@stream-io/video-client 2.0.0-beta.0 → 2.0.0-beta.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 +1126 -791
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +1126 -791
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +1126 -791
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +37 -11
- package/dist/src/StreamVideoClient.d.ts +15 -21
- package/dist/src/coordinator/connection/types.d.ts +16 -0
- package/dist/src/events/call.d.ts +0 -11
- package/dist/src/gen/coordinator/index.d.ts +73 -0
- package/dist/src/reporting/ClientEventReporter.d.ts +11 -1
- package/dist/src/ringing/RingStatePoller.d.ts +46 -0
- package/dist/src/ringing/RingTimeout.d.ts +27 -0
- package/dist/src/ringing/index.d.ts +4 -0
- package/dist/src/ringing/reconcileRingState.d.ts +18 -0
- package/dist/src/ringing/resolveOwnRingOutcome.d.ts +32 -0
- package/dist/src/rtc/Publisher.d.ts +18 -0
- package/dist/src/rtc/TransceiverCache.d.ts +10 -0
- package/dist/src/rtc/e2ee/E2EEManager.d.ts +10 -1
- package/dist/src/stats/utils.d.ts +6 -0
- package/dist/src/store/CallState.d.ts +118 -267
- package/dist/src/store/ClientState.d.ts +62 -0
- package/dist/src/store/index.d.ts +1 -1
- package/dist/src/store/subjects.d.ts +15 -0
- package/dist/src/store/types.d.ts +22 -0
- package/dist/src/types.d.ts +33 -4
- package/index.ts +1 -0
- package/package.json +2 -2
- package/src/Call.ts +285 -125
- package/src/StreamSfuClient.ts +6 -2
- package/src/StreamVideoClient.ts +40 -47
- package/src/__tests__/Call.autodrop.test.ts +118 -66
- package/src/__tests__/Call.getRingState.test.ts +87 -0
- package/src/__tests__/Call.lifecycle.test.ts +499 -6
- package/src/__tests__/Call.publishing.test.ts +2 -2
- package/src/__tests__/Call.ringSettled.test.ts +71 -0
- package/src/__tests__/Call.ringingLifecycle.test.ts +242 -0
- package/src/__tests__/StreamSfuClient.test.ts +48 -0
- package/src/__tests__/StreamVideoClient.disconnect.test.ts +62 -0
- package/src/coordinator/connection/types.ts +19 -0
- package/src/devices/__tests__/CameraManager.test.ts +2 -2
- package/src/devices/__tests__/DeviceManager.test.ts +2 -2
- package/src/devices/__tests__/DeviceManagerFilters.test.ts +2 -2
- package/src/devices/__tests__/MicrophoneManager.test.ts +2 -2
- package/src/devices/__tests__/MicrophoneManagerRN.test.ts +2 -2
- package/src/devices/__tests__/ScreenShareManager.test.ts +3 -3
- package/src/devices/__tests__/SpeakerManager.test.ts +4 -4
- package/src/events/__tests__/call.test.ts +5 -220
- package/src/events/call.ts +1 -73
- package/src/events/callEventHandlers.ts +12 -23
- package/src/gen/coordinator/index.ts +67 -0
- package/src/helpers/__tests__/AudioBindingsWatchdog.test.ts +2 -2
- package/src/helpers/__tests__/DynascaleManager.test.ts +2 -2
- package/src/helpers/__tests__/ViewportTracker.test.ts +2 -2
- package/src/reporting/ClientEventReporter.ts +30 -4
- package/src/reporting/__tests__/ClientEventReporter.test.ts +184 -7
- package/src/ringing/RingStatePoller.ts +177 -0
- package/src/ringing/RingTimeout.ts +90 -0
- package/src/ringing/__tests__/RingStatePoller.test.ts +462 -0
- package/src/ringing/__tests__/RingTimeout.test.ts +199 -0
- package/src/ringing/__tests__/reconcileRingState.test.ts +330 -0
- package/src/ringing/__tests__/resolveOwnRingOutcome.test.ts +103 -0
- package/src/ringing/index.ts +4 -0
- package/src/ringing/reconcileRingState.ts +108 -0
- package/src/ringing/resolveOwnRingOutcome.ts +58 -0
- package/src/rtc/Publisher.ts +66 -12
- package/src/rtc/TransceiverCache.ts +17 -0
- package/src/rtc/__tests__/Call.reconnect.test.ts +5 -5
- package/src/rtc/__tests__/Publisher.test.ts +209 -0
- package/src/rtc/__tests__/mocks/webrtc.mocks.ts +1 -0
- package/src/rtc/e2ee/E2EEManager.ts +10 -1
- package/src/rtc/e2ee/EncryptionManager.ts +1 -1
- package/src/rtc/e2ee/SPEC.md +1 -1
- package/src/stats/__tests__/utils.test.ts +33 -0
- package/src/stats/utils.ts +15 -0
- package/src/store/CallState.ts +305 -550
- package/src/store/ClientState.ts +101 -0
- package/src/store/__tests__/CallState.test.ts +60 -1
- package/src/store/__tests__/ClientState.test.ts +35 -0
- package/src/store/__tests__/rxUtils.test.ts +67 -1
- package/src/store/index.ts +1 -1
- package/src/store/rxUtils.ts +8 -4
- package/src/store/subjects.ts +30 -0
- package/src/store/types.ts +45 -0
- package/src/types.ts +40 -4
- package/dist/src/store/stateStore.d.ts +0 -84
- package/src/store/stateStore.ts +0 -156
|
@@ -21,6 +21,23 @@ export class TransceiverCache {
|
|
|
21
21
|
this.transceiverOrder.push(bundle.transceiver);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Retires a failed sender from the reusable cache.
|
|
26
|
+
*
|
|
27
|
+
* A transceiver that never reached an m-section also leaves the creation
|
|
28
|
+
* history: once stopped, it is left out of every later offer, so counting
|
|
29
|
+
* it would shift the `mid` index of every transceiver added after it. One
|
|
30
|
+
* that is already associated keeps its slot, since its m-section survives
|
|
31
|
+
* as a rejected one.
|
|
32
|
+
*/
|
|
33
|
+
remove = (transceiver: RTCRtpTransceiver) => {
|
|
34
|
+
const index = this.cache.findIndex((b) => b.transceiver === transceiver);
|
|
35
|
+
if (index !== -1) this.cache.splice(index, 1);
|
|
36
|
+
if (transceiver.mid) return;
|
|
37
|
+
const orderIndex = this.transceiverOrder.indexOf(transceiver);
|
|
38
|
+
if (orderIndex !== -1) this.transceiverOrder.splice(orderIndex, 1);
|
|
39
|
+
};
|
|
40
|
+
|
|
24
41
|
/**
|
|
25
42
|
* Gets the transceiver for the given publish option.
|
|
26
43
|
*/
|
|
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
4
4
|
import { Call } from '../../Call';
|
|
5
5
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
6
6
|
import { ClientEventReporter } from '../../reporting';
|
|
7
|
-
import {
|
|
7
|
+
import { ClientState } from '../../store';
|
|
8
8
|
import { CallingState } from '../../store';
|
|
9
9
|
import { NegotiationError } from '../NegotiationError';
|
|
10
10
|
import { ReconnectReason } from '../types';
|
|
@@ -27,7 +27,7 @@ vi.mock('../../StreamSfuClient', () => ({
|
|
|
27
27
|
|
|
28
28
|
const makeCall = ({ reportingEnabled = false } = {}) => {
|
|
29
29
|
const streamClient = new StreamClient('test-key');
|
|
30
|
-
const
|
|
30
|
+
const clientState = new ClientState();
|
|
31
31
|
return new Call({
|
|
32
32
|
type: 'default',
|
|
33
33
|
id: 'test-call',
|
|
@@ -36,7 +36,7 @@ const makeCall = ({ reportingEnabled = false } = {}) => {
|
|
|
36
36
|
streamClient,
|
|
37
37
|
enabled: reportingEnabled,
|
|
38
38
|
}),
|
|
39
|
-
|
|
39
|
+
clientState,
|
|
40
40
|
ringing: false,
|
|
41
41
|
watching: false,
|
|
42
42
|
});
|
|
@@ -729,13 +729,13 @@ describe('Call reconnect wiring (PC event → leave)', () => {
|
|
|
729
729
|
sfuClient.iceTrickleBuffer = new IceTrickleBuffer();
|
|
730
730
|
|
|
731
731
|
const streamClient = new StreamClient('test-key');
|
|
732
|
-
const
|
|
732
|
+
const clientState = new ClientState();
|
|
733
733
|
call = new Call({
|
|
734
734
|
type: 'default',
|
|
735
735
|
id: 'test-call',
|
|
736
736
|
streamClient,
|
|
737
737
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
738
|
-
|
|
738
|
+
clientState,
|
|
739
739
|
ringing: false,
|
|
740
740
|
watching: false,
|
|
741
741
|
});
|
|
@@ -26,6 +26,7 @@ import { TransceiverCache } from '../TransceiverCache';
|
|
|
26
26
|
import { promiseWithResolvers } from '../../helpers/promise';
|
|
27
27
|
import { settled } from '../../helpers/concurrency';
|
|
28
28
|
import { isFirefox } from '../../helpers/browsers';
|
|
29
|
+
import { isReactNative } from '../../helpers/platforms';
|
|
29
30
|
|
|
30
31
|
vi.mock('../../StreamSfuClient', () => {
|
|
31
32
|
console.log('MOCKING StreamSfuClient');
|
|
@@ -40,6 +41,12 @@ vi.mock('../../helpers/browsers', async (importOriginal) => {
|
|
|
40
41
|
return { ...actual, isFirefox: vi.fn().mockReturnValue(false) };
|
|
41
42
|
});
|
|
42
43
|
|
|
44
|
+
vi.mock('../../helpers/platforms', async (importOriginal) => {
|
|
45
|
+
const actual =
|
|
46
|
+
await importOriginal<typeof import('../../helpers/platforms')>();
|
|
47
|
+
return { ...actual, isReactNative: vi.fn().mockReturnValue(false) };
|
|
48
|
+
});
|
|
49
|
+
|
|
43
50
|
describe('Publisher', () => {
|
|
44
51
|
const sessionId = 'session-id-test';
|
|
45
52
|
let publisher: Publisher;
|
|
@@ -106,6 +113,208 @@ describe('Publisher', () => {
|
|
|
106
113
|
});
|
|
107
114
|
|
|
108
115
|
describe('Publishing', () => {
|
|
116
|
+
describe('E2EE initialization failures', () => {
|
|
117
|
+
afterEach(() => {
|
|
118
|
+
vi.mocked(isReactNative).mockReturnValue(false);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const setup = async () => {
|
|
122
|
+
await publisher.dispose();
|
|
123
|
+
const e2ee = { encrypt: vi.fn(), decrypt: vi.fn() };
|
|
124
|
+
publisher = new Publisher(
|
|
125
|
+
{
|
|
126
|
+
sfuClient,
|
|
127
|
+
dispatcher,
|
|
128
|
+
state,
|
|
129
|
+
tag: 'test',
|
|
130
|
+
enableTracing: false,
|
|
131
|
+
e2ee,
|
|
132
|
+
},
|
|
133
|
+
[
|
|
134
|
+
fromPartial<PublishOption>({
|
|
135
|
+
id: 1,
|
|
136
|
+
trackType: TrackType.VIDEO,
|
|
137
|
+
codec: { name: 'vp9' },
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
);
|
|
141
|
+
const transceivers: RTCRtpTransceiver[] = [];
|
|
142
|
+
vi.mocked(publisher['pc'].addTransceiver).mockImplementation((kind) => {
|
|
143
|
+
expect(kind).toBe('video');
|
|
144
|
+
const transceiver = new RTCRtpTransceiver();
|
|
145
|
+
vi.mocked(transceiver.sender.replaceTrack).mockImplementation(
|
|
146
|
+
async (track) => {
|
|
147
|
+
expect(e2ee.encrypt).toHaveBeenCalledWith(
|
|
148
|
+
transceiver.sender,
|
|
149
|
+
'vp9',
|
|
150
|
+
'VIDEO',
|
|
151
|
+
);
|
|
152
|
+
Object.assign(transceiver.sender, { track });
|
|
153
|
+
},
|
|
154
|
+
);
|
|
155
|
+
transceivers.push(transceiver);
|
|
156
|
+
return transceiver;
|
|
157
|
+
});
|
|
158
|
+
const track = new MediaStreamTrack();
|
|
159
|
+
vi.mocked(track.clone).mockImplementation(() => new MediaStreamTrack());
|
|
160
|
+
const realNegotiate = publisher['negotiate'];
|
|
161
|
+
const negotiate = vi.fn<Publisher['negotiate']>().mockResolvedValue();
|
|
162
|
+
publisher['negotiate'] = negotiate;
|
|
163
|
+
return { e2ee, transceivers, track, negotiate, realNegotiate };
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
it.each([
|
|
167
|
+
'encrypt',
|
|
168
|
+
'getParameters',
|
|
169
|
+
'setParameters',
|
|
170
|
+
'replaceTrack',
|
|
171
|
+
] as const)(
|
|
172
|
+
'retires the sender after %s fails and attaches encryption on retry',
|
|
173
|
+
async (failurePoint) => {
|
|
174
|
+
const { e2ee, transceivers, track, negotiate } = await setup();
|
|
175
|
+
const error = new Error('initialization failed');
|
|
176
|
+
e2ee.encrypt.mockImplementationOnce((sender: RTCRtpSender) => {
|
|
177
|
+
expect(sender.track).toBeNull();
|
|
178
|
+
if (failurePoint === 'encrypt') throw error;
|
|
179
|
+
if (failurePoint === 'getParameters') {
|
|
180
|
+
vi.mocked(sender.getParameters).mockImplementationOnce(() => {
|
|
181
|
+
throw error;
|
|
182
|
+
});
|
|
183
|
+
} else {
|
|
184
|
+
vi.mocked(sender[failurePoint]).mockRejectedValueOnce(error);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
await expect(publisher.publish(track, TrackType.VIDEO)).rejects.toBe(
|
|
188
|
+
error,
|
|
189
|
+
);
|
|
190
|
+
const failed = transceivers[0];
|
|
191
|
+
expect(failed.sender.track).toBeNull();
|
|
192
|
+
expect(failed.stop).toHaveBeenCalledOnce();
|
|
193
|
+
expect(publisher['transceiverCache'].items()).toHaveLength(0);
|
|
194
|
+
expect(publisher['clonedTracks'].size).toBe(0);
|
|
195
|
+
expect(negotiate).not.toHaveBeenCalled();
|
|
196
|
+
|
|
197
|
+
await publisher.publish(track, TrackType.VIDEO);
|
|
198
|
+
expect(transceivers).toHaveLength(2);
|
|
199
|
+
expect(e2ee.encrypt).toHaveBeenLastCalledWith(
|
|
200
|
+
transceivers[1].sender,
|
|
201
|
+
'vp9',
|
|
202
|
+
'VIDEO',
|
|
203
|
+
);
|
|
204
|
+
expect(transceivers[1].sender.track).not.toBeNull();
|
|
205
|
+
expect(publisher['transceiverCache'].indexOf(failed)).toBe(-1);
|
|
206
|
+
expect(publisher['transceiverCache'].indexOf(transceivers[1])).toBe(
|
|
207
|
+
0,
|
|
208
|
+
);
|
|
209
|
+
expect(negotiate).toHaveBeenCalledOnce();
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
it('keeps the mid index of a retired sender that reached an m-section', async () => {
|
|
214
|
+
const { e2ee, transceivers, track } = await setup();
|
|
215
|
+
const error = new Error('initialization failed');
|
|
216
|
+
e2ee.encrypt.mockImplementationOnce((sender: RTCRtpSender) => {
|
|
217
|
+
Object.assign(transceivers[0], { mid: '0' });
|
|
218
|
+
vi.mocked(sender.replaceTrack).mockRejectedValueOnce(error);
|
|
219
|
+
});
|
|
220
|
+
await expect(publisher.publish(track, TrackType.VIDEO)).rejects.toBe(
|
|
221
|
+
error,
|
|
222
|
+
);
|
|
223
|
+
expect(publisher['transceiverCache'].items()).toHaveLength(0);
|
|
224
|
+
expect(publisher['transceiverCache'].indexOf(transceivers[0])).toBe(0);
|
|
225
|
+
|
|
226
|
+
await publisher.publish(track, TrackType.VIDEO);
|
|
227
|
+
expect(publisher['transceiverCache'].indexOf(transceivers[1])).toBe(1);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('reports the initialization failure even when cleanup throws', async () => {
|
|
231
|
+
const { e2ee, transceivers, track } = await setup();
|
|
232
|
+
const error = new Error('initialization failed');
|
|
233
|
+
e2ee.encrypt.mockImplementationOnce(() => {
|
|
234
|
+
vi.mocked(transceivers[0].stop).mockImplementationOnce(() => {
|
|
235
|
+
throw new Error('peer connection is closed');
|
|
236
|
+
});
|
|
237
|
+
throw error;
|
|
238
|
+
});
|
|
239
|
+
await expect(publisher.publish(track, TrackType.VIDEO)).rejects.toBe(
|
|
240
|
+
error,
|
|
241
|
+
);
|
|
242
|
+
expect(publisher['transceiverCache'].items()).toHaveLength(0);
|
|
243
|
+
expect(publisher['clonedTracks'].size).toBe(0);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('leaves the cloned track alone on React Native', async () => {
|
|
247
|
+
vi.mocked(isReactNative).mockReturnValue(true);
|
|
248
|
+
const { e2ee, transceivers, track } = await setup();
|
|
249
|
+
const error = new Error('initialization failed');
|
|
250
|
+
e2ee.encrypt.mockImplementationOnce(() => {
|
|
251
|
+
throw error;
|
|
252
|
+
});
|
|
253
|
+
await expect(publisher.publish(track, TrackType.VIDEO)).rejects.toBe(
|
|
254
|
+
error,
|
|
255
|
+
);
|
|
256
|
+
const [clone] = publisher['clonedTracks'];
|
|
257
|
+
expect(clone.stop).not.toHaveBeenCalled();
|
|
258
|
+
expect(transceivers[0].stop).toHaveBeenCalledOnce();
|
|
259
|
+
expect(publisher['transceiverCache'].items()).toHaveLength(0);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('reuses an encrypted sender when only negotiation failed', async () => {
|
|
263
|
+
const { e2ee, transceivers, track, negotiate } = await setup();
|
|
264
|
+
const error = new Error('negotiation failed');
|
|
265
|
+
negotiate.mockRejectedValueOnce(error);
|
|
266
|
+
await expect(publisher.publish(track, TrackType.VIDEO)).rejects.toBe(
|
|
267
|
+
error,
|
|
268
|
+
);
|
|
269
|
+
expect(transceivers[0].sender.track).not.toBeNull();
|
|
270
|
+
expect(transceivers[0].stop).not.toHaveBeenCalled();
|
|
271
|
+
await publisher.publish(track, TrackType.VIDEO);
|
|
272
|
+
expect(transceivers).toHaveLength(1);
|
|
273
|
+
expect(e2ee.encrypt).toHaveBeenCalledOnce();
|
|
274
|
+
expect(negotiate).toHaveBeenCalledTimes(2);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('has no media to expose if ICE restart negotiates during parameter setup', async () => {
|
|
278
|
+
const { e2ee, transceivers, track, negotiate, realNegotiate } =
|
|
279
|
+
await setup();
|
|
280
|
+
negotiate.mockImplementation(realNegotiate);
|
|
281
|
+
publisher['publishOptions'].push(
|
|
282
|
+
fromPartial<PublishOption>({
|
|
283
|
+
id: 2,
|
|
284
|
+
trackType: TrackType.VIDEO,
|
|
285
|
+
codec: { name: 'vp9' },
|
|
286
|
+
}),
|
|
287
|
+
);
|
|
288
|
+
sfuClient.setPublisher = vi
|
|
289
|
+
.fn()
|
|
290
|
+
.mockResolvedValue({ response: { sdp: 'answer-sdp' } });
|
|
291
|
+
const parameters = promiseWithResolvers<void>();
|
|
292
|
+
e2ee.encrypt
|
|
293
|
+
.mockImplementationOnce(() => {})
|
|
294
|
+
.mockImplementationOnce((sender: RTCRtpSender) => {
|
|
295
|
+
vi.mocked(sender.setParameters).mockReturnValueOnce(
|
|
296
|
+
parameters.promise,
|
|
297
|
+
);
|
|
298
|
+
});
|
|
299
|
+
const publish = publisher.publish(track, TrackType.VIDEO);
|
|
300
|
+
await vi.waitFor(() => expect(e2ee.encrypt).toHaveBeenCalledTimes(2));
|
|
301
|
+
const [published, pending] = transceivers;
|
|
302
|
+
expect(pending.sender.track).toBeNull();
|
|
303
|
+
expect(pending.sender.replaceTrack).not.toHaveBeenCalled();
|
|
304
|
+
|
|
305
|
+
await publisher.restartIce();
|
|
306
|
+
const restart = vi.mocked(sfuClient.setPublisher).mock.calls[1][0];
|
|
307
|
+
expect(restart.tracks.map((t) => t.trackId)).toEqual([
|
|
308
|
+
published.sender.track!.id,
|
|
309
|
+
]);
|
|
310
|
+
|
|
311
|
+
parameters.resolve();
|
|
312
|
+
await publish;
|
|
313
|
+
expect(pending.sender.track).not.toBeNull();
|
|
314
|
+
expect(sfuClient.setPublisher).toHaveBeenCalledTimes(3);
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
109
318
|
it('should throw when publishing ended tracks', async () => {
|
|
110
319
|
const track = new MediaStreamTrack();
|
|
111
320
|
// @ts-expect-error readonly field
|
|
@@ -5,7 +5,16 @@
|
|
|
5
5
|
* attaching their own encoded transform in these two methods.
|
|
6
6
|
*/
|
|
7
7
|
export interface E2EEManager {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Synchronously attach a transform that encrypts the sender's outgoing frames.
|
|
10
|
+
* Must support a sender without a track, and throw if attachment fails.
|
|
11
|
+
*
|
|
12
|
+
* `sender.track` is always null here: the track is attached only after this
|
|
13
|
+
* returns, so implementations must not read it. Use `codec` and `trackType`
|
|
14
|
+
* instead.
|
|
15
|
+
*
|
|
16
|
+
* `trackType` only groups perf stats, keeping a camera and screen share apart.
|
|
17
|
+
*/
|
|
9
18
|
encrypt(sender: RTCRtpSender, codec?: string, trackType?: string): void;
|
|
10
19
|
/** `trackType` only groups perf stats, keeping a peer's audio and video apart. */
|
|
11
20
|
decrypt(receiver: RTCRtpReceiver, userId: string, trackType?: string): void;
|
|
@@ -263,9 +263,9 @@ export class EncryptionManager
|
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
if ((this.piped ??= new WeakSet()).has(target)) return;
|
|
266
|
-
this.piped.add(target);
|
|
267
266
|
// @ts-expect-error createEncodedStreams is not in the standard typedefs
|
|
268
267
|
const { readable, writable } = target.createEncodedStreams();
|
|
268
|
+
this.piped.add(target);
|
|
269
269
|
this.worker.postMessage(
|
|
270
270
|
{ type: 'cmd.setup_transform', ...options, readable, writable },
|
|
271
271
|
[readable, writable],
|
package/src/rtc/e2ee/SPEC.md
CHANGED
|
@@ -79,7 +79,7 @@ await call.join();
|
|
|
79
79
|
- **Removal comes in per-epoch and per-user forms, and the names must stay distinct.** `removeKey(userId, keyIndex)` retires one epoch; `removeAllKeys(userId)` revokes the participant entirely. Do not render these as overloads of one name: dropping the index argument would then silently mean "revoke everything", which is the opposite of the caller's intent and impossible to catch in review.
|
|
80
80
|
- **Every key operation's outcome is tabulated in Appendix B.** Implement the edge cases (removing the latest or active epoch, a failed import, an absent index) from that table rather than from prose.
|
|
81
81
|
- **Join request carries `e2ee: true`** so the backend knows the call is encrypted.
|
|
82
|
-
- The internal attach points (`encrypt(sender, codec, trackType)` / `decrypt(receiver, userId, trackType)`) are called by the RTC layer, not by apps. Keeping
|
|
82
|
+
- The internal attach points (`encrypt(sender, codec, trackType)` / `decrypt(receiver, userId, trackType)`) are called by the RTC layer, not by apps. The publisher creates an E2EE sender without a track and attaches media only after `encrypt` returns and sender parameters succeed. `encrypt` must synchronously attach the transform or throw, and must support a sender whose `track` is null. A failed initialization retires that transceiver so retries cannot bypass attachment. Keeping these points behind a small interface lets an integrator plug in a different scheme (e.g. SFrame).
|
|
83
83
|
|
|
84
84
|
---
|
|
85
85
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getStreamClientId } from '../utils';
|
|
3
|
+
import { SdkType } from '../../gen/video/sfu/models/models';
|
|
4
|
+
|
|
5
|
+
describe('getStreamClientId', () => {
|
|
6
|
+
const sdk = (type: SdkType) => ({
|
|
7
|
+
type,
|
|
8
|
+
major: '1',
|
|
9
|
+
minor: '43',
|
|
10
|
+
patch: '1',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('names the React SDK', () => {
|
|
14
|
+
expect(getStreamClientId(sdk(SdkType.REACT))).toBe(
|
|
15
|
+
'stream-video-react-v1.43.1',
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('names the React Native SDK', () => {
|
|
20
|
+
expect(getStreamClientId(sdk(SdkType.REACT_NATIVE))).toBe(
|
|
21
|
+
'stream-video-react-native-v1.43.1',
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('falls back to the plain JS client for every other SDK type', () => {
|
|
26
|
+
expect(getStreamClientId(sdk(SdkType.PLAIN_JAVASCRIPT))).toBe(
|
|
27
|
+
'stream-video-js-v1.43.1',
|
|
28
|
+
);
|
|
29
|
+
expect(getStreamClientId(undefined)).toBe(
|
|
30
|
+
'stream-video-js-v0.0.0-development',
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
});
|
package/src/stats/utils.ts
CHANGED
|
@@ -51,3 +51,18 @@ export const getSdkName = (sdk: Sdk | undefined) => {
|
|
|
51
51
|
export const getSdkVersion = (sdk: Sdk | undefined) => {
|
|
52
52
|
return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
|
|
53
53
|
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns the identifier the SFU receives in the `X-Stream-Client` header,
|
|
57
|
+
* e.g. `stream-video-react-v1.43.1`. Matches the format the coordinator
|
|
58
|
+
* already gets through the client's user agent.
|
|
59
|
+
*/
|
|
60
|
+
export const getStreamClientId = (sdk: Sdk | undefined) => {
|
|
61
|
+
const sdkPlatforms: Partial<Record<SdkType, string>> = {
|
|
62
|
+
[SdkType.REACT]: 'react',
|
|
63
|
+
[SdkType.REACT_NATIVE]: 'react-native',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const platform = (sdk && sdkPlatforms[sdk.type]) || 'js';
|
|
67
|
+
return `stream-video-${platform}-v${getSdkVersion(sdk)}`;
|
|
68
|
+
};
|