forked from AgoraIO/rtc-web-archive
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
4489 lines (4454 loc) · 203 KB
/
index.d.ts
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
/**
* AgoraRTC is the entry point for all the methods that can be called in Agora Web SDK.
*
* You can use the AgoraRTC methods to create {@link Client} and {@link Stream} objects.
*
* Other methods of the AgoraRTC object check for system requirements and set up error logging.
*/
export = AgoraRTC;
export as namespace AgoraRTC
declare namespace AgoraRTC {
/**
* Regions for the connection in {@link ClientConfig.areaCode}.
*/
enum AREAS {
/**
* China.
*/
CHINA = "CHINA",
/**
* Asia, excluding Mainland China.
*/
ASIA = "ASIA",
/**
* North America.
*/
NORTH_AMERICA = "NORTH_AMERICA",
/**
* Europe.
*/
EUROPE = "EUROPE",
/**
* Japan.
*/
JAPAN = "JAPAN",
/**
* India.
*/
INDIA = "INDIA",
/**
* Global.
*/
GLOBAL = "GLOBAL",
}
/**
* Gets the Sources for Screen-sharing
*
* To share the screen in Electron, call this method to get the screen sources. See [Share the Screen](../../screensharing_web?platform=Web#electron) for details.
*
* If this method succeeds, the SDK returns a list of screen sources in an array of {@link DesktopCapturerSource} objects.
* @example **Sample code**
* ```javascript
* AgoraRTC.getScreenSources(function(err, sources) {
* console.log(sources)
* }
* ```
*/
function getScreenSources(callback: (sources: DesktopCapturerSource[]) => void): void;
/**
* Creates a Client Object
*
* This method creates and returns a client object. You can only call this method once each call session.
* @example `AgoraRTC.createClient(config)`
* @param config Defines the property of the client, see {@link ClientConfig} for details.
*/
function createClient(config: ClientConfig): Client;
/**
* Creates a Stream Object
*
* This method creates and returns a stream object.
* @example `AgoraRTC.createStream(spec)`
* @param spec Defines the properties of the stream, see {@link StreamSpec} for details.
*/
function createStream(spec: StreamSpec): Stream;
/**
* Checks the Web Browser Compatibility
*
* This method checks the compatibility between the Web SDK and the current web browser.
*
* Use this method before calling {@link createClient} to check the compatibility between the system and the web browser.
*
* **Note**
*
* - Both the type and version of the browser affect the return value.
* - Agora has not conducted comprehensive tests on some Chromium kernel browsers, such as QQ and 360. You can call this method to check if the SDK supports the browser.
* @returns - `true`: The Web SDK is compatible with the current web browser.
* - `false`: The Web SDK is not compatible with the current web browser.
*/
function checkSystemRequirements(): boolean;
/**
* Gets the supported codec of the web browser
*
* This method returns the codecs supported by both the Agora Web SDK and the web browser. The Agora Web SDK supports VP8, VP9 and H.264 for video, and OPUS for audio.
*
* **Note**
*
* - This method supports all web browsers. For web browsers that do not support WebRTC or are not recognized, the returned codec list is empty.
* - The returned codec list is based on the [SDP](https://tools.ietf.org/html/rfc4566) used by the web browser and for reference only.
* - Some Android phones might claim to support H.264 but have problems in communicating with other platforms using H.264. In this case, we recommend using the VP8 or VP9 codec.
*
* @returns Returns a `Promise` object. In the `.then(function(result){})` callback, `result` has the following properties:
* - `video`: array, the supported video codecs. The array might include `"H264"`, `"VP8"` and `"VP9"`, or be empty.
* - `audio`: array, the supported audio codecs. The array might include `"OPUS"`, or be empty.
*
* @example
* **Sample code**
*
* ``` javascript
* // Gets the supported decoding formats as the receiver
* AgoraRTC.getSupportedCodec()
* .then(function(result){
* console.log(`Supported video codec: ${result.video.join(",")}`);
* console.log(`Supported audio codec: ${result.audio.join(",")}`);
* });
*
* // Gets the supported encoding formats as the sender
* navigator.mediaDevices.getUserMedia({video: true, audio: true})
* .then(function(mediaStream){
* return AgoraRTC.getSupportedCodec({stream: mediaStream});
* })
* .then(function(result){
* console.log(`Supported video codec: ${result.video.join(",")}`);
* console.log(`Supported audio codec: ${result.audio.join(",")}`);
* });
* ```
*/
function getSupportedCodec(supportedCodecOptions?: {
/**
* (Optional) Specifies a [[MediaStream]] object.
*
* If this parameter is empty, this method gets the supported decoding formats of the web browser as the receiver.
* Otherwise the method gets the supported encoding formats as the sender. In most cases, the supported decoding and encoding formats are the same.
*/
stream: MediaStream
}): Promise<{ video: Array<"VP8" | "VP9" | "H264">, audio: Array<"OPUS"> }>;
/**
* Enumerates the media devices
*
* This method enumerates the available media input and output devices, such as microphones, cameras, headsets, and so on.
*
* If this method succeeds, the SDK returns a list of media devices in an array of {@link MediaDeviceInfo} objects.
*
* **Note**
*
* - On Chrome 81 or later, Safari, and Firefox, device IDs are only available after the user has granted permissions to use the media device. See [Why can't I get device ID on Chrome 81?](https://docs.agora.io/en/faq/empty_deviceId)
* - You cannot get the `"audioinput"` device on Firefox and Safari.
*
* @example
* **Sample code**
*
* ``` javascript
* AgoraRTC.getDevices (function(devices) {
* var devCount = devices.length;
*
* var id = devices[0].deviceId;
* }, function(errStr){
* console.error("Failed to getDevice", errStr);
* });
* ```
*
* @param callback The callback when the method succeeds. The SDK returns a list of media devices in an array of {@link MediaDeviceInfo} objects.
* @param callback_Error The callback when the method fails. See the detailed error message in the `errStr` parameter.
*/
function getDevices(callback: (devices: MediaDeviceInfo[]) => void, callback_Error?: (errStr: string) => void): void;
/**
* Media Stream
*
* The `MediaStream` interface represents a stream of media content.
*
* A stream consists of several tracks such as video or audio tracks. Each track is specified as an instance of [[MediaStreamTrack]].
*
* See [MediaStream](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream) for details.
*/
interface MediaStream {
/**
* (Read-only) A [`DOMString`](https://developer.mozilla.org/en-US/docs/Web/API/DOMString) containing 36 characters denoting a universally unique identifier (UUID) for the object.
*
* See [MediaStream.id](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/id) for details.
*/
id: string;
/**
* (Read-only) A Boolean value that returns `true` if the stream is active, or `false` otherwise.
*
* See [active](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active) for details.
*/
active: boolean;
}
/**
* Screen Source Information
*
* This interface contains information on the screen source, see [DesktopCapturerSource](https://electronjs.org/docs/api/structures/desktop-capturer-source).
*
*/
interface DesktopCapturerSource {
/**
* ID of the screen source.
*/
readonly id: string;
/**
* Name of the screen source.
*/
readonly name: string;
/**
* Thumbnail of the screen source. See [nativeImage](https://electronjs.org/docs/api/native-image#nativeimage) for supported types.
*/
readonly thumbnail: any;
}
/**
* Media Stream Track
*
* This interface represents a single media track within a stream, for example an audio track or a video track.
*
* See [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) for details.
*
*/
interface MediaStreamTrack {
kind: "audio" | "video";
}
/**
* Media Device Information
*
* This interface contains information that describes a single media input or output device.
*
* The list of devices obtained by calling {@link AgoraRTC.getDevices} is an array of `MediaDeviceInfo` objects, one per media device.
*/
interface MediaDeviceInfo {
/**
* Device ID
*
* The unique ID of the device.
*
* **Note**
*
* On Chrome 81 or later, the device ID is only available after the user has granted permission to use the media device.
*/
readonly deviceId: string;
/**
* Device Label
*
* Returns a `DOMString` that is a label describing this device (for example "External USB Webcam").
*
* **Note**
*
* For security reasons, the label field is always blank unless an active media stream exists or the user has granted persistent permission for media device access.
*
*/
readonly label: string;
/**
* Device Type
*
* Returns an enumerated value that is "videoinput", "audioinput" or "audiooutput".
*/
readonly kind: string;
}
/**
* Error messages of stream playback
*
* When [[Stream.play]] fails to play the stream, this interface provides detailed error messages.
*
* In most cases, you can prompt the user to resume the playback ([[Stream.resume]]) by a user gesture except when the {@link status} is "aborted".
*/
interface StreamPlayError {
/**
* The status of the player:
* - "aborted": The player is removed before the stream is played successfully.
* - "paused": The player is stopped.
*/
readonly status: string,
/**
* The reason why the playback fails. Usually, this value is an event that triggers the playback failure. Possible values include the following:
* - "stalled": The failure might be caused by the browser policy. See [stalled event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/stalled_event).
* - "pause": The stream playback might be paused by the user. See [pause event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/pause_event).
* - "suspend": The failure might be caused by the browser policy. See [suspend event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/suspend_event).
* - "canplay": Some browsers automatically stop the playback when the playback window is not displayed on the screen. See [canplay event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplay_event).
* - "error": The playback failure is usually caused by autoplay restriction.
*
* Due to the differences in browsers, `reason` may have different values for the same event.
*/
readonly reason: string,
}
/**
* The video encoder configuration.
*
* This interface sets the video encoder configuration in {@link setVideoEncoderConfiguration}.
*
* Depending on the OS, browser, and camera, the actual resolution, frame rate, and bitrate might be different from the set values.
*/
interface VideoEncoderConfiguration{
/**
* Resolution of the video.
*
* We recommend using common resolutions, for example:
*
* - 480 × 360
* - 640 × 480
* - 960 × 720
*
*/
resolution?: {
/** Width of the video. The value range is [1,10000]. */
width: number,
/** Height of the video. The value range is [1,10000]. */
height: number,
},
/**
* The video encoding frame rate (fps). The value range is [1, 10000].
*
* Set this parameter as a value range. The minimum is **the expected frame rate**, and the maximum is the upper limit of the adjusted frame rate when the browser does not support the expected frame rate.
*
* **Note**
* - The actual encoding frame rate depends on the device, system, and browser.
* - When the network conditions change, the browser adjusts the encoding frame rate automatically.
*/
frameRate?: {
/** The default frame rate. The SDK uses this value as the expected frame rate. We recommend setting this value between 5 and 30. */
min: number,
/** The upper limit of the frame rate when the browser does not support the frame rate specified by `min`. */
max: number,
},
/**
* The video bitrate (Kbps). The value range is [1,10000000].
*
* We recommend setting the bitrate between 100 Kbps and 5000 Kbps. You can refer to the table below and set your bitrate.
*
* [[include:VideoProfileDefinition.md]]
*/
bitrate?: {
/** The minimum bitrate. */
min: number,
/** The maximum bitrate. */
max: number,
}
}
/**
* Audio statistics of the remote stream.
*
* If {@link getRemoteAudioStats} is called successfully, the {@link RemoteAudioStatsMap} interface provides the UID and {@link RemoteAudioStats} of each remote user.
*/
interface RemoteAudioStats {
/**
* End-to-end delay in ms.
*
* Delay from capturing to playing the audio.
*/
readonly End2EndDelay?: string;
/**
* Transport delay in ms.
*
* Delay from sending to receiving the audio.
*/
readonly TransportDelay?: string;
/** Packet loss rate (%) of the remote audio. */
readonly PacketLossRate?: string;
/** Volume of the received audio. */
readonly RecvLevel?: string;
/** Bitrate of the received audio, in Kbps. */
readonly RecvBitrate?: string;
/**
* Decoding type of the received audio.
*
* - "1": Opus.
* - "2": AAC.
*/
readonly CodecType?: string;
/**
* Whether the audio is muted or not.
*
* - "1": Muted.
* - "0": Unmuted.
*/
readonly MuteState?: string;
/** Total freeze time of the received audio. */
readonly TotalFreezeTime?: string;
/** Total playing duration of the received audio. */
readonly TotalPlayDuration?: string;
}
/**
* Audio statistics of the local stream.
*
* If {@link getLocalAudioStats} is called successfully, the {@link LocalAudioStatsMap} provides the UID and {@link LocalAudioStats} of the local user.
*/
interface LocalAudioStats {
/** Energy level of the captured audio. */
readonly RecordingLevel?: string;
/** Energy level of the sent audio. */
readonly SendLevel?: string;
/** Sampling rate, in kHz. */
readonly SamplingRate?: string;
/** Bitrate of the sent audio, in Kbps. */
readonly SendBitrate?: string;
/**
* Encoding type of the sent audio.
*
* - "1": Opus.
* - "2": AAC.
*/
readonly CodecType?: string;
/**
* Whether the audio is muted or not.
*
* - "1": Muted.
* - "0": Unmuted.
*/
readonly MuteState?: string;
}
/**
* Video statistics of the remote stream.
*
* If {@link getRemoteVideoStats} is called successfully, the {@link RemoteVideoStatsMap} interface provides the UID and {@link RemoteVideoStats} of each remote user.
*/
interface RemoteVideoStats {
/**
* End-to-end delay in ms.
*
* Delay from capturing to playing the video.
*/
readonly End2EndDelay?: string;
/**
* Transport delay in ms.
*
* Delay from sending to receiving the video.
*/
readonly TransportDelay?: string;
/** Packet loss rate (%) of the remote video. */
readonly PacketLossRate?: string;
/** Bitrate of the received video, in Kbps. */
readonly RecvBitrate?: string;
/** Resolution width of the received video, in pixels. */
readonly RecvResolutionWidth?: string;
/** Resolution height of the received video, in pixels. */
readonly RecvResolutionHeight?: string;
/** Rendering frame rate of the decoded video, in fps. */
readonly RenderFrameRate?: string;
/**
* Whether the video is muted or not.
*
* - "1": Muted.
* - "0": Unmuted.
*/
readonly MuteState?: string;
/** Total freeze time of the received video. */
readonly TotalFreezeTime?: string;
/** Total playing duration of the received video. */
readonly TotalPlayDuration?: string;
/** Width (pixels) of the rendered video */
readonly RenderResolutionWidth?: string;
/** Height (pixels) of the rendered video */
readonly RenderResolutionHeight?: string;
}
/**
* Video statistics of the local stream.
*
* If {@link getLocalVideoStats} is called successfully, the {@link LocalVideoStatsMap} interface provides the UID and {@link LocalVideoStats} of the local user.
*/
interface LocalVideoStats {
/** Bitrate of the local video set in [[setVideoProfile]]. */
readonly TargetSendBitrate?: string;
/** Frame rate of the sent video, in fps. */
readonly SendFrameRate?: string;
/** Bitrate of the sent video, in Kbps. */
readonly SendBitrate?: string;
/** Width of the sent video, in pixels. */
readonly SendResolutionWidth?: string;
/** Height of the sent video, in pixels. */
readonly SendResolutionHeight?: string;
/** Delay from capturing to encoding the local video, in ms. */
readonly EncodeDelay?: string;
/**
* Whether the video is muted or not.
*
* - "1": Muted.
* - "0": Unmuted.
*/
readonly MuteState?: string;
/** Width (pixels) of the captured video. */
readonly CaptureResolutionWidth?: string;
/** Height (pixels) of the captured video. */
readonly CaptureResolutionHeight?: string;
/** Frame rate of the captured video, in fps. */
readonly CaptureFrameRate?: string;
/** Total freeze time of the encoded video, in seconds. */
readonly TotalFreezeTime?: string;
/** Total duration of the published video, in seconds. */
readonly TotalDuration?: string;
}
/**
* Statistics of the network connection.
*
* If {@link getTransportStats} is called successfully, this interface provides the statistics.
*/
interface TransportStats {
/** RTT (Round-Trip Time) between the SDK and the access node of the SD-RTN, in ms. */
readonly RTT?: string;
/**
* Network type.
*
* - "bluetooth": Bluetooth network.
* - "cellular": Cellular network.
* - "ethernet": Ethernet.
* - "none": No network.
* - "wifi": Wi-Fi.
* - "wimax": WiMax.
* - "other": Other network type.
* - "unknown": Unknown network type.
* - "UNSUPPORTED": The browser does not support getting the network type.
*
* **Note**
*
* Chrome 61 or later is required for this function, and the compatibility is not guaranteed.
* See [Network Information API](https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API) for details.
*/
readonly NetworkType?: "bluetooth" | "cellular" | "ethernet" | "none" | "wifi" | "wimax" | "other" | "unknown" | "UNSUPPORTED";
/** The estimated available bandwidth for sending the stream, in Kbps. */
readonly OutgoingAvailableBandwidth?: string;
}
/**
* Statistics of the session connection.
*
* If {@link getSessionStats} is called successfully, this interface provides the statistics.
*/
interface SessionStats {
/** Call duration in seconds, represented by an aggregate value. */
readonly Duration?: string;
/**
* Number of users in the channel.
*
* - rtc mode: The number of all users in the channel.
* - live mode
* - If the local user is an audience: The number of hosts in the channel + 1.
* - If the user is a host: The number of hosts in the channel.
*/
readonly UserCount?: string;
/** Total number of bytes sent, represented by an aggregate value. */
readonly SendBytes?: string;
/** Total number of bytes received, represented by an aggregate value. */
readonly RecvBytes?: string;
/** Total sent bitrate of the stream, in Kbps, represented by an instantaneous value. */
readonly SendBitrate?: string;
/** Total received bitrate of the stream, in Kbps, represented by an instantaneous value. */
readonly RecvBitrate?: string;
}
/**
* Statistics of the network quality.
*
* After joining the channel, the SDK triggers the `"network-quality"` callback once every two seconds and provides the network quality ratings in this interface.
*/
interface NetworkQualityStats {
/**
* Uplink network quality rating of the user in terms of the transmission bitrate, packet loss rate, average RTT (Round-Trip Time) and jitter of the uplink network.
*
* - "0": The network quality is unknown.
* - "1": The network quality is excellent.
* - "2": The network quality is quite good, but the bitrate may be slightly lower than excellent.
* - "3": Users can feel the communication slightly impaired.
* - "4": Users can communicate only not very smoothly.
* - "5": The network is so bad that users can hardly communicate.
* - "6": The network is disconnected and users cannot communicate at all.
*/
readonly uplinkNetworkQuality?: string;
/**
* Downlink network quality rating of the user in terms of packet loss rate, average RTT, and jitter of the downlink network.
*
* - "0": The network quality is unknown.
* - "1": The network quality is excellent.
* - "2": The network quality is quite good, but the bitrate may be slightly lower than excellent.
* - "3": Users can feel the communication slightly impaired.
* - "4": Users can communicate only not very smoothly.
* - "5": The network is so bad that users can hardly communicate.
* - "6": The network is down and users cannot communicate at all.
*/
readonly downlinkNetworkQuality?: string;
}
/**
* Configurations for the watermark image to put on top of the video in {@link setLiveTranscoding}.
*
* **Since**
* <br>   *3.0.0*
*/
interface TranscodingWatermark {
/**
* The HTTP/HTTPS URL address of the image on the broadcasting video.
*
* ASCII characters only. The maximum length of this parameter is 1024 bytes. Supports online PNG only.
*/
url: string;
/**
* The horizontal distance (pixel) between the watermark image's top-left corner and the video's top-left corner.
*
* Integer only. The value range is [0,10000]. The default value is 0.
*/
x?: number;
/**
* The vertical distance (pixel) between the watermark image's top-left corner and the video's top-left corner.
*
* Integer only. The value range is [0,10000]. The default value is 0.
*/
y?: number;
/**
* The width (pixel) of the watermark image.
*
* Integer only. The value range is [0,10000]. The default value is 160.
*/
width?: number;
/**
* The height (pixel) of the watermark image.
*
* Integer only. The value range is [0,10000]. The default value is 160.
*/
height?: number;
}
/** Manages the user layout configuration in {@link setLiveTranscoding}. */
interface TranscodingUser {
/** The user ID of the CDN live host. */
uid?: number | string;
/**
* The position of the upper left end of the video on the horizontal axis.
*
* Integer only. The value range is [0,10000], and the default value is 0.
*/
x?: number;
/**
* The position of the upper left end of the video on the vertical axis.
*
* Integer only. The value range is [0,10000], and the default value is 0.
*/
y?: number;
/**
* The width of the video.
*
* Integer only. The value range is [0,10000], and the default value is 640.
*/
width?: number;
/**
* The height of the video.
*
* Integer only. The value range is [0,10000], and the default value is 360.
*/
height?: number;
/**
* The layer index of the video frame.
*
* Integer only. The value range is [0,100].
*
* From v2.3.0, Agora SDK supports setting zOrder as 0.
*
* - 0: (Default) Bottom layer.
* - 100: Top layer.
*
*/
zOrder?: number;
/**
* The transparency level of the video frame.
*
* The value ranges between 0.0 and 1.0:
*
* - 0.0: Completely transparent.
* - 1.0: Opaque.
*/
alpha: number;
}
/**
* A list of `RemoteAudioStats` objects, one per uid.
*
* If {@link getRemoteAudioStats} is called successfully, this interface provides the UID and [[RemoteAudioStats]] of each remote user.
*/
interface RemoteAudioStatsMap {
[uid: string]: RemoteAudioStats;
}
/**
* A list of `LocalAudioStats` objects, one per uid.
*
* If {@link getLocalAudioStats} is called successfully, this interface provides the UID and [[LocalAudioStats]] of the local user.
*/
interface LocalAudioStatsMap {
[uid: string]: LocalAudioStats;
}
/**
* A list of `RemoteVideoStats` objects, one per uid.
*
* If {@link getRemoteVideoStats} is called successfully, this interface provides the UID and [[RemoteVideoStats]] of each remote user.
*/
interface RemoteVideoStatsMap {
[uid: string]: RemoteVideoStats;
}
/**
* A list of `LocalVideoStats` objects, one per uid.
*
* If {@link getLocalVideoStats} is called successfully, this interface provides the UID and [[LocalVideoStats]] of each remote user.
*/
interface LocalVideoStatsMap {
[uid: string]: LocalVideoStats;
}
/**
* Configurations for a TURN server in {@link setTurnServer} or {@link createClient}.
*/
interface TurnServer {
/** Your TURN Server URL address. ASCII characters only, and the string length must be greater than 0 and less than 256 bytes. */
turnServerURL: string;
/** Your TURN Server username. ASCII characters only, and the string length must be greater than 0 and less than 256 bytes. */
username: string;
/** Your TURN Server password. ASCII characters only, and the string length must be greater than 0 and less than 256 bytes. */
password: string;
/** The UDP port(s) you want to add to TURN Server. Numeric characters only, and the string length must be greater than 0 and less than 256 bytes. */
udpport: string;
/** The TCP port(s) you want add to TURN Server. Numeric characters only, and the string length must be greater than 0 and less than 256 bytes. */
tcpport?: string;
/**
* Sets whether to force data transfer by TURN Server:
* - `true`: Force data transfer.
* - `false`: (default) Not to force data transfer.
*/
forceturn?: boolean;
}
/**
* Logger Settings
*
* Provides methods to enable/disable log upload and set output log level.
*/
namespace Logger {
/** Outputs all logs. */
type DEBUG = 0;
/** Outputs logs of the INFO, WARNING and ERROR levels. */
type INFO = 1;
/** Outputs logs of the WARNING and ERROR levels. */
type WARNING = 2;
/** Outputs logs of the ERROR level. */
type ERROR = 3;
/** Outputs no log. */
type NONE = 4;
/**
* Sets the Log Level
*
* This method sets the output log level.
*
* The log level follows the sequence of NONE, ERROR, WARNING, INFO, and DEBUG.
* For example, if you set the log level as `AgoraRTC.Logger.setLogLevel(AgoraRTC.Logger.INFO);`, then you can see logs in levels INFO, ERROR, and WARNING.
* @param level The output log level. The default value is {@link DEBUG}.
*/
function setLogLevel(level: DEBUG|INFO|WARNING|ERROR|NONE): void;
/**
* Enables Log Upload
*
* Call this method to enable log upload to Agora’s server.
*
* The log-upload function is disabled by default, if you need to enable this function, please call this method before all the other methods.
*
* **Note**
*
* If the user fails to join the channel, the log information is not available on Agora’s server.
* @example `AgoraRTC.Logger.enableLogUpload();`
*/
function enableLogUpload(): void;
/**
* Disables Log Upload
*
* This method disables log upload.
*
* By default, the log-upload function is disabled. If you have used {@link enableLogUpload}, call this method when you need to stop uploading the log.
* @example `AgoraRTC.Logger.disableLogUpload();`
*/
function disableLogUpload(): void;
}
/**
* A class defining the properties of the `config` parameter in the {@link createClient} method.
*
* **Note**
*
* Ensure that you set {@link mode} and {@link codec}.
* @example
* **Sample code**
* ``` javascript
* var config = {
* mode: "live",
* codec: "vp8",
* proxyServer: "YOUR HTTP PROXY SERVER IP",
* turnServer: {
* turnServerURL: "YOUR TURNSERVER URL",
* username: "YOUR USERNAME",
* password: "YOUR PASSWORD",
* udpport: "THE UDP PORT YOU WANT TO ADD",
* tcpport: "THE TCP PORT YOU WANT TO ADD",
* forceturn: false
* }
* }
* var client = AgoraRTC.createClient(config);```
*/
interface ClientConfig {
/**
* The channel profile.
*
* Agora Web SDK needs to know the application scenario to apply different optimization methods.
*
* Currently Agora Web SDK supports the following channel profiles:
* - `"live"`: Sets the channel profile as live broadcast. Host and audience roles that can be set by calling the [[Client.setClientRole]] method.
* The host sends and receives voice/video, while the audience can only receive voice/video.
* - `"rtc"`: Sets the channel profile as communication. This is used in one-on-one calls or group calls, where all users in the channel can talk freely.
*
* **Note**
*
* If you need to communicate with Agora Native SDK, Agora recommends the following settings:
* - For Native SDK v2.3.2 and later:
* * Set {@link mode} as `"rtc"` or `"live"` if the Native SDK uses the communication channel profile.
* * Set {@link mode} as `"live"` if the Native SDK uses the live broadcast channel profile.
* - For Native SDK before v2.3.2, set mode as "live" regardless of which channel profile the Native SDK uses.
*
* **Note**
*
* The `"rtc"` mode supports the Agora Recording SDK 2.3.3 or later.
*/
mode: "live" | "rtc";
/**
* The codec the Web browser uses for encoding.
* - `"vp8"`: Sets the browser to use VP8 for encoding.
* - `"vp9"`: Sets the browser to use VP9 for encoding.
* - `"h264"`: Sets the browser to use H.264 for encoding.
*
* **Note**
*
* - Safari 12.1 or earlier does not support the VP8 codec.
* - Codec support on mobile devices is a bit complex, see [Use Agora Web SDK on Mobile Devices](https://docs.agora.io/en/faq/web_on_mobile) for details.
*/
codec: "vp8" | "vp9" | "h264";
/**
* Your HTTP proxy server domain name.
*
* You can also use cloud proxy by {@link startProxyServer}. See [Use Cloud Proxy](https://docs.agora.io/en/Agora%20Platform/cloud_proxy_web?platform=Web) for details.
*
* ASCII characters only, and the string length must be greater than 0 and less than 256 bytes.
*
* **Note**
* - We support https/SSL proxy server via port 443.
* - Ensure that the proxy server supports wss (WebSocket Secure).
* - For the required firewall ports, see [Firewall Requirements](https://docs.agora.io/en/Agora%20Platform/firewall?platform=All%20Platforms#web-sdk-1).
*/
proxyServer?: string;
/**
* TURN server configurations.
*
* An array of the {@link TurnServer} objects. You can pass configurations of multiple TURN servers to this property.
*
* You can also use cloud proxy by {@link startProxyServer}. See [Use Cloud Proxy](https://docs.agora.io/en/Agora%20Platform/cloud_proxy_web?platform=Web) for details.
*/
turnServer?: TurnServer[];
/**
* The region for connection.
*
* **Since**
* <br>   *3.1.2*
*
* This advanced feature applies to scenarios that have regional restrictions.
*
* By default, the SDK connects to nearby Agora servers. After specifying the region, the SDK connects to the Agora servers within that region. For details, see {@link AREAS}.
*
* **Note:**
*
* - The regional restriction is a global configuration and applies to the entire browser tab. If one Client specifies the connection region, all the other Clients created on the same tab follow the restriction.
* - The SDK supports specifying only one region.
*
* **Sample code**
* ```js
* var config = {
* mode: "live",
* codec: "vp8",
* // Specify the region as North America.
* areaCode: [AgoraRTC.AREAS.NORTH_AMERICA]
* };
* var client = AgoraRTC.createClient(config);
* ```
*/
areaCode?: AREAS[];
excludedArea?: AREAS;
}
/**
* The configurations for CDN live stream transcoding. To be used in {@link setLiveTranscoding}.
*
* @example **Sample code**
* ``` javascript
* var LiveTranscoding = {
* width: 640,
* height: 360,
* videoBitrate: 400,
* videoFramerate: 15,
* audioSampleRate: AgoraRTC.AUDIO_SAMPLE_RATE_48000,
* audioBitrate: 48,
* audioChannels: 1,
* videoGop: 30,
* videoCodecProfile: AgoraRTC.VIDEO_CODEC_PROFILE_HIGH,
* userCount: 0,
* backgroundColor: 0x000000,
* transcodingUsers: [],
* images: [],
* };
* ```
*/
interface LiveTranscoding {
/**
* The width of the video in pixels.
*
* A positive integer, the default value is 640.
*
* - When pushing video streams to the CDN, ensure that `width` is at least 64; otherwise, the Agora server adjusts the value to 64.
* - When pushing audio streams to the CDN, set `width` and `height` as 0.
*/
width?: number;
/**
* The height of the video in pixels.
*
* A positive integer. The default value is 360.
*
* - When pushing video streams to the CDN, ensure that `height` is at least 64; otherwise, the Agora server adjusts the value to 64.
* - When pushing audio streams to the CDN, set `width` and `height` as 0.
*/
height?: number;
/**
* The bitrate (Kbps) of the output video stream.
*
* A positive integer. The default value is 400 Kbps. The value range is [1,1000000].
*
* Set the bitrate according to the {@link AgoraRTC.VideoEncoderConfiguration.bitrate Video Profile Table}. If you set a bitrate beyond the proper range, the SDK automatically adapts it to a value within the range.
*/
videoBitrate?: number;
/**
* The video frame rate (fps) of the CDN live stream.
*
* A positive integer. The default value is 15 fps. The value range is [1, 30]. The Agora server adjusts any value over 30 to 30.
*/
videoFramerate?: number;
/**
* **DEPRECATED**
*
* Latency mode:
* - true: Low latency with unassured quality.
* - false: (Default)High latency with assured quality.
*/
lowLatency?: boolean;
/**
* The audio sampling rate:
*
* - 32000: 32 kHz
* - 44100: (Default) 44.1 kHz
* - 48000: 48 kHz
*/
audioSampleRate?: 32000 | 44100 | 48000;
/**
* The audio bitrate (Kbps) of the CDN live stream.
*
* A positive integer. The default value is 48, and the highest value is 128.
*/
audioBitrate?: number;
/**
* The number of audio channels for the CDN live stream.
*
* Agora recommends choosing 1 (mono), or 2 (stereo) audio channels. Special players are required if you choose 3, 4, or 5.
*
* - 1: (Default) Mono
* - 2: Stereo
* - 3: Three audio channels
* - 4: Four audio channels
* - 5: Five audio channels
*/
audioChannels?: 1 | 2 | 3 | 4 | 5;
/** The video GOP in frames. The default value is 30 frames. The value range is [1,10000]. */
videoGop?: number;
/**
* The video codec profile type.
*
* Set it as 66, 77, or 100 (default). If you set this parameter to any other value, Agora adjusts it to the default value 100.
*
* - 66: Baseline video codec profile. Generally used for video calls on mobile phones.
* - 77: Main video codec profile. Generally used for mainstream electronics, such as MP4 players, portable video players, PSP, and iPads.
* - 100: (Default) High video codec profile. Generally used for high-resolution broadcasts or television.
*/
videoCodecProfile?: 66 | 77 | 100;
/** The number of users; default value is 0. The maximum is 17. */
userCount?: number;
/**
* The background color in RGB hex.
*
* Value only. Do not include a preceding #. The default value is 0x000000. The value range is [0x000000, 0xffffff].
*/