Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
a6975ee4cb
1 değiştirilmiş dosya ile 55 ekleme ve 0 silme
  1. 55
    0
      modules/xmpp/JingleSessionPC.js

+ 55
- 0
modules/xmpp/JingleSessionPC.js Dosyayı Görüntüle

20
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
20
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
21
 import AsyncQueue from '../util/AsyncQueue';
21
 import AsyncQueue from '../util/AsyncQueue';
22
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
22
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
23
+import XmppConnection from './XmppConnection';
23
 
24
 
24
 const logger = getLogger(__filename);
25
 const logger = getLogger(__filename);
25
 
26
 
137
          */
138
          */
138
         this._bridgeSessionId = null;
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
          * Stores result of {@link window.performance.now()} at the time when
158
          * Stores result of {@link window.performance.now()} at the time when
142
          * ICE enters 'checking' state.
159
          * ICE enters 'checking' state.
232
          * @type {number}
249
          * @type {number}
233
          */
250
          */
234
         this.establishmentDuration = undefined;
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
     /* eslint-enable max-params */
261
     /* eslint-enable max-params */
1329
         // this.reasonText = reasonText;
1353
         // this.reasonText = reasonText;
1330
         logger.info(`Session terminated ${this}`, reasonCondition, reasonText);
1354
         logger.info(`Session terminated ${this}`, reasonCondition, reasonText);
1331
 
1355
 
1356
+        this._xmppListeners.forEach(removeListener => removeListener());
1357
+        this._xmppListeners = [];
1358
+
1332
         this.close();
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
      * Parse the information from the xml sourceAddElem and translate it
1377
      * Parse the information from the xml sourceAddElem and translate it
1337
      *  into sdp lines
1378
      *  into sdp lines
2133
             return;
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
         // send source-remove IQ.
2191
         // send source-remove IQ.
2137
         let sdpDiffer = new SDPDiffer(newSDP, oldSDP);
2192
         let sdpDiffer = new SDPDiffer(newSDP, oldSDP);
2138
         const remove = $iq({ to: this.remoteJid,
2193
         const remove = $iq({ to: this.remoteJid,

Loading…
İptal
Kaydet