@whereby.com/media 2.8.2 → 2.8.3

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) {
@@ -2213,7 +2213,7 @@ var _a$4;
2213
2213
  const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
2214
2214
  const logger$7 = new Logger();
2215
2215
  class Session {
2216
- constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, shouldAddLocalVideo, incrementAnalyticMetric, }) {
2216
+ constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, incrementAnalyticMetric, }) {
2217
2217
  this.peerConnectionId = peerConnectionId;
2218
2218
  this.relayCandidateSeen = false;
2219
2219
  this.serverReflexiveCandidateSeen = false;
@@ -2223,7 +2223,6 @@ class Session {
2223
2223
  this.ipv6HostCandidate6to4Seen = false;
2224
2224
  this.mdnsHostCandidateSeen = false;
2225
2225
  this.peerConnectionConfig = peerConnectionConfig;
2226
- this.shouldAddLocalVideo = shouldAddLocalVideo;
2227
2226
  this.clientId = clientId;
2228
2227
  this.pc = new RTCPeerConnection(this.peerConnectionConfig);
2229
2228
  this.signalingState = this.pc.signalingState;
@@ -2291,11 +2290,13 @@ class Session {
2291
2290
  }
2292
2291
  }
2293
2292
  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
- }
2293
+ const streamIdIndex = this.streamIds.indexOf(stream.id);
2294
+ if (streamIdIndex !== -1) {
2295
+ this.streamIds.splice(streamIdIndex, 1);
2296
+ }
2297
+ const streamIndex = this.streams.indexOf(stream);
2298
+ if (streamIndex !== -1) {
2299
+ this.streams.splice(streamIndex, 1);
2299
2300
  }
2300
2301
  if (this.pc) {
2301
2302
  if (this.pc.removeTrack) {
@@ -2561,57 +2562,6 @@ const TYPES = {
2561
2562
  CONNECTION_DISCONNECTED: "connection_disconnected",
2562
2563
  };
2563
2564
 
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
2565
  var rtcManagerEvents = {
2616
2566
  CAMERA_NOT_WORKING: "camera_not_working",
2617
2567
  CONNECTION_BLOCKED_BY_NETWORK: "connection_blocked_by_network",
@@ -2626,11 +2576,16 @@ var rtcManagerEvents = {
2626
2576
  DOMINANT_SPEAKER: "dominant_speaker",
2627
2577
  };
2628
2578
 
2579
+ const CAMERA_STREAM_ID = "0";
2580
+ const STREAM_TYPES = {
2581
+ webcam: "webcam",
2582
+ screenshare: "screenshare",
2583
+ };
2584
+
2629
2585
  var _a$2, _b$1, _c;
2630
2586
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
2631
2587
  const logger$6 = new Logger();
2632
2588
  const ICE_PUBLIC_IP_GATHERING_TIMEOUT = 3 * 1000;
2633
- const CAMERA_STREAM_ID = RtcStream.getCameraId();
2634
2589
  const browserName$1 = (_b$1 = adapter$2.browserDetails) === null || _b$1 === void 0 ? void 0 : _b$1.browser;
2635
2590
  const browserVersion = adapter$2.browserDetails.version;
2636
2591
  if (browserName$1 === "firefox" && adapter$2.browserShim && "shimGetDisplayMedia" in adapter$2.browserShim) {
@@ -2855,13 +2810,10 @@ class P2pRtcManager {
2855
2810
  });
2856
2811
  }),
2857
2812
  this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, (payload) => {
2858
- var _a, _b;
2859
- if (payload === null || payload === void 0 ? void 0 : payload.error) {
2813
+ const { error } = payload;
2814
+ if (error || !this._wasScreenSharing) {
2860
2815
  return;
2861
2816
  }
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
2817
  const screenShareStreamId = Object.keys(this.localStreams).find((id) => id !== CAMERA_STREAM_ID);
2866
2818
  if (!screenShareStreamId) {
2867
2819
  return;
@@ -2877,6 +2829,15 @@ class P2pRtcManager {
2877
2829
  hasAudioTrack,
2878
2830
  });
2879
2831
  }),
2832
+ this._serverSocket.on(PROTOCOL_RESPONSES.SCREENSHARE_STOPPED, (payload) => {
2833
+ const session = this._getSession(payload.clientId);
2834
+ if (session) {
2835
+ const streamIdIndex = session.streamIds.indexOf(payload.streamId);
2836
+ if (streamIdIndex !== -1) {
2837
+ session.streamIds.splice(streamIdIndex, 1);
2838
+ }
2839
+ }
2840
+ }),
2880
2841
  ];
2881
2842
  }
2882
2843
  sendAudioMutedStats(muted) {
@@ -2988,7 +2949,7 @@ class P2pRtcManager {
2988
2949
  }
2989
2950
  return this.peerConnections[peerConnectionId];
2990
2951
  }
2991
- _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, shouldAddLocalVideo, }) {
2952
+ _getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, }) {
2992
2953
  let session = this.peerConnections[peerConnectionId];
2993
2954
  if (session === undefined) {
2994
2955
  const deprioritizeH264Encoding = browserName$1 === "safari" &&
@@ -3001,7 +2962,6 @@ class P2pRtcManager {
3001
2962
  peerConnectionConfig,
3002
2963
  bandwidth: initialBandwidth,
3003
2964
  deprioritizeH264Encoding,
3004
- shouldAddLocalVideo,
3005
2965
  incrementAnalyticMetric: (metric) => this.analytics[metric]++,
3006
2966
  });
3007
2967
  }
@@ -3034,7 +2994,7 @@ class P2pRtcManager {
3034
2994
  _transformOutgoingSdp(original) {
3035
2995
  return { type: original.type, sdpU: original.sdp, sdp: original.sdp };
3036
2996
  }
3037
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
2997
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, }) {
3038
2998
  if (!peerConnectionId) {
3039
2999
  throw new Error("peerConnectionId is missing");
3040
3000
  }
@@ -3063,7 +3023,6 @@ class P2pRtcManager {
3063
3023
  clientId,
3064
3024
  initialBandwidth,
3065
3025
  peerConnectionConfig,
3066
- shouldAddLocalVideo,
3067
3026
  });
3068
3027
  setTimeout(() => this._emit(rtcManagerEvents.NEW_PC), 0);
3069
3028
  this.analytics.numNewPc++;
@@ -3074,7 +3033,7 @@ class P2pRtcManager {
3074
3033
  this.analytics.P2POnTrackNoStream++;
3075
3034
  rtcStats.sendEvent("P2POnTrackNoStream", {
3076
3035
  trackKind: event.track.kind,
3077
- trackId: event.track.id
3036
+ trackId: event.track.id,
3078
3037
  });
3079
3038
  return;
3080
3039
  }
@@ -3161,30 +3120,28 @@ class P2pRtcManager {
3161
3120
  }
3162
3121
  };
3163
3122
  const localCameraStream = this.localStreams[CAMERA_STREAM_ID];
3164
- if (shouldAddLocalVideo && localCameraStream) {
3123
+ if (localCameraStream) {
3165
3124
  session.addStream(localCameraStream);
3166
3125
  }
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));
3126
+ Object.keys(this.localStreams).forEach((id) => {
3127
+ if (id === CAMERA_STREAM_ID) {
3128
+ return;
3129
+ }
3130
+ const screenshareStream = this.localStreams[id];
3131
+ if (isOfferer) {
3132
+ session.addStream(screenshareStream);
3133
+ }
3134
+ else {
3135
+ session.afterConnected.then(() => {
3136
+ this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
3137
+ receiverId: session.clientId,
3138
+ streamId: screenshareStream.id,
3139
+ hasAudioTrack: !!screenshareStream.getAudioTracks().length,
3184
3140
  });
3185
- }
3186
- });
3187
- }
3141
+ this._withForcedRenegotiation(session, () => session.addStream(screenshareStream));
3142
+ });
3143
+ }
3144
+ });
3188
3145
  return session;
3189
3146
  }
3190
3147
  _cleanup(peerConnectionId) {
@@ -3321,7 +3278,6 @@ class P2pRtcManager {
3321
3278
  session = this._createP2pSession({
3322
3279
  clientId,
3323
3280
  initialBandwidth,
3324
- shouldAddLocalVideo: true,
3325
3281
  isOfferer: true,
3326
3282
  });
3327
3283
  this._negotiatePeerConnection(clientId, session);
@@ -3465,12 +3421,11 @@ class P2pRtcManager {
3465
3421
  });
3466
3422
  return bandwidth;
3467
3423
  }
3468
- _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, }) {
3424
+ _createP2pSession({ clientId, initialBandwidth, isOfferer = false, }) {
3469
3425
  const session = this._createSession({
3470
3426
  peerConnectionId: clientId,
3471
3427
  clientId,
3472
3428
  initialBandwidth,
3473
- shouldAddLocalVideo,
3474
3429
  isOfferer,
3475
3430
  });
3476
3431
  const pc = session.pc;
@@ -3478,10 +3433,7 @@ class P2pRtcManager {
3478
3433
  this._setJitterBufferTarget(pc);
3479
3434
  }
3480
3435
  const localCameraStream = this.localStreams[CAMERA_STREAM_ID];
3481
- if (shouldAddLocalVideo &&
3482
- localCameraStream &&
3483
- !localCameraStream.getVideoTracks().length &&
3484
- this._stoppedVideoTrack) {
3436
+ if (localCameraStream && !localCameraStream.getVideoTracks().length && this._stoppedVideoTrack) {
3485
3437
  pc.addTrack(this._stoppedVideoTrack, localCameraStream);
3486
3438
  }
3487
3439
  pc.onicegatheringstatechange = (event) => {
@@ -3587,7 +3539,7 @@ class P2pRtcManager {
3587
3539
  };
3588
3540
  return session;
3589
3541
  }
3590
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
3542
+ acceptNewStream({ streamId, clientId }) {
3591
3543
  let session = this._getSession(clientId);
3592
3544
  if (session && streamId !== clientId) {
3593
3545
  return session;
@@ -3603,7 +3555,6 @@ class P2pRtcManager {
3603
3555
  session = this._createP2pSession({
3604
3556
  clientId,
3605
3557
  initialBandwidth,
3606
- shouldAddLocalVideo: !!shouldAddLocalVideo,
3607
3558
  isOfferer: false,
3608
3559
  });
3609
3560
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
@@ -3710,6 +3661,9 @@ class P2pRtcManager {
3710
3661
  hasClient(clientId) {
3711
3662
  return Object.keys(this.peerConnections).includes(clientId);
3712
3663
  }
3664
+ shouldAcceptStreamsFromBothSides() {
3665
+ return false;
3666
+ }
3713
3667
  }
3714
3668
 
3715
3669
  class KalmanFilter {
@@ -5462,14 +5416,14 @@ class VegaRtcManager {
5462
5416
  setRoomSessionId(roomSessionId) {
5463
5417
  this._roomSessionId = roomSessionId;
5464
5418
  }
5465
- disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
5419
+ disconnect(clientId, eventClaim) {
5466
5420
  var _a;
5467
- logger$2.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
5468
- const clientState = this._clientStates.get(clientIdOrStreamId);
5421
+ logger$2.info("disconnect() [clientId:%s, eventClaim:%s]", clientId, eventClaim);
5422
+ const clientState = this._clientStates.get(clientId);
5469
5423
  if (clientState) {
5470
5424
  clientState.hasAcceptedWebcamStream = false;
5471
5425
  clientState.hasAcceptedScreenStream = false;
5472
- this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
5426
+ this._syncIncomingStreamsWithPWA(clientId);
5473
5427
  }
5474
5428
  if (eventClaim) {
5475
5429
  this._eventClaim = eventClaim;
@@ -5511,7 +5465,7 @@ class VegaRtcManager {
5511
5465
  this._sendMicScore(this._micPaused ? 0 : data.out);
5512
5466
  }
5513
5467
  addNewStream(streamId, stream, audioPaused, videoPaused, beforeEffectTracks = []) {
5514
- if (streamId === "0") {
5468
+ if (streamId === CAMERA_STREAM_ID) {
5515
5469
  this._micPaused = audioPaused;
5516
5470
  this._webcamPaused = videoPaused;
5517
5471
  const videoTrack = stream.getVideoTracks()[0];
@@ -5978,7 +5932,7 @@ class VegaRtcManager {
5978
5932
  clientId,
5979
5933
  stream: webcamStream,
5980
5934
  streamId: camStreamId,
5981
- streamType: "webcam",
5935
+ streamType: STREAM_TYPES.webcam,
5982
5936
  });
5983
5937
  clientState.hasEmittedWebcamStream = true;
5984
5938
  }
@@ -5987,7 +5941,7 @@ class VegaRtcManager {
5987
5941
  clientId,
5988
5942
  stream: screenStream,
5989
5943
  streamId: screenShareStreamId,
5990
- streamType: "screenshare",
5944
+ streamType: STREAM_TYPES.screenshare,
5991
5945
  });
5992
5946
  clientState.hasEmittedScreenStream = true;
5993
5947
  }
@@ -7556,5 +7510,5 @@ var RtcEventNames;
7556
7510
  RtcEventNames["stream_added"] = "stream_added";
7557
7511
  })(RtcEventNames || (RtcEventNames = {}));
7558
7512
 
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 };
7513
+ 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
7514
  //# 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.3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {