|
@@ -2,7 +2,7 @@
|
2
|
2
|
|
3
|
3
|
import { getLogger } from 'jitsi-meet-logger';
|
4
|
4
|
|
5
|
|
-import DataChannels from './DataChannels';
|
|
5
|
+import BridgeChannel from './BridgeChannel';
|
6
|
6
|
import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
|
7
|
7
|
import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
|
8
|
8
|
import JitsiLocalTrack from './JitsiLocalTrack';
|
|
@@ -81,18 +81,24 @@ export default class RTC extends Listenable {
|
81
|
81
|
|
82
|
82
|
this.options = options;
|
83
|
83
|
|
84
|
|
- // A flag whether we had received that the data channel had opened
|
85
|
|
- // we can get this flag out of sync if for some reason data channel got
|
86
|
|
- // closed from server, a desired behaviour so we can see errors when
|
87
|
|
- // this happen
|
88
|
|
- this.dataChannelsOpen = false;
|
|
84
|
+ // BridgeChannel instance.
|
|
85
|
+ // @private
|
|
86
|
+ // @type {BridgeChannel}
|
|
87
|
+ this._channel = null;
|
|
88
|
+
|
|
89
|
+ // A flag whether we had received that the channel had opened we can
|
|
90
|
+ // get this flag out of sync if for some reason channel got closed
|
|
91
|
+ // from server, a desired behaviour so we can see errors when this
|
|
92
|
+ // happen.
|
|
93
|
+ // @private
|
|
94
|
+ // @type {boolean}
|
|
95
|
+ this._channelOpen = false;
|
89
|
96
|
|
90
|
97
|
/**
|
91
|
98
|
* The value specified to the last invocation of setLastN before the
|
92
|
|
- * data channels completed opening. If non-null, the value will be sent
|
93
|
|
- * through a data channel (once) as soon as it opens and will then be
|
|
99
|
+ * channel completed opening. If non-null, the value will be sent
|
|
100
|
+ * through a channel (once) as soon as it opens and will then be
|
94
|
101
|
* discarded.
|
95
|
|
- *
|
96
|
102
|
* @private
|
97
|
103
|
* @type {number}
|
98
|
104
|
*/
|
|
@@ -100,7 +106,7 @@ export default class RTC extends Listenable {
|
100
|
106
|
|
101
|
107
|
/**
|
102
|
108
|
* Defines the last N endpoints list. It can be null or an array once
|
103
|
|
- * initialised with a datachannel last N event.
|
|
109
|
+ * initialised with a channel last N event.
|
104
|
110
|
* @type {Array<string>|null}
|
105
|
111
|
* @private
|
106
|
112
|
*/
|
|
@@ -142,13 +148,13 @@ export default class RTC extends Listenable {
|
142
|
148
|
|
143
|
149
|
/**
|
144
|
150
|
* Creates the local MediaStreams.
|
145
|
|
- * @param {Object} [options] optional parameters
|
146
|
|
- * @param {Array} options.devices the devices that will be requested
|
147
|
|
- * @param {string} options.resolution resolution constraints
|
148
|
|
- * @param {bool} options.dontCreateJitsiTrack if <tt>true</tt> objects with
|
149
|
|
- * the following structure {stream: the Media Stream, type: "audio" or
|
150
|
|
- * "video", videoType: "camera" or "desktop"} will be returned trough the
|
151
|
|
- * Promise, otherwise JitsiTrack objects will be returned.
|
|
151
|
+ * @param {object} [options] Optional parameters.
|
|
152
|
+ * @param {array} options.devices The devices that will be requested.
|
|
153
|
+ * @param {string} options.resolution Resolution constraints.
|
|
154
|
+ * @param {bool} options.dontCreateJitsiTrack If <tt>true</tt> objects with
|
|
155
|
+ * the following structure {stream: the Media Stream, type: "audio" or
|
|
156
|
+ * "video", videoType: "camera" or "desktop"} will be returned trough
|
|
157
|
+ * the Promise, otherwise JitsiTrack objects will be returned.
|
152
|
158
|
* @param {string} options.cameraDeviceId
|
153
|
159
|
* @param {string} options.micDeviceId
|
154
|
160
|
* @returns {*} Promise object that will receive the new JitsiTracks
|
|
@@ -168,59 +174,62 @@ export default class RTC extends Listenable {
|
168
|
174
|
}
|
169
|
175
|
|
170
|
176
|
/**
|
171
|
|
- * Initializes the data channels of this instance.
|
172
|
|
- * @param peerconnection the associated PeerConnection.
|
173
|
|
- */
|
174
|
|
- initializeDataChannels(peerconnection) {
|
175
|
|
- if (this.options.config.openSctp) {
|
176
|
|
- this.dataChannels = new DataChannels(peerconnection,
|
177
|
|
- this.eventEmitter);
|
178
|
|
-
|
179
|
|
- this._dataChannelOpenListener = () => {
|
180
|
|
- // mark that dataChannel is opened
|
181
|
|
- this.dataChannelsOpen = true;
|
182
|
|
-
|
183
|
|
- // when the data channel becomes available, tell the bridge
|
184
|
|
- // about video selections so that it can do adaptive simulcast,
|
185
|
|
- // we want the notification to trigger even if userJid
|
186
|
|
- // is undefined, or null.
|
187
|
|
- try {
|
188
|
|
- this.dataChannels.sendPinnedEndpointMessage(
|
189
|
|
- this._pinnedEndpoint);
|
190
|
|
- this.dataChannels.sendSelectedEndpointMessage(
|
191
|
|
- this._selectedEndpoint);
|
192
|
|
- } catch (error) {
|
193
|
|
- GlobalOnErrorHandler.callErrorHandler(error);
|
194
|
|
- logger.error(
|
195
|
|
- `Cannot send selected(${this._selectedEndpoint})`
|
196
|
|
- + `pinned(${this._pinnedEndpoint}) endpoint message.`,
|
197
|
|
- error);
|
198
|
|
- }
|
199
|
|
-
|
200
|
|
- this.removeListener(RTCEvents.DATA_CHANNEL_OPEN,
|
201
|
|
- this._dataChannelOpenListener);
|
202
|
|
- this._dataChannelOpenListener = null;
|
203
|
|
-
|
204
|
|
- // If setLastN was invoked before the data channels completed
|
205
|
|
- // opening, apply the specified value now that the data channels
|
206
|
|
- // are open. NOTE that -1 is the default value assumed by both
|
207
|
|
- // RTC module and the JVB.
|
208
|
|
- if (this._lastN !== -1) {
|
209
|
|
- this.dataChannels.sendSetLastNMessage(this._lastN);
|
210
|
|
- }
|
211
|
|
- };
|
212
|
|
- this.addListener(RTCEvents.DATA_CHANNEL_OPEN,
|
213
|
|
- this._dataChannelOpenListener);
|
214
|
|
-
|
215
|
|
- // Add Last N change listener.
|
216
|
|
- this.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
|
217
|
|
- this._lastNChangeListener);
|
218
|
|
- }
|
|
177
|
+ * Initializes the bridge channel of this instance.
|
|
178
|
+ * At least one of both, peerconnection or wsUrl parameters, must be
|
|
179
|
+ * given.
|
|
180
|
+ * @param {RTCPeerConnection} [peerconnection] WebRTC peer connection
|
|
181
|
+ * instance.
|
|
182
|
+ * @param {string} [wsUrl] WebSocket URL.
|
|
183
|
+ */
|
|
184
|
+ initializeBridgeChannel(peerconnection, wsUrl) {
|
|
185
|
+ this._channel = new BridgeChannel(
|
|
186
|
+ peerconnection, wsUrl, this.eventEmitter);
|
|
187
|
+
|
|
188
|
+ this._channelOpenListener = () => {
|
|
189
|
+ // Mark that channel as opened.
|
|
190
|
+ this._channelOpen = true;
|
|
191
|
+
|
|
192
|
+ // When the channel becomes available, tell the bridge about
|
|
193
|
+ // video selections so that it can do adaptive simulcast,
|
|
194
|
+ // we want the notification to trigger even if userJid
|
|
195
|
+ // is undefined, or null.
|
|
196
|
+ try {
|
|
197
|
+ this._channel.sendPinnedEndpointMessage(
|
|
198
|
+ this._pinnedEndpoint);
|
|
199
|
+ this._channel.sendSelectedEndpointMessage(
|
|
200
|
+ this._selectedEndpoint);
|
|
201
|
+ } catch (error) {
|
|
202
|
+ GlobalOnErrorHandler.callErrorHandler(error);
|
|
203
|
+ logger.error(
|
|
204
|
+ `Cannot send selected(${this._selectedEndpoint})`
|
|
205
|
+ + `pinned(${this._pinnedEndpoint}) endpoint message.`,
|
|
206
|
+ error);
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ this.removeListener(RTCEvents.DATA_CHANNEL_OPEN,
|
|
210
|
+ this._channelOpenListener);
|
|
211
|
+ this._channelOpenListener = null;
|
|
212
|
+
|
|
213
|
+ // If setLastN was invoked before the bridge channel completed
|
|
214
|
+ // opening, apply the specified value now that the channel
|
|
215
|
+ // is open. NOTE that -1 is the default value assumed by both
|
|
216
|
+ // RTC module and the JVB.
|
|
217
|
+ if (this._lastN !== -1) {
|
|
218
|
+ this._channel.sendSetLastNMessage(this._lastN);
|
|
219
|
+ }
|
|
220
|
+ };
|
|
221
|
+
|
|
222
|
+ this.addListener(RTCEvents.DATA_CHANNEL_OPEN,
|
|
223
|
+ this._channelOpenListener);
|
|
224
|
+
|
|
225
|
+ // Add Last N change listener.
|
|
226
|
+ this.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
|
|
227
|
+ this._lastNChangeListener);
|
219
|
228
|
}
|
220
|
229
|
|
221
|
230
|
/**
|
222
|
231
|
* Receives events when Last N had changed.
|
223
|
|
- * @param {array} lastNEndpoints the new Last N endpoints.
|
|
232
|
+ * @param {array} lastNEndpoints The new Last N endpoints.
|
224
|
233
|
* @private
|
225
|
234
|
*/
|
226
|
235
|
_onLastNChanged(lastNEndpoints = []) {
|
|
@@ -247,13 +256,19 @@ export default class RTC extends Listenable {
|
247
|
256
|
* PeerConnection has been closed using PeerConnection.close() method.
|
248
|
257
|
*/
|
249
|
258
|
onCallEnded() {
|
250
|
|
- if (this.dataChannels) {
|
251
|
|
- // DataChannels are not explicitly closed as the PeerConnection
|
252
|
|
- // is closed on call ended which triggers data channel onclose
|
253
|
|
- // events. The reference is cleared to disable any logic related
|
254
|
|
- // to the data channels.
|
255
|
|
- this.dataChannels = null;
|
256
|
|
- this.dataChannelsOpen = false;
|
|
259
|
+ if (this._channel) {
|
|
260
|
+ // The BridgeChannel is not explicitly closed as the PeerConnection
|
|
261
|
+ // is closed on call ended which triggers datachannel onclose
|
|
262
|
+ // events. If using a WebSocket, the channel must be closed since
|
|
263
|
+ // it is not managed by the PeerConnection.
|
|
264
|
+ // The reference is cleared to disable any logic related to the
|
|
265
|
+ // channel.
|
|
266
|
+ if (this._channel && this._channel.mode === 'websocket') {
|
|
267
|
+ this._channel.close();
|
|
268
|
+ }
|
|
269
|
+
|
|
270
|
+ this._channel = null;
|
|
271
|
+ this._channelOpen = false;
|
257
|
272
|
}
|
258
|
273
|
}
|
259
|
274
|
|
|
@@ -261,17 +276,17 @@ export default class RTC extends Listenable {
|
261
|
276
|
* Elects the participant with the given id to be the selected participant
|
262
|
277
|
* in order to always receive video for this participant (even when last n
|
263
|
278
|
* is enabled).
|
264
|
|
- * If there is no data channel we store it and send it through the channel
|
265
|
|
- * once it is created.
|
266
|
|
- * @param id {string} the user id.
|
|
279
|
+ * If there is no channel we store it and send it through the channel once
|
|
280
|
+ * it is created.
|
|
281
|
+ * @param {string} id The user id.
|
267
|
282
|
* @throws NetworkError or InvalidStateError or Error if the operation
|
268
|
283
|
* fails.
|
269
|
284
|
*/
|
270
|
285
|
selectEndpoint(id) {
|
271
|
|
- // cache the value if channel is missing, till we open it
|
|
286
|
+ // Cache the value if channel is missing, till we open it.
|
272
|
287
|
this._selectedEndpoint = id;
|
273
|
|
- if (this.dataChannels && this.dataChannelsOpen) {
|
274
|
|
- this.dataChannels.sendSelectedEndpointMessage(id);
|
|
288
|
+ if (this._channel && this._channelOpen) {
|
|
289
|
+ this._channel.sendSelectedEndpointMessage(id);
|
275
|
290
|
}
|
276
|
291
|
}
|
277
|
292
|
|
|
@@ -279,15 +294,15 @@ export default class RTC extends Listenable {
|
279
|
294
|
* Elects the participant with the given id to be the pinned participant in
|
280
|
295
|
* order to always receive video for this participant (even when last n is
|
281
|
296
|
* enabled).
|
282
|
|
- * @param id {string} the user id
|
|
297
|
+ * @param {stirng} id The user id.
|
283
|
298
|
* @throws NetworkError or InvalidStateError or Error if the operation
|
284
|
299
|
* fails.
|
285
|
300
|
*/
|
286
|
301
|
pinEndpoint(id) {
|
287
|
|
- // cache the value if channel is missing, till we open it
|
|
302
|
+ // Cache the value if channel is missing, till we open it.
|
288
|
303
|
this._pinnedEndpoint = id;
|
289
|
|
- if (this.dataChannels && this.dataChannelsOpen) {
|
290
|
|
- this.dataChannels.sendPinnedEndpointMessage(id);
|
|
304
|
+ if (this._channel && this._channelOpen) {
|
|
305
|
+ this._channel.sendPinnedEndpointMessage(id);
|
291
|
306
|
}
|
292
|
307
|
}
|
293
|
308
|
|
|
@@ -337,19 +352,20 @@ export default class RTC extends Listenable {
|
337
|
352
|
|
338
|
353
|
/**
|
339
|
354
|
* Creates new <tt>TraceablePeerConnection</tt>
|
340
|
|
- * @param {SignalingLayer} signaling the signaling layer that will
|
341
|
|
- * provide information about the media or participants which is not carried
|
342
|
|
- * over SDP.
|
343
|
|
- * @param {Object} iceConfig an object describing the ICE config like
|
344
|
|
- * defined in the WebRTC specification.
|
345
|
|
- * @param {boolean} isP2P indicates whether or not the new TPC will be used
|
346
|
|
- * in a peer to peer type of session
|
347
|
|
- * @param {Object} options the config options
|
348
|
|
- * @param {boolean} options.disableSimulcast if set to 'true' will disable
|
349
|
|
- * the simulcast
|
350
|
|
- * @param {boolean} options.disableRtx if set to 'true' will disable the RTX
|
351
|
|
- * @param {boolean} options.preferH264 if set to 'true' H264 will be
|
352
|
|
- * preferred over other video codecs.
|
|
355
|
+ * @param {SignalingLayer} signaling The signaling layer that will
|
|
356
|
+ * provide information about the media or participants which is not
|
|
357
|
+ * carried over SDP.
|
|
358
|
+ * @param {object} iceConfig An object describing the ICE config like
|
|
359
|
+ * defined in the WebRTC specification.
|
|
360
|
+ * @param {boolean} isP2P Indicates whether or not the new TPC will be used
|
|
361
|
+ * in a peer to peer type of session.
|
|
362
|
+ * @param {object} options The config options.
|
|
363
|
+ * @param {boolean} options.disableSimulcast If set to 'true' will disable
|
|
364
|
+ * the simulcast.
|
|
365
|
+ * @param {boolean} options.disableRtx If set to 'true' will disable the
|
|
366
|
+ * RTX.
|
|
367
|
+ * @param {boolean} options.preferH264 If set to 'true' H264 will be
|
|
368
|
+ * preferred over other video codecs.
|
353
|
369
|
* @return {TraceablePeerConnection}
|
354
|
370
|
*/
|
355
|
371
|
createPeerConnection(signaling, iceConfig, isP2P, options) {
|
|
@@ -436,7 +452,7 @@ export default class RTC extends Listenable {
|
436
|
452
|
/**
|
437
|
453
|
* Returns the local tracks of the given media type, or all local tracks if
|
438
|
454
|
* no specific type is given.
|
439
|
|
- * @param {MediaType} [mediaType] optional media type filter
|
|
455
|
+ * @param {MediaType} [mediaType] Optional media type filter.
|
440
|
456
|
* (audio or video).
|
441
|
457
|
*/
|
442
|
458
|
getLocalTracks(mediaType) {
|
|
@@ -452,8 +468,8 @@ export default class RTC extends Listenable {
|
452
|
468
|
|
453
|
469
|
/**
|
454
|
470
|
* Obtains all remote tracks currently known to this RTC module instance.
|
455
|
|
- * @param {MediaType} [mediaType] the remote tracks will be filtered
|
456
|
|
- * by their media type if this argument is specified.
|
|
471
|
+ * @param {MediaType} [mediaType] The remote tracks will be filtered
|
|
472
|
+ * by their media type if this argument is specified.
|
457
|
473
|
* @return {Array<JitsiRemoteTrack>}
|
458
|
474
|
*/
|
459
|
475
|
getRemoteTracks(mediaType) {
|
|
@@ -472,7 +488,7 @@ export default class RTC extends Listenable {
|
472
|
488
|
|
473
|
489
|
/**
|
474
|
490
|
* Set mute for all local audio streams attached to the conference.
|
475
|
|
- * @param value the mute value
|
|
491
|
+ * @param value The mute value.
|
476
|
492
|
* @returns {Promise}
|
477
|
493
|
*/
|
478
|
494
|
setAudioMute(value) {
|
|
@@ -506,7 +522,7 @@ export default class RTC extends Listenable {
|
506
|
522
|
* Removes all JitsiRemoteTracks associated with given MUC nickname
|
507
|
523
|
* (resource part of the JID). Returns array of removed tracks.
|
508
|
524
|
*
|
509
|
|
- * @param {string} owner - The resource part of the MUC JID.
|
|
525
|
+ * @param {string} Owner The resource part of the MUC JID.
|
510
|
526
|
* @returns {JitsiRemoteTrack[]}
|
511
|
527
|
*/
|
512
|
528
|
removeRemoteTracks(owner) {
|
|
@@ -560,7 +576,7 @@ export default class RTC extends Listenable {
|
560
|
576
|
/**
|
561
|
577
|
* Returns true if changing the input (camera / microphone) or output
|
562
|
578
|
* (audio) device is supported and false if not.
|
563
|
|
- * @params {string} [deviceType] - type of device to change. Default is
|
|
579
|
+ * @param {string} [deviceType] Type of device to change. Default is
|
564
|
580
|
* undefined or 'input', 'output' - for audio output device change.
|
565
|
581
|
* @returns {boolean} true if available, false otherwise.
|
566
|
582
|
*/
|
|
@@ -580,7 +596,7 @@ export default class RTC extends Listenable {
|
580
|
596
|
/**
|
581
|
597
|
* Returns list of available media devices if its obtained, otherwise an
|
582
|
598
|
* empty array is returned/
|
583
|
|
- * @returns {Array} list of available media devices.
|
|
599
|
+ * @returns {array} list of available media devices.
|
584
|
600
|
*/
|
585
|
601
|
static getCurrentlyAvailableMediaDevices() {
|
586
|
602
|
return RTCUtils.getCurrentlyAvailableMediaDevices();
|
|
@@ -596,9 +612,9 @@ export default class RTC extends Listenable {
|
596
|
612
|
|
597
|
613
|
/**
|
598
|
614
|
* Sets current audio output device.
|
599
|
|
- * @param {string} deviceId - id of 'audiooutput' device from
|
600
|
|
- * navigator.mediaDevices.enumerateDevices()
|
601
|
|
- * @returns {Promise} - resolves when audio output is changed, is rejected
|
|
615
|
+ * @param {string} deviceId Id of 'audiooutput' device from
|
|
616
|
+ * navigator.mediaDevices.enumerateDevices().
|
|
617
|
+ * @returns {Promise} resolves when audio output is changed, is rejected
|
602
|
618
|
* otherwise
|
603
|
619
|
*/
|
604
|
620
|
static setAudioOutputDevice(deviceId) {
|
|
@@ -614,7 +630,7 @@ export default class RTC extends Listenable {
|
614
|
630
|
* "streams/channels/tracks" for receiving remote stream/tracks, as opposed
|
615
|
631
|
* to Plan B where there are only 3 channels: audio, video and data.
|
616
|
632
|
*
|
617
|
|
- * @param {MediaStream} stream the WebRTC MediaStream instance
|
|
633
|
+ * @param {MediaStream} stream The WebRTC MediaStream instance.
|
618
|
634
|
* @returns {boolean}
|
619
|
635
|
*/
|
620
|
636
|
static isUserStream(stream) {
|
|
@@ -630,7 +646,7 @@ export default class RTC extends Listenable {
|
630
|
646
|
* "streams/channels/tracks" for receiving remote stream/tracks, as opposed
|
631
|
647
|
* to Plan B where there are only 3 channels: audio, video and data.
|
632
|
648
|
*
|
633
|
|
- * @param {string} streamId the id of WebRTC MediaStream
|
|
649
|
+ * @param {string} streamId The id of WebRTC MediaStream.
|
634
|
650
|
* @returns {boolean}
|
635
|
651
|
*/
|
636
|
652
|
static isUserStreamById(streamId) {
|
|
@@ -640,7 +656,8 @@ export default class RTC extends Listenable {
|
640
|
656
|
|
641
|
657
|
/**
|
642
|
658
|
* Allows to receive list of available cameras/microphones.
|
643
|
|
- * @param {function} callback would receive array of devices as an argument
|
|
659
|
+ * @param {function} callback Would receive array of devices as an
|
|
660
|
+ * argument.
|
644
|
661
|
*/
|
645
|
662
|
static enumerateDevices(callback) {
|
646
|
663
|
RTCUtils.enumerateDevices(callback);
|
|
@@ -649,7 +666,7 @@ export default class RTC extends Listenable {
|
649
|
666
|
/**
|
650
|
667
|
* A method to handle stopping of the stream.
|
651
|
668
|
* One point to handle the differences in various implementations.
|
652
|
|
- * @param mediaStream MediaStream object to stop.
|
|
669
|
+ * @param {MediaStream} mediaStream MediaStream object to stop.
|
653
|
670
|
*/
|
654
|
671
|
static stopMediaStream(mediaStream) {
|
655
|
672
|
RTCUtils.stopMediaStream(mediaStream);
|
|
@@ -664,12 +681,12 @@ export default class RTC extends Listenable {
|
664
|
681
|
}
|
665
|
682
|
|
666
|
683
|
/**
|
667
|
|
- * Closes all currently opened data channels.
|
|
684
|
+ * Closes the currently opened bridge channel.
|
668
|
685
|
*/
|
669
|
|
- closeAllDataChannels() {
|
670
|
|
- if (this.dataChannels) {
|
671
|
|
- this.dataChannels.closeAllChannels();
|
672
|
|
- this.dataChannelsOpen = false;
|
|
686
|
+ closeBridgeChannel() {
|
|
687
|
+ if (this._channel) {
|
|
688
|
+ this._channel.close();
|
|
689
|
+ this._channelOpen = false;
|
673
|
690
|
|
674
|
691
|
this.removeListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
|
675
|
692
|
this._lastNChangeListener);
|
|
@@ -704,18 +721,18 @@ export default class RTC extends Listenable {
|
704
|
721
|
/* eslint-enable max-params */
|
705
|
722
|
|
706
|
723
|
/**
|
707
|
|
- * Sends message via the datachannels.
|
708
|
|
- * @param to {string} the id of the endpoint that should receive the
|
709
|
|
- * message. If "" the message will be sent to all participants.
|
710
|
|
- * @param payload {object} the payload of the message.
|
|
724
|
+ * Sends message via the bridge channel.
|
|
725
|
+ * @param {string} to The id of the endpoint that should receive the
|
|
726
|
+ * message. If "" the message will be sent to all participants.
|
|
727
|
+ * @param {object} payload The payload of the message.
|
711
|
728
|
* @throws NetworkError or InvalidStateError or Error if the operation
|
712
|
|
- * fails or there is no data channel created
|
|
729
|
+ * fails or there is no data channel created.
|
713
|
730
|
*/
|
714
|
|
- sendDataChannelMessage(to, payload) {
|
715
|
|
- if (this.dataChannels) {
|
716
|
|
- this.dataChannels.sendDataChannelMessage(to, payload);
|
|
731
|
+ sendChannelMessage(to, payload) {
|
|
732
|
+ if (this._channel) {
|
|
733
|
+ this._channel.sendMessage(to, payload);
|
717
|
734
|
} else {
|
718
|
|
- throw new Error('Data channels support is disabled!');
|
|
735
|
+ throw new Error('Channel support is disabled!');
|
719
|
736
|
}
|
720
|
737
|
}
|
721
|
738
|
|
|
@@ -723,13 +740,13 @@ export default class RTC extends Listenable {
|
723
|
740
|
* Selects a new value for "lastN". The requested amount of videos are going
|
724
|
741
|
* to be delivered after the value is in effect. Set to -1 for unlimited or
|
725
|
742
|
* all available videos.
|
726
|
|
- * @param value {number} the new value for lastN.
|
|
743
|
+ * @param {number} value the new value for lastN.
|
727
|
744
|
*/
|
728
|
745
|
setLastN(value) {
|
729
|
746
|
if (this._lastN !== value) {
|
730
|
747
|
this._lastN = value;
|
731
|
|
- if (this.dataChannels && this.dataChannelsOpen) {
|
732
|
|
- this.dataChannels.sendSetLastNMessage(value);
|
|
748
|
+ if (this._channel && this._channelOpen) {
|
|
749
|
+ this._channel.sendSetLastNMessage(value);
|
733
|
750
|
}
|
734
|
751
|
this.eventEmitter.emit(RTCEvents.LASTN_VALUE_CHANGED, value);
|
735
|
752
|
}
|
|
@@ -737,13 +754,12 @@ export default class RTC extends Listenable {
|
737
|
754
|
|
738
|
755
|
/**
|
739
|
756
|
* Indicates if the endpoint id is currently included in the last N.
|
740
|
|
- *
|
741
|
|
- * @param {string} id the endpoint id that we check for last N.
|
|
757
|
+ * @param {string} id The endpoint id that we check for last N.
|
742
|
758
|
* @returns {boolean} true if the endpoint id is in the last N or if we
|
743
|
|
- * don't have data channel support, otherwise we return false.
|
|
759
|
+ * don't have bridge channel support, otherwise we return false.
|
744
|
760
|
*/
|
745
|
761
|
isInLastN(id) {
|
746
|
|
- return !this._lastNEndpoints // lastNEndpoints not initialised yet
|
|
762
|
+ return !this._lastNEndpoints // lastNEndpoints not initialised yet.
|
747
|
763
|
|| this._lastNEndpoints.indexOf(id) > -1;
|
748
|
764
|
}
|
749
|
765
|
}
|