Procházet zdrojové kódy

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

Handle presence updates for multiple sources per remote endpoint.
dev1
Jaya Allamsetty před 3 roky
rodič
revize
665ab17499

+ 42
- 13
modules/RTC/TraceablePeerConnection.js Zobrazit soubor

@@ -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.

+ 7
- 9
modules/xmpp/SignalingLayerImpl.js Zobrazit soubor

@@ -218,10 +218,8 @@ export default class SignalingLayerImpl extends SignalingLayer {
218 218
 
219 219
                 if (oldSourceState.muted !== newMutedState) {
220 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,11 +231,11 @@ export default class SignalingLayerImpl extends SignalingLayer {
233 231
                 if (oldSourceState.videoType !== newVideoType) {
234 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 Zobrazit soubor

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

+ 4
- 0
service/RTC/SignalingEvents.spec.ts Zobrazit soubor

@@ -6,6 +6,8 @@ describe( "/service/RTC/SignalingEvents members", () => {
6 6
     const {
7 7
         PEER_MUTED_CHANGED,
8 8
         PEER_VIDEO_TYPE_CHANGED,
9
+        SOURCE_MUTED_CHANGED,
10
+        SOURCE_VIDEO_TYPE_CHANGED,
9 11
         SignalingEvents,
10 12
         ...others
11 13
     } = exported;
@@ -13,6 +15,8 @@ describe( "/service/RTC/SignalingEvents members", () => {
13 15
     it( "known members", () => {
14 16
         expect( PEER_MUTED_CHANGED ).toBe( 'signaling.peerMuted' );
15 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 21
         expect( SignalingEvents ).toBeDefined();
18 22
 

+ 21
- 1
service/RTC/SignalingEvents.ts Zobrazit soubor

@@ -1,6 +1,7 @@
1 1
 export enum SignalingEvents {
2 2
     /**
3 3
      * Event triggered when participant's muted status changes.
4
+     *
4 5
      * @param {string} endpointId the track owner's identifier (MUC nickname)
5 6
      * @param {MediaType} mediaType "audio" or "video"
6 7
      * @param {boolean} isMuted the new muted state
@@ -9,12 +10,31 @@ export enum SignalingEvents {
9 10
 
10 11
     /**
11 12
      * Event triggered when participant's video type changes.
13
+     *
12 14
      * @param {string} endpointId the video owner's ID (MUC nickname)
13 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 36
 // exported for backward compatibility
19 37
 export const PEER_MUTED_CHANGED = SignalingEvents.PEER_MUTED_CHANGED;
20 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 Zobrazit soubor

@@ -292,6 +292,20 @@ export default class TraceablePeerConnection {
292 292
      * <tt>false</tt> if it's turned off.
293 293
      */
294 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 310
      * Obtains audio levels of the remote audio tracks by getting the source information on the RTCRtpReceivers.
297 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 Zobrazit soubor

@@ -1,6 +1,7 @@
1 1
 export declare enum SignalingEvents {
2 2
     /**
3 3
      * Event triggered when participant's muted status changes.
4
+     *
4 5
      * @param {string} endpointId the track owner's identifier (MUC nickname)
5 6
      * @param {MediaType} mediaType "audio" or "video"
6 7
      * @param {boolean} isMuted the new muted state
@@ -8,10 +9,27 @@ export declare enum SignalingEvents {
8 9
     PEER_MUTED_CHANGED = "signaling.peerMuted",
9 10
     /**
10 11
      * Event triggered when participant's video type changes.
12
+     *
11 13
      * @param {string} endpointId the video owner's ID (MUC nickname)
12 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 32
 export declare const PEER_MUTED_CHANGED = SignalingEvents.PEER_MUTED_CHANGED;
17 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;

Načítá se…
Zrušit
Uložit