瀏覽代碼

feat(external_api) include transcription state in recordingStatusChanged

factor2
Saúl Ibarra Corretgé 1 年之前
父節點
當前提交
0be3e2b103
共有 3 個文件被更改,包括 32 次插入16 次删除
  1. 4
    2
      modules/API/API.js
  2. 17
    11
      react/features/recording/middleware.ts
  3. 11
    3
      react/features/transcribing/subscriber.ts

+ 4
- 2
modules/API/API.js 查看文件

@@ -1917,14 +1917,16 @@ class API {
1917 1917
      * @param {boolean} on - True if recording is on, false otherwise.
1918 1918
      * @param {string} mode - Stream or file or local.
1919 1919
      * @param {string} error - Error type or null if success.
1920
+     * @param {boolean} transcription - True if a transcription is being recorded, false otherwise.
1920 1921
      * @returns {void}
1921 1922
      */
1922
-    notifyRecordingStatusChanged(on, mode, error) {
1923
+    notifyRecordingStatusChanged(on, mode, error, transcription) {
1923 1924
         this._sendEvent({
1924 1925
             name: 'recording-status-changed',
1925 1926
             on,
1926 1927
             mode,
1927
-            error
1928
+            error,
1929
+            transcription
1928 1930
         });
1929 1931
     }
1930 1932
 

+ 17
- 11
react/features/recording/middleware.ts 查看文件

@@ -101,7 +101,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => async action =>
101 101
             (recorderSession: any) => {
102 102
                 if (recorderSession) {
103 103
                     recorderSession.getID() && dispatch(updateRecordingSessionData(recorderSession));
104
-                    recorderSession.getError() && _showRecordingErrorNotification(recorderSession, dispatch);
104
+                    recorderSession.getError() && _showRecordingErrorNotification(recorderSession, dispatch, getState);
105 105
                 }
106 106
 
107 107
                 return;
@@ -133,7 +133,8 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => async action =>
133 133
             dispatch(updateLocalRecordingStatus(true, onlySelf));
134 134
             sendAnalytics(createRecordingEvent('started', `local${onlySelf ? '.self' : ''}`));
135 135
             if (typeof APP !== 'undefined') {
136
-                APP.API.notifyRecordingStatusChanged(true, 'local');
136
+                APP.API.notifyRecordingStatusChanged(
137
+                    true, 'local', undefined, isRecorderTranscriptionsRunning(getState()));
137 138
             }
138 139
         } catch (err: any) {
139 140
             logger.error('Capture failed', err);
@@ -154,7 +155,8 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => async action =>
154 155
             };
155 156
 
156 157
             if (typeof APP !== 'undefined') {
157
-                APP.API.notifyRecordingStatusChanged(false, 'local', err.message);
158
+                APP.API.notifyRecordingStatusChanged(
159
+                    false, 'local', err.message, isRecorderTranscriptionsRunning(getState()));
158 160
             }
159 161
 
160 162
             dispatch(showErrorNotification(props, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
@@ -172,7 +174,8 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => async action =>
172 174
                 dispatch(playSound(RECORDING_OFF_SOUND_ID));
173 175
             }
174 176
             if (typeof APP !== 'undefined') {
175
-                APP.API.notifyRecordingStatusChanged(false, 'local');
177
+                APP.API.notifyRecordingStatusChanged(
178
+                    false, 'local', undefined, isRecorderTranscriptionsRunning(getState()));
176 179
             }
177 180
         }
178 181
         break;
@@ -237,7 +240,8 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => async action =>
237 240
                     }
238 241
 
239 242
                     if (typeof APP !== 'undefined') {
240
-                        APP.API.notifyRecordingStatusChanged(true, mode);
243
+                        APP.API.notifyRecordingStatusChanged(
244
+                            true, mode, undefined, isRecorderTranscriptionsRunning(state));
241 245
                     }
242 246
                 }
243 247
             } else if (updatedSessionData?.status === OFF && oldSessionData?.status !== OFF) {
@@ -269,7 +273,8 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => async action =>
269 273
                 }
270 274
 
271 275
                 if (typeof APP !== 'undefined') {
272
-                    APP.API.notifyRecordingStatusChanged(false, mode);
276
+                    APP.API.notifyRecordingStatusChanged(
277
+                        false, mode, undefined, isRecorderTranscriptionsRunning(state));
273 278
                 }
274 279
             }
275 280
         }
@@ -312,14 +317,15 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => async action =>
312 317
  * in recording session.
313 318
  *
314 319
  * @private
315
- * @param {Object} recorderSession - The recorder session model from the
320
+ * @param {Object} session - The recorder session model from the
316 321
  * lib.
317 322
  * @param {Dispatch} dispatch - The Redux Dispatch function.
323
+ * @param {Function} getState - The Redux getState function.
318 324
  * @returns {void}
319 325
  */
320
-function _showRecordingErrorNotification(recorderSession: any, dispatch: IStore['dispatch']) {
321
-    const mode = recorderSession.getMode();
322
-    const error = recorderSession.getError();
326
+function _showRecordingErrorNotification(session: any, dispatch: IStore['dispatch'], getState: IStore['getState']) {
327
+    const mode = session.getMode();
328
+    const error = session.getError();
323 329
     const isStreamMode = mode === JitsiMeetJS.constants.recording.mode.STREAM;
324 330
 
325 331
     switch (error) {
@@ -367,6 +373,6 @@ function _showRecordingErrorNotification(recorderSession: any, dispatch: IStore[
367 373
     }
368 374
 
369 375
     if (typeof APP !== 'undefined') {
370
-        APP.API.notifyRecordingStatusChanged(false, mode, error);
376
+        APP.API.notifyRecordingStatusChanged(false, mode, error, isRecorderTranscriptionsRunning(getState()));
371 377
     }
372 378
 }

+ 11
- 3
react/features/transcribing/subscriber.ts 查看文件

@@ -7,6 +7,7 @@ import { playSound } from '../base/sounds/actions';
7 7
 import { showNotification } from '../notifications/actions';
8 8
 import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
9 9
 import { RECORDING_OFF_SOUND_ID, RECORDING_ON_SOUND_ID } from '../recording/constants';
10
+import { isLiveStreamingRunning, isRecordingRunning } from '../recording/functions';
10 11
 
11 12
 import { isRecorderTranscriptionsRunning } from './functions';
12 13
 
@@ -17,10 +18,10 @@ StateListenerRegistry.register(
17 18
     /* selector */ isRecorderTranscriptionsRunning,
18 19
     /* listener */ (isRecorderTranscriptionsRunningValue, { getState, dispatch }) => {
19 20
         if (isRecorderTranscriptionsRunningValue) {
20
-            notifyTranscribingStatusChanged(true);
21
+            notifyTranscribingStatusChanged(getState, true);
21 22
             maybeEmitRecordingNotification(dispatch, getState, true);
22 23
         } else {
23
-            notifyTranscribingStatusChanged(false);
24
+            notifyTranscribingStatusChanged(getState, false);
24 25
             maybeEmitRecordingNotification(dispatch, getState, false);
25 26
         }
26 27
     }
@@ -58,11 +59,18 @@ function maybeEmitRecordingNotification(dispatch: IStore['dispatch'], getState:
58 59
 /**
59 60
  * Notify external application (if API is enabled) that transcribing has started or stopped.
60 61
  *
62
+ * @param {Function} getState - The Redux state.
61 63
  * @param {boolean} on - True if transcribing is on, false otherwise.
62 64
  * @returns {void}
63 65
  */
64
-function notifyTranscribingStatusChanged(on: boolean) {
66
+function notifyTranscribingStatusChanged(getState: IStore['getState'], on: boolean) {
65 67
     if (typeof APP !== 'undefined') {
68
+        const state = getState();
69
+        const isRecording = isRecordingRunning(state);
70
+        const isStreaming = isLiveStreamingRunning(state);
71
+        const mode = isRecording ? JitsiRecordingConstants.mode.FILE : JitsiRecordingConstants.mode.STREAM;
72
+
73
+        APP.API.notifyRecordingStatusChanged(isRecording || isStreaming, mode, undefined, on);
66 74
         APP.API.notifyTranscribingStatusChanged(on);
67 75
     }
68 76
 }

Loading…
取消
儲存