|
@@ -205,16 +205,18 @@ export default function TraceablePeerConnection(
|
205
|
205
|
|
206
|
206
|
// SignalingLayer listeners
|
207
|
207
|
this._peerVideoTypeChanged = this._peerVideoTypeChanged.bind(this);
|
208
|
|
- this.signalingLayer.on(
|
209
|
|
- SignalingEvents.PEER_VIDEO_TYPE_CHANGED,
|
210
|
|
- this._peerVideoTypeChanged);
|
|
208
|
+ this.signalingLayer.on(SignalingEvents.PEER_VIDEO_TYPE_CHANGED, this._peerVideoTypeChanged);
|
211
|
209
|
|
212
|
210
|
this._peerMutedChanged = this._peerMutedChanged.bind(this);
|
213
|
|
- this.signalingLayer.on(
|
214
|
|
- SignalingEvents.PEER_MUTED_CHANGED,
|
215
|
|
- this._peerMutedChanged);
|
|
211
|
+ this.signalingLayer.on(SignalingEvents.PEER_MUTED_CHANGED, this._peerMutedChanged);
|
216
|
212
|
this.options = options;
|
217
|
213
|
|
|
214
|
+ // Setup SignalingLayer listeners for source-name based events.
|
|
215
|
+ this.signalingLayer.on(SignalingEvents.SOURCE_MUTED_CHANGED,
|
|
216
|
+ (sourceName, isMuted) => this._sourceMutedChanged(sourceName, isMuted));
|
|
217
|
+ this.signalingLayer.on(SignalingEvents.SOURCE_VIDEO_TYPE_CHANGED,
|
|
218
|
+ (sourceName, videoType) => this._sourceVideoTypeChanged(sourceName, videoType));
|
|
219
|
+
|
218
|
220
|
// Make sure constraints is properly formatted in order to provide information about whether or not this
|
219
|
221
|
// connection is P2P to rtcstats.
|
220
|
222
|
const safeConstraints = constraints || {};
|
|
@@ -530,9 +532,7 @@ TraceablePeerConnection.prototype.isSimulcastOn = function() {
|
530
|
532
|
* @param {VideoType} videoType the new value
|
531
|
533
|
* @private
|
532
|
534
|
*/
|
533
|
|
-TraceablePeerConnection.prototype._peerVideoTypeChanged = function(
|
534
|
|
- endpointId,
|
535
|
|
- videoType) {
|
|
535
|
+TraceablePeerConnection.prototype._peerVideoTypeChanged = function(endpointId, videoType) {
|
536
|
536
|
// Check if endpointId has a value to avoid action on random track
|
537
|
537
|
if (!endpointId) {
|
538
|
538
|
logger.error(`${this} No endpointID on peerVideoTypeChanged`);
|
|
@@ -554,10 +554,7 @@ TraceablePeerConnection.prototype._peerVideoTypeChanged = function(
|
554
|
554
|
* @param {boolean} isMuted the new mute state
|
555
|
555
|
* @private
|
556
|
556
|
*/
|
557
|
|
-TraceablePeerConnection.prototype._peerMutedChanged = function(
|
558
|
|
- endpointId,
|
559
|
|
- mediaType,
|
560
|
|
- isMuted) {
|
|
557
|
+TraceablePeerConnection.prototype._peerMutedChanged = function(endpointId, mediaType, isMuted) {
|
561
|
558
|
// Check if endpointId is a value to avoid doing action on all remote tracks
|
562
|
559
|
if (!endpointId) {
|
563
|
560
|
logger.error(`${this} On peerMuteChanged - no endpoint ID`);
|
|
@@ -572,6 +569,38 @@ TraceablePeerConnection.prototype._peerMutedChanged = function(
|
572
|
569
|
}
|
573
|
570
|
};
|
574
|
571
|
|
|
572
|
+/**
|
|
573
|
+ * Handles remote source mute and unmute changed events.
|
|
574
|
+ *
|
|
575
|
+ * @param {string} sourceName - The name of the remote source.
|
|
576
|
+ * @param {boolean} isMuted - The new mute state.
|
|
577
|
+ */
|
|
578
|
+TraceablePeerConnection.prototype._sourceMutedChanged = function(sourceName, isMuted) {
|
|
579
|
+ const track = this.getRemoteTracks().find(t => t.getSourceName() === sourceName);
|
|
580
|
+
|
|
581
|
+ if (!track) {
|
|
582
|
+ return;
|
|
583
|
+ }
|
|
584
|
+
|
|
585
|
+ track.setMute(isMuted);
|
|
586
|
+};
|
|
587
|
+
|
|
588
|
+/**
|
|
589
|
+ * Handles remote source videoType changed events.
|
|
590
|
+ *
|
|
591
|
+ * @param {string} sourceName - The name of the remote source.
|
|
592
|
+ * @param {boolean} isMuted - The new value.
|
|
593
|
+ */
|
|
594
|
+TraceablePeerConnection.prototype._sourceVideoTypeChanged = function(sourceName, videoType) {
|
|
595
|
+ const track = this.getRemoteTracks().find(t => t.getSourceName() === sourceName);
|
|
596
|
+
|
|
597
|
+ if (!track) {
|
|
598
|
+ return;
|
|
599
|
+ }
|
|
600
|
+
|
|
601
|
+ track._setVideoType(videoType);
|
|
602
|
+};
|
|
603
|
+
|
575
|
604
|
/**
|
576
|
605
|
* Obtains audio levels of the remote audio tracks by getting the source information on the RTCRtpReceivers.
|
577
|
606
|
* The information relevant to the ssrc is updated each time a RTP packet constaining the ssrc is received.
|