@fishjam-cloud/js-server-sdk 0.21.0 → 0.22.1
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/dist/index.d.mts +126 -69
- package/dist/index.d.ts +126 -69
- package/dist/index.js +1113 -135
- package/dist/index.mjs +1113 -135
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -27,10 +27,16 @@ interface Peer$1 {
|
|
|
27
27
|
'status': PeerStatus;
|
|
28
28
|
/**
|
|
29
29
|
*
|
|
30
|
-
* @type {
|
|
30
|
+
* @type {SubscribeMode}
|
|
31
31
|
* @memberof Peer
|
|
32
32
|
*/
|
|
33
|
-
'
|
|
33
|
+
'subscribeMode': SubscribeMode;
|
|
34
|
+
/**
|
|
35
|
+
* Describes peer\'s subscriptions in manual mode
|
|
36
|
+
* @type {Array<string>}
|
|
37
|
+
* @memberof Peer
|
|
38
|
+
*/
|
|
39
|
+
'subscriptions': Array<string>;
|
|
34
40
|
/**
|
|
35
41
|
* List of all peer\'s tracks
|
|
36
42
|
* @type {Array<Track>}
|
|
@@ -49,7 +55,59 @@ interface Peer$1 {
|
|
|
49
55
|
* Peer-specific options
|
|
50
56
|
* @export
|
|
51
57
|
*/
|
|
52
|
-
type PeerOptions =
|
|
58
|
+
type PeerOptions = PeerOptionsAgent | PeerOptionsWebRTC;
|
|
59
|
+
/**
|
|
60
|
+
* Options specific to the Agent peer
|
|
61
|
+
* @export
|
|
62
|
+
* @interface PeerOptionsAgent
|
|
63
|
+
*/
|
|
64
|
+
interface PeerOptionsAgent {
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @type {PeerOptionsAgentOutput}
|
|
68
|
+
* @memberof PeerOptionsAgent
|
|
69
|
+
*/
|
|
70
|
+
'output'?: PeerOptionsAgentOutput;
|
|
71
|
+
/**
|
|
72
|
+
* Configuration of peer\'s subscribing policy
|
|
73
|
+
* @type {string}
|
|
74
|
+
* @memberof PeerOptionsAgent
|
|
75
|
+
*/
|
|
76
|
+
'subscribeMode'?: PeerOptionsAgentSubscribeModeEnum;
|
|
77
|
+
}
|
|
78
|
+
declare const PeerOptionsAgentSubscribeModeEnum: {
|
|
79
|
+
readonly Auto: "auto";
|
|
80
|
+
readonly Manual: "manual";
|
|
81
|
+
};
|
|
82
|
+
type PeerOptionsAgentSubscribeModeEnum = typeof PeerOptionsAgentSubscribeModeEnum[keyof typeof PeerOptionsAgentSubscribeModeEnum];
|
|
83
|
+
/**
|
|
84
|
+
* Output audio options
|
|
85
|
+
* @export
|
|
86
|
+
* @interface PeerOptionsAgentOutput
|
|
87
|
+
*/
|
|
88
|
+
interface PeerOptionsAgentOutput {
|
|
89
|
+
/**
|
|
90
|
+
* The format of the output audio
|
|
91
|
+
* @type {string}
|
|
92
|
+
* @memberof PeerOptionsAgentOutput
|
|
93
|
+
*/
|
|
94
|
+
'audioFormat'?: PeerOptionsAgentOutputAudioFormatEnum;
|
|
95
|
+
/**
|
|
96
|
+
* The sample rate of the output audio
|
|
97
|
+
* @type {number}
|
|
98
|
+
* @memberof PeerOptionsAgentOutput
|
|
99
|
+
*/
|
|
100
|
+
'audioSampleRate'?: PeerOptionsAgentOutputAudioSampleRateEnum;
|
|
101
|
+
}
|
|
102
|
+
declare const PeerOptionsAgentOutputAudioFormatEnum: {
|
|
103
|
+
readonly Pcm16: "pcm16";
|
|
104
|
+
};
|
|
105
|
+
type PeerOptionsAgentOutputAudioFormatEnum = typeof PeerOptionsAgentOutputAudioFormatEnum[keyof typeof PeerOptionsAgentOutputAudioFormatEnum];
|
|
106
|
+
declare const PeerOptionsAgentOutputAudioSampleRateEnum: {
|
|
107
|
+
readonly NUMBER_16000: 16000;
|
|
108
|
+
readonly NUMBER_24000: 24000;
|
|
109
|
+
};
|
|
110
|
+
type PeerOptionsAgentOutputAudioSampleRateEnum = typeof PeerOptionsAgentOutputAudioSampleRateEnum[keyof typeof PeerOptionsAgentOutputAudioSampleRateEnum];
|
|
53
111
|
/**
|
|
54
112
|
* Options specific to the WebRTC peer
|
|
55
113
|
* @export
|
|
@@ -71,12 +129,17 @@ interface PeerOptionsWebRTC {
|
|
|
71
129
|
[key: string]: any;
|
|
72
130
|
};
|
|
73
131
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @type {
|
|
132
|
+
* Configuration of peer\'s subscribing policy
|
|
133
|
+
* @type {string}
|
|
76
134
|
* @memberof PeerOptionsWebRTC
|
|
77
135
|
*/
|
|
78
|
-
'
|
|
136
|
+
'subscribeMode'?: PeerOptionsWebRTCSubscribeModeEnum;
|
|
79
137
|
}
|
|
138
|
+
declare const PeerOptionsWebRTCSubscribeModeEnum: {
|
|
139
|
+
readonly Auto: "auto";
|
|
140
|
+
readonly Manual: "manual";
|
|
141
|
+
};
|
|
142
|
+
type PeerOptionsWebRTCSubscribeModeEnum = typeof PeerOptionsWebRTCSubscribeModeEnum[keyof typeof PeerOptionsWebRTCSubscribeModeEnum];
|
|
80
143
|
/**
|
|
81
144
|
* Informs about the peer status
|
|
82
145
|
* @export
|
|
@@ -140,6 +203,7 @@ declare const RoomConfigRoomTypeEnum: {
|
|
|
140
203
|
readonly Broadcaster: "broadcaster";
|
|
141
204
|
readonly Livestream: "livestream";
|
|
142
205
|
readonly Conference: "conference";
|
|
206
|
+
readonly AudioOnlyLivestream: "audio_only_livestream";
|
|
143
207
|
};
|
|
144
208
|
type RoomConfigRoomTypeEnum = typeof RoomConfigRoomTypeEnum[keyof typeof RoomConfigRoomTypeEnum];
|
|
145
209
|
declare const RoomConfigVideoCodecEnum: {
|
|
@@ -161,69 +225,23 @@ interface StreamerToken {
|
|
|
161
225
|
'token': string;
|
|
162
226
|
}
|
|
163
227
|
/**
|
|
164
|
-
* Configuration of
|
|
165
|
-
* @export
|
|
166
|
-
* @interface SubscribeOptions
|
|
167
|
-
*/
|
|
168
|
-
interface SubscribeOptions {
|
|
169
|
-
/**
|
|
170
|
-
* The format of the output audio
|
|
171
|
-
* @type {string}
|
|
172
|
-
* @memberof SubscribeOptions
|
|
173
|
-
*/
|
|
174
|
-
'audioFormat'?: SubscribeOptionsAudioFormatEnum;
|
|
175
|
-
/**
|
|
176
|
-
* The sample rate of the output audio
|
|
177
|
-
* @type {number}
|
|
178
|
-
* @memberof SubscribeOptions
|
|
179
|
-
*/
|
|
180
|
-
'audioSampleRate'?: SubscribeOptionsAudioSampleRateEnum;
|
|
181
|
-
}
|
|
182
|
-
declare const SubscribeOptionsAudioFormatEnum: {
|
|
183
|
-
readonly Pcm16: "pcm16";
|
|
184
|
-
};
|
|
185
|
-
type SubscribeOptionsAudioFormatEnum = typeof SubscribeOptionsAudioFormatEnum[keyof typeof SubscribeOptionsAudioFormatEnum];
|
|
186
|
-
declare const SubscribeOptionsAudioSampleRateEnum: {
|
|
187
|
-
readonly NUMBER_16000: 16000;
|
|
188
|
-
readonly NUMBER_24000: 24000;
|
|
189
|
-
};
|
|
190
|
-
type SubscribeOptionsAudioSampleRateEnum = typeof SubscribeOptionsAudioSampleRateEnum[keyof typeof SubscribeOptionsAudioSampleRateEnum];
|
|
191
|
-
/**
|
|
192
|
-
* Configuration of server-side subscriptions to the peer\'s tracks
|
|
228
|
+
* Configuration of peer\'s subscribing policy
|
|
193
229
|
* @export
|
|
194
|
-
* @
|
|
230
|
+
* @enum {string}
|
|
195
231
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
* @type {string}
|
|
200
|
-
* @memberof SubscribeOptions1
|
|
201
|
-
*/
|
|
202
|
-
'audioFormat'?: SubscribeOptions1AudioFormatEnum;
|
|
203
|
-
/**
|
|
204
|
-
* The sample rate of the output audio
|
|
205
|
-
* @type {number}
|
|
206
|
-
* @memberof SubscribeOptions1
|
|
207
|
-
*/
|
|
208
|
-
'audioSampleRate'?: SubscribeOptions1AudioSampleRateEnum;
|
|
209
|
-
}
|
|
210
|
-
declare const SubscribeOptions1AudioFormatEnum: {
|
|
211
|
-
readonly Pcm16: "pcm16";
|
|
212
|
-
};
|
|
213
|
-
type SubscribeOptions1AudioFormatEnum = typeof SubscribeOptions1AudioFormatEnum[keyof typeof SubscribeOptions1AudioFormatEnum];
|
|
214
|
-
declare const SubscribeOptions1AudioSampleRateEnum: {
|
|
215
|
-
readonly NUMBER_16000: 16000;
|
|
216
|
-
readonly NUMBER_24000: 24000;
|
|
232
|
+
declare const SubscribeMode: {
|
|
233
|
+
readonly Auto: "auto";
|
|
234
|
+
readonly Manual: "manual";
|
|
217
235
|
};
|
|
218
|
-
type
|
|
236
|
+
type SubscribeMode = typeof SubscribeMode[keyof typeof SubscribeMode];
|
|
219
237
|
/**
|
|
220
|
-
* Describes media track of a Peer
|
|
238
|
+
* Describes media track of a Peer
|
|
221
239
|
* @export
|
|
222
240
|
* @interface Track
|
|
223
241
|
*/
|
|
224
242
|
interface Track$1 {
|
|
225
243
|
/**
|
|
226
|
-
*
|
|
244
|
+
* Assigned track id
|
|
227
245
|
* @type {string}
|
|
228
246
|
* @memberof Track
|
|
229
247
|
*/
|
|
@@ -327,10 +345,14 @@ interface ServerMessage {
|
|
|
327
345
|
trackMetadataUpdated?: ServerMessage_TrackMetadataUpdated | undefined;
|
|
328
346
|
peerAdded?: ServerMessage_PeerAdded | undefined;
|
|
329
347
|
peerDeleted?: ServerMessage_PeerDeleted | undefined;
|
|
348
|
+
/** @deprecated */
|
|
330
349
|
streamConnected?: ServerMessage_StreamConnected | undefined;
|
|
350
|
+
/** @deprecated */
|
|
331
351
|
streamDisconnected?: ServerMessage_StreamDisconnected | undefined;
|
|
332
352
|
viewerConnected?: ServerMessage_ViewerConnected | undefined;
|
|
333
353
|
viewerDisconnected?: ServerMessage_ViewerDisconnected | undefined;
|
|
354
|
+
streamerConnected?: ServerMessage_StreamerConnected | undefined;
|
|
355
|
+
streamerDisconnected?: ServerMessage_StreamerDisconnected | undefined;
|
|
334
356
|
}
|
|
335
357
|
declare const ServerMessage: MessageFns$1<ServerMessage>;
|
|
336
358
|
/** Notification sent when a room crashes */
|
|
@@ -479,6 +501,16 @@ interface ServerMessage_ViewerDisconnected {
|
|
|
479
501
|
viewerId: string;
|
|
480
502
|
}
|
|
481
503
|
declare const ServerMessage_ViewerDisconnected: MessageFns$1<ServerMessage_ViewerDisconnected>;
|
|
504
|
+
interface ServerMessage_StreamerConnected {
|
|
505
|
+
streamId: string;
|
|
506
|
+
streamerId: string;
|
|
507
|
+
}
|
|
508
|
+
declare const ServerMessage_StreamerConnected: MessageFns$1<ServerMessage_StreamerConnected>;
|
|
509
|
+
interface ServerMessage_StreamerDisconnected {
|
|
510
|
+
streamId: string;
|
|
511
|
+
streamerId: string;
|
|
512
|
+
}
|
|
513
|
+
declare const ServerMessage_StreamerDisconnected: MessageFns$1<ServerMessage_StreamerDisconnected>;
|
|
482
514
|
type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
483
515
|
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 {} ? {
|
|
484
516
|
[K in keyof T]?: DeepPartial$1<T[K]>;
|
|
@@ -606,12 +638,15 @@ type Room = {
|
|
|
606
638
|
config: RoomConfig;
|
|
607
639
|
};
|
|
608
640
|
type FishjamConfig = {
|
|
609
|
-
fishjamId
|
|
610
|
-
fishjamUrl?: string;
|
|
641
|
+
fishjamId: string;
|
|
611
642
|
managementToken: string;
|
|
612
643
|
};
|
|
613
644
|
type ErrorEventHandler = (msg: Event) => void;
|
|
614
645
|
type CloseEventHandler = (code: number, reason: string) => void;
|
|
646
|
+
type AgentCallbacks = {
|
|
647
|
+
onError?: ErrorEventHandler;
|
|
648
|
+
onClose?: CloseEventHandler;
|
|
649
|
+
};
|
|
615
650
|
|
|
616
651
|
type WithRoomId<T> = {
|
|
617
652
|
[P in keyof T]: NonNullable<T[P]> extends {
|
|
@@ -682,7 +717,9 @@ type IncomingTrackData = Omit<NonNullable<AgentResponse_TrackData>, 'peerId'> &
|
|
|
682
717
|
type OutgoingTrackData = Omit<NonNullable<AgentRequest_TrackData>, 'peerId'> & {
|
|
683
718
|
peerId: PeerId;
|
|
684
719
|
};
|
|
685
|
-
type AgentTrack = Track
|
|
720
|
+
type AgentTrack = Omit<Track, 'id'> & {
|
|
721
|
+
id: TrackId;
|
|
722
|
+
};
|
|
686
723
|
type TrackType = 'audio' | 'video';
|
|
687
724
|
type AudioCodecParameters = {
|
|
688
725
|
encoding: 'opus' | 'pcm16';
|
|
@@ -700,12 +737,21 @@ type AgentEvents = {
|
|
|
700
737
|
declare const FishjamAgent_base: new () => TypedEventEmitter<AgentEvents>;
|
|
701
738
|
declare class FishjamAgent extends FishjamAgent_base {
|
|
702
739
|
private readonly client;
|
|
703
|
-
constructor(config: FishjamConfig, agentToken: string,
|
|
740
|
+
constructor(config: FishjamConfig, agentToken: string, callbacks?: AgentCallbacks);
|
|
704
741
|
/**
|
|
705
742
|
* Creates an outgoing audio track for the agent
|
|
706
743
|
* @returns a new audio track
|
|
707
744
|
*/
|
|
708
745
|
createTrack(codecParameters: AudioCodecParameters, metadata?: object): AgentTrack;
|
|
746
|
+
/**
|
|
747
|
+
* Interrupt track indentified by `trackId`.
|
|
748
|
+
*
|
|
749
|
+
* Any audio that has been sent by the agent, but not played
|
|
750
|
+
* by Fishjam will be cleared and be prevented from playing.
|
|
751
|
+
*
|
|
752
|
+
* Audio sent after the interrupt will be played normally.
|
|
753
|
+
*/
|
|
754
|
+
interruptTrack(trackId: TrackId): void;
|
|
709
755
|
/**
|
|
710
756
|
* Deletes an outgoing audio track for the agent
|
|
711
757
|
*/
|
|
@@ -714,6 +760,7 @@ declare class FishjamAgent extends FishjamAgent_base {
|
|
|
714
760
|
* Send audio data for the given track
|
|
715
761
|
*/
|
|
716
762
|
sendData(trackId: TrackId, data: Uint8Array): void;
|
|
763
|
+
disconnect(): void;
|
|
717
764
|
private dispatchNotification;
|
|
718
765
|
private setupConnection;
|
|
719
766
|
private isExpectedEvent;
|
|
@@ -721,7 +768,7 @@ declare class FishjamAgent extends FishjamAgent_base {
|
|
|
721
768
|
|
|
722
769
|
/**
|
|
723
770
|
* Client class that allows to manage Rooms and Peers for a Fishjam App.
|
|
724
|
-
* It requires the Fishjam
|
|
771
|
+
* It requires the Fishjam ID and management token that can be retrieved from the Fishjam Dashboard.
|
|
725
772
|
* @category Client
|
|
726
773
|
*/
|
|
727
774
|
declare class FishjamClient {
|
|
@@ -735,7 +782,7 @@ declare class FishjamClient {
|
|
|
735
782
|
* Example usage:
|
|
736
783
|
* ```
|
|
737
784
|
* const fishjamClient = new FishjamClient({
|
|
738
|
-
*
|
|
785
|
+
* fishjamId: fastify.config.FISHJAM_ID,
|
|
739
786
|
* managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
|
|
740
787
|
* });
|
|
741
788
|
* ```
|
|
@@ -756,14 +803,14 @@ declare class FishjamClient {
|
|
|
756
803
|
/**
|
|
757
804
|
* Create a new peer assigned to a room.
|
|
758
805
|
*/
|
|
759
|
-
createPeer(roomId: RoomId, options?:
|
|
806
|
+
createPeer(roomId: RoomId, options?: PeerOptionsWebRTC): Promise<{
|
|
760
807
|
peer: Peer;
|
|
761
808
|
peerToken: string;
|
|
762
809
|
}>;
|
|
763
810
|
/**
|
|
764
811
|
* Create a new agent assigned to a room.
|
|
765
812
|
*/
|
|
766
|
-
createAgent(roomId: RoomId, options
|
|
813
|
+
createAgent(roomId: RoomId, options?: PeerOptionsAgent, callbacks?: AgentCallbacks): Promise<{
|
|
767
814
|
agent: FishjamAgent;
|
|
768
815
|
peer: Peer;
|
|
769
816
|
}>;
|
|
@@ -775,6 +822,16 @@ declare class FishjamClient {
|
|
|
775
822
|
* Delete a peer - this will also disconnect the peer from the room.
|
|
776
823
|
*/
|
|
777
824
|
deletePeer(roomId: RoomId, peerId: PeerId): Promise<void>;
|
|
825
|
+
/**
|
|
826
|
+
* Subscribe a peer to another peer - this will make all tracks from the publisher available to the subscriber.
|
|
827
|
+
* Using this function only makes sense if subscribeMode is set to manual
|
|
828
|
+
*/
|
|
829
|
+
subscribePeer(roomId: RoomId, subscriberPeerId: PeerId, publisherPeerId: PeerId): Promise<void>;
|
|
830
|
+
/**
|
|
831
|
+
* Subscribe a peer to specific tracks from another peer - this will make only the specified tracks from the publisher available to the subscriber.
|
|
832
|
+
* Using this function only makes sense if subscribeMode is set to manual
|
|
833
|
+
*/
|
|
834
|
+
subscribeTracks(roomId: RoomId, subscriberPeerId: PeerId, tracks: TrackId[]): Promise<void>;
|
|
778
835
|
/**
|
|
779
836
|
* Refresh the peer token for an already existing peer.
|
|
780
837
|
* If an already created peer has not been connected to the room for more than 24 hours, the token will become invalid. This method can be used to generate a new peer token for the existing peer.
|
|
@@ -819,4 +876,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
|
|
|
819
876
|
declare class UnknownException extends FishjamBaseException {
|
|
820
877
|
}
|
|
821
878
|
|
|
822
|
-
export { type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
|
879
|
+
export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,10 +27,16 @@ interface Peer$1 {
|
|
|
27
27
|
'status': PeerStatus;
|
|
28
28
|
/**
|
|
29
29
|
*
|
|
30
|
-
* @type {
|
|
30
|
+
* @type {SubscribeMode}
|
|
31
31
|
* @memberof Peer
|
|
32
32
|
*/
|
|
33
|
-
'
|
|
33
|
+
'subscribeMode': SubscribeMode;
|
|
34
|
+
/**
|
|
35
|
+
* Describes peer\'s subscriptions in manual mode
|
|
36
|
+
* @type {Array<string>}
|
|
37
|
+
* @memberof Peer
|
|
38
|
+
*/
|
|
39
|
+
'subscriptions': Array<string>;
|
|
34
40
|
/**
|
|
35
41
|
* List of all peer\'s tracks
|
|
36
42
|
* @type {Array<Track>}
|
|
@@ -49,7 +55,59 @@ interface Peer$1 {
|
|
|
49
55
|
* Peer-specific options
|
|
50
56
|
* @export
|
|
51
57
|
*/
|
|
52
|
-
type PeerOptions =
|
|
58
|
+
type PeerOptions = PeerOptionsAgent | PeerOptionsWebRTC;
|
|
59
|
+
/**
|
|
60
|
+
* Options specific to the Agent peer
|
|
61
|
+
* @export
|
|
62
|
+
* @interface PeerOptionsAgent
|
|
63
|
+
*/
|
|
64
|
+
interface PeerOptionsAgent {
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @type {PeerOptionsAgentOutput}
|
|
68
|
+
* @memberof PeerOptionsAgent
|
|
69
|
+
*/
|
|
70
|
+
'output'?: PeerOptionsAgentOutput;
|
|
71
|
+
/**
|
|
72
|
+
* Configuration of peer\'s subscribing policy
|
|
73
|
+
* @type {string}
|
|
74
|
+
* @memberof PeerOptionsAgent
|
|
75
|
+
*/
|
|
76
|
+
'subscribeMode'?: PeerOptionsAgentSubscribeModeEnum;
|
|
77
|
+
}
|
|
78
|
+
declare const PeerOptionsAgentSubscribeModeEnum: {
|
|
79
|
+
readonly Auto: "auto";
|
|
80
|
+
readonly Manual: "manual";
|
|
81
|
+
};
|
|
82
|
+
type PeerOptionsAgentSubscribeModeEnum = typeof PeerOptionsAgentSubscribeModeEnum[keyof typeof PeerOptionsAgentSubscribeModeEnum];
|
|
83
|
+
/**
|
|
84
|
+
* Output audio options
|
|
85
|
+
* @export
|
|
86
|
+
* @interface PeerOptionsAgentOutput
|
|
87
|
+
*/
|
|
88
|
+
interface PeerOptionsAgentOutput {
|
|
89
|
+
/**
|
|
90
|
+
* The format of the output audio
|
|
91
|
+
* @type {string}
|
|
92
|
+
* @memberof PeerOptionsAgentOutput
|
|
93
|
+
*/
|
|
94
|
+
'audioFormat'?: PeerOptionsAgentOutputAudioFormatEnum;
|
|
95
|
+
/**
|
|
96
|
+
* The sample rate of the output audio
|
|
97
|
+
* @type {number}
|
|
98
|
+
* @memberof PeerOptionsAgentOutput
|
|
99
|
+
*/
|
|
100
|
+
'audioSampleRate'?: PeerOptionsAgentOutputAudioSampleRateEnum;
|
|
101
|
+
}
|
|
102
|
+
declare const PeerOptionsAgentOutputAudioFormatEnum: {
|
|
103
|
+
readonly Pcm16: "pcm16";
|
|
104
|
+
};
|
|
105
|
+
type PeerOptionsAgentOutputAudioFormatEnum = typeof PeerOptionsAgentOutputAudioFormatEnum[keyof typeof PeerOptionsAgentOutputAudioFormatEnum];
|
|
106
|
+
declare const PeerOptionsAgentOutputAudioSampleRateEnum: {
|
|
107
|
+
readonly NUMBER_16000: 16000;
|
|
108
|
+
readonly NUMBER_24000: 24000;
|
|
109
|
+
};
|
|
110
|
+
type PeerOptionsAgentOutputAudioSampleRateEnum = typeof PeerOptionsAgentOutputAudioSampleRateEnum[keyof typeof PeerOptionsAgentOutputAudioSampleRateEnum];
|
|
53
111
|
/**
|
|
54
112
|
* Options specific to the WebRTC peer
|
|
55
113
|
* @export
|
|
@@ -71,12 +129,17 @@ interface PeerOptionsWebRTC {
|
|
|
71
129
|
[key: string]: any;
|
|
72
130
|
};
|
|
73
131
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @type {
|
|
132
|
+
* Configuration of peer\'s subscribing policy
|
|
133
|
+
* @type {string}
|
|
76
134
|
* @memberof PeerOptionsWebRTC
|
|
77
135
|
*/
|
|
78
|
-
'
|
|
136
|
+
'subscribeMode'?: PeerOptionsWebRTCSubscribeModeEnum;
|
|
79
137
|
}
|
|
138
|
+
declare const PeerOptionsWebRTCSubscribeModeEnum: {
|
|
139
|
+
readonly Auto: "auto";
|
|
140
|
+
readonly Manual: "manual";
|
|
141
|
+
};
|
|
142
|
+
type PeerOptionsWebRTCSubscribeModeEnum = typeof PeerOptionsWebRTCSubscribeModeEnum[keyof typeof PeerOptionsWebRTCSubscribeModeEnum];
|
|
80
143
|
/**
|
|
81
144
|
* Informs about the peer status
|
|
82
145
|
* @export
|
|
@@ -140,6 +203,7 @@ declare const RoomConfigRoomTypeEnum: {
|
|
|
140
203
|
readonly Broadcaster: "broadcaster";
|
|
141
204
|
readonly Livestream: "livestream";
|
|
142
205
|
readonly Conference: "conference";
|
|
206
|
+
readonly AudioOnlyLivestream: "audio_only_livestream";
|
|
143
207
|
};
|
|
144
208
|
type RoomConfigRoomTypeEnum = typeof RoomConfigRoomTypeEnum[keyof typeof RoomConfigRoomTypeEnum];
|
|
145
209
|
declare const RoomConfigVideoCodecEnum: {
|
|
@@ -161,69 +225,23 @@ interface StreamerToken {
|
|
|
161
225
|
'token': string;
|
|
162
226
|
}
|
|
163
227
|
/**
|
|
164
|
-
* Configuration of
|
|
165
|
-
* @export
|
|
166
|
-
* @interface SubscribeOptions
|
|
167
|
-
*/
|
|
168
|
-
interface SubscribeOptions {
|
|
169
|
-
/**
|
|
170
|
-
* The format of the output audio
|
|
171
|
-
* @type {string}
|
|
172
|
-
* @memberof SubscribeOptions
|
|
173
|
-
*/
|
|
174
|
-
'audioFormat'?: SubscribeOptionsAudioFormatEnum;
|
|
175
|
-
/**
|
|
176
|
-
* The sample rate of the output audio
|
|
177
|
-
* @type {number}
|
|
178
|
-
* @memberof SubscribeOptions
|
|
179
|
-
*/
|
|
180
|
-
'audioSampleRate'?: SubscribeOptionsAudioSampleRateEnum;
|
|
181
|
-
}
|
|
182
|
-
declare const SubscribeOptionsAudioFormatEnum: {
|
|
183
|
-
readonly Pcm16: "pcm16";
|
|
184
|
-
};
|
|
185
|
-
type SubscribeOptionsAudioFormatEnum = typeof SubscribeOptionsAudioFormatEnum[keyof typeof SubscribeOptionsAudioFormatEnum];
|
|
186
|
-
declare const SubscribeOptionsAudioSampleRateEnum: {
|
|
187
|
-
readonly NUMBER_16000: 16000;
|
|
188
|
-
readonly NUMBER_24000: 24000;
|
|
189
|
-
};
|
|
190
|
-
type SubscribeOptionsAudioSampleRateEnum = typeof SubscribeOptionsAudioSampleRateEnum[keyof typeof SubscribeOptionsAudioSampleRateEnum];
|
|
191
|
-
/**
|
|
192
|
-
* Configuration of server-side subscriptions to the peer\'s tracks
|
|
228
|
+
* Configuration of peer\'s subscribing policy
|
|
193
229
|
* @export
|
|
194
|
-
* @
|
|
230
|
+
* @enum {string}
|
|
195
231
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
* @type {string}
|
|
200
|
-
* @memberof SubscribeOptions1
|
|
201
|
-
*/
|
|
202
|
-
'audioFormat'?: SubscribeOptions1AudioFormatEnum;
|
|
203
|
-
/**
|
|
204
|
-
* The sample rate of the output audio
|
|
205
|
-
* @type {number}
|
|
206
|
-
* @memberof SubscribeOptions1
|
|
207
|
-
*/
|
|
208
|
-
'audioSampleRate'?: SubscribeOptions1AudioSampleRateEnum;
|
|
209
|
-
}
|
|
210
|
-
declare const SubscribeOptions1AudioFormatEnum: {
|
|
211
|
-
readonly Pcm16: "pcm16";
|
|
212
|
-
};
|
|
213
|
-
type SubscribeOptions1AudioFormatEnum = typeof SubscribeOptions1AudioFormatEnum[keyof typeof SubscribeOptions1AudioFormatEnum];
|
|
214
|
-
declare const SubscribeOptions1AudioSampleRateEnum: {
|
|
215
|
-
readonly NUMBER_16000: 16000;
|
|
216
|
-
readonly NUMBER_24000: 24000;
|
|
232
|
+
declare const SubscribeMode: {
|
|
233
|
+
readonly Auto: "auto";
|
|
234
|
+
readonly Manual: "manual";
|
|
217
235
|
};
|
|
218
|
-
type
|
|
236
|
+
type SubscribeMode = typeof SubscribeMode[keyof typeof SubscribeMode];
|
|
219
237
|
/**
|
|
220
|
-
* Describes media track of a Peer
|
|
238
|
+
* Describes media track of a Peer
|
|
221
239
|
* @export
|
|
222
240
|
* @interface Track
|
|
223
241
|
*/
|
|
224
242
|
interface Track$1 {
|
|
225
243
|
/**
|
|
226
|
-
*
|
|
244
|
+
* Assigned track id
|
|
227
245
|
* @type {string}
|
|
228
246
|
* @memberof Track
|
|
229
247
|
*/
|
|
@@ -327,10 +345,14 @@ interface ServerMessage {
|
|
|
327
345
|
trackMetadataUpdated?: ServerMessage_TrackMetadataUpdated | undefined;
|
|
328
346
|
peerAdded?: ServerMessage_PeerAdded | undefined;
|
|
329
347
|
peerDeleted?: ServerMessage_PeerDeleted | undefined;
|
|
348
|
+
/** @deprecated */
|
|
330
349
|
streamConnected?: ServerMessage_StreamConnected | undefined;
|
|
350
|
+
/** @deprecated */
|
|
331
351
|
streamDisconnected?: ServerMessage_StreamDisconnected | undefined;
|
|
332
352
|
viewerConnected?: ServerMessage_ViewerConnected | undefined;
|
|
333
353
|
viewerDisconnected?: ServerMessage_ViewerDisconnected | undefined;
|
|
354
|
+
streamerConnected?: ServerMessage_StreamerConnected | undefined;
|
|
355
|
+
streamerDisconnected?: ServerMessage_StreamerDisconnected | undefined;
|
|
334
356
|
}
|
|
335
357
|
declare const ServerMessage: MessageFns$1<ServerMessage>;
|
|
336
358
|
/** Notification sent when a room crashes */
|
|
@@ -479,6 +501,16 @@ interface ServerMessage_ViewerDisconnected {
|
|
|
479
501
|
viewerId: string;
|
|
480
502
|
}
|
|
481
503
|
declare const ServerMessage_ViewerDisconnected: MessageFns$1<ServerMessage_ViewerDisconnected>;
|
|
504
|
+
interface ServerMessage_StreamerConnected {
|
|
505
|
+
streamId: string;
|
|
506
|
+
streamerId: string;
|
|
507
|
+
}
|
|
508
|
+
declare const ServerMessage_StreamerConnected: MessageFns$1<ServerMessage_StreamerConnected>;
|
|
509
|
+
interface ServerMessage_StreamerDisconnected {
|
|
510
|
+
streamId: string;
|
|
511
|
+
streamerId: string;
|
|
512
|
+
}
|
|
513
|
+
declare const ServerMessage_StreamerDisconnected: MessageFns$1<ServerMessage_StreamerDisconnected>;
|
|
482
514
|
type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
483
515
|
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 {} ? {
|
|
484
516
|
[K in keyof T]?: DeepPartial$1<T[K]>;
|
|
@@ -606,12 +638,15 @@ type Room = {
|
|
|
606
638
|
config: RoomConfig;
|
|
607
639
|
};
|
|
608
640
|
type FishjamConfig = {
|
|
609
|
-
fishjamId
|
|
610
|
-
fishjamUrl?: string;
|
|
641
|
+
fishjamId: string;
|
|
611
642
|
managementToken: string;
|
|
612
643
|
};
|
|
613
644
|
type ErrorEventHandler = (msg: Event) => void;
|
|
614
645
|
type CloseEventHandler = (code: number, reason: string) => void;
|
|
646
|
+
type AgentCallbacks = {
|
|
647
|
+
onError?: ErrorEventHandler;
|
|
648
|
+
onClose?: CloseEventHandler;
|
|
649
|
+
};
|
|
615
650
|
|
|
616
651
|
type WithRoomId<T> = {
|
|
617
652
|
[P in keyof T]: NonNullable<T[P]> extends {
|
|
@@ -682,7 +717,9 @@ type IncomingTrackData = Omit<NonNullable<AgentResponse_TrackData>, 'peerId'> &
|
|
|
682
717
|
type OutgoingTrackData = Omit<NonNullable<AgentRequest_TrackData>, 'peerId'> & {
|
|
683
718
|
peerId: PeerId;
|
|
684
719
|
};
|
|
685
|
-
type AgentTrack = Track
|
|
720
|
+
type AgentTrack = Omit<Track, 'id'> & {
|
|
721
|
+
id: TrackId;
|
|
722
|
+
};
|
|
686
723
|
type TrackType = 'audio' | 'video';
|
|
687
724
|
type AudioCodecParameters = {
|
|
688
725
|
encoding: 'opus' | 'pcm16';
|
|
@@ -700,12 +737,21 @@ type AgentEvents = {
|
|
|
700
737
|
declare const FishjamAgent_base: new () => TypedEventEmitter<AgentEvents>;
|
|
701
738
|
declare class FishjamAgent extends FishjamAgent_base {
|
|
702
739
|
private readonly client;
|
|
703
|
-
constructor(config: FishjamConfig, agentToken: string,
|
|
740
|
+
constructor(config: FishjamConfig, agentToken: string, callbacks?: AgentCallbacks);
|
|
704
741
|
/**
|
|
705
742
|
* Creates an outgoing audio track for the agent
|
|
706
743
|
* @returns a new audio track
|
|
707
744
|
*/
|
|
708
745
|
createTrack(codecParameters: AudioCodecParameters, metadata?: object): AgentTrack;
|
|
746
|
+
/**
|
|
747
|
+
* Interrupt track indentified by `trackId`.
|
|
748
|
+
*
|
|
749
|
+
* Any audio that has been sent by the agent, but not played
|
|
750
|
+
* by Fishjam will be cleared and be prevented from playing.
|
|
751
|
+
*
|
|
752
|
+
* Audio sent after the interrupt will be played normally.
|
|
753
|
+
*/
|
|
754
|
+
interruptTrack(trackId: TrackId): void;
|
|
709
755
|
/**
|
|
710
756
|
* Deletes an outgoing audio track for the agent
|
|
711
757
|
*/
|
|
@@ -714,6 +760,7 @@ declare class FishjamAgent extends FishjamAgent_base {
|
|
|
714
760
|
* Send audio data for the given track
|
|
715
761
|
*/
|
|
716
762
|
sendData(trackId: TrackId, data: Uint8Array): void;
|
|
763
|
+
disconnect(): void;
|
|
717
764
|
private dispatchNotification;
|
|
718
765
|
private setupConnection;
|
|
719
766
|
private isExpectedEvent;
|
|
@@ -721,7 +768,7 @@ declare class FishjamAgent extends FishjamAgent_base {
|
|
|
721
768
|
|
|
722
769
|
/**
|
|
723
770
|
* Client class that allows to manage Rooms and Peers for a Fishjam App.
|
|
724
|
-
* It requires the Fishjam
|
|
771
|
+
* It requires the Fishjam ID and management token that can be retrieved from the Fishjam Dashboard.
|
|
725
772
|
* @category Client
|
|
726
773
|
*/
|
|
727
774
|
declare class FishjamClient {
|
|
@@ -735,7 +782,7 @@ declare class FishjamClient {
|
|
|
735
782
|
* Example usage:
|
|
736
783
|
* ```
|
|
737
784
|
* const fishjamClient = new FishjamClient({
|
|
738
|
-
*
|
|
785
|
+
* fishjamId: fastify.config.FISHJAM_ID,
|
|
739
786
|
* managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
|
|
740
787
|
* });
|
|
741
788
|
* ```
|
|
@@ -756,14 +803,14 @@ declare class FishjamClient {
|
|
|
756
803
|
/**
|
|
757
804
|
* Create a new peer assigned to a room.
|
|
758
805
|
*/
|
|
759
|
-
createPeer(roomId: RoomId, options?:
|
|
806
|
+
createPeer(roomId: RoomId, options?: PeerOptionsWebRTC): Promise<{
|
|
760
807
|
peer: Peer;
|
|
761
808
|
peerToken: string;
|
|
762
809
|
}>;
|
|
763
810
|
/**
|
|
764
811
|
* Create a new agent assigned to a room.
|
|
765
812
|
*/
|
|
766
|
-
createAgent(roomId: RoomId, options
|
|
813
|
+
createAgent(roomId: RoomId, options?: PeerOptionsAgent, callbacks?: AgentCallbacks): Promise<{
|
|
767
814
|
agent: FishjamAgent;
|
|
768
815
|
peer: Peer;
|
|
769
816
|
}>;
|
|
@@ -775,6 +822,16 @@ declare class FishjamClient {
|
|
|
775
822
|
* Delete a peer - this will also disconnect the peer from the room.
|
|
776
823
|
*/
|
|
777
824
|
deletePeer(roomId: RoomId, peerId: PeerId): Promise<void>;
|
|
825
|
+
/**
|
|
826
|
+
* Subscribe a peer to another peer - this will make all tracks from the publisher available to the subscriber.
|
|
827
|
+
* Using this function only makes sense if subscribeMode is set to manual
|
|
828
|
+
*/
|
|
829
|
+
subscribePeer(roomId: RoomId, subscriberPeerId: PeerId, publisherPeerId: PeerId): Promise<void>;
|
|
830
|
+
/**
|
|
831
|
+
* Subscribe a peer to specific tracks from another peer - this will make only the specified tracks from the publisher available to the subscriber.
|
|
832
|
+
* Using this function only makes sense if subscribeMode is set to manual
|
|
833
|
+
*/
|
|
834
|
+
subscribeTracks(roomId: RoomId, subscriberPeerId: PeerId, tracks: TrackId[]): Promise<void>;
|
|
778
835
|
/**
|
|
779
836
|
* Refresh the peer token for an already existing peer.
|
|
780
837
|
* If an already created peer has not been connected to the room for more than 24 hours, the token will become invalid. This method can be used to generate a new peer token for the existing peer.
|
|
@@ -819,4 +876,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
|
|
|
819
876
|
declare class UnknownException extends FishjamBaseException {
|
|
820
877
|
}
|
|
821
878
|
|
|
822
|
-
export { type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
|
879
|
+
export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|