Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(external_api) add command and event listener for CS
hmuresan4dda5087088d
diff --git a/modules/API/API.js b/modules/API/API.jsindex 4cdfaddd8b..1829b012d4 100644--- a/modules/API/API.js+++ b/modules/API/API.js@@ -413,6 +413,15 @@ function initCommands() {case 'is-sharing-screen':callback(Boolean(APP.conference.isSharingScreen));break;+ case 'get-content-sharing-participants': {+ const tracks = getState()['features/base/tracks'];+ const sharingParticipantIds = tracks.filter(tr => tr.videoType === 'desktop').map(t => t.participantId);++ callback({+ sharingParticipantIds+ });+ break;+ }default:return false;}@@ -656,6 +665,19 @@ class API {});}+ /**+ * Notify external application (if API is enabled) that the list of sharing participants changed.+ *+ * @param {Object} data - The event data.+ * @returns {void}+ */+ notifySharingParticipantsChanged(data: Object) {+ this._sendEvent({+ name: 'content-sharing-participants-changed',+ data+ });+ }+/*** Notify external application (if API is enabled) that the device list has* changed.diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.jsindex bc0b11133d..0d0ac7be39 100644--- a/modules/API/external/external_api.js+++ b/modules/API/external/external_api.js@@ -62,6 +62,7 @@ const events = {'audio-availability-changed': 'audioAvailabilityChanged','audio-mute-status-changed': 'audioMuteStatusChanged','camera-error': 'cameraError',+ 'content-sharing-participants-changed': 'contentSharingParticipantsChanged','device-list-changed': 'deviceListChanged','display-name-change': 'displayNameChange','email-change': 'emailChange',@@ -723,6 +724,17 @@ export default class JitsiMeetExternalAPI extends EventEmitter {return getAvailableDevices(this._transport);}+ /**+ * Gets a list of the currently sharing participant id's.+ *+ * @returns {Promise} - Resolves with the list of participant id's currently sharing.+ */+ getContentSharingParticipants() {+ return this._transport.sendRequest({+ name: 'get-content-sharing-participants'+ });+ }+/*** Returns Promise that resolves with current selected devices.*diff --git a/react/features/base/tracks/middleware.js b/react/features/base/tracks/middleware.jsindex 5e62d090b3..ebf352ee35 100644--- a/react/features/base/tracks/middleware.js+++ b/react/features/base/tracks/middleware.js@@ -35,6 +35,8 @@ import {setTrackMuted} from './functions';+import './subscriber';+declare var APP: Object;/**diff --git a/react/features/base/tracks/subscriber.js b/react/features/base/tracks/subscriber.jsnew file mode 100644index 0000000000..0fb7b7ccb3--- /dev/null+++ b/react/features/base/tracks/subscriber.js@@ -0,0 +1,24 @@+// @flow++import _ from 'lodash';++import { StateListenerRegistry } from '../../base/redux';++declare var APP: Object;++/**+ * Notifies when the list of currently sharing participants changes.+ */+StateListenerRegistry.register(+ /* selector */ state =>+ state['features/base/tracks'].filter(tr => tr.videoType === 'desktop').map(t => t.participantId),+ /* listener */ (participantIDs, store, previousParticipantIDs) => {+ if (typeof APP !== 'object') {+ return;+ }++ if (!_.isEqual(_.sortBy(participantIDs), _.sortBy(previousParticipantIDs))) {+ APP.API.notifySharingParticipantsChanged(participantIDs);+ }+ }+);