@fishjam-cloud/ts-client 0.10.2 → 0.12.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.txt +201 -0
- package/README.md +5 -6
- package/dist/index.d.mts +263 -253
- package/dist/index.mjs +1 -1
- package/package.json +16 -15
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import TypedEmitter from 'typed-emitter';
|
|
2
1
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
2
|
+
import TypedEmitter from 'typed-emitter';
|
|
3
|
+
|
|
4
|
+
declare const AUTH_ERROR_REASONS: readonly ["missing token", "invalid token", "expired token", "room not found", "peer not found"];
|
|
5
|
+
type AuthErrorReason = (typeof AUTH_ERROR_REASONS)[number];
|
|
6
|
+
declare const isAuthError: (error: string) => error is AuthErrorReason;
|
|
3
7
|
|
|
4
8
|
declare enum Variant {
|
|
5
9
|
VARIANT_UNSPECIFIED = 0,
|
|
@@ -35,36 +39,6 @@ interface MessageFns$2<T> {
|
|
|
35
39
|
fromPartial<I extends Exact$2<DeepPartial$2<T>, I>>(object: I): T;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
interface MediaEvent_Track_SimulcastConfig {
|
|
39
|
-
enabled: boolean;
|
|
40
|
-
enabledVariants: Variant[];
|
|
41
|
-
disabledVariants: Variant[];
|
|
42
|
-
}
|
|
43
|
-
declare const MediaEvent_Track_SimulcastConfig: MessageFns$1<MediaEvent_Track_SimulcastConfig>;
|
|
44
|
-
interface MediaEvent_OfferData_TrackTypes {
|
|
45
|
-
audio: number;
|
|
46
|
-
video: number;
|
|
47
|
-
}
|
|
48
|
-
declare const MediaEvent_OfferData_TrackTypes: MessageFns$1<MediaEvent_OfferData_TrackTypes>;
|
|
49
|
-
type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
50
|
-
type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {} ? {
|
|
51
|
-
[K in keyof T]?: DeepPartial$1<T[K]>;
|
|
52
|
-
} : Partial<T>;
|
|
53
|
-
type KeysOfUnion$1<T> = T extends T ? keyof T : never;
|
|
54
|
-
type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & {
|
|
55
|
-
[K in keyof P]: Exact$1<P[K], I[K]>;
|
|
56
|
-
} & {
|
|
57
|
-
[K in Exclude<keyof I, KeysOfUnion$1<P>>]: never;
|
|
58
|
-
};
|
|
59
|
-
interface MessageFns$1<T> {
|
|
60
|
-
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
61
|
-
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
62
|
-
fromJSON(object: any): T;
|
|
63
|
-
toJSON(message: T): unknown;
|
|
64
|
-
create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
|
|
65
|
-
fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
42
|
/** Defines any type of message sent from Peer to Membrane RTC Engine */
|
|
69
43
|
interface MediaEvent$1 {
|
|
70
44
|
connect?: MediaEvent_Connect | undefined;
|
|
@@ -79,36 +53,36 @@ interface MediaEvent$1 {
|
|
|
79
53
|
disableTrackVariant?: MediaEvent_DisableTrackVariant | undefined;
|
|
80
54
|
setTargetTrackVariant?: MediaEvent_SetTargetTrackVariant | undefined;
|
|
81
55
|
}
|
|
82
|
-
declare const MediaEvent$1: MessageFns<MediaEvent$1>;
|
|
56
|
+
declare const MediaEvent$1: MessageFns$1<MediaEvent$1>;
|
|
83
57
|
interface MediaEvent_VariantBitrate {
|
|
84
58
|
variant: Variant;
|
|
85
59
|
bitrate: number;
|
|
86
60
|
}
|
|
87
|
-
declare const MediaEvent_VariantBitrate: MessageFns<MediaEvent_VariantBitrate>;
|
|
61
|
+
declare const MediaEvent_VariantBitrate: MessageFns$1<MediaEvent_VariantBitrate>;
|
|
88
62
|
/** Sent when a peer wants to join WebRTC Endpoint. */
|
|
89
63
|
interface MediaEvent_Connect {
|
|
90
64
|
metadataJson: string;
|
|
91
65
|
}
|
|
92
|
-
declare const MediaEvent_Connect: MessageFns<MediaEvent_Connect>;
|
|
66
|
+
declare const MediaEvent_Connect: MessageFns$1<MediaEvent_Connect>;
|
|
93
67
|
/** Sent when a peer disconnects from WebRTC Endpoint. */
|
|
94
68
|
interface MediaEvent_Disconnect {
|
|
95
69
|
}
|
|
96
|
-
declare const MediaEvent_Disconnect: MessageFns<MediaEvent_Disconnect>;
|
|
70
|
+
declare const MediaEvent_Disconnect: MessageFns$1<MediaEvent_Disconnect>;
|
|
97
71
|
/** Sent when a peer wants to update its metadata */
|
|
98
72
|
interface MediaEvent_UpdateEndpointMetadata {
|
|
99
73
|
metadataJson: string;
|
|
100
74
|
}
|
|
101
|
-
declare const MediaEvent_UpdateEndpointMetadata: MessageFns<MediaEvent_UpdateEndpointMetadata>;
|
|
75
|
+
declare const MediaEvent_UpdateEndpointMetadata: MessageFns$1<MediaEvent_UpdateEndpointMetadata>;
|
|
102
76
|
/** Sent when a peer wants to update its track's metadata */
|
|
103
77
|
interface MediaEvent_UpdateTrackMetadata {
|
|
104
78
|
trackId: string;
|
|
105
79
|
metadataJson: string;
|
|
106
80
|
}
|
|
107
|
-
declare const MediaEvent_UpdateTrackMetadata: MessageFns<MediaEvent_UpdateTrackMetadata>;
|
|
81
|
+
declare const MediaEvent_UpdateTrackMetadata: MessageFns$1<MediaEvent_UpdateTrackMetadata>;
|
|
108
82
|
/** Sent when peer wants to renegatiate connection due to adding a track or removing a track */
|
|
109
83
|
interface MediaEvent_RenegotiateTracks {
|
|
110
84
|
}
|
|
111
|
-
declare const MediaEvent_RenegotiateTracks: MessageFns<MediaEvent_RenegotiateTracks>;
|
|
85
|
+
declare const MediaEvent_RenegotiateTracks: MessageFns$1<MediaEvent_RenegotiateTracks>;
|
|
112
86
|
/**
|
|
113
87
|
* Sent as a response to `offerData` media event during renegotiation
|
|
114
88
|
* Maps contain only information about current peer's `sendonly` tracks.
|
|
@@ -128,31 +102,61 @@ interface MediaEvent_SdpOffer {
|
|
|
128
102
|
[key: string]: string;
|
|
129
103
|
};
|
|
130
104
|
}
|
|
131
|
-
declare const MediaEvent_SdpOffer: MessageFns<MediaEvent_SdpOffer>;
|
|
105
|
+
declare const MediaEvent_SdpOffer: MessageFns$1<MediaEvent_SdpOffer>;
|
|
132
106
|
/** Sent when Peer wants to update its track's bitrate */
|
|
133
107
|
interface MediaEvent_TrackBitrates {
|
|
134
108
|
trackId: string;
|
|
135
109
|
/** Bitrate of each variant. For non-simulcast tracks use VARIANT_UNSPECIFIED. */
|
|
136
110
|
variantBitrates: MediaEvent_VariantBitrate[];
|
|
137
111
|
}
|
|
138
|
-
declare const MediaEvent_TrackBitrates: MessageFns<MediaEvent_TrackBitrates>;
|
|
112
|
+
declare const MediaEvent_TrackBitrates: MessageFns$1<MediaEvent_TrackBitrates>;
|
|
139
113
|
/** Sent when client disables one of the track variants */
|
|
140
114
|
interface MediaEvent_DisableTrackVariant {
|
|
141
115
|
trackId: string;
|
|
142
116
|
variant: Variant;
|
|
143
117
|
}
|
|
144
|
-
declare const MediaEvent_DisableTrackVariant: MessageFns<MediaEvent_DisableTrackVariant>;
|
|
118
|
+
declare const MediaEvent_DisableTrackVariant: MessageFns$1<MediaEvent_DisableTrackVariant>;
|
|
145
119
|
/** Sent when client enables one of the track variants */
|
|
146
120
|
interface MediaEvent_EnableTrackVariant {
|
|
147
121
|
trackId: string;
|
|
148
122
|
variant: Variant;
|
|
149
123
|
}
|
|
150
|
-
declare const MediaEvent_EnableTrackVariant: MessageFns<MediaEvent_EnableTrackVariant>;
|
|
124
|
+
declare const MediaEvent_EnableTrackVariant: MessageFns$1<MediaEvent_EnableTrackVariant>;
|
|
151
125
|
interface MediaEvent_SetTargetTrackVariant {
|
|
152
126
|
trackId: string;
|
|
153
127
|
variant: Variant;
|
|
154
128
|
}
|
|
155
|
-
declare const MediaEvent_SetTargetTrackVariant: MessageFns<MediaEvent_SetTargetTrackVariant>;
|
|
129
|
+
declare const MediaEvent_SetTargetTrackVariant: MessageFns$1<MediaEvent_SetTargetTrackVariant>;
|
|
130
|
+
type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
131
|
+
type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {} ? {
|
|
132
|
+
[K in keyof T]?: DeepPartial$1<T[K]>;
|
|
133
|
+
} : Partial<T>;
|
|
134
|
+
type KeysOfUnion$1<T> = T extends T ? keyof T : never;
|
|
135
|
+
type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & {
|
|
136
|
+
[K in keyof P]: Exact$1<P[K], I[K]>;
|
|
137
|
+
} & {
|
|
138
|
+
[K in Exclude<keyof I, KeysOfUnion$1<P>>]: never;
|
|
139
|
+
};
|
|
140
|
+
interface MessageFns$1<T> {
|
|
141
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
142
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
143
|
+
fromJSON(object: any): T;
|
|
144
|
+
toJSON(message: T): unknown;
|
|
145
|
+
create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
|
|
146
|
+
fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface MediaEvent_Track_SimulcastConfig {
|
|
150
|
+
enabled: boolean;
|
|
151
|
+
enabledVariants: Variant[];
|
|
152
|
+
disabledVariants: Variant[];
|
|
153
|
+
}
|
|
154
|
+
declare const MediaEvent_Track_SimulcastConfig: MessageFns<MediaEvent_Track_SimulcastConfig>;
|
|
155
|
+
interface MediaEvent_OfferData_TrackTypes {
|
|
156
|
+
audio: number;
|
|
157
|
+
video: number;
|
|
158
|
+
}
|
|
159
|
+
declare const MediaEvent_OfferData_TrackTypes: MessageFns<MediaEvent_OfferData_TrackTypes>;
|
|
156
160
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
157
161
|
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
158
162
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
@@ -430,6 +434,21 @@ interface Endpoint {
|
|
|
430
434
|
tracks: Map<string, TrackContext>;
|
|
431
435
|
}
|
|
432
436
|
|
|
437
|
+
declare class ConnectionManager {
|
|
438
|
+
private readonly connection;
|
|
439
|
+
constructor(iceServers: RTCIceServer[]);
|
|
440
|
+
isConnectionUnstable: () => boolean;
|
|
441
|
+
getConnection: () => RTCPeerConnection;
|
|
442
|
+
addTransceiversIfNeeded: (serverTracks: MediaEvent_OfferData_TrackTypes) => void;
|
|
443
|
+
addTransceiver: (track: MediaStreamTrack, transceiverConfig: RTCRtpTransceiverInit) => void;
|
|
444
|
+
setOnTrackReady: (onTrackReady: (event: RTCTrackEvent) => void) => void;
|
|
445
|
+
setRemoteDescription: (data: RTCSessionDescriptionInit) => Promise<void>;
|
|
446
|
+
isTrackInUse: (track: MediaStreamTrack) => boolean;
|
|
447
|
+
removeTrack: (sender: RTCRtpSender) => void;
|
|
448
|
+
findSender: (mediaStreamTrackId: MediaStreamTrackId) => RTCRtpSender;
|
|
449
|
+
addIceCandidate: (iceCandidate: RTCIceCandidate) => Promise<void>;
|
|
450
|
+
}
|
|
451
|
+
|
|
433
452
|
declare const TrackContextImpl_base: new () => TypedEmitter<Required<TrackContextEvents$1>>;
|
|
434
453
|
declare class TrackContextImpl extends TrackContextImpl_base implements TrackContext {
|
|
435
454
|
endpoint: Endpoint;
|
|
@@ -452,21 +471,6 @@ type EndpointWithTrackContext = Omit<Endpoint, 'tracks'> & {
|
|
|
452
471
|
tracks: Map<string, TrackContextImpl>;
|
|
453
472
|
};
|
|
454
473
|
|
|
455
|
-
declare class ConnectionManager {
|
|
456
|
-
private readonly connection;
|
|
457
|
-
constructor(iceServers: RTCIceServer[]);
|
|
458
|
-
isConnectionUnstable: () => boolean;
|
|
459
|
-
getConnection: () => RTCPeerConnection;
|
|
460
|
-
addTransceiversIfNeeded: (serverTracks: MediaEvent_OfferData_TrackTypes) => void;
|
|
461
|
-
addTransceiver: (track: MediaStreamTrack, transceiverConfig: RTCRtpTransceiverInit) => void;
|
|
462
|
-
setOnTrackReady: (onTrackReady: (event: RTCTrackEvent) => void) => void;
|
|
463
|
-
setRemoteDescription: (data: RTCSessionDescriptionInit) => Promise<void>;
|
|
464
|
-
isTrackInUse: (track: MediaStreamTrack) => boolean;
|
|
465
|
-
removeTrack: (sender: RTCRtpSender) => void;
|
|
466
|
-
findSender: (mediaStreamTrackId: MediaStreamTrackId) => RTCRtpSender;
|
|
467
|
-
addIceCandidate: (iceCandidate: RTCIceCandidate) => Promise<void>;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
474
|
declare const WebRTCEndpoint_base: new () => TypedEmitter<Required<WebRTCEndpointEvents>>;
|
|
471
475
|
/**
|
|
472
476
|
* Main class that is responsible for connecting to the RTC Engine, sending and receiving media.
|
|
@@ -520,7 +524,6 @@ declare class WebRTCEndpoint extends WebRTCEndpoint_base {
|
|
|
520
524
|
*
|
|
521
525
|
* @return {Promise<RTCStatsReport>}
|
|
522
526
|
*
|
|
523
|
-
* @external RTCPeerConnection#getStats()
|
|
524
527
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats | MDN Web Docs: RTCPeerConnection.getStats()}
|
|
525
528
|
*/
|
|
526
529
|
getStatistics(selector?: MediaStreamTrack | null): Promise<RTCStatsReport>;
|
|
@@ -759,12 +762,205 @@ declare class WebRTCEndpoint extends WebRTCEndpoint_base {
|
|
|
759
762
|
private onIceConnectionStateChange;
|
|
760
763
|
}
|
|
761
764
|
|
|
762
|
-
declare const
|
|
763
|
-
type
|
|
764
|
-
declare const
|
|
765
|
+
declare const JOIN_ERRORS: readonly ["reached peers limit", "room not found", "node not found", "Invalid SDK version"];
|
|
766
|
+
type JoinErrorReason = (typeof JOIN_ERRORS)[number];
|
|
767
|
+
declare const isJoinError: (error: string) => error is JoinErrorReason;
|
|
768
|
+
|
|
769
|
+
type ReconnectionStatus = 'reconnecting' | 'idle' | 'error';
|
|
770
|
+
type ReconnectConfig = {
|
|
771
|
+
maxAttempts?: number;
|
|
772
|
+
initialDelay?: number;
|
|
773
|
+
delay?: number;
|
|
774
|
+
addTracksOnReconnect?: boolean;
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
type TrackMetadata = {
|
|
778
|
+
type: 'camera' | 'microphone' | 'screenShareVideo' | 'screenShareAudio';
|
|
779
|
+
paused: boolean;
|
|
780
|
+
displayName?: string;
|
|
781
|
+
};
|
|
782
|
+
type GenericMetadata = Record<string, unknown> | undefined;
|
|
783
|
+
/**
|
|
784
|
+
*
|
|
785
|
+
* @category Connection
|
|
786
|
+
* @typeParam PeerMetadata Type of metadata set by peer while connecting to a room.
|
|
787
|
+
* @typeParam ServerMetadata Type of metadata set by the server while creating a peer.
|
|
788
|
+
*/
|
|
789
|
+
type Metadata<PeerMetadata = GenericMetadata, ServerMetadata = GenericMetadata> = {
|
|
790
|
+
peer: PeerMetadata;
|
|
791
|
+
server: ServerMetadata;
|
|
792
|
+
};
|
|
793
|
+
type TrackContextEvents = {
|
|
794
|
+
encodingChanged: (context: FishjamTrackContext) => void;
|
|
795
|
+
voiceActivityChanged: (context: FishjamTrackContext) => void;
|
|
796
|
+
};
|
|
797
|
+
interface FishjamTrackContext extends TypedEmitter<TrackContextEvents> {
|
|
798
|
+
readonly track: MediaStreamTrack | null;
|
|
799
|
+
readonly stream: MediaStream | null;
|
|
800
|
+
readonly endpoint: Endpoint;
|
|
801
|
+
readonly trackId: string;
|
|
802
|
+
readonly simulcastConfig?: MediaEvent_Track_SimulcastConfig;
|
|
803
|
+
readonly metadata?: TrackMetadata;
|
|
804
|
+
readonly maxBandwidth?: TrackBandwidthLimit;
|
|
805
|
+
readonly vadStatus: VadStatus;
|
|
806
|
+
readonly encoding?: Variant;
|
|
807
|
+
readonly encodingReason?: EncodingReason;
|
|
808
|
+
}
|
|
809
|
+
type Peer<PeerMetadata = GenericMetadata, ServerMetadata = GenericMetadata> = {
|
|
810
|
+
id: string;
|
|
811
|
+
type: string;
|
|
812
|
+
metadata?: Metadata<PeerMetadata, ServerMetadata>;
|
|
813
|
+
tracks: Map<string, FishjamTrackContext>;
|
|
814
|
+
};
|
|
815
|
+
type Component = Omit<Endpoint, 'type'> & {
|
|
816
|
+
type: 'recording' | 'hls' | 'file' | 'rtsp' | 'sip';
|
|
817
|
+
};
|
|
818
|
+
/**
|
|
819
|
+
* Events emitted by the client with their arguments.
|
|
820
|
+
*/
|
|
821
|
+
type MessageEvents<P, S> = {
|
|
822
|
+
/**
|
|
823
|
+
* Emitted when connect method invoked
|
|
824
|
+
*
|
|
825
|
+
*/
|
|
826
|
+
connectionStarted: () => void;
|
|
827
|
+
/**
|
|
828
|
+
* Emitted when the websocket connection is closed
|
|
829
|
+
*
|
|
830
|
+
* @param {CloseEvent} event - Close event object from the websocket
|
|
831
|
+
*/
|
|
832
|
+
socketClose: (event: CloseEvent) => void;
|
|
833
|
+
/**
|
|
834
|
+
* Emitted when occurs an error in the websocket connection
|
|
835
|
+
*
|
|
836
|
+
* @param {Event} event - Event object from the websocket
|
|
837
|
+
*/
|
|
838
|
+
socketError: (event: Event) => void;
|
|
839
|
+
/**
|
|
840
|
+
* Emitted when the websocket connection is opened
|
|
841
|
+
*
|
|
842
|
+
* @param {Event} event - Event object from the websocket
|
|
843
|
+
*/
|
|
844
|
+
socketOpen: (event: Event) => void;
|
|
845
|
+
/** Emitted when authentication is successful */
|
|
846
|
+
authSuccess: () => void;
|
|
847
|
+
/** Emitted when authentication fails */
|
|
848
|
+
authError: (reason: AuthErrorReason) => void;
|
|
849
|
+
/** Emitted when the connection is closed */
|
|
850
|
+
disconnected: () => void;
|
|
851
|
+
/** Emitted when the process of reconnection starts */
|
|
852
|
+
reconnectionStarted: () => void;
|
|
853
|
+
/** Emitted on successful reconnection */
|
|
854
|
+
reconnected: () => void;
|
|
855
|
+
/** Emitted when the maximum number of reconnection retries is reached */
|
|
856
|
+
reconnectionRetriesLimitReached: () => void;
|
|
857
|
+
/**
|
|
858
|
+
* Called when peer was accepted.
|
|
859
|
+
*/
|
|
860
|
+
joined: (peerId: string, peers: Peer<P, S>[], components: Component[]) => void;
|
|
861
|
+
/**
|
|
862
|
+
* Called when peer was not accepted
|
|
863
|
+
* @param metadata - Pass through for client application to communicate further actions to frontend
|
|
864
|
+
*/
|
|
865
|
+
joinError: (metadata: JoinErrorReason | unknown) => void;
|
|
866
|
+
/**
|
|
867
|
+
* Called when data in a new track arrives.
|
|
868
|
+
*
|
|
869
|
+
* This callback is always called after {@link MessageEvents.trackAdded}.
|
|
870
|
+
* It informs user that data related to the given track arrives and can be played or displayed.
|
|
871
|
+
*/
|
|
872
|
+
trackReady: (ctx: FishjamTrackContext) => void;
|
|
873
|
+
/**
|
|
874
|
+
* Called each time the peer which was already in the room, adds new track. Fields track and stream will be set to null.
|
|
875
|
+
* These fields will be set to non-null value in {@link MessageEvents.trackReady}
|
|
876
|
+
*/
|
|
877
|
+
trackAdded: (ctx: FishjamTrackContext) => void;
|
|
878
|
+
/**
|
|
879
|
+
* Called when some track will no longer be sent.
|
|
880
|
+
*
|
|
881
|
+
* It will also be called before {@link MessageEvents.peerLeft} for each track of this peer.
|
|
882
|
+
*/
|
|
883
|
+
trackRemoved: (ctx: FishjamTrackContext) => void;
|
|
884
|
+
/**
|
|
885
|
+
* Called each time peer has its track metadata updated.
|
|
886
|
+
*/
|
|
887
|
+
trackUpdated: (ctx: FishjamTrackContext) => void;
|
|
888
|
+
/**
|
|
889
|
+
* Called each time new peer joins the room.
|
|
890
|
+
*/
|
|
891
|
+
peerJoined: (peer: Peer<P, S>) => void;
|
|
892
|
+
/**
|
|
893
|
+
* Called each time peer leaves the room.
|
|
894
|
+
*/
|
|
895
|
+
peerLeft: (peer: Peer<P, S>) => void;
|
|
896
|
+
/**
|
|
897
|
+
* Called each time peer has its metadata updated.
|
|
898
|
+
*/
|
|
899
|
+
peerUpdated: (peer: Peer<P, S>) => void;
|
|
900
|
+
/**
|
|
901
|
+
* Called each time new peer joins the room.
|
|
902
|
+
*/
|
|
903
|
+
componentAdded: (peer: Component) => void;
|
|
904
|
+
/**
|
|
905
|
+
* Called each time peer leaves the room.
|
|
906
|
+
*/
|
|
907
|
+
componentRemoved: (peer: Component) => void;
|
|
908
|
+
/**
|
|
909
|
+
* Called each time peer has its metadata updated.
|
|
910
|
+
*/
|
|
911
|
+
componentUpdated: (peer: Component) => void;
|
|
912
|
+
/**
|
|
913
|
+
* Called in case of errors related to multimedia session e.g. ICE connection.
|
|
914
|
+
*/
|
|
915
|
+
connectionError: (error: {
|
|
916
|
+
message: string;
|
|
917
|
+
event?: Event;
|
|
918
|
+
}) => void;
|
|
919
|
+
/**
|
|
920
|
+
* Currently, this callback is only invoked when DisplayManager in RTC Engine is
|
|
921
|
+
* enabled and simulcast is disabled.
|
|
922
|
+
*
|
|
923
|
+
* Called when priority of video tracks have changed.
|
|
924
|
+
* @param enabledTracks - list of tracks which will be sent to client from SFU
|
|
925
|
+
* @param disabledTracks - list of tracks which will not be sent to client from SFU
|
|
926
|
+
*/
|
|
927
|
+
tracksPriorityChanged: (enabledTracks: FishjamTrackContext[], disabledTracks: FishjamTrackContext[]) => void;
|
|
928
|
+
/**
|
|
929
|
+
* Called every time the server estimates client's bandiwdth.
|
|
930
|
+
*
|
|
931
|
+
* @param {bigint} estimation - client's available incoming bitrate estimated
|
|
932
|
+
* by the server. It's measured in bits per second.
|
|
933
|
+
*/
|
|
934
|
+
bandwidthEstimationChanged: (estimation: bigint) => void;
|
|
935
|
+
targetTrackEncodingRequested: (event: Parameters<WebRTCEndpointEvents['targetTrackEncodingRequested']>[0]) => void;
|
|
936
|
+
localTrackAdded: (event: Parameters<WebRTCEndpointEvents['localTrackAdded']>[0]) => void;
|
|
937
|
+
localTrackRemoved: (event: Parameters<WebRTCEndpointEvents['localTrackRemoved']>[0]) => void;
|
|
938
|
+
localTrackReplaced: (event: Parameters<WebRTCEndpointEvents['localTrackReplaced']>[0]) => void;
|
|
939
|
+
localTrackMuted: (event: Parameters<WebRTCEndpointEvents['localTrackMuted']>[0]) => void;
|
|
940
|
+
localTrackUnmuted: (event: Parameters<WebRTCEndpointEvents['localTrackUnmuted']>[0]) => void;
|
|
941
|
+
localTrackBandwidthSet: (event: Parameters<WebRTCEndpointEvents['localTrackBandwidthSet']>[0]) => void;
|
|
942
|
+
localTrackEncodingBandwidthSet: (event: Parameters<WebRTCEndpointEvents['localTrackEncodingBandwidthSet']>[0]) => void;
|
|
943
|
+
localTrackEncodingEnabled: (event: Parameters<WebRTCEndpointEvents['localTrackEncodingEnabled']>[0]) => void;
|
|
944
|
+
localTrackEncodingDisabled: (event: Parameters<WebRTCEndpointEvents['localTrackEncodingDisabled']>[0]) => void;
|
|
945
|
+
localPeerMetadataChanged: (event: Parameters<WebRTCEndpointEvents['localEndpointMetadataChanged']>[0]) => void;
|
|
946
|
+
localTrackMetadataChanged: (event: Parameters<WebRTCEndpointEvents['localTrackMetadataChanged']>[0]) => void;
|
|
947
|
+
disconnectRequested: (event: Parameters<WebRTCEndpointEvents['disconnectRequested']>[0]) => void;
|
|
948
|
+
};
|
|
949
|
+
/** Configuration object for the client */
|
|
950
|
+
interface ConnectConfig<PeerMetadata> {
|
|
951
|
+
/** Metadata for the peer */
|
|
952
|
+
peerMetadata: PeerMetadata;
|
|
953
|
+
/** Token for authentication */
|
|
954
|
+
token: string;
|
|
955
|
+
/** Fishjam url */
|
|
956
|
+
url: string;
|
|
957
|
+
}
|
|
958
|
+
type CreateConfig = {
|
|
959
|
+
reconnect?: ReconnectConfig | boolean;
|
|
960
|
+
};
|
|
765
961
|
|
|
766
962
|
declare const FishjamClient_base: {
|
|
767
|
-
new <
|
|
963
|
+
new <P, S>(): TypedEmitter<MessageEvents<P, S>>;
|
|
768
964
|
};
|
|
769
965
|
/**
|
|
770
966
|
* FishjamClient is the main class to interact with Fishjam.
|
|
@@ -807,10 +1003,11 @@ declare class FishjamClient<PeerMetadata = GenericMetadata, ServerMetadata = Gen
|
|
|
807
1003
|
status: 'new' | 'initialized';
|
|
808
1004
|
private connectConfig;
|
|
809
1005
|
private reconnectManager;
|
|
1006
|
+
private peerMessageQueue;
|
|
810
1007
|
private sendStatisticsInterval;
|
|
811
1008
|
constructor(config?: CreateConfig);
|
|
812
1009
|
/**
|
|
813
|
-
* Uses the
|
|
1010
|
+
* Uses the WebSocket connection and {@link !WebRTCEndpoint | WebRTCEndpoint} to join to the room. Registers the callbacks to
|
|
814
1011
|
* handle the events emitted by the {@link !WebRTCEndpoint | WebRTCEndpoint}. Make sure that peer metadata is serializable.
|
|
815
1012
|
*
|
|
816
1013
|
* @example
|
|
@@ -835,7 +1032,6 @@ declare class FishjamClient<PeerMetadata = GenericMetadata, ServerMetadata = Gen
|
|
|
835
1032
|
*
|
|
836
1033
|
* @return {Promise<RTCStatsReport>}
|
|
837
1034
|
*
|
|
838
|
-
* @external RTCPeerConnection#getStats()
|
|
839
1035
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats | MDN Web Docs: RTCPeerConnection.getStats()}
|
|
840
1036
|
*/
|
|
841
1037
|
getStatistics(selector?: MediaStreamTrack | null): Promise<RTCStatsReport>;
|
|
@@ -855,6 +1051,7 @@ declare class FishjamClient<PeerMetadata = GenericMetadata, ServerMetadata = Gen
|
|
|
855
1051
|
getRemoteComponents(): Record<string, Component>;
|
|
856
1052
|
getLocalPeer(): Peer<PeerMetadata, ServerMetadata> | null;
|
|
857
1053
|
getBandwidthEstimation(): bigint;
|
|
1054
|
+
private isConnectingRelatedEvent;
|
|
858
1055
|
private setupCallbacks;
|
|
859
1056
|
private sendStatistics;
|
|
860
1057
|
/**
|
|
@@ -1118,191 +1315,4 @@ declare class FishjamClient<PeerMetadata = GenericMetadata, ServerMetadata = Gen
|
|
|
1118
1315
|
cleanup(): void;
|
|
1119
1316
|
}
|
|
1120
1317
|
|
|
1121
|
-
type ReconnectionStatus
|
|
1122
|
-
type ReconnectConfig = {
|
|
1123
|
-
maxAttempts?: number;
|
|
1124
|
-
initialDelay?: number;
|
|
1125
|
-
delay?: number;
|
|
1126
|
-
addTracksOnReconnect?: boolean;
|
|
1127
|
-
};
|
|
1128
|
-
|
|
1129
|
-
type TrackMetadata = {
|
|
1130
|
-
type: 'camera' | 'microphone' | 'screenShareVideo' | 'screenShareAudio';
|
|
1131
|
-
paused: boolean;
|
|
1132
|
-
displayName?: string;
|
|
1133
|
-
};
|
|
1134
|
-
type GenericMetadata = Record<string, unknown> | undefined;
|
|
1135
|
-
type Metadata<P = GenericMetadata, S = GenericMetadata> = {
|
|
1136
|
-
peer: P;
|
|
1137
|
-
server: S;
|
|
1138
|
-
};
|
|
1139
|
-
type TrackContextEvents = {
|
|
1140
|
-
encodingChanged: (context: FishjamTrackContext) => void;
|
|
1141
|
-
voiceActivityChanged: (context: FishjamTrackContext) => void;
|
|
1142
|
-
};
|
|
1143
|
-
interface FishjamTrackContext extends TypedEmitter<TrackContextEvents> {
|
|
1144
|
-
readonly track: MediaStreamTrack | null;
|
|
1145
|
-
readonly stream: MediaStream | null;
|
|
1146
|
-
readonly endpoint: Endpoint;
|
|
1147
|
-
readonly trackId: string;
|
|
1148
|
-
readonly simulcastConfig?: MediaEvent_Track_SimulcastConfig;
|
|
1149
|
-
readonly metadata?: TrackMetadata;
|
|
1150
|
-
readonly maxBandwidth?: TrackBandwidthLimit;
|
|
1151
|
-
readonly vadStatus: VadStatus;
|
|
1152
|
-
readonly encoding?: Variant;
|
|
1153
|
-
readonly encodingReason?: EncodingReason;
|
|
1154
|
-
}
|
|
1155
|
-
type Peer<PeerMetadata = GenericMetadata, ServerMetadata = GenericMetadata> = {
|
|
1156
|
-
id: string;
|
|
1157
|
-
type: string;
|
|
1158
|
-
metadata?: Metadata<PeerMetadata, ServerMetadata>;
|
|
1159
|
-
tracks: Map<string, FishjamTrackContext>;
|
|
1160
|
-
};
|
|
1161
|
-
type Component = Omit<Endpoint, 'type'> & {
|
|
1162
|
-
type: 'recording' | 'hls' | 'file' | 'rtsp' | 'sip';
|
|
1163
|
-
};
|
|
1164
|
-
/**
|
|
1165
|
-
* Events emitted by the client with their arguments.
|
|
1166
|
-
*/
|
|
1167
|
-
type MessageEvents<P, S> = {
|
|
1168
|
-
/**
|
|
1169
|
-
* Emitted when connect method invoked
|
|
1170
|
-
*
|
|
1171
|
-
*/
|
|
1172
|
-
connectionStarted: () => void;
|
|
1173
|
-
/**
|
|
1174
|
-
* Emitted when the websocket connection is closed
|
|
1175
|
-
*
|
|
1176
|
-
* @param {CloseEvent} event - Close event object from the websocket
|
|
1177
|
-
*/
|
|
1178
|
-
socketClose: (event: CloseEvent) => void;
|
|
1179
|
-
/**
|
|
1180
|
-
* Emitted when occurs an error in the websocket connection
|
|
1181
|
-
*
|
|
1182
|
-
* @param {Event} event - Event object from the websocket
|
|
1183
|
-
*/
|
|
1184
|
-
socketError: (event: Event) => void;
|
|
1185
|
-
/**
|
|
1186
|
-
* Emitted when the websocket connection is opened
|
|
1187
|
-
*
|
|
1188
|
-
* @param {Event} event - Event object from the websocket
|
|
1189
|
-
*/
|
|
1190
|
-
socketOpen: (event: Event) => void;
|
|
1191
|
-
/** Emitted when authentication is successful */
|
|
1192
|
-
authSuccess: () => void;
|
|
1193
|
-
/** Emitted when authentication fails */
|
|
1194
|
-
authError: (reason: AuthErrorReason) => void;
|
|
1195
|
-
/** Emitted when the connection is closed */
|
|
1196
|
-
disconnected: () => void;
|
|
1197
|
-
/** Emitted when the process of reconnection starts */
|
|
1198
|
-
reconnectionStarted: () => void;
|
|
1199
|
-
/** Emitted on successful reconnection */
|
|
1200
|
-
reconnected: () => void;
|
|
1201
|
-
/** Emitted when the maximum number of reconnection retries is reached */
|
|
1202
|
-
reconnectionRetriesLimitReached: () => void;
|
|
1203
|
-
/**
|
|
1204
|
-
* Called when peer was accepted.
|
|
1205
|
-
*/
|
|
1206
|
-
joined: (peerId: string, peers: Peer<P, S>[], components: Component[]) => void;
|
|
1207
|
-
/**
|
|
1208
|
-
* Called when peer was not accepted
|
|
1209
|
-
* @param metadata - Pass through for client application to communicate further actions to frontend
|
|
1210
|
-
*/
|
|
1211
|
-
joinError: (metadata: any) => void;
|
|
1212
|
-
/**
|
|
1213
|
-
* Called when data in a new track arrives.
|
|
1214
|
-
*
|
|
1215
|
-
* This callback is always called after {@link MessageEvents.trackAdded}.
|
|
1216
|
-
* It informs user that data related to the given track arrives and can be played or displayed.
|
|
1217
|
-
*/
|
|
1218
|
-
trackReady: (ctx: FishjamTrackContext) => void;
|
|
1219
|
-
/**
|
|
1220
|
-
* Called each time the peer which was already in the room, adds new track. Fields track and stream will be set to null.
|
|
1221
|
-
* These fields will be set to non-null value in {@link MessageEvents.trackReady}
|
|
1222
|
-
*/
|
|
1223
|
-
trackAdded: (ctx: FishjamTrackContext) => void;
|
|
1224
|
-
/**
|
|
1225
|
-
* Called when some track will no longer be sent.
|
|
1226
|
-
*
|
|
1227
|
-
* It will also be called before {@link MessageEvents.peerLeft} for each track of this peer.
|
|
1228
|
-
*/
|
|
1229
|
-
trackRemoved: (ctx: FishjamTrackContext) => void;
|
|
1230
|
-
/**
|
|
1231
|
-
* Called each time peer has its track metadata updated.
|
|
1232
|
-
*/
|
|
1233
|
-
trackUpdated: (ctx: FishjamTrackContext) => void;
|
|
1234
|
-
/**
|
|
1235
|
-
* Called each time new peer joins the room.
|
|
1236
|
-
*/
|
|
1237
|
-
peerJoined: (peer: Peer<P, S>) => void;
|
|
1238
|
-
/**
|
|
1239
|
-
* Called each time peer leaves the room.
|
|
1240
|
-
*/
|
|
1241
|
-
peerLeft: (peer: Peer<P, S>) => void;
|
|
1242
|
-
/**
|
|
1243
|
-
* Called each time peer has its metadata updated.
|
|
1244
|
-
*/
|
|
1245
|
-
peerUpdated: (peer: Peer<P, S>) => void;
|
|
1246
|
-
/**
|
|
1247
|
-
* Called each time new peer joins the room.
|
|
1248
|
-
*/
|
|
1249
|
-
componentAdded: (peer: Component) => void;
|
|
1250
|
-
/**
|
|
1251
|
-
* Called each time peer leaves the room.
|
|
1252
|
-
*/
|
|
1253
|
-
componentRemoved: (peer: Component) => void;
|
|
1254
|
-
/**
|
|
1255
|
-
* Called each time peer has its metadata updated.
|
|
1256
|
-
*/
|
|
1257
|
-
componentUpdated: (peer: Component) => void;
|
|
1258
|
-
/**
|
|
1259
|
-
* Called in case of errors related to multimedia session e.g. ICE connection.
|
|
1260
|
-
*/
|
|
1261
|
-
connectionError: (error: {
|
|
1262
|
-
message: string;
|
|
1263
|
-
event?: Event;
|
|
1264
|
-
}) => void;
|
|
1265
|
-
/**
|
|
1266
|
-
* Currently, this callback is only invoked when DisplayManager in RTC Engine is
|
|
1267
|
-
* enabled and simulcast is disabled.
|
|
1268
|
-
*
|
|
1269
|
-
* Called when priority of video tracks have changed.
|
|
1270
|
-
* @param enabledTracks - list of tracks which will be sent to client from SFU
|
|
1271
|
-
* @param disabledTracks - list of tracks which will not be sent to client from SFU
|
|
1272
|
-
*/
|
|
1273
|
-
tracksPriorityChanged: (enabledTracks: FishjamTrackContext[], disabledTracks: FishjamTrackContext[]) => void;
|
|
1274
|
-
/**
|
|
1275
|
-
* Called every time the server estimates client's bandiwdth.
|
|
1276
|
-
*
|
|
1277
|
-
* @param {bigint} estimation - client's available incoming bitrate estimated
|
|
1278
|
-
* by the server. It's measured in bits per second.
|
|
1279
|
-
*/
|
|
1280
|
-
bandwidthEstimationChanged: (estimation: bigint) => void;
|
|
1281
|
-
targetTrackEncodingRequested: (event: Parameters<WebRTCEndpointEvents['targetTrackEncodingRequested']>[0]) => void;
|
|
1282
|
-
localTrackAdded: (event: Parameters<WebRTCEndpointEvents['localTrackAdded']>[0]) => void;
|
|
1283
|
-
localTrackRemoved: (event: Parameters<WebRTCEndpointEvents['localTrackRemoved']>[0]) => void;
|
|
1284
|
-
localTrackReplaced: (event: Parameters<WebRTCEndpointEvents['localTrackReplaced']>[0]) => void;
|
|
1285
|
-
localTrackMuted: (event: Parameters<WebRTCEndpointEvents['localTrackMuted']>[0]) => void;
|
|
1286
|
-
localTrackUnmuted: (event: Parameters<WebRTCEndpointEvents['localTrackUnmuted']>[0]) => void;
|
|
1287
|
-
localTrackBandwidthSet: (event: Parameters<WebRTCEndpointEvents['localTrackBandwidthSet']>[0]) => void;
|
|
1288
|
-
localTrackEncodingBandwidthSet: (event: Parameters<WebRTCEndpointEvents['localTrackEncodingBandwidthSet']>[0]) => void;
|
|
1289
|
-
localTrackEncodingEnabled: (event: Parameters<WebRTCEndpointEvents['localTrackEncodingEnabled']>[0]) => void;
|
|
1290
|
-
localTrackEncodingDisabled: (event: Parameters<WebRTCEndpointEvents['localTrackEncodingDisabled']>[0]) => void;
|
|
1291
|
-
localPeerMetadataChanged: (event: Parameters<WebRTCEndpointEvents['localEndpointMetadataChanged']>[0]) => void;
|
|
1292
|
-
localTrackMetadataChanged: (event: Parameters<WebRTCEndpointEvents['localTrackMetadataChanged']>[0]) => void;
|
|
1293
|
-
disconnectRequested: (event: Parameters<WebRTCEndpointEvents['disconnectRequested']>[0]) => void;
|
|
1294
|
-
};
|
|
1295
|
-
/** Configuration object for the client */
|
|
1296
|
-
interface ConnectConfig<PeerMetadata> {
|
|
1297
|
-
/** Metadata for the peer */
|
|
1298
|
-
peerMetadata: PeerMetadata;
|
|
1299
|
-
/** Token for authentication */
|
|
1300
|
-
token: string;
|
|
1301
|
-
/** Fishjam url */
|
|
1302
|
-
url: string;
|
|
1303
|
-
}
|
|
1304
|
-
type CreateConfig = {
|
|
1305
|
-
reconnect?: ReconnectConfig | boolean;
|
|
1306
|
-
};
|
|
1307
|
-
|
|
1308
|
-
export { AUTH_ERROR_REASONS, type AuthErrorReason, type BandwidthLimit, type Component, type ConnectConfig, type CreateConfig, type EncodingReason, type Endpoint, FishjamClient, type FishjamTrackContext, type GenericMetadata, type MediaEvent, type MessageEvents, type Metadata, type Peer, type ReconnectConfig, type ReconnectionStatus, type SerializedMediaEvent, type SimulcastBandwidthLimit, MediaEvent_Track_SimulcastConfig as SimulcastConfig, type TrackBandwidthLimit, type TrackContext, type TrackContextEvents$1 as TrackContextEvents, type TrackKind, type TrackMetadata, type VadStatus, Variant, WebRTCEndpoint, type WebRTCEndpointEvents, isAuthError };
|
|
1318
|
+
export { AUTH_ERROR_REASONS, type AuthErrorReason, type BandwidthLimit, type Component, type ConnectConfig, type CreateConfig, type EncodingReason, type Endpoint, FishjamClient, type FishjamTrackContext, type GenericMetadata, JOIN_ERRORS, type JoinErrorReason, type MediaEvent, type MessageEvents, type Metadata, type Peer, type ReconnectConfig, type ReconnectionStatus, type SerializedMediaEvent, type SimulcastBandwidthLimit, MediaEvent_Track_SimulcastConfig as SimulcastConfig, type TrackBandwidthLimit, type TrackContext, type TrackContextEvents, type TrackKind, type TrackMetadata, type VadStatus, Variant, WebRTCEndpoint, type WebRTCEndpointEvents, isAuthError, isJoinError };
|