aliyun-rtc-sdk.d.ts 161 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509
  1. /// <reference types="https://esm.d8d.fun/@types/dom-mediacapture-transform@0.1.11/index.d.ts" />
  2. import { default as default_2 } from 'https://esm.d8d.fun/eventemitter3@5.0.1/index.d.ts';
  3. import { default as default_3 } from 'https://esm.d8d.fun/@aliyun-sls/web-track-browser@0.3.9/dist/web-track-browser.d.ts';
  4. import { IAudioConstraints } from 'https://esm.d8d.fun/media-device@1.3.0/dist/index.d.ts';
  5. import { IProfile } from 'https://esm.d8d.fun/aliyun-rts-sdk@2.12.3/dist/index.d.ts';
  6. import { IStreamConfig } from 'https://esm.d8d.fun/aliyun-rts-sdk@2.12.3/dist/index.d.ts';
  7. import { IVideoConstraints } from 'https://esm.d8d.fun/media-device@1.3.0/dist/index.d.ts';
  8. import { LocalStream } from 'https://esm.d8d.fun/aliyun-rts-sdk@2.12.3/dist/index.d.ts';
  9. import { RemoteStream } from 'https://esm.d8d.fun/aliyun-rts-sdk@2.12.3/dist/index.d.ts';
  10. declare interface AliEngineCameraCapturerConfiguration {
  11. width?: number;
  12. height?: number;
  13. frameRate?: number;
  14. maxSendFrameRate?: number;
  15. bitrate?: number;
  16. cameraDirection?: AliRtcCameraDirection;
  17. deviceId?: string;
  18. }
  19. declare enum AliRtcAudioTrack {
  20. /** 无麦克风 */
  21. AliRtcAudioTrackNo = 0,
  22. /** 麦克风 */
  23. AliRtcAudioTrackMic = 1,
  24. /** 第二音频流 */
  25. AliRtcAudioTrackDual = 2
  26. }
  27. export declare interface AliRtcAuthInfo {
  28. /** 频道ID */
  29. channelId: string;
  30. /** 用户ID */
  31. userId: string;
  32. /** 应用ID */
  33. appId: string;
  34. /** 随机串 */
  35. nonce?: string;
  36. /** 时间戳 */
  37. timestamp: number;
  38. /** 令牌 */
  39. token: string;
  40. /** 会议id */
  41. sessionId?: string;
  42. /** 角色鉴权值 */
  43. role?: AliRtcSdkTokenRole;
  44. }
  45. declare interface AliRtcBeautyConfig {
  46. whiteningLevel: number;
  47. /*! 磨皮等级[0-1.0] */
  48. smoothnessLevel: number;
  49. }
  50. declare enum AliRtcCameraDirection {
  51. /** 无效 */
  52. CAMERA_INVALID = -1,
  53. /** 后置 */
  54. CAMERA_REAR = 0,
  55. /** 前置 */
  56. CAMERA_FRONT = 1
  57. }
  58. export declare interface AliRtcCheckResult {
  59. support: boolean;
  60. detail: {
  61. isWebRTCSupported: boolean;
  62. isH264EncodeSupported: boolean;
  63. isH264DecodeSupported: boolean;
  64. isBrowserSupported: boolean;
  65. isScreenShareSupported: boolean;
  66. isSendMediaExtensionMsgSupported: boolean;
  67. };
  68. }
  69. export declare enum AliRtcConnectionStatus {
  70. /** 初始化完成 */
  71. AliRtcConnectionStatusInit = 0,
  72. /** 网络连接断开 */
  73. AliRtcConnectionStatusDisconnected = 1,
  74. /** 建立网络连接中 */
  75. AliRtcConnectionStatusConnecting = 2,
  76. /** 网络已连接 */
  77. AliRtcConnectionStatusConnected = 3,
  78. /** 重新建立网络连接中 */
  79. AliRtcConnectionStatusReconnecting = 4,
  80. /** 网络连接失败 */
  81. AliRtcConnectionStatusFailed = 5
  82. }
  83. export declare enum AliRtcConnectionStatusChangeReason {
  84. /** 未知原因 */
  85. AliRtcConnectionChangedDummyReason = 0,
  86. /** 媒体通道变更 */
  87. AliRtcConnectionMediaPathChanged = 1,
  88. /** 心跳超时 */
  89. AliRtcConnectionSignalingHeartbeatTimeout = 2,
  90. /** 心跳恢复 */
  91. AliRtcConnectionSignalingHeartbeatAlive = 3,
  92. /** DNS解析成功 */
  93. AliRtcConnectionSignalingHttpDnsResolved = 4,
  94. /** DNS解析失败 */
  95. AliRtcConnectionSignalingHttpDnsFailure = 5,
  96. /** GSLB请求失败 */
  97. AliRtcConnectionSignalingGslbFailure = 6,
  98. /** GSLB请求成功 */
  99. AliRtcConnectionSignalingGslbSuccess = 7,
  100. /** 加入频道失败 */
  101. AliRtcConnectionSignalingJoinRoomFailure = 8,
  102. /** 加入频道成功 */
  103. AliRtcConnectionSignalingJoinRoomSuccess = 9,
  104. /** 离开频道 */
  105. AliRtcConnectionSignalingLeaveRoom = 10,
  106. /** 信令建立连接 */
  107. AliRtcConnectionSignalingConnecting = 11,
  108. /** 网络连接中断 */
  109. AliRtcConnectionChangedNetworkInterrupted = 12
  110. }
  111. export declare class AliRtcDataChannelMsg {
  112. data: ArrayBuffer;
  113. networkTime: number;
  114. futureOrProgress: number;
  115. type: AliRtcDataMsgType;
  116. constructor(data: ArrayBuffer, type?: AliRtcDataMsgType, networkTime?: number, progress?: number);
  117. toBuffer(): ArrayBuffer;
  118. static parse(buffer: ArrayBuffer): AliRtcDataChannelMsg | undefined;
  119. }
  120. export declare enum AliRtcDataMsgType {
  121. AliEngineDataMsgNone = 0,
  122. AliEngineDataMsgMusicProgress = 1,
  123. AliEngineDataMsgCustom = 2
  124. }
  125. declare type AliRtcDualVideoPluginOptions = VideoScalerOptions;
  126. declare class AliRtcEngine_2 extends default_2<AliRtcEngineEventListener> {
  127. /**
  128. * @ignore
  129. */
  130. static logName: string;
  131. /**
  132. * @ignore
  133. */
  134. static logError: boolean;
  135. /**
  136. * 检查浏览器是否支持 WebRTC
  137. * @param {string} direction
  138. * @returns {Promise<AliRtcCheckResult>}
  139. */
  140. static isSupported: (direction?: "sendonly" | "recvonly" | "sendrecv" | undefined) => Promise<AliRtcCheckResult>;
  141. /**
  142. * 检查浏览器是否支持开启大小流
  143. * @returns {boolean}
  144. */
  145. static isDualVideoStreamSupported: typeof VideoScalerFactory.isSupport;
  146. /**
  147. * 获取摄像头列表
  148. * @returns {Promise<string[]>}
  149. */
  150. static getCameraList: () => Promise<MediaDeviceInfo[]>;
  151. static getMicrophoneList: () => Promise<MediaDeviceInfo[]>;
  152. static getSpeakerList: () => Promise<MediaDeviceInfo[]>;
  153. static getSdkVersion(): string;
  154. /**
  155. * 设置日志等级
  156. * @param level
  157. */
  158. static setLogLevel(level: AliRtcLogLevel): void;
  159. private static _instance?;
  160. /**
  161. * @brief 获取AliRtcEngine实例
  162. * @param key key 可选参与,用于创建多个实例
  163. * @details 该方法为同步调用,以单例的形式提供对象创建。
  164. */
  165. static getInstance(config?: AliRtcEngineConfig): AliRtcEngine_2;
  166. static AliRtcSdkChannelProfile: typeof AliRtcSdkChannelProfile;
  167. static AliRtcSdkClientRole: typeof AliRtcSdkClientRole;
  168. static AliRtcVideoStreamType: typeof AliRtcVideoStreamType;
  169. static AliRtcVideoTrack: typeof AliRtcVideoTrack;
  170. static AliRtcAudioTrack: typeof AliRtcAudioTrack;
  171. static AliRtcPublishState: typeof AliRtcPublishState;
  172. static AliRtcSubscribeState: typeof AliRtcSubscribeState;
  173. static AliRtcRawDataStreamType: typeof AliRtcRawDataStreamType;
  174. static AliRtcLogLevel: typeof AliRtcLogLevel;
  175. static AliRtcEngineLocalDeviceType: typeof AliRtcEngineLocalDeviceType;
  176. static AliRtcEngineLocalDeviceExceptionType: typeof AliRtcEngineLocalDeviceExceptionType;
  177. static AliRtcConnectionStatus: typeof AliRtcConnectionStatus;
  178. static AliRtcConnectionStatusChangeReason: typeof AliRtcConnectionStatusChangeReason;
  179. static AliRtcPlugin: typeof AliRtcPlugin;
  180. static AliRtcPluginTrackType: typeof AliRtcPluginTrackType;
  181. static AliRtcLiveTranscodingParam: typeof AliRtcLiveTranscodingParam;
  182. static AliRtcLiveTranscodingEncodeParam: typeof AliRtcLiveTranscodingEncodeParam;
  183. static AliRtcLiveTranscodingMixParam: typeof AliRtcLiveTranscodingMixParam;
  184. static AliRtcLiveTranscodingSingleParam: typeof AliRtcLiveTranscodingSingleParam;
  185. static AliRtcTranscodingClockWidget: typeof AliRtcTranscodingClockWidget;
  186. static AliRtcTranscodingImage: typeof AliRtcTranscodingImage;
  187. static AliRtcTranscodingText: typeof AliRtcTranscodingText;
  188. static AliRtcTranscodingUser: typeof AliRtcTranscodingUser;
  189. static AliRtcLiveTranscodingMixMode: typeof AliRtcLiveTranscodingMixMode;
  190. static AliRtcLiveTranscodingStreamType: typeof AliRtcLiveTranscodingStreamType;
  191. static AliRtcLiveTranscodingSourceType: typeof AliRtcLiveTranscodingSourceType;
  192. static AliRtcLiveTranscodingTaskProfile: typeof AliRtcLiveTranscodingTaskProfile;
  193. static AliRtcLiveTranscodingAudioSampleRate: typeof AliRtcLiveTranscodingAudioSampleRate;
  194. static AliRtcLiveTranscodingSegmentType: typeof AliRtcLiveTranscodingSegmentType;
  195. static AliRtcLiveTranscodingFontType: typeof AliRtcLiveTranscodingFontType;
  196. static AliRtcLiveTranscodingCropMode: typeof AliRtcLiveTranscodingCropMode;
  197. static AliRtcLiveTranscodingMediaProcessMode: typeof AliRtcLiveTranscodingMediaProcessMode;
  198. static AliRtcLiveTranscodingState: typeof AliRtcLiveTranscodingState;
  199. static AliRtcLiveTranscodingErrorCode: typeof AliRtcLiveTranscodingErrorCode;
  200. static AliRtcTrascodingPublishTaskStatus: typeof AliRtcTrascodingPublishTaskStatus;
  201. static AliRtcDataChannelMsg: typeof AliRtcDataChannelMsg;
  202. static AliRtcDataMsgType: typeof AliRtcDataMsgType;
  203. /**
  204. * @brief 销毁 {@link AliRtcEngine}实例
  205. * @details 调用该方法将会释放所有内部使用的资源,当完成音视频通信之后都建议调用该方法释放实例.调用该方法后,你将不能再使用 {@link AliRtcEngine} 的其他方法和任何回调,如需要再次使用需要重新调用 {@link AliRtcEngine.getInstance} 方法创建一个新的实例。
  206. * @note 该方法为同步调用,需要等待内部资源释放之后才能执行其他方法
  207. */
  208. destroy(): Promise<void>;
  209. protected channelProfile: AliRtcSdkChannelProfile;
  210. protected clientRole: AliRtcSdkClientRole;
  211. protected signalingManager: SignalingManager;
  212. protected bizControl: BizControl;
  213. protected liveTranscoding: AliRtcLiveTranscoding;
  214. protected maxSignalingConnectRetryCount?: number;
  215. protected slsReporter: SLSReporter;
  216. protected connectState: AliRtcConnectionStatus;
  217. protected networkError: boolean;
  218. private _audioOnlyMode;
  219. private _authInfoWillExpireTimer;
  220. private _authInfoExpiredTimer;
  221. private _serverCheckAuthInfoTimestamp;
  222. private _localCheckAuthInfoTimestamp;
  223. constructor(config?: AliRtcEngineConfig);
  224. /**
  225. * 获取当前频道号,已经入会成功返回频道号,否则返回undefined
  226. */
  227. get channel(): string | undefined;
  228. /**
  229. * 获取当前用户的 userId,已经入会成功返回自己的 userId,否则返回 undefined
  230. */
  231. get userId(): string | undefined;
  232. get remoteUsers(): RemoteUser[];
  233. get publisher(): LocalUser | undefined;
  234. get publishAudioStream(): LocalStream | undefined;
  235. get isPublishing(): boolean;
  236. private get currentRoleCanPublish();
  237. /**
  238. * 监听 Publisher 事件
  239. */
  240. private addPublisherListeners;
  241. private occurError;
  242. /**
  243. * 监听 UM 事件
  244. */
  245. private addBizControlListeners;
  246. /**
  247. * 添加信令处理
  248. * @returns {void}
  249. */
  250. private addSignalingManagerListeners;
  251. private backToUnpublishStatus;
  252. /**
  253. * 处理入会远程的用户
  254. * @param {JoinInfo[]} users
  255. * @returns {void}
  256. */
  257. private handleUsersJoin;
  258. /**
  259. * 本地用户设备状态变化,通过信令发送给其他人
  260. * @param {string} status
  261. * @returns {void}
  262. */
  263. protected onLocalDeviceStatusChange(status: string): void;
  264. /**
  265. * 网络恢复后,重推;
  266. */
  267. private resumePublishForNetworkRecovery;
  268. /**
  269. * 处理房间信令重连成功/心跳恢复
  270. * @returns {void}
  271. */
  272. protected onNetworkRecovery(users?: JoinInfo[]): Promise<void>;
  273. private resumeSubList;
  274. /**
  275. * 重新订阅远端用户
  276. * @param {string} userId
  277. * @returns {Promise<void>}
  278. */
  279. retrySubscribe(userId: string): Promise<void>;
  280. /**
  281. * 处理网络异常
  282. * @param {AliRtcError} err
  283. * @returns {void}
  284. */
  285. protected onNetworkError(): void;
  286. /**
  287. * 处理错误
  288. * @param {AliRtcError} err
  289. * @returns {void}
  290. */
  291. protected onError(err: AliRtcError): void;
  292. /**
  293. * 是否开启大小流
  294. * @param {boolean} enabled
  295. * @param {AliRtcDualVideoPluginOptions} [options]
  296. */
  297. setEnableDualVideoStream(enabled: boolean, options?: AliRtcDualVideoPluginOptions): void;
  298. /**
  299. * 对本地流的操作预检查
  300. */
  301. private hadPushStream;
  302. /**
  303. * 获取当前使用的麦克风 deviceId
  304. * @returns {string | undefined}
  305. */
  306. getCurrentMicDeviceId(): string | undefined;
  307. /**
  308. * 设置频道模式
  309. * @param {AliRtcSdkChannelProfile} channelProfile 频道类型,默认值为 AliEngineCommunication
  310. * @note 该接口只可以在加入频道之前调用,会议中不可以重新设置,离开频道后可以重新设置
  311. */
  312. setChannelProfile(channelProfile: AliRtcSdkChannelProfile): void;
  313. private startAndPublishDefaultDevices;
  314. /**
  315. * 设置用户角色
  316. * @param {AliRtcSdkClientRole} clientRole 用户角色类型,默认值为 {@link AliRtcSdkClientRole.AliRtcSdkLive}(观众角色)
  317. * @note 非通信模式下角色类型才有效
  318. */
  319. setClientRole(clientRole: AliRtcSdkClientRole): Promise<void>;
  320. /**
  321. * 获取用户角色
  322. * @returns {AliRtcSdkClientRole}
  323. */
  324. getCurrentClientRole(): AliRtcSdkClientRole;
  325. /**
  326. * 是否开启纯音频模式
  327. * @param {boolean} audioOnly
  328. * - true:只有音频推流和拉流
  329. * - false(默认值):音视频都支持
  330. * @note 只可以在 {@link joinChannel} 之前设置
  331. */
  332. setAudioOnlyMode(audioOnly: boolean): void;
  333. setAudioRedEnabled(audioRedEnabled: boolean): void;
  334. /**
  335. * 设定鉴权信息过期事件定时器
  336. * @param expireTimestamp 鉴权信息过期时间
  337. * @param serverTimestamp 入会时服务端时间
  338. */
  339. private setCheckAuthInfoTimer;
  340. /**
  341. * 清除鉴权信息过期事件定时器
  342. */
  343. private clearCheckAuthInfoTimer;
  344. /**
  345. * @brief 加入频道
  346. * @details 该方法让用户加入频道,一个频道内可以加入多个用户进行互相通话。
  347. * @details 一般在调用该方法前会根据场景先选择频道模式,通过调用 {@link setChannelProfile} 实现,默认频道模式为通信模式 {@link AliRtcSdkChannelProfile.AliRtcSdkCommunication}
  348. * ``` javascript
  349. * // 设置频道为互动模式
  350. * engine.setChannelProfile(AliRtcSdkChannelProfile.AliRtcInteractivelive);
  351. * // 设置角色为主播角色
  352. * engine.setClientRole(AliRtcSdkClientRole.AliRtcSdkInteractive);
  353. * ```
  354. * @param {AliRtcAuthInfo | string} authInfoOrToken (多参数/单参数) 认证信息,从App Server获取。
  355. * @param {string} userName 任意用于显示的用户名称。不是User ID
  356. * @note
  357. * - 异步接口,方法执行成功则为成功入会
  358. * - 正常情况一个Appid对应一个App,只有同一个AppId的应用可进行互相童话,不同AppId和channelID不同都不能互通
  359. * - 当入会成功后,会触发远端用户收到 {@link AliRtcEngineEventListener.remoteUserOnLineNotify} 回调
  360. * - 如果已在会中想重新入会,需要先调用 {@link leaveChannel} 离会,且确保方法执行成功
  361. * - 用户加入频道后,默认订阅频道内所有其他用户的音视频流,默认推送音视频流到远端,因此将会产生计费,如果想要取消默认订阅可以 {@link joinChannel} 前调用 {@link setDefaultSubscribeAllRemoteAudioStreams} 和 {@link setDefaultSubscribeAllRemoteVideoStreams}
  362. */
  363. joinChannel(authInfoOrToken: AliRtcAuthInfo | string, userName?: string): Promise<void>;
  364. /**
  365. * 离开频道
  366. * @note 如果当前不在频道内,调用 leaveChannel 不会对实例产生任何影响,但会产生消息,通知频道内其他用户
  367. */
  368. leaveChannel(): Promise<void>;
  369. /**
  370. * 检查当前是否在频道中
  371. * @returns {boolean}
  372. * - true:在频道中
  373. * - false:不在频道中
  374. */
  375. isInCall(): boolean;
  376. /**
  377. * 刷新鉴权信息
  378. * @param {AliRtcRefreshAuthInfo | string} authInfoOrToken
  379. */
  380. refreshAuthInfo(authInfoOrToken: AliRtcRefreshAuthInfo | string): Promise<void>;
  381. /**
  382. * 检查当前是否纯音频模式
  383. * @returns {boolean}
  384. * - true:纯音频模式
  385. * - false:音视频模式
  386. */
  387. isAudioOnly(): boolean;
  388. /**
  389. * @brief 是否推送音频流
  390. * @param enabled 是否开启/关闭本地音频流推送
  391. * - true: 开启音频流推送
  392. * - false: 关闭音频流推送
  393. * @note SDK默认设置推送音频流,在加入频道前也可以调用此接口修改默认值,并在加入频道成功时生效
  394. * @note 加入频道后调用不会停止本地音频采集
  395. */
  396. publishLocalAudioStream(enabled: boolean): Promise<void>;
  397. /**
  398. * @brief 查询是否设置推送音频流
  399. * @return
  400. * - true: 已设置推送
  401. * - false: 未设置推送
  402. * @note SDK默认设置推送音频流,如果需要取消推送音频流,可以通过 {@link publishLocalAudioStream}方法设置为不推送
  403. */
  404. isLocalAudioStreamPublished(): boolean;
  405. /**
  406. * 设置是否默认接收音频流
  407. * @param sub
  408. * - true: 接收用户的音频流
  409. * - false: 停止接收用户的音频流
  410. * @note 入会前入会后均可调用。如果在加入频道后调用 setDefaultSubscribeAllRemoteAudioStreams(false),会接收不到设置后加入频道的用户的音频流。
  411. * @note 停止接收音频流后,如果想要恢复接收,请调用 {@link subscribeRemoteAudioStream},并指定你想要接收的远端用户ID;
  412. * @note 如果想恢复接收多个用户的音频流,则需要多次调用 {@link subscribeRemoteAudioStream}。setDefaultSubscribeAllRemoteAudioStreams(true) 只能恢复接收后面加入频道的用户的音频流。
  413. */
  414. setDefaultSubscribeAllRemoteAudioStreams(sub: boolean): void;
  415. /**
  416. * 停止/恢复接收所有远端音频流
  417. * @param sub
  418. * - true: 接收所有用户的音频流
  419. * - false: 停止接收所有用户的音频流
  420. * @note 该接口作为订阅远端音频流的总开关,如果设置为false,则不仅当前会议中所有远端音频流都会停止订阅,后续入会的新用户也将不再订阅(即使设置了setDefaultSubscribeAllRemoteAudioStreams(true))
  421. */
  422. subscribeAllRemoteAudioStreams(sub: boolean): void;
  423. /**
  424. * 手动拉音频流
  425. * @param uid uid
  426. * @param sub,默认为 true
  427. * - true: 接收指定用户的音频流
  428. * - false: 停止接收指定用户的音频流
  429. * @note 如果之前有调用过 subscribeAllRemoteAudioStreams(false) 对所有远端音频进行静音,在调用本 API 之前请确保你已调用 subscribeAllRemoteAudioStreams(true)。
  430. * @note {@link subscribeAllRemoteAudioStreams} 是全局控制,{@link subscribeRemoteAudioStream} 是精细控制。
  431. */
  432. subscribeRemoteAudioStream(uid: string, sub: boolean): void;
  433. /**
  434. * 手动恢复远端用户音频流
  435. * @param uid
  436. * 用于在自动播放失败等场景恢复播放
  437. */
  438. resumeRemoteAudioStream(uid: string): void;
  439. stopRemoteAudioPlay(uid: string): void;
  440. /**
  441. * @brief 是否推送本地视频流
  442. * @param enabled 是否开启/关闭本地视频流推送
  443. * - true: 开启视频流推送
  444. * - false: 关闭视频流推送
  445. * @note SDK默认设置推送视频流,在加入频道前也可以调用此接口修改默认值,并在加入频道成功时生效
  446. * @note 加入频道后调用不会停止本地视频采集
  447. */
  448. publishLocalVideoStream(enabled: boolean): Promise<void>;
  449. /**
  450. * @brief 查询是否设置推送视频流
  451. * @return
  452. * - true: 已设置推送
  453. * - false: 未设置推送
  454. * @note SDK默认设置推送视频流,如果需要取消推送视频流,可以通过 {@link publishLocalVideoStream} 方法设置为不推送
  455. */
  456. isLocalVideoStreamPublished(): boolean;
  457. /**
  458. * 设置默认订阅的相机流格式,大流或小流,会覆盖单人的大小流设置
  459. * @param {AliRtcVideoStreamType} streamType 流类型
  460. * @note 仅支持传入 1 (默认大流)、2(默认小流),传入其他无效
  461. * @note 当无默认类型的相机流,但有另一个,将拉取另一个
  462. */
  463. setRemoteDefaultVideoStreamType(streamType: AliRtcVideoStreamType): void;
  464. /**
  465. * 设置某一用户默认订阅的相机流格式,大流或小流
  466. * @param userId 远端用户ID
  467. * @param {AliRtcVideoStreamType} streamType 流类型
  468. * @note 仅支持传入 1 (默认大流)、2(默认小流),传入其他无效
  469. * @note 当无默认类型的相机流,但有另一个,将拉取另一个
  470. */
  471. setRemoteUserVideoStreamType(userId: string, streamType: AliRtcVideoStreamType): void;
  472. /**
  473. * 设置是否默认接收视频流
  474. * @param sub
  475. * - true: 接收用户的视频流
  476. * - false: 不接收用户的视频流
  477. * @note 入会前入会后均可调用。如果在加入频道后调用 setDefaultSubscribeAllRemoteVideoStreams(false),会接收不到设置后加入频道的用户的视频流。
  478. * @note 停止接收视频流后,如果想要恢复接收,请调用 {@link subscribeRemoteVideoStream},并指定你想要接收的远端用户ID;
  479. * @note 如果想恢复接收多个用户的视频流,则需要多次调用 {@link subscribeRemoteVideoStream};setDefaultSubscribeAllRemoteVideoStreams(true) 只能恢复接收后面加入频道的用户的视频流。
  480. */
  481. setDefaultSubscribeAllRemoteVideoStreams(sub: boolean): void;
  482. /**
  483. * 停止/恢复接收所有远端视频流
  484. * @param sub
  485. * - true: 接收所有用户的视频流
  486. * - false: 停止接收所有用户的视频流
  487. * @note 该接口作为订阅远端视频流的总开关,如果设置为false,则不仅当前会议中所有远端视频流都会停止订阅,后续入会的新用户也将不再订阅(即使设置了setDefaultSubscribeAllRemoteVideoStreams(true))
  488. */
  489. subscribeAllRemoteVideoStreams(sub: boolean): void;
  490. /**
  491. * 合并订阅远端音视频流
  492. * @param uid uid
  493. * @param videoTrack 视频流类型
  494. * @param subVideo 是否订阅视频
  495. * @param subAudio 是否订阅音频
  496. * @return
  497. */
  498. subscribeRemoteMediaStream(uid: string, videoTrack: AliRtcVideoTrack, subVideo: boolean, subAudio: boolean): void;
  499. /**
  500. * @brief 手动恢复远端用户视频流
  501. * @param uid
  502. * @param videoTrack
  503. * 用于在自动播放失败等场景恢复播放
  504. */
  505. resumeRemoteMediaStream(uid: string, videoTrack: AliRtcVideoTrack): void;
  506. /**
  507. * @brief 订阅目标频道,指定用户的流
  508. * @param channelId 目标频道
  509. * @param uid 用户ID,从App server分配的唯一标示符
  510. * @param track 订阅的视频流类型
  511. * @param sub_audio 是否订阅远端用户的音频流
  512. * - true:订阅指定用户的音频流
  513. * - false:停止订阅指定用户的音频流
  514. * @param sub 是否订阅远端用户的流
  515. * - true:订阅指定用户的流
  516. * - false:停止订阅指定用户的流
  517. */
  518. /**
  519. * @brief 获取远端在线用户列表
  520. * @return 当前频道内所有在线用户userid列表
  521. * @note 若当前频道ChannelProfile设置为 {@link AliRtcSdkChannelProfile.AliRtcSdkInteractiveLive} 模式,只有设置角色为 {@link AliRtcSdkClientRole.AliRtcSdkInteractive} 的用户为在线用户,本方法不返回角色为 {@link AliRtcSdkClientRole.AliRtcSdkLive} 的用户
  522. */
  523. getOnlineRemoteUsers(): string[];
  524. /**
  525. * @brief 查询远端用户状态
  526. * @details 通过 uid 查询指定远端用户的状态信息.
  527. * @param uid 用户ID。从App server分配的唯一标示符
  528. * @return 返回一个远端用户对象。详见{@link RemoteUser}
  529. */
  530. getUserInfo(uid: string): AliRtcRemoteUserInfo | undefined;
  531. /**
  532. * @brief 查询用户是否在线
  533. * @param uid 用户ID,从App server分配的唯一标示符。不可为NULL
  534. * @return
  535. * - true: 用户在线
  536. * - false: 用户不在线
  537. * @note 根据特定的UserID,查询该用户是否在线。
  538. */
  539. isUserOnline(uid: string): boolean;
  540. /**
  541. * @brief 开始屏幕共享
  542. * @param config 开启屏幕共享的配置
  543. * @note 可以通过 config 选择是否开启音频或使用外部自定义 MediaStream
  544. * @note 自定义 MediaStream 仅支持一个视频流和一个音频流
  545. */
  546. startScreenShare(config?: AliRtcScreenShareStartConfig): Promise<void>;
  547. /**
  548. * @brief 停止屏幕共享
  549. */
  550. stopScreenShare(): Promise<void>;
  551. /**
  552. * @brief 设置屏幕流视频编码属性
  553. * @details 该方法用于设置屏幕流视频编码属性对应的视频参数,如分辨率、帧率、码率、等 所有设置的参数都有相应的范围限制,如果设置的参数不在有效范围内,SDK会自动调节
  554. * @param config 预定义的屏幕共享编码属性,
  555. * @note
  556. * - 该方法在入会前和入会后都可以调用,如果每次入会只需要设置一次屏幕流视频编码属性,建议在入会前调用
  557. */
  558. setScreenShareConfiguration(config: AliRtcScreenShareConfiguration): Promise<void>;
  559. /**
  560. * @breif 设置屏幕流采集内容提示
  561. * @param contentHint 设置屏幕流内容提示,用于提升在不同内容场景下的视频编码质量 [参考文档](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/contentHint)
  562. */
  563. setScreenShareContentHint(contentHint: string): Promise<void>;
  564. /**
  565. * @brief 是否推送屏幕分享
  566. * @param enabled 是否开启/关闭本地屏幕分享推送
  567. * - true: 开启屏幕分享推送
  568. * - false: 关闭屏幕分享推送
  569. * @param config 开启屏幕共享的配置
  570. * @note SDK默认设置推送屏幕分享,在加入频道前也可以调用此接口修改默认值,并在加入频道成功时生效
  571. * @note 加入频道后调用不会停止本地屏幕采集
  572. */
  573. publishLocalScreenShareStream(enabled: boolean, config?: AliRtcScreenShareStartConfig): Promise<void>;
  574. /**
  575. * @brief 查询是否设置推送屏幕分享
  576. * @return
  577. - true: 已设置推送
  578. - false: 未设置推送
  579. * @note SDK默认设置不推送屏幕分享,如果需要推送屏幕共享,可以通过{@link startScreenShare}方法开启屏幕共享推送
  580. */
  581. isScreenSharePublished(): boolean;
  582. /**
  583. * @brief 设置共享音频的音量大小
  584. * @param volume 共享音频音量大小,取值范围[0, 100]
  585. */
  586. setAudioShareVolume(volume: number): void;
  587. /**
  588. * 开启音量检测功能
  589. * @param {number} interval 检测间隔,单位: ms
  590. * @note 建议设置为300ms~500ms,取值 ≤0 表示不启用音量检测功能
  591. */
  592. enableAudioVolumeIndication(interval: number): void;
  593. /**
  594. * 停止/恢复本地音频数据发送
  595. * @param {boolean} mute 停止或恢复本地音频数据发送
  596. * - true:静音本地音频
  597. * - false(默认值):取消静音
  598. */
  599. muteLocalMic(mute?: boolean): void;
  600. /**
  601. * 停止/恢复远端指定用户的音频流的播放
  602. * @param {string} uid 用户ID, 从 App server 分配的唯一标示符
  603. * @param {boolean} mute 停止或恢复远端的音频播放
  604. * - true:停止播放
  605. * - false(默认值):恢复播放
  606. * @note 拉流和解码不受影响,支持 {@link joinChannel} 之前和之后设置
  607. */
  608. muteRemoteAudioPlaying(uid: string, mute?: boolean): void;
  609. /**
  610. * 停止/恢复远端的所有音频流的播放
  611. * @param {boolean} mute 停止或恢复远端的音频播放
  612. * - true:停止播放
  613. * - false(默认值):恢复播放
  614. * @note 拉流和解码不受影响,支持 {@link joinChannel} 之前和之后设置
  615. */
  616. muteAllRemoteAudioPlaying(mute?: boolean): void;
  617. /**
  618. * @brief 开启音频采集
  619. * @details 此接口可以控制提前打开音频采集,如果不设置,则SDK会自动控制音频采集设备:
  620. * - 如果打开推送音频流{@link publishLocalAudioStream},SDK在入会后会打开音频采集
  621. * - 如果关闭推送音频流{@link publishLocalAudioStream},SDK在入会后不会打开音频采集
  622. * @param {IAudioConstraints} audioConstraints 音频采集参数
  623. */
  624. startAudioCapture(audioConstraints?: IAudioConstraints): Promise<void>;
  625. /**
  626. * @brief 设置音频采集参数
  627. * @param constraints 音频采集参数
  628. */
  629. setAudioConstraints(constraints: IAudioConstraints): Promise<void>;
  630. /**
  631. * 关闭音频采集
  632. * @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
  633. */
  634. stopAudioCapture(): void;
  635. /**
  636. * 切换麦克风
  637. * @param {string} deviceId 麦克风设备ID
  638. * @param {MediaStreamAudioTrack} audioTrack 音频轨道
  639. * @note 传入 audioTrack 则会使用传入的音频轨道
  640. */
  641. switchMicrophone(deviceId: string, audioTrack?: MediaStreamAudioTrack): Promise<void>;
  642. /**
  643. * 设置录音音量
  644. * @param {VolumeSettings} volumeSettings 录音音量,取值范围[0,100]
  645. * - 0:静音
  646. * - <100:减小音量
  647. * - >100:放大音量
  648. */
  649. setRecordingVolume(volume: number): void;
  650. /**
  651. * @brief 设置播放音量
  652. * @param volume 播放音量,取值范围[0,100], 0:静音;100:原始音量
  653. * @note 注意此方法与 {@link setRemoteAudioVolume} 相互影响,以后调用的一个为准
  654. */
  655. setPlayoutVolume(volume: number): void;
  656. /**
  657. * @brief 设置播放音量
  658. * @param userId 用户ID
  659. * @param volume 播放音量,取值范围[0,100], 0:静音;100:原始音量
  660. * @note 注意此方法与 {@link setPlayoutVolume} 相互影响,以后调用的一个为准
  661. */
  662. setRemoteAudioVolume(userId: string, volume: number): void;
  663. /**
  664. * 设置麦克风 profile
  665. *
  666. * @param {AudioProfileKey} profileKey
  667. * @return {Promise<void>}
  668. */
  669. setAudioProfile(profileKey: AudioProfileKey): Promise<void>;
  670. /**
  671. * @brief 获取当前用户或远端用户的音频轨道
  672. * @param {string} userId 远端用户 userId
  673. * @return {MediaStreamTrack} 音频轨道
  674. *
  675. */
  676. getAudioTrack(userId?: string): Promise<MediaStreamTrack | undefined>;
  677. /**
  678. * 为本地预览设置渲染元素和视频流
  679. * @param {AliRtcLocalView} view 渲染元素,null 则为停止显示
  680. * @param {AliRtcVideoTrack} track 视频流类型
  681. */
  682. setLocalViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): Promise<void>;
  683. /**
  684. * @brief 采集偏好设置
  685. * @param cameraCapturerConfiguration 偏好设置
  686. * - width: 设置采集分辨率宽度 默认 1280
  687. * - height: 设置采集分辨率高度 默认 720
  688. * - frameRate: 设置采集帧率 默认 30
  689. * - bitrate: 设置采集码率 默认 2000
  690. * - cameraDirection: 设置采集方向,前置或后置摄像头
  691. * - deviceId: 设置采集相机ID
  692. */
  693. setCameraCapturerConfiguration(cameraCapturerConfiguration: AliEngineCameraCapturerConfiguration): Promise<void>;
  694. /**
  695. * @breif 设置摄像头采集内容提示
  696. * @param contentHint 设置视频内容提示,用于提升在不同内容场景下的视频编码质量 [参考文档](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/contentHint)
  697. */
  698. setCameraCapturerContentHint(contentHint: string): Promise<void>;
  699. /**
  700. * 禁用或启用摄像头采集
  701. * @param enabled
  702. * - true : 启用摄像头采集
  703. * - false : 禁用摄像头采集
  704. */
  705. enableLocalVideo(enabled?: boolean): Promise<void>;
  706. /**
  707. * 是否将停止摄像头流数据发送
  708. * @param mute
  709. * - true:停止发送摄像头流数据
  710. * - false:表示恢复正常
  711. */
  712. muteLocalCamera(mute: boolean): Promise<void>;
  713. /**
  714. * 是否将停止屏幕共享流数据发送
  715. * @param mute
  716. * - true:停止发送屏幕共享流数据
  717. * - false:表示恢复正常
  718. */
  719. muteLocalScreen(mute: boolean): Promise<void>;
  720. /**
  721. * 设置远端视频显示视图
  722. * @param {AliRtcLocalView} view 渲染元素
  723. * @param {AliRtcVideoTrack} track 视频流类型
  724. * @param {string} uid 用户ID, 从App server分配的唯一标示符
  725. * @note 支持joinChannel之前和之后切换窗口。如果 view 传入 null,则停止显示
  726. */
  727. setRemoteViewConfig(view: AliRtcLocalView, uid: string, track: AliRtcVideoTrack): void;
  728. /**
  729. * 检查camera是否打开
  730. * @return {boolean}
  731. * - true: 摄像头已打开
  732. * - false: 摄像头没有打开
  733. * @note 该接口用于检查当前camera的状态
  734. */
  735. isCameraOn(): boolean;
  736. /**
  737. * 切换摄像头
  738. * @param {string} deviceId 摄像头设备ID
  739. * @param {MediaStreamVideoTrack} videoTrack 视频流
  740. * @note 若不传 deviceId 则前后摄像头切换,传入 videoTrack 则会使用传入的 videoTrack
  741. */
  742. switchCamera(deviceId?: string, videoTrack?: MediaStreamVideoTrack): Promise<void>;
  743. /**
  744. * 获取摄像头设备ID
  745. * @return {string} 摄像头设备ID
  746. */
  747. getCurrentCameraDeviceId(): string | undefined;
  748. /**
  749. * @brief 开启摄像头预览
  750. * @details 开启摄像头预览并自动打开摄像头
  751. * @note 如果没有调用{@link setLocalViewConfig}设置显示的view,则无法预览,但不影响推流。
  752. * 可以在{@link joinChannel}之前就开启预览会自动打开摄像头。
  753. */
  754. startPreview(): Promise<void>;
  755. /**
  756. * @brief 开启屏幕共享预览
  757. * @details 开启屏幕共享预览并自动打开屏幕共享
  758. * @param config 开启屏幕共享的配置
  759. * @note 如果没有调用{@link setLocalViewConfig}设置显示的view,则无法预览,但不影响推流。
  760. * 可以在{@link joinChannel}之前就开启预览会自动打开屏幕共享。
  761. */
  762. startPreviewScreen(config?: AliRtcScreenShareStartConfig): Promise<void>;
  763. /**
  764. * @brief 停止本地视频预览
  765. */
  766. stopPreview(): Promise<void>;
  767. /**
  768. * @brief 停止本地屏幕共享预览
  769. */
  770. stopPreviewScreen(): Promise<void>;
  771. /**
  772. * @brief 获取当前用户或远端用户的视频轨道
  773. * @param {AliRtcVideoTrackConfig} config 视频轨道配置
  774. * @return {MediaStreamTrack} 视频轨道
  775. *
  776. */
  777. getVideoTrack(config: AliRtcVideoTrackConfig): Promise<MediaStreamTrack | undefined>;
  778. /**
  779. * @brief 开启旁路直播
  780. * @details SDK提供了开启旁路直播的功能,可以把实时音视频流经过混流、混音处理转为标准直播流并推送至指定CDN供应商
  781. * @param streamUrl 推流地址
  782. * @param transcoding 推流所需参数, 详细定义见{@link AliRtcLiveTranscodingParam}
  783. */
  784. startPublishLiveStream(streamUrl: string, transcoding: AliRtcLiveTranscodingParam): Promise<any>;
  785. /**
  786. * @brief 更新旁路直播相关参数
  787. * @details SDK提供了更新旁路直播的功能,用于实时更新旁路直播参数
  788. * @param streamUrl 推流地址
  789. * @param transcoding 推流所需参数, 详细定义见{@link AliRtcLiveTranscodingParam}
  790. */
  791. updatePublishLiveStream(streamUrl: string, transcoding: AliRtcLiveTranscodingParam): Promise<any>;
  792. /**
  793. * @brief 更新旁路直播相关参数
  794. * @details SDK提供了更新旁路直播的功能,用于实时更新旁路直播参数
  795. * @param taskId 任务Id
  796. * @param transcoding 推流所需参数, 详细定义见{@link AliRtcLiveTranscodingParam}
  797. * @return
  798. * - 0 : 成功
  799. * - 非0 : 失败
  800. * - ERR_INNER(-1) : SDK内部错误,可能的情况为SDK未初始化或者SDK销毁后调用
  801. * - 其他 : 返回值参考官网错误码
  802. */
  803. updatePublishLiveStreamWithTaskId(taskId: string, transcoding: AliRtcLiveTranscodingParam): Promise<any>;
  804. /**
  805. * @brief 停止旁路直播
  806. * @details SDK提供了停止旁路直播的功能
  807. * @param streamUrl 推流地址
  808. */
  809. stopPublishLiveStream(streamUrl: string): Promise<any>;
  810. /**
  811. * @brief 停止旁路直播
  812. * @details SDK提供了停止旁路直播的功能
  813. * @param taskId 任务Id
  814. */
  815. stopPublishLiveStreamWithTaskId(taskId: string): Promise<any>;
  816. /**
  817. * 获取旁路直播状态
  818. * @param streamUrl 推流地址
  819. * @return 路直播状态
  820. */
  821. /**
  822. * @brief 设置是否启用媒体扩展信息
  823. * @param enabled 是否启用媒体扩展,需要在加入房间之前调用
  824. */
  825. setEnableMediaExtensionMsg(enabled: boolean): void;
  826. /**
  827. * @brief 发送媒体扩展信息
  828. * @details SDK提供了发送和接收媒体扩展信息的功能,接收端参考 {@link AliRtcEngineEventListener.mediaExtensionMsgReceived},使用场景:
  829. * - 使用媒体扩展信息传递时间戳,计算端到端的网络延迟,或者跟自身其他业务做数据同步
  830. * - 使用媒体扩展信息传递描述信息。目前可以传递最多 4k Byte数据,可以用来传输少量数据,建议使用Json或者纯字符串;
  831. * - 内部使用SEI扩展协议来实现;
  832. *
  833. * @param message 媒体扩展信息,长度限制为最大4K字节
  834. * @param repeatCount 重复次数,代表消息冗余度,用于防止网络丢包导致的消息丢失,-1为无限传输
  835. *
  836. * @note 启用此能力会增加客户端性能开销,如有需求需要在加入房间之前调用 setEnableMediaExtensionMsg
  837. * @note 使用媒体扩展信息时需要复用音视频数据通道,因此必须控制自定义消息的发送频率和消息数据长度,使用限制如下:
  838. * - 每秒最多发送profile条消息,因为sei信息是放到h264/h265流中传输,有视频帧编码才能附加扩展信息;
  839. * - 为了不影响媒体数据的传输质量,自定义消息体长度限制为4k Byte,可以用来传输少量信息;
  840. * - sendMediaExtensionMsg函数中repeatCount参数为自定义消息冗余度,若大于1,则会发送多次,
  841. * - 防止网络丢包导致的消息丢失,此时房间里的其他人也会收到多次相同的消息,需要去重
  842. * - 发送的自定义消息,在旁路直播时,房间里的订阅者也一样会收到
  843. * - 同一时间只有一条MediaExtensionMsg在传输,多次调用sendMediaExtensionMsg,新调用的数据会覆盖前一次的数据;
  844. */
  845. sendMediaExtensionMsg(message: ArrayBuffer, repeatCount: number): Promise<void>;
  846. /**
  847. * @brief 发送媒体扩展信息
  848. * @details SDK提供了发送和接收媒体扩展信息的功能,接收端参考 {@link AliRtcEngineEventListener.mediaExtensionMsgReceived},使用场景:
  849. * - 使用媒体扩展信息传递时间戳,计算端到端的网络延迟,或者跟自身其他业务做数据同步
  850. * - 使用媒体扩展信息传递描述信息。目前可以传递最多 4k Byte数据,可以用来传输少量数据,建议使用Json或者纯字符串;
  851. * - 内部使用SEI扩展协议来实现;
  852. *
  853. * @param message 媒体扩展信息,长度限制为最大4K字节
  854. * @param repeatCount 重复次数,代表消息冗余度,用于防止网络丢包导致的消息丢失,-1为无限传输
  855. * @param payloadType [5, 100..254]范围 payloadType=5等于使用sendMediaExtensionMsg 接口
  856. *
  857. * @note 启用此能力会增加客户端性能开销,如有需求需要在加入房间之前调用 setEnableMediaExtensionMsg
  858. * @note 使用媒体扩展信息时需要复用音视频数据通道,因此必须控制自定义消息的发送频率和消息数据长度,使用限制如下:
  859. * - 每秒最多发送profile条消息,因为sei信息是放到h264/h265流中传输,有视频帧编码才能附加扩展信息;
  860. * - 为了不影响媒体数据的传输质量,自定义消息体长度限制为4k Byte,可以用来传输少量信息;
  861. * - sendMediaExtensionMsg函数中repeatCount参数为自定义消息冗余度,若大于1,则会发送多次,
  862. * - 防止网络丢包导致的消息丢失,此时房间里的其他人也会收到多次相同的消息,需要去重
  863. * - 发送的自定义消息,在旁路直播时,房间里的订阅者也一样会收到
  864. * - 同一时间只有一条MediaExtensionMsg在传输,多次调用sendMediaExtensionMsg,新调用的数据会覆盖前一次的数据;
  865. */
  866. sendMediaExtensionMsgEx(message: ArrayBuffer, repeatCount: number, payloadType: number): Promise<void>;
  867. static Plugin: typeof AliRtcPlugin;
  868. /**
  869. * @brief 开启音视频处理算法插件
  870. * @details RTC采用插件件形式提供音视频增强及特效能力,可通过[官网组件文档](https://help.aliyun.com/document_detail/261183.html) 进行组件下载,参考插件集成文档集成进RTC引擎;
  871. * @param plugin 插件库
  872. * @param option 插件初始化参数值,请阅读插件库接入文档
  873. * @note
  874. * - 入会前入会后均可调用;
  875. * - 如果重复调用会报错;
  876. */
  877. enablePlugin(plugin: AliRtcPlugin, options?: any): void;
  878. /**
  879. * @brief 关闭音视频处理算法插件
  880. * @param name 插件名称,通过 plugin.name 获取
  881. * @note
  882. * - 入会前入会后均可调用;
  883. * - 重复调用返回错误;
  884. */
  885. removePlugin(name: string): void;
  886. /**
  887. * @brief 根据插件ID设置插件
  888. * @param name 插件名称,通过 plugin.name 获取
  889. * @param option 插件初始化参数值,请阅读插件库接入文档
  890. */
  891. setPluginOption(name: string, option: any): void;
  892. /**
  893. * @brief 根据插件ID获取插件内部信息
  894. * @param name 插件名称,通过 plugin.name 获取
  895. */
  896. getPluginOption(name: string): any;
  897. /**
  898. * 美颜功能是否有效
  899. * @return
  900. * - true: 美颜功能有效
  901. * - false: 无效
  902. */
  903. isBeautyAvailable(): boolean;
  904. /**
  905. * 美颜功能是否开启
  906. * @return
  907. * - true: 美颜功能已开启
  908. * - false: 已关闭
  909. */
  910. isBeautyEnabled(): boolean;
  911. /**
  912. * @brief 开启或关闭美颜功能, 并设置美颜效果参数
  913. * @param enable
  914. * - true: 开启美颜功能
  915. * - false: 关闭美颜功能
  916. * @param config 美颜效果参数
  917. */
  918. setBeautyEffect(enable: boolean, config: AliRtcBeautyConfig): void;
  919. /**
  920. * @brief 开启/关闭虚拟背景替换功能
  921. * @details 需要集成美颜插件;
  922. * @param enable 是否开启;
  923. * @param path 虚拟背景本地图片路径,支持JPG,PNG 格式;
  924. *
  925. * @note
  926. * - 与背景虚化为替换关系,如开启虚拟背景开关后再次开启背景虚化,则只有背景虚化效果;
  927. */
  928. enableBackgroundExchange(enable: boolean, path: string): void;
  929. /**
  930. * @brief 开启/关闭虚拟背景虚化功能
  931. * @details 需要集成美颜插件;
  932. * 需要集成美颜插件,背景替换与背景虚化不可同时使用,如开启虚拟背景开关后再次开启背景虚化,则只有背景虚化效果;
  933. * @param enable 是否开启;
  934. *
  935. * @note
  936. * - 与虚拟背景为替换关系,如开启背景虚化开关后再次开启虚拟背景,则只有虚拟背景效果;
  937. */
  938. enableBackgroundBlur(enable: boolean): void;
  939. setParameter(parameter: string): void;
  940. getParameter(): string;
  941. /**
  942. * @brief 发送 DataChannel 消息
  943. * @param dataChannelMsg 伴奏控制消息
  944. */
  945. sendDataChannelMessage(dataChannelMsg: AliRtcDataChannelMsg): void;
  946. }
  947. declare interface AliRtcEngineConfig {
  948. env?: AliRtcEnv;
  949. webTrack?: boolean | AliRtcWebTrackConfig;
  950. maxSignalingConnectRetryCount?: number;
  951. }
  952. declare interface AliRtcEngineEventListener {
  953. /**
  954. * @brief 网络连接状态改变
  955. * @param status 连接状态
  956. * @param reason 连接状态变化原因
  957. */
  958. connectionStatusChange: (status: AliRtcConnectionStatus, reason: AliRtcConnectionStatusChangeReason) => void;
  959. /**
  960. * @brief 本地设备异常回调
  961. * @param deviceType 设备类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceType}
  962. * @param exceptionType 设备异常类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceExceptionType}
  963. * @param msg 异常时携带的信息
  964. * @note 此回调标识了内部无法恢复了设备异常,收到此回调时用户需要检查设备是否可用
  965. */
  966. localDeviceException: (localDeviceType: AliRtcEngineLocalDeviceType, localDeviceExceptionType: AliRtcEngineLocalDeviceExceptionType, description: string) => void;
  967. /**
  968. * @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
  969. * @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo}
  970. */
  971. /**
  972. * 被服务器踢出/会议结束频道的消息
  973. * @param code 原因参考{@link AliRtcEngine.AliRtcOnByeType}
  974. */
  975. bye: (code: AliRtcOnByeType) => void;
  976. /**
  977. * @brief 远端用户(通信模式)/(互动模式,主播角色)加入频道回调
  978. * @details 该回调在以下场景会被触发
  979. * - 通信模式:远端用户加入频道会触发该回调,如果当前用户在加入频道前已有其他用户在频道中,当前用户加入频道后也会收到已加入频道用户的回调
  980. * - 互动模式:
  981. * - 远端主播角色用户加入频道会触发该回调,如果当前用户在加入频道前已有其他主播在频道中,当前用户加入频道后也会收到已加入频道主播的回调
  982. * - 远端观众角色调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
  983. *
  984. * @param uid 用户ID,从App server分配的唯一标示符
  985. * @param elapsed 用户加入频道时的耗时
  986. * @note 互动模式下回调行为
  987. * - 主播间可以互相收到加入频道回调
  988. * - 观众可以收到主播加入频道回调
  989. * - 主播无法收到观众加入频道回调
  990. */
  991. remoteUserOnLineNotify: (uid: string, elapsed: number) => void;
  992. /**
  993. * @brief 远端用户(通信模式)/(互动模式,主播角色)离开频道回调
  994. * @details 该回调在以下场景会被触发
  995. * - 通信模式:远端用户离开频道会触发该回调
  996. * - 互动模式:
  997. * - 远端主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive} 离开频道
  998. * - 远端主播切换调用 {@link AliRtcEngine.setClientRole} 切换为观众角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkLive},会触发该回调
  999. * - 通信模式和互动模式主播角色情况下,当长时间收不到远端用户数据,超时掉线时,会触发该回调
  1000. *
  1001. * @param uid 用户ID,从App server分配的唯一标示符
  1002. * @param reason 用户离线的原因,详见 {@link AliRtcEngine.AliRtcUserOfflineReason}
  1003. */
  1004. remoteUserOffLineNotify: (uid: string, aliRtcUserOfflineReason: AliRtcUserOfflineReason) => void;
  1005. /**
  1006. * @brief 远端用户的音视频流发生变化回调
  1007. * @details 该回调在以下场景会被触发
  1008. * - 当远端用户从未推流变更为推流(包括音频和视频)
  1009. * - 当远端用户从已推流变更为未推流(包括音频和视频)
  1010. * - 互动模式下,调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
  1011. *
  1012. * @param uid 用户ID,从App server分配的唯一标示符
  1013. * @param audioTrack 音频流类型,详见 {@link AliRtcEngine.AliRtcAudioTrack}
  1014. * @param videoTrack 视频流类型,详见 {@link AliRtcEngine.AliRtcVideoTrack}
  1015. * @note 该回调仅在通信模式用户和互动模式下的主播角色才会触发
  1016. */
  1017. remoteTrackAvailableNotify: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
  1018. /**
  1019. * @brief 远端用户静音/取消静音回调
  1020. * @param uid 远端用户ID
  1021. * @param isMute 该用户是否静音
  1022. * - true: 静音
  1023. * - false: 取消静音
  1024. */
  1025. userAudioMuted: (uid: string, isMute: boolean) => void;
  1026. /**
  1027. * @brief 对端用户发送视频黑帧数据发送通知
  1028. * @param uid 执行muteVideo的用户ID
  1029. * @param isMute
  1030. * - true: 推流黑帧
  1031. * - false: 正常推流
  1032. * @note 该接口用于对端用户发送视频黑帧数据时的回调
  1033. */
  1034. userVideoMuted: (uid: string, isMute: boolean) => void;
  1035. /**
  1036. * @brief 对端用户发送屏幕黑帧数据发送通知
  1037. * @param uid 执行muteVideo的用户ID
  1038. * @param isMute
  1039. * - true: 推流黑帧
  1040. * - false: 正常推流
  1041. * @note 该接口用于对端用户发送屏幕黑帧数据时的回调
  1042. */
  1043. userScreenMuted: (uid: string, isMute: boolean) => void;
  1044. /**
  1045. * 音量反馈
  1046. * @param {Array} speakers 用户音量对象数组
  1047. * @param {string} speaker.userId 用户ID
  1048. * @param {number} speaker.volume 音量
  1049. * @note userId 为空字符串时代表是本地麦克风采集的音量
  1050. */
  1051. audioVolume: (speakers: {
  1052. userId: string;
  1053. volume: number;
  1054. }[]) => void;
  1055. /**
  1056. * 发布视频流的数据统计
  1057. * @param aliRtcStats 统计信息
  1058. */
  1059. aliRtcStats: (aliRtcStats: any) => void;
  1060. /**
  1061. * 音频推流变更回调
  1062. * @param track 流标识
  1063. * @param oldState 之前的推流状态
  1064. * @param newState 当前的推流状态
  1065. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1066. * @param channel 当前频道
  1067. */
  1068. audioPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
  1069. /**
  1070. * 音频订阅情况变更回调
  1071. * @param uid 用户ID
  1072. * @param oldState 之前的订阅状态
  1073. * @param newState 当前的订阅状态
  1074. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1075. * @param channel 当前频道
  1076. */
  1077. audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  1078. /**
  1079. * 视频推流变更回调
  1080. * @param oldState 之前的推流状态
  1081. * @param newState 当前的推流状态
  1082. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1083. * @param channel 当前频道
  1084. */
  1085. videoPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
  1086. /**
  1087. * 次要流推流变更回调
  1088. * @param oldState 之前的推流状态
  1089. * @param newState 当前的推流状态
  1090. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1091. * @param channel 当前频道
  1092. */
  1093. dualStreamPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
  1094. /**
  1095. * 屏幕分享推流变更回调
  1096. * @param oldState 之前的推流状态
  1097. * @param newState 当前的推流状态
  1098. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1099. * @param channel 当前频道
  1100. */
  1101. screenSharePublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
  1102. /**
  1103. * DataChannel 推流变更回调
  1104. * @param oldState 之前的推流状态
  1105. * @param newState 当前的推流状态
  1106. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1107. * @param channel 当前频道
  1108. */
  1109. dataPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
  1110. /**
  1111. * 相机流订阅情况变更回调
  1112. * @param uid 用户ID
  1113. * @param oldState 之前的订阅状态
  1114. * @param newState 当前的订阅状态
  1115. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1116. * @param channel 当前频道
  1117. */
  1118. videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  1119. /**
  1120. * 大小流订阅情况变更回调
  1121. * @param uid 用户ID
  1122. * @param oldStreamType 之前的订阅状态
  1123. * @param newStreamType 当前的订阅状态
  1124. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1125. * @param channel 当前频道
  1126. */
  1127. subscribeStreamTypeChanged: (uid: string, oldStreamType: AliRtcVideoStreamType, newStreamType: AliRtcVideoStreamType, elapseSinceLastState: number, channel: string) => void;
  1128. /**
  1129. * 屏幕分享流订阅情况变更回调
  1130. * @param uid 用户ID
  1131. * @param oldState 之前的订阅状态
  1132. * @param newState 当前的订阅状态
  1133. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1134. * @param channel 当前频道
  1135. */
  1136. screenShareSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  1137. /**
  1138. * DataChannel 订阅情况变更回调
  1139. * @param uid 用户ID
  1140. * @param oldState 之前的订阅状态
  1141. * @param newState 当前的订阅状态
  1142. * @param elapseSinceLastState 状态变更时间间隔(毫秒)
  1143. * @param channel 当前频道
  1144. */
  1145. dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  1146. /**
  1147. * 收到媒体扩展信息回调
  1148. * @param uid 用户ID,媒体信息发送用户的ID
  1149. * @param message 媒体扩展信息
  1150. * @param payloadType payload类型,sendMediaExtensionMsg返回5,sendMediaExtensionMsgEx发送的会返回具体类型
  1151. * @note 当一端通过 {@link AliRtcEngine.sendMediaExtensionMsg} 发送信息后,其他端通过该回调接收数据
  1152. */
  1153. mediaExtensionMsgReceived: (uid: string, message: ArrayBuffer, payloadType: number) => void;
  1154. /**
  1155. * @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
  1156. * @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo:}
  1157. */
  1158. authInfoWillExpire: () => void;
  1159. /**
  1160. * @brief 用户调用需要鉴权的接口,服务端返回信息过期
  1161. * @note 该回调触发代表鉴权信息已过期,想要继续在会中,需要重新入会,参考 {@link AliRtcEngine.joinChannel:name:onResultWithUserId:}
  1162. */
  1163. authInfoExpired: () => {};
  1164. /**
  1165. * 远程用户的音频自动播放失败
  1166. * @param uid
  1167. * @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
  1168. */
  1169. remoteAudioAutoPlayFail: (uid: string) => void;
  1170. /**
  1171. * 远程用户的视频自动播放失败
  1172. * @param uid
  1173. * @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
  1174. */
  1175. remoteVideoAutoPlayFail: (uid: string, videoTrack: AliRtcVideoTrack) => void;
  1176. /**
  1177. * 远程用户的音频播放出错
  1178. * @param uid 用户ID
  1179. * @param reason 出错原因,可选
  1180. */
  1181. remoteAudioPlayError: (uid: string, reason: string | undefined) => void;
  1182. /**
  1183. * 远程用户的视频播放出错
  1184. * @param uid 用户ID
  1185. * @param reason 出错原因,可选
  1186. */
  1187. remoteVideoPlayError: (uid: string, reason: string | undefined) => void;
  1188. /**
  1189. * rtc 传输数据统计
  1190. * @param stats 统计信息
  1191. */
  1192. rtcStats: (stats: any) => void;
  1193. /**
  1194. * 发布视频流的数据统计
  1195. * @param aliRtcStats 统计信息
  1196. */
  1197. rtcLocalVideoStats: (stats: AliRtcLocalVideoStats[]) => void;
  1198. /**
  1199. * 发布音频流的数据统计
  1200. * @param aliRtcStats 统计信息
  1201. */
  1202. rtcLocalAudioStats: (stats: AliRtcLocalAudioStats[]) => void;
  1203. /**
  1204. * 订阅视频流的数据统计
  1205. * @param aliRtcStats 统计信息
  1206. */
  1207. rtcRemoteVideoStats: (stats: AliRtcRemoteVideoStats[]) => void;
  1208. /**
  1209. * 订阅远端音频流的数据统计
  1210. * @param aliRtcStats 统计信息
  1211. */
  1212. rtcRemoteAudioStats: (stats: AliRtcRemoteAudioStats[]) => void;
  1213. /**
  1214. * @brief 错误通知
  1215. * @deprecated 请使用 occurError
  1216. * @details 如果engine出现error,通过这个回调通知app
  1217. * @param error 错误类型,参考 {@link AliRtcError}
  1218. * @param uid 用户 Id,不一定存在
  1219. */
  1220. onOccurError: (error: AliRtcError, uid?: string) => void;
  1221. /**
  1222. * @brief 错误通知
  1223. * @details 如果engine出现error,通过这个回调通知app
  1224. * @param error 错误类型,参考 {@link AliRtcError}
  1225. * @param uid 用户 Id,不一定存在
  1226. */
  1227. occurError: (error: AliRtcError, uid?: string) => void;
  1228. /**
  1229. * @brief 收到数据通道消息
  1230. * @param uid 用户ID
  1231. * @param message 消息
  1232. */
  1233. dataChannelMsg: (uid: string, message: AliRtcDataChannelMsg) => void;
  1234. }
  1235. export declare enum AliRtcEngineLocalDeviceExceptionType {
  1236. /** 未知异常类型 */
  1237. AliEngineLocalDeviceExceptionTypeUnknown = 0,
  1238. /** 麦克风打开失败 */
  1239. AliEngineLocalDeviceExceptionTypeMicOpenFail = 1,
  1240. /** 麦克风被打断 */
  1241. AliEngineLocalDeviceExceptionTypeMicInterrupt = 2,
  1242. /** 麦克风无权限 */
  1243. AliEngineLocalDeviceExceptionTypeMicAuthFail = 3,
  1244. /** 无可用麦克风 */
  1245. AliEngineLocalDeviceExceptionTypeMicNotAvailable = 4,
  1246. /** 扬声器打开失败 */
  1247. AliEngineLocalDeviceExceptionTypeSpeakerOpenFail = 5,
  1248. /** 扬声器被打断 */
  1249. AliEngineLocalDeviceExceptionTypeSpeakerInterrupt = 6,
  1250. /** 无可用扬声器 */
  1251. AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable = 7,
  1252. /** 音频设备异常 */
  1253. AliEngineLocalDeviceExceptionTypeAudioDeviceException = 8,
  1254. /** 摄像头打开失败 */
  1255. AliEngineLocalDeviceExceptionTypeCameraOpenFail = 9,
  1256. /** 摄像头被打断 */
  1257. AliEngineLocalDeviceExceptionTypeCameraInterrupt = 10,
  1258. /** 摄像头无权限 */
  1259. AliEngineLocalDeviceExceptionTypeCameraAuthFail = 11,
  1260. /** 显示设备异常 */
  1261. AliEngineLocalDeviceExceptionTypeDisplayException = 12,
  1262. /** 视频设备异常 */
  1263. AliEngineLocalDeviceExceptionTypeVideoDeviceException = 13
  1264. }
  1265. export declare enum AliRtcEngineLocalDeviceType {
  1266. /** 未知设备类型 */
  1267. AliEngineLocalDeviceTypeUnknown = 0,
  1268. /** 麦克风设备 */
  1269. AliEngineLocalDeviceTypeMic = 1,
  1270. /** 扬声器设备 */
  1271. AliEngineLocalDeviceTypeSpeaker = 2,
  1272. /** 音频设备 */
  1273. AliEngineLocalDeviceTypeAudioDevice = 3,
  1274. /** 摄像头设备 */
  1275. AliEngineLocalDeviceTypeCamera = 4,
  1276. /** 显示设备 */
  1277. AliEngineLocalDeviceTypeDisplay = 5,
  1278. /** 视频设备 */
  1279. AliEngineLocalDeviceTypeVideoDevice = 6
  1280. }
  1281. declare enum AliRtcEnv {
  1282. pre = "pre",
  1283. prod = "prod"
  1284. }
  1285. declare class AliRtcError extends Error {
  1286. _code: number;
  1287. _extra?: any;
  1288. static fromRtsError(error: any): AliRtcError;
  1289. static fromError(error: any, code?: number, fallbackMessage?: string): AliRtcError;
  1290. constructor(code: number, message: string, extra?: any);
  1291. get code(): number;
  1292. set code(code: number);
  1293. get reason(): string;
  1294. get extra(): any;
  1295. }
  1296. export declare enum AliRtcErrorCode {
  1297. /****************************************************
  1298. * 入会错误码
  1299. ****************************************************/
  1300. /** 已经加入频道 */
  1301. ERR_JOIN_ALREADY_JOINED = 16843521,
  1302. /** AppId不存在,请在控制台创建应用 */
  1303. ERR_JOIN_BAD_APPID = 33620481,
  1304. /** AppId已失效,请在控制台重新启用应用 */
  1305. ERR_JOIN_INVALID_APPID = 33620482,
  1306. /**
  1307. * 频道不存在,请尝试重新加入频道
  1308. * 如会议发起者入会后又很快离会,第二个人随后入会,发现会议已经不存在了。
  1309. */
  1310. ERR_JOIN_BAD_CHANNEL = 33620484,
  1311. /** 频道已经失效(目前频道有效期为48小时),请重新生成频道鉴权令牌(Token) */
  1312. ERR_JOIN_INVALID_CHANNEL = 33620483,
  1313. /** Token无效。 请重新生成频道鉴权令牌(Token) */
  1314. ERR_JOIN_BAD_TOKEN = 33620485,
  1315. /** 加入频道超时,请检查网络连接是否正常 */
  1316. ERR_JOIN_TIMEOUT = 16908804,
  1317. /** 参数错误,{@link AliRtcAuthInfo}中的字段为空或者timestamp<=0,请检查字段是否完整 */
  1318. ERR_JOIN_ERR_JOIN_BAD_PARAMBAD = 16974081,
  1319. /** 加入频道失败 */
  1320. ERR_JOIN_CHANNEL_FAILED = 16974338,
  1321. /****************************************************
  1322. * 日志模块错误码
  1323. ****************************************************/
  1324. /** 日志模块已经初始化 */
  1325. ERR_LOG_ALREADY_INIT = 16974085,
  1326. /** 日志模块根路径错误,请检查路径是否存在或路径是否具有写入权限 */
  1327. ERR_LOG_ROOT_PATH_ERROR = 16974086,
  1328. /****************************************************
  1329. * 音频设备错误码
  1330. ****************************************************/
  1331. /**
  1332. * 采集设备初始化失败、采集设备媒体服务异常、音频设备被占用。
  1333. * - Mac端和Windows端查看系统设置中音频设备是否有能量条
  1334. * - iOS端和Android端确认是否被其他应用占用
  1335. * - 如果都正常,请重启设备
  1336. */
  1337. ERR_MIC_OPEN_FAIL = 17040388,
  1338. /**
  1339. * 播放设备初始化失败、播放设备媒体服务异常、音频设备被占用。
  1340. * - Mac端和Windows端查看系统设置中音频设备是否有能量条
  1341. * - iOS端和Android端确认是否被其他应用占用
  1342. * - 如果都正常,请重启设备
  1343. */
  1344. ERR_SPEAKER_OPEN_FAIL = 17040389,
  1345. /** 系统性能不足、采集设备媒体服务异常、音频设备被占用。建议重启应用或重启设备 */
  1346. ERR_MIC_INTERRUPT = 17040390,
  1347. /** 系统性能不足,播放设备媒体服务异常,音频设备被占用。建议重启应用或重启设备 */
  1348. ERR_SPEAKER_INTERRUPT = 17040391,
  1349. /** 麦克风设备未授权,建议去系统设置中,打开麦克风授权,并且重新加入频道 */
  1350. ERR_MIC_AUTH_FAIL = 17040392,
  1351. /** 无可用的音频采集设备,检查是否接入了可用的麦克风,并检查系统设置中,该设备是否被禁用 */
  1352. ERR_MIC_NOT_AVAILABLE = 17040393,
  1353. /** 无可用的音频播放设备,检查是否接入了可用的扬声器或耳机,并检查系统设置中,该设备是否被禁用 */
  1354. ERR_SPEAKER_NOT_AVAILABLE = 17040400,
  1355. /****************************************************
  1356. * 视频设备错误码
  1357. ****************************************************/
  1358. /** 采集设备初始化失败,检查系统相机是否可用,移动端App是否占用了相机 */
  1359. ERR_CAMERA_OPEN_FAIL = 17039620,
  1360. /** 采集设备未授权,建议去系统设置中,打开摄像头授权,并且重新加入频道 */
  1361. ERR_CAMERA_AUTH_FAIL = 17039621,
  1362. /** 采集过程中出现异常,Mac、Winodows电脑相机采集灯熄灭,设备被强制中断。建议重新加入频道或者重启App */
  1363. ERR_CAMERA_INTERRUPT = 17039622,
  1364. /** 无可用的视频采集设备,检查是否接入了可用的摄像头,并检查系统设置中,该设备是否被禁用 */
  1365. ERR_CAMERA_NOT_AVAILABLE = 17039623,
  1366. /** 渲染设备初始化失败,检查Windows端显卡驱动是否需要升级,移动端手机型号或者Android平板盒子等外设是否支持OpenGL */
  1367. ERR_VIDEO_DISPLAY_OPEN_FAIL = 17039873,
  1368. /** 渲染过程中出现异常,系统异常错误导致渲染引擎报错,重新加入频道或者重启App */
  1369. ERR_VIDEO_DISPLAY_INTERRUPT = 1064992,
  1370. /****************************************************
  1371. * 网络错误码
  1372. ****************************************************/
  1373. /** 媒体通道建立失败,检查网络连接是否正常 */
  1374. ERR_ICE_CONNECTION_CONNECT_FAIL = 17105409,
  1375. /** 媒体通道重连失败,检查网络连接是否正常 */
  1376. ERR_ICE_CONNECTION_RECONNECT_FAI = 17105410,
  1377. /** 媒体通道mobility失败,应用层需要重走入会流程 */
  1378. ERR_ICE_CONNECTION_MOBILITY_FAIL = 17105411,
  1379. /** 信令心跳超时,检查网络连接是否正常 */
  1380. ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT = 16908812,
  1381. /**
  1382. * 低延时互动直播模式相关错误码
  1383. */
  1384. /** 低延时互动直播信令失败 */
  1385. ERR_LATENCY_LIVE_COMMUNICATION_FAILED = 17235971,
  1386. /** 低延时互动直播媒体设置错误 */
  1387. ERR_LATENCY_LIVE_MEIDASETTING_FAILED = 17235972,
  1388. /** 低延时互动直播当前房间没有主播推流 */
  1389. ERR_LATENCY_LIVE_NONE_BROADCASTER = 17235973,
  1390. /** 低延时互动直播错误,应用层需要重新创建新的SDK实例 */
  1391. ERR_LATENCY_LIVE_NEED_RESTART = 17235974,
  1392. /** 低延时互动直播错误,应用层需要稍等一定时间(自定义间隔)重新创建新的SDK实例 */
  1393. ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER = 17235975,
  1394. /** 低延迟互动直播服务不可用或者服务降级,客户端应该选择其它方式拉超大方会流,即不从cdn sfu拉流 */
  1395. ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE = 17235976,
  1396. /** 低延迟互动直播网络中断错误,销毁当前sdk实例重新创建sdk后重新走订阅流程 */
  1397. ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION = 17235977,
  1398. /****************************************************
  1399. * 推流相关错误码
  1400. ****************************************************/
  1401. /** 推流无效 */
  1402. ERR_SDK_PUBLISH_INVAILD = 16974597,
  1403. /** 未进入频道推流失败 */
  1404. ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL = 16843782,
  1405. /** 推送音频流失败 */
  1406. ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED = 16843856,
  1407. /** 推送视频流失败 */
  1408. ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED = 16843857,
  1409. /** 推送小流失败 */
  1410. ERR_SDK_PUBLISH_DUAL_STREAM_FAILED = 16843858,
  1411. /** 推送屏幕共享失败 */
  1412. ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED = 16843859,
  1413. /** 屏幕共享配置错误 */
  1414. ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR = 16843860,
  1415. /****************************************************
  1416. * 订阅相关错误码
  1417. ****************************************************/
  1418. /** 订阅无效 */
  1419. ERR_SDK_SUBSCRIBE_INVAILD = 16974852,
  1420. /** 未进入频道订阅错误 */
  1421. ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL = 16844112,
  1422. /** 订阅音频流失败 */
  1423. ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED = 16844113,
  1424. /** 订阅视频流失败 */
  1425. ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED = 16844114,
  1426. /** 订阅小流失败 */
  1427. ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED = 16844115,
  1428. /** 订阅屏幕共享失败 */
  1429. ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED = 16844116,
  1430. /** 订阅 DataChannel 失败 */
  1431. ERR_SDK_SUBSCRIBE_DATA_FAILED = 16844117,
  1432. /** 订阅 DataChannel 过程中报错 */
  1433. ERR_SDK_SUBSCRIBE_DATA_ERROR = 16844118,
  1434. /****************************************************
  1435. * 其他错误码
  1436. ****************************************************/
  1437. /** SDK状态错误,建议销毁SDK重新创建实例。 */
  1438. ERR_SDK_INVALID_STATE = 16974340,
  1439. /** 参数不匹配 */
  1440. ERR_INVALID_ARGUMENTS = 16974083,
  1441. /** Session已经被移除,建议销毁实例之后重新创建实例并加入频道。 */
  1442. ERR_SESSION_REMOVED = 33620229,
  1443. /** 互动模式下设置角色错误 */
  1444. ERR_SDK_UPDATE_ROLE_CHANNEL = 16908801,
  1445. /** SDK内部错误 */
  1446. ERR_INNER = -1,
  1447. /************************************************************************************/
  1448. /******************************** 旁路直播错误码 start ********************************/
  1449. /************************************************************************************/
  1450. /**
  1451. * MPU任务发布成功
  1452. */
  1453. ERR_SDK_MPU_TASK_PUBLISH_OK = 0,
  1454. /**
  1455. * MPU任务流未找到
  1456. */
  1457. ERR_SDK_MPU_TASK_STREAM_NOT_FOUND = 17825793,
  1458. /**
  1459. * MPU任务流已存在
  1460. */
  1461. ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST = 17825794,
  1462. /**
  1463. * MPU任务无效参数
  1464. */
  1465. ERR_SDK_MPU_TASK_INVALID_PARAM = 17825795,
  1466. /**
  1467. * MPU任务内部错误
  1468. */
  1469. ERR_SDK_MPU_TASK_INTERNAL_ERROR = 17825796,
  1470. /**
  1471. * MPU任务rtmp服务错误
  1472. */
  1473. ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR = 17825797,
  1474. /**
  1475. * MPU任务rtmp流地址错误
  1476. */
  1477. ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR = 17825798,
  1478. /**
  1479. * MPU任务发布超时
  1480. */
  1481. ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT = 17825799,
  1482. /**
  1483. * MPU任务发布成功
  1484. */
  1485. ERR_SDK_MPU_TASK_NOT_AUTHORIZED = 17825800,
  1486. /************************************************************************************/
  1487. /******************************** 旁路直播错误码 end ********************************/
  1488. /************************************************************************************/
  1489. /************************************************************************************/
  1490. /******************************** 跨频道转推错误码 start ******************************/
  1491. /************************************************************************************/
  1492. /**
  1493. * 检测到本地状态不对,没入会,角色错误,频道模式错误
  1494. */
  1495. ERR_SDK_CHANNEL_RELAY_STATE_ERROR = 18874369,
  1496. /**
  1497. * 服务端返回436,源通道模式不匹配
  1498. */
  1499. ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW = 18874370,
  1500. /**
  1501. * 服务端返回437,目标通道不存在或者模式不匹配
  1502. */
  1503. ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED = 18874371,
  1504. /**
  1505. * 服务端返回438,token无效
  1506. */
  1507. ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID = 18874372,
  1508. /**
  1509. * 服务端返651,session不是主播
  1510. */
  1511. ERR_SDK_CHANNEL_RELAY_ROLE_ERROR = 18874373,
  1512. /**
  1513. * 服务端400,参数错误
  1514. */
  1515. ERR_SDK_CHANNEL_RELAY_INVALID_PARAM = 18874374,
  1516. /**
  1517. * 服务端返回440,不能转推到本频道
  1518. */
  1519. ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR = 18874375
  1520. }
  1521. declare class AliRtcLiveTranscoding {
  1522. authInfo?: AliRtcAuthInfo;
  1523. private slsReporter;
  1524. constructor(slsReporter: SLSReporter);
  1525. private doRequest;
  1526. setAuthInfo(authInfo: AliRtcAuthInfo): void;
  1527. clear(): void;
  1528. startPublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
  1529. startPublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
  1530. updatePublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
  1531. updatePublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
  1532. stopPublishLiveStream(streamUrl: string): Promise<any>;
  1533. stopPublishLiveStreamWithTaskId(taskId: string): Promise<any>;
  1534. refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
  1535. }
  1536. export declare enum AliRtcLiveTranscodingAudioSampleRate {
  1537. LiveTranscoding_HZ_48000 = 48000,
  1538. LiveTranscoding_HZ_44100 = 44100,
  1539. LiveTranscoding_HZ_32000 = 32000,
  1540. LiveTranscoding_HZ_16000 = 16000,
  1541. LiveTranscoding_HZ_8000 = 8000
  1542. }
  1543. export declare enum AliRtcLiveTranscodingCropMode {
  1544. /*! 缩放模式 */
  1545. LiveTranscodingOrigin = 0,
  1546. /*! 剪裁 */
  1547. LiveTranscodingCrop = 1,
  1548. /*! 填充 */
  1549. LiveTranscodingFill = 2
  1550. }
  1551. export declare class AliRtcLiveTranscodingEncodeParam {
  1552. videoWidth: number;
  1553. videoHeight: number;
  1554. videoFramerate: number;
  1555. videoBitrate: number;
  1556. videoGop: number;
  1557. audioSamplerate: AliRtcLiveTranscodingAudioSampleRate;
  1558. audioBitrate: number;
  1559. audioChannels: number;
  1560. constructor(videoWidth: number, videoHeight: number, videoFramerate?: number, videoBitrate?: number, videoGop?: number, audioSamplerate?: AliRtcLiveTranscodingAudioSampleRate, audioBitrate?: number, audioChannels?: number);
  1561. }
  1562. export declare enum AliRtcLiveTranscodingErrorCode {
  1563. LiveTranscodingErrorPublishOk = 0,
  1564. LiveTranscodingErrorStreamNotFound = 17825793,
  1565. LiveTranscodingErrorStreamAlreadyExist = 17825794,
  1566. LiveTranscodingErrorInvalidParam = 17825795,
  1567. LiveTranscodingErrorInternalError = 17825796,
  1568. LiveTranscodingErrorRtmpServerError = 17825797,
  1569. LiveTranscodingErrorRtmpStreamUrlError = 17825798,
  1570. LiveTranscodingErrorPublishTimeout = 17825799,
  1571. LiveTranscodingErrorNotAuthorized = 17825800
  1572. }
  1573. export declare enum AliRtcLiveTranscodingFontType {
  1574. NOTO_SERIF_CJKSC_REGULAR = 0,
  1575. ALIBABA_PUHUITI_REGULAR = 1,
  1576. ALIBABA_PUHUITI_BOLD = 2,
  1577. ALIBABA_PUHUITI_Heavy = 3,
  1578. ALIBABA_PUHUITI_LIGHT = 4,
  1579. ALIBABA_PUHUITI_MEDIUM = 5
  1580. }
  1581. export declare enum AliRtcLiveTranscodingMediaProcessMode {
  1582. /*! 通用模式 */
  1583. LiveTranscodingNormal = 0,
  1584. /*! 虚拟背景模式 */
  1585. LiveTranscodingVirtualBackground = 1
  1586. }
  1587. export declare enum AliRtcLiveTranscodingMixMode {
  1588. /*! 单路模式 */
  1589. LiveTranscodingSingle = 0,
  1590. /*! 混流模式 */
  1591. LiveTranscodingMix = 1
  1592. }
  1593. export declare class AliRtcLiveTranscodingMixParam {
  1594. taskProfile: AliRtcLiveTranscodingTaskProfile;
  1595. encodeParam?: AliRtcLiveTranscodingEncodeParam;
  1596. users: AliRtcTranscodingUser[];
  1597. backgroundColor: number;
  1598. backgrounds: AliRtcTranscodingImage[];
  1599. watermarks: AliRtcTranscodingImage[];
  1600. clockWidgets: AliRtcTranscodingClockWidget[];
  1601. cropMode?: AliRtcLiveTranscodingCropMode;
  1602. mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode;
  1603. constructor(taskProfile: AliRtcLiveTranscodingTaskProfile);
  1604. }
  1605. export declare class AliRtcLiveTranscodingParam {
  1606. /*! 旁路模式 */
  1607. mixMode: AliRtcLiveTranscodingMixMode;
  1608. /*! 路模式单路参数 */
  1609. singleParam?: AliRtcLiveTranscodingSingleParam;
  1610. /*! 旁路模式混流参数 */
  1611. mixParam?: AliRtcLiveTranscodingMixParam;
  1612. constructor(mixMode?: AliRtcLiveTranscodingMixMode, singleParam?: AliRtcLiveTranscodingSingleParam, mixParam?: AliRtcLiveTranscodingMixParam);
  1613. toJson(type: MPU_TASK_TRANSACTION_TYPE, authInfo: AliRtcAuthInfo, taskId: string, streamUrl?: string, messageId?: string): {
  1614. [key: string]: any;
  1615. };
  1616. }
  1617. export declare enum AliRtcLiveTranscodingSegmentType {
  1618. /*! 无人像分割 */
  1619. LiveTranscodingNoBody = 0,
  1620. /*! 人像分割 */
  1621. LiveTranscodingBody = 1
  1622. }
  1623. export declare class AliRtcLiveTranscodingSingleParam {
  1624. userId?: string;
  1625. streamType?: AliRtcLiveTranscodingStreamType;
  1626. sourceType?: AliRtcLiveTranscodingSourceType;
  1627. constructor(uid?: string, streamType?: AliRtcLiveTranscodingStreamType, sourceType?: AliRtcLiveTranscodingSourceType);
  1628. }
  1629. export declare enum AliRtcLiveTranscodingSourceType {
  1630. /*! 相机流 */
  1631. LiveTranscodingCamera = 0,
  1632. /*! 屏幕流 */
  1633. LiveTranscodingShareScreen = 1
  1634. }
  1635. export declare enum AliRtcLiveTranscodingState {
  1636. LiveTranscodingState_IDLE = 0,
  1637. LiveTranscodingState_CONNNECT = 1,
  1638. LiveTranscodingState_RUNNING = 2,
  1639. LiveTranscodingState_RECOVERING = 3,
  1640. LiveTranscodingState_FAILURE = 4,
  1641. LiveTranscodingState_END = 5
  1642. }
  1643. export declare enum AliRtcLiveTranscodingStreamType {
  1644. /*! 原始流 */
  1645. LiveTranscodingOrigin = 0,
  1646. /*! 音频 */
  1647. LiveTranscodingAudio = 1,
  1648. /*! 视频 */
  1649. LiveTranscodingVideo = 2
  1650. }
  1651. export declare enum AliRtcLiveTranscodingTaskProfile {
  1652. LiveTranscoding_Profile_1IN_1080P = 0,
  1653. LiveTranscoding_Profile_1IN_720P = 1,
  1654. LiveTranscoding_Profile_1IN_360P = 2,
  1655. LiveTranscoding_Profile_2IN_1080P = 3,
  1656. LiveTranscoding_Profile_2IN_720P = 4,
  1657. LiveTranscoding_Profile_2IN_360P = 5,
  1658. LiveTranscoding_Profile_4IN_1080P = 6,
  1659. LiveTranscoding_Profile_4IN_720P = 7,
  1660. LiveTranscoding_Profile_4IN_360P = 8,
  1661. LiveTranscoding_Profile_9IN_1080P = 9,
  1662. LiveTranscoding_Profile_9IN_720P = 10,
  1663. LiveTranscoding_Profile_9IN_360P = 11,
  1664. LiveTranscoding_Profile_12IN_1080P = 12,
  1665. LiveTranscoding_Profile_12IN_720P = 13,
  1666. LiveTranscoding_Profile_12IN_360P = 14,
  1667. LiveTranscoding_Profile_16IN_1080P = 15,
  1668. LiveTranscoding_Profile_16IN_720P = 16,
  1669. LiveTranscoding_Profile_16IN_360P = 17,
  1670. LiveTranscoding_Profile_Mixed = 9999
  1671. }
  1672. declare interface AliRtcLocalAudioStats {
  1673. track: AliRtcAudioTrack;
  1674. stats: any;
  1675. }
  1676. export declare class AliRtcLocalStreamInfo extends default_2<AliRtcLocalStreamListener> {
  1677. type: AliRtcRawDataStreamType;
  1678. originVideoTrack?: MediaStreamTrack;
  1679. videoSource?: VideoStreamSource;
  1680. private _videoMuted;
  1681. originAudioTrack?: MediaStreamTrack;
  1682. audioSource?: AudioStreamSource;
  1683. private _audioMuted;
  1684. private _targetVideoTrack?;
  1685. private _targetDualVideoTrack?;
  1686. private _targetAudioTrack?;
  1687. private _publishVideoStream?;
  1688. private _publishDualVideoStream?;
  1689. private _publishAudioStream?;
  1690. private _previewStream?;
  1691. plugins: AliRtcPlugin[];
  1692. private _profileManager?;
  1693. cameraVideoConstraints?: IVideoConstraints;
  1694. micAudioConstraints?: IAudioConstraints;
  1695. private get profileManager();
  1696. get audioProfile(): AudioProfileKey | undefined;
  1697. constructor(type: AliRtcRawDataStreamType);
  1698. private onVideoTrackEnded;
  1699. private onAudioTrackEnded;
  1700. updateSource(newStream: LocalStream, newVideoSource?: VideoStreamSource, newAudioSource?: AudioStreamSource): Promise<void>;
  1701. get currentProfile(): string | undefined;
  1702. get currentVideoTrack(): MediaStreamTrack | undefined;
  1703. get currentDualVideoTrack(): MediaStreamTrack | undefined;
  1704. get publishVideoStream(): LocalStream | undefined;
  1705. get publishDualVideoStream(): LocalStream | undefined;
  1706. get currentAudioTrack(): MediaStreamTrack | undefined;
  1707. get publishAudioStream(): LocalStream | undefined;
  1708. get previewStream(): LocalStream | undefined;
  1709. /**
  1710. * 更新 VideoTrack
  1711. * @param videoTrack
  1712. */
  1713. updateVideoTrack(videoTrack?: MediaStreamTrack, force?: boolean): Promise<void>;
  1714. /**
  1715. * 更新 DualVideoTrack
  1716. * @param videoTrack
  1717. * @param force
  1718. */
  1719. updateDualVideoTrack(videoTrack?: MediaStreamTrack, force?: boolean): Promise<void>;
  1720. /**
  1721. * 更新 AudioTrack
  1722. * @param audioTrack
  1723. */
  1724. updateAudioTrack(audioTrack?: MediaStreamTrack, force?: boolean): Promise<void>;
  1725. /**
  1726. * 设置音频流静音
  1727. * @param muted
  1728. */
  1729. setAudioMuted(muted: boolean): void;
  1730. get isAudioMuted(): boolean;
  1731. /**
  1732. * 设置视频流静音
  1733. * @param muted
  1734. */
  1735. setVideoMuted(muted: boolean): void;
  1736. get isVideoMuted(): boolean;
  1737. process(localStreamInfos: AliRtcLocalStreamInfo[]): Promise<void>;
  1738. /**
  1739. * 停止视频流
  1740. */
  1741. stopVideo(): void;
  1742. /**
  1743. * 停止音频流
  1744. */
  1745. stopAudio(): void;
  1746. /**
  1747. * 停止视频流和音频流
  1748. */
  1749. stop(): void;
  1750. /**
  1751. * 应该在执行完 plugin 后调用
  1752. * @param profileName
  1753. * @param profileValue
  1754. */
  1755. updateVideoProfile(profileName?: string, profileValue?: Partial<IProfile>, skipConstraints?: boolean): Promise<void>;
  1756. get videoProfile(): string | undefined;
  1757. setVideoContentHint(hint?: string): void;
  1758. /**
  1759. * 应该在执行完 plugin 后调用
  1760. * @param profileName
  1761. */
  1762. updateAudioProfile(profileKey: AudioProfileKey): Promise<void>;
  1763. /**
  1764. * 复制视频 profile 到指定 LocalStream
  1765. * @param publishStream
  1766. */
  1767. cloneVideoProfile(publishStream: LocalStream): Promise<void>;
  1768. addPlugin(plugin: AliRtcPlugin): void;
  1769. removePlugin(plugin: AliRtcPlugin): boolean;
  1770. }
  1771. declare interface AliRtcLocalStreamListener {
  1772. videotrackended: () => void;
  1773. audiotrackended: () => void;
  1774. }
  1775. declare interface AliRtcLocalVideoStats {
  1776. track: AliRtcVideoTrack;
  1777. streamType?: AliRtcVideoStreamType;
  1778. stats: any;
  1779. }
  1780. declare type AliRtcLocalView = string | HTMLVideoElement | string[] | HTMLVideoElement[] | null;
  1781. export declare enum AliRtcLogLevel {
  1782. DEBUG = 0,
  1783. INFO = 1,
  1784. API = 2,
  1785. WARNING = 3,
  1786. ERROR = 4,
  1787. NONE = 5
  1788. }
  1789. /**
  1790. * @brief OnBye类型枚举
  1791. */
  1792. declare enum AliRtcOnByeType {
  1793. /** 当前user被踢出channel */
  1794. AliRtcOnByeBeKickedOut = 1,
  1795. /** channel已结束,需要离开会议 */
  1796. AliRtcOnByeChannelTerminated = 2,
  1797. /** 相同userID在其他设备joinChannel,当前设备被下线 */
  1798. AliRtcOnByeUserReplaced = 3
  1799. }
  1800. export declare abstract class AliRtcPlugin extends default_2<AliRtcPluginListener> {
  1801. name: string;
  1802. options: any;
  1803. type: AliRtcPluginType;
  1804. streamType: AliRtcRawDataStreamType;
  1805. trackType: AliRtcPluginTrackType;
  1806. zIndex: number;
  1807. private _isEnable;
  1808. lastInputAudioTrack?: MediaStreamTrack;
  1809. lastOutputAudioTrack?: MediaStreamTrack;
  1810. lastInputVideoTrack?: MediaStreamTrack;
  1811. lastOutputVideoTrack?: MediaStreamTrack;
  1812. private _hasCleared;
  1813. constructor(name: string, streamType?: AliRtcRawDataStreamType, trackType?: AliRtcPluginTrackType);
  1814. get initOptions(): {};
  1815. getOptions(): any;
  1816. abstract setOptions(options: any): void;
  1817. abstract isSupported(version: string): boolean;
  1818. init(): Promise<void>;
  1819. enable(): void;
  1820. disable(): void;
  1821. get isEnable(): boolean;
  1822. protected audioUpdated(streamInfo: AliRtcLocalStreamInfo): boolean;
  1823. protected videoUpdated(streamInfo: AliRtcLocalStreamInfo): boolean;
  1824. execute(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): Promise<void>;
  1825. abstract shouldUpdate(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): boolean;
  1826. abstract process(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): Promise<void>;
  1827. clear(_streamInfo?: AliRtcLocalStreamInfo): void;
  1828. }
  1829. declare interface AliRtcPluginListener {
  1830. enabled: () => void;
  1831. disabled: () => void;
  1832. updated: () => void;
  1833. ready: () => void;
  1834. overload: (info: any) => void;
  1835. error: (error: any) => void;
  1836. unsupported: () => void;
  1837. }
  1838. export declare enum AliRtcPluginTrackType {
  1839. AUDIO = 0,
  1840. VIDEO = 1,
  1841. BOTH = 2
  1842. }
  1843. export declare enum AliRtcPluginType {
  1844. PRE_PROCESSOR = 0,
  1845. POST_PROCESSOR = 1
  1846. }
  1847. export declare enum AliRtcPublishState {
  1848. /** 0: SDK初始推流状态 */
  1849. AliRtcStatePublishIdle = 0,
  1850. /** 1: 未推流状态,可能是因为:
  1851. * - 已设置停止推送媒体流
  1852. * - 推送媒体流失败
  1853. */
  1854. AliRtcStateNoPublish = 1,
  1855. /** 2: 推流链接建立过程中 */
  1856. AliRtcStatePublishing = 2,
  1857. /** 3: 推流成功 */
  1858. AliRtcStatePublished = 3
  1859. }
  1860. export declare enum AliRtcRawDataStreamType {
  1861. /** 相机流 */
  1862. AliRtcSdkStreamTypeCapture = 0,
  1863. /** 屏幕共享流 */
  1864. AliRtcSdkStreamTypeScreen = 1
  1865. }
  1866. export declare type AliRtcRefreshAuthInfo = Pick<AliRtcAuthInfo, 'userId' | 'nonce' | 'token' | 'timestamp' | 'role'>;
  1867. declare interface AliRtcRemoteAudioStats {
  1868. uid: string;
  1869. track: AliRtcAudioTrack;
  1870. stats: any;
  1871. }
  1872. export declare class AliRtcRemoteUserInfo {
  1873. private remoteUser;
  1874. constructor(remoteUser: RemoteUser);
  1875. get userId(): string;
  1876. get displayName(): string;
  1877. get isMuteAudioPlaying(): boolean;
  1878. get hasAudio(): boolean;
  1879. get hasCamera(): boolean;
  1880. get hasCameraLarge(): boolean;
  1881. get hasCameraSmall(): boolean;
  1882. get hasScreenShare(): boolean;
  1883. get isAudioSubscribing(): boolean;
  1884. get isVideoSubscribing(): boolean;
  1885. get isVideoLargeSubscribing(): boolean;
  1886. get isVideoSmallSubscribing(): boolean;
  1887. get isScreenSubscribing(): boolean;
  1888. get audioElement(): HTMLAudioElement | undefined;
  1889. }
  1890. declare interface AliRtcRemoteVideoStats {
  1891. uid: string;
  1892. track: AliRtcVideoTrack;
  1893. streamType?: AliRtcVideoStreamType;
  1894. stats: any;
  1895. }
  1896. declare interface AliRtcScreenShareConfiguration {
  1897. frameRate?: number;
  1898. bitrate?: number;
  1899. }
  1900. declare interface AliRtcScreenShareStartConfig {
  1901. audio?: boolean;
  1902. videoTrack?: MediaStreamVideoTrack;
  1903. audioTrack?: MediaStreamAudioTrack;
  1904. }
  1905. export declare enum AliRtcSdkChannelProfile {
  1906. /** 普通通信模式 */
  1907. AliRtcSdkCommunication = "communication",
  1908. /** 直播模式(大方会模式) */
  1909. AliRtcSdkInteractiveLive = "interactive_live",
  1910. /** 低延迟互动直播模式 */
  1911. AliRtcSdkInteractiveWithLowLatencyLive = "cdn_live"
  1912. }
  1913. export declare enum AliRtcSdkClientRole {
  1914. /** 互动角色 */
  1915. AliRtcSdkInteractive = "interactive",
  1916. /** 观众角色 */
  1917. AliRtcSdkLive = "live"
  1918. }
  1919. /** 角色鉴权 主播pub|观众sub|转推流鉴权(跨房间转推中使用)relay */
  1920. declare type AliRtcSdkTokenRole = 'pub' | 'sub' | 'relay';
  1921. export declare enum AliRtcSubscribeState {
  1922. /** 初始状态 */
  1923. AliRtcStateSubscribeIdle = 0,
  1924. /** 未订阅 */
  1925. AliRtcStateNoSubscribe = 1,
  1926. /** 订阅中 */
  1927. AliRtcStateSubscribing = 2,
  1928. /** 已订阅 */
  1929. AliRtcStateSubscribed = 3
  1930. }
  1931. export declare class AliRtcTranscodingClockWidget {
  1932. x: number;
  1933. y: number;
  1934. fontSize: number;
  1935. zOrder: number;
  1936. fontColor: number;
  1937. fontType: AliRtcLiveTranscodingFontType;
  1938. constructor(x: number, y: number, fontSize: number);
  1939. constructor(x: number, y: number, fontSize: number, zOrder: number);
  1940. constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
  1941. constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
  1942. toJson(videoWidth: number, videoHeight: number): {
  1943. x: number;
  1944. y: number;
  1945. fonttype: AliRtcLiveTranscodingFontType;
  1946. fontsize: number;
  1947. fontcolor: number;
  1948. zorder: number;
  1949. };
  1950. }
  1951. export declare class AliRtcTranscodingImage {
  1952. static DisplayType: typeof DisplayType;
  1953. url: string;
  1954. x: number;
  1955. y: number;
  1956. width: number;
  1957. height: number;
  1958. alpha: number;
  1959. display: DisplayType;
  1960. zOrder: number;
  1961. constructor(url: string, x: number, y: number, width: number, height: number);
  1962. constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number);
  1963. constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number);
  1964. constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number, display: DisplayType);
  1965. toJson(videoWidth: number, videoHeight: number): {
  1966. url: string;
  1967. alpha: number;
  1968. display: DisplayType;
  1969. x: number;
  1970. y: number;
  1971. width: number;
  1972. height: number;
  1973. zorder: number;
  1974. };
  1975. }
  1976. export declare class AliRtcTranscodingText {
  1977. text: string;
  1978. x: number;
  1979. y: number;
  1980. fontSize: number;
  1981. zOrder: number;
  1982. fontColor: number;
  1983. fontType: AliRtcLiveTranscodingFontType;
  1984. constructor(text: string, x: number, y: number, fontSize: number);
  1985. constructor(text: string, x: number, y: number, fontSize: number, zOrder: number);
  1986. constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
  1987. constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
  1988. toJson(videoWidth: number, videoHeight: number): {
  1989. text: string;
  1990. x: number;
  1991. y: number;
  1992. fonttype: AliRtcLiveTranscodingFontType;
  1993. fontsize: number;
  1994. fontcolor: number;
  1995. zorder: number;
  1996. };
  1997. }
  1998. export declare class AliRtcTranscodingUser {
  1999. userId: string;
  2000. x: number;
  2001. y: number;
  2002. width: number;
  2003. height: number;
  2004. zOrder?: number;
  2005. sourceType?: AliRtcLiveTranscodingSourceType;
  2006. segmentType: AliRtcLiveTranscodingSegmentType;
  2007. images: AliRtcTranscodingImage[];
  2008. texts: AliRtcTranscodingText[];
  2009. constructor(userId: string, x: number, y: number, width: number, height: number);
  2010. constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number);
  2011. constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number, sourceType: AliRtcLiveTranscodingSourceType);
  2012. toJson(index: number, videoWidth: number, videoHeight: number, mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode): {
  2013. [key: string]: any;
  2014. };
  2015. }
  2016. export declare enum AliRtcTrascodingPublishTaskStatus {
  2017. /*! 任务开始 */
  2018. TrascodingPublishTaskStatusStart = 0,
  2019. /*! 任务更新 */
  2020. TrascodingPublishTaskStatusUpdate = 1,
  2021. /*! 任务已停止 */
  2022. TrascodingPublishTaskStatusStop = 2
  2023. }
  2024. declare enum AliRtcUserOfflineReason {
  2025. /** 用户主动离开 */
  2026. AliRtcUserOfflineQuit = 0,
  2027. /** 因过长时间收不到对方数据包,超时掉线 */
  2028. AliRtcUserOfflineDropped = 1,
  2029. /** 用户身份从主播切换为观众时触发 */
  2030. AliRtcUserOfflineBecomeAudience = 2
  2031. }
  2032. export declare enum AliRtcVideoStreamType {
  2033. /** 无,在OnSubscribeStreamTypeChanged回调表示当前未订阅 */
  2034. AliRtcVideoStreamTypeNone = 0,
  2035. /** 高码率,高分辨率流(大流) */
  2036. AliRtcVideoStreamTypeHigh = 1,
  2037. /** 低码率,低分辨率流(小流) */
  2038. AliRtcVideoStreamTypeLow = 2
  2039. }
  2040. export declare enum AliRtcVideoTrack {
  2041. /** 无视频流 **/
  2042. AliRtcVideoTrackNo = 0,
  2043. /** 相机流 **/
  2044. AliRtcVideoTrackCamera = 1,
  2045. /** 屏幕共享流 **/
  2046. AliRtcVideoTrackScreen = 2,
  2047. /** 相机流和屏幕共享流 **/
  2048. AliRtcVideoTrackBoth = 3
  2049. }
  2050. declare interface AliRtcVideoTrackConfig {
  2051. userId?: string;
  2052. streamType: AliRtcRawDataStreamType;
  2053. }
  2054. declare interface AliRtcWebTrackConfig {
  2055. biz: string;
  2056. extraParams?: string;
  2057. }
  2058. declare class AudioLevelMonitor extends default_2<AudioLevelMonitorListener> {
  2059. private audioContext;
  2060. private stream;
  2061. private sourceNode?;
  2062. private analyser?;
  2063. constructor();
  2064. getLevel(): number;
  2065. /**
  2066. * 开启监听 audio level 的变化
  2067. *
  2068. * @param {MediaStreamTrack} track 音频轨
  2069. * @param {number} [interval=1000] 检测间隔,单位毫秒,默认 1000ms
  2070. */
  2071. start(track: MediaStreamTrack, interval?: number): void;
  2072. stop(): void;
  2073. dispose(): void;
  2074. }
  2075. declare interface AudioLevelMonitorListener {
  2076. audioLevel: (level: number) => void;
  2077. }
  2078. declare interface AudioMixerPluginOptions {
  2079. audio?: number;
  2080. screen?: number;
  2081. }
  2082. /**
  2083. * ------------------ 模式 ----- 采样率 ----- 声道 ----- 码率(kbps) -----
  2084. *
  2085. * standard: 标准音质 48000 单声道 64
  2086. *
  2087. * high: 高音质 48000 单声道 128
  2088. *
  2089. * standard-stereo: 立体声音质 48000 双声道 80
  2090. *
  2091. * high-stereo: 立体声高音质 48000 双声道 192
  2092. */
  2093. declare type AudioProfileKey = 'standard' | 'high' | 'standard-stereo' | 'high-stereo';
  2094. declare enum AudioStreamSource {
  2095. Microphone = 0,
  2096. Screen = 1,
  2097. Mixed = 2
  2098. }
  2099. declare class BizControl extends default_2<BizControlListener> {
  2100. /**
  2101. * @ignore
  2102. */
  2103. static logName: string;
  2104. protected self: LocalUser;
  2105. protected userMap: RemoteUserMap;
  2106. private usersViewMap;
  2107. rtsManager: RtsManager;
  2108. protected localStreamManager: LocalStreamManager;
  2109. protected authInfo?: AliRtcAuthInfo;
  2110. protected signalingManager: SignalingManager;
  2111. pluginManager: PluginManager;
  2112. private audioMixerPlugin?;
  2113. private dualVideoPlugin?;
  2114. private blankAudioPlugin?;
  2115. protected slsReporter: SLSReporter;
  2116. private statsMonitorId?;
  2117. private autoSubAudio;
  2118. private autoSubVideo;
  2119. private autoSubScreen;
  2120. private wantSubAudio;
  2121. private wantSubVideo;
  2122. private wantSubScreen;
  2123. private defaultStreamType;
  2124. private audioMuted;
  2125. private playoutVolume;
  2126. private refreshUrlTimer?;
  2127. private audioVolumeIndicationInterval;
  2128. private indicationTimer;
  2129. private parameter;
  2130. constructor(config: BizControlConfig);
  2131. private addSignalingManagerListener;
  2132. isAutoSubAudio(): boolean;
  2133. setAutoSubAudio(value: boolean): void;
  2134. isAutoSubVideo(): boolean;
  2135. setAutoSubVideo(value: boolean): void;
  2136. isAutoSubScreen(): boolean;
  2137. setAutoSubScreen(value: boolean): void;
  2138. isWantSubAudio(): boolean;
  2139. setWantSubAudio(value: boolean): void;
  2140. isWantSubVideo(): boolean;
  2141. setWantSubVideo(value: boolean): void;
  2142. isWantSubScreen(): boolean;
  2143. setWantSubScreen(value: boolean): void;
  2144. setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
  2145. setRemoteUserVideoStreamType(userId: string, type: AliRtcVideoStreamType): void;
  2146. setAudioMuted(mute: boolean): void;
  2147. setLocalViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
  2148. setRemoteViewConfig(uid: string, view: AliRtcLocalView, track: AliRtcVideoTrack): void;
  2149. get channel(): string | undefined;
  2150. get userId(): string | undefined;
  2151. get remoteUsers(): RemoteUser[];
  2152. /**
  2153. * 获取推流对象,只能是自己
  2154. */
  2155. get publisher(): LocalUser | undefined;
  2156. get isSubscribing(): boolean;
  2157. /**
  2158. * 处理远端用户推流状态变化
  2159. * @param {string} userId
  2160. * @param {string} displayname
  2161. * @param {string} callid
  2162. * @param {string} pullStreamUrl
  2163. * @param {TrackInfo[]} tracks
  2164. * @returns {void}
  2165. */
  2166. onRemotePublishStateChange(publishInfo: PublishUser): void;
  2167. /** 定期更新所有人的推拉流地址,便于重连
  2168. * @param pushStreamUrl 已有的推流地址,根据地址中的过期时间来设置定时器
  2169. * @private
  2170. */
  2171. private setTimeoutToUpdateAllStreamUrls;
  2172. /**
  2173. * 登陆成功后初始化用户管理,创建自己
  2174. * @param {AliRtcAuthInfo} authInfo
  2175. * @param {JoinResult} data
  2176. * @returns {Promise<void>}
  2177. */
  2178. init(authInfo: AliRtcAuthInfo, data: JoinResult): void;
  2179. leave(): Promise<void>;
  2180. /**
  2181. * 离会后清除所有数据
  2182. * @returns {Promise<void>}
  2183. */
  2184. clear(): Promise<void>;
  2185. private startStatsMonitor;
  2186. private stopStatsMonitor;
  2187. /**
  2188. * 添加远端用户
  2189. * @param {string} userId
  2190. * @param {string} displayName
  2191. * @returns {void}
  2192. */
  2193. addUser(userId: string, displayName: string, reason: SubscribeReason): RemoteUser;
  2194. /**
  2195. * 执行添加远端用户
  2196. * @param {string} userId
  2197. * @param {string} displayName
  2198. * @returns {RemoteUser}
  2199. */
  2200. private executeAddUser;
  2201. /**
  2202. * 远端用户设备状态变化
  2203. * @param {DeviceStatusChangeType} event
  2204. * @param {string} userId
  2205. */
  2206. private onRemoteDeviceStatusChange;
  2207. /**
  2208. * 远端流数据采集上报
  2209. * @param {any} stat
  2210. */
  2211. private onRemoteStatReport;
  2212. /**
  2213. * rts 单 PC 订阅超限
  2214. */
  2215. private onSubscribeExceeds;
  2216. /**
  2217. * 移除远端用户
  2218. * @param {LeaveInfo} user
  2219. * @returns {Promise<void>}
  2220. */
  2221. removeLeftUser(user: LeaveInfo): Promise<void>;
  2222. /**
  2223. * 更新远端用户数据
  2224. * @param {JoinInfo[]} users
  2225. * @returns {{joinList: JoinInfo[], leaveList: LeaveInfo[], presentList: JoinInfo[]}}
  2226. */
  2227. updateUsers(users: JoinInfo[]): {
  2228. joinList: JoinInfo[];
  2229. leaveList: LeaveInfo[];
  2230. presentList: JoinInfo[];
  2231. };
  2232. /**
  2233. * 根据 userId 获取 RemoteUser
  2234. * @param {string} userId
  2235. * @returns {RemoteUser | undefined}
  2236. */
  2237. getRemoteUser(userId: string): RemoteUser | undefined;
  2238. /**
  2239. * 更新远端用户设备信息
  2240. * @param {RemoteUserStatus} user
  2241. * @returns {boolean} true: 用户状态改变 false: 用户状态没有改变
  2242. */
  2243. updateRemoteUserDeviceStatus(user: RemoteUserStatus): void;
  2244. updateAudioWant(uid: string, sub: boolean): void;
  2245. updateVideoWant(uid: string, sub: boolean): void;
  2246. updateScreenWant(uid: string, sub: boolean): void;
  2247. private stopIndication;
  2248. private startIndication;
  2249. setEnableDualVideoStream(enabled: boolean, options?: AliRtcDualVideoPluginOptions): void;
  2250. setAudioVolume(options: AudioMixerPluginOptions): void;
  2251. enableAudioVolumeIndication(interval: number): void;
  2252. setPlayoutVolume(volume: number): void;
  2253. refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
  2254. setEnableMediaExtensionMsg(enable: boolean): void;
  2255. setAudioRedEnabled(enable: boolean): void;
  2256. setParameter(parameter: string): void;
  2257. getParameter(): string;
  2258. sendDataChannelMessage(message: AliRtcDataChannelMsg): Promise<void>;
  2259. }
  2260. declare interface BizControlConfig {
  2261. slsReporter: SLSReporter;
  2262. signalingManager: SignalingManager;
  2263. }
  2264. declare interface BizControlListener {
  2265. [ClientEventType.RtsSubscribeExceeds]: (userId: string, options?: SubscribeOptions) => void;
  2266. [DeviceStatusChange.Remote]: (event: DeviceStatusChangeType, userId: string) => void;
  2267. [ClientEventType.PullStreamStats]: (userId: string, stat: any, pullStreamUrl: string) => void;
  2268. remoteTrackAvailableChange: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
  2269. audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  2270. videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  2271. screenSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  2272. dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
  2273. userAudioMuted: (uid: string, isMute: boolean) => void;
  2274. userVideoMuted: (uid: string, isMute: boolean) => void;
  2275. userScreenMuted: (userId: string, isMute: boolean) => void;
  2276. audioVolume: (speakers: {
  2277. userId: string;
  2278. volume: number;
  2279. }[]) => void;
  2280. rtcLocalVideoStats: (stats: AliRtcLocalVideoStats[]) => void;
  2281. rtcLocalAudioStats: (stats: AliRtcLocalAudioStats[]) => void;
  2282. rtcRemoteVideoStats: (stats: AliRtcRemoteVideoStats[]) => void;
  2283. rtcRemoteAudioStats: (stats: AliRtcRemoteAudioStats[]) => void;
  2284. rtcStats: (stats: any) => void;
  2285. remoteAudioAutoPlayFail: (uid: string) => void;
  2286. remoteVideoAutoPlayFail: (uid: string, track: AliRtcVideoTrack) => void;
  2287. remoteAudioPlayError: (uid: string, reason?: string) => void;
  2288. remoteVideoPlayError: (uid: string, reason?: string) => void;
  2289. remoteSubscribeError: (error: AliRtcError, uid?: string) => void;
  2290. occurError: (error: AliRtcError, uid?: string) => void;
  2291. remoteDataChannelMessage: (uid: string, message: AliRtcDataChannelMsg) => void;
  2292. }
  2293. declare enum ClientEventType {
  2294. PullStreamStats = "remoteStat",
  2295. RtsSubscribeExceeds = "rtsSubscribeExceeds",
  2296. UserJoined = "userJoined",
  2297. UserLeft = "userLeft",
  2298. Bye = "bye",
  2299. MuteAudio = "muteAudio",
  2300. UnmuteAudio = "unmuteAudio",
  2301. MuteVideo = "muteVideo",
  2302. UnmuteVideo = "unmuteVideo",
  2303. MuteScreen = "muteScreen",
  2304. UnmuteScreen = "unmuteScreen",
  2305. Error = "error"
  2306. }
  2307. declare enum CmdType {
  2308. Add = 0,
  2309. Del = 1,
  2310. Update = 2,
  2311. None = 100
  2312. }
  2313. declare enum CodecType {
  2314. OPUS = "opus",
  2315. H264 = "H264",
  2316. UNKNOWN = ""
  2317. }
  2318. declare enum ConnectionLatencyStage {
  2319. CREATE_ENGINE = "create_engine",
  2320. JOIN = "join",
  2321. WANT_INSERT_PUB_TASK = "wantInsertPubTask",
  2322. INSERT_PUB_TASK = "InsertPubTask",
  2323. HANDLE_PUB_TASK = "HandlePubTask",
  2324. RECV_NOTIFY_PUBLISH = "RecvNotifyPublish",
  2325. INSERT_SUB_TASK = "InsertSubTask",
  2326. HANDLE_SUB_TASK = "HandleSubTask",
  2327. FIRST_REMOTE = "first_remote"
  2328. }
  2329. declare enum ConnectionLatencyStatus {
  2330. START = "start",
  2331. SEND_SIG = "send_sig",
  2332. RECV_RST = "recv_rst",
  2333. END = "end",
  2334. RECEIVED = "received",
  2335. DECODED = "decoded",
  2336. PLAYED = "played"
  2337. }
  2338. /**
  2339. * websocket链接状态
  2340. */
  2341. declare enum CONNECTSTATUS {
  2342. DISCONNECTED = 0,
  2343. CONNECTING = 1,
  2344. CONNECTED = 2
  2345. }
  2346. declare interface DeviceStatus {
  2347. micOpen: boolean;
  2348. micInterrupted: boolean;
  2349. cameraOpen: boolean;
  2350. screenShare: boolean;
  2351. audioDisable: boolean;
  2352. videoDisable: boolean;
  2353. screenDisable: boolean;
  2354. backgroundMode: boolean;
  2355. accompanyPlaying: boolean;
  2356. }
  2357. declare enum DeviceStatusChange {
  2358. Local = "local-device-status-change",
  2359. Remote = "remote-device-status-change"
  2360. }
  2361. declare type DeviceStatusChangeType = ClientEventType.MuteAudio | ClientEventType.UnmuteAudio | ClientEventType.MuteScreen | ClientEventType.UnmuteScreen | ClientEventType.MuteVideo | ClientEventType.UnmuteVideo;
  2362. declare enum DisplayType {
  2363. NOT_DISPLAY = 0,
  2364. ALWAYS = 1,
  2365. WHEN_NO_VIDEO = 2
  2366. }
  2367. declare interface IResponse {
  2368. version: number;
  2369. code: number;
  2370. msgtype: MessageType;
  2371. tid: string;
  2372. isproxy?: boolean;
  2373. }
  2374. declare interface ISendPackage {
  2375. version: number;
  2376. msgtype: MessageType;
  2377. tid: string;
  2378. header: {
  2379. appid: string;
  2380. channelid: string;
  2381. sessionid: string;
  2382. userid: string;
  2383. displayName?: string;
  2384. clientversion?: string;
  2385. platform?: string;
  2386. };
  2387. data: {
  2388. seq: number;
  2389. l1ip?: string;
  2390. status?: string;
  2391. clientrole?: string;
  2392. configure?: {
  2393. clientrole?: AliRtcSdkClientRole;
  2394. channelprofile: AliRtcSdkChannelProfile;
  2395. };
  2396. auth?: SendPackageAuthInfo;
  2397. sessionid?: string;
  2398. pushstreamurl?: string;
  2399. users?: any[];
  2400. };
  2401. }
  2402. /**
  2403. * 服务端通知的远端用户信息
  2404. */
  2405. declare interface JoinInfo {
  2406. displayname: string;
  2407. session: string;
  2408. userid: string;
  2409. callid: string;
  2410. clientrole?: string;
  2411. subscribe?: {
  2412. pullstreamurl: string;
  2413. };
  2414. tracks?: TrackInfo[];
  2415. }
  2416. declare interface JoinResult {
  2417. pushstreamurl: string;
  2418. tid: string;
  2419. users: JoinInfo[];
  2420. timestamp: number;
  2421. }
  2422. declare interface LeaveInfo {
  2423. userid: string;
  2424. leavecode: AliRtcUserOfflineReason;
  2425. reason: string;
  2426. }
  2427. declare class LocalProfileManager {
  2428. private defaultProfile;
  2429. profile?: string;
  2430. profileMap: Map<string, IProfile>;
  2431. audioProfile?: AudioProfileKey;
  2432. contentHint?: string;
  2433. constructor(defaultProfile?: IProfile);
  2434. updateProfile(profileKey: string, profileValue?: Partial<IProfile>): void;
  2435. get videoProfile(): string | undefined;
  2436. updateAudioProfile(profileKey: AudioProfileKey): void;
  2437. setContentHint(videoTrack: MediaStreamTrack | undefined, contentHint?: string): void;
  2438. /**
  2439. * 更新源流 Constraints
  2440. * 更新 PeerConnectiong Sender 相关配置
  2441. * @param stream
  2442. */
  2443. setVideoProfile(originVideoTrack: MediaStreamTrack | undefined, target: LocalStream | undefined, skipConstraints?: boolean): Promise<void>;
  2444. }
  2445. declare type LocalStreamConfig = Omit<_LocalStreamConfig, 'custom'>;
  2446. declare interface _LocalStreamConfig extends IStreamConfig {
  2447. videoProfile?: string;
  2448. screenProfile?: string;
  2449. }
  2450. declare class LocalStreamManager extends default_2<LocalStreamManagerListener> {
  2451. /**
  2452. * @ignore
  2453. */
  2454. static logName: string;
  2455. private pluginManager;
  2456. private slsReporter;
  2457. private publishingCameraVideoStream;
  2458. private publishingScreenVideoStream;
  2459. cameraStreamInfo: AliRtcLocalStreamInfo;
  2460. screenStreamInfo: AliRtcLocalStreamInfo;
  2461. private streamInfos;
  2462. private _audioCaptureDisabled;
  2463. private _cameraCaptureDisabled;
  2464. private _publishLocalAudioStreamEnabled;
  2465. private _publishLocalVideoStreamEnabled;
  2466. private _publishLocalScreenStreamEnabled;
  2467. constructor(pluginManager: PluginManager, slsReporter: SLSReporter);
  2468. get hasCamera(): boolean;
  2469. get audioCaptureDisabled(): boolean;
  2470. set audioCaptureDisabled(closed: boolean);
  2471. get cameraCaptureDisabled(): boolean;
  2472. set cameraCaptureDisabled(closed: boolean);
  2473. setAudioMuted(muted: boolean): void;
  2474. get isAudioMuted(): boolean;
  2475. setCameraMuted(muted: boolean): void;
  2476. get isCameraMuted(): boolean;
  2477. setScreenMuted(muted: boolean): void;
  2478. get isScreenMuted(): boolean;
  2479. get publishLocalAudioStreamEnabled(): boolean;
  2480. set publishLocalAudioStreamEnabled(enable: boolean);
  2481. get publishLocalVideoStreamEnabled(): boolean;
  2482. set publishLocalVideoStreamEnabled(enable: boolean);
  2483. get publishLocalScreenStreamEnabled(): boolean;
  2484. set publishLocalScreenStreamEnabled(enable: boolean);
  2485. updateStreams(): Promise<void>;
  2486. private setAvailableCameraDeviceId;
  2487. private setAvailableMicrophoneDeviceId;
  2488. /**
  2489. * 创建 LocalStream
  2490. * @param {LocalStreamConfig} params 创建 LocalStream 的配置
  2491. * @returns {LocalStream} 当前创建的 LocalStream
  2492. */
  2493. createLocalStream(params: LocalStreamConfig): Promise<LocalStream | undefined>;
  2494. /**
  2495. * 停止推流,底层调用 rts publishStop,不会导致 DC 马上关闭。适合暂时停推的场景
  2496. * @param {StopPublishOptions} options
  2497. * @returns {Promise<PublishStreamInfo>} 如果返回了 audio,则表示需要更新音频流
  2498. */
  2499. stopLocalStream(options: StopPublishOptions): Promise<void>;
  2500. get publishStreams(): PublishStreamInfo;
  2501. createHTTPPublishStream(): Promise<{
  2502. publishStream: LocalStream | undefined;
  2503. videoSmallStream: LocalStream | undefined;
  2504. screenStream: LocalStream | undefined;
  2505. vMsid: string | undefined;
  2506. }>;
  2507. /**
  2508. * 停止所有流
  2509. */
  2510. stop(): void;
  2511. /**
  2512. * 设置摄像头流 profile
  2513. * @param {LocalStream | null} stream
  2514. * @param {string} profileKey
  2515. * @param {IProfile} profile
  2516. */
  2517. setVideoProfile(profileKey?: string, profile?: Partial<IProfile>, skipConstraints?: boolean): Promise<void>;
  2518. /**
  2519. * 设置摄像头流 content hint
  2520. * @param {string} hint
  2521. * @note 不传则尝试复用之前的 hint
  2522. */
  2523. setVideoContentHint(hint?: string): void;
  2524. /**
  2525. * 设置音频流 profile
  2526. * @param {string} profileKey
  2527. */
  2528. setAudioProfile(profileKey: AudioProfileKey): Promise<void>;
  2529. /**
  2530. * 设置屏幕共享流 profile
  2531. * @param {LocalStream} stream
  2532. * @param {string} profileKey
  2533. * @param {IProfile} profile
  2534. */
  2535. setScreenProfile(profileKey?: string, profile?: Partial<IProfile>): Promise<void>;
  2536. setScreenContentHint(hint?: string): void;
  2537. /**
  2538. * 设置 cameraVideoConstraints
  2539. * @param {IVideoConstraints} cameraVideoConstraints
  2540. */
  2541. setCameraVideoConstraints(cameraVideoConstraints: IVideoConstraints): void;
  2542. /**
  2543. * 设置 micAudioConstraints
  2544. * @param {IAudioConstraints} micAudioConstraints
  2545. */
  2546. setMicAudioConstraints(micAudioConstraints: IAudioConstraints): void;
  2547. }
  2548. declare interface LocalStreamManagerListener {
  2549. trackended: (type: TrackEvent_2) => {};
  2550. publishupdate: () => {};
  2551. }
  2552. declare class LocalUser extends User {
  2553. /**
  2554. * @ignore
  2555. */
  2556. static logName: string;
  2557. private _url;
  2558. private joinTime;
  2559. private _isPublishing;
  2560. private publishPromise;
  2561. private previewElements;
  2562. private screenPreviewElements;
  2563. private streamManager;
  2564. private dc;
  2565. protected streamTracks?: TrackInfo[];
  2566. protected publishId: string;
  2567. protected signalingManager: SignalingManager;
  2568. traceId: string;
  2569. private monitorTimerId?;
  2570. private monitorDataCache;
  2571. private trackTraceIdMap;
  2572. private candidateDataCache;
  2573. private pcMediaStatsMap;
  2574. protected slsReporter: SLSReporter;
  2575. private audioPubState;
  2576. private videoPubState;
  2577. private videoSmallPubState;
  2578. private screenPubState;
  2579. private dataPubState;
  2580. private parameter;
  2581. constructor(config: LocalUserConfig);
  2582. get url(): string;
  2583. set url(value: string);
  2584. get joined(): boolean;
  2585. get isPublishing(): boolean;
  2586. get publishStreams(): PublishStreamInfo;
  2587. get cameraTrack(): MediaStreamTrack | undefined;
  2588. get screenTrack(): MediaStreamTrack | undefined;
  2589. get audioTrack(): MediaStreamTrack | undefined;
  2590. get hasCamera(): boolean;
  2591. get hasMicrophone(): boolean;
  2592. get hasScreenShare(): boolean;
  2593. get hasCameraTrackInMS(): boolean;
  2594. get hasCameraDualTrackInMS(): boolean;
  2595. get hasScreenTrackInMS(): boolean;
  2596. get hasAudioTrackInMS(): boolean;
  2597. get cameraDirection(): string | undefined;
  2598. get audioCaptureDisabled(): boolean;
  2599. get cameraCaptureDisabled(): boolean;
  2600. get publishLocalVideoStreamEnabled(): boolean;
  2601. get publishLocalAudioStreamEnabled(): boolean;
  2602. get publishLocalScreenStreamEnabled(): boolean;
  2603. setPublishLocalAudioStreamEnabled(enable: boolean): void;
  2604. setPublishLocalVideoStreamEnabled(enable: boolean): void;
  2605. setPublishLocalScreenStreamEnabled(enable: boolean): void;
  2606. initInfo(authInfo: AliRtcAuthInfo, pushStreamUrl: string): void;
  2607. setVideoProfile(profile?: VideoProfileWithSendFramerate): Promise<void>;
  2608. setVideoContentHint(hint: string): void;
  2609. setScreenContentHint(hint: string): void;
  2610. setAudioProfile(profileKey: AudioProfileKey): Promise<void>;
  2611. setScreenProfile(profile?: Partial<IProfile>): Promise<void>;
  2612. setCameraDirection(direction: AliRtcCameraDirection): void;
  2613. setCameraDeviceId(deviceId: string): void;
  2614. muteLocalCamera(mute: boolean): void;
  2615. muteLocalMic(mute: boolean): void;
  2616. muteLocalScreen(mute: boolean): void;
  2617. setMicrophoneDeviceId(deviceId: string): void;
  2618. setMicrophoneConstraints(constraints: MediaTrackConstraints): void;
  2619. updatePubId(): void;
  2620. clearPublishState(): void;
  2621. leave(): Promise<void>;
  2622. /**
  2623. * 销毁,停止推流
  2624. * @returns {Promise<void>}
  2625. */
  2626. clear(): Promise<void>;
  2627. resetElement(element: HTMLVideoElement): void;
  2628. setPreviewElement(previewParams: PreviewConfig): void;
  2629. startDefaultCamera(audioOnly: boolean): Promise<void>;
  2630. startDefaultAudio(): Promise<void>;
  2631. /**
  2632. * 为本地预览设置渲染元素和视频流
  2633. * @param {AliRtcLocalView} view 渲染元素,null 则为停止显示
  2634. * @param {AliRtcVideoTrack} track 视频流类型
  2635. */
  2636. setViewConfig(elements: null | HTMLVideoElement[], track: AliRtcVideoTrack): void;
  2637. /**
  2638. * 开启摄像头采集
  2639. * @param params
  2640. * @returns
  2641. */
  2642. startCameraCapture(): Promise<LocalStream | undefined>;
  2643. /**
  2644. * 关闭摄像头采集
  2645. * @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
  2646. */
  2647. stopCameraCapture(): Promise<void>;
  2648. /**
  2649. * 开启麦克风采集
  2650. * @param params
  2651. * @returns
  2652. */
  2653. startAudioCapture(): Promise<LocalStream | undefined>;
  2654. /**
  2655. * 关闭音频采集
  2656. * @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
  2657. */
  2658. stopAudioCapture(): Promise<void>;
  2659. /**
  2660. * 预览本地流
  2661. * @param {PreviewConfig} previewParams
  2662. * @returns {Promise<MediaStream>}
  2663. */
  2664. preview(previewParams: PreviewConfig): Promise<MediaStream | undefined>;
  2665. /**
  2666. * 在所有预览容器中预览当前流
  2667. * @param {boolean} screen 是否指定预览辅流
  2668. */
  2669. previewAll(previewAllParams?: PreviewAllConfig): Promise<void>;
  2670. /**
  2671. * 停止预览本地流
  2672. */
  2673. stopPreview(previewParams?: StopPreviewConfig): void;
  2674. /**
  2675. * 恢复推流
  2676. * @returns {Promise<void>}
  2677. */
  2678. resumePublish(): Promise<void>;
  2679. createLocalStream(params: LocalStreamConfig): Promise<LocalStream | undefined>;
  2680. stopLocalStream(options: PublishOptions): Promise<void>;
  2681. private compareAndPublish;
  2682. private reportAudioProfile;
  2683. private reportVideoProfile;
  2684. private reportScreenProfile;
  2685. private updateDataChannel;
  2686. private publishDataChannel;
  2687. /**
  2688. * 开始推流
  2689. * @param isResume 是否是恢复推流
  2690. * @returns
  2691. */
  2692. startPublish(isResume?: boolean, reason?: PublishReason): Promise<void>;
  2693. /**
  2694. * 重新执行 progress 并触发 publishupdate
  2695. */
  2696. updateStreams(): Promise<void>;
  2697. /**
  2698. * 对比本地流和正在推流,进行推流更新
  2699. * @param isResume 是否是恢复推流
  2700. */
  2701. publishUpdate(reason?: PublishReason): Promise<PublishInfo | undefined>;
  2702. private syncPublishToRoomServer;
  2703. private refreshPushStreamUrl;
  2704. /**
  2705. * 推流,用于 rts subscribe/publish 被调用后,此时 DataChannel 已存在
  2706. * @param {LocalStream} stream
  2707. * @returns {Promise<PublishInfo>}
  2708. */
  2709. publishAdd(stream: LocalStream, extra: PublishExtraParams, isResume?: boolean, retryTimes?: number): Promise<PublishInfo>;
  2710. /**
  2711. * 替换推流 Track(仅限于替换已存在的 Track 类型)
  2712. * @param {LocalStream} stream
  2713. * @returns {Promise<PublishInfo>}
  2714. */
  2715. publishReplace(stream: LocalStream, extra?: PublishExtraParams): Promise<PublishInfo>;
  2716. /**
  2717. * 停止推某些轨,不销毁 DataChannel 和 LocalStream,用于非销毁场景
  2718. * @param {PublishOptions} options
  2719. * @returns {Promise<PublishInfo>}
  2720. */
  2721. publishDeleteTracks(options: PublishOptions): Promise<PublishInfo>;
  2722. /**
  2723. * 停止推流,不销毁 LocalStream,用于非销毁场景
  2724. * @returns {Promise<PublishInfo>}
  2725. */
  2726. publishStop(): Promise<PublishInfo>;
  2727. /**
  2728. * 停止推流,销毁 DataChannel,用于销毁的场景
  2729. * @returns {Promise<PublishInfo>}
  2730. */
  2731. unPublish(): Promise<PublishInfo>;
  2732. /**
  2733. * 事件通知本地的设备使用状态
  2734. */
  2735. reportSelfDeviceStatus(): void;
  2736. /**
  2737. * 从localStream 中获取当前的设备状态
  2738. * @returns {string}
  2739. */
  2740. private getDeviceStatus;
  2741. private onTrackEnd;
  2742. private resetPreviewElements;
  2743. private resetSecondayPreviewElements;
  2744. getMediaStats(id: string): any;
  2745. private reportPublishMonitor;
  2746. private reportNetwork;
  2747. private startStreamMonitor;
  2748. /**
  2749. * 停止本地流数据采集
  2750. */
  2751. private stopStreamMonitor;
  2752. /**
  2753. * 清除本地流
  2754. * @returns {void}
  2755. */
  2756. clearStream(): void;
  2757. /**
  2758. * 获取当前使用的摄像头 deviceId
  2759. * @returns {string | undefined}
  2760. */
  2761. getCurrentCameraDeviceId(): string | undefined;
  2762. /**
  2763. * 获取当前使用的摄像头 deviceId
  2764. * @returns {string | undefined}
  2765. */
  2766. getCurrentMicDeviceId(): string | undefined;
  2767. enableAudioVolumeIndication(interval: number): void;
  2768. sendSEI(message: ArrayBuffer, repeatCount: number, payloadType: number): Promise<void>;
  2769. sendDataChannelMessage(message: AliRtcDataChannelMsg): Promise<void>;
  2770. getStats(): Promise<{
  2771. audio: AliRtcLocalAudioStats[];
  2772. video: AliRtcLocalVideoStats[];
  2773. candidate: any;
  2774. }>;
  2775. }
  2776. declare interface LocalUserConfig {
  2777. rtsManager: RtsManager;
  2778. localStreamManager: LocalStreamManager;
  2779. slsReporter: SLSReporter;
  2780. signalingManager: SignalingManager;
  2781. pluginManager: PluginManager;
  2782. audioVolumeIndicationInterval: number;
  2783. parameter: {
  2784. [key: string]: any;
  2785. };
  2786. }
  2787. /**
  2788. * 日志埋点类,调用LogReporter进行日志埋点
  2789. * 在入会之前,会将埋点缓存,入会后以每200ms一条的速度将缓存的埋点按顺序上报
  2790. */
  2791. declare class LogClient {
  2792. protected tracker?: default_3;
  2793. protected param?: any;
  2794. protected msgCacheArr: any[];
  2795. protected index: number;
  2796. protected stsOpt?: any;
  2797. protected slsToken?: SLSSTSToken;
  2798. protected ossToken?: OSSSTSToken;
  2799. protected ntpClock: NTPClient;
  2800. constructor();
  2801. private createTracker;
  2802. start(info: AliRtcAuthInfo): void;
  2803. updateToken(slsToken: SLSSTSToken, ossToken?: OSSSTSToken): void;
  2804. /**
  2805. * 断开连接
  2806. */
  2807. stop(): void;
  2808. /**
  2809. * 发送一条日志
  2810. * @param {any} log
  2811. */
  2812. sendReport(log: any): void;
  2813. /**
  2814. * 初始化公共参数
  2815. */
  2816. protected initParam(info: AliRtcAuthInfo): void;
  2817. }
  2818. declare interface LogInfo {
  2819. [key: string]: string | number;
  2820. }
  2821. declare interface MediaTrackInfo {
  2822. ssrc: string;
  2823. msid: string;
  2824. red: number;
  2825. codec: CodecType;
  2826. sample?: number;
  2827. pt: number;
  2828. type?: CmdType;
  2829. }
  2830. declare enum MessageType {
  2831. KEEPALIVE = "keepalive",
  2832. JOINCHANNEL = "joinchannel",
  2833. NOTIFYJOIN = "notifyjoin",
  2834. NOTIFYSTATUS = "notifystatus",
  2835. STATUSREPORT = "statusreport",
  2836. LEAVECHANNEL = "leavechannel",
  2837. NOTIFYLEAVE = "notifyleave",
  2838. NOTIFYPUBLISH = "notifypublish",
  2839. BYE = "bye",
  2840. RECONNECT = "reconnect",
  2841. PUBLISH = "publish",
  2842. REFRESHURL = "refreshurl",
  2843. UNSUBSCRIBE = "unsubscribe",
  2844. ROLEUPDATE = "roleupdate"
  2845. }
  2846. declare enum MPU_TASK_TRANSACTION_TYPE {
  2847. MPU_TASK_TRANSACTION_START = 0,
  2848. MPU_TASK_TRANSACTION_UPDATE = 1,
  2849. MPU_TASK_TRANSACTION_STOP = 2,
  2850. MPU_TASK_TRANSACTION_LIST = 3,
  2851. MPU_TASK_TRANSACTION_POLLING = 4,
  2852. MPU_TASK_TRANSACTION_ACKNOWLEDGE = 5,
  2853. MPU_TASK_TRANSACTION_END = 6
  2854. }
  2855. declare enum MsidType {
  2856. Audio = "sophon_audio",
  2857. VideoLarge = "sophon_video_camera_large",
  2858. VideoSmall = "sophon_video_camera_small",
  2859. Screen = "sophon_video_screen_share",
  2860. Data = "sophon_data"
  2861. }
  2862. declare class NTPClient {
  2863. private static instance;
  2864. private ntpClock;
  2865. private constructor();
  2866. static getInstance(): NTPClient;
  2867. now(): number;
  2868. }
  2869. declare interface OSSSTSToken {
  2870. access_key_id: string;
  2871. access_key_secret: string;
  2872. security_token: string;
  2873. region_endpoint: string;
  2874. bucket_name: string;
  2875. expiration: number;
  2876. }
  2877. declare interface OSSToken {
  2878. access_key_id: string;
  2879. access_key_secret: string;
  2880. security_token: string;
  2881. region_endpoint: string;
  2882. bucket_name: string;
  2883. expiration: number;
  2884. }
  2885. declare class PackageCreater {
  2886. protected authInfo: AliRtcAuthInfo;
  2887. protected userName: string;
  2888. protected seqIndex: number;
  2889. constructor(authInfo: AliRtcAuthInfo, userName: string);
  2890. get roleAuth(): SendPackageAuthInfo | undefined;
  2891. refreshAuthInfo(authInfo: AliRtcAuthInfo): void;
  2892. getSeqIndex(): number;
  2893. /**
  2894. * 创建一个心跳包
  2895. * @returns
  2896. */
  2897. createKeepAlivePackage(): ISendPackage;
  2898. /**
  2899. * 创建一个用于发送入会消息的Package
  2900. * @returns
  2901. */
  2902. createJoinPackage(): ISendPackage;
  2903. /**
  2904. * 创建一个用于发送离会消息的Package
  2905. * @returns
  2906. */
  2907. crateLeavePackage(): ISendPackage;
  2908. createStatusPackage(status: string): ISendPackage;
  2909. /**
  2910. * 创建一个用于发送推流消息的Package
  2911. * @returns
  2912. */
  2913. createPublishPackage(): ISendPackage;
  2914. createRoleUpdatePackage(): ISendPackage;
  2915. createReconnectPackage(data?: ReconnectData): ISendPackage;
  2916. createRefreshUrlPackage(): ISendPackage;
  2917. /**
  2918. * 创建一个Response包
  2919. * @param {string} tid Notify消息的tid
  2920. * @param {MessageType} msgType 消息类型
  2921. * @returns {IResponse}
  2922. */
  2923. createResponsePackage(tid: string, msgType: MessageType): IResponse;
  2924. /**
  2925. *
  2926. * @param messageType
  2927. * @returns
  2928. */
  2929. protected createBaseSendPackage(messageType: MessageType): ISendPackage;
  2930. }
  2931. declare type Parameter = {
  2932. [key: string]: any;
  2933. };
  2934. declare class PluginManager extends default_2<PluginManagerListener> {
  2935. private plugins;
  2936. add(plugin: AliRtcPlugin, options?: any): void;
  2937. remove(name: string): void;
  2938. removeAll(): void;
  2939. get(name: string): AliRtcPlugin | undefined;
  2940. has(name: string): boolean;
  2941. getAll(): AliRtcPlugin[];
  2942. }
  2943. declare interface PluginManagerListener {
  2944. added: (plugin: AliRtcPlugin) => void;
  2945. removed: (plugin: AliRtcPlugin) => void;
  2946. updated: (plugin: AliRtcPlugin) => void;
  2947. }
  2948. declare interface PreviewAllConfig {
  2949. primary?: boolean;
  2950. screen?: boolean;
  2951. }
  2952. declare interface PreviewConfig {
  2953. videoElement: HTMLVideoElement;
  2954. screen?: boolean;
  2955. }
  2956. declare interface PublishExtraParams {
  2957. vMsid?: string;
  2958. aMsid?: string;
  2959. isVideoSmall?: boolean;
  2960. isScreen?: boolean;
  2961. isAudio?: boolean;
  2962. }
  2963. declare interface PublishInfo {
  2964. type: PublishType;
  2965. userid: string;
  2966. sessionid: string;
  2967. displayname: string;
  2968. pubid?: string;
  2969. resume?: boolean;
  2970. subscribe: {
  2971. signal: string;
  2972. pullstreamurl: string;
  2973. };
  2974. l1ip?: string;
  2975. callid: string;
  2976. tracks: TrackInfo[];
  2977. traceid?: string;
  2978. signaltid?: string;
  2979. }
  2980. declare type PublishOptions = StreamOptions & {
  2981. vMsid?: string;
  2982. };
  2983. declare enum PublishReason {
  2984. MANUAL = 0,
  2985. JOIN_CHANNEL = 1,
  2986. ROLE_CHANGE = 2,
  2987. RECONNECT = 3
  2988. }
  2989. declare interface PublishStreamInfo {
  2990. audio?: LocalStream;
  2991. video?: LocalStream;
  2992. videoSmall?: LocalStream;
  2993. screen?: LocalStream;
  2994. videoProfile?: LocalProfileManager;
  2995. screenProfile?: LocalProfileManager;
  2996. }
  2997. declare enum PublishType {
  2998. Add = "add",
  2999. Delete = "delete",
  3000. Replace = "replace",
  3001. Stop = "stop",
  3002. UnPublish = "unpublish"
  3003. }
  3004. declare interface PublishUser {
  3005. callid: string;
  3006. clientrole?: string;
  3007. displayname: string;
  3008. subscribe?: {
  3009. pullstreamurl: string;
  3010. };
  3011. pubid?: string;
  3012. tracks?: TrackInfo[];
  3013. userid: string;
  3014. sessionid?: string;
  3015. }
  3016. declare interface ReconnectData {
  3017. role?: RoleForReconnectData;
  3018. auth?: SendPackageAuthInfo;
  3019. publish?: {
  3020. users: [PublishInfo];
  3021. };
  3022. }
  3023. declare interface RefreshInfo {
  3024. pushstreamurl?: string;
  3025. users?: RefreshUser[];
  3026. }
  3027. declare interface RefreshUrlResult extends SignalingResult {
  3028. pushstreamurl?: string;
  3029. users?: RefreshUser[];
  3030. }
  3031. declare interface RefreshUser {
  3032. userid: string;
  3033. subscribe: {
  3034. pullstreamurl: string;
  3035. };
  3036. }
  3037. declare interface RemoteMediaTrackInfo extends MediaTrackInfo {
  3038. subscribeState?: RemoteTrackSubscribeState;
  3039. }
  3040. declare class RemoteStreamInfo extends default_2<StreamListener> {
  3041. /**
  3042. * @ignore
  3043. */
  3044. static logName: string;
  3045. protected audioInfo: RemoteMediaTrackInfo;
  3046. protected videoLargeInfo: RemoteMediaTrackInfo;
  3047. protected videoSmallInfo: RemoteMediaTrackInfo;
  3048. protected screenInfo: RemoteMediaTrackInfo;
  3049. protected dataInfo: RemoteMediaTrackInfo;
  3050. protected audioVolume: number;
  3051. protected audioMuted: boolean;
  3052. protected userStatus?: DeviceStatus;
  3053. constructor();
  3054. /**
  3055. * 远端流音频轨道信息
  3056. * @returns
  3057. */
  3058. getAudioInfo(): RemoteMediaTrackInfo;
  3059. /**
  3060. * 远端流视频轨道信息
  3061. * @returns
  3062. */
  3063. getVideoSmallInfo(): RemoteMediaTrackInfo;
  3064. /**
  3065. * 远端流视频轨道信息
  3066. * @returns
  3067. */
  3068. getVideoLargeInfo(): RemoteMediaTrackInfo;
  3069. /**
  3070. * 远端流屏幕共享轨道信息
  3071. * @returns
  3072. */
  3073. getScreenInfo(): RemoteMediaTrackInfo;
  3074. getDataInfo(): RemoteMediaTrackInfo;
  3075. get subscribingInfos(): RemoteMediaTrackInfo[];
  3076. get hasTrack(): boolean;
  3077. /**
  3078. * 远端流是否包含音频轨道
  3079. * @returns
  3080. */
  3081. get hasAudio(): boolean;
  3082. /**
  3083. * 远端流是否包含视频轨道
  3084. * @returns
  3085. */
  3086. get hasVideo(): boolean;
  3087. /**
  3088. * 远端流是否包含视频大流轨道
  3089. * @returns
  3090. */
  3091. get hasVideoLarge(): boolean;
  3092. /**
  3093. * 远端流是否包含视频小流轨道
  3094. * @returns
  3095. */
  3096. get hasVideoSmall(): boolean;
  3097. /**
  3098. * 远端流是否包含屏幕共享轨道
  3099. * @returns
  3100. */
  3101. get hasScreen(): boolean;
  3102. get hasData(): boolean;
  3103. /**
  3104. * 是否订阅远端流音频轨道
  3105. * @returns
  3106. */
  3107. get isAudioSubscribed(): boolean;
  3108. get isAudioSubscribing(): boolean;
  3109. /**
  3110. * 是否订阅远端流视频轨道
  3111. * @returns
  3112. */
  3113. get isVideoSubscribed(): boolean;
  3114. get isVideoSubscribing(): boolean;
  3115. /**
  3116. * 是否订阅远端流视频大流轨道
  3117. * @returns
  3118. */
  3119. get isVideoLargeSubscribed(): boolean;
  3120. get isVideoLargeSubscribing(): boolean;
  3121. /**
  3122. * 是否订阅远端流视频小流轨道
  3123. * @returns
  3124. */
  3125. get isVideoSmallSubscribed(): boolean;
  3126. get isVideoSmallSubscribing(): boolean;
  3127. /**
  3128. * 是否订阅远端流屏幕共享轨道
  3129. * @returns
  3130. */
  3131. get isScreenSubscribed(): boolean;
  3132. get isScreenSubscribing(): boolean;
  3133. get isDataSubscribed(): boolean;
  3134. get isDataSubscribing(): boolean;
  3135. get audioCodec(): CodecType;
  3136. get videoCodec(): CodecType;
  3137. get audioTrackInfo(): AliRtcAudioTrack;
  3138. get videoTrackInfo(): AliRtcVideoTrack;
  3139. updateTracks(tracks?: TrackInfo[]): UpdateTracksResult;
  3140. protected updateRemoteTrackSsrc(audioSsrc: string, videoLargeSsrc: string, videoSmallSsrc: string, screenSsrc: string, dataSsrc: string): void;
  3141. markRemoteTrackSubscribing(option: SubscribeOptions): any;
  3142. updateRemoteTrackSubState(option: SubscribeOptions): any;
  3143. /**
  3144. * 更新远端用户设备状态
  3145. * @param status
  3146. * @returns {boolean} 状态改变返回true,否则返回false
  3147. */
  3148. updateRemoteUserDeviceStatus(status: string): boolean;
  3149. }
  3150. declare interface RemoteSubscribeOptions {
  3151. remoteUser: RemoteUser;
  3152. options: SubscribeOptions;
  3153. }
  3154. declare enum RemoteTrackSubscribeState {
  3155. NotSubscribe = 0,
  3156. Subscribing = 1,
  3157. Subscribed = 2
  3158. }
  3159. declare class RemoteUser extends User {
  3160. /**
  3161. * @ignore
  3162. */
  3163. static logName: string;
  3164. remoteCallid: string;
  3165. remoteUserInfo: AliRtcRemoteUserInfo;
  3166. protected localUser?: LocalUser;
  3167. protected lastPubId: string;
  3168. protected stream?: RemoteStream;
  3169. protected screenStream?: RemoteStream;
  3170. private viewMap;
  3171. private audioTrack?;
  3172. private audioElement?;
  3173. protected subscribed: boolean;
  3174. protected mediaStream?: MediaStream;
  3175. protected secondaryMediaStream?: MediaStream;
  3176. protected prevSubConfig?: SubConfig;
  3177. protected signalingManager: SignalingManager;
  3178. protected slsReporter: SLSReporter;
  3179. private wantSubAudio;
  3180. private wantSubVideo;
  3181. private wantSubScreen;
  3182. private defaultVideoStreamType;
  3183. private audioMuted;
  3184. private playoutVolume;
  3185. private playoutGainNode?;
  3186. private audioSubState;
  3187. private videoSubState;
  3188. private videoLargeSubState;
  3189. private videoSmallSubState;
  3190. private screenSubState;
  3191. private dataSubState;
  3192. private dc;
  3193. private dcMsgWaitingPieces;
  3194. streamInfo: RemoteStreamInfo;
  3195. private _streamUrl;
  3196. private parameter;
  3197. private monitorTimerId?;
  3198. private monitorDataCache;
  3199. private trackTraceIdMap;
  3200. constructor(config: RemoteUserConfig);
  3201. get streamUrl(): string;
  3202. set streamUrl(value: string);
  3203. isWantSubAudio(): boolean;
  3204. setWantSubAudio(value: boolean): void;
  3205. isWantSubVideo(): boolean;
  3206. setWantSubVideo(value: boolean): void;
  3207. isWantSubScreen(): boolean;
  3208. setWantSubScreen(value: boolean): void;
  3209. setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
  3210. setAudioMuted(value: boolean): void;
  3211. getAudioElement(): HTMLAudioElement | undefined;
  3212. private handleAudioContextSuspended;
  3213. setPlayoutVolume(value: number): void;
  3214. getAudioMuted(): boolean;
  3215. get hasAudioTrack(): boolean;
  3216. get hasVideoTrack(): boolean;
  3217. get hasVideoLargeTrack(): boolean;
  3218. get hasVideoSmallTrack(): boolean;
  3219. get hasScreenTrack(): boolean;
  3220. get isAudioSubscribing(): boolean;
  3221. get isVideoSubscribing(): boolean;
  3222. get isVideoLargeSubscribing(): boolean;
  3223. get isVideoSmallSubscribing(): boolean;
  3224. get isScreenSubscribing(): boolean;
  3225. get isDataSubscribing(): boolean;
  3226. get audioEnabled(): boolean;
  3227. get videoEnabled(): boolean;
  3228. get screenEnabled(): boolean;
  3229. get getAudioTrack(): MediaStreamAudioTrack | undefined;
  3230. get getCameraStream(): RemoteStream | undefined;
  3231. get getScreenStream(): RemoteStream | undefined;
  3232. setViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
  3233. /**
  3234. * 销毁
  3235. * @returns {Promise<void>}
  3236. */
  3237. clear(needStopSub?: boolean): Promise<void>;
  3238. /**
  3239. * 更新远端用户的设备状态
  3240. * @param {string} status
  3241. * @returns {void}
  3242. */
  3243. updateRemoteUserDeviceStatus(status: string): void;
  3244. /**
  3245. * 更新远端用户的推流状态,已经停止推流的 tracks 要 delete,或者整体 stop
  3246. * @param {string} callid
  3247. * @param {string} pullStreamUrl
  3248. * @param {TrackInfo[]} tracks
  3249. * @returns {Promise<TrackChangeState>}
  3250. */
  3251. updateRemoteTracks(callid: string, pullStreamUrl: string, _pubid: string, tracks?: TrackInfo[]): Promise<UpdateTracksResult>;
  3252. /**
  3253. * 订阅远端流
  3254. * @param {SubscribeOptions} options
  3255. * @returns {Promise<void>} 返回可播放的 MediaStream,可能为空。如果同时订阅了主流和辅流,只会返回主流对应的 MediaStream
  3256. */
  3257. subscribe(options?: SubscribeOptions, reason?: SubscribeReason, startTs?: number): Promise<void>;
  3258. /**
  3259. * 订阅远端流
  3260. * @param {SubscribeOptions} options 订阅配置
  3261. * @param {boolean} secondary 是否订阅辅流
  3262. * @returns {Promise<SubscribeResult>}
  3263. */
  3264. private subscribeProxy;
  3265. /**
  3266. * 移除对某些轨道的订阅
  3267. * @param {UnSubscribeOptions} options 取消订阅轨道配置
  3268. * @returns {Promise<SubscribeResult>}
  3269. */
  3270. private subscribeDeleteTracks;
  3271. /**
  3272. * 移除对某些轨道的订阅
  3273. * @param {Partial<ISubConfigItem>} deleteTrack 删除订阅配置
  3274. * @returns {Promise<SubscribeResult>}
  3275. */
  3276. private subscribeDeleteProxy;
  3277. /**
  3278. * 用保存的订阅参数恢复订阅
  3279. */
  3280. restore(): void;
  3281. resumeAudio(): Promise<void>;
  3282. resumeVideo(videoTrack?: AliRtcVideoTrack): Promise<void>;
  3283. resumePlay(): void;
  3284. /**
  3285. * 停止订阅远端流
  3286. * @param {string} userId
  3287. * @param {UnSubscribeOptions} options
  3288. * @returns {Promise<void>}
  3289. */
  3290. stopSubscribe(options?: UnSubscribeOptions): Promise<void>;
  3291. /**
  3292. * 停止对某个拉流 URL 的订阅
  3293. * @param {url} pullStreamUrl
  3294. * @returns {Promise<SubscribeResult>}
  3295. */
  3296. private doStopSubscribe;
  3297. private updateStream;
  3298. private updateScreenStream;
  3299. private clearStream;
  3300. private clearScreenStream;
  3301. private onDataChannelMessage;
  3302. private onDataChannelError;
  3303. private dataChannelConnected;
  3304. private subscribeDataChannel;
  3305. private subscribeStopDataChannel;
  3306. getRetryOptions(): RemoteSubscribeOptions | undefined;
  3307. /**
  3308. * 尝试更新订阅
  3309. * 1. 需要新增订阅的情况:想要订阅 & 没有正在订阅 & 远端有流
  3310. */
  3311. updateSubscribe(reason: SubscribeReason): {
  3312. addOption: SubscribeOptions;
  3313. deleteOption: SubscribeOptions;
  3314. };
  3315. private handleAutoPlayFailed;
  3316. private handleAudioPaused;
  3317. private handleVideoPlayFailded;
  3318. private playAudio;
  3319. stopPlayAudio(): void;
  3320. playAll(isScreen?: boolean, isReplace?: boolean): void;
  3321. /**
  3322. * 播放
  3323. */
  3324. private play;
  3325. stopPlayAll(isScreen?: boolean): void;
  3326. /**
  3327. * 是否开启声音
  3328. * @param {boolean} enable
  3329. * @returns {void}
  3330. */
  3331. toggleAudio(enable?: boolean): void;
  3332. /**
  3333. * 是否开启画面
  3334. * @param {boolean} enable
  3335. * @returns {void}
  3336. */
  3337. toggleVideo(enable?: boolean): void;
  3338. /**
  3339. * 是否开启画面
  3340. * @param {boolean} enable
  3341. * @returns {void}
  3342. */
  3343. toggleScreen(enable?: boolean): void;
  3344. getStats(): Promise<{
  3345. audio: AliRtcRemoteAudioStats[];
  3346. video: AliRtcRemoteVideoStats[];
  3347. }>;
  3348. /**
  3349. * 开启音量检测
  3350. * @param {number} interval 时间间隔
  3351. */
  3352. enableAudioVolumeIndication(interval: number): void;
  3353. private reportSubscribeMonitor;
  3354. private startStreamMonitor;
  3355. /**
  3356. * 停止本地流数据采集
  3357. */
  3358. private stopStreamMonitor;
  3359. }
  3360. declare interface RemoteUserConfig {
  3361. userId: string;
  3362. displayName: string;
  3363. rtsManager: RtsManager;
  3364. usersViewMap: {
  3365. [key: string]: RemoteUserViewMap;
  3366. };
  3367. slsReporter: SLSReporter;
  3368. signalingManager: SignalingManager;
  3369. localUser?: LocalUser;
  3370. audioVolumeIndicationInterval: number;
  3371. playoutVolume: number;
  3372. parameter: {
  3373. [key: string]: any;
  3374. };
  3375. }
  3376. declare interface RemoteUserMap {
  3377. [userId: string]: RemoteUser;
  3378. }
  3379. declare interface RemoteUserStatus {
  3380. userid: string;
  3381. status: string;
  3382. }
  3383. declare interface RemoteUserViewMap {
  3384. cameraViews: HTMLVideoElement[];
  3385. screenViews: HTMLVideoElement[];
  3386. }
  3387. declare interface RoleForReconnectData {
  3388. channelprofile?: AliRtcSdkChannelProfile;
  3389. clientrole?: AliRtcSdkClientRole;
  3390. }
  3391. /**
  3392. * RoomServerMessageCenter支持的事件
  3393. */
  3394. declare interface RoomServerListener {
  3395. onJoinChannelResult: (data: any) => void;
  3396. onPublishResult: (code: number, tid: string, description: string) => void;
  3397. onNotifyJoin: (users: JoinInfo[]) => void;
  3398. onNotifyStatus: (users: RemoteUserStatus[]) => void;
  3399. onLeaveResult: (code: number, tid: string) => void;
  3400. onRoleUpdateResult: (code: number, tid: string, description: string) => void;
  3401. onRefreshUrlResult: (data: any) => void;
  3402. onNotifyLeave: (users: LeaveInfo[]) => void;
  3403. onNotifyPublish: (users: PublishUser[]) => void;
  3404. onStatusReport: (code: number, tid: string, description: string) => void;
  3405. onBye: (reason: AliRtcOnByeType, description: string) => void;
  3406. onKeepAliveRsp: () => void;
  3407. onConnectFail: (err: AliRtcError) => void;
  3408. onNetworkError: (err: AliRtcError) => void;
  3409. onAuthInvalid: () => void;
  3410. onReconnectStart: () => void;
  3411. onReconnectFail: (err: AliRtcError) => void;
  3412. onReconnectSuccess: (users: JoinInfo[]) => void;
  3413. onError: (err: AliRtcError) => void;
  3414. }
  3415. /**
  3416. * RoomServer消息中心
  3417. * 负责发送和接收信令数据,消息重发、回复Response
  3418. */
  3419. declare class RoomServerMessageCenter extends default_2<RoomServerListener> {
  3420. static logName: string;
  3421. protected authInfo: AliRtcAuthInfo;
  3422. protected userName: string;
  3423. protected channelProfile: AliRtcSdkChannelProfile;
  3424. protected clientRole: AliRtcSdkClientRole;
  3425. private slsReporter;
  3426. protected wsClient: Socket;
  3427. protected packageCreater: PackageCreater;
  3428. protected keepAliveTimer: number;
  3429. protected packageCache: Map<string, ISendPackage>;
  3430. protected isFirstConnect: boolean;
  3431. protected aliveChecker: number;
  3432. protected reconnectData?: ReconnectData;
  3433. constructor(authInfo: AliRtcAuthInfo, userName: string, channelProfile: AliRtcSdkChannelProfile, clientRole: AliRtcSdkClientRole, slsReporter: SLSReporter, maxConnectRetryCount?: number);
  3434. get retryCount(): number;
  3435. /**
  3436. * 开始连接信令
  3437. * @param roomserverurl
  3438. */
  3439. start(roomserverurl: string): void;
  3440. /**
  3441. * 开始心跳计时器,并自动发送心跳包
  3442. */
  3443. startKeepAlive(): void;
  3444. /**
  3445. * 停止心跳计时器
  3446. */
  3447. stopKeepAlive(): void;
  3448. /**
  3449. * 发送入会、重连前所缓存信息
  3450. */
  3451. sendPkgCache(): void;
  3452. /**
  3453. * 发送离开房间
  3454. */
  3455. leave(): void;
  3456. /**
  3457. * 透明通道消息上报
  3458. * @param status
  3459. */
  3460. reportStatus(status: string): void;
  3461. /**
  3462. * 发送推流消息
  3463. */
  3464. publish(_pubInfo: PublishInfo): void;
  3465. /**
  3466. * 更新角色
  3467. */
  3468. roleUpdate(role: string): void;
  3469. /**
  3470. * 更新推拉流地址
  3471. * @param {RefreshInfo} info
  3472. */
  3473. refreshUrl(info: RefreshInfo): void;
  3474. refreshAuthInfo(authInfo: AliRtcAuthInfo): void;
  3475. /**
  3476. * 关闭websocket连接,并销毁
  3477. */
  3478. close(): void;
  3479. /**
  3480. * 通过此方法发送数据到业务信令
  3481. * 此方法会自动保存发送的package,并做重发.
  3482. * response包不要通过此方法发送
  3483. * @param pkg
  3484. */
  3485. protected sendPackage(pkg: ISendPackage): void;
  3486. /**
  3487. * 更新重连 payload
  3488. * @param {ReconnectData} reconnectData
  3489. */
  3490. updateReconnectData(reconnectData?: ReconnectData): void;
  3491. /**
  3492. * 收到websocket连接成功的消息
  3493. * ws连接建立成功后立刻发送join消息
  3494. */
  3495. protected onOpen(): void;
  3496. /**
  3497. * 收到业务信令消息
  3498. * @param event
  3499. */
  3500. protected onMessage(event: MessageEvent): void;
  3501. /**
  3502. * 收到错误消息
  3503. * @param event
  3504. */
  3505. protected onError(event: Event): void;
  3506. /**
  3507. * 连接失败
  3508. */
  3509. protected onConnectFail(): void;
  3510. /**
  3511. * 鉴权失败
  3512. */
  3513. protected onAuthInvalid(): void;
  3514. /**
  3515. * 网络异常
  3516. */
  3517. protected onNetworkError(): void;
  3518. /**
  3519. * 收到websocket断开消息
  3520. * @param event
  3521. */
  3522. protected onClose(event: CloseEvent): void;
  3523. protected onKeepAliveRsp(): void;
  3524. protected onReconnectStart(): void;
  3525. protected onReconnectFail(): void;
  3526. /**
  3527. * 处理 Keepalive 心跳,加速判断网络异常
  3528. */
  3529. protected checkAlive(): void;
  3530. /**
  3531. * 处理收到的业务信令
  3532. * @param response
  3533. */
  3534. protected onRecvMessage(response: any): void;
  3535. /**
  3536. * 收到入会消息的response
  3537. * @param response
  3538. */
  3539. protected onJoinResult(response: any): void;
  3540. /**
  3541. * 收到离开消息的response
  3542. * @param response
  3543. */
  3544. protected onLeaveResult(response: any): void;
  3545. /**
  3546. * 收到publish消息的response
  3547. * @param response
  3548. */
  3549. protected onPublishResult(response: any): void;
  3550. /**
  3551. * 收到roleUpdate消息的response
  3552. * @param response
  3553. */
  3554. protected onRoleUpdateResult(response: any): void;
  3555. /**
  3556. * 收到 refreshurl 消息的response
  3557. * @param response
  3558. */
  3559. protected onRefreshUrlResult(response: any): void;
  3560. /**
  3561. * 收到重联消息的response
  3562. * @param response
  3563. */
  3564. protected onReconnectResult(response: any): void;
  3565. /**
  3566. * 收到业务信令下发的消息
  3567. * @param response
  3568. */
  3569. protected onNotifyJoin(response: any): void;
  3570. /**
  3571. * 收到业务信令下发的透明通道消息
  3572. * @param response
  3573. */
  3574. protected onNotifyStatus(response: any): void;
  3575. /**
  3576. * 收到远端用户离开的通知
  3577. * @param response
  3578. */
  3579. protected onNotifyLeave(response: any): void;
  3580. /**
  3581. * 收到远端用户推流的通知
  3582. * @param response
  3583. */
  3584. protected onNotifyPublish(response: any): void;
  3585. /**
  3586. * 收到statusreport的response
  3587. * @param response
  3588. */
  3589. protected onStatusReport(response: any): void;
  3590. /**
  3591. * 收到被踢出频道的消息
  3592. * @param {any} response
  3593. */
  3594. protected onBye(response: any): void;
  3595. }
  3596. declare class RoomServerSignaling extends default_2<RoomServerListener> {
  3597. /**
  3598. * @ignore
  3599. */
  3600. static logName: string;
  3601. protected messageCenter?: RoomServerMessageCenter;
  3602. protected authInfo?: AliRtcAuthInfo;
  3603. protected userName?: string;
  3604. protected channelProfile: AliRtcSdkChannelProfile;
  3605. protected clientRole: AliRtcSdkClientRole;
  3606. private slsReporter;
  3607. protected reconnectData?: ReconnectData;
  3608. protected roomServerUri: string;
  3609. constructor(channelProfile: AliRtcSdkChannelProfile, clientRole: AliRtcSdkClientRole, slsReporter: SLSReporter, env?: AliRtcEnv);
  3610. /**
  3611. * 更新重连数据
  3612. * @param {ReconnectData} reconnectData
  3613. */
  3614. private updateReconnectData;
  3615. /**
  3616. * 释放资源
  3617. */
  3618. reset(): void;
  3619. /**
  3620. * 加入频道
  3621. * @param {AliRtcAuthInfo} authInfo
  3622. * @returns
  3623. */
  3624. join(authInfo: AliRtcAuthInfo, userName: string, maxConnectRetryCount?: number): Promise<JoinResult>;
  3625. /**
  3626. * 离开频道
  3627. * @returns
  3628. */
  3629. leave(): Promise<SignalingResult>;
  3630. /**
  3631. * 开始推流
  3632. * @param pubInfo
  3633. * @returns
  3634. */
  3635. publish(pubInfo: PublishInfo): Promise<SignalingResult>;
  3636. roleUpdate(role: AliRtcSdkClientRole): Promise<SignalingResult>;
  3637. setChannelProfile(channelProfile: AliRtcSdkChannelProfile): void;
  3638. /**
  3639. * 更新推流地址
  3640. */
  3641. refreshUrl(info: RefreshInfo): Promise<RefreshUrlResult>;
  3642. /**
  3643. * 上报设备状态
  3644. * @param status
  3645. */
  3646. reportStatus(status: string): Promise<void>;
  3647. protected handleSignalError(code: number, description: string, errorCode?: AliRtcErrorCode): AliRtcError;
  3648. refreshAuthInfo(authInfo: AliRtcAuthInfo): Promise<void>;
  3649. /**
  3650. * 初始化MessageCenter,增加事件监听
  3651. */
  3652. protected initMessageCenter(): void;
  3653. }
  3654. declare class RtsManager extends default_2<RtsManagerEventListener> {
  3655. /**
  3656. * @ignore
  3657. */
  3658. static logName: string;
  3659. private rts;
  3660. private encodedInsertableStreams;
  3661. private audioRedEnabled;
  3662. private localStreamManager;
  3663. private slsReporter;
  3664. private _rtsReconnecting;
  3665. private _rtsPeerConnectionType;
  3666. private connecting;
  3667. private connected;
  3668. private _pcTraceId;
  3669. private _localJoinTime;
  3670. private connectionResolve?;
  3671. private connectingPromise?;
  3672. private dcResolve?;
  3673. private dcReject?;
  3674. private dcConnectingPromise?;
  3675. private _publishingTracks;
  3676. private parameter;
  3677. constructor(localStreamManager: LocalStreamManager, slsReporter: SLSReporter, parameter: Parameter);
  3678. private addRTSListener;
  3679. /**
  3680. * 更新鉴权信息,传入一个新的带鉴权的 URL,RTS 会去除鉴权信息做更新
  3681. * @param newUrlWithAuth
  3682. */
  3683. updateAuth(newUrlWithAuth: string): void;
  3684. get pcTraceId(): string;
  3685. set localJoinTime(time: number);
  3686. setEncodedInsertableStreams(enable: boolean): void;
  3687. setAudioRedEnabled(enable: boolean): void;
  3688. clear(): void;
  3689. private startConnect;
  3690. private setConnected;
  3691. get isConnecting(): boolean;
  3692. get isConnected(): boolean;
  3693. get publishingTracks(): TrackInfo[];
  3694. private getPubMsid;
  3695. private updatePublishingTracks;
  3696. private httpPublish;
  3697. waitPublishSender(streamUrl: string, isAudio?: boolean, msid?: string): Promise<any>;
  3698. getPublishVideoStats(streamUrl: string, msid?: string): Promise<unknown>;
  3699. getPublishAudioStats(streamUrl: string, msid?: string): Promise<unknown>;
  3700. publishAdd(streamUrl: string, stream: LocalStream, callId: string, extra?: PublishExtraParams, isResume?: boolean, waitSender?: boolean, reason?: PublishReason): Promise<string>;
  3701. publishDelete(streamUrl: string, options: PublishOptions): Promise<string>;
  3702. publishReplace(streamUrl: string, stream: LocalStream, extra?: PublishExtraParams): Promise<string>;
  3703. publishStop(streamUrl: string): Promise<string>;
  3704. publishAddDataChannel(streamUrl: string): Promise<any>;
  3705. publishStopDataChannel(streamUrl: string, datachannel: any): Promise<void>;
  3706. unpublish(): Promise<void>;
  3707. /**
  3708. * 获取 sub/subAdd config
  3709. * @param {ISubscribeConfig | ISubConfigItem} options
  3710. * @returns {Omit<ISignalConfig | ISubConfigItem, 'url'>}
  3711. */
  3712. private getSubConfig;
  3713. private httpSubscribe;
  3714. private subscribeAdd;
  3715. subscribeDelete(subscribeOptions: RemoteSubscribeOptions): Promise<{
  3716. url: string;
  3717. stream: any;
  3718. } | undefined>;
  3719. subscibeStop(streamUrl: string): Promise<void>;
  3720. subscribeAddDataChannel(streamUrl: string): Promise<any>;
  3721. subscribeStopDatachannel(streamUrl: string, datachannel: any): Promise<any>;
  3722. publish(streamUrl: string, callId: string, isResume?: boolean, reason?: PublishReason): Promise<{
  3723. traceId: string;
  3724. l1ip?: string;
  3725. }>;
  3726. private reportSubscribeLatency;
  3727. subscribe(remoteSubscribeOptions: RemoteSubscribeOptions, reason: SubscribeReason, callId: string, remoteCallId: string, startTs: number): Promise<any>;
  3728. getSubscribeVideoStats(streamUrl: string, msid?: string): Promise<unknown>;
  3729. getSubscribeAudioStats(streamUrl: string, msid?: string): Promise<unknown>;
  3730. getStreamByMsid(config: any): LocalStream | RemoteStream;
  3731. getDatachannelByMsid(config: {
  3732. url: string;
  3733. msid?: string;
  3734. }): any;
  3735. getPCStats(): Promise<any>;
  3736. sendSEI(streamUrl: string, data: ArrayBuffer, repeatCount: number, payloadType: number): Promise<void>;
  3737. }
  3738. declare interface RtsManagerEventListener {
  3739. reconnecting: (type: RtsPeerConnectionType) => {};
  3740. disconnected: () => {};
  3741. connected: (isReconnected: boolean, type: RtsPeerConnectionType) => {};
  3742. subscribeexceeds: () => {};
  3743. seimessage: (url: string, payloadType: number, data: ArrayBuffer) => {};
  3744. }
  3745. declare enum RtsPeerConnectionType {
  3746. PUBLISH = "publish",
  3747. SUBSCRIBE = "subscribe"
  3748. }
  3749. declare interface SendPackageAuthInfo {
  3750. timestamp: number;
  3751. nonce?: string;
  3752. token: string;
  3753. tokenrole: AliRtcSdkTokenRole;
  3754. }
  3755. declare class SignalingManager extends default_2<RoomServerListener> {
  3756. /**
  3757. * @ignore
  3758. */
  3759. static logName: string;
  3760. protected signaling?: RoomServerSignaling;
  3761. protected authInfo?: AliRtcAuthInfo;
  3762. protected userName?: string;
  3763. protected channelProfile: AliRtcSdkChannelProfile;
  3764. protected clientRole: AliRtcSdkClientRole;
  3765. protected env: AliRtcEnv;
  3766. protected maxConnectRetryCount?: number;
  3767. stsManager: StsManager;
  3768. private slsReporter;
  3769. constructor(channelProfile: AliRtcSdkChannelProfile, clientRole: AliRtcSdkClientRole, slsReporter: SLSReporter, env?: AliRtcEnv);
  3770. reset(): void;
  3771. /**
  3772. * 向业务信令发送入会
  3773. * @param {AliRtcAuthInfo} authInfo
  3774. * @returns
  3775. */
  3776. join(authInfo: AliRtcAuthInfo, userName?: string, maxConnectRetryCount?: number, timeRecorder?: TimeRecorder): Promise<JoinResult>;
  3777. retryJoin(): void;
  3778. /**
  3779. * 向业务信令发送离会
  3780. * @returns
  3781. */
  3782. leave(): Promise<SignalingResult>;
  3783. /**
  3784. * 推流
  3785. * @param pubInfo
  3786. * @returns
  3787. */
  3788. publish(pubInfo: PublishInfo): Promise<SignalingResult>;
  3789. /**
  3790. * 通过透明通道发送设备状态
  3791. * @param {string} status
  3792. * @returns
  3793. */
  3794. reportStatus(status: string): Promise<void>;
  3795. /**
  3796. * 切换角色
  3797. * @param {AliRtcSdkClientRole} role
  3798. * @returns
  3799. */
  3800. setClientRole(role: AliRtcSdkClientRole): Promise<SignalingResult | undefined>;
  3801. /**
  3802. * 切换模式
  3803. * @param {AliRtcSdkChannelProfile} channelProfile
  3804. */
  3805. setChannelProfile(channelProfile: AliRtcSdkChannelProfile): void;
  3806. /**
  3807. * 更新推流url
  3808. * @param {RefreshInfo} info
  3809. * @returns
  3810. */
  3811. refreshUrl(info: RefreshInfo): Promise<RefreshUrlResult>;
  3812. refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): Promise<void>;
  3813. /**
  3814. * 监听业务信令相关的事件
  3815. */
  3816. protected initSignaling(): void;
  3817. /**
  3818. * 收到心跳消息
  3819. */
  3820. protected onKeepAliveRsp(): void;
  3821. /**
  3822. * 收到远端用户入会消息
  3823. * @param {JoinInfo[]} users
  3824. */
  3825. protected onNotifyJoin(users: JoinInfo[]): void;
  3826. /**
  3827. * 收到远端用户的透明通道消息
  3828. * @param {RemoteUserStatus[]} users
  3829. */
  3830. protected onNotifyStatus(users: RemoteUserStatus[]): void;
  3831. /**
  3832. * 收到远端用户的离会消息
  3833. * @param {LeaveInfo[]} users
  3834. */
  3835. protected onNotifyLeave(users: LeaveInfo[]): void;
  3836. /**
  3837. * 收到远端用户推流状态变化消息
  3838. * @param {PublishInfo[]} users
  3839. */
  3840. protected onNotifyPublish(users: PublishUser[]): void;
  3841. /**
  3842. * 收到被踢掉消息
  3843. * @param {string} reason
  3844. * @param {string} description
  3845. */
  3846. protected onBye(reason: AliRtcOnByeType, description: string): void;
  3847. /**
  3848. * 收到连接失败消息
  3849. * @param {AliRtcError} err
  3850. */
  3851. protected onConnectFail(err: AliRtcError): void;
  3852. /**
  3853. * 收到网络异常消息
  3854. * @param {AliRtcError} err
  3855. */
  3856. protected onNetworkError(err: AliRtcError): void;
  3857. /**
  3858. * 收到网络异常消息
  3859. */
  3860. protected onAuthInvalid(): void;
  3861. protected onReconnectStart(): void;
  3862. /**
  3863. * 收到重连成功消息
  3864. * @param {JoinInfo[]} users
  3865. */
  3866. protected onReconnectSuccess(users: JoinInfo[]): void;
  3867. /**
  3868. * 收到重连失败消息
  3869. */
  3870. protected onReconnectFail(err: AliRtcError): void;
  3871. /**
  3872. * 收到错误消息
  3873. * @param {AliRtcError} err
  3874. */
  3875. protected onError(err: AliRtcError): void;
  3876. }
  3877. declare interface SignalingResult {
  3878. tid: string;
  3879. code?: number;
  3880. message?: string;
  3881. }
  3882. /**
  3883. * 日志埋点类
  3884. * 每个埋点暴露对应的接口
  3885. */
  3886. declare class SLSReporter {
  3887. private engine;
  3888. protected logClient: LogClient;
  3889. protected authInfo?: AliRtcAuthInfo;
  3890. private ntpClock;
  3891. private static staticClient;
  3892. private static getLogClient;
  3893. static reportOSSUpload(sessionId: string, date: string, responseCode?: number): void;
  3894. constructor(engine: WrappedAliRtcEngine);
  3895. private customFields;
  3896. /**
  3897. * 设置通用字段
  3898. * @param fields 字段键值对
  3899. */
  3900. setCustomFields(fields: {
  3901. [key: string]: any;
  3902. }): void;
  3903. /**
  3904. * 获取通用字段
  3905. * @param key 字段键
  3906. * @returns 字段值或undefined
  3907. */
  3908. getCustomField(key: string): any;
  3909. /**
  3910. * 开始建立连接
  3911. * @param authInfo
  3912. */
  3913. start(info: AliRtcAuthInfo): void;
  3914. updateToken(token: SLSSTSToken, ossToken?: OSSSTSToken): void;
  3915. /**
  3916. * 断开连接
  3917. */
  3918. stop(): void;
  3919. reportPublishMonitor(callId: string, traceId: string, msid: string, track: MediaStreamTrack | undefined, stats: any[]): void;
  3920. reportSubscribeMonitor(callId: string, remoteId: string, traceId: string, msid: string, stats: any[]): void;
  3921. reportNetworkMonitor(candidates: any[]): void;
  3922. /**
  3923. * 加入房间成功埋点
  3924. * @param {number} joinTime
  3925. * @param {number} result
  3926. * @param {string} tid
  3927. */
  3928. reportJoin(result: number, timeRecord: TimeRecorder, tid?: string): void;
  3929. /**
  3930. * Join 链接细节
  3931. */
  3932. reportJoinConnection(logInfo: LogInfo): void;
  3933. /**
  3934. * 用户离开频道事件埋点
  3935. * @param {number} leaveTime
  3936. * @param {number} result
  3937. * @param {string} tid
  3938. */
  3939. reportLeave(leaveTime: number, result: number, tid: string): void;
  3940. /**
  3941. * 推流事件上报
  3942. * @param {string} callid
  3943. * @param {boolean} isLargeVideo
  3944. * @param {boolean} isSmallVideo
  3945. * @param {boolean} isScreenShare
  3946. * @param {boolean} isAudio
  3947. * @param {number} result
  3948. * @param {string} tid
  3949. * @param {number} pubTime
  3950. */
  3951. reportPublish(isRepublish: boolean, url: string, callid: string, isLargeVideo: boolean, isSmallVideo: boolean, isScreenShare: boolean, isAudio: boolean, result: number | undefined, pcTraceId: string, traceId: string, startTime: number): void;
  3952. /**
  3953. * 首包上报
  3954. * @param {string} callid
  3955. * @param {number} startTime
  3956. * @param {number} publishTime
  3957. * @param {number} joinTime
  3958. * @param {string} tckid
  3959. * @param {string} pcTraceId
  3960. * @param {string} traceId
  3961. * @param {PublishReason} reason
  3962. */
  3963. reportPublishFirstPacket(isRepublish: boolean, callid: string, startTime: number, publishTime: number, joinTime: number, tckid: string, pcTraceId: string, traceId: string, reason: PublishReason): void;
  3964. /**
  3965. * 停止推流事件上报
  3966. * @param {string} callid
  3967. * @param {number} unpubTime
  3968. * @param {number} result
  3969. * @param {string} tid
  3970. */
  3971. reportUnpublish(callid: string, unpubTime: number, result: number, tid: string): void;
  3972. /**
  3973. * 订阅事件埋点
  3974. * @param {string} callid
  3975. * @param {string} remoteid
  3976. * @param {boolean} isLargeVideo
  3977. * @param {boolean} isSmallVideo
  3978. * @param {boolean} isScreenShare
  3979. * @param {boolean} isAudio
  3980. * @param {number} result
  3981. * @param {string} tid
  3982. * @param {number} subTime
  3983. */
  3984. reportSubscribe(callid: string, remoteid: string, isLargeVideo: boolean, isSmallVideo: boolean, isScreenShare: boolean, isAudio: boolean, result: number, tid: string, subTime: number, logInfo: LogInfo): void;
  3985. reportSubscribeFirstPacket(isResume: boolean, callid: string, remoteid: string, trackId: string, logInfo: LogInfo): void;
  3986. reportSubscribeFirstFrame(isResume: boolean, callid: string, remoteid: string, trackId: string, logInfo: LogInfo): void;
  3987. /**
  3988. * 停止订阅事件埋点
  3989. * @param {string} callid
  3990. * @param {string} remoteid
  3991. * @param {number} unsubTime
  3992. * @param {number} result
  3993. * @param {string} tid
  3994. */
  3995. reportUnsubscribe(callid: string, remoteid: string, unsubTime: number, result: number, tid: string): void;
  3996. reportMute(callid: string, enable: boolean, type: 'audio' | 'video' | 'screen'): void;
  3997. /**
  3998. * 更新角色埋点
  3999. * @param {string|undefined} or 旧的角色
  4000. * @param {string} nr 新的角色
  4001. */
  4002. reportRoleUpdate(or: string | undefined, nr: string): void;
  4003. /**
  4004. * 更新角色埋点
  4005. * @param {string|undefined} or 旧的角色
  4006. * @param {string} nr 新的角色
  4007. */
  4008. reportRoleUpdateResult(or: string | undefined, nr: string, ctm: number, result: number): void;
  4009. /**
  4010. * 设置camera videoprofile
  4011. */
  4012. reportVideoProfile(profile: string): void;
  4013. /**
  4014. * 设置screenshare videoprofile
  4015. */
  4016. reportScreenProfile(profile: string): void;
  4017. /**
  4018. * 错误事件埋点
  4019. * @param err
  4020. */
  4021. reportError(err: any): void;
  4022. /**
  4023. * 错误事件埋点
  4024. * @param err
  4025. */
  4026. reportWarning(msg: string): void;
  4027. reportRoomServerEvent(isRequest: boolean, type: string, requestId: string, content: any): void;
  4028. reportTranscodingError(result: number, taskid: string): void;
  4029. reportBye(result: number): void;
  4030. reportAudio(error: any, cost: number, deviceName: string): void;
  4031. reportScreen(error: any, cost: number): void;
  4032. reportScreenStop(error: any): void;
  4033. reportSwitchCamera(deviceId: string): void;
  4034. reportPublishProfile(trackId: string, logInfo: LogInfo): void;
  4035. reportSDKCreated(startTs: number): void;
  4036. reportJoinInvoked(authInfo: AliRtcAuthInfo): void;
  4037. reportJoinResult(error: any): void;
  4038. reportSTSResult(code: number, startTs: number): void;
  4039. reportLeaveInvoked(): void;
  4040. reportSEIMessage(payloadType: number, length: number, repeatCount: number, delay: number, isKey: boolean): void;
  4041. /**
  4042. * 接通耗时事件(12001)
  4043. * 用stage和status来区分接通过程中各个时间节点。
  4044. * @param state
  4045. * @param status
  4046. * @param calid
  4047. * @param tckid
  4048. */
  4049. reportConnectionLatencyEvent<Stage extends keyof ValidStatusMap>(stage: Stage, status: ValidStatusMap[Stage], calid: string, tckid: string, tm?: number, ntptm?: number, http?: boolean): void;
  4050. /**
  4051. * 日志埋点
  4052. * 在埋点中增加tm字段,表示发生埋点的客户端本地时间
  4053. * @param {any} param 埋点内容
  4054. */
  4055. protected log(param: any): void;
  4056. /**
  4057. * 将Object转换成string
  4058. * @param {any} data
  4059. * @returns {string}
  4060. */
  4061. protected data2String(data: any): string;
  4062. }
  4063. declare interface SLSSTSToken {
  4064. access_key_id: string;
  4065. access_key_secret: string;
  4066. expiration: number;
  4067. log_store_debug: string;
  4068. log_store_stats: string;
  4069. project: string;
  4070. region_endpoint: string;
  4071. security_token: string;
  4072. }
  4073. declare interface SLSToken {
  4074. access_key_id: string;
  4075. access_key_secret: string;
  4076. security_token: string;
  4077. region_endpoint: string;
  4078. project: string;
  4079. log_store_stats: string;
  4080. log_store_debug: string;
  4081. expiration: number;
  4082. }
  4083. /**
  4084. * Websocket类
  4085. */
  4086. declare class Socket extends default_2<SocketListener> {
  4087. /**
  4088. * @ignore
  4089. */
  4090. static logName: string;
  4091. protected ws?: WebSocket;
  4092. protected socketStatus: CONNECTSTATUS;
  4093. protected wsUrl: string;
  4094. protected lastConnectStartTime: number;
  4095. protected maxConnectRetryCount: number;
  4096. connectRetryCount: number;
  4097. protected gotErr: boolean;
  4098. protected closedByInvoke: boolean;
  4099. protected isReconnecting: boolean;
  4100. protected networkAvailableChecked: boolean;
  4101. private reconnectTimeoutId;
  4102. constructor(maxConnectRetryCount?: number);
  4103. get connectUrl(): string;
  4104. /**
  4105. * 返回websocket连接的状态
  4106. */
  4107. get connectStatus(): CONNECTSTATUS;
  4108. /**
  4109. * 开始连接
  4110. * @param wsUrl
  4111. */
  4112. start(wsUrl: string): void;
  4113. /**
  4114. * 发送消息
  4115. * @param pkg
  4116. */
  4117. send(pkg: ISendPackage | IResponse): boolean;
  4118. /**
  4119. * 主动断开连接
  4120. */
  4121. close(): void;
  4122. reconnect(): void;
  4123. /**
  4124. * 连接成功
  4125. * @param event
  4126. */
  4127. protected onOpen(event: Event): void;
  4128. /**
  4129. * 收到消息
  4130. * @param event
  4131. */
  4132. protected onMessage(event: MessageEvent): void;
  4133. /**
  4134. * 收到错误
  4135. * @param event
  4136. */
  4137. protected onError(event: Event): void;
  4138. /**
  4139. * 连接断开
  4140. * @param event
  4141. */
  4142. protected onClose(event: CloseEvent): Promise<void>;
  4143. /**
  4144. * 初始化websocket
  4145. */
  4146. protected initWebSocket(): void;
  4147. /**
  4148. * 反初始化websocket
  4149. */
  4150. protected uninitWebsocket(): void;
  4151. }
  4152. /**
  4153. * Socket的支持的事件
  4154. */
  4155. declare interface SocketListener {
  4156. onOpen: (event: Event) => void;
  4157. onMessage: (event: MessageEvent) => void;
  4158. onError: (event: Event) => void;
  4159. onClose: (event: CloseEvent) => void;
  4160. onConnectFail: () => void;
  4161. onAuthInvalid: () => void;
  4162. onNetworkError: () => void;
  4163. onReconnectStart: () => void;
  4164. onReconnectFail: (event: Event) => void;
  4165. }
  4166. declare interface StopPreviewConfig {
  4167. videoElement?: HTMLVideoElement;
  4168. primary?: boolean;
  4169. screen?: boolean;
  4170. }
  4171. declare type StopPublishOptions = StreamOptions;
  4172. declare interface StreamListener {
  4173. [DeviceStatusChange.Remote]: (event: DeviceStatusChangeType) => void;
  4174. error: (err: AliRtcError) => void;
  4175. }
  4176. declare interface StreamOptions {
  4177. audio?: boolean;
  4178. video?: boolean;
  4179. screen?: boolean;
  4180. data?: boolean;
  4181. }
  4182. declare class StsManager extends default_2<StsManagerListener> {
  4183. static logName: string;
  4184. private env;
  4185. private authInfo?;
  4186. private timer?;
  4187. private slsReporter;
  4188. private expiration;
  4189. private skipTime;
  4190. constructor(slsReporter: SLSReporter, env: AliRtcEnv);
  4191. refreshAuthInfo(authInfo: AliRtcAuthInfo): void;
  4192. private requestToken;
  4193. startSTSUpdate(authInfo: AliRtcAuthInfo): void;
  4194. clear(): void;
  4195. }
  4196. declare interface StsManagerListener {
  4197. onTokenUpdate: (ossToken: OSSToken, slsToken: SLSToken) => void;
  4198. }
  4199. declare interface SubConfig {
  4200. isAudioSubscribing: boolean;
  4201. isVideoSubscribing: boolean;
  4202. isScreenSubscribing: boolean;
  4203. audioEnabled: boolean;
  4204. videoEnabled: boolean;
  4205. screenEnabled: boolean;
  4206. }
  4207. declare type SubscribeOptions = StreamOptions & {
  4208. aMsid?: string;
  4209. vMsid?: string;
  4210. };
  4211. declare enum SubscribeReason {
  4212. InRoom = "inRoom",
  4213. Join = "join",
  4214. Publish = "publish",
  4215. User = "user",
  4216. Resume = "resume",
  4217. Retry = "retry",
  4218. Reconnect = "reconnect"
  4219. }
  4220. declare interface TimeRecorder {
  4221. start: number;
  4222. [key: string]: number;
  4223. }
  4224. declare enum TrackEvent_2 {
  4225. VideoTrackEnded = "videoTrackEnded",
  4226. AudioTrackEnded = "audioTrackEnded",
  4227. ScreenTrackEnded = "screenTrackEnded"
  4228. }
  4229. declare interface TrackInfo {
  4230. ssrc: string;
  4231. codec: string;
  4232. msid?: MsidType;
  4233. type: string;
  4234. from?: string | undefined;
  4235. userdata?: string;
  4236. trackId?: string;
  4237. attr?: Record<string, any>;
  4238. pt?: number;
  4239. }
  4240. declare type UnSubscribeOptions = SubscribeOptions;
  4241. declare interface UpdateTracksResult {
  4242. restoreSub?: boolean;
  4243. }
  4244. declare class User extends default_2<UserListener> {
  4245. protected uid: string;
  4246. protected name: string;
  4247. protected rtsManager: RtsManager;
  4248. callId: string;
  4249. protected audioLevelMonitor: AudioLevelMonitor;
  4250. protected audioVolumeIndicationInterval: number;
  4251. constructor(userId: string, displayname: string, rtsManager: RtsManager, interval: number);
  4252. get userId(): string;
  4253. get displayname(): string;
  4254. protected createCallId(): void;
  4255. setUserInfo(uid: string, displayName: string): void;
  4256. refreshUserInfo(uid: string): void;
  4257. /**
  4258. * 获取音频 level
  4259. */
  4260. getAudioLevel(): number;
  4261. enableAudioVolumeIndication(interval: number): void;
  4262. /**
  4263. * 销毁用户,清空数据
  4264. */
  4265. clear(): void;
  4266. }
  4267. declare interface UserListener {
  4268. [DeviceStatusChange.Local]: (status: string) => void;
  4269. [DeviceStatusChange.Remote]: (event: DeviceStatusChangeType, userId: string) => void;
  4270. [ClientEventType.PullStreamStats]: (userId: string, stat: any, pullStreamUrl: string) => void;
  4271. [ClientEventType.RtsSubscribeExceeds]: (userId: string, options?: SubscribeOptions) => void;
  4272. [TrackEvent_2.VideoTrackEnded]: () => void;
  4273. [TrackEvent_2.AudioTrackEnded]: () => void;
  4274. [TrackEvent_2.ScreenTrackEnded]: () => void;
  4275. remoteTrackAvailableChange: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
  4276. audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
  4277. videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
  4278. screenSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
  4279. dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
  4280. audioPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
  4281. videoPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
  4282. dualStreamPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
  4283. screenPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
  4284. dataPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
  4285. localDeviceException: (localDeviceType: AliRtcEngineLocalDeviceType, localDeviceExceptionType: AliRtcEngineLocalDeviceExceptionType, description: string) => void;
  4286. publishDataError: (error: AliRtcError) => void;
  4287. remoteAudioAutoPlayFail: (uid: string) => void;
  4288. remoteVideoAutoPlayFail: (uid: string, track: AliRtcVideoTrack) => void;
  4289. remoteAudioPlayError: (uid: string, reason?: string) => void;
  4290. remoteVideoPlayError: (uid: string, reason?: string) => void;
  4291. remoteSubscribeError: (error: AliRtcError) => void;
  4292. occurError: (error: AliRtcError) => void;
  4293. remoteDataChannelMessage: (uid: string, message: AliRtcDataChannelMsg) => void;
  4294. }
  4295. declare type ValidStatusMap = {
  4296. [ConnectionLatencyStage.CREATE_ENGINE]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.END;
  4297. [ConnectionLatencyStage.JOIN]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.SEND_SIG | ConnectionLatencyStatus.RECV_RST | ConnectionLatencyStatus.END;
  4298. [ConnectionLatencyStage.FIRST_REMOTE]: ConnectionLatencyStatus.RECEIVED | ConnectionLatencyStatus.DECODED | ConnectionLatencyStatus.PLAYED;
  4299. [ConnectionLatencyStage.RECV_NOTIFY_PUBLISH]: any;
  4300. [ConnectionLatencyStage.HANDLE_PUB_TASK]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.END;
  4301. [ConnectionLatencyStage.HANDLE_SUB_TASK]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.END;
  4302. };
  4303. declare type VideoProfileWithSendFramerate = Partial<IProfile & {
  4304. maxSendFrameRate: number;
  4305. }>;
  4306. declare interface VideoScaler {
  4307. getVideoTrack: () => MediaStreamTrack;
  4308. updateOptions: (options: VideoScalerOptions) => void;
  4309. dispose: () => void;
  4310. }
  4311. declare class VideoScalerFactory {
  4312. static isSupport(): boolean;
  4313. /**
  4314. * 获取实例
  4315. * @param {MediaStreamTrack} videoTrack
  4316. * @param {IProfile} profile
  4317. * @return {VideoScaler}
  4318. */
  4319. static getInstance(videoTrack: MediaStreamTrack, options: VideoScalerOptions): VideoScaler;
  4320. }
  4321. declare interface VideoScalerOptions {
  4322. width: number;
  4323. height: number;
  4324. frameRate: number;
  4325. }
  4326. declare enum VideoStreamSource {
  4327. Camera = 0,
  4328. Screen = 1,
  4329. Image = 2
  4330. }
  4331. declare const WrappedAliRtcEngine: typeof AliRtcEngine_2;
  4332. declare type WrappedAliRtcEngine = InstanceType<typeof AliRtcEngine_2>;
  4333. export { WrappedAliRtcEngine as AliRtcEngine }
  4334. export default WrappedAliRtcEngine;
  4335. export { }