From d8079a4232bc017c656bf1716aa69c20c701b9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 21 Jun 2024 12:23:05 +0200 Subject: [PATCH] feat(external_api) add ability to start transcriptions together with recordings --- modules/API/API.js | 33 +++++++++++++++++++++------- modules/API/external/external_api.js | 6 +++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/modules/API/API.js b/modules/API/API.js index cb3907280e22..c06ac0190c08 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -100,7 +100,7 @@ import { } from '../../react/features/participants-pane/actions'; import { getParticipantsPaneOpen, isForceMuted } from '../../react/features/participants-pane/functions'; import { startLocalVideoRecording, stopLocalVideoRecording } from '../../react/features/recording/actions.any'; -import { RECORDING_TYPES } from '../../react/features/recording/constants'; +import { RECORDING_METADATA_ID, RECORDING_TYPES } from '../../react/features/recording/constants'; import { getActiveSession, supportsLocalRecording } from '../../react/features/recording/functions'; import { startAudioScreenShareFlow, startScreenShareFlow } from '../../react/features/screen-share/actions'; import { isScreenAudioSupported } from '../../react/features/screen-share/functions'; @@ -629,6 +629,7 @@ function initCommands() { * @param { string } arg.youtubeStreamKey - The youtube stream key. * @param { string } arg.youtubeBroadcastID - The youtube broadcast ID. * @param { Object } arg.extraMetadata - Any extra metadata params for file recording. + * @param { boolean } arg.transcription - Whether a transcription should be started or not. * @returns {void} */ 'start-recording': ({ @@ -640,7 +641,8 @@ function initCommands() { rtmpBroadcastID, youtubeStreamKey, youtubeBroadcastID, - extraMetadata = {} + extraMetadata = {}, + transcription }) => { const state = APP.store.getState(); const conference = getCurrentConference(state); @@ -715,25 +717,33 @@ function initCommands() { mode: JitsiRecordingConstants.mode.STREAM, streamId: youtubeStreamKey || rtmpStreamKey }; - } else { - logger.error('Invalid recording mode provided'); - - return; } if (isScreenshotCaptureEnabled(state, true, false)) { APP.store.dispatch(toggleScreenshotCaptureSummary(true)); } - conference.startRecording(recordingConfig); + + // Start audio / video recording, if requested. + if (typeof recordingConfig !== 'undefined') { + conference.startRecording(recordingConfig); + } + + if (transcription) { + APP.store.dispatch(setRequestingSubtitles(true, false, null)); + conference.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, { + isTranscribingEnabled: true + }); + } }, /** * Stops a recording or streaming in progress. * * @param {string} mode - `local`, `file` or `stream`. + * @param {boolean} transcription - Whether the transcription needs to be stopped. * @returns {void} */ - 'stop-recording': mode => { + 'stop-recording': (mode, transcription) => { const state = APP.store.getState(); const conference = getCurrentConference(state); @@ -743,6 +753,13 @@ function initCommands() { return; } + if (transcription) { + APP.store.dispatch(setRequestingSubtitles(false, false, null)); + conference.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, { + isTranscribingEnabled: false + }); + } + if (mode === 'local') { APP.store.dispatch(stopLocalVideoRecording()); diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 399f56d8be51..01f4631356e0 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -1446,6 +1446,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter { * @param { string } options.youtubeStreamKey - The youtube stream key. * @param { string } options.youtubeBroadcastID - The youtube broadcast ID. * @param {Object } options.extraMetadata - Any extra metadata params for file recording. + * @param { boolean } arg.transcription - Whether a transcription should be started or not. * @returns {void} */ startRecording(options) { @@ -1456,10 +1457,11 @@ export default class JitsiMeetExternalAPI extends EventEmitter { * Stops a recording or streaming session that is in progress. * * @param {string} mode - `file` or `stream`. + * @param {boolean} transcription - Whether the transcription needs to be stopped. * @returns {void} */ - stopRecording(mode) { - this.executeCommand('stopRecording', mode); + stopRecording(mode, transcription) { + this.executeCommand('stopRecording', mode, transcription); } /**