@axonkit/client-sdk-js 0.1.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 (43) hide show
  1. package/LICENSE +85 -0
  2. package/README.md +125 -0
  3. package/dist/Room.d.ts +273 -0
  4. package/dist/axonkit-client.esm.js +1 -0
  5. package/dist/axonkit-client.umd.js +1 -0
  6. package/dist/connectionHelper/ConnectionCheck.d.ts +33 -0
  7. package/dist/data-stream/DataStreamManager.d.ts +65 -0
  8. package/dist/events.d.ts +432 -0
  9. package/dist/index.d.ts +41 -0
  10. package/dist/participant/LocalParticipant.d.ts +186 -0
  11. package/dist/participant/LocalTrackPublication.d.ts +28 -0
  12. package/dist/participant/Participant.d.ts +133 -0
  13. package/dist/participant/RemoteParticipant.d.ts +30 -0
  14. package/dist/participant/RemoteTrackPublication.d.ts +63 -0
  15. package/dist/protocol/errors.d.ts +22 -0
  16. package/dist/protocol/message.d.ts +30 -0
  17. package/dist/protocol/types.d.ts +522 -0
  18. package/dist/room/DefaultReconnectPolicy.d.ts +28 -0
  19. package/dist/room/options.d.ts +74 -0
  20. package/dist/rpc.d.ts +28 -0
  21. package/dist/signal/RPCClient.d.ts +28 -0
  22. package/dist/signal/SignalClient.d.ts +14 -0
  23. package/dist/stats/StatsCollector.d.ts +15 -0
  24. package/dist/track/LocalAudioTrack.d.ts +20 -0
  25. package/dist/track/LocalTrack.d.ts +108 -0
  26. package/dist/track/LocalVideoTrack.d.ts +35 -0
  27. package/dist/track/RemoteAudioTrack.d.ts +7 -0
  28. package/dist/track/RemoteTrack.d.ts +33 -0
  29. package/dist/track/RemoteVideoTrack.d.ts +31 -0
  30. package/dist/track/Track.d.ts +62 -0
  31. package/dist/track/create.d.ts +30 -0
  32. package/dist/track/options.d.ts +525 -0
  33. package/dist/track/processor/types.d.ts +49 -0
  34. package/dist/track/publishUtils.d.ts +14 -0
  35. package/dist/transport/TransportManager.d.ts +62 -0
  36. package/dist/types.d.ts +146 -0
  37. package/dist/utils/browser.d.ts +113 -0
  38. package/dist/utils/deviceFailure.d.ts +30 -0
  39. package/dist/utils/id.d.ts +1 -0
  40. package/dist/utils/logger.d.ts +39 -0
  41. package/dist/utils/typedEmitter.d.ts +24 -0
  42. package/dist/version.d.ts +2 -0
  43. package/package.json +80 -0
@@ -0,0 +1,525 @@
1
+ import type { TrackSource } from '../protocol/types';
2
+ /**
3
+ * Options for capturing video from a camera device.
4
+ */
5
+ export interface VideoCaptureOptions {
6
+ /**
7
+ * A ConstrainDOMString specifying a device ID or an array of device IDs
8
+ * which are acceptable and/or required.
9
+ */
10
+ deviceId?: ConstrainDOMString;
11
+ /**
12
+ * A ConstrainDouble specifying the frame rate or range of frame rates
13
+ * which are acceptable and/or required.
14
+ */
15
+ frameRate?: ConstrainDouble;
16
+ /**
17
+ * A facing or an array of facings which are acceptable and/or required.
18
+ */
19
+ facingMode?: 'user' | 'environment' | 'left' | 'right';
20
+ /**
21
+ * Target capture resolution.
22
+ */
23
+ resolution?: VideoResolution;
24
+ }
25
+ /**
26
+ * Video resolution descriptor.
27
+ */
28
+ export interface VideoResolution {
29
+ width: number;
30
+ height: number;
31
+ frameRate?: number;
32
+ aspectRatio?: number;
33
+ }
34
+ /**
35
+ * Options for capturing audio from a microphone device.
36
+ */
37
+ export interface AudioCaptureOptions {
38
+ /**
39
+ * Specifies whether automatic gain control is preferred and/or required.
40
+ */
41
+ autoGainControl?: ConstrainBoolean;
42
+ /**
43
+ * The channel count or range of channel counts which are acceptable
44
+ * and/or required.
45
+ */
46
+ channelCount?: ConstrainULong;
47
+ /**
48
+ * A ConstrainDOMString specifying a device ID or an array of device IDs
49
+ * which are acceptable and/or required.
50
+ */
51
+ deviceId?: ConstrainDOMString;
52
+ /**
53
+ * Whether or not echo cancellation is preferred and/or required.
54
+ */
55
+ echoCancellation?: ConstrainBoolean;
56
+ /**
57
+ * The latency or range of latencies which are acceptable and/or required.
58
+ */
59
+ latency?: ConstrainDouble;
60
+ /**
61
+ * Whether noise suppression is preferred and/or required.
62
+ */
63
+ noiseSuppression?: ConstrainBoolean;
64
+ /**
65
+ * @experimental
66
+ * A stronger version of `noiseSuppression`; browser support is not
67
+ * widespread yet. When set (and supported) the value for
68
+ * `noiseSuppression` will be ignored.
69
+ *
70
+ * @see https://w3c.github.io/mediacapture-extensions/#voiceisolation-constraint
71
+ */
72
+ voiceIsolation?: ConstrainBoolean;
73
+ /**
74
+ * The sample rate or range of sample rates which are acceptable
75
+ * and/or required.
76
+ */
77
+ sampleRate?: ConstrainULong;
78
+ /**
79
+ * The sample size or range of sample sizes which are acceptable
80
+ * and/or required.
81
+ */
82
+ sampleSize?: ConstrainULong;
83
+ }
84
+ /**
85
+ * Options for audio output device selection.
86
+ *
87
+ * Only supported on browsers where `setSinkId` is available.
88
+ */
89
+ export interface AudioOutputOptions {
90
+ /**
91
+ * Device ID to route audio output to.
92
+ */
93
+ deviceId?: string;
94
+ }
95
+ /**
96
+ * Options for capturing a screen share.
97
+ */
98
+ export interface ScreenShareCaptureOptions {
99
+ /**
100
+ * `true` to capture audio shared alongside the screen. Browser support for
101
+ * audio capturing in screen share is limited.
102
+ *
103
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#browser_compatibility
104
+ */
105
+ audio?: boolean | AudioCaptureOptions;
106
+ /**
107
+ * `true` to capture video. Chrome allows additional options.
108
+ *
109
+ * @see https://developer.chrome.com/docs/web-platform/screen-sharing-controls/#displaySurface
110
+ */
111
+ video?: true | {
112
+ displaySurface?: 'window' | 'browser' | 'monitor';
113
+ };
114
+ /**
115
+ * Capture resolution. Defaults to 1080 for most browsers.
116
+ */
117
+ resolution?: VideoResolution;
118
+ /**
119
+ * Target frame rate for the screen share capture.
120
+ */
121
+ frameRate?: number;
122
+ /**
123
+ * Specifies whether the browser should allow the user to select the
124
+ * current tab for capture.
125
+ */
126
+ selfBrowserSurface?: 'include' | 'exclude';
127
+ /**
128
+ * Specifies whether the browser should display a control to allow the user
129
+ * to dynamically switch the shared tab during screen-sharing.
130
+ */
131
+ surfaceSwitching?: 'include' | 'exclude';
132
+ /**
133
+ * Specifies whether the browser should include the system audio among the
134
+ * possible audio sources offered to the user.
135
+ */
136
+ systemAudio?: 'include' | 'exclude';
137
+ /**
138
+ * Specify the type of content.
139
+ *
140
+ * @see https://www.w3.org/TR/mst-content-hint/#video-content-hints
141
+ */
142
+ contentHint?: 'detail' | 'text' | 'motion';
143
+ /**
144
+ * @experimental
145
+ * Controls whether the audio playing in a tab will continue to be played
146
+ * out of a user's local speakers when the tab is captured.
147
+ */
148
+ suppressLocalAudioPlayback?: boolean;
149
+ /**
150
+ * @experimental
151
+ * Instructs the browser to offer the current tab as the most prominent
152
+ * capture source.
153
+ *
154
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#prefercurrenttab
155
+ */
156
+ preferCurrentTab?: boolean;
157
+ /**
158
+ * A CaptureController instance for further manipulation of the capture
159
+ * session if included.
160
+ */
161
+ controller?: unknown;
162
+ }
163
+ /**
164
+ * Video encoding parameters.
165
+ */
166
+ export interface VideoEncoding {
167
+ maxBitrate: number;
168
+ maxFramerate?: number;
169
+ priority?: RTCPriorityType;
170
+ }
171
+ /**
172
+ * Audio preset defining the maximum bitrate and optional priority.
173
+ */
174
+ export interface AudioPreset {
175
+ maxBitrate: number;
176
+ priority?: RTCPriorityType;
177
+ }
178
+ /**
179
+ * Options accepted by the {@link VideoPreset} constructor.
180
+ */
181
+ export interface VideoPresetOptions {
182
+ width: number;
183
+ height: number;
184
+ aspectRatio?: number;
185
+ maxBitrate: number;
186
+ maxFramerate?: number;
187
+ priority?: RTCPriorityType;
188
+ }
189
+ /**
190
+ * Encapsulates a video resolution together with its target encoding
191
+ * parameters. Used for simulcast layers and default presets.
192
+ */
193
+ export declare class VideoPreset {
194
+ encoding: VideoEncoding;
195
+ width: number;
196
+ height: number;
197
+ aspectRatio?: number;
198
+ constructor(options: VideoPresetOptions);
199
+ constructor(width: number, height: number, maxBitrate: number, maxFramerate?: number, priority?: RTCPriorityType);
200
+ /** Convenience getter that returns a {@link VideoResolution} from this preset. */
201
+ get resolution(): VideoResolution;
202
+ }
203
+ /** `red` is not technically a codec but treated as one in signalling. */
204
+ export declare const audioCodecs: readonly ["opus", "red"];
205
+ /** Audio codec identifier. */
206
+ export type AudioCodec = (typeof audioCodecs)[number];
207
+ declare const backupVideoCodecs: readonly ["vp8", "h264"];
208
+ /** All supported video codecs. */
209
+ export declare const videoCodecs: readonly ["vp8", "h264", "vp9", "av1", "h265"];
210
+ /** Video codec identifier. */
211
+ export type VideoCodec = (typeof videoCodecs)[number];
212
+ /** Subset of video codecs that can serve as a backup codec. */
213
+ export type BackupVideoCodec = (typeof backupVideoCodecs)[number];
214
+ /**
215
+ * Returns `true` if the given codec string is a valid backup video codec.
216
+ */
217
+ export declare function isBackupVideoCodec(codec: string): codec is BackupVideoCodec;
218
+ /**
219
+ * Policy for handling backup codec behaviour when the primary codec is an
220
+ * advanced codec (VP9 / AV1 / H265).
221
+ */
222
+ export declare enum BackupCodecPolicy {
223
+ /**
224
+ * Codec regression is preferred — the SFU will try to regress codec if
225
+ * possible but it is not guaranteed.
226
+ */
227
+ PREFER_REGRESSION = 0,
228
+ /** Multi-codec simulcast: publish both primary and backup codec simultaneously. */
229
+ SIMULCAST = 1,
230
+ /** Always use backup codec only. */
231
+ REGRESSION = 2
232
+ }
233
+ /**
234
+ * Scalability modes for SVC (Scalable Video Coding).
235
+ *
236
+ * @see https://www.w3.org/TR/webrtc-svc/#scalabilitymodes
237
+ */
238
+ export type ScalabilityMode = 'L1T1' | 'L1T2' | 'L1T3' | 'L2T1' | 'L2T1h' | 'L2T1_KEY' | 'L2T2' | 'L2T2h' | 'L2T2_KEY' | 'L2T3' | 'L2T3h' | 'L2T3_KEY' | 'L3T1' | 'L3T1h' | 'L3T1_KEY' | 'L3T2' | 'L3T2h' | 'L3T2_KEY' | 'L3T3' | 'L3T3h' | 'L3T3_KEY';
239
+ /**
240
+ * Codec-specific options that map to SDP `fmtp` parameters for the
241
+ * selected codec.
242
+ */
243
+ export interface PublishCodecOptions {
244
+ opusStereo?: boolean;
245
+ opusFec?: boolean;
246
+ opusDtx?: boolean;
247
+ opusMaxPlaybackRate?: number;
248
+ opusMaxAverageBitrate?: number;
249
+ opusPtime?: number;
250
+ opusNack?: boolean;
251
+ videoGoogleStartBitrate?: number;
252
+ videoGoogleMaxBitrate?: number;
253
+ videoGoogleMinBitrate?: number;
254
+ }
255
+ /**
256
+ * Default parameters applied when publishing a track. These can be set once
257
+ * on {@link RoomOptions.publishDefaults} and will be used for every subsequent
258
+ * publish call unless overridden per-track.
259
+ */
260
+ export interface TrackPublishDefaults {
261
+ /**
262
+ * Encoding parameters for camera track.
263
+ */
264
+ videoEncoding?: VideoEncoding;
265
+ /**
266
+ * Advanced codecs (VP9 / AV1 / H265) are not supported by all browser
267
+ * clients. When `backupCodec` is set and an incompatible client attempts
268
+ * to subscribe, the server will automatically publish a secondary track
269
+ * encoded with the backup codec.
270
+ *
271
+ * You can customize the encoding parameters of the backup track by
272
+ * explicitly setting codec and encoding fields.
273
+ *
274
+ * @defaultValue `true`
275
+ */
276
+ backupCodec?: true | false | {
277
+ codec: BackupVideoCodec;
278
+ encoding?: VideoEncoding;
279
+ };
280
+ /**
281
+ * Policy for deciding whether to send the primary codec at the same time
282
+ * as the backup codec.
283
+ *
284
+ * @see {@link BackupCodecPolicy}
285
+ */
286
+ backupCodecPolicy?: BackupCodecPolicy;
287
+ /**
288
+ * Encoding parameters for screen share tracks.
289
+ */
290
+ screenShareEncoding?: VideoEncoding;
291
+ /**
292
+ * Video codec, defaults to `'vp8'`. For SVC codecs, auto-enable `'vp8'`
293
+ * as backup.
294
+ */
295
+ videoCodec?: VideoCodec;
296
+ /**
297
+ * Which audio preset should be used for publishing audio tracks.
298
+ *
299
+ * @defaultValue {@link AudioPresets.music}
300
+ */
301
+ audioPreset?: AudioPreset;
302
+ /**
303
+ * DTX (Discontinuous Transmission of audio). Enabled by default for mono
304
+ * tracks.
305
+ */
306
+ dtx?: boolean;
307
+ /**
308
+ * RED (Redundant Encoding for audio). Enabled by default for mono tracks.
309
+ * When using stereo, RED is automatically disabled unless explicitly set.
310
+ */
311
+ red?: boolean;
312
+ /**
313
+ * Publish track in stereo mode (or set to `false` to disable). Default is
314
+ * determined by the capture channel count.
315
+ */
316
+ forceStereo?: boolean;
317
+ /**
318
+ * Use simulcast. Defaults to `true`.
319
+ *
320
+ * When using simulcast, the SDK will publish up to three versions of the
321
+ * stream at various resolutions.
322
+ */
323
+ simulcast?: boolean;
324
+ /**
325
+ * Scalability mode for SVC codecs, defaults to `'L3T3_KEY'`.
326
+ * When an SVC codec is used, simulcast is disabled.
327
+ */
328
+ scalabilityMode?: ScalabilityMode;
329
+ /**
330
+ * Degradation preference hint for the browser encoder.
331
+ */
332
+ degradationPreference?: RTCDegradationPreference;
333
+ /**
334
+ * Up to two additional simulcast layers to publish in addition to the
335
+ * original track.
336
+ *
337
+ * When left blank, it defaults to `[VideoPresets.h180, VideoPresets.h360]`.
338
+ * If an SVC codec is used (VP9 or AV1), this field has no effect.
339
+ *
340
+ * @example
341
+ * ```ts
342
+ * {
343
+ * videoEncoding: { maxBitrate: 1_700_000, maxFramerate: 30 },
344
+ * videoSimulcastLayers: [VideoPresets.h540, VideoPresets.h216],
345
+ * }
346
+ * ```
347
+ */
348
+ videoSimulcastLayers?: VideoPreset[];
349
+ /**
350
+ * Custom simulcast layers for screen share tracks.
351
+ *
352
+ * Note: layers should be ordered from lowest to highest quality.
353
+ */
354
+ screenShareSimulcastLayers?: VideoPreset[];
355
+ /**
356
+ * For local tracks, stop the underlying `MediaStreamTrack` when the track
357
+ * is muted (or paused). On some platforms this is necessary to disable the
358
+ * microphone recording indicator.
359
+ *
360
+ * Note: when enabled with Bluetooth devices connected, they will
361
+ * transition between profiles (e.g. HFP to A2DP) causing an audible
362
+ * difference in playback.
363
+ *
364
+ * @defaultValue `false`
365
+ */
366
+ stopMicTrackOnMute?: boolean;
367
+ /**
368
+ * Codec-specific options (SDP `fmtp` parameters) forwarded to the
369
+ * underlying transport layer.
370
+ *
371
+ * @see {@link PublishCodecOptions}
372
+ */
373
+ codecOptions?: PublishCodecOptions;
374
+ /**
375
+ * should local track be stopped when they are unpublished. defaults to false
376
+ * set this to true if you would prefer to clean up unpublished local track automatically.
377
+ */
378
+ stopTrackOnUnpublish?: boolean;
379
+ }
380
+ /**
381
+ * Options when publishing tracks. Extends {@link TrackPublishDefaults} with
382
+ * per-track metadata.
383
+ */
384
+ export interface TrackPublishOptions extends TrackPublishDefaults {
385
+ /**
386
+ * A human-readable name for the track.
387
+ */
388
+ name?: string;
389
+ /**
390
+ * Source of track — camera, microphone, or screen.
391
+ */
392
+ source?: TrackSource;
393
+ /**
394
+ * Set a stream name for the track. Audio and video tracks with the same
395
+ * stream name will be placed in the same `MediaStream` and offer better
396
+ * synchronisation.
397
+ *
398
+ * By default, camera and microphone are placed in one stream; screen share
399
+ * video and audio in another.
400
+ */
401
+ stream?: string;
402
+ /**
403
+ * Target audio bitrate in bits per second.
404
+ */
405
+ audioBitrate?: number;
406
+ }
407
+ /**
408
+ * Options for publishing data via a DataChannel.
409
+ */
410
+ export interface DataPublishOptions {
411
+ /** A human-readable name for the data track. */
412
+ name?: string;
413
+ /** DataChannel label. */
414
+ label?: string;
415
+ /** Whether messages should be delivered in order. */
416
+ ordered?: boolean;
417
+ /** Maximum number of retransmissions. */
418
+ maxRetransmits?: number;
419
+ /** Maximum packet lifetime in milliseconds. */
420
+ maxPacketLifeTime?: number;
421
+ }
422
+ /**
423
+ * Options accepted by {@link createLocalTracks}.
424
+ */
425
+ export interface CreateLocalTracksOptions {
426
+ /**
427
+ * Audio track options. `true` to create with defaults, `false` to skip.
428
+ *
429
+ * @defaultValue `true`
430
+ */
431
+ audio?: boolean | AudioCaptureOptions;
432
+ /**
433
+ * Video track options. `true` to create with defaults, `false` to skip.
434
+ *
435
+ * @defaultValue `true`
436
+ */
437
+ video?: boolean | VideoCaptureOptions;
438
+ }
439
+ /**
440
+ * Default camera capture options: 720p @ 30 fps.
441
+ */
442
+ export declare const defaultVideoCaptureOptions: VideoCaptureOptions;
443
+ /**
444
+ * Default microphone capture options with echo cancellation, noise
445
+ * suppression and automatic gain control enabled.
446
+ */
447
+ export declare const defaultAudioCaptureOptions: AudioCaptureOptions;
448
+ /**
449
+ * Default video encoding: 720p @ 30 fps, 1.7 Mbps.
450
+ */
451
+ export declare const defaultVideoEncoding: VideoEncoding;
452
+ /**
453
+ * Default screen share encoding: 1080p @ 30 fps, 3 Mbps.
454
+ */
455
+ export declare const defaultScreenShareEncoding: VideoEncoding;
456
+ /**
457
+ * Pre-defined audio encoding presets.
458
+ */
459
+ export declare const AudioPresets: {
460
+ /** 12 kbps — suitable for telephone-quality speech. */
461
+ readonly telephone: AudioPreset;
462
+ /** 24 kbps — good quality speech. */
463
+ readonly speech: AudioPreset;
464
+ /** 48 kbps — music quality (mono). */
465
+ readonly music: AudioPreset;
466
+ /** 64 kbps — music quality (stereo). */
467
+ readonly musicStereo: AudioPreset;
468
+ /** 96 kbps — high quality music (mono). */
469
+ readonly musicHighQuality: AudioPreset;
470
+ /** 128 kbps — high quality music (stereo). */
471
+ readonly musicHighQualityStereo: AudioPreset;
472
+ };
473
+ /**
474
+ * Pre-defined 16 : 9 video resolution / encoding presets.
475
+ */
476
+ export declare const VideoPresets: {
477
+ readonly h90: VideoPreset;
478
+ readonly h180: VideoPreset;
479
+ readonly h216: VideoPreset;
480
+ readonly h360: VideoPreset;
481
+ readonly h540: VideoPreset;
482
+ readonly h720: VideoPreset;
483
+ readonly h1080: VideoPreset;
484
+ readonly h1440: VideoPreset;
485
+ readonly h2160: VideoPreset;
486
+ };
487
+ /**
488
+ * Pre-defined 4 : 3 video resolution / encoding presets.
489
+ */
490
+ export declare const VideoPresets43: {
491
+ readonly h120: VideoPreset;
492
+ readonly h180: VideoPreset;
493
+ readonly h240: VideoPreset;
494
+ readonly h360: VideoPreset;
495
+ readonly h480: VideoPreset;
496
+ readonly h540: VideoPreset;
497
+ readonly h720: VideoPreset;
498
+ readonly h1080: VideoPreset;
499
+ readonly h1440: VideoPreset;
500
+ };
501
+ /**
502
+ * Pre-defined screen share resolution / encoding presets.
503
+ */
504
+ export declare const ScreenSharePresets: {
505
+ readonly h360fps3: VideoPreset;
506
+ readonly h360fps15: VideoPreset;
507
+ readonly h720fps5: VideoPreset;
508
+ readonly h720fps15: VideoPreset;
509
+ readonly h720fps30: VideoPreset;
510
+ readonly h1080fps15: VideoPreset;
511
+ readonly h1080fps30: VideoPreset;
512
+ /** Original resolution, no resizing applied. */
513
+ readonly original: VideoPreset;
514
+ };
515
+ /**
516
+ * Simulcast encoding presets used internally for building default
517
+ * simulcast layers.
518
+ */
519
+ export declare const videoSimulcastPresets: {
520
+ h180: VideoEncoding;
521
+ h360: VideoEncoding;
522
+ h720: VideoEncoding;
523
+ h1080: VideoEncoding;
524
+ };
525
+ export {};
@@ -0,0 +1,49 @@
1
+ import type { TrackKind } from '../../protocol/types';
2
+ /**
3
+ * Options provided to a track processor during initialization.
4
+ *
5
+ * @experimental
6
+ */
7
+ export interface ProcessorOptions<T extends TrackKind = TrackKind> {
8
+ kind: T;
9
+ track: MediaStreamTrack;
10
+ element?: HTMLMediaElement;
11
+ audioContext?: AudioContext;
12
+ }
13
+ /**
14
+ * A track processor transforms a `MediaStreamTrack` before publishing.
15
+ *
16
+ * Implementors must provide at least `init`, `restart`, and `destroy`.
17
+ * The SDK calls these methods at the appropriate lifecycle moments.
18
+ *
19
+ * After `init` (and `restart`), the processor MUST set `processedTrack`
20
+ * to the transformed output track. The SDK will publish this track instead
21
+ * of the original.
22
+ *
23
+ * @experimental
24
+ */
25
+ export interface TrackProcessor<T extends TrackKind = TrackKind> {
26
+ /** Human-readable processor name (for logging/debugging). */
27
+ name: string;
28
+ /**
29
+ * Initialize the processor with the given options. After this call,
30
+ * `processedTrack` must be set.
31
+ */
32
+ init: (opts: ProcessorOptions<T>) => Promise<void>;
33
+ /**
34
+ * Restart the processor (e.g. when the source track changes). The
35
+ * implementation should release old resources and re-initialize with the
36
+ * new options.
37
+ */
38
+ restart: (opts: ProcessorOptions<T>) => Promise<void>;
39
+ /**
40
+ * Destroy the processor and release all resources. After calling this,
41
+ * `processedTrack` should be `undefined`.
42
+ */
43
+ destroy: () => Promise<void>;
44
+ /**
45
+ * The transformed output track. Must be set after `init` / `restart`.
46
+ * The SDK publishes this track instead of the original source.
47
+ */
48
+ processedTrack?: MediaStreamTrack;
49
+ }
@@ -0,0 +1,14 @@
1
+ import type { TrackPublishOptions, VideoCodec, VideoEncoding } from './options';
2
+ import { TrackSource } from '../protocol/types';
3
+ export declare function isSVCCodec(codec?: string): boolean;
4
+ export declare function determineAppropriateEncoding(isScreenShare: boolean, width: number, height: number, codec?: VideoCodec): VideoEncoding;
5
+ /**
6
+ * Compute video encodings for publishing based on the current track source,
7
+ * dimensions, and publish options. Handles simulcast layers and SVC modes.
8
+ */
9
+ export declare function computeVideoEncodings(isScreenShare: boolean, width?: number, height?: number, options?: TrackPublishOptions): RTCRtpEncodingParameters[];
10
+ /**
11
+ * Returns the default degradation preference for a video track based on its
12
+ * source and resolution constraints.
13
+ */
14
+ export declare function getDefaultDegradationPreference(source: TrackSource, constraints?: MediaTrackConstraints): RTCDegradationPreference;
@@ -0,0 +1,62 @@
1
+ import * as mediasoupClient from 'mediasoup-client';
2
+ import { types as mediasoupTypes } from 'mediasoup-client';
3
+ import { TypedEmitter } from '../utils/typedEmitter';
4
+ import { SignalClient } from '../signal/SignalClient';
5
+ import type { JoinResponse, DtlsFingerprint, IceParameters } from '../protocol/types';
6
+ export type ProduceCallback = (params: {
7
+ kind: mediasoupTypes.MediaKind;
8
+ rtpParameters: mediasoupTypes.RtpParameters;
9
+ appData: Record<string, unknown>;
10
+ }, callback: (response: {
11
+ id: string;
12
+ }) => void, errback: (error: Error) => void) => void;
13
+ export type ProduceDataCallback = (params: {
14
+ sctpStreamParameters: mediasoupTypes.SctpStreamParameters;
15
+ label?: string;
16
+ protocol?: string;
17
+ appData: Record<string, unknown>;
18
+ }, callback: (response: {
19
+ id: string;
20
+ }) => void, errback: (error: Error) => void) => void;
21
+ export type TransportEvents = {
22
+ signalReady: (sendDC: mediasoupTypes.DataProducer, recvDC: mediasoupTypes.DataConsumer) => void;
23
+ connectionFailed: (direction: 'send' | 'recv') => void;
24
+ closed: () => void;
25
+ };
26
+ export declare class TransportManager extends TypedEmitter<TransportEvents> {
27
+ device: mediasoupClient.Device;
28
+ sendTransport: mediasoupTypes.Transport | null;
29
+ recvTransport: mediasoupTypes.Transport | null;
30
+ signalDataProducer: mediasoupTypes.DataProducer | null;
31
+ signalDataConsumer: mediasoupTypes.DataConsumer | null;
32
+ private url;
33
+ private signalClient;
34
+ private hasDtlsFingerprints;
35
+ private joinResponse;
36
+ private certificate;
37
+ private pendingProduceCallbacks;
38
+ private pendingProduceDataCallbacks;
39
+ constructor(signalClient: SignalClient);
40
+ registerProduceCallback(clientTrackId: string, cb: ProduceCallback): void;
41
+ registerProduceDataCallback(clientTrackId: string, cb: ProduceDataCallback): void;
42
+ generateCertificate(): Promise<DtlsFingerprint[]>;
43
+ getCertificate(): RTCCertificate | null;
44
+ /** Used when replacing TransportManager (full reconnect) so DTLS matches join fingerprints. */
45
+ setCertificate(cert: RTCCertificate | null): void;
46
+ getDtlsFingerprints(): DtlsFingerprint[];
47
+ setup(url: string, joinResponse: JoinResponse, hasDtlsFingerprints: boolean, rtcConfig?: RTCConfiguration): Promise<void>;
48
+ restartIce(iceParamsMap: Record<string, IceParameters>): Promise<void>;
49
+ /**
50
+ * Returns WebRTC stats for the send and/or receive transports.
51
+ */
52
+ getStats(): Promise<{
53
+ send?: RTCStatsReport;
54
+ recv?: RTCStatsReport;
55
+ }>;
56
+ close(): void;
57
+ private setupTransportEvents;
58
+ private connectTransports;
59
+ private setupSignalChannels;
60
+ private static readonly DC_OPEN_TIMEOUT;
61
+ private waitForDataChannelOpen;
62
+ }