Browse Source

fix(multi-stream) Handle source-name based presence updates.

Handle presence updates for multiple sources per remote endpoint.
dev1
Jaya Allamsetty 3 years ago
parent
commit
665ab17499

+ 42
- 13
modules/RTC/TraceablePeerConnection.js View File

205
 
205
 
206
     // SignalingLayer listeners
206
     // SignalingLayer listeners
207
     this._peerVideoTypeChanged = this._peerVideoTypeChanged.bind(this);
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
     this._peerMutedChanged = this._peerMutedChanged.bind(this);
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
     this.options = options;
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
     // Make sure constraints is properly formatted in order to provide information about whether or not this
220
     // Make sure constraints is properly formatted in order to provide information about whether or not this
219
     // connection is P2P to rtcstats.
221
     // connection is P2P to rtcstats.
220
     const safeConstraints = constraints || {};
222
     const safeConstraints = constraints || {};
530
  * @param {VideoType} videoType the new value
532
  * @param {VideoType} videoType the new value
531
  * @private
533
  * @private
532
  */
534
  */
533
-TraceablePeerConnection.prototype._peerVideoTypeChanged = function(
534
-        endpointId,
535
-        videoType) {
535
+TraceablePeerConnection.prototype._peerVideoTypeChanged = function(endpointId, videoType) {
536
     // Check if endpointId has a value to avoid action on random track
536
     // Check if endpointId has a value to avoid action on random track
537
     if (!endpointId) {
537
     if (!endpointId) {
538
         logger.error(`${this} No endpointID on peerVideoTypeChanged`);
538
         logger.error(`${this} No endpointID on peerVideoTypeChanged`);
554
  * @param {boolean} isMuted the new mute state
554
  * @param {boolean} isMuted the new mute state
555
  * @private
555
  * @private
556
  */
556
  */
557
-TraceablePeerConnection.prototype._peerMutedChanged = function(
558
-        endpointId,
559
-        mediaType,
560
-        isMuted) {
557
+TraceablePeerConnection.prototype._peerMutedChanged = function(endpointId, mediaType, isMuted) {
561
     // Check if endpointId is a value to avoid doing action on all remote tracks
558
     // Check if endpointId is a value to avoid doing action on all remote tracks
562
     if (!endpointId) {
559
     if (!endpointId) {
563
         logger.error(`${this} On peerMuteChanged - no endpoint ID`);
560
         logger.error(`${this} On peerMuteChanged - no endpoint ID`);
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
  * Obtains audio levels of the remote audio tracks by getting the source information on the RTCRtpReceivers.
605
  * Obtains audio levels of the remote audio tracks by getting the source information on the RTCRtpReceivers.
577
  * The information relevant to the ssrc is updated each time a RTP packet constaining the ssrc is received.
606
  * The information relevant to the ssrc is updated each time a RTP packet constaining the ssrc is received.

+ 7
- 9
modules/xmpp/SignalingLayerImpl.js View File

218
 
218
 
219
                 if (oldSourceState.muted !== newMutedState) {
219
                 if (oldSourceState.muted !== newMutedState) {
220
                     oldSourceState.muted = newMutedState;
220
                     oldSourceState.muted = newMutedState;
221
-                    if (emitEventsFromHere && mediaType === MediaType.AUDIO) {
222
-                        emitAudioMutedEvent(endpointId, newMutedState);
223
-                    } else {
224
-                        emitVideoMutedEvent(endpointId, newMutedState);
221
+                    if (emitEventsFromHere && !this._localSourceState[sourceName]) {
222
+                        this.eventEmitter.emit(SignalingEvents.SOURCE_MUTED_CHANGED, sourceName, newMutedState);
225
                     }
223
                     }
226
                 }
224
                 }
227
 
225
 
233
                 if (oldSourceState.videoType !== newVideoType) {
231
                 if (oldSourceState.videoType !== newVideoType) {
234
                     oldSourceState.videoType = newVideoType;
232
                     oldSourceState.videoType = newVideoType;
235
 
233
 
236
-                    // videoType is not allowed to change on a given JitsiLocalTrack when multi stream support is
237
-                    // enabled.
238
-                    emitEventsFromHere
239
-                        && !FeatureFlags.isMultiStreamSupportEnabled()
240
-                        && emitVideoTypeEvent(endpointId, newVideoType);
234
+                    // Since having a mix of eps that do/don't support multi-stream in the same call is supported, emit
235
+                    // SOURCE_VIDEO_TYPE_CHANGED event when the remote source changes videoType.
236
+                    if (emitEventsFromHere && !this._localSourceState[sourceName]) {
237
+                        this.eventEmitter.emit(SignalingEvents.SOURCE_VIDEO_TYPE_CHANGED, sourceName, newVideoType);
238
+                    }
241
                 }
239
                 }
242
             }
240
             }
243
 
241
 

+ 2
- 3
modules/xmpp/SignalingLayerImpl.spec.js View File

200
                 // Just once event though the legacy presence is there as well
200
                 // Just once event though the legacy presence is there as well
201
                 expect(emitterSpy).toHaveBeenCalledTimes(1);
201
                 expect(emitterSpy).toHaveBeenCalledTimes(1);
202
                 expect(emitterSpy).toHaveBeenCalledWith(
202
                 expect(emitterSpy).toHaveBeenCalledWith(
203
-                    SignalingEvents.PEER_MUTED_CHANGED,
204
-                    'endpoint1',
205
-                    'audio',
203
+                    SignalingEvents.SOURCE_MUTED_CHANGED,
204
+                    '12345678-a0',
206
                     true
205
                     true
207
                 );
206
                 );
208
             });
207
             });

+ 4
- 0
service/RTC/SignalingEvents.spec.ts View File

6
     const {
6
     const {
7
         PEER_MUTED_CHANGED,
7
         PEER_MUTED_CHANGED,
8
         PEER_VIDEO_TYPE_CHANGED,
8
         PEER_VIDEO_TYPE_CHANGED,
9
+        SOURCE_MUTED_CHANGED,
10
+        SOURCE_VIDEO_TYPE_CHANGED,
9
         SignalingEvents,
11
         SignalingEvents,
10
         ...others
12
         ...others
11
     } = exported;
13
     } = exported;
13
     it( "known members", () => {
15
     it( "known members", () => {
14
         expect( PEER_MUTED_CHANGED ).toBe( 'signaling.peerMuted' );
16
         expect( PEER_MUTED_CHANGED ).toBe( 'signaling.peerMuted' );
15
         expect( PEER_VIDEO_TYPE_CHANGED ).toBe( 'signaling.peerVideoType' );
17
         expect( PEER_VIDEO_TYPE_CHANGED ).toBe( 'signaling.peerVideoType' );
18
+        expect( SOURCE_MUTED_CHANGED ).toBe( 'signaling.sourceMuted');
19
+        expect( SOURCE_VIDEO_TYPE_CHANGED ).toBe( 'signaling.sourceVideoType');
16
 
20
 
17
         expect( SignalingEvents ).toBeDefined();
21
         expect( SignalingEvents ).toBeDefined();
18
 
22
 

+ 21
- 1
service/RTC/SignalingEvents.ts View File

1
 export enum SignalingEvents {
1
 export enum SignalingEvents {
2
     /**
2
     /**
3
      * Event triggered when participant's muted status changes.
3
      * Event triggered when participant's muted status changes.
4
+     *
4
      * @param {string} endpointId the track owner's identifier (MUC nickname)
5
      * @param {string} endpointId the track owner's identifier (MUC nickname)
5
      * @param {MediaType} mediaType "audio" or "video"
6
      * @param {MediaType} mediaType "audio" or "video"
6
      * @param {boolean} isMuted the new muted state
7
      * @param {boolean} isMuted the new muted state
9
 
10
 
10
     /**
11
     /**
11
      * Event triggered when participant's video type changes.
12
      * Event triggered when participant's video type changes.
13
+     *
12
      * @param {string} endpointId the video owner's ID (MUC nickname)
14
      * @param {string} endpointId the video owner's ID (MUC nickname)
13
      * @param {VideoType} videoType the new value
15
      * @param {VideoType} videoType the new value
14
      */
16
      */
15
-    PEER_VIDEO_TYPE_CHANGED = 'signaling.peerVideoType'
17
+    PEER_VIDEO_TYPE_CHANGED = 'signaling.peerVideoType',
18
+
19
+    /**
20
+     * Event triggered when source's muted status changes.
21
+     *
22
+     * @param {string} sourceName - The name of the source.
23
+     * @param {boolean} isMuted - The new muted state.
24
+     */
25
+    SOURCE_MUTED_CHANGED = 'signaling.sourceMuted',
26
+
27
+    /**
28
+     * Event triggered when source's video type changes.
29
+     *
30
+     * @param {string} source - The name of the source.
31
+     * @param {VideoType} videoType - The new value.
32
+     */
33
+    SOURCE_VIDEO_TYPE_CHANGED = 'signaling.sourceVideoType'
16
 }
34
 }
17
 
35
 
18
 // exported for backward compatibility
36
 // exported for backward compatibility
19
 export const PEER_MUTED_CHANGED = SignalingEvents.PEER_MUTED_CHANGED;
37
 export const PEER_MUTED_CHANGED = SignalingEvents.PEER_MUTED_CHANGED;
20
 export const PEER_VIDEO_TYPE_CHANGED = SignalingEvents.PEER_VIDEO_TYPE_CHANGED;
38
 export const PEER_VIDEO_TYPE_CHANGED = SignalingEvents.PEER_VIDEO_TYPE_CHANGED;
39
+export const SOURCE_MUTED_CHANGED = SignalingEvents.SOURCE_MUTED_CHANGED;
40
+export const SOURCE_VIDEO_TYPE_CHANGED = SignalingEvents.SOURCE_VIDEO_TYPE_CHANGED;

+ 14
- 0
types/auto/modules/RTC/TraceablePeerConnection.d.ts View File

292
      * <tt>false</tt> if it's turned off.
292
      * <tt>false</tt> if it's turned off.
293
      */
293
      */
294
     isSimulcastOn(): boolean;
294
     isSimulcastOn(): boolean;
295
+    /**
296
+     * Handles remote source mute and unmute changed events.
297
+     *
298
+     * @param {string} sourceName - The name of the remote source.
299
+     * @param {boolean} isMuted - The new mute state.
300
+     */
301
+    _sourceMutedChanged(sourceName: string, isMuted: boolean): void;
302
+    /**
303
+     * Handles remote source videoType changed events.
304
+     *
305
+     * @param {string} sourceName - The name of the remote source.
306
+     * @param {boolean} isMuted - The new value.
307
+     */
308
+    _sourceVideoTypeChanged(sourceName: string, videoType: any): void;
295
     /**
309
     /**
296
      * Obtains audio levels of the remote audio tracks by getting the source information on the RTCRtpReceivers.
310
      * Obtains audio levels of the remote audio tracks by getting the source information on the RTCRtpReceivers.
297
      * The information relevant to the ssrc is updated each time a RTP packet constaining the ssrc is received.
311
      * The information relevant to the ssrc is updated each time a RTP packet constaining the ssrc is received.

+ 19
- 1
types/auto/service/RTC/SignalingEvents.d.ts View File

1
 export declare enum SignalingEvents {
1
 export declare enum SignalingEvents {
2
     /**
2
     /**
3
      * Event triggered when participant's muted status changes.
3
      * Event triggered when participant's muted status changes.
4
+     *
4
      * @param {string} endpointId the track owner's identifier (MUC nickname)
5
      * @param {string} endpointId the track owner's identifier (MUC nickname)
5
      * @param {MediaType} mediaType "audio" or "video"
6
      * @param {MediaType} mediaType "audio" or "video"
6
      * @param {boolean} isMuted the new muted state
7
      * @param {boolean} isMuted the new muted state
8
     PEER_MUTED_CHANGED = "signaling.peerMuted",
9
     PEER_MUTED_CHANGED = "signaling.peerMuted",
9
     /**
10
     /**
10
      * Event triggered when participant's video type changes.
11
      * Event triggered when participant's video type changes.
12
+     *
11
      * @param {string} endpointId the video owner's ID (MUC nickname)
13
      * @param {string} endpointId the video owner's ID (MUC nickname)
12
      * @param {VideoType} videoType the new value
14
      * @param {VideoType} videoType the new value
13
      */
15
      */
14
-    PEER_VIDEO_TYPE_CHANGED = "signaling.peerVideoType"
16
+    PEER_VIDEO_TYPE_CHANGED = "signaling.peerVideoType",
17
+    /**
18
+     * Event triggered when source's muted status changes.
19
+     *
20
+     * @param {string} sourceName - The name of the source.
21
+     * @param {boolean} isMuted - The new muted state.
22
+     */
23
+    SOURCE_MUTED_CHANGED = "signaling.sourceMuted",
24
+    /**
25
+     * Event triggered when source's video type changes.
26
+     *
27
+     * @param {string} source - The name of the source.
28
+     * @param {VideoType} videoType - The new value.
29
+     */
30
+    SOURCE_VIDEO_TYPE_CHANGED = "signaling.sourceVideoType"
15
 }
31
 }
16
 export declare const PEER_MUTED_CHANGED = SignalingEvents.PEER_MUTED_CHANGED;
32
 export declare const PEER_MUTED_CHANGED = SignalingEvents.PEER_MUTED_CHANGED;
17
 export declare const PEER_VIDEO_TYPE_CHANGED = SignalingEvents.PEER_VIDEO_TYPE_CHANGED;
33
 export declare const PEER_VIDEO_TYPE_CHANGED = SignalingEvents.PEER_VIDEO_TYPE_CHANGED;
34
+export declare const SOURCE_MUTED_CHANGED = SignalingEvents.SOURCE_MUTED_CHANGED;
35
+export declare const SOURCE_VIDEO_TYPE_CHANGED = SignalingEvents.SOURCE_VIDEO_TYPE_CHANGED;

Loading…
Cancel
Save