@whereby.com/media 9.0.0 → 9.1.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/index.cjs +34 -12
- package/dist/index.d.cts +14 -1
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.mjs +34 -12
- package/dist/legacy-esm.js +34 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7149,9 +7149,25 @@ function getStream(constraintOpt_1) {
|
|
|
7149
7149
|
let newConstraints;
|
|
7150
7150
|
let retryConstraintOpt;
|
|
7151
7151
|
let stream = null;
|
|
7152
|
+
const attempts = [];
|
|
7152
7153
|
const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
|
|
7153
7154
|
const stopTracks = isMobile || only !== "video";
|
|
7154
7155
|
const constraints = getConstraints(constraintOpt);
|
|
7156
|
+
const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
|
|
7157
|
+
var _a, _b;
|
|
7158
|
+
try {
|
|
7159
|
+
const s = yield getUserMedia(c);
|
|
7160
|
+
attempts.push({ constraints: c, outcome: { ok: true } });
|
|
7161
|
+
return s;
|
|
7162
|
+
}
|
|
7163
|
+
catch (e) {
|
|
7164
|
+
attempts.push({
|
|
7165
|
+
constraints: c,
|
|
7166
|
+
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 })),
|
|
7167
|
+
});
|
|
7168
|
+
throw e;
|
|
7169
|
+
}
|
|
7170
|
+
});
|
|
7155
7171
|
const addDetails = (err, orgErr) => {
|
|
7156
7172
|
if (err) {
|
|
7157
7173
|
err.details = Object.assign({ constraints, constraint: err.constraint || (orgErr === null || orgErr === void 0 ? void 0 : orgErr.constraint), newConstraints,
|
|
@@ -7163,10 +7179,15 @@ function getStream(constraintOpt_1) {
|
|
|
7163
7179
|
return new Error("Unknown error");
|
|
7164
7180
|
}
|
|
7165
7181
|
};
|
|
7182
|
+
const attachAttempts = (err) => {
|
|
7183
|
+
if (err)
|
|
7184
|
+
err.attempts = attempts;
|
|
7185
|
+
return err;
|
|
7186
|
+
};
|
|
7166
7187
|
const getSingleStream = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
7167
7188
|
if (constraints.audio && constraints.video) {
|
|
7168
7189
|
try {
|
|
7169
|
-
stream = yield
|
|
7190
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { audioId: false })));
|
|
7170
7191
|
}
|
|
7171
7192
|
catch (e2) {
|
|
7172
7193
|
if ((e2 === null || e2 === void 0 ? void 0 : e2.name) !== "NotFoundError") {
|
|
@@ -7175,7 +7196,7 @@ function getStream(constraintOpt_1) {
|
|
|
7175
7196
|
}
|
|
7176
7197
|
try {
|
|
7177
7198
|
if (!stream)
|
|
7178
|
-
stream = yield
|
|
7199
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { videoId: false })));
|
|
7179
7200
|
}
|
|
7180
7201
|
catch (e2) {
|
|
7181
7202
|
addDetails(e2, e);
|
|
@@ -7185,12 +7206,12 @@ function getStream(constraintOpt_1) {
|
|
|
7185
7206
|
if (stopTracks && replaceStream)
|
|
7186
7207
|
stopStreamTracks(replaceStream, only);
|
|
7187
7208
|
try {
|
|
7188
|
-
stream = yield
|
|
7209
|
+
stream = yield attempt(constraints);
|
|
7189
7210
|
}
|
|
7190
7211
|
catch (e) {
|
|
7191
7212
|
error = e;
|
|
7192
7213
|
if (!fallback) {
|
|
7193
|
-
throw addDetails(e);
|
|
7214
|
+
throw attachAttempts(addDetails(e));
|
|
7194
7215
|
}
|
|
7195
7216
|
if ((e === null || e === void 0 ? void 0 : e.name) === "OverconstrainedError") {
|
|
7196
7217
|
const laxConstraints = {
|
|
@@ -7214,7 +7235,7 @@ function getStream(constraintOpt_1) {
|
|
|
7214
7235
|
}
|
|
7215
7236
|
else if (e.name !== "NotAllowedError") {
|
|
7216
7237
|
try {
|
|
7217
|
-
stream = yield
|
|
7238
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: true }) })));
|
|
7218
7239
|
}
|
|
7219
7240
|
catch (e2) {
|
|
7220
7241
|
logger.warn(`Tried getting stream again with laxer constraints, but failed: ${"" + e2}`);
|
|
@@ -7223,7 +7244,7 @@ function getStream(constraintOpt_1) {
|
|
|
7223
7244
|
const problemWith = { audio: "audioId", video: "videoId" }[((_a = /(video|audio)/.exec(errMsg)) === null || _a === void 0 ? void 0 : _a[0]) || only || ""];
|
|
7224
7245
|
if (!stream && problemWith) {
|
|
7225
7246
|
try {
|
|
7226
|
-
stream = yield
|
|
7247
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { [problemWith]: null })));
|
|
7227
7248
|
}
|
|
7228
7249
|
catch (e2) {
|
|
7229
7250
|
logger.warn(`Re-tried ${problemWith} with no constraints, but failed: ${"" + e2}`);
|
|
@@ -7233,7 +7254,7 @@ function getStream(constraintOpt_1) {
|
|
|
7233
7254
|
const tryOnly = problemWith ? [problemWith] : ["videoId", "audioId"];
|
|
7234
7255
|
for (const kind of tryOnly) {
|
|
7235
7256
|
try {
|
|
7236
|
-
stream = yield
|
|
7257
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { [kind]: false })));
|
|
7237
7258
|
}
|
|
7238
7259
|
catch (e2) {
|
|
7239
7260
|
logger.warn(`Re-tried without ${kind}, but failed: ${"" + e2}`);
|
|
@@ -7250,16 +7271,17 @@ function getStream(constraintOpt_1) {
|
|
|
7250
7271
|
}
|
|
7251
7272
|
if (retryConstraintOpt) {
|
|
7252
7273
|
const onlyConstraints = only ? { audio: { videoId: false }, video: { audioId: false } }[only] : {};
|
|
7253
|
-
|
|
7274
|
+
const retryConstraints = getConstraints(Object.assign(Object.assign(Object.assign(Object.assign({}, constraintOpt), retryConstraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: retryConstraintOpt.lax }) }), onlyConstraints));
|
|
7275
|
+
newConstraints = retryConstraints;
|
|
7254
7276
|
try {
|
|
7255
|
-
stream = yield
|
|
7277
|
+
stream = yield attempt(retryConstraints);
|
|
7256
7278
|
}
|
|
7257
7279
|
catch (e) {
|
|
7258
|
-
throw addDetails(e, error);
|
|
7280
|
+
throw attachAttempts(addDetails(e, error));
|
|
7259
7281
|
}
|
|
7260
7282
|
}
|
|
7261
7283
|
if (!stream) {
|
|
7262
|
-
throw addDetails(error);
|
|
7284
|
+
throw attachAttempts(addDetails(error));
|
|
7263
7285
|
}
|
|
7264
7286
|
let replacedTracks;
|
|
7265
7287
|
if (replaceStream) {
|
|
@@ -7268,7 +7290,7 @@ function getStream(constraintOpt_1) {
|
|
|
7268
7290
|
replacedTracks = replaceTracksInStream(replaceStream, stream, only);
|
|
7269
7291
|
stream = replaceStream;
|
|
7270
7292
|
}
|
|
7271
|
-
return { error: error && addDetails(error), stream, replacedTracks };
|
|
7293
|
+
return { error: error && addDetails(error), stream, replacedTracks, attempts };
|
|
7272
7294
|
});
|
|
7273
7295
|
}
|
|
7274
7296
|
function hasGetDisplayMedia() {
|
package/dist/index.d.cts
CHANGED
|
@@ -604,10 +604,23 @@ interface BuildDeviceListOptions {
|
|
|
604
604
|
busyDeviceIds: string[];
|
|
605
605
|
kind: MediaDeviceKind;
|
|
606
606
|
}
|
|
607
|
+
type GetUserMediaAttemptOutcome = {
|
|
608
|
+
ok: true;
|
|
609
|
+
} | {
|
|
610
|
+
ok: false;
|
|
611
|
+
errorName: string;
|
|
612
|
+
errorMessage: string;
|
|
613
|
+
constraint?: string;
|
|
614
|
+
};
|
|
615
|
+
type GetUserMediaAttempt = {
|
|
616
|
+
constraints: MediaStreamConstraints;
|
|
617
|
+
outcome: GetUserMediaAttemptOutcome;
|
|
618
|
+
};
|
|
607
619
|
type GetStreamResult = {
|
|
608
620
|
error?: unknown;
|
|
609
621
|
replacedTracks?: MediaStreamTrack[];
|
|
610
622
|
stream: MediaStream;
|
|
623
|
+
attempts: GetUserMediaAttempt[];
|
|
611
624
|
};
|
|
612
625
|
type UpdatedDeviceInfo = {
|
|
613
626
|
deviceId?: string | null;
|
|
@@ -2017,4 +2030,4 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
2017
2030
|
}
|
|
2018
2031
|
|
|
2019
2032
|
export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, 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, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, variance };
|
|
2020
|
-
export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatMessage, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, 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 };
|
|
2033
|
+
export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatMessage, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, 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
|
@@ -604,10 +604,23 @@ interface BuildDeviceListOptions {
|
|
|
604
604
|
busyDeviceIds: string[];
|
|
605
605
|
kind: MediaDeviceKind;
|
|
606
606
|
}
|
|
607
|
+
type GetUserMediaAttemptOutcome = {
|
|
608
|
+
ok: true;
|
|
609
|
+
} | {
|
|
610
|
+
ok: false;
|
|
611
|
+
errorName: string;
|
|
612
|
+
errorMessage: string;
|
|
613
|
+
constraint?: string;
|
|
614
|
+
};
|
|
615
|
+
type GetUserMediaAttempt = {
|
|
616
|
+
constraints: MediaStreamConstraints;
|
|
617
|
+
outcome: GetUserMediaAttemptOutcome;
|
|
618
|
+
};
|
|
607
619
|
type GetStreamResult = {
|
|
608
620
|
error?: unknown;
|
|
609
621
|
replacedTracks?: MediaStreamTrack[];
|
|
610
622
|
stream: MediaStream;
|
|
623
|
+
attempts: GetUserMediaAttempt[];
|
|
611
624
|
};
|
|
612
625
|
type UpdatedDeviceInfo = {
|
|
613
626
|
deviceId?: string | null;
|
|
@@ -2017,4 +2030,4 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
2017
2030
|
}
|
|
2018
2031
|
|
|
2019
2032
|
export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, 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, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, variance };
|
|
2020
|
-
export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatMessage, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, 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 };
|
|
2033
|
+
export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatMessage, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, 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
|
@@ -604,10 +604,23 @@ interface BuildDeviceListOptions {
|
|
|
604
604
|
busyDeviceIds: string[];
|
|
605
605
|
kind: MediaDeviceKind;
|
|
606
606
|
}
|
|
607
|
+
type GetUserMediaAttemptOutcome = {
|
|
608
|
+
ok: true;
|
|
609
|
+
} | {
|
|
610
|
+
ok: false;
|
|
611
|
+
errorName: string;
|
|
612
|
+
errorMessage: string;
|
|
613
|
+
constraint?: string;
|
|
614
|
+
};
|
|
615
|
+
type GetUserMediaAttempt = {
|
|
616
|
+
constraints: MediaStreamConstraints;
|
|
617
|
+
outcome: GetUserMediaAttemptOutcome;
|
|
618
|
+
};
|
|
607
619
|
type GetStreamResult = {
|
|
608
620
|
error?: unknown;
|
|
609
621
|
replacedTracks?: MediaStreamTrack[];
|
|
610
622
|
stream: MediaStream;
|
|
623
|
+
attempts: GetUserMediaAttempt[];
|
|
611
624
|
};
|
|
612
625
|
type UpdatedDeviceInfo = {
|
|
613
626
|
deviceId?: string | null;
|
|
@@ -2017,4 +2030,4 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
2017
2030
|
}
|
|
2018
2031
|
|
|
2019
2032
|
export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, 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, isMobile, issueDetectorOrMetricEnabled, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, variance };
|
|
2020
|
-
export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatMessage, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, 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 };
|
|
2033
|
+
export type { AddCameraStreamOptions, AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, BuildDeviceListOptions, CannotJoinUnclaimedRoomError, ChatMessage, ClearableTimeout, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, ConnectionStatus, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, GetUserMediaAttempt, GetUserMediaAttemptOutcome, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, 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
|
@@ -7128,9 +7128,25 @@ function getStream(constraintOpt_1) {
|
|
|
7128
7128
|
let newConstraints;
|
|
7129
7129
|
let retryConstraintOpt;
|
|
7130
7130
|
let stream = null;
|
|
7131
|
+
const attempts = [];
|
|
7131
7132
|
const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
|
|
7132
7133
|
const stopTracks = isMobile || only !== "video";
|
|
7133
7134
|
const constraints = getConstraints(constraintOpt);
|
|
7135
|
+
const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
|
|
7136
|
+
var _a, _b;
|
|
7137
|
+
try {
|
|
7138
|
+
const s = yield getUserMedia(c);
|
|
7139
|
+
attempts.push({ constraints: c, outcome: { ok: true } });
|
|
7140
|
+
return s;
|
|
7141
|
+
}
|
|
7142
|
+
catch (e) {
|
|
7143
|
+
attempts.push({
|
|
7144
|
+
constraints: c,
|
|
7145
|
+
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 })),
|
|
7146
|
+
});
|
|
7147
|
+
throw e;
|
|
7148
|
+
}
|
|
7149
|
+
});
|
|
7134
7150
|
const addDetails = (err, orgErr) => {
|
|
7135
7151
|
if (err) {
|
|
7136
7152
|
err.details = Object.assign({ constraints, constraint: err.constraint || (orgErr === null || orgErr === void 0 ? void 0 : orgErr.constraint), newConstraints,
|
|
@@ -7142,10 +7158,15 @@ function getStream(constraintOpt_1) {
|
|
|
7142
7158
|
return new Error("Unknown error");
|
|
7143
7159
|
}
|
|
7144
7160
|
};
|
|
7161
|
+
const attachAttempts = (err) => {
|
|
7162
|
+
if (err)
|
|
7163
|
+
err.attempts = attempts;
|
|
7164
|
+
return err;
|
|
7165
|
+
};
|
|
7145
7166
|
const getSingleStream = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
7146
7167
|
if (constraints.audio && constraints.video) {
|
|
7147
7168
|
try {
|
|
7148
|
-
stream = yield
|
|
7169
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { audioId: false })));
|
|
7149
7170
|
}
|
|
7150
7171
|
catch (e2) {
|
|
7151
7172
|
if ((e2 === null || e2 === void 0 ? void 0 : e2.name) !== "NotFoundError") {
|
|
@@ -7154,7 +7175,7 @@ function getStream(constraintOpt_1) {
|
|
|
7154
7175
|
}
|
|
7155
7176
|
try {
|
|
7156
7177
|
if (!stream)
|
|
7157
|
-
stream = yield
|
|
7178
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { videoId: false })));
|
|
7158
7179
|
}
|
|
7159
7180
|
catch (e2) {
|
|
7160
7181
|
addDetails(e2, e);
|
|
@@ -7164,12 +7185,12 @@ function getStream(constraintOpt_1) {
|
|
|
7164
7185
|
if (stopTracks && replaceStream)
|
|
7165
7186
|
stopStreamTracks(replaceStream, only);
|
|
7166
7187
|
try {
|
|
7167
|
-
stream = yield
|
|
7188
|
+
stream = yield attempt(constraints);
|
|
7168
7189
|
}
|
|
7169
7190
|
catch (e) {
|
|
7170
7191
|
error = e;
|
|
7171
7192
|
if (!fallback) {
|
|
7172
|
-
throw addDetails(e);
|
|
7193
|
+
throw attachAttempts(addDetails(e));
|
|
7173
7194
|
}
|
|
7174
7195
|
if ((e === null || e === void 0 ? void 0 : e.name) === "OverconstrainedError") {
|
|
7175
7196
|
const laxConstraints = {
|
|
@@ -7193,7 +7214,7 @@ function getStream(constraintOpt_1) {
|
|
|
7193
7214
|
}
|
|
7194
7215
|
else if (e.name !== "NotAllowedError") {
|
|
7195
7216
|
try {
|
|
7196
|
-
stream = yield
|
|
7217
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: true }) })));
|
|
7197
7218
|
}
|
|
7198
7219
|
catch (e2) {
|
|
7199
7220
|
logger.warn(`Tried getting stream again with laxer constraints, but failed: ${"" + e2}`);
|
|
@@ -7202,7 +7223,7 @@ function getStream(constraintOpt_1) {
|
|
|
7202
7223
|
const problemWith = { audio: "audioId", video: "videoId" }[((_a = /(video|audio)/.exec(errMsg)) === null || _a === void 0 ? void 0 : _a[0]) || only || ""];
|
|
7203
7224
|
if (!stream && problemWith) {
|
|
7204
7225
|
try {
|
|
7205
|
-
stream = yield
|
|
7226
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { [problemWith]: null })));
|
|
7206
7227
|
}
|
|
7207
7228
|
catch (e2) {
|
|
7208
7229
|
logger.warn(`Re-tried ${problemWith} with no constraints, but failed: ${"" + e2}`);
|
|
@@ -7212,7 +7233,7 @@ function getStream(constraintOpt_1) {
|
|
|
7212
7233
|
const tryOnly = problemWith ? [problemWith] : ["videoId", "audioId"];
|
|
7213
7234
|
for (const kind of tryOnly) {
|
|
7214
7235
|
try {
|
|
7215
|
-
stream = yield
|
|
7236
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { [kind]: false })));
|
|
7216
7237
|
}
|
|
7217
7238
|
catch (e2) {
|
|
7218
7239
|
logger.warn(`Re-tried without ${kind}, but failed: ${"" + e2}`);
|
|
@@ -7229,16 +7250,17 @@ function getStream(constraintOpt_1) {
|
|
|
7229
7250
|
}
|
|
7230
7251
|
if (retryConstraintOpt) {
|
|
7231
7252
|
const onlyConstraints = only ? { audio: { videoId: false }, video: { audioId: false } }[only] : {};
|
|
7232
|
-
|
|
7253
|
+
const retryConstraints = getConstraints(Object.assign(Object.assign(Object.assign(Object.assign({}, constraintOpt), retryConstraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: retryConstraintOpt.lax }) }), onlyConstraints));
|
|
7254
|
+
newConstraints = retryConstraints;
|
|
7233
7255
|
try {
|
|
7234
|
-
stream = yield
|
|
7256
|
+
stream = yield attempt(retryConstraints);
|
|
7235
7257
|
}
|
|
7236
7258
|
catch (e) {
|
|
7237
|
-
throw addDetails(e, error);
|
|
7259
|
+
throw attachAttempts(addDetails(e, error));
|
|
7238
7260
|
}
|
|
7239
7261
|
}
|
|
7240
7262
|
if (!stream) {
|
|
7241
|
-
throw addDetails(error);
|
|
7263
|
+
throw attachAttempts(addDetails(error));
|
|
7242
7264
|
}
|
|
7243
7265
|
let replacedTracks;
|
|
7244
7266
|
if (replaceStream) {
|
|
@@ -7247,7 +7269,7 @@ function getStream(constraintOpt_1) {
|
|
|
7247
7269
|
replacedTracks = replaceTracksInStream(replaceStream, stream, only);
|
|
7248
7270
|
stream = replaceStream;
|
|
7249
7271
|
}
|
|
7250
|
-
return { error: error && addDetails(error), stream, replacedTracks };
|
|
7272
|
+
return { error: error && addDetails(error), stream, replacedTracks, attempts };
|
|
7251
7273
|
});
|
|
7252
7274
|
}
|
|
7253
7275
|
function hasGetDisplayMedia() {
|
package/dist/legacy-esm.js
CHANGED
|
@@ -7128,9 +7128,25 @@ function getStream(constraintOpt_1) {
|
|
|
7128
7128
|
let newConstraints;
|
|
7129
7129
|
let retryConstraintOpt;
|
|
7130
7130
|
let stream = null;
|
|
7131
|
+
const attempts = [];
|
|
7131
7132
|
const only = (constraintOpt.audioId === false && "video") || (constraintOpt.videoId === false && "audio");
|
|
7132
7133
|
const stopTracks = isMobile || only !== "video";
|
|
7133
7134
|
const constraints = getConstraints(constraintOpt);
|
|
7135
|
+
const attempt = (c) => __awaiter(this, void 0, void 0, function* () {
|
|
7136
|
+
var _a, _b;
|
|
7137
|
+
try {
|
|
7138
|
+
const s = yield getUserMedia(c);
|
|
7139
|
+
attempts.push({ constraints: c, outcome: { ok: true } });
|
|
7140
|
+
return s;
|
|
7141
|
+
}
|
|
7142
|
+
catch (e) {
|
|
7143
|
+
attempts.push({
|
|
7144
|
+
constraints: c,
|
|
7145
|
+
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 })),
|
|
7146
|
+
});
|
|
7147
|
+
throw e;
|
|
7148
|
+
}
|
|
7149
|
+
});
|
|
7134
7150
|
const addDetails = (err, orgErr) => {
|
|
7135
7151
|
if (err) {
|
|
7136
7152
|
err.details = Object.assign({ constraints, constraint: err.constraint || (orgErr === null || orgErr === void 0 ? void 0 : orgErr.constraint), newConstraints,
|
|
@@ -7142,10 +7158,15 @@ function getStream(constraintOpt_1) {
|
|
|
7142
7158
|
return new Error("Unknown error");
|
|
7143
7159
|
}
|
|
7144
7160
|
};
|
|
7161
|
+
const attachAttempts = (err) => {
|
|
7162
|
+
if (err)
|
|
7163
|
+
err.attempts = attempts;
|
|
7164
|
+
return err;
|
|
7165
|
+
};
|
|
7145
7166
|
const getSingleStream = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
7146
7167
|
if (constraints.audio && constraints.video) {
|
|
7147
7168
|
try {
|
|
7148
|
-
stream = yield
|
|
7169
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { audioId: false })));
|
|
7149
7170
|
}
|
|
7150
7171
|
catch (e2) {
|
|
7151
7172
|
if ((e2 === null || e2 === void 0 ? void 0 : e2.name) !== "NotFoundError") {
|
|
@@ -7154,7 +7175,7 @@ function getStream(constraintOpt_1) {
|
|
|
7154
7175
|
}
|
|
7155
7176
|
try {
|
|
7156
7177
|
if (!stream)
|
|
7157
|
-
stream = yield
|
|
7178
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { videoId: false })));
|
|
7158
7179
|
}
|
|
7159
7180
|
catch (e2) {
|
|
7160
7181
|
addDetails(e2, e);
|
|
@@ -7164,12 +7185,12 @@ function getStream(constraintOpt_1) {
|
|
|
7164
7185
|
if (stopTracks && replaceStream)
|
|
7165
7186
|
stopStreamTracks(replaceStream, only);
|
|
7166
7187
|
try {
|
|
7167
|
-
stream = yield
|
|
7188
|
+
stream = yield attempt(constraints);
|
|
7168
7189
|
}
|
|
7169
7190
|
catch (e) {
|
|
7170
7191
|
error = e;
|
|
7171
7192
|
if (!fallback) {
|
|
7172
|
-
throw addDetails(e);
|
|
7193
|
+
throw attachAttempts(addDetails(e));
|
|
7173
7194
|
}
|
|
7174
7195
|
if ((e === null || e === void 0 ? void 0 : e.name) === "OverconstrainedError") {
|
|
7175
7196
|
const laxConstraints = {
|
|
@@ -7193,7 +7214,7 @@ function getStream(constraintOpt_1) {
|
|
|
7193
7214
|
}
|
|
7194
7215
|
else if (e.name !== "NotAllowedError") {
|
|
7195
7216
|
try {
|
|
7196
|
-
stream = yield
|
|
7217
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: true }) })));
|
|
7197
7218
|
}
|
|
7198
7219
|
catch (e2) {
|
|
7199
7220
|
logger.warn(`Tried getting stream again with laxer constraints, but failed: ${"" + e2}`);
|
|
@@ -7202,7 +7223,7 @@ function getStream(constraintOpt_1) {
|
|
|
7202
7223
|
const problemWith = { audio: "audioId", video: "videoId" }[((_a = /(video|audio)/.exec(errMsg)) === null || _a === void 0 ? void 0 : _a[0]) || only || ""];
|
|
7203
7224
|
if (!stream && problemWith) {
|
|
7204
7225
|
try {
|
|
7205
|
-
stream = yield
|
|
7226
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { [problemWith]: null })));
|
|
7206
7227
|
}
|
|
7207
7228
|
catch (e2) {
|
|
7208
7229
|
logger.warn(`Re-tried ${problemWith} with no constraints, but failed: ${"" + e2}`);
|
|
@@ -7212,7 +7233,7 @@ function getStream(constraintOpt_1) {
|
|
|
7212
7233
|
const tryOnly = problemWith ? [problemWith] : ["videoId", "audioId"];
|
|
7213
7234
|
for (const kind of tryOnly) {
|
|
7214
7235
|
try {
|
|
7215
|
-
stream = yield
|
|
7236
|
+
stream = yield attempt(getConstraints(Object.assign(Object.assign({}, constraintOpt), { [kind]: false })));
|
|
7216
7237
|
}
|
|
7217
7238
|
catch (e2) {
|
|
7218
7239
|
logger.warn(`Re-tried without ${kind}, but failed: ${"" + e2}`);
|
|
@@ -7229,16 +7250,17 @@ function getStream(constraintOpt_1) {
|
|
|
7229
7250
|
}
|
|
7230
7251
|
if (retryConstraintOpt) {
|
|
7231
7252
|
const onlyConstraints = only ? { audio: { videoId: false }, video: { audioId: false } }[only] : {};
|
|
7232
|
-
|
|
7253
|
+
const retryConstraints = getConstraints(Object.assign(Object.assign(Object.assign(Object.assign({}, constraintOpt), retryConstraintOpt), { options: Object.assign(Object.assign({}, constraintOpt.options), { lax: retryConstraintOpt.lax }) }), onlyConstraints));
|
|
7254
|
+
newConstraints = retryConstraints;
|
|
7233
7255
|
try {
|
|
7234
|
-
stream = yield
|
|
7256
|
+
stream = yield attempt(retryConstraints);
|
|
7235
7257
|
}
|
|
7236
7258
|
catch (e) {
|
|
7237
|
-
throw addDetails(e, error);
|
|
7259
|
+
throw attachAttempts(addDetails(e, error));
|
|
7238
7260
|
}
|
|
7239
7261
|
}
|
|
7240
7262
|
if (!stream) {
|
|
7241
|
-
throw addDetails(error);
|
|
7263
|
+
throw attachAttempts(addDetails(error));
|
|
7242
7264
|
}
|
|
7243
7265
|
let replacedTracks;
|
|
7244
7266
|
if (replaceStream) {
|
|
@@ -7247,7 +7269,7 @@ function getStream(constraintOpt_1) {
|
|
|
7247
7269
|
replacedTracks = replaceTracksInStream(replaceStream, stream, only);
|
|
7248
7270
|
stream = replaceStream;
|
|
7249
7271
|
}
|
|
7250
|
-
return { error: error && addDetails(error), stream, replacedTracks };
|
|
7272
|
+
return { error: error && addDetails(error), stream, replacedTracks, attempts };
|
|
7251
7273
|
});
|
|
7252
7274
|
}
|
|
7253
7275
|
function hasGetDisplayMedia() {
|