|
@@ -49,18 +49,6 @@ export class TPCUtils {
|
49
|
49
|
];
|
50
|
50
|
}
|
51
|
51
|
|
52
|
|
- /**
|
53
|
|
- * Obtains local tracks for given {@link MediaType}.
|
54
|
|
- * @param {MediaType} mediaType - audio or video.
|
55
|
|
- * @return {Array<JitsiLocalTrack>} - array containing the local tracks
|
56
|
|
- * attached to the peerconnection of the given media type.
|
57
|
|
- */
|
58
|
|
- _getLocalTracks(mediaType) {
|
59
|
|
- const tracks = Array.from(this.pc.localTracks.values());
|
60
|
|
-
|
61
|
|
- return tracks.filter(track => track.getType() === mediaType);
|
62
|
|
- }
|
63
|
|
-
|
64
|
52
|
/**
|
65
|
53
|
* Obtains stream encodings that need to be configured on the given track.
|
66
|
54
|
* @param {JitsiLocalTrack} localTrack
|
|
@@ -301,16 +289,23 @@ export class TPCUtils {
|
301
|
289
|
}
|
302
|
290
|
|
303
|
291
|
/**
|
304
|
|
- *
|
305
|
|
- * @param {boolean} active
|
306
|
|
- */
|
|
292
|
+ * Enables/disables audio transmission on the peer connection. When
|
|
293
|
+ * disabled the audio transceiver direction will be set to 'inactive'
|
|
294
|
+ * which means that no data will be sent nor accepted, but
|
|
295
|
+ * the connection should be kept alive.
|
|
296
|
+ * @param {boolean} active - true to enable audio media transmission or
|
|
297
|
+ * false to disable.
|
|
298
|
+ * @returns {false} - returns false always so that renegotiation is not automatically
|
|
299
|
+ * triggered after this operation.
|
|
300
|
+ */
|
307
|
301
|
setAudioTransferActive(active) {
|
308
|
302
|
return this.setMediaTransferActive('audio', active);
|
309
|
303
|
}
|
310
|
304
|
|
311
|
305
|
/**
|
312
|
306
|
* Set the simulcast stream encoding properties on the RTCRtpSender.
|
313
|
|
- * @param {*} track - the current track in use for which the encodings are to be set.
|
|
307
|
+ * @param {JitsiLocalTrack} track - the current track in use for which
|
|
308
|
+ * the encodings are to be set.
|
314
|
309
|
*/
|
315
|
310
|
setEncodings(track) {
|
316
|
311
|
const transceiver = this.pc.peerconnection.getTransceivers()
|
|
@@ -322,17 +317,23 @@ export class TPCUtils {
|
322
|
317
|
}
|
323
|
318
|
|
324
|
319
|
/**
|
325
|
|
- *
|
326
|
|
- * @param {*} mediaType
|
327
|
|
- * @param {boolean} active
|
|
320
|
+ * Enables/disables media transmission on the peerconnection by changing the direction
|
|
321
|
+ * on the transceiver for the specified media type.
|
|
322
|
+ * @param {String} mediaType - 'audio' or 'video'
|
|
323
|
+ * @param {boolean} active - true to enable media transmission or false
|
|
324
|
+ * to disable.
|
|
325
|
+ * @returns {false} - returns false always so that renegotiation is not automatically
|
|
326
|
+ * triggered after this operation
|
328
|
327
|
*/
|
329
|
328
|
setMediaTransferActive(mediaType, active) {
|
330
|
329
|
const transceivers = this.pc.peerconnection.getTransceivers()
|
331
|
330
|
.filter(t => t.receiver && t.receiver.track && t.receiver.track.kind === mediaType);
|
|
331
|
+ const localTracks = Array.from(this.pc.localTracks.values())
|
|
332
|
+ .filter(track => track.getType() === mediaType);
|
332
|
333
|
|
333
|
334
|
if (active) {
|
334
|
335
|
transceivers.forEach(transceiver => {
|
335
|
|
- if (this._getLocalTracks(mediaType).length > 0) {
|
|
336
|
+ if (localTracks.length) {
|
336
|
337
|
transceiver.direction = 'sendrecv';
|
337
|
338
|
const parameters = transceiver.sender.getParameters();
|
338
|
339
|
|
|
@@ -352,13 +353,19 @@ export class TPCUtils {
|
352
|
353
|
});
|
353
|
354
|
}
|
354
|
355
|
|
355
|
|
- return true;
|
|
356
|
+ return false;
|
356
|
357
|
}
|
357
|
358
|
|
358
|
359
|
/**
|
359
|
|
- *
|
360
|
|
- * @param {boolean} active
|
361
|
|
- */
|
|
360
|
+ * Enables/disables video media transmission on the peer connection. When
|
|
361
|
+ * disabled the SDP video media direction in the local SDP will be adjusted to
|
|
362
|
+ * 'inactive' which means that no data will be sent nor accepted, but
|
|
363
|
+ * the connection should be kept alive.
|
|
364
|
+ * @param {boolean} active - true to enable video media transmission or
|
|
365
|
+ * false to disable.
|
|
366
|
+ * @returns {false} - returns false always so that renegotiation is not automatically
|
|
367
|
+ * triggered after this operation.
|
|
368
|
+ */
|
362
|
369
|
setVideoTransferActive(active) {
|
363
|
370
|
return this.setMediaTransferActive('video', active);
|
364
|
371
|
}
|