livekit-client 1.4.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/dist/livekit-client.esm.mjs +510 -38
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/connectionHelper/ConnectionCheck.d.ts +25 -0
  6. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -0
  7. package/dist/src/connectionHelper/checks/Checker.d.ts +59 -0
  8. package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -0
  9. package/dist/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  10. package/dist/src/connectionHelper/checks/publishAudio.d.ts.map +1 -0
  11. package/dist/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  12. package/dist/src/connectionHelper/checks/publishVideo.d.ts.map +1 -0
  13. package/dist/src/connectionHelper/checks/reconnect.d.ts +6 -0
  14. package/dist/src/connectionHelper/checks/reconnect.d.ts.map +1 -0
  15. package/dist/src/connectionHelper/checks/turn.d.ts +6 -0
  16. package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -0
  17. package/dist/src/connectionHelper/checks/webrtc.d.ts +6 -0
  18. package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -0
  19. package/dist/src/connectionHelper/checks/websocket.d.ts +6 -0
  20. package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -0
  21. package/dist/src/index.d.ts +3 -1
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/dist/src/proto/livekit_rtc.d.ts +8 -0
  24. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  25. package/dist/src/room/DeviceManager.d.ts.map +1 -1
  26. package/dist/src/room/Room.d.ts +6 -0
  27. package/dist/src/room/Room.d.ts.map +1 -1
  28. package/dist/src/room/events.d.ts +5 -1
  29. package/dist/src/room/events.d.ts.map +1 -1
  30. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  31. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  32. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -0
  33. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  34. package/dist/ts4.2/src/api/SignalClient.d.ts +85 -0
  35. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +25 -0
  36. package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +59 -0
  37. package/dist/ts4.2/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  38. package/dist/ts4.2/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  39. package/dist/ts4.2/src/connectionHelper/checks/reconnect.d.ts +6 -0
  40. package/dist/ts4.2/src/connectionHelper/checks/turn.d.ts +6 -0
  41. package/dist/ts4.2/src/connectionHelper/checks/webrtc.d.ts +6 -0
  42. package/dist/ts4.2/src/connectionHelper/checks/websocket.d.ts +6 -0
  43. package/dist/ts4.2/src/index.d.ts +30 -0
  44. package/dist/ts4.2/src/logger.d.ts +26 -0
  45. package/dist/ts4.2/src/options.d.ts +91 -0
  46. package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +141 -0
  47. package/dist/ts4.2/src/proto/livekit_models.d.ts +1421 -0
  48. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +7122 -0
  49. package/dist/ts4.2/src/room/DefaultReconnectPolicy.d.ts +8 -0
  50. package/dist/ts4.2/src/room/DeviceManager.d.ts +9 -0
  51. package/dist/ts4.2/src/room/PCTransport.d.ts +33 -0
  52. package/dist/ts4.2/src/room/RTCEngine.d.ts +96 -0
  53. package/dist/ts4.2/src/room/ReconnectPolicy.d.ts +23 -0
  54. package/dist/ts4.2/src/room/Room.d.ts +203 -0
  55. package/dist/ts4.2/src/room/defaults.d.ts +8 -0
  56. package/dist/ts4.2/src/room/errors.d.ts +39 -0
  57. package/dist/ts4.2/src/room/events.d.ts +422 -0
  58. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +141 -0
  59. package/dist/ts4.2/src/room/participant/Participant.d.ts +92 -0
  60. package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
  61. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +52 -0
  62. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +19 -0
  63. package/dist/ts4.2/src/room/stats.d.ts +67 -0
  64. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +25 -0
  65. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +42 -0
  66. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +38 -0
  67. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +53 -0
  68. package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +53 -0
  69. package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +15 -0
  70. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +61 -0
  71. package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +52 -0
  72. package/dist/ts4.2/src/room/track/Track.d.ts +121 -0
  73. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +68 -0
  74. package/dist/ts4.2/src/room/track/create.d.ts +24 -0
  75. package/dist/ts4.2/src/room/track/options.d.ts +241 -0
  76. package/dist/ts4.2/src/room/track/types.d.ts +23 -0
  77. package/dist/ts4.2/src/room/track/utils.d.ts +14 -0
  78. package/dist/ts4.2/src/room/utils.d.ts +35 -0
  79. package/dist/ts4.2/src/test/MockMediaStreamTrack.d.ts +26 -0
  80. package/dist/ts4.2/src/test/mocks.d.ts +11 -0
  81. package/dist/ts4.2/src/version.d.ts +3 -0
  82. package/package.json +13 -3
  83. package/src/api/SignalClient.ts +2 -2
  84. package/src/connectionHelper/ConnectionCheck.ts +90 -0
  85. package/src/connectionHelper/checks/Checker.ts +164 -0
  86. package/src/connectionHelper/checks/publishAudio.ts +33 -0
  87. package/src/connectionHelper/checks/publishVideo.ts +33 -0
  88. package/src/connectionHelper/checks/reconnect.ts +45 -0
  89. package/src/connectionHelper/checks/turn.ts +53 -0
  90. package/src/connectionHelper/checks/webrtc.ts +18 -0
  91. package/src/connectionHelper/checks/websocket.ts +22 -0
  92. package/src/index.ts +3 -1
  93. package/src/proto/livekit_rtc.ts +12 -1
  94. package/src/room/DeviceManager.ts +0 -17
  95. package/src/room/Room.ts +22 -2
  96. package/src/room/events.ts +5 -0
  97. package/src/room/participant/LocalParticipant.ts +15 -8
  98. package/src/room/track/LocalTrack.ts +3 -0
  99. package/src/room/track/RemoteTrackPublication.ts +20 -0
@@ -0,0 +1,52 @@
1
+ import type { SignalClient } from '../../api/SignalClient';
2
+ import type { ParticipantInfo } from '../../proto/livekit_models';
3
+ import type { AudioOutputOptions } from '../track/options';
4
+ import RemoteTrackPublication from '../track/RemoteTrackPublication';
5
+ import { Track } from '../track/Track';
6
+ import type { AdaptiveStreamSettings } from '../track/types';
7
+ import Participant, { ParticipantEventCallbacks } from './Participant';
8
+ export default class RemoteParticipant extends Participant {
9
+ audioTracks: Map<string, RemoteTrackPublication>;
10
+ videoTracks: Map<string, RemoteTrackPublication>;
11
+ tracks: Map<string, RemoteTrackPublication>;
12
+ signalClient: SignalClient;
13
+ private volume?;
14
+ private audioContext?;
15
+ private audioOutput?;
16
+ /** @internal */
17
+ static fromParticipantInfo(signalClient: SignalClient, pi: ParticipantInfo): RemoteParticipant;
18
+ /** @internal */
19
+ constructor(signalClient: SignalClient, sid: string, identity?: string, name?: string, metadata?: string);
20
+ protected addTrackPublication(publication: RemoteTrackPublication): void;
21
+ getTrack(source: Track.Source): RemoteTrackPublication | undefined;
22
+ getTrackByName(name: string): RemoteTrackPublication | undefined;
23
+ /**
24
+ * sets the volume on the participant's microphone track
25
+ * if no track exists the volume will be applied when the microphone track is added
26
+ */
27
+ setVolume(volume: number): void;
28
+ /**
29
+ * gets the volume on the participant's microphone track
30
+ */
31
+ getVolume(): number | undefined;
32
+ /** @internal */
33
+ addSubscribedMediaTrack(mediaTrack: MediaStreamTrack, sid: Track.SID, mediaStream: MediaStream, receiver?: RTCRtpReceiver, adaptiveStreamSettings?: AdaptiveStreamSettings, triesLeft?: number): RemoteTrackPublication | undefined;
34
+ /** @internal */
35
+ get hasMetadata(): boolean;
36
+ getTrackPublication(sid: Track.SID): RemoteTrackPublication | undefined;
37
+ /** @internal */
38
+ updateInfo(info: ParticipantInfo): void;
39
+ /** @internal */
40
+ unpublishTrack(sid: Track.SID, sendUnpublish?: boolean): void;
41
+ /**
42
+ * @internal
43
+ */
44
+ setAudioContext(ctx: AudioContext | undefined): void;
45
+ /**
46
+ * @internal
47
+ */
48
+ setAudioOutput(output: AudioOutputOptions): Promise<void>;
49
+ /** @internal */
50
+ emit<E extends keyof ParticipantEventCallbacks>(event: E, ...args: Parameters<ParticipantEventCallbacks[E]>): boolean;
51
+ }
52
+ //# sourceMappingURL=RemoteParticipant.d.ts.map
@@ -0,0 +1,19 @@
1
+ import LocalAudioTrack from '../track/LocalAudioTrack';
2
+ import LocalVideoTrack from '../track/LocalVideoTrack';
3
+ import { BackupVideoCodec, TrackPublishOptions, VideoCodec, VideoEncoding, VideoPreset } from '../track/options';
4
+ /** @internal */
5
+ export declare function mediaTrackToLocalTrack(mediaStreamTrack: MediaStreamTrack, constraints?: MediaTrackConstraints): LocalVideoTrack | LocalAudioTrack;
6
+ export declare const presets169: VideoPreset[];
7
+ export declare const presets43: VideoPreset[];
8
+ export declare const presetsScreenShare: VideoPreset[];
9
+ export declare const defaultSimulcastPresets169: VideoPreset[];
10
+ export declare const defaultSimulcastPresets43: VideoPreset[];
11
+ export declare const computeDefaultScreenShareSimulcastPresets: (fromPreset: VideoPreset) => VideoPreset[];
12
+ export declare function computeVideoEncodings(isScreenShare: boolean, width?: number, height?: number, options?: TrackPublishOptions): RTCRtpEncodingParameters[];
13
+ export declare function computeTrackBackupEncodings(track: LocalVideoTrack, videoCodec: BackupVideoCodec, opts: TrackPublishOptions): RTCRtpEncodingParameters[] | undefined;
14
+ export declare function determineAppropriateEncoding(isScreenShare: boolean, width: number, height: number, codec?: VideoCodec): VideoEncoding;
15
+ export declare function presetsForResolution(isScreenShare: boolean, width: number, height: number): VideoPreset[];
16
+ export declare function defaultSimulcastLayers(isScreenShare: boolean, original: VideoPreset): VideoPreset[];
17
+ /** @internal */
18
+ export declare function sortPresets(presets: Array<VideoPreset> | undefined): VideoPreset[] | undefined;
19
+ //# sourceMappingURL=publishUtils.d.ts.map
@@ -0,0 +1,67 @@
1
+ export declare const monitorFrequency = 2000;
2
+ interface SenderStats {
3
+ /** number of packets sent */
4
+ packetsSent?: number;
5
+ /** number of bytes sent */
6
+ bytesSent?: number;
7
+ /** jitter as perceived by remote */
8
+ jitter?: number;
9
+ /** packets reported lost by remote */
10
+ packetsLost?: number;
11
+ /** RTT reported by remote */
12
+ roundTripTime?: number;
13
+ /** ID of the outbound stream */
14
+ streamId?: string;
15
+ timestamp: number;
16
+ }
17
+ export interface AudioSenderStats extends SenderStats {
18
+ type: 'audio';
19
+ }
20
+ export interface VideoSenderStats extends SenderStats {
21
+ type: 'video';
22
+ firCount: number;
23
+ pliCount: number;
24
+ nackCount: number;
25
+ rid: string;
26
+ frameWidth: number;
27
+ frameHeight: number;
28
+ framesSent: number;
29
+ qualityLimitationReason: string;
30
+ qualityLimitationResolutionChanges: number;
31
+ retransmittedPacketsSent: number;
32
+ }
33
+ interface ReceiverStats {
34
+ jitterBufferDelay?: number;
35
+ /** packets reported lost by remote */
36
+ packetsLost?: number;
37
+ /** number of packets sent */
38
+ packetsReceived?: number;
39
+ bytesReceived?: number;
40
+ streamId?: string;
41
+ jitter?: number;
42
+ timestamp: number;
43
+ }
44
+ export interface AudioReceiverStats extends ReceiverStats {
45
+ type: 'audio';
46
+ concealedSamples?: number;
47
+ concealmentEvents?: number;
48
+ silentConcealedSamples?: number;
49
+ silentConcealmentEvents?: number;
50
+ totalAudioEnergy?: number;
51
+ totalSamplesDuration?: number;
52
+ }
53
+ export interface VideoReceiverStats extends ReceiverStats {
54
+ type: 'video';
55
+ framesDecoded: number;
56
+ framesDropped: number;
57
+ framesReceived: number;
58
+ frameWidth?: number;
59
+ frameHeight?: number;
60
+ firCount?: number;
61
+ pliCount?: number;
62
+ nackCount?: number;
63
+ decoderImplementation?: string;
64
+ }
65
+ export declare function computeBitrate<T extends ReceiverStats | SenderStats>(currentStats: T, prevStats?: T): number;
66
+ export {};
67
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { AudioSenderStats } from '../stats';
2
+ import LocalTrack from './LocalTrack';
3
+ import type { AudioCaptureOptions } from './options';
4
+ export default class LocalAudioTrack extends LocalTrack {
5
+ /** @internal */
6
+ stopOnMute: boolean;
7
+ private prevStats?;
8
+ /**
9
+ *
10
+ * @param mediaTrack
11
+ * @param constraints MediaTrackConstraints that are being used when restarting or reacquiring tracks
12
+ * @param userProvidedTrack Signals to the SDK whether or not the mediaTrack should be managed (i.e. released and reacquired) internally by the SDK
13
+ */
14
+ constructor(mediaTrack: MediaStreamTrack, constraints?: MediaTrackConstraints, userProvidedTrack?: boolean);
15
+ setDeviceId(deviceId: string): Promise<void>;
16
+ mute(): Promise<LocalAudioTrack>;
17
+ unmute(): Promise<LocalAudioTrack>;
18
+ restartTrack(options?: AudioCaptureOptions): Promise<void>;
19
+ protected restart(constraints?: MediaTrackConstraints): Promise<LocalTrack>;
20
+ startMonitor(): void;
21
+ protected monitorSender: () => Promise<void>;
22
+ getSenderStats(): Promise<AudioSenderStats | undefined>;
23
+ checkForSilence(): Promise<void>;
24
+ }
25
+ //# sourceMappingURL=LocalAudioTrack.d.ts.map
@@ -0,0 +1,42 @@
1
+ import Queue from 'async-await-queue';
2
+ import type { VideoCodec } from './options';
3
+ import { Track } from './Track';
4
+ export default abstract class LocalTrack extends Track {
5
+ /** @internal */
6
+ sender?: RTCRtpSender;
7
+ /** @internal */
8
+ codec?: VideoCodec;
9
+ protected constraints: MediaTrackConstraints;
10
+ protected reacquireTrack: boolean;
11
+ protected providedByUser: boolean;
12
+ protected muteQueue: Queue;
13
+ /**
14
+ *
15
+ * @param mediaTrack
16
+ * @param kind
17
+ * @param constraints MediaTrackConstraints that are being used when restarting or reacquiring tracks
18
+ * @param userProvidedTrack Signals to the SDK whether or not the mediaTrack should be managed (i.e. released and reacquired) internally by the SDK
19
+ */
20
+ protected constructor(mediaTrack: MediaStreamTrack, kind: Track.Kind, constraints?: MediaTrackConstraints, userProvidedTrack?: boolean);
21
+ get id(): string;
22
+ get dimensions(): Track.Dimensions | undefined;
23
+ private _isUpstreamPaused;
24
+ get isUpstreamPaused(): boolean;
25
+ get isUserProvided(): boolean;
26
+ /**
27
+ * @returns DeviceID of the device that is currently being used for this track
28
+ */
29
+ getDeviceId(): Promise<string | undefined>;
30
+ mute(): Promise<LocalTrack>;
31
+ unmute(): Promise<LocalTrack>;
32
+ replaceTrack(track: MediaStreamTrack, userProvidedTrack?: boolean): Promise<LocalTrack>;
33
+ protected restart(constraints?: MediaTrackConstraints): Promise<LocalTrack>;
34
+ protected setTrackMuted(muted: boolean): void;
35
+ protected get needsReAcquisition(): boolean;
36
+ protected handleAppVisibilityChanged(): Promise<void>;
37
+ private handleEnded;
38
+ pauseUpstream(): Promise<void>;
39
+ resumeUpstream(): Promise<void>;
40
+ protected abstract monitorSender(): void;
41
+ }
42
+ //# sourceMappingURL=LocalTrack.d.ts.map
@@ -0,0 +1,38 @@
1
+ import type { TrackInfo } from '../../proto/livekit_models';
2
+ import type LocalAudioTrack from './LocalAudioTrack';
3
+ import type LocalTrack from './LocalTrack';
4
+ import type LocalVideoTrack from './LocalVideoTrack';
5
+ import type { TrackPublishOptions } from './options';
6
+ import type { Track } from './Track';
7
+ import { TrackPublication } from './TrackPublication';
8
+ export default class LocalTrackPublication extends TrackPublication {
9
+ track?: LocalTrack;
10
+ options?: TrackPublishOptions;
11
+ get isUpstreamPaused(): boolean | undefined;
12
+ constructor(kind: Track.Kind, ti: TrackInfo, track?: LocalTrack);
13
+ setTrack(track?: Track): void;
14
+ get isMuted(): boolean;
15
+ get audioTrack(): LocalAudioTrack | undefined;
16
+ get videoTrack(): LocalVideoTrack | undefined;
17
+ /**
18
+ * Mute the track associated with this publication
19
+ */
20
+ mute(): Promise<LocalTrack | undefined>;
21
+ /**
22
+ * Unmute track associated with this publication
23
+ */
24
+ unmute(): Promise<LocalTrack | undefined>;
25
+ /**
26
+ * Pauses the media stream track associated with this publication from being sent to the server
27
+ * and signals "muted" event to other participants
28
+ * Useful if you want to pause the stream without pausing the local media stream track
29
+ */
30
+ pauseUpstream(): Promise<void>;
31
+ /**
32
+ * Resumes sending the media stream track associated with this publication to the server after a call to [[pauseUpstream()]]
33
+ * and signals "unmuted" event to other participants (unless the track is explicitly muted)
34
+ */
35
+ resumeUpstream(): Promise<void>;
36
+ handleTrackEnded: () => void;
37
+ }
38
+ //# sourceMappingURL=LocalTrackPublication.d.ts.map
@@ -0,0 +1,53 @@
1
+ import type { SignalClient } from '../../api/SignalClient';
2
+ import { VideoLayer, VideoQuality } from '../../proto/livekit_models';
3
+ import type { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc';
4
+ import { VideoSenderStats } from '../stats';
5
+ import LocalTrack from './LocalTrack';
6
+ import type { VideoCaptureOptions, VideoCodec } from './options';
7
+ export declare class SimulcastTrackInfo {
8
+ codec: VideoCodec;
9
+ mediaStreamTrack: MediaStreamTrack;
10
+ sender?: RTCRtpSender;
11
+ encodings?: RTCRtpEncodingParameters[];
12
+ constructor(codec: VideoCodec, mediaStreamTrack: MediaStreamTrack);
13
+ }
14
+ export default class LocalVideoTrack extends LocalTrack {
15
+ signalClient?: SignalClient;
16
+ private prevStats?;
17
+ private encodings?;
18
+ simulcastCodecs: Map<VideoCodec, SimulcastTrackInfo>;
19
+ private subscribedCodecs?;
20
+ /**
21
+ *
22
+ * @param mediaTrack
23
+ * @param constraints MediaTrackConstraints that are being used when restarting or reacquiring tracks
24
+ * @param userProvidedTrack Signals to the SDK whether or not the mediaTrack should be managed (i.e. released and reacquired) internally by the SDK
25
+ */
26
+ constructor(mediaTrack: MediaStreamTrack, constraints?: MediaTrackConstraints, userProvidedTrack?: boolean);
27
+ get isSimulcast(): boolean;
28
+ startMonitor(signalClient: SignalClient): void;
29
+ stop(): void;
30
+ mute(): Promise<LocalVideoTrack>;
31
+ unmute(): Promise<LocalVideoTrack>;
32
+ getSenderStats(): Promise<VideoSenderStats[]>;
33
+ setPublishingQuality(maxQuality: VideoQuality): void;
34
+ setDeviceId(deviceId: string): Promise<void>;
35
+ restartTrack(options?: VideoCaptureOptions): Promise<void>;
36
+ addSimulcastTrack(codec: VideoCodec, encodings?: RTCRtpEncodingParameters[]): SimulcastTrackInfo;
37
+ setSimulcastTrackSender(codec: VideoCodec, sender: RTCRtpSender): void;
38
+ /**
39
+ * @internal
40
+ * Sets codecs that should be publishing
41
+ */
42
+ setPublishingCodecs(codecs: SubscribedCodec[]): Promise<VideoCodec[]>;
43
+ /**
44
+ * @internal
45
+ * Sets layers that should be publishing
46
+ */
47
+ setPublishingLayers(qualities: SubscribedQuality[]): Promise<void>;
48
+ protected monitorSender: () => Promise<void>;
49
+ protected handleAppVisibilityChanged(): Promise<void>;
50
+ }
51
+ export declare function videoQualityForRid(rid: string): VideoQuality;
52
+ export declare function videoLayersFromEncodings(width: number, height: number, encodings?: RTCRtpEncodingParameters[]): VideoLayer[];
53
+ //# sourceMappingURL=LocalVideoTrack.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { AudioReceiverStats } from '../stats';
2
+ import type { AudioOutputOptions } from './options';
3
+ import RemoteTrack from './RemoteTrack';
4
+ export default class RemoteAudioTrack extends RemoteTrack {
5
+ private prevStats?;
6
+ private elementVolume;
7
+ private audioContext?;
8
+ private gainNode?;
9
+ private sourceNode?;
10
+ private webAudioPluginNodes;
11
+ private sinkId?;
12
+ constructor(mediaTrack: MediaStreamTrack, sid: string, receiver?: RTCRtpReceiver, audioContext?: AudioContext, audioOutput?: AudioOutputOptions);
13
+ /**
14
+ * sets the volume for all attached audio elements
15
+ */
16
+ setVolume(volume: number): void;
17
+ /**
18
+ * gets the volume of attached audio elements (loudest)
19
+ */
20
+ getVolume(): number;
21
+ /**
22
+ * calls setSinkId on all attached elements, if supported
23
+ * @param deviceId audio output device
24
+ */
25
+ setSinkId(deviceId: string): Promise<void>;
26
+ attach(): HTMLMediaElement;
27
+ attach(element: HTMLMediaElement): HTMLMediaElement;
28
+ /**
29
+ * Detaches from all attached elements
30
+ */
31
+ detach(): HTMLMediaElement[];
32
+ /**
33
+ * Detach from a single element
34
+ * @param element
35
+ */
36
+ detach(element: HTMLMediaElement): HTMLMediaElement;
37
+ /**
38
+ * @internal
39
+ * @experimental
40
+ */
41
+ setAudioContext(audioContext: AudioContext | undefined): void;
42
+ /**
43
+ * @internal
44
+ * @experimental
45
+ * @param {AudioNode[]} nodes - An array of WebAudio nodes. These nodes should not be connected to each other when passed, as the sdk will take care of connecting them in the order of the array.
46
+ */
47
+ setWebAudioPlugins(nodes: AudioNode[]): void;
48
+ private connectWebAudio;
49
+ private disconnectWebAudio;
50
+ protected monitorReceiver: () => Promise<void>;
51
+ protected getReceiverStats(): Promise<AudioReceiverStats | undefined>;
52
+ }
53
+ //# sourceMappingURL=RemoteAudioTrack.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { Track } from './Track';
2
+ export default abstract class RemoteTrack extends Track {
3
+ /** @internal */
4
+ receiver?: RTCRtpReceiver;
5
+ constructor(mediaTrack: MediaStreamTrack, sid: string, kind: Track.Kind, receiver?: RTCRtpReceiver);
6
+ /** @internal */
7
+ setMuted(muted: boolean): void;
8
+ /** @internal */
9
+ setMediaStream(stream: MediaStream): void;
10
+ start(): void;
11
+ stop(): void;
12
+ startMonitor(): void;
13
+ protected abstract monitorReceiver(): void;
14
+ }
15
+ //# sourceMappingURL=RemoteTrack.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { TrackInfo, VideoQuality } from '../../proto/livekit_models';
2
+ import type RemoteTrack from './RemoteTrack';
3
+ import type { Track } from './Track';
4
+ import { TrackPublication } from './TrackPublication';
5
+ export default class RemoteTrackPublication extends TrackPublication {
6
+ track?: RemoteTrack;
7
+ /** @internal */
8
+ protected allowed: boolean;
9
+ protected subscribed?: boolean;
10
+ protected disabled: boolean;
11
+ protected currentVideoQuality?: VideoQuality;
12
+ protected videoDimensions?: Track.Dimensions;
13
+ protected fps?: number;
14
+ constructor(kind: Track.Kind, id: string, name: string, autoSubscribe: boolean | undefined);
15
+ /**
16
+ * Subscribe or unsubscribe to this remote track
17
+ * @param subscribed true to subscribe to a track, false to unsubscribe
18
+ */
19
+ setSubscribed(subscribed: boolean): void;
20
+ get subscriptionStatus(): TrackPublication.SubscriptionStatus;
21
+ get permissionStatus(): TrackPublication.PermissionStatus;
22
+ /**
23
+ * Returns true if track is subscribed, and ready for playback
24
+ */
25
+ get isSubscribed(): boolean;
26
+ get isDesired(): boolean;
27
+ get isEnabled(): boolean;
28
+ /**
29
+ * disable server from sending down data for this track. this is useful when
30
+ * the participant is off screen, you may disable streaming down their video
31
+ * to reduce bandwidth requirements
32
+ * @param enabled
33
+ */
34
+ setEnabled(enabled: boolean): void;
35
+ /**
36
+ * for tracks that support simulcasting, adjust subscribed quality
37
+ *
38
+ * This indicates the highest quality the client can accept. if network
39
+ * bandwidth does not allow, server will automatically reduce quality to
40
+ * optimize for uninterrupted video
41
+ */
42
+ setVideoQuality(quality: VideoQuality): void;
43
+ setVideoDimensions(dimensions: Track.Dimensions): void;
44
+ setVideoFPS(fps: number): void;
45
+ get videoQuality(): VideoQuality | undefined;
46
+ /** @internal */
47
+ setTrack(track?: RemoteTrack): void;
48
+ /** @internal */
49
+ setAllowed(allowed: boolean): void;
50
+ /** @internal */
51
+ updateInfo(info: TrackInfo): void;
52
+ private emitSubscriptionUpdateIfChanged;
53
+ private emitPermissionUpdateIfChanged;
54
+ private isManualOperationAllowed;
55
+ protected handleEnded: (track: RemoteTrack) => void;
56
+ protected get isAdaptiveStream(): boolean;
57
+ protected handleVisibilityChange: (visible: boolean) => void;
58
+ protected handleVideoDimensionsChange: (dimensions: Track.Dimensions) => void;
59
+ emitTrackUpdate(): void;
60
+ }
61
+ //# sourceMappingURL=RemoteTrackPublication.d.ts.map
@@ -0,0 +1,52 @@
1
+ import RemoteTrack from './RemoteTrack';
2
+ import type { AdaptiveStreamSettings } from './types';
3
+ export default class RemoteVideoTrack extends RemoteTrack {
4
+ private prevStats?;
5
+ private elementInfos;
6
+ private adaptiveStreamSettings?;
7
+ private lastVisible?;
8
+ private lastDimensions?;
9
+ private hasUsedAttach;
10
+ constructor(mediaTrack: MediaStreamTrack, sid: string, receiver?: RTCRtpReceiver, adaptiveStreamSettings?: AdaptiveStreamSettings);
11
+ get isAdaptiveStream(): boolean;
12
+ get mediaStreamTrack(): MediaStreamTrack;
13
+ /** @internal */
14
+ setMuted(muted: boolean): void;
15
+ attach(): HTMLMediaElement;
16
+ attach(element: HTMLMediaElement): HTMLMediaElement;
17
+ /**
18
+ * Observe an ElementInfo for changes when adaptive streaming.
19
+ * @param elementInfo
20
+ * @internal
21
+ */
22
+ observeElementInfo(elementInfo: ElementInfo): void;
23
+ /**
24
+ * Stop observing an ElementInfo for changes.
25
+ * @param elementInfo
26
+ * @internal
27
+ */
28
+ stopObservingElementInfo(elementInfo: ElementInfo): void;
29
+ detach(): HTMLMediaElement[];
30
+ detach(element: HTMLMediaElement): HTMLMediaElement;
31
+ /** @internal */
32
+ getDecoderImplementation(): string | undefined;
33
+ protected monitorReceiver: () => Promise<void>;
34
+ private getReceiverStats;
35
+ private stopObservingElement;
36
+ protected handleAppVisibilityChanged(): Promise<void>;
37
+ private readonly debouncedHandleResize;
38
+ private updateVisibility;
39
+ private updateDimensions;
40
+ }
41
+ export interface ElementInfo {
42
+ element: object;
43
+ width(): number;
44
+ height(): number;
45
+ visible: boolean;
46
+ visibilityChangedAt: number | undefined;
47
+ handleResize?: () => void;
48
+ handleVisibilityChanged?: () => void;
49
+ observe(): void;
50
+ stopObserving(): void;
51
+ }
52
+ //# sourceMappingURL=RemoteVideoTrack.d.ts.map
@@ -0,0 +1,121 @@
1
+ import type TypedEventEmitter from 'typed-emitter';
2
+ import type { SignalClient } from '../../api/SignalClient';
3
+ import { TrackSource, TrackType } from '../../proto/livekit_models';
4
+ import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc';
5
+ declare const Track_base: new () => TypedEventEmitter<TrackEventCallbacks>;
6
+ export declare abstract class Track extends Track_base {
7
+ kind: Track.Kind;
8
+ attachedElements: HTMLMediaElement[];
9
+ isMuted: boolean;
10
+ source: Track.Source;
11
+ /**
12
+ * sid is set after track is published to server, or if it's a remote track
13
+ */
14
+ sid?: Track.SID;
15
+ /**
16
+ * @internal
17
+ */
18
+ mediaStream?: MediaStream;
19
+ /**
20
+ * indicates current state of stream
21
+ */
22
+ streamState: Track.StreamState;
23
+ protected _mediaStreamTrack: MediaStreamTrack;
24
+ protected _mediaStreamID: string;
25
+ protected isInBackground: boolean;
26
+ private backgroundTimeout;
27
+ protected _currentBitrate: number;
28
+ protected monitorInterval?: ReturnType<typeof setInterval>;
29
+ protected constructor(mediaTrack: MediaStreamTrack, kind: Track.Kind);
30
+ /** current receive bits per second */
31
+ get currentBitrate(): number;
32
+ get mediaStreamTrack(): MediaStreamTrack;
33
+ /**
34
+ * @internal
35
+ * used for keep mediaStream's first id, since it's id might change
36
+ * if we disable/enable a track
37
+ */
38
+ get mediaStreamID(): string;
39
+ /**
40
+ * creates a new HTMLAudioElement or HTMLVideoElement, attaches to it, and returns it
41
+ */
42
+ attach(): HTMLMediaElement;
43
+ /**
44
+ * attaches track to an existing HTMLAudioElement or HTMLVideoElement
45
+ */
46
+ attach(element: HTMLMediaElement): HTMLMediaElement;
47
+ /**
48
+ * Detaches from all attached elements
49
+ */
50
+ detach(): HTMLMediaElement[];
51
+ /**
52
+ * Detach from a single element
53
+ * @param element
54
+ */
55
+ detach(element: HTMLMediaElement): HTMLMediaElement;
56
+ stop(): void;
57
+ protected enable(): void;
58
+ protected disable(): void;
59
+ abstract startMonitor(signalClient?: SignalClient): void;
60
+ protected stopMonitor(): void;
61
+ private recycleElement;
62
+ protected appVisibilityChangedListener: () => void;
63
+ protected handleAppVisibilityChanged(): Promise<void>;
64
+ }
65
+ /** @internal */
66
+ export declare function attachToElement(track: MediaStreamTrack, element: HTMLMediaElement): void;
67
+ /** @internal */
68
+ export declare function detachTrack(track: MediaStreamTrack, element: HTMLMediaElement): void;
69
+ export declare namespace Track {
70
+ enum Kind {
71
+ Audio = "audio",
72
+ Video = "video",
73
+ Unknown = "unknown"
74
+ }
75
+ type SID = string;
76
+ enum Source {
77
+ Camera = "camera",
78
+ Microphone = "microphone",
79
+ ScreenShare = "screen_share",
80
+ ScreenShareAudio = "screen_share_audio",
81
+ Unknown = "unknown"
82
+ }
83
+ enum StreamState {
84
+ Active = "active",
85
+ Paused = "paused",
86
+ Unknown = "unknown"
87
+ }
88
+ interface Dimensions {
89
+ width: number;
90
+ height: number;
91
+ }
92
+ /** @internal */
93
+ function kindToProto(k: Kind): TrackType;
94
+ /** @internal */
95
+ function kindFromProto(t: TrackType): Kind | undefined;
96
+ /** @internal */
97
+ function sourceToProto(s: Source): TrackSource;
98
+ /** @internal */
99
+ function sourceFromProto(s: TrackSource): Source;
100
+ /** @internal */
101
+ function streamStateFromProto(s: ProtoStreamState): StreamState;
102
+ }
103
+ export declare type TrackEventCallbacks = {
104
+ message: () => void;
105
+ muted: (track?: any) => void;
106
+ unmuted: (track?: any) => void;
107
+ ended: (track?: any) => void;
108
+ updateSettings: () => void;
109
+ updateSubscription: () => void;
110
+ audioPlaybackStarted: () => void;
111
+ audioPlaybackFailed: (error: Error) => void;
112
+ audioSilenceDetected: () => void;
113
+ visibilityChanged: (visible: boolean, track?: any) => void;
114
+ videoDimensionsChanged: (dimensions: Track.Dimensions, track?: any) => void;
115
+ elementAttached: (element: HTMLMediaElement) => void;
116
+ elementDetached: (element: HTMLMediaElement) => void;
117
+ upstreamPaused: (track: any) => void;
118
+ upstreamResumed: (track: any) => void;
119
+ };
120
+ export {};
121
+ //# sourceMappingURL=Track.d.ts.map
@@ -0,0 +1,68 @@
1
+ import type TypedEventEmitter from 'typed-emitter';
2
+ import type { TrackInfo } from '../../proto/livekit_models';
3
+ import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc';
4
+ import LocalAudioTrack from './LocalAudioTrack';
5
+ import LocalVideoTrack from './LocalVideoTrack';
6
+ import RemoteAudioTrack from './RemoteAudioTrack';
7
+ import type RemoteTrack from './RemoteTrack';
8
+ import RemoteVideoTrack from './RemoteVideoTrack';
9
+ import { Track } from './Track';
10
+ declare const TrackPublication_base: new () => TypedEventEmitter<PublicationEventCallbacks>;
11
+ export declare class TrackPublication extends TrackPublication_base {
12
+ kind: Track.Kind;
13
+ trackName: string;
14
+ trackSid: Track.SID;
15
+ track?: Track;
16
+ source: Track.Source;
17
+ /** MimeType of the published track */
18
+ mimeType?: string;
19
+ /** dimension of the original published stream, video-only */
20
+ dimensions?: Track.Dimensions;
21
+ /** true if track was simulcasted to server, video-only */
22
+ simulcasted?: boolean;
23
+ /** @internal */
24
+ trackInfo?: TrackInfo;
25
+ protected metadataMuted: boolean;
26
+ constructor(kind: Track.Kind, id: string, name: string);
27
+ /** @internal */
28
+ setTrack(track?: Track): void;
29
+ get isMuted(): boolean;
30
+ get isEnabled(): boolean;
31
+ get isSubscribed(): boolean;
32
+ /**
33
+ * an [AudioTrack] if this publication holds an audio track
34
+ */
35
+ get audioTrack(): LocalAudioTrack | RemoteAudioTrack | undefined;
36
+ /**
37
+ * an [VideoTrack] if this publication holds a video track
38
+ */
39
+ get videoTrack(): LocalVideoTrack | RemoteVideoTrack | undefined;
40
+ handleMuted: () => void;
41
+ handleUnmuted: () => void;
42
+ /** @internal */
43
+ updateInfo(info: TrackInfo): void;
44
+ }
45
+ export declare namespace TrackPublication {
46
+ enum SubscriptionStatus {
47
+ Desired = "desired",
48
+ Subscribed = "subscribed",
49
+ Unsubscribed = "unsubscribed"
50
+ }
51
+ enum PermissionStatus {
52
+ Allowed = "allowed",
53
+ NotAllowed = "not_allowed"
54
+ }
55
+ }
56
+ export declare type PublicationEventCallbacks = {
57
+ muted: () => void;
58
+ unmuted: () => void;
59
+ ended: (track?: Track) => void;
60
+ updateSettings: (settings: UpdateTrackSettings) => void;
61
+ subscriptionPermissionChanged: (status: TrackPublication.PermissionStatus, prevStatus: TrackPublication.PermissionStatus) => void;
62
+ updateSubscription: (sub: UpdateSubscription) => void;
63
+ subscribed: (track: RemoteTrack) => void;
64
+ unsubscribed: (track: RemoteTrack) => void;
65
+ subscriptionStatusChanged: (status: TrackPublication.SubscriptionStatus, prevStatus: TrackPublication.SubscriptionStatus) => void;
66
+ };
67
+ export {};
68
+ //# sourceMappingURL=TrackPublication.d.ts.map