@webex/internal-media-core 1.35.3 → 1.35.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1983,7 +1983,7 @@ class Track extends EventEmitter$4 {
1983
1983
 
1984
1984
  var eventEmitter = new EventEmitter$4();
1985
1985
  var deviceList = [];
1986
- var getDevices = /*#__PURE__*/function () {
1986
+ var getDevices$1 = /*#__PURE__*/function () {
1987
1987
  var _ref = _asyncToGenerator__default["default"](function* () {
1988
1988
  var _navigator$mediaDevic;
1989
1989
  logger$5.debug({
@@ -2013,7 +2013,7 @@ var getCameras = /*#__PURE__*/function () {
2013
2013
  action: 'getCameras()',
2014
2014
  description: 'Called'
2015
2015
  });
2016
- var devices = yield getDevices();
2016
+ var devices = yield getDevices$1();
2017
2017
  logger$5.info({
2018
2018
  mediaType: DEVICE,
2019
2019
  action: 'getCameras()',
@@ -2045,7 +2045,7 @@ var getMicrophones = /*#__PURE__*/function () {
2045
2045
  action: 'getMicrophones()',
2046
2046
  description: 'Called'
2047
2047
  });
2048
- var devices = yield getDevices();
2048
+ var devices = yield getDevices$1();
2049
2049
  logger$5.info({
2050
2050
  mediaType: DEVICE,
2051
2051
  action: 'getMicrophones()',
@@ -2077,7 +2077,7 @@ var getSpeakers = /*#__PURE__*/function () {
2077
2077
  action: 'getSpeakers()',
2078
2078
  description: 'Called'
2079
2079
  });
2080
- var devices = yield getDevices();
2080
+ var devices = yield getDevices$1();
2081
2081
  logger$5.info({
2082
2082
  mediaType: DEVICE,
2083
2083
  action: 'getSpeakers()',
@@ -2389,7 +2389,7 @@ function _on() {
2389
2389
  });
2390
2390
  eventEmitter.on(eventName, listener);
2391
2391
  if (eventName === 'device:changed') {
2392
- var thisDeviceList = yield getDevices();
2392
+ var thisDeviceList = yield getDevices$1();
2393
2393
  deviceList.push(...thisDeviceList);
2394
2394
  navigator.mediaDevices.addEventListener('devicechange', deviceChangePublisher);
2395
2395
  }
@@ -2933,6 +2933,22 @@ class FingerprintLine$1 extends Line$1 {
2933
2933
  }
2934
2934
  }
2935
2935
  FingerprintLine$1.regex = new RegExp("^fingerprint:(".concat(REST$1, ")"));
2936
+ function parseFmtpParams$1(fmtpParams) {
2937
+ fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
2938
+ var fmtpObj = new Map();
2939
+ if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
2940
+ fmtpObj.set(fmtpParams, undefined);
2941
+ return fmtpObj;
2942
+ }
2943
+ fmtpParams.split(';').forEach(param => {
2944
+ var paramArr = param && param.split('=');
2945
+ if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
2946
+ throw new Error("Fmtp params is invalid with ".concat(fmtpParams));
2947
+ }
2948
+ fmtpObj.set(paramArr[0], paramArr[1]);
2949
+ });
2950
+ return fmtpObj;
2951
+ }
2936
2952
  class FmtpLine$1 extends Line$1 {
2937
2953
  constructor(payloadType, params) {
2938
2954
  super();
@@ -2946,10 +2962,16 @@ class FmtpLine$1 extends Line$1 {
2946
2962
  var tokens = line.match(FmtpLine$1.regex);
2947
2963
  var payloadType = parseInt(tokens[1], 10);
2948
2964
  var params = tokens[2];
2949
- return new FmtpLine$1(payloadType, params);
2965
+ return new FmtpLine$1(payloadType, parseFmtpParams$1(params));
2950
2966
  }
2951
2967
  toSdpLine() {
2952
- return "a=fmtp:".concat(this.payloadType, " ").concat(this.params);
2968
+ var fmtParams = Array.from(this.params.keys()).map(key => {
2969
+ if (this.params.get(key) !== undefined) {
2970
+ return "".concat(key, "=").concat(this.params.get(key));
2971
+ }
2972
+ return "".concat(key);
2973
+ }).join(';');
2974
+ return "a=fmtp:".concat(this.payloadType, " ").concat(fmtParams);
2953
2975
  }
2954
2976
  }
2955
2977
  FmtpLine$1.regex = new RegExp("^fmtp:(".concat(NUM$1, ") (").concat(REST$1, ")"));
@@ -3610,7 +3632,7 @@ class ApplicationMediaDescription$1 extends MediaDescription$1 {
3610
3632
  }
3611
3633
  class CodecInfo$2 {
3612
3634
  constructor(pt) {
3613
- this.fmtParams = [];
3635
+ this.fmtParams = new Map();
3614
3636
  this.feedback = [];
3615
3637
  this.pt = pt;
3616
3638
  }
@@ -3622,9 +3644,9 @@ class CodecInfo$2 {
3622
3644
  return true;
3623
3645
  }
3624
3646
  if (line instanceof FmtpLine$1) {
3625
- this.fmtParams.push(line.params);
3626
- if (line.params.indexOf('apt') !== -1) {
3627
- var apt = line.params.split('=')[1];
3647
+ this.fmtParams = new Map([...Array.from(this.fmtParams.entries()), ...Array.from(line.params.entries())]);
3648
+ if (line.params.has('apt')) {
3649
+ var apt = line.params.get('apt');
3628
3650
  this.primaryCodecPt = parseInt(apt, 10);
3629
3651
  }
3630
3652
  return true;
@@ -3637,13 +3659,15 @@ class CodecInfo$2 {
3637
3659
  }
3638
3660
  toLines() {
3639
3661
  var lines = [];
3640
- lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3662
+ if (this.name && this.clockRate) {
3663
+ lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3664
+ }
3641
3665
  this.feedback.forEach(fb => {
3642
3666
  lines.push(new RtcpFbLine$1(this.pt, fb));
3643
3667
  });
3644
- this.fmtParams.forEach(fmt => {
3645
- lines.push(new FmtpLine$1(this.pt, fmt));
3646
- });
3668
+ if (this.fmtParams.size > 0) {
3669
+ lines.push(new FmtpLine$1(this.pt, this.fmtParams));
3670
+ }
3647
3671
  return lines;
3648
3672
  }
3649
3673
  }
@@ -4044,13 +4068,13 @@ function disableExtmap(sdp) {
4044
4068
  media.extMaps.length = 0;
4045
4069
  });
4046
4070
  }
4047
- function appendToH264fmtpParams(sdp, paramsToAppend) {
4071
+ function updateH264fmtpParams(sdp, paramsToUpdate) {
4048
4072
  sdp.avMedia.forEach(media => {
4049
4073
  if (media.type === 'video') {
4050
4074
  media.codecs.forEach(codec => {
4051
4075
  var _codec$name2;
4052
4076
  if (((_codec$name2 = codec.name) === null || _codec$name2 === void 0 ? void 0 : _codec$name2.toUpperCase()) === 'H264') {
4053
- codec.fmtParams = codec.fmtParams.map(fmtp => "".concat(fmtp, ";").concat(paramsToAppend));
4077
+ paramsToUpdate.forEach((value, key) => codec.fmtParams.set(key, value));
4054
4078
  }
4055
4079
  });
4056
4080
  }
@@ -4084,32 +4108,30 @@ function adjustH264Profile(sdp, maxFsValue) {
4084
4108
  media.codecs.forEach(codec => {
4085
4109
  var _codec$name3;
4086
4110
  if (((_codec$name3 = codec.name) === null || _codec$name3 === void 0 ? void 0 : _codec$name3.toUpperCase()) === 'H264') {
4087
- codec.fmtParams = codec.fmtParams.map(fmtp => {
4088
- var parsedRegex = fmtp.match(/(.*)profile-level-id=(\w{4})(\w{2})(.*)/);
4089
- if (parsedRegex && parsedRegex.length === 5) {
4090
- var stuffBeforeProfileLevelId = parsedRegex[1];
4091
- var profile = parsedRegex[2].toLowerCase();
4092
- var levelId = parseInt(parsedRegex[3], 16);
4093
- var stuffAfterProfileLevelId = parsedRegex[4];
4094
- if (!maxFsForProfileLevel[levelId]) {
4095
- throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
4096
- }
4097
- if (maxFsForProfileLevel[levelId] === maxFsValue) {
4098
- return fmtp;
4099
- }
4100
- if (maxFsForProfileLevel[levelId] < maxFsValue) {
4101
- return "".concat(fmtp, ";max-fs=").concat(maxFsValue, ";max-mbps=").concat(maxFsValue * framesPerSecond);
4102
- }
4103
- var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
4104
- if (newLevelId) {
4105
- var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
4106
- var maxMbps = "max-mbps=".concat(maxFsValue * framesPerSecond);
4107
- return "".concat(stuffBeforeProfileLevelId, "profile-level-id=").concat(profile).concat(newLevelIdHex, ";").concat(maxMbps).concat(stuffAfterProfileLevelId);
4108
- }
4109
- throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
4111
+ var profileLevelIdValue = codec.fmtParams.get('profile-level-id');
4112
+ if (profileLevelIdValue) {
4113
+ var profile = profileLevelIdValue.substring(0, 4).toLowerCase();
4114
+ var levelId = parseInt(profileLevelIdValue.substring(4, 6), 16);
4115
+ if (!maxFsForProfileLevel[levelId]) {
4116
+ throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
4110
4117
  }
4111
- return fmtp;
4112
- });
4118
+ if (maxFsForProfileLevel[levelId] === maxFsValue) {
4119
+ return;
4120
+ }
4121
+ if (maxFsForProfileLevel[levelId] < maxFsValue) {
4122
+ codec.fmtParams.set('max-fs', "".concat(maxFsValue));
4123
+ codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
4124
+ return;
4125
+ }
4126
+ var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
4127
+ if (newLevelId) {
4128
+ var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
4129
+ codec.fmtParams.set('profile-level-id', "".concat(profile).concat(newLevelIdHex));
4130
+ codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
4131
+ return;
4132
+ }
4133
+ throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
4134
+ }
4113
4135
  }
4114
4136
  });
4115
4137
  }
@@ -4160,7 +4182,7 @@ function mungeLocalSdp(config, sdp) {
4160
4182
  return parsedSdp.toString();
4161
4183
  }
4162
4184
  function setStartBitrate(sdp, startBitrate) {
4163
- appendToH264fmtpParams(sdp, "x-google-start-bitrate=".concat(startBitrate));
4185
+ updateH264fmtpParams(sdp, new Map([['x-google-start-bitrate', startBitrate.toString()]]));
4164
4186
  }
4165
4187
  function removeXtlsIceCandidates(sdp) {
4166
4188
  sdp.media.forEach(media => {
@@ -4518,6 +4540,145 @@ var DeviceKind;
4518
4540
  DeviceKind["AudioOutput"] = "audiooutput";
4519
4541
  DeviceKind["VideoInput"] = "videoinput";
4520
4542
  })(DeviceKind || (DeviceKind = {}));
4543
+ /**
4544
+ * Prompts the user for permission to use a media input which produces a MediaStream with tracks
4545
+ * containing the requested types of media.
4546
+ *
4547
+ * @param constraints - A MediaStreamConstraints object specifying the types of media to request,
4548
+ * along with any requirements for each type.
4549
+ * @returns A Promise whose fulfillment handler receives a MediaStream object when the requested
4550
+ * media has successfully been obtained.
4551
+ */
4552
+ function getUserMedia(constraints) {
4553
+ return __awaiter$1(this, void 0, void 0, function* () {
4554
+ return navigator.mediaDevices.getUserMedia(constraints);
4555
+ });
4556
+ }
4557
+ /**
4558
+ * Prompts the user for permission to use a user's display media and audio. If a video track is
4559
+ * absent from the constraints argument, one will still be provided.
4560
+ *
4561
+ * @param constraints - A MediaStreamConstraints object specifying the types of media to request,
4562
+ * along with any requirements for each type.
4563
+ * @returns A Promise whose fulfillment handler receives a MediaStream object when the requested
4564
+ * media has successfully been obtained.
4565
+ */
4566
+ function getDisplayMedia(constraints) {
4567
+ return navigator.mediaDevices.getDisplayMedia(constraints);
4568
+ }
4569
+ /**
4570
+ * Requests a list of the available media input and output devices, such as microphones, cameras,
4571
+ * headsets, and so forth.
4572
+ *
4573
+ * @returns A Promise that receives an array of MediaDeviceInfo objects when the promise is
4574
+ * fulfilled.
4575
+ */
4576
+ function enumerateDevices() {
4577
+ return __awaiter$1(this, void 0, void 0, function* () {
4578
+ return navigator.mediaDevices.enumerateDevices();
4579
+ });
4580
+ }
4581
+ /**
4582
+ * Adds the callback handler to be notified of a media device change (for example, a headset is
4583
+ * unplugged from the user's computer).
4584
+ *
4585
+ * @param handler - The callback function to execute.
4586
+ */
4587
+ function setOnDeviceChangeHandler$1(handler) {
4588
+ navigator.mediaDevices.ondevicechange = handler;
4589
+ }
4590
+ /**
4591
+ * Checks permissions using the navigator's permissions api.
4592
+ *
4593
+ * @param deviceKinds - Array of DeviceKind items.
4594
+ * @throws An error if camera or microphone aren't available options for query() (Firefox), or if
4595
+ * navigator.permissions is undefined (Safari and others).
4596
+ * @returns Array of Permission Status objects.
4597
+ */
4598
+ function checkNavigatorPermissions(deviceKinds) {
4599
+ return __awaiter$1(this, void 0, void 0, function* () {
4600
+ var permissionRequests = [];
4601
+ if (deviceKinds.includes(DeviceKind.VideoInput)) {
4602
+ permissionRequests.push(navigator.permissions.query({
4603
+ name: 'camera'
4604
+ }));
4605
+ }
4606
+ if (deviceKinds.includes(DeviceKind.AudioInput)) {
4607
+ permissionRequests.push(navigator.permissions.query({
4608
+ name: 'microphone'
4609
+ }));
4610
+ }
4611
+ return Promise.all(permissionRequests);
4612
+ });
4613
+ }
4614
+ /**
4615
+ * Check to see if the user has granted the application permission to use their devices.
4616
+ *
4617
+ * @param deviceKinds - Array of DeviceKind items.
4618
+ * @returns True if device permissions exist, false if otherwise.
4619
+ */
4620
+ function checkDevicePermissions(deviceKinds) {
4621
+ return __awaiter$1(this, void 0, void 0, function* () {
4622
+ try {
4623
+ var permissions = yield checkNavigatorPermissions(deviceKinds);
4624
+ if (permissions.every(permission => permission.state === 'granted')) {
4625
+ return true;
4626
+ }
4627
+ // eslint-disable-next-line no-empty
4628
+ } catch (e) {}
4629
+ try {
4630
+ var devices = yield enumerateDevices();
4631
+ // If permissions are granted, the MediaDeviceInfo objects will have labels.
4632
+ return devices.filter(device => deviceKinds.includes(device.kind)).every(device => device.label);
4633
+ // eslint-disable-next-line no-empty
4634
+ } catch (e) {}
4635
+ return false;
4636
+ });
4637
+ }
4638
+ /**
4639
+ * Ensures that the user has granted permissions to the microphone and camera.
4640
+ *
4641
+ * @param deviceKinds - Array of DeviceKind items.
4642
+ * @param callback - Function that will be executed while device permissions are granted. After this
4643
+ * returns, permissions (for example device labels in Firefox) may not be available anymore.
4644
+ * @returns The callback's response.
4645
+ */
4646
+ function ensureDevicePermissions(deviceKinds, callback) {
4647
+ return __awaiter$1(this, void 0, void 0, function* () {
4648
+ try {
4649
+ var hasDevicePermissions = yield checkDevicePermissions(deviceKinds);
4650
+ if (!hasDevicePermissions) {
4651
+ var stream = yield getUserMedia({
4652
+ audio: deviceKinds.includes(DeviceKind.AudioInput),
4653
+ video: deviceKinds.includes(DeviceKind.VideoInput)
4654
+ });
4655
+ // Callback is here to call a function while an active capture exists, so that the browser
4656
+ // (Firefox) will allow the user to access device information.
4657
+ var callbackRes = yield callback();
4658
+ // Stop tracks in the stream so the browser (Safari) will know that there is not an active
4659
+ // stream running.
4660
+ stream.getTracks().forEach(track => track.stop());
4661
+ return callbackRes;
4662
+ }
4663
+ return callback();
4664
+ } catch (e) {
4665
+ logger$3.error(e);
4666
+ throw new Error('Failed to ensure device permissions.');
4667
+ }
4668
+ });
4669
+ }
4670
+ var media = /*#__PURE__*/Object.freeze({
4671
+ __proto__: null,
4672
+ get DeviceKind() {
4673
+ return DeviceKind;
4674
+ },
4675
+ getUserMedia: getUserMedia,
4676
+ getDisplayMedia: getDisplayMedia,
4677
+ enumerateDevices: enumerateDevices,
4678
+ setOnDeviceChangeHandler: setOnDeviceChangeHandler$1,
4679
+ checkDevicePermissions: checkDevicePermissions,
4680
+ ensureDevicePermissions: ensureDevicePermissions
4681
+ });
4521
4682
  var events$1 = {
4522
4683
  exports: {}
4523
4684
  };
@@ -5202,6 +5363,129 @@ var ErrorTypes;
5202
5363
  ErrorTypes["CREATE_CAMERA_TRACK_FAILED"] = "CREATE_CAMERA_TRACK_FAILED";
5203
5364
  ErrorTypes["CREATE_MICROPHONE_TRACK_FAILED"] = "CREATE_MICROPHONE_TRACK_FAILED";
5204
5365
  })(ErrorTypes || (ErrorTypes = {}));
5366
+ /**
5367
+ * Represents a WCME error, which contains error type and error message.
5368
+ */
5369
+ class WcmeError {
5370
+ /**
5371
+ * Creates new error.
5372
+ *
5373
+ * @param type - Error type.
5374
+ * @param message - Error message.
5375
+ */
5376
+ constructor(type) {
5377
+ var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5378
+ this.type = type;
5379
+ this.message = message;
5380
+ }
5381
+ }
5382
+ /**
5383
+ * Creates a camera video track. Please note that the constraint params in second getUserMedia call would NOT take effect when:
5384
+ *
5385
+ * 1. Previous captured video track from the same device is not stopped .
5386
+ * 2. Previous createCameraTrack() call for the same device is in progress.
5387
+ *
5388
+ * @param constraints - Video device constraints.
5389
+ * @returns A LocalTrack object or an error.
5390
+ */
5391
+ function createCameraTrack(constraints) {
5392
+ return __awaiter$1(this, void 0, void 0, function* () {
5393
+ var stream;
5394
+ try {
5395
+ stream = yield getUserMedia({
5396
+ video: Object.assign({}, constraints)
5397
+ });
5398
+ } catch (error) {
5399
+ throw new WcmeError(ErrorTypes.CREATE_CAMERA_TRACK_FAILED, "Failed to create camera track ".concat(error));
5400
+ }
5401
+ return new LocalCameraTrack(stream);
5402
+ });
5403
+ }
5404
+ /**
5405
+ * Creates a microphone audio track.
5406
+ *
5407
+ * @param constraints - Audio device constraints.
5408
+ * @returns A LocalTrack object or an error.
5409
+ */
5410
+ function createMicrophoneTrack(constraints) {
5411
+ return __awaiter$1(this, void 0, void 0, function* () {
5412
+ var stream;
5413
+ try {
5414
+ stream = yield getUserMedia({
5415
+ audio: Object.assign({}, constraints)
5416
+ });
5417
+ } catch (error) {
5418
+ throw new WcmeError(ErrorTypes.CREATE_MICROPHONE_TRACK_FAILED, "Failed to create microphone track ".concat(error));
5419
+ }
5420
+ return new LocalMicrophoneTrack(stream);
5421
+ });
5422
+ }
5423
+ /**
5424
+ * Creates a display video track.
5425
+ *
5426
+ * @returns A Promise that resolves to a LocalDisplayTrack.
5427
+ */
5428
+ function createDisplayTrack() {
5429
+ return __awaiter$1(this, void 0, void 0, function* () {
5430
+ var stream = yield getDisplayMedia({
5431
+ video: true
5432
+ });
5433
+ return new LocalDisplayTrack(stream);
5434
+ });
5435
+ }
5436
+ /**
5437
+ * Enumerates the media input and output devices available.
5438
+ *
5439
+ * @param deviceKind - Optional filter to return a specific device kind.
5440
+ * @returns List of media devices in an array of MediaDeviceInfo objects.
5441
+ */
5442
+ function getDevices(deviceKind) {
5443
+ return __awaiter$1(this, void 0, void 0, function* () {
5444
+ var devices;
5445
+ try {
5446
+ devices = yield ensureDevicePermissions([DeviceKind.AudioInput, DeviceKind.VideoInput], enumerateDevices);
5447
+ } catch (error) {
5448
+ throw new WcmeError(ErrorTypes.DEVICE_PERMISSION_DENIED, 'Failed to ensure device permissions');
5449
+ }
5450
+ return devices.filter(v => deviceKind ? v.kind === deviceKind : true);
5451
+ });
5452
+ }
5453
+ /**
5454
+ * Helper function to get a list of microphone devices.
5455
+ *
5456
+ * @returns List of microphone devices in an array of MediaDeviceInfo objects.
5457
+ */
5458
+ function getAudioInputDevices() {
5459
+ return __awaiter$1(this, void 0, void 0, function* () {
5460
+ return getDevices(DeviceKind.AudioInput);
5461
+ });
5462
+ }
5463
+ /**
5464
+ * Helper function to get a list of speaker devices.
5465
+ *
5466
+ * @returns List of speaker devices in an array of MediaDeviceInfo objects.
5467
+ */
5468
+ function getAudioOutputDevices() {
5469
+ return __awaiter$1(this, void 0, void 0, function* () {
5470
+ return getDevices(DeviceKind.AudioOutput);
5471
+ });
5472
+ }
5473
+ /**
5474
+ * Helper function to get a list of camera devices.
5475
+ *
5476
+ * @returns List of camera devices in an array of MediaDeviceInfo objects.
5477
+ */
5478
+ function getVideoInputDevices() {
5479
+ return __awaiter$1(this, void 0, void 0, function* () {
5480
+ return getDevices(DeviceKind.VideoInput);
5481
+ });
5482
+ }
5483
+ /**
5484
+ * Export the setOnDeviceChangeHandler method directly from the core lib.
5485
+ */
5486
+ var {
5487
+ setOnDeviceChangeHandler
5488
+ } = media;
5205
5489
 
5206
5490
  // Overall connection state (based on the ICE and DTLS connection states)
5207
5491
  exports.ConnectionState = void 0;
@@ -8374,11 +8658,11 @@ function createRTCPeerConnection(configuration) {
8374
8658
  /**
8375
8659
  * A type-safe form of the DOMString used in the MediaStreamTrack.kind field.
8376
8660
  */
8377
- var MediaStreamTrackKind;
8661
+ exports.MediaStreamTrackKind = void 0;
8378
8662
  (function (MediaStreamTrackKind) {
8379
8663
  MediaStreamTrackKind["Audio"] = "audio";
8380
8664
  MediaStreamTrackKind["Video"] = "video";
8381
- })(MediaStreamTrackKind || (MediaStreamTrackKind = {}));
8665
+ })(exports.MediaStreamTrackKind || (exports.MediaStreamTrackKind = {}));
8382
8666
  var PeerConnectionEvents;
8383
8667
  (function (PeerConnectionEvents) {
8384
8668
  PeerConnectionEvents["IceGatheringStateChange"] = "icegatheringstatechange";
@@ -14219,10 +14503,10 @@ function setLogHandler(logHandler) {
14219
14503
  Logger$1.setHandler(logHandler);
14220
14504
  }
14221
14505
  function toMediaStreamTrackKind(mediaType) {
14222
- return [MediaType.VideoMain, MediaType.VideoSlides].includes(mediaType) ? MediaStreamTrackKind.Video : MediaStreamTrackKind.Audio;
14506
+ return [MediaType.VideoMain, MediaType.VideoSlides].includes(mediaType) ? exports.MediaStreamTrackKind.Video : exports.MediaStreamTrackKind.Audio;
14223
14507
  }
14224
14508
  function toMediaFamily(kind) {
14225
- if (kind === MediaStreamTrackKind.Video) {
14509
+ if (kind === exports.MediaStreamTrackKind.Video) {
14226
14510
  return MediaFamily.Video;
14227
14511
  }
14228
14512
  return MediaFamily.Audio;
@@ -24183,11 +24467,21 @@ exports.LocalTrack = LocalTrack;
24183
24467
  exports.Media = Media;
24184
24468
  exports.MediaRequest = MediaRequest;
24185
24469
  exports.MultistreamRoapMediaConnection = MultistreamRoapMediaConnection;
24470
+ exports.PeerConnection = PeerConnection;
24186
24471
  exports.ReceiveSlot = ReceiveSlot;
24187
24472
  exports.ReceiverSelectedInfo = ReceiverSelectedInfo;
24188
24473
  exports.RoapMediaConnection = RoapMediaConnection;
24474
+ exports.WcmeError = WcmeError;
24475
+ exports.createCameraTrack = createCameraTrack;
24476
+ exports.createDisplayTrack = createDisplayTrack;
24477
+ exports.createMicrophoneTrack = createMicrophoneTrack;
24478
+ exports.getAudioInputDevices = getAudioInputDevices;
24479
+ exports.getAudioOutputDevices = getAudioOutputDevices;
24480
+ exports.getDevices = getDevices;
24189
24481
  exports.getErrorDescription = getErrorDescription;
24190
24482
  exports.getLogger = getLogger;
24191
24483
  exports.getMediaFamily = getMediaFamily;
24484
+ exports.getVideoInputDevices = getVideoInputDevices;
24192
24485
  exports.isBrowserSupported = isBrowserSupported;
24193
24486
  exports.setLogger = setLogger;
24487
+ exports.setOnDeviceChangeHandler = setOnDeviceChangeHandler;
package/dist/esm/index.js CHANGED
@@ -1972,7 +1972,7 @@ class Track extends EventEmitter$4 {
1972
1972
 
1973
1973
  var eventEmitter = new EventEmitter$4();
1974
1974
  var deviceList = [];
1975
- var getDevices = /*#__PURE__*/function () {
1975
+ var getDevices$1 = /*#__PURE__*/function () {
1976
1976
  var _ref = _asyncToGenerator(function* () {
1977
1977
  var _navigator$mediaDevic;
1978
1978
  logger$5.debug({
@@ -2002,7 +2002,7 @@ var getCameras = /*#__PURE__*/function () {
2002
2002
  action: 'getCameras()',
2003
2003
  description: 'Called'
2004
2004
  });
2005
- var devices = yield getDevices();
2005
+ var devices = yield getDevices$1();
2006
2006
  logger$5.info({
2007
2007
  mediaType: DEVICE,
2008
2008
  action: 'getCameras()',
@@ -2034,7 +2034,7 @@ var getMicrophones = /*#__PURE__*/function () {
2034
2034
  action: 'getMicrophones()',
2035
2035
  description: 'Called'
2036
2036
  });
2037
- var devices = yield getDevices();
2037
+ var devices = yield getDevices$1();
2038
2038
  logger$5.info({
2039
2039
  mediaType: DEVICE,
2040
2040
  action: 'getMicrophones()',
@@ -2066,7 +2066,7 @@ var getSpeakers = /*#__PURE__*/function () {
2066
2066
  action: 'getSpeakers()',
2067
2067
  description: 'Called'
2068
2068
  });
2069
- var devices = yield getDevices();
2069
+ var devices = yield getDevices$1();
2070
2070
  logger$5.info({
2071
2071
  mediaType: DEVICE,
2072
2072
  action: 'getSpeakers()',
@@ -2378,7 +2378,7 @@ function _on() {
2378
2378
  });
2379
2379
  eventEmitter.on(eventName, listener);
2380
2380
  if (eventName === 'device:changed') {
2381
- var thisDeviceList = yield getDevices();
2381
+ var thisDeviceList = yield getDevices$1();
2382
2382
  deviceList.push(...thisDeviceList);
2383
2383
  navigator.mediaDevices.addEventListener('devicechange', deviceChangePublisher);
2384
2384
  }
@@ -2922,6 +2922,22 @@ class FingerprintLine$1 extends Line$1 {
2922
2922
  }
2923
2923
  }
2924
2924
  FingerprintLine$1.regex = new RegExp("^fingerprint:(".concat(REST$1, ")"));
2925
+ function parseFmtpParams$1(fmtpParams) {
2926
+ fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
2927
+ var fmtpObj = new Map();
2928
+ if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
2929
+ fmtpObj.set(fmtpParams, undefined);
2930
+ return fmtpObj;
2931
+ }
2932
+ fmtpParams.split(';').forEach(param => {
2933
+ var paramArr = param && param.split('=');
2934
+ if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
2935
+ throw new Error("Fmtp params is invalid with ".concat(fmtpParams));
2936
+ }
2937
+ fmtpObj.set(paramArr[0], paramArr[1]);
2938
+ });
2939
+ return fmtpObj;
2940
+ }
2925
2941
  class FmtpLine$1 extends Line$1 {
2926
2942
  constructor(payloadType, params) {
2927
2943
  super();
@@ -2935,10 +2951,16 @@ class FmtpLine$1 extends Line$1 {
2935
2951
  var tokens = line.match(FmtpLine$1.regex);
2936
2952
  var payloadType = parseInt(tokens[1], 10);
2937
2953
  var params = tokens[2];
2938
- return new FmtpLine$1(payloadType, params);
2954
+ return new FmtpLine$1(payloadType, parseFmtpParams$1(params));
2939
2955
  }
2940
2956
  toSdpLine() {
2941
- return "a=fmtp:".concat(this.payloadType, " ").concat(this.params);
2957
+ var fmtParams = Array.from(this.params.keys()).map(key => {
2958
+ if (this.params.get(key) !== undefined) {
2959
+ return "".concat(key, "=").concat(this.params.get(key));
2960
+ }
2961
+ return "".concat(key);
2962
+ }).join(';');
2963
+ return "a=fmtp:".concat(this.payloadType, " ").concat(fmtParams);
2942
2964
  }
2943
2965
  }
2944
2966
  FmtpLine$1.regex = new RegExp("^fmtp:(".concat(NUM$1, ") (").concat(REST$1, ")"));
@@ -3599,7 +3621,7 @@ class ApplicationMediaDescription$1 extends MediaDescription$1 {
3599
3621
  }
3600
3622
  class CodecInfo$2 {
3601
3623
  constructor(pt) {
3602
- this.fmtParams = [];
3624
+ this.fmtParams = new Map();
3603
3625
  this.feedback = [];
3604
3626
  this.pt = pt;
3605
3627
  }
@@ -3611,9 +3633,9 @@ class CodecInfo$2 {
3611
3633
  return true;
3612
3634
  }
3613
3635
  if (line instanceof FmtpLine$1) {
3614
- this.fmtParams.push(line.params);
3615
- if (line.params.indexOf('apt') !== -1) {
3616
- var apt = line.params.split('=')[1];
3636
+ this.fmtParams = new Map([...Array.from(this.fmtParams.entries()), ...Array.from(line.params.entries())]);
3637
+ if (line.params.has('apt')) {
3638
+ var apt = line.params.get('apt');
3617
3639
  this.primaryCodecPt = parseInt(apt, 10);
3618
3640
  }
3619
3641
  return true;
@@ -3626,13 +3648,15 @@ class CodecInfo$2 {
3626
3648
  }
3627
3649
  toLines() {
3628
3650
  var lines = [];
3629
- lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3651
+ if (this.name && this.clockRate) {
3652
+ lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3653
+ }
3630
3654
  this.feedback.forEach(fb => {
3631
3655
  lines.push(new RtcpFbLine$1(this.pt, fb));
3632
3656
  });
3633
- this.fmtParams.forEach(fmt => {
3634
- lines.push(new FmtpLine$1(this.pt, fmt));
3635
- });
3657
+ if (this.fmtParams.size > 0) {
3658
+ lines.push(new FmtpLine$1(this.pt, this.fmtParams));
3659
+ }
3636
3660
  return lines;
3637
3661
  }
3638
3662
  }
@@ -4033,13 +4057,13 @@ function disableExtmap(sdp) {
4033
4057
  media.extMaps.length = 0;
4034
4058
  });
4035
4059
  }
4036
- function appendToH264fmtpParams(sdp, paramsToAppend) {
4060
+ function updateH264fmtpParams(sdp, paramsToUpdate) {
4037
4061
  sdp.avMedia.forEach(media => {
4038
4062
  if (media.type === 'video') {
4039
4063
  media.codecs.forEach(codec => {
4040
4064
  var _codec$name2;
4041
4065
  if (((_codec$name2 = codec.name) === null || _codec$name2 === void 0 ? void 0 : _codec$name2.toUpperCase()) === 'H264') {
4042
- codec.fmtParams = codec.fmtParams.map(fmtp => "".concat(fmtp, ";").concat(paramsToAppend));
4066
+ paramsToUpdate.forEach((value, key) => codec.fmtParams.set(key, value));
4043
4067
  }
4044
4068
  });
4045
4069
  }
@@ -4073,32 +4097,30 @@ function adjustH264Profile(sdp, maxFsValue) {
4073
4097
  media.codecs.forEach(codec => {
4074
4098
  var _codec$name3;
4075
4099
  if (((_codec$name3 = codec.name) === null || _codec$name3 === void 0 ? void 0 : _codec$name3.toUpperCase()) === 'H264') {
4076
- codec.fmtParams = codec.fmtParams.map(fmtp => {
4077
- var parsedRegex = fmtp.match(/(.*)profile-level-id=(\w{4})(\w{2})(.*)/);
4078
- if (parsedRegex && parsedRegex.length === 5) {
4079
- var stuffBeforeProfileLevelId = parsedRegex[1];
4080
- var profile = parsedRegex[2].toLowerCase();
4081
- var levelId = parseInt(parsedRegex[3], 16);
4082
- var stuffAfterProfileLevelId = parsedRegex[4];
4083
- if (!maxFsForProfileLevel[levelId]) {
4084
- throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
4085
- }
4086
- if (maxFsForProfileLevel[levelId] === maxFsValue) {
4087
- return fmtp;
4088
- }
4089
- if (maxFsForProfileLevel[levelId] < maxFsValue) {
4090
- return "".concat(fmtp, ";max-fs=").concat(maxFsValue, ";max-mbps=").concat(maxFsValue * framesPerSecond);
4091
- }
4092
- var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
4093
- if (newLevelId) {
4094
- var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
4095
- var maxMbps = "max-mbps=".concat(maxFsValue * framesPerSecond);
4096
- return "".concat(stuffBeforeProfileLevelId, "profile-level-id=").concat(profile).concat(newLevelIdHex, ";").concat(maxMbps).concat(stuffAfterProfileLevelId);
4097
- }
4098
- throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
4100
+ var profileLevelIdValue = codec.fmtParams.get('profile-level-id');
4101
+ if (profileLevelIdValue) {
4102
+ var profile = profileLevelIdValue.substring(0, 4).toLowerCase();
4103
+ var levelId = parseInt(profileLevelIdValue.substring(4, 6), 16);
4104
+ if (!maxFsForProfileLevel[levelId]) {
4105
+ throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
4099
4106
  }
4100
- return fmtp;
4101
- });
4107
+ if (maxFsForProfileLevel[levelId] === maxFsValue) {
4108
+ return;
4109
+ }
4110
+ if (maxFsForProfileLevel[levelId] < maxFsValue) {
4111
+ codec.fmtParams.set('max-fs', "".concat(maxFsValue));
4112
+ codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
4113
+ return;
4114
+ }
4115
+ var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
4116
+ if (newLevelId) {
4117
+ var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
4118
+ codec.fmtParams.set('profile-level-id', "".concat(profile).concat(newLevelIdHex));
4119
+ codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
4120
+ return;
4121
+ }
4122
+ throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
4123
+ }
4102
4124
  }
4103
4125
  });
4104
4126
  }
@@ -4149,7 +4171,7 @@ function mungeLocalSdp(config, sdp) {
4149
4171
  return parsedSdp.toString();
4150
4172
  }
4151
4173
  function setStartBitrate(sdp, startBitrate) {
4152
- appendToH264fmtpParams(sdp, "x-google-start-bitrate=".concat(startBitrate));
4174
+ updateH264fmtpParams(sdp, new Map([['x-google-start-bitrate', startBitrate.toString()]]));
4153
4175
  }
4154
4176
  function removeXtlsIceCandidates(sdp) {
4155
4177
  sdp.media.forEach(media => {
@@ -4507,6 +4529,145 @@ var DeviceKind;
4507
4529
  DeviceKind["AudioOutput"] = "audiooutput";
4508
4530
  DeviceKind["VideoInput"] = "videoinput";
4509
4531
  })(DeviceKind || (DeviceKind = {}));
4532
+ /**
4533
+ * Prompts the user for permission to use a media input which produces a MediaStream with tracks
4534
+ * containing the requested types of media.
4535
+ *
4536
+ * @param constraints - A MediaStreamConstraints object specifying the types of media to request,
4537
+ * along with any requirements for each type.
4538
+ * @returns A Promise whose fulfillment handler receives a MediaStream object when the requested
4539
+ * media has successfully been obtained.
4540
+ */
4541
+ function getUserMedia(constraints) {
4542
+ return __awaiter$1(this, void 0, void 0, function* () {
4543
+ return navigator.mediaDevices.getUserMedia(constraints);
4544
+ });
4545
+ }
4546
+ /**
4547
+ * Prompts the user for permission to use a user's display media and audio. If a video track is
4548
+ * absent from the constraints argument, one will still be provided.
4549
+ *
4550
+ * @param constraints - A MediaStreamConstraints object specifying the types of media to request,
4551
+ * along with any requirements for each type.
4552
+ * @returns A Promise whose fulfillment handler receives a MediaStream object when the requested
4553
+ * media has successfully been obtained.
4554
+ */
4555
+ function getDisplayMedia(constraints) {
4556
+ return navigator.mediaDevices.getDisplayMedia(constraints);
4557
+ }
4558
+ /**
4559
+ * Requests a list of the available media input and output devices, such as microphones, cameras,
4560
+ * headsets, and so forth.
4561
+ *
4562
+ * @returns A Promise that receives an array of MediaDeviceInfo objects when the promise is
4563
+ * fulfilled.
4564
+ */
4565
+ function enumerateDevices() {
4566
+ return __awaiter$1(this, void 0, void 0, function* () {
4567
+ return navigator.mediaDevices.enumerateDevices();
4568
+ });
4569
+ }
4570
+ /**
4571
+ * Adds the callback handler to be notified of a media device change (for example, a headset is
4572
+ * unplugged from the user's computer).
4573
+ *
4574
+ * @param handler - The callback function to execute.
4575
+ */
4576
+ function setOnDeviceChangeHandler$1(handler) {
4577
+ navigator.mediaDevices.ondevicechange = handler;
4578
+ }
4579
+ /**
4580
+ * Checks permissions using the navigator's permissions api.
4581
+ *
4582
+ * @param deviceKinds - Array of DeviceKind items.
4583
+ * @throws An error if camera or microphone aren't available options for query() (Firefox), or if
4584
+ * navigator.permissions is undefined (Safari and others).
4585
+ * @returns Array of Permission Status objects.
4586
+ */
4587
+ function checkNavigatorPermissions(deviceKinds) {
4588
+ return __awaiter$1(this, void 0, void 0, function* () {
4589
+ var permissionRequests = [];
4590
+ if (deviceKinds.includes(DeviceKind.VideoInput)) {
4591
+ permissionRequests.push(navigator.permissions.query({
4592
+ name: 'camera'
4593
+ }));
4594
+ }
4595
+ if (deviceKinds.includes(DeviceKind.AudioInput)) {
4596
+ permissionRequests.push(navigator.permissions.query({
4597
+ name: 'microphone'
4598
+ }));
4599
+ }
4600
+ return Promise.all(permissionRequests);
4601
+ });
4602
+ }
4603
+ /**
4604
+ * Check to see if the user has granted the application permission to use their devices.
4605
+ *
4606
+ * @param deviceKinds - Array of DeviceKind items.
4607
+ * @returns True if device permissions exist, false if otherwise.
4608
+ */
4609
+ function checkDevicePermissions(deviceKinds) {
4610
+ return __awaiter$1(this, void 0, void 0, function* () {
4611
+ try {
4612
+ var permissions = yield checkNavigatorPermissions(deviceKinds);
4613
+ if (permissions.every(permission => permission.state === 'granted')) {
4614
+ return true;
4615
+ }
4616
+ // eslint-disable-next-line no-empty
4617
+ } catch (e) {}
4618
+ try {
4619
+ var devices = yield enumerateDevices();
4620
+ // If permissions are granted, the MediaDeviceInfo objects will have labels.
4621
+ return devices.filter(device => deviceKinds.includes(device.kind)).every(device => device.label);
4622
+ // eslint-disable-next-line no-empty
4623
+ } catch (e) {}
4624
+ return false;
4625
+ });
4626
+ }
4627
+ /**
4628
+ * Ensures that the user has granted permissions to the microphone and camera.
4629
+ *
4630
+ * @param deviceKinds - Array of DeviceKind items.
4631
+ * @param callback - Function that will be executed while device permissions are granted. After this
4632
+ * returns, permissions (for example device labels in Firefox) may not be available anymore.
4633
+ * @returns The callback's response.
4634
+ */
4635
+ function ensureDevicePermissions(deviceKinds, callback) {
4636
+ return __awaiter$1(this, void 0, void 0, function* () {
4637
+ try {
4638
+ var hasDevicePermissions = yield checkDevicePermissions(deviceKinds);
4639
+ if (!hasDevicePermissions) {
4640
+ var stream = yield getUserMedia({
4641
+ audio: deviceKinds.includes(DeviceKind.AudioInput),
4642
+ video: deviceKinds.includes(DeviceKind.VideoInput)
4643
+ });
4644
+ // Callback is here to call a function while an active capture exists, so that the browser
4645
+ // (Firefox) will allow the user to access device information.
4646
+ var callbackRes = yield callback();
4647
+ // Stop tracks in the stream so the browser (Safari) will know that there is not an active
4648
+ // stream running.
4649
+ stream.getTracks().forEach(track => track.stop());
4650
+ return callbackRes;
4651
+ }
4652
+ return callback();
4653
+ } catch (e) {
4654
+ logger$3.error(e);
4655
+ throw new Error('Failed to ensure device permissions.');
4656
+ }
4657
+ });
4658
+ }
4659
+ var media = /*#__PURE__*/Object.freeze({
4660
+ __proto__: null,
4661
+ get DeviceKind() {
4662
+ return DeviceKind;
4663
+ },
4664
+ getUserMedia: getUserMedia,
4665
+ getDisplayMedia: getDisplayMedia,
4666
+ enumerateDevices: enumerateDevices,
4667
+ setOnDeviceChangeHandler: setOnDeviceChangeHandler$1,
4668
+ checkDevicePermissions: checkDevicePermissions,
4669
+ ensureDevicePermissions: ensureDevicePermissions
4670
+ });
4510
4671
  var events$1 = {
4511
4672
  exports: {}
4512
4673
  };
@@ -5191,6 +5352,129 @@ var ErrorTypes;
5191
5352
  ErrorTypes["CREATE_CAMERA_TRACK_FAILED"] = "CREATE_CAMERA_TRACK_FAILED";
5192
5353
  ErrorTypes["CREATE_MICROPHONE_TRACK_FAILED"] = "CREATE_MICROPHONE_TRACK_FAILED";
5193
5354
  })(ErrorTypes || (ErrorTypes = {}));
5355
+ /**
5356
+ * Represents a WCME error, which contains error type and error message.
5357
+ */
5358
+ class WcmeError {
5359
+ /**
5360
+ * Creates new error.
5361
+ *
5362
+ * @param type - Error type.
5363
+ * @param message - Error message.
5364
+ */
5365
+ constructor(type) {
5366
+ var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5367
+ this.type = type;
5368
+ this.message = message;
5369
+ }
5370
+ }
5371
+ /**
5372
+ * Creates a camera video track. Please note that the constraint params in second getUserMedia call would NOT take effect when:
5373
+ *
5374
+ * 1. Previous captured video track from the same device is not stopped .
5375
+ * 2. Previous createCameraTrack() call for the same device is in progress.
5376
+ *
5377
+ * @param constraints - Video device constraints.
5378
+ * @returns A LocalTrack object or an error.
5379
+ */
5380
+ function createCameraTrack(constraints) {
5381
+ return __awaiter$1(this, void 0, void 0, function* () {
5382
+ var stream;
5383
+ try {
5384
+ stream = yield getUserMedia({
5385
+ video: Object.assign({}, constraints)
5386
+ });
5387
+ } catch (error) {
5388
+ throw new WcmeError(ErrorTypes.CREATE_CAMERA_TRACK_FAILED, "Failed to create camera track ".concat(error));
5389
+ }
5390
+ return new LocalCameraTrack(stream);
5391
+ });
5392
+ }
5393
+ /**
5394
+ * Creates a microphone audio track.
5395
+ *
5396
+ * @param constraints - Audio device constraints.
5397
+ * @returns A LocalTrack object or an error.
5398
+ */
5399
+ function createMicrophoneTrack(constraints) {
5400
+ return __awaiter$1(this, void 0, void 0, function* () {
5401
+ var stream;
5402
+ try {
5403
+ stream = yield getUserMedia({
5404
+ audio: Object.assign({}, constraints)
5405
+ });
5406
+ } catch (error) {
5407
+ throw new WcmeError(ErrorTypes.CREATE_MICROPHONE_TRACK_FAILED, "Failed to create microphone track ".concat(error));
5408
+ }
5409
+ return new LocalMicrophoneTrack(stream);
5410
+ });
5411
+ }
5412
+ /**
5413
+ * Creates a display video track.
5414
+ *
5415
+ * @returns A Promise that resolves to a LocalDisplayTrack.
5416
+ */
5417
+ function createDisplayTrack() {
5418
+ return __awaiter$1(this, void 0, void 0, function* () {
5419
+ var stream = yield getDisplayMedia({
5420
+ video: true
5421
+ });
5422
+ return new LocalDisplayTrack(stream);
5423
+ });
5424
+ }
5425
+ /**
5426
+ * Enumerates the media input and output devices available.
5427
+ *
5428
+ * @param deviceKind - Optional filter to return a specific device kind.
5429
+ * @returns List of media devices in an array of MediaDeviceInfo objects.
5430
+ */
5431
+ function getDevices(deviceKind) {
5432
+ return __awaiter$1(this, void 0, void 0, function* () {
5433
+ var devices;
5434
+ try {
5435
+ devices = yield ensureDevicePermissions([DeviceKind.AudioInput, DeviceKind.VideoInput], enumerateDevices);
5436
+ } catch (error) {
5437
+ throw new WcmeError(ErrorTypes.DEVICE_PERMISSION_DENIED, 'Failed to ensure device permissions');
5438
+ }
5439
+ return devices.filter(v => deviceKind ? v.kind === deviceKind : true);
5440
+ });
5441
+ }
5442
+ /**
5443
+ * Helper function to get a list of microphone devices.
5444
+ *
5445
+ * @returns List of microphone devices in an array of MediaDeviceInfo objects.
5446
+ */
5447
+ function getAudioInputDevices() {
5448
+ return __awaiter$1(this, void 0, void 0, function* () {
5449
+ return getDevices(DeviceKind.AudioInput);
5450
+ });
5451
+ }
5452
+ /**
5453
+ * Helper function to get a list of speaker devices.
5454
+ *
5455
+ * @returns List of speaker devices in an array of MediaDeviceInfo objects.
5456
+ */
5457
+ function getAudioOutputDevices() {
5458
+ return __awaiter$1(this, void 0, void 0, function* () {
5459
+ return getDevices(DeviceKind.AudioOutput);
5460
+ });
5461
+ }
5462
+ /**
5463
+ * Helper function to get a list of camera devices.
5464
+ *
5465
+ * @returns List of camera devices in an array of MediaDeviceInfo objects.
5466
+ */
5467
+ function getVideoInputDevices() {
5468
+ return __awaiter$1(this, void 0, void 0, function* () {
5469
+ return getDevices(DeviceKind.VideoInput);
5470
+ });
5471
+ }
5472
+ /**
5473
+ * Export the setOnDeviceChangeHandler method directly from the core lib.
5474
+ */
5475
+ var {
5476
+ setOnDeviceChangeHandler
5477
+ } = media;
5194
5478
 
5195
5479
  // Overall connection state (based on the ICE and DTLS connection states)
5196
5480
  var ConnectionState;
@@ -24161,4 +24445,4 @@ var Media = {
24161
24445
  isBrowserSupported
24162
24446
  };
24163
24447
 
24164
- export { ActiveSpeakerInfo, CodecInfo, ConnectionState, ErrorType, Errors, Event$1 as Event, H264Codec, LocalCameraTrack, LocalDisplayTrack, LocalMicrophoneTrack, LocalTrack, LocalTrackEvents, Media, MediaFamily, MediaRequest, MediaType, MultistreamRoapMediaConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RemoteTrackType, RoapMediaConnection, getErrorDescription, getLogger, getMediaFamily, isBrowserSupported, setLogger };
24448
+ export { ActiveSpeakerInfo, CodecInfo, ConnectionState, ErrorType, Errors, Event$1 as Event, H264Codec, LocalCameraTrack, LocalDisplayTrack, LocalMicrophoneTrack, LocalTrack, LocalTrackEvents, Media, MediaFamily, MediaRequest, MediaStreamTrackKind, MediaType, MultistreamRoapMediaConnection, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RemoteTrackType, RoapMediaConnection, WcmeError, createCameraTrack, createDisplayTrack, createMicrophoneTrack, getAudioInputDevices, getAudioOutputDevices, getDevices, getErrorDescription, getLogger, getMediaFamily, getVideoInputDevices, isBrowserSupported, setLogger, setOnDeviceChangeHandler };
@@ -4,7 +4,7 @@ import { LocalTrack, MediaRequest, ReceiveSlot, TransceiverStats } from '@webex/
4
4
  import { MediaType } from '@webex/json-multistream';
5
5
  import { ConnectionState, RoapMessage } from './eventTypes';
6
6
  import { MultistreamConnectionConfig } from './config';
7
- export { LocalCameraTrack, LocalDisplayTrack, LocalMicrophoneTrack, LocalTrack, LocalTrackEvents, MediaRequest, ReceiveSlot, ReceiveSlotEvents, } from '@webex/web-client-media-engine';
7
+ export { MediaRequest, ReceiveSlot, ReceiveSlotEvents, getAudioOutputDevices, getVideoInputDevices, setOnDeviceChangeHandler, WcmeError, AudioDeviceConstraints, VideoDeviceConstraints, LocalTrackEvents, TrackPublishEvent, TrackMuteEvent, TrackEndEvent, LocalCameraTrack, LocalDisplayTrack, LocalMicrophoneTrack, LocalTrack, MediaStreamTrackKind, PeerConnection, createCameraTrack, createDisplayTrack, createMicrophoneTrack, getDevices, getAudioInputDevices, } from '@webex/web-client-media-engine';
8
8
  export { ActiveSpeakerInfo, CodecInfo, getMediaFamily, H264Codec, MediaFamily, MediaType, SourceState, Policy, PolicySpecificInfo, ReceiverSelectedInfo, } from '@webex/json-multistream';
9
9
  export declare class MultistreamRoapMediaConnection extends EventEmitter {
10
10
  private id?;
@@ -1 +1 @@
1
- {"version":3,"file":"MultistreamRoapMediaConnection.d.ts","sourceRoot":"","sources":["../../../src/MediaConnection/MultistreamRoapMediaConnection.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,EAEL,UAAU,EACV,YAAY,EAGZ,WAAW,EACX,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAA6C,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAG9F,OAAO,EAAQ,eAAe,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAC;AAKnF,OAAO,EAAC,2BAA2B,EAAC,MAAM,UAAU,CAAC;AAGrD,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,MAAM,EACN,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAGjC,qBAAa,8BAA+B,SAAQ,YAAY;IAC9D,OAAO,CAAC,EAAE,CAAC,CAAS;IAEpB,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,OAAO,CAAC,qBAAqB,CAAwB;IAErD,OAAO,CAAC,IAAI,CAAO;IAEnB,OAAO,CAAC,qBAAqB,CAAS;gBAS1B,qBAAqB,EAAE,2BAA2B,EAAE,OAAO,CAAC,EAAE,MAAM;IAehF,OAAO,CAAC,mBAAmB;IAqC3B,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,2BAA2B;IAyCnC,OAAO,CAAC,UAAU;IA4BX,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB9B,KAAK,IAAI,IAAI;IAOpB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,eAAe;IAiBhB,SAAS,CAAC,UAAU,EAAE,YAAY,EAAE,EAAE,aAAa,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1E,kBAAkB,IAAI,eAAe;IAWrC,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAOnC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAShD,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAanD,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvD,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAM9C,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAM7D,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,IAAI;IAM9E,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,kBAAkB;CAkB3B"}
1
+ {"version":3,"file":"MultistreamRoapMediaConnection.d.ts","sourceRoot":"","sources":["../../../src/MediaConnection/MultistreamRoapMediaConnection.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,EAEL,UAAU,EACV,YAAY,EAGZ,WAAW,EACX,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAA6C,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAG9F,OAAO,EAAQ,eAAe,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAC;AAKnF,OAAO,EAAC,2BAA2B,EAAC,MAAM,UAAU,CAAC;AAGrD,OAAO,EAEL,YAAY,EACZ,WAAW,EACX,iBAAiB,EAEjB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,MAAM,EACN,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAGjC,qBAAa,8BAA+B,SAAQ,YAAY;IAC9D,OAAO,CAAC,EAAE,CAAC,CAAS;IAEpB,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,OAAO,CAAC,qBAAqB,CAAwB;IAErD,OAAO,CAAC,IAAI,CAAO;IAEnB,OAAO,CAAC,qBAAqB,CAAS;gBAS1B,qBAAqB,EAAE,2BAA2B,EAAE,OAAO,CAAC,EAAE,MAAM;IAehF,OAAO,CAAC,mBAAmB;IAqC3B,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,2BAA2B;IAyCnC,OAAO,CAAC,UAAU;IA4BX,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB9B,KAAK,IAAI,IAAI;IAOpB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,eAAe;IAiBhB,SAAS,CAAC,UAAU,EAAE,YAAY,EAAE,EAAE,aAAa,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1E,kBAAkB,IAAI,eAAe;IAWrC,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAOnC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAShD,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAanD,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvD,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAM9C,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAM7D,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,IAAI;IAM9E,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,kBAAkB;CAkB3B"}
@@ -22,5 +22,6 @@ export interface MultistreamConnectionConfig {
22
22
  iceServers: Array<RTCIceServer>;
23
23
  enableMainAudio: boolean;
24
24
  enableMainVideo: boolean;
25
+ bundlePolicy?: 'max-bundle' | 'max-compat';
25
26
  }
26
27
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/MediaConnection/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAoE;IAC7F,gBAAgB,CAAC,EAAE,OAAO,CAAuE;IACjG,kBAAkB,CAAC,EAAE,OAAO,CAAoE;IAChG,eAAe,CAAC,EAAE;QAChB,KAAK,EAAE,MAAM,CAA6E;QAC1F,KAAK,EAAE,MAAM,CAA6E;KAC3F,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CACmE;IACxF,iBAAiB,CAAC,EAAE,MAAM,CAAqE;IAC/F,aAAa,CAAC,EAAE,OAAO,CACkC;IACzD,UAAU,CAAC,EAAE,OAAO,CAC4C;IAChE,SAAS,CAAC,EAAE,MAAM,CAEkD;CACrE;AAED,MAAM,WAAW,qBAAqB;IAEpC,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,wBAAwB,EAAE,OAAO,CAmBM;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;CAC1B"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/MediaConnection/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAoE;IAC7F,gBAAgB,CAAC,EAAE,OAAO,CAAuE;IACjG,kBAAkB,CAAC,EAAE,OAAO,CAAoE;IAChG,eAAe,CAAC,EAAE;QAChB,KAAK,EAAE,MAAM,CAA6E;QAC1F,KAAK,EAAE,MAAM,CAA6E;KAC3F,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CACmE;IACxF,iBAAiB,CAAC,EAAE,MAAM,CAAqE;IAC/F,aAAa,CAAC,EAAE,OAAO,CACkC;IACzD,UAAU,CAAC,EAAE,OAAO,CAC4C;IAChE,SAAS,CAAC,EAAE,MAAM,CAEkD;CACrE;AAED,MAAM,WAAW,qBAAqB;IAEpC,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,wBAAwB,EAAE,OAAO,CAmBM;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC;CAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/MediaConnection/utils.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAI1C,oBAAY,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,OAAO,EAChB,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,GACnC;IAAC,WAAW,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,0BAA0B,CAAA;CAAC,CAYpF;AAmBD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IACP,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACtB,EACD,GAAG,CAAC,EAAE,MAAM,GACX,KAAK,GAAG,KAAK,CA6Bf;AA8ND,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQrF;AASD,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA2B3E;AAcD,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAc5E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/MediaConnection/utils.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAI1C,oBAAY,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,OAAO,EAChB,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,GACnC;IAAC,WAAW,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,0BAA0B,CAAA;CAAC,CAYpF;AAmBD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IACP,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACtB,EACD,GAAG,CAAC,EAAE,MAAM,GACX,KAAK,GAAG,KAAK,CA6Bf;AAkOD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQrF;AASD,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA2B3E;AAcD,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAc5E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-media-core",
3
- "version": "1.35.3",
3
+ "version": "1.35.5",
4
4
  "files": [
5
5
  "dist/cjs",
6
6
  "dist/esm",
@@ -46,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "@babel/runtime": "^7.18.9",
48
48
  "@webex/json-multistream": "1.20.2",
49
- "@webex/ts-sdp": "1.3.0",
49
+ "@webex/ts-sdp": "1.3.2",
50
50
  "@webex/web-client-media-engine": "1.40.2",
51
51
  "detectrtc": "^1.4.1",
52
52
  "events": "^3.3.0",