@whereby.com/media 2.6.7 → 2.6.9

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
@@ -2167,7 +2167,7 @@ var _a$4;
2167
2167
  const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
2168
2168
  const logger$7 = new Logger();
2169
2169
  class Session {
2170
- constructor({ peerConnectionId, bandwidth, deprioritizeH264Encoding, incrementAnalyticMetric, }) {
2170
+ constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, shouldAddLocalVideo, incrementAnalyticMetric, }) {
2171
2171
  this.peerConnectionId = peerConnectionId;
2172
2172
  this.relayCandidateSeen = false;
2173
2173
  this.serverReflexiveCandidateSeen = false;
@@ -2176,7 +2176,24 @@ class Session {
2176
2176
  this.ipv6HostCandidateTeredoSeen = false;
2177
2177
  this.ipv6HostCandidate6to4Seen = false;
2178
2178
  this.mdnsHostCandidateSeen = false;
2179
- this.pc = null;
2179
+ this.peerConnectionConfig = peerConnectionConfig;
2180
+ this.shouldAddLocalVideo = shouldAddLocalVideo;
2181
+ this.clientId = clientId;
2182
+ this.pc = new RTCPeerConnection(this.peerConnectionConfig);
2183
+ this.signalingState = this.pc.signalingState;
2184
+ this.pc.addEventListener("signalingstatechange", () => {
2185
+ if (this.signalingState === this.pc.signalingState) {
2186
+ return;
2187
+ }
2188
+ this.signalingState = this.pc.signalingState;
2189
+ if (this.pc.signalingState === "stable") {
2190
+ this.isOperationPending = false;
2191
+ const action = this.pending.shift();
2192
+ if (action) {
2193
+ action.apply();
2194
+ }
2195
+ }
2196
+ });
2180
2197
  this.wasEverConnected = false;
2181
2198
  this.connectionStatus = null;
2182
2199
  this.stats = {
@@ -2196,27 +2213,6 @@ class Session {
2196
2213
  this._deprioritizeH264Encoding = deprioritizeH264Encoding;
2197
2214
  this._incrementAnalyticMetric = incrementAnalyticMetric;
2198
2215
  }
2199
- setAndGetPeerConnection({ clientId, constraints, peerConnectionConfig, shouldAddLocalVideo, }) {
2200
- this.peerConnectionConfig = peerConnectionConfig;
2201
- this.shouldAddLocalVideo = shouldAddLocalVideo;
2202
- this.clientId = clientId;
2203
- this.pc = new RTCPeerConnection(peerConnectionConfig);
2204
- this.signalingState = this.pc.signalingState;
2205
- this.pc.addEventListener("signalingstatechange", () => {
2206
- if (this.signalingState === this.pc.signalingState) {
2207
- return;
2208
- }
2209
- this.signalingState = this.pc.signalingState;
2210
- if (this.pc.signalingState === "stable") {
2211
- this.isOperationPending = false;
2212
- const action = this.pending.shift();
2213
- if (action) {
2214
- action.apply();
2215
- }
2216
- }
2217
- });
2218
- return this.pc;
2219
- }
2220
2216
  addStream(stream) {
2221
2217
  this.streamIds.push(stream.id);
2222
2218
  this.streams.push(stream);
@@ -2309,8 +2305,6 @@ class Session {
2309
2305
  const desc = { type: message.type, sdp };
2310
2306
  return this._setRemoteDescription(desc).then(() => {
2311
2307
  return setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
2312
- }, (e) => {
2313
- logger$7.warn("Could not set remote description from remote answer: ", e);
2314
2308
  });
2315
2309
  }
2316
2310
  addIceCandidate(candidate) {
@@ -2353,7 +2347,7 @@ class Session {
2353
2347
  return this.pc && this.pc.connectionState === "connected";
2354
2348
  }
2355
2349
  replaceTrack(oldTrack, newTrack) {
2356
- var _a;
2350
+ var _a, _b;
2357
2351
  const pc = this.pc;
2358
2352
  if (!pc) {
2359
2353
  rtcStats.sendEvent("P2PReplaceTrackNoPC", {
@@ -2444,11 +2438,12 @@ class Session {
2444
2438
  setTimeout(() => {
2445
2439
  pc.onnegotiationneeded = onn;
2446
2440
  }, 0);
2447
- if (pc.localDescription.type === "offer") {
2441
+ if (((_b = pc.localDescription) === null || _b === void 0 ? void 0 : _b.type) === "offer") {
2448
2442
  return pc
2449
2443
  .createOffer()
2450
2444
  .then((offer) => {
2451
- offer.sdp = replaceSSRCs(pc.localDescription.sdp, offer.sdp);
2445
+ var _a;
2446
+ offer.sdp = replaceSSRCs((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp, offer.sdp);
2452
2447
  return pc.setLocalDescription(offer);
2453
2448
  })
2454
2449
  .then(() => {
@@ -2461,12 +2456,14 @@ class Session {
2461
2456
  return pc.createAnswer();
2462
2457
  })
2463
2458
  .then((answer) => {
2464
- answer.sdp = replaceSSRCs(pc.localDescription.sdp, answer.sdp);
2459
+ var _a;
2460
+ answer.sdp = replaceSSRCs((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp, answer.sdp);
2465
2461
  return pc.setLocalDescription(answer);
2466
2462
  });
2467
2463
  }
2468
2464
  }
2469
2465
  changeBandwidth(bandwidth) {
2466
+ var _a;
2470
2467
  if (bandwidth === this.bandwidth) {
2471
2468
  return;
2472
2469
  }
@@ -2475,22 +2472,24 @@ class Session {
2475
2472
  return;
2476
2473
  }
2477
2474
  this.bandwidth = bandwidth;
2478
- if (!this.pc.localDescription || this.pc.localDescription.type === "") {
2475
+ if (((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "") {
2476
+ this._incrementAnalyticMetric("P2PChangeBandwidthEmptySDPType");
2477
+ return;
2478
+ }
2479
+ if (!this.pc.localDescription) {
2479
2480
  return;
2480
2481
  }
2481
2482
  setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
2482
2483
  }
2483
2484
  setAudioOnly(enable, excludedTrackIds = []) {
2484
- this.pc
2485
- .getTransceivers()
2486
- .filter((videoTransceiver) => {
2485
+ var _a;
2486
+ (_a = this.pc) === null || _a === void 0 ? void 0 : _a.getTransceivers().filter((videoTransceiver) => {
2487
2487
  var _a, _b, _c, _d, _e, _f;
2488
2488
  return (videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.direction) !== "recvonly" &&
2489
2489
  ((_b = (_a = videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.receiver) === null || _a === void 0 ? void 0 : _a.track) === null || _b === void 0 ? void 0 : _b.kind) === "video" &&
2490
2490
  !excludedTrackIds.includes((_d = (_c = videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.receiver) === null || _c === void 0 ? void 0 : _c.track) === null || _d === void 0 ? void 0 : _d.id) &&
2491
2491
  !excludedTrackIds.includes((_f = (_e = videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.sender) === null || _e === void 0 ? void 0 : _e.track) === null || _f === void 0 ? void 0 : _f.id);
2492
- })
2493
- .forEach((videoTransceiver) => {
2492
+ }).forEach((videoTransceiver) => {
2494
2493
  videoTransceiver.direction = enable ? "sendonly" : "sendrecv";
2495
2494
  });
2496
2495
  }
@@ -2611,9 +2610,6 @@ var rtcManagerEvents = {
2611
2610
  SFU_CONNECTION_INFO: "sfu_connection_info",
2612
2611
  COLOCATION_SPEAKER: "colocation_speaker",
2613
2612
  DOMINANT_SPEAKER: "dominant_speaker",
2614
- PC_SLD_FAILURE: "pc_sld_failure",
2615
- PC_ON_ANSWER_FAILURE: "pc_on_answer_failure",
2616
- PC_ON_OFFER_FAILURE: "pc_on_offer_failure",
2617
2613
  };
2618
2614
 
2619
2615
  var _a$2, _b$1, _c;
@@ -2656,10 +2652,12 @@ class P2pRtcManager {
2656
2652
  this._audioTrackOnEnded = () => {
2657
2653
  rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
2658
2654
  this._emit(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
2655
+ this.analytics.micTrackEndedCount++;
2659
2656
  };
2660
2657
  this._videoTrackOnEnded = () => {
2661
2658
  rtcStats.sendEvent("video_ended", { unloading: unloading$1 });
2662
2659
  this._emit(rtcManagerEvents.CAMERA_STOPPED_WORKING, {});
2660
+ this.analytics.camTrackEndedCount++;
2663
2661
  };
2664
2662
  this._updateAndScheduleMediaServersRefresh({
2665
2663
  sfuServer,
@@ -2680,6 +2678,14 @@ class P2pRtcManager {
2680
2678
  numIceIpv6TeredoSeen: 0,
2681
2679
  numIceIpv6SixToFour: 0,
2682
2680
  numIceMdnsSeen: 0,
2681
+ micTrackEndedCount: 0,
2682
+ camTrackEndedCount: 0,
2683
+ numPcSldFailure: 0,
2684
+ numPcOnAnswerFailure: 0,
2685
+ numPcOnOfferFailure: 0,
2686
+ P2PChangeBandwidthEmptySDPType: 0,
2687
+ P2PNegotiationNeeded: 0,
2688
+ P2PSessionAlreadyCreated: 0,
2683
2689
  };
2684
2690
  }
2685
2691
  numberOfPeerconnections() {
@@ -2799,7 +2805,7 @@ class P2pRtcManager {
2799
2805
  logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
2800
2806
  return;
2801
2807
  }
2802
- const offer = this._transformIncomingSdp(data.message, session.pc);
2808
+ const offer = this._transformIncomingSdp(data.message);
2803
2809
  (_b = (_a = session
2804
2810
  .handleOffer(offer)
2805
2811
  .then((answer) => {
@@ -2808,7 +2814,7 @@ class P2pRtcManager {
2808
2814
  message: this._transformOutgoingSdp(answer),
2809
2815
  });
2810
2816
  })).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
2811
- this._emit(rtcManagerEvents.PC_ON_OFFER_FAILURE, e);
2817
+ this.analytics.numPcOnOfferFailure++;
2812
2818
  });
2813
2819
  }),
2814
2820
  this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
@@ -2818,9 +2824,10 @@ class P2pRtcManager {
2818
2824
  logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
2819
2825
  return;
2820
2826
  }
2821
- const answer = this._transformIncomingSdp(data.message, session.pc);
2827
+ const answer = this._transformIncomingSdp(data.message);
2822
2828
  (_b = (_a = session.handleAnswer(answer)) === null || _a === void 0 ? void 0 : _a.catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
2823
- this._emit(rtcManagerEvents.PC_ON_ANSWER_FAILURE, e);
2829
+ logger$6.warn("Could not set remote description from remote answer: ", e);
2830
+ this.analytics.numPcOnAnswerFailure++;
2824
2831
  });
2825
2832
  }),
2826
2833
  this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, (payload) => {
@@ -2956,7 +2963,7 @@ class P2pRtcManager {
2956
2963
  }
2957
2964
  return this.peerConnections[peerConnectionId];
2958
2965
  }
2959
- _getOrCreateSession(peerConnectionId, initialBandwidth) {
2966
+ _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, shouldAddLocalVideo, }) {
2960
2967
  let session = this.peerConnections[peerConnectionId];
2961
2968
  if (session === undefined) {
2962
2969
  const deprioritizeH264Encoding = browserName$1 === "safari" &&
@@ -2965,12 +2972,22 @@ class P2pRtcManager {
2965
2972
  this._features.deprioritizeH264OnSafari;
2966
2973
  this.peerConnections[peerConnectionId] = session = new Session({
2967
2974
  peerConnectionId,
2975
+ clientId,
2976
+ peerConnectionConfig,
2968
2977
  bandwidth: initialBandwidth,
2969
2978
  deprioritizeH264Encoding,
2979
+ shouldAddLocalVideo,
2970
2980
  incrementAnalyticMetric: (metric) => this.analytics[metric]++,
2971
2981
  });
2972
2982
  this.totalSessionsCreated++;
2973
2983
  }
2984
+ else {
2985
+ this.analytics.P2PSessionAlreadyCreated++;
2986
+ rtcStats.sendEvent("P2PSessionAlreadyCreated", {
2987
+ clientId,
2988
+ peerConnectionId,
2989
+ });
2990
+ }
2974
2991
  return session;
2975
2992
  }
2976
2993
  _getLocalCameraStream() {
@@ -2986,7 +3003,7 @@ class P2pRtcManager {
2986
3003
  const streamIds = this._getNonLocalCameraStreamIds();
2987
3004
  return streamIds.length === 0 ? null : this.localStreams[streamIds[0]];
2988
3005
  }
2989
- _transformIncomingSdp(original, _) {
3006
+ _transformIncomingSdp(original) {
2990
3007
  return { type: original.type, sdp: original.sdpU };
2991
3008
  }
2992
3009
  _transformOutgoingSdp(original) {
@@ -2999,34 +3016,33 @@ class P2pRtcManager {
2999
3016
  if (!clientId) {
3000
3017
  throw new Error("clientId is missing");
3001
3018
  }
3002
- const session = this._getOrCreateSession(peerConnectionId, initialBandwidth);
3019
+ const peerConnectionConfig = {
3020
+ iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
3021
+ };
3003
3022
  const constraints = { optional: [] };
3023
+ constraints.optional.push({ rtcStatsRoomSessionId: this._roomSessionId });
3024
+ constraints.optional.push({ rtcStatsClientId: this._selfId });
3025
+ constraints.optional.push({ rtcStatsPeerId: peerConnectionId });
3026
+ constraints.optional.push({ rtcStatsConferenceId: this._roomName });
3004
3027
  if (browserName$1 === "chrome") {
3005
3028
  constraints.optional.push({
3006
3029
  googCpuOveruseDetection: true,
3007
3030
  });
3031
+ peerConnectionConfig.sdpSemantics = "unified-plan";
3008
3032
  }
3009
- constraints.optional.push({ rtcStatsRoomSessionId: this._roomSessionId });
3010
- constraints.optional.push({ rtcStatsClientId: this._selfId });
3011
- constraints.optional.push({ rtcStatsPeerId: peerConnectionId });
3012
- constraints.optional.push({ rtcStatsConferenceId: this._roomName });
3013
- const peerConnectionConfig = {
3014
- iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
3015
- };
3016
3033
  peerConnectionConfig.iceServers = turnServerOverride(peerConnectionConfig.iceServers, this._features.turnServerOverrideHost);
3017
3034
  external_stun_servers(peerConnectionConfig, this._features);
3018
3035
  maybeTurnOnly(peerConnectionConfig, this._features);
3019
- if (browserName$1 === "chrome") {
3020
- peerConnectionConfig.sdpSemantics = "unified-plan";
3021
- }
3022
- const pc = session.setAndGetPeerConnection({
3023
- constraints,
3036
+ const session = this._getOrCreateSession({
3037
+ peerConnectionId,
3038
+ clientId,
3039
+ initialBandwidth,
3024
3040
  peerConnectionConfig,
3025
3041
  shouldAddLocalVideo,
3026
- clientId,
3027
3042
  });
3028
3043
  setTimeout(() => this._emit(rtcManagerEvents.NEW_PC), 0);
3029
3044
  this.analytics.numNewPc++;
3045
+ const { pc } = session;
3030
3046
  pc.ontrack = (event) => {
3031
3047
  const stream = event.streams[0];
3032
3048
  if (stream.id === "default" && stream.getAudioTracks().length === 0) {
@@ -3369,7 +3385,7 @@ class P2pRtcManager {
3369
3385
  pc.setLocalDescription(offer)
3370
3386
  .catch((e) => {
3371
3387
  logger$6.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
3372
- this._emit(rtcManagerEvents.PC_SLD_FAILURE, e);
3388
+ this.analytics.numPcSldFailure++;
3373
3389
  throw e;
3374
3390
  })
3375
3391
  .then(() => {
@@ -3385,7 +3401,7 @@ class P2pRtcManager {
3385
3401
  }
3386
3402
  _withForcedRenegotiation(session, action) {
3387
3403
  const pc = session.pc;
3388
- const originalOnnegotationneeded = pc.onnegotationneeded;
3404
+ const originalOnnegotationneeded = pc.onnegotiationneeded;
3389
3405
  pc.onnegotiationneeded = null;
3390
3406
  action();
3391
3407
  this._negotiatePeerConnection(session.clientId, session);
@@ -3450,7 +3466,7 @@ class P2pRtcManager {
3450
3466
  if (!session.publicHostCandidateSeen &&
3451
3467
  !session.relayCandidateSeen &&
3452
3468
  !session.serverReflexiveCandidateSeen) {
3453
- if (pc.iceConnectionState !== "connected" || pc.iceConnectionState !== "completed")
3469
+ if (pc.iceConnectionState !== "connected" && pc.iceConnectionState !== "completed")
3454
3470
  this.analytics.numIceNoPublicIpGatheredIn3sec++;
3455
3471
  }
3456
3472
  }, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
@@ -3534,6 +3550,8 @@ class P2pRtcManager {
3534
3550
  }
3535
3551
  };
3536
3552
  pc.onnegotiationneeded = () => {
3553
+ this.analytics.P2PNegotiationNeeded++;
3554
+ rtcStats.sendEvent("P2PNegotiationNeeded", {});
3537
3555
  if (pc.iceConnectionState === "new" || !session.connectionStatus) {
3538
3556
  return;
3539
3557
  }
@@ -4546,10 +4564,12 @@ class VegaRtcManager {
4546
4564
  this._audioTrackOnEnded = () => {
4547
4565
  rtcStats.sendEvent("audio_ended", { unloading });
4548
4566
  this._emitToPWA(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
4567
+ this.analytics.micTrackEndedCount++;
4549
4568
  };
4550
4569
  this._videoTrackOnEnded = () => {
4551
4570
  rtcStats.sendEvent("video_ended", { unloading });
4552
4571
  this._emitToPWA(rtcManagerEvents.CAMERA_STOPPED_WORKING, {});
4572
+ this.analytics.camTrackEndedCount++;
4553
4573
  };
4554
4574
  this._updateAndScheduleMediaServersRefresh({
4555
4575
  sfuServer,
@@ -4576,6 +4596,8 @@ class VegaRtcManager {
4576
4596
  vegaIceRestartMissingTransport: 0,
4577
4597
  vegaIceRestartWrongTransportId: 0,
4578
4598
  vegaNonErrorRejectionValueGUMError: 0,
4599
+ micTrackEndedCount: 0,
4600
+ camTrackEndedCount: 0,
4579
4601
  };
4580
4602
  }
4581
4603
  _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds, }) {
@@ -7029,8 +7051,12 @@ class BandwidthTester extends EventEmitter {
7029
7051
  this._sendTransport.getStats(),
7030
7052
  this._receiveTransport.getStats(),
7031
7053
  ]);
7032
- const { recvStats: [remoteRecvStats = null] = [] } = yield this._vegaConnection.request("getTransportStats");
7033
- const { availableOutgoingBitrate = 5000000 } = remoteRecvStats || {};
7054
+ let availableOutgoingBitrate = 5000000;
7055
+ try {
7056
+ availableOutgoingBitrate = (yield this._vegaConnection.request("getTransportStats")).recvStats[0]
7057
+ .availableOutgoingBitrate;
7058
+ }
7059
+ catch (_a) { }
7034
7060
  let outboundPackets = 0;
7035
7061
  let remotePacketsLost = 0;
7036
7062
  localSendStats.forEach((localSendStat) => {
package/dist/index.d.cts CHANGED
@@ -381,6 +381,14 @@ type RtcEvents = {
381
381
  remote_stream_track_added: void;
382
382
  remote_stream_track_removed: void;
383
383
  };
384
+ type UnifiedPlanSDP = {
385
+ sdpU: string;
386
+ type: RTCSdpType;
387
+ };
388
+ type SDPRelayMessage = {
389
+ clientId: string;
390
+ message: UnifiedPlanSDP;
391
+ };
384
392
  type GetMediaConstraintsOptions = {
385
393
  disableAEC: boolean;
386
394
  disableAGC: boolean;
@@ -491,6 +499,67 @@ declare function getUpdatedDevices({ oldDevices, newDevices, currentAudioId, cur
491
499
  currentSpeakerId?: string | undefined;
492
500
  }): GetUpdatedDevicesResult;
493
501
 
502
+ interface P2PSessionOptions {
503
+ peerConnectionId: string;
504
+ clientId: string;
505
+ bandwidth: number;
506
+ peerConnectionConfig: RTCConfiguration;
507
+ deprioritizeH264Encoding: boolean;
508
+ shouldAddLocalVideo: boolean;
509
+ incrementAnalyticMetric: P2PIncrementAnalyticMetric;
510
+ }
511
+ declare class Session {
512
+ peerConnectionId: any;
513
+ relayCandidateSeen: boolean;
514
+ serverReflexiveCandidateSeen: boolean;
515
+ publicHostCandidateSeen: boolean;
516
+ ipv6HostCandidateSeen: boolean;
517
+ ipv6HostCandidateTeredoSeen: boolean;
518
+ ipv6HostCandidate6to4Seen: boolean;
519
+ mdnsHostCandidateSeen: boolean;
520
+ pc: RTCPeerConnection;
521
+ wasEverConnected: boolean;
522
+ connectionStatus: any;
523
+ stats: {
524
+ totalSent: number;
525
+ totalRecv: number;
526
+ };
527
+ bandwidth: any;
528
+ pending: any[];
529
+ isOperationPending: boolean;
530
+ streamIds: any[];
531
+ streams: MediaStream[];
532
+ earlyIceCandidates: any[];
533
+ afterConnected: Promise<unknown>;
534
+ registerConnected: any;
535
+ offerOptions: {
536
+ offerToReceiveAudio: boolean;
537
+ offerToReceiveVideo: boolean;
538
+ };
539
+ _deprioritizeH264Encoding: any;
540
+ clientId: any;
541
+ peerConnectionConfig: RTCConfiguration;
542
+ shouldAddLocalVideo: boolean;
543
+ signalingState: any;
544
+ srdComplete: any;
545
+ _incrementAnalyticMetric: P2PIncrementAnalyticMetric;
546
+ constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, shouldAddLocalVideo, incrementAnalyticMetric, }: P2PSessionOptions);
547
+ addStream(stream: MediaStream): void;
548
+ addTrack(track: MediaStreamTrack, stream?: MediaStream): void;
549
+ removeTrack(track: MediaStreamTrack): void;
550
+ removeStream(stream: MediaStream): void;
551
+ _setRemoteDescription(desc: any): any;
552
+ handleOffer(message: RTCSessionDescription): any;
553
+ handleAnswer(message: RTCSessionDescription): any;
554
+ addIceCandidate(candidate: any): void;
555
+ canModifyPeerConnection(): boolean;
556
+ close(): void;
557
+ hasConnectedPeerConnection(): boolean;
558
+ replaceTrack(oldTrack: CustomMediaStreamTrack | undefined | null, newTrack: MediaStreamTrack): any;
559
+ changeBandwidth(bandwidth: any): void;
560
+ setAudioOnly(enable: boolean, excludedTrackIds?: string[]): void;
561
+ }
562
+
494
563
  declare const assert: {
495
564
  fail: (message?: string | Error) => void;
496
565
  ok: (value: any, message?: string | Error) => void;
@@ -1078,6 +1147,13 @@ declare function fromLocation({ host, protocol }?: {
1078
1147
  subdomain: string;
1079
1148
  };
1080
1149
 
1150
+ interface GetOrCreateSessionOptions {
1151
+ peerConnectionId: string;
1152
+ clientId: string;
1153
+ shouldAddLocalVideo: boolean;
1154
+ initialBandwidth: number;
1155
+ peerConnectionConfig: RTCConfiguration;
1156
+ }
1081
1157
  type P2PAnalytics = {
1082
1158
  P2PReplaceTrackNoPC: number;
1083
1159
  P2PNonErrorRejectionValueGUMError: number;
@@ -1090,6 +1166,14 @@ type P2PAnalytics = {
1090
1166
  numIceIpv6TeredoSeen: number;
1091
1167
  numIceIpv6SixToFour: number;
1092
1168
  numIceMdnsSeen: number;
1169
+ micTrackEndedCount: number;
1170
+ camTrackEndedCount: number;
1171
+ numPcOnAnswerFailure: number;
1172
+ numPcOnOfferFailure: number;
1173
+ numPcSldFailure: number;
1174
+ P2PChangeBandwidthEmptySDPType: number;
1175
+ P2PNegotiationNeeded: number;
1176
+ P2PSessionAlreadyCreated: number;
1093
1177
  };
1094
1178
  type P2PAnalyticMetric = keyof P2PAnalytics;
1095
1179
  type P2PIncrementAnalyticMetric = (metric: P2PAnalyticMetric) => void;
@@ -1097,10 +1181,10 @@ declare class P2pRtcManager implements RtcManager {
1097
1181
  _selfId: any;
1098
1182
  _roomName: any;
1099
1183
  _roomSessionId: any;
1100
- peerConnections: any;
1184
+ peerConnections: Record<string, Session>;
1101
1185
  localStreams: any;
1102
1186
  enabledLocalStreamIds: any[];
1103
- _screenshareVideoTrackIds: any[];
1187
+ _screenshareVideoTrackIds: string[];
1104
1188
  _socketListenerDeregisterFunctions: any[];
1105
1189
  _localStreamDeregisterFunction: any;
1106
1190
  _emitter: any;
@@ -1164,27 +1248,21 @@ declare class P2pRtcManager implements RtcManager {
1164
1248
  _emit(eventName: string, data?: any): void;
1165
1249
  _addEnabledLocalStreamId(streamId: string): void;
1166
1250
  _deleteEnabledLocalStreamId(streamId: string): void;
1167
- _getSession(peerConnectionId: string): any;
1168
- _getOrCreateSession(peerConnectionId: string, initialBandwidth: any): any;
1251
+ _getSession(peerConnectionId: string): Session | null;
1252
+ _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, shouldAddLocalVideo, }: GetOrCreateSessionOptions): Session;
1169
1253
  _getLocalCameraStream(): any;
1170
1254
  _getNonLocalCameraStreamIds(): string[];
1171
1255
  _isScreensharingLocally(): boolean;
1172
1256
  _getFirstLocalNonCameraStream(): any;
1173
- _transformIncomingSdp(original: any, _: any): {
1174
- type: any;
1175
- sdp: any;
1176
- };
1177
- _transformOutgoingSdp(original: any): {
1178
- type: any;
1179
- sdpU: any;
1180
- };
1257
+ _transformIncomingSdp(original: UnifiedPlanSDP): RTCSessionDescription;
1258
+ _transformOutgoingSdp(original: RTCSessionDescription): UnifiedPlanSDP;
1181
1259
  _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }: {
1182
1260
  clientId: string;
1183
1261
  initialBandwidth: any;
1184
1262
  isOfferer: any;
1185
1263
  peerConnectionId: string;
1186
1264
  shouldAddLocalVideo: boolean;
1187
- }): any;
1265
+ }): Session;
1188
1266
  _cleanup(peerConnectionId: string): void;
1189
1267
  _forEachPeerConnection(func: any): void;
1190
1268
  _addStreamToPeerConnections(stream: any): void;
@@ -1198,23 +1276,23 @@ declare class P2pRtcManager implements RtcManager {
1198
1276
  _clearMediaServersRefresh(): void;
1199
1277
  _monitorAudioTrack(track: any): void;
1200
1278
  _monitorVideoTrack(track: CustomMediaStreamTrack): void;
1201
- _connect(clientId: string): Promise<any>;
1279
+ _connect(clientId: string): Promise<Session>;
1202
1280
  _maybeRestartIce(clientId: string, session: any): void;
1203
1281
  _setCodecPreferences(pc: RTCPeerConnection): Promise<void>;
1204
1282
  _negotiatePeerConnection(clientId: string, session: any, constraints?: any): void;
1205
- _withForcedRenegotiation(session: any, action: any): void;
1283
+ _withForcedRenegotiation(session: Session, action: any): void;
1206
1284
  _changeBandwidthForAllClients(isJoining: boolean): number;
1207
1285
  _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo, isOfferer, }: {
1208
1286
  clientId: string;
1209
1287
  initialBandwidth: number;
1210
1288
  shouldAddLocalVideo: boolean;
1211
1289
  isOfferer: boolean;
1212
- }): any;
1290
+ }): Session;
1213
1291
  acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }: {
1214
1292
  streamId: string;
1215
1293
  clientId: string;
1216
1294
  shouldAddLocalVideo?: boolean;
1217
- }): any;
1295
+ }): Session;
1218
1296
  disconnect(clientId: string): void;
1219
1297
  updateStreamResolution(): void;
1220
1298
  stopOrResumeAudio(): void;
@@ -1256,9 +1334,6 @@ declare const _default: {
1256
1334
  SFU_CONNECTION_INFO: string;
1257
1335
  COLOCATION_SPEAKER: string;
1258
1336
  DOMINANT_SPEAKER: string;
1259
- PC_SLD_FAILURE: string;
1260
- PC_ON_ANSWER_FAILURE: string;
1261
- PC_ON_OFFER_FAILURE: string;
1262
1337
  };
1263
1338
 
1264
1339
  declare function setVideoBandwidthUsingSetParameters(pc: any, bandwidth: any, logger?: any): any;
@@ -1287,69 +1362,6 @@ declare function changeMediaDirection(sdp: any, active: any): string;
1287
1362
  declare function addExtMap(sdp: any, extmapUri: any, modifyAudio?: any, modifyVideo?: any): any;
1288
1363
  declare function addAbsCaptureTimeExtMap(sdp: any): any;
1289
1364
 
1290
- declare class Session {
1291
- peerConnectionId: any;
1292
- relayCandidateSeen: boolean;
1293
- serverReflexiveCandidateSeen: boolean;
1294
- publicHostCandidateSeen: boolean;
1295
- ipv6HostCandidateSeen: boolean;
1296
- ipv6HostCandidateTeredoSeen: boolean;
1297
- ipv6HostCandidate6to4Seen: boolean;
1298
- mdnsHostCandidateSeen: boolean;
1299
- pc: any;
1300
- wasEverConnected: boolean;
1301
- connectionStatus: any;
1302
- stats: {
1303
- totalSent: number;
1304
- totalRecv: number;
1305
- };
1306
- bandwidth: any;
1307
- pending: any[];
1308
- isOperationPending: boolean;
1309
- streamIds: any[];
1310
- streams: any[];
1311
- earlyIceCandidates: any[];
1312
- afterConnected: Promise<unknown>;
1313
- registerConnected: any;
1314
- offerOptions: {
1315
- offerToReceiveAudio: boolean;
1316
- offerToReceiveVideo: boolean;
1317
- };
1318
- _deprioritizeH264Encoding: any;
1319
- clientId: any;
1320
- peerConnectionConfig: any;
1321
- shouldAddLocalVideo: any;
1322
- signalingState: any;
1323
- srdComplete: any;
1324
- _incrementAnalyticMetric: P2PIncrementAnalyticMetric;
1325
- constructor({ peerConnectionId, bandwidth, deprioritizeH264Encoding, incrementAnalyticMetric, }: {
1326
- peerConnectionId: any;
1327
- bandwidth: any;
1328
- deprioritizeH264Encoding: any;
1329
- incrementAnalyticMetric: P2PIncrementAnalyticMetric;
1330
- });
1331
- setAndGetPeerConnection({ clientId, constraints, peerConnectionConfig, shouldAddLocalVideo, }: {
1332
- clientId: any;
1333
- constraints: any;
1334
- peerConnectionConfig: any;
1335
- shouldAddLocalVideo: any;
1336
- }): any;
1337
- addStream(stream: MediaStream): void;
1338
- addTrack(track: MediaStreamTrack, stream?: MediaStream): void;
1339
- removeTrack(track: MediaStreamTrack): void;
1340
- removeStream(stream: MediaStream): void;
1341
- _setRemoteDescription(desc: any): any;
1342
- handleOffer(message: any): any;
1343
- handleAnswer(message: any): any;
1344
- addIceCandidate(candidate: any): void;
1345
- canModifyPeerConnection(): boolean;
1346
- close(): void;
1347
- hasConnectedPeerConnection(): any;
1348
- replaceTrack(oldTrack: CustomMediaStreamTrack | undefined | null, newTrack: MediaStreamTrack): any;
1349
- changeBandwidth(bandwidth: any): void;
1350
- setAudioOnly(enable: boolean, excludedTrackIds?: any[]): void;
1351
- }
1352
-
1353
1365
  declare class SfuV2Parser {
1354
1366
  static parse(raw: any): any;
1355
1367
  static _handleRequest(rawMessage: any): any;
@@ -1503,6 +1515,8 @@ type VegaAnalytics = {
1503
1515
  vegaIceRestartMissingTransport: number;
1504
1516
  vegaIceRestartWrongTransportId: number;
1505
1517
  vegaNonErrorRejectionValueGUMError: number;
1518
+ micTrackEndedCount: number;
1519
+ camTrackEndedCount: number;
1506
1520
  };
1507
1521
 
1508
1522
  type MediaStreamWhichMayHaveInboundId = MediaStream & { inboundId?: string };
@@ -1875,4 +1889,4 @@ declare class RtcStream {
1875
1889
  }
1876
1890
 
1877
1891
  export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, 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, changeMediaDirection, 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, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, turnServerOverride, variance };
1878
- export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, CustomMediaStreamTrack, 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, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcStreamAddedPayload, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalKnocker, SignalRequests, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UpdatedDeviceInfo, UpdatedDevicesInfo, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent };
1892
+ export type { AddSpotlightRequest, AudioEnableRequest, AudioEnableRequestedEvent, AudioEnabledEvent, BreakoutConfig, BreakoutGroupJoinedEvent, BreakoutSessionUpdatedEvent, CannotJoinUnclaimedRoomError, ChatMessage, ClientKickedEvent, ClientLeftEvent, ClientMetadataPayload, ClientMetadataReceivedEvent, ClientRole, ClientUnableToJoinEvent, CloudRecordingStartedEvent, Codec, Credentials, CustomMediaStreamTrack, 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, RtcEvents, RtcLocalStreamTrackAddedPayload, RtcLocalStreamTrackRemovedPayload, RtcManager, RtcManagerCreatedPayload, RtcStreamAddedPayload, SDPRelayMessage, ScreenshareStartedEvent, ScreenshareStoppedEvent, SendClientMetadataRequest, SignalClient, SignalEvents, SignalKnocker, SignalRequests, SocketConf, SocketManager, Spotlight, SpotlightAddedEvent, SpotlightRemovedEvent, StatsMonitorOptions, StatsMonitorState, StatsSubscription, TurnTransportProtocol, UnifiedPlanSDP, UpdatedDeviceInfo, UpdatedDevicesInfo, VideoEnableRequest, VideoEnableRequestedEvent, VideoEnabledEvent };