@wireapp/avs 9.9.8 → 9.10.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/avs_pc.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var ENV_FIREFOX = 1;
4
+ var TIMEOUT_GATHER = 2000;
4
5
  var em_module;
5
6
  var logFn = null;
6
7
  var userMediaHandler = null;
@@ -308,6 +309,21 @@ function ccallGetMediaKey(self, index) {
308
309
  function ccallGetCurrentMediaKey(self) {
309
310
  em_module.ccall("pc_get_current_media_key", null, ["number"], [self]);
310
311
  }
312
+ function gatheringComplete(pc) {
313
+ if (pc.gatherTimer != null) {
314
+ clearTimeout(pc.gatherTimer);
315
+ pc.gatherTimer = null;
316
+ }
317
+ var rtc = pc.rtc;
318
+ if (!rtc) {
319
+ return;
320
+ }
321
+ var sdp = rtc.localDescription;
322
+ if (!sdp) {
323
+ return;
324
+ }
325
+ ccallGatheringHandler(pc, sdp.type.toString(), sdp.sdp.toString());
326
+ }
311
327
  function gatheringHandler(pc) {
312
328
  var rtc = pc.rtc;
313
329
  if (!rtc) {
@@ -321,11 +337,7 @@ function gatheringHandler(pc) {
321
337
  case "gathering":
322
338
  break;
323
339
  case "complete":
324
- var sdp = rtc.localDescription;
325
- if (!sdp) {
326
- return;
327
- }
328
- ccallGatheringHandler(pc, sdp.type.toString(), sdp.sdp.toString());
340
+ gatheringComplete(pc);
329
341
  break;
330
342
  }
331
343
  }
@@ -366,11 +378,21 @@ function candidateHandler(pc, cand) {
366
378
  return;
367
379
  if (!cand) {
368
380
  pc_log(LOG_LEVEL_INFO, 'candidateHandler: end-of-candidates');
369
- var sdp = pc.rtc.localDescription;
370
- if (sdp)
371
- ccallGatheringHandler(pc, sdp.type.toString(), sdp.sdp.toString());
381
+ gatheringComplete(pc);
372
382
  return;
373
383
  }
384
+ /* As soon as we get the first relay, we start a gathering timer
385
+ * this was we ensure that gathering never takes more than the
386
+ * timeout period.
387
+ */
388
+ if (cand.type === 'relay') {
389
+ if (pc.gatherTimer == null) {
390
+ pc.gatherTimer = setTimeout(function () {
391
+ pc.gatherTimer = null;
392
+ gatheringComplete(pc);
393
+ }, TIMEOUT_GATHER);
394
+ }
395
+ }
374
396
  }
375
397
  function connectionHandler(pc) {
376
398
  var rtc = pc.rtc;
@@ -451,6 +473,7 @@ function pc_New(self, convidPtr, audioIvPtr, videoIvPtr, ivlen) {
451
473
  rtt: 0
452
474
  },
453
475
  streams: {},
476
+ gatherTimer: null
454
477
  };
455
478
  worker.postMessage({ op: 'create', self: pc.self, iva: iva8, ivv: ivv8 });
456
479
  var hnd = connectionsStore.storePeerConnection(pc);
package/package.json CHANGED
@@ -21,5 +21,5 @@
21
21
  "prepack": "prettier -w src/avs_wcall.ts && tsc && cp src/*.js src/*.d.ts dist/",
22
22
  "test": "karma start"
23
23
  },
24
- "version": "9.9.8"
24
+ "version": "9.10.9"
25
25
  }