livekit-client 1.4.4 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.esm.mjs +2478 -5368
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts +3 -2
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/connectionHelper/ConnectionCheck.d.ts +25 -0
- package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/Checker.d.ts +59 -0
- package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/publishAudio.d.ts +6 -0
- package/dist/src/connectionHelper/checks/publishAudio.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/publishVideo.d.ts +6 -0
- package/dist/src/connectionHelper/checks/publishVideo.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/reconnect.d.ts +6 -0
- package/dist/src/connectionHelper/checks/reconnect.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/turn.d.ts +6 -0
- package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/webrtc.d.ts +6 -0
- package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/websocket.d.ts +6 -0
- package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -0
- package/dist/src/index.d.ts +6 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logger.d.ts +3 -3
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/options.d.ts +4 -1
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.d.ts +4 -4
- package/dist/src/proto/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/src/proto/livekit_models.d.ts +4 -4
- package/dist/src/proto/livekit_models.d.ts.map +1 -1
- package/dist/src/proto/livekit_rtc.d.ts +12 -4
- package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
- package/dist/src/room/DeviceManager.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +4 -3
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +27 -4
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +9 -1
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +1 -1
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -0
- package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/Track.d.ts +2 -1
- package/dist/src/room/track/Track.d.ts.map +1 -1
- package/dist/src/room/track/TrackPublication.d.ts +1 -1
- package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +3 -3
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/types.d.ts +3 -3
- package/dist/src/room/track/types.d.ts.map +1 -1
- package/dist/src/room/types.d.ts +13 -0
- package/dist/src/room/types.d.ts.map +1 -0
- package/dist/src/room/utils.d.ts +44 -0
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +86 -0
- package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +25 -0
- package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +59 -0
- package/dist/ts4.2/src/connectionHelper/checks/publishAudio.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/publishVideo.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/reconnect.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/turn.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/webrtc.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/websocket.d.ts +6 -0
- package/dist/ts4.2/src/index.d.ts +31 -0
- package/dist/ts4.2/src/logger.d.ts +26 -0
- package/dist/ts4.2/src/options.d.ts +94 -0
- package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +141 -0
- package/dist/ts4.2/src/proto/livekit_models.d.ts +1421 -0
- package/dist/ts4.2/src/proto/livekit_rtc.d.ts +7122 -0
- package/dist/ts4.2/src/room/DefaultReconnectPolicy.d.ts +8 -0
- package/dist/ts4.2/src/room/DeviceManager.d.ts +9 -0
- package/dist/ts4.2/src/room/PCTransport.d.ts +33 -0
- package/dist/ts4.2/src/room/RTCEngine.d.ts +97 -0
- package/dist/ts4.2/src/room/ReconnectPolicy.d.ts +23 -0
- package/dist/ts4.2/src/room/Room.d.ts +220 -0
- package/dist/ts4.2/src/room/defaults.d.ts +8 -0
- package/dist/ts4.2/src/room/errors.d.ts +39 -0
- package/dist/ts4.2/src/room/events.d.ts +426 -0
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +141 -0
- package/dist/ts4.2/src/room/participant/Participant.d.ts +92 -0
- package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +52 -0
- package/dist/ts4.2/src/room/participant/publishUtils.d.ts +19 -0
- package/dist/ts4.2/src/room/stats.d.ts +67 -0
- package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +25 -0
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +42 -0
- package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +38 -0
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +53 -0
- package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +53 -0
- package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +15 -0
- package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +61 -0
- package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +52 -0
- package/dist/ts4.2/src/room/track/Track.d.ts +122 -0
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +68 -0
- package/dist/ts4.2/src/room/track/create.d.ts +24 -0
- package/dist/ts4.2/src/room/track/options.d.ts +241 -0
- package/dist/ts4.2/src/room/track/types.d.ts +23 -0
- package/dist/ts4.2/src/room/track/utils.d.ts +14 -0
- package/dist/ts4.2/src/room/types.d.ts +13 -0
- package/dist/ts4.2/src/room/utils.d.ts +79 -0
- package/dist/ts4.2/src/test/MockMediaStreamTrack.d.ts +26 -0
- package/dist/ts4.2/src/test/mocks.d.ts +11 -0
- package/dist/ts4.2/src/version.d.ts +3 -0
- package/package.json +32 -22
- package/src/api/SignalClient.ts +41 -17
- package/src/connectionHelper/ConnectionCheck.ts +90 -0
- package/src/connectionHelper/checks/Checker.ts +164 -0
- package/src/connectionHelper/checks/publishAudio.ts +33 -0
- package/src/connectionHelper/checks/publishVideo.ts +33 -0
- package/src/connectionHelper/checks/reconnect.ts +45 -0
- package/src/connectionHelper/checks/turn.ts +53 -0
- package/src/connectionHelper/checks/webrtc.ts +18 -0
- package/src/connectionHelper/checks/websocket.ts +22 -0
- package/src/index.ts +8 -1
- package/src/options.ts +5 -1
- package/src/proto/livekit_rtc.ts +12 -1
- package/src/room/DeviceManager.ts +0 -17
- package/src/room/RTCEngine.ts +35 -26
- package/src/room/Room.ts +231 -63
- package/src/room/events.ts +9 -0
- package/src/room/participant/LocalParticipant.ts +18 -11
- package/src/room/participant/publishUtils.ts +1 -1
- package/src/room/track/LocalAudioTrack.ts +1 -1
- package/src/room/track/LocalTrack.ts +4 -0
- package/src/room/track/LocalVideoTrack.ts +1 -1
- package/src/room/track/RemoteTrackPublication.ts +20 -0
- package/src/room/track/RemoteVideoTrack.ts +4 -0
- package/src/room/track/Track.ts +1 -0
- package/src/room/types.ts +12 -0
- package/src/room/utils.ts +150 -12
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { ReconnectContext, ReconnectPolicy } from './ReconnectPolicy';
|
2
|
+
declare class DefaultReconnectPolicy implements ReconnectPolicy {
|
3
|
+
private readonly _retryDelays;
|
4
|
+
constructor(retryDelays?: number[]);
|
5
|
+
nextRetryDelayInMs(context: ReconnectContext): number | null;
|
6
|
+
}
|
7
|
+
export default DefaultReconnectPolicy;
|
8
|
+
//# sourceMappingURL=DefaultReconnectPolicy.d.ts.map
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export default class DeviceManager {
|
2
|
+
private static instance?;
|
3
|
+
static mediaDeviceKinds: MediaDeviceKind[];
|
4
|
+
static getInstance(): DeviceManager;
|
5
|
+
static userMediaPromiseMap: Map<MediaDeviceKind, Promise<MediaStream>>;
|
6
|
+
getDevices(kind?: MediaDeviceKind, requestPermissions?: boolean): Promise<MediaDeviceInfo[]>;
|
7
|
+
normalizeDeviceId(kind: MediaDeviceKind, deviceId?: string, groupId?: string): Promise<string | undefined>;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=DeviceManager.d.ts.map
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/** @internal */
|
2
|
+
interface TrackBitrateInfo {
|
3
|
+
sid: string;
|
4
|
+
codec: string;
|
5
|
+
maxbr: number;
|
6
|
+
}
|
7
|
+
/** @internal */
|
8
|
+
export default class PCTransport {
|
9
|
+
pc: RTCPeerConnection;
|
10
|
+
pendingCandidates: RTCIceCandidateInit[];
|
11
|
+
restartingIce: boolean;
|
12
|
+
renegotiate: boolean;
|
13
|
+
trackBitrates: TrackBitrateInfo[];
|
14
|
+
remoteStereoMids: string[];
|
15
|
+
onOffer?: (offer: RTCSessionDescriptionInit) => void;
|
16
|
+
constructor(config?: RTCConfiguration);
|
17
|
+
get isICEConnected(): boolean;
|
18
|
+
addIceCandidate(candidate: RTCIceCandidateInit): Promise<void>;
|
19
|
+
setRemoteDescription(sd: RTCSessionDescriptionInit): Promise<void>;
|
20
|
+
negotiate: {
|
21
|
+
(this: unknown, ...args: [
|
22
|
+
onError?: ((e: Error) => void) | undefined
|
23
|
+
] & any[]): Promise<void>;
|
24
|
+
cancel: (reason?: any) => void;
|
25
|
+
};
|
26
|
+
createAndSendOffer(options?: RTCOfferOptions): Promise<void>;
|
27
|
+
createAndSetAnswer(): Promise<RTCSessionDescriptionInit>;
|
28
|
+
setTrackCodecBitrate(sid: string, codec: string, maxbr: number): void;
|
29
|
+
close(): void;
|
30
|
+
private setMungedLocalDescription;
|
31
|
+
}
|
32
|
+
export {};
|
33
|
+
//# sourceMappingURL=PCTransport.d.ts.map
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import type TypedEventEmitter from 'typed-emitter';
|
2
|
+
import { SignalClient, SignalOptions } from '../api/SignalClient';
|
3
|
+
import type { InternalRoomOptions } from '../options';
|
4
|
+
import { DataPacket, DataPacket_Kind, DisconnectReason, SpeakerInfo, TrackInfo, UserPacket } from '../proto/livekit_models';
|
5
|
+
import { AddTrackRequest, JoinResponse } from '../proto/livekit_rtc';
|
6
|
+
import PCTransport from './PCTransport';
|
7
|
+
import type LocalTrack from './track/LocalTrack';
|
8
|
+
import type LocalVideoTrack from './track/LocalVideoTrack';
|
9
|
+
import type { SimulcastTrackInfo } from './track/LocalVideoTrack';
|
10
|
+
import type { TrackPublishOptions } from './track/options';
|
11
|
+
declare const RTCEngine_base: new () => TypedEventEmitter<EngineEventCallbacks>;
|
12
|
+
/** @internal */
|
13
|
+
export default class RTCEngine extends RTCEngine_base {
|
14
|
+
private options;
|
15
|
+
publisher?: PCTransport;
|
16
|
+
subscriber?: PCTransport;
|
17
|
+
client: SignalClient;
|
18
|
+
rtcConfig: RTCConfiguration;
|
19
|
+
peerConnectionTimeout: number;
|
20
|
+
get isClosed(): boolean;
|
21
|
+
private lossyDC?;
|
22
|
+
private lossyDCSub?;
|
23
|
+
private reliableDC?;
|
24
|
+
private reliableDCSub?;
|
25
|
+
private subscriberPrimary;
|
26
|
+
private primaryPC?;
|
27
|
+
private pcState;
|
28
|
+
private _isClosed;
|
29
|
+
private pendingTrackResolvers;
|
30
|
+
private hasPublished;
|
31
|
+
private url?;
|
32
|
+
private token?;
|
33
|
+
private signalOpts?;
|
34
|
+
private reconnectAttempts;
|
35
|
+
private reconnectStart;
|
36
|
+
private fullReconnectOnNext;
|
37
|
+
private clientConfiguration?;
|
38
|
+
private connectedServerAddr?;
|
39
|
+
private attemptingReconnect;
|
40
|
+
private reconnectPolicy;
|
41
|
+
private reconnectTimeout?;
|
42
|
+
private participantSid?;
|
43
|
+
/** keeps track of how often an initial join connection has been tried */
|
44
|
+
private joinAttempts;
|
45
|
+
/** specifies how often an initial join connection is allowed to retry */
|
46
|
+
private maxJoinAttempts;
|
47
|
+
private closingLock;
|
48
|
+
constructor(options: InternalRoomOptions);
|
49
|
+
join(url: string, token: string, opts: SignalOptions, abortSignal?: AbortSignal): Promise<JoinResponse>;
|
50
|
+
close(): Promise<void>;
|
51
|
+
addTrack(req: AddTrackRequest): Promise<TrackInfo>;
|
52
|
+
removeTrack(sender: RTCRtpSender): void;
|
53
|
+
updateMuteStatus(trackSid: string, muted: boolean): void;
|
54
|
+
get dataSubscriberReadyState(): string | undefined;
|
55
|
+
get connectedServerAddress(): string | undefined;
|
56
|
+
private configure;
|
57
|
+
private createDataChannels;
|
58
|
+
private handleDataChannel;
|
59
|
+
private handleDataMessage;
|
60
|
+
private handleDataError;
|
61
|
+
private setPreferredCodec;
|
62
|
+
createSender(track: LocalTrack, opts: TrackPublishOptions, encodings?: RTCRtpEncodingParameters[]): Promise<RTCRtpSender>;
|
63
|
+
createSimulcastSender(track: LocalVideoTrack, simulcastTrack: SimulcastTrackInfo, opts: TrackPublishOptions, encodings?: RTCRtpEncodingParameters[]): Promise<RTCRtpSender | undefined>;
|
64
|
+
private createTransceiverRTCRtpSender;
|
65
|
+
private createSimulcastTransceiverSender;
|
66
|
+
private createRTCRtpSender;
|
67
|
+
private handleDisconnect;
|
68
|
+
private attemptReconnect;
|
69
|
+
private getNextRetryDelay;
|
70
|
+
private restartConnection;
|
71
|
+
private resumeConnection;
|
72
|
+
waitForPCConnected(): Promise<void>;
|
73
|
+
sendDataPacket(packet: DataPacket, kind: DataPacket_Kind): Promise<void>;
|
74
|
+
private ensurePublisherConnected;
|
75
|
+
/** @internal */
|
76
|
+
negotiate(): void;
|
77
|
+
dataChannelForKind(kind: DataPacket_Kind, sub?: boolean): RTCDataChannel | undefined;
|
78
|
+
private clearPendingReconnect;
|
79
|
+
private handleBrowserOnLine;
|
80
|
+
private registerOnLineListener;
|
81
|
+
private deregisterOnLineListener;
|
82
|
+
}
|
83
|
+
export type EngineEventCallbacks = {
|
84
|
+
connected: (joinResp: JoinResponse) => void;
|
85
|
+
disconnected: (reason?: DisconnectReason) => void;
|
86
|
+
resuming: () => void;
|
87
|
+
resumed: () => void;
|
88
|
+
restarting: () => void;
|
89
|
+
restarted: (joinResp: JoinResponse) => void;
|
90
|
+
signalResumed: () => void;
|
91
|
+
mediaTrackAdded: (track: MediaStreamTrack, streams: MediaStream, receiver?: RTCRtpReceiver) => void;
|
92
|
+
activeSpeakersUpdate: (speakers: Array<SpeakerInfo>) => void;
|
93
|
+
dataPacketReceived: (userPacket: UserPacket, kind: DataPacket_Kind) => void;
|
94
|
+
transportsCreated: (publisher: PCTransport, subscriber: PCTransport) => void;
|
95
|
+
};
|
96
|
+
export {};
|
97
|
+
//# sourceMappingURL=RTCEngine.d.ts.map
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/** Controls reconnecting of the client */
|
2
|
+
export interface ReconnectPolicy {
|
3
|
+
/** Called after disconnect was detected
|
4
|
+
*
|
5
|
+
* @returns {number | null} Amount of time in milliseconds to delay the next reconnect attempt, `null` signals to stop retrying.
|
6
|
+
*/
|
7
|
+
nextRetryDelayInMs(context: ReconnectContext): number | null;
|
8
|
+
}
|
9
|
+
export interface ReconnectContext {
|
10
|
+
/**
|
11
|
+
* Number of failed reconnect attempts
|
12
|
+
*/
|
13
|
+
readonly retryCount: number;
|
14
|
+
/**
|
15
|
+
* Elapsed amount of time in milliseconds since the disconnect.
|
16
|
+
*/
|
17
|
+
readonly elapsedMs: number;
|
18
|
+
/**
|
19
|
+
* Reason for retrying
|
20
|
+
*/
|
21
|
+
readonly retryReason?: Error;
|
22
|
+
}
|
23
|
+
//# sourceMappingURL=ReconnectPolicy.d.ts.map
|
@@ -0,0 +1,220 @@
|
|
1
|
+
import type TypedEmitter from 'typed-emitter';
|
2
|
+
import type { InternalRoomOptions, RoomConnectOptions, RoomOptions } from '../options';
|
3
|
+
import { DataPacket_Kind, DisconnectReason, ParticipantPermission } from '../proto/livekit_models';
|
4
|
+
import LocalParticipant from './participant/LocalParticipant';
|
5
|
+
import type Participant from './participant/Participant';
|
6
|
+
import type { ConnectionQuality } from './participant/Participant';
|
7
|
+
import RemoteParticipant from './participant/RemoteParticipant';
|
8
|
+
import RTCEngine from './RTCEngine';
|
9
|
+
import LocalTrackPublication from './track/LocalTrackPublication';
|
10
|
+
import type RemoteTrack from './track/RemoteTrack';
|
11
|
+
import RemoteTrackPublication from './track/RemoteTrackPublication';
|
12
|
+
import { Track } from './track/Track';
|
13
|
+
import type { TrackPublication } from './track/TrackPublication';
|
14
|
+
import type { SimulationOptions } from './types';
|
15
|
+
export declare enum ConnectionState {
|
16
|
+
Disconnected = "disconnected",
|
17
|
+
Connecting = "connecting",
|
18
|
+
Connected = "connected",
|
19
|
+
Reconnecting = "reconnecting"
|
20
|
+
}
|
21
|
+
/** @deprecated RoomState has been renamed to [[ConnectionState]] */
|
22
|
+
export declare const RoomState: typeof ConnectionState;
|
23
|
+
declare const Room_base: new () => TypedEmitter<RoomEventCallbacks>;
|
24
|
+
/**
|
25
|
+
* In LiveKit, a room is the logical grouping for a list of participants.
|
26
|
+
* Participants in a room can publish tracks, and subscribe to others' tracks.
|
27
|
+
*
|
28
|
+
* a Room fires [[RoomEvent | RoomEvents]].
|
29
|
+
*
|
30
|
+
* @noInheritDoc
|
31
|
+
*/
|
32
|
+
declare class Room extends Room_base {
|
33
|
+
state: ConnectionState;
|
34
|
+
/** map of sid: [[RemoteParticipant]] */
|
35
|
+
participants: Map<string, RemoteParticipant>;
|
36
|
+
/**
|
37
|
+
* list of participants that are actively speaking. when this changes
|
38
|
+
* a [[RoomEvent.ActiveSpeakersChanged]] event is fired
|
39
|
+
*/
|
40
|
+
activeSpeakers: Participant[];
|
41
|
+
/** @internal */
|
42
|
+
engine: RTCEngine;
|
43
|
+
/** server assigned unique room id */
|
44
|
+
sid: string;
|
45
|
+
/** user assigned name, derived from JWT token */
|
46
|
+
name: string;
|
47
|
+
/** the current participant */
|
48
|
+
localParticipant: LocalParticipant;
|
49
|
+
/** room metadata */
|
50
|
+
metadata: string | undefined;
|
51
|
+
/** options of room */
|
52
|
+
options: InternalRoomOptions;
|
53
|
+
private _isRecording;
|
54
|
+
private identityToSid;
|
55
|
+
/** connect options of room */
|
56
|
+
private connOptions?;
|
57
|
+
private audioEnabled;
|
58
|
+
private audioContext?;
|
59
|
+
/** used for aborting pending connections to a LiveKit server */
|
60
|
+
private abortController?;
|
61
|
+
/** future holding client initiated connection attempt */
|
62
|
+
private connectFuture?;
|
63
|
+
private disconnectLock;
|
64
|
+
/**
|
65
|
+
* Creates a new Room, the primary construct for a LiveKit session.
|
66
|
+
* @param options
|
67
|
+
*/
|
68
|
+
constructor(options?: RoomOptions);
|
69
|
+
private maybeCreateEngine;
|
70
|
+
/**
|
71
|
+
* getLocalDevices abstracts navigator.mediaDevices.enumerateDevices.
|
72
|
+
* In particular, it handles Chrome's unique behavior of creating `default`
|
73
|
+
* devices. When encountered, it'll be removed from the list of devices.
|
74
|
+
* The actual default device will be placed at top.
|
75
|
+
* @param kind
|
76
|
+
* @returns a list of available local devices
|
77
|
+
*/
|
78
|
+
static getLocalDevices(kind?: MediaDeviceKind, requestPermissions?: boolean): Promise<MediaDeviceInfo[]>;
|
79
|
+
/**
|
80
|
+
* prepares the connection to the livekit server by sending a HEAD request in order to
|
81
|
+
* 1. speed up DNS resolution
|
82
|
+
* 2. speed up TLS setup
|
83
|
+
* on the actual connection request
|
84
|
+
* throws an error if server is not reachable after the request timeout
|
85
|
+
* @experimental
|
86
|
+
*/
|
87
|
+
prepareConnection(url: string): Promise<void>;
|
88
|
+
connect: (url: string, token: string, opts?: RoomConnectOptions) => Promise<void>;
|
89
|
+
/**
|
90
|
+
* disconnects the room, emits [[RoomEvent.Disconnected]]
|
91
|
+
*/
|
92
|
+
disconnect: (stopTracks?: boolean) => Promise<void>;
|
93
|
+
/**
|
94
|
+
* retrieves a participant by identity
|
95
|
+
* @param identity
|
96
|
+
* @returns
|
97
|
+
*/
|
98
|
+
getParticipantByIdentity(identity: string): Participant | undefined;
|
99
|
+
private clearConnectionFutures;
|
100
|
+
/**
|
101
|
+
* if the current room has a participant with `recorder: true` in its JWT grant
|
102
|
+
**/
|
103
|
+
get isRecording(): boolean;
|
104
|
+
/**
|
105
|
+
* @internal for testing
|
106
|
+
*/
|
107
|
+
simulateScenario(scenario: string): Promise<void>;
|
108
|
+
private onBeforeUnload;
|
109
|
+
/**
|
110
|
+
* Browsers have different policies regarding audio playback. Most requiring
|
111
|
+
* some form of user interaction (click/tap/etc).
|
112
|
+
* In those cases, audio will be silent until a click/tap triggering one of the following
|
113
|
+
* - `startAudio`
|
114
|
+
* - `getUserMedia`
|
115
|
+
*/
|
116
|
+
startAudio(): Promise<void>;
|
117
|
+
/**
|
118
|
+
* Returns true if audio playback is enabled
|
119
|
+
*/
|
120
|
+
get canPlaybackAudio(): boolean;
|
121
|
+
/**
|
122
|
+
* Returns the active audio output device used in this room.
|
123
|
+
*
|
124
|
+
* Note: to get the active `audioinput` or `videoinput` use [[LocalTrack.getDeviceId()]]
|
125
|
+
*
|
126
|
+
* @return the previously successfully set audio output device ID or an empty string if the default device is used.
|
127
|
+
*/
|
128
|
+
getActiveAudioOutputDevice(): string;
|
129
|
+
/**
|
130
|
+
* Switches all active devices used in this room to the given device.
|
131
|
+
*
|
132
|
+
* Note: setting AudioOutput is not supported on some browsers. See [setSinkId](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId#browser_compatibility)
|
133
|
+
*
|
134
|
+
* @param kind use `videoinput` for camera track,
|
135
|
+
* `audioinput` for microphone track,
|
136
|
+
* `audiooutput` to set speaker for all incoming audio tracks
|
137
|
+
* @param deviceId
|
138
|
+
*/
|
139
|
+
switchActiveDevice(kind: MediaDeviceKind, deviceId: string): Promise<void>;
|
140
|
+
private setupLocalParticipantEvents;
|
141
|
+
private recreateEngine;
|
142
|
+
private onTrackAdded;
|
143
|
+
private handleRestarting;
|
144
|
+
private handleRestarted;
|
145
|
+
private handleDisconnect;
|
146
|
+
private handleParticipantUpdates;
|
147
|
+
private handleParticipantDisconnected;
|
148
|
+
private handleActiveSpeakersUpdate;
|
149
|
+
private handleSpeakersChanged;
|
150
|
+
private handleStreamStateUpdate;
|
151
|
+
private handleSubscriptionPermissionUpdate;
|
152
|
+
private handleDataPacket;
|
153
|
+
private handleAudioPlaybackStarted;
|
154
|
+
private handleAudioPlaybackFailed;
|
155
|
+
private handleDeviceChange;
|
156
|
+
private handleRoomUpdate;
|
157
|
+
private handleConnectionQualityUpdate;
|
158
|
+
private acquireAudioContext;
|
159
|
+
private createParticipant;
|
160
|
+
private getOrCreateParticipant;
|
161
|
+
private sendSyncState;
|
162
|
+
/**
|
163
|
+
* After resuming, we'll need to notify the server of the current
|
164
|
+
* subscription settings.
|
165
|
+
*/
|
166
|
+
private updateSubscriptions;
|
167
|
+
private setAndEmitConnectionState;
|
168
|
+
private emitWhenConnected;
|
169
|
+
private onLocalParticipantMetadataChanged;
|
170
|
+
private onLocalTrackMuted;
|
171
|
+
private onLocalTrackUnmuted;
|
172
|
+
private onLocalTrackPublished;
|
173
|
+
private onLocalTrackUnpublished;
|
174
|
+
private onLocalConnectionQualityChanged;
|
175
|
+
private onMediaDevicesError;
|
176
|
+
private onLocalParticipantPermissionsChanged;
|
177
|
+
/**
|
178
|
+
* Allows to populate a room with simulated participants.
|
179
|
+
* No actual connection to a server will be established, all state is
|
180
|
+
* @experimental
|
181
|
+
*/
|
182
|
+
simulateParticipants(options: SimulationOptions): void;
|
183
|
+
emit<E extends keyof RoomEventCallbacks>(event: E, ...args: Parameters<RoomEventCallbacks[E]>): boolean;
|
184
|
+
}
|
185
|
+
export default Room;
|
186
|
+
export type RoomEventCallbacks = {
|
187
|
+
connected: () => void;
|
188
|
+
reconnecting: () => void;
|
189
|
+
reconnected: () => void;
|
190
|
+
disconnected: (reason?: DisconnectReason) => void;
|
191
|
+
/** @deprecated stateChanged has been renamed to connectionStateChanged */
|
192
|
+
stateChanged: (state: ConnectionState) => void;
|
193
|
+
connectionStateChanged: (state: ConnectionState) => void;
|
194
|
+
mediaDevicesChanged: () => void;
|
195
|
+
participantConnected: (participant: RemoteParticipant) => void;
|
196
|
+
participantDisconnected: (participant: RemoteParticipant) => void;
|
197
|
+
trackPublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
198
|
+
trackSubscribed: (track: RemoteTrack, publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
199
|
+
trackSubscriptionFailed: (trackSid: string, participant: RemoteParticipant) => void;
|
200
|
+
trackUnpublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
201
|
+
trackUnsubscribed: (track: RemoteTrack, publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
202
|
+
trackMuted: (publication: TrackPublication, participant: Participant) => void;
|
203
|
+
trackUnmuted: (publication: TrackPublication, participant: Participant) => void;
|
204
|
+
localTrackPublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
|
205
|
+
localTrackUnpublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
|
206
|
+
participantMetadataChanged: (metadata: string | undefined, participant: RemoteParticipant | LocalParticipant) => void;
|
207
|
+
participantPermissionsChanged: (prevPermissions: ParticipantPermission, participant: RemoteParticipant | LocalParticipant) => void;
|
208
|
+
activeSpeakersChanged: (speakers: Array<Participant>) => void;
|
209
|
+
roomMetadataChanged: (metadata: string) => void;
|
210
|
+
dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacket_Kind) => void;
|
211
|
+
connectionQualityChanged: (quality: ConnectionQuality, participant: Participant) => void;
|
212
|
+
mediaDevicesError: (error: Error) => void;
|
213
|
+
trackStreamStateChanged: (publication: RemoteTrackPublication, streamState: Track.StreamState, participant: RemoteParticipant) => void;
|
214
|
+
trackSubscriptionPermissionChanged: (publication: RemoteTrackPublication, status: TrackPublication.PermissionStatus, participant: RemoteParticipant) => void;
|
215
|
+
trackSubscriptionStatusChanged: (publication: RemoteTrackPublication, status: TrackPublication.SubscriptionStatus, participant: RemoteParticipant) => void;
|
216
|
+
audioPlaybackChanged: (playing: boolean) => void;
|
217
|
+
signalConnected: () => void;
|
218
|
+
recordingStatusChanged: (recording: boolean) => void;
|
219
|
+
};
|
220
|
+
//# sourceMappingURL=Room.d.ts.map
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { InternalRoomConnectOptions, InternalRoomOptions } from '../options';
|
2
|
+
import { AudioCaptureOptions, TrackPublishDefaults, VideoCaptureOptions } from './track/options';
|
3
|
+
export declare const publishDefaults: TrackPublishDefaults;
|
4
|
+
export declare const audioDefaults: AudioCaptureOptions;
|
5
|
+
export declare const videoDefaults: VideoCaptureOptions;
|
6
|
+
export declare const roomOptionDefaults: InternalRoomOptions;
|
7
|
+
export declare const roomConnectOptionDefaults: InternalRoomConnectOptions;
|
8
|
+
//# sourceMappingURL=defaults.d.ts.map
|
@@ -0,0 +1,39 @@
|
|
1
|
+
export declare class LivekitError extends Error {
|
2
|
+
code: number;
|
3
|
+
constructor(code: number, message?: string);
|
4
|
+
}
|
5
|
+
export declare const enum ConnectionErrorReason {
|
6
|
+
NotAllowed = 0,
|
7
|
+
ServerUnreachable = 1,
|
8
|
+
InternalError = 2
|
9
|
+
}
|
10
|
+
export declare class ConnectionError extends LivekitError {
|
11
|
+
status?: number;
|
12
|
+
reason?: ConnectionErrorReason;
|
13
|
+
constructor(message?: string, reason?: ConnectionErrorReason, status?: number);
|
14
|
+
}
|
15
|
+
export declare class TrackInvalidError extends LivekitError {
|
16
|
+
constructor(message?: string);
|
17
|
+
}
|
18
|
+
export declare class UnsupportedServer extends LivekitError {
|
19
|
+
constructor(message?: string);
|
20
|
+
}
|
21
|
+
export declare class UnexpectedConnectionState extends LivekitError {
|
22
|
+
constructor(message?: string);
|
23
|
+
}
|
24
|
+
export declare class NegotiationError extends LivekitError {
|
25
|
+
constructor(message?: string);
|
26
|
+
}
|
27
|
+
export declare class PublishDataError extends LivekitError {
|
28
|
+
constructor(message?: string);
|
29
|
+
}
|
30
|
+
export declare enum MediaDeviceFailure {
|
31
|
+
PermissionDenied = "PermissionDenied",
|
32
|
+
NotFound = "NotFound",
|
33
|
+
DeviceInUse = "DeviceInUse",
|
34
|
+
Other = "Other"
|
35
|
+
}
|
36
|
+
export declare namespace MediaDeviceFailure {
|
37
|
+
function getFailure(error: any): MediaDeviceFailure | undefined;
|
38
|
+
}
|
39
|
+
//# sourceMappingURL=errors.d.ts.map
|