@stream-io/video-client 1.52.0 → 1.53.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/index.browser.es.js +796 -51
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +796 -50
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.es.js +796 -51
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/src/Call.d.ts +5 -1
  9. package/dist/src/StreamVideoClient.d.ts +2 -0
  10. package/dist/src/coordinator/connection/client.d.ts +1 -0
  11. package/dist/src/errors/SfuTimeoutError.d.ts +8 -0
  12. package/dist/src/errors/index.d.ts +1 -0
  13. package/dist/src/helpers/firstVideoFrame.d.ts +7 -0
  14. package/dist/src/reporting/ClientEventReporter.d.ts +84 -0
  15. package/dist/src/reporting/index.d.ts +1 -0
  16. package/dist/src/rtc/BasePeerConnection.d.ts +5 -2
  17. package/dist/src/rtc/types.d.ts +24 -1
  18. package/dist/src/types.d.ts +5 -0
  19. package/package.json +1 -1
  20. package/src/Call.ts +184 -60
  21. package/src/StreamSfuClient.ts +3 -3
  22. package/src/StreamVideoClient.ts +18 -3
  23. package/src/__tests__/Call.autodrop.test.ts +4 -1
  24. package/src/__tests__/Call.lifecycle.test.ts +4 -1
  25. package/src/__tests__/Call.publishing.test.ts +4 -1
  26. package/src/__tests__/Call.test.ts +23 -0
  27. package/src/coordinator/connection/client.ts +5 -0
  28. package/src/devices/__tests__/CameraManager.test.ts +10 -1
  29. package/src/devices/__tests__/DeviceManager.test.ts +10 -1
  30. package/src/devices/__tests__/DeviceManagerFilters.test.ts +4 -1
  31. package/src/devices/__tests__/MicrophoneManager.test.ts +10 -1
  32. package/src/devices/__tests__/MicrophoneManagerRN.test.ts +4 -1
  33. package/src/devices/__tests__/ScreenShareManager.test.ts +4 -1
  34. package/src/devices/__tests__/SpeakerManager.test.ts +13 -4
  35. package/src/errors/SfuTimeoutError.ts +7 -0
  36. package/src/errors/index.ts +1 -0
  37. package/src/events/__tests__/call.test.ts +2 -0
  38. package/src/events/__tests__/mutes.test.ts +4 -1
  39. package/src/events/call.ts +8 -0
  40. package/src/helpers/__tests__/AudioBindingsWatchdog.test.ts +6 -3
  41. package/src/helpers/__tests__/DynascaleManager.test.ts +6 -3
  42. package/src/helpers/__tests__/ViewportTracker.test.ts +6 -3
  43. package/src/helpers/__tests__/firstVideoFrame.test.ts +91 -0
  44. package/src/helpers/firstVideoFrame.ts +38 -0
  45. package/src/reporting/ClientEventReporter.ts +859 -0
  46. package/src/reporting/__tests__/ClientEventReporter.test.ts +620 -0
  47. package/src/reporting/index.ts +1 -0
  48. package/src/rtc/BasePeerConnection.ts +30 -0
  49. package/src/rtc/Subscriber.ts +1 -0
  50. package/src/rtc/__tests__/Call.reconnect.test.ts +3 -0
  51. package/src/rtc/types.ts +34 -0
  52. package/src/types.ts +6 -0
@@ -94,6 +94,7 @@ export class Subscriber extends BasePeerConnection {
94
94
  track.addEventListener('unmute', () => {
95
95
  this.logger.info(`[onTrack]: Track unmuted: ${trackDebugInfo}`);
96
96
  this.setRemoteTrackInterrupted(trackId, trackType, false);
97
+ this.onRemoteTrackUnmute?.(trackType, track.id);
97
98
  });
98
99
  track.addEventListener('ended', () => {
99
100
  this.logger.info(`[onTrack]: Track ended: ${trackDebugInfo}`);
@@ -3,6 +3,7 @@ import './mocks/webrtc.mocks';
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
4
  import { Call } from '../../Call';
5
5
  import { StreamClient } from '../../coordinator/connection/client';
6
+ import { ClientEventReporter } from '../../reporting';
6
7
  import { StreamVideoWriteableStateStore } from '../../store';
7
8
  import { CallingState } from '../../store';
8
9
  import { NegotiationError } from '../NegotiationError';
@@ -30,6 +31,7 @@ const makeCall = () => {
30
31
  type: 'default',
31
32
  id: 'test-call',
32
33
  streamClient,
34
+ clientEventReporter: new ClientEventReporter({ streamClient }),
33
35
  clientStore,
34
36
  ringing: false,
35
37
  watching: false,
@@ -585,6 +587,7 @@ describe('Call reconnect wiring (PC event → leave)', () => {
585
587
  type: 'default',
586
588
  id: 'test-call',
587
589
  streamClient,
590
+ clientEventReporter: new ClientEventReporter({ streamClient }),
588
591
  clientStore,
589
592
  ringing: false,
590
593
  watching: false,
package/src/rtc/types.ts CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  AudioBitrateProfile,
3
3
  PeerType,
4
4
  PublishOption,
5
+ TrackType,
5
6
  WebsocketReconnectStrategy,
6
7
  } from '../gen/video/sfu/models/models';
7
8
  import { StreamSfuClient } from '../StreamSfuClient';
@@ -53,6 +54,37 @@ export type OnReconnectionNeeded = (
53
54
  */
54
55
  export type OnIceConnected = (peerType: PeerType) => void;
55
56
 
57
+ /**
58
+ * Snapshot of the peer connection's ICE and DTLS state surfaced to telemetry
59
+ * consumers (e.g. `ClientEventReporter`). Fired on every transition of
60
+ * either `iceConnectionState` or `peerConnectionState`.
61
+ */
62
+ export type PeerConnectionStateChangeEvent =
63
+ | {
64
+ peerType: PeerType;
65
+ stateType: 'ice';
66
+ state: RTCIceConnectionState;
67
+ }
68
+ | {
69
+ peerType: PeerType;
70
+ stateType: 'peerConnection';
71
+ state: RTCPeerConnectionState;
72
+ };
73
+
74
+ export type OnPeerConnectionStateChange = (
75
+ event: PeerConnectionStateChangeEvent,
76
+ ) => void;
77
+
78
+ /**
79
+ * Fired when a remote track starts receiving media (`unmute`). Used by
80
+ * telemetry to report the `FirstVideoFrame` / `FirstAudioFrame` stage; the
81
+ * consumer decides which track types are relevant.
82
+ */
83
+ export type OnRemoteTrackUnmute = (
84
+ trackType: TrackType,
85
+ trackId: string,
86
+ ) => void;
87
+
56
88
  export type BasePeerConnectionOpts = {
57
89
  sfuClient: StreamSfuClient;
58
90
  state: CallState;
@@ -60,6 +92,8 @@ export type BasePeerConnectionOpts = {
60
92
  dispatcher: Dispatcher;
61
93
  onReconnectionNeeded?: OnReconnectionNeeded;
62
94
  onIceConnected?: OnIceConnected;
95
+ onPeerConnectionStateChange?: OnPeerConnectionStateChange;
96
+ onRemoteTrackUnmute?: OnRemoteTrackUnmute;
63
97
  tag: string;
64
98
  enableTracing: boolean;
65
99
  iceRestartDelay?: number;
package/src/types.ts CHANGED
@@ -14,6 +14,7 @@ import type {
14
14
  StartRecordingResponse,
15
15
  } from './gen/coordinator';
16
16
  import type { StreamClient } from './coordinator/connection/client';
17
+ import type { ClientEventReporter } from './reporting';
17
18
  import type {
18
19
  RejectReason,
19
20
  StreamClientOptions,
@@ -311,6 +312,11 @@ export type CallConstructor = {
311
312
  */
312
313
  streamClient: StreamClient;
313
314
 
315
+ /**
316
+ * The shared client event reporter, owned by `StreamVideoClient`.
317
+ */
318
+ clientEventReporter: ClientEventReporter;
319
+
314
320
  /**
315
321
  * The Call type.
316
322
  */