瀏覽代碼

Merge pull request #8379 from horymury/hmuresan/broadcast-screenshare

feat(external_api) add command and event listener for CS
master
Avram Tudor 4 年之前
父節點
當前提交
7f1894dd57
No account linked to committer's email address

+ 22
- 0
modules/API/API.js 查看文件

@@ -432,6 +432,15 @@ function initCommands() {
432 432
         case 'is-sharing-screen':
433 433
             callback(Boolean(APP.conference.isSharingScreen));
434 434
             break;
435
+        case 'get-content-sharing-participants': {
436
+            const tracks = getState()['features/base/tracks'];
437
+            const sharingParticipantIds = tracks.filter(tr => tr.videoType === 'desktop').map(t => t.participantId);
438
+
439
+            callback({
440
+                sharingParticipantIds
441
+            });
442
+            break;
443
+        }
435 444
         default:
436 445
             return false;
437 446
         }
@@ -675,6 +684,19 @@ class API {
675 684
         });
676 685
     }
677 686
 
687
+    /**
688
+     * Notify external application (if API is enabled) that the list of sharing participants changed.
689
+     *
690
+     * @param {Object} data - The event data.
691
+     * @returns {void}
692
+     */
693
+    notifySharingParticipantsChanged(data: Object) {
694
+        this._sendEvent({
695
+            name: 'content-sharing-participants-changed',
696
+            data
697
+        });
698
+    }
699
+
678 700
     /**
679 701
      * Notify external application (if API is enabled) that the device list has
680 702
      * changed.

+ 12
- 0
modules/API/external/external_api.js 查看文件

@@ -64,6 +64,7 @@ const events = {
64 64
     'audio-availability-changed': 'audioAvailabilityChanged',
65 65
     'audio-mute-status-changed': 'audioMuteStatusChanged',
66 66
     'camera-error': 'cameraError',
67
+    'content-sharing-participants-changed': 'contentSharingParticipantsChanged',
67 68
     'device-list-changed': 'deviceListChanged',
68 69
     'display-name-change': 'displayNameChange',
69 70
     'email-change': 'emailChange',
@@ -725,6 +726,17 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
725 726
         return getAvailableDevices(this._transport);
726 727
     }
727 728
 
729
+    /**
730
+     * Gets a list of the currently sharing participant id's.
731
+     *
732
+     * @returns {Promise} - Resolves with the list of participant id's currently sharing.
733
+     */
734
+    getContentSharingParticipants() {
735
+        return this._transport.sendRequest({
736
+            name: 'get-content-sharing-participants'
737
+        });
738
+    }
739
+
728 740
     /**
729 741
      * Returns Promise that resolves with current selected devices.
730 742
      *

+ 2
- 0
react/features/base/tracks/middleware.js 查看文件

@@ -35,6 +35,8 @@ import {
35 35
     setTrackMuted
36 36
 } from './functions';
37 37
 
38
+import './subscriber';
39
+
38 40
 declare var APP: Object;
39 41
 
40 42
 /**

+ 24
- 0
react/features/base/tracks/subscriber.js 查看文件

@@ -0,0 +1,24 @@
1
+// @flow
2
+
3
+import _ from 'lodash';
4
+
5
+import { StateListenerRegistry } from '../../base/redux';
6
+
7
+declare var APP: Object;
8
+
9
+/**
10
+ * Notifies when the list of currently sharing participants changes.
11
+ */
12
+StateListenerRegistry.register(
13
+    /* selector */ state =>
14
+        state['features/base/tracks'].filter(tr => tr.videoType === 'desktop').map(t => t.participantId),
15
+    /* listener */ (participantIDs, store, previousParticipantIDs) => {
16
+        if (typeof APP !== 'object') {
17
+            return;
18
+        }
19
+
20
+        if (!_.isEqual(_.sortBy(participantIDs), _.sortBy(previousParticipantIDs))) {
21
+            APP.API.notifySharingParticipantsChanged(participantIDs);
22
+        }
23
+    }
24
+);

Loading…
取消
儲存