@webex/web-client-media-engine 2.1.3 → 2.1.5

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/esm/index.js CHANGED
@@ -6254,623 +6254,7 @@ function getDefaultExportFromCjs (x) {
6254
6254
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6255
6255
  }
6256
6256
 
6257
- function getAugmentedNamespace(n) {
6258
- if (n.__esModule) return n;
6259
- var a = Object.defineProperty({}, '__esModule', {value: true});
6260
- Object.keys(n).forEach(function (k) {
6261
- var d = Object.getOwnPropertyDescriptor(n, k);
6262
- Object.defineProperty(a, k, d.get ? d : {
6263
- enumerable: true,
6264
- get: function () {
6265
- return n[k];
6266
- }
6267
- });
6268
- });
6269
- return a;
6270
- }
6271
-
6272
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
6273
- // require the crypto API and do not support built-in fallback to lower quality random number
6274
- // generators (like Math.random()).
6275
- var getRandomValues;
6276
- var rnds8 = new Uint8Array(16);
6277
- function rng() {
6278
- // lazy load so that environments that need to polyfill have a chance to do so
6279
- if (!getRandomValues) {
6280
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
6281
- // find the complete implementation of crypto (msCrypto) on IE11.
6282
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
6283
-
6284
- if (!getRandomValues) {
6285
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
6286
- }
6287
- }
6288
-
6289
- return getRandomValues(rnds8);
6290
- }
6291
-
6292
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
6293
-
6294
- function validate(uuid) {
6295
- return typeof uuid === 'string' && REGEX.test(uuid);
6296
- }
6297
-
6298
- /**
6299
- * Convert array of 16 byte values to UUID string format of the form:
6300
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6301
- */
6302
-
6303
- var byteToHex = [];
6304
-
6305
- for (var i = 0; i < 256; ++i) {
6306
- byteToHex.push((i + 0x100).toString(16).substr(1));
6307
- }
6308
-
6309
- function stringify(arr) {
6310
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
6311
- // Note: Be careful editing this code! It's been tuned for performance
6312
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
6313
- var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
6314
- // of the following:
6315
- // - One or more input array values don't map to a hex octet (leading to
6316
- // "undefined" in the uuid)
6317
- // - Invalid input values for the RFC `version` or `variant` fields
6318
-
6319
- if (!validate(uuid)) {
6320
- throw TypeError('Stringified UUID is invalid');
6321
- }
6322
-
6323
- return uuid;
6324
- }
6325
-
6326
- //
6327
- // Inspired by https://github.com/LiosK/UUID.js
6328
- // and http://docs.python.org/library/uuid.html
6329
-
6330
- var _nodeId;
6331
-
6332
- var _clockseq; // Previous uuid creation time
6333
-
6334
-
6335
- var _lastMSecs = 0;
6336
- var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
6337
-
6338
- function v1(options, buf, offset) {
6339
- var i = buf && offset || 0;
6340
- var b = buf || new Array(16);
6341
- options = options || {};
6342
- var node = options.node || _nodeId;
6343
- var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
6344
- // specified. We do this lazily to minimize issues related to insufficient
6345
- // system entropy. See #189
6346
-
6347
- if (node == null || clockseq == null) {
6348
- var seedBytes = options.random || (options.rng || rng)();
6349
-
6350
- if (node == null) {
6351
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
6352
- node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
6353
- }
6354
-
6355
- if (clockseq == null) {
6356
- // Per 4.2.2, randomize (14 bit) clockseq
6357
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
6358
- }
6359
- } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
6360
- // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
6361
- // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
6362
- // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
6363
-
6364
-
6365
- var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
6366
- // cycle to simulate higher resolution clock
6367
-
6368
- var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
6369
-
6370
- var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
6371
-
6372
- if (dt < 0 && options.clockseq === undefined) {
6373
- clockseq = clockseq + 1 & 0x3fff;
6374
- } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
6375
- // time interval
6376
-
6377
-
6378
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
6379
- nsecs = 0;
6380
- } // Per 4.2.1.2 Throw error if too many uuids are requested
6381
-
6382
-
6383
- if (nsecs >= 10000) {
6384
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
6385
- }
6386
-
6387
- _lastMSecs = msecs;
6388
- _lastNSecs = nsecs;
6389
- _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
6390
-
6391
- msecs += 12219292800000; // `time_low`
6392
-
6393
- var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
6394
- b[i++] = tl >>> 24 & 0xff;
6395
- b[i++] = tl >>> 16 & 0xff;
6396
- b[i++] = tl >>> 8 & 0xff;
6397
- b[i++] = tl & 0xff; // `time_mid`
6398
-
6399
- var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
6400
- b[i++] = tmh >>> 8 & 0xff;
6401
- b[i++] = tmh & 0xff; // `time_high_and_version`
6402
-
6403
- b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
6404
-
6405
- b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
6406
-
6407
- b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
6408
-
6409
- b[i++] = clockseq & 0xff; // `node`
6410
-
6411
- for (var n = 0; n < 6; ++n) {
6412
- b[i + n] = node[n];
6413
- }
6414
-
6415
- return buf || stringify(b);
6416
- }
6417
-
6418
- function parse$1(uuid) {
6419
- if (!validate(uuid)) {
6420
- throw TypeError('Invalid UUID');
6421
- }
6422
-
6423
- var v;
6424
- var arr = new Uint8Array(16); // Parse ########-....-....-....-............
6425
-
6426
- arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
6427
- arr[1] = v >>> 16 & 0xff;
6428
- arr[2] = v >>> 8 & 0xff;
6429
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
6430
-
6431
- arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
6432
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
6433
-
6434
- arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
6435
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
6436
-
6437
- arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
6438
- arr[9] = v & 0xff; // Parse ........-....-....-....-############
6439
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
6440
-
6441
- arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
6442
- arr[11] = v / 0x100000000 & 0xff;
6443
- arr[12] = v >>> 24 & 0xff;
6444
- arr[13] = v >>> 16 & 0xff;
6445
- arr[14] = v >>> 8 & 0xff;
6446
- arr[15] = v & 0xff;
6447
- return arr;
6448
- }
6449
-
6450
- function stringToBytes(str) {
6451
- str = unescape(encodeURIComponent(str)); // UTF8 escape
6452
-
6453
- var bytes = [];
6454
-
6455
- for (var i = 0; i < str.length; ++i) {
6456
- bytes.push(str.charCodeAt(i));
6457
- }
6458
-
6459
- return bytes;
6460
- }
6461
-
6462
- var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
6463
- var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
6464
- function v35 (name, version, hashfunc) {
6465
- function generateUUID(value, namespace, buf, offset) {
6466
- if (typeof value === 'string') {
6467
- value = stringToBytes(value);
6468
- }
6469
-
6470
- if (typeof namespace === 'string') {
6471
- namespace = parse$1(namespace);
6472
- }
6473
-
6474
- if (namespace.length !== 16) {
6475
- throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
6476
- } // Compute hash of namespace and value, Per 4.3
6477
- // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
6478
- // hashfunc([...namespace, ... value])`
6479
-
6480
-
6481
- var bytes = new Uint8Array(16 + value.length);
6482
- bytes.set(namespace);
6483
- bytes.set(value, namespace.length);
6484
- bytes = hashfunc(bytes);
6485
- bytes[6] = bytes[6] & 0x0f | version;
6486
- bytes[8] = bytes[8] & 0x3f | 0x80;
6487
-
6488
- if (buf) {
6489
- offset = offset || 0;
6490
-
6491
- for (var i = 0; i < 16; ++i) {
6492
- buf[offset + i] = bytes[i];
6493
- }
6494
-
6495
- return buf;
6496
- }
6497
-
6498
- return stringify(bytes);
6499
- } // Function#name is not settable on some platforms (#270)
6500
-
6501
-
6502
- try {
6503
- generateUUID.name = name; // eslint-disable-next-line no-empty
6504
- } catch (err) {} // For CommonJS default export support
6505
-
6506
-
6507
- generateUUID.DNS = DNS;
6508
- generateUUID.URL = URL;
6509
- return generateUUID;
6510
- }
6511
-
6512
- /*
6513
- * Browser-compatible JavaScript MD5
6514
- *
6515
- * Modification of JavaScript MD5
6516
- * https://github.com/blueimp/JavaScript-MD5
6517
- *
6518
- * Copyright 2011, Sebastian Tschan
6519
- * https://blueimp.net
6520
- *
6521
- * Licensed under the MIT license:
6522
- * https://opensource.org/licenses/MIT
6523
- *
6524
- * Based on
6525
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
6526
- * Digest Algorithm, as defined in RFC 1321.
6527
- * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
6528
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6529
- * Distributed under the BSD License
6530
- * See http://pajhome.org.uk/crypt/md5 for more info.
6531
- */
6532
- function md5(bytes) {
6533
- if (typeof bytes === 'string') {
6534
- var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
6535
-
6536
- bytes = new Uint8Array(msg.length);
6537
-
6538
- for (var i = 0; i < msg.length; ++i) {
6539
- bytes[i] = msg.charCodeAt(i);
6540
- }
6541
- }
6542
-
6543
- return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
6544
- }
6545
- /*
6546
- * Convert an array of little-endian words to an array of bytes
6547
- */
6548
-
6549
-
6550
- function md5ToHexEncodedArray(input) {
6551
- var output = [];
6552
- var length32 = input.length * 32;
6553
- var hexTab = '0123456789abcdef';
6554
-
6555
- for (var i = 0; i < length32; i += 8) {
6556
- var x = input[i >> 5] >>> i % 32 & 0xff;
6557
- var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
6558
- output.push(hex);
6559
- }
6560
-
6561
- return output;
6562
- }
6563
- /**
6564
- * Calculate output length with padding and bit length
6565
- */
6566
-
6567
-
6568
- function getOutputLength(inputLength8) {
6569
- return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
6570
- }
6571
- /*
6572
- * Calculate the MD5 of an array of little-endian words, and a bit length.
6573
- */
6574
-
6575
-
6576
- function wordsToMd5(x, len) {
6577
- /* append padding */
6578
- x[len >> 5] |= 0x80 << len % 32;
6579
- x[getOutputLength(len) - 1] = len;
6580
- var a = 1732584193;
6581
- var b = -271733879;
6582
- var c = -1732584194;
6583
- var d = 271733878;
6584
-
6585
- for (var i = 0; i < x.length; i += 16) {
6586
- var olda = a;
6587
- var oldb = b;
6588
- var oldc = c;
6589
- var oldd = d;
6590
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
6591
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
6592
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
6593
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
6594
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
6595
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
6596
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
6597
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
6598
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
6599
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
6600
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
6601
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
6602
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
6603
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
6604
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
6605
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
6606
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
6607
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
6608
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
6609
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
6610
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
6611
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
6612
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
6613
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
6614
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
6615
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
6616
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
6617
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
6618
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
6619
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
6620
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
6621
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
6622
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
6623
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
6624
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
6625
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
6626
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
6627
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
6628
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
6629
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
6630
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
6631
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
6632
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
6633
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
6634
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
6635
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
6636
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
6637
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
6638
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
6639
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
6640
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
6641
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
6642
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
6643
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
6644
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
6645
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
6646
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
6647
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
6648
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
6649
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
6650
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
6651
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
6652
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
6653
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
6654
- a = safeAdd(a, olda);
6655
- b = safeAdd(b, oldb);
6656
- c = safeAdd(c, oldc);
6657
- d = safeAdd(d, oldd);
6658
- }
6659
-
6660
- return [a, b, c, d];
6661
- }
6662
- /*
6663
- * Convert an array bytes to an array of little-endian words
6664
- * Characters >255 have their high-byte silently ignored.
6665
- */
6666
-
6667
-
6668
- function bytesToWords(input) {
6669
- if (input.length === 0) {
6670
- return [];
6671
- }
6672
-
6673
- var length8 = input.length * 8;
6674
- var output = new Uint32Array(getOutputLength(length8));
6675
-
6676
- for (var i = 0; i < length8; i += 8) {
6677
- output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
6678
- }
6679
-
6680
- return output;
6681
- }
6682
- /*
6683
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
6684
- * to work around bugs in some JS interpreters.
6685
- */
6686
-
6687
-
6688
- function safeAdd(x, y) {
6689
- var lsw = (x & 0xffff) + (y & 0xffff);
6690
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
6691
- return msw << 16 | lsw & 0xffff;
6692
- }
6693
- /*
6694
- * Bitwise rotate a 32-bit number to the left.
6695
- */
6696
-
6697
-
6698
- function bitRotateLeft(num, cnt) {
6699
- return num << cnt | num >>> 32 - cnt;
6700
- }
6701
- /*
6702
- * These functions implement the four basic operations the algorithm uses.
6703
- */
6704
-
6705
-
6706
- function md5cmn(q, a, b, x, s, t) {
6707
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
6708
- }
6709
-
6710
- function md5ff(a, b, c, d, x, s, t) {
6711
- return md5cmn(b & c | ~b & d, a, b, x, s, t);
6712
- }
6713
-
6714
- function md5gg(a, b, c, d, x, s, t) {
6715
- return md5cmn(b & d | c & ~d, a, b, x, s, t);
6716
- }
6717
-
6718
- function md5hh(a, b, c, d, x, s, t) {
6719
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
6720
- }
6721
-
6722
- function md5ii(a, b, c, d, x, s, t) {
6723
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
6724
- }
6725
-
6726
- var v3 = v35('v3', 0x30, md5);
6727
- var v3$1 = v3;
6728
-
6729
- function v4(options, buf, offset) {
6730
- options = options || {};
6731
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
6732
-
6733
- rnds[6] = rnds[6] & 0x0f | 0x40;
6734
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
6735
-
6736
- if (buf) {
6737
- offset = offset || 0;
6738
-
6739
- for (var i = 0; i < 16; ++i) {
6740
- buf[offset + i] = rnds[i];
6741
- }
6742
-
6743
- return buf;
6744
- }
6745
-
6746
- return stringify(rnds);
6747
- }
6748
-
6749
- // Adapted from Chris Veness' SHA1 code at
6750
- // http://www.movable-type.co.uk/scripts/sha1.html
6751
- function f(s, x, y, z) {
6752
- switch (s) {
6753
- case 0:
6754
- return x & y ^ ~x & z;
6755
-
6756
- case 1:
6757
- return x ^ y ^ z;
6758
-
6759
- case 2:
6760
- return x & y ^ x & z ^ y & z;
6761
-
6762
- case 3:
6763
- return x ^ y ^ z;
6764
- }
6765
- }
6766
-
6767
- function ROTL(x, n) {
6768
- return x << n | x >>> 32 - n;
6769
- }
6770
-
6771
- function sha1(bytes) {
6772
- var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
6773
- var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
6774
-
6775
- if (typeof bytes === 'string') {
6776
- var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
6777
-
6778
- bytes = [];
6779
-
6780
- for (var i = 0; i < msg.length; ++i) {
6781
- bytes.push(msg.charCodeAt(i));
6782
- }
6783
- } else if (!Array.isArray(bytes)) {
6784
- // Convert Array-like to Array
6785
- bytes = Array.prototype.slice.call(bytes);
6786
- }
6787
-
6788
- bytes.push(0x80);
6789
- var l = bytes.length / 4 + 2;
6790
- var N = Math.ceil(l / 16);
6791
- var M = new Array(N);
6792
-
6793
- for (var _i = 0; _i < N; ++_i) {
6794
- var arr = new Uint32Array(16);
6795
-
6796
- for (var j = 0; j < 16; ++j) {
6797
- arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
6798
- }
6799
-
6800
- M[_i] = arr;
6801
- }
6802
-
6803
- M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
6804
- M[N - 1][14] = Math.floor(M[N - 1][14]);
6805
- M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
6806
-
6807
- for (var _i2 = 0; _i2 < N; ++_i2) {
6808
- var W = new Uint32Array(80);
6809
-
6810
- for (var t = 0; t < 16; ++t) {
6811
- W[t] = M[_i2][t];
6812
- }
6813
-
6814
- for (var _t = 16; _t < 80; ++_t) {
6815
- W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
6816
- }
6817
-
6818
- var a = H[0];
6819
- var b = H[1];
6820
- var c = H[2];
6821
- var d = H[3];
6822
- var e = H[4];
6823
-
6824
- for (var _t2 = 0; _t2 < 80; ++_t2) {
6825
- var s = Math.floor(_t2 / 20);
6826
- var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
6827
- e = d;
6828
- d = c;
6829
- c = ROTL(b, 30) >>> 0;
6830
- b = a;
6831
- a = T;
6832
- }
6833
-
6834
- H[0] = H[0] + a >>> 0;
6835
- H[1] = H[1] + b >>> 0;
6836
- H[2] = H[2] + c >>> 0;
6837
- H[3] = H[3] + d >>> 0;
6838
- H[4] = H[4] + e >>> 0;
6839
- }
6840
-
6841
- return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
6842
- }
6843
-
6844
- var v5 = v35('v5', 0x50, sha1);
6845
- var v5$1 = v5;
6846
-
6847
- var nil = '00000000-0000-0000-0000-000000000000';
6848
-
6849
- function version(uuid) {
6850
- if (!validate(uuid)) {
6851
- throw TypeError('Invalid UUID');
6852
- }
6853
-
6854
- return parseInt(uuid.substr(14, 1), 16);
6855
- }
6856
-
6857
- var esmBrowser = /*#__PURE__*/Object.freeze({
6858
- __proto__: null,
6859
- v1: v1,
6860
- v3: v3$1,
6861
- v4: v4,
6862
- v5: v5$1,
6863
- NIL: nil,
6864
- version: version,
6865
- validate: validate,
6866
- stringify: stringify,
6867
- parse: parse$1
6868
- });
6869
-
6870
- var require$$0 = /*@__PURE__*/getAugmentedNamespace(esmBrowser);
6871
-
6872
6257
  var rtcStats_1 = void 0;
6873
- var uuid_1 = require$$0;
6874
6258
  /**
6875
6259
  * Copies values of any nested depth.
6876
6260
  *
@@ -6898,9 +6282,10 @@ var deepEqual = function (value1, value2) {
6898
6282
  if (Object.keys(value1).length !== Object.keys(value2).length) {
6899
6283
  return false;
6900
6284
  }
6901
- // Deep equal check each property in the opject.
6902
- for (var prop in value1) {
6903
- if (value2.hasOwnProperty(prop)) {
6285
+ // Deep equal check each property in the object, returns true if we found no
6286
+ // differing properties.
6287
+ return Object.keys(value1).reduce(function (val, prop) {
6288
+ if (value2[prop]) {
6904
6289
  if (!deepEqual(value1[prop], value2[prop])) {
6905
6290
  return false;
6906
6291
  }
@@ -6908,17 +6293,16 @@ var deepEqual = function (value1, value2) {
6908
6293
  else {
6909
6294
  return false;
6910
6295
  }
6911
- }
6912
- // Return true if we found no differing properties.
6913
- return true;
6296
+ return val;
6297
+ }, true);
6914
6298
  }
6915
6299
  // Return false if no other conditions are met.
6916
6300
  return false;
6917
6301
  };
6918
6302
  /**
6919
- * Translates a RTCStatsReport into an object.
6303
+ * Translates a Map into an object.
6920
6304
  *
6921
- * @param report - The report.
6305
+ * @param report - The report in Map form.
6922
6306
  * @returns - A deduped object.
6923
6307
  */
6924
6308
  var map2obj = function (report) {
@@ -6938,6 +6322,7 @@ var persistedKeys = ['type', 'id', 'timestamp'];
6938
6322
  * @param report - The report line being checked.
6939
6323
  * @returns True if the report item contains non-persisted keys, false otherwise.
6940
6324
  */
6325
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6941
6326
  var hasNonMetadata = function (report) {
6942
6327
  return !!Object.keys(report).filter(function (key) { return !persistedKeys.includes(key); }).length;
6943
6328
  };
@@ -6994,7 +6379,7 @@ var deltaCompression = function (oldStats, newStats) {
6994
6379
  var formatStatsReport = function (report) {
6995
6380
  return Object.keys(report)
6996
6381
  .filter(function (name) { return name !== 'timestamp'; })
6997
- .map(function (name) { return report[name]; });
6382
+ .map(function (name) { return JSON.stringify(report[name]); });
6998
6383
  };
6999
6384
  /**
7000
6385
  * Parametrize a single string event to contain type and an (empty) id.
@@ -7002,18 +6387,16 @@ var formatStatsReport = function (report) {
7002
6387
  * @param value - The value to parametrize.
7003
6388
  * @returns An event object.
7004
6389
  */
7005
- var makeEvent = function (value) { return ([{ value: value, type: 'string', id: '' }]); };
6390
+ var makeEvent = function (value) { return [JSON.stringify({ value: value, type: 'string', id: '' })]; };
7006
6391
  /**
7007
6392
  * Attach a Peer Connection to periodically get updated on events and stats.
7008
6393
  *
7009
6394
  * @param pc - Peer Connection in which we attach.
7010
6395
  * @param logger - Logging function to log events and stats.
7011
6396
  * @param intervalTime - Time between each `getStats` check.
7012
- * @param id - Optional id string used for logging.
7013
6397
  * @param statsPreProcessor - Optional function that modifies stats.
7014
6398
  */
7015
- var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7016
- if (id === void 0) { id = (0, uuid_1.v4)(); }
6399
+ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7017
6400
  if (statsPreProcessor === void 0) { statsPreProcessor = function () { return Promise.resolve(); }; }
7018
6401
  var prev = {};
7019
6402
  /**
@@ -7021,9 +6404,10 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7021
6404
  *
7022
6405
  * @param name - Name of the event to log.
7023
6406
  * @param payload - Log data pertaining to the event.
6407
+ * @param timestamp - Time the event happened in milliseconds.
7024
6408
  */
7025
6409
  var trace = function (name, payload, timestamp) {
7026
- logger({ id: id, timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
6410
+ logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
7027
6411
  };
7028
6412
  pc.addEventListener('icecandidate', function (e) {
7029
6413
  if (e.candidate) {
@@ -7035,7 +6419,9 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7035
6419
  trace('onicecandidateerror', makeEvent("".concat(errorCode, ": ").concat(errorText)));
7036
6420
  });
7037
6421
  pc.addEventListener('track', function (e) {
7038
- trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams.map(function (stream) { return "stream:".concat(stream.id); }).join(' '))));
6422
+ trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams
6423
+ .map(function (stream) { return "stream:".concat(stream.id); })
6424
+ .join(' '))));
7039
6425
  });
7040
6426
  pc.addEventListener('signalingstatechange', function () {
7041
6427
  trace('onsignalingstatechange', makeEvent(pc.signalingState));
@@ -7061,8 +6447,11 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7061
6447
  return;
7062
6448
  }
7063
6449
  pc.getStats(null).then(function (res) {
7064
- var now = map2obj(res);
7065
- statsPreProcessor(now).then(function () {
6450
+ // Convert from stats report to js Map in order to have values set in `statsPreProcessor`
6451
+ var statsMap = new Map();
6452
+ res.forEach(function (stats, key) { return statsMap.set(key, stats); });
6453
+ statsPreProcessor(statsMap).then(function () {
6454
+ var now = map2obj(statsMap);
7066
6455
  var base = deepCopy$1(now); // our new prev
7067
6456
  var compressed = deltaCompression(prev, now);
7068
6457
  trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
@@ -9428,12 +8817,17 @@ class SendOnlyTransceiver extends Transceiver {
9428
8817
  }
9429
8818
  updateSendParameters(requestedIdEncodingParamsMap) {
9430
8819
  return __awaiter(this, void 0, void 0, function* () {
8820
+ if (!this.publishedTrack)
8821
+ return;
8822
+ this.setTrackRequested(requestedIdEncodingParamsMap.size > 0);
9431
8823
  const sendParameters = this.sender.getParameters();
9432
8824
  sendParameters.encodings.forEach((encoding, index) => {
8825
+ var _a, _b;
9433
8826
  const encodingParams = requestedIdEncodingParamsMap.get(index);
9434
8827
  encoding.active = !!encodingParams;
9435
8828
  if (encodingParams) {
9436
- const { maxPayloadBitsPerSecond, scaleDownRatio } = encodingParams;
8829
+ const { maxPayloadBitsPerSecond, maxFs, maxWidth, maxHeight } = encodingParams;
8830
+ const scaleDownRatio = getScaleDownRatio((_a = this.publishedTrack) === null || _a === void 0 ? void 0 : _a.getSettings().width, (_b = this.publishedTrack) === null || _b === void 0 ? void 0 : _b.getSettings().height, maxFs, maxWidth, maxHeight);
9437
8831
  if (maxPayloadBitsPerSecond !== undefined && maxPayloadBitsPerSecond >= 0) {
9438
8832
  encoding.maxBitrate = maxPayloadBitsPerSecond;
9439
8833
  }
@@ -13278,6 +12672,7 @@ class MultistreamConnection extends EventEmitter {
13278
12672
  this.overuseUpdateCallback = () => { };
13279
12673
  this.midPredictor = new MidPredictor();
13280
12674
  this.offerAnswerQueue = new AsyncQueue();
12675
+ this.requestedIdEncodingParamsMap = new Map();
13281
12676
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
13282
12677
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
13283
12678
  this.initializePeerConnection();
@@ -13401,7 +12796,7 @@ class MultistreamConnection extends EventEmitter {
13401
12796
  logger.warn('Ignoring non-receiver-selected requests');
13402
12797
  }
13403
12798
  rsRequests.forEach(({ ids, policySpecificInfo, codecInfos, maxPayloadBitsPerSecond }) => {
13404
- var _a, _b, _c, _d;
12799
+ var _a, _b, _c;
13405
12800
  if (ids.length > 1) {
13406
12801
  throw new Error(`More than a single ID being unexpected/invalid ${ids}`);
13407
12802
  }
@@ -13420,10 +12815,9 @@ class MultistreamConnection extends EventEmitter {
13420
12815
  if (encodingIndex !== -1) {
13421
12816
  const encodingParams = { maxPayloadBitsPerSecond };
13422
12817
  if (mediaFamily === MediaFamily.Video) {
13423
- const trackSettings = (_a = sendTransceiver.publishedTrack) === null || _a === void 0 ? void 0 : _a.getSettings();
13424
- if (trackSettings) {
13425
- encodingParams.scaleDownRatio = getScaleDownRatio(trackSettings.width, trackSettings.height, (_b = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _b === void 0 ? void 0 : _b.maxFs, (_c = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _c === void 0 ? void 0 : _c.maxWidth, (_d = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _d === void 0 ? void 0 : _d.maxHeight);
13426
- }
12818
+ encodingParams.maxFs = (_a = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _a === void 0 ? void 0 : _a.maxFs;
12819
+ encodingParams.maxWidth = (_b = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _b === void 0 ? void 0 : _b.maxWidth;
12820
+ encodingParams.maxHeight = (_c = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _c === void 0 ? void 0 : _c.maxHeight;
13427
12821
  }
13428
12822
  requestedIdEncodingParamsMap.set(encodingIndex, encodingParams);
13429
12823
  }
@@ -13435,8 +12829,8 @@ class MultistreamConnection extends EventEmitter {
13435
12829
  logger.warn(`${mediaType}: Unable to find matching stream ID for requested ID: ${JSON.stringify(id)}`);
13436
12830
  }
13437
12831
  });
13438
- sendTransceiver.setTrackRequested(requestedIdEncodingParamsMap.size > 0);
13439
12832
  sendTransceiver.updateSendParameters(requestedIdEncodingParamsMap);
12833
+ this.requestedIdEncodingParamsMap = requestedIdEncodingParamsMap;
13440
12834
  }
13441
12835
  createDataChannel() {
13442
12836
  const dataChannel = this.pc.createDataChannel('datachannel', {});
@@ -13577,8 +12971,9 @@ class MultistreamConnection extends EventEmitter {
13577
12971
  });
13578
12972
  }
13579
12973
  addTrackListeners(mediaType, track) {
12974
+ const sendTransceiver = this.getSendTransceiverOrThrow(mediaType);
13580
12975
  const onTrackResolutionChange = () => {
13581
- this.sendMediaRequestStatus(mediaType);
12976
+ sendTransceiver.updateSendParameters(this.requestedIdEncodingParamsMap);
13582
12977
  };
13583
12978
  track.on(LocalTrack.Events.TrackConstraintsChange, onTrackResolutionChange);
13584
12979
  const onTrackMute = () => {
@@ -13595,16 +12990,18 @@ class MultistreamConnection extends EventEmitter {
13595
12990
  if (!track.muted) {
13596
12991
  this.sendSourceAdvertisement(mediaType);
13597
12992
  this.sendMediaRequestStatus(mediaType);
12993
+ if (mediaType === MediaType.VideoMain) {
12994
+ sendTransceiver.updateSendParameters(this.requestedIdEncodingParamsMap);
12995
+ }
13598
12996
  }
13599
12997
  };
13600
12998
  track.on(LocalTrack.Events.PublishedStateUpdate, onTrackPublish);
13601
12999
  }
13602
13000
  getVideoStreamStates(mediaType) {
13603
- var _a, _b, _c;
13001
+ var _a, _b;
13604
13002
  const sendTransceiver = this.getSendTransceiverOrThrow(mediaType);
13605
- const activeSimulcastLayerNumber = ((_a = sendTransceiver.publishedTrack) === null || _a === void 0 ? void 0 : _a.getNumActiveSimulcastLayers()) || 0;
13606
- const published = (_b = sendTransceiver.publishedTrack) === null || _b === void 0 ? void 0 : _b.published;
13607
- const muted = ((_c = sendTransceiver.publishedTrack) === null || _c === void 0 ? void 0 : _c.muted) === true;
13003
+ const published = (_a = sendTransceiver.publishedTrack) === null || _a === void 0 ? void 0 : _a.published;
13004
+ const muted = ((_b = sendTransceiver.publishedTrack) === null || _b === void 0 ? void 0 : _b.muted) === true;
13608
13005
  return sendTransceiver.senderIds.map((id) => {
13609
13006
  let state;
13610
13007
  if (!published) {
@@ -13613,9 +13010,6 @@ class MultistreamConnection extends EventEmitter {
13613
13010
  else if (muted) {
13614
13011
  state = 'avatar';
13615
13012
  }
13616
- else if (activeSimulcastLayerNumber < sendTransceiver.getEncodingIndexForStreamId(id)) {
13617
- state = 'no source';
13618
- }
13619
13013
  else {
13620
13014
  state = 'live';
13621
13015
  }
@@ -13990,7 +13384,7 @@ class MultistreamConnection extends EventEmitter {
13990
13384
  });
13991
13385
  }
13992
13386
  attachMetricsObserver() {
13993
- rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000);
13387
+ rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats));
13994
13388
  }
13995
13389
  setMetricsCallback(callback) {
13996
13390
  this.metricsCallback = callback;