agora的web rtc的sdk库,基于3.0.1进行的一些临时额外处理

AgoraRTCSDK.min.js 859KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770
  1. /*! AgoraRTC|BUILD v3.1.2-0-ge669c7b */
  2. !
  3. function(e, t) {
  4. "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define("AgoraRTC", [], t) : "object" == typeof exports ? exports.AgoraRTC = t() : e.AgoraRTC = t()
  5. } (window, (function() {
  6. return function(e) {
  7. var t = {};
  8. function n(a) {
  9. if (t[a]) return t[a].exports;
  10. var i = t[a] = {
  11. i: a,
  12. l: !1,
  13. exports: {}
  14. };
  15. return e[a].call(i.exports, i, i.exports, n),
  16. i.l = !0,
  17. i.exports
  18. }
  19. return n.m = e,
  20. n.c = t,
  21. n.d = function(e, t, a) {
  22. n.o(e, t) || Object.defineProperty(e, t, {
  23. enumerable: !0,
  24. get: a
  25. })
  26. },
  27. n.r = function(e) {
  28. "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
  29. value: "Module"
  30. }),
  31. Object.defineProperty(e, "__esModule", {
  32. value: !0
  33. })
  34. },
  35. n.t = function(e, t) {
  36. if (1 & t && (e = n(e)), 8 & t) return e;
  37. if (4 & t && "object" == typeof e && e && e.__esModule) return e;
  38. var a = Object.create(null);
  39. if (n.r(a), Object.defineProperty(a, "default", {
  40. enumerable: !0,
  41. value: e
  42. }), 2 & t && "string" != typeof e) for (var i in e) n.d(a, i,
  43. function(t) {
  44. return e[t]
  45. }.bind(null, i));
  46. return a
  47. },
  48. n.n = function(e) {
  49. var t = e && e.__esModule ?
  50. function() {
  51. return e.
  52. default
  53. }:
  54. function() {
  55. return e
  56. };
  57. return n.d(t, "a", t),
  58. t
  59. },
  60. n.o = function(e, t) {
  61. return Object.prototype.hasOwnProperty.call(e, t)
  62. },
  63. n.p = "",
  64. n(n.s = 40)
  65. } ([function(e, t, n) {
  66. "use strict";
  67. n.r(t);
  68. var a, i = n(9),
  69. o = n.n(i),
  70. r = function() {
  71. var e = new Date;
  72. return e.toTimeString().split(" ")[0] + ":" + e.getMilliseconds()
  73. },
  74. s = n(11),
  75. c = n(3),
  76. d = n(2),
  77. u = n(22),
  78. l = n.n(u),
  79. p = n(23),
  80. f = n.n(p),
  81. g = new Array(32).fill(void 0);
  82. function m(e) {
  83. return g[e]
  84. }
  85. g.push(void 0, null, !0, !1);
  86. var v = g.length;
  87. function S(e) {
  88. var t = m(e);
  89. return function(e) {
  90. e < 36 || (g[e] = v, v = e)
  91. } (e),
  92. t
  93. }
  94. var E = new TextDecoder("utf-8", {
  95. ignoreBOM: !0,
  96. fatal: !0
  97. });
  98. E.decode();
  99. var _ = null;
  100. function h() {
  101. return null !== _ && _.buffer === a.memory.buffer || (_ = new Uint8Array(a.memory.buffer)),
  102. _
  103. }
  104. function I(e, t) {
  105. return E.decode(h().subarray(e, e + t))
  106. }
  107. function b(e) {
  108. v === g.length && g.push(g.length + 1);
  109. var t = v;
  110. return v = g[t],
  111. g[t] = e,
  112. t
  113. }
  114. var T = 0,
  115. R = new TextEncoder("utf-8"),
  116. A = "function" == typeof R.encodeInto ?
  117. function(e, t) {
  118. return R.encodeInto(e, t)
  119. }: function(e, t) {
  120. var n = R.encode(e);
  121. return t.set(n),
  122. {
  123. read: e.length,
  124. written: n.length
  125. }
  126. };
  127. var y = null;
  128. function O() {
  129. return null !== y && y.buffer === a.memory.buffer || (y = new Int32Array(a.memory.buffer)),
  130. y
  131. }
  132. var C = function() {
  133. function e() {
  134. l()(this, e)
  135. }
  136. return f()(e, [{
  137. key: "free",
  138. value: function() {
  139. var e = this.ptr;
  140. this.ptr = 0,
  141. a.__wbg_signmanager_free(e)
  142. }
  143. },
  144. {
  145. key: "get_digest",
  146. value: function(e) {
  147. return S(a.signmanager_get_digest(this.ptr, b(e)))
  148. }
  149. }], [{
  150. key: "__wrap",
  151. value: function(t) {
  152. var n = Object.create(e.prototype);
  153. return n.ptr = t,
  154. n
  155. }
  156. },
  157. {
  158. key: "new",
  159. value: function() {
  160. var t = a.signmanager_new();
  161. return e.__wrap(t)
  162. }
  163. }]),
  164. e
  165. } (),
  166. N = !1,
  167. w = null;
  168. var D, k = 0,
  169. L = "free",
  170. P = [],
  171. M = [],
  172. U = 0; (w ? Promise.resolve(w) : new Promise((function(e) {
  173. N || a ||
  174. function e() {
  175. var t = {
  176. wbg: {}
  177. };
  178. t.wbg.__wbindgen_object_drop_ref = function(e) {
  179. S(e)
  180. },
  181. t.wbg.__wbindgen_string_new = function(e, t) {
  182. return b(I(e, t))
  183. },
  184. t.wbg.__wbindgen_string_get = function(e, t) {
  185. var n = m(t),
  186. i = "string" == typeof n ? n: void 0,
  187. o = null == i ? 0 : function(e, t, n) {
  188. if (void 0 === n) {
  189. var a = R.encode(e),
  190. i = t(a.length);
  191. return h().subarray(i, i + a.length).set(a),
  192. T = a.length,
  193. i
  194. }
  195. for (var o = e.length,
  196. r = (i = t(o), h()), s = 0; s < o; s++) {
  197. var c = e.charCodeAt(s);
  198. if (c > 127) break;
  199. r[i + s] = c
  200. }
  201. if (s !== o) {
  202. 0 !== s && (e = e.slice(s)),
  203. i = n(i, o, o = s + 3 * e.length);
  204. var d = h().subarray(i + s, i + o);
  205. s += A(e, d).written
  206. }
  207. return T = s,
  208. i
  209. } (i, a.__wbindgen_malloc, a.__wbindgen_realloc),
  210. r = T;
  211. O()[e / 4 + 1] = r,
  212. O()[e / 4 + 0] = o
  213. },
  214. t.wbg.__wbindgen_throw = function(e, t) {
  215. throw new Error(I(e, t))
  216. };
  217. for (var n = Uint8Array.from(atob("55ZBgM/2Bzm2JGhNn//ljJsSorhWUYE66a1Hf8O7pfQGR2zfol8qRP6CDhsi3iG7nFZu9stSyPq/qu2Rr2w8QkTGP6Gm2cg3J5qsQgq5bcHA9mDpGv/b24uEwsixZVl1eGkdV4SB/6ayw2v48hLmNA+w5UlnTCiWwerzESQPidpSUMbamXL3pU815EQm12GhhZ9aWzo568gdZvXevBc/WHfFKQSuTgWva4e4eSmW7UxpH8sY4HlDsCTMu0WwEB8B95XsZwOp3GLgfOQmJBw036DgIKU+XGn4KpIEq77WE/h6R7sZKsFUp+u+2cDnW7IPNe7xfd9areFo0EUh0/9K9CqxUkLqMB5hlgS1fwQHRzKPhQ7gALyc6HwMCPooS0M1NrzjdfH3vUn0PeQ1GBlnrnXgiu8TunfHg5TcbBfPEbxbyiiow1Np+VEBlHNh00PiAWyu024NHaPbDGfMtzu4WF02fgkh8Pxb7bCSpCZndjTytQgAzfZxk2bbe6NoHHFnsviqYzHVpxoPEk7icHRWcZC28d2muthq673KCMQay1fJcPqSTuYhWUZS5eylIguT33lP+TBbOWQI8KtCzBN5FzqILfKzRkzrJ3L192BUF8SILdwmriv10HU9ZlQAyQA1VdegnzOl/dYk2GGsB3724y7w/7aJLHJzEfwrfIzFd5CoAft7ct+zQW2G4Wm2kpoz6uJfgrNyykQgwCO6pkPy1ADrBUuJon9ySjhgcFru6AKa99wTlIhzBw3FKFt9Aa1/1KWWy7W1wAIGzRTs/7rLXRkKFjNqGVXBdoVNTpHFtfEFsuX0X98ISr0Bennlx0h2Yl/CGNb5Kc7i3bio1XJHX24avcMsEAwfdfskCki4/dkStn7QC97YJC3z+7gD84IiEEeGcnn7gHJyeALr0ssbqDUcKqxEyheyFs9FToJziLB+eYw6nMQLmYTrQyrg3b+3YBdgx7pzNEDSyz3tmaPaikwcLSyB/Igo6U/oP/fS2TZLtmN03m4iS76YrDJAgI+2W1GboabuixVcLdxm6SQ4CzUnHSPl1knhcGhW/+OcKa53tB5j5C4wEpiENv6T9PUu4K0YwtEAqFbd/eN2wVAYCKn/nlVA8uiESxCfgs0411mRFk4i1pixJLPP5AFPG9QFZnj6X19TqmhmIhl8D6Q1rOvPCqPZV/z04HjayX4qPzPzP/5NVilN/sHhQe7ulriGmU/3rj5QEuiOymsL7EdCQMc/4mXDPdVrDBfbt6dnv11oLYGmqOP1oSBj02FtsmYrMn9pRg7HJoCh86jAnzuOYn4tGnQ4gw/89sb64NAXcoIbTIjyiHBAQCCK2Yn4I/fNF10rkQlvSvkpqLG2eYpJmpWrcouNDEUtJFR607oNraLdmUKyLc1g7SNpS+ofp1FL6rua/HFSrb5kTF2Vcy2gl+6MACbFRChKoP/un7IbYJuOima/JWFZcs/MXokIx+ijuqjMtVKaYRTzNI5ncPa2y/EXTNdUUFpMhbE7sa39Uoh6Hci/viXy2KFTNbiw+BkWOPnyOr04LjIYKlJ8ud/KvjuvNUGQOHJvj6tpZJxj97tr0OrgZCAxSHGU5JQfqEd/U0QfzGM8Wh3zdsnd9LhoIIRJAtyA2PmjwJk4zTxeYlgwPqAVTU3+9bA1QD+jLZZ3Ffk3MRq+Ar2RT8YN6ASR4bItt3omBj0LJe0zeGY3OzfhljL6LA1m4+IUp+CzeWo0aEjnvRk3iCJeajgdC+NUGB5qh8PWKtBeC58woavnRjvRNphXS4b9M7Aymcfq26B2YY2lS+wLf763OnGJlVdV/srgyAUJJZjarxom4zrYy23kLFB8zFzWuwSMue5Xm1YWape91JGDuRLIctrJWU47/XfLm6Zgei4xOwq1RcjikGuaZtDwcFg9aKtO+JOGJsCjy9AiPnmt+rmdX83GsT3KtTETnLv6ZQcnGtmt4H8AjFgGYePdQc40cj8VAOV8NCLspyW5w63b3g37GXJrzjm9Fym3fh27psjo5RuTs7XCSrNENxKm9jCcXPqWxyuXJSn6dhdWnw5SAnUjixXviWS4HsnYjw4Xt4cSwkqCB9naLstVXt5D2HgG4fzHFNHvnETft0mrhU81IBDTSyNFdDvFEX8cifoc6FcNq7pzXlotl2ZS1FIzNXddZrdXpBNYZPV52gtCok6ePpUR/Y8jyJpE9P3q8dmFVivVGgmKTcBKMDDbzeOfl4MpOGBtBX/Lab/kzqG42sTyOyGUyOoFXYGMUWJ33GPI2KNa/mW8zVl+imshfbj7PiK1qRUn74KjAkH4wjKnu50AONYUaiveSdwnEc1zCjZSJ3dmBKSxhWAcO2PdHBg5m9+JCiPGCVfK9dzoM8Bm7xx9noJiqt4hNiVa5di1Fd1JRN4rnd1DbKglKpAVSoqvJPxmuyH56TFE4BQjhfKbDMZezQJqx+KXDiW1JWGeDYaPVBWPYeZX6STIzC/DjS7UFlqoKgGGAGP17x8wmMRE6O/axG5jDzloCGxCmrymT0ZGCh4g54O1iDYUtmJr7Bo1d+H9RQj2Y10BxcMkLFTIZVjm9e3vtIbeRx0OdXE1Ou37J/WeJZyPXn1fszvp/KonCqVnt862LrxfoB/0sF5gk4Y/f6LVneU5hun9/V1OVre9XrnDBhcVaQa9Ye6gs8sHW9HCNchaFbkUpxSiyxVEFZIlbejbjSPFlkYOLhtQHduwZWRHWA9akqykJNG3PKvOZAaJG5nWQq8+e4K0JF/AXTKIIr4J7zDt8ZR4xb9T2gxjl1nfqzidMRIY5B4rkw0oetta+j8rqkFpTEGA+hU/tw7bDtpkPYvCguwncnCjwULNFT9I9jXx3H4Ws3WWMCit29F7kGq2Ka+rU/MjnuP0lsXkoB1rr8LawHH5gaf8rajq/BhKrGTIfjDiZG5qz+L7SZBZsMSZZ9pM1QhKju+GTD9iC+9HlhfXMtj94gz8U4h7eGXziEO7lo7LwLL6/DVMrGbkv68JYUYhGz2yBm/8cbQEh5vhakbhmpv1K6XYM9rzdsd9bwYcYt3cfKE3m+/NrUa42+RpJBdFg7cAmxsZ7/0TMyVw6Aqu2gzldb2ag4iLrPNEyW1ywaJ2DXMgPi/sjnDzhuo+vIUrc86j4ZLhT4GAN6uqwbnXq5UDzX7TfuB48oMvvE1sK5q6owkdWfklgnC6pSBpK7wl+e3kuvaYnGRGJJMBQuVgWL1awHrVtfOTsSE1vc0ZdG+a/Jbza6pHbyfi5L7FXJAGdQTk0EP3VT54+F7RZ/MJ9fj56aMxzhJRwQJ6df3cM26qSc5bW/zP3PFXypTOBwzCvVtwGQzkGvDW7XGwgLbTNHDpQXOd2BQ5Zd9bjQqGg+S+kIqWZVZCqVLfyFPF9bEOHfPepL6nRDJUD2l5uRnXqeTvidaSIoqS1Fbc6mLPtYnbp6uuts6Qo8TbMzFuI7NuaPuKnQIyVu7vUGJ8jg1uVOjlMNKdVtLPr9/ZEKVZVj7lsFA+nm3zRjjr1DRKhr/wY1CI1iXKVTeQZ0i2PSnN99j4iVTSwNAYQLWWD+KyZ/xRLVxmZQPuSkLeKBRAkavxjWnIFQb1dn72wMSUdcB9cNCNJNdyTkrl44MRR+pUuiVrTAnTlzL33X32eEYwT+vn564yxFJLUDyIMNjJ0nx+GreKSOglI2et0kAwRHKYFclH9GVTiVlB0TWeUJGD+7JYogF7BizjTGyPOUEWQCguIEmtC4fHD5461T80Z3Mp7rhNTI+Cswuknr9hrIZmpRyFSrSrP8R4S1Cf34Tu4RNrDxpofVK9nGTklZPsYM6eiP29Lx264fsX9oLdYhq7vCwcrRMJ1a5d0QHXUYRV5IqTFBoUSpxkQ6IHHL8ckM4NCzwk8K0CA3pj5Jp2a9wZjfKq7R/eukzQFuhMxV2qgHf2E3t7/SA8N7sMvsmF0p3J96QRE3rA85ekH1q8nrBVujlIqahmL0Qto3+JxdqAfnKMCblQGSKVWZgWLMm82MG/9pjhdkMzG7C2GRLGMty2y8NhX1pZWHNbLOmvaC424LNz/Nl5tkPv7fVbCT2ItB+/dx3ZhVhmgSLd1zL+2PsNFmj7VGBruTttezlo1mDKErjY27nTswjf2fY/Uq8lPcVAgRpJM+m7jS/8dk8cdl7fkY7Tuj4TfiSe0tiNSoJgZwom4+9haoBQ65AifaB7pUiTc0MAXCvG+nDydkRIbKx5fL6gAlyMAnBbQf+Qh1naLfzzwLVTP0EEyoenW2W1zKqfMql5rwGlyCB9mSa2s25yHf4SDSBlgEVMJtplpRgegZvDakpWDKgx3UR4W7yKW+RD7bd7rEa/GQmA/q0RYAOIaXfO/2CgEUPtNhPS2uqy29lBYFPPv5SHQ0t/jRxQLBpe09ateAWKypt9TWS7Z5gynOePS5M2NC16AhF0Xz6s7DUjtI0xNho9Y6GK16J5V8HqHypV/OAz7+VBzTaiR57XGH4r62GoAiJqfWOM7okzKCeeSBnOIKPHtwgM0SQbvCvv7rmS6ZAacu4BbXZ5R9gOhdR9H3bi7lWLBNnqqLPIy0k6m4XBhtl40B6z/5AcJxjtKfwvIExl7VsQRqbW8gpPMsmJZfSp3uC35g1AkP+BJlju3RVoFZNo3JR18A5uc60NGD4zvzIdGTAOth4ZAZx0ZGQItHuNcLz/0CiavJdkjD65h4avf1vf7LFZ1uogJz6vLK3uDisXIBIGkXOlIpxTdjjjTQt6Khy50bYbXsG9JBrSUGhsBWpeRUnq2cZWOifhfueY95gFIDAu37oKR3FQ1YxGMg3UMq+L2VN2rtqodelSHof8SyYZVQWs7L0bjtgolId1tAAjHI7J1/+JIRXeUBjjaGGQAU+az9XFfiqn+VRAGG8JDdP/WmEqjhYpcy00LIBIBzCF9I9mbXCv8IX9fhPlI5NqWGO/v0ikpfn+hb5U16FcPYsx+xLb4la6nSbvrTDP5MthPyeLIIY7ZE/rNU4ajgPmI0/3RvD7WtEbo8UGPjnev55N2ELuFpEPzkNu9MzXqq8K0cWxk4lT2DQPi3rDO8x8i5jX7wWQi8e0neCMb0SUO67zRfaekZONGfaFl47LByciUuy5dhqxMPokhTE2WbzxqCyt/s2TqG66R0ocYHmzv9f7tJ+TES8NFyzL3fhNoZoW5IxWNE+stYWutd3LPwa7HKhhRAbl5uCEbEGjrUzTXwbzG0qvpmNtpnYnmKjzTaSAFNCxfw9edcjaxCiRKKIDd6GS/eDsGBgTvJexDfwGmVWm9jadZhee9jRFiZFtL6m7sY1oQa8F9ycxSuPANXCqWkApcaEfQLkt1yyfeRs5yC5O/6XGJ4TEtJmCTPJFRr95au20STIPgkoEF1mzZ+5ZRtWKUYuWJVZDwcA/lTy6oYp0/d0LGPRUXnXRm0qtIXQVdnoVhKZPeWACt9rujRL57MEDi2kHtfV/ucu+k03bN0fQlbalUJ0faY99GC6L8MO8MXTSmqDAxNSpqpIFPhgHgAg0YK/GZhlQjbQXE4tMDEDO9obNfp4W6m8fdznMesSSRINBG5FDf//DkT9pSRQsIdSg4VK7W7j2d2jsQUIyjJmbd/2zCTaqh0Yq0cH6mS/5g/cq3eGOiJbaCNo6oVwGURzXVAeVaGIfJFhd2A59sVp+rVfe1f8B6bVbCLIKgGUgpUokO0vTg6ouAxXGQKtveMhhBT83ukPIRZ02+qF1kvM+nNCVy8uzrB0+W9QIKbMio2m/7zW78xd5Tf9itocpLbRuNC5cuS/GyRGXw6fzFzjM1UITlQ5dlvoyYxuvb7ol4S1MyhkfMNZbif6/xic0wB3uSScez3oFTRbCHBd0cbJL3cLwfQjCBpGBrRVC7174qW4XWnw0eYGSSzTVSEDOlMaTUIGJO+s7/z8JxaZprcEsoB4+vt9/+uwtM/iyqLVPidu8ZTh+F1rsEWKwZhDAg/giVc6VzRq+DJCrhn81b/LYlLJOdgoAjID2VnwgU+mQhCL6KhgIqqiVraD25UIYEqxMcZ1aRcZvHa8x5gh5onPtsVcl53Xek9BOYqkyj64acX921zwqoY0lmNA81NE7BzVts3cwWDZ4Dk6uuzwtfJuJc7vVS+fdVDEg3ATwC9oG5/Vb1swTyzTsl2V4m+93bSQo5STFG5AruTDWTym6Lxtt4OrAeIVgdoyTJL+keHiHTNiL0/nO5oYwftSQK1aYBuA0e12t/FVN+LsCk0L/hfCCcke89LuP4d46qnFo3NLpHb+NFrvekXVT4GiZgMW2H0orIY0TpS15wlxVUaGCUo7YSN0yWDRU5+p41dCOs5/vXq1do7K+Byjj35/mPlQ+VEDqqF7OIBQrXfHgCXYPy8ye3Ih3io+tYA6nK0/2clIERrpA0AMHKLTGEO7q/IzIcOCwYN9W/ISH4v4uk9MhzNu7Fg2IPCq5CQF1GLuzQu+wNv2h94NIA2UJydawv5X2bHkZjv+kB/WQCYjxUNEU8ssUdxDZstpv2qNAHmI6BMD84olxMiwFdK5J80zc9x7de/cz3ZNIkkGIpMCZJqKKkaLVo1MLnR/h/hQeUvfqJmvkPeIre3EjnliNkKJKL0KNaupHzY7Eoztaj0cNOhJ5dxIRB2is3kLcSK1FZswRJR0B5OXX+Q4UlFIrhR10lIge3Fg5DnaGoZoOyFaaHztrdF251JubDsCZRDSWA0y6ysykO+h4jhXtuWF7D5Wp7B4Hx3EQvKsmPPZYcLevowjlWghHbRBEhwPI3bzjhNWXlqtym5ObYAeYxuHyvyYue2X4651f7Om3+m8KT7Y/JqLWXwgayCdzxHuJidti1ITuf/oXzeCfTRbG5ytXlDk/epX061W6BO074jI7nV518OkYtRJDnPqdDFAf0uWcATfk0h17+gP7GHjy0Rc0Ive9XmvA6gCkoMjNjMEA7GQ3xy7e12DzfNpIfND7GKKojMifTrvkDXrfa3o4wNYktY6/VlBdHtrcH9F7uMWICej/BjZXVX83WFGcVHx3nOXxSL59kE9bSmHc3Xp8iDbPuSG5GIRp3fTFHnmTzzGedl6al2gUbGFKtkC0jFNtKTk2rr8LEObiGgfCoSpTWknvAYDQBoj93s0KiRNPOqgY++Xka2cQiDwqUsLl8/i57YC/V6sy5/NvhViRRZgCzcyjNHGzZsYA5YMtUntyfC1gNFP7cL3AwVA+326NJI7MQJoxTqcHL/YhntsnYTR5R6GVVvFYIlW8Nv9qn3daoGXMz0MoAsXpCzbiHZ0XWkfw2qlJkmZjgQtMAEhHXNgokGRPfOprmtlvNZaNlGB1EjQTVX1Y4tCyJFZhdhID4CowB23uQF16NifyxH+DGnQrnxeklnG7UQV2BRVdr6ZEKZYv7Gj+PbpojzAskvbdtaFsataqPrLDoejjc6ZfPA5zA0iYcCvcNjzuy9SuT0uG8NWMTLv2OsImL++PQV1sifUENAwi4O3yBvzTy4J77B7mMBpjCYGXAyjFGFZL4eAazSmvZ8thJ0FFW+keLHL+ft1dQBKmXY6JatelGebcIC/PyLBHdfX9bRcauGg4xEO7mMl8AjlcPMczkPniNQpiQFqcDJYrFGoxMV2hskxMn0bRQT8Ajc6w6sQYkGl0CQUImPrGfie9dsk4mrCLMIFOqcm0WT8O8AiREEGmooBTO7WI0qk506NsV7ffvc0rVJERJKcyRyCmFZdTSn/SrBfjV7SXT3pQlgluoY4FBUCDDkzwBgjkrE1oFUA3ls+xVP10w5jjBIMwKBSQqRVAEDXw+Dyj+jH3ila8czULWsCKhWd4qGsMFN7++OGBAz9eXHjAO9m++mTXF6qiyG35Q+61yjYQKsBrjR4NNexrwVGqBwAZA6cr5mp8AhoyzPomJ6TLfWEJjEeRI3QsX5oQkNuyF7u650QFka+VjFeNRY6ALklleTW9I0v4ABKDCXTGkjv80vqVNk+FTL0bJK7ndSjjMJD7OBFIEywBPJFrxTdyzocmxEgG0zu1VDgsQuXITYCx1RRty89A/F+CdSAlbMlIkptCC0GrF/jFS8PAU+6TNV1eBqJrCr9BgH1mth8FtdfE7druR+xyZKn5idfUKzGW6ACGF4M61IRoSs9o6xmaj3dnAVQvFWUsMcR6MI3xTKJNyMxkhXhhvT0IxialnG7i/BBzXfMXYh5jl4BXzCSNlxU4+aboEgIDr48/+pfj8J3WcNccFfzV6eiX05qkNktmafoBcxrEsrM8WQV0VVSRybQyXPOqJ1yndwBI6BOGO9oGxGDAd+HcKaZlptCMJsR1Cp3m7F9HpBFSu/NYVj+WSDY7jWSFBlTBSCFyyPEUn8S9NmBVa+mwGVsz0Q+fxe23w1w6wVO7sVnZqRpmXJeXg72QFkl7Qda1lBzn/FW+rRwLvFxCsuad67Wmzab1RJdzPGsuq8AzW6tL+JiwW/VPUSBbBmV1+EjqQ28x1u9W5Eoy7zhsU8NT87CtNbZ0lPEpsoWMewxC80kPanfWPrQXmixWDXXz7uf1kBTr1J/iYuls7fUsyAChXjKcKOaCF4ySqkhMTGmjNqYiG5joBUi/SZpWvgxk28pyIPhf28YULINiqmbWPBKuTCLFruV7JfRgGM87XfNEFc7tgnYx503k/0UXJfpmjx6wKbKcvV5fqrctx+OrIn++TxRxSKlTScEIwd2vG5mg/p5wsQDpiD+X91XbkReKLB25Jvp/IJaJh715RXqBzwCwlY3URonyy+oZoTD8Ym8XMMv/dMllh0LCFZkZFn2gYcLG9iO+I5S/GyxwjajQLQtwH7o+n50vimC+ES8ePOpPDwlu4oG8KhS7NL/OTdIWPIHbSa6/9DfjOq9W66EpaK57R78PpEzVNLkTP2L6lllqDT6SDhIDIvQS3SQbxG96khXgvW/rME+tiXFXi+BC0udi9keyGlc3sLBN3CP3QXzswhBGTxvz2LmRMkU3rLuSkYR1Gzr7vj1VxTN1y1iciA0DswsPZ38eB6X10Uzk6HZqjzBK+EJ5osJJJ/s3b0MFRIWYlM15TPm1uzeOk1zQ96quClQLEZbpxmV/eAduIotXUYQZjWAkTulBJt7kw9uEnLo7OpZrf8k+0ZQP0agcOTLbfrekHji86Mxr7rTwve82mePKoAkkEthE45VI+f1VqpyWNW1kbBbVVfuatKt6MEKqyTUyxSFGHk81kY7CxkgMNexiikN0+IeiUNsfuktjfOAiMfDhbTe4rtxSEPvO4CCUGaktA58TGnSO8rHdCicmGkNrwWsnXgUWjhp8bllNcnQN10TbwxYPAwQKW/JJiYQadr4THXO+vWudiq3I47vqmEM/Ab3Dlq11Q7RmRWntYOEyESbTI8PZYwbtsmjcSwBtTAIHQ5h3I633h3FpOkT2c0PlMjzj0Q/OuqaTVt639fowVppqvSlNcK5KupBnrxfKHQK+SoKSuaO8PNMkYkbcEAc9F0I4uzPfRVP/q5QkvJVsVoJ8BEWW/q1+kivHEMQfb+J2NfJjSTG+WhjHjL8eqi7FgfVewxwmqG9IOnTkwDjAHUaJMIyhVkadW/+GQjLyNP4zyHcLAdWcB5zQ2kc/blAx2RKfG+ON3RfC+iQ5Th7V2i5abkoy0pjfyOwTjIvaq9slSCtoNGBZggBDOiWwau0CX4NAIThFyqu9VWCLr8TsqhQZvQP+xrywovGs6A079U7YBjhEXyQw4Q3rbQY1EQnxTPXNlHfn9vQnuhsJnzx6PZrCqry8fidPz2U1scmAMVPHxa/injIf+hDziEU02xWm9ou67OgebktON9V6wwVotoNOzVNJhiDBlHbktBwOjX1BlJHybLox5y/7NhR7uc8f85O6xdxueabhwtJjYcBzac56v6RbuI9IRvPzOnNbltj8Hh0ftwwhWyHAyiEat0oDSEVZ925jmxJKAqTo4/uHnkozgMDsnkzXPXBDJ1sDTawXy23mXuTJOYV6ZVWrervMaGGGQpgQjAnfP7KPZro+OKt/MpnoM0NeGQgIFAiH7dU7Nl1QbcMiwO6/5nIosJtrFB8w1kpqb6OjI9BgZHG1nzTMGA++HNrl4WQNcq3SajD4C9utQYAu/fETPFMMJeCDwHRCnPuRAlqJ5t0E5h3Wlh1Nw57LQ36kDjC3lS9w0a89eI8ym6BzEA25Cdz3LQAyz94Fvjqp7MyHrpm3PzmsV/tbSLF9NJBjFmzWPQ8Tfgvj3fi8dg78tXvEatqtUhLxsNp2VCU6IzSqafxWw93+Wk47skJv5qxM+tv7CrpYKvWLEylJNEXlh7GHm9UenNf2/szZOl+54P4ZWksh1r6+rphL68QYhmqW7DqKVrc2rjzPYcvFDmKtCGL/F62i3riMV9z+LoLnuVaMn4dtpNNFmQEQ4uEhDfLYU4x8G2OHCz7gnxLCa4zE4CFo9m/+ECmdzziVumHM/P00/BESH2rxUYMBL8/9NRG5fiskFJr4AO0qNUKUCgTRgEiFsTbGXtP4DTTzc8ZAmfNJuJQE5Kp7W7U7QZnBXKepfSHkYTEqgOhqo95Jw9i56kYGt4BWwX50mC27CCW92SVMl4tbUEhBDSB36zgztz5Zts0563Kjc34B+6ZUnMIk+BiQNvqSkZHnk3rHNSaYthO72IWLIxij0hcv7n228yc82FsQLK9jmptjY6estDfH3OSMaAj+poCLKwRFXvXWb6jwM9mG4nu1yug0Cc4L89w4EYek6dnV17VBfIxB2dmFFQdp0kqx3BM9gdMAr0KS7WLOSf3cn5eDItDLP2UW7MWaIR+GJ0EGcEL3ejBdu0to6vDh04JcRMNU55usmSn3jp74myzWE3azMIT96wr39F62c3G/ldGskbqTIMTk3gMg61vNBQ0cJSIxVdcgNb3xFDowwVyIqYz54F8Rqg0uQE4FIiUGZxJhND/AWhkukqIqLLZEpxj07kPBN6Zb2pWht/X5JrC8yJzPlvFhfJndQ4jcgjFyhvymr/a17uxTKHpKNWDEoL4nNa9/Prf7TYRw6Gyo6vcwYcUHk17SMb9aEdVnx24msNCDEKbj0OVzRaA3gFJeXZPObqJKvWqFlavGpxXnP+4ZYTl0Dmcri6vMdwX687ApG+ygiGHZDwNzU68F4JMPQ9JB45vLkCsE2w50QNP1kJZlI56dVGzfK1MyRqP4J6VshesfOT4hzR6MYq373IoONlLvENdYXN6pTxo5eRzQkwk2tZ1zmZqczCytqTEhpweKcBCCZ/FhizgLm8/x5ScBlO0wEXHZm90mpmL1gR/J2CUnz3wDU99YFFKqm01AZ8q2S5Fnh81CbD687c7K2OjWlZgdvEJA9M0JT3eKdIRd9GCx6g1TO5PWTE8OOphUDKdazyYnmMqFhFxfJ//cWJTsgYbol2a7Ob/Q69Fy3kb9K7aZLzH+Kl/uCzWnqTOrQonVL7LTFPr7wbTaepfAl5zSgMInjrGXY+Gspw+fCNgEU1zyC0Suum6VFyHBjdKWft7strrOXqOSQwxsYXp4F013mN9gZyu4Hc84A4dzIHN5UNXmxNn+vPjS82JM6klySWB9pLCzLBUgXiMDllaG6fT2PSBv/b+yaruyWBVcpsOKuEaQ37W3A3t9YFRcgB5rFMDjwOn3c0lfsg+5V+dBX2EmWLTSelNZkeq67CFnxaKtnlsAJRPBqYvoWVZcJKn0zSelrO2TwnailO7zgAHaMRmQYbXo9beBs16JWf7V8LjYGS/DYUKTTE1zKECC/pK1EKf6mxIgmV+mJ+Mc8h04qep+okIIEXaN351J3N0VUk7cEEaOLE1rFF3W4vqRcodPfbLqINF6QtTsfny1+O46J5ahlamZEyxglZtpjEkKd9yKDsgwnzqoAPN5o76IsI+FRaBc8u1qLBWxpKU615chTVegNFR5V4o1T2JGwVkueD6CjAhOplPnRyv8sauMnMy2wEMARR6AmCQ8S5ebL0nCEqjSztMoUyAEjQ6FDYqkGweu48DkBR5HjwlBloKVawYcDezxKBH8WWnMpJKZj1Ol+OHMmg5iq9xDswLx0iTNkujgatOkeRU0c/GmSSH+7GTTMLQJdj51l3EkojjEwWOjw8XBOm88GqC4bWPEE+U/5XYtZNJG/X4FYjgIvVd69RYVbMEMfPSKJ825e3XQ6RBesp/G+lkMk4VIxRakyUBPLO1u0UYnNG9ExAnPdOO0OfFvcPOL9rBJO8bR+q9Lp9/i+fH32KkaNR2WgoxQY3FY+rS2NUvtCOgZAaF9vny16WG/3zeUtRP9V28PcGivAHAwwCcRk0D0iohjAfgL/EKXJkr8gIFqbNq7lXUFRKqMbpBa182ol77SqJq1M5setGUJuSBKqYBYKdDZv3XdT/u6J5aKKkLvA5ez6PuWX0RT7kELSKDKfg9w9nwSmMmJHjbnr0blM2WvpiirR/nLid6SRN9+5KoLUb+pLw3QzD8JlS3X2q0m4BNRxfltr5KWqryOuuGDt6IOHSE8/zqGXMiTqgrUOfDH58NoWe0te4mFc1GxswvhZXWJZmaWaMJo2SBnuXa7+jIfFbnhNH74Z6jygwcqXsldYfI/Zh8BZbqTh2I7Hu44dilfbX8Uh18NVB3phRnTwpUonKquUs/iZXRnDFjtEmKg2YRQm2CP1FWRb/B92HqJlHT7Hs/Tpl3RrlxvkoskpNlW53/6Ujse0fkHLNeUm97TlDsaRXpfZkR1uWMTwhPv4oYM2Bv941R+c7nQ0yBdFNVQpZRkpejmIfjFrdQUA7DPwR69aq6Pzmk3IXarIMKG6R4MBdkB3j3HWxohnZLWpaNy/BMxS+84e4vPPfO/7+nLWVZsdpUY/nGDkQts0NGnRpZK/lW60tmncMoTepY5fMbow1GyKhqSXLbOZkz59l8DG9v9ZHPwA1roKz3MW/j2tN/U+lPQVYXTa6h1ePQkSWR2bp9OHmCCvT6s8v9PVG2ufK7dkbpY500gNx7fdArzH3yCjY33Fa5TbOuybLNdW8juJyJtikDn+5jMnMzIWP/+v12XkaXj195xk6eOKuvA5zeKk1i1PrSnmWA46Ca2ldgNqJ0rvLqM9X2EPn/QuMjLnLg0iVJ4H4r5S2PgpGdSdfVoiX/rBAq6yVDc30v8DOUae4oquSM0YDCIafLQ+hvEmB5b/f+QsTFtAR0zIVWeLyYbmrx3g9gHhVRfelCz9/exh19AGsyXcwuSaBiCzQIoctYvyhhkdCsC/cdZDce/1Fav35JQt+RJFAjiMRQhCdE4eS3SmfsREHe9LZa0ElOLhxxvs5uS/SnMYssyK9FxiucRjjOqfaIp2N8CmuNJqg3WvtMk+MlbAYeji9K94rx6U7nj9L1TGhVcAyz+Gb4sib21AW94HRzWbTrRKEkx5+KLE69Vc+8Cj1Vu2GkZ1AA2E4kaJ2aTjsEL2C0srAINXRAjnxwI3p5ED0NRYn9sT1iY9GPBJwhhd6WXEJ/Z44D0rufaDOA8dUj1SIqywRs2b7SjYcCYS8eefkwdWlpN0DvnecdwHVc3TqyCcUy7K2PMS2l2KZHzZfLCTCPaPq/NVc/Nlc5hVJoFvnNUpKWZcTsxVeHfH1mnELREECq9YES9v6FcvONCxXLQmf0k3S2dyNmsxbvlXM0u7lSqkx81md0rad3E33PPuPpDGM9UiBhSeJn3Sejmx+LdLCiZYcVxow59nCqrUmXGAbsR4O7wVQzyHdL6DX5s8k5BjHXlONz0PaIqS89xMhkYetMw6w7JZ5c/oJBH2jdZPbS6KbR0RpEe16BATLzU4QiHybxArrjBM8MKKP8Zz6MVbg/d8yb76U8nQzCK4Eqa5ombBm7/6xo2dR9O/ByfcU6qDu+efdLFAP4LiCr6C3aihDPjigUYuy0voLuX3Flevl7xXRtRZ4Vc48j2tgA7tK0wqv4OjLwCzZJn9lYIQuScQBEFMBjA6Vj8FTp4h3OphB6g0uA13nTnVLmKQ+zfELl+6znWX5nCWvbwak0t3q4qwWK3MAPKE2vqDEeCsFKvmJ2Ws+VOqnrA+ekCk9jaszBsZd71InADWijT4SHnyVmc55dv5ivXl1fED4vwNrxbiZHWeGinS3ImcoDAT1vGiLpP/D3NaiIPq9A2h5DT5SgaCVCh0JKu7DKsHjW9ZAACRxHgTSo5jrVWUJfGKweg2auQuittVidB+JaCdwYd0x9oJ4jyI5UygrB9Nzi2gbLVcCnpu+1ytsiWCbJb1Xxas8FhG/EX86taG6flZZauhaGnpRyfBB5ojGdsdPBVHEtb8R951oaNTvKXK7CddSeWaeOi2FIDPEhWhAk19RzuR9wSKEwvvi8nQFz649+fUlBMuDL7VmUBSsC1ExWwqY+uSdNKowEkpsBb+/KpWl6oGxymyR/e4uKjipBJrVPXg0nE2j6HL2JbCHNh01lV+/+6FUglhV8GTypzdvdfhYc7t0ZYtkyH/17wDakU7r1GAdUIXXmtxamhK2FdelBa4BPryblCC9gJG9htJue9LMrNS7mM6gbRA1xSFnWNsziDuGZeS3Dcu4bjsWaIebrgNnxpl/pLGxV5EtkFwDeh8fPyfPU8CZAM/Ljk3+Vi7jUtNZmZM8+f7d4wlUIkTHiAULRUKu0ODFIeyk20BiqLB7vvAT342SIDP+z5FPaa6Tjyqh/AsX2jFhbeIXKxDMb8fid0jHAWk6JKhswbtvtP6bDz+lYjvXIPwV1Y+nyft2uM8c1aUxmDHAUmZnJBvZXT43mxjXDHP05R1/dKfoExcgcYzv3wO5mazi7ugS01z6oUmByKtfQ6fA2+MQynPCoDHcp1eDtag/E3HQpHMWAgGkNh9wWR5Y48YG0W4CgvOrngI111j/x+MIuH5xFlVkxqptSjW+hnVbt9qxtXndEH5RtnxWfd9eP+kli/x3LU1WGsZVAkVElXD274LBGK0bMveEUbj/6EpnocEnvRSlglpE4GiAO5S4JdYb4uYd6oeK8vuZvTQaWMS3dEIJ2ssCxWz8DqYmc/b38ynz0DWCCeF1gCyipaLG2Kq9wqfHz3S6m7CS+H42nmDYAz2dYcx77M8purGOS5tQ4aykJXIDQBwHjIGSU+52M+1OV53rp4B3JbIXecQWEjfk9gkVoz8T6HJbIhFgm3quNMk+cIyRHlj/BdURXY8o7H7dBQfsdpLJhAsxS/1JtMkY8JoP4YdyOxzJY5x/+A9scOTXvPVoQAMqgmP899s6GvRtzNFGXLX7VHSnUj7VPO8K1qxaS/a/6v/YhRlUtNgnqnth3Jo/DKbdhdPn6HgB9YjU5GuN1uPyUXZJDZYfFwMfdqNPVoI8d1csoHMK5tquGoK060mIwBHMk3pFGqBosajr9g/5kBPrrtuIIEPFZnaAKSCQqLdeQq2B6Bs8WxD8+DfzGJ2nu0Xeb58spPoiHZAVV+I5lRUseUE0IA4E844UzFYADNYcLBW3zsP7aWzLnUZoQPuIDR3FX3bkM5mCunvXaPSi4PRkKnItEv8/OYiq8RSKQcaTwxX9YgdNbgPuXLwb5ARofv0Zj3WpHhNnlTq2Qu/lwvM3PUaqv8L7kpFqQR9aRaXfFanbLgbyxJ2kAx9oA1kRMyH3JXI06oQhRiZQ1LtWz+QKKxme0zAgI2q6/dmYApsA7WGeBae5+Y3eqkqDjXyS7Q+LzYgrM3EiqGHsibaKZKgFecxpGiMLXY5+kkuDKBdMkj2Bd8uTKI+aTWpu97gNp78fm891zYuT68sIEzE5JggpWjlWFSpzYayxvnOxJ3JYK/q8WbCy14KhtCFhdLOxCEAvyqXN3K+oP52ZzdxHiCAac5LX2TO5CTmkxp6zCT5JZDIBgnnmQU8GBowEvogfPni17fE1sljd55P2C4mWCNDr8l3hMH+4zpyZqp3iFbJx20nGtU+9LJozl0OxNrk/c0C9chEe+k4vUECnUaXbS8JqdnymqbZ1SCI+4+1BYMW4nzYKDLaqL3Nm08C/Ug7zNg2BuwhWepXrkqaRX58LCWLPDQyUzn369E1drtekeuNcI4SgdmyQZ/7xhXZ6sOKg9G/HEiJQsriRQThvHz4BhaFaXic4nlrz4LhUthGBLbnnB6tufJizYx4c6b2rY1E63pLDA8QdZsTOD7euNMku1a0T2nNQ9rOPBYPDyksaP+EmKTvqcgRycKMtzhHh37mAqVERuzIIMs/zXE9jGBpJBBWb8KCPZne6Sxw0+UFlY6/VeXJUHunHXY1csfc40Tw95XrkpLzxqX/LrsaYM7Y0UQ/Qe6PTjMQUXDseSMhYwHTXCohySQ+1fIjz/yjZWRFI1/a4d9eQzWLoGjz8O8ldPhzhpWFwwlaR0T1gpMP3VeHvDOx4RJocHJOSRQ+H4/nHJsiuXWDKowYZZW8Jk9vUiw2jExedn7glAsC/bgN1NrgIp1y+y3tmLd2V9x7yKVC+QK6MOFq19dlQflj350qUavBULMCTn0BvCRQY4q6VjniU6XHISUsaApCVoQeevAOuCUFcnwWfK+44XDo1qSpPF1wcnbH7N9aO+AzD212PgFlGkXlaQ3Gbfz9XIUMjulgGUREelr6IX+tR2K9H/yep959z5WLXlZ81Z8HCIV8CyU0JKYzkIeFqf6o2ywb2O73oRi7i8F6Vcn2zU1VWZpLfSXgTNkRtqM7r5s13UimLWtAVZs97rLcMRlwXzYp98ZnKvQLj/dpKn8nfNnU9V2Bp90frlQedeKt6zd4mPR53FKQ1J4r95n1G8ph0XG37DC9b185sWbnoyC4Q1iUvyy5IOxBrIqbqn/JSUWzdrlOiZGDJrU5IGuzUl5TaupUTIgFeLfT6uh0gIEJ5nZQ/8XjB0mmEZxTvocrU/BFoOaUvV/N48W3W/aQu5nR3KwsSByfSDAEq6qBqTVTkZtkaAd/1Rie2jkdRlZvxFMu0MGnLc0SHPII8eOz/bjfIhSQhAb38dSRcFmfRb+fpDrDHeazED6EHNayy0kESoRG+XFbJa6xWB6OlbwHVDwdO9Ka7bIOqLRHpZjwXmv/2DR9nu+2xwxE39cBHq/7Vv99HcvH8ZJeGmgHr8mBKQmOCTkvLkxf5k4FrqZuNpaRNhCB3puFuF5d2nnQbhgAaANLMCYAiGsJhX2bFM/r3BGhR/dkGPXeBQUJ4tTARQnVqA07mW/42Dv2k7Wa7hWU/wv7FTIWLwWyHX0Vqdg4BHrlJ7zh+b+T6fH+W3d53LS5rkXK5GIctMIttK+osfGYIvOD0BkkXBJR0EYUmteToIxpoaMVKZmCRC2BbmBLdUTIZiI1kVYKYnq9Q5xMGODu+6vCT2ofvYE0pmGbQ9Ln6wnBDYZUD/BL9rmiPn3n28Zs33OsHUQcLp2vjUEV5sOBLO2ScyescGu0N58y1q1NSNJuXCzI4fu4RWJtSIn3P3+9eAsMo/2NupFeaf70/usLGd2Z0F27EjLoIj+nmJ4/Q5edPFhVNpPURQrUzPALNNzEvx3e82rDtPpbZjugv7Abm2q2vMGwz5W+hGH0hkCzXdZhPFbLk0sR5vVhScLgAPdZIVZIjTuzwIKVuWmvpMr7Gwxgiglpy8ecfOAZcCpXRzG6lNuRB64D4G9AWD9vQi/crWV4Xq5VjJnRjQc3g4bJe+MmksjEctghn27n5i5PHZvW/gM0BsXzo8Pou6yOLnp49dGXpK/oLAbOdOel9h+kDqEtZunvsXa9EFomdl0QbDvk+H58SjszCVqVOXSgDpOdZjXWfZpFL6S/fd1Lq8FQS3LklgiNhdvE5GzgSO8uq3gtj8I2o+JzucnrUSrtoxa6IejmVQLGzF3rSCy3fdhBPhZnDdgctC89dRJ+PTfW4ga5WWAyaWspzFg5251FoByB8LUbD3AxhvV6M1ARNXRJ4NhPe2j9WOlu5I2KmCMGvGP5CbHAyZk3YhiuIdtDgOvre9Cz0yOWvHH5FpZQzqzyHE5XkTTFMU2JhG1nvne9SCi9zNvPnGj9h/bQXgpue78rpogXJl8oDSfMwz9fp4ocyOxEV1JCEslSsRvodEzPbUsMUYWDERNzR6f45Ku6EmW3qdD48dcFQtc9rr2wF3o85edZ/2SY0BSkOdQX1ahwPVBP554Q1Z4lbd0d/vrRCO5k3QBWOb3iML0vI4MRkiKwqt735Q2fkq0Xl1pI3nk4ll51cSEHOrFTctkxwLOiQl6HJh2q3iqHFmtOCSo0A4YLl+mllolm7FLpe/79gMoe7A5cbFPCbX9Z3GhI43FgBbWoq8pwaIoDlklRimVauOx355pv7v26P0MLrgiqWTOxJaIGO/UhHf7GSOm0r1O5m1sPYYn1bathmEkYfrQLiEWQ2/3IjunsIxgAmi6t4JsxalYxE4YyvD59EpzvswOjZUvSgkHwPZonVtaiMTLXnV3p0dKpCSSz38Kv8QbNFzqLbwbBBRUHw/nHSxNipNm5vtjfkuf06jWRwkctgu8wZqKwS/7IcGnFtmwnbJFPhpGcyV9GVFzCCG+TOeNgAWxOUPgmtLdD8JawVVDV+e3iR8kHuaZXIknncI/3uFnblTd2P/OdWvxl+9CXbqJb1CS8osg2fg/qaA9KvM3FQoZQ79JRZC/Upm90ABPCGzksTWJ7Xy9VHpnPZCgGzAVbJhmurq8tm24BjBvnm1GOKfotvCqXyIXFE1bYTRS1WtzgZrGWgR/oOUDnNgDPXqUfTmyFPfNCD9MX22hvuBans/Kl1DustiTunl9Kravj0NG1Ds5nkTqlQSYOfhgvRIowimmWAYWma55eqvaQL9GvHmuH/hIVB/tiN6s7yOW2iahReL8dNddIbMJ6BLVguJ4n1dnquV3ZNqi6V0H/Vn00j0cE80ERsZTgsHPJ0eUjxYik+eDtaEHnyAsYeR2AjRcGw=="), (function(e) {
  218. return e.charCodeAt(0)
  219. })), i = new Uint8Array([177, 156, 215, 89, 13, 111, 230, 1]), o = new Uint8Array(n.length), r = new Uint8Array(256), s = 0; s < 256; s++) r[s] = s;
  220. var c, d = 0;
  221. for (s = 0; s < 256; s++) {
  222. d = (d + r[s] + i[s % i.length]) % 256;
  223. var u = [r[d], r[s]];
  224. r[s] = u[0],
  225. r[d] = u[1]
  226. }
  227. s = 0,
  228. d = 0;
  229. for (var l = 0; l < 0 + n.length; l++) {
  230. d = (d + r[s = (s + 1) % 256]) % 256;
  231. var p = [r[d], r[s]];
  232. r[s] = p[0],
  233. r[d] = p[1],
  234. c = r[(r[s] + r[d]) % 256],
  235. l >= 0 && (o[l - 0] = n[l - 0] ^ c)
  236. }
  237. return N = !0,
  238. new Promise((function(n) { (function(e, t) {
  239. return WebAssembly.instantiate(e, t)
  240. })(o.buffer, t).then((function(t) {
  241. N = !1,
  242. a = t.instance.exports,
  243. e.__wbindgen_wasm_module = t.module,
  244. n()
  245. }))
  246. }))
  247. } ().then((function() {
  248. w = C.new(),
  249. e(w)
  250. }))
  251. }))).then((function(e) {
  252. D = e
  253. })),
  254. setInterval((function() {
  255. Object(c.getParameter)("UPLOAD_LOG") && x.info("console log upload")
  256. }), 9e5);
  257. var x = function() {
  258. var e, t, n, a, i, u, l = null,
  259. p = ["DEBUG", "INFO", "WARNING", "ERROR", "NONE"],
  260. f = 0,
  261. g = function(e, t, n) {
  262. var a = {};
  263. Array.isArray(e) || (e = [e]),
  264. e = e.map((function(e) {
  265. return {
  266. log_item_id: k++,
  267. log_level: e.log_level,
  268. payload_str: e.payload
  269. }
  270. })),
  271. a = {
  272. timestamp: Date.now(),
  273. sdk_version: c.VERSION,
  274. process_id: Object(d.a)(),
  275. payload: JSON.stringify(e)
  276. },
  277. D ? a.hash = D.get_digest("".concat(a.payload).concat(a.process_id).concat(a.timestamp)) : n && n();
  278. try {
  279. var i = l || "https://".concat(Object(c.getParameter)("LOG_UPLOAD_SERVER"), "/upload/v2");
  280. Object(s.post)(i, a, (function(e) {
  281. "OK" === e ? t && t(e) : n && n(e)
  282. }), (function(e) {
  283. n && n(e)
  284. }), {
  285. withCredentials: !0
  286. })
  287. } catch(e) {
  288. n && n(e)
  289. }
  290. },
  291. m = function(e, t) {
  292. if (Object(c.getParameter)("UPLOAD_LOG")) try {
  293. t = Array.prototype.slice.call(t);
  294. var n = "";
  295. t.forEach((function(e) {
  296. "object" === o()(e) && (e = JSON.stringify(e)),
  297. n = n + e + " "
  298. })),
  299. P.push({
  300. payload: n,
  301. log_level: e
  302. }),
  303. "free" === L &&
  304. function e(t) {
  305. L = "uploading",
  306. setTimeout((function() {
  307. g(t, (function() {
  308. U = 0,
  309. 0 !== P.length ? (M = P.length < 10 ? P.splice(0, P.length) : P.splice(0, 10), e(M)) : L = "free"
  310. }), (function() {
  311. setTimeout((function() {
  312. e(M)
  313. }), U++<2 ? 200 : 1e4)
  314. }))
  315. }), 3e3)
  316. } (M = P.length < 10 ? P.splice(0, P.length) : P.splice(0, 10))
  317. } catch(e) {}
  318. };
  319. t = function() {
  320. for (var t = [0], n = 0; n < arguments.length; n++) t.push(arguments[n]);
  321. e.apply(this, t)
  322. },
  323. n = function() {
  324. for (var t = [1], n = 0; n < arguments.length; n++) t.push(arguments[n]);
  325. e.apply(this, t)
  326. },
  327. a = function() {
  328. for (var t = [2], n = 0; n < arguments.length; n++) t.push(arguments[n]);
  329. e.apply(this, t)
  330. },
  331. i = function() {
  332. for (var t = [3], n = 0; n < arguments.length; n++) t.push(arguments[n]);
  333. e.apply(this, t)
  334. };
  335. var v = {};
  336. return u = function(e) {
  337. v[e] || (a.apply(void 0, arguments), v[e] = !0)
  338. },
  339. {
  340. DEBUG: 0,
  341. INFO: 1,
  342. WARNING: 2,
  343. ERROR: 3,
  344. NONE: 4,
  345. enableLogUpload: function() {
  346. Object(c.setParameter)("UPLOAD_LOG", !0)
  347. },
  348. disableLogUpload: function() {
  349. Object(c.setParameter)("UPLOAD_LOG", !1)
  350. },
  351. setProxyServer: function(e) {
  352. l = e ? "https://".concat(l, "/ls/?h=").concat(Object(c.getParameter)("LOG_UPLOAD_SERVER"), "&p=443&d=upload/v2") : "https://".concat(Object(c.getParameter)("LOG_UPLOAD_SERVER"), "/upload/v2")
  353. },
  354. setLogLevel: function(e) {
  355. e > 4 ? e = 4 : e < 0 && (e = 0),
  356. f = e
  357. },
  358. log: e = function() {
  359. var e = arguments[0],
  360. t = arguments;
  361. if (t[0] = r() + " Agora-SDK [" + (p[e] || "DEFAULT") + "]:", m(e, t), !(e < f)) switch (e) {
  362. case 0:
  363. case 1:
  364. console.log.apply(console, t);
  365. break;
  366. case 2:
  367. console.warn.apply(console, t);
  368. break;
  369. case 3:
  370. console.log.apply(console, t);
  371. break;
  372. default:
  373. return void console.log.apply(console, t)
  374. }
  375. },
  376. debug: t,
  377. info: n,
  378. warning: a,
  379. deprecate: u,
  380. error: i
  381. }
  382. } ();
  383. t.
  384. default = x
  385. },
  386. function(e, t, n) {
  387. "use strict";
  388. n.r(t),
  389. n.d(t, "checkValidObject", (function() {
  390. return r
  391. })),
  392. n.d(t, "checkValidString", (function() {
  393. return s
  394. })),
  395. n.d(t, "checkValidNumber", (function() {
  396. return c
  397. })),
  398. n.d(t, "checkValidFloatNumber", (function() {
  399. return d
  400. })),
  401. n.d(t, "checkValidBoolean", (function() {
  402. return u
  403. })),
  404. n.d(t, "checkValidEnum", (function() {
  405. return o
  406. })),
  407. n.d(t, "isValidString", (function() {
  408. return l
  409. })),
  410. n.d(t, "isValidNumber", (function() {
  411. return p
  412. })),
  413. n.d(t, "isValidBoolean", (function() {
  414. return g
  415. })),
  416. n.d(t, "isASCII", (function() {
  417. return S
  418. })),
  419. n.d(t, "isInteger", (function() {
  420. return E
  421. })),
  422. n.d(t, "isNumber", (function() {
  423. return _
  424. })),
  425. n.d(t, "isString", (function() {
  426. return h
  427. })),
  428. n.d(t, "isArray", (function() {
  429. return I
  430. })),
  431. n.d(t, "isEmpty", (function() {
  432. return b
  433. })),
  434. n.d(t, "isValidToken", (function() {
  435. return m
  436. })),
  437. n.d(t, "isValidChannelName", (function() {
  438. return v
  439. }));
  440. var a = n(9),
  441. i = n.n(a),
  442. o = function(e, t, n) {
  443. for (var a = 0; a < n.length; a++) if (e === n[a]) return ! 0;
  444. throw new Error("".concat(t, " can only be set as ").concat(JSON.stringify(n)))
  445. },
  446. r = function(e, t) {
  447. if (!e) throw new Error("Invalid param: ".concat(t || "param", " cannot be empty"));
  448. if ("object" !== i()(e)) throw new Error("".concat(t || "This paramter", " is of the object type"));
  449. return ! 0
  450. },
  451. s = function(e, t, n, a, i) {
  452. if (b(n) && (n = 1), a = a || 255, b(i) && (i = !0), b(e)) throw new Error("".concat(t || "param", " cannot be empty"));
  453. if (!l(e, n, a, i)) throw new Error("Invalid ".concat(t || "string param", ": Length of the string: [").concat(n, ",").concat(a, "].").concat(i ? " ASCII characters only.": ""))
  454. },
  455. c = function(e, t, n, a) {
  456. if (b(n) && (n = 1), a = a || 1e4, b(e)) throw new Error("".concat(t || "param", " cannot be empty"));
  457. if (!p(e, n, a)) throw new Error("Invalid ".concat(t || "number param", ": The value range is [").concat(n, ",").concat(a, "]. integer only"))
  458. },
  459. d = function(e, t, n, a) {
  460. if (null == e) throw new Error("".concat(t || "param", " cannot be null"));
  461. if (b(n) && (n = 0), a = a || 1e4, b(e)) throw new Error("".concat(t || "param", " cannot be empty"));
  462. if (!f(e, n, a)) throw new Error("Invalid ".concat(t || "number param", ": The value range is [").concat(n, ",").concat(a, "]."))
  463. },
  464. u = function(e, t) {
  465. if (b(e)) throw new Error("".concat(t || "param", " cannot be empty"));
  466. if (!g(e)) throw new Error("Invalid ".concat(t || "boolean param", ": The value is of the boolean type."))
  467. },
  468. l = function(e, t, n, a) {
  469. return t || (t = 0),
  470. n || (n = Number.MAX_SAFE_INTEGER),
  471. b(a) && (a = !0),
  472. h(e) && (!a || S(e)) && e.length >= t && e.length <= n
  473. },
  474. p = function(e, t, n) {
  475. return E(e) && e >= t && e <= n
  476. },
  477. f = function(e, t, n) {
  478. return _(e) && e >= t && e <= n
  479. },
  480. g = function(e) {
  481. return "boolean" == typeof e
  482. },
  483. m = function(e) {
  484. return l(e, 1, 2047)
  485. },
  486. v = function(e) {
  487. return h(e) && /^[a-zA-Z0-9 \!\#\$\%\&\(\)\+\-\:\;\<\=\.\>\?\@\[\]\^\_\{\}\|\~\,]{1,64}$/.test(e)
  488. },
  489. S = function(e) {
  490. if ("string" == typeof e) {
  491. for (var t = 0; t < e.length; t++) {
  492. var n = e.charCodeAt(t);
  493. if (n < 0 || n > 255) return ! 1
  494. }
  495. return ! 0
  496. }
  497. },
  498. E = function(e) {
  499. return "number" == typeof e && e % 1 == 0
  500. },
  501. _ = function(e) {
  502. return "number" == typeof e
  503. },
  504. h = function(e) {
  505. return "string" == typeof e
  506. },
  507. I = function(e) {
  508. return e instanceof Array
  509. },
  510. b = function(e) {
  511. return null == e
  512. }
  513. },
  514. function(e, t, n) {
  515. "use strict";
  516. n.d(t, "b", (function() {
  517. return _
  518. })),
  519. n.d(t, "a", (function() {
  520. return E
  521. }));
  522. var a = n(21),
  523. i = n.n(a),
  524. o = n(6),
  525. r = n.n(o),
  526. s = n(3),
  527. c = n(0),
  528. d = n(11),
  529. u = n(15),
  530. l = n.n(u);
  531. function p(e, t) {
  532. var n = Object.keys(e);
  533. if (Object.getOwnPropertySymbols) {
  534. var a = Object.getOwnPropertySymbols(e);
  535. t && (a = a.filter((function(t) {
  536. return Object.getOwnPropertyDescriptor(e, t).enumerable
  537. }))),
  538. n.push.apply(n, a)
  539. }
  540. return n
  541. }
  542. function f(e) {
  543. for (var t = 1; t < arguments.length; t++) {
  544. var n = null != arguments[t] ? arguments[t] : {};
  545. t % 2 ? p(Object(n), !0).forEach((function(t) {
  546. i()(e, t, n[t])
  547. })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : p(Object(n)).forEach((function(t) {
  548. Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t))
  549. }))
  550. }
  551. return e
  552. }
  553. var g, m, v = {
  554. eventType: null,
  555. sid: null,
  556. lts: null,
  557. success: null,
  558. cname: null,
  559. uid: null,
  560. peer: null,
  561. cid: null,
  562. elapse: null,
  563. extend: null,
  564. vid: 0
  565. },
  566. S = null,
  567. E = function() {
  568. return S || (S = "process-" + l()(), c.
  569. default.info("processId: " + S)),
  570. S
  571. },
  572. _ = (m = 0, (g = {
  573. list: {},
  574. setProxyServer: function(e) {
  575. g.proxyServerURL = e
  576. },
  577. getUrl: function() {
  578. return g.proxyServerURL ? "https://".concat(g.proxyServerURL, "/rs/?h=").concat(Object(s.getParameter)("EVENT_REPORT_DOMAIN"), "&p=6443&d=events/message") : "https://".concat(Object(s.getParameter)("EVENT_REPORT_DOMAIN"), ":6443/events/message")
  579. },
  580. getBackUrl: function() {
  581. return g.proxyServerURL ? "https://".concat(g.proxyServerURL, "/rs/?h=").concat(Object(s.getParameter)("EVENT_REPORT_BACKUP_DOMAIN"), "&p=6443&d=events/message") : "https://".concat(Object(s.getParameter)("EVENT_REPORT_BACKUP_DOMAIN"), ":6443/events/message")
  582. },
  583. getSessionStartTime: function(e) {
  584. return g.list[e].startTime
  585. },
  586. sessionInit: function(e, t) {
  587. var n = r()({},
  588. v);
  589. n.startTime = +new Date,
  590. n.sid = e,
  591. n.cname = t.cname,
  592. g.list[e] = n;
  593. var a = r()({},
  594. {
  595. willUploadConsoleLog: Object(s.getParameter)("UPLOAD_LOG"),
  596. areaVersion: "global"
  597. },
  598. t.extend),
  599. i = r()({},
  600. n);
  601. i.eventType = "session_init",
  602. i.appid = t.appid,
  603. i.browser = navigator.userAgent,
  604. i.build = s.BUILD,
  605. i.lts = +new Date,
  606. i.elapse = i.lts - i.startTime,
  607. i.extend = JSON.stringify(a),
  608. i.mode = t.mode,
  609. i.process = E(),
  610. i.success = t.succ,
  611. i.version = s.VERSION,
  612. delete i.startTime,
  613. g.send({
  614. type: "io.agora.pb.Wrtc.Session",
  615. data: i
  616. }),
  617. g._flushInvokeReport(e)
  618. },
  619. joinChooseServer: function(e, t, n) {
  620. if (g.list[e]) {
  621. t.uid && (g.list[e].uid = parseInt(t.uid)),
  622. t.cid && (g.list[e].cid = parseInt(t.cid));
  623. var a = r()({},
  624. g.list[e]);
  625. a.eventType = "join_choose_server";
  626. var i = t.lts;
  627. a.lts = Date.now(),
  628. a.eventElapse = a.lts - i,
  629. a.chooseServerAddr = t.csAddr,
  630. a.errorCode = t.ec,
  631. a.elapse = a.lts - a.startTime,
  632. a.success = t.succ,
  633. a.chooseServerAddrList = JSON.stringify(t.serverList),
  634. delete a.startTime,
  635. g.send({
  636. type: "io.agora.pb.Wrtc.JoinChooseServer",
  637. data: a
  638. })
  639. }
  640. },
  641. reqUserAccount: function(e, t) {
  642. t.vid && (g.list[e].vid = t.vid);
  643. var n = r()({},
  644. g.list[e]),
  645. a = t.lts;
  646. n.eventType = "req_user_account",
  647. n.lts = Date.now(),
  648. n.success = t.success,
  649. n.serverAddress = t.serverAddress,
  650. n.stringUid = t.stringUid,
  651. n.uid = t.uid,
  652. n.errorCode = t.errorCode,
  653. n.elapse = n.lts - n.startTime,
  654. n.eventElapse = n.lts - a,
  655. n.extend = "string" == typeof t.extend ? t.extend: JSON.stringify(t.extend),
  656. delete n.startTime,
  657. g.send({
  658. type: "io.agora.pb.Wrtc.ReqUserAccount",
  659. data: n
  660. })
  661. },
  662. joinGateway: function(e, t) {
  663. t.vid && (g.list[e].vid = t.vid);
  664. var n = r()({},
  665. g.list[e]),
  666. a = t.lts;
  667. n.eventType = "join_gateway",
  668. n.firstSuccess = t.firstSuccess,
  669. n.lts = Date.now(),
  670. n.gatewayAddr = t.addr,
  671. n.success = t.succ,
  672. n.errorCode = t.ec,
  673. n.elapse = n.lts - n.startTime,
  674. n.eventElapse = n.lts - a,
  675. delete n.startTime,
  676. g.send({
  677. type: "io.agora.pb.Wrtc.JoinGateway",
  678. data: n
  679. })
  680. },
  681. publish: function(e, t) {
  682. var n = r()({},
  683. g.list[e]);
  684. n.eventType = "publish";
  685. var a = t.lts;
  686. n.lts = Date.now(),
  687. n.eventElapse = n.lts - a,
  688. n.elapse = n.lts - n.startTime,
  689. n.success = t.succ,
  690. n.errorCode = t.ec,
  691. n.audio = t.audio,
  692. n.video = t.video,
  693. n.screenshare = t.screenshare,
  694. n.publishRequestid = t.publishRequestid,
  695. n.p2pid = t.p2pid,
  696. t.videoName && (n.videoName = t.videoName),
  697. t.audioName && (n.audioName = t.audioName),
  698. t.screenName && (n.screenName = t.screenName),
  699. delete n.startTime,
  700. g.send({
  701. type: "io.agora.pb.Wrtc.Publish",
  702. data: n
  703. }),
  704. g._flushInvokeReport(e)
  705. },
  706. subscribe: function(e, t) {
  707. var n = r()({},
  708. g.list[e]);
  709. n.eventType = "subscribe";
  710. var a = t.lts;
  711. n.lts = Date.now(),
  712. n.eventElapse = n.lts - a,
  713. n.elapse = n.lts - n.startTime,
  714. n.errorCode = t.ec,
  715. n.success = t.succ,
  716. n.subscribeRequestid = t.subscribeRequestid,
  717. n.p2pid = t.p2pid,
  718. isFinite(t.peerid) ? n.peer = t.peerid: n.peerSuid = "" + t.peerid,
  719. "boolean" == typeof t.video && (n.video = t.video),
  720. "boolean" == typeof t.audio && (n.audio = t.audio),
  721. delete n.startTime,
  722. g.send({
  723. type: "io.agora.pb.Wrtc.Subscribe",
  724. data: n
  725. }),
  726. g._flushInvokeReport(e)
  727. },
  728. firstRemoteFrame: function(e, t) {
  729. var n = r()({},
  730. g.list[e]);
  731. n.eventType = "first_remote_frame";
  732. var a = t.lts;
  733. n.lts = Date.now(),
  734. n.eventElapse = n.lts - a,
  735. n.elapse = n.lts - n.startTime,
  736. n.width = t.width,
  737. n.height = t.height,
  738. n.success = t.succ,
  739. n.errorCode = t.ec,
  740. isFinite(t.peerid) ? n.peer = t.peerid: n.peerSuid = "" + t.peerid,
  741. delete n.startTime,
  742. g.send({
  743. type: "io.agora.pb.Wrtc.FirstFrame",
  744. data: n
  745. })
  746. },
  747. firstVideoReceived: function(e, t) {
  748. var n = r()({},
  749. g.list[e]);
  750. n.eventType = "first_video_received",
  751. n.lts = Date.now(),
  752. n.peer = t.peerid,
  753. n.uid = t.uid,
  754. n.elapse = t.elapse,
  755. n.subscribeElapse = t.subscribeElapse,
  756. n.subscribeRequestid = t.subscribeRequestid,
  757. n.p2pid = t.p2pid,
  758. g.send({
  759. type: "io.agora.pb.Wrtc.FirstVideoReceived",
  760. data: n
  761. })
  762. },
  763. firstAudioReceived: function(e, t) {
  764. var n = r()({},
  765. g.list[e]);
  766. n.eventType = "first_audio_received",
  767. n.lts = Date.now(),
  768. n.peer = t.peerid,
  769. n.uid = t.uid,
  770. n.elapse = t.elapse,
  771. n.subscribeElapse = t.subscribeElapse,
  772. n.subscribeRequestid = t.subscribeRequestid,
  773. n.p2pid = t.p2pid,
  774. g.send({
  775. type: "io.agora.pb.Wrtc.FirstAudioReceived",
  776. data: n
  777. })
  778. },
  779. firstVideoDecode: function(e, t) {
  780. var n = r()({},
  781. g.list[e]);
  782. n.eventType = "first_video_decode",
  783. n.lts = Date.now(),
  784. n.peer = t.peerid,
  785. n.uid = t.uid,
  786. n.elapse = t.elapse,
  787. n.videowidth = t.width,
  788. n.videoheight = t.height,
  789. n.subscribeElapse = t.subscribeElapse,
  790. n.subscribeRequestid = t.subscribeRequestid,
  791. n.p2pid = t.p2pid,
  792. g.send({
  793. type: "io.agora.pb.Wrtc.FirstVideoDecode",
  794. data: n
  795. })
  796. },
  797. firstAudioDecode: function(e, t) {
  798. var n = r()({},
  799. g.list[e]);
  800. n.eventType = "first_audio_decode",
  801. n.lts = Date.now(),
  802. n.uid = t.uid,
  803. n.peer = t.peerid,
  804. n.elapse = t.elapse,
  805. n.subscribeElapse = t.subscribeElapse,
  806. n.subscribeRequestid = t.subscribeRequestid,
  807. n.p2pid = t.p2pid,
  808. g.send({
  809. type: "io.agora.pb.Wrtc.FirstAudioDecode",
  810. data: n
  811. })
  812. },
  813. onAddAudioStream: function(e, t) {
  814. var n = r()({},
  815. g.list[e]);
  816. n.eventType = "on_add_audio_stream",
  817. n.lts = Date.now(),
  818. n.uid = t.uid,
  819. n.peer = t.peerid,
  820. g.send({
  821. type: "io.agora.pb.Wrtc.OnAddAudioStream",
  822. data: n
  823. })
  824. },
  825. onAddVideoStream: function(e, t) {
  826. var n = r()({},
  827. g.list[e]);
  828. n.eventType = "on_add_video_stream",
  829. n.lts = Date.now(),
  830. n.uid = t.uid,
  831. n.peer = t.peerid,
  832. g.send({
  833. type: "io.agora.pb.Wrtc.OnAddVideoStream",
  834. data: n
  835. })
  836. },
  837. onUpdateStream: function(e, t) {
  838. var n = r()({},
  839. g.list[e]);
  840. n.eventType = "on_update_stream",
  841. n.lts = Date.now(),
  842. n.uid = t.uid,
  843. n.peer = t.peerid,
  844. n.audio = t.audio,
  845. n.video = t.video,
  846. g.send({
  847. type: "io.agora.pb.Wrtc.OnUpdateStream",
  848. data: n
  849. })
  850. },
  851. onRemoveStream: function(e, t) {
  852. var n = r()({},
  853. g.list[e]);
  854. n.eventType = "on_remove_stream",
  855. n.lts = Date.now(),
  856. n.uid = t.uid,
  857. n.peer = t.peerid,
  858. g.send({
  859. type: "io.agora.pb.Wrtc.OnRemoveStream",
  860. data: n
  861. })
  862. },
  863. streamSwitch: function(e, t) {
  864. var n = r()({},
  865. g.list[e]);
  866. n.eventType = "stream_switch",
  867. n.lts = Date.now(),
  868. n.isDual = t.isdual,
  869. n.elapse = n.lts - n.startTime,
  870. n.success = n.succ,
  871. delete n.startTime,
  872. g.send({
  873. type: "io.agora.pb.Wrtc.StreamSwitch",
  874. data: n
  875. })
  876. },
  877. audioSendingStopped: function(e, t) {
  878. var n = r()({},
  879. g.list[e]);
  880. n.eventType = "audio_sending_stopped",
  881. n.lts = Date.now(),
  882. n.elapse = n.lts - n.startTime,
  883. n.reason = t.reason,
  884. n.success = t.succ,
  885. delete n.startTime,
  886. g.send({
  887. type: "io.agora.pb.Wrtc.AudioSendingStopped",
  888. data: n
  889. })
  890. },
  891. videoSendingStopped: function(e, t) {
  892. var n = r()({},
  893. g.list[e]);
  894. n.eventType = "video_sending_stopped",
  895. n.lts = Date.now(),
  896. n.elapse = n.lts - n.startTime,
  897. n.reson = t.reason,
  898. n.success = t.succ,
  899. delete n.startTime,
  900. g.send({
  901. type: "io.agora.pb.Wrtc.VideoSendingStopped",
  902. data: n
  903. })
  904. },
  905. requestProxyAppCenter: function(e, t) {
  906. var n = r()({},
  907. g.list[e]),
  908. a = t.lts;
  909. n.eventType = "request_proxy_appcenter",
  910. n.lts = Date.now(),
  911. n.eventElapse = n.lts - a,
  912. n.elapse = n.lts - n.startTime,
  913. n.extend = t.extend + "",
  914. n.APAddr = t.APAddr,
  915. n.workerManagerList = t.workerManagerList,
  916. n.response = t.response,
  917. n.errorCode = t.ec,
  918. n.success = t.succ,
  919. delete n.startTime,
  920. g.send({
  921. type: "io.agora.pb.Wrtc.RequestProxyAppCenter",
  922. data: n
  923. })
  924. },
  925. requestProxyWorkerManager: function(e, t) {
  926. var n = r()({},
  927. g.list[e]),
  928. a = t.lts;
  929. n.eventType = "request_proxy_worker_manager",
  930. n.lts = Date.now(),
  931. n.eventElapse = n.lts - a,
  932. n.elapse = n.lts - n.startTime,
  933. n.extend = t.extend,
  934. n.workerManagerAddr = t.workerManagerAddr,
  935. n.response = t.response,
  936. n.errorCode = t.ec,
  937. n.success = t.succ,
  938. delete n.startTime,
  939. g.send({
  940. type: "io.agora.pb.Wrtc.RequestProxyWorkerManager",
  941. data: n
  942. })
  943. },
  944. sendCustomReportMessage: function(e, t, n) {
  945. var a = {
  946. type: "io.agora.pb.Wrtc.UserAnalytics",
  947. data: f({
  948. sid: e
  949. },
  950. t)
  951. },
  952. i = g.getUrl();
  953. Object(d.post)(i, a, (function(e) {
  954. n && n()
  955. }), (function(e) {
  956. var t = g.getBackUrl();
  957. Object(d.post)(t, a, (function(e) {
  958. n && n()
  959. }), (function(e) {
  960. n && n("Failed")
  961. }), {
  962. timeout: Object(s.getParameter)("CUSTOMER_REPORT_TIMEOUT")
  963. })
  964. }), {
  965. timeout: Object(s.getParameter)("CUSTOMER_REPORT_TIMEOUT")
  966. })
  967. },
  968. joinChannelTimeOut: function(e) {
  969. g.send({
  970. type: "io.agora.pb.Wrtc.JoinChannelTimeout",
  971. data: f({},
  972. e)
  973. })
  974. },
  975. peerPublishStatus: function(e) {
  976. g.send({
  977. type: "io.agora.pb.Wrtc.PeerPublishStatus",
  978. data: f({},
  979. e)
  980. })
  981. }
  982. }).reportApiInvoke = function(e, t) {
  983. var n = t.tag,
  984. a = t.name,
  985. i = t.getStates,
  986. o = t.options,
  987. r = t.timeout,
  988. d = void 0 === r ? 6e4: r,
  989. u = t.callback,
  990. l = t.reportResult,
  991. p = void 0 === l || l,
  992. g = Date.now(),
  993. v = 0,
  994. S = m++,
  995. E = function() {
  996. return f({
  997. tag: n,
  998. invokeId: S,
  999. sid: e,
  1000. name: a,
  1001. apiInvokeTime: g,
  1002. options: o
  1003. },
  1004. i && {
  1005. states: (t = i(), Object.keys(t).reduce((function(e, n) {
  1006. var a = e;
  1007. return null != t[n] && (a[n] = t[n]),
  1008. a
  1009. }), {}))
  1010. });
  1011. var t
  1012. }, h = !!Object(s.getParameter)("SHOW_REPORT_INVOKER_LOG");
  1013. h && c.
  1014. default.info("".concat(a, " start"));
  1015. var I = setTimeout((function() {
  1016. _._sendApiInvoke(f({},
  1017. E(), {
  1018. error: "API_INVOKE_TIMEOUT",
  1019. success: !1
  1020. }))
  1021. }), d);
  1022. return function(e, t) {
  1023. if (clearTimeout(I), ++v > 1 && (e = "EXECUTOR_INVOKE_".concat(v)), e) return _._sendApiInvoke(f({},
  1024. E(), {
  1025. success: !1,
  1026. error: e
  1027. },
  1028. i && {
  1029. states: i()
  1030. })),
  1031. h && c.
  1032. default.info("".concat(a, " onFailure"), e),
  1033. u && u(e);
  1034. _._sendApiInvoke(f({},
  1035. E(), {
  1036. success: !0
  1037. },
  1038. p && {
  1039. result: t
  1040. },
  1041. {},
  1042. i && {
  1043. states: i()
  1044. })),
  1045. h && c.
  1046. default.info("".concat(a, " onSuccess")),
  1047. u && u(null, t)
  1048. }
  1049. },
  1050. g._cachedItems = [], g._cacheInvokeReport = function(e) {
  1051. e.lts || (e.lts = Date.now()),
  1052. g._cachedItems.push(e),
  1053. g._cachedItems.length > 50 && g._cachedItems.shift()
  1054. },
  1055. g._flushInvokeReport = function(e) {
  1056. if (g._cachedItems.length) {
  1057. var t = g._cachedItems;
  1058. g._cachedItems = [],
  1059. c.
  1060. default.debug("Flush cached event reporting:", t.length),
  1061. t.forEach((function(t, n) {
  1062. t.sid = e,
  1063. setTimeout((function() {
  1064. g._sendApiInvoke(t)
  1065. }), 5e3 + 500 * n)
  1066. }))
  1067. }
  1068. },
  1069. g._sendApiInvoke = function(e) {
  1070. var t = e.tag,
  1071. n = e.invokeId,
  1072. a = e.sid,
  1073. i = e.name,
  1074. o = e.result,
  1075. r = e.states,
  1076. c = e.options,
  1077. d = e.error,
  1078. u = e.success,
  1079. l = e.apiInvokeTime,
  1080. p = e.lts,
  1081. m = Object(s.getParameter)("NOT_REPORT_EVENT");
  1082. if (! (t && m instanceof Array && -1 !== m.indexOf(t))) if (g.list[a]) {
  1083. var v = g.list[a],
  1084. S = v.startTime,
  1085. E = v.cname,
  1086. _ = v.uid,
  1087. h = v.cid,
  1088. I = (p = p || Date.now()) - S,
  1089. b = p - l,
  1090. T = "";
  1091. if (c) try {
  1092. T = JSON.stringify(c)
  1093. } catch(e) {
  1094. T = c.toString()
  1095. }
  1096. var R = f({
  1097. invokeId: n,
  1098. sid: a,
  1099. cname: E,
  1100. cid: h,
  1101. lts: p,
  1102. uid: _,
  1103. success: u,
  1104. elapse: I,
  1105. apiName: i,
  1106. execElapse: b
  1107. },
  1108. void 0 !== c && {
  1109. options: T
  1110. },
  1111. {},
  1112. void 0 !== r && {
  1113. execStates: JSON.stringify(r)
  1114. },
  1115. {},
  1116. void 0 !== d && {
  1117. errorCode: JSON.stringify(d)
  1118. },
  1119. {},
  1120. void 0 !== o && {
  1121. execResult: JSON.stringify(o)
  1122. });
  1123. g.send({
  1124. type: "io.agora.pb.Wrtc.ApiInvoke",
  1125. data: R
  1126. })
  1127. } else g._cacheInvokeReport(arguments[0])
  1128. },
  1129. g._send = function(e) {
  1130. try {
  1131. var t = [];
  1132. e && e.data && e.data.apiName ? t.push(["apiName", "" + e.data.apiName]) : e && e.data && e.data.eventType && t.push(["eventType", e.data.eventType]);
  1133. var n = t.map((function(e) {
  1134. return "".concat(e[0], "=").concat(encodeURIComponent(e[1]))
  1135. })).join("&"),
  1136. a = g.getUrl();
  1137. a = -1 === g.getUrl().indexOf("?") ? "".concat(a, "?").concat(n) : a,
  1138. Object(d.post)(a, e, null, (function(t) {
  1139. var a = g.getBackUrl();
  1140. a = -1 === a.indexOf("?") ? "".concat(a, "?").concat(n) : a,
  1141. Object(d.post)(a, e, null, (function(e) {}), {
  1142. timeout: 1e4
  1143. })
  1144. }), {
  1145. timeout: 1e4
  1146. })
  1147. } catch(e) {
  1148. console.error(e)
  1149. }
  1150. },
  1151. g.sendCache = [], g.sendTimer = null, g.send = function(e) {
  1152. if (e.data) {
  1153. var t = e.data;
  1154. g._lastLts && g._lastLts >= t.lts && (t.lts = g._lastLts + 1),
  1155. g._lastLts = t.lts
  1156. }
  1157. if (g.sendCache.push(e), null === g.sendTimer) return function e() {
  1158. g.sendTimer = setTimeout((function() {
  1159. if (0 !== g.sendCache.length) return g._send(g.sendCache.shift()),
  1160. e();
  1161. g.sendTimer = null
  1162. }), Object(s.getParameter)("EVENT_REPORT_SEND_INTERVAL"))
  1163. } ()
  1164. },
  1165. g)
  1166. },
  1167. function(e, t, n) {
  1168. "use strict";
  1169. Object.defineProperty(t, "__esModule", {
  1170. value: !0
  1171. });
  1172. t.BUILD = "v3.1.2-0-ge669c7b";
  1173. t.VERSION = "3.1.2";
  1174. var a = 0 * Date.now() + 11499 + 86604 + 5615 + 6547 + 846;
  1175. t.SUPPORT_RESOLUTION_LIST = {
  1176. "90p_1": [160, 90, null, null, null, null],
  1177. "120p_1": [160, 120, 15, 15, 30, 65],
  1178. "120p_3": [120, 120, 15, 15, 30, 50],
  1179. "120p_4": [212, 120, null, null, null, null],
  1180. "180p_1": [320, 180, 15, 15, 30, 140],
  1181. "180p_3": [180, 180, 15, 15, 30, 100],
  1182. "180p_4": [240, 180, 15, 15, 30, 120],
  1183. "240p_1": [320, 240, 15, 15, 40, 200],
  1184. "240p_3": [240, 240, 15, 15, 40, 140],
  1185. "240p_4": [424, 240, 15, 15, 40, 220],
  1186. "360p_1": [640, 360, 15, 15, 80, 400],
  1187. "360p_3": [360, 360, 15, 15, 80, 260],
  1188. "360p_4": [640, 360, 30, 30, 80, 600],
  1189. "360p_6": [360, 360, 30, 30, 80, 400],
  1190. "360p_7": [480, 360, 15, 15, 80, 320],
  1191. "360p_8": [480, 360, 30, 30, 80, 490],
  1192. "360p_9": [640, 360, 15, 15, 80, 800],
  1193. "360p_10": [640, 360, 24, 24, 80, 800],
  1194. "360p_11": [640, 360, 24, 24, 80, 1e3],
  1195. "480p_1": [640, 480, 15, 15, 100, 500, 1, 5],
  1196. "480p_2": [640, 480, 30, 30, 100, 1e3, 25, 30],
  1197. "480p_3": [480, 480, 15, 15, 100, 400],
  1198. "480p_4": [640, 480, 30, 30, 100, 750],
  1199. "480p_6": [480, 480, 30, 30, 100, 600],
  1200. "480p_8": [848, 480, 15, 15, 100, 610],
  1201. "480p_9": [848, 480, 30, 30, 100, 930],
  1202. "480p_10": [640, 480, 10, 10, 100, 400],
  1203. "720p_1": [1280, 720, 15, 15, 120, 1130, 1, 5],
  1204. "720p_2": [1280, 720, 30, 30, 120, 2e3, 25, 30],
  1205. "720p_3": [1280, 720, 30, 30, 120, 1710],
  1206. "720p_5": [960, 720, 15, 15, 120, 910],
  1207. "720p_6": [960, 720, 30, 30, 120, 1380],
  1208. "1080p_1": [1920, 1080, 15, 15, 120, 2080, 1, 5],
  1209. "1080p_2": [1920, 1080, 30, 30, 120, 3e3, 25, 30],
  1210. "1080p_3": [1920, 1080, 30, 30, 120, 3150],
  1211. "1080p_5": [1920, 1080, 60, 60, 120, 4780],
  1212. "1440p_1": [2560, 1440, 30, 30, 120, 4850],
  1213. "1440p_2": [2560, 1440, 60, 60, 120, 7350],
  1214. "4k_1": [3840, 2160, 30, 30, 120, 8910],
  1215. "4k_3": [3840, 2160, 60, 60, 120, 13500]
  1216. };
  1217. t.AUDIO_PROFILE_SETTINGS = {
  1218. speech_low_quality: [!1, !1, !0, !0],
  1219. speech_standard: [!1, !1, !0, !1],
  1220. music_standard: [!1, !1, !1, !1],
  1221. standard_stereo: [!1, !0, !1, !1],
  1222. high_quality: [!0, !1, !1, !1],
  1223. high_quality_stereo: [!0, !0, !1, !1],
  1224. default:
  1225. [!1, !1, !1, !1]
  1226. };
  1227. var i = {
  1228. WEBCS_DOMAIN: ["ap-web-1-oversea.agora.io", "ap-web-1-north-america.agora.io"],
  1229. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-oversea.agora.io", "ap-web-2-north-america.agora.io"],
  1230. PROXY_CS: ["proxy-ap-web-oversea.agora.io", "proxy-ap-web-america.agora.io"],
  1231. CDS_AP: ["cds-ap-web-oversea.agora.io", "cds-ap-web-america.agora.io", "cds-ap-web-america2.agora.io"],
  1232. ACCOUNT_REGISTER: ["sua-ap-web-oversea.agora.io", "sua-ap-web-america.agora.io", "sua-ap-web-america2.agora.io"],
  1233. UAP_AP: ["uap-ap-web-oversea.agora.io", "uap-ap-web-america.agora.io", "uap-ap-web-america2.agora.io"],
  1234. LOG_UPLOAD_SERVER: "logservice-oversea.agora.io",
  1235. EVENT_REPORT_DOMAIN: "statscollector-1-oversea.agora.io",
  1236. EVENT_REPORT_BACKUP_DOMAIN: "statscollector-2-oversea.agora.io",
  1237. ENABLE_LIVE_SERVER_LIST: !1,
  1238. LIVE_SERVER_LIST: [],
  1239. ACCOUNT_REGISTER_RETRY_TIMEOUT: 1,
  1240. ACCOUNT_REGISTER_RETRY_RATIO: 2,
  1241. ACCOUNT_REGISTER_RETRY_TIMEOUT_MAX: 6e4,
  1242. ACCOUNT_REGISTER_RETRY_COUNT_MAX: 1e5,
  1243. AUDIO_CONTEXT: null,
  1244. GATEWAY_DOMAINS: ["edge.agora.io"],
  1245. WEBCS_BACKUP_CONNECT_TIMEOUT: 6e3,
  1246. LIVESTREAMING_ALIGN: !0,
  1247. HTTP_CONNECT_TIMEOUT: 5e3,
  1248. PLAYER_STATE_DEFER: 2e3,
  1249. SIGNAL_REQUEST_TIMEOUT: 1e7,
  1250. SIGNAL_REQUEST_WATCH_INTERVAL: 1e3,
  1251. REPORT_STATS: !0,
  1252. REPORT_STATS_TIMEOUT: 3e3,
  1253. UPLOAD_LOG: !1,
  1254. NOT_REPORT_EVENT: [],
  1255. FILEPATH_LENMAX: 255,
  1256. SUBSCRIBE_TCC: !1,
  1257. PING_PONG_TIME_OUT: 10,
  1258. DUALSTREAM_OPERATION_CHECK: !0,
  1259. WEBSOCKET_TIMEOUT_MIN: 1e4,
  1260. EVENT_REPORT_SEND_INTERVAL: 1e3,
  1261. MEDIA_ELEMENT_EXISTS_DEPTH: 3,
  1262. CANDIDATE_TIMEOUT: 2e3,
  1263. SHIM_CANDIDATE: !1,
  1264. LEAVE_MSG_TIMEOUT: 2e3,
  1265. TICKET_RENEW_TIMEOUT: 828e5,
  1266. SHOW_REPORT_INVOKER_LOG: !1,
  1267. STATS_FILTER: {
  1268. transportId: !0,
  1269. googTrackId: !0
  1270. },
  1271. FORCE_TURN: !1,
  1272. TURN_ENABLE_TCP: !0,
  1273. TURN_ENABLE_UDP: !0,
  1274. FORCE_CHANGED_GATEWAY_FLAG: !1,
  1275. JOIN_EXTEND: "",
  1276. PUB_EXTEND: "",
  1277. SUB_EXTEND: "",
  1278. CHROME_NEW_STATS: !1,
  1279. AP_BACKOFF_MAX_TIME: 8,
  1280. SET_DEFAULT_TURNSERVER: !0,
  1281. TURN_SERVER_PASSWORD: a.toString(),
  1282. PROXY_SERVER_TYPE2: "webnginx-proxy.agora.io",
  1283. CR: !0,
  1284. CRL: 10,
  1285. CRI: 6,
  1286. CUSTOMER_REPORT_TIMEOUT: 5e3
  1287. };
  1288. i.WEBCS_DOMAIN = ["webrtc2-ap-web-1.agora.io", "webrtc2-ap-web-2.agoraio.cn"],
  1289. i.WEBCS_DOMAIN_BACKUP_LIST = ["webrtc2-ap-web-3.agora.io", "webrtc2-ap-web-4.agoraio.cn"],
  1290. i.PROXY_CS = ["ap-proxy-1.agora.io", "ap-proxy-2.agora.io"],
  1291. i.CDS_AP = ["cds-ap-web-1.agora.io", "cds-ap-web-2.agoraio.cn", "cds-ap-web-3.agora.io", "cds-ap-web-4.agoraio.cn"],
  1292. i.ACCOUNT_REGISTER = ["sua-ap-web-1.agora.io", "sua-ap-web-2.agoraio.cn", "sua-ap-web-3.agora.io", "sua-ap-web-4.agoraio.cn"],
  1293. i.UAP_AP = ["uap-ap-web-1.agora.io", "uap-ap-web-2.agoraio.cn", "uap-ap-web-3.agora.io", "uap-ap-web-4.agoraio.cn"],
  1294. i.LOG_UPLOAD_SERVER = "logservice.agora.io",
  1295. i.EVENT_REPORT_DOMAIN = "webcollector-1.agora.io",
  1296. i.EVENT_REPORT_BACKUP_DOMAIN = "webcollector-2.agoraio.cn",
  1297. i.GATEWAY_DOMAINS = ["edge.agora.io", "edge.agoraio.cn"];
  1298. t.setParameter = function(e, t) {
  1299. return void 0 !== i[e] && (i[e] = t, !0)
  1300. };
  1301. t.getParameter = function(e) {
  1302. return void 0 !== i[e] ? i[e] : null
  1303. }
  1304. },
  1305. function(e, t, n) {
  1306. "use strict";
  1307. n.r(t),
  1308. n.d(t, "APErrorCode", (function() {
  1309. return a
  1310. })),
  1311. n.d(t, "GatewayErrorCode", (function() {
  1312. return i
  1313. })),
  1314. n.d(t, "StringUidErrorCode", (function() {
  1315. return o
  1316. })),
  1317. n.d(t, "JOIN_GS_TRYNEXT_LIST", (function() {
  1318. return r
  1319. })),
  1320. n.d(t, "JOIN_CS_RETRY_LIST", (function() {
  1321. return s
  1322. })),
  1323. n.d(t, "INJECT_STREAM_STATUS", (function() {
  1324. return c
  1325. }));
  1326. var a = {
  1327. 1010100 : "NO_FLAG_SET",
  1328. 1010101 : "FLAG_SET_BUT_EMPTY",
  1329. 1010102 : "INVALID_FALG_SET",
  1330. 2010005 : "INVALID_VENDOR_KEY",
  1331. 2010007 : "INVALID_CHANNEL_NAME",
  1332. 2010008 : "INTERNAL_ERROR",
  1333. 2010009 : "NO_AUTHORIZED",
  1334. 2010010 : "DYNAMIC_KEY_TIMEOUT",
  1335. 2010011 : "NO_ACTIVE_STATUS",
  1336. 2010013 : "DYNAMIC_KEY_EXPIRED",
  1337. 2010014 : "STATIC_USE_DYANMIC_KEY",
  1338. 2010015 : "DYNAMIC_USE_STATIC_KEY",
  1339. 2010016 : "USER_OVERLOAD",
  1340. 2010018 : "FORBIDDEN_REGION",
  1341. 2010019 : "CANNOT_MEET_AREA_DEMAND"
  1342. },
  1343. i = {
  1344. 2e3: "ERR_NO_VOCS_AVAILABLE",
  1345. 2001 : "ERR_NO_VOS_AVAILABLE",
  1346. 2002 : "ERR_JOIN_CHANNEL_TIMEOUT",
  1347. 2003 : "WARN_REPEAT_JOIN",
  1348. 2004 : "ERR_JOIN_BY_MULTI_IP",
  1349. 2011 : "ERR_NOT_JOINED",
  1350. 2012 : "WARN_REPEAT_JOIN",
  1351. 2013 : "ERR_INVALID_VENDOR_KEY",
  1352. 2014 : "ERR_INVALID_CHANNEL_NAME",
  1353. 2015 : "ERR_INVALID_STRINGUID",
  1354. 2016 : "ERR_TOO_MANY_USERS",
  1355. 2017 : "ERR_SET_CLIENT_ROLE_TIMEOUT",
  1356. 2018 : "ERR_SET_CLIENT_ROLE_NO_PERMISSION",
  1357. 2019 : "ERR_SET_CLIENT_ROLE_ALREADY_IN_USE",
  1358. 2020 : "ERR_PUBLISH_REQUEST_INVALID",
  1359. 2021 : "ERR_SUBSCRIBE_REQUEST_INVALID",
  1360. 2022 : "ERR_NOT_SUPPORTED_MESSAGE",
  1361. 2023 : "ERR_ILLEAGAL_PLUGIN",
  1362. 101 : "ERR_INVALID_VENDOR_KEY",
  1363. 102 : "ERR_INVALID_CHANNEL_NAME",
  1364. 103 : "WARN_NO_AVAILABLE_CHANNEL",
  1365. 104 : "WARN_LOOKUP_CHANNEL_TIMEOUT",
  1366. 105 : "WARN_LOOKUP_CHANNEL_REJECTED",
  1367. 106 : "WARN_OPEN_CHANNEL_TIMEOUT",
  1368. 107 : "WARN_OPEN_CHANNEL_REJECTED",
  1369. 108 : "WARN_REQUEST_DEFERRED",
  1370. 109 : "ERR_DYNAMIC_KEY_TIMEOUT",
  1371. 110 : "ERR_NO_AUTHORIZED",
  1372. 111 : "ERR_VOM_SERVICE_UNAVAILABLE",
  1373. 112 : "ERR_NO_CHANNEL_AVAILABLE_CODE",
  1374. 113 : "ERR_TOO_MANY_USERS",
  1375. 114 : "ERR_MASTER_VOCS_UNAVAILABLE",
  1376. 115 : "ERR_INTERNAL_ERROR",
  1377. 116 : "ERR_NO_ACTIVE_STATUS",
  1378. 117 : "ERR_INVALID_UID",
  1379. 118 : "ERR_DYNAMIC_KEY_EXPIRED",
  1380. 119 : "ERR_STATIC_USE_DYANMIC_KE",
  1381. 120 : "ERR_DYNAMIC_USE_STATIC_KE",
  1382. 2 : "K_TIMESTAMP_EXPIRED",
  1383. 3 : "K_CHANNEL_PERMISSION_INVALID",
  1384. 4 : "K_CERTIFICATE_INVALID",
  1385. 5 : "K_CHANNEL_NAME_EMPTY",
  1386. 6 : "K_CHANNEL_NOT_FOUND",
  1387. 7 : "K_TICKET_INVALID",
  1388. 8 : "K_CHANNEL_CONFLICTED",
  1389. 9 : "K_SERVICE_NOT_READY",
  1390. 10 : "K_SERVICE_TOO_HEAVY",
  1391. 14 : "K_UID_BANNED",
  1392. 15 : "K_IP_BANNED",
  1393. 16 : "K_CHANNEL_BANNED"
  1394. },
  1395. o = {
  1396. 1 : "ERROR_ILLEAGAL_APPID",
  1397. 2 : "ERROR_ILLEAGAL_UID",
  1398. 3 : "INTERNAL_SERVER_ERROR"
  1399. },
  1400. r = ["ERR_NO_VOCS_AVAILABLE", "ERR_NO_VOS_AVAILABLE", "ERR_JOIN_CHANNEL_TIMEOUT", "WARN_LOOKUP_CHANNEL_TIMEOUT", "WARN_OPEN_CHANNEL_TIMEOUT", "ERR_VOM_SERVICE_UNAVAILABLE", "ERR_TOO_MANY_USERS", "ERR_MASTER_VOCS_UNAVAILABLE", "ERR_INTERNAL_ERROR"],
  1401. s = ["NO_SERVICE_AVAILABLE"],
  1402. c = {
  1403. INJECT_STREAM_STATUS_START_SUCCESS: 0,
  1404. INJECT_STREAM_STATUS_START_ALREADY_EXISTS: 1,
  1405. INJECT_STREAM_STATUS_START_UNAUTHORIZED: 2,
  1406. INJECT_STREAM_STATUS_START_TIMEDOUT: 3,
  1407. INJECT_STREAM_STATUS_START_FAILED: 4,
  1408. INJECT_STREAM_STATUS_STOP_SUCCESS: 5,
  1409. INJECT_STREAM_STATUS_STOP_NOT_FOUND: 6,
  1410. INJECT_STREAM_STATUS_STOP_UNAUTHORIZED: 7,
  1411. INJECT_STREAM_STATUS_STOP_TIMEDOUT: 8,
  1412. INJECT_STREAM_STATUS_STOP_FAILED: 9,
  1413. INJECT_STREAM_STATUS_BROKEN: 10
  1414. };
  1415. t.
  1416. default = {
  1417. FAILED: "FAILED",
  1418. INVALID_KEY: "INVALID_KEY",
  1419. INVALID_CLIENT_MODE: "INVALID_CLIENT_MODE",
  1420. INVALID_CLIENT_CODEC: "INVALID_CLIENT_CODEC",
  1421. CLIENT_MODE_CODEC_MISMATCH: "CLIENT_MODE_CODEC_MISMATCH",
  1422. WEB_API_NOT_SUPPORTED: "WEB_API_NOT_SUPPORTED",
  1423. INVALID_PARAMETER: "INVALID_PARAMETER",
  1424. NO_TRACK_IN_STREAM: "NO_TRACK_IN_STREAM",
  1425. INVALID_OPERATION: "INVALID_OPERATION",
  1426. INVALID_LOCAL_STREAM: "INVALID_LOCAL_STREAM",
  1427. INVALID_REMOTE_STREAM: "INVALID_REMOTE_STREAM",
  1428. INVALID_DYNAMIC_KEY: "INVALID_DYNAMIC_KEY",
  1429. DYNAMIC_KEY_TIMEOUT: "DYNAMIC_KEY_TIMEOUT",
  1430. NO_VOCS_AVAILABLE: "NO_VOCS_AVAILABLE",
  1431. NO_VOS_AVAILABLE: "ERR_NO_VOS_AVAILABLE",
  1432. JOIN_CHANNEL_TIMEOUT: "ERR_JOIN_CHANNEL_TIMEOUT",
  1433. NO_AVAILABLE_CHANNEL: "NO_AVAILABLE_CHANNEL",
  1434. LOOKUP_CHANNEL_TIMEOUT: "LOOKUP_CHANNEL_TIMEOUT",
  1435. LOOKUP_CHANNEL_REJECTED: "LOOKUP_CHANNEL_REJECTED",
  1436. OPEN_CHANNEL_TIMEOUT: "OPEN_CHANNEL_TIMEOUT",
  1437. OPEN_CHANNEL_REJECTED: "OPEN_CHANNEL_REJECTED",
  1438. REQUEST_DEFERRED: "REQUEST_DEFERRED",
  1439. STREAM_ALREADY_PUBLISHED: "STREAM_ALREADY_PUBLISHED",
  1440. STREAM_NOT_YET_PUBLISHED: "STREAM_NOT_YET_PUBLISHED",
  1441. JOIN_TOO_FREQUENT: "JOIN_TOO_FREQUENT",
  1442. SOCKET_ERROR: "SOCKET_ERROR",
  1443. SOCKET_DISCONNECTED: "SOCKET_DISCONNECTED",
  1444. PEERCONNECTION_FAILED: "PEERCONNECTION_FAILED",
  1445. CONNECT_GATEWAY_ERROR: "CONNECT_GATEWAY_ERROR",
  1446. SERVICE_NOT_AVAILABLE: "SERVICE_NOT_AVAILABLE",
  1447. JOIN_CHANNEL_FAILED: "JOIN_CHANNEL_FAILED",
  1448. PUBLISH_STREAM_FAILED: "PUBLISH_STREAM_FAILED",
  1449. UNPUBLISH_STREAM_FAILED: "UNPUBLISH_STREAM_FAILED",
  1450. SUBSCRIBE_STREAM_FAILED: "SUBSCRIBE_STREAM_FAILED",
  1451. UNSUBSCRIBE_STREAM_FAILED: "UNSUBSCRIBE_STREAM_FAILED",
  1452. NO_SUCH_REMOTE_STREAM: "NO_SUCH_REMOTE_STREAM",
  1453. ERR_FAILED: "1",
  1454. ERR_INVALID_VENDOR_KEY: "101",
  1455. ERR_INVALID_CHANNEL_NAME: "102",
  1456. WARN_NO_AVAILABLE_CHANNEL: "103",
  1457. WARN_LOOKUP_CHANNEL_TIMEOUT: "104",
  1458. WARN_LOOKUP_CHANNEL_REJECTED: "105",
  1459. WARN_OPEN_CHANNEL_TIMEOUT: "106",
  1460. WARN_OPEN_CHANNEL_REJECTED: "107",
  1461. WARN_REQUEST_DEFERRED: "108",
  1462. ERR_DYNAMIC_KEY_TIMEOUT: "109",
  1463. ERR_INVALID_DYNAMIC_KEY: "110",
  1464. ERR_NO_VOCS_AVAILABLE: "2000",
  1465. ERR_NO_VOS_AVAILABLE: "2001",
  1466. ERR_JOIN_CHANNEL_TIMEOUT: "2002",
  1467. IOS_NOT_SUPPORT: "IOS_NOT_SUPPORT",
  1468. WECHAT_NOT_SUPPORT: "WECHAT_NOT_SUPPORT",
  1469. SHARING_SCREEN_NOT_SUPPORT: "SHARING_SCREEN_NOT_SUPPORT",
  1470. STILL_ON_PUBLISHING: "STILL_ON_PUBLISHING",
  1471. LOW_STREAM_ALREADY_PUBLISHED: "LOW_STREAM_ALREADY_PUBLISHED",
  1472. LOW_STREAM_NOT_YET_PUBLISHED: "LOW_STREAM_ALREADY_PUBLISHED",
  1473. HIGH_STREAM_NOT_VIDEO_TRACE: "HIGH_STREAM_NOT_VIDEO_TRACE",
  1474. NOT_FIND_DEVICE_BY_LABEL: "NOT_FIND_DEVICE_BY_LABEL",
  1475. ENABLE_DUALSTREAM_FAILED: "ENABLE_DUALSTREAM_FAILED",
  1476. DISABLE_DUALSTREAM_FAILED: "DISABLE_DUALSTREAM_FAILED",
  1477. PLAYER_NOT_FOUND: "PLAYER_NOT_FOUND",
  1478. ELECTRON_NOT_SUPPORT_SHARING_SCREEN: "ELECTRON_NOT_SUPPORT_SHARING_SCREEN",
  1479. BAD_ENVIRONMENT: "BAD_ENVIRONMENT",
  1480. LOAD_AUDIO_FAILED: "LOAD_AUDIO_FAILED"
  1481. }
  1482. },
  1483. function(e, t, n) {
  1484. "use strict";
  1485. n.r(t),
  1486. n.d(t, "getBrowserInfo", (function() {
  1487. return E
  1488. })),
  1489. n.d(t, "getBrowserVersion", (function() {
  1490. return p
  1491. })),
  1492. n.d(t, "getBrowserOS", (function() {
  1493. return f
  1494. })),
  1495. n.d(t, "isChrome", (function() {
  1496. return a
  1497. })),
  1498. n.d(t, "isSafari", (function() {
  1499. return i
  1500. })),
  1501. n.d(t, "isFireFox", (function() {
  1502. return r
  1503. })),
  1504. n.d(t, "isOpera", (function() {
  1505. return s
  1506. })),
  1507. n.d(t, "isEdge", (function() {
  1508. return o
  1509. })),
  1510. n.d(t, "isQQBrowser", (function() {
  1511. return c
  1512. })),
  1513. n.d(t, "isWeChatBrowser", (function() {
  1514. return d
  1515. })),
  1516. n.d(t, "isLegacyChrome", (function() {
  1517. return m
  1518. })),
  1519. n.d(t, "isSupportedPC", (function() {
  1520. return u
  1521. })),
  1522. n.d(t, "isSupportedMobile", (function() {
  1523. return l
  1524. })),
  1525. n.d(t, "getChromeKernelVersion", (function() {
  1526. return S
  1527. })),
  1528. n.d(t, "isChromeKernel", (function() {
  1529. return g
  1530. }));
  1531. var a = function() {
  1532. var e = E();
  1533. return e.name && "Chrome" === e.name
  1534. },
  1535. i = function() {
  1536. var e = E();
  1537. return e.name && "Safari" === e.name
  1538. },
  1539. o = function() {
  1540. var e = E();
  1541. return e.name && "Edge" === e.name
  1542. },
  1543. r = function() {
  1544. var e = E();
  1545. return e.name && "Firefox" === e.name
  1546. },
  1547. s = function() {
  1548. var e = E();
  1549. return e.name && "OPR" === e.name
  1550. },
  1551. c = function() {
  1552. var e = E();
  1553. return e.name && "QQBrowser" === e.name
  1554. },
  1555. d = function() {
  1556. var e = E();
  1557. return e.name && "MicroMessenger" === e.name
  1558. },
  1559. u = function() {
  1560. var e = f();
  1561. return "Linux" === e || "Mac OS X" === e || "Mac OS" === e || -1 !== e.indexOf("Windows")
  1562. },
  1563. l = function() {
  1564. var e = f();
  1565. return "Android" === e || "iOS" === e
  1566. },
  1567. p = function() {
  1568. return E().version
  1569. },
  1570. f = function() {
  1571. return E().os
  1572. },
  1573. g = function() {
  1574. return !! navigator.userAgent.match(/chrome\/[\d]./i)
  1575. };
  1576. function m() {
  1577. return window.navigator.appVersion && null !== window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./) && window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1] <= 35
  1578. }
  1579. var v, S = function() {
  1580. var e = navigator.userAgent.match(/chrome\/[\d]./i);
  1581. return e && e[0] && e[0].split("/")[1]
  1582. },
  1583. E = (v = function() {
  1584. var e, t = navigator.userAgent,
  1585. n = t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
  1586. "Chrome" === n[1] && null != (e = t.match(/(OPR(?=\/))\/?(\d+)/i)) && (n = e),
  1587. "Safari" === n[1] && null != (e = t.match(/version\/(\d+)/i)) && (n[2] = e[1]),
  1588. ~t.toLowerCase().indexOf("qqbrowser") && null != (e = t.match(/(qqbrowser(?=\/))\/?(\d+)/i)) && (n = e),
  1589. ~t.toLowerCase().indexOf("micromessenger") && null != (e = t.match(/(micromessenger(?=\/))\/?(\d+)/i)) && (n = e),
  1590. ~t.toLowerCase().indexOf("edge") && null != (e = t.match(/(edge(?=\/))\/?(\d+)/i)) && (n = e),
  1591. ~t.toLowerCase().indexOf("trident") && null != (e = /\brv[ :]+(\d+)/g.exec(t) || []) && (n = [null, "IE", e[1]]);
  1592. var a = void 0,
  1593. i = [{
  1594. s: "Windows 10",
  1595. r: /(Windows 10.0|Windows NT 10.0)/
  1596. },
  1597. {
  1598. s: "Windows 8.1",
  1599. r: /(Windows 8.1|Windows NT 6.3)/
  1600. },
  1601. {
  1602. s: "Windows 8",
  1603. r: /(Windows 8|Windows NT 6.2)/
  1604. },
  1605. {
  1606. s: "Windows 7",
  1607. r: /(Windows 7|Windows NT 6.1)/
  1608. },
  1609. {
  1610. s: "Windows Vista",
  1611. r: /Windows NT 6.0/
  1612. },
  1613. {
  1614. s: "Windows Server 2003",
  1615. r: /Windows NT 5.2/
  1616. },
  1617. {
  1618. s: "Windows XP",
  1619. r: /(Windows NT 5.1|Windows XP)/
  1620. },
  1621. {
  1622. s: "Windows 2000",
  1623. r: /(Windows NT 5.0|Windows 2000)/
  1624. },
  1625. {
  1626. s: "Windows ME",
  1627. r: /(Win 9x 4.90|Windows ME)/
  1628. },
  1629. {
  1630. s: "Windows 98",
  1631. r: /(Windows 98|Win98)/
  1632. },
  1633. {
  1634. s: "Windows 95",
  1635. r: /(Windows 95|Win95|Windows_95)/
  1636. },
  1637. {
  1638. s: "Windows NT 4.0",
  1639. r: /(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/
  1640. },
  1641. {
  1642. s: "Windows CE",
  1643. r: /Windows CE/
  1644. },
  1645. {
  1646. s: "Windows 3.11",
  1647. r: /Win16/
  1648. },
  1649. {
  1650. s: "Android",
  1651. r: /Android/
  1652. },
  1653. {
  1654. s: "Open BSD",
  1655. r: /OpenBSD/
  1656. },
  1657. {
  1658. s: "Sun OS",
  1659. r: /SunOS/
  1660. },
  1661. {
  1662. s: "Linux",
  1663. r: /(Linux|X11)/
  1664. },
  1665. {
  1666. s: "iOS",
  1667. r: /(iPhone|iPad|iPod)/
  1668. },
  1669. {
  1670. s: "Mac OS X",
  1671. r: /Mac OS X/
  1672. },
  1673. {
  1674. s: "Mac OS",
  1675. r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/
  1676. },
  1677. {
  1678. s: "QNX",
  1679. r: /QNX/
  1680. },
  1681. {
  1682. s: "UNIX",
  1683. r: /UNIX/
  1684. },
  1685. {
  1686. s: "BeOS",
  1687. r: /BeOS/
  1688. },
  1689. {
  1690. s: "OS/2",
  1691. r: /OS\/2/
  1692. },
  1693. {
  1694. s: "Search Bot",
  1695. r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/
  1696. }];
  1697. for (var o in i) {
  1698. var r = i[o];
  1699. if (r.r.test(navigator.userAgent)) {
  1700. a = r.s;
  1701. break
  1702. }
  1703. }
  1704. return {
  1705. name: n[1],
  1706. version: n[2],
  1707. os: a
  1708. }
  1709. } (),
  1710. function() {
  1711. return v
  1712. })
  1713. },
  1714. function(e, t) {
  1715. function n() {
  1716. return e.exports = n = Object.assign ||
  1717. function(e) {
  1718. for (var t = 1; t < arguments.length; t++) {
  1719. var n = arguments[t];
  1720. for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a])
  1721. }
  1722. return e
  1723. },
  1724. n.apply(this, arguments)
  1725. }
  1726. e.exports = n
  1727. },
  1728. function(e, t, n) {
  1729. e.exports = n(31)
  1730. },
  1731. function(e, t, n) {
  1732. "use strict";
  1733. var a, i = this && this.__extends || (a = function(e, t) {
  1734. return (a = Object.setPrototypeOf || {
  1735. __proto__: []
  1736. }
  1737. instanceof Array &&
  1738. function(e, t) {
  1739. e.__proto__ = t
  1740. } ||
  1741. function(e, t) {
  1742. for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
  1743. })(e, t)
  1744. },
  1745. function(e, t) {
  1746. function n() {
  1747. this.constructor = e
  1748. }
  1749. a(e, t),
  1750. e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n)
  1751. }),
  1752. o = this && this.__awaiter ||
  1753. function(e, t, n, a) {
  1754. return new(n || (n = Promise))((function(i, o) {
  1755. function r(e) {
  1756. try {
  1757. c(a.next(e))
  1758. } catch(e) {
  1759. o(e)
  1760. }
  1761. }
  1762. function s(e) {
  1763. try {
  1764. c(a.
  1765. throw (e))
  1766. } catch(e) {
  1767. o(e)
  1768. }
  1769. }
  1770. function c(e) {
  1771. var t;
  1772. e.done ? i(e.value) : (t = e.value, t instanceof n ? t: new n((function(e) {
  1773. e(t)
  1774. }))).then(r, s)
  1775. }
  1776. c((a = a.apply(e, t || [])).next())
  1777. }))
  1778. },
  1779. r = this && this.__generator ||
  1780. function(e, t) {
  1781. var n, a, i, o, r = {
  1782. label: 0,
  1783. sent: function() {
  1784. if (1 & i[0]) throw i[1];
  1785. return i[1]
  1786. },
  1787. trys: [],
  1788. ops: []
  1789. };
  1790. return o = {
  1791. next: s(0),
  1792. throw: s(1),
  1793. return: s(2)
  1794. },
  1795. "function" == typeof Symbol && (o[Symbol.iterator] = function() {
  1796. return this
  1797. }),
  1798. o;
  1799. function s(o) {
  1800. return function(s) {
  1801. return function(o) {
  1802. if (n) throw new TypeError("Generator is already executing.");
  1803. for (; r;) try {
  1804. if (n = 1, a && (i = 2 & o[0] ? a.
  1805. return: o[0] ? a.
  1806. throw || ((i = a.
  1807. return) && i.call(a), 0) : a.next) && !(i = i.call(a, o[1])).done) return i;
  1808. switch (a = 0, i && (o = [2 & o[0], i.value]), o[0]) {
  1809. case 0:
  1810. case 1:
  1811. i = o;
  1812. break;
  1813. case 4:
  1814. return r.label++,
  1815. {
  1816. value: o[1],
  1817. done: !1
  1818. };
  1819. case 5:
  1820. r.label++,
  1821. a = o[1],
  1822. o = [0];
  1823. continue;
  1824. case 7:
  1825. o = r.ops.pop(),
  1826. r.trys.pop();
  1827. continue;
  1828. default:
  1829. if (! (i = r.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
  1830. r = 0;
  1831. continue
  1832. }
  1833. if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
  1834. r.label = o[1];
  1835. break
  1836. }
  1837. if (6 === o[0] && r.label < i[1]) {
  1838. r.label = i[1],
  1839. i = o;
  1840. break
  1841. }
  1842. if (i && r.label < i[2]) {
  1843. r.label = i[2],
  1844. r.ops.push(o);
  1845. break
  1846. }
  1847. i[2] && r.ops.pop(),
  1848. r.trys.pop();
  1849. continue
  1850. }
  1851. o = t.call(e, r)
  1852. } catch(e) {
  1853. o = [6, e],
  1854. a = 0
  1855. } finally {
  1856. n = i = 0
  1857. }
  1858. if (5 & o[0]) throw o[1];
  1859. return {
  1860. value: o[0] ? o[1] : void 0,
  1861. done: !0
  1862. }
  1863. } ([o, s])
  1864. }
  1865. }
  1866. },
  1867. s = this && this.__importDefault ||
  1868. function(e) {
  1869. return e && e.__esModule ? e: {
  1870. default:
  1871. e
  1872. }
  1873. };
  1874. Object.defineProperty(t, "__esModule", {
  1875. value: !0
  1876. });
  1877. var c = s(n(36)),
  1878. d = n(3),
  1879. u = s(n(0)),
  1880. l = n(1),
  1881. p = n(11),
  1882. f = n(10),
  1883. g = function(e) {
  1884. function t(t, n) {
  1885. var a = e.call(this) || this;
  1886. return a._state = _.RELAY_STATE_IDLE,
  1887. a._onStatus = function(e) {
  1888. u.
  1889. default.debug("[" + a.clientId + "] ChannelMediaStatus: " + JSON.stringify(e)),
  1890. e && e.command && ("onAudioPacketReceived" === e.command && a.emit("event", E.PACKET_RECEIVED_AUDIO_FROM_SRC), "onVideoPacketReceived" === e.command && a.emit("event", E.PACKET_RECEIVED_VIDEO_FROM_SRC), "onSrcTokenPrivilegeDidExpire" === e.command && (a._state = _.RELAY_STATE_FAILURE, a.emit("state", _.RELAY_STATE_FAILURE, h.SRC_TOKEN_EXPIRED)), "onDestTokenPrivilegeDidExpire" === e.command && (a._state = _.RELAY_STATE_FAILURE, a.emit("state", _.RELAY_STATE_FAILURE, h.DEST_TOKEN_EXPIRED, e.channelName ? {
  1891. came: e.channelName
  1892. }: null)))
  1893. },
  1894. a._onClose = function() {
  1895. return o(a, void 0, void 0, (function() {
  1896. var e;
  1897. return r(this, (function(t) {
  1898. switch (t.label) {
  1899. case 0:
  1900. if (u.
  1901. default.debug("[" + this.clientId + "] ChannelMediaSocket onClose"), this.emit("event", E.NETWORK_DISCONNECTED), this.state = _.RELAY_STATE_IDLE, !this._prevChannelMediaConfig) return [3, 4];
  1902. t.label = 1;
  1903. case 1:
  1904. return t.trys.push([1, 3, , 4]),
  1905. [4, this.startChannelMediaRelay(this._prevChannelMediaConfig)];
  1906. case 2:
  1907. return t.sent(),
  1908. [3, 4];
  1909. case 3:
  1910. return (e = t.sent()) instanceof b && (e.message === v.WS_ABORT || e.message === v.AP_REQUEST_ABORT) ? [2] : (this.emit("state", _.RELAY_STATE_FAILURE, h.SERVER_CONNECTION_LOST), [3, 4]);
  1911. case 4:
  1912. return [2]
  1913. }
  1914. }))
  1915. }))
  1916. },
  1917. a.token = t.appId,
  1918. a.appId = t.appId,
  1919. a.cname = t.cname,
  1920. a.uid = t.uid,
  1921. a.sid = t.sid,
  1922. a.clientId = n,
  1923. a
  1924. }
  1925. return i(t, e),
  1926. Object.defineProperty(t.prototype, "state", {
  1927. get: function() {
  1928. return this._state
  1929. },
  1930. set: function(e) {
  1931. var t = this._state;
  1932. this._state = e,
  1933. t !== e && this.emit("state", e)
  1934. },
  1935. enumerable: !0,
  1936. configurable: !0
  1937. }),
  1938. t.prototype.startChannelMediaRelay = function(e) {
  1939. return o(this, void 0, void 0, (function() {
  1940. return r(this, (function(t) {
  1941. switch (t.label) {
  1942. case 0:
  1943. if (this.state !== _.RELAY_STATE_IDLE) throw new b(v.BAD_STATE);
  1944. return this.state = _.RELAY_STATE_CONNECTING,
  1945. [4, this._connect()];
  1946. case 1:
  1947. return t.sent(),
  1948. u.
  1949. default.debug("[" + this.clientId + "] startChannelMediaRelay: connect success"),
  1950. [4, this._sendStartRelayMessage(e)];
  1951. case 2:
  1952. return t.sent(),
  1953. this._prevChannelMediaConfig = e,
  1954. [2]
  1955. }
  1956. }))
  1957. }))
  1958. },
  1959. t.prototype.updateChannelMediaRelay = function(e) {
  1960. return o(this, void 0, void 0, (function() {
  1961. return r(this, (function(t) {
  1962. switch (t.label) {
  1963. case 0:
  1964. if (this.state !== _.RELAY_STATE_RUNNING) throw new b(v.BAD_STATE);
  1965. return [4, this._sendUpdateMessage(e)];
  1966. case 1:
  1967. return t.sent(),
  1968. this._prevChannelMediaConfig = e,
  1969. [2]
  1970. }
  1971. }))
  1972. }))
  1973. },
  1974. t.prototype.stopChannelMediaRelay = function() {
  1975. return o(this, void 0, void 0, (function() {
  1976. return r(this, (function(e) {
  1977. switch (e.label) {
  1978. case 0:
  1979. return [4, this._sendStopRelayMessage()];
  1980. case 1:
  1981. return e.sent(),
  1982. u.
  1983. default.debug("[" + this.clientId + "] stopChannelMediaRelay: send stop message success"),
  1984. this.state = _.RELAY_STATE_IDLE,
  1985. this.dispose(),
  1986. [2]
  1987. }
  1988. }))
  1989. }))
  1990. },
  1991. t.prototype.dispose = function() {
  1992. u.
  1993. default.debug("[" + this.clientId + "] disposeChannelMediaRelay"),
  1994. this.state = _.RELAY_STATE_IDLE,
  1995. this.emit("dispose"),
  1996. this._signal && this._signal.dispose(),
  1997. this._prevChannelMediaConfig = null,
  1998. this.removeEvent()
  1999. },
  2000. t.prototype._requestOneAP = function(e) {
  2001. var t = this;
  2002. return new Promise((function(n, a) {
  2003. var i = {
  2004. command: "convergeAllocateEdge",
  2005. sid: t.sid,
  2006. appId: t.appId,
  2007. token: "",
  2008. ts: +new Date,
  2009. version: d.VERSION,
  2010. cname: t.cname,
  2011. uid: t.uid + "",
  2012. seq: 1,
  2013. requestId: 1
  2014. },
  2015. o = {
  2016. service_name: "tele_channel",
  2017. json_body: JSON.stringify(i)
  2018. },
  2019. r = "https://" + e;
  2020. p.post(r, o, (function(e) {
  2021. var t = null,
  2022. i = null;
  2023. try {
  2024. t = JSON.parse(e)
  2025. } catch(e) {
  2026. a(new b(v.AP_JSON_PARSE_ERROR, e))
  2027. }
  2028. 0 !== t.code && a(new b(v.AP_REQUEST_ERROR, t));
  2029. try {
  2030. i = JSON.parse(t.json_body)
  2031. } catch(e) {
  2032. a(new b(v.AP_JSON_PARSE_ERROR, e))
  2033. }
  2034. 200 !== i.code && a(new b(v.AP_REQUEST_ERROR, i)),
  2035. i.servers ? n(i.servers) : a(new b(v.AP_JSON_PARSE_ERROR, i))
  2036. }), (function(e) {
  2037. return a(e)
  2038. }), {
  2039. "X-Packet-Service-Type": 0,
  2040. "X-Packet-URI": 61
  2041. })
  2042. }))
  2043. },
  2044. t.prototype._requestAP = function() {
  2045. var e = this,
  2046. t = d.getParameter("UAP_AP");
  2047. return new Promise((function(n, a) {
  2048. setTimeout((function() {
  2049. a(new b(v.AP_REQUEST_TIMEOUT))
  2050. }), 5e3),
  2051. e.on("dispose", (function() {
  2052. a(new b(v.AP_REQUEST_ABORT))
  2053. })),
  2054. t.forEach((function(t) {
  2055. t += "/api/v1",
  2056. e._requestOneAP(t).then((function(a) {
  2057. u.
  2058. default.debug("[" + e.clientId + "] startChannelMediaRelay request AP " + t + " success: " + JSON.stringify(a));
  2059. var i = a[0],
  2060. o = "wss://" + i.address.replace(/\./g, "-") + ".edge.agora.io:" + i.wss;
  2061. n(o)
  2062. })).
  2063. catch((function(n) {
  2064. u.
  2065. default.debug("[" + e.clientId + "] startChannelMediaRelay request AP " + t + " failed: " + JSON.stringify(n))
  2066. }))
  2067. }))
  2068. }))
  2069. },
  2070. t.prototype._connectWebsocket = function(e) {
  2071. return this._signal = new I(this.appId, this.cname, this.uid, this.sid),
  2072. this._signal.connect(e)
  2073. },
  2074. t.prototype._connect = function() {
  2075. return o(this, void 0, void 0, (function() {
  2076. var e;
  2077. return r(this, (function(t) {
  2078. switch (t.label) {
  2079. case 0:
  2080. return [4, this._requestAP()];
  2081. case 1:
  2082. return e = t.sent(),
  2083. [4, this._connectWebsocket(e)];
  2084. case 2:
  2085. return t.sent(),
  2086. this._signal.on("close", this._onClose.bind(this)),
  2087. this._signal.on("status", this._onStatus.bind(this)),
  2088. this.emit("event", E.NETWORK_CONNECTED),
  2089. [2]
  2090. }
  2091. }))
  2092. }))
  2093. },
  2094. t.prototype._sendStartRelayMessage = function(e) {
  2095. return o(this, void 0, void 0, (function() {
  2096. var t, n, a, i, o, s;
  2097. return r(this, (function(r) {
  2098. switch (r.label) {
  2099. case 0:
  2100. return this._checkSignal(),
  2101. t = this._genMessage(S.StopPacketTransfer),
  2102. [4, this._signal.request(t)];
  2103. case 1:
  2104. return r.sent(),
  2105. [4, this._signal.waitStatus("Normal Quit")];
  2106. case 2:
  2107. return r.sent(),
  2108. u.
  2109. default.debug("[" + this.clientId + "] startChannelMediaRelay: StopPacketTransfer success"),
  2110. n = this._genMessage(S.SetSdkProfile, e),
  2111. [4, this._signal.request(n)];
  2112. case 3:
  2113. return r.sent(),
  2114. u.
  2115. default.debug("[" + this.clientId + "] startChannelMediaRelay: SetSdkProfile success"),
  2116. a = this._genMessage(S.SetSourceChannel, e),
  2117. [4, this._signal.request(a)];
  2118. case 4:
  2119. return r.sent(),
  2120. [4, this._signal.waitStatus("SetSourceChannelStatus")];
  2121. case 5:
  2122. return r.sent(),
  2123. this.emit("event", E.PACKET_JOINED_SRC_CHANNEL),
  2124. u.
  2125. default.debug("[" + this.clientId + "] startChannelMediaRelay: SetSourceChannel success"),
  2126. i = this._genMessage(S.SetSourceUserId, e),
  2127. [4, this._signal.request(i)];
  2128. case 6:
  2129. return r.sent(),
  2130. u.
  2131. default.debug("[" + this.clientId + "] startChannelMediaRelay: SetSourceUserId success"),
  2132. o = this._genMessage(S.SetDestChannel, e),
  2133. [4, this._signal.request(o)];
  2134. case 7:
  2135. return r.sent(),
  2136. [4, this._signal.waitStatus("SetDestChannelStatus")];
  2137. case 8:
  2138. return r.sent(),
  2139. this.emit("event", E.PACKET_JOINED_DEST_CHANNEL),
  2140. u.
  2141. default.debug("[" + this.clientId + "] startChannelMediaRelay: SetDestChannel success"),
  2142. s = this._genMessage(S.StartPacketTransfer, e),
  2143. [4, this._signal.request(s)];
  2144. case 9:
  2145. return r.sent(),
  2146. this.emit("event", E.PACKET_SENT_TO_DEST_CHANNEL),
  2147. this.state = _.RELAY_STATE_RUNNING,
  2148. u.
  2149. default.debug("[" + this.clientId + "] startChannelMediaRelay: StartPacketTransfer success"),
  2150. [2]
  2151. }
  2152. }))
  2153. }))
  2154. },
  2155. t.prototype._sendReconnectMessage = function(e) {
  2156. return o(this, void 0, void 0, (function() {
  2157. var t;
  2158. return r(this, (function(n) {
  2159. switch (n.label) {
  2160. case 0:
  2161. return this._checkSignal(),
  2162. t = this._genMessage(S.Reconnect, e),
  2163. [4, this._signal.request(t)];
  2164. case 1:
  2165. return n.sent(),
  2166. [2]
  2167. }
  2168. }))
  2169. }))
  2170. },
  2171. t.prototype._sendUpdateMessage = function(e) {
  2172. return o(this, void 0, void 0, (function() {
  2173. var t;
  2174. return r(this, (function(n) {
  2175. switch (n.label) {
  2176. case 0:
  2177. return this._checkSignal(),
  2178. t = this._genMessage(S.UpdateDestChannel, e),
  2179. [4, this._signal.request(t)];
  2180. case 1:
  2181. return n.sent(),
  2182. this.emit("event", E.PACKET_UPDATE_DEST_CHANNEL),
  2183. u.
  2184. default.debug("[" + this.clientId + "] sendUpdateMessage: UpdateDestChannel success"),
  2185. [2]
  2186. }
  2187. }))
  2188. }))
  2189. },
  2190. t.prototype._sendStopRelayMessage = function() {
  2191. return o(this, void 0, void 0, (function() {
  2192. var e;
  2193. return r(this, (function(t) {
  2194. switch (t.label) {
  2195. case 0:
  2196. return this._checkSignal(),
  2197. e = this._genMessage(S.StopPacketTransfer),
  2198. [4, this._signal.request(e)];
  2199. case 1:
  2200. return t.sent(),
  2201. u.
  2202. default.debug("[" + this.clientId + "] sendStopRelayMessage: StopPacketTransfer success"),
  2203. [2]
  2204. }
  2205. }))
  2206. }))
  2207. },
  2208. t.prototype._genMessage = function(e, t) {
  2209. var n = this,
  2210. a = [],
  2211. i = [],
  2212. o = [],
  2213. r = {
  2214. appId: this.appId,
  2215. cname: this.cname,
  2216. uid: this.uid + "",
  2217. sdkVersion: d.VERSION,
  2218. sid: this.sid,
  2219. ts: +new Date,
  2220. requestId: 0,
  2221. seq: 0,
  2222. allocate: !0,
  2223. clientRequest: {}
  2224. },
  2225. s = null;
  2226. switch (e) {
  2227. case S.SetSdkProfile:
  2228. return r.clientRequest = {
  2229. command: "SetSdkProfile",
  2230. type: "multi_channel"
  2231. },
  2232. r;
  2233. case S.SetSourceChannel:
  2234. return s = t.getSrcChannelMediaInfo(),
  2235. r.clientRequest = {
  2236. command: "SetSourceChannel",
  2237. uid: s.uid + "",
  2238. channelName: s.channelName,
  2239. token: s.token || this.appId
  2240. },
  2241. r;
  2242. case S.SetSourceUserId:
  2243. return s = t.getSrcChannelMediaInfo(),
  2244. r.clientRequest = {
  2245. command: "SetSourceUserId",
  2246. uid: this.uid + ""
  2247. },
  2248. r;
  2249. case S.SetDestChannel:
  2250. return t.getDestChannelMediaInfos().forEach((function(e) {
  2251. a.push(e.channelName),
  2252. i.push(e.uid + ""),
  2253. o.push(e.token || n.appId)
  2254. })),
  2255. r.clientRequest = {
  2256. command: "SetDestChannel",
  2257. channelName: a,
  2258. uid: i,
  2259. token: o
  2260. },
  2261. r;
  2262. case S.StartPacketTransfer:
  2263. return r.clientRequest = {
  2264. command: "StartPacketTransfer"
  2265. },
  2266. r;
  2267. case S.Reconnect:
  2268. return r.clientRequest = {
  2269. command: "Reconnect"
  2270. },
  2271. r;
  2272. case S.StopPacketTransfer:
  2273. return r.clientRequest = {
  2274. command: "StopPacketTransfer"
  2275. },
  2276. r;
  2277. case S.UpdateDestChannel:
  2278. return t.getDestChannelMediaInfos().forEach((function(e) {
  2279. a.push(e.channelName),
  2280. i.push(e.uid + ""),
  2281. o.push(e.token || n.appId)
  2282. })),
  2283. r.clientRequest = {
  2284. command: "UpdateDestChannel",
  2285. channelName: a,
  2286. uid: i,
  2287. token: o
  2288. },
  2289. r
  2290. }
  2291. },
  2292. t.prototype._checkSignal = function() {
  2293. if (!this._signal || !this._signal.isConnect()) throw new b(v.WS_DISCONNECTED)
  2294. },
  2295. t
  2296. } (c.
  2297. default);
  2298. t.
  2299. default = g;
  2300. var m = function() {
  2301. function e() {
  2302. this.destChannelMediaInfos = new Map
  2303. }
  2304. return e.prototype.setSrcChannelInfo = function(e) {
  2305. l.checkValidObject(e, "srcInfo");
  2306. var t = e.uid,
  2307. n = e.channelName,
  2308. a = e.token;
  2309. if (a && !l.isValidToken(a)) throw new Error("Invalid token in SrcChannelInfo");
  2310. if (!l.isValidChannelName(n)) throw new Error("Invalid channelName in SrcChannelInfo");
  2311. if (!f.is32Uint(t)) throw new Error("Invalid uid in SrcChannelInfo");
  2312. this.srcChannelMediaInfo = e
  2313. },
  2314. e.prototype.setDestChannelInfo = function(e, t) {
  2315. if (!l.isValidChannelName(e)) throw new Error("Invalid channelName in DestChannelInfo");
  2316. l.checkValidObject(t, "destInfo");
  2317. var n = t.uid,
  2318. a = t.token,
  2319. i = t.channelName;
  2320. if (a && !l.isValidToken(a)) throw new Error("Invalid token in DestChannelInfo");
  2321. if (!l.isValidChannelName(i)) throw new Error("Invalid channelName in DestChannelInfo");
  2322. if (!f.is32Uint(n)) throw new Error("Invalid uid in DestChannelInfo");
  2323. this.destChannelMediaInfos.set(e, t)
  2324. },
  2325. e.prototype.removeDestChannelInfo = function(e) {
  2326. if (!l.isValidChannelName(e)) throw new Error("Invalid channelName when invoke removeDestChannelInfo");
  2327. this.destChannelMediaInfos.delete(e)
  2328. },
  2329. e.prototype.getSrcChannelMediaInfo = function() {
  2330. return this.srcChannelMediaInfo
  2331. },
  2332. e.prototype.getDestChannelMediaInfos = function() {
  2333. return this.destChannelMediaInfos
  2334. },
  2335. e
  2336. } ();
  2337. t.ChannelMediaRelayConfiguration = m;
  2338. var v, S, E, _, h, I = function(e) {
  2339. function t(t, n, a, i) {
  2340. var o = e.call(this) || this;
  2341. return o._onOpen = function() {
  2342. o.emit("open")
  2343. },
  2344. o._onClose = function(e) {
  2345. o.emit("close"),
  2346. o.dispose()
  2347. },
  2348. o._onMessage = function(e) {
  2349. var t = JSON.parse(e.data);
  2350. if (!t || "serverResponse" !== t.command || !t.requestId) return t && "serverStatus" === t.command && t.serverStatus && t.serverStatus.command ? (o.emit("status", t.serverStatus), void o.emit(t.serverStatus.command, t.serverStatus)) : void 0;
  2351. o.emit("req_" + t.requestId, t)
  2352. },
  2353. o._requestId = 1,
  2354. o.appId = t,
  2355. o.cname = n,
  2356. o.uid = a,
  2357. o.sid = i,
  2358. o
  2359. }
  2360. return i(t, e),
  2361. t.prototype.isConnect = function() {
  2362. return this._ws && this._ws.readyState === WebSocket.OPEN
  2363. },
  2364. t.prototype.sendMessage = function(e) {
  2365. if (!this._ws || this._ws.readyState !== WebSocket.OPEN) throw new b(v.WS_DISCONNECTED);
  2366. var t = this._requestId++;
  2367. return e.requestId = t,
  2368. e.seq = t,
  2369. this._ws.send(JSON.stringify(e)),
  2370. t
  2371. },
  2372. t.prototype.waitStatus = function(e) {
  2373. var t = this;
  2374. return new Promise((function(n, a) {
  2375. var i = window.setTimeout((function() {
  2376. a(new b(v.WAIT_STATUS_TIMEOUT, e))
  2377. }), 5e3);
  2378. t.once(e, (function(t) {
  2379. clearTimeout(i),
  2380. t.state && 0 !== t.state ? a(new b(v.WAIT_STATUS_ERROR, e)) : n()
  2381. })),
  2382. t.once("dispose", (function() {
  2383. clearTimeout(i),
  2384. a(new b(v.WS_ABORT))
  2385. }))
  2386. }))
  2387. },
  2388. t.prototype.request = function(e) {
  2389. var t = this;
  2390. return new Promise((function(n, a) {
  2391. var i = t.sendMessage(e),
  2392. o = window.setTimeout((function() {
  2393. t.removeAllListeners("req_" + i),
  2394. a(new b(v.REQUEST_TIMEOUT))
  2395. }), 3e3);
  2396. t.once("req_" + i, (function(e) {
  2397. clearTimeout(o),
  2398. e && 200 === e.code ? n(e) : a(new b(v.REQUEST_FAILED, e))
  2399. })),
  2400. t.once("dispose", (function() {
  2401. clearTimeout(o),
  2402. a(new b(v.WS_ABORT))
  2403. }))
  2404. }))
  2405. },
  2406. t.prototype.connect = function(e) {
  2407. var t = this;
  2408. return new Promise((function(n, a) {
  2409. t._ws = new WebSocket(e),
  2410. t._ws.onopen = function() {
  2411. t._onOpen(),
  2412. t._prvUrl = e,
  2413. t._ws.onmessage = t._onMessage,
  2414. t._ws.onclose = t._onClose,
  2415. t._startHeartBeatCheck(),
  2416. n()
  2417. },
  2418. t._ws.onclose = function(e) {
  2419. t._ws = null,
  2420. a(new b(v.CONNECT_FAILED, "websocket error code: " + e.code))
  2421. },
  2422. setTimeout((function() {
  2423. t._ws && t._ws.readyState !== WebSocket.OPEN && (t._ws.onopen = null, t._ws.onclose = null, t._ws.close(), t._ws = null, a(new b(v.CONNECT_TIMEOUT)))
  2424. }), 5e3),
  2425. t.once("dispose", (function() {
  2426. a(new b(v.WS_ABORT))
  2427. }))
  2428. }))
  2429. },
  2430. t.prototype.dispose = function() {
  2431. this._clearHeartBeatCheck(),
  2432. this.emit("dispose"),
  2433. this.removeEvent(),
  2434. this._ws && (this._ws.onopen = null, this._ws.onclose = null, this._ws.onmessage = null, this._ws.close()),
  2435. this._ws = null
  2436. },
  2437. t.prototype._sendPing = function(e) {
  2438. if (!this._ws || this._ws.readyState !== WebSocket.OPEN) throw new b(v.WS_DISCONNECTED);
  2439. var t = this._requestId++;
  2440. return e.requestId = t,
  2441. this._ws.send(JSON.stringify(e)),
  2442. t
  2443. },
  2444. t.prototype._startHeartBeatCheck = function() {
  2445. var e = this;
  2446. this._heartBeatTimer = window.setInterval((function() {
  2447. e._sendPing({
  2448. command: "ping",
  2449. appId: e.appId,
  2450. cname: e.cname,
  2451. uid: e.uid + "",
  2452. sid: e.sid,
  2453. ts: +new Date,
  2454. requestId: 0
  2455. })
  2456. }), 3e3)
  2457. },
  2458. t.prototype._clearHeartBeatCheck = function() {
  2459. window.clearInterval(this._heartBeatTimer)
  2460. },
  2461. t
  2462. } (c.
  2463. default),
  2464. b = function(e, t, n) {
  2465. void 0 === e && (e = ""),
  2466. this.code = n,
  2467. this.data = t,
  2468. this.message = e
  2469. };
  2470. t.ChannelMediaError = b,
  2471. function(e) {
  2472. e.CONNECT_FAILED = "connect failed",
  2473. e.CONNECT_TIMEOUT = "connect timeout",
  2474. e.WS_DISCONNECTED = "websocket disconnected",
  2475. e.REQUEST_TIMEOUT = "request timeout",
  2476. e.REQUEST_FAILED = "request failed",
  2477. e.WAIT_STATUS_TIMEOUT = "wait status timeout",
  2478. e.WAIT_STATUS_ERROR = "wait status error",
  2479. e.BAD_STATE = "bad state",
  2480. e.WS_ABORT = "ws abort",
  2481. e.AP_REQUEST_TIMEOUT = "AP request timeout",
  2482. e.AP_JSON_PARSE_ERROR = "AP json parse error",
  2483. e.AP_REQUEST_ERROR = "AP request error",
  2484. e.AP_REQUEST_ABORT = "AP request abort"
  2485. } (v = t.CHANNEL_MEDIA_ERROR || (t.CHANNEL_MEDIA_ERROR = {})),
  2486. function(e) {
  2487. e[e.SetSdkProfile = 0] = "SetSdkProfile",
  2488. e[e.SetSourceChannel = 1] = "SetSourceChannel",
  2489. e[e.SetSourceUserId = 2] = "SetSourceUserId",
  2490. e[e.SetDestChannel = 3] = "SetDestChannel",
  2491. e[e.StartPacketTransfer = 4] = "StartPacketTransfer",
  2492. e[e.StopPacketTransfer = 5] = "StopPacketTransfer",
  2493. e[e.UpdateDestChannel = 6] = "UpdateDestChannel",
  2494. e[e.Reconnect = 7] = "Reconnect",
  2495. e[e.SetVideoProfile = 8] = "SetVideoProfile"
  2496. } (S || (S = {})),
  2497. function(e) {
  2498. e[e.NETWORK_DISCONNECTED = 0] = "NETWORK_DISCONNECTED",
  2499. e[e.NETWORK_CONNECTED = 1] = "NETWORK_CONNECTED",
  2500. e[e.PACKET_JOINED_SRC_CHANNEL = 2] = "PACKET_JOINED_SRC_CHANNEL",
  2501. e[e.PACKET_JOINED_DEST_CHANNEL = 3] = "PACKET_JOINED_DEST_CHANNEL",
  2502. e[e.PACKET_SENT_TO_DEST_CHANNEL = 4] = "PACKET_SENT_TO_DEST_CHANNEL",
  2503. e[e.PACKET_RECEIVED_VIDEO_FROM_SRC = 5] = "PACKET_RECEIVED_VIDEO_FROM_SRC",
  2504. e[e.PACKET_RECEIVED_AUDIO_FROM_SRC = 6] = "PACKET_RECEIVED_AUDIO_FROM_SRC",
  2505. e[e.PACKET_UPDATE_DEST_CHANNEL = 7] = "PACKET_UPDATE_DEST_CHANNEL",
  2506. e[e.PACKET_UPDATE_DEST_CHANNEL_REFUSED = 8] = "PACKET_UPDATE_DEST_CHANNEL_REFUSED",
  2507. e[e.PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE = 9] = "PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE"
  2508. } (E = t.CHANNEL_MEDIA_RELAY_EVENT || (t.CHANNEL_MEDIA_RELAY_EVENT = {})),
  2509. function(e) {
  2510. e[e.RELAY_STATE_IDLE = 0] = "RELAY_STATE_IDLE",
  2511. e[e.RELAY_STATE_CONNECTING = 1] = "RELAY_STATE_CONNECTING",
  2512. e[e.RELAY_STATE_RUNNING = 2] = "RELAY_STATE_RUNNING",
  2513. e[e.RELAY_STATE_FAILURE = 3] = "RELAY_STATE_FAILURE"
  2514. } (_ = t.CHANNEL_MEDIA_RELAY_STATE || (t.CHANNEL_MEDIA_RELAY_STATE = {})),
  2515. function(e) {
  2516. e[e.RELAY_OK = 0] = "RELAY_OK",
  2517. e[e.SERVER_ERROR_RESPONSE = 1] = "SERVER_ERROR_RESPONSE",
  2518. e[e.SERVER_NO_RESPONSE = 2] = "SERVER_NO_RESPONSE",
  2519. e[e.NO_RESOURCE_AVAILABLE = 3] = "NO_RESOURCE_AVAILABLE",
  2520. e[e.FAILED_JOIN_SRC = 4] = "FAILED_JOIN_SRC",
  2521. e[e.FAILED_JOIN_DEST = 5] = "FAILED_JOIN_DEST",
  2522. e[e.FAILED_PACKET_RECEIVED_FROM_SRC = 6] = "FAILED_PACKET_RECEIVED_FROM_SRC",
  2523. e[e.FAILED_PACKET_SENT_TO_DEST = 7] = "FAILED_PACKET_SENT_TO_DEST",
  2524. e[e.SERVER_CONNECTION_LOST = 8] = "SERVER_CONNECTION_LOST",
  2525. e[e.INTERNAL_ERROR = 9] = "INTERNAL_ERROR",
  2526. e[e.SRC_TOKEN_EXPIRED = 10] = "SRC_TOKEN_EXPIRED",
  2527. e[e.DEST_TOKEN_EXPIRED = 11] = "DEST_TOKEN_EXPIRED",
  2528. e[e.RELAY_ALREADY_START = 12] = "RELAY_ALREADY_START",
  2529. e[e.RELAY_NOT_START = 13] = "RELAY_NOT_START",
  2530. e[e.OPERATION_ABORT = 14] = "OPERATION_ABORT"
  2531. } (h = t.CHANNEL_MEDIA_RELAY_ERROR || (t.CHANNEL_MEDIA_RELAY_ERROR = {}))
  2532. },
  2533. function(e, t) {
  2534. function n(t) {
  2535. return "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? e.exports = n = function(e) {
  2536. return typeof e
  2537. }: e.exports = n = function(e) {
  2538. return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol": typeof e
  2539. },
  2540. n(t)
  2541. }
  2542. e.exports = n
  2543. },
  2544. function(e, t, n) {
  2545. "use strict";
  2546. n.r(t),
  2547. n.d(t, "isLiveTranscodingValid", (function() {
  2548. return E
  2549. })),
  2550. n.d(t, "generateSessionId", (function() {
  2551. return m
  2552. })),
  2553. n.d(t, "audioLevelHelper", (function() {
  2554. return p
  2555. })),
  2556. n.d(t, "vsResHack", (function() {
  2557. return v
  2558. })),
  2559. n.d(t, "is32Uint", (function() {
  2560. return S
  2561. })),
  2562. n.d(t, "safeCall", (function() {
  2563. return l
  2564. })),
  2565. n.d(t, "random", (function() {
  2566. return h
  2567. })),
  2568. n.d(t, "popBanTip", (function() {
  2569. return T
  2570. })),
  2571. n.d(t, "lengthInUtf8Bytes", (function() {
  2572. return I
  2573. })),
  2574. n.d(t, "audioTimerLoop", (function() {
  2575. return b
  2576. })),
  2577. n.d(t, "generateId", (function() {
  2578. return g
  2579. }));
  2580. var a = n(9),
  2581. i = n.n(a),
  2582. o = n(5),
  2583. r = n(0),
  2584. s = n(15),
  2585. c = n.n(s),
  2586. d = n(14),
  2587. u = n(13),
  2588. l = function() {
  2589. var e = arguments[0];
  2590. if ("function" == typeof e) {
  2591. var t = Array.prototype.slice.call(arguments, 1);
  2592. e.apply(null, t)
  2593. }
  2594. },
  2595. p = function(e) {
  2596. return this.audioContext = Object(d.a)(),
  2597. this.sourceNode = e.otWebkitAudioSource || this.audioContext.createMediaStreamSource(e),
  2598. this.analyser = this.audioContext.createAnalyser(),
  2599. this.timeDomainData = new Uint8Array(this.analyser.frequencyBinCount),
  2600. this.sourceNode.connect(this.analyser),
  2601. this.getAudioLevel = function() {
  2602. if (this.analyser) {
  2603. this.analyser.getByteTimeDomainData(this.timeDomainData);
  2604. for (var e = 0,
  2605. t = 0; t < this.timeDomainData.length; t++) e = Math.max(e, Math.abs(this.timeDomainData[t] - 128));
  2606. return e / 128
  2607. }
  2608. return r.
  2609. default.warning("can't find analyser in audioLevelHelper"),
  2610. 0
  2611. },
  2612. this
  2613. },
  2614. f = 1e4;
  2615. function g() {
  2616. return++f
  2617. }
  2618. function m() {
  2619. return c()().replace(/-/g, "").toUpperCase()
  2620. }
  2621. var v = function(e, t, n) {
  2622. try {
  2623. r.
  2624. default.debug("start vsResHack", e);
  2625. var a = document.createElement("video");
  2626. a.setAttribute("autoplay", ""),
  2627. a.setAttribute("muted", ""),
  2628. a.muted = !0,
  2629. a.setAttribute("playsinline", ""),
  2630. a.setAttribute("style", "position: absolute; top: 0; left: 0; width:1px; high:1px;"),
  2631. document.body.appendChild(a),
  2632. a.addEventListener("playing", (function(n) {
  2633. o.isFireFox() ? a.videoWidth && (r.
  2634. default.debug("[vsResHack] get stream resolution: ", "".concat(a.videoWidth, " x ").concat(a.videoHeight), e), t(a.videoWidth, a.videoHeight), document.body.removeChild(a)) : (r.
  2635. default.debug("[vsResHack] get stream resolution: ", "".concat(a.videoWidth, " x ").concat(a.videoHeight), e), t(a.videoWidth, a.videoHeight), document.body.removeChild(a))
  2636. })),
  2637. Object(u.setSrcObject)(a, e)
  2638. } catch(e) {
  2639. n(e)
  2640. }
  2641. },
  2642. S = function(e) {
  2643. return "number" == typeof e && 0 <= e && e <= 4294967295
  2644. },
  2645. E = function(e) {
  2646. var t = ["lowLatency", "userConfigExtraInfo", "transcodingUsers"];
  2647. for (var n in e) if ("lowLatency" === n && "boolean" != typeof e[n] || "userConfigExtraInfo" === n && "object" !== i()(e[n]) || "transcodingUsers" === n && !_(e[n]) || !~t.indexOf(n) && "number" != typeof e[n]) throw new Error("Param [" + n + "] is inValid");
  2648. return ! 0
  2649. },
  2650. _ = function(e) {
  2651. for (var t = 0; t < e.length; t++) for (var n in e[t]) if ("number" != typeof e[t][n]) throw new Error("Param user[" + t + "] - [" + n + "] is inValid");
  2652. return ! 0
  2653. },
  2654. h = function(e) {
  2655. isNaN(e) && (e = 1e3);
  2656. var t = +new Date,
  2657. n = (t = (9301 * t + 49297) % 233280) / 233280;
  2658. return Math.ceil(n * e)
  2659. },
  2660. I = function(e) {
  2661. var t = encodeURIComponent(e).match(/%[89ABab]/g);
  2662. return e.length + (t ? t.length: 0)
  2663. },
  2664. b = function(e, t) {
  2665. var n = 1 / t,
  2666. a = Object(d.a)(),
  2667. i = a.createGain();
  2668. i.gain.value = 0,
  2669. i.connect(a.destination);
  2670. var o = !1;
  2671. return function t() {
  2672. var r = a.createOscillator();
  2673. r.onended = t,
  2674. r.connect(i),
  2675. r.start(0),
  2676. r.stop(a.currentTime + n),
  2677. e(a.currentTime),
  2678. o && (r.onended = function() {})
  2679. } (),
  2680. function() {
  2681. o = !0
  2682. }
  2683. },
  2684. T = function() {
  2685. if (!document.getElementById("agora-ban-tip")) {
  2686. var e = document.createElement("div");
  2687. e.id = "agora-ban-tip",
  2688. e.style = "position: absolute; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; color: #fff;",
  2689. document.querySelector("body").prepend(e);
  2690. var t = document.createElement("div");
  2691. t.style = "background: #000; width: 346px; height: 116px; z-index: 100000; opacity: 0.6; border-radius: 10px; box-shadow: 0 2px 4px #000;",
  2692. e.append(t);
  2693. var n = document.createElement("div");
  2694. n.style = "height: 76px; display: flex; justify-content: center; align-items: center;";
  2695. var a = document.createElement("span");
  2696. a.style = "height: 28px; width: 28px; color: #000; text-align: center; line-height: 30px; background: #fff; border-radius: 50%; font-weight: 600; font-size: 20px;margin-right: 5px;",
  2697. a.innerText = "!";
  2698. var i = document.createElement("span");
  2699. i.innerText = "This browser does not support webRTC",
  2700. n.append(a),
  2701. n.append(i);
  2702. var o = document.createElement("div");
  2703. o.style = "height: 38px; display: flex; border-top: #fff 1px solid; justify-content: center; align-items: center;",
  2704. o.innerText = "OK",
  2705. t.append(n),
  2706. t.append(o),
  2707. o.onclick = function() {
  2708. var e = document.getElementById("agora-ban-tip");
  2709. e.parentNode.removeChild(e)
  2710. }
  2711. }
  2712. }
  2713. },
  2714. function(e, t, n) {
  2715. "use strict";
  2716. n.r(t),
  2717. n.d(t, "post", (function() {
  2718. return u
  2719. })),
  2720. n.d(t, "shouldUseHttps", (function() {
  2721. return l
  2722. })),
  2723. n.d(t, "getHTTPSendBytes", (function() {
  2724. return s
  2725. })),
  2726. n.d(t, "getHTTPRecvBytes", (function() {
  2727. return c
  2728. })),
  2729. n.d(t, "resetHTTPByetsCount", (function() {
  2730. return d
  2731. }));
  2732. var a = n(3),
  2733. i = n(10),
  2734. o = 0,
  2735. r = 0,
  2736. s = function() {
  2737. return o
  2738. },
  2739. c = function() {
  2740. return r
  2741. },
  2742. d = function() {
  2743. o = 0,
  2744. r = 0
  2745. },
  2746. u = function(e, t, n, s, c) {
  2747. var d = new XMLHttpRequest;
  2748. if (d.timeout = t.timeout || Object(a.getParameter)("HTTP_CONNECT_TIMEOUT"), d.open("POST", e, !0), d.setRequestHeader("Content-type", "application/json; charset=utf-8"), c) for (var u in c)"withCredentials" == u ? d.withCredentials = !0 : d.setRequestHeader(u, c[u]);
  2749. d.onload = function(e) {
  2750. r += Object(i.lengthInUtf8Bytes)(d.responseText),
  2751. n && n(d.responseText)
  2752. },
  2753. d.onerror = function(t) {
  2754. s && s(t, e)
  2755. },
  2756. d.ontimeout = function(t) {
  2757. s && s(t, e)
  2758. };
  2759. var l = JSON.stringify(t);
  2760. o += Object(i.lengthInUtf8Bytes)(l),
  2761. d.send(l)
  2762. },
  2763. l = function() {
  2764. return "https:" == document.location.protocol
  2765. }
  2766. },
  2767. function(e, t) {
  2768. function n(e, t, n, a, i, o, r) {
  2769. try {
  2770. var s = e[o](r),
  2771. c = s.value
  2772. } catch(e) {
  2773. return void n(e)
  2774. }
  2775. s.done ? t(c) : Promise.resolve(c).then(a, i)
  2776. }
  2777. e.exports = function(e) {
  2778. return function() {
  2779. var t = this,
  2780. a = arguments;
  2781. return new Promise((function(i, o) {
  2782. var r = e.apply(t, a);
  2783. function s(e) {
  2784. n(r, i, o, s, c, "next", e)
  2785. }
  2786. function c(e) {
  2787. n(r, i, o, s, c, "throw", e)
  2788. }
  2789. s(void 0)
  2790. }))
  2791. }
  2792. }
  2793. },
  2794. function(e, t, n) {
  2795. "use strict";
  2796. n.r(t),
  2797. n.d(t, "RTCPeerConnection", (function() {
  2798. return T
  2799. })),
  2800. n.d(t, "getUserMedia", (function() {
  2801. return r
  2802. })),
  2803. n.d(t, "attachMediaStream", (function() {
  2804. return s
  2805. })),
  2806. n.d(t, "reattachMediaStream", (function() {
  2807. return c
  2808. })),
  2809. n.d(t, "setSrcObject", (function() {
  2810. return f
  2811. })),
  2812. n.d(t, "getSrcObject", (function() {
  2813. return g
  2814. })),
  2815. n.d(t, "webrtcDetectedBrowser", (function() {
  2816. return d
  2817. })),
  2818. n.d(t, "webrtcDetectedVersion", (function() {
  2819. return u
  2820. })),
  2821. n.d(t, "webrtcMinimumVersion", (function() {
  2822. return l
  2823. })),
  2824. n.d(t, "webrtcTesting", (function() {
  2825. return R
  2826. })),
  2827. n.d(t, "webrtcUtils", (function() {
  2828. return S
  2829. }));
  2830. var a = n(9),
  2831. i = n.n(a),
  2832. o = n(5),
  2833. r = null,
  2834. s = null,
  2835. c = null,
  2836. d = null,
  2837. u = null,
  2838. l = null,
  2839. p = null,
  2840. f = null,
  2841. g = null,
  2842. m = null,
  2843. v = {
  2844. addStream: null
  2845. },
  2846. S = {
  2847. log: function() {},
  2848. extractVersion: function(e, t, n) {
  2849. var a = e.match(t);
  2850. return a && a.length >= n && parseInt(a[n])
  2851. }
  2852. };
  2853. if ("object" == ("undefined" == typeof window ? "undefined": i()(window)) ? (window.HTMLMediaElement && !("srcObject" in window.HTMLMediaElement.prototype) ? (f = function(e, t) {
  2854. "mozSrcObject" in e ? e.mozSrcObject = t: (e._srcObject = t, e.src = t ? URL.createObjectURL(t) : null)
  2855. },
  2856. g = function(e) {
  2857. return "mozSrcObject" in e ? e.mozSrcObject: e._srcObject
  2858. }) : (f = function(e, t) {
  2859. e.srcObject = t
  2860. },
  2861. g = function(e) {
  2862. return e.srcObject
  2863. }), r = window.navigator && window.navigator.getUserMedia) : (f = function(e, t) {
  2864. e.srcObject = t
  2865. },
  2866. g = function(e) {
  2867. return e.srcObject
  2868. }), s = function(e, t) {
  2869. f(e, t)
  2870. },
  2871. c = function(e, t) {
  2872. f(e, g(t))
  2873. },
  2874. "undefined" != typeof window && window.navigator) if (navigator.mozGetUserMedia && window.mozRTCPeerConnection) {
  2875. for (var E in S.log("This appears to be Firefox"), d = "firefox", u = S.extractVersion(navigator.userAgent, /Firefox\/([0-9]+)\./, 1), l = 31, m = mozRTCPeerConnection, v) v[E] = m.prototype[E];
  2876. if (p = function(e, t) {
  2877. if (u < 38 && e && e.iceServers) {
  2878. for (var n = [], a = 0; a < e.iceServers.length; a++) {
  2879. var i = e.iceServers[a];
  2880. if (i.hasOwnProperty("urls")) for (var o = 0; o < i.urls.length; o++) {
  2881. var r = {
  2882. url: i.urls[o]
  2883. };
  2884. 0 === i.urls[o].indexOf("turn") && (r.username = i.username, r.credential = i.credential),
  2885. n.push(r)
  2886. } else n.push(e.iceServers[a])
  2887. }
  2888. e.iceServers = n
  2889. }
  2890. var s = new m(e, t);
  2891. for (var c in v) s[c] = v[c];
  2892. return s
  2893. },
  2894. window.RTCSessionDescription || (window.RTCSessionDescription = mozRTCSessionDescription), window.RTCIceCandidate || (window.RTCIceCandidate = mozRTCIceCandidate), r = function(e, t, n) {
  2895. var a = function(e) {
  2896. if ("object" !== i()(e) || e.require) return e;
  2897. var t = [];
  2898. return Object.keys(e).forEach((function(n) {
  2899. if ("require" !== n && "advanced" !== n && "mediaSource" !== n) {
  2900. var a = e[n] = "object" === i()(e[n]) ? e[n] : {
  2901. ideal: e[n]
  2902. };
  2903. if (void 0 === a.min && void 0 === a.max && void 0 === a.exact || t.push(n), void 0 !== a.exact && ("number" == typeof a.exact ? a.min = a.max = a.exact: e[n] = a.exact, delete a.exact), void 0 !== a.ideal) {
  2904. e.advanced = e.advanced || [];
  2905. var o = {};
  2906. "number" == typeof a.ideal ? o[n] = {
  2907. min: a.ideal,
  2908. max: a.ideal
  2909. }: o[n] = a.ideal,
  2910. e.advanced.push(o),
  2911. delete a.ideal,
  2912. Object.keys(a).length || delete e[n]
  2913. }
  2914. }
  2915. })),
  2916. t.length && (e.require = t),
  2917. e
  2918. };
  2919. return u < 38 && (S.log("spec: " + JSON.stringify(e)), e.audio && (e.audio = a(e.audio)), e.video && (e.video = a(e.video)), S.log("ff37: " + JSON.stringify(e))),
  2920. navigator.mozGetUserMedia(e, t, n)
  2921. },
  2922. navigator.getUserMedia = r, navigator.mediaDevices || (navigator.mediaDevices = {
  2923. getUserMedia: b,
  2924. addEventListener: function() {},
  2925. removeEventListener: function() {}
  2926. }), navigator.mediaDevices.enumerateDevices = navigator.mediaDevices.enumerateDevices ||
  2927. function() {
  2928. return new Promise((function(e) {
  2929. e([{
  2930. kind: "audioinput",
  2931. deviceId: "default",
  2932. label: "",
  2933. groupId: ""
  2934. },
  2935. {
  2936. kind: "videoinput",
  2937. deviceId: "default",
  2938. label: "",
  2939. groupId: ""
  2940. }])
  2941. }))
  2942. },
  2943. u < 41) {
  2944. var _ = navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);
  2945. navigator.mediaDevices.enumerateDevices = function() {
  2946. return _().then(void 0, (function(e) {
  2947. if ("NotFoundError" === e.name) return [];
  2948. throw e
  2949. }))
  2950. }
  2951. }
  2952. } else if (navigator.webkitGetUserMedia && window.webkitRTCPeerConnection) {
  2953. for (var E in S.log("This appears to be Chrome"), d = "chrome", u = S.extractVersion(navigator.userAgent, /Chrom(e|ium)\/([0-9]+)\./, 2), l = 38, m = webkitRTCPeerConnection, v) v[E] = m.prototype[E];
  2954. p = function(e, t) {
  2955. e && e.iceTransportPolicy && (e.iceTransports = e.iceTransportPolicy);
  2956. var n = new m(e, t);
  2957. for (var a in v) n[a] = v[a];
  2958. var i = n.getStats.bind(n);
  2959. return n.getStats = function(e, t, n) {
  2960. var a = arguments;
  2961. a.length > 0 && "function" == typeof e && (t ? (n = t, t = e, a = [e = null, t, n]) : (t = e, a = [e = null, t]));
  2962. var o = function(e) {
  2963. var t = {};
  2964. return e.result().forEach((function(e) {
  2965. var n = {
  2966. id: e.id,
  2967. timestamp: e.timestamp,
  2968. type: e.type
  2969. };
  2970. e.names().forEach((function(t) {
  2971. n[t] = e.stat(t)
  2972. })),
  2973. t[n.id] = n
  2974. })),
  2975. t
  2976. };
  2977. if (a.length >= 2) {
  2978. var r = function(e) {
  2979. a[1](o(e))
  2980. };
  2981. return i.apply(this, [r, a[0]])
  2982. }
  2983. return i()
  2984. },
  2985. n
  2986. },
  2987. ["createOffer", "createAnswer"].forEach((function(e) {
  2988. var t = webkitRTCPeerConnection.prototype[e];
  2989. webkitRTCPeerConnection.prototype[e] = function() {
  2990. var e = this;
  2991. if (arguments.length < 1 || 1 === arguments.length && "object" === i()(arguments[0])) {
  2992. var n = 1 === arguments.length ? arguments[0] : void 0;
  2993. return new Promise((function(a, i) {
  2994. t.apply(e, [a, i, n])
  2995. }))
  2996. }
  2997. return t.apply(this, arguments)
  2998. }
  2999. })),
  3000. ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach((function(e) {
  3001. var t = webkitRTCPeerConnection.prototype[e];
  3002. webkitRTCPeerConnection.prototype[e] = function() {
  3003. var e = arguments,
  3004. n = this;
  3005. return new Promise((function(a, i) {
  3006. t.apply(n, [e[0],
  3007. function() {
  3008. a(),
  3009. e.length >= 2 && e[1].apply(null, [])
  3010. },
  3011. function(t) {
  3012. i(t),
  3013. e.length >= 3 && e[2].apply(null, [t])
  3014. }])
  3015. }))
  3016. }
  3017. }));
  3018. var h = function(e) {
  3019. if ("object" !== i()(e) || e.mandatory || e.optional) return e;
  3020. var t = {};
  3021. return Object.keys(e).forEach((function(n) {
  3022. if ("require" !== n && "advanced" !== n && "mediaSource" !== n) {
  3023. var a = "object" === i()(e[n]) ? e[n] : {
  3024. ideal: e[n]
  3025. };
  3026. void 0 !== a.exact && "number" == typeof a.exact && (a.min = a.max = a.exact);
  3027. var o = function(e, t) {
  3028. return e ? e + t.charAt(0).toUpperCase() + t.slice(1) : "deviceId" === t ? "sourceId": t
  3029. };
  3030. if (void 0 !== a.ideal) {
  3031. t.optional = t.optional || [];
  3032. var r = {};
  3033. "number" == typeof a.ideal ? (r[o("min", n)] = a.ideal, t.optional.push(r), (r = {})[o("max", n)] = a.ideal, t.optional.push(r)) : (r[o("", n)] = a.ideal, t.optional.push(r))
  3034. }
  3035. void 0 !== a.exact && "number" != typeof a.exact ? (t.mandatory = t.mandatory || {},
  3036. t.mandatory[o("", n)] = a.exact) : ["min", "max"].forEach((function(e) {
  3037. void 0 !== a[e] && (t.mandatory = t.mandatory || {},
  3038. t.mandatory[o(e, n)] = a[e])
  3039. }))
  3040. }
  3041. })),
  3042. e.advanced && (t.optional = (t.optional || []).concat(e.advanced)),
  3043. t
  3044. };
  3045. if (r = function(e, t, n) {
  3046. return e.audio && (e.audio = h(e.audio)),
  3047. e.video && (e.video = h(e.video)),
  3048. S.log("chrome: " + JSON.stringify(e)),
  3049. navigator.webkitGetUserMedia(e, t, n)
  3050. },
  3051. navigator.getUserMedia = r, navigator.mediaDevices || (navigator.mediaDevices = {
  3052. getUserMedia: b,
  3053. enumerateDevices: function() {
  3054. return new Promise((function(e) {
  3055. var t = {
  3056. audio: "audioinput",
  3057. video: "videoinput"
  3058. };
  3059. return MediaStreamTrack.getSources((function(n) {
  3060. e(n.map((function(e) {
  3061. return {
  3062. label: e.label,
  3063. kind: t[e.kind],
  3064. deviceId: e.id,
  3065. groupId: ""
  3066. }
  3067. })))
  3068. }))
  3069. }))
  3070. }
  3071. }), navigator.mediaDevices.getUserMedia) {
  3072. if ((Object(o.getBrowserVersion)() ? Number(Object(o.getBrowserVersion)().split(".")[0]) : void 0) < 46) {
  3073. var I = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
  3074. navigator.mediaDevices.getUserMedia = function(e) {
  3075. return S.log("spec: " + JSON.stringify(e)),
  3076. e.audio = h(e.audio),
  3077. e.video = h(e.video),
  3078. S.log("chrome: " + JSON.stringify(e)),
  3079. I(e)
  3080. }
  3081. }
  3082. } else navigator.mediaDevices.getUserMedia = function(e) {
  3083. return b(e)
  3084. };
  3085. void 0 === navigator.mediaDevices.addEventListener && (navigator.mediaDevices.addEventListener = function() {
  3086. S.log("Dummy mediaDevices.addEventListener called.")
  3087. }),
  3088. void 0 === navigator.mediaDevices.removeEventListener && (navigator.mediaDevices.removeEventListener = function() {
  3089. S.log("Dummy mediaDevices.removeEventListener called.")
  3090. }),
  3091. s = function(e, t) {
  3092. u >= 43 ? f(e, t) : void 0 !== e.src ? e.src = t ? URL.createObjectURL(t) : null: S.log("Error attaching stream to element.")
  3093. },
  3094. c = function(e, t) {
  3095. u >= 43 ? f(e, g(t)) : e.src = t.src
  3096. }
  3097. } else navigator.mediaDevices && navigator.userAgent.match(/Edge\/(\d+).(\d+)$/) ? (S.log("This appears to be Edge"), d = "edge", u = S.extractVersion(navigator.userAgent, /Edge\/(\d+).(\d+)$/, 2), l = 12) : S.log("Browser does not appear to be WebRTC-capable");
  3098. else S.log("This does not appear to be a browser"),
  3099. d = "not a browser";
  3100. function b(e) {
  3101. return new Promise((function(t, n) {
  3102. r(e, t, n)
  3103. }))
  3104. }
  3105. var T, R = {};
  3106. try {
  3107. Object.defineProperty(R, "version", {
  3108. set: function(e) {
  3109. u = e
  3110. }
  3111. })
  3112. } catch(e) {}
  3113. p ? T = p: "undefined" != typeof window && (T = window.RTCPeerConnection)
  3114. },
  3115. function(e, t, n) {
  3116. "use strict";
  3117. n.d(t, "a", (function() {
  3118. return s
  3119. }));
  3120. var a = window.AudioContext || window.webkitAudioContext,
  3121. i = n(3),
  3122. o = i.getParameter,
  3123. r = i.setParameter,
  3124. s = function() {
  3125. return o("AUDIO_CONTEXT") || (console.log("Creating Audio Context"), r("AUDIO_CONTEXT",
  3126. function() {
  3127. if (a) return new a;
  3128. throw new Error("AUDIO_CONTEXT_NOT_SUPPORTED")
  3129. } ())),
  3130. o("AUDIO_CONTEXT")
  3131. }
  3132. },
  3133. function(e, t, n) {
  3134. var a = n(29),
  3135. i = n(30);
  3136. e.exports = function(e, t, n) {
  3137. var o = t && n || 0;
  3138. "string" == typeof e && (t = "binary" === e ? new Array(16) : null, e = null);
  3139. var r = (e = e || {}).random || (e.rng || a)();
  3140. if (r[6] = 15 & r[6] | 64, r[8] = 63 & r[8] | 128, t) for (var s = 0; s < 16; ++s) t[o + s] = r[s];
  3141. return t || i(r)
  3142. }
  3143. },
  3144. function(e, t, n) {
  3145. "use strict";
  3146. var a = this && this.__importDefault ||
  3147. function(e) {
  3148. return e && e.__esModule ? e: {
  3149. default:
  3150. e
  3151. }
  3152. };
  3153. Object.defineProperty(t, "__esModule", {
  3154. value: !0
  3155. });
  3156. var i, o, r = a(n(0)); !
  3157. function(e) {
  3158. e.CHINA = "CHINA",
  3159. e.ASIA = "ASIA",
  3160. e.NORTH_AMERICA = "NORTH_AMERICA",
  3161. e.EUROPE = "EUROPE",
  3162. e.JAPAN = "JAPAN",
  3163. e.INDIA = "INDIA",
  3164. e.OCEANIA = "OCEANIA",
  3165. e.SOUTH_AMERICA = "SOUTH_AMERICA",
  3166. e.AFRICA = "AFRICA",
  3167. e.OVERSEA = "OVERSEA",
  3168. e.GLOBAL = "GLOBAL"
  3169. } (i || (i = {})),
  3170. t.AREAS = i,
  3171. function(e) {
  3172. e.CHINA = "CN",
  3173. e.ASIA = "AS",
  3174. e.NORTH_AMERICA = "NA",
  3175. e.EUROPE = "EU",
  3176. e.JAPAN = "JP",
  3177. e.INDIA = "IN",
  3178. e.OCEANIA = "OC",
  3179. e.SOUTH_AMERICA = "SA",
  3180. e.AFRICA = "AF",
  3181. e.OVERSEA = "OVERSEA",
  3182. e.GLOBAL = "GLOBAL"
  3183. } (o || (o = {}));
  3184. var s = {
  3185. ASIA: {
  3186. CODE: o.ASIA,
  3187. WEBCS_DOMAIN: ["ap-web-1-asia.agora.io"],
  3188. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-asia.agora.io"],
  3189. PROXY_CS: ["proxy-ap-web-asia.agora.io"],
  3190. CDS_AP: ["cds-ap-web-asia.agora.io", "cds-ap-web-asia2.agora.io"],
  3191. ACCOUNT_REGISTER: ["sua-ap-web-asia.agora.io", "sua-ap-web-asia2.agora.io"],
  3192. UAP_AP: ["uap-ap-web-asia.agora.io", "uap-ap-web-asia2.agora.io"],
  3193. EVENT_REPORT_DOMAIN: ["statscollector-1-asia.agora.io"],
  3194. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-asia.agora.io"],
  3195. LOG_UPLOAD_SERVER: ["logservice-asia.agora.io"]
  3196. },
  3197. NORTH_AMERICA: {
  3198. CODE: o.NORTH_AMERICA,
  3199. WEBCS_DOMAIN: ["ap-web-1-north-america.agora.io"],
  3200. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-north-america.agora.io"],
  3201. PROXY_CS: ["proxy-ap-web-america.agora.io"],
  3202. CDS_AP: ["cds-ap-web-america.agora.io", "cds-ap-web-america2.agora.io"],
  3203. ACCOUNT_REGISTER: ["sua-ap-web-america.agora.io", "sua-ap-web-america2.agora.io"],
  3204. UAP_AP: ["uap-ap-web-america.agora.io", "uap-ap-web-america2.agora.io"],
  3205. EVENT_REPORT_DOMAIN: ["statscollector-1-north-america.agora.io"],
  3206. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-north-america.agora.io"],
  3207. LOG_UPLOAD_SERVER: ["logservice-north-america.agora.io"]
  3208. },
  3209. EUROPE: {
  3210. CODE: o.EUROPE,
  3211. WEBCS_DOMAIN: ["ap-web-1-europe.agora.io"],
  3212. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-europe.agora.io"],
  3213. PROXY_CS: ["proxy-ap-web-europe.agora.io"],
  3214. CDS_AP: ["cds-ap-web-europe.agora.io", "cds-ap-web-europe2.agora.io"],
  3215. ACCOUNT_REGISTER: ["sua-ap-web-europe.agora.io", "sua-ap-web-europe.agora.io"],
  3216. UAP_AP: ["uap-ap-web-europe.agora.io", "uap-ap-web-europe2.agora.io"],
  3217. EVENT_REPORT_DOMAIN: ["statscollector-1-europe.agora.io"],
  3218. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-europe.agora.io"],
  3219. LOG_UPLOAD_SERVER: ["logservice-europe.agora.io"]
  3220. },
  3221. JAPAN: {
  3222. CODE: o.JAPAN,
  3223. WEBCS_DOMAIN: ["ap-web-1-japan.agora.io"],
  3224. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-japan.agora.io"],
  3225. PROXY_CS: ["proxy-ap-web-japan.agora.io"],
  3226. CDS_AP: ["cds-ap-web-japan.agora.io", "cds-ap-web-japan2.agora.io"],
  3227. ACCOUNT_REGISTER: ["sua-ap-web-japan.agora.io", "sua-ap-web-japan2.agora.io"],
  3228. UAP_AP: ["uap-ap-web-japan.agora.io", "\tuap-ap-web-japan2.agora.io"],
  3229. EVENT_REPORT_DOMAIN: ["statscollector-1-japan.agora.io"],
  3230. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-japan.agora.io"],
  3231. LOG_UPLOAD_SERVER: ["logservice-japan.agora.io"]
  3232. },
  3233. INDIA: {
  3234. CODE: o.INDIA,
  3235. WEBCS_DOMAIN: ["ap-web-1-india.agora.io"],
  3236. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-india.agora.io"],
  3237. PROXY_CS: ["proxy-ap-web-india.agora.io"],
  3238. CDS_AP: ["cds-ap-web-india.agora.io", "cds-ap-web-india2.agora.io"],
  3239. ACCOUNT_REGISTER: ["sua-ap-web-india.agora.io", "sua-ap-web-india2.agora.io"],
  3240. UAP_AP: ["uap-ap-web-india.agora.io", "uap-ap-web-india2.agora.io"],
  3241. EVENT_REPORT_DOMAIN: ["statscollector-1-india.agora.io"],
  3242. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-india.agora.io"],
  3243. LOG_UPLOAD_SERVER: ["logservice-india.agora.io"]
  3244. },
  3245. OVERSEA: {
  3246. CODE: o.OVERSEA,
  3247. WEBCS_DOMAIN: ["ap-web-1-oversea.agora.io"],
  3248. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-oversea.agora.io"],
  3249. PROXY_CS: ["proxy-ap-web-oversea.agora.io"],
  3250. CDS_AP: ["cds-ap-web-oversea.agora.io"],
  3251. ACCOUNT_REGISTER: ["sua-ap-web-oversea.agora.io"],
  3252. UAP_AP: ["uap-ap-web-oversea.agora.io"],
  3253. EVENT_REPORT_DOMAIN: ["statscollector-1-oversea.agora.io"],
  3254. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-oversea.agora.io"],
  3255. LOG_UPLOAD_SERVER: ["logservice-oversea.agora.io"]
  3256. },
  3257. GLOBAL: {
  3258. CODE: o.GLOBAL,
  3259. WEBCS_DOMAIN: ["webrtc2-ap-web-1.agora.io"],
  3260. WEBCS_DOMAIN_BACKUP_LIST: ["webrtc2-ap-web-3.agora.io"],
  3261. PROXY_CS: ["ap-proxy-1.agora.io", "ap-proxy-2.agora.io"],
  3262. CDS_AP: ["cds-ap-web-1.agora.io", "cds-ap-web-3.agora.io"],
  3263. ACCOUNT_REGISTER: ["sua-ap-web-1.agora.io", "sua-ap-web-3.agora.io"],
  3264. UAP_AP: ["uap-ap-web-1.agora.io", "uap-ap-web-3.agora.io"],
  3265. EVENT_REPORT_DOMAIN: ["statscollector-1.agora.io"],
  3266. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2.agora.io"],
  3267. LOG_UPLOAD_SERVER: ["logservice.agora.io"]
  3268. },
  3269. OCEANIA: {
  3270. CODE: o.OCEANIA,
  3271. WEBCS_DOMAIN: ["ap-web-1-oceania.agora.io"],
  3272. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-oceania.agora.io"],
  3273. PROXY_CS: ["proxy-ap-web-oceania.agora.io"],
  3274. CDS_AP: ["cds-ap-web-oceania.agora.io", "cds-ap-web-oceania2.agora.io"],
  3275. ACCOUNT_REGISTER: ["sua-ap-web-oceania.agora.io", "sua-ap-web-oceania2.agora.io"],
  3276. UAP_AP: ["uap-ap-web-oceania.agora.io", "uap-ap-web-oceania2.agora.io"],
  3277. EVENT_REPORT_DOMAIN: ["statscollector-1-oceania.agora.io"],
  3278. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-oceania.agora.io"],
  3279. LOG_UPLOAD_SERVER: ["logservice-oceania.agora.io"]
  3280. },
  3281. SOUTH_AMERICA: {
  3282. CODE: o.SOUTH_AMERICA,
  3283. WEBCS_DOMAIN: ["ap-web-1-south-america.agora.io"],
  3284. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-south-america.agora.io"],
  3285. PROXY_CS: ["proxy-ap-web-south-america.agora.io"],
  3286. CDS_AP: ["cds-ap-web-south-america.agora.io", "cds-ap-web-south-america2.agora.io"],
  3287. ACCOUNT_REGISTER: ["sua-ap-web-south-america.agora.io", "sua-ap-web-south-america2.agora.io"],
  3288. UAP_AP: ["uap-ap-web-south-america.agora.io", "uap-ap-web-south-america2.agora.io"],
  3289. EVENT_REPORT_DOMAIN: ["statscollector-1-south-america.agora.io"],
  3290. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-south-america.agora.io"],
  3291. LOG_UPLOAD_SERVER: ["logservice-south-america.agora.io"]
  3292. },
  3293. AFRICA: {
  3294. CODE: o.AFRICA,
  3295. WEBCS_DOMAIN: ["ap-web-1-africa.agora.io"],
  3296. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-africa.agora.io"],
  3297. PROXY_CS: ["proxy-ap-web-africa.agora.io"],
  3298. CDS_AP: ["cds-ap-web-africa.agora.io", "cds-ap-web-africa2.agora.io"],
  3299. ACCOUNT_REGISTER: ["sua-ap-web-africa.agora.io", "sua-ap-web-africa2.agora.io"],
  3300. UAP_AP: ["uap-ap-web-africa.agora.io", "uap-ap-web-africa2.agora.io"],
  3301. EVENT_REPORT_DOMAIN: ["statscollector-1-africa.agora.io"],
  3302. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-africa.agora.io"],
  3303. LOG_UPLOAD_SERVER: ["logservice-south-africa.agora.io"]
  3304. }
  3305. };
  3306. t.AREA_DOMAIN_MAP = s,
  3307. s.CHINA = {
  3308. CODE: o.CHINA,
  3309. WEBCS_DOMAIN: ["webrtc2-ap-web-2.agoraio.cn"],
  3310. WEBCS_DOMAIN_BACKUP_LIST: ["webrtc2-ap-web-4.agoraio.cn"],
  3311. PROXY_CS: ["proxy-ap-web.agoraio.cn"],
  3312. CDS_AP: ["cds-ap-web-2.agoraio.cn", "cds-ap-web-4.agoraio.cn"],
  3313. ACCOUNT_REGISTER: ["sua-ap-web-2.agoraio.cn", "sua-ap-web-4.agoraio.cn"],
  3314. UAP_AP: ["uap-ap-web-2.agoraio.cn", "uap-ap-web-4.agoraio.cn"],
  3315. EVENT_REPORT_DOMAIN: ["statscollector-3.agoraio.cn"],
  3316. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-4.agoraio.cn"],
  3317. LOG_UPLOAD_SERVER: ["logservice-china.agora.io"]
  3318. };
  3319. t.getAreaCodeByWebCS = function(e) {
  3320. for (var t = Object.keys(s), n = 0; n < t.length; n++) {
  3321. var a = t[n],
  3322. i = s[a];
  3323. if (i.WEBCS_DOMAIN.includes(e) || i.WEBCS_DOMAIN_BACKUP_LIST.includes(e)) return i.CODE === o.OVERSEA ? o.ASIA + "," + o.EUROPE + "," + o.AFRICA + "," + o.NORTH_AMERICA + "," + o.SOUTH_AMERICA + "," + o.OCEANIA: i.CODE
  3324. }
  3325. };
  3326. t.getAreaDomainConfig = function(e) {
  3327. var t = {
  3328. WEBCS_DOMAIN: [],
  3329. WEBCS_DOMAIN_BACKUP_LIST: [],
  3330. PROXY_CS: [],
  3331. CDS_AP: [],
  3332. ACCOUNT_REGISTER: [],
  3333. UAP_AP: [],
  3334. EVENT_REPORT_DOMAIN: [],
  3335. EVENT_REPORT_BACKUP_DOMAIN: [],
  3336. LOG_UPLOAD_SERVER: []
  3337. };
  3338. return e.map((function(e) {
  3339. var n = s[e],
  3340. a = Object.keys(n);
  3341. a ? a.map((function(e) {
  3342. "CODE" !== e && (t[e] = t[e].concat(n[e]))
  3343. })) : r.
  3344. default.info(e + " is not exist")
  3345. })),
  3346. t
  3347. }
  3348. },
  3349. function(e, t, n) {
  3350. var a = n(37),
  3351. i = n(38),
  3352. o = n(19),
  3353. r = n(39);
  3354. e.exports = function(e) {
  3355. return a(e) || i(e) || o(e) || r()
  3356. }
  3357. },
  3358. function(e, t, n) {
  3359. "use strict";
  3360. var a = this && this.__importDefault ||
  3361. function(e) {
  3362. return e && e.__esModule ? e: {
  3363. default:
  3364. e
  3365. }
  3366. };
  3367. Object.defineProperty(t, "__esModule", {
  3368. value: !0
  3369. });
  3370. var i, o, r = a(n(0)); !
  3371. function(e) {
  3372. e.CHINA = "CHINA",
  3373. e.ASIA = "ASIA",
  3374. e.NORTH_AMERICA = "NORTH_AMERICA",
  3375. e.EUROPE = "EUROPE",
  3376. e.JAPAN = "JAPAN",
  3377. e.INDIA = "INDIA",
  3378. e.OCEANIA = "OCEANIA",
  3379. e.SOUTH_AMERICA = "SOUTH_AMERICA",
  3380. e.AFRICA = "AFRICA",
  3381. e.OVERSEA = "OVERSEA",
  3382. e.GLOBAL = "GLOBAL"
  3383. } (i || (i = {})),
  3384. t.AREAS = i,
  3385. function(e) {
  3386. e.CHINA = "CN",
  3387. e.ASIA = "AS",
  3388. e.NORTH_AMERICA = "NA",
  3389. e.EUROPE = "EU",
  3390. e.JAPAN = "JP",
  3391. e.INDIA = "IN",
  3392. e.OCEANIA = "OC",
  3393. e.SOUTH_AMERICA = "SA",
  3394. e.AFRICA = "AF",
  3395. e.OVERSEA = "OVERSEA",
  3396. e.GLOBAL = "GLOBAL"
  3397. } (o || (o = {}));
  3398. var s = {
  3399. ASIA: {
  3400. CODE: o.ASIA,
  3401. WEBCS_DOMAIN: ["ap-web-1-asia.agora.io"],
  3402. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-asia.agora.io"],
  3403. PROXY_CS: ["proxy-ap-web-asia.agora.io"],
  3404. CDS_AP: ["cds-ap-web-asia.agora.io", "cds-ap-web-asia2.agora.io"],
  3405. ACCOUNT_REGISTER: ["sua-ap-web-asia.agora.io", "sua-ap-web-asia2.agora.io"],
  3406. UAP_AP: ["uap-ap-web-asia.agora.io", "uap-ap-web-asia2.agora.io"],
  3407. EVENT_REPORT_DOMAIN: ["statscollector-1-asia.agora.io"],
  3408. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-asia.agora.io"],
  3409. LOG_UPLOAD_SERVER: ["logservice-asia.agora.io"]
  3410. },
  3411. NORTH_AMERICA: {
  3412. CODE: o.NORTH_AMERICA,
  3413. WEBCS_DOMAIN: ["ap-web-1-north-america.agora.io"],
  3414. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-north-america.agora.io"],
  3415. PROXY_CS: ["proxy-ap-web-america.agora.io"],
  3416. CDS_AP: ["cds-ap-web-america.agora.io", "cds-ap-web-america2.agora.io"],
  3417. ACCOUNT_REGISTER: ["sua-ap-web-america.agora.io", "sua-ap-web-america2.agora.io"],
  3418. UAP_AP: ["uap-ap-web-america.agora.io", "uap-ap-web-america2.agora.io"],
  3419. EVENT_REPORT_DOMAIN: ["statscollector-1-north-america.agora.io"],
  3420. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-north-america.agora.io"],
  3421. LOG_UPLOAD_SERVER: ["logservice-north-america.agora.io"]
  3422. },
  3423. EUROPE: {
  3424. CODE: o.EUROPE,
  3425. WEBCS_DOMAIN: ["ap-web-1-europe.agora.io"],
  3426. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-europe.agora.io"],
  3427. PROXY_CS: ["proxy-ap-web-europe.agora.io"],
  3428. CDS_AP: ["cds-ap-web-europe.agora.io", "cds-ap-web-europe2.agora.io"],
  3429. ACCOUNT_REGISTER: ["sua-ap-web-europe.agora.io", "sua-ap-web-europe.agora.io"],
  3430. UAP_AP: ["uap-ap-web-europe.agora.io", "uap-ap-web-europe2.agora.io"],
  3431. EVENT_REPORT_DOMAIN: ["statscollector-1-europe.agora.io"],
  3432. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-europe.agora.io"],
  3433. LOG_UPLOAD_SERVER: ["logservice-europe.agora.io"]
  3434. },
  3435. JAPAN: {
  3436. CODE: o.JAPAN,
  3437. WEBCS_DOMAIN: ["ap-web-1-japan.agora.io"],
  3438. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-japan.agora.io"],
  3439. PROXY_CS: ["proxy-ap-web-japan.agora.io"],
  3440. CDS_AP: ["cds-ap-web-japan.agora.io", "cds-ap-web-japan2.agora.io"],
  3441. ACCOUNT_REGISTER: ["sua-ap-web-japan.agora.io", "sua-ap-web-japan2.agora.io"],
  3442. UAP_AP: ["uap-ap-web-japan.agora.io", "\tuap-ap-web-japan2.agora.io"],
  3443. EVENT_REPORT_DOMAIN: ["statscollector-1-japan.agora.io"],
  3444. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-japan.agora.io"],
  3445. LOG_UPLOAD_SERVER: ["logservice-japan.agora.io"]
  3446. },
  3447. INDIA: {
  3448. CODE: o.INDIA,
  3449. WEBCS_DOMAIN: ["ap-web-1-india.agora.io"],
  3450. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-india.agora.io"],
  3451. PROXY_CS: ["proxy-ap-web-india.agora.io"],
  3452. CDS_AP: ["cds-ap-web-india.agora.io", "cds-ap-web-india2.agora.io"],
  3453. ACCOUNT_REGISTER: ["sua-ap-web-india.agora.io", "sua-ap-web-india2.agora.io"],
  3454. UAP_AP: ["uap-ap-web-india.agora.io", "uap-ap-web-india2.agora.io"],
  3455. EVENT_REPORT_DOMAIN: ["statscollector-1-india.agora.io"],
  3456. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-india.agora.io"],
  3457. LOG_UPLOAD_SERVER: ["logservice-india.agora.io"]
  3458. },
  3459. OVERSEA: {
  3460. CODE: o.OVERSEA,
  3461. WEBCS_DOMAIN: ["ap-web-1-oversea.agora.io"],
  3462. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-oversea.agora.io"],
  3463. PROXY_CS: ["proxy-ap-web-oversea.agora.io"],
  3464. CDS_AP: ["cds-ap-web-oversea.agora.io"],
  3465. ACCOUNT_REGISTER: ["sua-ap-web-oversea.agora.io"],
  3466. UAP_AP: ["uap-ap-web-oversea.agora.io"],
  3467. EVENT_REPORT_DOMAIN: ["statscollector-1-oversea.agora.io"],
  3468. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-oversea.agora.io"],
  3469. LOG_UPLOAD_SERVER: ["logservice-oversea.agora.io"]
  3470. },
  3471. GLOBAL: {
  3472. CODE: o.GLOBAL,
  3473. WEBCS_DOMAIN: ["webrtc2-ap-web-1.agora.io"],
  3474. WEBCS_DOMAIN_BACKUP_LIST: ["webrtc2-ap-web-3.agora.io"],
  3475. PROXY_CS: ["ap-proxy-1.agora.io", "ap-proxy-2.agora.io"],
  3476. CDS_AP: ["cds-ap-web-1.agora.io", "cds-ap-web-3.agora.io"],
  3477. ACCOUNT_REGISTER: ["sua-ap-web-1.agora.io", "sua-ap-web-3.agora.io"],
  3478. UAP_AP: ["uap-ap-web-1.agora.io", "uap-ap-web-3.agora.io"],
  3479. EVENT_REPORT_DOMAIN: ["statscollector-1.agora.io"],
  3480. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2.agora.io"],
  3481. LOG_UPLOAD_SERVER: ["logservice.agora.io"]
  3482. },
  3483. OCEANIA: {
  3484. CODE: o.OCEANIA,
  3485. WEBCS_DOMAIN: ["ap-web-1-oceania.agora.io"],
  3486. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-oceania.agora.io"],
  3487. PROXY_CS: ["proxy-ap-web-oceania.agora.io"],
  3488. CDS_AP: ["cds-ap-web-oceania.agora.io", "cds-ap-web-oceania2.agora.io"],
  3489. ACCOUNT_REGISTER: ["sua-ap-web-oceania.agora.io", "sua-ap-web-oceania2.agora.io"],
  3490. UAP_AP: ["uap-ap-web-oceania.agora.io", "uap-ap-web-oceania2.agora.io"],
  3491. EVENT_REPORT_DOMAIN: ["statscollector-1-oceania.agora.io"],
  3492. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-oceania.agora.io"],
  3493. LOG_UPLOAD_SERVER: ["logservice-oceania.agora.io"]
  3494. },
  3495. SOUTH_AMERICA: {
  3496. CODE: o.SOUTH_AMERICA,
  3497. WEBCS_DOMAIN: ["ap-web-1-south-america.agora.io"],
  3498. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-south-america.agora.io"],
  3499. PROXY_CS: ["proxy-ap-web-south-america.agora.io"],
  3500. CDS_AP: ["cds-ap-web-south-america.agora.io", "cds-ap-web-south-america2.agora.io"],
  3501. ACCOUNT_REGISTER: ["sua-ap-web-south-america.agora.io", "sua-ap-web-south-america2.agora.io"],
  3502. UAP_AP: ["uap-ap-web-south-america.agora.io", "uap-ap-web-south-america2.agora.io"],
  3503. EVENT_REPORT_DOMAIN: ["statscollector-1-south-america.agora.io"],
  3504. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-south-america.agora.io"],
  3505. LOG_UPLOAD_SERVER: ["logservice-south-america.agora.io"]
  3506. },
  3507. AFRICA: {
  3508. CODE: o.AFRICA,
  3509. WEBCS_DOMAIN: ["ap-web-1-africa.agora.io"],
  3510. WEBCS_DOMAIN_BACKUP_LIST: ["ap-web-2-africa.agora.io"],
  3511. PROXY_CS: ["proxy-ap-web-africa.agora.io"],
  3512. CDS_AP: ["cds-ap-web-africa.agora.io", "cds-ap-web-africa2.agora.io"],
  3513. ACCOUNT_REGISTER: ["sua-ap-web-africa.agora.io", "sua-ap-web-africa2.agora.io"],
  3514. UAP_AP: ["uap-ap-web-africa.agora.io", "uap-ap-web-africa2.agora.io"],
  3515. EVENT_REPORT_DOMAIN: ["statscollector-1-africa.agora.io"],
  3516. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-2-africa.agora.io"],
  3517. LOG_UPLOAD_SERVER: ["logservice-south-africa.agora.io"]
  3518. }
  3519. };
  3520. t.AREA_DOMAIN_MAP = s,
  3521. s.CHINA = {
  3522. CODE: o.CHINA,
  3523. WEBCS_DOMAIN: ["webrtc2-ap-web-2.agoraio.cn"],
  3524. WEBCS_DOMAIN_BACKUP_LIST: ["webrtc2-ap-web-4.agoraio.cn"],
  3525. PROXY_CS: ["proxy-ap-web.agoraio.cn"],
  3526. CDS_AP: ["cds-ap-web-2.agoraio.cn", "cds-ap-web-4.agoraio.cn"],
  3527. ACCOUNT_REGISTER: ["sua-ap-web-2.agoraio.cn", "sua-ap-web-4.agoraio.cn"],
  3528. UAP_AP: ["uap-ap-web-2.agoraio.cn", "uap-ap-web-4.agoraio.cn"],
  3529. EVENT_REPORT_DOMAIN: ["statscollector-3.agoraio.cn"],
  3530. EVENT_REPORT_BACKUP_DOMAIN: ["statscollector-4.agoraio.cn"],
  3531. LOG_UPLOAD_SERVER: ["logservice-china.agora.io"]
  3532. };
  3533. t.getAreaCodeByWebCS = function(e) {
  3534. for (var t = Object.keys(s), n = 0; n < t.length; n++) {
  3535. var a = t[n],
  3536. i = s[a];
  3537. if (i.WEBCS_DOMAIN.includes(e) || i.WEBCS_DOMAIN_BACKUP_LIST.includes(e)) return i.CODE === o.OVERSEA ? o.ASIA + "," + o.EUROPE + "," + o.AFRICA + "," + o.NORTH_AMERICA + "," + o.SOUTH_AMERICA + "," + o.OCEANIA: i.CODE
  3538. }
  3539. };
  3540. t.getAreaDomainConfig = function(e) {
  3541. var t = {
  3542. WEBCS_DOMAIN: [],
  3543. WEBCS_DOMAIN_BACKUP_LIST: [],
  3544. PROXY_CS: [],
  3545. CDS_AP: [],
  3546. ACCOUNT_REGISTER: [],
  3547. UAP_AP: [],
  3548. EVENT_REPORT_DOMAIN: [],
  3549. EVENT_REPORT_BACKUP_DOMAIN: [],
  3550. LOG_UPLOAD_SERVER: []
  3551. };
  3552. return e.map((function(e) {
  3553. var n = s[e],
  3554. a = Object.keys(n);
  3555. a ? a.map((function(e) {
  3556. "CODE" !== e && (t[e] = t[e].concat(n[e]))
  3557. })) : r.
  3558. default.info(e + " is not exist")
  3559. })),
  3560. t
  3561. }
  3562. },
  3563. function(e, t, n) {
  3564. var a = n(20);
  3565. e.exports = function(e, t) {
  3566. if (e) {
  3567. if ("string" == typeof e) return a(e, t);
  3568. var n = Object.prototype.toString.call(e).slice(8, -1);
  3569. return "Object" === n && e.constructor && (n = e.constructor.name),
  3570. "Map" === n || "Set" === n ? Array.from(n) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? a(e, t) : void 0
  3571. }
  3572. }
  3573. },
  3574. function(e, t) {
  3575. e.exports = function(e, t) { (null == t || t > e.length) && (t = e.length);
  3576. for (var n = 0,
  3577. a = new Array(t); n < t; n++) a[n] = e[n];
  3578. return a
  3579. }
  3580. },
  3581. function(e, t) {
  3582. e.exports = function(e, t, n) {
  3583. return t in e ? Object.defineProperty(e, t, {
  3584. value: n,
  3585. enumerable: !0,
  3586. configurable: !0,
  3587. writable: !0
  3588. }) : e[t] = n,
  3589. e
  3590. }
  3591. },
  3592. function(e, t) {
  3593. e.exports = function(e, t) {
  3594. if (! (e instanceof t)) throw new TypeError("Cannot call a class as a function")
  3595. }
  3596. },
  3597. function(e, t) {
  3598. function n(e, t) {
  3599. for (var n = 0; n < t.length; n++) {
  3600. var a = t[n];
  3601. a.enumerable = a.enumerable || !1,
  3602. a.configurable = !0,
  3603. "value" in a && (a.writable = !0),
  3604. Object.defineProperty(e, a.key, a)
  3605. }
  3606. }
  3607. e.exports = function(e, t, a) {
  3608. return t && n(e.prototype, t),
  3609. a && n(e, a),
  3610. e
  3611. }
  3612. },
  3613. function(e, t, n) {
  3614. "use strict";
  3615. var a = this && this.__importDefault ||
  3616. function(e) {
  3617. return e && e.__esModule ? e: {
  3618. default:
  3619. e
  3620. }
  3621. };
  3622. Object.defineProperty(t, "__esModule", {
  3623. value: !0
  3624. });
  3625. var i, o = a(n(0)),
  3626. r = n(13); !
  3627. function(e) {
  3628. e.NEW = "new",
  3629. e.PREPARING_OFFER = "preparing-offer",
  3630. e.OFFER_SENT = "offer-sent",
  3631. e.ESTABLISHED = "established",
  3632. e.CLOSED = "closed"
  3633. } (i || (i = {}));
  3634. var s = function() {
  3635. function e(e) {
  3636. this.candidate = null,
  3637. this.state = i.NEW,
  3638. this.config = e,
  3639. this.isSubscriber = this.config.isSubscriber,
  3640. this.peerConnection = this.initPeecConnection(e),
  3641. this.peerConnection.onicecandidate = this._onicecandidate.bind(this),
  3642. this.peerConnection.oniceconnectionstatechange = this._oniceconnectionstatechange.bind(this),
  3643. this.peerConnection.onaddstream = this._onaddstream.bind(this),
  3644. this.peerConnection.ontrack = this._ontrack.bind(this),
  3645. this.processSignalingMessage = this.setAnswer.bind(this),
  3646. this.peerConnection.createOffer({
  3647. offerToReceiveAudio: !0,
  3648. offerToReceiveVideo: !0
  3649. }).then(this.setLocalSDP.bind(this)),
  3650. this.sendVideoStats = {
  3651. id: "",
  3652. type: "",
  3653. mediaType: "",
  3654. googCodecName: "h264" === this.config.codec ? "H264": "VP8",
  3655. bytesSent: "0",
  3656. packetsLost: "0",
  3657. packetsSent: "0",
  3658. googAdaptationChanges: "0",
  3659. googAvgEncodeMs: "0",
  3660. googEncodeUsagePercent: "0",
  3661. googFirsReceived: "0",
  3662. googFrameHeightSent: "0",
  3663. googFrameHeightInput: "0",
  3664. googFrameRateInput: "0",
  3665. googFrameRateSent: "0",
  3666. googFrameWidthSent: "0",
  3667. googFrameWidthInput: "0",
  3668. googNacksReceived: "0",
  3669. googPlisReceived: "0",
  3670. googRtt: "0",
  3671. googFramesEncoded: "0"
  3672. },
  3673. this.sendAudioStats = {
  3674. id: "",
  3675. type: "",
  3676. mediaType: "",
  3677. googCodecName: "opus",
  3678. aecDivergentFilterFraction: "0",
  3679. audioInputLevel: "0",
  3680. bytesSent: "0",
  3681. packetsSent: "0",
  3682. googEchoCancellationReturnLoss: "0",
  3683. googEchoCancellationReturnLossEnhancement: "0"
  3684. },
  3685. this.receiveAudioStats = {
  3686. id: "",
  3687. type: "",
  3688. mediaType: "",
  3689. audioOutputLevel: "0",
  3690. bytesReceived: "0",
  3691. packetsLost: "0",
  3692. packetsReceived: "0",
  3693. googAccelerateRate: "0",
  3694. googCurrentDelayMs: "0",
  3695. googDecodingCNG: "0",
  3696. googDecodingCTN: "0",
  3697. googDecodingCTSG: "0",
  3698. googDecodingNormal: "0",
  3699. googDecodingPLC: "0",
  3700. googDecodingPLCCNG: "0",
  3701. googExpandRate: "0",
  3702. googJitterBufferMs: "0",
  3703. googJitterReceived: "0",
  3704. googPreemptiveExpandRate: "0",
  3705. googPreferredJitterBufferMs: "0",
  3706. googSecondaryDecodedRate: "0",
  3707. googSpeechExpandRate: "0"
  3708. },
  3709. this.receiveVideoStats = {
  3710. id: "",
  3711. type: "",
  3712. mediaType: "",
  3713. googTargetDelayMs: "0",
  3714. packetsLost: "0",
  3715. googDecodeMs: "0",
  3716. googMaxDecodeMs: "0",
  3717. googRenderDelayMs: "0",
  3718. googFrameWidthReceived: "0",
  3719. googFrameHeightReceived: "0",
  3720. googFrameRateReceived: "0",
  3721. googFrameRateDecoded: "0",
  3722. googFrameRateOutput: "0",
  3723. googFramesDecoded: "0",
  3724. googFrameReceived: "0",
  3725. googJitterBufferMs: "0",
  3726. googCurrentDelayMs: "0",
  3727. googMinPlayoutDelayMs: "0",
  3728. googNacksSent: "0",
  3729. googPlisSent: "0",
  3730. googFirsSent: "0",
  3731. bytesReceived: "0",
  3732. packetsReceived: "0"
  3733. }
  3734. }
  3735. return e.prototype.addStream = function(e) {
  3736. this.peerConnection.addStream(e)
  3737. },
  3738. e.prototype.setAnswer = function(e) {
  3739. var t = JSON.parse(e);
  3740. this.peerConnection.setRemoteDescription(new RTCSessionDescription({
  3741. sdp: t.sdp,
  3742. type: "answer"
  3743. })),
  3744. this.onsignalingmessage && this.onsignalingmessage("")
  3745. },
  3746. e.prototype.close = function() {
  3747. this.peerConnection.close()
  3748. },
  3749. e.prototype.getStats = function(e, t) {
  3750. if (void 0 === t && (t = 500), t = t > 500 ? 500 : t, Date.now() - this.lastTimeGetStats < t) {
  3751. var n = [];
  3752. this.config.isSubscriber ? (n.push(this.receiveVideoStats), n.push(this.receiveAudioStats)) : (n.push(this.sendAudioStats), n.push(this.sendVideoStats)),
  3753. n.push({
  3754. id: "time",
  3755. startTime: this.connectedTime,
  3756. timestamp: Date.now()
  3757. }),
  3758. e && e(n)
  3759. } else this._getStats(e)
  3760. },
  3761. e.prototype._getStats = function(e) {
  3762. var t = this,
  3763. n = [];
  3764. this.peerConnection.getStats(null).then((function(a) {
  3765. t.lastTimeGetStats = Date.now(),
  3766. Object.keys(a).map((function(e) {
  3767. var n = a[e];
  3768. t.config.isSubscriber ? n.type && "inboundrtp" === n.type && n.mediaType && "audio" === n.mediaType ? (t.receiveAudioStats.id = n.id + "recv", t.receiveAudioStats.type = n.type + "", t.receiveAudioStats.mediaType = n.mediaType + "", t.receiveAudioStats.packetsReceived = n.packetsReceived + "", t.receiveAudioStats.bytesReceived = n.bytesReceived + "", t.receiveAudioStats.packetsLost = n.packetsLost + "", t.receiveAudioStats.googJitterReceived = n.jitter + "") : n.type && "inboundrtp" === n.type && n.mediaType && "video" === n.mediaType ? (t.receiveVideoStats.id = n.id + "recv", t.receiveVideoStats.type = n.type + "", t.receiveVideoStats.mediaType = n.mediaType + "", t.receiveVideoStats.packetsReceived = n.packetsReceived + "", t.receiveVideoStats.bytesReceived = n.bytesReceived + "", t.receiveVideoStats.packetsLost = n.packetsLost + "", t.receiveVideoStats.googJitterBufferMs = n.jitter + "", t.receiveVideoStats.googPlisSent = n.pliCount + "", t.receiveVideoStats.googFirsSent = n.firCount + "", t.receiveVideoStats.googNacksSent = n.nackCount + "") : n.remoteSource && n.type && "track" === n.type && n.trackIdentifier && -1 !== n.trackIdentifier.indexOf("v") ? (t.receiveVideoStats.googFrameHeightReceived = n.frameHeight + "", t.receiveVideoStats.googFrameWidthReceived = n.frameWidth + "", t.receiveVideoStats.googFrameRateDecoded = n.framesPerSecond + "", t.receiveVideoStats.googFrameRateOutput = n.framesPerSecond + "", t.receiveVideoStats.googFrameRateReceived = n.framesPerSecond + "", t.receiveVideoStats.googFramesDecoded = n.framesDecoded + "", t.receiveVideoStats.googFrameReceived = n.framesReceived + "") : n.remoteSource && n.type && "track" === n.type && n.trackIdentifier && -1 !== n.trackIdentifier.indexOf("a") && (t.receiveAudioStats.audioOutputLevel = n.audioLevel + "") : !n.isRemote && n.type && "outboundrtp" === n.type && n.mediaType && "audio" === n.mediaType ? (t.sendAudioStats.id = n.id + "send", t.sendAudioStats.type = n.type + "", t.sendAudioStats.mediaType = n.mediaType + "", t.sendAudioStats.packetsSent = n.packetsSent + "", t.sendAudioStats.bytesSent = n.bytesSent + "") : !n.isRemote && n.type && "outboundrtp" === n.type && n.mediaType && "video" === n.mediaType ? (t.sendVideoStats.id = n.id + "send", t.sendVideoStats.type = n.type + "", t.sendVideoStats.mediaType = n.mediaType + "", t.sendVideoStats.packetsSent = n.packetsSent + "", t.sendVideoStats.bytesSent = n.bytesSent + "", t.sendVideoStats.googRtt = n.roundTripTime + "", t.sendVideoStats.googPlisReceived = n.pliCount + "", t.sendVideoStats.googFirsReceived = n.firCount + "", t.sendVideoStats.googNacksReceived = n.nackCount + "") : !n.remoteSource && n.type && "track" === n.type && n.framesSent && 0 !== n.framesSent && (t.sendVideoStats.googFrameHeightSent = n.frameHeight + "", t.sendVideoStats.googFrameHeightInput = n.frameHeight + "", t.sendVideoStats.googFrameWidthSent = n.frameWidth + "", t.sendVideoStats.googFrameWidthInput = n.frameWidth + "", t.sendVideoStats.googFramesEncoded = n.framesSent + "", t.sendVideoStats.googFrameRateSent = n.framesPerSecond + "")
  3769. })),
  3770. t.config.isSubscriber ? (n.push(t.receiveVideoStats), n.push(t.receiveAudioStats)) : (n.push(t.sendAudioStats), n.push(t.sendVideoStats)),
  3771. n.push({
  3772. id: "time",
  3773. startTime: t.connectedTime,
  3774. timestamp: Date.now()
  3775. }),
  3776. e && e(n)
  3777. }))
  3778. },
  3779. e.prototype.getStatsRate = function(e) {
  3780. this.getStats(e)
  3781. },
  3782. e.prototype.initPeecConnection = function(e) {
  3783. var t = e.stunServerUrl,
  3784. n = e.turnServer,
  3785. a = e.iceServers;
  3786. return this.pcConfig = {
  3787. iceServers: [{
  3788. urls: "stun:webcs.agora.io:3478"
  3789. }]
  3790. },
  3791. a instanceof Array ? this.pcConfig.iceServers = e.iceServers: t && (t instanceof Array ? t.map((function(e) {
  3792. "string" == typeof e && "" !== e && this.pcConfig.iceServers.push({
  3793. urls: e
  3794. })
  3795. })) : "string" == typeof t && "" !== t && this.pcConfig.iceServers.push({
  3796. urls: t
  3797. })),
  3798. n && (n instanceof Array ? n.map((function(e) {
  3799. "string" == typeof e.url && "" !== e.url && this.pcConfig.iceServers.push({
  3800. username: e.username,
  3801. credential: e.credential,
  3802. url: e.url
  3803. })
  3804. })) : "auto" !== n.mode && "manual" !== n.mode || (n.udpport && this.pcConfig.iceServers.push({
  3805. username: n.username,
  3806. credential: n.credential,
  3807. credentialType: "password",
  3808. urls: "turn:" + n.url + ":" + n.udpport + "?transport=udp"
  3809. }), "string" == typeof n.tcpport && "" !== n.tcpport && this.pcConfig.iceServers.push({
  3810. username: n.username,
  3811. credential: n.credential,
  3812. credentialType: "password",
  3813. urls: "turn:" + n.url + ":" + n.tcpport + "?transport=tcp"
  3814. }), !0 === n.forceturn && (this.pcConfig.iceTransportPolicy = "relay"))),
  3815. new r.RTCPeerConnection(this.pcConfig)
  3816. },
  3817. e.prototype._ontrack = function(e) {
  3818. this.onaddstream && this.onaddstream(e, "ontrack")
  3819. },
  3820. e.prototype._onaddstream = function(e) {
  3821. this.onaddstream && this.onaddstream(e, "onaddstream")
  3822. },
  3823. e.prototype._oniceconnectionstatechange = function(e) {
  3824. "connected" === e.currentTarget.iceConnectionState && (this.state = i.ESTABLISHED, this.connectedTime = Date.now()),
  3825. this.oniceconnectionstatechange && this.oniceconnectionstatechange(e.currentTarget.iceConnectionState)
  3826. },
  3827. e.prototype._onicecandidate = function(e) { ! this.candidate && e && (this.candidate = e.candidate, this.peerConnection.createOffer({
  3828. offerToReceiveAudio: !0,
  3829. offerToReceiveVideo: !0
  3830. }).then(this.editLocalSDP.bind(this)).then(this.setLocalSDP.bind(this)).then(this.sendOffer.bind(this)).
  3831. catch())
  3832. },
  3833. e.prototype.setLocalSDP = function(e) {
  3834. return this.peerConnection.setLocalDescription(new RTCSessionDescription({
  3835. sdp: e.sdp,
  3836. type: "offer"
  3837. })),
  3838. this.state = i.PREPARING_OFFER,
  3839. e
  3840. },
  3841. e.prototype.editLocalSDP = function(e) {
  3842. return e.sdp = this.setBandWidth(e.sdp),
  3843. e.sdp = this.reviseOpus(e.sdp),
  3844. e.sdp = this.addCandidate(e.sdp),
  3845. e
  3846. },
  3847. e.prototype.setSendRecv = function(e) {
  3848. return e = (e = (e = e.replace(/a=recvonly\r\n/g, "a=sendrecv\r\n")).replace(/a=sendonly\r\n/g, "a=sendrecv\r\n")).replace(/a=inactive\r\n/g, "a=sendrecv\r\n")
  3849. },
  3850. e.prototype.setBandWidth = function(e) {
  3851. var t, n, a = this.config,
  3852. i = a.codec,
  3853. r = a.minVideoBW,
  3854. s = a.maxVideoBW,
  3855. c = a.maxAudioBW,
  3856. d = a.clientId;
  3857. if ((t = e.match(/m=video.*\r\n/)) && r && s) {
  3858. n = t[0] + "b=AS:" + s + "\r\n";
  3859. var u = 0,
  3860. l = 0;
  3861. "h264" === i ? (u = e.search(/a=rtpmap:(\d+) H264\/90000\r\n/), l = e.search(/H264\/90000\r\n/)) : "vp8" === i && (u = e.search(/a=rtpmap:(\d+) VP8\/90000\r\n/), l = e.search(/VP8\/90000\r\n/)),
  3862. -1 !== u && -1 !== l && l - u > 10 && (n = n + "a=fmtp:" + e.slice(u + 9, l - 1) + " x-google-min-bitrate=" + r + "\r\n"),
  3863. e = e.replace(t[0], n),
  3864. o.
  3865. default.debug("[" + d + "]Set Video Bitrate - min:" + r + " max:" + s)
  3866. }
  3867. return (t = e.match(/m=audio.*\r\n/)) && c && (n = t[0] + "b=AS:" + c + "\r\n", e = e.replace(t[0], n)),
  3868. e
  3869. },
  3870. e.prototype.reviseOpus = function(e) {
  3871. return e = (e = e.replace(/a=rtpmap:102 opus\/48000\/2/g, "a=rtpmap:111 opus/48000/2")).replace(/m=audio 9 UDP\/TLS\/RTP\/SAVPF 102 0 8 97 13 118 101/g, "m=audio 9 UDP/TLS/RTP/SAVPF 111 0 8 97 13 118 101")
  3872. },
  3873. e.prototype.addCandidate = function(e) {
  3874. return e += "a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"
  3875. },
  3876. e.prototype.sendOffer = function(e) {
  3877. this.config.callback(JSON.stringify({
  3878. sdp: e.sdp,
  3879. messageType: "OFFER",
  3880. tiebreaker: Math.floor(429496723 * Math.random() + 1)
  3881. })),
  3882. this.state = i.OFFER_SENT
  3883. },
  3884. e
  3885. } ();
  3886. t.
  3887. default = s
  3888. },
  3889. function(e, t, n) {
  3890. var a = n(32),
  3891. i = n(33),
  3892. o = n(19),
  3893. r = n(34);
  3894. e.exports = function(e, t) {
  3895. return a(e) || i(e, t) || o(e, t) || r()
  3896. }
  3897. },
  3898. function(e, t, n) {
  3899. var a, i, o;
  3900. i = this,
  3901. o = function() {
  3902. "use strict";
  3903. var e, t = this;
  3904. function n(e) {
  3905. t.console && (t.console.error ? t.console.error(e) : t.console.log && t.console.log(e))
  3906. }
  3907. function a(e, t, a, i) {
  3908. var o = i || n,
  3909. r = e.createShader(a);
  3910. return e.shaderSource(r, t),
  3911. e.compileShader(r),
  3912. e.getShaderParameter(r, e.COMPILE_STATUS) ? r: (o("*** Error compiling shader '" + r + "':" + e.getShaderInfoLog(r)), e.deleteShader(r), null)
  3913. }
  3914. function i(e, t, a, i, o) {
  3915. var r = o || n,
  3916. s = e.createProgram();
  3917. return t.forEach((function(t) {
  3918. e.attachShader(s, t)
  3919. })),
  3920. a && a.forEach((function(t, n) {
  3921. e.bindAttribLocation(s, i ? i[n] : n, t)
  3922. })),
  3923. e.linkProgram(s),
  3924. e.getProgramParameter(s, e.LINK_STATUS) ? s: (r("Error in program linking:" + e.getProgramInfoLog(s)), e.deleteProgram(s), null)
  3925. } (e = e || t) === e.top && (console.log("%c%s", "color:blue;font-weight:bold;", "for more about webgl-utils.js see:"), console.log("%c%s", "color:blue;font-weight:bold;", "http://webglfundamentals.org/webgl/lessons/webgl-boilerplate.html"));
  3926. var o, r = ["VERTEX_SHADER", "FRAGMENT_SHADER"];
  3927. return ! document.documentMode && !!window.StyleMedia && (HTMLCanvasElement.prototype.getContext = (o = HTMLCanvasElement.prototype.getContext,
  3928. function() {
  3929. var e = arguments,
  3930. t = e[0];
  3931. return "webgl" === t && ((e = [].slice.call(arguments))[0] = "experimental-webgl"),
  3932. o.apply(this, e)
  3933. })),
  3934. {
  3935. createProgram: i,
  3936. createProgramFromSources: function(e, t, n, o, s) {
  3937. for (var c = [], d = 0; d < t.length; ++d) c.push(a(e, t[d], e[r[d]], s));
  3938. return i(e, c, n, o, s)
  3939. }
  3940. }
  3941. },
  3942. void 0 === (a = function() {
  3943. return o.call(i)
  3944. }.apply(t, [])) || (e.exports = a)
  3945. },
  3946. function(e, t, n) {
  3947. "use strict";
  3948. var a = this && this.__awaiter ||
  3949. function(e, t, n, a) {
  3950. return new(n || (n = Promise))((function(i, o) {
  3951. function r(e) {
  3952. try {
  3953. c(a.next(e))
  3954. } catch(e) {
  3955. o(e)
  3956. }
  3957. }
  3958. function s(e) {
  3959. try {
  3960. c(a.
  3961. throw (e))
  3962. } catch(e) {
  3963. o(e)
  3964. }
  3965. }
  3966. function c(e) {
  3967. var t;
  3968. e.done ? i(e.value) : (t = e.value, t instanceof n ? t: new n((function(e) {
  3969. e(t)
  3970. }))).then(r, s)
  3971. }
  3972. c((a = a.apply(e, t || [])).next())
  3973. }))
  3974. },
  3975. i = this && this.__generator ||
  3976. function(e, t) {
  3977. var n, a, i, o, r = {
  3978. label: 0,
  3979. sent: function() {
  3980. if (1 & i[0]) throw i[1];
  3981. return i[1]
  3982. },
  3983. trys: [],
  3984. ops: []
  3985. };
  3986. return o = {
  3987. next: s(0),
  3988. throw: s(1),
  3989. return: s(2)
  3990. },
  3991. "function" == typeof Symbol && (o[Symbol.iterator] = function() {
  3992. return this
  3993. }),
  3994. o;
  3995. function s(o) {
  3996. return function(s) {
  3997. return function(o) {
  3998. if (n) throw new TypeError("Generator is already executing.");
  3999. for (; r;) try {
  4000. if (n = 1, a && (i = 2 & o[0] ? a.
  4001. return: o[0] ? a.
  4002. throw || ((i = a.
  4003. return) && i.call(a), 0) : a.next) && !(i = i.call(a, o[1])).done) return i;
  4004. switch (a = 0, i && (o = [2 & o[0], i.value]), o[0]) {
  4005. case 0:
  4006. case 1:
  4007. i = o;
  4008. break;
  4009. case 4:
  4010. return r.label++,
  4011. {
  4012. value: o[1],
  4013. done: !1
  4014. };
  4015. case 5:
  4016. r.label++,
  4017. a = o[1],
  4018. o = [0];
  4019. continue;
  4020. case 7:
  4021. o = r.ops.pop(),
  4022. r.trys.pop();
  4023. continue;
  4024. default:
  4025. if (! (i = r.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
  4026. r = 0;
  4027. continue
  4028. }
  4029. if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
  4030. r.label = o[1];
  4031. break
  4032. }
  4033. if (6 === o[0] && r.label < i[1]) {
  4034. r.label = i[1],
  4035. i = o;
  4036. break
  4037. }
  4038. if (i && r.label < i[2]) {
  4039. r.label = i[2],
  4040. r.ops.push(o);
  4041. break
  4042. }
  4043. i[2] && r.ops.pop(),
  4044. r.trys.pop();
  4045. continue
  4046. }
  4047. o = t.call(e, r)
  4048. } catch(e) {
  4049. o = [6, e],
  4050. a = 0
  4051. } finally {
  4052. n = i = 0
  4053. }
  4054. if (5 & o[0]) throw o[1];
  4055. return {
  4056. value: o[0] ? o[1] : void 0,
  4057. done: !0
  4058. }
  4059. } ([o, s])
  4060. }
  4061. }
  4062. },
  4063. o = this && this.__importDefault ||
  4064. function(e) {
  4065. return e && e.__esModule ? e: {
  4066. default:
  4067. e
  4068. }
  4069. };
  4070. Object.defineProperty(t, "__esModule", {
  4071. value: !0
  4072. });
  4073. var r = n(35),
  4074. s = n(5),
  4075. c = o(n(0));
  4076. t.getSupportedCodec = function(e) {
  4077. return a(void 0, void 0, void 0, (function() {
  4078. var t, n, a, o, u;
  4079. return i(this, (function(i) {
  4080. switch (i.label) {
  4081. case 0:
  4082. return t = {
  4083. video: [],
  4084. audio: []
  4085. },
  4086. "undefined" != typeof window ? [3, 1] : ("NOT_BROWSER_ENV", c.
  4087. default.error("getSupportedCodec: NOT_BROWSER_ENV"), [2, Promise.reject("NOT_BROWSER_ENV")]);
  4088. case 1:
  4089. try {
  4090. n = r.createRTCPeerConnection({
  4091. iceServers: []
  4092. })
  4093. } catch(e) {
  4094. return c.
  4095. default.error("Failed to init RTCPeerConnection", e),
  4096. [2, Promise.reject(e)]
  4097. }
  4098. return n ? [3, 2] : (c.
  4099. default.warning("getSupportedCodec: no RTCPeerConnection constructor is detected"), [2, Promise.resolve(t)]);
  4100. case 2:
  4101. return e && e.stream ? [3, 7] : (a = {
  4102. mandatory: {
  4103. OfferToReceiveAudio: !0,
  4104. OfferToReceiveVideo: !0
  4105. }
  4106. },
  4107. o = void 0, (s.isSafari() || s.isFireFox() || s.isWeChatBrowser()) && n.addTransceiver ? (n.addTransceiver("audio"), n.addTransceiver("video"), [4, n.createOffer()]) : [3, 4]);
  4108. case 3:
  4109. return o = i.sent(),
  4110. [3, 6];
  4111. case 4:
  4112. return [4, new Promise((function(e, t) {
  4113. var i = setTimeout((function() {
  4114. t("CREATEOFFER_TIMEOUT")
  4115. }), 3e3);
  4116. n.createOffer((function(t) {
  4117. clearTimeout(i),
  4118. e(t)
  4119. }), (function(e) {
  4120. clearTimeout(i),
  4121. t(e)
  4122. }), a)
  4123. }))];
  4124. case 5:
  4125. o = i.sent(),
  4126. i.label = 6;
  4127. case 6:
  4128. return n.close(),
  4129. u = o.sdp,
  4130. [2, d(u)];
  4131. case 7:
  4132. return e.stream.getTracks && n.addTrack ? e.stream.getTracks().forEach((function(t) {
  4133. n.addTrack(t, e.stream)
  4134. })) : n.addStream(e.stream),
  4135. o = void 0,
  4136. s.isSafari() || s.isFireFox() ? [4, n.createOffer()] : [3, 9];
  4137. case 8:
  4138. return o = i.sent(),
  4139. [3, 11];
  4140. case 9:
  4141. return [4, new Promise((function(e, t) {
  4142. n.createOffer(e, t)
  4143. }))];
  4144. case 10:
  4145. o = i.sent(),
  4146. i.label = 11;
  4147. case 11:
  4148. return n.close(),
  4149. u = o.sdp,
  4150. [2, d(u)]
  4151. }
  4152. }))
  4153. }))
  4154. };
  4155. var d = function(e) {
  4156. var t = {
  4157. video: [],
  4158. audio: []
  4159. };
  4160. return e.match(/ VP8/i) && t.video.push("VP8"),
  4161. e.match(/ H264/i) && t.video.push("H264"),
  4162. e.match(/ opus/i) && t.audio.push("OPUS"),
  4163. Promise.resolve(t)
  4164. }
  4165. },
  4166. function(e, t, n) {
  4167. "use strict";
  4168. var a = this && this.__importDefault ||
  4169. function(e) {
  4170. return e && e.__esModule ? e: {
  4171. default:
  4172. e
  4173. }
  4174. };
  4175. Object.defineProperty(t, "__esModule", {
  4176. value: !0
  4177. });
  4178. var i = a(n(4)),
  4179. o = a(n(0)),
  4180. r = n(10);
  4181. t.
  4182. default = function(e, t) {
  4183. void 0 === t && (t = {
  4184. width: 160,
  4185. height: 120,
  4186. framerate: 15
  4187. });
  4188. var n = t.width,
  4189. a = t.height,
  4190. s = t.framerate,
  4191. c = e.stream;
  4192. if (!c) throw i.
  4193. default.INVALID_LOCAL_STREAM;
  4194. if (!c.getVideoTracks()[0]) throw i.
  4195. default.HIGH_STREAM_NOT_VIDEO_TRACE;
  4196. var d = c.getVideoTracks()[0];
  4197. o.
  4198. default.debug("Start getLowStream");
  4199. var u = document.createElement("video"),
  4200. l = document.createElement("canvas");
  4201. u.setAttribute("style", "display:none"),
  4202. u.setAttribute("muted", ""),
  4203. u.muted = !0,
  4204. u.setAttribute("autoplay", ""),
  4205. u.autoplay = !0,
  4206. u.setAttribute("playsinline", ""),
  4207. l.setAttribute("style", "display:none"),
  4208. l.setAttribute("width", n.toString()),
  4209. l.setAttribute("height", a.toString());
  4210. var p = l.getContext("2d");
  4211. if (!p) throw new Error("not get canvas context");
  4212. u.srcObject = c,
  4213. document.body.append(u),
  4214. document.body.append(l),
  4215. u.play(),
  4216. o.
  4217. default.debug("Start render lowStream");
  4218. var f = r.audioTimerLoop((function() {
  4219. return function() {
  4220. if (u.paused && u.play(), u.videoHeight > 2 && u.videoWidth > 2) {
  4221. var t = u.videoWidth,
  4222. n = u.videoHeight / t,
  4223. a = l.width * n;
  4224. Math.abs(a - l.height) >= 2 && (o.
  4225. default.debug("adjust low stream resolution", l.width + "x" + l.height + " -> " + l.width + "x" + a), l.height = a)
  4226. }
  4227. p.drawImage(u, 0, 0, l.width, l.height);
  4228. var i = e.stream;
  4229. if (i) {
  4230. var r = i.getVideoTracks()[0];
  4231. d !== r && (o.
  4232. default.debug("adjust low stream track"), u.srcObject = i, d = r)
  4233. }
  4234. } ()
  4235. }), s),
  4236. g = l.captureStream(s),
  4237. m = g.getVideoTracks()[0];
  4238. return m.requestFrame && m.requestFrame(),
  4239. g.clean = function() {
  4240. o.
  4241. default.debug("Start clean lowStream"),
  4242. f(),
  4243. (u || u.parentNode || u.parentNode.removeChild) && u.parentNode.removeChild(u),
  4244. (l || l.parentNode || l.parentNode.removeChild) && l.parentNode.removeChild(l),
  4245. o.
  4246. default.debug("Clean lowStream")
  4247. },
  4248. g
  4249. }
  4250. },
  4251. function(e, t) {
  4252. var n = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof window.msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto);
  4253. if (n) {
  4254. var a = new Uint8Array(16);
  4255. e.exports = function() {
  4256. return n(a),
  4257. a
  4258. }
  4259. } else {
  4260. var i = new Array(16);
  4261. e.exports = function() {
  4262. for (var e, t = 0; t < 16; t++) 0 == (3 & t) && (e = 4294967296 * Math.random()),
  4263. i[t] = e >>> ((3 & t) << 3) & 255;
  4264. return i
  4265. }
  4266. }
  4267. },
  4268. function(e, t) {
  4269. for (var n = [], a = 0; a < 256; ++a) n[a] = (a + 256).toString(16).substr(1);
  4270. e.exports = function(e, t) {
  4271. var a = t || 0,
  4272. i = n;
  4273. return [i[e[a++]], i[e[a++]], i[e[a++]], i[e[a++]], "-", i[e[a++]], i[e[a++]], "-", i[e[a++]], i[e[a++]], "-", i[e[a++]], i[e[a++]], "-", i[e[a++]], i[e[a++]], i[e[a++]], i[e[a++]], i[e[a++]], i[e[a++]]].join("")
  4274. }
  4275. },
  4276. function(e, t, n) {
  4277. var a = function(e) {
  4278. "use strict";
  4279. var t = Object.prototype,
  4280. n = t.hasOwnProperty,
  4281. a = "function" == typeof Symbol ? Symbol: {},
  4282. i = a.iterator || "@@iterator",
  4283. o = a.asyncIterator || "@@asyncIterator",
  4284. r = a.toStringTag || "@@toStringTag";
  4285. function s(e, t, n, a) {
  4286. var i = t && t.prototype instanceof u ? t: u,
  4287. o = Object.create(i.prototype),
  4288. r = new b(a || []);
  4289. return o._invoke = function(e, t, n) {
  4290. var a = "suspendedStart";
  4291. return function(i, o) {
  4292. if ("executing" === a) throw new Error("Generator is already running");
  4293. if ("completed" === a) {
  4294. if ("throw" === i) throw o;
  4295. return R()
  4296. }
  4297. for (n.method = i, n.arg = o;;) {
  4298. var r = n.delegate;
  4299. if (r) {
  4300. var s = _(r, n);
  4301. if (s) {
  4302. if (s === d) continue;
  4303. return s
  4304. }
  4305. }
  4306. if ("next" === n.method) n.sent = n._sent = n.arg;
  4307. else if ("throw" === n.method) {
  4308. if ("suspendedStart" === a) throw a = "completed",
  4309. n.arg;
  4310. n.dispatchException(n.arg)
  4311. } else "return" === n.method && n.abrupt("return", n.arg);
  4312. a = "executing";
  4313. var u = c(e, t, n);
  4314. if ("normal" === u.type) {
  4315. if (a = n.done ? "completed": "suspendedYield", u.arg === d) continue;
  4316. return {
  4317. value: u.arg,
  4318. done: n.done
  4319. }
  4320. }
  4321. "throw" === u.type && (a = "completed", n.method = "throw", n.arg = u.arg)
  4322. }
  4323. }
  4324. } (e, n, r),
  4325. o
  4326. }
  4327. function c(e, t, n) {
  4328. try {
  4329. return {
  4330. type: "normal",
  4331. arg: e.call(t, n)
  4332. }
  4333. } catch(e) {
  4334. return {
  4335. type: "throw",
  4336. arg: e
  4337. }
  4338. }
  4339. }
  4340. e.wrap = s;
  4341. var d = {};
  4342. function u() {}
  4343. function l() {}
  4344. function p() {}
  4345. var f = {};
  4346. f[i] = function() {
  4347. return this
  4348. };
  4349. var g = Object.getPrototypeOf,
  4350. m = g && g(g(T([])));
  4351. m && m !== t && n.call(m, i) && (f = m);
  4352. var v = p.prototype = u.prototype = Object.create(f);
  4353. function S(e) { ["next", "throw", "return"].forEach((function(t) {
  4354. e[t] = function(e) {
  4355. return this._invoke(t, e)
  4356. }
  4357. }))
  4358. }
  4359. function E(e, t) {
  4360. var a;
  4361. this._invoke = function(i, o) {
  4362. function r() {
  4363. return new t((function(a, r) { !
  4364. function a(i, o, r, s) {
  4365. var d = c(e[i], e, o);
  4366. if ("throw" !== d.type) {
  4367. var u = d.arg,
  4368. l = u.value;
  4369. return l && "object" == typeof l && n.call(l, "__await") ? t.resolve(l.__await).then((function(e) {
  4370. a("next", e, r, s)
  4371. }), (function(e) {
  4372. a("throw", e, r, s)
  4373. })) : t.resolve(l).then((function(e) {
  4374. u.value = e,
  4375. r(u)
  4376. }), (function(e) {
  4377. return a("throw", e, r, s)
  4378. }))
  4379. }
  4380. s(d.arg)
  4381. } (i, o, a, r)
  4382. }))
  4383. }
  4384. return a = a ? a.then(r, r) : r()
  4385. }
  4386. }
  4387. function _(e, t) {
  4388. var n = e.iterator[t.method];
  4389. if (void 0 === n) {
  4390. if (t.delegate = null, "throw" === t.method) {
  4391. if (e.iterator.
  4392. return && (t.method = "return", t.arg = void 0, _(e, t), "throw" === t.method)) return d;
  4393. t.method = "throw",
  4394. t.arg = new TypeError("The iterator does not provide a 'throw' method")
  4395. }
  4396. return d
  4397. }
  4398. var a = c(n, e.iterator, t.arg);
  4399. if ("throw" === a.type) return t.method = "throw",
  4400. t.arg = a.arg,
  4401. t.delegate = null,
  4402. d;
  4403. var i = a.arg;
  4404. return i ? i.done ? (t[e.resultName] = i.value, t.next = e.nextLoc, "return" !== t.method && (t.method = "next", t.arg = void 0), t.delegate = null, d) : i: (t.method = "throw", t.arg = new TypeError("iterator result is not an object"), t.delegate = null, d)
  4405. }
  4406. function h(e) {
  4407. var t = {
  4408. tryLoc: e[0]
  4409. };
  4410. 1 in e && (t.catchLoc = e[1]),
  4411. 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]),
  4412. this.tryEntries.push(t)
  4413. }
  4414. function I(e) {
  4415. var t = e.completion || {};
  4416. t.type = "normal",
  4417. delete t.arg,
  4418. e.completion = t
  4419. }
  4420. function b(e) {
  4421. this.tryEntries = [{
  4422. tryLoc: "root"
  4423. }],
  4424. e.forEach(h, this),
  4425. this.reset(!0)
  4426. }
  4427. function T(e) {
  4428. if (e) {
  4429. var t = e[i];
  4430. if (t) return t.call(e);
  4431. if ("function" == typeof e.next) return e;
  4432. if (!isNaN(e.length)) {
  4433. var a = -1,
  4434. o = function t() {
  4435. for (; ++a < e.length;) if (n.call(e, a)) return t.value = e[a],
  4436. t.done = !1,
  4437. t;
  4438. return t.value = void 0,
  4439. t.done = !0,
  4440. t
  4441. };
  4442. return o.next = o
  4443. }
  4444. }
  4445. return {
  4446. next: R
  4447. }
  4448. }
  4449. function R() {
  4450. return {
  4451. value: void 0,
  4452. done: !0
  4453. }
  4454. }
  4455. return l.prototype = v.constructor = p,
  4456. p.constructor = l,
  4457. p[r] = l.displayName = "GeneratorFunction",
  4458. e.isGeneratorFunction = function(e) {
  4459. var t = "function" == typeof e && e.constructor;
  4460. return !! t && (t === l || "GeneratorFunction" === (t.displayName || t.name))
  4461. },
  4462. e.mark = function(e) {
  4463. return Object.setPrototypeOf ? Object.setPrototypeOf(e, p) : (e.__proto__ = p, r in e || (e[r] = "GeneratorFunction")),
  4464. e.prototype = Object.create(v),
  4465. e
  4466. },
  4467. e.awrap = function(e) {
  4468. return {
  4469. __await: e
  4470. }
  4471. },
  4472. S(E.prototype),
  4473. E.prototype[o] = function() {
  4474. return this
  4475. },
  4476. e.AsyncIterator = E,
  4477. e.async = function(t, n, a, i, o) {
  4478. void 0 === o && (o = Promise);
  4479. var r = new E(s(t, n, a, i), o);
  4480. return e.isGeneratorFunction(n) ? r: r.next().then((function(e) {
  4481. return e.done ? e.value: r.next()
  4482. }))
  4483. },
  4484. S(v),
  4485. v[r] = "Generator",
  4486. v[i] = function() {
  4487. return this
  4488. },
  4489. v.toString = function() {
  4490. return "[object Generator]"
  4491. },
  4492. e.keys = function(e) {
  4493. var t = [];
  4494. for (var n in e) t.push(n);
  4495. return t.reverse(),
  4496. function n() {
  4497. for (; t.length;) {
  4498. var a = t.pop();
  4499. if (a in e) return n.value = a,
  4500. n.done = !1,
  4501. n
  4502. }
  4503. return n.done = !0,
  4504. n
  4505. }
  4506. },
  4507. e.values = T,
  4508. b.prototype = {
  4509. constructor: b,
  4510. reset: function(e) {
  4511. if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(I), !e) for (var t in this)"t" === t.charAt(0) && n.call(this, t) && !isNaN( + t.slice(1)) && (this[t] = void 0)
  4512. },
  4513. stop: function() {
  4514. this.done = !0;
  4515. var e = this.tryEntries[0].completion;
  4516. if ("throw" === e.type) throw e.arg;
  4517. return this.rval
  4518. },
  4519. dispatchException: function(e) {
  4520. if (this.done) throw e;
  4521. var t = this;
  4522. function a(n, a) {
  4523. return r.type = "throw",
  4524. r.arg = e,
  4525. t.next = n,
  4526. a && (t.method = "next", t.arg = void 0),
  4527. !!a
  4528. }
  4529. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4530. var o = this.tryEntries[i],
  4531. r = o.completion;
  4532. if ("root" === o.tryLoc) return a("end");
  4533. if (o.tryLoc <= this.prev) {
  4534. var s = n.call(o, "catchLoc"),
  4535. c = n.call(o, "finallyLoc");
  4536. if (s && c) {
  4537. if (this.prev < o.catchLoc) return a(o.catchLoc, !0);
  4538. if (this.prev < o.finallyLoc) return a(o.finallyLoc)
  4539. } else if (s) {
  4540. if (this.prev < o.catchLoc) return a(o.catchLoc, !0)
  4541. } else {
  4542. if (!c) throw new Error("try statement without catch or finally");
  4543. if (this.prev < o.finallyLoc) return a(o.finallyLoc)
  4544. }
  4545. }
  4546. }
  4547. },
  4548. abrupt: function(e, t) {
  4549. for (var a = this.tryEntries.length - 1; a >= 0; --a) {
  4550. var i = this.tryEntries[a];
  4551. if (i.tryLoc <= this.prev && n.call(i, "finallyLoc") && this.prev < i.finallyLoc) {
  4552. var o = i;
  4553. break
  4554. }
  4555. }
  4556. o && ("break" === e || "continue" === e) && o.tryLoc <= t && t <= o.finallyLoc && (o = null);
  4557. var r = o ? o.completion: {};
  4558. return r.type = e,
  4559. r.arg = t,
  4560. o ? (this.method = "next", this.next = o.finallyLoc, d) : this.complete(r)
  4561. },
  4562. complete: function(e, t) {
  4563. if ("throw" === e.type) throw e.arg;
  4564. return "break" === e.type || "continue" === e.type ? this.next = e.arg: "return" === e.type ? (this.rval = this.arg = e.arg, this.method = "return", this.next = "end") : "normal" === e.type && t && (this.next = t),
  4565. d
  4566. },
  4567. finish: function(e) {
  4568. for (var t = this.tryEntries.length - 1; t >= 0; --t) {
  4569. var n = this.tryEntries[t];
  4570. if (n.finallyLoc === e) return this.complete(n.completion, n.afterLoc),
  4571. I(n),
  4572. d
  4573. }
  4574. },
  4575. catch: function(e) {
  4576. for (var t = this.tryEntries.length - 1; t >= 0; --t) {
  4577. var n = this.tryEntries[t];
  4578. if (n.tryLoc === e) {
  4579. var a = n.completion;
  4580. if ("throw" === a.type) {
  4581. var i = a.arg;
  4582. I(n)
  4583. }
  4584. return i
  4585. }
  4586. }
  4587. throw new Error("illegal catch attempt")
  4588. },
  4589. delegateYield: function(e, t, n) {
  4590. return this.delegate = {
  4591. iterator: T(e),
  4592. resultName: t,
  4593. nextLoc: n
  4594. },
  4595. "next" === this.method && (this.arg = void 0),
  4596. d
  4597. }
  4598. },
  4599. e
  4600. } (e.exports);
  4601. try {
  4602. regeneratorRuntime = a
  4603. } catch(e) {
  4604. Function("r", "regeneratorRuntime = r")(a)
  4605. }
  4606. },
  4607. function(e, t) {
  4608. e.exports = function(e) {
  4609. if (Array.isArray(e)) return e
  4610. }
  4611. },
  4612. function(e, t) {
  4613. e.exports = function(e, t) {
  4614. if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) {
  4615. var n = [],
  4616. a = !0,
  4617. i = !1,
  4618. o = void 0;
  4619. try {
  4620. for (var r, s = e[Symbol.iterator](); ! (a = (r = s.next()).done) && (n.push(r.value), !t || n.length !== t); a = !0);
  4621. } catch(e) {
  4622. i = !0,
  4623. o = e
  4624. } finally {
  4625. try {
  4626. a || null == s.
  4627. return || s.
  4628. return ()
  4629. } finally {
  4630. if (i) throw o
  4631. }
  4632. }
  4633. return n
  4634. }
  4635. }
  4636. },
  4637. function(e, t) {
  4638. e.exports = function() {
  4639. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  4640. }
  4641. },
  4642. function(e, t, n) {
  4643. "use strict";
  4644. Object.defineProperty(t, "__esModule", {
  4645. value: !0
  4646. });
  4647. var a = "object" == typeof window && window.RTCPeerConnection,
  4648. i = "object" == typeof window && window.webkitRTCPeerConnection,
  4649. o = "object" == typeof window && window.mozRTCPeerConnection;
  4650. t.createRTCPeerConnection = function(e) {
  4651. var t = a || i || o;
  4652. return t ? new t(e) : null
  4653. }
  4654. },
  4655. function(e, t, n) {
  4656. var a;
  4657. /*!
  4658. * EventEmitter v5.2.9 - git.io/ee
  4659. * Unlicense - http://unlicense.org/
  4660. * Oliver Caldwell - https://oli.me.uk/
  4661. * @preserve
  4662. */
  4663. !
  4664. function(t) {
  4665. "use strict";
  4666. function i() {}
  4667. var o = i.prototype,
  4668. r = t.EventEmitter;
  4669. function s(e, t) {
  4670. for (var n = e.length; n--;) if (e[n].listener === t) return n;
  4671. return - 1
  4672. }
  4673. function c(e) {
  4674. return function() {
  4675. return this[e].apply(this, arguments)
  4676. }
  4677. }
  4678. o.getListeners = function(e) {
  4679. var t, n, a = this._getEvents();
  4680. if (e instanceof RegExp) for (n in t = {},
  4681. a) a.hasOwnProperty(n) && e.test(n) && (t[n] = a[n]);
  4682. else t = a[e] || (a[e] = []);
  4683. return t
  4684. },
  4685. o.flattenListeners = function(e) {
  4686. var t, n = [];
  4687. for (t = 0; t < e.length; t += 1) n.push(e[t].listener);
  4688. return n
  4689. },
  4690. o.getListenersAsObject = function(e) {
  4691. var t, n = this.getListeners(e);
  4692. return n instanceof Array && ((t = {})[e] = n),
  4693. t || n
  4694. },
  4695. o.addListener = function(e, t) {
  4696. if (!
  4697. function e(t) {
  4698. return "function" == typeof t || t instanceof RegExp || !(!t || "object" != typeof t) && e(t.listener)
  4699. } (t)) throw new TypeError("listener must be a function");
  4700. var n, a = this.getListenersAsObject(e),
  4701. i = "object" == typeof t;
  4702. for (n in a) a.hasOwnProperty(n) && -1 === s(a[n], t) && a[n].push(i ? t: {
  4703. listener: t,
  4704. once: !1
  4705. });
  4706. return this
  4707. },
  4708. o.on = c("addListener"),
  4709. o.addOnceListener = function(e, t) {
  4710. return this.addListener(e, {
  4711. listener: t,
  4712. once: !0
  4713. })
  4714. },
  4715. o.once = c("addOnceListener"),
  4716. o.defineEvent = function(e) {
  4717. return this.getListeners(e),
  4718. this
  4719. },
  4720. o.defineEvents = function(e) {
  4721. for (var t = 0; t < e.length; t += 1) this.defineEvent(e[t]);
  4722. return this
  4723. },
  4724. o.removeListener = function(e, t) {
  4725. var n, a, i = this.getListenersAsObject(e);
  4726. for (a in i) i.hasOwnProperty(a) && -1 !== (n = s(i[a], t)) && i[a].splice(n, 1);
  4727. return this
  4728. },
  4729. o.off = c("removeListener"),
  4730. o.addListeners = function(e, t) {
  4731. return this.manipulateListeners(!1, e, t)
  4732. },
  4733. o.removeListeners = function(e, t) {
  4734. return this.manipulateListeners(!0, e, t)
  4735. },
  4736. o.manipulateListeners = function(e, t, n) {
  4737. var a, i, o = e ? this.removeListener: this.addListener,
  4738. r = e ? this.removeListeners: this.addListeners;
  4739. if ("object" != typeof t || t instanceof RegExp) for (a = n.length; a--;) o.call(this, t, n[a]);
  4740. else for (a in t) t.hasOwnProperty(a) && (i = t[a]) && ("function" == typeof i ? o.call(this, a, i) : r.call(this, a, i));
  4741. return this
  4742. },
  4743. o.removeEvent = function(e) {
  4744. var t, n = typeof e,
  4745. a = this._getEvents();
  4746. if ("string" === n) delete a[e];
  4747. else if (e instanceof RegExp) for (t in a) a.hasOwnProperty(t) && e.test(t) && delete a[t];
  4748. else delete this._events;
  4749. return this
  4750. },
  4751. o.removeAllListeners = c("removeEvent"),
  4752. o.emitEvent = function(e, t) {
  4753. var n, a, i, o, r = this.getListenersAsObject(e);
  4754. for (o in r) if (r.hasOwnProperty(o)) for (n = r[o].slice(0), i = 0; i < n.length; i++) ! 0 === (a = n[i]).once && this.removeListener(e, a.listener),
  4755. a.listener.apply(this, t || []) === this._getOnceReturnValue() && this.removeListener(e, a.listener);
  4756. return this
  4757. },
  4758. o.trigger = c("emitEvent"),
  4759. o.emit = function(e) {
  4760. var t = Array.prototype.slice.call(arguments, 1);
  4761. return this.emitEvent(e, t)
  4762. },
  4763. o.setOnceReturnValue = function(e) {
  4764. return this._onceReturnValue = e,
  4765. this
  4766. },
  4767. o._getOnceReturnValue = function() {
  4768. return ! this.hasOwnProperty("_onceReturnValue") || this._onceReturnValue
  4769. },
  4770. o._getEvents = function() {
  4771. return this._events || (this._events = {})
  4772. },
  4773. i.noConflict = function() {
  4774. return t.EventEmitter = r,
  4775. i
  4776. },
  4777. void 0 === (a = function() {
  4778. return i
  4779. }.call(t, n, t, e)) || (e.exports = a)
  4780. } ("undefined" != typeof window ? window: this || {})
  4781. },
  4782. function(e, t, n) {
  4783. var a = n(20);
  4784. e.exports = function(e) {
  4785. if (Array.isArray(e)) return a(e)
  4786. }
  4787. },
  4788. function(e, t) {
  4789. e.exports = function(e) {
  4790. if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e)
  4791. }
  4792. },
  4793. function(e, t) {
  4794. e.exports = function() {
  4795. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  4796. }
  4797. },
  4798. function(t, n, a) {
  4799. "use strict";
  4800. a.r(n);
  4801. var o = a(3),
  4802. r = a(0),
  4803. s = a(2),
  4804. c = function() {
  4805. var e = {
  4806. dispatcher: {}
  4807. };
  4808. return e.dispatcher.eventListeners = {},
  4809. e.addEventListener = function(t, n) {
  4810. void 0 === e.dispatcher.eventListeners[t] && (e.dispatcher.eventListeners[t] = []),
  4811. e.dispatcher.eventListeners[t].push(n)
  4812. },
  4813. e.hasListeners = function(t) {
  4814. return ! (!e.dispatcher.eventListeners[t] || !e.dispatcher.eventListeners[t].length)
  4815. },
  4816. e.on = e.addEventListener,
  4817. e.removeEventListener = function(t, n) {
  4818. var a;
  4819. e.dispatcher.eventListeners[t] && -1 !== (a = e.dispatcher.eventListeners[t].indexOf(n)) && e.dispatcher.eventListeners[t].splice(a, 1)
  4820. },
  4821. e.dispatchEvent = function(t) {
  4822. var n;
  4823. for (n in e.dispatcher.eventListeners[t.type]) if (e.dispatcher.eventListeners[t.type] && e.dispatcher.eventListeners[t.type].hasOwnProperty(n) && "function" == typeof e.dispatcher.eventListeners[t.type][n]) try {
  4824. e.dispatcher.eventListeners[t.type][n](t)
  4825. } catch(n) {
  4826. r.
  4827. default.debug("[".concat(e.clientId, "] Error in ").concat(t.type, " event"), n)
  4828. }
  4829. },
  4830. e.dispatchSocketEvent = function(t) {
  4831. var n;
  4832. for (n in e.dispatcher.eventListeners[t.type]) e.dispatcher.eventListeners[t.type] && e.dispatcher.eventListeners[t.type].hasOwnProperty(n) && "function" == typeof e.dispatcher.eventListeners[t.type][n] && e.dispatcher.eventListeners[t.type][n](t.msg)
  4833. },
  4834. e
  4835. },
  4836. d = function(e) {
  4837. var t = {};
  4838. return t.type = e.type,
  4839. t
  4840. },
  4841. u = function(e) {
  4842. var t = d(e);
  4843. return t.stream = e.stream,
  4844. t.reason = e.reason,
  4845. t.msg = e.msg,
  4846. t
  4847. },
  4848. l = function(e) {
  4849. var t = d(e);
  4850. return t.uid = e.uid,
  4851. t.attr = e.attr,
  4852. t.stream = e.stream,
  4853. t
  4854. },
  4855. p = function(e) {
  4856. var t = d(e);
  4857. return t.msg = e.msg,
  4858. t
  4859. },
  4860. f = function(e) {
  4861. var t = d(e);
  4862. return t.url = e.url,
  4863. t.uid = e.uid,
  4864. t.status = e.status,
  4865. t.reason = e.reason,
  4866. t
  4867. },
  4868. g = a(5),
  4869. m = function() {};
  4870. m.prototype.set = function(e, t) { ["BatteryLevel"].indexOf(e) > -1 && (this[e] = t)
  4871. };
  4872. var v = new
  4873. function() {
  4874. var e = c();
  4875. return e.states = {
  4876. UNINIT: "UNINIT",
  4877. INITING: "INITING",
  4878. INITED: "INITED"
  4879. },
  4880. e.state = e.states.UNINIT,
  4881. e.batteryManager = null,
  4882. e._init = function(t, n) {
  4883. e.state = e.states.INITING,
  4884. navigator.getBattery ? navigator.getBattery().then((function(n) {
  4885. e.batteryManager = n,
  4886. t && setTimeout((function() {
  4887. t()
  4888. }), 0)
  4889. })).
  4890. catch((function(e) {
  4891. r.
  4892. default.debug("navigator.getBattery is disabled", e),
  4893. t && t()
  4894. })) : (e.state = e.states.INITED, t && t())
  4895. },
  4896. e._getBatteryStats = function() {
  4897. var t = {};
  4898. return e.batteryManager && e.batteryManager.level ? t.BatteryLevel = Math.floor(100 * e.batteryManager.level) : t.BatteryLevel = "UNSUPPORTED",
  4899. t
  4900. },
  4901. e.getStats = function(t, n) {
  4902. var a = new m,
  4903. i = e._getBatteryStats();
  4904. i && i.BatteryLevel && a.set("BatteryLevel", i.BatteryLevel),
  4905. t && t(a)
  4906. },
  4907. e._init(),
  4908. e
  4909. },
  4910. S = a(6),
  4911. E = a.n(S),
  4912. _ = function(e) {
  4913. var t = c();
  4914. return t.url = ".",
  4915. t
  4916. },
  4917. h = a(13),
  4918. I = a(4),
  4919. b = 0,
  4920. T = function(e) {
  4921. var t = _({});
  4922. t.id = e.id,
  4923. t.playerId = b++,
  4924. t.destroyed = !1,
  4925. t.fit = e.options && e.options.fit,
  4926. "contain" !== t.fit && "cover" !== t.fit && (t.fit = null),
  4927. t.url = e.url,
  4928. t.stream = e.stream.stream,
  4929. t.isFreeze = !1,
  4930. t.freezeCount = 0,
  4931. t.lastFreezeCount = 0,
  4932. t.lastTimeupdateTime = 0,
  4933. t.elementID = e.elementID,
  4934. t.setAudioOutput = function(e, n, a) {
  4935. var i = t.video || t.audio;
  4936. return i ? i.setSinkId ? void i.setSinkId(e).then((function() {
  4937. return r.
  4938. default.debug("[" + t.id + "] " + "video ".concat(t.id, " setAudioOutput ").concat(e, " SUCCESS")),
  4939. i == t.video && t.audio ? t.audio.setSinkId(e) : Promise.resolve()
  4940. })).then((function() {
  4941. return r.
  4942. default.debug("[" + t.id + "] " + "audio ".concat(t.id, " setAudioOutput ").concat(e, " SUCCESS")),
  4943. n && n()
  4944. })).
  4945. catch((function(e) {
  4946. return r.
  4947. default.error("[" + t.id + "] VideoPlayer.setAudioOutput", e),
  4948. a && a(e)
  4949. })) : (r.
  4950. default.error("[" + t.id + "] ", I.
  4951. default.WEB_API_NOT_SUPPORTED), a && a(I.
  4952. default.WEB_API_NOT_SUPPORTED)):
  4953. (r.
  4954. default.error("[" + t.id + "] ", I.
  4955. default.PLAYER_NOT_FOUND), a && a(I.
  4956. default.PLAYER_NOT_FOUND))
  4957. },
  4958. t.destroy = function() {
  4959. r.
  4960. default.debug("[".concat(t.id, "] destroy ").concat(e.stream.local ? "local": "remote", " Player ").concat(t.id)),
  4961. Object(h.setSrcObject)(t.video, null),
  4962. Object(h.setSrcObject)(t.audio, null),
  4963. t.video.pause(),
  4964. t.freezeCheckInterval && clearInterval(t.freezeCheckInterval),
  4965. t.destroyed = !0,
  4966. delete t.resizer,
  4967. document.getElementById(t.div.id) && t.parentNode.contains(t.div) && t.parentNode.removeChild(t.div),
  4968. ["video", "audio"].forEach((function(n) {
  4969. t[n];
  4970. var a = i[n];
  4971. clearTimeout(a.playDeferTimeout),
  4972. a.formerMediaState = null;
  4973. var o = {
  4974. playerId: t.playerId,
  4975. stateId: a.stateId + 1,
  4976. playDeferTimeout: null,
  4977. error: !1,
  4978. status: "aborted",
  4979. reason: "stop",
  4980. updatedAt: Date.now()
  4981. };
  4982. i[n] = o;
  4983. var c = {
  4984. type: "player-status-change",
  4985. playerId: t.playerId,
  4986. mediaType: n,
  4987. status: o.status,
  4988. reason: o.reason,
  4989. isErrorState: !1,
  4990. streamId: t.id
  4991. };
  4992. r.
  4993. default.debug("[".concat(t.id, "] Media Player Status Change Triggered by destroy()"), c),
  4994. e.stream.dispatchEvent(c),
  4995. s.b.reportApiInvoke(e.stream.sid, {
  4996. name: "Stream.playerStatusChange",
  4997. options: c,
  4998. tag: "tracer"
  4999. })()
  5000. }))
  5001. },
  5002. t.div = document.createElement("div"),
  5003. t.div.setAttribute("id", "player_" + t.id),
  5004. e.stream.video ? t.div.setAttribute("style", "width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;") : t.div.setAttribute("style", "width: 100%; height: 100%; position: relative; overflow: hidden;"),
  5005. t.video = document.createElement("video"),
  5006. t.video.setAttribute("id", "video" + t.id),
  5007. e.stream.local && !e.stream.screen ? e.stream.mirror ? t.video.setAttribute("style", "width: 100%; height: 100%; position: absolute; transform: rotateY(180deg); object-fit: ".concat(t.fit || "cover", ";")) : t.video.setAttribute("style", "width: 100%; height: 100%; position: absolute; object-fit: ".concat(t.fit || "cover", ";")) : e.stream.video ? t.video.setAttribute("style", "width: 100%; height: 100%; position: absolute; object-fit: ".concat(t.fit || "cover", ";")) : e.stream.screen ? t.video.setAttribute("style", "width: 100%; height: 100%; position: absolute; object-fit: ".concat(t.fit || "contain")) : t.video.setAttribute("style", "width: 100%; height: 100%; position: absolute; display: none; object-fit: ".concat(t.fit || "cover"));
  5008. var n = {
  5009. autoplay: !0,
  5010. muted: !!e.stream.local || !(!g.isSafari() && "iOS" !== g.getBrowserOS()) && "video_element_muted",
  5011. playsinline: !0,
  5012. controls: !1,
  5013. volume: null
  5014. },
  5015. a = E()({},
  5016. n, e.options); ! 0 !== a.muted || a.volume || (a.volume = 0),
  5017. t.video.setAttribute("autoplay", ""),
  5018. t.video.setAttribute("muted", ""),
  5019. t.video.muted = !0,
  5020. t.video.autoplay = !0,
  5021. a.playsinline && t.video.setAttribute("playsinline", ""),
  5022. a.controls && t.video.setAttribute("controls", ""),
  5023. a.contains && (t.video.controls = !0),
  5024. Number.isFinite(a.volume) && (t.video.volume = a.volume),
  5025. t.audio = document.createElement("audio"),
  5026. t.audio.setAttribute("id", "audio" + t.id),
  5027. !0 === a.muted && t.audio.setAttribute("muted", ""),
  5028. !0 === a.muted && (t.audio.muted = !0),
  5029. a.playsinline && t.audio.setAttribute("playsinline", ""),
  5030. Number.isFinite(a.volume) && (t.audio.volume = a.volume),
  5031. void 0 !== t.elementID ? (document.getElementById(t.elementID).appendChild(t.div), t.container = document.getElementById(t.elementID)) : (document.body.appendChild(t.div), t.container = document.body),
  5032. t.parentNode = t.div.parentNode;
  5033. var i = {
  5034. video: {
  5035. playerId: t.playerId,
  5036. stateId: 0,
  5037. playDeferTimeout: null,
  5038. error: !1,
  5039. status: "init",
  5040. reason: null,
  5041. updatedAt: Date.now()
  5042. },
  5043. audio: {
  5044. playerId: t.playerId,
  5045. stateId: 0,
  5046. playDeferTimeout: null,
  5047. error: !1,
  5048. status: "init",
  5049. reason: null,
  5050. updatedAt: Date.now()
  5051. }
  5052. };
  5053. t.mediaElemExists = function(e) {
  5054. for (var t = e,
  5055. n = 0; n < Object(o.getParameter)("MEDIA_ELEMENT_EXISTS_DEPTH") && t; n++) t = t.parentNode;
  5056. return !! t
  5057. };
  5058. var c = function(e) {
  5059. return t.mediaElemExists(e) ? e.paused ? "paused": "play": "aborted"
  5060. },
  5061. d = function(e, t, n) {
  5062. var a = c(e),
  5063. i = !0;
  5064. return "paused" === a ? ("audio" === t && !0 === n.muted && (i = !1), n.autoplay || (i = !1)) : "play" === a ? "video" === t ? i = !1 : !0 === n.muted ? e.muted && (i = !1) : e.muted || (i = !1) : "aborted" === a && (i = !1),
  5065. i
  5066. },
  5067. u = function(n) {
  5068. var u, l = this;
  5069. if (l === t.video ? u = "video": l === t.audio && (u = "audio"), u) {
  5070. n.type || r.
  5071. default.error("[".concat(t.id, "] Unexpected evt"), n);
  5072. var p = c(l);
  5073. clearTimeout(i[u].playDeferTimeout),
  5074. i[u].playDeferTimeout = setTimeout((function() {
  5075. i[u].playDeferTimeout = null;
  5076. var o = i[u],
  5077. f = c(l);
  5078. if (p === f) {
  5079. var g = {
  5080. playerId: t.playerId,
  5081. stateId: o.stateId + 1,
  5082. playDeferTimeout: null,
  5083. error: d(l, u, a),
  5084. status: c(l),
  5085. reason: n.type,
  5086. updatedAt: Date.now()
  5087. };
  5088. if (o.status !== g.status) {
  5089. i[u] = g;
  5090. var m = {
  5091. type: "player-status-change",
  5092. playerId: t.playerId,
  5093. mediaType: u,
  5094. status: g.status,
  5095. reason: g.reason,
  5096. isErrorState: g.error,
  5097. streamId: t.id
  5098. };
  5099. r.
  5100. default.debug("[".concat(t.id, "] Media Player Status Change"), m),
  5101. e.stream.dispatchEvent(m),
  5102. s.b.reportApiInvoke(e.stream.sid, {
  5103. name: "Stream.playerStatusChange",
  5104. options: m,
  5105. tag: "tracer"
  5106. })()
  5107. }
  5108. } else r.
  5109. default.debug("[".concat(t.id, "] Status Change after event Triggered.") + "Stream ".concat(t.id, " PlayerId ").concat(t.playerId, " mediaType ").concat(u, " Status ").concat(p, "=>").concat(f))
  5110. }), Object(o.getParameter)("PLAYER_STATE_DEFER"))
  5111. } else r.
  5112. default.error("[".concat(t.id, "] Unknown media element"), l)
  5113. };
  5114. t.video.addEventListener("playing", (function(e) { !
  5115. function e() {
  5116. t.video.videoWidth * t.video.videoHeight > 4 ? r.
  5117. default.debug("[" + t.id + "] video dimensions:", t.video.videoWidth, t.video.videoHeight) : setTimeout(e, 50)
  5118. } ()
  5119. }));
  5120. t.freezeCheckInterval = setInterval((function() {
  5121. Date.now() - t.lastTimeupdateTime > 500 ? (t.isFreeze = !0, t.freezeCount += 1) : t.isFreeze = !1
  5122. }), 500),
  5123. t.video.addEventListener("playing", u),
  5124. t.video.addEventListener("canplay", u),
  5125. t.video.addEventListener("abort", u),
  5126. t.video.addEventListener("onerror", u),
  5127. t.video.addEventListener("suspend", u),
  5128. t.video.addEventListener("stalled", u),
  5129. t.video.addEventListener("pause", u),
  5130. t.video.addEventListener("timeupdate", (function() {
  5131. t.lastTimeupdateTime = Date.now()
  5132. })),
  5133. t.audio.addEventListener("playing", u),
  5134. t.audio.addEventListener("canplay", u),
  5135. t.audio.addEventListener("abort", u),
  5136. t.audio.addEventListener("onerror", u),
  5137. t.audio.addEventListener("suspend", u),
  5138. t.audio.addEventListener("stalled", u),
  5139. t.audio.addEventListener("pause", u);
  5140. var l = t.audio,
  5141. p = "audio";
  5142. if (e.stream.hasVideo() || e.stream.hasScreen()) t.div.appendChild(t.video),
  5143. t.div.appendChild(t.audio),
  5144. g.isEdge() ? t.video.srcObject = e.stream.stream: (Object(h.attachMediaStream)(t.video, e.stream.stream), Object(h.attachMediaStream)(t.audio, e.stream.stream));
  5145. else { ! 1 !== a.muted && "video_element_muted" !== a.muted || (t.video.removeAttribute("muted"), t.video.muted = !1),
  5146. t.video.removeAttribute("autoplay"),
  5147. t.video.autoplay = !1,
  5148. t.div.appendChild(t.video),
  5149. l = t.video,
  5150. p = "video";
  5151. var f = i.audio,
  5152. m = {
  5153. playerId: t.playerId,
  5154. stateId: f.stateId + 1,
  5155. playDeferTimeout: null,
  5156. error: !1,
  5157. status: "aborted",
  5158. reason: "audioonly",
  5159. updatedAt: Date.now()
  5160. };
  5161. i.audio = m;
  5162. var v = {
  5163. type: "player-status-change",
  5164. playerId: t.playerId,
  5165. mediaType: "audio",
  5166. status: m.status,
  5167. reason: m.reason,
  5168. isErrorState: m.error,
  5169. streamId: t.id
  5170. };
  5171. if (r.
  5172. default.debug("[".concat(t.id, "] Media Player Status Change"), v), Promise.resolve().then((function() {
  5173. return e.stream.dispatchEvent(v)
  5174. })), s.b.reportApiInvoke(e.stream.sid, {
  5175. name: "Stream.playerStatusChange",
  5176. options: v,
  5177. tag: "tracer"
  5178. })(), window.MediaStream && (g.isSafari() || "iOS" === g.getBrowserOS())) {
  5179. var S = new MediaStream(e.stream.stream.getAudioTracks());
  5180. Object(h.setSrcObject)(t.video, S)
  5181. } else Object(h.setSrcObject)(t.video, e.stream.stream)
  5182. }
  5183. if (a.autoplay && l) {
  5184. var T = l.play();
  5185. T && T.
  5186. catch && T.
  5187. catch((function(n) {
  5188. if (!t.destroyed && l) {
  5189. var o = i[p],
  5190. u = {
  5191. playerId: t.playerId,
  5192. stateId: o.stateId + 1,
  5193. playDeferTimeout: null,
  5194. error: d(l, p, a),
  5195. status: c(l),
  5196. reason: "error",
  5197. updatedAt: Date.now()
  5198. };
  5199. if (o.status !== u.status) {
  5200. r.
  5201. default.debug("[".concat(t.id, "] Player ").concat(t.playerId, " Status Changed Detected by promise error: ").concat(o.status, "=>").concat(u.status), n),
  5202. i[p] = u;
  5203. var f = {
  5204. type: "player-status-change",
  5205. playerId: t.playerId,
  5206. mediaType: p,
  5207. status: u.status,
  5208. reason: u.reason,
  5209. isErrorState: u.error,
  5210. streamId: t.id
  5211. };
  5212. r.
  5213. default.debug("[".concat(t.id, "] Media Player Status Change"), f),
  5214. e.stream.dispatchEvent(f),
  5215. s.b.reportApiInvoke(e.stream.sid, {
  5216. name: "Stream.playerStatusChange",
  5217. options: f,
  5218. tag: "tracer"
  5219. })()
  5220. }
  5221. }
  5222. }))
  5223. }
  5224. return t.setAudioVolume = function(e) {
  5225. var n = parseInt(e) / 100;
  5226. isFinite(n) && (n < 0 ? n = 0 : n > 1 && (n = 1), t.video && (t.video.volume = n), t.audio && (t.audio.volume = n))
  5227. },
  5228. t
  5229. };
  5230. function R(e) {
  5231. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  5232. if (Array.isArray(e) || (e = function(e, t) {
  5233. if (!e) return;
  5234. if ("string" == typeof e) return A(e, t);
  5235. var n = Object.prototype.toString.call(e).slice(8, -1);
  5236. "Object" === n && e.constructor && (n = e.constructor.name);
  5237. if ("Map" === n || "Set" === n) return Array.from(n);
  5238. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return A(e, t)
  5239. } (e))) {
  5240. var t = 0,
  5241. n = function() {};
  5242. return {
  5243. s: n,
  5244. n: function() {
  5245. return t >= e.length ? {
  5246. done: !0
  5247. }: {
  5248. done: !1,
  5249. value: e[t++]
  5250. }
  5251. },
  5252. e: function(e) {
  5253. throw e
  5254. },
  5255. f: n
  5256. }
  5257. }
  5258. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  5259. }
  5260. var a, i, o = !0,
  5261. r = !1;
  5262. return {
  5263. s: function() {
  5264. a = e[Symbol.iterator]()
  5265. },
  5266. n: function() {
  5267. var e = a.next();
  5268. return o = e.done,
  5269. e
  5270. },
  5271. e: function(e) {
  5272. r = !0,
  5273. i = e
  5274. },
  5275. f: function() {
  5276. try {
  5277. o || null == a.
  5278. return || a.
  5279. return ()
  5280. } finally {
  5281. if (r) throw i
  5282. }
  5283. }
  5284. }
  5285. }
  5286. function A(e, t) { (null == t || t > e.length) && (t = e.length);
  5287. for (var n = 0,
  5288. a = new Array(t); n < t; n++) a[n] = e[n];
  5289. return a
  5290. }
  5291. var y = function(e) {
  5292. var t = {},
  5293. n = h.RTCPeerConnection;
  5294. t.uid = e.uid,
  5295. t.isVideoMute = e.isVideoMute,
  5296. t.isAudioMute = e.isAudioMute,
  5297. t.isSubscriber = e.isSubscriber,
  5298. t.clientId = e.clientId,
  5299. t.filterStatsCache = [],
  5300. t.originStatsCache = [],
  5301. t.lastTimeGetStats = null,
  5302. t.pc_config = {
  5303. iceServers: [{
  5304. url: "stun:webcs.agora.io:3478"
  5305. }]
  5306. };
  5307. var a = {
  5308. id: "outbound_audio_ssrc_send",
  5309. type: "ssrc",
  5310. mediaType: "",
  5311. googCodecName: "opus",
  5312. aecDivergentFilterFraction: "0",
  5313. audioInputLevel: "0",
  5314. bytesSent: "0",
  5315. packetsSent: "0",
  5316. googEchoCancellationReturnLoss: "0",
  5317. googEchoCancellationReturnLossEnhancement: "0"
  5318. },
  5319. i = {
  5320. id: "outbound_video_ssrc_send",
  5321. type: "ssrc",
  5322. mediaType: "",
  5323. googCodecName: "h264" === e.codec ? "H264": "VP8",
  5324. bytesSent: "0",
  5325. packetsLost: "0",
  5326. packetsSent: "0",
  5327. googAdaptationChanges: "0",
  5328. googAvgEncodeMs: "0",
  5329. googEncodeUsagePercent: "0",
  5330. googFirsReceived: "0",
  5331. googFrameHeightSent: "0",
  5332. googFrameHeightInput: "0",
  5333. googFrameRateInput: "0",
  5334. googFrameRateSent: "0",
  5335. googFrameWidthSent: "0",
  5336. googFrameWidthInput: "0",
  5337. googNacksReceived: "0",
  5338. googPlisReceived: "0",
  5339. googRtt: "0"
  5340. },
  5341. s = {
  5342. id: "inbound_audio_ssrc_recv",
  5343. type: "ssrc",
  5344. mediaType: "",
  5345. googCodecName: "opus",
  5346. audioOutputLevel: "0",
  5347. bytesReceived: "0",
  5348. packetsLost: "0",
  5349. packetsReceived: "0",
  5350. googAccelerateRate: "0",
  5351. googCurrentDelayMs: "0",
  5352. googDecodingCNG: "0",
  5353. googDecodingCTN: "0",
  5354. googDecodingCTSG: "0",
  5355. googDecodingNormal: "0",
  5356. googDecodingPLC: "0",
  5357. googDecodingPLCCNG: "0",
  5358. googExpandRate: "0",
  5359. googJitterBufferMs: "0",
  5360. googJitterReceived: "0",
  5361. googPreemptiveExpandRate: "0",
  5362. googPreferredJitterBufferMs: "0",
  5363. googSecondaryDecodedRate: "0",
  5364. googSpeechExpandRate: "0"
  5365. },
  5366. c = {
  5367. id: "inbound_video_ssrc_recv",
  5368. type: "ssrc",
  5369. mediaType: "",
  5370. googTargetDelayMs: "0",
  5371. packetsLost: "0",
  5372. googDecodeMs: "0",
  5373. googMaxDecodeMs: "0",
  5374. googRenderDelayMs: "0",
  5375. googFrameWidthReceived: "0",
  5376. googFrameHeightReceived: "0",
  5377. googFrameRateReceived: "0",
  5378. googFrameRateDecoded: "0",
  5379. googFrameRateOutput: "0",
  5380. googJitterBufferMs: "0",
  5381. googCurrentDelayMs: "0",
  5382. googMinPlayoutDelayMs: "0",
  5383. googNacksSent: "0",
  5384. googPlisSent: "0",
  5385. googFirsSent: "0",
  5386. bytesReceived: "0",
  5387. packetsReceived: "0",
  5388. googFramesReceived: "0",
  5389. googFramesDecoded: "0"
  5390. },
  5391. d = {
  5392. id: "bweforvideo",
  5393. type: "VideoBwe",
  5394. googAvailableSendBandwidth: "0",
  5395. googAvailableReceiveBandwidth: "0",
  5396. googActualEncBitrate: "0",
  5397. googRetransmitBitrate: "0",
  5398. googTargetEncBitrate: "0",
  5399. googBucketDelay: "0",
  5400. googTransmitBitrate: "0"
  5401. };
  5402. t.con = {
  5403. optional: [{
  5404. DtlsSrtpKeyAgreement: !0
  5405. }]
  5406. },
  5407. e.iceServers instanceof Array ? t.pc_config.iceServers = e.iceServers: (e.stunServerUrl && (e.stunServerUrl instanceof Array ? e.stunServerUrl.map((function(e) {
  5408. "string" == typeof e && "" !== e && t.pc_config.iceServers.push({
  5409. url: e
  5410. })
  5411. })) : "string" == typeof e.stunServerUrl && "" !== e.stunServerUrl && t.pc_config.iceServers.push({
  5412. url: e.stunServerUrl
  5413. })), e.turnServers && (e.turnServers instanceof Array ? e.turnServers.map((function(e) {
  5414. e.udpport && t.pc_config.iceServers.push({
  5415. username: e.username,
  5416. credential: e.credential,
  5417. credentialType: "password",
  5418. urls: "turn:" + e.url + ":" + e.udpport + "?transport=udp"
  5419. }),
  5420. "string" == typeof e.tcpport && "" !== e.tcpport && t.pc_config.iceServers.push({
  5421. username: e.username,
  5422. credential: e.credential,
  5423. credentialType: "password",
  5424. urls: "turn:" + e.url + ":" + e.tcpport + "?transport=tcp"
  5425. }),
  5426. !0 === e.forceturn && (t.pc_config.iceTransportPolicy = "relay")
  5427. })) : r.
  5428. default.error("[".concat(t.clientId, "] turnServers is not a array")))),
  5429. void 0 === e.audio && (e.audio = !0),
  5430. void 0 === e.video && (e.video = !0),
  5431. t.mediaConstraints = {
  5432. mandatory: {
  5433. OfferToReceiveVideo: e.video,
  5434. OfferToReceiveAudio: e.audio
  5435. }
  5436. },
  5437. t.roapSessionId = 103;
  5438. try {
  5439. t.pc_config.sdpSemantics = "plan-b",
  5440. t.peerConnection = new n(t.pc_config, t.con)
  5441. } catch(e) {
  5442. delete t.pc_config.sdpSemantics,
  5443. t.peerConnection = new n(t.pc_config, t.con)
  5444. }
  5445. t.iceCandidateTimer = setTimeout((function() {
  5446. t.iceCandidateTimer = null,
  5447. r.
  5448. default.debug("[".concat(t.clientId, "]Candidates collected: ").concat(t.iceCandidateCount)),
  5449. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  5450. }), Object(o.getParameter)("CANDIDATE_TIMEOUT")),
  5451. t.peerConnection.onicecandidate = function(e) {
  5452. var n, a, i, o;
  5453. a = (n = t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),
  5454. i = n.match(/a=candidate:.+typ\shost.+\r\n/),
  5455. o = n.match(/a=candidate:.+typ\srelay.+\r\n/),
  5456. null === a && null === i && null === o || void 0 !== t.ice || !t.iceCandidateTimer || (clearTimeout(t.iceCandidateTimer), t.iceCandidateTimer = null, t.ice = 0, t.moreIceComing = !1, t.markActionNeeded()),
  5457. t.iceCandidateCount = t.iceCandidateCount + 1
  5458. };
  5459. var u = function(t) {
  5460. return e.screen && (t = t.replace("a=x-google-flag:conference\r\n", "")),
  5461. t
  5462. },
  5463. l = function(n) {
  5464. var a, i;
  5465. if ((a = n.match(/m=video.*\r\n/)) && e.minVideoBW && e.maxVideoBW) {
  5466. i = a[0] + "b=AS:" + e.maxVideoBW + "\r\n";
  5467. var o = 0,
  5468. s = 0;
  5469. "h264" === e.codec ? (o = n.search(/a=rtpmap:(\d+) H264\/90000\r\n/), s = n.search(/H264\/90000\r\n/)) : "vp8" === e.codec && (o = n.search(/a=rtpmap:(\d+) VP8\/90000\r\n/), s = n.search(/VP8\/90000\r\n/)),
  5470. -1 !== o && -1 !== s && s - o > 10 && (i = i + "a=fmtp:" + n.slice(o + 9, s - 1) + " x-google-min-bitrate=" + e.minVideoBW + "\r\n"),
  5471. n = n.replace(a[0], i),
  5472. r.
  5473. default.debug("[" + t.clientId + "]Set Video Bitrate - min:" + e.minVideoBW + " max:" + e.maxVideoBW)
  5474. }
  5475. return (a = n.match(/m=audio.*\r\n/)) && e.maxAudioBW && (i = a[0] + "b=AS:" + e.maxAudioBW + "\r\n", n = n.replace(a[0], i)),
  5476. n
  5477. };
  5478. t.processSignalingMessage = function(e) {
  5479. var n, a = JSON.parse(e);
  5480. t.incomingMessage = a,
  5481. "new" === t.state ? "OFFER" === a.messageType ? (n = {
  5482. sdp: a.sdp,
  5483. type: "offer"
  5484. },
  5485. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5486. catch((function(e) {})), t.state = "offer-received", t.markActionNeeded()) : t.error("Illegal message for this state: " + a.messageType + " in state " + t.state) : "offer-sent" === t.state ? "ANSWER" === a.messageType ? ((n = {
  5487. sdp: a.sdp,
  5488. type: "answer"
  5489. }).sdp = u(n.sdp), n.sdp = l(n.sdp), n.sdp = n.sdp.replace("minptime=10", "minptime=10;stereo=1; sprop-stereo=1"), t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5490. catch((function(e) {})), t.state = "established") : "pr-answer" === a.messageType ? (n = {
  5491. sdp: a.sdp,
  5492. type: "pr-answer"
  5493. },
  5494. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5495. catch((function(e) {}))) : "offer" === a.messageType ? t.error("Not written yet") : t.error("Illegal message for this state: " + a.messageType + " in state " + t.state) : "established" === t.state && ("OFFER" === a.messageType ? (n = {
  5496. sdp: a.sdp,
  5497. type: "offer"
  5498. },
  5499. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5500. catch((function(e) {})), t.state = "offer-received", t.markActionNeeded()) : "ANSWER" === a.messageType ? ((n = {
  5501. sdp: a.sdp,
  5502. type: "answer"
  5503. }).sdp = u(n.sdp), n.sdp = l(n.sdp), t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5504. catch((function(e) {}))) : t.error("Illegal message for this state: " + a.messageType + " in state " + t.state))
  5505. };
  5506. var p = 0,
  5507. f = 0;
  5508. return t.getVideoRelatedStats = function(e) {
  5509. t.getStats((function(n) {
  5510. n.forEach((function(n) {
  5511. if (t.isSubscriber) {
  5512. if ("video" === n.mediaType && n.id && ~n.id.indexOf("recv")) {
  5513. if (g.isChromeKernel() && +g.getBrowserVersion() >= 76) {
  5514. var a = +n.googFramesReceived - p,
  5515. i = +n.googFramesDecoded - f;
  5516. t._setStat(c, "googFrameRateReceived", a),
  5517. t._setStat(c, "googFrameRateDecoded", i),
  5518. t._setStat(c, "googFrameRateOutput", i),
  5519. p = +n.googFramesReceived,
  5520. f = +n.googFramesDecoded
  5521. }
  5522. e && e({
  5523. mediaType: "video",
  5524. peerId: t.uid,
  5525. isVideoMute: t.isVideoMute,
  5526. frameRateReceived: n.googFrameRateReceived,
  5527. frameRateDecoded: n.googFrameRateDecoded,
  5528. bytesReceived: n.bytesReceived,
  5529. packetsReceived: n.packetsReceived,
  5530. packetsLost: n.packetsLost
  5531. })
  5532. }
  5533. } else "video" === n.mediaType && n.id && ~n.id.indexOf("send") && e && e({
  5534. mediaType: "video",
  5535. isVideoMute: t.isVideoMute,
  5536. frameRateInput: n.googFrameRateInput,
  5537. frameRateSent: n.googFrameRateSent,
  5538. googRtt: n.googRtt
  5539. })
  5540. }))
  5541. }))
  5542. },
  5543. t.getAudioRelatedStats = function(e) {
  5544. t.getStats((function(n) {
  5545. n.forEach((function(n) {
  5546. t.isSubscriber && "audio" === n.mediaType && n.id && ~n.id.indexOf("recv") && e && e({
  5547. mediaType: "audio",
  5548. peerId: t.uid,
  5549. isAudioMute: t.isAudioMute,
  5550. frameDropped: parseInt(n.googDecodingPLC) + parseInt(n.googDecodingPLCCNG) + "",
  5551. frameReceived: n.googDecodingCTN,
  5552. googJitterReceived: n.googJitterReceived,
  5553. bytesReceived: n.bytesReceived,
  5554. packetsReceived: n.packetsReceived,
  5555. packetsLost: n.packetsLost
  5556. })
  5557. }))
  5558. }))
  5559. },
  5560. t.getStatsRate = function(e) {
  5561. t.getStats((function(t) {
  5562. e(t)
  5563. }))
  5564. },
  5565. t.getStats = function(e, n) {
  5566. n = (n = n || 500) > 500 ? 500 : n,
  5567. t.lastTimeGetStats && Date.now() - t.lastTimeGetStats < n ? e && e(t.filterStatsCache, t.originStatsCache) : (t.lastTimeGetStats = Date.now(), this._getStats((function(n, a) {
  5568. t.filterStatsCache = n,
  5569. t.originStatsCache = a,
  5570. e && e(n, a)
  5571. })))
  5572. },
  5573. t._setStat = function(e, t, n) {
  5574. e.hasOwnProperty(t) && (null != n && n !== 1 / 0 && n == n || (n = 0), e[t] = n + "")
  5575. },
  5576. t._processGetStatsAfterChrome76 = function(e) {
  5577. var n = this;
  5578. t.lastStats || (t.lastStats = new Map),
  5579. t.peerConnection.getStats().then((function(o) {
  5580. var r, u = [],
  5581. l = [],
  5582. p = new Map,
  5583. f = new Date,
  5584. g = R(o.values());
  5585. try {
  5586. for (g.s(); ! (r = g.n()).done;) {
  5587. var m = r.value;
  5588. "codec" != m.type ? "candidate-pair" != m.type ? ("inbound-rtp" === m.type && "video" === m.mediaType && p.set("inbound-video", m), "inbound-rtp" === m.type && "audio" === m.mediaType && p.set("inbound-audio", m), "outbound-rtp" === m.type && "audio" === m.mediaType && p.set("outbound-audio", m), "outbound-rtp" === m.type && "video" === m.mediaType && p.set("outbound-video", m), "track" === m.type && "video" === m.kind && m.remoteSource && p.set("remote-video-track", m), "track" === m.type && "audio" === m.kind && m.remoteSource && p.set("remote-audio-track", m), "remote-inbound-rtp" === m.type && "video" === m.mediaType && p.set("remote-inbound-video", m), "remote-inbound-rtp" === m.type && "audio" === m.mediaType && p.set("remote-inbound-audio", m), "track" !== m.type || "video" !== m.kind || m.remoteSource || p.set("local-video-track", m), "track" !== m.type || "audio" !== m.kind || m.remoteSource || p.set("local-audio-track", m), "media-source" === m.type && "video" === m.kind && p.set("media-source-video", m), "media-source" === m.type && "audio" === m.kind && p.set("media-source-audio", m)) : l.push(m) : u.push(m)
  5589. }
  5590. } catch(e) {
  5591. g.e(e)
  5592. } finally {
  5593. g.f()
  5594. }
  5595. p.set("codec", u),
  5596. p.set("candidatePairs", l),
  5597. p.set("timestamp", +f);
  5598. var v = null,
  5599. S = null;
  5600. if (c.timestamp = f, s.timestamp = f, a.timestamp = f, a.timestamp = f, d.timestamp = f, n.isSubscriber)(v = p.get("inbound-video")) && (t._setStat(c, "id", "inbound_video_ssrc_recv"), t._setStat(c, "mediaType", v.mediaType), t._setStat(c, "packetsLost", v.packetsLost), t._setStat(c, "googDecodeMs", null), t._setStat(c, "googMaxDecodeMs", null), t._setStat(c, "googRenderDelayMs", null), t._setStat(c, "googMinPlayoutDelayMs", null), t._setStat(c, "googNacksSent", v.nackCount), t._setStat(c, "googPlisSent", v.pliCount), t._setStat(c, "googFirsSent", v.firCount), t._setStat(c, "bytesReceived", v.bytesReceived), t._setStat(c, "packetsReceived", v.packetsReceived)),
  5601. (v = p.get("inbound-audio")) && (t._setStat(s, "id", "inbound_audio_ssrc_recv"), t._setStat(s, "mediaType", v.mediaType), t._setStat(s, "bytesReceived", v.bytesReceived), t._setStat(s, "packetsLost", v.packetsLost), t._setStat(s, "packetsReceived", v.packetsReceived), t._setStat(s, "googAccelerateRate", v.removedSamplesForAcceleration), t._setStat(s, "googCurrentDelayMs", v.jitterBufferDelay), t._setStat(s, "googDecodingCNG", null), t._setStat(s, "googDecodingCTN", null), t._setStat(s, "googDecodingCTSG", null), t._setStat(s, "googDecodingNormal", null), t._setStat(s, "googDecodingPLC", null), t._setStat(s, "googDecodingPLCCNG", null), t._setStat(s, "googJitterReceived", v.jitter), t._setStat(s, "googPreferredJitterBufferMs", null), t._setStat(s, "googSecondaryDecodedRate", null)),
  5602. (v = p.get("remote-video-track")) && (t._setStat(c, "googTargetDelayMs", v.jitterBufferDelay), t._setStat(c, "googFrameWidthReceived", v.frameWidth), t._setStat(c, "googFrameHeightReceived", v.frameHeight), t._setStat(c, "googJitterBufferMs", v.jitterBufferDelay / v.jitterBufferEmittedCount * 1e3), t._setStat(c, "googCurrentDelayMs", v.jitterBufferDelay), t._setStat(c, "googFramesDecoded", v.framesDecoded), t._setStat(c, "googFramesReceived", v.framesReceived)),
  5603. (v = p.get("remote-audio-track")) && (t._setStat(s, "audioOutputLevel", 32767 * v.audioLevel), t._setStat(s, "googJitterBufferMs", v.jitterBufferDelay / v.jitterBufferEmittedCount * 1e3), t._setStat(s, "googExpandRate", v.concealedSamples), t._setStat(s, "googPreemptiveExpandRate", v.insertedSamplesForDeceleration), t._setStat(s, "googSpeechExpandRate", v.silentConcealedSamples));
  5604. else {
  5605. var _ = t.lastStats.get("timestamp"),
  5606. h = t.lastStats.get("outbound-video");
  5607. if ((v = p.get("outbound-audio")) && (t._setStat(a, "id", "outbound_audio_ssrc_send"), t._setStat(a, "mediaType", v.mediaType), t._setStat(a, "aecDivergentFilterFraction", null), t._setStat(a, "bytesSent", v.bytesSent), t._setStat(a, "packetsSent", v.packetsSent), S = v.transportId), v = p.get("outbound-video")) {
  5608. if (t._setStat(i, "id", "outbound_video_ssrc_send"), t._setStat(i, "mediaType", v.mediaType), t._setStat(i, "bytesSent", v.bytesSent), t._setStat(i, "packetsSent", v.packetsSent), t._setStat(i, "googAdaptationChanges", v.qualityLimitationDurations), t._setStat(i, "googAvgEncodeMs", null), t._setStat(i, "googEncodeUsagePercent", null), S = v.transportId, v.totalEncodedBytesTarget && h && h.totalEncodedBytesTarget) {
  5609. var I = (v.totalEncodedBytesTarget - h.totalEncodedBytesTarget) / ( + new Date - _);
  5610. t._setStat(d, "googTargetEncBitrate", Math.floor(8 * I * 1e3))
  5611. }
  5612. if (v.retransmittedBytesSent && h && h.retransmittedBytesSent) {
  5613. var b = (v.retransmittedBytesSent - h.retransmittedBytesSent) / ( + new Date - _);
  5614. t._setStat(d, "googRetransmitBitrate", Math.floor(8 * b * 1e3))
  5615. }
  5616. if (v.bytesSent && h && h.bytesSent) {
  5617. var T = (v.bytesSent - h.bytesSent) / ( + new Date - _);
  5618. t._setStat(d, "googTransmitBitrate", Math.floor(8 * T * 1e3)),
  5619. t._setStat(d, "googActualEncBitrate", Math.floor(8 * T * 1e3))
  5620. }
  5621. if (v.totalPacketSendDelay && h && h.totalPacketSendDelay) {
  5622. var A = (v.totalPacketSendDelay - h.totalPacketSendDelay) / ( + new Date - _);
  5623. t._setStat(d, "googBucketDelay", Math.floor(1e3 * A))
  5624. }
  5625. }
  5626. if ((v = p.get("remote-inbound-video")) && (t._setStat(i, "packetsLost", v.packetsLost), t._setStat(i, "googRtt", v.roundTripTime)), (v = p.get("local-video-track")) && (t._setStat(i, "googFrameHeightSent", v.frameHeight), t._setStat(i, "googFrameWidthSent", v.frameWidth), void 0 !== v.framesPerSecond && t._setStat(i, "googFrameRateSent", v.framesPerSecond)), (v = p.get("local-audio-track")) && (t._setStat(a, "googEchoCancellationReturnLoss", v.echoReturnLoss), t._setStat(a, "googEchoCancellationReturnLossEnhancement", v.echoReturnLossEnhancement)), (v = p.get("media-source-video")) && (t._setStat(i, "googFrameHeightInput", v.height), t._setStat(i, "googFrameWidthInput", v.width), t._setStat(i, "googFrameRateInput", v.framesPerSecond)), (v = p.get("media-source-audio")) && t._setStat(a, "audioInputLevel", 32767 * v.totalAudioEnergy), (v = p.get("inbound-video")) && (t._setStat(i, "googFirsReceived", v.firCount), t._setStat(i, "googNacksReceived", v.nackCount), t._setStat(i, "googPlisReceived", v.pliCount)), S) p.get("candidatePairs").map((function(e) {
  5627. S == e.transportId && t._setStat(d, "googAvailableSendBandwidth", e.availableOutgoingBitrate)
  5628. }));
  5629. else {
  5630. var y = p.get("candidatePairs")[0];
  5631. y && t._setStat(d, "googAvailableSendBandwidth", y.availableOutgoingBitrate)
  5632. }
  5633. }
  5634. t.lastStats = p;
  5635. var O = [E()({},
  5636. i), E()({},
  5637. a), E()({},
  5638. c), E()({},
  5639. s), E()({},
  5640. d)];
  5641. O.push({
  5642. id: "time",
  5643. startTime: t.connectedTime,
  5644. timestamp: new Date
  5645. }),
  5646. e(O)
  5647. }))
  5648. },
  5649. t._processGetStatsBeforeChrome76 = function(e) {
  5650. t.peerConnection.getStats((function(n) {
  5651. var o = [],
  5652. r = [],
  5653. u = null;
  5654. Object.keys(n).forEach((function(e) {
  5655. var t = n[e];
  5656. t && (r.push(t), u = t.timestamp, "VideoBwe" === t.type ? d = t: t.id.indexOf("_send") > -1 && "video" === t.mediaType ? i = t: t.id.indexOf("_send") > -1 && "audio" === t.mediaType ? a = t: t.id.indexOf("_recv") > -1 && "video" === t.mediaType ? c = t: t.id.indexOf("_recv") > -1 && "audio" === t.mediaType && (s = t))
  5657. })),
  5658. (o = [E()({},
  5659. i), E()({},
  5660. a), E()({},
  5661. c), E()({},
  5662. s), E()({},
  5663. d)]).push({
  5664. id: "time",
  5665. startTime: t.connectedTime,
  5666. timestamp: u || new Date
  5667. }),
  5668. e(o, r)
  5669. }))
  5670. },
  5671. t._getStats = function(e) {
  5672. Object(o.getParameter)("CHROME_NEW_STATS") && g.isChromeKernel() && +g.getBrowserVersion() >= 76 ? t._processGetStatsAfterChrome76(e) : t._processGetStatsBeforeChrome76(e)
  5673. },
  5674. t.addTrack = function(e, n) {
  5675. t.peerConnection.addTrack(e, n)
  5676. },
  5677. t.removeTrack = function(e, n) {
  5678. t.peerConnection.removeTrack(t.peerConnection.getSenders().find((function(t) {
  5679. return t.track == e
  5680. })))
  5681. },
  5682. t.addStream = function(e) {
  5683. t.peerConnection.addStream(e),
  5684. t.markActionNeeded()
  5685. },
  5686. t.removeStream = function() {
  5687. t.markActionNeeded()
  5688. },
  5689. t.close = function() {
  5690. t.state = "closed",
  5691. t.peerConnection.close()
  5692. },
  5693. t.markActionNeeded = function() {
  5694. t.actionNeeded = !0,
  5695. t.doLater((function() {
  5696. t.onstablestate()
  5697. }))
  5698. },
  5699. t.doLater = function(e) {
  5700. window.setTimeout(e, 1)
  5701. },
  5702. t.onstablestate = function() {
  5703. var e;
  5704. if (t.actionNeeded) {
  5705. if ("new" === t.state || "established" === t.state) t.peerConnection.createOffer((function(e) {
  5706. if (e.sdp !== t.prevOffer) return e.sdp = e.sdp.replace("minptime=10", "minptime=10;stereo=1; sprop-stereo=1"),
  5707. t.peerConnection.setLocalDescription(e),
  5708. t.state = "preparing-offer",
  5709. void t.markActionNeeded();
  5710. r.
  5711. default.debug("[" + t.clientId + "]Not sending a new offer")
  5712. }), (function(e) {
  5713. r.
  5714. default.debug("[" + t.clientId + "]peer connection create offer failed ", e)
  5715. }), t.mediaConstraints);
  5716. else if ("preparing-offer" === t.state) {
  5717. if (t.moreIceComing) return;
  5718. t.prevOffer = t.peerConnection.localDescription.sdp,
  5719. t.offerCandidates = t.prevOffer.match(/a=candidate.+\r\n/g) || [],
  5720. t.offerCandidates.length || (r.
  5721. default.warning("[".concat(t.clientId, "]No Ice Candidate generated")), Object(o.getParameter)("SHIM_CANDIDATE") ? (r.
  5722. default.debug("Shimming fake candidate"), t.prevOffer += "a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n") : r.
  5723. default.error("[".concat(t.clientId, "]None Ice Candidate not allowed"))),
  5724. t.prevOffer = t.prevOffer.replace(/a=candidate:.+typ\shost.+\r\n/g, "a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"),
  5725. t.sendMessage("OFFER", t.prevOffer),
  5726. t.state = "offer-sent"
  5727. } else if ("offer-received" === t.state) t.peerConnection.createAnswer((function(e) {
  5728. if (t.peerConnection.setLocalDescription(e), t.state = "offer-received-preparing-answer", t.iceStarted) t.markActionNeeded();
  5729. else {
  5730. var n = new Date;
  5731. r.
  5732. default.debug("[" + t.clientId + "]" + n.getTime() + ": Starting ICE in responder"),
  5733. t.iceStarted = !0
  5734. }
  5735. }), (function(e) {
  5736. r.
  5737. default.debug("[" + t.clientId + "]peer connection create answer failed ", e)
  5738. }), t.mediaConstraints);
  5739. else if ("offer-received-preparing-answer" === t.state) {
  5740. if (t.moreIceComing) return;
  5741. e = t.peerConnection.localDescription.sdp,
  5742. t.sendMessage("ANSWER", e),
  5743. t.state = "established"
  5744. } else r.
  5745. default.debug("[".concat(t.clientId, "] Dazed and confused in state ' + that.state + ', stopping here'"));
  5746. t.actionNeeded = !1
  5747. }
  5748. },
  5749. t.sendMessage = function(e, n) {
  5750. var a = {};
  5751. a.messageType = e,
  5752. a.sdp = n,
  5753. "OFFER" === e ? (a.offererSessionId = t.sessionId, a.answererSessionId = t.otherSessionId, a.seq = t.sequenceNumber += 1, a.tiebreaker = Math.floor(429496723 * Math.random() + 1)) : (a.offererSessionId = t.incomingMessage.offererSessionId, a.answererSessionId = t.sessionId, a.seq = t.incomingMessage.seq),
  5754. t.onsignalingmessage(JSON.stringify(a))
  5755. },
  5756. t._getSender = function(e) {
  5757. if (t.peerConnection && t.peerConnection.getSenders) {
  5758. var n = t.peerConnection.getSenders().find((function(t) {
  5759. return t.track.kind == e
  5760. }));
  5761. if (n) return n
  5762. }
  5763. return null
  5764. },
  5765. t.hasSender = function(e) {
  5766. return !! t._getSender(e)
  5767. },
  5768. t.replaceTrack = function(e, n, a) {
  5769. var i = t._getSender(e.kind);
  5770. if (!i) {
  5771. return a("NO_SENDER_FOUND")
  5772. }
  5773. try {
  5774. i.replaceTrack(e)
  5775. } catch(e) {
  5776. return a && a(e)
  5777. }
  5778. setTimeout((function() {
  5779. return n && n()
  5780. }), 50)
  5781. },
  5782. t.error = function(e) {
  5783. throw "Error in RoapOnJsep: " + e
  5784. },
  5785. t.sessionId = t.roapSessionId += 1,
  5786. t.sequenceNumber = 0,
  5787. t.actionNeeded = !1,
  5788. t.iceStarted = !1,
  5789. t.moreIceComing = !0,
  5790. t.iceCandidateCount = 0,
  5791. t.onsignalingmessage = e.callback,
  5792. t.peerConnection.ontrack = function(e) {
  5793. t.onaddstream && (t.onaddstream(e, "ontrack"), t.peerConnection.onaddstream = null)
  5794. },
  5795. t.peerConnection.onaddstream = function(e) {
  5796. t.onaddstream && (t.onaddstream(e, "onaddstream"), t.peerConnection.ontrack = null)
  5797. },
  5798. t.peerConnection.onremovestream = function(e) {
  5799. t.onremovestream && t.onremovestream(e)
  5800. },
  5801. t.peerConnection.oniceconnectionstatechange = function(e) {
  5802. "connected" === e.currentTarget.iceConnectionState && (t.connectedTime = new Date),
  5803. t.oniceconnectionstatechange && t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)
  5804. },
  5805. t.renegotiate = function() {
  5806. void 0 !== t.prevOffer && t.peerConnection.createOffer().then((function(e) {
  5807. return e.sdp = e.sdp.replace(/a=recvonly\r\n/g, "a=inactive\r\n"),
  5808. e.sdp = u(e.sdp),
  5809. e.sdp = l(e.sdp),
  5810. t.peerConnection.setLocalDescription(e)
  5811. })).then((function() {
  5812. t.onnegotiationneeded && t.onnegotiationneeded(t.peerConnection.localDescription.sdp)
  5813. })).
  5814. catch((function(e) {
  5815. console.log("createOffer error: ", e)
  5816. }))
  5817. },
  5818. t.peerConnection.onnegotiationneeded = t.renegotiate,
  5819. t.onaddstream = null,
  5820. t.onremovestream = null,
  5821. t.onnegotiationneeded = null,
  5822. t.state = "new",
  5823. t.markActionNeeded(),
  5824. t
  5825. },
  5826. O = function(e) {
  5827. var t = {},
  5828. n = h.RTCPeerConnection;
  5829. t.uid = e.uid,
  5830. t.isVideoMute = e.isVideoMute,
  5831. t.isAudioMute = e.isAudioMute,
  5832. t.isSubscriber = e.isSubscriber,
  5833. t.clientId = e.clientId,
  5834. t.filterStatsCache = [],
  5835. t.originStatsCache = [],
  5836. t.lastTimeGetStats = null,
  5837. t.pc_config = {
  5838. iceServers: [{
  5839. urls: ["stun:webcs.agora.io:3478", "stun:stun.l.google.com:19302"]
  5840. }],
  5841. bundlePolicy: "max-bundle"
  5842. },
  5843. t.con = {
  5844. optional: [{
  5845. DtlsSrtpKeyAgreement: !0
  5846. }]
  5847. },
  5848. e.iceServers instanceof Array ? t.pc_config.iceServers = e.iceServers: (e.stunServerUrl && (e.stunServerUrl instanceof Array ? e.stunServerUrl.map((function(e) {
  5849. "string" == typeof e && "" !== e && t.pc_config.iceServers.push({
  5850. url: e
  5851. })
  5852. })) : "string" == typeof e.stunServerUrl && "" !== e.stunServerUrl && t.pc_config.iceServers.push({
  5853. url: e.stunServerUrl
  5854. })), e.turnServers && (e.turnServers instanceof Array ? e.turnServers.map((function(e) {
  5855. e.udpport && t.pc_config.iceServers.push({
  5856. username: e.username,
  5857. credential: e.credential,
  5858. credentialType: "password",
  5859. urls: "turn:" + e.url + ":" + e.udpport + "?transport=udp"
  5860. }),
  5861. "string" == typeof e.tcpport && "" !== e.tcpport && t.pc_config.iceServers.push({
  5862. username: e.username,
  5863. credential: e.credential,
  5864. credentialType: "password",
  5865. urls: "turn:" + e.url + ":" + e.tcpport + "?transport=tcp"
  5866. }),
  5867. !0 === e.forceturn && (t.pc_config.iceTransportPolicy = "relay")
  5868. })) : r.
  5869. default.error("[".concat(t.clientId, "] turnServers is not a array")))),
  5870. void 0 === e.audio && (e.audio = !0),
  5871. void 0 === e.video && (e.video = !0),
  5872. t.mediaConstraints = {
  5873. mandatory: {
  5874. OfferToReceiveVideo: e.video,
  5875. OfferToReceiveAudio: e.audio
  5876. }
  5877. },
  5878. t.roapSessionId = 103;
  5879. try {
  5880. t.pc_config.sdpSemantics = "plan-b",
  5881. t.peerConnection = new n(t.pc_config, t.con)
  5882. } catch(e) {
  5883. delete t.pc_config.sdpSemantics,
  5884. t.peerConnection = new n(t.pc_config, t.con)
  5885. }
  5886. t.iceCandidateTimer = setTimeout((function() {
  5887. t.iceCandidateTimer = null,
  5888. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  5889. }), Object(o.getParameter)("CANDIDATE_TIMEOUT")),
  5890. t.peerConnection.onicecandidate = function(e) {
  5891. var n, a, i, o;
  5892. a = (n = t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),
  5893. i = n.match(/a=candidate:.+typ\shost.+\r\n/),
  5894. o = n.match(/a=candidate:.+typ\srelay.+\r\n/),
  5895. 0 === t.iceCandidateCount && (t.timeout = setTimeout((function() {
  5896. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  5897. }), 1e3)),
  5898. null === a && null === i && null === o || void 0 !== t.ice || !t.iceCandidateTimer || (clearTimeout(t.iceCandidateTimer), t.iceCandidateTimer = null, t.ice = 0, t.moreIceComing = !1, t.markActionNeeded()),
  5899. t.iceCandidateCount = t.iceCandidateCount + 1
  5900. };
  5901. var a = function(t) {
  5902. return e.screen && (t = t.replace("a=x-google-flag:conference\r\n", "")),
  5903. t
  5904. },
  5905. i = function(n) {
  5906. var a, i;
  5907. return (a = n.match(/m=video.*\r\n/)) && e.minVideoBW && e.maxVideoBW && (i = a[0] + "b=AS:" + e.maxVideoBW + "\r\n", n = n.replace(a[0], i), r.
  5908. default.debug("[" + t.clientId + "]Set Video Bitrate - min:" + e.minVideoBW + " max:" + e.maxVideoBW)),
  5909. (a = n.match(/m=audio.*\r\n/)) && e.maxAudioBW && (i = a[0] + "b=AS:" + e.maxAudioBW + "\r\n", n = n.replace(a[0], i)),
  5910. n
  5911. };
  5912. t.processSignalingMessage = function(e) {
  5913. var n, o = JSON.parse(e);
  5914. t.incomingMessage = o,
  5915. "new" === t.state ? "OFFER" === o.messageType ? (n = {
  5916. sdp: o.sdp,
  5917. type: "offer"
  5918. },
  5919. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)), t.state = "offer-received", t.markActionNeeded()) : t.error("Illegal message for this state: " + o.messageType + " in state " + t.state) : "offer-sent" === t.state ? "ANSWER" === o.messageType ? ((n = {
  5920. sdp: o.sdp,
  5921. type: "answer"
  5922. }).sdp = a(n.sdp), n.sdp = i(n.sdp), n.sdp = n.sdp.replace(/a=x-google-flag:conference\r\n/g, ""), t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)), t.state = "established") : "pr-answer" === o.messageType ? (n = {
  5923. sdp: o.sdp,
  5924. type: "pr-answer"
  5925. },
  5926. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n))) : "offer" === o.messageType ? t.error("Not written yet") : t.error("Illegal message for this state: " + o.messageType + " in state " + t.state) : "established" === t.state && ("OFFER" === o.messageType ? (n = {
  5927. sdp: o.sdp,
  5928. type: "offer"
  5929. },
  5930. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)), t.state = "offer-received", t.markActionNeeded()) : "ANSWER" === o.messageType ? ((n = {
  5931. sdp: o.sdp,
  5932. type: "answer"
  5933. }).sdp = a(n.sdp), n.sdp = i(n.sdp), t.peerConnection.setRemoteDescription(new RTCSessionDescription(n))) : t.error("Illegal message for this state: " + o.messageType + " in state " + t.state))
  5934. };
  5935. var s = {
  5936. id: "",
  5937. type: "",
  5938. mediaType: "",
  5939. googCodecName: "opus",
  5940. aecDivergentFilterFraction: "0",
  5941. audioInputLevel: "0",
  5942. bytesSent: "0",
  5943. packetsSent: "0",
  5944. googEchoCancellationReturnLoss: "0",
  5945. googEchoCancellationReturnLossEnhancement: "0"
  5946. },
  5947. c = {
  5948. id: "",
  5949. type: "",
  5950. mediaType: "",
  5951. googCodecName: "h264" === e.codec ? "H264": "VP8",
  5952. bytesSent: "0",
  5953. packetsLost: "0",
  5954. packetsSent: "0",
  5955. googAdaptationChanges: "0",
  5956. googAvgEncodeMs: "0",
  5957. googEncodeUsagePercent: "0",
  5958. googFirsReceived: "0",
  5959. googFrameHeightSent: "0",
  5960. googFrameHeightInput: "0",
  5961. googFrameRateInput: "0",
  5962. googFrameRateSent: "0",
  5963. googFrameWidthSent: "0",
  5964. googFrameWidthInput: "0",
  5965. googNacksReceived: "0",
  5966. googPlisReceived: "0",
  5967. googRtt: "0",
  5968. googFramesEncoded: "0"
  5969. },
  5970. d = {
  5971. id: "",
  5972. type: "",
  5973. mediaType: "",
  5974. audioOutputLevel: "0",
  5975. bytesReceived: "0",
  5976. packetsLost: "0",
  5977. packetsReceived: "0",
  5978. googAccelerateRate: "0",
  5979. googCurrentDelayMs: "0",
  5980. googDecodingCNG: "0",
  5981. googDecodingCTN: "0",
  5982. googDecodingCTSG: "0",
  5983. googDecodingNormal: "0",
  5984. googDecodingPLC: "0",
  5985. googDecodingPLCCNG: "0",
  5986. googExpandRate: "0",
  5987. googJitterBufferMs: "0",
  5988. googJitterReceived: "0",
  5989. googPreemptiveExpandRate: "0",
  5990. googPreferredJitterBufferMs: "0",
  5991. googSecondaryDecodedRate: "0",
  5992. googSpeechExpandRate: "0"
  5993. },
  5994. u = {
  5995. id: "",
  5996. type: "",
  5997. mediaType: "",
  5998. googTargetDelayMs: "0",
  5999. packetsLost: "0",
  6000. googDecodeMs: "0",
  6001. googMaxDecodeMs: "0",
  6002. googRenderDelayMs: "0",
  6003. googFrameWidthReceived: "0",
  6004. googFrameHeightReceived: "0",
  6005. googFrameRateReceived: "0",
  6006. googFrameRateDecoded: "0",
  6007. googFrameRateOutput: "0",
  6008. googFramesDecoded: "0",
  6009. googFrameReceived: "0",
  6010. googJitterBufferMs: "0",
  6011. googCurrentDelayMs: "0",
  6012. googMinPlayoutDelayMs: "0",
  6013. googNacksSent: "0",
  6014. googPlisSent: "0",
  6015. googFirsSent: "0",
  6016. bytesReceived: "0",
  6017. packetsReceived: "0"
  6018. },
  6019. l = {
  6020. id: "bweforvideo",
  6021. type: "VideoBwe",
  6022. googAvailableSendBandwidth: "0",
  6023. googAvailableReceiveBandwidth: "0",
  6024. googActualEncBitrate: "0",
  6025. googRetransmitBitrate: "0",
  6026. googTargetEncBitrate: "0",
  6027. googBucketDelay: "0",
  6028. googTransmitBitrate: "0"
  6029. },
  6030. p = 0,
  6031. f = 0,
  6032. g = 0;
  6033. return t.isRemoteVideoStats = function(e) {
  6034. return !! (e.frameHeight && e.frameWidth && e.remoteSource)
  6035. },
  6036. t.getVideoRelatedStats = function(n) {
  6037. t.peerConnection.getStats().then((function(a) {
  6038. var i = {
  6039. peerId: t.uid,
  6040. mediaType: "video",
  6041. isVideoMute: t.isVideoMute
  6042. };
  6043. a.forEach((function(a) {
  6044. if (t.isSubscriber) {
  6045. if ("track" === a.type && (~a.id.indexOf("video") || ~a.trackIdentifier.indexOf("v") || t.isRemoteVideoStats(a))) {
  6046. if (!t.lastReport) return void(t.lastReport = a);
  6047. i.frameRateReceived = a.framesReceived - t.lastReport.framesReceived + "",
  6048. i.frameRateDecoded = a.framesDecoded - t.lastReport.framesDecoded + "",
  6049. t.lastReport = a
  6050. }
  6051. "inbound-rtp" === a.type && ~a.id.indexOf("Video") && (i.bytesReceived = a.bytesReceived + "", i.packetsReceived = a.packetsReceived + "", i.packetsLost = a.packetsLost + "")
  6052. } else if ("outbound-rtp" === a.type && ~a.id.indexOf("Video")) {
  6053. if (!t.lastReport) return void(t.lastReport = a);
  6054. n && n({
  6055. mediaType: "video",
  6056. isVideoMute: t.isVideoMute,
  6057. frameRateInput: e.maxFrameRate + "",
  6058. frameRateSent: a.framesEncoded - t.lastReport.framesEncoded + ""
  6059. }),
  6060. t.lastReport = a
  6061. }
  6062. })),
  6063. n && n(i)
  6064. }))
  6065. },
  6066. t.getAudioRelatedStats = function(e) {
  6067. t.peerConnection.getStats().then((function(n) {
  6068. n.forEach((function(n) {
  6069. t.isSubscriber && "inbound-rtp" === n.type && ~n.id.indexOf("Audio") && e && e({
  6070. peerId: t.uid,
  6071. mediaType: "audio",
  6072. isAudioMute: t.isAudioMute,
  6073. frameDropped: n.packetsLost + "",
  6074. frameReceived: n.packetsReceived + "",
  6075. googJitterReceived: n.jitter + "",
  6076. bytesReceived: n.bytesReceived + "",
  6077. packetsReceived: n.packetsReceived + "",
  6078. packetsLost: n.packetsLost + ""
  6079. })
  6080. }))
  6081. }))
  6082. },
  6083. t.getStatsRate = function(e) {
  6084. t.getStats((function(t) {
  6085. t.forEach((function(e) {
  6086. "outbound-rtp" === e.type && "video" === e.mediaType && e.googFramesEncoded && (e.googFrameRateSent = ((e.googFramesEncoded - p) / 3).toString(), p = e.googFramesEncoded),
  6087. "inbound-rtp" === e.type && -1 != e.id.indexOf("55543") && (e.googFrameRateReceived && (e.googFrameRateReceived = ((e.googFrameReceived - g) / 3).toString(), g = e.googFrameReceived), e.googFrameRateDecoded && (e.googFrameRateDecoded = ((e.googFramesDecoded - f) / 3).toString(), f = e.googFramesDecoded))
  6088. })),
  6089. e(t)
  6090. }))
  6091. },
  6092. t.getStats = function(e, n) {
  6093. n = (n = n || 500) > 500 ? 500 : n,
  6094. t.lastTimeGetStats && Date.now() - t.lastTimeGetStats < n ? e && e(t.filterStatsCache, t.originStatsCache) : this._getStats((function(n, a) {
  6095. t.filterStatsCache = n,
  6096. t.originStatsCache = a,
  6097. t.lastTimeGetStats = Date.now(),
  6098. e && e(n, a)
  6099. }))
  6100. },
  6101. t._getStats = function(e) {
  6102. var n = [];
  6103. t.peerConnection.getStats().then((function(a) {
  6104. a.forEach((function(e) {
  6105. n.push(e),
  6106. "outbound-rtp" === e.type && "audio" === e.mediaType && (s.id = e.id, s.type = e.type, s.mediaType = e.mediaType, s.bytesSent = e.bytesSent ? e.bytesSent + "": "0", s.packetsSent = e.packetsSent ? e.packetsSent + "": "0"),
  6107. "outbound-rtp" === e.type && "video" === e.mediaType && (c.id = e.id, c.type = e.type, c.mediaType = e.mediaType, c.bytesSent = e.bytesSent ? e.bytesSent + "": "0", c.packetsSent = e.packetsSent ? e.packetsSent + "": "0", c.googPlisReceived = e.pliCount ? e.pliCount + "": "0", c.googNacksReceived = e.nackCount ? e.nackCount + "": "0", c.googFirsReceived = e.firCount ? e.firCount + "": "0", c.googFramesEncoded = e.framesEncoded ? e.framesEncoded + "": "0"),
  6108. "inbound-rtp" === e.type && -1 != e.id.indexOf("44444") && (d.id = e.id, d.type = e.type, d.mediaType = "audio", d.packetsReceived = e.packetsReceived ? e.packetsReceived + "": "0", d.bytesReceived = e.bytesReceived ? e.bytesReceived + "": "0", d.packetsLost = e.packetsLost ? e.packetsLost + "": "0", d.packetsReceived = e.packetsReceived ? e.packetsReceived + "": "0", d.googJitterReceived = e.jitter ? e.jitter + "": "0"),
  6109. "inbound-rtp" === e.type && -1 != e.id.indexOf("55543") && (u.id = e.id, u.type = e.type, u.mediaType = "video", u.packetsReceived = e.packetsReceived ? e.packetsReceived + "": "0", u.bytesReceived = e.bytesReceived ? e.bytesReceived + "": "0", u.packetsLost = e.packetsLost ? e.packetsLost + "": "0", u.googJitterBufferMs = e.jitter ? e.jitter + "": "0", u.googNacksSent = e.nackCount ? e.nackCount + "": "0", u.googPlisSent = e.pliCount ? e.pliCount + "": "0", u.googFirsSent = e.firCount ? e.firCount + "": "0"),
  6110. "track" !== e.type || -1 == e.id.indexOf("55543") && !~e.trackIdentifier.indexOf("v") && null != e.audioLevel || (u.googFrameWidthReceived = e.frameWidth ? e.frameWidth + "": "0", u.googFrameHeightReceived = e.frameHeight ? e.frameHeight + "": "0", u.googFrameReceived = e.framesReceived ? e.framesReceived + "": "0", u.googFramesDecoded = e.framesDecoded ? e.framesDecoded + "": "0"),
  6111. "track" !== e.type || -1 == e.id.indexOf("44444") && !~e.trackIdentifier.indexOf("a") && void 0 === e.audioLevel || (d.audioOutputLevel = e.audioLevel + "", s.audioInputLevel = e.audioLevel + ""),
  6112. "candidate-pair" === e.type && (0 == e.availableIncomingBitrate ? l.googAvailableSendBandwidth = e.availableOutgoingBitrate + "": l.googAvailableReceiveBandwidth = e.availableIncomingBitrate + "")
  6113. }));
  6114. var i = [l, s, c, d, u];
  6115. i.push({
  6116. id: "time",
  6117. startTime: t.connectedTime,
  6118. timestamp: new Date
  6119. }),
  6120. e(i, n)
  6121. })).
  6122. catch((function(e) {
  6123. r.
  6124. default.error("[" + t.clientId + "] ", e)
  6125. }))
  6126. },
  6127. t.addTrack = function(e, n) {
  6128. t.peerConnection.addTrack(e, n)
  6129. },
  6130. t.removeTrack = function(e, n) {
  6131. var a = t.peerConnection.getSenders().find((function(t) {
  6132. return t.track == e
  6133. }));
  6134. a.replaceTrack(null),
  6135. t.peerConnection.removeTrack(a)
  6136. },
  6137. t.addStream = function(e) {
  6138. window.navigator.userAgent.indexOf("Safari") > -1 && -1 === navigator.userAgent.indexOf("Chrome") ? e.getTracks().forEach((function(n) {
  6139. return t.peerConnection.addTrack(n, e)
  6140. })) : t.peerConnection.addStream(e),
  6141. t.markActionNeeded()
  6142. },
  6143. t.removeStream = function() {
  6144. t.markActionNeeded()
  6145. },
  6146. t.close = function() {
  6147. t.state = "closed",
  6148. t.peerConnection.close()
  6149. },
  6150. t.markActionNeeded = function() {
  6151. t.actionNeeded = !0,
  6152. t.doLater((function() {
  6153. t.onstablestate()
  6154. }))
  6155. },
  6156. t.doLater = function(e) {
  6157. window.setTimeout(e, 1)
  6158. },
  6159. t.onstablestate = function() {
  6160. var n;
  6161. if (t.actionNeeded) {
  6162. if ("new" === t.state || "established" === t.state) {
  6163. if (e.isSubscriber) t.peerConnection.addTransceiver("audio", {
  6164. direction: "recvonly"
  6165. }),
  6166. t.peerConnection.addTransceiver("video", {
  6167. direction: "recvonly"
  6168. });
  6169. t.peerConnection.createOffer(t.mediaConstraints).then((function(n) {
  6170. if (n.sdp = i(n.sdp), e.isSubscriber || (n.sdp = n.sdp.replace(/a=.*video-orientation\r\n/g, "")), n.sdp !== t.prevOffer) return t.peerConnection.setLocalDescription(n),
  6171. t.state = "preparing-offer",
  6172. void t.markActionNeeded();
  6173. r.
  6174. default.debug("[" + t.clientId + "]Not sending a new offer")
  6175. })).
  6176. catch((function(e) {
  6177. r.
  6178. default.debug("[" + t.clientId + "]peer connection create offer failed ", e)
  6179. }))
  6180. } else if ("preparing-offer" === t.state) {
  6181. if (t.moreIceComing) return;
  6182. t.prevOffer = t.peerConnection.localDescription.sdp,
  6183. t.offerCandidates = t.prevOffer.match(/a=candidate.+\r\n/g) || [],
  6184. t.offerCandidates.length || (r.
  6185. default.warning("[".concat(t.clientId, "]No Ice Candidate generated")), Object(o.getParameter)("SHIM_CANDIDATE") ? (r.
  6186. default.debug("Shimming fake candidate"), t.prevOffer += "a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n") : r.
  6187. default.error("[".concat(t.clientId, "]None Ice Candidate not allowed"))),
  6188. t.prevOffer = t.prevOffer.replace(/a=candidate:.+typ\shost.+\r\n/g, "a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"),
  6189. t.sendMessage("OFFER", t.prevOffer),
  6190. t.state = "offer-sent"
  6191. } else if ("offer-received" === t.state) t.peerConnection.createAnswer((function(e) {
  6192. if (t.peerConnection.setLocalDescription(e), t.state = "offer-received-preparing-answer", t.iceStarted) t.markActionNeeded();
  6193. else {
  6194. var n = new Date;
  6195. r.
  6196. default.debug("[" + t.clientId + "]" + n.getTime() + ": Starting ICE in responder"),
  6197. t.iceStarted = !0
  6198. }
  6199. }), (function(e) {
  6200. r.
  6201. default.debug("[" + t.clientId + "]peer connection create answer failed ", e)
  6202. }), t.mediaConstraints);
  6203. else if ("offer-received-preparing-answer" === t.state) {
  6204. if (t.moreIceComing) return;
  6205. n = t.peerConnection.localDescription.sdp,
  6206. t.sendMessage("ANSWER", n),
  6207. t.state = "established"
  6208. } else t.debug("Dazed and confused in state " + t.state + ", stopping here");
  6209. t.actionNeeded = !1
  6210. }
  6211. },
  6212. t.sendMessage = function(e, n) {
  6213. var a = {};
  6214. a.messageType = e,
  6215. a.sdp = n,
  6216. "OFFER" === e ? (a.offererSessionId = t.sessionId, a.answererSessionId = t.otherSessionId, a.seq = t.sequenceNumber += 1, a.tiebreaker = Math.floor(429496723 * Math.random() + 1)) : (a.offererSessionId = t.incomingMessage.offererSessionId, a.answererSessionId = t.sessionId, a.seq = t.incomingMessage.seq),
  6217. t.onsignalingmessage(JSON.stringify(a))
  6218. },
  6219. t._getSender = function(e) {
  6220. if (t.peerConnection && t.peerConnection.getSenders) {
  6221. var n = t.peerConnection.getSenders().find((function(t) {
  6222. return t.track.kind == e
  6223. }));
  6224. if (n) return n
  6225. }
  6226. return null
  6227. },
  6228. t.hasSender = function(e) {
  6229. return !! t._getSender(e)
  6230. },
  6231. t.replaceTrack = function(e, n, a) {
  6232. var i = t._getSender(e.kind);
  6233. if (!i) {
  6234. return a("NO_SENDER_FOUND")
  6235. }
  6236. try {
  6237. i.replaceTrack(e)
  6238. } catch(e) {
  6239. return a && a(e)
  6240. }
  6241. setTimeout((function() {
  6242. return n && n()
  6243. }), 50)
  6244. },
  6245. t.error = function(e) {
  6246. throw "Error in RoapOnJsep: " + e
  6247. },
  6248. t.sessionId = t.roapSessionId += 1,
  6249. t.sequenceNumber = 0,
  6250. t.actionNeeded = !1,
  6251. t.iceStarted = !1,
  6252. t.moreIceComing = !0,
  6253. t.iceCandidateCount = 0,
  6254. t.onsignalingmessage = e.callback,
  6255. t.peerConnection.ontrack = function(e) {
  6256. console.log("!!! ontrack, ", e.track.kind, e.track),
  6257. t.onaddstream && t.onaddstream(e, "ontrack")
  6258. },
  6259. t.peerConnection.onremovestream = function(e) {
  6260. t.onremovestream && t.onremovestream(e)
  6261. },
  6262. t.peerConnection.oniceconnectionstatechange = function(e) {
  6263. "connected" === e.currentTarget.iceConnectionState && (t.connectedTime = new Date),
  6264. t.oniceconnectionstatechange && t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)
  6265. },
  6266. t.renegotiate = function() {
  6267. void 0 !== t.prevOffer && t.peerConnection.createOffer().then((function(e) {
  6268. return e.sdp = e.sdp.replace(/a=recvonly\r\n/g, "a=inactive\r\n"),
  6269. e.sdp = a(e.sdp),
  6270. e.sdp = i(e.sdp),
  6271. t.peerConnection.setLocalDescription(e)
  6272. })).then((function() {
  6273. t.onnegotiationneeded && t.onnegotiationneeded(t.peerConnection.localDescription.sdp)
  6274. })).
  6275. catch((function(e) {
  6276. console.log("createOffer error: ", e)
  6277. }))
  6278. },
  6279. t.peerConnection.onnegotiationneeded = t.renegotiate,
  6280. t.onaddstream = null,
  6281. t.onremovestream = null,
  6282. t.state = "new",
  6283. t.markActionNeeded(),
  6284. t
  6285. };
  6286. function C(e) {
  6287. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  6288. if (Array.isArray(e) || (e = function(e, t) {
  6289. if (!e) return;
  6290. if ("string" == typeof e) return N(e, t);
  6291. var n = Object.prototype.toString.call(e).slice(8, -1);
  6292. "Object" === n && e.constructor && (n = e.constructor.name);
  6293. if ("Map" === n || "Set" === n) return Array.from(n);
  6294. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return N(e, t)
  6295. } (e))) {
  6296. var t = 0,
  6297. n = function() {};
  6298. return {
  6299. s: n,
  6300. n: function() {
  6301. return t >= e.length ? {
  6302. done: !0
  6303. }: {
  6304. done: !1,
  6305. value: e[t++]
  6306. }
  6307. },
  6308. e: function(e) {
  6309. throw e
  6310. },
  6311. f: n
  6312. }
  6313. }
  6314. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  6315. }
  6316. var a, i, o = !0,
  6317. r = !1;
  6318. return {
  6319. s: function() {
  6320. a = e[Symbol.iterator]()
  6321. },
  6322. n: function() {
  6323. var e = a.next();
  6324. return o = e.done,
  6325. e
  6326. },
  6327. e: function(e) {
  6328. r = !0,
  6329. i = e
  6330. },
  6331. f: function() {
  6332. try {
  6333. o || null == a.
  6334. return || a.
  6335. return ()
  6336. } finally {
  6337. if (r) throw i
  6338. }
  6339. }
  6340. }
  6341. }
  6342. function N(e, t) { (null == t || t > e.length) && (t = e.length);
  6343. for (var n = 0,
  6344. a = new Array(t); n < t; n++) a[n] = e[n];
  6345. return a
  6346. }
  6347. var w = function(e) {
  6348. var t = {},
  6349. n = (mozRTCPeerConnection, mozRTCSessionDescription),
  6350. a = !1;
  6351. t.uid = e.uid,
  6352. t.isVideoMute = e.isVideoMute,
  6353. t.isAudioMute = e.isAudioMute,
  6354. t.isSubscriber = e.isSubscriber,
  6355. t.clientId = e.clientId,
  6356. t.filterStatsCache = [],
  6357. t.originStatsCache = [],
  6358. t.lastTimeGetStats = null,
  6359. t.pc_config = {
  6360. iceServers: []
  6361. },
  6362. e.iceServers instanceof Array ? e.iceServers.map((function(e) {
  6363. 0 === e.url.indexOf("stun:") && t.pc_config.iceServers.push({
  6364. url: e.url
  6365. })
  6366. })) : (e.stunServerUrl && (e.stunServerUrl instanceof Array ? e.stunServerUrl.map((function(e) {
  6367. "string" == typeof e && "" !== e && t.pc_config.iceServers.push({
  6368. url: e
  6369. })
  6370. })) : "string" == typeof e.stunServerUrl && "" !== e.stunServerUrl && t.pc_config.iceServers.push({
  6371. url: e.stunServerUrl
  6372. })), e.turnServers && (e.turnServers instanceof Array ? e.turnServers.map((function(e) {
  6373. e.udpport && t.pc_config.iceServers.push({
  6374. username: e.username,
  6375. credential: e.credential,
  6376. credentialType: "password",
  6377. urls: "turn:" + e.url + ":" + e.udpport + "?transport=udp"
  6378. }),
  6379. "string" == typeof e.tcpport && "" !== e.tcpport && t.pc_config.iceServers.push({
  6380. username: e.username,
  6381. credential: e.credential,
  6382. credentialType: "password",
  6383. urls: "turn:" + e.url + ":" + e.tcpport + "?transport=tcp"
  6384. }),
  6385. !0 === e.forceturn && (t.pc_config.iceTransportPolicy = "relay")
  6386. })) : r.
  6387. default.error("[".concat(t.clientId, "] turnServers is not a array")))),
  6388. void 0 === e.audio && (e.audio = !0),
  6389. void 0 === e.video && (e.video = !0),
  6390. t.mediaConstraints = {
  6391. offerToReceiveAudio: e.audio,
  6392. offerToReceiveVideo: e.video,
  6393. mozDontOfferDataChannel: !0
  6394. },
  6395. t.roapSessionId = 103,
  6396. t.peerConnection = new h.RTCPeerConnection(t.pc_config),
  6397. t.iceCandidateTimer = setTimeout((function() {
  6398. t.iceCandidateTimer = null,
  6399. r.
  6400. default.debug("[".concat(t.clientId, "]Candidates collected: ").concat(t.iceCandidateCount)),
  6401. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  6402. }), Object(o.getParameter)("CANDIDATE_TIMEOUT")),
  6403. t.peerConnection.onicecandidate = function(e) {
  6404. var n, a, i, o;
  6405. a = (n = t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),
  6406. i = n.match(/a=candidate:.+typ\shost.+\r\n/),
  6407. o = n.match(/a=candidate:.+typ\srelay.+\r\n/),
  6408. null === a && null === i && null === o || void 0 !== t.ice || !t.iceCandidateTimer || (clearTimeout(t.iceCandidateTimer), t.iceCandidateTimer = null, t.ice = 0, t.moreIceComing = !1, t.markActionNeeded()),
  6409. t.iceCandidateCount = t.iceCandidateCount + 1
  6410. },
  6411. t.checkMLineReverseInSDP = function(e) {
  6412. return ! (!~e.indexOf("m=audio") || !~e.indexOf("m=video")) && e.indexOf("m=audio") > e.indexOf("m=video")
  6413. },
  6414. t.reverseMLineInSDP = function(e) {
  6415. var t = e.split("m=audio"),
  6416. n = t[1].split("m=video"),
  6417. a = "m=video" + n[1],
  6418. i = "m=audio" + n[0];
  6419. return e = t[0] + a + i
  6420. },
  6421. t.processSignalingMessage = function(e) {
  6422. var a, i = JSON.parse(e);
  6423. t.incomingMessage = i,
  6424. "new" === t.state ? "OFFER" === i.messageType ? (i.sdp = l(i.sdp), a = {
  6425. sdp: i.sdp,
  6426. type: "offer"
  6427. },
  6428. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6429. r.
  6430. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6431. }), (function(e) {
  6432. r.
  6433. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e.name)
  6434. })), t.state = "offer-received", t.markActionNeeded()) : t.error("Illegal message for this state: " + i.messageType + " in state " + t.state) : "offer-sent" === t.state ? "ANSWER" === i.messageType ? (i.sdp = l(i.sdp), i.sdp = i.sdp.replace(/ generation 0/g, ""), i.sdp = i.sdp.replace(/ udp /g, " UDP "), -1 !== i.sdp.indexOf("a=group:BUNDLE") ? (i.sdp = i.sdp.replace(/a=group:BUNDLE audio video/, "a=group:BUNDLE sdparta_0 sdparta_1"), i.sdp = i.sdp.replace(/a=mid:audio/, "a=mid:sdparta_0"), i.sdp = i.sdp.replace(/a=mid:video/, "a=mid:sdparta_1")) : (i.sdp = i.sdp.replace(/a=mid:audio/, "a=mid:sdparta_0"), i.sdp = i.sdp.replace(/a=mid:video/, "a=mid:sdparta_0")), a = {
  6435. sdp: i.sdp,
  6436. type: "answer"
  6437. },
  6438. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6439. r.
  6440. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6441. }), (function(e) {
  6442. r.
  6443. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e)
  6444. })), t.state = "established") : "pr-answer" === i.messageType ? (a = {
  6445. sdp: i.sdp,
  6446. type: "pr-answer"
  6447. },
  6448. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6449. r.
  6450. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6451. }), (function(e) {
  6452. r.
  6453. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e.name)
  6454. }))) : "offer" === i.messageType ? t.error("Not written yet") : t.error("Illegal message for this state: " + i.messageType + " in state " + t.state) : "established" === t.state && ("OFFER" === i.messageType ? (a = {
  6455. sdp: i.sdp,
  6456. type: "offer"
  6457. },
  6458. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6459. r.
  6460. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6461. }), (function(e) {
  6462. r.
  6463. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e.name)
  6464. })), t.state = "offer-received", t.markActionNeeded()) : t.error("Illegal message for this state: " + i.messageType + " in state " + t.state))
  6465. };
  6466. var i = {
  6467. id: "",
  6468. type: "",
  6469. mediaType: "opus",
  6470. googCodecName: "opus",
  6471. aecDivergentFilterFraction: "0",
  6472. audioInputLevel: "0",
  6473. bytesSent: "0",
  6474. packetsSent: "0",
  6475. googEchoCancellationReturnLoss: "0",
  6476. googEchoCancellationReturnLossEnhancement: "0"
  6477. },
  6478. s = {
  6479. id: "",
  6480. type: "",
  6481. mediaType: "",
  6482. googCodecName: "h264" === e.codec ? "H264": "VP8",
  6483. bytesSent: "0",
  6484. packetsLost: "0",
  6485. packetsSent: "0",
  6486. googAdaptationChanges: "0",
  6487. googAvgEncodeMs: "0",
  6488. googEncodeUsagePercent: "0",
  6489. googFirsReceived: "0",
  6490. googFrameHeightSent: "0",
  6491. googFrameHeightInput: "0",
  6492. googFrameRateInput: "0",
  6493. googFrameRateSent: "0",
  6494. googFrameWidthSent: "0",
  6495. googFrameWidthInput: "0",
  6496. googNacksReceived: "0",
  6497. googPlisReceived: "0",
  6498. googRtt: "0"
  6499. },
  6500. c = {
  6501. id: "",
  6502. type: "",
  6503. mediaType: "",
  6504. audioOutputLevel: "0",
  6505. bytesReceived: "0",
  6506. packetsLost: "0",
  6507. packetsReceived: "0",
  6508. googAccelerateRate: "0",
  6509. googCurrentDelayMs: "0",
  6510. googDecodingCNG: "0",
  6511. googDecodingCTN: "0",
  6512. googDecodingCTSG: "0",
  6513. googDecodingNormal: "0",
  6514. googDecodingPLC: "0",
  6515. googDecodingPLCCNG: "0",
  6516. googExpandRate: "0",
  6517. googJitterBufferMs: "0",
  6518. googJitterReceived: "0",
  6519. googPreemptiveExpandRate: "0",
  6520. googPreferredJitterBufferMs: "0",
  6521. googSecondaryDecodedRate: "0",
  6522. googSpeechExpandRate: "0"
  6523. },
  6524. d = {
  6525. id: "",
  6526. type: "",
  6527. mediaType: "",
  6528. googTargetDelayMs: "0",
  6529. packetsLost: "0",
  6530. googDecodeMs: "0",
  6531. googMaxDecodeMs: "0",
  6532. googRenderDelayMs: "0",
  6533. googFrameWidthReceived: "0",
  6534. googFrameHeightReceived: "0",
  6535. googFrameRateReceived: "0",
  6536. googFrameRateDecoded: "0",
  6537. googFrameRateOutput: "0",
  6538. googJitterBufferMs: "0",
  6539. googCurrentDelayMs: "0",
  6540. googMinPlayoutDelayMs: "0",
  6541. googNacksSent: "0",
  6542. googPlisSent: "0",
  6543. googFirsSent: "0",
  6544. bytesReceived: "0",
  6545. packetsReceived: "0",
  6546. googFramesDecoded: "0"
  6547. },
  6548. u = 0;
  6549. t.getVideoRelatedStats = function(e) {
  6550. t.peerConnection.getStats().then((function(n) {
  6551. var a, i = C(n.values());
  6552. try {
  6553. for (i.s(); ! (a = i.n()).done;) {
  6554. var o = a.value;
  6555. if (t.isSubscriber) {
  6556. if (("inbound-rtp" === o.type || "inboundrtp" === o.type) && "video" === o.mediaType) {
  6557. if (!t.lastReport) return void(t.lastReport = o);
  6558. e && e({
  6559. browser: "firefox",
  6560. mediaType: "video",
  6561. peerId: t.uid,
  6562. isVideoMute: t.isVideoMute,
  6563. frameRateReceived: o.framerateMean + "",
  6564. frameRateDecoded: o.framesDecoded - t.lastReport.framesDecoded + "",
  6565. bytesReceived: o.bytesReceived + "",
  6566. packetsReceived: o.packetsReceived + "",
  6567. packetsLost: o.packetsLost + ""
  6568. }),
  6569. t.lastReport = o
  6570. }
  6571. } else if (("outbound-rtp" === o.type || "outboundrtp" === o.type) && "video" === o.mediaType) {
  6572. if (!t.lastReport) return void(t.lastReport = o);
  6573. e && e({
  6574. mediaType: "video",
  6575. isVideoMute: t.isVideoMute,
  6576. frameRateInput: o.framerateMean + "",
  6577. frameRateSent: o.framesEncoded - t.lastReport.framesEncoded + ""
  6578. }),
  6579. t.lastReport = o
  6580. }
  6581. }
  6582. } catch(e) {
  6583. i.e(e)
  6584. } finally {
  6585. i.f()
  6586. }
  6587. }))
  6588. },
  6589. t.getAudioRelatedStats = function(e) {
  6590. t.peerConnection.getStats().then((function(n) {
  6591. var a, i = C(n.values());
  6592. try {
  6593. for (i.s(); ! (a = i.n()).done;) {
  6594. var o = a.value;
  6595. t.isSubscriber && ("inbound-rtp" !== o.type && "inboundrtp" !== o.type || "audio" !== o.mediaType || e && e({
  6596. browser: "firefox",
  6597. mediaType: "audio",
  6598. peerId: t.uid,
  6599. isAudioMute: t.isAudioMute,
  6600. frameDropped: o.packetsLost + "",
  6601. frameReceived: o.packetsReceived + "",
  6602. googJitterReceived: o.jitter + "",
  6603. bytesReceived: o.bytesReceived + "",
  6604. packetsReceived: o.packetsReceived + "",
  6605. packetsLost: o.packetsLost + ""
  6606. }))
  6607. }
  6608. } catch(e) {
  6609. i.e(e)
  6610. } finally {
  6611. i.f()
  6612. }
  6613. }))
  6614. },
  6615. t.getStatsRate = function(e) {
  6616. t.getStats((function(t) {
  6617. t.forEach((function(e) {
  6618. "inbound-rtp" !== e.type && "inboundrtp" !== e.type || "video" !== e.mediaType || e.googFrameRateDecoded && (e.googFrameRateDecoded = ((e.googFramesDecoded - u) / 3).toString(), u = e.googFramesDecoded)
  6619. })),
  6620. e(t)
  6621. }))
  6622. },
  6623. t.getStats = function(e, n) {
  6624. n = (n = n || 500) > 500 ? 500 : n,
  6625. t.lastTimeGetStats && Date.now() - t.lastTimeGetStats < n ? e && e(t.filterStatsCache, t.originStatsCache) : this._getStats((function(n, a) {
  6626. t.filterStatsCache = n,
  6627. t.originStatsCache = a,
  6628. t.lastTimeGetStats = Date.now(),
  6629. e && e(n, a)
  6630. }))
  6631. },
  6632. t._getStats = function(e) {
  6633. t.peerConnection.getStats().then((function(n) {
  6634. var a, o = [],
  6635. r = C(n.values());
  6636. try {
  6637. for (r.s(); ! (a = r.n()).done;) {
  6638. var u = a.value;
  6639. o.push(u),
  6640. "outbound-rtp" !== u.type && "outboundrtp" !== u.type || "video" !== u.mediaType || -1 !== u.id.indexOf("rtcp") || (s.id = u.id, s.type = u.type, s.mediaType = u.mediaType, s.bytesSent = u.bytesSent ? u.bytesSent + "": "0", s.packetsSent = u.packetsSent ? u.packetsSent + "": "0", s.googPlisReceived = u.pliCount ? u.pliCount + "": "0", s.googNacksReceived = u.nackCount ? u.nackCount + "": "0", s.googFirsReceived = u.firCount ? u.firCount + "": "0", s.googFrameRateSent = u.framerateMean ? u.framerateMean + "": "0"),
  6641. "outbound-rtp" !== u.type && "outboundrtp" !== u.type || "audio" !== u.mediaType || -1 !== u.id.indexOf("rtcp") || (i.id = u.id, i.type = u.type, i.mediaType = u.mediaType, i.bytesSent = u.bytesSent ? u.bytesSent + "": "0", i.packetsSent = u.packetsSent ? u.packetsSent + "": "0"),
  6642. "inbound-rtp" !== u.type && "inboundrtp" !== u.type || "audio" !== u.mediaType || u.isRemote || -1 !== u.id.indexOf("rtcp") || (c.id = u.id, c.type = u.type, c.mediaType = u.mediaType, c.bytesReceived = u.bytesReceived ? u.bytesReceived + "": "0", c.packetsLost = u.packetsLost ? u.packetsLost + "": "0", c.packetsReceived = u.packetsReceived ? u.packetsReceived + "": "0", c.googJitterReceived = u.jitter ? u.jitter + "": "0"),
  6643. "inbound-rtp" !== u.type && "inboundrtp" !== u.type || "video" !== u.mediaType || u.isRemote || -1 !== u.id.indexOf("rtcp") || (d.id = u.id, d.type = u.type, d.mediaType = u.mediaType, d.bytesReceived = u.bytesReceived ? u.bytesReceived + "": "0", d.googFrameRateReceived = u.framerateMean ? u.framerateMean + "": "0", d.googFramesDecoded = u.framesDecoded ? u.framesDecoded + "": "0", d.packetsLost = u.packetsLost ? u.packetsLost + "": "0", d.packetsReceived = u.packetsReceived ? u.packetsReceived + "": "0", d.googJitterBufferMs = u.jitter ? u.jitter + "": "0", d.googNacksSent = u.nackCount ? u.nackCount + "": "0", d.googPlisSent = u.pliCount ? u.pliCount + "": "0", d.googFirsSent = u.firCount ? u.firCount + "": "0"),
  6644. -1 !== u.id.indexOf("outbound_rtcp_video") && (s.packetsLost = u.packetsLost ? u.packetsLost + "": "0")
  6645. }
  6646. } catch(e) {
  6647. r.e(e)
  6648. } finally {
  6649. r.f()
  6650. }
  6651. var l = [s, i, c, d];
  6652. l.push({
  6653. id: "time",
  6654. startTime: t.connectedTime,
  6655. timestamp: new Date
  6656. }),
  6657. e(l, o)
  6658. }), (function(e) {
  6659. r.
  6660. default.error("[" + t.clientId + "]" + e)
  6661. }))
  6662. },
  6663. t.addStream = function(e) {
  6664. a = !0,
  6665. t.peerConnection.addStream(e),
  6666. t.markActionNeeded()
  6667. },
  6668. t.removeStream = function() {
  6669. t.markActionNeeded()
  6670. },
  6671. t.close = function() {
  6672. t.state = "closed",
  6673. t.peerConnection.close()
  6674. },
  6675. t.markActionNeeded = function() {
  6676. t.actionNeeded = !0,
  6677. t.doLater((function() {
  6678. t.onstablestate()
  6679. }))
  6680. },
  6681. t.doLater = function(e) {
  6682. window.setTimeout(e, 1)
  6683. },
  6684. t.onstablestate = function() {
  6685. if (t.actionNeeded) {
  6686. if ("new" === t.state || "established" === t.state) {
  6687. a && (t.mediaConstraints = void 0),
  6688. t.peerConnection.createOffer((function(e) {
  6689. if (e.sdp = l(e.sdp), e.sdp = e.sdp.replace(/a=extmap:1 http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/abs-send-time/, "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"), e.sdp !== t.prevOffer) return t.peerConnection.setLocalDescription(e),
  6690. t.state = "preparing-offer",
  6691. void t.markActionNeeded();
  6692. r.
  6693. default.debug("[" + t.clientId + "]Not sending a new offer")
  6694. }), (function(e) {
  6695. r.
  6696. default.debug("[" + t.clientId + "]Ups! create offer failed ", e)
  6697. }), t.mediaConstraints)
  6698. } else if ("preparing-offer" === t.state) {
  6699. if (t.moreIceComing) return;
  6700. t.prevOffer = t.peerConnection.localDescription.sdp,
  6701. t.offerCandidates = t.prevOffer.match(/a=candidate.+\r\n/g) || [],
  6702. t.offerCandidates.length || (r.
  6703. default.warning("[".concat(t.clientId, "]No Ice Candidate generated")), Object(o.getParameter)("SHIM_CANDIDATE") ? (r.
  6704. default.debug("Shimming fake candidate"), t.prevOffer += "a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n") : r.
  6705. default.error("[".concat(t.clientId, "]None Ice Candidate not allowed"))),
  6706. t.prevOffer = t.prevOffer.replace(/a=candidate:.+typ\shost.+\r\n/g, "a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"),
  6707. t.sendMessage("OFFER", t.prevOffer),
  6708. t.state = "offer-sent"
  6709. } else if ("offer-received" === t.state) t.peerConnection.createAnswer((function(e) {
  6710. if (t.peerConnection.setLocalDescription(e), t.state = "offer-received-preparing-answer", t.iceStarted) t.markActionNeeded();
  6711. else {
  6712. var n = new Date;
  6713. r.
  6714. default.debug("[" + t.clientId + "]" + n.getTime() + ": Starting ICE in responder"),
  6715. t.iceStarted = !0
  6716. }
  6717. }), (function() {
  6718. r.
  6719. default.debug("[" + t.clientId + "]Ups! Something went wrong")
  6720. }));
  6721. else if ("offer-received-preparing-answer" === t.state) {
  6722. if (t.moreIceComing) return;
  6723. var e = t.peerConnection.localDescription.sdp;
  6724. t.sendMessage("ANSWER", e),
  6725. t.state = "established"
  6726. } else t.debug("Dazed and confused in state " + t.state + ", stopping here");
  6727. t.actionNeeded = !1
  6728. }
  6729. },
  6730. t.sendMessage = function(e, n) {
  6731. var a = {};
  6732. a.messageType = e,
  6733. a.sdp = n,
  6734. "OFFER" === e ? (a.offererSessionId = t.sessionId, a.answererSessionId = t.otherSessionId, a.seq = t.sequenceNumber += 1, a.tiebreaker = Math.floor(429496723 * Math.random() + 1)) : (a.offererSessionId = t.incomingMessage.offererSessionId, a.answererSessionId = t.sessionId, a.seq = t.incomingMessage.seq),
  6735. t.onsignalingmessage(JSON.stringify(a))
  6736. },
  6737. t._getSender = function(e) {
  6738. if (t.peerConnection && t.peerConnection.getSenders) {
  6739. var n = t.peerConnection.getSenders().find((function(t) {
  6740. return t.track.kind == e
  6741. }));
  6742. if (n) return n
  6743. }
  6744. return null
  6745. },
  6746. t.hasSender = function(e) {
  6747. return !! t._getSender(e)
  6748. },
  6749. t.replaceTrack = function(e, n, a) {
  6750. var i = t._getSender(e.kind);
  6751. if (!i) {
  6752. return a("NO_SENDER_FOUND")
  6753. }
  6754. try {
  6755. i.replaceTrack(e)
  6756. } catch(e) {
  6757. return a && a(e)
  6758. }
  6759. setTimeout((function() {
  6760. return n && n()
  6761. }), 50)
  6762. },
  6763. t.error = function(e) {
  6764. throw "Error in RoapOnJsep: " + e
  6765. },
  6766. t.sessionId = t.roapSessionId += 1,
  6767. t.sequenceNumber = 0,
  6768. t.actionNeeded = !1,
  6769. t.iceStarted = !1,
  6770. t.moreIceComing = !0,
  6771. t.iceCandidateCount = 0,
  6772. t.onsignalingmessage = e.callback,
  6773. t.peerConnection.ontrack = function(e) {
  6774. t.onaddstream && t.onaddstream(e, "ontrack")
  6775. },
  6776. t.peerConnection.onremovestream = function(e) {
  6777. t.onremovestream && t.onremovestream(e)
  6778. },
  6779. t.peerConnection.oniceconnectionstatechange = function(e) {
  6780. "connected" === e.currentTarget.iceConnectionState && (t.connectedTime = new Date),
  6781. t.oniceconnectionstatechange && t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)
  6782. };
  6783. var l = function(t) {
  6784. var n;
  6785. if (e.video && e.maxVideoBW && (null == (n = t.match(/m=video.*\r\n/)) && (n = t.match(/m=video.*\n/)), n && n.length > 0)) {
  6786. var a = n[0] + "b=TIAS:" + 1e3 * e.maxVideoBW + "\r\n";
  6787. t = t.replace(n[0], a)
  6788. }
  6789. if (e.audio && e.maxAudioBW && (null == (n = t.match(/m=audio.*\r\n/)) && (n = t.match(/m=audio.*\n/)), n && n.length > 0)) {
  6790. a = n[0] + "b=TIAS:" + 1e3 * e.maxAudioBW + "\r\n";
  6791. t = t.replace(n[0], a)
  6792. }
  6793. return t
  6794. };
  6795. return t.onaddstream = null,
  6796. t.onremovestream = null,
  6797. t.state = "new",
  6798. t.markActionNeeded(),
  6799. t
  6800. },
  6801. D = a(24),
  6802. k = a.n(D),
  6803. L = null,
  6804. P = function() {
  6805. try {
  6806. L = window.require("electron")
  6807. } catch(e) {}
  6808. return L
  6809. },
  6810. M = function(e) {
  6811. var t = s.b.reportApiInvoke(null, {
  6812. callback: e,
  6813. name: "getScreenSources",
  6814. options: arguments,
  6815. tag: "tracer"
  6816. }),
  6817. n = P();
  6818. if (!n) return t && t("electron is null");
  6819. try {
  6820. var a = n.desktopCapturer.getSources({
  6821. types: ["window", "screen"]
  6822. })
  6823. } catch(e) {
  6824. console.log(e)
  6825. }
  6826. if (a instanceof Promise) console.log("electron.desktopCapturer.getSources return type is Promise"),
  6827. a.then((function(e) {
  6828. return t && t(null, e)
  6829. })).
  6830. catch((function(e) {
  6831. return t && t(e)
  6832. }));
  6833. else a = n.desktopCapturer.getSources({
  6834. types: ["window", "screen"]
  6835. },
  6836. (function(e, n) {
  6837. console.log("electron.desktopCapturer.getSources return type is callback"),
  6838. t && t(null, n)
  6839. }))
  6840. },
  6841. U = function(e, t, n) {
  6842. var a = t.width;
  6843. t = {
  6844. audio: !1,
  6845. video: {
  6846. mandatory: {
  6847. chromeMediaSource: "desktop",
  6848. chromeMediaSourceId: e,
  6849. maxHeight: t.height,
  6850. maxWidth: a,
  6851. maxFrameRate: t.frameRate && t.frameRate.max,
  6852. minFrameRate: t.frameRate && t.frameRate.min
  6853. }
  6854. }
  6855. };
  6856. navigator.webkitGetUserMedia(t, (function(e) {
  6857. n && n(null, e)
  6858. }), (function(e) {
  6859. n && n(e)
  6860. }))
  6861. },
  6862. x = function() {
  6863. return !! P()
  6864. },
  6865. V = M,
  6866. j = U,
  6867. B = function(e, t) {
  6868. M((function(n, a) {
  6869. if (n) return t && t(n); !
  6870. function(e, t) {
  6871. var n = document.createElement("div");
  6872. n.innerText = "share screen",
  6873. n.setAttribute("style", "text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;");
  6874. var a = document.createElement("div");
  6875. a.setAttribute("style", "width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;");
  6876. var i = document.createElement("div");
  6877. i.innerText = "Agora Web Screensharing wants to share the contents of your screen with webdemo.agorabeckon.com. Choose what you'd like to share.",
  6878. i.setAttribute("style", "height: 12%;");
  6879. var o = document.createElement("div");
  6880. o.setAttribute("style", "width: 100%; height: 80%; background: #FFF; border: solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around; overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");
  6881. var r = document.createElement("div");
  6882. r.setAttribute("style", "text-align: right; padding: 16px 0;");
  6883. var s = document.createElement("button");
  6884. s.innerHTML = "cancel",
  6885. s.setAttribute("style", "width: 85px;"),
  6886. s.onclick = function() {
  6887. document.body.removeChild(c),
  6888. t && t("NotAllowedError")
  6889. },
  6890. r.appendChild(s),
  6891. a.appendChild(i),
  6892. a.appendChild(o),
  6893. a.appendChild(r);
  6894. var c = document.createElement("div");
  6895. c.setAttribute("style", "position: absolute; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);"),
  6896. c.appendChild(n),
  6897. c.appendChild(a),
  6898. document.body.appendChild(c),
  6899. e.map((function(e) {
  6900. if (e.id) {
  6901. var n = document.createElement("div");
  6902. n.setAttribute("style", "width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;"),
  6903. n.innerHTML = '<div style="height: 120px; display: table-cell; vertical-align: middle;"><img style="width: 100%; background: #333333; box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);" src=' + e.thumbnail.toDataURL() + ' /></div><span style="\theight: 40px; line-height: 40px; display: inline-block; width: 70%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">' + e.name + "</span>",
  6904. n.onclick = function() {
  6905. document.body.removeChild(c),
  6906. t && t(null, e.id)
  6907. },
  6908. o.appendChild(n)
  6909. }
  6910. }))
  6911. } (a, (function(n, a) {
  6912. if (n) return t && t(n);
  6913. U(a, e, t)
  6914. }))
  6915. }))
  6916. },
  6917. F = 103,
  6918. W = function(e) {
  6919. var t = {};
  6920. if (t.clientId = e.clientId, e.session_id = F += 1, "undefined" == typeof window || !window.navigator) throw r.
  6921. default.error("[" + t.streamId + "][" + t.clientId + "]Publish/subscribe video/audio streams not supported yet"),
  6922. new Error("NON_BROWSER_ENV_DETECTED");
  6923. return null !== window.navigator.userAgent.match("Firefox") ? (t.browser = "mozilla", t = w(e)) : "iOS" === g.getBrowserOS() || g.isSafari() ? (r.
  6924. default.debug("[" + t.streamId + "][" + t.clientId + "]Safari"), (t = O(e)).browser = "safari") : ~window.navigator.userAgent.indexOf("Edge") ? t = new k.a(e) : (t = y(e)).browser = "chrome-stable",
  6925. t
  6926. },
  6927. G = function(e, t, n) {
  6928. var a = {};
  6929. a.config = e,
  6930. a.streamId = e.streamId,
  6931. delete e.streamId,
  6932. navigator.getMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  6933. var i = 0,
  6934. o = 1,
  6935. s = !1,
  6936. c = null,
  6937. d = function(e) {
  6938. if (i++, c) if (c === e) r.
  6939. default.debug("Using Video Source/ Audio Source");
  6940. else {
  6941. var n = c.getVideoTracks()[0],
  6942. a = c.getAudioTracks()[0],
  6943. d = e.getVideoTracks()[0],
  6944. u = e.getAudioTracks()[0];
  6945. d && (n && c.removeTrack(n), c.addTrack(d)),
  6946. u && (a && c.removeTrack(a), c.addTrack(u))
  6947. } else c = e;
  6948. i !== o || s || (s = !0, setTimeout((function() {
  6949. t(c)
  6950. }), 0))
  6951. },
  6952. u = function(e) {
  6953. r.
  6954. default.error("Failed to GetUserMedia", e.name, e.code, e.message, e),
  6955. i++,
  6956. s || (s = !0, setTimeout((function() {
  6957. n && n(e)
  6958. }), 0))
  6959. },
  6960. l = function() {
  6961. var t = {
  6962. video: e.video,
  6963. audio: e.audio
  6964. };
  6965. if (r.
  6966. default.debug("GetUserMedia", JSON.stringify(t)), navigator.mediaDevices && navigator.mediaDevices.getUserMedia) navigator.mediaDevices.getUserMedia(t).then(d).
  6967. catch(u);
  6968. else if ("undefined" != typeof navigator && navigator.getMedia) navigator.getMedia(e, d, u);
  6969. else {
  6970. var i = {
  6971. name: "MEDIA_NOT_SUPPORT",
  6972. message: "Video/audio streams not supported yet"
  6973. };
  6974. r.
  6975. default.error("[" + a.streamId + "]" + i.message),
  6976. n && n(i)
  6977. }
  6978. };
  6979. if ((e.videoSource || e.audioSource) && (c = new MediaStream, e.videoSource && c.addTrack(e.videoSource), e.audioSource && c.addTrack(e.audioSource)), e.video || e.audio || e.screen || e.screenAudio) {
  6980. if (!e.screen && e.screenAudio) return n && n({
  6981. code: "Set screen to true before sharing the audio"
  6982. });
  6983. if (e.screen) {
  6984. if (x()) return e.screen.sourceId ? j(e.screen.sourceId, e.screen, (function(t, n) {
  6985. t ? u(t) : (e.audio && (o++, l()), d(n))
  6986. })) : B(e.screen, (function(t, n) {
  6987. t ? u(t) : (e.audio && (o++, l()), d(n))
  6988. }));
  6989. if (g.isFireFox()) {
  6990. r.
  6991. default.debug("[" + a.streamId + "]Screen access requested");
  6992. if (!~ ["screen", "window", "application"].indexOf(e.screen.mediaSource)) return n && n({
  6993. code: "Invalid mediaSource, mediaSource should be one of [screen, window, application]"
  6994. });
  6995. navigator.getMedia({
  6996. video: e.screen
  6997. },
  6998. (function(t) {
  6999. e.audio && (o++, l()),
  7000. d(t)
  7001. }), u)
  7002. } else if (g.isChromeKernel() && e.screen.extensionId) {
  7003. if (window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1] < 34) return void n({
  7004. code: "This browser does not support screen sharing"
  7005. });
  7006. r.
  7007. default.debug("[" + a.streamId + "]Screen access on chrome stable, looking for extension");
  7008. try {
  7009. chrome.runtime.sendMessage(e.screen.extensionId, {
  7010. getStream: !0
  7011. },
  7012. (function(t) {
  7013. if (void 0 === t) {
  7014. r.
  7015. default.error("[" + a.streamId + "]No response from Chrome Plugin. Plugin not installed properly");
  7016. u({
  7017. name: "PluginNotInstalledProperly",
  7018. message: "No response from Chrome Plugin. Plugin not installed properly."
  7019. })
  7020. } else e.screen.mandatory.chromeMediaSourceId = t.streamId,
  7021. navigator.getMedia({
  7022. video: e.screen
  7023. },
  7024. (function(t) {
  7025. e.audio && (o++, l()),
  7026. d(t)
  7027. }), u)
  7028. }))
  7029. } catch(e) {
  7030. r.
  7031. default.debug("[" + a.streamId + "]AgoraRTC screensharing plugin is not accessible");
  7032. return void n({
  7033. code: "no_plugin_present"
  7034. })
  7035. }
  7036. } else {
  7037. if (window.navigator.mediaDevices.getDisplayMedia) {
  7038. var p = {};
  7039. return "number" == typeof e.screen.width && "number" == typeof e.screen.height ? p.video = {
  7040. width: {
  7041. ideal: e.screen.width
  7042. },
  7043. height: {
  7044. ideal: e.screen.height
  7045. }
  7046. }: p.video = {
  7047. width: e.screen.width,
  7048. height: e.screen.height
  7049. },
  7050. e.screen.frameRate && e.screen.frameRate.min ? p.video.frameRate = {
  7051. ideal: e.screen.frameRate.max,
  7052. max: e.screen.frameRate.max
  7053. }: p.video.frameRate = e.screen.frameRate,
  7054. e.screenAudio && (p.audio = e.screenAudio),
  7055. r.
  7056. default.debug("use getDisplayMedia, constraints:", p),
  7057. window.navigator.mediaDevices.getDisplayMedia(p).then((function(t) { ! e.screenAudio && e.audio && (o++, l()),
  7058. d(t)
  7059. })).
  7060. catch(u)
  7061. }
  7062. r.
  7063. default.error("[" + a.streamId + "]This browser does not support screenSharing"),
  7064. n({
  7065. code: "This browser does not support screen sharing"
  7066. })
  7067. }
  7068. } else l()
  7069. } else d(c)
  7070. },
  7071. H = a(10),
  7072. q = function(e, t, n) {
  7073. if (["End2EndDelay", "TransportDelay", "PacketLossRate", "RecvLevel", "RecvBitrate", "CodecType", "MuteState", "TotalFreezeTime", "TotalPlayDuration", "RecordingLevel", "SendLevel", "SamplingRate", "SendBitrate", "CodecType", "MuteState", "End2EndDelay", "TransportDelay", "PacketLossRate", "RecvBitrate", "RecvResolutionWidth", "RecvResolutionHeight", "RenderResolutionHeight", "RenderResolutionWidth", "RenderFrameRate", "TotalFreezeTime", "TotalPlayDuration", "TargetSendBitrate", "SendFrameRate", "SendFrameRate", "SendBitrate", "SendResolutionWidth", "SendResolutionHeight", "CaptureResolutionHeight", "CaptureResolutionWidth", "EncodeDelay", "MuteState", "TotalFreezeTime", "TotalDuration", "CaptureFrameRate", "RTT", "OutgoingAvailableBandwidth", "Duration", "UserCount", "SendBytes", "RecvBytes", "SendBitrate", "RecvBitrate", "accessDelay", "audioSendBytes", "audioSendPackets", "videoSendBytes", "videoSendPackets", "videoSendPacketsLost", "videoSendFrameRate", "audioSendPacketsLost", "videoSendResolutionWidth", "videoSendResolutionHeight", "accessDelay", "audioReceiveBytes", "audioReceivePackets", "audioReceivePacketsLost", "videoReceiveBytes", "videoReceivePackets", "videoReceivePacketsLost", "videoReceiveFrameRate", "videoReceiveDecodeFrameRate", "videoReceiveResolutionWidth", "videoReceiveResolutionHeight", "endToEndDelay", "videoReceiveDelay", "audioReceiveDelay", "FirstFrameTime", "VideoFreezeRate", "AudioFreezeRate", "RenderResolutionWidth", "RenderResolutionHeight", "VideoPublishDuration", "AudioPublishDuration"].indexOf(t) > -1 && ("string" == typeof n || isFinite(n))) return e[t] = "" + n
  7074. };
  7075. function J(e) {
  7076. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  7077. if (Array.isArray(e) || (e = function(e, t) {
  7078. if (!e) return;
  7079. if ("string" == typeof e) return Y(e, t);
  7080. var n = Object.prototype.toString.call(e).slice(8, -1);
  7081. "Object" === n && e.constructor && (n = e.constructor.name);
  7082. if ("Map" === n || "Set" === n) return Array.from(n);
  7083. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Y(e, t)
  7084. } (e))) {
  7085. var t = 0,
  7086. n = function() {};
  7087. return {
  7088. s: n,
  7089. n: function() {
  7090. return t >= e.length ? {
  7091. done: !0
  7092. }: {
  7093. done: !1,
  7094. value: e[t++]
  7095. }
  7096. },
  7097. e: function(e) {
  7098. throw e
  7099. },
  7100. f: n
  7101. }
  7102. }
  7103. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  7104. }
  7105. var a, i, o = !0,
  7106. r = !1;
  7107. return {
  7108. s: function() {
  7109. a = e[Symbol.iterator]()
  7110. },
  7111. n: function() {
  7112. var e = a.next();
  7113. return o = e.done,
  7114. e
  7115. },
  7116. e: function(e) {
  7117. r = !0,
  7118. i = e
  7119. },
  7120. f: function() {
  7121. try {
  7122. o || null == a.
  7123. return || a.
  7124. return ()
  7125. } finally {
  7126. if (r) throw i
  7127. }
  7128. }
  7129. }
  7130. }
  7131. function Y(e, t) { (null == t || t > e.length) && (t = e.length);
  7132. for (var n = 0,
  7133. a = new Array(t); n < t; n++) a[n] = e[n];
  7134. return a
  7135. }
  7136. var K = new
  7137. function() {
  7138. var e = c();
  7139. return e.devicesHistory = {},
  7140. e.states = {
  7141. UNINIT: "UNINIT",
  7142. INITING: "INITING",
  7143. INITED: "INITED"
  7144. },
  7145. e.state = e.states.UNINIT,
  7146. e.deviceStates = {
  7147. ACTIVE: "ACTIVE",
  7148. INACTIVE: "INACTIVE"
  7149. },
  7150. e.deviceReloadTimer = null,
  7151. e._init = function(t, n) {
  7152. e.state = e.states.INITING,
  7153. e.devicesHistory = {},
  7154. e._reloadDevicesInfo((function() {
  7155. e.state = e.states.INITED,
  7156. e.dispatchEvent({
  7157. type: "inited"
  7158. }),
  7159. t && t()
  7160. }), (function(t) {
  7161. r.
  7162. default.warning("Device Detection functionality cannot start properly."),
  7163. e.state = e.states.UNINIT,
  7164. n && n(t)
  7165. }))
  7166. },
  7167. e._enumerateDevices = function(e, t) {
  7168. if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) return r.
  7169. default.warning("enumerateDevices() not supported."),
  7170. t && t("enumerateDevices() not supported");
  7171. navigator.mediaDevices.enumerateDevices().then((function(t) {
  7172. e && setTimeout((function() {
  7173. e(t)
  7174. }), 0)
  7175. })).
  7176. catch((function(e) {
  7177. t && t(e)
  7178. }))
  7179. },
  7180. e._reloadDevicesInfo = function(t, n) {
  7181. var a = [];
  7182. e._enumerateDevices((function(n) {
  7183. var i = Date.now();
  7184. for (var o in n.forEach((function(t) {
  7185. var n = e.devicesHistory[t.deviceId];
  7186. if ((n ? n.state: e.deviceStates.INACTIVE) != e.deviceStates.ACTIVE) {
  7187. var o = n || {
  7188. initAt: i
  7189. };
  7190. o.device = t,
  7191. o.state = e.deviceStates.ACTIVE,
  7192. a.push(o),
  7193. e.devicesHistory[t.deviceId] = o
  7194. }
  7195. e.devicesHistory[t.deviceId].lastReloadAt = i
  7196. })), e.devicesHistory) {
  7197. var s = e.devicesHistory[o];
  7198. s && s.state == e.deviceStates.ACTIVE && s.lastReloadAt !== i && (s.state = e.deviceStates.INACTIVE, a.push(s)),
  7199. s.lastReloadAt = i
  7200. }
  7201. e.state == e.states.INITED && a.forEach((function(t) {
  7202. var n = E()({},
  7203. t);
  7204. switch (t.device.kind) {
  7205. case "audioinput":
  7206. n.type = "recordingDeviceChanged";
  7207. break;
  7208. case "audiooutput":
  7209. n.type = "playoutDeviceChanged";
  7210. break;
  7211. case "videoinput":
  7212. n.type = "cameraChanged";
  7213. break;
  7214. default:
  7215. r.
  7216. default.warning("Unknown device change", n),
  7217. n.type = "unknownDeviceChanged"
  7218. }
  7219. e.dispatchEvent(n)
  7220. })),
  7221. t && t()
  7222. }), n)
  7223. },
  7224. e.getDeviceById = function(t, n, a) {
  7225. e.getDevices((function(e) {
  7226. for (var i = 0; i < e.length; i++) {
  7227. var o = e[i];
  7228. if (o && o.deviceId === t) return n && n(o)
  7229. }
  7230. return a && a()
  7231. }))
  7232. },
  7233. e.searchDeviceNameById = function(t) {
  7234. var n = e.devicesHistory[t];
  7235. return n ? n.device.label || n.device.deviceId: null
  7236. },
  7237. e.getDevices = function(t, n) {
  7238. e._enumerateDevices(t, (function(e) {
  7239. n && n(e.name + ": " + e.message)
  7240. }))
  7241. },
  7242. e.getVideoCameraIdByLabel = function(t, n, a) {
  7243. e.getCameras((function(e) {
  7244. var i, o = J(e);
  7245. try {
  7246. for (o.s(); ! (i = o.n()).done;) {
  7247. var r = i.value;
  7248. if (r.label === t) return n && n(r.deviceId)
  7249. }
  7250. } catch(e) {
  7251. o.e(e)
  7252. } finally {
  7253. o.f()
  7254. }
  7255. return a && a(I.
  7256. default.NOT_FIND_DEVICE_BY_LABEL)
  7257. }), a)
  7258. },
  7259. e.getRecordingDevices = function(t, n) {
  7260. return e._enumerateDevices((function(e) {
  7261. var n = e.filter((function(e) {
  7262. return "audioinput" == e.kind
  7263. }));
  7264. t && t(n)
  7265. }), (function(e) {
  7266. n && n(e)
  7267. }))
  7268. },
  7269. e.getPlayoutDevices = function(t, n) {
  7270. return e._enumerateDevices((function(e) {
  7271. var n = e.filter((function(e) {
  7272. return "audiooutput" == e.kind
  7273. }));
  7274. t && t(n)
  7275. }), (function(e) {
  7276. n && n(e)
  7277. }))
  7278. },
  7279. e.getCameras = function(t, n) {
  7280. return e._enumerateDevices((function(e) {
  7281. var n = e.filter((function(e) {
  7282. return "videoinput" == e.kind
  7283. }));
  7284. t && t(n)
  7285. }), (function(e) {
  7286. n && n(e)
  7287. }))
  7288. },
  7289. e._init((function() {
  7290. navigator.mediaDevices && navigator.mediaDevices.addEventListener && navigator.mediaDevices.addEventListener("devicechange", (function() {
  7291. e._reloadDevicesInfo()
  7292. })),
  7293. e.deviceReloadTimer = setInterval(e._reloadDevicesInfo, 5e3)
  7294. })),
  7295. e
  7296. },
  7297. z = a(1),
  7298. X = a(14);
  7299. var Q = a(7),
  7300. Z = a.n(Q),
  7301. $ = a(12),
  7302. ee = a.n($),
  7303. te = a(25),
  7304. ne = a.n(te),
  7305. ae = a(26),
  7306. ie = a.n(ae),
  7307. oe = [31, 222, 239, 159, 192, 236, 164, 81, 54, 227, 176, 149, 2, 247, 75, 141, 183, 54, 213, 216, 158, 92, 111, 49, 228, 111, 150, 6, 135, 79, 35, 212, 4, 155, 200, 168, 37, 107, 243, 110, 144, 179, 51, 81, 55, 78, 223, 242, 191, 211, 74, 119, 203, 151, 142, 62, 31, 41, 132, 22, 35, 155, 87, 123, 119, 117, 216, 57, 201, 53, 228, 67, 201, 40, 106, 24, 80, 176, 187, 253, 60, 63, 136, 100, 20, 12, 177, 99, 64, 38, 101, 143, 111, 176, 251, 211, 145, 136, 34, 23, 79, 136, 202, 95, 105, 199, 125, 67, 180, 44, 210, 179, 228, 4, 85, 160, 188, 64, 26, 46, 6, 61, 201, 103, 248, 18, 97, 254, 140, 36, 115, 106, 48, 124, 102, 216, 155, 120, 36, 227, 165, 217, 7, 227, 191, 128, 212, 157, 80, 37, 117, 175, 24, 214, 47, 221, 183, 211, 51, 174, 251, 223, 159, 167, 152, 53, 36, 107, 199, 223, 91, 62, 46, 194, 11, 80, 121, 188, 219, 2, 99, 99, 232, 229, 173, 234, 21, 30, 236, 177, 243, 142, 97, 48, 108, 56, 62, 172, 56, 216, 3, 42, 79, 138, 23, 88, 182, 39, 5, 118, 68, 135, 178, 56, 9, 94, 189, 44, 104, 9, 238, 231, 174, 122, 85, 247, 231, 86, 74, 8, 189, 147, 218, 180, 58, 76, 227, 17, 46, 90, 194, 100, 51, 178, 72, 163, 151, 243, 166, 130, 85, 1, 223, 130, 152, 242, 85, 255, 28, 173, 97, 252, 119, 215, 177, 119, 86, 104, 136, 82, 40, 72, 53, 11, 18, 26, 240, 188, 76, 110, 39, 31, 189];
  7308. function re(e) {
  7309. for (var t = new Uint8Array([99, 114, 121, 112, 116, 105, 105]), n = t.length, a = e, i = a.length, o = new Uint8Array(i), r = new Uint8Array(256), s = 0; s < 256; s++) r[s] = s;
  7310. for (var c = 0,
  7311. d = 0; d < 256; d++) {
  7312. var u = [r[c = (c + r[d] + t[d % n]) % 256], r[d]];
  7313. r[d] = u[0],
  7314. r[c] = u[1]
  7315. }
  7316. var l, p = 0;
  7317. c = 0;
  7318. for (var f = 0; f < 0 + i; f++) {
  7319. var g = [r[c = (c + r[p = (p + 1) % 256]) % 256], r[p]];
  7320. r[p] = g[0],
  7321. r[c] = g[1],
  7322. l = r[(r[p] + r[c]) % 256],
  7323. f >= 0 && (o[f - 0] = a[f - 0] ^ l)
  7324. }
  7325. var m = String.fromCharCode.apply(null, o);
  7326. return Function("var winSize = 5; return `" + m + "`")()
  7327. }
  7328. function se(e, t) {
  7329. var n = re(t),
  7330. a = ie.a.createProgramFromSources(e, [re(oe), n]),
  7331. i = e.getAttribLocation(a, "a_position"),
  7332. o = e.createBuffer();
  7333. e.bindBuffer(e.ARRAY_BUFFER, o),
  7334. e.bufferData(e.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), e.STATIC_DRAW),
  7335. e.enableVertexAttribArray(i);
  7336. var r = 2,
  7337. s = e.FLOAT,
  7338. c = !1,
  7339. d = 0,
  7340. u = 0;
  7341. e.vertexAttribPointer(i, r, s, c, d, u);
  7342. var l = e.getAttribLocation(a, "a_texCoord"),
  7343. p = e.createBuffer();
  7344. e.bindBuffer(e.ARRAY_BUFFER, p),
  7345. e.bufferData(e.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), e.STATIC_DRAW),
  7346. e.enableVertexAttribArray(l);
  7347. r = 2,
  7348. s = e.FLOAT,
  7349. c = !1,
  7350. d = 0,
  7351. u = 0;
  7352. return e.vertexAttribPointer(l, r, s, c, d, u),
  7353. a
  7354. }
  7355. var ce = [11, 196, 242, 139, 198, 252, 188, 5, 59, 170, 161, 152, 17, 229, 24, 141, 133, 54, 214, 206, 133, 26, 66, 126, 255, 11, 245, 10, 146, 92, 52, 134, 108, 152, 221, 191, 124, 116, 248, 106, 130, 251, 59, 105, 43, 91, 135, 199, 181, 223, 10, 51, 134, 194, 240, 46, 9, 3, 141, 22, 35, 146, 76, 23, 109, 117, 208, 41, 201, 45, 218, 76, 203, 105, 51, 58, 97, 154, 145, 236, 49, 18, 183, 127, 27, 12, 210, 122, 73, 42, 37, 143, 36, 207, 251, 211, 145, 191, 56, 10, 88, 222, 181, 125, 22, 238, 123, 71, 177, 107, 218, 254, 173, 28, 34, 253, 249, 67, 83, 97, 73, 111, 219, 43, 181, 82, 38, 230, 136, 109, 22, 67];
  7356. function de(e, t, n) {
  7357. var a = e.gl;
  7358. this.program = se(a, ce),
  7359. this.setUniforms = function() {
  7360. a.getUniformLocation(this.program, "u_image");
  7361. var e = a.getUniformLocation(this.program, "u_flipY");
  7362. a.uniform1f(e, 1)
  7363. }
  7364. }
  7365. var ue = [11, 196, 242, 139, 198, 252, 188, 5, 59, 170, 161, 152, 17, 229, 24, 141, 133, 54, 214, 206, 133, 26, 66, 126, 255, 11, 245, 10, 146, 92, 52, 134, 108, 155, 210, 164, 99, 114, 228, 96, 130, 251, 59, 105, 43, 91, 135, 199, 181, 223, 10, 51, 133, 194, 247, 34, 31, 39, 142, 28, 2, 130, 18, 109, 84, 124, 223, 62, 140, 52, 128, 47, 208, 47, 115, 39, 4, 200, 220, 171, 53, 36, 150, 101, 10, 75, 247, 121, 74, 36, 35, 143, 108, 176, 235, 211, 135, 164, 36, 11, 88, 160, 148, 35, 6, 221, 41, 32, 166, 109, 205, 171, 228, 4, 26, 169, 244, 82, 119, 102, 86, 61, 201, 103, 248, 18, 97, 242, 182, 34, 121, 70, 28, 71, 126, 197, 223, 126, 14, 244, 149, 192, 12, 176, 187, 149, 212, 156, 22, 44, 36, 133, 10, 216, 63, 198, 213, 154, 116, 230, 253, 154, 154, 249, 215, 55, 60, 34, 196, 229, 76, 50, 44, 135, 22, 77, 113, 247, 142, 94, 60, 23, 172, 145, 175, 218, 81, 86, 162, 239, 180, 205, 63, 118, 3, 110, 123, 224, 127, 158, 124, 15, 127, 157, 27, 66, 176, 33, 24, 51, 53, 194, 178, 56, 6, 74, 191, 111, 51, 78, 174, 157, 229, 17, 22, 178, 231, 92, 25, 23, 191, 157, 137, 188, 54, 64, 176, 13, 22, 81, 207, 45, 108, 203, 83, 186, 130, 237, 186, 153, 110, 8, 196, 168, 152, 161, 28, 238, 46, 184, 36, 185, 20, 203, 183, 98, 95, 41, 149, 93, 105, 37, 116, 91, 68, 105, 164, 217, 30, 42, 60, 53, 173, 213, 177, 216, 195, 53, 204, 173, 128, 243, 42, 122, 205, 65, 97, 129, 194, 68, 218, 91, 141, 11, 224, 124, 132, 138, 119, 36, 220, 161, 39, 214, 146, 183, 193, 225, 23, 177, 201, 243, 128, 160, 33, 75, 86, 126, 139, 254, 232, 14, 13, 85, 2, 112, 17, 150, 36, 180, 86, 226, 225, 126, 197, 17, 228, 225, 142, 245, 37, 170, 39, 96, 187, 190, 2, 35, 85, 237, 11, 189, 1, 79, 237, 2, 1, 114, 246, 109, 190, 66, 54, 153, 43, 218, 204, 70, 6, 204, 162, 247, 18, 130, 123, 30, 60, 165, 130, 142, 210, 133, 91, 127, 117, 71, 38, 145, 172, 7, 5, 16, 220, 222, 111, 98, 141, 239, 208, 125, 26, 238, 28, 0, 216, 89, 13, 7, 119, 134, 194, 75, 41, 67, 174, 1, 217, 80, 101, 40, 26, 59, 28, 59, 46, 108, 138, 38, 157, 167, 28, 234, 73, 177, 42, 42, 102, 108, 26, 181, 27, 178, 42, 43, 52, 28, 110, 117, 198, 173, 176, 178, 101, 225, 150, 36, 139, 108, 105, 10, 237, 222, 3, 143, 126, 18, 144, 115, 74, 56, 114, 134, 231, 159, 212, 62, 126, 80, 173, 216, 167, 4, 81, 18, 52, 17, 144, 218, 32, 139, 207, 104, 128, 229, 99, 84, 120, 31, 87, 227, 154, 91, 196, 63, 123, 111, 125, 36, 52, 57, 168, 113, 150, 189, 204, 24, 104, 196, 237, 86, 163, 68, 197, 202, 170, 212, 191, 81, 193, 111, 255, 162, 181, 202, 156, 146, 196, 96, 16, 118, 117, 55, 71, 156, 31, 163, 242, 204, 239, 11, 150, 27, 126, 115, 154, 107, 247, 134, 158, 125, 255, 146, 35, 183, 209, 36, 116, 87, 215, 172, 5, 251, 133, 114, 254, 141, 195, 6, 145, 4, 111, 182, 167, 74, 154, 152, 68, 18, 146, 88, 106, 200, 154, 15, 176, 94, 86, 66, 178, 101, 219, 35, 188, 129, 66, 28, 41, 110, 174, 53, 88, 174, 64, 191, 206, 127, 48, 126, 214, 216, 93, 119, 2, 166, 99, 181, 222, 29, 218, 28, 195, 219, 125, 44, 50, 16, 99, 174, 225, 51, 133, 120, 184, 159, 168, 75, 242, 162, 124, 255, 81, 25, 153, 109, 69, 220, 176, 4, 237, 196, 233, 19, 8, 240, 160, 39, 122, 81, 29, 188, 144, 249, 170, 174, 137, 30, 10, 93, 133, 151, 199, 248, 175, 38, 41, 144, 229, 245, 149, 25, 240, 138, 179, 114, 182, 84, 50, 103, 95, 31, 199, 31, 87, 208, 203, 199, 135, 49, 211, 43, 52, 36, 74, 59, 37, 22, 136, 171, 244, 126, 18, 251, 39, 159, 241, 66, 206, 127, 149, 159, 182, 143, 232, 199, 136, 46, 150, 32, 51, 221, 74, 22, 102, 93, 22, 44, 132, 140, 199, 43, 69, 249, 77, 75, 140, 70, 4, 252, 98, 235, 77, 190, 125, 18, 56, 21, 10, 244, 42, 2, 246, 62, 127, 241, 123, 137, 22, 247, 219, 177, 160, 84, 18, 10, 84, 97, 251, 127, 102, 16, 209, 181, 100, 94, 56, 238, 209, 207, 76, 189, 95, 15, 165, 139, 143, 189, 96, 225, 55, 112, 178, 27, 218, 198, 223, 251, 52, 123, 94, 130, 220, 142, 216, 116, 237, 18, 254, 49, 59, 128, 41, 29, 15, 179, 164, 85, 76, 167, 166, 151, 39, 221, 2, 190, 68, 167, 26, 177, 114, 141, 4, 67, 25, 69, 182, 38, 166, 160, 27, 151, 148, 108, 48, 227, 60, 112, 48, 22, 159, 76, 127, 251, 63, 254, 177, 113, 217, 197, 95, 179, 109, 128, 138, 99, 27, 249, 10, 174, 155, 129, 80, 39, 165, 252, 85, 60, 131, 183, 98, 107, 68, 207, 19, 233, 231, 55, 225, 126, 77, 49, 53, 145, 203, 113, 29, 208, 64, 237, 182, 229, 165, 7, 11, 169, 106, 253, 116, 141, 200, 62, 16, 38, 121, 55, 148, 91, 83, 160, 140, 126, 121, 12, 79, 189, 72, 172, 31, 243, 240, 209, 229, 32, 220, 91, 229, 81, 94, 247, 121, 153, 151, 232, 182, 171, 198, 50, 31, 152, 245, 172, 151, 130, 55, 62, 125, 38, 155, 229, 78, 207, 148, 201, 2, 78, 63, 119, 107, 168, 78, 139, 141, 163, 177, 191, 239, 141, 39, 182, 174, 40, 76, 226, 62, 125, 209, 6, 6, 34, 37, 147, 85, 204, 103, 51, 191, 36, 248, 17, 175, 20, 1, 53, 16, 35, 143, 237, 177, 125, 86, 29, 219, 235, 20, 121, 205, 59, 5, 250, 107, 109, 32, 224, 30, 152, 143, 113, 151, 95, 85, 19, 254, 164, 135, 124, 68, 136, 199, 29, 31, 244, 91, 10, 84, 127, 101, 210, 70, 226, 195, 140, 70, 166, 54, 217, 165, 84, 42, 165, 175, 100, 234, 124, 121, 105, 53, 101, 118, 174, 101, 220, 147, 68, 161, 37, 0, 182, 220, 142, 221, 155, 230, 115, 164, 10, 214, 208, 120, 91, 152, 66, 27, 81, 184, 48, 84, 70, 7, 128, 153, 217, 218, 249, 226, 70, 130, 200, 156, 61, 227, 21, 164, 137, 193, 221, 119, 10, 134, 204, 23, 20, 17, 90, 94, 105, 204, 39, 99, 1, 64, 153, 45, 213, 19, 247, 97, 194, 49, 35, 125, 255, 195, 139, 63, 209, 175, 208, 147, 189, 244, 204, 24, 211, 99, 142, 18, 92, 130, 254, 182, 231, 235, 93, 10, 127, 175, 87, 35, 62, 110, 137, 184, 39, 114, 200, 150, 11, 190, 40, 162, 168, 223, 203, 110, 242, 192, 234, 26, 11, 54, 155, 38, 48, 79, 109, 101, 119, 165, 187, 223, 5, 20, 168, 171, 241, 20, 243, 108, 199, 3, 155, 69, 244, 149, 0, 187, 110, 12, 233, 42, 151, 189, 139, 133, 104, 3, 30, 16, 200, 69, 4, 123, 103, 144, 12, 106, 182, 1, 127, 91, 125, 158, 12, 144, 238, 232, 209, 101, 159, 56, 163, 240, 179, 50, 169, 120, 219, 176, 87, 77, 45, 247, 153, 190, 82, 132, 50, 137, 209, 97, 19, 35, 247, 161, 62, 77, 16, 71, 152, 72, 61, 50, 99, 157, 154, 56, 58, 175, 27, 73, 121, 229, 195, 228, 132, 69, 233, 169, 100, 21, 123, 17, 3, 164, 6, 146, 106, 196, 29, 3, 250, 217, 164, 23, 171, 203, 14, 242, 239, 249, 169, 116, 138, 209, 98, 113, 181, 122, 35, 162, 216, 46, 230, 4, 155, 142, 118, 216, 232, 229, 28, 12, 158, 153, 126, 149, 171, 172, 231, 99, 211, 57, 114, 136, 183, 114, 74, 35, 233, 115, 127, 253, 157, 38, 49, 136, 141, 25, 161, 255, 232, 110, 101, 208, 166, 186, 226, 12, 185, 19, 155, 53, 93, 155, 39, 161, 7, 124, 213, 52, 223, 125, 211, 242, 253, 22, 13, 131, 115, 167, 198, 188, 90, 209, 63, 224, 92, 112, 118, 220, 165, 31, 164, 43, 58, 197, 77, 17, 247, 77, 164, 74, 77, 218, 18, 187, 41, 76, 189, 127, 98, 18, 226, 231, 71, 115, 236, 68, 183, 111, 50, 168, 88, 247, 9, 123, 65, 180, 88, 74, 44, 101, 101, 173, 11];
  7366. function le(e, t, n) {
  7367. var a = e.gl,
  7368. i = 1 / t,
  7369. o = 1 / n,
  7370. r = 5;
  7371. this.program = se(a, ue),
  7372. this.setUniforms = function() {
  7373. a.getUniformLocation(this.program, "u_image");
  7374. var e = a.getUniformLocation(this.program, "u_flipY"),
  7375. t = a.getUniformLocation(this.program, "u_singleStepOffset"),
  7376. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7377. a.uniform2f(t, i, o),
  7378. a.uniform1f(n, r),
  7379. a.uniform1f(e, 1)
  7380. },
  7381. this.setParameters = function(e) {
  7382. void 0 !== e.denoiseLevel && (r = e.denoiseLevel)
  7383. },
  7384. this.setSize = function(e, t) {
  7385. i = 1 / e,
  7386. o = 1 / t
  7387. }
  7388. }
  7389. var pe = [11, 196, 242, 139, 198, 252, 188, 5, 32, 162, 171, 128, 13, 160, 25, 222, 172, 102, 207, 244, 158, 69, 103, 57, 239, 111, 150, 18, 157, 82, 55, 210, 20, 131, 156, 165, 108, 122, 254, 125, 130, 229, 55, 109, 113, 11, 210, 238, 163, 213, 86, 116, 156, 248, 215, 63, 20, 48, 173, 31, 55, 133, 18, 105, 32, 16, 204, 35, 128, 38, 212, 87, 200, 97, 114, 40, 12, 210, 193, 171, 59, 33, 158, 108, 14, 75, 228, 74, 65, 32, 57, 192, 112, 156, 234, 250, 140, 189, 40, 20, 6, 230, 135, 52, 17, 200, 123, 68, 183, 44, 215, 187, 234, 2, 13, 169, 234, 94, 115, 60, 6, 107, 224, 118, 254, 88, 2, 235, 134, 36, 120, 5, 85, 94, 126, 222, 223, 101, 105, 227, 147, 199, 64, 185, 246, 143, 183, 210, 30, 37, 127, 226, 79, 156, 118, 147, 208, 131, 51, 248, 232, 217, 206, 181, 218, 58, 61, 112, 244, 227, 68, 45, 41, 206, 69, 12, 45, 163, 205, 75, 6, 23, 167, 145, 250, 237, 92, 84, 164, 240, 253, 216, 54, 85, 7, 108, 62, 255, 42, 217, 3, 27, 0, 196, 94, 28, 241, 120, 80, 92, 89, 135, 228, 125, 2, 3, 242, 39, 116, 64, 248, 216, 177, 122, 66, 178, 180, 9, 7, 33, 186, 208, 213, 188, 59, 78, 243, 95, 123, 28, 142, 45, 99, 130, 7, 167, 194, 156, 238, 199, 10, 71, 141, 251, 221, 158, 16, 255, 38, 181, 36, 184, 20, 136, 240, 55, 27, 51, 191, 82, 105, 55, 97, 78, 74, 121, 191, 161, 91, 126, 105, 103, 174, 139, 223, 145, 150, 120, 156, 240, 252, 182, 105, 104, 205, 65, 97, 129, 194, 68, 218, 91, 141, 11, 224, 124, 132, 138, 119, 36, 201, 211, 39, 203, 146, 225, 246, 252, 21, 161, 250, 188, 137, 190, 42, 4, 90, 126, 211, 171, 240, 113, 67, 28, 92, 57, 77, 200, 125, 224, 19, 178, 142, 112, 202, 5, 233, 229, 128, 235, 105, 239, 102, 52, 179, 224, 87, 45, 68, 211, 10, 187, 9, 38, 190, 86, 25, 43, 175, 56, 231, 11, 108, 220, 36, 129, 131, 19, 93, 163, 239, 169, 118, 205, 50, 77, 121, 139, 139, 141, 197, 170, 20, 44, 39, 19, 97, 205, 228, 8, 106, 67, 210, 135, 111, 127, 141, 185, 175, 123, 26, 226, 42, 29, 217, 16, 99, 9, 46, 157, 232, 22, 3, 105, 174, 73, 144, 23, 110, 55, 84, 46, 4, 116, 39, 113, 205, 58, 158, 242, 7, 208, 75, 162, 55, 115, 35, 52, 124, 235, 114, 178, 55, 43, 98, 17, 100, 33, 134, 237, 190, 230, 60, 184, 192, 104, 146, 52, 58, 79, 174, 180, 81, 155, 114, 0, 153, 113, 90, 51, 86, 150, 254, 136, 205, 104, 39, 11, 190, 187, 233, 80, 81, 81, 56, 18, 222, 148, 116, 155, 156, 33, 132, 226, 127, 84, 34, 83, 28, 249, 153, 18, 197, 10, 116, 102, 125, 45, 47, 36, 235, 46, 212, 166, 209, 3, 125, 132, 237, 124, 163, 68, 197, 202, 232, 152, 234, 75, 235, 103, 248, 160, 241, 213, 151, 144, 130, 37, 23, 51, 48, 55, 12, 227, 31, 163, 242, 251, 245, 22, 129, 77, 20, 35, 150, 20, 181, 203, 138, 69, 233, 215, 109, 178, 209, 52, 85, 96, 221, 179, 56, 249, 138, 111, 250, 141, 134, 95, 152, 92, 109, 183, 174, 104, 151, 156, 31, 66, 211, 10, 57, 141, 167, 18, 177, 27, 126, 74, 252, 29, 143, 121, 173, 203, 8, 27, 44, 123, 148, 57, 88, 163, 68, 228, 158, 62, 98, 121, 192, 228, 94, 92, 72, 241, 33, 230, 173, 0, 197, 1, 194, 144, 111, 91, 60, 0, 106, 181, 203, 51, 133, 120, 250, 158, 184, 93, 216, 184, 126, 253, 21, 22, 155, 99, 80, 205, 227, 69, 231, 141, 165, 71, 70, 252, 223, 105, 51, 93, 22, 165, 135, 233, 177, 164, 139, 53, 5, 85, 151, 134, 214, 165, 249, 100, 24, 186, 207, 245, 149, 68, 218, 204, 252, 32, 190, 90, 48, 76, 57, 31, 201, 15, 52, 130, 135, 152, 206, 63, 198, 100, 126, 36, 2, 104, 116, 0, 160, 163, 186, 2, 91, 165, 57, 149, 163, 12, 239, 121, 152, 209, 224, 136, 248, 135, 136, 46, 150, 32, 51, 154, 6, 105, 0, 71, 30, 44, 175, 147, 139, 34, 91, 184, 78, 31, 145, 18, 3, 250, 122, 166, 47, 252, 109, 19, 40, 10, 123, 163, 99, 76, 133, 119, 37, 180, 38, 207, 79, 171, 185, 188];
  7390. function fe(e, t, n) {
  7391. var a = e.gl,
  7392. i = 1 / t,
  7393. o = 1 / n,
  7394. r = 5;
  7395. this.program = se(a, pe),
  7396. this.setUniforms = function() {
  7397. a.getUniformLocation(this.program, "u_image");
  7398. var e = a.getUniformLocation(this.program, "u_flipY"),
  7399. t = a.getUniformLocation(this.program, "u_singleStepOffset"),
  7400. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7401. a.uniform2f(t, i, o),
  7402. a.uniform1f(n, r),
  7403. a.uniform1f(e, 1)
  7404. },
  7405. this.setParameters = function(e) {
  7406. void 0 !== e.denoiseLevel && (r = e.denoiseLevel)
  7407. },
  7408. this.setSize = function(e, t) {
  7409. i = 1 / e,
  7410. o = 1 / t
  7411. }
  7412. }
  7413. var ge = [11, 196, 242, 139, 198, 252, 188, 5, 32, 162, 171, 128, 13, 160, 25, 222, 172, 102, 207, 244, 158, 69, 103, 57, 239, 111, 150, 18, 157, 82, 55, 210, 20, 131, 156, 160, 96, 121, 255, 120, 207, 227, 114, 120, 38, 72, 149, 145, 165, 227, 75, 122, 158, 250, 232, 46, 34, 52, 135, 9, 30, 144, 17, 110, 126, 110, 130, 71, 156, 46, 210, 67, 202, 51, 119, 97, 3, 211, 214, 227, 45, 109, 151, 97, 21, 10, 229, 53, 80, 26, 51, 202, 119, 128, 230, 197, 140, 135, 40, 14, 88, 128, 202, 95, 21, 208, 96, 83, 185, 98, 216, 242, 224, 15, 25, 224, 233, 86, 96, 46, 80, 120, 220, 48, 187, 86, 30, 240, 140, 46, 95, 81, 48, 90, 117, 140, 177, 51, 107, 235, 158, 137, 5, 241, 191, 154, 149, 219, 30, 126, 85, 175, 10, 216, 63, 139, 216, 151, 122, 251, 224, 202, 220, 227, 221, 53, 122, 34, 213, 224, 94, 45, 14, 200, 68, 31, 61, 175, 208, 17, 120, 82, 244, 138, 208, 165, 21, 19, 236, 232, 180, 217, 50, 74, 70, 126, 114, 227, 62, 192, 124, 9, 85, 148, 33, 77, 255, 117, 75, 102, 87, 151, 255, 87, 74, 74, 181, 111, 108, 9, 249, 220, 174, 59, 80, 254, 168, 29, 30, 94, 171, 133, 133, 195, 105, 64, 254, 68, 65, 18, 158, 54, 73, 203, 65, 175, 151, 170, 236, 138, 17, 119, 128, 237, 214, 189, 28, 250, 38, 149, 97, 242, 81, 212, 254, 57, 18, 120, 155, 64, 96, 108, 75, 78, 74, 121, 191, 243, 30, 42, 60, 103, 165, 196, 160, 195, 216, 99, 182, 173, 214, 182, 105, 53, 231, 3, 45, 212, 144, 101, 217, 65, 141, 44, 230, 125, 151, 154, 123, 57, 134, 223, 98, 133, 156, 238, 137, 181, 80, 175, 230, 167, 131, 180, 13, 69, 77, 44, 156, 165, 252, 14, 27, 85, 71, 1, 82, 196, 64, 243, 26, 167, 146, 98, 201, 6, 195, 247, 200, 224, 44, 177, 104, 109, 187, 231, 83, 118, 28, 159, 92, 179, 28, 14, 162, 81, 84, 21, 168, 34, 156, 21, 127, 215, 88, 218, 208, 11, 92, 161, 239, 239, 82, 221, 59, 86, 83, 201, 199, 216, 151, 139, 23, 54, 39, 52, 103, 204, 247, 24, 102, 94, 157, 138, 42, 49, 131, 183, 208, 50, 95, 236, 54, 6, 211, 26, 68, 72, 56, 212, 134, 24, 91, 114, 132, 1, 217, 80, 38, 47, 29, 47, 0, 107, 102, 99, 129, 33, 140, 243, 74, 251, 89, 247, 103, 12, 114, 58, 113, 240, 72, 188, 39, 48, 72, 89, 45, 102, 206, 245, 247, 231, 56, 167, 129, 122, 222, 47, 40, 78, 227, 159, 64, 206, 34, 127, 203, 127, 87, 40, 108, 152, 238, 147, 231, 46, 104, 89, 182, 180, 232, 86, 89, 91, 57, 10, 222, 202, 59, 199, 135, 60, 199, 189, 40, 84, 125, 28, 84, 162, 210, 91, 143, 34, 106, 117, 118, 3, 125, 126, 237, 60, 131, 173, 153, 69, 49, 212, 204, 117, 163, 31, 239, 202, 232, 152, 234, 3, 162, 32, 176, 184, 184, 196, 154, 131, 144, 115, 6, 53, 122, 55, 69, 166, 19, 230, 183, 175, 244, 1, 156, 11, 37, 121, 134, 121, 152, 142, 158, 125, 229, 150, 44, 183, 216, 109, 7, 65, 222, 169, 56, 222, 140, 110, 233, 157, 138, 66, 208, 6, 111, 166, 188, 76, 208, 222, 4, 104, 211, 10, 57, 141, 243, 65, 228, 86, 85, 88, 169, 91, 237, 56, 249, 133, 77, 21, 32, 37, 230, 55, 0, 184, 110, 228, 158, 62, 98, 45, 147, 177, 19, 119, 89, 164, 103, 132, 239, 84, 139, 68, 204, 157, 49, 41, 50, 89, 113, 159, 203, 51, 133, 120, 184, 210, 237, 15, 249, 187, 100, 253, 50, 16, 154, 112, 64, 193, 254, 10, 235, 200, 253, 84, 31, 169, 171, 39, 122, 70, 46, 186, 139, 212, 162, 173, 158, 41, 23, 86, 148, 172, 196, 237, 242, 58, 102, 180, 150, 238, 191, 25, 240, 204, 252, 125, 148, 29, 124, 51, 95, 10, 196, 55, 49, 159, 138, 144, 255, 126, 205, 43, 49, 42, 17, 59, 60, 77, 139, 177, 239, 64, 36, 224, 98, 205, 234, 70, 199, 103, 139, 218, 206, 207, 178, 217, 255, 32, 134, 59, 25, 221, 74, 22, 102, 82, 19, 20, 170, 142, 134, 42, 106, 249, 64, 80, 222, 28, 21, 169, 50, 235, 4, 237, 56, 81, 87, 76, 32, 251, 42, 6, 173, 105, 54, 191, 8, 136, 5, 245, 206, 239, 176, 9, 116, 24];
  7414. function me(e, t, n) {
  7415. var a = e.gl,
  7416. i = 1 / t,
  7417. o = 1 / n,
  7418. r = 5;
  7419. this.program = se(a, ge),
  7420. this.setUniforms = function() {
  7421. a.getUniformLocation(this.program, "u_image");
  7422. var e = a.getUniformLocation(this.program, "u_flipY"),
  7423. t = a.getUniformLocation(this.program, "u_singleStepOffset"),
  7424. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7425. a.uniform2f(t, i, o),
  7426. a.uniform1f(n, r),
  7427. a.uniform1f(e, 1)
  7428. },
  7429. this.setParameters = function(e) {
  7430. void 0 !== e.denoiseLevel && (r = e.denoiseLevel)
  7431. },
  7432. this.setSize = function(e, t) {
  7433. i = 1 / e,
  7434. o = 1 / t
  7435. }
  7436. }
  7437. var ve = [11, 196, 242, 139, 198, 252, 188, 5, 32, 162, 171, 128, 13, 160, 25, 222, 172, 102, 207, 244, 158, 69, 103, 57, 239, 111, 150, 18, 157, 82, 55, 210, 20, 131, 156, 190, 100, 112, 230, 97, 199, 225, 96, 74, 99, 94, 248, 222, 162, 213, 95, 122, 158, 212, 233, 42, 22, 37, 217, 115, 36, 152, 30, 123, 116, 104, 212, 109, 129, 41, 220, 77, 213, 97, 124, 45, 4, 219, 197, 171, 40, 18, 149, 104, 20, 4, 248, 102, 64, 9, 50, 217, 124, 131, 180, 188, 159, 170, 63, 1, 84, 130, 150, 117, 14, 212, 118, 67, 165, 97, 207, 242, 251, 15, 30, 187, 188, 77, 79, 122, 67, 101, 252, 109, 244, 82, 37, 191, 227, 35, 114, 87, 57, 71, 99, 218, 155, 54, 101, 239, 138, 197, 13, 226, 228, 176, 157, 158, 87, 98, 55, 251, 79, 150, 64, 138, 200, 135, 40, 132, 135, 207, 146, 252, 222, 57, 58, 111, 151, 225, 78, 59, 36, 210, 70, 29, 121, 160, 210, 31, 109, 67, 167, 194, 177, 236, 91, 108, 164, 229, 130, 211, 59, 66, 93, 18, 107, 226, 54, 210, 51, 8, 77, 217, 19, 73, 187, 33, 30, 59, 9, 135, 162, 49, 5, 11, 225, 111, 119, 11, 247, 218, 129, 115, 83, 205, 170, 21, 4, 69, 210, 133, 134, 245, 109, 15, 177, 9, 81, 81, 203, 105, 42, 158, 12, 255, 151, 165, 230, 205, 5, 92, 196, 251, 211, 187, 27, 214, 43, 186, 91, 233, 85, 192, 229, 15, 71, 38, 220, 20, 38, 101, 44, 78, 7, 60, 251, 186, 75, 103, 108, 53, 166, 220, 186, 208, 194, 120, 207, 230, 159, 248, 22, 32, 142, 124, 96, 157, 222, 60, 191, 65, 145, 6, 239, 125, 151, 147, 50, 58, 130, 207, 110, 131, 223, 231, 137, 238, 28, 182, 216, 167, 198, 191, 37, 67, 76, 1, 144, 232, 218, 79, 72, 28, 65, 101, 43, 216, 64, 253, 16, 173, 179, 123, 140, 27, 233, 245, 199, 230, 36, 181, 102, 114, 247, 162, 18, 34, 20, 212, 25, 171, 24, 28, 143, 80, 94, 40, 167, 34, 209, 61, 117, 130, 1, 198, 196, 7, 21, 252, 180, 255, 92, 128, 119, 9, 48, 156, 138, 136, 151, 143, 23, 44, 52, 3, 40, 197, 228, 31, 123, 67, 163, 140, 32, 54, 204, 187, 149, 80, 19, 255, 82, 120, 195, 12, 110, 65, 56, 212, 143, 22, 78, 44, 234, 72, 140, 29, 118, 103, 18, 36, 7, 122, 50, 37, 139, 47, 142, 243, 25, 208, 88, 237, 126, 50, 103, 127, 19, 183, 29, 169, 29, 1, 55, 23, 100, 32, 129, 239, 243, 160, 61, 178, 197, 117, 199, 45, 57, 26, 165, 135, 92, 218, 59, 0, 197, 54, 13, 96, 40, 141, 212, 221, 131, 103, 46, 22, 228, 191, 167, 73, 20, 86, 62, 11, 147, 217, 116, 205, 203, 110, 134, 249, 51, 6, 123, 23, 86, 231, 157, 8, 144, 83, 126, 115, 118, 35, 96, 36, 229, 36, 220, 228, 143, 71, 45, 223, 129, 48, 236, 5, 145, 202, 188, 208, 184, 70, 241, 104, 255, 188, 181, 146, 210, 206, 144, 53, 77, 101, 120, 38, 8, 245, 80, 230, 165, 160, 183, 83, 202, 79, 127, 57, 214, 126, 242, 150, 208, 40, 239, 148, 35, 163, 201, 97, 74, 70, 214, 181, 63, 240, 147, 33, 253, 149, 140, 77, 197, 82, 126, 189, 231, 7, 196, 212, 80, 14, 151, 24, 57, 144, 243, 81, 234, 66, 24, 19, 236, 2, 137, 121, 246, 129, 65, 7, 99, 110, 174, 54, 74, 182, 81, 234, 142, 37, 72, 110, 220, 255, 64, 119, 10, 188, 111, 191, 228, 1, 205, 9, 204, 143, 56, 62, 125, 84, 106, 225, 131, 97, 192, 43, 240, 157, 161, 75, 168, 247, 44, 175, 65, 81, 192, 48, 21, 157, 167, 80, 191, 130, 161, 75, 85, 186, 174, 42, 117, 1, 68, 252, 204, 138, 254, 203, 152, 21, 13, 64, 144, 195, 207, 238, 229, 54, 103, 247, 159, 245, 211, 85, 191, 141, 168, 32, 234, 85, 46, 118, 12, 5, 199, 4, 19, 217, 203, 202, 156, 33, 143, 114, 116, 60, 66, 40, 58, 77, 208, 237, 171, 26, 72, 175, 114, 205, 248, 87, 137, 62, 210, 143, 151, 197, 167, 210, 241, 122, 150, 104, 122, 154, 2, 70, 102, 83, 19, 36, 141, 136, 199, 42, 79, 229, 71, 86, 194, 109, 31, 236, 80, 166, 17, 230, 109, 1, 40, 28, 46, 224, 56, 20, 230, 47, 100, 254, 116, 208, 76, 169, 157, 241, 175, 3, 70, 85, 31, 38, 245, 58, 33, 80, 145, 237, 8, 22, 71, 224, 158, 156, 31, 249, 81, 87, 247, 230, 199, 237, 96, 167, 123, 63, 243, 79, 156, 206, 203, 160, 54, 124, 68, 253, 215, 132, 235, 57, 185, 92, 238, 55, 59, 210, 104, 71, 26, 183, 180, 71, 12, 255, 224, 192, 65, 154, 72, 244, 8, 164, 10, 248, 46, 207, 30, 92, 1, 80, 244, 31, 189, 138, 88, 216, 218, 63, 100, 227, 116, 57, 119, 94, 135, 5, 126, 255, 32, 191, 163, 61, 209, 194, 88, 248, 112, 139, 173, 43, 69, 134, 3, 160, 151, 137, 25, 98, 239, 166, 19, 123, 208, 180, 31, 120, 30, 191, 75, 183, 179, 126, 180, 125, 92, 107, 105, 206, 138, 28, 67, 139, 3, 188, 230, 184, 255, 121, 13, 181, 45, 160, 114, 202, 194, 123, 87, 55, 124, 97, 164, 82, 95, 232, 216, 117, 62, 5, 90, 176, 82, 167, 52, 160, 153, 174, 168, 105, 146, 91, 248, 81, 79, 249, 97, 138, 133, 170, 245, 229, 132, 61, 5, 149, 224, 246, 194, 213, 61, 12, 109, 44, 136, 235, 95, 219, 133, 220, 27, 93, 36, 93, 124, 180, 81, 141, 152, 220, 170, 163, 229, 197, 124, 171, 232, 48, 70, 251, 106, 119, 150, 20, 16, 49, 119, 247, 42, 132, 36, 76, 254, 124, 177, 66, 175, 9, 1, 39, 92, 127, 195, 171, 198, 34, 2, 64, 144, 179, 72, 40, 151, 110, 89, 229, 42, 125, 33, 238, 16, 220, 228, 51, 203, 8, 1, 68, 145, 253, 133, 118, 93, 163, 129, 22, 13, 248, 65, 12, 4, 63, 101, 210, 70, 170, 138, 203, 14, 246, 54, 194, 195, 27, 107, 241, 175, 35, 171, 49, 52, 106, 121, 45, 36, 152, 85, 215, 132, 78, 167, 34, 18, 167, 245, 152, 133, 134, 170, 120, 182, 10, 146, 191, 37, 2, 205, 47, 125, 20, 203, 44, 88, 81, 32, 150, 223, 220, 218, 238, 254, 30, 212, 167, 221, 115, 156, 82, 226, 137, 220, 221, 97, 3, 139, 202, 33, 9, 27, 26, 126, 40, 215, 25, 126, 9, 82, 208, 49, 217, 14, 161, 81, 196, 61, 60, 87, 254, 213, 194, 81, 216, 161, 151, 209, 166, 222, 230, 24, 128, 117, 140, 92, 4, 203, 254, 170, 253, 249, 88, 90, 112, 226, 18, 44, 122, 39, 158, 158, 56, 69, 204, 159, 5, 179, 51, 197, 233, 139, 216, 102, 226, 206, 248, 15, 78, 112, 214, 126, 67, 28, 40, 38, 98, 190, 178, 206, 67, 94, 245, 254, 160, 101, 176, 32, 157, 26, 132, 83, 252, 228, 87, 242, 32, 127, 160, 112, 210, 224, 133, 149, 115, 41, 30, 16, 200, 69, 89, 81, 77, 144, 12, 106, 182, 73, 54, 28, 53, 195, 28, 216, 179, 179, 136, 35, 141, 102, 234, 177, 240, 34, 186, 106, 145, 245, 3, 84, 48, 251, 157, 245, 11, 217, 111, 227, 138, 42, 67, 114, 211, 177, 37, 103, 16, 71, 152, 72, 117, 123, 36, 213, 202, 56, 124, 227, 84, 8, 45, 229, 149, 165, 214, 69, 244, 169, 55, 68, 62, 94, 104, 228, 74, 205, 123, 222, 17, 7, 172, 158, 227, 74, 206, 149, 67, 175, 171, 251, 185, 121, 151, 223, 63, 35, 229, 32, 49, 190, 209, 120, 137, 69, 213, 214, 19, 150, 187, 177, 28, 12, 158, 153, 126, 149, 171, 167, 234, 120, 129, 109, 32, 157, 180, 75, 66, 56, 233, 115, 127, 230, 157, 32, 34, 143, 156, 31, 230, 168, 174, 125, 118, 195, 249, 243, 165, 81, 246, 10, 144, 15, 103, 139, 55, 173, 7, 59, 136, 69, 172, 54, 132, 165, 140, 78, 77, 230, 33, 169, 129, 188, 71, 209, 109, 161, 8, 57, 57, 199, 143, 31, 164, 43, 58, 130, 1, 110, 145, 31, 229, 13, 46, 149, 94, 244, 106, 76, 238, 105, 107, 1, 183, 177, 10, 61, 225, 94, 185, 116, 58, 183, 95, 225, 22, 119, 19, 248, 28, 13, 123, 125, 108, 158, 64, 184, 77, 245, 153, 162, 217, 227, 208, 41, 185, 211, 235, 41, 153, 181, 54, 166, 165, 11, 154, 55, 21, 184, 209, 192, 249, 44, 164, 160, 29, 229, 159, 82, 156, 198, 241, 183, 114, 83, 137, 186, 151, 148, 31, 21, 197, 216, 145, 32, 13, 50, 22, 241, 137, 39, 71, 28, 142, 160, 215, 107, 221, 45, 202, 104, 227, 110, 186, 12, 150, 145, 240, 51, 49, 44, 196, 115, 224, 238, 149, 189, 134, 99, 67, 241, 62, 157, 240, 114, 247, 195, 26, 200, 141, 97, 147, 249, 23, 150, 174, 10, 13, 219, 81, 73, 58, 242, 96, 250, 243, 15, 49, 218, 58, 230, 104, 252, 175, 150, 123, 86, 185, 84, 90, 198, 6, 36, 0, 99, 72, 28, 166, 238, 115, 231, 171, 249, 179, 71, 174, 68, 156, 227, 17, 198, 79, 73, 142, 99, 144, 20, 80, 62, 80, 191, 142, 46, 71, 9, 243, 6, 8, 214, 116, 72, 190, 106, 161, 19, 185, 100, 9, 187, 64, 94, 86, 203, 174, 156, 245, 222, 95, 54, 30, 148, 19, 11, 50, 112, 96, 61, 237, 159, 173, 7, 154, 127, 175, 79, 48, 97, 89, 78, 126, 66, 171, 204, 158, 195, 27, 226, 205, 222, 157, 89, 251, 90, 125, 37, 212, 27, 97, 3, 141, 247, 175, 50, 121, 7, 187, 68, 196, 181, 202, 167, 189, 57, 84, 81, 222, 23, 27, 84, 130, 176, 98, 66, 240, 207, 18, 23, 28, 163, 163, 194, 45, 37, 129, 202, 170, 97, 189, 0, 81, 238, 0, 39, 199, 163, 35, 211, 206, 247, 65, 29, 116, 242, 67, 102, 235, 13, 136, 232, 230, 114, 146, 187, 7, 254, 142, 26, 121, 16, 237, 5, 160, 201, 114, 94, 178, 199, 95, 212, 241, 45, 112, 180, 188, 72, 86, 114, 189, 155, 149, 149, 163, 210, 112, 101, 12, 69, 225, 75, 202, 223, 28, 242, 90, 215, 156, 169, 224, 245, 135, 128, 92, 148, 217, 131, 208, 255, 25, 135, 117, 136, 5, 104, 185, 249, 161, 228, 214, 16, 105, 204, 9, 182, 135, 153, 220, 101, 244, 160, 207, 58, 182, 118, 185, 240, 57, 245, 123, 13, 112, 182, 106, 229, 220, 90, 29, 86, 215, 96, 147, 232, 2, 55, 131, 225, 137, 68, 245, 89, 141, 252, 97, 3, 129, 155, 216, 223, 98, 116, 45, 78, 85, 141, 161, 74, 215, 7, 150, 171, 225, 59, 78, 221, 152, 236, 14, 117, 100, 208, 158, 86, 13, 185, 124, 87, 157, 111, 40, 187, 182, 124, 173, 71, 173, 23, 199, 52, 155, 190, 134, 11, 23, 64, 25, 215, 39, 115, 231, 173, 77, 72, 114, 54, 252, 116, 178, 59, 221, 106, 241, 119, 254, 30, 226, 241, 204, 233, 113, 197, 96, 146, 0, 41, 67, 3, 231, 126, 12, 218, 202, 22, 171, 114, 249, 176, 134, 160, 19, 216, 31, 229, 118, 226, 62, 242, 126, 126, 42, 127, 130, 68, 218, 218, 81, 202, 106, 217, 191, 25, 177, 82, 97, 81, 36, 232, 137, 58, 90, 216, 190, 117, 235, 20, 194, 144, 76, 178, 27, 213, 13, 208, 18, 29, 118, 126, 49, 98, 203, 179, 128, 237, 100, 32, 242, 189, 212, 6, 210, 210, 188, 161, 205, 13, 124, 119, 13, 215, 112, 41, 183, 176, 215, 168, 210, 182, 111, 1, 115, 2, 239, 141, 8, 177, 124, 112, 48, 197, 2, 239, 11, 99, 4, 36, 77, 69, 47, 244, 19, 153, 61, 19, 2, 96, 176, 7, 112, 122, 131, 169, 25, 189, 116, 171, 49, 12, 121, 162, 79, 154, 74, 251, 50, 233, 182, 63, 180, 224, 118, 49, 253, 21, 20, 16, 31, 144, 184, 93, 174, 231, 244, 183, 13, 49, 225, 189, 211, 73, 185, 49, 110, 142, 25, 226, 45, 176, 233, 204, 74, 33, 16, 205, 88, 131, 92, 157, 170, 175, 68, 170, 61, 53, 116, 165, 16, 27, 182, 160, 181, 87, 241, 15, 151, 85, 107, 76, 167, 129, 25, 172, 127, 184, 138, 153, 222, 228, 125, 64, 44, 45, 32, 12, 227, 148, 106, 152, 83, 240, 166, 54, 235, 32, 190, 12, 242, 164, 123, 189, 53, 194, 141, 104, 43, 202, 110, 4, 168, 119, 245, 232, 179, 178, 198, 1, 224, 87, 86, 160, 31, 19, 140, 233, 102, 191, 204, 4, 98, 138, 163, 191, 106, 24, 213, 47, 208, 82, 137, 132, 131, 16, 253, 84, 25, 144, 90, 159, 148, 16, 196, 84, 166, 61, 160, 101, 229, 227, 93, 118, 59, 87, 66, 16, 128, 59, 96, 131, 250, 20, 184, 150, 205, 91, 227, 201, 62, 35, 79, 180, 172, 173, 85, 197, 106, 153, 238, 229, 60, 204, 65, 193, 230, 94, 101, 177, 134, 6, 165, 53, 171, 142, 208, 155, 2, 11, 4, 202, 127, 54, 17, 142, 117, 227, 121, 128, 204, 192, 147, 147, 92, 189, 5, 224, 148, 72, 18, 83, 101, 126, 124, 228, 153, 242, 123, 229, 247, 92, 221, 6, 73, 227, 250, 87, 167, 194, 129, 187, 73, 38, 185, 109, 217, 240, 193, 88, 50, 178, 180, 151, 54, 197, 187, 137, 190, 166, 233, 1, 103, 204, 88, 31, 127, 185, 29, 65, 1, 29, 254, 223, 14, 83, 167, 215, 114, 248, 30, 173, 89, 173, 187, 69, 5, 105, 117, 15, 106, 94, 173, 63, 227, 25, 230, 190, 136, 168, 177, 175, 107, 91, 126, 254, 34, 188, 25, 118, 48, 12, 226, 130, 153, 162, 57, 47, 181, 212, 79, 160, 97, 64, 157, 246, 90, 53, 43, 149, 76, 102, 15, 195, 107, 58, 242, 84, 172, 29, 81, 198, 113, 81, 251, 138, 182, 154, 111, 30, 171, 129, 56, 17, 45, 214, 153, 112, 117, 203, 174, 40, 38, 234, 236, 32, 4, 112, 225, 26, 187, 195, 246, 252, 9, 218, 69, 160, 223, 178, 54, 148, 81, 8, 134, 151, 75, 248, 63, 224, 240, 48, 75, 250, 221, 85, 46, 100, 50, 3, 70, 64, 102, 111, 160, 155, 233, 59, 147, 184, 57, 61, 6, 126, 79, 176, 16, 185, 94, 166, 33, 135, 78, 42, 75, 140, 208, 140, 44, 153, 187, 64, 103, 119, 160, 236, 16, 239, 74, 218, 219, 212, 207, 110, 53, 30, 76, 248, 40, 111, 98, 44, 20, 113, 204, 233, 109, 135, 96, 107, 39, 163, 203, 125, 45, 157, 152, 71, 239, 175, 174, 159, 147, 80, 111, 93, 38, 253, 228, 154, 225, 181, 101, 12, 241, 127, 65, 49, 189, 5, 85, 151, 237, 213, 143, 14, 104, 138, 54, 52, 27, 4, 132, 67, 35, 156, 86, 157, 73, 16, 229, 222, 245, 110, 79, 165, 179, 56, 179, 53, 218, 229, 100, 58, 87, 149, 48, 231, 64, 63, 115, 67, 3, 172, 6, 186, 115, 154, 60, 53, 214, 152, 149, 89, 234, 37, 143, 82, 255, 64, 28, 183, 93, 112, 39, 70, 185, 57, 0, 199, 9, 61, 175, 219, 41, 76, 37, 176, 82, 125, 65, 53, 160, 214, 105, 62, 153, 244, 222, 96, 205, 6, 178, 85, 41, 240, 113, 0, 96, 149, 38, 3, 195, 18, 152, 41, 246, 3, 103, 29, 110, 134, 30, 101, 75, 46, 103, 199, 184, 20, 230, 8, 55, 120, 4, 229, 168, 35, 43, 7, 28, 161, 143, 87, 27, 87, 79, 255, 186, 44, 195, 158, 155, 181, 119, 81, 172, 217, 107, 95, 98, 55, 243, 186, 66, 105, 48, 224, 123, 232, 84, 156, 20, 10, 156, 208, 204, 52, 34, 228, 136, 97, 242, 200, 246, 211, 67, 202, 40, 241, 91, 92, 253, 9, 54, 72, 131, 221, 106, 178, 32, 44, 182, 4, 225, 193, 37, 20, 249, 249, 231, 10, 206, 18, 71, 254, 221, 187, 172, 88, 204, 6, 127, 138, 102, 7, 208, 75, 147, 219, 199, 177, 79, 36, 170, 101, 207, 177, 109, 95, 143, 217, 41, 199, 80, 183, 201, 2, 254, 12, 55, 23, 198, 14, 255, 69, 245, 138, 155, 129, 227, 167, 168, 130, 156, 135, 14, 96, 93, 48, 99, 143, 107, 126, 92, 117, 143, 112, 108, 193, 228, 84, 13, 41, 186, 27, 172, 92, 201, 149, 116, 19, 112, 197, 116, 209, 128, 102, 1, 55, 152, 177, 28, 37, 34, 50, 83, 41, 199, 74, 178, 59, 111, 67, 118, 35, 252, 36, 33, 87, 28, 170, 17, 215, 47, 90, 154, 124, 137, 15, 14, 211, 59, 75, 59, 30, 77, 0, 49, 37, 225, 191, 87, 101, 127, 214, 227, 160, 99, 174, 234, 82, 148, 235, 16, 241, 219, 147, 170, 127, 221, 250, 116, 39, 218, 156, 72, 227, 172, 55, 0, 79, 188, 76, 51, 222, 232, 24, 36, 62, 94, 154, 3, 61, 230, 146, 114, 253, 0, 128, 58, 253, 90, 72, 211, 242, 38, 39, 133, 153, 161, 119, 105, 195, 152, 225, 208, 105, 140, 80, 217, 186, 196, 157, 21, 116, 230, 116, 139, 25, 159, 143, 118, 128, 77, 201, 238, 247, 228, 15, 168, 4, 133, 148, 21, 148, 12, 44, 241, 7, 115, 17, 129, 176, 202, 46, 130, 122, 129, 235, 141, 223, 85, 21, 199, 65, 181, 169, 52, 174, 161, 153, 62, 25, 164, 115, 213, 89, 138, 199, 103, 79, 200, 165, 135, 249, 244, 27, 209, 178, 240, 129, 211, 61, 9, 111, 157, 147, 119, 36, 119, 255, 110, 130, 84, 49, 210, 225, 247, 100, 26, 121, 127, 163, 160, 26, 79, 99, 24, 77, 65, 32, 178, 109, 36, 27, 253, 173, 110, 183, 11, 14, 211, 57, 130, 254, 124, 104, 165, 219, 31, 70, 97, 14, 194, 39, 61, 26, 141, 125, 228, 126, 194, 184, 101, 160, 204, 106, 128, 144, 106, 103, 171, 18, 246, 129, 220, 85, 172, 151, 123, 5, 73, 155, 192, 175, 91, 157, 239, 61, 237, 116, 170, 65, 233, 56, 19, 49, 114, 168, 190, 3, 214, 53, 250, 90, 213, 244, 88, 101, 30, 229, 248, 124, 15, 71, 141, 27, 172, 235, 21, 129, 211, 72, 61, 172, 112, 170, 128, 135, 96, 196, 221, 255, 27, 176, 105, 188, 183, 121, 33, 37, 149, 53, 131, 226, 233, 29, 167, 234, 218, 109, 53, 185, 152, 36, 248, 53, 61, 235, 78, 21, 201, 214, 210, 163, 12, 251, 187, 45, 188, 137, 126, 127, 237, 92, 234, 91, 240, 225, 38, 194, 57, 213, 251, 237, 171, 30, 99, 52, 14, 49, 84, 101, 252, 237, 7, 166, 122, 114, 32, 107, 32, 207, 239, 136, 168, 178, 12, 11, 241, 233, 230, 146, 132, 18, 83, 233, 41, 172, 17, 6, 161, 42, 113, 87, 40, 255, 185, 1, 146, 128, 5, 240, 126, 131, 71, 42, 54, 124, 205, 2, 122, 71, 30, 222, 229, 40, 134, 142, 102, 97, 239, 151, 177, 1, 230, 231, 49, 123, 219, 28, 129, 91, 152, 112, 13, 154, 81, 197, 226, 255, 112, 158, 178, 177, 55, 181, 108, 138, 185, 245, 29, 186, 21, 73, 188, 209, 154, 200, 89, 116, 235, 198, 144, 36, 87, 248, 22, 7, 200, 122, 7, 148, 44, 42, 87, 140, 238, 204, 95, 231, 252, 0, 136, 0, 22, 39, 70, 123, 125, 165, 113, 227, 172, 146, 163, 128, 158, 36, 52, 91, 19, 36, 245, 27, 150, 138, 141, 11, 67, 239, 224, 65, 24, 116, 101, 7, 39, 46, 142, 172, 164, 243, 148, 0, 33, 226, 59, 47, 203, 137, 156, 241, 66, 250, 157, 30, 204, 101, 143, 134, 98, 238, 155, 226, 25, 184, 136, 219, 89, 100, 193, 11, 143, 71, 139, 243, 230, 151, 0, 249, 1, 78, 26, 32, 93, 104, 157, 67, 97, 164, 248, 86, 124, 146, 93, 74, 222, 228, 167, 55, 53, 100, 135, 216, 109, 13, 64, 37, 106, 177, 200, 200, 182, 92, 251, 69, 31, 243, 89, 80, 198, 14, 132, 203, 72, 103, 28, 104, 217, 24, 97, 223, 113, 11, 29, 178, 191, 210, 46, 162, 255, 68, 99, 8, 237, 213, 162, 152, 193, 183, 121, 203, 19, 108, 182, 29, 86, 26, 192, 103, 220, 103, 205, 154, 179, 197, 9, 22, 73, 127, 175, 146, 38, 119, 210, 0, 24, 180, 21, 245, 215, 204, 91, 186, 119, 138, 183, 239, 15, 155, 231, 248, 133, 39, 24, 101, 144, 236, 10, 230, 54, 174, 227, 73, 21, 110, 10, 160, 241, 232, 131, 14, 212, 127, 232, 59, 122, 65, 146, 54, 163, 9, 189, 190, 121, 88, 170, 62, 194, 14, 204, 152, 245, 38, 131, 37, 91, 81, 72, 114, 29, 115, 239, 182, 56, 44, 156, 159, 177, 180, 82, 160, 93, 97, 86, 183, 236, 50, 95, 85, 39, 71, 181, 225, 152, 143, 63, 123, 117, 34, 44, 109, 160, 166, 229, 240, 91, 138, 102, 54, 180, 173, 44, 50, 80, 42, 124, 7, 50, 124, 211, 239, 21, 94, 197, 185, 239, 213, 107, 142, 64, 95, 124, 125, 17, 180, 97, 189, 101, 52, 48, 19, 112, 12, 70, 9, 212, 177, 54, 118, 66, 84, 147, 236, 248, 26, 124, 95, 103, 135, 254, 124, 49, 112, 186, 99, 120, 90, 8, 194, 191, 88, 57, 242, 65, 61, 10, 104, 246, 197, 252, 19, 159, 58, 194, 75, 173, 242, 103, 8, 115, 84, 69, 238, 149, 26, 15, 159, 182, 141, 132, 119, 70, 29, 53, 20, 143, 46, 163, 204, 6, 236, 59, 45, 185, 172, 89, 119, 83, 38, 144, 36, 222, 96, 151, 26, 99, 195, 163, 170, 133, 92, 159, 214, 53, 150, 116, 90, 176, 69, 145, 130, 15, 172, 140, 217, 215, 101, 163, 115, 161, 65, 101, 8, 7, 183, 113, 213, 134, 58, 175, 130, 251, 143, 173, 248, 168, 135, 60, 159, 30, 194, 68, 208, 119, 120, 2, 40, 178, 227, 247, 161, 77, 47, 136, 46, 244, 163, 72, 65, 158, 25, 225, 195, 61, 132, 182, 204, 177, 186, 200, 81, 2, 65, 105, 212, 72, 94, 203, 232, 217, 182, 123, 251, 228, 160, 1, 161, 204, 123, 20, 37, 1, 77, 208, 179, 45, 149, 181, 122, 102, 190, 123, 213, 164, 231, 41, 216, 130, 234, 248, 208, 251, 252, 220, 84, 209, 67, 47, 61, 220, 5, 142, 162, 26, 236, 121, 142, 248, 132, 255, 65, 122, 203, 196, 102, 191, 187, 2, 195, 127, 255, 193, 92, 49, 91, 186, 154, 39, 156, 29, 211, 172, 49, 104, 245, 114, 153, 223, 211, 199, 249, 35, 130, 160, 128, 0, 152, 176, 183, 20, 236, 113, 193, 108, 26, 255, 11, 237, 102, 133, 245, 94, 115, 114, 10, 89, 229, 214, 221, 99, 149, 30, 99, 37, 246, 10, 26, 26, 39, 92, 123, 170, 73, 211, 127, 227, 54, 30, 86, 133, 159, 112, 225, 91, 148, 100, 174, 149, 75, 143, 14, 140, 20, 44, 64, 212, 5, 243, 8, 116, 63, 30, 97, 42, 123, 20, 73, 212, 85, 207, 83, 122, 27, 251, 233, 84, 10, 17, 236, 232, 83, 200, 127, 119, 143, 163, 204, 220, 167, 59, 231, 20, 106, 186, 222, 191, 8, 40, 234, 21, 25, 180, 13, 116, 250, 152, 224, 174, 75, 3, 205, 38, 173, 215, 236, 151, 185, 121, 254, 244, 154, 239, 17, 53, 106, 164, 61, 49, 116, 216, 118, 94, 150, 35, 181, 26, 238, 66, 49, 211, 221, 132, 146, 166, 115, 39, 136, 36, 205, 230, 179, 31, 197, 51, 148, 165, 109, 38, 70, 37, 148, 52, 44, 209, 250, 98, 58, 246, 225, 103, 198, 101, 26, 25, 196, 207, 8, 166, 21, 88, 252, 175, 253, 10, 88, 107, 157, 19, 225, 61, 12, 246, 221, 37, 239, 186, 167, 137, 142, 135, 222, 128, 174, 62, 95, 216, 38, 141, 157, 45, 232, 97, 217, 173, 203, 234, 116, 129, 69, 206, 189, 94, 221, 12, 54, 139, 186, 247, 184, 16, 200, 121, 244, 104, 8, 7, 35, 111, 47, 188, 10, 140, 92, 73, 143, 206, 203, 72, 122, 184, 20, 102, 197, 130, 64, 150, 63, 96, 239, 8, 132, 111, 217, 84, 91, 198, 32, 43, 100, 138, 241, 15, 160, 42, 190, 253, 193, 184, 164, 124, 29, 210, 96, 67, 224, 221, 182, 29, 218, 129, 149, 29, 128, 174, 98, 88, 88, 125, 56, 40, 255, 120, 5, 0, 87, 174, 42, 150, 90, 112, 201, 183, 169, 19, 57, 195, 191, 12, 58, 244, 235, 132, 25, 145, 72, 146, 214, 8, 125, 100, 135, 12, 5, 102, 97, 248, 174, 24, 159, 90, 33, 43, 187, 6, 61, 212, 241, 225, 190, 219, 252, 197, 123, 129, 164, 108, 123, 55, 230, 4, 153, 166, 105, 234, 15, 85, 216, 23, 56, 32, 3, 41, 110, 68, 146, 172, 133, 202, 98, 41, 7, 47, 152, 35, 255, 168, 106, 241, 226, 222, 77, 244, 52, 185, 65, 252, 227, 32, 66, 38, 11, 172, 60, 28, 28, 103, 84, 1, 1, 205, 182, 190, 28, 189, 102, 253, 43, 1, 191, 148, 116, 10, 227, 18, 81, 93, 80, 239, 157, 232, 215, 180, 163, 165, 161, 109, 177, 71, 150, 244, 144, 208, 160, 110, 22, 174, 60, 206, 43, 103, 121, 55, 103, 114, 115, 173, 238, 13, 10, 227, 251, 41, 176, 216, 158, 229, 216, 55, 234, 128, 128, 20, 167, 106, 181, 86, 163, 130, 215, 110, 149, 191, 10, 227, 215, 8, 214, 154, 178, 181, 15, 19, 0, 247, 250, 97, 74, 43, 157, 55, 94, 174, 41, 41, 9, 199, 97, 20, 91, 32, 18, 10, 43, 98, 240, 247, 203, 20, 250, 117, 160, 44, 229, 202, 187, 64, 54, 124, 15, 184, 169, 129, 27, 160, 240, 26, 61, 255, 60, 166, 60, 144, 209, 84, 55, 187, 186, 168, 13, 124, 125, 29, 17, 100, 249, 227, 62, 205, 78, 179, 163, 168, 139, 168, 21, 38, 83, 239, 151, 74, 43, 66, 2, 92, 72, 71, 94, 216, 134, 238, 20, 45, 158, 213, 164, 73, 57, 80, 47, 198, 184, 130, 223, 227, 71, 132, 133, 235, 177, 85, 174, 142, 124, 172, 200, 54, 229, 40, 126, 60, 76, 92, 216, 153, 56, 241, 174, 66, 141, 90, 226, 3, 30, 68, 234, 71, 187, 163, 112, 146, 255, 22, 143, 170, 204, 3, 127, 179, 81, 139, 160, 37, 77, 246, 128, 220, 196, 158, 153, 73, 177, 65, 199, 119, 29, 197, 144, 130, 248, 206, 155, 253, 108, 213, 124, 7, 223, 221, 162, 146, 134, 242, 65, 99, 162, 107, 120, 247, 214, 207, 96, 150, 169, 131, 208, 218, 221, 28, 24, 112, 208, 23, 1, 130, 142, 232, 56, 104, 45, 33, 158, 95, 255, 123, 31, 74, 76, 120, 178, 155, 213, 6, 195, 164, 8, 8, 69, 241, 197, 127, 83, 169, 21, 167, 19, 94, 143, 252, 33, 159, 248, 241, 170, 153, 147, 1, 149, 199, 201, 131, 170, 79, 236, 212, 209, 143, 107, 98, 24, 123, 56, 33, 193, 85, 247, 64, 225, 135, 210, 78, 145, 57, 16, 145, 71, 170, 20, 133, 87, 235, 4, 166, 239, 100, 82, 235, 81, 50, 223, 9, 193, 52, 49, 86, 129, 190, 196, 82, 165, 107, 63, 115, 161, 98, 33, 20, 193, 29, 42, 151, 205, 252, 124, 72, 245, 48, 181, 67, 7, 13, 21, 127, 59, 226, 188, 144, 129, 112, 244, 192, 121, 213, 80, 42, 196, 1, 13, 107, 108, 78, 0, 40, 121, 225, 148, 237, 234, 209, 216, 238, 9, 147, 226, 254, 96, 89, 212, 72, 193, 106, 75, 135, 74, 227, 67, 255, 92, 191, 81, 188, 124, 226, 149, 152, 142, 15, 159, 195, 238, 114, 55, 255, 166, 157, 230, 59, 148, 170, 166, 151, 65, 213, 104, 253, 253, 112, 150, 82, 147, 137, 27, 214, 100, 247, 65, 81, 92, 47, 86, 217, 7, 45, 120, 81, 130, 31, 236, 243, 76, 78, 3, 45, 105, 172, 220, 71, 48, 220, 94, 196, 249, 163, 193, 133, 50, 236, 205, 20, 55, 2, 63, 14, 127, 69, 113, 212, 204, 12, 58, 79, 89, 86, 29, 61, 199, 201, 64, 149, 6, 144, 182, 150, 129, 31, 18, 167, 120, 248, 82, 107, 25, 143, 128, 27, 161, 28, 25, 153, 183, 217, 238, 78, 186, 106, 92, 27, 202, 219, 165, 96, 0, 216, 234, 169, 73, 101, 39, 182, 113, 217, 240, 170, 116, 172, 221, 250, 233, 48, 49, 242, 83, 227, 92, 181, 184, 72, 230, 180, 21, 15, 108, 135, 25, 38, 153, 25, 124, 227, 26, 149, 73, 236, 39, 211, 244, 149, 58, 183, 132, 26, 223, 219, 174, 144, 117, 233, 219, 165, 205, 157, 159, 222, 184, 52, 47, 241, 201, 123, 65, 24, 44, 55, 215, 177, 168, 250, 179, 115, 190, 227, 123, 158, 163, 179, 224, 69, 196, 66, 207, 254, 243, 101, 221, 193, 140, 250, 4, 28, 222, 52, 96, 138, 160, 33, 218, 64, 118, 214, 234, 201, 152, 148, 91, 178, 111, 107, 144, 142, 6, 182, 102, 72, 188, 34, 213, 181, 26, 223, 58, 255, 103, 81, 17, 47, 169, 11, 245, 224, 123, 148, 215, 237, 186, 107, 75, 152, 90, 202, 166, 22, 149, 197, 5, 246, 238, 78, 76, 229, 106, 199, 94, 127, 195, 0, 45, 82, 6, 159, 103, 96, 138, 231, 71, 46, 107, 59, 216, 39, 43, 12, 221, 27, 214, 56, 155, 145, 66, 187, 169, 250, 235, 78, 211, 179, 239, 183, 198, 163, 93, 5, 196, 24, 174, 143, 225, 106, 139, 89, 98, 13, 127, 207, 184, 194, 30, 1, 165, 198, 169, 8, 197, 118, 86, 163, 221, 138, 23, 209, 61, 116, 79, 99, 233, 43, 130, 60, 244, 85, 229, 243, 172, 123, 148, 200, 120, 192, 127, 211, 52, 11, 159, 41, 95, 212, 230, 188, 169, 156, 137, 29, 212, 12, 148, 168, 148, 133, 243, 44, 241, 139, 127, 24, 246, 220, 227, 125, 209, 97, 60, 52, 162, 192, 146, 49, 161, 92, 138, 112, 189, 128, 59, 126, 125, 46, 207, 60, 79, 231, 174, 152, 209, 68, 223, 205, 2, 38, 14, 91, 116, 159, 255, 28, 27, 178, 248, 164, 104, 158, 79, 69, 214, 234, 157, 12, 75, 163, 83, 253, 245, 202, 61, 213, 176, 6, 197, 230, 29, 208, 166, 253, 194, 254, 235, 29, 141, 241, 70, 249, 15, 62, 0, 148, 163, 135, 52, 122, 40, 96, 87, 31, 179, 152, 51, 216, 133, 184, 122, 198, 203, 60, 115, 218, 191, 193, 16, 178, 25, 148, 252, 112, 104, 103, 252, 36, 92, 221, 28, 179, 43, 199, 198, 151, 128, 100, 252, 217, 161, 249, 34, 201, 172, 118, 52, 180, 252, 104, 7, 223, 44, 116, 102, 212, 21, 40, 224, 184, 55, 163, 210, 21, 207, 161, 239, 51, 54, 155, 41, 133, 18, 67, 48, 3, 165, 130, 251, 4, 79, 214, 57, 72, 130, 157, 212, 144];
  7438. function Se(e, t, n) {
  7439. var a = e.gl,
  7440. i = 5,
  7441. o = .1,
  7442. r = .5,
  7443. s = 175 / 180 * 3.141593,
  7444. c = 115 / 180 * 3.141593,
  7445. d = 173 / 180 * 3.141593,
  7446. u = 116 / 180 * 3.141593,
  7447. l = 2.04203545,
  7448. p = 0,
  7449. f = 0,
  7450. g = 0,
  7451. m = [],
  7452. v = [0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21, 22, 24, 26, 29, 31, 34, 36, 39, 41, 44, 46, 49, 51, 54, 56, 59, 61, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 94, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 145, 146, 147, 148, 149, 150, 151, 153, 154, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 168, 169, 170, 171, 172, 173, 175, 176, 177, 178, 179, 180, 182, 183, 184, 185, 186, 187, 188, 190, 191, 192, 193, 194, 195, 197, 198, 199, 200, 201, 202, 204, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 219, 220, 221, 222, 223, 224, 226, 226, 226, 227, 227, 227, 228, 228, 228, 229, 229, 229, 230, 230, 231, 231, 231, 232, 232, 232, 233, 233, 233, 234, 234, 235, 235, 235, 236, 236, 236, 237, 237, 237, 238, 238, 239, 239, 239, 240, 240, 240, 241, 241, 241, 242, 242, 243, 243, 243, 244, 244, 244, 245, 245, 245, 246, 246, 246, 247, 247, 247, 248, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 252, 252, 252, 253, 253, 253, 254, 254, 254, 255],
  7453. S = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 35, 36, 37, 39, 40, 42, 43, 44, 46, 47, 49, 50, 51, 53, 54, 56, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 90, 91, 92, 93, 95, 96, 97, 98, 100, 101, 102, 103, 105, 106, 107, 108, 110, 111, 112, 113, 115, 116, 117, 118, 120, 121, 122, 124, 125, 126, 127, 129, 130, 131, 132, 134, 135, 136, 137, 139, 140, 141, 142, 144, 145, 146, 147, 149, 150, 151, 152, 154, 155, 156, 158, 159, 160, 161, 163, 164, 165, 166, 168, 169, 170, 171, 173, 174, 175, 176, 178, 179, 180, 181, 183, 184, 185, 186, 188, 189, 190, 192, 193, 194, 195, 197, 198, 199, 200, 202, 203, 204, 205, 207, 208, 209, 210, 212, 213, 214, 215, 217, 218, 219, 220, 222, 223, 224, 226, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244, 244, 245, 245, 245, 246, 246, 246, 247, 247, 247, 248, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 252, 252, 252, 253, 253, 253, 254, 254, 254, 255],
  7454. E = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 72, 73, 74, 76, 77, 78, 80, 81, 83, 84, 85, 87, 88, 89, 91, 92, 94, 95, 96, 98, 99, 100, 102, 103, 105, 106, 107, 109, 110, 111, 113, 114, 116, 117, 118, 120, 121, 122, 124, 125, 127, 128, 129, 131, 132, 133, 135, 136, 138, 139, 140, 142, 143, 144, 146, 147, 149, 150, 151, 153, 154, 155, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 199, 200, 201, 201, 202, 203, 203, 204, 205, 205, 206, 207, 207, 208, 209, 209, 210, 211, 211, 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 219, 219, 220, 221, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 235, 235, 236, 237, 237, 238, 239, 239, 240, 241, 241, 242, 243, 243, 244, 245, 245, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, 253, 253, 254, 255];
  7455. this.program = se(a, ve),
  7456. this.setUniforms = function() {
  7457. var t = a.getUniformLocation(this.program, "u_flipY"),
  7458. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7459. a.uniform1f(n, i),
  7460. a.uniform1f(t, 1);
  7461. var v = a.getUniformLocation(this.program, "light");
  7462. a.uniform1f(v, o);
  7463. var S = a.getUniformLocation(this.program, "redness");
  7464. a.uniform1f(S, r);
  7465. var E = a.getUniformLocation(this.program, "skin_he_max"),
  7466. _ = a.getUniformLocation(this.program, "skin_he_min"),
  7467. h = a.getUniformLocation(this.program, "skin_hc_max"),
  7468. I = a.getUniformLocation(this.program, "skin_hc_min"),
  7469. b = a.getUniformLocation(this.program, "skin_hc_axis"),
  7470. T = a.getUniformLocation(this.program, "facts_rotate_c"),
  7471. R = a.getUniformLocation(this.program, "facts_rotate_le"),
  7472. A = a.getUniformLocation(this.program, "facts_rotate_ge");
  7473. a.uniform1f(E, s),
  7474. a.uniform1f(_, c),
  7475. a.uniform1f(h, d),
  7476. a.uniform1f(I, u),
  7477. a.uniform1f(b, l),
  7478. a.uniform1f(T, p),
  7479. a.uniform1f(R, f),
  7480. a.uniform1f(A, g);
  7481. var y = a.getUniformLocation(this.program, "u_originImage");
  7482. a.activeTexture(a.TEXTURE2),
  7483. a.bindTexture(a.TEXTURE_2D, e.inputTexture),
  7484. a.uniform1i(y, 2);
  7485. for (var O = ["lighten_lut"], C = [a.TEXTURE3], N = 0; N < O.length; N++) {
  7486. var w = a.getUniformLocation(this.program, O[N]);
  7487. a.activeTexture(C[N]),
  7488. a.bindTexture(a.TEXTURE_2D, m[N]),
  7489. a.uniform1i(w, N + 3)
  7490. }
  7491. },
  7492. this.setParameters = function(e) {
  7493. void 0 !== e.denoiseLevel && (i = e.denoiseLevel),
  7494. void 0 !== e.lightLevel && (o = e.lightLevel),
  7495. void 0 !== e.rednessLevel && (r = e.rednessLevel, this._updateRedness(r)),
  7496. void 0 !== e.lighteningContrastLevel && this._updateLut(e.lighteningContrastLevel)
  7497. },
  7498. this._updateRedness = function(e) {
  7499. var t, n, a = 3.141593,
  7500. i = e,
  7501. o = i;
  7502. i > 1 && (i = 1),
  7503. i < 0 && (i = 0),
  7504. o > 1 && (o = 1),
  7505. o < 0 && (o = 0),
  7506. p = .8 * i,
  7507. o < .8 && (o = 0),
  7508. (l = (117 - 4 * o) / 180 * a) < (u = (116 - 4 * o) / 180 * a) && (l = u),
  7509. u < a / 2 && (u = a / 2),
  7510. l < a / 2 && (l = a / 2),
  7511. (c = (115 - 4 * o) / 180 * a) < a / 2 && (c = a / 2),
  7512. (d = 173 / 180 * a) > a && (d = a),
  7513. l > a && (l = a),
  7514. (s = 175 / 180 * a) > a && (s = a),
  7515. n = d - l,
  7516. g = (t = s - d) > .01 ? p * n / t: p,
  7517. n = l - u,
  7518. f = (t = u - c) > .01 ? p * n / t: p
  7519. },
  7520. this._updateLut = function(e) {
  7521. var t = null;
  7522. 0 == e && (t = S),
  7523. 1 == e && (t = E),
  7524. 2 == e && (t = v);
  7525. for (var n = [new Uint8Array(t)], i = [256], o = [1], r = 0; r < n.length; r++) a.bindTexture(a.TEXTURE_2D, m[r]),
  7526. a.texImage2D(a.TEXTURE_2D, 0, a.LUMINANCE, i[r], o[r], 0, a.LUMINANCE, a.UNSIGNED_BYTE, n[r])
  7527. },
  7528. this._init = function() {
  7529. var e = null;
  7530. e = S;
  7531. for (var t = [new Uint8Array(e)], n = [256], i = [1], o = 0; o < t.length; o++) {
  7532. var r = a.createTexture();
  7533. a.bindTexture(a.TEXTURE_2D, r),
  7534. a.texImage2D(a.TEXTURE_2D, 0, a.LUMINANCE, n[o], i[o], 0, a.LUMINANCE, a.UNSIGNED_BYTE, t[o]),
  7535. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE),
  7536. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE),
  7537. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR),
  7538. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR),
  7539. m.push(r)
  7540. }
  7541. },
  7542. this._init()
  7543. }
  7544. var Ee = !1;
  7545. function _e() {
  7546. this.programs = [];
  7547. var e = this,
  7548. t = null,
  7549. n = null;
  7550. e.gl = null,
  7551. e.inputTexture = null;
  7552. var a = [],
  7553. i = [],
  7554. o = 0,
  7555. r = 0;
  7556. e._initGl = function(n, s) {
  7557. e.inputTexture = t.createTexture(),
  7558. t.bindTexture(t.TEXTURE_2D, e.inputTexture),
  7559. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE),
  7560. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE),
  7561. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR),
  7562. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR);
  7563. for (var c = 0; c < 4; c++) {
  7564. var d = t.createTexture();
  7565. t.bindTexture(t.TEXTURE_2D, d),
  7566. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE),
  7567. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE),
  7568. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR),
  7569. c < 2 ? t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, n, s, 0, t.RGBA, t.UNSIGNED_BYTE, null) : t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, s, n, 0, t.RGBA, t.UNSIGNED_BYTE, null);
  7570. var u = t.createFramebuffer();
  7571. t.bindFramebuffer(t.FRAMEBUFFER, u),
  7572. t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, d, 0),
  7573. a.push(d),
  7574. i.push(u)
  7575. }
  7576. t.viewport(0, 0, n, s),
  7577. o = n,
  7578. r = s
  7579. },
  7580. e.render = function(s) {
  7581. if (t) {
  7582. var c = 0;
  7583. r == s.videoWidth && o === s.videoHeight && (c = 2),
  7584. t.viewport(0, 0, s.videoWidth, s.videoHeight),
  7585. t.bindTexture(t.TEXTURE_2D, e.inputTexture),
  7586. t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, s);
  7587. for (var d = Ee ? e.programs.length - 1 : 0, u = 0; u <= d; u++) {
  7588. var l = e.programs[u].program;
  7589. t.useProgram(l);
  7590. var p = t.getUniformLocation(l, "u_image");
  7591. e.programs[u].setUniforms(),
  7592. t.bindFramebuffer(t.FRAMEBUFFER, i[c + u % 2]),
  7593. t.clearColor(0, 0, 0, 1),
  7594. t.clear(t.COLOR_BUFFER_BIT),
  7595. t.drawArrays(t.TRIANGLES, 0, 6),
  7596. t.activeTexture(t.TEXTURE0),
  7597. t.bindTexture(t.TEXTURE_2D, a[c + u % 2]),
  7598. t.uniform1i(p, 0)
  7599. }
  7600. t.useProgram(n);
  7601. var f = t.getUniformLocation(n, "u_flipY");
  7602. t.uniform1f(f, -1),
  7603. t.bindFramebuffer(t.FRAMEBUFFER, null),
  7604. t.clearColor(0, 0, 0, 1),
  7605. t.clear(t.COLOR_BUFFER_BIT),
  7606. t.drawArrays(t.TRIANGLES, 0, 6)
  7607. }
  7608. },
  7609. e.setEnableBeauty = function(e) {
  7610. Ee = e
  7611. },
  7612. e.init = function(a, i, o) {
  7613. if ("undefined" == typeof WebGLRenderingContext) throw new Error("NOT_SUPPORT");
  7614. t = o.getContext("webgl"),
  7615. e.gl = t,
  7616. e._initGl(a, i),
  7617. e.programs.push(new de(this, a, i)),
  7618. e.programs.push(new le(this, a, i)),
  7619. e.programs.push(new fe(this, a, i)),
  7620. e.programs.push(new me(this, a, i)),
  7621. e.programs.push(new Se(this, a, i)),
  7622. n = e.programs[0].program
  7623. },
  7624. e.release = function() {
  7625. e.gl = null,
  7626. t = null,
  7627. n = null,
  7628. e.inputTexture = null,
  7629. e.programs = [],
  7630. a = [],
  7631. i = []
  7632. },
  7633. e.setDenoiseLevel = function(t) {
  7634. e.programs.forEach((function(e) {
  7635. e.setParameters && e.setParameters({
  7636. denoiseLevel: t
  7637. })
  7638. }))
  7639. },
  7640. e.setLightLevel = function(t) {
  7641. e.programs.forEach((function(e) {
  7642. e.setParameters && e.setParameters({
  7643. lightLevel: t
  7644. })
  7645. }))
  7646. },
  7647. e.setRednessLevel = function(t) {
  7648. e.programs.forEach((function(e) {
  7649. e.setParameters && e.setParameters({
  7650. rednessLevel: t
  7651. })
  7652. }))
  7653. },
  7654. e.setContrastLevel = function(t) {
  7655. e.programs.forEach((function(e) {
  7656. e.setParameters && e.setParameters({
  7657. lighteningContrastLevel: t
  7658. })
  7659. }))
  7660. },
  7661. e.setSize = function(t, n) {
  7662. e.programs.forEach((function(e) {
  7663. e.setSize && e.setSize(t, n)
  7664. }))
  7665. }
  7666. }
  7667. _e._instance = null,
  7668. _e.getInstance = function() {
  7669. return _e._instance || (_e._instance = new _e),
  7670. _e._instance
  7671. };
  7672. var he = {
  7673. addVideoEffectCapability: function(e) {
  7674. e.videoEffect = {
  7675. canvas: null,
  7676. video: null,
  7677. fps: 30,
  7678. stopChromeBackgroundLoop: null,
  7679. enableBeauty: !1,
  7680. denoiseLevel: 5,
  7681. lightLevel: .35,
  7682. rednessLevel: .5,
  7683. lighteningContrastLevel: 1,
  7684. videoContextInited: !1,
  7685. originVideoTrack: null,
  7686. canvasVideoTrack: null,
  7687. ctx: null
  7688. },
  7689. e._initVideoContext = function() {
  7690. if (e.videoEffect.videoContextInited) throw new Error("Failed to init video context. Already inited");
  7691. if (!e.stream) throw new Error("Failed to init video context. Local Stream not initialized");
  7692. e.videoEffect.originVideoTrack = e.stream.getVideoTracks()[0],
  7693. e.attributes && e.attributes.maxFrameRate && (e.videoEffect.fps = e.attributes.maxFrameRate),
  7694. e.videoEffect.videoContextInited = !0
  7695. },
  7696. e._renderWithWebGL = function(t) {
  7697. return new Promise((function(n) {
  7698. e.videoEffect.canvas || (e.videoEffect.canvas = document.createElement("canvas")),
  7699. e.videoEffect.video || (e.videoEffect.video = document.createElement("video")),
  7700. e.videoEffect.video.setAttribute("autoplay", ""),
  7701. e.videoEffect.video.setAttribute("muted", ""),
  7702. e.videoEffect.video.muted = !0,
  7703. e.videoEffect.video.setAttribute("playsinline", ""),
  7704. e.videoEffect.video.setAttribute("style", "display:none"),
  7705. e.videoEffect.video.srcObject = t;
  7706. var a = t.getVideoTracks()[0].getSettings(),
  7707. i = a.width,
  7708. o = a.height;
  7709. console.log("Width: ".concat(i, ", Height: ").concat(o)),
  7710. e.videoEffect.canvas.setAttribute("width", i),
  7711. e.videoEffect.canvas.setAttribute("height", o),
  7712. e.videoEffect.video.setAttribute("width", i),
  7713. e.videoEffect.video.setAttribute("height", o);
  7714. var r = _e.getInstance();
  7715. r.init(e.videoEffect.video.width, e.videoEffect.video.height, e.videoEffect.canvas),
  7716. r.setDenoiseLevel(e.videoEffect.denoiseLevel),
  7717. r.setLightLevel(e.videoEffect.lightLevel),
  7718. r.setRednessLevel(e.videoEffect.rednessLevel),
  7719. r.setContrastLevel(e.videoEffect.lighteningContrastLevel);
  7720. e.videoEffect.video.addEventListener("playing", (function t() {
  7721. var a = e.videoEffect.canvas.captureStream(e.videoEffect.fps);
  7722. e.videoEffect.video.removeEventListener("playing", t, !0),
  7723. n([a.getVideoTracks()[0], e.videoEffect.video])
  7724. }), !0),
  7725. e.videoEffect.video.play()
  7726. }))
  7727. },
  7728. e._disableEffect = function() {
  7729. e.videoEffect.videoContextInited || e._initVideoContext();
  7730. var t = e.videoEffect.originVideoTrack;
  7731. if (!t) return r.
  7732. default.warning("Video track is null, fail to disable video effect!"),
  7733. Promise.resolve();
  7734. if (e.pc && e.pc.peerConnection && e.pc.peerConnection) {
  7735. var n = (e.pc.peerConnection && e.pc.peerConnection.getSenders()).find((function(e) {
  7736. return e && e.track && "video" == e.track.kind
  7737. }));
  7738. if (n && n.replaceTrack && t) return n.replaceTrack(t)
  7739. }
  7740. return Promise.resolve()
  7741. },
  7742. e._releaseEffect = function() {
  7743. var t;
  7744. return t = e.videoEffect.enableBeauty ? e._disableEffect() : Promise.resolve(),
  7745. _e.getInstance().release(),
  7746. e.videoEffect.videoContextInited = !1,
  7747. e.videoEffect.canvasVideoTrack = null,
  7748. t
  7749. },
  7750. e._enableEffect = function() {
  7751. return e.videoEffect.videoContextInited || e._initVideoContext(),
  7752. e.videoEffect.originVideoTrack ? e.videoEffect.canvasVideoTrack ? (e._showEffectInLocalPlayer(), e._replaceWithCanvasTrack()) : e._renderWithWebGL(e.stream).then((function(t) {
  7753. var n = ne()(t, 2),
  7754. a = n[0],
  7755. i = n[1];
  7756. e.videoEffect.canvasVideoTrack = a;
  7757. var o = _e.getInstance();
  7758. return requestAnimationFrame((function t() {
  7759. e.videoEffect.enableBeauty && o.render(i),
  7760. e.videoEffect.videoContextInited && requestAnimationFrame(t)
  7761. })),
  7762. g.isChrome() && document.addEventListener("visibilitychange", (function() {
  7763. document.hidden;
  7764. document.hidden ? e.videoEffect.stopChromeBackgroundLoop = function(e, t) {
  7765. var n = 1 / t,
  7766. a = new AudioContext,
  7767. i = a.createGain();
  7768. i.gain.value = 0,
  7769. i.connect(a.destination),
  7770. function t() {
  7771. var r = a.createOscillator();
  7772. r.onended = t,
  7773. r.connect(i),
  7774. r.start(0),
  7775. r.stop(a.currentTime + n),
  7776. e(a.currentTime),
  7777. o && (r.onended = function() {
  7778. a.close()
  7779. })
  7780. } ();
  7781. var o = !1;
  7782. return function() {
  7783. o = !0
  7784. }
  7785. } ((function() {
  7786. e.videoEffect.enableBeauty && o.render(i)
  7787. }), e.videoEffect.fps) : e.videoEffect.stopChromeBackgroundLoop && (e.videoEffect.stopChromeBackgroundLoop(), e.videoEffect.stopChromeBackgroundLoop = null)
  7788. }), !1),
  7789. e._showEffectInLocalPlayer(),
  7790. e._replaceWithCanvasTrack()
  7791. })) : (r.
  7792. default.warning("Video track is null, fail to enable video effect!"), Promise.resolve())
  7793. },
  7794. e._showEffectInLocalPlayer = function() {
  7795. if (e.player) {
  7796. var t = e.player.div.children[0];
  7797. if ("none" !== t.style.display && (e.player.div.appendChild(e.videoEffect.canvas), "video" === t.tagName.toLowerCase())) {
  7798. var n = t.getAttribute("style");
  7799. e.videoEffect.canvas.setAttribute("style", n),
  7800. "none" !== t.style.display && (t.style.display = "none")
  7801. }
  7802. }
  7803. },
  7804. e._removeEffectFromLocalPlayer = function() {
  7805. if (e.player && e.player.div && e.videoEffect.enableBeauty && e.videoEffect.canvas) {
  7806. e.player.div.removeChild(e.videoEffect.canvas);
  7807. var t = e.player.div.children[0];
  7808. "video" === t.tagName.toLowerCase() && (e.videoEffect.canvas.style.display = "none", t.style.display = "block")
  7809. }
  7810. },
  7811. e._replaceWithCanvasTrack = function() {
  7812. var t = null;
  7813. e.pc && e.pc.peerConnection && e.pc.peerConnection && (t = (e.pc.peerConnection && e.pc.peerConnection.getSenders()).find((function(e) {
  7814. return e && e.track && "video" == e.track.kind
  7815. })));
  7816. return t && t.replaceTrack && e.videoEffect.canvasVideoTrack ? t.replaceTrack(e.videoEffect.canvasVideoTrack) : Promise.resolve()
  7817. },
  7818. e.setBeautyEffectOptions = function() {
  7819. var t = ee()(Z.a.mark((function t(n, a) {
  7820. var i, o = arguments;
  7821. return Z.a.wrap((function(t) {
  7822. for (;;) switch (t.prev = t.next) {
  7823. case 0:
  7824. if (Object(z.checkValidBoolean)(n, "enabled"), i = _e.getInstance(), e.videoEffect.enableBeauty == n) {
  7825. t.next = 14;
  7826. break
  7827. }
  7828. if (i.setEnableBeauty(n), !n) {
  7829. t.next = 9;
  7830. break
  7831. }
  7832. return t.next = 7,
  7833. e._enableEffect();
  7834. case 7:
  7835. t.next = 12;
  7836. break;
  7837. case 9:
  7838. return e._removeEffectFromLocalPlayer(),
  7839. t.next = 12,
  7840. e._releaseEffect();
  7841. case 12:
  7842. e.videoEffect.enableBeauty = n,
  7843. s.b.reportApiInvoke(e.sid, {
  7844. callback: null,
  7845. options: o,
  7846. name: "Stream.setBeautyEffectOptions",
  7847. tag: "tracer"
  7848. });
  7849. case 14:
  7850. if (n) {
  7851. t.next = 16;
  7852. break
  7853. }
  7854. return t.abrupt("return");
  7855. case 16:
  7856. if (!a) {
  7857. t.next = 20;
  7858. break
  7859. }
  7860. Object(z.checkValidObject)(a, "options"),
  7861. t.next = 21;
  7862. break;
  7863. case 20:
  7864. return t.abrupt("return");
  7865. case 21:
  7866. if (void 0 !== a.smoothnessLevel && (Object(z.checkValidFloatNumber)(a.smoothnessLevel, "smoothnessLevel", 0, 1), e.videoEffect.denoiseLevel = 10 * a.smoothnessLevel, e.videoEffect.denoiseLevel < .1 && (e.videoEffect.denoiseLevel = .1), i.setDenoiseLevel(e.videoEffect.denoiseLevel)), void 0 !== a.lighteningLevel && (Object(z.checkValidFloatNumber)(a.lighteningLevel, "lighteningLevel", 0, 1), e.videoEffect.lightLevel = a.lighteningLevel / 2, e.videoEffect.lightLevel < .01 && (e.videoEffect.lightLevel = .01), i.setLightLevel(e.videoEffect.lightLevel)), void 0 !== a.rednessLevel && (Object(z.checkValidFloatNumber)(a.rednessLevel, "rednessLevel", 0, 1), e.videoEffect.rednessLevel = a.rednessLevel, e.videoEffect.rednessLevel < .01 && (e.videoEffect.rednessLevel = .01), i.setRednessLevel(e.videoEffect.rednessLevel)), void 0 === a.lighteningContrastLevel) {
  7867. t.next = 29;
  7868. break
  7869. }
  7870. if (0 === a.lighteningContrastLevel || 1 === a.lighteningContrastLevel || 2 === a.lighteningContrastLevel) {
  7871. t.next = 27;
  7872. break
  7873. }
  7874. throw new Error("Invalid lighteningContrastLevel: The value should be 0, 1 or 2.");
  7875. case 27:
  7876. e.videoEffect.lighteningContrastLevel = parseFloat(a.lighteningContrastLevel),
  7877. i.setContrastLevel(e.videoEffect.lighteningContrastLevel);
  7878. case 29:
  7879. case "end":
  7880. return t.stop()
  7881. }
  7882. }), t)
  7883. })));
  7884. return function(e, n) {
  7885. return t.apply(this, arguments)
  7886. }
  7887. } ()
  7888. },
  7889. restoreVideoEffect: function(e) {
  7890. return e.videoEffect.enableBeauty ? e._enableEffect() : Promise.resolve()
  7891. },
  7892. disableVideoEffect: function(e) {
  7893. return e._releaseEffect ? e._releaseEffect() : Promise.resolve()
  7894. },
  7895. applyEffectInPlayer: function(e) {
  7896. e.videoEffect.enableBeauty && e.videoEffect.canvas && e._showEffectInLocalPlayer()
  7897. },
  7898. removeEffectFromLocalPlayer: function(e) {
  7899. e._removeEffectFromLocalPlayer()
  7900. },
  7901. replaceWithCanvasTrack: function(e) {
  7902. return e.videoEffect.enableBeauty ? e._replaceWithCanvasTrack() : Promise.resolve()
  7903. },
  7904. checkVideoEffectEnabled: function(e) {
  7905. if (e.videoEffect.enableBeauty && e.videoEffect && e.videoEffect.videoContextInited) {
  7906. return r.
  7907. default.error("Operation not permitted: ".concat("VIDEO_EFFECT_ENABLED")),
  7908. "VIDEO_EFFECT_ENABLED"
  7909. }
  7910. return ! 1
  7911. }
  7912. },
  7913. Ie = a(9),
  7914. be = a.n(Ie),
  7915. Te = function(e) {
  7916. Object(z.checkValidString)(e, "profileName"),
  7917. -1 === (e = e.toLowerCase()).indexOf("_") && (e += "_1"),
  7918. Object(z.checkValidEnum)(e, "profileName", Object.keys(o.SUPPORT_RESOLUTION_LIST));
  7919. var t = o.SUPPORT_RESOLUTION_LIST[e];
  7920. t || (e = Object(o.getParameter)("DEFAULT_PROFILE"), t = o.SUPPORT_RESOLUTION_LIST[e]);
  7921. var n = {
  7922. profileName: e,
  7923. video: {
  7924. width: t[0],
  7925. height: t[1]
  7926. },
  7927. attributes: {
  7928. resolution: "".concat(t[0], "x").concat(t[1]),
  7929. minFrameRate: t[2],
  7930. maxFrameRate: t[3],
  7931. minVideoBW: t[4],
  7932. maxVideoBW: t[5]
  7933. }
  7934. };
  7935. return t[2] && t[3] && (n.video.frameRate = {
  7936. ideal: t[2],
  7937. max: t[3]
  7938. }),
  7939. t[6] && t[7] && (n.screen = {
  7940. width: t[0],
  7941. height: t[1],
  7942. frameRate: {
  7943. min: t[6],
  7944. max: t[7]
  7945. }
  7946. }),
  7947. n
  7948. },
  7949. Re = function(e) {
  7950. return Object.keys(o.SUPPORT_RESOLUTION_LIST).filter((function(t) {
  7951. var n = o.SUPPORT_RESOLUTION_LIST[t],
  7952. a = ["width", "height", "frameRate"];
  7953. for (var i in a) {
  7954. var r = a[i];
  7955. if (e[r] && n[i]) {
  7956. if ("number" == typeof e[r].max && e[r].max < n[i]) return ! 1;
  7957. if ("number" == typeof e[r].min && e[r].min > n[i]) return ! 1
  7958. }
  7959. }
  7960. return ! 0
  7961. })).reverse()
  7962. },
  7963. Ae = function(e) {
  7964. var t = o.AUDIO_PROFILE_SETTINGS[e] || o.AUDIO_PROFILE_SETTINGS.
  7965. default;
  7966. return {
  7967. highQuality:
  7968. t[0],
  7969. stereo: t[1],
  7970. speech: t[2],
  7971. lowQuality: t[3]
  7972. }
  7973. };
  7974. var ye = function(e) {
  7975. var t = c();
  7976. if (t.params = E()({},
  7977. e), t.stream = e.stream, t.url = e.url, t.onClose = void 0, t.local = !1, t.videoSource = e.videoSource, t.audioSource = e.audioSource, e.video = !(!e.videoSource && !e.video), t.video = e.video, e.audio = !(!e.audioSource && !e.audio), t.audio = e.audio, t.screen = !!e.screen, t.screenAudio = !!e.screenAudio, t.screenAttributes = {
  7978. width: 1920,
  7979. height: 1080,
  7980. maxFr: 5,
  7981. minFr: 1
  7982. },
  7983. t.videoSize = e.videoSize, t.player = void 0, t.audioLevelHelper = null, e.attributes = e.attributes || {},
  7984. t.attributes = e.attributes, t.microphoneId = e.microphoneId, t.cameraId = e.cameraId, t.facingMode = e.facingMode, t.inSwitchDevice = !1, t.userMuteVideo = !1, t.userMuteAudio = !1, t.peerMuteVideo = !1, t.peerMuteAudio = !1, t.lowStream = null, t.videoWidth = 0, t.videoHeight = 0, t.streamId = e.streamID, t.userId = null, t.uintId = e.uintUID || null, t.mirror = !1 !== e.mirror, t.DTX = e.audioProcessing && e.audioProcessing.DTX, t.audioProcessing = e.audioProcessing, t.highQuality = !1, t.stereo = !1, t.speech = !1, t.screen || delete t.screen, !(void 0 === t.videoSize || t.videoSize instanceof Array && 4 === t.videoSize.length)) throw Error("Invalid Video Size");
  7985. function n() {
  7986. var e = {};
  7987. t.getVideoTrack() === this ? (r.
  7988. default.debug("Video Track Ended"), e.type = "videoTrackEnded", e.track = this) : t.getAudioTrack() === this ? (r.
  7989. default.debug("Audio Track Ended"), e.type = "audioTrackEnded", e.track = this) : r.
  7990. default.debug("Detached Track ended", this.kind, this.label, this),
  7991. e.type && t.dispatchEvent(e)
  7992. }
  7993. return t.videoSize = [640, 480, 640, 480],
  7994. void 0 !== e.local && !0 !== e.local || (t.local = !0),
  7995. t.initialized = !t.local,
  7996. t._streamInitID = null,
  7997. function(e) {
  7998. e.audioMixing = {
  7999. audioContextInited: !1,
  8000. defaultVolume: 100,
  8001. inEarMonitoring: "FILE",
  8002. sounds: {},
  8003. states: {
  8004. IDLE: "IDLE",
  8005. STARTING: "STARTING",
  8006. BUSY: "BUSY",
  8007. PAUSED: "PAUSED"
  8008. },
  8009. inEarMonitoringModes: {
  8010. NONE: "NONE",
  8011. FILE: "FILE",
  8012. MICROPHONE: "MOCROPHONE",
  8013. ALL: "ALL"
  8014. },
  8015. ctx: null,
  8016. mediaStreamSource: null,
  8017. mediaStreamDest: null,
  8018. buffer: {}
  8019. },
  8020. e._initSoundIfNotExists = function(t, n) {
  8021. e.audioMixing.sounds[t] || (e.audioMixing.sounds[t] = {
  8022. soundId: t,
  8023. state: "IDLE",
  8024. muted: e.userMuteAudio,
  8025. filePath: n,
  8026. volume: e.audioMixing.defaultVolume,
  8027. startAt: null,
  8028. startOffset: null,
  8029. pauseAt: null,
  8030. pauseOffset: null,
  8031. resumeAt: null,
  8032. resumeOffset: null,
  8033. stopAt: null,
  8034. options: null,
  8035. source: null
  8036. })
  8037. },
  8038. e._initSoundIfNotExists( - 1),
  8039. e.loadAudioBuffer = function(t, n, a) {
  8040. var i = s.b.reportApiInvoke(e.sid, {
  8041. callback: a,
  8042. name: "Stream.loadAudioBuffer",
  8043. options: arguments,
  8044. tag: "tracer"
  8045. });
  8046. Object(z.checkValidString)(n, "url", 1, 1024, !1),
  8047. Object(z.checkValidString)(t, "id", 1, 1024, !1);
  8048. var o = function(t) {
  8049. r.
  8050. default.error("[".concat(e.streamId, "] loadAudioBuffer Failed: ") + t),
  8051. i(I.
  8052. default.LOAD_AUDIO_FAILED)
  8053. },
  8054. c = new XMLHttpRequest;
  8055. c.open("GET", n, !0),
  8056. c.responseType = "arraybuffer",
  8057. c.onload = function() {
  8058. if (c.status > 400) o("".concat(c.status, " ").concat(c.statusText));
  8059. else {
  8060. var n = c.response;
  8061. e.audioMixing.audioContextInited || e._initAudioContext(),
  8062. e.audioMixing.ctx.decodeAudioData(n, (function(n) {
  8063. e.audioMixing.buffer[t] = n,
  8064. i(null)
  8065. }), (function(t) {
  8066. r.
  8067. default.error("[".concat(e.streamId, "] decodeAudioData Failed: "), t),
  8068. i(t)
  8069. }))
  8070. }
  8071. },
  8072. c.onerror = function() {
  8073. return o("load error")
  8074. },
  8075. c.ontimeout = function() {
  8076. return o("timeout")
  8077. },
  8078. c.send()
  8079. },
  8080. e.createAudioBufferSource = function(t) {
  8081. var n = s.b.reportApiInvoke(e.sid, {
  8082. name: "Stream.createAudioBufferSource",
  8083. options: arguments,
  8084. tag: "tracer"
  8085. });
  8086. if (e.audioMixing.buffer[t.id]) {
  8087. var a = e.audioMixing.buffer[t.id],
  8088. i = e.audioMixing.ctx.createBufferSource();
  8089. i.buffer = a;
  8090. var o = e.audioMixing.ctx.createGain();
  8091. if (i.connect(o), o.connect(e.audioMixing.mediaStreamDest), i.gainNode = o, t.loop) i.loop = !0,
  8092. i.start(0, t.playTime / 1e3);
  8093. else if (t.cycle > 1) if (Object(g.isChrome)()) {
  8094. i.loop = !0;
  8095. var c = t.cycle * a.duration * 1e3 - (t.playTime || 0);
  8096. i.start(0, t.playTime / 1e3, c / 1e3)
  8097. } else r.
  8098. default.warning("[".concat(e.streamId, "] Cycle Param is ignored by current browser")),
  8099. i.start(0, t.playTime / 1e3);
  8100. else i.start(0, t.playTime / 1e3);
  8101. var d = e.audioMixing.sounds[t.soundId];
  8102. return d.source = i,
  8103. e._flushAudioMixingMuteStatus(),
  8104. i.addEventListener("ended", (function() {
  8105. i === d.source && e.dispatchEvent({
  8106. type: "audioSourceEnded",
  8107. soundId: t.soundId,
  8108. source: i,
  8109. sound: d
  8110. })
  8111. })),
  8112. n(),
  8113. i
  8114. }
  8115. var u = "AUDIOBUFFER_NOT_FOUND";
  8116. return r.
  8117. default.error("[".concat(e.streamId, "] "), u, t.id),
  8118. n(!1),
  8119. !1
  8120. },
  8121. e.on("audioSourceEnded", (function(t) {
  8122. var n = t.source,
  8123. a = t.sound;
  8124. a && a.state === e.audioMixing.states.BUSY && !a.pauseAt && (a.state = e.audioMixing.states.IDLE, a.startAt = null, a.startOffset = null, a.resumeAt = null, a.resumeOffset = null, n.gainNode && n.gainNode.disconnect && n.gainNode.disconnect(), n.buffer = null, e.audioMixing.mediaStreamSource.connect(e.audioMixing.mediaStreamDest))
  8125. })),
  8126. e.clearAudioBufferSource = function() {
  8127. e.audioBufferSource.forEach((function(e) {
  8128. e.stop()
  8129. }))
  8130. },
  8131. e._isSoundExists = function(t) {
  8132. return !! e.audioMixing.sounds[t.soundId] || (r.
  8133. default.error("SoundId not exists. #".concat(t.soundId)), !1)
  8134. },
  8135. e._initAudioContext = function() {
  8136. if (e.audioMixing.audioContextInited) throw new Error("Failed to init audio context. Already inited");
  8137. if (!e.stream) throw new Error("Failed to init audio context. Local Stream not initialized");
  8138. e.audioMixing.ctx = Object(X.a)(),
  8139. e.audioMixing.mediaStreamSource = e.audioMixing.ctx.createMediaStreamSource(e.stream),
  8140. e.audioMixing.mediaStreamDest = e.audioMixing.ctx.createMediaStreamDestination(),
  8141. e.audioMixing.mediaStreamSource.connect(e.audioMixing.mediaStreamDest);
  8142. var t = e.stream.getVideoTracks()[0];
  8143. if (t && e.audioMixing.mediaStreamDest.stream.addTrack(t), e._originStream = e.stream, e._isAudioMuted() ? (e._unmuteAudio(), e.stream = e.audioMixing.mediaStreamDest.stream, e._muteAudio()) : e.stream = e.audioMixing.mediaStreamDest.stream, e.audioLevelHelper = null, e.pc && e.pc.peerConnection && e.pc.peerConnection) {
  8144. var n = (e.pc.peerConnection && e.pc.peerConnection.getSenders()).find((function(e) {
  8145. return e && e.track && "audio" == e.track.kind
  8146. })),
  8147. a = e.audioMixing.mediaStreamDest.stream.getAudioTracks()[0];
  8148. n && n.replaceTrack && a && n.replaceTrack(a)
  8149. }
  8150. e.audioMixing.audioContextInited = !0
  8151. },
  8152. e._cleanupAudioMixing = function() {
  8153. if (e.audioMixing.audioContextInited) {
  8154. for (var t in e.audioMixing.sounds) {
  8155. var n = e.audioMixing.sounds[t];
  8156. n.state !== e.audioMixing.states.BUSY && n.state !== e.audioMixing.states.PAUSED || e._stopOneEffect({
  8157. soundId: t
  8158. })
  8159. }
  8160. e.audioLevelHelper = null,
  8161. e.audioMixing.audioContextInited = !1
  8162. }
  8163. },
  8164. e._reloadInEarMonitoringMode = function(t) {
  8165. if (t) {
  8166. if (!e.audioMixing.inEarMonitoringModes[t]) return r.
  8167. default.error("[".concat(e.streamId, "] Invalid InEarMonitoringMode ").concat(t));
  8168. e.audioMixing.inEarMonitoring = t
  8169. }
  8170. switch (e.audioMixing.audioContextInited || e._initAudioContext(), e.audioMixing.inEarMonitoring) {
  8171. case e.audioMixing.inEarMonitoringModes.FILE:
  8172. e.audioMixing.mediaStreamSource.connectedToDestination && (e.audioMixing.mediaStreamSource.disconnect(e.audioMixing.ctx.destination), e.audioMixing.mediaStreamSource.connectedToDestination = !1);
  8173. case e.audioMixing.inEarMonitoringModes.ALL:
  8174. for (var n in e.audioMixing.sounds) {
  8175. var a = e.audioMixing.sounds[n];
  8176. a && a.source && !a.source.connectedToDestination && (a.source.gainNode.connect(e.audioMixing.ctx.destination), a.source.connectedToDestination = !0)
  8177. }
  8178. }
  8179. switch (e.audioMixing.inEarMonitoring) {
  8180. case e.audioMixing.inEarMonitoringModes.MICROPHONE:
  8181. e.audioMixing.source.forEach((function(t) {
  8182. t.connectedToDestination && (t.gainNode.disconnect(e.audioMixing.ctx.destination), t.connectedToDestination = !1)
  8183. }));
  8184. case e.audioMixing.inEarMonitoringModes.ALL:
  8185. e.audioMixing.mediaStreamSource.connectedToDestination || (e.audioMixing.mediaStreamSource.connect(e.audioMixing.ctx.destination), e.audioMixing.mediaStreamSource.connectedToDestination = !0)
  8186. }
  8187. },
  8188. e._startAudioMixingBufferSource = function(t) {
  8189. e.audioMixing.audioContextInited || e._initAudioContext();
  8190. var n = {
  8191. soundId: t.soundId,
  8192. id: t.filePath,
  8193. loop: t.loop,
  8194. cycle: t.cycle,
  8195. playTime: t.playTime || 0
  8196. },
  8197. a = t.replace,
  8198. i = e.createAudioBufferSource(n);
  8199. return i.sound = e.audioMixing.sounds[t.soundId],
  8200. i ? (i.addEventListener("ended", e._audioMixingFinishedListener, {
  8201. once: !0
  8202. }), e._reloadInEarMonitoringMode(), a && e.audioMixing.mediaStreamSource.disconnect(e.audioMixing.mediaStreamDest), i) : null
  8203. },
  8204. e._stopAudioMixingBufferSource = function(t) {
  8205. var n = e.audioMixing.sounds[t.soundId].source;
  8206. return n ? (n.removeEventListener("ended", e._audioMixingFinishedListener), e.audioMixing.mediaStreamSource.connect(e.audioMixing.mediaStreamDest), n.stop(), n.gainNode && n.gainNode.disconnect && n.gainNode.disconnect(), n.buffer = null, n) : null
  8207. },
  8208. e._flushAudioMixingMuteStatus = function(t) {
  8209. for (var n in e.audioMixing.sounds) {
  8210. var a = e.audioMixing.sounds[n];
  8211. a && (void 0 !== t && (a.muted = !!t), a.source && (a.muted ? a.source.gainNode.gain.value = 0 : a.source.gainNode.gain.value = a.volume / 100))
  8212. }
  8213. },
  8214. e._handleAudioMixingInvalidStateError = function(t, n, a) {
  8215. var i = e.audioMixing.sounds[n.soundId],
  8216. o = -1 === n.soundId ? "INVALID_AUDIO_MIXING_STATE": "INVALID_PLAY_EFFECT_STATE";
  8217. r.
  8218. default.error("[".concat(e.streamId, "] Cannot ").concat(t, ": ").concat(o, ", state is ").concat(i.state)),
  8219. a && a(o)
  8220. },
  8221. e._handleAudioMixingNoSourceError = function(t, n, a) {
  8222. e.audioMixing.sounds[n.soundId].state = e.audioMixing.states.IDLE;
  8223. var i = -1 === n.soundId ? "NO_AUDIO_MIXING_SOURCE": "NO_EFFECT_SOURCE";
  8224. r.
  8225. default.error("[".concat(e.streamId, "] Cannot ").concat(t, ": ").concat(i)),
  8226. a && a(i)
  8227. },
  8228. e._getOneEffectStates = function(t) {
  8229. var n = e.audioMixing.sounds[t.soundId];
  8230. return function() {
  8231. return n ? {
  8232. state: n.state,
  8233. startAt: n.startAt,
  8234. resumeAt: n.resumeAt,
  8235. pauseOffset: n.pauseOffset,
  8236. pauseAt: n.pauseAt,
  8237. resumeOffset: n.resumeOffset,
  8238. stopAt: n.stopAt,
  8239. duration: e._getOneEffectDuration(t),
  8240. position: e._getOneEffectCurrentPosition(t)
  8241. }: {}
  8242. }
  8243. },
  8244. e._audioMixingFinishedListener = function() {
  8245. var t = this.sound;
  8246. t.state === e.audioMixing.states.IDLE && e.audioMixing.buffer[t.options.filePath] && !t.options.cacheResource && (r.
  8247. default.debug("Recycled buffer ".concat(t.options.filePath)), delete e.audioMixing.buffer[t.options.filePath]),
  8248. -1 === t.soundId && e.dispatchEvent({
  8249. type: "audioMixingFinished"
  8250. })
  8251. },
  8252. e._playOneEffect = function(t, n) {
  8253. Object(z.checkValidObject)(t, "options");
  8254. var a = t.soundId,
  8255. i = (t.filePath, t.cacheResource);
  8256. t.cycle,
  8257. t.loop,
  8258. t.playTime,
  8259. t.replace;
  8260. if (Object(g.isSafari)() && Object(g.getBrowserVersion)() < 12) {
  8261. var o = "BROWSER_NOT_SUPPORT";
  8262. return r.
  8263. default.error("[".concat(e.streamId, "] Cannot _playOneEffect: "), o),
  8264. n(o)
  8265. }
  8266. e.audioMixing.audioContextInited || e._initAudioContext(),
  8267. e._initSoundIfNotExists(a);
  8268. var s = e.audioMixing.sounds[a];
  8269. if (s.state === e.audioMixing.states.IDLE) {
  8270. if (void 0 !== t.cycle && !t.cycle > 0) {
  8271. o = "Invalid Parmeter cycle: " + t.cycle;
  8272. return r.
  8273. default.error("[".concat(e.streamId, "] ").concat(a), o),
  8274. n(o)
  8275. }
  8276. if (Object(z.isEmpty)(i) && (t.cacheResource = !0), s.state = e.audioMixing.states.STARTING, s.options = t, e.audioMixing.buffer[t.filePath]) {
  8277. var c = e._startAudioMixingBufferSource(t);
  8278. if (c) return s.source = c,
  8279. s.startAt = Date.now(),
  8280. s.resumeAt = null,
  8281. s.pauseOffset = null,
  8282. s.pauseAt = null,
  8283. s.resumeOffset = null,
  8284. s.stopAt = null,
  8285. s.startOffset = t.playTime || 0,
  8286. s.state = e.audioMixing.states.BUSY,
  8287. e._flushAudioMixingMuteStatus(),
  8288. n(null);
  8289. s.state = e.audioMixing.states.IDLE;
  8290. var d = "CREATE_BUFFERSOURCE_FAILED";
  8291. if (n) return n(d);
  8292. r.
  8293. default.error("[".concat(e.streamId, "] "), d)
  8294. } else e.loadAudioBuffer(t.filePath, t.filePath, (function(a) {
  8295. if (a) s.state = e.audioMixing.states.IDLE,
  8296. n ? n(a) : r.
  8297. default.error("[".concat(e.streamId, "] "), a);
  8298. else {
  8299. var i = e._startAudioMixingBufferSource(t);
  8300. if (i) return s.source = i,
  8301. s.startAt = Date.now(),
  8302. s.resumeAt = null,
  8303. s.pauseOffset = null,
  8304. s.pauseAt = null,
  8305. s.resumeOffset = null,
  8306. s.stopAt = null,
  8307. s.startOffset = t.playTime || 0,
  8308. s.state = e.audioMixing.states.BUSY,
  8309. e._flushAudioMixingMuteStatus(),
  8310. n(null);
  8311. s.state = e.audioMixing.states.IDLE;
  8312. a = "CREATE_BUFFERSOURCE_FAILED";
  8313. if (n) return n(a);
  8314. r.
  8315. default.error("[".concat(e.streamId, "] "), a)
  8316. }
  8317. }))
  8318. } else e._handleAudioMixingInvalidStateError("_playEffect", t, n)
  8319. },
  8320. e._stopOneEffect = function(t, n) {
  8321. var a = e.audioMixing.sounds[t.soundId];
  8322. return e._isSoundExists(t) ? a.state === e.audioMixing.states.BUSY || a.state === e.audioMixing.states.PAUSED ? (e._stopAudioMixingBufferSource(t), a.stopAt = Date.now(), a.state = e.audioMixing.states.IDLE, e.audioMixing.buffer[a.options.filePath] && !a.options.cacheResource && (r.
  8323. default.debug("Recycled buffer ".concat(a.options.filePath)), delete e.audioMixing.buffer[a.options.filePath]), void(n && n(null))) : void e._handleAudioMixingInvalidStateError("_stopOneEffect", t, n) : n("SOUND_NOT_EXISTS")
  8324. },
  8325. e._pauseOneEffect = function(t, n) {
  8326. var a = e.audioMixing.sounds[t.soundId];
  8327. if (a.state === e.audioMixing.states.BUSY) return e._stopAudioMixingBufferSource(t) ? (a.pauseAt = Date.now(), a.state = e.audioMixing.states.PAUSED, a.resumeAt ? a.pauseOffset = a.pauseAt - a.resumeAt + a.resumeOffset: a.pauseOffset = a.pauseAt - a.startAt + a.startOffset, n && n(null)) : void e._handleAudioMixingNoSourceError("_pauseOneEffect", t, n);
  8328. e._handleAudioMixingInvalidStateError("_pauseOneEffect", t, n)
  8329. },
  8330. e._resumeOneEffect = function(t, n) {
  8331. var a = e.audioMixing.sounds[t.soundId];
  8332. if (a.state === e.audioMixing.states.PAUSED) {
  8333. var i = {
  8334. soundId: t.soundId,
  8335. filePath: a.options.filePath,
  8336. cycle: a.options.cycle,
  8337. loop: a.options.loop,
  8338. playTime: a.pauseOffset,
  8339. replace: a.options.replace
  8340. },
  8341. o = e._startAudioMixingBufferSource(i);
  8342. if (!o) {
  8343. var s = "CREATE_BUFFERSOURCE_FAILED";
  8344. return n(s),
  8345. void r.
  8346. default.error("[".concat(e.streamId, "] "), s)
  8347. }
  8348. a.source = o,
  8349. a.resumeAt = Date.now(),
  8350. a.resumeOffset = a.pauseOffset,
  8351. a.state = e.audioMixing.states.BUSY,
  8352. a.pauseAt = null,
  8353. a.pauseOffset = null,
  8354. n(null)
  8355. } else e._handleAudioMixingInvalidStateError("_resumeOneEffect", t, n)
  8356. },
  8357. e._getOneEffectDuration = function(t) {
  8358. var n = e.audioMixing.sounds[t.soundId];
  8359. return n.options && n.options.filePath && e.audioMixing.buffer[n.options.filePath] ? 1e3 * e.audioMixing.buffer[n.options.filePath].duration: null
  8360. },
  8361. e._getOneEffectCurrentPosition = function(t, n) {
  8362. var a = e.audioMixing.sounds[t.soundId];
  8363. return a.state === e.audioMixing.states.PAUSED ? a.pauseOffset % e._getOneEffectDuration(t) : a.state === e.audioMixing.states.BUSY ? a.resumeAt ? (Date.now() - a.resumeAt + a.resumeOffset) % e._getOneEffectDuration(t) : (Date.now() - a.startAt + a.startOffset) % e._getOneEffectDuration(t) : void(n && e._handleAudioMixingInvalidStateError("_getOneEffectCurrentPosition", t))
  8364. },
  8365. e._setOneEffectPosition = function(t, n, a) {
  8366. var i = e.audioMixing.sounds[t.soundId];
  8367. if (i.state === e.audioMixing.states.BUSY) {
  8368. if (!e._stopAudioMixingBufferSource(t)) return void e._handleAudioMixingNoSourceError("_setOneEffectPosition", t, a);
  8369. var o = {
  8370. soundId: t.soundId,
  8371. filePath: i.options.filePath,
  8372. loop: i.options.loop,
  8373. cycle: i.options.cycle,
  8374. playTime: n
  8375. },
  8376. s = e._startAudioMixingBufferSource(o);
  8377. if (!s) {
  8378. var c = "CREATE_BUFFERSOURCE_FAILED";
  8379. return a && a(c),
  8380. void r.
  8381. default.error("[".concat(e.streamId, "] "), c)
  8382. }
  8383. i.source = s,
  8384. i.startAt = Date.now(),
  8385. i.startOffset = n,
  8386. i.resumeAt = null,
  8387. i.resumeOffset = null,
  8388. i.pauseOffset = null,
  8389. i.pauseAt = null
  8390. } else {
  8391. if (i.state !== e.audioMixing.states.PAUSED) return void e._handleAudioMixingInvalidStateError("_setOneEffectPosition", t, a);
  8392. i.pauseOffset = n
  8393. }
  8394. a && a(null)
  8395. },
  8396. e.startAudioMixing = function(t, n) {
  8397. var a = s.b.reportApiInvoke(e.sid, {
  8398. callback: function(t) {
  8399. if (t) return n && n(t);
  8400. e.dispatchEvent({
  8401. type: "audioMixingPlayed"
  8402. }),
  8403. n && n(null)
  8404. },
  8405. getStates: e._getOneEffectStates({
  8406. soundId: -1
  8407. }),
  8408. name: "Stream.startAudioMixing",
  8409. options: t
  8410. });
  8411. Object(z.checkValidObject)(t, "options");
  8412. var i = t.filePath,
  8413. r = t.cacheResource,
  8414. c = t.cycle,
  8415. d = t.loop,
  8416. u = t.playTime,
  8417. l = t.replace;
  8418. Object(z.checkValidString)(i, "filePath", 1, Object(o.getParameter)("FILEPATH_LENMAX"), !1),
  8419. Object(z.checkValidNumber)(u, "playTime", 0, 1e8),
  8420. !Object(z.isEmpty)(c) && Object(z.checkValidNumber)(c, "cycle"),
  8421. !Object(z.isEmpty)(d) && Object(z.checkValidBoolean)(d, "loop"),
  8422. !Object(z.isEmpty)(l) && Object(z.checkValidBoolean)(l, "replace"),
  8423. !Object(z.isEmpty)(r) && Object(z.checkValidBoolean)(r, "cacheResource");
  8424. var p = E()({
  8425. soundId: -1
  8426. },
  8427. t);
  8428. e._playOneEffect(p, a)
  8429. },
  8430. e.stopAudioMixing = function(t) {
  8431. var n = s.b.reportApiInvoke(e.sid, {
  8432. callback: t,
  8433. getStates: e._getOneEffectStates({
  8434. soundId: -1
  8435. }),
  8436. name: "Stream.stopAudioMixing"
  8437. });
  8438. e._stopOneEffect({
  8439. soundId: -1
  8440. },
  8441. n)
  8442. },
  8443. e.pauseAudioMixing = function(t) {
  8444. var n = s.b.reportApiInvoke(e.sid, {
  8445. callback: t,
  8446. getStates: e._getOneEffectStates({
  8447. soundId: -1
  8448. }),
  8449. name: "Stream.pauseAudioMixing"
  8450. });
  8451. return e._pauseOneEffect({
  8452. soundId: -1
  8453. },
  8454. n)
  8455. },
  8456. e.resumeAudioMixing = function(t) {
  8457. var n = s.b.reportApiInvoke(e.sid, {
  8458. callback: function(n, a) {
  8459. if (n) return t && t(n);
  8460. e.dispatchEvent({
  8461. type: "audioMixingPlayed"
  8462. }),
  8463. t && t(null)
  8464. },
  8465. getStates: e._getOneEffectStates({
  8466. soundId: -1
  8467. }),
  8468. name: "Stream.resumeAudioMixing"
  8469. });
  8470. e._resumeOneEffect({
  8471. soundId: -1
  8472. },
  8473. n)
  8474. },
  8475. e.adjustAudioMixingVolume = function(t) {
  8476. var n = s.b.reportApiInvoke(e.sid, {
  8477. getStates: e._getOneEffectStates({
  8478. soundId: -1
  8479. }),
  8480. name: "Stream.adjustAudioMixingVolume",
  8481. options: arguments,
  8482. tag: "tracer"
  8483. });
  8484. Object(z.checkValidNumber)(t, "volume", 0, 100),
  8485. e.audioMixing.sounds[ - 1].volume = t,
  8486. e._flushAudioMixingMuteStatus(),
  8487. n()
  8488. },
  8489. e.getAudioMixingDuration = function() {
  8490. var t = s.b.reportApiInvoke(e.sid, {
  8491. getStates: e._getOneEffectStates({
  8492. soundId: -1
  8493. }),
  8494. name: "Stream.getAudioMixingDuration"
  8495. }),
  8496. n = e._getOneEffectDuration({
  8497. soundId: -1
  8498. });
  8499. return t(null, n),
  8500. n
  8501. },
  8502. e.getAudioMixingCurrentPosition = function() {
  8503. var t = s.b.reportApiInvoke(e.sid, {
  8504. getStates: e._getOneEffectStates({
  8505. soundId: -1
  8506. }),
  8507. name: "Stream.getAudioMixingCurrentPosition"
  8508. }),
  8509. n = e._getOneEffectCurrentPosition({
  8510. soundId: -1
  8511. },
  8512. !0);
  8513. return t(null, n),
  8514. n
  8515. },
  8516. e.setAudioMixingPosition = function(t, n) {
  8517. var a = s.b.reportApiInvoke(e.sid, {
  8518. callback: n,
  8519. options: arguments,
  8520. tag: "tracer",
  8521. getStates: e._getOneEffectStates({
  8522. soundId: -1
  8523. }),
  8524. name: "Stream.setAudioMixingPosition"
  8525. });
  8526. Object(z.checkValidNumber)(t, "position", 0, 1e8),
  8527. e._setOneEffectPosition({
  8528. soundId: -1
  8529. },
  8530. t, a)
  8531. },
  8532. e.playEffect = function(t, n) {
  8533. var a = s.b.reportApiInvoke(e.sid, {
  8534. callback: function(t) {
  8535. if (t) return n && n(t);
  8536. e.dispatchEvent({
  8537. type: "effectPlayed"
  8538. }),
  8539. n && n(null)
  8540. },
  8541. name: "Stream.playEffect",
  8542. options: t
  8543. });
  8544. Object(z.checkValidObject)(t, "options");
  8545. var i = t.soundId,
  8546. r = t.filePath,
  8547. c = t.cycle;
  8548. Object(z.checkValidNumber)(i, "soundId", 1, 1e4),
  8549. Object(z.checkValidString)(r, "filePath", 0, Object(o.getParameter)("FILEPATH_LENMAX"), !1),
  8550. !Object(z.isEmpty)(c) && Object(z.checkValidNumber)(c, "cycle"),
  8551. e._playOneEffect(t, a)
  8552. },
  8553. e.stopEffect = function(t, n) {
  8554. var a = s.b.reportApiInvoke(e.sid, {
  8555. callback: n,
  8556. getStates: e._getOneEffectStates({
  8557. soundId: t
  8558. }),
  8559. name: "Stream.stopEffect"
  8560. });
  8561. Object(z.checkValidNumber)(t, "soundId", 1, 1e4),
  8562. e._stopOneEffect({
  8563. soundId: t
  8564. },
  8565. a)
  8566. },
  8567. e.stopAllEffects = function(t) {
  8568. var n = s.b.reportApiInvoke(e.sid, {
  8569. callback: t,
  8570. name: "Stream.stopAllEffect"
  8571. }),
  8572. a = !1,
  8573. i = 0,
  8574. o = 0,
  8575. r = function(e) {
  8576. a || (e ? (n(e), a = !0) : i += 1, i === o && (n(null), a = !0))
  8577. };
  8578. for (var c in e.audioMixing.sounds) {
  8579. var d = e.audioMixing.sounds[c]; - 1 !== d.soundId && (d.state !== e.audioMixing.states.BUSY && d.state !== e.audioMixing.states.PAUSED || (o++, e._stopOneEffect({
  8580. soundId: c
  8581. },
  8582. r)))
  8583. }
  8584. o || n(null)
  8585. },
  8586. e.preloadEffect = function(t, n, a) {
  8587. var i = s.b.reportApiInvoke(e.sid, {
  8588. callback: a,
  8589. options: arguments,
  8590. tag: "tracer",
  8591. name: "Stream.preloadEffect"
  8592. });
  8593. Object(z.checkValidNumber)(t, "soundId", 1, 1e4),
  8594. Object(z.checkValidString)(n, "filePath", 1, Object(o.getParameter)("FILEPATH_LENMAX"), !1),
  8595. e._initSoundIfNotExists(t, n),
  8596. e.audioMixing.buffer[n] ? i(null) : e.loadAudioBuffer(n, n, i)
  8597. },
  8598. e.unloadEffect = function(t, n) {
  8599. var a = s.b.reportApiInvoke(e.sid, {
  8600. callback: n,
  8601. options: arguments,
  8602. tag: "tracer",
  8603. name: "Stream.unloadEffect"
  8604. });
  8605. Object(z.checkValidNumber)(t, "soundId", 1, 1e4);
  8606. var i = e.audioMixing.sounds[t];
  8607. if (!i) {
  8608. var o = "SOUND_NOT_EXISTS";
  8609. return r.
  8610. default.error(o, t),
  8611. void a(o)
  8612. }
  8613. var c = i.options ? i.options.filePath: i.filePath;
  8614. if (c) delete e.audioMixing.buffer[c],
  8615. delete e.audioMixing.sounds[t],
  8616. a(null);
  8617. else {
  8618. var d = "SOUND_BUFFER_NOT_FOUND";
  8619. r.
  8620. default.error(d, t),
  8621. a(d)
  8622. }
  8623. },
  8624. e.pauseEffect = function(t, n) {
  8625. var a = s.b.reportApiInvoke(e.sid, {
  8626. callback: n,
  8627. options: arguments,
  8628. tag: "tracer",
  8629. name: "Stream.pauseEffect"
  8630. });
  8631. return e._pauseOneEffect({
  8632. soundId: t
  8633. },
  8634. a)
  8635. },
  8636. e.pauseAllEffects = function(t) {
  8637. var n = s.b.reportApiInvoke(e.sid, {
  8638. callback: t,
  8639. name: "Stream.pauseAllEffects"
  8640. }),
  8641. a = !1,
  8642. i = 0,
  8643. o = 0,
  8644. r = function(e) {
  8645. a || (e ? (n(e), a = !0) : i += 1, i === o && (n(null), a = !0))
  8646. };
  8647. for (var c in e.audioMixing.sounds)"-1" !== c && e.audioMixing.sounds[c].state === e.audioMixing.states.BUSY && (o++, e._pauseOneEffect({
  8648. soundId: c
  8649. },
  8650. r));
  8651. o || n(null)
  8652. },
  8653. e.resumeEffect = function(t, n) {
  8654. Object(z.checkValidNumber)(t, "soundId", 1, 1e4);
  8655. var a = s.b.reportApiInvoke(e.sid, {
  8656. callback: n,
  8657. options: arguments,
  8658. tag: "tracer",
  8659. name: "Stream.resumeEffect"
  8660. });
  8661. return e._resumeOneEffect({
  8662. soundId: t
  8663. },
  8664. a)
  8665. },
  8666. e.resumeAllEffects = function(t) {
  8667. var n = s.b.reportApiInvoke(e.sid, {
  8668. callback: t,
  8669. name: "Stream.resumeAllEffects"
  8670. }),
  8671. a = !1,
  8672. i = 0,
  8673. o = 0,
  8674. r = function(e) {
  8675. a || (e ? (n(e), a = !0) : i += 1, i === o && (n(null), a = !0))
  8676. };
  8677. for (var c in e.audioMixing.sounds)"-1" !== c && e.audioMixing.sounds[c].state === e.audioMixing.states.PAUSED && (o++, e._resumeOneEffect({
  8678. soundId: c
  8679. },
  8680. r));
  8681. o || n(null)
  8682. },
  8683. e.getEffectsVolume = function() {
  8684. var t = [];
  8685. for (var n in e.audioMixing.sounds) {
  8686. var a = e.audioMixing.sounds[n];
  8687. a && "-1" !== n && t.push({
  8688. soundId: parseInt(n),
  8689. volume: a.volume
  8690. })
  8691. }
  8692. return t
  8693. },
  8694. e.setEffectsVolume = function(t, n) {
  8695. var a = s.b.reportApiInvoke(e.sid, {
  8696. name: "Stream.setEffectsVolume",
  8697. options: arguments,
  8698. tag: "tracer",
  8699. callback: n
  8700. });
  8701. for (var i in Object(z.checkValidNumber)(t, "volume", 0, 100), e.audioMixing.defaultVolume = t, e.audioMixing.sounds) {
  8702. var o = e.audioMixing.sounds[i];
  8703. "-1" !== i && (o.volume = t)
  8704. }
  8705. e._flushAudioMixingMuteStatus(),
  8706. a(null)
  8707. },
  8708. e.setVolumeOfEffect = function(t, n, a) {
  8709. var i = s.b.reportApiInvoke(e.sid, {
  8710. name: "Stream.setVolumeOfEffect",
  8711. options: arguments,
  8712. tag: "tracer",
  8713. callback: a
  8714. });
  8715. Object(z.checkValidNumber)(t, "soundId", 0, 1e4),
  8716. Object(z.checkValidNumber)(n, "volume", 0, 100),
  8717. e._initSoundIfNotExists(t);
  8718. var o = e.audioMixing.sounds[t];
  8719. o.volume = n,
  8720. e._flushAudioMixingMuteStatus(),
  8721. i(null)
  8722. }
  8723. } (t),
  8724. he.addVideoEffectCapability(t),
  8725. function(e, t) {
  8726. e.videoConstraint = {},
  8727. t.cameraId && (e.videoConstraint.deviceId = {
  8728. exact: t.cameraId
  8729. }),
  8730. t.facingMode && (e.videoConstraint.facingMode = t.facingMode),
  8731. e.videoSize && (e.videoConstraint.width = e.videoSize[0], e.videoConstraint.height = e.videoSize[1]),
  8732. Object(g.isLegacyChrome)() || (e.videoConstraint.frameRate = {
  8733. ideal: 30,
  8734. max: 30
  8735. }),
  8736. e.audioConstraint = {},
  8737. t.microphoneId && (e.audioConstraint.deviceId = {
  8738. exact: t.microphoneId
  8739. }),
  8740. Object(g.isLegacyChrome)() || e.audioProcessing && (void 0 !== e.audioProcessing.AGC && (Object(g.isFireFox)() ? e.audioConstraint.autoGainControl = e.audioProcessing.AGC: Object(g.isChrome)() && (e.audioConstraint.googAutoGainControl = e.audioProcessing.AGC, e.audioConstraint.googAutoGainControl2 = e.audioProcessing.AGC)), void 0 !== e.audioProcessing.AEC && (e.audioConstraint.echoCancellation = e.audioProcessing.AEC), void 0 !== e.audioProcessing.ANS && (Object(g.isFireFox)() ? e.audioConstraint.noiseSuppression = e.audioProcessing.ANS: Object(g.isChrome)() && (e.audioConstraint.googNoiseSuppression = e.audioProcessing.ANS))),
  8741. e.screenConstraint = {},
  8742. t.sourceId && (e.screenConstraint.sourceId = t.sourceId),
  8743. t.extensionId && Object(g.isChrome)() ? (e.screenConstraint.extensionId = t.extensionId, e.screenConstraint.mandatory = {
  8744. chromeMediaSource: "desktop",
  8745. maxWidth: e.screenAttributes.width,
  8746. maxHeight: e.screenAttributes.height,
  8747. maxFrameRate: e.screenAttributes.maxFr,
  8748. minFrameRate: e.screenAttributes.minFr
  8749. }) : (e.screenConstraint.mediaSource = "screen", e.screenConstraint.width = e.screenAttributes.width, e.screenConstraint.height = e.screenAttributes.height, e.screenConstraint.frameRate = {
  8750. ideal: e.screenAttributes.maxFr,
  8751. max: e.screenAttributes.maxFr
  8752. }),
  8753. t.mediaSource && (e.screenConstraint.mediaSource = t.mediaSource),
  8754. e.setVideoResolution = function(n) {
  8755. var a = s.b.reportApiInvoke(e.sid, {
  8756. name: "Stream.setVideoResolution",
  8757. options: arguments,
  8758. tag: "tracer"
  8759. });
  8760. if (! (n instanceof Array)) {
  8761. var i = Te(n += "");
  8762. return i && i.video ? (e.videoConstraint = E()(e.videoConstraint, {
  8763. width: {
  8764. ideal: i.video.width
  8765. },
  8766. height: {
  8767. ideal: i.video.height
  8768. }
  8769. }), t.attributes.resolution = i.attributes.resolution, (o = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0]) && o.applyConstraints ? (r.
  8770. default.debug("setVideoResolution applyConstraints", e.videoConstraint), o.applyConstraints(e.videoConstraint).then(a).
  8771. catch(a)) : a(), !0) : (a("NO_PROFILE_".concat(n)), !1)
  8772. }
  8773. var o, c = n[0],
  8774. d = n[1];
  8775. e.videoConstraint = E()(e.videoConstraint, {
  8776. width: {
  8777. ideal: c
  8778. },
  8779. height: {
  8780. ideal: d
  8781. }
  8782. }),
  8783. t.attributes.resolution = "".concat(c, "x").concat(d),
  8784. (o = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0]) && o.applyConstraints ? (r.
  8785. default.debug("setVideoResolution applyConstraints", e.videoConstraint), he.disableVideoEffect(e).then((function() {
  8786. return o.applyConstraints(e.videoConstraint).then(a).
  8787. catch(a)
  8788. })).then((function() {
  8789. return he.restoreVideoEffect(e)
  8790. }))) : a()
  8791. },
  8792. e.setVideoFrameRate = function(t) {
  8793. var n = s.b.reportApiInvoke(e.sid, {
  8794. name: "Stream.setVideoFrameRate",
  8795. options: arguments,
  8796. tag: "tracer"
  8797. });
  8798. if (Object(g.isFireFox)()) return n("FIREFOX_NOT_SUPPORTED"),
  8799. !1;
  8800. if ("object" === be()(t) && t instanceof Array && t.length > 1) {
  8801. e.videoConstraint = E()(e.videoConstraint, {
  8802. frameRate: {
  8803. ideal: t[0],
  8804. max: t[1]
  8805. }
  8806. }),
  8807. e.attributes.minFrameRate = t[0],
  8808. e.attributes.maxFrameRate = t[1];
  8809. var a = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0];
  8810. return a && a.applyConstraints ? (r.
  8811. default.debug("setVideoFrameRate applyConstraints", e.videoConstraint), a.applyConstraints(e.videoConstraint).then(n).
  8812. catch(n)) : n(),
  8813. !0
  8814. }
  8815. return n("INVALID_PARAM_".concat(JSON.stringify(t))),
  8816. !1
  8817. },
  8818. e.setVideoBitRate = function(n) {
  8819. var a = s.b.reportApiInvoke(e.sid, {
  8820. name: "Stream.setVideoBitRate",
  8821. options: arguments,
  8822. tag: "tracer"
  8823. });
  8824. return "object" === be()(n) && n instanceof Array && n.length > 1 ? (t.attributes.minVideoBW = n[0], t.attributes.maxVideoBW = n[1], e.connectionSpec && (e.connectionSpec.minVideoBW = n[0], e.connectionSpec.maxVideoBW = n[1]), e.pc && e.pc.renegotiate && e.pc.renegotiate(), a(), !0) : (a("INVALID_PARAM_".concat(JSON.stringify(n))), !1)
  8825. },
  8826. e.setScreenBitRate = function(t) {
  8827. var n = s.b.reportApiInvoke(e.sid, {
  8828. name: "Stream.setScreenBitRate",
  8829. options: arguments,
  8830. tag: "tracer"
  8831. });
  8832. return "object" === be()(t) && t instanceof Array && t.length > 1 ? (e.screenAttributes.minVideoBW = t[0], e.screenAttributes.maxVideoBW = t[1], n(), !0) : (n("INVALID_PARAM_".concat(JSON.stringify(t))), !1)
  8833. },
  8834. e.setScreenProfile = function(t) {
  8835. var n = s.b.reportApiInvoke(e.sid, {
  8836. name: "Stream.setScreenProfile",
  8837. options: arguments,
  8838. tag: "tracer"
  8839. });
  8840. Object(z.checkValidEnum)(t, "profile", ["480p_1", "480p_2", "720p_1", "720p_2", "1080p_1", "1080p_2"]);
  8841. var a = Te(t);
  8842. return a && a.screen ? (e.screenConstraint.mandatory ? (e.screenConstraint.mandatory.maxWidth = a.screen.width, e.screenConstraint.mandatory.maxHeight = a.screen.height, a.screen.frameRate && a.screen.frameRate.min && a.screen.frameRate.max && (e.screenConstraint.mandatory.minFrameRate = a.screen.frameRate.min, e.screenConstraint.mandatory.maxFrameRate = a.screen.frameRate.max)) : e.screenConstraint = E()(e.screenConstraint, a.screen), e.screenAttributes.width = a.screen.width, e.screenAttributes.height = a.screen.height, e.screenAttributes.minFr = a.screen.frameRate.min, e.screenAttributes.maxFr = a.screen.frameRate.max, n(), !0) : (n("NO_SCREEN_PROFILE_".concat(JSON.stringify(t))), !1)
  8843. },
  8844. e.setVideoProfileCustom = function(t) {
  8845. var n = s.b.reportApiInvoke(e.sid, {
  8846. name: "Stream.setVideoProfileCustom",
  8847. options: arguments,
  8848. tag: "tracer"
  8849. });
  8850. e.setVideoResolution(t[0]),
  8851. e.setVideoFrameRate([t[1], t[1]]),
  8852. e.setVideoBitRate([t[2], t[2]]),
  8853. n()
  8854. },
  8855. e.setVideoProfileCustomPlus = function(n) {
  8856. var a = s.b.reportApiInvoke(e.sid, {
  8857. name: "Stream.setVideoProfileCustom",
  8858. options: arguments,
  8859. tag: "tracer"
  8860. });
  8861. e.setVideoResolution([n.width, n.height]),
  8862. t.attributes.resolution = "".concat(n.width, "x").concat(n.height),
  8863. e.setVideoFrameRate([n.framerate, n.framerate]),
  8864. e.setVideoBitRate([n.bitrate, n.bitrate]),
  8865. a()
  8866. },
  8867. e.setVideoProfile = function(n) {
  8868. var a = s.b.reportApiInvoke(e.sid, {
  8869. name: "Stream.setVideoProfile",
  8870. options: arguments,
  8871. tag: "tracer"
  8872. }),
  8873. i = Te(n);
  8874. if (!i) {
  8875. var o = "Invalid Profile ".concat(n);
  8876. throw new Error(o)
  8877. }
  8878. if (e.profile = n, i && i.video) {
  8879. e.profile = i.profileName,
  8880. e.videoConstraint = E()(e.videoConstraint, i.video),
  8881. e.connectionSpec && i.attributes.maxVideoBW && (e.connectionSpec.minVideoBW = i.attributes.minVideoBW, e.connectionSpec.maxVideoBW = i.attributes.maxVideoBW),
  8882. Object(g.isEdge)() && (e.videoConstraint.frameRate.max = 60),
  8883. Object(g.isFireFox)() && (e.videoConstraint.frameRate = {
  8884. ideal: 30,
  8885. max: 30
  8886. }),
  8887. t.attributes = E()(t.attributes, i.attributes),
  8888. e.pc && e.pc.renegotiate && e.pc.renegotiate();
  8889. var c = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0];
  8890. return c && c.applyConstraints ? (r.
  8891. default.debug("setVideoProfile applyConstraints", e.videoConstraint), he.disableVideoEffect(e).then((function() {
  8892. return c.applyConstraints(e.videoConstraint)
  8893. })).then((function() {
  8894. return he.restoreVideoEffect(e)
  8895. })).then((function(t) {
  8896. return new Promise((function(n, i) {
  8897. a(t),
  8898. Object(H.vsResHack)(e.stream, (function(t, a) {
  8899. e.videoWidth = t,
  8900. e.videoHeight = a,
  8901. n()
  8902. }), (function(t) {
  8903. r.
  8904. default.warning("[".concat(e.streamId, "] vsResHack failed: "), t),
  8905. i()
  8906. }))
  8907. }))
  8908. })).
  8909. catch(a)) : a(),
  8910. !0
  8911. }
  8912. return a("INVALID_VIDEO_PROFILE_".concat(n)),
  8913. !1
  8914. },
  8915. e.setAudioProfile = function(t) {
  8916. var n = s.b.reportApiInvoke(e.sid, {
  8917. name: "Stream.setAudioProfile",
  8918. options: arguments,
  8919. tag: "tracer"
  8920. });
  8921. Object(z.checkValidEnum)(t, "profile", ["speech_low_quality", "speech_standard", "music_standard", "standard_stereo", "high_quality", "high_quality_stereo"]),
  8922. e.audioProfile = t;
  8923. var a = Ae(t);
  8924. return e.highQuality = a.highQuality,
  8925. e.stereo = a.stereo,
  8926. e.speech = a.speech,
  8927. e.lowQuality = a.lowQuality,
  8928. e.stereo && Object(g.isChrome)() && (e.audioConstraint.googAutoGainControl = !1, e.audioConstraint.googAutoGainControl2 = !1, e.audioConstraint.echoCancellation = !1, e.audioConstraint.googNoiseSuppression = !1),
  8929. n(),
  8930. !0
  8931. },
  8932. e.setVideoEncoderConfiguration = function(t) {
  8933. Object(z.checkValidObject)(t, "config");
  8934. var n = s.b.reportApiInvoke(e.sid, {
  8935. name: "Stream.setVideoEncoderConfiguration",
  8936. options: t,
  8937. tag: "tracer"
  8938. });
  8939. t.resolution && (Object(z.checkValidNumber)(t.resolution.width, "config.resolution.width"), Object(z.checkValidNumber)(t.resolution.height, "config.resolution.height"), e.setVideoResolution([t.resolution.width, t.resolution.height])),
  8940. t.frameRate && (Object(z.checkValidNumber)(t.frameRate.min, "config.frameRate.min"), Object(z.checkValidNumber)(t.frameRate.max, "config.frameRate.max"), e.setVideoFrameRate([t.frameRate.min, t.frameRate.max])),
  8941. t.bitrate && (Object(z.checkValidNumber)(t.bitrate.min, "config.bitrate.min", 1, 1e7), Object(z.checkValidNumber)(t.bitrate.max, "config.bitrate.max", 1, 1e7), e.setVideoBitRate([t.bitrate.min, t.bitrate.max])),
  8942. n()
  8943. },
  8944. e.getSupportedProfile = function(t) {
  8945. var n = s.b.reportApiInvoke(e.sid, {
  8946. name: "Stream.getSupportedProfile",
  8947. options: arguments,
  8948. tag: "tracer",
  8949. callback: t
  8950. });
  8951. if (!e.local) {
  8952. var a = "ONLY_LOCAL_STREAM_SUPPORTED";
  8953. return r.
  8954. default.error(a),
  8955. n(a)
  8956. }
  8957. if (!e.stream) {
  8958. a = "STREAM_NOT_INIT";
  8959. return r.
  8960. default.error(a),
  8961. n(a)
  8962. }
  8963. if (!e.stream.getVideoTracks) {
  8964. a = "TRACK_NOT_SUPPORT";
  8965. return r.
  8966. default.error(a),
  8967. n(a)
  8968. }
  8969. var i = e.stream.getVideoTracks()[0];
  8970. if (!i) {
  8971. a = "NO_VIDEO_TRACK_FOUND";
  8972. return r.
  8973. default.error(a),
  8974. n(a)
  8975. }
  8976. if (!i.getCapabilities) {
  8977. a = "GETCAPABILITY_NOT_SUPPORT";
  8978. return r.
  8979. default.error(a),
  8980. n(a)
  8981. }
  8982. var o = i.getCapabilities(),
  8983. c = Re(o);
  8984. return n(null, c)
  8985. }
  8986. } (t, e),
  8987. t.getId = function() {
  8988. return t.streamId
  8989. },
  8990. t.getUserId = function() {
  8991. return t.userId
  8992. },
  8993. t.checkDualStreamEnabled = function() {
  8994. if (Object(o.getParameter)("DUALSTREAM_OPERATION_CHECK") && t.isDualStream) {
  8995. return r.
  8996. default.error("Operation not permitted: ".concat("DUAL_STREAM_ENABLED")),
  8997. "DUAL_STREAM_ENABLED"
  8998. }
  8999. return ! 1
  9000. },
  9001. t.setUserId = function(e) {
  9002. var n = s.b.reportApiInvoke(t.sid, {
  9003. name: "Stream.setUserId",
  9004. options: arguments,
  9005. tag: "tracer"
  9006. });
  9007. t.userId && r.
  9008. default.warning("[".concat(t.streamId, "] Stream.userId ").concat(t.userId, " => ").concat(e)),
  9009. t.userId = e,
  9010. n()
  9011. },
  9012. t.getAttributes = function() {
  9013. return e.screen ? t.screenAttributes: e.attributes
  9014. },
  9015. t.hasAudio = function() {
  9016. return !! t.audio
  9017. },
  9018. t.hasVideo = function() {
  9019. return !! t.video
  9020. },
  9021. t.hasScreen = function() {
  9022. return !! t.screen
  9023. },
  9024. t.hasScreenAudio = function() {
  9025. return !! t.screenAudio
  9026. },
  9027. t.isVideoOn = function() {
  9028. return (t.hasVideo() || t.hasScreen()) && !t.userMuteVideo
  9029. },
  9030. t.isAudioOn = function() {
  9031. return t.hasAudio() && !t.userMuteAudio
  9032. },
  9033. t.init = function(a, i) {
  9034. var o = s.b.reportApiInvoke(t.sid, {
  9035. callback: function(e, t) {
  9036. if (e) return i && i(e);
  9037. a && a(t)
  9038. },
  9039. name: "Stream.init",
  9040. options: arguments,
  9041. tag: "tracer"
  9042. }),
  9043. c = ((new Date).getTime(), arguments[2]);
  9044. if (void 0 === c && (c = 2), !0 === t.initialized) return o({
  9045. type: "warning",
  9046. msg: "STREAM_ALREADY_INITIALIZED"
  9047. });
  9048. if (!0 !== t.local) return o({
  9049. type: "warning",
  9050. msg: "STREAM_NOT_LOCAL"
  9051. });
  9052. var d = Math.random().toString().slice(3);
  9053. t._streamInitID = d,
  9054. t.videoSource ? t.videoName = "videoSource": t.video && (t.videoName = K.searchDeviceNameById(e.cameraId) || "default"),
  9055. t.audioSource ? t.audioName = "audioSource": t.audio && (t.audioName = K.searchDeviceNameById(e.microphoneId) || "default"),
  9056. t.screen && (t.screenName = e.extensionId || "default");
  9057. try {
  9058. if (e.audio || e.video || e.screen || e.screenAudio || e.videoSource || e.audioSource) {
  9059. r.
  9060. default.debug("[".concat(t.streamId, "] Requested access to local media"));
  9061. var u = {
  9062. streamId: t.streamId
  9063. };
  9064. e.videoSource ? u.videoSource = e.videoSource: e.screen ? u.screen = t.screenConstraint: e.video && (u.video = t.videoConstraint),
  9065. e.audioSource ? u.audioSource = e.audioSource: e.screenAudio ? u.screenAudio = e.screenAudio: e.audio && (u.audio = t.audioConstraint),
  9066. G(u, (function(a) {
  9067. if (u.screenAudio && !a.getAudioTracks()[0] && r.
  9068. default.warning("[".concat(t.streamId, "] Audio sharing is not selected")), u.screen && r.
  9069. default.debug("[".concat(t.streamId, "] User has granted access to screen sharing")), (u.video || u.audio) && r.
  9070. default.debug("[".concat(t.streamId, "] User has granted access to local media")), null === t._streamInitID) {
  9071. a.getTracks().forEach((function(e) {
  9072. e.stop()
  9073. }));
  9074. var i = {
  9075. type: "error",
  9076. msg: "STREAM_IS_CLOSED",
  9077. info: "stream is closed and cannot be initialized"
  9078. };
  9079. return r.
  9080. default.error(t.streamId, i.info),
  9081. void o(i)
  9082. }
  9083. if (t._streamInitID !== d) {
  9084. a.getTracks().forEach((function(e) {
  9085. e.stop()
  9086. }));
  9087. i = {
  9088. type: "error",
  9089. msg: "ABORT_OTHER_INIT",
  9090. info: "stream initialization is aborted because of another stream.init"
  9091. };
  9092. return r.
  9093. default.error(t.streamId, i.info),
  9094. void o(i)
  9095. }
  9096. t.dispatchEvent({
  9097. type: "accessAllowed"
  9098. }),
  9099. t.stream = a,
  9100. t.initialized = !0,
  9101. t.reloadDeviceName(),
  9102. t.hasVideo() && Object(H.vsResHack)(a, (function(e, n) {
  9103. t.videoWidth = e,
  9104. t.videoHeight = n
  9105. }), (function(e) {
  9106. r.
  9107. default.warning("[".concat(t.streamId, "] vsResHack failed: "), e)
  9108. })),
  9109. e.screen && t.stream && t.stream.getVideoTracks()[0] && (t.stream.getVideoTracks()[0].onended = function() {
  9110. t.dispatchEvent({
  9111. type: "stopScreenSharing"
  9112. })
  9113. }),
  9114. t.stream && t.stream.getTracks && t.stream.getTracks().forEach((function(e) {
  9115. e && !e.onended && (e.onended = n)
  9116. })),
  9117. o()
  9118. }), (function(e) {
  9119. var n = {
  9120. type: "error",
  9121. info: null
  9122. };
  9123. switch (e && (n.msg = e.name || e.code || e, e.message && (n.info = e.message), e.code && (n.info ? n.info += ". " + e.code: n.info = " " + e.code), e.constraint && (n.info ? n.info += ". Constraint: " + e.constraint: n.info = "constraint: " + e.constraint)), n.msg) {
  9124. case "Starting video failed":
  9125. case "TrackStartError":
  9126. if (t.videoConstraint && (delete t.videoConstraint.width, delete t.videoConstraint.height), c > 0) return void setTimeout((function() {
  9127. t.init((function(e) {
  9128. return o(e)
  9129. }), o, c - 1)
  9130. }), 1);
  9131. n.msg = "MEDIA_OPTION_INVALID";
  9132. break;
  9133. case "DevicesNotFoundError":
  9134. n.msg = "DEVICES_NOT_FOUND";
  9135. break;
  9136. case "NotSupportedError":
  9137. n.msg = "NOT_SUPPORTED";
  9138. break;
  9139. case "PermissionDeniedError":
  9140. case "InvalidStateError":
  9141. n.msg = "PERMISSION_DENIED",
  9142. t.dispatchEvent({
  9143. type: "accessDenied"
  9144. });
  9145. break;
  9146. case "PERMISSION_DENIED":
  9147. case "NotAllowedError":
  9148. t.dispatchEvent({
  9149. type:
  9150. "accessDenied"
  9151. });
  9152. break;
  9153. case "ConstraintNotSatisfiedError":
  9154. n.msg = "CONSTRAINT_NOT_SATISFIED";
  9155. break;
  9156. default:
  9157. n.msg || (n.msg = "UNDEFINED")
  9158. }
  9159. var a = "Media access ".concat(n.msg).concat(n.info ? ": " + n.info: "");
  9160. r.
  9161. default.error("[".concat(t.streamId, "] "), a),
  9162. o(n)
  9163. }))
  9164. } else o({
  9165. type: "warning",
  9166. msg: "STREAM_HAS_NO_MEDIA_ATTRIBUTES"
  9167. })
  9168. } catch(e) {
  9169. r.
  9170. default.error("[".concat(t.streamId, "] Stream init: "), e),
  9171. o({
  9172. type: "error",
  9173. msg: e.message || e
  9174. })
  9175. }
  9176. },
  9177. t.reloadDeviceName = function() {
  9178. if (t.stream) {
  9179. if (t.stream.getVideoTracks) {
  9180. var e = t.stream.getVideoTracks()[0];
  9181. e && e.label && (t.videoName = e.label)
  9182. }
  9183. if (t.stream.getAudioTracks) {
  9184. var n = t.stream.getAudioTracks()[0];
  9185. n && n.label && (t.audioName = n.label)
  9186. }
  9187. }
  9188. },
  9189. t.close = function() {
  9190. var e = s.b.reportApiInvoke(null, {
  9191. name: "Stream.close",
  9192. options: arguments,
  9193. tag: "tracer"
  9194. });
  9195. if (r.
  9196. default.debug("[".concat(t.streamId, "] Close stream with id"), t.streamId), t._originStream) try {
  9197. t._originStream.getTracks().map((function(e) {
  9198. return e.stop()
  9199. }))
  9200. } catch(e) {}
  9201. if (void 0 !== t.stream) {
  9202. var n = t.stream.getTracks();
  9203. for (var a in n) n.hasOwnProperty(a) && n[a].stop(); ! t.isLowStream && t.local ? he.disableVideoEffect(t).then((function() {
  9204. t.stream = void 0
  9205. })) : (t.stream && t.stream.clean && t.stream.clean(), t.stream = void 0)
  9206. }
  9207. if (Object(g.isSafari)() && t.pc && t.pc.peerConnection && t.pc.peerConnection.removeTrack && t.pc.peerConnection.getSenders) {
  9208. var i = t.pc.peerConnection.getSenders();
  9209. i.forEach((function(e) {
  9210. e && (r.
  9211. default.debug("[".concat(t.streamId, "] Remove Track"), e), t.pc.peerConnection.removeTrack(e))
  9212. }))
  9213. }
  9214. t.local && (t.initialized = !1),
  9215. t._streamInitID = null,
  9216. t._onAudioMute = void 0,
  9217. t._onAudioUnmute = void 0,
  9218. t._onVideoMute = void 0,
  9219. t._onVideoUnmute = void 0,
  9220. t.lowStream && t.lowStream.close(),
  9221. e()
  9222. },
  9223. t.enableAudio = function() {
  9224. var e, n = s.b.reportApiInvoke(t.sid, {
  9225. name: "Stream.enableAudio",
  9226. options: arguments,
  9227. tag: "tracer"
  9228. });
  9229. return r.
  9230. default.deprecate("[".concat(t.streamId, "] Stream.enableAudio is deprecated and will be removed in the future. Use Stream.unmuteAudio instead")),
  9231. t.userMuteAudio || r.
  9232. default.warning("[".concat(t.streamId, "] User already enableAudio")),
  9233. t.userMuteAudio = !1,
  9234. n(null, e = !t.peerMuteAudio && t._unmuteAudio()),
  9235. e
  9236. },
  9237. t.disableAudio = function() {
  9238. var e = s.b.reportApiInvoke(t.sid, {
  9239. name: "Stream.disableAudio",
  9240. options: arguments,
  9241. tag: "tracer"
  9242. });
  9243. r.
  9244. default.deprecate("[".concat(t.streamId, "] Stream.disableAudio is deprecated and will be removed in the future. Use Stream.muteAudio instead")),
  9245. t.userMuteAudio && r.
  9246. default.warning("[".concat(t.streamId, "] User already disableAudio")),
  9247. t.userMuteAudio = !0;
  9248. var n = t._muteAudio();
  9249. return e(null, n),
  9250. n
  9251. },
  9252. t.enableVideo = function() {
  9253. var e, n = s.b.reportApiInvoke(t.sid, {
  9254. name: "Stream.enableVideo",
  9255. options: arguments,
  9256. tag: "tracer"
  9257. });
  9258. return r.
  9259. default.deprecate("[".concat(t.streamId, "] Stream.enableVideo is deprecated and will be removed in the future. Use Stream.unmuteVideo instead")),
  9260. t.userMuteVideo || r.
  9261. default.warning("[".concat(t.streamId, "] User already enableVideo")),
  9262. t.userMuteVideo = !1,
  9263. t.lowStream && (t.lowStream.userMuteVideo = !1),
  9264. n(null, e = !t.peerMuteVideo && t._unmuteVideo()),
  9265. e
  9266. },
  9267. t.disableVideo = function() {
  9268. var e = s.b.reportApiInvoke(t.sid, {
  9269. name: "Stream.disableVideo",
  9270. options: arguments,
  9271. tag: "tracer"
  9272. });
  9273. r.
  9274. default.deprecate("[".concat(t.streamId, "] Stream.disableVideo is deprecated and will be removed in the future. Use Stream.muteVideo instead")),
  9275. t.userMuteVideo && r.
  9276. default.warning("[".concat(t.streamId, "] User already disableVideo")),
  9277. t.userMuteVideo = !0,
  9278. t.lowStream && (t.lowStream.userMuteVideo = !0);
  9279. var n = t._muteVideo();
  9280. return e(null, n),
  9281. n
  9282. },
  9283. t.unmuteAudio = function() {
  9284. var e, n = s.b.reportApiInvoke(t.sid, {
  9285. name: "Stream.unmuteAudio",
  9286. options: arguments,
  9287. tag: "tracer"
  9288. });
  9289. return t.userMuteAudio || r.
  9290. default.warning("[".concat(t.streamId, "] User already unmuteAudio")),
  9291. t.userMuteAudio = !1,
  9292. n(null, e = !t.peerMuteAudio && t._unmuteAudio()),
  9293. e
  9294. },
  9295. t.muteAudio = function() {
  9296. var e = s.b.reportApiInvoke(t.sid, {
  9297. name: "Stream.muteAudio",
  9298. options: arguments,
  9299. tag: "tracer"
  9300. });
  9301. t.userMuteAudio && r.
  9302. default.warning("[".concat(t.streamId, "] User already muteAudio")),
  9303. t.userMuteAudio = !0;
  9304. var n = t._muteAudio();
  9305. return e(null, n),
  9306. n
  9307. },
  9308. t.unmuteVideo = function() {
  9309. var e, n = s.b.reportApiInvoke(t.sid, {
  9310. name: "Stream.unmuteVideo",
  9311. options: arguments,
  9312. tag: "tracer"
  9313. });
  9314. return t.userMuteVideo || r.
  9315. default.warning("[".concat(t.streamId, "] User already unmuteVideo")),
  9316. t.userMuteVideo = !1,
  9317. t.lowStream && (t.lowStream.userMuteVideo = !1),
  9318. n(null, e = !t.peerMuteVideo && t._unmuteVideo()),
  9319. e
  9320. },
  9321. t.muteVideo = function() {
  9322. var e = s.b.reportApiInvoke(t.sid, {
  9323. name: "Stream.muteVideo",
  9324. options: arguments,
  9325. tag: "tracer"
  9326. });
  9327. t.userMuteVideo && r.
  9328. default.warning("[".concat(t.streamId, "] User already muteVideo")),
  9329. t.userMuteVideo = !0,
  9330. t.lowStream && (t.lowStream.userMuteVideo = !0);
  9331. var n = t._muteVideo();
  9332. return e(null, n),
  9333. n
  9334. },
  9335. t._unmuteAudio = function() {
  9336. return r.
  9337. default.debug("[".concat(t.streamId, "] Unmuted audio stream with id "), t.streamId),
  9338. t._flushAudioMixingMuteStatus(!1),
  9339. !(!t.hasAudio() || !t.initialized || void 0 === t.stream || !0 === t.stream.getAudioTracks()[0].enabled) && (t._onAudioUnmute && t._onAudioUnmute(), t.pc && (t.pc.isAudioMute = !1), t.stream.getAudioTracks()[0].enabled = !0, !0)
  9340. },
  9341. t._isAudioMuted = function() {
  9342. if (t.stream && t.hasAudio()) {
  9343. var e = t.stream.getAudioTracks();
  9344. return e.length > 0 && !e[0].enabled
  9345. }
  9346. return ! 1
  9347. },
  9348. t._isVideoMuted = function() {
  9349. if (t.stream && t.hasVideo()) {
  9350. var e = t.stream.getVideoTracks();
  9351. return e.length > 0 && !e[0].enabled
  9352. }
  9353. return ! 1
  9354. },
  9355. t._muteAudio = function() {
  9356. return r.
  9357. default.debug("[".concat(t.streamId, "] Muted audio stream with id "), t.streamId),
  9358. t._flushAudioMixingMuteStatus(!0),
  9359. !!(t.hasAudio() && t.initialized && void 0 !== t.stream && t.stream.getAudioTracks()[0].enabled) && (t._onAudioMute && t._onAudioMute(), t.pc && (t.pc.isAudioMute = !0), t.stream.getAudioTracks()[0].enabled = !1, t.sid && s.b.audioSendingStopped(t.sid, {
  9360. succ: !0,
  9361. reason: "muteAudio"
  9362. }), !0)
  9363. },
  9364. t._unmuteVideo = function() {
  9365. return r.
  9366. default.debug("[".concat(t.streamId, "] Unmuted video stream with id"), t.streamId),
  9367. !(!t.initialized || void 0 === t.stream || !t.stream.getVideoTracks().length || !0 === t.stream.getVideoTracks()[0].enabled) && (t._onVideoUnmute && t._onVideoUnmute(), t.pc && (t.pc.isVideoMute = !1), t.stream.getVideoTracks()[0].enabled = !0, t.lowStream && t.lowStream._unmuteVideo(), !0)
  9368. },
  9369. t._muteVideo = function() {
  9370. return r.
  9371. default.debug("[".concat(t.streamId, "] Muted video stream with id"), t.streamId),
  9372. !!(t.initialized && void 0 !== t.stream && t.stream.getVideoTracks().length && t.stream.getVideoTracks()[0].enabled) && (t._onVideoMute && t._onVideoMute(), t.pc && (t.pc.isVideoMute = !0), t.stream.getVideoTracks()[0].enabled = !1, t.lowStream && t.lowStream._muteVideo(), t.sid && s.b.videoSendingStopped(t.sid, {
  9373. succ: !0,
  9374. reason: "muteVideo"
  9375. }), !0)
  9376. },
  9377. t.addTrack = function(a) {
  9378. var i = s.b.reportApiInvoke(t.sid, {
  9379. name: "Stream.addTrack",
  9380. options: arguments,
  9381. tag: "tracer"
  9382. });
  9383. if (t.pc && t.pc.addTrack(a, t.stream), "audio" == a.kind) {
  9384. t._cleanupAudioMixing();
  9385. var o = new MediaStream;
  9386. t.userMuteAudio && (a.enabled = !1),
  9387. o.addTrack(a);
  9388. var r = t.stream.getVideoTracks()[0];
  9389. r && o.addTrack(r),
  9390. t.audio = !0,
  9391. e.audio = !0,
  9392. t.stream = o,
  9393. t.audioLevelHelper = null,
  9394. t.player && t.player.video && (t.player.video.srcObject = t.stream)
  9395. } else t.userMuteVideo && (a.enabled = !1),
  9396. t.stream.addTrack(a),
  9397. t.video = !0,
  9398. e.video = !0;
  9399. a.onended || (a.onended = n),
  9400. i()
  9401. },
  9402. t.removeTrack = function(n) {
  9403. var a = s.b.reportApiInvoke(t.sid, {
  9404. name: "Stream.removeTrack",
  9405. options: arguments,
  9406. tag: "tracer"
  9407. });
  9408. t.pc && t.pc.removeTrack(n, t.stream),
  9409. t.stream.removeTrack(n),
  9410. t._cleanupAudioMixing(),
  9411. "audio" === n.kind ? (t.audio = !1, e.audio = !1) : (t.video = !1, e.video = !1),
  9412. t.audioLevelHelper = null,
  9413. "live" == n.readyState && (n.stop(), r.
  9414. default.debug("[".concat(t.streamId, "] Track ").concat(n.kind, " Stopped"))),
  9415. a()
  9416. },
  9417. t.setAudioOutput = function(e, n, a) {
  9418. var i = s.b.reportApiInvoke(t.sid, {
  9419. callback: function(e, t) {
  9420. if (e) return a && a(e);
  9421. n && n(t)
  9422. },
  9423. name: "Stream.setAudioOutput",
  9424. options: arguments,
  9425. tag: "tracer"
  9426. });
  9427. return Object(z.isValidString)(e, 1, 255) ? (t.audioOutput = e, t.player ? void t.player.setAudioOutput(e, (function() {
  9428. return i()
  9429. }), i) : i()) : (r.
  9430. default.error("[".concat(t.streamId, "] setAudioOutput Invalid Parameter"), e), i(I.
  9431. default.INVALID_PARAMETER))
  9432. },
  9433. t.play = function(e, n, a) {
  9434. "function" == typeof n && (a = n, n = null),
  9435. r.
  9436. default.debug("[".concat(t.streamId, "] play()."), e, n);
  9437. var i = s.b.reportApiInvoke(t.sid, {
  9438. name: "Stream.play",
  9439. options: arguments,
  9440. tag: "tracer",
  9441. callback: a
  9442. });
  9443. if (Object(z.checkValidString)(e, "elementID"), Object(z.isEmpty)(n) || (Object(z.isEmpty)(n.fit) || Object(z.checkValidEnum)(n.fit, "fit", ["cover", "contain"]), Object(z.isEmpty)(n.muted) || Object(z.checkValidBoolean)(n.muted, "muted")), t.player) r.
  9444. default.warning("[".concat(t.streamId, "] Stream.play(): Stream is already playing. Fallback to resume stream")),
  9445. t.resume().then((function() {
  9446. i(null)
  9447. })).
  9448. catch(i);
  9449. else {
  9450. t.elementID = e,
  9451. t.playOptions = n,
  9452. !t.local || t.video || t.screen ? (t.player = new T({
  9453. id: t.getId(),
  9454. stream: t,
  9455. elementID: e,
  9456. options: n
  9457. }), t.local && he.applyEffectInPlayer(t)) : t.hasAudio() && (t.player = new T({
  9458. id: t.getId(),
  9459. stream: t,
  9460. elementID: e,
  9461. options: n
  9462. }));
  9463. var o = {
  9464. video: null,
  9465. audio: null
  9466. },
  9467. c = function e(n) {
  9468. if (o[n.mediaType] = n, o.video && o.audio) if (t.removeEventListener("player-status-change", e), o.video.isErrorState || o.audio.isErrorState) {
  9469. var a = o.video.isErrorState ? o.video: o.audio;
  9470. i({
  9471. isErrorState: !0,
  9472. status: a.status,
  9473. reason: a.reason,
  9474. video: o.video,
  9475. audio: o.audio
  9476. })
  9477. } else "aborted" === o.video.status && "aborted" === o.audio.status ? i({
  9478. status: "aborted",
  9479. reason: "stop",
  9480. video: o.video,
  9481. audio: o.audio
  9482. }) : i(null)
  9483. };
  9484. t.on("player-status-change", c),
  9485. t.audioOutput && t.player.setAudioOutput(t.audioOutput),
  9486. void 0 !== t.audioLevel && t.player.setAudioVolume(t.audioLevel),
  9487. t._flushAudioMixingMuteStatus(!1)
  9488. }
  9489. },
  9490. t.stop = function() {
  9491. var e = s.b.reportApiInvoke(t.sid, {
  9492. name: "Stream.stop",
  9493. options: arguments,
  9494. tag: "tracer"
  9495. });
  9496. r.
  9497. default.debug("[".concat(t.streamId, "] Stop stream player with id "), t.streamId),
  9498. t.player ? (he.removeEffectFromLocalPlayer(t), t.player.destroy(), delete t.player) : r.
  9499. default.error("[".concat(t.streamId, "] Stream.stop(): Stream is not playing")),
  9500. t._flushAudioMixingMuteStatus(!0),
  9501. e()
  9502. },
  9503. t.isPlaying = function() {
  9504. return !! t.player
  9505. },
  9506. t.isPaused = function() {
  9507. return !! t.player && ( !! (t.player.video && t.player.video.paused && t.player.mediaElemExists(t.player.video)) || !!(t.player.audio && t.player.audio.paused && t.player.mediaElemExists(t.player.audio)))
  9508. },
  9509. t.resume = function() {
  9510. var e, n;
  9511. return t.player ? (t.player.video && t.player.video.play && (e = t.player.video.play()), e = e || Promise.resolve(), t.player.audio && t.player.audio.play && (n = t.player.audio.play()), n = n || Promise.resolve(), Promise.all([e, n])) : Promise.reject("NO_PLAYER_FOUND")
  9512. },
  9513. t.getVideoTrack = function() {
  9514. var e = s.b.reportApiInvoke(t.sid, {
  9515. name: "Stream.getVideoTrack",
  9516. options: arguments,
  9517. tag: "tracer"
  9518. });
  9519. if (t.stream && t.stream.getVideoTracks) {
  9520. var n = t.stream.getVideoTracks()[0];
  9521. if (n) return r.
  9522. default.info("[".concat(t.streamId, "] getVideoTrack"), n),
  9523. e(),
  9524. n
  9525. }
  9526. r.
  9527. default.info("[".concat(t.streamId, "] getVideoTrack None")),
  9528. e(null, "getVideoTrack None")
  9529. },
  9530. t.getAudioTrack = function() {
  9531. var e = s.b.reportApiInvoke(t.sid, {
  9532. name: "Stream.getAudioTrack",
  9533. options: arguments,
  9534. tag: "tracer"
  9535. });
  9536. if (t.stream && t.stream.getAudioTracks) {
  9537. var n = t.stream.getAudioTracks()[0];
  9538. if (n) return r.
  9539. default.info("[".concat(t.streamId, "] getAudioTracks"), n),
  9540. e(),
  9541. n
  9542. }
  9543. r.
  9544. default.info("[".concat(t.streamId, "] getAudioTracks None")),
  9545. e(null, "getAudioTracks None")
  9546. },
  9547. t._hasVideoTracks = function() {
  9548. return !! (t.stream && t.stream.getVideoTracks && t.stream.getVideoTracks()[0])
  9549. },
  9550. t._hasAudioTracks = function() {
  9551. return !! (t.stream && t.stream.getAudioTracks && t.stream.getAudioTracks()[0])
  9552. },
  9553. t._replaceMediaStreamTrack = function(e, n, a) {
  9554. if (t.stream) {
  9555. if ("video" == e.kind) {
  9556. if (o = t.stream.getVideoTracks()[0]) return t.userMuteVideo && (e.enabled = !1),
  9557. t.stream.removeTrack(o),
  9558. t.stream.addTrack(e),
  9559. r.
  9560. default.debug("[".concat(t.streamId, "] _replaceMediaStreamTrack ").concat(e.kind, " SUCCESS")),
  9561. "live" == o.readyState && (o.stop(), r.
  9562. default.debug("[".concat(t.streamId, "] Track ").concat(o.kind, " Stopped"))),
  9563. n && n();
  9564. var i = "MEDIASTREAM_TRACK_NOT_FOUND";
  9565. return r.
  9566. default.error("[".concat(t.streamId, "] MEDIASTREAM_TRACK_NOT_FOUND ").concat(e.kind)),
  9567. a(i)
  9568. }
  9569. if ("audio" == e.kind) {
  9570. var o;
  9571. if (o = t.stream.getAudioTracks()[0]) {
  9572. t.userMuteAudio && (e.enabled = !1);
  9573. var s = new MediaStream;
  9574. s.addTrack(e);
  9575. var c = t.stream && t.stream.getVideoTracks()[0];
  9576. return c && s.addTrack(c),
  9577. t.stream = s,
  9578. t.audioLevelHelper = null,
  9579. t.player && t.player.video && (t.player.video.srcObject = t.stream),
  9580. r.
  9581. default.debug("[".concat(t.streamId, "] _replaceMediaStreamTrack SUCCESS")),
  9582. "live" == o.readyState && (o.stop(), r.
  9583. default.debug("[".concat(t.streamId, "] Track ").concat(o.kind, " Stopped"))),
  9584. n && n()
  9585. }
  9586. i = "MEDIASTREAM_TRACK_NOT_FOUND";
  9587. return r.
  9588. default.error("[".concat(t.streamId, "] MEDIASTREAM_TRACK_NOT_FOUND ").concat(e.kind)),
  9589. a(i)
  9590. }
  9591. i = "INVALID_TRACK_TYPE";
  9592. return r.
  9593. default.error("[".concat(t.streamId, "] _replaceMediaStreamTrack ").concat(i, " ").concat(e.kind)),
  9594. a && a(i)
  9595. }
  9596. i = "NO_STREAM_FOUND";
  9597. return r.
  9598. default.error("[".concat(t.streamId, "] _replaceMediaStreamTrack ").concat(i)),
  9599. a && a(i)
  9600. },
  9601. t.replaceTrack = function(e, a, i) {
  9602. var o = s.b.reportApiInvoke(t.sid, {
  9603. callback: function(e, t) {
  9604. if (e) return i && i(e);
  9605. a && a(t)
  9606. },
  9607. name: "Stream.replaceTrack",
  9608. options: arguments,
  9609. tag: "tracer"
  9610. });
  9611. return e && e.kind ? (t._cleanupAudioMixing(), e.onended || (e.onended = n), t.pc && t.pc.hasSender && t.pc.hasSender(e.kind) ? void t.pc.replaceTrack(e, (function() {
  9612. return r.
  9613. default.debug("[".concat(t.streamId, "] PeerConnection.replaceTrack ").concat(e.kind, " SUCCESS")),
  9614. t._replaceMediaStreamTrack(e, (function(e) {
  9615. return o(null, e)
  9616. }), o)
  9617. }), (function(n) {
  9618. return r.
  9619. default.error("[".concat(t.streamId, "] PeerConnection.replaceTrack ").concat(e.kind, " Failed ").concat(n)),
  9620. o(n)
  9621. })) : t._replaceMediaStreamTrack(e, (function(e) {
  9622. return o(null, e)
  9623. }), o)) : o("INVALID_TRACK")
  9624. },
  9625. t.setAudioVolume = function(e) {
  9626. var n = s.b.reportApiInvoke(t.sid, {
  9627. name: "Stream.setAudioVolume",
  9628. options: arguments,
  9629. tag: "tracer"
  9630. });
  9631. Object(z.checkValidNumber)(e, "level", 0, 100),
  9632. t.audioLevel = e,
  9633. t.player && t.player.setAudioVolume(e),
  9634. n()
  9635. },
  9636. t.getStats = function(e, n, a) {
  9637. var i = [];
  9638. i.push(t._getPCStats(a)),
  9639. i.push(new Promise((function(e) {
  9640. var n = {};
  9641. t.pc && t.pc.isSubscriber ? null !== window.navigator.userAgent.match("Firefox") && (q(n, "videoReceiveResolutionHeight", t.videoHeight), q(n, "videoReceiveResolutionWidth", t.videoWidth)) : t.pc && !t.pc.isSubscriber && ((Object(g.isSafari)() || Object(g.isFireFox)()) && (q(n, "videoSendResolutionHeight", t.videoHeight), q(n, "videoSendResolutionWidth", t.videoWidth)), (Object(g.isSafari)() || Object(g.isFireFox)()) && t.uplinkStats && q(n, "videoSendPacketsLost", t.uplinkStats.uplink_cumulative_lost)),
  9642. e(n)
  9643. }))),
  9644. i.push(new Promise((function(e) {
  9645. var n = {};
  9646. return t.traffic_stats && t.pc && t.pc.isSubscriber ? (q(n, "accessDelay", t.traffic_stats.access_delay), q(n, "endToEndDelay", t.traffic_stats.e2e_delay), q(n, "videoReceiveDelay", t.traffic_stats.video_delay), q(n, "audioReceiveDelay", t.traffic_stats.audio_delay)) : t.traffic_stats && t.pc && !t.pc.isSubscriber && q(n, "accessDelay", t.traffic_stats.access_delay),
  9647. e(n)
  9648. }))),
  9649. Promise.all(i).then((function(n) {
  9650. for (var a = {},
  9651. i = n.length - 1; i >= 0; i--) {
  9652. var o = n[i];
  9653. E()(a, o)
  9654. }
  9655. e && setTimeout(e.bind(t, a), 0)
  9656. })).
  9657. catch((function(e) {
  9658. n && setTimeout(n.bind(t, e), 0)
  9659. }))
  9660. },
  9661. t._getPCStats = function(e) {
  9662. return new Promise((function(n, a) {
  9663. if (!t.pc || "established" !== t.pc.state || !t.pc.getStats) {
  9664. return a("PEER_CONNECTION_NOT_ESTABLISHED")
  9665. }
  9666. t.pc.getStats((function(e) {
  9667. if (!t.pc || "established" !== t.pc.state || !t.pc.getStats) {
  9668. return a("PEER_CONNECTION_STATE_CHANGE")
  9669. }
  9670. var i = t.pc.isSubscriber ?
  9671. function(e) {
  9672. var t = {};
  9673. return e.forEach((function(e) {
  9674. e.id && e.type && ( - 1 === e.id.indexOf("recv") && -1 === e.type.toLowerCase().indexOf("inbound") && -1 === e.id.indexOf("inbound_rtp") && -1 === e.id.indexOf("inbound-rtp") && -1 === e.id.indexOf("InboundRTP") || ("audio" === e.mediaType ? (q(t, "audioReceiveBytes", e.bytesReceived), q(t, "audioReceivePackets", e.packetsReceived), q(t, "audioReceivePacketsLost", e.packetsLost)) : (q(t, "videoReceiveBytes", e.bytesReceived), q(t, "videoReceivePacketsLost", e.packetsLost), q(t, "videoReceivePackets", e.packetsReceived), q(t, "videoReceiveFrameRate", e.googFrameRateReceived), q(t, "videoReceiveDecodeFrameRate", e.googFrameRateDecoded), q(t, "videoReceiveResolutionWidth", e.googFrameWidthReceived), q(t, "videoReceiveResolutionHeight", e.googFrameHeightReceived))))
  9675. })),
  9676. t
  9677. } (e) : function(e) {
  9678. var t = {};
  9679. return e.forEach((function(e) {
  9680. e.id && e.type && ( - 1 === e.id.indexOf("send") && -1 === e.type.toLowerCase().indexOf("outbound") && -1 === e.id.indexOf("outbound_rtp") && -1 === e.id.indexOf("OutboundRTP") || ("audio" === e.mediaType ? (q(t, "audioSendBytes", e.bytesSent), q(t, "audioSendPackets", e.packetsSent), q(t, "audioSendPacketsLost", e.packetsLost)) : (q(t, "videoSendBytes", e.bytesSent), q(t, "videoSendPackets", e.packetsSent), q(t, "videoSendPacketsLost", e.packetsLost), q(t, "videoSendFrameRate", e.googFrameRateSent), q(t, "videoSendResolutionWidth", e.googFrameWidthSent), q(t, "videoSendResolutionHeight", e.googFrameHeightSent))))
  9681. })),
  9682. t
  9683. } (e);
  9684. return n(i)
  9685. }), e)
  9686. })).then((function(e) {
  9687. return t.pc.isSubscriber ? (Object(g.isFireFox)() || Object(g.isSafari)()) && (e.videoReceiveResolutionHeight && "0" !== e.videoReceiveResolutionHeight || e.videoReceiveResolutionWidth && "0" !== e.videoReceiveResolutionWidth || (q(e, "videoReceiveResolutionHeight", t.videoHeight), q(e, "videoReceiveResolutionWidth", t.videoWidth))) : ((Object(g.isSafari)() || Object(g.isFireFox)()) && (e.videoSendResolutionHeight && "0" !== e.videoSendResolutionHeight || e.videoSendResolutionWidth && "0" !== e.videoSendResolutionWidth || (q(e, "videoSendResolutionHeight", t.videoHeight), q(e, "videoSendResolutionWidth", t.videoWidth))), (Object(g.isSafari)() || Object(g.isFireFox)()) && t.uplinkStats && q(e, "videoSendPacketsLost", t.uplinkStats.uplink_cumulative_lost)),
  9688. Promise.resolve(e)
  9689. }))
  9690. },
  9691. t.getAudioLevel = function() {
  9692. if (t.audioLevelHelper) return t.audioLevelHelper.getAudioLevel();
  9693. if (t.stream) {
  9694. if (0 !== t.stream.getAudioTracks().length) return t.audioLevelHelper = new H.audioLevelHelper(t.stream),
  9695. t.audioLevelHelper.getAudioLevel();
  9696. r.
  9697. default.warning("[".concat(t.streamId, "] can't get audioLevel beacuse no audio trace in stream"))
  9698. } else r.
  9699. default.warning("[".concat(t.streamId, "] can't get audioLevel beacuse no stream exist"))
  9700. },
  9701. t.setVideoProfile("480p_1"),
  9702. t._switchVideoDevice = function(e, n, a) {
  9703. if (e === t.cameraId) return n && n();
  9704. var i = {
  9705. video: E()({},
  9706. t.videoConstraint, {
  9707. deviceId: {
  9708. exact: e
  9709. }
  9710. }),
  9711. audio: !1
  9712. };
  9713. r.
  9714. default.debug("[".concat(t.streamId, "] ").concat(i)),
  9715. G(i, (function(i) {
  9716. try {
  9717. var o = function() {
  9718. t.isPlaying() && (t.stop(), t.elementID && t.play(t.elementID, t.playOptions)),
  9719. t.cameraId = e,
  9720. t.videoConstraint.deviceId = {
  9721. exact: e
  9722. },
  9723. t.userMuteVideo && (t.stream.getVideoTracks()[0].enabled = !1),
  9724. he.restoreVideoEffect(t).then((function() {
  9725. n && n()
  9726. }))
  9727. };
  9728. he.disableVideoEffect(t).then((function() {
  9729. Object(g.isSafari)() ? t.replaceTrack(i.getVideoTracks()[0], o, a) : (t.removeTrack(t.stream.getVideoTracks()[0]), t.addTrack(i.getVideoTracks()[0]), o())
  9730. }))
  9731. } catch(e) {
  9732. return a && a(e)
  9733. }
  9734. }), (function(e) {
  9735. return a && a(e)
  9736. }))
  9737. },
  9738. t._switchAudioDevice = function(e, n, a) {
  9739. if (e === t.microphoneId) return n && n();
  9740. var i = {
  9741. video: !1,
  9742. audio: E()({},
  9743. t.audioConstraint, {
  9744. deviceId: {
  9745. exact: e
  9746. }
  9747. })
  9748. };
  9749. r.
  9750. default.debug("[".concat(t.streamId, "] "), i),
  9751. G(i, (function(i) {
  9752. var o = function() {
  9753. t._cleanupAudioMixing(),
  9754. t.userMuteAudio && (t.stream.getAudioTracks()[0].enabled = !1),
  9755. t.isPlaying() && (t.stop(), t.elementID && t.play(t.elementID)),
  9756. t.microphoneId = e,
  9757. t.audioConstraint.deviceId = {
  9758. exact: e
  9759. },
  9760. n && n()
  9761. };
  9762. try {
  9763. Object(g.isSafari)() ? t.replaceTrack(i.getAudioTracks()[0], o, a) : (t.removeTrack(t.stream.getAudioTracks()[0]), t.addTrack(i.getAudioTracks()[0]), o())
  9764. } catch(e) {
  9765. return a && a(e)
  9766. }
  9767. }), (function(e) {
  9768. return a && a(e)
  9769. }))
  9770. },
  9771. t.switchDevice = function(e, n, a, i) {
  9772. var o = s.b.reportApiInvoke(t.sid, {
  9773. callback: function(e, t) {
  9774. if (e) return i && i(e);
  9775. a && a(t)
  9776. },
  9777. name: "Stream.switchDevice",
  9778. options: arguments,
  9779. tag: "tracer"
  9780. });
  9781. Object(z.checkValidString)(n, "deviceId");
  9782. var c = function() {
  9783. return t.inSwitchDevice = !1,
  9784. o()
  9785. },
  9786. d = function(e) {
  9787. t.inSwitchDevice = !1,
  9788. r.
  9789. default.error("[".concat(t.streamId, "] "), e),
  9790. o(e)
  9791. };
  9792. if (t.inSwitchDevice) return o("Device switch is in process.");
  9793. if (t.inSwitchDevice = !0, !t.local) return d("Only the local stream can switch the device.");
  9794. if (t.screen && "video" === e) return d("The device cannot be switched during screen-sharing.");
  9795. if (!t.video && "video" === e) return d("Video track not exist.");
  9796. if (!t.audio && "audio" === e) return d("Audio track not exist.");
  9797. if (t.videoSource || t.audioSource) return d("The device cannot be switched when using videoSource or audioSource.");
  9798. var u = !1;
  9799. for (var l in t.audioMixing.sounds) {
  9800. var p = t.audioMixing.sounds[l];
  9801. if (p.state !== t.audioMixing.states.IDLE) {
  9802. u = !0;
  9803. break
  9804. }
  9805. }
  9806. var f = t.audioMixing.audioContextInited;
  9807. if (f && u) return d("The device cannot be switched when using audio Mixing.");
  9808. K.getDeviceById(n, (function() {
  9809. if ("video" === e) t._switchVideoDevice(n, c, d);
  9810. else {
  9811. if ("audio" !== e) return d("Invalid type.");
  9812. t._switchAudioDevice(n, c, d)
  9813. }
  9814. }), (function() {
  9815. return d("The device does not exist.")
  9816. }))
  9817. },
  9818. t
  9819. },
  9820. Oe = a(27),
  9821. Ce = a(8),
  9822. Ne = a.n(Ce),
  9823. we = ["live", "rtc", "web", "interop", "h264_interop", "web-only"],
  9824. De = ["vp8", "h264"],
  9825. ke = ["aes-128-xts", "aes-256-xts", "aes-128-ecb", "sm4-128-ecb"],
  9826. Le = a(17),
  9827. Pe = a.n(Le),
  9828. Me = function(e) {
  9829. e && e.apply(this, [].slice.call(arguments, 1))
  9830. },
  9831. Ue = a(11),
  9832. xe = function(e) {
  9833. var t = c();
  9834. t.needReconnect = !0,
  9835. t.isTimeout = !1,
  9836. t.isInit = !0,
  9837. t.sendbytes = 0,
  9838. t.recvbytes = 0,
  9839. t.startTime = Date.now(),
  9840. t.lastMsgTime = null,
  9841. t.clientId = e.clientId,
  9842. t.hostIndex = 0,
  9843. t.requestID = 0,
  9844. e.host instanceof Array ? t.host = e.host: t.host = [e.host],
  9845. t.getSendBytes = function() {
  9846. return t.sendbytes
  9847. },
  9848. t.getRecvBytes = function() {
  9849. return t.recvbytes
  9850. },
  9851. t.getDuration = function() {
  9852. return Math.ceil((Date.now() - t.startTime) / 1e3)
  9853. },
  9854. t.getURL = function() {
  9855. return t.connection.url
  9856. },
  9857. t.reconnect = function() {
  9858. t.isInit = !0,
  9859. t.creatConnection()
  9860. },
  9861. t.connectNext = function() {
  9862. t.isInit = !0,
  9863. ++t.hostIndex,
  9864. r.
  9865. default.debug("[" + t.clientId + "] Gateway length:" + t.host.length + " current index:" + t.hostIndex),
  9866. t.hostIndex >= t.host.length ? t.dispatchEvent(p({
  9867. type: "recover"
  9868. })) : t.creatConnection()
  9869. },
  9870. t.replaceHost = function(e) {
  9871. t.host = e || t.host,
  9872. t.hostIndex = 0,
  9873. t.creatConnection()
  9874. },
  9875. t.creatConnection = function() {
  9876. if (t.needReconnect = !0, t.lts = (new Date).getTime(), t.connection = new WebSocket("wss://" + t.host[t.hostIndex]), t.connection.binaryType = "arraybuffer", t.turnConfig = {},
  9877. t.connection.url) {
  9878. var n = t.connection.url.match(/wss\:\/\/([^:]+):(\d+)/),
  9879. a = t.host[t.hostIndex].split(":"),
  9880. i = t.connection.url.match(/h=([^:]+)&p=(\d+)/);
  9881. n ? (t.turnConfig.url = n[1], Object(o.getParameter)("TURN_ENABLE_TCP") && (t.turnConfig.tcpport = parseInt(n[2]) + 30), Object(o.getParameter)("TURN_ENABLE_UDP") && (t.turnConfig.udpport = parseInt(n[2]) + 30)) : i ? (t.turnConfig.url = i[1], Object(o.getParameter)("TURN_ENABLE_TCP") && (t.turnConfig.tcpport = parseInt(i[2]) + 30), Object(o.getParameter)("TURN_ENABLE_UDP") && (t.turnConfig.udpport = parseInt(i[2]) + 30)) : a && (t.turnConfig.url = a[0], Object(o.getParameter)("TURN_ENABLE_TCP") && (t.turnConfig.tcpport = parseInt(a[1]) + 30), Object(o.getParameter)("TURN_ENABLE_UDP") && (t.turnConfig.udpport = parseInt(a[1]) + 30))
  9882. }
  9883. t.connection.onopen = function(e) {
  9884. t.needReconnect = !0,
  9885. t.isTimeout = !1,
  9886. t.isInit = !1,
  9887. t.sendbytes = 0,
  9888. t.recvbytes = 0,
  9889. t.startTime = Date.now(),
  9890. Object(Ue.resetHTTPByetsCount)(),
  9891. clearTimeout(t.timeoutCheck),
  9892. t.dispatchEvent(p({
  9893. type: "onopen",
  9894. event: e,
  9895. socket: t
  9896. }))
  9897. },
  9898. t.connection.onmessage = function(e) {
  9899. if (e.data instanceof ArrayBuffer) t.dispatchEvent({
  9900. type: "onBinaryData",
  9901. data: e.data
  9902. });
  9903. else {
  9904. t.recvbytes += Object(H.lengthInUtf8Bytes)(e.data);
  9905. var n = JSON.parse(e.data);
  9906. t.lastMsgTime = Date.now(),
  9907. n.hasOwnProperty("_id") ? t.dispatchEvent(p({
  9908. type: n._id,
  9909. msg: n
  9910. })) : n.hasOwnProperty("_type") && t.dispatchSocketEvent(p({
  9911. type: n._type,
  9912. msg: n._message
  9913. }))
  9914. }
  9915. },
  9916. t.connection.onclose = function(n) {
  9917. t.needReconnect ? t.isTimeout || t.isInit ? (r.
  9918. default.debug("[" + t.clientId + "] websockect connect timeout"), s.b.joinGateway(e.sid, {
  9919. lts: t.lts,
  9920. succ: !1,
  9921. ec: "timeout",
  9922. addr: t.connection.url
  9923. }), t.connectNext()) : (t.dispatchEvent(p({
  9924. type: "disconnect",
  9925. event: n
  9926. })), t.requests && t.requests instanceof Array && (t.requests.map((function(e) {
  9927. e.callback("REQUEST_ABORT")
  9928. })), t.requests = [])) : (r.
  9929. default.debug("[" + t.clientId + "] websockect closeed"), Me(e.onFailure, n), clearTimeout(t.timeoutCheck), t.dispatchEvent(p({
  9930. type: "close",
  9931. event: n
  9932. })), t.connection.onopen = void 0, t.connection.onclose = void 0, t.connection.onerror = void 0, t.connection.onmessage = void 0, t.connection = void 0)
  9933. },
  9934. t.connection.onerror = function(e) {};
  9935. setTimeout((function() {
  9936. t.connection && t.connection.readyState != WebSocket.OPEN && (t.isTimeout = !0, t.connection.close())
  9937. }), 5e3)
  9938. },
  9939. t.creatConnection(),
  9940. t.sendMessage = function(e, n) {
  9941. if (t.connection && t.connection.readyState == WebSocket.OPEN) {
  9942. var a = JSON.stringify(e);
  9943. t.sendbytes += Object(H.lengthInUtf8Bytes)(a),
  9944. t.connection.send(a)
  9945. } else n({
  9946. error: "Gateway not connected"
  9947. })
  9948. },
  9949. t.disconnect = function() {
  9950. t.needReconnect = !0,
  9951. t.connection.close()
  9952. },
  9953. t.close = function() {
  9954. t.needReconnect = !1,
  9955. t.connection.onclose = void 0,
  9956. t.connection.close(),
  9957. clearInterval(t.requestTimer),
  9958. t.requests && t.requests instanceof Array && (t.requests.map((function(e) {
  9959. e.callback("REQUEST_ABORT")
  9960. })), t.requests = [])
  9961. },
  9962. t.sendSignalCommand = function(e, n) {
  9963. e._id = "_request_" + t.requestID,
  9964. t.requestID += 1,
  9965. "publish_stats" !== e._type && "subscribe_stats" !== e._type && "publish_stats_low" !== e._type && t.on(e._id, (function(a) {
  9966. a.msg && n && n(a.msg._result, a.msg.message),
  9967. delete t.dispatcher.eventListeners[e._id]
  9968. })),
  9969. t.sendMessage(e, (function(e) {
  9970. e.reason = "NOT_CONNECTED",
  9971. n && n(e.reason, e)
  9972. }))
  9973. },
  9974. t.requests = [];
  9975. var n = function(e) {
  9976. var n = t.requests.findIndex((function(t) {
  9977. return t.id === e.type
  9978. }));
  9979. if (n >= 0) var a = t.requests.splice(n, 1)[0];
  9980. a && t.dispatcher.eventListeners[e.type] ? (delete t.dispatcher.eventListeners[e.type], e.msg && a.callback && a.callback(e.msg._result, e.msg._message)) : r.
  9981. default.warning("Detached Response", e.type, e.msg)
  9982. },
  9983. a = function(e) {
  9984. var n = this,
  9985. a = t.requests.findIndex((function(e) {
  9986. return e.id === n.id
  9987. }));
  9988. a >= 0 && (n = t.requests.splice(a, 1)[0]),
  9989. n && t.dispatcher.eventListeners[e.type] ? (delete t.dispatcher.eventListeners[e.type], e.reason = "NOT_CONNECTED", n.callback && n.callback(e.reason, e)) : r.
  9990. default.warning("handleSendError", n)
  9991. };
  9992. return t.sendRequest = function(e, i) {
  9993. e = E()({
  9994. _id: "_request_" + t.requestID
  9995. },
  9996. e),
  9997. t.requestID += 1;
  9998. var o = {
  9999. id: e._id,
  10000. timeoutCounter: 0,
  10001. stalledAt: Date.now(),
  10002. message: e,
  10003. callback: i
  10004. };
  10005. t.requests.push(o),
  10006. t.addEventListener(e._id, n),
  10007. t.sendMessage(e, a.bind(o))
  10008. },
  10009. t.checkRequestTimeout = function() {
  10010. for (var e = Math.ceil(Object(o.getParameter)("SIGNAL_REQUEST_TIMEOUT") / Object(o.getParameter)("SIGNAL_REQUEST_WATCH_INTERVAL")), n = t.requests.length - 1; n >= 0; n--) {
  10011. var a = t.requests[n];
  10012. a.timeoutCounter >= e ? (t.requests.splice(n, 1), r.
  10013. default.error("Request Timeout", a.timeoutCounter, a.message), a.callback && a.callback("TIMEOUT")) : a.timeoutCounter++
  10014. }
  10015. },
  10016. clearInterval(t.requestTimer),
  10017. t.requestTimer = setInterval(t.checkRequestTimeout, Object(o.getParameter)("SIGNAL_REQUEST_WATCH_INTERVAL")),
  10018. t.sendReport = function(e) {
  10019. t.sendMessage(e, (function() {}))
  10020. },
  10021. t
  10022. },
  10023. Ve = function(e, t) {
  10024. var n = {
  10025. connect: function() {
  10026. t.host = e,
  10027. n.signal = xe(t),
  10028. n.on = n.signal.on,
  10029. n.dispatchEvent = n.signal.dispatchEvent,
  10030. n.signal.on("onopen", (function(e) {
  10031. n.signal.onEvent = function(e) {
  10032. n.dispatchEvent(p({
  10033. type: e.event,
  10034. msg: e
  10035. }))
  10036. },
  10037. n.dispatchEvent(p({
  10038. type: "connect",
  10039. msg: e
  10040. }))
  10041. })),
  10042. n.signal.on("onError", (function(e) {
  10043. var t = e.msg;
  10044. onError(t.code, "error")
  10045. }))
  10046. },
  10047. getLastMsgTime: function() {
  10048. return n.signal && n.signal.lastMsgTime
  10049. },
  10050. getSendBytes: function() {
  10051. return n.signal.getSendBytes()
  10052. },
  10053. getRecvBytes: function() {
  10054. return n.signal.getRecvBytes()
  10055. },
  10056. getDuration: function() {
  10057. return n.signal.getDuration()
  10058. },
  10059. disconnect: function() {
  10060. n.signal.disconnect()
  10061. },
  10062. close: function() {
  10063. n.signal.close()
  10064. },
  10065. getURL: function() {
  10066. return n.signal.getURL()
  10067. },
  10068. reconnect: function() {
  10069. n.signal.reconnect()
  10070. },
  10071. connectNext: function() {
  10072. n.signal.connectNext()
  10073. },
  10074. replaceHost: function(e) {
  10075. n.signal.replaceHost(e)
  10076. },
  10077. emitSimpleMessage: function(e, t) {
  10078. n.signal.sendSignalCommand(e, t)
  10079. },
  10080. emitRequest: function(e, t) {
  10081. n.signal.sendRequest(e, t)
  10082. },
  10083. emitReport: function(e) {
  10084. n.signal.sendReport(e)
  10085. }
  10086. };
  10087. return n.connect(),
  10088. n
  10089. },
  10090. je = function(e, t) {
  10091. var n = !1,
  10092. a = 0,
  10093. i = {
  10094. command: "convergeAllocateEdge",
  10095. sid: e.sid,
  10096. appId: e.appId,
  10097. token: e.token,
  10098. uid: e.uid,
  10099. cname: e.cname,
  10100. ts: Math.floor(Date.now() / 1e3),
  10101. version: o.VERSION,
  10102. seq: 0,
  10103. requestId: 1
  10104. };
  10105. Object(o.getParameter)("PROXY_CS").map((function(c) {
  10106. var d = (new Date).getTime();
  10107. Be("https://" + c + "/api/v1", i, (function(i, u) {
  10108. if (i) return r.
  10109. default.debug("[" + e.clientId + "] Request proxy server failed: ", i),
  10110. a++,
  10111. s.b.requestProxyAppCenter(e.sid, {
  10112. lts: d,
  10113. succ: !1,
  10114. APAddr: c,
  10115. workerManagerList: null,
  10116. ec: JSON.stringify(i),
  10117. response: JSON.stringify({
  10118. err: i,
  10119. res: u
  10120. })
  10121. }),
  10122. void(a >= Object(o.getParameter)("PROXY_CS").length && t && t("Get proxy server failed: request all failed"));
  10123. if (!n) if ((u = JSON.parse(u)).json_body) {
  10124. var l = JSON.parse(u.json_body);
  10125. if (r.
  10126. default.debug("[" + e.clientId + "] App return:", l.servers), 200 !== l.code) {
  10127. i = "Get proxy server failed: response code [" + l.code + "], reason [ " + l.reason + "]";
  10128. r.
  10129. default.debug("[" + e.clientId + "] " + i),
  10130. s.b.requestProxyAppCenter(e.sid, {
  10131. lts: d,
  10132. succ: !1,
  10133. APAddr: c,
  10134. workerManagerList: null,
  10135. ec: i,
  10136. response: JSON.stringify({
  10137. err: i,
  10138. res: u
  10139. })
  10140. })
  10141. } else {
  10142. n = !0;
  10143. var p = We(l.servers);
  10144. s.b.requestProxyAppCenter(e.sid, {
  10145. lts: d,
  10146. succ: !0,
  10147. APAddr: c,
  10148. workerManagerList: JSON.stringify(p),
  10149. ec: null,
  10150. response: JSON.stringify({
  10151. res: u
  10152. })
  10153. }),
  10154. t && t(null, p)
  10155. }
  10156. } else r.
  10157. default.debug("[" + e.clientId + "] Get proxy server failed: no json_body"),
  10158. s.b.requestProxyAppCenter(e.sid, {
  10159. lts: d,
  10160. succ: !1,
  10161. APAddr: c,
  10162. workerManagerList: null,
  10163. ec: "Get proxy server failed: no json_body",
  10164. response: JSON.stringify({
  10165. res: u
  10166. })
  10167. })
  10168. }))
  10169. }))
  10170. },
  10171. Be = function(e, t, n) {
  10172. var a = {
  10173. service_name: "webrtc_proxy",
  10174. json_body: JSON.stringify(t)
  10175. };
  10176. Object(Ue.post)(e, a, (function(e) {
  10177. n && n(null, e)
  10178. }), (function(e) {
  10179. n && n(e)
  10180. }), {
  10181. "X-Packet-Service-Type": 0,
  10182. "X-Packet-URI": 61
  10183. })
  10184. },
  10185. Fe = function(e, t, n) {
  10186. var a = !1,
  10187. i = 0,
  10188. o = {
  10189. command: "request",
  10190. gatewayType: "http",
  10191. appId: e.appId,
  10192. cname: e.cname,
  10193. uid: e.uid + "",
  10194. sdkVersion: "2.3.1",
  10195. sid: e.sid,
  10196. seq: 1,
  10197. ts: +new Date,
  10198. requestId: 3,
  10199. clientRequest: {
  10200. appId: e.appId,
  10201. cname: e.cname,
  10202. uid: e.uid + "",
  10203. sid: e.sid
  10204. }
  10205. };
  10206. t.map((function(c) {
  10207. var d = (new Date).getTime(); !
  10208. function(e, t, n) {
  10209. Object(Ue.post)(e, t, (function(e) {
  10210. n && n(null, e)
  10211. }), (function(e) {
  10212. n && n(e)
  10213. }))
  10214. } ("https://" + c + ":4000/v2/machine", o, (function(o, u) {
  10215. if (o) return r.
  10216. default.debug("[" + e.clientId + "] Request worker manager failed: ", o),
  10217. i++,
  10218. s.b.requestProxyWorkerManager(e.sid, {
  10219. lts: d,
  10220. succ: !1,
  10221. workerManagerAddr: c,
  10222. ec: JSON.stringify(o),
  10223. response: JSON.stringify({
  10224. res: u
  10225. })
  10226. }),
  10227. void(i >= t.length && n && n("requeet worker manager server failed: request failed"));
  10228. if (!a) {
  10229. if (! (u = JSON.parse(u)).serverResponse) return n && n("requeet worker manager server failed: serverResponse is undefined");
  10230. a = !0,
  10231. s.b.requestProxyWorkerManager(e.sid, {
  10232. lts: d,
  10233. succ: !0,
  10234. workerManagerAddr: c,
  10235. ec: JSON.stringify(o),
  10236. response: JSON.stringify({
  10237. res: u
  10238. })
  10239. }),
  10240. n && n(null, {
  10241. address: c,
  10242. serverResponse: u.serverResponse
  10243. })
  10244. }
  10245. }))
  10246. }))
  10247. },
  10248. We = function(e) {
  10249. if (!e || [] instanceof Array == !1) return [];
  10250. var t = [];
  10251. return e.forEach((function(e) {
  10252. var n;
  10253. e.address && e.tcp ? (e.address.match(/^[\.\:\d]+$/) ? n = "".concat(e.address.replace(/[^\d]/g, "-"), ".edge.agora.io") : (r.
  10254. default.info("[" + joinInfo.clientId + "] " + "Cannot recognized as IP address ".concat(e.address, ". Used As Host instead")), n = "".concat(e.address, ":").concat(e.tcp)), t.push(n)) : r.
  10255. default.error("[" + joinInfo.clientId + "] Invalid address format ", e)
  10256. })),
  10257. t
  10258. },
  10259. Ge = function(e, t) {
  10260. var n = E()({},
  10261. e),
  10262. a = Object(o.getParameter)("CDS_AP"),
  10263. i = [],
  10264. r = !1; (a = a.map((function(e) {
  10265. return n.proxyServer ? "https://".concat(n.proxyServer, "/ap/?url=").concat(e + "/api/v1") : "https://".concat(e, "/api/v1?action=config")
  10266. }))).map((function(e) { !
  10267. function(e, t, n) {
  10268. var a = {
  10269. flag: 64,
  10270. cipher_method: 0,
  10271. timeout: 1e3,
  10272. features: t
  10273. };
  10274. Object(Ue.post)(e, a, (function(e) {
  10275. try {
  10276. var t = JSON.parse(e);
  10277. n && n(null, t)
  10278. } catch(e) {
  10279. n && n(e)
  10280. }
  10281. n && n(null, e)
  10282. }), (function(e) {
  10283. n && n(e)
  10284. }), {
  10285. "X-Packet-Service-Type": 0,
  10286. "X-Packet-URI": 54
  10287. })
  10288. } (e, n, (function(e, n) {
  10289. r || (e ? (i.push(e), i.length >= a.length && t && t("ALL_REQUEST_FAILED")) : (r = !0, t && t(null, n)))
  10290. }))
  10291. }))
  10292. },
  10293. He = a(18),
  10294. qe = {},
  10295. Je = {},
  10296. Ye = function(e) {
  10297. return qe[e]
  10298. },
  10299. Ke = function(e, t, n, a, i) {
  10300. var c = (new Date).getTime(),
  10301. d = t,
  10302. u = "";
  10303. t.multiIP && t.multiIP.gateway_ip && (u = {
  10304. vocs_ip: [t.multiIP.uni_lbs_ip],
  10305. vos_ip: [t.multiIP.gateway_ip]
  10306. });
  10307. var l = {
  10308. opid: 133,
  10309. flag: 4096,
  10310. ts: +new Date,
  10311. key: t.token,
  10312. cname: t.cname,
  10313. sid: t.sid,
  10314. detail: {
  10315. 6 : t.stringUid,
  10316. 11 : i
  10317. },
  10318. uid: t.uid || 0
  10319. };
  10320. u && (l.detail[5] = JSON.stringify(u)),
  10321. Object(Ue.post)(e + "".concat( - 1 === e.indexOf("?") ? "?": "&", "action=wrtc_gateway"), l, (function(i) {
  10322. try {
  10323. var u = JSON.parse(i);
  10324. u.res && (u = u.res);
  10325. var l = u.code
  10326. } catch(e) {
  10327. var p = "requestChooseServer failed with unexpected body " + i;
  10328. return r.
  10329. default.error("[" + d.clientId + "]", p),
  10330. a(p)
  10331. }
  10332. if (l) return v = new RegExp(/10102\d{2}$/).test(l) ? "NO_SERVICE_AVAILABLE": I.APErrorCode[u.code] || l,
  10333. s.b.joinChooseServer(t.sid, {
  10334. lts: c,
  10335. succ: !1,
  10336. csAddr: e,
  10337. serverList: null,
  10338. ec: v
  10339. }),
  10340. a("Get server node failed [" + v + "]", e, v);
  10341. var f = [],
  10342. g = Object(o.getParameter)("GATEWAY_DOMAINS"),
  10343. m = 0;
  10344. if (e.indexOf(g[1]) > -1 && (m = 1), u.addresses.forEach((function(e) {
  10345. var t;
  10346. e.ip && e.port ? (e.ip.match(/^[\.\:\d]+$/) ? t = "".concat(e.ip.replace(/[^\d]/g, "-"), ".").concat(g[m++%g.length], ":").concat(e.port) : (r.
  10347. default.info("[" + d.clientId + "] " + "Cannot recognized as IP address ".concat(e.ip, ". Used As Host instead")), t = "".concat(e.ip, ":").concat(e.port)), f.push(t)) : r.
  10348. default.error("[" + d.clientId + "] Invalid address format ", e)
  10349. })), !f.length) {
  10350. r.
  10351. default.error("[" + d.clientId + "] Empty Address response", u);
  10352. var v = "EMPTY_ADDRESS_RESPONSE";
  10353. return s.b.joinChooseServer(t.sid, {
  10354. lts: c,
  10355. succ: !1,
  10356. csAddr: e,
  10357. serverList: null,
  10358. ec: v
  10359. }),
  10360. a("Get server node failed [" + v + "]", e, v)
  10361. }
  10362. var S = {
  10363. gateway_addr: f,
  10364. uid: u.uid,
  10365. cid: u.cid,
  10366. vid: u.detail && u.detail[8],
  10367. res: u,
  10368. uni_lbs_ip: u.detail
  10369. };
  10370. return n(S, e)
  10371. }), (function(e, n) {
  10372. "timeout" === e.type ? (s.b.joinChooseServer(t.sid, {
  10373. lts: c,
  10374. succ: !1,
  10375. csAddr: n,
  10376. serverList: null,
  10377. ec: "timeout"
  10378. }), a("Connect choose server timeout", n)) : (s.b.joinChooseServer(t.sid, {
  10379. lts: c,
  10380. succ: !1,
  10381. csAddr: n,
  10382. serverList: null,
  10383. ec: "server_wrong"
  10384. }), a("Connect choose server error", n))
  10385. }), {
  10386. "X-Packet-Service-Type": 0,
  10387. "X-Packet-URI": 69
  10388. })
  10389. },
  10390. ze = function(e, t, n) {
  10391. var a = !1,
  10392. i = null,
  10393. c = 1,
  10394. d = 1,
  10395. u = null,
  10396. l = e.clientId,
  10397. p = function t(d, p) {
  10398. if (!a) {
  10399. var f = !1,
  10400. m = !1,
  10401. v = [],
  10402. S = g.getBrowserInfo() || {};
  10403. Ge({
  10404. device: S.name,
  10405. system: S.os,
  10406. vendor: e.appId,
  10407. version: o.VERSION,
  10408. cname: e.cname,
  10409. sid: e.sid,
  10410. session_id: Object(s.a)(),
  10411. detail: "",
  10412. proxyServer: d
  10413. },
  10414. (function(t, n) {
  10415. m = !0;
  10416. try {
  10417. var a = Object.keys(n.test_tags)[0],
  10418. i = JSON.parse(n.test_tags[a]);
  10419. u = i[1]
  10420. } catch(e) {
  10421. u = null
  10422. }
  10423. s.b.reportApiInvoke(e.sid, {
  10424. name: "_config-distribute-request",
  10425. options: {
  10426. err: t,
  10427. res: n
  10428. }
  10429. })(),
  10430. Je[l] !== st.DISCONNECTED && Je[l] !== st.DISCONNECTING ? f && p && p(v, u) : r.
  10431. default.debug("[".concat(e.clientId, "] Request config success when connection state is ").concat(Je[l]))
  10432. })),
  10433. function(e, t, n) {
  10434. for (var a, i = (new Date).getTime(), c = !1, d = !0, u = 0, l = Object(o.getParameter)("WEBCS_DOMAIN"), p = Object(o.getParameter)("WEBCS_DOMAIN_BACKUP_LIST"), f = function(n, a) {
  10435. if (c) s.b.joinChooseServer(e.sid, {
  10436. lts: i,
  10437. succ: !0,
  10438. csAddr: a,
  10439. serverList: n.gateway_addr,
  10440. cid: n.cid + "",
  10441. uid: n.uid + "",
  10442. ec: null
  10443. },
  10444. !1);
  10445. else {
  10446. if (clearTimeout(_), c = !0, e.proxyServer) for (var o = n.gateway_addr,
  10447. r = 0; r < o.length; r++) {
  10448. var d = o[r].split(":");
  10449. n.gateway_addr[r] = e.proxyServer + "/ws/?h=" + d[0] + "&p=" + d[1]
  10450. }
  10451. t(n),
  10452. s.b.joinChooseServer(e.sid, {
  10453. lts: i,
  10454. succ: !0,
  10455. csAddr: a,
  10456. serverList: n.gateway_addr,
  10457. cid: n.cid + "",
  10458. uid: n.uid + "",
  10459. ec: null
  10460. },
  10461. !0)
  10462. }
  10463. },
  10464. g = function(t, i, o) {
  10465. u++,
  10466. r.
  10467. default.error("[" + e.clientId + "]", t, i, o),
  10468. o && -1 === I.JOIN_CS_RETRY_LIST.indexOf(o) && (d = !1, a = o),
  10469. u === l.length + p.length && n(a)
  10470. },
  10471. m = 0; m < l.length; ++m) {
  10472. var v;
  10473. if ("string" == typeof l[m]) {
  10474. var S = l[m];
  10475. v = e.proxyServer ? "https://".concat(e.proxyServer, "/ap/?url=").concat(S + "/api/v1") : "https://".concat(S, "/api/v1");
  10476. var E = Object(He.getAreaCodeByWebCS)(S);
  10477. r.
  10478. default.debug("[" + e.clientId + "] " + "Connect to choose_server: ".concat(v, ", ").concat(E)),
  10479. Ke(v, e, f, g, E)
  10480. } else r.
  10481. default.error("[" + e.clientId + "] Invalid Host", l[m])
  10482. }
  10483. var _ = setTimeout((function() {
  10484. if (!c) for (var t = 0; t < p.length; ++t) {
  10485. if ("string" == typeof p[t]) {
  10486. var n = p[t];
  10487. v = e.proxyServer ? "https://".concat(e.proxyServer, "/ap/?url=").concat(n + "/api/v1") : "https://".concat(n, "/api/v1");
  10488. var a = Object(He.getAreaCodeByWebCS)(n);
  10489. r.
  10490. default.debug("[" + e.clientId + "] " + "Connect to backup_choose_server: ".concat(v, ", ").concat(a)),
  10491. Ke(v, e, f, g, a)
  10492. } else r.
  10493. default.error("[" + e.clientId + "] Invalid Host", p[t])
  10494. }
  10495. }), 1e3);
  10496. setTimeout((function() { ! c && d && n()
  10497. }), Object(o.getParameter)("WEBCS_BACKUP_CONNECT_TIMEOUT"))
  10498. } (e, (function(t) {
  10499. a = !0,
  10500. f = !0,
  10501. v = t,
  10502. clearTimeout(i),
  10503. Je[l] !== st.DISCONNECTED && Je[l] !== st.DISCONNECTING ? m && p && p(v, u) : r.
  10504. default.debug("[".concat(e.clientId, "] Request gateway list success when connection state is ").concat(Je[l]))
  10505. }), (function(a) {
  10506. if (a) return r.
  10507. default.info("[" + e.clientId + "] Join failed: " + a),
  10508. void(n && n(a));
  10509. if (Je[l] === st.DISCONNECTED || Je[l] === st.DISCONNECTING) return r.
  10510. default.debug("[".concat(e.clientId, "] Request gateway list falied when connection state is ").concat(Je[l])),
  10511. void(n && n("OPERATION_ABORT"));
  10512. r.
  10513. default.debug("[" + e.clientId + "] Request gateway list will be restart in " + c + "s"),
  10514. i = setTimeout((function() {
  10515. t(d, p)
  10516. }), 1e3 * c),
  10517. qe[l] = i;
  10518. var s = Object(o.getParameter)("AP_BACKOFF_MAX_TIME");
  10519. c = c >= s ? s: 2 * c
  10520. }))
  10521. }
  10522. },
  10523. f = function n() { !
  10524. function(e, t) {
  10525. je(e, (function(n, a) {
  10526. if (n) return t && t(n);
  10527. r.
  10528. default.debug("[" + e.clientId + "] getProxyServerList: ", a),
  10529. Fe(e, a, t)
  10530. }))
  10531. } (e, (function(a, c) {
  10532. if (a) {
  10533. r.
  10534. default.debug("[" + e.clientId + "]", a),
  10535. r.
  10536. default.debug("[" + e.clientId + "] Request proxy will be restart in " + d + "s"),
  10537. i = setTimeout((function() {
  10538. n()
  10539. }), 1e3 * d),
  10540. qe[l] = i;
  10541. var u = Object(o.getParameter)("AP_BACKOFF_MAX_TIME");
  10542. d = d >= u ? u: 2 * d
  10543. } else {
  10544. clearTimeout(i);
  10545. var f = c.address;
  10546. e.proxyServer = f;
  10547. var g = {
  10548. mode: "manual",
  10549. url: c.address,
  10550. tcpport: c.serverResponse.tcpport || "3433",
  10551. udpport: c.serverResponse.udpport || "3478",
  10552. username: c.serverResponse.username || "test",
  10553. credential: c.serverResponse.password || Object(o.getParameter)("TURN_SERVER_PASSWORD"),
  10554. forceturn: !0
  10555. };
  10556. g.tcpport += "",
  10557. g.udpport += "",
  10558. e.turnServers = [],
  10559. e.turnServers.push(g),
  10560. s.b.setProxyServer(f),
  10561. r.
  10562. default.setProxyServer(f),
  10563. p(f, t)
  10564. }
  10565. }))
  10566. };
  10567. e.useProxyServer ? 1 == e.proxyServerType ? f() : 2 == e.proxyServerType ?
  10568. function n() { !
  10569. function(e, t) {
  10570. je(e, (function(n, a) {
  10571. return n ? t && t(n) : (r.
  10572. default.debug("[" + e.clientId + "] getProxyServerList: ", a), t && t(null, {
  10573. address: a[0],
  10574. serverResponse: {
  10575. tcpport: "443",
  10576. udpport: "3478",
  10577. username: "test",
  10578. password: "111111"
  10579. }
  10580. }))
  10581. }))
  10582. } (e, (function(a, c) {
  10583. if (a) return r.
  10584. default.debug("[" + e.clientId + "]", a),
  10585. r.
  10586. default.debug("[" + e.clientId + "] Request proxy will be restart in " + d + "s"),
  10587. i = setTimeout((function() {
  10588. n()
  10589. }), 1e3 * d),
  10590. qe[l] = i,
  10591. void(d = d >= 3600 ? 3600 : 2 * d);
  10592. clearTimeout(i);
  10593. var u = Object(o.getParameter)("PROXY_SERVER_TYPE2");
  10594. e.proxyServer = u;
  10595. var f = {
  10596. mode: "manual",
  10597. url: c.address,
  10598. tcpport: c.serverResponse.tcpport || "3433",
  10599. udpport: c.serverResponse.udpport || "3478",
  10600. username: c.serverResponse.username || "test",
  10601. credential: c.serverResponse.password || "111111",
  10602. forceturn: !0
  10603. };
  10604. f.tcpport += "",
  10605. f.udpport += "",
  10606. e.turnServers = [],
  10607. e.turnServers.push(f),
  10608. s.b.setProxyServer(u),
  10609. r.
  10610. default.setProxyServer(u),
  10611. p(u, t)
  10612. }))
  10613. } () : f() : p(null, t)
  10614. },
  10615. Xe = function(e, t, n, a) {
  10616. var i = Date.now();
  10617. a = a || t.stringUid;
  10618. var o = {
  10619. sid: t.sid,
  10620. opid: 10,
  10621. appid: t.appId,
  10622. string_uid: a
  10623. };
  10624. return new Promise((function(c, d) {
  10625. Object(Ue.post)(e + "".concat( - 1 === e.indexOf("?") ? "?": "&", "action=stringuid"), o, (function(u) {
  10626. try {
  10627. var l = JSON.parse(u),
  10628. p = l.code
  10629. } catch(c) {
  10630. var f = "requestUserAccount failed with unexpected body " + u;
  10631. return r.
  10632. default.error("[" + t.clientId + "]", f),
  10633. d({
  10634. retryable: !0,
  10635. info: f,
  10636. url: e
  10637. }),
  10638. n && n.dispatchEvent({
  10639. type: "error",
  10640. reason: "USER_ACCOUNT_BODY_NOT_JSON"
  10641. }),
  10642. void s.b.reqUserAccount(o.sid, {
  10643. lts: i,
  10644. success: !1,
  10645. serverAddress: e,
  10646. stringUid: a,
  10647. uid: null,
  10648. extend: u,
  10649. errorCode: "USER_ACCOUNT_BODY_NOT_JSON"
  10650. })
  10651. }
  10652. if (p) {
  10653. var g = I.StringUidErrorCode[l.code % 1e4] || "REQ_ACCOUNT_ERR_".concat(p);
  10654. return n && n.dispatchEvent({
  10655. type: "error",
  10656. reason: g
  10657. }),
  10658. s.b.reqUserAccount(o.sid, {
  10659. lts: i,
  10660. success: !1,
  10661. serverAddress: e,
  10662. stringUid: a,
  10663. uid: null,
  10664. errorCode: g,
  10665. extend: o
  10666. }),
  10667. d({
  10668. retryable: !1,
  10669. info: f = "Get String Uid Failed [" + g + "]",
  10670. url: e,
  10671. error: g
  10672. })
  10673. }
  10674. var m = l.uid;
  10675. if (! (m > 0 && m < Math.pow(2, 32))) {
  10676. r.
  10677. default.error("[" + t.clientId + "] " + "Invalid Uint Uid ".concat(a, " => ").concat(m), l);
  10678. g = "INVALID_UINT_UID_".concat(m);
  10679. return n && n.dispatchEvent({
  10680. type: "error",
  10681. reason: g
  10682. }),
  10683. s.b.reqUserAccount(o.sid, {
  10684. lts: i,
  10685. success: !1,
  10686. serverAddress: e,
  10687. stringUid: a,
  10688. uid: null,
  10689. errorCode: g,
  10690. extend: o
  10691. }),
  10692. d({
  10693. retryable: !0,
  10694. error: g,
  10695. info: "Get String Uid failed [" + g + "]",
  10696. url: e
  10697. })
  10698. }
  10699. c({
  10700. uid: m,
  10701. url: e
  10702. }),
  10703. s.b.reqUserAccount(o.sid, {
  10704. lts: i,
  10705. success: !0,
  10706. serverAddress: e,
  10707. stringUid: a,
  10708. uid: m,
  10709. errorCode: null,
  10710. extend: o
  10711. })
  10712. }), (function(e, t) {
  10713. if ("timeout" === e.type) {
  10714. var r = "USER_ACCOUNT_TIMEOUT";
  10715. n && n.dispatchEvent({
  10716. type: "error",
  10717. reason: r
  10718. }),
  10719. s.b.reqUserAccount(o.sid, {
  10720. lts: i,
  10721. success: !1,
  10722. serverAddress: t,
  10723. stringUid: a,
  10724. uid: null,
  10725. errorCode: r,
  10726. extend: o
  10727. }),
  10728. d({
  10729. retryable: !0,
  10730. info: r,
  10731. url: t
  10732. })
  10733. } else {
  10734. var c = "USER_ACCOUNT_SERVER_WRONG_".concat(e.type);
  10735. n && n.dispatchEvent({
  10736. type: "error",
  10737. reason: c
  10738. }),
  10739. s.b.reqUserAccount(o.sid, {
  10740. lts: i,
  10741. success: !1,
  10742. serverAddress: t,
  10743. stringUid: a,
  10744. uid: null,
  10745. errorCode: c,
  10746. extend: o
  10747. }),
  10748. d({
  10749. retryable: !0,
  10750. info: c,
  10751. url: t
  10752. })
  10753. }
  10754. }), {
  10755. "X-Packet-Service-Type": 0,
  10756. "X-Packet-URI": 72
  10757. })
  10758. }))
  10759. },
  10760. Qe = function(e, t, n) {
  10761. Date.now();
  10762. var a, s = Object(o.getParameter)("ACCOUNT_REGISTER"),
  10763. c = !1,
  10764. d = Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_TIMEOUT"),
  10765. u = null,
  10766. l = null,
  10767. p = new Promise(function() {
  10768. var p = ee()(Z.a.mark((function p(f, g) {
  10769. var m, v, S;
  10770. return Z.a.wrap((function(p) {
  10771. for (;;) switch (p.prev = p.next) {
  10772. case 0:
  10773. u = f,
  10774. l = g,
  10775. a = 0;
  10776. case 3:
  10777. if (! (a < Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_COUNT_MAX"))) {
  10778. p.next = 33;
  10779. break
  10780. }
  10781. if (!c) {
  10782. p.next = 6;
  10783. break
  10784. }
  10785. return p.abrupt("return");
  10786. case 6:
  10787. return m = s[a % s.length],
  10788. v = e.proxyServer ? "https://".concat(e.proxyServer, "/ap/?url=").concat(s[i] + "/api/v1") : "https://".concat(m, "/api/v1"),
  10789. p.prev = 8,
  10790. p.delegateYield(Z.a.mark((function a() {
  10791. var i;
  10792. return Z.a.wrap((function(a) {
  10793. for (;;) switch (a.prev = a.next) {
  10794. case 0:
  10795. return a.next = 2,
  10796. Xe(v, e, t, n);
  10797. case 2:
  10798. if (i = a.sent, !c) {
  10799. a.next = 5;
  10800. break
  10801. }
  10802. return a.abrupt("return", {
  10803. v: void 0
  10804. });
  10805. case 5:
  10806. c = !0,
  10807. setTimeout((function() {
  10808. r.
  10809. default.debug("Get UserAccount Successfully", i),
  10810. u(i)
  10811. }), 0);
  10812. case 7:
  10813. case "end":
  10814. return a.stop()
  10815. }
  10816. }), a)
  10817. }))(), "t0", 10);
  10818. case 10:
  10819. if (S = p.t0, "object" !== be()(S)) {
  10820. p.next = 13;
  10821. break
  10822. }
  10823. return p.abrupt("return", S.v);
  10824. case 13:
  10825. p.next = 30;
  10826. break;
  10827. case 15:
  10828. if (p.prev = 15, p.t1 = p.
  10829. catch(8), !c) {
  10830. p.next = 19;
  10831. break
  10832. }
  10833. return p.abrupt("return");
  10834. case 19:
  10835. if (!p.t1.retryable) {
  10836. p.next = 27;
  10837. break
  10838. }
  10839. return (d = Math.ceil(d * Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_RATIO"))) > Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_TIMEOUT_MAX") && (d = Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_TIMEOUT_MAX")),
  10840. r.
  10841. default.error("".concat(p.t1.info, " ").concat(p.t1.url, " Will Fetch User Account in ").concat(d / 1e3, " seconds")),
  10842. p.next = 25,
  10843. new Promise((function(e) {
  10844. setTimeout(e, d)
  10845. }));
  10846. case 25:
  10847. p.next = 30;
  10848. break;
  10849. case 27:
  10850. r.
  10851. default.error("Get UserAccount Error: ".concat(p.t1.info, " ").concat(p.t1.url), p.t1.error),
  10852. c = !0,
  10853. l(p.t1);
  10854. case 30:
  10855. a++,
  10856. p.next = 3;
  10857. break;
  10858. case 33:
  10859. case "end":
  10860. return p.stop()
  10861. }
  10862. }), p, null, [[8, 15]])
  10863. })));
  10864. return function(e, t) {
  10865. return p.apply(this, arguments)
  10866. }
  10867. } ());
  10868. return p.cancel = function() {
  10869. c || (c = !0, l({
  10870. info: "Request Cancelled",
  10871. retryable: !1
  10872. }))
  10873. },
  10874. p.isFinished = function() {
  10875. return c
  10876. },
  10877. p
  10878. },
  10879. Ze = {
  10880. ERR_NO_VOCS_AVAILABLE: "tryNext",
  10881. ERR_NO_VOS_AVAILABLE: "tryNext",
  10882. ERR_JOIN_CHANNEL_TIMEOUT: "tryNext",
  10883. WARN_REPEAT_JOIN: "quit",
  10884. ERR_JOIN_BY_MULTI_IP: "recover",
  10885. WARN_LOOKUP_CHANNEL_TIMEOUT: "tryNext",
  10886. WARN_OPEN_CHANNEL_TIMEOUT: "tryNext",
  10887. ERR_VOM_SERVICE_UNAVAILABLE: "tryNext",
  10888. ERR_TOO_MANY_USERS: "tryNext",
  10889. ERR_MASTER_VOCS_UNAVAILABLE: "tryNext",
  10890. ERR_INTERNAL_ERROR: "tryNext",
  10891. K_SERVICE_NOT_READY: "recover",
  10892. K_SERVICE_TOO_HEAVY: "tryNext",
  10893. notification_test_recover: "recover",
  10894. notification_test_tryNext: "tryNext",
  10895. notification_test_retry: "retry"
  10896. },
  10897. $e = {
  10898. googActualEncBitrate: "A_aeb",
  10899. googAvailableSendBandwidth: "A_asb",
  10900. googRetransmitBitrate: "A_rb",
  10901. googAvailableReceiveBandwidth: "A_arb",
  10902. googTargetEncBitrate: "A_teb",
  10903. googBucketDelay: "A_bd",
  10904. googTransmitBitrate: "A_tb",
  10905. googCodecName: "A_cn",
  10906. bytesSent: "bytesSent",
  10907. packetsLost: "packetsLost",
  10908. packetsSent: "packetsSent",
  10909. googAdaptationChanges: "A_ac",
  10910. googAvgEncodeMs: "A_aem",
  10911. googEncodeUsagePercent: "A_eup",
  10912. googFirsReceived: "A_fr",
  10913. googFrameHeightInput: "A_fhi",
  10914. googFrameHeightSent: "A_fhs",
  10915. googFrameRateInput: "A_fri",
  10916. googFrameRateSent: "A_frs",
  10917. googFrameWidthInput: "A_fwi",
  10918. googFrameWidthSent: "A_fws",
  10919. googNacksReceived: "A_nr",
  10920. googPlisReceived: "A_pr",
  10921. googRtt: "A_rtt",
  10922. aecDivergentFilterFraction: "A_adff",
  10923. audioInputLevel: "A_ail",
  10924. googEchoCancellationReturnLoss: "A_ecrl",
  10925. googEchoCancellationReturnLossEnhancement: "A_ecrle",
  10926. googResidualEchoLikelihood: "A_rel",
  10927. googResidualEchoLikelihoodRecentMax: "A_relrm",
  10928. googTargetDelayMs: "A_tdm",
  10929. bytesReceived: "bytesReceived",
  10930. packetsReceived: "packetsReceived",
  10931. googDecodeMs: "A_dm",
  10932. googMaxDecodeMs: "A_mdm",
  10933. googRenderDelayMs: "A_rdm",
  10934. googFrameWidthReceived: "A_fwr",
  10935. googFrameHeightReceived: "A_fhr",
  10936. googFrameRateReceived: "A_frr",
  10937. googFrameRateDecoded: "A_frd",
  10938. googFrameRateOutput: "A_fro",
  10939. googJitterBufferMs: "A_jbm",
  10940. googCurrentDelayMs: "A_cdm",
  10941. googMinPlayoutDelayMs: "A_mpdm",
  10942. googNacksSent: "A_ns",
  10943. googPlisSent: "A_ps",
  10944. googFirsSent: "A_fs",
  10945. audioOutputLevel: "A_aol",
  10946. googAccelerateRate: "A_ar",
  10947. googDecodingCNG: "A_dcng",
  10948. googDecodingCTN: "A_dctn",
  10949. googDecodingCTSG: "A_dctsg",
  10950. googDecodingNormal: "A_dn",
  10951. googDecodingPLC: "A_dplc",
  10952. googDecodingPLCCNG: "A_dplccng",
  10953. googExpandRate: "A_er",
  10954. googJitterReceived: "A_jr",
  10955. googPreemptiveExpandRate: "A_per",
  10956. googPreferredJitterBufferMs: "A_pjbm",
  10957. googSecondaryDecodedRate: "A_sdr",
  10958. googSpeechExpandRate: "A_ser",
  10959. uplink_fraction_lost: "B_ufl",
  10960. uplink_cumulative_lost: "B_ucl",
  10961. uplink_available_bandwidth: "B_uab",
  10962. period_fir: "B_fir",
  10963. access_delay: "B_acd",
  10964. uplink_network_quality: "B_unq",
  10965. downlink_network_quality: "B_dnq",
  10966. pub_audio_lost_ratio_400ms: "B_palr4",
  10967. pub_video_lost_ratio_400ms: "B_pvlr4",
  10968. e2e_delay: "B_ed",
  10969. audio_delay: "B_ad",
  10970. video_delay: "B_vd",
  10971. stream_type: "B_st",
  10972. e2e_audio_lost_ratio_400ms: "B_ealr4",
  10973. e2e_video_lost_ratio_400ms: "B_evlr4",
  10974. downlink_estimate_bandwidth: "B_deb",
  10975. peer_publish_audio_duration: "B_ppad",
  10976. peer_publish_video_duration: "B_ppvd"
  10977. },
  10978. et = {};
  10979. for (var tt in $e) {
  10980. var nt = $e[tt];
  10981. et[nt] && r.
  10982. default.error("Key Conflict: ".concat(nt, ": ").concat($e[nt], "| ").concat(tt)),
  10983. et[nt] = tt
  10984. }
  10985. var at = function(e) {
  10986. return $e[e] || e
  10987. },
  10988. it = function(e) {
  10989. return et[e] || e
  10990. };
  10991. var ot = function t(n) {
  10992. var a = !1,
  10993. i = function(e) {
  10994. return {
  10995. _type: "control",
  10996. _message: e
  10997. }
  10998. },
  10999. d = function(e, t) {
  11000. var n = {};
  11001. return Object.keys(t).forEach((function(e) {
  11002. Object(o.getParameter)("STATS_FILTER")[e] || (n[at(e)] = t[e])
  11003. })),
  11004. {
  11005. _type: "subscribe_related_stats",
  11006. _message: {
  11007. stream_type: "high",
  11008. stream_id: e,
  11009. stats: n
  11010. }
  11011. }
  11012. },
  11013. m = function(e) {
  11014. return {
  11015. _type: "publish",
  11016. _message: e
  11017. }
  11018. },
  11019. v = function(e, t) {
  11020. var n = {};
  11021. return Object.keys(t).forEach((function(e) {
  11022. Object(o.getParameter)("STATS_FILTER")[e] || (n[at(e)] = t[e])
  11023. })),
  11024. {
  11025. _type: "subscribe_stats",
  11026. _message: {
  11027. stream_id: e,
  11028. stats: n
  11029. }
  11030. }
  11031. },
  11032. S = t.DISCONNECTED,
  11033. _ = t.CONNECTING,
  11034. h = t.CONNECTED,
  11035. b = t.DISCONNECTING,
  11036. T = S,
  11037. R = c();
  11038. Object.defineProperty(R, "state", {
  11039. set: function(e) {
  11040. var n = T;
  11041. T = e,
  11042. function(e, t) {
  11043. Je[e] = t
  11044. } (R.clientId, e),
  11045. e !== t.CONNECTED && (R.hasJoined = !1),
  11046. n !== e && R.dispatchEvent({
  11047. type: "connection-state-change",
  11048. prevState: t.connetionStateMap[n],
  11049. curState: t.connetionStateMap[e]
  11050. })
  11051. },
  11052. get: function() {
  11053. return T
  11054. }
  11055. }),
  11056. R.socket = void 0,
  11057. R.state = S,
  11058. R.mode = n.mode,
  11059. R.role = n.role,
  11060. R.codec = n.codec,
  11061. R.config = {},
  11062. R.timers = {},
  11063. R.timer_counter = {},
  11064. R.localStreams = {},
  11065. R.remoteStreams = {},
  11066. R.remoteMuteState = {},
  11067. R.attemps = 1,
  11068. R.p2p_attemps = 1,
  11069. R.audioLevel = {},
  11070. R.activeSpeaker = void 0,
  11071. R.reconnectMode = "tryNext",
  11072. R.rejoinAttempt = 0,
  11073. R.hasChangeBGPAddress = !1,
  11074. R.traffic_stats = {},
  11075. R.clientId = n.clientId,
  11076. R.pingpongCounter = 0,
  11077. R.hasInvokeLeave = !1,
  11078. R.p2ps = new Map,
  11079. R.liveStreams = new Map,
  11080. R.injectLiveStreams = new Map,
  11081. R.remoteStreamsInChannel = new Set,
  11082. R.subscribeRequestId = new Map,
  11083. R.publishRequestId = 0,
  11084. R.hasJoined = !1,
  11085. R.isFirstSuccess = !0,
  11086. function(e) {
  11087. var t = Me;
  11088. e.makeRequest = function(n, a, i) {
  11089. if (void 0 === e.socket) return r.
  11090. default.debug("[".concat(e.clientId, "] No socket available")),
  11091. void t(i, I.
  11092. default.INVALID_OPERATION);
  11093. try {
  11094. e.socket.emitRequest(n, (function(e, t) {
  11095. var n;
  11096. "success" === e ? "function" == typeof a && a(t) : "function" == typeof i && (n = t && t.error_code && I.GatewayErrorCode[t.error_code] ? I.GatewayErrorCode[t.error_code] : t && t.error_str ? t.error_str: t && t.error_code ? "UNKNOW_ERROR_".concat(t.error_code) : e, i(n, t))
  11097. }))
  11098. } catch(a) {
  11099. r.
  11100. default.debug("[".concat(e.clientId, "] Socket emit message failed ").concat(JSON.stringify(n))),
  11101. r.
  11102. default.debug("[".concat(e.clientId, "] "), a),
  11103. t(i, I.
  11104. default.SOCKET_ERROR)
  11105. }
  11106. },
  11107. e.makeReport = function(t) {
  11108. void 0 === e.socket && r.
  11109. default.debug("[".concat(e.clientId, "] No socket available"));
  11110. try {
  11111. e.socket.emitReport(t)
  11112. } catch(n) {
  11113. r.
  11114. default.debug("[".concat(e.clientId, "] Socket emit report failed ").concat(JSON.stringify(t)))
  11115. }
  11116. }
  11117. } (R),
  11118. R.inChannelInfo = {
  11119. joinAt: null,
  11120. duration: 0
  11121. },
  11122. R._sendMessage = function(e, t) {
  11123. switch (e) {
  11124. case "SubscribeStats":
  11125. R.makeReport(v.apply(void 0, Pe()(t)));
  11126. break;
  11127. case "SubscribeRelatedStats":
  11128. R.makeReport(d.apply(void 0, Pe()(t)))
  11129. }
  11130. };
  11131. var A = Me;
  11132. R.p2pCounter = Object(H.random)(1e5),
  11133. R.generateP2PId = function() {
  11134. return++R.p2pCounter
  11135. },
  11136. R.audioVolumeIndication = {
  11137. enabled: !1,
  11138. sortedAudioVolumes: [],
  11139. smooth: 3,
  11140. interval: 2e3
  11141. },
  11142. R.remoteVideoStreamTypes = {
  11143. REMOTE_VIDEO_STREAM_HIGH: 0,
  11144. REMOTE_VIDEO_STREAM_LOW: 1,
  11145. REMOTE_VIDEO_STREAM_MEDIUM: 2
  11146. },
  11147. R.streamFallbackTypes = {
  11148. STREAM_FALLBACK_OPTION_DISABLED: 0,
  11149. STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW: 1,
  11150. STREAM_FALLBACK_OPTION_AUDIO_ONLY: 2
  11151. },
  11152. R.configPublisher = function(e) {
  11153. R.config = e
  11154. },
  11155. R.getGatewayInfo = function(e, t) {
  11156. R.makeRequest({
  11157. _type: "gateway_info"
  11158. },
  11159. e, t)
  11160. },
  11161. R.setClientRole = function(e, t) {
  11162. r.
  11163. default.debug("[".concat(R.clientId, "] setClientRole to ").concat(e));
  11164. var n = s.b.reportApiInvoke(R.joinInfo.sid, {
  11165. name: "_setClientRole",
  11166. callback: t
  11167. });
  11168. R.makeRequest({
  11169. _type: "set_client_role",
  11170. _message: {
  11171. role: e
  11172. }
  11173. },
  11174. (function() {
  11175. R.role = e,
  11176. R.dispatchEvent({
  11177. type: "client-role-changed",
  11178. role: e
  11179. }),
  11180. n && n(null, {
  11181. role: e
  11182. })
  11183. }), (function(t, a) {
  11184. if (a && a.code && (t = I.GatewayErrorCode[a.code] || "UNKNOW_ERROR_" + a.code), "ERR_SET_CLIENT_ROLE_ALREADY_IN_USE" === t) return n && n(null);
  11185. r.
  11186. default.error("set Client role error to " + e + ": " + t),
  11187. n && n(t)
  11188. }))
  11189. },
  11190. R.join = function(e, t, a, i) {
  11191. R.hasInvokeLeave = !1,
  11192. e.useProxyServer && (R.hasChangeBGPAddress = !0);
  11193. var c = (new Date).getTime(),
  11194. d = e.uid;
  11195. if (R.inChannelInfo.joinAt && (R.inChannelInfo.duration += c - R.inChannelInfo.joinAt), R.inChannelInfo.joinAt = c, R.state !== _) return r.
  11196. default.error("[".concat(R.clientId, "] GatewayClient.join Failed: state "), R.state),
  11197. i && i(I.
  11198. default.INVALID_OPERATION),
  11199. void s.b.joinGateway(e.sid, {
  11200. lts: c,
  11201. succ: !1,
  11202. ec: I.
  11203. default.INVALID_OPERATION,
  11204. addr: null
  11205. });
  11206. if (null != d && parseInt(d) !== d) return r.
  11207. default.error("[".concat(R.clientId, "] Input uid is invalid")),
  11208. R.state = S,
  11209. i && i(I.
  11210. default.INVALID_PARAMETER),
  11211. void s.b.joinGateway(e.sid, {
  11212. lts: c,
  11213. succ: !1,
  11214. ec: I.
  11215. default.INVALID_PARAMETER,
  11216. addr: null
  11217. });
  11218. var u = rt.register(R, {
  11219. uid: d,
  11220. cname: e && e.cname
  11221. });
  11222. if (u) return R.state = S,
  11223. i && i(u),
  11224. void s.b.joinGateway(e.sid, {
  11225. lts: c,
  11226. succ: !1,
  11227. ec: u,
  11228. addr: null
  11229. });
  11230. R.joinInfo = E()({},
  11231. e),
  11232. R.uid = d,
  11233. R.key = t,
  11234. R.pingpongCounter = 0,
  11235. N(e, (function(t) {
  11236. if (R.state === b || R.state === S) return i && i("LEAVE_BEFORE_JOIN_SUCCESS");
  11237. R.state = h,
  11238. r.
  11239. default.debug("[".concat(R.clientId, "] Connected to gateway server")),
  11240. clearInterval(R.pingTimer),
  11241. R.pingTimer = setInterval((function() {
  11242. var e = Object(o.getParameter)("PING_PONG_TIME_OUT");
  11243. if (++R.pingpongCounter >= e) {
  11244. var t = Date.now();
  11245. R.socket && r.
  11246. default.warning("PINGPONG Timeout. Last Socket Message: ".concat(t - R.socket.getLastMsgTime(), "ms")),
  11247. R.socket && R.socket.getLastMsgTime() && t - R.socket.getLastMsgTime() > Object(o.getParameter)("WEBSOCKET_TIMEOUT_MIN") && (R.pingpongCounter = 0, R.socket.close(), R.socket.dispatchEvent(p({
  11248. type: "disconnect",
  11249. event: {
  11250. msg: "PING_PONG_TIME_OUT"
  11251. }
  11252. })))
  11253. }
  11254. var n = Date.now();
  11255. R.makeRequest({
  11256. _type: "ping"
  11257. },
  11258. (function() {
  11259. R.pingpongCounter = 0;
  11260. var e = Date.now() - n;
  11261. setTimeout((function() {
  11262. Object(o.getParameter)("REPORT_STATS") && R.makeRequest({
  11263. _type: "ping_back",
  11264. _message: {
  11265. pingpongElapse: e
  11266. }
  11267. })
  11268. }), 1e3)
  11269. }), (function(e, t) {
  11270. "TIMEOUT" !== e && (r.
  11271. default.error("Ping Error ".concat(e, " ").concat(JSON.stringify(t))), t && t.error_code && R.socket && R.socket.signal && R.socket.signal.connection && R.socket.signal.connection.readyState === WebSocket.OPEN && (r.
  11272. default.info("Disconnecting websocket connection"), R.socket.signal.connection.close()))
  11273. }))
  11274. }), 3e3),
  11275. R.makeRequest(function(e) {
  11276. var t = e.role,
  11277. a = E()({},
  11278. R.joinInfo.apResponse),
  11279. i = {
  11280. session_id: R.joinInfo.sid,
  11281. app_id: n.appId,
  11282. channel_key: R.key,
  11283. channel_name: R.joinInfo.cname,
  11284. sdk_version: o.VERSION,
  11285. browser: navigator.userAgent,
  11286. process_id: Object(s.a)(),
  11287. mode: R.mode,
  11288. codec: R.codec,
  11289. role: t,
  11290. has_changed_gateway: Object(o.getParameter)("FORCE_CHANGED_GATEWAY_FLAG") || R.hasChangeBGPAddress,
  11291. ap_response: a,
  11292. extend: Object(o.getParameter)("JOIN_EXTEND"),
  11293. details: {}
  11294. };
  11295. if (R.joinInfo.hasOwnProperty("stringUid") && (i.string_uid = R.joinInfo.stringUid), R.joinInfo.aesmode && R.joinInfo.aespassword && (i.aes_mode = R.joinInfo.aesmode, i.aes_secret = R.joinInfo.aespassword), R.socket && R.socket.signal && R.socket.signal && (a.addresses[R.socket.signal.hostIndex] && (i.ap_response.ticket = a.addresses[R.socket.signal.hostIndex].ticket, delete a.addresses), Object(o.getParameter)("SET_DEFAULT_TURNSERVER") && R.socket.signal.turnConfig)) {
  11296. var r = {
  11297. username: "test",
  11298. credential: Object(o.getParameter)("TURN_SERVER_PASSWORD"),
  11299. forceturn: Object(o.getParameter)("FORCE_TURN")
  11300. };
  11301. r.url = R.socket.signal.turnConfig.url,
  11302. R.socket.signal.turnConfig.tcpport && (r.tcpport = "" + R.socket.signal.turnConfig.tcpport),
  11303. R.socket.signal.turnConfig.udpport && (r.udpport = "" + R.socket.signal.turnConfig.udpport),
  11304. R.joinInfo.turnServers.push(r)
  11305. }
  11306. return R.dispatchEvent({
  11307. type: "join-message-hook",
  11308. joinMessage: i
  11309. }),
  11310. {
  11311. _type: "join",
  11312. _message: i
  11313. }
  11314. } ({
  11315. role: R.role
  11316. }), (function(t) {
  11317. if (s.b.joinGateway(e.sid, {
  11318. lts: c,
  11319. succ: !0,
  11320. ec: null,
  11321. vid: e.vid,
  11322. addr: R.socket.getURL(),
  11323. firstSuccess: R.isFirstSuccess
  11324. }), R.joinSuccessLts = Date.now(), R.isFirstSuccess = !1, R.rejoinAttempt = 0, R.hasJoined = !0, a && a(t.uid), !0 === t.return_vosip || !0 === Object(o.getParameter)("ENABLE_LIVE_SERVER_LIST")) {
  11325. var n = null;
  11326. try {
  11327. n = R.socket.signal.connection.url
  11328. } catch(e) {
  11329. r.
  11330. default.debug("[".concat(R.clientId, "] Can not get gateway ip: ").concat(e))
  11331. }
  11332. n ? Object(o.setParameter)("LIVE_SERVER_LIST", [n]) : Object(o.setParameter)("LIVE_SERVER_LIST", [])
  11333. }
  11334. R.dispatchEvent({
  11335. type: "join"
  11336. }),
  11337. clearInterval(R.timers.trafficStats),
  11338. R.timers.trafficStats = setInterval((function() {
  11339. R.makeRequest({
  11340. _type: "traffic_stats"
  11341. },
  11342. (function(e) {
  11343. var t = {};
  11344. for (var n in e) t[it(n)] = e[n];
  11345. if (t.peer_delay && t.peer_delay.length) {
  11346. var a = [];
  11347. t.peer_delay.forEach((function(e) {
  11348. var t = {};
  11349. for (var n in e) t[it(n)] = e[n];
  11350. a.push(t)
  11351. })),
  11352. t.peer_delay = a
  11353. }
  11354. R.traffic_stats = t,
  11355. R.traffic_stats.timestamp = Date.now();
  11356. var i = R.joinInfo.stringUid,
  11357. o = R.localStreams[d] || R.localStreams[i];
  11358. o && (o.traffic_stats = {
  11359. access_delay: t.access_delay
  11360. }),
  11361. t.peer_delay && t.peer_delay.forEach((function(e) {
  11362. var n = R.remoteStreams[e.peer_uid];
  11363. n && (n.traffic_stats = {
  11364. access_delay: t.access_delay,
  11365. e2e_delay: e.e2e_delay,
  11366. audio_delay: e.audio_delay,
  11367. video_delay: e.video_delay
  11368. })
  11369. })),
  11370. R.dispatchEvent({
  11371. type: "after-getTrafficStats",
  11372. trafficStats: t
  11373. })
  11374. }))
  11375. }), 3e3)
  11376. }), (function(t, n) {
  11377. if (r.
  11378. default.error("[".concat(R.clientId, "] User join failed [").concat(t, "]")), "ERR_JOIN_BY_MULTI_IP" === t) {
  11379. try {
  11380. s.b.joinGateway(e.sid, {
  11381. lts: c,
  11382. succ: !1,
  11383. ec: "ERR_JOIN_BY_MULTI_IP",
  11384. addr: R.socket.getURL()
  11385. })
  11386. } catch(e) {}
  11387. return R.dispatchEvent({
  11388. type: "onMultiIP",
  11389. option: n.option
  11390. })
  11391. }
  11392. Ze[t] && R.rejoinAttempt < 4 ? R._doWithAction(Ze[t], a, i) : i && i(t),
  11393. s.b.joinGateway(e.sid, {
  11394. lts: c,
  11395. succ: !1,
  11396. ec: t,
  11397. addr: R.socket && R.socket.getURL()
  11398. })
  11399. }))
  11400. }), (function(t) {
  11401. r.
  11402. default.error("[".concat(R.clientId, "] User join failed [").concat(t, "]")),
  11403. i && i(t),
  11404. s.b.joinGateway(e.sid, {
  11405. lts: c,
  11406. succ: !1,
  11407. ec: t,
  11408. addr: R.socket.getURL()
  11409. })
  11410. })),
  11411. this.remoteMuteState = {},
  11412. R.resetAudioVolumeIndication()
  11413. },
  11414. R.leave = function(e, t) {
  11415. var n = rt.unregister(R);
  11416. switch (n && r.
  11417. default.debug("[".concat(R.clientId, "] "), n), R.state) {
  11418. case S:
  11419. return r.
  11420. default.debug("[".concat(R.clientId, "] Client Already in DISCONNECTED status")),
  11421. void A(e);
  11422. case b:
  11423. return r.
  11424. default.debug("[".concat(R.clientId, "] Client Already in DISCONNECTING status")),
  11425. void A(t, I.
  11426. default.INVALID_OPERATION);
  11427. case _:
  11428. return R.socket && R.socket.close(),
  11429. R.socket = void 0,
  11430. r.
  11431. default.info("[".concat(R.clientId, "] Client connecting, Leave channel success")),
  11432. R.state = S,
  11433. e && e()
  11434. }
  11435. for (var a in R.state = b,
  11436. R.channelMediaConfig && (R.channelMediaRelayController && R.channelMediaRelayController.dispose(), R.channelMediaConfig, R.channelMediaRelayController = null), clearInterval(R.pingTimer), R.timers) R.timers.hasOwnProperty(a) && clearInterval(R.timers[a]);
  11437. for (var a in R.inChannelInfo.joinAt && (R.inChannelInfo.duration += Date.now() - R.inChannelInfo.joinAt, R.inChannelInfo.joinAt = null), R.hasJoined ? R.makeRequest({
  11438. _type: "leave"
  11439. },
  11440. (function(t) {
  11441. R.socket.close(),
  11442. R.socket = void 0,
  11443. r.
  11444. default.info("[".concat(R.clientId, "] Leave channel success")),
  11445. R.state = S,
  11446. e && e(t)
  11447. }), (function(e) {
  11448. "TIMEOUT" !== e && (r.
  11449. default.error("[".concat(R.clientId, "] Leave Channel Failed"), e), R.state = h, t && t(e))
  11450. })) : (R.socket && (R.socket.close(), R.socket = void 0), r.
  11451. default.info("[".concat(R.clientId, "] Leave channel before joined")), R.state = S, e && e()), R.localStreams) if (R.localStreams.hasOwnProperty(a)) {
  11452. var i = R.localStreams[a];
  11453. delete R.localStreams[a],
  11454. void 0 !== i.pc && (i.pc.close(), i.pc = void 0)
  11455. }
  11456. k()
  11457. },
  11458. R.publish = function(e, t, n, a) {
  11459. var c = (new Date).getTime(),
  11460. d = !1;
  11461. if (e.publishLTS = c, "object" !== be()(e) || null === e) return r.
  11462. default.error("[".concat(R.clientId, "] Invalid local stream")),
  11463. a && a(I.
  11464. default.INVALID_LOCAL_STREAM),
  11465. void s.b.publish(R.joinInfo.sid, {
  11466. lts: c,
  11467. succ: !1,
  11468. audio: !1,
  11469. video: !1,
  11470. screenshare: !1,
  11471. audioName: "",
  11472. videoName: "",
  11473. screenName: "",
  11474. ec: I.
  11475. default.INVALID_LOCAL_STREAM
  11476. });
  11477. if (!e.stream && void 0 === e.url) return r.
  11478. default.error("[".concat(R.clientId, "] Invalid local media stream")),
  11479. a && a(I.
  11480. default.INVALID_LOCAL_STREAM),
  11481. void s.b.publish(R.joinInfo.sid, {
  11482. lts: c,
  11483. succ: !1,
  11484. audio: !1,
  11485. video: !1,
  11486. screenshare: !1,
  11487. audioName: "",
  11488. videoName: "",
  11489. screenName: "",
  11490. ec: I.
  11491. default.INVALID_LOCAL_STREAM
  11492. });
  11493. if (R.state !== h) return r.
  11494. default.error("[".concat(R.clientId, "] User is not in the session")),
  11495. a && a(I.
  11496. default.INVALID_OPERATION),
  11497. void s.b.publish(R.joinInfo.sid, {
  11498. lts: c,
  11499. succ: !1,
  11500. audio: e.hasAudio(),
  11501. video: e.hasVideo(),
  11502. screenshare: e.hasScreen(),
  11503. audioName: e.hasAudio() && e.audioName,
  11504. videoName: e.hasVideo() && e.videoName,
  11505. screenName: e.hasScreen() && e.screenName,
  11506. ec: I.
  11507. default.INVALID_OPERATION
  11508. });
  11509. var u = e.getAttributes() || {};
  11510. if (e.local && void 0 === R.localStreams[e.getId()] && (e.hasAudio() || e.hasVideo() || e.hasScreen())) {
  11511. var p = R.generateP2PId();
  11512. if (R.p2ps.set(p, e), e.p2pId = p, void 0 !== e.url) w(m({
  11513. state: "url",
  11514. audio: e.hasAudio(),
  11515. video: e.hasVideo(),
  11516. attributes: e.getAttributes()
  11517. },
  11518. e.url), (function(t, n) {
  11519. "success" === t ? (e.getUserId() !== n && e.setUserId(n), R.localStreams[n] = e, e.onClose = function() {
  11520. R.unpublish(e)
  11521. }) : r.
  11522. default.error("[".concat(R.clientId, "] Publish local stream failed"), t)
  11523. }));
  11524. else {
  11525. R.localStreams[e.getId()] = e,
  11526. e.connectionSpec = {
  11527. callback: function(u) {
  11528. R.makeRequest(m({
  11529. state: "offer",
  11530. stream_type: 1 == t.streamType ? "low": "high",
  11531. p2p_id: p,
  11532. sdp: u,
  11533. audio: e.audio || e.screenAudio,
  11534. video: e.screen || e.video,
  11535. screen: e.screen,
  11536. attributes: e.getAttributes(),
  11537. dtx: e.DTX,
  11538. hq: e.highQuality,
  11539. lq: e.lowQuality,
  11540. stereo: e.stereo,
  11541. speech: e.speech,
  11542. codec: R.codec,
  11543. extend: Object(o.getParameter)("PUB_EXTEND")
  11544. }), (function(t) {
  11545. e.getUserId() !== t.uid && e.setUserId(t.uid),
  11546. r.
  11547. default.info("[".concat(R.clientId, "] Local stream published with uid"), t.uid),
  11548. e.onClose = function() {
  11549. R.unpublish(e)
  11550. },
  11551. e._onAudioUnmute = function() {
  11552. R.makeReport(i({
  11553. action: "unmute_local_audio",
  11554. stream_id: e.getId()
  11555. }))
  11556. },
  11557. e._onVideoUnmute = function() {
  11558. R.makeReport(i({
  11559. action: "unmute_local_video",
  11560. stream_id: e.getId()
  11561. }))
  11562. },
  11563. e._onAudioMute = function() {
  11564. R.makeReport(i({
  11565. action: "mute_local_audio",
  11566. stream_id: e.getId()
  11567. }))
  11568. },
  11569. e._onVideoMute = function() {
  11570. R.makeReport(i({
  11571. action: "mute_local_video",
  11572. stream_id: e.getId()
  11573. }))
  11574. },
  11575. e.getId() === e.getUserId() && (e.isAudioOn() || e.hasAudio() && (r.
  11576. default.debug("[".concat(R.clientId, "] local stream audio mute")), e._onAudioMute()), e.isVideoOn() || (e.hasVideo() || e.hasScreen()) && (r.
  11577. default.debug("[".concat(R.clientId, "] local stream video mute")), e._onVideoMute())),
  11578. e.pc.oniceconnectionstatechange = function(t) {
  11579. if ("failed" === t) {
  11580. if (null != R.timers[e.getId()] && (clearInterval(R.timers[e.getId()]), clearInterval(R.timers[e.getId()] + "_RelatedStats")), r.
  11581. default.error("[".concat(R.clientId, "] Publisher connection is lost -- streamId: ").concat(e.getId(), ", p2pId: ").concat(p)), R.p2ps.delete(p), r.
  11582. default.debug("[".concat(R.clientId, "] publish p2p failed: "), R.p2ps), !d) return d = !0,
  11583. s.b.publish(R.joinInfo.sid, {
  11584. lts: c,
  11585. succ: !1,
  11586. audio: e.hasAudio(),
  11587. video: e.hasVideo(),
  11588. screenshare: e.hasScreen(),
  11589. audioName: e.hasAudio() && e.audioName,
  11590. videoName: e.hasVideo() && e.videoName,
  11591. screenName: e.hasScreen() && e.screenName,
  11592. ec: I.
  11593. default.PEERCONNECTION_FAILED,
  11594. publishRequestid: R.publishRequestId || 0,
  11595. p2pid: p
  11596. }),
  11597. R.dispatchEvent(l({
  11598. type: "pubP2PLost",
  11599. stream: e
  11600. })),
  11601. a && a(I.
  11602. default.PEERCONNECTION_FAILED);
  11603. R.dispatchEvent(l({
  11604. type:
  11605. "pubP2PLost",
  11606. stream: e
  11607. }))
  11608. } else if ("connected" === t && (r.
  11609. default.debug("[".concat(R.clientId, "] publish p2p connected: "), R.p2ps), e.getId() === e.getUserId() && (e._isAudioMuted() ? R.makeReport(i({
  11610. action: "mute_local_audio",
  11611. stream_id: e.getId()
  11612. })) : R.makeReport(i({
  11613. action: "unmute_local_audio",
  11614. stream_id: e.getId()
  11615. })), e._isVideoMuted() ? R.makeReport(i({
  11616. action: "mute_local_video",
  11617. stream_id: e.getId()
  11618. })) : R.makeReport(i({
  11619. action: "unmute_local_video",
  11620. stream_id: e.getId()
  11621. }))), !d)) return d = !0,
  11622. s.b.publish(R.joinInfo.sid, {
  11623. lts: c,
  11624. succ: !0,
  11625. audio: e.hasAudio(),
  11626. video: e.hasVideo(),
  11627. screenshare: e.hasScreen(),
  11628. audioName: e.hasAudio() && e.audioName,
  11629. videoName: e.hasVideo() && e.videoName,
  11630. screenName: e.hasScreen() && e.screenName,
  11631. ec: null,
  11632. publishRequestid: R.publishRequestId || 0,
  11633. p2pid: p
  11634. }),
  11635. n && n()
  11636. },
  11637. e.pc.processSignalingMessage(t.sdp)
  11638. }), (function(t, n) {
  11639. r.
  11640. default.error("Publish Failed: ".concat(t)),
  11641. s.b.publish(R.joinInfo.sid, {
  11642. lts: c,
  11643. succ: !1,
  11644. audio: e.hasAudio(),
  11645. video: e.hasVideo(),
  11646. screenshare: e.hasScreen(),
  11647. audioName: e.hasAudio() && e.audioName,
  11648. videoName: e.hasVideo() && e.videoName,
  11649. screenName: e.hasScreen() && e.screenName,
  11650. ec: t,
  11651. publishRequestid: R.publishRequestId || 0,
  11652. p2pid: p
  11653. }),
  11654. "TIMEOUT" != t && (R.processPublishFailure(e), a && a(t))
  11655. }))
  11656. },
  11657. audio: e.hasAudio(),
  11658. video: e.hasVideo(),
  11659. screen: e.hasScreen(),
  11660. isSubscriber: !1,
  11661. stunServerUrl: R.stunServerUrl,
  11662. turnServers: R.joinInfo.turnServers,
  11663. maxAudioBW: u.maxAudioBW,
  11664. minVideoBW: u.minVideoBW,
  11665. maxVideoBW: u.maxVideoBW,
  11666. mode: R.mode,
  11667. codec: R.codec,
  11668. isVideoMute: e.userMuteVideo || e.peerMuteVideo,
  11669. isAudioMute: e.userMuteAudio || e.peerMuteAudio,
  11670. maxFrameRate: e.attributes.maxFrameRate,
  11671. clientId: R.clientId
  11672. },
  11673. e.pc = W(e.connectionSpec),
  11674. e.pc.addStream(e.stream),
  11675. r.
  11676. default.debug("[".concat(R.clientId, "] PeerConnection add stream :"), e.stream),
  11677. e.pc.onnegotiationneeded = function(n) {
  11678. var a = {
  11679. state: "negotiation",
  11680. stream_type: 1 === t.streamType ? "low": "high",
  11681. p2p_id: p,
  11682. sdp: n
  11683. };
  11684. R.makeRequest(m(a), (function(t) {
  11685. r.
  11686. default.debug("Negotating Stream ".concat(e.getId())),
  11687. e.pc.processSignalingMessage(t.sdp)
  11688. }), (function(e, t) {
  11689. r.
  11690. default.error("Negotiation failed ".concat(e), t, a)
  11691. }))
  11692. },
  11693. clearInterval(R.timers[e.getId()]),
  11694. R.timers[e.getId()] = setInterval((function() {
  11695. if (Object(o.getParameter)("REPORT_STATS")) {
  11696. var t = 0;
  11697. e && e.pc && e.pc.getStats && e.pc.getStatsRate((function(n) {
  11698. n.forEach((function(n) {
  11699. if (n && n.id && !/_recv$/.test(n.id) && !/^time$/.test(n.id) && e.getUserId()) {
  11700. if ( - 1 === n.id.indexOf("outbound_rtp") && -1 === n.id.indexOf("OutboundRTP") && -1 === n.type.toLowerCase().indexOf("outbound") || "video" !== n.mediaType || (n.googFrameWidthSent = e.videoWidth + "", n.googFrameHeightSent = e.videoHeight + ""), "video" === n.mediaType) try {
  11701. var a = e.stream.getVideoTracks()[0];
  11702. n.A_vstd = a.enabled ? "0": "1"
  11703. } catch(e) {}
  11704. if ("audio" === n.mediaType) try {
  11705. var i = e.stream.getAudioTracks()[0];
  11706. n.A_astd = i.enabled ? "0": "1"
  11707. } catch(e) {}
  11708. if (e.getId() == e.getUserId()) {
  11709. var s = 200 * t;
  11710. t++,
  11711. setTimeout((function() {
  11712. var e = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11713. e > Object(o.getParameter)("REPORT_STATS_TIMEOUT") ? r.
  11714. default.debug("PublishStats report blocked by REPORT_STATS_TIMEOUT ".concat(e)):
  11715. R.makeReport(function(e) {
  11716. var t = {};
  11717. return Object.keys(e).forEach((function(n) {
  11718. Object(o.getParameter)("STATS_FILTER")[n] || (t[at(n)] = e[n])
  11719. })),
  11720. {
  11721. _type: "publish_stats",
  11722. _message: {
  11723. stream_type: "high",
  11724. stats: t
  11725. }
  11726. }
  11727. } (n))
  11728. }), s)
  11729. } else {
  11730. s = 200 * t;
  11731. t++,
  11732. setTimeout((function() {
  11733. var e = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11734. e > Object(o.getParameter)("REPORT_STATS_TIMEOUT") ? r.
  11735. default.debug("PublishStatsLow report blocked by REPORT_STATS_TIMEOUT ".concat(e)):
  11736. R.makeReport(function(e) {
  11737. var t = {};
  11738. return Object.keys(e).forEach((function(n) {
  11739. Object(o.getParameter)("STATS_FILTER")[n] || (t[at(n)] = e[n])
  11740. })),
  11741. {
  11742. _type: "publish_stats",
  11743. _message: {
  11744. stream_type: "low",
  11745. stats: t
  11746. }
  11747. }
  11748. } (n))
  11749. }), s)
  11750. }
  11751. }
  11752. }))
  11753. }))
  11754. }
  11755. }), 3e3);
  11756. var f = function() {
  11757. Object(o.getParameter)("REPORT_STATS") && e && e.pc && e.pc.getVideoRelatedStats && e.pc.getVideoRelatedStats((function(t) {
  11758. var n, a, i = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11759. i > Object(o.getParameter)("REPORT_STATS_TIMEOUT") ? r.
  11760. default.debug("PublishRelatedStats report blocked by REPORT_STATS_TIMEOUT ".concat(i)):
  11761. e.getId() === e.getUserId() ? R.makeReport((n = t, a = {},
  11762. Object.keys(n).forEach((function(e) {
  11763. Object(o.getParameter)("STATS_FILTER")[e] || (a[at(e)] = n[e])
  11764. })), {
  11765. _type: "publish_related_stats",
  11766. _message: {
  11767. stream_type: "high",
  11768. stats: a
  11769. }
  11770. })) : R.makeReport(function(e) {
  11771. var t = {};
  11772. return Object.keys(e).forEach((function(n) {
  11773. Object(o.getParameter)("STATS_FILTER")[n] || (t[at(n)] = e[n])
  11774. })),
  11775. {
  11776. _type: "publish_related_stats",
  11777. _message: {
  11778. stream_type: "low",
  11779. stats: t
  11780. }
  11781. }
  11782. } (t))
  11783. }))
  11784. };
  11785. f(),
  11786. clearInterval(R.timers[e.getId() + "_RelatedStats"]),
  11787. R.timers[e.getId() + "_RelatedStats"] = setInterval(f, 1e3)
  11788. }
  11789. }
  11790. },
  11791. R.unpublish = function(e, t, n, a) {
  11792. if ("object" !== be()(e) || null === e) return r.
  11793. default.error("[".concat(R.clientId, "] Invalid local stream")),
  11794. void A(a, I.
  11795. default.INVALID_LOCAL_STREAM);
  11796. if (R.state !== h) return r.
  11797. default.error("[".concat(R.clientId, "] User not in the session")),
  11798. void A(a, I.
  11799. default.INVALID_OPERATION);
  11800. if (null != R.timers[e.getId()] && (clearInterval(R.timers[e.getId()]), clearInterval(R.timers[e.getId() + "_RelatedStats"])), void 0 !== R.socket) if (e.local && void 0 !== R.localStreams[e.getId()]) {
  11801. delete R.localStreams[e.getId()];
  11802. var i = {
  11803. stream_id: e.getUserId(),
  11804. stream_type: 1 === t.streamType ? "low": "high"
  11805. };
  11806. R.makeRequest({
  11807. _type: "unpublish",
  11808. _message: i
  11809. }),
  11810. (e.hasAudio() || e.hasVideo() || e.hasScreen()) && void 0 === e.url && void 0 !== e.pc && (e.pc.close(), e.pc = void 0),
  11811. e.onClose = void 0,
  11812. e._onAudioMute = void 0,
  11813. e._onAudioUnute = void 0,
  11814. e._onVideoMute = void 0,
  11815. e._onVideoUnmute = void 0,
  11816. R.p2ps.delete(e.p2pId),
  11817. R.dispatchEvent({
  11818. type: "stream-unpublished",
  11819. stream: e,
  11820. options: t
  11821. }),
  11822. n && n()
  11823. } else r.
  11824. default.error("[".concat(R.clientId, "] Invalid local stream")),
  11825. A(a, I.
  11826. default.INVALID_LOCAL_STREAM);
  11827. else r.
  11828. default.error("[".concat(R.clientId, "] User not in the session")),
  11829. A(a, I.
  11830. default.INVALID_OPERATION)
  11831. },
  11832. R.subscribe = function(e, t, n) {
  11833. var a = (new Date).getTime();
  11834. e.subscribeLTS = a;
  11835. var c = !1;
  11836. if (r.
  11837. default.info("[".concat(R.clientId, "] Gatewayclient ").concat(R.uid, " Subscribe ").concat(e.getId(), ": ").concat(JSON.stringify(e.subscribeOptions))), "object" !== be()(e) || null === e) return r.
  11838. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  11839. n && n(I.
  11840. default.INVALID_REMOTE_STREAM),
  11841. void s.b.subscribe(R.joinInfo.sid, {
  11842. lts: a,
  11843. succ: !1,
  11844. video: e.subscribeOptions && e.subscribeOptions.video,
  11845. audio: e.subscribeOptions && e.subscribeOptions.audio,
  11846. peerid: e.getId(),
  11847. ec: I.
  11848. default.INVALID_REMOTE_STREAM
  11849. });
  11850. if (R.state !== h && (r.
  11851. default.error("[".concat(R.clientId, "] User is not in the session")), !c)) return c = !0,
  11852. s.b.subscribe(R.joinInfo.sid, {
  11853. lts: a,
  11854. succ: !1,
  11855. video: e.subscribeOptions && e.subscribeOptions.video,
  11856. audio: e.subscribeOptions && e.subscribeOptions.audio,
  11857. peerid: e.getId(),
  11858. ec: I.
  11859. default.INVALID_OPERATION
  11860. }),
  11861. n && n(I.
  11862. default.INVALID_OPERATION);
  11863. if (!e.local && R.remoteStreams.hasOwnProperty(e.getId())) if (e.hasAudio() || e.hasVideo() || e.hasScreen()) {
  11864. var p = R.generateP2PId();
  11865. R.p2ps.set(p, e),
  11866. e.p2pId = p,
  11867. e.pc = W({
  11868. callback: function(t) {
  11869. var i = {
  11870. stream_id: e.getId(),
  11871. audio: !e.subscribeOptions || e.subscribeOptions.audio,
  11872. video: !e.subscribeOptions || e.subscribeOptions.video,
  11873. codec: R.codec,
  11874. p2p_id: p,
  11875. sdp: t,
  11876. tcc: Object(o.getParameter)("SUBSCRIBE_TCC"),
  11877. extend: Object(o.getParameter)("SUB_EXTEND")
  11878. };
  11879. R.makeRequest({
  11880. _type: "subscribe",
  11881. _message: i
  11882. },
  11883. (function(t) {
  11884. e.pc.processSignalingMessage(t.sdp)
  11885. }), (function(t, i) {
  11886. r.
  11887. default.error("[".concat(R.clientId, "] Subscribe remote stream Failed: ").concat(t, ", closing stream "), e.getId(), i),
  11888. s.b.subscribe(R.joinInfo.sid, {
  11889. lts: a,
  11890. succ: !1,
  11891. video: e.subscribeOptions && e.subscribeOptions.video,
  11892. audio: e.subscribeOptions && e.subscribeOptions.audio,
  11893. peerid: e.getId(),
  11894. ec: t
  11895. }),
  11896. "TIMEOUT" != t && (R.processSubscribeFailure(e), n && n(t))
  11897. }))
  11898. },
  11899. nop2p: !0,
  11900. audio: !0,
  11901. video: !0,
  11902. screen: e.hasScreen(),
  11903. isSubscriber: !0,
  11904. stunServerUrl: R.stunServerUrl,
  11905. turnServers: R.joinInfo.turnServers,
  11906. isVideoMute: e.userMuteVideo,
  11907. isAudioMute: e.userMuteAudio,
  11908. uid: e.getId(),
  11909. clientId: R.clientId
  11910. }),
  11911. e.pc.onaddstream = function(t, n) {
  11912. if (e._onAudioUnmute = function() {
  11913. R.makeReport(i({
  11914. action: "unmute_remote_audio",
  11915. stream_id: e.getId()
  11916. }), (function() {}), (function() {}))
  11917. },
  11918. e._onAudioMute = function() {
  11919. R.makeReport(i({
  11920. action: "mute_remote_audio",
  11921. stream_id: e.getId()
  11922. }), (function() {}), (function() {}))
  11923. },
  11924. e._onVideoUnmute = function() {
  11925. R.makeReport(i({
  11926. action: "unmute_remote_video",
  11927. stream_id: e.getId()
  11928. }), (function() {}), (function() {}))
  11929. },
  11930. e._onVideoMute = function() {
  11931. R.makeReport(i({
  11932. action: "mute_remote_video",
  11933. stream_id: e.getId()
  11934. }), (function() {}), (function() {}))
  11935. },
  11936. "ontrack" === n && "video" === t.track.kind || "onaddstream" === n) {
  11937. r.
  11938. default.info("[".concat(R.clientId, "] Remote stream subscribed with uid "), e.getId());
  11939. var a = R.remoteStreams[e.getId()];
  11940. if (R.remoteStreams[e.getId()].stream = "onaddstream" === n ? t.stream: t.streams[0], R.remoteStreams[e.getId()].hasVideo()) {
  11941. if (Object(g.isFireFox)() || Object(g.isSafari)()) {
  11942. var o = R.remoteStreams[e.getId()].stream;
  11943. Object(H.vsResHack)(o, (function(t, n) {
  11944. e.videoWidth = t,
  11945. e.videoHeight = n
  11946. }), (function(e) {
  11947. return r.
  11948. default.warning("[".concat(R.clientId, "] vsResHack failed: ") + e)
  11949. }))
  11950. }
  11951. } else {
  11952. var s = R.remoteStreams[e.getId()];
  11953. s.peerMuteVideo = !0,
  11954. R._adjustPCMuteStatus(s)
  11955. }
  11956. a && a.isPlaying() && a.elementID && (r.
  11957. default.debug("[".concat(R.clientId, "] Reload Player ").concat(a.elementID, " StreamId ").concat(a.getId())), e.audioOutput = a.audioOutput, a.stop(), e.play(a.elementID, a.playOptions)),
  11958. delete e.audioLevelHelper;
  11959. var c = u({
  11960. type: "stream-subscribed",
  11961. stream: R.remoteStreams[e.getId()]
  11962. });
  11963. R.dispatchEvent(c)
  11964. }
  11965. },
  11966. clearInterval(R.timers[e.getId()]),
  11967. R.timers[e.getId()] = setInterval((function() {
  11968. if (Object(o.getParameter)("REPORT_STATS")) {
  11969. var t = 0;
  11970. e && e.pc && e.pc.getStats && e.pc.getStatsRate((function(n) {
  11971. n.forEach((function(n) {
  11972. if (n && n.id) {
  11973. if (/_send$/.test(n.id) || /^time$/.test(n.id) || /^bweforvideo$/.test(n.id)) return; - 1 === n.id.indexOf("inbound_rtp") && -1 === n.id.indexOf("inbound-rtp") && -1 === n.type.toLowerCase().indexOf("inbound") || "video" !== n.mediaType || (n.googFrameWidthReceived = e.videoWidth + "", n.googFrameHeightReceived = e.videoHeight + "");
  11974. var a = 200 * t;
  11975. t++;
  11976. var i = e.getId();
  11977. setTimeout((function() {
  11978. var t = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11979. if (t > Object(o.getParameter)("REPORT_STATS_TIMEOUT")) r.
  11980. default.debug("SubscribeStats report blocked by REPORT_STATS_TIMEOUT ".concat(t));
  11981. else {
  11982. if ("video" === n.mediaType) try {
  11983. var a = e.stream.getVideoTracks()[0];
  11984. n.A_vrtd = a.enabled ? "0": "1"
  11985. } catch(e) {}
  11986. if ("audio" === n.mediaType) try {
  11987. var s = e.stream.getAudioTracks()[0];
  11988. n.A_artd = s.enabled ? "0": "1"
  11989. } catch(e) {}
  11990. R.makeReport(v(i, n))
  11991. }
  11992. }), a)
  11993. } else;
  11994. }))
  11995. }))
  11996. }
  11997. }), 3e3),
  11998. clearInterval(R.timers[e.getId() + "_RelatedStats"]),
  11999. R.timers[e.getId() + "_RelatedStats"] = setInterval((function() {
  12000. if (Object(o.getParameter)("REPORT_STATS") && e && e.pc) {
  12001. var t = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  12002. if (t > Object(o.getParameter)("REPORT_STATS_TIMEOUT")) return void r.
  12003. default.debug("SubscribeRelatedStats report blocked by REPORT_STATS_TIMEOUT ".concat(t));
  12004. e.pc.getVideoRelatedStats && e.pc.getVideoRelatedStats((function(t) {
  12005. e.player && (t.isFreeze = e.player.freezeCount > e.player.lastFreezeCount, e.player.lastFreezeCount = e.player.freezeCount),
  12006. R.makeReport(d(e.getId(), t))
  12007. })),
  12008. e.pc.getAudioRelatedStats && e.pc.getAudioRelatedStats((function(t) {
  12009. R.makeReport(d(e.getId(), t))
  12010. }))
  12011. }
  12012. }), 1e3),
  12013. R.audioLevel[e.getId()] = 0,
  12014. clearInterval(R.timers[e.getId() + "audio"]),
  12015. R.timers[e.getId() + "audio"] = setInterval((function() {
  12016. R.hasListeners("active-speaker") && e && e.pc && "established" === e.pc.state && e.pc.getStats && e.pc.getStats((function(t) {
  12017. t.forEach((function(t) {
  12018. if ("audio" === t.mediaType) {
  12019. if (t.audioOutputLevel > 5e3) for (var n in R.audioLevel[e.getId()] < 20 && (R.audioLevel[e.getId()] += 1), R.audioLevel) n !== "" + e.getId() && R.audioLevel[n] > 0 && (R.audioLevel[n] -= 1);
  12020. var a = Object.keys(R.audioLevel).sort((function(e, t) {
  12021. return R.audioLevel[t] - R.audioLevel[e]
  12022. }));
  12023. if (R.activeSpeaker !== a[0]) {
  12024. var i = l({
  12025. type: "active-speaker",
  12026. uid: a[0]
  12027. });
  12028. R.dispatchEvent(i),
  12029. R.activeSpeaker = a[0],
  12030. r.
  12031. default.debug("[".concat(R.clientId, "] Update active speaker: ").concat(R.activeSpeaker))
  12032. }
  12033. }
  12034. }))
  12035. }), 50)
  12036. }), 50),
  12037. e.pc.oniceconnectionstatechange = function(i) {
  12038. if ("failed" === i) null != R.timers[e.getId()] && (clearInterval(R.timers[e.getId()]), clearInterval(R.timers[e.getId()] + "audio")),
  12039. r.
  12040. default.error("[".concat(R.clientId, "] Subscriber connection is lost -- streamId: ").concat(e.getId(), ", p2pId: ").concat(p)),
  12041. r.
  12042. default.debug("[".concat(R.clientId, "] subscribe p2p failed: "), R.p2ps),
  12043. c || (c = !0, n && n(I.
  12044. default.PEERCONNECTION_FAILED), s.b.subscribe(R.joinInfo.sid, {
  12045. lts: a,
  12046. succ: !1,
  12047. video: e.subscribeOptions && e.subscribeOptions.video,
  12048. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12049. peerid: e.getId(),
  12050. ec: I.
  12051. default.PEERCONNECTION_FAILED,
  12052. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12053. p2pid: p
  12054. })),
  12055. R.remoteStreams[e.getId()] && R.p2ps.has(p) && (R.p2ps.delete(p), R.dispatchEvent(l({
  12056. type: "subP2PLost",
  12057. stream: e
  12058. })));
  12059. else if ("connected" === i && (r.
  12060. default.debug("[".concat(R.clientId, "] subscribe p2p connected: "), R.p2ps), !c)) {
  12061. c = !0,
  12062. s.b.subscribe(R.joinInfo.sid, {
  12063. lts: a,
  12064. succ: !0,
  12065. video: e.subscribeOptions && e.subscribeOptions.video,
  12066. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12067. peerid: e.getId(),
  12068. ec: null,
  12069. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12070. p2pid: p
  12071. }),
  12072. R._adjustPCMuteStatus(e);
  12073. var o = !1,
  12074. d = !1,
  12075. u = !1,
  12076. f = setInterval((function() {
  12077. o && d || (e.pc ? e.pc.getStats((function(t) {
  12078. t.forEach((function(t) {
  12079. if (( - 1 !== t.id.indexOf("recv") || t.type && -1 !== t.type.toLowerCase().indexOf("inbound") || -1 !== t.id.indexOf("inbound_rtp") || -1 !== t.id.indexOf("inbound-rtp") || -1 !== t.id.indexOf("InboundRTP")) && "audio" === t.mediaType) {
  12080. if ((t.googDecodingNormal > 0 || t.audioOutputLevel > 0) && !o) {
  12081. o = !0,
  12082. R.dispatchEvent({
  12083. type: "first-audio-frame-decode",
  12084. stream: e
  12085. }),
  12086. o && d && clearInterval(f);
  12087. var n = Date.now(),
  12088. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12089. s.b.firstAudioDecode(R.joinInfo.sid, {
  12090. peerid: e.uintId,
  12091. uid: R.uid,
  12092. elapse: n - a,
  12093. subscribeElapse: n - e.subscribeLTS,
  12094. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12095. p2pid: p
  12096. })
  12097. }
  12098. if (parseInt(t.packetsReceived) > 0 && !d) {
  12099. d = !0,
  12100. R.dispatchEvent({
  12101. type: "first-audio-packet-received",
  12102. stream: e
  12103. }),
  12104. o && d && clearInterval(f);
  12105. n = Date.now(),
  12106. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12107. s.b.firstAudioReceived(R.joinInfo.sid, {
  12108. peerid: e.uintId,
  12109. uid: R.uid,
  12110. elapse: n - a,
  12111. subscribeElapse: n - e.subscribeLTS,
  12112. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12113. p2pid: p
  12114. })
  12115. }
  12116. }
  12117. }))
  12118. }), 100) : clearInterval(f))
  12119. }), 100),
  12120. g = !1,
  12121. m = !1,
  12122. v = setInterval((function() {
  12123. g && m || (e.pc ? e.pc.getStats((function(t) {
  12124. t.forEach((function(t) {
  12125. if (( - 1 !== t.id.indexOf("recv") || t.type && -1 !== t.type.toLowerCase().indexOf("inbound") || -1 !== t.id.indexOf("inbound_rtp") || -1 !== t.id.indexOf("inbound-rtp") || -1 !== t.id.indexOf("InboundRTP")) && "video" === t.mediaType) {
  12126. if ((t.framesDecoded > 0 || t.googFramesDecoded > 0) && !g) {
  12127. g = !0,
  12128. R.dispatchEvent({
  12129. type: "first-video-frame-decode",
  12130. stream: e
  12131. }),
  12132. g && m && clearInterval(v);
  12133. var n = Date.now(),
  12134. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12135. e.firstFrameTime = (new Date).getTime() - e.subscribeLTS,
  12136. s.b.firstVideoDecode(R.joinInfo.sid, {
  12137. peerid: e.uintId,
  12138. width: parseInt(t.googFrameWidthReceived) || 0,
  12139. height: parseInt(t.googFrameHeightReceived) || 0,
  12140. uid: R.uid,
  12141. elapse: n - a,
  12142. subscribeElapse: n - e.subscribeLTS,
  12143. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12144. p2pid: p
  12145. })
  12146. }
  12147. if (t.packetsReceived > 0 && !m) {
  12148. m = !0,
  12149. R.dispatchEvent({
  12150. type: "first-video-packet-received",
  12151. stream: e
  12152. }),
  12153. g && m && clearInterval(v);
  12154. n = Date.now(),
  12155. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12156. s.b.firstVideoReceived(R.joinInfo.sid, {
  12157. peerid: e.uintId,
  12158. uid: R.uid,
  12159. elapse: n - a,
  12160. subscribeElapse: n - e.subscribeLTS,
  12161. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12162. p2pid: p
  12163. })
  12164. }
  12165. }
  12166. }))
  12167. }), 100) : clearInterval(v))
  12168. }), 100),
  12169. S = setInterval((function() {
  12170. if (!u) {
  12171. var t = e.getId(),
  12172. n = R.traffic_stats;
  12173. if (n && n.peer_delay) {
  12174. var a = n.peer_delay.find((function(e) {
  12175. return e.peer_uid == t
  12176. }));
  12177. if (a) {
  12178. u = !0;
  12179. var i = s.b.getSessionStartTime(R.joinInfo.sid),
  12180. o = a.peer_publish_audio_duration + (Date.now() - n.timestamp),
  12181. r = Date.now();
  12182. s.b.peerPublishStatus({
  12183. lts: r,
  12184. sid: R.joinInfo.sid,
  12185. cname: R.joinInfo.cname,
  12186. cid: R.joinInfo.cid,
  12187. uid: R.joinInfo.uid,
  12188. elapse: r - i,
  12189. peer: t,
  12190. peerPublishDuration: o,
  12191. joinChannelSuccessElapse: r - R.joinSuccessLts,
  12192. subscribeElapse: r - e.subscribeLTS
  12193. }),
  12194. clearInterval(S)
  12195. }
  12196. }
  12197. }
  12198. }), 1e3);
  12199. return e.sid = R.joinInfo.sid,
  12200. t && t()
  12201. }
  12202. }
  12203. } else r.
  12204. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  12205. c || (c = !0, n && n(I.
  12206. default.INVALID_REMOTE_STREAM), s.b.subscribe(R.joinInfo.sid, {
  12207. lts: a,
  12208. succ: !1,
  12209. video: e.subscribeOptions && e.subscribeOptions.video,
  12210. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12211. peerid: e.getId(),
  12212. ec: I.
  12213. default.INVALID_REMOTE_STREAM
  12214. }));
  12215. else r.
  12216. default.error("[".concat(R.clientId, "] No such remote stream")),
  12217. c || (c = !0, n && n(I.
  12218. default.NO_SUCH_REMOTE_STREAM), s.b.subscribe(R.joinInfo.sid, {
  12219. lts: a,
  12220. succ: !1,
  12221. video: e.subscribeOptions && e.subscribeOptions.video,
  12222. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12223. peerid: e.getId(),
  12224. ec: I.
  12225. default.NO_SUCH_REMOTE_STREAM
  12226. }))
  12227. },
  12228. R.subscribeChange = function(e, t, n) {
  12229. var a = Date.now();
  12230. r.
  12231. default.info("[".concat(R.clientId, "] Gatewayclient ").concat(R.uid, " SubscribeChange ").concat(e.getId(), ": ").concat(JSON.stringify(e.subscribeOptions))),
  12232. R._adjustPCMuteStatus(e);
  12233. var i = {
  12234. stream_id: e.getId(),
  12235. audio: e.subscribeOptions.audio,
  12236. video: e.subscribeOptions.video
  12237. };
  12238. R.makeRequest({
  12239. _type: "subscribe_change",
  12240. _message: i
  12241. },
  12242. (function(n) {
  12243. var i = u({
  12244. type: "stream-subscribe-changed",
  12245. stream: R.remoteStreams[e.getId()]
  12246. });
  12247. s.b.subscribe(R.joinInfo.sid, {
  12248. lts: a,
  12249. succ: !0,
  12250. video: e.subscribeOptions && e.subscribeOptions.video,
  12251. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12252. peerid: e.getId(),
  12253. ec: null,
  12254. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12255. p2pid: R.p2ps.get(e.getId())
  12256. }),
  12257. R.dispatchEvent(i),
  12258. t && t()
  12259. }), (function(t, a) {
  12260. r.
  12261. default.error("[".concat(R.clientId, "] Subscribe Change Failed ").concat(e.getId()), t, a),
  12262. n && n(t, a)
  12263. }))
  12264. },
  12265. R.processPublishFailure = function(e) {
  12266. e.publishLTS = null,
  12267. e.p2pId && R.p2ps.get(e.p2pId) === e && R.p2ps.delete(e.p2pId),
  12268. R.localStreams[e.getUserId()] === e && delete R.localStreams[e.getUserId()],
  12269. R.localStreams[e.getId()] === e && delete R.localStreams[e.getId()],
  12270. e.pc && (e.pc.processSignalingMessage = function() {},
  12271. e.pc.oniceconnectionstatechange = function() {},
  12272. e.pc.close(), delete e.pc),
  12273. delete e.onClose,
  12274. delete e._onAudioUnmute,
  12275. delete e._onVideoUnmute,
  12276. delete e._onAudioMute,
  12277. delete e._onVideoMute,
  12278. delete e._onAudioUnmute
  12279. },
  12280. R.processSubscribeFailure = function(e) {
  12281. e.p2pId && R.p2ps.get(e.p2pId) === e && R.p2ps.delete(e.p2pId),
  12282. e.pc && (e.pc.onaddstream = function() {},
  12283. e.pc.processSignalingMessage = function() {},
  12284. e.pc.oniceconnectionstatechange = function() {},
  12285. e.pc.close(), delete e.pc),
  12286. delete e.onClose,
  12287. delete e._onAudioUnmute,
  12288. delete e._onVideoUnmute,
  12289. delete e._onAudioMute,
  12290. delete e._onVideoMute,
  12291. delete e._onAudioUnmute
  12292. },
  12293. R._adjustPCMuteStatus = function(e) { ! e.local && e.pc && e.pc.peerConnection.getReceivers && e.pc.peerConnection.getReceivers().forEach((function(t) {
  12294. if (t && t.track && "audio" === t.track.kind) {
  12295. var n = !e.userMuteAudio && !e.peerMuteAudio;
  12296. e.subscribeOptions && !e.subscribeOptions.audio && (n = !1),
  12297. t.track.enabled = !!n
  12298. } else if (t && t.track && "video" === t.track.kind) {
  12299. var a = !e.userMuteVideo && !e.peerMuteVideo;
  12300. e.subscribeOptions && !e.subscribeOptions.video && (a = !1),
  12301. t.track.enabled = !!a
  12302. }
  12303. }))
  12304. },
  12305. R.unsubscribe = function(e, t, n) {
  12306. if ("object" !== be()(e) || null === e) return r.
  12307. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  12308. void A(n, I.
  12309. default.INVALID_REMOTE_STREAM);
  12310. if (R.state !== h) return r.
  12311. default.error("[".concat(R.clientId, "] User is not in the session")),
  12312. void A(n, I.
  12313. default.INVALID_OPERATION);
  12314. if (null != R.timers[e.getId()] && (clearInterval(R.timers[e.getId()]), clearInterval(R.timers[e.getId()] + "audio")), null != R.audioLevel[e.getId()] && delete R.audioLevel[e.getId()], null != R.timer_counter[e.getId()] && delete R.timer_counter[e.getId()], R.remoteStreams.hasOwnProperty(e.getId())) {
  12315. if (!R.socket) return r.
  12316. default.error("[".concat(R.clientId, "] User is not in the session")),
  12317. void A(n, I.
  12318. default.INVALID_OPERATION);
  12319. if (e.local) return r.
  12320. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  12321. void A(n, I.
  12322. default.INVALID_REMOTE_STREAM);
  12323. e.close(),
  12324. e.stop();
  12325. var a = {
  12326. stream_id: e.getId()
  12327. };
  12328. R.makeRequest({
  12329. _type: "unsubscribe",
  12330. _message: a
  12331. }),
  12332. void 0 !== e.pc && (e.pc.close(), e.pc = void 0),
  12333. e.onClose = void 0,
  12334. e._onAudioMute = void 0,
  12335. e._onAudioUnute = void 0,
  12336. e._onVideoMute = void 0,
  12337. e._onVideoUnmute = void 0,
  12338. delete e.subscribeOptions,
  12339. R.p2ps.delete(e.p2pId),
  12340. r.
  12341. default.info("[".concat(R.clientId, "] Unsubscribe stream success")),
  12342. t && t()
  12343. } else A(n, I.
  12344. default.NO_SUCH_REMOTE_STREAM)
  12345. },
  12346. R.setRemoteVideoStreamType = function(e, t) {
  12347. if (r.
  12348. default.debug("[".concat(R.clientId, "] Switching remote video stream ").concat(e.getId(), " to ").concat(t)), "object" === be()(e) && null !== e) if (R.state === h) {
  12349. if (!e.local) {
  12350. switch (t) {
  12351. case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_HIGH:
  12352. case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_LOW:
  12353. case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_MEDIUM:
  12354. break;
  12355. default:
  12356. return
  12357. }
  12358. var n = {
  12359. stream_id: e.getId(),
  12360. stream_type: t
  12361. };
  12362. R.makeRequest({
  12363. _type: "switch_video_stream",
  12364. _message: n
  12365. },
  12366. (function() {
  12367. r.
  12368. default.debug("SwitchVideoStream Success ".concat(n.stream_id, " ").concat(n.stream_type))
  12369. }), (function(e, t) {
  12370. r.
  12371. default.error("SwitchVideoStream Error ".concat(e, " ").concat(n.stream_id, " ").concat(n.stream_type), t)
  12372. }))
  12373. }
  12374. } else r.
  12375. default.error("[".concat(R.clientId, "] User is not in the session"));
  12376. else r.
  12377. default.error("[".concat(R.clientId, "] Invalid remote stream"))
  12378. },
  12379. R.renewToken = function(e, t, n) {
  12380. e ? R.key ? R.state !== h ? (r.
  12381. default.debug("[".concat(R.clientId, "] Client is not connected. Trying to rejoin")), R.key = e, R.rejoin(), t && t()) : (r.
  12382. default.debug("[".concat(R.clientId, "] renewToken from ").concat(R.key, " to ").concat(e)), R.makeRequest({
  12383. _type: "renew_token",
  12384. _message: {
  12385. token: e
  12386. }
  12387. },
  12388. t, n)) : (r.
  12389. default.error("[".concat(R.clientId, "] Client is previously joined without token")), n && n(I.
  12390. default.INVALID_PARAMETER)):
  12391. (r.
  12392. default.error("[".concat(R.clientId, "] Invalid Token ").concat(e)), n && n(I.
  12393. default.INVALID_PARAMETER))
  12394. },
  12395. R.setStreamFallbackOption = function(e, t) {
  12396. if (r.
  12397. default.debug("[".concat(R.clientId, "] Set stream fallback option ").concat(e.getId(), " to ").concat(t)), "object" === be()(e) && null !== e) if (R.state === h) {
  12398. if (!e.local) {
  12399. switch (t) {
  12400. case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_DISABLED:
  12401. case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW:
  12402. case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_AUDIO_ONLY:
  12403. break;
  12404. default:
  12405. return
  12406. }
  12407. var n = {
  12408. stream_id: e.getId(),
  12409. fallback_type: t
  12410. };
  12411. R.makeRequest({
  12412. _type: "set_fallback_option",
  12413. _message: n
  12414. },
  12415. (function() {
  12416. r.
  12417. default.debug("SetStreamFallbackOption success ".concat(n.stream_id, " ").concat(t))
  12418. }), (function(e, a) {
  12419. r.
  12420. default.error("Failed to SetStreamFallbackOption ".concat(n.stream_id, " ").concat(t, " ").concat(e), a)
  12421. }))
  12422. }
  12423. } else r.
  12424. default.error("[".concat(R.clientId, "] User is not in the session"));
  12425. else r.
  12426. default.error("[".concat(R.clientId, "] Invalid remote stream"))
  12427. },
  12428. R.enableAudioVolumeIndicator = function(e, t) {
  12429. R.audioVolumeIndication.enabled = !0,
  12430. R.audioVolumeIndication.interval = e,
  12431. R.audioVolumeIndication.smooth = t,
  12432. R.resetAudioVolumeIndication()
  12433. },
  12434. R.resetAudioVolumeIndication = function() {
  12435. if (clearInterval(R.timers.audioVolumeIndication), clearInterval(R.timers.audioVolumeSampling), R.audioVolumeIndication.enabled && R.audioVolumeIndication.interval) {
  12436. var e = Math.floor(1e3 * R.audioVolumeIndication.smooth / 100);
  12437. clearInterval(R.timers.audioVolumeSampling),
  12438. R.timers.audioVolumeSampling = setInterval((function() {
  12439. R.audioVolumeSampling || (R.audioVolumeSampling = {});
  12440. var t = {};
  12441. for (var n in R.remoteStreams) {
  12442. var a = R.remoteStreams[n];
  12443. if (a.stream && a.hasAudio()) {
  12444. var i = a.getAudioLevel();
  12445. i > 0 && i < 1 && (i *= 100);
  12446. var o = R.audioVolumeSampling[n] || [];
  12447. for (o.push(i); o.length > e;) o.shift();
  12448. t[n] = o
  12449. }
  12450. }
  12451. R.audioVolumeSampling = t
  12452. }), 100),
  12453. clearInterval(R.timers.audioVolumeIndication),
  12454. R.timers.audioVolumeIndication = setInterval((function() {
  12455. if (R.socket && R.socket.signal && R.socket.signal.connection && R.socket.signal.connection.readyState === WebSocket.OPEN) {
  12456. var e = [];
  12457. for (var t in R.remoteStreams) if (R.audioVolumeSampling && R.audioVolumeSampling[t]) {
  12458. var n = R.audioVolumeSampling[t],
  12459. a = 0;
  12460. n.forEach((function(e) {
  12461. a += e
  12462. }));
  12463. var i = {
  12464. uid: t,
  12465. level: Math.floor(a / n.length)
  12466. };
  12467. i.level && e.push(i)
  12468. }
  12469. var o = e.sort((function(e, t) {
  12470. return e.level - t.level
  12471. }));
  12472. r.
  12473. default.debug("[".concat(R.clientId, "] volume-indicator "), JSON.stringify(o)),
  12474. R.audioVolumeIndication.sortedAudioVolumes = o;
  12475. var s = l({
  12476. type: "volume-indicator",
  12477. attr: o
  12478. });
  12479. R.dispatchEvent(s)
  12480. }
  12481. }), R.audioVolumeIndication.interval)
  12482. }
  12483. },
  12484. R.closeGateway = function() {
  12485. r.
  12486. default.debug("[".concat(R.clientId, "] close gateway")),
  12487. R.state = S,
  12488. R.socket.close(),
  12489. O()
  12490. },
  12491. R.startChannelMediaRelay = function() {
  12492. var e = ee()(Z.a.mark((function e(t) {
  12493. var n, a, i, o;
  12494. return Z.a.wrap((function(e) {
  12495. for (;;) switch (e.prev = e.next) {
  12496. case 0:
  12497. if (!R.channelMediaRelayController) {
  12498. e.next = 2;
  12499. break
  12500. }
  12501. throw new Ce.ChannelMediaError("RELAY_ALREADY_START", "", Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_ALREADY_START);
  12502. case 2:
  12503. return n = function(e) {
  12504. R.dispatchEvent({
  12505. type: "channel-media-relay-event",
  12506. code: e
  12507. })
  12508. },
  12509. a = function(e, t, n) {
  12510. e === Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE && t === Ce.CHANNEL_MEDIA_RELAY_ERROR.SERVER_CONNECTION_LOST && (R.channelMediaRelayController.dispose(), R.channelMediaRelayController = null),
  12511. R.dispatchEvent({
  12512. type: "channel-media-relay-state",
  12513. state: e,
  12514. code: t,
  12515. data: n
  12516. })
  12517. },
  12518. R.channelMediaRelayController = new Ne.a(R.joinInfo, R.clientId),
  12519. R.channelMediaRelayController.on("event", n),
  12520. R.channelMediaRelayController.on("state", a),
  12521. e.prev = 7,
  12522. e.next = 10,
  12523. R.channelMediaRelayController.startChannelMediaRelay(t);
  12524. case 10:
  12525. e.next = 22;
  12526. break;
  12527. case 12:
  12528. throw e.prev = 12,
  12529. e.t0 = e.
  12530. catch(7),
  12531. r.
  12532. default.debug("[".concat(R.clientId, "] startChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),
  12533. i = Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,
  12534. o = "",
  12535. o = e.t0 instanceof Ce.ChannelMediaError ? "SetSourceChannelStatus" === e.t0.data || e.t0.data && e.t0.data.serverResponse && "SetSourceChannel" === e.t0.data.serverResponse.command ? "FAILED_JOIN_SRC": "SetDestChannelStatus" === e.t0.data || e.t0.data && e.t0.data.serverResponse && "SetDestChannel" === e.t0.data.serverResponse.command ? "FAILED_JOIN_DEST": e.t0.data && e.t0.data.serverResponse && "StartPacketTransfer" === e.t0.data.serverResponse.command ? "FAILED_PACKET_SENT_TO_DEST": e.t0.message === Ce.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT || e.t0.message === Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT ? "SERVER_NO_RESPONSE": e.t0.message === Ce.CHANNEL_MEDIA_ERROR.REQUEST_FAILED || e.t0.message === Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR ? "SERVER_ERROR_RESPONSE": e.t0.message === Ce.CHANNEL_MEDIA_ERROR.AP_REQUEST_TIMEOUT ? "NO_RESOURCE_AVAILABLE": e.t0.message === Ce.CHANNEL_MEDIA_ERROR.WS_ABORT || e.t0.message === Ce.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT ? "OPERATION_ABORT": "INTERNAL_ERROR": "INTERNAL_ERROR",
  12536. R.dispatchEvent({
  12537. type: "channel-media-relay-state",
  12538. state: i,
  12539. code: Ce.CHANNEL_MEDIA_RELAY_ERROR[o]
  12540. }),
  12541. R.channelMediaRelayController && (R.channelMediaRelayController.dispose(), R.channelMediaConfig = null, R.channelMediaRelayController = null),
  12542. R.dispatchEvent({
  12543. type: "channel-media-relay-state",
  12544. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE
  12545. }),
  12546. new Ce.ChannelMediaError(o, null, Ce.CHANNEL_MEDIA_RELAY_ERROR[o]);
  12547. case 22:
  12548. R.dispatchEvent({
  12549. type:
  12550. "channel-media-relay-state",
  12551. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_RUNNING,
  12552. code: Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_OK
  12553. }),
  12554. R.channelMediaConfig = t;
  12555. case 24:
  12556. case "end":
  12557. return e.stop()
  12558. }
  12559. }), e, null, [[7, 12]])
  12560. })));
  12561. return function(t) {
  12562. return e.apply(this, arguments)
  12563. }
  12564. } (),
  12565. R.updateChannelMediaRelay = function() {
  12566. var t = ee()(Z.a.mark((function t(n) {
  12567. var a, i;
  12568. return Z.a.wrap((function(t) {
  12569. for (;;) switch (t.prev = t.next) {
  12570. case 0:
  12571. if (R.channelMediaRelayController) {
  12572. t.next = 2;
  12573. break
  12574. }
  12575. throw new Ce.ChannelMediaError("RELAY_NOT_START", null, Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);
  12576. case 2:
  12577. return t.prev = 2,
  12578. t.next = 5,
  12579. R.channelMediaRelayController.updateChannelMediaRelay(n);
  12580. case 5:
  12581. t.next = 18;
  12582. break;
  12583. case 7:
  12584. throw t.prev = 7,
  12585. t.t0 = t.
  12586. catch(2),
  12587. r.
  12588. default.debug("[".concat(R.clientId, "] updateChannelMediaRelay exception: ").concat(JSON.stringify(e))),
  12589. a = Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,
  12590. i = "",
  12591. i = e instanceof Ce.ChannelMediaError ? e.message === Ce.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT || e.message === Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT ? "SERVER_NO_RESPONSE": e.message === Ce.CHANNEL_MEDIA_ERROR.REQUEST_FAILED || e.message === Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR ? "SERVER_ERROR_RESPONSE": e.message === Ce.CHANNEL_MEDIA_ERROR.WS_ABORT || e.message === Ce.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT ? "OPERATION_ABORT": "INTERNAL_ERROR": "INTERNAL_ERROR",
  12592. R.dispatchEvent({
  12593. type: "channel-media-relay-event",
  12594. code: Ce.CHANNEL_MEDIA_RELAY_EVENT.PACKET_UPDATE_DEST_CHANNEL_REFUSED
  12595. }),
  12596. R.dispatchEvent({
  12597. type: "channel-media-relay-state",
  12598. state: a,
  12599. code: Ce.CHANNEL_MEDIA_RELAY_ERROR[i]
  12600. }),
  12601. R.channelMediaRelayController && (R.channelMediaRelayController.dispose(), R.channelMediaConfig = null, R.channelMediaRelayController = null),
  12602. R.dispatchEvent({
  12603. type: "channel-media-relay-state",
  12604. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE
  12605. }),
  12606. new Ce.ChannelMediaError(i, null, Ce.CHANNEL_MEDIA_RELAY_ERROR[i]);
  12607. case 18:
  12608. R.channelMediaConfig = n;
  12609. case 19:
  12610. case "end":
  12611. return t.stop()
  12612. }
  12613. }), t, null, [[2, 7]])
  12614. })));
  12615. return function(e) {
  12616. return t.apply(this, arguments)
  12617. }
  12618. } (),
  12619. R.stopChannelMediaRelay = ee()(Z.a.mark((function t() {
  12620. var n, a;
  12621. return Z.a.wrap((function(t) {
  12622. for (;;) switch (t.prev = t.next) {
  12623. case 0:
  12624. if (R.channelMediaRelayController) {
  12625. t.next = 2;
  12626. break
  12627. }
  12628. throw new Ce.ChannelMediaError("RELAY_NOT_START", null, Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);
  12629. case 2:
  12630. return t.prev = 2,
  12631. t.next = 5,
  12632. R.channelMediaRelayController.stopChannelMediaRelay();
  12633. case 5:
  12634. t.next = 17;
  12635. break;
  12636. case 7:
  12637. throw t.prev = 7,
  12638. t.t0 = t.
  12639. catch(2),
  12640. r.
  12641. default.debug("[".concat(R.clientId, "] stopChannelMediaRelay exception: ").concat(JSON.stringify(e))),
  12642. n = Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,
  12643. a = "",
  12644. a = e instanceof Ce.ChannelMediaError ? e.message === Ce.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT || e.message === Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT ? "SERVER_NO_RESPONSE": e.message === Ce.CHANNEL_MEDIA_ERROR.REQUEST_FAILED || e.message === Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR ? "SERVER_ERROR_RESPONSE": "INTERNAL_ERROR": "INTERNAL_ERROR",
  12645. R.dispatchEvent({
  12646. type: "channel-media-relay-state",
  12647. state: n,
  12648. code: Ce.CHANNEL_MEDIA_RELAY_ERROR[a]
  12649. }),
  12650. R.channelMediaRelayController && (R.channelMediaRelayController.dispose(), R.channelMediaConfig = null, R.channelMediaRelayController = null),
  12651. R.dispatchEvent({
  12652. type: "channel-media-relay-state",
  12653. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE
  12654. }),
  12655. new Ce.ChannelMediaError(a, null, Ce.CHANNEL_MEDIA_RELAY_ERROR[a]);
  12656. case 17:
  12657. R.channelMediaConfig = null,
  12658. R.channelMediaRelayController = null;
  12659. case 19:
  12660. case "end":
  12661. return t.stop()
  12662. }
  12663. }), t, null, [[2, 7]])
  12664. }))),
  12665. R.sendMetadata = function(e, t) {
  12666. R.makeRequest(function(e) {
  12667. return {
  12668. _type: "send_metadata",
  12669. _message: {
  12670. session_id: R.joinInfo.sid,
  12671. metadata: window.btoa(unescape(encodeURIComponent(e)))
  12672. }
  12673. }
  12674. } (e), (function() {
  12675. r.
  12676. default.debug("[".concat(R.clientId, '] send metadata "').concat(e, '" success')),
  12677. t && t(null)
  12678. }), (function(n) {
  12679. r.
  12680. default.error("[".concat(R.clientId, '] send metadata "').concat(e, '" failed'), n),
  12681. t && t(n)
  12682. }))
  12683. };
  12684. var y = function() {
  12685. r.
  12686. default.debug("[".concat(R.clientId, "] Reconnect gateway")),
  12687. R.state = S,
  12688. R.socket.close(),
  12689. O(),
  12690. R.reconnectMode = "recover",
  12691. R.state = _,
  12692. C()
  12693. };
  12694. R.recover = y;
  12695. var O = function() {
  12696. for (var e in R.dispatchEvent({
  12697. type: "before-clear-connection"
  12698. }), R.timers) R.timers.hasOwnProperty(e) && clearInterval(R.timers[e]);
  12699. for (var e in R.remoteStreams) if (R.remoteStreams.hasOwnProperty(e)) {
  12700. var t = R.remoteStreams[e],
  12701. n = l({
  12702. type: "stream-removed",
  12703. uid: t.getId(),
  12704. stream: t
  12705. });
  12706. R.dispatchEvent(n)
  12707. }
  12708. R.p2ps.clear(),
  12709. k(),
  12710. D(),
  12711. clearInterval(R.pingTimer)
  12712. };
  12713. R.rejoin = function() {
  12714. R.socket && (clearInterval(R.pingTimer), R.socket.close(), R.socket = void 0),
  12715. R.state = _,
  12716. C()
  12717. };
  12718. var C = function(e, t) {
  12719. R.dispatchEvent(l({
  12720. type: "rejoin-start"
  12721. })),
  12722. e = e ||
  12723. function(e) {
  12724. r.
  12725. default.info("[".concat(R.clientId, "] User ").concat(e, " is re-joined to ").concat(R.joinInfo.cname)),
  12726. R.dispatchEvent(l({
  12727. type: "rejoin"
  12728. })),
  12729. R.channelMediaConfig && R.startChannelMediaRelay(R.channelMediaConfig).then((function() {
  12730. r.
  12731. default.debug("[".concat(R.clientId, "] restartChannelMediaRelay success"))
  12732. })).
  12733. catch((function(e) {
  12734. r.
  12735. default.debug("[".concat(R.clientId, "] restartChannelMediaRelay failed: ").concat(JSON.stringify(e)))
  12736. })),
  12737. R.liveStreams && R.liveStreams.size && R.liveStreams.forEach((function(e, t) {
  12738. e && R.setLiveTranscoding(R.transcoding),
  12739. R.startLiveStreaming(t, e)
  12740. })),
  12741. R.injectLiveStreams && R.injectLiveStreams.size && R.injectLiveStreams.forEach((function(e, t) {
  12742. R.addInjectStreamUrl(t, e)
  12743. }))
  12744. },
  12745. t = t ||
  12746. function(e) {
  12747. r.
  12748. default.error("[".concat(R.clientId, "] Re-join to channel failed "), e),
  12749. R.dispatchEvent(u({
  12750. type: "error",
  12751. reason: e
  12752. }))
  12753. },
  12754. R.key ? (++R.rejoinAttempt, R.join(R.joinInfo, R.key, e, t)) : r.
  12755. default.error("[".concat(R.clientId, "] Connection recover failed [Invalid channel key]"))
  12756. },
  12757. N = function(e, t, n) {
  12758. if (R.onConnect = t, R.socket) {
  12759. if (R.dispatchEvent({
  12760. type: "reconnect"
  12761. }), "retry" === R.reconnectMode) r.
  12762. default.debug("[".concat(R.clientId, "] Retry current gateway")),
  12763. R.socket.reconnect();
  12764. else if ("tryNext" === R.reconnectMode) r.
  12765. default.debug("[".concat(R.clientId, "] Try next gateway")),
  12766. R.socket.connectNext();
  12767. else if ("recover" === R.reconnectMode) {
  12768. r.
  12769. default.debug("[".concat(R.clientId, "] Recover gateway")),
  12770. r.
  12771. default.debug("[".concat(R.clientId, "] Try to reconnect choose server and get gateway list again ")),
  12772. R.reconnectingCS = !0;
  12773. var i = R.joinInfo && R.joinInfo.sid;
  12774. 0,
  12775. ze(R.joinInfo, (function(e) {
  12776. r.
  12777. default.debug("[".concat(R.clientId, "] session: ").concat(i, " get gateway list success")),
  12778. R.joinInfo.apResponse = e.res,
  12779. R.reconnectingCS ? R.socket.replaceHost(e.gateway_addr) : r.
  12780. default.debug("[".concat(R.clientId, "] session: ").concat(i, " already leave"))
  12781. }))
  12782. }
  12783. } else c = e.gatewayAddr,
  12784. R.socket = Ve(c, {
  12785. sid: R.joinInfo.sid,
  12786. clientId: R.clientId
  12787. }),
  12788. R.socket.on("start-connection", (function(e) {
  12789. R.ticket = e && e.msg && e.msg.ticket
  12790. })),
  12791. R.socket.on("on_uplink_stats", (function(e) {
  12792. var t = {};
  12793. for (var n in e) t[it(n)] = e[n];
  12794. if (R.OutgoingAvailableBandwidth = t.uplink_available_bandwidth, R.localStreams[R.uid]) {
  12795. var a = R.localStreams[R.uid].uplinkStats;
  12796. a && a.period_fir === t.period_fir || r.
  12797. default.debug("[".concat(R.clientId, "]: Period fir change to: ").concat(t.period_fir)),
  12798. R.localStreams[R.uid].uplinkStats = t
  12799. }
  12800. })),
  12801. R.socket.on("connect", (function() {
  12802. R.dispatchEvent({
  12803. type: "connected"
  12804. }),
  12805. R.attemps = 1,
  12806. R.onConnect()
  12807. })),
  12808. R.socket.on("recover", (function() {
  12809. R.state = _,
  12810. r.
  12811. default.debug("[".concat(R.clientId, "] Try to reconnect choose server and get gateway list again ")),
  12812. R.reconnectingCS = !0;
  12813. var e = R.joinInfo && R.joinInfo.sid;
  12814. ze(R.joinInfo, (function(t) {
  12815. r.
  12816. default.debug("[".concat(R.clientId, "] session: ").concat(e, " get gateway list success")),
  12817. R.reconnectingCS ? R.socket.replaceHost(t.gateway_addr) : r.
  12818. default.debug("[".concat(R.clientId, "] session: ").concat(e, " already leave"))
  12819. }))
  12820. })),
  12821. R.socket.on("disconnect", (function(e) {
  12822. if (r.
  12823. default.debug("[".concat(R.clientId, "] Receive disconnect message")), R.state !== S) {
  12824. R.state = S;
  12825. var t = u({
  12826. type: "error",
  12827. reason: I.
  12828. default.SOCKET_DISCONNECTED
  12829. });
  12830. if (R.dispatchEvent(t), 0 === R.p2ps.size ? R.reconnectMode = "tryNext": R.reconnectMode = "retry", O(), R.channelMediaRelayController && R.channelMediaRelayController.dispose(), R.channelMediaRelayController = null, 1 != a) {
  12831. var n, i = (n = R.attemps, 1e3 * Math.min(30, Math.pow(2, n) - 1));
  12832. if (r.
  12833. default.error("[".concat(R.clientId, "] Disconnect from server [").concat(JSON.stringify(e), "], attempt to recover [#").concat(R.attemps, "] after ").concat(i / 1e3, " seconds")), R.hasInvokeLeave) return r.
  12834. default.debug("[".concat(R.clientId, "] No reconnection because Client.leave has been invoked")),
  12835. void(R.hasInvokeLeave = !1);
  12836. setTimeout((function() {
  12837. R.attemps++,
  12838. R.state = _,
  12839. R.inChannelInfo && Date.now() - R.inChannelInfo.joinAt > Object(o.getParameter)("TICKET_RENEW_TIMEOUT") ? (r.
  12840. default.debug("Recovering to renew ticket"), y()) : C()
  12841. }), i)
  12842. }
  12843. }
  12844. })),
  12845. R.socket.on("on_add_audio_stream", (function(e) {
  12846. if (r.
  12847. default.info("[".concat(R.clientId, "] Newly added audio stream with uid ").concat(e.uid)), R.joinInfo.stringUid && "string" != typeof e.uid && r.
  12848. default.error("StringUID is Mixed with UintUID"), R.remoteStreamsInChannel.has(e.uid) || R.remoteStreamsInChannel.add(e.uid), void 0 === R.remoteStreams[e.uid]) {
  12849. var t = ye({
  12850. streamID: e.uid,
  12851. local: !1,
  12852. audio: e.audio,
  12853. video: e.video,
  12854. uintUID: e.uint_id || e.uid
  12855. });
  12856. t.peerMuteVideo = !0,
  12857. R.remoteStreams[e.uid] = t;
  12858. var n = u({
  12859. type: "stream-added",
  12860. stream: t
  12861. });
  12862. R.dispatchEvent(n);
  12863. var a = R.remoteMuteState[e.uid];
  12864. if (a && a.audio) {
  12865. n = l({
  12866. type: "mute-audio",
  12867. uid: e.uid
  12868. });
  12869. R.dispatchEvent(n)
  12870. }
  12871. if (a && a.video) {
  12872. n = l({
  12873. type: "mute-video",
  12874. uid: e.uid
  12875. });
  12876. R.dispatchEvent(n)
  12877. }
  12878. }
  12879. s.b.onAddAudioStream(R.joinInfo.sid, {
  12880. peerid: e.uint_id || e.uid,
  12881. uid: R.uid
  12882. })
  12883. })),
  12884. R.socket.on("on_update_stream", (function(e) {
  12885. var t = R.remoteStreams[e.uid];
  12886. if (R.joinInfo.stringUid && "string" != typeof e.uid && r.
  12887. default.error("StringUID is Mixed with UintUID"), t) {
  12888. t.audio = e.audio,
  12889. t.video = e.video,
  12890. t.screen = e.screen,
  12891. t.pc && R._adjustPCMuteStatus(t);
  12892. var n = u({
  12893. type: "stream-updated",
  12894. stream: t
  12895. });
  12896. R.dispatchEvent(n)
  12897. } else r.
  12898. default.debug("[".concat(R.clientId, "] Ignoring onUpdateStream event before onAddStream for uid ").concat(e.uid));
  12899. s.b.onUpdateStream(R.joinInfo.sid, {
  12900. peerid: e.uint_id || e.uid,
  12901. audio: e.audio,
  12902. video: e.video,
  12903. uid: R.uid
  12904. })
  12905. })),
  12906. R.socket.on("on_add_video_stream", (function(e) {
  12907. if (r.
  12908. default.info("[".concat(R.clientId, "] Newly added remote stream with uid ").concat(e.uid, ".")), R.joinInfo.stringUid && "string" != typeof e.uid && r.
  12909. default.error("StringUID is Mixed with UintUID"), R.remoteStreamsInChannel.has(e.uid) || R.remoteStreamsInChannel.add(e.uid), void 0 === R.remoteStreams[e.uid]) {
  12910. var t = ye({
  12911. streamID: e.uid,
  12912. local: !1,
  12913. audio: e.audio,
  12914. video: e.video,
  12915. uintUID: e.uint_id || e.uid
  12916. });
  12917. R.remoteStreams[e.uid] = t;
  12918. var n = u({
  12919. type: "stream-added",
  12920. stream: t
  12921. });
  12922. R.dispatchEvent(n);
  12923. var a = R.remoteMuteState[e.uid];
  12924. if (a && a.audio) {
  12925. n = l({
  12926. type: "mute-audio",
  12927. uid: e.uid
  12928. });
  12929. R.dispatchEvent(n)
  12930. }
  12931. if (a && a.video) {
  12932. n = l({
  12933. type: "mute-video",
  12934. uid: e.uid
  12935. });
  12936. R.dispatchEvent(n)
  12937. }
  12938. } else {
  12939. var i = R.remoteStreams[e.uid];
  12940. if (void 0 !== i.stream) {
  12941. if ((t = R.remoteStreams[e.uid]).video = !0, t.peerMuteVideo = !1, t.pc && R._adjustPCMuteStatus(t), r.
  12942. default.info("[".concat(R.clientId, "] Stream changed: enable video ").concat(e.uid)), t.isPlaying()) {
  12943. var o = t.player.elementID;
  12944. t.stop(),
  12945. t.play(o, t.playOptions)
  12946. }
  12947. } else if (i.p2pId) R.remoteStreams[e.uid].video = !0;
  12948. else {
  12949. t = ye({
  12950. streamID: e.uid,
  12951. local: !1,
  12952. audio: !0,
  12953. video: !0,
  12954. uintUID: e.uint_id || e.uid
  12955. });
  12956. R.remoteStreams[e.uid] = t,
  12957. r.
  12958. default.info("[".concat(R.clientId, "] Stream changed: modify video ").concat(e.uid))
  12959. }
  12960. }
  12961. s.b.onAddVideoStream(R.joinInfo.sid, {
  12962. peerid: e.uint_id || e.uid,
  12963. uid: R.uid
  12964. })
  12965. })),
  12966. R.socket.on("on_remove_stream", (function(e) {
  12967. R.remoteStreamsInChannel.has(e.uid) && R.remoteStreamsInChannel.delete(e.uid);
  12968. var t = R.remoteStreams[e.uid];
  12969. if (t) {
  12970. delete R.remoteStreams[e.uid],
  12971. delete R.remoteMuteState[e.uid];
  12972. var n = u({
  12973. type: "stream-removed",
  12974. stream: t
  12975. });
  12976. R.dispatchEvent(n),
  12977. t.close(),
  12978. void 0 !== t.pc && (t.pc.close(), t.pc = void 0, R.p2ps.delete(t.p2pId)),
  12979. s.b.onRemoveStream(R.joinInfo.sid, {
  12980. peerid: e.uint_id || e.uid,
  12981. uid: R.uid
  12982. })
  12983. } else r.
  12984. default.error("ERROR stream ", e.uid, " not found onRemoveStream ", e)
  12985. })),
  12986. R.socket.on("on_publish_stream", (function(e) {
  12987. var t = R.localStreams[e.uid],
  12988. n = u({
  12989. type: "streamPublished",
  12990. stream: t
  12991. });
  12992. R.dispatchEvent(n)
  12993. })),
  12994. R.socket.on("mute_audio", (function(e) {
  12995. r.
  12996. default.info("[".concat(R.clientId, "] rcv peer mute audio: ").concat(e.uid)),
  12997. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  12998. audio: !1,
  12999. video: !1
  13000. },
  13001. R.remoteMuteState[e.uid].audio = !0;
  13002. var t = l({
  13003. type: "mute-audio",
  13004. uid: e.uid
  13005. }),
  13006. n = R.remoteStreams[e.uid];
  13007. n ? (n.peerMuteAudio = !0, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13008. default.debug("Ignoring event ".concat(e.type), e)
  13009. })),
  13010. R.socket.on("unmute_audio", (function(e) {
  13011. r.
  13012. default.info("[".concat(R.clientId, "] rcv peer unmute audio: ").concat(e.uid)),
  13013. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  13014. audio: !1,
  13015. video: !1
  13016. },
  13017. R.remoteMuteState[e.uid].audio = !1;
  13018. var t = l({
  13019. type: "unmute-audio",
  13020. uid: e.uid
  13021. }),
  13022. n = R.remoteStreams[e.uid];
  13023. n ? (n.peerMuteAudio = !1, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13024. default.debug("Ignoring event ".concat(e.type), e)
  13025. })),
  13026. R.socket.on("mute_video", (function(e) {
  13027. r.
  13028. default.info("[".concat(R.clientId, "] rcv peer mute video: ").concat(e.uid)),
  13029. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  13030. audio: !1,
  13031. video: !1
  13032. },
  13033. R.remoteMuteState[e.uid].video = !0;
  13034. var t = l({
  13035. type: "mute-video",
  13036. uid: e.uid
  13037. }),
  13038. n = R.remoteStreams[e.uid];
  13039. n ? (n.peerMuteVideo = !0, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13040. default.debug("Ignoring event ".concat(e.type), e)
  13041. })),
  13042. R.socket.on("unmute_video", (function(e) {
  13043. r.
  13044. default.info("[".concat(R.clientId, "] rcv peer unmute video: ").concat(e.uid)),
  13045. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  13046. audio: !1,
  13047. video: !1
  13048. },
  13049. R.remoteMuteState[e.uid].video = !1;
  13050. var t = l({
  13051. type: "unmute-video",
  13052. uid: e.uid
  13053. }),
  13054. n = R.remoteStreams[e.uid];
  13055. n ? (n.peerMuteVideo = !1, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13056. default.debug("Ignoring event ".concat(e.type), e)
  13057. })),
  13058. R.socket.on("on_crypt_error", (function(e) {
  13059. r.
  13060. default.warning("[".concat(R.clientId, "] stream crypt error"));
  13061. var t = l({
  13062. type: "crypt-error",
  13063. cryptType: e.crypt_type
  13064. });
  13065. R.dispatchEvent(t)
  13066. })),
  13067. R.socket.on("on_user_banned", (function(e) {
  13068. r.
  13069. default.info("[".concat(R.clientId, "] user banned uid: ").concat(e.uid, " error: ").concat(e.error_code));
  13070. var t = l({
  13071. type: "client-banned",
  13072. uid: e.uid,
  13073. attr: e.error_code
  13074. });
  13075. R.dispatchEvent(t),
  13076. a = !0
  13077. })),
  13078. R.socket.on("on_stream_fallback_update", (function(e) {
  13079. r.
  13080. default.info("[".concat(R.clientId, "] stream fallback peerId: ").concat(e.stream_id, " type: ").concat(e.stream_type));
  13081. var t = l({
  13082. type: "stream-fallback",
  13083. uid: e.stream_id,
  13084. stream: e.stream_id,
  13085. attr: e.stream_type
  13086. });
  13087. R.dispatchEvent(t)
  13088. })),
  13089. R.socket.on("stream_recover", (function(e) {
  13090. r.
  13091. default.info("[".concat(R.clientId, "] stream recover uid: ").concat(e.id, " peerId: ").concat(e.peerid, " type: ").concat(e.type));
  13092. var t = l({
  13093. type: "stream-recover",
  13094. uid: e.id,
  13095. stream: e.peerid,
  13096. attr: e.type
  13097. });
  13098. R.dispatchEvent(t)
  13099. })),
  13100. R.socket.on("on_p2p_lost", (function(e) {
  13101. r.
  13102. default.debug("[".concat(R.clientId, "] p2plost: "), e, "p2ps:", R.p2ps);
  13103. var t, n = "DTLS failed"; (t = R.localStreams[e.uid] || R.remoteStreams[e.uid]) ? (t.pc && t.pc.offerCandidates && 0 === t.pc.offerCandidates.length && (n = "NO_CANDIDATES_IN_OFFER"), "publish" === e.event && s.b.publish(R.joinInfo.sid, {
  13104. lts: t.publishLTS,
  13105. succ: !1,
  13106. audio: t.hasAudio(),
  13107. video: t.hasVideo(),
  13108. screenshare: t.hasScreen(),
  13109. audioName: t.hasAudio() && t.audioName,
  13110. videoName: t.hasVideo() && t.videoName,
  13111. screenName: t.hasScreen() && t.screenName,
  13112. ec: n,
  13113. publishRequestid: R.publishRequestId || 0,
  13114. p2pid: R.p2ps.get(t.getId())
  13115. }), "subscribe" === e.event && s.b.subscribe(R.joinInfo.sid, {
  13116. lts: t.subscribeLTS,
  13117. succ: !1,
  13118. video: t.subscribeOptions && t.subscribeOptions.video,
  13119. audio: t.subscribeOptions && t.subscribeOptions.audio,
  13120. peerid: e.uid + "",
  13121. ec: n,
  13122. subscribeRequestid: R.subscribeRequestId.get(t.getId()) || 0,
  13123. p2pid: R.p2ps.get(t.getId())
  13124. })) : r.
  13125. default.warning("P2PLost Stream Not found", e),
  13126. r.
  13127. default.debug("[".concat(R.clientId, "] p2plost:"), e.p2pid),
  13128. (t = R.p2ps.get(e.p2pid)) && (R.p2ps.delete(e.p2pid), t.local ? R.dispatchEvent(l({
  13129. type: "pubP2PLost",
  13130. stream: t,
  13131. attr: n
  13132. })) : R.remoteStreams[t.getId()] && R.dispatchEvent(l({
  13133. type: "subP2PLost",
  13134. stream: t,
  13135. attr: n
  13136. })))
  13137. })),
  13138. R.socket.on("on_token_privilege_will_expire", (function(e) {
  13139. r.
  13140. default.debug("[".concat(R.clientId, "] Received Message onTokenPrivilegeWillExpire")),
  13141. R.dispatchEvent(l({
  13142. type: "onTokenPrivilegeWillExpire"
  13143. }))
  13144. })),
  13145. R.socket.on("on_token_privilege_did_expire", (function() {
  13146. r.
  13147. default.warning("[".concat(R.clientId, "] Received Message onTokenPrivilegeDidExpire, please get new token and join again")),
  13148. R.closeGateway(),
  13149. R.dispatchEvent(l({
  13150. type: "onTokenPrivilegeDidExpire"
  13151. }))
  13152. })),
  13153. R.socket.on("enable_local_video", (function(e) {
  13154. R.dispatchEvent(l({
  13155. type: "enable-local-video",
  13156. uid: e.uid
  13157. }))
  13158. })),
  13159. R.socket.on("disable_local_video", (function(e) {
  13160. R.dispatchEvent(l({
  13161. type: "disable-local-video",
  13162. uid: e.uid
  13163. }))
  13164. })),
  13165. R._doWithAction = function(e, t, n) {
  13166. "tryNext" === e ?
  13167. function(e, t) {
  13168. r.
  13169. default.debug("[".concat(R.clientId, "] Connect next gateway")),
  13170. R.state = S,
  13171. R.socket.close(),
  13172. O(),
  13173. R.reconnectMode = "tryNext",
  13174. R.state = _,
  13175. C(e, t)
  13176. } (t, n) : "retry" === e ?
  13177. function(e, t) {
  13178. r.
  13179. default.debug("[".concat(R.clientId, "] Reconnect gateway")),
  13180. R.state = S,
  13181. R.socket.close(),
  13182. O(),
  13183. R.reconnectMode = "retry",
  13184. R.state = _,
  13185. C(e, t)
  13186. } (t, n) : "quit" === e ? (r.
  13187. default.debug("[".concat(R.clientId, "] quit gateway")), R.state = S, R.socket.close(), O()) : "recover" === e && y()
  13188. },
  13189. R.socket.on("on_notification", (function(e) {
  13190. if (r.
  13191. default.debug("[".concat(R.clientId, "] Receive notification: "), e), "ERR_JOIN_BY_MULTI_IP" === I.GatewayErrorCode[e.code]) return R.dispatchEvent({
  13192. type: "onMultiIP",
  13193. option: e.option
  13194. });
  13195. e.detail ? R._doWithAction(Ze[I.GatewayErrorCode[e.code]]) : e.action && R._doWithAction(e.action)
  13196. })),
  13197. R.socket.on("on_user_offline", (function(e) {
  13198. var t = l({
  13199. type: "peer-leave",
  13200. uid: e.uid
  13201. });
  13202. if (R.remoteStreamsInChannel.has(e.uid) && R.remoteStreamsInChannel.delete(e.uid), R.remoteStreams.hasOwnProperty(e.uid) && (t.stream = R.remoteStreams[e.uid]), t.reason = e.reason, R.dispatchEvent(t), R.remoteStreams.hasOwnProperty(e.uid)) {
  13203. r.
  13204. default.info("[".concat(R.clientId, "] closing stream on peer leave"), e.uid);
  13205. var n = R.remoteStreams[e.uid];
  13206. n.close(),
  13207. delete R.remoteStreams[e.uid],
  13208. delete R.remoteMuteState[e.uid],
  13209. s.b.onRemoveStream(R.joinInfo.sid, {
  13210. peerid: e.uint_id || e.uid,
  13211. uid: R.uid
  13212. }),
  13213. void 0 !== n.pc && (n.pc.close(), n.pc = void 0, R.p2ps.delete(n.p2pId))
  13214. }
  13215. R.timers.hasOwnProperty(e.uid) && (clearInterval(R.timers[e.uid]), clearInterval(R.timers[e.uid] + "_RelatedStats"), delete R.timers[e.uid]),
  13216. null != R.audioLevel[e.uid] && delete R.audioLevel[e.uid],
  13217. null != R.timer_counter[e.uid] && delete R.timer_counter[e.uid]
  13218. })),
  13219. R.socket.on("onUplinkStats", (function(e) {})),
  13220. R.socket.on("liveStreamingStarted", (function(e) {
  13221. var t = f({
  13222. type: "liveStreamingStarted",
  13223. url: e.url
  13224. });
  13225. R.dispatchEvent(t)
  13226. })),
  13227. R.socket.on("liveStreamingFailed", (function(e) {
  13228. var t = f({
  13229. type: "liveStreamingFailed",
  13230. url: e.url
  13231. });
  13232. R.dispatchEvent(t)
  13233. })),
  13234. R.socket.on("liveStreamingStopped", (function(e) {
  13235. var t = f({
  13236. type: "liveStreamingStopped",
  13237. url: e.url
  13238. });
  13239. R.dispatchEvent(t)
  13240. })),
  13241. R.socket.on("liveTranscodingUpdated", (function(e) {
  13242. var t = f({
  13243. type: "liveTranscodingUpdated",
  13244. reason: e.reason
  13245. });
  13246. R.dispatchEvent(t)
  13247. })),
  13248. R.socket.on("streamInjectedStatus", (function(e) {
  13249. var t = f({
  13250. type: "streamInjectedStatus",
  13251. url: e.url,
  13252. uid: e.uid,
  13253. status: e.status
  13254. });
  13255. R.dispatchEvent(t)
  13256. })),
  13257. R.socket.on("on_user_online", (function(e) {
  13258. R.joinInfo.stringUid && "string" != typeof e.uid && r.
  13259. default.error("StringUID is Mixed with UintUID"),
  13260. R.dispatchEvent({
  13261. type: "peer-online",
  13262. uid: e.uid
  13263. })
  13264. })),
  13265. R.socket.on("receive_metadata", (function(e) {
  13266. R.joinInfo.stringUid && "string" != typeof e.uid && r.
  13267. default.error("StringUID is Mixed with UintUID");
  13268. var t = decodeURIComponent(escape(window.atob(e.metadata)));
  13269. r.
  13270. default.debug("[".concat(R.clientId, "] received ").concat(e.uid, " metadata: ").concat(t)),
  13271. R.dispatchEvent({
  13272. type: "receive-metadata",
  13273. uid: e.uid,
  13274. metadata: t
  13275. })
  13276. }));
  13277. var c
  13278. }, w = function(e, t) {
  13279. if (void 0 !== R.socket) try {
  13280. R.socket.emitSimpleMessage(e, (function(e, n) {
  13281. t && t(e, n)
  13282. }))
  13283. } catch(e) {
  13284. r.
  13285. default.error("[".concat(R.clientId, "] Error in sendSimpleSdp [").concat(e, "]"))
  13286. } else r.
  13287. default.error("[".concat(R.clientId, "] Error in sendSimpleSdp [socket not ready]"))
  13288. },
  13289. D = function() {
  13290. for (var e in R.localStreams) if (void 0 !== R.localStreams[e]) {
  13291. var t = R.localStreams[e];
  13292. delete R.localStreams[e],
  13293. void 0 !== t.pc && (t.pc.close(), t.pc = void 0)
  13294. }
  13295. },
  13296. k = function() {
  13297. for (var e in R.remoteStreamsInChannel.clear(), R.remoteStreams) if (R.remoteStreams.hasOwnProperty(e)) {
  13298. var t = R.remoteStreams[e];
  13299. t.isPlaying() && t.stop(),
  13300. t.close(),
  13301. delete R.remoteStreams[e],
  13302. void 0 !== t.pc && (t.pc.close(), t.pc = void 0)
  13303. }
  13304. };
  13305. return R
  13306. },
  13307. rt = {
  13308. _gatewayClients: {},
  13309. register: function(e, t) {
  13310. if (!t.uid) {
  13311. var n = "NO_UID_PROVIDED";
  13312. return r.
  13313. default.error("[".concat(e.clientId, "] "), n, t),
  13314. n
  13315. }
  13316. if (t.cname) {
  13317. if (this._gatewayClients[t.cname] && this._gatewayClients[t.cname][t.uid] && this._gatewayClients[t.cname][t.uid] !== e) {
  13318. n = "UID_CONFLICT";
  13319. return r.
  13320. default.error("[".concat(e.clientId, "] "), n, t),
  13321. n
  13322. }
  13323. return r.
  13324. default.debug("[".concat(e.clientId, "] register client Channel"), t.cname, "Uid", t.uid),
  13325. this._gatewayClients[t.cname] || (this._gatewayClients[t.cname] = {}),
  13326. this._gatewayClients[t.cname][t.uid] = e,
  13327. null
  13328. }
  13329. var n = "NO_CHANNEL_PROVIDED";
  13330. return r.
  13331. default.error("[".concat(e.clientId, "] "), n, t),
  13332. n
  13333. },
  13334. unregister: function(e) {
  13335. var t = e && e.uid,
  13336. n = e.joinInfo && e.joinInfo.cname;
  13337. if (!t || !n) {
  13338. var a = "INVALID_GATEWAYCLIENT";
  13339. return r.
  13340. default.error("[".concat(e.clientId, "] "), a),
  13341. a
  13342. }
  13343. if (this._gatewayClients[n] && this._gatewayClients[n][t]) {
  13344. if (this._gatewayClients[n][t] !== e) {
  13345. a = "GATEWAYCLIENT_UID_CONFLICT";
  13346. return r.
  13347. default.error("[".concat(e.clientId, "] "), a),
  13348. a
  13349. }
  13350. return r.
  13351. default.debug("[".concat(e.clientId, "] unregister client "), e.uid),
  13352. delete this._gatewayClients[n][t],
  13353. null
  13354. }
  13355. var a = "GATEWEAY_CLIENT_UNREGISTERED";
  13356. r.
  13357. default.error("[".concat(e.clientId, "] "), a)
  13358. }
  13359. };
  13360. ot.DISCONNECTED = 0,
  13361. ot.CONNECTING = 1,
  13362. ot.CONNECTED = 2,
  13363. ot.DISCONNECTING = 3,
  13364. ot.connetionStateMap = {
  13365. 0 : "DISCONNECTED",
  13366. 1 : "CONNECTING",
  13367. 2 : "CONNECTED",
  13368. 3 : "DISCONNECTING"
  13369. };
  13370. var st = ot,
  13371. ct = {
  13372. 1001 : "FRAMERATE_INPUT_TOO_LOW",
  13373. 1002 : "FRAMERATE_SENT_TOO_LOW",
  13374. 1003 : "SEND_VIDEO_BITRATE_TOO_LOW",
  13375. 1005 : "RECV_VIDEO_DECODE_FAILED",
  13376. 2001 : "AUDIO_INPUT_LEVEL_TOO_LOW",
  13377. 2002 : "AUDIO_OUTPUT_LEVEL_TOO_LOW",
  13378. 2003 : "SEND_AUDIO_BITRATE_TOO_LOW",
  13379. 2005 : "RECV_AUDIO_DECODE_FAILED",
  13380. 3001 : "FRAMERATE_INPUT_TOO_LOW_RECOVER",
  13381. 3002 : "FRAMERATE_SENT_TOO_LOW_RECOVER",
  13382. 3003 : "SEND_VIDEO_BITRATE_TOO_LOW_RECOVER",
  13383. 3005 : "RECV_VIDEO_DECODE_FAILED_RECOVER",
  13384. 4001 : "AUDIO_INPUT_LEVEL_TOO_LOW_RECOVER",
  13385. 4002 : "AUDIO_OUTPUT_LEVEL_TOO_LOW_RECOVER",
  13386. 4003 : "SEND_AUDIO_BITRATE_TOO_LOW_RECOVER",
  13387. 4005 : "RECV_AUDIO_DECODE_FAILED_RECOVER"
  13388. },
  13389. dt = {
  13390. FramerateInput: 1001,
  13391. FramerateSent: 1002,
  13392. SendVideoBitrate: 1003,
  13393. VideoDecode: 1005,
  13394. AudioIntputLevel: 2001,
  13395. AudioOutputLevel: 2002,
  13396. SendAudioBitrate: 2003,
  13397. AudioDecode: 2005
  13398. },
  13399. ut = function(e) {
  13400. var t = {
  13401. remoteStreamStorage: {},
  13402. localStreamStorage: {}
  13403. };
  13404. return t.gatewayClient = e,
  13405. t.checkAudioOutputLevel = function(e) {
  13406. return ! (e && parseInt(e.audioRecvBytesDelta) > 0 && parseInt(e.audioDecodingNormalDelta) > 0 && 0 === parseInt(e.audioOutputLevel))
  13407. },
  13408. t.checkAudioIntputLevel = function(e) {
  13409. return ! e || 0 !== parseInt(e.audioInputLevel)
  13410. },
  13411. t.checkFramerateInput = function(e, t) {
  13412. if (!e || !t.attributes) return ! 0;
  13413. var n = parseInt(t.attributes.maxFrameRate),
  13414. a = parseInt(e.googFrameRateInput);
  13415. return ! n || !a || !(n > 10 && a < 5 || n < 10 && n >= 5 && a <= 1)
  13416. },
  13417. t.checkFramerateSent = function(e) {
  13418. return ! (e && parseInt(e.googFrameRateInput) > 5 && parseInt(e.googFrameRateSent) <= 1)
  13419. },
  13420. t.checkSendVideoBitrate = function(e) {
  13421. return ! e || 0 !== parseInt(e.videoSendBytesDelta)
  13422. },
  13423. t.checkSendAudioBitrate = function(e) {
  13424. return ! e || 0 !== parseInt(e.audioSendBytesDelta)
  13425. },
  13426. t.checkVideoDecode = function(e) {
  13427. return ! e || 0 === parseInt(e.videoRecvBytesDelta) || 0 !== parseInt(e.googFrameRateDecoded)
  13428. },
  13429. t.checkAudioDecode = function(e) {
  13430. return ! e || 0 === parseInt(e.audioRecvBytesDelta) || 0 !== parseInt(e.audioDecodingNormalDelta)
  13431. },
  13432. t.record = function(e, n, a, i, o) {
  13433. a[e] || (a[e] = {
  13434. isPrevNormal: !0,
  13435. record: []
  13436. });
  13437. var r = a[e],
  13438. s = t["check" + e](n, o);
  13439. if (r.record.push(s), r.record.length >= 5) {
  13440. r.isCurNormal = -1 !== r.record.indexOf(!0);
  13441. var c = dt[e];
  13442. r.isPrevNormal && !r.isCurNormal && t.gatewayClient.dispatchEvent({
  13443. type: "exception",
  13444. code: c,
  13445. msg: ct[c],
  13446. uid: i
  13447. }),
  13448. !r.isPrevNormal && r.isCurNormal && t.gatewayClient.dispatchEvent({
  13449. type: "exception",
  13450. code: c + 2e3,
  13451. msg: ct[c + 2e3],
  13452. uid: i
  13453. }),
  13454. r.isPrevNormal = r.isCurNormal,
  13455. r.record = []
  13456. }
  13457. },
  13458. t.setLocalStats = function(e) {
  13459. var n = {};
  13460. Object.keys(e).map((function(a) {
  13461. var i = e[a],
  13462. o = t.gatewayClient.localStreams[parseInt(a)],
  13463. r = t.localStreamStorage[a] || {};
  13464. o && o.hasVideo() && (t.record("SendVideoBitrate", i.videoStats, r, a), t.record("FramerateInput", i.videoStats, r, a, o), t.record("FramerateSent", i.videoStats, r, a)),
  13465. o && o.hasAudio() && (t.record("AudioIntputLevel", i.audioStats, r, a), t.record("SendAudioBitrate", i.audioStats, r, a)),
  13466. n[a] = r
  13467. })),
  13468. t.localStreamStorage = n
  13469. },
  13470. t.setRemoteStats = function(n) {
  13471. var a = {};
  13472. Object.keys(n).map((function(i) {
  13473. var o = n[i],
  13474. r = e.remoteStreams[i],
  13475. s = t.remoteStreamStorage[i] || {};
  13476. r && r.hasVideo() && r.isPlaying() && t.record("VideoDecode", o.videoStats, s, i),
  13477. r && r.hasAudio() && r.isPlaying() && (t.record("AudioOutputLevel", o.audioStats, s, i), t.record("AudioDecode", o.audioStats, s, i)),
  13478. a[i] = s
  13479. })),
  13480. t.remoteStreamStorage = a
  13481. },
  13482. t
  13483. };
  13484. function lt(e) {
  13485. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  13486. if (Array.isArray(e) || (e = function(e, t) {
  13487. if (!e) return;
  13488. if ("string" == typeof e) return pt(e, t);
  13489. var n = Object.prototype.toString.call(e).slice(8, -1);
  13490. "Object" === n && e.constructor && (n = e.constructor.name);
  13491. if ("Map" === n || "Set" === n) return Array.from(n);
  13492. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pt(e, t)
  13493. } (e))) {
  13494. var t = 0,
  13495. n = function() {};
  13496. return {
  13497. s: n,
  13498. n: function() {
  13499. return t >= e.length ? {
  13500. done: !0
  13501. }: {
  13502. done: !1,
  13503. value: e[t++]
  13504. }
  13505. },
  13506. e: function(e) {
  13507. throw e
  13508. },
  13509. f: n
  13510. }
  13511. }
  13512. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  13513. }
  13514. var a, i, o = !0,
  13515. r = !1;
  13516. return {
  13517. s: function() {
  13518. a = e[Symbol.iterator]()
  13519. },
  13520. n: function() {
  13521. var e = a.next();
  13522. return o = e.done,
  13523. e
  13524. },
  13525. e: function(e) {
  13526. r = !0,
  13527. i = e
  13528. },
  13529. f: function() {
  13530. try {
  13531. o || null == a.
  13532. return || a.
  13533. return ()
  13534. } finally {
  13535. if (r) throw i
  13536. }
  13537. }
  13538. }
  13539. }
  13540. function pt(e, t) { (null == t || t > e.length) && (t = e.length);
  13541. for (var n = 0,
  13542. a = new Array(t); n < t; n++) a[n] = e[n];
  13543. return a
  13544. }
  13545. var ft = new
  13546. function() {
  13547. var e = c();
  13548. return e.states = {
  13549. UNINIT: "UNINIT",
  13550. INITING: "INITING",
  13551. INITED: "INITED"
  13552. },
  13553. e.state = e.states.UNINIT,
  13554. e.type = null,
  13555. e.lastConnectedAt = null,
  13556. e.lastDisconnectedAt = null,
  13557. e.lastTypeChangedAt = null,
  13558. e.networkChangeTimer = null,
  13559. e._init = function(t, n) {
  13560. if (e.state = e.states.INITING, navigator.connection && navigator.connection.addEventListener) {
  13561. var a = e._getNetworkInfo();
  13562. e.type = a && a.type,
  13563. e.state = e.states.INITED,
  13564. t && t()
  13565. } else e.state = e.states.UNINIT,
  13566. n && n("DO_NOT_SUPPORT")
  13567. },
  13568. e._getNetworkInfo = function() {
  13569. return navigator.connection
  13570. },
  13571. e._reloadNetworkInfo = function() {
  13572. var t = e._getNetworkInfo(),
  13573. n = t && t.type || "UNSUPPORTED",
  13574. a = Date.now();
  13575. if (n !== e.type) {
  13576. e.lastTypeChangedAt = a,
  13577. "none" == n ? e.lastDisconnectedAt = a: "none" == e.type && (e.lastConnectedAt = a),
  13578. e.type = n;
  13579. var i = {
  13580. type: "networkTypeChanged",
  13581. networkType: n
  13582. };
  13583. e.dispatchEvent(i)
  13584. }
  13585. },
  13586. e.getStats = function(t, n) {
  13587. var a = {},
  13588. i = e._getNetworkInfo();
  13589. i && (a.NetworkType = i.type || "UNSUPPORTED"),
  13590. setTimeout((function() {
  13591. t(a)
  13592. }), 0)
  13593. },
  13594. e._init((function() {
  13595. navigator.connection.addEventListener("change", (function() {
  13596. e._reloadNetworkInfo()
  13597. })),
  13598. e.networkChangeTimer = setInterval((function() {
  13599. e._reloadNetworkInfo()
  13600. }), 5e3)
  13601. }), (function(e) {})),
  13602. e
  13603. },
  13604. gt = "DISCONNECTING",
  13605. mt = "DISCONNECTED",
  13606. vt = "CONNECTED",
  13607. St = "INIT",
  13608. Et = [],
  13609. _t = (setInterval((function() {
  13610. Date.now();
  13611. Et.forEach((function(e) {
  13612. for (var t = e.requests.length - 1; t >= 0; t--) {
  13613. var n = e.requests[t];
  13614. n.timeoutCnt++,
  13615. n.timeoutCnt >= 15 && (e.requests.splice(t, 1), n.promises.reject({
  13616. reason: "TIMEOUT",
  13617. code: 499
  13618. }))
  13619. }
  13620. }))
  13621. }), 1e3), 1),
  13622. ht = 1,
  13623. It = 1,
  13624. bt = function() {
  13625. var e = ee()(Z.a.mark((function e(t) {
  13626. var n, a, i, s, c, d, u;
  13627. return Z.a.wrap((function(e) {
  13628. for (;;) switch (e.prev = e.next) {
  13629. case 0:
  13630. return n = t.uid,
  13631. a = t.url,
  13632. i = t.serviceName,
  13633. s = t.sid,
  13634. c = t.appId,
  13635. d = t.cname,
  13636. u = t.timeout,
  13637. e.abrupt("return", new Promise((function(e, t) {
  13638. var l = !1,
  13639. p = new XMLHttpRequest;
  13640. p.open("POST", a, !0),
  13641. p.setRequestHeader("Content-Type", "application/json; charset=utf-8"),
  13642. p.setRequestHeader("X-Packet-Service-Type", "0"),
  13643. p.setRequestHeader("X-Packet-URI", "61"),
  13644. p.onload = function() {
  13645. if (!l) {
  13646. var n = null,
  13647. a = null;
  13648. try {
  13649. n = JSON.parse(p.responseText)
  13650. } catch(e) {
  13651. var i = "Invalid text ".concat(p.responseText);
  13652. return r.
  13653. default.error(i),
  13654. l = !0,
  13655. t(i)
  13656. }
  13657. if (n.code) {
  13658. var o = "AP_ERR_".concat(n.code);
  13659. return r.
  13660. default.error(o, n),
  13661. l = !0,
  13662. t(o)
  13663. }
  13664. try {
  13665. a = JSON.parse(n.json_body || n.json)
  13666. } catch(e) {
  13667. var s = "Invalid json_body ".concat(p.responseText);
  13668. return r.
  13669. default.error(s),
  13670. l = !0,
  13671. t(s)
  13672. }
  13673. if (200 !== a.code) {
  13674. var c = "APPCENTER_CODE_".concat(a.code);
  13675. return r.
  13676. default.error(c, a),
  13677. l = !0,
  13678. t(c)
  13679. }
  13680. if (! (a.servers && a.servers.length > 0)) {
  13681. return r.
  13682. default.error("APPCENTER_EMPTY_SERVER", a),
  13683. l = !0,
  13684. t("APPCENTER_EMPTY_SERVER")
  13685. }
  13686. return l = !0,
  13687. e(a)
  13688. }
  13689. },
  13690. p.onerror = function(e) {
  13691. var n = "AP_REUEST_".concat(e.type);
  13692. r.
  13693. default.error(n, a, e),
  13694. l || (l = !0, t(n))
  13695. },
  13696. p.ontimeout = function(e) {
  13697. r.
  13698. default.error("AP_REUEST_TIMEOUT", a, e),
  13699. l || (l = !0, t("AP_REUEST_TIMEOUT"))
  13700. },
  13701. u && (p.timeout = u),
  13702. p.send(JSON.stringify({
  13703. service_name: i,
  13704. json_body: JSON.stringify({
  13705. command: "convergeAllocateEdge",
  13706. sid: s,
  13707. uid: n + "",
  13708. appId: c,
  13709. ts: Math.floor(Date.now() / 1e3),
  13710. seq: _t++,
  13711. cname: d,
  13712. version: o.VERSION,
  13713. requestId: ht++
  13714. })
  13715. }))
  13716. })));
  13717. case 2:
  13718. case "end":
  13719. return e.stop()
  13720. }
  13721. }), e)
  13722. })));
  13723. return function(t) {
  13724. return e.apply(this, arguments)
  13725. }
  13726. } (),
  13727. Tt = function() {
  13728. var e = ee()(Z.a.mark((function e(t) {
  13729. var n, a, i, s, c, d, u, l, p, f, g, m, v;
  13730. return Z.a.wrap((function(e) {
  13731. for (;;) switch (e.prev = e.next) {
  13732. case 0:
  13733. n = t.serviceName,
  13734. a = t.sid,
  13735. i = t.appId,
  13736. s = t.cname,
  13737. c = t.uid,
  13738. d = t.proxyServer,
  13739. u = null,
  13740. e.t0 = Z.a.keys(Object(o.getParameter)("UAP_AP"));
  13741. case 3:
  13742. if ((e.t1 = e.t0()).done) {
  13743. e.next = 34;
  13744. break
  13745. }
  13746. return l = e.t1.value,
  13747. p = d ? "https://".concat(d, "/ap/?url=").concat(Object(o.getParameter)("UAP_AP")[l], "/api/v1&action=uap") : "https://".concat(Object(o.getParameter)("UAP_AP")[l], "/api/v1?action=uap"),
  13748. f = void 0,
  13749. e.prev = 7,
  13750. e.next = 10,
  13751. bt({
  13752. uid: c,
  13753. url: p,
  13754. appId: i,
  13755. sid: a,
  13756. serviceName: n,
  13757. cname: s,
  13758. timeout: Object(o.getParameter)("HTTP_CONNECT_TIMEOUT")
  13759. });
  13760. case 10:
  13761. f = e.sent,
  13762. e.next = 18;
  13763. break;
  13764. case 13:
  13765. return e.prev = 13,
  13766. e.t2 = e.
  13767. catch(7),
  13768. r.
  13769. default.error(e.t2),
  13770. u = e.t2,
  13771. e.abrupt("continue", 3);
  13772. case 18:
  13773. g = Z.a.mark((function e(t) {
  13774. var a, i, o;
  13775. return Z.a.wrap((function(e) {
  13776. for (;;) switch (e.prev = e.next) {
  13777. case 0:
  13778. if (a = f.servers[t], i = void 0, i = d ? "wss://".concat(d, "/ws/?h=").concat(a.address.replace(/\./g, "-"), ".edge.").concat(t % 2 == 0 ? "agora.io": "agoraio.cn", "&p=").concat(a.wss, "&serviceName=").concat(encodeURIComponent(n)) : "wss://".concat(a.address.replace(/\./g, "-"), ".edge.").concat(t % 2 == 0 ? "agora.io": "agoraio.cn", ":").concat(a.wss, "?serviceName=").concat(encodeURIComponent(n)), a.wss) {
  13779. e.next = 6;
  13780. break
  13781. }
  13782. return r.
  13783. default.error("Invalid server response", a),
  13784. e.abrupt("return", "continue");
  13785. case 6:
  13786. return e.prev = 6,
  13787. e.next = 9,
  13788. new Promise((function(e, t) {
  13789. var n = new WebSocket(i),
  13790. a = !1;
  13791. n.addEventListener("open", (function() {
  13792. a || (a = !0, e(n))
  13793. })),
  13794. n.addEventListener("error", (function(e) {
  13795. a || (a = !0, t(e))
  13796. }))
  13797. }));
  13798. case 9:
  13799. return (o = e.sent).workerToken = f.workerToken,
  13800. e.abrupt("return", {
  13801. v: o
  13802. });
  13803. case 14:
  13804. e.prev = 14,
  13805. e.t0 = e.
  13806. catch(6),
  13807. r.
  13808. default.error(e.t0),
  13809. u = e.t0;
  13810. case 18:
  13811. case "end":
  13812. return e.stop()
  13813. }
  13814. }), e, null, [[6, 14]])
  13815. })),
  13816. m = 0;
  13817. case 20:
  13818. if (! (m < f.servers.length)) {
  13819. e.next = 32;
  13820. break
  13821. }
  13822. return e.delegateYield(g(m), "t3", 22);
  13823. case 22:
  13824. v = e.t3,
  13825. e.t4 = v,
  13826. e.next = "continue" === e.t4 ? 26 : 27;
  13827. break;
  13828. case 26:
  13829. return e.abrupt("continue", 29);
  13830. case 27:
  13831. if ("object" !== be()(v)) {
  13832. e.next = 29;
  13833. break
  13834. }
  13835. return e.abrupt("return", v.v);
  13836. case 29:
  13837. m++,
  13838. e.next = 20;
  13839. break;
  13840. case 32:
  13841. e.next = 3;
  13842. break;
  13843. case 34:
  13844. throw u;
  13845. case 35:
  13846. case "end":
  13847. return e.stop()
  13848. }
  13849. }), e, null, [[7, 13]])
  13850. })));
  13851. return function(t) {
  13852. return e.apply(this, arguments)
  13853. }
  13854. } (),
  13855. Rt = {},
  13856. At = function(e) {
  13857. return Rt[e] ? (Rt[e] += 1, Rt[e]) : (Rt[e] = 1, Rt[e])
  13858. },
  13859. yt = {},
  13860. Ot = function(e) {
  13861. return yt[e] ? (yt[e] += 1, yt[e]) : (yt[e] = 1, yt[e])
  13862. },
  13863. Ct = function(e) {
  13864. var t = e.appId,
  13865. n = e.cname,
  13866. a = e.uid,
  13867. i = e.sid,
  13868. s = c();
  13869. return s.status = St,
  13870. s.pingpongTimer = null,
  13871. s.connection = null,
  13872. s.requests = [],
  13873. s.appId = t,
  13874. s.cname = n,
  13875. s.uid = a,
  13876. s.sid = i,
  13877. s.connection = null,
  13878. s.connectionId = It++,
  13879. s.connect = function() {
  13880. var e = ee()(Z.a.mark((function e(t) {
  13881. var n;
  13882. return Z.a.wrap((function(e) {
  13883. for (;;) switch (e.prev = e.next) {
  13884. case 0:
  13885. if (n = t.wsClient, s.status === St) {
  13886. e.next = 4;
  13887. break
  13888. }
  13889. return r.
  13890. default.debug("Ignored UapConnection.connect: ".concat(s.status)),
  13891. e.abrupt("return");
  13892. case 4:
  13893. s.connection = n,
  13894. s.status = vt,
  13895. s._flush(),
  13896. s.startPingpong(),
  13897. n.addEventListener("close", (function(e) {
  13898. if (console.log("Weboskcet closed", e), n === s.connection) {
  13899. var t = {
  13900. type: "close",
  13901. evt: e
  13902. };
  13903. s.dispatchEvent(t)
  13904. }
  13905. })),
  13906. n.addEventListener("message", (function(e) {
  13907. if (e.data) {
  13908. var t = null;
  13909. try {
  13910. t = JSON.parse(e.data)
  13911. } catch(e) {
  13912. return void r.
  13913. default.error("Invalid data from worker manager", t)
  13914. }
  13915. if (t.requestId) for (var n = s.requests.length - 1; n >= 0; n--) {
  13916. var a = s.requests[n];
  13917. if (a.reqData.requestId === t.requestId) {
  13918. s.requests.splice(n, 1),
  13919. t.code < 400 && t.code >= 200 ? a.promises.resolve(t) : a.promises.reject(t);
  13920. break
  13921. }
  13922. } else t.type = "notification",
  13923. s.dispatchEvent(t)
  13924. }
  13925. }));
  13926. case 10:
  13927. case "end":
  13928. return e.stop()
  13929. }
  13930. }), e)
  13931. })));
  13932. return function(t) {
  13933. return e.apply(this, arguments)
  13934. }
  13935. } (),
  13936. s.disconnect = ee()(Z.a.mark((function e() {
  13937. var t;
  13938. return Z.a.wrap((function(e) {
  13939. for (;;) switch (e.prev = e.next) {
  13940. case 0:
  13941. for (t in s.status = gt, clearInterval(s.pingpongTimer), s.pingpongTimer = null, s.requests) s.requests[t].promises.reject("DISCONNECTED");
  13942. return s.requests = [],
  13943. null,
  13944. s.connection && (s.connection.close(), s.connection = null),
  13945. s.status = mt,
  13946. e.abrupt("return", null);
  13947. case 9:
  13948. case "end":
  13949. return e.stop()
  13950. }
  13951. }), e)
  13952. }))),
  13953. s.request = function() {
  13954. var e = ee()(Z.a.mark((function e(t) {
  13955. var n, a, i, c;
  13956. return Z.a.wrap((function(e) {
  13957. for (;;) switch (e.prev = e.next) {
  13958. case 0:
  13959. if (n = E()({
  13960. command: "request",
  13961. sdkVersion: o.VERSION,
  13962. seq: Ot(s.sid),
  13963. appId: s.appId,
  13964. cname: s.cname,
  13965. uid: "" + s.uid,
  13966. sid: s.sid,
  13967. requestId: At(s.sid),
  13968. ts: Math.floor(Date.now() / 1e3)
  13969. },
  13970. t), "INIT" !== s.status) {
  13971. e.next = 5;
  13972. break
  13973. }
  13974. return e.abrupt("return", new Promise((function(e, t) {
  13975. var a = {
  13976. reqData: n,
  13977. stalledTs: Date.now(),
  13978. timeoutCnt: 0,
  13979. promises: {
  13980. resolve: e,
  13981. reject: t
  13982. }
  13983. };
  13984. s.requests.push(a)
  13985. })));
  13986. case 5:
  13987. if (s.connection) {
  13988. e.next = 11;
  13989. break
  13990. }
  13991. throw a = "NO_WEBSOCKET_CONNECTION",
  13992. r.
  13993. default.error(a),
  13994. new Error(a);
  13995. case 11:
  13996. if (s.status !== gt || t.clientRequest && "DestroyWorker" === t.clientRequest.command) {
  13997. e.next = 17;
  13998. break
  13999. }
  14000. throw i = "WEBSOCKET_DISCONNECTING",
  14001. r.
  14002. default.error(i),
  14003. new Error(i);
  14004. case 17:
  14005. if ("DISCONNECTED" !== s.status) {
  14006. e.next = 23;
  14007. break
  14008. }
  14009. throw c = "WEBSOCKET_DISCONNECTED",
  14010. r.
  14011. default.error(c),
  14012. new Error(c);
  14013. case 23:
  14014. return e.abrupt("return", new Promise((function(e, t) {
  14015. var a = {
  14016. reqData: n,
  14017. stalledTs: Date.now(),
  14018. timeoutCnt: 0,
  14019. promises: {
  14020. resolve: e,
  14021. reject: t
  14022. }
  14023. };
  14024. s.requests.push(a),
  14025. s._flush()
  14026. })));
  14027. case 24:
  14028. case "end":
  14029. return e.stop()
  14030. }
  14031. }), e)
  14032. })));
  14033. return function(t) {
  14034. return e.apply(this, arguments)
  14035. }
  14036. } (),
  14037. s._flush = function() {
  14038. s.connection && s.status === vt && s.requests.forEach((function(e) {
  14039. e.sentTs || (e.sentTs = Date.now(), e.reqData.clientRequest && (e.reqData.clientRequest.workerToken = s.connection.workerToken), s.connection.send(JSON.stringify(e.reqData)))
  14040. }))
  14041. },
  14042. s.startPingpong = function() {
  14043. clearInterval(s.pingpongTimer),
  14044. s.pingpongTimer = setInterval(ee()(Z.a.mark((function e() {
  14045. return Z.a.wrap((function(e) {
  14046. for (;;) switch (e.prev = e.next) {
  14047. case 0:
  14048. if (s.status !== vt || !s.connection || 1 !== s.connection.readyState) {
  14049. e.next = 9;
  14050. break
  14051. }
  14052. return e.prev = 1,
  14053. e.next = 4,
  14054. s.request({
  14055. command: "ping"
  14056. });
  14057. case 4:
  14058. e.next = 9;
  14059. break;
  14060. case 6:
  14061. e.prev = 6,
  14062. e.t0 = e.
  14063. catch(1),
  14064. r.
  14065. default.error("pingpong", e.t0);
  14066. case 9:
  14067. case "end":
  14068. return e.stop()
  14069. }
  14070. }), e, null, [[1, 6]])
  14071. }))), 6e3)
  14072. },
  14073. s._flush(),
  14074. s.startPingpong(),
  14075. Et.push(s),
  14076. s
  14077. },
  14078. Nt = function(e) {
  14079. e.disconnect();
  14080. var t = Et.find((function(t) {
  14081. return e.connectionId === t.connectionId
  14082. }));
  14083. Et.splice(t, 1)
  14084. },
  14085. wt = function(e) {
  14086. return "number" == typeof e && 0 <= e && e <= 4294967295
  14087. };
  14088. var Dt = function(e) {
  14089. var t = e;
  14090. if (Object(o.getParameter)("LIVESTREAMING_ALIGN")) switch (e) {
  14091. case 200:
  14092. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_SUCCESS;
  14093. break;
  14094. case 451:
  14095. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_ALREADY_EXISTS;
  14096. break;
  14097. case 453:
  14098. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_UNAUTHORIZED;
  14099. break;
  14100. case 470:
  14101. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_BROKEN;
  14102. break;
  14103. case 499:
  14104. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_TIMEDOUT;
  14105. break;
  14106. default:
  14107. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_FAILED
  14108. }
  14109. return t
  14110. },
  14111. kt = function(e) {
  14112. var t = e;
  14113. if (Object(o.getParameter)("LIVESTREAMING_ALIGN")) switch (e) {
  14114. case 200:
  14115. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_SUCCESS;
  14116. break;
  14117. case 404:
  14118. case 452:
  14119. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_NOT_FOUND;
  14120. break;
  14121. case 453:
  14122. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_UNAUTHORIZED;
  14123. break;
  14124. case 499:
  14125. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_TIMEDOUT;
  14126. break;
  14127. default:
  14128. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_FAILED
  14129. }
  14130. return t
  14131. },
  14132. Lt = a(28),
  14133. Pt = a.n(Lt),
  14134. Mt = a(16),
  14135. Ut = "host",
  14136. xt = function(e) {
  14137. var t = {
  14138. key: void 0,
  14139. highStream: null,
  14140. lowStream: null,
  14141. lowStreamParameter: null,
  14142. isDualStream: !1,
  14143. highStreamState: 2,
  14144. lowStreamState: 2,
  14145. proxyServer: null,
  14146. turnServers: [],
  14147. useProxyServer: !1
  14148. };
  14149. t.mode = e.mode,
  14150. t.codec = e.codec,
  14151. t.clientId = Object(H.generateSessionId)().slice(0, 5),
  14152. t.uintUid = null,
  14153. t.customReportCount = 0;
  14154. e = E()({},
  14155. e);
  14156. if (t.aespassword = null, t.aesmode = "none", t.hasPublished = !1, t.getSessionId = function() {
  14157. return e.sessionId
  14158. },
  14159. t.startChannelMediaRelay = function(n, a) {
  14160. var i = s.b.reportApiInvoke(e.sessionId, {
  14161. callback: function(e) {
  14162. if (e) return a && a(e);
  14163. a && a()
  14164. },
  14165. name: "Client.startChannelMediaRelay",
  14166. options: arguments,
  14167. tag: "tracer"
  14168. });
  14169. if (! (n instanceof Ce.ChannelMediaRelayConfiguration)) throw "Configration should be instance of [ChannelMediaRelayConfiguration]";
  14170. var o = n.getSrcChannelMediaInfo(),
  14171. r = n.getDestChannelMediaInfos();
  14172. if (Object(z.isEmpty)(o)) throw "srcChannelMediaInfo should not be empty";
  14173. if (Object(z.isEmpty)(r) || 0 === r.length) throw "destChannelMediaInfos should not be empty";
  14174. if (!Object(H.is32Uint)(o.uid)) throw "Invalid uid in srcChannelMediaInfo";
  14175. if (!Object(z.isValidChannelName)(o.channelName)) throw "Invalid channelName in srcChannelMediaInfo";
  14176. if (o.token && !Object(z.isValidToken)(o.token)) throw "Invalid token in srcChannelMediaInfo";
  14177. if (r.forEach((function(e) {
  14178. if (!Object(H.is32Uint)(e.uid)) throw "Invalid uid in destChannelMediaInfo";
  14179. if (!Object(z.isValidChannelName)(e.channelName)) throw "Invalid channelName in destChannelMediaInfo";
  14180. if (e.token && !Object(z.isValidToken)(e.token)) throw "Invalid token in destChannelMediaInfo"
  14181. })), t.gatewayClient.state !== st.CONNECTED) throw "startChannelMediaRelay should be used after join";
  14182. t.gatewayClient.startChannelMediaRelay(n).then((function() {
  14183. i && i()
  14184. })).
  14185. catch((function(e) {
  14186. i && i(e)
  14187. }))
  14188. },
  14189. t.updateChannelMediaRelay = function(n, a) {
  14190. var i = s.b.reportApiInvoke(e.sessionId, {
  14191. callback: function(e) {
  14192. if (e) return a && a(e);
  14193. a && a()
  14194. },
  14195. name: "Client.updateChannelMediaRelay",
  14196. options: arguments,
  14197. tag: "tracer"
  14198. });
  14199. if (! (n instanceof Ce.ChannelMediaRelayConfiguration)) throw "Configration should be instance of [ChannelMediaRelayConfiguration]";
  14200. var o = n.getSrcChannelMediaInfo(),
  14201. r = n.getDestChannelMediaInfos();
  14202. if (Object(z.isEmpty)(o)) throw "srcChannelMediaInfo should not be empty";
  14203. if (Object(z.isEmpty)(r) || 0 === r.length) throw "destChannelMediaInfos should not be empty";
  14204. if (!Object(H.is32Uint)(o.uid)) throw "Invalid uid in srcChannelMediaInfo";
  14205. if (!Object(z.isValidChannelName)(o.channelName)) throw "Invalid channelName in srcChannelMediaInfo";
  14206. if (o.token && !Object(z.isValidToken)(o.token)) throw "Invalid token in srcChannelMediaInfo";
  14207. if (r.forEach((function(e) {
  14208. if (!Object(H.is32Uint)(e.uid)) throw "Invalid uid in destChannelMediaInfo";
  14209. if (!Object(z.isValidChannelName)(e.channelName)) throw "Invalid channelName in destChannelMediaInfo";
  14210. if (e.token && !Object(z.isValidToken)(e.token)) throw "Invalid token in destChannelMediaInfo"
  14211. })), t.gatewayClient.state !== st.CONNECTED) throw "updateChannelMediaRelay should be used after join";
  14212. t.gatewayClient.updateChannelMediaRelay(n).then((function() {
  14213. i && i()
  14214. })).
  14215. catch((function(e) {
  14216. i && i(e)
  14217. }))
  14218. },
  14219. t.stopChannelMediaRelay = function(n) {
  14220. var a = s.b.reportApiInvoke(e.sessionId, {
  14221. callback: function(e) {
  14222. if (e) return n && n(e);
  14223. n && n()
  14224. },
  14225. name: "Client.stopChannelMediaRelay",
  14226. options: arguments,
  14227. tag: "tracer"
  14228. });
  14229. t.gatewayClient.stopChannelMediaRelay().then((function() {
  14230. a && a()
  14231. })).
  14232. catch((function(e) {
  14233. a && a(e)
  14234. }))
  14235. },
  14236. t.getConnectionState = function() {
  14237. var n = s.b.reportApiInvoke(e.sessionId, {
  14238. name: "Client.getConnectionState",
  14239. options: arguments,
  14240. tag: "tracer"
  14241. }),
  14242. a = st.connetionStateMap[t.gatewayClient.state];
  14243. return n(),
  14244. a
  14245. },
  14246. t.setClientRole = function(n, a) {
  14247. var i = s.b.reportApiInvoke(e.sessionId, {
  14248. callback: a,
  14249. name: "Client.setClientRole",
  14250. options: arguments,
  14251. tag: "tracer"
  14252. });
  14253. if (Object(z.checkValidEnum)(n, "setClientRole", [Ut, "audience"]), "rtc" === t.mode) {
  14254. var o = "RTC mode can not use setClientRole";
  14255. return r.
  14256. default.warning("[".concat(t.clientId, "] ").concat(o)),
  14257. i && i(o)
  14258. }
  14259. t.gatewayClient && t.gatewayClient.state === st.CONNECTED ? ("audience" === n && (0 === this.highStreamState ? this._unpublish(this.highStream, (function() {
  14260. i && i(null, {
  14261. role: n
  14262. })
  14263. }), (function(e) {
  14264. i && i(e)
  14265. })) : t.gatewayClient.setClientRole("audience", i)), n === Ut && t.gatewayClient.setClientRole(Ut, i)) : (t.gatewayClient.role = n, i && i(null, {
  14266. role: n
  14267. }))
  14268. },
  14269. t.getGatewayInfo = function(e) {
  14270. if (t.gatewayClient.state !== st.CONNECTED) {
  14271. var n = "Client is not in connected state";
  14272. return r.
  14273. default.error("[".concat(t.clientId, "] ").concat(n)),
  14274. void e(n)
  14275. }
  14276. t.gatewayClient.getGatewayInfo((function(t) {
  14277. e(null, t)
  14278. }), e)
  14279. },
  14280. t.renewToken = function(n, a, i) {
  14281. var o = s.b.reportApiInvoke(e.sessionId, {
  14282. callback: function(e, t) {
  14283. if (e) return r.
  14284. default.error("Failed to renew token ".concat(e), t),
  14285. i && i(e);
  14286. a && a(t)
  14287. },
  14288. name: "Client.renewToken",
  14289. options: arguments,
  14290. tag: "tracer"
  14291. });
  14292. if (!Object(z.isValidToken)(n)) throw new Error("Invalid token: Token is of the string type .Length of the string: [1,255]. ASCII characters only.");
  14293. return t.gatewayClient ? t.key ? (t.key = n, void t.gatewayClient.renewToken(n, (function(e) {
  14294. return o(null, e)
  14295. }), o)) : (r.
  14296. default.error("[".concat(t.clientId, "] renewToken should not be called before user join")), o(I.
  14297. default.INVALID_OPERATION)):
  14298. (r.
  14299. default.error("[".concat(t.clientId, "] renewToken Failed. GatewayClient not Exist")), o(I.
  14300. default.INVALID_OPERATION))
  14301. },
  14302. t.setLowStreamParameter = function(n) {
  14303. var a = s.b.reportApiInvoke(e.sessionId, {
  14304. name: "Client.setLowStreamParameter",
  14305. options: arguments,
  14306. tag: "tracer"
  14307. });
  14308. Object(z.checkValidObject)(n, "param");
  14309. var i = n.width,
  14310. o = n.height,
  14311. c = n.framerate,
  14312. d = n.bitrate;
  14313. Object(z.isEmpty)(i) || Object(z.checkValidNumber)(i, "width"),
  14314. Object(z.isEmpty)(o) || Object(z.checkValidNumber)(o, "height"),
  14315. Object(z.isEmpty)(c) || Object(z.checkValidNumber)(c, "framerate"),
  14316. Object(z.isEmpty)(d) || Object(z.checkValidNumber)(d, "bitrate", 1, 1e7),
  14317. (!i && o || i && !o) && r.
  14318. default.warning("[".concat(t.clientId, "] The width and height parameters take effect only when both are set")),
  14319. t.lowStreamParameter = n,
  14320. a()
  14321. },
  14322. t.init = function(t, n, a) {
  14323. var i = s.b.reportApiInvoke(e.sessionId, {
  14324. callback: function(e, t) {
  14325. if (e) return a && a(e);
  14326. n && n(t)
  14327. },
  14328. name: "Client.init",
  14329. options: arguments,
  14330. tag: "tracer"
  14331. });
  14332. Object(z.checkValidString)(t),
  14333. Object(g.isChromeKernel)() && Object(g.getChromeKernelVersion)() <= 48 ? a ? i(I.
  14334. default.BAD_ENVIRONMENT):
  14335. Object(H.popBanTip)():
  14336. (e.appId = t, e.sessionId = Object(H.generateSessionId)(), i())
  14337. },
  14338. t.setTurnServer = function(n) {
  14339. var a = s.b.reportApiInvoke(e.sessionId, {
  14340. name: "Client.setTurnServer",
  14341. options: arguments,
  14342. tag: "tracer"
  14343. });
  14344. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Set turn server before join channel");
  14345. if (t.useProxyServer) throw new Error("You have already set the proxy");
  14346. n instanceof Array || (n = [n]);
  14347. var i = [];
  14348. n.map((function(e, n) {
  14349. Object(z.checkValidObject)(e, "turnServer");
  14350. var a = e.turnServerURL,
  14351. o = e.username,
  14352. s = e.password,
  14353. c = e.udpport,
  14354. d = e.forceturn,
  14355. u = e.tcpport;
  14356. if (Object(z.checkValidString)(a, "turnServerURL"), Object(z.checkValidString)(o, "username"), Object(z.checkValidString)(s, "password"), Object(z.checkValidString)(c, "udpport"), 0 === parseInt(c)) throw new Error("udpport should not be ".concat(c));
  14357. Object(z.isEmpty)(d) || Object(z.checkValidBoolean)(d, "forceturn");
  14358. var l = {
  14359. mode: "manual"
  14360. };
  14361. if (l.url = a, l.udpport = c, l.username = o, l.credential = s, l.forceturn = d || !1, !Object(z.isEmpty)(u)) {
  14362. if (Object(z.checkValidString)(u, "tcpport"), 0 === parseInt(u)) throw new Error("tcpport should not be ".concat(u));
  14363. l.tcpport = u,
  14364. r.
  14365. default.info("[".concat(t.clientId, "] Set turnserver[").concat(n, "] tcpurl. ").concat(l.url, ":").concat(l.tcpport))
  14366. }
  14367. r.
  14368. default.info("[".concat(t.clientId, "] Set turnserver[").concat(n, "] udpurl. ").concat(l.url, ":").concat(l.udpport, ",username: ").concat(l.username)),
  14369. i.push(l)
  14370. })),
  14371. t.turnServers = i,
  14372. a()
  14373. },
  14374. t.setProxyServer = function(n) {
  14375. var a = s.b.reportApiInvoke(e.sessionId, {
  14376. name: "Client.setProxyServer",
  14377. options: arguments,
  14378. tag: "tracer"
  14379. });
  14380. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Set proxy server before join channel");
  14381. if (!n) throw new Error("Do not set the proxyServer parameter as empty");
  14382. if (t.useProxyServer) throw new Error("You have already set the proxy");
  14383. Object(z.checkValidString)(n, "proxyServer"),
  14384. t.proxyServer = n,
  14385. s.b.setProxyServer(n),
  14386. r.
  14387. default.setProxyServer(n),
  14388. a()
  14389. },
  14390. t.startProxyServer = function(n) {
  14391. var a = s.b.reportApiInvoke(e.sessionId, {
  14392. name: "Client.startProxyServer",
  14393. options: arguments,
  14394. tag: "tracer"
  14395. });
  14396. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Start proxy server before join channel");
  14397. if (t.proxyServer) throw new Error("You have already set the proxy");
  14398. t.useProxyServer = !0,
  14399. t.proxyServerType = n || 1,
  14400. a()
  14401. },
  14402. t.stopProxyServer = function() {
  14403. var n = s.b.reportApiInvoke(e.sessionId, {
  14404. name: "Client.stopProxyServer",
  14405. options: arguments,
  14406. tag: "tracer"
  14407. });
  14408. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Stop proxy server after leave channel");
  14409. s.b.setProxyServer(),
  14410. r.
  14411. default.setProxyServer(),
  14412. t.turnServers = [],
  14413. t.proxyServer = null,
  14414. t.useProxyServer = !1,
  14415. t.proxyServerType = null,
  14416. n()
  14417. },
  14418. t.setEncryptionSecret = function(n) {
  14419. var a = s.b.reportApiInvoke(e.sessionId, {
  14420. name: "Client.setEncryptionSecret",
  14421. options: arguments,
  14422. tag: "tracer"
  14423. });
  14424. Object(z.checkValidString)(n, "password"),
  14425. t.aespassword = n,
  14426. a()
  14427. },
  14428. t.setEncryptionMode = function(n) {
  14429. var a = s.b.reportApiInvoke(e.sessionId, {
  14430. name: "Client.setEncryptionMode",
  14431. options: arguments,
  14432. tag: "tracer"
  14433. });
  14434. if (Object(z.checkValidString)(n, "encryptionMode"), -1 === ke.indexOf(n)) throw new Error('Invalid encryptionMode: encryptionMode should be "aes-128-xts" | "aes-256-xts" | "aes-128-ecb" | "sm4-128-ecb"');
  14435. t.aesmode = n,
  14436. a()
  14437. },
  14438. t.configPublisher = function(n) {
  14439. var a = s.b.reportApiInvoke(e.sessionId, {
  14440. name: "Client.configPublisher",
  14441. options: arguments,
  14442. tag: "tracer"
  14443. });
  14444. Object(z.checkValidObject)(n, "config");
  14445. var i = n.width,
  14446. o = n.height,
  14447. r = n.framerate,
  14448. c = n.bitrate,
  14449. d = n.publisherUrl;
  14450. Object(z.checkValidNumber)(i, "width"),
  14451. Object(z.checkValidNumber)(o, "height"),
  14452. Object(z.checkValidNumber)(r, "framerate"),
  14453. Object(z.checkValidNumber)(c, "bitrate", 1, 1e7),
  14454. d && Object(z.checkValidString)(d, "publisherUrl"),
  14455. t.gatewayClient.configPublisher(n),
  14456. a()
  14457. },
  14458. t.enableDualStream = function(n, a) {
  14459. var i = s.b.reportApiInvoke(e.sessionId, {
  14460. callback: function(e, t) {
  14461. if (e) return a && a(e);
  14462. n && n(t)
  14463. },
  14464. name: "Client.enableDualStream",
  14465. options: arguments,
  14466. tag: "tracer"
  14467. });
  14468. return "iOS" === Object(g.getBrowserOS)() ? (s.b.streamSwitch(e.sessionId, {
  14469. lts: (new Date).getTime(),
  14470. isdual: !0,
  14471. succ: !1
  14472. }), i(I.
  14473. default.IOS_NOT_SUPPORT)):
  14474. Object(g.isWeChatBrowser)() ? (s.b.streamSwitch(e.sessionId, {
  14475. lts: (new Date).getTime(),
  14476. isdual: !0,
  14477. succ: !1
  14478. }), i(I.
  14479. default.WECHAT_NOT_SUPPORT)):
  14480. (s.b.streamSwitch(e.sessionId, {
  14481. lts: (new Date).getTime(),
  14482. isdual: !0,
  14483. succ: !0
  14484. }), t.isDualStream = !0, t.highStream && (t.highStream.isDualStream = !0), void(0 === t.highStreamState ? t._publishLowStream((function(e) {
  14485. return i(null, e)
  14486. }), (function(e) {
  14487. r.
  14488. default.warning("[".concat(t.clientId, "]"), e),
  14489. i(I.
  14490. default.ENABLE_DUALSTREAM_FAILED)
  14491. })):
  14492. 1 === t.highStreamState ? i(I.
  14493. default.STILL_ON_PUBLISHING):
  14494. i(null)))
  14495. },
  14496. t.disableDualStream = function(n, a) {
  14497. var i = s.b.reportApiInvoke(e.sessionId, {
  14498. callback: function(e, t) {
  14499. if (e) return a && a(e);
  14500. n && n(t)
  14501. },
  14502. name: "Client.disableDualStream",
  14503. options: arguments,
  14504. tag: "tracer"
  14505. });
  14506. s.b.streamSwitch(e.sessionId, {
  14507. lts: (new Date).getTime(),
  14508. isdual: !1,
  14509. succ: !0
  14510. }),
  14511. t.isDualStream = !1,
  14512. t.highStream && (t.highStream.isDualStream = !1),
  14513. 0 === t.highStreamState ? t._unpublishLowStream((function() {
  14514. t.highStream.lowStream = null,
  14515. i()
  14516. }), (function(e) {
  14517. r.
  14518. default.warning("[".concat(t.clientId, "]"), e),
  14519. i(I.
  14520. default.DISABLE_DUALSTREAM_FAILED)
  14521. })):
  14522. 1 === t.highStreamState ? i(I.
  14523. default.STILL_ON_PUBLISHING):
  14524. i()
  14525. },
  14526. t._getLowStream = function(e, n) {
  14527. t.lowStream ? e(t.lowStream) : t._createLowStream((function(n) {
  14528. t.lowStream = n,
  14529. e(t.lowStream)
  14530. }), n)
  14531. },
  14532. t._createLowStream = function(e, n) {
  14533. if (t.highStream && t.highStream.stream) {
  14534. var a = E()({},
  14535. t.highStream.params);
  14536. if (a.streamID += 1, a.audio = !1, a.video) if (t.highStream.stream.getVideoTracks()[0]) {
  14537. var i = new ye(a);
  14538. if (i.isLowStream = !0, i.streamId = t.highStream.getId() + 1, t.lowStreamParameter) {
  14539. var o = E()({},
  14540. t.lowStreamParameter);
  14541. o.width && o.height || (o.width = 160, o.height = 120),
  14542. o.framerate = o.framerate || 15,
  14543. o.bitrate = o.bitrate || 50,
  14544. i.setVideoProfileCustomPlus(o)
  14545. } else i.setVideoProfileCustom(function(e) {
  14546. var t;
  14547. switch (e) {
  14548. case "120p":
  14549. case "120p_1":
  14550. t = ["120p_1", "120p_1", "120p_1"];
  14551. break;
  14552. case "120p_3":
  14553. t = ["120p_3", "120p_3", "120p_3"];
  14554. break;
  14555. case "180p":
  14556. case "180p_1":
  14557. t = ["90p_1", "90p_1", "180p_1"];
  14558. break;
  14559. case "180p_3":
  14560. t = ["120p_3", "120p_3", "180p_3"];
  14561. break;
  14562. case "180p_4":
  14563. t = ["120p_1", "120p_1", "180p_4"];
  14564. break;
  14565. case "240p":
  14566. case "240p_1":
  14567. t = ["120p_1", "120p_1", "240p_1"];
  14568. break;
  14569. case "240p_3":
  14570. t = ["120p_3", "120p_3", "240p_3"];
  14571. break;
  14572. case "240p_4":
  14573. t = ["120p_4", "120p_4", "240p_4"];
  14574. break;
  14575. case "360p":
  14576. case "360p_1":
  14577. case "360p_4":
  14578. case "360p_9":
  14579. case "360p_10":
  14580. case "360p_11":
  14581. t = ["90p_1", "90p_1", "360p_1"];
  14582. break;
  14583. case "360p_3":
  14584. case "360p_6":
  14585. t = ["120p_3", "120p_3", "360p_3"];
  14586. break;
  14587. case "360p_7":
  14588. case "360p_8":
  14589. t = ["120p_1", "120p_1", "360p_7"];
  14590. break;
  14591. case "480p":
  14592. case "480p_1":
  14593. case "480p_2":
  14594. case "480p_4":
  14595. case "480p_10":
  14596. t = ["120p_1", "120p_1", "480p_1"];
  14597. break;
  14598. case "480p_3":
  14599. case "480p_6":
  14600. t = ["120p_3", "120p_3", "480p_3"];
  14601. break;
  14602. case "480p_8":
  14603. case "480p_9":
  14604. t = ["120p_4", "120p_4", "480p_8"];
  14605. break;
  14606. case "720p":
  14607. case "720p_1":
  14608. case "720p_2":
  14609. case "720p_3":
  14610. t = ["90p_1", "90p_1", "720p_1"];
  14611. break;
  14612. case "720p_5":
  14613. case "720p_6":
  14614. t = ["120p_1", "120p_1", "720p_5"];
  14615. break;
  14616. case "1080p":
  14617. case "1080p_1":
  14618. case "1080p_2":
  14619. case "1080p_3":
  14620. case "1080p_5":
  14621. t = ["90p_1", "90p_1", "1080p_1"];
  14622. break;
  14623. case "1440p":
  14624. case "1440p_1":
  14625. case "1440p_2":
  14626. t = ["90p_1", "90p_1", "1440p_1"];
  14627. break;
  14628. case "4k":
  14629. case "4k_1":
  14630. case "4k_3":
  14631. t = ["90p_1", "90p_1", "4k_1"];
  14632. break;
  14633. default:
  14634. t = ["120p_1", "120p_1", "360p_7"]
  14635. }
  14636. return Object(g.isOpera)() ? [e, 15, 50] : Object(g.isFireFox)() ? [t[1], 15, 100] : Object(g.isSafari)() ? [t[2], 15, 50] : [t[0], 15, 50]
  14637. } (t.highStream.profile));
  14638. try {
  14639. console.log(i.videoConstraint);
  14640. var r = Pt()(t.highStream, {
  14641. width: i.videoConstraint.width.ideal,
  14642. height: i.videoConstraint.height.ideal,
  14643. framerate: i.videoConstraint.frameRate.max
  14644. });
  14645. return i.stream = r,
  14646. t.highStream.lowStream = i,
  14647. t.highStream.userMuteVideo && i.muteVideo(),
  14648. e && e(i)
  14649. } catch(e) {
  14650. return n && n(e)
  14651. }
  14652. } else n && n(I.
  14653. default.HIGH_STREAM_NOT_VIDEO_TRACE);
  14654. else n && n(I.
  14655. default.HIGH_STREAM_NOT_VIDEO_TRACE)
  14656. } else n && n(I.
  14657. default.HIGH_STREAM_NOT_VIDEO_TRACE)
  14658. },
  14659. t._publishLowStream = function(e, n) {
  14660. return 2 !== t.lowStreamState ? n && n(I.
  14661. default.LOW_STREAM_ALREADY_PUBLISHED):
  14662. t.highStream && t.highStream.hasScreen() ? n && n(I.
  14663. default.SHARING_SCREEN_NOT_SUPPORT):
  14664. void t._getLowStream((function(a) {
  14665. t.lowStreamState = 1,
  14666. t.gatewayClient.publish(a, {
  14667. streamType: 1
  14668. },
  14669. (function() {
  14670. t.lowStreamState = 0,
  14671. e && e()
  14672. }), (function(e) {
  14673. 1 === t.lowStreamState && (t.lowStreamState = 2),
  14674. r.
  14675. default.debug("[".concat(t.clientId, "] publish low stream failed")),
  14676. n && n(e)
  14677. }))
  14678. }), n)
  14679. },
  14680. t._unpublishLowStream = function(e, n) {
  14681. if (0 !== t.lowStreamState) return n && n(I.
  14682. default.LOW_STREAM_NOT_YET_PUBLISHED);
  14683. t.lowStream && (t.gatewayClient.unpublish(t.lowStream, {
  14684. streamType: 1
  14685. },
  14686. (function() {}), (function(e) {
  14687. r.
  14688. default.debug("[".concat(t.clientId, "] unpublish low stream failed")),
  14689. n && n(e)
  14690. })), t.lowStream.close(), t.lowStream = null, t.lowStreamState = 2, e && e())
  14691. },
  14692. t.join = function(n, a, i, o, c) {
  14693. var d = s.b.reportApiInvoke(e.sessionId, {
  14694. callback: function(e, t) {
  14695. if (e) return c && c(e);
  14696. o && o(t)
  14697. },
  14698. name: "Client.join",
  14699. options: arguments,
  14700. tag: "tracer"
  14701. });
  14702. if (n && !Object(z.isValidToken)(n)) return r.
  14703. default.warning("[".concat(t.clientId, "] Param channelKey should be string")),
  14704. d(I.
  14705. default.INVALID_PARAMETER);
  14706. if (!Object(z.isValidChannelName)(a)) return r.
  14707. default.error("Invalid Channel Name ".concat(a)),
  14708. r.
  14709. default.warning("[".concat(t.clientId, "] The length must be within 64 bytes. The supported characters: a-z,A-Z,0-9,space,!, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~, ,")),
  14710. d(I.
  14711. default.INVALID_PARAMETER);
  14712. if ("string" == typeof a && "" === a) return r.
  14713. default.warning("[".concat(t.clientId, "] Param channel should not be empty")),
  14714. d(I.
  14715. default.INVALID_PARAMETER);
  14716. if (i && !Object(H.is32Uint)(i) && !Object(z.isValidString)(i, 1, 255)) return r.
  14717. default.error("Invalid UID ".concat(i, " ").concat(be()(i))),
  14718. r.
  14719. default.warning("[".concat(t.clientId, "] [String uid] Length of the string: [1,255]. ASCII characters only. [Number uid] The value range is [0,10000]")),
  14720. d(I.
  14721. default.INVALID_PARAMETER);
  14722. if ("string" == typeof i && 0 == i.length) return r.
  14723. default.warning("[".concat(t.clientId, "] String uid should not be empty")),
  14724. d(I.
  14725. default.INVALID_PARAMETER);
  14726. if ("string" == typeof i && i.length > 256) return r.
  14727. default.warning("[".concat(t.clientId, "] Length of string uid should be less than 255")),
  14728. d(I.
  14729. default.INVALID_PARAMETER);
  14730. t.highStream = null,
  14731. t.lowStream = null,
  14732. t.lowStreamParameter = null,
  14733. t.isDualStream = !1,
  14734. t.highStreamState = 2,
  14735. t.lowStreamState = 2;
  14736. var u = Date.now(),
  14737. l = setTimeout((function() {
  14738. if (1 != t.gatewayClient.hasJoined) {
  14739. r.
  14740. default.debug("[".concat(t.clientId, "] The time to join the channel is greater than 5 seconds "));
  14741. var n = Date.now();
  14742. s.b.joinChannelTimeOut({
  14743. lts: n,
  14744. sid: e.sessionId,
  14745. cname: a,
  14746. cid: p.cid,
  14747. uid: p.uid || ("string" == typeof i ? void 0 : i),
  14748. elapse: n - u,
  14749. timeout: 5
  14750. })
  14751. }
  14752. }), 5e3),
  14753. p = {
  14754. clientId: t.clientId,
  14755. appId: e.appId,
  14756. sid: e.sessionId,
  14757. cname: a,
  14758. uid: i,
  14759. turnServers: t.turnServers.concat(),
  14760. proxyServer: t.proxyServer,
  14761. token: n || e.appId,
  14762. useProxyServer: t.useProxyServer,
  14763. proxyServerType: t.proxyServerType
  14764. };
  14765. if ("string" == typeof i && (p.stringUid = i, t.uintUid ? (p.uid = t.uintUid, delete t.uintUid) : p.uid = 0), t.aespassword && "none" !== t.aesmode && E()(p, {
  14766. aespassword: t.aespassword,
  14767. aesmode: t.aesmode
  14768. }), s.b.sessionInit(e.sessionId, {
  14769. lts: (new Date).getTime(),
  14770. cname: a,
  14771. appid: e.appId,
  14772. mode: e.mode,
  14773. succ: !0
  14774. }), t.onSuccess = function(e) {
  14775. clearTimeout(l),
  14776. t.rtcStatsCollector.startNetworkQualityTimer(),
  14777. t.onSuccess = null,
  14778. d(null, e)
  14779. },
  14780. t.onFailure = function(e) {
  14781. return d(e)
  14782. },
  14783. t.channel = a, t.gatewayClient.state !== st.DISCONNECTED) return r.
  14784. default.error("[".concat(t.clientId, "] Client already in connecting/connected state")),
  14785. d(I.
  14786. default.INVALID_OPERATION),
  14787. void s.b.joinGateway(e.sessionId, {
  14788. lts: Date.now(),
  14789. succ: !1,
  14790. ec: I.
  14791. default.INVALID_OPERATION,
  14792. addr: null
  14793. });
  14794. t.gatewayClient.state = st.CONNECTING;
  14795. var f = function(i, o) {
  14796. r.
  14797. default.info("[".concat(t.clientId, "] Joining channel: ").concat(a)),
  14798. t.gatewayClient.dispatchEvent({
  14799. type: "config-distribute",
  14800. config: o,
  14801. joinInfo: p
  14802. }),
  14803. t.key = n || e.appId,
  14804. p.cid = i.cid,
  14805. p.uid || (p.uid = i.uid),
  14806. p.vid = i.vid,
  14807. p.clientId = t.clientId,
  14808. p.apResponse = i.res,
  14809. i.uni_lbs_ip && i.uni_lbs_ip[1] && (p.uni_lbs_ip = i.uni_lbs_ip[1]),
  14810. p.gatewayAddr = i.gateway_addr,
  14811. t.joinInfo = p,
  14812. t.gatewayClient.join(p, t.key, (function(e) {
  14813. r.
  14814. default.info("[".concat(t.clientId, "] Join channel ").concat(a, " success, join with uid: ").concat(e, ".")),
  14815. t.onSuccess = null,
  14816. t.rtcStatsCollector.startNetworkQualityTimer(),
  14817. d(null, e)
  14818. }), (function(e) {
  14819. return d(e)
  14820. }))
  14821. };
  14822. p.stringUid && !p.uid ? (t.userAccountReq && !t.userAccountReq.isFinished() && t.userAccountReq.cancel(), t.userAccountReq = Qe(p, t.gatewayClient), t.userAccountReq.then((function(e) {
  14823. r.
  14824. default.debug("getUserAccount Success ".concat(e.url, " ").concat(p.stringUid, " => ").concat(e.uid)),
  14825. p.uid = e.uid,
  14826. ze(p, f, (function(e) {
  14827. return d(e)
  14828. }))
  14829. })).
  14830. catch((function(e) {
  14831. r.
  14832. default.error("getUserAccount rejected", e),
  14833. d(e)
  14834. }))) : ze(p, f, (function(e) {
  14835. return d(e)
  14836. }))
  14837. },
  14838. t.renewChannelKey = function(n, a, i) {
  14839. var o = s.b.reportApiInvoke(e.sessionId, {
  14840. callback: function(e, t) {
  14841. if (e) return i && i(e);
  14842. a && a(t)
  14843. },
  14844. name: "Client.renewChannelKey",
  14845. options: arguments,
  14846. tag: "tracer"
  14847. });
  14848. Object(z.checkValidString)(n, "key", 1, 2047),
  14849. void 0 === t.key ? (r.
  14850. default.error("[".concat(t.clientId, "] renewChannelKey should not be called before user join")), o(I.
  14851. default.INVALID_OPERATION)):
  14852. (t.key = n, t.gatewayClient.joinInfo.token = n, t.gatewayClient.key = n, t.gatewayClient.recover(), o())
  14853. },
  14854. t.leave = function(n, a) {
  14855. t.gatewayClient.isFirstSuccess = !0,
  14856. t.gatewayClient.hasInvokeLeave = !0;
  14857. var i = !1,
  14858. c = s.b.reportApiInvoke(e.sessionId, {
  14859. callback: function(e, i) {
  14860. if (e) return a && a(e);
  14861. t.gatewayClient.reconnectingCS = !1,
  14862. t.gatewayClient.state = st.DISCONNECTED,
  14863. clearTimeout(Ye(t.clientId)),
  14864. t._renewSession(),
  14865. t.rtcStatsCollector.clearNetworkQualityTimer(),
  14866. n && n(i)
  14867. },
  14868. name: "Client.leave",
  14869. options: arguments,
  14870. tag: "tracer"
  14871. });
  14872. r.
  14873. default.info("[".concat(t.clientId, "] Leaving channel")),
  14874. t.userAccountReq && !t.userAccountReq.isFinished() && (t.userAccountReq.cancel(), t.gatewayClient.state === st.CONNECTING && (t.gatewayClient.state = st.DISCONNECTED)),
  14875. t.gatewayClient.leave((function(e) {
  14876. i = !0,
  14877. c(null, e)
  14878. }), c),
  14879. setTimeout((function() {
  14880. i || (t.gatewayClient.socket && (t.gatewayClient.socket.close(), t.gatewayClient.socket = null), t.gatewayClient.state = st.DISCONNECTED, c(null, "LEAVE_MSG_TIMEOUT"))
  14881. }), Object(o.getParameter)("LEAVE_MSG_TIMEOUT"))
  14882. },
  14883. t._renewSession = function() {
  14884. var n = Object(H.generateSessionId)();
  14885. if (r.
  14886. default.debug("renewSession ".concat(e.sessionId, " => ").concat(n)), e.sessionId = n, t.joinInfo && (t.joinInfo.sid = n), t.gatewayClient && (t.gatewayClient.joinInfo && (t.gatewayClient.joinInfo.sid = n), t.gatewayClient.localStreams)) for (var a in t.gatewayClient.localStreams) {
  14887. var i = t.gatewayClient.localStreams[a];
  14888. i && (i.sid = n)
  14889. }
  14890. },
  14891. t._publish = function(n, a, i, s) {
  14892. if (2 !== t.highStreamState) return r.
  14893. default.warning("[".concat(t.clientId, "] Can't publish stream when stream already publish ").concat(n.getId())),
  14894. i && i(I.
  14895. default.STREAM_ALREADY_PUBLISHED);
  14896. if (0 === t.turnServers.length && Object(o.getParameter)("FORCE_TURN") && !Object(o.getParameter)("TURN_ENABLE_TCP") && !Object(o.getParameter)("TURN_ENABLE_UDP")) throw new Error("force TURN With No TURN Configuration");
  14897. r.
  14898. default.info("[".concat(t.clientId, "] Publishing stream, uid ").concat(n.getId())),
  14899. t.highStream = n,
  14900. t.highStreamState = 1,
  14901. t.highStream.streamId = t.joinInfo.stringUid || t.joinInfo.uid,
  14902. t.hasPublished = !1;
  14903. var c = function(n, a, i) {
  14904. t.gatewayClient.publish(n, {
  14905. streamType: 0
  14906. },
  14907. (function() {
  14908. n.sid = e.sessionId,
  14909. t.highStreamState = 0,
  14910. r.
  14911. default.info("[".concat(t.clientId, "] Publish success, uid: ").concat(n.getId())),
  14912. t.highStream && (t.highStream.isDualStream = t.isDualStream),
  14913. t.isDualStream ? t._publishLowStream((function() {
  14914. a && a()
  14915. }), (function(e) {
  14916. r.
  14917. default.warning("[".concat(t.clientId, "] "), e),
  14918. he.replaceWithCanvasTrack(n).then((function() {
  14919. a && a()
  14920. }))
  14921. })) : he.replaceWithCanvasTrack(n).then((function() {
  14922. a && a()
  14923. }))
  14924. }), i)
  14925. };
  14926. "audience" !== t.gatewayClient.role || "live" !== t.mode || s ? c(n, a, i) : t.gatewayClient.setClientRole(Ut, (function(e) {
  14927. if (e) return i && i(e);
  14928. c(n, a, i)
  14929. }))
  14930. },
  14931. t._unpublish = function(e, n, a, i) {
  14932. if (0 !== t.highStreamState) return r.
  14933. default.warning("[".concat(t.clientId, "] Can't unpublish stream when stream not publish")),
  14934. a && a(I.
  14935. default.STREAM_NOT_YET_PUBLISHED);
  14936. r.
  14937. default.info("[".concat(t.clientId, "] Unpublish stream, uid ").concat(e.getId()));
  14938. var o = function(e, n, a) {
  14939. t.isDualStream && t.lowStream && t._unpublishLowStream(null, a),
  14940. t.gatewayClient.unpublish(e, {
  14941. streamType: 0
  14942. },
  14943. (function() {
  14944. t.highStreamState = 2,
  14945. r.
  14946. default.info("[".concat(t.clientId, "] Unpublish stream success, uid: ").concat(e.getId())),
  14947. n && n()
  14948. }), (function(n) {
  14949. r.
  14950. default.info("[".concat(t.clientId, "] Unpublish stream fail, uid: ").concat(e.getId())),
  14951. a && a(n)
  14952. }))
  14953. };
  14954. t.gatewayClient.role !== Ut || "live" !== t.mode || i ? o(e, n, a) : t.gatewayClient.setClientRole("audience", (function(t) {
  14955. if (t) return a && a(t);
  14956. o(e, n, a)
  14957. }))
  14958. },
  14959. t.publish = function(n, a) {
  14960. var i = s.b.reportApiInvoke(e.sessionId, {
  14961. callback: function(e, n) {
  14962. if (e) return 1 === t.highStreamState && (t.highStreamState = 2),
  14963. a && a(e)
  14964. },
  14965. name: "Client.publish",
  14966. tag: "tracer",
  14967. options: {
  14968. stream: "too long to show",
  14969. onFailure: !!a
  14970. }
  14971. });
  14972. 2 === t.highStreamState ? n._hasVideoTracks() || n._hasAudioTracks() ? (t.gatewayClient.publishRequestId = Object(H.generateId)(), t._publish(n, (function(e) {
  14973. return i(null, e)
  14974. }), (function(e) {
  14975. return i(e)
  14976. }))) : i(I.
  14977. default.NO_TRACK_IN_STREAM):
  14978. i(I.
  14979. default.STREAM_ALREADY_PUBLISHED)
  14980. },
  14981. t.unpublish = function(n, a, i) {
  14982. var o = s.b.reportApiInvoke(e.sessionId, {
  14983. callback: function(e, t) {
  14984. if (e) return a && a(e);
  14985. i && i(t)
  14986. },
  14987. name: "Client.unpublish",
  14988. tag: "tracer",
  14989. options: {
  14990. stream: "too long to show",
  14991. onFailure: !!a
  14992. }
  14993. });
  14994. 0 === t.highStreamState ? (t.gatewayClient.publishRequestId = null, t._unpublish(n, (function(e) {
  14995. return o(null, e)
  14996. }), (function(e) {
  14997. return o(e)
  14998. }))) : o(I.
  14999. default.STREAM_NOT_YET_PUBLISHED)
  15000. },
  15001. t.subscribe = function(n, a, i) {
  15002. var o = s.b.reportApiInvoke(e.sessionId, {
  15003. callback: function(e, t) {
  15004. if (e) return i && i(e)
  15005. },
  15006. name: "Client.subscribe",
  15007. tag: "tracer",
  15008. options: {
  15009. stream: "too long to show",
  15010. options: a,
  15011. onFailure: !!i
  15012. }
  15013. });
  15014. "function" == typeof a && (i = a, a = null),
  15015. Object(z.checkValidObject)(n, "stream"),
  15016. Object(z.isEmpty)(a) || (Object(z.checkValidObject)(a, "options"), Object(z.isEmpty)(a.video) || Object(z.checkValidBoolean)(a.video, "options.video"), Object(z.isEmpty)(a.audio) || Object(z.checkValidBoolean)(a.audio, "options.audio"));
  15017. var c = {
  15018. video: !0,
  15019. audio: !0
  15020. };
  15021. if (!Object(z.isEmpty)(a)) {
  15022. if (Object(g.isSafari)() && (!a.video || !a.audio)) {
  15023. var d = "SAFARI_NOT_SUPPORTED_FOR_TRACK_SUBSCRIPTION";
  15024. return r.
  15025. default.error("[".concat(t.clientId, "] "), d),
  15026. void o(d)
  15027. }
  15028. if (!Object(z.isEmpty)(a.video) && !Object(z.isValidBoolean)(a.video) || !Object(z.isEmpty)(a.audio) && !Object(z.isValidBoolean)(a.audio) || !1 === a.audio && !1 === a.video) {
  15029. d = "INVALID_PARAMETER ".concat(JSON.stringify(a));
  15030. return r.
  15031. default.error("[".concat(t.clientId, "] "), d),
  15032. void o(d)
  15033. }
  15034. }
  15035. n.subscribeOptions ? (E()(n.subscribeOptions, c, a), t.gatewayClient.subscribeChange(n, (function(e) {
  15036. return o(null, e)
  15037. }), o)) : (t.gatewayClient.subscribeRequestId.set(n.getId(), Object(H.generateId)()), n.subscribeOptions = E()({},
  15038. c, a), t.gatewayClient.subscribe(n, (function(e) {
  15039. return o(null, e)
  15040. }), o))
  15041. },
  15042. t.unsubscribe = function(n, a) {
  15043. var i = s.b.reportApiInvoke(e.sessionId, {
  15044. callback: function(e, t) {
  15045. if (e) return a && a(e)
  15046. },
  15047. name: "Client.unsubscribe",
  15048. tag: "tracer",
  15049. options: {
  15050. stream: "too long to show",
  15051. onFailure: !!a
  15052. }
  15053. });
  15054. r.
  15055. default.info("[".concat(t.clientId, "] Unsubscribe stream, uid: ").concat(n.getId())),
  15056. t.gatewayClient.subscribeRequestId.delete(n.getId()),
  15057. t.gatewayClient.unsubscribe(n, (function(e) {
  15058. return i(null, e)
  15059. }), i)
  15060. },
  15061. t.setRemoteVideoStreamType = function(n, a) {
  15062. var i = s.b.reportApiInvoke(e.sessionId, {
  15063. name: "Client.setRemoteVideoStreamType",
  15064. tag: "tracer",
  15065. options: {
  15066. stream: "too long to show",
  15067. streamType: a
  15068. }
  15069. });
  15070. Object(z.checkValidEnum)(a, "streamType", [0, 1]),
  15071. t.gatewayClient.setRemoteVideoStreamType(n, a),
  15072. i()
  15073. },
  15074. t.setStreamFallbackOption = function(n, a) {
  15075. var i = s.b.reportApiInvoke(e.sessionId, {
  15076. name: "Client.setStreamFallbackOption",
  15077. tag: "tracer",
  15078. options: {
  15079. stream: "too long to show",
  15080. fallbackType: a
  15081. }
  15082. });
  15083. Object(z.checkValidEnum)(a, "fallbackType", [0, 1, 2]),
  15084. t.gatewayClient.setStreamFallbackOption(n, a),
  15085. i()
  15086. },
  15087. t.enableAudioVolumeIndicator = function(n, a) {
  15088. var i = s.b.reportApiInvoke(e.sessionId, {
  15089. name: "Client.enableAudioVolumeIndicator",
  15090. options: arguments,
  15091. tag: "tracer"
  15092. });
  15093. n = n || 2e3,
  15094. a = a || 3,
  15095. Object(z.checkValidNumber)(a, "smooth", 1, 100),
  15096. Object(z.checkValidNumber)(n, "interval", 50, 1e5),
  15097. t.audioVolumeIndication = t.audioVolumeIndication || {
  15098. enabled: !0
  15099. },
  15100. t.audioVolumeIndication.interval = n,
  15101. t.audioVolumeIndication.smooth = a,
  15102. t.audioVolumeIndication = {
  15103. interval: n,
  15104. smooth: a
  15105. },
  15106. r.
  15107. default.info("[".concat(t.clientId, "] enableAudioVolumeIndicator interval ").concat(n, " smooth ").concat(a)),
  15108. t.gatewayClient.enableAudioVolumeIndicator(n, a),
  15109. i()
  15110. },
  15111. t.getNetworkStats = function(e, n) {
  15112. return r.
  15113. default.deprecate("[".concat(t.clientId, "] client.getNetworkStats is deprecated. Use client.getTransportStats instead.")),
  15114. ft.getStats(e, n)
  15115. },
  15116. t.getSystemStats = function(e, t) {
  15117. return v.getStats(e, t)
  15118. },
  15119. t.getRecordingDevices = function(e, t) {
  15120. return K.getRecordingDevices(e, t)
  15121. },
  15122. t.getPlayoutDevices = function(e, t) {
  15123. return K.getPlayoutDevices(e, t)
  15124. },
  15125. t.getCameras = function(e, t) {
  15126. return K.getCameras(e, t)
  15127. },
  15128. t.getRemoteAudioStats = function(e, n) {
  15129. return t.rtcStatsCollector.getRemoteAudioStats(e, n)
  15130. },
  15131. t.getLocalAudioStats = function(e, n) {
  15132. return t.rtcStatsCollector.getLocalAudioStats(e, n)
  15133. },
  15134. t.getRemoteVideoStats = function(e, n) {
  15135. return t.rtcStatsCollector.getRemoteVideoStats(e, n)
  15136. },
  15137. t.getLocalVideoStats = function(e, n) {
  15138. return t.rtcStatsCollector.getLocalVideoStats(e, n)
  15139. },
  15140. t._getRemoteVideoQualityStats = function(e, n) {
  15141. return t.rtcStatsCollector.getRemoteVideoQualityStats(e, n)
  15142. },
  15143. t._getRemoteAudioQualityStats = function(e, n) {
  15144. return t.rtcStatsCollector.getRemoteAudioQualityStats(e, n)
  15145. },
  15146. t.getTransportStats = function(e, n) {
  15147. return t.rtcStatsCollector.getTransportStats((function(t) {
  15148. return ft.getStats((function(n) {
  15149. var a = E()({},
  15150. t, n);
  15151. e && e(a)
  15152. }), n)
  15153. }), n)
  15154. },
  15155. t.getSessionStats = function(e, n) {
  15156. return t.rtcStatsCollector.getSessionStats(e, n)
  15157. },
  15158. t.onNetworkQuality = function() {
  15159. return t.rtcStatsCollector.onNetworkQuality(onSuccess, onFailure)
  15160. },
  15161. t.sendMetadata = function(n, a) {
  15162. var i = s.b.reportApiInvoke(e.sessionId, {
  15163. name: "Client.sendMetadata",
  15164. tag: "tracer",
  15165. callback: function(e) {
  15166. if (e) return a && a(e);
  15167. a && a()
  15168. }
  15169. });
  15170. t.gatewayClient.sendMetadata(n, i)
  15171. },
  15172. t.sendCustomReportMessage = function(n, a, i, c, d, u) {
  15173. Object(o.getParameter)("CR") ? t.customReportCount > Object(o.getParameter)("CRL") ? u && u("REPORT_LIMITED") : (t.gatewayClient.hasJoined || (r.
  15174. default.WARNING("Should invoke Client.sendCustomReportMessage after join"), u && u("REPORT_BEFORE_JOINED")), t.customReportTimer || (t.customReportTimer = setInterval((function() {
  15175. t.customReportCount = 0
  15176. }), Object(o.getParameter)("CRI"))), Object(z.checkValidString)(n, "reportId", 0, 100, !1), Object(z.checkValidString)(a, "category", 0, 100, !1), Object(z.checkValidString)(i, "event", 0, 100, !1), Object(z.checkValidString)(c, "label", 0, 100, !1), Object(z.checkValidNumber)(d, "value", Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER), t.customReportCount++, s.b.sendCustomReportMessage(e.sessionId, {
  15177. reportId: n,
  15178. category: a,
  15179. event: i,
  15180. label: c,
  15181. value: d,
  15182. lts: Date.now()
  15183. },
  15184. (function(e) {
  15185. e ? u && u("REPORT_FAILED") : u && u()
  15186. }))) : u && u("REPORT_FORBIDDEN")
  15187. },
  15188. e.clientId = t.clientId, t.gatewayClient = st(e), t.listenerLoggerTimer = null, t.listenerLoggerCache = [], t.on = function(e, n) {
  15189. t.gatewayClient.on(e, n),
  15190. t.listenerLoggerCache.push("".concat(e).concat(n.name ? ":" + n.name: "")),
  15191. t.listenerLoggerTimer ? clearTimeout(t.listenerLoggerTimer) : r.
  15192. default.info("[".concat(t.clientId, "] Adding event handler on ").concat(e)),
  15193. t.listenerLoggerTimer = setTimeout((function() {
  15194. t.listenerLoggerCache.length && (t.listenerLoggerTimer = null, r.
  15195. default.info("[".concat(t.clientId, "] Added event handler on ").concat(t.listenerLoggerCache.join(", "))), t.listenerLoggerCache = [])
  15196. }), 0)
  15197. },
  15198. t.off = function(e, n) {
  15199. r.
  15200. default.info("remove event handler from [".concat(e, "]")),
  15201. t.gatewayClient.removeEventListener(e, n)
  15202. },
  15203. t.rtcStatsCollector = function(e) {
  15204. var t = c();
  15205. return t.gatewayClient = e,
  15206. t.exceptionMonitor = new ut(e),
  15207. t.localStats = {},
  15208. t.remoteStats = {},
  15209. t.session = {
  15210. sendBytes: 0,
  15211. recvBytes: 0,
  15212. WSSendBytes: 0,
  15213. WSSendBytesDelta: 0,
  15214. WSRecvBytes: 0,
  15215. WSRecvBytesDelta: 0,
  15216. HTTPSendBytes: 0,
  15217. HTTPSendBytesDelta: 0,
  15218. HTTPRecvBytes: 0,
  15219. HTTPRecvBytesDelta: 0
  15220. },
  15221. t.getRemoteAudioStats = function(e) {
  15222. var n = t.gatewayClient.traffic_stats,
  15223. a = {};
  15224. for (var i in t.remoteStats) {
  15225. var o = {},
  15226. r = t.remoteStats[i];
  15227. if (q(o, "End2EndDelay", r.peer_delay && r.peer_delay.audio_delay), q(o, "TransportDelay", r.peer_delay && r.peer_delay.e2e_delay), q(o, "PacketLossRate", r.peer_delay && r.peer_delay.e2e_audio_lost_ratio_400ms), q(o, "RecvLevel", r.audioStats && r.audioStats.audioOutputLevel), q(o, "RecvBitrate", r.audioRecvBitrate), q(o, "CodecType", r.audioStats && r.audioStats.googCodecName), q(o, "MuteState", r.audioDisabled), q(o, "TotalFreezeTime", r.audioStats && r.audioStats.audioTotalFreezeTime), q(o, "TotalPlayDuration", r.audioStats && r.audioStats.audioTotalPlayDuration), n && n.peer_delay) {
  15228. var s = n.peer_delay.find((function(e) {
  15229. return e.peer_uid == i
  15230. }));
  15231. if (s) {
  15232. var c = s.peer_publish_audio_duration + (Date.now() - n.timestamp);
  15233. q(o, "AudioPublishDuration", c)
  15234. } else q(o, "AudioPublishDuration", -1)
  15235. }
  15236. a[i] = o
  15237. }
  15238. e && e(a)
  15239. },
  15240. t.getLocalAudioStats = function(e) {
  15241. var n = {};
  15242. for (var a in t.localStats) {
  15243. var i = {},
  15244. o = t.localStats[a];
  15245. q(i, "RecordingLevel", o.audioStats && o.audioStats.audioInputLevel),
  15246. q(i, "SendLevel", o.audioStats && o.audioStats.totalAudioEnergy),
  15247. q(i, "SamplingRate", o.audioStats && o.audioStats.totalSamplesDuration),
  15248. q(i, "SendBitrate", o.audioSendBitrate),
  15249. q(i, "CodecType", o.audioStats && o.audioStats.googCodecName),
  15250. q(i, "MuteState", o.audioDisabled),
  15251. q(i, "audioSendPacketsLost", o.audioStats && o.audioStats.packetsLost);
  15252. var r = t.gatewayClient.localStreams[a];
  15253. r && r.isPlaying() && q(i, "MuteState", r.userMuteAudio ? "1": "0"),
  15254. n[a] = i
  15255. }
  15256. e && e(n)
  15257. },
  15258. t.getRemoteVideoStats = function(e) {
  15259. var n = t.gatewayClient.traffic_stats,
  15260. a = {};
  15261. for (var i in t.remoteStats) {
  15262. var o = {},
  15263. r = t.remoteStats[i];
  15264. if (q(o, "End2EndDelay", r.peer_delay && r.peer_delay.video_delay), q(o, "TransportDelay", r.peer_delay && r.peer_delay.e2e_delay), q(o, "PacketLossRate", r.peer_delay && r.peer_delay.e2e_video_lost_ratio_400ms), q(o, "RecvBitrate", r.videoRecvBitrate), q(o, "RecvResolutionWidth", r.videoStats && r.videoStats.googFrameWidthReceived), q(o, "RecvResolutionHeight", r.videoStats && r.videoStats.googFrameHeightReceived), q(o, "RenderResolutionWidth", r.videoStats && r.videoStats.renderRemoteWidth), q(o, "RenderResolutionHeight", r.videoStats && r.videoStats.renderRemoteHeight), q(o, "RenderFrameRate", r.videoStats && r.videoStats.googFrameRateOutput), q(o, "MuteState", r.videoDisabled), q(o, "TotalFreezeTime", r.videoStats && r.videoStats.videoTotalFreezeTime), q(o, "TotalPlayDuration", r.videoStats && r.videoStats.videoTotalPlayDuration), n && n.peer_delay) {
  15265. var s = n.peer_delay.find((function(e) {
  15266. return e.peer_uid == i
  15267. }));
  15268. if (s) {
  15269. var c = s.peer_publish_video_duration + (Date.now() - n.timestamp);
  15270. q(o, "VideoPublishDuration", c)
  15271. } else q(o, "VideoPublishDuration", -1)
  15272. }
  15273. a[i] = o
  15274. }
  15275. e && e(a)
  15276. },
  15277. t.getLocalVideoStats = function(e) {
  15278. var n = {};
  15279. for (var a in t.localStats) {
  15280. var i = {},
  15281. o = t.localStats[a];
  15282. q(i, "TargetSendBitrate", o.videoTargetSendBitrate),
  15283. q(i, "SendFrameRate", o.videoStats && o.videoStats.googFrameRateSent),
  15284. q(i, "SendBitrate", o.videoSendBitrate),
  15285. q(i, "SendResolutionWidth", o.videoStats && o.videoStats.googFrameWidthSent),
  15286. q(i, "SendResolutionHeight", o.videoStats && o.videoStats.googFrameHeightSent),
  15287. q(i, "CaptureResolutionWidth", o.videoStats && o.videoStats.googFrameWidthInput),
  15288. q(i, "CaptureResolutionHeight", o.videoStats && o.videoStats.googFrameHeightInput),
  15289. q(i, "EncodeDelay", o.videoStats && o.videoStats.googAvgEncodeMs),
  15290. q(i, "MuteState", o.videoDisabled),
  15291. q(i, "TotalFreezeTime", o.videoStats && o.videoStats.videoTotalFreezeTime),
  15292. q(i, "TotalDuration", o.videoStats && o.videoStats.videoTotalPlayDuration),
  15293. q(i, "CaptureFrameRate", o.videoStats && o.videoStats.googFrameRateSent),
  15294. q(i, "videoSendPacketsLost", o.videoStats && o.videoStats.packetsLost),
  15295. o.videoStats && !o.videoStats.googFrameWidthInput && q(i, "CaptureResolutionWidth", o.videoStats && o.videoStats.renderLocalWidth),
  15296. o.videoStats && !o.videoStats.googFrameHeightInput && q(i, "CaptureResolutionHeight", o.videoStats && o.videoStats.renderLocalHeight),
  15297. n[a] = i
  15298. }
  15299. e && e(n)
  15300. },
  15301. t.getRemoteVideoQualityStats = function(e) {
  15302. var n = {};
  15303. for (var a in t.remoteStats) {
  15304. var i = {},
  15305. o = t.remoteStats[a];
  15306. q(i, "videoReceiveDelay", o.videoStats && o.videoStats.googCurrentDelayMs),
  15307. q(i, "VideoFreezeRate", o.videoStats && o.videoStats.videoFreezeRate),
  15308. q(i, "FirstFrameTime", o.firstFrameTime),
  15309. n[a] = i
  15310. }
  15311. e && e(n)
  15312. },
  15313. t.getRemoteAudioQualityStats = function(e) {
  15314. var n = {};
  15315. for (var a in t.remoteStats) {
  15316. var i = {},
  15317. o = t.remoteStats[a];
  15318. q(i, "audioReceiveDelay", o.audioStats && o.audioStats.googCurrentDelayMs),
  15319. q(i, "AudioFreezeRate", o.videoStats && o.videoStats.videoFreezeRate),
  15320. n[a] = i
  15321. }
  15322. e && e(n)
  15323. },
  15324. t.getTransportStats = function(e) {
  15325. var n = {},
  15326. a = {},
  15327. i = t.gatewayClient.traffic_stats,
  15328. o = i.peer_delay;
  15329. if (q(n, "OutgoingAvailableBandwidth", t.gatewayClient.OutgoingAvailableBandwidth / 1e3), q(n, "RTT", i && 2 * i.access_delay), o) {
  15330. var r, s = lt(o);
  15331. try {
  15332. for (s.s(); ! (r = s.n()).done;) {
  15333. var c = r.value;
  15334. c.downlink_estimate_bandwidth && (a[c.peer_uid] = c.downlink_estimate_bandwidth / 1e3 + "")
  15335. }
  15336. } catch(e) {
  15337. s.e(e)
  15338. } finally {
  15339. s.f()
  15340. }
  15341. }
  15342. n.IncomingAvailableBandwidth = a,
  15343. e && e(n)
  15344. },
  15345. t.getSessionStats = function(e) {
  15346. var n = {},
  15347. a = t.gatewayClient.traffic_stats,
  15348. i = t.gatewayClient.socket,
  15349. o = 0,
  15350. r = 0;
  15351. for (var s in t.remoteStats) { (c = t.remoteStats[s]) && c.videoStats && c.videoStats.videoRecvBytesDelta && (r += parseInt(c.videoStats.videoRecvBytesDelta)),
  15352. c && c.audioStats && c.audioStats.audioRecvBytesDelta && (r += parseInt(c.audioStats.audioRecvBytesDelta))
  15353. }
  15354. for (var s in t.localStats) {
  15355. var c; (c = t.localStats[s]) && c.videoStats && c.videoStats.videoSendBytesDelta && (o += parseInt(c.videoStats.videoSendBytesDelta)),
  15356. c && c.audioStats && c.audioStats.audioSendBytesDelta && (o += parseInt(c.audioStats.audioSendBytesDelta))
  15357. }
  15358. var d = o + t.session.WSSendBytesDelta + t.session.HTTPSendBytesDelta,
  15359. u = r + t.session.WSRecvBytesDelta + t.session.HTTPRecvBytesDelta,
  15360. l = t.session.sendBytes + Object(Ue.getHTTPSendBytes)(),
  15361. p = t.session.recvBytes + Object(Ue.getHTTPRecvBytes)();
  15362. t.gatewayClient.socket && t.gatewayClient.socket.state === t.gatewayClient.CONNECTED && (l += i.getSendBytes(), p += i.getRecvBytes());
  15363. var f = 1;
  15364. a.peer_delay && (f = a.peer_delay.length, f += 1),
  15365. q(n, "Duration", i.getDuration()),
  15366. q(n, "UserCount", f),
  15367. q(n, "SendBytes", l),
  15368. q(n, "RecvBytes", p),
  15369. q(n, "SendBitrate", 8 * d / 1e3),
  15370. q(n, "RecvBitrate", 8 * u / 1e3),
  15371. e && e(n)
  15372. },
  15373. t.isLocalVideoFreeze = function(e, t) {
  15374. var n = 0,
  15375. a = 0;
  15376. if (!e || !t) return ! 1;
  15377. if (Object(g.isChrome)() || Object(g.isOpera)()) n = e.googFrameRateInput,
  15378. a = e.googFrameRateSent;
  15379. else if (Object(g.isSafari)()) n = parseInt(e.framerateMean),
  15380. a = parseInt(e.framesEncoded) - parseInt(t.framesEncoded);
  15381. else {
  15382. if (!Object(g.isFireFox)()) return ! 1;
  15383. n = parseInt(e.framerateMean),
  15384. a = parseInt(e.framesEncoded) - parseInt(t.framesEncoded)
  15385. }
  15386. return n > 5 && a < 3
  15387. },
  15388. t.isRemoteVideoFreeze = function(e, t) {
  15389. var n = 0,
  15390. a = 0;
  15391. if (!e || !t) return ! 1;
  15392. if (Object(g.isChrome)() || Object(g.isOpera)()) n = e.googFrameRateReceived,
  15393. a = e.googFrameRateDecoded;
  15394. else if (Object(g.isSafari)()) n = e.framerateMean,
  15395. a = parseInt(e.framesDecoded) - parseInt(t.framesDecoded);
  15396. else {
  15397. if (!Object(g.isFireFox)()) return ! 1;
  15398. n = parseInt(e.framesReceived) - parseInt(t.framesReceived),
  15399. a = parseInt(e.framesDecoded) - parseInt(t.framesDecoded)
  15400. }
  15401. return n > 5 && n < 10 && a < 3 || (n > 10 && n < 20 && a < 4 || n > 20 && a < 5)
  15402. },
  15403. t.isAudioFreeze = function(e) {
  15404. if (Object(g.isChrome)() && e) {
  15405. if (e.googDecodingPLC && e.googDecodingPLCCNG && e.googDecodingCTN) return (parseInt(e.googDecodingPLC) + parseInt(e.googDecodingPLCCNG)) / parseInt(e.googDecodingCTN) > .2
  15406. } else if ((Object(g.isSafari)() || Object(g.isFireFox)()) && e.packetsLost && e.packetsReceived) return parseInt(e.packetsLost) / (parseInt(e.packetsLost) + parseInt(e.packetsReceived)) > .2;
  15407. return ! 1
  15408. },
  15409. t.isAudioDecodeFailed = function(e) {
  15410. return !! ((Object(g.isChrome)() || Object(g.isOpera)()) && e && parseInt(e.bytesReceived) > 0 && 0 === parseInt(e.googDecodingNormal))
  15411. },
  15412. t.startNetworkQualityTimer = function() {
  15413. t.clearNetworkQualityTimer(),
  15414. t.networkQualityTimer = setInterval((function() {
  15415. if (t.gatewayClient.state !== st.CONNECTED) t.gatewayClient.dispatchEvent({
  15416. type: "network-quality",
  15417. uplinkNetworkQuality: 0,
  15418. downlinkNetworkQuality: 0
  15419. });
  15420. else {
  15421. var e = t.gatewayClient.traffic_stats;
  15422. t.gatewayClient.dispatchEvent({
  15423. type: "network-quality",
  15424. uplinkNetworkQuality: t.networkQualityTrans(e.uplink_network_quality),
  15425. downlinkNetworkQuality: t.networkQualityTrans(e.downlink_network_quality)
  15426. })
  15427. }
  15428. }), 2e3)
  15429. },
  15430. t.clearNetworkQualityTimer = function() {
  15431. t.networkQualityTimer && clearInterval(t.networkQualityTimer)
  15432. },
  15433. t.networkQualityTrans = function(e) {
  15434. return e >= 0 && e < .17 ? 1 : e >= .17 && e < .36 ? 2 : e >= .36 && e < .59 ? 3 : e >= .59 && e <= 1 ? 4 : e > 1 ? 5 : 0
  15435. },
  15436. t.getStatsTimer = setInterval((function() {
  15437. var e = t.gatewayClient.traffic_stats,
  15438. n = Date.now();
  15439. t.gatewayClient.dispatchEvent({
  15440. type: "_testException"
  15441. }),
  15442. Object.keys(t.localStats).length && t.exceptionMonitor.setLocalStats(t.localStats),
  15443. Object.keys(t.remoteStats).length && t.exceptionMonitor.setRemoteStats(t.remoteStats);
  15444. var a = {};
  15445. Object.keys(t.gatewayClient.remoteStreams).forEach((function(i) {
  15446. var o = t.gatewayClient.remoteStreams[i],
  15447. r = t.remoteStats[i],
  15448. s = {
  15449. id: i,
  15450. updatedAt: n
  15451. };
  15452. a[i] = s,
  15453. s.firstFrameTime = o.firstFrameTime,
  15454. r ? (s.audioTotalPlayDuration = r.audioTotalPlayDuration + 1, s.audioTotalFreezeTime = r.audioTotalFreezeTime, s.isAudioFreeze = !1, s.isAudioDecodeFailed = !1, s.videoTotalPlayDuration = r.videoTotalPlayDuration + 1, s.videoTotalFreezeTime = r.videoTotalFreezeTime, s.isVideoFreeze = !1) : (s.audioTotalPlayDuration = 1, s.audioTotalFreezeTime = 0, s.videoTotalPlayDuration = 1, s.videoTotalFreezeTime = 0);
  15455. var c = e && e.peer_delay && e.peer_delay.find((function(e) {
  15456. return e.peer_uid == i
  15457. }));
  15458. c && (s.peer_delay = c),
  15459. o && (o.isPlaying() && (s.audioDisabled = o.userMuteAudio || o.peerMuteAudio ? "1": "0", s.videoDisabled = o.userMuteVideo || o.peerMuteVideo ? "1": "0"), r && r.peer_delay && c && r.peer_delay.stream_type !== c.stream_type && t.gatewayClient.dispatchEvent({
  15460. type: "streamTypeChange",
  15461. uid: i,
  15462. streamType: c.stream_type
  15463. }), o.pc && "established" == o.pc.state && o.pc.getStats((function(e) {
  15464. if (s.pcStats = e, s.audioStats = e.find((function(e) {
  15465. return "audio" == e.mediaType && (e.id.indexOf("_recv") > -1 || e.id.toLowerCase().indexOf("inbound") > -1)
  15466. })), s.videoStats = e.find((function(e) {
  15467. return "video" == e.mediaType && (e.id.indexOf("_recv") > -1 || e.id.toLowerCase().indexOf("inbound") > -1)
  15468. })), r && r.audioStats && s.audioStats) {
  15469. var n = parseInt(s.audioStats.bytesReceived) - parseInt(r.audioStats.bytesReceived),
  15470. a = parseInt(s.audioStats.googDecodingNormal) - parseInt(r.audioStats.googDecodingNormal);
  15471. if (s.audioStats.audioRecvBytesDelta = n, s.audioStats.audioDecodingNormalDelta = a, t.session.recvBytes += n, isFinite(n) && s.audioStats.timestamp) {
  15472. var i = s.audioStats.timestamp.getTime() - r.audioStats.timestamp.getTime();
  15473. s.audioRecvBitrate = Math.floor(8 * n / i)
  15474. }
  15475. t.isAudioFreeze(s.audioStats) && s.audioTotalPlayDuration > 10 && (s.audioTotalFreezeTime++, s.isAudioFreeze = !0),
  15476. t.isAudioDecodeFailed(s.audioStats) && s.audioTotalPlayDuration > 10 && (s.isAudioDecodeFailed = !0),
  15477. s.audioStats.audioTotalFreezeTime = s.audioTotalFreezeTime,
  15478. s.audioStats.audioTotalPlayDuration = s.audioTotalPlayDuration,
  15479. s.audioStats.audioFreezeRate = Math.ceil(100 * s.audioTotalFreezeTime / s.audioTotalPlayDuration)
  15480. }
  15481. if (r && r.videoStats && s.videoStats) {
  15482. var c = parseInt(s.videoStats.bytesReceived) - parseInt(r.videoStats.bytesReceived);
  15483. if (s.videoStats.videoRecvBytesDelta = c, t.session.recvBytes += c, isFinite(c) && s.videoStats.timestamp) {
  15484. i = s.videoStats.timestamp.getTime() - r.videoStats.timestamp.getTime();
  15485. s.videoRecvBitrate = Math.floor(8 * c / i)
  15486. }
  15487. t.isRemoteVideoFreeze(s.videoStats, r.videoStats) && (s.videoTotalFreezeTime++, s.isVideoFreeze = !0),
  15488. s.videoStats.videoTotalFreezeTime = s.videoTotalFreezeTime,
  15489. s.videoStats.videoTotalPlayDuration = s.videoTotalPlayDuration,
  15490. s.videoStats.videoFreezeRate = Math.ceil(100 * s.videoTotalFreezeTime / s.videoTotalPlayDuration),
  15491. o.player && o.player.video && o.player.video.videoWidth && o.player.video.videoHeight ? (s.videoStats.renderRemoteWidth = o.player.video.videoWidth, s.videoStats.renderRemoteHeight = o.player.video.videoHeight) : (s.videoStats.renderRemoteWidth = o.videoWidth || s.videoStats.googFrameWidthReceived, s.videoStats.renderRemoteHeight = o.videoHeight || s.videoStats.googFrameHeightReceived)
  15492. }
  15493. })))
  15494. })),
  15495. t.remoteStats = a;
  15496. var i = {};
  15497. if (Object.keys(t.gatewayClient.localStreams).forEach((function(e) {
  15498. var a = t.gatewayClient.localStreams[e],
  15499. o = t.localStats[e],
  15500. r = {
  15501. id: e,
  15502. updatedAt: n
  15503. };
  15504. i[e] = r,
  15505. o ? (r.videoTotalPlayDuration = o.videoTotalPlayDuration + 1, r.videoTotalFreezeTime = o.videoTotalFreezeTime, r.isVideoFreeze = !1) : (r.videoTotalPlayDuration = 1, r.videoTotalFreezeTime = 0),
  15506. a && (a.isPlaying() && (r.audioDisabled = a.userMuteAudio ? "1": "0", r.videoDisabled = a.userMuteVideo ? "1": "0"), a.video && a.attributes.maxVideoBW ? r.videoTargetSendBitrate = a.attributes.maxVideoBW: a.video && a.screenAttributes && (r.videoTargetSendBitrate = a.screenAttributes.maxVideoBW), a.pc && "established" == a.pc.state && a.pc.getStats((function(e) {
  15507. if (r.pcStats = e.reverse(), r.audioStats = e.find((function(e) {
  15508. return "audio" == e.mediaType && (e.id.indexOf("_send") > -1 || e.id.toLowerCase().indexOf("outbound") > -1)
  15509. })), r.videoStats = e.find((function(e) {
  15510. return "video" == e.mediaType && (e.id.indexOf("_send") > -1 || e.id.toLowerCase().indexOf("outbound") > -1)
  15511. })), r.audioStats && o && o.audioStats) {
  15512. var n = parseInt(r.audioStats.bytesSent) - parseInt(o.audioStats.bytesSent);
  15513. if (r.audioStats.audioSendBytesDelta = n, t.session.sendBytes += n, isFinite(n) && r.audioStats.timestamp) {
  15514. var i = r.audioStats.timestamp.getTime() - o.audioStats.timestamp.getTime();
  15515. r.audioSendBitrate = Math.floor(8 * n / i)
  15516. }
  15517. }
  15518. if (r.videoStats && o && o.videoStats) {
  15519. var s = parseInt(r.videoStats.bytesSent) - parseInt(o.videoStats.bytesSent);
  15520. if (r.videoStats.videoSendBytesDelta = s, t.session.sendBytes += s, isFinite(s) && r.videoStats.timestamp) {
  15521. i = r.videoStats.timestamp.getTime() - o.videoStats.timestamp.getTime();
  15522. r.videoSendBitrate = Math.floor(8 * s / i)
  15523. }
  15524. t.isLocalVideoFreeze(r.videoStats, o.videoStats) && (r.videoTotalFreezeTime++, r.isVideoFreeze = !0),
  15525. r.videoStats.videoTotalFreezeTime = r.videoTotalFreezeTime,
  15526. r.videoStats.videoTotalPlayDuration = r.videoTotalPlayDuration,
  15527. r.videoStats.videoFreezeRate = Math.ceil(100 * r.videoTotalFreezeTime / r.videoTotalPlayDuration),
  15528. r.videoStats.renderLocalWidth = a.videoWidth || r.videoStats.googFrameWidthSent,
  15529. r.videoStats.renderLocalHeight = a.videoHeight || r.videoStats.googFrameHeightSent
  15530. }
  15531. })))
  15532. })), t.localStats = i, t.session.HTTPSendBytesDelta = Object(Ue.getHTTPSendBytes)() - t.session.HTTPSendBytes, t.session.HTTPSendBytes = Object(Ue.getHTTPSendBytes)(), t.session.HTTPRecvBytesDelta = Object(Ue.getHTTPRecvBytes)() - t.session.HTTPRecvBytes, t.session.HTTPRecvBytes = Object(Ue.getHTTPRecvBytes)(), t.gatewayClient.socket && t.gatewayClient.socket.state === t.gatewayClient.CONNECTED) {
  15533. var o = t.gatewayClient.socket;
  15534. t.session.WSSendBytesDelta = o.getSendBytes() - t.session.WSSendBytes,
  15535. t.session.WSSendBytes = o.getSendBytes(),
  15536. t.session.WSRecvBytesDelta = o.getRecvBytes() - t.session.WSRecvBytes,
  15537. t.session.WSRecvBytes = o.getRecvBytes()
  15538. }
  15539. }), 1e3),
  15540. t.gatewayClient.on("join", (function() {
  15541. t.session = {
  15542. sendBytes: 0,
  15543. recvBytes: 0,
  15544. WSSendBytes: 0,
  15545. WSSendBytesDelta: 0,
  15546. WSRecvBytes: 0,
  15547. WSRecvBytesDelta: 0,
  15548. HTTPSendBytes: 0,
  15549. HTTPSendBytesDelta: 0,
  15550. HTTPRecvBytes: 0,
  15551. HTTPRecvBytesDelta: 0
  15552. }
  15553. })),
  15554. t
  15555. } (t.gatewayClient), t.configDistributManager = function(e) {
  15556. var t = {};
  15557. return t.client = e,
  15558. t.client.gatewayClient && t.client.gatewayClient.on("config-distribute", (function(n) {
  15559. var a = n.joinInfo,
  15560. i = n.config;
  15561. if (i) {
  15562. Object(z.isEmpty)(i.uploadLog) || (Object(o.setParameter)("UPLOAD_LOG", i.uploadLog), s.b.reportApiInvoke(a.sid, {
  15563. name: "_configDistribute",
  15564. options: {
  15565. feature: "uploadLog",
  15566. value: i.uploadLog
  15567. }
  15568. })()),
  15569. Object(z.isEmpty)(i.dualStream) || (e.isDualStream = i.dualStream, s.b.reportApiInvoke(a.sid, {
  15570. name: "_configDistribute",
  15571. options: {
  15572. feature: "dualStream",
  15573. value: i.dualStream
  15574. }
  15575. })()),
  15576. Object(z.isEmpty)(i.streamFallbackOption) || t.client.gatewayClient && t.client.gatewayClient.on("stream-subscribed", (function(e) {
  15577. var n = e.stream;
  15578. n ? (t.client.gatewayClient.setStreamFallbackOption(n, i.streamFallbackOption), s.b.reportApiInvoke(a.sid, {
  15579. name: "_configDistribute",
  15580. options: {
  15581. feature: "streamFallbackOption",
  15582. value: i.streamFallbackOption,
  15583. streamId: n.getId()
  15584. }
  15585. })()) : s.b.reportApiInvoke(a.sid, {
  15586. name: "_configDistribute",
  15587. options: {
  15588. feature: "streamFallbackOption",
  15589. value: i.streamFallbackOption,
  15590. streamId: n.getId(),
  15591. err: "invalid stream"
  15592. }
  15593. })()
  15594. }));
  15595. try {
  15596. r.
  15597. default.debug("[".concat(e.clientId, "] setParameter in distribution: ").concat(JSON.stringify(i))),
  15598. Object.keys(i).map((function(e) {
  15599. return Object(o.setParameter)(e, i[e])
  15600. }))
  15601. } catch(t) {
  15602. r.
  15603. default.debug("[".concat(e.clientId, "] setParameter in distribution failed: ").concat(JSON.stringify(i)))
  15604. }
  15605. }
  15606. })),
  15607. t
  15608. } (t),
  15609. function(e, t) {
  15610. var n = arguments;
  15611. e.liveStreaming = c(),
  15612. e.liveStreaming.connections = {
  15613. inject_streaming: null,
  15614. mix_streaming: null,
  15615. raw_streaming: null
  15616. },
  15617. e.liveStreaming.connectionTypes = {
  15618. inject_streaming: "pull",
  15619. mix_streaming: "push",
  15620. raw_streaming: "push"
  15621. },
  15622. e.liveStreaming.pushStates = {},
  15623. e.liveStreaming.pullStates = {},
  15624. e.gatewayClient.addEventListener("join", (function(t) {
  15625. e.liveStreaming.resumeStates("pull")
  15626. })),
  15627. e.gatewayClient.addEventListener("stream-unpublished", (function(t) {
  15628. if (t.options && 0 === t.options.streamType) for (var n in e.liveStreaming.pushStates) {
  15629. var a = e.liveStreaming.pushStates[n];
  15630. a.url && e._stopLiveStreaming(a.url, a.transcodingEnabled, !0)
  15631. }
  15632. })),
  15633. e.gatewayClient.addEventListener("stream-published", (function(t) {
  15634. e.liveStreaming.resumeStates("push")
  15635. })),
  15636. e.liveStreaming.connect = function() {
  15637. var n = ee()(Z.a.mark((function n(a) {
  15638. var i, o;
  15639. return Z.a.wrap((function(n) {
  15640. for (;;) switch (n.prev = n.next) {
  15641. case 0:
  15642. if (e.joinInfo && e.joinInfo.uid && parseInt(e.joinInfo.vid, 10)) {
  15643. n.next = 3;
  15644. break
  15645. }
  15646. throw "CLIENT_NOT_JOINED",
  15647. new Error("CLIENT_NOT_JOINED");
  15648. case 3:
  15649. return i = new Ct({
  15650. appId: t.appId,
  15651. cname: e.channel,
  15652. sid: t.sessionId,
  15653. uid: e.joinInfo.uid
  15654. }),
  15655. e.liveStreaming.connections[a] = i,
  15656. n.next = 7,
  15657. Tt({
  15658. proxyServer: e.useProxyServer && e.joinInfo && e.joinInfo.proxyServer,
  15659. appId: t.appId,
  15660. cname: e.channel,
  15661. serviceName: a,
  15662. sid: t.sessionId,
  15663. uid: e.joinInfo.uid
  15664. });
  15665. case 7:
  15666. return o = n.sent,
  15667. n.next = 10,
  15668. i.connect({
  15669. wsClient: o
  15670. });
  15671. case 10:
  15672. return i.on("notification", (function(t) {
  15673. if (t.serviceName = a, e.liveStreaming.dispatchEvent(t), 503 === t.code);
  15674. else switch (t.serviceName) {
  15675. case "inject_streaming":
  15676. var n = {
  15677. reason: t && t.reason,
  15678. status: Dt(t && t.code),
  15679. type: "streamInjectedStatus",
  15680. uid: t && t.serverStatus && t.serverStatus.inject_uid,
  15681. url: t && t.serverStatus && t.serverStatus.url
  15682. };
  15683. e.gatewayClient.dispatchEvent(n);
  15684. break;
  15685. case "raw_streaming":
  15686. case "mix_streaming":
  15687. var i = {
  15688. reason: t && t.reason,
  15689. status: t && t.code,
  15690. type: t && 200 === t.code ? "liveStreamingStarted": "liveStreamingFailed",
  15691. uid: t && t.serverStatus && t.uid,
  15692. url: t && t.serverStatus && t.serverStatus.url
  15693. };
  15694. e.gatewayClient.dispatchEvent(i)
  15695. }
  15696. })),
  15697. i.on("close", (function(t) {
  15698. Nt(i),
  15699. r.
  15700. default.debug("Reconnect ".concat(a)),
  15701. e.liveStreaming.connect(a).
  15702. catch((function(t) {
  15703. e.liveStreaming.connections[a] = null,
  15704. e.gatewayClient.dispatchEvent({
  15705. type: "".concat(a.replace("_", "-"), "-disconnected")
  15706. })
  15707. }))
  15708. })),
  15709. r.
  15710. default.debug("".concat(a, " connected")),
  15711. n.abrupt("return", i);
  15712. case 14:
  15713. case "end":
  15714. return n.stop()
  15715. }
  15716. }), n)
  15717. })));
  15718. return function(e) {
  15719. return n.apply(this, arguments)
  15720. }
  15721. } (),
  15722. e.liveStreaming.disconnect = function() {
  15723. var t = ee()(Z.a.mark((function t(n) {
  15724. var a, i;
  15725. return Z.a.wrap((function(t) {
  15726. for (;;) switch (t.prev = t.next) {
  15727. case 0:
  15728. t.t0 = Z.a.keys(e.liveStreaming.connections);
  15729. case 1:
  15730. if ((t.t1 = t.t0()).done) {
  15731. t.next = 13;
  15732. break
  15733. }
  15734. if (a = t.t1.value, !e.liveStreaming.connections.hasOwnProperty(a)) {
  15735. t.next = 11;
  15736. break
  15737. }
  15738. if (! (i = e.liveStreaming.connections[a]) || n && n !== a) {
  15739. t.next = 11;
  15740. break
  15741. }
  15742. return r.
  15743. default.info("Disconnecting liveStreaming ".concat(a)),
  15744. t.next = 9,
  15745. i.disconnect();
  15746. case 9:
  15747. t.sent,
  15748. e.liveStreaming.connections[a] = null;
  15749. case 11:
  15750. t.next = 1;
  15751. break;
  15752. case 13:
  15753. case "end":
  15754. return t.stop()
  15755. }
  15756. }), t)
  15757. })));
  15758. return function(e) {
  15759. return t.apply(this, arguments)
  15760. }
  15761. } (),
  15762. e.liveStreaming.resumeStates = function() {
  15763. var t = ee()(Z.a.mark((function t(n) {
  15764. var a, i, o, s, c, d, u, l;
  15765. return Z.a.wrap((function(t) {
  15766. for (;;) switch (t.prev = t.next) {
  15767. case 0:
  15768. t.t0 = Z.a.keys(e.liveStreaming.connections);
  15769. case 1:
  15770. if ((t.t1 = t.t0()).done) {
  15771. t.next = 8;
  15772. break
  15773. }
  15774. if (a = t.t1.value, !n || e.liveStreaming.connectionTypes[a] === n) {
  15775. t.next = 5;
  15776. break
  15777. }
  15778. return t.abrupt("continue", 1);
  15779. case 5:
  15780. e.liveStreaming.connections.hasOwnProperty(a) && (i = e.liveStreaming.connections[a]) && (r.
  15781. default.info("LiveStreaming closing connection ".concat(a)), i.disconnect(), e.liveStreaming.connections[a] = null),
  15782. t.next = 1;
  15783. break;
  15784. case 8:
  15785. t.t2 = Z.a.keys(e.liveStreaming.pushStates);
  15786. case 9:
  15787. if ((t.t3 = t.t2()).done) {
  15788. t.next = 37;
  15789. break
  15790. }
  15791. if (o = t.t3.value, !n || "push" === n) {
  15792. t.next = 13;
  15793. break
  15794. }
  15795. return t.abrupt("continue", 9);
  15796. case 13:
  15797. if (!e.liveStreaming.pushStates.hasOwnProperty(o)) {
  15798. t.next = 35;
  15799. break
  15800. }
  15801. if (s = e.liveStreaming.pushStates[o], "audience" !== e.gatewayClient.role) {
  15802. t.next = 19;
  15803. break
  15804. }
  15805. r.
  15806. default.warning("Cannot resume LiveStreaming in audience mode. ".concat(s.url), s),
  15807. t.next = 35;
  15808. break;
  15809. case 19:
  15810. if (!s) {
  15811. t.next = 35;
  15812. break
  15813. }
  15814. return r.
  15815. default.debug("Resuming LiveStreaming ".concat(s.url), s),
  15816. t.prev = 21,
  15817. t.next = 24,
  15818. e._startLiveStreaming(s.url, s.transcodingEnabled);
  15819. case 24:
  15820. c = t.sent,
  15821. r.
  15822. default.debug("Resumed LiveStreaming ".concat(s.url, ": ").concat(c.reason)),
  15823. t.next = 35;
  15824. break;
  15825. case 28:
  15826. if (t.prev = 28, t.t4 = t.
  15827. catch(21), 454 !== t.t4.code) {
  15828. t.next = 34;
  15829. break
  15830. }
  15831. r.
  15832. default.debug("Resumed LiveStreaming ".concat(s.url, ": ").concat(t.t4.reason)),
  15833. t.next = 35;
  15834. break;
  15835. case 34:
  15836. throw t.t4;
  15837. case 35:
  15838. t.next = 9;
  15839. break;
  15840. case 37:
  15841. t.t5 = Z.a.keys(e.liveStreaming.pullStates);
  15842. case 38:
  15843. if ((t.t6 = t.t5()).done) {
  15844. t.next = 62;
  15845. break
  15846. }
  15847. if (d = t.t6.value, !n || "pull" === n) {
  15848. t.next = 42;
  15849. break
  15850. }
  15851. return t.abrupt("continue", 38);
  15852. case 42:
  15853. if (!e.liveStreaming.pullStates.hasOwnProperty(d)) {
  15854. t.next = 60;
  15855. break
  15856. }
  15857. if (u = e.liveStreaming.pullStates[d], "audience" !== e.gatewayClient.role) {
  15858. t.next = 48;
  15859. break
  15860. }
  15861. r.
  15862. default.warning("Cannot resume addInjectStreamUrl in audience mode. ".concat(u.url), u),
  15863. t.next = 60;
  15864. break;
  15865. case 48:
  15866. if (!u) {
  15867. t.next = 60;
  15868. break
  15869. }
  15870. return r.
  15871. default.debug("Resuming LiveStreaming pullStream ".concat(u.url), u),
  15872. t.prev = 50,
  15873. t.next = 53,
  15874. e._addInjectStreamUrl(u.url, u.transcodingConfig);
  15875. case 53:
  15876. l = t.sent,
  15877. r.
  15878. default.debug("Resumed LiveStreaming pullStream ".concat(u.url, ": ").concat(l.reason)),
  15879. t.next = 60;
  15880. break;
  15881. case 57:
  15882. t.prev = 57,
  15883. t.t7 = t.
  15884. catch(50),
  15885. 451 === t.t7.code && r.
  15886. default.debug("Resumed LiveStreaming pullStream ".concat(u.url, ": ").concat(t.t7.reason));
  15887. case 60:
  15888. t.next = 38;
  15889. break;
  15890. case 62:
  15891. case "end":
  15892. return t.stop()
  15893. }
  15894. }), t, null, [[21, 28], [50, 57]])
  15895. })));
  15896. return function(e) {
  15897. return t.apply(this, arguments)
  15898. }
  15899. } (),
  15900. e.liveStreaming.startOptions = {
  15901. autoDestroyTime: 30
  15902. },
  15903. e.liveStreaming.transcodingConfig = {
  15904. audioBitrate: 48,
  15905. audioChannels: 1,
  15906. audioSampleRate: 48e3,
  15907. backgroundColor: 0,
  15908. height: 360,
  15909. images: [],
  15910. lowLatency: !1,
  15911. metadata: "",
  15912. userConfigExtraInfo: "",
  15913. userConfigs: [],
  15914. videoBitrate: 400,
  15915. videoCodecProfile: 100,
  15916. videoCodecType: 1,
  15917. videoFramerate: 15,
  15918. videoGop: 30,
  15919. width: 640
  15920. },
  15921. e.startLiveStreaming = function(n, a) {
  15922. Object(z.isEmpty)(a) || Object(z.checkValidBoolean)(a, "transcodingEnabled"),
  15923. Object(z.checkValidString)(n, "url", 1, 1024);
  15924. var i = s.b.reportApiInvoke(t.sessionId, {
  15925. name: "Client.startLiveStreaming",
  15926. options: arguments,
  15927. tag: "tracer"
  15928. });
  15929. if (e.gatewayClient && "audience" === e.gatewayClient.role) {
  15930. var o = {
  15931. code: 403,
  15932. reason: "AUDIENCE_STREAMING_FORBIDDEN"
  15933. };
  15934. throw i(o),
  15935. o
  15936. }
  15937. var r = e._startLiveStreaming(n, a);
  15938. return r.then((function(e) {
  15939. i(null, e)
  15940. })).
  15941. catch((function(e) {
  15942. i(e)
  15943. })),
  15944. r
  15945. },
  15946. e._startLiveStreaming = function() {
  15947. var n = ee()(Z.a.mark((function n(a, i) {
  15948. var o, s, c, d;
  15949. return Z.a.wrap((function(n) {
  15950. for (;;) switch (n.prev = n.next) {
  15951. case 0:
  15952. return o = E()({
  15953. allocate: !0,
  15954. clientRequest: {
  15955. command: "PublishStream"
  15956. },
  15957. command: "request"
  15958. }),
  15959. r.
  15960. default.debug("startLiveStreaming ".concat(a, ", ").concat(i)),
  15961. E()(o.clientRequest, e.liveStreaming.startOptions, {
  15962. ts: Date.now(),
  15963. url: a,
  15964. vid: parseInt(e.joinInfo.vid, 10)
  15965. }),
  15966. s = null,
  15967. i ? (e.liveStreaming.connections.mix_streaming || e.liveStreaming.connect("mix_streaming"), o.clientRequest.transcodingConfig = JSON.parse(JSON.stringify(e.liveStreaming.transcodingConfig)), s = e.liveStreaming.connections.mix_streaming) : ("vp8" === t.codec && r.
  15968. default.warning("VP8 is not supported by raw_streaming. Subscriber side will suffer"), "rtc" === t.mode && r.
  15969. default.warning("RTC mode is not supported by raw_streaming. Subscriber side will suffer"), e.liveStreaming.connections.raw_streaming || e.liveStreaming.connect("raw_streaming"), s = e.liveStreaming.connections.raw_streaming),
  15970. c = null,
  15971. d = {},
  15972. n.prev = 7,
  15973. n.next = 10,
  15974. s.request(o);
  15975. case 10:
  15976. c = n.sent,
  15977. d.type = "liveStreamingStarted",
  15978. d.reason = c && c.reason,
  15979. d.status = c && c.code,
  15980. d.url = c && c.serverResponse && c.serverResponse.url,
  15981. e.gatewayClient.dispatchEvent(d),
  15982. n.next = 26;
  15983. break;
  15984. case 18:
  15985. throw n.prev = 18,
  15986. n.t0 = n.
  15987. catch(7),
  15988. d.type = "liveStreamingFailed",
  15989. d.reason = n.t0 && n.t0.reason,
  15990. d.status = n.t0 && n.t0.code,
  15991. d.url = n.t0 && n.t0.serverResponse && n.t0.serverResponse.url,
  15992. e.gatewayClient.dispatchEvent(d),
  15993. n.t0;
  15994. case 26:
  15995. return e.liveStreaming.pushStates[a] = {
  15996. transcodingEnabled: i,
  15997. url: a
  15998. },
  15999. n.abrupt("return", c);
  16000. case 28:
  16001. case "end":
  16002. return n.stop()
  16003. }
  16004. }), n, null, [[7, 18]])
  16005. })));
  16006. return function(e, t) {
  16007. return n.apply(this, arguments)
  16008. }
  16009. } (),
  16010. e.setLiveTranscoding = function(n, a) {
  16011. r.
  16012. default.debug("setLiveTranscoding: ".concat(JSON.stringify(n))),
  16013. Object(z.checkValidObject)(n, "transcoding");
  16014. var i = n,
  16015. o = i.width,
  16016. c = i.height,
  16017. d = i.videoBitrate,
  16018. u = i.videoFramerate,
  16019. l = i.lowLatency,
  16020. p = i.audioSampleRate,
  16021. f = i.audioBitrate,
  16022. g = i.audioChannels,
  16023. m = i.videoGop,
  16024. v = i.images,
  16025. S = i.videoCodecProfile,
  16026. E = i.userCount,
  16027. _ = i.backgroundColor,
  16028. h = i.transcodingUsers;
  16029. if (h || (h = n.userConfigs), Object(z.isEmpty)(o) || Object(z.checkValidNumber)(o, "width"), Object(z.isEmpty)(c) || Object(z.checkValidNumber)(c, "height"), Object(z.isEmpty)(d) || Object(z.checkValidNumber)(d, "videoBitrate", 1, 1e6), Object(z.isEmpty)(u) || Object(z.checkValidNumber)(u, "videoFramerate"), Object(z.isEmpty)(l) || Object(z.checkValidBoolean)(l, "lowLatency"), Object(z.isEmpty)(p) || Object(z.checkValidEnum)(p, "audioSampleRate", [32e3, 44100, 48e3]), Object(z.isEmpty)(f) || Object(z.checkValidNumber)(f, "audioBitrate", 1, 128), Object(z.isEmpty)(g) || Object(z.checkValidEnum)(g, "audioChannels", [1, 2, 3, 4, 5]), Object(z.isEmpty)(m) || Object(z.checkValidNumber)(m, "videoGop"), Object(z.isEmpty)(S) || Object(z.checkValidEnum)(S, "videoCodecProfile", [66, 77, 100]), Object(z.isEmpty)(E) || Object(z.checkValidNumber)(E, "userCount", 0, 17), Object(z.isEmpty)(_) || Object(z.checkValidNumber)(_, "backgroundColor", 0, 16777215), !Object(z.isEmpty)(h)) {
  16030. if (!Object(z.isArray)(h)) throw new Error("[transcodingUsers]: transcodingUsers should be Array");
  16031. if (h.length > 17) throw new Error("The length of transcodingUsers cannot greater than 17");
  16032. h.map((function(e, t) {
  16033. if (!Object(z.isEmpty)(e.uid) && !wt(e.uid) && !Object(z.isValidString)(e.uid, 1, 255)) throw new Error("[String uid] Length of the string: [1,255]. ASCII characters only. [Number uid] The value range is [0,10000]");
  16034. if (Object(z.isEmpty)(e.x) ? e.x = 0 : Object(z.checkValidNumber)(e.x, "transcodingUser[".concat(t, "].x"), 0, 1e4), Object(z.isEmpty)(e.y) ? e.y = 0 : Object(z.checkValidNumber)(e.y, "transcodingUser[".concat(t, "].y"), 0, 1e4), Object(z.isEmpty)(e.width) ? e.width = 640 : Object(z.checkValidNumber)(e.width, "transcodingUser[".concat(t, "].width"), 0, 1e4), Object(z.isEmpty)(e.height) ? e.height = 360 : Object(z.checkValidNumber)(e.height, "transcodingUser[".concat(t, "].height"), 0, 1e4), Object(z.isEmpty)(e.zOrder) ? e.zOrder = 0 : Object(z.checkValidNumber)(e.zOrder, "transcodingUser[".concat(t, "].zOrder"), 0, 100), Object(z.isEmpty)(e.alpha)) e.alpha = 1;
  16035. else if (! (Object(z.isNumber)(e.alpha) && e.alpha <= 1 && e.alpha >= 0)) throw new Error("transcodingUser[${index}].alpha: The value range is [0, 1]")
  16036. }))
  16037. }
  16038. if (!Object(z.isEmpty)(v)) {
  16039. if (!Object(z.isArray)(v)) throw new Error("[images]: images should be Array");
  16040. v.map((function(e, t) {
  16041. if (Object(z.checkValidString)(e.url, "images[".concat(t, "].url"), 1, 1024), Object(z.isEmpty)(e.x) ? e.x = 0 : Object(z.checkValidNumber)(e.x, "images[".concat(t, "].x"), 0, 1e4), Object(z.isEmpty)(e.y) ? e.y = 0 : Object(z.checkValidNumber)(e.y, "images[".concat(t, "].y"), 0, 1e4), Object(z.isEmpty)(e.width) ? e.width = 160 : Object(z.checkValidNumber)(e.width, "images[".concat(t, "].width"), 0, 1e4), Object(z.isEmpty)(e.height) ? e.height = 160 : Object(z.checkValidNumber)(e.height, "images[".concat(t, "].height"), 0, 1e4), Object(z.isEmpty)(e.zOrder) ? e.zOrder = 0 : Object(z.checkValidNumber)(e.zOrder, "images[".concat(t, "].zOrder"), 0, 100), Object(z.isEmpty)(e.alpha)) e.alpha = 1;
  16042. else if (! (Object(z.isNumber)(e.alpha) && e.alpha <= 1 && e.alpha >= 0)) throw new Error("image[${index}].alpha: The value range is [0, 1]")
  16043. }))
  16044. }
  16045. var I = s.b.reportApiInvoke(t.sessionId, {
  16046. name: "Client.setLiveTranscoding",
  16047. options: arguments,
  16048. tag: "tracer"
  16049. });
  16050. if ((n = JSON.parse(JSON.stringify(n))).transcodingUsers && (n.userConfigs = n.transcodingUsers, delete n.transcodingUsers), e.joinInfo.stringUid && n.userConfigs && n.userConfigs.length) {
  16051. var b = [];
  16052. n.userConfigs.forEach((function(t) {
  16053. b.push(Qe(e.joinInfo, e.gatewayClient, t.uid).then((function(e) {
  16054. t.uid = e.uid
  16055. })))
  16056. }));
  16057. var T = Promise.all(b).then((function() {
  16058. return e._setLiveTranscoding(n, a)
  16059. }));
  16060. return T.then((function(e) {
  16061. I(null, e)
  16062. })).
  16063. catch((function(e) {
  16064. I(e)
  16065. })),
  16066. T
  16067. }
  16068. var R = e._setLiveTranscoding(n, a);
  16069. return R.then((function(e) {
  16070. I(null, e)
  16071. })).
  16072. catch((function(e) {
  16073. I(e)
  16074. })),
  16075. R
  16076. },
  16077. e._setLiveTranscoding = function() {
  16078. var t = ee()(Z.a.mark((function t(n, a) {
  16079. var i, o, r;
  16080. return Z.a.wrap((function(t) {
  16081. for (;;) switch (t.prev = t.next) {
  16082. case 0:
  16083. if (e.liveStreaming.transcodingConfig = E()(e.liveStreaming.transcodingConfig, n), "boolean" != typeof a && (a = !!e.liveStreaming.connections.mix_streaming), i = JSON.parse(JSON.stringify({
  16084. allocate: !1,
  16085. clientRequest: {
  16086. command: "UpdateTranscoding",
  16087. transcodingConfig: e.liveStreaming.transcodingConfig
  16088. },
  16089. command: "request"
  16090. })), o = {},
  16091. !a) {
  16092. t.next = 16;
  16093. break
  16094. }
  16095. return e.liveStreaming.connections.mix_streaming || e.liveStreaming.connect("mix_streaming"),
  16096. t.next = 8,
  16097. e.liveStreaming.connections.mix_streaming.request(i);
  16098. case 8:
  16099. return r = t.sent,
  16100. o.type = "liveTranscodingUpdated",
  16101. o.reason = r.reason,
  16102. o.status = r.code,
  16103. e.gatewayClient.dispatchEvent(o),
  16104. t.abrupt("return", r);
  16105. case 16:
  16106. return t.abrupt("return", {
  16107. code: 200,
  16108. reason: "success"
  16109. });
  16110. case 17:
  16111. case "end":
  16112. return t.stop()
  16113. }
  16114. }), t)
  16115. })));
  16116. return function(e, n) {
  16117. return t.apply(this, arguments)
  16118. }
  16119. } (),
  16120. e.stopLiveStreaming = function(n, a) {
  16121. Object(z.checkValidString)(n, "url", 1, 1024);
  16122. var i = s.b.reportApiInvoke(t.sessionId, {
  16123. name: "Client.stopLiveStreaming",
  16124. options: arguments,
  16125. tag: "tracer"
  16126. }),
  16127. o = e._stopLiveStreaming(n, a);
  16128. return o.then((function(e) {
  16129. i(null, e)
  16130. })).
  16131. catch((function(e) {
  16132. i(e)
  16133. })),
  16134. o
  16135. },
  16136. e._stopLiveStreaming = function() {
  16137. var t = ee()(Z.a.mark((function t(n, a, i) {
  16138. var o, r, s, c, d, u;
  16139. return Z.a.wrap((function(t) {
  16140. for (;;) switch (t.prev = t.next) {
  16141. case 0:
  16142. return o = null,
  16143. r = e.liveStreaming.pushStates[n],
  16144. o = r ? r.transcodingEnabled ? "mix_streaming": "raw_streaming": a ? "mix_streaming": "raw_streaming",
  16145. s = {
  16146. allocate: !1,
  16147. clientRequest: {
  16148. command: "UnpublishStream",
  16149. url: n
  16150. },
  16151. command: "request"
  16152. },
  16153. e.liveStreaming.connections[o] || e.liveStreaming.connect(o),
  16154. c = null,
  16155. t.prev = 6,
  16156. t.next = 9,
  16157. e.liveStreaming.connections[o].request(s);
  16158. case 9:
  16159. c = t.sent,
  16160. (d = {}).type = "liveStreamingStopped",
  16161. d.reason = c && c.reason,
  16162. d.status = c && c.code,
  16163. d.url = c && c.serverResponse && c.serverResponse.url,
  16164. e.gatewayClient.dispatchEvent(d),
  16165. t.next = 27;
  16166. break;
  16167. case 18:
  16168. throw t.prev = 18,
  16169. t.t0 = t.
  16170. catch(6),
  16171. (u = {}).type = "liveStreamingStopped",
  16172. u.reason = t.t0 && t.t0.reason,
  16173. u.status = t.t0 && t.t0.code,
  16174. u.url = t.t0 && t.t0.serverResponse && t.t0.serverResponse.url,
  16175. e.gatewayClient.dispatchEvent(u),
  16176. t.t0;
  16177. case 27:
  16178. return i || delete e.liveStreaming.pushStates[n],
  16179. t.abrupt("return", c);
  16180. case 29:
  16181. case "end":
  16182. return t.stop()
  16183. }
  16184. }), t, null, [[6, 18]])
  16185. })));
  16186. return function(e, n, a) {
  16187. return t.apply(this, arguments)
  16188. }
  16189. } (),
  16190. e.liveStreaming.injectStreamTranscodingConfig = {
  16191. autoDestroyTime: 30,
  16192. audioBitrate: 48,
  16193. audioChannels: 1,
  16194. audioSampleRate: 44100,
  16195. height: 0,
  16196. videoBitrate: 400,
  16197. videoFramerate: 15,
  16198. videoGop: 30,
  16199. width: 0
  16200. },
  16201. e.addInjectStreamUrl = function(a, i) {
  16202. Object(z.checkValidString)(a, "url", 1, 1024),
  16203. Object(z.checkValidObject)(i, "config"),
  16204. !Object(z.isEmpty)(i && i.width) && Object(z.checkValidNumber)(i.width, "config.width", 0, 1e4),
  16205. !Object(z.isEmpty)(i && i.height) && Object(z.checkValidNumber)(i.height, "config.height", 0, 1e4),
  16206. !Object(z.isEmpty)(i && i.videoGop) && Object(z.checkValidNumber)(i.videoGop, "config.videoGop", 1, 1e4),
  16207. !Object(z.isEmpty)(i && i.videoFramerate) && Object(z.checkValidNumber)(i.videoFramerate, "config.videoFramerate", 1, 1e4),
  16208. !Object(z.isEmpty)(i && i.videoBitrate) && Object(z.checkValidNumber)(i.videoBitrate, "config.videoBitrate", 1, 1e4),
  16209. !Object(z.isEmpty)(i && i.audioSampleRate) && Object(z.checkValidEnum)(i.audioSampleRate, "config.audioSampleRate", [32e3, 44100, 48e3]),
  16210. !Object(z.isEmpty)(i && i.audioBitrate) && Object(z.checkValidNumber)(i.audioBitrate, "config.audioBitrate", 1, 1e4),
  16211. !Object(z.isEmpty)(i && i.audioChannels) && Object(z.checkValidNumber)(i.audioChannels, "config.audioChannels", 1, 2);
  16212. var o = s.b.reportApiInvoke(t.sessionId, {
  16213. name: "Client.addInjectStreamUrl",
  16214. options: n,
  16215. tag: "tracer"
  16216. });
  16217. if ("audience" === e.gatewayClient.role) {
  16218. var r = {
  16219. code: 403,
  16220. reason: "AUDIENCE_INJECTING_FORBIDDEN"
  16221. };
  16222. throw o(r),
  16223. r
  16224. }
  16225. var c = e._addInjectStreamUrl(a, i);
  16226. return c.then((function(e) {
  16227. o(null, e)
  16228. })).
  16229. catch((function(e) {
  16230. o(e)
  16231. })),
  16232. c
  16233. },
  16234. e._addInjectStreamUrl = function() {
  16235. var n = ee()(Z.a.mark((function n(a, i) {
  16236. var o, r, s, c, d;
  16237. return Z.a.wrap((function(n) {
  16238. for (;;) switch (n.prev = n.next) {
  16239. case 0:
  16240. return o = E()({},
  16241. e.liveStreaming.injectStreamTranscodingConfig, i),
  16242. r = {
  16243. allocate: !0,
  16244. clientRequest: {
  16245. cname: e.channel,
  16246. command: "InjectStream",
  16247. sid: t.sessionId,
  16248. transcodingConfig: o,
  16249. ts: Date.now(),
  16250. url: a,
  16251. vid: parseInt(e.joinInfo.vid, 10)
  16252. },
  16253. command: "request"
  16254. },
  16255. e.liveStreaming.connections.inject_streaming || e.liveStreaming.connect("inject_streaming"),
  16256. s = null,
  16257. n.prev = 4,
  16258. n.next = 7,
  16259. e.liveStreaming.connections.inject_streaming.request(r);
  16260. case 7:
  16261. s = n.sent,
  16262. c = {
  16263. reason: s && s.reason,
  16264. status: Dt(s && s.code),
  16265. type: "streamInjectedStatus",
  16266. uid: s && s.serverResponse && s.serverResponse.inject_uid,
  16267. url: s && s.serverResponse && s.serverResponse.url
  16268. },
  16269. e.gatewayClient.dispatchEvent(c),
  16270. n.next = 17;
  16271. break;
  16272. case 12:
  16273. throw n.prev = 12,
  16274. n.t0 = n.
  16275. catch(4),
  16276. d = {
  16277. reason: n.t0 && n.t0.reason,
  16278. status: Dt(n.t0 && n.t0.code),
  16279. type: "streamInjectedStatus",
  16280. uid: n.t0 && n.t0.serverResponse && n.t0.serverResponse.inject_uid,
  16281. url: n.t0 && n.t0.serverResponse && n.t0.serverResponse.url
  16282. },
  16283. e.gatewayClient.dispatchEvent(d),
  16284. n.t0;
  16285. case 17:
  16286. return e.liveStreaming.pullStates[a] = {
  16287. transcodingConfig: o,
  16288. url: a
  16289. },
  16290. n.abrupt("return", s);
  16291. case 19:
  16292. case "end":
  16293. return n.stop()
  16294. }
  16295. }), n, null, [[4, 12]])
  16296. })));
  16297. return function(e, t) {
  16298. return n.apply(this, arguments)
  16299. }
  16300. } (),
  16301. e.removeInjectStreamUrl = function() {
  16302. var n = ee()(Z.a.mark((function n(a) {
  16303. var i, o, r = arguments;
  16304. return Z.a.wrap((function(n) {
  16305. for (;;) switch (n.prev = n.next) {
  16306. case 0:
  16307. return Object(z.checkValidString)(a, "url", 1, 255),
  16308. i = s.b.reportApiInvoke(t.sessionId, {
  16309. name: "Client.removeInjectStreamUrl",
  16310. options: r,
  16311. tag: "tracer"
  16312. }),
  16313. (o = e._removeInjectStreamUrl(a)).then((function(e) {
  16314. i(null, e)
  16315. })).
  16316. catch((function(e) {
  16317. i(e)
  16318. })),
  16319. n.abrupt("return", o);
  16320. case 5:
  16321. case "end":
  16322. return n.stop()
  16323. }
  16324. }), n)
  16325. })));
  16326. return function(e) {
  16327. return n.apply(this, arguments)
  16328. }
  16329. } (),
  16330. e._removeInjectStreamUrl = function() {
  16331. var t = ee()(Z.a.mark((function t(n) {
  16332. var a, i, o, r;
  16333. return Z.a.wrap((function(t) {
  16334. for (;;) switch (t.prev = t.next) {
  16335. case 0:
  16336. return a = {
  16337. allocate: !1,
  16338. clientRequest: {
  16339. command: "UninjectStream",
  16340. url: n
  16341. },
  16342. command: "request"
  16343. },
  16344. e.liveStreaming.connections.inject_streaming || e.liveStreaming.connect("inject_streaming"),
  16345. i = null,
  16346. t.prev = 3,
  16347. t.next = 6,
  16348. e.liveStreaming.connections.inject_streaming.request(a);
  16349. case 6:
  16350. i = t.sent,
  16351. o = {
  16352. reason: i && i.reason,
  16353. status: kt(i && i.code),
  16354. type: "streamInjectedStatus",
  16355. uid: i && i.serverResponse && i.serverResponse.inject_uid,
  16356. url: i && i.serverResponse && i.serverResponse.url
  16357. },
  16358. e.gatewayClient.dispatchEvent(o),
  16359. t.next = 16;
  16360. break;
  16361. case 11:
  16362. throw t.prev = 11,
  16363. t.t0 = t.
  16364. catch(3),
  16365. r = {
  16366. reason: t.t0 && t.t0.reason,
  16367. status: kt(t.t0 && t.t0.code),
  16368. type: "streamInjectedStatus",
  16369. uid: t.t0 && t.t0.serverResponse && t.t0.serverResponse.inject_uid,
  16370. url: t.t0 && t.t0.serverResponse && t.t0.serverResponse.url
  16371. },
  16372. e.gatewayClient.dispatchEvent(r),
  16373. t.t0;
  16374. case 16:
  16375. return delete e.liveStreaming.pullStates[n],
  16376. t.abrupt("return", i);
  16377. case 18:
  16378. case "end":
  16379. return t.stop()
  16380. }
  16381. }), t, null, [[3, 11]])
  16382. })));
  16383. return function(e) {
  16384. return t.apply(this, arguments)
  16385. }
  16386. } ()
  16387. } (t, e), e.areaCode) {
  16388. var n = Object(Mt.getAreaDomainConfig)(e.areaCode);
  16389. Object.keys(n).map((function(e) {
  16390. "LOG_UPLOAD_SERVER" == e || "EVENT_REPORT_DOMAIN" == e || "EVENT_REPORT_BACKUP_DOMAIN" == e ? Object(o.setParameter)(e, n[e][0]) : Object(o.setParameter)(e, n[e])
  16391. }))
  16392. }
  16393. return Object(z.isEmpty)(e.turnServer) || t.setTurnServer(e.turnServer),
  16394. Object(z.isEmpty)(e.proxyServer) || t.setProxyServer(e.proxyServer),
  16395. "live" === t.mode && (t.gatewayClient.role = "audience"),
  16396. "rtc" === t.mode && (t.gatewayClient.role = Ut),
  16397. t.gatewayClient.on("onMultiIP", (function(e) {
  16398. t.gatewayClient.closeGateway(),
  16399. t.gatewayClient.socket = void 0,
  16400. t.gatewayClient.hasChangeBGPAddress = !0,
  16401. t.joinInfo.multiIP = e.option,
  16402. t.gatewayClient.state = st.CONNECTING;
  16403. var n = function(e) {
  16404. r.
  16405. default.info("[".concat(t.clientId, "] Joining channel: ").concat(t.channel)),
  16406. t.joinInfo.cid = e.cid,
  16407. t.joinInfo.uid || (t.joinInfo.uid = e.uid),
  16408. t.joinInfo.uni_lbs_ip = e.uni_lbs_ip,
  16409. t.joinInfo.gatewayAddr = e.gateway_addr,
  16410. t.onSuccess ? t.gatewayClient.join(t.joinInfo, t.key, (function(e) {
  16411. r.
  16412. default.info("[".concat(t.clientId, "] Join channel ").concat(t.channel, " success"));
  16413. var n = t.onSuccess;
  16414. t.onSuccess = null,
  16415. t.onFailure = null,
  16416. n(e)
  16417. }), t.onFailure) : (t.gatewayClient.joinInfo = E()({},
  16418. t.joinInfo), t.gatewayClient.rejoin())
  16419. };
  16420. t.joinInfo.stringUid && !t.joinInfo.uid ? (t.userAccountReq && !t.userAccountReq.isFinished() && t.userAccountReq.cancel(), t.userAccountReq = Qe(joinInfo, t.gatewayClient), t.userAccountReq.then((function(e) {
  16421. r.
  16422. default.error("getUserAccount Success ".concat(e.url, " ").concat(joinInfo.stringUid, " => ").concat(e.uid)),
  16423. t.joinInfo.uid = e.uid,
  16424. ze(t.joinInfo, n, t.onFailure)
  16425. })).
  16426. catch((function(e) {
  16427. r.
  16428. default.error("getUserAccount rejected", e),
  16429. t.onFailure(e)
  16430. }))) : ze(t.joinInfo, n, t.onFailure)
  16431. })),
  16432. t.gatewayClient.on("rejoin-start", (function() {
  16433. t._renewSession(),
  16434. s.b.sessionInit(e.sessionId, {
  16435. lts: (new Date).getTime(),
  16436. extend: {
  16437. rejoin: !0
  16438. },
  16439. cname: t.channel,
  16440. appid: e.appId,
  16441. mode: e.mode,
  16442. succ: !0
  16443. })
  16444. })),
  16445. t.gatewayClient.on("recover", (function() {
  16446. t._renewSession(),
  16447. console.log("recover", e.sessionId),
  16448. s.b.sessionInit(e.sessionId, {
  16449. lts: (new Date).getTime(),
  16450. extend: {
  16451. recover: !0
  16452. },
  16453. cname: t.channel,
  16454. appid: e.appId,
  16455. mode: e.mode,
  16456. succ: !0
  16457. })
  16458. })),
  16459. t.gatewayClient.on("rejoin", (function() {
  16460. var e = t.highStreamState;
  16461. if (r.
  16462. default.debug("[".concat(t.clientId, "] Client local stream preState: ").concat(e)), t.onSuccess) {
  16463. var n = t.onSuccess;
  16464. t.onSuccess = null,
  16465. t.onFailure = null,
  16466. n(t.joinInfo.uid)
  16467. } ! t.highStream || 0 !== e && 1 !== e || (r.
  16468. default.info("[".concat(t.clientId, "] publish after rejoin")), t.highStreamState = 2, t.lowStreamState = 2, t.publish(t.highStream, (function(e) {
  16469. e && r.
  16470. default.info("[".concat(t.clientId, "] "), e)
  16471. })))
  16472. })),
  16473. t.gatewayClient.on("streamPublished", (function(e) {
  16474. t.hasPublished || (t.hasPublished = !0, t.gatewayClient.dispatchEvent(u({
  16475. type: "stream-published",
  16476. stream: e.stream
  16477. })))
  16478. })),
  16479. t.gatewayClient.on("pubP2PLost", (function(e) {
  16480. r.
  16481. default.debug("[".concat(t.clientId, "] Start reconnect local peerConnection: ").concat(t.highStream.getId())),
  16482. t.gatewayClient.dispatchEvent({
  16483. type: "stream-reconnect-start",
  16484. uid: t.highStream.getId()
  16485. }),
  16486. 1 === t.highStreamState && (t.highStreamState = 0, t.lowStreamState = 0),
  16487. t._unpublish(t.highStream, (function() {
  16488. t._publish(t.highStream, (function() {
  16489. r.
  16490. default.debug("[".concat(t.clientId, "] Reconnect local peerConnection success: ").concat(t.highStream.getId())),
  16491. t.gatewayClient.dispatchEvent({
  16492. type: "stream-reconnect-end",
  16493. uid: t.highStream.getId(),
  16494. success: !0,
  16495. reason: ""
  16496. })
  16497. }), (function(e) {
  16498. r.
  16499. default.debug("[".concat(t.clientId, "] Reconnect local peerConnection failed: ").concat(e)),
  16500. t.gatewayClient.dispatchEvent({
  16501. type: "stream-reconnect-end",
  16502. uid: t.highStream.getId(),
  16503. success: !1,
  16504. reason: e
  16505. })
  16506. }), !0)
  16507. }), (function(e) {
  16508. r.
  16509. default.debug("[".concat(t.clientId, "] Reconnect local peerConnection failed: ").concat(e)),
  16510. t.gatewayClient.dispatchEvent({
  16511. type: "stream-reconnect-end",
  16512. uid: t.highStream.getId(),
  16513. success: !1,
  16514. reason: e
  16515. })
  16516. }), !0)
  16517. })),
  16518. t.gatewayClient.on("subP2PLost", (function(e) {
  16519. r.
  16520. default.debug("[".concat(t.clientId, "] Start reconnect remote peerConnection: ").concat(e.stream.getId(), " ").concat(e.stream.subscribeOptions)),
  16521. t.gatewayClient.dispatchEvent({
  16522. type: "stream-reconnect-start",
  16523. uid: e.stream.getId()
  16524. });
  16525. var n = e.stream.subscribeOptions;
  16526. console.log("Re-subscribe stream", n, e.stream),
  16527. t.gatewayClient.unsubscribe(e.stream, (function() {
  16528. e.stream.subscribeOptions = n,
  16529. t.gatewayClient.subscribe(e.stream, (function() {
  16530. r.
  16531. default.debug("[".concat(t.clientId, "] Reconnect remote peerConnection success: ").concat(e.stream.getId())),
  16532. t.gatewayClient.dispatchEvent({
  16533. type: "stream-reconnect-end",
  16534. uid: e.stream.getId(),
  16535. success: !0,
  16536. reason: ""
  16537. })
  16538. }), (function(n) {
  16539. r.
  16540. default.debug("[".concat(t.clientId, "] Reconnect remote peerConnection failed: "), n),
  16541. t.gatewayClient.dispatchEvent({
  16542. type: "stream-reconnect-end",
  16543. uid: e.stream.getId(),
  16544. success: !1,
  16545. reason: n
  16546. })
  16547. }))
  16548. }), (function(n) {
  16549. r.
  16550. default.debug("[".concat(t.clientId, "] Reconnect remote peerConnection failed: "), n),
  16551. t.gatewayClient.dispatchEvent({
  16552. type: "stream-reconnect-end",
  16553. uid: e.stream.getId(),
  16554. success: !1,
  16555. reason: n
  16556. })
  16557. }))
  16558. })),
  16559. ft.on("networkTypeChanged", (function(e) {
  16560. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16561. var n = E()({},
  16562. e, {
  16563. type: "network-type-changed"
  16564. });
  16565. t.gatewayClient.dispatchEvent(n)
  16566. })),
  16567. K.on("recordingDeviceChanged", (function(e) {
  16568. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16569. var n = E()({},
  16570. e, {
  16571. type: "recording-device-changed"
  16572. });
  16573. t.gatewayClient.dispatchEvent(n)
  16574. })),
  16575. K.on("playoutDeviceChanged", (function(e) {
  16576. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16577. var n = E()({},
  16578. e, {
  16579. type: "playout-device-changed"
  16580. });
  16581. t.gatewayClient.dispatchEvent(n)
  16582. })),
  16583. K.on("cameraChanged", (function(e) {
  16584. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16585. var n = E()({},
  16586. e, {
  16587. type: "camera-changed"
  16588. });
  16589. t.gatewayClient.dispatchEvent(n)
  16590. })),
  16591. t.gatewayClient.on("streamTypeChange", (function(n) {
  16592. var a = E()({},
  16593. n, {
  16594. type: "stream-type-changed"
  16595. });
  16596. t.gatewayClient.dispatchEvent(a),
  16597. s.b.reportApiInvoke(e.sessionId, {
  16598. name: "streamTypeChange"
  16599. })(null, JSON.stringify(n))
  16600. })),
  16601. t
  16602. },
  16603. Vt = {
  16604. width: 640,
  16605. height: 360,
  16606. videoBitrate: 400,
  16607. videoFramerate: 15,
  16608. lowLatency: !1,
  16609. audioSampleRate: 48e3,
  16610. audioBitrate: 48,
  16611. audioChannels: 1,
  16612. videoGop: 30,
  16613. videoCodecProfile: 100,
  16614. userCount: 0,
  16615. userConfigExtraInfo: {},
  16616. backgroundColor: 0,
  16617. transcodingUsers: []
  16618. },
  16619. jt = function(e) {
  16620. switch (e) {
  16621. case "h264_interop":
  16622. return "h264";
  16623. default:
  16624. return "vp8"
  16625. }
  16626. },
  16627. Bt = function(e) {
  16628. return - 1 === we.indexOf(e.mode) ? I.
  16629. default.INVALID_CLIENT_MODE:
  16630. -1 === De.indexOf(e.codec) ? I.
  16631. default.INVALID_CLIENT_CODEC:
  16632. "h264_interop" == e.mode && "h264" !== e.codec && I.
  16633. default.CLIENT_MODE_CODEC_MISMATCH
  16634. },
  16635. Ft = function(e) {
  16636. switch (e.mode) {
  16637. case "interop":
  16638. case "h264_interop":
  16639. e.mode = "live";
  16640. break;
  16641. case "web-only":
  16642. e.mode = "rtc"
  16643. }
  16644. },
  16645. Wt = K.getDevices,
  16646. Gt = V,
  16647. Ht = JSON.parse(JSON.stringify(o.SUPPORT_RESOLUTION_LIST));
  16648. n.
  16649. default = {
  16650. TranscodingUser: {
  16651. uid: 0,
  16652. x: 0,
  16653. y: 0,
  16654. width: 0,
  16655. height: 0,
  16656. zOrder: 0,
  16657. alpha: 1
  16658. },
  16659. LiveTranscoding: Vt,
  16660. createClient: function(e) {
  16661. var t = s.b.reportApiInvoke(null, {
  16662. name: "createClient",
  16663. options: arguments,
  16664. tag: "tracer"
  16665. }); (e = E()({},
  16666. e || {})).codec || (e.codec = jt(e.mode));
  16667. var n = Bt(e);
  16668. if (n) throw r.
  16669. default.error("Invalid parameter setting MODE: ".concat(e.mode, " CODEC: ").concat(e.codec, " ERROR ").concat(n)),
  16670. t(n),
  16671. new Error(n);
  16672. return r.
  16673. default.info("Creating client, MODE: ".concat(e.mode, " CODEC: ").concat(e.codec)),
  16674. Ft(e),
  16675. t(null, e),
  16676. xt(e)
  16677. },
  16678. createStream: function(e) {
  16679. var t = s.b.reportApiInvoke(null, {
  16680. name: "createStream",
  16681. options: arguments,
  16682. tag: "tracer",
  16683. getStates: function() {
  16684. return {
  16685. audioTrackEnable: e && e.audioSource ? e.audioSource.enabled: null,
  16686. videoTrackEnable: e && e.videoSource ? e.videoSource.enabled: null
  16687. }
  16688. }
  16689. });
  16690. Object(z.checkValidObject)(e, "StreamSpec");
  16691. var n = e.streamID,
  16692. a = e.audio,
  16693. i = e.video,
  16694. o = e.screen,
  16695. c = e.screenAudio,
  16696. d = (e.audioSource, e.videoSource, e.cameraId),
  16697. u = e.facingMode,
  16698. l = e.microphoneId,
  16699. p = e.mirror,
  16700. f = e.extensionId,
  16701. g = e.mediaSource,
  16702. m = e.audioProcessing;
  16703. if (!Object(z.isEmpty)(n) && !Object(H.is32Uint)(n) && !Object(z.isValidString)(n, 1, 255)) throw new Error("[String streamID] Length of the string: [1,255]. ASCII characters only. [Number streamID] The value range is Uint32");
  16704. if (Object(z.checkValidBoolean)(a, "audio"), Object(z.checkValidBoolean)(i, "video"), Object(z.isEmpty)(o) || Object(z.checkValidBoolean)(o, "screen"), Object(z.isEmpty)(c) || Object(z.checkValidBoolean)(c, "screenAudio"), Object(z.isEmpty)(d) || Object(z.checkValidString)(d, "cameraId", 0, 255, !1), Object(z.isEmpty)(u) || Object(z.checkValidEnum)(u, "facingMode", ["user", "environment", "left", "right"]), Object(z.isEmpty)(l) || Object(z.checkValidString)(l, "microphoneId", 0, 255, !1), Object(z.isEmpty)(f) || Object(z.checkValidString)(f, "extensionId"), Object(z.isEmpty)(g) || Object(z.checkValidEnum)(g, "mediaSource", ["screen", "application", "window"]), Object(z.isEmpty)(p) || Object(z.checkValidBoolean)(p, "mirror"), !Object(z.isEmpty)(m)) {
  16705. var v = m.AGC,
  16706. S = m.AEC,
  16707. E = m.ANS;
  16708. Object(z.isEmpty)(v) || Object(z.checkValidBoolean)(v, "AGC"),
  16709. Object(z.isEmpty)(S) || Object(z.checkValidBoolean)(S, "AEC"),
  16710. Object(z.isEmpty)(E) || Object(z.checkValidBoolean)(E, "ANS")
  16711. }
  16712. r.
  16713. default.debug("Create stream"),
  16714. !0 === c && !0 === a && r.
  16715. default.warning("Do not set both 'screenAudio' and 'audio' to true at the same time");
  16716. var _ = ye(e);
  16717. return t(),
  16718. _
  16719. },
  16720. Logger: r.
  16721. default,
  16722. report: s.b,
  16723. getDevices: Wt,
  16724. getScreenSources: Gt,
  16725. getParameter: o.getParameter,
  16726. setParameter: o.setParameter,
  16727. checkSystemRequirements: function() {
  16728. var e = s.b.reportApiInvoke(null, {
  16729. name: "checkSystemRequirements",
  16730. options: arguments,
  16731. tag: "tracer"
  16732. }),
  16733. t = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection,
  16734. n = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia || navigator.mediaDevices && navigator.mediaDevices.getUserMedia,
  16735. a = window.WebSocket,
  16736. i = !!t && !!n && !!a,
  16737. o = !1;
  16738. g.isChrome() && g.getBrowserVersion() >= 58 && "iOS" !== g.getBrowserOS() && (o = !0),
  16739. g.isFireFox() && g.getBrowserVersion() >= 56 && (o = !0),
  16740. g.isOpera() && g.getBrowserVersion() >= 45 && (o = !0),
  16741. g.isSafari() && g.getBrowserVersion() >= 11 && (o = !0),
  16742. g.isEdge() && (o = !0),
  16743. (g.isWeChatBrowser() || g.isQQBrowser()) && "iOS" !== g.getBrowserOS() && (o = !0),
  16744. g.isSupportedPC() || g.isSupportedMobile() || (o = !1),
  16745. r.
  16746. default.debug(g.getBrowserInfo(), "isAPISupport: " + i + ", isVendorAndVersionSupport: " + o);
  16747. var c = i && o;
  16748. return e(null, c),
  16749. c
  16750. },
  16751. getSupportedCodec: Oe.getSupportedCodec,
  16752. ChannelMediaRelayConfiguration: Ce.ChannelMediaRelayConfiguration,
  16753. VERSION: o.VERSION,
  16754. BUILD: o.BUILD,
  16755. PROFILE_TABLE: Ht,
  16756. AUDIO_SAMPLE_RATE_32000: 32e3,
  16757. AUDIO_SAMPLE_RATE_44100: 44100,
  16758. AUDIO_SAMPLE_RATE_48000: 48e3,
  16759. VIDEO_CODEC_PROFILE_BASELINE: 66,
  16760. VIDEO_CODEC_PROFILE_MAIN: 77,
  16761. VIDEO_CODEC_PROFILE_HIGH: 100,
  16762. REMOTE_VIDEO_STREAM_HIGH: 0,
  16763. REMOTE_VIDEO_STREAM_LOW: 1,
  16764. REMOTE_VIDEO_STREAM_MEDIUM: 2,
  16765. AREAS: Mt.AREAS,
  16766. AREA_VERSION: "global"
  16767. }
  16768. }]).
  16769. default
  16770. }));