@stream-io/video-client 1.14.0 → 1.15.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 (92) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.browser.es.js +1532 -1784
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +1512 -1783
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.es.js +1532 -1784
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/src/Call.d.ts +43 -28
  9. package/dist/src/StreamSfuClient.d.ts +4 -5
  10. package/dist/src/devices/CameraManager.d.ts +5 -8
  11. package/dist/src/devices/InputMediaDeviceManager.d.ts +5 -5
  12. package/dist/src/devices/MicrophoneManager.d.ts +7 -2
  13. package/dist/src/devices/ScreenShareManager.d.ts +1 -2
  14. package/dist/src/gen/video/sfu/event/events.d.ts +38 -19
  15. package/dist/src/gen/video/sfu/models/models.d.ts +76 -9
  16. package/dist/src/helpers/array.d.ts +7 -0
  17. package/dist/src/permissions/PermissionsContext.d.ts +6 -0
  18. package/dist/src/rtc/BasePeerConnection.d.ts +90 -0
  19. package/dist/src/rtc/Dispatcher.d.ts +0 -1
  20. package/dist/src/rtc/IceTrickleBuffer.d.ts +3 -2
  21. package/dist/src/rtc/Publisher.d.ts +32 -86
  22. package/dist/src/rtc/Subscriber.d.ts +4 -56
  23. package/dist/src/rtc/TransceiverCache.d.ts +55 -0
  24. package/dist/src/rtc/codecs.d.ts +1 -15
  25. package/dist/src/rtc/helpers/sdp.d.ts +8 -0
  26. package/dist/src/rtc/helpers/tracks.d.ts +1 -0
  27. package/dist/src/rtc/index.d.ts +3 -0
  28. package/dist/src/rtc/videoLayers.d.ts +11 -25
  29. package/dist/src/stats/{stateStoreStatsReporter.d.ts → CallStateStatsReporter.d.ts} +5 -1
  30. package/dist/src/stats/SfuStatsReporter.d.ts +4 -2
  31. package/dist/src/stats/index.d.ts +1 -1
  32. package/dist/src/stats/types.d.ts +8 -0
  33. package/dist/src/types.d.ts +12 -22
  34. package/package.json +1 -1
  35. package/src/Call.ts +254 -268
  36. package/src/StreamSfuClient.ts +9 -14
  37. package/src/StreamVideoClient.ts +1 -1
  38. package/src/__tests__/Call.publishing.test.ts +306 -0
  39. package/src/devices/CameraManager.ts +33 -16
  40. package/src/devices/InputMediaDeviceManager.ts +36 -27
  41. package/src/devices/MicrophoneManager.ts +29 -8
  42. package/src/devices/ScreenShareManager.ts +6 -8
  43. package/src/devices/__tests__/CameraManager.test.ts +111 -14
  44. package/src/devices/__tests__/InputMediaDeviceManager.test.ts +4 -4
  45. package/src/devices/__tests__/MicrophoneManager.test.ts +59 -21
  46. package/src/devices/__tests__/ScreenShareManager.test.ts +5 -5
  47. package/src/devices/__tests__/mocks.ts +1 -0
  48. package/src/events/__tests__/internal.test.ts +132 -0
  49. package/src/events/__tests__/mutes.test.ts +0 -3
  50. package/src/events/__tests__/speaker.test.ts +92 -0
  51. package/src/events/participant.ts +3 -4
  52. package/src/gen/video/sfu/event/events.ts +91 -30
  53. package/src/gen/video/sfu/models/models.ts +105 -13
  54. package/src/helpers/array.ts +14 -0
  55. package/src/permissions/PermissionsContext.ts +22 -0
  56. package/src/permissions/__tests__/PermissionsContext.test.ts +40 -0
  57. package/src/rpc/__tests__/createClient.test.ts +38 -0
  58. package/src/rpc/createClient.ts +11 -5
  59. package/src/rtc/BasePeerConnection.ts +240 -0
  60. package/src/rtc/Dispatcher.ts +0 -9
  61. package/src/rtc/IceTrickleBuffer.ts +24 -4
  62. package/src/rtc/Publisher.ts +210 -528
  63. package/src/rtc/Subscriber.ts +26 -200
  64. package/src/rtc/TransceiverCache.ts +120 -0
  65. package/src/rtc/__tests__/Publisher.test.ts +407 -210
  66. package/src/rtc/__tests__/Subscriber.test.ts +88 -36
  67. package/src/rtc/__tests__/mocks/webrtc.mocks.ts +22 -2
  68. package/src/rtc/__tests__/videoLayers.test.ts +161 -54
  69. package/src/rtc/codecs.ts +1 -131
  70. package/src/rtc/helpers/__tests__/rtcConfiguration.test.ts +34 -0
  71. package/src/rtc/helpers/__tests__/sdp.test.ts +59 -0
  72. package/src/rtc/helpers/sdp.ts +30 -0
  73. package/src/rtc/helpers/tracks.ts +3 -0
  74. package/src/rtc/index.ts +4 -0
  75. package/src/rtc/videoLayers.ts +68 -76
  76. package/src/stats/{stateStoreStatsReporter.ts → CallStateStatsReporter.ts} +58 -27
  77. package/src/stats/SfuStatsReporter.ts +31 -3
  78. package/src/stats/index.ts +1 -1
  79. package/src/stats/types.ts +12 -0
  80. package/src/types.ts +12 -22
  81. package/dist/src/helpers/sdp-munging.d.ts +0 -24
  82. package/dist/src/rtc/bitrateLookup.d.ts +0 -2
  83. package/dist/src/rtc/helpers/iceCandidate.d.ts +0 -2
  84. package/src/helpers/__tests__/hq-audio-sdp.ts +0 -332
  85. package/src/helpers/__tests__/sdp-munging.test.ts +0 -283
  86. package/src/helpers/sdp-munging.ts +0 -265
  87. package/src/rtc/__tests__/bitrateLookup.test.ts +0 -12
  88. package/src/rtc/__tests__/codecs.test.ts +0 -145
  89. package/src/rtc/bitrateLookup.ts +0 -61
  90. package/src/rtc/helpers/iceCandidate.ts +0 -16
  91. /package/dist/src/{compatibility.d.ts → helpers/compatibility.d.ts} +0 -0
  92. /package/src/{compatibility.ts → helpers/compatibility.ts} +0 -0
@@ -5,7 +5,8 @@ import { ICETrickle } from '../gen/video/sfu/event/events';
5
5
  * - https://bloggeek.me/webrtcglossary/trickle-ice/
6
6
  */
7
7
  export declare class IceTrickleBuffer {
8
- readonly subscriberCandidates: ReplaySubject<ICETrickle>;
9
- readonly publisherCandidates: ReplaySubject<ICETrickle>;
8
+ readonly subscriberCandidates: ReplaySubject<RTCIceCandidateInit>;
9
+ readonly publisherCandidates: ReplaySubject<RTCIceCandidateInit>;
10
10
  push: (iceTrickle: ICETrickle) => void;
11
+ dispose: () => void;
11
12
  }
@@ -1,118 +1,59 @@
1
- import { StreamSfuClient } from '../StreamSfuClient';
2
- import { TrackInfo, TrackType } from '../gen/video/sfu/models/models';
3
- import { CallState } from '../store';
4
- import { PublishOptions } from '../types';
5
- import { Dispatcher } from './Dispatcher';
6
- export type PublisherConstructorOpts = {
7
- sfuClient: StreamSfuClient;
8
- state: CallState;
9
- dispatcher: Dispatcher;
10
- connectionConfig?: RTCConfiguration;
11
- isDtxEnabled: boolean;
12
- isRedEnabled: boolean;
13
- onUnrecoverableError?: () => void;
14
- logTag: string;
1
+ import { BasePeerConnection, BasePeerConnectionOpts } from './BasePeerConnection';
2
+ import { PublishOption, TrackInfo, TrackType } from '../gen/video/sfu/models/models';
3
+ export type PublisherConstructorOpts = BasePeerConnectionOpts & {
4
+ publishOptions: PublishOption[];
15
5
  };
16
6
  /**
17
7
  * The `Publisher` is responsible for publishing/unpublishing media streams to/from the SFU
18
8
  *
19
9
  * @internal
20
10
  */
21
- export declare class Publisher {
22
- private readonly logger;
23
- private pc;
24
- private readonly state;
11
+ export declare class Publisher extends BasePeerConnection {
25
12
  private readonly transceiverCache;
26
- private readonly trackLayersCache;
27
- private readonly publishOptsForTrack;
28
- /**
29
- * An array maintaining the order how transceivers were added to the peer connection.
30
- * This is needed because some browsers (Firefox) don't reliably report
31
- * trackId and `mid` parameters.
32
- *
33
- * @internal
34
- */
35
- private readonly transceiverInitOrder;
36
- private readonly isDtxEnabled;
37
- private readonly isRedEnabled;
38
- private readonly unsubscribeOnIceRestart;
39
- private readonly unsubscribeChangePublishQuality;
40
- private readonly onUnrecoverableError?;
41
- private isIceRestarting;
42
- private sfuClient;
13
+ private publishOptions;
43
14
  /**
44
15
  * Constructs a new `Publisher` instance.
45
16
  */
46
- constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled, onUnrecoverableError, logTag, }: PublisherConstructorOpts);
47
- private createPeerConnection;
48
- /**
49
- * Closes the publisher PeerConnection and cleans up the resources.
50
- */
51
- close: ({ stopTracks }: {
52
- stopTracks: boolean;
53
- }) => void;
17
+ constructor({ publishOptions, ...baseOptions }: PublisherConstructorOpts);
54
18
  /**
55
19
  * Detaches the event handlers from the `RTCPeerConnection`.
56
20
  * This is useful when we want to replace the `RTCPeerConnection`
57
21
  * instance with a new one (in case of migration).
58
22
  */
59
- detachEventHandlers: () => void;
23
+ detachEventHandlers(): void;
60
24
  /**
61
25
  * Starts publishing the given track of the given media stream.
62
26
  *
63
27
  * Consecutive calls to this method will replace the stream.
64
28
  * The previous stream will be stopped.
65
29
  *
66
- * @param mediaStream the media stream to publish.
67
30
  * @param track the track to publish.
68
31
  * @param trackType the track type to publish.
69
- * @param opts the optional publish options to use.
70
32
  */
71
- publishStream: (mediaStream: MediaStream, track: MediaStreamTrack, trackType: TrackType, opts?: PublishOptions) => Promise<void>;
33
+ publish: (track: MediaStreamTrack, trackType: TrackType) => Promise<void>;
72
34
  /**
73
- * Adds a new transceiver to the peer connection.
74
- * This needs to be called when a new track kind is added to the peer connection.
75
- * In other cases, use `updateTransceiver` method.
35
+ * Adds a new transceiver carrying the given track to the peer connection.
76
36
  */
77
37
  private addTransceiver;
78
38
  /**
79
- * Updates the given transceiver with the new track.
80
- * Stops the previous track and replaces it with the new one.
39
+ * Synchronizes the current Publisher state with the provided publish options.
81
40
  */
82
- private updateTransceiver;
83
- /**
84
- * Stops publishing the given track type to the SFU, if it is currently being published.
85
- * Underlying track will be stopped and removed from the publisher.
86
- * @param trackType the track type to unpublish.
87
- * @param stopTrack specifies whether track should be stopped or just disabled
88
- */
89
- unpublishStream: (trackType: TrackType, stopTrack: boolean) => Promise<void>;
41
+ private syncPublishOptions;
90
42
  /**
91
43
  * Returns true if the given track type is currently being published to the SFU.
92
44
  *
93
45
  * @param trackType the track type to check.
94
46
  */
95
47
  isPublishing: (trackType: TrackType) => boolean;
96
- private notifyTrackMuteStateChanged;
97
48
  /**
98
- * Stops publishing all tracks and stop all tracks.
49
+ * Maps the given track ID to the corresponding track type.
99
50
  */
100
- private stopPublishing;
101
- private changePublishQuality;
51
+ getTrackType: (trackId: string) => TrackType | undefined;
102
52
  /**
103
- * Returns the result of the `RTCPeerConnection.getStats()` method
104
- * @param selector
105
- * @returns
106
- */
107
- getStats: (selector?: MediaStreamTrack | null | undefined) => Promise<RTCStatsReport>;
108
- private getCodecPreferences;
109
- private onIceCandidate;
110
- /**
111
- * Sets the SFU client to use.
112
- *
113
- * @param sfuClient the SFU client to use.
53
+ * Stops the cloned track that is being published to the SFU.
114
54
  */
115
- setSfuClient: (sfuClient: StreamSfuClient) => void;
55
+ stopTracks: (...trackTypes: TrackType[]) => void;
56
+ private changePublishQuality;
116
57
  /**
117
58
  * Restarts the ICE connection and renegotiates with the SFU.
118
59
  */
@@ -124,18 +65,23 @@ export declare class Publisher {
124
65
  * @param options the optional offer options to use.
125
66
  */
126
67
  private negotiate;
127
- private removeUnpreferredCodecs;
128
- private enableHighQualityAudio;
129
68
  /**
130
69
  * Returns a list of tracks that are currently being published.
131
- *
132
- * @internal
70
+ */
71
+ getPublishedTracks: () => MediaStreamTrack[];
72
+ /**
73
+ * Returns a list of tracks that are currently being published.
133
74
  * @param sdp an optional SDP to extract the `mid` from.
134
75
  */
135
- getAnnouncedTracks: (sdp?: string) => TrackInfo[];
136
- private computeLayers;
137
- private onIceCandidateError;
138
- private onIceConnectionStateChange;
139
- private onIceGatheringStateChange;
140
- private onSignalingStateChange;
76
+ getAnnouncedTracks: (sdp: string | undefined) => TrackInfo[];
77
+ /**
78
+ * Returns a list of tracks that are currently being published.
79
+ * This method shall be used for the reconnection flow.
80
+ * There we shouldn't announce the tracks that have been stopped due to a codec switch.
81
+ */
82
+ getAnnouncedTracksForReconnect: () => TrackInfo[];
83
+ /**
84
+ * Converts the given transceiver to a `TrackInfo` object.
85
+ */
86
+ private toTrackInfo;
141
87
  }
@@ -1,77 +1,25 @@
1
- import { StreamSfuClient } from '../StreamSfuClient';
2
- import { Dispatcher } from './Dispatcher';
3
- import { CallState } from '../store';
4
- export type SubscriberOpts = {
5
- sfuClient: StreamSfuClient;
6
- dispatcher: Dispatcher;
7
- state: CallState;
8
- connectionConfig?: RTCConfiguration;
9
- onUnrecoverableError?: () => void;
10
- logTag: string;
11
- };
1
+ import { BasePeerConnection, BasePeerConnectionOpts } from './BasePeerConnection';
12
2
  /**
13
3
  * A wrapper around the `RTCPeerConnection` that handles the incoming
14
4
  * media streams from the SFU.
15
5
  *
16
6
  * @internal
17
7
  */
18
- export declare class Subscriber {
19
- private readonly logger;
20
- private pc;
21
- private sfuClient;
22
- private state;
23
- private readonly unregisterOnSubscriberOffer;
24
- private readonly unregisterOnIceRestart;
25
- private readonly onUnrecoverableError?;
26
- private isIceRestarting;
8
+ export declare class Subscriber extends BasePeerConnection {
27
9
  /**
28
10
  * Constructs a new `Subscriber` instance.
29
- *
30
- * @param sfuClient the SFU client to use.
31
- * @param dispatcher the dispatcher to use.
32
- * @param state the state of the call.
33
- * @param connectionConfig the connection configuration to use.
34
- * @param iceRestartDelay the delay in milliseconds to wait before restarting ICE when connection goes to `disconnected` state.
35
- * @param onUnrecoverableError a callback to call when an unrecoverable error occurs.
36
- * @param logTag a tag to use for logging.
37
11
  */
38
- constructor({ sfuClient, dispatcher, state, connectionConfig, onUnrecoverableError, logTag, }: SubscriberOpts);
39
- /**
40
- * Creates a new `RTCPeerConnection` instance with the given configuration.
41
- *
42
- * @param connectionConfig the connection configuration to use.
43
- */
44
- private createPeerConnection;
45
- /**
46
- * Closes the `RTCPeerConnection` and unsubscribes from the dispatcher.
47
- */
48
- close: () => void;
12
+ constructor(opts: BasePeerConnectionOpts);
49
13
  /**
50
14
  * Detaches the event handlers from the `RTCPeerConnection`.
51
15
  * This is useful when we want to replace the `RTCPeerConnection`
52
16
  * instance with a new one (in case of migration).
53
17
  */
54
- detachEventHandlers: () => void;
55
- /**
56
- * Returns the result of the `RTCPeerConnection.getStats()` method
57
- * @param selector
58
- * @returns
59
- */
60
- getStats: (selector?: MediaStreamTrack | null | undefined) => Promise<RTCStatsReport>;
61
- /**
62
- * Sets the SFU client to use.
63
- *
64
- * @param sfuClient the SFU client to use.
65
- */
66
- setSfuClient: (sfuClient: StreamSfuClient) => void;
18
+ detachEventHandlers(): void;
67
19
  /**
68
20
  * Restarts the ICE connection and renegotiates with the SFU.
69
21
  */
70
22
  restartIce: () => Promise<void>;
71
23
  private handleOnTrack;
72
- private onIceCandidate;
73
24
  private negotiate;
74
- private onIceConnectionStateChange;
75
- private onIceGatheringStateChange;
76
- private onIceCandidateError;
77
25
  }
@@ -0,0 +1,55 @@
1
+ import { PublishOption, TrackType } from '../gen/video/sfu/models/models';
2
+ import { OptimalVideoLayer } from './videoLayers';
3
+ type TransceiverId = {
4
+ publishOption: PublishOption;
5
+ transceiver: RTCRtpTransceiver;
6
+ };
7
+ export declare class TransceiverCache {
8
+ private readonly cache;
9
+ private readonly layers;
10
+ /**
11
+ * An array maintaining the order how transceivers were added to the peer connection.
12
+ * This is needed because some browsers (Firefox) don't reliably report
13
+ * trackId and `mid` parameters.
14
+ */
15
+ private readonly transceiverOrder;
16
+ /**
17
+ * Adds a transceiver to the cache.
18
+ */
19
+ add: (publishOption: PublishOption, transceiver: RTCRtpTransceiver) => void;
20
+ /**
21
+ * Gets the transceiver for the given publish option.
22
+ */
23
+ get: (publishOption: PublishOption) => RTCRtpTransceiver | undefined;
24
+ /**
25
+ * Gets the last transceiver for the given track type and publish option id.
26
+ */
27
+ getWith: (trackType: TrackType, id: number) => RTCRtpTransceiver | undefined;
28
+ /**
29
+ * Checks if the cache has the given publish option.
30
+ */
31
+ has: (publishOption: PublishOption) => boolean;
32
+ /**
33
+ * Finds the first transceiver that satisfies the given predicate.
34
+ */
35
+ find: (predicate: (item: TransceiverId) => boolean) => TransceiverId | undefined;
36
+ /**
37
+ * Provides all the items in the cache.
38
+ */
39
+ items: () => TransceiverId[];
40
+ /**
41
+ * Init index of the transceiver in the cache.
42
+ */
43
+ indexOf: (transceiver: RTCRtpTransceiver) => number;
44
+ /**
45
+ * Gets cached video layers for the given track.
46
+ */
47
+ getLayers: (publishOption: PublishOption) => OptimalVideoLayer[] | undefined;
48
+ /**
49
+ * Sets the video layers for the given track.
50
+ */
51
+ setLayers: (publishOption: PublishOption, layers?: OptimalVideoLayer[]) => void;
52
+ private findTransceiver;
53
+ private findLayer;
54
+ }
55
+ export {};
@@ -1,25 +1,11 @@
1
- import type { PreferredCodec } from '../types';
2
- /**
3
- * Returns back a list of sorted codecs, with the preferred codec first.
4
- *
5
- * @param kind the kind of codec to get.
6
- * @param preferredCodec the codec to prioritize (vp8, h264, vp9, av1...).
7
- * @param codecToRemove the codec to exclude from the list.
8
- * @param codecPreferencesSource the source of the codec preferences.
9
- */
10
- export declare const getPreferredCodecs: (kind: "audio" | "video", preferredCodec: string, codecToRemove: string | undefined, codecPreferencesSource: "sender" | "receiver") => RTCRtpCodec[] | undefined;
11
1
  /**
12
2
  * Returns a generic SDP for the given direction.
13
3
  * We use this SDP to send it as part of our JoinRequest so that the SFU
14
- * can use it to determine client's codec capabilities.
4
+ * can use it to determine the client's codec capabilities.
15
5
  *
16
6
  * @param direction the direction of the transceiver.
17
7
  */
18
8
  export declare const getGenericSdp: (direction: RTCRtpTransceiverDirection) => Promise<string>;
19
- /**
20
- * Returns the optimal video codec for the device.
21
- */
22
- export declare const getOptimalVideoCodec: (preferredCodec: PreferredCodec | undefined) => PreferredCodec;
23
9
  /**
24
10
  * Returns whether the codec is an SVC codec.
25
11
  *
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Extracts the mid from the transceiver or the SDP.
3
+ *
4
+ * @param transceiver the transceiver.
5
+ * @param transceiverInitIndex the index of the transceiver in the transceiver's init array.
6
+ * @param sdp the SDP.
7
+ */
8
+ export declare const extractMid: (transceiver: RTCRtpTransceiver, transceiverInitIndex: number, sdp: string | undefined) => string;
@@ -3,3 +3,4 @@ import { TrackMuteType } from '../../types';
3
3
  export declare const trackTypeToParticipantStreamKey: (trackType: TrackType) => "audioStream" | "videoStream" | "screenShareStream" | "screenShareAudioStream" | undefined;
4
4
  export declare const muteTypeToTrackType: (muteType: TrackMuteType) => TrackType | undefined;
5
5
  export declare const toTrackType: (trackType: string) => TrackType | undefined;
6
+ export declare const isAudioTrackType: (trackType: TrackType) => boolean;
@@ -5,3 +5,6 @@ export * from './Publisher';
5
5
  export * from './Subscriber';
6
6
  export * from './signal';
7
7
  export * from './videoLayers';
8
+ export * from './helpers/sdp';
9
+ export * from './helpers/tracks';
10
+ export * from './helpers/rtcConfiguration';
@@ -1,6 +1,4 @@
1
- import { PreferredCodec, PublishOptions } from '../types';
2
- import { TargetResolutionResponse } from '../gen/shims';
3
- import { VideoQuality } from '../gen/video/sfu/models/models';
1
+ import { PublishOption, VideoDimension, VideoLayer, VideoQuality } from '../gen/video/sfu/models/models';
4
2
  export type OptimalVideoLayer = RTCRtpEncodingParameters & {
5
3
  width: number;
6
4
  height: number;
@@ -13,32 +11,22 @@ export type OptimalVideoLayer = RTCRtpEncodingParameters & {
13
11
  *
14
12
  * @param layers the layers to process.
15
13
  */
16
- export declare const toSvcEncodings: (layers: OptimalVideoLayer[] | undefined) => {
17
- rid: string;
18
- active?: boolean;
19
- maxBitrate?: number;
20
- maxFramerate?: number;
21
- networkPriority?: RTCPriorityType;
22
- priority?: RTCPriorityType;
23
- scaleResolutionDownBy?: number;
24
- width: number;
25
- height: number;
26
- scalabilityMode?: string;
27
- }[] | undefined;
14
+ export declare const toSvcEncodings: (layers: OptimalVideoLayer[] | undefined) => RTCRtpEncodingParameters[] | undefined;
28
15
  /**
29
16
  * Converts the rid to a video quality.
30
17
  */
31
18
  export declare const ridToVideoQuality: (rid: string) => VideoQuality;
32
19
  /**
33
- * Determines the most optimal video layers for simulcasting
34
- * for the given track.
20
+ * Converts the given video layers to SFU video layers.
21
+ */
22
+ export declare const toVideoLayers: (layers?: OptimalVideoLayer[] | undefined) => VideoLayer[];
23
+ /**
24
+ * Determines the most optimal video layers for the given track.
35
25
  *
36
26
  * @param videoTrack the video track to find optimal layers for.
37
- * @param targetResolution the expected target resolution.
38
- * @param codecInUse the codec in use.
39
- * @param publishOptions the publish options for the track.
27
+ * @param publishOption the publish options for the track.
40
28
  */
41
- export declare const findOptimalVideoLayers: (videoTrack: MediaStreamTrack, targetResolution?: TargetResolutionResponse, codecInUse?: PreferredCodec, publishOptions?: PublishOptions) => OptimalVideoLayer[];
29
+ export declare const computeVideoLayers: (videoTrack: MediaStreamTrack, publishOption: PublishOption) => OptimalVideoLayer[] | undefined;
42
30
  /**
43
31
  * Computes the maximum bitrate for a given resolution.
44
32
  * If the current resolution is lower than the target resolution,
@@ -49,8 +37,6 @@ export declare const findOptimalVideoLayers: (videoTrack: MediaStreamTrack, targ
49
37
  * @param targetResolution the target resolution.
50
38
  * @param currentWidth the current width of the track.
51
39
  * @param currentHeight the current height of the track.
52
- * @param codecInUse the codec in use.
53
- * @param publishOptions the publish options.
40
+ * @param bitrate the target bitrate.
54
41
  */
55
- export declare const getComputedMaxBitrate: (targetResolution: TargetResolutionResponse, currentWidth: number, currentHeight: number, codecInUse?: PreferredCodec, publishOptions?: PublishOptions) => number;
56
- export declare const findOptimalScreenSharingLayers: (videoTrack: MediaStreamTrack, publishOptions?: PublishOptions, defaultMaxBitrate?: number) => OptimalVideoLayer[];
42
+ export declare const getComputedMaxBitrate: (targetResolution: VideoDimension, currentWidth: number, currentHeight: number, bitrate: number) => number;
@@ -28,7 +28,7 @@ export type StatsReporter = {
28
28
  * @param kind the peer connection kind (subscriber or publisher).
29
29
  * @param mediaStream the media stream.
30
30
  */
31
- getStatsForStream: (kind: 'subscriber' | 'publisher', mediaStream: MediaStream) => Promise<StatsReport[]>;
31
+ getStatsForStream: (kind: 'subscriber' | 'publisher', tracks: MediaStreamTrack[]) => Promise<StatsReport[]>;
32
32
  /**
33
33
  * Helper method for retrieving raw stats for a given peer connection kind.
34
34
  *
@@ -54,4 +54,8 @@ export type StatsTransformOpts = {
54
54
  * The kind of peer connection we are transforming stats for.
55
55
  */
56
56
  kind: 'subscriber' | 'publisher';
57
+ /**
58
+ * The publisher instance.
59
+ */
60
+ publisher: Publisher | undefined;
57
61
  };
@@ -2,9 +2,9 @@ import { StreamSfuClient } from '../StreamSfuClient';
2
2
  import { StatsOptions } from '../gen/coordinator';
3
3
  import { Publisher, Subscriber } from '../rtc';
4
4
  import { LocalClientDetailsType } from '../client-details';
5
+ import { WebsocketReconnectStrategy } from '../gen/video/sfu/models/models';
5
6
  import { CameraManager, MicrophoneManager } from '../devices';
6
7
  import { CallState } from '../store';
7
- import { Telemetry } from '../gen/video/sfu/signal_rpc/signal';
8
8
  export type SfuStatsReporterOptions = {
9
9
  options: StatsOptions;
10
10
  clientDetails: LocalClientDetailsType;
@@ -32,7 +32,9 @@ export declare class SfuStatsReporter {
32
32
  private readonly inputDevices;
33
33
  constructor(sfuClient: StreamSfuClient, { options, clientDetails, subscriber, publisher, microphone, camera, state, }: SfuStatsReporterOptions);
34
34
  private observeDevice;
35
- sendTelemetryData: (telemetryData: Telemetry) => Promise<void>;
35
+ sendConnectionTime: (connectionTimeSeconds: number) => void;
36
+ sendReconnectionTime: (strategy: WebsocketReconnectStrategy, timeSeconds: number) => void;
37
+ private sendTelemetryData;
36
38
  private run;
37
39
  start: () => void;
38
40
  stop: () => void;
@@ -1,3 +1,3 @@
1
- export * from './stateStoreStatsReporter';
1
+ export * from './CallStateStatsReporter';
2
2
  export * from './SfuStatsReporter';
3
3
  export * from './types';
@@ -1,3 +1,4 @@
1
+ import { TrackType } from '../gen/video/sfu/models/models';
1
2
  export type BaseStats = {
2
3
  audioLevel?: number;
3
4
  bytesSent?: number;
@@ -9,9 +10,11 @@ export type BaseStats = {
9
10
  framesPerSecond?: number;
10
11
  jitter?: number;
11
12
  kind?: string;
13
+ mediaSourceId?: string;
12
14
  qualityLimitationReason?: string;
13
15
  rid?: string;
14
16
  ssrc?: number;
17
+ trackType?: TrackType;
15
18
  };
16
19
  export type StatsReport = {
17
20
  rawStats?: RTCStatsReport;
@@ -28,6 +31,7 @@ export type AggregatedStatsReport = {
28
31
  highestFrameHeight: number;
29
32
  highestFramesPerSecond: number;
30
33
  codec: string;
34
+ codecPerTrackType: Partial<Record<TrackType, string>>;
31
35
  timestamp: number;
32
36
  rawReport: StatsReport;
33
37
  };
@@ -43,3 +47,7 @@ export type CallStatsReport = {
43
47
  participants: ParticipantsStatsReport;
44
48
  timestamp: number;
45
49
  };
50
+ export interface RTCMediaSourceStats {
51
+ kind: string;
52
+ trackIdentifier: string;
53
+ }
@@ -124,7 +124,7 @@ export type SubscriptionChanges = {
124
124
  [sessionId: string]: SubscriptionChange;
125
125
  };
126
126
  /**
127
- * A preferred codec to use when publishing a video track.
127
+ * A preferred codec to use when publishing a video or audio track.
128
128
  * @internal
129
129
  */
130
130
  export type PreferredCodec = 'vp8' | 'h264' | 'vp9' | 'av1';
@@ -132,41 +132,31 @@ export type PreferredCodec = 'vp8' | 'h264' | 'vp9' | 'av1';
132
132
  * A collection of track publication options.
133
133
  * @internal
134
134
  */
135
- export type PublishOptions = {
135
+ export type ClientPublishOptions = {
136
136
  /**
137
137
  * The preferred codec to use when publishing the video stream.
138
138
  */
139
139
  preferredCodec?: PreferredCodec;
140
140
  /**
141
- * Force the codec to use when publishing the video stream.
142
- * This will override the preferred codec and the internal codec selection logic.
143
- * Use with caution.
141
+ * The fmtp line for the video codec.
144
142
  */
145
- forceCodec?: PreferredCodec;
146
- /**
147
- * When using a preferred codec, force the use of a single codec.
148
- * Enabling this, it will remove all other supported codecs from the SDP.
149
- * Defaults to false.
150
- */
151
- forceSingleCodec?: boolean;
152
- /**
153
- * The preferred scalability to use when publishing the video stream.
154
- * Applicable only for SVC codecs.
155
- */
156
- scalabilityMode?: string;
143
+ fmtpLine?: string;
157
144
  /**
158
145
  * The preferred bitrate to use when publishing the video stream.
159
146
  */
160
147
  preferredBitrate?: number;
161
- /**
162
- * The preferred downscale factor to use when publishing the video stream
163
- * in simulcast mode (non-SVC).
164
- */
165
- bitrateDownscaleFactor?: number;
166
148
  /**
167
149
  * The maximum number of simulcast layers to use when publishing the video stream.
168
150
  */
169
151
  maxSimulcastLayers?: number;
152
+ /**
153
+ * The preferred subscription (incoming video stream) codec.
154
+ */
155
+ subscriberCodec?: PreferredCodec;
156
+ /**
157
+ * The fmtp line for the subscriber codec.
158
+ */
159
+ subscriberFmtpLine?: string;
170
160
  /**
171
161
  * Screen share settings.
172
162
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",