index.d.ts 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. // Type definitions for trtc-js-sdk
  2. // Npm: https://www.npmjs.com/package/trtc-js-sdk
  3. // Github: https://github.com/LiteAVSDK/TRTC_Web
  4. type Nullable<T> = T | null;
  5. type Callback<T = any> = (event: T) => void;
  6. type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
  7. export interface CheckResult {
  8. /** Compatibility check results */
  9. result: boolean;
  10. detail: {
  11. /** Whether the browser is supported by the SDK */
  12. isBrowserSupported: boolean;
  13. /** Whether the browser supports WebRTC */
  14. isWebRTCSupported: boolean;
  15. /** Whether the browser supports getting media devices and media streams */
  16. isMediaDevicesSupported: boolean;
  17. /** Whether the browser supports H.264 encoding */
  18. isH264EncodeSupported: boolean;
  19. /** Whether the browser supports H.264 decoding */
  20. isH264DecodeSupported: boolean;
  21. /** Whether the browser supports VP8 encoding */
  22. isVp8EncodeSupported: boolean;
  23. /** Whether the browser supports VP8 decoding */
  24. isVp8DecodeSupported: boolean;
  25. };
  26. }
  27. export interface ClientConfig {
  28. /** sdkAppId */
  29. sdkAppId: number;
  30. /** userId */
  31. userId: string;
  32. /** User signature */
  33. userSig: string;
  34. /**
  35. * Application scenario, which can be:
  36. * 'rtc': real-time call
  37. * 'live': interactive live streaming
  38. */
  39. mode: 'rtc' | 'live';
  40. /** Whether to use string-type `roomId`, supported on v4.3.0+ */
  41. useStringRoomId?: boolean;
  42. /**
  43. * Whether to receive remote streams automatically, supported on v4.8.0+
  44. */
  45. autoSubscribe?: boolean;
  46. /**
  47. * enable autoplay dialog, since v4.11.9.
  48. */
  49. enableAutoPlayDialog?: boolean;
  50. /** Stream ID bound to Tencent Cloud’s live streaming CDN. */
  51. streamId?: string;
  52. /** Recording ID (`userdefinerecordid`) in the callback for on-cloud recording */
  53. userDefineRecordId?: string;
  54. /**
  55. * Audio-only publishing mode. Include this parameter if you need to enable relayed live streaming and record the audio.
  56. */
  57. pureAudioPushMode?: 1 | 2;
  58. /**
  59. * Enabling SEI send and receive. supported on v4.14.1+
  60. */
  61. enableSEI?: boolean;
  62. }
  63. interface ProxyServer {
  64. websocketProxy: string;
  65. loggerProxy: string;
  66. scheduleProxy: string;
  67. /**
  68. * @since v4.15.8
  69. */
  70. unifiedProxy: string;
  71. }
  72. export interface Client {
  73. /**
  74. * Set a proxy server.
  75. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#setProxyServer
  76. */
  77. setProxyServer(proxyServer: string | ProxyServer): void;
  78. /**
  79. * Set TURN servers.
  80. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#setTurnServer
  81. */
  82. setTurnServer(config: TurnServerConfig | TurnServerConfig[]): void;
  83. /**
  84. * Join an audio/video call room.
  85. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#join
  86. */
  87. join(options: JoinOptions): Promise<void>;
  88. /**
  89. * Leave room.
  90. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#leave
  91. */
  92. leave(): Promise<void>;
  93. /**
  94. * Destroy client.
  95. * @since 4.13.0
  96. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#destroy
  97. */
  98. destroy(): void;
  99. /**
  100. * Publish localStream
  101. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#publish
  102. */
  103. publish(localStream: LocalStream, options?: { isAuxiliary?: boolean }): Promise<void>;
  104. /**
  105. * Unpublish localStream
  106. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#unpublish
  107. */
  108. unpublish(localStream: LocalStream): Promise<void>;
  109. /**
  110. * subscribe remoteStream
  111. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#subscribe
  112. */
  113. subscribe(remoteStream: RemoteStream, options?: { audio?: boolean; video?: boolean }): Promise<void>;
  114. /**
  115. * unsubscribe remoteStream
  116. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#unsubscribe
  117. */
  118. unsubscribe(remoteStream: RemoteStream): Promise<void>;
  119. /**
  120. * switch role
  121. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#switchRole
  122. */
  123. switchRole(role: Role): Promise<void>;
  124. /**
  125. * send SEI message
  126. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#sendSEIMessage
  127. * @since 4.14.1
  128. */
  129. sendSEIMessage(buffer: ArrayBuffer, options?: { seiPayloadType: number }): void;
  130. /**
  131. * listen for client event.
  132. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#on
  133. */
  134. on<K extends keyof ClientEventMap>(event: K, handler: Callback<ClientEventMap[K]>, context?: any): void;
  135. /**
  136. * stop listen for client event.
  137. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#off
  138. */
  139. off<K extends keyof ClientEventMap>(event: K, handler: Callback<ClientEventMap[K]>, context?: any): void;
  140. /** stop listen for all client events. */
  141. off(event: '*'): void;
  142. /** Get the list of the audio/video mute status of remote users in the current room. */
  143. getRemoteMutedState(): RemoteMutedState[];
  144. /** Get current network transfer statistics. */
  145. getTransportStats(): Promise<TransportStats>;
  146. /** Get audio statistics of published local streams. */
  147. getLocalAudioStats(): Promise<LocalAudioStatsMap>;
  148. /** Get video statistics of published local streams. */
  149. getLocalVideoStats(): Promise<LocalVideoStatsMap>;
  150. /** Get audio statistics of all current remote streams. */
  151. getRemoteAudioStats(): Promise<RemoteAudioStatsMap>;
  152. /** Get video statistics of all current remote streams. */
  153. getRemoteVideoStats(remoteStreamType?: RemoteStreamType): Promise<RemoteVideoStatsMap>;
  154. /**
  155. * Start mixtranscoding
  156. * @since 4.8.0
  157. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#startMixTranscode
  158. */
  159. startMixTranscode(config: MixTranscodeConfig): Promise<void>;
  160. /**
  161. * Stop mixtranscoding.
  162. * @since 4.8.0
  163. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#stopMixTranscode
  164. */
  165. stopMixTranscode(): Promise<void>;
  166. /**
  167. * Start publishing the current user's audio/video streams to CDN.
  168. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#startPublishCDNStream
  169. * @since 4.10.0
  170. */
  171. startPublishCDNStream(options: PublishCDNStreamOptions): Promise<void>;
  172. /**
  173. * Stop publishing the current user's audio/video streams to CDN.
  174. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#stopPublishCDNStream
  175. * @since 4.10.0
  176. */
  177. stopPublishCDNStream(): Promise<void>;
  178. /**
  179. * Enable/Disable the volume callback feature.
  180. * @param interval Time interval for triggering the client.on('audio-volume') event.
  181. * @param enableInBackground For performance reasons, the SDK does not throw a volume callback event after your application is switched to the background. If you want to receive the volume callback event after your application is switched to the background, set this parameter to `true`.
  182. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#enableAudioVolumeEvaluation
  183. * @since 4.9.0
  184. */
  185. enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void
  186. /**
  187. * Enable the big/small stream mode.
  188. * @since 4.11.0
  189. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#enableSmallStream
  190. */
  191. enableSmallStream(): Promise<void>;
  192. /**
  193. * Disable the big/small stream mode.
  194. * @since 4.11.0
  195. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#disableSmallStream
  196. */
  197. disableSmallStream(): Promise<void>;
  198. /**
  199. * Set small stream parameters.
  200. * @since 4.11.0
  201. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#setSmallStreamProfile
  202. */
  203. setSmallStreamProfile(options: SmallStreamProfile): void;
  204. /**
  205. * Switch the big/small stream attribute.
  206. * @param remoteStream Remote stream subscribed
  207. * @param status
  208. * 'big': manually switch to the big stream
  209. *
  210. * 'small': manually switch to the small stream
  211. * @since 4.11.0
  212. *
  213. * This method has been changed from synchronous to asynchronous since v4.12.0
  214. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#setRemoteVideoStreamType
  215. */
  216. setRemoteVideoStreamType(remoteStream: RemoteStream, status: 'big' | 'small'): Promise<void>;
  217. /**
  218. * call experimental API.
  219. * @param name
  220. * @param options
  221. */
  222. callExperimentalAPI(name: ExperimentalAPIName, options: Object): Promise<any>;
  223. }
  224. type ExperimentalAPIName = 'updatePrivateMapKey'
  225. export interface StreamConfig {
  226. /** userId */
  227. userId?: string;
  228. /** Whether to capture audio from the mic */
  229. audio?: boolean;
  230. /** Whether to capture video from the camera */
  231. video?: boolean;
  232. /** Audio source */
  233. audioSource?: MediaStreamTrack;
  234. /** Video source */
  235. videoSource?: MediaStreamTrack;
  236. /** Device ID of the mic, which can be obtained via getMicrophones() */
  237. microphoneId?: string;
  238. /** Device ID of the camera, which can be obtained via getCameras() */
  239. cameraId?: string;
  240. /**
  241. * Whether to use the front or rear camera for video capturing.
  242. * You can use this parameter to specify whether to use the front or rear camera on mobile devices.
  243. * - 'user': front camera
  244. * - 'environment': rear camera
  245. * Note: Do not use both `cameraId` and `facingMode`.
  246. */
  247. facingMode?: 'user' | 'environment';
  248. /** Whether to capture the screen sharing stream */
  249. screen?: boolean;
  250. /**
  251. * Whether to capture system audio Note
  252. * - Do not set both `audio` and `screenAudio` to true.
  253. * - System audio capturing is supported on Chrome M74+ only. On Chrome for Windows and Chrome OS, you can capture the audio of the entire system, while on Chrome for Linux and macOS, you can capture only the audio of Chrome tabs. Other Chrome versions, OS, and browsers do not support system audio capturing.
  254. * - For detailed directions on screen sharing, see [Screen Sharing](https://web.sdk.qcloud.com/trtc/webrtc/doc/en/tutorial-16-basic-screencast.html).
  255. */
  256. screenAudio?: boolean;
  257. /**
  258. * Whether to mirror the video. Default value: true. We recommend that you enable the mirror mode when using the front camera and disable it when using the rear camera.
  259. * Screen sharing does not support mirroring.
  260. * @deprecated 4.12.1
  261. *
  262. * see [play](https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#play)
  263. */
  264. mirror?: boolean;
  265. }
  266. export interface RtcError extends Error {
  267. /** Get the error code. See [ErrorCode](https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html) for the error code list. */
  268. getCode<K extends keyof ErrorCode>(): ErrorCode[K];
  269. }
  270. /** Client Event */
  271. export interface ClientEventMap {
  272. /** A remote stream was added. This notification will be received when a remote user publishes a stream. */
  273. 'stream-added': RemoteStreamInfo;
  274. /** A remote stream was removed. This notification will be received when a remote user unpublishes a stream. */
  275. 'stream-removed': RemoteStreamInfo;
  276. /** A remote stream was updated. This notification will be received when a remote user adds, removes, or replaces an audio/video track. */
  277. 'stream-updated': RemoteStreamUpdatedInfo;
  278. /** A remote stream was successfully subscribed. This event will be triggered after [client.subscribe()](https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#subscribe) is successfully called. */
  279. 'stream-subscribed': RemoteStreamInfo;
  280. /**
  281. * The connection status between the SDK and Tencent Cloud changed.
  282. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.CONNECTION_STATE_CHANGED
  283. */
  284. 'connection-state-changed': {
  285. prevState: ConnectionState;
  286. state: ConnectionState;
  287. };
  288. /** A remote user entered a room. */
  289. 'peer-join': RemoteUserInfo;
  290. /** A remote user left the room. */
  291. 'peer-leave': RemoteUserInfo;
  292. /** A remote user mute audio. */
  293. 'mute-audio': RemoteUserInfo;
  294. /** A remote user mute video. */
  295. 'mute-video': RemoteUserInfo;
  296. /** A remote user unmute audio. */
  297. 'unmute-audio': RemoteUserInfo;
  298. /** A remote user unmute video. */
  299. 'unmute-video': RemoteUserInfo;
  300. /**
  301. * A user was kicked out of the room. Possible reasons:
  302. * - A user with the same username has already logged in. Note that users with the same name are not allowed to log in at the same time, which may cause abnormal audio/video calls between the two parties. This is an application business logic error.
  303. * - The user was kicked out of the room by the account admin.
  304. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.CLIENT_BANNED
  305. */
  306. 'client-banned': {
  307. reason: 'kick' | 'banned' | 'room-disband';
  308. message: string;
  309. };
  310. /**
  311. * Network quality statistics.
  312. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.NETWORK_QUALITY
  313. */
  314. 'network-quality': NetworkQuality;
  315. /**
  316. * Volume event
  317. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.AUDIO_VOLUME
  318. */
  319. 'audio-volume': {
  320. result: UserAudioVolume[]
  321. };
  322. /**
  323. * SEI message received
  324. * @since 4.14.1
  325. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.SEI_MESSAGE
  326. */
  327. 'sei-message': SEIMessageEvent;
  328. /** Error event. This event is thrown when an unrecoverable error occurs. */
  329. 'error': RtcError;
  330. }
  331. /**
  332. * Audio/Video stream. A stream can contain at most one audio track and one video track.
  333. * The `Stream` class is the base class of `LocalStream` and `RemoteStream`. It includes APIs applicable to both * local and remote streams.
  334. *
  335. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Stream.html
  336. */
  337. export interface Stream {
  338. /**
  339. * Play the audio/video stream
  340. * @param elementId HTML tag ID or `HTMLDivElement` object. The audio and video tags created internally by the API are added to this container.
  341. * @param options Playback options
  342. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Stream.html#play
  343. */
  344. play(elementId: HTMLDivElement['id'] | HTMLDivElement, options?: PlaybackOptions): Promise<void>;
  345. /** Stop playing an audio/video stream */
  346. stop(): void;
  347. /**
  348. * Resume playback
  349. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Stream.html#resume
  350. */
  351. resume(): Promise<void>;
  352. /**
  353. * Close an audio/video stream
  354. *
  355. * For local streams, this API will turn the camera off and release the camera and mic.
  356. */
  357. close(): void;
  358. /**
  359. * mute local audioTrack
  360. * @returns `true`: The video track is disabled successfully. `false`: Failed to disable the video track as it does not exist.
  361. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Stream.html#muteAudio
  362. */
  363. muteAudio(): boolean;
  364. /**
  365. * mute local videoTrack
  366. * @returns `true`: The video track is disabled successfully. `false`: Failed to disable the video track as it does not exist.
  367. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Stream.html#muteVideo
  368. */
  369. muteVideo(): boolean;
  370. /**
  371. * unmute local audioTrack
  372. */
  373. unmuteAudio(): boolean;
  374. /**
  375. * unmute local videoTrack
  376. */
  377. unmuteVideo(): boolean;
  378. /** Get the unique ID of a stream */
  379. getId(): string;
  380. /** Get the userId of stream */
  381. getUserId(): string;
  382. /**
  383. * Set the audio output device
  384. * @param deviceId Device ID, which can be obtained via `TRTC.getSpeakers()`
  385. */
  386. setAudioOutput(deviceId: string): Promise<void>;
  387. /**
  388. * Set the playback volume
  389. * @param volume Value range: 0.0-1.0
  390. */
  391. setAudioVolume(volume: number): void;
  392. /**
  393. * Get the current audio level
  394. */
  395. getAudioLevel(): number;
  396. /** whether a stream has an audio track */
  397. hasAudio(): boolean;
  398. /** whether a stream has a video track */
  399. hasVideo(): boolean;
  400. /** Get the audio track of a stream */
  401. getAudioTrack(): Nullable<MediaStreamTrack>;
  402. /** Get the video track of a stream */
  403. getVideoTrack(): Nullable<MediaStreamTrack>;
  404. /**
  405. * Get the current video frame
  406. */
  407. getVideoFrame(): Nullable<string>;
  408. /**
  409. * Listen for stream events
  410. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Stream.html#on
  411. */
  412. on<K extends keyof StreamEventMap>(event: K, handler: Callback<StreamEventMap[K]>, context?: any): void;
  413. /**
  414. * Stop listen for stream events
  415. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Stream.html#off
  416. */
  417. off<K extends keyof StreamEventMap>(event: K, handler: Callback<StreamEventMap[K]>, context?: any): void;
  418. /** stop listen for all stream events. */
  419. off(event: '*'): void;
  420. }
  421. export interface LocalStream extends Stream {
  422. /**
  423. * Initialize local audio/video stream objects.
  424. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#initialize
  425. */
  426. initialize(): Promise<void>;
  427. /**
  428. * Set audio profile
  429. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#setAudioProfile
  430. */
  431. setAudioProfile(profile: AudioProfileString): void;
  432. /**
  433. * Set video profile
  434. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#setVideoProfile
  435. */
  436. setVideoProfile(profile: VideoProfileString | VideoProfile): void;
  437. /**
  438. * Set screen sharing profile
  439. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#setScreenProfile
  440. */
  441. setScreenProfile(profile: ScreenProfileString | ScreenProfile): void;
  442. /**
  443. * Set video content hint.
  444. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#setVideoContentHint
  445. */
  446. setVideoContentHint(hint: 'motion' | 'detail' | 'text'): void;
  447. /**
  448. * Switch the media input device.
  449. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#switchDevice
  450. */
  451. switchDevice(type: 'audio' | 'video', deviceId: string): Promise<void>;
  452. /**
  453. * Add an audio or video track.
  454. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#addTrack
  455. */
  456. addTrack(track: MediaStreamTrack): Promise<void>;
  457. /**
  458. * Remove and audio or video track.
  459. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#removeTrack
  460. */
  461. removeTrack(track: MediaStreamTrack): Promise<void>;
  462. /**
  463. * Replace audio/video track.
  464. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#replaceTrack
  465. */
  466. replaceTrack(track: MediaStreamTrack): Promise<void>;
  467. /**
  468. * Set microphone capture volume
  469. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/LocalStream.html#setAudioCaptureVolume
  470. * @since 4.14.0
  471. */
  472. setAudioCaptureVolume(volume: Number): Boolean;
  473. }
  474. export interface RemoteStream extends Stream {
  475. /**
  476. * Get the type of a remote stream
  477. */
  478. getType(): RemoteStreamType;
  479. }
  480. export interface StreamEventMap {
  481. /**
  482. * Status change of the audio/video player. You can update the UI of your application based on these callbacks
  483. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.PLAYER_STATE_CHANGED
  484. */
  485. 'player-state-changed': {
  486. type: 'audio' | 'video';
  487. state: 'PLAYING' | 'PAUSED' | 'STOPPED';
  488. reason: 'playing' | 'mute' | 'unmute' | 'ended' | 'pause';
  489. };
  490. /** local screen sharing stopped */
  491. 'screen-sharing-stopped': undefined;
  492. /**
  493. * Stream connection status change
  494. * @since 4.10.1
  495. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.CONNECTION_STATE_CHANGED
  496. */
  497. 'connection-state-changed': {
  498. prevState: ConnectionState;
  499. state: ConnectionState;
  500. },
  501. /**
  502. * @since v4.13.0
  503. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.DEVICE_AUTO_RECOVERED
  504. */
  505. 'device-auto-recovered': {
  506. isCamera: boolean;
  507. isMicrophone: boolean;
  508. cameraId: string;
  509. microphoneId: string;
  510. },
  511. /**
  512. * Error event. This event is thrown when an unrecoverable error occurs.
  513. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.ERROR
  514. */
  515. 'error': RtcError;
  516. }
  517. export interface TurnServerConfig extends Omit<RTCIceServer, 'urls'> {
  518. /** TURN server url */
  519. url: string;
  520. }
  521. /**
  522. * User role. This parameter is valid only in `live` mode. Currently, two roles are supported:
  523. * - `anchor`
  524. * - `audience`
  525. *
  526. * Note: in live mode, users of the `audience` role do not have the permission to publish local streams. They have only the permission to view remote streams. If they want to co-anchor with the anchor for interaction, they need to use switchRole() to switch their roles to `anchor` before publishing local streams.
  527. */
  528. export type Role = 'anchor' | 'audience';
  529. export type RemoteStreamType = 'main' | 'auxiliary';
  530. export interface JoinOptions {
  531. /** roomId */
  532. roomId: number | string;
  533. /** user role */
  534. role?: Role;
  535. /**
  536. * @deprecated Key for entering a room. If permission control is required, please carry this parameter (empty or incorrect value will cause a failure in entering the room).
  537. */
  538. privateMapKey?: string;
  539. }
  540. export interface RemoteMutedState {
  541. /** remote userId */
  542. userId: string;
  543. /** Whether there is audio */
  544. hasAudio: boolean;
  545. /** Whether there is a video */
  546. hasVideo: boolean;
  547. /** Whether there is a small-stream video */
  548. hasSmall: boolean;
  549. /** Whether audio is muted */
  550. audioMuted: boolean;
  551. /** Whether the camera is disabled */
  552. videoMuted: boolean;
  553. }
  554. export interface TransportStats {
  555. /** Round-trip Time (RTT) of the uplink media connection between the SDK and Tencent Video Cloud, in ms */
  556. rtt: number;
  557. /**
  558. * RTT of the downlink media connection between the SDK and Tencent Video Cloud, in ms
  559. * @since 4.10.1
  560. */
  561. downlinksRTT: {
  562. [userId: string]: number;
  563. }
  564. }
  565. /** Audio statistics of local streams */
  566. export interface LocalAudioStats {
  567. /** Number of bytes sent */
  568. bytesSent: number;
  569. /** Number of packets sent */
  570. packetsSent: number;
  571. }
  572. /** Video statistics of local streams */
  573. export interface LocalVideoStats {
  574. /** Number of bytes sent */
  575. bytesSent: number;
  576. /** Number of packets sent */
  577. packetsSent: number;
  578. /** Number of frames encoded */
  579. framesEncoded: number;
  580. /** Number of frames sent */
  581. framesSent: number;
  582. /** width of video frame */
  583. frameWidth: number;
  584. /** height of video frame */
  585. frameHeight: number;
  586. }
  587. /** Audio statistics of remote streams */
  588. export interface RemoteAudioStats {
  589. /** Number of bytes received */
  590. bytesReceived: number;
  591. /** Number of packets received */
  592. packetsReceived: number;
  593. /** Number of packets lost */
  594. packetsLost: number;
  595. }
  596. /** Remote stream video statistics */
  597. export interface RemoteVideoStats {
  598. /** Number of bytes received */
  599. bytesReceived: number;
  600. /** Number of packets received */
  601. packetsReceived: number;
  602. /** Number of packets lost */
  603. packetsLost: number;
  604. /** Number of frames decoded */
  605. framesDecoded: number;
  606. /** width of video frame */
  607. frameWidth: number;
  608. /** height of video frame */
  609. frameHeight: number;
  610. }
  611. export interface LocalAudioStatsMap {
  612. [userId: string]: LocalAudioStats;
  613. }
  614. export interface LocalVideoStatsMap {
  615. [userId: string]: LocalVideoStats;
  616. }
  617. export interface RemoteAudioStatsMap {
  618. [userId: string]: RemoteAudioStats;
  619. }
  620. export interface RemoteVideoStatsMap {
  621. [userId: string]: RemoteVideoStats;
  622. }
  623. export interface MixUserItem {
  624. userId: string;
  625. hasAudio: boolean;
  626. hasVideo: boolean;
  627. hasAuxiliary: boolean;
  628. }
  629. export interface RemoteStreamInfo {
  630. stream: RemoteStream;
  631. }
  632. export interface RemoteStreamUpdatedInfo extends RemoteStreamInfo {
  633. /**
  634. * @since v4.15.8
  635. */
  636. mixUserList?: MixUserItem[]
  637. }
  638. export interface RemoteUserInfo {
  639. userId: string;
  640. }
  641. /**
  642. * Connection State
  643. * - `DISCONNECTED`: connection is disconnected
  644. * - `CONNECTING`: connection is connecting
  645. * - `RECONNECTING`: connection is reconnecting
  646. * - `CONNECTED`: connection is connected
  647. */
  648. export type ConnectionState = 'DISCONNECTED' | 'CONNECTING' | 'RECONNECTING' | 'CONNECTED';
  649. /** Playback options */
  650. export interface PlaybackOptions {
  651. /** Video fill mode. For details, see the [CSS object-fit](https://developer.mozilla.org/zh-CN/docs/Web/CSS/object-fit) property. */
  652. objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
  653. /** Whether to mute audio. You may want to mute the audio of local streams so that the audio captured by the mic won’t be played locally. */
  654. muted?: boolean;
  655. /**
  656. * Whether to mirror the video. Default value: true. We recommend that you enable the mirror mode when using the front camera and disable it when using the rear camera.
  657. * Screen sharing does not support mirroring.
  658. * @since 4.12.1
  659. *
  660. * This option has been supported since v4.12.1. see [play](https://web.sdk.qcloud.com/trtc/webrtc/doc/zh-cn/LocalStream.html#play)
  661. */
  662. mirror?: boolean;
  663. }
  664. export interface VideoProfile {
  665. width?: number;
  666. height?: number;
  667. frameRate?: number;
  668. /** video encode bitrate(kbps) */
  669. bitrate?: number;
  670. }
  671. export interface ScreenProfile {
  672. width: number;
  673. height: number;
  674. frameRate: number;
  675. /** video encode bitrate(kbps) */
  676. bitrate: number;
  677. }
  678. export type AudioProfileString = 'standard' | 'high' | 'standard-stereo' | 'high-stereo';
  679. export type VideoProfileString = '120p' | '120p_2' | '180p' | '180p_2' | '240p' | '240p_2' | '360p' | '360p_2' | '480p' | '480p_2' |'720p' | '1080p' | '1440p' | '4K';
  680. export type ScreenProfileString = '480p' | '480p_2' | '720p' | '720p_2' | '1080p' | '1080p_2';
  681. export interface NetworkQuality {
  682. /** Uplink network quality (uplinkNetworkQuality): network quality of the upstream connection from SDK to Tencent Cloud */
  683. uplinkNetworkQuality: 1 | 2 | 3 | 4 | 5 | 6;
  684. /** Downlink network quality (downlinkNetworkQuality): average network quality of all downlink connections from Tencent Cloud to SDK Enumerated values */
  685. downlinkNetworkQuality: 1 | 2 | 3 | 4 | 5 | 6;
  686. /**
  687. * uplink rtt
  688. * @since v4.10.3
  689. */
  690. uplinkRTT: number;
  691. /**
  692. * uplink loss
  693. * @since v4.10.3
  694. */
  695. uplinkLoss: number;
  696. /**
  697. * downlink rtt
  698. * @since v4.10.3
  699. */
  700. downlinkRTT: number;
  701. /**
  702. * downlink loss
  703. * @since v4.10.3
  704. */
  705. downlinkLoss: number;
  706. }
  707. export interface UserAudioVolume {
  708. /** userId */
  709. userId: string;
  710. /** audio volume. value range 0 to 100 */
  711. audioVolume: number;
  712. /** Stream */
  713. stream: Stream;
  714. }
  715. export interface SEIMessageEvent {
  716. /** userId */
  717. userId: string;
  718. /** audio volume. value range 0 to 100 */
  719. data: ArrayBuffer;
  720. /** sei payload type */
  721. seiPayloadType: 5 | 243;
  722. /**
  723. * is the SEI received from the auxiliary stream
  724. * @since v4.15.11
  725. */
  726. isFromAuxiliary: boolean;
  727. }
  728. export interface MixTranscodeConfig {
  729. /** Stream mixing mode */
  730. mode?: 'manual' | 'preset-layout';
  731. /** Stream ID after mixtranscoding. Default value: '' */
  732. streamId?: string;
  733. /**
  734. * Width of the video resolution in px after transcoding. Default value: 640.
  735. *
  736. * The value must be greater than or equal to 0 and is large enough so that all mixed video streams can be accommodated.
  737. */
  738. videoWidth?: number;
  739. /**
  740. * Height of the video resolution in px after transcoding. Default value: 480.
  741. *
  742. * The value must be greater than or equal to 0 and is large enough so that all mixed video streams can be accommodated.
  743. */
  744. videoHeight?: number;
  745. /** Video bitrate (Kbps) after transcoding. If `0` is passed in, the bitrate value is determined by `videoWidth` and `videoHeight`. */
  746. videoBitrate?: number;
  747. /** Video frame rate (fps) after transcoding. Default value: 15. Value range: (0, 30]. */
  748. videoFramerate?: number;
  749. /** Video keyframe interval (s) after transcoding. Default value: 2. Value range: [1, 8]. */
  750. videoGOP?: number;
  751. /** Audio sample rate (Hz) after transcoding. Default value: 48000 */
  752. audioSampleRate?: number;
  753. /** Audio bitrate (Kbps) after transcoding. Default value: 64. Value range: [32, 192]. */
  754. audioBitrate?: number;
  755. /** Number of sound channels after transcoding. Valid values: 1 (default), 2 */
  756. audioChannels?: 1 | 2;
  757. /** Background color of the image after mixing. The value must be a hexadecimal number. Default value: 0x000000 (black) */
  758. backgroundColor?: number;
  759. /** Background picture of the image after mixing. Default value: '' */
  760. backgroundImage?: string;
  761. /** Information list of users' streams mixed. The list must contain API caller information. */
  762. mixUsers: MixUser[];
  763. }
  764. /**
  765. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/zh-cn/global.html#MixUser
  766. */
  767. export interface MixUser {
  768. /** userId */
  769. userId: string;
  770. /**
  771. * user's roomId. You can use this param to mix streams from diffrent rooms.
  772. * @since 4.11.5
  773. */
  774. roomId: number | string;
  775. /** Only the user's audio stream is mixed in. If the value is `true`, the following video parameters do not need to be passed in. */
  776. pureAudio: boolean;
  777. /** Width (px) of the user's stream in the mixed stream. The value must be greater than or equal to 0. The default value is 0. */
  778. width?: number;
  779. /** Height (px) of the user's stream in the mixed stream. The value must be greater than or equal to 0. The default value is 0. */
  780. height?: number;
  781. /** X coordinate (px) of the user's stream in the mixed stream, starting from the upper left corner of the mixed stream. The value must be greater than or equal to 0. The default value is 0. */
  782. locationX?: number;
  783. /** Y coordinate (px) of the user's stream in the mixed stream, starting from the upper left corner of the mixed stream. The value must be greater than or equal to 0. The default value is 0. */
  784. locationY?: number;
  785. /** Layer number of the user's stream in the mixed stream. The value range is [1, 15]. If `pureAudio` is `false`, `zOrder` must be passed in. */
  786. zOrder?: number;
  787. /** Remote stream type in manual mode. This parameter does not need to be set in preset layout mode. Valid values: `main` (primary stream), `auxiliary` (substream of screen sharing) */
  788. streamType?: RemoteStreamType;
  789. /**
  790. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/zh-cn/global.html#MixUser
  791. */
  792. renderMode: 0 | 1 | 2;
  793. }
  794. export interface PublishCDNStreamOptions {
  795. /** Custom stream ID. Default value: ${sdkAppId}_${roomId}_${userId}_main */
  796. streamId?: string;
  797. /** Tencent Cloud live streaming `appId` */
  798. appId?: number;
  799. /** Tencent Cloud live streaming `bizId` */
  800. bizId?: number;
  801. /** Specified CDN address for stream publishing */
  802. url?: string;
  803. }
  804. export interface SmallStreamProfile {
  805. /** Width of the video resolution of the small stream */
  806. width: number;
  807. /** Height of the video resolution of the small stream */
  808. height: number;
  809. /** Bitrate of the small stream */
  810. bitrate: number;
  811. /** Frame rate of the small stream */
  812. frameRate: number;
  813. }
  814. /** @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html */
  815. export interface ErrorCode {
  816. /** Invalid parameter. */
  817. INVALID_PARAMETER: 0x1000;
  818. /** Invalid operation. */
  819. INVALID_OPERATION: 0x1001;
  820. /** Not supported.
  821. *
  822. * Note: this error is reported when an SDK API is called, indicating that the current browser does not support calling the API.
  823. *
  824. * Handling suggestion: use a browser supported by the SDK. Reference: [Check supported browsers](https://web.sdk.qcloud.com/trtc/webrtc/doc/en/tutorial-23-advanced-support-detection.html)
  825. */
  826. NOT_SUPPORTED: 0x1002;
  827. /**
  828. * User's device has not microphone or camera, but trying to capture microphone or camera.
  829. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.DEVICE_NOT_FOUND
  830. */
  831. DEVICE_NOT_FOUND: 0x1003;
  832. /**
  833. * LocalStream.initialize() failed.
  834. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.INITIALIZE_FAILED
  835. */
  836. INITIALIZE_FAILED: 0x1004;
  837. /**
  838. * Failed to establish the WebSocket signaling channel.
  839. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.SIGNAL_CHANNEL_SETUP_FAILED
  840. */
  841. SIGNAL_CHANNEL_SETUP_FAILED: 0x4001;
  842. /**
  843. * WebSocket signaling channel error.
  844. * @deprecated on v4.6.5
  845. */
  846. SIGNAL_CHANNEL_ERROR: 0x4002;
  847. /**
  848. * ICE Transport connection error, i.e., audio/video data transmission channel error.
  849. * @deprecated on v4.6.6
  850. */
  851. ICE_TRANSPORT_ERROR: 0x4003;
  852. /**
  853. * join room failed
  854. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.JOIN_ROOM_FAILED
  855. */
  856. JOIN_ROOM_FAILED: 0x4004;
  857. /**
  858. * Failed to create SDP offer.
  859. */
  860. CREATE_OFFER_FAILED: 0x4005;
  861. /**
  862. * Failed to reconnect the WebSocket signaling channel.
  863. *
  864. * Description: when the WebSocket is disconnected, the SDK retries the connection multiple times and throws this error if all the retries fail.
  865. *
  866. * Handling suggestion: remind the user to check the network and enter the room again.
  867. */
  868. SIGNAL_CHANNEL_RECONNECTION_FAILED: 0x4006;
  869. /**
  870. * uplink peer connection retries failed.
  871. *
  872. * Description: when the uplink peer connection is disconnected, the SDK retries the connection multiple times and throws this error if all the retries fail.
  873. *
  874. * Handling suggestion: remind the user to check the network and perform push again or enter the room again.
  875. */
  876. UPLINK_RECONNECTION_FAILED: 0x4007;
  877. /**
  878. * downlink peer connection retries failed.
  879. *
  880. * Description: when the downstream peer connection is disconnected unexpectedly, the SDK retries the connection multiple times and throws this error if all the retries fail.
  881. *
  882. * Handling suggestion: remind the user to check the network and enter the room again.
  883. */
  884. DOWNLINK_RECONNECTION_FAILED: 0x4008;
  885. /**
  886. * Remote stream do not exist.
  887. *
  888. * Description: When A tries to subscribe remoteStream published by B, B unpublish stream, causing A to fail to subscribe remoteStream from B.<br />
  889. *
  890. * Handling suggestion: It is a normal interaction process and does not need to be handled.
  891. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.REMOTE_STREAM_NOT_EXIST
  892. */
  893. REMOTE_STREAM_NOT_EXIST: 0x4010;
  894. /**
  895. * User was kicked out.
  896. */
  897. CLIENT_BANNED: 0x4040;
  898. /**
  899. * Media transmission service timed out.
  900. */
  901. SERVER_TIMEOUT: 0x4041;
  902. /**
  903. * Remote stream subscription timed out.
  904. */
  905. SUBSCRIPTION_TIMEOUT: 0x4042;
  906. /**
  907. * Autoplay failed error.
  908. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.PLAY_NOT_ALLOWED
  909. */
  910. PLAY_NOT_ALLOWED: 0x4043;
  911. /**
  912. * Failed to resume camera/mic capturing.
  913. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.DEVICE_AUTO_RECOVER_FAILED
  914. */
  915. DEVICE_AUTO_RECOVER_FAILED: 0x4044;
  916. /**
  917. * Failed to start publishing streams to CDN.
  918. */
  919. START_PUBLISH_CDN_FAILED: 0x4045;
  920. /**
  921. * Failed to stop publishing streams to CDN.
  922. */
  923. STOP_PUBLISH_CDN_FAILED: 0x4046;
  924. /**
  925. * Failed to start mixtranscoding.
  926. */
  927. START_MIX_TRANSCODE_FAILED: 0x4047;
  928. /**
  929. * Failed to stop mixtranscoding.
  930. */
  931. STOP_MIX_TRANSCODE_FAILED: 0x4048;
  932. /**
  933. * The current device does not support H.264.
  934. */
  935. NOT_SUPPORTED_H264: 0x4049;
  936. /**
  937. * Failed to change the role.
  938. */
  939. SWITCH_ROLE_FAILED: 0x404a;
  940. /**
  941. * API call timeout.
  942. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ErrorCode.html#.API_CALL_TIMEOUT
  943. */
  944. API_CALL_TIMEOUT: 0x404b;
  945. /**
  946. * Unknown error.
  947. */
  948. UNKNOWN: 0xffff;
  949. }
  950. export interface ClientEvent {
  951. /** A remote stream was added. This notification will be received when a remote user publishes a stream. */
  952. STREAM_ADDED: 'stream-added';
  953. /** A remote stream was removed. This notification will be received when a remote user unpublishes a stream. */
  954. STREAM_REMOVED: 'stream-removed';
  955. /** A remote stream was updated. This notification will be received when a remote user adds, removes, or replaces an audio/video track. */
  956. STREAM_UPDATED: 'stream-updated';
  957. /** A remote stream was successfully subscribed. This event will be triggered after [client.subscribe()](https://web.sdk.qcloud.com/trtc/webrtc/doc/en/Client.html#subscribe) is successfully called. */
  958. STREAM_SUBSCRIBED: 'stream-subscribed';
  959. /**
  960. * The connection status between the SDK and Tencent Cloud changed.
  961. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.CONNECTION_STATE_CHANGED
  962. */
  963. CONNECTION_STATE_CHANGED: 'connection-state-changed';
  964. /** A remote user entered a room. */
  965. PEER_JOIN: 'peer-join';
  966. /** A remote user left the room. */
  967. PEER_LEAVE: 'peer-leave';
  968. /** A remote user mute audio. */
  969. MUTE_AUDIO: 'mute-audio';
  970. /** A remote user mute video. */
  971. MUTE_VIDEO: 'mute-video';
  972. /** A remote user unmute audio. */
  973. UNMUTE_AUDIO: 'unmute-audio';
  974. /** A remote user unmute video. */
  975. UNMUTE_VIDEO: 'unmute-video';
  976. /**
  977. * A user was kicked out of the room. Possible reasons:
  978. * - A user with the same username has already logged in. Note that users with the same name are not allowed to log in at the same time, which may cause abnormal audio/video calls between the two parties. This is an application business logic error.
  979. * - The user was kicked out of the room by the account admin.
  980. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.CLIENT_BANNED
  981. */
  982. CLIENT_BANNED: 'client-banned';
  983. /**
  984. * Network quality statistics.
  985. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.NETWORK_QUALITY
  986. */
  987. NETWORK_QUALITY: 'network-quality';
  988. /**
  989. * Volume event
  990. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-ClientEvent.html#.AUDIO_VOLUME
  991. */
  992. AUDIO_VOLUME: 'audio-volume';
  993. /** Error event. This event is thrown when an unrecoverable error occurs. */
  994. ERROR: 'error';
  995. }
  996. export interface StreamEvent {
  997. /**
  998. * Status change of the audio/video player. You can update the UI of your application based on these callbacks
  999. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.PLAYER_STATE_CHANGED
  1000. */
  1001. PLAYER_STATE_CHANGED: 'player-state-changed';
  1002. /** local screen sharing stopped */
  1003. SCREEN_SHARING_STOPPED: 'screen-sharing-stopped';
  1004. /**
  1005. * Stream connection status change
  1006. * @since 4.10.1
  1007. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.CONNECTION_STATE_CHANGED
  1008. */
  1009. CONNECTION_STATE_CHANGED: 'connection-state-changed';
  1010. /**
  1011. * When the camera or microphone being used has an capture exception, SDK will try to automatically recover the capture. This event will be fired when the capture is recovered successfully.
  1012. * @since 4.13.0
  1013. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.DEVICE_AUTO_RECOVERED
  1014. */
  1015. DEVICE_AUTO_RECOVERED: 'device-auto-recovered';
  1016. /**
  1017. * Error event. This event is thrown when an unrecoverable error occurs.
  1018. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/module-StreamEvent.html#.ERROR
  1019. */
  1020. ERROR: 'error';
  1021. }
  1022. declare namespace TRTC {
  1023. /** SDK Version */
  1024. const VERSION: string;
  1025. /**
  1026. * SDK Logger
  1027. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/TRTC.Logger.html
  1028. */
  1029. namespace Logger {
  1030. /** Log output level */
  1031. const LogLevel: {
  1032. /** All */
  1033. TRACE: 0;
  1034. /** DEBUG, INFO, WARN, and ERROR */
  1035. DEBUG: 1;
  1036. /** INFO, WARN, and ERROR */
  1037. INFO: 2;
  1038. /** WARN and ERROR */
  1039. WARN: 3;
  1040. /** ERROR */
  1041. ERROR: 4;
  1042. /**
  1043. * Off
  1044. */
  1045. NONE: 5;
  1046. };
  1047. /** Set the log output level */
  1048. function setLogLevel(level: 0 | 1 | 2 | 3 | 4 | 5): void;
  1049. /** Enable log upload */
  1050. function enableUploadLog(): void;
  1051. /**
  1052. * Disable log upload
  1053. *
  1054. * Note: We won’t be able to identify problems for you online if you disable log upload.
  1055. */
  1056. function disableUploadLog(): void;
  1057. }
  1058. /** Check whether the TRTC SDK for web is compatible with the browser. */
  1059. function checkSystemRequirements(): Promise<CheckResult>;
  1060. /** Check whether the browser supports screen sharing */
  1061. function isScreenShareSupported(): boolean;
  1062. /** Check whether the browser supports the dual-channel mode */
  1063. function isSmallStreamSupported(): boolean;
  1064. /** Get the list of media input and output devices */
  1065. function getDevices(): Promise<MediaDeviceInfo[]>;
  1066. /** Get the camera list */
  1067. function getCameras(): Promise<InputDeviceInfo[]>;
  1068. /** Get the mic list */
  1069. function getMicrophones(): Promise<InputDeviceInfo[]>;
  1070. /** Get the speaker list */
  1071. function getSpeakers(): Promise<MediaDeviceInfo[]>;
  1072. /**
  1073. * Create a client object for real-time audio/video calls. This API needs to be called only once for each call.
  1074. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/TRTC.html#.createClient
  1075. */
  1076. function createClient(config: ClientConfig): Client;
  1077. /**
  1078. * Create a localStream, which can use the client.publish() API to publish localStream.
  1079. * @link https://web.sdk.qcloud.com/trtc/webrtc/doc/en/TRTC.html#.createStream
  1080. */
  1081. function createStream(config: StreamConfig): LocalStream;
  1082. }
  1083. export default TRTC;