@webex/web-client-media-engine 3.27.0 → 3.28.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.
- package/dist/cjs/index.js +104 -32
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +103 -33
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -358,10 +358,11 @@ function getUserMedia(constraints) {
|
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
360
|
* Prompts the user for permission to use a user's display media and audio. If a video track is
|
|
361
|
-
* absent from the constraints argument, one will still be provided.
|
|
361
|
+
* absent from the constraints argument, one will still be provided. Includes experimental options
|
|
362
|
+
* found in https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#options.
|
|
362
363
|
*
|
|
363
364
|
* @param constraints - A MediaStreamConstraints object specifying the types of media to request,
|
|
364
|
-
* along with any requirements for each type.
|
|
365
|
+
* along with any requirements for each type, as well as experimental options.
|
|
365
366
|
* @returns A Promise whose fulfillment handler receives a MediaStream object when the requested
|
|
366
367
|
* media has successfully been obtained.
|
|
367
368
|
*/
|
|
@@ -510,11 +511,11 @@ class WebrtcCoreError {
|
|
|
510
511
|
* 1. Previous captured video stream from the same device is not stopped.
|
|
511
512
|
* 2. Previous createCameraStream() call for the same device is in progress.
|
|
512
513
|
*
|
|
513
|
-
* @param
|
|
514
|
+
* @param cameraStreamConstructor - Constructor for the local camera stream.
|
|
514
515
|
* @param constraints - Video device constraints.
|
|
515
516
|
* @returns A LocalCameraStream object or an error.
|
|
516
517
|
*/
|
|
517
|
-
function createCameraStream(
|
|
518
|
+
function createCameraStream(cameraStreamConstructor, constraints) {
|
|
518
519
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
519
520
|
let stream;
|
|
520
521
|
try {
|
|
@@ -523,17 +524,18 @@ function createCameraStream(constructor, constraints) {
|
|
|
523
524
|
catch (error) {
|
|
524
525
|
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create camera stream: ${error}`);
|
|
525
526
|
}
|
|
526
|
-
|
|
527
|
+
// eslint-disable-next-line new-cap
|
|
528
|
+
return new cameraStreamConstructor(stream);
|
|
527
529
|
});
|
|
528
530
|
}
|
|
529
531
|
/**
|
|
530
532
|
* Creates a LocalMicrophoneStream with the given constraints.
|
|
531
533
|
*
|
|
532
|
-
* @param
|
|
534
|
+
* @param microphoneStreamConstructor - Constructor for the local microphone stream.
|
|
533
535
|
* @param constraints - Audio device constraints.
|
|
534
536
|
* @returns A LocalMicrophoneStream object or an error.
|
|
535
537
|
*/
|
|
536
|
-
function createMicrophoneStream(
|
|
538
|
+
function createMicrophoneStream(microphoneStreamConstructor, constraints) {
|
|
537
539
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
538
540
|
let stream;
|
|
539
541
|
try {
|
|
@@ -542,64 +544,132 @@ function createMicrophoneStream(constructor, constraints) {
|
|
|
542
544
|
catch (error) {
|
|
543
545
|
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create microphone stream: ${error}`);
|
|
544
546
|
}
|
|
545
|
-
|
|
547
|
+
// eslint-disable-next-line new-cap
|
|
548
|
+
return new microphoneStreamConstructor(stream);
|
|
546
549
|
});
|
|
547
550
|
}
|
|
548
551
|
/**
|
|
549
|
-
* Creates a
|
|
550
|
-
*
|
|
551
|
-
* @param
|
|
552
|
-
* @param
|
|
553
|
-
* @
|
|
552
|
+
* Creates a LocalCameraStream and a LocalMicrophoneStream with the given constraints.
|
|
553
|
+
*
|
|
554
|
+
* @param cameraStreamConstructor - Constructor for the local camera stream.
|
|
555
|
+
* @param microphoneStreamConstructor - Constructor for the local microphone stream.
|
|
556
|
+
* @param constraints - Object containing video and audio device constraints.
|
|
557
|
+
* @param constraints.video - Video device constraints.
|
|
558
|
+
* @param constraints.audio - Audio device constraints.
|
|
559
|
+
* @returns A Promise that resolves to a LocalCameraStream and a LocalMicrophoneStream or an error.
|
|
554
560
|
*/
|
|
555
|
-
function
|
|
561
|
+
function createCameraAndMicrophoneStreams(cameraStreamConstructor, microphoneStreamConstructor, constraints) {
|
|
556
562
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
557
563
|
let stream;
|
|
558
564
|
try {
|
|
559
|
-
stream = yield
|
|
565
|
+
stream = yield getUserMedia({
|
|
566
|
+
video: Object.assign({}, constraints === null || constraints === void 0 ? void 0 : constraints.video),
|
|
567
|
+
audio: Object.assign({}, constraints === null || constraints === void 0 ? void 0 : constraints.audio),
|
|
568
|
+
});
|
|
560
569
|
}
|
|
561
570
|
catch (error) {
|
|
562
|
-
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create
|
|
563
|
-
}
|
|
564
|
-
const localDisplayStream = new constructor(stream);
|
|
565
|
-
if (videoContentHint) {
|
|
566
|
-
localDisplayStream.contentHint = videoContentHint;
|
|
571
|
+
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create camera and microphone streams: ${error}`);
|
|
567
572
|
}
|
|
568
|
-
|
|
573
|
+
// eslint-disable-next-line new-cap
|
|
574
|
+
const localCameraStream = new cameraStreamConstructor(new MediaStream(stream.getVideoTracks()));
|
|
575
|
+
// eslint-disable-next-line new-cap
|
|
576
|
+
const localMicrophoneStream = new microphoneStreamConstructor(new MediaStream(stream.getAudioTracks()));
|
|
577
|
+
return [localCameraStream, localMicrophoneStream];
|
|
569
578
|
});
|
|
570
579
|
}
|
|
571
580
|
/**
|
|
572
581
|
* Creates a LocalDisplayStream and a LocalSystemAudioStream with the given parameters.
|
|
573
582
|
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
583
|
+
* This is a more advanced version of createDisplayStreamWithAudio that allows the user to specify
|
|
584
|
+
* additional display media options and constraints.
|
|
585
|
+
*
|
|
586
|
+
* See https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#options.
|
|
587
|
+
*
|
|
588
|
+
* @param options - An object containing the options for creating the display and system audio streams.
|
|
589
|
+
* @param options.video - An object containing the video stream options.
|
|
590
|
+
* @param options.video.displayStreamConstructor - Constructor for the local display stream.
|
|
591
|
+
* @param options.video.constraints - Video device constraints.
|
|
592
|
+
* @param options.video.videoContentHint - A hint for the content of the stream.
|
|
593
|
+
* @param options.video.preferCurrentTab - Whether to offer the current tab as the most prominent capture source.
|
|
594
|
+
* @param options.video.selfBrowserSurface - Whether to allow the user to select the current tab for capture.
|
|
595
|
+
* @param options.video.surfaceSwitching - Whether to allow the user to dynamically switch the shared tab during screen-sharing.
|
|
596
|
+
* @param options.video.monitorTypeSurfaces - Whether to offer the user the option to choose display surfaces whose type is monitor.
|
|
597
|
+
* @param options.audio - An object containing the audio stream options. If present, a system audio stream will be created.
|
|
598
|
+
* @param options.audio.systemAudioStreamConstructor - Constructor for the local system audio stream.
|
|
599
|
+
* @param options.audio.constraints - Audio device constraints.
|
|
600
|
+
* @param options.audio.systemAudio - Whether to include the system audio among the possible audio sources offered to the user.
|
|
601
|
+
* @param options.controller - CaptureController to further manipulate the capture session.
|
|
577
602
|
* @returns A Promise that resolves to a LocalDisplayStream and a LocalSystemAudioStream or an
|
|
578
603
|
* error. If no system audio is available, the LocalSystemAudioStream will be resolved as null
|
|
579
604
|
* instead.
|
|
580
605
|
*/
|
|
581
|
-
function
|
|
606
|
+
function createDisplayMedia(options) {
|
|
582
607
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
608
|
+
var _a, _b;
|
|
583
609
|
let stream;
|
|
610
|
+
const videoConstraints = options.video.constraints || true;
|
|
611
|
+
const audioConstraints = ((_a = options.audio) === null || _a === void 0 ? void 0 : _a.constraints) || !!options.audio;
|
|
584
612
|
try {
|
|
585
|
-
stream = yield getDisplayMedia({
|
|
613
|
+
stream = yield getDisplayMedia({
|
|
614
|
+
video: videoConstraints,
|
|
615
|
+
audio: audioConstraints,
|
|
616
|
+
controller: options.controller,
|
|
617
|
+
preferCurrentTab: options.video.preferCurrentTab,
|
|
618
|
+
selfBrowserSurface: options.video.selfBrowserSurface,
|
|
619
|
+
surfaceSwitching: options.video.surfaceSwitching,
|
|
620
|
+
systemAudio: (_b = options.audio) === null || _b === void 0 ? void 0 : _b.systemAudio,
|
|
621
|
+
monitorTypeSurfaces: options.video.monitorTypeSurfaces,
|
|
622
|
+
});
|
|
586
623
|
}
|
|
587
624
|
catch (error) {
|
|
588
|
-
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create display and system audio streams: ${error}`);
|
|
625
|
+
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create display and/or system audio streams: ${error}`);
|
|
589
626
|
}
|
|
590
627
|
// eslint-disable-next-line new-cap
|
|
591
|
-
const localDisplayStream = new displayStreamConstructor(new MediaStream(stream.getVideoTracks()));
|
|
592
|
-
if (videoContentHint) {
|
|
593
|
-
localDisplayStream.contentHint = videoContentHint;
|
|
628
|
+
const localDisplayStream = new options.video.displayStreamConstructor(new MediaStream(stream.getVideoTracks()));
|
|
629
|
+
if (options.video.videoContentHint) {
|
|
630
|
+
localDisplayStream.contentHint = options.video.videoContentHint;
|
|
594
631
|
}
|
|
595
632
|
let localSystemAudioStream = null;
|
|
596
|
-
if (stream.getAudioTracks().length > 0) {
|
|
633
|
+
if (options.audio && stream.getAudioTracks().length > 0) {
|
|
597
634
|
// eslint-disable-next-line new-cap
|
|
598
|
-
localSystemAudioStream = new systemAudioStreamConstructor(new MediaStream(stream.getAudioTracks()));
|
|
635
|
+
localSystemAudioStream = new options.audio.systemAudioStreamConstructor(new MediaStream(stream.getAudioTracks()));
|
|
599
636
|
}
|
|
600
637
|
return [localDisplayStream, localSystemAudioStream];
|
|
601
638
|
});
|
|
602
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Creates a LocalDisplayStream with the given parameters.
|
|
642
|
+
*
|
|
643
|
+
* @param displayStreamConstructor - Constructor for the local display stream.
|
|
644
|
+
* @param videoContentHint - An optional parameter to give a hint for the content of the stream.
|
|
645
|
+
* @returns A Promise that resolves to a LocalDisplayStream or an error.
|
|
646
|
+
*/
|
|
647
|
+
function createDisplayStream(displayStreamConstructor, videoContentHint) {
|
|
648
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
649
|
+
const [localDisplayStream] = yield createDisplayMedia({
|
|
650
|
+
video: { displayStreamConstructor, videoContentHint },
|
|
651
|
+
});
|
|
652
|
+
return localDisplayStream;
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Creates a LocalDisplayStream and a LocalSystemAudioStream with the given parameters.
|
|
657
|
+
*
|
|
658
|
+
* @param displayStreamConstructor - Constructor for the local display stream.
|
|
659
|
+
* @param systemAudioStreamConstructor - Constructor for the local system audio stream.
|
|
660
|
+
* @param videoContentHint - An optional parameter to give a hint for the content of the stream.
|
|
661
|
+
* @returns A Promise that resolves to a LocalDisplayStream and a LocalSystemAudioStream or an
|
|
662
|
+
* error. If no system audio is available, the LocalSystemAudioStream will be resolved as null
|
|
663
|
+
* instead.
|
|
664
|
+
*/
|
|
665
|
+
function createDisplayStreamWithAudio(displayStreamConstructor, systemAudioStreamConstructor, videoContentHint) {
|
|
666
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
667
|
+
return createDisplayMedia({
|
|
668
|
+
video: { displayStreamConstructor, videoContentHint },
|
|
669
|
+
audio: { systemAudioStreamConstructor },
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
}
|
|
603
673
|
/**
|
|
604
674
|
* Enumerates the media input and output devices available.
|
|
605
675
|
*
|
|
@@ -15684,5 +15754,5 @@ class StreamRequest {
|
|
|
15684
15754
|
|
|
15685
15755
|
const { DeviceKind } = media;
|
|
15686
15756
|
|
|
15687
|
-
export { ActiveSpeakerInfo, CodecInfo$1 as CodecInfo, ConnectionState, DeviceKind, H264Codec, Logger$1 as JMPLogger, LocalCameraStream, LocalDisplayStream, LocalMicrophoneStream, LocalStream, LocalStreamEventNames, LocalSystemAudioStream, Logger, MediaCodecMimeType, MediaContent, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamConnection, MultistreamConnectionEventNames, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteMediaState, RemoteStream, RemoteStreamEventNames, SendSlot, StreamEventNames, StreamRequest, WcmeError, WcmeErrorType, Logger$2 as WebRtcCoreLogger, WebrtcCoreError, WebrtcCoreErrorType, areReceiveSlotIdsEqual, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, createMicrophoneStream, getAudioInputDevices, getAudioOutputDevices, getDevices, getLogLevel, getMediaContent, getMediaFamily, getMediaType, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices, logErrorAndThrow, setLogHandler, setLogLevel, setOnDeviceChangeHandler };
|
|
15757
|
+
export { ActiveSpeakerInfo, CodecInfo$1 as CodecInfo, ConnectionState, DeviceKind, H264Codec, Logger$1 as JMPLogger, LocalCameraStream, LocalDisplayStream, LocalMicrophoneStream, LocalStream, LocalStreamEventNames, LocalSystemAudioStream, Logger, MediaCodecMimeType, MediaContent, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamConnection, MultistreamConnectionEventNames, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteMediaState, RemoteStream, RemoteStreamEventNames, SendSlot, StreamEventNames, StreamRequest, WcmeError, WcmeErrorType, Logger$2 as WebRtcCoreLogger, WebrtcCoreError, WebrtcCoreErrorType, areReceiveSlotIdsEqual, createCameraAndMicrophoneStreams, createCameraStream, createDisplayMedia, createDisplayStream, createDisplayStreamWithAudio, createMicrophoneStream, getAudioInputDevices, getAudioOutputDevices, getDevices, getLogLevel, getMediaContent, getMediaFamily, getMediaType, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices, logErrorAndThrow, setLogHandler, setLogLevel, setOnDeviceChangeHandler };
|
|
15688
15758
|
//# sourceMappingURL=index.js.map
|