Browse Source

feat: Add an option to prefer SCTP (if offered) over a colibri-ws. (#2227)

master
bgrozev 2 years ago
parent
commit
d43c349dbc
No account linked to committer's email address
1 changed files with 29 additions and 21 deletions
  1. 29
    21
      JitsiConference.js

+ 29
- 21
JitsiConference.js View File

@@ -2320,37 +2320,45 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(jingleSession, jingl
2320 2320
  */
2321 2321
 JitsiConference.prototype._setBridgeChannel = function(offerIq, pc) {
2322 2322
     const ignoreDomain = this.connection?.options?.bridgeChannel?.ignoreDomain;
2323
+    const preferSctp = this.connection?.options?.bridgeChannel?.preferSctp ?? false;
2324
+    const sctpOffered = $(offerIq).find('>content[name="data"]')
2325
+        .first().length === 1;
2323 2326
     let wsUrl = null;
2324 2327
 
2325
-    $(offerIq).find('>content>transport>web-socket')
2326
-        .toArray()
2327
-        .map(e => e.getAttribute('url'))
2328
-        .forEach(url => {
2329
-            if (!wsUrl && (!ignoreDomain || ignoreDomain !== new URL(url).hostname)) {
2330
-                wsUrl = url;
2331
-                logger.info(`Using colibri-ws url ${url}`);
2332
-            } else if (!wsUrl) {
2333
-                logger.info(`Ignoring colibri-ws url with domain ${ignoreDomain}`);
2334
-            }
2335
-        });
2328
+    logger.info(`SCTP: offered=${sctpOffered}, prefered=${preferSctp}`);
2329
+
2330
+    if (!(sctpOffered && preferSctp)) {
2331
+        $(offerIq).find('>content>transport>web-socket')
2332
+            .toArray()
2333
+            .map(e => e.getAttribute('url'))
2334
+            .forEach(url => {
2335
+                if (!wsUrl && (!ignoreDomain || ignoreDomain !== new URL(url).hostname)) {
2336
+                    wsUrl = url;
2337
+                    logger.info(`Using colibri-ws url ${url}`);
2338
+                } else if (!wsUrl) {
2339
+                    logger.info(`Ignoring colibri-ws url with domain ${ignoreDomain}`);
2340
+                }
2341
+            });
2336 2342
 
2337
-    if (!wsUrl) {
2338
-        const firstWsUrl = $(offerIq).find('>content>transport>web-socket')
2339
-            .first();
2343
+        if (!wsUrl) {
2344
+            const firstWsUrl = $(offerIq).find('>content>transport>web-socket')
2345
+                .first();
2340 2346
 
2341
-        if (firstWsUrl.length === 1) {
2342
-            wsUrl = firstWsUrl[0].getAttribute('url');
2343
-            logger.info(`Falling back to ${wsUrl}`);
2347
+            if (firstWsUrl.length === 1) {
2348
+                wsUrl = firstWsUrl[0].getAttribute('url');
2349
+                logger.info(`Falling back to ${wsUrl}`);
2350
+            }
2344 2351
         }
2345 2352
     }
2346 2353
 
2347
-    if (wsUrl) {
2348
-        // If the offer contains a websocket use it.
2354
+    if (wsUrl && !(sctpOffered && preferSctp)) {
2355
+        // If the offer contains a websocket and we don't prefer SCTP use it.
2349 2356
         this.rtc.initializeBridgeChannel(null, wsUrl);
2350
-    } else {
2357
+    } else if (sctpOffered) {
2351 2358
         // Otherwise, fall back to an attempt to use SCTP.
2352
-        logger.info('No colibri-ws found.');
2353 2359
         this.rtc.initializeBridgeChannel(pc, null);
2360
+    } else {
2361
+        logger.warn('Neither SCTP nor a websocket is available. Will not initialize bridge channel.');
2354 2362
     }
2355 2363
 };
2356 2364
 

Loading…
Cancel
Save