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
Implement external API notification about screen sharing status
Slava Kisele1d849e3a0b7
diff --git a/conference.js b/conference.jsindex 3ec751eb7e..18538c57fa 100644--- a/conference.js+++ b/conference.js@@ -1334,19 +1334,35 @@ export default {replaceLocalTrack(this.localVideo, newStream, room)).then(() => {this.localVideo = newStream;-+ this._setSharingScreen(newStream);if (newStream) {- this.isSharingScreen = newStream.videoType === 'desktop';-APP.UI.addLocalStream(newStream);- } else {- this.isSharingScreen = false;}this.setVideoMuteStatus(this.isLocalVideoMuted());- APP.UI.updateDesktopSharingButtons();});},+ /**+ * Sets `this.isSharingScreen` depending on provided video stream.+ * In case new screen sharing status is not equal previous one+ * it updates desktop sharing buttons in UI+ * and notifies external application.+ *+ * @param {JitsiLocalTrack} [newStream] new stream to use or null+ * @private+ * @returns {void}+ */+ _setSharingScreen(newStream) {+ const wasSharingScreen = this.isSharingScreen;++ this.isSharingScreen = newStream && newStream.videoType === 'desktop';++ if (wasSharingScreen !== this.isSharingScreen) {+ APP.UI.updateDesktopSharingButtons();+ APP.API.notifyScreenSharingStatusChanged(this.isSharingScreen);+ }+ },+/*** Start using provided audio stream.* Stops previous audio stream.diff --git a/doc/api.md b/doc/api.mdindex c5361e13d8..929f26747b 100644--- a/doc/api.md+++ b/doc/api.md@@ -164,6 +164,13 @@ changes. The listener will receive an object with the following structure:}```+* **screenSharingStatusChanged** - receives event notifications about turning on/off the local user screen sharing. The listener will receive object with the following structure:+```javascript+{+"on": on //whether screen sharing is on+}+```+* **incomingMessage** - Event notifications about incomingmessages. The listener will receive an object with the following structure:```javascriptdiff --git a/modules/API/API.js b/modules/API/API.jsindex a1dcae3366..7bed8149a8 100644--- a/modules/API/API.js+++ b/modules/API/API.js@@ -471,6 +471,20 @@ class API {this._sendEvent({ name: 'feedback-submitted' });}+ /**+ * Notify external application (if API is enabled) that the screen sharing+ * has been turned on/off.+ *+ * @param {boolean} on - True if screen sharing is enabled.+ * @returns {void}+ */+ notifyScreenSharingStatusChanged(on: boolean) {+ this._sendEvent({+ name: 'screen-sharing-status-changed',+ on+ });+ }+/*** Disposes the allocated resources.*diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.jsindex 33568d57d7..22286a5f4e 100644--- a/modules/API/external/external_api.js+++ b/modules/API/external/external_api.js@@ -48,7 +48,8 @@ const events = {'video-conference-joined': 'videoConferenceJoined','video-conference-left': 'videoConferenceLeft','video-availability-changed': 'videoAvailabilityChanged',- 'video-mute-status-changed': 'videoMuteStatusChanged'+ 'video-mute-status-changed': 'videoMuteStatusChanged',+ 'screen-sharing-status-changed': 'screenSharingStatusChanged'};/**@@ -485,6 +486,12 @@ export default class JitsiMeetExternalAPI extends EventEmitter {* {{* roomName: room //the room name of the conference* }}+ * screenSharingStatusChanged - receives event notifications about+ * turning on/off the local user screen sharing.+ * The listener will receive object with the following structure:+ * {{+ * on: on //whether screen sharing is on+ * }}* readyToClose - all hangup operations are completed and Jitsi Meet is* ready to be disposed.* @returns {void}