@whereby.com/media 2.9.2 → 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 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,
@@ -2654,9 +2656,6 @@ class P2pRtcManager {
2654
2656
  isInitializedWith({ selfId, roomName, isSfu }) {
2655
2657
  return this._selfId === selfId && this._roomName === roomName && !isSfu;
2656
2658
  }
2657
- supportsScreenShareAudio() {
2658
- return true;
2659
- }
2660
2659
  addNewStream(streamId, stream, audioPaused, videoPaused, beforeEffectTracks = []) {
2661
2660
  if (stream === this.localStreams[streamId]) {
2662
2661
  return;
@@ -2741,6 +2740,7 @@ class P2pRtcManager {
2741
2740
  this._updateAndScheduleMediaServersRefresh(data);
2742
2741
  }),
2743
2742
  this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
2743
+ logger$6.info(`got ready_to_receive_offer from ${data.clientId}`);
2744
2744
  this._connect(data.clientId);
2745
2745
  }),
2746
2746
  this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
@@ -2752,6 +2752,7 @@ class P2pRtcManager {
2752
2752
  session.addIceCandidate(data.message);
2753
2753
  }),
2754
2754
  this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
2755
+ logger$6.info(`got end_of_ice_candidates from ${data.clientId}`);
2755
2756
  const session = this._getSession(data.clientId);
2756
2757
  if (!session) {
2757
2758
  logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
@@ -2761,6 +2762,7 @@ class P2pRtcManager {
2761
2762
  }),
2762
2763
  this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
2763
2764
  var _a, _b;
2765
+ logger$6.info(`got offer from ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
2764
2766
  const session = this._getSession(data.clientId);
2765
2767
  if (!session) {
2766
2768
  logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
@@ -2770,6 +2772,16 @@ class P2pRtcManager {
2770
2772
  sdp: data.message.sdp || data.message.sdpU,
2771
2773
  type: data.message.type,
2772
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
+ }
2773
2785
  (_b = (_a = session
2774
2786
  .handleOffer(sdp)
2775
2787
  .then((answer) => {
@@ -2783,6 +2795,7 @@ class P2pRtcManager {
2783
2795
  }),
2784
2796
  this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
2785
2797
  var _a, _b;
2798
+ logger$6.info(`got offer from ${data.clientId}`);
2786
2799
  const session = this._getSession(data.clientId);
2787
2800
  if (!session) {
2788
2801
  logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
@@ -2976,6 +2989,7 @@ class P2pRtcManager {
2976
2989
  };
2977
2990
  pc.oniceconnectionstatechange = () => {
2978
2991
  var _a;
2992
+ logger$6.info(`iceConnectionState changed to ${pc.iceConnectionState} for session ${session.clientId}`);
2979
2993
  let newStatus;
2980
2994
  const currentStatus = session.connectionStatus;
2981
2995
  switch (pc.iceConnectionState) {
@@ -3005,7 +3019,7 @@ class P2pRtcManager {
3005
3019
  if (pc.iceConnectionState === "disconnected") {
3006
3020
  this._maybeRestartIce(clientId, session);
3007
3021
  }
3008
- }, 2000);
3022
+ }, ICE_RESTART_DELAY);
3009
3023
  break;
3010
3024
  case "failed":
3011
3025
  newStatus = TYPES.CONNECTION_FAILED;
@@ -3028,6 +3042,7 @@ class P2pRtcManager {
3028
3042
  };
3029
3043
  pc.onconnectionstatechange = () => {
3030
3044
  var _a;
3045
+ logger$6.info(`connectionState changed to ${pc.connectionState} for session ${session.clientId}`);
3031
3046
  switch (pc.connectionState) {
3032
3047
  case "connected":
3033
3048
  setTimeout(() => {
@@ -3208,7 +3223,7 @@ class P2pRtcManager {
3208
3223
  initialBandwidth,
3209
3224
  isOfferer: true,
3210
3225
  });
3211
- this._negotiatePeerConnection(clientId, session);
3226
+ this._negotiatePeerConnection({ clientId, session, isInitialOffer: true });
3212
3227
  return session;
3213
3228
  }
3214
3229
  _maybeRestartIce(clientId, session) {
@@ -3226,7 +3241,8 @@ class P2pRtcManager {
3226
3241
  session.ipv6HostCandidate6to4Seen = false;
3227
3242
  session.mdnsHostCandidateSeen = false;
3228
3243
  this.analytics.numIceRestart++;
3229
- this._negotiatePeerConnection(clientId, session, Object.assign({}, this.offerOptions, { iceRestart: true }));
3244
+ const constraints = Object.assign(Object.assign({}, this.offerOptions), { iceRestart: true });
3245
+ this._negotiatePeerConnection({ clientId, session, constraints });
3230
3246
  }
3231
3247
  }
3232
3248
  _setCodecPreferences(pc) {
@@ -3270,7 +3286,7 @@ class P2pRtcManager {
3270
3286
  }
3271
3287
  });
3272
3288
  }
3273
- _negotiatePeerConnection(clientId, session, constraints) {
3289
+ _negotiatePeerConnection({ clientId, session, constraints, isInitialOffer = false, }) {
3274
3290
  if (!session) {
3275
3291
  logger$6.warn("No RTCPeerConnection in negotiatePeerConnection()", clientId);
3276
3292
  return;
@@ -3278,7 +3294,7 @@ class P2pRtcManager {
3278
3294
  const pc = session.pc;
3279
3295
  if (!session.canModifyPeerConnection()) {
3280
3296
  session.pending.push(() => {
3281
- this._negotiatePeerConnection(clientId, session, constraints);
3297
+ this._negotiatePeerConnection({ clientId, session, constraints, isInitialOffer });
3282
3298
  });
3283
3299
  return;
3284
3300
  }
@@ -3314,6 +3330,7 @@ class P2pRtcManager {
3314
3330
  sdp: offer.sdp,
3315
3331
  sdpU: offer.sdp,
3316
3332
  type: offer.type,
3333
+ isInitialOffer,
3317
3334
  };
3318
3335
  this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
3319
3336
  receiverId: clientId,
@@ -3330,7 +3347,7 @@ class P2pRtcManager {
3330
3347
  const originalOnnegotationneeded = pc.onnegotiationneeded;
3331
3348
  pc.onnegotiationneeded = null;
3332
3349
  action();
3333
- this._negotiatePeerConnection(session.clientId, session);
3350
+ this._negotiatePeerConnection({ clientId: session.clientId, session });
3334
3351
  setTimeout(() => (pc.onnegotiationneeded = originalOnnegotationneeded), 0);
3335
3352
  }
3336
3353
  _changeBandwidthForAllClients(isJoining) {
@@ -3480,7 +3497,7 @@ class P2pRtcManager {
3480
3497
  if (pc.iceConnectionState === "new" || !session.connectionStatus) {
3481
3498
  return;
3482
3499
  }
3483
- this._negotiatePeerConnection(clientId, session);
3500
+ this._negotiatePeerConnection({ clientId, session });
3484
3501
  };
3485
3502
  return session;
3486
3503
  }
@@ -5539,9 +5556,6 @@ class VegaRtcManager {
5539
5556
  });
5540
5557
  }
5541
5558
  }
5542
- supportsScreenShareAudio() {
5543
- return true;
5544
- }
5545
5559
  acceptNewStream({ streamId, clientId }) {
5546
5560
  logger$2.info("acceptNewStream()", { streamId, clientId });
5547
5561
  const clientState = this._getOrCreateClientState(clientId);
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 RTCSessionDescription = {
1019
+ type SignalRTCSessionDescription = {
1020
1020
  sdp?: string;
1021
1021
  sdpU?: string;
1022
1022
  type: RTCSdpType;
1023
+ isInitialOffer?: boolean;
1023
1024
  };
1024
- type SDPRelayMessage = {
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: RTCSessionDescription): Promise<void>;
1209
- handleOffer(offer: RTCSessionDescription): Promise<RTCSessionDescription>;
1210
- handleAnswer(message: RTCSessionDescription): Promise<void>;
1211
- addIceCandidate(candidate: any): void;
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;
@@ -1298,7 +1316,6 @@ declare class P2pRtcManager implements RtcManager {
1298
1316
  roomName: string;
1299
1317
  isSfu: boolean;
1300
1318
  }): boolean;
1301
- supportsScreenShareAudio(): boolean;
1302
1319
  addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: MediaStreamTrack[]): void;
1303
1320
  replaceTrack(oldTrack: MediaStreamTrack | null, newTrack: MediaStreamTrack): Promise<void | any[]>;
1304
1321
  close(): void;
@@ -1341,7 +1358,7 @@ declare class P2pRtcManager implements RtcManager {
1341
1358
  _connect(clientId: string): Session;
1342
1359
  _maybeRestartIce(clientId: string, session: any): void;
1343
1360
  _setCodecPreferences(pc: RTCPeerConnection): Promise<void>;
1344
- _negotiatePeerConnection(clientId: string, session: Session, constraints?: any): void;
1361
+ _negotiatePeerConnection({ clientId, session, constraints, isInitialOffer, }: NegotiatePeerConnectionOptions): void;
1345
1362
  _withForcedRenegotiation(session: Session, action: any): void;
1346
1363
  _changeBandwidthForAllClients(isJoining: boolean): number;
1347
1364
  _createP2pSession({ clientId, initialBandwidth, isOfferer, }: {
@@ -1711,7 +1728,6 @@ declare class VegaRtcManager implements RtcManager {
1711
1728
  track: MediaStreamTrack;
1712
1729
  }): void;
1713
1730
  stopOrResumeVideo(localStream: MediaStream, enable: boolean): void;
1714
- supportsScreenShareAudio(): boolean;
1715
1731
  acceptNewStream({ streamId, clientId }: {
1716
1732
  streamId: string;
1717
1733
  clientId: string;
@@ -1920,4 +1936,4 @@ declare const STREAM_TYPES: {
1920
1936
  };
1921
1937
 
1922
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 };
1923
- 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, RTCSessionDescription, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomFullError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, SDPRelayMessage, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRequests, SignalRoom, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
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 RTCSessionDescription = {
1019
+ type SignalRTCSessionDescription = {
1020
1020
  sdp?: string;
1021
1021
  sdpU?: string;
1022
1022
  type: RTCSdpType;
1023
+ isInitialOffer?: boolean;
1023
1024
  };
1024
- type SDPRelayMessage = {
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: RTCSessionDescription): Promise<void>;
1209
- handleOffer(offer: RTCSessionDescription): Promise<RTCSessionDescription>;
1210
- handleAnswer(message: RTCSessionDescription): Promise<void>;
1211
- addIceCandidate(candidate: any): void;
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;
@@ -1298,7 +1316,6 @@ declare class P2pRtcManager implements RtcManager {
1298
1316
  roomName: string;
1299
1317
  isSfu: boolean;
1300
1318
  }): boolean;
1301
- supportsScreenShareAudio(): boolean;
1302
1319
  addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: MediaStreamTrack[]): void;
1303
1320
  replaceTrack(oldTrack: MediaStreamTrack | null, newTrack: MediaStreamTrack): Promise<void | any[]>;
1304
1321
  close(): void;
@@ -1341,7 +1358,7 @@ declare class P2pRtcManager implements RtcManager {
1341
1358
  _connect(clientId: string): Session;
1342
1359
  _maybeRestartIce(clientId: string, session: any): void;
1343
1360
  _setCodecPreferences(pc: RTCPeerConnection): Promise<void>;
1344
- _negotiatePeerConnection(clientId: string, session: Session, constraints?: any): void;
1361
+ _negotiatePeerConnection({ clientId, session, constraints, isInitialOffer, }: NegotiatePeerConnectionOptions): void;
1345
1362
  _withForcedRenegotiation(session: Session, action: any): void;
1346
1363
  _changeBandwidthForAllClients(isJoining: boolean): number;
1347
1364
  _createP2pSession({ clientId, initialBandwidth, isOfferer, }: {
@@ -1711,7 +1728,6 @@ declare class VegaRtcManager implements RtcManager {
1711
1728
  track: MediaStreamTrack;
1712
1729
  }): void;
1713
1730
  stopOrResumeVideo(localStream: MediaStream, enable: boolean): void;
1714
- supportsScreenShareAudio(): boolean;
1715
1731
  acceptNewStream({ streamId, clientId }: {
1716
1732
  streamId: string;
1717
1733
  clientId: string;
@@ -1920,4 +1936,4 @@ declare const STREAM_TYPES: {
1920
1936
  };
1921
1937
 
1922
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 };
1923
- 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, RTCSessionDescription, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomFullError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, SDPRelayMessage, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRequests, SignalRoom, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
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 RTCSessionDescription = {
1019
+ type SignalRTCSessionDescription = {
1020
1020
  sdp?: string;
1021
1021
  sdpU?: string;
1022
1022
  type: RTCSdpType;
1023
+ isInitialOffer?: boolean;
1023
1024
  };
1024
- type SDPRelayMessage = {
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: RTCSessionDescription): Promise<void>;
1209
- handleOffer(offer: RTCSessionDescription): Promise<RTCSessionDescription>;
1210
- handleAnswer(message: RTCSessionDescription): Promise<void>;
1211
- addIceCandidate(candidate: any): void;
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;
@@ -1298,7 +1316,6 @@ declare class P2pRtcManager implements RtcManager {
1298
1316
  roomName: string;
1299
1317
  isSfu: boolean;
1300
1318
  }): boolean;
1301
- supportsScreenShareAudio(): boolean;
1302
1319
  addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: MediaStreamTrack[]): void;
1303
1320
  replaceTrack(oldTrack: MediaStreamTrack | null, newTrack: MediaStreamTrack): Promise<void | any[]>;
1304
1321
  close(): void;
@@ -1341,7 +1358,7 @@ declare class P2pRtcManager implements RtcManager {
1341
1358
  _connect(clientId: string): Session;
1342
1359
  _maybeRestartIce(clientId: string, session: any): void;
1343
1360
  _setCodecPreferences(pc: RTCPeerConnection): Promise<void>;
1344
- _negotiatePeerConnection(clientId: string, session: Session, constraints?: any): void;
1361
+ _negotiatePeerConnection({ clientId, session, constraints, isInitialOffer, }: NegotiatePeerConnectionOptions): void;
1345
1362
  _withForcedRenegotiation(session: Session, action: any): void;
1346
1363
  _changeBandwidthForAllClients(isJoining: boolean): number;
1347
1364
  _createP2pSession({ clientId, initialBandwidth, isOfferer, }: {
@@ -1711,7 +1728,6 @@ declare class VegaRtcManager implements RtcManager {
1711
1728
  track: MediaStreamTrack;
1712
1729
  }): void;
1713
1730
  stopOrResumeVideo(localStream: MediaStream, enable: boolean): void;
1714
- supportsScreenShareAudio(): boolean;
1715
1731
  acceptNewStream({ streamId, clientId }: {
1716
1732
  streamId: string;
1717
1733
  clientId: string;
@@ -1920,4 +1936,4 @@ declare const STREAM_TYPES: {
1920
1936
  };
1921
1937
 
1922
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 };
1923
- 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, RTCSessionDescription, RemoveSpotlightRequest, RoleName, RoomConcurrencyControlsError, RoomFullError, RoomJoinedErrors, RoomJoinedEvent, RoomJoinedSuccess, RoomKnockedEvent, RoomLockedError, RoomLockedEvent, RoomMeetingTimeExhaustedError, RoomMode, RoomSessionEndedEvent, RtcClientConnectionStatusChangedPayload, RtcEventEmitter, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcManagerOptions, RtcStreamAddedPayload, SDPRelayMessage, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalIceServer, SignalKnocker, SignalMediaServerConfig, SignalRequests, SignalRoom, SignalSFUServer, SignalTurnServer, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UpdatedDeviceInfo, UpdatedDevicesInfo, VegaRtcManagerOptions, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent, WebRTCProvider };
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,
@@ -2633,9 +2635,6 @@ class P2pRtcManager {
2633
2635
  isInitializedWith({ selfId, roomName, isSfu }) {
2634
2636
  return this._selfId === selfId && this._roomName === roomName && !isSfu;
2635
2637
  }
2636
- supportsScreenShareAudio() {
2637
- return true;
2638
- }
2639
2638
  addNewStream(streamId, stream, audioPaused, videoPaused, beforeEffectTracks = []) {
2640
2639
  if (stream === this.localStreams[streamId]) {
2641
2640
  return;
@@ -2720,6 +2719,7 @@ class P2pRtcManager {
2720
2719
  this._updateAndScheduleMediaServersRefresh(data);
2721
2720
  }),
2722
2721
  this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
2722
+ logger$6.info(`got ready_to_receive_offer from ${data.clientId}`);
2723
2723
  this._connect(data.clientId);
2724
2724
  }),
2725
2725
  this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
@@ -2731,6 +2731,7 @@ class P2pRtcManager {
2731
2731
  session.addIceCandidate(data.message);
2732
2732
  }),
2733
2733
  this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
2734
+ logger$6.info(`got end_of_ice_candidates from ${data.clientId}`);
2734
2735
  const session = this._getSession(data.clientId);
2735
2736
  if (!session) {
2736
2737
  logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
@@ -2740,6 +2741,7 @@ class P2pRtcManager {
2740
2741
  }),
2741
2742
  this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
2742
2743
  var _a, _b;
2744
+ logger$6.info(`got offer from ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
2743
2745
  const session = this._getSession(data.clientId);
2744
2746
  if (!session) {
2745
2747
  logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
@@ -2749,6 +2751,16 @@ class P2pRtcManager {
2749
2751
  sdp: data.message.sdp || data.message.sdpU,
2750
2752
  type: data.message.type,
2751
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
+ }
2752
2764
  (_b = (_a = session
2753
2765
  .handleOffer(sdp)
2754
2766
  .then((answer) => {
@@ -2762,6 +2774,7 @@ class P2pRtcManager {
2762
2774
  }),
2763
2775
  this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
2764
2776
  var _a, _b;
2777
+ logger$6.info(`got offer from ${data.clientId}`);
2765
2778
  const session = this._getSession(data.clientId);
2766
2779
  if (!session) {
2767
2780
  logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
@@ -2955,6 +2968,7 @@ class P2pRtcManager {
2955
2968
  };
2956
2969
  pc.oniceconnectionstatechange = () => {
2957
2970
  var _a;
2971
+ logger$6.info(`iceConnectionState changed to ${pc.iceConnectionState} for session ${session.clientId}`);
2958
2972
  let newStatus;
2959
2973
  const currentStatus = session.connectionStatus;
2960
2974
  switch (pc.iceConnectionState) {
@@ -2984,7 +2998,7 @@ class P2pRtcManager {
2984
2998
  if (pc.iceConnectionState === "disconnected") {
2985
2999
  this._maybeRestartIce(clientId, session);
2986
3000
  }
2987
- }, 2000);
3001
+ }, ICE_RESTART_DELAY);
2988
3002
  break;
2989
3003
  case "failed":
2990
3004
  newStatus = TYPES.CONNECTION_FAILED;
@@ -3007,6 +3021,7 @@ class P2pRtcManager {
3007
3021
  };
3008
3022
  pc.onconnectionstatechange = () => {
3009
3023
  var _a;
3024
+ logger$6.info(`connectionState changed to ${pc.connectionState} for session ${session.clientId}`);
3010
3025
  switch (pc.connectionState) {
3011
3026
  case "connected":
3012
3027
  setTimeout(() => {
@@ -3187,7 +3202,7 @@ class P2pRtcManager {
3187
3202
  initialBandwidth,
3188
3203
  isOfferer: true,
3189
3204
  });
3190
- this._negotiatePeerConnection(clientId, session);
3205
+ this._negotiatePeerConnection({ clientId, session, isInitialOffer: true });
3191
3206
  return session;
3192
3207
  }
3193
3208
  _maybeRestartIce(clientId, session) {
@@ -3205,7 +3220,8 @@ class P2pRtcManager {
3205
3220
  session.ipv6HostCandidate6to4Seen = false;
3206
3221
  session.mdnsHostCandidateSeen = false;
3207
3222
  this.analytics.numIceRestart++;
3208
- this._negotiatePeerConnection(clientId, session, Object.assign({}, this.offerOptions, { iceRestart: true }));
3223
+ const constraints = Object.assign(Object.assign({}, this.offerOptions), { iceRestart: true });
3224
+ this._negotiatePeerConnection({ clientId, session, constraints });
3209
3225
  }
3210
3226
  }
3211
3227
  _setCodecPreferences(pc) {
@@ -3249,7 +3265,7 @@ class P2pRtcManager {
3249
3265
  }
3250
3266
  });
3251
3267
  }
3252
- _negotiatePeerConnection(clientId, session, constraints) {
3268
+ _negotiatePeerConnection({ clientId, session, constraints, isInitialOffer = false, }) {
3253
3269
  if (!session) {
3254
3270
  logger$6.warn("No RTCPeerConnection in negotiatePeerConnection()", clientId);
3255
3271
  return;
@@ -3257,7 +3273,7 @@ class P2pRtcManager {
3257
3273
  const pc = session.pc;
3258
3274
  if (!session.canModifyPeerConnection()) {
3259
3275
  session.pending.push(() => {
3260
- this._negotiatePeerConnection(clientId, session, constraints);
3276
+ this._negotiatePeerConnection({ clientId, session, constraints, isInitialOffer });
3261
3277
  });
3262
3278
  return;
3263
3279
  }
@@ -3293,6 +3309,7 @@ class P2pRtcManager {
3293
3309
  sdp: offer.sdp,
3294
3310
  sdpU: offer.sdp,
3295
3311
  type: offer.type,
3312
+ isInitialOffer,
3296
3313
  };
3297
3314
  this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
3298
3315
  receiverId: clientId,
@@ -3309,7 +3326,7 @@ class P2pRtcManager {
3309
3326
  const originalOnnegotationneeded = pc.onnegotiationneeded;
3310
3327
  pc.onnegotiationneeded = null;
3311
3328
  action();
3312
- this._negotiatePeerConnection(session.clientId, session);
3329
+ this._negotiatePeerConnection({ clientId: session.clientId, session });
3313
3330
  setTimeout(() => (pc.onnegotiationneeded = originalOnnegotationneeded), 0);
3314
3331
  }
3315
3332
  _changeBandwidthForAllClients(isJoining) {
@@ -3459,7 +3476,7 @@ class P2pRtcManager {
3459
3476
  if (pc.iceConnectionState === "new" || !session.connectionStatus) {
3460
3477
  return;
3461
3478
  }
3462
- this._negotiatePeerConnection(clientId, session);
3479
+ this._negotiatePeerConnection({ clientId, session });
3463
3480
  };
3464
3481
  return session;
3465
3482
  }
@@ -5518,9 +5535,6 @@ class VegaRtcManager {
5518
5535
  });
5519
5536
  }
5520
5537
  }
5521
- supportsScreenShareAudio() {
5522
- return true;
5523
- }
5524
5538
  acceptNewStream({ streamId, clientId }) {
5525
5539
  logger$2.info("acceptNewStream()", { streamId, clientId });
5526
5540
  const clientState = this._getOrCreateClientState(clientId);
@@ -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,
@@ -2633,9 +2635,6 @@ class P2pRtcManager {
2633
2635
  isInitializedWith({ selfId, roomName, isSfu }) {
2634
2636
  return this._selfId === selfId && this._roomName === roomName && !isSfu;
2635
2637
  }
2636
- supportsScreenShareAudio() {
2637
- return true;
2638
- }
2639
2638
  addNewStream(streamId, stream, audioPaused, videoPaused, beforeEffectTracks = []) {
2640
2639
  if (stream === this.localStreams[streamId]) {
2641
2640
  return;
@@ -2720,6 +2719,7 @@ class P2pRtcManager {
2720
2719
  this._updateAndScheduleMediaServersRefresh(data);
2721
2720
  }),
2722
2721
  this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
2722
+ logger$6.info(`got ready_to_receive_offer from ${data.clientId}`);
2723
2723
  this._connect(data.clientId);
2724
2724
  }),
2725
2725
  this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
@@ -2731,6 +2731,7 @@ class P2pRtcManager {
2731
2731
  session.addIceCandidate(data.message);
2732
2732
  }),
2733
2733
  this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
2734
+ logger$6.info(`got end_of_ice_candidates from ${data.clientId}`);
2734
2735
  const session = this._getSession(data.clientId);
2735
2736
  if (!session) {
2736
2737
  logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
@@ -2740,6 +2741,7 @@ class P2pRtcManager {
2740
2741
  }),
2741
2742
  this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
2742
2743
  var _a, _b;
2744
+ logger$6.info(`got offer from ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
2743
2745
  const session = this._getSession(data.clientId);
2744
2746
  if (!session) {
2745
2747
  logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
@@ -2749,6 +2751,16 @@ class P2pRtcManager {
2749
2751
  sdp: data.message.sdp || data.message.sdpU,
2750
2752
  type: data.message.type,
2751
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
+ }
2752
2764
  (_b = (_a = session
2753
2765
  .handleOffer(sdp)
2754
2766
  .then((answer) => {
@@ -2762,6 +2774,7 @@ class P2pRtcManager {
2762
2774
  }),
2763
2775
  this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
2764
2776
  var _a, _b;
2777
+ logger$6.info(`got offer from ${data.clientId}`);
2765
2778
  const session = this._getSession(data.clientId);
2766
2779
  if (!session) {
2767
2780
  logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
@@ -2955,6 +2968,7 @@ class P2pRtcManager {
2955
2968
  };
2956
2969
  pc.oniceconnectionstatechange = () => {
2957
2970
  var _a;
2971
+ logger$6.info(`iceConnectionState changed to ${pc.iceConnectionState} for session ${session.clientId}`);
2958
2972
  let newStatus;
2959
2973
  const currentStatus = session.connectionStatus;
2960
2974
  switch (pc.iceConnectionState) {
@@ -2984,7 +2998,7 @@ class P2pRtcManager {
2984
2998
  if (pc.iceConnectionState === "disconnected") {
2985
2999
  this._maybeRestartIce(clientId, session);
2986
3000
  }
2987
- }, 2000);
3001
+ }, ICE_RESTART_DELAY);
2988
3002
  break;
2989
3003
  case "failed":
2990
3004
  newStatus = TYPES.CONNECTION_FAILED;
@@ -3007,6 +3021,7 @@ class P2pRtcManager {
3007
3021
  };
3008
3022
  pc.onconnectionstatechange = () => {
3009
3023
  var _a;
3024
+ logger$6.info(`connectionState changed to ${pc.connectionState} for session ${session.clientId}`);
3010
3025
  switch (pc.connectionState) {
3011
3026
  case "connected":
3012
3027
  setTimeout(() => {
@@ -3187,7 +3202,7 @@ class P2pRtcManager {
3187
3202
  initialBandwidth,
3188
3203
  isOfferer: true,
3189
3204
  });
3190
- this._negotiatePeerConnection(clientId, session);
3205
+ this._negotiatePeerConnection({ clientId, session, isInitialOffer: true });
3191
3206
  return session;
3192
3207
  }
3193
3208
  _maybeRestartIce(clientId, session) {
@@ -3205,7 +3220,8 @@ class P2pRtcManager {
3205
3220
  session.ipv6HostCandidate6to4Seen = false;
3206
3221
  session.mdnsHostCandidateSeen = false;
3207
3222
  this.analytics.numIceRestart++;
3208
- this._negotiatePeerConnection(clientId, session, Object.assign({}, this.offerOptions, { iceRestart: true }));
3223
+ const constraints = Object.assign(Object.assign({}, this.offerOptions), { iceRestart: true });
3224
+ this._negotiatePeerConnection({ clientId, session, constraints });
3209
3225
  }
3210
3226
  }
3211
3227
  _setCodecPreferences(pc) {
@@ -3249,7 +3265,7 @@ class P2pRtcManager {
3249
3265
  }
3250
3266
  });
3251
3267
  }
3252
- _negotiatePeerConnection(clientId, session, constraints) {
3268
+ _negotiatePeerConnection({ clientId, session, constraints, isInitialOffer = false, }) {
3253
3269
  if (!session) {
3254
3270
  logger$6.warn("No RTCPeerConnection in negotiatePeerConnection()", clientId);
3255
3271
  return;
@@ -3257,7 +3273,7 @@ class P2pRtcManager {
3257
3273
  const pc = session.pc;
3258
3274
  if (!session.canModifyPeerConnection()) {
3259
3275
  session.pending.push(() => {
3260
- this._negotiatePeerConnection(clientId, session, constraints);
3276
+ this._negotiatePeerConnection({ clientId, session, constraints, isInitialOffer });
3261
3277
  });
3262
3278
  return;
3263
3279
  }
@@ -3293,6 +3309,7 @@ class P2pRtcManager {
3293
3309
  sdp: offer.sdp,
3294
3310
  sdpU: offer.sdp,
3295
3311
  type: offer.type,
3312
+ isInitialOffer,
3296
3313
  };
3297
3314
  this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
3298
3315
  receiverId: clientId,
@@ -3309,7 +3326,7 @@ class P2pRtcManager {
3309
3326
  const originalOnnegotationneeded = pc.onnegotiationneeded;
3310
3327
  pc.onnegotiationneeded = null;
3311
3328
  action();
3312
- this._negotiatePeerConnection(session.clientId, session);
3329
+ this._negotiatePeerConnection({ clientId: session.clientId, session });
3313
3330
  setTimeout(() => (pc.onnegotiationneeded = originalOnnegotationneeded), 0);
3314
3331
  }
3315
3332
  _changeBandwidthForAllClients(isJoining) {
@@ -3459,7 +3476,7 @@ class P2pRtcManager {
3459
3476
  if (pc.iceConnectionState === "new" || !session.connectionStatus) {
3460
3477
  return;
3461
3478
  }
3462
- this._negotiatePeerConnection(clientId, session);
3479
+ this._negotiatePeerConnection({ clientId, session });
3463
3480
  };
3464
3481
  return session;
3465
3482
  }
@@ -5518,9 +5535,6 @@ class VegaRtcManager {
5518
5535
  });
5519
5536
  }
5520
5537
  }
5521
- supportsScreenShareAudio() {
5522
- return true;
5523
- }
5524
5538
  acceptNewStream({ streamId, clientId }) {
5525
5539
  logger$2.info("acceptNewStream()", { streamId, clientId });
5526
5540
  const clientState = this._getOrCreateClientState(clientId);
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": "2.9.2",
4
+ "version": "3.1.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {
@@ -62,9 +62,9 @@
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/tsconfig": "0.1.0",
67
65
  "@whereby.com/rollup-config": "0.1.1",
66
+ "@whereby.com/tsconfig": "0.1.0",
67
+ "@whereby.com/jest-config": "0.1.0",
68
68
  "@whereby.com/prettier-config": "0.1.0"
69
69
  },
70
70
  "engines": {