@whereby.com/media 3.0.0 → 3.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 +27 -7
- package/dist/index.d.cts +27 -9
- package/dist/index.d.mts +27 -9
- package/dist/index.d.ts +27 -9
- package/dist/index.mjs +27 -7
- package/dist/legacy-esm.js +27 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2572,6 +2572,7 @@ var _a$2, _b$1;
|
|
|
2572
2572
|
const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
|
|
2573
2573
|
const logger$6 = new Logger();
|
|
2574
2574
|
const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
|
|
2575
|
+
const ICE_RESTART_DELAY = 2 * 1000;
|
|
2575
2576
|
const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
|
|
2576
2577
|
const browserVersion = adapter$2.browserDetails.version;
|
|
2577
2578
|
let unloading$1 = false;
|
|
@@ -2616,6 +2617,7 @@ class P2pRtcManager {
|
|
|
2616
2617
|
mediaserverConfigTtlSeconds,
|
|
2617
2618
|
});
|
|
2618
2619
|
this.analytics = {
|
|
2620
|
+
P2POffendingInitialOffer: 0,
|
|
2619
2621
|
P2PNonErrorRejectionValueGUMError: 0,
|
|
2620
2622
|
numNewPc: 0,
|
|
2621
2623
|
numIceConnected: 0,
|
|
@@ -2738,6 +2740,7 @@ class P2pRtcManager {
|
|
|
2738
2740
|
this._updateAndScheduleMediaServersRefresh(data);
|
|
2739
2741
|
}),
|
|
2740
2742
|
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
|
|
2743
|
+
logger$6.info(`got ready_to_receive_offer from ${data.clientId}`);
|
|
2741
2744
|
this._connect(data.clientId);
|
|
2742
2745
|
}),
|
|
2743
2746
|
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
|
|
@@ -2749,6 +2752,7 @@ class P2pRtcManager {
|
|
|
2749
2752
|
session.addIceCandidate(data.message);
|
|
2750
2753
|
}),
|
|
2751
2754
|
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
|
|
2755
|
+
logger$6.info(`got end_of_ice_candidates from ${data.clientId}`);
|
|
2752
2756
|
const session = this._getSession(data.clientId);
|
|
2753
2757
|
if (!session) {
|
|
2754
2758
|
logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
|
|
@@ -2758,6 +2762,7 @@ class P2pRtcManager {
|
|
|
2758
2762
|
}),
|
|
2759
2763
|
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
|
|
2760
2764
|
var _a, _b;
|
|
2765
|
+
logger$6.info(`got offer from ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
|
|
2761
2766
|
const session = this._getSession(data.clientId);
|
|
2762
2767
|
if (!session) {
|
|
2763
2768
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
@@ -2767,6 +2772,16 @@ class P2pRtcManager {
|
|
|
2767
2772
|
sdp: data.message.sdp || data.message.sdpU,
|
|
2768
2773
|
type: data.message.type,
|
|
2769
2774
|
};
|
|
2775
|
+
if ("isInitialOffer" in data.message &&
|
|
2776
|
+
data.message.isInitialOffer === false &&
|
|
2777
|
+
session.pc.connectionState === "new" &&
|
|
2778
|
+
session.pc.iceConnectionState === "new" &&
|
|
2779
|
+
!session.connectionStatus) {
|
|
2780
|
+
logger$6.info("We have asked for an initial offer, ignoring all others");
|
|
2781
|
+
this.analytics.P2POffendingInitialOffer++;
|
|
2782
|
+
rtcStats.sendEvent("P2POffendingInitialOffer", { clientId: session.clientId });
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2770
2785
|
(_b = (_a = session
|
|
2771
2786
|
.handleOffer(sdp)
|
|
2772
2787
|
.then((answer) => {
|
|
@@ -2780,6 +2795,7 @@ class P2pRtcManager {
|
|
|
2780
2795
|
}),
|
|
2781
2796
|
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
|
|
2782
2797
|
var _a, _b;
|
|
2798
|
+
logger$6.info(`got offer from ${data.clientId}`);
|
|
2783
2799
|
const session = this._getSession(data.clientId);
|
|
2784
2800
|
if (!session) {
|
|
2785
2801
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
@@ -2973,6 +2989,7 @@ class P2pRtcManager {
|
|
|
2973
2989
|
};
|
|
2974
2990
|
pc.oniceconnectionstatechange = () => {
|
|
2975
2991
|
var _a;
|
|
2992
|
+
logger$6.info(`iceConnectionState changed to ${pc.iceConnectionState} for session ${session.clientId}`);
|
|
2976
2993
|
let newStatus;
|
|
2977
2994
|
const currentStatus = session.connectionStatus;
|
|
2978
2995
|
switch (pc.iceConnectionState) {
|
|
@@ -3002,7 +3019,7 @@ class P2pRtcManager {
|
|
|
3002
3019
|
if (pc.iceConnectionState === "disconnected") {
|
|
3003
3020
|
this._maybeRestartIce(clientId, session);
|
|
3004
3021
|
}
|
|
3005
|
-
},
|
|
3022
|
+
}, ICE_RESTART_DELAY);
|
|
3006
3023
|
break;
|
|
3007
3024
|
case "failed":
|
|
3008
3025
|
newStatus = TYPES.CONNECTION_FAILED;
|
|
@@ -3025,6 +3042,7 @@ class P2pRtcManager {
|
|
|
3025
3042
|
};
|
|
3026
3043
|
pc.onconnectionstatechange = () => {
|
|
3027
3044
|
var _a;
|
|
3045
|
+
logger$6.info(`connectionState changed to ${pc.connectionState} for session ${session.clientId}`);
|
|
3028
3046
|
switch (pc.connectionState) {
|
|
3029
3047
|
case "connected":
|
|
3030
3048
|
setTimeout(() => {
|
|
@@ -3205,7 +3223,7 @@ class P2pRtcManager {
|
|
|
3205
3223
|
initialBandwidth,
|
|
3206
3224
|
isOfferer: true,
|
|
3207
3225
|
});
|
|
3208
|
-
this._negotiatePeerConnection(clientId, session);
|
|
3226
|
+
this._negotiatePeerConnection({ clientId, session, isInitialOffer: true });
|
|
3209
3227
|
return session;
|
|
3210
3228
|
}
|
|
3211
3229
|
_maybeRestartIce(clientId, session) {
|
|
@@ -3223,7 +3241,8 @@ class P2pRtcManager {
|
|
|
3223
3241
|
session.ipv6HostCandidate6to4Seen = false;
|
|
3224
3242
|
session.mdnsHostCandidateSeen = false;
|
|
3225
3243
|
this.analytics.numIceRestart++;
|
|
3226
|
-
|
|
3244
|
+
const constraints = Object.assign(Object.assign({}, this.offerOptions), { iceRestart: true });
|
|
3245
|
+
this._negotiatePeerConnection({ clientId, session, constraints });
|
|
3227
3246
|
}
|
|
3228
3247
|
}
|
|
3229
3248
|
_setCodecPreferences(pc) {
|
|
@@ -3267,7 +3286,7 @@ class P2pRtcManager {
|
|
|
3267
3286
|
}
|
|
3268
3287
|
});
|
|
3269
3288
|
}
|
|
3270
|
-
_negotiatePeerConnection(clientId, session, constraints) {
|
|
3289
|
+
_negotiatePeerConnection({ clientId, session, constraints, isInitialOffer = false, }) {
|
|
3271
3290
|
if (!session) {
|
|
3272
3291
|
logger$6.warn("No RTCPeerConnection in negotiatePeerConnection()", clientId);
|
|
3273
3292
|
return;
|
|
@@ -3275,7 +3294,7 @@ class P2pRtcManager {
|
|
|
3275
3294
|
const pc = session.pc;
|
|
3276
3295
|
if (!session.canModifyPeerConnection()) {
|
|
3277
3296
|
session.pending.push(() => {
|
|
3278
|
-
this._negotiatePeerConnection(clientId, session, constraints);
|
|
3297
|
+
this._negotiatePeerConnection({ clientId, session, constraints, isInitialOffer });
|
|
3279
3298
|
});
|
|
3280
3299
|
return;
|
|
3281
3300
|
}
|
|
@@ -3311,6 +3330,7 @@ class P2pRtcManager {
|
|
|
3311
3330
|
sdp: offer.sdp,
|
|
3312
3331
|
sdpU: offer.sdp,
|
|
3313
3332
|
type: offer.type,
|
|
3333
|
+
isInitialOffer,
|
|
3314
3334
|
};
|
|
3315
3335
|
this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
|
|
3316
3336
|
receiverId: clientId,
|
|
@@ -3327,7 +3347,7 @@ class P2pRtcManager {
|
|
|
3327
3347
|
const originalOnnegotationneeded = pc.onnegotiationneeded;
|
|
3328
3348
|
pc.onnegotiationneeded = null;
|
|
3329
3349
|
action();
|
|
3330
|
-
this._negotiatePeerConnection(session.clientId, session);
|
|
3350
|
+
this._negotiatePeerConnection({ clientId: session.clientId, session });
|
|
3331
3351
|
setTimeout(() => (pc.onnegotiationneeded = originalOnnegotationneeded), 0);
|
|
3332
3352
|
}
|
|
3333
3353
|
_changeBandwidthForAllClients(isJoining) {
|
|
@@ -3477,7 +3497,7 @@ class P2pRtcManager {
|
|
|
3477
3497
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3478
3498
|
return;
|
|
3479
3499
|
}
|
|
3480
|
-
this._negotiatePeerConnection(clientId, session);
|
|
3500
|
+
this._negotiatePeerConnection({ clientId, session });
|
|
3481
3501
|
};
|
|
3482
3502
|
return session;
|
|
3483
3503
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1016,14 +1016,25 @@ type RtcEvents = {
|
|
|
1016
1016
|
remote_stream_track_added: void;
|
|
1017
1017
|
remote_stream_track_removed: void;
|
|
1018
1018
|
};
|
|
1019
|
-
type
|
|
1019
|
+
type SignalRTCSessionDescription = {
|
|
1020
1020
|
sdp?: string;
|
|
1021
1021
|
sdpU?: string;
|
|
1022
1022
|
type: RTCSdpType;
|
|
1023
|
+
isInitialOffer?: boolean;
|
|
1023
1024
|
};
|
|
1024
|
-
type
|
|
1025
|
+
type SignalSDPMessage = {
|
|
1026
|
+
clientId: string;
|
|
1027
|
+
message: SignalRTCSessionDescription;
|
|
1028
|
+
};
|
|
1029
|
+
type SignalIceCandidateMessage = {
|
|
1030
|
+
clientId: string;
|
|
1031
|
+
message: RTCIceCandidate;
|
|
1032
|
+
};
|
|
1033
|
+
type SignalReadyToReceiveOfferMessage = {
|
|
1034
|
+
clientId: string;
|
|
1035
|
+
};
|
|
1036
|
+
type SignalIceEndOfCandidatesMessage = {
|
|
1025
1037
|
clientId: string;
|
|
1026
|
-
message: RTCSessionDescription;
|
|
1027
1038
|
};
|
|
1028
1039
|
interface WebRTCProvider {
|
|
1029
1040
|
getMediaConstraints: () => MediaStreamConstraints;
|
|
@@ -1205,10 +1216,10 @@ declare class Session {
|
|
|
1205
1216
|
addTrack(track: MediaStreamTrack, stream?: MediaStream): void;
|
|
1206
1217
|
removeTrack(track: MediaStreamTrack): void;
|
|
1207
1218
|
removeStream(stream: MediaStream): void;
|
|
1208
|
-
_setRemoteDescription(desc:
|
|
1209
|
-
handleOffer(offer:
|
|
1210
|
-
handleAnswer(message:
|
|
1211
|
-
addIceCandidate(candidate:
|
|
1219
|
+
_setRemoteDescription(desc: SignalRTCSessionDescription): Promise<void>;
|
|
1220
|
+
handleOffer(offer: SignalRTCSessionDescription): Promise<SignalRTCSessionDescription>;
|
|
1221
|
+
handleAnswer(message: SignalRTCSessionDescription): Promise<void>;
|
|
1222
|
+
addIceCandidate(candidate: RTCIceCandidate | null): void;
|
|
1212
1223
|
canModifyPeerConnection(): boolean;
|
|
1213
1224
|
close(): void;
|
|
1214
1225
|
hasConnectedPeerConnection(): boolean;
|
|
@@ -1223,7 +1234,14 @@ interface CreateSessionOptions {
|
|
|
1223
1234
|
initialBandwidth: number;
|
|
1224
1235
|
isOfferer: boolean;
|
|
1225
1236
|
}
|
|
1237
|
+
interface NegotiatePeerConnectionOptions {
|
|
1238
|
+
clientId: string;
|
|
1239
|
+
session: Session;
|
|
1240
|
+
constraints?: RTCOfferOptions;
|
|
1241
|
+
isInitialOffer?: boolean;
|
|
1242
|
+
}
|
|
1226
1243
|
type P2PAnalytics = {
|
|
1244
|
+
P2POffendingInitialOffer: number;
|
|
1227
1245
|
P2PNonErrorRejectionValueGUMError: number;
|
|
1228
1246
|
numNewPc: number;
|
|
1229
1247
|
numIceConnected: number;
|
|
@@ -1340,7 +1358,7 @@ declare class P2pRtcManager implements RtcManager {
|
|
|
1340
1358
|
_connect(clientId: string): Session;
|
|
1341
1359
|
_maybeRestartIce(clientId: string, session: any): void;
|
|
1342
1360
|
_setCodecPreferences(pc: RTCPeerConnection): Promise<void>;
|
|
1343
|
-
_negotiatePeerConnection(clientId
|
|
1361
|
+
_negotiatePeerConnection({ clientId, session, constraints, isInitialOffer, }: NegotiatePeerConnectionOptions): void;
|
|
1344
1362
|
_withForcedRenegotiation(session: Session, action: any): void;
|
|
1345
1363
|
_changeBandwidthForAllClients(isJoining: boolean): number;
|
|
1346
1364
|
_createP2pSession({ clientId, initialBandwidth, isOfferer, }: {
|
|
@@ -1918,4 +1936,4 @@ declare const STREAM_TYPES: {
|
|
|
1918
1936
|
};
|
|
1919
1937
|
|
|
1920
1938
|
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 };
|
|
1921
|
-
export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError,
|
|
1939
|
+
export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomFullError, 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, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
|
package/dist/index.d.mts
CHANGED
|
@@ -1016,14 +1016,25 @@ type RtcEvents = {
|
|
|
1016
1016
|
remote_stream_track_added: void;
|
|
1017
1017
|
remote_stream_track_removed: void;
|
|
1018
1018
|
};
|
|
1019
|
-
type
|
|
1019
|
+
type SignalRTCSessionDescription = {
|
|
1020
1020
|
sdp?: string;
|
|
1021
1021
|
sdpU?: string;
|
|
1022
1022
|
type: RTCSdpType;
|
|
1023
|
+
isInitialOffer?: boolean;
|
|
1023
1024
|
};
|
|
1024
|
-
type
|
|
1025
|
+
type SignalSDPMessage = {
|
|
1026
|
+
clientId: string;
|
|
1027
|
+
message: SignalRTCSessionDescription;
|
|
1028
|
+
};
|
|
1029
|
+
type SignalIceCandidateMessage = {
|
|
1030
|
+
clientId: string;
|
|
1031
|
+
message: RTCIceCandidate;
|
|
1032
|
+
};
|
|
1033
|
+
type SignalReadyToReceiveOfferMessage = {
|
|
1034
|
+
clientId: string;
|
|
1035
|
+
};
|
|
1036
|
+
type SignalIceEndOfCandidatesMessage = {
|
|
1025
1037
|
clientId: string;
|
|
1026
|
-
message: RTCSessionDescription;
|
|
1027
1038
|
};
|
|
1028
1039
|
interface WebRTCProvider {
|
|
1029
1040
|
getMediaConstraints: () => MediaStreamConstraints;
|
|
@@ -1205,10 +1216,10 @@ declare class Session {
|
|
|
1205
1216
|
addTrack(track: MediaStreamTrack, stream?: MediaStream): void;
|
|
1206
1217
|
removeTrack(track: MediaStreamTrack): void;
|
|
1207
1218
|
removeStream(stream: MediaStream): void;
|
|
1208
|
-
_setRemoteDescription(desc:
|
|
1209
|
-
handleOffer(offer:
|
|
1210
|
-
handleAnswer(message:
|
|
1211
|
-
addIceCandidate(candidate:
|
|
1219
|
+
_setRemoteDescription(desc: SignalRTCSessionDescription): Promise<void>;
|
|
1220
|
+
handleOffer(offer: SignalRTCSessionDescription): Promise<SignalRTCSessionDescription>;
|
|
1221
|
+
handleAnswer(message: SignalRTCSessionDescription): Promise<void>;
|
|
1222
|
+
addIceCandidate(candidate: RTCIceCandidate | null): void;
|
|
1212
1223
|
canModifyPeerConnection(): boolean;
|
|
1213
1224
|
close(): void;
|
|
1214
1225
|
hasConnectedPeerConnection(): boolean;
|
|
@@ -1223,7 +1234,14 @@ interface CreateSessionOptions {
|
|
|
1223
1234
|
initialBandwidth: number;
|
|
1224
1235
|
isOfferer: boolean;
|
|
1225
1236
|
}
|
|
1237
|
+
interface NegotiatePeerConnectionOptions {
|
|
1238
|
+
clientId: string;
|
|
1239
|
+
session: Session;
|
|
1240
|
+
constraints?: RTCOfferOptions;
|
|
1241
|
+
isInitialOffer?: boolean;
|
|
1242
|
+
}
|
|
1226
1243
|
type P2PAnalytics = {
|
|
1244
|
+
P2POffendingInitialOffer: number;
|
|
1227
1245
|
P2PNonErrorRejectionValueGUMError: number;
|
|
1228
1246
|
numNewPc: number;
|
|
1229
1247
|
numIceConnected: number;
|
|
@@ -1340,7 +1358,7 @@ declare class P2pRtcManager implements RtcManager {
|
|
|
1340
1358
|
_connect(clientId: string): Session;
|
|
1341
1359
|
_maybeRestartIce(clientId: string, session: any): void;
|
|
1342
1360
|
_setCodecPreferences(pc: RTCPeerConnection): Promise<void>;
|
|
1343
|
-
_negotiatePeerConnection(clientId
|
|
1361
|
+
_negotiatePeerConnection({ clientId, session, constraints, isInitialOffer, }: NegotiatePeerConnectionOptions): void;
|
|
1344
1362
|
_withForcedRenegotiation(session: Session, action: any): void;
|
|
1345
1363
|
_changeBandwidthForAllClients(isJoining: boolean): number;
|
|
1346
1364
|
_createP2pSession({ clientId, initialBandwidth, isOfferer, }: {
|
|
@@ -1918,4 +1936,4 @@ declare const STREAM_TYPES: {
|
|
|
1918
1936
|
};
|
|
1919
1937
|
|
|
1920
1938
|
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 };
|
|
1921
|
-
export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError,
|
|
1939
|
+
export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomFullError, 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, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -1016,14 +1016,25 @@ type RtcEvents = {
|
|
|
1016
1016
|
remote_stream_track_added: void;
|
|
1017
1017
|
remote_stream_track_removed: void;
|
|
1018
1018
|
};
|
|
1019
|
-
type
|
|
1019
|
+
type SignalRTCSessionDescription = {
|
|
1020
1020
|
sdp?: string;
|
|
1021
1021
|
sdpU?: string;
|
|
1022
1022
|
type: RTCSdpType;
|
|
1023
|
+
isInitialOffer?: boolean;
|
|
1023
1024
|
};
|
|
1024
|
-
type
|
|
1025
|
+
type SignalSDPMessage = {
|
|
1026
|
+
clientId: string;
|
|
1027
|
+
message: SignalRTCSessionDescription;
|
|
1028
|
+
};
|
|
1029
|
+
type SignalIceCandidateMessage = {
|
|
1030
|
+
clientId: string;
|
|
1031
|
+
message: RTCIceCandidate;
|
|
1032
|
+
};
|
|
1033
|
+
type SignalReadyToReceiveOfferMessage = {
|
|
1034
|
+
clientId: string;
|
|
1035
|
+
};
|
|
1036
|
+
type SignalIceEndOfCandidatesMessage = {
|
|
1025
1037
|
clientId: string;
|
|
1026
|
-
message: RTCSessionDescription;
|
|
1027
1038
|
};
|
|
1028
1039
|
interface WebRTCProvider {
|
|
1029
1040
|
getMediaConstraints: () => MediaStreamConstraints;
|
|
@@ -1205,10 +1216,10 @@ declare class Session {
|
|
|
1205
1216
|
addTrack(track: MediaStreamTrack, stream?: MediaStream): void;
|
|
1206
1217
|
removeTrack(track: MediaStreamTrack): void;
|
|
1207
1218
|
removeStream(stream: MediaStream): void;
|
|
1208
|
-
_setRemoteDescription(desc:
|
|
1209
|
-
handleOffer(offer:
|
|
1210
|
-
handleAnswer(message:
|
|
1211
|
-
addIceCandidate(candidate:
|
|
1219
|
+
_setRemoteDescription(desc: SignalRTCSessionDescription): Promise<void>;
|
|
1220
|
+
handleOffer(offer: SignalRTCSessionDescription): Promise<SignalRTCSessionDescription>;
|
|
1221
|
+
handleAnswer(message: SignalRTCSessionDescription): Promise<void>;
|
|
1222
|
+
addIceCandidate(candidate: RTCIceCandidate | null): void;
|
|
1212
1223
|
canModifyPeerConnection(): boolean;
|
|
1213
1224
|
close(): void;
|
|
1214
1225
|
hasConnectedPeerConnection(): boolean;
|
|
@@ -1223,7 +1234,14 @@ interface CreateSessionOptions {
|
|
|
1223
1234
|
initialBandwidth: number;
|
|
1224
1235
|
isOfferer: boolean;
|
|
1225
1236
|
}
|
|
1237
|
+
interface NegotiatePeerConnectionOptions {
|
|
1238
|
+
clientId: string;
|
|
1239
|
+
session: Session;
|
|
1240
|
+
constraints?: RTCOfferOptions;
|
|
1241
|
+
isInitialOffer?: boolean;
|
|
1242
|
+
}
|
|
1226
1243
|
type P2PAnalytics = {
|
|
1244
|
+
P2POffendingInitialOffer: number;
|
|
1227
1245
|
P2PNonErrorRejectionValueGUMError: number;
|
|
1228
1246
|
numNewPc: number;
|
|
1229
1247
|
numIceConnected: number;
|
|
@@ -1340,7 +1358,7 @@ declare class P2pRtcManager implements RtcManager {
|
|
|
1340
1358
|
_connect(clientId: string): Session;
|
|
1341
1359
|
_maybeRestartIce(clientId: string, session: any): void;
|
|
1342
1360
|
_setCodecPreferences(pc: RTCPeerConnection): Promise<void>;
|
|
1343
|
-
_negotiatePeerConnection(clientId
|
|
1361
|
+
_negotiatePeerConnection({ clientId, session, constraints, isInitialOffer, }: NegotiatePeerConnectionOptions): void;
|
|
1344
1362
|
_withForcedRenegotiation(session: Session, action: any): void;
|
|
1345
1363
|
_changeBandwidthForAllClients(isJoining: boolean): number;
|
|
1346
1364
|
_createP2pSession({ clientId, initialBandwidth, isOfferer, }: {
|
|
@@ -1918,4 +1936,4 @@ declare const STREAM_TYPES: {
|
|
|
1918
1936
|
};
|
|
1919
1937
|
|
|
1920
1938
|
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 };
|
|
1921
|
-
export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError,
|
|
1939
|
+
export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, ForbiddenError, ForbiddenErrorNames, GetConstraintsOptions, GetDeviceDataResult, GetMediaConstraintsOptions, GetStreamOptions, GetStreamResult, GetUpdatedDevicesResult, HostPresenceControlsError, IdentifyDeviceRequest, InternalServerError, InvalidAssistantKeyError, IssuesAndMetricsByView, JoinRoomRequest, KnockAcceptedEvent, KnockRejectedEvent, KnockRoomRequest, KnockerLeftEvent, LiveTranscriptionStartedEvent, LiveTranscriptionStoppedEvent, MaxViewerLimitReachedError, Metric, NewClientEvent, OrganizationAssistantNotEnabledError, OrganizationAssistantNotFoundError, OrganizationPlanExhaustedError, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomFullError, 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, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
|
package/dist/index.mjs
CHANGED
|
@@ -2551,6 +2551,7 @@ var _a$2, _b$1;
|
|
|
2551
2551
|
const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
|
|
2552
2552
|
const logger$6 = new Logger();
|
|
2553
2553
|
const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
|
|
2554
|
+
const ICE_RESTART_DELAY = 2 * 1000;
|
|
2554
2555
|
const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
|
|
2555
2556
|
const browserVersion = adapter$2.browserDetails.version;
|
|
2556
2557
|
let unloading$1 = false;
|
|
@@ -2595,6 +2596,7 @@ class P2pRtcManager {
|
|
|
2595
2596
|
mediaserverConfigTtlSeconds,
|
|
2596
2597
|
});
|
|
2597
2598
|
this.analytics = {
|
|
2599
|
+
P2POffendingInitialOffer: 0,
|
|
2598
2600
|
P2PNonErrorRejectionValueGUMError: 0,
|
|
2599
2601
|
numNewPc: 0,
|
|
2600
2602
|
numIceConnected: 0,
|
|
@@ -2717,6 +2719,7 @@ class P2pRtcManager {
|
|
|
2717
2719
|
this._updateAndScheduleMediaServersRefresh(data);
|
|
2718
2720
|
}),
|
|
2719
2721
|
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
|
|
2722
|
+
logger$6.info(`got ready_to_receive_offer from ${data.clientId}`);
|
|
2720
2723
|
this._connect(data.clientId);
|
|
2721
2724
|
}),
|
|
2722
2725
|
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
|
|
@@ -2728,6 +2731,7 @@ class P2pRtcManager {
|
|
|
2728
2731
|
session.addIceCandidate(data.message);
|
|
2729
2732
|
}),
|
|
2730
2733
|
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
|
|
2734
|
+
logger$6.info(`got end_of_ice_candidates from ${data.clientId}`);
|
|
2731
2735
|
const session = this._getSession(data.clientId);
|
|
2732
2736
|
if (!session) {
|
|
2733
2737
|
logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
|
|
@@ -2737,6 +2741,7 @@ class P2pRtcManager {
|
|
|
2737
2741
|
}),
|
|
2738
2742
|
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
|
|
2739
2743
|
var _a, _b;
|
|
2744
|
+
logger$6.info(`got offer from ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
|
|
2740
2745
|
const session = this._getSession(data.clientId);
|
|
2741
2746
|
if (!session) {
|
|
2742
2747
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
@@ -2746,6 +2751,16 @@ class P2pRtcManager {
|
|
|
2746
2751
|
sdp: data.message.sdp || data.message.sdpU,
|
|
2747
2752
|
type: data.message.type,
|
|
2748
2753
|
};
|
|
2754
|
+
if ("isInitialOffer" in data.message &&
|
|
2755
|
+
data.message.isInitialOffer === false &&
|
|
2756
|
+
session.pc.connectionState === "new" &&
|
|
2757
|
+
session.pc.iceConnectionState === "new" &&
|
|
2758
|
+
!session.connectionStatus) {
|
|
2759
|
+
logger$6.info("We have asked for an initial offer, ignoring all others");
|
|
2760
|
+
this.analytics.P2POffendingInitialOffer++;
|
|
2761
|
+
rtcStats.sendEvent("P2POffendingInitialOffer", { clientId: session.clientId });
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2749
2764
|
(_b = (_a = session
|
|
2750
2765
|
.handleOffer(sdp)
|
|
2751
2766
|
.then((answer) => {
|
|
@@ -2759,6 +2774,7 @@ class P2pRtcManager {
|
|
|
2759
2774
|
}),
|
|
2760
2775
|
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
|
|
2761
2776
|
var _a, _b;
|
|
2777
|
+
logger$6.info(`got offer from ${data.clientId}`);
|
|
2762
2778
|
const session = this._getSession(data.clientId);
|
|
2763
2779
|
if (!session) {
|
|
2764
2780
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
@@ -2952,6 +2968,7 @@ class P2pRtcManager {
|
|
|
2952
2968
|
};
|
|
2953
2969
|
pc.oniceconnectionstatechange = () => {
|
|
2954
2970
|
var _a;
|
|
2971
|
+
logger$6.info(`iceConnectionState changed to ${pc.iceConnectionState} for session ${session.clientId}`);
|
|
2955
2972
|
let newStatus;
|
|
2956
2973
|
const currentStatus = session.connectionStatus;
|
|
2957
2974
|
switch (pc.iceConnectionState) {
|
|
@@ -2981,7 +2998,7 @@ class P2pRtcManager {
|
|
|
2981
2998
|
if (pc.iceConnectionState === "disconnected") {
|
|
2982
2999
|
this._maybeRestartIce(clientId, session);
|
|
2983
3000
|
}
|
|
2984
|
-
},
|
|
3001
|
+
}, ICE_RESTART_DELAY);
|
|
2985
3002
|
break;
|
|
2986
3003
|
case "failed":
|
|
2987
3004
|
newStatus = TYPES.CONNECTION_FAILED;
|
|
@@ -3004,6 +3021,7 @@ class P2pRtcManager {
|
|
|
3004
3021
|
};
|
|
3005
3022
|
pc.onconnectionstatechange = () => {
|
|
3006
3023
|
var _a;
|
|
3024
|
+
logger$6.info(`connectionState changed to ${pc.connectionState} for session ${session.clientId}`);
|
|
3007
3025
|
switch (pc.connectionState) {
|
|
3008
3026
|
case "connected":
|
|
3009
3027
|
setTimeout(() => {
|
|
@@ -3184,7 +3202,7 @@ class P2pRtcManager {
|
|
|
3184
3202
|
initialBandwidth,
|
|
3185
3203
|
isOfferer: true,
|
|
3186
3204
|
});
|
|
3187
|
-
this._negotiatePeerConnection(clientId, session);
|
|
3205
|
+
this._negotiatePeerConnection({ clientId, session, isInitialOffer: true });
|
|
3188
3206
|
return session;
|
|
3189
3207
|
}
|
|
3190
3208
|
_maybeRestartIce(clientId, session) {
|
|
@@ -3202,7 +3220,8 @@ class P2pRtcManager {
|
|
|
3202
3220
|
session.ipv6HostCandidate6to4Seen = false;
|
|
3203
3221
|
session.mdnsHostCandidateSeen = false;
|
|
3204
3222
|
this.analytics.numIceRestart++;
|
|
3205
|
-
|
|
3223
|
+
const constraints = Object.assign(Object.assign({}, this.offerOptions), { iceRestart: true });
|
|
3224
|
+
this._negotiatePeerConnection({ clientId, session, constraints });
|
|
3206
3225
|
}
|
|
3207
3226
|
}
|
|
3208
3227
|
_setCodecPreferences(pc) {
|
|
@@ -3246,7 +3265,7 @@ class P2pRtcManager {
|
|
|
3246
3265
|
}
|
|
3247
3266
|
});
|
|
3248
3267
|
}
|
|
3249
|
-
_negotiatePeerConnection(clientId, session, constraints) {
|
|
3268
|
+
_negotiatePeerConnection({ clientId, session, constraints, isInitialOffer = false, }) {
|
|
3250
3269
|
if (!session) {
|
|
3251
3270
|
logger$6.warn("No RTCPeerConnection in negotiatePeerConnection()", clientId);
|
|
3252
3271
|
return;
|
|
@@ -3254,7 +3273,7 @@ class P2pRtcManager {
|
|
|
3254
3273
|
const pc = session.pc;
|
|
3255
3274
|
if (!session.canModifyPeerConnection()) {
|
|
3256
3275
|
session.pending.push(() => {
|
|
3257
|
-
this._negotiatePeerConnection(clientId, session, constraints);
|
|
3276
|
+
this._negotiatePeerConnection({ clientId, session, constraints, isInitialOffer });
|
|
3258
3277
|
});
|
|
3259
3278
|
return;
|
|
3260
3279
|
}
|
|
@@ -3290,6 +3309,7 @@ class P2pRtcManager {
|
|
|
3290
3309
|
sdp: offer.sdp,
|
|
3291
3310
|
sdpU: offer.sdp,
|
|
3292
3311
|
type: offer.type,
|
|
3312
|
+
isInitialOffer,
|
|
3293
3313
|
};
|
|
3294
3314
|
this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
|
|
3295
3315
|
receiverId: clientId,
|
|
@@ -3306,7 +3326,7 @@ class P2pRtcManager {
|
|
|
3306
3326
|
const originalOnnegotationneeded = pc.onnegotiationneeded;
|
|
3307
3327
|
pc.onnegotiationneeded = null;
|
|
3308
3328
|
action();
|
|
3309
|
-
this._negotiatePeerConnection(session.clientId, session);
|
|
3329
|
+
this._negotiatePeerConnection({ clientId: session.clientId, session });
|
|
3310
3330
|
setTimeout(() => (pc.onnegotiationneeded = originalOnnegotationneeded), 0);
|
|
3311
3331
|
}
|
|
3312
3332
|
_changeBandwidthForAllClients(isJoining) {
|
|
@@ -3456,7 +3476,7 @@ class P2pRtcManager {
|
|
|
3456
3476
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3457
3477
|
return;
|
|
3458
3478
|
}
|
|
3459
|
-
this._negotiatePeerConnection(clientId, session);
|
|
3479
|
+
this._negotiatePeerConnection({ clientId, session });
|
|
3460
3480
|
};
|
|
3461
3481
|
return session;
|
|
3462
3482
|
}
|
package/dist/legacy-esm.js
CHANGED
|
@@ -2551,6 +2551,7 @@ var _a$2, _b$1;
|
|
|
2551
2551
|
const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
|
|
2552
2552
|
const logger$6 = new Logger();
|
|
2553
2553
|
const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
|
|
2554
|
+
const ICE_RESTART_DELAY = 2 * 1000;
|
|
2554
2555
|
const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
|
|
2555
2556
|
const browserVersion = adapter$2.browserDetails.version;
|
|
2556
2557
|
let unloading$1 = false;
|
|
@@ -2595,6 +2596,7 @@ class P2pRtcManager {
|
|
|
2595
2596
|
mediaserverConfigTtlSeconds,
|
|
2596
2597
|
});
|
|
2597
2598
|
this.analytics = {
|
|
2599
|
+
P2POffendingInitialOffer: 0,
|
|
2598
2600
|
P2PNonErrorRejectionValueGUMError: 0,
|
|
2599
2601
|
numNewPc: 0,
|
|
2600
2602
|
numIceConnected: 0,
|
|
@@ -2717,6 +2719,7 @@ class P2pRtcManager {
|
|
|
2717
2719
|
this._updateAndScheduleMediaServersRefresh(data);
|
|
2718
2720
|
}),
|
|
2719
2721
|
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
|
|
2722
|
+
logger$6.info(`got ready_to_receive_offer from ${data.clientId}`);
|
|
2720
2723
|
this._connect(data.clientId);
|
|
2721
2724
|
}),
|
|
2722
2725
|
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
|
|
@@ -2728,6 +2731,7 @@ class P2pRtcManager {
|
|
|
2728
2731
|
session.addIceCandidate(data.message);
|
|
2729
2732
|
}),
|
|
2730
2733
|
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
|
|
2734
|
+
logger$6.info(`got end_of_ice_candidates from ${data.clientId}`);
|
|
2731
2735
|
const session = this._getSession(data.clientId);
|
|
2732
2736
|
if (!session) {
|
|
2733
2737
|
logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
|
|
@@ -2737,6 +2741,7 @@ class P2pRtcManager {
|
|
|
2737
2741
|
}),
|
|
2738
2742
|
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
|
|
2739
2743
|
var _a, _b;
|
|
2744
|
+
logger$6.info(`got offer from ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
|
|
2740
2745
|
const session = this._getSession(data.clientId);
|
|
2741
2746
|
if (!session) {
|
|
2742
2747
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
@@ -2746,6 +2751,16 @@ class P2pRtcManager {
|
|
|
2746
2751
|
sdp: data.message.sdp || data.message.sdpU,
|
|
2747
2752
|
type: data.message.type,
|
|
2748
2753
|
};
|
|
2754
|
+
if ("isInitialOffer" in data.message &&
|
|
2755
|
+
data.message.isInitialOffer === false &&
|
|
2756
|
+
session.pc.connectionState === "new" &&
|
|
2757
|
+
session.pc.iceConnectionState === "new" &&
|
|
2758
|
+
!session.connectionStatus) {
|
|
2759
|
+
logger$6.info("We have asked for an initial offer, ignoring all others");
|
|
2760
|
+
this.analytics.P2POffendingInitialOffer++;
|
|
2761
|
+
rtcStats.sendEvent("P2POffendingInitialOffer", { clientId: session.clientId });
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2749
2764
|
(_b = (_a = session
|
|
2750
2765
|
.handleOffer(sdp)
|
|
2751
2766
|
.then((answer) => {
|
|
@@ -2759,6 +2774,7 @@ class P2pRtcManager {
|
|
|
2759
2774
|
}),
|
|
2760
2775
|
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
|
|
2761
2776
|
var _a, _b;
|
|
2777
|
+
logger$6.info(`got offer from ${data.clientId}`);
|
|
2762
2778
|
const session = this._getSession(data.clientId);
|
|
2763
2779
|
if (!session) {
|
|
2764
2780
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
@@ -2952,6 +2968,7 @@ class P2pRtcManager {
|
|
|
2952
2968
|
};
|
|
2953
2969
|
pc.oniceconnectionstatechange = () => {
|
|
2954
2970
|
var _a;
|
|
2971
|
+
logger$6.info(`iceConnectionState changed to ${pc.iceConnectionState} for session ${session.clientId}`);
|
|
2955
2972
|
let newStatus;
|
|
2956
2973
|
const currentStatus = session.connectionStatus;
|
|
2957
2974
|
switch (pc.iceConnectionState) {
|
|
@@ -2981,7 +2998,7 @@ class P2pRtcManager {
|
|
|
2981
2998
|
if (pc.iceConnectionState === "disconnected") {
|
|
2982
2999
|
this._maybeRestartIce(clientId, session);
|
|
2983
3000
|
}
|
|
2984
|
-
},
|
|
3001
|
+
}, ICE_RESTART_DELAY);
|
|
2985
3002
|
break;
|
|
2986
3003
|
case "failed":
|
|
2987
3004
|
newStatus = TYPES.CONNECTION_FAILED;
|
|
@@ -3004,6 +3021,7 @@ class P2pRtcManager {
|
|
|
3004
3021
|
};
|
|
3005
3022
|
pc.onconnectionstatechange = () => {
|
|
3006
3023
|
var _a;
|
|
3024
|
+
logger$6.info(`connectionState changed to ${pc.connectionState} for session ${session.clientId}`);
|
|
3007
3025
|
switch (pc.connectionState) {
|
|
3008
3026
|
case "connected":
|
|
3009
3027
|
setTimeout(() => {
|
|
@@ -3184,7 +3202,7 @@ class P2pRtcManager {
|
|
|
3184
3202
|
initialBandwidth,
|
|
3185
3203
|
isOfferer: true,
|
|
3186
3204
|
});
|
|
3187
|
-
this._negotiatePeerConnection(clientId, session);
|
|
3205
|
+
this._negotiatePeerConnection({ clientId, session, isInitialOffer: true });
|
|
3188
3206
|
return session;
|
|
3189
3207
|
}
|
|
3190
3208
|
_maybeRestartIce(clientId, session) {
|
|
@@ -3202,7 +3220,8 @@ class P2pRtcManager {
|
|
|
3202
3220
|
session.ipv6HostCandidate6to4Seen = false;
|
|
3203
3221
|
session.mdnsHostCandidateSeen = false;
|
|
3204
3222
|
this.analytics.numIceRestart++;
|
|
3205
|
-
|
|
3223
|
+
const constraints = Object.assign(Object.assign({}, this.offerOptions), { iceRestart: true });
|
|
3224
|
+
this._negotiatePeerConnection({ clientId, session, constraints });
|
|
3206
3225
|
}
|
|
3207
3226
|
}
|
|
3208
3227
|
_setCodecPreferences(pc) {
|
|
@@ -3246,7 +3265,7 @@ class P2pRtcManager {
|
|
|
3246
3265
|
}
|
|
3247
3266
|
});
|
|
3248
3267
|
}
|
|
3249
|
-
_negotiatePeerConnection(clientId, session, constraints) {
|
|
3268
|
+
_negotiatePeerConnection({ clientId, session, constraints, isInitialOffer = false, }) {
|
|
3250
3269
|
if (!session) {
|
|
3251
3270
|
logger$6.warn("No RTCPeerConnection in negotiatePeerConnection()", clientId);
|
|
3252
3271
|
return;
|
|
@@ -3254,7 +3273,7 @@ class P2pRtcManager {
|
|
|
3254
3273
|
const pc = session.pc;
|
|
3255
3274
|
if (!session.canModifyPeerConnection()) {
|
|
3256
3275
|
session.pending.push(() => {
|
|
3257
|
-
this._negotiatePeerConnection(clientId, session, constraints);
|
|
3276
|
+
this._negotiatePeerConnection({ clientId, session, constraints, isInitialOffer });
|
|
3258
3277
|
});
|
|
3259
3278
|
return;
|
|
3260
3279
|
}
|
|
@@ -3290,6 +3309,7 @@ class P2pRtcManager {
|
|
|
3290
3309
|
sdp: offer.sdp,
|
|
3291
3310
|
sdpU: offer.sdp,
|
|
3292
3311
|
type: offer.type,
|
|
3312
|
+
isInitialOffer,
|
|
3293
3313
|
};
|
|
3294
3314
|
this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
|
|
3295
3315
|
receiverId: clientId,
|
|
@@ -3306,7 +3326,7 @@ class P2pRtcManager {
|
|
|
3306
3326
|
const originalOnnegotationneeded = pc.onnegotiationneeded;
|
|
3307
3327
|
pc.onnegotiationneeded = null;
|
|
3308
3328
|
action();
|
|
3309
|
-
this._negotiatePeerConnection(session.clientId, session);
|
|
3329
|
+
this._negotiatePeerConnection({ clientId: session.clientId, session });
|
|
3310
3330
|
setTimeout(() => (pc.onnegotiationneeded = originalOnnegotationneeded), 0);
|
|
3311
3331
|
}
|
|
3312
3332
|
_changeBandwidthForAllClients(isJoining) {
|
|
@@ -3456,7 +3476,7 @@ class P2pRtcManager {
|
|
|
3456
3476
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3457
3477
|
return;
|
|
3458
3478
|
}
|
|
3459
|
-
this._negotiatePeerConnection(clientId, session);
|
|
3479
|
+
this._negotiatePeerConnection({ clientId, session });
|
|
3460
3480
|
};
|
|
3461
3481
|
return session;
|
|
3462
3482
|
}
|
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": "3.
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/whereby/sdk",
|
|
7
7
|
"repository": {
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"process": "^0.11.10",
|
|
63
63
|
"typescript": "^5.8.3",
|
|
64
64
|
"@whereby.com/eslint-config": "0.1.0",
|
|
65
|
-
"@whereby.com/jest-config": "0.1.0",
|
|
66
|
-
"@whereby.com/prettier-config": "0.1.0",
|
|
67
65
|
"@whereby.com/rollup-config": "0.1.1",
|
|
68
|
-
"@whereby.com/tsconfig": "0.1.0"
|
|
66
|
+
"@whereby.com/tsconfig": "0.1.0",
|
|
67
|
+
"@whereby.com/jest-config": "0.1.0",
|
|
68
|
+
"@whereby.com/prettier-config": "0.1.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=16.0.0"
|