浏览代码

feat(conference): expose method to select multiple participants (#784)

* feat(conference): expose method to select multiple participants

* squash: fix typo

* squash: reduce to one code flow

* squash: default to empty array to mimic previous null default

* squash: fix typos, change docs, default params

* squash: remove defaults

* squash: update comment about array arg
dev1
virtuacoplenny 7 年前
父节点
当前提交
2be752fc88
没有帐户链接到提交者的电子邮件
共有 3 个文件被更改,包括 47 次插入24 次删除
  1. 22
    1
      JitsiConference.js
  2. 8
    7
      modules/RTC/BridgeChannel.js
  3. 17
    16
      modules/RTC/RTC.js

+ 22
- 1
JitsiConference.js 查看文件

1036
  * Or cache it if channel is not created and send it once channel is available.
1036
  * Or cache it if channel is not created and send it once channel is available.
1037
  * @param participantId the identifier of the participant
1037
  * @param participantId the identifier of the participant
1038
  * @throws NetworkError or InvalidStateError or Error if the operation fails.
1038
  * @throws NetworkError or InvalidStateError or Error if the operation fails.
1039
+ * @returns {void}
1039
  */
1040
  */
1040
 JitsiConference.prototype.selectParticipant = function(participantId) {
1041
 JitsiConference.prototype.selectParticipant = function(participantId) {
1041
-    this.rtc.selectEndpoint(participantId);
1042
+    this.selectParticipants([ participantId ]);
1043
+};
1044
+
1045
+/*
1046
+ * Elects participants with given ids to be the selected participants in order
1047
+ * to receive higher video quality (if simulcast is enabled). The argument
1048
+ * should be an array of participant id strings or an empty array; an error will
1049
+ * be thrown if a non-array is passed in. The error is thrown as a layer of
1050
+ * protection against passing an invalid argument, as the error will happen in
1051
+ * the bridge and may not be visible in the client.
1052
+ *
1053
+ * @param {Array<strings>} participantIds - An array of identifiers for
1054
+ * participants.
1055
+ * @returns {void}
1056
+ */
1057
+JitsiConference.prototype.selectParticipants = function(participantIds) {
1058
+    if (!Array.isArray(participantIds)) {
1059
+        throw new Error('Invalid argument; participantIds must be an array.');
1060
+    }
1061
+
1062
+    this.rtc.selectEndpoints(participantIds);
1042
 };
1063
 };
1043
 
1064
 
1044
 /**
1065
 /**

+ 8
- 7
modules/RTC/BridgeChannel.js 查看文件

152
     }
152
     }
153
 
153
 
154
     /**
154
     /**
155
-     * Sends a "selected endpoint changed" message via the channel.
156
-     * @param {string} endpointId The id of the selected endpoint.
155
+     * Sends a "selected endpoints changed" message via the channel.
156
+     *
157
+     * @param {Array<string>} endpointIds - The ids of the selected endpoints.
157
      * @throws NetworkError or InvalidStateError from RTCDataChannel#send (@see
158
      * @throws NetworkError or InvalidStateError from RTCDataChannel#send (@see
158
      * {@link https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send})
159
      * {@link https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send})
159
      * or from WebSocket#send or Error with "No opened channel" message.
160
      * or from WebSocket#send or Error with "No opened channel" message.
160
      */
161
      */
161
-    sendSelectedEndpointMessage(endpointId) {
162
+    sendSelectedEndpointsMessage(endpointIds) {
162
         logger.log(
163
         logger.log(
163
-            'sending selected changed notification to the bridge for endpoint ',
164
-            endpointId);
164
+            'sending selected changed notification to the bridge for endpoints',
165
+            endpointIds);
165
 
166
 
166
         this._send({
167
         this._send({
167
-            colibriClass: 'SelectedEndpointChangedEvent',
168
-            selectedEndpoint: endpointId || null
168
+            colibriClass: 'SelectedEndpointsChangedEvent',
169
+            selectedEndpoints: endpointIds
169
         });
170
         });
170
     }
171
     }
171
 
172
 

+ 17
- 16
modules/RTC/RTC.js 查看文件

179
         this._pinnedEndpoint = null;
179
         this._pinnedEndpoint = null;
180
 
180
 
181
         /**
181
         /**
182
-         * The endpoint ID of currently selected participant or <tt>null</tt> if
183
-         * no user is selected.
184
-         * @type {string|null}
182
+         * The endpoint IDs of currently selected participants.
183
+         *
184
+         * @type {Array}
185
          * @private
185
          * @private
186
          */
186
          */
187
-        this._selectedEndpoint = null;
187
+        this._selectedEndpoints = [];
188
 
188
 
189
         // The last N change listener.
189
         // The last N change listener.
190
         this._lastNChangeListener = this._onLastNChanged.bind(this);
190
         this._lastNChangeListener = this._onLastNChanged.bind(this);
258
             try {
258
             try {
259
                 this._channel.sendPinnedEndpointMessage(
259
                 this._channel.sendPinnedEndpointMessage(
260
                     this._pinnedEndpoint);
260
                     this._pinnedEndpoint);
261
-                this._channel.sendSelectedEndpointMessage(
262
-                    this._selectedEndpoint);
261
+                this._channel.sendSelectedEndpointsMessage(
262
+                    this._selectedEndpoints);
263
 
263
 
264
                 if (typeof this._maxFrameHeight !== 'undefined') {
264
                 if (typeof this._maxFrameHeight !== 'undefined') {
265
                     this._channel.sendReceiverVideoConstraintMessage(
265
                     this._channel.sendReceiverVideoConstraintMessage(
358
     }
358
     }
359
 
359
 
360
     /**
360
     /**
361
-     * Elects the participant with the given id to be the selected participant
362
-     * in order to always receive video for this participant (even when last n
363
-     * is enabled).
364
-     * If there is no channel we store it and send it through the channel once
365
-     * it is created.
366
-     * @param {string} id The user id.
361
+     * Elects the participants with the given ids to be the selected
362
+     * participants in order to always receive video for this participant (even
363
+     * when last n is enabled). If there is no channel we store it and send it
364
+     * through the channel once it is created.
365
+     *
366
+     * @param {Array<string>} ids - The user ids.
367
      * @throws NetworkError or InvalidStateError or Error if the operation
367
      * @throws NetworkError or InvalidStateError or Error if the operation
368
      * fails.
368
      * fails.
369
+     * @returns {void}
369
      */
370
      */
370
-    selectEndpoint(id) {
371
-        // Cache the value if channel is missing, till we open it.
372
-        this._selectedEndpoint = id;
371
+    selectEndpoints(ids) {
372
+        this._selectedEndpoints = ids;
373
+
373
         if (this._channel && this._channelOpen) {
374
         if (this._channel && this._channelOpen) {
374
-            this._channel.sendSelectedEndpointMessage(id);
375
+            this._channel.sendSelectedEndpointsMessage(ids);
375
         }
376
         }
376
     }
377
     }
377
 
378
 

正在加载...
取消
保存