Browse Source

Implement external API notification about screen sharing status

master
Slava Kisel 7 years ago
parent
commit
e1d849e3a0
No account linked to committer's email address
4 changed files with 51 additions and 7 deletions
  1. 22
    6
      conference.js
  2. 7
    0
      doc/api.md
  3. 14
    0
      modules/API/API.js
  4. 8
    1
      modules/API/external/external_api.js

+ 22
- 6
conference.js View File

1334
             replaceLocalTrack(this.localVideo, newStream, room))
1334
             replaceLocalTrack(this.localVideo, newStream, room))
1335
             .then(() => {
1335
             .then(() => {
1336
                 this.localVideo = newStream;
1336
                 this.localVideo = newStream;
1337
-
1337
+                this._setSharingScreen(newStream);
1338
                 if (newStream) {
1338
                 if (newStream) {
1339
-                    this.isSharingScreen = newStream.videoType === 'desktop';
1340
-
1341
                     APP.UI.addLocalStream(newStream);
1339
                     APP.UI.addLocalStream(newStream);
1342
-                } else {
1343
-                    this.isSharingScreen = false;
1344
                 }
1340
                 }
1345
                 this.setVideoMuteStatus(this.isLocalVideoMuted());
1341
                 this.setVideoMuteStatus(this.isLocalVideoMuted());
1346
-                APP.UI.updateDesktopSharingButtons();
1347
             });
1342
             });
1348
     },
1343
     },
1349
 
1344
 
1345
+    /**
1346
+     * Sets `this.isSharingScreen` depending on provided video stream.
1347
+     * In case new screen sharing status is not equal previous one
1348
+     * it updates desktop sharing buttons in UI
1349
+     * and notifies external application.
1350
+     *
1351
+     * @param {JitsiLocalTrack} [newStream] new stream to use or null
1352
+     * @private
1353
+     * @returns {void}
1354
+     */
1355
+    _setSharingScreen(newStream) {
1356
+        const wasSharingScreen = this.isSharingScreen;
1357
+
1358
+        this.isSharingScreen = newStream && newStream.videoType === 'desktop';
1359
+
1360
+        if (wasSharingScreen !== this.isSharingScreen) {
1361
+            APP.UI.updateDesktopSharingButtons();
1362
+            APP.API.notifyScreenSharingStatusChanged(this.isSharingScreen);
1363
+        }
1364
+    },
1365
+
1350
     /**
1366
     /**
1351
      * Start using provided audio stream.
1367
      * Start using provided audio stream.
1352
      * Stops previous audio stream.
1368
      * Stops previous audio stream.

+ 7
- 0
doc/api.md View File

164
 }
164
 }
165
 ```
165
 ```
166
 
166
 
167
+* **screenSharingStatusChanged** - receives event notifications about turning on/off the local user screen sharing. The listener will receive object with the following structure:
168
+```javascript
169
+{
170
+"on": on //whether screen sharing is on
171
+}
172
+```
173
+
167
 * **incomingMessage** - Event notifications about incoming
174
 * **incomingMessage** - Event notifications about incoming
168
 messages. The listener will receive an object with the following structure:
175
 messages. The listener will receive an object with the following structure:
169
 ```javascript
176
 ```javascript

+ 14
- 0
modules/API/API.js View File

471
         this._sendEvent({ name: 'feedback-submitted' });
471
         this._sendEvent({ name: 'feedback-submitted' });
472
     }
472
     }
473
 
473
 
474
+    /**
475
+     * Notify external application (if API is enabled) that the screen sharing
476
+     * has been turned on/off.
477
+     *
478
+     * @param {boolean} on - True if screen sharing is enabled.
479
+     * @returns {void}
480
+     */
481
+    notifyScreenSharingStatusChanged(on: boolean) {
482
+        this._sendEvent({
483
+            name: 'screen-sharing-status-changed',
484
+            on
485
+        });
486
+    }
487
+
474
     /**
488
     /**
475
      * Disposes the allocated resources.
489
      * Disposes the allocated resources.
476
      *
490
      *

+ 8
- 1
modules/API/external/external_api.js View File

48
     'video-conference-joined': 'videoConferenceJoined',
48
     'video-conference-joined': 'videoConferenceJoined',
49
     'video-conference-left': 'videoConferenceLeft',
49
     'video-conference-left': 'videoConferenceLeft',
50
     'video-availability-changed': 'videoAvailabilityChanged',
50
     'video-availability-changed': 'videoAvailabilityChanged',
51
-    'video-mute-status-changed': 'videoMuteStatusChanged'
51
+    'video-mute-status-changed': 'videoMuteStatusChanged',
52
+    'screen-sharing-status-changed': 'screenSharingStatusChanged'
52
 };
53
 };
53
 
54
 
54
 /**
55
 /**
485
      * {{
486
      * {{
486
      * roomName: room //the room name of the conference
487
      * roomName: room //the room name of the conference
487
      * }}
488
      * }}
489
+     * screenSharingStatusChanged - receives event notifications about
490
+     * turning on/off the local user screen sharing.
491
+     * The listener will receive object with the following structure:
492
+     * {{
493
+     * on: on //whether screen sharing is on
494
+     * }}
488
      * readyToClose - all hangup operations are completed and Jitsi Meet is
495
      * readyToClose - all hangup operations are completed and Jitsi Meet is
489
      * ready to be disposed.
496
      * ready to be disposed.
490
      * @returns {void}
497
      * @returns {void}

Loading…
Cancel
Save