index.d.ts 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113
  1. import { CDNStreaming, CDNStreamingOptions } from './plugins/cdn-streaming';
  2. import { DeviceDetector, DeviceDetectorOptions } from './plugins/device-detector';
  3. import { VirtualBackground, VirtualBackgroundOptions, UpdateVirtualBackgroundOptions } from './plugins/video-effect/virtual-background';
  4. import { Watermark, WatermarkOptions } from './plugins/video-effect/watermark';
  5. import { Beauty, BeautyOptions, UpdateBeautyOptions } from './plugins/video-effect/beauty';
  6. import { BasicBeauty, BasicBeautyOptions } from './plugins/video-effect/basic-beauty';
  7. import { CrossRoom, StartCrossRoomOption, UpdateCrossRoomOption, StopCrossRoomOption } from './plugins/cross-room';
  8. import { Debug, DebugOptions } from './plugins/debug';
  9. export { CDNStreamingOptions, DeviceDetectorOptions, VirtualBackgroundOptions, UpdateVirtualBackgroundOptions, WatermarkOptions, BeautyOptions, UpdateBeautyOptions, BasicBeautyOptions, StartCrossRoomOption, UpdateCrossRoomOption, StopCrossRoomOption, DebugOptions };
  10. type TRTCPlugin = typeof CrossRoom | typeof CDNStreaming | typeof DeviceDetector | typeof VirtualBackground | typeof Watermark | typeof Beauty | typeof BasicBeauty | typeof Debug;
  11. export declare type PluginStartOptionsMap = {
  12. 'AudioMixer': AudioMixerOptions;
  13. 'AIDenoiser': AIDenoiserOptions;
  14. 'CDNStreaming': CDNStreamingOptions;
  15. 'VirtualBackground': VirtualBackgroundOptions;
  16. 'Watermark': WatermarkOptions;
  17. 'Beauty': BeautyOptions;
  18. 'BasicBeauty': BasicBeautyOptions;
  19. 'DeviceDetector': DeviceDetectorOptions;
  20. 'Debug': undefined;
  21. 'CrossRoom': StartCrossRoomOption;
  22. };
  23. export declare type PluginUpdateOptionsMap = {
  24. 'AudioMixer': UpdateAudioMixerOptions;
  25. 'CDNStreaming': CDNStreamingOptions;
  26. 'VirtualBackground': UpdateVirtualBackgroundOptions;
  27. 'Beauty': UpdateBeautyOptions;
  28. 'BasicBeauty': BasicBeautyOptions;
  29. 'CrossRoom': UpdateCrossRoomOption;
  30. };
  31. export declare type PluginStopOptionsMap = {
  32. 'AudioMixer': StopAudioMixerOptions;
  33. 'AIDenoiser': undefined;
  34. 'CDNStreaming': CDNStreamingOptions;
  35. 'VirtualBackground': undefined;
  36. 'Watermark': undefined;
  37. 'Beauty': undefined;
  38. 'BasicBeauty': undefined;
  39. 'DeviceDetector': undefined;
  40. 'Debug': undefined;
  41. 'CrossRoom': StopCrossRoomOption | undefined;
  42. };
  43. export declare class RtcError extends Error implements RTCErrorInterface {
  44. name: string;
  45. /**
  46. *
  47. * Error code
  48. * @see Detailed error code list: {@link module:ERROR_CODE ErrorCode}
  49. * @readonly
  50. * @memberof RtcError
  51. */
  52. code: number;
  53. /**
  54. *
  55. * Extended error code
  56. * @see Detailed error code list: {@link module:ERROR_CODE ErrorCode}
  57. * @readonly
  58. * @memberof RtcError
  59. */
  60. extraCode?: number;
  61. /**
  62. *
  63. * The name of the function that throws the error
  64. * @readonly
  65. * @memberof RtcError
  66. */
  67. functionName: string;
  68. /**
  69. *
  70. * Error message
  71. * @readonly
  72. * @memberof RtcError
  73. */
  74. message: string;
  75. /**
  76. * Error handler. For the following errors, you can call error.handler() for recovering.
  77. *
  78. * - {@link module:ERROR_CODE.DEVICE_ERROR ErrorCode.DEVICE_ERROR} extraCode: 5302
  79. * ```js
  80. * trtc.startLocalAudio().catch(error => {
  81. * if (error.extraCode === 5302 && typeof error.handler === 'function') {
  82. * // Prompt the user the browser permission(camera/microphone/screen sharing) has been denied by system. The browser will jump to the System Settings APP, please enable the relevant permissions!
  83. * // Available in Windows and MacOS.
  84. * error.handler();
  85. * }
  86. * })
  87. * ```
  88. * @since v5.2.0
  89. * @readonly
  90. * @memberof RtcError
  91. */
  92. handler?: () => void;
  93. originError?: Error | DOMException | RtcError;
  94. constructor({ code, extraCode, message, messageParams, fnName, originError }: RTCErrorParams);
  95. static convertFrom(originError: Error, fnName?: string, fnParams?: any): RtcError;
  96. }
  97. export declare enum LOG_LEVEL {
  98. /**
  99. * 输出所有日志
  100. */
  101. TRACE = 0,
  102. /**
  103. * 输出 DEBUG、INFO、WARN、ERROR 等级日志
  104. */
  105. DEBUG = 1,
  106. /**
  107. * 输出 INFO、WARN、ERROR 等级日志
  108. */
  109. INFO = 2,
  110. /**
  111. * 输出 WARN、ERROR 等级日志
  112. */
  113. WARN = 3,
  114. /**
  115. * 输出 ERROR 等级日志
  116. */
  117. ERROR = 4,
  118. /**
  119. * 不输出任何日志
  120. */
  121. NONE = 5
  122. }
  123. export declare const audioProfileMap: {
  124. readonly standard: {
  125. readonly sampleRate: 48000;
  126. readonly channelCount: 1;
  127. readonly bitrate: 40;
  128. };
  129. readonly 'standard-stereo': {
  130. readonly sampleRate: 48000;
  131. readonly channelCount: 2;
  132. readonly bitrate: 64;
  133. };
  134. readonly high: {
  135. readonly sampleRate: 48000;
  136. readonly channelCount: 1;
  137. readonly bitrate: 192;
  138. };
  139. readonly 'high-stereo': {
  140. readonly sampleRate: 48000;
  141. readonly channelCount: 2;
  142. readonly bitrate: 192;
  143. };
  144. };
  145. export declare const videoProfileMap: {
  146. readonly '120p': {
  147. readonly width: 160;
  148. readonly height: 120;
  149. readonly frameRate: 15;
  150. readonly bitrate: 200;
  151. };
  152. readonly '180p': {
  153. readonly width: 320;
  154. readonly height: 180;
  155. readonly frameRate: 15;
  156. readonly bitrate: 350;
  157. };
  158. readonly '240p': {
  159. readonly width: 320;
  160. readonly height: 240;
  161. readonly frameRate: 15;
  162. readonly bitrate: 400;
  163. };
  164. readonly '360p': {
  165. readonly width: 640;
  166. readonly height: 360;
  167. readonly frameRate: 15;
  168. readonly bitrate: 800;
  169. };
  170. readonly '480p': {
  171. readonly width: 640;
  172. readonly height: 480;
  173. readonly frameRate: 15;
  174. readonly bitrate: 900;
  175. };
  176. readonly '720p': {
  177. readonly width: 1280;
  178. readonly height: 720;
  179. readonly frameRate: 15;
  180. readonly bitrate: 1500;
  181. };
  182. readonly '1080p': {
  183. readonly width: 1920;
  184. readonly height: 1080;
  185. readonly frameRate: 15;
  186. readonly bitrate: 2000;
  187. };
  188. readonly '1440p': {
  189. readonly width: 2560;
  190. readonly height: 1440;
  191. readonly frameRate: 30;
  192. readonly bitrate: 4860;
  193. };
  194. readonly '4K': {
  195. readonly width: 3840;
  196. readonly height: 2160;
  197. readonly frameRate: 30;
  198. readonly bitrate: 9000;
  199. };
  200. };
  201. export declare const screenProfileMap: {
  202. readonly '480p': {
  203. readonly width: 640;
  204. readonly height: 480;
  205. readonly frameRate: 5;
  206. readonly bitrate: 900;
  207. };
  208. readonly '480p_2': {
  209. readonly width: 640;
  210. readonly height: 480;
  211. readonly frameRate: 30;
  212. readonly bitrate: 1000;
  213. };
  214. readonly '720p': {
  215. readonly width: 1280;
  216. readonly height: 720;
  217. readonly frameRate: 5;
  218. readonly bitrate: 1200;
  219. };
  220. readonly '720p_2': {
  221. readonly width: 1280;
  222. readonly height: 720;
  223. readonly frameRate: 30;
  224. readonly bitrate: 3000;
  225. };
  226. readonly '1080p': {
  227. readonly width: 1920;
  228. readonly height: 1080;
  229. readonly frameRate: 5;
  230. readonly bitrate: 1600;
  231. };
  232. readonly '1080p_2': {
  233. readonly width: 1920;
  234. readonly height: 1080;
  235. readonly frameRate: 30;
  236. readonly bitrate: 4000;
  237. };
  238. };
  239. export declare const enum Scene {
  240. LIVE = 'live',
  241. RTC = 'rtc'
  242. }
  243. export declare const enum NetworkQualityValue {
  244. UNKNOWN,
  245. EXCELLENT,
  246. GOOD,
  247. POOR,
  248. BAD,
  249. VERY_BAD,
  250. DISCONNECTED
  251. }
  252. export declare const enum PlayerState {
  253. PAUSED = 'PAUSED',
  254. PLAYING = 'PLAYING',
  255. STOPPED = 'STOPPED'
  256. }
  257. export declare const enum UserRole {
  258. ANCHOR = 'anchor',
  259. AUDIENCE = 'audience'
  260. }
  261. export declare const enum ConnectionState {
  262. CONNECTED = 'CONNECTED',
  263. DISCONNECTED = 'DISCONNECTED',
  264. CONNECTING = 'CONNECTING',
  265. RECONNECTED = 'RECONNECTED',
  266. RECONNECTING = 'RECONNECTING'
  267. }
  268. export declare interface PingResult {
  269. domain: string;
  270. cost: number;
  271. }
  272. export declare interface PingResults {
  273. isPoorNetwork?: boolean;
  274. timestamp?: number;
  275. data?: PingResult[];
  276. }
  277. export declare interface NetworkQuality {
  278. uplinkNetworkQuality: NetworkQualityValue;
  279. downlinkNetworkQuality: NetworkQualityValue;
  280. uplinkRTT: number;
  281. uplinkLoss: number;
  282. downlinkRTT: number;
  283. downlinkLoss: number;
  284. pingResults?: PingResults;
  285. }
  286. export declare const enum BannedReason {
  287. BANNED = 'banned',
  288. KICK = 'kick',
  289. USER_TIME_OUT = 'user_time_out',
  290. ROOM_DISBAND = 'room_disband'
  291. }
  292. export declare type PluginWithAssets = {
  293. plugin: TRTCPlugin;
  294. assetsPath?: string;
  295. };
  296. export declare interface TRTCOptions {
  297. plugins?: Array<TRTCPlugin>;
  298. enableSEI?: boolean;
  299. assetsPath?: string;
  300. }
  301. export interface VideoProfile { width: number, height: number, frameRate: number, bitrate: number; }
  302. export interface AudioProfile { sampleRate: number, channelCount: number, bitrate: number; }
  303. export declare interface LocalVideoConfig {
  304. view?: string | HTMLElement | HTMLElement[] | null;
  305. publish?: boolean;
  306. mute?: boolean | string;
  307. option?: {
  308. cameraId?: string;
  309. useFrontCamera?: boolean;
  310. profile?: keyof typeof videoProfileMap | VideoProfile;
  311. fillMode?: 'contain' | 'cover' | 'fill';
  312. mirror?: boolean | string;
  313. small?: keyof typeof videoProfileMap | VideoProfile | boolean;
  314. qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
  315. videoTrack?: MediaStreamTrack;
  316. };
  317. }
  318. export interface TurnServerOptions {
  319. url: string;
  320. username?: string;
  321. credential?: string;
  322. credentialType?: 'password';
  323. }
  324. export declare interface ProxyServer {
  325. websocketProxy?: string;
  326. loggerProxy?: string;
  327. turnServer?: TurnServerOptions | TurnServerOptions[];
  328. iceTransportPolicy?: RTCIceTransportPolicy;
  329. webtransportProxy?: string;
  330. scheduleProxy?: string;
  331. unifiedProxy?: string;
  332. }
  333. export declare interface EnterRoomConfig {
  334. sdkAppId: number;
  335. userId: string;
  336. userSig: string;
  337. roomId?: number;
  338. strRoomId?: string;
  339. role?: UserRole;
  340. autoReceiveAudio?: boolean;
  341. autoReceiveVideo?: boolean;
  342. privateMapKey?: string;
  343. latencyLevel?: number;
  344. businessInfo?: string;
  345. enableAutoPlayDialog?: boolean;
  346. proxy?: ProxyServer | string;
  347. scene?: Scene;
  348. userDefineRecordId?: string;
  349. }
  350. export declare interface ScreenShareConfig {
  351. view?: string | HTMLElement | HTMLElement[] | null;
  352. publish?: boolean;
  353. option?: {
  354. profile?: keyof typeof screenProfileMap | VideoProfile;
  355. fillMode?: 'contain' | 'cover' | 'fill';
  356. systemAudio?: boolean;
  357. echoCancellation?: boolean;
  358. autoGainControl?: boolean;
  359. noiseSuppression?: boolean;
  360. audioTrack?: MediaStreamTrack;
  361. videoTrack?: MediaStreamTrack;
  362. captureElement?: HTMLElement;
  363. preferDisplaySurface?: 'current-tab' | 'tab' | 'window' | 'monitor';
  364. qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
  365. };
  366. }
  367. export declare interface UpdateScreenShareConfig extends ScreenShareConfig {
  368. option?: {
  369. fillMode?: 'contain' | 'cover' | 'fill';
  370. qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
  371. };
  372. }
  373. export declare interface RemoteVideoConfig {
  374. view?: string | HTMLElement | HTMLElement[] | null;
  375. userId: string;
  376. streamType: TRTCStreamType;
  377. option?: {
  378. fillMode?: 'contain' | 'cover' | 'fill';
  379. mirror?: boolean;
  380. small?: boolean;
  381. receiveWhenViewVisible?: boolean;
  382. viewRoot?: HTMLElement;
  383. canvasRender?: boolean;
  384. };
  385. }
  386. export declare interface StopRemoteVideoConfig {
  387. userId: string;
  388. streamType?: TRTCStreamType;
  389. }
  390. export declare interface LocalAudioConfig {
  391. publish?: boolean;
  392. mute?: boolean;
  393. option?: {
  394. microphoneId?: string;
  395. profile?: keyof typeof audioProfileMap;
  396. audioTrack?: MediaStreamTrack;
  397. captureVolume?: number;
  398. earMonitorVolume?: number;
  399. echoCancellation?: boolean;
  400. autoGainControl?: boolean;
  401. noiseSuppression?: boolean;
  402. };
  403. }
  404. export declare interface UpdateLocalAudioConfig extends LocalAudioConfig {
  405. mute?: boolean;
  406. option?: {
  407. microphoneId?: string;
  408. audioTrack?: MediaStreamTrack;
  409. captureVolume?: number;
  410. earMonitorVolume?: number;
  411. echoCancellation?: boolean;
  412. autoGainControl?: boolean;
  413. noiseSuppression?: boolean;
  414. };
  415. }
  416. export declare interface RemoteAudioConfig {
  417. userId: string;
  418. option?: {
  419. volume?: number;
  420. };
  421. }
  422. export declare interface StopRemoteAudioConfig {
  423. userId: string;
  424. }
  425. export declare const enum TRTCStreamType {
  426. Main = 'main',
  427. Sub = 'sub'
  428. }
  429. export declare enum TRTCDeviceType {
  430. Camera = 'camera',
  431. Microphone = 'microphone',
  432. Speaker = 'speaker'
  433. }
  434. export declare enum TRTCDeviceAction {
  435. Remove = 'remove',
  436. Add = 'add',
  437. Active = 'active'
  438. }
  439. export declare interface RTCErrorParams {
  440. code: number;
  441. extraCode?: number;
  442. functionName?: string;
  443. fnName?: string;
  444. message?: string;
  445. messageParams?: any;
  446. originError?: Error | DOMException;
  447. }
  448. export declare interface RTCErrorInterface {
  449. readonly name: string;
  450. readonly code: number;
  451. readonly extraCode?: number;
  452. readonly functionName?: string;
  453. readonly message?: string;
  454. readonly originError?: Error | DOMException;
  455. }
  456. /**
  457. * **TRTC Constants**<br>
  458. * @module TYPE
  459. * @example
  460. * // Usage:
  461. * TRTC.TYPE.SCENE_LIVE
  462. */
  463. export declare const TRTCType: {
  464. /**
  465. * Live streaming scene
  466. * @default 'live'
  467. * @memberof module:TYPE
  468. */
  469. readonly SCENE_LIVE: Scene.LIVE;
  470. /**
  471. * RTC scene
  472. * @default 'rtc'
  473. * @memberof module:TYPE
  474. */
  475. readonly SCENE_RTC: Scene.RTC;
  476. /**
  477. * Anchor role
  478. * @default 'anchor'
  479. * @memberof module:TYPE
  480. */
  481. readonly ROLE_ANCHOR: UserRole.ANCHOR;
  482. /**
  483. * Audience role
  484. * @default 'audience'
  485. * @memberof module:TYPE
  486. */
  487. readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
  488. /**
  489. * Main stream
  490. *
  491. * - TRTC has a main video stream (main stream) and an sub video stream (sub stream)
  492. * - The camera is published through the main stream, and the screen sharing is published through the sub stream.
  493. * - The main video stream includes: high-definition large picture and low-definition small picture. By default, {@link TRTC#startRemoteVideo TRTC.startRemoteVideo} plays the high-definition large picture, and the low-definition small picture can be played through the small parameter. Refer to: [Enable small stream function](./tutorial-27-advanced-small-stream.html).
  494. * @default 'main'
  495. * @memberof module:TYPE
  496. */
  497. readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
  498. /**
  499. * Sub stream
  500. * @default 'sub'
  501. * @memberof module:TYPE
  502. */
  503. readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
  504. /**
  505. * Standard audio quality
  506. * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
  507. * | :--- | :--- | :--- | :--- |
  508. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
  509. * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
  510. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
  511. * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
  512. * @default 'standard'
  513. * @memberof module:TYPE
  514. */
  515. readonly AUDIO_PROFILE_STANDARD: 'standard';
  516. /**
  517. * Standard stereo audio quality
  518. * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
  519. * | :--- | :--- | :--- | :--- |
  520. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
  521. * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
  522. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
  523. * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
  524. * @default 'standard-stereo'
  525. * @memberof module:TYPE
  526. */
  527. readonly AUDIO_PROFILE_STANDARD_STEREO: 'standard-stereo';
  528. /**
  529. * High audio quality
  530. * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
  531. * | :--- | :--- | :--- | :--- |
  532. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
  533. * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
  534. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
  535. * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
  536. * @default 'high'
  537. * @memberof module:TYPE
  538. */
  539. readonly AUDIO_PROFILE_HIGH: 'high';
  540. /**
  541. * High-quality stereo audio
  542. * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
  543. * | :--- | :--- | :--- | :--- |
  544. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
  545. * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
  546. * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
  547. * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
  548. * @default 'high-stereo'
  549. * @memberof module:TYPE
  550. */
  551. readonly AUDIO_PROFILE_HIGH_STEREO: 'high-stereo';
  552. /**
  553. * When the network is weak, the video encoding strategy takes 'smooth' first, i.e., the priority is to preserve frame rate.
  554. * <br>
  555. * Default 'smooth' first for camera, 'default' clear first for screen sharing
  556. * @default 'smooth'
  557. * @memberof module:TYPE
  558. */
  559. readonly QOS_PREFERENCE_SMOOTH: 'smooth';
  560. /**
  561. * When the network is weak, the video encoding strategy takes 'clear' first, i.e., the priority is to preserve resolution.
  562. * <br>
  563. * Default 'smooth' first for camera, 'default' clear first for screen sharing
  564. * @default 'clear'
  565. * @memberof module:TYPE
  566. */
  567. readonly QOS_PREFERENCE_CLEAR: 'clear';
  568. };
  569. export declare interface AudioMixerOptions {
  570. id: string;
  571. url: string;
  572. loop?: boolean;
  573. volume?: number;
  574. }
  575. export declare interface UpdateAudioMixerOptions {
  576. id: string;
  577. loop?: boolean;
  578. volume?: number;
  579. seekFrom?: number;
  580. operation?: 'pause' | 'resume' | 'stop';
  581. }
  582. export declare interface StopAudioMixerOptions {
  583. id: string;
  584. }
  585. export declare interface AIDenoiserOptions {
  586. assetsPath: string;
  587. sdkAppId: number;
  588. userId: string;
  589. userSig: string;
  590. }
  591. export declare interface TRTCStatistics {
  592. rtt: number;
  593. downLoss: number;
  594. upLoss: number;
  595. bytesSent: number;
  596. bytesReceived: number;
  597. localStatistics: LocalStatistic;
  598. remoteStatistics: RemoteStatistic[];
  599. }
  600. export declare interface LocalStatistic {
  601. audio: {
  602. bitrate: number;
  603. audioLevel: number;
  604. };
  605. video: {
  606. width: number;
  607. height: number;
  608. frameRate: number;
  609. bitrate: number;
  610. videoType: TRTCVideoType;
  611. }[];
  612. }
  613. export declare enum TRTCVideoType {
  614. Big = 'big',
  615. Small = 'small',
  616. Sub = 'sub'
  617. }
  618. export declare interface RemoteStatistic {
  619. audio: {
  620. bitrate: number;
  621. audioLevel: number;
  622. };
  623. video: {
  624. width: number;
  625. height: number;
  626. frameRate: number;
  627. bitrate: number;
  628. videoType: TRTCVideoType;
  629. }[];
  630. userId: string;
  631. }
  632. export declare interface VideoFrameConfig {
  633. userId?: string;
  634. streamType?: TRTCStreamType;
  635. }
  636. export declare enum AutoStartPluginName {
  637. Debug = 'Debug'
  638. }
  639. /**
  640. * @typedef TRTCStatistics TRTC statistics
  641. * @property {number} rtt The round-trip time from SDK to TRTC server(SDK -> TRTC server -> SDK). Unit: ms.
  642. * @property {number} upLoss Uplink loss rate from SDK to TRTC server. Unit: %
  643. * @property {number} downLoss Downlink loss rate from TRTC server to SDK. Unit: %
  644. * @property {number} bytesSent Total bytes sent, including signaling data and media data. Unit: bytes.
  645. * @property {number} bytesReceived Total bytes received, including signaling data and media data. Unit: bytes.
  646. * @property {TRTCLocalStatistics} localStatistics Local statistics.
  647. * @property {TRTCRemoteStatistics[]} remoteStatistics Remote statistics.
  648. */
  649. /**
  650. * Local statistics
  651. * @typedef TRTCLocalStatistics
  652. * @property {TRTCAudioStatistic} audio Local audio statistics
  653. * @property {TRTCVideoStatistic[]} video Local video statistics
  654. */
  655. /**
  656. * Remote statistics.
  657. * @typedef TRTCRemoteStatistics
  658. * @property {string} userId The userId of remote user
  659. * @property {TRTCAudioStatistic} audio Remote audio statistics
  660. * @property {TRTCVideoStatistic[]} video Remote video statistics
  661. */
  662. /**
  663. * Audio statistics
  664. * @typedef TRTCAudioStatistic
  665. * @property {number} bitrate Audio bitrate. Unit: kbps
  666. * @property {number} audioLevel Audio level. Value: float from 0 to 1.
  667. */
  668. /** Video statistics
  669. * @typedef TRTCVideoStatistic
  670. * @property {number} bitrate Video bitrate. Unit: kbps
  671. * @property {number} width Video width
  672. * @property {number} height Video height
  673. * @property {number} frameRate Video frameRate
  674. * @property {'big'|'small'|'sub'} videoType Video type: big, small, sub.
  675. */
  676. /**
  677. * **TRTC Event List**<br>
  678. * <br>
  679. * Listen to specific events through {@link TRTC#on trtc.on(TRTC.EVENT.XXX)}. You can use these events to manage the room user list, manage user stream state, and perceive network state. The following is a detailed introduction to the events.
  680. * > !
  681. * > - Events need to be listened to before they are triggered, so that you can receive the corresponding event notifications. Therefore, it is recommended to complete event listening before entering the room, so as to ensure that no event notifications are missed.
  682. * @module EVENT
  683. * @example
  684. * // Usage:
  685. * trtc.on(TRTC.EVENT.ERROR, () => {});
  686. */
  687. export declare const TRTCEvent: {
  688. /**
  689. * Error event, non-API call error, SDK throws when an unrecoverable error occurs during operation.
  690. *
  691. * - Error code (error.code): {@link module:ERROR_CODE.OPERATION_FAILED ErrorCode.OPERATION_FAILED}
  692. * - Possible extended error codes (error.extraCode): 5501, 5502
  693. * @default 'error'
  694. * @memberof module:EVENT
  695. * @see {@link RtcError RtcError}
  696. * @e
  697. * @example
  698. *
  699. * trtc.on(TRTC.EVENT.ERROR, error => {
  700. * console.error('trtc error observed: ' + error);
  701. * const errorCode = error.code;
  702. * const extraCode = error.extraCode;
  703. * });
  704. */
  705. readonly ERROR: 'error';
  706. /**
  707. * @description Automatic playback failed, refer to {@tutorial 21-advanced-auto-play-policy}
  708. * @default 'autoplay-failed'
  709. * @memberof module:EVENT
  710. * @example
  711. * trtc.on(TRTC.EVENT.AUTOPLAY_FAILED, event => {
  712. * // Guide user to click the page, SDK will resume playback automatically when user click the page.
  713. * // Since v5.1.3+, you can get userId on this event.
  714. * console.log(event.userId);
  715. * });
  716. */
  717. readonly AUTOPLAY_FAILED: 'autoplay-failed';
  718. /**
  719. * @description Kicked out of the room for some reason, including:<br>
  720. * - kick: The same user with same userId enters same room. The user who enters the room first will be kicked out of the room by the user who enters later.
  721. * - Entering a room with the same userId is not allowed behavior, which may lead to abnormal audio/video calls between the two parties, and should be avoided on the business side.
  722. * - Users with the same userId who enter the same room with the same audience role may not receive this event.
  723. * - banned: kicked out by the administrator using [Server API - RemoveUser](https://trtc.io/document/34267/34268).
  724. * - room_disband: kicked out by the administrator using [Server API - DismissRoom](https://trtc.io/document/34267/34269).
  725. * @default 'kicked-out'
  726. * @memberof module:EVENT
  727. * @example
  728. *
  729. * trtc.on(TRTC.EVENT.KICKED_OUT, event => {
  730. * console.log(event.reason)
  731. * });
  732. */
  733. readonly KICKED_OUT: 'kicked-out';
  734. /**
  735. * Remote user enters the room event.
  736. *
  737. * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
  738. * - In `live` mode, only the anchor has the notification of entering and exiting the room, and the audience does not have the notification of entering and exiting the room. The audience can receive the notification of entering and exiting the room of the anchor.
  739. * @default 'remote-user-enter'
  740. * @memberof module:EVENT
  741. * @example
  742. *
  743. * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, event => {
  744. * const userId = event.userId;
  745. * });
  746. */
  747. readonly REMOTE_USER_ENTER: 'remote-user-enter';
  748. /**
  749. * Remote user exits the room event.
  750. *
  751. * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
  752. * - In `live` mode, only the anchor has the notification of entering and exiting the room, and the audience does not have the notification of entering and exiting the room. The audience can receive the notification of entering and exiting the room of the anchor.
  753. * @default 'remote-user-exit'
  754. * @memberof module:EVENT
  755. * @example
  756. *
  757. * trtc.on(TRTC.EVENT.REMOTE_USER_EXIT, event => {
  758. * const userId = event.userId;
  759. * });
  760. */
  761. readonly REMOTE_USER_EXIT: 'remote-user-exit';
  762. /**
  763. * Remote user publishes audio. You will receive this notification when the remote user turns on the microphone. Refer to: [Turn on/off camera and microphone](./tutorial-15-basic-dynamic-add-video.html)
  764. *
  765. * - By default, the SDK automatically plays remote audio, and you do not need to call the API to play remote audio. You can listen for this event and {@link module:EVENT.REMOTE_AUDIO_UNAVAILABLE REMOTE_AUDIO_UNAVAILABLE} to update the UI icon for "whether the remote microphone is turned on".
  766. * - Note: If the user has not interacted with the page before entering the room, automatic audio playback may fail due to the [browser's automatic playback policy restrictions](./tutorial-21-advanced-auto-play-policy.html). You need to refer to the [suggestions for handling automatic playback restrictions](./tutorial-21-advanced-auto-play-policy.html) for processing.
  767. * - If you do not want the SDK to automatically play audio, you can set `autoReceiveAudio` to `false` to turn off automatic audio playback when calling {@link TRTC#enterRoom trtc.enterRoom()}.
  768. * - Listen for the {@link module:EVENT.REMOTE_AUDIO_AVAILABLE TRTC.EVENT.REMOTE_AUDIO_AVAILABLE} event, record the userId with remote audio, and call the {@link TRTC#muteRemoteAudio trtc.muteRemoteAudio(userId, false)} method when you need to play audio.
  769. * @default 'remote-audio-available'
  770. * @memberof module:EVENT
  771. * @example
  772. * // Listen before entering the room
  773. * trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, event => {
  774. * const userId = event.userId;
  775. * });
  776. */
  777. readonly REMOTE_AUDIO_AVAILABLE: 'remote-audio-available';
  778. /**
  779. * Remote user stops publishing audio. You will receive this notification when the remote user turns off the microphone.
  780. *
  781. * @default 'remote-audio-unavailable'
  782. * @memberof module:EVENT
  783. * @example
  784. * // Listen before entering the room
  785. * trtc.on(TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE, event => {
  786. * const userId = event.userId;
  787. *
  788. * });
  789. */
  790. readonly REMOTE_AUDIO_UNAVAILABLE: 'remote-audio-unavailable';
  791. /**
  792. * Remote user publishes video. You will receive this notification when the remote user turns on the camera. Refer to: [Turn on/off camera and microphone](./tutorial-15-basic-dynamic-add-video.html)
  793. *
  794. * - You can listen for this event and {@link module:EVENT.REMOTE_VIDEO_UNAVAILABLE REMOTE_VIDEO_UNAVAILABLE} to update the UI icon for "whether the remote camera is turned on".
  795. * @see {@link module:TYPE.STREAM_TYPE_MAIN STREAM_TYPE_MAIN}
  796. * @see {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}
  797. * @default 'remote-video-available'
  798. * @memberof module:EVENT
  799. * @example
  800. * // Listen before entering the room
  801. * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
  802. * const userId = event.userId;
  803. * const streamType = event.streamType;
  804. * trtc.startRemoteVideo({userId, streamType, view});
  805. * });
  806. */
  807. readonly REMOTE_VIDEO_AVAILABLE: 'remote-video-available';
  808. /**
  809. * Remote user stops publishing video. You will receive this notification when the remote user turns off the camera.
  810. * @default 'remote-video-unavailable'
  811. * @memberof module:EVENT
  812. * @example
  813. * // Listen before entering the room
  814. * trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, event => {
  815. * const userId = event.userId;
  816. * const streamType = event.streamType;
  817. * // At this point, the SDK will automatically stop playing, and there is no need to call stopRemoteVideo.
  818. * });
  819. */
  820. readonly REMOTE_VIDEO_UNAVAILABLE: 'remote-video-unavailable';
  821. /**
  822. * @description Volume event<br>
  823. * After calling the {@link TRTC#enableAudioVolumeEvaluation enableAudioVolumeEvaluation} interface to enable the volume callback, the SDK will throw this event regularly to notify the volume of each userId.<br>
  824. * **Note**
  825. * - The callback contains the volume of the local microphone and the volume of the remote user. The callback will be triggered regardless of whether anyone is speaking.
  826. * - The event.result will be sorted from large to small according to the volume size.
  827. * - When userId is an empty string, it represents the volume of the local microphone.
  828. * - volume is a positive integer with a value of 0-100.
  829. * @default 'audio-volume'
  830. * @memberof module:EVENT
  831. * @example
  832. * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
  833. * event.result.forEach(({ userId, volume }) => {
  834. * const isMe = userId === ''; // When userId is an empty string, it represents the volume of the local microphone.
  835. * if (isMe) {
  836. * console.log(`my volume: ${volume}`);
  837. * } else {
  838. * console.log(`user: ${userId} volume: ${volume}`);
  839. * }
  840. * })
  841. * });
  842. *
  843. * // Enable volume callback and trigger the event every 1000ms
  844. * trtc.enableAudioVolumeEvaluation(1000);
  845. */
  846. readonly AUDIO_VOLUME: 'audio-volume';
  847. /**
  848. * @description Network quality statistics data event, which starts to be counted after entering the room and triggers every two seconds. This data reflects the network quality of your local uplink and downlink.
  849. * - The uplink network quality (uplinkNetworkQuality) refers to the network situation of uploading local streams (uplink connection network quality from SDK to Tencent Cloud)
  850. * - The downlink network quality (downlinkNetworkQuality) refers to the average network situation of downloading all streams (average network quality of all downlink connections from Tencent Cloud to SDK)
  851. *
  852. * The enumeration values and meanings are shown in the following table:
  853. * | Value | Meaning |
  854. * | :--- | :---- |
  855. * | 0 | Network state is unknown, indicating that the current trtc instance has not established an uplink/downlink connection |
  856. * | 1 | Network state is excellent |
  857. * | 2 | Network state is good |
  858. * | 3 | Network state is average |
  859. * | 4 | Network state is poor |
  860. * | 5 | Network state is very poor |
  861. * | 6 | Network connection is disconnected<br/>Note: If the downlink network quality is this value, it means that all downlink connections have been disconnected |
  862. * - uplinkRTT, uplinkLoss are the uplink RTT (ms) and uplink packet loss rate.
  863. * - downlinkRTT, downlinkLoss are the average RTT (ms) and average packet loss rate of all downlink connections.
  864. *
  865. * **Note**
  866. * - If you want to know the uplink and downlink network conditions of the other party, you need to broadcast the other party's network quality through IM.
  867. *
  868. * @default 'network-quality'
  869. * @memberof module:EVENT
  870. * @example
  871. * trtc.on(TRTC.EVENT.NETWORK_QUALITY, event => {
  872. * console.log(`network-quality, uplinkNetworkQuality:${event.uplinkNetworkQuality}, downlinkNetworkQuality: ${event.downlinkNetworkQuality}`)
  873. * console.log(`uplink rtt:${event.uplinkRTT} loss:${event.uplinkLoss}`)
  874. * console.log(`downlink rtt:${event.downlinkRTT} loss:${event.downlinkLoss}`)
  875. * })
  876. */
  877. readonly NETWORK_QUALITY: 'network-quality';
  878. /**
  879. * @description SDK and Tencent Cloud connection state change event, you can use this event to listen to the overall connection state of the SDK and Tencent Cloud.<br>
  880. * - 'DISCONNECTED': Connection disconnected
  881. * - 'CONNECTING': Connecting
  882. * - 'CONNECTED': Connected
  883. *
  884. * Meanings of different state changes:
  885. *
  886. * - DISCONNECTED -> CONNECTING: Trying to establish a connection, triggered when calling the enter room interface or when the SDK automatically reconnects.
  887. * - CONNECTING -> DISCONNECTED: Connection establishment failed, triggered when calling the exit room interface to interrupt the connection or when the connection fails after SDK retries.
  888. * - CONNECTING -> CONNECTED: Connection established successfully, triggered when the connection is successful.
  889. * - CONNECTED -> DISCONNECTED: Connection interrupted, triggered when calling the exit room interface or when the connection is disconnected due to network anomalies.
  890. *
  891. * Suggestion: You can listen to this event and display different UIs in different states to remind users of the current connection state.
  892. *
  893. * @default 'connection-state-changed'
  894. * @memberof module:EVENT
  895. * @example
  896. * trtc.on(TRTC.EVENT.CONNECTION_STATE_CHANGED, event => {
  897. * const prevState = event.prevState;
  898. * const curState = event.state;
  899. * });
  900. */
  901. readonly CONNECTION_STATE_CHANGED: 'connection-state-changed';
  902. /**
  903. * @description Audio playback state change event
  904. *
  905. * event.userId When userId is an empty string, it represents the local user, and when it is a non-empty string, it represents a remote user.
  906. *
  907. * event.state The value is as follows:
  908. * - 'PLAYING': start playing
  909. * - event.reason is 'playing' or 'unmute'.
  910. * - 'PAUSED': pause playback
  911. * - When event.reason is 'pause', it is triggered by the pause event of the \<audio\> element. The following situations will trigger:
  912. * - Call the HTMLMediaElement.pause interface.
  913. * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
  914. * - When userId is oneself, this event is triggered, indicating that audio collection is paused, usually caused by device abnormalities, such as being preempted by other applications on the device, at this time, the user needs to be guided to recollect.
  915. * - When userId is others, this event is triggered, indicating that the received audio data is not enough to play. Usually caused by network jitter, no processing is required on the access side. When the received data is sufficient to play, it will automatically resume.
  916. * - 'STOPPED': stop playing
  917. * - event.reason is 'ended'.
  918. *
  919. * event.reason The reason for the state change, the value is as follows:
  920. * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
  921. * - 'mute': The audio track cannot provide data temporarily, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
  922. * - 'unmute': The audio track resumes providing data, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/unmute_event | MediaStreamTrack.unmute_event}
  923. * - 'ended': The audio track has been closed
  924. * - 'pause': Playback paused
  925. * @default 'audio-play-state-changed'
  926. * @memberof module:EVENT
  927. * @example
  928. * trtc.on(TRTC.EVENT.AUDIO_PLAY_STATE_CHANGED, event => {
  929. * console.log(`${event.userId} player is ${event.state} because of ${event.reason}`);
  930. * });
  931. */
  932. readonly AUDIO_PLAY_STATE_CHANGED: 'audio-play-state-changed';
  933. /**
  934. * @description Video playback state change event
  935. *
  936. * event.userId When userId is an empty string, it represents the local user, and when it is a non-empty string, it represents a remote user.
  937. *
  938. * event.streamType Stream type, value: {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN} {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}
  939. *
  940. * event.state The value is as follows:
  941. * - 'PLAYING': start playing
  942. * - event.reason is 'playing' or 'unmute'.
  943. * - 'PAUSED': pause playback
  944. * - When event.reason is 'pause', it is triggered by the pause event of the \<video\> element. The following situations will trigger:
  945. * - Call the HTMLMediaElement.pause interface.
  946. * - After successful playback, the view container for playing the video is removed from the DOM.
  947. * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
  948. * - When userId is oneself, this event is triggered, indicating that video collection is paused, usually caused by device abnormalities, such as being preempted by other applications on the device, at this time, the user needs to be guided to recollect.
  949. * - When userId is others, this event is triggered, indicating that the received video data is not enough to play. Usually caused by network jitter, no processing is required on the access side. When the received data is sufficient to play, it will automatically resume.
  950. * - 'STOPPED': stop playing
  951. * - event.reason is 'ended'.
  952. *
  953. * event.reason The reason for the state change, the value is as follows:
  954. * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
  955. * - 'mute': The video track cannot provide data temporarily, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
  956. * - 'unmute': The video track resumes providing data, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/unmute_event | MediaStreamTrack.unmute_event}
  957. * - 'ended': The video track has been closed
  958. * - 'pause': Playback paused
  959. * @default 'video-play-state-changed'
  960. * @memberof module:EVENT
  961. * @example
  962. * trtc.on(TRTC.EVENT.VIDEO_PLAY_STATE_CHANGED, event => {
  963. * console.log(`${event.userId} ${event.streamType} video player is ${event.state} because of ${event.reason}`);
  964. * });
  965. */
  966. readonly VIDEO_PLAY_STATE_CHANGED: 'video-play-state-changed';
  967. /**
  968. * @description Notification event for local screen sharing stop, only valid for local screen sharing streams.
  969. * @default 'screen-share-stopped'
  970. * @memberof module:EVENT
  971. * @example
  972. * trtc.on(TRTC.EVENT.SCREEN_SHARE_STOPPED, () => {
  973. * console.log('screen sharing was stopped');
  974. * });
  975. */
  976. readonly SCREEN_SHARE_STOPPED: 'screen-share-stopped';
  977. /**
  978. * @description Notification event for device changes such as camera and microphone.
  979. * - event.device is a [MediaDeviceInfo](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) object with properties:
  980. * - deviceId: device ID
  981. * - label: device description information
  982. * - groupId: device group ID
  983. * - event.type value: `'camera'|'microphone'|'speaker'`
  984. * - event.action value:
  985. * - 'add' device has been added.
  986. * - 'remove' device has been removed.
  987. * - 'active' device has been activated, for example: after startLocalVideo is successful, this event will be triggered.
  988. * @default 'device-changed'
  989. * @memberof module:EVENT
  990. * @example
  991. * trtc.on(TRTC.EVENT.DEVICE_CHANGED, (event) => {
  992. * console.log(`${event.type}(${event.device.label}) ${event.action}`);
  993. * });
  994. */
  995. readonly DEVICE_CHANGED: 'device-changed';
  996. /**
  997. * @description Publish state change event.
  998. * - event.mediaType media type, value: `'audio'|'video'|'screen'`.
  999. * - event.state current publish state, value:
  1000. * - `'starting'` trying to publish stream
  1001. * - `'started'` publish stream succeeded
  1002. * - `'stopped'` publish stream stopped, see event.reason field for the reason
  1003. * - event.prevState the publish state at the last event trigger, with the same type as event.state.
  1004. * - event.reason the reason for the publish state to become `'stopped'`, value:
  1005. * - `'timeout'` publish stream timeout, usually caused by network jitter or firewall interception. The SDK will keep retrying, and the business side can guide the user to check the network or change the network at this time.
  1006. * - `'error'` publish stream error, at this time, you can get the specific error information from event.error, usually caused by the browser not supporting H264 encoding.
  1007. * - `'api-call'` publish stream stopped due to business side API call, for example, stopLocalVideo was called to stop the publish stream before startLocalVideo was successful, which is a normal behavior and the business side does not need to pay attention to it.
  1008. * - event.error error information when event.reason is `'error'`.
  1009. * @default 'publish-state-changed'
  1010. * @memberof module:EVENT
  1011. * @example
  1012. * trtc.on(TRTC.EVENT.PUBLISH_STATE_CHANGED, (event) => {
  1013. * console.log(`${event.mediaType} ${event.state} ${event.reason}`);
  1014. * });
  1015. */
  1016. readonly PUBLISH_STATE_CHANGED: 'publish-state-changed';
  1017. /**
  1018. * @since v5.3.0
  1019. * @description a new MediaStreamTrack object received.
  1020. * @default 'track'
  1021. * @memberof module:EVENT
  1022. * @example
  1023. * trtc.on(TRTC.EVENT.TRACK, event => {
  1024. * // userId === '' means event.track is a local track, otherwise it's a remote track
  1025. * const isLocal = event.userId === '';
  1026. * // Usually the sub stream is a screen-sharing video stream.
  1027. * const isSubStream = event.streamType === TRTC.TYPE.STREAM_TYPE_SUB;
  1028. * const mediaStreamTrack = event.track;
  1029. * const kind = event.track.kind; // audio or video
  1030. * })
  1031. */
  1032. readonly TRACK: 'track';
  1033. /**
  1034. * @description TRTC statistics.<br>
  1035. *
  1036. * - SDK will fires this event once every 2s.
  1037. * - You can get the network quality, statistics of audio and video from this event. For detailed parameter description, please refer to {@link TRTCStatistics}.
  1038. * @default 'statistics'
  1039. * @since v5.2.0
  1040. * @memberof module:EVENT
  1041. * @example
  1042. * trtc.on(TRTC.EVENT.STATISTICS, statistics => {
  1043. * console.warn(statistics.rtt, statistics.upLoss, statistics.downLoss);
  1044. * })
  1045. */
  1046. readonly STATISTICS: 'statistics';
  1047. /**
  1048. * @since v5.3.0
  1049. * @description SEI message received<br>
  1050. * @default 'sei-message'
  1051. * @memberof module:EVENT
  1052. * @example
  1053. * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
  1054. * console.log(`received sei message from ${event.userId}, data: ${event.data}, streamType: ${event.streamType}`)
  1055. * })
  1056. */
  1057. readonly SEI_MESSAGE: 'sei-message';
  1058. /**
  1059. * @since v5.6.0
  1060. * @description received a new custom message.
  1061. * @default 'custom-message'
  1062. * @memberof module:EVENT
  1063. * @example
  1064. * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
  1065. * // event.userId: remote userId.
  1066. * // event.cmdId: message cmdId.
  1067. * // event.seq: message sequence number.
  1068. * // event.data: custom message data, type is ArrayBuffer.
  1069. * })
  1070. */
  1071. readonly CUSTOM_MESSAGE: 'custom-message';
  1072. };
  1073. export declare interface TRTCEventTypes {
  1074. [TRTCEvent.ERROR]: [RtcError];
  1075. [TRTCEvent.AUTOPLAY_FAILED]: [{
  1076. userId: string;
  1077. }];
  1078. [TRTCEvent.KICKED_OUT]: [{
  1079. reason: Exclude<BannedReason, 'user_time_out'>;
  1080. }];
  1081. [TRTCEvent.REMOTE_USER_ENTER]: [{
  1082. userId: string;
  1083. }];
  1084. [TRTCEvent.REMOTE_USER_EXIT]: [{
  1085. userId: string;
  1086. }];
  1087. [TRTCEvent.REMOTE_AUDIO_AVAILABLE]: [{
  1088. userId: string;
  1089. }];
  1090. [TRTCEvent.REMOTE_AUDIO_UNAVAILABLE]: [{
  1091. userId: string;
  1092. }];
  1093. [TRTCEvent.REMOTE_VIDEO_AVAILABLE]: [{
  1094. userId: string;
  1095. streamType: TRTCStreamType;
  1096. }];
  1097. [TRTCEvent.REMOTE_VIDEO_UNAVAILABLE]: [{
  1098. userId: string;
  1099. streamType: TRTCStreamType;
  1100. }];
  1101. [TRTCEvent.AUDIO_VOLUME]: [{
  1102. result: {
  1103. userId: string;
  1104. volume: number;
  1105. }[];
  1106. }];
  1107. [TRTCEvent.NETWORK_QUALITY]: [NetworkQuality];
  1108. [TRTCEvent.CONNECTION_STATE_CHANGED]: [{
  1109. prevState: ConnectionState;
  1110. state: ConnectionState;
  1111. }];
  1112. [TRTCEvent.AUDIO_PLAY_STATE_CHANGED]: [{
  1113. userId: string;
  1114. state: PlayerState;
  1115. reason: string;
  1116. }];
  1117. [TRTCEvent.VIDEO_PLAY_STATE_CHANGED]: [{
  1118. userId: string;
  1119. streamType: TRTCStreamType;
  1120. state: PlayerState;
  1121. reason: string;
  1122. }];
  1123. [TRTCEvent.SCREEN_SHARE_STOPPED]: [];
  1124. [TRTCEvent.DEVICE_CHANGED]: [{
  1125. type: TRTCDeviceType;
  1126. action: TRTCDeviceAction;
  1127. device: MediaDeviceInfo;
  1128. }];
  1129. [TRTCEvent.PUBLISH_STATE_CHANGED]: [
  1130. {
  1131. mediaType: 'audio' | 'video' | 'screen';
  1132. state: 'started' | 'stopped' | 'starting';
  1133. prevState: 'started' | 'stopped' | 'starting';
  1134. reason?: 'timeout' | 'error' | 'api-call';
  1135. error?: RtcError;
  1136. }
  1137. ];
  1138. [TRTCEvent.SEI_MESSAGE]: [{
  1139. data: ArrayBuffer;
  1140. userId: string;
  1141. streamType: TRTCStreamType;
  1142. seiPayloadType: number;
  1143. }];
  1144. [TRTCEvent.STATISTICS]: [statistics: TRTCStatistics];
  1145. [TRTCEvent.TRACK]: [{
  1146. userId: string;
  1147. streamType?: TRTCStreamType;
  1148. track: MediaStreamTrack;
  1149. }];
  1150. [TRTCEvent.CUSTOM_MESSAGE]: [CustomMessage];
  1151. }
  1152. export declare interface CustomMessageData {
  1153. cmdId: number;
  1154. data: ArrayBuffer;
  1155. }
  1156. export declare interface CustomMessage extends CustomMessageData {
  1157. userId: string;
  1158. seq: number;
  1159. }
  1160. export declare class TRTC {
  1161. /**
  1162. * Create a TRTC object for implementing functions such as entering a room, previewing, publishing, and subscribing streams.<br>
  1163. *
  1164. * **Note:**
  1165. * - You must create a TRTC object first and call its methods and listen to its events to implement various functions required by the business.
  1166. * @example
  1167. * // Create a TRTC object
  1168. * const trtc = TRTC.create();
  1169. *
  1170. * @returns {TRTC} TRTC object
  1171. */
  1172. static create(options?: TRTCOptions): TRTC;
  1173. /**
  1174. * @private
  1175. * regi <br>
  1176. *
  1177. * @example
  1178. * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
  1179. * trtc.use({ plugin: VirtualBackground });
  1180. *
  1181. * @example
  1182. * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
  1183. * trtc.use({ plugin: VirtualBackground, assetsPath: './js/assets/' });
  1184. *
  1185. * @example
  1186. * // 简写使用
  1187. * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
  1188. * trtc.use(VirtualBackground);
  1189. */
  1190. use(pluginObject: PluginWithAssets | TRTCPlugin): void;
  1191. /**
  1192. * @typedef TurnServer
  1193. * @property {string} url TURN server url
  1194. * @property {string=} username TURN server auth user name
  1195. * @property {string=} credential TURN server password
  1196. * @property {string=} [credentialType=password] TURN server verify password type
  1197. */
  1198. /**
  1199. * @typedef ProxyServer
  1200. * @property {string} [websocketProxy] websocket service proxy
  1201. * @property {string} [loggerProxy] log service agent
  1202. * @property {TurnServer[]} [turnServer] media data transmission agent
  1203. * @property {'all'|'relay'} [iceTransportPolicy='all'] 'all' gives priority to directly connecting to TRTC, and tries to go to the turn server if the connection fails.<br>
  1204. * 'relay' forces the connection through the TURN server.
  1205. */
  1206. /**
  1207. * Enter a video call room.<br>
  1208. * - Entering a room means starting a video call session. Only after entering the room successfully can you make audio and video calls with other users in the room.
  1209. * - You can publish local audio and video streams through {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} respectively. After successful publishing, other users in the room will receive the {@link module:EVENT.REMOTE_AUDIO_AVAILABLE REMOTE_AUDIO_AVAILABLE} and {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event notifications.
  1210. * - By default, the SDK automatically plays remote audio. You need to call {@link TRTC#startRemoteVideo startRemoteVideo()} to play remote video.
  1211. *
  1212. * @param {object} options Enter room parameters
  1213. * @param {number} options.sdkAppId sdkAppId <br>
  1214. * You can obtain the sdkAppId information in the **Application Information** section after creating a new application by clicking **Application Management** > **Create Application** in the [TRTC Console](https://console.intl.cloud.tencent.com/trtc).
  1215. * @param {string} options.userId User ID <br>
  1216. * It is recommended to limit the length to 32 bytes, and only allow uppercase and lowercase English letters (a-zA-Z), numbers (0-9), underscores, and hyphens.
  1217. * @param {string} options.userSig UserSig signature <br>
  1218. * Please refer to [UserSig related](https://www.tencentcloud.com/document/product/647/35166) for the calculation method of userSig.
  1219. * @param {number=} options.roomId
  1220. * the value must be an integer between 1 and 4294967294<br>
  1221. * <font color="red">If you need to use a string type room id, please use the strRoomId parameter. One of roomId and strRoomId must be passed in. If both are passed in, the roomId will be selected first.</font>
  1222. * @param {string=} options.strRoomId
  1223. * String type room id, the length is limited to 64 bytes, and only supports the following characters:
  1224. * - Uppercase and lowercase English letters (a-zA-Z)
  1225. * - Numbers (0-9)
  1226. * - Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
  1227. * <font color="red">Note: It is recommended to use a numeric type roomId. The string type room id "123" is not the same room as the numeric type room id 123.</font>
  1228. * @param {string} [options.scene] Application scene, currently supports the following two scenes:
  1229. * - {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} (default) Real-time call scene, which is suitable for 1-to-1 audio and video calls, or online meetings with up to 300 participants. {@tutorial 04-info-uplink-limits}.
  1230. * - {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} Interactive live streaming scene, which is suitable for online live streaming scenes with up to 100,000 people, but you need to specify the role field in the options parameter introduced next.
  1231. * @param {string=} [options.role] User role, only meaningful in the {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} scene, and the {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} scene does not need to specify the role. Currently supports two roles:
  1232. * - {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} (default) Anchor
  1233. * - {@link module:TYPE.ROLE_AUDIENCE TRTC.TYPE.ROLE_AUDIENCE} Audience
  1234. * Note: The audience role does not have the permission to publish local audio and video, only the permission to watch remote streams. If the audience wants to interact with the anchor by connecting to the microphone, please switch the role to the anchor through {@link TRTC#switchRole switchRole()} before publishing local audio and video.
  1235. * @param {boolean} [options.autoReceiveAudio=true] Whether to automatically receive audio. When a remote user publishes audio, the SDK automatically plays the remote user's audio.
  1236. * @param {boolean} [options.autoReceiveVideo=false] Whether to automatically receive video. When a remote user publishes video, the SDK automatically subscribes and decodes the remote video. You need to call {@link TRTC#startRemoteVideo startRemoteVideo} to play the remote video.
  1237. * - The default value was changed to `false` since v5.6.0. Refer to [Breaking Changed for v5.6.0](https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/tutorial-00-info-update-guideline.html).
  1238. * @param {boolean} [options.enableAutoPlayDialog] Whether to enable the SDK's automatic playback failure dialog box, default: true.
  1239. * - Enabled by default. When automatic playback fails, the SDK will pop up a dialog box to guide the user to click the page to restore audio and video playback.
  1240. * - Can be set to false in order to turn off. Refer to {@tutorial 21-advanced-auto-play-policy}.
  1241. * @param {string|ProxyServer} [options.proxy] proxy config. Refer to {@tutorial 34-advanced-proxy}.
  1242. * @param {boolean} [options.privateMapKey] 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).<br>[privateMapKey permission configuration](https://www.tencentcloud.com/document/product/647/35157?lang=en&pg=).
  1243. * @throws
  1244. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1245. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1246. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1247. * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
  1248. * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
  1249. * @example
  1250. * const trtc = TRTC.create();
  1251. * await trtc.enterRoom({ roomId: 8888, sdkAppId, userId, userSig });
  1252. */
  1253. enterRoom(params: EnterRoomConfig): Promise<void>;
  1254. /**
  1255. * Exit the current audio and video call room.
  1256. * - After exiting the room, the connection with remote users will be closed, and remote audio and video will no longer be received and played, and the publishing of local audio and video will be stopped.
  1257. * - The capture and preview of the local camera and microphone will not stop. You can call {@link TRTC#stopLocalVideo stopLocalVideo()} and {@link TRTC#stopLocalAudio stopLocalAudio()} to stop capturing local microphone and camera.
  1258. * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1259. * @memberof TRTC
  1260. * @example
  1261. * await trtc.exitRoom();
  1262. */
  1263. exitRoom(): Promise<void>;
  1264. /**
  1265. * Switches the user role, only effective in TRTC.TYPE.SCENE_LIVE interactive live streaming mode.
  1266. *
  1267. * In interactive live streaming mode, a user may need to switch between "audience" and "anchor".
  1268. * You can determine the role through the role field in {@link TRTC#enterRoom enterRoom()}, or switch roles after entering the room through switchRole.
  1269. * - Audience switches to anchor, call trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR) to convert the user role to TRTC.TYPE.ROLE_ANCHOR anchor role, and then call {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} to publish local audio and video as needed.
  1270. * - Anchor switches to audience, call trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE) to convert the user role to TRTC.TYPE.ROLE_AUDIENCE audience role. If there is already published local audio and video, the SDK will cancel the publishing of local audio and video.
  1271. * > !
  1272. * > - This interface can only be called after entering the room successfully.
  1273. * > - After closing the camera and microphone, it is recommended to switch to the audience role in time to avoid the anchor role occupying the resources of 50 upstreams.
  1274. * @param {string} role User role
  1275. * - TRTC.TYPE.ROLE_ANCHOR anchor, can publish local audio and video, up to 50 anchors can publish local audio and video in a single room at the same time.
  1276. * - TRTC.TYPE.ROLE_AUDIENCE audience, cannot publish local audio and video, can only watch remote streams, and there is no upper limit on the number of audience members in a single room.
  1277. * @param {object} [option]
  1278. * @param {string} [option.privateMapKey] `Since v5.3.0+` <br>
  1279. * The privateMapKey may expire after a timeout, so you can use this parameter to update the privateMapKey.
  1280. * @throws
  1281. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1282. * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
  1283. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1284. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1285. * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
  1286. * @memberof TRTC
  1287. * @example
  1288. * // After entering the room successfully
  1289. * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, audience switches to anchor
  1290. * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR);
  1291. * // Switch from audience role to anchor role and start streaming
  1292. * await trtc.startLocalVideo();
  1293. *
  1294. * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, anchor switches to audience
  1295. * await trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE);
  1296. * @example
  1297. * // Since v5.3.0+
  1298. * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR, { privateMapKey: 'your new privateMapKey' });
  1299. */
  1300. switchRole(role: UserRole, option?: {
  1301. privateMapKey?: string;
  1302. latencyLevel?: number;
  1303. }): Promise<void>;
  1304. /**
  1305. * Destroy the TRTC instance <br/>
  1306. *
  1307. * After exiting the room, if the business side no longer needs to use trtc, you need to call this interface to destroy the trtc instance in time and release related resources.
  1308. *
  1309. * Note:
  1310. * - The trtc instance after destruction cannot be used again.
  1311. * - If you have entered the room, you need to call the {@link TRTC#exitRoom TRTC.exitRoom} interface to exit the room successfully before calling this interface to destroy trtc.
  1312. *
  1313. * @example
  1314. * // When the call is over
  1315. * await trtc.exitRoom();
  1316. * // If the trtc is no longer needed, destroy the trtc and release the reference.
  1317. * trtc.destroy();
  1318. * trtc = null;
  1319. * @throws {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1320. * @memberof TRTC
  1321. */
  1322. destroy(): void;
  1323. /**
  1324. * Start collecting audio from the local microphone and publish it to the current room.
  1325. * - When to call: can be called before or after entering the room, cannot be called repeatedly.
  1326. * - Only one microphone can be opened for a trtc instance. If you need to open another microphone for testing in the case of already opening one microphone, you can create multiple trtc instances to achieve it.
  1327. *
  1328. * @param {object} [config] - Configuration item
  1329. * @param {boolean} [config.publish] - Whether to publish local audio to the room, default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
  1330. * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
  1331. * @param {object} [config.option] - Local audio options
  1332. * @param {string} [config.option.microphoneId]- Specify which microphone to use
  1333. * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
  1334. * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
  1335. * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
  1336. * @param {string} [config.option.profile] - Audio encoding configuration, default {@link module:TYPE.AUDIO_PROFILE_STANDARD TRTC.TYPE.AUDIO_PROFILE_STANDARD}
  1337. * @throws
  1338. * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
  1339. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1340. * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
  1341. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1342. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1343. * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
  1344. * @example
  1345. * // Collect the default microphone and publish
  1346. * await trtc.startLocalAudio();
  1347. * @example
  1348. * // The following is a code example for testing microphone volume, which can be used for microphone volume detection.
  1349. * trtc.enableAudioVolumeEvaluation();
  1350. * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => { });
  1351. * // No need to publish audio for testing microphone
  1352. * await trtc.startLocalAudio({ publish: false });
  1353. * // After the test is completed, turn off the microphone
  1354. * await trtc.stopLocalAudio();
  1355. * @memberof TRTC
  1356. */
  1357. startLocalAudio(config?: LocalAudioConfig): Promise<void>;
  1358. /**
  1359. * Update the configuration of the local microphone.
  1360. * - When to call: This interface needs to be called after {@link TRTC#startLocalAudio startLocalAudio()} is successful and can be called multiple times.
  1361. * - This method uses incremental update: only update the passed parameters, and keep the parameters that are not passed unchanged.
  1362. * @param {object} [config]
  1363. * @param {boolean} [config.publish] - Whether to publish local audio to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
  1364. * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
  1365. * @param {object} [config.option] - Local audio configuration
  1366. * @param {string} [config.option.microphoneId] - Specify which microphone to use to switch microphones.
  1367. * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
  1368. * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
  1369. * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
  1370. * @throws
  1371. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1372. * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
  1373. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1374. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1375. * @example
  1376. * // Switch microphone
  1377. * const microphoneList = await TRTC.getMicrophoneList();
  1378. * if (microphoneList[1]) {
  1379. * await trtc.updateLocalAudio({ option: { microphoneId: microphoneList[1].deviceId }});
  1380. * }
  1381. * @memberof TRTC
  1382. */
  1383. updateLocalAudio(config: UpdateLocalAudioConfig): Promise<void>;
  1384. /**
  1385. * Stop collecting and publishing the local microphone.
  1386. * - If you just want to mute the microphone, please use updateLocalAudio({ mute: true }). Refer to: {@tutorial 15-basic-dynamic-add-video}.
  1387. * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1388. * @example
  1389. * await trtc.stopLocalAudio();
  1390. */
  1391. stopLocalAudio(): Promise<void>;
  1392. /**
  1393. * @typedef {object|string} VideoProfile - Configuration for local video stream
  1394. *
  1395. * Video configuration parameters, can use preset values in string format or custom resolution and other parameters
  1396. * | Video Profile | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) | Remarks |
  1397. * | :--- | :--- | :--- | :--- | :--- |
  1398. * | 120p | 160 x 120 | 15 | 200 ||
  1399. * | 180p | 320 x 180 | 15 | 350 ||
  1400. * | 240p | 320 x 240 | 15 | 400 ||
  1401. * | 360p | 640 x 360 | 15 | 800 ||
  1402. * | 480p | 640 x 480 | 15 | 900 ||
  1403. * | 720p | 1280 x 720 | 15 | 1500 ||
  1404. * | 1080p | 1920 x 1080 | 15 | 2000 ||
  1405. * | 1440p | 2560 x 1440 | 30 | 4860 ||
  1406. * | 4K | 3840 x 2160 | 30 | 9000 ||
  1407. * @property {number} width - Video width
  1408. * @property {number} height - Video height
  1409. * @property {number} frameRate - Video frame rate
  1410. * @property {number} bitrate - Video bitrate
  1411. * @example
  1412. * const config = {
  1413. * option: {
  1414. * profile: '480p',
  1415. * },
  1416. * }
  1417. * await trtc.startLocalVideo(config);
  1418. * @example
  1419. * const config = {
  1420. * option: {
  1421. * profile: {
  1422. * width: 640,
  1423. * height: 480,
  1424. * frameRate: 15,
  1425. * bitrate: 900,
  1426. * }
  1427. * }
  1428. * }
  1429. * await trtc.startLocalVideo(config);
  1430. */
  1431. /**
  1432. * Start collecting video from the local camera, play the camera's video on the specified HTMLElement tag, and publish the camera's video to the current room.
  1433. * - When to call: can be called before or after entering the room, but cannot be called repeatedly.
  1434. * - Only one camera can be started per trtc instance. If you need to start another camera for testing while one camera is already started, you can create multiple trtc instances to achieve this.
  1435. * @param {object} [config]
  1436. * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or ID for local video preview. If not passed or passed as null, the video will not be played.
  1437. * @param {boolean} [config.publish] - Whether to publish the local video to the room. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
  1438. * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
  1439. * @param {object} [config.option] - Local video configuration
  1440. * @param {string} [config.option.cameraId] - Specify which camera to use for switching cameras.
  1441. * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera.
  1442. * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
  1443. * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
  1444. * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
  1445. * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
  1446. * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
  1447. * - false: Boolean value, represents no mirroring.
  1448. *
  1449. * <font color="orange"> Note: Before version 5.3.2, only boolean can be passed, where true represents local preview mirroring, and false represents no mirroring.</font>
  1450. * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `cover`. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
  1451. * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main video.
  1452. * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
  1453. * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first(default) ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
  1454. * @throws
  1455. * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
  1456. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1457. * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
  1458. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1459. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1460. * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
  1461. * @example
  1462. * // Preview and publish the camera
  1463. * await trtc.startLocalVideo({
  1464. * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
  1465. * });
  1466. * @example
  1467. * // Preview the camera without publishing. Can be used for camera testing.
  1468. * const config = {
  1469. * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
  1470. * publish: false // Do not publish the camera
  1471. * }
  1472. * await trtc.startLocalVideo(config);
  1473. * // Call updateLocalVideo when you need to publish the video
  1474. * await trtc.updateLocalVideo({ publish:true });
  1475. * @example
  1476. * // Use a specified camera.
  1477. * const cameraList = await TRTC.getCameraList();
  1478. * if (cameraList[0]) {
  1479. * await trtc.startLocalVideo({
  1480. * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
  1481. * option: {
  1482. * cameraId: cameraList[0].deviceId,
  1483. * }
  1484. * });
  1485. * }
  1486. *
  1487. * // use front camera on mobile device.
  1488. * await trtc.startLocalVideo({ view, option: { useFrontCamera: true }});
  1489. * // use rear camera on mobile device.
  1490. * await trtc.startLocalVideo({ view, option: { useFrontCamera: false }});
  1491. * @memberof TRTC
  1492. */
  1493. startLocalVideo(config?: LocalVideoConfig): Promise<void>;
  1494. /**
  1495. * Update the local camera configuration.
  1496. * - This interface needs to be called after {@link TRTC#startLocalVideo startLocalVideo()} is successful.
  1497. * - This interface can be called multiple times.
  1498. * - This method uses incremental update: only updates the passed-in parameters, and keeps the parameters that are not passed in unchanged.
  1499. * @param {object} [config]
  1500. * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id of the preview camera. If not passed in or passed in null, the video will not be rendered, but the container that consumes bandwidth will still be pushed.
  1501. * @param {boolean} [config.publish] - Whether to publish the local video to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
  1502. * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
  1503. * @param {object} [config.option] - Local video configuration
  1504. * @param {string} [config.option.cameraId] - Specify which camera to use
  1505. * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera
  1506. * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
  1507. * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
  1508. * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
  1509. * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
  1510. * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
  1511. * - false: Boolean value, represents no mirroring.
  1512. * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit| CSS object-fit} property
  1513. * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main stream
  1514. * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
  1515. * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
  1516. * @throws
  1517. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1518. * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
  1519. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1520. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1521. * @example
  1522. * // Switch camera
  1523. * const cameraList = await TRTC.getCameraList();
  1524. * if (cameraList[1]) {
  1525. * await trtc.updateLocalVideo({ option: { cameraId: cameraList[1].deviceId }});
  1526. * }
  1527. * @example
  1528. * // Stop publishing video, but keep local preview
  1529. * await trtc.updateLocalVideo({ publish:false });
  1530. * @memberof TRTC
  1531. */
  1532. updateLocalVideo(config: LocalVideoConfig): Promise<void>;
  1533. /**
  1534. * Stop capturing, previewing, and publishing the local camera.
  1535. * - If you only want to stop publishing video but keep the local camera preview, you can use the {@link TRTC#updateLocalVideo updateLocalVideo({ publish:false })} method.<br>
  1536. * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1537. * @example
  1538. * await trtc.stopLocalVideo();
  1539. */
  1540. stopLocalVideo(): Promise<void>;
  1541. /**
  1542. * @typedef {object|string} ScreenShareProfile - Screen sharing resolution, bit rate, and frame rate configuration
  1543. * Screen sharing configuration parameters, can use preset values or custom resolution and other parameters
  1544. * | Screen Profile | Resolution (width x height) | Frame Rate (fps) | Bitrate (kbps) |
  1545. * | :--- | :--- | :--- | :--- |
  1546. * | 480p | 640 x 480 | 5 | 900 |
  1547. * | 480p_2 | 640 x 480 | 30 | 1000 |
  1548. * | 720p | 1280 x 720 | 5 | 1200 |
  1549. * | 720p_2 | 1280 x 720 | 30 | 3000 |
  1550. * | 1080p | 1920 x 1080 | 5 | 1600 |
  1551. * | 1080p_2 | 1920 x 1080 | 30 | 4000 |
  1552. * - The default resolution for screen sharing is `1080p`.
  1553. * - If the above profiles do not meet your business needs, you can also specify custom resolution, frame rate, and bitrate.
  1554. * @property {number} width - Screen sharing width
  1555. * @property {number} height - Screen sharing height
  1556. * @property {number} frameRate - Screen sharing frame rate
  1557. * @property {number} bitrate - Screen sharing bitrate
  1558. * @example
  1559. * const config = {
  1560. * option: {
  1561. * profile: '720p',
  1562. * },
  1563. * }
  1564. * await trtc.startScreenShare(config);
  1565. */
  1566. /**
  1567. * Start screen sharing.
  1568. *
  1569. * - After starting screen sharing, other users in the room will receive the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event, with streamType as {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}, and other users can play screen sharing through {@link TRTC#startRemoteVideo startRemoteVideo}.
  1570. * @param {object} [config]
  1571. * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for previewing local screen sharing. If not passed or passed as null, local screen sharing will not be rendered.
  1572. * @param {boolean} [config.publish] - Whether to publish screen sharing to the room. The default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
  1573. * @param {object} [config.option] - Screen sharing configuration
  1574. * @param {boolean} [config.option.systemAudio] - Whether to capture system audio. The default is false.
  1575. * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
  1576. * @param {ScreenShareProfile} [config.option.profile] - Screen sharing encoding configuration.
  1577. * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first(default) ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
  1578. * @param {HTMLElement} [config.option.captureElement] - Capture screen from the specified element of current tab. Available on Chrome 104+.
  1579. * @param {'current-tab' | 'tab' | 'window' | 'monitor'} [config.option.preferDisplaySurface='monitor'] - The prefer display surface for screen sharing. Available on Chrome 94+.
  1580. * - The default is monitor, which means that monitor capture will be displayed first in the Screen Sharing Capture pre-checkbox。
  1581. * - If you fill in 'current-tab', the pre-checkbox will only show the current page.
  1582. * @throws
  1583. * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
  1584. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1585. * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
  1586. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1587. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1588. * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
  1589. * @example
  1590. * // Start screen sharing
  1591. * await trtc.startScreenShare();
  1592. * @memberof TRTC
  1593. */
  1594. startScreenShare(config?: ScreenShareConfig): Promise<void>;
  1595. /**
  1596. * Update screen sharing configuration
  1597. * - This interface needs to be called after {@link TRTC#startScreenShare startScreenShare()} is successful.
  1598. * - This interface can be called multiple times.
  1599. * - This method uses incremental update: only update the passed-in parameters, and keep the parameters that are not passed-in unchanged.
  1600. * @param {object} [config]
  1601. * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for screen sharing preview. If not passed in or passed in null, the screen sharing will not be rendered.
  1602. * @param {boolean} [config.publish=true] - Whether to publish screen sharing to the room
  1603. * @param {object} [config.option] - Screen sharing configuration
  1604. * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
  1605. * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
  1606. * @throws
  1607. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1608. * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
  1609. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1610. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1611. * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
  1612. * @example
  1613. * // Stop screen sharing, but keep the local preview of screen sharing
  1614. * await trtc.updateScreenShare({ publish:false });
  1615. * @memberof TRTC
  1616. */
  1617. updateScreenShare(config: UpdateScreenShareConfig): Promise<void>;
  1618. /**
  1619. * Stop screen sharing.
  1620. * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1621. * @example
  1622. * await trtc.stopScreenShare();
  1623. */
  1624. stopScreenShare(): Promise<void>;
  1625. /**
  1626. * Play remote video
  1627. *
  1628. * - When to call: Call after receiving the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE TRTC.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE)} event.
  1629. * @param {object} [config]
  1630. * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
  1631. * @param {string} config.userId - Remote user ID
  1632. * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
  1633. * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
  1634. * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
  1635. * @param {object} [config.option] - Remote video configuration
  1636. * @param {boolean} [config.option.small] - Whether to subscribe small streams
  1637. * @param {boolean} [config.option.mirror] - Whether to enable mirror
  1638. * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
  1639. * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
  1640. * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
  1641. * @throws
  1642. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1643. * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
  1644. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1645. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1646. * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
  1647. * @example
  1648. * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
  1649. * // You need to place the video container in the DOM in advance, and it is recommended to use `${userId}_${streamType}` as the element id.
  1650. * trtc.startRemoteVideo({ userId, streamType, view: `${userId}_${streamType}` });
  1651. * })
  1652. * @memberof TRTC
  1653. */
  1654. startRemoteVideo(config: RemoteVideoConfig): Promise<void>;
  1655. /**
  1656. * Update remote video playback configuration<br>
  1657. * - This method should be called after {@link TRTC#startRemoteVideo startRemoteVideo} is successful.
  1658. * - This method can be called multiple times.
  1659. * - This method uses incremental updates, so only the configuration items that need to be updated need to be passed in.
  1660. * @param {object} [config]
  1661. * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
  1662. * @param {string} config.userId - Remote user ID
  1663. * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
  1664. * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
  1665. * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
  1666. * @param {object} [config.option] - Remote video configuration
  1667. * @param {boolean} [config.option.small] - Whether to subscribe small streams. Refer to: {@tutorial 27-advanced-small-stream}.
  1668. * @param {boolean} [config.option.mirror] - Whether to enable mirror
  1669. * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
  1670. * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
  1671. * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
  1672. * @throws
  1673. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1674. * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
  1675. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1676. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1677. * @example
  1678. * const config = {
  1679. * view: document.getElementById(userId), // you can use a new view to update the position of video.
  1680. * userId,
  1681. * streamType: TRTC.TYPE.STREAM_TYPE_MAIN
  1682. * }
  1683. * await trtc.updateRemoteVideo(config);
  1684. * @memberof TRTC
  1685. */
  1686. updateRemoteVideo(config: RemoteVideoConfig): Promise<void>;
  1687. /**
  1688. * Used to stop remote video playback.<br>
  1689. * @param {object} config - Remote video configuration
  1690. * @param {string} config.userId - Remote user ID, '*' represents all users.
  1691. * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} [config.streamType] - Remote stream type. This field is required when userId is not '*'.
  1692. * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
  1693. * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
  1694. * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1695. * @example
  1696. * // Stop playing all remote users
  1697. * await trtc.stopRemoteVideo({ userId: '*' });
  1698. */
  1699. stopRemoteVideo(config: StopRemoteVideoConfig): Promise<void>;
  1700. /**
  1701. * Mute a remote user and stop subscribing audio data from that user. Only effective for the current user, other users in the room can still hear the muted user's voice.<br>
  1702. *
  1703. * Note:
  1704. * - By default, after entering the room, the SDK will automatically play remote audio. You can call this interface to mute or unmute remote users.
  1705. * - If the parameter autoReceiveAudio = false is passed in when entering the room, remote audio will not be played automatically. When audio playback is required, you need to call this method (mute is passed in false) to play remote audio.
  1706. * - This interface is effective before or after entering the room (enterRoom), and the mute state will be reset to false after exiting the room (exitRoom).
  1707. * - If you want to continue subscribing audio data from the user but not play it, you can call setRemoteAudioVolume(userId, 0)
  1708. * @param {string} userId - Remote user ID, '*' represents all users.
  1709. * @param {boolean} mute - Whether to mute
  1710. * @throws
  1711. * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
  1712. * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
  1713. * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
  1714. * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
  1715. * @example
  1716. * // Mute all remote users
  1717. * await trtc.muteRemoteAudio('*', true);
  1718. */
  1719. muteRemoteAudio(userId: string, mute: boolean): Promise<void>;
  1720. /**
  1721. * Used to control the playback volume of remote audio.<br>
  1722. *
  1723. * - Not supported by iOS Safari
  1724. * @param {string} userId - Remote user ID。'*' represents all remote users.
  1725. * @param {number} volume - Volume, ranging from 0 to 100. The default value is 100.<br>
  1726. * Since `v5.1.3+`, the volume can be set higher than 100.
  1727. * @example
  1728. * await trtc.setRemoteAudioVolume('123', 90);
  1729. */
  1730. setRemoteAudioVolume(userId: string, volume: number): void;
  1731. startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
  1732. startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
  1733. updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
  1734. updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
  1735. stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
  1736. stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
  1737. /**
  1738. * Enables or disables the volume callback.<br>
  1739. *
  1740. * - After enabling this function, whether someone is speaking in the room or not, the SDK will regularly throw the {@link module:EVENT.AUDIO_VOLUME TRTC.on(TRTC.EVENT.AUDIO_VOLUME)} event, which feedbacks the volume evaluation value of each user.<br>
  1741. *
  1742. * @param {number} [interval=2000] Used to set the time interval for triggering the volume callback event. The default is 2000(ms), and the minimum value is 100(ms). If set to less than or equal to 0, the volume callback will be turned off.
  1743. * @param {boolean} [enableInBackground=false] For performance reasons, when the page switches to the background, the SDK will not throw volume callback events. If you need to receive volume callback events when the page is switched to the background, you can set this parameter to true.
  1744. * @memberof TRTC
  1745. * @example
  1746. * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
  1747. * event.result.forEach(({ userId, volume }) => {
  1748. * const isMe = userId === ''; // When userId is an empty string, it represents the local microphone volume.
  1749. * if (isMe) {
  1750. * console.log(`my volume: ${volume}`);
  1751. * } else {
  1752. * console.log(`user: ${userId} volume: ${volume}`);
  1753. * }
  1754. * })
  1755. * });
  1756. *
  1757. * // Enable volume callback and trigger the event every 1000ms
  1758. * trtc.enableAudioVolumeEvaluation(1000);
  1759. *
  1760. * // To turn off the volume callback, pass in an interval value less than or equal to 0
  1761. * trtc.enableAudioVolumeEvaluation(-1);
  1762. */
  1763. enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void;
  1764. /**
  1765. * Listen to TRTC events<br><br>
  1766. * For a detailed list of events, please refer to: {@link module:EVENT TRTC.EVENT}
  1767. *
  1768. * @param {string} eventName Event name
  1769. * @param {function} handler Event callback function
  1770. * @param {context} context Context
  1771. * @memberof TRTC
  1772. * @example
  1773. * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
  1774. * // REMOTE_VIDEO_AVAILABLE event handler
  1775. * });
  1776. */
  1777. on<T extends keyof TRTCEventTypes>(event: T, handler: (...args: TRTCEventTypes[T]) => void, context?: any): this;
  1778. /**
  1779. * Remove event listener<br>
  1780. *
  1781. * @param {string} eventName Event name. Passing in the wildcard '*' will remove all event listeners.
  1782. * @param {function} handler Event callback function
  1783. * @param {context} context Context
  1784. * @memberof TRTC
  1785. * @example
  1786. * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, function peerJoinHandler(event) {
  1787. * // REMOTE_USER_ENTER event handler
  1788. * console.log('remote user enter');
  1789. *
  1790. * trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, peerJoinHandler);
  1791. * });
  1792. *
  1793. * // Remove all event listeners
  1794. * trtc.off('*');
  1795. */
  1796. off<T extends keyof TRTCEventTypes>(event: T | '*', handler: T extends '*' ? never : (...args: TRTCEventTypes[T]) => void, context?: any): this;
  1797. /**
  1798. * Get audio track
  1799. *
  1800. * @returns {MediaStreamTrack?} Audio track
  1801. * @param {Object|string} [config] If not passed, get the local microphone audioTrack
  1802. * @param {string} [config.userId] If not passed or passed an empty string, get the local audioTrack. Pass the userId of the remote user to get the remote user's audioTrack.
  1803. * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
  1804. * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's microphone)(default)
  1805. * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing audio). Only works for local screen sharing audio because there is only one remote audioTrack, and there is no distinction between Main and Sub for remote audioTrack.
  1806. * @param {boolean} [config.processed=false] - Whether to get the processed audioTrack. The processed audioTrack is the audioTrack after the SDK processes the audio frame, such as ai-denose, gain, mix. The default value is false.
  1807. * @memberof TRTC
  1808. * @example
  1809. * // Version before v5.4.3
  1810. * trtc.getAudioTrack(); // Get local microphone audioTrack, captured by trtc.startLocalAudio()
  1811. * trtc.getAudioTrack('remoteUserId'); // Get remote audioTrack
  1812. *
  1813. * // Since v5.4.3+, you can get local screen audioTrack by passing the streamType = TRTC.STREAM_TYPE_SUB
  1814. * trtc.getAudioTrack({ streamType: TRTC.STREAM_TYPE_SUB });
  1815. *
  1816. * // Since v5.8.2+, you can get the processed audioTrack by passing processed = true
  1817. * trtc.getAudioTrack({ processed: true });
  1818. */
  1819. getAudioTrack(configOrUserId?: {
  1820. userId?: string;
  1821. streamType?: TRTCStreamType;
  1822. processed?: boolean;
  1823. } | string): MediaStreamTrack | null;
  1824. /**
  1825. * Get video track
  1826. *
  1827. * @param {string} [config] If not passed, get the local camera videoTrack
  1828. * @param {string} [config.userId] If not passed or passed an empty string, get the local videoTrack. Pass the userId of the remote user to get the remote user's videoTrack.
  1829. * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
  1830. * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's camera)(default)
  1831. * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing)
  1832. * @param {boolean} [config.processed=false] - Whether to get the processed videoTrack. The processed videoTrack is the videoTrack after the SDK processes the video frame, such as visualbackground, mirror, watermark. The default value is false.
  1833. * @returns {MediaStreamTrack|null} Video track
  1834. * @memberof TRTC
  1835. * @example
  1836. * // Get local camera videoTrack
  1837. * const videoTrack = trtc.getVideoTrack();
  1838. * // Get local screen sharing videoTrack
  1839. * const screenVideoTrack = trtc.getVideoTrack({ streamType: TRTC.TYPE.STREAM_TYPE_SUB });
  1840. * // Get remote user's main stream videoTrack
  1841. * const remoteMainVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_MAIN });
  1842. * // Get remote user's sub stream videoTrack
  1843. * const remoteSubVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_SUB });
  1844. * // Since v5.8.2+, you can get the processed videoTrack by passing processed = true
  1845. * const processedVideoTrack = trtc.getVideoTrack({ processed: true });
  1846. */
  1847. getVideoTrack(config?: {
  1848. userId?: string;
  1849. streamType?: TRTCStreamType;
  1850. processed?: boolean;
  1851. }): MediaStreamTrack | null;
  1852. /**
  1853. * Get video snapshot <br>
  1854. * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
  1855. * @param {string} config.userId - Remote user ID
  1856. * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
  1857. * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
  1858. * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
  1859. * @since 5.4.0
  1860. * @example
  1861. * // get self main stream video frame
  1862. * trtc.getVideoSnapshot()
  1863. * // get self sub stream video frame
  1864. * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
  1865. * // get remote user main stream video frame
  1866. * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
  1867. * @memberof TRTC
  1868. */
  1869. getVideoSnapshot(config?: VideoFrameConfig): string;
  1870. setCurrentSpeaker(speakerId: string): void;
  1871. /**
  1872. * Send SEI Message <br>
  1873. *
  1874. * > The header of a video frame has a header block called SEI.
  1875. * > The principle of this interface is to use the SEI to embed the custom data you want to send along with the video frame.
  1876. * > SEI messages can accompany video frames all the way to the live CDN.
  1877. *
  1878. * Applicable scenarios: synchronization of lyrics, live answering questions, etc.
  1879. *
  1880. * When to call: call after {@link TRTC#startLocalVideo trtc.startLocalVideo} or {@link TRTC#startLocalScreen trtc.startLocalScreen} when set 'toSubStream' option to true successfully.
  1881. *
  1882. * Note:
  1883. * 1. Maximum 1KB(Byte) sent in a single call, maximum 30 calls per second, maximum 8KB sent per second.
  1884. * 2. Currently only support Chrome 86+, Edge 86+, Opera 72+ browsers.
  1885. * 3. Since SEI is sent along with video frames, there is a possibility that video frames may be lost, and therefore SEI may be lost as well. The number of times it can be sent can be increased within the frequency limit, and the business side needs to do message de-duplication on the receiving side.
  1886. * 4. SEI cannot be sent without trtc.startLocalVideo(or trtc.startLocalScreen when set 'toSubStream' option to true); SEI cannot be received without startRemoteVideo.
  1887. * 5. Only H264 encoder is supported to send SEI.
  1888. * 6. SEI sending and receiving is not supported for small streams for the time being.
  1889. * @see {@link module:EVENT.SEI_MESSAGE TRTC.EVENT.SEI_MESSAGE}
  1890. * @since v5.3.0
  1891. * @param {ArrayBuffer} buffer SEI data to be sent
  1892. * @param {Object=} options
  1893. * @param {Number} options.seiPayloadType Set the SEI payload type. SDK uses the custom payloadType 243 by default, the business side can use this parameter to set the payloadType to the standard 5. When the business side uses the 5 payloadType, you need to follow the specification to make sure that the first 16 bytes of the `buffer` are the business side's customized uuid.
  1894. * @param {Boolean} [options.toSubStream=false] Send SEI data to substream. Need call trtc.startLocalScreen first. Since v5.7.0+.
  1895. * @example
  1896. * // 1. enable SEI
  1897. * const trtc = TRTC.create({
  1898. * enableSEI: true
  1899. * })
  1900. *
  1901. * // 2. send SEI
  1902. * try {
  1903. * await trtc.enterRoom({
  1904. * userId: 'user_1',
  1905. * roomId: 12345,
  1906. * })
  1907. * await trtc.startLocalVideo();
  1908. * const unit8Array = new Uint8Array([1, 2, 3]);
  1909. * trtc.sendSEIMessage(unit8Array.buffer);
  1910. * } catch(error) {
  1911. * console.warn(error);
  1912. * }
  1913. *
  1914. * // 3. receive SEI
  1915. * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
  1916. * console.warn(`sei ${event.data} from ${event.userId}`);
  1917. * })
  1918. */
  1919. sendSEIMessage(buffer: ArrayBuffer, options?: {
  1920. seiPayloadType?: number;
  1921. toSubStream?: boolean;
  1922. }): void;
  1923. /**
  1924. * Send Custom Message to all remote users in the room. <br>
  1925. *
  1926. * Note:
  1927. *
  1928. * 1. Only {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} can call sendCustomMessage.
  1929. * 2. You should call this api after {@link TRTC#enterRoom TRTC.enterRoom} successfully.
  1930. * 3. The custom message will be sent in order and as reliably as possible, but it's possible to loss messages in a very bad network. The receiver will also receive the message in order.
  1931. * @since v5.6.0
  1932. * @see Listen for the event {@link module:EVENT.CUSTOM_MESSAGE TRTC.EVENT.CUSTOM_MESSAGE} to receive custom message.
  1933. * @param {object} message
  1934. * @param {number} message.cmdId message Id. Integer, range [1, 10]. You can set different cmdId for different types of messages to reduce the delay of transferring message.
  1935. * @param {ArrayBuffer} message.data - message content. <br/>
  1936. * - Maximum 1KB(Byte) sent in a single call.
  1937. * - Maximum 30 calls per second
  1938. * - Maximum 8KB sent per second.
  1939. * @example
  1940. * // send custom message
  1941. * trtc.sendCustomMessage({
  1942. * cmdId: 1,
  1943. * data: new TextEncoder().encode('hello').buffer
  1944. * });
  1945. *
  1946. * // receive custom message
  1947. * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
  1948. * // event.userId: remote userId.
  1949. * // event.cmdId: message cmdId.
  1950. * // event.seq: message sequence number.
  1951. * // event.data: custom message data, type is ArrayBuffer.
  1952. * console.log(`received custom msg from ${event.userId}, message: ${new TextDecoder().decode(event.data)}`)
  1953. * })
  1954. */
  1955. sendCustomMessage(message: CustomMessageData): void;
  1956. static EVENT: {
  1957. readonly ERROR: 'error';
  1958. readonly AUTOPLAY_FAILED: 'autoplay-failed';
  1959. readonly KICKED_OUT: 'kicked-out';
  1960. readonly REMOTE_USER_ENTER: 'remote-user-enter';
  1961. readonly REMOTE_USER_EXIT: 'remote-user-exit';
  1962. readonly REMOTE_AUDIO_AVAILABLE: 'remote-audio-available';
  1963. readonly REMOTE_AUDIO_UNAVAILABLE: 'remote-audio-unavailable';
  1964. readonly REMOTE_VIDEO_AVAILABLE: 'remote-video-available';
  1965. readonly REMOTE_VIDEO_UNAVAILABLE: 'remote-video-unavailable';
  1966. readonly AUDIO_VOLUME: 'audio-volume';
  1967. readonly NETWORK_QUALITY: 'network-quality';
  1968. readonly CONNECTION_STATE_CHANGED: 'connection-state-changed';
  1969. readonly AUDIO_PLAY_STATE_CHANGED: 'audio-play-state-changed';
  1970. readonly VIDEO_PLAY_STATE_CHANGED: 'video-play-state-changed';
  1971. readonly SCREEN_SHARE_STOPPED: 'screen-share-stopped';
  1972. readonly DEVICE_CHANGED: 'device-changed';
  1973. readonly PUBLISH_STATE_CHANGED: 'publish-state-changed';
  1974. readonly TRACK: 'track';
  1975. readonly STATISTICS: 'statistics';
  1976. readonly SEI_MESSAGE: 'sei-message';
  1977. readonly CUSTOM_MESSAGE: 'custom-message';
  1978. };
  1979. static ERROR_CODE: {
  1980. INVALID_PARAMETER: number;
  1981. INVALID_OPERATION: number;
  1982. ENV_NOT_SUPPORTED: number;
  1983. DEVICE_ERROR: number;
  1984. SERVER_ERROR: number;
  1985. OPERATION_FAILED: number;
  1986. OPERATION_ABORT: number;
  1987. UNKNOWN_ERROR: number;
  1988. };
  1989. static TYPE: {
  1990. readonly SCENE_LIVE: Scene.LIVE;
  1991. readonly SCENE_RTC: Scene.RTC;
  1992. readonly ROLE_ANCHOR: UserRole.ANCHOR;
  1993. readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
  1994. readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
  1995. readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
  1996. readonly AUDIO_PROFILE_STANDARD: 'standard';
  1997. readonly AUDIO_PROFILE_STANDARD_STEREO: 'standard-stereo';
  1998. readonly AUDIO_PROFILE_HIGH: 'high';
  1999. readonly AUDIO_PROFILE_HIGH_STEREO: 'high-stereo';
  2000. readonly QOS_PREFERENCE_SMOOTH: 'smooth';
  2001. readonly QOS_PREFERENCE_CLEAR: 'clear';
  2002. };
  2003. static frameWorkType: number;
  2004. /**
  2005. * Set the log output level
  2006. * <br>
  2007. * It is recommended to set the DEBUG level during development and testing, which includes detailed prompt information.
  2008. * The default output level is INFO, which includes the log information of the main functions of the SDK.
  2009. *
  2010. * @param {0-5} [level] Log output level 0: TRACE 1: DEBUG 2: INFO 3: WARN 4: ERROR 5: NONE
  2011. * @param {boolean} [enableUploadLog=true] Whether to enable log upload, which is enabled by default. It is not recommended to turn it off, which will affect problem troubleshooting.
  2012. * @example
  2013. * // Output log levels above DEBUG
  2014. * TRTC.setLogLevel(1);
  2015. */
  2016. static setLogLevel(level: LOG_LEVEL, enableUploadLog?: boolean): void;
  2017. /**
  2018. * Check if the TRTC Web SDK is supported by the current browser
  2019. *
  2020. * - Reference: {@tutorial 05-info-browser}.
  2021. * @example
  2022. * TRTC.isSupported().then((checkResult) => {
  2023. * if(!checkResult.result) {
  2024. * console.log('checkResult', checkResult.result, 'checkDetail', checkResult.detail);
  2025. * // The SDK is not supported by the current browser, guide the user to use the latest version of Chrome browser.
  2026. * }
  2027. * });
  2028. *
  2029. * @returns {Promise.<object>} Promise returns the detection result
  2030. * | Property | Type | Description |
  2031. * |--------------------------------------------|---------|-------------------------------------|
  2032. * | checkResult.result | boolean | Detection result |
  2033. * | checkResult.detail.isBrowserSupported | boolean | Whether the current browser is supported by the SDK |
  2034. * | checkResult.detail.isWebRTCSupported | boolean | Whether the current browser supports WebRTC |
  2035. * | checkResult.detail.isWebCodecsSupported | boolean | Whether the current browser supports WebCodecs |
  2036. * | checkResult.detail.isMediaDevicesSupported | boolean | Whether the current browser supports obtaining media devices and media streams |
  2037. * | checkResult.detail.isScreenShareSupported | boolean | Whether the current browser supports screen sharing |
  2038. * | checkResult.detail.isSmallStreamSupported | boolean | Whether the current browser supports small streams |
  2039. * | checkResult.detail.isH264EncodeSupported | boolean | Whether the current browser supports H264 encoding for uplink |
  2040. * | checkResult.detail.isH264DecodeSupported | boolean | Whether the current browser supports H264 decoding for downlink |
  2041. * | checkResult.detail.isVp8EncodeSupported | boolean | Whether the current browser supports VP8 encoding for uplink |
  2042. * | checkResult.detail.isVp8DecodeSupported | boolean | Whether the current browser supports VP8 decoding for downlink |
  2043. */
  2044. static isSupported(): Promise<any>;
  2045. /**
  2046. * Returns the list of camera devices
  2047. * <br>
  2048. * **Note**
  2049. * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
  2050. * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get the maximum resolutions supported by the camera, frame rate, mobile devices to distinguish between front and rear cameras, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
  2051. * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the camera. If requestPermission is true, calling this method may temporarily open the camera to ensure that the camera list can be normally obtained, and the SDK will automatically stop the camera capture later.
  2052. * @example
  2053. * const cameraList = await TRTC.getCameraList();
  2054. * if (cameraList[0] && cameraList[0].getCapabilities) {
  2055. * const { width, height, frameRate, facingMode } = cameraList[0].getCapabilities();
  2056. * console.log(width.max, height.max, frameRate.max);
  2057. * if (facingMode) {
  2058. * if (facingMode[0] === 'user') {
  2059. * // front camera
  2060. * } else if (facingMode[0] === 'environment') {
  2061. * // rear camera
  2062. * }
  2063. * }
  2064. * }
  2065. * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
  2066. */
  2067. static getCameraList(requestPermission?: boolean): Promise<MediaDeviceInfo[]>;
  2068. /**
  2069. * Returns the list of microphone devices
  2070. * <br>
  2071. * **Note**
  2072. * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
  2073. * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get information about the microphone's capabilities, e.g. the maximum number of channels supported, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
  2074. * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the microphone. If requestPermission is true, calling this method may temporarily open the microphone to ensure that the microphone list can be normally obtained, and the SDK will automatically stop the microphone capture later.
  2075. * @example
  2076. * const microphoneList = await TRTC.getMicrophoneList();
  2077. * if (microphoneList[0] && microphoneList[0].getCapabilities) {
  2078. * const { channelCount } = microphoneList[0].getCapabilities();
  2079. * console.log(channelCount.max);
  2080. * }
  2081. * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
  2082. */
  2083. static getMicrophoneList(requestPermission?: boolean): Promise<MediaDeviceInfo[]>;
  2084. /**
  2085. * Returns the list of speaker devices. Only support PC browser, not support mobile browser.
  2086. * <br>
  2087. * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the microphone. If requestPermission is true, calling this method may temporarily open the microphone to ensure that the microphone list can be normally obtained, and the SDK will automatically stop the microphone capture later.
  2088. * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
  2089. */
  2090. static getSpeakerList(requestPermission?: boolean): Promise<MediaDeviceInfo[]>;
  2091. /**
  2092. * Set the current speaker for audio playback
  2093. *
  2094. * @param {string} speakerId Speaker ID
  2095. */
  2096. static setCurrentSpeaker(speakerId: string): Promise<void>;
  2097. }
  2098. export default TRTC;