twilio-video 2.24.3 → 2.26.0

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/README.md +1 -2
  3. package/dist/twilio-video.js +1651 -1174
  4. package/dist/twilio-video.min.js +21 -21
  5. package/es5/createlocaltrack.js +10 -2
  6. package/es5/createlocaltrack.js.map +1 -1
  7. package/es5/createlocaltracks.js +20 -8
  8. package/es5/createlocaltracks.js.map +1 -1
  9. package/es5/media/track/localaudiotrack.js +140 -7
  10. package/es5/media/track/localaudiotrack.js.map +1 -1
  11. package/es5/media/track/localmediatrack.js +32 -6
  12. package/es5/media/track/localmediatrack.js.map +1 -1
  13. package/es5/media/track/localvideotrack.js +33 -12
  14. package/es5/media/track/localvideotrack.js.map +1 -1
  15. package/es5/media/track/mediatrack.js +3 -3
  16. package/es5/media/track/mediatrack.js.map +1 -1
  17. package/es5/media/track/remotemediatrack.js +2 -2
  18. package/es5/media/track/remotemediatrack.js.map +1 -1
  19. package/es5/media/track/sender.js +39 -1
  20. package/es5/media/track/sender.js.map +1 -1
  21. package/es5/room.js +50 -1
  22. package/es5/room.js.map +1 -1
  23. package/es5/transceiver.js +3 -3
  24. package/es5/transceiver.js.map +1 -1
  25. package/es5/util/browserdetection.js +16 -15
  26. package/es5/util/browserdetection.js.map +1 -1
  27. package/es5/webrtc/getstats.js +75 -58
  28. package/es5/webrtc/getstats.js.map +1 -1
  29. package/es5/webrtc/getusermedia.js +1 -1
  30. package/es5/webrtc/getusermedia.js.map +1 -1
  31. package/es5/webrtc/index.js.map +1 -1
  32. package/es5/webrtc/rtcpeerconnection/chrome.js +339 -286
  33. package/es5/webrtc/rtcpeerconnection/chrome.js.map +1 -1
  34. package/es5/webrtc/rtcpeerconnection/firefox.js +225 -179
  35. package/es5/webrtc/rtcpeerconnection/firefox.js.map +1 -1
  36. package/es5/webrtc/rtcpeerconnection/index.js.map +1 -1
  37. package/es5/webrtc/rtcpeerconnection/safari.js +276 -236
  38. package/es5/webrtc/rtcpeerconnection/safari.js.map +1 -1
  39. package/es5/webrtc/rtcrtpsender.js +12 -9
  40. package/es5/webrtc/rtcrtpsender.js.map +1 -1
  41. package/es5/webrtc/rtcsessiondescription/chrome.js +29 -22
  42. package/es5/webrtc/rtcsessiondescription/chrome.js.map +1 -1
  43. package/es5/webrtc/rtcsessiondescription/index.js.map +1 -1
  44. package/es5/webrtc/util/index.js +32 -15
  45. package/es5/webrtc/util/index.js.map +1 -1
  46. package/es5/webrtc/util/latch.js +83 -82
  47. package/es5/webrtc/util/latch.js.map +1 -1
  48. package/es5/webrtc/util/sdp.js +12 -19
  49. package/es5/webrtc/util/sdp.js.map +1 -1
  50. package/lib/createlocaltrack.js +10 -2
  51. package/lib/createlocaltracks.ts +32 -11
  52. package/lib/media/track/localaudiotrack.js +142 -8
  53. package/lib/media/track/localmediatrack.js +31 -5
  54. package/lib/media/track/localvideotrack.js +35 -13
  55. package/lib/media/track/mediatrack.js +2 -2
  56. package/lib/media/track/remotemediatrack.js +2 -2
  57. package/lib/media/track/sender.js +42 -1
  58. package/lib/room.js +41 -1
  59. package/lib/transceiver.js +3 -3
  60. package/lib/util/browserdetection.js +16 -15
  61. package/lib/webrtc/getstats.js +155 -171
  62. package/lib/webrtc/getusermedia.js +1 -2
  63. package/lib/webrtc/index.js +1 -1
  64. package/lib/webrtc/rtcpeerconnection/chrome.js +284 -316
  65. package/lib/webrtc/rtcpeerconnection/firefox.js +173 -197
  66. package/lib/webrtc/rtcpeerconnection/index.js +1 -1
  67. package/lib/webrtc/rtcpeerconnection/safari.js +228 -256
  68. package/lib/webrtc/rtcrtpsender.js +10 -8
  69. package/lib/webrtc/rtcsessiondescription/chrome.js +24 -24
  70. package/lib/webrtc/rtcsessiondescription/index.js +1 -1
  71. package/lib/webrtc/util/index.js +26 -33
  72. package/lib/webrtc/util/latch.js +78 -83
  73. package/lib/webrtc/util/sdp.js +32 -41
  74. package/package.json +3 -3
  75. package/tsdef/LocalAudioTrack.d.ts +3 -0
  76. package/tsdef/LocalVideoTrack.d.ts +3 -0
  77. package/tsdef/Room.d.ts +1 -0
  78. package/tsdef/index.d.ts +1 -0
  79. package/tsdef/types.d.ts +2 -0
  80. package/es5/webrtc/util/eventtarget.js +0 -34
  81. package/es5/webrtc/util/eventtarget.js.map +0 -1
  82. package/lib/webrtc/util/eventtarget.js +0 -39
@@ -1,4 +1,4 @@
1
- /*! twilio-video.js 2.24.3
1
+ /*! twilio-video.js 2.26.0
2
2
 
3
3
  The following license applies to all parts of this software except as
4
4
  documented below.
@@ -83,7 +83,7 @@ function createCancelableRoomPromise(getLocalTracks, createLocalParticipant, cre
83
83
  }
84
84
  module.exports = createCancelableRoomPromise;
85
85
 
86
- },{"./util/cancelablepromise":123}],2:[function(require,module,exports){
86
+ },{"./util/cancelablepromise":124}],2:[function(require,module,exports){
87
87
  'use strict';
88
88
  var MediaStreamTrack = require('./webrtc').MediaStreamTrack;
89
89
  var _a = require('./webrtc/util'), guessBrowser = _a.guessBrowser, guessBrowserVersion = _a.guessBrowserVersion;
@@ -999,7 +999,7 @@ function normalizeCodecSettings(nameOrSettings) {
999
999
  }
1000
1000
  module.exports = connect;
1001
1001
 
1002
- },{"./cancelableroompromise":1,"./encodingparameters":9,"./localparticipant":12,"./media/track/es5":14,"./networkqualityconfiguration":43,"./room":56,"./signaling/v2":70,"./util":131,"./util/cancelablepromise":123,"./util/constants":124,"./util/eventobserver":129,"./util/insightspublisher":132,"./util/insightspublisher/null":133,"./util/log":135,"./util/validate":149,"./webrtc":157,"./webrtc/util":170}],3:[function(require,module,exports){
1002
+ },{"./cancelableroompromise":1,"./encodingparameters":9,"./localparticipant":13,"./media/track/es5":15,"./networkqualityconfiguration":44,"./room":57,"./signaling/v2":71,"./util":132,"./util/cancelablepromise":124,"./util/constants":125,"./util/eventobserver":130,"./util/insightspublisher":133,"./util/insightspublisher/null":134,"./util/log":136,"./util/validate":150,"./webrtc":158,"./webrtc/util":170}],3:[function(require,module,exports){
1003
1003
  'use strict';
1004
1004
  var _a = require('./util/constants'), DEFAULT_LOG_LEVEL = _a.DEFAULT_LOG_LEVEL, DEFAULT_LOGGER_NAME = _a.DEFAULT_LOGGER_NAME;
1005
1005
  /**
@@ -1116,8 +1116,16 @@ var NoiseCancellationVendor = {
1116
1116
  * @property {boolean} [workaroundWebKitBug180748=false] - setting this
1117
1117
  * attempts to workaround WebKit Bug 180748, where, in Safari, getUserMedia may return a silent audio
1118
1118
  * MediaStreamTrack.
1119
- * @property {NoiseCancellationOptions} [noiseCancellationOptions] - This property enables using 3rd party plugins
1120
- * for noise cancellation. This is a beta feature.
1119
+ * @property {DefaultDeviceCaptureMode} [defaultDeviceCaptureMode="auto"] - This optional property only applies if the
1120
+ * {@link LocalAudioTrack} is capturing from the default audio input device connected to a desktop or laptop. When the
1121
+ * property is set to "auto", the LocalAudioTrack restarts whenever the default audio input device changes, in order to
1122
+ * capture audio from the new default audio input device. For example, when a bluetooth audio headset is connected to a
1123
+ * Macbook, the LocalAudioTrack will start capturing audio from the headset microphone. When the headset is disconnected,
1124
+ * the LocalAudioTrack will start capturing audio from the Macbook microphone. When the property is set to "manual", the
1125
+ * LocalAudioTrack continues to capture from the same audio input device even after the default audio input device changes.
1126
+ * When the property is not specified, it defaults to "auto".
1127
+ * @property {NoiseCancellationOptions} [noiseCancellationOptions] - This optional property enables using 3rd party plugins
1128
+ * for noise cancellation.
1121
1129
  */
1122
1130
  /**
1123
1131
  * Create {@link LocalTrack} options. Apart from the properties listed here, you can
@@ -1140,7 +1148,7 @@ module.exports = {
1140
1148
  video: createLocalVideoTrack
1141
1149
  };
1142
1150
 
1143
- },{"./util/constants":124}],4:[function(require,module,exports){
1151
+ },{"./util/constants":125}],4:[function(require,module,exports){
1144
1152
  /* eslint-disable @typescript-eslint/no-explicit-any */
1145
1153
  'use strict';
1146
1154
  var __assign = (this && this.__assign) || function () {
@@ -1218,7 +1226,7 @@ var buildLogLevels = require('./util').buildLogLevels;
1218
1226
  var _a = require('./webrtc'), getUserMedia = _a.getUserMedia, MediaStreamTrack = _a.MediaStreamTrack;
1219
1227
  var _b = require('./media/track/es5'), LocalAudioTrack = _b.LocalAudioTrack, LocalDataTrack = _b.LocalDataTrack, LocalVideoTrack = _b.LocalVideoTrack;
1220
1228
  var Log = require('./util/log');
1221
- var _c = require('./util/constants'), DEFAULT_LOG_LEVEL = _c.DEFAULT_LOG_LEVEL, DEFAULT_LOGGER_NAME = _c.DEFAULT_LOGGER_NAME;
1229
+ var _c = require('./util/constants'), DEFAULT_LOG_LEVEL = _c.DEFAULT_LOG_LEVEL, DEFAULT_LOGGER_NAME = _c.DEFAULT_LOGGER_NAME, INVALID_VALUE = _c.typeErrors.INVALID_VALUE;
1222
1230
  var workaround180748 = require('./webaudio/workaround180748');
1223
1231
  // This is used to make out which createLocalTracks() call a particular Log
1224
1232
  // statement belongs to. Each call to createLocalTracks() increments this
@@ -1317,19 +1325,31 @@ function createLocalTracks(options) {
1317
1325
  extraLocalTrackOptions = {
1318
1326
  audio: typeof fullOptions.audio === 'object' && fullOptions.audio.name
1319
1327
  ? { name: fullOptions.audio.name }
1320
- : {},
1328
+ : { defaultDeviceCaptureMode: 'auto' },
1321
1329
  video: typeof fullOptions.video === 'object' && fullOptions.video.name
1322
1330
  ? { name: fullOptions.video.name }
1323
1331
  : {}
1324
1332
  };
1325
1333
  extraLocalTrackOptions.audio.isCreatedByCreateLocalTracks = true;
1326
1334
  extraLocalTrackOptions.video.isCreatedByCreateLocalTracks = true;
1327
- if (typeof fullOptions.audio === 'object' && typeof fullOptions.audio.workaroundWebKitBug1208516 === 'boolean') {
1328
- extraLocalTrackOptions.audio.workaroundWebKitBug1208516 = fullOptions.audio.workaroundWebKitBug1208516;
1329
- }
1330
- if (typeof fullOptions.audio === 'object' && 'noiseCancellationOptions' in fullOptions.audio) {
1331
- noiseCancellationOptions = fullOptions.audio.noiseCancellationOptions;
1332
- delete fullOptions.audio.noiseCancellationOptions;
1335
+ if (typeof fullOptions.audio === 'object') {
1336
+ if (typeof fullOptions.audio.workaroundWebKitBug1208516 === 'boolean') {
1337
+ extraLocalTrackOptions.audio.workaroundWebKitBug1208516 = fullOptions.audio.workaroundWebKitBug1208516;
1338
+ }
1339
+ if ('noiseCancellationOptions' in fullOptions.audio) {
1340
+ noiseCancellationOptions = fullOptions.audio.noiseCancellationOptions;
1341
+ delete fullOptions.audio.noiseCancellationOptions;
1342
+ }
1343
+ if (!('defaultDeviceCaptureMode' in fullOptions.audio)) {
1344
+ extraLocalTrackOptions.audio.defaultDeviceCaptureMode = 'auto';
1345
+ }
1346
+ else if (['auto', 'manual'].every(function (mode) { return mode !== fullOptions.audio.defaultDeviceCaptureMode; })) {
1347
+ // eslint-disable-next-line new-cap
1348
+ throw INVALID_VALUE('CreateLocalAudioTrackOptions.defaultDeviceCaptureMode', ['auto', 'manual']);
1349
+ }
1350
+ else {
1351
+ extraLocalTrackOptions.audio.defaultDeviceCaptureMode = fullOptions.audio.defaultDeviceCaptureMode;
1352
+ }
1333
1353
  }
1334
1354
  if (typeof fullOptions.video === 'object' && typeof fullOptions.video.workaroundWebKitBug1208516 === 'boolean') {
1335
1355
  extraLocalTrackOptions.video.workaroundWebKitBug1208516 = fullOptions.video.workaroundWebKitBug1208516;
@@ -1386,7 +1406,7 @@ function createLocalTracks(options) {
1386
1406
  }
1387
1407
  exports.createLocalTracks = createLocalTracks;
1388
1408
 
1389
- },{"./media/track/es5":14,"./media/track/noisecancellationimpl":28,"./util":131,"./util/constants":124,"./util/log":135,"./webaudio/workaround180748":154,"./webrtc":157}],5:[function(require,module,exports){
1409
+ },{"./media/track/es5":15,"./media/track/noisecancellationimpl":29,"./util":132,"./util/constants":125,"./util/log":136,"./webaudio/workaround180748":155,"./webrtc":158}],5:[function(require,module,exports){
1390
1410
  'use strict';
1391
1411
  var __extends = (this && this.__extends) || (function () {
1392
1412
  var extendStatics = function (d, b) {
@@ -1585,7 +1605,7 @@ var DataTrackSender = /** @class */ (function (_super) {
1585
1605
  }(DataTrackTransceiver));
1586
1606
  module.exports = DataTrackSender;
1587
1607
 
1588
- },{"../util":131,"./transceiver":7}],7:[function(require,module,exports){
1608
+ },{"../util":132,"./transceiver":7}],7:[function(require,module,exports){
1589
1609
  'use strict';
1590
1610
  var __extends = (this && this.__extends) || (function () {
1591
1611
  var extendStatics = function (d, b) {
@@ -1645,7 +1665,7 @@ var DataTrackTransceiver = /** @class */ (function (_super) {
1645
1665
  }(TrackTransceiver));
1646
1666
  module.exports = DataTrackTransceiver;
1647
1667
 
1648
- },{"../transceiver":118}],8:[function(require,module,exports){
1668
+ },{"../transceiver":119}],8:[function(require,module,exports){
1649
1669
  'use strict';
1650
1670
  var __extends = (this && this.__extends) || (function () {
1651
1671
  var extendStatics = function (d, b) {
@@ -1846,7 +1866,54 @@ var EventEmitter = require('events').EventEmitter;
1846
1866
  var hidePrivateAndCertainPublicPropertiesInClass = require('./util').hidePrivateAndCertainPublicPropertiesInClass;
1847
1867
  module.exports = hidePrivateAndCertainPublicPropertiesInClass(EventEmitter, ['domain']);
1848
1868
 
1849
- },{"./util":131,"events":173}],11:[function(require,module,exports){
1869
+ },{"./util":132,"events":173}],11:[function(require,module,exports){
1870
+ 'use strict';
1871
+ var __read = (this && this.__read) || function (o, n) {
1872
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
1873
+ if (!m) return o;
1874
+ var i = m.call(o), r, ar = [], e;
1875
+ try {
1876
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1877
+ }
1878
+ catch (error) { e = { error: error }; }
1879
+ finally {
1880
+ try {
1881
+ if (r && !r.done && (m = i["return"])) m.call(i);
1882
+ }
1883
+ finally { if (e) throw e.error; }
1884
+ }
1885
+ return ar;
1886
+ };
1887
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
1888
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1889
+ to[j] = from[i];
1890
+ return to;
1891
+ };
1892
+ var EventEmitter = require('events').EventEmitter;
1893
+ var EventTarget = /** @class */ (function () {
1894
+ function EventTarget() {
1895
+ Object.defineProperties(this, {
1896
+ _eventEmitter: {
1897
+ value: new EventEmitter()
1898
+ }
1899
+ });
1900
+ }
1901
+ EventTarget.prototype.dispatchEvent = function (event) {
1902
+ return this._eventEmitter.emit(event.type, event);
1903
+ };
1904
+ EventTarget.prototype.addEventListener = function () {
1905
+ var _a;
1906
+ return (_a = this._eventEmitter).addListener.apply(_a, __spreadArray([], __read(arguments)));
1907
+ };
1908
+ EventTarget.prototype.removeEventListener = function () {
1909
+ var _a;
1910
+ return (_a = this._eventEmitter).removeListener.apply(_a, __spreadArray([], __read(arguments)));
1911
+ };
1912
+ return EventTarget;
1913
+ }());
1914
+ module.exports = EventTarget;
1915
+
1916
+ },{"events":173}],12:[function(require,module,exports){
1850
1917
  'use strict';
1851
1918
  var __assign = (this && this.__assign) || function () {
1852
1919
  __assign = Object.assign || function(t) {
@@ -1920,7 +1987,7 @@ module.exports = {
1920
1987
  LocalDataTrack: LocalDataTrack,
1921
1988
  };
1922
1989
 
1923
- },{"../package.json":174,"./connect":2,"./createlocaltrack":3,"./createlocaltracks":4,"./media/track/es5":14,"./preflight/preflighttest":50,"./util/support":144,"./vendor/loglevel":151}],12:[function(require,module,exports){
1990
+ },{"../package.json":174,"./connect":2,"./createlocaltrack":3,"./createlocaltracks":4,"./media/track/es5":15,"./preflight/preflighttest":51,"./util/support":145,"./vendor/loglevel":152}],13:[function(require,module,exports){
1924
1991
  'use strict';
1925
1992
  var __extends = (this && this.__extends) || (function () {
1926
1993
  var extendStatics = function (d, b) {
@@ -2632,7 +2699,7 @@ function getTrackPublication(trackPublications, track) {
2632
2699
  }
2633
2700
  module.exports = LocalParticipant;
2634
2701
 
2635
- },{"./media/track/es5":14,"./media/track/localaudiotrackpublication":20,"./media/track/localdatatrackpublication":22,"./media/track/localvideotrackpublication":26,"./participant":45,"./util":131,"./util/constants":124,"./util/validate":149,"./webrtc":157}],13:[function(require,module,exports){
2702
+ },{"./media/track/es5":15,"./media/track/localaudiotrackpublication":21,"./media/track/localdatatrackpublication":23,"./media/track/localvideotrackpublication":27,"./participant":46,"./util":132,"./util/constants":125,"./util/validate":150,"./webrtc":158}],14:[function(require,module,exports){
2636
2703
  'use strict';
2637
2704
  var __extends = (this && this.__extends) || (function () {
2638
2705
  var extendStatics = function (d, b) {
@@ -2787,7 +2854,7 @@ var AudioTrack = /** @class */ (function (_super) {
2787
2854
  */
2788
2855
  module.exports = AudioTrack;
2789
2856
 
2790
- },{"./mediatrack":27}],14:[function(require,module,exports){
2857
+ },{"./mediatrack":28}],15:[function(require,module,exports){
2791
2858
  'use strict';
2792
2859
  module.exports = {
2793
2860
  LocalAudioTrack: require('./localaudiotrack'),
@@ -2795,7 +2862,7 @@ module.exports = {
2795
2862
  LocalDataTrack: require('./localdatatrack')
2796
2863
  };
2797
2864
 
2798
- },{"./localaudiotrack":15,"./localdatatrack":16,"./localvideotrack":17}],15:[function(require,module,exports){
2865
+ },{"./localaudiotrack":16,"./localdatatrack":17,"./localvideotrack":18}],16:[function(require,module,exports){
2799
2866
  // eslint-disable-next-line no-warning-comments
2800
2867
  // TODO(mroberts): Remove this when we go to the next major version. This is
2801
2868
  // only in place so that we can support ES6 classes without requiring `new`.
@@ -2810,7 +2877,7 @@ function LocalAudioTrack(mediaStreamTrack, options) {
2810
2877
  inherits(LocalAudioTrack, LocalAudioTrackClass);
2811
2878
  module.exports = LocalAudioTrack;
2812
2879
 
2813
- },{"../../../vendor/inherits":150,"../localaudiotrack":19}],16:[function(require,module,exports){
2880
+ },{"../../../vendor/inherits":151,"../localaudiotrack":20}],17:[function(require,module,exports){
2814
2881
  // eslint-disable-next-line no-warning-comments
2815
2882
  // TODO(mroberts): Remove this when we go to the next major version. This is
2816
2883
  // only in place so that we can support ES6 classes without requiring `new`.
@@ -2825,7 +2892,7 @@ function LocalDataTrack(options) {
2825
2892
  inherits(LocalDataTrack, LocalDataTrackClass);
2826
2893
  module.exports = LocalDataTrack;
2827
2894
 
2828
- },{"../../../vendor/inherits":150,"../localdatatrack":21}],17:[function(require,module,exports){
2895
+ },{"../../../vendor/inherits":151,"../localdatatrack":22}],18:[function(require,module,exports){
2829
2896
  // eslint-disable-next-line no-warning-comments
2830
2897
  // TODO(mroberts): Remove this when we go to the next major version. This is
2831
2898
  // only in place so that we can support ES6 classes without requiring `new`.
@@ -2840,7 +2907,7 @@ function LocalVideoTrack(mediaStreamTrack, options) {
2840
2907
  inherits(LocalVideoTrack, LocalVideoTrackClass);
2841
2908
  module.exports = LocalVideoTrack;
2842
2909
 
2843
- },{"../../../vendor/inherits":150,"../localvideotrack":25}],18:[function(require,module,exports){
2910
+ },{"../../../vendor/inherits":151,"../localvideotrack":26}],19:[function(require,module,exports){
2844
2911
  'use strict';
2845
2912
  var __extends = (this && this.__extends) || (function () {
2846
2913
  var extendStatics = function (d, b) {
@@ -2952,7 +3019,7 @@ var Track = /** @class */ (function (_super) {
2952
3019
  */
2953
3020
  module.exports = Track;
2954
3021
 
2955
- },{"../../eventemitter":10,"../../util":131,"../../util/constants":124,"../../util/log":135}],19:[function(require,module,exports){
3022
+ },{"../../eventemitter":10,"../../util":132,"../../util/constants":125,"../../util/log":136}],20:[function(require,module,exports){
2956
3023
  'use strict';
2957
3024
  var __extends = (this && this.__extends) || (function () {
2958
3025
  var extendStatics = function (d, b) {
@@ -2969,6 +3036,7 @@ var __extends = (this && this.__extends) || (function () {
2969
3036
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2970
3037
  };
2971
3038
  })();
3039
+ var isIOS = require('../../util/browserdetection').isIOS;
2972
3040
  var AudioTrack = require('./audiotrack');
2973
3041
  var mixinLocalMediaTrack = require('./localmediatrack');
2974
3042
  var LocalMediaAudioTrack = mixinLocalMediaTrack(AudioTrack);
@@ -2980,6 +3048,10 @@ var LocalMediaAudioTrack = mixinLocalMediaTrack(AudioTrack);
2980
3048
  * {@link LocalAudioTrack#stop}.
2981
3049
  * @extends AudioTrack
2982
3050
  * @property {Track.ID} id - The {@link LocalAudioTrack}'s ID
3051
+ * @property {boolean} isMuted - Whether or not the audio source has stopped sending samples to the
3052
+ * {@link LocalAudioTrack}; This can happen when the microphone is taken over by another application,
3053
+ * mainly on mobile devices; When this property toggles, then <code>muted</code> and <code>unmuted</code>
3054
+ * events are fired appropriately
2983
3055
  * @property {boolean} isStopped - Whether or not the {@link LocalAudioTrack} is
2984
3056
  * stopped
2985
3057
  * @property {NoiseCancellation?} noiseCancellation - When a LocalAudioTrack is created
@@ -2987,8 +3059,10 @@ var LocalMediaAudioTrack = mixinLocalMediaTrack(AudioTrack);
2987
3059
  * to enable or disable the noise cancellation at runtime.
2988
3060
  * @emits LocalAudioTrack#disabled
2989
3061
  * @emits LocalAudioTrack#enabled
3062
+ * @emits LocalAudioTrack#muted
2990
3063
  * @emits LocalAudioTrack#started
2991
3064
  * @emits LocalAudioTrack#stopped
3065
+ * @emits LocalAudioTrack#unmuted
2992
3066
  */
2993
3067
  var LocalAudioTrack = /** @class */ (function (_super) {
2994
3068
  __extends(LocalAudioTrack, _super);
@@ -3001,13 +3075,61 @@ var LocalAudioTrack = /** @class */ (function (_super) {
3001
3075
  var _this = this;
3002
3076
  var noiseCancellation = (options === null || options === void 0 ? void 0 : options.noiseCancellation) || null;
3003
3077
  _this = _super.call(this, mediaStreamTrack, options) || this;
3078
+ var log = _this._log;
3079
+ var _a = mediaStreamTrack.label, defaultDeviceLabel = _a === void 0 ? '' : _a;
3080
+ var _b = mediaStreamTrack.getSettings(), _c = _b.deviceId, defaultDeviceId = _c === void 0 ? '' : _c, _d = _b.groupId, defaultGroupId = _d === void 0 ? '' : _d;
3004
3081
  Object.defineProperties(_this, {
3082
+ _currentDefaultDeviceInfo: {
3083
+ value: { deviceId: defaultDeviceId, groupId: defaultGroupId, label: defaultDeviceLabel },
3084
+ writable: true
3085
+ },
3086
+ _defaultDeviceCaptureMode: {
3087
+ value: !isIOS()
3088
+ && _this._isCreatedByCreateLocalTracks
3089
+ && typeof navigator === 'object'
3090
+ && typeof navigator.mediaDevices === 'object'
3091
+ && typeof navigator.mediaDevices.addEventListener === 'function'
3092
+ && typeof navigator.mediaDevices.enumerateDevices === 'function'
3093
+ ? (options === null || options === void 0 ? void 0 : options.defaultDeviceCaptureMode) || 'auto'
3094
+ : 'manual'
3095
+ },
3096
+ _onDeviceChange: {
3097
+ value: function () {
3098
+ navigator.mediaDevices.enumerateDevices().then(function (deviceInfos) {
3099
+ // NOTE(mmalavalli): In Chrome, when the default device changes, and we restart the LocalAudioTrack with
3100
+ // device ID "default", it will not switch to the new default device unless all LocalAudioTracks capturing
3101
+ // from the old default device are stopped. So, we restart the LocalAudioTrack with the actual device ID of
3102
+ // the new default device instead.
3103
+ var defaultDeviceInfo = deviceInfos.find(function (_a) {
3104
+ var deviceId = _a.deviceId, kind = _a.kind;
3105
+ return kind === 'audioinput' && deviceId !== 'default';
3106
+ });
3107
+ if (defaultDeviceInfo && ['deviceId', 'groupId'].some(function (prop) {
3108
+ return defaultDeviceInfo[prop] !== _this._currentDefaultDeviceInfo[prop];
3109
+ })) {
3110
+ log.info('Default device changed, restarting the LocalAudioTrack');
3111
+ log.debug("Old default device: \"" + _this._currentDefaultDeviceInfo.deviceId + "\" => \"" + _this._currentDefaultDeviceInfo.label + "\"");
3112
+ log.debug("New default device: \"" + defaultDeviceInfo.deviceId + "\" => \"" + defaultDeviceInfo.label + "\"");
3113
+ _this._currentDefaultDeviceInfo = defaultDeviceInfo;
3114
+ _this._restartDefaultDevice().catch(function (error) { return log.warn("Failed to restart: " + error.message); });
3115
+ }
3116
+ }, function (error) {
3117
+ log.warn("Failed to run enumerateDevices(): " + error.message);
3118
+ });
3119
+ }
3120
+ },
3121
+ _restartOnDefaultDeviceChangeCleanup: {
3122
+ value: null,
3123
+ writable: true
3124
+ },
3005
3125
  noiseCancellation: {
3006
3126
  enumerable: true,
3007
3127
  value: noiseCancellation,
3008
3128
  writable: false
3009
3129
  },
3010
3130
  });
3131
+ log.debug('defaultDeviceCaptureMode:', _this._defaultDeviceCaptureMode);
3132
+ _this._maybeRestartOnDefaultDeviceChange();
3011
3133
  return _this;
3012
3134
  }
3013
3135
  LocalAudioTrack.prototype.toString = function () {
@@ -3024,6 +3146,51 @@ var LocalAudioTrack = /** @class */ (function (_super) {
3024
3146
  LocalAudioTrack.prototype._end = function () {
3025
3147
  return _super.prototype._end.apply(this, arguments);
3026
3148
  };
3149
+ /**
3150
+ * @private
3151
+ */
3152
+ LocalAudioTrack.prototype._maybeRestartOnDefaultDeviceChange = function () {
3153
+ var _this = this;
3154
+ var _a = this, constraints = _a._constraints, defaultDeviceCaptureMode = _a._defaultDeviceCaptureMode, log = _a._log;
3155
+ var mediaStreamTrack = this.noiseCancellation ? this.noiseCancellation.sourceTrack : this.mediaStreamTrack;
3156
+ var deviceId = mediaStreamTrack.getSettings().deviceId;
3157
+ var isNotEqualToCapturedDeviceIdOrEqualToDefault = function (requestedDeviceId) {
3158
+ return requestedDeviceId !== deviceId || requestedDeviceId === 'default';
3159
+ };
3160
+ var isCapturingFromDefaultDevice = (function checkIfCapturingFromDefaultDevice(deviceIdConstraint) {
3161
+ if (deviceIdConstraint === void 0) { deviceIdConstraint = {}; }
3162
+ if (typeof deviceIdConstraint === 'string') {
3163
+ return isNotEqualToCapturedDeviceIdOrEqualToDefault(deviceIdConstraint);
3164
+ }
3165
+ else if (Array.isArray(deviceIdConstraint)) {
3166
+ return deviceIdConstraint.every(isNotEqualToCapturedDeviceIdOrEqualToDefault);
3167
+ }
3168
+ else if (deviceIdConstraint.exact) {
3169
+ return checkIfCapturingFromDefaultDevice(deviceIdConstraint.exact);
3170
+ }
3171
+ else if (deviceIdConstraint.ideal) {
3172
+ return checkIfCapturingFromDefaultDevice(deviceIdConstraint.ideal);
3173
+ }
3174
+ return true;
3175
+ }(constraints.deviceId));
3176
+ if (defaultDeviceCaptureMode === 'auto' && isCapturingFromDefaultDevice) {
3177
+ if (!this._restartOnDefaultDeviceChangeCleanup) {
3178
+ log.info('LocalAudioTrack will be restarted if the default device changes');
3179
+ navigator.mediaDevices.addEventListener('devicechange', this._onDeviceChange);
3180
+ this._restartOnDefaultDeviceChangeCleanup = function () {
3181
+ log.info('Cleaning up the listener to restart the LocalAudioTrack if the default device changes');
3182
+ navigator.mediaDevices.removeEventListener('devicechange', _this._onDeviceChange);
3183
+ _this._restartOnDefaultDeviceChangeCleanup = null;
3184
+ };
3185
+ }
3186
+ }
3187
+ else {
3188
+ log.info('LocalAudioTrack will NOT be restarted if the default device changes');
3189
+ if (this._restartOnDefaultDeviceChangeCleanup) {
3190
+ this._restartOnDefaultDeviceChangeCleanup();
3191
+ }
3192
+ }
3193
+ };
3027
3194
  /**
3028
3195
  * @private
3029
3196
  */
@@ -3038,7 +3205,22 @@ var LocalAudioTrack = /** @class */ (function (_super) {
3038
3205
  return _super.prototype._reacquireTrack.call(this, constraints);
3039
3206
  };
3040
3207
  /**
3041
- * Disable the {@link LocalAudioTrack}. This is effectively "mute".
3208
+ * @private
3209
+ */
3210
+ LocalAudioTrack.prototype._restartDefaultDevice = function () {
3211
+ var _this = this;
3212
+ var constraints = Object.assign({}, this._constraints);
3213
+ var restartConstraints = Object.assign({}, constraints, { deviceId: this._currentDefaultDeviceInfo.deviceId });
3214
+ return this.restart(restartConstraints).then(function () {
3215
+ // NOTE(mmalavalli): Since we used the new default device's ID while restarting the LocalAudioTrack,
3216
+ // we reset the constraints to the original constraints so that the default device detection logic in
3217
+ // _maybeRestartOnDefaultDeviceChange() still works.
3218
+ _this._constraints = constraints;
3219
+ _this._maybeRestartOnDefaultDeviceChange();
3220
+ });
3221
+ };
3222
+ /**
3223
+ * Disable the {@link LocalAudioTrack}. This is equivalent to muting the audio source.
3042
3224
  * @returns {this}
3043
3225
  * @fires LocalAudioTrack#disabled
3044
3226
  */
@@ -3046,13 +3228,13 @@ var LocalAudioTrack = /** @class */ (function (_super) {
3046
3228
  return _super.prototype.disable.apply(this, arguments);
3047
3229
  };
3048
3230
  /**
3049
- * Enable the {@link LocalAudioTrack}. This is effectively "unmute".
3231
+ * Enable the {@link LocalAudioTrack}. This is equivalent to unmuting the audio source.
3050
3232
  * @returns {this}
3051
3233
  * @fires LocalAudioTrack#enabled
3052
3234
  */ /**
3053
- * Enable or disable the {@link LocalAudioTrack}. This is effectively "unmute"
3054
- * or "mute".
3055
- * @param {boolean} [enabled] - Specify false to mute the
3235
+ * Enable or disable the {@link LocalAudioTrack}. This is equivalent to unmuting or muting
3236
+ * the audio source respectively.
3237
+ * @param {boolean} [enabled] - Specify false to disable the
3056
3238
  * {@link LocalAudioTrack}
3057
3239
  * @returns {this}
3058
3240
  * @fires LocalAudioTrack#disabled
@@ -3108,21 +3290,30 @@ var LocalAudioTrack = /** @class */ (function (_super) {
3108
3290
  if (this.noiseCancellation) {
3109
3291
  this.noiseCancellation.stop();
3110
3292
  }
3293
+ if (this._restartOnDefaultDeviceChangeCleanup) {
3294
+ this._restartOnDefaultDeviceChangeCleanup();
3295
+ }
3111
3296
  return _super.prototype.stop.apply(this, arguments);
3112
3297
  };
3113
3298
  return LocalAudioTrack;
3114
3299
  }(LocalMediaAudioTrack));
3115
3300
  /**
3116
- * The {@link LocalAudioTrack} was disabled, i.e. "muted".
3301
+ * The {@link LocalAudioTrack} was disabled, i.e. the audio source was muted by the user.
3117
3302
  * @param {LocalAudioTrack} track - The {@link LocalAudioTrack} that was
3118
3303
  * disabled
3119
3304
  * @event LocalAudioTrack#disabled
3120
3305
  */
3121
3306
  /**
3122
- * The {@link LocalAudioTrack} was enabled, i.e. "unmuted".
3307
+ * The {@link LocalAudioTrack} was enabled, i.e. the audio source was unmuted by the user.
3123
3308
  * @param {LocalAudioTrack} track - The {@link LocalAudioTrack} that was enabled
3124
3309
  * @event LocalAudioTrack#enabled
3125
3310
  */
3311
+ /**
3312
+ * The {@link LocalAudioTrack} was muted because the audio source stopped sending samples, most
3313
+ * likely due to another application taking said audio source, especially on mobile devices.
3314
+ * @param {LocalAudioTrack} track - The {@link LocalAudioTrack} that was muted
3315
+ * @event LocalAudioTrack#muted
3316
+ */
3126
3317
  /**
3127
3318
  * The {@link LocalAudioTrack} started. This means there is enough audio data to
3128
3319
  * begin playback.
@@ -3136,9 +3327,18 @@ var LocalAudioTrack = /** @class */ (function (_super) {
3136
3327
  * @param {LocalAudioTrack} track - The {@link LocalAudioTrack} that stopped
3137
3328
  * @event LocalAudioTrack#stopped
3138
3329
  */
3330
+ /**
3331
+ * The {@link LocalAudioTrack} was unmuted because the audio source resumed sending samples,
3332
+ * most likely due to the application that took over the said audio source has released it
3333
+ * back to the application, especially on mobile devices. This event is also fired when
3334
+ * {@link LocalAudioTrack#restart} is called on a muted {@link LocalAudioTrack} with a
3335
+ * new audio source.
3336
+ * @param {LocalAudioTrack} track - The {@link LocalAudioTrack} that was unmuted
3337
+ * @event LocalAudioTrack#unmuted
3338
+ */
3139
3339
  module.exports = LocalAudioTrack;
3140
3340
 
3141
- },{"./audiotrack":13,"./localmediatrack":23}],20:[function(require,module,exports){
3341
+ },{"../../util/browserdetection":123,"./audiotrack":14,"./localmediatrack":24}],21:[function(require,module,exports){
3142
3342
  'use strict';
3143
3343
  var __extends = (this && this.__extends) || (function () {
3144
3344
  var extendStatics = function (d, b) {
@@ -3184,7 +3384,7 @@ var LocalAudioTrackPublication = /** @class */ (function (_super) {
3184
3384
  }(LocalTrackPublication));
3185
3385
  module.exports = LocalAudioTrackPublication;
3186
3386
 
3187
- },{"./localtrackpublication":24}],21:[function(require,module,exports){
3387
+ },{"./localtrackpublication":25}],22:[function(require,module,exports){
3188
3388
  'use strict';
3189
3389
  var __extends = (this && this.__extends) || (function () {
3190
3390
  var extendStatics = function (d, b) {
@@ -3322,7 +3522,7 @@ var LocalDataTrack = /** @class */ (function (_super) {
3322
3522
  */
3323
3523
  module.exports = LocalDataTrack;
3324
3524
 
3325
- },{"../../data/sender":6,"./":18}],22:[function(require,module,exports){
3525
+ },{"../../data/sender":6,"./":19}],23:[function(require,module,exports){
3326
3526
  'use strict';
3327
3527
  var __extends = (this && this.__extends) || (function () {
3328
3528
  var extendStatics = function (d, b) {
@@ -3368,7 +3568,7 @@ var LocalDataTrackPublication = /** @class */ (function (_super) {
3368
3568
  }(LocalTrackPublication));
3369
3569
  module.exports = LocalDataTrackPublication;
3370
3570
 
3371
- },{"./localtrackpublication":24}],23:[function(require,module,exports){
3571
+ },{"./localtrackpublication":25}],24:[function(require,module,exports){
3372
3572
  /* eslint new-cap:0 */
3373
3573
  'use strict';
3374
3574
  var __extends = (this && this.__extends) || (function () {
@@ -3387,8 +3587,8 @@ var __extends = (this && this.__extends) || (function () {
3387
3587
  };
3388
3588
  })();
3389
3589
  var getUserMedia = require('../../webrtc').getUserMedia;
3390
- var _a = require('../../webrtc/util'), guessBrowser = _a.guessBrowser, isIOSChrome = _a.isIOSChrome;
3391
- var _b = require('../../util'), capitalize = _b.capitalize, defer = _b.defer, isUserMediaTrack = _b.isUserMediaTrack, waitForSometime = _b.waitForSometime, waitForEvent = _b.waitForEvent;
3590
+ var isIOS = require('../../util/browserdetection').isIOS;
3591
+ var _a = require('../../util'), capitalize = _a.capitalize, defer = _a.defer, isUserMediaTrack = _a.isUserMediaTrack, waitForSometime = _a.waitForSometime, waitForEvent = _a.waitForEvent;
3392
3592
  var ILLEGAL_INVOKE = require('../../util/constants').typeErrors.ILLEGAL_INVOKE;
3393
3593
  var detectSilentAudio = require('../../util/detectsilentaudio');
3394
3594
  var detectSilentVideo = require('../../util/detectsilentvideo');
@@ -3403,7 +3603,9 @@ function mixinLocalMediaTrack(AudioOrVideoTrack) {
3403
3603
  * enabled and disabled with {@link LocalMediaTrack#enable} and
3404
3604
  * {@link LocalMediaTrack#disable} or stopped completely with
3405
3605
  * {@link LocalMediaTrack#stop}.
3606
+ * @emits LocalMediaTrack#muted
3406
3607
  * @emits LocalMediaTrack#stopped
3608
+ * @emits LocalMediaTrack#unmuted
3407
3609
  */
3408
3610
  return /** @class */ (function (_super) {
3409
3611
  __extends(LocalMediaTrack, _super);
@@ -3414,10 +3616,7 @@ function mixinLocalMediaTrack(AudioOrVideoTrack) {
3414
3616
  */
3415
3617
  function LocalMediaTrack(mediaStreamTrack, options) {
3416
3618
  var _this = this;
3417
- // NOTE(mpatwardhan): by default workaround for WebKitBug1208516 will be enabled on Safari browsers
3418
- // although the bug is seen mainly on iOS devices, we do not have a reliable way to tell iOS from MacOs
3419
- // userAgent on iOS pretends its macOs if Safari is set to request desktop pages.
3420
- var workaroundWebKitBug1208516 = (guessBrowser() === 'safari' || isIOSChrome())
3619
+ var workaroundWebKitBug1208516 = isIOS()
3421
3620
  && isUserMediaTrack(mediaStreamTrack)
3422
3621
  && typeof document === 'object'
3423
3622
  && typeof document.addEventListener === 'function'
@@ -3444,6 +3643,12 @@ function mixinLocalMediaTrack(AudioOrVideoTrack) {
3444
3643
  _gUMSilentTrackWorkaround: {
3445
3644
  value: options.gUMSilentTrackWorkaround
3446
3645
  },
3646
+ _eventsToReemitters: {
3647
+ value: new Map([
3648
+ ['muted', function () { return _this.emit('muted', _this); }],
3649
+ ['unmuted', function () { return _this.emit('unmuted', _this); }]
3650
+ ])
3651
+ },
3447
3652
  _workaroundWebKitBug1208516: {
3448
3653
  value: options.workaroundWebKitBug1208516
3449
3654
  },
@@ -3471,6 +3676,12 @@ function mixinLocalMediaTrack(AudioOrVideoTrack) {
3471
3676
  return mediaTrackSender.enabled;
3472
3677
  }
3473
3678
  },
3679
+ isMuted: {
3680
+ enumerable: true,
3681
+ get: function () {
3682
+ return mediaTrackSender.muted;
3683
+ }
3684
+ },
3474
3685
  isStopped: {
3475
3686
  enumerable: true,
3476
3687
  get: function () {
@@ -3483,17 +3694,20 @@ function mixinLocalMediaTrack(AudioOrVideoTrack) {
3483
3694
  if (_this._workaroundWebKitBug1208516) {
3484
3695
  _this._workaroundWebKitBug1208516Cleanup = restartWhenInadvertentlyStopped(_this);
3485
3696
  }
3697
+ _this._reemitTrackSenderEvents();
3486
3698
  return _this;
3487
3699
  }
3488
3700
  /**
3489
3701
  * @private
3490
3702
  */
3491
3703
  LocalMediaTrack.prototype._end = function () {
3704
+ var _this = this;
3492
3705
  if (this._didCallEnd) {
3493
3706
  return;
3494
3707
  }
3495
3708
  _super.prototype._end.call(this);
3496
3709
  this._didCallEnd = true;
3710
+ this._eventsToReemitters.forEach(function (reemitter, event) { return _this._trackSender.removeListener(event, reemitter); });
3497
3711
  this.emit('stopped', this);
3498
3712
  };
3499
3713
  /**
@@ -3503,6 +3717,9 @@ function mixinLocalMediaTrack(AudioOrVideoTrack) {
3503
3717
  if (this._didCallEnd) {
3504
3718
  this._didCallEnd = false;
3505
3719
  }
3720
+ if (this._eventsToReemitters) {
3721
+ this._reemitTrackSenderEvents();
3722
+ }
3506
3723
  _super.prototype._initialize.call(this);
3507
3724
  };
3508
3725
  /**
@@ -3524,6 +3741,15 @@ function mixinLocalMediaTrack(AudioOrVideoTrack) {
3524
3741
  return mediaStream.getTracks()[0];
3525
3742
  });
3526
3743
  };
3744
+ /**
3745
+ * @private
3746
+ */
3747
+ LocalMediaTrack.prototype._reemitTrackSenderEvents = function () {
3748
+ var _this = this;
3749
+ this._eventsToReemitters.forEach(function (reemitter, event) { return _this._trackSender.on(event, reemitter); });
3750
+ this._trackSender.dequeue('muted');
3751
+ this._trackSender.dequeue('unmuted');
3752
+ };
3527
3753
  /**
3528
3754
  * @private
3529
3755
  */
@@ -3726,7 +3952,7 @@ function restartWhenInadvertentlyStopped(localMediaTrack) {
3726
3952
  }
3727
3953
  module.exports = mixinLocalMediaTrack;
3728
3954
 
3729
- },{"../../util":131,"../../util/constants":124,"../../util/detectsilentaudio":125,"../../util/detectsilentvideo":126,"../../util/documentvisibilitymonitor.js":127,"../../util/localmediarestartdeferreds":134,"../../webaudio/workaround180748":154,"../../webrtc":157,"../../webrtc/util":170,"./sender":38}],24:[function(require,module,exports){
3955
+ },{"../../util":132,"../../util/browserdetection":123,"../../util/constants":125,"../../util/detectsilentaudio":126,"../../util/detectsilentvideo":127,"../../util/documentvisibilitymonitor.js":128,"../../util/localmediarestartdeferreds":135,"../../webaudio/workaround180748":155,"../../webrtc":158,"./sender":39}],25:[function(require,module,exports){
3730
3956
  /* eslint new-cap:0 */
3731
3957
  'use strict';
3732
3958
  var __extends = (this && this.__extends) || (function () {
@@ -3892,7 +4118,7 @@ var LocalTrackPublication = /** @class */ (function (_super) {
3892
4118
  */
3893
4119
  module.exports = LocalTrackPublication;
3894
4120
 
3895
- },{"../../util/constants":124,"./trackpublication":39}],25:[function(require,module,exports){
4121
+ },{"../../util/constants":125,"./trackpublication":40}],26:[function(require,module,exports){
3896
4122
  'use strict';
3897
4123
  var __extends = (this && this.__extends) || (function () {
3898
4124
  var extendStatics = function (d, b) {
@@ -3909,7 +4135,7 @@ var __extends = (this && this.__extends) || (function () {
3909
4135
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3910
4136
  };
3911
4137
  })();
3912
- var _a = require('../../webrtc/util'), guessBrowser = _a.guessBrowser, isIOSChrome = _a.isIOSChrome;
4138
+ var isIOS = require('../../util/browserdetection').isIOS;
3913
4139
  var detectSilentVideo = require('../../util/detectsilentvideo');
3914
4140
  var mixinLocalMediaTrack = require('./localmediatrack');
3915
4141
  var VideoTrack = require('./videotrack');
@@ -3923,12 +4149,18 @@ var LocalMediaVideoTrack = mixinLocalMediaTrack(VideoTrack);
3923
4149
  * {@link LocalVideoTrack#stop}.
3924
4150
  * @extends VideoTrack
3925
4151
  * @property {Track.ID} id - The {@link LocalVideoTrack}'s ID
4152
+ * @property {boolean} isMuted - Whether or not the video source has stopped sending frames to the
4153
+ * {@link LocalVideoTrack}; This can happen when the camera is taken over by another application,
4154
+ * mainly on mobile devices; When this property toggles, then <code>muted</code> and <code>unmuted</code>
4155
+ * events are fired appropriately
3926
4156
  * @property {boolean} isStopped - Whether or not the {@link LocalVideoTrack} is
3927
4157
  * stopped
3928
4158
  * @emits LocalVideoTrack#disabled
3929
4159
  * @emits LocalVideoTrack#enabled
4160
+ * @emits LocalVideoTrack#muted
3930
4161
  * @emits LocalVideoTrack#started
3931
4162
  * @emits LocalVideoTrack#stopped
4163
+ * @emits LocalVideoTrack#unmuted
3932
4164
  */
3933
4165
  var LocalVideoTrack = /** @class */ (function (_super) {
3934
4166
  __extends(LocalVideoTrack, _super);
@@ -3940,7 +4172,7 @@ var LocalVideoTrack = /** @class */ (function (_super) {
3940
4172
  function LocalVideoTrack(mediaStreamTrack, options) {
3941
4173
  var _this = this;
3942
4174
  options = Object.assign({
3943
- workaroundSilentLocalVideo: (guessBrowser() === 'safari' || isIOSChrome())
4175
+ workaroundSilentLocalVideo: isIOS()
3944
4176
  && isUserMediaTrack(mediaStreamTrack)
3945
4177
  && typeof document !== 'undefined'
3946
4178
  && typeof document.createElement === 'function'
@@ -4055,8 +4287,8 @@ var LocalVideoTrack = /** @class */ (function (_super) {
4055
4287
  return result;
4056
4288
  };
4057
4289
  /**
4058
- * Disable the {@link LocalVideoTrack}. This is effectively "pause".
4059
- * If a {@link VideoProcessor} is added, then `processedTrack` is disabled as well.
4290
+ * Disable the {@link LocalVideoTrack}. This is equivalent to pausing a video source.
4291
+ * If a {@link VideoProcessor} is added, then <code>processedTrack</code> is also disabled.
4060
4292
  * @returns {this}
4061
4293
  * @fires VideoTrack#disabled
4062
4294
  */
@@ -4068,15 +4300,15 @@ var LocalVideoTrack = /** @class */ (function (_super) {
4068
4300
  return result;
4069
4301
  };
4070
4302
  /**
4071
- * Enable the {@link LocalVideoTrack}. This is effectively "unpause".
4072
- * If a {@link VideoProcessor} is added, then `processedTrack` is enabled as well.
4303
+ * Enable the {@link LocalVideoTrack}. This is equivalent to unpausing the video source.
4304
+ * If a {@link VideoProcessor} is added, then <code>processedTrack</code> is also enabled.
4073
4305
  * @returns {this}
4074
4306
  * @fires VideoTrack#enabled
4075
4307
  */ /**
4076
- * Enable or disable the {@link LocalVideoTrack}. This is effectively "unpause"
4077
- * or "pause". If a {@link VideoProcessor} is added,
4078
- * then `processedTrack` is enabled or disabled as well.
4079
- * @param {boolean} [enabled] - Specify false to pause the
4308
+ * Enable or disable the {@link LocalVideoTrack}. This is equivalent to unpausing or pausing
4309
+ * the video source respectively. If a {@link VideoProcessor} is added, then <code>processedTrack</code>
4310
+ * is also enabled or disabled.
4311
+ * @param {boolean} [enabled] - Specify false to disable the
4080
4312
  * {@link LocalVideoTrack}
4081
4313
  * @returns {this}
4082
4314
  * @fires VideoTrack#disabled
@@ -4214,16 +4446,22 @@ function workaroundSilentLocalVideo(localVideoTrack, doc) {
4214
4446
  };
4215
4447
  }
4216
4448
  /**
4217
- * The {@link LocalVideoTrack} was disabled, i.e. "muted".
4449
+ * The {@link LocalVideoTrack} was disabled, i.e. the video source was paused by the user.
4218
4450
  * @param {LocalVideoTrack} track - The {@link LocalVideoTrack} that was
4219
4451
  * disabled
4220
4452
  * @event LocalVideoTrack#disabled
4221
4453
  */
4222
4454
  /**
4223
- * The {@link LocalVideoTrack} was enabled, i.e. "unmuted".
4455
+ * The {@link LocalVideoTrack} was enabled, i.e. the video source was unpaused by the user.
4224
4456
  * @param {LocalVideoTrack} track - The {@link LocalVideoTrack} that was enabled
4225
4457
  * @event LocalVideoTrack#enabled
4226
4458
  */
4459
+ /**
4460
+ * The {@link LocalVideoTrack} was muted because the video source stopped sending frames, most
4461
+ * likely due to another application taking said video source, especially on mobile devices.
4462
+ * @param {LocalVideoTrack} track - The {@link LocalVideoTrack} that was muted
4463
+ * @event LocalVideoTrack#muted
4464
+ */
4227
4465
  /**
4228
4466
  * The {@link LocalVideoTrack} started. This means there is enough video data
4229
4467
  * to begin playback.
@@ -4237,9 +4475,18 @@ function workaroundSilentLocalVideo(localVideoTrack, doc) {
4237
4475
  * @param {LocalVideoTrack} track - The {@link LocalVideoTrack} that stopped
4238
4476
  * @event LocalVideoTrack#stopped
4239
4477
  */
4478
+ /**
4479
+ * The {@link LocalVideoTrack} was unmuted because the video source resumed sending frames,
4480
+ * most likely due to the application that took over the said video source has released it
4481
+ * back to the application, especially on mobile devices. This event is also fired when
4482
+ * {@link LocalVideoTrack#restart} is called on a muted {@link LocalVideoTrack} with a
4483
+ * new video source.
4484
+ * @param {LocalVideoTrack} track - The {@link LocalVideoTrack} that was unmuted
4485
+ * @event LocalVideoTrack#unmuted
4486
+ */
4240
4487
  module.exports = LocalVideoTrack;
4241
4488
 
4242
- },{"../../util":131,"../../util/detectsilentvideo":126,"../../webrtc/util":170,"./localmediatrack":23,"./videotrack":42}],26:[function(require,module,exports){
4489
+ },{"../../util":132,"../../util/browserdetection":123,"../../util/detectsilentvideo":127,"./localmediatrack":24,"./videotrack":43}],27:[function(require,module,exports){
4243
4490
  'use strict';
4244
4491
  var __extends = (this && this.__extends) || (function () {
4245
4492
  var extendStatics = function (d, b) {
@@ -4285,7 +4532,7 @@ var LocalVideoTrackPublication = /** @class */ (function (_super) {
4285
4532
  }(LocalTrackPublication));
4286
4533
  module.exports = LocalVideoTrackPublication;
4287
4534
 
4288
- },{"./localtrackpublication":24}],27:[function(require,module,exports){
4535
+ },{"./localtrackpublication":25}],28:[function(require,module,exports){
4289
4536
  'use strict';
4290
4537
  var __extends = (this && this.__extends) || (function () {
4291
4538
  var extendStatics = function (d, b) {
@@ -4302,9 +4549,9 @@ var __extends = (this && this.__extends) || (function () {
4302
4549
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4303
4550
  };
4304
4551
  })();
4305
- var _a = require('../../webrtc/util'), guessBrowser = _a.guessBrowser, isIOSChrome = _a.isIOSChrome;
4552
+ var isIOS = require('../../util/browserdetection').isIOS;
4306
4553
  var MediaStream = require('../../webrtc').MediaStream;
4307
- var _b = require('../../util'), waitForEvent = _b.waitForEvent, waitForSometime = _b.waitForSometime;
4554
+ var _a = require('../../util'), waitForEvent = _a.waitForEvent, waitForSometime = _a.waitForSometime;
4308
4555
  var localMediaRestartDeferreds = require('../../util/localmediarestartdeferreds');
4309
4556
  var Track = require('./');
4310
4557
  /**
@@ -4334,7 +4581,7 @@ var MediaTrack = /** @class */ (function (_super) {
4334
4581
  function MediaTrack(mediaTrackTransceiver, options) {
4335
4582
  var _this = this;
4336
4583
  options = Object.assign({
4337
- playPausedElementsIfNotBackgrounded: (guessBrowser() === 'safari' || isIOSChrome())
4584
+ playPausedElementsIfNotBackgrounded: isIOS()
4338
4585
  && typeof document === 'object'
4339
4586
  && typeof document.addEventListener === 'function'
4340
4587
  && typeof document.visibilityState === 'string'
@@ -4649,7 +4896,7 @@ function shimMediaElement(el, onUnintentionallyPaused) {
4649
4896
  }
4650
4897
  module.exports = MediaTrack;
4651
4898
 
4652
- },{"../../util":131,"../../util/localmediarestartdeferreds":134,"../../webrtc":157,"../../webrtc/util":170,"./":18}],28:[function(require,module,exports){
4899
+ },{"../../util":132,"../../util/browserdetection":123,"../../util/localmediarestartdeferreds":135,"../../webrtc":158,"./":19}],29:[function(require,module,exports){
4653
4900
  'use strict';
4654
4901
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4655
4902
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -4878,7 +5125,7 @@ function applyNoiseCancellation(mediaStreamTrack, noiseCancellationOptions, log)
4878
5125
  }
4879
5126
  exports.applyNoiseCancellation = applyNoiseCancellation;
4880
5127
 
4881
- },{"../../noisecancellationadapter":44,"../../util/log":135}],29:[function(require,module,exports){
5128
+ },{"../../noisecancellationadapter":45,"../../util/log":136}],30:[function(require,module,exports){
4882
5129
  'use strict';
4883
5130
  var __extends = (this && this.__extends) || (function () {
4884
5131
  var extendStatics = function (d, b) {
@@ -4914,7 +5161,7 @@ var MediaTrackReceiver = /** @class */ (function (_super) {
4914
5161
  }(MediaTrackTransceiver));
4915
5162
  module.exports = MediaTrackReceiver;
4916
5163
 
4917
- },{"./transceiver":40}],30:[function(require,module,exports){
5164
+ },{"./transceiver":41}],31:[function(require,module,exports){
4918
5165
  'use strict';
4919
5166
  var __extends = (this && this.__extends) || (function () {
4920
5167
  var extendStatics = function (d, b) {
@@ -5023,7 +5270,7 @@ var RemoteAudioTrack = /** @class */ (function (_super) {
5023
5270
  */
5024
5271
  module.exports = RemoteAudioTrack;
5025
5272
 
5026
- },{"./audiotrack":13,"./remotemediatrack":34}],31:[function(require,module,exports){
5273
+ },{"./audiotrack":14,"./remotemediatrack":35}],32:[function(require,module,exports){
5027
5274
  'use strict';
5028
5275
  var __extends = (this && this.__extends) || (function () {
5029
5276
  var extendStatics = function (d, b) {
@@ -5095,7 +5342,7 @@ var RemoteAudioTrackPublication = /** @class */ (function (_super) {
5095
5342
  */
5096
5343
  module.exports = RemoteAudioTrackPublication;
5097
5344
 
5098
- },{"./remotetrackpublication":35}],32:[function(require,module,exports){
5345
+ },{"./remotetrackpublication":36}],33:[function(require,module,exports){
5099
5346
  'use strict';
5100
5347
  var __extends = (this && this.__extends) || (function () {
5101
5348
  var extendStatics = function (d, b) {
@@ -5282,7 +5529,7 @@ var RemoteDataTrack = /** @class */ (function (_super) {
5282
5529
  */
5283
5530
  module.exports = RemoteDataTrack;
5284
5531
 
5285
- },{"../../util/constants":124,"./":18}],33:[function(require,module,exports){
5532
+ },{"../../util/constants":125,"./":19}],34:[function(require,module,exports){
5286
5533
  'use strict';
5287
5534
  var __extends = (this && this.__extends) || (function () {
5288
5535
  var extendStatics = function (d, b) {
@@ -5344,7 +5591,7 @@ var RemoteDataTrackPublication = /** @class */ (function (_super) {
5344
5591
  */
5345
5592
  module.exports = RemoteDataTrackPublication;
5346
5593
 
5347
- },{"./remotetrackpublication":35}],34:[function(require,module,exports){
5594
+ },{"./remotetrackpublication":36}],35:[function(require,module,exports){
5348
5595
  'use strict';
5349
5596
  var __extends = (this && this.__extends) || (function () {
5350
5597
  var extendStatics = function (d, b) {
@@ -5383,7 +5630,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
5383
5630
  return to;
5384
5631
  };
5385
5632
  var _a = require('../../util/constants'), E = _a.typeErrors, trackPriority = _a.trackPriority;
5386
- var _b = require('../../webrtc/util'), guessBrowser = _b.guessBrowser, isIOSChrome = _b.isIOSChrome;
5633
+ var isIOS = require('../../util/browserdetection').isIOS;
5387
5634
  var documentVisibilityMonitor = require('../../util/documentvisibilitymonitor.js');
5388
5635
  function mixinRemoteMediaTrack(AudioOrVideoTrack) {
5389
5636
  /**
@@ -5417,7 +5664,7 @@ function mixinRemoteMediaTrack(AudioOrVideoTrack) {
5417
5664
  // NOTE(mpatwardhan): WebKit bug: 212780 sometimes causes the audio/video elements to stay paused when safari
5418
5665
  // regains foreground. To workaround it, when safari gains foreground - we will play any elements that were
5419
5666
  // playing before safari lost foreground.
5420
- workaroundWebKitBug212780: (guessBrowser() === 'safari' || isIOSChrome())
5667
+ workaroundWebKitBug212780: isIOS()
5421
5668
  && typeof document === 'object'
5422
5669
  && typeof document.addEventListener === 'function'
5423
5670
  && typeof document.visibilityState === 'string'
@@ -5630,7 +5877,7 @@ function playIfPausedWhileInBackground(remoteMediaTrack) {
5630
5877
  */
5631
5878
  module.exports = mixinRemoteMediaTrack;
5632
5879
 
5633
- },{"../../util/constants":124,"../../util/documentvisibilitymonitor.js":127,"../../webrtc/util":170}],35:[function(require,module,exports){
5880
+ },{"../../util/browserdetection":123,"../../util/constants":125,"../../util/documentvisibilitymonitor.js":128}],36:[function(require,module,exports){
5634
5881
  'use strict';
5635
5882
  var __extends = (this && this.__extends) || (function () {
5636
5883
  var extendStatics = function (d, b) {
@@ -5825,7 +6072,7 @@ var RemoteTrackPublication = /** @class */ (function (_super) {
5825
6072
  */
5826
6073
  module.exports = RemoteTrackPublication;
5827
6074
 
5828
- },{"./trackpublication":39}],36:[function(require,module,exports){
6075
+ },{"./trackpublication":40}],37:[function(require,module,exports){
5829
6076
  'use strict';
5830
6077
  var __extends = (this && this.__extends) || (function () {
5831
6078
  var extendStatics = function (d, b) {
@@ -6259,7 +6506,7 @@ function maybeUpdateDimensionHint(remoteVideoTrack) {
6259
6506
  */
6260
6507
  module.exports = RemoteVideoTrack;
6261
6508
 
6262
- },{"../../util/documentvisibilitymonitor.js":127,"../../util/nullobserver.js":138,"../../util/timeout":145,"./remotemediatrack":34,"./videotrack":42}],37:[function(require,module,exports){
6509
+ },{"../../util/documentvisibilitymonitor.js":128,"../../util/nullobserver.js":139,"../../util/timeout":146,"./remotemediatrack":35,"./videotrack":43}],38:[function(require,module,exports){
6263
6510
  'use strict';
6264
6511
  var __extends = (this && this.__extends) || (function () {
6265
6512
  var extendStatics = function (d, b) {
@@ -6331,7 +6578,7 @@ var RemoteVideoTrackPublication = /** @class */ (function (_super) {
6331
6578
  */
6332
6579
  module.exports = RemoteVideoTrackPublication;
6333
6580
 
6334
- },{"./remotetrackpublication":35}],38:[function(require,module,exports){
6581
+ },{"./remotetrackpublication":36}],39:[function(require,module,exports){
6335
6582
  'use strict';
6336
6583
  var __extends = (this && this.__extends) || (function () {
6337
6584
  var extendStatics = function (d, b) {
@@ -6382,6 +6629,12 @@ var MediaTrackSender = /** @class */ (function (_super) {
6382
6629
  _clones: {
6383
6630
  value: new Set()
6384
6631
  },
6632
+ _eventsToReemitters: {
6633
+ value: new Map([
6634
+ ['mute', function () { return _this.queue('muted'); }],
6635
+ ['unmute', function () { return _this.queue('unmuted'); }]
6636
+ ])
6637
+ },
6385
6638
  _senders: {
6386
6639
  value: new Set()
6387
6640
  },
@@ -6389,13 +6642,36 @@ var MediaTrackSender = /** @class */ (function (_super) {
6389
6642
  value: new Map()
6390
6643
  },
6391
6644
  isPublishing: {
6645
+ enumerable: true,
6392
6646
  get: function () {
6393
6647
  return !!this._clones.size;
6394
6648
  }
6649
+ },
6650
+ muted: {
6651
+ enumerable: true,
6652
+ get: function () {
6653
+ return this._track.muted;
6654
+ }
6395
6655
  }
6396
6656
  });
6657
+ _this._reemitMediaStreamTrackEvents();
6397
6658
  return _this;
6398
6659
  }
6660
+ /**
6661
+ * @private
6662
+ */
6663
+ MediaTrackSender.prototype._reemitMediaStreamTrackEvents = function (mediaStreamTrack) {
6664
+ if (mediaStreamTrack === void 0) { mediaStreamTrack = this._track; }
6665
+ var _a = this, eventsToReemitters = _a._eventsToReemitters, track = _a._track;
6666
+ eventsToReemitters.forEach(function (reemitter, event) { return mediaStreamTrack.addEventListener(event, reemitter); });
6667
+ if (track !== mediaStreamTrack) {
6668
+ eventsToReemitters.forEach(function (reemitter, event) { return track.removeEventListener(event, reemitter); });
6669
+ if (track.muted !== mediaStreamTrack.muted) {
6670
+ var reemitter = eventsToReemitters.get(mediaStreamTrack.muted ? 'mute' : 'unmute');
6671
+ reemitter();
6672
+ }
6673
+ }
6674
+ };
6399
6675
  /**
6400
6676
  * Return a new {@link MediaTrackSender} containing a clone of the underlying
6401
6677
  * MediaStreamTrack. No RTCRtpSenders are copied.
@@ -6427,6 +6703,7 @@ var MediaTrackSender = /** @class */ (function (_super) {
6427
6703
  }).concat(senders.map(function (sender) {
6428
6704
  return _this._replaceTrack(sender, mediaStreamTrack);
6429
6705
  }))).finally(function () {
6706
+ _this._reemitMediaStreamTrackEvents(mediaStreamTrack);
6430
6707
  _this._track = mediaStreamTrack;
6431
6708
  });
6432
6709
  };
@@ -6475,12 +6752,20 @@ var MediaTrackSender = /** @class */ (function (_super) {
6475
6752
  return MediaTrackSender;
6476
6753
  }(MediaTrackTransceiver));
6477
6754
  /**
6478
- * The {@link MediaTrackSender} replaced the underlying mediaStreamTrack
6755
+ * The {@link MediaTrackSender}'s underlying MediaStreamTrack was muted.
6756
+ * @event MediaTrackSender#muted
6757
+ */
6758
+ /**
6759
+ * The {@link MediaTrackSender} replaced the underlying MediaStreamTrack.
6479
6760
  * @event MediaTrackSender#replaced
6480
6761
  */
6762
+ /**
6763
+ * The {@link MediaTrackSender}'s underlying MediaStreamTrack was unmuted.
6764
+ * @event MediaTrackSender#unmuted
6765
+ */
6481
6766
  module.exports = MediaTrackSender;
6482
6767
 
6483
- },{"./transceiver":40}],39:[function(require,module,exports){
6768
+ },{"./transceiver":41}],40:[function(require,module,exports){
6484
6769
  'use strict';
6485
6770
  var __extends = (this && this.__extends) || (function () {
6486
6771
  var extendStatics = function (d, b) {
@@ -6577,7 +6862,7 @@ var TrackPublication = /** @class */ (function (_super) {
6577
6862
  */
6578
6863
  module.exports = TrackPublication;
6579
6864
 
6580
- },{"../../eventemitter":10,"../../util":131,"../../util/constants":124,"../../util/log":135}],40:[function(require,module,exports){
6865
+ },{"../../eventemitter":10,"../../util":132,"../../util/constants":125,"../../util/log":136}],41:[function(require,module,exports){
6581
6866
  'use strict';
6582
6867
  var __extends = (this && this.__extends) || (function () {
6583
6868
  var extendStatics = function (d, b) {
@@ -6644,7 +6929,7 @@ var MediaTrackTransceiver = /** @class */ (function (_super) {
6644
6929
  }(TrackTransceiver));
6645
6930
  module.exports = MediaTrackTransceiver;
6646
6931
 
6647
- },{"../../transceiver":118}],41:[function(require,module,exports){
6932
+ },{"../../transceiver":119}],42:[function(require,module,exports){
6648
6933
  'use strict';
6649
6934
  var __extends = (this && this.__extends) || (function () {
6650
6935
  var extendStatics = function (d, b) {
@@ -6799,7 +7084,7 @@ var VideoProcessorEventObserver = /** @class */ (function (_super) {
6799
7084
  }(EventEmitter));
6800
7085
  module.exports = VideoProcessorEventObserver;
6801
7086
 
6802
- },{"../../util/constants":124,"events":173}],42:[function(require,module,exports){
7087
+ },{"../../util/constants":125,"events":173}],43:[function(require,module,exports){
6803
7088
  'use strict';
6804
7089
  var __extends = (this && this.__extends) || (function () {
6805
7090
  var extendStatics = function (d, b) {
@@ -7314,7 +7599,7 @@ function dimensionsChanged(track, elem) {
7314
7599
  */
7315
7600
  module.exports = VideoTrack;
7316
7601
 
7317
- },{"../../util/constants":124,"./mediatrack":27,"./videoprocessoreventobserver":41}],43:[function(require,module,exports){
7602
+ },{"../../util/constants":125,"./mediatrack":28,"./videoprocessoreventobserver":42}],44:[function(require,module,exports){
7318
7603
  'use strict';
7319
7604
  var __extends = (this && this.__extends) || (function () {
7320
7605
  var extendStatics = function (d, b) {
@@ -7413,7 +7698,7 @@ var NetworkQualityConfigurationImpl = /** @class */ (function (_super) {
7413
7698
  }(EventEmitter));
7414
7699
  module.exports = NetworkQualityConfigurationImpl;
7415
7700
 
7416
- },{"./util":131,"./util/constants":124,"events":173}],44:[function(require,module,exports){
7701
+ },{"./util":132,"./util/constants":125,"events":173}],45:[function(require,module,exports){
7417
7702
  'use strict';
7418
7703
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7419
7704
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -7568,7 +7853,7 @@ function createNoiseCancellationAudioProcessor(noiseCancellationOptions, log) {
7568
7853
  }
7569
7854
  exports.createNoiseCancellationAudioProcessor = createNoiseCancellationAudioProcessor;
7570
7855
 
7571
- },{"./util/dynamicimport":128,"./util/log":135}],45:[function(require,module,exports){
7856
+ },{"./util/dynamicimport":129,"./util/log":136}],46:[function(require,module,exports){
7572
7857
  'use strict';
7573
7858
  var __extends = (this && this.__extends) || (function () {
7574
7859
  var extendStatics = function (d, b) {
@@ -8185,7 +8470,7 @@ function reemitTrackPublicationEvents(participant, publication) {
8185
8470
  }
8186
8471
  module.exports = Participant;
8187
8472
 
8188
- },{"./eventemitter":10,"./media/track/remoteaudiotrack":30,"./media/track/remoteaudiotrackpublication":31,"./media/track/remotedatatrack":32,"./media/track/remotedatatrackpublication":33,"./media/track/remotevideotrack":36,"./media/track/remotevideotrackpublication":37,"./util":131}],46:[function(require,module,exports){
8473
+ },{"./eventemitter":10,"./media/track/remoteaudiotrack":31,"./media/track/remoteaudiotrackpublication":32,"./media/track/remotedatatrack":33,"./media/track/remotedatatrackpublication":34,"./media/track/remotevideotrack":37,"./media/track/remotevideotrackpublication":38,"./util":132}],47:[function(require,module,exports){
8189
8474
  "use strict";
8190
8475
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8191
8476
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -8339,7 +8624,7 @@ function extractSelectedActiveCandidatePair(stats) {
8339
8624
  };
8340
8625
  }
8341
8626
 
8342
- },{}],47:[function(require,module,exports){
8627
+ },{}],48:[function(require,module,exports){
8343
8628
  "use strict";
8344
8629
  Object.defineProperty(exports, "__esModule", { value: true });
8345
8630
  exports.getTurnCredentials = void 0;
@@ -8387,7 +8672,7 @@ function getTurnCredentials(token, wsServer) {
8387
8672
  }
8388
8673
  exports.getTurnCredentials = getTurnCredentials;
8389
8674
 
8390
- },{"../twilioconnection.js":119,"../util/constants":124,"../util/twilio-video-errors":146,"events":173}],48:[function(require,module,exports){
8675
+ },{"../twilioconnection.js":120,"../util/constants":125,"../util/twilio-video-errors":147,"events":173}],49:[function(require,module,exports){
8391
8676
  "use strict";
8392
8677
  var __read = (this && this.__read) || function (o, n) {
8393
8678
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -8428,7 +8713,7 @@ function makeStat(values) {
8428
8713
  }
8429
8714
  exports.makeStat = makeStat;
8430
8715
 
8431
- },{}],49:[function(require,module,exports){
8716
+ },{}],50:[function(require,module,exports){
8432
8717
  "use strict";
8433
8718
  Object.defineProperty(exports, "__esModule", { value: true });
8434
8719
  exports.mosToScore = exports.calculateMOS = void 0;
@@ -8489,7 +8774,7 @@ function mosToScore(mosValue) {
8489
8774
  }
8490
8775
  exports.mosToScore = mosToScore;
8491
8776
 
8492
- },{}],50:[function(require,module,exports){
8777
+ },{}],51:[function(require,module,exports){
8493
8778
  "use strict";
8494
8779
  var __extends = (this && this.__extends) || (function () {
8495
8780
  var extendStatics = function (d, b) {
@@ -9133,7 +9418,7 @@ function runPreflight(token, options) {
9133
9418
  }
9134
9419
  exports.runPreflight = runPreflight;
9135
9420
 
9136
- },{"../eventemitter":10,"../util/constants":124,"../util/eventobserver":129,"../util/index":131,"../util/insightspublisher":132,"../util/log":135,"../util/movingaveragedelta":136,"../util/sid":143,"../util/twilio-video-errors":146,"./getCombinedConnectionStats":46,"./getturncredentials":47,"./makestat":48,"./mos":49,"./syntheticaudio":51,"./syntheticvideo":52,"./timer":53}],51:[function(require,module,exports){
9421
+ },{"../eventemitter":10,"../util/constants":125,"../util/eventobserver":130,"../util/index":132,"../util/insightspublisher":133,"../util/log":136,"../util/movingaveragedelta":137,"../util/sid":144,"../util/twilio-video-errors":147,"./getCombinedConnectionStats":47,"./getturncredentials":48,"./makestat":49,"./mos":50,"./syntheticaudio":52,"./syntheticvideo":53,"./timer":54}],52:[function(require,module,exports){
9137
9422
  "use strict";
9138
9423
  Object.defineProperty(exports, "__esModule", { value: true });
9139
9424
  exports.syntheticAudio = void 0;
@@ -9156,7 +9441,7 @@ function syntheticAudio() {
9156
9441
  }
9157
9442
  exports.syntheticAudio = syntheticAudio;
9158
9443
 
9159
- },{"../webaudio/audiocontext":152}],52:[function(require,module,exports){
9444
+ },{"../webaudio/audiocontext":153}],53:[function(require,module,exports){
9160
9445
  "use strict";
9161
9446
  Object.defineProperty(exports, "__esModule", { value: true });
9162
9447
  exports.syntheticVideo = void 0;
@@ -9190,7 +9475,7 @@ function syntheticVideo(_a) {
9190
9475
  }
9191
9476
  exports.syntheticVideo = syntheticVideo;
9192
9477
 
9193
- },{}],53:[function(require,module,exports){
9478
+ },{}],54:[function(require,module,exports){
9194
9479
  "use strict";
9195
9480
  Object.defineProperty(exports, "__esModule", { value: true });
9196
9481
  exports.Timer = void 0;
@@ -9220,7 +9505,7 @@ var Timer = /** @class */ (function () {
9220
9505
  }());
9221
9506
  exports.Timer = Timer;
9222
9507
 
9223
- },{}],54:[function(require,module,exports){
9508
+ },{}],55:[function(require,module,exports){
9224
9509
  'use strict';
9225
9510
  var __extends = (this && this.__extends) || (function () {
9226
9511
  var extendStatics = function (d, b) {
@@ -9321,7 +9606,7 @@ var QueueingEventEmitter = /** @class */ (function (_super) {
9321
9606
  }(EventEmitter));
9322
9607
  module.exports = QueueingEventEmitter;
9323
9608
 
9324
- },{"events":173}],55:[function(require,module,exports){
9609
+ },{"events":173}],56:[function(require,module,exports){
9325
9610
  'use strict';
9326
9611
  var __extends = (this && this.__extends) || (function () {
9327
9612
  var extendStatics = function (d, b) {
@@ -9602,7 +9887,7 @@ var RemoteParticipant = /** @class */ (function (_super) {
9602
9887
  */
9603
9888
  module.exports = RemoteParticipant;
9604
9889
 
9605
- },{"./participant":45}],56:[function(require,module,exports){
9890
+ },{"./participant":46}],57:[function(require,module,exports){
9606
9891
  'use strict';
9607
9892
  var __extends = (this && this.__extends) || (function () {
9608
9893
  var extendStatics = function (d, b) {
@@ -9643,7 +9928,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
9643
9928
  var EventEmitter = require('./eventemitter');
9644
9929
  var RemoteParticipant = require('./remoteparticipant');
9645
9930
  var StatsReport = require('./stats/statsreport');
9646
- var valueToJSON = require('./util').valueToJSON;
9931
+ var _a = require('./util'), flatMap = _a.flatMap, valueToJSON = _a.valueToJSON;
9647
9932
  var nInstances = 0;
9648
9933
  /**
9649
9934
  * A {@link Room} represents communication between you and one or more
@@ -9801,6 +10086,55 @@ var Room = /** @class */ (function (_super) {
9801
10086
  });
9802
10087
  });
9803
10088
  };
10089
+ /**
10090
+ * Restart the muted local media {@link Track}s and play inadvertently paused HTMLMediaElements
10091
+ * that are attached to local and remote media {@link Track}s. This method is useful mainly on
10092
+ * mobile browsers (Safari and Chrome on iOS), where there is a possibility that the muted local
10093
+ * media {@link Track}s are never unmuted and inadvertently paused HTMLMediaElements are never
10094
+ * played again, especially after handling an incoming phone call.
10095
+ * @returns {this}
10096
+ */
10097
+ Room.prototype.refreshInactiveMedia = function () {
10098
+ var localTrackPublications = this.localParticipant.tracks;
10099
+ var localMediaTracks = Array.from(localTrackPublications.values())
10100
+ .filter(function (_a) {
10101
+ var kind = _a.track.kind;
10102
+ return kind !== 'data';
10103
+ })
10104
+ .map(function (_a) {
10105
+ var track = _a.track;
10106
+ return track;
10107
+ });
10108
+ var remoteMediaTracks = flatMap(this.participants, function (participants) { return Array.from(participants.tracks.values()); })
10109
+ .filter(function (_a) {
10110
+ var track = _a.track;
10111
+ return track && track.kind !== 'data';
10112
+ })
10113
+ .map(function (_a) {
10114
+ var track = _a.track;
10115
+ return track;
10116
+ });
10117
+ var mediaTracks = localMediaTracks.concat(remoteMediaTracks);
10118
+ var unmuteEvent = new Event('unmute');
10119
+ localMediaTracks.forEach(function (_a) {
10120
+ var isMuted = _a.isMuted, mediaStreamTrack = _a.mediaStreamTrack;
10121
+ if (isMuted) {
10122
+ mediaStreamTrack.dispatchEvent(unmuteEvent);
10123
+ }
10124
+ });
10125
+ var pauseEvent = new Event('pause');
10126
+ mediaTracks.forEach(function (_a) {
10127
+ var attachments = _a._attachments, elShims = _a._elShims;
10128
+ return attachments.forEach(function (el) {
10129
+ var shim = elShims.get(el);
10130
+ var isInadvertentlyPaused = el.paused && shim && !shim.pausedIntentionally();
10131
+ if (isInadvertentlyPaused) {
10132
+ el.dispatchEvent(pauseEvent);
10133
+ }
10134
+ });
10135
+ });
10136
+ return this;
10137
+ };
9804
10138
  Room.prototype.toJSON = function () {
9805
10139
  return valueToJSON(this);
9806
10140
  };
@@ -10229,7 +10563,7 @@ function handleSignalingEvents(room, signaling) {
10229
10563
  }
10230
10564
  module.exports = Room;
10231
10565
 
10232
- },{"./eventemitter":10,"./remoteparticipant":55,"./stats/statsreport":115,"./util":131}],57:[function(require,module,exports){
10566
+ },{"./eventemitter":10,"./remoteparticipant":56,"./stats/statsreport":116,"./util":132}],58:[function(require,module,exports){
10233
10567
  /* eslint consistent-return:0 */
10234
10568
  'use strict';
10235
10569
  var __extends = (this && this.__extends) || (function () {
@@ -10399,7 +10733,7 @@ var Signaling = /** @class */ (function (_super) {
10399
10733
  }(StateMachine));
10400
10734
  module.exports = Signaling;
10401
10735
 
10402
- },{"../statemachine":87,"./participant":60,"./room":64}],58:[function(require,module,exports){
10736
+ },{"../statemachine":88,"./participant":61,"./room":65}],59:[function(require,module,exports){
10403
10737
  'use strict';
10404
10738
  var __extends = (this && this.__extends) || (function () {
10405
10739
  var extendStatics = function (d, b) {
@@ -10481,7 +10815,7 @@ var LocalParticipantSignaling = /** @class */ (function (_super) {
10481
10815
  }(ParticipantSignaling));
10482
10816
  module.exports = LocalParticipantSignaling;
10483
10817
 
10484
- },{"./participant":60}],59:[function(require,module,exports){
10818
+ },{"./participant":61}],60:[function(require,module,exports){
10485
10819
  'use strict';
10486
10820
  var __extends = (this && this.__extends) || (function () {
10487
10821
  var extendStatics = function (d, b) {
@@ -10612,7 +10946,7 @@ function setError(publication, error) {
10612
10946
  }
10613
10947
  module.exports = LocalTrackPublicationSignaling;
10614
10948
 
10615
- },{"./track":65}],60:[function(require,module,exports){
10949
+ },{"./track":66}],61:[function(require,module,exports){
10616
10950
  'use strict';
10617
10951
  var __extends = (this && this.__extends) || (function () {
10618
10952
  var extendStatics = function (d, b) {
@@ -10837,7 +11171,7 @@ var ParticipantSignaling = /** @class */ (function (_super) {
10837
11171
  */
10838
11172
  module.exports = ParticipantSignaling;
10839
11173
 
10840
- },{"../statemachine":87,"../stats/networkqualitystats":102}],61:[function(require,module,exports){
11174
+ },{"../statemachine":88,"../stats/networkqualitystats":103}],62:[function(require,module,exports){
10841
11175
  'use strict';
10842
11176
  var __extends = (this && this.__extends) || (function () {
10843
11177
  var extendStatics = function (d, b) {
@@ -10910,7 +11244,7 @@ var RecordingSignaling = /** @class */ (function (_super) {
10910
11244
  */
10911
11245
  module.exports = RecordingSignaling;
10912
11246
 
10913
- },{"events":173}],62:[function(require,module,exports){
11247
+ },{"events":173}],63:[function(require,module,exports){
10914
11248
  'use strict';
10915
11249
  var __extends = (this && this.__extends) || (function () {
10916
11250
  var extendStatics = function (d, b) {
@@ -10950,7 +11284,7 @@ var RemoteParticipantSignaling = /** @class */ (function (_super) {
10950
11284
  }(ParticipantSignaling));
10951
11285
  module.exports = RemoteParticipantSignaling;
10952
11286
 
10953
- },{"./participant":60}],63:[function(require,module,exports){
11287
+ },{"./participant":61}],64:[function(require,module,exports){
10954
11288
  'use strict';
10955
11289
  var __extends = (this && this.__extends) || (function () {
10956
11290
  var extendStatics = function (d, b) {
@@ -11055,7 +11389,7 @@ var RemoteTrackPublicationSignaling = /** @class */ (function (_super) {
11055
11389
  }(TrackSignaling));
11056
11390
  module.exports = RemoteTrackPublicationSignaling;
11057
11391
 
11058
- },{"./track":65}],64:[function(require,module,exports){
11392
+ },{"./track":66}],65:[function(require,module,exports){
11059
11393
  'use strict';
11060
11394
  var __extends = (this && this.__extends) || (function () {
11061
11395
  var extendStatics = function (d, b) {
@@ -11336,7 +11670,7 @@ function maybeUpdateState(roomSignaling) {
11336
11670
  }
11337
11671
  module.exports = RoomSignaling;
11338
11672
 
11339
- },{"../statemachine":87,"../util":131,"../util/constants":124,"../util/log":135,"../util/timeout":145,"../util/twilio-video-errors":146,"./recording":61}],65:[function(require,module,exports){
11673
+ },{"../statemachine":88,"../util":132,"../util/constants":125,"../util/log":136,"../util/timeout":146,"../util/twilio-video-errors":147,"./recording":62}],66:[function(require,module,exports){
11340
11674
  'use strict';
11341
11675
  var __extends = (this && this.__extends) || (function () {
11342
11676
  var extendStatics = function (d, b) {
@@ -11519,7 +11853,7 @@ var TrackSignaling = /** @class */ (function (_super) {
11519
11853
  */
11520
11854
  module.exports = TrackSignaling;
11521
11855
 
11522
- },{"events":173}],66:[function(require,module,exports){
11856
+ },{"events":173}],67:[function(require,module,exports){
11523
11857
  'use strict';
11524
11858
  var CancelablePromise = require('../../util/cancelablepromise');
11525
11859
  var DefaultPeerConnectionManager = require('./peerconnectionmanager');
@@ -11636,7 +11970,7 @@ function createCancelableRoomSignalingPromise(token, wsServer, localParticipant,
11636
11970
  }
11637
11971
  module.exports = createCancelableRoomSignalingPromise;
11638
11972
 
11639
- },{"../../util":131,"../../util/cancelablepromise":123,"../../util/twilio-video-errors":146,"./peerconnectionmanager":77,"./room":83,"./twilioconnectiontransport":86}],67:[function(require,module,exports){
11973
+ },{"../../util":132,"../../util/cancelablepromise":124,"../../util/twilio-video-errors":147,"./peerconnectionmanager":78,"./room":84,"./twilioconnectiontransport":87}],68:[function(require,module,exports){
11640
11974
  'use strict';
11641
11975
  var __extends = (this && this.__extends) || (function () {
11642
11976
  var extendStatics = function (d, b) {
@@ -11714,7 +12048,7 @@ var DominantSpeakerSignaling = /** @class */ (function (_super) {
11714
12048
  */
11715
12049
  module.exports = DominantSpeakerSignaling;
11716
12050
 
11717
- },{"./mediasignaling":73}],68:[function(require,module,exports){
12051
+ },{"./mediasignaling":74}],69:[function(require,module,exports){
11718
12052
  'use strict';
11719
12053
  var Filter = require('../../util/filter');
11720
12054
  /**
@@ -11782,7 +12116,7 @@ var IceBox = /** @class */ (function () {
11782
12116
  }());
11783
12117
  module.exports = IceBox;
11784
12118
 
11785
- },{"../../util/filter":130}],69:[function(require,module,exports){
12119
+ },{"../../util/filter":131}],70:[function(require,module,exports){
11786
12120
  'use strict';
11787
12121
  var _a = require('../../util/constants'), ICE_ACTIVITY_CHECK_PERIOD_MS = _a.ICE_ACTIVITY_CHECK_PERIOD_MS, ICE_INACTIVITY_THRESHOLD_MS = _a.ICE_INACTIVITY_THRESHOLD_MS;
11788
12122
  /**
@@ -11915,7 +12249,7 @@ var IceConnectionMonitor = /** @class */ (function () {
11915
12249
  }());
11916
12250
  module.exports = IceConnectionMonitor;
11917
12251
 
11918
- },{"../../util/constants":124}],70:[function(require,module,exports){
12252
+ },{"../../util/constants":125}],71:[function(require,module,exports){
11919
12253
  'use strict';
11920
12254
  var __extends = (this && this.__extends) || (function () {
11921
12255
  var extendStatics = function (d, b) {
@@ -11980,7 +12314,7 @@ var SignalingV2 = /** @class */ (function (_super) {
11980
12314
  }(Signaling));
11981
12315
  module.exports = SignalingV2;
11982
12316
 
11983
- },{"../":57,"./cancelableroomsignalingpromise":66,"./localparticipant":71}],71:[function(require,module,exports){
12317
+ },{"../":58,"./cancelableroomsignalingpromise":67,"./localparticipant":72}],72:[function(require,module,exports){
11984
12318
  'use strict';
11985
12319
  var __extends = (this && this.__extends) || (function () {
11986
12320
  var extendStatics = function (d, b) {
@@ -12320,7 +12654,7 @@ var LocalParticipantV2 = /** @class */ (function (_super) {
12320
12654
  */
12321
12655
  module.exports = LocalParticipantV2;
12322
12656
 
12323
- },{"../../util":131,"../../util/constants":124,"../../util/log":135,"../localparticipant":58,"./localtrackpublication":72}],72:[function(require,module,exports){
12657
+ },{"../../util":132,"../../util/constants":125,"../../util/log":136,"../localparticipant":59,"./localtrackpublication":73}],73:[function(require,module,exports){
12324
12658
  'use strict';
12325
12659
  var __extends = (this && this.__extends) || (function () {
12326
12660
  var extendStatics = function (d, b) {
@@ -12447,7 +12781,7 @@ var LocalTrackPublicationV2 = /** @class */ (function (_super) {
12447
12781
  */
12448
12782
  module.exports = LocalTrackPublicationV2;
12449
12783
 
12450
- },{"../../util/twilio-video-errors":146,"../../util/twiliowarning":148,"../localtrackpublication":59}],73:[function(require,module,exports){
12784
+ },{"../../util/twilio-video-errors":147,"../../util/twiliowarning":149,"../localtrackpublication":60}],74:[function(require,module,exports){
12451
12785
  /* eslint callback-return:0 */
12452
12786
  'use strict';
12453
12787
  var __extends = (this && this.__extends) || (function () {
@@ -12544,7 +12878,7 @@ var MediaSignaling = /** @class */ (function (_super) {
12544
12878
  }(EventEmitter));
12545
12879
  module.exports = MediaSignaling;
12546
12880
 
12547
- },{"events":173}],74:[function(require,module,exports){
12881
+ },{"events":173}],75:[function(require,module,exports){
12548
12882
  /* eslint callback-return:0 */
12549
12883
  'use strict';
12550
12884
  var __extends = (this && this.__extends) || (function () {
@@ -12703,7 +13037,7 @@ function next(monitor) {
12703
13037
  */
12704
13038
  module.exports = NetworkQualityMonitor;
12705
13039
 
12706
- },{"../../stats/peerconnectionreportfactory":105,"events":173}],75:[function(require,module,exports){
13040
+ },{"../../stats/peerconnectionreportfactory":106,"events":173}],76:[function(require,module,exports){
12707
13041
  'use strict';
12708
13042
  var __extends = (this && this.__extends) || (function () {
12709
13043
  var extendStatics = function (d, b) {
@@ -12968,7 +13302,7 @@ function createNetworkQualityInputsMessage(networkQualityInputs, networkQualityR
12968
13302
  }
12969
13303
  module.exports = NetworkQualitySignaling;
12970
13304
 
12971
- },{"../../util/asyncvar":120,"../../util/timeout":145,"./mediasignaling":73}],76:[function(require,module,exports){
13305
+ },{"../../util/asyncvar":121,"../../util/timeout":146,"./mediasignaling":74}],77:[function(require,module,exports){
12972
13306
  'use strict';
12973
13307
  var __extends = (this && this.__extends) || (function () {
12974
13308
  var extendStatics = function (d, b) {
@@ -14828,7 +15162,7 @@ function setMaxBitrate(params, maxBitrate) {
14828
15162
  }
14829
15163
  module.exports = PeerConnectionV2;
14830
15164
 
14831
- },{"../../data/receiver":5,"../../media/track/receiver":29,"../../statemachine":87,"../../util":131,"../../util/backoff":121,"../../util/constants":124,"../../util/log":135,"../../util/sdp":139,"../../util/sdp/issue8329":140,"../../util/sdp/trackmatcher":142,"../../util/timeout":145,"../../util/twilio-video-errors":146,"../../webrtc":157,"../../webrtc/util":170,"./icebox":68,"./iceconnectionmonitor.js":69}],77:[function(require,module,exports){
15165
+ },{"../../data/receiver":5,"../../media/track/receiver":30,"../../statemachine":88,"../../util":132,"../../util/backoff":122,"../../util/constants":125,"../../util/log":136,"../../util/sdp":140,"../../util/sdp/issue8329":141,"../../util/sdp/trackmatcher":143,"../../util/timeout":146,"../../util/twilio-video-errors":147,"../../webrtc":158,"../../webrtc/util":170,"./icebox":69,"./iceconnectionmonitor.js":70}],78:[function(require,module,exports){
14832
15166
  'use strict';
14833
15167
  var __extends = (this && this.__extends) || (function () {
14834
15168
  var extendStatics = function (d, b) {
@@ -15396,7 +15730,7 @@ function updateConnectionState(pcm) {
15396
15730
  }
15397
15731
  module.exports = PeerConnectionManager;
15398
15732
 
15399
- },{"../../media/track/sender":38,"../../queueingeventemitter":54,"../../util":131,"../../util/twilio-video-errors":146,"../../webaudio/audiocontext":152,"../../webrtc/util":170,"./peerconnection":76}],78:[function(require,module,exports){
15733
+ },{"../../media/track/sender":39,"../../queueingeventemitter":55,"../../util":132,"../../util/twilio-video-errors":147,"../../webaudio/audiocontext":153,"../../webrtc/util":170,"./peerconnection":77}],79:[function(require,module,exports){
15400
15734
  /* eslint callback-return:0 */
15401
15735
  'use strict';
15402
15736
  var __extends = (this && this.__extends) || (function () {
@@ -15482,7 +15816,7 @@ var PublisherHintsSignaling = /** @class */ (function (_super) {
15482
15816
  }(MediaSignaling));
15483
15817
  module.exports = PublisherHintsSignaling;
15484
15818
 
15485
- },{"./mediasignaling":73}],79:[function(require,module,exports){
15819
+ },{"./mediasignaling":74}],80:[function(require,module,exports){
15486
15820
  'use strict';
15487
15821
  var __extends = (this && this.__extends) || (function () {
15488
15822
  var extendStatics = function (d, b) {
@@ -15542,7 +15876,7 @@ var RecordingV2 = /** @class */ (function (_super) {
15542
15876
  */
15543
15877
  module.exports = RecordingV2;
15544
15878
 
15545
- },{"../recording":61}],80:[function(require,module,exports){
15879
+ },{"../recording":62}],81:[function(require,module,exports){
15546
15880
  'use strict';
15547
15881
  var __extends = (this && this.__extends) || (function () {
15548
15882
  var extendStatics = function (d, b) {
@@ -15662,7 +15996,7 @@ var RemoteParticipantV2 = /** @class */ (function (_super) {
15662
15996
  }(RemoteParticipantSignaling));
15663
15997
  module.exports = RemoteParticipantV2;
15664
15998
 
15665
- },{"../remoteparticipant":62,"./remotetrackpublication":81}],81:[function(require,module,exports){
15999
+ },{"../remoteparticipant":63,"./remotetrackpublication":82}],82:[function(require,module,exports){
15666
16000
  'use strict';
15667
16001
  var __extends = (this && this.__extends) || (function () {
15668
16002
  var extendStatics = function (d, b) {
@@ -15716,7 +16050,7 @@ var RemoteTrackPublicationV2 = /** @class */ (function (_super) {
15716
16050
  */
15717
16051
  module.exports = RemoteTrackPublicationV2;
15718
16052
 
15719
- },{"../remotetrackpublication":63}],82:[function(require,module,exports){
16053
+ },{"../remotetrackpublication":64}],83:[function(require,module,exports){
15720
16054
  /* eslint callback-return:0 */
15721
16055
  'use strict';
15722
16056
  var __extends = (this && this.__extends) || (function () {
@@ -15867,7 +16201,7 @@ var RenderHintsSignaling = /** @class */ (function (_super) {
15867
16201
  }(MediaSignaling));
15868
16202
  module.exports = RenderHintsSignaling;
15869
16203
 
15870
- },{"../../util":131,"../../util/timeout":145,"./mediasignaling":73}],83:[function(require,module,exports){
16204
+ },{"../../util":132,"../../util/timeout":146,"./mediasignaling":74}],84:[function(require,module,exports){
15871
16205
  /* eslint-disable no-console */
15872
16206
  'use strict';
15873
16207
  var __extends = (this && this.__extends) || (function () {
@@ -16725,7 +17059,7 @@ function replaceNullsWithDefaults(activeIceCandidatePair, peerConnectionId) {
16725
17059
  }
16726
17060
  module.exports = RoomV2;
16727
17061
 
16728
- },{"../../stats/statsreport":115,"../../util":131,"../../util/movingaveragedelta":136,"../../util/twilio-video-errors":146,"../room":64,"./dominantspeakersignaling":67,"./networkqualitymonitor":74,"./networkqualitysignaling":75,"./publisherhintsignaling.js":78,"./recording":79,"./remoteparticipant":80,"./renderhintssignaling":82,"./trackprioritysignaling":84,"./trackswitchoffsignaling":85}],84:[function(require,module,exports){
17062
+ },{"../../stats/statsreport":116,"../../util":132,"../../util/movingaveragedelta":137,"../../util/twilio-video-errors":147,"../room":65,"./dominantspeakersignaling":68,"./networkqualitymonitor":75,"./networkqualitysignaling":76,"./publisherhintsignaling.js":79,"./recording":80,"./remoteparticipant":81,"./renderhintssignaling":83,"./trackprioritysignaling":85,"./trackswitchoffsignaling":86}],85:[function(require,module,exports){
16729
17063
  'use strict';
16730
17064
  var __extends = (this && this.__extends) || (function () {
16731
17065
  var extendStatics = function (d, b) {
@@ -16791,7 +17125,7 @@ var TrackPrioritySignaling = /** @class */ (function (_super) {
16791
17125
  }(MediaSignaling));
16792
17126
  module.exports = TrackPrioritySignaling;
16793
17127
 
16794
- },{"./mediasignaling":73}],85:[function(require,module,exports){
17128
+ },{"./mediasignaling":74}],86:[function(require,module,exports){
16795
17129
  'use strict';
16796
17130
  var __extends = (this && this.__extends) || (function () {
16797
17131
  var extendStatics = function (d, b) {
@@ -16849,7 +17183,7 @@ var TrackSwitchOffSignaling = /** @class */ (function (_super) {
16849
17183
  */
16850
17184
  module.exports = TrackSwitchOffSignaling;
16851
17185
 
16852
- },{"./mediasignaling":73}],86:[function(require,module,exports){
17186
+ },{"./mediasignaling":74}],87:[function(require,module,exports){
16853
17187
  'use strict';
16854
17188
  var __extends = (this && this.__extends) || (function () {
16855
17189
  var extendStatics = function (d, b) {
@@ -17436,7 +17770,7 @@ function setupTransport(transport) {
17436
17770
  }
17437
17771
  module.exports = TwilioConnectionTransport;
17438
17772
 
17439
- },{"../../statemachine":87,"../../twilioconnection":119,"../../util":131,"../../util/backoff":121,"../../util/constants":124,"../../util/timeout":145,"../../util/twilio-video-errors":146}],87:[function(require,module,exports){
17773
+ },{"../../statemachine":88,"../../twilioconnection":120,"../../util":132,"../../util/backoff":122,"../../util/constants":125,"../../util/timeout":146,"../../util/twilio-video-errors":147}],88:[function(require,module,exports){
17440
17774
  'use strict';
17441
17775
  var __extends = (this && this.__extends) || (function () {
17442
17776
  var extendStatics = function (d, b) {
@@ -17882,7 +18216,7 @@ function createUnreachableError(here, there) {
17882
18216
  }
17883
18217
  module.exports = StateMachine;
17884
18218
 
17885
- },{"./util":131,"events":173}],88:[function(require,module,exports){
18219
+ },{"./util":132,"events":173}],89:[function(require,module,exports){
17886
18220
  /* eslint no-undefined:0 */
17887
18221
  'use strict';
17888
18222
  /**
@@ -17895,7 +18229,7 @@ function average(xs) {
17895
18229
  }
17896
18230
  module.exports = average;
17897
18231
 
17898
- },{}],89:[function(require,module,exports){
18232
+ },{}],90:[function(require,module,exports){
17899
18233
  'use strict';
17900
18234
  /**
17901
18235
  * @property {number} [availableSend] - bps (undefined in Firefox)
@@ -17953,7 +18287,7 @@ var IceReport = /** @class */ (function () {
17953
18287
  }());
17954
18288
  module.exports = IceReport;
17955
18289
 
17956
- },{}],90:[function(require,module,exports){
18290
+ },{}],91:[function(require,module,exports){
17957
18291
  'use strict';
17958
18292
  var IceReport = require('./icereport');
17959
18293
  /**
@@ -17998,7 +18332,7 @@ var IceReportFactory = /** @class */ (function () {
17998
18332
  }());
17999
18333
  module.exports = IceReportFactory;
18000
18334
 
18001
- },{"./icereport":89}],91:[function(require,module,exports){
18335
+ },{"./icereport":90}],92:[function(require,module,exports){
18002
18336
  'use strict';
18003
18337
  var __extends = (this && this.__extends) || (function () {
18004
18338
  var extendStatics = function (d, b) {
@@ -18056,7 +18390,7 @@ var LocalAudioTrackStats = /** @class */ (function (_super) {
18056
18390
  */
18057
18391
  module.exports = LocalAudioTrackStats;
18058
18392
 
18059
- },{"./localtrackstats":92}],92:[function(require,module,exports){
18393
+ },{"./localtrackstats":93}],93:[function(require,module,exports){
18060
18394
  'use strict';
18061
18395
  var __extends = (this && this.__extends) || (function () {
18062
18396
  var extendStatics = function (d, b) {
@@ -18116,7 +18450,7 @@ var LocalTrackStats = /** @class */ (function (_super) {
18116
18450
  }(TrackStats));
18117
18451
  module.exports = LocalTrackStats;
18118
18452
 
18119
- },{"./trackstats":117}],93:[function(require,module,exports){
18453
+ },{"./trackstats":118}],94:[function(require,module,exports){
18120
18454
  'use strict';
18121
18455
  var __extends = (this && this.__extends) || (function () {
18122
18456
  var extendStatics = function (d, b) {
@@ -18209,7 +18543,7 @@ var LocalVideoTrackStats = /** @class */ (function (_super) {
18209
18543
  }(LocalTrackStats));
18210
18544
  module.exports = LocalVideoTrackStats;
18211
18545
 
18212
- },{"./localtrackstats":92}],94:[function(require,module,exports){
18546
+ },{"./localtrackstats":93}],95:[function(require,module,exports){
18213
18547
  'use strict';
18214
18548
  var __extends = (this && this.__extends) || (function () {
18215
18549
  var extendStatics = function (d, b) {
@@ -18243,7 +18577,7 @@ var NetworkQualityAudioStats = /** @class */ (function (_super) {
18243
18577
  }(NetworkQualityMediaStats));
18244
18578
  module.exports = NetworkQualityAudioStats;
18245
18579
 
18246
- },{"./networkqualitymediastats":98}],95:[function(require,module,exports){
18580
+ },{"./networkqualitymediastats":99}],96:[function(require,module,exports){
18247
18581
  'use strict';
18248
18582
  /**
18249
18583
  * Bandwidth network quality statistics.
@@ -18277,7 +18611,7 @@ var NetworkQualityBandwidthStats = /** @class */ (function () {
18277
18611
  }());
18278
18612
  module.exports = NetworkQualityBandwidthStats;
18279
18613
 
18280
- },{}],96:[function(require,module,exports){
18614
+ },{}],97:[function(require,module,exports){
18281
18615
  'use strict';
18282
18616
  /**
18283
18617
  * Fraction lost network quality statistics.
@@ -18306,7 +18640,7 @@ var NetworkQualityFractionLostStats = /** @class */ (function () {
18306
18640
  }());
18307
18641
  module.exports = NetworkQualityFractionLostStats;
18308
18642
 
18309
- },{}],97:[function(require,module,exports){
18643
+ },{}],98:[function(require,module,exports){
18310
18644
  'use strict';
18311
18645
  /**
18312
18646
  * Latency network quality statistics.
@@ -18340,7 +18674,7 @@ var NetworkQualityLatencyStats = /** @class */ (function () {
18340
18674
  }());
18341
18675
  module.exports = NetworkQualityLatencyStats;
18342
18676
 
18343
- },{}],98:[function(require,module,exports){
18677
+ },{}],99:[function(require,module,exports){
18344
18678
  'use strict';
18345
18679
  var NetworkQualitySendStats = require('./networkqualitysendstats');
18346
18680
  var NetworkQualityRecvStats = require('./networkqualityrecvstats');
@@ -18387,7 +18721,7 @@ var NetworkQualityMediaStats = /** @class */ (function () {
18387
18721
  }());
18388
18722
  module.exports = NetworkQualityMediaStats;
18389
18723
 
18390
- },{"./networkqualityrecvstats":99,"./networkqualitysendstats":101}],99:[function(require,module,exports){
18724
+ },{"./networkqualityrecvstats":100,"./networkqualitysendstats":102}],100:[function(require,module,exports){
18391
18725
  'use strict';
18392
18726
  var __extends = (this && this.__extends) || (function () {
18393
18727
  var extendStatics = function (d, b) {
@@ -18422,7 +18756,7 @@ var NetworkQualityRecvStats = /** @class */ (function (_super) {
18422
18756
  }(NetworkQualitySendOrRecvStats));
18423
18757
  module.exports = NetworkQualityRecvStats;
18424
18758
 
18425
- },{"./networkqualitysendorrecvstats":100}],100:[function(require,module,exports){
18759
+ },{"./networkqualitysendorrecvstats":101}],101:[function(require,module,exports){
18426
18760
  'use strict';
18427
18761
  var NetworkQualityBandwidthStats = require('./networkqualitybandwidthstats');
18428
18762
  var NetworkQualityFractionLostStats = require('./networkqualityfractionloststats');
@@ -18462,7 +18796,7 @@ var NetworkQualitySendOrRecvStats = /** @class */ (function () {
18462
18796
  }());
18463
18797
  module.exports = NetworkQualitySendOrRecvStats;
18464
18798
 
18465
- },{"./networkqualitybandwidthstats":95,"./networkqualityfractionloststats":96,"./networkqualitylatencystats":97}],101:[function(require,module,exports){
18799
+ },{"./networkqualitybandwidthstats":96,"./networkqualityfractionloststats":97,"./networkqualitylatencystats":98}],102:[function(require,module,exports){
18466
18800
  'use strict';
18467
18801
  var __extends = (this && this.__extends) || (function () {
18468
18802
  var extendStatics = function (d, b) {
@@ -18497,7 +18831,7 @@ var NetworkQualitySendStats = /** @class */ (function (_super) {
18497
18831
  }(NetworkQualitySendOrRecvStats));
18498
18832
  module.exports = NetworkQualitySendStats;
18499
18833
 
18500
- },{"./networkqualitysendorrecvstats":100}],102:[function(require,module,exports){
18834
+ },{"./networkqualitysendorrecvstats":101}],103:[function(require,module,exports){
18501
18835
  'use strict';
18502
18836
  var NetworkQualityAudioStats = require('./networkqualityaudiostats');
18503
18837
  var NetworkQualityVideoStats = require('./networkqualityvideostats');
@@ -18537,7 +18871,7 @@ var NetworkQualityStats = /** @class */ (function () {
18537
18871
  }());
18538
18872
  module.exports = NetworkQualityStats;
18539
18873
 
18540
- },{"./networkqualityaudiostats":94,"./networkqualityvideostats":103}],103:[function(require,module,exports){
18874
+ },{"./networkqualityaudiostats":95,"./networkqualityvideostats":104}],104:[function(require,module,exports){
18541
18875
  'use strict';
18542
18876
  var __extends = (this && this.__extends) || (function () {
18543
18877
  var extendStatics = function (d, b) {
@@ -18571,7 +18905,7 @@ var NetworkQualityVideoStats = /** @class */ (function (_super) {
18571
18905
  }(NetworkQualityMediaStats));
18572
18906
  module.exports = NetworkQualityVideoStats;
18573
18907
 
18574
- },{"./networkqualitymediastats":98}],104:[function(require,module,exports){
18908
+ },{"./networkqualitymediastats":99}],105:[function(require,module,exports){
18575
18909
  'use strict';
18576
18910
  var ReceiverReport = require('./receiverreport');
18577
18911
  var SenderReport = require('./senderreport');
@@ -18649,7 +18983,7 @@ var PeerConnectionReport = /** @class */ (function () {
18649
18983
  }());
18650
18984
  module.exports = PeerConnectionReport;
18651
18985
 
18652
- },{"./receiverreport":106,"./senderreport":113}],105:[function(require,module,exports){
18986
+ },{"./receiverreport":107,"./senderreport":114}],106:[function(require,module,exports){
18653
18987
  'use strict';
18654
18988
  var __read = (this && this.__read) || function (o, n) {
18655
18989
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -19079,7 +19413,7 @@ function updateChrome(factory) {
19079
19413
  }
19080
19414
  module.exports = PeerConnectionReportFactory;
19081
19415
 
19082
- },{"../webrtc/util":170,"./icereportfactory":90,"./peerconnectionreport":104,"./receiverreportfactory":107,"./senderreportfactory":114}],106:[function(require,module,exports){
19416
+ },{"../webrtc/util":170,"./icereportfactory":91,"./peerconnectionreport":105,"./receiverreportfactory":108,"./senderreportfactory":115}],107:[function(require,module,exports){
19083
19417
  'use strict';
19084
19418
  var __extends = (this && this.__extends) || (function () {
19085
19419
  var extendStatics = function (d, b) {
@@ -19205,7 +19539,7 @@ var ReceiverReport = /** @class */ (function (_super) {
19205
19539
  }(SenderOrReceiverReport));
19206
19540
  module.exports = ReceiverReport;
19207
19541
 
19208
- },{"./average":88,"./senderorreceiverreport":111,"./sum":116}],107:[function(require,module,exports){
19542
+ },{"./average":89,"./senderorreceiverreport":112,"./sum":117}],108:[function(require,module,exports){
19209
19543
  'use strict';
19210
19544
  var __extends = (this && this.__extends) || (function () {
19211
19545
  var extendStatics = function (d, b) {
@@ -19264,7 +19598,7 @@ var ReceiverReportFactory = /** @class */ (function (_super) {
19264
19598
  }(SenderOrReceiverReportFactory));
19265
19599
  module.exports = ReceiverReportFactory;
19266
19600
 
19267
- },{"./receiverreport":106,"./senderorreceiverreportfactory":112}],108:[function(require,module,exports){
19601
+ },{"./receiverreport":107,"./senderorreceiverreportfactory":113}],109:[function(require,module,exports){
19268
19602
  'use strict';
19269
19603
  var __extends = (this && this.__extends) || (function () {
19270
19604
  var extendStatics = function (d, b) {
@@ -19316,7 +19650,7 @@ var RemoteAudioTrackStats = /** @class */ (function (_super) {
19316
19650
  }(RemoteTrackStats));
19317
19651
  module.exports = RemoteAudioTrackStats;
19318
19652
 
19319
- },{"./remotetrackstats":109}],109:[function(require,module,exports){
19653
+ },{"./remotetrackstats":110}],110:[function(require,module,exports){
19320
19654
  'use strict';
19321
19655
  var __extends = (this && this.__extends) || (function () {
19322
19656
  var extendStatics = function (d, b) {
@@ -19368,7 +19702,7 @@ var RemoteTrackStats = /** @class */ (function (_super) {
19368
19702
  }(TrackStats));
19369
19703
  module.exports = RemoteTrackStats;
19370
19704
 
19371
- },{"./trackstats":117}],110:[function(require,module,exports){
19705
+ },{"./trackstats":118}],111:[function(require,module,exports){
19372
19706
  'use strict';
19373
19707
  var __extends = (this && this.__extends) || (function () {
19374
19708
  var extendStatics = function (d, b) {
@@ -19433,7 +19767,7 @@ var RemoteVideoTrackStats = /** @class */ (function (_super) {
19433
19767
  }(RemoteTrackStats));
19434
19768
  module.exports = RemoteVideoTrackStats;
19435
19769
 
19436
- },{"./remotetrackstats":109}],111:[function(require,module,exports){
19770
+ },{"./remotetrackstats":110}],112:[function(require,module,exports){
19437
19771
  'use strict';
19438
19772
  /**
19439
19773
  * @property {StatsId} id
@@ -19467,7 +19801,7 @@ var SenderOrReceiverReport = /** @class */ (function () {
19467
19801
  }());
19468
19802
  module.exports = SenderOrReceiverReport;
19469
19803
 
19470
- },{}],112:[function(require,module,exports){
19804
+ },{}],113:[function(require,module,exports){
19471
19805
  'use strict';
19472
19806
  /**
19473
19807
  * @property {StatsId} id
@@ -19503,7 +19837,7 @@ var SenderOrReceiverReportFactory = /** @class */ (function () {
19503
19837
  }());
19504
19838
  module.exports = SenderOrReceiverReportFactory;
19505
19839
 
19506
- },{}],113:[function(require,module,exports){
19840
+ },{}],114:[function(require,module,exports){
19507
19841
  /* eslint no-undefined:0 */
19508
19842
  'use strict';
19509
19843
  var __extends = (this && this.__extends) || (function () {
@@ -19591,7 +19925,7 @@ var SenderReport = /** @class */ (function (_super) {
19591
19925
  }(SenderOrReceiverReport));
19592
19926
  module.exports = SenderReport;
19593
19927
 
19594
- },{"./average":88,"./senderorreceiverreport":111,"./sum":116}],114:[function(require,module,exports){
19928
+ },{"./average":89,"./senderorreceiverreport":112,"./sum":117}],115:[function(require,module,exports){
19595
19929
  'use strict';
19596
19930
  var __extends = (this && this.__extends) || (function () {
19597
19931
  var extendStatics = function (d, b) {
@@ -19650,7 +19984,7 @@ var SenderReportFactory = /** @class */ (function (_super) {
19650
19984
  }(SenderOrReceiverReportFactory));
19651
19985
  module.exports = SenderReportFactory;
19652
19986
 
19653
- },{"./senderorreceiverreportfactory":112,"./senderreport":113}],115:[function(require,module,exports){
19987
+ },{"./senderorreceiverreportfactory":113,"./senderreport":114}],116:[function(require,module,exports){
19654
19988
  'use strict';
19655
19989
  var LocalAudioTrackStats = require('./localaudiotrackstats');
19656
19990
  var LocalVideoTrackStats = require('./localvideotrackstats');
@@ -19701,7 +20035,7 @@ var StatsReport = /** @class */ (function () {
19701
20035
  }());
19702
20036
  module.exports = StatsReport;
19703
20037
 
19704
- },{"./localaudiotrackstats":91,"./localvideotrackstats":93,"./remoteaudiotrackstats":108,"./remotevideotrackstats":110}],116:[function(require,module,exports){
20038
+ },{"./localaudiotrackstats":92,"./localvideotrackstats":94,"./remoteaudiotrackstats":109,"./remotevideotrackstats":111}],117:[function(require,module,exports){
19705
20039
  'use strict';
19706
20040
  /**
19707
20041
  * @param {Array<number|undefined>} xs
@@ -19712,7 +20046,7 @@ function sum(xs) {
19712
20046
  }
19713
20047
  module.exports = sum;
19714
20048
 
19715
- },{}],117:[function(require,module,exports){
20049
+ },{}],118:[function(require,module,exports){
19716
20050
  'use strict';
19717
20051
  /**
19718
20052
  * Statistics for a {@link Track}.
@@ -19771,7 +20105,7 @@ var TrackStats = /** @class */ (function () {
19771
20105
  }());
19772
20106
  module.exports = TrackStats;
19773
20107
 
19774
- },{}],118:[function(require,module,exports){
20108
+ },{}],119:[function(require,module,exports){
19775
20109
  'use strict';
19776
20110
  var __extends = (this && this.__extends) || (function () {
19777
20111
  var extendStatics = function (d, b) {
@@ -19788,11 +20122,11 @@ var __extends = (this && this.__extends) || (function () {
19788
20122
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19789
20123
  };
19790
20124
  })();
19791
- var EventEmitter = require('events').EventEmitter;
20125
+ var QueueingEventEmitter = require('./queueingeventemitter');
19792
20126
  /**
19793
20127
  * A {@link TrackTransceiver} represents either one or more local RTCRtpSenders
19794
20128
  * or RTCDataChannels, or a single RTCRtpReceiver or remote RTCDataChannel.
19795
- * @extends EventEmitter
20129
+ * @extends QueueingEventEmitter
19796
20130
  * @property {Track.ID} id
19797
20131
  * @property {Track.kind} kind
19798
20132
  */
@@ -19826,14 +20160,14 @@ var TrackTransceiver = /** @class */ (function (_super) {
19826
20160
  this.emit('stopped');
19827
20161
  };
19828
20162
  return TrackTransceiver;
19829
- }(EventEmitter));
20163
+ }(QueueingEventEmitter));
19830
20164
  /**
19831
20165
  * The {@link TrackTransceiver} was stopped.
19832
20166
  * @event TrackTransceiver#stopped
19833
20167
  */
19834
20168
  module.exports = TrackTransceiver;
19835
20169
 
19836
- },{"events":173}],119:[function(require,module,exports){
20170
+ },{"./queueingeventemitter":55}],120:[function(require,module,exports){
19837
20171
  'use strict';
19838
20172
  var __extends = (this && this.__extends) || (function () {
19839
20173
  var extendStatics = function (d, b) {
@@ -20486,7 +20820,7 @@ TwilioConnection.CloseReason = CloseReason;
20486
20820
  */
20487
20821
  module.exports = TwilioConnection;
20488
20822
 
20489
- },{"./statemachine":87,"./util":131,"./util/log":135,"./util/networkmonitor":137,"./util/timeout":145,"ws":175}],120:[function(require,module,exports){
20823
+ },{"./statemachine":88,"./util":132,"./util/log":136,"./util/networkmonitor":138,"./util/timeout":146,"ws":175}],121:[function(require,module,exports){
20490
20824
  'use strict';
20491
20825
  var defer = require('./').defer;
20492
20826
  /**
@@ -20551,7 +20885,7 @@ var AsyncVar = /** @class */ (function () {
20551
20885
  }());
20552
20886
  module.exports = AsyncVar;
20553
20887
 
20554
- },{"./":131}],121:[function(require,module,exports){
20888
+ },{"./":132}],122:[function(require,module,exports){
20555
20889
  /**
20556
20890
  * Expose `Backoff`.
20557
20891
  */
@@ -20635,7 +20969,7 @@ var Backoff = /** @class */ (function () {
20635
20969
  }());
20636
20970
  module.exports = Backoff;
20637
20971
 
20638
- },{}],122:[function(require,module,exports){
20972
+ },{}],123:[function(require,module,exports){
20639
20973
  /* globals chrome, navigator */
20640
20974
  'use strict';
20641
20975
  var __read = (this && this.__read) || function (o, n) {
@@ -20661,36 +20995,37 @@ var __read = (this && this.__read) || function (o, n) {
20661
20995
  function isAndroid() {
20662
20996
  return /Android/.test(navigator.userAgent);
20663
20997
  }
20664
- /**
20665
- * Check whether the current browser is an iOS device.
20666
- * @returns {boolean}
20667
- */
20668
- function isIOS() {
20669
- return /iPad|iPhone|iPod/.test(navigator.userAgent);
20670
- }
20671
20998
  /**
20672
20999
  * Detects whether or not a device is an Apple touch screen device.
20673
21000
  * @returns {boolean}
20674
21001
  */
20675
21002
  function hasTouchScreen() {
20676
- return navigator && navigator.maxTouchPoints &&
20677
- navigator.maxTouchPoints > 2;
21003
+ return !!(navigator && navigator.maxTouchPoints && navigator.maxTouchPoints > 2);
20678
21004
  }
20679
21005
  /**
20680
- * Detects whether or not a device is an iPad
21006
+ * Detects whether or not a device is an iPad.
20681
21007
  * @returns {boolean}
20682
21008
  */
20683
21009
  function isIpad() {
20684
- return hasTouchScreen() && window.screen.width >= 744 &&
20685
- (/Macintosh/i.test(navigator.userAgent) || /iPad/.test(navigator.userAgent) || /iPad/.test(navigator.platform));
21010
+ return hasTouchScreen() && window.screen.width >= 744 && (/Macintosh/i.test(navigator.userAgent)
21011
+ || /iPad/.test(navigator.userAgent)
21012
+ || /iPad/.test(navigator.platform));
20686
21013
  }
20687
21014
  /**
20688
- * Detects whether or not a device is an iPhone
21015
+ * Detects whether or not a device is an iPhone.
20689
21016
  * @returns {boolean}
20690
21017
  */
20691
21018
  function isIphone() {
20692
- return hasTouchScreen() && window.screen.width <= 476 &&
20693
- (/Macintosh/i.test(navigator.userAgent) || /iPhone/.test(navigator.userAgent) || /iPhone/.test(navigator.platform));
21019
+ return hasTouchScreen() && window.screen.width <= 476 && (/Macintosh/i.test(navigator.userAgent)
21020
+ || /iPhone/.test(navigator.userAgent)
21021
+ || /iPhone/.test(navigator.platform));
21022
+ }
21023
+ /**
21024
+ * Check whether the current device is an iOS device.
21025
+ * @returns {boolean}
21026
+ */
21027
+ function isIOS() {
21028
+ return isIpad() || isIphone();
20694
21029
  }
20695
21030
  /**
20696
21031
  * Check whether the current browser is a mobile browser
@@ -20792,7 +21127,7 @@ module.exports = {
20792
21127
  rebrandedChromeBrowser: rebrandedChromeBrowser
20793
21128
  };
20794
21129
 
20795
- },{}],123:[function(require,module,exports){
21130
+ },{}],124:[function(require,module,exports){
20796
21131
  'use strict';
20797
21132
  var __read = (this && this.__read) || function (o, n) {
20798
21133
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -20935,7 +21270,7 @@ var CancelablePromise = /** @class */ (function () {
20935
21270
  }());
20936
21271
  module.exports = CancelablePromise;
20937
21272
 
20938
- },{}],124:[function(require,module,exports){
21273
+ },{}],125:[function(require,module,exports){
20939
21274
  'use strict';
20940
21275
  /* eslint-disable camelcase */
20941
21276
  var packageInfo = require('../../package.json');
@@ -21037,7 +21372,7 @@ module.exports.videoContentPreferencesMode = {
21037
21372
  MODE_MANUAL: 'manual'
21038
21373
  };
21039
21374
 
21040
- },{"../../package.json":174}],125:[function(require,module,exports){
21375
+ },{"../../package.json":174}],126:[function(require,module,exports){
21041
21376
  'use strict';
21042
21377
  var detectSilence = require('../webaudio/detectsilence');
21043
21378
  var N_ATTEMPTS = 3;
@@ -21078,7 +21413,7 @@ function detectSilentAudio(el) {
21078
21413
  }
21079
21414
  module.exports = detectSilentAudio;
21080
21415
 
21081
- },{"../webaudio/audiocontext":152,"../webaudio/detectsilence":153}],126:[function(require,module,exports){
21416
+ },{"../webaudio/audiocontext":153,"../webaudio/detectsilence":154}],127:[function(require,module,exports){
21082
21417
  'use strict';
21083
21418
  // Cached copy of the <canvas> used to check silent video frames.
21084
21419
  var canvas = null;
@@ -21137,7 +21472,7 @@ function detectSilentVideo(el) {
21137
21472
  }
21138
21473
  module.exports = detectSilentVideo;
21139
21474
 
21140
- },{}],127:[function(require,module,exports){
21475
+ },{}],128:[function(require,module,exports){
21141
21476
  'use strict';
21142
21477
  /**
21143
21478
  * The {@link DocumentVisibilityMonitor} monitors the visibility state of the DOM
@@ -21259,7 +21594,7 @@ var DocumentVisibilityMonitor = /** @class */ (function () {
21259
21594
  }());
21260
21595
  module.exports = new DocumentVisibilityMonitor(2);
21261
21596
 
21262
- },{}],128:[function(require,module,exports){
21597
+ },{}],129:[function(require,module,exports){
21263
21598
  'use strict';
21264
21599
  module.exports = (function (scope) {
21265
21600
  var location = scope.location, URL = scope.URL;
@@ -21282,7 +21617,7 @@ module.exports = (function (scope) {
21282
21617
  };
21283
21618
  }(globalThis));
21284
21619
 
21285
- },{}],129:[function(require,module,exports){
21620
+ },{}],130:[function(require,module,exports){
21286
21621
  /* eslint-disable no-console */
21287
21622
  'use strict';
21288
21623
  var __extends = (this && this.__extends) || (function () {
@@ -21380,7 +21715,7 @@ var EventObserver = /** @class */ (function (_super) {
21380
21715
  */
21381
21716
  module.exports = EventObserver;
21382
21717
 
21383
- },{"events":173}],130:[function(require,module,exports){
21718
+ },{"events":173}],131:[function(require,module,exports){
21384
21719
  'use strict';
21385
21720
  var Filter = /** @class */ (function () {
21386
21721
  function Filter(options) {
@@ -21424,7 +21759,7 @@ var Filter = /** @class */ (function () {
21424
21759
  }());
21425
21760
  module.exports = Filter;
21426
21761
 
21427
- },{}],131:[function(require,module,exports){
21762
+ },{}],132:[function(require,module,exports){
21428
21763
  'use strict';
21429
21764
  var __extends = (this && this.__extends) || (function () {
21430
21765
  var extendStatics = function (d, b) {
@@ -22321,7 +22656,7 @@ exports.isUserMediaTrack = isUserMediaTrack;
22321
22656
  exports.waitForSometime = waitForSometime;
22322
22657
  exports.waitForEvent = waitForEvent;
22323
22658
 
22324
- },{"../webrtc/util":170,"./constants":124,"./sid":143,"./twiliowarning":148}],132:[function(require,module,exports){
22659
+ },{"../webrtc/util":170,"./constants":125,"./sid":144,"./twiliowarning":149}],133:[function(require,module,exports){
22325
22660
  /* eslint-disable camelcase */
22326
22661
  'use strict';
22327
22662
  var __extends = (this && this.__extends) || (function () {
@@ -22616,7 +22951,7 @@ function reconnect(publisher, token, sdkName, sdkVersion, roomSid, participantSi
22616
22951
  */
22617
22952
  module.exports = InsightsPublisher;
22618
22953
 
22619
- },{"..":131,"../../util":131,"../browserdetection":122,"../constants":124,"events":173,"ws":175}],133:[function(require,module,exports){
22954
+ },{"..":132,"../../util":132,"../browserdetection":123,"../constants":125,"events":173,"ws":175}],134:[function(require,module,exports){
22620
22955
  // eslint-disable-next-line no-warning-comments
22621
22956
  // TODO(mroberts): This should be described as implementing some
22622
22957
  // InsightsPublisher interface.
@@ -22661,7 +22996,7 @@ var InsightsPublisher = /** @class */ (function () {
22661
22996
  }());
22662
22997
  module.exports = InsightsPublisher;
22663
22998
 
22664
- },{}],134:[function(require,module,exports){
22999
+ },{}],135:[function(require,module,exports){
22665
23000
  'use strict';
22666
23001
  var defer = require('./').defer;
22667
23002
  /**
@@ -22723,7 +23058,7 @@ var LocalMediaRestartDeferreds = /** @class */ (function () {
22723
23058
  }());
22724
23059
  module.exports = new LocalMediaRestartDeferreds();
22725
23060
 
22726
- },{"./":131}],135:[function(require,module,exports){
23061
+ },{"./":132}],136:[function(require,module,exports){
22727
23062
  /* eslint new-cap:0 */
22728
23063
  'use strict';
22729
23064
  var __read = (this && this.__read) || function (o, n) {
@@ -23010,7 +23345,7 @@ function validateLogLevels(levels) {
23010
23345
  }
23011
23346
  module.exports = Log;
23012
23347
 
23013
- },{"../vendor/loglevel":151,"./constants":124}],136:[function(require,module,exports){
23348
+ },{"../vendor/loglevel":152,"./constants":125}],137:[function(require,module,exports){
23014
23349
  'use strict';
23015
23350
  /**
23016
23351
  * Calculates the moving average delta for the given pair ofsamples. A sample (S)
@@ -23057,7 +23392,7 @@ var MovingAverageDelta = /** @class */ (function () {
23057
23392
  }());
23058
23393
  module.exports = MovingAverageDelta;
23059
23394
 
23060
- },{}],137:[function(require,module,exports){
23395
+ },{}],138:[function(require,module,exports){
23061
23396
  'use strict';
23062
23397
  /**
23063
23398
  * Monitor the network connection status to detect interruptions and handoffs.
@@ -23146,7 +23481,7 @@ var NetworkMonitor = /** @class */ (function () {
23146
23481
  }());
23147
23482
  module.exports = NetworkMonitor;
23148
23483
 
23149
- },{}],138:[function(require,module,exports){
23484
+ },{}],139:[function(require,module,exports){
23150
23485
  /* eslint-disable no-console */
23151
23486
  'use strict';
23152
23487
  var __extends = (this && this.__extends) || (function () {
@@ -23209,7 +23544,7 @@ var NullResizeObserver = /** @class */ (function (_super) {
23209
23544
  }(NullObserver));
23210
23545
  module.exports = { NullIntersectionObserver: NullIntersectionObserver, NullResizeObserver: NullResizeObserver, NullObserver: NullObserver };
23211
23546
 
23212
- },{}],139:[function(require,module,exports){
23547
+ },{}],140:[function(require,module,exports){
23213
23548
  'use strict';
23214
23549
  var __read = (this && this.__read) || function (o, n) {
23215
23550
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -23747,7 +24082,7 @@ exports.revertSimulcast = revertSimulcast;
23747
24082
  exports.setCodecPreferences = setCodecPreferences;
23748
24083
  exports.setSimulcast = setSimulcast;
23749
24084
 
23750
- },{"../":131,"./simulcast":141}],140:[function(require,module,exports){
24085
+ },{"../":132,"./simulcast":142}],141:[function(require,module,exports){
23751
24086
  'use strict';
23752
24087
  var RTCSessionDescription = require('../../webrtc').RTCSessionDescription;
23753
24088
  var _a = require('./'), createPtToCodecName = _a.createPtToCodecName, getMediaSections = _a.getMediaSections;
@@ -23940,7 +24275,7 @@ function addFmtpAttributeForRtxPt(mediaSection, rtxPt, pt) {
23940
24275
  }
23941
24276
  module.exports = workaround;
23942
24277
 
23943
- },{"../../webrtc":157,"./":139}],141:[function(require,module,exports){
24278
+ },{"../../webrtc":158,"./":140}],142:[function(require,module,exports){
23944
24279
  'use strict';
23945
24280
  var __read = (this && this.__read) || function (o, n) {
23946
24281
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -24203,7 +24538,7 @@ function setSimulcastInMediaSection(section, trackIdsToAttributes) {
24203
24538
  */
24204
24539
  module.exports = setSimulcastInMediaSection;
24205
24540
 
24206
- },{"../":131}],142:[function(require,module,exports){
24541
+ },{"../":132}],143:[function(require,module,exports){
24207
24542
  'use strict';
24208
24543
  var getMediaSections = require('./').getMediaSections;
24209
24544
  /**
@@ -24248,7 +24583,7 @@ var TrackMatcher = /** @class */ (function () {
24248
24583
  }());
24249
24584
  module.exports = TrackMatcher;
24250
24585
 
24251
- },{"./":139}],143:[function(require,module,exports){
24586
+ },{"./":140}],144:[function(require,module,exports){
24252
24587
  var SID_CHARS = '1234567890abcdef';
24253
24588
  var SID_CHAR_LENGTH = 32;
24254
24589
  // copied from: https://code.hq.twilio.com/flex/monkey/blob/0fdce2b6c52d6be0b17a5cdb92f0c54f119b8ea8/src/client/lib/sid.ts#L39
@@ -24267,7 +24602,7 @@ function createSID(prefix) {
24267
24602
  exports.sessionSID = createSID('SS');
24268
24603
  exports.createSID = createSID;
24269
24604
 
24270
- },{}],144:[function(require,module,exports){
24605
+ },{}],145:[function(require,module,exports){
24271
24606
  'use strict';
24272
24607
  var _a = require('../webrtc/util'), guessBrowser = _a.guessBrowser, isWebRTCSupported = _a.support;
24273
24608
  var getSdpFormat = require('../webrtc/util/sdp').getSdpFormat;
@@ -24314,7 +24649,7 @@ function isSupported() {
24314
24649
  }
24315
24650
  module.exports = isSupported;
24316
24651
 
24317
- },{"../webrtc/util":170,"../webrtc/util/sdp":172,"./browserdetection":122}],145:[function(require,module,exports){
24652
+ },{"../webrtc/util":170,"../webrtc/util/sdp":172,"./browserdetection":123}],146:[function(require,module,exports){
24318
24653
  'use strict';
24319
24654
  /**
24320
24655
  * A {@link Timeout} represents a resettable and clearable timeout.
@@ -24409,7 +24744,7 @@ var Timeout = /** @class */ (function () {
24409
24744
  }());
24410
24745
  module.exports = Timeout;
24411
24746
 
24412
- },{}],146:[function(require,module,exports){
24747
+ },{}],147:[function(require,module,exports){
24413
24748
  // NOTE: Do not edit this file. This code is auto-generated. Contact the
24414
24749
  // Twilio SDK Team for more information.
24415
24750
  'use strict';
@@ -25433,7 +25768,7 @@ var ConfigurationAcquireTurnFailedError = /** @class */ (function (_super) {
25433
25768
  exports.ConfigurationAcquireTurnFailedError = ConfigurationAcquireTurnFailedError;
25434
25769
  Object.defineProperty(TwilioErrorByCode, 53501, { value: ConfigurationAcquireTurnFailedError });
25435
25770
 
25436
- },{"./twilioerror":147}],147:[function(require,module,exports){
25771
+ },{"./twilioerror":148}],148:[function(require,module,exports){
25437
25772
  'use strict';
25438
25773
  var __extends = (this && this.__extends) || (function () {
25439
25774
  var extendStatics = function (d, b) {
@@ -25515,7 +25850,7 @@ var TwilioError = /** @class */ (function (_super) {
25515
25850
  }(Error));
25516
25851
  module.exports = TwilioError;
25517
25852
 
25518
- },{}],148:[function(require,module,exports){
25853
+ },{}],149:[function(require,module,exports){
25519
25854
  'use strict';
25520
25855
  /**
25521
25856
  * @private
@@ -25528,7 +25863,7 @@ var TwilioWarning = {
25528
25863
  };
25529
25864
  module.exports = TwilioWarning;
25530
25865
 
25531
- },{}],149:[function(require,module,exports){
25866
+ },{}],150:[function(require,module,exports){
25532
25867
  'use strict';
25533
25868
  var isNonArrayObject = require('./').isNonArrayObject;
25534
25869
  var _a = require('./constants'), E = _a.typeErrors, clientTrackSwitchOffControl = _a.clientTrackSwitchOffControl, videoContentPreferencesMode = _a.videoContentPreferencesMode, subscriptionMode = _a.subscriptionMode, trackPriority = _a.trackPriority, trackSwitchOffMode = _a.trackSwitchOffMode;
@@ -25645,7 +25980,7 @@ exports.validateBandwidthProfile = validateBandwidthProfile;
25645
25980
  exports.validateLocalTrack = validateLocalTrack;
25646
25981
  exports.validateObject = validateObject;
25647
25982
 
25648
- },{"./":131,"./constants":124}],150:[function(require,module,exports){
25983
+ },{"./":132,"./constants":125}],151:[function(require,module,exports){
25649
25984
  /**
25650
25985
  * Copyright (c) 2011-2022 Isaac Z. Schlueter
25651
25986
  * Licensed under the ISC License.
@@ -25680,7 +26015,7 @@ module.exports = function inherits(ctor, superCtor) {
25680
26015
  }
25681
26016
  };
25682
26017
 
25683
- },{}],151:[function(require,module,exports){
26018
+ },{}],152:[function(require,module,exports){
25684
26019
  /**
25685
26020
  * Copyright (c) 2013 Tim Perry
25686
26021
  * Licensed under the MIT license.
@@ -25920,7 +26255,7 @@ defaultLogger.getLoggers = function getLoggers() {
25920
26255
  defaultLogger['default'] = defaultLogger;
25921
26256
  module.exports = defaultLogger;
25922
26257
 
25923
- },{}],152:[function(require,module,exports){
26258
+ },{}],153:[function(require,module,exports){
25924
26259
  /* globals webkitAudioContext, AudioContext */
25925
26260
  'use strict';
25926
26261
  var NativeAudioContext = typeof AudioContext !== 'undefined'
@@ -26003,7 +26338,7 @@ var AudioContextFactory = /** @class */ (function () {
26003
26338
  }());
26004
26339
  module.exports = new AudioContextFactory();
26005
26340
 
26006
- },{}],153:[function(require,module,exports){
26341
+ },{}],154:[function(require,module,exports){
26007
26342
  'use strict';
26008
26343
  /**
26009
26344
  * Return a Promise that resolves after `timeout` milliseconds.
@@ -26056,7 +26391,7 @@ function detectSilence(audioContext, stream, timeout) {
26056
26391
  }
26057
26392
  module.exports = detectSilence;
26058
26393
 
26059
- },{}],154:[function(require,module,exports){
26394
+ },{}],155:[function(require,module,exports){
26060
26395
  'use strict';
26061
26396
  var detectSilence = require('./detectsilence');
26062
26397
  /**
@@ -26126,11 +26461,25 @@ to get a new one, but we\'ve run out of retries; returning it anyway.');
26126
26461
  }
26127
26462
  module.exports = workaround;
26128
26463
 
26129
- },{"./audiocontext":152,"./detectsilence":153}],155:[function(require,module,exports){
26464
+ },{"./audiocontext":153,"./detectsilence":154}],156:[function(require,module,exports){
26130
26465
  'use strict';
26131
- var flatMap = require('./util').flatMap;
26132
- var guessBrowser = require('./util').guessBrowser;
26133
- var guessBrowserVersion = require('./util').guessBrowserVersion;
26466
+ var __read = (this && this.__read) || function (o, n) {
26467
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26468
+ if (!m) return o;
26469
+ var i = m.call(o), r, ar = [], e;
26470
+ try {
26471
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
26472
+ }
26473
+ catch (error) { e = { error: error }; }
26474
+ finally {
26475
+ try {
26476
+ if (r && !r.done && (m = i["return"])) m.call(i);
26477
+ }
26478
+ finally { if (e) throw e.error; }
26479
+ }
26480
+ return ar;
26481
+ };
26482
+ var _a = require('./util'), flatMap = _a.flatMap, guessBrowser = _a.guessBrowser, guessBrowserVersion = _a.guessBrowserVersion;
26134
26483
  var getSdpFormat = require('./util/sdp').getSdpFormat;
26135
26484
  var guess = guessBrowser();
26136
26485
  var guessVersion = guessBrowserVersion();
@@ -26174,10 +26523,8 @@ function _getStats(peerConnection, options) {
26174
26523
  [localVideoTracks, 'localVideoTrackStats', false],
26175
26524
  [remoteAudioTracks, 'remoteAudioTrackStats', true],
26176
26525
  [remoteVideoTracks, 'remoteVideoTrackStats', true]
26177
- ], function (triple) {
26178
- var tracks = triple[0];
26179
- var statsArrayName = triple[1];
26180
- var isRemote = triple[2];
26526
+ ], function (_a) {
26527
+ var _b = __read(_a, 3), tracks = _b[0], statsArrayName = _b[1], isRemote = _b[2];
26181
26528
  return tracks.map(function (track) {
26182
26529
  return getTrackStats(peerConnection, track, Object.assign({
26183
26530
  isRemote: isRemote
@@ -26204,7 +26551,7 @@ function _getStats(peerConnection, options) {
26204
26551
  * @returns {Promise<StandardizedActiveIceCandidatePairStatsReport>}
26205
26552
  */
26206
26553
  function getActiveIceCandidatePairStats(peerConnection, options) {
26207
- options = options || {};
26554
+ if (options === void 0) { options = {}; }
26208
26555
  if (typeof options.testForChrome !== 'undefined' || isChrome
26209
26556
  || typeof options.testForSafari !== 'undefined' || isSafari) {
26210
26557
  return peerConnection.getStats().then(standardizeChromeOrSafariActiveIceCandidatePairStats);
@@ -26220,8 +26567,9 @@ function getActiveIceCandidatePairStats(peerConnection, options) {
26220
26567
  * @returns {?StandardizedActiveIceCandidatePairStatsReport}
26221
26568
  */
26222
26569
  function standardizeChromeOrSafariActiveIceCandidatePairStats(stats) {
26223
- var activeCandidatePairStats = Array.from(stats.values()).find(function (stat) {
26224
- return stat.type === 'candidate-pair' && stat.nominated;
26570
+ var activeCandidatePairStats = Array.from(stats.values()).find(function (_a) {
26571
+ var nominated = _a.nominated, type = _a.type;
26572
+ return type === 'candidate-pair' && nominated;
26225
26573
  });
26226
26574
  if (!activeCandidatePairStats) {
26227
26575
  return null;
@@ -26241,17 +26589,19 @@ function standardizeChromeOrSafariActiveIceCandidatePairStats(stats) {
26241
26589
  { key: 'relayProtocol', type: 'string' }
26242
26590
  ]);
26243
26591
  var standatdizedLocalCandidateStatsReport = activeLocalCandidateStats
26244
- ? standardizedLocalCandidateStatsKeys.reduce(function (report, keyInfo) {
26245
- report[keyInfo.key] = typeof activeLocalCandidateStats[keyInfo.key] === keyInfo.type
26246
- ? activeLocalCandidateStats[keyInfo.key]
26247
- : keyInfo.key === 'deleted' ? false : null;
26592
+ ? standardizedLocalCandidateStatsKeys.reduce(function (report, _a) {
26593
+ var key = _a.key, type = _a.type;
26594
+ report[key] = typeof activeLocalCandidateStats[key] === type
26595
+ ? activeLocalCandidateStats[key]
26596
+ : key === 'deleted' ? false : null;
26248
26597
  return report;
26249
26598
  }, {})
26250
26599
  : null;
26251
26600
  var standardizedRemoteCandidateStatsReport = activeRemoteCandidateStats
26252
- ? standardizedCandidateStatsKeys.reduce(function (report, keyInfo) {
26253
- report[keyInfo.key] = typeof activeRemoteCandidateStats[keyInfo.key] === keyInfo.type
26254
- ? activeRemoteCandidateStats[keyInfo.key]
26601
+ ? standardizedCandidateStatsKeys.reduce(function (report, _a) {
26602
+ var key = _a.key, type = _a.type;
26603
+ report[key] = typeof activeRemoteCandidateStats[key] === type
26604
+ ? activeRemoteCandidateStats[key]
26255
26605
  : null;
26256
26606
  return report;
26257
26607
  }, {})
@@ -26278,9 +26628,10 @@ function standardizeChromeOrSafariActiveIceCandidatePairStats(stats) {
26278
26628
  { key: 'totalRoundTripTime', type: 'number' },
26279
26629
  { key: 'transportId', type: 'string' },
26280
26630
  { key: 'writable', type: 'boolean' }
26281
- ].reduce(function (report, keyInfo) {
26282
- report[keyInfo.key] = typeof activeCandidatePairStats[keyInfo.key] === keyInfo.type
26283
- ? (keyInfo.fixup ? keyInfo.fixup(activeCandidatePairStats[keyInfo.key]) : activeCandidatePairStats[keyInfo.key])
26631
+ ].reduce(function (report, _a) {
26632
+ var key = _a.key, type = _a.type, fixup = _a.fixup;
26633
+ report[key] = typeof activeCandidatePairStats[key] === type
26634
+ ? (fixup ? fixup(activeCandidatePairStats[key]) : activeCandidatePairStats[key])
26284
26635
  : null;
26285
26636
  return report;
26286
26637
  }, {
@@ -26294,8 +26645,9 @@ function standardizeChromeOrSafariActiveIceCandidatePairStats(stats) {
26294
26645
  * @returns {?StandardizedActiveIceCandidatePairStatsReport}
26295
26646
  */
26296
26647
  function standardizeFirefoxActiveIceCandidatePairStats(stats) {
26297
- var activeCandidatePairStats = Array.from(stats.values()).find(function (stat) {
26298
- return stat.type === 'candidate-pair' && stat.nominated;
26648
+ var activeCandidatePairStats = Array.from(stats.values()).find(function (_a) {
26649
+ var nominated = _a.nominated, type = _a.type;
26650
+ return type === 'candidate-pair' && nominated;
26299
26651
  });
26300
26652
  if (!activeCandidatePairStats) {
26301
26653
  return null;
@@ -26321,27 +26673,25 @@ function standardizeFirefoxActiveIceCandidatePairStats(stats) {
26321
26673
  serverreflexive: 'srflx'
26322
26674
  };
26323
26675
  var standatdizedLocalCandidateStatsReport = activeLocalCandidateStats
26324
- ? standardizedLocalCandidateStatsKeys.reduce(function (report, keyInfo) {
26325
- var key = keyInfo.ffKeys && keyInfo.ffKeys.find(function (key) {
26326
- return key in activeLocalCandidateStats;
26327
- }) || keyInfo.key;
26328
- report[keyInfo.key] = typeof activeLocalCandidateStats[key] === keyInfo.type
26329
- ? key === 'candidateType'
26330
- ? candidateTypes[activeLocalCandidateStats[key]] || activeLocalCandidateStats[key]
26331
- : activeLocalCandidateStats[key]
26332
- : key === 'deleted' ? false : null;
26676
+ ? standardizedLocalCandidateStatsKeys.reduce(function (report, _a) {
26677
+ var ffKeys = _a.ffKeys, key = _a.key, type = _a.type;
26678
+ var localStatKey = ffKeys && ffKeys.find(function (key) { return key in activeLocalCandidateStats; }) || key;
26679
+ report[key] = typeof activeLocalCandidateStats[localStatKey] === type
26680
+ ? localStatKey === 'candidateType'
26681
+ ? candidateTypes[activeLocalCandidateStats[localStatKey]] || activeLocalCandidateStats[localStatKey]
26682
+ : activeLocalCandidateStats[localStatKey]
26683
+ : localStatKey === 'deleted' ? false : null;
26333
26684
  return report;
26334
26685
  }, {})
26335
26686
  : null;
26336
26687
  var standardizedRemoteCandidateStatsReport = activeRemoteCandidateStats
26337
- ? standardizedCandidateStatsKeys.reduce(function (report, keyInfo) {
26338
- var key = keyInfo.ffKeys && keyInfo.ffKeys.find(function (key) {
26339
- return key in activeRemoteCandidateStats;
26340
- }) || keyInfo.key;
26341
- report[keyInfo.key] = typeof activeRemoteCandidateStats[key] === keyInfo.type
26342
- ? key === 'candidateType'
26343
- ? candidateTypes[activeRemoteCandidateStats[key]] || activeRemoteCandidateStats[key]
26344
- : activeRemoteCandidateStats[key]
26688
+ ? standardizedCandidateStatsKeys.reduce(function (report, _a) {
26689
+ var ffKeys = _a.ffKeys, key = _a.key, type = _a.type;
26690
+ var remoteStatKey = ffKeys && ffKeys.find(function (key) { return key in activeRemoteCandidateStats; }) || key;
26691
+ report[key] = typeof activeRemoteCandidateStats[remoteStatKey] === type
26692
+ ? remoteStatKey === 'candidateType'
26693
+ ? candidateTypes[activeRemoteCandidateStats[remoteStatKey]] || activeRemoteCandidateStats[remoteStatKey]
26694
+ : activeRemoteCandidateStats[remoteStatKey]
26345
26695
  : null;
26346
26696
  return report;
26347
26697
  }, {})
@@ -26368,9 +26718,10 @@ function standardizeFirefoxActiveIceCandidatePairStats(stats) {
26368
26718
  { key: 'totalRoundTripTime', type: 'number' },
26369
26719
  { key: 'transportId', type: 'string' },
26370
26720
  { key: 'writable', type: 'boolean' }
26371
- ].reduce(function (report, keyInfo) {
26372
- report[keyInfo.key] = typeof activeCandidatePairStats[keyInfo.key] === keyInfo.type
26373
- ? activeCandidatePairStats[keyInfo.key]
26721
+ ].reduce(function (report, _a) {
26722
+ var key = _a.key, type = _a.type;
26723
+ report[key] = typeof activeCandidatePairStats[key] === type
26724
+ ? activeCandidatePairStats[key]
26374
26725
  : null;
26375
26726
  return report;
26376
26727
  }, {
@@ -26388,17 +26739,16 @@ function standardizeFirefoxActiveIceCandidatePairStats(stats) {
26388
26739
  function getTracks(peerConnection, kind, localOrRemote) {
26389
26740
  var getSendersOrReceivers = localOrRemote === 'local' ? 'getSenders' : 'getReceivers';
26390
26741
  if (peerConnection[getSendersOrReceivers]) {
26391
- return peerConnection[getSendersOrReceivers]().map(function (senderOrReceiver) {
26392
- return senderOrReceiver.track;
26393
- }).filter(function (track) {
26394
- return track && track.kind === kind;
26395
- });
26742
+ return peerConnection[getSendersOrReceivers]()
26743
+ .map(function (_a) {
26744
+ var track = _a.track;
26745
+ return track;
26746
+ })
26747
+ .filter(function (track) { return track && track.kind === kind; });
26396
26748
  }
26397
26749
  var getStreams = localOrRemote === 'local' ? 'getLocalStreams' : 'getRemoteStreams';
26398
- return flatMap(peerConnection[getStreams](), function (stream) {
26399
- var getTracks = kind === 'audio' ? 'getAudioTracks' : 'getVideoTracks';
26400
- return stream[getTracks]();
26401
- });
26750
+ var getTracks = kind === 'audio' ? 'getAudioTracks' : 'getVideoTracks';
26751
+ return flatMap(peerConnection[getStreams](), function (stream) { return stream[getTracks](); });
26402
26752
  }
26403
26753
  /**
26404
26754
  * Get the standardized statistics for a particular MediaStreamTrack.
@@ -26408,7 +26758,7 @@ function getTracks(peerConnection, kind, localOrRemote) {
26408
26758
  * @returns {Promise.<Array<StandardizedTrackStatsReport>>}
26409
26759
  */
26410
26760
  function getTrackStats(peerConnection, track, options) {
26411
- options = options || {};
26761
+ if (options === void 0) { options = {}; }
26412
26762
  if (typeof options.testForChrome !== 'undefined' || isChrome) {
26413
26763
  return chromeOrSafariGetTrackStats(peerConnection, track);
26414
26764
  }
@@ -26547,7 +26897,8 @@ function standardizeChromeOrSafariStats(response) {
26547
26897
  var codec = null;
26548
26898
  var localMedia = null;
26549
26899
  response.forEach(function (stat) {
26550
- switch (stat.type) {
26900
+ var type = stat.type;
26901
+ switch (type) {
26551
26902
  case 'inbound-rtp':
26552
26903
  inbound = stat;
26553
26904
  break;
@@ -26712,7 +27063,7 @@ function standardizeFirefoxStats(response, isRemote) {
26712
27063
  //
26713
27064
  // https://bugzilla.mozilla.org/show_bug.cgi?id=1377225
26714
27065
  //
26715
- response = response || new Map();
27066
+ if (response === void 0) { response = new Map(); }
26716
27067
  var inbound = null;
26717
27068
  var outbound = null;
26718
27069
  // NOTE(mmalavalli): Starting from Firefox 63, RTC{Inbound, Outbound}RTPStreamStats.isRemote
@@ -26725,17 +27076,18 @@ function standardizeFirefoxStats(response, isRemote) {
26725
27076
  // Source: https://blog.mozilla.org/webrtc/getstats-isremote-65/
26726
27077
  //
26727
27078
  response.forEach(function (stat) {
26728
- if (stat.isRemote) {
27079
+ var isRemote = stat.isRemote, remoteId = stat.remoteId, type = stat.type;
27080
+ if (isRemote) {
26729
27081
  return;
26730
27082
  }
26731
- switch (stat.type) {
27083
+ switch (type) {
26732
27084
  case 'inbound-rtp':
26733
27085
  inbound = stat;
26734
- outbound = response.get(stat.remoteId);
27086
+ outbound = response.get(remoteId);
26735
27087
  break;
26736
27088
  case 'outbound-rtp':
26737
27089
  outbound = stat;
26738
- inbound = response.get(stat.remoteId);
27090
+ inbound = response.get(remoteId);
26739
27091
  break;
26740
27092
  }
26741
27093
  });
@@ -26920,7 +27272,7 @@ function standardizeFirefoxStats(response, isRemote) {
26920
27272
  */
26921
27273
  module.exports = getStats;
26922
27274
 
26923
- },{"./util":170,"./util/sdp":172}],156:[function(require,module,exports){
27275
+ },{"./util":170,"./util/sdp":172}],157:[function(require,module,exports){
26924
27276
  /* globals navigator */
26925
27277
  'use strict';
26926
27278
  /**
@@ -26934,17 +27286,17 @@ module.exports = getStats;
26934
27286
  * @returns Promise<MediaStream>
26935
27287
  */
26936
27288
  function getUserMedia(constraints) {
27289
+ if (constraints === void 0) { constraints = { audio: true, video: true }; }
26937
27290
  if (typeof navigator === 'object'
26938
27291
  && typeof navigator.mediaDevices === 'object'
26939
27292
  && typeof navigator.mediaDevices.getUserMedia === 'function') {
26940
- constraints = constraints || { audio: true, video: true };
26941
27293
  return navigator.mediaDevices.getUserMedia(constraints);
26942
27294
  }
26943
27295
  return Promise.reject(new Error('getUserMedia is not supported'));
26944
27296
  }
26945
27297
  module.exports = getUserMedia;
26946
27298
 
26947
- },{}],157:[function(require,module,exports){
27299
+ },{}],158:[function(require,module,exports){
26948
27300
  'use strict';
26949
27301
  var WebRTC = {};
26950
27302
  Object.defineProperties(WebRTC, {
@@ -26979,7 +27331,7 @@ Object.defineProperties(WebRTC, {
26979
27331
  });
26980
27332
  module.exports = WebRTC;
26981
27333
 
26982
- },{"./getstats":155,"./getusermedia":156,"./mediastream":158,"./mediastreamtrack":159,"./rtcicecandidate":160,"./rtcpeerconnection":163,"./rtcsessiondescription":168}],158:[function(require,module,exports){
27334
+ },{"./getstats":156,"./getusermedia":157,"./mediastream":159,"./mediastreamtrack":160,"./rtcicecandidate":161,"./rtcpeerconnection":164,"./rtcsessiondescription":169}],159:[function(require,module,exports){
26983
27335
  /* globals MediaStream */
26984
27336
  'use strict';
26985
27337
  if (typeof MediaStream === 'function') {
@@ -26991,7 +27343,7 @@ else {
26991
27343
  };
26992
27344
  }
26993
27345
 
26994
- },{}],159:[function(require,module,exports){
27346
+ },{}],160:[function(require,module,exports){
26995
27347
  /* global MediaStreamTrack */
26996
27348
  'use strict';
26997
27349
  if (typeof MediaStreamTrack === 'function') {
@@ -27003,7 +27355,7 @@ else {
27003
27355
  };
27004
27356
  }
27005
27357
 
27006
- },{}],160:[function(require,module,exports){
27358
+ },{}],161:[function(require,module,exports){
27007
27359
  /* global RTCIceCandidate */
27008
27360
  'use strict';
27009
27361
  if (typeof RTCIceCandidate === 'function') {
@@ -27015,19 +27367,53 @@ else {
27015
27367
  };
27016
27368
  }
27017
27369
 
27018
- },{}],161:[function(require,module,exports){
27370
+ },{}],162:[function(require,module,exports){
27019
27371
  /* globals RTCDataChannel, RTCPeerConnection, RTCSessionDescription */
27020
27372
  'use strict';
27373
+ var __extends = (this && this.__extends) || (function () {
27374
+ var extendStatics = function (d, b) {
27375
+ extendStatics = Object.setPrototypeOf ||
27376
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27377
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
27378
+ return extendStatics(d, b);
27379
+ };
27380
+ return function (d, b) {
27381
+ if (typeof b !== "function" && b !== null)
27382
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
27383
+ extendStatics(d, b);
27384
+ function __() { this.constructor = d; }
27385
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27386
+ };
27387
+ })();
27388
+ var __read = (this && this.__read) || function (o, n) {
27389
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27390
+ if (!m) return o;
27391
+ var i = m.call(o), r, ar = [], e;
27392
+ try {
27393
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27394
+ }
27395
+ catch (error) { e = { error: error }; }
27396
+ finally {
27397
+ try {
27398
+ if (r && !r.done && (m = i["return"])) m.call(i);
27399
+ }
27400
+ finally { if (e) throw e.error; }
27401
+ }
27402
+ return ar;
27403
+ };
27404
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
27405
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
27406
+ to[j] = from[i];
27407
+ return to;
27408
+ };
27021
27409
  var ChromeRTCSessionDescription = require('../rtcsessiondescription/chrome');
27022
- var EventTarget = require('../util/eventtarget');
27023
- var inherits = require('../../vendor/inherits');
27410
+ var EventTarget = require('../../eventtarget');
27024
27411
  var Latch = require('../util/latch');
27025
27412
  var MediaStream = require('../mediastream');
27026
27413
  var RTCRtpSenderShim = require('../rtcrtpsender');
27027
- var sdpUtils = require('../util/sdp');
27028
- var util = require('../util');
27029
- var isIOSChrome = require('../util').isIOSChrome;
27030
- var isUnifiedPlan = sdpUtils.getSdpFormat() === 'unified';
27414
+ var _a = require('../util/sdp'), getSdpFormat = _a.getSdpFormat, updatePlanBTrackIdsToSSRCs = _a.updatePlanBTrackIdsToSSRCs, updateUnifiedPlanTrackIdsToSSRCs = _a.updateUnifiedPlanTrackIdsToSSRCs;
27415
+ var _b = require('../util'), delegateMethods = _b.delegateMethods, interceptEvent = _b.interceptEvent, isIOSChrome = _b.isIOSChrome, legacyPromise = _b.legacyPromise, proxyProperties = _b.proxyProperties;
27416
+ var isUnifiedPlan = getSdpFormat() === 'unified';
27031
27417
  // NOTE(mroberts): This class wraps Chrome's RTCPeerConnection implementation.
27032
27418
  // It provides some functionality not currently present in Chrome, namely the
27033
27419
  // abilities to
@@ -27039,119 +27425,127 @@ var isUnifiedPlan = sdpUtils.getSdpFormat() === 'unified';
27039
27425
  //
27040
27426
  // 3. Set iceTransportPolicy.
27041
27427
  //
27042
- function ChromeRTCPeerConnection(configuration, constraints) {
27043
- if (!(this instanceof ChromeRTCPeerConnection)) {
27044
- return new ChromeRTCPeerConnection(configuration, constraints);
27045
- }
27046
- EventTarget.call(this);
27047
- configuration = configuration || {};
27048
- var newConfiguration = Object.assign(configuration.iceTransportPolicy
27049
- ? { iceTransports: configuration.iceTransportPolicy }
27050
- : {}, configuration);
27051
- util.interceptEvent(this, 'datachannel');
27052
- util.interceptEvent(this, 'signalingstatechange');
27053
- var sdpFormat = sdpUtils.getSdpFormat(newConfiguration.sdpSemantics);
27054
- var peerConnection = new RTCPeerConnection(newConfiguration, constraints);
27055
- Object.defineProperties(this, {
27056
- _appliedTracksToSSRCs: {
27057
- value: new Map(),
27058
- writable: true
27059
- },
27060
- _localStream: {
27061
- value: new MediaStream()
27062
- },
27063
- _peerConnection: {
27064
- value: peerConnection
27065
- },
27066
- _pendingLocalOffer: {
27067
- value: null,
27068
- writable: true
27069
- },
27070
- _pendingRemoteOffer: {
27071
- value: null,
27072
- writable: true
27073
- },
27074
- _rolledBackTracksToSSRCs: {
27075
- value: new Map(),
27076
- writable: true
27077
- },
27078
- _sdpFormat: {
27079
- value: sdpFormat
27080
- },
27081
- _senders: {
27082
- value: new Map()
27083
- },
27084
- _signalingStateLatch: {
27085
- value: new Latch()
27086
- },
27087
- _tracksToSSRCs: {
27088
- value: new Map(),
27089
- writable: true
27090
- },
27091
- localDescription: {
27092
- enumerable: true,
27093
- get: function () {
27094
- return this._pendingLocalOffer ? this._pendingLocalOffer : peerConnection.localDescription;
27095
- }
27096
- },
27097
- remoteDescription: {
27098
- enumerable: true,
27099
- get: function () {
27100
- return this._pendingRemoteOffer ? this._pendingRemoteOffer : peerConnection.remoteDescription;
27428
+ var ChromeRTCPeerConnection = /** @class */ (function (_super) {
27429
+ __extends(ChromeRTCPeerConnection, _super);
27430
+ function ChromeRTCPeerConnection(configuration, constraints) {
27431
+ if (configuration === void 0) { configuration = {}; }
27432
+ var _this = _super.call(this) || this;
27433
+ var newConfiguration = Object.assign(configuration.iceTransportPolicy
27434
+ ? { iceTransports: configuration.iceTransportPolicy }
27435
+ : {}, configuration);
27436
+ interceptEvent(_this, 'datachannel');
27437
+ interceptEvent(_this, 'signalingstatechange');
27438
+ var sdpFormat = getSdpFormat(newConfiguration.sdpSemantics);
27439
+ var peerConnection = new RTCPeerConnection(newConfiguration, constraints);
27440
+ Object.defineProperties(_this, {
27441
+ _appliedTracksToSSRCs: {
27442
+ value: new Map(),
27443
+ writable: true
27444
+ },
27445
+ _localStream: {
27446
+ value: new MediaStream()
27447
+ },
27448
+ _peerConnection: {
27449
+ value: peerConnection
27450
+ },
27451
+ _pendingLocalOffer: {
27452
+ value: null,
27453
+ writable: true
27454
+ },
27455
+ _pendingRemoteOffer: {
27456
+ value: null,
27457
+ writable: true
27458
+ },
27459
+ _rolledBackTracksToSSRCs: {
27460
+ value: new Map(),
27461
+ writable: true
27462
+ },
27463
+ _sdpFormat: {
27464
+ value: sdpFormat
27465
+ },
27466
+ _senders: {
27467
+ value: new Map()
27468
+ },
27469
+ _signalingStateLatch: {
27470
+ value: new Latch()
27471
+ },
27472
+ _tracksToSSRCs: {
27473
+ value: new Map(),
27474
+ writable: true
27101
27475
  }
27102
- },
27103
- signalingState: {
27104
- enumerable: true,
27105
- get: function () {
27106
- if (this._pendingLocalOffer) {
27107
- return 'have-local-offer';
27108
- }
27109
- else if (this._pendingRemoteOffer) {
27110
- return 'have-remote-offer';
27111
- }
27112
- return peerConnection.signalingState;
27476
+ });
27477
+ peerConnection.addEventListener('datachannel', function (event) {
27478
+ shimDataChannel(event.channel);
27479
+ _this.dispatchEvent(event);
27480
+ });
27481
+ peerConnection.addEventListener('signalingstatechange', function () {
27482
+ var args = [];
27483
+ for (var _i = 0; _i < arguments.length; _i++) {
27484
+ args[_i] = arguments[_i];
27485
+ }
27486
+ if (peerConnection.signalingState === 'stable') {
27487
+ _this._appliedTracksToSSRCs = new Map(_this._tracksToSSRCs);
27488
+ }
27489
+ if (!_this._pendingLocalOffer && !_this._pendingRemoteOffer) {
27490
+ _this.dispatchEvent.apply(_this, __spreadArray([], __read(args)));
27113
27491
  }
27492
+ });
27493
+ peerConnection.ontrack = function () {
27494
+ // NOTE(mroberts): adapter.js's "track" event shim only kicks off if we set
27495
+ // the ontrack property of the RTCPeerConnection.
27496
+ };
27497
+ if (typeof peerConnection.addTrack !== 'function') {
27498
+ peerConnection.addStream(_this._localStream);
27114
27499
  }
27500
+ proxyProperties(RTCPeerConnection.prototype, _this, peerConnection);
27501
+ return _this;
27502
+ }
27503
+ Object.defineProperty(ChromeRTCPeerConnection.prototype, "localDescription", {
27504
+ get: function () {
27505
+ return this._pendingLocalOffer ? this._pendingLocalOffer : this._peerConnection.localDescription;
27506
+ },
27507
+ enumerable: false,
27508
+ configurable: true
27115
27509
  });
27116
- var self = this;
27117
- peerConnection.addEventListener('datachannel', function ondatachannel(event) {
27118
- shimDataChannel(event.channel);
27119
- self.dispatchEvent(event);
27510
+ Object.defineProperty(ChromeRTCPeerConnection.prototype, "remoteDescription", {
27511
+ get: function () {
27512
+ return this._pendingRemoteOffer ? this._pendingRemoteOffer : this._peerConnection.remoteDescription;
27513
+ },
27514
+ enumerable: false,
27515
+ configurable: true
27120
27516
  });
27121
- peerConnection.addEventListener('signalingstatechange', function onsignalingstatechange() {
27122
- if (peerConnection.signalingState === 'stable') {
27123
- self._appliedTracksToSSRCs = new Map(self._tracksToSSRCs);
27124
- }
27125
- if (!self._pendingLocalOffer && !self._pendingRemoteOffer) {
27126
- self.dispatchEvent.apply(self, arguments);
27127
- }
27517
+ Object.defineProperty(ChromeRTCPeerConnection.prototype, "signalingState", {
27518
+ get: function () {
27519
+ if (this._pendingLocalOffer) {
27520
+ return 'have-local-offer';
27521
+ }
27522
+ else if (this._pendingRemoteOffer) {
27523
+ return 'have-remote-offer';
27524
+ }
27525
+ return this._peerConnection.signalingState;
27526
+ },
27527
+ enumerable: false,
27528
+ configurable: true
27128
27529
  });
27129
- peerConnection.ontrack = function ontrack() {
27130
- // NOTE(mroberts): adapter.js's "track" event shim only kicks off if we set
27131
- // the ontrack property of the RTCPeerConnection.
27132
- };
27133
- if (typeof RTCPeerConnection.prototype.addTrack !== 'function') {
27134
- peerConnection.addStream(this._localStream);
27135
- }
27136
- util.proxyProperties(RTCPeerConnection.prototype, this, peerConnection);
27137
- }
27138
- inherits(ChromeRTCPeerConnection, EventTarget);
27139
- if (typeof RTCPeerConnection.prototype.addTrack !== 'function') {
27140
27530
  // NOTE(mmalavalli): This shim supports our limited case of adding
27141
27531
  // all MediaStreamTracks to one MediaStream. It has been implemented this
27142
27532
  // keeping in mind that this is to be maintained only until "addTrack" is
27143
27533
  // supported natively in Chrome.
27144
- ChromeRTCPeerConnection.prototype.addTrack = function addTrack() {
27145
- var args = [].slice.call(arguments);
27146
- var track = args[0];
27534
+ ChromeRTCPeerConnection.prototype.addTrack = function (track) {
27535
+ var _a;
27536
+ var rest = [];
27537
+ for (var _i = 1; _i < arguments.length; _i++) {
27538
+ rest[_i - 1] = arguments[_i];
27539
+ }
27540
+ if (typeof this._peerConnection.addTrack === 'function') {
27541
+ return (_a = this._peerConnection).addTrack.apply(_a, __spreadArray([track], __read(rest)));
27542
+ }
27147
27543
  if (this._peerConnection.signalingState === 'closed') {
27148
- throw new Error('Cannot add MediaStreamTrack [' + track.id + ', '
27149
- + track.kind + ']: RTCPeerConnection is closed');
27544
+ throw new Error("Cannot add MediaStreamTrack [" + track.id + ", \n " + track.kind + "]: RTCPeerConnection is closed");
27150
27545
  }
27151
27546
  var sender = this._senders.get(track);
27152
27547
  if (sender && sender.track) {
27153
- throw new Error('Cannot add MediaStreamTrack [' + track.id + ', '
27154
- + track.kind + ']: RTCPeerConnection already has it');
27548
+ throw new Error("Cannot add MediaStreamTrack ['" + track.id + ", \n " + track.kind + "]: RTCPeerConnection already has it");
27155
27549
  }
27156
27550
  this._peerConnection.removeStream(this._localStream);
27157
27551
  this._localStream.addTrack(track);
@@ -27164,192 +27558,207 @@ if (typeof RTCPeerConnection.prototype.addTrack !== 'function') {
27164
27558
  // MediaStreamTracks from one MediaStream. It has been implemented this
27165
27559
  // keeping in mind that this is to be maintained only until "removeTrack" is
27166
27560
  // supported natively in Chrome.
27167
- ChromeRTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
27561
+ ChromeRTCPeerConnection.prototype.removeTrack = function (sender) {
27168
27562
  if (this._peerConnection.signalingState === 'closed') {
27169
27563
  throw new Error('Cannot remove MediaStreamTrack: RTCPeerConnection is closed');
27170
27564
  }
27171
- var track = sender.track;
27172
- if (!track) {
27173
- return;
27565
+ if (typeof this._peerConnection.addTrack === 'function') {
27566
+ try {
27567
+ return this._peerConnection.removeTrack(sender);
27568
+ }
27569
+ catch (e) {
27570
+ // NOTE(mhuynh): Do nothing. In Chrome, will throw if a 'sender was not
27571
+ // created by this peer connection'. This behavior does not seem to be
27572
+ // spec compliant, so a temporary shim is introduced. A bug has been filed,
27573
+ // and is tracked here:
27574
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=860853
27575
+ }
27174
27576
  }
27175
- sender = this._senders.get(track);
27176
- if (sender && sender.track) {
27177
- sender.track = null;
27178
- this._peerConnection.removeStream(this._localStream);
27179
- this._localStream.removeTrack(track);
27180
- this._peerConnection.addStream(this._localStream);
27577
+ else {
27578
+ var track = sender.track;
27579
+ if (!track) {
27580
+ return;
27581
+ }
27582
+ sender = this._senders.get(track);
27583
+ if (sender && sender.track) {
27584
+ sender.track = null;
27585
+ this._peerConnection.removeStream(this._localStream);
27586
+ this._localStream.removeTrack(track);
27587
+ this._peerConnection.addStream(this._localStream);
27588
+ }
27181
27589
  }
27182
27590
  };
27183
- ChromeRTCPeerConnection.prototype.getSenders = function getSenders() {
27591
+ ChromeRTCPeerConnection.prototype.getSenders = function () {
27592
+ if (typeof this._peerConnection.addTrack === 'function') {
27593
+ return this._peerConnection.getSenders();
27594
+ }
27184
27595
  return Array.from(this._senders.values());
27185
27596
  };
27186
- }
27187
- else {
27188
- ChromeRTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
27189
- if (this._peerConnection.signalingState === 'closed') {
27190
- throw new Error('Cannot remove MediaStreamTrack: RTCPeerConnection is closed');
27191
- }
27192
- try {
27193
- this._peerConnection.removeTrack(sender);
27597
+ ChromeRTCPeerConnection.prototype.addIceCandidate = function (candidate) {
27598
+ var _this = this;
27599
+ var rest = [];
27600
+ for (var _i = 1; _i < arguments.length; _i++) {
27601
+ rest[_i - 1] = arguments[_i];
27602
+ }
27603
+ var promise;
27604
+ if (this.signalingState === 'have-remote-offer') {
27605
+ // NOTE(mroberts): Because the ChromeRTCPeerConnection simulates the
27606
+ // "have-remote-offer" signalingStates, we only want to invoke the true
27607
+ // addIceCandidates method when the remote description has been applied.
27608
+ promise = this._signalingStateLatch.when('low').then(function () {
27609
+ return _this._peerConnection.addIceCandidate(candidate);
27610
+ });
27194
27611
  }
27195
- catch (e) {
27196
- // NOTE(mhuynh): Do nothing. In Chrome, will throw if a 'sender was not
27197
- // created by this peer connection'. This behavior does not seem to be
27198
- // spec compliant, so a temporary shim is introduced. A bug has been filed,
27199
- // and is tracked here:
27200
- // https://bugs.chromium.org/p/chromium/issues/detail?id=860853
27612
+ else {
27613
+ promise = this._peerConnection.addIceCandidate(candidate);
27614
+ }
27615
+ return rest.length > 0
27616
+ ? legacyPromise.apply(void 0, __spreadArray([promise], __read(rest))) : promise;
27617
+ };
27618
+ // NOTE(mroberts): The WebRTC spec does not specify that close should throw an
27619
+ // Error; however, in Chrome it does. We workaround this by checking the
27620
+ // signalingState manually.
27621
+ ChromeRTCPeerConnection.prototype.close = function () {
27622
+ if (this.signalingState !== 'closed') {
27623
+ this._pendingLocalOffer = null;
27624
+ this._pendingRemoteOffer = null;
27625
+ this._peerConnection.close();
27201
27626
  }
27202
27627
  };
27203
- }
27204
- ChromeRTCPeerConnection.prototype.addIceCandidate = function addIceCandidate(candidate) {
27205
- var args = [].slice.call(arguments);
27206
- var promise;
27207
- var self = this;
27208
- if (this.signalingState === 'have-remote-offer') {
27209
- // NOTE(mroberts): Because the ChromeRTCPeerConnection simulates the
27210
- // "have-remote-offer" signalingStates, we only want to invoke the true
27211
- // addIceCandidates method when the remote description has been applied.
27212
- promise = this._signalingStateLatch.when('low').then(function signalingStatesResolved() {
27213
- return self._peerConnection.addIceCandidate(candidate);
27214
- });
27215
- }
27216
- else {
27217
- promise = this._peerConnection.addIceCandidate(candidate);
27218
- }
27219
- return args.length > 1
27220
- ? util.legacyPromise(promise, args[1], args[2])
27221
- : promise;
27222
- };
27223
- // NOTE(mroberts): The WebRTC spec does not specify that close should throw an
27224
- // Error; however, in Chrome it does. We workaround this by checking the
27225
- // signalingState manually.
27226
- ChromeRTCPeerConnection.prototype.close = function close() {
27227
- if (this.signalingState !== 'closed') {
27228
- this._pendingLocalOffer = null;
27229
- this._pendingRemoteOffer = null;
27230
- this._peerConnection.close();
27231
- }
27232
- };
27233
- // NOTE(mroberts): Because we workaround Chrome's lack of rollback support by
27234
- // "faking" setRemoteDescription, we cannot create an answer until we actually
27235
- // apply the remote description. This means, once you call createAnswer, you
27236
- // can no longer rollback. This is acceptable for our use case because we will
27237
- // apply the newly-created answer almost immediately; however, this may be
27238
- // unacceptable for other use cases.
27239
- ChromeRTCPeerConnection.prototype.createAnswer = function createAnswer() {
27240
- var args = [].slice.call(arguments);
27241
- var promise;
27242
- var self = this;
27243
- if (this._pendingRemoteOffer) {
27244
- promise = this._peerConnection.setRemoteDescription(this._pendingRemoteOffer).then(function setRemoteDescriptionSucceeded() {
27245
- // NOTE(mroberts): The signalingStates between the ChromeRTCPeerConnection
27246
- // and the underlying RTCPeerConnection implementation have converged. We
27247
- // can unblock any pending calls to addIceCandidate now.
27248
- self._signalingStateLatch.lower();
27249
- return self._peerConnection.createAnswer();
27250
- }).then(function createAnswerSucceeded(answer) {
27251
- self._pendingRemoteOffer = null;
27252
- // NOTE(mmalavalli): If createAnswer() is called immediately after rolling back, then we no
27253
- // longer need to retain the rolled back tracks to SSRCs Map.
27254
- self._rolledBackTracksToSSRCs.clear();
27255
- return new ChromeRTCSessionDescription({
27256
- type: 'answer',
27257
- sdp: updateTrackIdsToSSRCs(self._sdpFormat, self._tracksToSSRCs, answer.sdp)
27628
+ // NOTE(mroberts): Because we workaround Chrome's lack of rollback support by
27629
+ // "faking" setRemoteDescription, we cannot create an answer until we actually
27630
+ // apply the remote description. This means, once you call createAnswer, you
27631
+ // can no longer rollback. This is acceptable for our use case because we will
27632
+ // apply the newly-created answer almost immediately; however, this may be
27633
+ // unacceptable for other use cases.
27634
+ ChromeRTCPeerConnection.prototype.createAnswer = function () {
27635
+ var _this = this;
27636
+ var args = [];
27637
+ for (var _i = 0; _i < arguments.length; _i++) {
27638
+ args[_i] = arguments[_i];
27639
+ }
27640
+ var promise;
27641
+ if (this._pendingRemoteOffer) {
27642
+ promise = this._peerConnection.setRemoteDescription(this._pendingRemoteOffer).then(function () {
27643
+ // NOTE(mroberts): The signalingStates between the ChromeRTCPeerConnection
27644
+ // and the underlying RTCPeerConnection implementation have converged. We
27645
+ // can unblock any pending calls to addIceCandidate now.
27646
+ _this._signalingStateLatch.lower();
27647
+ return _this._peerConnection.createAnswer();
27648
+ }).then(function (answer) {
27649
+ _this._pendingRemoteOffer = null;
27650
+ // NOTE(mmalavalli): If createAnswer() is called immediately after rolling back, then we no
27651
+ // longer need to retain the rolled back tracks to SSRCs Map.
27652
+ _this._rolledBackTracksToSSRCs.clear();
27653
+ return new ChromeRTCSessionDescription({
27654
+ type: 'answer',
27655
+ sdp: updateTrackIdsToSSRCs(_this._sdpFormat, _this._tracksToSSRCs, answer.sdp)
27656
+ });
27657
+ }, function (error) {
27658
+ _this._pendingRemoteOffer = null;
27659
+ throw error;
27258
27660
  });
27259
- }, function setRemoteDescriptionOrCreateAnswerFailed(error) {
27260
- self._pendingRemoteOffer = null;
27261
- throw error;
27262
- });
27263
- }
27264
- else {
27265
- promise = this._peerConnection.createAnswer().then(function (answer) {
27266
- // NOTE(mmalavalli): If createAnswer() is called immediately after rolling back, then we no
27267
- // longer need to retain the rolled back tracks to SSRCs Map.
27268
- self._rolledBackTracksToSSRCs.clear();
27269
- return new ChromeRTCSessionDescription({
27270
- type: 'answer',
27271
- sdp: updateTrackIdsToSSRCs(self._sdpFormat, self._tracksToSSRCs, answer.sdp)
27661
+ }
27662
+ else {
27663
+ promise = this._peerConnection.createAnswer().then(function (answer) {
27664
+ // NOTE(mmalavalli): If createAnswer() is called immediately after rolling back, then we no
27665
+ // longer need to retain the rolled back tracks to SSRCs Map.
27666
+ _this._rolledBackTracksToSSRCs.clear();
27667
+ return new ChromeRTCSessionDescription({
27668
+ type: 'answer',
27669
+ sdp: updateTrackIdsToSSRCs(_this._sdpFormat, _this._tracksToSSRCs, answer.sdp)
27670
+ });
27272
27671
  });
27273
- });
27274
- }
27275
- return args.length > 1
27276
- ? util.legacyPromise(promise, args[0], args[1])
27277
- : promise;
27278
- };
27279
- ChromeRTCPeerConnection.prototype.createOffer = function createOffer() {
27280
- var args = [].slice.call(arguments);
27281
- var options = (args.length > 1 ? args[2] : args[0]) || {};
27282
- var self = this;
27283
- if (isIOSChrome()) {
27284
- // NOTE (joma): From SafariRTCPeerConnection in order to support iOS Chrome.
27285
- if (options.offerToReceiveVideo && !this._audioTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'audio'))) {
27286
- delete options.offerToReceiveAudio;
27287
- try {
27288
- this._audioTransceiver = isUnifiedPlan
27289
- ? this.addTransceiver('audio', { direction: 'recvonly' })
27290
- : this.addTransceiver('audio');
27291
- }
27292
- catch (e) {
27293
- return Promise.reject(e);
27294
- }
27295
27672
  }
27296
- if (options.offerToReceiveVideo && !this._videoTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'video'))) {
27297
- delete options.offerToReceiveVideo;
27298
- try {
27299
- this._videoTransceiver = isUnifiedPlan
27300
- ? this.addTransceiver('video', { direction: 'recvonly' })
27301
- : this.addTransceiver('video');
27673
+ return args.length > 1
27674
+ ? legacyPromise.apply(void 0, __spreadArray([promise], __read(args))) : promise;
27675
+ };
27676
+ ChromeRTCPeerConnection.prototype.createOffer = function () {
27677
+ var _this = this;
27678
+ var args = [];
27679
+ for (var _i = 0; _i < arguments.length; _i++) {
27680
+ args[_i] = arguments[_i];
27681
+ }
27682
+ var _a = __read(args, 3), arg1 = _a[0], arg2 = _a[1], arg3 = _a[2];
27683
+ var options = arg3 || arg1 || {};
27684
+ if (isIOSChrome()) {
27685
+ // NOTE (joma): From SafariRTCPeerConnection in order to support iOS Chrome.
27686
+ if (options.offerToReceiveVideo && !this._audioTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'audio'))) {
27687
+ delete options.offerToReceiveAudio;
27688
+ try {
27689
+ this._audioTransceiver = isUnifiedPlan
27690
+ ? this.addTransceiver('audio', { direction: 'recvonly' })
27691
+ : this.addTransceiver('audio');
27692
+ }
27693
+ catch (e) {
27694
+ return Promise.reject(e);
27695
+ }
27302
27696
  }
27303
- catch (e) {
27304
- return Promise.reject(e);
27697
+ if (options.offerToReceiveVideo && !this._videoTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'video'))) {
27698
+ delete options.offerToReceiveVideo;
27699
+ try {
27700
+ this._videoTransceiver = isUnifiedPlan
27701
+ ? this.addTransceiver('video', { direction: 'recvonly' })
27702
+ : this.addTransceiver('video');
27703
+ }
27704
+ catch (e) {
27705
+ return Promise.reject(e);
27706
+ }
27305
27707
  }
27306
27708
  }
27307
- }
27308
- var promise = this._peerConnection.createOffer(options).then(function (offer) {
27309
- // NOTE(mmalavalli): If createOffer() is called immediately after rolling back, then we no
27310
- // longer need to retain the rolled back tracks to SSRCs Map.
27311
- self._rolledBackTracksToSSRCs.clear();
27312
- return new ChromeRTCSessionDescription({
27313
- type: offer.type,
27314
- sdp: updateTrackIdsToSSRCs(self._sdpFormat, self._tracksToSSRCs, offer.sdp)
27709
+ var promise = this._peerConnection.createOffer(options).then(function (offer) {
27710
+ // NOTE(mmalavalli): If createOffer() is called immediately after rolling back, then we no
27711
+ // longer need to retain the rolled back tracks to SSRCs Map.
27712
+ _this._rolledBackTracksToSSRCs.clear();
27713
+ return new ChromeRTCSessionDescription({
27714
+ type: offer.type,
27715
+ sdp: updateTrackIdsToSSRCs(_this._sdpFormat, _this._tracksToSSRCs, offer.sdp)
27716
+ });
27315
27717
  });
27316
- });
27317
- return args.length > 1
27318
- ? util.legacyPromise(promise, args[0], args[1])
27319
- : promise;
27320
- };
27321
- ChromeRTCPeerConnection.prototype.createDataChannel = function createDataChannel(label, dataChannelDict) {
27322
- dataChannelDict = shimDataChannelInit(dataChannelDict);
27323
- var dataChannel = this._peerConnection.createDataChannel(label, dataChannelDict);
27324
- shimDataChannel(dataChannel);
27325
- return dataChannel;
27326
- };
27327
- ChromeRTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
27328
- var args = [].slice.call(arguments);
27329
- var description = args[0];
27330
- // NOTE(mmalavalli): If setLocalDescription() is called immediately after rolling back,
27331
- // then we need to restore the rolled back tracks to SSRCs Map.
27332
- if (this._rolledBackTracksToSSRCs.size > 0) {
27333
- this._tracksToSSRCs = new Map(this._rolledBackTracksToSSRCs);
27718
+ return args.length > 1
27719
+ ? legacyPromise(promise, arg1, arg2)
27720
+ : promise;
27721
+ };
27722
+ ChromeRTCPeerConnection.prototype.createDataChannel = function (label, dataChannelDict) {
27723
+ dataChannelDict = shimDataChannelInit(dataChannelDict);
27724
+ var dataChannel = this._peerConnection.createDataChannel(label, dataChannelDict);
27725
+ shimDataChannel(dataChannel);
27726
+ return dataChannel;
27727
+ };
27728
+ ChromeRTCPeerConnection.prototype.setLocalDescription = function () {
27729
+ var args = [];
27730
+ for (var _i = 0; _i < arguments.length; _i++) {
27731
+ args[_i] = arguments[_i];
27732
+ }
27733
+ var _a = __read(args, 3), description = _a[0], arg1 = _a[1], arg2 = _a[2];
27734
+ // NOTE(mmalavalli): If setLocalDescription() is called immediately after rolling back,
27735
+ // then we need to restore the rolled back tracks to SSRCs Map.
27736
+ if (this._rolledBackTracksToSSRCs.size > 0) {
27737
+ this._tracksToSSRCs = new Map(this._rolledBackTracksToSSRCs);
27738
+ this._rolledBackTracksToSSRCs.clear();
27739
+ }
27740
+ var promise = setDescription(this, true, description);
27741
+ return args.length > 1
27742
+ ? legacyPromise(promise, arg1, arg2)
27743
+ : promise;
27744
+ };
27745
+ ChromeRTCPeerConnection.prototype.setRemoteDescription = function () {
27746
+ var args = [];
27747
+ for (var _i = 0; _i < arguments.length; _i++) {
27748
+ args[_i] = arguments[_i];
27749
+ }
27750
+ var _a = __read(args, 3), description = _a[0], arg1 = _a[1], arg2 = _a[2];
27751
+ // NOTE(mmalavalli): If setRemoteDescription() is called immediately after rolling back,
27752
+ // then we no longer need to retain the rolled back tracks to SSRCs Map.
27334
27753
  this._rolledBackTracksToSSRCs.clear();
27335
- }
27336
- var promise = setDescription(this, true, description);
27337
- return args.length > 1
27338
- ? util.legacyPromise(promise, args[1], args[2])
27339
- : promise;
27340
- };
27341
- ChromeRTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
27342
- var args = [].slice.call(arguments);
27343
- var description = args[0];
27344
- // NOTE(mmalavalli): If setRemoteDescription() is called immediately after rolling back,
27345
- // then we no longer need to retain the rolled back tracks to SSRCs Map.
27346
- this._rolledBackTracksToSSRCs.clear();
27347
- var promise = setDescription(this, false, description);
27348
- return args.length > 1
27349
- ? util.legacyPromise(promise, args[1], args[2])
27350
- : promise;
27351
- };
27352
- util.delegateMethods(RTCPeerConnection.prototype, ChromeRTCPeerConnection.prototype, '_peerConnection');
27754
+ var promise = setDescription(this, false, description);
27755
+ return args.length > 1
27756
+ ? legacyPromise(promise, arg1, arg2)
27757
+ : promise;
27758
+ };
27759
+ return ChromeRTCPeerConnection;
27760
+ }(EventTarget));
27761
+ delegateMethods(RTCPeerConnection.prototype, ChromeRTCPeerConnection.prototype, '_peerConnection');
27353
27762
  // NOTE(mroberts): We workaround Chrome's lack of rollback support, per the
27354
27763
  // workaround suggested here: https://bugs.chromium.org/p/webrtc/issues/detail?id=5738#c3
27355
27764
  // Namely, we "fake" setting the local or remote description and instead buffer
@@ -27384,8 +27793,7 @@ function setDescription(peerConnection, local, description) {
27384
27793
  else if (description.type === 'offer') {
27385
27794
  if (peerConnection.signalingState !== intermediateState && peerConnection.signalingState !== 'stable') {
27386
27795
  // NOTE(mroberts): Error message copied from Firefox.
27387
- return Promise.reject(new Error('Cannot set ' + (local ? 'local' : 'remote') +
27388
- ' offer in state ' + peerConnection.signalingState));
27796
+ return Promise.reject(new Error("Cannot set " + (local ? 'local' : 'remote') + " offer in state " + peerConnection.signalingState));
27389
27797
  }
27390
27798
  // We need to save this local offer in case of a rollback. We also need to
27391
27799
  // check to see if the signalingState between the ChromeRTCPeerConnection
@@ -27399,16 +27807,13 @@ function setDescription(peerConnection, local, description) {
27399
27807
  promise = Promise.resolve();
27400
27808
  // Only dispatch a signalingstatechange event if we transitioned.
27401
27809
  if (peerConnection.signalingState !== previousSignalingState) {
27402
- promise.then(function dispatchSignalingStateChangeEvent() {
27403
- peerConnection.dispatchEvent(new Event('signalingstatechange'));
27404
- });
27810
+ promise.then(function () { return peerConnection.dispatchEvent(new Event('signalingstatechange')); });
27405
27811
  }
27406
27812
  }
27407
27813
  else if (description.type === 'rollback') {
27408
27814
  if (peerConnection.signalingState !== intermediateState) {
27409
27815
  // NOTE(mroberts): Error message copied from Firefox.
27410
- promise = Promise.reject(new Error('Cannot rollback ' +
27411
- (local ? 'local' : 'remote') + ' description in ' + peerConnection.signalingState));
27816
+ promise = Promise.reject(new Error("Cannot rollback " + (local ? 'local' : 'remote') + " description in " + peerConnection.signalingState));
27412
27817
  }
27413
27818
  else {
27414
27819
  // Reset the pending offer.
@@ -27420,9 +27825,7 @@ function setDescription(peerConnection, local, description) {
27420
27825
  peerConnection._rolledBackTracksToSSRCs = new Map(peerConnection._tracksToSSRCs);
27421
27826
  peerConnection._tracksToSSRCs = new Map(peerConnection._appliedTracksToSSRCs);
27422
27827
  promise = Promise.resolve();
27423
- promise.then(function dispatchSignalingStateChangeEvent() {
27424
- peerConnection.dispatchEvent(new Event('signalingstatechange'));
27425
- });
27828
+ promise.then(function () { return peerConnection.dispatchEvent(new Event('signalingstatechange')); });
27426
27829
  }
27427
27830
  }
27428
27831
  return promise || peerConnection._peerConnection[setLocalDescription](unwrap(description));
@@ -27430,10 +27833,10 @@ function setDescription(peerConnection, local, description) {
27430
27833
  function setRemoteAnswer(peerConnection, answer) {
27431
27834
  // Apply the pending local offer.
27432
27835
  var pendingLocalOffer = peerConnection._pendingLocalOffer;
27433
- return peerConnection._peerConnection.setLocalDescription(pendingLocalOffer).then(function setLocalOfferSucceeded() {
27836
+ return peerConnection._peerConnection.setLocalDescription(pendingLocalOffer).then(function () {
27434
27837
  peerConnection._pendingLocalOffer = null;
27435
27838
  return peerConnection.setRemoteDescription(answer);
27436
- }).then(function setRemoteAnswerSucceeded() {
27839
+ }).then(function () {
27437
27840
  // NOTE(mroberts): The signalingStates between the ChromeRTCPeerConnection
27438
27841
  // and the underlying RTCPeerConnection implementation have converged. We
27439
27842
  // can unblock any pending calls to addIceCandidate now.
@@ -27448,8 +27851,10 @@ function setRemoteAnswer(peerConnection, answer) {
27448
27851
  * @returns {boolean}
27449
27852
  */
27450
27853
  function hasReceiversForTracksOfKind(peerConnection, kind) {
27451
- return !!peerConnection.getTransceivers().find(function (transceiver) {
27452
- return transceiver.receiver && transceiver.receiver.track && transceiver.receiver.track.kind === kind;
27854
+ return !!peerConnection.getTransceivers().find(function (_a) {
27855
+ var _b = _a.receiver, receiver = _b === void 0 ? {} : _b;
27856
+ var _c = receiver.track, track = _c === void 0 ? {} : _c;
27857
+ return track.kind === kind;
27453
27858
  });
27454
27859
  }
27455
27860
  function unwrap(description) {
@@ -27521,19 +27926,54 @@ function shimDataChannel(dataChannel) {
27521
27926
  */
27522
27927
  function updateTrackIdsToSSRCs(sdpFormat, tracksToSSRCs, sdp) {
27523
27928
  return sdpFormat === 'unified'
27524
- ? sdpUtils.updateUnifiedPlanTrackIdsToSSRCs(tracksToSSRCs, sdp)
27525
- : sdpUtils.updatePlanBTrackIdsToSSRCs(tracksToSSRCs, sdp);
27929
+ ? updateUnifiedPlanTrackIdsToSSRCs(tracksToSSRCs, sdp)
27930
+ : updatePlanBTrackIdsToSSRCs(tracksToSSRCs, sdp);
27526
27931
  }
27527
27932
  module.exports = ChromeRTCPeerConnection;
27528
27933
 
27529
- },{"../../vendor/inherits":150,"../mediastream":158,"../rtcrtpsender":165,"../rtcsessiondescription/chrome":166,"../util":170,"../util/eventtarget":169,"../util/latch":171,"../util/sdp":172}],162:[function(require,module,exports){
27934
+ },{"../../eventtarget":11,"../mediastream":159,"../rtcrtpsender":166,"../rtcsessiondescription/chrome":167,"../util":170,"../util/latch":171,"../util/sdp":172}],163:[function(require,module,exports){
27530
27935
  /* globals RTCPeerConnection */
27531
27936
  'use strict';
27532
- var EventTarget = require('../util/eventtarget');
27937
+ var __extends = (this && this.__extends) || (function () {
27938
+ var extendStatics = function (d, b) {
27939
+ extendStatics = Object.setPrototypeOf ||
27940
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27941
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
27942
+ return extendStatics(d, b);
27943
+ };
27944
+ return function (d, b) {
27945
+ if (typeof b !== "function" && b !== null)
27946
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
27947
+ extendStatics(d, b);
27948
+ function __() { this.constructor = d; }
27949
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27950
+ };
27951
+ })();
27952
+ var __read = (this && this.__read) || function (o, n) {
27953
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27954
+ if (!m) return o;
27955
+ var i = m.call(o), r, ar = [], e;
27956
+ try {
27957
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27958
+ }
27959
+ catch (error) { e = { error: error }; }
27960
+ finally {
27961
+ try {
27962
+ if (r && !r.done && (m = i["return"])) m.call(i);
27963
+ }
27964
+ finally { if (e) throw e.error; }
27965
+ }
27966
+ return ar;
27967
+ };
27968
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
27969
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
27970
+ to[j] = from[i];
27971
+ return to;
27972
+ };
27973
+ var EventTarget = require('../../eventtarget');
27533
27974
  var FirefoxRTCSessionDescription = require('../rtcsessiondescription/firefox');
27534
- var inherits = require('../../vendor/inherits');
27535
27975
  var updateTracksToSSRCs = require('../util/sdp').updateUnifiedPlanTrackIdsToSSRCs;
27536
- var util = require('../util');
27976
+ var _a = require('../util'), delegateMethods = _a.delegateMethods, interceptEvent = _a.interceptEvent, legacyPromise = _a.legacyPromise, proxyProperties = _a.proxyProperties;
27537
27977
  // NOTE(mroberts): This class wraps Firefox's RTCPeerConnection implementation.
27538
27978
  // It provides some functionality not currently present in Firefox, namely the
27539
27979
  // abilities to
@@ -27554,201 +27994,212 @@ var util = require('../util');
27554
27994
  //
27555
27995
  // https://bugzilla.mozilla.org/show_bug.cgi?id=1240897
27556
27996
  //
27557
- function FirefoxRTCPeerConnection(configuration) {
27558
- if (!(this instanceof FirefoxRTCPeerConnection)) {
27559
- return new FirefoxRTCPeerConnection(configuration);
27560
- }
27561
- EventTarget.call(this);
27562
- util.interceptEvent(this, 'signalingstatechange');
27563
- /* eslint new-cap:0 */
27564
- var peerConnection = new RTCPeerConnection(configuration);
27565
- Object.defineProperties(this, {
27566
- _initiallyNegotiatedDtlsRole: {
27567
- value: null,
27568
- writable: true
27569
- },
27570
- _isClosed: {
27571
- value: false,
27572
- writable: true
27573
- },
27574
- _peerConnection: {
27575
- value: peerConnection
27576
- },
27577
- _rollingBack: {
27578
- value: false,
27579
- writable: true
27580
- },
27581
- _tracksToSSRCs: {
27582
- value: new Map()
27583
- },
27584
- iceGatheringState: {
27585
- enumerable: true,
27586
- get: function () {
27587
- return this._isClosed ? 'complete' : this._peerConnection.iceGatheringState;
27997
+ var FirefoxRTCPeerConnection = /** @class */ (function (_super) {
27998
+ __extends(FirefoxRTCPeerConnection, _super);
27999
+ function FirefoxRTCPeerConnection(configuration) {
28000
+ var _this = _super.call(this) || this;
28001
+ interceptEvent(_this, 'signalingstatechange');
28002
+ /* eslint new-cap:0 */
28003
+ var peerConnection = new RTCPeerConnection(configuration);
28004
+ Object.defineProperties(_this, {
28005
+ _initiallyNegotiatedDtlsRole: {
28006
+ value: null,
28007
+ writable: true
28008
+ },
28009
+ _isClosed: {
28010
+ value: false,
28011
+ writable: true
28012
+ },
28013
+ _peerConnection: {
28014
+ value: peerConnection
28015
+ },
28016
+ _rollingBack: {
28017
+ value: false,
28018
+ writable: true
28019
+ },
28020
+ _tracksToSSRCs: {
28021
+ value: new Map()
28022
+ },
28023
+ // NOTE(mmalavalli): Firefox throws a TypeError when the PeerConnection's
28024
+ // prototype's "peerIdentity" property is accessed. In order to overcome
28025
+ // this, we ignore this property while delegating methods.
28026
+ // Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=1363815
28027
+ peerIdentity: {
28028
+ enumerable: true,
28029
+ value: Promise.resolve({
28030
+ idp: '',
28031
+ name: ''
28032
+ })
27588
28033
  }
27589
- },
27590
- localDescription: {
27591
- enumerable: true,
27592
- get: function () {
27593
- return overwriteWithInitiallyNegotiatedDtlsRole(this._peerConnection.localDescription, this._initiallyNegotiatedDtlsRole);
28034
+ });
28035
+ var previousSignalingState;
28036
+ peerConnection.addEventListener('signalingstatechange', function () {
28037
+ var args = [];
28038
+ for (var _i = 0; _i < arguments.length; _i++) {
28039
+ args[_i] = arguments[_i];
27594
28040
  }
27595
- },
27596
- signalingState: {
27597
- enumerable: true,
27598
- get: function () {
27599
- return this._isClosed ? 'closed' : this._peerConnection.signalingState;
28041
+ if (!_this._rollingBack && _this.signalingState !== previousSignalingState) {
28042
+ previousSignalingState = _this.signalingState;
28043
+ // NOTE(mmalavalli): In Firefox, 'signalingstatechange' event is
28044
+ // triggered synchronously in the same tick after
28045
+ // RTCPeerConnection#close() is called. So we mimic Chrome's behavior
28046
+ // by triggering 'signalingstatechange' on the next tick.
28047
+ if (_this._isClosed) {
28048
+ setTimeout(function () { return _this.dispatchEvent.apply(_this, __spreadArray([], __read(args))); });
28049
+ }
28050
+ else {
28051
+ _this.dispatchEvent.apply(_this, __spreadArray([], __read(args)));
28052
+ }
27600
28053
  }
27601
- }
28054
+ });
28055
+ proxyProperties(RTCPeerConnection.prototype, _this, peerConnection);
28056
+ return _this;
28057
+ }
28058
+ Object.defineProperty(FirefoxRTCPeerConnection.prototype, "iceGatheringState", {
28059
+ get: function () {
28060
+ return this._isClosed ? 'complete' : this._peerConnection.iceGatheringState;
28061
+ },
28062
+ enumerable: false,
28063
+ configurable: true
27602
28064
  });
27603
- var self = this;
27604
- var previousSignalingState;
27605
- peerConnection.addEventListener('signalingstatechange', function onsignalingstatechange() {
27606
- if (!self._rollingBack && self.signalingState !== previousSignalingState) {
27607
- previousSignalingState = self.signalingState;
27608
- // NOTE(mmalavalli): In Firefox, 'signalingstatechange' event is
27609
- // triggered synchronously in the same tick after
27610
- // RTCPeerConnection#close() is called. So we mimic Chrome's behavior
27611
- // by triggering 'signalingstatechange' on the next tick.
27612
- var dispatchEventToSelf = self.dispatchEvent.apply.bind(self.dispatchEvent, self, arguments);
27613
- if (self._isClosed) {
27614
- setTimeout(dispatchEventToSelf);
27615
- }
27616
- else {
27617
- dispatchEventToSelf();
27618
- }
27619
- }
28065
+ Object.defineProperty(FirefoxRTCPeerConnection.prototype, "localDescription", {
28066
+ get: function () {
28067
+ return overwriteWithInitiallyNegotiatedDtlsRole(this._peerConnection.localDescription, this._initiallyNegotiatedDtlsRole);
28068
+ },
28069
+ enumerable: false,
28070
+ configurable: true
27620
28071
  });
27621
- util.proxyProperties(RTCPeerConnection.prototype, this, peerConnection);
27622
- }
27623
- inherits(FirefoxRTCPeerConnection, EventTarget);
27624
- // NOTE(mmalavalli): Firefox throws a TypeError when the PeerConnection's
27625
- // prototype's "peerIdentity" property is accessed. In order to overcome
27626
- // this, we ignore this property while delegating methods.
27627
- // Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=1363815
27628
- Object.defineProperty(FirefoxRTCPeerConnection.prototype, 'peerIdentity', {
27629
- enumerable: true,
27630
- value: Promise.resolve({
27631
- idp: '',
27632
- name: ''
27633
- })
27634
- });
27635
- FirefoxRTCPeerConnection.prototype.createAnswer = function createAnswer() {
27636
- var args = [].slice.call(arguments);
27637
- var promise;
27638
- var self = this;
27639
- promise = this._peerConnection.createAnswer().then(function createAnswerSucceeded(answer) {
27640
- saveInitiallyNegotiatedDtlsRole(self, answer);
27641
- return overwriteWithInitiallyNegotiatedDtlsRole(answer, self._initiallyNegotiatedDtlsRole);
28072
+ Object.defineProperty(FirefoxRTCPeerConnection.prototype, "signalingState", {
28073
+ get: function () {
28074
+ return this._isClosed ? 'closed' : this._peerConnection.signalingState;
28075
+ },
28076
+ enumerable: false,
28077
+ configurable: true
27642
28078
  });
27643
- return typeof args[0] === 'function'
27644
- ? util.legacyPromise(promise, args[0], args[1])
27645
- : promise;
27646
- };
27647
- // NOTE(mroberts): The WebRTC spec allows you to call createOffer from any
27648
- // signalingState other than "closed"; however, Firefox has not yet implemented
27649
- // this (https://bugzilla.mozilla.org/show_bug.cgi?id=1072388). We workaround
27650
- // this by rolling back if we are in state "have-local-offer" or
27651
- // "have-remote-offer". This is acceptable for our use case because we will
27652
- // apply the newly-created offer almost immediately; however, this may be
27653
- // unacceptable for other use cases.
27654
- FirefoxRTCPeerConnection.prototype.createOffer = function createOffer() {
27655
- var args = [].slice.call(arguments);
27656
- var options = (args.length > 1 ? args[2] : args[0]) || {};
27657
- var promise;
27658
- var self = this;
27659
- if (this.signalingState === 'have-local-offer' ||
27660
- this.signalingState === 'have-remote-offer') {
27661
- var local = this.signalingState === 'have-local-offer';
27662
- promise = rollback(this, local, function rollbackSucceeded() {
27663
- return self.createOffer(options);
27664
- });
27665
- }
27666
- else {
27667
- promise = self._peerConnection.createOffer(options);
27668
- }
27669
- promise = promise.then(function (offer) {
27670
- return new FirefoxRTCSessionDescription({
27671
- type: offer.type,
27672
- sdp: updateTracksToSSRCs(self._tracksToSSRCs, offer.sdp)
28079
+ FirefoxRTCPeerConnection.prototype.createAnswer = function () {
28080
+ var _this = this;
28081
+ var args = [];
28082
+ for (var _i = 0; _i < arguments.length; _i++) {
28083
+ args[_i] = arguments[_i];
28084
+ }
28085
+ var promise;
28086
+ promise = this._peerConnection.createAnswer().then(function (answer) {
28087
+ saveInitiallyNegotiatedDtlsRole(_this, answer);
28088
+ return overwriteWithInitiallyNegotiatedDtlsRole(answer, _this._initiallyNegotiatedDtlsRole);
28089
+ });
28090
+ return typeof args[0] === 'function'
28091
+ ? legacyPromise.apply(void 0, __spreadArray([promise], __read(args))) : promise;
28092
+ };
28093
+ // NOTE(mroberts): The WebRTC spec allows you to call createOffer from any
28094
+ // signalingState other than "closed"; however, Firefox has not yet implemented
28095
+ // this (https://bugzilla.mozilla.org/show_bug.cgi?id=1072388). We workaround
28096
+ // this by rolling back if we are in state "have-local-offer" or
28097
+ // "have-remote-offer". This is acceptable for our use case because we will
28098
+ // apply the newly-created offer almost immediately; however, this may be
28099
+ // unacceptable for other use cases.
28100
+ FirefoxRTCPeerConnection.prototype.createOffer = function () {
28101
+ var _this = this;
28102
+ var args = [];
28103
+ for (var _i = 0; _i < arguments.length; _i++) {
28104
+ args[_i] = arguments[_i];
28105
+ }
28106
+ var _a = __read(args, 3), arg1 = _a[0], arg2 = _a[1], arg3 = _a[2];
28107
+ var options = arg3 || arg1 || {};
28108
+ var promise;
28109
+ if (this.signalingState === 'have-local-offer' ||
28110
+ this.signalingState === 'have-remote-offer') {
28111
+ var local = this.signalingState === 'have-local-offer';
28112
+ promise = rollback(this, local, function () { return _this.createOffer(options); });
28113
+ }
28114
+ else {
28115
+ promise = this._peerConnection.createOffer(options);
28116
+ }
28117
+ promise = promise.then(function (offer) {
28118
+ return new FirefoxRTCSessionDescription({
28119
+ type: offer.type,
28120
+ sdp: updateTracksToSSRCs(_this._tracksToSSRCs, offer.sdp)
28121
+ });
27673
28122
  });
27674
- });
27675
- return args.length > 1
27676
- ? util.legacyPromise(promise, args[0], args[1])
27677
- : promise;
27678
- };
27679
- // NOTE(mroberts): While Firefox will reject the Promise returned by
27680
- // setLocalDescription when called from signalingState "have-local-offer" with
27681
- // an answer, it still updates the .localDescription property. We workaround
27682
- // this by explicitly handling this case.
27683
- FirefoxRTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
27684
- var args = [].slice.call(arguments);
27685
- var description = args[0];
27686
- var promise;
27687
- if (description && description.type === 'answer' && this.signalingState === 'have-local-offer') {
27688
- promise = Promise.reject(new Error('Cannot set local answer in state have-local-offer'));
27689
- }
27690
- if (promise) {
27691
28123
  return args.length > 1
27692
- ? util.legacyPromise(promise, args[1], args[2])
28124
+ ? legacyPromise(promise, arg1, arg2)
27693
28125
  : promise;
27694
- }
27695
- return this._peerConnection.setLocalDescription.apply(this._peerConnection, args);
27696
- };
27697
- // NOTE(mroberts): The WebRTC spec allows you to call setRemoteDescription with
27698
- // an offer multiple times in signalingState "have-remote-offer"; however,
27699
- // Firefox has not yet implemented this (https://bugzilla.mozilla.org/show_bug.cgi?id=1072388).
27700
- // We workaround this by rolling back if we are in state "have-remote-offer".
27701
- // This is acceptable for our use case; however, this may be unacceptable for
27702
- // other use cases.
27703
- //
27704
- // While Firefox will reject the Promise returned by setRemoteDescription when
27705
- // called from signalingState "have-remote-offer" with an answer, it sill
27706
- // updates the .remoteDescription property. We workaround this by explicitly
27707
- // handling this case.
27708
- FirefoxRTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
27709
- var args = [].slice.call(arguments);
27710
- var description = args[0];
27711
- var promise;
27712
- var self = this;
27713
- if (description && this.signalingState === 'have-remote-offer') {
27714
- if (description.type === 'answer') {
27715
- promise = Promise.reject(new Error('Cannot set remote answer in state have-remote-offer'));
28126
+ };
28127
+ // NOTE(mroberts): While Firefox will reject the Promise returned by
28128
+ // setLocalDescription when called from signalingState "have-local-offer" with
28129
+ // an answer, it still updates the .localDescription property. We workaround
28130
+ // this by explicitly handling this case.
28131
+ FirefoxRTCPeerConnection.prototype.setLocalDescription = function () {
28132
+ var _a;
28133
+ var args = [];
28134
+ for (var _i = 0; _i < arguments.length; _i++) {
28135
+ args[_i] = arguments[_i];
27716
28136
  }
27717
- else if (description.type === 'offer') {
27718
- promise = rollback(this, false, function rollbackSucceeded() {
27719
- return self._peerConnection.setRemoteDescription(description);
27720
- });
28137
+ var _b = __read(args), description = _b[0], rest = _b.slice(1);
28138
+ var promise;
28139
+ if (description && description.type === 'answer' && this.signalingState === 'have-local-offer') {
28140
+ promise = Promise.reject(new Error('Cannot set local answer in state have-local-offer'));
27721
28141
  }
27722
- }
27723
- if (!promise) {
27724
- promise = this._peerConnection.setRemoteDescription(description);
27725
- }
27726
- promise = promise.then(function setRemoteDescriptionSucceeded() {
27727
- saveInitiallyNegotiatedDtlsRole(self, description, true);
27728
- });
27729
- return args.length > 1
27730
- ? util.legacyPromise(promise, args[1], args[2])
27731
- : promise;
27732
- };
27733
- // NOTE(mroberts): The WebRTC spec specifies that the PeerConnection's internal
27734
- // isClosed slot should immediately be set to true; however, in Firefox it
27735
- // occurs in the next tick. We workaround this by tracking isClosed manually.
27736
- FirefoxRTCPeerConnection.prototype.close = function close() {
27737
- if (this.signalingState !== 'closed') {
27738
- this._isClosed = true;
27739
- this._peerConnection.close();
27740
- }
27741
- };
27742
- util.delegateMethods(RTCPeerConnection.prototype, FirefoxRTCPeerConnection.prototype, '_peerConnection');
28142
+ if (promise) {
28143
+ return args.length > 1
28144
+ ? legacyPromise.apply(void 0, __spreadArray([promise], __read(rest))) : promise;
28145
+ }
28146
+ return (_a = this._peerConnection).setLocalDescription.apply(_a, __spreadArray([], __read(args)));
28147
+ };
28148
+ // NOTE(mroberts): The WebRTC spec allows you to call setRemoteDescription with
28149
+ // an offer multiple times in signalingState "have-remote-offer"; however,
28150
+ // Firefox has not yet implemented this (https://bugzilla.mozilla.org/show_bug.cgi?id=1072388).
28151
+ // We workaround this by rolling back if we are in state "have-remote-offer".
28152
+ // This is acceptable for our use case; however, this may be unacceptable for
28153
+ // other use cases.
28154
+ //
28155
+ // While Firefox will reject the Promise returned by setRemoteDescription when
28156
+ // called from signalingState "have-remote-offer" with an answer, it sill
28157
+ // updates the .remoteDescription property. We workaround this by explicitly
28158
+ // handling this case.
28159
+ FirefoxRTCPeerConnection.prototype.setRemoteDescription = function () {
28160
+ var _this = this;
28161
+ var args = [];
28162
+ for (var _i = 0; _i < arguments.length; _i++) {
28163
+ args[_i] = arguments[_i];
28164
+ }
28165
+ var _a = __read(args), description = _a[0], rest = _a.slice(1);
28166
+ var promise;
28167
+ if (description && this.signalingState === 'have-remote-offer') {
28168
+ if (description.type === 'answer') {
28169
+ promise = Promise.reject(new Error('Cannot set remote answer in state have-remote-offer'));
28170
+ }
28171
+ else if (description.type === 'offer') {
28172
+ promise = rollback(this, false, function () { return _this._peerConnection.setRemoteDescription(description); });
28173
+ }
28174
+ }
28175
+ if (!promise) {
28176
+ promise = this._peerConnection.setRemoteDescription(description);
28177
+ }
28178
+ promise = promise.then(function () { return saveInitiallyNegotiatedDtlsRole(_this, description, true); });
28179
+ return args.length > 1
28180
+ ? legacyPromise.apply(void 0, __spreadArray([promise], __read(rest))) : promise;
28181
+ };
28182
+ // NOTE(mroberts): The WebRTC spec specifies that the PeerConnection's internal
28183
+ // isClosed slot should immediately be set to true; however, in Firefox it
28184
+ // occurs in the next tick. We workaround this by tracking isClosed manually.
28185
+ FirefoxRTCPeerConnection.prototype.close = function () {
28186
+ if (this.signalingState !== 'closed') {
28187
+ this._isClosed = true;
28188
+ this._peerConnection.close();
28189
+ }
28190
+ };
28191
+ return FirefoxRTCPeerConnection;
28192
+ }(EventTarget));
28193
+ delegateMethods(RTCPeerConnection.prototype, FirefoxRTCPeerConnection.prototype, '_peerConnection');
27743
28194
  function rollback(peerConnection, local, onceRolledBack) {
27744
28195
  var setLocalDescription = local ? 'setLocalDescription' : 'setRemoteDescription';
27745
28196
  peerConnection._rollingBack = true;
27746
28197
  return peerConnection._peerConnection[setLocalDescription](new FirefoxRTCSessionDescription({
27747
28198
  type: 'rollback'
27748
- })).then(onceRolledBack).then(function onceRolledBackSucceeded(result) {
28199
+ })).then(onceRolledBack).then(function (result) {
27749
28200
  peerConnection._rollingBack = false;
27750
28201
  return result;
27751
- }, function rollbackOrOnceRolledBackFailed(error) {
28202
+ }, function (error) {
27752
28203
  peerConnection._rollingBack = false;
27753
28204
  throw error;
27754
28205
  });
@@ -27807,7 +28258,7 @@ function overwriteWithInitiallyNegotiatedDtlsRole(description, dtlsRole) {
27807
28258
  }
27808
28259
  module.exports = FirefoxRTCPeerConnection;
27809
28260
 
27810
- },{"../../vendor/inherits":150,"../rtcsessiondescription/firefox":167,"../util":170,"../util/eventtarget":169,"../util/sdp":172}],163:[function(require,module,exports){
28261
+ },{"../../eventtarget":11,"../rtcsessiondescription/firefox":168,"../util":170,"../util/sdp":172}],164:[function(require,module,exports){
27811
28262
  'use strict';
27812
28263
  if (typeof RTCPeerConnection === 'function') {
27813
28264
  var guessBrowser = require('../util').guessBrowser;
@@ -27832,253 +28283,299 @@ else {
27832
28283
  };
27833
28284
  }
27834
28285
 
27835
- },{"../util":170,"./chrome":161,"./firefox":162,"./safari":164}],164:[function(require,module,exports){
28286
+ },{"../util":170,"./chrome":162,"./firefox":163,"./safari":165}],165:[function(require,module,exports){
27836
28287
  /* globals RTCPeerConnection, RTCSessionDescription */
27837
28288
  'use strict';
27838
- var EventTarget = require('../util/eventtarget');
27839
- var inherits = require('../../vendor/inherits');
28289
+ var __extends = (this && this.__extends) || (function () {
28290
+ var extendStatics = function (d, b) {
28291
+ extendStatics = Object.setPrototypeOf ||
28292
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28293
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
28294
+ return extendStatics(d, b);
28295
+ };
28296
+ return function (d, b) {
28297
+ if (typeof b !== "function" && b !== null)
28298
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28299
+ extendStatics(d, b);
28300
+ function __() { this.constructor = d; }
28301
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28302
+ };
28303
+ })();
28304
+ var __read = (this && this.__read) || function (o, n) {
28305
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
28306
+ if (!m) return o;
28307
+ var i = m.call(o), r, ar = [], e;
28308
+ try {
28309
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
28310
+ }
28311
+ catch (error) { e = { error: error }; }
28312
+ finally {
28313
+ try {
28314
+ if (r && !r.done && (m = i["return"])) m.call(i);
28315
+ }
28316
+ finally { if (e) throw e.error; }
28317
+ }
28318
+ return ar;
28319
+ };
28320
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
28321
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
28322
+ to[j] = from[i];
28323
+ return to;
28324
+ };
28325
+ var EventTarget = require('../../eventtarget');
27840
28326
  var Latch = require('../util/latch');
27841
- var sdpUtils = require('../util/sdp');
27842
- var util = require('../util');
27843
- var isUnifiedPlan = sdpUtils.getSdpFormat() === 'unified';
28327
+ var _a = require('../util/sdp'), getSdpFormat = _a.getSdpFormat, updatePlanBTrackIdsToSSRCs = _a.updatePlanBTrackIdsToSSRCs, updateUnifiedPlanTrackIdsToSSRCs = _a.updateUnifiedPlanTrackIdsToSSRCs;
28328
+ var _b = require('../util'), delegateMethods = _b.delegateMethods, interceptEvent = _b.interceptEvent, proxyProperties = _b.proxyProperties;
28329
+ var isUnifiedPlan = getSdpFormat() === 'unified';
27844
28330
  var updateTrackIdsToSSRCs = isUnifiedPlan
27845
- ? sdpUtils.updateUnifiedPlanTrackIdsToSSRCs
27846
- : sdpUtils.updatePlanBTrackIdsToSSRCs;
27847
- function SafariRTCPeerConnection(configuration) {
27848
- if (!(this instanceof SafariRTCPeerConnection)) {
27849
- return new SafariRTCPeerConnection(configuration);
27850
- }
27851
- EventTarget.call(this);
27852
- util.interceptEvent(this, 'datachannel');
27853
- util.interceptEvent(this, 'iceconnectionstatechange');
27854
- util.interceptEvent(this, 'signalingstatechange');
27855
- util.interceptEvent(this, 'track');
27856
- var peerConnection = new RTCPeerConnection(configuration);
27857
- Object.defineProperties(this, {
27858
- _appliedTracksToSSRCs: {
27859
- value: new Map(),
27860
- writable: true
27861
- },
27862
- _audioTransceiver: {
27863
- value: null,
27864
- writable: true
27865
- },
27866
- _isClosed: {
27867
- value: false,
27868
- writable: true
27869
- },
27870
- _peerConnection: {
27871
- value: peerConnection
27872
- },
27873
- _pendingLocalOffer: {
27874
- value: null,
27875
- writable: true
27876
- },
27877
- _pendingRemoteOffer: {
27878
- value: null,
27879
- writable: true
27880
- },
27881
- _rolledBackTracksToSSRCs: {
27882
- value: new Map(),
27883
- writable: true
27884
- },
27885
- _signalingStateLatch: {
27886
- value: new Latch()
28331
+ ? updateUnifiedPlanTrackIdsToSSRCs
28332
+ : updatePlanBTrackIdsToSSRCs;
28333
+ var SafariRTCPeerConnection = /** @class */ (function (_super) {
28334
+ __extends(SafariRTCPeerConnection, _super);
28335
+ function SafariRTCPeerConnection(configuration) {
28336
+ var _this = _super.call(this) || this;
28337
+ interceptEvent(_this, 'datachannel');
28338
+ interceptEvent(_this, 'iceconnectionstatechange');
28339
+ interceptEvent(_this, 'signalingstatechange');
28340
+ interceptEvent(_this, 'track');
28341
+ var peerConnection = new RTCPeerConnection(configuration);
28342
+ Object.defineProperties(_this, {
28343
+ _appliedTracksToSSRCs: {
28344
+ value: new Map(),
28345
+ writable: true
28346
+ },
28347
+ _audioTransceiver: {
28348
+ value: null,
28349
+ writable: true
28350
+ },
28351
+ _isClosed: {
28352
+ value: false,
28353
+ writable: true
28354
+ },
28355
+ _peerConnection: {
28356
+ value: peerConnection
28357
+ },
28358
+ _pendingLocalOffer: {
28359
+ value: null,
28360
+ writable: true
28361
+ },
28362
+ _pendingRemoteOffer: {
28363
+ value: null,
28364
+ writable: true
28365
+ },
28366
+ _rolledBackTracksToSSRCs: {
28367
+ value: new Map(),
28368
+ writable: true
28369
+ },
28370
+ _signalingStateLatch: {
28371
+ value: new Latch()
28372
+ },
28373
+ _tracksToSSRCs: {
28374
+ value: new Map(),
28375
+ writable: true
28376
+ },
28377
+ _videoTransceiver: {
28378
+ value: null,
28379
+ writable: true
28380
+ }
28381
+ });
28382
+ peerConnection.addEventListener('datachannel', function (event) {
28383
+ shimDataChannel(event.channel);
28384
+ _this.dispatchEvent(event);
28385
+ });
28386
+ peerConnection.addEventListener('iceconnectionstatechange', function () {
28387
+ var args = [];
28388
+ for (var _i = 0; _i < arguments.length; _i++) {
28389
+ args[_i] = arguments[_i];
28390
+ }
28391
+ if (_this._isClosed) {
28392
+ return;
28393
+ }
28394
+ _this.dispatchEvent.apply(_this, __spreadArray([], __read(args)));
28395
+ });
28396
+ peerConnection.addEventListener('signalingstatechange', function () {
28397
+ var args = [];
28398
+ for (var _i = 0; _i < arguments.length; _i++) {
28399
+ args[_i] = arguments[_i];
28400
+ }
28401
+ if (_this._isClosed) {
28402
+ return;
28403
+ }
28404
+ if (peerConnection.signalingState === 'stable') {
28405
+ _this._appliedTracksToSSRCs = new Map(_this._tracksToSSRCs);
28406
+ }
28407
+ if (!_this._pendingLocalOffer && !_this._pendingRemoteOffer) {
28408
+ _this.dispatchEvent.apply(_this, __spreadArray([], __read(args)));
28409
+ }
28410
+ });
28411
+ // NOTE(syerrapragada): This ensures that SafariRTCPeerConnection's "remoteDescription", when accessed
28412
+ // in an RTCTrackEvent listener, will point to the underlying RTCPeerConnection's
28413
+ // "remoteDescription". Before this fix, this was still pointing to "_pendingRemoteOffer"
28414
+ // even though a new remote RTCSessionDescription had already been applied.
28415
+ peerConnection.addEventListener('track', function (event) {
28416
+ _this._pendingRemoteOffer = null;
28417
+ _this.dispatchEvent(event);
28418
+ });
28419
+ proxyProperties(RTCPeerConnection.prototype, _this, peerConnection);
28420
+ return _this;
28421
+ }
28422
+ Object.defineProperty(SafariRTCPeerConnection.prototype, "localDescription", {
28423
+ get: function () {
28424
+ return this._pendingLocalOffer || this._peerConnection.localDescription;
27887
28425
  },
27888
- _tracksToSSRCs: {
27889
- value: new Map(),
27890
- writable: true
28426
+ enumerable: false,
28427
+ configurable: true
28428
+ });
28429
+ Object.defineProperty(SafariRTCPeerConnection.prototype, "iceConnectionState", {
28430
+ get: function () {
28431
+ return this._isClosed ? 'closed' : this._peerConnection.iceConnectionState;
27891
28432
  },
27892
- _videoTransceiver: {
27893
- value: null,
27894
- writable: true
28433
+ enumerable: false,
28434
+ configurable: true
28435
+ });
28436
+ Object.defineProperty(SafariRTCPeerConnection.prototype, "iceGatheringState", {
28437
+ get: function () {
28438
+ return this._isClosed ? 'complete' : this._peerConnection.iceGatheringState;
27895
28439
  },
27896
- localDescription: {
27897
- enumerable: true,
27898
- get: function () {
27899
- return this._pendingLocalOffer || this._peerConnection.localDescription;
27900
- }
28440
+ enumerable: false,
28441
+ configurable: true
28442
+ });
28443
+ Object.defineProperty(SafariRTCPeerConnection.prototype, "remoteDescription", {
28444
+ get: function () {
28445
+ return this._pendingRemoteOffer || this._peerConnection.remoteDescription;
27901
28446
  },
27902
- iceConnectionState: {
27903
- enumerable: true,
27904
- get: function () {
27905
- return this._isClosed ? 'closed' : this._peerConnection.iceConnectionState;
28447
+ enumerable: false,
28448
+ configurable: true
28449
+ });
28450
+ Object.defineProperty(SafariRTCPeerConnection.prototype, "signalingState", {
28451
+ get: function () {
28452
+ if (this._isClosed) {
28453
+ return 'closed';
27906
28454
  }
27907
- },
27908
- iceGatheringState: {
27909
- enumerable: true,
27910
- get: function () {
27911
- return this._isClosed ? 'complete' : this._peerConnection.iceGatheringState;
28455
+ else if (this._pendingLocalOffer) {
28456
+ return 'have-local-offer';
27912
28457
  }
27913
- },
27914
- remoteDescription: {
27915
- enumerable: true,
27916
- get: function () {
27917
- return this._pendingRemoteOffer || this._peerConnection.remoteDescription;
28458
+ else if (this._pendingRemoteOffer) {
28459
+ return 'have-remote-offer';
27918
28460
  }
28461
+ return this._peerConnection.signalingState;
27919
28462
  },
27920
- signalingState: {
27921
- enumerable: true,
27922
- get: function () {
27923
- if (this._isClosed) {
27924
- return 'closed';
27925
- }
27926
- else if (this._pendingLocalOffer) {
27927
- return 'have-local-offer';
27928
- }
27929
- else if (this._pendingRemoteOffer) {
27930
- return 'have-remote-offer';
27931
- }
27932
- return this._peerConnection.signalingState;
27933
- }
27934
- }
27935
- });
27936
- var self = this;
27937
- peerConnection.addEventListener('datachannel', function ondatachannel(event) {
27938
- shimDataChannel(event.channel);
27939
- self.dispatchEvent(event);
27940
- });
27941
- peerConnection.addEventListener('iceconnectionstatechange', function oniceconnectionstatechange() {
27942
- if (self._isClosed) {
27943
- return;
27944
- }
27945
- self.dispatchEvent.apply(self, arguments);
28463
+ enumerable: false,
28464
+ configurable: true
27946
28465
  });
27947
- peerConnection.addEventListener('signalingstatechange', function onsignalingstatechange() {
27948
- if (self._isClosed) {
27949
- return;
28466
+ SafariRTCPeerConnection.prototype.addIceCandidate = function (candidate) {
28467
+ var _this = this;
28468
+ if (this.signalingState === 'have-remote-offer') {
28469
+ return this._signalingStateLatch.when('low').then(function () { return _this._peerConnection.addIceCandidate(candidate); });
27950
28470
  }
27951
- if (peerConnection.signalingState === 'stable') {
27952
- self._appliedTracksToSSRCs = new Map(self._tracksToSSRCs);
28471
+ return this._peerConnection.addIceCandidate(candidate);
28472
+ };
28473
+ SafariRTCPeerConnection.prototype.createOffer = function (options) {
28474
+ var _this = this;
28475
+ options = Object.assign({}, options);
28476
+ // NOTE(mroberts): In general, this is not the way to do this; however, it's
28477
+ // good enough for our application.
28478
+ if (options.offerToReceiveVideo && !this._audioTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'audio'))) {
28479
+ delete options.offerToReceiveAudio;
28480
+ try {
28481
+ this._audioTransceiver = isUnifiedPlan
28482
+ ? this.addTransceiver('audio', { direction: 'recvonly' })
28483
+ : this.addTransceiver('audio');
28484
+ }
28485
+ catch (e) {
28486
+ return Promise.reject(e);
28487
+ }
27953
28488
  }
27954
- if (!self._pendingLocalOffer && !self._pendingRemoteOffer) {
27955
- self.dispatchEvent.apply(self, arguments);
28489
+ if (options.offerToReceiveVideo && !this._videoTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'video'))) {
28490
+ delete options.offerToReceiveVideo;
28491
+ try {
28492
+ this._videoTransceiver = isUnifiedPlan
28493
+ ? this.addTransceiver('video', { direction: 'recvonly' })
28494
+ : this.addTransceiver('video');
28495
+ }
28496
+ catch (e) {
28497
+ return Promise.reject(e);
28498
+ }
27956
28499
  }
27957
- });
27958
- // NOTE(syerrapragada): This ensures that SafariRTCPeerConnection's "remoteDescription", when accessed
27959
- // in an RTCTrackEvent listener, will point to the underlying RTCPeerConnection's
27960
- // "remoteDescription". Before this fix, this was still pointing to "_pendingRemoteOffer"
27961
- // even though a new remote RTCSessionDescription had already been applied.
27962
- peerConnection.addEventListener('track', function ontrack(event) {
27963
- self._pendingRemoteOffer = null;
27964
- self.dispatchEvent(event);
27965
- });
27966
- util.proxyProperties(RTCPeerConnection.prototype, this, peerConnection);
27967
- }
27968
- inherits(SafariRTCPeerConnection, EventTarget);
27969
- SafariRTCPeerConnection.prototype.addIceCandidate = function addIceCandidate(candidate) {
27970
- var self = this;
27971
- if (this.signalingState === 'have-remote-offer') {
27972
- return this._signalingStateLatch.when('low').then(function signalingStatesResolved() {
27973
- return self._peerConnection.addIceCandidate(candidate);
28500
+ return this._peerConnection.createOffer(options).then(function (offer) {
28501
+ // NOTE(mmalavalli): If createOffer() is called immediately after rolling back,
28502
+ // then we no longer need to retain the rolled back tracks to SSRCs Map.
28503
+ _this._rolledBackTracksToSSRCs.clear();
28504
+ return new RTCSessionDescription({
28505
+ type: offer.type,
28506
+ sdp: updateTrackIdsToSSRCs(_this._tracksToSSRCs, offer.sdp)
28507
+ });
27974
28508
  });
27975
- }
27976
- return this._peerConnection.addIceCandidate(candidate);
27977
- };
27978
- SafariRTCPeerConnection.prototype.createOffer = function createOffer(options) {
27979
- options = Object.assign({}, options);
27980
- var self = this;
27981
- // NOTE(mroberts): In general, this is not the way to do this; however, it's
27982
- // good enough for our application.
27983
- if (options.offerToReceiveVideo && !this._audioTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'audio'))) {
27984
- delete options.offerToReceiveAudio;
27985
- try {
27986
- this._audioTransceiver = isUnifiedPlan
27987
- ? this.addTransceiver('audio', { direction: 'recvonly' })
27988
- : this.addTransceiver('audio');
27989
- }
27990
- catch (e) {
27991
- return Promise.reject(e);
27992
- }
27993
- }
27994
- if (options.offerToReceiveVideo && !this._videoTransceiver && !(isUnifiedPlan && hasReceiversForTracksOfKind(this, 'video'))) {
27995
- delete options.offerToReceiveVideo;
27996
- try {
27997
- this._videoTransceiver = isUnifiedPlan
27998
- ? this.addTransceiver('video', { direction: 'recvonly' })
27999
- : this.addTransceiver('video');
28000
- }
28001
- catch (e) {
28002
- return Promise.reject(e);
28509
+ };
28510
+ SafariRTCPeerConnection.prototype.createAnswer = function (options) {
28511
+ var _this = this;
28512
+ if (this._pendingRemoteOffer) {
28513
+ return this._peerConnection.setRemoteDescription(this._pendingRemoteOffer).then(function () {
28514
+ _this._signalingStateLatch.lower();
28515
+ return _this._peerConnection.createAnswer();
28516
+ }).then(function (answer) {
28517
+ _this._pendingRemoteOffer = null;
28518
+ // NOTE(mmalavalli): If createAnswer() is called immediately after rolling back, then we no
28519
+ // longer need to retain the rolled back tracks to SSRCs Map.
28520
+ _this._rolledBackTracksToSSRCs.clear();
28521
+ return isUnifiedPlan ? new RTCSessionDescription({
28522
+ type: answer.type,
28523
+ sdp: updateTrackIdsToSSRCs(_this._tracksToSSRCs, answer.sdp)
28524
+ }) : answer;
28525
+ }, function (error) {
28526
+ _this._pendingRemoteOffer = null;
28527
+ throw error;
28528
+ });
28003
28529
  }
28004
- }
28005
- return this._peerConnection.createOffer(options).then(function (offer) {
28006
- // NOTE(mmalavalli): If createOffer() is called immediately after rolling back,
28007
- // then we no longer need to retain the rolled back tracks to SSRCs Map.
28008
- self._rolledBackTracksToSSRCs.clear();
28009
- return new RTCSessionDescription({
28010
- type: offer.type,
28011
- sdp: updateTrackIdsToSSRCs(self._tracksToSSRCs, offer.sdp)
28012
- });
28013
- });
28014
- };
28015
- SafariRTCPeerConnection.prototype.createAnswer = function createAnswer(options) {
28016
- var self = this;
28017
- if (this._pendingRemoteOffer) {
28018
- return this._peerConnection.setRemoteDescription(this._pendingRemoteOffer).then(function setRemoteDescriptionSucceeded() {
28019
- self._signalingStateLatch.lower();
28020
- return self._peerConnection.createAnswer();
28021
- }).then(function createAnswerSucceeded(answer) {
28022
- self._pendingRemoteOffer = null;
28530
+ return this._peerConnection.createAnswer(options).then(function (answer) {
28023
28531
  // NOTE(mmalavalli): If createAnswer() is called immediately after rolling back, then we no
28024
28532
  // longer need to retain the rolled back tracks to SSRCs Map.
28025
- self._rolledBackTracksToSSRCs.clear();
28533
+ _this._rolledBackTracksToSSRCs.clear();
28026
28534
  return isUnifiedPlan ? new RTCSessionDescription({
28027
28535
  type: answer.type,
28028
- sdp: updateTrackIdsToSSRCs(self._tracksToSSRCs, answer.sdp)
28536
+ sdp: updateTrackIdsToSSRCs(_this._tracksToSSRCs, answer.sdp)
28029
28537
  }) : answer;
28030
- }, function setRemoteDescriptionOrCreateAnswerFailed(error) {
28031
- self._pendingRemoteOffer = null;
28032
- throw error;
28033
28538
  });
28034
- }
28035
- return this._peerConnection.createAnswer(options).then(function createAnswerSucceeded(answer) {
28036
- // NOTE(mmalavalli): If createAnswer() is called immediately after rolling back, then we no
28037
- // longer need to retain the rolled back tracks to SSRCs Map.
28038
- self._rolledBackTracksToSSRCs.clear();
28039
- return isUnifiedPlan ? new RTCSessionDescription({
28040
- type: answer.type,
28041
- sdp: updateTrackIdsToSSRCs(self._tracksToSSRCs, answer.sdp)
28042
- }) : answer;
28043
- });
28044
- };
28045
- SafariRTCPeerConnection.prototype.createDataChannel = function createDataChannel(label, dataChannelDict) {
28046
- var dataChannel = this._peerConnection.createDataChannel(label, dataChannelDict);
28047
- shimDataChannel(dataChannel);
28048
- return dataChannel;
28049
- };
28050
- SafariRTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
28051
- sender.replaceTrack(null);
28052
- this._peerConnection.removeTrack(sender);
28053
- };
28054
- SafariRTCPeerConnection.prototype.setLocalDescription = function setLocalDescription(description) {
28055
- // NOTE(mmalavalli): If setLocalDescription() is called immediately after rolling back,
28056
- // then we need to restore the rolled back tracks to SSRCs Map.
28057
- if (this._rolledBackTracksToSSRCs.size > 0) {
28058
- this._tracksToSSRCs = new Map(this._rolledBackTracksToSSRCs);
28539
+ };
28540
+ SafariRTCPeerConnection.prototype.createDataChannel = function (label, dataChannelDict) {
28541
+ var dataChannel = this._peerConnection.createDataChannel(label, dataChannelDict);
28542
+ shimDataChannel(dataChannel);
28543
+ return dataChannel;
28544
+ };
28545
+ SafariRTCPeerConnection.prototype.removeTrack = function (sender) {
28546
+ sender.replaceTrack(null);
28547
+ this._peerConnection.removeTrack(sender);
28548
+ };
28549
+ SafariRTCPeerConnection.prototype.setLocalDescription = function (description) {
28550
+ // NOTE(mmalavalli): If setLocalDescription() is called immediately after rolling back,
28551
+ // then we need to restore the rolled back tracks to SSRCs Map.
28552
+ if (this._rolledBackTracksToSSRCs.size > 0) {
28553
+ this._tracksToSSRCs = new Map(this._rolledBackTracksToSSRCs);
28554
+ this._rolledBackTracksToSSRCs.clear();
28555
+ }
28556
+ return setDescription(this, true, description);
28557
+ };
28558
+ SafariRTCPeerConnection.prototype.setRemoteDescription = function (description) {
28559
+ // NOTE(mmalavalli): If setRemoteDescription() is called immediately after rolling back,
28560
+ // then we no longer need to retain the rolled back tracks to SSRCs Map.
28059
28561
  this._rolledBackTracksToSSRCs.clear();
28060
- }
28061
- return setDescription(this, true, description);
28062
- };
28063
- SafariRTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription(description) {
28064
- // NOTE(mmalavalli): If setRemoteDescription() is called immediately after rolling back,
28065
- // then we no longer need to retain the rolled back tracks to SSRCs Map.
28066
- this._rolledBackTracksToSSRCs.clear();
28067
- return setDescription(this, false, description);
28068
- };
28069
- SafariRTCPeerConnection.prototype.close = function close() {
28070
- if (this._isClosed) {
28071
- return;
28072
- }
28073
- this._isClosed = true;
28074
- this._peerConnection.close();
28075
- var self = this;
28076
- setTimeout(function () {
28077
- self.dispatchEvent(new Event('iceconnectionstatechange'));
28078
- self.dispatchEvent(new Event('signalingstatechange'));
28079
- });
28080
- };
28081
- util.delegateMethods(RTCPeerConnection.prototype, SafariRTCPeerConnection.prototype, '_peerConnection');
28562
+ return setDescription(this, false, description);
28563
+ };
28564
+ SafariRTCPeerConnection.prototype.close = function () {
28565
+ var _this = this;
28566
+ if (this._isClosed) {
28567
+ return;
28568
+ }
28569
+ this._isClosed = true;
28570
+ this._peerConnection.close();
28571
+ setTimeout(function () {
28572
+ _this.dispatchEvent(new Event('iceconnectionstatechange'));
28573
+ _this.dispatchEvent(new Event('signalingstatechange'));
28574
+ });
28575
+ };
28576
+ return SafariRTCPeerConnection;
28577
+ }(EventTarget));
28578
+ delegateMethods(RTCPeerConnection.prototype, SafariRTCPeerConnection.prototype, '_peerConnection');
28082
28579
  function setDescription(peerConnection, local, description) {
28083
28580
  function setPendingLocalOffer(offer) {
28084
28581
  if (local) {
@@ -28105,8 +28602,7 @@ function setDescription(peerConnection, local, description) {
28105
28602
  }
28106
28603
  else if (description.type === 'offer') {
28107
28604
  if (peerConnection.signalingState !== intermediateState && peerConnection.signalingState !== 'stable') {
28108
- return Promise.reject(new Error('Cannot set ' + (local ? 'local' : 'remote') +
28109
- ' offer in state ' + peerConnection.signalingState));
28605
+ return Promise.reject(new Error("Cannot set " + (local ? 'local' : 'remote') + "\n offer in state " + peerConnection.signalingState));
28110
28606
  }
28111
28607
  if (!pendingLocalOffer && peerConnection._signalingStateLatch.state === 'low') {
28112
28608
  peerConnection._signalingStateLatch.raise();
@@ -28115,16 +28611,13 @@ function setDescription(peerConnection, local, description) {
28115
28611
  setPendingLocalOffer(description);
28116
28612
  // Only dispatch a signalingstatechange event if we transitioned.
28117
28613
  if (peerConnection.signalingState !== previousSignalingState) {
28118
- return Promise.resolve().then(function dispatchSignalingStateChangeEvent() {
28119
- peerConnection.dispatchEvent(new Event('signalingstatechange'));
28120
- });
28614
+ return Promise.resolve().then(function () { return peerConnection.dispatchEvent(new Event('signalingstatechange')); });
28121
28615
  }
28122
28616
  return Promise.resolve();
28123
28617
  }
28124
28618
  else if (description.type === 'rollback') {
28125
28619
  if (peerConnection.signalingState !== intermediateState) {
28126
- return Promise.reject(new Error('Cannot rollback ' +
28127
- (local ? 'local' : 'remote') + ' description in ' + peerConnection.signalingState));
28620
+ return Promise.reject(new Error("Cannot rollback \n " + (local ? 'local' : 'remote') + " description in " + peerConnection.signalingState));
28128
28621
  }
28129
28622
  clearPendingLocalOffer();
28130
28623
  // NOTE(mmalavalli): We store the rolled back tracks to SSRCs Map here in case
@@ -28133,20 +28626,16 @@ function setDescription(peerConnection, local, description) {
28133
28626
  // a glare scenario and this Map should be restored.
28134
28627
  peerConnection._rolledBackTracksToSSRCs = new Map(peerConnection._tracksToSSRCs);
28135
28628
  peerConnection._tracksToSSRCs = new Map(peerConnection._appliedTracksToSSRCs);
28136
- return Promise.resolve().then(function dispatchSignalingStateChangeEvent() {
28137
- peerConnection.dispatchEvent(new Event('signalingstatechange'));
28138
- });
28629
+ return Promise.resolve().then(function () { return peerConnection.dispatchEvent(new Event('signalingstatechange')); });
28139
28630
  }
28140
28631
  return peerConnection._peerConnection[setLocalDescription](description);
28141
28632
  }
28142
28633
  function setRemoteAnswer(peerConnection, answer) {
28143
28634
  var pendingLocalOffer = peerConnection._pendingLocalOffer;
28144
- return peerConnection._peerConnection.setLocalDescription(pendingLocalOffer).then(function setLocalOfferSucceeded() {
28635
+ return peerConnection._peerConnection.setLocalDescription(pendingLocalOffer).then(function () {
28145
28636
  peerConnection._pendingLocalOffer = null;
28146
28637
  return peerConnection.setRemoteDescription(answer);
28147
- }).then(function setRemoteAnswerSucceeded() {
28148
- peerConnection._signalingStateLatch.lower();
28149
- });
28638
+ }).then(function () { return peerConnection._signalingStateLatch.lower(); });
28150
28639
  }
28151
28640
  /**
28152
28641
  * Whether a SafariRTCPeerConnection has any RTCRtpReceivers(s) for the given
@@ -28156,8 +28645,10 @@ function setRemoteAnswer(peerConnection, answer) {
28156
28645
  * @returns {boolean}
28157
28646
  */
28158
28647
  function hasReceiversForTracksOfKind(peerConnection, kind) {
28159
- return !!peerConnection.getTransceivers().find(function (transceiver) {
28160
- return transceiver.receiver && transceiver.receiver.track && transceiver.receiver.track.kind === kind;
28648
+ return !!peerConnection.getTransceivers().find(function (_a) {
28649
+ var _b = _a.receiver, receiver = _b === void 0 ? {} : _b;
28650
+ var _c = receiver.track, track = _c === void 0 ? {} : _c;
28651
+ return track.kind === kind;
28161
28652
  });
28162
28653
  }
28163
28654
  /**
@@ -28181,22 +28672,25 @@ function shimDataChannel(dataChannel) {
28181
28672
  }
28182
28673
  module.exports = SafariRTCPeerConnection;
28183
28674
 
28184
- },{"../../vendor/inherits":150,"../util":170,"../util/eventtarget":169,"../util/latch":171,"../util/sdp":172}],165:[function(require,module,exports){
28675
+ },{"../../eventtarget":11,"../util":170,"../util/latch":171,"../util/sdp":172}],166:[function(require,module,exports){
28185
28676
  'use strict';
28186
28677
  /**
28187
28678
  * RTCRtpSender shim.
28188
28679
  * @param {MediaStreamTrack} track
28189
28680
  * @property {MediaStreamTrack} track
28190
28681
  */
28191
- function RTCRtpSenderShim(track) {
28192
- Object.defineProperties(this, {
28193
- track: {
28194
- enumerable: true,
28195
- value: track,
28196
- writable: true
28197
- }
28198
- });
28199
- }
28682
+ var RTCRtpSenderShim = /** @class */ (function () {
28683
+ function RTCRtpSenderShim(track) {
28684
+ Object.defineProperties(this, {
28685
+ track: {
28686
+ enumerable: true,
28687
+ value: track,
28688
+ writable: true
28689
+ }
28690
+ });
28691
+ }
28692
+ return RTCRtpSenderShim;
28693
+ }());
28200
28694
  // NOTE(mmalavalli): Because of the way we will be using this shim, there
28201
28695
  // are a couple of use cases that will not be covered:
28202
28696
  //
@@ -28219,7 +28713,7 @@ function RTCRtpSenderShim(track) {
28219
28713
  // using the RTCRtpSender APIs.
28220
28714
  module.exports = RTCRtpSenderShim;
28221
28715
 
28222
- },{}],166:[function(require,module,exports){
28716
+ },{}],167:[function(require,module,exports){
28223
28717
  /* globals RTCSessionDescription */
28224
28718
  'use strict';
28225
28719
  // This class wraps Chrome's RTCSessionDescription implementation. It provides
@@ -28228,40 +28722,47 @@ module.exports = RTCRtpSenderShim;
28228
28722
  // 1. Rollback support
28229
28723
  // https://bugs.chromium.org/p/webrtc/issues/detail?id=4676
28230
28724
  //
28231
- function ChromeRTCSessionDescription(descriptionInitDict) {
28232
- if (!(this instanceof ChromeRTCSessionDescription)) {
28233
- return new ChromeRTCSessionDescription(descriptionInitDict);
28234
- }
28235
- // If this constructor is called with an object with a .type property set to
28236
- // "rollback", we should not call Chrome's RTCSessionDescription constructor,
28237
- // because this would throw an RTCSdpType error.
28238
- var description = descriptionInitDict && descriptionInitDict.type === 'rollback'
28239
- ? null
28240
- : new RTCSessionDescription(descriptionInitDict);
28241
- Object.defineProperties(this, {
28242
- _description: {
28243
- get: function () {
28244
- return description;
28725
+ var ChromeRTCSessionDescription = /** @class */ (function () {
28726
+ function ChromeRTCSessionDescription(descriptionInitDict) {
28727
+ this.descriptionInitDict = descriptionInitDict;
28728
+ // If this constructor is called with an object with a .type property set to
28729
+ // "rollback", we should not call Chrome's RTCSessionDescription constructor,
28730
+ // because this would throw an RTCSdpType error.
28731
+ var description = descriptionInitDict && descriptionInitDict.type === 'rollback'
28732
+ ? null
28733
+ : new RTCSessionDescription(descriptionInitDict);
28734
+ Object.defineProperties(this, {
28735
+ _description: {
28736
+ get: function () {
28737
+ return description;
28738
+ }
28245
28739
  }
28740
+ });
28741
+ }
28742
+ Object.defineProperty(ChromeRTCSessionDescription.prototype, "sdp", {
28743
+ get: function () {
28744
+ return this._description ? this._description.sdp : this.descriptionInitDict.sdp;
28246
28745
  },
28247
- sdp: {
28248
- enumerable: true,
28249
- value: description ? description.sdp : descriptionInitDict.sdp
28746
+ enumerable: false,
28747
+ configurable: true
28748
+ });
28749
+ Object.defineProperty(ChromeRTCSessionDescription.prototype, "type", {
28750
+ get: function () {
28751
+ return this._description ? this._description.type : this.descriptionInitDict.type;
28250
28752
  },
28251
- type: {
28252
- enumerable: true,
28253
- value: description ? description.type : descriptionInitDict.type
28254
- }
28753
+ enumerable: false,
28754
+ configurable: true
28255
28755
  });
28256
- }
28756
+ return ChromeRTCSessionDescription;
28757
+ }());
28257
28758
  module.exports = ChromeRTCSessionDescription;
28258
28759
 
28259
- },{}],167:[function(require,module,exports){
28760
+ },{}],168:[function(require,module,exports){
28260
28761
  /* globals RTCSessionDescription */
28261
28762
  'use strict';
28262
28763
  module.exports = RTCSessionDescription;
28263
28764
 
28264
- },{}],168:[function(require,module,exports){
28765
+ },{}],169:[function(require,module,exports){
28265
28766
  /* globals RTCSessionDescription */
28266
28767
  'use strict';
28267
28768
  if (typeof RTCSessionDescription === 'function') {
@@ -28284,43 +28785,29 @@ else {
28284
28785
  };
28285
28786
  }
28286
28787
 
28287
- },{"../util":170,"./chrome":166,"./firefox":167}],169:[function(require,module,exports){
28788
+ },{"../util":170,"./chrome":167,"./firefox":168}],170:[function(require,module,exports){
28288
28789
  'use strict';
28289
- var EventEmitter = require('events').EventEmitter;
28290
- /**
28291
- * Event target.
28292
- * @class
28293
- */
28294
- function EventTarget() {
28295
- Object.defineProperties(this, {
28296
- _eventEmitter: {
28297
- value: new EventEmitter()
28790
+ var __read = (this && this.__read) || function (o, n) {
28791
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
28792
+ if (!m) return o;
28793
+ var i = m.call(o), r, ar = [], e;
28794
+ try {
28795
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
28796
+ }
28797
+ catch (error) { e = { error: error }; }
28798
+ finally {
28799
+ try {
28800
+ if (r && !r.done && (m = i["return"])) m.call(i);
28298
28801
  }
28299
- });
28300
- }
28301
- /**
28302
- * Dispatch an Event to the {@link EventTarget}.
28303
- * @param {Event} event
28304
- */
28305
- EventTarget.prototype.dispatchEvent = function dispatchEvent(event) {
28306
- return this._eventEmitter.emit(event.type, event);
28307
- };
28308
- /**
28309
- * Add an Event listener to the {@link EventTarget}.
28310
- */
28311
- EventTarget.prototype.addEventListener = function addEventListener() {
28312
- return this._eventEmitter.addListener.apply(this._eventEmitter, arguments);
28802
+ finally { if (e) throw e.error; }
28803
+ }
28804
+ return ar;
28313
28805
  };
28314
- /**
28315
- * Remove an Event listener to the {@link EventTarget}.
28316
- */
28317
- EventTarget.prototype.removeEventListener = function removeEventListener() {
28318
- return this._eventEmitter.removeListener.apply(this._eventEmitter, arguments);
28806
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
28807
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
28808
+ to[j] = from[i];
28809
+ return to;
28319
28810
  };
28320
- module.exports = EventTarget;
28321
-
28322
- },{"events":173}],170:[function(require,module,exports){
28323
- 'use strict';
28324
28811
  /**
28325
28812
  * Create a {@link Deferred}.
28326
28813
  * @returns {Deferred}
@@ -28427,10 +28914,7 @@ function flatMap(list, mapFn) {
28427
28914
  var listArray = list instanceof Map || list instanceof Set
28428
28915
  ? Array.from(list.values())
28429
28916
  : list;
28430
- return listArray.reduce(function (flattened, item) {
28431
- var mapped = mapFn(item);
28432
- return flattened.concat(mapped);
28433
- }, []);
28917
+ return listArray.reduce(function (flattened, item) { return flattened.concat(mapFn(item)); }, []);
28434
28918
  }
28435
28919
  /**
28436
28920
  * Get the browser's user agent, if available.
@@ -28478,8 +28962,8 @@ function guessBrowserVersion(userAgent) {
28478
28962
  if (!prefix) {
28479
28963
  return null;
28480
28964
  }
28481
- var regex = new RegExp('(' + prefix + ')/([^\\s]+)');
28482
- var match = (userAgent.match(regex) || [])[2];
28965
+ var regex = new RegExp("(" + prefix + ")/([^\\s]+)");
28966
+ var _a = __read(userAgent.match(regex) || [], 3), match = _a[2];
28483
28967
  if (!match) {
28484
28968
  return null;
28485
28969
  }
@@ -28535,14 +29019,9 @@ function interceptEvent(target, type) {
28535
29019
  * @returns {Promise<undefined>}
28536
29020
  */
28537
29021
  function legacyPromise(promise, onSuccess, onFailure) {
28538
- if (onSuccess) {
28539
- return promise.then(function (result) {
28540
- onSuccess(result);
28541
- }, function (error) {
28542
- onFailure(error);
28543
- });
28544
- }
28545
- return promise;
29022
+ return onSuccess
29023
+ ? promise.then(onSuccess, onFailure)
29024
+ : promise;
28546
29025
  }
28547
29026
  /**
28548
29027
  * Make a unique ID.
@@ -28588,7 +29067,11 @@ function proxyProperty(source, wrapper, target, propertyName) {
28588
29067
  writable: true
28589
29068
  });
28590
29069
  target.addEventListener(propertyName.slice(2), function () {
28591
- wrapper.dispatchEvent.apply(wrapper, arguments);
29070
+ var args = [];
29071
+ for (var _i = 0; _i < arguments.length; _i++) {
29072
+ args[_i] = arguments[_i];
29073
+ }
29074
+ return wrapper.dispatchEvent.apply(wrapper, __spreadArray([], __read(args)));
28592
29075
  });
28593
29076
  return;
28594
29077
  }
@@ -28642,103 +29125,103 @@ var states = {
28642
29125
  * transitioning between them ({@link Latch#raise} and {@link Latch#lower}).
28643
29126
  * @param {string} [initialState="low"] - either "high" or "low"
28644
29127
  */
28645
- function Latch(initialState) {
28646
- if (!(this instanceof Latch)) {
28647
- return new Latch(initialState);
28648
- }
28649
- var state = initialState || 'low';
28650
- Object.defineProperties(this, {
28651
- _state: {
28652
- set: function (_state) {
28653
- if (state !== _state) {
28654
- state = _state;
28655
- var whenDeferreds = this._whenDeferreds.get(state);
28656
- whenDeferreds.forEach(function (deferred) {
28657
- deferred.resolve(this);
28658
- }, this);
28659
- whenDeferreds.clear();
29128
+ var Latch = /** @class */ (function () {
29129
+ function Latch(initialState) {
29130
+ if (initialState === void 0) { initialState = 'low'; }
29131
+ var state = initialState;
29132
+ Object.defineProperties(this, {
29133
+ _state: {
29134
+ set: function (_state) {
29135
+ var _this = this;
29136
+ if (state !== _state) {
29137
+ state = _state;
29138
+ var whenDeferreds = this._whenDeferreds.get(state);
29139
+ whenDeferreds.forEach(function (deferred) { return deferred.resolve(_this); });
29140
+ whenDeferreds.clear();
29141
+ }
29142
+ },
29143
+ get: function () {
29144
+ return state;
28660
29145
  }
28661
29146
  },
28662
- get: function () {
28663
- return state;
29147
+ _whenDeferreds: {
29148
+ value: new Map([
29149
+ ['high', new Set()],
29150
+ ['low', new Set()]
29151
+ ])
28664
29152
  }
29153
+ });
29154
+ }
29155
+ Object.defineProperty(Latch.prototype, "state", {
29156
+ get: function () {
29157
+ return this._state;
28665
29158
  },
28666
- _whenDeferreds: {
28667
- value: new Map([
28668
- ['high', new Set()],
28669
- ['low', new Set()]
28670
- ])
28671
- },
28672
- state: {
28673
- enumerable: true,
28674
- get: function () {
28675
- return this._state;
28676
- }
28677
- }
29159
+ enumerable: false,
29160
+ configurable: true
28678
29161
  });
28679
- }
28680
- /**
28681
- * Transition to "low".
28682
- * @returns {this}
28683
- * @throws {Error}
28684
- */
28685
- Latch.prototype.lower = function lower() {
28686
- return this.transition('low');
28687
- };
28688
- /**
28689
- * Transition to "high".
28690
- * @returns {this}
28691
- * @throws {Error}
28692
- */
28693
- Latch.prototype.raise = function raise() {
28694
- return this.transition('high');
28695
- };
28696
- /**
28697
- * Transition to a new state.
28698
- * @param {string} newState
28699
- * @returns {this}
28700
- * @throws {Error}
28701
- */
28702
- Latch.prototype.transition = function transition(newState) {
28703
- if (!states[this.state].has(newState)) {
28704
- throw createUnreachableStateError(this.state, newState);
28705
- }
28706
- this._state = newState;
28707
- return this;
28708
- };
28709
- /**
28710
- * Return a Promise that resolves when the {@link Latch} transitions to
28711
- * the specified state.
28712
- * @param {string} state
28713
- * @returns {Promise<this>}
28714
- */
28715
- Latch.prototype.when = function when(state) {
28716
- if (this.state === state) {
28717
- return Promise.resolve(this);
28718
- }
28719
- if (!states[this.state].has(state)) {
28720
- return Promise.reject(createUnreachableStateError(this.state, state));
28721
- }
28722
- var deferred = defer();
28723
- this._whenDeferreds.get(state).add(deferred);
28724
- return deferred.promise;
28725
- };
29162
+ /**
29163
+ * Transition to "low".
29164
+ * @returns {this}
29165
+ * @throws {Error}
29166
+ */
29167
+ Latch.prototype.lower = function () {
29168
+ return this.transition('low');
29169
+ };
29170
+ /**
29171
+ * Transition to "high".
29172
+ * @returns {this}
29173
+ * @throws {Error}
29174
+ */
29175
+ Latch.prototype.raise = function () {
29176
+ return this.transition('high');
29177
+ };
29178
+ /**
29179
+ * Transition to a new state.
29180
+ * @param {string} newState
29181
+ * @returns {this}
29182
+ * @throws {Error}
29183
+ */
29184
+ Latch.prototype.transition = function (newState) {
29185
+ if (!states[this.state].has(newState)) {
29186
+ throw createUnreachableStateError(this.state, newState);
29187
+ }
29188
+ this._state = newState;
29189
+ return this;
29190
+ };
29191
+ /**
29192
+ * Return a Promise that resolves when the {@link Latch} transitions to
29193
+ * the specified state.
29194
+ * @param {string} state
29195
+ * @returns {Promise<this>}
29196
+ */
29197
+ Latch.prototype.when = function (state) {
29198
+ if (this.state === state) {
29199
+ return Promise.resolve(this);
29200
+ }
29201
+ if (!states[this.state].has(state)) {
29202
+ return Promise.reject(createUnreachableStateError(this.state, state));
29203
+ }
29204
+ var deferred = defer();
29205
+ this._whenDeferreds.get(state).add(deferred);
29206
+ return deferred.promise;
29207
+ };
29208
+ return Latch;
29209
+ }());
28726
29210
  /**
28727
- * Create an unreachable state Error.
28728
- * @param {string} from - state to be transitioned from
28729
- * @param {string} to - state to be transitioned to
28730
- * @return {Error}
28731
- */
29211
+ * Create an unreachable state Error.
29212
+ * @param {string} from - state to be transitioned from
29213
+ * @param {string} to - state to be transitioned to
29214
+ * @return {Error}
29215
+ */
28732
29216
  function createUnreachableStateError(from, to) {
28733
- return new Error('Cannot transition from "' + from + '" to "' + to + '"');
29217
+ return new Error("Cannot transition from \"" + from + "\" to \"" + to + "\"");
28734
29218
  }
28735
29219
  module.exports = Latch;
28736
29220
 
28737
29221
  },{"./":170}],172:[function(require,module,exports){
28738
29222
  /* globals RTCPeerConnection, RTCRtpTransceiver */
28739
29223
  'use strict';
28740
- var flatMap = require('./').flatMap;
28741
- var guessBrowser = require('./').guessBrowser;
29224
+ var _a = require('./'), flatMap = _a.flatMap, guessBrowser = _a.guessBrowser;
28742
29225
  // NOTE(mmalavalli): We cache Chrome's sdpSemantics support in order to prevent
28743
29226
  // instantiation of more than one RTCPeerConnection.
28744
29227
  var isSdpSemanticsSupported = null;
@@ -28879,7 +29362,7 @@ function getUnifiedPlanTrackIds(sdp) {
28879
29362
  * @returns {Set<string>}
28880
29363
  */
28881
29364
  function getPlanBSSRCs(sdp, trackId) {
28882
- var pattern = '^a=ssrc:([0-9]+) +msid:[^ ]+ +' + trackId + ' *$';
29365
+ var pattern = "^a=ssrc:([0-9]+) +msid:[^ ]+ +" + trackId + " *$";
28883
29366
  return getMatches(pattern, sdp);
28884
29367
  }
28885
29368
  /**
@@ -28890,13 +29373,11 @@ function getPlanBSSRCs(sdp, trackId) {
28890
29373
  * @returns {Array<string>} mediaSections
28891
29374
  */
28892
29375
  function getMediaSections(sdp, kind, direction) {
28893
- kind = kind || '.*';
28894
- direction = direction || '.*';
28895
- return sdp.split('\r\nm=').slice(1).map(function (mediaSection) {
28896
- return 'm=' + mediaSection;
28897
- }).filter(function (mediaSection) {
28898
- var kindPattern = new RegExp('m=' + kind, 'gm');
28899
- var directionPattern = new RegExp('a=' + direction, 'gm');
29376
+ if (kind === void 0) { kind = '.*'; }
29377
+ if (direction === void 0) { direction = '.*'; }
29378
+ return sdp.split('\r\nm=').slice(1).map(function (mediaSection) { return "m=" + mediaSection; }).filter(function (mediaSection) {
29379
+ var kindPattern = new RegExp("m=" + kind, 'gm');
29380
+ var directionPattern = new RegExp("a=" + direction, 'gm');
28900
29381
  return kindPattern.test(mediaSection) && directionPattern.test(mediaSection);
28901
29382
  });
28902
29383
  }
@@ -28916,10 +29397,8 @@ function getMediaSectionSSRCs(mediaSection) {
28916
29397
  */
28917
29398
  function getUnifiedPlanSSRCs(sdp, trackId) {
28918
29399
  var mediaSections = getMediaSections(sdp);
28919
- var msidAttrRegExp = new RegExp('^a=msid:[^ ]+ +' + trackId + ' *$', 'gm');
28920
- var matchingMediaSections = mediaSections.filter(function (mediaSection) {
28921
- return mediaSection.match(msidAttrRegExp);
28922
- });
29400
+ var msidAttrRegExp = new RegExp("^a=msid:[^ ]+ +" + trackId + " *$", 'gm');
29401
+ var matchingMediaSections = mediaSections.filter(function (mediaSection) { return mediaSection.match(msidAttrRegExp); });
28923
29402
  return new Set(flatMap(matchingMediaSections, getMediaSectionSSRCs));
28924
29403
  }
28925
29404
  /**
@@ -28930,9 +29409,7 @@ function getUnifiedPlanSSRCs(sdp, trackId) {
28930
29409
  * @returns {Map<string, Set<string>>} trackIdsToSSRCs
28931
29410
  */
28932
29411
  function getTrackIdsToSSRCs(getTrackIds, getSSRCs, sdp) {
28933
- return new Map(Array.from(getTrackIds(sdp)).map(function (trackId) {
28934
- return [trackId, getSSRCs(sdp, trackId)];
28935
- }));
29412
+ return new Map(Array.from(getTrackIds(sdp)).map(function (trackId) { return [trackId, getSSRCs(sdp, trackId)]; }));
28936
29413
  }
28937
29414
  /**
28938
29415
  * Get a Map from MediaStreamTrack IDs to SSRCs from a Plan B SDP.
@@ -28973,8 +29450,8 @@ function updateTrackIdsToSSRCs(getTrackIdsToSSRCs, trackIdsToSSRCs, sdp) {
28973
29450
  oldSSRCs.forEach(function (oldSSRC, i) {
28974
29451
  var newSSRC = newSSRCs[i];
28975
29452
  newSSRCsToOldSSRCs.set(newSSRC, oldSSRC);
28976
- var pattern = '^a=ssrc:' + newSSRC + ' (.*)$';
28977
- var replacement = 'a=ssrc:' + oldSSRC + ' $1';
29453
+ var pattern = "^a=ssrc:" + newSSRC + " (.*)$";
29454
+ var replacement = "a=ssrc:" + oldSSRC + " $1";
28978
29455
  sdp = sdp.replace(new RegExp(pattern, 'gm'), replacement);
28979
29456
  });
28980
29457
  });
@@ -29532,7 +30009,7 @@ module.exports={
29532
30009
  "name": "twilio-video",
29533
30010
  "title": "Twilio Video",
29534
30011
  "description": "Twilio Video JavaScript Library",
29535
- "version": "2.24.3",
30012
+ "version": "2.26.0",
29536
30013
  "homepage": "https://twilio.com",
29537
30014
  "author": "Mark Andrus Roberts <mroberts@twilio.com>",
29538
30015
  "contributors": [
@@ -29583,7 +30060,7 @@ module.exports={
29583
30060
  "jsdoc": "^3.5.5",
29584
30061
  "jsdoc-babel": "^0.5.0",
29585
30062
  "json-loader": "^0.5.7",
29586
- "karma": "^5.0.2",
30063
+ "karma": "6.4.1",
29587
30064
  "karma-browserify": "^8.0.0",
29588
30065
  "karma-chrome-launcher": "^2.0.0",
29589
30066
  "karma-edgium-launcher": "^4.0.0-0",
@@ -29633,7 +30110,7 @@ module.exports={
29633
30110
  "test:serversiderender": "mocha ./test/serversiderender/index.js",
29634
30111
  "test:integration:adapter": "node ./scripts/karma.js karma/integration.adapter.conf.js",
29635
30112
  "test:integration": "npm run build:es5 && node ./scripts/karma.js karma/integration.conf.js",
29636
- "test:umd:install": "npm install puppeteer@5.5.0",
30113
+ "test:umd:install": "npm install puppeteer@19.2.2",
29637
30114
  "test:umd": "mocha ./test/umd/index.js",
29638
30115
  "test:crossbrowser:build:clean": "rimraf ./test/crossbrowser/lib ./test/crossbrowser/src/browser/index.js",
29639
30116
  "test:crossbrowser:build:lint": "cd ./test/crossbrowser && tslint --project tsconfig.json",
@@ -29689,9 +30166,9 @@ module.exports={
29689
30166
  },{}],175:[function(require,module,exports){
29690
30167
  module.exports = WebSocket;
29691
30168
 
29692
- },{}]},{},[11]);
30169
+ },{}]},{},[12]);
29693
30170
  ;
29694
- var Video = bundle(11);
30171
+ var Video = bundle(12);
29695
30172
  /* globals define */
29696
30173
  if (typeof define === 'function' && define.amd) {
29697
30174
  define([], function() { return Video; });