Преглед изворни кода

Implement external API notification about screen sharing status

master
Slava Kisel пре 7 година
родитељ
комит
e1d849e3a0
No account linked to committer's email address
4 измењених фајлова са 51 додато и 7 уклоњено
  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 Прегледај датотеку

@@ -1334,19 +1334,35 @@ export default {
1334 1334
             replaceLocalTrack(this.localVideo, newStream, room))
1335 1335
             .then(() => {
1336 1336
                 this.localVideo = newStream;
1337
-
1337
+                this._setSharingScreen(newStream);
1338 1338
                 if (newStream) {
1339
-                    this.isSharingScreen = newStream.videoType === 'desktop';
1340
-
1341 1339
                     APP.UI.addLocalStream(newStream);
1342
-                } else {
1343
-                    this.isSharingScreen = false;
1344 1340
                 }
1345 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 1367
      * Start using provided audio stream.
1352 1368
      * Stops previous audio stream.

+ 7
- 0
doc/api.md Прегледај датотеку

@@ -164,6 +164,13 @@ changes. The listener will receive an object with the following structure:
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 174
 * **incomingMessage** - Event notifications about incoming
168 175
 messages. The listener will receive an object with the following structure:
169 176
 ```javascript

+ 14
- 0
modules/API/API.js Прегледај датотеку

@@ -471,6 +471,20 @@ class API {
471 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 489
      * Disposes the allocated resources.
476 490
      *

+ 8
- 1
modules/API/external/external_api.js Прегледај датотеку

@@ -48,7 +48,8 @@ const events = {
48 48
     'video-conference-joined': 'videoConferenceJoined',
49 49
     'video-conference-left': 'videoConferenceLeft',
50 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,6 +486,12 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
485 486
      * {{
486 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 495
      * readyToClose - all hangup operations are completed and Jitsi Meet is
489 496
      * ready to be disposed.
490 497
      * @returns {void}

Loading…
Откажи
Сачувај