@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.
package/dist/index.cjs CHANGED
@@ -1427,7 +1427,7 @@ class ReconnectManager extends EventEmitter {
1427
1427
  clearTimeout(client.timeout);
1428
1428
  delete this._clients[clientId];
1429
1429
  }
1430
- (_a = this.rtcManager) === null || _a === void 0 ? void 0 : _a.disconnect(clientId, null, payload.eventClaim);
1430
+ (_a = this.rtcManager) === null || _a === void 0 ? void 0 : _a.disconnect(clientId, payload.eventClaim);
1431
1431
  this.emit(PROTOCOL_RESPONSES.CLIENT_LEFT, payload);
1432
1432
  }
1433
1433
  _onPendingClientLeft(payload) {
@@ -1650,8 +1650,7 @@ class ServerSocket {
1650
1650
  if (this._serverSideDisconnectDurationLimitOn)
1651
1651
  this._keepAliveManager = new KeepAliveManager(this);
1652
1652
  this._socket.on("room_joined", (payload) => {
1653
- const { error } = payload;
1654
- if (!error) {
1653
+ if (!("error" in payload)) {
1655
1654
  this.joinRoomFinished = true;
1656
1655
  }
1657
1656
  });
@@ -2234,7 +2233,7 @@ var _a$4;
2234
2233
  const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
2235
2234
  const logger$7 = new Logger();
2236
2235
  class Session {
2237
- constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, shouldAddLocalVideo, incrementAnalyticMetric, }) {
2236
+ constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, incrementAnalyticMetric, }) {
2238
2237
  this.peerConnectionId = peerConnectionId;
2239
2238
  this.relayCandidateSeen = false;
2240
2239
  this.serverReflexiveCandidateSeen = false;
@@ -2244,7 +2243,6 @@ class Session {
2244
2243
  this.ipv6HostCandidate6to4Seen = false;
2245
2244
  this.mdnsHostCandidateSeen = false;
2246
2245
  this.peerConnectionConfig = peerConnectionConfig;
2247
- this.shouldAddLocalVideo = shouldAddLocalVideo;
2248
2246
  this.clientId = clientId;
2249
2247
  this.pc = new RTCPeerConnection(this.peerConnectionConfig);
2250
2248
  this.signalingState = this.pc.signalingState;
@@ -2312,11 +2310,13 @@ class Session {
2312
2310
  }
2313
2311
  }
2314
2312
  removeStream(stream) {
2315
- for (let i = 0; i < this.streamIds.length; i++) {
2316
- if (this.streamIds[i] === stream.id) {
2317
- this.streamIds.splice(i, 1);
2318
- this.streams.splice(i, 1);
2319
- }
2313
+ const streamIdIndex = this.streamIds.indexOf(stream.id);
2314
+ if (streamIdIndex !== -1) {
2315
+ this.streamIds.splice(streamIdIndex, 1);
2316
+ }
2317
+ const streamIndex = this.streams.indexOf(stream);
2318
+ if (streamIndex !== -1) {
2319
+ this.streams.splice(streamIndex, 1);
2320
2320
  }
2321
2321
  if (this.pc) {
2322
2322
  if (this.pc.removeTrack) {
@@ -2582,57 +2582,6 @@ const TYPES = {
2582
2582
  CONNECTION_DISCONNECTED: "connection_disconnected",
2583
2583
  };
2584
2584
 
2585
- const CAMERA_STREAM_ID$1 = "0";
2586
- const STREAM_TYPES = {
2587
- CAMERA: "camera",
2588
- SCREEN_SHARE: "screen_share",
2589
- };
2590
- class RtcStream {
2591
- constructor(id, type) {
2592
- this.id = "" + id;
2593
- this.type = type;
2594
- this.isEnabled = true;
2595
- this.hasSupportForAutoSuperSize = false;
2596
- this.isAudioEnabled = true;
2597
- this.isVideoEnabled = true;
2598
- this.status = TYPES.CONNECTING;
2599
- this.stream = null;
2600
- this.streamId = null;
2601
- }
2602
- setup(stream) {
2603
- this.stream = stream;
2604
- this.streamId = stream.id;
2605
- this.setVideoEnabled(this.isVideoEnabled && stream.getVideoTracks().length > 0);
2606
- this.setAudioEnabled(this.isAudioEnabled && stream.getAudioTracks().length > 0);
2607
- return this;
2608
- }
2609
- setStatus(status) {
2610
- this.status = status;
2611
- return this;
2612
- }
2613
- setVideoEnabled(isEnabled) {
2614
- this.isVideoEnabled = isEnabled;
2615
- if (!this.stream) {
2616
- return;
2617
- }
2618
- this.stream.getVideoTracks().forEach((track) => {
2619
- track.enabled = isEnabled;
2620
- });
2621
- }
2622
- setAudioEnabled(isEnabled) {
2623
- this.isAudioEnabled = isEnabled;
2624
- if (!this.stream) {
2625
- return;
2626
- }
2627
- this.stream.getAudioTracks().forEach((track) => {
2628
- track.enabled = isEnabled;
2629
- });
2630
- }
2631
- static getCameraId() {
2632
- return CAMERA_STREAM_ID$1;
2633
- }
2634
- }
2635
-
2636
2585
  var rtcManagerEvents = {
2637
2586
  CAMERA_NOT_WORKING: "camera_not_working",
2638
2587
  CONNECTION_BLOCKED_BY_NETWORK: "connection_blocked_by_network",
@@ -2647,11 +2596,16 @@ var rtcManagerEvents = {
2647
2596
  DOMINANT_SPEAKER: "dominant_speaker",
2648
2597
  };
2649
2598
 
2599
+ const CAMERA_STREAM_ID = "0";
2600
+ const STREAM_TYPES = {
2601
+ webcam: "webcam",
2602
+ screenshare: "screenshare",
2603
+ };
2604
+
2650
2605
  var _a$2, _b$1, _c;
2651
2606
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
2652
2607
  const logger$6 = new Logger();
2653
2608
  const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
2654
- const CAMERA_STREAM_ID = RtcStream.getCameraId();
2655
2609
  const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
2656
2610
  const browserVersion = adapter$2.browserDetails.version;
2657
2611
  if (browserName$1 === "firefox" && adapter$2.browserShim && "shimGetDisplayMedia" in adapter$2.browserShim) {
@@ -2664,8 +2618,8 @@ if (browserName$1 === "chrome") {
2664
2618
  });
2665
2619
  }
2666
2620
  class P2pRtcManager {
2667
- constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }) {
2668
- const { name, session, iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds } = room;
2621
+ constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features }) {
2622
+ const { name, session, iceServers, turnServers, mediaserverConfigTtlSeconds } = room;
2669
2623
  this._selfId = selfId;
2670
2624
  this._roomName = name;
2671
2625
  this._roomSessionId = session && session.id;
@@ -2695,7 +2649,6 @@ class P2pRtcManager {
2695
2649
  this.analytics.camTrackEndedCount++;
2696
2650
  };
2697
2651
  this._updateAndScheduleMediaServersRefresh({
2698
- sfuServer,
2699
2652
  iceServers: (iceServers === null || iceServers === void 0 ? void 0 : iceServers.iceServers) || [],
2700
2653
  turnServers: turnServers || [],
2701
2654
  mediaserverConfigTtlSeconds,
@@ -2736,7 +2689,7 @@ class P2pRtcManager {
2736
2689
  return Object.keys(this.peerConnections).length;
2737
2690
  }
2738
2691
  isInitializedWith({ selfId, roomName, isSfu }) {
2739
- return this._selfId === selfId && this._roomName === roomName && isSfu === !!this._sfuServer;
2692
+ return this._selfId === selfId && this._roomName === roomName && !isSfu;
2740
2693
  }
2741
2694
  supportsScreenShareAudio() {
2742
2695
  return true;
@@ -2876,13 +2829,9 @@ class P2pRtcManager {
2876
2829
  });
2877
2830
  }),
2878
2831
  this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, (payload) => {
2879
- var _a, _b;
2880
- if (payload === null || payload === void 0 ? void 0 : payload.error) {
2832
+ if ("error" in payload || !this._wasScreenSharing) {
2881
2833
  return;
2882
2834
  }
2883
- 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;
2884
- if (isSfu || !this._wasScreenSharing)
2885
- return;
2886
2835
  const screenShareStreamId = Object.keys(this.localStreams).find((id) => id !== CAMERA_STREAM_ID);
2887
2836
  if (!screenShareStreamId) {
2888
2837
  return;
@@ -2898,6 +2847,15 @@ class P2pRtcManager {
2898
2847
  hasAudioTrack,
2899
2848
  });
2900
2849
  }),
2850
+ this._serverSocket.on(PROTOCOL_RESPONSES.SCREENSHARE_STOPPED, (payload) => {
2851
+ const session = this._getSession(payload.clientId);
2852
+ if (session) {
2853
+ const streamIdIndex = session.streamIds.indexOf(payload.streamId);
2854
+ if (streamIdIndex !== -1) {
2855
+ session.streamIds.splice(streamIdIndex, 1);
2856
+ }
2857
+ }
2858
+ }),
2901
2859
  ];
2902
2860
  }
2903
2861
  sendAudioMutedStats(muted) {
@@ -2946,9 +2904,6 @@ class P2pRtcManager {
2946
2904
  if (previousStatus === newStatus) {
2947
2905
  return;
2948
2906
  }
2949
- if (session.peerConnectionId === this._selfId) {
2950
- return;
2951
- }
2952
2907
  if (previousStatus === TYPES.CONNECTION_DISCONNECTED &&
2953
2908
  newStatus === TYPES.CONNECTING) {
2954
2909
  return;
@@ -3009,7 +2964,7 @@ class P2pRtcManager {
3009
2964
  }
3010
2965
  return this.peerConnections[peerConnectionId];
3011
2966
  }
3012
- _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, shouldAddLocalVideo, }) {
2967
+ _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, }) {
3013
2968
  let session = this.peerConnections[peerConnectionId];
3014
2969
  if (session === undefined) {
3015
2970
  const deprioritizeH264Encoding = browserName$1 === "safari" &&
@@ -3022,7 +2977,6 @@ class P2pRtcManager {
3022
2977
  peerConnectionConfig,
3023
2978
  bandwidth: initialBandwidth,
3024
2979
  deprioritizeH264Encoding,
3025
- shouldAddLocalVideo,
3026
2980
  incrementAnalyticMetric: (metric) => this.analytics[metric]++,
3027
2981
  });
3028
2982
  }
@@ -3055,7 +3009,7 @@ class P2pRtcManager {
3055
3009
  _transformOutgoingSdp(original) {
3056
3010
  return { type: original.type, sdpU: original.sdp, sdp: original.sdp };
3057
3011
  }
3058
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
3012
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, }) {
3059
3013
  if (!peerConnectionId) {
3060
3014
  throw new Error("peerConnectionId is missing");
3061
3015
  }
@@ -3084,7 +3038,6 @@ class P2pRtcManager {
3084
3038
  clientId,
3085
3039
  initialBandwidth,
3086
3040
  peerConnectionConfig,
3087
- shouldAddLocalVideo,
3088
3041
  });
3089
3042
  setTimeout(() => this._emit(rtcManagerEvents.NEW_PC), 0);
3090
3043
  this.analytics.numNewPc++;
@@ -3095,7 +3048,7 @@ class P2pRtcManager {
3095
3048
  this.analytics.P2POnTrackNoStream++;
3096
3049
  rtcStats.sendEvent("P2POnTrackNoStream", {
3097
3050
  trackKind: event.track.kind,
3098
- trackId: event.track.id
3051
+ trackId: event.track.id,
3099
3052
  });
3100
3053
  return;
3101
3054
  }
@@ -3182,30 +3135,28 @@ class P2pRtcManager {
3182
3135
  }
3183
3136
  };
3184
3137
  const localCameraStream = this.localStreams[CAMERA_STREAM_ID];
3185
- if (shouldAddLocalVideo && localCameraStream) {
3138
+ if (localCameraStream) {
3186
3139
  session.addStream(localCameraStream);
3187
3140
  }
3188
- if (shouldAddLocalVideo) {
3189
- Object.keys(this.localStreams).forEach((id) => {
3190
- if (id === CAMERA_STREAM_ID) {
3191
- return;
3192
- }
3193
- const screenshareStream = this.localStreams[id];
3194
- if (isOfferer) {
3195
- session.addStream(screenshareStream);
3196
- }
3197
- else {
3198
- session.afterConnected.then(() => {
3199
- this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
3200
- receiverId: session.clientId,
3201
- streamId: screenshareStream.id,
3202
- hasAudioTrack: !!screenshareStream.getAudioTracks().length,
3203
- });
3204
- this._withForcedRenegotiation(session, () => session.addStream(screenshareStream));
3141
+ Object.keys(this.localStreams).forEach((id) => {
3142
+ if (id === CAMERA_STREAM_ID) {
3143
+ return;
3144
+ }
3145
+ const screenshareStream = this.localStreams[id];
3146
+ if (isOfferer) {
3147
+ session.addStream(screenshareStream);
3148
+ }
3149
+ else {
3150
+ session.afterConnected.then(() => {
3151
+ this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
3152
+ receiverId: session.clientId,
3153
+ streamId: screenshareStream.id,
3154
+ hasAudioTrack: !!screenshareStream.getAudioTracks().length,
3205
3155
  });
3206
- }
3207
- });
3208
- }
3156
+ this._withForcedRenegotiation(session, () => session.addStream(screenshareStream));
3157
+ });
3158
+ }
3159
+ });
3209
3160
  return session;
3210
3161
  }
3211
3162
  _cleanup(peerConnectionId) {
@@ -3292,10 +3243,9 @@ class P2pRtcManager {
3292
3243
  delete this.localStreams[streamId];
3293
3244
  this._deleteEnabledLocalStreamId(streamId);
3294
3245
  }
3295
- _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds }) {
3246
+ _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, mediaserverConfigTtlSeconds, }) {
3296
3247
  this._iceServers = iceServers;
3297
3248
  this._turnServers = turnServers;
3298
- this._sfuServer = sfuServer;
3299
3249
  this._mediaserverConfigTtlSeconds = mediaserverConfigTtlSeconds;
3300
3250
  this._clearMediaServersRefresh();
3301
3251
  if (!mediaserverConfigTtlSeconds) {
@@ -3342,7 +3292,6 @@ class P2pRtcManager {
3342
3292
  session = this._createP2pSession({
3343
3293
  clientId,
3344
3294
  initialBandwidth,
3345
- shouldAddLocalVideo: true,
3346
3295
  isOfferer: true,
3347
3296
  });
3348
3297
  this._negotiatePeerConnection(clientId, session);
@@ -3486,12 +3435,11 @@ class P2pRtcManager {
3486
3435
  });
3487
3436
  return bandwidth;
3488
3437
  }
3489
- _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, }) {
3438
+ _createP2pSession({ clientId, initialBandwidth, isOfferer = false, }) {
3490
3439
  const session = this._createSession({
3491
3440
  peerConnectionId: clientId,
3492
3441
  clientId,
3493
3442
  initialBandwidth,
3494
- shouldAddLocalVideo,
3495
3443
  isOfferer,
3496
3444
  });
3497
3445
  const pc = session.pc;
@@ -3499,10 +3447,7 @@ class P2pRtcManager {
3499
3447
  this._setJitterBufferTarget(pc);
3500
3448
  }
3501
3449
  const localCameraStream = this.localStreams[CAMERA_STREAM_ID];
3502
- if (shouldAddLocalVideo &&
3503
- localCameraStream &&
3504
- !localCameraStream.getVideoTracks().length &&
3505
- this._stoppedVideoTrack) {
3450
+ if (localCameraStream && !localCameraStream.getVideoTracks().length && this._stoppedVideoTrack) {
3506
3451
  pc.addTrack(this._stoppedVideoTrack, localCameraStream);
3507
3452
  }
3508
3453
  pc.onicegatheringstatechange = (event) => {
@@ -3608,7 +3553,7 @@ class P2pRtcManager {
3608
3553
  };
3609
3554
  return session;
3610
3555
  }
3611
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
3556
+ acceptNewStream({ streamId, clientId }) {
3612
3557
  let session = this._getSession(clientId);
3613
3558
  if (session && streamId !== clientId) {
3614
3559
  return session;
@@ -3624,7 +3569,6 @@ class P2pRtcManager {
3624
3569
  session = this._createP2pSession({
3625
3570
  clientId,
3626
3571
  initialBandwidth,
3627
- shouldAddLocalVideo: !!shouldAddLocalVideo,
3628
3572
  isOfferer: false,
3629
3573
  });
3630
3574
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
@@ -3731,6 +3675,9 @@ class P2pRtcManager {
3731
3675
  hasClient(clientId) {
3732
3676
  return Object.keys(this.peerConnections).includes(clientId);
3733
3677
  }
3678
+ shouldAcceptStreamsFromBothSides() {
3679
+ return false;
3680
+ }
3734
3681
  }
3735
3682
 
3736
3683
  class KalmanFilter {
@@ -4567,8 +4514,8 @@ const OUTBOUND_SCREEN_OUTBOUND_STREAM_ID = uuid.v4();
4567
4514
  if (browserName === "chrome")
4568
4515
  window.document.addEventListener("beforeunload", () => (unloading = true));
4569
4516
  class VegaRtcManager {
4570
- constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, }) {
4571
- const { session, iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds } = room;
4517
+ constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim }) {
4518
+ const { session, iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds } = room;
4572
4519
  this._selfId = selfId;
4573
4520
  this._room = room;
4574
4521
  this._roomSessionId = session === null || session === void 0 ? void 0 : session.id;
@@ -4622,7 +4569,6 @@ class VegaRtcManager {
4622
4569
  };
4623
4570
  this._updateAndScheduleMediaServersRefresh({
4624
4571
  sfuServer,
4625
- sfuServers,
4626
4572
  iceServers: (iceServers === null || iceServers === void 0 ? void 0 : iceServers.iceServers) || [],
4627
4573
  turnServers: turnServers || [],
4628
4574
  mediaserverConfigTtlSeconds,
@@ -4649,13 +4595,14 @@ class VegaRtcManager {
4649
4595
  camTrackEndedCount: 0,
4650
4596
  };
4651
4597
  }
4652
- _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, sfuServers, mediaserverConfigTtlSeconds, }) {
4653
- var _a, _b, _c;
4598
+ _updateAndScheduleMediaServersRefresh({ iceServers, turnServers, sfuServer, mediaserverConfigTtlSeconds, }) {
4599
+ var _a, _b, _c, _d;
4654
4600
  this._iceServers = iceServers;
4655
4601
  this._turnServers = turnServers;
4656
- this._sfuServer = sfuServer;
4657
- this._sfuServers = sfuServers;
4658
- if (!sfuServers && (sfuServer === null || sfuServer === void 0 ? void 0 : sfuServer.fallbackServers)) {
4602
+ if (sfuServer) {
4603
+ this._sfuServer = sfuServer;
4604
+ }
4605
+ if (sfuServer === null || sfuServer === void 0 ? void 0 : sfuServer.fallbackServers) {
4659
4606
  this._sfuServers = sfuServer.fallbackServers.map((entry) => ({
4660
4607
  host: entry.host || entry.fqdn,
4661
4608
  dc: entry.dc,
@@ -4665,14 +4612,14 @@ class VegaRtcManager {
4665
4612
  (_a = this._vegaConnectionManager) === null || _a === void 0 ? void 0 : _a.updateHostList(this._features.sfuServersOverride ||
4666
4613
  this._sfuServers ||
4667
4614
  this._features.sfuServerOverrideHost ||
4668
- sfuServer.url);
4615
+ ((_b = this._sfuServer) === null || _b === void 0 ? void 0 : _b.url));
4669
4616
  const iceServersList = {
4670
4617
  iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
4671
4618
  };
4672
4619
  iceServersList.iceServers = turnServerOverride(iceServersList.iceServers, this._features.turnServerOverrideHost);
4673
4620
  if (browserName !== "firefox") {
4674
- (_b = this._sendTransport) === null || _b === void 0 ? void 0 : _b.updateIceServers(iceServersList);
4675
- (_c = this._receiveTransport) === null || _c === void 0 ? void 0 : _c.updateIceServers(iceServersList);
4621
+ (_c = this._sendTransport) === null || _c === void 0 ? void 0 : _c.updateIceServers(iceServersList);
4622
+ (_d = this._receiveTransport) === null || _d === void 0 ? void 0 : _d.updateIceServers(iceServersList);
4676
4623
  }
4677
4624
  this._clearMediaServersRefresh();
4678
4625
  if (!mediaserverConfigTtlSeconds) {
@@ -4726,6 +4673,7 @@ class VegaRtcManager {
4726
4673
  });
4727
4674
  }
4728
4675
  _connect() {
4676
+ var _a;
4729
4677
  if (this._isConnectingOrConnected)
4730
4678
  return;
4731
4679
  if (!this._serverSocket.isConnected()) {
@@ -4741,7 +4689,7 @@ class VegaRtcManager {
4741
4689
  const hostList = this._features.sfuServersOverride ||
4742
4690
  this._sfuServers ||
4743
4691
  this._features.sfuServerOverrideHost ||
4744
- this._sfuServer.url;
4692
+ ((_a = this._sfuServer) === null || _a === void 0 ? void 0 : _a.url);
4745
4693
  this._vegaConnectionManager = createVegaConnectionManager({
4746
4694
  initialHostList: hostList,
4747
4695
  getUrlForHost: (host) => {
@@ -5483,14 +5431,14 @@ class VegaRtcManager {
5483
5431
  setRoomSessionId(roomSessionId) {
5484
5432
  this._roomSessionId = roomSessionId;
5485
5433
  }
5486
- disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
5434
+ disconnect(clientId, eventClaim) {
5487
5435
  var _a;
5488
- logger$2.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
5489
- const clientState = this._clientStates.get(clientIdOrStreamId);
5436
+ logger$2.info("disconnect() [clientId:%s, eventClaim:%s]", clientId, eventClaim);
5437
+ const clientState = this._clientStates.get(clientId);
5490
5438
  if (clientState) {
5491
5439
  clientState.hasAcceptedWebcamStream = false;
5492
5440
  clientState.hasAcceptedScreenStream = false;
5493
- this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
5441
+ this._syncIncomingStreamsWithPWA(clientId);
5494
5442
  }
5495
5443
  if (eventClaim) {
5496
5444
  this._eventClaim = eventClaim;
@@ -5532,7 +5480,7 @@ class VegaRtcManager {
5532
5480
  this._sendMicScore(this._micPaused ? 0 : data.out);
5533
5481
  }
5534
5482
  addNewStream(streamId, stream, audioPaused, videoPaused, beforeEffectTracks = []) {
5535
- if (streamId === "0") {
5483
+ if (streamId === CAMERA_STREAM_ID) {
5536
5484
  this._micPaused = audioPaused;
5537
5485
  this._webcamPaused = videoPaused;
5538
5486
  const videoTrack = stream.getVideoTracks()[0];
@@ -5999,7 +5947,7 @@ class VegaRtcManager {
5999
5947
  clientId,
6000
5948
  stream: webcamStream,
6001
5949
  streamId: camStreamId,
6002
- streamType: "webcam",
5950
+ streamType: STREAM_TYPES.webcam,
6003
5951
  });
6004
5952
  clientState.hasEmittedWebcamStream = true;
6005
5953
  }
@@ -6008,7 +5956,7 @@ class VegaRtcManager {
6008
5956
  clientId,
6009
5957
  stream: screenStream,
6010
5958
  streamId: screenShareStreamId,
6011
- streamType: "screenshare",
5959
+ streamType: STREAM_TYPES.screenshare,
6012
5960
  });
6013
5961
  clientState.hasEmittedScreenStream = true;
6014
5962
  }
@@ -6051,9 +5999,10 @@ class RtcManagerDispatcher {
6051
5999
  constructor({ emitter, serverSocket, webrtcProvider, features, }) {
6052
6000
  this.emitter = emitter;
6053
6001
  this.currentManager = null;
6054
- serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, ({ room, selfId, error, eventClaim }) => {
6055
- if (error)
6002
+ serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, (payload) => {
6003
+ if ("error" in payload)
6056
6004
  return;
6005
+ const { room, selfId, eventClaim } = payload;
6057
6006
  const config = {
6058
6007
  selfId,
6059
6008
  room,
@@ -7580,6 +7529,7 @@ exports.RtcEventNames = void 0;
7580
7529
  exports.ADDITIONAL_SCREEN_SHARE_SETTINGS = ADDITIONAL_SCREEN_SHARE_SETTINGS;
7581
7530
  exports.AUDIO_SETTINGS = AUDIO_SETTINGS;
7582
7531
  exports.BandwidthTester = BandwidthTester;
7532
+ exports.CAMERA_STREAM_ID = CAMERA_STREAM_ID;
7583
7533
  exports.EVENTS = EVENTS;
7584
7534
  exports.KNOCK_MESSAGES = KNOCK_MESSAGES;
7585
7535
  exports.KalmanFilter = KalmanFilter;
@@ -7594,7 +7544,6 @@ exports.PROTOCOL_RESPONSES = PROTOCOL_RESPONSES;
7594
7544
  exports.RELAY_MESSAGES = RELAY_MESSAGES;
7595
7545
  exports.ReconnectManager = ReconnectManager;
7596
7546
  exports.RtcManagerDispatcher = RtcManagerDispatcher;
7597
- exports.RtcStream = RtcStream;
7598
7547
  exports.SCREEN_SHARE_SETTINGS = SCREEN_SHARE_SETTINGS;
7599
7548
  exports.SCREEN_SHARE_SIMULCAST_SETTINGS = SCREEN_SHARE_SIMULCAST_SETTINGS;
7600
7549
  exports.STREAM_TYPES = STREAM_TYPES;