Переглянути джерело

feat(external_api) add ability to start transcriptions together with recordings

factor2
Saúl Ibarra Corretgé 1 рік тому
джерело
коміт
d8079a4232
2 змінених файлів з 29 додано та 10 видалено
  1. 25
    8
      modules/API/API.js
  2. 4
    2
      modules/API/external/external_api.js

+ 25
- 8
modules/API/API.js Переглянути файл

@@ -100,7 +100,7 @@ import {
100 100
 } from '../../react/features/participants-pane/actions';
101 101
 import { getParticipantsPaneOpen, isForceMuted } from '../../react/features/participants-pane/functions';
102 102
 import { startLocalVideoRecording, stopLocalVideoRecording } from '../../react/features/recording/actions.any';
103
-import { RECORDING_TYPES } from '../../react/features/recording/constants';
103
+import { RECORDING_METADATA_ID, RECORDING_TYPES } from '../../react/features/recording/constants';
104 104
 import { getActiveSession, supportsLocalRecording } from '../../react/features/recording/functions';
105 105
 import { startAudioScreenShareFlow, startScreenShareFlow } from '../../react/features/screen-share/actions';
106 106
 import { isScreenAudioSupported } from '../../react/features/screen-share/functions';
@@ -629,6 +629,7 @@ function initCommands() {
629 629
          * @param { string } arg.youtubeStreamKey - The youtube stream key.
630 630
          * @param { string } arg.youtubeBroadcastID - The youtube broadcast ID.
631 631
          * @param { Object } arg.extraMetadata - Any extra metadata params for file recording.
632
+         * @param { boolean } arg.transcription - Whether a transcription should be started or not.
632 633
          * @returns {void}
633 634
          */
634 635
         'start-recording': ({
@@ -640,7 +641,8 @@ function initCommands() {
640 641
             rtmpBroadcastID,
641 642
             youtubeStreamKey,
642 643
             youtubeBroadcastID,
643
-            extraMetadata = {}
644
+            extraMetadata = {},
645
+            transcription
644 646
         }) => {
645 647
             const state = APP.store.getState();
646 648
             const conference = getCurrentConference(state);
@@ -715,25 +717,33 @@ function initCommands() {
715 717
                     mode: JitsiRecordingConstants.mode.STREAM,
716 718
                     streamId: youtubeStreamKey || rtmpStreamKey
717 719
                 };
718
-            } else {
719
-                logger.error('Invalid recording mode provided');
720
-
721
-                return;
722 720
             }
723 721
 
724 722
             if (isScreenshotCaptureEnabled(state, true, false)) {
725 723
                 APP.store.dispatch(toggleScreenshotCaptureSummary(true));
726 724
             }
727
-            conference.startRecording(recordingConfig);
725
+
726
+            // Start audio / video recording, if requested.
727
+            if (typeof recordingConfig !== 'undefined') {
728
+                conference.startRecording(recordingConfig);
729
+            }
730
+
731
+            if (transcription) {
732
+                APP.store.dispatch(setRequestingSubtitles(true, false, null));
733
+                conference.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {
734
+                    isTranscribingEnabled: true
735
+                });
736
+            }
728 737
         },
729 738
 
730 739
         /**
731 740
          * Stops a recording or streaming in progress.
732 741
          *
733 742
          * @param {string} mode - `local`, `file` or `stream`.
743
+         * @param {boolean} transcription - Whether the transcription needs to be stopped.
734 744
          * @returns {void}
735 745
          */
736
-        'stop-recording': mode => {
746
+        'stop-recording': (mode, transcription) => {
737 747
             const state = APP.store.getState();
738 748
             const conference = getCurrentConference(state);
739 749
 
@@ -743,6 +753,13 @@ function initCommands() {
743 753
                 return;
744 754
             }
745 755
 
756
+            if (transcription) {
757
+                APP.store.dispatch(setRequestingSubtitles(false, false, null));
758
+                conference.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {
759
+                    isTranscribingEnabled: false
760
+                });
761
+            }
762
+
746 763
             if (mode === 'local') {
747 764
                 APP.store.dispatch(stopLocalVideoRecording());
748 765
 

+ 4
- 2
modules/API/external/external_api.js Переглянути файл

@@ -1446,6 +1446,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
1446 1446
      * @param { string } options.youtubeStreamKey - The youtube stream key.
1447 1447
      * @param { string } options.youtubeBroadcastID - The youtube broadcast ID.
1448 1448
      * @param {Object } options.extraMetadata - Any extra metadata params for file recording.
1449
+     * @param { boolean } arg.transcription - Whether a transcription should be started or not.
1449 1450
      * @returns {void}
1450 1451
      */
1451 1452
     startRecording(options) {
@@ -1456,10 +1457,11 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
1456 1457
      * Stops a recording or streaming session that is in progress.
1457 1458
      *
1458 1459
      * @param {string} mode - `file` or `stream`.
1460
+     * @param {boolean} transcription - Whether the transcription needs to be stopped.
1459 1461
      * @returns {void}
1460 1462
      */
1461
-    stopRecording(mode) {
1462
-        this.executeCommand('stopRecording', mode);
1463
+    stopRecording(mode, transcription) {
1464
+        this.executeCommand('stopRecording', mode, transcription);
1463 1465
     }
1464 1466
 
1465 1467
     /**

Завантаження…
Відмінити
Зберегти