@whereby.com/media 9.6.1 → 9.7.1

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/index.cjs CHANGED
@@ -2498,18 +2498,19 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2498
2498
  return constraints;
2499
2499
  }
2500
2500
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2501
- const audioDevices = devices.filter((d) => d.kind === "audioinput");
2502
- const videoDevices = devices.filter((d) => d.kind === "videoinput");
2503
- const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2504
- const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2501
+ const strict = !!devices;
2502
+ const audioDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "audioinput");
2503
+ const videoDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "videoinput");
2504
+ const useDefaultAudio = !audioId || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.some((d) => d.deviceId === audioId)));
2505
+ const useDefaultVideo = !videoId || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.some((d) => d.deviceId === videoId)));
2505
2506
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2506
2507
  audioId: useDefaultAudio ? null : { [type]: audioId },
2507
2508
  videoId: useDefaultVideo ? null : { [type]: videoId },
2508
2509
  } }, options));
2509
- if (audioId === false || !audioDevices.length) {
2510
+ if (audioId === false || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.length))) {
2510
2511
  delete constraints.audio;
2511
2512
  }
2512
- if (videoId === false || !videoDevices.length) {
2513
+ if (videoId === false || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.length))) {
2513
2514
  delete constraints.video;
2514
2515
  }
2515
2516
  return constraints;
@@ -7332,64 +7333,128 @@ function replaceTracksInStream(stream, newStream, only) {
7332
7333
  replacedTracks.forEach((track) => stream.removeTrack(track));
7333
7334
  return replacedTracks;
7334
7335
  }
7335
- function getStream(constraintOpt_1) {
7336
- return __awaiter(this, arguments, void 0, function* (constraintOpt, { replaceStream, fallback = true } = {}) {
7337
- var _a;
7336
+ function createGetUserMediaAttempts() {
7337
+ const attempts = [];
7338
+ const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
7339
+ var _a, _b;
7340
+ try {
7341
+ const s = yield getUserMedia(c);
7342
+ attempts.push({ constraints: c, outcome: { ok: true } });
7343
+ return s;
7344
+ }
7345
+ catch (e) {
7346
+ attempts.push({
7347
+ constraints: c,
7348
+ outcome: Object.assign({ ok: false, errorName: (_a = e === null || e === void 0 ? void 0 : e.name) !== null && _a !== void 0 ? _a : "UnknownError", errorMessage: (_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : String(e) }, ((e === null || e === void 0 ? void 0 : e.constraint) && { constraint: e.constraint })),
7349
+ });
7350
+ throw e;
7351
+ }
7352
+ });
7353
+ const attachAttempts = (err) => {
7354
+ if (err)
7355
+ err.attempts = attempts;
7356
+ return err;
7357
+ };
7358
+ return { attempts, attempt, attachAttempts };
7359
+ }
7360
+ function getInitialStream(constraintOpt) {
7361
+ return __awaiter(this, void 0, void 0, function* () {
7362
+ const { attempts, attempt, attachAttempts } = createGetUserMediaAttempts();
7338
7363
  let error;
7339
- let newConstraints;
7340
- let retryConstraintOpt;
7341
- let stream = null;
7342
- const attempts = [];
7343
- const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
7344
- const stopTracks = isMobile || only !== "video";
7345
- const constraints = getConstraints(constraintOpt);
7346
- const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
7347
- var _a, _b;
7364
+ let stream;
7365
+ const opts = Object.assign(Object.assign({}, constraintOpt), { type: "exact" });
7366
+ try {
7367
+ stream = yield attempt(getConstraints(opts));
7368
+ return {
7369
+ stream,
7370
+ attempts,
7371
+ };
7372
+ }
7373
+ catch (e) {
7374
+ logger.error(e);
7375
+ error = e;
7376
+ }
7377
+ const acquireOneKind = (targetConstraint) => __awaiter(this, void 0, void 0, function* () {
7378
+ const retryOpts = Object.assign(Object.assign({}, opts), { options: Object.assign({}, opts.options) });
7379
+ let stream;
7380
+ let lastError = error;
7381
+ const ignoredConstraint = targetConstraint === "videoId" ? "audioId" : "videoId";
7382
+ if (retryOpts[ignoredConstraint] !== false) {
7383
+ retryOpts[ignoredConstraint] = false;
7384
+ try {
7385
+ stream = yield attempt(getConstraints(retryOpts));
7386
+ return stream;
7387
+ }
7388
+ catch (e) {
7389
+ logger.error(e);
7390
+ lastError = e;
7391
+ }
7392
+ }
7393
+ if ((lastError === null || lastError === void 0 ? void 0 : lastError.name) === "NotAllowedError") {
7394
+ return;
7395
+ }
7396
+ if (retryOpts[targetConstraint]) {
7397
+ retryOpts[targetConstraint] = null;
7398
+ try {
7399
+ stream = yield attempt(getConstraints(retryOpts));
7400
+ return stream;
7401
+ }
7402
+ catch (e) {
7403
+ logger.error(e);
7404
+ }
7405
+ }
7348
7406
  try {
7349
- const s = yield getUserMedia(c);
7350
- attempts.push({ constraints: c, outcome: { ok: true } });
7351
- return s;
7407
+ retryOpts.options.lax = true;
7408
+ stream = yield attempt(getConstraints(retryOpts));
7409
+ return stream;
7352
7410
  }
7353
7411
  catch (e) {
7354
- attempts.push({
7355
- constraints: c,
7356
- outcome: Object.assign({ ok: false, errorName: (_a = e === null || e === void 0 ? void 0 : e.name) !== null && _a !== void 0 ? _a : "UnknownError", errorMessage: (_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : String(e) }, ((e === null || e === void 0 ? void 0 : e.constraint) && { constraint: e.constraint })),
7357
- });
7358
- throw e;
7412
+ logger.error(e);
7359
7413
  }
7360
7414
  });
7361
- const addDetails = (err, orgErr) => {
7362
- if (err) {
7363
- err.details = Object.assign({ constraints, constraint: err.constraint || (orgErr === null || orgErr === void 0 ? void 0 : orgErr.constraint), newConstraints,
7364
- fallback,
7365
- stopTracks }, (err !== error && { error: String(error) }));
7366
- return err;
7415
+ if (opts.videoId !== false) {
7416
+ stream = yield acquireOneKind("videoId");
7417
+ }
7418
+ if (opts.audioId !== false) {
7419
+ if (!stream) {
7420
+ stream = yield acquireOneKind("audioId");
7367
7421
  }
7368
7422
  else {
7369
- return new Error("Unknown error");
7423
+ const audioOnlyStream = yield acquireOneKind("audioId");
7424
+ if (audioOnlyStream) {
7425
+ const audioTrack = audioOnlyStream.getAudioTracks()[0];
7426
+ stream.addTrack(audioTrack);
7427
+ }
7370
7428
  }
7371
- };
7372
- const attachAttempts = (err) => {
7373
- if (err)
7374
- err.attempts = attempts;
7375
- return err;
7376
- };
7377
- const getSingleStream = (e) => __awaiter(this, void 0, void 0, function* () {
7429
+ }
7430
+ if (!stream) {
7431
+ throw attachAttempts(error !== null && error !== void 0 ? error : new Error("Unknown error"));
7432
+ }
7433
+ return { error, stream, attempts };
7434
+ });
7435
+ }
7436
+ function getStream(constraintOpt_1) {
7437
+ return __awaiter(this, arguments, void 0, function* (constraintOpt, { replaceStream, fallback = true } = {}) {
7438
+ var _a;
7439
+ let error;
7440
+ let retryConstraintOpt;
7441
+ let stream = null;
7442
+ const { attempts, attempt, attachAttempts } = createGetUserMediaAttempts();
7443
+ const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
7444
+ const stopTracks = isMobile || only !== "video";
7445
+ const constraints = getConstraints(constraintOpt);
7446
+ const getSingleStream = () => __awaiter(this, void 0, void 0, function* () {
7378
7447
  if (constraints.audio && constraints.video) {
7379
7448
  try {
7380
7449
  stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { audioId: false })));
7381
7450
  }
7382
- catch (e2) {
7383
- if ((e2 === null || e2 === void 0 ? void 0 : e2.name) !== "NotFoundError") {
7384
- addDetails(e2, e);
7385
- }
7451
+ catch (_a) {
7386
7452
  }
7387
7453
  try {
7388
7454
  if (!stream)
7389
7455
  stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { videoId: false })));
7390
7456
  }
7391
- catch (e2) {
7392
- addDetails(e2, e);
7457
+ catch (_b) {
7393
7458
  }
7394
7459
  }
7395
7460
  });
@@ -7401,7 +7466,7 @@ function getStream(constraintOpt_1) {
7401
7466
  catch (e) {
7402
7467
  error = e;
7403
7468
  if (!fallback) {
7404
- throw attachAttempts(addDetails(e));
7469
+ throw attachAttempts(e || new Error("Unknown error"));
7405
7470
  }
7406
7471
  if ((e === null || e === void 0 ? void 0 : e.name) === "OverconstrainedError") {
7407
7472
  const laxConstraints = {
@@ -7413,7 +7478,7 @@ function getStream(constraintOpt_1) {
7413
7478
  retryConstraintOpt = laxConstraints[e.constraint || ""];
7414
7479
  }
7415
7480
  else if ((e === null || e === void 0 ? void 0 : e.name) === "NotFoundError") {
7416
- yield getSingleStream(e);
7481
+ yield getSingleStream();
7417
7482
  }
7418
7483
  else if ((e === null || e === void 0 ? void 0 : e.name) === "NotAllowedError" || (e === null || e === void 0 ? void 0 : e.name) === "NotReadableError" || (e === null || e === void 0 ? void 0 : e.name) === "AbortError") {
7419
7484
  if (replaceStream && !stopTracks) {
@@ -7421,7 +7486,7 @@ function getStream(constraintOpt_1) {
7421
7486
  retryConstraintOpt = constraintOpt;
7422
7487
  }
7423
7488
  if ((e === null || e === void 0 ? void 0 : e.name) === "NotAllowedError") {
7424
- yield getSingleStream(e);
7489
+ yield getSingleStream();
7425
7490
  }
7426
7491
  else if (e.name !== "NotAllowedError") {
7427
7492
  try {
@@ -7456,22 +7521,21 @@ function getStream(constraintOpt_1) {
7456
7521
  }
7457
7522
  }
7458
7523
  else if (!e) {
7459
- yield getSingleStream(e);
7524
+ yield getSingleStream();
7460
7525
  }
7461
7526
  }
7462
7527
  if (retryConstraintOpt) {
7463
7528
  const onlyConstraints = only ? { audio: { videoId: false }, video: { audioId: false } }[only] : {};
7464
7529
  const retryConstraints = getConstraints(Object.assign(Object.assign(Object.assign(Object.assign({}, constraintOpt), retryConstraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: retryConstraintOpt.lax }) }), onlyConstraints));
7465
- newConstraints = retryConstraints;
7466
7530
  try {
7467
7531
  stream = yield attempt(retryConstraints);
7468
7532
  }
7469
7533
  catch (e) {
7470
- throw attachAttempts(addDetails(e, error));
7534
+ throw attachAttempts(e || new Error("Unknown error"));
7471
7535
  }
7472
7536
  }
7473
7537
  if (!stream) {
7474
- throw attachAttempts(addDetails(error));
7538
+ throw attachAttempts(error || new Error("Unknown error"));
7475
7539
  }
7476
7540
  let replacedTracks;
7477
7541
  if (replaceStream) {
@@ -7480,7 +7544,7 @@ function getStream(constraintOpt_1) {
7480
7544
  replacedTracks = replaceTracksInStream(replaceStream, stream, only);
7481
7545
  stream = replaceStream;
7482
7546
  }
7483
- return { error: error && addDetails(error), stream, replacedTracks, attempts };
7547
+ return { error, stream, replacedTracks, attempts };
7484
7548
  });
7485
7549
  }
7486
7550
  function hasGetDisplayMedia() {
@@ -7647,6 +7711,7 @@ exports.getConstraints = getConstraints;
7647
7711
  exports.getCurrentPeerConnections = getCurrentPeerConnections;
7648
7712
  exports.getDeviceData = getDeviceData;
7649
7713
  exports.getDisplayMedia = getDisplayMedia;
7714
+ exports.getInitialStream = getInitialStream;
7650
7715
  exports.getIssuesAndMetrics = getIssuesAndMetrics;
7651
7716
  exports.getMediaConstraints = getMediaConstraints;
7652
7717
  exports.getMediaSettings = getMediaSettings;
package/dist/index.d.cts CHANGED
@@ -603,8 +603,13 @@ type GetMediaConstraintsOptions = {
603
603
  simulcast: boolean;
604
604
  widescreen: boolean;
605
605
  };
606
+ type GetInitialStreamOptions = {
607
+ videoId: false | string | null;
608
+ audioId: false | string | null;
609
+ options: Omit<GetMediaConstraintsOptions, "preferredDeviceIds">;
610
+ };
606
611
  type GetConstraintsOptions = {
607
- devices: MediaDeviceInfo[];
612
+ devices?: MediaDeviceInfo[];
608
613
  audioId?: boolean | string | null;
609
614
  videoId?: boolean | string | null;
610
615
  type?: "ideal" | "exact";
@@ -1387,6 +1392,7 @@ declare function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTr
1387
1392
  }): GetDeviceDataResult;
1388
1393
  declare function stopStreamTracks(stream: MediaStream, only?: "audio" | "video" | false): void;
1389
1394
  declare function replaceTracksInStream(stream: MediaStream, newStream: MediaStream, only: "audio" | "video" | false): MediaStreamTrack[];
1395
+ declare function getInitialStream(constraintOpt: GetInitialStreamOptions): Promise<GetStreamResult>;
1390
1396
  declare function getStream(constraintOpt: GetConstraintsOptions, { replaceStream, fallback }?: GetStreamOptions): Promise<GetStreamResult>;
1391
1397
  declare function hasGetDisplayMedia(): boolean;
1392
1398
  declare function getDisplayMedia(constraints?: DisplayMediaStreamOptions, contentHint?: string): Promise<MediaStream>;
@@ -2153,5 +2159,5 @@ declare class VegaRtcManager implements RtcManager {
2153
2159
  hasClient(clientId: string): boolean;
2154
2160
  }
2155
2161
 
2156
- export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2157
- export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdateRequest, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatFileShare, ChatMessage, ChatMessageError, ChatMessageRemoved, ChatMessageRequest, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, FileShareErrorCode, FileUploadUrl, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockOnHoldEvent, KnockRejectedEvent, KnockResponse, KnockResponseSender, KnockRoomRequest, KnockerLeftEvent, LiveCaptionEvent, LiveCaptionsStartedEvent, LiveCaptionsStoppedEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, MediaPrefs, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveScreenshareStreamOptions, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomEmptyError, RoomFullError, RoomJoinPermissionDeniedError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceCandidateMessage, SignalIceEndOfCandidatesMessage, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRTCSessionDescription, SignalReadyToReceiveOfferMessage, SignalRequests, SignalRoom, SignalSDPMessage, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UniqueRoleAlreadyInRoomError, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaConnectionOptions, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
2162
+ export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getInitialStream, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2163
+ export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdateRequest, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatFileShare, ChatMessage, ChatMessageError, ChatMessageRemoved, ChatMessageRequest, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, FileShareErrorCode, FileUploadUrl, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetInitialStreamOptions, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockOnHoldEvent, KnockRejectedEvent, KnockResponse, KnockResponseSender, KnockRoomRequest, KnockerLeftEvent, LiveCaptionEvent, LiveCaptionsStartedEvent, LiveCaptionsStoppedEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, MediaPrefs, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveScreenshareStreamOptions, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomEmptyError, RoomFullError, RoomJoinPermissionDeniedError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceCandidateMessage, SignalIceEndOfCandidatesMessage, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRTCSessionDescription, SignalReadyToReceiveOfferMessage, SignalRequests, SignalRoom, SignalSDPMessage, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UniqueRoleAlreadyInRoomError, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaConnectionOptions, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
package/dist/index.d.mts CHANGED
@@ -603,8 +603,13 @@ type GetMediaConstraintsOptions = {
603
603
  simulcast: boolean;
604
604
  widescreen: boolean;
605
605
  };
606
+ type GetInitialStreamOptions = {
607
+ videoId: false | string | null;
608
+ audioId: false | string | null;
609
+ options: Omit<GetMediaConstraintsOptions, "preferredDeviceIds">;
610
+ };
606
611
  type GetConstraintsOptions = {
607
- devices: MediaDeviceInfo[];
612
+ devices?: MediaDeviceInfo[];
608
613
  audioId?: boolean | string | null;
609
614
  videoId?: boolean | string | null;
610
615
  type?: "ideal" | "exact";
@@ -1387,6 +1392,7 @@ declare function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTr
1387
1392
  }): GetDeviceDataResult;
1388
1393
  declare function stopStreamTracks(stream: MediaStream, only?: "audio" | "video" | false): void;
1389
1394
  declare function replaceTracksInStream(stream: MediaStream, newStream: MediaStream, only: "audio" | "video" | false): MediaStreamTrack[];
1395
+ declare function getInitialStream(constraintOpt: GetInitialStreamOptions): Promise<GetStreamResult>;
1390
1396
  declare function getStream(constraintOpt: GetConstraintsOptions, { replaceStream, fallback }?: GetStreamOptions): Promise<GetStreamResult>;
1391
1397
  declare function hasGetDisplayMedia(): boolean;
1392
1398
  declare function getDisplayMedia(constraints?: DisplayMediaStreamOptions, contentHint?: string): Promise<MediaStream>;
@@ -2153,5 +2159,5 @@ declare class VegaRtcManager implements RtcManager {
2153
2159
  hasClient(clientId: string): boolean;
2154
2160
  }
2155
2161
 
2156
- export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2157
- export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdateRequest, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatFileShare, ChatMessage, ChatMessageError, ChatMessageRemoved, ChatMessageRequest, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, FileShareErrorCode, FileUploadUrl, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockOnHoldEvent, KnockRejectedEvent, KnockResponse, KnockResponseSender, KnockRoomRequest, KnockerLeftEvent, LiveCaptionEvent, LiveCaptionsStartedEvent, LiveCaptionsStoppedEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, MediaPrefs, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveScreenshareStreamOptions, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomEmptyError, RoomFullError, RoomJoinPermissionDeniedError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceCandidateMessage, SignalIceEndOfCandidatesMessage, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRTCSessionDescription, SignalReadyToReceiveOfferMessage, SignalRequests, SignalRoom, SignalSDPMessage, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UniqueRoleAlreadyInRoomError, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaConnectionOptions, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
2162
+ export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getInitialStream, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2163
+ export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdateRequest, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatFileShare, ChatMessage, ChatMessageError, ChatMessageRemoved, ChatMessageRequest, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, FileShareErrorCode, FileUploadUrl, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetInitialStreamOptions, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockOnHoldEvent, KnockRejectedEvent, KnockResponse, KnockResponseSender, KnockRoomRequest, KnockerLeftEvent, LiveCaptionEvent, LiveCaptionsStartedEvent, LiveCaptionsStoppedEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, MediaPrefs, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveScreenshareStreamOptions, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomEmptyError, RoomFullError, RoomJoinPermissionDeniedError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceCandidateMessage, SignalIceEndOfCandidatesMessage, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRTCSessionDescription, SignalReadyToReceiveOfferMessage, SignalRequests, SignalRoom, SignalSDPMessage, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UniqueRoleAlreadyInRoomError, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaConnectionOptions, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
package/dist/index.d.ts CHANGED
@@ -603,8 +603,13 @@ type GetMediaConstraintsOptions = {
603
603
  simulcast: boolean;
604
604
  widescreen: boolean;
605
605
  };
606
+ type GetInitialStreamOptions = {
607
+ videoId: false | string | null;
608
+ audioId: false | string | null;
609
+ options: Omit<GetMediaConstraintsOptions, "preferredDeviceIds">;
610
+ };
606
611
  type GetConstraintsOptions = {
607
- devices: MediaDeviceInfo[];
612
+ devices?: MediaDeviceInfo[];
608
613
  audioId?: boolean | string | null;
609
614
  videoId?: boolean | string | null;
610
615
  type?: "ideal" | "exact";
@@ -1387,6 +1392,7 @@ declare function getDeviceData({ audioTrack, videoTrack, devices, stoppedVideoTr
1387
1392
  }): GetDeviceDataResult;
1388
1393
  declare function stopStreamTracks(stream: MediaStream, only?: "audio" | "video" | false): void;
1389
1394
  declare function replaceTracksInStream(stream: MediaStream, newStream: MediaStream, only: "audio" | "video" | false): MediaStreamTrack[];
1395
+ declare function getInitialStream(constraintOpt: GetInitialStreamOptions): Promise<GetStreamResult>;
1390
1396
  declare function getStream(constraintOpt: GetConstraintsOptions, { replaceStream, fallback }?: GetStreamOptions): Promise<GetStreamResult>;
1391
1397
  declare function hasGetDisplayMedia(): boolean;
1392
1398
  declare function getDisplayMedia(constraints?: DisplayMediaStreamOptions, contentHint?: string): Promise<MediaStream>;
@@ -2153,5 +2159,5 @@ declare class VegaRtcManager implements RtcManager {
2153
2159
  hasClient(clientId: string): boolean;
2154
2160
  }
2155
2161
 
2156
- export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2157
- export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdateRequest, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatFileShare, ChatMessage, ChatMessageError, ChatMessageRemoved, ChatMessageRequest, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, FileShareErrorCode, FileUploadUrl, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockOnHoldEvent, KnockRejectedEvent, KnockResponse, KnockResponseSender, KnockRoomRequest, KnockerLeftEvent, LiveCaptionEvent, LiveCaptionsStartedEvent, LiveCaptionsStoppedEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, MediaPrefs, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveScreenshareStreamOptions, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomEmptyError, RoomFullError, RoomJoinPermissionDeniedError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceCandidateMessage, SignalIceEndOfCandidatesMessage, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRTCSessionDescription, SignalReadyToReceiveOfferMessage, SignalRequests, SignalRoom, SignalSDPMessage, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UniqueRoleAlreadyInRoomError, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaConnectionOptions, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
2162
+ export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getInitialStream, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
2163
+ export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdateRequest, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatFileShare, ChatMessage, ChatMessageError, ChatMessageRemoved, ChatMessageRequest, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, FileShareErrorCode, FileUploadUrl, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetInitialStreamOptions, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockOnHoldEvent, KnockRejectedEvent, KnockResponse, KnockResponseSender, KnockRoomRequest, KnockerLeftEvent, LiveCaptionEvent, LiveCaptionsStartedEvent, LiveCaptionsStoppedEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, MediaPrefs, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveScreenshareStreamOptions, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomEmptyError, RoomFullError, RoomJoinPermissionDeniedError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceCandidateMessage, SignalIceEndOfCandidatesMessage, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRTCSessionDescription, SignalReadyToReceiveOfferMessage, SignalRequests, SignalRoom, SignalSDPMessage, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UniqueRoleAlreadyInRoomError, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaConnectionOptions, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
package/dist/index.mjs CHANGED
@@ -2478,18 +2478,19 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2478
2478
  return constraints;
2479
2479
  }
2480
2480
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2481
- const audioDevices = devices.filter((d) => d.kind === "audioinput");
2482
- const videoDevices = devices.filter((d) => d.kind === "videoinput");
2483
- const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2484
- const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2481
+ const strict = !!devices;
2482
+ const audioDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "audioinput");
2483
+ const videoDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "videoinput");
2484
+ const useDefaultAudio = !audioId || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.some((d) => d.deviceId === audioId)));
2485
+ const useDefaultVideo = !videoId || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.some((d) => d.deviceId === videoId)));
2485
2486
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2486
2487
  audioId: useDefaultAudio ? null : { [type]: audioId },
2487
2488
  videoId: useDefaultVideo ? null : { [type]: videoId },
2488
2489
  } }, options));
2489
- if (audioId === false || !audioDevices.length) {
2490
+ if (audioId === false || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.length))) {
2490
2491
  delete constraints.audio;
2491
2492
  }
2492
- if (videoId === false || !videoDevices.length) {
2493
+ if (videoId === false || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.length))) {
2493
2494
  delete constraints.video;
2494
2495
  }
2495
2496
  return constraints;
@@ -7312,64 +7313,128 @@ function replaceTracksInStream(stream, newStream, only) {
7312
7313
  replacedTracks.forEach((track) => stream.removeTrack(track));
7313
7314
  return replacedTracks;
7314
7315
  }
7315
- function getStream(constraintOpt_1) {
7316
- return __awaiter(this, arguments, void 0, function* (constraintOpt, { replaceStream, fallback = true } = {}) {
7317
- var _a;
7316
+ function createGetUserMediaAttempts() {
7317
+ const attempts = [];
7318
+ const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
7319
+ var _a, _b;
7320
+ try {
7321
+ const s = yield getUserMedia(c);
7322
+ attempts.push({ constraints: c, outcome: { ok: true } });
7323
+ return s;
7324
+ }
7325
+ catch (e) {
7326
+ attempts.push({
7327
+ constraints: c,
7328
+ outcome: Object.assign({ ok: false, errorName: (_a = e === null || e === void 0 ? void 0 : e.name) !== null && _a !== void 0 ? _a : "UnknownError", errorMessage: (_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : String(e) }, ((e === null || e === void 0 ? void 0 : e.constraint) && { constraint: e.constraint })),
7329
+ });
7330
+ throw e;
7331
+ }
7332
+ });
7333
+ const attachAttempts = (err) => {
7334
+ if (err)
7335
+ err.attempts = attempts;
7336
+ return err;
7337
+ };
7338
+ return { attempts, attempt, attachAttempts };
7339
+ }
7340
+ function getInitialStream(constraintOpt) {
7341
+ return __awaiter(this, void 0, void 0, function* () {
7342
+ const { attempts, attempt, attachAttempts } = createGetUserMediaAttempts();
7318
7343
  let error;
7319
- let newConstraints;
7320
- let retryConstraintOpt;
7321
- let stream = null;
7322
- const attempts = [];
7323
- const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
7324
- const stopTracks = isMobile || only !== "video";
7325
- const constraints = getConstraints(constraintOpt);
7326
- const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
7327
- var _a, _b;
7344
+ let stream;
7345
+ const opts = Object.assign(Object.assign({}, constraintOpt), { type: "exact" });
7346
+ try {
7347
+ stream = yield attempt(getConstraints(opts));
7348
+ return {
7349
+ stream,
7350
+ attempts,
7351
+ };
7352
+ }
7353
+ catch (e) {
7354
+ logger.error(e);
7355
+ error = e;
7356
+ }
7357
+ const acquireOneKind = (targetConstraint) => __awaiter(this, void 0, void 0, function* () {
7358
+ const retryOpts = Object.assign(Object.assign({}, opts), { options: Object.assign({}, opts.options) });
7359
+ let stream;
7360
+ let lastError = error;
7361
+ const ignoredConstraint = targetConstraint === "videoId" ? "audioId" : "videoId";
7362
+ if (retryOpts[ignoredConstraint] !== false) {
7363
+ retryOpts[ignoredConstraint] = false;
7364
+ try {
7365
+ stream = yield attempt(getConstraints(retryOpts));
7366
+ return stream;
7367
+ }
7368
+ catch (e) {
7369
+ logger.error(e);
7370
+ lastError = e;
7371
+ }
7372
+ }
7373
+ if ((lastError === null || lastError === void 0 ? void 0 : lastError.name) === "NotAllowedError") {
7374
+ return;
7375
+ }
7376
+ if (retryOpts[targetConstraint]) {
7377
+ retryOpts[targetConstraint] = null;
7378
+ try {
7379
+ stream = yield attempt(getConstraints(retryOpts));
7380
+ return stream;
7381
+ }
7382
+ catch (e) {
7383
+ logger.error(e);
7384
+ }
7385
+ }
7328
7386
  try {
7329
- const s = yield getUserMedia(c);
7330
- attempts.push({ constraints: c, outcome: { ok: true } });
7331
- return s;
7387
+ retryOpts.options.lax = true;
7388
+ stream = yield attempt(getConstraints(retryOpts));
7389
+ return stream;
7332
7390
  }
7333
7391
  catch (e) {
7334
- attempts.push({
7335
- constraints: c,
7336
- outcome: Object.assign({ ok: false, errorName: (_a = e === null || e === void 0 ? void 0 : e.name) !== null && _a !== void 0 ? _a : "UnknownError", errorMessage: (_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : String(e) }, ((e === null || e === void 0 ? void 0 : e.constraint) && { constraint: e.constraint })),
7337
- });
7338
- throw e;
7392
+ logger.error(e);
7339
7393
  }
7340
7394
  });
7341
- const addDetails = (err, orgErr) => {
7342
- if (err) {
7343
- err.details = Object.assign({ constraints, constraint: err.constraint || (orgErr === null || orgErr === void 0 ? void 0 : orgErr.constraint), newConstraints,
7344
- fallback,
7345
- stopTracks }, (err !== error && { error: String(error) }));
7346
- return err;
7395
+ if (opts.videoId !== false) {
7396
+ stream = yield acquireOneKind("videoId");
7397
+ }
7398
+ if (opts.audioId !== false) {
7399
+ if (!stream) {
7400
+ stream = yield acquireOneKind("audioId");
7347
7401
  }
7348
7402
  else {
7349
- return new Error("Unknown error");
7403
+ const audioOnlyStream = yield acquireOneKind("audioId");
7404
+ if (audioOnlyStream) {
7405
+ const audioTrack = audioOnlyStream.getAudioTracks()[0];
7406
+ stream.addTrack(audioTrack);
7407
+ }
7350
7408
  }
7351
- };
7352
- const attachAttempts = (err) => {
7353
- if (err)
7354
- err.attempts = attempts;
7355
- return err;
7356
- };
7357
- const getSingleStream = (e) => __awaiter(this, void 0, void 0, function* () {
7409
+ }
7410
+ if (!stream) {
7411
+ throw attachAttempts(error !== null && error !== void 0 ? error : new Error("Unknown error"));
7412
+ }
7413
+ return { error, stream, attempts };
7414
+ });
7415
+ }
7416
+ function getStream(constraintOpt_1) {
7417
+ return __awaiter(this, arguments, void 0, function* (constraintOpt, { replaceStream, fallback = true } = {}) {
7418
+ var _a;
7419
+ let error;
7420
+ let retryConstraintOpt;
7421
+ let stream = null;
7422
+ const { attempts, attempt, attachAttempts } = createGetUserMediaAttempts();
7423
+ const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
7424
+ const stopTracks = isMobile || only !== "video";
7425
+ const constraints = getConstraints(constraintOpt);
7426
+ const getSingleStream = () => __awaiter(this, void 0, void 0, function* () {
7358
7427
  if (constraints.audio && constraints.video) {
7359
7428
  try {
7360
7429
  stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { audioId: false })));
7361
7430
  }
7362
- catch (e2) {
7363
- if ((e2 === null || e2 === void 0 ? void 0 : e2.name) !== "NotFoundError") {
7364
- addDetails(e2, e);
7365
- }
7431
+ catch (_a) {
7366
7432
  }
7367
7433
  try {
7368
7434
  if (!stream)
7369
7435
  stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { videoId: false })));
7370
7436
  }
7371
- catch (e2) {
7372
- addDetails(e2, e);
7437
+ catch (_b) {
7373
7438
  }
7374
7439
  }
7375
7440
  });
@@ -7381,7 +7446,7 @@ function getStream(constraintOpt_1) {
7381
7446
  catch (e) {
7382
7447
  error = e;
7383
7448
  if (!fallback) {
7384
- throw attachAttempts(addDetails(e));
7449
+ throw attachAttempts(e || new Error("Unknown error"));
7385
7450
  }
7386
7451
  if ((e === null || e === void 0 ? void 0 : e.name) === "OverconstrainedError") {
7387
7452
  const laxConstraints = {
@@ -7393,7 +7458,7 @@ function getStream(constraintOpt_1) {
7393
7458
  retryConstraintOpt = laxConstraints[e.constraint || ""];
7394
7459
  }
7395
7460
  else if ((e === null || e === void 0 ? void 0 : e.name) === "NotFoundError") {
7396
- yield getSingleStream(e);
7461
+ yield getSingleStream();
7397
7462
  }
7398
7463
  else if ((e === null || e === void 0 ? void 0 : e.name) === "NotAllowedError" || (e === null || e === void 0 ? void 0 : e.name) === "NotReadableError" || (e === null || e === void 0 ? void 0 : e.name) === "AbortError") {
7399
7464
  if (replaceStream && !stopTracks) {
@@ -7401,7 +7466,7 @@ function getStream(constraintOpt_1) {
7401
7466
  retryConstraintOpt = constraintOpt;
7402
7467
  }
7403
7468
  if ((e === null || e === void 0 ? void 0 : e.name) === "NotAllowedError") {
7404
- yield getSingleStream(e);
7469
+ yield getSingleStream();
7405
7470
  }
7406
7471
  else if (e.name !== "NotAllowedError") {
7407
7472
  try {
@@ -7436,22 +7501,21 @@ function getStream(constraintOpt_1) {
7436
7501
  }
7437
7502
  }
7438
7503
  else if (!e) {
7439
- yield getSingleStream(e);
7504
+ yield getSingleStream();
7440
7505
  }
7441
7506
  }
7442
7507
  if (retryConstraintOpt) {
7443
7508
  const onlyConstraints = only ? { audio: { videoId: false }, video: { audioId: false } }[only] : {};
7444
7509
  const retryConstraints = getConstraints(Object.assign(Object.assign(Object.assign(Object.assign({}, constraintOpt), retryConstraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: retryConstraintOpt.lax }) }), onlyConstraints));
7445
- newConstraints = retryConstraints;
7446
7510
  try {
7447
7511
  stream = yield attempt(retryConstraints);
7448
7512
  }
7449
7513
  catch (e) {
7450
- throw attachAttempts(addDetails(e, error));
7514
+ throw attachAttempts(e || new Error("Unknown error"));
7451
7515
  }
7452
7516
  }
7453
7517
  if (!stream) {
7454
- throw attachAttempts(addDetails(error));
7518
+ throw attachAttempts(error || new Error("Unknown error"));
7455
7519
  }
7456
7520
  let replacedTracks;
7457
7521
  if (replaceStream) {
@@ -7460,7 +7524,7 @@ function getStream(constraintOpt_1) {
7460
7524
  replacedTracks = replaceTracksInStream(replaceStream, stream, only);
7461
7525
  stream = replaceStream;
7462
7526
  }
7463
- return { error: error && addDetails(error), stream, replacedTracks, attempts };
7527
+ return { error, stream, replacedTracks, attempts };
7464
7528
  });
7465
7529
  }
7466
7530
  function hasGetDisplayMedia() {
@@ -7563,4 +7627,4 @@ var RtcEventNames;
7563
7627
  RtcEventNames["stream_added"] = "stream_added";
7564
7628
  })(RtcEventNames || (RtcEventNames = {}));
7565
7629
 
7566
- export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
7630
+ export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getInitialStream, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
@@ -2478,18 +2478,19 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2478
2478
  return constraints;
2479
2479
  }
2480
2480
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2481
- const audioDevices = devices.filter((d) => d.kind === "audioinput");
2482
- const videoDevices = devices.filter((d) => d.kind === "videoinput");
2483
- const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2484
- const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2481
+ const strict = !!devices;
2482
+ const audioDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "audioinput");
2483
+ const videoDevices = devices === null || devices === void 0 ? void 0 : devices.filter((d) => d.kind === "videoinput");
2484
+ const useDefaultAudio = !audioId || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.some((d) => d.deviceId === audioId)));
2485
+ const useDefaultVideo = !videoId || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.some((d) => d.deviceId === videoId)));
2485
2486
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2486
2487
  audioId: useDefaultAudio ? null : { [type]: audioId },
2487
2488
  videoId: useDefaultVideo ? null : { [type]: videoId },
2488
2489
  } }, options));
2489
- if (audioId === false || !audioDevices.length) {
2490
+ if (audioId === false || (strict && !(audioDevices === null || audioDevices === void 0 ? void 0 : audioDevices.length))) {
2490
2491
  delete constraints.audio;
2491
2492
  }
2492
- if (videoId === false || !videoDevices.length) {
2493
+ if (videoId === false || (strict && !(videoDevices === null || videoDevices === void 0 ? void 0 : videoDevices.length))) {
2493
2494
  delete constraints.video;
2494
2495
  }
2495
2496
  return constraints;
@@ -7312,64 +7313,128 @@ function replaceTracksInStream(stream, newStream, only) {
7312
7313
  replacedTracks.forEach((track) => stream.removeTrack(track));
7313
7314
  return replacedTracks;
7314
7315
  }
7315
- function getStream(constraintOpt_1) {
7316
- return __awaiter(this, arguments, void 0, function* (constraintOpt, { replaceStream, fallback = true } = {}) {
7317
- var _a;
7316
+ function createGetUserMediaAttempts() {
7317
+ const attempts = [];
7318
+ const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
7319
+ var _a, _b;
7320
+ try {
7321
+ const s = yield getUserMedia(c);
7322
+ attempts.push({ constraints: c, outcome: { ok: true } });
7323
+ return s;
7324
+ }
7325
+ catch (e) {
7326
+ attempts.push({
7327
+ constraints: c,
7328
+ outcome: Object.assign({ ok: false, errorName: (_a = e === null || e === void 0 ? void 0 : e.name) !== null && _a !== void 0 ? _a : "UnknownError", errorMessage: (_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : String(e) }, ((e === null || e === void 0 ? void 0 : e.constraint) && { constraint: e.constraint })),
7329
+ });
7330
+ throw e;
7331
+ }
7332
+ });
7333
+ const attachAttempts = (err) => {
7334
+ if (err)
7335
+ err.attempts = attempts;
7336
+ return err;
7337
+ };
7338
+ return { attempts, attempt, attachAttempts };
7339
+ }
7340
+ function getInitialStream(constraintOpt) {
7341
+ return __awaiter(this, void 0, void 0, function* () {
7342
+ const { attempts, attempt, attachAttempts } = createGetUserMediaAttempts();
7318
7343
  let error;
7319
- let newConstraints;
7320
- let retryConstraintOpt;
7321
- let stream = null;
7322
- const attempts = [];
7323
- const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
7324
- const stopTracks = isMobile || only !== "video";
7325
- const constraints = getConstraints(constraintOpt);
7326
- const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
7327
- var _a, _b;
7344
+ let stream;
7345
+ const opts = Object.assign(Object.assign({}, constraintOpt), { type: "exact" });
7346
+ try {
7347
+ stream = yield attempt(getConstraints(opts));
7348
+ return {
7349
+ stream,
7350
+ attempts,
7351
+ };
7352
+ }
7353
+ catch (e) {
7354
+ logger.error(e);
7355
+ error = e;
7356
+ }
7357
+ const acquireOneKind = (targetConstraint) => __awaiter(this, void 0, void 0, function* () {
7358
+ const retryOpts = Object.assign(Object.assign({}, opts), { options: Object.assign({}, opts.options) });
7359
+ let stream;
7360
+ let lastError = error;
7361
+ const ignoredConstraint = targetConstraint === "videoId" ? "audioId" : "videoId";
7362
+ if (retryOpts[ignoredConstraint] !== false) {
7363
+ retryOpts[ignoredConstraint] = false;
7364
+ try {
7365
+ stream = yield attempt(getConstraints(retryOpts));
7366
+ return stream;
7367
+ }
7368
+ catch (e) {
7369
+ logger.error(e);
7370
+ lastError = e;
7371
+ }
7372
+ }
7373
+ if ((lastError === null || lastError === void 0 ? void 0 : lastError.name) === "NotAllowedError") {
7374
+ return;
7375
+ }
7376
+ if (retryOpts[targetConstraint]) {
7377
+ retryOpts[targetConstraint] = null;
7378
+ try {
7379
+ stream = yield attempt(getConstraints(retryOpts));
7380
+ return stream;
7381
+ }
7382
+ catch (e) {
7383
+ logger.error(e);
7384
+ }
7385
+ }
7328
7386
  try {
7329
- const s = yield getUserMedia(c);
7330
- attempts.push({ constraints: c, outcome: { ok: true } });
7331
- return s;
7387
+ retryOpts.options.lax = true;
7388
+ stream = yield attempt(getConstraints(retryOpts));
7389
+ return stream;
7332
7390
  }
7333
7391
  catch (e) {
7334
- attempts.push({
7335
- constraints: c,
7336
- outcome: Object.assign({ ok: false, errorName: (_a = e === null || e === void 0 ? void 0 : e.name) !== null && _a !== void 0 ? _a : "UnknownError", errorMessage: (_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : String(e) }, ((e === null || e === void 0 ? void 0 : e.constraint) && { constraint: e.constraint })),
7337
- });
7338
- throw e;
7392
+ logger.error(e);
7339
7393
  }
7340
7394
  });
7341
- const addDetails = (err, orgErr) => {
7342
- if (err) {
7343
- err.details = Object.assign({ constraints, constraint: err.constraint || (orgErr === null || orgErr === void 0 ? void 0 : orgErr.constraint), newConstraints,
7344
- fallback,
7345
- stopTracks }, (err !== error && { error: String(error) }));
7346
- return err;
7395
+ if (opts.videoId !== false) {
7396
+ stream = yield acquireOneKind("videoId");
7397
+ }
7398
+ if (opts.audioId !== false) {
7399
+ if (!stream) {
7400
+ stream = yield acquireOneKind("audioId");
7347
7401
  }
7348
7402
  else {
7349
- return new Error("Unknown error");
7403
+ const audioOnlyStream = yield acquireOneKind("audioId");
7404
+ if (audioOnlyStream) {
7405
+ const audioTrack = audioOnlyStream.getAudioTracks()[0];
7406
+ stream.addTrack(audioTrack);
7407
+ }
7350
7408
  }
7351
- };
7352
- const attachAttempts = (err) => {
7353
- if (err)
7354
- err.attempts = attempts;
7355
- return err;
7356
- };
7357
- const getSingleStream = (e) => __awaiter(this, void 0, void 0, function* () {
7409
+ }
7410
+ if (!stream) {
7411
+ throw attachAttempts(error !== null && error !== void 0 ? error : new Error("Unknown error"));
7412
+ }
7413
+ return { error, stream, attempts };
7414
+ });
7415
+ }
7416
+ function getStream(constraintOpt_1) {
7417
+ return __awaiter(this, arguments, void 0, function* (constraintOpt, { replaceStream, fallback = true } = {}) {
7418
+ var _a;
7419
+ let error;
7420
+ let retryConstraintOpt;
7421
+ let stream = null;
7422
+ const { attempts, attempt, attachAttempts } = createGetUserMediaAttempts();
7423
+ const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
7424
+ const stopTracks = isMobile || only !== "video";
7425
+ const constraints = getConstraints(constraintOpt);
7426
+ const getSingleStream = () => __awaiter(this, void 0, void 0, function* () {
7358
7427
  if (constraints.audio && constraints.video) {
7359
7428
  try {
7360
7429
  stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { audioId: false })));
7361
7430
  }
7362
- catch (e2) {
7363
- if ((e2 === null || e2 === void 0 ? void 0 : e2.name) !== "NotFoundError") {
7364
- addDetails(e2, e);
7365
- }
7431
+ catch (_a) {
7366
7432
  }
7367
7433
  try {
7368
7434
  if (!stream)
7369
7435
  stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { videoId: false })));
7370
7436
  }
7371
- catch (e2) {
7372
- addDetails(e2, e);
7437
+ catch (_b) {
7373
7438
  }
7374
7439
  }
7375
7440
  });
@@ -7381,7 +7446,7 @@ function getStream(constraintOpt_1) {
7381
7446
  catch (e) {
7382
7447
  error = e;
7383
7448
  if (!fallback) {
7384
- throw attachAttempts(addDetails(e));
7449
+ throw attachAttempts(e || new Error("Unknown error"));
7385
7450
  }
7386
7451
  if ((e === null || e === void 0 ? void 0 : e.name) === "OverconstrainedError") {
7387
7452
  const laxConstraints = {
@@ -7393,7 +7458,7 @@ function getStream(constraintOpt_1) {
7393
7458
  retryConstraintOpt = laxConstraints[e.constraint || ""];
7394
7459
  }
7395
7460
  else if ((e === null || e === void 0 ? void 0 : e.name) === "NotFoundError") {
7396
- yield getSingleStream(e);
7461
+ yield getSingleStream();
7397
7462
  }
7398
7463
  else if ((e === null || e === void 0 ? void 0 : e.name) === "NotAllowedError" || (e === null || e === void 0 ? void 0 : e.name) === "NotReadableError" || (e === null || e === void 0 ? void 0 : e.name) === "AbortError") {
7399
7464
  if (replaceStream && !stopTracks) {
@@ -7401,7 +7466,7 @@ function getStream(constraintOpt_1) {
7401
7466
  retryConstraintOpt = constraintOpt;
7402
7467
  }
7403
7468
  if ((e === null || e === void 0 ? void 0 : e.name) === "NotAllowedError") {
7404
- yield getSingleStream(e);
7469
+ yield getSingleStream();
7405
7470
  }
7406
7471
  else if (e.name !== "NotAllowedError") {
7407
7472
  try {
@@ -7436,22 +7501,21 @@ function getStream(constraintOpt_1) {
7436
7501
  }
7437
7502
  }
7438
7503
  else if (!e) {
7439
- yield getSingleStream(e);
7504
+ yield getSingleStream();
7440
7505
  }
7441
7506
  }
7442
7507
  if (retryConstraintOpt) {
7443
7508
  const onlyConstraints = only ? { audio: { videoId: false }, video: { audioId: false } }[only] : {};
7444
7509
  const retryConstraints = getConstraints(Object.assign(Object.assign(Object.assign(Object.assign({}, constraintOpt), retryConstraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: retryConstraintOpt.lax }) }), onlyConstraints));
7445
- newConstraints = retryConstraints;
7446
7510
  try {
7447
7511
  stream = yield attempt(retryConstraints);
7448
7512
  }
7449
7513
  catch (e) {
7450
- throw attachAttempts(addDetails(e, error));
7514
+ throw attachAttempts(e || new Error("Unknown error"));
7451
7515
  }
7452
7516
  }
7453
7517
  if (!stream) {
7454
- throw attachAttempts(addDetails(error));
7518
+ throw attachAttempts(error || new Error("Unknown error"));
7455
7519
  }
7456
7520
  let replacedTracks;
7457
7521
  if (replaceStream) {
@@ -7460,7 +7524,7 @@ function getStream(constraintOpt_1) {
7460
7524
  replacedTracks = replaceTracksInStream(replaceStream, stream, only);
7461
7525
  stream = replaceStream;
7462
7526
  }
7463
- return { error: error && addDetails(error), stream, replacedTracks, attempts };
7527
+ return { error, stream, replacedTracks, attempts };
7464
7528
  });
7465
7529
  }
7466
7530
  function hasGetDisplayMedia() {
@@ -7563,5 +7627,5 @@ var RtcEventNames;
7563
7627
  RtcEventNames["stream_added"] = "stream_added";
7564
7628
  })(RtcEventNames || (RtcEventNames = {}));
7565
7629
 
7566
- export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
7630
+ export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, FILE_SHARE_ERROR_CODES, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getInitialStream, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isFileShareError, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, updateRenderedDimensions, variance };
7567
7631
  //# sourceMappingURL=legacy-esm.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "9.6.1",
4
+ "version": "9.7.1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {