agora-appbuilder-core 4.0.22-beta-10 → 4.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -249,7 +249,7 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
249
249
|
}),
|
|
250
250
|
PersistanceLevel.Session,
|
|
251
251
|
);
|
|
252
|
-
logger.
|
|
252
|
+
logger.log(
|
|
253
253
|
LogSource.NetworkRest,
|
|
254
254
|
'recording_start',
|
|
255
255
|
'Trying to start recording',
|
|
@@ -276,7 +276,7 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
276
276
|
})
|
|
277
277
|
.then((res: any) => {
|
|
278
278
|
if (res.status === 200) {
|
|
279
|
-
logger.
|
|
279
|
+
logger.log(
|
|
280
280
|
LogSource.NetworkRest,
|
|
281
281
|
'recording_start',
|
|
282
282
|
'start recording successfully',
|
|
@@ -322,34 +322,20 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
} else if (res.status === 500) {
|
|
325
|
-
setRecordingActive(false);
|
|
326
|
-
setInProgress(false);
|
|
327
|
-
events.send(
|
|
328
|
-
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
329
|
-
JSON.stringify({
|
|
330
|
-
action: RecordingActions.RECORDING_REQUEST_STATE.FAILED,
|
|
331
|
-
value: `${localUid}`,
|
|
332
|
-
}),
|
|
333
|
-
PersistanceLevel.Session,
|
|
334
|
-
);
|
|
335
325
|
showErrorToast(headingStartError, subheadingError);
|
|
336
326
|
throw Error(`Internal server error ${res.status}`);
|
|
337
327
|
} else {
|
|
338
|
-
setRecordingActive(false);
|
|
339
|
-
setInProgress(false);
|
|
340
|
-
events.send(
|
|
341
|
-
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
342
|
-
JSON.stringify({
|
|
343
|
-
action: RecordingActions.RECORDING_REQUEST_STATE.FAILED,
|
|
344
|
-
value: `${localUid}`,
|
|
345
|
-
}),
|
|
346
|
-
PersistanceLevel.Session,
|
|
347
|
-
);
|
|
348
328
|
showErrorToast(headingStartError);
|
|
349
329
|
throw Error(`Internal server error ${res.status}`);
|
|
350
330
|
}
|
|
351
331
|
})
|
|
352
332
|
.catch(err => {
|
|
333
|
+
logger.error(
|
|
334
|
+
LogSource.NetworkRest,
|
|
335
|
+
'recording_start',
|
|
336
|
+
'Error while start recording',
|
|
337
|
+
err,
|
|
338
|
+
);
|
|
353
339
|
setRecordingActive(false);
|
|
354
340
|
setInProgress(false);
|
|
355
341
|
events.send(
|
|
@@ -360,81 +346,81 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
360
346
|
}),
|
|
361
347
|
PersistanceLevel.Session,
|
|
362
348
|
);
|
|
363
|
-
logger.error(
|
|
364
|
-
LogSource.NetworkRest,
|
|
365
|
-
'recording_start',
|
|
366
|
-
'Error while start recording',
|
|
367
|
-
err,
|
|
368
|
-
);
|
|
369
349
|
});
|
|
370
350
|
};
|
|
371
351
|
|
|
372
|
-
const _stopRecording = useCallback(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
)
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
352
|
+
const _stopRecording = useCallback(
|
|
353
|
+
async (calledBy?: 'user' | 'bot' | 'bot-when-no-host') => {
|
|
354
|
+
/**
|
|
355
|
+
* Any host in the channel can stop recording.
|
|
356
|
+
*/
|
|
357
|
+
logger.log(
|
|
358
|
+
LogSource.Internals,
|
|
359
|
+
'RECORDING',
|
|
360
|
+
'_stopRecording API called',
|
|
361
|
+
{calledBy: calledBy},
|
|
362
|
+
);
|
|
363
|
+
events.send(
|
|
364
|
+
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
365
|
+
JSON.stringify({
|
|
366
|
+
action: RecordingActions.RECORDING_REQUEST_STATE.PENDING,
|
|
367
|
+
value: {uid: `${localUid}`, api: 'STOP_RECORDING'},
|
|
368
|
+
}),
|
|
369
|
+
PersistanceLevel.Session,
|
|
370
|
+
);
|
|
371
|
+
fetchRetry(`${$config.BACKEND_ENDPOINT}/v1/recording/stop`, {
|
|
372
|
+
method: 'POST',
|
|
373
|
+
headers: {
|
|
374
|
+
'Content-Type': 'application/json',
|
|
375
|
+
authorization: store.token ? `Bearer ${store.token}` : '',
|
|
376
|
+
},
|
|
377
|
+
body: JSON.stringify({
|
|
378
|
+
passphrase: roomId.host,
|
|
379
|
+
mode: recordingMode.toLowerCase(),
|
|
380
|
+
}),
|
|
381
|
+
})
|
|
382
|
+
.then(res => {
|
|
383
|
+
setInProgress(false);
|
|
384
|
+
if (res.status === 200 || res.status === 202) {
|
|
385
|
+
logger.log(
|
|
386
|
+
LogSource.NetworkRest,
|
|
387
|
+
'recording_stop',
|
|
388
|
+
'_stopRecording successfull',
|
|
389
|
+
res,
|
|
390
|
+
);
|
|
391
|
+
/**
|
|
392
|
+
* 1. Once the backend sucessfuly stops recording, send message
|
|
393
|
+
* in the channel indicating that cloud recording is now inactive.
|
|
394
|
+
*/
|
|
395
|
+
log('Recording-bot: recording stopped successfully');
|
|
396
|
+
events.send(
|
|
397
|
+
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
398
|
+
JSON.stringify({
|
|
399
|
+
action: RecordingActions.RECORDING_REQUEST_STATE.STOPPED,
|
|
400
|
+
value: `${localUid}`,
|
|
401
|
+
}),
|
|
402
|
+
PersistanceLevel.Session,
|
|
403
|
+
);
|
|
404
|
+
// 2. set the local recording state to false to update the UI
|
|
405
|
+
setRecordingActive(false);
|
|
406
|
+
} else if (res.status === 500) {
|
|
407
|
+
showErrorToast(headingStopError, subheadingError);
|
|
408
|
+
throw Error(`Internal server error ${res.status}`);
|
|
409
|
+
} else {
|
|
410
|
+
showErrorToast(headingStopError);
|
|
411
|
+
// return Promise.reject(res);
|
|
412
|
+
throw Error(`Internal server error ${res.status}`);
|
|
413
|
+
}
|
|
414
|
+
})
|
|
415
|
+
.catch(err => {
|
|
429
416
|
logger.error(
|
|
430
417
|
LogSource.NetworkRest,
|
|
431
418
|
'recording_stop',
|
|
432
|
-
'Error
|
|
433
|
-
|
|
419
|
+
'_stopRecording Error',
|
|
420
|
+
err,
|
|
434
421
|
);
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
} else {
|
|
422
|
+
setInProgress(false);
|
|
423
|
+
log('stop recording', err);
|
|
438
424
|
events.send(
|
|
439
425
|
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
440
426
|
JSON.stringify({
|
|
@@ -443,41 +429,31 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
443
429
|
}),
|
|
444
430
|
PersistanceLevel.Session,
|
|
445
431
|
);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
.catch(err => {
|
|
458
|
-
setInProgress(false);
|
|
459
|
-
log('stop recording', err);
|
|
460
|
-
events.send(
|
|
461
|
-
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
462
|
-
JSON.stringify({
|
|
463
|
-
action: RecordingActions.RECORDING_REQUEST_STATE.STOP_FAILED,
|
|
464
|
-
value: `${localUid}`,
|
|
465
|
-
}),
|
|
466
|
-
PersistanceLevel.Session,
|
|
467
|
-
);
|
|
468
|
-
});
|
|
469
|
-
}, [
|
|
470
|
-
headingStopError,
|
|
471
|
-
roomId.host,
|
|
472
|
-
setRecordingActive,
|
|
473
|
-
store.token,
|
|
474
|
-
subheadingError,
|
|
475
|
-
localUid,
|
|
476
|
-
]);
|
|
432
|
+
});
|
|
433
|
+
},
|
|
434
|
+
[
|
|
435
|
+
headingStopError,
|
|
436
|
+
roomId.host,
|
|
437
|
+
setRecordingActive,
|
|
438
|
+
store.token,
|
|
439
|
+
subheadingError,
|
|
440
|
+
localUid,
|
|
441
|
+
],
|
|
442
|
+
);
|
|
477
443
|
|
|
478
444
|
const stopRecording = useCallback(() => {
|
|
479
445
|
setInProgress(true);
|
|
480
446
|
if (recordingMode === 'WEB') {
|
|
447
|
+
logger.log(
|
|
448
|
+
LogSource.Internals,
|
|
449
|
+
'RECORDING',
|
|
450
|
+
'stopRecording function is called',
|
|
451
|
+
{
|
|
452
|
+
recordingBotId: RECORDING_BOT_UID,
|
|
453
|
+
recordingMode: recordingMode,
|
|
454
|
+
},
|
|
455
|
+
);
|
|
456
|
+
//add logger
|
|
481
457
|
log('Stopping recording by sending event to bot');
|
|
482
458
|
// send stop request to bot
|
|
483
459
|
events.send(
|
|
@@ -490,8 +466,15 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
490
466
|
RECORDING_BOT_UID, // bot uid
|
|
491
467
|
);
|
|
492
468
|
} else {
|
|
469
|
+
logger.log(
|
|
470
|
+
LogSource.Internals,
|
|
471
|
+
'RECORDING',
|
|
472
|
+
'stopRecording function is called',
|
|
473
|
+
{recordingMode: recordingMode},
|
|
474
|
+
);
|
|
493
475
|
log('Stopping recording by calling stop');
|
|
494
|
-
|
|
476
|
+
//add logger - mix mode
|
|
477
|
+
_stopRecording('user');
|
|
495
478
|
}
|
|
496
479
|
}, [_stopRecording, localUid]);
|
|
497
480
|
|
|
@@ -557,11 +540,22 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
557
540
|
// Events
|
|
558
541
|
useEffect(() => {
|
|
559
542
|
events.on(EventNames.RECORDING_STATE_ATTRIBUTE, data => {
|
|
543
|
+
logger.log(
|
|
544
|
+
LogSource.Internals,
|
|
545
|
+
'RECORDING',
|
|
546
|
+
'recording_state event listener triggered',
|
|
547
|
+
data,
|
|
548
|
+
);
|
|
560
549
|
log('recording_state attribute received', data);
|
|
561
550
|
const payload = JSON.parse(data.payload);
|
|
562
551
|
const action = payload.action;
|
|
563
552
|
switch (action) {
|
|
564
553
|
case RecordingActions.RECORDING_REQUEST_STATE.PENDING:
|
|
554
|
+
logger.log(
|
|
555
|
+
LogSource.Internals,
|
|
556
|
+
'RECORDING',
|
|
557
|
+
'recording_state -> PENDING',
|
|
558
|
+
);
|
|
565
559
|
setInProgress(true);
|
|
566
560
|
if (isRecordingBot && payload?.value?.api === 'START_RECORDING') {
|
|
567
561
|
log('Recording-bot: sending event that recording has started');
|
|
@@ -583,19 +577,43 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
583
577
|
}
|
|
584
578
|
break;
|
|
585
579
|
case RecordingActions.RECORDING_REQUEST_STATE.STARTED_MIX:
|
|
580
|
+
logger.log(
|
|
581
|
+
LogSource.Internals,
|
|
582
|
+
'RECORDING',
|
|
583
|
+
'recording_state -> STARTED_MIX',
|
|
584
|
+
);
|
|
585
|
+
//add logger
|
|
586
586
|
setInProgress(false);
|
|
587
587
|
setRecordingActive(true);
|
|
588
588
|
break;
|
|
589
589
|
case RecordingActions.RECORDING_REQUEST_STATE.STARTED_WEB:
|
|
590
|
+
logger.log(
|
|
591
|
+
LogSource.Internals,
|
|
592
|
+
'RECORDING',
|
|
593
|
+
'recording_state -> STARTED_WEB',
|
|
594
|
+
);
|
|
595
|
+
//add logger
|
|
590
596
|
setInProgress(false);
|
|
591
597
|
setRecordingActive(true);
|
|
592
598
|
break;
|
|
593
599
|
case RecordingActions.RECORDING_REQUEST_STATE.FAILED:
|
|
600
|
+
logger.log(
|
|
601
|
+
LogSource.Internals,
|
|
602
|
+
'RECORDING',
|
|
603
|
+
'recording_state -> FAILED',
|
|
604
|
+
);
|
|
605
|
+
//add logger
|
|
594
606
|
setInProgress(false);
|
|
595
607
|
setRecordingActive(false);
|
|
596
608
|
showErrorToast(headingStartError, subheadingError);
|
|
597
609
|
break;
|
|
598
610
|
case RecordingActions.RECORDING_REQUEST_STATE.STOPPED:
|
|
611
|
+
logger.log(
|
|
612
|
+
LogSource.Internals,
|
|
613
|
+
'RECORDING',
|
|
614
|
+
'recording_state -> STOPPED',
|
|
615
|
+
);
|
|
616
|
+
//add logger
|
|
599
617
|
setInProgress(false);
|
|
600
618
|
setRecordingActive(false);
|
|
601
619
|
break;
|
|
@@ -603,6 +621,11 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
603
621
|
* The below case is for enable stop button again if stop recording api failed. for remote users
|
|
604
622
|
*/
|
|
605
623
|
case RecordingActions.RECORDING_REQUEST_STATE.STOP_FAILED:
|
|
624
|
+
logger.log(
|
|
625
|
+
LogSource.Internals,
|
|
626
|
+
'RECORDING',
|
|
627
|
+
'recording_state -> STOP_FAILED',
|
|
628
|
+
);
|
|
606
629
|
setInProgress(false);
|
|
607
630
|
setRecordingActive(true);
|
|
608
631
|
break;
|
|
@@ -611,7 +634,12 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
611
634
|
* new user gets the correct state or not
|
|
612
635
|
*/
|
|
613
636
|
case RecordingActions.REQUEST_TO_STOP_RECORDING:
|
|
614
|
-
|
|
637
|
+
logger.log(
|
|
638
|
+
LogSource.Internals,
|
|
639
|
+
'RECORDING',
|
|
640
|
+
'recording_state -> REQUEST_TO_STOP_RECORDING',
|
|
641
|
+
);
|
|
642
|
+
_stopRecording('bot');
|
|
615
643
|
break;
|
|
616
644
|
default:
|
|
617
645
|
break;
|
|
@@ -674,6 +702,18 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
674
702
|
areHostsInChannel: hostUids?.length,
|
|
675
703
|
stopAPIcalled: stopAPICalledByBotOnce.current,
|
|
676
704
|
});
|
|
705
|
+
|
|
706
|
+
logger.log(
|
|
707
|
+
LogSource.Internals,
|
|
708
|
+
'RECORDING',
|
|
709
|
+
'Recording-bot: Checking if bot should stop recording',
|
|
710
|
+
{
|
|
711
|
+
shouldStopRecording: shouldStopRecording(),
|
|
712
|
+
isRecordingBot: isRecordingBot,
|
|
713
|
+
areHostsInChannel: hostUids?.length,
|
|
714
|
+
stopAPIcalled: stopAPICalledByBotOnce.current,
|
|
715
|
+
},
|
|
716
|
+
);
|
|
677
717
|
if (shouldStopRecording()) {
|
|
678
718
|
logger.log(
|
|
679
719
|
LogSource.Internals,
|
|
@@ -681,15 +721,21 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
681
721
|
'Recording-bot: will end the meeting after 15 seconds if no one joins',
|
|
682
722
|
);
|
|
683
723
|
timer = setTimeout(() => {
|
|
684
|
-
//
|
|
724
|
+
//Check again if still there are some users
|
|
685
725
|
logger.log(
|
|
686
726
|
LogSource.Internals,
|
|
687
727
|
'RECORDING',
|
|
688
728
|
'Recording-bot: trying to stop recording',
|
|
729
|
+
{
|
|
730
|
+
shouldStopRecording: shouldStopRecording(),
|
|
731
|
+
isRecordingBot: isRecordingBot,
|
|
732
|
+
areHostsInChannel: hostUids?.length,
|
|
733
|
+
stopAPIcalled: stopAPICalledByBotOnce.current,
|
|
734
|
+
},
|
|
689
735
|
);
|
|
690
736
|
stopAPICalledByBotOnce.current = true;
|
|
691
737
|
clearTimeout(timer);
|
|
692
|
-
_stopRecording();
|
|
738
|
+
_stopRecording('bot-when-no-host');
|
|
693
739
|
// Run after 15 seconds
|
|
694
740
|
}, 15000);
|
|
695
741
|
log('Recording-bot: timer starts, timerId - ', timer);
|