@stream-io/video-client 1.40.3 → 1.41.1
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 +18 -0
- package/dist/index.browser.es.js +245 -38
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +252 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +245 -38
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +4 -4
- package/dist/src/devices/SpeakerManager.d.ts +3 -2
- package/dist/src/gen/coordinator/index.d.ts +269 -0
- package/dist/src/helpers/DynascaleManager.d.ts +13 -1
- package/dist/src/helpers/types.d.ts +16 -0
- package/dist/src/rtc/helpers/sdp.d.ts +8 -0
- package/dist/src/store/CallState.d.ts +21 -2
- package/dist/src/types.d.ts +29 -1
- package/package.json +2 -2
- package/src/Call.ts +29 -6
- package/src/devices/SpeakerManager.ts +40 -2
- package/src/devices/__tests__/MicrophoneManager.test.ts +34 -23
- package/src/devices/__tests__/mocks.ts +14 -12
- package/src/events/__tests__/call.test.ts +4 -5
- package/src/gen/coordinator/index.ts +293 -0
- package/src/helpers/DynascaleManager.ts +57 -9
- package/src/helpers/__tests__/DynascaleManager.test.ts +8 -1
- package/src/helpers/types.ts +26 -0
- package/src/rtc/Publisher.ts +1 -1
- package/src/rtc/__tests__/mocks/webrtc.mocks.ts +1 -0
- package/src/rtc/helpers/__tests__/sdp.startBitrate.test.ts +105 -0
- package/src/rtc/helpers/sdp.ts +30 -12
- package/src/store/CallState.ts +72 -9
- package/src/store/__tests__/CallState.test.ts +462 -106
- package/src/types.ts +42 -0
package/dist/index.cjs.js
CHANGED
|
@@ -46,6 +46,38 @@ const AudioSettingsResponseDefaultDeviceEnum = {
|
|
|
46
46
|
SPEAKER: 'speaker',
|
|
47
47
|
EARPIECE: 'earpiece',
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* @export
|
|
51
|
+
*/
|
|
52
|
+
const CallRecordingFailedEventRecordingTypeEnum = {
|
|
53
|
+
COMPOSITE: 'composite',
|
|
54
|
+
INDIVIDUAL: 'individual',
|
|
55
|
+
RAW: 'raw',
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @export
|
|
59
|
+
*/
|
|
60
|
+
const CallRecordingReadyEventRecordingTypeEnum = {
|
|
61
|
+
COMPOSITE: 'composite',
|
|
62
|
+
INDIVIDUAL: 'individual',
|
|
63
|
+
RAW: 'raw',
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* @export
|
|
67
|
+
*/
|
|
68
|
+
const CallRecordingStartedEventRecordingTypeEnum = {
|
|
69
|
+
COMPOSITE: 'composite',
|
|
70
|
+
INDIVIDUAL: 'individual',
|
|
71
|
+
RAW: 'raw',
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* @export
|
|
75
|
+
*/
|
|
76
|
+
const CallRecordingStoppedEventRecordingTypeEnum = {
|
|
77
|
+
COMPOSITE: 'composite',
|
|
78
|
+
INDIVIDUAL: 'individual',
|
|
79
|
+
RAW: 'raw',
|
|
80
|
+
};
|
|
49
81
|
/**
|
|
50
82
|
* @export
|
|
51
83
|
*/
|
|
@@ -81,6 +113,22 @@ const FrameRecordingSettingsResponseModeEnum = {
|
|
|
81
113
|
DISABLED: 'disabled',
|
|
82
114
|
AUTO_ON: 'auto-on',
|
|
83
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* @export
|
|
118
|
+
*/
|
|
119
|
+
const IndividualRecordingSettingsRequestModeEnum = {
|
|
120
|
+
AVAILABLE: 'available',
|
|
121
|
+
DISABLED: 'disabled',
|
|
122
|
+
AUTO_ON: 'auto-on',
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* @export
|
|
126
|
+
*/
|
|
127
|
+
const IndividualRecordingSettingsResponseModeEnum = {
|
|
128
|
+
AVAILABLE: 'available',
|
|
129
|
+
DISABLED: 'disabled',
|
|
130
|
+
AUTO_ON: 'auto-on',
|
|
131
|
+
};
|
|
84
132
|
/**
|
|
85
133
|
* @export
|
|
86
134
|
*/
|
|
@@ -146,11 +194,15 @@ const OwnCapability = {
|
|
|
146
194
|
START_BROADCAST_CALL: 'start-broadcast-call',
|
|
147
195
|
START_CLOSED_CAPTIONS_CALL: 'start-closed-captions-call',
|
|
148
196
|
START_FRAME_RECORD_CALL: 'start-frame-record-call',
|
|
197
|
+
START_INDIVIDUAL_RECORD_CALL: 'start-individual-record-call',
|
|
198
|
+
START_RAW_RECORD_CALL: 'start-raw-record-call',
|
|
149
199
|
START_RECORD_CALL: 'start-record-call',
|
|
150
200
|
START_TRANSCRIPTION_CALL: 'start-transcription-call',
|
|
151
201
|
STOP_BROADCAST_CALL: 'stop-broadcast-call',
|
|
152
202
|
STOP_CLOSED_CAPTIONS_CALL: 'stop-closed-captions-call',
|
|
153
203
|
STOP_FRAME_RECORD_CALL: 'stop-frame-record-call',
|
|
204
|
+
STOP_INDIVIDUAL_RECORD_CALL: 'stop-individual-record-call',
|
|
205
|
+
STOP_RAW_RECORD_CALL: 'stop-raw-record-call',
|
|
154
206
|
STOP_RECORD_CALL: 'stop-record-call',
|
|
155
207
|
STOP_TRANSCRIPTION_CALL: 'stop-transcription-call',
|
|
156
208
|
UPDATE_CALL: 'update-call',
|
|
@@ -188,6 +240,22 @@ const RTMPSettingsRequestQualityEnum = {
|
|
|
188
240
|
PORTRAIT_1080X1920: 'portrait-1080x1920',
|
|
189
241
|
PORTRAIT_1440X2560: 'portrait-1440x2560',
|
|
190
242
|
};
|
|
243
|
+
/**
|
|
244
|
+
* @export
|
|
245
|
+
*/
|
|
246
|
+
const RawRecordingSettingsRequestModeEnum = {
|
|
247
|
+
AVAILABLE: 'available',
|
|
248
|
+
DISABLED: 'disabled',
|
|
249
|
+
AUTO_ON: 'auto-on',
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* @export
|
|
253
|
+
*/
|
|
254
|
+
const RawRecordingSettingsResponseModeEnum = {
|
|
255
|
+
AVAILABLE: 'available',
|
|
256
|
+
DISABLED: 'disabled',
|
|
257
|
+
AUTO_ON: 'auto-on',
|
|
258
|
+
};
|
|
191
259
|
/**
|
|
192
260
|
* @export
|
|
193
261
|
*/
|
|
@@ -4003,15 +4071,18 @@ const extractMid = (transceiver, transceiverInitIndex, sdp) => {
|
|
|
4003
4071
|
return '';
|
|
4004
4072
|
return String(transceiverInitIndex);
|
|
4005
4073
|
};
|
|
4006
|
-
|
|
4007
|
-
* Sets the start bitrate for the VP9 and
|
|
4074
|
+
/**
|
|
4075
|
+
* Sets the start bitrate for the VP9, H264, and AV1 codecs in the SDP.
|
|
4008
4076
|
*
|
|
4009
4077
|
* @param offerSdp the offer SDP to modify.
|
|
4010
|
-
* @param
|
|
4078
|
+
* @param maxBitrateKbps the maximum bitrate in kbps.
|
|
4079
|
+
* @param startBitrateFactor the factor (0-1) to multiply with maxBitrateKbps to get the start bitrate.
|
|
4080
|
+
* @param targetMid the media ID to target.
|
|
4011
4081
|
*/
|
|
4012
4082
|
const setStartBitrate = (offerSdp, maxBitrateKbps, startBitrateFactor, targetMid) => {
|
|
4013
4083
|
// start bitrate should be between 300kbps and max-bitrate-kbps
|
|
4014
|
-
|
|
4084
|
+
// Clamp to max first, then ensure minimum of 300 (but never exceed max)
|
|
4085
|
+
const startBitrate = Math.min(maxBitrateKbps, Math.max(300, startBitrateFactor * maxBitrateKbps));
|
|
4015
4086
|
const parsedSdp = sdpTransform.parse(offerSdp);
|
|
4016
4087
|
const targetCodecs = new Set(['av1', 'vp9', 'h264']);
|
|
4017
4088
|
for (const media of parsedSdp.media) {
|
|
@@ -4022,14 +4093,27 @@ const setStartBitrate = (offerSdp, maxBitrateKbps, startBitrateFactor, targetMid
|
|
|
4022
4093
|
for (const rtp of media.rtp) {
|
|
4023
4094
|
if (!targetCodecs.has(rtp.codec.toLowerCase()))
|
|
4024
4095
|
continue;
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4096
|
+
// Find existing fmtp entry for this payload
|
|
4097
|
+
// Guard against media.fmtp being undefined when SDP has no a=fmtp lines
|
|
4098
|
+
const fmtpList = media.fmtp ?? (media.fmtp = []);
|
|
4099
|
+
const existingFmtp = fmtpList.find((fmtp) => fmtp.payload === rtp.payload);
|
|
4100
|
+
if (existingFmtp) {
|
|
4101
|
+
// Append to existing fmtp if not already present
|
|
4102
|
+
// Guard against undefined or empty config from malformed SDP
|
|
4103
|
+
const config = existingFmtp.config ?? '';
|
|
4104
|
+
if (!config.includes('x-google-start-bitrate')) {
|
|
4105
|
+
existingFmtp.config = config
|
|
4106
|
+
? `${config};x-google-start-bitrate=${startBitrate}`
|
|
4107
|
+
: `x-google-start-bitrate=${startBitrate}`;
|
|
4031
4108
|
}
|
|
4032
4109
|
}
|
|
4110
|
+
else {
|
|
4111
|
+
// Create new fmtp entry if none exists
|
|
4112
|
+
fmtpList.push({
|
|
4113
|
+
payload: rtp.payload,
|
|
4114
|
+
config: `x-google-start-bitrate=${startBitrate}`,
|
|
4115
|
+
});
|
|
4116
|
+
}
|
|
4033
4117
|
}
|
|
4034
4118
|
}
|
|
4035
4119
|
return sdpTransform.write(parsedSdp);
|
|
@@ -4959,6 +5043,10 @@ const paginatedLayoutSortPreset = combineComparators(pinned, ifInvisibleOrUnknow
|
|
|
4959
5043
|
*/
|
|
4960
5044
|
const livestreamOrAudioRoomSortPreset = combineComparators(ifInvisibleBy(combineComparators(dominantSpeaker, speaking, reactionType('raised-hand'), withVideoIngressSource, publishingVideo, publishingAudio)), role('admin', 'host', 'speaker'));
|
|
4961
5045
|
|
|
5046
|
+
const ensureExhausted = (x, message) => {
|
|
5047
|
+
videoLoggerSystem.getLogger('helpers').warn(message, x);
|
|
5048
|
+
};
|
|
5049
|
+
|
|
4962
5050
|
/**
|
|
4963
5051
|
* Returns the default egress object - when no egress data is available.
|
|
4964
5052
|
*/
|
|
@@ -4988,6 +5076,8 @@ class CallState {
|
|
|
4988
5076
|
this.egressSubject = new rxjs.BehaviorSubject(undefined);
|
|
4989
5077
|
this.ingressSubject = new rxjs.BehaviorSubject(undefined);
|
|
4990
5078
|
this.recordingSubject = new rxjs.BehaviorSubject(false);
|
|
5079
|
+
this.individualRecordingSubject = new rxjs.BehaviorSubject(false);
|
|
5080
|
+
this.rawRecordingSubject = new rxjs.BehaviorSubject(false);
|
|
4991
5081
|
this.sessionSubject = new rxjs.BehaviorSubject(undefined);
|
|
4992
5082
|
this.settingsSubject = new rxjs.BehaviorSubject(undefined);
|
|
4993
5083
|
this.transcribingSubject = new rxjs.BehaviorSubject(false);
|
|
@@ -5414,7 +5504,10 @@ class CallState {
|
|
|
5414
5504
|
this.setCurrentValue(this.customSubject, call.custom);
|
|
5415
5505
|
this.setCurrentValue(this.egressSubject, call.egress);
|
|
5416
5506
|
this.setCurrentValue(this.ingressSubject, call.ingress);
|
|
5417
|
-
|
|
5507
|
+
const { individual_recording, composite_recording, raw_recording } = call.egress;
|
|
5508
|
+
this.setCurrentValue(this.recordingSubject, call.recording || composite_recording?.status === 'running');
|
|
5509
|
+
this.setCurrentValue(this.individualRecordingSubject, individual_recording?.status === 'running');
|
|
5510
|
+
this.setCurrentValue(this.rawRecordingSubject, raw_recording?.status === 'running');
|
|
5418
5511
|
const s = this.setCurrentValue(this.sessionSubject, call.session);
|
|
5419
5512
|
this.updateParticipantCountFromSession(s);
|
|
5420
5513
|
this.setCurrentValue(this.settingsSubject, call.settings);
|
|
@@ -5490,6 +5583,21 @@ class CallState {
|
|
|
5490
5583
|
},
|
|
5491
5584
|
}));
|
|
5492
5585
|
};
|
|
5586
|
+
this.updateFromRecordingEvent = (type, running) => {
|
|
5587
|
+
// handle the legacy format, where `type` is absent in the emitted events
|
|
5588
|
+
if (type === undefined || type === 'composite') {
|
|
5589
|
+
this.setCurrentValue(this.recordingSubject, running);
|
|
5590
|
+
}
|
|
5591
|
+
else if (type === 'individual') {
|
|
5592
|
+
this.setCurrentValue(this.individualRecordingSubject, running);
|
|
5593
|
+
}
|
|
5594
|
+
else if (type === 'raw') {
|
|
5595
|
+
this.setCurrentValue(this.rawRecordingSubject, running);
|
|
5596
|
+
}
|
|
5597
|
+
else {
|
|
5598
|
+
ensureExhausted(type, 'Unknown recording type');
|
|
5599
|
+
}
|
|
5600
|
+
};
|
|
5493
5601
|
this.updateParticipantCountFromSession = (session) => {
|
|
5494
5602
|
// when in JOINED state, we should use the participant count coming through
|
|
5495
5603
|
// the SFU healthcheck event, as it's more accurate.
|
|
@@ -5724,6 +5832,8 @@ class CallState {
|
|
|
5724
5832
|
}), rxjs.distinctUntilChanged(isShallowEqual), rxjs.shareReplay({ bufferSize: 1, refCount: true }));
|
|
5725
5833
|
this.participantCount$ = duc(this.participantCountSubject);
|
|
5726
5834
|
this.recording$ = duc(this.recordingSubject);
|
|
5835
|
+
this.individualRecording$ = duc(this.individualRecordingSubject);
|
|
5836
|
+
this.rawRecording$ = duc(this.rawRecordingSubject);
|
|
5727
5837
|
this.transcribing$ = duc(this.transcribingSubject);
|
|
5728
5838
|
this.captioning$ = duc(this.captioningSubject);
|
|
5729
5839
|
this.eventHandlers = {
|
|
@@ -5790,9 +5900,15 @@ class CallState {
|
|
|
5790
5900
|
},
|
|
5791
5901
|
'call.permissions_updated': this.updateOwnCapabilities,
|
|
5792
5902
|
'call.reaction_new': this.updateParticipantReaction,
|
|
5793
|
-
'call.recording_started': () =>
|
|
5794
|
-
|
|
5795
|
-
|
|
5903
|
+
'call.recording_started': (e) => {
|
|
5904
|
+
this.updateFromRecordingEvent(e.recording_type, true);
|
|
5905
|
+
},
|
|
5906
|
+
'call.recording_stopped': (e) => {
|
|
5907
|
+
this.updateFromRecordingEvent(e.recording_type, false);
|
|
5908
|
+
},
|
|
5909
|
+
'call.recording_failed': (e) => {
|
|
5910
|
+
this.updateFromRecordingEvent(e.recording_type, false);
|
|
5911
|
+
},
|
|
5796
5912
|
'call.rejected': (e) => this.updateFromCallResponse(e.call),
|
|
5797
5913
|
'call.ring': (e) => this.updateFromCallResponse(e.call),
|
|
5798
5914
|
'call.missed': (e) => this.updateFromCallResponse(e.call),
|
|
@@ -5975,11 +6091,23 @@ class CallState {
|
|
|
5975
6091
|
return this.getCurrentValue(this.ingress$);
|
|
5976
6092
|
}
|
|
5977
6093
|
/**
|
|
5978
|
-
* Will provide the recording state of this call.
|
|
6094
|
+
* Will provide the composite recording state of this call.
|
|
5979
6095
|
*/
|
|
5980
6096
|
get recording() {
|
|
5981
6097
|
return this.getCurrentValue(this.recording$);
|
|
5982
6098
|
}
|
|
6099
|
+
/**
|
|
6100
|
+
* Will provide the individual recording state of this call.
|
|
6101
|
+
*/
|
|
6102
|
+
get individualRecording() {
|
|
6103
|
+
return this.getCurrentValue(this.individualRecording$);
|
|
6104
|
+
}
|
|
6105
|
+
/**
|
|
6106
|
+
* Will provide the raw recording state of this call.
|
|
6107
|
+
*/
|
|
6108
|
+
get rawRecording() {
|
|
6109
|
+
return this.getCurrentValue(this.rawRecording$);
|
|
6110
|
+
}
|
|
5983
6111
|
/**
|
|
5984
6112
|
* Will provide the session data of this call.
|
|
5985
6113
|
*/
|
|
@@ -6080,7 +6208,7 @@ const getSdkVersion = (sdk) => {
|
|
|
6080
6208
|
return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
|
|
6081
6209
|
};
|
|
6082
6210
|
|
|
6083
|
-
const version = "1.
|
|
6211
|
+
const version = "1.41.1";
|
|
6084
6212
|
const [major, minor, patch] = version.split('.');
|
|
6085
6213
|
let sdkInfo = {
|
|
6086
6214
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -7428,10 +7556,6 @@ class TransceiverCache {
|
|
|
7428
7556
|
}
|
|
7429
7557
|
}
|
|
7430
7558
|
|
|
7431
|
-
const ensureExhausted = (x, message) => {
|
|
7432
|
-
videoLoggerSystem.getLogger('helpers').warn(message, x);
|
|
7433
|
-
};
|
|
7434
|
-
|
|
7435
7559
|
const trackTypeToParticipantStreamKey = (trackType) => {
|
|
7436
7560
|
switch (trackType) {
|
|
7437
7561
|
case TrackType.SCREEN_SHARE:
|
|
@@ -7912,7 +8036,7 @@ class Publisher extends BasePeerConnection {
|
|
|
7912
8036
|
let sdp = dangerouslyForceCodec
|
|
7913
8037
|
? removeCodecsExcept(baseSdp, dangerouslyForceCodec, fmtpLine)
|
|
7914
8038
|
: baseSdp;
|
|
7915
|
-
if (dangerouslySetStartBitrateFactor) {
|
|
8039
|
+
if (dangerouslySetStartBitrateFactor !== undefined) {
|
|
7916
8040
|
this.transceiverCache.items().forEach((t) => {
|
|
7917
8041
|
if (t.publishOption.trackType !== TrackType.VIDEO)
|
|
7918
8042
|
return;
|
|
@@ -9268,12 +9392,13 @@ class DynascaleManager {
|
|
|
9268
9392
|
/**
|
|
9269
9393
|
* Creates a new DynascaleManager instance.
|
|
9270
9394
|
*/
|
|
9271
|
-
constructor(callState, speaker) {
|
|
9395
|
+
constructor(callState, speaker, tracer) {
|
|
9272
9396
|
/**
|
|
9273
9397
|
* The viewport tracker instance.
|
|
9274
9398
|
*/
|
|
9275
9399
|
this.viewportTracker = new ViewportTracker();
|
|
9276
9400
|
this.logger = videoLoggerSystem.getLogger('DynascaleManager');
|
|
9401
|
+
this.useWebAudio = isSafari();
|
|
9277
9402
|
this.pendingSubscriptionsUpdate = null;
|
|
9278
9403
|
this.videoTrackSubscriptionOverridesSubject = new rxjs.BehaviorSubject({});
|
|
9279
9404
|
this.videoTrackSubscriptionOverrides$ = this.videoTrackSubscriptionOverridesSubject.asObservable();
|
|
@@ -9313,6 +9438,10 @@ class DynascaleManager {
|
|
|
9313
9438
|
}
|
|
9314
9439
|
};
|
|
9315
9440
|
this.setVideoTrackSubscriptionOverrides = (override, sessionIds) => {
|
|
9441
|
+
this.tracer.trace('setVideoTrackSubscriptionOverrides', [
|
|
9442
|
+
override,
|
|
9443
|
+
sessionIds,
|
|
9444
|
+
]);
|
|
9316
9445
|
if (!sessionIds) {
|
|
9317
9446
|
return setCurrentValue(this.videoTrackSubscriptionOverridesSubject, override ? { [globalOverrideKey]: override } : {});
|
|
9318
9447
|
}
|
|
@@ -9394,6 +9523,18 @@ class DynascaleManager {
|
|
|
9394
9523
|
this.setViewport = (element) => {
|
|
9395
9524
|
return this.viewportTracker.setViewport(element);
|
|
9396
9525
|
};
|
|
9526
|
+
/**
|
|
9527
|
+
* Sets whether to use WebAudio API for audio playback.
|
|
9528
|
+
* Must be set before joining the call.
|
|
9529
|
+
*
|
|
9530
|
+
* @internal
|
|
9531
|
+
*
|
|
9532
|
+
* @param useWebAudio whether to use WebAudio API.
|
|
9533
|
+
*/
|
|
9534
|
+
this.setUseWebAudio = (useWebAudio) => {
|
|
9535
|
+
this.tracer.trace('setUseWebAudio', useWebAudio);
|
|
9536
|
+
this.useWebAudio = useWebAudio;
|
|
9537
|
+
};
|
|
9397
9538
|
/**
|
|
9398
9539
|
* Binds a DOM <video> element to the given session id.
|
|
9399
9540
|
* This method will make sure that the video element will play
|
|
@@ -9609,6 +9750,7 @@ class DynascaleManager {
|
|
|
9609
9750
|
// we will play audio directly through the audio element in other browsers
|
|
9610
9751
|
audioElement.muted = false;
|
|
9611
9752
|
audioElement.play().catch((e) => {
|
|
9753
|
+
this.tracer.trace('audioPlaybackError', e.message);
|
|
9612
9754
|
this.logger.warn(`Failed to play audio stream`, e);
|
|
9613
9755
|
});
|
|
9614
9756
|
}
|
|
@@ -9643,32 +9785,57 @@ class DynascaleManager {
|
|
|
9643
9785
|
};
|
|
9644
9786
|
};
|
|
9645
9787
|
this.getOrCreateAudioContext = () => {
|
|
9646
|
-
if (this.
|
|
9788
|
+
if (!this.useWebAudio)
|
|
9789
|
+
return;
|
|
9790
|
+
if (this.audioContext)
|
|
9647
9791
|
return this.audioContext;
|
|
9648
9792
|
const context = new AudioContext();
|
|
9793
|
+
this.tracer.trace('audioContext.create', context.state);
|
|
9649
9794
|
if (context.state === 'suspended') {
|
|
9650
9795
|
document.addEventListener('click', this.resumeAudioContext);
|
|
9651
9796
|
}
|
|
9652
|
-
|
|
9797
|
+
context.addEventListener('statechange', () => {
|
|
9798
|
+
this.tracer.trace('audioContext.state', context.state);
|
|
9799
|
+
if (context.state === 'interrupted') {
|
|
9800
|
+
this.resumeAudioContext();
|
|
9801
|
+
}
|
|
9802
|
+
});
|
|
9653
9803
|
const audioSession = navigator.audioSession;
|
|
9654
9804
|
if (audioSession) {
|
|
9655
9805
|
// https://github.com/w3c/audio-session/blob/main/explainer.md
|
|
9656
9806
|
audioSession.type = 'play-and-record';
|
|
9807
|
+
let isSessionInterrupted = false;
|
|
9808
|
+
audioSession.addEventListener('statechange', () => {
|
|
9809
|
+
this.tracer.trace('audioSession.state', audioSession.state);
|
|
9810
|
+
if (audioSession.state === 'interrupted') {
|
|
9811
|
+
isSessionInterrupted = true;
|
|
9812
|
+
}
|
|
9813
|
+
else if (isSessionInterrupted) {
|
|
9814
|
+
this.resumeAudioContext();
|
|
9815
|
+
isSessionInterrupted = false;
|
|
9816
|
+
}
|
|
9817
|
+
});
|
|
9657
9818
|
}
|
|
9658
9819
|
return (this.audioContext = context);
|
|
9659
9820
|
};
|
|
9660
9821
|
this.resumeAudioContext = () => {
|
|
9661
|
-
if (this.audioContext
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9822
|
+
if (!this.audioContext)
|
|
9823
|
+
return;
|
|
9824
|
+
const { state } = this.audioContext;
|
|
9825
|
+
if (state === 'suspended' || state === 'interrupted') {
|
|
9826
|
+
const tag = 'audioContext.resume';
|
|
9827
|
+
this.audioContext.resume().then(() => {
|
|
9828
|
+
this.tracer.trace(tag, this.audioContext?.state);
|
|
9666
9829
|
document.removeEventListener('click', this.resumeAudioContext);
|
|
9830
|
+
}, (err) => {
|
|
9831
|
+
this.tracer.trace(`${tag}Error`, this.audioContext?.state);
|
|
9832
|
+
this.logger.warn(`Can't resume audio context`, err);
|
|
9667
9833
|
});
|
|
9668
9834
|
}
|
|
9669
9835
|
};
|
|
9670
9836
|
this.callState = callState;
|
|
9671
9837
|
this.speaker = speaker;
|
|
9838
|
+
this.tracer = tracer;
|
|
9672
9839
|
}
|
|
9673
9840
|
setSfuClient(sfuClient) {
|
|
9674
9841
|
this.sfuClient = sfuClient;
|
|
@@ -11888,6 +12055,37 @@ class SpeakerManager {
|
|
|
11888
12055
|
this.state = new SpeakerState(call.tracer);
|
|
11889
12056
|
this.setup();
|
|
11890
12057
|
}
|
|
12058
|
+
apply(settings) {
|
|
12059
|
+
if (!isReactNative()) {
|
|
12060
|
+
return;
|
|
12061
|
+
}
|
|
12062
|
+
/// Determines if the speaker should be enabled based on a priority hierarchy of
|
|
12063
|
+
/// settings.
|
|
12064
|
+
///
|
|
12065
|
+
/// The priority order is as follows:
|
|
12066
|
+
/// 1. If video camera is set to be on by default, speaker is enabled
|
|
12067
|
+
/// 2. If audio speaker is set to be on by default, speaker is enabled
|
|
12068
|
+
/// 3. If the default audio device is set to speaker, speaker is enabled
|
|
12069
|
+
///
|
|
12070
|
+
/// This ensures that the speaker state aligns with the most important user
|
|
12071
|
+
/// preference or system requirement.
|
|
12072
|
+
const speakerOnWithSettingsPriority = settings.video.camera_default_on ||
|
|
12073
|
+
settings.audio.speaker_default_on ||
|
|
12074
|
+
settings.audio.default_device ===
|
|
12075
|
+
AudioSettingsRequestDefaultDeviceEnum.SPEAKER;
|
|
12076
|
+
const defaultDevice = speakerOnWithSettingsPriority
|
|
12077
|
+
? AudioSettingsRequestDefaultDeviceEnum.SPEAKER
|
|
12078
|
+
: AudioSettingsRequestDefaultDeviceEnum.EARPIECE;
|
|
12079
|
+
if (this.defaultDevice !== defaultDevice) {
|
|
12080
|
+
this.call.logger.debug('SpeakerManager: setting default device', {
|
|
12081
|
+
defaultDevice,
|
|
12082
|
+
});
|
|
12083
|
+
this.defaultDevice = defaultDevice;
|
|
12084
|
+
globalThis.streamRNVideoSDK?.callManager.setup({
|
|
12085
|
+
defaultDevice,
|
|
12086
|
+
});
|
|
12087
|
+
}
|
|
12088
|
+
}
|
|
11891
12089
|
setup() {
|
|
11892
12090
|
if (this.areSubscriptionsSetUp) {
|
|
11893
12091
|
return;
|
|
@@ -11950,8 +12148,6 @@ class SpeakerManager {
|
|
|
11950
12148
|
/**
|
|
11951
12149
|
* Set the volume of a participant.
|
|
11952
12150
|
*
|
|
11953
|
-
* Note: This method is not supported in React Native.
|
|
11954
|
-
*
|
|
11955
12151
|
* @param sessionId the participant's session id.
|
|
11956
12152
|
* @param volume a number between 0 and 1. Set it to `undefined` to use the default volume.
|
|
11957
12153
|
*/
|
|
@@ -12294,6 +12490,7 @@ class Call {
|
|
|
12294
12490
|
this.ringingSubject.next(false);
|
|
12295
12491
|
this.cancelAutoDrop();
|
|
12296
12492
|
this.clientStore.unregisterCall(this);
|
|
12493
|
+
globalThis.streamRNVideoSDK?.callManager.stop();
|
|
12297
12494
|
this.camera.dispose();
|
|
12298
12495
|
this.microphone.dispose();
|
|
12299
12496
|
this.screenShare.dispose();
|
|
@@ -12626,6 +12823,7 @@ class Call {
|
|
|
12626
12823
|
// re-apply them on later reconnections or server-side data fetches
|
|
12627
12824
|
if (!this.deviceSettingsAppliedOnce && this.state.settings) {
|
|
12628
12825
|
await this.applyDeviceConfig(this.state.settings, true);
|
|
12826
|
+
globalThis.streamRNVideoSDK?.callManager.start();
|
|
12629
12827
|
this.deviceSettingsAppliedOnce = true;
|
|
12630
12828
|
}
|
|
12631
12829
|
// We shouldn't persist the `ring` and `notify` state after joining the call
|
|
@@ -13417,14 +13615,22 @@ class Call {
|
|
|
13417
13615
|
/**
|
|
13418
13616
|
* Starts recording the call
|
|
13419
13617
|
*/
|
|
13420
|
-
this.startRecording = async (
|
|
13421
|
-
|
|
13618
|
+
this.startRecording = async (dataOrType, type) => {
|
|
13619
|
+
type = typeof dataOrType === 'string' ? dataOrType : type;
|
|
13620
|
+
dataOrType = typeof dataOrType === 'string' ? undefined : dataOrType;
|
|
13621
|
+
const endpoint = !type
|
|
13622
|
+
? `/start_recording`
|
|
13623
|
+
: `/recordings/${encodeURIComponent(type)}/start`;
|
|
13624
|
+
return this.streamClient.post(`${this.streamClientBasePath}${endpoint}`, dataOrType);
|
|
13422
13625
|
};
|
|
13423
13626
|
/**
|
|
13424
13627
|
* Stops recording the call
|
|
13425
13628
|
*/
|
|
13426
|
-
this.stopRecording = async () => {
|
|
13427
|
-
|
|
13629
|
+
this.stopRecording = async (type) => {
|
|
13630
|
+
const endpoint = !type
|
|
13631
|
+
? `/stop_recording`
|
|
13632
|
+
: `/recordings/${encodeURIComponent(type)}/stop`;
|
|
13633
|
+
return this.streamClient.post(`${this.streamClientBasePath}${endpoint}`);
|
|
13428
13634
|
};
|
|
13429
13635
|
/**
|
|
13430
13636
|
* Starts the transcription of the call.
|
|
@@ -13821,6 +14027,7 @@ class Call {
|
|
|
13821
14027
|
* @internal
|
|
13822
14028
|
*/
|
|
13823
14029
|
this.applyDeviceConfig = async (settings, publish) => {
|
|
14030
|
+
this.speaker.apply(settings);
|
|
13824
14031
|
await this.camera.apply(settings.video, publish).catch((err) => {
|
|
13825
14032
|
this.logger.warn('Camera init failed', err);
|
|
13826
14033
|
});
|
|
@@ -13990,7 +14197,7 @@ class Call {
|
|
|
13990
14197
|
this.microphone = new MicrophoneManager(this);
|
|
13991
14198
|
this.speaker = new SpeakerManager(this);
|
|
13992
14199
|
this.screenShare = new ScreenShareManager(this);
|
|
13993
|
-
this.dynascaleManager = new DynascaleManager(this.state, this.speaker);
|
|
14200
|
+
this.dynascaleManager = new DynascaleManager(this.state, this.speaker, this.tracer);
|
|
13994
14201
|
}
|
|
13995
14202
|
/**
|
|
13996
14203
|
* A flag indicating whether the call is "ringing" type of call.
|
|
@@ -15132,7 +15339,7 @@ class StreamClient {
|
|
|
15132
15339
|
this.getUserAgent = () => {
|
|
15133
15340
|
if (!this.cachedUserAgent) {
|
|
15134
15341
|
const { clientAppIdentifier = {} } = this.options;
|
|
15135
|
-
const { sdkName = 'js', sdkVersion = "1.
|
|
15342
|
+
const { sdkName = 'js', sdkVersion = "1.41.1", ...extras } = clientAppIdentifier;
|
|
15136
15343
|
this.cachedUserAgent = [
|
|
15137
15344
|
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
15138
15345
|
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|
|
@@ -15780,6 +15987,10 @@ exports.AudioSettingsRequestDefaultDeviceEnum = AudioSettingsRequestDefaultDevic
|
|
|
15780
15987
|
exports.AudioSettingsResponseDefaultDeviceEnum = AudioSettingsResponseDefaultDeviceEnum;
|
|
15781
15988
|
exports.Browsers = browsers;
|
|
15782
15989
|
exports.Call = Call;
|
|
15990
|
+
exports.CallRecordingFailedEventRecordingTypeEnum = CallRecordingFailedEventRecordingTypeEnum;
|
|
15991
|
+
exports.CallRecordingReadyEventRecordingTypeEnum = CallRecordingReadyEventRecordingTypeEnum;
|
|
15992
|
+
exports.CallRecordingStartedEventRecordingTypeEnum = CallRecordingStartedEventRecordingTypeEnum;
|
|
15993
|
+
exports.CallRecordingStoppedEventRecordingTypeEnum = CallRecordingStoppedEventRecordingTypeEnum;
|
|
15783
15994
|
exports.CallState = CallState;
|
|
15784
15995
|
exports.CallType = CallType;
|
|
15785
15996
|
exports.CallTypes = CallTypes;
|
|
@@ -15793,6 +16004,8 @@ exports.ErrorFromResponse = ErrorFromResponse;
|
|
|
15793
16004
|
exports.FrameRecordingSettingsRequestModeEnum = FrameRecordingSettingsRequestModeEnum;
|
|
15794
16005
|
exports.FrameRecordingSettingsRequestQualityEnum = FrameRecordingSettingsRequestQualityEnum;
|
|
15795
16006
|
exports.FrameRecordingSettingsResponseModeEnum = FrameRecordingSettingsResponseModeEnum;
|
|
16007
|
+
exports.IndividualRecordingSettingsRequestModeEnum = IndividualRecordingSettingsRequestModeEnum;
|
|
16008
|
+
exports.IndividualRecordingSettingsResponseModeEnum = IndividualRecordingSettingsResponseModeEnum;
|
|
15796
16009
|
exports.IngressAudioEncodingOptionsRequestChannelsEnum = IngressAudioEncodingOptionsRequestChannelsEnum;
|
|
15797
16010
|
exports.IngressSourceRequestFpsEnum = IngressSourceRequestFpsEnum;
|
|
15798
16011
|
exports.IngressVideoLayerRequestCodecEnum = IngressVideoLayerRequestCodecEnum;
|
|
@@ -15804,6 +16017,8 @@ exports.OwnCapability = OwnCapability;
|
|
|
15804
16017
|
exports.RNSpeechDetector = RNSpeechDetector;
|
|
15805
16018
|
exports.RTMPBroadcastRequestQualityEnum = RTMPBroadcastRequestQualityEnum;
|
|
15806
16019
|
exports.RTMPSettingsRequestQualityEnum = RTMPSettingsRequestQualityEnum;
|
|
16020
|
+
exports.RawRecordingSettingsRequestModeEnum = RawRecordingSettingsRequestModeEnum;
|
|
16021
|
+
exports.RawRecordingSettingsResponseModeEnum = RawRecordingSettingsResponseModeEnum;
|
|
15807
16022
|
exports.RecordSettingsRequestModeEnum = RecordSettingsRequestModeEnum;
|
|
15808
16023
|
exports.RecordSettingsRequestQualityEnum = RecordSettingsRequestQualityEnum;
|
|
15809
16024
|
exports.RxUtils = rxUtils;
|