@stream-io/video-client 1.55.2 → 1.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.browser.es.js +180 -103
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +180 -103
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +180 -103
- package/dist/index.es.js.map +1 -1
- package/dist/src/helpers/BlockedAudioTracker.d.ts +16 -1
- package/dist/src/reporting/ClientEventReporter.d.ts +1 -0
- package/dist/src/rtc/Publisher.d.ts +1 -0
- package/dist/src/rtc/types.d.ts +9 -2
- package/dist/src/store/rxUtils.d.ts +5 -0
- package/package.json +2 -2
- package/src/Call.ts +1 -0
- package/src/helpers/BlockedAudioTracker.ts +71 -13
- package/src/helpers/DynascaleManager.ts +14 -3
- package/src/helpers/__tests__/BlockedAudioTracker.test.ts +54 -6
- package/src/helpers/__tests__/DynascaleManager.test.ts +45 -0
- package/src/reporting/ClientEventReporter.ts +37 -31
- package/src/reporting/__tests__/ClientEventReporter.test.ts +159 -44
- package/src/rtc/BasePeerConnection.ts +1 -0
- package/src/rtc/Publisher.ts +78 -58
- package/src/rtc/__tests__/Publisher.test.ts +297 -0
- package/src/rtc/types.ts +13 -11
- package/src/store/CallState.ts +5 -17
- package/src/store/rxUtils.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.56.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.55.2...@stream-io/video-client-1.56.0) (2026-07-30)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **react-sdk:** show blocked audio overlay per participant ([#2341](https://github.com/GetStream/stream-video-js/issues/2341)) ([4fe5c40](https://github.com/GetStream/stream-video-js/commit/4fe5c40aaed1829125bff49deec39a008c7abec5))
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- **client:** fix stale mid in SetPublisher after PeerConnection rollback ([#2344](https://github.com/GetStream/stream-video-js/issues/2344)) ([9c3e201](https://github.com/GetStream/stream-video-js/commit/9c3e201c9a1cf129e182da961b1d73652508b9f2))
|
|
14
|
+
- **client:** never announce two tracks for the same publish option ([#2352](https://github.com/GetStream/stream-video-js/issues/2352)) ([b9a0c6e](https://github.com/GetStream/stream-video-js/commit/b9a0c6e709805e8658e74a68dc6e84459353db37))
|
|
15
|
+
- **client:** preserve ICE state in peer connection failure reports ([#2340](https://github.com/GetStream/stream-video-js/issues/2340)) ([2ce42a2](https://github.com/GetStream/stream-video-js/commit/2ce42a229eecfc60ae8f6783672c517b94b6ab42))
|
|
16
|
+
|
|
5
17
|
## [1.55.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.55.1...@stream-io/video-client-1.55.2) (2026-07-17)
|
|
6
18
|
|
|
7
19
|
### Bug Fixes
|
package/dist/index.browser.es.js
CHANGED
|
@@ -4926,7 +4926,7 @@ const toIceCandidate = (iceTrickle) => {
|
|
|
4926
4926
|
}
|
|
4927
4927
|
};
|
|
4928
4928
|
|
|
4929
|
-
const version = "1.
|
|
4929
|
+
const version = "1.56.0";
|
|
4930
4930
|
const [major, minor, patch] = version.split('.');
|
|
4931
4931
|
let sdkInfo = {
|
|
4932
4932
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -5255,6 +5255,23 @@ function wrapWithCancellation(tag, cb) {
|
|
|
5255
5255
|
return { cb: wrapped, onContinued };
|
|
5256
5256
|
}
|
|
5257
5257
|
|
|
5258
|
+
/**
|
|
5259
|
+
* Performs shallow comparison of two arrays.
|
|
5260
|
+
* Expects primitive values: [1, 2, 3] is equal to [2, 1, 3].
|
|
5261
|
+
*/
|
|
5262
|
+
const isShallowArrayEqual = (a, b) => {
|
|
5263
|
+
if (a.length !== b.length)
|
|
5264
|
+
return false;
|
|
5265
|
+
for (const item of a) {
|
|
5266
|
+
if (!b.includes(item))
|
|
5267
|
+
return false;
|
|
5268
|
+
}
|
|
5269
|
+
for (const item of b) {
|
|
5270
|
+
if (!a.includes(item))
|
|
5271
|
+
return false;
|
|
5272
|
+
}
|
|
5273
|
+
return true;
|
|
5274
|
+
};
|
|
5258
5275
|
/**
|
|
5259
5276
|
* Checks if the provided update is a function patch.
|
|
5260
5277
|
*
|
|
@@ -5367,6 +5384,7 @@ var rxUtils = /*#__PURE__*/Object.freeze({
|
|
|
5367
5384
|
createSafeAsyncSubscription: createSafeAsyncSubscription,
|
|
5368
5385
|
createSubscription: createSubscription,
|
|
5369
5386
|
getCurrentValue: getCurrentValue,
|
|
5387
|
+
isShallowArrayEqual: isShallowArrayEqual,
|
|
5370
5388
|
setCurrentValue: setCurrentValue,
|
|
5371
5389
|
setCurrentValueAsync: setCurrentValueAsync,
|
|
5372
5390
|
updateValue: updateValue
|
|
@@ -6107,23 +6125,6 @@ class CallState {
|
|
|
6107
6125
|
this.endedBy$ = this.endedBySubject.asObservable();
|
|
6108
6126
|
this.thumbnails$ = this.thumbnailsSubject.asObservable();
|
|
6109
6127
|
this.closedCaptions$ = this.closedCaptionsSubject.asObservable();
|
|
6110
|
-
/**
|
|
6111
|
-
* Performs shallow comparison of two arrays.
|
|
6112
|
-
* Expects primitive values: [1, 2, 3] is equal to [2, 1, 3].
|
|
6113
|
-
*/
|
|
6114
|
-
const isShallowEqual = (a, b) => {
|
|
6115
|
-
if (a.length !== b.length)
|
|
6116
|
-
return false;
|
|
6117
|
-
for (const item of a) {
|
|
6118
|
-
if (!b.includes(item))
|
|
6119
|
-
return false;
|
|
6120
|
-
}
|
|
6121
|
-
for (const item of b) {
|
|
6122
|
-
if (!a.includes(item))
|
|
6123
|
-
return false;
|
|
6124
|
-
}
|
|
6125
|
-
return true;
|
|
6126
|
-
};
|
|
6127
6128
|
/**
|
|
6128
6129
|
* Creates an Observable from the given subject by piping to the
|
|
6129
6130
|
* `distinctUntilChanged()` operator.
|
|
@@ -6131,7 +6132,7 @@ class CallState {
|
|
|
6131
6132
|
const duc = (subject, comparator) => subject.pipe(distinctUntilChanged(comparator));
|
|
6132
6133
|
// primitive values should only emit once the value they hold changes
|
|
6133
6134
|
this.anonymousParticipantCount$ = duc(this.anonymousParticipantCountSubject);
|
|
6134
|
-
this.blockedUserIds$ = duc(this.blockedUserIdsSubject,
|
|
6135
|
+
this.blockedUserIds$ = duc(this.blockedUserIdsSubject, isShallowArrayEqual);
|
|
6135
6136
|
this.backstage$ = duc(this.backstageSubject);
|
|
6136
6137
|
this.callingState$ = duc(this.callingStateSubject);
|
|
6137
6138
|
this.ownCapabilities$ = combineLatest([
|
|
@@ -6160,7 +6161,7 @@ class CallState {
|
|
|
6160
6161
|
}
|
|
6161
6162
|
}
|
|
6162
6163
|
return nextCapabilities;
|
|
6163
|
-
}), distinctUntilChanged(
|
|
6164
|
+
}), distinctUntilChanged(isShallowArrayEqual), shareReplay({ bufferSize: 1, refCount: true }));
|
|
6164
6165
|
this.participantCount$ = duc(this.participantCountSubject);
|
|
6165
6166
|
this.recording$ = duc(this.recordingSubject);
|
|
6166
6167
|
this.individualRecording$ = duc(this.individualRecordingSubject);
|
|
@@ -8471,6 +8472,7 @@ class BasePeerConnection {
|
|
|
8471
8472
|
try {
|
|
8472
8473
|
this.onPeerConnectionStateChange?.({
|
|
8473
8474
|
peerType: this.peerType,
|
|
8475
|
+
iceConnectionState: this.pc.iceConnectionState,
|
|
8474
8476
|
...event,
|
|
8475
8477
|
});
|
|
8476
8478
|
}
|
|
@@ -8925,6 +8927,7 @@ class Publisher extends BasePeerConnection {
|
|
|
8925
8927
|
clonedTracks = new Set();
|
|
8926
8928
|
publishOptions;
|
|
8927
8929
|
selfSubEnabled;
|
|
8930
|
+
transceiverLockKey = `pub.tx.${this.lock}`;
|
|
8928
8931
|
/**
|
|
8929
8932
|
* Constructs a new `Publisher` instance.
|
|
8930
8933
|
*/
|
|
@@ -8980,32 +8983,34 @@ class Publisher extends BasePeerConnection {
|
|
|
8980
8983
|
* @param options the publish options to use.
|
|
8981
8984
|
*/
|
|
8982
8985
|
publish = async (track, trackType, options = {}) => {
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
if (publishOption.trackType !== trackType)
|
|
8988
|
-
continue;
|
|
8989
|
-
// create a clone of the track as otherwise the same trackId will
|
|
8990
|
-
// appear in the SDP in multiple transceivers
|
|
8991
|
-
const trackToPublish = this.cloneTrack(track);
|
|
8992
|
-
const bundle = this.transceiverCache.get(publishOption);
|
|
8993
|
-
if (!bundle) {
|
|
8994
|
-
await this.addTransceiver(trackToPublish, publishOption, options);
|
|
8986
|
+
return withoutConcurrency(this.transceiverLockKey, async () => {
|
|
8987
|
+
const publishOptions = this.publishOptions.filter((o) => o.trackType === trackType);
|
|
8988
|
+
if (!publishOptions.length) {
|
|
8989
|
+
throw new Error(`No publish options found for ${TrackType[trackType]}`);
|
|
8995
8990
|
}
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
8991
|
+
for (const publishOption of publishOptions) {
|
|
8992
|
+
// create a clone of the track as otherwise the same trackId will
|
|
8993
|
+
// appear in the SDP in multiple transceivers
|
|
8994
|
+
const trackToPublish = this.cloneTrack(track);
|
|
8995
|
+
const bundle = this.transceiverCache.get(publishOption);
|
|
8996
|
+
if (!bundle) {
|
|
8997
|
+
await this.addTransceiver(trackToPublish, publishOption, options);
|
|
8998
|
+
}
|
|
8999
|
+
else {
|
|
9000
|
+
const previousTrack = bundle.transceiver.sender.track;
|
|
9001
|
+
await this.updateTransceiver(bundle, trackToPublish, options);
|
|
9002
|
+
if (!isReactNative()) {
|
|
9003
|
+
this.stopTrack(previousTrack);
|
|
9004
|
+
}
|
|
9001
9005
|
}
|
|
9002
9006
|
}
|
|
9003
|
-
}
|
|
9007
|
+
});
|
|
9004
9008
|
};
|
|
9005
9009
|
/**
|
|
9006
9010
|
* Adds a new transceiver carrying the given track to the peer connection.
|
|
9007
9011
|
*/
|
|
9008
9012
|
addTransceiver = async (track, publishOption, options) => {
|
|
9013
|
+
const trackType = publishOption.trackType;
|
|
9009
9014
|
const encodings = isAudioTrackType(publishOption.trackType)
|
|
9010
9015
|
? computeAudioLayers(publishOption, options)
|
|
9011
9016
|
: computeVideoLayers(track, publishOption);
|
|
@@ -9016,15 +9021,17 @@ class Publisher extends BasePeerConnection {
|
|
|
9016
9021
|
direction: 'sendonly',
|
|
9017
9022
|
sendEncodings,
|
|
9018
9023
|
});
|
|
9024
|
+
// claim the cache entry in the same task that created the transceiver:
|
|
9025
|
+
// an await in between would let a concurrent caller add a second one
|
|
9026
|
+
// for the same publish option
|
|
9027
|
+
this.transceiverCache.add({ publishOption, transceiver, options });
|
|
9028
|
+
this.trackIdToTrackType.set(track.id, trackType);
|
|
9029
|
+
this.logger.debug(`Added ${TrackType[trackType]} transceiver`);
|
|
9019
9030
|
const params = transceiver.sender.getParameters();
|
|
9020
9031
|
params.degradationPreference =
|
|
9021
9032
|
toRTCDegradationPreference(publishOption.degradationPreference) ??
|
|
9022
9033
|
'maintain-framerate';
|
|
9023
9034
|
await transceiver.sender.setParameters(params);
|
|
9024
|
-
const trackType = publishOption.trackType;
|
|
9025
|
-
this.logger.debug(`Added ${TrackType[trackType]} transceiver`);
|
|
9026
|
-
this.transceiverCache.add({ publishOption, transceiver, options });
|
|
9027
|
-
this.trackIdToTrackType.set(track.id, trackType);
|
|
9028
9035
|
await this.negotiate();
|
|
9029
9036
|
};
|
|
9030
9037
|
/**
|
|
@@ -9081,33 +9088,35 @@ class Publisher extends BasePeerConnection {
|
|
|
9081
9088
|
* Synchronizes the current Publisher state with the provided publish options.
|
|
9082
9089
|
*/
|
|
9083
9090
|
syncPublishOptions = async () => {
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
const
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
i.
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
const
|
|
9103
|
-
|
|
9104
|
-
option.
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9091
|
+
return withoutConcurrency(this.transceiverLockKey, async () => {
|
|
9092
|
+
// enable publishing with new options -> [av1, vp9]
|
|
9093
|
+
for (const publishOption of this.publishOptions) {
|
|
9094
|
+
const { trackType } = publishOption;
|
|
9095
|
+
if (!this.isPublishing(trackType))
|
|
9096
|
+
continue;
|
|
9097
|
+
if (this.transceiverCache.has(publishOption))
|
|
9098
|
+
continue;
|
|
9099
|
+
const item = this.transceiverCache.find((i) => !!i.transceiver.sender.track &&
|
|
9100
|
+
i.publishOption.trackType === trackType);
|
|
9101
|
+
if (!item)
|
|
9102
|
+
continue;
|
|
9103
|
+
// take the track from the existing transceiver for the same track type,
|
|
9104
|
+
// clone it and publish it with the new publish options
|
|
9105
|
+
const track = this.cloneTrack(item.transceiver.sender.track);
|
|
9106
|
+
await this.addTransceiver(track, publishOption, item.options);
|
|
9107
|
+
}
|
|
9108
|
+
// stop publishing with options not required anymore -> [vp9]
|
|
9109
|
+
for (const item of this.transceiverCache.items()) {
|
|
9110
|
+
const { publishOption, transceiver } = item;
|
|
9111
|
+
const hasPublishOption = this.publishOptions.some((option) => option.id === publishOption.id &&
|
|
9112
|
+
option.trackType === publishOption.trackType);
|
|
9113
|
+
if (hasPublishOption)
|
|
9114
|
+
continue;
|
|
9115
|
+
// it is safe to stop the track here, it is a clone
|
|
9116
|
+
this.stopTrack(transceiver.sender.track);
|
|
9117
|
+
await this.updateTransceiver(item, null);
|
|
9118
|
+
}
|
|
9119
|
+
});
|
|
9111
9120
|
};
|
|
9112
9121
|
/**
|
|
9113
9122
|
* Returns true if the given track type is currently being published to the SFU.
|
|
@@ -9275,12 +9284,23 @@ class Publisher extends BasePeerConnection {
|
|
|
9275
9284
|
negotiate = async (options) => {
|
|
9276
9285
|
return withoutConcurrency(`publisher.negotiate.${this.lock}`, async () => {
|
|
9277
9286
|
const offer = await this.pc.createOffer(options);
|
|
9278
|
-
const tracks = this.getAnnouncedTracks(offer.sdp);
|
|
9279
|
-
if (!tracks.length)
|
|
9280
|
-
throw new Error(`Can't negotiate without any tracks`);
|
|
9281
9287
|
try {
|
|
9282
9288
|
this.isIceRestarting = options?.iceRestart ?? false;
|
|
9283
9289
|
await this.pc.setLocalDescription(offer);
|
|
9290
|
+
// the announced tracks have to be read after `setLocalDescription`.
|
|
9291
|
+
// `transceiver.mid` is null until the offer is applied, and reading the
|
|
9292
|
+
// tracks earlier makes `extractMid` guess the mid from the offer SDP.
|
|
9293
|
+
// That guess goes stale after a rolled-back negotiation, and a mid that
|
|
9294
|
+
// doesn't match the m-section carrying the track stops the SFU from
|
|
9295
|
+
// correlating the two: it then answers with every offered codec instead
|
|
9296
|
+
// of the announced one, and we publish the first codec of that list.
|
|
9297
|
+
// Per https://www.w3.org/TR/webrtc/#set-description, applying a local
|
|
9298
|
+
// offer associates the transceiver with its m-section and sets
|
|
9299
|
+
// `[[Mid]]` to `[[JsepMid]]`; a rollback disassociates a transceiver
|
|
9300
|
+
// that wasn't associated before and resets both slots to null.
|
|
9301
|
+
const tracks = this.getAnnouncedTracks(offer.sdp);
|
|
9302
|
+
if (!tracks.length)
|
|
9303
|
+
throw new Error(`Can't negotiate without any tracks`);
|
|
9284
9304
|
const { sdp: baseSdp = '' } = offer;
|
|
9285
9305
|
const { dangerouslyForceCodec, dangerouslySetStartBitrateFactor, fmtpLine, } = this.clientPublishOptions || {};
|
|
9286
9306
|
let sdp = dangerouslyForceCodec
|
|
@@ -10905,34 +10925,67 @@ class AudioBindingsWatchdog {
|
|
|
10905
10925
|
class BlockedAudioTracker {
|
|
10906
10926
|
logger = videoLoggerSystem.getLogger('BlockedAudioTracker');
|
|
10907
10927
|
tracer;
|
|
10908
|
-
blockedElementsSubject = new BehaviorSubject(
|
|
10928
|
+
blockedElementsSubject = new BehaviorSubject([]);
|
|
10909
10929
|
/**
|
|
10910
10930
|
* Whether the browser's autoplay policy is blocking audio playback.
|
|
10911
10931
|
* Will be `true` when at least one audio element is currently blocked.
|
|
10912
10932
|
* Use {@link resumeAudio} within a user gesture to unblock.
|
|
10913
10933
|
*/
|
|
10914
|
-
autoplayBlocked$ = this.blockedElementsSubject.pipe(map((elements) => elements.
|
|
10934
|
+
autoplayBlocked$ = this.blockedElementsSubject.pipe(map((elements) => elements.length > 0), distinctUntilChanged());
|
|
10935
|
+
/**
|
|
10936
|
+
* The list of participant `sessionId`s whose audio element is currently
|
|
10937
|
+
* blocked by the browser's autoplay policy. Only some participants may be
|
|
10938
|
+
* blocked (e.g. one joined while a gesture was active and a later one was
|
|
10939
|
+
* not), so use this to render a per-participant affordance rather than a
|
|
10940
|
+
* call-wide one. Call {@link resumeAudio} within a user gesture to unblock
|
|
10941
|
+
* all of them.
|
|
10942
|
+
*
|
|
10943
|
+
* Session ids are registered together with the audio element.
|
|
10944
|
+
*/
|
|
10945
|
+
blockedSessionIds$ = this.blockedElementsSubject.pipe(map((elements) => {
|
|
10946
|
+
const ids = [];
|
|
10947
|
+
elements.forEach(({ sessionId }) => {
|
|
10948
|
+
if (sessionId && !ids.includes(sessionId))
|
|
10949
|
+
ids.push(sessionId);
|
|
10950
|
+
});
|
|
10951
|
+
return ids;
|
|
10952
|
+
}), distinctUntilChanged(isShallowArrayEqual), shareReplay({ bufferSize: 1, refCount: true }));
|
|
10915
10953
|
constructor(tracer) {
|
|
10916
10954
|
this.tracer = tracer;
|
|
10917
10955
|
}
|
|
10918
10956
|
/**
|
|
10919
10957
|
* Registers an audio element as blocked by the browser's autoplay policy.
|
|
10920
10958
|
*/
|
|
10921
|
-
markBlocked = (audioElement, blocked) => {
|
|
10959
|
+
markBlocked = (audioElement, blocked, sessionId) => {
|
|
10922
10960
|
setCurrentValue(this.blockedElementsSubject, (elements) => {
|
|
10923
|
-
if (blocked)
|
|
10924
|
-
elements.
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10961
|
+
if (!blocked) {
|
|
10962
|
+
return elements.filter(({ element }) => element !== audioElement);
|
|
10963
|
+
}
|
|
10964
|
+
const existing = elements.find(({ element }) => element === audioElement);
|
|
10965
|
+
if (existing) {
|
|
10966
|
+
return elements.map((entry) => entry.element === audioElement
|
|
10967
|
+
? { element: audioElement, sessionId: sessionId ?? entry.sessionId }
|
|
10968
|
+
: entry);
|
|
10969
|
+
}
|
|
10970
|
+
return [...elements, { element: audioElement, sessionId }];
|
|
10928
10971
|
});
|
|
10929
10972
|
};
|
|
10973
|
+
/**
|
|
10974
|
+
* Clears all tracked elements. The tracker stays usable afterwards.
|
|
10975
|
+
*/
|
|
10976
|
+
reset = () => {
|
|
10977
|
+
if (this.blockedElementsSubject.getValue().length > 0) {
|
|
10978
|
+
this.blockedElementsSubject.next([]);
|
|
10979
|
+
}
|
|
10980
|
+
};
|
|
10930
10981
|
/**
|
|
10931
10982
|
* Returns whether the given audio element is currently flagged as blocked
|
|
10932
10983
|
* by the browser's autoplay policy.
|
|
10933
10984
|
*/
|
|
10934
10985
|
isBlocked = (audioElement) => {
|
|
10935
|
-
return this.blockedElementsSubject
|
|
10986
|
+
return this.blockedElementsSubject
|
|
10987
|
+
.getValue()
|
|
10988
|
+
.some(({ element }) => element === audioElement);
|
|
10936
10989
|
};
|
|
10937
10990
|
/**
|
|
10938
10991
|
* Plays all audio elements blocked by the browser's autoplay policy.
|
|
@@ -10941,17 +10994,18 @@ class BlockedAudioTracker {
|
|
|
10941
10994
|
resumeAudio = async () => {
|
|
10942
10995
|
this.tracer.trace('resumeAudio', null);
|
|
10943
10996
|
await setCurrentValueAsync(this.blockedElementsSubject, async (elements) => {
|
|
10944
|
-
|
|
10997
|
+
let next = elements;
|
|
10998
|
+
await Promise.all(elements.map(async ({ element }) => {
|
|
10945
10999
|
try {
|
|
10946
11000
|
if (element.srcObject)
|
|
10947
11001
|
await timeboxed([element.play()], 2000);
|
|
10948
|
-
|
|
11002
|
+
next = next.filter((entry) => entry.element !== element);
|
|
10949
11003
|
}
|
|
10950
11004
|
catch (err) {
|
|
10951
11005
|
this.logger.warn(`Can't resume audio for element`, element, err);
|
|
10952
11006
|
}
|
|
10953
11007
|
}));
|
|
10954
|
-
return
|
|
11008
|
+
return next;
|
|
10955
11009
|
});
|
|
10956
11010
|
};
|
|
10957
11011
|
}
|
|
@@ -11483,6 +11537,12 @@ class DynascaleManager {
|
|
|
11483
11537
|
let sourceNode = undefined;
|
|
11484
11538
|
let gainNode = undefined;
|
|
11485
11539
|
let audioWatchdog = undefined;
|
|
11540
|
+
const clearBlockedAudio = () => {
|
|
11541
|
+
if (!this.blockedAudioTracker.isBlocked(audioElement))
|
|
11542
|
+
return;
|
|
11543
|
+
this.blockedAudioTracker.markBlocked(audioElement, false);
|
|
11544
|
+
};
|
|
11545
|
+
audioElement.addEventListener('playing', clearBlockedAudio);
|
|
11486
11546
|
const isAudioTrack = trackType === 'audioTrack';
|
|
11487
11547
|
const trackKey = isAudioTrack ? 'audioStream' : 'screenShareAudioStream';
|
|
11488
11548
|
const updateMediaStreamSubscription = participant$
|
|
@@ -11496,7 +11556,7 @@ class DynascaleManager {
|
|
|
11496
11556
|
audioWatchdog?.dispose();
|
|
11497
11557
|
audioWatchdog = undefined;
|
|
11498
11558
|
if (!source) {
|
|
11499
|
-
|
|
11559
|
+
clearBlockedAudio();
|
|
11500
11560
|
return;
|
|
11501
11561
|
}
|
|
11502
11562
|
// Safari has a special quirk that prevents playing audio until the user
|
|
@@ -11524,7 +11584,7 @@ class DynascaleManager {
|
|
|
11524
11584
|
this.tracer.trace('audioPlaybackError', e.message);
|
|
11525
11585
|
if (e.name === 'NotAllowedError') {
|
|
11526
11586
|
this.tracer.trace('audioPlaybackBlocked', null);
|
|
11527
|
-
this.blockedAudioTracker.markBlocked(audioElement, true);
|
|
11587
|
+
this.blockedAudioTracker.markBlocked(audioElement, true, sessionId);
|
|
11528
11588
|
}
|
|
11529
11589
|
this.logger.warn(`Failed to play audio stream`, e);
|
|
11530
11590
|
});
|
|
@@ -11557,7 +11617,8 @@ class DynascaleManager {
|
|
|
11557
11617
|
});
|
|
11558
11618
|
audioElement.autoplay = true;
|
|
11559
11619
|
return () => {
|
|
11560
|
-
|
|
11620
|
+
audioElement.removeEventListener('playing', clearBlockedAudio);
|
|
11621
|
+
clearBlockedAudio();
|
|
11561
11622
|
sinkIdSubscription?.unsubscribe();
|
|
11562
11623
|
volumeSubscription.unsubscribe();
|
|
11563
11624
|
updateMediaStreamSubscription.unsubscribe();
|
|
@@ -14732,6 +14793,7 @@ class Call {
|
|
|
14732
14793
|
this.screenShare = new ScreenShareManager(this);
|
|
14733
14794
|
this.trackSubscriptionManager = new TrackSubscriptionManager(this.state, this.tracer);
|
|
14734
14795
|
this.blockedAudioTracker = new BlockedAudioTracker(this.tracer);
|
|
14796
|
+
this.leaveCallHooks.add(this.blockedAudioTracker.reset);
|
|
14735
14797
|
if (typeof document !== 'undefined') {
|
|
14736
14798
|
this.audioBindingsWatchdog = new AudioBindingsWatchdog(this.state, this.tracer);
|
|
14737
14799
|
this.viewportTracker = new ViewportTracker(this.state);
|
|
@@ -18430,11 +18492,11 @@ class StreamClient {
|
|
|
18430
18492
|
return await this.wsConnection.connect(this.defaultWSTimeout);
|
|
18431
18493
|
};
|
|
18432
18494
|
getSdkVersion = () => this.options.clientAppIdentifier?.sdkVersion ||
|
|
18433
|
-
"1.
|
|
18495
|
+
"1.56.0";
|
|
18434
18496
|
getUserAgent = () => {
|
|
18435
18497
|
if (!this.cachedUserAgent) {
|
|
18436
18498
|
const { clientAppIdentifier = {} } = this.options;
|
|
18437
|
-
const { sdkName = 'js', sdkVersion = "1.
|
|
18499
|
+
const { sdkName = 'js', sdkVersion = "1.56.0", ...extras } = clientAppIdentifier;
|
|
18438
18500
|
this.cachedUserAgent = [
|
|
18439
18501
|
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
18440
18502
|
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|
|
@@ -18771,8 +18833,8 @@ class ClientEventReporter {
|
|
|
18771
18833
|
applyErrorIfAbsent(this.wsPairs.get(cid), stageError);
|
|
18772
18834
|
this.failCoordinator(cid);
|
|
18773
18835
|
this.failWs(cid);
|
|
18774
|
-
this.emitPeerConnectionFailure(cid, 'publish', code, reason
|
|
18775
|
-
this.emitPeerConnectionFailure(cid, 'subscribe', code, reason
|
|
18836
|
+
this.emitPeerConnectionFailure(cid, 'publish', code, reason);
|
|
18837
|
+
this.emitPeerConnectionFailure(cid, 'subscribe', code, reason);
|
|
18776
18838
|
}
|
|
18777
18839
|
catch (err) {
|
|
18778
18840
|
this.logger.warn('Failed to report abort', err);
|
|
@@ -18784,7 +18846,7 @@ class ClientEventReporter {
|
|
|
18784
18846
|
if (this.wsPairs.get(cid))
|
|
18785
18847
|
this.failWs(cid);
|
|
18786
18848
|
for (const role of ['publish', 'subscribe']) {
|
|
18787
|
-
this.emitPeerConnectionFailure(cid, role, 'CLIENT_ABORTED', 'superseded by a new join attempt'
|
|
18849
|
+
this.emitPeerConnectionFailure(cid, role, 'CLIENT_ABORTED', 'superseded by a new join attempt');
|
|
18788
18850
|
}
|
|
18789
18851
|
};
|
|
18790
18852
|
emitJoinInitiated = (cid) => {
|
|
@@ -18946,21 +19008,24 @@ class ClientEventReporter {
|
|
|
18946
19008
|
};
|
|
18947
19009
|
onPeerConnectionStateChange = (cid, event) => {
|
|
18948
19010
|
const role = event.peerType === PeerType.SUBSCRIBER ? 'subscribe' : 'publish';
|
|
18949
|
-
|
|
18950
|
-
|
|
19011
|
+
const pair = this.peerConnectionPairs.get(pcKey(cid, role));
|
|
19012
|
+
if (pair)
|
|
19013
|
+
pair.lastIceState = event.iceConnectionState;
|
|
19014
|
+
if (event.stateType === 'ice') {
|
|
19015
|
+
if (event.state === 'failed') {
|
|
19016
|
+
this.emitPeerConnectionFailure(cid, role, 'ICE_CONNECTIVITY_FAILED', 'ICE connectivity checks failed');
|
|
19017
|
+
}
|
|
18951
19018
|
return;
|
|
18952
19019
|
}
|
|
18953
|
-
if (event.
|
|
18954
|
-
this.emitPeerConnectionFailure(cid, role, 'DTLS_CONNECTIVITY_FAILED', 'DTLS connectivity checks failed'
|
|
19020
|
+
if (event.state === 'failed') {
|
|
19021
|
+
this.emitPeerConnectionFailure(cid, role, 'DTLS_CONNECTIVITY_FAILED', 'DTLS connectivity checks failed');
|
|
18955
19022
|
return;
|
|
18956
19023
|
}
|
|
18957
|
-
if (event.stateType !== 'peerConnection')
|
|
18958
|
-
return;
|
|
18959
19024
|
switch (event.state) {
|
|
18960
19025
|
case 'connecting':
|
|
18961
|
-
if (
|
|
19026
|
+
if (pair)
|
|
18962
19027
|
return;
|
|
18963
|
-
this.openPeerConnectionPair(cid, role);
|
|
19028
|
+
this.openPeerConnectionPair(cid, role, event.iceConnectionState);
|
|
18964
19029
|
break;
|
|
18965
19030
|
case 'connected':
|
|
18966
19031
|
this.emitPeerConnectionSuccess(cid, role);
|
|
@@ -18968,7 +19033,7 @@ class ClientEventReporter {
|
|
|
18968
19033
|
break;
|
|
18969
19034
|
}
|
|
18970
19035
|
};
|
|
18971
|
-
openPeerConnectionPair = (cid, role) => {
|
|
19036
|
+
openPeerConnectionPair = (cid, role, iceConnectionState) => {
|
|
18972
19037
|
const key = pcKey(cid, role);
|
|
18973
19038
|
const pair = {
|
|
18974
19039
|
sid: generateUUIDv4(),
|
|
@@ -18978,6 +19043,7 @@ class ClientEventReporter {
|
|
|
18978
19043
|
sfuId: this.getSfuId(cid),
|
|
18979
19044
|
userSessionId: this.getUserSessionId(cid),
|
|
18980
19045
|
wasPreviouslyConnected: this.pcEverConnected.get(key) === true,
|
|
19046
|
+
lastIceState: iceConnectionState,
|
|
18981
19047
|
};
|
|
18982
19048
|
this.peerConnectionPairs.set(key, pair);
|
|
18983
19049
|
this.sendForCall(cid, {
|
|
@@ -19013,7 +19079,7 @@ class ClientEventReporter {
|
|
|
19013
19079
|
});
|
|
19014
19080
|
this.peerConnectionPairs.delete(key);
|
|
19015
19081
|
};
|
|
19016
|
-
emitPeerConnectionFailure = (cid, role, code, reason
|
|
19082
|
+
emitPeerConnectionFailure = (cid, role, code, reason) => {
|
|
19017
19083
|
const key = pcKey(cid, role);
|
|
19018
19084
|
const pair = this.peerConnectionPairs.get(key);
|
|
19019
19085
|
if (!pair)
|
|
@@ -19031,7 +19097,7 @@ class ClientEventReporter {
|
|
|
19031
19097
|
outcome: 'failure',
|
|
19032
19098
|
retry_count_attempt: 0,
|
|
19033
19099
|
elapsed_time: Date.now() - pair.startedAt,
|
|
19034
|
-
ice_state:
|
|
19100
|
+
ice_state: toReportedIceState(pair.lastIceState),
|
|
19035
19101
|
retry_failure_reason: reason,
|
|
19036
19102
|
retry_failure_code: code,
|
|
19037
19103
|
});
|
|
@@ -19097,6 +19163,17 @@ class ClientEventReporter {
|
|
|
19097
19163
|
return false;
|
|
19098
19164
|
};
|
|
19099
19165
|
}
|
|
19166
|
+
const toReportedIceState = (state) => {
|
|
19167
|
+
switch (state) {
|
|
19168
|
+
case 'connected':
|
|
19169
|
+
case 'completed':
|
|
19170
|
+
return 'CONNECTED';
|
|
19171
|
+
case 'failed':
|
|
19172
|
+
return 'FAILED';
|
|
19173
|
+
default:
|
|
19174
|
+
return 'NOT_CONNECTED';
|
|
19175
|
+
}
|
|
19176
|
+
};
|
|
19100
19177
|
const readPermissionStatus = (permission) => {
|
|
19101
19178
|
const state = getCurrentValue(permission.asStateObservable());
|
|
19102
19179
|
switch (state) {
|