aliyun-rtc-sdk.d.ts 162 KB

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