@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.
- package/LICENSE +85 -0
- package/README.md +125 -0
- package/dist/Room.d.ts +273 -0
- package/dist/axonkit-client.esm.js +1 -0
- package/dist/axonkit-client.umd.js +1 -0
- package/dist/connectionHelper/ConnectionCheck.d.ts +33 -0
- package/dist/data-stream/DataStreamManager.d.ts +65 -0
- package/dist/events.d.ts +432 -0
- package/dist/index.d.ts +41 -0
- package/dist/participant/LocalParticipant.d.ts +186 -0
- package/dist/participant/LocalTrackPublication.d.ts +28 -0
- package/dist/participant/Participant.d.ts +133 -0
- package/dist/participant/RemoteParticipant.d.ts +30 -0
- package/dist/participant/RemoteTrackPublication.d.ts +63 -0
- package/dist/protocol/errors.d.ts +22 -0
- package/dist/protocol/message.d.ts +30 -0
- package/dist/protocol/types.d.ts +522 -0
- package/dist/room/DefaultReconnectPolicy.d.ts +28 -0
- package/dist/room/options.d.ts +74 -0
- package/dist/rpc.d.ts +28 -0
- package/dist/signal/RPCClient.d.ts +28 -0
- package/dist/signal/SignalClient.d.ts +14 -0
- package/dist/stats/StatsCollector.d.ts +15 -0
- package/dist/track/LocalAudioTrack.d.ts +20 -0
- package/dist/track/LocalTrack.d.ts +108 -0
- package/dist/track/LocalVideoTrack.d.ts +35 -0
- package/dist/track/RemoteAudioTrack.d.ts +7 -0
- package/dist/track/RemoteTrack.d.ts +33 -0
- package/dist/track/RemoteVideoTrack.d.ts +31 -0
- package/dist/track/Track.d.ts +62 -0
- package/dist/track/create.d.ts +30 -0
- package/dist/track/options.d.ts +525 -0
- package/dist/track/processor/types.d.ts +49 -0
- package/dist/track/publishUtils.d.ts +14 -0
- package/dist/transport/TransportManager.d.ts +62 -0
- package/dist/types.d.ts +146 -0
- package/dist/utils/browser.d.ts +113 -0
- package/dist/utils/deviceFailure.d.ts +30 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/logger.d.ts +39 -0
- package/dist/utils/typedEmitter.d.ts +24 -0
- package/dist/version.d.ts +2 -0
- package/package.json +80 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Participant } from './Participant';
|
|
2
|
+
import { LocalTrackPublication } from './LocalTrackPublication';
|
|
3
|
+
import { LocalTrack } from '../track/LocalTrack';
|
|
4
|
+
import type { ParticipantTrackPermission, ParticipantInfo } from '../protocol/types';
|
|
5
|
+
import type { TrackPublishOptions, DataPublishOptions, AudioCaptureOptions, VideoCaptureOptions, ScreenShareCaptureOptions } from '../track/options';
|
|
6
|
+
import type { RoomOptions } from '../room/options';
|
|
7
|
+
import type { Message, SendTextOptions, StreamTextOptions, StreamBytesOptions, SendFileOptions, PerformRpcParams } from '../types';
|
|
8
|
+
import { TextStreamWriter, ByteStreamWriter } from '../data-stream/DataStreamManager';
|
|
9
|
+
export declare class LocalParticipant extends Participant<LocalTrackPublication> {
|
|
10
|
+
private rpc;
|
|
11
|
+
private transportManager;
|
|
12
|
+
private producers;
|
|
13
|
+
private dataProducers;
|
|
14
|
+
private dataStreamSender?;
|
|
15
|
+
private _lastCameraError?;
|
|
16
|
+
private _lastMicrophoneError?;
|
|
17
|
+
private participantTrackPermissions;
|
|
18
|
+
private allParticipantsAllowedToSubscribe;
|
|
19
|
+
/** Room-level options passed in from the Room instance. */
|
|
20
|
+
roomOptions?: RoomOptions;
|
|
21
|
+
get isLocal(): boolean;
|
|
22
|
+
/** Last error encountered while creating a camera track. */
|
|
23
|
+
get lastCameraError(): Error | undefined;
|
|
24
|
+
/** Last error encountered while creating a microphone track. */
|
|
25
|
+
get lastMicrophoneError(): Error | undefined;
|
|
26
|
+
setCameraEnabled(enabled: boolean, captureOptions?: VideoCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
|
|
27
|
+
setMicrophoneEnabled(enabled: boolean, captureOptions?: AudioCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
|
|
28
|
+
setScreenShareEnabled(enabled: boolean, captureOptions?: ScreenShareCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Enable both camera and microphone simultaneously.
|
|
31
|
+
* Uses a single `getUserMedia` call so the user only grants permission once.
|
|
32
|
+
*/
|
|
33
|
+
enableCameraAndMicrophone(captureOptions?: {
|
|
34
|
+
audio?: AudioCaptureOptions;
|
|
35
|
+
video?: VideoCaptureOptions;
|
|
36
|
+
}, publishOptions?: TrackPublishOptions): Promise<void>;
|
|
37
|
+
publishTrack(track: LocalTrack | MediaStreamTrack, options?: TrackPublishOptions): Promise<LocalTrackPublication>;
|
|
38
|
+
/**
|
|
39
|
+
* Unpublish a track from the room.
|
|
40
|
+
* @param track - The track or MediaStreamTrack to unpublish.
|
|
41
|
+
* @param stopOnUnpublish - Whether to stop the track after unpublishing.
|
|
42
|
+
* Defaults to `false`.
|
|
43
|
+
*/
|
|
44
|
+
unpublishTrack(track: LocalTrack | MediaStreamTrack): Promise<LocalTrackPublication | undefined>;
|
|
45
|
+
publishData(data: Uint8Array, options?: DataPublishOptions): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Sets and updates the metadata of the local participant.
|
|
48
|
+
* Note: this requires `canUpdateMetadata` permission.
|
|
49
|
+
*/
|
|
50
|
+
setMetadata(metadata: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Sets and updates the name of the local participant.
|
|
53
|
+
* Note: this requires `canUpdateMetadata` permission.
|
|
54
|
+
*/
|
|
55
|
+
setName(name: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Set or update participant attributes. It will make updates only to keys that
|
|
58
|
+
* are present in `attributes`, and will not override others.
|
|
59
|
+
* Note: this requires `canUpdateMetadata` permission.
|
|
60
|
+
*/
|
|
61
|
+
setAttributes(attributes: Record<string, string>): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Join a group (breakout room). The server will rewire subscriptions
|
|
64
|
+
* so that only participants in the same group exchange media.
|
|
65
|
+
* Permissions may change to the group-level permissions.
|
|
66
|
+
* @returns The list of other participants already in the group.
|
|
67
|
+
*/
|
|
68
|
+
joinGroup(groupId: string): Promise<ParticipantInfo[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Leave the current group and return to the main room.
|
|
71
|
+
* Permissions revert to room-level defaults.
|
|
72
|
+
*/
|
|
73
|
+
leaveGroup(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Control who can subscribe to LocalParticipant's published tracks.
|
|
76
|
+
*
|
|
77
|
+
* By default, all participants can subscribe. This allows fine-grained control over
|
|
78
|
+
* who is able to subscribe at a participant and track level.
|
|
79
|
+
*
|
|
80
|
+
* @param allParticipantsAllowed - Allows all participants to subscribe all tracks.
|
|
81
|
+
* Takes precedence over `participantTrackPermissions` if set to true.
|
|
82
|
+
* @param participantTrackPermissions - Full list of individual permissions per
|
|
83
|
+
* participant/track. Any omitted participants will not receive any permissions.
|
|
84
|
+
*/
|
|
85
|
+
setTrackSubscriptionPermissions(allParticipantsAllowed: boolean, participantTrackPermissions?: ParticipantTrackPermission[]): void;
|
|
86
|
+
private updateTrackSubscriptionPermissions;
|
|
87
|
+
/**
|
|
88
|
+
* Send a message to all participants in the room.
|
|
89
|
+
* @param text - The message text / payload.
|
|
90
|
+
* @param options - Optional settings such as `type`, `transient`, `topic`, etc.
|
|
91
|
+
*/
|
|
92
|
+
sendMessage(text: string, options?: SendTextOptions & {
|
|
93
|
+
type?: string;
|
|
94
|
+
transient?: boolean;
|
|
95
|
+
}): Promise<Message>;
|
|
96
|
+
/**
|
|
97
|
+
* Edit a previously sent message.
|
|
98
|
+
*/
|
|
99
|
+
editMessage(editText: string, originalMessage: Message): Promise<Message>;
|
|
100
|
+
/**
|
|
101
|
+
* Delete a single message by ID.
|
|
102
|
+
*/
|
|
103
|
+
deleteMessage(id: string): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Delete all messages of a given type.
|
|
106
|
+
*/
|
|
107
|
+
deleteMessagesByType(type: string): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Update a key in the room's shared state.
|
|
110
|
+
*/
|
|
111
|
+
updateRoomState(key: string, value: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Delete a key from the room's shared state.
|
|
114
|
+
*/
|
|
115
|
+
deleteRoomState(key: string): Promise<void>;
|
|
116
|
+
/** @deprecated Use {@link sendMessage} instead. */
|
|
117
|
+
sendChatMessage(text: string, options?: SendTextOptions): Promise<Message>;
|
|
118
|
+
/** @deprecated Use {@link editMessage} instead. */
|
|
119
|
+
editChatMessage(editText: string, originalMessage: Message): Promise<Message>;
|
|
120
|
+
/**
|
|
121
|
+
* Send a complete text message to participants via data stream.
|
|
122
|
+
*/
|
|
123
|
+
sendText(text: string, options?: SendTextOptions): Promise<{
|
|
124
|
+
id: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Open an incremental text stream to participants.
|
|
128
|
+
* Returns a writer that can be used to send text chunks.
|
|
129
|
+
*/
|
|
130
|
+
streamText(options?: StreamTextOptions): Promise<TextStreamWriter>;
|
|
131
|
+
/**
|
|
132
|
+
* Send a file to participants via data stream.
|
|
133
|
+
*/
|
|
134
|
+
sendFile(file: File, options?: SendFileOptions): Promise<{
|
|
135
|
+
id: string;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Open an incremental byte stream to participants.
|
|
139
|
+
* Returns a writer that can be used to send byte chunks.
|
|
140
|
+
*/
|
|
141
|
+
streamBytes(options?: StreamBytesOptions): Promise<ByteStreamWriter>;
|
|
142
|
+
/**
|
|
143
|
+
* Perform an RPC call to a specific remote participant.
|
|
144
|
+
* The remote participant must have registered a handler for the method
|
|
145
|
+
* via `room.registerRpcMethod`.
|
|
146
|
+
*
|
|
147
|
+
* @returns The response payload string.
|
|
148
|
+
*/
|
|
149
|
+
performRpc(params: PerformRpcParams): Promise<string>;
|
|
150
|
+
private buildCodecOptions;
|
|
151
|
+
/**
|
|
152
|
+
* Unpublish all tracks matching the given sources, or all tracks if no sources specified.
|
|
153
|
+
*/
|
|
154
|
+
unpublishTracks(tracks: LocalTrack[]): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Create local tracks without publishing. Useful for creating preview tracks.
|
|
157
|
+
*/
|
|
158
|
+
createTracks(options?: {
|
|
159
|
+
audio?: AudioCaptureOptions | boolean;
|
|
160
|
+
video?: VideoCaptureOptions | boolean;
|
|
161
|
+
}): Promise<LocalTrack[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Create screen share tracks without publishing.
|
|
164
|
+
*/
|
|
165
|
+
createScreenTracks(options?: ScreenShareCaptureOptions): Promise<LocalTrack[]>;
|
|
166
|
+
/**
|
|
167
|
+
* Re-publish all currently published tracks. Useful after a full reconnect
|
|
168
|
+
* or when changing publish options globally.
|
|
169
|
+
*
|
|
170
|
+
* The transportclose handler only clears `producers`, not
|
|
171
|
+
* `trackPublications`, so the publications are still available here even
|
|
172
|
+
* after the old transport has been closed.
|
|
173
|
+
*/
|
|
174
|
+
republishAllTracks(options?: TrackPublishOptions, restartTracks?: boolean): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Creates a second producer for the backup codec on an already-published
|
|
177
|
+
* video track. The new producer is registered on the server via
|
|
178
|
+
* `track.publishBackup` RPC.
|
|
179
|
+
*/
|
|
180
|
+
private publishAdditionalCodecForTrack;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Resolves the backup codec string from publish options.
|
|
184
|
+
* Returns the backup codec name or undefined if no backup is configured.
|
|
185
|
+
*/
|
|
186
|
+
export declare function resolveBackupCodec(opts: TrackPublishOptions): string | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TrackPublication } from './Participant';
|
|
2
|
+
import { AudioTrackFeature } from '../protocol/types';
|
|
3
|
+
import type { TrackPublishOptions } from '../track/options';
|
|
4
|
+
export declare class LocalTrackPublication extends TrackPublication {
|
|
5
|
+
/** The options used when publishing the track. */
|
|
6
|
+
options?: TrackPublishOptions;
|
|
7
|
+
get isLocal(): boolean;
|
|
8
|
+
get isMuted(): boolean;
|
|
9
|
+
/** Whether upstream publishing is paused for this track. */
|
|
10
|
+
get isUpstreamPaused(): boolean;
|
|
11
|
+
/** Mute the track associated with this publication. */
|
|
12
|
+
mute(): void;
|
|
13
|
+
/** Unmute the track associated with this publication. */
|
|
14
|
+
unmute(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Pause publishing to the server without disabling the local MediaStreamTrack.
|
|
17
|
+
*/
|
|
18
|
+
pauseUpstream(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Resume publishing after a call to {@link pauseUpstream}.
|
|
21
|
+
*/
|
|
22
|
+
resumeUpstream(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a list of audio track features detected from the current track settings.
|
|
25
|
+
* Only applicable to audio tracks.
|
|
26
|
+
*/
|
|
27
|
+
getTrackFeatures(): AudioTrackFeature[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { TypedEmitter } from '../utils/typedEmitter';
|
|
2
|
+
import type { ParticipantInfo, ParticipantPermission, TrackInfo, TrackSource } from '../protocol/types';
|
|
3
|
+
import { ConnectionQuality, ParticipantState, ParticipantKind, StreamState } from '../protocol/types';
|
|
4
|
+
import type { Track } from '../track/Track';
|
|
5
|
+
import type { LocalAudioTrack } from '../track/LocalAudioTrack';
|
|
6
|
+
import type { LocalVideoTrack } from '../track/LocalVideoTrack';
|
|
7
|
+
import type { RemoteAudioTrack } from '../track/RemoteAudioTrack';
|
|
8
|
+
import type { RemoteVideoTrack } from '../track/RemoteVideoTrack';
|
|
9
|
+
import { ParticipantEvent } from '../events';
|
|
10
|
+
import type { Message } from '../types';
|
|
11
|
+
/**
|
|
12
|
+
* Subscription status for a remote track publication.
|
|
13
|
+
*/
|
|
14
|
+
export declare enum SubscriptionStatus {
|
|
15
|
+
/** The track is desired but not yet subscribed. */
|
|
16
|
+
Desired = "desired",
|
|
17
|
+
/** The track is subscribed and a {@link Track} is available. */
|
|
18
|
+
Subscribed = "subscribed",
|
|
19
|
+
/** The track is not subscribed. */
|
|
20
|
+
Unsubscribed = "unsubscribed"
|
|
21
|
+
}
|
|
22
|
+
export declare class TrackPublication {
|
|
23
|
+
trackSid: string;
|
|
24
|
+
trackName: string;
|
|
25
|
+
kind: string;
|
|
26
|
+
source: TrackSource;
|
|
27
|
+
track?: Track;
|
|
28
|
+
muted: boolean;
|
|
29
|
+
info?: TrackInfo;
|
|
30
|
+
/** MIME type of the track (e.g. `video/VP8`, `audio/opus`). */
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
/** Whether the track was published with simulcast. */
|
|
33
|
+
simulcasted?: boolean;
|
|
34
|
+
/** Original video dimensions from the publisher. */
|
|
35
|
+
dimensions?: {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
constructor(init: {
|
|
40
|
+
trackSid: string;
|
|
41
|
+
trackName: string;
|
|
42
|
+
kind: string;
|
|
43
|
+
source: TrackSource;
|
|
44
|
+
track?: Track;
|
|
45
|
+
muted: boolean;
|
|
46
|
+
info?: TrackInfo;
|
|
47
|
+
});
|
|
48
|
+
/** Whether the track is subscribed (i.e. a concrete {@link Track} is available). */
|
|
49
|
+
get isSubscribed(): boolean;
|
|
50
|
+
/** Whether the track is enabled (not muted). */
|
|
51
|
+
get isEnabled(): boolean;
|
|
52
|
+
/** Whether the track is muted. */
|
|
53
|
+
get isMuted(): boolean;
|
|
54
|
+
/** Type-safe audio track getter. Returns `undefined` if the track is video. */
|
|
55
|
+
get audioTrack(): LocalAudioTrack | RemoteAudioTrack | undefined;
|
|
56
|
+
/** Type-safe video track getter. Returns `undefined` if the track is audio. */
|
|
57
|
+
get videoTrack(): LocalVideoTrack | RemoteVideoTrack | undefined;
|
|
58
|
+
/** Whether this publication belongs to the local participant. */
|
|
59
|
+
get isLocal(): boolean;
|
|
60
|
+
}
|
|
61
|
+
export type ParticipantEvents<TPublication extends TrackPublication = TrackPublication> = {
|
|
62
|
+
[ParticipantEvent.TrackPublished]: (publication: TPublication) => void;
|
|
63
|
+
[ParticipantEvent.TrackUnpublished]: (publication: TPublication) => void;
|
|
64
|
+
[ParticipantEvent.TrackMuted]: (publication: TPublication) => void;
|
|
65
|
+
[ParticipantEvent.TrackUnmuted]: (publication: TPublication) => void;
|
|
66
|
+
[ParticipantEvent.TrackSubscribed]: (track: Track, publication: TPublication) => void;
|
|
67
|
+
[ParticipantEvent.TrackUnsubscribed]: (track: Track, publication: TPublication) => void;
|
|
68
|
+
[ParticipantEvent.LocalTrackPublished]: (publication: TPublication) => void;
|
|
69
|
+
[ParticipantEvent.LocalTrackUnpublished]: (publication: TPublication) => void;
|
|
70
|
+
[ParticipantEvent.MetadataChanged]: (metadata: string | undefined, participant: Participant<TPublication>) => void;
|
|
71
|
+
[ParticipantEvent.NameChanged]: (name: string | undefined, participant: Participant<TPublication>) => void;
|
|
72
|
+
[ParticipantEvent.AttributesChanged]: (changedAttributes: Record<string, string>, participant: Participant<TPublication>) => void;
|
|
73
|
+
[ParticipantEvent.IsSpeakingChanged]: (speaking: boolean) => void;
|
|
74
|
+
[ParticipantEvent.ConnectionQualityChanged]: (quality: ConnectionQuality) => void;
|
|
75
|
+
[ParticipantEvent.PermissionsChanged]: (prevPermissions?: ParticipantPermission) => void;
|
|
76
|
+
[ParticipantEvent.TrackStreamStateChanged]: (publication: TPublication, streamState: StreamState) => void;
|
|
77
|
+
[ParticipantEvent.DataReceived]: (data: ArrayBuffer) => void;
|
|
78
|
+
[ParticipantEvent.ChatMessage]: (message: Message) => void;
|
|
79
|
+
};
|
|
80
|
+
export declare abstract class Participant<TPublication extends TrackPublication = TrackPublication> extends TypedEmitter<ParticipantEvents<TPublication>> {
|
|
81
|
+
sid: string;
|
|
82
|
+
identity: string;
|
|
83
|
+
name?: string;
|
|
84
|
+
metadata?: string;
|
|
85
|
+
state: ParticipantState;
|
|
86
|
+
isSpeaking: boolean;
|
|
87
|
+
audioLevel: number;
|
|
88
|
+
attributes: Record<string, string>;
|
|
89
|
+
permissions?: ParticipantPermission;
|
|
90
|
+
/** The group (breakout room) this participant is currently in. `undefined` = main room. */
|
|
91
|
+
groupId?: string;
|
|
92
|
+
trackPublications: Map<string, TPublication>;
|
|
93
|
+
audioTrackPublications: Map<string, TPublication>;
|
|
94
|
+
videoTrackPublications: Map<string, TPublication>;
|
|
95
|
+
lastSpokeAt?: Date;
|
|
96
|
+
joinedAt?: Date;
|
|
97
|
+
private _connectionQuality;
|
|
98
|
+
private _kind;
|
|
99
|
+
private _activeResolvers;
|
|
100
|
+
private emitParticipantEvent;
|
|
101
|
+
constructor(sid: string, identity: string, name?: string, metadata?: string);
|
|
102
|
+
abstract get isLocal(): boolean;
|
|
103
|
+
/** The kind of participant (Standard, Agent, etc.). */
|
|
104
|
+
get kind(): ParticipantKind;
|
|
105
|
+
/** Whether this participant is an AI agent. */
|
|
106
|
+
get isAgent(): boolean;
|
|
107
|
+
/** Whether the participant is in an active (joined) state. */
|
|
108
|
+
get isActive(): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Returns a promise that resolves once the participant is active
|
|
111
|
+
* and ready to receive data messages.
|
|
112
|
+
*/
|
|
113
|
+
waitUntilActive(): Promise<void>;
|
|
114
|
+
/** Current connection quality for this participant. */
|
|
115
|
+
get connectionQuality(): ConnectionQuality;
|
|
116
|
+
/** Whether the participant has an enabled camera track. */
|
|
117
|
+
get isCameraEnabled(): boolean;
|
|
118
|
+
/** Whether the participant has an enabled microphone track. */
|
|
119
|
+
get isMicrophoneEnabled(): boolean;
|
|
120
|
+
/** Whether the participant is sharing their screen. */
|
|
121
|
+
get isScreenShareEnabled(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Returns all track publications as an array.
|
|
124
|
+
*/
|
|
125
|
+
getTrackPublications(): TPublication[];
|
|
126
|
+
updateFromInfo(info: ParticipantInfo): void;
|
|
127
|
+
getTrackPublication(source: TrackSource): TPublication | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Find a track publication by its name.
|
|
130
|
+
*/
|
|
131
|
+
getTrackPublicationByName(name: string): TPublication | undefined;
|
|
132
|
+
private isTrackEnabled;
|
|
133
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Participant } from './Participant';
|
|
2
|
+
import { RemoteTrackPublication } from './RemoteTrackPublication';
|
|
3
|
+
import { TransportManager } from '../transport/TransportManager';
|
|
4
|
+
import { RPCClient } from '../signal/RPCClient';
|
|
5
|
+
import { type DataStreamReceiver } from '../data-stream/DataStreamManager';
|
|
6
|
+
export interface RemoteParticipantOptions {
|
|
7
|
+
transportManager: TransportManager;
|
|
8
|
+
rpc: RPCClient;
|
|
9
|
+
autoSubscribe?: boolean;
|
|
10
|
+
streamReceiver?: DataStreamReceiver;
|
|
11
|
+
}
|
|
12
|
+
export declare class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
|
13
|
+
private transportManager;
|
|
14
|
+
private rpc;
|
|
15
|
+
private consumers;
|
|
16
|
+
private dataConsumers;
|
|
17
|
+
private streamReceiver?;
|
|
18
|
+
private autoSubscribe;
|
|
19
|
+
get isLocal(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Set the output volume for all audio tracks from this participant.
|
|
22
|
+
* @param volume - Value between 0 and 1.
|
|
23
|
+
*/
|
|
24
|
+
setVolume(volume: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get the current output volume for this participant's audio tracks.
|
|
27
|
+
* Returns the volume of the first audio track, or 1 if none.
|
|
28
|
+
*/
|
|
29
|
+
getVolume(): number;
|
|
30
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TrackPublication, SubscriptionStatus } from './Participant';
|
|
2
|
+
import { VideoQuality, StreamState } from '../protocol/types';
|
|
3
|
+
export declare class RemoteTrackPublication extends TrackPublication {
|
|
4
|
+
streamState: StreamState;
|
|
5
|
+
private _consumer?;
|
|
6
|
+
private _rpc?;
|
|
7
|
+
private _subscribed;
|
|
8
|
+
private _videoQuality?;
|
|
9
|
+
private _enabled;
|
|
10
|
+
private _fps?;
|
|
11
|
+
private _requestedVideoDimensions?;
|
|
12
|
+
/** Whether this track is currently subscribed. */
|
|
13
|
+
get isSubscribed(): boolean;
|
|
14
|
+
/** Returns `true` if the client wants to subscribe to this track. */
|
|
15
|
+
get isDesired(): boolean;
|
|
16
|
+
/** Current subscription status. */
|
|
17
|
+
get subscriptionStatus(): SubscriptionStatus;
|
|
18
|
+
/** The currently requested video quality. */
|
|
19
|
+
get videoQuality(): VideoQuality | undefined;
|
|
20
|
+
/** Whether the server is enabled to send data for this track. */
|
|
21
|
+
get isEnabled(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Enable or disable the server from sending data for this track.
|
|
24
|
+
* Useful when a track is off-screen.
|
|
25
|
+
*/
|
|
26
|
+
setEnabled(enabled: boolean): void;
|
|
27
|
+
/**
|
|
28
|
+
* Control whether the subscription for this track is desired.
|
|
29
|
+
* When set to `false`, the server will stop sending media for this track.
|
|
30
|
+
*/
|
|
31
|
+
setSubscribed(subscribed: boolean): void;
|
|
32
|
+
/**
|
|
33
|
+
* Set the preferred video quality for this subscription.
|
|
34
|
+
* Only applicable to video tracks.
|
|
35
|
+
*/
|
|
36
|
+
setVideoQuality(quality: VideoQuality): void;
|
|
37
|
+
/**
|
|
38
|
+
* Explicitly set the desired video dimensions for this track.
|
|
39
|
+
* Maps to spatialLayer using {@link TrackInfo} width/height as the high layer
|
|
40
|
+
* and typical simulcast factors (1/2, 1/4) when layer metadata is not on the wire.
|
|
41
|
+
*/
|
|
42
|
+
setVideoDimensions(dimensions: {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}): void;
|
|
46
|
+
/**
|
|
47
|
+
* Set the desired video FPS for this subscription.
|
|
48
|
+
* In simulcast and SVC scenarios, fps controls the temporal layer.
|
|
49
|
+
*/
|
|
50
|
+
setVideoFPS(fps: number): void;
|
|
51
|
+
private isManualOperationAllowed;
|
|
52
|
+
/**
|
|
53
|
+
* Sends the current preferred layers to the server.
|
|
54
|
+
* Computes spatialLayer from videoQuality or dimensions, and temporalLayer from fps.
|
|
55
|
+
*/
|
|
56
|
+
private emitTrackUpdate;
|
|
57
|
+
/**
|
|
58
|
+
* Pick the smallest spatial layer whose notional size covers the request.
|
|
59
|
+
* Uses published track dimensions as the full layer; derives low/medium like
|
|
60
|
+
* LiveKit's videoLayersFromEncodings (ceil half / quarter) when only width/height exist.
|
|
61
|
+
*/
|
|
62
|
+
private spatialLayerForDimensions;
|
|
63
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare enum ErrorCode {
|
|
2
|
+
OK = 200,
|
|
3
|
+
BadRequest = 400,
|
|
4
|
+
Unauthorized = 401,
|
|
5
|
+
Forbidden = 403,
|
|
6
|
+
NotFound = 404,
|
|
7
|
+
Conflict = 409,
|
|
8
|
+
InternalError = 500
|
|
9
|
+
}
|
|
10
|
+
export declare class AxonError extends Error {
|
|
11
|
+
code: ErrorCode;
|
|
12
|
+
logId?: string;
|
|
13
|
+
constructor(code: ErrorCode, message: string, logId?: string);
|
|
14
|
+
static fromStatus(status: number, message: string, logId?: string): AxonError;
|
|
15
|
+
}
|
|
16
|
+
export declare class ConnectionError extends Error {
|
|
17
|
+
status?: number;
|
|
18
|
+
constructor(message: string, status?: number);
|
|
19
|
+
}
|
|
20
|
+
export declare class TimeoutError extends Error {
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axon Protocol message encoder/decoder.
|
|
3
|
+
*
|
|
4
|
+
* Wire format (text-based, binary-safe body):
|
|
5
|
+
* Request: REQ <method> <logId>\r\n[headers]\r\n<body>
|
|
6
|
+
* Response: RES <logId> <status>\r\n[headers]\r\n<body>
|
|
7
|
+
* Notification: MSG <method> [<logId>]\r\n[headers]\r\n<body>
|
|
8
|
+
*
|
|
9
|
+
* Optional headers block:
|
|
10
|
+
* AXON/1.0\r\n
|
|
11
|
+
* Key: Value\r\n
|
|
12
|
+
* \r\n
|
|
13
|
+
*/
|
|
14
|
+
export declare enum MessageType {
|
|
15
|
+
REQ = "REQ",
|
|
16
|
+
RES = "RES",
|
|
17
|
+
MSG = "MSG"
|
|
18
|
+
}
|
|
19
|
+
export interface AxonMessage {
|
|
20
|
+
type: MessageType;
|
|
21
|
+
method?: string;
|
|
22
|
+
logId?: string;
|
|
23
|
+
status?: number;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
body?: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
export declare function encode(msg: AxonMessage): Uint8Array;
|
|
28
|
+
export declare function decode(data: Uint8Array | ArrayBuffer): AxonMessage;
|
|
29
|
+
export declare function bodyToJSON<T = any>(msg: AxonMessage): T | undefined;
|
|
30
|
+
export declare function jsonToBody(obj: any): Uint8Array;
|