浏览代码

feat(JingleSessionPC) Handle source-add rejects by Jicofo.

tags/v0.0.2
Jaya Allamsetty 4 年前
父节点
当前提交
8aa35dae40
共有 3 个文件被更改,包括 57 次插入6 次删除
  1. 21
    0
      JitsiConference.js
  2. 6
    0
      JitsiConferenceEvents.js
  3. 30
    6
      modules/xmpp/JingleSessionPC.js

+ 21
- 0
JitsiConference.js 查看文件

400
     this._sendConferenceJoinAnalyticsEvent = this._sendConferenceJoinAnalyticsEvent.bind(this);
400
     this._sendConferenceJoinAnalyticsEvent = this._sendConferenceJoinAnalyticsEvent.bind(this);
401
     this.room.addListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
401
     this.room.addListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
402
 
402
 
403
+    this._removeLocalSourceOnReject = this._removeLocalSourceOnReject.bind(this);
403
     this._updateRoomPresence = this._updateRoomPresence.bind(this);
404
     this._updateRoomPresence = this._updateRoomPresence.bind(this);
404
     this.room.addListener(XMPPEvents.SESSION_ACCEPT, this._updateRoomPresence);
405
     this.room.addListener(XMPPEvents.SESSION_ACCEPT, this._updateRoomPresence);
405
     this.room.addListener(XMPPEvents.SOURCE_ADD, this._updateRoomPresence);
406
     this.room.addListener(XMPPEvents.SOURCE_ADD, this._updateRoomPresence);
407
+    this.room.addListener(XMPPEvents.SOURCE_ADD_ERROR, this._removeLocalSourceOnReject);
406
     this.room.addListener(XMPPEvents.SOURCE_REMOVE, this._updateRoomPresence);
408
     this.room.addListener(XMPPEvents.SOURCE_REMOVE, this._updateRoomPresence);
407
 
409
 
408
     this.e2eping = new E2ePing(
410
     this.e2eping = new E2ePing(
692
     room.removeListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
694
     room.removeListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
693
     room.removeListener(XMPPEvents.SESSION_ACCEPT, this._updateRoomPresence);
695
     room.removeListener(XMPPEvents.SESSION_ACCEPT, this._updateRoomPresence);
694
     room.removeListener(XMPPEvents.SOURCE_ADD, this._updateRoomPresence);
696
     room.removeListener(XMPPEvents.SOURCE_ADD, this._updateRoomPresence);
697
+    room.removeListener(XMPPEvents.SOURCE_ADD_ERROR, this._removeLocalSourceOnReject);
695
     room.removeListener(XMPPEvents.SOURCE_REMOVE, this._updateRoomPresence);
698
     room.removeListener(XMPPEvents.SOURCE_REMOVE, this._updateRoomPresence);
696
 
699
 
697
     this.eventManager.removeXMPPListeners();
700
     this.eventManager.removeXMPPListeners();
1311
     return Promise.all(replaceTrackPromises);
1314
     return Promise.all(replaceTrackPromises);
1312
 };
1315
 };
1313
 
1316
 
1317
+/**
1318
+ * Handler for when a source-add for a local source is rejected by Jicofo.
1319
+ *
1320
+ * @param {JingleSessionPC} jingleSession - The media session.
1321
+ * @param {Error} error - The error message.
1322
+ * @param {MediaType} mediaType - The media type of the track associated with the source that was rejected.
1323
+ * @returns {void}
1324
+ */
1325
+JitsiConference.prototype._removeLocalSourceOnReject = function(jingleSession, error, mediaType) {
1326
+    if (!jingleSession) {
1327
+        return;
1328
+    }
1329
+    logger.warn(`Source-add rejected on ${jingleSession}, reason="${error?.reason}", message="${error?.msg}"`);
1330
+    const track = this.getLocalTracks(mediaType)[0];
1331
+
1332
+    this.eventEmitter.emit(JitsiConferenceEvents.TRACK_UNMUTE_REJECTED, track);
1333
+};
1334
+
1314
 /**
1335
 /**
1315
  * Operations related to creating a new track
1336
  * Operations related to creating a new track
1316
  * @param {JitsiLocalTrack} newTrack the new track being created
1337
  * @param {JitsiLocalTrack} newTrack the new track being created

+ 6
- 0
JitsiConferenceEvents.js 查看文件

338
  */
338
  */
339
 export const TRACK_REMOVED = 'conference.trackRemoved';
339
 export const TRACK_REMOVED = 'conference.trackRemoved';
340
 
340
 
341
+/**
342
+ * The source-add for unmuting of a media track was rejected by Jicofo.
343
+ *
344
+ */
345
+export const TRACK_UNMUTE_REJECTED = 'conference.trackUnmuteRejected';
346
+
341
 /**
347
 /**
342
  * Notifies for transcription status changes. The event provides the
348
  * Notifies for transcription status changes. The event provides the
343
  * following parameters to its listeners:
349
  * following parameters to its listeners:

+ 30
- 6
modules/xmpp/JingleSessionPC.js 查看文件

2487
      * @param newSDP SDP object for new description.
2487
      * @param newSDP SDP object for new description.
2488
      */
2488
      */
2489
     notifyMySSRCUpdate(oldSDP, newSDP) {
2489
     notifyMySSRCUpdate(oldSDP, newSDP) {
2490
-
2491
         if (this.state !== JingleSessionState.ACTIVE) {
2490
         if (this.state !== JingleSessionState.ACTIVE) {
2492
             logger.warn(`${this} Skipping SSRC update in '${this.state} ' state.`);
2491
             logger.warn(`${this} Skipping SSRC update in '${this.state} ' state.`);
2493
 
2492
 
2508
         this._cachedOldLocalSdp = undefined;
2507
         this._cachedOldLocalSdp = undefined;
2509
         this._cachedNewLocalSdp = undefined;
2508
         this._cachedNewLocalSdp = undefined;
2510
 
2509
 
2510
+        const getSignaledSourceInfo = sdpDiffer => {
2511
+            const newMedia = sdpDiffer.getNewMedia();
2512
+            let ssrcs = [];
2513
+            let mediaType = null;
2514
+
2515
+            // It is assumed that sources are signaled one at a time.
2516
+            Object.keys(newMedia).forEach(mediaIndex => {
2517
+                const signaledSsrcs = Object.keys(newMedia[mediaIndex].ssrcs);
2518
+
2519
+                mediaType = newMedia[mediaIndex].mid;
2520
+                if (signaledSsrcs?.length) {
2521
+                    ssrcs = ssrcs.concat(signaledSsrcs);
2522
+                }
2523
+            });
2524
+
2525
+            return {
2526
+                mediaType,
2527
+                ssrcs
2528
+            };
2529
+        };
2530
+
2511
         // send source-remove IQ.
2531
         // send source-remove IQ.
2512
         let sdpDiffer = new SDPDiffer(newSDP, oldSDP);
2532
         let sdpDiffer = new SDPDiffer(newSDP, oldSDP);
2513
         const remove = $iq({ to: this.remoteJid,
2533
         const remove = $iq({ to: this.remoteJid,
2526
         const ctx = {};
2546
         const ctx = {};
2527
 
2547
 
2528
         if (removedAnySSRCs) {
2548
         if (removedAnySSRCs) {
2529
-            logger.info(`${this} Sending source-remove`);
2530
-            logger.debug(remove.tree());
2549
+            const sourceInfo = getSignaledSourceInfo(sdpDiffer);
2550
+
2551
+            // Log only the SSRCs instead of the full IQ.
2552
+            logger.info(`${this} Sending source-remove for ${sourceInfo.mediaType} ssrcs=${sourceInfo.ssrcs}`);
2531
             this.connection.sendIQ(
2553
             this.connection.sendIQ(
2532
                 remove,
2554
                 remove,
2533
                 () => {
2555
                 () => {
2554
         const containsNewSSRCs = sdpDiffer.toJingle(add);
2576
         const containsNewSSRCs = sdpDiffer.toJingle(add);
2555
 
2577
 
2556
         if (containsNewSSRCs) {
2578
         if (containsNewSSRCs) {
2557
-            logger.info(`${this} Sending source-add`);
2558
-            logger.debug(add.tree());
2579
+            const sourceInfo = getSignaledSourceInfo(sdpDiffer);
2580
+
2581
+            // Log only the SSRCs instead of the full IQ.
2582
+            logger.info(`${this} Sending source-add for ${sourceInfo.mediaType} ssrcs=${sourceInfo.ssrcs}`);
2559
             this.connection.sendIQ(
2583
             this.connection.sendIQ(
2560
                 add,
2584
                 add,
2561
                 () => {
2585
                 () => {
2562
                     this.room.eventEmitter.emit(XMPPEvents.SOURCE_ADD, this, ctx);
2586
                     this.room.eventEmitter.emit(XMPPEvents.SOURCE_ADD, this, ctx);
2563
                 },
2587
                 },
2564
                 this.newJingleErrorHandler(add, error => {
2588
                 this.newJingleErrorHandler(add, error => {
2565
-                    this.room.eventEmitter.emit(XMPPEvents.SOURCE_ADD_ERROR, this, error, ctx);
2589
+                    this.room.eventEmitter.emit(XMPPEvents.SOURCE_ADD_ERROR, this, error, sourceInfo.mediaType, ctx);
2566
                 }),
2590
                 }),
2567
                 IQ_TIMEOUT);
2591
                 IQ_TIMEOUT);
2568
         }
2592
         }

正在加载...
取消
保存