forked from zoom/rtms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtms.d.ts
More file actions
1358 lines (1255 loc) · 37.6 KB
/
rtms.d.ts
File metadata and controls
1358 lines (1255 loc) · 37.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Zoom Realtime Media Streams (RTMS) SDK
*
* The RTMS SDK provides access to real-time audio, video, and transcript data
* from Zoom meetings. It offers both class-based and singleton approaches for
* connecting to meetings.
*
* @packageDocumentation
* @module rtms
*/
/**
* Available log levels for RTMS SDK logging
*
* @category Common
*/
export enum LogLevel {
/** Error messages only */
ERROR = 0,
/** Error and warning messages */
WARN = 1,
/** Error, warning, and informational messages (default) */
INFO = 2,
/** All messages including debug information */
DEBUG = 3,
/** All messages including detailed trace information */
TRACE = 4
}
/**
* Available log output formats
*
* @category Common
*/
export enum LogFormat {
/** Human-readable progressive format for console output */
PROGRESSIVE = 'progressive',
/** Machine-readable JSON format for log processing */
JSON = 'json'
}
/**
* Configuration options for the RTMS logger
*
* @category Common
*/
export interface LoggerConfig {
/** The minimum log level to display */
level: LogLevel;
/** The format for log output */
format: LogFormat;
/** Whether logging is enabled */
enabled: boolean;
}
/**
* Media type flags that can be combined with bitwise OR (|)
*
* @example
* // Enable both audio and video, but not transcript
* const mediaTypes = rtms.MEDIA_TYPE_AUDIO | rtms.MEDIA_TYPE_VIDEO;
*
* @category Constants
*/
/** Flag to enable audio stream processing */
export const MEDIA_TYPE_AUDIO: number;
/** Flag to enable video stream processing */
export const MEDIA_TYPE_VIDEO: number;
/** Flag to enable desktop sharing stream processing */
export const MEDIA_TYPE_DESKSHARE: number;
/** Flag to enable transcript stream processing */
export const MEDIA_TYPE_TRANSCRIPT: number;
/** Flag to enable chat message processing */
export const MEDIA_TYPE_CHAT: number;
/** Flag to enable all supported media types */
export const MEDIA_TYPE_ALL: number;
/**
* Session event constants
*
* @category Constants
*/
/** Event constant indicating a session has been added */
export const SESSION_EVENT_ADD: number;
/** Event constant indicating a session has been stopped */
export const SESSION_EVENT_STOP: number;
/** Event constant indicating a session has been paused */
export const SESSION_EVENT_PAUSE: number;
/** Event constant indicating a session has been resumed */
export const SESSION_EVENT_RESUME: number;
/**
* User event constants
*
* @category Constants
*/
/** Event constant indicating a user has joined */
export const USER_EVENT_JOIN: number;
/** Event constant indicating a user has left */
export const USER_EVENT_LEAVE: number;
/**
* SDK status codes
*
* @category Constants
*/
/** Status code indicating an SDK operation failed */
export const RTMS_SDK_FAILURE: number;
/** Status code indicating an SDK operation succeeded */
export const RTMS_SDK_OK: number;
/** Status code indicating an SDK operation timed out */
export const RTMS_SDK_TIMEOUT: number;
/** Status code indicating a requested resource does not exist */
export const RTMS_SDK_NOT_EXIST: number;
/** Status code indicating an incorrect type was provided */
export const RTMS_SDK_WRONG_TYPE: number;
/** Status code indicating an invalid status */
export const RTMS_SDK_INVALID_STATUS: number;
/** Status code indicating invalid arguments were provided */
export const RTMS_SDK_INVALID_ARGS: number;
/**
* Session status constants
*
* @category Constants
*/
/** Session status indicating the session is active */
export const SESS_STATUS_ACTIVE: number;
/** Session status indicating the session is paused */
export const SESS_STATUS_PAUSED: number;
//-----------------------------------------------------------------------------------
// Data type interfaces
//-----------------------------------------------------------------------------------
/**
* Configuration options for media stream types to receive
*
* @category Common Interfaces
*/
export interface MediaTypes {
/** Whether to receive audio streams */
audio: boolean;
/** Whether to receive video streams */
video?: boolean;
/** Whether to receive transcript data */
transcript?: boolean;
}
/**
* Metadata information about a participant in a Zoom meeting
*
* @category Data Interfaces
*/
export interface Metadata {
/** The display name of the Zoom participant */
userName: string;
/** The user ID of the Zoom participant */
userId: number;
}
/**
* Information about a participant in a Zoom meeting
*
* @category Data Interfaces
*/
export interface ParticipantInfo {
/** The unique identifier for this participant */
id: number;
/** The display name of this participant */
name: string;
}
/**
* Information about a Zoom meeting session
*
* @category Data Interfaces
*/
export interface SessionInfo {
/** The unique identifier for this session */
sessionId: string;
/** The start time of this session (Unix timestamp) */
statTime: number;
/** The current status of this session (SESS_STATUS_*) */
status: number;
/** Whether this session is currently active */
isActive: boolean;
/** Whether this session is currently paused */
isPaused: boolean;
}
/**
* Configuration parameters for audio streams
*
* @category Media Configuration
*/
export interface AudioParams {
/** The type of audio content */
contentType?: number;
/** The audio codec to use */
codec?: number;
/** The sample rate SR_8K = 0, SR_16K = 1, SR_32K = 2, SR_48K = 3 */
sampleRate?: number;
/** The number of audio channels (1=mono, 2=stereo) */
channel?: number;
/** Additional data options for audio processing */
dataOpt?: number;
/** The duration of each audio frame in milliseconds */
duration?: number;
/** The size of each audio frame in samples */
frameSize?: number;
}
/**
* Configuration parameters for video streams
*
* @category Media Configuration
*/
export interface VideoParams {
/** The type of video content */
contentType?: number;
/** The video codec to use */
codec?: number;
/** The video resolution */
resolution?: number;
/** Additional data options for video processing */
dataOpt?: number;
/** The video frame rate (frames per second) */
fps?: number;
}
/**
* Configuration parameters for video streams
*
* @category Media Configuration
*/
export interface DeskshareParams {
/** The type of deskshare content */
contentType?: number;
/** The deskshare codec to use */
codec?: number;
/** The deskshare resolution */
resolution?: number;
/** The video frame rate (frames per second) */
fps?: number;
}
//-----------------------------------------------------------------------------------
// Parameter interfaces
//-----------------------------------------------------------------------------------
/**
* Parameters for joining a Zoom RTMS session
*
* @category Common Interfaces
*/
export interface JoinParams {
/** The UUID of the Zoom meeting */
meeting_uuid: string;
/** The RTMS stream ID for this connection */
rtms_stream_id: string;
/** The server URL(s) to connect to */
server_urls: string;
/** The authentication signature (optional if client and secret are provided) */
signature?: string;
/** The Zoom OAuth client ID (defaults to ZM_RTMS_CLIENT environment variable) */
client?: string;
/** The Zoom OAuth client secret (defaults to ZM_RTMS_SECRET environment variable) */
secret?: string;
/** The path to a CA certificate file (defaults to system CA) */
ca?: string;
/** The timeout for the join operation in milliseconds */
timeout?: number;
/** The interval between poll operations in milliseconds */
pollInterval?: number;
}
/**
* Parameters for generating an authentication signature
*
* @category Common Interfaces
*/
export interface SignatureParams {
/** The Zoom OAuth client ID */
client: string;
/** The Zoom OAuth client secret */
secret: string;
/** The UUID of the Zoom meeting */
uuid: string;
/** The RTMS stream ID for this connection */
streamId: string;
}
//-----------------------------------------------------------------------------------
// Callback types
//-----------------------------------------------------------------------------------
/**
* Callback function for processing webhook events
*
* @param payload The JSON payload of the webhook event
*
* @category Callback Types
*/
export type WebhookCallback = (payload: Record<string, any>) => void;
/**
* Callback function for when a join operation is confirmed
*
* @param reason The reason code for the join confirmation
*
* @category Callback Types
*/
export type JoinConfirmCallback = (reason: number) => void;
/**
* Callback function for session update events
*
* @param op The operation type (SESSION_EVENT_*)
* @param sessionInfo Information about the updated session
*
* @category Callback Types
*/
export type SessionUpdateCallback = (op: number, sessionInfo: SessionInfo) => void;
/**
* Callback function for user update events
*
* @param op The operation type (USER_EVENT_*)
* @param participantInfo Information about the updated participant
*
* @category Callback Types
*/
export type UserUpdateCallback = (op: number, participantInfo: ParticipantInfo) => void;
/**
* Callback function for receiving deskshare data
*
* @param buffer The raw deskshare data buffer
* @param size The size of the deskshare data in bytes
* @param timestamp The timestamp of the deskshare data
* @param metadata Metadata about the participant who sent the audio
*
* @category Callback Types
*/
export type DeskshareCallback = (buffer: Buffer, size: number, timestamp: number, metadata: Metadata) => void;
/**
* Callback function for receiving audio data
*
* @param buffer The raw audio data buffer
* @param size The size of the audio data in bytes
* @param timestamp The timestamp of the audio data
* @param metadata Metadata about the participant who sent the audio
*
* @category Callback Types
*/
export type AudioDataCallback = (buffer: Buffer, size: number, timestamp: number, metadata: Metadata) => void;
/**
* Callback function for receiving video data
*
* @param buffer The raw video data buffer
* @param size The size of the video data in bytes
* @param timestamp The timestamp of the video data
* @param metadata Metadata about the participant who sent the video
*
* @category Callback Types
*/
export type VideoDataCallback = (buffer: Buffer, size: number, timestamp: number, metadata: Metadata) => void;
/**
* Callback function for receiving transcript data
*
* @param buffer The raw transcript data buffer
* @param size The size of the transcript data in bytes
* @param timestamp The timestamp of the transcript data
* @param metadata Metadata about the participant who sent the transcript
*
* @category Callback Types
*/
export type TranscriptDataCallback = (buffer: Buffer, size: number, timestamp: number, metadata: Metadata) => void;
/**
* Callback function for leave events
*
* @param reason The reason code for the leave event
*
* @category Callback Types
*/
export type LeaveCallback = (reason: number) => void;
//-----------------------------------------------------------------------------------
// Client class
//-----------------------------------------------------------------------------------
/**
* RTMS Client: Core interface for connecting to Zoom real-time media streams
*
* The Client class provides the main interface for connecting to and processing
* Zoom RTMS streams. Use this approach when you need to:
* - Connect to multiple meetings simultaneously
* - Process different media types (audio, video, transcript)
* - Handle session and user events
*
* @example
* ```typescript
* import rtms from "@zoom/rtms";
*
* const client = new rtms.Client();
*
* // Set up event handlers
* client.onJoinConfirm((reason) => {
* console.log(`Join confirmed with reason: ${reason}`);
* });
*
* client.onAudioData((buffer, size, timestamp, metadata) => {
* console.log(`Received ${size} bytes of audio from ${metadata.userName}`);
* // Process audio data...
* });
*
* // Join the meeting
* client.join({
* meeting_uuid: "abc123-meeting-uuid",
* rtms_stream_id: "xyz789-stream-id",
* server_urls: "wss://rtms.zoom.us",
* pollInterval: 10 // milliseconds
* });
*
* // Later, leave the meeting
* client.leave();
* ```
*
* @category Client Instance
*/
export class Client {
/**
* Creates a new RTMS Client instance
*
* Each Client instance represents a connection to a single Zoom meeting.
* You can create multiple Client instances to connect to different meetings.
*/
constructor();
/**
* Initializes the RTMS SDK with the specified CA certificate path
*
* This static method must be called before creating any Client instances.
* It's automatically called by the join method if not already initialized.
*
* @param caPath Path to the CA certificate file (defaults to system CA)
* @returns true if initialization succeeds
*/
static initialize(caPath?: string): boolean;
/**
* Uninitializes the RTMS SDK and releases resources
*
* This static method should be called when you're done using the SDK.
* It releases all system resources allocated by the SDK.
*
* @returns true if uninitialization succeeds
*/
static uninitialize(): boolean;
/**
* Joins a Zoom RTMS session with parameters object
*
* This method establishes a connection to a Zoom RTMS stream.
* After joining, callback methods will be invoked as events occur.
*
* @param options An object containing join parameters
* @returns true if the join operation succeeds
*
* @example
* ```typescript
* client.join({
* meeting_uuid: "abc123-meeting-uuid",
* rtms_stream_id: "xyz789-stream-id",
* server_urls: "wss://rtms.zoom.us",
* pollInterval: 10
* });
* ```
*/
join(options: JoinParams): boolean;
/**
* Joins a Zoom RTMS session with individual parameters
*
* This method establishes a connection to a Zoom RTMS stream.
* After joining, callback methods will be invoked as events occur.
*
* @param meetingUuid The UUID of the Zoom meeting
* @param rtmsStreamId The RTMS stream ID for this connection
* @param signature The authentication signature
* @param serverUrls The server URL(s) to connect to
* @param timeout The timeout for the join operation in milliseconds
* @returns true if the join operation succeeds
*
* @example
* ```typescript
* // Generate signature
* const signature = rtms.generateSignature({
* client: "client_id",
* secret: "client_secret",
* uuid: "abc123-meeting-uuid",
* streamId: "xyz789-stream-id"
* });
*
* // Join with explicit parameters
* client.join(
* "abc123-meeting-uuid",
* "xyz789-stream-id",
* signature,
* "wss://rtms.zoom.us"
* );
* ```
*/
join(meetingUuid: string, rtmsStreamId: string, signature: string, serverUrls: string, timeout?: number): boolean;
/**
* Manually polls for events from the RTMS server
*
* This method is automatically called by the SDK's internal polling
* mechanism. You typically don't need to call this manually.
*
* @returns true if the poll operation succeeds
*/
poll(): boolean;
/**
* Releases client resources
*
* This method disconnects from the server and releases resources.
* It's automatically called by the leave method.
*
* @returns true if the release operation succeeds
*/
release(): boolean;
/**
* Leaves the current session and releases resources
*
* This method disconnects from the Zoom RTMS stream,
* stops background polling, and releases resources.
*
* @returns true if the leave operation succeeds
*
* @example
* ```typescript
* // Leave the meeting when done
* client.leave();
* ```
*/
leave(): boolean;
/**
* Gets the UUID of the current meeting
*
* @returns The meeting UUID
*/
uuid(): string;
/**
* Gets the stream ID of the current connection
*
* @returns The RTMS stream ID
*/
streamId(): string;
/**
* Sets audio parameters for the client
*
* This method configures audio processing parameters.
*
* @param params Audio parameters configuration
* @returns true if the operation succeeds
*/
setAudioParams(params: AudioParams): boolean;
/**
* Sets video parameters for the client
*
* This method configures video processing parameters.
*
* @param params Video parameters configuration
* @returns true if the operation succeeds
*/
setVideoParams(params: VideoParams): boolean;
/**
* Sets deskshare parameters for the client
*
* This method configures deskshare video processing parameters.
*
* @param params Deskshare parameter configuration
* @returns true if the operation succeeds
*/
setDeskshareParams(params: DeskshareParams): boolean;
/**
* Sets a callback for join confirmation events
*
* This callback is triggered when the join operation is confirmed by the server.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onJoinConfirm((reason) => {
* console.log(`Join confirmed with reason code: ${reason}`);
* // 0 = success, other values indicate specific error conditions
* });
* ```
*/
onJoinConfirm(callback: JoinConfirmCallback): boolean;
/**
* Sets a callback for session update events
*
* This callback is triggered when session information is updated.
* It provides details about session status changes (add, stop, pause, resume).
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onSessionUpdate((op, sessionInfo) => {
* // op = SESSION_EVENT_ADD, SESSION_EVENT_STOP, etc.
* console.log(`Session ${sessionInfo.sessionId} updated: ${op}`);
* console.log(`Status: ${sessionInfo.isActive ? 'active' : 'inactive'}`);
* });
* ```
*/
onSessionUpdate(callback: SessionUpdateCallback): boolean;
/**
* Sets a callback for user update events
*
* This callback is triggered when users join or leave the meeting.
* It provides information about the participant who joined or left.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onUserUpdate((op, participantInfo) => {
* // op = USER_EVENT_JOIN or USER_EVENT_LEAVE
* if (op === rtms.USER_EVENT_JOIN) {
* console.log(`User joined: ${participantInfo.name} (ID: ${participantInfo.id})`);
* } else {
* console.log(`User left: ${participantInfo.name} (ID: ${participantInfo.id})`);
* }
* });
* ```
*/
onUserUpdate(callback: UserUpdateCallback): boolean;
/**
* Sets a callback for receiving deskshare data
*
* This callback is triggered when data is received from the meeting.
* It provides the raw audio data buffer and metadata about the sender.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onDsData((buffer, size, timestamp, metadata) => {
* console.log(`Received ${size} bytes of deskshare data from ${metadata.userName}`);
*
* // Process the data
* // buffer - Raw deskshare data (Buffer)
* // size - Size of the deskshare data in bytes
* // timestamp - Timestamp of the deskshare data
* // metadata - Information about the sender
* });
* ```
*/
onDeskshareData(callback: DeskshareDataCallback): boolean;
/**
* Sets a callback for receiving audio data
*
* This callback is triggered when audio data is received from the meeting.
* It provides the raw audio data buffer and metadata about the sender.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onAudioData((buffer, size, timestamp, metadata) => {
* console.log(`Received ${size} bytes of audio from ${metadata.userName}`);
*
* // Process the audio data
* // buffer - Raw audio data (Buffer)
* // size - Size of the audio data in bytes
* // timestamp - Timestamp of the audio data
* // metadata - Information about the sender
* });
* ```
*/
onAudioData(callback: AudioDataCallback): boolean;
/**
* Sets a callback for receiving video data
*
* This callback is triggered when video data is received from the meeting.
* It provides the raw video data buffer, track ID, and metadata about the sender.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onVideoData((buffer, size, timestamp, trackId, metadata) => {
* console.log(`Received ${size} bytes of video from ${metadata.userName}`);
* console.log(`Track ID: ${trackId}`);
*
* // Process the video data
* // buffer - Raw video data (Buffer)
* // size - Size of the video data in bytes
* // timestamp - Timestamp of the video data
* // trackId - ID of the video track
* // metadata - Information about the sender
* });
* ```
*/
onVideoData(callback: VideoDataCallback): boolean;
/**
* Sets a callback for receiving transcript data
*
* This callback is triggered when transcript data is received from the meeting.
* It provides the raw transcript data buffer and metadata about the sender.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onTranscriptData((buffer, size, timestamp, metadata) => {
* // Convert buffer to string (assuming UTF-8 encoding)
* const text = buffer.toString('utf8');
* console.log(`Transcript from ${metadata.userName}: ${text}`);
* });
* ```
*/
onTranscriptData(callback: TranscriptDataCallback): boolean;
/**
* Sets a callback for leave events
*
* This callback is triggered when the client leaves the meeting,
* either voluntarily or due to an error.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* client.onLeave((reason) => {
* console.log(`Left meeting with reason code: ${reason}`);
* // Clean up resources or reconnect based on the reason code
* });
* ```
*/
onLeave(callback: LeaveCallback): boolean;
}
//-----------------------------------------------------------------------------------
// Singleton (global) functions
//-----------------------------------------------------------------------------------
/**
* Sets up a webhook server to receive events from Zoom
*
* This function creates an HTTP or HTTPS server that listens for webhook events from Zoom.
* When a webhook event is received, it parses the JSON payload and passes it to
* the provided callback function.
*
* For secure HTTPS connections, provide the following environment variables:
* - ZM_RTMS_CERT: Path to SSL certificate file
* - ZM_RTMS_KEY: Path to SSL certificate key file
* - ZM_RTMS_CA_WEBHOOK: (Optional) Path to CA certificate for client verification
*
* @param callback Function to call when webhook events are received
*
* @example
* ```typescript
* import rtms from '@zoom/rtms';
*
* // Set up the webhook listener (uses HTTPS if certificates are provided)
* rtms.onWebhookEvent(({event, payload}) => {
* if (event === "meeting.rtms.started") {
* console.log(`RTMS started for meeting: ${payload.meeting_uuid}`);
*
* // Create a dedicated client for this meeting
* const client = new rtms.Client();
*
* // Set up callbacks
* client.onAudioData((data, timestamp, metadata) => {
* console.log(`Received audio: ${data.length} bytes from ${metadata.userName}`);
* });
*
* // Join the meeting
* client.join(payload);
* }
* });
* ```
*
* @category Common Functions
*/
export function onWebhookEvent(callback: WebhookCallback): void;
/**
* Joins a Zoom RTMS session using the global client
*
* This function is part of the singleton API, which provides a simplified interface for
* connecting to a single Zoom meeting. It handles initialization and starts
* background polling for events.
*
* @param options An object containing join parameters
* @returns true if the join operation succeeds
*
* @example
* ```typescript
* // Join with parameters object
* rtms.join({
* meeting_uuid: "meeting_uuid_here",
* rtms_stream_id: "stream_id_here",
* server_urls: "wss://rtms.zoom.us",
* pollInterval: 10
* });
* ```
*
* @category Singleton API
*/
export function join(options: JoinParams): boolean;
/**
* Joins a Zoom RTMS session using the global client
*
* This function is part of the singleton API.
* It establishes a connection to a Zoom RTMS stream using the global client.
*
* @param meetingUuid The UUID of the Zoom meeting
* @param rtmsStreamId The RTMS stream ID for this connection
* @param signature The authentication signature
* @param serverUrls The server URL(s) to connect to
* @param timeout The timeout for the join operation in milliseconds
* @returns true if the join operation succeeds
*
* @example
* ```typescript
* // Generate signature
* const signature = rtms.generateSignature({
* client: "client_id",
* secret: "client_secret",
* uuid: "meeting_uuid",
* streamId: "stream_id"
* });
*
* // Join with explicit parameters
* rtms.join(
* "meeting_uuid",
* "stream_id",
* signature,
* "wss://rtms.zoom.us"
* );
* ```
*
* @category Singleton API
*/
export function join(meetingUuid: string, rtmsStreamId: string, signature: string, serverUrls: string, timeout?: number): boolean;
/**
* Leaves the current session and releases global client resources
*
* This function is part of the singleton API.
* It disconnects from the Zoom RTMS stream and releases resources.
*
* @returns true if the leave operation succeeds
*
* @example
* ```typescript
* // Leave the meeting when done
* rtms.leave();
* ```
*
* @category Singleton API
*/
export function leave(): boolean;
/**
* Manually polls for events from the RTMS server using the global client
*
* This function is part of the singleton API.
* It's automatically called by the SDK's internal polling mechanism.
*
* @returns true if the poll operation succeeds
*
* @category Singleton API
*/
export function poll(): boolean;
/**
* Gets the UUID of the current meeting from the global client
*
* This function is part of the singleton API.
*
* @returns The meeting UUID
*
* @category Singleton API
*/
export function uuid(): string;
/**
* Gets the stream ID of the current connection from the global client
*
* This function is part of the singleton API.
*
* @returns The RTMS stream ID
*
* @category Singleton API
*/
export function streamId(): string;
/**
* Sets a callback for join confirmation events on the global client
*
* This function is part of the singleton API.
* The callback is triggered when the join operation is confirmed by the server.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* rtms.onJoinConfirm((reason) => {
* console.log(`Join confirmed with reason code: ${reason}`);
* });
* ```
*
* @category Singleton API
*/
export function onJoinConfirm(callback: JoinConfirmCallback): boolean;
/**
* Sets a callback for session update events on the global client
*
* This function is part of the singleton API.
* The callback is triggered when session information is updated.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @category Singleton API
*/
export function onSessionUpdate(callback: SessionUpdateCallback): boolean;
/**
* Sets a callback for user update events on the global client
*
* This function is part of the singleton API.
* The callback is triggered when users join or leave the meeting.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @category Singleton API
*/
export function onUserUpdate(callback: UserUpdateCallback): boolean;
/**
* Sets a callback for receiving audio data on the global client
*
* This function is part of the singleton API.
* The callback is triggered when audio data is received from the meeting.
*
* @param callback The callback function to invoke
* @returns true if the callback was set successfully
*
* @example
* ```typescript
* rtms.onAudioData((buffer, size, timestamp, metadata) => {
* console.log(`Received ${size} bytes of audio from ${metadata.userName}`);
*
* // Process the audio data
* // buffer - Raw audio data (Buffer)