浏览代码

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

feat(external_api) add command and event listener for CS
master
Avram Tudor 4 年前
父节点
当前提交
7f1894dd57
没有帐户链接到提交者的电子邮件

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

432
         case 'is-sharing-screen':
432
         case 'is-sharing-screen':
433
             callback(Boolean(APP.conference.isSharingScreen));
433
             callback(Boolean(APP.conference.isSharingScreen));
434
             break;
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
         default:
444
         default:
436
             return false;
445
             return false;
437
         }
446
         }
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
      * Notify external application (if API is enabled) that the device list has
701
      * Notify external application (if API is enabled) that the device list has
680
      * changed.
702
      * changed.

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

64
     'audio-availability-changed': 'audioAvailabilityChanged',
64
     'audio-availability-changed': 'audioAvailabilityChanged',
65
     'audio-mute-status-changed': 'audioMuteStatusChanged',
65
     'audio-mute-status-changed': 'audioMuteStatusChanged',
66
     'camera-error': 'cameraError',
66
     'camera-error': 'cameraError',
67
+    'content-sharing-participants-changed': 'contentSharingParticipantsChanged',
67
     'device-list-changed': 'deviceListChanged',
68
     'device-list-changed': 'deviceListChanged',
68
     'display-name-change': 'displayNameChange',
69
     'display-name-change': 'displayNameChange',
69
     'email-change': 'emailChange',
70
     'email-change': 'emailChange',
725
         return getAvailableDevices(this._transport);
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
      * Returns Promise that resolves with current selected devices.
741
      * Returns Promise that resolves with current selected devices.
730
      *
742
      *

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

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

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

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
+);

正在加载...
取消
保存