agora-appbuilder-core 4.0.22-beta-9 → 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
|
@@ -117,6 +117,7 @@ enum RECORDING_REQUEST_STATE {
|
|
|
117
117
|
STARTED_MIX = 'STARTED_MIX',
|
|
118
118
|
STARTED_WEB = 'STARTED_WEB',
|
|
119
119
|
STOPPED = 'STOPPED',
|
|
120
|
+
STOP_FAILED = 'STOP_FAILED',
|
|
120
121
|
FAILED = 'FAILED',
|
|
121
122
|
}
|
|
122
123
|
const RecordingActions = {
|
|
@@ -248,7 +249,7 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
248
249
|
}),
|
|
249
250
|
PersistanceLevel.Session,
|
|
250
251
|
);
|
|
251
|
-
logger.
|
|
252
|
+
logger.log(
|
|
252
253
|
LogSource.NetworkRest,
|
|
253
254
|
'recording_start',
|
|
254
255
|
'Trying to start recording',
|
|
@@ -275,7 +276,7 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
275
276
|
})
|
|
276
277
|
.then((res: any) => {
|
|
277
278
|
if (res.status === 200) {
|
|
278
|
-
logger.
|
|
279
|
+
logger.log(
|
|
279
280
|
LogSource.NetworkRest,
|
|
280
281
|
'recording_start',
|
|
281
282
|
'start recording successfully',
|
|
@@ -329,6 +330,12 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
329
330
|
}
|
|
330
331
|
})
|
|
331
332
|
.catch(err => {
|
|
333
|
+
logger.error(
|
|
334
|
+
LogSource.NetworkRest,
|
|
335
|
+
'recording_start',
|
|
336
|
+
'Error while start recording',
|
|
337
|
+
err,
|
|
338
|
+
);
|
|
332
339
|
setRecordingActive(false);
|
|
333
340
|
setInProgress(false);
|
|
334
341
|
events.send(
|
|
@@ -339,109 +346,114 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
339
346
|
}),
|
|
340
347
|
PersistanceLevel.Session,
|
|
341
348
|
);
|
|
342
|
-
logger.error(
|
|
343
|
-
LogSource.NetworkRest,
|
|
344
|
-
'recording_start',
|
|
345
|
-
'Error while start recording',
|
|
346
|
-
err,
|
|
347
|
-
);
|
|
348
349
|
});
|
|
349
350
|
};
|
|
350
351
|
|
|
351
|
-
const _stopRecording = useCallback(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
'
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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 => {
|
|
416
|
+
logger.error(
|
|
371
417
|
LogSource.NetworkRest,
|
|
372
418
|
'recording_stop',
|
|
373
|
-
'
|
|
374
|
-
|
|
419
|
+
'_stopRecording Error',
|
|
420
|
+
err,
|
|
375
421
|
);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
* in the channel indicating that cloud recording is now inactive.
|
|
379
|
-
*/
|
|
380
|
-
log('Recording-bot: recording stopped successfully');
|
|
422
|
+
setInProgress(false);
|
|
423
|
+
log('stop recording', err);
|
|
381
424
|
events.send(
|
|
382
425
|
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
383
426
|
JSON.stringify({
|
|
384
|
-
action: RecordingActions.RECORDING_REQUEST_STATE.
|
|
427
|
+
action: RecordingActions.RECORDING_REQUEST_STATE.STOP_FAILED,
|
|
385
428
|
value: `${localUid}`,
|
|
386
429
|
}),
|
|
387
430
|
PersistanceLevel.Session,
|
|
388
431
|
);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
} else {
|
|
401
|
-
logger.error(
|
|
402
|
-
LogSource.NetworkRest,
|
|
403
|
-
'recording_stop',
|
|
404
|
-
'Error while stopping recording',
|
|
405
|
-
res,
|
|
406
|
-
);
|
|
407
|
-
showErrorToast(headingStopError);
|
|
408
|
-
// return Promise.reject(res);
|
|
409
|
-
throw Error(`Internal server error ${res.status}`);
|
|
410
|
-
}
|
|
411
|
-
})
|
|
412
|
-
.catch(err => {
|
|
413
|
-
setRecordingActive(false);
|
|
414
|
-
setInProgress(false);
|
|
415
|
-
log('stop recording', err);
|
|
416
|
-
events.send(
|
|
417
|
-
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
418
|
-
JSON.stringify({
|
|
419
|
-
action: RecordingActions.RECORDING_REQUEST_STATE.FAILED,
|
|
420
|
-
value: `${localUid}`,
|
|
421
|
-
}),
|
|
422
|
-
PersistanceLevel.Session,
|
|
423
|
-
);
|
|
424
|
-
});
|
|
425
|
-
}, [
|
|
426
|
-
headingStopError,
|
|
427
|
-
roomId.host,
|
|
428
|
-
setRecordingActive,
|
|
429
|
-
store.token,
|
|
430
|
-
subheadingError,
|
|
431
|
-
localUid,
|
|
432
|
-
]);
|
|
432
|
+
});
|
|
433
|
+
},
|
|
434
|
+
[
|
|
435
|
+
headingStopError,
|
|
436
|
+
roomId.host,
|
|
437
|
+
setRecordingActive,
|
|
438
|
+
store.token,
|
|
439
|
+
subheadingError,
|
|
440
|
+
localUid,
|
|
441
|
+
],
|
|
442
|
+
);
|
|
433
443
|
|
|
434
444
|
const stopRecording = useCallback(() => {
|
|
435
445
|
setInProgress(true);
|
|
436
|
-
events.send(
|
|
437
|
-
EventNames.RECORDING_STATE_ATTRIBUTE,
|
|
438
|
-
JSON.stringify({
|
|
439
|
-
action: RecordingActions.RECORDING_REQUEST_STATE.PENDING,
|
|
440
|
-
value: {uid: `${localUid}`, api: 'STOP_RECORDING'},
|
|
441
|
-
}),
|
|
442
|
-
PersistanceLevel.Session,
|
|
443
|
-
);
|
|
444
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
|
|
445
457
|
log('Stopping recording by sending event to bot');
|
|
446
458
|
// send stop request to bot
|
|
447
459
|
events.send(
|
|
@@ -454,8 +466,15 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
454
466
|
RECORDING_BOT_UID, // bot uid
|
|
455
467
|
);
|
|
456
468
|
} else {
|
|
469
|
+
logger.log(
|
|
470
|
+
LogSource.Internals,
|
|
471
|
+
'RECORDING',
|
|
472
|
+
'stopRecording function is called',
|
|
473
|
+
{recordingMode: recordingMode},
|
|
474
|
+
);
|
|
457
475
|
log('Stopping recording by calling stop');
|
|
458
|
-
|
|
476
|
+
//add logger - mix mode
|
|
477
|
+
_stopRecording('user');
|
|
459
478
|
}
|
|
460
479
|
}, [_stopRecording, localUid]);
|
|
461
480
|
|
|
@@ -521,11 +540,22 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
521
540
|
// Events
|
|
522
541
|
useEffect(() => {
|
|
523
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
|
+
);
|
|
524
549
|
log('recording_state attribute received', data);
|
|
525
550
|
const payload = JSON.parse(data.payload);
|
|
526
551
|
const action = payload.action;
|
|
527
552
|
switch (action) {
|
|
528
553
|
case RecordingActions.RECORDING_REQUEST_STATE.PENDING:
|
|
554
|
+
logger.log(
|
|
555
|
+
LogSource.Internals,
|
|
556
|
+
'RECORDING',
|
|
557
|
+
'recording_state -> PENDING',
|
|
558
|
+
);
|
|
529
559
|
setInProgress(true);
|
|
530
560
|
if (isRecordingBot && payload?.value?.api === 'START_RECORDING') {
|
|
531
561
|
log('Recording-bot: sending event that recording has started');
|
|
@@ -547,28 +577,69 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
547
577
|
}
|
|
548
578
|
break;
|
|
549
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
|
|
550
586
|
setInProgress(false);
|
|
551
587
|
setRecordingActive(true);
|
|
552
588
|
break;
|
|
553
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
|
|
554
596
|
setInProgress(false);
|
|
555
597
|
setRecordingActive(true);
|
|
556
598
|
break;
|
|
557
599
|
case RecordingActions.RECORDING_REQUEST_STATE.FAILED:
|
|
600
|
+
logger.log(
|
|
601
|
+
LogSource.Internals,
|
|
602
|
+
'RECORDING',
|
|
603
|
+
'recording_state -> FAILED',
|
|
604
|
+
);
|
|
605
|
+
//add logger
|
|
558
606
|
setInProgress(false);
|
|
559
607
|
setRecordingActive(false);
|
|
560
608
|
showErrorToast(headingStartError, subheadingError);
|
|
561
609
|
break;
|
|
562
610
|
case RecordingActions.RECORDING_REQUEST_STATE.STOPPED:
|
|
611
|
+
logger.log(
|
|
612
|
+
LogSource.Internals,
|
|
613
|
+
'RECORDING',
|
|
614
|
+
'recording_state -> STOPPED',
|
|
615
|
+
);
|
|
616
|
+
//add logger
|
|
563
617
|
setInProgress(false);
|
|
564
618
|
setRecordingActive(false);
|
|
565
619
|
break;
|
|
620
|
+
/**
|
|
621
|
+
* The below case is for enable stop button again if stop recording api failed. for remote users
|
|
622
|
+
*/
|
|
623
|
+
case RecordingActions.RECORDING_REQUEST_STATE.STOP_FAILED:
|
|
624
|
+
logger.log(
|
|
625
|
+
LogSource.Internals,
|
|
626
|
+
'RECORDING',
|
|
627
|
+
'recording_state -> STOP_FAILED',
|
|
628
|
+
);
|
|
629
|
+
setInProgress(false);
|
|
630
|
+
setRecordingActive(true);
|
|
631
|
+
break;
|
|
566
632
|
/**
|
|
567
633
|
* The below case is not persisted, hence we need not worry about whether the
|
|
568
634
|
* new user gets the correct state or not
|
|
569
635
|
*/
|
|
570
636
|
case RecordingActions.REQUEST_TO_STOP_RECORDING:
|
|
571
|
-
|
|
637
|
+
logger.log(
|
|
638
|
+
LogSource.Internals,
|
|
639
|
+
'RECORDING',
|
|
640
|
+
'recording_state -> REQUEST_TO_STOP_RECORDING',
|
|
641
|
+
);
|
|
642
|
+
_stopRecording('bot');
|
|
572
643
|
break;
|
|
573
644
|
default:
|
|
574
645
|
break;
|
|
@@ -631,6 +702,18 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
631
702
|
areHostsInChannel: hostUids?.length,
|
|
632
703
|
stopAPIcalled: stopAPICalledByBotOnce.current,
|
|
633
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
|
+
);
|
|
634
717
|
if (shouldStopRecording()) {
|
|
635
718
|
logger.log(
|
|
636
719
|
LogSource.Internals,
|
|
@@ -638,15 +721,21 @@ const RecordingProvider = (props: RecordingProviderProps) => {
|
|
|
638
721
|
'Recording-bot: will end the meeting after 15 seconds if no one joins',
|
|
639
722
|
);
|
|
640
723
|
timer = setTimeout(() => {
|
|
641
|
-
//
|
|
724
|
+
//Check again if still there are some users
|
|
642
725
|
logger.log(
|
|
643
726
|
LogSource.Internals,
|
|
644
727
|
'RECORDING',
|
|
645
728
|
'Recording-bot: trying to stop recording',
|
|
729
|
+
{
|
|
730
|
+
shouldStopRecording: shouldStopRecording(),
|
|
731
|
+
isRecordingBot: isRecordingBot,
|
|
732
|
+
areHostsInChannel: hostUids?.length,
|
|
733
|
+
stopAPIcalled: stopAPICalledByBotOnce.current,
|
|
734
|
+
},
|
|
646
735
|
);
|
|
647
736
|
stopAPICalledByBotOnce.current = true;
|
|
648
737
|
clearTimeout(timer);
|
|
649
|
-
_stopRecording();
|
|
738
|
+
_stopRecording('bot-when-no-host');
|
|
650
739
|
// Run after 15 seconds
|
|
651
740
|
}, 15000);
|
|
652
741
|
log('Recording-bot: timer starts, timerId - ', timer);
|