@whereby.com/media 1.11.1 → 1.12.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
@@ -3548,6 +3548,7 @@ class P2pRtcManager {
3548
3548
  this._isAudioOnlyMode = false;
3549
3549
  this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
3550
3550
  this._pendingActionsForConnectedPeerConnections = [];
3551
+ this._nodeJsClients = [];
3551
3552
  this._audioTrackOnEnded = () => {
3552
3553
  rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
3553
3554
  this._emit(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
@@ -3629,9 +3630,6 @@ class P2pRtcManager {
3629
3630
  }
3630
3631
  return this._replaceTrackToPeerConnections(oldTrack, newTrack);
3631
3632
  }
3632
- accept({ clientId, shouldAddLocalVideo }) {
3633
- return this.acceptNewStream({ streamId: clientId, clientId, shouldAddLocalVideo });
3634
- }
3635
3633
  disconnectAll() {
3636
3634
  Object.keys(this.peerConnections).forEach((peerConnectionId) => {
3637
3635
  this.disconnect(peerConnectionId);
@@ -3666,6 +3664,11 @@ class P2pRtcManager {
3666
3664
  setupSocketListeners() {
3667
3665
  this._socketListenerDeregisterFunctions = [
3668
3666
  () => this._clearMediaServersRefresh(),
3667
+ this._serverSocket.on(PROTOCOL_RESPONSES.NEW_CLIENT, (data) => {
3668
+ if (data.client.isDialIn && !this._nodeJsClients.includes(data.client.id)) {
3669
+ this._nodeJsClients.push(data.client.id);
3670
+ }
3671
+ }),
3669
3672
  this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
3670
3673
  if (data.error) {
3671
3674
  logger$4.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
@@ -3863,7 +3866,7 @@ class P2pRtcManager {
3863
3866
  _transformOutgoingSdp(original) {
3864
3867
  return { type: original.type, sdpU: original.sdp };
3865
3868
  }
3866
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
3869
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }) {
3867
3870
  if (!peerConnectionId) {
3868
3871
  throw new Error("peerConnectionId is missing");
3869
3872
  }
@@ -3899,13 +3902,13 @@ class P2pRtcManager {
3899
3902
  return entry;
3900
3903
  });
3901
3904
  }
3902
- if (this._features.useOnlyTURN) {
3905
+ if (enforceTurnProtocol || this._features.useOnlyTURN) {
3903
3906
  peerConnectionConfig.iceTransportPolicy = "relay";
3904
3907
  const filter = {
3905
3908
  onlyudp: /^turn:.*transport=udp$/,
3906
3909
  onlytcp: /^turn:.*transport=tcp$/,
3907
3910
  onlytls: /^turns:.*transport=tcp$/,
3908
- }[this._features.useOnlyTURN];
3911
+ }[enforceTurnProtocol || this._features.useOnlyTURN];
3909
3912
  if (filter) {
3910
3913
  peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter((entry) => entry.url && entry.url.match(filter));
3911
3914
  }
@@ -4157,17 +4160,26 @@ class P2pRtcManager {
4157
4160
  }
4158
4161
  _connect(clientId) {
4159
4162
  this.rtcStatsReconnect();
4160
- const shouldAddLocalVideo = true;
4161
4163
  let session = this._getSession(clientId);
4162
- let bandwidth = (session && session.bandwidth) || 0;
4164
+ let initialBandwidth = (session && session.bandwidth) || 0;
4163
4165
  if (session) {
4164
4166
  logger$4.warn("Replacing peer session", clientId);
4165
4167
  this._cleanup(clientId);
4166
4168
  }
4167
4169
  else {
4168
- bandwidth = this._changeBandwidthForAllClients(true);
4170
+ initialBandwidth = this._changeBandwidthForAllClients(true);
4169
4171
  }
4170
- session = this._createP2pSession(clientId, bandwidth, shouldAddLocalVideo, true);
4172
+ let enforceTurnProtocol;
4173
+ if (this._nodeJsClients.includes(clientId)) {
4174
+ enforceTurnProtocol = this._features.isNodeSdk ? "onlyudp" : "onlytls";
4175
+ }
4176
+ session = this._createP2pSession({
4177
+ clientId,
4178
+ initialBandwidth,
4179
+ shouldAddLocalVideo: true,
4180
+ isOfferer: true,
4181
+ enforceTurnProtocol,
4182
+ });
4171
4183
  this._negotiatePeerConnection(clientId, session);
4172
4184
  return Promise.resolve(session);
4173
4185
  }
@@ -4338,13 +4350,14 @@ class P2pRtcManager {
4338
4350
  });
4339
4351
  return bandwidth;
4340
4352
  }
4341
- _createP2pSession(clientId, initialBandwidth, shouldAddLocalVideo, isOfferer) {
4353
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, enforceTurnProtocol, }) {
4342
4354
  const session = this._createSession({
4343
4355
  peerConnectionId: clientId,
4344
4356
  clientId,
4345
4357
  initialBandwidth,
4346
4358
  shouldAddLocalVideo,
4347
4359
  isOfferer,
4360
+ enforceTurnProtocol,
4348
4361
  });
4349
4362
  const pc = session.pc;
4350
4363
  if (this._features.increaseIncomingMediaBufferOn) {
@@ -4458,20 +4471,26 @@ class P2pRtcManager {
4458
4471
  };
4459
4472
  return session;
4460
4473
  }
4461
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
4474
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }) {
4462
4475
  let session = this._getSession(clientId);
4463
4476
  if (session && streamId !== clientId) {
4464
4477
  return session;
4465
4478
  }
4466
- let bandwidth = (session && session.bandwidth) || 0;
4479
+ let initialBandwidth = (session && session.bandwidth) || 0;
4467
4480
  if (session) {
4468
4481
  logger$4.warn("Replacing peer session", clientId);
4469
4482
  this._cleanup(clientId);
4470
4483
  }
4471
4484
  else {
4472
- bandwidth = this._changeBandwidthForAllClients(true);
4485
+ initialBandwidth = this._changeBandwidthForAllClients(true);
4473
4486
  }
4474
- session = this._createP2pSession(clientId, bandwidth, shouldAddLocalVideo);
4487
+ session = this._createP2pSession({
4488
+ clientId,
4489
+ initialBandwidth,
4490
+ shouldAddLocalVideo: !!shouldAddLocalVideo,
4491
+ enforceTurnProtocol,
4492
+ isOfferer: false,
4493
+ });
4475
4494
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
4476
4495
  receiverId: clientId,
4477
4496
  });
package/dist/index.d.cts CHANGED
@@ -309,140 +309,6 @@ declare function getUpdatedDevices({ oldDevices, newDevices, currentAudioId, cur
309
309
  currentSpeakerId?: string | undefined;
310
310
  }): GetUpdatedDevicesResult;
311
311
 
312
- declare class P2pRtcManager implements RtcManager {
313
- _selfId: any;
314
- _roomName: any;
315
- _roomSessionId: any;
316
- peerConnections: any;
317
- localStreams: any;
318
- enabledLocalStreamIds: any[];
319
- _screenshareVideoTrackIds: any[];
320
- _socketListenerDeregisterFunctions: any[];
321
- _localStreamDeregisterFunction: any;
322
- _emitter: any;
323
- _serverSocket: any;
324
- _webrtcProvider: any;
325
- _features: any;
326
- _isAudioOnlyMode: boolean;
327
- offerOptions: {
328
- offerToReceiveAudio: boolean;
329
- offerToReceiveVideo: boolean;
330
- };
331
- _pendingActionsForConnectedPeerConnections: any[];
332
- _audioTrackOnEnded: () => void;
333
- _videoTrackOnEnded: () => void;
334
- totalSessionsCreated: number;
335
- _iceServers: any;
336
- _sfuServer: any;
337
- _mediaserverConfigTtlSeconds: any;
338
- _fetchMediaServersTimer: any;
339
- _wasScreenSharing: any;
340
- ipv6HostCandidateTeredoSeen: any;
341
- ipv6HostCandidate6to4Seen: any;
342
- mdnsHostCandidateSeen: any;
343
- _lastReverseDirectionAttemptByClientId: any;
344
- _stoppedVideoTrack: any;
345
- icePublicIPGatheringTimeoutID: any;
346
- _videoTrackBeingMonitored?: CustomMediaStreamTrack;
347
- _audioTrackBeingMonitored?: CustomMediaStreamTrack;
348
- constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
349
- selfId: any;
350
- room: any;
351
- emitter: any;
352
- serverSocket: any;
353
- webrtcProvider: any;
354
- features: any;
355
- });
356
- numberOfPeerconnections(): number;
357
- isInitializedWith({ selfId, roomName, isSfu }: {
358
- selfId: any;
359
- roomName: any;
360
- isSfu: any;
361
- }): boolean;
362
- supportsScreenShareAudio(): boolean;
363
- maybeRestrictRelayBandwidth(session: any): void;
364
- addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: CustomMediaStreamTrack[]): void;
365
- replaceTrack(oldTrack: CustomMediaStreamTrack | null, newTrack: CustomMediaStreamTrack): Promise<any[]>;
366
- accept({ clientId, shouldAddLocalVideo }: {
367
- clientId: string;
368
- shouldAddLocalVideo?: boolean;
369
- }): any;
370
- disconnectAll(): void;
371
- fixChromeAudio(constraints: any): Promise<any[]> | undefined;
372
- setupSocketListeners(): void;
373
- sendAudioMutedStats(muted: boolean): void;
374
- sendVideoMutedStats(muted: boolean): void;
375
- sendStatsCustomEvent(eventName: string, data: any): void;
376
- rtcStatsDisconnect(): void;
377
- rtcStatsReconnect(): void;
378
- setAudioOnly(audioOnly: any): void;
379
- setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds?: never[]): void;
380
- setRoomSessionId(roomSessionId: string): void;
381
- _setConnectionStatus(session: any, newStatus: any, clientId: string): void;
382
- _setJitterBufferTarget(pc: any): void;
383
- _emitServerEvent(eventName: string, data?: any, callback?: any): void;
384
- _emit(eventName: string, data?: any): void;
385
- _addEnabledLocalStreamId(streamId: string): void;
386
- _deleteEnabledLocalStreamId(streamId: string): void;
387
- _getSession(peerConnectionId: string): any;
388
- _getOrCreateSession(peerConnectionId: string, initialBandwidth: any): any;
389
- _getLocalCameraStream(): any;
390
- _getNonLocalCameraStreamIds(): string[];
391
- _isScreensharingLocally(): boolean;
392
- _getFirstLocalNonCameraStream(): any;
393
- _transformIncomingSdp(original: any, _: any): {
394
- type: any;
395
- sdp: any;
396
- };
397
- _transformOutgoingSdp(original: any): {
398
- type: any;
399
- sdpU: any;
400
- };
401
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }: {
402
- clientId: string;
403
- initialBandwidth: any;
404
- isOfferer: any;
405
- peerConnectionId: string;
406
- shouldAddLocalVideo: boolean;
407
- }): any;
408
- _cleanup(peerConnectionId: string): void;
409
- _forEachPeerConnection(func: any): void;
410
- _addStreamToPeerConnections(stream: any): void;
411
- _addTrackToPeerConnections(track: any, stream?: any): void;
412
- _replaceTrackToPeerConnections(oldTrack: any, newTrack: any): Promise<any[]>;
413
- _removeStreamFromPeerConnections(stream: any): void;
414
- _removeTrackFromPeerConnections(track: any): void;
415
- _addLocalStream(streamId: string, stream: any): void;
416
- _removeLocalStream(streamId: string): void;
417
- _updateAndScheduleMediaServersRefresh({ iceServers, sfuServer, mediaserverConfigTtlSeconds }: any): void;
418
- _clearMediaServersRefresh(): void;
419
- _monitorAudioTrack(track: any): void;
420
- _monitorVideoTrack(track: CustomMediaStreamTrack): void;
421
- _connect(clientId: string): Promise<any>;
422
- _maybeRestartIce(clientId: string, session: any): void;
423
- _setCodecPreferences(pc: any, vp9On: any, av1On: any, redOn: any): void;
424
- _negotiatePeerConnection(clientId: string, session: any, constraints?: any): void;
425
- _withForcedRenegotiation(session: any, action: any): void;
426
- _changeBandwidthForAllClients(isJoining: boolean): number;
427
- _createP2pSession(clientId: string, initialBandwidth: any, shouldAddLocalVideo: any, isOfferer?: any): any;
428
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }: {
429
- streamId: string;
430
- clientId: string;
431
- shouldAddLocalVideo?: boolean;
432
- }): any;
433
- disconnect(clientId: string): void;
434
- updateStreamResolution(): void;
435
- stopOrResumeAudio(): void;
436
- _handleStopOrResumeVideo({ enable, track }: {
437
- enable: boolean;
438
- track: any;
439
- }): void;
440
- stopOrResumeVideo(localStream: any, enable: boolean): void;
441
- _shareScreen(streamId: string, stream: any): void;
442
- removeStream(streamId: string, stream: any, requestedByClientId: any): void;
443
- hasClient(clientId: string): boolean;
444
- }
445
-
446
312
  declare const assert: {
447
313
  fail: (message?: string | Error) => void;
448
314
  ok: (value: any, message?: string | Error) => void;
@@ -823,6 +689,7 @@ interface SignalRequests {
823
689
  };
824
690
  stop_recording: void;
825
691
  }
692
+ type TurnTransportProtocol = "onlyudp" | "onlytcp" | "onlytls";
826
693
 
827
694
  declare function fromLocation({ host, protocol }?: {
828
695
  host?: string | undefined;
@@ -836,6 +703,145 @@ declare function fromLocation({ host, protocol }?: {
836
703
  subdomain: string;
837
704
  };
838
705
 
706
+ declare class P2pRtcManager implements RtcManager {
707
+ _selfId: any;
708
+ _roomName: any;
709
+ _roomSessionId: any;
710
+ peerConnections: any;
711
+ localStreams: any;
712
+ enabledLocalStreamIds: any[];
713
+ _screenshareVideoTrackIds: any[];
714
+ _socketListenerDeregisterFunctions: any[];
715
+ _localStreamDeregisterFunction: any;
716
+ _emitter: any;
717
+ _serverSocket: any;
718
+ _webrtcProvider: any;
719
+ _features: any;
720
+ _isAudioOnlyMode: boolean;
721
+ offerOptions: {
722
+ offerToReceiveAudio: boolean;
723
+ offerToReceiveVideo: boolean;
724
+ };
725
+ _pendingActionsForConnectedPeerConnections: any[];
726
+ _audioTrackOnEnded: () => void;
727
+ _videoTrackOnEnded: () => void;
728
+ totalSessionsCreated: number;
729
+ _iceServers: any;
730
+ _sfuServer: any;
731
+ _mediaserverConfigTtlSeconds: any;
732
+ _fetchMediaServersTimer: any;
733
+ _wasScreenSharing: any;
734
+ ipv6HostCandidateTeredoSeen: any;
735
+ ipv6HostCandidate6to4Seen: any;
736
+ mdnsHostCandidateSeen: any;
737
+ _lastReverseDirectionAttemptByClientId: any;
738
+ _stoppedVideoTrack: any;
739
+ icePublicIPGatheringTimeoutID: any;
740
+ _videoTrackBeingMonitored?: CustomMediaStreamTrack;
741
+ _audioTrackBeingMonitored?: CustomMediaStreamTrack;
742
+ _nodeJsClients: string[];
743
+ constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
744
+ selfId: any;
745
+ room: any;
746
+ emitter: any;
747
+ serverSocket: any;
748
+ webrtcProvider: any;
749
+ features: any;
750
+ });
751
+ numberOfPeerconnections(): number;
752
+ isInitializedWith({ selfId, roomName, isSfu }: {
753
+ selfId: any;
754
+ roomName: any;
755
+ isSfu: any;
756
+ }): boolean;
757
+ supportsScreenShareAudio(): boolean;
758
+ maybeRestrictRelayBandwidth(session: any): void;
759
+ addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: CustomMediaStreamTrack[]): void;
760
+ replaceTrack(oldTrack: CustomMediaStreamTrack | null, newTrack: CustomMediaStreamTrack): Promise<any[]>;
761
+ disconnectAll(): void;
762
+ fixChromeAudio(constraints: any): Promise<any[]> | undefined;
763
+ setupSocketListeners(): void;
764
+ sendAudioMutedStats(muted: boolean): void;
765
+ sendVideoMutedStats(muted: boolean): void;
766
+ sendStatsCustomEvent(eventName: string, data: any): void;
767
+ rtcStatsDisconnect(): void;
768
+ rtcStatsReconnect(): void;
769
+ setAudioOnly(audioOnly: any): void;
770
+ setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds?: never[]): void;
771
+ setRoomSessionId(roomSessionId: string): void;
772
+ _setConnectionStatus(session: any, newStatus: any, clientId: string): void;
773
+ _setJitterBufferTarget(pc: any): void;
774
+ _emitServerEvent(eventName: string, data?: any, callback?: any): void;
775
+ _emit(eventName: string, data?: any): void;
776
+ _addEnabledLocalStreamId(streamId: string): void;
777
+ _deleteEnabledLocalStreamId(streamId: string): void;
778
+ _getSession(peerConnectionId: string): any;
779
+ _getOrCreateSession(peerConnectionId: string, initialBandwidth: any): any;
780
+ _getLocalCameraStream(): any;
781
+ _getNonLocalCameraStreamIds(): string[];
782
+ _isScreensharingLocally(): boolean;
783
+ _getFirstLocalNonCameraStream(): any;
784
+ _transformIncomingSdp(original: any, _: any): {
785
+ type: any;
786
+ sdp: any;
787
+ };
788
+ _transformOutgoingSdp(original: any): {
789
+ type: any;
790
+ sdpU: any;
791
+ };
792
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }: {
793
+ clientId: string;
794
+ initialBandwidth: any;
795
+ isOfferer: any;
796
+ peerConnectionId: string;
797
+ shouldAddLocalVideo: boolean;
798
+ enforceTurnProtocol?: TurnTransportProtocol;
799
+ }): any;
800
+ _cleanup(peerConnectionId: string): void;
801
+ _forEachPeerConnection(func: any): void;
802
+ _addStreamToPeerConnections(stream: any): void;
803
+ _addTrackToPeerConnections(track: any, stream?: any): void;
804
+ _replaceTrackToPeerConnections(oldTrack: any, newTrack: any): Promise<any[]>;
805
+ _removeStreamFromPeerConnections(stream: any): void;
806
+ _removeTrackFromPeerConnections(track: any): void;
807
+ _addLocalStream(streamId: string, stream: any): void;
808
+ _removeLocalStream(streamId: string): void;
809
+ _updateAndScheduleMediaServersRefresh({ iceServers, sfuServer, mediaserverConfigTtlSeconds }: any): void;
810
+ _clearMediaServersRefresh(): void;
811
+ _monitorAudioTrack(track: any): void;
812
+ _monitorVideoTrack(track: CustomMediaStreamTrack): void;
813
+ _connect(clientId: string): Promise<any>;
814
+ _maybeRestartIce(clientId: string, session: any): void;
815
+ _setCodecPreferences(pc: any, vp9On: any, av1On: any, redOn: any): void;
816
+ _negotiatePeerConnection(clientId: string, session: any, constraints?: any): void;
817
+ _withForcedRenegotiation(session: any, action: any): void;
818
+ _changeBandwidthForAllClients(isJoining: boolean): number;
819
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo, isOfferer, enforceTurnProtocol, }: {
820
+ clientId: string;
821
+ initialBandwidth: number;
822
+ shouldAddLocalVideo: boolean;
823
+ isOfferer: boolean;
824
+ enforceTurnProtocol?: TurnTransportProtocol;
825
+ }): any;
826
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }: {
827
+ streamId: string;
828
+ clientId: string;
829
+ shouldAddLocalVideo?: boolean;
830
+ enforceTurnProtocol?: TurnTransportProtocol;
831
+ }): any;
832
+ disconnect(clientId: string): void;
833
+ updateStreamResolution(): void;
834
+ stopOrResumeAudio(): void;
835
+ _handleStopOrResumeVideo({ enable, track }: {
836
+ enable: boolean;
837
+ track: any;
838
+ }): void;
839
+ stopOrResumeVideo(localStream: any, enable: boolean): void;
840
+ _shareScreen(streamId: string, stream: any): void;
841
+ removeStream(streamId: string, stream: any, requestedByClientId: any): void;
842
+ hasClient(clientId: string): boolean;
843
+ }
844
+
839
845
  declare class RtcManagerDispatcher {
840
846
  emitter: {
841
847
  emit: <K extends keyof RtcEvents>(eventName: K, args?: RtcEvents[K]) => void;
@@ -1410,4 +1416,4 @@ declare class RtcStream {
1410
1416
  static getTypeFromId(id: string): string;
1411
1417
  }
1412
1418
 
1413
- export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
1419
+ export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, type TurnTransportProtocol, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
package/dist/index.d.mts CHANGED
@@ -309,140 +309,6 @@ declare function getUpdatedDevices({ oldDevices, newDevices, currentAudioId, cur
309
309
  currentSpeakerId?: string | undefined;
310
310
  }): GetUpdatedDevicesResult;
311
311
 
312
- declare class P2pRtcManager implements RtcManager {
313
- _selfId: any;
314
- _roomName: any;
315
- _roomSessionId: any;
316
- peerConnections: any;
317
- localStreams: any;
318
- enabledLocalStreamIds: any[];
319
- _screenshareVideoTrackIds: any[];
320
- _socketListenerDeregisterFunctions: any[];
321
- _localStreamDeregisterFunction: any;
322
- _emitter: any;
323
- _serverSocket: any;
324
- _webrtcProvider: any;
325
- _features: any;
326
- _isAudioOnlyMode: boolean;
327
- offerOptions: {
328
- offerToReceiveAudio: boolean;
329
- offerToReceiveVideo: boolean;
330
- };
331
- _pendingActionsForConnectedPeerConnections: any[];
332
- _audioTrackOnEnded: () => void;
333
- _videoTrackOnEnded: () => void;
334
- totalSessionsCreated: number;
335
- _iceServers: any;
336
- _sfuServer: any;
337
- _mediaserverConfigTtlSeconds: any;
338
- _fetchMediaServersTimer: any;
339
- _wasScreenSharing: any;
340
- ipv6HostCandidateTeredoSeen: any;
341
- ipv6HostCandidate6to4Seen: any;
342
- mdnsHostCandidateSeen: any;
343
- _lastReverseDirectionAttemptByClientId: any;
344
- _stoppedVideoTrack: any;
345
- icePublicIPGatheringTimeoutID: any;
346
- _videoTrackBeingMonitored?: CustomMediaStreamTrack;
347
- _audioTrackBeingMonitored?: CustomMediaStreamTrack;
348
- constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
349
- selfId: any;
350
- room: any;
351
- emitter: any;
352
- serverSocket: any;
353
- webrtcProvider: any;
354
- features: any;
355
- });
356
- numberOfPeerconnections(): number;
357
- isInitializedWith({ selfId, roomName, isSfu }: {
358
- selfId: any;
359
- roomName: any;
360
- isSfu: any;
361
- }): boolean;
362
- supportsScreenShareAudio(): boolean;
363
- maybeRestrictRelayBandwidth(session: any): void;
364
- addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: CustomMediaStreamTrack[]): void;
365
- replaceTrack(oldTrack: CustomMediaStreamTrack | null, newTrack: CustomMediaStreamTrack): Promise<any[]>;
366
- accept({ clientId, shouldAddLocalVideo }: {
367
- clientId: string;
368
- shouldAddLocalVideo?: boolean;
369
- }): any;
370
- disconnectAll(): void;
371
- fixChromeAudio(constraints: any): Promise<any[]> | undefined;
372
- setupSocketListeners(): void;
373
- sendAudioMutedStats(muted: boolean): void;
374
- sendVideoMutedStats(muted: boolean): void;
375
- sendStatsCustomEvent(eventName: string, data: any): void;
376
- rtcStatsDisconnect(): void;
377
- rtcStatsReconnect(): void;
378
- setAudioOnly(audioOnly: any): void;
379
- setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds?: never[]): void;
380
- setRoomSessionId(roomSessionId: string): void;
381
- _setConnectionStatus(session: any, newStatus: any, clientId: string): void;
382
- _setJitterBufferTarget(pc: any): void;
383
- _emitServerEvent(eventName: string, data?: any, callback?: any): void;
384
- _emit(eventName: string, data?: any): void;
385
- _addEnabledLocalStreamId(streamId: string): void;
386
- _deleteEnabledLocalStreamId(streamId: string): void;
387
- _getSession(peerConnectionId: string): any;
388
- _getOrCreateSession(peerConnectionId: string, initialBandwidth: any): any;
389
- _getLocalCameraStream(): any;
390
- _getNonLocalCameraStreamIds(): string[];
391
- _isScreensharingLocally(): boolean;
392
- _getFirstLocalNonCameraStream(): any;
393
- _transformIncomingSdp(original: any, _: any): {
394
- type: any;
395
- sdp: any;
396
- };
397
- _transformOutgoingSdp(original: any): {
398
- type: any;
399
- sdpU: any;
400
- };
401
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }: {
402
- clientId: string;
403
- initialBandwidth: any;
404
- isOfferer: any;
405
- peerConnectionId: string;
406
- shouldAddLocalVideo: boolean;
407
- }): any;
408
- _cleanup(peerConnectionId: string): void;
409
- _forEachPeerConnection(func: any): void;
410
- _addStreamToPeerConnections(stream: any): void;
411
- _addTrackToPeerConnections(track: any, stream?: any): void;
412
- _replaceTrackToPeerConnections(oldTrack: any, newTrack: any): Promise<any[]>;
413
- _removeStreamFromPeerConnections(stream: any): void;
414
- _removeTrackFromPeerConnections(track: any): void;
415
- _addLocalStream(streamId: string, stream: any): void;
416
- _removeLocalStream(streamId: string): void;
417
- _updateAndScheduleMediaServersRefresh({ iceServers, sfuServer, mediaserverConfigTtlSeconds }: any): void;
418
- _clearMediaServersRefresh(): void;
419
- _monitorAudioTrack(track: any): void;
420
- _monitorVideoTrack(track: CustomMediaStreamTrack): void;
421
- _connect(clientId: string): Promise<any>;
422
- _maybeRestartIce(clientId: string, session: any): void;
423
- _setCodecPreferences(pc: any, vp9On: any, av1On: any, redOn: any): void;
424
- _negotiatePeerConnection(clientId: string, session: any, constraints?: any): void;
425
- _withForcedRenegotiation(session: any, action: any): void;
426
- _changeBandwidthForAllClients(isJoining: boolean): number;
427
- _createP2pSession(clientId: string, initialBandwidth: any, shouldAddLocalVideo: any, isOfferer?: any): any;
428
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }: {
429
- streamId: string;
430
- clientId: string;
431
- shouldAddLocalVideo?: boolean;
432
- }): any;
433
- disconnect(clientId: string): void;
434
- updateStreamResolution(): void;
435
- stopOrResumeAudio(): void;
436
- _handleStopOrResumeVideo({ enable, track }: {
437
- enable: boolean;
438
- track: any;
439
- }): void;
440
- stopOrResumeVideo(localStream: any, enable: boolean): void;
441
- _shareScreen(streamId: string, stream: any): void;
442
- removeStream(streamId: string, stream: any, requestedByClientId: any): void;
443
- hasClient(clientId: string): boolean;
444
- }
445
-
446
312
  declare const assert: {
447
313
  fail: (message?: string | Error) => void;
448
314
  ok: (value: any, message?: string | Error) => void;
@@ -823,6 +689,7 @@ interface SignalRequests {
823
689
  };
824
690
  stop_recording: void;
825
691
  }
692
+ type TurnTransportProtocol = "onlyudp" | "onlytcp" | "onlytls";
826
693
 
827
694
  declare function fromLocation({ host, protocol }?: {
828
695
  host?: string | undefined;
@@ -836,6 +703,145 @@ declare function fromLocation({ host, protocol }?: {
836
703
  subdomain: string;
837
704
  };
838
705
 
706
+ declare class P2pRtcManager implements RtcManager {
707
+ _selfId: any;
708
+ _roomName: any;
709
+ _roomSessionId: any;
710
+ peerConnections: any;
711
+ localStreams: any;
712
+ enabledLocalStreamIds: any[];
713
+ _screenshareVideoTrackIds: any[];
714
+ _socketListenerDeregisterFunctions: any[];
715
+ _localStreamDeregisterFunction: any;
716
+ _emitter: any;
717
+ _serverSocket: any;
718
+ _webrtcProvider: any;
719
+ _features: any;
720
+ _isAudioOnlyMode: boolean;
721
+ offerOptions: {
722
+ offerToReceiveAudio: boolean;
723
+ offerToReceiveVideo: boolean;
724
+ };
725
+ _pendingActionsForConnectedPeerConnections: any[];
726
+ _audioTrackOnEnded: () => void;
727
+ _videoTrackOnEnded: () => void;
728
+ totalSessionsCreated: number;
729
+ _iceServers: any;
730
+ _sfuServer: any;
731
+ _mediaserverConfigTtlSeconds: any;
732
+ _fetchMediaServersTimer: any;
733
+ _wasScreenSharing: any;
734
+ ipv6HostCandidateTeredoSeen: any;
735
+ ipv6HostCandidate6to4Seen: any;
736
+ mdnsHostCandidateSeen: any;
737
+ _lastReverseDirectionAttemptByClientId: any;
738
+ _stoppedVideoTrack: any;
739
+ icePublicIPGatheringTimeoutID: any;
740
+ _videoTrackBeingMonitored?: CustomMediaStreamTrack;
741
+ _audioTrackBeingMonitored?: CustomMediaStreamTrack;
742
+ _nodeJsClients: string[];
743
+ constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
744
+ selfId: any;
745
+ room: any;
746
+ emitter: any;
747
+ serverSocket: any;
748
+ webrtcProvider: any;
749
+ features: any;
750
+ });
751
+ numberOfPeerconnections(): number;
752
+ isInitializedWith({ selfId, roomName, isSfu }: {
753
+ selfId: any;
754
+ roomName: any;
755
+ isSfu: any;
756
+ }): boolean;
757
+ supportsScreenShareAudio(): boolean;
758
+ maybeRestrictRelayBandwidth(session: any): void;
759
+ addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: CustomMediaStreamTrack[]): void;
760
+ replaceTrack(oldTrack: CustomMediaStreamTrack | null, newTrack: CustomMediaStreamTrack): Promise<any[]>;
761
+ disconnectAll(): void;
762
+ fixChromeAudio(constraints: any): Promise<any[]> | undefined;
763
+ setupSocketListeners(): void;
764
+ sendAudioMutedStats(muted: boolean): void;
765
+ sendVideoMutedStats(muted: boolean): void;
766
+ sendStatsCustomEvent(eventName: string, data: any): void;
767
+ rtcStatsDisconnect(): void;
768
+ rtcStatsReconnect(): void;
769
+ setAudioOnly(audioOnly: any): void;
770
+ setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds?: never[]): void;
771
+ setRoomSessionId(roomSessionId: string): void;
772
+ _setConnectionStatus(session: any, newStatus: any, clientId: string): void;
773
+ _setJitterBufferTarget(pc: any): void;
774
+ _emitServerEvent(eventName: string, data?: any, callback?: any): void;
775
+ _emit(eventName: string, data?: any): void;
776
+ _addEnabledLocalStreamId(streamId: string): void;
777
+ _deleteEnabledLocalStreamId(streamId: string): void;
778
+ _getSession(peerConnectionId: string): any;
779
+ _getOrCreateSession(peerConnectionId: string, initialBandwidth: any): any;
780
+ _getLocalCameraStream(): any;
781
+ _getNonLocalCameraStreamIds(): string[];
782
+ _isScreensharingLocally(): boolean;
783
+ _getFirstLocalNonCameraStream(): any;
784
+ _transformIncomingSdp(original: any, _: any): {
785
+ type: any;
786
+ sdp: any;
787
+ };
788
+ _transformOutgoingSdp(original: any): {
789
+ type: any;
790
+ sdpU: any;
791
+ };
792
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }: {
793
+ clientId: string;
794
+ initialBandwidth: any;
795
+ isOfferer: any;
796
+ peerConnectionId: string;
797
+ shouldAddLocalVideo: boolean;
798
+ enforceTurnProtocol?: TurnTransportProtocol;
799
+ }): any;
800
+ _cleanup(peerConnectionId: string): void;
801
+ _forEachPeerConnection(func: any): void;
802
+ _addStreamToPeerConnections(stream: any): void;
803
+ _addTrackToPeerConnections(track: any, stream?: any): void;
804
+ _replaceTrackToPeerConnections(oldTrack: any, newTrack: any): Promise<any[]>;
805
+ _removeStreamFromPeerConnections(stream: any): void;
806
+ _removeTrackFromPeerConnections(track: any): void;
807
+ _addLocalStream(streamId: string, stream: any): void;
808
+ _removeLocalStream(streamId: string): void;
809
+ _updateAndScheduleMediaServersRefresh({ iceServers, sfuServer, mediaserverConfigTtlSeconds }: any): void;
810
+ _clearMediaServersRefresh(): void;
811
+ _monitorAudioTrack(track: any): void;
812
+ _monitorVideoTrack(track: CustomMediaStreamTrack): void;
813
+ _connect(clientId: string): Promise<any>;
814
+ _maybeRestartIce(clientId: string, session: any): void;
815
+ _setCodecPreferences(pc: any, vp9On: any, av1On: any, redOn: any): void;
816
+ _negotiatePeerConnection(clientId: string, session: any, constraints?: any): void;
817
+ _withForcedRenegotiation(session: any, action: any): void;
818
+ _changeBandwidthForAllClients(isJoining: boolean): number;
819
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo, isOfferer, enforceTurnProtocol, }: {
820
+ clientId: string;
821
+ initialBandwidth: number;
822
+ shouldAddLocalVideo: boolean;
823
+ isOfferer: boolean;
824
+ enforceTurnProtocol?: TurnTransportProtocol;
825
+ }): any;
826
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }: {
827
+ streamId: string;
828
+ clientId: string;
829
+ shouldAddLocalVideo?: boolean;
830
+ enforceTurnProtocol?: TurnTransportProtocol;
831
+ }): any;
832
+ disconnect(clientId: string): void;
833
+ updateStreamResolution(): void;
834
+ stopOrResumeAudio(): void;
835
+ _handleStopOrResumeVideo({ enable, track }: {
836
+ enable: boolean;
837
+ track: any;
838
+ }): void;
839
+ stopOrResumeVideo(localStream: any, enable: boolean): void;
840
+ _shareScreen(streamId: string, stream: any): void;
841
+ removeStream(streamId: string, stream: any, requestedByClientId: any): void;
842
+ hasClient(clientId: string): boolean;
843
+ }
844
+
839
845
  declare class RtcManagerDispatcher {
840
846
  emitter: {
841
847
  emit: <K extends keyof RtcEvents>(eventName: K, args?: RtcEvents[K]) => void;
@@ -1410,4 +1416,4 @@ declare class RtcStream {
1410
1416
  static getTypeFromId(id: string): string;
1411
1417
  }
1412
1418
 
1413
- export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
1419
+ export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, type TurnTransportProtocol, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
package/dist/index.d.ts CHANGED
@@ -309,140 +309,6 @@ declare function getUpdatedDevices({ oldDevices, newDevices, currentAudioId, cur
309
309
  currentSpeakerId?: string | undefined;
310
310
  }): GetUpdatedDevicesResult;
311
311
 
312
- declare class P2pRtcManager implements RtcManager {
313
- _selfId: any;
314
- _roomName: any;
315
- _roomSessionId: any;
316
- peerConnections: any;
317
- localStreams: any;
318
- enabledLocalStreamIds: any[];
319
- _screenshareVideoTrackIds: any[];
320
- _socketListenerDeregisterFunctions: any[];
321
- _localStreamDeregisterFunction: any;
322
- _emitter: any;
323
- _serverSocket: any;
324
- _webrtcProvider: any;
325
- _features: any;
326
- _isAudioOnlyMode: boolean;
327
- offerOptions: {
328
- offerToReceiveAudio: boolean;
329
- offerToReceiveVideo: boolean;
330
- };
331
- _pendingActionsForConnectedPeerConnections: any[];
332
- _audioTrackOnEnded: () => void;
333
- _videoTrackOnEnded: () => void;
334
- totalSessionsCreated: number;
335
- _iceServers: any;
336
- _sfuServer: any;
337
- _mediaserverConfigTtlSeconds: any;
338
- _fetchMediaServersTimer: any;
339
- _wasScreenSharing: any;
340
- ipv6HostCandidateTeredoSeen: any;
341
- ipv6HostCandidate6to4Seen: any;
342
- mdnsHostCandidateSeen: any;
343
- _lastReverseDirectionAttemptByClientId: any;
344
- _stoppedVideoTrack: any;
345
- icePublicIPGatheringTimeoutID: any;
346
- _videoTrackBeingMonitored?: CustomMediaStreamTrack;
347
- _audioTrackBeingMonitored?: CustomMediaStreamTrack;
348
- constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
349
- selfId: any;
350
- room: any;
351
- emitter: any;
352
- serverSocket: any;
353
- webrtcProvider: any;
354
- features: any;
355
- });
356
- numberOfPeerconnections(): number;
357
- isInitializedWith({ selfId, roomName, isSfu }: {
358
- selfId: any;
359
- roomName: any;
360
- isSfu: any;
361
- }): boolean;
362
- supportsScreenShareAudio(): boolean;
363
- maybeRestrictRelayBandwidth(session: any): void;
364
- addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: CustomMediaStreamTrack[]): void;
365
- replaceTrack(oldTrack: CustomMediaStreamTrack | null, newTrack: CustomMediaStreamTrack): Promise<any[]>;
366
- accept({ clientId, shouldAddLocalVideo }: {
367
- clientId: string;
368
- shouldAddLocalVideo?: boolean;
369
- }): any;
370
- disconnectAll(): void;
371
- fixChromeAudio(constraints: any): Promise<any[]> | undefined;
372
- setupSocketListeners(): void;
373
- sendAudioMutedStats(muted: boolean): void;
374
- sendVideoMutedStats(muted: boolean): void;
375
- sendStatsCustomEvent(eventName: string, data: any): void;
376
- rtcStatsDisconnect(): void;
377
- rtcStatsReconnect(): void;
378
- setAudioOnly(audioOnly: any): void;
379
- setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds?: never[]): void;
380
- setRoomSessionId(roomSessionId: string): void;
381
- _setConnectionStatus(session: any, newStatus: any, clientId: string): void;
382
- _setJitterBufferTarget(pc: any): void;
383
- _emitServerEvent(eventName: string, data?: any, callback?: any): void;
384
- _emit(eventName: string, data?: any): void;
385
- _addEnabledLocalStreamId(streamId: string): void;
386
- _deleteEnabledLocalStreamId(streamId: string): void;
387
- _getSession(peerConnectionId: string): any;
388
- _getOrCreateSession(peerConnectionId: string, initialBandwidth: any): any;
389
- _getLocalCameraStream(): any;
390
- _getNonLocalCameraStreamIds(): string[];
391
- _isScreensharingLocally(): boolean;
392
- _getFirstLocalNonCameraStream(): any;
393
- _transformIncomingSdp(original: any, _: any): {
394
- type: any;
395
- sdp: any;
396
- };
397
- _transformOutgoingSdp(original: any): {
398
- type: any;
399
- sdpU: any;
400
- };
401
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }: {
402
- clientId: string;
403
- initialBandwidth: any;
404
- isOfferer: any;
405
- peerConnectionId: string;
406
- shouldAddLocalVideo: boolean;
407
- }): any;
408
- _cleanup(peerConnectionId: string): void;
409
- _forEachPeerConnection(func: any): void;
410
- _addStreamToPeerConnections(stream: any): void;
411
- _addTrackToPeerConnections(track: any, stream?: any): void;
412
- _replaceTrackToPeerConnections(oldTrack: any, newTrack: any): Promise<any[]>;
413
- _removeStreamFromPeerConnections(stream: any): void;
414
- _removeTrackFromPeerConnections(track: any): void;
415
- _addLocalStream(streamId: string, stream: any): void;
416
- _removeLocalStream(streamId: string): void;
417
- _updateAndScheduleMediaServersRefresh({ iceServers, sfuServer, mediaserverConfigTtlSeconds }: any): void;
418
- _clearMediaServersRefresh(): void;
419
- _monitorAudioTrack(track: any): void;
420
- _monitorVideoTrack(track: CustomMediaStreamTrack): void;
421
- _connect(clientId: string): Promise<any>;
422
- _maybeRestartIce(clientId: string, session: any): void;
423
- _setCodecPreferences(pc: any, vp9On: any, av1On: any, redOn: any): void;
424
- _negotiatePeerConnection(clientId: string, session: any, constraints?: any): void;
425
- _withForcedRenegotiation(session: any, action: any): void;
426
- _changeBandwidthForAllClients(isJoining: boolean): number;
427
- _createP2pSession(clientId: string, initialBandwidth: any, shouldAddLocalVideo: any, isOfferer?: any): any;
428
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }: {
429
- streamId: string;
430
- clientId: string;
431
- shouldAddLocalVideo?: boolean;
432
- }): any;
433
- disconnect(clientId: string): void;
434
- updateStreamResolution(): void;
435
- stopOrResumeAudio(): void;
436
- _handleStopOrResumeVideo({ enable, track }: {
437
- enable: boolean;
438
- track: any;
439
- }): void;
440
- stopOrResumeVideo(localStream: any, enable: boolean): void;
441
- _shareScreen(streamId: string, stream: any): void;
442
- removeStream(streamId: string, stream: any, requestedByClientId: any): void;
443
- hasClient(clientId: string): boolean;
444
- }
445
-
446
312
  declare const assert: {
447
313
  fail: (message?: string | Error) => void;
448
314
  ok: (value: any, message?: string | Error) => void;
@@ -823,6 +689,7 @@ interface SignalRequests {
823
689
  };
824
690
  stop_recording: void;
825
691
  }
692
+ type TurnTransportProtocol = "onlyudp" | "onlytcp" | "onlytls";
826
693
 
827
694
  declare function fromLocation({ host, protocol }?: {
828
695
  host?: string | undefined;
@@ -836,6 +703,145 @@ declare function fromLocation({ host, protocol }?: {
836
703
  subdomain: string;
837
704
  };
838
705
 
706
+ declare class P2pRtcManager implements RtcManager {
707
+ _selfId: any;
708
+ _roomName: any;
709
+ _roomSessionId: any;
710
+ peerConnections: any;
711
+ localStreams: any;
712
+ enabledLocalStreamIds: any[];
713
+ _screenshareVideoTrackIds: any[];
714
+ _socketListenerDeregisterFunctions: any[];
715
+ _localStreamDeregisterFunction: any;
716
+ _emitter: any;
717
+ _serverSocket: any;
718
+ _webrtcProvider: any;
719
+ _features: any;
720
+ _isAudioOnlyMode: boolean;
721
+ offerOptions: {
722
+ offerToReceiveAudio: boolean;
723
+ offerToReceiveVideo: boolean;
724
+ };
725
+ _pendingActionsForConnectedPeerConnections: any[];
726
+ _audioTrackOnEnded: () => void;
727
+ _videoTrackOnEnded: () => void;
728
+ totalSessionsCreated: number;
729
+ _iceServers: any;
730
+ _sfuServer: any;
731
+ _mediaserverConfigTtlSeconds: any;
732
+ _fetchMediaServersTimer: any;
733
+ _wasScreenSharing: any;
734
+ ipv6HostCandidateTeredoSeen: any;
735
+ ipv6HostCandidate6to4Seen: any;
736
+ mdnsHostCandidateSeen: any;
737
+ _lastReverseDirectionAttemptByClientId: any;
738
+ _stoppedVideoTrack: any;
739
+ icePublicIPGatheringTimeoutID: any;
740
+ _videoTrackBeingMonitored?: CustomMediaStreamTrack;
741
+ _audioTrackBeingMonitored?: CustomMediaStreamTrack;
742
+ _nodeJsClients: string[];
743
+ constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
744
+ selfId: any;
745
+ room: any;
746
+ emitter: any;
747
+ serverSocket: any;
748
+ webrtcProvider: any;
749
+ features: any;
750
+ });
751
+ numberOfPeerconnections(): number;
752
+ isInitializedWith({ selfId, roomName, isSfu }: {
753
+ selfId: any;
754
+ roomName: any;
755
+ isSfu: any;
756
+ }): boolean;
757
+ supportsScreenShareAudio(): boolean;
758
+ maybeRestrictRelayBandwidth(session: any): void;
759
+ addNewStream(streamId: string, stream: MediaStream, audioPaused: boolean, videoPaused: boolean, beforeEffectTracks?: CustomMediaStreamTrack[]): void;
760
+ replaceTrack(oldTrack: CustomMediaStreamTrack | null, newTrack: CustomMediaStreamTrack): Promise<any[]>;
761
+ disconnectAll(): void;
762
+ fixChromeAudio(constraints: any): Promise<any[]> | undefined;
763
+ setupSocketListeners(): void;
764
+ sendAudioMutedStats(muted: boolean): void;
765
+ sendVideoMutedStats(muted: boolean): void;
766
+ sendStatsCustomEvent(eventName: string, data: any): void;
767
+ rtcStatsDisconnect(): void;
768
+ rtcStatsReconnect(): void;
769
+ setAudioOnly(audioOnly: any): void;
770
+ setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds?: never[]): void;
771
+ setRoomSessionId(roomSessionId: string): void;
772
+ _setConnectionStatus(session: any, newStatus: any, clientId: string): void;
773
+ _setJitterBufferTarget(pc: any): void;
774
+ _emitServerEvent(eventName: string, data?: any, callback?: any): void;
775
+ _emit(eventName: string, data?: any): void;
776
+ _addEnabledLocalStreamId(streamId: string): void;
777
+ _deleteEnabledLocalStreamId(streamId: string): void;
778
+ _getSession(peerConnectionId: string): any;
779
+ _getOrCreateSession(peerConnectionId: string, initialBandwidth: any): any;
780
+ _getLocalCameraStream(): any;
781
+ _getNonLocalCameraStreamIds(): string[];
782
+ _isScreensharingLocally(): boolean;
783
+ _getFirstLocalNonCameraStream(): any;
784
+ _transformIncomingSdp(original: any, _: any): {
785
+ type: any;
786
+ sdp: any;
787
+ };
788
+ _transformOutgoingSdp(original: any): {
789
+ type: any;
790
+ sdpU: any;
791
+ };
792
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }: {
793
+ clientId: string;
794
+ initialBandwidth: any;
795
+ isOfferer: any;
796
+ peerConnectionId: string;
797
+ shouldAddLocalVideo: boolean;
798
+ enforceTurnProtocol?: TurnTransportProtocol;
799
+ }): any;
800
+ _cleanup(peerConnectionId: string): void;
801
+ _forEachPeerConnection(func: any): void;
802
+ _addStreamToPeerConnections(stream: any): void;
803
+ _addTrackToPeerConnections(track: any, stream?: any): void;
804
+ _replaceTrackToPeerConnections(oldTrack: any, newTrack: any): Promise<any[]>;
805
+ _removeStreamFromPeerConnections(stream: any): void;
806
+ _removeTrackFromPeerConnections(track: any): void;
807
+ _addLocalStream(streamId: string, stream: any): void;
808
+ _removeLocalStream(streamId: string): void;
809
+ _updateAndScheduleMediaServersRefresh({ iceServers, sfuServer, mediaserverConfigTtlSeconds }: any): void;
810
+ _clearMediaServersRefresh(): void;
811
+ _monitorAudioTrack(track: any): void;
812
+ _monitorVideoTrack(track: CustomMediaStreamTrack): void;
813
+ _connect(clientId: string): Promise<any>;
814
+ _maybeRestartIce(clientId: string, session: any): void;
815
+ _setCodecPreferences(pc: any, vp9On: any, av1On: any, redOn: any): void;
816
+ _negotiatePeerConnection(clientId: string, session: any, constraints?: any): void;
817
+ _withForcedRenegotiation(session: any, action: any): void;
818
+ _changeBandwidthForAllClients(isJoining: boolean): number;
819
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo, isOfferer, enforceTurnProtocol, }: {
820
+ clientId: string;
821
+ initialBandwidth: number;
822
+ shouldAddLocalVideo: boolean;
823
+ isOfferer: boolean;
824
+ enforceTurnProtocol?: TurnTransportProtocol;
825
+ }): any;
826
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }: {
827
+ streamId: string;
828
+ clientId: string;
829
+ shouldAddLocalVideo?: boolean;
830
+ enforceTurnProtocol?: TurnTransportProtocol;
831
+ }): any;
832
+ disconnect(clientId: string): void;
833
+ updateStreamResolution(): void;
834
+ stopOrResumeAudio(): void;
835
+ _handleStopOrResumeVideo({ enable, track }: {
836
+ enable: boolean;
837
+ track: any;
838
+ }): void;
839
+ stopOrResumeVideo(localStream: any, enable: boolean): void;
840
+ _shareScreen(streamId: string, stream: any): void;
841
+ removeStream(streamId: string, stream: any, requestedByClientId: any): void;
842
+ hasClient(clientId: string): boolean;
843
+ }
844
+
839
845
  declare class RtcManagerDispatcher {
840
846
  emitter: {
841
847
  emit: <K extends keyof RtcEvents>(eventName: K, args?: RtcEvents[K]) => void;
@@ -1410,4 +1416,4 @@ declare class RtcStream {
1410
1416
  static getTypeFromId(id: string): string;
1411
1417
  }
1412
1418
 
1413
- export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
1419
+ export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, type TurnTransportProtocol, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
package/dist/index.mjs CHANGED
@@ -3527,6 +3527,7 @@ class P2pRtcManager {
3527
3527
  this._isAudioOnlyMode = false;
3528
3528
  this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
3529
3529
  this._pendingActionsForConnectedPeerConnections = [];
3530
+ this._nodeJsClients = [];
3530
3531
  this._audioTrackOnEnded = () => {
3531
3532
  rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
3532
3533
  this._emit(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
@@ -3608,9 +3609,6 @@ class P2pRtcManager {
3608
3609
  }
3609
3610
  return this._replaceTrackToPeerConnections(oldTrack, newTrack);
3610
3611
  }
3611
- accept({ clientId, shouldAddLocalVideo }) {
3612
- return this.acceptNewStream({ streamId: clientId, clientId, shouldAddLocalVideo });
3613
- }
3614
3612
  disconnectAll() {
3615
3613
  Object.keys(this.peerConnections).forEach((peerConnectionId) => {
3616
3614
  this.disconnect(peerConnectionId);
@@ -3645,6 +3643,11 @@ class P2pRtcManager {
3645
3643
  setupSocketListeners() {
3646
3644
  this._socketListenerDeregisterFunctions = [
3647
3645
  () => this._clearMediaServersRefresh(),
3646
+ this._serverSocket.on(PROTOCOL_RESPONSES.NEW_CLIENT, (data) => {
3647
+ if (data.client.isDialIn && !this._nodeJsClients.includes(data.client.id)) {
3648
+ this._nodeJsClients.push(data.client.id);
3649
+ }
3650
+ }),
3648
3651
  this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
3649
3652
  if (data.error) {
3650
3653
  logger$4.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
@@ -3842,7 +3845,7 @@ class P2pRtcManager {
3842
3845
  _transformOutgoingSdp(original) {
3843
3846
  return { type: original.type, sdpU: original.sdp };
3844
3847
  }
3845
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
3848
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }) {
3846
3849
  if (!peerConnectionId) {
3847
3850
  throw new Error("peerConnectionId is missing");
3848
3851
  }
@@ -3878,13 +3881,13 @@ class P2pRtcManager {
3878
3881
  return entry;
3879
3882
  });
3880
3883
  }
3881
- if (this._features.useOnlyTURN) {
3884
+ if (enforceTurnProtocol || this._features.useOnlyTURN) {
3882
3885
  peerConnectionConfig.iceTransportPolicy = "relay";
3883
3886
  const filter = {
3884
3887
  onlyudp: /^turn:.*transport=udp$/,
3885
3888
  onlytcp: /^turn:.*transport=tcp$/,
3886
3889
  onlytls: /^turns:.*transport=tcp$/,
3887
- }[this._features.useOnlyTURN];
3890
+ }[enforceTurnProtocol || this._features.useOnlyTURN];
3888
3891
  if (filter) {
3889
3892
  peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter((entry) => entry.url && entry.url.match(filter));
3890
3893
  }
@@ -4136,17 +4139,26 @@ class P2pRtcManager {
4136
4139
  }
4137
4140
  _connect(clientId) {
4138
4141
  this.rtcStatsReconnect();
4139
- const shouldAddLocalVideo = true;
4140
4142
  let session = this._getSession(clientId);
4141
- let bandwidth = (session && session.bandwidth) || 0;
4143
+ let initialBandwidth = (session && session.bandwidth) || 0;
4142
4144
  if (session) {
4143
4145
  logger$4.warn("Replacing peer session", clientId);
4144
4146
  this._cleanup(clientId);
4145
4147
  }
4146
4148
  else {
4147
- bandwidth = this._changeBandwidthForAllClients(true);
4149
+ initialBandwidth = this._changeBandwidthForAllClients(true);
4148
4150
  }
4149
- session = this._createP2pSession(clientId, bandwidth, shouldAddLocalVideo, true);
4151
+ let enforceTurnProtocol;
4152
+ if (this._nodeJsClients.includes(clientId)) {
4153
+ enforceTurnProtocol = this._features.isNodeSdk ? "onlyudp" : "onlytls";
4154
+ }
4155
+ session = this._createP2pSession({
4156
+ clientId,
4157
+ initialBandwidth,
4158
+ shouldAddLocalVideo: true,
4159
+ isOfferer: true,
4160
+ enforceTurnProtocol,
4161
+ });
4150
4162
  this._negotiatePeerConnection(clientId, session);
4151
4163
  return Promise.resolve(session);
4152
4164
  }
@@ -4317,13 +4329,14 @@ class P2pRtcManager {
4317
4329
  });
4318
4330
  return bandwidth;
4319
4331
  }
4320
- _createP2pSession(clientId, initialBandwidth, shouldAddLocalVideo, isOfferer) {
4332
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, enforceTurnProtocol, }) {
4321
4333
  const session = this._createSession({
4322
4334
  peerConnectionId: clientId,
4323
4335
  clientId,
4324
4336
  initialBandwidth,
4325
4337
  shouldAddLocalVideo,
4326
4338
  isOfferer,
4339
+ enforceTurnProtocol,
4327
4340
  });
4328
4341
  const pc = session.pc;
4329
4342
  if (this._features.increaseIncomingMediaBufferOn) {
@@ -4437,20 +4450,26 @@ class P2pRtcManager {
4437
4450
  };
4438
4451
  return session;
4439
4452
  }
4440
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
4453
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }) {
4441
4454
  let session = this._getSession(clientId);
4442
4455
  if (session && streamId !== clientId) {
4443
4456
  return session;
4444
4457
  }
4445
- let bandwidth = (session && session.bandwidth) || 0;
4458
+ let initialBandwidth = (session && session.bandwidth) || 0;
4446
4459
  if (session) {
4447
4460
  logger$4.warn("Replacing peer session", clientId);
4448
4461
  this._cleanup(clientId);
4449
4462
  }
4450
4463
  else {
4451
- bandwidth = this._changeBandwidthForAllClients(true);
4464
+ initialBandwidth = this._changeBandwidthForAllClients(true);
4452
4465
  }
4453
- session = this._createP2pSession(clientId, bandwidth, shouldAddLocalVideo);
4466
+ session = this._createP2pSession({
4467
+ clientId,
4468
+ initialBandwidth,
4469
+ shouldAddLocalVideo: !!shouldAddLocalVideo,
4470
+ enforceTurnProtocol,
4471
+ isOfferer: false,
4472
+ });
4454
4473
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
4455
4474
  receiverId: clientId,
4456
4475
  });
@@ -3527,6 +3527,7 @@ class P2pRtcManager {
3527
3527
  this._isAudioOnlyMode = false;
3528
3528
  this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
3529
3529
  this._pendingActionsForConnectedPeerConnections = [];
3530
+ this._nodeJsClients = [];
3530
3531
  this._audioTrackOnEnded = () => {
3531
3532
  rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
3532
3533
  this._emit(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
@@ -3608,9 +3609,6 @@ class P2pRtcManager {
3608
3609
  }
3609
3610
  return this._replaceTrackToPeerConnections(oldTrack, newTrack);
3610
3611
  }
3611
- accept({ clientId, shouldAddLocalVideo }) {
3612
- return this.acceptNewStream({ streamId: clientId, clientId, shouldAddLocalVideo });
3613
- }
3614
3612
  disconnectAll() {
3615
3613
  Object.keys(this.peerConnections).forEach((peerConnectionId) => {
3616
3614
  this.disconnect(peerConnectionId);
@@ -3645,6 +3643,11 @@ class P2pRtcManager {
3645
3643
  setupSocketListeners() {
3646
3644
  this._socketListenerDeregisterFunctions = [
3647
3645
  () => this._clearMediaServersRefresh(),
3646
+ this._serverSocket.on(PROTOCOL_RESPONSES.NEW_CLIENT, (data) => {
3647
+ if (data.client.isDialIn && !this._nodeJsClients.includes(data.client.id)) {
3648
+ this._nodeJsClients.push(data.client.id);
3649
+ }
3650
+ }),
3648
3651
  this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
3649
3652
  if (data.error) {
3650
3653
  logger$4.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
@@ -3842,7 +3845,7 @@ class P2pRtcManager {
3842
3845
  _transformOutgoingSdp(original) {
3843
3846
  return { type: original.type, sdpU: original.sdp };
3844
3847
  }
3845
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
3848
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }) {
3846
3849
  if (!peerConnectionId) {
3847
3850
  throw new Error("peerConnectionId is missing");
3848
3851
  }
@@ -3878,13 +3881,13 @@ class P2pRtcManager {
3878
3881
  return entry;
3879
3882
  });
3880
3883
  }
3881
- if (this._features.useOnlyTURN) {
3884
+ if (enforceTurnProtocol || this._features.useOnlyTURN) {
3882
3885
  peerConnectionConfig.iceTransportPolicy = "relay";
3883
3886
  const filter = {
3884
3887
  onlyudp: /^turn:.*transport=udp$/,
3885
3888
  onlytcp: /^turn:.*transport=tcp$/,
3886
3889
  onlytls: /^turns:.*transport=tcp$/,
3887
- }[this._features.useOnlyTURN];
3890
+ }[enforceTurnProtocol || this._features.useOnlyTURN];
3888
3891
  if (filter) {
3889
3892
  peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter((entry) => entry.url && entry.url.match(filter));
3890
3893
  }
@@ -4136,17 +4139,26 @@ class P2pRtcManager {
4136
4139
  }
4137
4140
  _connect(clientId) {
4138
4141
  this.rtcStatsReconnect();
4139
- const shouldAddLocalVideo = true;
4140
4142
  let session = this._getSession(clientId);
4141
- let bandwidth = (session && session.bandwidth) || 0;
4143
+ let initialBandwidth = (session && session.bandwidth) || 0;
4142
4144
  if (session) {
4143
4145
  logger$4.warn("Replacing peer session", clientId);
4144
4146
  this._cleanup(clientId);
4145
4147
  }
4146
4148
  else {
4147
- bandwidth = this._changeBandwidthForAllClients(true);
4149
+ initialBandwidth = this._changeBandwidthForAllClients(true);
4148
4150
  }
4149
- session = this._createP2pSession(clientId, bandwidth, shouldAddLocalVideo, true);
4151
+ let enforceTurnProtocol;
4152
+ if (this._nodeJsClients.includes(clientId)) {
4153
+ enforceTurnProtocol = this._features.isNodeSdk ? "onlyudp" : "onlytls";
4154
+ }
4155
+ session = this._createP2pSession({
4156
+ clientId,
4157
+ initialBandwidth,
4158
+ shouldAddLocalVideo: true,
4159
+ isOfferer: true,
4160
+ enforceTurnProtocol,
4161
+ });
4150
4162
  this._negotiatePeerConnection(clientId, session);
4151
4163
  return Promise.resolve(session);
4152
4164
  }
@@ -4317,13 +4329,14 @@ class P2pRtcManager {
4317
4329
  });
4318
4330
  return bandwidth;
4319
4331
  }
4320
- _createP2pSession(clientId, initialBandwidth, shouldAddLocalVideo, isOfferer) {
4332
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, enforceTurnProtocol, }) {
4321
4333
  const session = this._createSession({
4322
4334
  peerConnectionId: clientId,
4323
4335
  clientId,
4324
4336
  initialBandwidth,
4325
4337
  shouldAddLocalVideo,
4326
4338
  isOfferer,
4339
+ enforceTurnProtocol,
4327
4340
  });
4328
4341
  const pc = session.pc;
4329
4342
  if (this._features.increaseIncomingMediaBufferOn) {
@@ -4437,20 +4450,26 @@ class P2pRtcManager {
4437
4450
  };
4438
4451
  return session;
4439
4452
  }
4440
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
4453
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }) {
4441
4454
  let session = this._getSession(clientId);
4442
4455
  if (session && streamId !== clientId) {
4443
4456
  return session;
4444
4457
  }
4445
- let bandwidth = (session && session.bandwidth) || 0;
4458
+ let initialBandwidth = (session && session.bandwidth) || 0;
4446
4459
  if (session) {
4447
4460
  logger$4.warn("Replacing peer session", clientId);
4448
4461
  this._cleanup(clientId);
4449
4462
  }
4450
4463
  else {
4451
- bandwidth = this._changeBandwidthForAllClients(true);
4464
+ initialBandwidth = this._changeBandwidthForAllClients(true);
4452
4465
  }
4453
- session = this._createP2pSession(clientId, bandwidth, shouldAddLocalVideo);
4466
+ session = this._createP2pSession({
4467
+ clientId,
4468
+ initialBandwidth,
4469
+ shouldAddLocalVideo: !!shouldAddLocalVideo,
4470
+ enforceTurnProtocol,
4471
+ isOfferer: false,
4472
+ });
4454
4473
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
4455
4474
  receiverId: clientId,
4456
4475
  });
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": "1.11.1",
4
+ "version": "1.12.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {
@@ -12,6 +12,7 @@
12
12
  "url": "https://github.com/whereby/sdk/issues"
13
13
  },
14
14
  "scripts": {
15
+ "clean": "rimraf dist node_modules .turbo",
15
16
  "build": "rimraf dist && rollup -c rollup.config.js",
16
17
  "test": "npm run test:lint && npm run test:unit",
17
18
  "test:unit": "jest",