소스 검색

ref(JingleSessionPC): send source update upon reconnect

Given that the XMPP connection is able to reconnect after a drop, now
the jingle session needs to hold off any updates that have to be sent
while the signalling is down. Send the update upon reconnect to sync
Jicofo and JVB with the client's source description.
master
paweldomas 5 년 전
부모
커밋
a6975ee4cb
1개의 변경된 파일55개의 추가작업 그리고 0개의 파일을 삭제
  1. 55
    0
      modules/xmpp/JingleSessionPC.js

+ 55
- 0
modules/xmpp/JingleSessionPC.js 파일 보기

@@ -20,6 +20,7 @@ import Statistics from '../statistics/statistics';
20 20
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
21 21
 import AsyncQueue from '../util/AsyncQueue';
22 22
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
23
+import XmppConnection from './XmppConnection';
23 24
 
24 25
 const logger = getLogger(__filename);
25 26
 
@@ -137,6 +138,22 @@ export default class JingleSessionPC extends JingleSession {
137 138
          */
138 139
         this._bridgeSessionId = null;
139 140
 
141
+        /**
142
+         * The oldest SDP passed to {@link notifyMySSRCUpdate} while the XMPP connection was offline that will be
143
+         * used to update Jicofo once the XMPP connection goes back online.
144
+         * @type {SDP|undefined}
145
+         * @private
146
+         */
147
+        this._cachedOldLocalSdp = undefined;
148
+
149
+        /**
150
+         * The latest SDP passed to {@link notifyMySSRCUpdate} while the XMPP connection was offline that will be
151
+         * used to update Jicofo once the XMPP connection goes back online.
152
+         * @type {SDP|undefined}
153
+         * @private
154
+         */
155
+        this._cachedNewLocalSdp = undefined;
156
+
140 157
         /**
141 158
          * Stores result of {@link window.performance.now()} at the time when
142 159
          * ICE enters 'checking' state.
@@ -232,6 +249,13 @@ export default class JingleSessionPC extends JingleSession {
232 249
          * @type {number}
233 250
          */
234 251
         this.establishmentDuration = undefined;
252
+
253
+        this._xmppListeners = [];
254
+        this._xmppListeners.push(
255
+            connection.addEventListener(
256
+                XmppConnection.Events.CONN_STATUS_CHANGED,
257
+                this.onXmppStatusChanged.bind(this))
258
+        );
235 259
     }
236 260
 
237 261
     /* eslint-enable max-params */
@@ -1329,9 +1353,26 @@ export default class JingleSessionPC extends JingleSession {
1329 1353
         // this.reasonText = reasonText;
1330 1354
         logger.info(`Session terminated ${this}`, reasonCondition, reasonText);
1331 1355
 
1356
+        this._xmppListeners.forEach(removeListener => removeListener());
1357
+        this._xmppListeners = [];
1358
+
1332 1359
         this.close();
1333 1360
     }
1334 1361
 
1362
+    /**
1363
+     * Handles XMPP connection state changes.
1364
+     *
1365
+     * @param {XmppConnection.Status} status - The new status.
1366
+     */
1367
+    onXmppStatusChanged(status) {
1368
+        if (status === XmppConnection.Status.CONNECTED && this._cachedOldLocalSdp) {
1369
+            logger.info('Sending SSRC update on reconnect');
1370
+            this.notifyMySSRCUpdate(
1371
+                this._cachedOldLocalSdp,
1372
+                this._cachedNewLocalSdp);
1373
+        }
1374
+    }
1375
+
1335 1376
     /**
1336 1377
      * Parse the information from the xml sourceAddElem and translate it
1337 1378
      *  into sdp lines
@@ -2133,6 +2174,20 @@ export default class JingleSessionPC extends JingleSession {
2133 2174
             return;
2134 2175
         }
2135 2176
 
2177
+        if (!this.connection.connected) {
2178
+            // The goal is to compare the oldest SDP with the latest one upon reconnect
2179
+            if (!this._cachedOldLocalSdp) {
2180
+                this._cachedOldLocalSdp = oldSDP;
2181
+            }
2182
+            this._cachedNewLocalSdp = newSDP;
2183
+            logger.warn('Not sending SSRC update while the signaling is disconnected');
2184
+
2185
+            return;
2186
+        }
2187
+
2188
+        this._cachedOldLocalSdp = undefined;
2189
+        this._cachedNewLocalSdp = undefined;
2190
+
2136 2191
         // send source-remove IQ.
2137 2192
         let sdpDiffer = new SDPDiffer(newSDP, oldSDP);
2138 2193
         const remove = $iq({ to: this.remoteJid,

Loading…
취소
저장