@webex/internal-media-core 1.35.4 → 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
  }
@@ -4540,6 +4540,145 @@ var DeviceKind;
4540
4540
  DeviceKind["AudioOutput"] = "audiooutput";
4541
4541
  DeviceKind["VideoInput"] = "videoinput";
4542
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
+ });
4543
4682
  var events$1 = {
4544
4683
  exports: {}
4545
4684
  };
@@ -5224,6 +5363,129 @@ var ErrorTypes;
5224
5363
  ErrorTypes["CREATE_CAMERA_TRACK_FAILED"] = "CREATE_CAMERA_TRACK_FAILED";
5225
5364
  ErrorTypes["CREATE_MICROPHONE_TRACK_FAILED"] = "CREATE_MICROPHONE_TRACK_FAILED";
5226
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;
5227
5489
 
5228
5490
  // Overall connection state (based on the ICE and DTLS connection states)
5229
5491
  exports.ConnectionState = void 0;
@@ -8396,11 +8658,11 @@ function createRTCPeerConnection(configuration) {
8396
8658
  /**
8397
8659
  * A type-safe form of the DOMString used in the MediaStreamTrack.kind field.
8398
8660
  */
8399
- var MediaStreamTrackKind;
8661
+ exports.MediaStreamTrackKind = void 0;
8400
8662
  (function (MediaStreamTrackKind) {
8401
8663
  MediaStreamTrackKind["Audio"] = "audio";
8402
8664
  MediaStreamTrackKind["Video"] = "video";
8403
- })(MediaStreamTrackKind || (MediaStreamTrackKind = {}));
8665
+ })(exports.MediaStreamTrackKind || (exports.MediaStreamTrackKind = {}));
8404
8666
  var PeerConnectionEvents;
8405
8667
  (function (PeerConnectionEvents) {
8406
8668
  PeerConnectionEvents["IceGatheringStateChange"] = "icegatheringstatechange";
@@ -14241,10 +14503,10 @@ function setLogHandler(logHandler) {
14241
14503
  Logger$1.setHandler(logHandler);
14242
14504
  }
14243
14505
  function toMediaStreamTrackKind(mediaType) {
14244
- 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;
14245
14507
  }
14246
14508
  function toMediaFamily(kind) {
14247
- if (kind === MediaStreamTrackKind.Video) {
14509
+ if (kind === exports.MediaStreamTrackKind.Video) {
14248
14510
  return MediaFamily.Video;
14249
14511
  }
14250
14512
  return MediaFamily.Audio;
@@ -24205,11 +24467,21 @@ exports.LocalTrack = LocalTrack;
24205
24467
  exports.Media = Media;
24206
24468
  exports.MediaRequest = MediaRequest;
24207
24469
  exports.MultistreamRoapMediaConnection = MultistreamRoapMediaConnection;
24470
+ exports.PeerConnection = PeerConnection;
24208
24471
  exports.ReceiveSlot = ReceiveSlot;
24209
24472
  exports.ReceiverSelectedInfo = ReceiverSelectedInfo;
24210
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;
24211
24481
  exports.getErrorDescription = getErrorDescription;
24212
24482
  exports.getLogger = getLogger;
24213
24483
  exports.getMediaFamily = getMediaFamily;
24484
+ exports.getVideoInputDevices = getVideoInputDevices;
24214
24485
  exports.isBrowserSupported = isBrowserSupported;
24215
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
  }
@@ -4529,6 +4529,145 @@ var DeviceKind;
4529
4529
  DeviceKind["AudioOutput"] = "audiooutput";
4530
4530
  DeviceKind["VideoInput"] = "videoinput";
4531
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
+ });
4532
4671
  var events$1 = {
4533
4672
  exports: {}
4534
4673
  };
@@ -5213,6 +5352,129 @@ var ErrorTypes;
5213
5352
  ErrorTypes["CREATE_CAMERA_TRACK_FAILED"] = "CREATE_CAMERA_TRACK_FAILED";
5214
5353
  ErrorTypes["CREATE_MICROPHONE_TRACK_FAILED"] = "CREATE_MICROPHONE_TRACK_FAILED";
5215
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;
5216
5478
 
5217
5479
  // Overall connection state (based on the ICE and DTLS connection states)
5218
5480
  var ConnectionState;
@@ -24183,4 +24445,4 @@ var Media = {
24183
24445
  isBrowserSupported
24184
24446
  };
24185
24447
 
24186
- 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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,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,EAA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AO,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-media-core",
3
- "version": "1.35.4",
3
+ "version": "1.35.5",
4
4
  "files": [
5
5
  "dist/cjs",
6
6
  "dist/esm",