@whereby.com/media 2.8.2 → 2.8.4

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.
@@ -1406,7 +1406,7 @@ class ReconnectManager extends EventEmitter {
1406
1406
  clearTimeout(client.timeout);
1407
1407
  delete this._clients[clientId];
1408
1408
  }
1409
- (_a = this.rtcManager) === null || _a === void 0 ? void 0 : _a.disconnect(clientId, null, payload.eventClaim);
1409
+ (_a = this.rtcManager) === null || _a === void 0 ? void 0 : _a.disconnect(clientId, payload.eventClaim);
1410
1410
  this.emit(PROTOCOL_RESPONSES.CLIENT_LEFT, payload);
1411
1411
  }
1412
1412
  _onPendingClientLeft(payload) {
@@ -1629,8 +1629,7 @@ class ServerSocket {
1629
1629
  if (this._serverSideDisconnectDurationLimitOn)
1630
1630
  this._keepAliveManager = new KeepAliveManager(this);
1631
1631
  this._socket.on("room_joined", (payload) => {
1632
- const { error } = payload;
1633
- if (!error) {
1632
+ if (!("error" in payload)) {
1634
1633
  this.joinRoomFinished = true;
1635
1634
  }
1636
1635
  });
@@ -2213,7 +2212,7 @@ var _a$4;
2213
2212
  const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
2214
2213
  const logger$7 = new Logger();
2215
2214
  class Session {
2216
- constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, shouldAddLocalVideo, incrementAnalyticMetric, }) {
2215
+ constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, incrementAnalyticMetric, }) {
2217
2216
  this.peerConnectionId = peerConnectionId;
2218
2217
  this.relayCandidateSeen = false;
2219
2218
  this.serverReflexiveCandidateSeen = false;
@@ -2223,7 +2222,6 @@ class Session {
2223
2222
  this.ipv6HostCandidate6to4Seen = false;
2224
2223
  this.mdnsHostCandidateSeen = false;
2225
2224
  this.peerConnectionConfig = peerConnectionConfig;
2226
- this.shouldAddLocalVideo = shouldAddLocalVideo;
2227
2225
  this.clientId = clientId;
2228
2226
  this.pc = new RTCPeerConnection(this.peerConnectionConfig);
2229
2227
  this.signalingState = this.pc.signalingState;
@@ -2291,11 +2289,13 @@ class Session {
2291
2289
  }
2292
2290
  }
2293
2291
  removeStream(stream) {
2294
- for (let i = 0; i < this.streamIds.length; i++) {
2295
- if (this.streamIds[i] === stream.id) {
2296
- this.streamIds.splice(i, 1);
2297
- this.streams.splice(i, 1);
2298
- }
2292
+ const streamIdIndex = this.streamIds.indexOf(stream.id);
2293
+ if (streamIdIndex !== -1) {
2294
+ this.streamIds.splice(streamIdIndex, 1);
2295
+ }
2296
+ const streamIndex = this.streams.indexOf(stream);
2297
+ if (streamIndex !== -1) {
2298
+ this.streams.splice(streamIndex, 1);
2299
2299
  }
2300
2300
  if (this.pc) {
2301
2301
  if (this.pc.removeTrack) {
@@ -2561,57 +2561,6 @@ const TYPES = {
2561
2561
  CONNECTION_DISCONNECTED: "connection_disconnected",
2562
2562
  };
2563
2563
 
2564
- const CAMERA_STREAM_ID$1 = "0";
2565
- const STREAM_TYPES = {
2566
- CAMERA: "camera",
2567
- SCREEN_SHARE: "screen_share",
2568
- };
2569
- class RtcStream {
2570
- constructor(id, type) {
2571
- this.id = "" + id;
2572
- this.type = type;
2573
- this.isEnabled = true;
2574
- this.hasSupportForAutoSuperSize = false;
2575
- this.isAudioEnabled = true;
2576
- this.isVideoEnabled = true;
2577
- this.status = TYPES.CONNECTING;
2578
- this.stream = null;
2579
- this.streamId = null;
2580
- }
2581
- setup(stream) {
2582
- this.stream = stream;
2583
- this.streamId = stream.id;
2584
- this.setVideoEnabled(this.isVideoEnabled && stream.getVideoTracks().length > 0);
2585
- this.setAudioEnabled(this.isAudioEnabled && stream.getAudioTracks().length > 0);
2586
- return this;
2587
- }
2588
- setStatus(status) {
2589
- this.status = status;
2590
- return this;
2591
- }
2592
- setVideoEnabled(isEnabled) {
2593
- this.isVideoEnabled = isEnabled;
2594
- if (!this.stream) {
2595
- return;
2596
- }
2597
- this.stream.getVideoTracks().forEach((track) => {
2598
- track.enabled = isEnabled;
2599
- });
2600
- }
2601
- setAudioEnabled(isEnabled) {
2602
- this.isAudioEnabled = isEnabled;
2603
- if (!this.stream) {
2604
- return;
2605
- }
2606
- this.stream.getAudioTracks().forEach((track) => {
2607
- track.enabled = isEnabled;
2608
- });
2609
- }
2610
- static getCameraId() {
2611
- return CAMERA_STREAM_ID$1;
2612
- }
2613
- }
2614
-
2615
2564
  var rtcManagerEvents = {
2616
2565
  CAMERA_NOT_WORKING: "camera_not_working",
2617
2566
  CONNECTION_BLOCKED_BY_NETWORK: "connection_blocked_by_network",
@@ -2626,11 +2575,16 @@ var rtcManagerEvents = {
2626
2575
  DOMINANT_SPEAKER: "dominant_speaker",
2627
2576
  };
2628
2577
 
2578
+ const CAMERA_STREAM_ID = "0";
2579
+ const STREAM_TYPES = {
2580
+ webcam: "webcam",
2581
+ screenshare: "screenshare",
2582
+ };
2583
+
2629
2584
  var _a$2, _b$1, _c;
2630
2585
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
2631
2586
  const logger$6 = new Logger();
2632
2587
  const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
2633
- const CAMERA_STREAM_ID = RtcStream.getCameraId();
2634
2588
  const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
2635
2589
  const browserVersion = adapter$2.browserDetails.version;
2636
2590
  if (browserName$1 === "firefox" && adapter$2.browserShim && "shimGetDisplayMedia" in adapter$2.browserShim) {
@@ -2643,8 +2597,8 @@ if (browserName$1 === "chrome") {
2643
2597
  });
2644
2598
  }
2645
2599
  class P2pRtcManager {
2646
- constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }) {
2647
- const { name, session, iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds } = room;
2600
+ constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features }) {
2601
+ const { name, session, iceServers, turnServers, mediaserverConfigTtlSeconds } = room;
2648
2602
  this._selfId = selfId;
2649
2603
  this._roomName = name;
2650
2604
  this._roomSessionId = session && session.id;
@@ -2674,7 +2628,6 @@ class P2pRtcManager {
2674
2628
  this.analytics.camTrackEndedCount++;
2675
2629
  };
2676
2630
  this._updateAndScheduleMediaServersRefresh({
2677
- sfuServer,
2678
2631
  iceServers: (iceServers === null || iceServers === void 0 ? void 0 : iceServers.iceServers) || [],
2679
2632
  turnServers: turnServers || [],
2680
2633
  mediaserverConfigTtlSeconds,
@@ -2715,7 +2668,7 @@ class P2pRtcManager {
2715
2668
  return Object.keys(this.peerConnections).length;
2716
2669
  }
2717
2670
  isInitializedWith({ selfId, roomName, isSfu }) {
2718
- return this._selfId === selfId && this._roomName === roomName && isSfu === !!this._sfuServer;
2671
+ return this._selfId === selfId && this._roomName === roomName && !isSfu;
2719
2672
  }
2720
2673
  supportsScreenShareAudio() {
2721
2674
  return true;
@@ -2855,13 +2808,9 @@ class P2pRtcManager {
2855
2808
  });
2856
2809
  }),
2857
2810
  this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, (payload) => {
2858
- var _a, _b;
2859
- if (payload === null || payload === void 0 ? void 0 : payload.error) {
2811
+ if ("error" in payload || !this._wasScreenSharing) {
2860
2812
  return;
2861
2813
  }
2862
- const isSfu = (_b = (_a = payload === null || payload === void 0 ? void 0 : payload.room) === null || _a === void 0 ? void 0 : _a.sfuServer) !== null && _b !== void 0 ? _b : false;
2863
- if (isSfu || !this._wasScreenSharing)
2864
- return;
2865
2814
  const screenShareStreamId = Object.keys(this.localStreams).find((id) => id !== CAMERA_STREAM_ID);
2866
2815
  if (!screenShareStreamId) {
2867
2816
  return;
@@ -2877,6 +2826,15 @@ class P2pRtcManager {
2877
2826
  hasAudioTrack,
2878
2827
  });
2879
2828
  }),
2829
+ this._serverSocket.on(PROTOCOL_RESPONSES.SCREENSHARE_STOPPED, (payload) => {
2830
+ const session = this._getSession(payload.clientId);
2831
+ if (session) {
2832
+ const streamIdIndex = session.streamIds.indexOf(payload.streamId);
2833
+ if (streamIdIndex !== -1) {
2834
+ session.streamIds.splice(streamIdIndex, 1);
2835
+ }
2836
+ }
2837
+ }),
2880
2838
  ];
2881
2839
  }
2882
2840
  sendAudioMutedStats(muted) {
@@ -2925,9 +2883,6 @@ class P2pRtcManager {
2925
2883
  if (previousStatus === newStatus) {
2926
2884
  return;
2927
2885
  }
2928
- if (session.peerConnectionId === this._selfId) {
2929
- return;
2930
- }
2931
2886
  if (previousStatus === TYPES.CONNECTION_DISCONNECTED &&
2932
2887
  newStatus === TYPES.CONNECTING) {
2933
2888
  return;
@@ -2988,7 +2943,7 @@ class P2pRtcManager {
2988
2943
  }
2989
2944
  return this.peerConnections[peerConnectionId];
2990
2945
  }
2991
- _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, shouldAddLocalVideo, }) {
2946
+ _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, }) {
2992
2947
  let session = this.peerConnections[peerConnectionId];
2993
2948
  if (session === undefined) {
2994
2949
  const deprioritizeH264Encoding = browserName$1 === "safari" &&
@@ -3001,7 +2956,6 @@ class P2pRtcManager {
3001
2956
  peerConnectionConfig,
3002
2957
  bandwidth: initialBandwidth,
3003
2958
  deprioritizeH264Encoding,
3004
- shouldAddLocalVideo,
3005
2959
  incrementAnalyticMetric: (metric) => this.analytics[metric]++,
3006
2960
  });
3007
2961
  }
@@ -3034,7 +2988,7 @@ class P2pRtcManager {
3034
2988
  _transformOutgoingSdp(original) {
3035
2989
  return { type: original.type, sdpU: original.sdp, sdp: original.sdp };
3036
2990
  }
3037
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
2991
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, }) {
3038
2992
  if (!peerConnectionId) {
3039
2993
  throw new Error("peerConnectionId is missing");
3040
2994
  }
@@ -3063,7 +3017,6 @@ class P2pRtcManager {
3063
3017
  clientId,
3064
3018
  initialBandwidth,
3065
3019
  peerConnectionConfig,
3066
- shouldAddLocalVideo,
3067
3020
  });
3068
3021
  setTimeout(() => this._emit(rtcManagerEvents.NEW_PC), 0);
3069
3022
  this.analytics.numNewPc++;
@@ -3074,7 +3027,7 @@ class P2pRtcManager {
3074
3027
  this.analytics.P2POnTrackNoStream++;
3075
3028
  rtcStats.sendEvent("P2POnTrackNoStream", {
3076
3029
  trackKind: event.track.kind,
3077
- trackId: event.track.id
3030
+ trackId: event.track.id,
3078
3031
  });
3079
3032
  return;
3080
3033
  }
@@ -3161,30 +3114,28 @@ class P2pRtcManager {
3161
3114
  }
3162
3115
  };
3163
3116
  const localCameraStream = this.localStreams[CAMERA_STREAM_ID];
3164
- if (shouldAddLocalVideo && localCameraStream) {
3117
+ if (localCameraStream) {
3165
3118
  session.addStream(localCameraStream);
3166
3119
  }
3167
- if (shouldAddLocalVideo) {
3168
- Object.keys(this.localStreams).forEach((id) => {
3169
- if (id === CAMERA_STREAM_ID) {
3170
- return;
3171
- }
3172
- const screenshareStream = this.localStreams[id];
3173
- if (isOfferer) {
3174
- session.addStream(screenshareStream);
3175
- }
3176
- else {
3177
- session.afterConnected.then(() => {
3178
- this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
3179
- receiverId: session.clientId,
3180
- streamId: screenshareStream.id,
3181
- hasAudioTrack: !!screenshareStream.getAudioTracks().length,
3182
- });
3183
- this._withForcedRenegotiation(session, () => session.addStream(screenshareStream));
3120
+ Object.keys(this.localStreams).forEach((id) => {
3121
+ if (id === CAMERA_STREAM_ID) {
3122
+ return;
3123
+ }
3124
+ const screenshareStream = this.localStreams[id];
3125
+ if (isOfferer) {
3126
+ session.addStream(screenshareStream);
3127
+ }
3128
+ else {
3129
+ session.afterConnected.then(() => {
3130
+ this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
3131
+ receiverId: session.clientId,
3132
+ streamId: screenshareStream.id,
3133
+ hasAudioTrack: !!screenshareStream.getAudioTracks().length,
3184
3134
  });
3185
- }
3186
- });
3187
- }
3135
+ this._withForcedRenegotiation(session, () => session.addStream(screenshareStream));
3136
+ });
3137
+ }
3138
+ });
3188
3139
  return session;
3189
3140
  }
3190
3141
  _cleanup(peerConnectionId) {
@@ -3271,10 +3222,9 @@ class P2pRtcManager {
3271
3222
  delete this.localStreams[streamId];
3272
3223
  this._deleteEnabledLocalStreamId(streamId);
3273
3224
  }
3274
- _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds }) {
3225
+ _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, mediaserverConfigTtlSeconds, }) {
3275
3226
  this._iceServers = iceServers;
3276
3227
  this._turnServers = turnServers;
3277
- this._sfuServer = sfuServer;
3278
3228
  this._mediaserverConfigTtlSeconds = mediaserverConfigTtlSeconds;
3279
3229
  this._clearMediaServersRefresh();
3280
3230
  if (!mediaserverConfigTtlSeconds) {
@@ -3321,7 +3271,6 @@ class P2pRtcManager {
3321
3271
  session = this._createP2pSession({
3322
3272
  clientId,
3323
3273
  initialBandwidth,
3324
- shouldAddLocalVideo: true,
3325
3274
  isOfferer: true,
3326
3275
  });
3327
3276
  this._negotiatePeerConnection(clientId, session);
@@ -3465,12 +3414,11 @@ class P2pRtcManager {
3465
3414
  });
3466
3415
  return bandwidth;
3467
3416
  }
3468
- _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, }) {
3417
+ _createP2pSession({ clientId, initialBandwidth, isOfferer = false, }) {
3469
3418
  const session = this._createSession({
3470
3419
  peerConnectionId: clientId,
3471
3420
  clientId,
3472
3421
  initialBandwidth,
3473
- shouldAddLocalVideo,
3474
3422
  isOfferer,
3475
3423
  });
3476
3424
  const pc = session.pc;
@@ -3478,10 +3426,7 @@ class P2pRtcManager {
3478
3426
  this._setJitterBufferTarget(pc);
3479
3427
  }
3480
3428
  const localCameraStream = this.localStreams[CAMERA_STREAM_ID];
3481
- if (shouldAddLocalVideo &&
3482
- localCameraStream &&
3483
- !localCameraStream.getVideoTracks().length &&
3484
- this._stoppedVideoTrack) {
3429
+ if (localCameraStream && !localCameraStream.getVideoTracks().length && this._stoppedVideoTrack) {
3485
3430
  pc.addTrack(this._stoppedVideoTrack, localCameraStream);
3486
3431
  }
3487
3432
  pc.onicegatheringstatechange = (event) => {
@@ -3587,7 +3532,7 @@ class P2pRtcManager {
3587
3532
  };
3588
3533
  return session;
3589
3534
  }
3590
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
3535
+ acceptNewStream({ streamId, clientId }) {
3591
3536
  let session = this._getSession(clientId);
3592
3537
  if (session && streamId !== clientId) {
3593
3538
  return session;
@@ -3603,7 +3548,6 @@ class P2pRtcManager {
3603
3548
  session = this._createP2pSession({
3604
3549
  clientId,
3605
3550
  initialBandwidth,
3606
- shouldAddLocalVideo: !!shouldAddLocalVideo,
3607
3551
  isOfferer: false,
3608
3552
  });
3609
3553
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
@@ -3710,6 +3654,9 @@ class P2pRtcManager {
3710
3654
  hasClient(clientId) {
3711
3655
  return Object.keys(this.peerConnections).includes(clientId);
3712
3656
  }
3657
+ shouldAcceptStreamsFromBothSides() {
3658
+ return false;
3659
+ }
3713
3660
  }
3714
3661
 
3715
3662
  class KalmanFilter {
@@ -4546,8 +4493,8 @@ const OUTBOUND_SCREEN_OUTBOUND_STREAM_ID = v4$1();
4546
4493
  if (browserName === "chrome")
4547
4494
  window.document.addEventListener("beforeunload", () => (unloading = true));
4548
4495
  class VegaRtcManager {
4549
- constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, }) {
4550
- const { session, iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds } = room;
4496
+ constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim }) {
4497
+ const { session, iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds } = room;
4551
4498
  this._selfId = selfId;
4552
4499
  this._room = room;
4553
4500
  this._roomSessionId = session === null || session === void 0 ? void 0 : session.id;
@@ -4601,7 +4548,6 @@ class VegaRtcManager {
4601
4548
  };
4602
4549
  this._updateAndScheduleMediaServersRefresh({
4603
4550
  sfuServer,
4604
- sfuServers,
4605
4551
  iceServers: (iceServers === null || iceServers === void 0 ? void 0 : iceServers.iceServers) || [],
4606
4552
  turnServers: turnServers || [],
4607
4553
  mediaserverConfigTtlSeconds,
@@ -4628,13 +4574,14 @@ class VegaRtcManager {
4628
4574
  camTrackEndedCount: 0,
4629
4575
  };
4630
4576
  }
4631
- _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds, }) {
4632
- var _a, _b, _c;
4577
+ _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds, }) {
4578
+ var _a, _b, _c, _d;
4633
4579
  this._iceServers = iceServers;
4634
4580
  this._turnServers = turnServers;
4635
- this._sfuServer = sfuServer;
4636
- this._sfuServers = sfuServers;
4637
- if (!sfuServers && (sfuServer === null || sfuServer === void 0 ? void 0 : sfuServer.fallbackServers)) {
4581
+ if (sfuServer) {
4582
+ this._sfuServer = sfuServer;
4583
+ }
4584
+ if (sfuServer === null || sfuServer === void 0 ? void 0 : sfuServer.fallbackServers) {
4638
4585
  this._sfuServers = sfuServer.fallbackServers.map((entry) => ({
4639
4586
  host: entry.host || entry.fqdn,
4640
4587
  dc: entry.dc,
@@ -4644,14 +4591,14 @@ class VegaRtcManager {
4644
4591
  (_a = this._vegaConnectionManager) === null || _a === void 0 ? void 0 : _a.updateHostList(this._features.sfuServersOverride ||
4645
4592
  this._sfuServers ||
4646
4593
  this._features.sfuServerOverrideHost ||
4647
- sfuServer.url);
4594
+ ((_b = this._sfuServer) === null || _b === void 0 ? void 0 : _b.url));
4648
4595
  const iceServersList = {
4649
4596
  iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
4650
4597
  };
4651
4598
  iceServersList.iceServers = turnServerOverride(iceServersList.iceServers, this._features.turnServerOverrideHost);
4652
4599
  if (browserName !== "firefox") {
4653
- (_b = this._sendTransport) === null || _b === void 0 ? void 0 : _b.updateIceServers(iceServersList);
4654
- (_c = this._receiveTransport) === null || _c === void 0 ? void 0 : _c.updateIceServers(iceServersList);
4600
+ (_c = this._sendTransport) === null || _c === void 0 ? void 0 : _c.updateIceServers(iceServersList);
4601
+ (_d = this._receiveTransport) === null || _d === void 0 ? void 0 : _d.updateIceServers(iceServersList);
4655
4602
  }
4656
4603
  this._clearMediaServersRefresh();
4657
4604
  if (!mediaserverConfigTtlSeconds) {
@@ -4705,6 +4652,7 @@ class VegaRtcManager {
4705
4652
  });
4706
4653
  }
4707
4654
  _connect() {
4655
+ var _a;
4708
4656
  if (this._isConnectingOrConnected)
4709
4657
  return;
4710
4658
  if (!this._serverSocket.isConnected()) {
@@ -4720,7 +4668,7 @@ class VegaRtcManager {
4720
4668
  const hostList = this._features.sfuServersOverride ||
4721
4669
  this._sfuServers ||
4722
4670
  this._features.sfuServerOverrideHost ||
4723
- this._sfuServer.url;
4671
+ ((_a = this._sfuServer) === null || _a === void 0 ? void 0 : _a.url);
4724
4672
  this._vegaConnectionManager = createVegaConnectionManager({
4725
4673
  initialHostList: hostList,
4726
4674
  getUrlForHost: (host) => {
@@ -5462,14 +5410,14 @@ class VegaRtcManager {
5462
5410
  setRoomSessionId(roomSessionId) {
5463
5411
  this._roomSessionId = roomSessionId;
5464
5412
  }
5465
- disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
5413
+ disconnect(clientId, eventClaim) {
5466
5414
  var _a;
5467
- logger$2.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
5468
- const clientState = this._clientStates.get(clientIdOrStreamId);
5415
+ logger$2.info("disconnect() [clientId:%s, eventClaim:%s]", clientId, eventClaim);
5416
+ const clientState = this._clientStates.get(clientId);
5469
5417
  if (clientState) {
5470
5418
  clientState.hasAcceptedWebcamStream = false;
5471
5419
  clientState.hasAcceptedScreenStream = false;
5472
- this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
5420
+ this._syncIncomingStreamsWithPWA(clientId);
5473
5421
  }
5474
5422
  if (eventClaim) {
5475
5423
  this._eventClaim = eventClaim;
@@ -5511,7 +5459,7 @@ class VegaRtcManager {
5511
5459
  this._sendMicScore(this._micPaused ? 0 : data.out);
5512
5460
  }
5513
5461
  addNewStream(streamId, stream, audioPaused, videoPaused, beforeEffectTracks = []) {
5514
- if (streamId === "0") {
5462
+ if (streamId === CAMERA_STREAM_ID) {
5515
5463
  this._micPaused = audioPaused;
5516
5464
  this._webcamPaused = videoPaused;
5517
5465
  const videoTrack = stream.getVideoTracks()[0];
@@ -5978,7 +5926,7 @@ class VegaRtcManager {
5978
5926
  clientId,
5979
5927
  stream: webcamStream,
5980
5928
  streamId: camStreamId,
5981
- streamType: "webcam",
5929
+ streamType: STREAM_TYPES.webcam,
5982
5930
  });
5983
5931
  clientState.hasEmittedWebcamStream = true;
5984
5932
  }
@@ -5987,7 +5935,7 @@ class VegaRtcManager {
5987
5935
  clientId,
5988
5936
  stream: screenStream,
5989
5937
  streamId: screenShareStreamId,
5990
- streamType: "screenshare",
5938
+ streamType: STREAM_TYPES.screenshare,
5991
5939
  });
5992
5940
  clientState.hasEmittedScreenStream = true;
5993
5941
  }
@@ -6030,9 +5978,10 @@ class RtcManagerDispatcher {
6030
5978
  constructor({ emitter, serverSocket, webrtcProvider, features, }) {
6031
5979
  this.emitter = emitter;
6032
5980
  this.currentManager = null;
6033
- serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, ({ room, selfId, error, eventClaim }) => {
6034
- if (error)
5981
+ serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, (payload) => {
5982
+ if ("error" in payload)
6035
5983
  return;
5984
+ const { room, selfId, eventClaim } = payload;
6036
5985
  const config = {
6037
5986
  selfId,
6038
5987
  room,
@@ -7556,5 +7505,5 @@ var RtcEventNames;
7556
7505
  RtcEventNames["stream_added"] = "stream_added";
7557
7506
  })(RtcEventNames || (RtcEventNames = {}));
7558
7507
 
7559
- 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, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, variance };
7508
+ export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, CAMERA_STREAM_ID, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, 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, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, variance };
7560
7509
  //# sourceMappingURL=legacy-esm.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "2.8.2",
4
+ "version": "2.8.4",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {