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

AgoraRTCSDK.min.js 859KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780
  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. // fix by Adam 修正由于dom速度原因导致的可能play的时候document还未创建的报错
  5032. void 0 !== t.elementID && document.getElementById(t.elementID) !== null ? (document.getElementById(t.elementID).appendChild(t.div), t.container = document.getElementById(t.elementID)) : (document.body.appendChild(t.div), t.container = document.body),
  5033. t.parentNode = t.div.parentNode;
  5034. var i = {
  5035. video: {
  5036. playerId: t.playerId,
  5037. stateId: 0,
  5038. playDeferTimeout: null,
  5039. error: !1,
  5040. status: "init",
  5041. reason: null,
  5042. updatedAt: Date.now()
  5043. },
  5044. audio: {
  5045. playerId: t.playerId,
  5046. stateId: 0,
  5047. playDeferTimeout: null,
  5048. error: !1,
  5049. status: "init",
  5050. reason: null,
  5051. updatedAt: Date.now()
  5052. }
  5053. };
  5054. t.mediaElemExists = function(e) {
  5055. for (var t = e,
  5056. n = 0; n < Object(o.getParameter)("MEDIA_ELEMENT_EXISTS_DEPTH") && t; n++) t = t.parentNode;
  5057. return !! t
  5058. };
  5059. var c = function(e) {
  5060. return t.mediaElemExists(e) ? e.paused ? "paused": "play": "aborted"
  5061. },
  5062. d = function(e, t, n) {
  5063. var a = c(e),
  5064. i = !0;
  5065. 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),
  5066. i
  5067. },
  5068. u = function(n) {
  5069. var u, l = this;
  5070. if (l === t.video ? u = "video": l === t.audio && (u = "audio"), u) {
  5071. n.type || r.
  5072. default.error("[".concat(t.id, "] Unexpected evt"), n);
  5073. var p = c(l);
  5074. clearTimeout(i[u].playDeferTimeout),
  5075. i[u].playDeferTimeout = setTimeout((function() {
  5076. i[u].playDeferTimeout = null;
  5077. var o = i[u],
  5078. f = c(l);
  5079. if (p === f) {
  5080. var g = {
  5081. playerId: t.playerId,
  5082. stateId: o.stateId + 1,
  5083. playDeferTimeout: null,
  5084. error: d(l, u, a),
  5085. status: c(l),
  5086. reason: n.type,
  5087. updatedAt: Date.now()
  5088. };
  5089. if (o.status !== g.status) {
  5090. i[u] = g;
  5091. var m = {
  5092. type: "player-status-change",
  5093. playerId: t.playerId,
  5094. mediaType: u,
  5095. status: g.status,
  5096. reason: g.reason,
  5097. isErrorState: g.error,
  5098. streamId: t.id
  5099. };
  5100. r.
  5101. default.debug("[".concat(t.id, "] Media Player Status Change"), m),
  5102. e.stream.dispatchEvent(m),
  5103. s.b.reportApiInvoke(e.stream.sid, {
  5104. name: "Stream.playerStatusChange",
  5105. options: m,
  5106. tag: "tracer"
  5107. })()
  5108. }
  5109. } else r.
  5110. 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))
  5111. }), Object(o.getParameter)("PLAYER_STATE_DEFER"))
  5112. } else r.
  5113. default.error("[".concat(t.id, "] Unknown media element"), l)
  5114. };
  5115. t.video.addEventListener("playing", (function(e) { !
  5116. function e() {
  5117. t.video.videoWidth * t.video.videoHeight > 4 ? r.
  5118. default.debug("[" + t.id + "] video dimensions:", t.video.videoWidth, t.video.videoHeight) : setTimeout(e, 50)
  5119. } ()
  5120. }));
  5121. t.freezeCheckInterval = setInterval((function() {
  5122. Date.now() - t.lastTimeupdateTime > 500 ? (t.isFreeze = !0, t.freezeCount += 1) : t.isFreeze = !1
  5123. }), 500),
  5124. t.video.addEventListener("playing", u),
  5125. t.video.addEventListener("canplay", u),
  5126. t.video.addEventListener("abort", u),
  5127. t.video.addEventListener("onerror", u),
  5128. t.video.addEventListener("suspend", u),
  5129. t.video.addEventListener("stalled", u),
  5130. t.video.addEventListener("pause", u),
  5131. t.video.addEventListener("timeupdate", (function() {
  5132. t.lastTimeupdateTime = Date.now()
  5133. })),
  5134. t.audio.addEventListener("playing", u),
  5135. t.audio.addEventListener("canplay", u),
  5136. t.audio.addEventListener("abort", u),
  5137. t.audio.addEventListener("onerror", u),
  5138. t.audio.addEventListener("suspend", u),
  5139. t.audio.addEventListener("stalled", u),
  5140. t.audio.addEventListener("pause", u);
  5141. var l = t.audio,
  5142. p = "audio";
  5143. if (e.stream.hasVideo() || e.stream.hasScreen()) t.div.appendChild(t.video),
  5144. t.div.appendChild(t.audio),
  5145. g.isEdge() ? t.video.srcObject = e.stream.stream: (Object(h.attachMediaStream)(t.video, e.stream.stream), Object(h.attachMediaStream)(t.audio, e.stream.stream));
  5146. else { ! 1 !== a.muted && "video_element_muted" !== a.muted || (t.video.removeAttribute("muted"), t.video.muted = !1),
  5147. t.video.removeAttribute("autoplay"),
  5148. t.video.autoplay = !1,
  5149. t.div.appendChild(t.video),
  5150. l = t.video,
  5151. p = "video";
  5152. var f = i.audio,
  5153. m = {
  5154. playerId: t.playerId,
  5155. stateId: f.stateId + 1,
  5156. playDeferTimeout: null,
  5157. error: !1,
  5158. status: "aborted",
  5159. reason: "audioonly",
  5160. updatedAt: Date.now()
  5161. };
  5162. i.audio = m;
  5163. var v = {
  5164. type: "player-status-change",
  5165. playerId: t.playerId,
  5166. mediaType: "audio",
  5167. status: m.status,
  5168. reason: m.reason,
  5169. isErrorState: m.error,
  5170. streamId: t.id
  5171. };
  5172. if (r.
  5173. default.debug("[".concat(t.id, "] Media Player Status Change"), v), Promise.resolve().then((function() {
  5174. return e.stream.dispatchEvent(v)
  5175. })), s.b.reportApiInvoke(e.stream.sid, {
  5176. name: "Stream.playerStatusChange",
  5177. options: v,
  5178. tag: "tracer"
  5179. })(), window.MediaStream && (g.isSafari() || "iOS" === g.getBrowserOS())) {
  5180. var S = new MediaStream(e.stream.stream.getAudioTracks());
  5181. Object(h.setSrcObject)(t.video, S)
  5182. } else Object(h.setSrcObject)(t.video, e.stream.stream)
  5183. }
  5184. if (a.autoplay && l) {
  5185. var T = l.play();
  5186. T && T.
  5187. catch && T.
  5188. catch((function(n) {
  5189. if (!t.destroyed && l) {
  5190. var o = i[p],
  5191. u = {
  5192. playerId: t.playerId,
  5193. stateId: o.stateId + 1,
  5194. playDeferTimeout: null,
  5195. error: d(l, p, a),
  5196. status: c(l),
  5197. reason: "error",
  5198. updatedAt: Date.now()
  5199. };
  5200. if (o.status !== u.status) {
  5201. r.
  5202. default.debug("[".concat(t.id, "] Player ").concat(t.playerId, " Status Changed Detected by promise error: ").concat(o.status, "=>").concat(u.status), n),
  5203. i[p] = u;
  5204. var f = {
  5205. type: "player-status-change",
  5206. playerId: t.playerId,
  5207. mediaType: p,
  5208. status: u.status,
  5209. reason: u.reason,
  5210. isErrorState: u.error,
  5211. streamId: t.id
  5212. };
  5213. r.
  5214. default.debug("[".concat(t.id, "] Media Player Status Change"), f),
  5215. e.stream.dispatchEvent(f),
  5216. s.b.reportApiInvoke(e.stream.sid, {
  5217. name: "Stream.playerStatusChange",
  5218. options: f,
  5219. tag: "tracer"
  5220. })()
  5221. }
  5222. }
  5223. }))
  5224. }
  5225. return t.setAudioVolume = function(e) {
  5226. var n = parseInt(e) / 100;
  5227. isFinite(n) && (n < 0 ? n = 0 : n > 1 && (n = 1), t.video && (t.video.volume = n), t.audio && (t.audio.volume = n))
  5228. },
  5229. t
  5230. };
  5231. function R(e) {
  5232. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  5233. if (Array.isArray(e) || (e = function(e, t) {
  5234. if (!e) return;
  5235. if ("string" == typeof e) return A(e, t);
  5236. var n = Object.prototype.toString.call(e).slice(8, -1);
  5237. "Object" === n && e.constructor && (n = e.constructor.name);
  5238. if ("Map" === n || "Set" === n) return Array.from(n);
  5239. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return A(e, t)
  5240. } (e))) {
  5241. var t = 0,
  5242. n = function() {};
  5243. return {
  5244. s: n,
  5245. n: function() {
  5246. return t >= e.length ? {
  5247. done: !0
  5248. }: {
  5249. done: !1,
  5250. value: e[t++]
  5251. }
  5252. },
  5253. e: function(e) {
  5254. throw e
  5255. },
  5256. f: n
  5257. }
  5258. }
  5259. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  5260. }
  5261. var a, i, o = !0,
  5262. r = !1;
  5263. return {
  5264. s: function() {
  5265. a = e[Symbol.iterator]()
  5266. },
  5267. n: function() {
  5268. var e = a.next();
  5269. return o = e.done,
  5270. e
  5271. },
  5272. e: function(e) {
  5273. r = !0,
  5274. i = e
  5275. },
  5276. f: function() {
  5277. try {
  5278. o || null == a.
  5279. return || a.
  5280. return ()
  5281. } finally {
  5282. if (r) throw i
  5283. }
  5284. }
  5285. }
  5286. }
  5287. function A(e, t) { (null == t || t > e.length) && (t = e.length);
  5288. for (var n = 0,
  5289. a = new Array(t); n < t; n++) a[n] = e[n];
  5290. return a
  5291. }
  5292. var y = function(e) {
  5293. var t = {},
  5294. n = h.RTCPeerConnection;
  5295. t.uid = e.uid,
  5296. t.isVideoMute = e.isVideoMute,
  5297. t.isAudioMute = e.isAudioMute,
  5298. t.isSubscriber = e.isSubscriber,
  5299. t.clientId = e.clientId,
  5300. t.filterStatsCache = [],
  5301. t.originStatsCache = [],
  5302. t.lastTimeGetStats = null,
  5303. t.pc_config = {
  5304. iceServers: [{
  5305. url: "stun:webcs.agora.io:3478"
  5306. }]
  5307. };
  5308. var a = {
  5309. id: "outbound_audio_ssrc_send",
  5310. type: "ssrc",
  5311. mediaType: "",
  5312. googCodecName: "opus",
  5313. aecDivergentFilterFraction: "0",
  5314. audioInputLevel: "0",
  5315. bytesSent: "0",
  5316. packetsSent: "0",
  5317. googEchoCancellationReturnLoss: "0",
  5318. googEchoCancellationReturnLossEnhancement: "0"
  5319. },
  5320. i = {
  5321. id: "outbound_video_ssrc_send",
  5322. type: "ssrc",
  5323. mediaType: "",
  5324. googCodecName: "h264" === e.codec ? "H264": "VP8",
  5325. bytesSent: "0",
  5326. packetsLost: "0",
  5327. packetsSent: "0",
  5328. googAdaptationChanges: "0",
  5329. googAvgEncodeMs: "0",
  5330. googEncodeUsagePercent: "0",
  5331. googFirsReceived: "0",
  5332. googFrameHeightSent: "0",
  5333. googFrameHeightInput: "0",
  5334. googFrameRateInput: "0",
  5335. googFrameRateSent: "0",
  5336. googFrameWidthSent: "0",
  5337. googFrameWidthInput: "0",
  5338. googNacksReceived: "0",
  5339. googPlisReceived: "0",
  5340. googRtt: "0"
  5341. },
  5342. s = {
  5343. id: "inbound_audio_ssrc_recv",
  5344. type: "ssrc",
  5345. mediaType: "",
  5346. googCodecName: "opus",
  5347. audioOutputLevel: "0",
  5348. bytesReceived: "0",
  5349. packetsLost: "0",
  5350. packetsReceived: "0",
  5351. googAccelerateRate: "0",
  5352. googCurrentDelayMs: "0",
  5353. googDecodingCNG: "0",
  5354. googDecodingCTN: "0",
  5355. googDecodingCTSG: "0",
  5356. googDecodingNormal: "0",
  5357. googDecodingPLC: "0",
  5358. googDecodingPLCCNG: "0",
  5359. googExpandRate: "0",
  5360. googJitterBufferMs: "0",
  5361. googJitterReceived: "0",
  5362. googPreemptiveExpandRate: "0",
  5363. googPreferredJitterBufferMs: "0",
  5364. googSecondaryDecodedRate: "0",
  5365. googSpeechExpandRate: "0"
  5366. },
  5367. c = {
  5368. id: "inbound_video_ssrc_recv",
  5369. type: "ssrc",
  5370. mediaType: "",
  5371. googTargetDelayMs: "0",
  5372. packetsLost: "0",
  5373. googDecodeMs: "0",
  5374. googMaxDecodeMs: "0",
  5375. googRenderDelayMs: "0",
  5376. googFrameWidthReceived: "0",
  5377. googFrameHeightReceived: "0",
  5378. googFrameRateReceived: "0",
  5379. googFrameRateDecoded: "0",
  5380. googFrameRateOutput: "0",
  5381. googJitterBufferMs: "0",
  5382. googCurrentDelayMs: "0",
  5383. googMinPlayoutDelayMs: "0",
  5384. googNacksSent: "0",
  5385. googPlisSent: "0",
  5386. googFirsSent: "0",
  5387. bytesReceived: "0",
  5388. packetsReceived: "0",
  5389. googFramesReceived: "0",
  5390. googFramesDecoded: "0"
  5391. },
  5392. d = {
  5393. id: "bweforvideo",
  5394. type: "VideoBwe",
  5395. googAvailableSendBandwidth: "0",
  5396. googAvailableReceiveBandwidth: "0",
  5397. googActualEncBitrate: "0",
  5398. googRetransmitBitrate: "0",
  5399. googTargetEncBitrate: "0",
  5400. googBucketDelay: "0",
  5401. googTransmitBitrate: "0"
  5402. };
  5403. t.con = {
  5404. optional: [{
  5405. DtlsSrtpKeyAgreement: !0
  5406. }]
  5407. },
  5408. e.iceServers instanceof Array ? t.pc_config.iceServers = e.iceServers: (e.stunServerUrl && (e.stunServerUrl instanceof Array ? e.stunServerUrl.map((function(e) {
  5409. "string" == typeof e && "" !== e && t.pc_config.iceServers.push({
  5410. url: e
  5411. })
  5412. })) : "string" == typeof e.stunServerUrl && "" !== e.stunServerUrl && t.pc_config.iceServers.push({
  5413. url: e.stunServerUrl
  5414. })), e.turnServers && (e.turnServers instanceof Array ? e.turnServers.map((function(e) {
  5415. e.udpport && t.pc_config.iceServers.push({
  5416. username: e.username,
  5417. credential: e.credential,
  5418. credentialType: "password",
  5419. urls: "turn:" + e.url + ":" + e.udpport + "?transport=udp"
  5420. }),
  5421. "string" == typeof e.tcpport && "" !== e.tcpport && t.pc_config.iceServers.push({
  5422. username: e.username,
  5423. credential: e.credential,
  5424. credentialType: "password",
  5425. urls: "turn:" + e.url + ":" + e.tcpport + "?transport=tcp"
  5426. }),
  5427. !0 === e.forceturn && (t.pc_config.iceTransportPolicy = "relay")
  5428. })) : r.
  5429. default.error("[".concat(t.clientId, "] turnServers is not a array")))),
  5430. void 0 === e.audio && (e.audio = !0),
  5431. void 0 === e.video && (e.video = !0),
  5432. t.mediaConstraints = {
  5433. mandatory: {
  5434. OfferToReceiveVideo: e.video,
  5435. OfferToReceiveAudio: e.audio
  5436. }
  5437. },
  5438. t.roapSessionId = 103;
  5439. try {
  5440. t.pc_config.sdpSemantics = "plan-b",
  5441. t.peerConnection = new n(t.pc_config, t.con)
  5442. } catch(e) {
  5443. delete t.pc_config.sdpSemantics,
  5444. t.peerConnection = new n(t.pc_config, t.con)
  5445. }
  5446. t.iceCandidateTimer = setTimeout((function() {
  5447. t.iceCandidateTimer = null,
  5448. r.
  5449. default.debug("[".concat(t.clientId, "]Candidates collected: ").concat(t.iceCandidateCount)),
  5450. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  5451. }), Object(o.getParameter)("CANDIDATE_TIMEOUT")),
  5452. t.peerConnection.onicecandidate = function(e) {
  5453. var n, a, i, o;
  5454. a = (n = t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),
  5455. i = n.match(/a=candidate:.+typ\shost.+\r\n/),
  5456. o = n.match(/a=candidate:.+typ\srelay.+\r\n/),
  5457. 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()),
  5458. t.iceCandidateCount = t.iceCandidateCount + 1
  5459. };
  5460. var u = function(t) {
  5461. return e.screen && (t = t.replace("a=x-google-flag:conference\r\n", "")),
  5462. t
  5463. },
  5464. l = function(n) {
  5465. var a, i;
  5466. if ((a = n.match(/m=video.*\r\n/)) && e.minVideoBW && e.maxVideoBW) {
  5467. i = a[0] + "b=AS:" + e.maxVideoBW + "\r\n";
  5468. var o = 0,
  5469. s = 0;
  5470. "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/)),
  5471. -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"),
  5472. n = n.replace(a[0], i),
  5473. r.
  5474. default.debug("[" + t.clientId + "]Set Video Bitrate - min:" + e.minVideoBW + " max:" + e.maxVideoBW)
  5475. }
  5476. 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)),
  5477. n
  5478. };
  5479. t.processSignalingMessage = function(e) {
  5480. var n, a = JSON.parse(e);
  5481. t.incomingMessage = a,
  5482. "new" === t.state ? "OFFER" === a.messageType ? (n = {
  5483. sdp: a.sdp,
  5484. type: "offer"
  5485. },
  5486. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5487. 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 = {
  5488. sdp: a.sdp,
  5489. type: "answer"
  5490. }).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)).
  5491. catch((function(e) {})), t.state = "established") : "pr-answer" === a.messageType ? (n = {
  5492. sdp: a.sdp,
  5493. type: "pr-answer"
  5494. },
  5495. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5496. 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 = {
  5497. sdp: a.sdp,
  5498. type: "offer"
  5499. },
  5500. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5501. catch((function(e) {})), t.state = "offer-received", t.markActionNeeded()) : "ANSWER" === a.messageType ? ((n = {
  5502. sdp: a.sdp,
  5503. type: "answer"
  5504. }).sdp = u(n.sdp), n.sdp = l(n.sdp), t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).
  5505. catch((function(e) {}))) : t.error("Illegal message for this state: " + a.messageType + " in state " + t.state))
  5506. };
  5507. var p = 0,
  5508. f = 0;
  5509. return t.getVideoRelatedStats = function(e) {
  5510. t.getStats((function(n) {
  5511. n.forEach((function(n) {
  5512. if (t.isSubscriber) {
  5513. if ("video" === n.mediaType && n.id && ~n.id.indexOf("recv")) {
  5514. if (g.isChromeKernel() && +g.getBrowserVersion() >= 76) {
  5515. var a = +n.googFramesReceived - p,
  5516. i = +n.googFramesDecoded - f;
  5517. t._setStat(c, "googFrameRateReceived", a),
  5518. t._setStat(c, "googFrameRateDecoded", i),
  5519. t._setStat(c, "googFrameRateOutput", i),
  5520. p = +n.googFramesReceived,
  5521. f = +n.googFramesDecoded
  5522. }
  5523. e && e({
  5524. mediaType: "video",
  5525. peerId: t.uid,
  5526. isVideoMute: t.isVideoMute,
  5527. frameRateReceived: n.googFrameRateReceived,
  5528. frameRateDecoded: n.googFrameRateDecoded,
  5529. bytesReceived: n.bytesReceived,
  5530. packetsReceived: n.packetsReceived,
  5531. packetsLost: n.packetsLost
  5532. })
  5533. }
  5534. } else "video" === n.mediaType && n.id && ~n.id.indexOf("send") && e && e({
  5535. mediaType: "video",
  5536. isVideoMute: t.isVideoMute,
  5537. frameRateInput: n.googFrameRateInput,
  5538. frameRateSent: n.googFrameRateSent,
  5539. googRtt: n.googRtt
  5540. })
  5541. }))
  5542. }))
  5543. },
  5544. t.getAudioRelatedStats = function(e) {
  5545. t.getStats((function(n) {
  5546. n.forEach((function(n) {
  5547. t.isSubscriber && "audio" === n.mediaType && n.id && ~n.id.indexOf("recv") && e && e({
  5548. mediaType: "audio",
  5549. peerId: t.uid,
  5550. isAudioMute: t.isAudioMute,
  5551. frameDropped: parseInt(n.googDecodingPLC) + parseInt(n.googDecodingPLCCNG) + "",
  5552. frameReceived: n.googDecodingCTN,
  5553. googJitterReceived: n.googJitterReceived,
  5554. bytesReceived: n.bytesReceived,
  5555. packetsReceived: n.packetsReceived,
  5556. packetsLost: n.packetsLost
  5557. })
  5558. }))
  5559. }))
  5560. },
  5561. t.getStatsRate = function(e) {
  5562. t.getStats((function(t) {
  5563. e(t)
  5564. }))
  5565. },
  5566. t.getStats = function(e, n) {
  5567. n = (n = n || 500) > 500 ? 500 : n,
  5568. t.lastTimeGetStats && Date.now() - t.lastTimeGetStats < n ? e && e(t.filterStatsCache, t.originStatsCache) : (t.lastTimeGetStats = Date.now(), this._getStats((function(n, a) {
  5569. t.filterStatsCache = n,
  5570. t.originStatsCache = a,
  5571. e && e(n, a)
  5572. })))
  5573. },
  5574. t._setStat = function(e, t, n) {
  5575. e.hasOwnProperty(t) && (null != n && n !== 1 / 0 && n == n || (n = 0), e[t] = n + "")
  5576. },
  5577. t._processGetStatsAfterChrome76 = function(e) {
  5578. var n = this;
  5579. t.lastStats || (t.lastStats = new Map),
  5580. t.peerConnection.getStats().then((function(o) {
  5581. var r, u = [],
  5582. l = [],
  5583. p = new Map,
  5584. f = new Date,
  5585. g = R(o.values());
  5586. try {
  5587. for (g.s(); ! (r = g.n()).done;) {
  5588. var m = r.value;
  5589. "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)
  5590. }
  5591. } catch(e) {
  5592. g.e(e)
  5593. } finally {
  5594. g.f()
  5595. }
  5596. p.set("codec", u),
  5597. p.set("candidatePairs", l),
  5598. p.set("timestamp", +f);
  5599. var v = null,
  5600. S = null;
  5601. 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)),
  5602. (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)),
  5603. (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)),
  5604. (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));
  5605. else {
  5606. var _ = t.lastStats.get("timestamp"),
  5607. h = t.lastStats.get("outbound-video");
  5608. 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")) {
  5609. 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) {
  5610. var I = (v.totalEncodedBytesTarget - h.totalEncodedBytesTarget) / ( + new Date - _);
  5611. t._setStat(d, "googTargetEncBitrate", Math.floor(8 * I * 1e3))
  5612. }
  5613. if (v.retransmittedBytesSent && h && h.retransmittedBytesSent) {
  5614. var b = (v.retransmittedBytesSent - h.retransmittedBytesSent) / ( + new Date - _);
  5615. t._setStat(d, "googRetransmitBitrate", Math.floor(8 * b * 1e3))
  5616. }
  5617. if (v.bytesSent && h && h.bytesSent) {
  5618. var T = (v.bytesSent - h.bytesSent) / ( + new Date - _);
  5619. t._setStat(d, "googTransmitBitrate", Math.floor(8 * T * 1e3)),
  5620. t._setStat(d, "googActualEncBitrate", Math.floor(8 * T * 1e3))
  5621. }
  5622. if (v.totalPacketSendDelay && h && h.totalPacketSendDelay) {
  5623. var A = (v.totalPacketSendDelay - h.totalPacketSendDelay) / ( + new Date - _);
  5624. t._setStat(d, "googBucketDelay", Math.floor(1e3 * A))
  5625. }
  5626. }
  5627. 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) {
  5628. S == e.transportId && t._setStat(d, "googAvailableSendBandwidth", e.availableOutgoingBitrate)
  5629. }));
  5630. else {
  5631. var y = p.get("candidatePairs")[0];
  5632. y && t._setStat(d, "googAvailableSendBandwidth", y.availableOutgoingBitrate)
  5633. }
  5634. }
  5635. t.lastStats = p;
  5636. var O = [E()({},
  5637. i), E()({},
  5638. a), E()({},
  5639. c), E()({},
  5640. s), E()({},
  5641. d)];
  5642. O.push({
  5643. id: "time",
  5644. startTime: t.connectedTime,
  5645. timestamp: new Date
  5646. }),
  5647. e(O)
  5648. }))
  5649. },
  5650. t._processGetStatsBeforeChrome76 = function(e) {
  5651. t.peerConnection.getStats((function(n) {
  5652. var o = [],
  5653. r = [],
  5654. u = null;
  5655. Object.keys(n).forEach((function(e) {
  5656. var t = n[e];
  5657. 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))
  5658. })),
  5659. (o = [E()({},
  5660. i), E()({},
  5661. a), E()({},
  5662. c), E()({},
  5663. s), E()({},
  5664. d)]).push({
  5665. id: "time",
  5666. startTime: t.connectedTime,
  5667. timestamp: u || new Date
  5668. }),
  5669. e(o, r)
  5670. }))
  5671. },
  5672. t._getStats = function(e) {
  5673. Object(o.getParameter)("CHROME_NEW_STATS") && g.isChromeKernel() && +g.getBrowserVersion() >= 76 ? t._processGetStatsAfterChrome76(e) : t._processGetStatsBeforeChrome76(e)
  5674. },
  5675. t.addTrack = function(e, n) {
  5676. t.peerConnection.addTrack(e, n)
  5677. },
  5678. t.removeTrack = function(e, n) {
  5679. t.peerConnection.removeTrack(t.peerConnection.getSenders().find((function(t) {
  5680. return t.track == e
  5681. })))
  5682. },
  5683. t.addStream = function(e) {
  5684. t.peerConnection.addStream(e),
  5685. t.markActionNeeded()
  5686. },
  5687. t.removeStream = function() {
  5688. t.markActionNeeded()
  5689. },
  5690. t.close = function() {
  5691. t.state = "closed",
  5692. t.peerConnection.close()
  5693. },
  5694. t.markActionNeeded = function() {
  5695. t.actionNeeded = !0,
  5696. t.doLater((function() {
  5697. t.onstablestate()
  5698. }))
  5699. },
  5700. t.doLater = function(e) {
  5701. window.setTimeout(e, 1)
  5702. },
  5703. t.onstablestate = function() {
  5704. var e;
  5705. if (t.actionNeeded) {
  5706. if ("new" === t.state || "established" === t.state) t.peerConnection.createOffer((function(e) {
  5707. if (e.sdp !== t.prevOffer) return e.sdp = e.sdp.replace("minptime=10", "minptime=10;stereo=1; sprop-stereo=1"),
  5708. t.peerConnection.setLocalDescription(e),
  5709. t.state = "preparing-offer",
  5710. void t.markActionNeeded();
  5711. r.
  5712. default.debug("[" + t.clientId + "]Not sending a new offer")
  5713. }), (function(e) {
  5714. r.
  5715. default.debug("[" + t.clientId + "]peer connection create offer failed ", e)
  5716. }), t.mediaConstraints);
  5717. else if ("preparing-offer" === t.state) {
  5718. if (t.moreIceComing) return;
  5719. t.prevOffer = t.peerConnection.localDescription.sdp,
  5720. t.offerCandidates = t.prevOffer.match(/a=candidate.+\r\n/g) || [],
  5721. t.offerCandidates.length || (r.
  5722. default.warning("[".concat(t.clientId, "]No Ice Candidate generated")), Object(o.getParameter)("SHIM_CANDIDATE") ? (r.
  5723. 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.
  5724. default.error("[".concat(t.clientId, "]None Ice Candidate not allowed"))),
  5725. 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"),
  5726. t.sendMessage("OFFER", t.prevOffer),
  5727. t.state = "offer-sent"
  5728. } else if ("offer-received" === t.state) t.peerConnection.createAnswer((function(e) {
  5729. if (t.peerConnection.setLocalDescription(e), t.state = "offer-received-preparing-answer", t.iceStarted) t.markActionNeeded();
  5730. else {
  5731. var n = new Date;
  5732. r.
  5733. default.debug("[" + t.clientId + "]" + n.getTime() + ": Starting ICE in responder"),
  5734. t.iceStarted = !0
  5735. }
  5736. }), (function(e) {
  5737. r.
  5738. default.debug("[" + t.clientId + "]peer connection create answer failed ", e)
  5739. }), t.mediaConstraints);
  5740. else if ("offer-received-preparing-answer" === t.state) {
  5741. if (t.moreIceComing) return;
  5742. e = t.peerConnection.localDescription.sdp,
  5743. t.sendMessage("ANSWER", e),
  5744. t.state = "established"
  5745. } else r.
  5746. default.debug("[".concat(t.clientId, "] Dazed and confused in state ' + that.state + ', stopping here'"));
  5747. t.actionNeeded = !1
  5748. }
  5749. },
  5750. t.sendMessage = function(e, n) {
  5751. var a = {};
  5752. a.messageType = e,
  5753. a.sdp = n,
  5754. "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),
  5755. t.onsignalingmessage(JSON.stringify(a))
  5756. },
  5757. t._getSender = function(e) {
  5758. if (t.peerConnection && t.peerConnection.getSenders) {
  5759. var n = t.peerConnection.getSenders().find((function(t) {
  5760. return t.track.kind == e
  5761. }));
  5762. if (n) return n
  5763. }
  5764. return null
  5765. },
  5766. t.hasSender = function(e) {
  5767. return !! t._getSender(e)
  5768. },
  5769. t.replaceTrack = function(e, n, a) {
  5770. var i = t._getSender(e.kind);
  5771. if (!i) {
  5772. return a("NO_SENDER_FOUND")
  5773. }
  5774. try {
  5775. i.replaceTrack(e)
  5776. } catch(e) {
  5777. return a && a(e)
  5778. }
  5779. setTimeout((function() {
  5780. return n && n()
  5781. }), 50)
  5782. },
  5783. t.error = function(e) {
  5784. throw "Error in RoapOnJsep: " + e
  5785. },
  5786. t.sessionId = t.roapSessionId += 1,
  5787. t.sequenceNumber = 0,
  5788. t.actionNeeded = !1,
  5789. t.iceStarted = !1,
  5790. t.moreIceComing = !0,
  5791. t.iceCandidateCount = 0,
  5792. t.onsignalingmessage = e.callback,
  5793. t.peerConnection.ontrack = function(e) {
  5794. t.onaddstream && (t.onaddstream(e, "ontrack"), t.peerConnection.onaddstream = null)
  5795. },
  5796. t.peerConnection.onaddstream = function(e) {
  5797. t.onaddstream && (t.onaddstream(e, "onaddstream"), t.peerConnection.ontrack = null)
  5798. },
  5799. t.peerConnection.onremovestream = function(e) {
  5800. t.onremovestream && t.onremovestream(e)
  5801. },
  5802. t.peerConnection.oniceconnectionstatechange = function(e) {
  5803. "connected" === e.currentTarget.iceConnectionState && (t.connectedTime = new Date),
  5804. t.oniceconnectionstatechange && t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)
  5805. },
  5806. t.renegotiate = function() {
  5807. void 0 !== t.prevOffer && t.peerConnection.createOffer().then((function(e) {
  5808. return e.sdp = e.sdp.replace(/a=recvonly\r\n/g, "a=inactive\r\n"),
  5809. e.sdp = u(e.sdp),
  5810. e.sdp = l(e.sdp),
  5811. t.peerConnection.setLocalDescription(e)
  5812. })).then((function() {
  5813. t.onnegotiationneeded && t.onnegotiationneeded(t.peerConnection.localDescription.sdp)
  5814. })).
  5815. catch((function(e) {
  5816. console.log("createOffer error: ", e)
  5817. }))
  5818. },
  5819. t.peerConnection.onnegotiationneeded = t.renegotiate,
  5820. t.onaddstream = null,
  5821. t.onremovestream = null,
  5822. t.onnegotiationneeded = null,
  5823. t.state = "new",
  5824. t.markActionNeeded(),
  5825. t
  5826. },
  5827. O = function(e) {
  5828. var t = {},
  5829. n = h.RTCPeerConnection;
  5830. t.uid = e.uid,
  5831. t.isVideoMute = e.isVideoMute,
  5832. t.isAudioMute = e.isAudioMute,
  5833. t.isSubscriber = e.isSubscriber,
  5834. t.clientId = e.clientId,
  5835. t.filterStatsCache = [],
  5836. t.originStatsCache = [],
  5837. t.lastTimeGetStats = null,
  5838. t.pc_config = {
  5839. iceServers: [{
  5840. urls: ["stun:webcs.agora.io:3478", "stun:stun.l.google.com:19302"]
  5841. }],
  5842. bundlePolicy: "max-bundle"
  5843. },
  5844. t.con = {
  5845. optional: [{
  5846. DtlsSrtpKeyAgreement: !0
  5847. }]
  5848. },
  5849. e.iceServers instanceof Array ? t.pc_config.iceServers = e.iceServers: (e.stunServerUrl && (e.stunServerUrl instanceof Array ? e.stunServerUrl.map((function(e) {
  5850. "string" == typeof e && "" !== e && t.pc_config.iceServers.push({
  5851. url: e
  5852. })
  5853. })) : "string" == typeof e.stunServerUrl && "" !== e.stunServerUrl && t.pc_config.iceServers.push({
  5854. url: e.stunServerUrl
  5855. })), e.turnServers && (e.turnServers instanceof Array ? e.turnServers.map((function(e) {
  5856. e.udpport && t.pc_config.iceServers.push({
  5857. username: e.username,
  5858. credential: e.credential,
  5859. credentialType: "password",
  5860. urls: "turn:" + e.url + ":" + e.udpport + "?transport=udp"
  5861. }),
  5862. "string" == typeof e.tcpport && "" !== e.tcpport && t.pc_config.iceServers.push({
  5863. username: e.username,
  5864. credential: e.credential,
  5865. credentialType: "password",
  5866. urls: "turn:" + e.url + ":" + e.tcpport + "?transport=tcp"
  5867. }),
  5868. !0 === e.forceturn && (t.pc_config.iceTransportPolicy = "relay")
  5869. })) : r.
  5870. default.error("[".concat(t.clientId, "] turnServers is not a array")))),
  5871. void 0 === e.audio && (e.audio = !0),
  5872. void 0 === e.video && (e.video = !0),
  5873. t.mediaConstraints = {
  5874. mandatory: {
  5875. OfferToReceiveVideo: e.video,
  5876. OfferToReceiveAudio: e.audio
  5877. }
  5878. },
  5879. t.roapSessionId = 103;
  5880. try {
  5881. t.pc_config.sdpSemantics = "plan-b",
  5882. t.peerConnection = new n(t.pc_config, t.con)
  5883. } catch(e) {
  5884. delete t.pc_config.sdpSemantics,
  5885. t.peerConnection = new n(t.pc_config, t.con)
  5886. }
  5887. t.iceCandidateTimer = setTimeout((function() {
  5888. t.iceCandidateTimer = null,
  5889. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  5890. }), Object(o.getParameter)("CANDIDATE_TIMEOUT")),
  5891. t.peerConnection.onicecandidate = function(e) {
  5892. var n, a, i, o;
  5893. a = (n = t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),
  5894. i = n.match(/a=candidate:.+typ\shost.+\r\n/),
  5895. o = n.match(/a=candidate:.+typ\srelay.+\r\n/),
  5896. 0 === t.iceCandidateCount && (t.timeout = setTimeout((function() {
  5897. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  5898. }), 1e3)),
  5899. 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()),
  5900. t.iceCandidateCount = t.iceCandidateCount + 1
  5901. };
  5902. var a = function(t) {
  5903. return e.screen && (t = t.replace("a=x-google-flag:conference\r\n", "")),
  5904. t
  5905. },
  5906. i = function(n) {
  5907. var a, i;
  5908. 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.
  5909. default.debug("[" + t.clientId + "]Set Video Bitrate - min:" + e.minVideoBW + " max:" + e.maxVideoBW)),
  5910. (a = n.match(/m=audio.*\r\n/)) && e.maxAudioBW && (i = a[0] + "b=AS:" + e.maxAudioBW + "\r\n", n = n.replace(a[0], i)),
  5911. n
  5912. };
  5913. t.processSignalingMessage = function(e) {
  5914. var n, o = JSON.parse(e);
  5915. t.incomingMessage = o,
  5916. "new" === t.state ? "OFFER" === o.messageType ? (n = {
  5917. sdp: o.sdp,
  5918. type: "offer"
  5919. },
  5920. 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 = {
  5921. sdp: o.sdp,
  5922. type: "answer"
  5923. }).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 = {
  5924. sdp: o.sdp,
  5925. type: "pr-answer"
  5926. },
  5927. 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 = {
  5928. sdp: o.sdp,
  5929. type: "offer"
  5930. },
  5931. t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)), t.state = "offer-received", t.markActionNeeded()) : "ANSWER" === o.messageType ? ((n = {
  5932. sdp: o.sdp,
  5933. type: "answer"
  5934. }).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))
  5935. };
  5936. var s = {
  5937. id: "",
  5938. type: "",
  5939. mediaType: "",
  5940. googCodecName: "opus",
  5941. aecDivergentFilterFraction: "0",
  5942. audioInputLevel: "0",
  5943. bytesSent: "0",
  5944. packetsSent: "0",
  5945. googEchoCancellationReturnLoss: "0",
  5946. googEchoCancellationReturnLossEnhancement: "0"
  5947. },
  5948. c = {
  5949. id: "",
  5950. type: "",
  5951. mediaType: "",
  5952. googCodecName: "h264" === e.codec ? "H264": "VP8",
  5953. bytesSent: "0",
  5954. packetsLost: "0",
  5955. packetsSent: "0",
  5956. googAdaptationChanges: "0",
  5957. googAvgEncodeMs: "0",
  5958. googEncodeUsagePercent: "0",
  5959. googFirsReceived: "0",
  5960. googFrameHeightSent: "0",
  5961. googFrameHeightInput: "0",
  5962. googFrameRateInput: "0",
  5963. googFrameRateSent: "0",
  5964. googFrameWidthSent: "0",
  5965. googFrameWidthInput: "0",
  5966. googNacksReceived: "0",
  5967. googPlisReceived: "0",
  5968. googRtt: "0",
  5969. googFramesEncoded: "0"
  5970. },
  5971. d = {
  5972. id: "",
  5973. type: "",
  5974. mediaType: "",
  5975. audioOutputLevel: "0",
  5976. bytesReceived: "0",
  5977. packetsLost: "0",
  5978. packetsReceived: "0",
  5979. googAccelerateRate: "0",
  5980. googCurrentDelayMs: "0",
  5981. googDecodingCNG: "0",
  5982. googDecodingCTN: "0",
  5983. googDecodingCTSG: "0",
  5984. googDecodingNormal: "0",
  5985. googDecodingPLC: "0",
  5986. googDecodingPLCCNG: "0",
  5987. googExpandRate: "0",
  5988. googJitterBufferMs: "0",
  5989. googJitterReceived: "0",
  5990. googPreemptiveExpandRate: "0",
  5991. googPreferredJitterBufferMs: "0",
  5992. googSecondaryDecodedRate: "0",
  5993. googSpeechExpandRate: "0"
  5994. },
  5995. u = {
  5996. id: "",
  5997. type: "",
  5998. mediaType: "",
  5999. googTargetDelayMs: "0",
  6000. packetsLost: "0",
  6001. googDecodeMs: "0",
  6002. googMaxDecodeMs: "0",
  6003. googRenderDelayMs: "0",
  6004. googFrameWidthReceived: "0",
  6005. googFrameHeightReceived: "0",
  6006. googFrameRateReceived: "0",
  6007. googFrameRateDecoded: "0",
  6008. googFrameRateOutput: "0",
  6009. googFramesDecoded: "0",
  6010. googFrameReceived: "0",
  6011. googJitterBufferMs: "0",
  6012. googCurrentDelayMs: "0",
  6013. googMinPlayoutDelayMs: "0",
  6014. googNacksSent: "0",
  6015. googPlisSent: "0",
  6016. googFirsSent: "0",
  6017. bytesReceived: "0",
  6018. packetsReceived: "0"
  6019. },
  6020. l = {
  6021. id: "bweforvideo",
  6022. type: "VideoBwe",
  6023. googAvailableSendBandwidth: "0",
  6024. googAvailableReceiveBandwidth: "0",
  6025. googActualEncBitrate: "0",
  6026. googRetransmitBitrate: "0",
  6027. googTargetEncBitrate: "0",
  6028. googBucketDelay: "0",
  6029. googTransmitBitrate: "0"
  6030. },
  6031. p = 0,
  6032. f = 0,
  6033. g = 0;
  6034. return t.isRemoteVideoStats = function(e) {
  6035. return !! (e.frameHeight && e.frameWidth && e.remoteSource)
  6036. },
  6037. t.getVideoRelatedStats = function(n) {
  6038. t.peerConnection.getStats().then((function(a) {
  6039. var i = {
  6040. peerId: t.uid,
  6041. mediaType: "video",
  6042. isVideoMute: t.isVideoMute
  6043. };
  6044. a.forEach((function(a) {
  6045. if (t.isSubscriber) {
  6046. if ("track" === a.type && (~a.id.indexOf("video") || ~a.trackIdentifier.indexOf("v") || t.isRemoteVideoStats(a))) {
  6047. if (!t.lastReport) return void(t.lastReport = a);
  6048. i.frameRateReceived = a.framesReceived - t.lastReport.framesReceived + "",
  6049. i.frameRateDecoded = a.framesDecoded - t.lastReport.framesDecoded + "",
  6050. t.lastReport = a
  6051. }
  6052. "inbound-rtp" === a.type && ~a.id.indexOf("Video") && (i.bytesReceived = a.bytesReceived + "", i.packetsReceived = a.packetsReceived + "", i.packetsLost = a.packetsLost + "")
  6053. } else if ("outbound-rtp" === a.type && ~a.id.indexOf("Video")) {
  6054. if (!t.lastReport) return void(t.lastReport = a);
  6055. n && n({
  6056. mediaType: "video",
  6057. isVideoMute: t.isVideoMute,
  6058. frameRateInput: e.maxFrameRate + "",
  6059. frameRateSent: a.framesEncoded - t.lastReport.framesEncoded + ""
  6060. }),
  6061. t.lastReport = a
  6062. }
  6063. })),
  6064. n && n(i)
  6065. }))
  6066. },
  6067. t.getAudioRelatedStats = function(e) {
  6068. t.peerConnection.getStats().then((function(n) {
  6069. n.forEach((function(n) {
  6070. t.isSubscriber && "inbound-rtp" === n.type && ~n.id.indexOf("Audio") && e && e({
  6071. peerId: t.uid,
  6072. mediaType: "audio",
  6073. isAudioMute: t.isAudioMute,
  6074. frameDropped: n.packetsLost + "",
  6075. frameReceived: n.packetsReceived + "",
  6076. googJitterReceived: n.jitter + "",
  6077. bytesReceived: n.bytesReceived + "",
  6078. packetsReceived: n.packetsReceived + "",
  6079. packetsLost: n.packetsLost + ""
  6080. })
  6081. }))
  6082. }))
  6083. },
  6084. t.getStatsRate = function(e) {
  6085. t.getStats((function(t) {
  6086. t.forEach((function(e) {
  6087. "outbound-rtp" === e.type && "video" === e.mediaType && e.googFramesEncoded && (e.googFrameRateSent = ((e.googFramesEncoded - p) / 3).toString(), p = e.googFramesEncoded),
  6088. "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))
  6089. })),
  6090. e(t)
  6091. }))
  6092. },
  6093. t.getStats = function(e, n) {
  6094. n = (n = n || 500) > 500 ? 500 : n,
  6095. t.lastTimeGetStats && Date.now() - t.lastTimeGetStats < n ? e && e(t.filterStatsCache, t.originStatsCache) : this._getStats((function(n, a) {
  6096. t.filterStatsCache = n,
  6097. t.originStatsCache = a,
  6098. t.lastTimeGetStats = Date.now(),
  6099. e && e(n, a)
  6100. }))
  6101. },
  6102. t._getStats = function(e) {
  6103. var n = [];
  6104. t.peerConnection.getStats().then((function(a) {
  6105. a.forEach((function(e) {
  6106. n.push(e),
  6107. "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"),
  6108. "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"),
  6109. "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"),
  6110. "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"),
  6111. "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"),
  6112. "track" !== e.type || -1 == e.id.indexOf("44444") && !~e.trackIdentifier.indexOf("a") && void 0 === e.audioLevel || (d.audioOutputLevel = e.audioLevel + "", s.audioInputLevel = e.audioLevel + ""),
  6113. "candidate-pair" === e.type && (0 == e.availableIncomingBitrate ? l.googAvailableSendBandwidth = e.availableOutgoingBitrate + "": l.googAvailableReceiveBandwidth = e.availableIncomingBitrate + "")
  6114. }));
  6115. var i = [l, s, c, d, u];
  6116. i.push({
  6117. id: "time",
  6118. startTime: t.connectedTime,
  6119. timestamp: new Date
  6120. }),
  6121. e(i, n)
  6122. })).
  6123. catch((function(e) {
  6124. r.
  6125. default.error("[" + t.clientId + "] ", e)
  6126. }))
  6127. },
  6128. t.addTrack = function(e, n) {
  6129. t.peerConnection.addTrack(e, n)
  6130. },
  6131. t.removeTrack = function(e, n) {
  6132. var a = t.peerConnection.getSenders().find((function(t) {
  6133. return t.track == e
  6134. }));
  6135. a.replaceTrack(null),
  6136. t.peerConnection.removeTrack(a)
  6137. },
  6138. t.addStream = function(e) {
  6139. window.navigator.userAgent.indexOf("Safari") > -1 && -1 === navigator.userAgent.indexOf("Chrome") ? e.getTracks().forEach((function(n) {
  6140. return t.peerConnection.addTrack(n, e)
  6141. })) : t.peerConnection.addStream(e),
  6142. t.markActionNeeded()
  6143. },
  6144. t.removeStream = function() {
  6145. t.markActionNeeded()
  6146. },
  6147. t.close = function() {
  6148. t.state = "closed",
  6149. t.peerConnection.close()
  6150. },
  6151. t.markActionNeeded = function() {
  6152. t.actionNeeded = !0,
  6153. t.doLater((function() {
  6154. t.onstablestate()
  6155. }))
  6156. },
  6157. t.doLater = function(e) {
  6158. window.setTimeout(e, 1)
  6159. },
  6160. t.onstablestate = function() {
  6161. var n;
  6162. if (t.actionNeeded) {
  6163. if ("new" === t.state || "established" === t.state) {
  6164. if (e.isSubscriber) t.peerConnection.addTransceiver("audio", {
  6165. direction: "recvonly"
  6166. }),
  6167. t.peerConnection.addTransceiver("video", {
  6168. direction: "recvonly"
  6169. });
  6170. t.peerConnection.createOffer(t.mediaConstraints).then((function(n) {
  6171. 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),
  6172. t.state = "preparing-offer",
  6173. void t.markActionNeeded();
  6174. r.
  6175. default.debug("[" + t.clientId + "]Not sending a new offer")
  6176. })).
  6177. catch((function(e) {
  6178. r.
  6179. default.debug("[" + t.clientId + "]peer connection create offer failed ", e)
  6180. }))
  6181. } else if ("preparing-offer" === t.state) {
  6182. if (t.moreIceComing) return;
  6183. t.prevOffer = t.peerConnection.localDescription.sdp,
  6184. t.offerCandidates = t.prevOffer.match(/a=candidate.+\r\n/g) || [],
  6185. t.offerCandidates.length || (r.
  6186. default.warning("[".concat(t.clientId, "]No Ice Candidate generated")), Object(o.getParameter)("SHIM_CANDIDATE") ? (r.
  6187. 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.
  6188. default.error("[".concat(t.clientId, "]None Ice Candidate not allowed"))),
  6189. 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"),
  6190. t.sendMessage("OFFER", t.prevOffer),
  6191. t.state = "offer-sent"
  6192. } else if ("offer-received" === t.state) t.peerConnection.createAnswer((function(e) {
  6193. if (t.peerConnection.setLocalDescription(e), t.state = "offer-received-preparing-answer", t.iceStarted) t.markActionNeeded();
  6194. else {
  6195. var n = new Date;
  6196. r.
  6197. default.debug("[" + t.clientId + "]" + n.getTime() + ": Starting ICE in responder"),
  6198. t.iceStarted = !0
  6199. }
  6200. }), (function(e) {
  6201. r.
  6202. default.debug("[" + t.clientId + "]peer connection create answer failed ", e)
  6203. }), t.mediaConstraints);
  6204. else if ("offer-received-preparing-answer" === t.state) {
  6205. if (t.moreIceComing) return;
  6206. n = t.peerConnection.localDescription.sdp,
  6207. t.sendMessage("ANSWER", n),
  6208. t.state = "established"
  6209. } else t.debug("Dazed and confused in state " + t.state + ", stopping here");
  6210. t.actionNeeded = !1
  6211. }
  6212. },
  6213. t.sendMessage = function(e, n) {
  6214. var a = {};
  6215. a.messageType = e,
  6216. a.sdp = n,
  6217. "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),
  6218. t.onsignalingmessage(JSON.stringify(a))
  6219. },
  6220. t._getSender = function(e) {
  6221. if (t.peerConnection && t.peerConnection.getSenders) {
  6222. var n = t.peerConnection.getSenders().find((function(t) {
  6223. return t.track.kind == e
  6224. }));
  6225. if (n) return n
  6226. }
  6227. return null
  6228. },
  6229. t.hasSender = function(e) {
  6230. return !! t._getSender(e)
  6231. },
  6232. t.replaceTrack = function(e, n, a) {
  6233. var i = t._getSender(e.kind);
  6234. if (!i) {
  6235. return a("NO_SENDER_FOUND")
  6236. }
  6237. try {
  6238. i.replaceTrack(e)
  6239. } catch(e) {
  6240. return a && a(e)
  6241. }
  6242. setTimeout((function() {
  6243. return n && n()
  6244. }), 50)
  6245. },
  6246. t.error = function(e) {
  6247. throw "Error in RoapOnJsep: " + e
  6248. },
  6249. t.sessionId = t.roapSessionId += 1,
  6250. t.sequenceNumber = 0,
  6251. t.actionNeeded = !1,
  6252. t.iceStarted = !1,
  6253. t.moreIceComing = !0,
  6254. t.iceCandidateCount = 0,
  6255. t.onsignalingmessage = e.callback,
  6256. t.peerConnection.ontrack = function(e) {
  6257. console.log("!!! ontrack, ", e.track.kind, e.track),
  6258. t.onaddstream && t.onaddstream(e, "ontrack")
  6259. },
  6260. t.peerConnection.onremovestream = function(e) {
  6261. t.onremovestream && t.onremovestream(e)
  6262. },
  6263. t.peerConnection.oniceconnectionstatechange = function(e) {
  6264. "connected" === e.currentTarget.iceConnectionState && (t.connectedTime = new Date),
  6265. t.oniceconnectionstatechange && t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)
  6266. },
  6267. t.renegotiate = function() {
  6268. void 0 !== t.prevOffer && t.peerConnection.createOffer().then((function(e) {
  6269. return e.sdp = e.sdp.replace(/a=recvonly\r\n/g, "a=inactive\r\n"),
  6270. e.sdp = a(e.sdp),
  6271. e.sdp = i(e.sdp),
  6272. t.peerConnection.setLocalDescription(e)
  6273. })).then((function() {
  6274. t.onnegotiationneeded && t.onnegotiationneeded(t.peerConnection.localDescription.sdp)
  6275. })).
  6276. catch((function(e) {
  6277. console.log("createOffer error: ", e)
  6278. }))
  6279. },
  6280. t.peerConnection.onnegotiationneeded = t.renegotiate,
  6281. t.onaddstream = null,
  6282. t.onremovestream = null,
  6283. t.state = "new",
  6284. t.markActionNeeded(),
  6285. t
  6286. };
  6287. function C(e) {
  6288. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  6289. if (Array.isArray(e) || (e = function(e, t) {
  6290. if (!e) return;
  6291. if ("string" == typeof e) return N(e, t);
  6292. var n = Object.prototype.toString.call(e).slice(8, -1);
  6293. "Object" === n && e.constructor && (n = e.constructor.name);
  6294. if ("Map" === n || "Set" === n) return Array.from(n);
  6295. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return N(e, t)
  6296. } (e))) {
  6297. var t = 0,
  6298. n = function() {};
  6299. return {
  6300. s: n,
  6301. n: function() {
  6302. return t >= e.length ? {
  6303. done: !0
  6304. }: {
  6305. done: !1,
  6306. value: e[t++]
  6307. }
  6308. },
  6309. e: function(e) {
  6310. throw e
  6311. },
  6312. f: n
  6313. }
  6314. }
  6315. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  6316. }
  6317. var a, i, o = !0,
  6318. r = !1;
  6319. return {
  6320. s: function() {
  6321. a = e[Symbol.iterator]()
  6322. },
  6323. n: function() {
  6324. var e = a.next();
  6325. return o = e.done,
  6326. e
  6327. },
  6328. e: function(e) {
  6329. r = !0,
  6330. i = e
  6331. },
  6332. f: function() {
  6333. try {
  6334. o || null == a.
  6335. return || a.
  6336. return ()
  6337. } finally {
  6338. if (r) throw i
  6339. }
  6340. }
  6341. }
  6342. }
  6343. function N(e, t) { (null == t || t > e.length) && (t = e.length);
  6344. for (var n = 0,
  6345. a = new Array(t); n < t; n++) a[n] = e[n];
  6346. return a
  6347. }
  6348. var w = function(e) {
  6349. var t = {},
  6350. n = (mozRTCPeerConnection, mozRTCSessionDescription),
  6351. a = !1;
  6352. t.uid = e.uid,
  6353. t.isVideoMute = e.isVideoMute,
  6354. t.isAudioMute = e.isAudioMute,
  6355. t.isSubscriber = e.isSubscriber,
  6356. t.clientId = e.clientId,
  6357. t.filterStatsCache = [],
  6358. t.originStatsCache = [],
  6359. t.lastTimeGetStats = null,
  6360. t.pc_config = {
  6361. iceServers: []
  6362. },
  6363. e.iceServers instanceof Array ? e.iceServers.map((function(e) {
  6364. 0 === e.url.indexOf("stun:") && t.pc_config.iceServers.push({
  6365. url: e.url
  6366. })
  6367. })) : (e.stunServerUrl && (e.stunServerUrl instanceof Array ? e.stunServerUrl.map((function(e) {
  6368. "string" == typeof e && "" !== e && t.pc_config.iceServers.push({
  6369. url: e
  6370. })
  6371. })) : "string" == typeof e.stunServerUrl && "" !== e.stunServerUrl && t.pc_config.iceServers.push({
  6372. url: e.stunServerUrl
  6373. })), e.turnServers && (e.turnServers instanceof Array ? e.turnServers.map((function(e) {
  6374. e.udpport && t.pc_config.iceServers.push({
  6375. username: e.username,
  6376. credential: e.credential,
  6377. credentialType: "password",
  6378. urls: "turn:" + e.url + ":" + e.udpport + "?transport=udp"
  6379. }),
  6380. "string" == typeof e.tcpport && "" !== e.tcpport && t.pc_config.iceServers.push({
  6381. username: e.username,
  6382. credential: e.credential,
  6383. credentialType: "password",
  6384. urls: "turn:" + e.url + ":" + e.tcpport + "?transport=tcp"
  6385. }),
  6386. !0 === e.forceturn && (t.pc_config.iceTransportPolicy = "relay")
  6387. })) : r.
  6388. default.error("[".concat(t.clientId, "] turnServers is not a array")))),
  6389. void 0 === e.audio && (e.audio = !0),
  6390. void 0 === e.video && (e.video = !0),
  6391. t.mediaConstraints = {
  6392. offerToReceiveAudio: e.audio,
  6393. offerToReceiveVideo: e.video,
  6394. mozDontOfferDataChannel: !0
  6395. },
  6396. t.roapSessionId = 103,
  6397. t.peerConnection = new h.RTCPeerConnection(t.pc_config),
  6398. t.iceCandidateTimer = setTimeout((function() {
  6399. t.iceCandidateTimer = null,
  6400. r.
  6401. default.debug("[".concat(t.clientId, "]Candidates collected: ").concat(t.iceCandidateCount)),
  6402. t.moreIceComing && (t.moreIceComing = !1, t.markActionNeeded())
  6403. }), Object(o.getParameter)("CANDIDATE_TIMEOUT")),
  6404. t.peerConnection.onicecandidate = function(e) {
  6405. var n, a, i, o;
  6406. a = (n = t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),
  6407. i = n.match(/a=candidate:.+typ\shost.+\r\n/),
  6408. o = n.match(/a=candidate:.+typ\srelay.+\r\n/),
  6409. 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()),
  6410. t.iceCandidateCount = t.iceCandidateCount + 1
  6411. },
  6412. t.checkMLineReverseInSDP = function(e) {
  6413. return ! (!~e.indexOf("m=audio") || !~e.indexOf("m=video")) && e.indexOf("m=audio") > e.indexOf("m=video")
  6414. },
  6415. t.reverseMLineInSDP = function(e) {
  6416. var t = e.split("m=audio"),
  6417. n = t[1].split("m=video"),
  6418. a = "m=video" + n[1],
  6419. i = "m=audio" + n[0];
  6420. return e = t[0] + a + i
  6421. },
  6422. t.processSignalingMessage = function(e) {
  6423. var a, i = JSON.parse(e);
  6424. t.incomingMessage = i,
  6425. "new" === t.state ? "OFFER" === i.messageType ? (i.sdp = l(i.sdp), a = {
  6426. sdp: i.sdp,
  6427. type: "offer"
  6428. },
  6429. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6430. r.
  6431. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6432. }), (function(e) {
  6433. r.
  6434. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e.name)
  6435. })), 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 = {
  6436. sdp: i.sdp,
  6437. type: "answer"
  6438. },
  6439. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6440. r.
  6441. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6442. }), (function(e) {
  6443. r.
  6444. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e)
  6445. })), t.state = "established") : "pr-answer" === i.messageType ? (a = {
  6446. sdp: i.sdp,
  6447. type: "pr-answer"
  6448. },
  6449. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6450. r.
  6451. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6452. }), (function(e) {
  6453. r.
  6454. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e.name)
  6455. }))) : "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 = {
  6456. sdp: i.sdp,
  6457. type: "offer"
  6458. },
  6459. t.peerConnection.setRemoteDescription(new n(a), (function() {
  6460. r.
  6461. default.debug("[" + t.clientId + "]setRemoteDescription succeeded")
  6462. }), (function(e) {
  6463. r.
  6464. default.info("[" + t.clientId + "]setRemoteDescription failed: " + e.name)
  6465. })), t.state = "offer-received", t.markActionNeeded()) : t.error("Illegal message for this state: " + i.messageType + " in state " + t.state))
  6466. };
  6467. var i = {
  6468. id: "",
  6469. type: "",
  6470. mediaType: "opus",
  6471. googCodecName: "opus",
  6472. aecDivergentFilterFraction: "0",
  6473. audioInputLevel: "0",
  6474. bytesSent: "0",
  6475. packetsSent: "0",
  6476. googEchoCancellationReturnLoss: "0",
  6477. googEchoCancellationReturnLossEnhancement: "0"
  6478. },
  6479. s = {
  6480. id: "",
  6481. type: "",
  6482. mediaType: "",
  6483. googCodecName: "h264" === e.codec ? "H264": "VP8",
  6484. bytesSent: "0",
  6485. packetsLost: "0",
  6486. packetsSent: "0",
  6487. googAdaptationChanges: "0",
  6488. googAvgEncodeMs: "0",
  6489. googEncodeUsagePercent: "0",
  6490. googFirsReceived: "0",
  6491. googFrameHeightSent: "0",
  6492. googFrameHeightInput: "0",
  6493. googFrameRateInput: "0",
  6494. googFrameRateSent: "0",
  6495. googFrameWidthSent: "0",
  6496. googFrameWidthInput: "0",
  6497. googNacksReceived: "0",
  6498. googPlisReceived: "0",
  6499. googRtt: "0"
  6500. },
  6501. c = {
  6502. id: "",
  6503. type: "",
  6504. mediaType: "",
  6505. audioOutputLevel: "0",
  6506. bytesReceived: "0",
  6507. packetsLost: "0",
  6508. packetsReceived: "0",
  6509. googAccelerateRate: "0",
  6510. googCurrentDelayMs: "0",
  6511. googDecodingCNG: "0",
  6512. googDecodingCTN: "0",
  6513. googDecodingCTSG: "0",
  6514. googDecodingNormal: "0",
  6515. googDecodingPLC: "0",
  6516. googDecodingPLCCNG: "0",
  6517. googExpandRate: "0",
  6518. googJitterBufferMs: "0",
  6519. googJitterReceived: "0",
  6520. googPreemptiveExpandRate: "0",
  6521. googPreferredJitterBufferMs: "0",
  6522. googSecondaryDecodedRate: "0",
  6523. googSpeechExpandRate: "0"
  6524. },
  6525. d = {
  6526. id: "",
  6527. type: "",
  6528. mediaType: "",
  6529. googTargetDelayMs: "0",
  6530. packetsLost: "0",
  6531. googDecodeMs: "0",
  6532. googMaxDecodeMs: "0",
  6533. googRenderDelayMs: "0",
  6534. googFrameWidthReceived: "0",
  6535. googFrameHeightReceived: "0",
  6536. googFrameRateReceived: "0",
  6537. googFrameRateDecoded: "0",
  6538. googFrameRateOutput: "0",
  6539. googJitterBufferMs: "0",
  6540. googCurrentDelayMs: "0",
  6541. googMinPlayoutDelayMs: "0",
  6542. googNacksSent: "0",
  6543. googPlisSent: "0",
  6544. googFirsSent: "0",
  6545. bytesReceived: "0",
  6546. packetsReceived: "0",
  6547. googFramesDecoded: "0"
  6548. },
  6549. u = 0;
  6550. t.getVideoRelatedStats = function(e) {
  6551. t.peerConnection.getStats().then((function(n) {
  6552. var a, i = C(n.values());
  6553. try {
  6554. for (i.s(); ! (a = i.n()).done;) {
  6555. var o = a.value;
  6556. if (t.isSubscriber) {
  6557. if (("inbound-rtp" === o.type || "inboundrtp" === o.type) && "video" === o.mediaType) {
  6558. if (!t.lastReport) return void(t.lastReport = o);
  6559. e && e({
  6560. browser: "firefox",
  6561. mediaType: "video",
  6562. peerId: t.uid,
  6563. isVideoMute: t.isVideoMute,
  6564. frameRateReceived: o.framerateMean + "",
  6565. frameRateDecoded: o.framesDecoded - t.lastReport.framesDecoded + "",
  6566. bytesReceived: o.bytesReceived + "",
  6567. packetsReceived: o.packetsReceived + "",
  6568. packetsLost: o.packetsLost + ""
  6569. }),
  6570. t.lastReport = o
  6571. }
  6572. } else if (("outbound-rtp" === o.type || "outboundrtp" === o.type) && "video" === o.mediaType) {
  6573. if (!t.lastReport) return void(t.lastReport = o);
  6574. e && e({
  6575. mediaType: "video",
  6576. isVideoMute: t.isVideoMute,
  6577. frameRateInput: o.framerateMean + "",
  6578. frameRateSent: o.framesEncoded - t.lastReport.framesEncoded + ""
  6579. }),
  6580. t.lastReport = o
  6581. }
  6582. }
  6583. } catch(e) {
  6584. i.e(e)
  6585. } finally {
  6586. i.f()
  6587. }
  6588. }))
  6589. },
  6590. t.getAudioRelatedStats = function(e) {
  6591. t.peerConnection.getStats().then((function(n) {
  6592. var a, i = C(n.values());
  6593. try {
  6594. for (i.s(); ! (a = i.n()).done;) {
  6595. var o = a.value;
  6596. t.isSubscriber && ("inbound-rtp" !== o.type && "inboundrtp" !== o.type || "audio" !== o.mediaType || e && e({
  6597. browser: "firefox",
  6598. mediaType: "audio",
  6599. peerId: t.uid,
  6600. isAudioMute: t.isAudioMute,
  6601. frameDropped: o.packetsLost + "",
  6602. frameReceived: o.packetsReceived + "",
  6603. googJitterReceived: o.jitter + "",
  6604. bytesReceived: o.bytesReceived + "",
  6605. packetsReceived: o.packetsReceived + "",
  6606. packetsLost: o.packetsLost + ""
  6607. }))
  6608. }
  6609. } catch(e) {
  6610. i.e(e)
  6611. } finally {
  6612. i.f()
  6613. }
  6614. }))
  6615. },
  6616. t.getStatsRate = function(e) {
  6617. t.getStats((function(t) {
  6618. t.forEach((function(e) {
  6619. "inbound-rtp" !== e.type && "inboundrtp" !== e.type || "video" !== e.mediaType || e.googFrameRateDecoded && (e.googFrameRateDecoded = ((e.googFramesDecoded - u) / 3).toString(), u = e.googFramesDecoded)
  6620. })),
  6621. e(t)
  6622. }))
  6623. },
  6624. t.getStats = function(e, n) {
  6625. n = (n = n || 500) > 500 ? 500 : n,
  6626. t.lastTimeGetStats && Date.now() - t.lastTimeGetStats < n ? e && e(t.filterStatsCache, t.originStatsCache) : this._getStats((function(n, a) {
  6627. t.filterStatsCache = n,
  6628. t.originStatsCache = a,
  6629. t.lastTimeGetStats = Date.now(),
  6630. e && e(n, a)
  6631. }))
  6632. },
  6633. t._getStats = function(e) {
  6634. t.peerConnection.getStats().then((function(n) {
  6635. var a, o = [],
  6636. r = C(n.values());
  6637. try {
  6638. for (r.s(); ! (a = r.n()).done;) {
  6639. var u = a.value;
  6640. o.push(u),
  6641. "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"),
  6642. "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"),
  6643. "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"),
  6644. "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"),
  6645. -1 !== u.id.indexOf("outbound_rtcp_video") && (s.packetsLost = u.packetsLost ? u.packetsLost + "": "0")
  6646. }
  6647. } catch(e) {
  6648. r.e(e)
  6649. } finally {
  6650. r.f()
  6651. }
  6652. var l = [s, i, c, d];
  6653. l.push({
  6654. id: "time",
  6655. startTime: t.connectedTime,
  6656. timestamp: new Date
  6657. }),
  6658. e(l, o)
  6659. }), (function(e) {
  6660. r.
  6661. default.error("[" + t.clientId + "]" + e)
  6662. }))
  6663. },
  6664. t.addStream = function(e) {
  6665. a = !0,
  6666. t.peerConnection.addStream(e),
  6667. t.markActionNeeded()
  6668. },
  6669. t.removeStream = function() {
  6670. t.markActionNeeded()
  6671. },
  6672. t.close = function() {
  6673. t.state = "closed",
  6674. t.peerConnection.close()
  6675. },
  6676. t.markActionNeeded = function() {
  6677. t.actionNeeded = !0,
  6678. t.doLater((function() {
  6679. t.onstablestate()
  6680. }))
  6681. },
  6682. t.doLater = function(e) {
  6683. window.setTimeout(e, 1)
  6684. },
  6685. t.onstablestate = function() {
  6686. if (t.actionNeeded) {
  6687. if ("new" === t.state || "established" === t.state) {
  6688. a && (t.mediaConstraints = void 0),
  6689. t.peerConnection.createOffer((function(e) {
  6690. 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),
  6691. t.state = "preparing-offer",
  6692. void t.markActionNeeded();
  6693. r.
  6694. default.debug("[" + t.clientId + "]Not sending a new offer")
  6695. }), (function(e) {
  6696. r.
  6697. default.debug("[" + t.clientId + "]Ups! create offer failed ", e)
  6698. }), t.mediaConstraints)
  6699. } else if ("preparing-offer" === t.state) {
  6700. if (t.moreIceComing) return;
  6701. t.prevOffer = t.peerConnection.localDescription.sdp,
  6702. t.offerCandidates = t.prevOffer.match(/a=candidate.+\r\n/g) || [],
  6703. t.offerCandidates.length || (r.
  6704. default.warning("[".concat(t.clientId, "]No Ice Candidate generated")), Object(o.getParameter)("SHIM_CANDIDATE") ? (r.
  6705. 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.
  6706. default.error("[".concat(t.clientId, "]None Ice Candidate not allowed"))),
  6707. 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"),
  6708. t.sendMessage("OFFER", t.prevOffer),
  6709. t.state = "offer-sent"
  6710. } else if ("offer-received" === t.state) t.peerConnection.createAnswer((function(e) {
  6711. if (t.peerConnection.setLocalDescription(e), t.state = "offer-received-preparing-answer", t.iceStarted) t.markActionNeeded();
  6712. else {
  6713. var n = new Date;
  6714. r.
  6715. default.debug("[" + t.clientId + "]" + n.getTime() + ": Starting ICE in responder"),
  6716. t.iceStarted = !0
  6717. }
  6718. }), (function() {
  6719. r.
  6720. default.debug("[" + t.clientId + "]Ups! Something went wrong")
  6721. }));
  6722. else if ("offer-received-preparing-answer" === t.state) {
  6723. if (t.moreIceComing) return;
  6724. var e = t.peerConnection.localDescription.sdp;
  6725. t.sendMessage("ANSWER", e),
  6726. t.state = "established"
  6727. } else t.debug("Dazed and confused in state " + t.state + ", stopping here");
  6728. t.actionNeeded = !1
  6729. }
  6730. },
  6731. t.sendMessage = function(e, n) {
  6732. var a = {};
  6733. a.messageType = e,
  6734. a.sdp = n,
  6735. "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),
  6736. t.onsignalingmessage(JSON.stringify(a))
  6737. },
  6738. t._getSender = function(e) {
  6739. if (t.peerConnection && t.peerConnection.getSenders) {
  6740. var n = t.peerConnection.getSenders().find((function(t) {
  6741. return t.track.kind == e
  6742. }));
  6743. if (n) return n
  6744. }
  6745. return null
  6746. },
  6747. t.hasSender = function(e) {
  6748. return !! t._getSender(e)
  6749. },
  6750. t.replaceTrack = function(e, n, a) {
  6751. var i = t._getSender(e.kind);
  6752. if (!i) {
  6753. return a("NO_SENDER_FOUND")
  6754. }
  6755. try {
  6756. i.replaceTrack(e)
  6757. } catch(e) {
  6758. return a && a(e)
  6759. }
  6760. setTimeout((function() {
  6761. return n && n()
  6762. }), 50)
  6763. },
  6764. t.error = function(e) {
  6765. throw "Error in RoapOnJsep: " + e
  6766. },
  6767. t.sessionId = t.roapSessionId += 1,
  6768. t.sequenceNumber = 0,
  6769. t.actionNeeded = !1,
  6770. t.iceStarted = !1,
  6771. t.moreIceComing = !0,
  6772. t.iceCandidateCount = 0,
  6773. t.onsignalingmessage = e.callback,
  6774. t.peerConnection.ontrack = function(e) {
  6775. t.onaddstream && t.onaddstream(e, "ontrack")
  6776. },
  6777. t.peerConnection.onremovestream = function(e) {
  6778. t.onremovestream && t.onremovestream(e)
  6779. },
  6780. t.peerConnection.oniceconnectionstatechange = function(e) {
  6781. "connected" === e.currentTarget.iceConnectionState && (t.connectedTime = new Date),
  6782. t.oniceconnectionstatechange && t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)
  6783. };
  6784. var l = function(t) {
  6785. var n;
  6786. if (e.video && e.maxVideoBW && (null == (n = t.match(/m=video.*\r\n/)) && (n = t.match(/m=video.*\n/)), n && n.length > 0)) {
  6787. var a = n[0] + "b=TIAS:" + 1e3 * e.maxVideoBW + "\r\n";
  6788. t = t.replace(n[0], a)
  6789. }
  6790. if (e.audio && e.maxAudioBW && (null == (n = t.match(/m=audio.*\r\n/)) && (n = t.match(/m=audio.*\n/)), n && n.length > 0)) {
  6791. a = n[0] + "b=TIAS:" + 1e3 * e.maxAudioBW + "\r\n";
  6792. t = t.replace(n[0], a)
  6793. }
  6794. return t
  6795. };
  6796. return t.onaddstream = null,
  6797. t.onremovestream = null,
  6798. t.state = "new",
  6799. t.markActionNeeded(),
  6800. t
  6801. },
  6802. D = a(24),
  6803. k = a.n(D),
  6804. L = null,
  6805. P = function() {
  6806. try {
  6807. L = window.require("electron")
  6808. } catch(e) {}
  6809. return L
  6810. },
  6811. M = function(e) {
  6812. var t = s.b.reportApiInvoke(null, {
  6813. callback: e,
  6814. name: "getScreenSources",
  6815. options: arguments,
  6816. tag: "tracer"
  6817. }),
  6818. n = P();
  6819. if (!n) return t && t("electron is null");
  6820. try {
  6821. var a = n.desktopCapturer.getSources({
  6822. types: ["window", "screen"]
  6823. })
  6824. } catch(e) {
  6825. console.log(e)
  6826. }
  6827. if (a instanceof Promise) console.log("electron.desktopCapturer.getSources return type is Promise"),
  6828. a.then((function(e) {
  6829. return t && t(null, e)
  6830. })).
  6831. catch((function(e) {
  6832. return t && t(e)
  6833. }));
  6834. else a = n.desktopCapturer.getSources({
  6835. types: ["window", "screen"]
  6836. },
  6837. (function(e, n) {
  6838. console.log("electron.desktopCapturer.getSources return type is callback"),
  6839. t && t(null, n)
  6840. }))
  6841. },
  6842. U = function(e, t, n) {
  6843. var a = t.width;
  6844. t = {
  6845. audio: !1,
  6846. video: {
  6847. mandatory: {
  6848. chromeMediaSource: "desktop",
  6849. chromeMediaSourceId: e,
  6850. maxHeight: t.height,
  6851. maxWidth: a,
  6852. maxFrameRate: t.frameRate && t.frameRate.max,
  6853. minFrameRate: t.frameRate && t.frameRate.min
  6854. }
  6855. }
  6856. };
  6857. navigator.webkitGetUserMedia(t, (function(e) {
  6858. n && n(null, e)
  6859. }), (function(e) {
  6860. n && n(e)
  6861. }))
  6862. },
  6863. x = function() {
  6864. return !! P()
  6865. },
  6866. V = M,
  6867. j = U,
  6868. B = function(e, t) {
  6869. M((function(n, a) {
  6870. if (n) return t && t(n); !
  6871. function(e, t) {
  6872. var n = document.createElement("div");
  6873. n.innerText = "share screen",
  6874. n.setAttribute("style", "text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;");
  6875. var a = document.createElement("div");
  6876. a.setAttribute("style", "width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;");
  6877. var i = document.createElement("div");
  6878. i.innerText = "Agora Web Screensharing wants to share the contents of your screen with webdemo.agorabeckon.com. Choose what you'd like to share.",
  6879. i.setAttribute("style", "height: 12%;");
  6880. var o = document.createElement("div");
  6881. 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;");
  6882. var r = document.createElement("div");
  6883. r.setAttribute("style", "text-align: right; padding: 16px 0;");
  6884. var s = document.createElement("button");
  6885. s.innerHTML = "cancel",
  6886. s.setAttribute("style", "width: 85px;"),
  6887. s.onclick = function() {
  6888. document.body.removeChild(c),
  6889. t && t("NotAllowedError")
  6890. },
  6891. r.appendChild(s),
  6892. a.appendChild(i),
  6893. a.appendChild(o),
  6894. a.appendChild(r);
  6895. var c = document.createElement("div");
  6896. 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%);"),
  6897. c.appendChild(n),
  6898. c.appendChild(a),
  6899. document.body.appendChild(c),
  6900. e.map((function(e) {
  6901. if (e.id) {
  6902. var n = document.createElement("div");
  6903. n.setAttribute("style", "width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;"),
  6904. 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>",
  6905. n.onclick = function() {
  6906. document.body.removeChild(c),
  6907. t && t(null, e.id)
  6908. },
  6909. o.appendChild(n)
  6910. }
  6911. }))
  6912. } (a, (function(n, a) {
  6913. if (n) return t && t(n);
  6914. U(a, e, t)
  6915. }))
  6916. }))
  6917. },
  6918. F = 103,
  6919. W = function(e) {
  6920. var t = {};
  6921. if (t.clientId = e.clientId, e.session_id = F += 1, "undefined" == typeof window || !window.navigator) throw r.
  6922. default.error("[" + t.streamId + "][" + t.clientId + "]Publish/subscribe video/audio streams not supported yet"),
  6923. new Error("NON_BROWSER_ENV_DETECTED");
  6924. return null !== window.navigator.userAgent.match("Firefox") ? (t.browser = "mozilla", t = w(e)) : "iOS" === g.getBrowserOS() || g.isSafari() ? (r.
  6925. 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",
  6926. t
  6927. },
  6928. G = function(e, t, n) {
  6929. var a = {};
  6930. a.config = e,
  6931. a.streamId = e.streamId,
  6932. delete e.streamId,
  6933. navigator.getMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  6934. var i = 0,
  6935. o = 1,
  6936. s = !1,
  6937. c = null,
  6938. d = function(e) {
  6939. if (i++, c) if (c === e) r.
  6940. default.debug("Using Video Source/ Audio Source");
  6941. else {
  6942. var n = c.getVideoTracks()[0],
  6943. a = c.getAudioTracks()[0],
  6944. d = e.getVideoTracks()[0],
  6945. u = e.getAudioTracks()[0];
  6946. d && (n && c.removeTrack(n), c.addTrack(d)),
  6947. u && (a && c.removeTrack(a), c.addTrack(u))
  6948. } else c = e;
  6949. i !== o || s || (s = !0, setTimeout((function() {
  6950. t(c)
  6951. }), 0))
  6952. },
  6953. u = function(e) {
  6954. r.
  6955. default.error("Failed to GetUserMedia", e.name, e.code, e.message, e),
  6956. i++,
  6957. s || (s = !0, setTimeout((function() {
  6958. n && n(e)
  6959. }), 0))
  6960. },
  6961. l = function() {
  6962. var t = {
  6963. video: e.video,
  6964. audio: e.audio
  6965. };
  6966. if (r.
  6967. default.debug("GetUserMedia", JSON.stringify(t)), navigator.mediaDevices && navigator.mediaDevices.getUserMedia) navigator.mediaDevices.getUserMedia(t).then(d).
  6968. catch(u);
  6969. else if ("undefined" != typeof navigator && navigator.getMedia) navigator.getMedia(e, d, u);
  6970. else {
  6971. var i = {
  6972. name: "MEDIA_NOT_SUPPORT",
  6973. message: "Video/audio streams not supported yet"
  6974. };
  6975. r.
  6976. default.error("[" + a.streamId + "]" + i.message),
  6977. n && n(i)
  6978. }
  6979. };
  6980. 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) {
  6981. if (!e.screen && e.screenAudio) return n && n({
  6982. code: "Set screen to true before sharing the audio"
  6983. });
  6984. if (e.screen) {
  6985. if (x()) return e.screen.sourceId ? j(e.screen.sourceId, e.screen, (function(t, n) {
  6986. t ? u(t) : (e.audio && (o++, l()), d(n))
  6987. })) : B(e.screen, (function(t, n) {
  6988. t ? u(t) : (e.audio && (o++, l()), d(n))
  6989. }));
  6990. if (g.isFireFox()) {
  6991. r.
  6992. default.debug("[" + a.streamId + "]Screen access requested");
  6993. if (!~ ["screen", "window", "application"].indexOf(e.screen.mediaSource)) return n && n({
  6994. code: "Invalid mediaSource, mediaSource should be one of [screen, window, application]"
  6995. });
  6996. navigator.getMedia({
  6997. video: e.screen
  6998. },
  6999. (function(t) {
  7000. e.audio && (o++, l()),
  7001. d(t)
  7002. }), u)
  7003. } else if (g.isChromeKernel() && e.screen.extensionId) {
  7004. if (window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1] < 34) return void n({
  7005. code: "This browser does not support screen sharing"
  7006. });
  7007. r.
  7008. default.debug("[" + a.streamId + "]Screen access on chrome stable, looking for extension");
  7009. try {
  7010. chrome.runtime.sendMessage(e.screen.extensionId, {
  7011. getStream: !0
  7012. },
  7013. (function(t) {
  7014. if (void 0 === t) {
  7015. r.
  7016. default.error("[" + a.streamId + "]No response from Chrome Plugin. Plugin not installed properly");
  7017. u({
  7018. name: "PluginNotInstalledProperly",
  7019. message: "No response from Chrome Plugin. Plugin not installed properly."
  7020. })
  7021. } else e.screen.mandatory.chromeMediaSourceId = t.streamId,
  7022. navigator.getMedia({
  7023. video: e.screen
  7024. },
  7025. (function(t) {
  7026. e.audio && (o++, l()),
  7027. d(t)
  7028. }), u)
  7029. }))
  7030. } catch(e) {
  7031. r.
  7032. default.debug("[" + a.streamId + "]AgoraRTC screensharing plugin is not accessible");
  7033. return void n({
  7034. code: "no_plugin_present"
  7035. })
  7036. }
  7037. } else {
  7038. if (window.navigator.mediaDevices.getDisplayMedia) {
  7039. var p = {};
  7040. return "number" == typeof e.screen.width && "number" == typeof e.screen.height ? p.video = {
  7041. width: {
  7042. ideal: e.screen.width
  7043. },
  7044. height: {
  7045. ideal: e.screen.height
  7046. }
  7047. }: p.video = {
  7048. width: e.screen.width,
  7049. height: e.screen.height
  7050. },
  7051. e.screen.frameRate && e.screen.frameRate.min ? p.video.frameRate = {
  7052. ideal: e.screen.frameRate.max,
  7053. max: e.screen.frameRate.max
  7054. }: p.video.frameRate = e.screen.frameRate,
  7055. e.screenAudio && (p.audio = e.screenAudio),
  7056. r.
  7057. default.debug("use getDisplayMedia, constraints:", p),
  7058. window.navigator.mediaDevices.getDisplayMedia(p).then((function(t) { ! e.screenAudio && e.audio && (o++, l()),
  7059. d(t)
  7060. })).
  7061. catch(u)
  7062. }
  7063. r.
  7064. default.error("[" + a.streamId + "]This browser does not support screenSharing"),
  7065. n({
  7066. code: "This browser does not support screen sharing"
  7067. })
  7068. }
  7069. } else l()
  7070. } else d(c)
  7071. },
  7072. H = a(10),
  7073. q = function(e, t, n) {
  7074. 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
  7075. };
  7076. function J(e) {
  7077. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  7078. if (Array.isArray(e) || (e = function(e, t) {
  7079. if (!e) return;
  7080. if ("string" == typeof e) return Y(e, t);
  7081. var n = Object.prototype.toString.call(e).slice(8, -1);
  7082. "Object" === n && e.constructor && (n = e.constructor.name);
  7083. if ("Map" === n || "Set" === n) return Array.from(n);
  7084. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Y(e, t)
  7085. } (e))) {
  7086. var t = 0,
  7087. n = function() {};
  7088. return {
  7089. s: n,
  7090. n: function() {
  7091. return t >= e.length ? {
  7092. done: !0
  7093. }: {
  7094. done: !1,
  7095. value: e[t++]
  7096. }
  7097. },
  7098. e: function(e) {
  7099. throw e
  7100. },
  7101. f: n
  7102. }
  7103. }
  7104. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  7105. }
  7106. var a, i, o = !0,
  7107. r = !1;
  7108. return {
  7109. s: function() {
  7110. a = e[Symbol.iterator]()
  7111. },
  7112. n: function() {
  7113. var e = a.next();
  7114. return o = e.done,
  7115. e
  7116. },
  7117. e: function(e) {
  7118. r = !0,
  7119. i = e
  7120. },
  7121. f: function() {
  7122. try {
  7123. o || null == a.
  7124. return || a.
  7125. return ()
  7126. } finally {
  7127. if (r) throw i
  7128. }
  7129. }
  7130. }
  7131. }
  7132. function Y(e, t) { (null == t || t > e.length) && (t = e.length);
  7133. for (var n = 0,
  7134. a = new Array(t); n < t; n++) a[n] = e[n];
  7135. return a
  7136. }
  7137. var K = new
  7138. function() {
  7139. var e = c();
  7140. return e.devicesHistory = {},
  7141. e.states = {
  7142. UNINIT: "UNINIT",
  7143. INITING: "INITING",
  7144. INITED: "INITED"
  7145. },
  7146. e.state = e.states.UNINIT,
  7147. e.deviceStates = {
  7148. ACTIVE: "ACTIVE",
  7149. INACTIVE: "INACTIVE"
  7150. },
  7151. e.deviceReloadTimer = null,
  7152. e._init = function(t, n) {
  7153. e.state = e.states.INITING,
  7154. e.devicesHistory = {},
  7155. e._reloadDevicesInfo((function() {
  7156. e.state = e.states.INITED,
  7157. e.dispatchEvent({
  7158. type: "inited"
  7159. }),
  7160. t && t()
  7161. }), (function(t) {
  7162. r.
  7163. default.warning("Device Detection functionality cannot start properly."),
  7164. e.state = e.states.UNINIT,
  7165. n && n(t)
  7166. }))
  7167. },
  7168. e._enumerateDevices = function(e, t) {
  7169. if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) return r.
  7170. default.warning("enumerateDevices() not supported."),
  7171. t && t("enumerateDevices() not supported");
  7172. navigator.mediaDevices.enumerateDevices().then((function(t) {
  7173. e && setTimeout((function() {
  7174. e(t)
  7175. }), 0)
  7176. })).
  7177. catch((function(e) {
  7178. t && t(e)
  7179. }))
  7180. },
  7181. e._reloadDevicesInfo = function(t, n) {
  7182. var a = [];
  7183. e._enumerateDevices((function(n) {
  7184. var i = Date.now();
  7185. for (var o in n.forEach((function(t) {
  7186. var n = e.devicesHistory[t.deviceId];
  7187. if ((n ? n.state: e.deviceStates.INACTIVE) != e.deviceStates.ACTIVE) {
  7188. var o = n || {
  7189. initAt: i
  7190. };
  7191. o.device = t,
  7192. o.state = e.deviceStates.ACTIVE,
  7193. a.push(o),
  7194. e.devicesHistory[t.deviceId] = o
  7195. }
  7196. e.devicesHistory[t.deviceId].lastReloadAt = i
  7197. })), e.devicesHistory) {
  7198. var s = e.devicesHistory[o];
  7199. s && s.state == e.deviceStates.ACTIVE && s.lastReloadAt !== i && (s.state = e.deviceStates.INACTIVE, a.push(s)),
  7200. s.lastReloadAt = i
  7201. }
  7202. e.state == e.states.INITED && a.forEach((function(t) {
  7203. var n = E()({},
  7204. t);
  7205. switch (t.device.kind) {
  7206. case "audioinput":
  7207. n.type = "recordingDeviceChanged";
  7208. break;
  7209. case "audiooutput":
  7210. n.type = "playoutDeviceChanged";
  7211. break;
  7212. case "videoinput":
  7213. n.type = "cameraChanged";
  7214. break;
  7215. default:
  7216. r.
  7217. default.warning("Unknown device change", n),
  7218. n.type = "unknownDeviceChanged"
  7219. }
  7220. e.dispatchEvent(n)
  7221. })),
  7222. t && t()
  7223. }), n)
  7224. },
  7225. e.getDeviceById = function(t, n, a) {
  7226. e.getDevices((function(e) {
  7227. for (var i = 0; i < e.length; i++) {
  7228. var o = e[i];
  7229. if (o && o.deviceId === t) return n && n(o)
  7230. }
  7231. return a && a()
  7232. }))
  7233. },
  7234. e.searchDeviceNameById = function(t) {
  7235. var n = e.devicesHistory[t];
  7236. return n ? n.device.label || n.device.deviceId: null
  7237. },
  7238. e.getDevices = function(t, n) {
  7239. e._enumerateDevices(t, (function(e) {
  7240. n && n(e.name + ": " + e.message)
  7241. }))
  7242. },
  7243. e.getVideoCameraIdByLabel = function(t, n, a) {
  7244. e.getCameras((function(e) {
  7245. var i, o = J(e);
  7246. try {
  7247. for (o.s(); ! (i = o.n()).done;) {
  7248. var r = i.value;
  7249. if (r.label === t) return n && n(r.deviceId)
  7250. }
  7251. } catch(e) {
  7252. o.e(e)
  7253. } finally {
  7254. o.f()
  7255. }
  7256. return a && a(I.
  7257. default.NOT_FIND_DEVICE_BY_LABEL)
  7258. }), a)
  7259. },
  7260. e.getRecordingDevices = function(t, n) {
  7261. return e._enumerateDevices((function(e) {
  7262. var n = e.filter((function(e) {
  7263. return "audioinput" == e.kind
  7264. }));
  7265. t && t(n)
  7266. }), (function(e) {
  7267. n && n(e)
  7268. }))
  7269. },
  7270. e.getPlayoutDevices = function(t, n) {
  7271. return e._enumerateDevices((function(e) {
  7272. var n = e.filter((function(e) {
  7273. return "audiooutput" == e.kind
  7274. }));
  7275. t && t(n)
  7276. }), (function(e) {
  7277. n && n(e)
  7278. }))
  7279. },
  7280. e.getCameras = function(t, n) {
  7281. return e._enumerateDevices((function(e) {
  7282. var n = e.filter((function(e) {
  7283. return "videoinput" == e.kind
  7284. }));
  7285. t && t(n)
  7286. }), (function(e) {
  7287. n && n(e)
  7288. }))
  7289. },
  7290. e._init((function() {
  7291. navigator.mediaDevices && navigator.mediaDevices.addEventListener && navigator.mediaDevices.addEventListener("devicechange", (function() {
  7292. e._reloadDevicesInfo()
  7293. })),
  7294. e.deviceReloadTimer = setInterval(e._reloadDevicesInfo, 5e3)
  7295. })),
  7296. e
  7297. },
  7298. z = a(1),
  7299. X = a(14);
  7300. var Q = a(7),
  7301. Z = a.n(Q),
  7302. $ = a(12),
  7303. ee = a.n($),
  7304. te = a(25),
  7305. ne = a.n(te),
  7306. ae = a(26),
  7307. ie = a.n(ae),
  7308. 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];
  7309. function re(e) {
  7310. 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;
  7311. for (var c = 0,
  7312. d = 0; d < 256; d++) {
  7313. var u = [r[c = (c + r[d] + t[d % n]) % 256], r[d]];
  7314. r[d] = u[0],
  7315. r[c] = u[1]
  7316. }
  7317. var l, p = 0;
  7318. c = 0;
  7319. for (var f = 0; f < 0 + i; f++) {
  7320. var g = [r[c = (c + r[p = (p + 1) % 256]) % 256], r[p]];
  7321. r[p] = g[0],
  7322. r[c] = g[1],
  7323. l = r[(r[p] + r[c]) % 256],
  7324. f >= 0 && (o[f - 0] = a[f - 0] ^ l)
  7325. }
  7326. var m = String.fromCharCode.apply(null, o);
  7327. return Function("var winSize = 5; return `" + m + "`")()
  7328. }
  7329. function se(e, t) {
  7330. var n = re(t),
  7331. a = ie.a.createProgramFromSources(e, [re(oe), n]),
  7332. i = e.getAttribLocation(a, "a_position"),
  7333. o = e.createBuffer();
  7334. e.bindBuffer(e.ARRAY_BUFFER, o),
  7335. e.bufferData(e.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), e.STATIC_DRAW),
  7336. e.enableVertexAttribArray(i);
  7337. var r = 2,
  7338. s = e.FLOAT,
  7339. c = !1,
  7340. d = 0,
  7341. u = 0;
  7342. e.vertexAttribPointer(i, r, s, c, d, u);
  7343. var l = e.getAttribLocation(a, "a_texCoord"),
  7344. p = e.createBuffer();
  7345. e.bindBuffer(e.ARRAY_BUFFER, p),
  7346. e.bufferData(e.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), e.STATIC_DRAW),
  7347. e.enableVertexAttribArray(l);
  7348. r = 2,
  7349. s = e.FLOAT,
  7350. c = !1,
  7351. d = 0,
  7352. u = 0;
  7353. return e.vertexAttribPointer(l, r, s, c, d, u),
  7354. a
  7355. }
  7356. 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];
  7357. function de(e, t, n) {
  7358. var a = e.gl;
  7359. this.program = se(a, ce),
  7360. this.setUniforms = function() {
  7361. a.getUniformLocation(this.program, "u_image");
  7362. var e = a.getUniformLocation(this.program, "u_flipY");
  7363. a.uniform1f(e, 1)
  7364. }
  7365. }
  7366. 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];
  7367. function le(e, t, n) {
  7368. var a = e.gl,
  7369. i = 1 / t,
  7370. o = 1 / n,
  7371. r = 5;
  7372. this.program = se(a, ue),
  7373. this.setUniforms = function() {
  7374. a.getUniformLocation(this.program, "u_image");
  7375. var e = a.getUniformLocation(this.program, "u_flipY"),
  7376. t = a.getUniformLocation(this.program, "u_singleStepOffset"),
  7377. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7378. a.uniform2f(t, i, o),
  7379. a.uniform1f(n, r),
  7380. a.uniform1f(e, 1)
  7381. },
  7382. this.setParameters = function(e) {
  7383. void 0 !== e.denoiseLevel && (r = e.denoiseLevel)
  7384. },
  7385. this.setSize = function(e, t) {
  7386. i = 1 / e,
  7387. o = 1 / t
  7388. }
  7389. }
  7390. 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];
  7391. function fe(e, t, n) {
  7392. var a = e.gl,
  7393. i = 1 / t,
  7394. o = 1 / n,
  7395. r = 5;
  7396. this.program = se(a, pe),
  7397. this.setUniforms = function() {
  7398. a.getUniformLocation(this.program, "u_image");
  7399. var e = a.getUniformLocation(this.program, "u_flipY"),
  7400. t = a.getUniformLocation(this.program, "u_singleStepOffset"),
  7401. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7402. a.uniform2f(t, i, o),
  7403. a.uniform1f(n, r),
  7404. a.uniform1f(e, 1)
  7405. },
  7406. this.setParameters = function(e) {
  7407. void 0 !== e.denoiseLevel && (r = e.denoiseLevel)
  7408. },
  7409. this.setSize = function(e, t) {
  7410. i = 1 / e,
  7411. o = 1 / t
  7412. }
  7413. }
  7414. 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];
  7415. function me(e, t, n) {
  7416. var a = e.gl,
  7417. i = 1 / t,
  7418. o = 1 / n,
  7419. r = 5;
  7420. this.program = se(a, ge),
  7421. this.setUniforms = function() {
  7422. a.getUniformLocation(this.program, "u_image");
  7423. var e = a.getUniformLocation(this.program, "u_flipY"),
  7424. t = a.getUniformLocation(this.program, "u_singleStepOffset"),
  7425. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7426. a.uniform2f(t, i, o),
  7427. a.uniform1f(n, r),
  7428. a.uniform1f(e, 1)
  7429. },
  7430. this.setParameters = function(e) {
  7431. void 0 !== e.denoiseLevel && (r = e.denoiseLevel)
  7432. },
  7433. this.setSize = function(e, t) {
  7434. i = 1 / e,
  7435. o = 1 / t
  7436. }
  7437. }
  7438. 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];
  7439. function Se(e, t, n) {
  7440. var a = e.gl,
  7441. i = 5,
  7442. o = .1,
  7443. r = .5,
  7444. s = 175 / 180 * 3.141593,
  7445. c = 115 / 180 * 3.141593,
  7446. d = 173 / 180 * 3.141593,
  7447. u = 116 / 180 * 3.141593,
  7448. l = 2.04203545,
  7449. p = 0,
  7450. f = 0,
  7451. g = 0,
  7452. m = [],
  7453. 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],
  7454. 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],
  7455. 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];
  7456. this.program = se(a, ve),
  7457. this.setUniforms = function() {
  7458. var t = a.getUniformLocation(this.program, "u_flipY"),
  7459. n = a.getUniformLocation(this.program, "u_denoiseLevel");
  7460. a.uniform1f(n, i),
  7461. a.uniform1f(t, 1);
  7462. var v = a.getUniformLocation(this.program, "light");
  7463. a.uniform1f(v, o);
  7464. var S = a.getUniformLocation(this.program, "redness");
  7465. a.uniform1f(S, r);
  7466. var E = a.getUniformLocation(this.program, "skin_he_max"),
  7467. _ = a.getUniformLocation(this.program, "skin_he_min"),
  7468. h = a.getUniformLocation(this.program, "skin_hc_max"),
  7469. I = a.getUniformLocation(this.program, "skin_hc_min"),
  7470. b = a.getUniformLocation(this.program, "skin_hc_axis"),
  7471. T = a.getUniformLocation(this.program, "facts_rotate_c"),
  7472. R = a.getUniformLocation(this.program, "facts_rotate_le"),
  7473. A = a.getUniformLocation(this.program, "facts_rotate_ge");
  7474. a.uniform1f(E, s),
  7475. a.uniform1f(_, c),
  7476. a.uniform1f(h, d),
  7477. a.uniform1f(I, u),
  7478. a.uniform1f(b, l),
  7479. a.uniform1f(T, p),
  7480. a.uniform1f(R, f),
  7481. a.uniform1f(A, g);
  7482. var y = a.getUniformLocation(this.program, "u_originImage");
  7483. a.activeTexture(a.TEXTURE2),
  7484. a.bindTexture(a.TEXTURE_2D, e.inputTexture),
  7485. a.uniform1i(y, 2);
  7486. for (var O = ["lighten_lut"], C = [a.TEXTURE3], N = 0; N < O.length; N++) {
  7487. var w = a.getUniformLocation(this.program, O[N]);
  7488. a.activeTexture(C[N]),
  7489. a.bindTexture(a.TEXTURE_2D, m[N]),
  7490. a.uniform1i(w, N + 3)
  7491. }
  7492. },
  7493. this.setParameters = function(e) {
  7494. void 0 !== e.denoiseLevel && (i = e.denoiseLevel),
  7495. void 0 !== e.lightLevel && (o = e.lightLevel),
  7496. void 0 !== e.rednessLevel && (r = e.rednessLevel, this._updateRedness(r)),
  7497. void 0 !== e.lighteningContrastLevel && this._updateLut(e.lighteningContrastLevel)
  7498. },
  7499. this._updateRedness = function(e) {
  7500. var t, n, a = 3.141593,
  7501. i = e,
  7502. o = i;
  7503. i > 1 && (i = 1),
  7504. i < 0 && (i = 0),
  7505. o > 1 && (o = 1),
  7506. o < 0 && (o = 0),
  7507. p = .8 * i,
  7508. o < .8 && (o = 0),
  7509. (l = (117 - 4 * o) / 180 * a) < (u = (116 - 4 * o) / 180 * a) && (l = u),
  7510. u < a / 2 && (u = a / 2),
  7511. l < a / 2 && (l = a / 2),
  7512. (c = (115 - 4 * o) / 180 * a) < a / 2 && (c = a / 2),
  7513. (d = 173 / 180 * a) > a && (d = a),
  7514. l > a && (l = a),
  7515. (s = 175 / 180 * a) > a && (s = a),
  7516. n = d - l,
  7517. g = (t = s - d) > .01 ? p * n / t: p,
  7518. n = l - u,
  7519. f = (t = u - c) > .01 ? p * n / t: p
  7520. },
  7521. this._updateLut = function(e) {
  7522. var t = null;
  7523. 0 == e && (t = S),
  7524. 1 == e && (t = E),
  7525. 2 == e && (t = v);
  7526. for (var n = [new Uint8Array(t)], i = [256], o = [1], r = 0; r < n.length; r++) a.bindTexture(a.TEXTURE_2D, m[r]),
  7527. a.texImage2D(a.TEXTURE_2D, 0, a.LUMINANCE, i[r], o[r], 0, a.LUMINANCE, a.UNSIGNED_BYTE, n[r])
  7528. },
  7529. this._init = function() {
  7530. var e = null;
  7531. e = S;
  7532. for (var t = [new Uint8Array(e)], n = [256], i = [1], o = 0; o < t.length; o++) {
  7533. var r = a.createTexture();
  7534. a.bindTexture(a.TEXTURE_2D, r),
  7535. a.texImage2D(a.TEXTURE_2D, 0, a.LUMINANCE, n[o], i[o], 0, a.LUMINANCE, a.UNSIGNED_BYTE, t[o]),
  7536. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE),
  7537. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE),
  7538. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR),
  7539. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR),
  7540. m.push(r)
  7541. }
  7542. },
  7543. this._init()
  7544. }
  7545. var Ee = !1;
  7546. function _e() {
  7547. this.programs = [];
  7548. var e = this,
  7549. t = null,
  7550. n = null;
  7551. e.gl = null,
  7552. e.inputTexture = null;
  7553. var a = [],
  7554. i = [],
  7555. o = 0,
  7556. r = 0;
  7557. e._initGl = function(n, s) {
  7558. e.inputTexture = t.createTexture(),
  7559. t.bindTexture(t.TEXTURE_2D, e.inputTexture),
  7560. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE),
  7561. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE),
  7562. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR),
  7563. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR);
  7564. for (var c = 0; c < 4; c++) {
  7565. var d = t.createTexture();
  7566. t.bindTexture(t.TEXTURE_2D, d),
  7567. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE),
  7568. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE),
  7569. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR),
  7570. 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);
  7571. var u = t.createFramebuffer();
  7572. t.bindFramebuffer(t.FRAMEBUFFER, u),
  7573. t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, d, 0),
  7574. a.push(d),
  7575. i.push(u)
  7576. }
  7577. t.viewport(0, 0, n, s),
  7578. o = n,
  7579. r = s
  7580. },
  7581. e.render = function(s) {
  7582. if (t) {
  7583. var c = 0;
  7584. r == s.videoWidth && o === s.videoHeight && (c = 2),
  7585. t.viewport(0, 0, s.videoWidth, s.videoHeight),
  7586. t.bindTexture(t.TEXTURE_2D, e.inputTexture),
  7587. t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, s);
  7588. for (var d = Ee ? e.programs.length - 1 : 0, u = 0; u <= d; u++) {
  7589. var l = e.programs[u].program;
  7590. t.useProgram(l);
  7591. var p = t.getUniformLocation(l, "u_image");
  7592. e.programs[u].setUniforms(),
  7593. t.bindFramebuffer(t.FRAMEBUFFER, i[c + u % 2]),
  7594. t.clearColor(0, 0, 0, 1),
  7595. t.clear(t.COLOR_BUFFER_BIT),
  7596. t.drawArrays(t.TRIANGLES, 0, 6),
  7597. t.activeTexture(t.TEXTURE0),
  7598. t.bindTexture(t.TEXTURE_2D, a[c + u % 2]),
  7599. t.uniform1i(p, 0)
  7600. }
  7601. t.useProgram(n);
  7602. var f = t.getUniformLocation(n, "u_flipY");
  7603. t.uniform1f(f, -1),
  7604. t.bindFramebuffer(t.FRAMEBUFFER, null),
  7605. t.clearColor(0, 0, 0, 1),
  7606. t.clear(t.COLOR_BUFFER_BIT),
  7607. t.drawArrays(t.TRIANGLES, 0, 6)
  7608. }
  7609. },
  7610. e.setEnableBeauty = function(e) {
  7611. Ee = e
  7612. },
  7613. e.init = function(a, i, o) {
  7614. if ("undefined" == typeof WebGLRenderingContext) throw new Error("NOT_SUPPORT");
  7615. t = o.getContext("webgl"),
  7616. e.gl = t,
  7617. e._initGl(a, i),
  7618. e.programs.push(new de(this, a, i)),
  7619. e.programs.push(new le(this, a, i)),
  7620. e.programs.push(new fe(this, a, i)),
  7621. e.programs.push(new me(this, a, i)),
  7622. e.programs.push(new Se(this, a, i)),
  7623. n = e.programs[0].program
  7624. },
  7625. e.release = function() {
  7626. e.gl = null,
  7627. t = null,
  7628. n = null,
  7629. e.inputTexture = null,
  7630. e.programs = [],
  7631. a = [],
  7632. i = []
  7633. },
  7634. e.setDenoiseLevel = function(t) {
  7635. e.programs.forEach((function(e) {
  7636. e.setParameters && e.setParameters({
  7637. denoiseLevel: t
  7638. })
  7639. }))
  7640. },
  7641. e.setLightLevel = function(t) {
  7642. e.programs.forEach((function(e) {
  7643. e.setParameters && e.setParameters({
  7644. lightLevel: t
  7645. })
  7646. }))
  7647. },
  7648. e.setRednessLevel = function(t) {
  7649. e.programs.forEach((function(e) {
  7650. e.setParameters && e.setParameters({
  7651. rednessLevel: t
  7652. })
  7653. }))
  7654. },
  7655. e.setContrastLevel = function(t) {
  7656. e.programs.forEach((function(e) {
  7657. e.setParameters && e.setParameters({
  7658. lighteningContrastLevel: t
  7659. })
  7660. }))
  7661. },
  7662. e.setSize = function(t, n) {
  7663. e.programs.forEach((function(e) {
  7664. e.setSize && e.setSize(t, n)
  7665. }))
  7666. }
  7667. }
  7668. _e._instance = null,
  7669. _e.getInstance = function() {
  7670. return _e._instance || (_e._instance = new _e),
  7671. _e._instance
  7672. };
  7673. var he = {
  7674. addVideoEffectCapability: function(e) {
  7675. e.videoEffect = {
  7676. canvas: null,
  7677. video: null,
  7678. fps: 30,
  7679. stopChromeBackgroundLoop: null,
  7680. enableBeauty: !1,
  7681. denoiseLevel: 5,
  7682. lightLevel: .35,
  7683. rednessLevel: .5,
  7684. lighteningContrastLevel: 1,
  7685. videoContextInited: !1,
  7686. originVideoTrack: null,
  7687. canvasVideoTrack: null,
  7688. ctx: null
  7689. },
  7690. e._initVideoContext = function() {
  7691. if (e.videoEffect.videoContextInited) throw new Error("Failed to init video context. Already inited");
  7692. if (!e.stream) throw new Error("Failed to init video context. Local Stream not initialized");
  7693. e.videoEffect.originVideoTrack = e.stream.getVideoTracks()[0],
  7694. e.attributes && e.attributes.maxFrameRate && (e.videoEffect.fps = e.attributes.maxFrameRate),
  7695. e.videoEffect.videoContextInited = !0
  7696. },
  7697. e._renderWithWebGL = function(t) {
  7698. return new Promise((function(n) {
  7699. e.videoEffect.canvas || (e.videoEffect.canvas = document.createElement("canvas")),
  7700. e.videoEffect.video || (e.videoEffect.video = document.createElement("video")),
  7701. e.videoEffect.video.setAttribute("autoplay", ""),
  7702. e.videoEffect.video.setAttribute("muted", ""),
  7703. e.videoEffect.video.muted = !0,
  7704. e.videoEffect.video.setAttribute("playsinline", ""),
  7705. e.videoEffect.video.setAttribute("style", "display:none"),
  7706. e.videoEffect.video.srcObject = t;
  7707. var a = t.getVideoTracks()[0].getSettings(),
  7708. i = a.width,
  7709. o = a.height;
  7710. console.log("Width: ".concat(i, ", Height: ").concat(o)),
  7711. e.videoEffect.canvas.setAttribute("width", i),
  7712. e.videoEffect.canvas.setAttribute("height", o),
  7713. e.videoEffect.video.setAttribute("width", i),
  7714. e.videoEffect.video.setAttribute("height", o);
  7715. var r = _e.getInstance();
  7716. r.init(e.videoEffect.video.width, e.videoEffect.video.height, e.videoEffect.canvas),
  7717. r.setDenoiseLevel(e.videoEffect.denoiseLevel),
  7718. r.setLightLevel(e.videoEffect.lightLevel),
  7719. r.setRednessLevel(e.videoEffect.rednessLevel),
  7720. r.setContrastLevel(e.videoEffect.lighteningContrastLevel);
  7721. e.videoEffect.video.addEventListener("playing", (function t() {
  7722. var a = e.videoEffect.canvas.captureStream(e.videoEffect.fps);
  7723. e.videoEffect.video.removeEventListener("playing", t, !0),
  7724. n([a.getVideoTracks()[0], e.videoEffect.video])
  7725. }), !0),
  7726. e.videoEffect.video.play()
  7727. }))
  7728. },
  7729. e._disableEffect = function() {
  7730. e.videoEffect.videoContextInited || e._initVideoContext();
  7731. var t = e.videoEffect.originVideoTrack;
  7732. if (!t) return r.
  7733. default.warning("Video track is null, fail to disable video effect!"),
  7734. Promise.resolve();
  7735. if (e.pc && e.pc.peerConnection && e.pc.peerConnection) {
  7736. var n = (e.pc.peerConnection && e.pc.peerConnection.getSenders()).find((function(e) {
  7737. return e && e.track && "video" == e.track.kind
  7738. }));
  7739. if (n && n.replaceTrack && t) return n.replaceTrack(t)
  7740. }
  7741. return Promise.resolve()
  7742. },
  7743. e._releaseEffect = function() {
  7744. var t;
  7745. return t = e.videoEffect.enableBeauty ? e._disableEffect() : Promise.resolve(),
  7746. _e.getInstance().release(),
  7747. e.videoEffect.videoContextInited = !1,
  7748. e.videoEffect.canvasVideoTrack = null,
  7749. t
  7750. },
  7751. e._enableEffect = function() {
  7752. return e.videoEffect.videoContextInited || e._initVideoContext(),
  7753. e.videoEffect.originVideoTrack ? e.videoEffect.canvasVideoTrack ? (e._showEffectInLocalPlayer(), e._replaceWithCanvasTrack()) : e._renderWithWebGL(e.stream).then((function(t) {
  7754. var n = ne()(t, 2),
  7755. a = n[0],
  7756. i = n[1];
  7757. e.videoEffect.canvasVideoTrack = a;
  7758. var o = _e.getInstance();
  7759. return requestAnimationFrame((function t() {
  7760. e.videoEffect.enableBeauty && o.render(i),
  7761. e.videoEffect.videoContextInited && requestAnimationFrame(t)
  7762. })),
  7763. g.isChrome() && document.addEventListener("visibilitychange", (function() {
  7764. document.hidden;
  7765. document.hidden ? e.videoEffect.stopChromeBackgroundLoop = function(e, t) {
  7766. var n = 1 / t,
  7767. a = new AudioContext,
  7768. i = a.createGain();
  7769. i.gain.value = 0,
  7770. i.connect(a.destination),
  7771. function t() {
  7772. var r = a.createOscillator();
  7773. r.onended = t,
  7774. r.connect(i),
  7775. r.start(0),
  7776. r.stop(a.currentTime + n),
  7777. e(a.currentTime),
  7778. o && (r.onended = function() {
  7779. a.close()
  7780. })
  7781. } ();
  7782. var o = !1;
  7783. return function() {
  7784. o = !0
  7785. }
  7786. } ((function() {
  7787. e.videoEffect.enableBeauty && o.render(i)
  7788. }), e.videoEffect.fps) : e.videoEffect.stopChromeBackgroundLoop && (e.videoEffect.stopChromeBackgroundLoop(), e.videoEffect.stopChromeBackgroundLoop = null)
  7789. }), !1),
  7790. e._showEffectInLocalPlayer(),
  7791. e._replaceWithCanvasTrack()
  7792. })) : (r.
  7793. default.warning("Video track is null, fail to enable video effect!"), Promise.resolve())
  7794. },
  7795. e._showEffectInLocalPlayer = function() {
  7796. if (e.player) {
  7797. var t = e.player.div.children[0];
  7798. if ("none" !== t.style.display && (e.player.div.appendChild(e.videoEffect.canvas), "video" === t.tagName.toLowerCase())) {
  7799. var n = t.getAttribute("style");
  7800. e.videoEffect.canvas.setAttribute("style", n),
  7801. "none" !== t.style.display && (t.style.display = "none")
  7802. }
  7803. }
  7804. },
  7805. e._removeEffectFromLocalPlayer = function() {
  7806. if (e.player && e.player.div && e.videoEffect.enableBeauty && e.videoEffect.canvas) {
  7807. e.player.div.removeChild(e.videoEffect.canvas);
  7808. var t = e.player.div.children[0];
  7809. "video" === t.tagName.toLowerCase() && (e.videoEffect.canvas.style.display = "none", t.style.display = "block")
  7810. }
  7811. },
  7812. e._replaceWithCanvasTrack = function() {
  7813. var t = null;
  7814. e.pc && e.pc.peerConnection && e.pc.peerConnection && (t = (e.pc.peerConnection && e.pc.peerConnection.getSenders()).find((function(e) {
  7815. return e && e.track && "video" == e.track.kind
  7816. })));
  7817. return t && t.replaceTrack && e.videoEffect.canvasVideoTrack ? t.replaceTrack(e.videoEffect.canvasVideoTrack) : Promise.resolve()
  7818. },
  7819. e.setBeautyEffectOptions = function() {
  7820. var t = ee()(Z.a.mark((function t(n, a) {
  7821. var i, o = arguments;
  7822. return Z.a.wrap((function(t) {
  7823. for (;;) switch (t.prev = t.next) {
  7824. case 0:
  7825. if (Object(z.checkValidBoolean)(n, "enabled"), i = _e.getInstance(), e.videoEffect.enableBeauty == n) {
  7826. t.next = 14;
  7827. break
  7828. }
  7829. if (i.setEnableBeauty(n), !n) {
  7830. t.next = 9;
  7831. break
  7832. }
  7833. return t.next = 7,
  7834. e._enableEffect();
  7835. case 7:
  7836. t.next = 12;
  7837. break;
  7838. case 9:
  7839. return e._removeEffectFromLocalPlayer(),
  7840. t.next = 12,
  7841. e._releaseEffect();
  7842. case 12:
  7843. e.videoEffect.enableBeauty = n,
  7844. s.b.reportApiInvoke(e.sid, {
  7845. callback: null,
  7846. options: o,
  7847. name: "Stream.setBeautyEffectOptions",
  7848. tag: "tracer"
  7849. });
  7850. case 14:
  7851. if (n) {
  7852. t.next = 16;
  7853. break
  7854. }
  7855. return t.abrupt("return");
  7856. case 16:
  7857. if (!a) {
  7858. t.next = 20;
  7859. break
  7860. }
  7861. Object(z.checkValidObject)(a, "options"),
  7862. t.next = 21;
  7863. break;
  7864. case 20:
  7865. return t.abrupt("return");
  7866. case 21:
  7867. 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) {
  7868. t.next = 29;
  7869. break
  7870. }
  7871. if (0 === a.lighteningContrastLevel || 1 === a.lighteningContrastLevel || 2 === a.lighteningContrastLevel) {
  7872. t.next = 27;
  7873. break
  7874. }
  7875. throw new Error("Invalid lighteningContrastLevel: The value should be 0, 1 or 2.");
  7876. case 27:
  7877. e.videoEffect.lighteningContrastLevel = parseFloat(a.lighteningContrastLevel),
  7878. i.setContrastLevel(e.videoEffect.lighteningContrastLevel);
  7879. case 29:
  7880. case "end":
  7881. return t.stop()
  7882. }
  7883. }), t)
  7884. })));
  7885. return function(e, n) {
  7886. return t.apply(this, arguments)
  7887. }
  7888. } ()
  7889. },
  7890. restoreVideoEffect: function(e) {
  7891. return e.videoEffect.enableBeauty ? e._enableEffect() : Promise.resolve()
  7892. },
  7893. disableVideoEffect: function(e) {
  7894. return e._releaseEffect ? e._releaseEffect() : Promise.resolve()
  7895. },
  7896. applyEffectInPlayer: function(e) {
  7897. e.videoEffect.enableBeauty && e.videoEffect.canvas && e._showEffectInLocalPlayer()
  7898. },
  7899. removeEffectFromLocalPlayer: function(e) {
  7900. e._removeEffectFromLocalPlayer()
  7901. },
  7902. replaceWithCanvasTrack: function(e) {
  7903. return e.videoEffect.enableBeauty ? e._replaceWithCanvasTrack() : Promise.resolve()
  7904. },
  7905. checkVideoEffectEnabled: function(e) {
  7906. if (e.videoEffect.enableBeauty && e.videoEffect && e.videoEffect.videoContextInited) {
  7907. return r.
  7908. default.error("Operation not permitted: ".concat("VIDEO_EFFECT_ENABLED")),
  7909. "VIDEO_EFFECT_ENABLED"
  7910. }
  7911. return ! 1
  7912. }
  7913. },
  7914. Ie = a(9),
  7915. be = a.n(Ie),
  7916. Te = function(e) {
  7917. Object(z.checkValidString)(e, "profileName"),
  7918. -1 === (e = e.toLowerCase()).indexOf("_") && (e += "_1"),
  7919. Object(z.checkValidEnum)(e, "profileName", Object.keys(o.SUPPORT_RESOLUTION_LIST));
  7920. var t = o.SUPPORT_RESOLUTION_LIST[e];
  7921. t || (e = Object(o.getParameter)("DEFAULT_PROFILE"), t = o.SUPPORT_RESOLUTION_LIST[e]);
  7922. var n = {
  7923. profileName: e,
  7924. video: {
  7925. width: t[0],
  7926. height: t[1]
  7927. },
  7928. attributes: {
  7929. resolution: "".concat(t[0], "x").concat(t[1]),
  7930. minFrameRate: t[2],
  7931. maxFrameRate: t[3],
  7932. minVideoBW: t[4],
  7933. maxVideoBW: t[5]
  7934. }
  7935. };
  7936. return t[2] && t[3] && (n.video.frameRate = {
  7937. ideal: t[2],
  7938. max: t[3]
  7939. }),
  7940. t[6] && t[7] && (n.screen = {
  7941. width: t[0],
  7942. height: t[1],
  7943. frameRate: {
  7944. min: t[6],
  7945. max: t[7]
  7946. }
  7947. }),
  7948. n
  7949. },
  7950. Re = function(e) {
  7951. return Object.keys(o.SUPPORT_RESOLUTION_LIST).filter((function(t) {
  7952. var n = o.SUPPORT_RESOLUTION_LIST[t],
  7953. a = ["width", "height", "frameRate"];
  7954. for (var i in a) {
  7955. var r = a[i];
  7956. if (e[r] && n[i]) {
  7957. if ("number" == typeof e[r].max && e[r].max < n[i]) return ! 1;
  7958. if ("number" == typeof e[r].min && e[r].min > n[i]) return ! 1
  7959. }
  7960. }
  7961. return ! 0
  7962. })).reverse()
  7963. },
  7964. Ae = function(e) {
  7965. var t = o.AUDIO_PROFILE_SETTINGS[e] || o.AUDIO_PROFILE_SETTINGS.
  7966. default;
  7967. return {
  7968. highQuality:
  7969. t[0],
  7970. stereo: t[1],
  7971. speech: t[2],
  7972. lowQuality: t[3]
  7973. }
  7974. };
  7975. var ye = function(e) {
  7976. var t = c();
  7977. if (t.params = E()({},
  7978. 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 = {
  7979. width: 1920,
  7980. height: 1080,
  7981. maxFr: 5,
  7982. minFr: 1
  7983. },
  7984. t.videoSize = e.videoSize, t.player = void 0, t.audioLevelHelper = null, e.attributes = e.attributes || {},
  7985. 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");
  7986. function n() {
  7987. var e = {};
  7988. t.getVideoTrack() === this ? (r.
  7989. default.debug("Video Track Ended"), e.type = "videoTrackEnded", e.track = this) : t.getAudioTrack() === this ? (r.
  7990. default.debug("Audio Track Ended"), e.type = "audioTrackEnded", e.track = this) : r.
  7991. default.debug("Detached Track ended", this.kind, this.label, this),
  7992. e.type && t.dispatchEvent(e)
  7993. }
  7994. return t.videoSize = [640, 480, 640, 480],
  7995. void 0 !== e.local && !0 !== e.local || (t.local = !0),
  7996. t.initialized = !t.local,
  7997. t._streamInitID = null,
  7998. function(e) {
  7999. e.audioMixing = {
  8000. audioContextInited: !1,
  8001. defaultVolume: 100,
  8002. inEarMonitoring: "FILE",
  8003. sounds: {},
  8004. states: {
  8005. IDLE: "IDLE",
  8006. STARTING: "STARTING",
  8007. BUSY: "BUSY",
  8008. PAUSED: "PAUSED"
  8009. },
  8010. inEarMonitoringModes: {
  8011. NONE: "NONE",
  8012. FILE: "FILE",
  8013. MICROPHONE: "MOCROPHONE",
  8014. ALL: "ALL"
  8015. },
  8016. ctx: null,
  8017. mediaStreamSource: null,
  8018. mediaStreamDest: null,
  8019. buffer: {}
  8020. },
  8021. e._initSoundIfNotExists = function(t, n) {
  8022. e.audioMixing.sounds[t] || (e.audioMixing.sounds[t] = {
  8023. soundId: t,
  8024. state: "IDLE",
  8025. muted: e.userMuteAudio,
  8026. filePath: n,
  8027. volume: e.audioMixing.defaultVolume,
  8028. startAt: null,
  8029. startOffset: null,
  8030. pauseAt: null,
  8031. pauseOffset: null,
  8032. resumeAt: null,
  8033. resumeOffset: null,
  8034. stopAt: null,
  8035. options: null,
  8036. source: null
  8037. })
  8038. },
  8039. e._initSoundIfNotExists( - 1),
  8040. e.loadAudioBuffer = function(t, n, a) {
  8041. var i = s.b.reportApiInvoke(e.sid, {
  8042. callback: a,
  8043. name: "Stream.loadAudioBuffer",
  8044. options: arguments,
  8045. tag: "tracer"
  8046. });
  8047. Object(z.checkValidString)(n, "url", 1, 1024, !1),
  8048. Object(z.checkValidString)(t, "id", 1, 1024, !1);
  8049. var o = function(t) {
  8050. r.
  8051. default.error("[".concat(e.streamId, "] loadAudioBuffer Failed: ") + t),
  8052. i(I.
  8053. default.LOAD_AUDIO_FAILED)
  8054. },
  8055. c = new XMLHttpRequest;
  8056. c.open("GET", n, !0),
  8057. c.responseType = "arraybuffer",
  8058. c.onload = function() {
  8059. if (c.status > 400) o("".concat(c.status, " ").concat(c.statusText));
  8060. else {
  8061. var n = c.response;
  8062. e.audioMixing.audioContextInited || e._initAudioContext(),
  8063. e.audioMixing.ctx.decodeAudioData(n, (function(n) {
  8064. e.audioMixing.buffer[t] = n,
  8065. i(null)
  8066. }), (function(t) {
  8067. r.
  8068. default.error("[".concat(e.streamId, "] decodeAudioData Failed: "), t),
  8069. i(t)
  8070. }))
  8071. }
  8072. },
  8073. c.onerror = function() {
  8074. return o("load error")
  8075. },
  8076. c.ontimeout = function() {
  8077. return o("timeout")
  8078. },
  8079. c.send()
  8080. },
  8081. e.createAudioBufferSource = function(t) {
  8082. var n = s.b.reportApiInvoke(e.sid, {
  8083. name: "Stream.createAudioBufferSource",
  8084. options: arguments,
  8085. tag: "tracer"
  8086. });
  8087. if (e.audioMixing.buffer[t.id]) {
  8088. var a = e.audioMixing.buffer[t.id],
  8089. i = e.audioMixing.ctx.createBufferSource();
  8090. i.buffer = a;
  8091. var o = e.audioMixing.ctx.createGain();
  8092. if (i.connect(o), o.connect(e.audioMixing.mediaStreamDest), i.gainNode = o, t.loop) i.loop = !0,
  8093. i.start(0, t.playTime / 1e3);
  8094. else if (t.cycle > 1) if (Object(g.isChrome)()) {
  8095. i.loop = !0;
  8096. var c = t.cycle * a.duration * 1e3 - (t.playTime || 0);
  8097. i.start(0, t.playTime / 1e3, c / 1e3)
  8098. } else r.
  8099. default.warning("[".concat(e.streamId, "] Cycle Param is ignored by current browser")),
  8100. i.start(0, t.playTime / 1e3);
  8101. else i.start(0, t.playTime / 1e3);
  8102. var d = e.audioMixing.sounds[t.soundId];
  8103. return d.source = i,
  8104. e._flushAudioMixingMuteStatus(),
  8105. i.addEventListener("ended", (function() {
  8106. i === d.source && e.dispatchEvent({
  8107. type: "audioSourceEnded",
  8108. soundId: t.soundId,
  8109. source: i,
  8110. sound: d
  8111. })
  8112. })),
  8113. n(),
  8114. i
  8115. }
  8116. var u = "AUDIOBUFFER_NOT_FOUND";
  8117. return r.
  8118. default.error("[".concat(e.streamId, "] "), u, t.id),
  8119. n(!1),
  8120. !1
  8121. },
  8122. e.on("audioSourceEnded", (function(t) {
  8123. var n = t.source,
  8124. a = t.sound;
  8125. 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))
  8126. })),
  8127. e.clearAudioBufferSource = function() {
  8128. e.audioBufferSource.forEach((function(e) {
  8129. e.stop()
  8130. }))
  8131. },
  8132. e._isSoundExists = function(t) {
  8133. return !! e.audioMixing.sounds[t.soundId] || (r.
  8134. default.error("SoundId not exists. #".concat(t.soundId)), !1)
  8135. },
  8136. e._initAudioContext = function() {
  8137. if (e.audioMixing.audioContextInited) throw new Error("Failed to init audio context. Already inited");
  8138. if (!e.stream) throw new Error("Failed to init audio context. Local Stream not initialized");
  8139. e.audioMixing.ctx = Object(X.a)(),
  8140. e.audioMixing.mediaStreamSource = e.audioMixing.ctx.createMediaStreamSource(e.stream),
  8141. e.audioMixing.mediaStreamDest = e.audioMixing.ctx.createMediaStreamDestination(),
  8142. e.audioMixing.mediaStreamSource.connect(e.audioMixing.mediaStreamDest);
  8143. var t = e.stream.getVideoTracks()[0];
  8144. 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) {
  8145. var n = (e.pc.peerConnection && e.pc.peerConnection.getSenders()).find((function(e) {
  8146. return e && e.track && "audio" == e.track.kind
  8147. })),
  8148. a = e.audioMixing.mediaStreamDest.stream.getAudioTracks()[0];
  8149. n && n.replaceTrack && a && n.replaceTrack(a)
  8150. }
  8151. e.audioMixing.audioContextInited = !0
  8152. },
  8153. e._cleanupAudioMixing = function() {
  8154. if (e.audioMixing.audioContextInited) {
  8155. for (var t in e.audioMixing.sounds) {
  8156. var n = e.audioMixing.sounds[t];
  8157. n.state !== e.audioMixing.states.BUSY && n.state !== e.audioMixing.states.PAUSED || e._stopOneEffect({
  8158. soundId: t
  8159. })
  8160. }
  8161. e.audioLevelHelper = null,
  8162. e.audioMixing.audioContextInited = !1
  8163. }
  8164. },
  8165. e._reloadInEarMonitoringMode = function(t) {
  8166. if (t) {
  8167. if (!e.audioMixing.inEarMonitoringModes[t]) return r.
  8168. default.error("[".concat(e.streamId, "] Invalid InEarMonitoringMode ").concat(t));
  8169. e.audioMixing.inEarMonitoring = t
  8170. }
  8171. switch (e.audioMixing.audioContextInited || e._initAudioContext(), e.audioMixing.inEarMonitoring) {
  8172. case e.audioMixing.inEarMonitoringModes.FILE:
  8173. e.audioMixing.mediaStreamSource.connectedToDestination && (e.audioMixing.mediaStreamSource.disconnect(e.audioMixing.ctx.destination), e.audioMixing.mediaStreamSource.connectedToDestination = !1);
  8174. case e.audioMixing.inEarMonitoringModes.ALL:
  8175. for (var n in e.audioMixing.sounds) {
  8176. var a = e.audioMixing.sounds[n];
  8177. a && a.source && !a.source.connectedToDestination && (a.source.gainNode.connect(e.audioMixing.ctx.destination), a.source.connectedToDestination = !0)
  8178. }
  8179. }
  8180. switch (e.audioMixing.inEarMonitoring) {
  8181. case e.audioMixing.inEarMonitoringModes.MICROPHONE:
  8182. e.audioMixing.source.forEach((function(t) {
  8183. t.connectedToDestination && (t.gainNode.disconnect(e.audioMixing.ctx.destination), t.connectedToDestination = !1)
  8184. }));
  8185. case e.audioMixing.inEarMonitoringModes.ALL:
  8186. e.audioMixing.mediaStreamSource.connectedToDestination || (e.audioMixing.mediaStreamSource.connect(e.audioMixing.ctx.destination), e.audioMixing.mediaStreamSource.connectedToDestination = !0)
  8187. }
  8188. },
  8189. e._startAudioMixingBufferSource = function(t) {
  8190. e.audioMixing.audioContextInited || e._initAudioContext();
  8191. var n = {
  8192. soundId: t.soundId,
  8193. id: t.filePath,
  8194. loop: t.loop,
  8195. cycle: t.cycle,
  8196. playTime: t.playTime || 0
  8197. },
  8198. a = t.replace,
  8199. i = e.createAudioBufferSource(n);
  8200. return i.sound = e.audioMixing.sounds[t.soundId],
  8201. i ? (i.addEventListener("ended", e._audioMixingFinishedListener, {
  8202. once: !0
  8203. }), e._reloadInEarMonitoringMode(), a && e.audioMixing.mediaStreamSource.disconnect(e.audioMixing.mediaStreamDest), i) : null
  8204. },
  8205. e._stopAudioMixingBufferSource = function(t) {
  8206. var n = e.audioMixing.sounds[t.soundId].source;
  8207. 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
  8208. },
  8209. e._flushAudioMixingMuteStatus = function(t) {
  8210. for (var n in e.audioMixing.sounds) {
  8211. var a = e.audioMixing.sounds[n];
  8212. 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))
  8213. }
  8214. },
  8215. e._handleAudioMixingInvalidStateError = function(t, n, a) {
  8216. var i = e.audioMixing.sounds[n.soundId],
  8217. o = -1 === n.soundId ? "INVALID_AUDIO_MIXING_STATE": "INVALID_PLAY_EFFECT_STATE";
  8218. r.
  8219. default.error("[".concat(e.streamId, "] Cannot ").concat(t, ": ").concat(o, ", state is ").concat(i.state)),
  8220. a && a(o)
  8221. },
  8222. e._handleAudioMixingNoSourceError = function(t, n, a) {
  8223. e.audioMixing.sounds[n.soundId].state = e.audioMixing.states.IDLE;
  8224. var i = -1 === n.soundId ? "NO_AUDIO_MIXING_SOURCE": "NO_EFFECT_SOURCE";
  8225. r.
  8226. default.error("[".concat(e.streamId, "] Cannot ").concat(t, ": ").concat(i)),
  8227. a && a(i)
  8228. },
  8229. e._getOneEffectStates = function(t) {
  8230. var n = e.audioMixing.sounds[t.soundId];
  8231. return function() {
  8232. return n ? {
  8233. state: n.state,
  8234. startAt: n.startAt,
  8235. resumeAt: n.resumeAt,
  8236. pauseOffset: n.pauseOffset,
  8237. pauseAt: n.pauseAt,
  8238. resumeOffset: n.resumeOffset,
  8239. stopAt: n.stopAt,
  8240. duration: e._getOneEffectDuration(t),
  8241. position: e._getOneEffectCurrentPosition(t)
  8242. }: {}
  8243. }
  8244. },
  8245. e._audioMixingFinishedListener = function() {
  8246. var t = this.sound;
  8247. t.state === e.audioMixing.states.IDLE && e.audioMixing.buffer[t.options.filePath] && !t.options.cacheResource && (r.
  8248. default.debug("Recycled buffer ".concat(t.options.filePath)), delete e.audioMixing.buffer[t.options.filePath]),
  8249. -1 === t.soundId && e.dispatchEvent({
  8250. type: "audioMixingFinished"
  8251. })
  8252. },
  8253. e._playOneEffect = function(t, n) {
  8254. Object(z.checkValidObject)(t, "options");
  8255. var a = t.soundId,
  8256. i = (t.filePath, t.cacheResource);
  8257. t.cycle,
  8258. t.loop,
  8259. t.playTime,
  8260. t.replace;
  8261. if (Object(g.isSafari)() && Object(g.getBrowserVersion)() < 12) {
  8262. var o = "BROWSER_NOT_SUPPORT";
  8263. return r.
  8264. default.error("[".concat(e.streamId, "] Cannot _playOneEffect: "), o),
  8265. n(o)
  8266. }
  8267. e.audioMixing.audioContextInited || e._initAudioContext(),
  8268. e._initSoundIfNotExists(a);
  8269. var s = e.audioMixing.sounds[a];
  8270. if (s.state === e.audioMixing.states.IDLE) {
  8271. if (void 0 !== t.cycle && !t.cycle > 0) {
  8272. o = "Invalid Parmeter cycle: " + t.cycle;
  8273. return r.
  8274. default.error("[".concat(e.streamId, "] ").concat(a), o),
  8275. n(o)
  8276. }
  8277. if (Object(z.isEmpty)(i) && (t.cacheResource = !0), s.state = e.audioMixing.states.STARTING, s.options = t, e.audioMixing.buffer[t.filePath]) {
  8278. var c = e._startAudioMixingBufferSource(t);
  8279. if (c) return s.source = c,
  8280. s.startAt = Date.now(),
  8281. s.resumeAt = null,
  8282. s.pauseOffset = null,
  8283. s.pauseAt = null,
  8284. s.resumeOffset = null,
  8285. s.stopAt = null,
  8286. s.startOffset = t.playTime || 0,
  8287. s.state = e.audioMixing.states.BUSY,
  8288. e._flushAudioMixingMuteStatus(),
  8289. n(null);
  8290. s.state = e.audioMixing.states.IDLE;
  8291. var d = "CREATE_BUFFERSOURCE_FAILED";
  8292. if (n) return n(d);
  8293. r.
  8294. default.error("[".concat(e.streamId, "] "), d)
  8295. } else e.loadAudioBuffer(t.filePath, t.filePath, (function(a) {
  8296. if (a) s.state = e.audioMixing.states.IDLE,
  8297. n ? n(a) : r.
  8298. default.error("[".concat(e.streamId, "] "), a);
  8299. else {
  8300. var i = e._startAudioMixingBufferSource(t);
  8301. if (i) return s.source = i,
  8302. s.startAt = Date.now(),
  8303. s.resumeAt = null,
  8304. s.pauseOffset = null,
  8305. s.pauseAt = null,
  8306. s.resumeOffset = null,
  8307. s.stopAt = null,
  8308. s.startOffset = t.playTime || 0,
  8309. s.state = e.audioMixing.states.BUSY,
  8310. e._flushAudioMixingMuteStatus(),
  8311. n(null);
  8312. s.state = e.audioMixing.states.IDLE;
  8313. a = "CREATE_BUFFERSOURCE_FAILED";
  8314. if (n) return n(a);
  8315. r.
  8316. default.error("[".concat(e.streamId, "] "), a)
  8317. }
  8318. }))
  8319. } else e._handleAudioMixingInvalidStateError("_playEffect", t, n)
  8320. },
  8321. e._stopOneEffect = function(t, n) {
  8322. var a = e.audioMixing.sounds[t.soundId];
  8323. 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.
  8324. 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")
  8325. },
  8326. e._pauseOneEffect = function(t, n) {
  8327. var a = e.audioMixing.sounds[t.soundId];
  8328. 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);
  8329. e._handleAudioMixingInvalidStateError("_pauseOneEffect", t, n)
  8330. },
  8331. e._resumeOneEffect = function(t, n) {
  8332. var a = e.audioMixing.sounds[t.soundId];
  8333. if (a.state === e.audioMixing.states.PAUSED) {
  8334. var i = {
  8335. soundId: t.soundId,
  8336. filePath: a.options.filePath,
  8337. cycle: a.options.cycle,
  8338. loop: a.options.loop,
  8339. playTime: a.pauseOffset,
  8340. replace: a.options.replace
  8341. },
  8342. o = e._startAudioMixingBufferSource(i);
  8343. if (!o) {
  8344. var s = "CREATE_BUFFERSOURCE_FAILED";
  8345. return n(s),
  8346. void r.
  8347. default.error("[".concat(e.streamId, "] "), s)
  8348. }
  8349. a.source = o,
  8350. a.resumeAt = Date.now(),
  8351. a.resumeOffset = a.pauseOffset,
  8352. a.state = e.audioMixing.states.BUSY,
  8353. a.pauseAt = null,
  8354. a.pauseOffset = null,
  8355. n(null)
  8356. } else e._handleAudioMixingInvalidStateError("_resumeOneEffect", t, n)
  8357. },
  8358. e._getOneEffectDuration = function(t) {
  8359. var n = e.audioMixing.sounds[t.soundId];
  8360. return n.options && n.options.filePath && e.audioMixing.buffer[n.options.filePath] ? 1e3 * e.audioMixing.buffer[n.options.filePath].duration: null
  8361. },
  8362. e._getOneEffectCurrentPosition = function(t, n) {
  8363. var a = e.audioMixing.sounds[t.soundId];
  8364. 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))
  8365. },
  8366. e._setOneEffectPosition = function(t, n, a) {
  8367. var i = e.audioMixing.sounds[t.soundId];
  8368. if (i.state === e.audioMixing.states.BUSY) {
  8369. if (!e._stopAudioMixingBufferSource(t)) return void e._handleAudioMixingNoSourceError("_setOneEffectPosition", t, a);
  8370. var o = {
  8371. soundId: t.soundId,
  8372. filePath: i.options.filePath,
  8373. loop: i.options.loop,
  8374. cycle: i.options.cycle,
  8375. playTime: n
  8376. },
  8377. s = e._startAudioMixingBufferSource(o);
  8378. if (!s) {
  8379. var c = "CREATE_BUFFERSOURCE_FAILED";
  8380. return a && a(c),
  8381. void r.
  8382. default.error("[".concat(e.streamId, "] "), c)
  8383. }
  8384. i.source = s,
  8385. i.startAt = Date.now(),
  8386. i.startOffset = n,
  8387. i.resumeAt = null,
  8388. i.resumeOffset = null,
  8389. i.pauseOffset = null,
  8390. i.pauseAt = null
  8391. } else {
  8392. if (i.state !== e.audioMixing.states.PAUSED) return void e._handleAudioMixingInvalidStateError("_setOneEffectPosition", t, a);
  8393. i.pauseOffset = n
  8394. }
  8395. a && a(null)
  8396. },
  8397. e.startAudioMixing = function(t, n) {
  8398. var a = s.b.reportApiInvoke(e.sid, {
  8399. callback: function(t) {
  8400. if (t) return n && n(t);
  8401. e.dispatchEvent({
  8402. type: "audioMixingPlayed"
  8403. }),
  8404. n && n(null)
  8405. },
  8406. getStates: e._getOneEffectStates({
  8407. soundId: -1
  8408. }),
  8409. name: "Stream.startAudioMixing",
  8410. options: t
  8411. });
  8412. Object(z.checkValidObject)(t, "options");
  8413. var i = t.filePath,
  8414. r = t.cacheResource,
  8415. c = t.cycle,
  8416. d = t.loop,
  8417. u = t.playTime,
  8418. l = t.replace;
  8419. Object(z.checkValidString)(i, "filePath", 1, Object(o.getParameter)("FILEPATH_LENMAX"), !1),
  8420. Object(z.checkValidNumber)(u, "playTime", 0, 1e8),
  8421. !Object(z.isEmpty)(c) && Object(z.checkValidNumber)(c, "cycle"),
  8422. !Object(z.isEmpty)(d) && Object(z.checkValidBoolean)(d, "loop"),
  8423. !Object(z.isEmpty)(l) && Object(z.checkValidBoolean)(l, "replace"),
  8424. !Object(z.isEmpty)(r) && Object(z.checkValidBoolean)(r, "cacheResource");
  8425. var p = E()({
  8426. soundId: -1
  8427. },
  8428. t);
  8429. e._playOneEffect(p, a)
  8430. },
  8431. e.stopAudioMixing = function(t) {
  8432. var n = s.b.reportApiInvoke(e.sid, {
  8433. callback: t,
  8434. getStates: e._getOneEffectStates({
  8435. soundId: -1
  8436. }),
  8437. name: "Stream.stopAudioMixing"
  8438. });
  8439. e._stopOneEffect({
  8440. soundId: -1
  8441. },
  8442. n)
  8443. },
  8444. e.pauseAudioMixing = function(t) {
  8445. var n = s.b.reportApiInvoke(e.sid, {
  8446. callback: t,
  8447. getStates: e._getOneEffectStates({
  8448. soundId: -1
  8449. }),
  8450. name: "Stream.pauseAudioMixing"
  8451. });
  8452. return e._pauseOneEffect({
  8453. soundId: -1
  8454. },
  8455. n)
  8456. },
  8457. e.resumeAudioMixing = function(t) {
  8458. var n = s.b.reportApiInvoke(e.sid, {
  8459. callback: function(n, a) {
  8460. if (n) return t && t(n);
  8461. e.dispatchEvent({
  8462. type: "audioMixingPlayed"
  8463. }),
  8464. t && t(null)
  8465. },
  8466. getStates: e._getOneEffectStates({
  8467. soundId: -1
  8468. }),
  8469. name: "Stream.resumeAudioMixing"
  8470. });
  8471. e._resumeOneEffect({
  8472. soundId: -1
  8473. },
  8474. n)
  8475. },
  8476. e.adjustAudioMixingVolume = function(t) {
  8477. var n = s.b.reportApiInvoke(e.sid, {
  8478. getStates: e._getOneEffectStates({
  8479. soundId: -1
  8480. }),
  8481. name: "Stream.adjustAudioMixingVolume",
  8482. options: arguments,
  8483. tag: "tracer"
  8484. });
  8485. Object(z.checkValidNumber)(t, "volume", 0, 100),
  8486. e.audioMixing.sounds[ - 1].volume = t,
  8487. e._flushAudioMixingMuteStatus(),
  8488. n()
  8489. },
  8490. e.getAudioMixingDuration = function() {
  8491. var t = s.b.reportApiInvoke(e.sid, {
  8492. getStates: e._getOneEffectStates({
  8493. soundId: -1
  8494. }),
  8495. name: "Stream.getAudioMixingDuration"
  8496. }),
  8497. n = e._getOneEffectDuration({
  8498. soundId: -1
  8499. });
  8500. return t(null, n),
  8501. n
  8502. },
  8503. e.getAudioMixingCurrentPosition = function() {
  8504. var t = s.b.reportApiInvoke(e.sid, {
  8505. getStates: e._getOneEffectStates({
  8506. soundId: -1
  8507. }),
  8508. name: "Stream.getAudioMixingCurrentPosition"
  8509. }),
  8510. n = e._getOneEffectCurrentPosition({
  8511. soundId: -1
  8512. },
  8513. !0);
  8514. return t(null, n),
  8515. n
  8516. },
  8517. e.setAudioMixingPosition = function(t, n) {
  8518. var a = s.b.reportApiInvoke(e.sid, {
  8519. callback: n,
  8520. options: arguments,
  8521. tag: "tracer",
  8522. getStates: e._getOneEffectStates({
  8523. soundId: -1
  8524. }),
  8525. name: "Stream.setAudioMixingPosition"
  8526. });
  8527. Object(z.checkValidNumber)(t, "position", 0, 1e8),
  8528. e._setOneEffectPosition({
  8529. soundId: -1
  8530. },
  8531. t, a)
  8532. },
  8533. e.playEffect = function(t, n) {
  8534. var a = s.b.reportApiInvoke(e.sid, {
  8535. callback: function(t) {
  8536. if (t) return n && n(t);
  8537. e.dispatchEvent({
  8538. type: "effectPlayed"
  8539. }),
  8540. n && n(null)
  8541. },
  8542. name: "Stream.playEffect",
  8543. options: t
  8544. });
  8545. Object(z.checkValidObject)(t, "options");
  8546. var i = t.soundId,
  8547. r = t.filePath,
  8548. c = t.cycle;
  8549. Object(z.checkValidNumber)(i, "soundId", 1, 1e4),
  8550. Object(z.checkValidString)(r, "filePath", 0, Object(o.getParameter)("FILEPATH_LENMAX"), !1),
  8551. !Object(z.isEmpty)(c) && Object(z.checkValidNumber)(c, "cycle"),
  8552. e._playOneEffect(t, a)
  8553. },
  8554. e.stopEffect = function(t, n) {
  8555. var a = s.b.reportApiInvoke(e.sid, {
  8556. callback: n,
  8557. getStates: e._getOneEffectStates({
  8558. soundId: t
  8559. }),
  8560. name: "Stream.stopEffect"
  8561. });
  8562. Object(z.checkValidNumber)(t, "soundId", 1, 1e4),
  8563. e._stopOneEffect({
  8564. soundId: t
  8565. },
  8566. a)
  8567. },
  8568. e.stopAllEffects = function(t) {
  8569. var n = s.b.reportApiInvoke(e.sid, {
  8570. callback: t,
  8571. name: "Stream.stopAllEffect"
  8572. }),
  8573. a = !1,
  8574. i = 0,
  8575. o = 0,
  8576. r = function(e) {
  8577. a || (e ? (n(e), a = !0) : i += 1, i === o && (n(null), a = !0))
  8578. };
  8579. for (var c in e.audioMixing.sounds) {
  8580. var d = e.audioMixing.sounds[c]; - 1 !== d.soundId && (d.state !== e.audioMixing.states.BUSY && d.state !== e.audioMixing.states.PAUSED || (o++, e._stopOneEffect({
  8581. soundId: c
  8582. },
  8583. r)))
  8584. }
  8585. o || n(null)
  8586. },
  8587. e.preloadEffect = function(t, n, a) {
  8588. var i = s.b.reportApiInvoke(e.sid, {
  8589. callback: a,
  8590. options: arguments,
  8591. tag: "tracer",
  8592. name: "Stream.preloadEffect"
  8593. });
  8594. Object(z.checkValidNumber)(t, "soundId", 1, 1e4),
  8595. Object(z.checkValidString)(n, "filePath", 1, Object(o.getParameter)("FILEPATH_LENMAX"), !1),
  8596. e._initSoundIfNotExists(t, n),
  8597. e.audioMixing.buffer[n] ? i(null) : e.loadAudioBuffer(n, n, i)
  8598. },
  8599. e.unloadEffect = function(t, n) {
  8600. var a = s.b.reportApiInvoke(e.sid, {
  8601. callback: n,
  8602. options: arguments,
  8603. tag: "tracer",
  8604. name: "Stream.unloadEffect"
  8605. });
  8606. Object(z.checkValidNumber)(t, "soundId", 1, 1e4);
  8607. var i = e.audioMixing.sounds[t];
  8608. if (!i) {
  8609. var o = "SOUND_NOT_EXISTS";
  8610. return r.
  8611. default.error(o, t),
  8612. void a(o)
  8613. }
  8614. var c = i.options ? i.options.filePath: i.filePath;
  8615. if (c) delete e.audioMixing.buffer[c],
  8616. delete e.audioMixing.sounds[t],
  8617. a(null);
  8618. else {
  8619. var d = "SOUND_BUFFER_NOT_FOUND";
  8620. r.
  8621. default.error(d, t),
  8622. a(d)
  8623. }
  8624. },
  8625. e.pauseEffect = function(t, n) {
  8626. var a = s.b.reportApiInvoke(e.sid, {
  8627. callback: n,
  8628. options: arguments,
  8629. tag: "tracer",
  8630. name: "Stream.pauseEffect"
  8631. });
  8632. return e._pauseOneEffect({
  8633. soundId: t
  8634. },
  8635. a)
  8636. },
  8637. e.pauseAllEffects = function(t) {
  8638. var n = s.b.reportApiInvoke(e.sid, {
  8639. callback: t,
  8640. name: "Stream.pauseAllEffects"
  8641. }),
  8642. a = !1,
  8643. i = 0,
  8644. o = 0,
  8645. r = function(e) {
  8646. a || (e ? (n(e), a = !0) : i += 1, i === o && (n(null), a = !0))
  8647. };
  8648. for (var c in e.audioMixing.sounds)"-1" !== c && e.audioMixing.sounds[c].state === e.audioMixing.states.BUSY && (o++, e._pauseOneEffect({
  8649. soundId: c
  8650. },
  8651. r));
  8652. o || n(null)
  8653. },
  8654. e.resumeEffect = function(t, n) {
  8655. Object(z.checkValidNumber)(t, "soundId", 1, 1e4);
  8656. var a = s.b.reportApiInvoke(e.sid, {
  8657. callback: n,
  8658. options: arguments,
  8659. tag: "tracer",
  8660. name: "Stream.resumeEffect"
  8661. });
  8662. return e._resumeOneEffect({
  8663. soundId: t
  8664. },
  8665. a)
  8666. },
  8667. e.resumeAllEffects = function(t) {
  8668. var n = s.b.reportApiInvoke(e.sid, {
  8669. callback: t,
  8670. name: "Stream.resumeAllEffects"
  8671. }),
  8672. a = !1,
  8673. i = 0,
  8674. o = 0,
  8675. r = function(e) {
  8676. a || (e ? (n(e), a = !0) : i += 1, i === o && (n(null), a = !0))
  8677. };
  8678. for (var c in e.audioMixing.sounds)"-1" !== c && e.audioMixing.sounds[c].state === e.audioMixing.states.PAUSED && (o++, e._resumeOneEffect({
  8679. soundId: c
  8680. },
  8681. r));
  8682. o || n(null)
  8683. },
  8684. e.getEffectsVolume = function() {
  8685. var t = [];
  8686. for (var n in e.audioMixing.sounds) {
  8687. var a = e.audioMixing.sounds[n];
  8688. a && "-1" !== n && t.push({
  8689. soundId: parseInt(n),
  8690. volume: a.volume
  8691. })
  8692. }
  8693. return t
  8694. },
  8695. e.setEffectsVolume = function(t, n) {
  8696. var a = s.b.reportApiInvoke(e.sid, {
  8697. name: "Stream.setEffectsVolume",
  8698. options: arguments,
  8699. tag: "tracer",
  8700. callback: n
  8701. });
  8702. for (var i in Object(z.checkValidNumber)(t, "volume", 0, 100), e.audioMixing.defaultVolume = t, e.audioMixing.sounds) {
  8703. var o = e.audioMixing.sounds[i];
  8704. "-1" !== i && (o.volume = t)
  8705. }
  8706. e._flushAudioMixingMuteStatus(),
  8707. a(null)
  8708. },
  8709. e.setVolumeOfEffect = function(t, n, a) {
  8710. var i = s.b.reportApiInvoke(e.sid, {
  8711. name: "Stream.setVolumeOfEffect",
  8712. options: arguments,
  8713. tag: "tracer",
  8714. callback: a
  8715. });
  8716. Object(z.checkValidNumber)(t, "soundId", 0, 1e4),
  8717. Object(z.checkValidNumber)(n, "volume", 0, 100),
  8718. e._initSoundIfNotExists(t);
  8719. var o = e.audioMixing.sounds[t];
  8720. o.volume = n,
  8721. e._flushAudioMixingMuteStatus(),
  8722. i(null)
  8723. }
  8724. } (t),
  8725. he.addVideoEffectCapability(t),
  8726. function(e, t) {
  8727. e.videoConstraint = {},
  8728. t.cameraId && (e.videoConstraint.deviceId = {
  8729. exact: t.cameraId
  8730. }),
  8731. t.facingMode && (e.videoConstraint.facingMode = t.facingMode),
  8732. e.videoSize && (e.videoConstraint.width = e.videoSize[0], e.videoConstraint.height = e.videoSize[1]),
  8733. Object(g.isLegacyChrome)() || (e.videoConstraint.frameRate = {
  8734. ideal: 30,
  8735. max: 30
  8736. }),
  8737. e.audioConstraint = {},
  8738. t.microphoneId && (e.audioConstraint.deviceId = {
  8739. exact: t.microphoneId
  8740. }),
  8741. 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))),
  8742. e.screenConstraint = {},
  8743. t.sourceId && (e.screenConstraint.sourceId = t.sourceId),
  8744. t.extensionId && Object(g.isChrome)() ? (e.screenConstraint.extensionId = t.extensionId, e.screenConstraint.mandatory = {
  8745. chromeMediaSource: "desktop",
  8746. maxWidth: e.screenAttributes.width,
  8747. maxHeight: e.screenAttributes.height,
  8748. maxFrameRate: e.screenAttributes.maxFr,
  8749. minFrameRate: e.screenAttributes.minFr
  8750. }) : (e.screenConstraint.mediaSource = "screen", e.screenConstraint.width = e.screenAttributes.width, e.screenConstraint.height = e.screenAttributes.height, e.screenConstraint.frameRate = {
  8751. ideal: e.screenAttributes.maxFr,
  8752. max: e.screenAttributes.maxFr
  8753. }),
  8754. t.mediaSource && (e.screenConstraint.mediaSource = t.mediaSource),
  8755. e.setVideoResolution = function(n) {
  8756. var a = s.b.reportApiInvoke(e.sid, {
  8757. name: "Stream.setVideoResolution",
  8758. options: arguments,
  8759. tag: "tracer"
  8760. });
  8761. if (! (n instanceof Array)) {
  8762. var i = Te(n += "");
  8763. return i && i.video ? (e.videoConstraint = E()(e.videoConstraint, {
  8764. width: {
  8765. ideal: i.video.width
  8766. },
  8767. height: {
  8768. ideal: i.video.height
  8769. }
  8770. }), t.attributes.resolution = i.attributes.resolution, (o = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0]) && o.applyConstraints ? (r.
  8771. default.debug("setVideoResolution applyConstraints", e.videoConstraint), o.applyConstraints(e.videoConstraint).then(a).
  8772. catch(a)) : a(), !0) : (a("NO_PROFILE_".concat(n)), !1)
  8773. }
  8774. var o, c = n[0],
  8775. d = n[1];
  8776. e.videoConstraint = E()(e.videoConstraint, {
  8777. width: {
  8778. ideal: c
  8779. },
  8780. height: {
  8781. ideal: d
  8782. }
  8783. }),
  8784. t.attributes.resolution = "".concat(c, "x").concat(d),
  8785. (o = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0]) && o.applyConstraints ? (r.
  8786. default.debug("setVideoResolution applyConstraints", e.videoConstraint), he.disableVideoEffect(e).then((function() {
  8787. return o.applyConstraints(e.videoConstraint).then(a).
  8788. catch(a)
  8789. })).then((function() {
  8790. return he.restoreVideoEffect(e)
  8791. }))) : a()
  8792. },
  8793. e.setVideoFrameRate = function(t) {
  8794. var n = s.b.reportApiInvoke(e.sid, {
  8795. name: "Stream.setVideoFrameRate",
  8796. options: arguments,
  8797. tag: "tracer"
  8798. });
  8799. if (Object(g.isFireFox)()) return n("FIREFOX_NOT_SUPPORTED"),
  8800. !1;
  8801. if ("object" === be()(t) && t instanceof Array && t.length > 1) {
  8802. e.videoConstraint = E()(e.videoConstraint, {
  8803. frameRate: {
  8804. ideal: t[0],
  8805. max: t[1]
  8806. }
  8807. }),
  8808. e.attributes.minFrameRate = t[0],
  8809. e.attributes.maxFrameRate = t[1];
  8810. var a = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0];
  8811. return a && a.applyConstraints ? (r.
  8812. default.debug("setVideoFrameRate applyConstraints", e.videoConstraint), a.applyConstraints(e.videoConstraint).then(n).
  8813. catch(n)) : n(),
  8814. !0
  8815. }
  8816. return n("INVALID_PARAM_".concat(JSON.stringify(t))),
  8817. !1
  8818. },
  8819. e.setVideoBitRate = function(n) {
  8820. var a = s.b.reportApiInvoke(e.sid, {
  8821. name: "Stream.setVideoBitRate",
  8822. options: arguments,
  8823. tag: "tracer"
  8824. });
  8825. 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)
  8826. },
  8827. e.setScreenBitRate = function(t) {
  8828. var n = s.b.reportApiInvoke(e.sid, {
  8829. name: "Stream.setScreenBitRate",
  8830. options: arguments,
  8831. tag: "tracer"
  8832. });
  8833. 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)
  8834. },
  8835. e.setScreenProfile = function(t) {
  8836. var n = s.b.reportApiInvoke(e.sid, {
  8837. name: "Stream.setScreenProfile",
  8838. options: arguments,
  8839. tag: "tracer"
  8840. });
  8841. Object(z.checkValidEnum)(t, "profile", ["480p_1", "480p_2", "720p_1", "720p_2", "1080p_1", "1080p_2"]);
  8842. var a = Te(t);
  8843. 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)
  8844. },
  8845. e.setVideoProfileCustom = function(t) {
  8846. var n = s.b.reportApiInvoke(e.sid, {
  8847. name: "Stream.setVideoProfileCustom",
  8848. options: arguments,
  8849. tag: "tracer"
  8850. });
  8851. e.setVideoResolution(t[0]),
  8852. e.setVideoFrameRate([t[1], t[1]]),
  8853. e.setVideoBitRate([t[2], t[2]]),
  8854. n()
  8855. },
  8856. e.setVideoProfileCustomPlus = function(n) {
  8857. var a = s.b.reportApiInvoke(e.sid, {
  8858. name: "Stream.setVideoProfileCustom",
  8859. options: arguments,
  8860. tag: "tracer"
  8861. });
  8862. e.setVideoResolution([n.width, n.height]),
  8863. t.attributes.resolution = "".concat(n.width, "x").concat(n.height),
  8864. e.setVideoFrameRate([n.framerate, n.framerate]),
  8865. e.setVideoBitRate([n.bitrate, n.bitrate]),
  8866. a()
  8867. },
  8868. e.setVideoProfile = function(n) {
  8869. var a = s.b.reportApiInvoke(e.sid, {
  8870. name: "Stream.setVideoProfile",
  8871. options: arguments,
  8872. tag: "tracer"
  8873. }),
  8874. i = Te(n);
  8875. if (!i) {
  8876. var o = "Invalid Profile ".concat(n);
  8877. throw new Error(o)
  8878. }
  8879. if (e.profile = n, i && i.video) {
  8880. e.profile = i.profileName,
  8881. e.videoConstraint = E()(e.videoConstraint, i.video),
  8882. e.connectionSpec && i.attributes.maxVideoBW && (e.connectionSpec.minVideoBW = i.attributes.minVideoBW, e.connectionSpec.maxVideoBW = i.attributes.maxVideoBW),
  8883. Object(g.isEdge)() && (e.videoConstraint.frameRate.max = 60),
  8884. Object(g.isFireFox)() && (e.videoConstraint.frameRate = {
  8885. ideal: 30,
  8886. max: 30
  8887. }),
  8888. t.attributes = E()(t.attributes, i.attributes),
  8889. e.pc && e.pc.renegotiate && e.pc.renegotiate();
  8890. var c = e.stream && e.stream.getVideoTracks && e.stream.getVideoTracks()[0];
  8891. return c && c.applyConstraints ? (r.
  8892. default.debug("setVideoProfile applyConstraints", e.videoConstraint), he.disableVideoEffect(e).then((function() {
  8893. return c.applyConstraints(e.videoConstraint)
  8894. })).then((function() {
  8895. return he.restoreVideoEffect(e)
  8896. })).then((function(t) {
  8897. return new Promise((function(n, i) {
  8898. a(t),
  8899. Object(H.vsResHack)(e.stream, (function(t, a) {
  8900. e.videoWidth = t,
  8901. e.videoHeight = a,
  8902. n()
  8903. }), (function(t) {
  8904. r.
  8905. default.warning("[".concat(e.streamId, "] vsResHack failed: "), t),
  8906. i()
  8907. }))
  8908. }))
  8909. })).
  8910. catch(a)) : a(),
  8911. !0
  8912. }
  8913. return a("INVALID_VIDEO_PROFILE_".concat(n)),
  8914. !1
  8915. },
  8916. e.setAudioProfile = function(t) {
  8917. var n = s.b.reportApiInvoke(e.sid, {
  8918. name: "Stream.setAudioProfile",
  8919. options: arguments,
  8920. tag: "tracer"
  8921. });
  8922. Object(z.checkValidEnum)(t, "profile", ["speech_low_quality", "speech_standard", "music_standard", "standard_stereo", "high_quality", "high_quality_stereo"]),
  8923. e.audioProfile = t;
  8924. var a = Ae(t);
  8925. return e.highQuality = a.highQuality,
  8926. e.stereo = a.stereo,
  8927. e.speech = a.speech,
  8928. e.lowQuality = a.lowQuality,
  8929. e.stereo && Object(g.isChrome)() && (e.audioConstraint.googAutoGainControl = !1, e.audioConstraint.googAutoGainControl2 = !1, e.audioConstraint.echoCancellation = !1, e.audioConstraint.googNoiseSuppression = !1),
  8930. n(),
  8931. !0
  8932. },
  8933. e.setVideoEncoderConfiguration = function(t) {
  8934. Object(z.checkValidObject)(t, "config");
  8935. var n = s.b.reportApiInvoke(e.sid, {
  8936. name: "Stream.setVideoEncoderConfiguration",
  8937. options: t,
  8938. tag: "tracer"
  8939. });
  8940. 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])),
  8941. 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])),
  8942. 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])),
  8943. n()
  8944. },
  8945. e.getSupportedProfile = function(t) {
  8946. var n = s.b.reportApiInvoke(e.sid, {
  8947. name: "Stream.getSupportedProfile",
  8948. options: arguments,
  8949. tag: "tracer",
  8950. callback: t
  8951. });
  8952. if (!e.local) {
  8953. var a = "ONLY_LOCAL_STREAM_SUPPORTED";
  8954. return r.
  8955. default.error(a),
  8956. n(a)
  8957. }
  8958. if (!e.stream) {
  8959. a = "STREAM_NOT_INIT";
  8960. return r.
  8961. default.error(a),
  8962. n(a)
  8963. }
  8964. if (!e.stream.getVideoTracks) {
  8965. a = "TRACK_NOT_SUPPORT";
  8966. return r.
  8967. default.error(a),
  8968. n(a)
  8969. }
  8970. var i = e.stream.getVideoTracks()[0];
  8971. if (!i) {
  8972. a = "NO_VIDEO_TRACK_FOUND";
  8973. return r.
  8974. default.error(a),
  8975. n(a)
  8976. }
  8977. if (!i.getCapabilities) {
  8978. a = "GETCAPABILITY_NOT_SUPPORT";
  8979. return r.
  8980. default.error(a),
  8981. n(a)
  8982. }
  8983. var o = i.getCapabilities(),
  8984. c = Re(o);
  8985. return n(null, c)
  8986. }
  8987. } (t, e),
  8988. t.getId = function() {
  8989. return t.streamId
  8990. },
  8991. t.getUserId = function() {
  8992. return t.userId
  8993. },
  8994. t.checkDualStreamEnabled = function() {
  8995. if (Object(o.getParameter)("DUALSTREAM_OPERATION_CHECK") && t.isDualStream) {
  8996. return r.
  8997. default.error("Operation not permitted: ".concat("DUAL_STREAM_ENABLED")),
  8998. "DUAL_STREAM_ENABLED"
  8999. }
  9000. return ! 1
  9001. },
  9002. t.setUserId = function(e) {
  9003. var n = s.b.reportApiInvoke(t.sid, {
  9004. name: "Stream.setUserId",
  9005. options: arguments,
  9006. tag: "tracer"
  9007. });
  9008. t.userId && r.
  9009. default.warning("[".concat(t.streamId, "] Stream.userId ").concat(t.userId, " => ").concat(e)),
  9010. t.userId = e,
  9011. n()
  9012. },
  9013. t.getAttributes = function() {
  9014. return e.screen ? t.screenAttributes: e.attributes
  9015. },
  9016. t.hasAudio = function() {
  9017. return !! t.audio
  9018. },
  9019. t.hasVideo = function() {
  9020. return !! t.video
  9021. },
  9022. t.hasScreen = function() {
  9023. return !! t.screen
  9024. },
  9025. t.hasScreenAudio = function() {
  9026. return !! t.screenAudio
  9027. },
  9028. t.isVideoOn = function() {
  9029. return (t.hasVideo() || t.hasScreen()) && !t.userMuteVideo
  9030. },
  9031. t.isAudioOn = function() {
  9032. return t.hasAudio() && !t.userMuteAudio
  9033. },
  9034. t.init = function(a, i) {
  9035. var o = s.b.reportApiInvoke(t.sid, {
  9036. callback: function(e, t) {
  9037. if (e) return i && i(e);
  9038. a && a(t)
  9039. },
  9040. name: "Stream.init",
  9041. options: arguments,
  9042. tag: "tracer"
  9043. }),
  9044. c = ((new Date).getTime(), arguments[2]);
  9045. if (void 0 === c && (c = 2), !0 === t.initialized) return o({
  9046. type: "warning",
  9047. msg: "STREAM_ALREADY_INITIALIZED"
  9048. });
  9049. if (!0 !== t.local) return o({
  9050. type: "warning",
  9051. msg: "STREAM_NOT_LOCAL"
  9052. });
  9053. var d = Math.random().toString().slice(3);
  9054. t._streamInitID = d,
  9055. t.videoSource ? t.videoName = "videoSource": t.video && (t.videoName = K.searchDeviceNameById(e.cameraId) || "default"),
  9056. t.audioSource ? t.audioName = "audioSource": t.audio && (t.audioName = K.searchDeviceNameById(e.microphoneId) || "default"),
  9057. t.screen && (t.screenName = e.extensionId || "default");
  9058. try {
  9059. if (e.audio || e.video || e.screen || e.screenAudio || e.videoSource || e.audioSource) {
  9060. r.
  9061. default.debug("[".concat(t.streamId, "] Requested access to local media"));
  9062. var u = {
  9063. streamId: t.streamId
  9064. };
  9065. e.videoSource ? u.videoSource = e.videoSource: e.screen ? u.screen = t.screenConstraint: e.video && (u.video = t.videoConstraint),
  9066. e.audioSource ? u.audioSource = e.audioSource: e.screenAudio ? u.screenAudio = e.screenAudio: e.audio && (u.audio = t.audioConstraint),
  9067. G(u, (function(a) {
  9068. if (u.screenAudio && !a.getAudioTracks()[0] && r.
  9069. default.warning("[".concat(t.streamId, "] Audio sharing is not selected")), u.screen && r.
  9070. default.debug("[".concat(t.streamId, "] User has granted access to screen sharing")), (u.video || u.audio) && r.
  9071. default.debug("[".concat(t.streamId, "] User has granted access to local media")), null === t._streamInitID) {
  9072. a.getTracks().forEach((function(e) {
  9073. e.stop()
  9074. }));
  9075. var i = {
  9076. type: "error",
  9077. msg: "STREAM_IS_CLOSED",
  9078. info: "stream is closed and cannot be initialized"
  9079. };
  9080. return r.
  9081. default.error(t.streamId, i.info),
  9082. void o(i)
  9083. }
  9084. if (t._streamInitID !== d) {
  9085. a.getTracks().forEach((function(e) {
  9086. e.stop()
  9087. }));
  9088. i = {
  9089. type: "error",
  9090. msg: "ABORT_OTHER_INIT",
  9091. info: "stream initialization is aborted because of another stream.init"
  9092. };
  9093. return r.
  9094. default.error(t.streamId, i.info),
  9095. void o(i)
  9096. }
  9097. t.dispatchEvent({
  9098. type: "accessAllowed"
  9099. }),
  9100. t.stream = a,
  9101. t.initialized = !0,
  9102. t.reloadDeviceName(),
  9103. t.hasVideo() && Object(H.vsResHack)(a, (function(e, n) {
  9104. t.videoWidth = e,
  9105. t.videoHeight = n
  9106. }), (function(e) {
  9107. r.
  9108. default.warning("[".concat(t.streamId, "] vsResHack failed: "), e)
  9109. })),
  9110. e.screen && t.stream && t.stream.getVideoTracks()[0] && (t.stream.getVideoTracks()[0].onended = function() {
  9111. t.dispatchEvent({
  9112. type: "stopScreenSharing"
  9113. })
  9114. }),
  9115. t.stream && t.stream.getTracks && t.stream.getTracks().forEach((function(e) {
  9116. e && !e.onended && (e.onended = n)
  9117. })),
  9118. o()
  9119. }), (function(e) {
  9120. var n = {
  9121. type: "error",
  9122. info: null
  9123. };
  9124. 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) {
  9125. case "Starting video failed":
  9126. case "TrackStartError":
  9127. if (t.videoConstraint && (delete t.videoConstraint.width, delete t.videoConstraint.height), c > 0) return void setTimeout((function() {
  9128. t.init((function(e) {
  9129. return o(e)
  9130. }), o, c - 1)
  9131. }), 1);
  9132. n.msg = "MEDIA_OPTION_INVALID";
  9133. break;
  9134. case "DevicesNotFoundError":
  9135. n.msg = "DEVICES_NOT_FOUND";
  9136. break;
  9137. case "NotSupportedError":
  9138. n.msg = "NOT_SUPPORTED";
  9139. break;
  9140. case "PermissionDeniedError":
  9141. case "InvalidStateError":
  9142. n.msg = "PERMISSION_DENIED",
  9143. t.dispatchEvent({
  9144. type: "accessDenied"
  9145. });
  9146. break;
  9147. case "PERMISSION_DENIED":
  9148. case "NotAllowedError":
  9149. t.dispatchEvent({
  9150. type:
  9151. "accessDenied"
  9152. });
  9153. break;
  9154. case "ConstraintNotSatisfiedError":
  9155. n.msg = "CONSTRAINT_NOT_SATISFIED";
  9156. break;
  9157. default:
  9158. n.msg || (n.msg = "UNDEFINED")
  9159. }
  9160. var a = "Media access ".concat(n.msg).concat(n.info ? ": " + n.info: "");
  9161. r.
  9162. default.error("[".concat(t.streamId, "] "), a),
  9163. o(n)
  9164. }))
  9165. } else o({
  9166. type: "warning",
  9167. msg: "STREAM_HAS_NO_MEDIA_ATTRIBUTES"
  9168. })
  9169. } catch(e) {
  9170. r.
  9171. default.error("[".concat(t.streamId, "] Stream init: "), e),
  9172. o({
  9173. type: "error",
  9174. msg: e.message || e
  9175. })
  9176. }
  9177. },
  9178. t.reloadDeviceName = function() {
  9179. if (t.stream) {
  9180. if (t.stream.getVideoTracks) {
  9181. var e = t.stream.getVideoTracks()[0];
  9182. e && e.label && (t.videoName = e.label)
  9183. }
  9184. if (t.stream.getAudioTracks) {
  9185. var n = t.stream.getAudioTracks()[0];
  9186. n && n.label && (t.audioName = n.label)
  9187. }
  9188. }
  9189. },
  9190. t.close = function() {
  9191. var e = s.b.reportApiInvoke(null, {
  9192. name: "Stream.close",
  9193. options: arguments,
  9194. tag: "tracer"
  9195. });
  9196. if (r.
  9197. default.debug("[".concat(t.streamId, "] Close stream with id"), t.streamId), t._originStream) try {
  9198. t._originStream.getTracks().map((function(e) {
  9199. return e.stop()
  9200. }))
  9201. } catch(e) {}
  9202. if (void 0 !== t.stream) {
  9203. var n = t.stream.getTracks();
  9204. for (var a in n) n.hasOwnProperty(a) && n[a].stop(); ! t.isLowStream && t.local ? he.disableVideoEffect(t).then((function() {
  9205. t.stream = void 0
  9206. })) : (t.stream && t.stream.clean && t.stream.clean(), t.stream = void 0)
  9207. }
  9208. if (Object(g.isSafari)() && t.pc && t.pc.peerConnection && t.pc.peerConnection.removeTrack && t.pc.peerConnection.getSenders) {
  9209. var i = t.pc.peerConnection.getSenders();
  9210. i.forEach((function(e) {
  9211. e && (r.
  9212. default.debug("[".concat(t.streamId, "] Remove Track"), e), t.pc.peerConnection.removeTrack(e))
  9213. }))
  9214. }
  9215. t.local && (t.initialized = !1),
  9216. t._streamInitID = null,
  9217. t._onAudioMute = void 0,
  9218. t._onAudioUnmute = void 0,
  9219. t._onVideoMute = void 0,
  9220. t._onVideoUnmute = void 0,
  9221. t.lowStream && t.lowStream.close(),
  9222. e()
  9223. },
  9224. t.enableAudio = function() {
  9225. var e, n = s.b.reportApiInvoke(t.sid, {
  9226. name: "Stream.enableAudio",
  9227. options: arguments,
  9228. tag: "tracer"
  9229. });
  9230. return r.
  9231. default.deprecate("[".concat(t.streamId, "] Stream.enableAudio is deprecated and will be removed in the future. Use Stream.unmuteAudio instead")),
  9232. t.userMuteAudio || r.
  9233. default.warning("[".concat(t.streamId, "] User already enableAudio")),
  9234. t.userMuteAudio = !1,
  9235. n(null, e = !t.peerMuteAudio && t._unmuteAudio()),
  9236. e
  9237. },
  9238. t.disableAudio = function() {
  9239. var e = s.b.reportApiInvoke(t.sid, {
  9240. name: "Stream.disableAudio",
  9241. options: arguments,
  9242. tag: "tracer"
  9243. });
  9244. r.
  9245. default.deprecate("[".concat(t.streamId, "] Stream.disableAudio is deprecated and will be removed in the future. Use Stream.muteAudio instead")),
  9246. t.userMuteAudio && r.
  9247. default.warning("[".concat(t.streamId, "] User already disableAudio")),
  9248. t.userMuteAudio = !0;
  9249. var n = t._muteAudio();
  9250. return e(null, n),
  9251. n
  9252. },
  9253. t.enableVideo = function() {
  9254. var e, n = s.b.reportApiInvoke(t.sid, {
  9255. name: "Stream.enableVideo",
  9256. options: arguments,
  9257. tag: "tracer"
  9258. });
  9259. return r.
  9260. default.deprecate("[".concat(t.streamId, "] Stream.enableVideo is deprecated and will be removed in the future. Use Stream.unmuteVideo instead")),
  9261. t.userMuteVideo || r.
  9262. default.warning("[".concat(t.streamId, "] User already enableVideo")),
  9263. t.userMuteVideo = !1,
  9264. t.lowStream && (t.lowStream.userMuteVideo = !1),
  9265. n(null, e = !t.peerMuteVideo && t._unmuteVideo()),
  9266. e
  9267. },
  9268. t.disableVideo = function() {
  9269. var e = s.b.reportApiInvoke(t.sid, {
  9270. name: "Stream.disableVideo",
  9271. options: arguments,
  9272. tag: "tracer"
  9273. });
  9274. r.
  9275. default.deprecate("[".concat(t.streamId, "] Stream.disableVideo is deprecated and will be removed in the future. Use Stream.muteVideo instead")),
  9276. t.userMuteVideo && r.
  9277. default.warning("[".concat(t.streamId, "] User already disableVideo")),
  9278. t.userMuteVideo = !0,
  9279. t.lowStream && (t.lowStream.userMuteVideo = !0);
  9280. var n = t._muteVideo();
  9281. return e(null, n),
  9282. n
  9283. },
  9284. t.unmuteAudio = function() {
  9285. var e, n = s.b.reportApiInvoke(t.sid, {
  9286. name: "Stream.unmuteAudio",
  9287. options: arguments,
  9288. tag: "tracer"
  9289. });
  9290. return t.userMuteAudio || r.
  9291. default.warning("[".concat(t.streamId, "] User already unmuteAudio")),
  9292. t.userMuteAudio = !1,
  9293. n(null, e = !t.peerMuteAudio && t._unmuteAudio()),
  9294. e
  9295. },
  9296. t.muteAudio = function() {
  9297. var e = s.b.reportApiInvoke(t.sid, {
  9298. name: "Stream.muteAudio",
  9299. options: arguments,
  9300. tag: "tracer"
  9301. });
  9302. t.userMuteAudio && r.
  9303. default.warning("[".concat(t.streamId, "] User already muteAudio")),
  9304. t.userMuteAudio = !0;
  9305. var n = t._muteAudio();
  9306. return e(null, n),
  9307. n
  9308. },
  9309. t.unmuteVideo = function() {
  9310. var e, n = s.b.reportApiInvoke(t.sid, {
  9311. name: "Stream.unmuteVideo",
  9312. options: arguments,
  9313. tag: "tracer"
  9314. });
  9315. return t.userMuteVideo || r.
  9316. default.warning("[".concat(t.streamId, "] User already unmuteVideo")),
  9317. t.userMuteVideo = !1,
  9318. t.lowStream && (t.lowStream.userMuteVideo = !1),
  9319. n(null, e = !t.peerMuteVideo && t._unmuteVideo()),
  9320. e
  9321. },
  9322. t.muteVideo = function() {
  9323. var e = s.b.reportApiInvoke(t.sid, {
  9324. name: "Stream.muteVideo",
  9325. options: arguments,
  9326. tag: "tracer"
  9327. });
  9328. t.userMuteVideo && r.
  9329. default.warning("[".concat(t.streamId, "] User already muteVideo")),
  9330. t.userMuteVideo = !0,
  9331. t.lowStream && (t.lowStream.userMuteVideo = !0);
  9332. var n = t._muteVideo();
  9333. return e(null, n),
  9334. n
  9335. },
  9336. t._unmuteAudio = function() {
  9337. return r.
  9338. default.debug("[".concat(t.streamId, "] Unmuted audio stream with id "), t.streamId),
  9339. t._flushAudioMixingMuteStatus(!1),
  9340. !(!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)
  9341. },
  9342. t._isAudioMuted = function() {
  9343. if (t.stream && t.hasAudio()) {
  9344. var e = t.stream.getAudioTracks();
  9345. return e.length > 0 && !e[0].enabled
  9346. }
  9347. return ! 1
  9348. },
  9349. t._isVideoMuted = function() {
  9350. if (t.stream && t.hasVideo()) {
  9351. var e = t.stream.getVideoTracks();
  9352. return e.length > 0 && !e[0].enabled
  9353. }
  9354. return ! 1
  9355. },
  9356. t._muteAudio = function() {
  9357. return r.
  9358. default.debug("[".concat(t.streamId, "] Muted audio stream with id "), t.streamId),
  9359. t._flushAudioMixingMuteStatus(!0),
  9360. !!(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, {
  9361. succ: !0,
  9362. reason: "muteAudio"
  9363. }), !0)
  9364. },
  9365. t._unmuteVideo = function() {
  9366. return r.
  9367. default.debug("[".concat(t.streamId, "] Unmuted video stream with id"), t.streamId),
  9368. !(!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)
  9369. },
  9370. t._muteVideo = function() {
  9371. return r.
  9372. default.debug("[".concat(t.streamId, "] Muted video stream with id"), t.streamId),
  9373. !!(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, {
  9374. succ: !0,
  9375. reason: "muteVideo"
  9376. }), !0)
  9377. },
  9378. t.addTrack = function(a) {
  9379. var i = s.b.reportApiInvoke(t.sid, {
  9380. name: "Stream.addTrack",
  9381. options: arguments,
  9382. tag: "tracer"
  9383. });
  9384. if (t.pc && t.pc.addTrack(a, t.stream), "audio" == a.kind) {
  9385. t._cleanupAudioMixing();
  9386. var o = new MediaStream;
  9387. t.userMuteAudio && (a.enabled = !1),
  9388. o.addTrack(a);
  9389. var r = t.stream.getVideoTracks()[0];
  9390. r && o.addTrack(r),
  9391. t.audio = !0,
  9392. e.audio = !0,
  9393. t.stream = o,
  9394. t.audioLevelHelper = null,
  9395. t.player && t.player.video && (t.player.video.srcObject = t.stream)
  9396. } else t.userMuteVideo && (a.enabled = !1),
  9397. t.stream.addTrack(a),
  9398. t.video = !0,
  9399. e.video = !0;
  9400. a.onended || (a.onended = n),
  9401. i()
  9402. },
  9403. t.removeTrack = function(n) {
  9404. var a = s.b.reportApiInvoke(t.sid, {
  9405. name: "Stream.removeTrack",
  9406. options: arguments,
  9407. tag: "tracer"
  9408. });
  9409. t.pc && t.pc.removeTrack(n, t.stream),
  9410. t.stream.removeTrack(n),
  9411. t._cleanupAudioMixing(),
  9412. "audio" === n.kind ? (t.audio = !1, e.audio = !1) : (t.video = !1, e.video = !1),
  9413. t.audioLevelHelper = null,
  9414. "live" == n.readyState && (n.stop(), r.
  9415. default.debug("[".concat(t.streamId, "] Track ").concat(n.kind, " Stopped"))),
  9416. a()
  9417. },
  9418. t.setAudioOutput = function(e, n, a) {
  9419. var i = s.b.reportApiInvoke(t.sid, {
  9420. callback: function(e, t) {
  9421. if (e) return a && a(e);
  9422. n && n(t)
  9423. },
  9424. name: "Stream.setAudioOutput",
  9425. options: arguments,
  9426. tag: "tracer"
  9427. });
  9428. return Object(z.isValidString)(e, 1, 255) ? (t.audioOutput = e, t.player ? void t.player.setAudioOutput(e, (function() {
  9429. return i()
  9430. }), i) : i()) : (r.
  9431. default.error("[".concat(t.streamId, "] setAudioOutput Invalid Parameter"), e), i(I.
  9432. default.INVALID_PARAMETER))
  9433. },
  9434. t.play = function(e, n, a) {
  9435. "function" == typeof n && (a = n, n = null),
  9436. r.
  9437. default.debug("[".concat(t.streamId, "] play()."), e, n);
  9438. var i = s.b.reportApiInvoke(t.sid, {
  9439. name: "Stream.play",
  9440. options: arguments,
  9441. tag: "tracer",
  9442. callback: a
  9443. });
  9444. 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.
  9445. default.warning("[".concat(t.streamId, "] Stream.play(): Stream is already playing. Fallback to resume stream")),
  9446. t.resume().then((function() {
  9447. i(null)
  9448. })).
  9449. catch(i);
  9450. else {
  9451. t.elementID = e,
  9452. t.playOptions = n,
  9453. !t.local || t.video || t.screen ? (t.player = new T({
  9454. id: t.getId(),
  9455. stream: t,
  9456. elementID: e,
  9457. options: n
  9458. }), t.local && he.applyEffectInPlayer(t)) : t.hasAudio() && (t.player = new T({
  9459. id: t.getId(),
  9460. stream: t,
  9461. elementID: e,
  9462. options: n
  9463. }));
  9464. var o = {
  9465. video: null,
  9466. audio: null
  9467. },
  9468. c = function e(n) {
  9469. if (o[n.mediaType] = n, o.video && o.audio) if (t.removeEventListener("player-status-change", e), o.video.isErrorState || o.audio.isErrorState) {
  9470. var a = o.video.isErrorState ? o.video: o.audio;
  9471. i({
  9472. isErrorState: !0,
  9473. status: a.status,
  9474. reason: a.reason,
  9475. video: o.video,
  9476. audio: o.audio
  9477. })
  9478. } else "aborted" === o.video.status && "aborted" === o.audio.status ? i({
  9479. status: "aborted",
  9480. reason: "stop",
  9481. video: o.video,
  9482. audio: o.audio
  9483. }) : i(null)
  9484. };
  9485. t.on("player-status-change", c),
  9486. t.audioOutput && t.player.setAudioOutput(t.audioOutput),
  9487. void 0 !== t.audioLevel && t.player.setAudioVolume(t.audioLevel),
  9488. t._flushAudioMixingMuteStatus(!1)
  9489. }
  9490. },
  9491. t.stop = function() {
  9492. var e = s.b.reportApiInvoke(t.sid, {
  9493. name: "Stream.stop",
  9494. options: arguments,
  9495. tag: "tracer"
  9496. });
  9497. r.
  9498. default.debug("[".concat(t.streamId, "] Stop stream player with id "), t.streamId),
  9499. t.player ? (he.removeEffectFromLocalPlayer(t), t.player.destroy(), delete t.player) : r.
  9500. default.error("[".concat(t.streamId, "] Stream.stop(): Stream is not playing")),
  9501. t._flushAudioMixingMuteStatus(!0),
  9502. e()
  9503. },
  9504. t.isPlaying = function() {
  9505. return !! t.player
  9506. },
  9507. t.isPaused = function() {
  9508. 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)))
  9509. },
  9510. t.resume = function() {
  9511. var e, n;
  9512. 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")
  9513. },
  9514. t.getVideoTrack = function() {
  9515. var e = s.b.reportApiInvoke(t.sid, {
  9516. name: "Stream.getVideoTrack",
  9517. options: arguments,
  9518. tag: "tracer"
  9519. });
  9520. if (t.stream && t.stream.getVideoTracks) {
  9521. var n = t.stream.getVideoTracks()[0];
  9522. if (n) return r.
  9523. default.info("[".concat(t.streamId, "] getVideoTrack"), n),
  9524. e(),
  9525. n
  9526. }
  9527. r.
  9528. default.info("[".concat(t.streamId, "] getVideoTrack None")),
  9529. e(null, "getVideoTrack None")
  9530. },
  9531. t.getAudioTrack = function() {
  9532. var e = s.b.reportApiInvoke(t.sid, {
  9533. name: "Stream.getAudioTrack",
  9534. options: arguments,
  9535. tag: "tracer"
  9536. });
  9537. if (t.stream && t.stream.getAudioTracks) {
  9538. var n = t.stream.getAudioTracks()[0];
  9539. if (n) return r.
  9540. default.info("[".concat(t.streamId, "] getAudioTracks"), n),
  9541. e(),
  9542. n
  9543. }
  9544. r.
  9545. default.info("[".concat(t.streamId, "] getAudioTracks None")),
  9546. e(null, "getAudioTracks None")
  9547. },
  9548. t._hasVideoTracks = function() {
  9549. return !! (t.stream && t.stream.getVideoTracks && t.stream.getVideoTracks()[0])
  9550. },
  9551. t._hasAudioTracks = function() {
  9552. return !! (t.stream && t.stream.getAudioTracks && t.stream.getAudioTracks()[0])
  9553. },
  9554. t._replaceMediaStreamTrack = function(e, n, a) {
  9555. if (t.stream) {
  9556. if ("video" == e.kind) {
  9557. if (o = t.stream.getVideoTracks()[0]) return t.userMuteVideo && (e.enabled = !1),
  9558. t.stream.removeTrack(o),
  9559. t.stream.addTrack(e),
  9560. r.
  9561. default.debug("[".concat(t.streamId, "] _replaceMediaStreamTrack ").concat(e.kind, " SUCCESS")),
  9562. "live" == o.readyState && (o.stop(), r.
  9563. default.debug("[".concat(t.streamId, "] Track ").concat(o.kind, " Stopped"))),
  9564. n && n();
  9565. var i = "MEDIASTREAM_TRACK_NOT_FOUND";
  9566. return r.
  9567. default.error("[".concat(t.streamId, "] MEDIASTREAM_TRACK_NOT_FOUND ").concat(e.kind)),
  9568. a(i)
  9569. }
  9570. if ("audio" == e.kind) {
  9571. var o;
  9572. if (o = t.stream.getAudioTracks()[0]) {
  9573. t.userMuteAudio && (e.enabled = !1);
  9574. var s = new MediaStream;
  9575. s.addTrack(e);
  9576. var c = t.stream && t.stream.getVideoTracks()[0];
  9577. return c && s.addTrack(c),
  9578. t.stream = s,
  9579. t.audioLevelHelper = null,
  9580. t.player && t.player.video && (t.player.video.srcObject = t.stream),
  9581. r.
  9582. default.debug("[".concat(t.streamId, "] _replaceMediaStreamTrack SUCCESS")),
  9583. "live" == o.readyState && (o.stop(), r.
  9584. default.debug("[".concat(t.streamId, "] Track ").concat(o.kind, " Stopped"))),
  9585. n && n()
  9586. }
  9587. i = "MEDIASTREAM_TRACK_NOT_FOUND";
  9588. return r.
  9589. default.error("[".concat(t.streamId, "] MEDIASTREAM_TRACK_NOT_FOUND ").concat(e.kind)),
  9590. a(i)
  9591. }
  9592. i = "INVALID_TRACK_TYPE";
  9593. return r.
  9594. default.error("[".concat(t.streamId, "] _replaceMediaStreamTrack ").concat(i, " ").concat(e.kind)),
  9595. a && a(i)
  9596. }
  9597. i = "NO_STREAM_FOUND";
  9598. return r.
  9599. default.error("[".concat(t.streamId, "] _replaceMediaStreamTrack ").concat(i)),
  9600. a && a(i)
  9601. },
  9602. t.replaceTrack = function(e, a, i) {
  9603. var o = s.b.reportApiInvoke(t.sid, {
  9604. callback: function(e, t) {
  9605. if (e) return i && i(e);
  9606. a && a(t)
  9607. },
  9608. name: "Stream.replaceTrack",
  9609. options: arguments,
  9610. tag: "tracer"
  9611. });
  9612. 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() {
  9613. return r.
  9614. default.debug("[".concat(t.streamId, "] PeerConnection.replaceTrack ").concat(e.kind, " SUCCESS")),
  9615. t._replaceMediaStreamTrack(e, (function(e) {
  9616. return o(null, e)
  9617. }), o)
  9618. }), (function(n) {
  9619. return r.
  9620. default.error("[".concat(t.streamId, "] PeerConnection.replaceTrack ").concat(e.kind, " Failed ").concat(n)),
  9621. o(n)
  9622. })) : t._replaceMediaStreamTrack(e, (function(e) {
  9623. return o(null, e)
  9624. }), o)) : o("INVALID_TRACK")
  9625. },
  9626. t.setAudioVolume = function(e) {
  9627. var n = s.b.reportApiInvoke(t.sid, {
  9628. name: "Stream.setAudioVolume",
  9629. options: arguments,
  9630. tag: "tracer"
  9631. });
  9632. Object(z.checkValidNumber)(e, "level", 0, 100),
  9633. t.audioLevel = e,
  9634. t.player && t.player.setAudioVolume(e),
  9635. n()
  9636. },
  9637. t.getStats = function(e, n, a) {
  9638. var i = [];
  9639. i.push(t._getPCStats(a)),
  9640. i.push(new Promise((function(e) {
  9641. var n = {};
  9642. 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)),
  9643. e(n)
  9644. }))),
  9645. i.push(new Promise((function(e) {
  9646. var n = {};
  9647. 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),
  9648. e(n)
  9649. }))),
  9650. Promise.all(i).then((function(n) {
  9651. for (var a = {},
  9652. i = n.length - 1; i >= 0; i--) {
  9653. var o = n[i];
  9654. E()(a, o)
  9655. }
  9656. e && setTimeout(e.bind(t, a), 0)
  9657. })).
  9658. catch((function(e) {
  9659. n && setTimeout(n.bind(t, e), 0)
  9660. }))
  9661. },
  9662. t._getPCStats = function(e) {
  9663. return new Promise((function(n, a) {
  9664. if (!t.pc || "established" !== t.pc.state || !t.pc.getStats) {
  9665. return a("PEER_CONNECTION_NOT_ESTABLISHED")
  9666. }
  9667. t.pc.getStats((function(e) {
  9668. if (!t.pc || "established" !== t.pc.state || !t.pc.getStats) {
  9669. return a("PEER_CONNECTION_STATE_CHANGE")
  9670. }
  9671. var i = t.pc.isSubscriber ?
  9672. function(e) {
  9673. var t = {};
  9674. return e.forEach((function(e) {
  9675. 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))))
  9676. })),
  9677. t
  9678. } (e) : function(e) {
  9679. var t = {};
  9680. return e.forEach((function(e) {
  9681. 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))))
  9682. })),
  9683. t
  9684. } (e);
  9685. return n(i)
  9686. }), e)
  9687. })).then((function(e) {
  9688. 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)),
  9689. Promise.resolve(e)
  9690. }))
  9691. },
  9692. t.getAudioLevel = function() {
  9693. if (t.audioLevelHelper) return t.audioLevelHelper.getAudioLevel();
  9694. if (t.stream) {
  9695. if (0 !== t.stream.getAudioTracks().length) return t.audioLevelHelper = new H.audioLevelHelper(t.stream),
  9696. t.audioLevelHelper.getAudioLevel();
  9697. r.
  9698. default.warning("[".concat(t.streamId, "] can't get audioLevel beacuse no audio trace in stream"))
  9699. } else r.
  9700. default.warning("[".concat(t.streamId, "] can't get audioLevel beacuse no stream exist"))
  9701. },
  9702. t.setVideoProfile("480p_1"),
  9703. t._switchVideoDevice = function(e, n, a) {
  9704. if (e === t.cameraId) return n && n();
  9705. var i = {
  9706. video: E()({},
  9707. t.videoConstraint, {
  9708. deviceId: {
  9709. exact: e
  9710. }
  9711. }),
  9712. audio: !1
  9713. };
  9714. r.
  9715. default.debug("[".concat(t.streamId, "] ").concat(i)),
  9716. G(i, (function(i) {
  9717. try {
  9718. var o = function() {
  9719. t.isPlaying() && (t.stop(), t.elementID && t.play(t.elementID, t.playOptions)),
  9720. t.cameraId = e,
  9721. t.videoConstraint.deviceId = {
  9722. exact: e
  9723. },
  9724. t.userMuteVideo && (t.stream.getVideoTracks()[0].enabled = !1),
  9725. he.restoreVideoEffect(t).then((function() {
  9726. n && n()
  9727. }))
  9728. };
  9729. he.disableVideoEffect(t).then((function() {
  9730. Object(g.isSafari)() ? t.replaceTrack(i.getVideoTracks()[0], o, a) : (t.removeTrack(t.stream.getVideoTracks()[0]), t.addTrack(i.getVideoTracks()[0]), o())
  9731. }))
  9732. } catch(e) {
  9733. return a && a(e)
  9734. }
  9735. }), (function(e) {
  9736. return a && a(e)
  9737. }))
  9738. },
  9739. t._switchAudioDevice = function(e, n, a) {
  9740. if (e === t.microphoneId) return n && n();
  9741. var i = {
  9742. video: !1,
  9743. audio: E()({},
  9744. t.audioConstraint, {
  9745. deviceId: {
  9746. exact: e
  9747. }
  9748. })
  9749. };
  9750. r.
  9751. default.debug("[".concat(t.streamId, "] "), i),
  9752. G(i, (function(i) {
  9753. var o = function() {
  9754. t._cleanupAudioMixing(),
  9755. t.userMuteAudio && (t.stream.getAudioTracks()[0].enabled = !1),
  9756. t.isPlaying() && (t.stop(), t.elementID && t.play(t.elementID)),
  9757. t.microphoneId = e,
  9758. t.audioConstraint.deviceId = {
  9759. exact: e
  9760. },
  9761. n && n()
  9762. };
  9763. try {
  9764. Object(g.isSafari)() ? t.replaceTrack(i.getAudioTracks()[0], o, a) : (t.removeTrack(t.stream.getAudioTracks()[0]), t.addTrack(i.getAudioTracks()[0]), o())
  9765. } catch(e) {
  9766. return a && a(e)
  9767. }
  9768. }), (function(e) {
  9769. return a && a(e)
  9770. }))
  9771. },
  9772. t.switchDevice = function(e, n, a, i) {
  9773. var o = s.b.reportApiInvoke(t.sid, {
  9774. callback: function(e, t) {
  9775. if (e) return i && i(e);
  9776. a && a(t)
  9777. },
  9778. name: "Stream.switchDevice",
  9779. options: arguments,
  9780. tag: "tracer"
  9781. });
  9782. Object(z.checkValidString)(n, "deviceId");
  9783. var c = function() {
  9784. return t.inSwitchDevice = !1,
  9785. o()
  9786. },
  9787. d = function(e) {
  9788. t.inSwitchDevice = !1,
  9789. r.
  9790. default.error("[".concat(t.streamId, "] "), e),
  9791. o(e)
  9792. };
  9793. if (t.inSwitchDevice) return o("Device switch is in process.");
  9794. if (t.inSwitchDevice = !0, !t.local) return d("Only the local stream can switch the device.");
  9795. if (t.screen && "video" === e) return d("The device cannot be switched during screen-sharing.");
  9796. if (!t.video && "video" === e) return d("Video track not exist.");
  9797. if (!t.audio && "audio" === e) return d("Audio track not exist.");
  9798. if (t.videoSource || t.audioSource) return d("The device cannot be switched when using videoSource or audioSource.");
  9799. var u = !1;
  9800. for (var l in t.audioMixing.sounds) {
  9801. var p = t.audioMixing.sounds[l];
  9802. if (p.state !== t.audioMixing.states.IDLE) {
  9803. u = !0;
  9804. break
  9805. }
  9806. }
  9807. var f = t.audioMixing.audioContextInited;
  9808. if (f && u) return d("The device cannot be switched when using audio Mixing.");
  9809. K.getDeviceById(n, (function() {
  9810. if ("video" === e) t._switchVideoDevice(n, c, d);
  9811. else {
  9812. if ("audio" !== e) return d("Invalid type.");
  9813. t._switchAudioDevice(n, c, d)
  9814. }
  9815. }), (function() {
  9816. return d("The device does not exist.")
  9817. }))
  9818. },
  9819. t
  9820. },
  9821. Oe = a(27),
  9822. Ce = a(8),
  9823. Ne = a.n(Ce),
  9824. we = ["live", "rtc", "web", "interop", "h264_interop", "web-only"],
  9825. De = ["vp8", "h264"],
  9826. ke = ["aes-128-xts", "aes-256-xts", "aes-128-ecb", "sm4-128-ecb"],
  9827. Le = a(17),
  9828. Pe = a.n(Le),
  9829. Me = function(e) {
  9830. e && e.apply(this, [].slice.call(arguments, 1))
  9831. },
  9832. Ue = a(11),
  9833. xe = function(e) {
  9834. var t = c();
  9835. t.needReconnect = !0,
  9836. t.isTimeout = !1,
  9837. t.isInit = !0,
  9838. t.sendbytes = 0,
  9839. t.recvbytes = 0,
  9840. t.startTime = Date.now(),
  9841. t.lastMsgTime = null,
  9842. t.clientId = e.clientId,
  9843. t.hostIndex = 0,
  9844. t.requestID = 0,
  9845. e.host instanceof Array ? t.host = e.host: t.host = [e.host],
  9846. t.getSendBytes = function() {
  9847. return t.sendbytes
  9848. },
  9849. t.getRecvBytes = function() {
  9850. return t.recvbytes
  9851. },
  9852. t.getDuration = function() {
  9853. return Math.ceil((Date.now() - t.startTime) / 1e3)
  9854. },
  9855. t.getURL = function() {
  9856. return t.connection.url
  9857. },
  9858. t.reconnect = function() {
  9859. t.isInit = !0,
  9860. t.creatConnection()
  9861. },
  9862. t.connectNext = function() {
  9863. t.isInit = !0,
  9864. ++t.hostIndex,
  9865. r.
  9866. default.debug("[" + t.clientId + "] Gateway length:" + t.host.length + " current index:" + t.hostIndex),
  9867. t.hostIndex >= t.host.length ? t.dispatchEvent(p({
  9868. type: "recover"
  9869. })) : t.creatConnection()
  9870. },
  9871. t.replaceHost = function(e) {
  9872. t.host = e || t.host,
  9873. t.hostIndex = 0,
  9874. t.creatConnection()
  9875. },
  9876. t.creatConnection = function() {
  9877. if (t.needReconnect = !0, t.lts = (new Date).getTime(), t.connection = new WebSocket("wss://" + t.host[t.hostIndex]), t.connection.binaryType = "arraybuffer", t.turnConfig = {},
  9878. t.connection.url) {
  9879. var n = t.connection.url.match(/wss\:\/\/([^:]+):(\d+)/),
  9880. a = t.host[t.hostIndex].split(":"),
  9881. i = t.connection.url.match(/h=([^:]+)&p=(\d+)/);
  9882. 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))
  9883. }
  9884. t.connection.onopen = function(e) {
  9885. t.needReconnect = !0,
  9886. t.isTimeout = !1,
  9887. t.isInit = !1,
  9888. t.sendbytes = 0,
  9889. t.recvbytes = 0,
  9890. t.startTime = Date.now(),
  9891. Object(Ue.resetHTTPByetsCount)(),
  9892. clearTimeout(t.timeoutCheck),
  9893. t.dispatchEvent(p({
  9894. type: "onopen",
  9895. event: e,
  9896. socket: t
  9897. }))
  9898. },
  9899. t.connection.onmessage = function(e) {
  9900. if (e.data instanceof ArrayBuffer) t.dispatchEvent({
  9901. type: "onBinaryData",
  9902. data: e.data
  9903. });
  9904. else {
  9905. t.recvbytes += Object(H.lengthInUtf8Bytes)(e.data);
  9906. var n = JSON.parse(e.data);
  9907. t.lastMsgTime = Date.now(),
  9908. n.hasOwnProperty("_id") ? t.dispatchEvent(p({
  9909. type: n._id,
  9910. msg: n
  9911. })) : n.hasOwnProperty("_type") && t.dispatchSocketEvent(p({
  9912. type: n._type,
  9913. msg: n._message
  9914. }))
  9915. }
  9916. },
  9917. t.connection.onclose = function(n) {
  9918. t.needReconnect ? t.isTimeout || t.isInit ? (r.
  9919. default.debug("[" + t.clientId + "] websockect connect timeout"), s.b.joinGateway(e.sid, {
  9920. lts: t.lts,
  9921. succ: !1,
  9922. ec: "timeout",
  9923. addr: t.connection.url
  9924. }), t.connectNext()) : (t.dispatchEvent(p({
  9925. type: "disconnect",
  9926. event: n
  9927. })), t.requests && t.requests instanceof Array && (t.requests.map((function(e) {
  9928. e.callback("REQUEST_ABORT")
  9929. })), t.requests = [])) : (r.
  9930. default.debug("[" + t.clientId + "] websockect closeed"), Me(e.onFailure, n), clearTimeout(t.timeoutCheck), t.dispatchEvent(p({
  9931. type: "close",
  9932. event: n
  9933. })), t.connection.onopen = void 0, t.connection.onclose = void 0, t.connection.onerror = void 0, t.connection.onmessage = void 0, t.connection = void 0)
  9934. },
  9935. t.connection.onerror = function(e) {};
  9936. setTimeout((function() {
  9937. t.connection && t.connection.readyState != WebSocket.OPEN && (t.isTimeout = !0, t.connection.close())
  9938. }), 5e3)
  9939. },
  9940. t.creatConnection(),
  9941. t.sendMessage = function(e, n) {
  9942. if (t.connection && t.connection.readyState == WebSocket.OPEN) {
  9943. var a = JSON.stringify(e);
  9944. t.sendbytes += Object(H.lengthInUtf8Bytes)(a),
  9945. t.connection.send(a)
  9946. } else n({
  9947. error: "Gateway not connected"
  9948. })
  9949. },
  9950. t.disconnect = function() {
  9951. t.needReconnect = !0,
  9952. t.connection.close()
  9953. },
  9954. t.close = function() {
  9955. t.needReconnect = !1,
  9956. t.connection.onclose = void 0,
  9957. t.connection.close(),
  9958. clearInterval(t.requestTimer),
  9959. t.requests && t.requests instanceof Array && (t.requests.map((function(e) {
  9960. e.callback("REQUEST_ABORT")
  9961. })), t.requests = [])
  9962. },
  9963. t.sendSignalCommand = function(e, n) {
  9964. e._id = "_request_" + t.requestID,
  9965. t.requestID += 1,
  9966. "publish_stats" !== e._type && "subscribe_stats" !== e._type && "publish_stats_low" !== e._type && t.on(e._id, (function(a) {
  9967. a.msg && n && n(a.msg._result, a.msg.message),
  9968. delete t.dispatcher.eventListeners[e._id]
  9969. })),
  9970. t.sendMessage(e, (function(e) {
  9971. e.reason = "NOT_CONNECTED",
  9972. n && n(e.reason, e)
  9973. }))
  9974. },
  9975. t.requests = [];
  9976. var n = function(e) {
  9977. var n = t.requests.findIndex((function(t) {
  9978. return t.id === e.type
  9979. }));
  9980. if (n >= 0) var a = t.requests.splice(n, 1)[0];
  9981. 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.
  9982. default.warning("Detached Response", e.type, e.msg)
  9983. },
  9984. a = function(e) {
  9985. var n = this,
  9986. a = t.requests.findIndex((function(e) {
  9987. return e.id === n.id
  9988. }));
  9989. a >= 0 && (n = t.requests.splice(a, 1)[0]),
  9990. n && t.dispatcher.eventListeners[e.type] ? (delete t.dispatcher.eventListeners[e.type], e.reason = "NOT_CONNECTED", n.callback && n.callback(e.reason, e)) : r.
  9991. default.warning("handleSendError", n)
  9992. };
  9993. return t.sendRequest = function(e, i) {
  9994. e = E()({
  9995. _id: "_request_" + t.requestID
  9996. },
  9997. e),
  9998. t.requestID += 1;
  9999. var o = {
  10000. id: e._id,
  10001. timeoutCounter: 0,
  10002. stalledAt: Date.now(),
  10003. message: e,
  10004. callback: i
  10005. };
  10006. t.requests.push(o),
  10007. t.addEventListener(e._id, n),
  10008. t.sendMessage(e, a.bind(o))
  10009. },
  10010. t.checkRequestTimeout = function() {
  10011. 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--) {
  10012. var a = t.requests[n];
  10013. a.timeoutCounter >= e ? (t.requests.splice(n, 1), r.
  10014. default.error("Request Timeout", a.timeoutCounter, a.message), a.callback && a.callback("TIMEOUT")) : a.timeoutCounter++
  10015. }
  10016. },
  10017. clearInterval(t.requestTimer),
  10018. t.requestTimer = setInterval(t.checkRequestTimeout, Object(o.getParameter)("SIGNAL_REQUEST_WATCH_INTERVAL")),
  10019. t.sendReport = function(e) {
  10020. t.sendMessage(e, (function() {}))
  10021. },
  10022. t
  10023. },
  10024. Ve = function(e, t) {
  10025. var n = {
  10026. connect: function() {
  10027. t.host = e,
  10028. n.signal = xe(t),
  10029. n.on = n.signal.on,
  10030. n.dispatchEvent = n.signal.dispatchEvent,
  10031. n.signal.on("onopen", (function(e) {
  10032. n.signal.onEvent = function(e) {
  10033. n.dispatchEvent(p({
  10034. type: e.event,
  10035. msg: e
  10036. }))
  10037. },
  10038. n.dispatchEvent(p({
  10039. type: "connect",
  10040. msg: e
  10041. }))
  10042. })),
  10043. n.signal.on("onError", (function(e) {
  10044. var t = e.msg;
  10045. onError(t.code, "error")
  10046. }))
  10047. },
  10048. getLastMsgTime: function() {
  10049. return n.signal && n.signal.lastMsgTime
  10050. },
  10051. getSendBytes: function() {
  10052. return n.signal.getSendBytes()
  10053. },
  10054. getRecvBytes: function() {
  10055. return n.signal.getRecvBytes()
  10056. },
  10057. getDuration: function() {
  10058. return n.signal.getDuration()
  10059. },
  10060. disconnect: function() {
  10061. n.signal.disconnect()
  10062. },
  10063. close: function() {
  10064. n.signal.close()
  10065. },
  10066. getURL: function() {
  10067. return n.signal.getURL()
  10068. },
  10069. reconnect: function() {
  10070. n.signal.reconnect()
  10071. },
  10072. connectNext: function() {
  10073. n.signal.connectNext()
  10074. },
  10075. replaceHost: function(e) {
  10076. n.signal.replaceHost(e)
  10077. },
  10078. emitSimpleMessage: function(e, t) {
  10079. n.signal.sendSignalCommand(e, t)
  10080. },
  10081. emitRequest: function(e, t) {
  10082. n.signal.sendRequest(e, t)
  10083. },
  10084. emitReport: function(e) {
  10085. n.signal.sendReport(e)
  10086. }
  10087. };
  10088. return n.connect(),
  10089. n
  10090. },
  10091. je = function(e, t) {
  10092. var n = !1,
  10093. a = 0,
  10094. i = {
  10095. command: "convergeAllocateEdge",
  10096. sid: e.sid,
  10097. appId: e.appId,
  10098. token: e.token,
  10099. uid: e.uid,
  10100. cname: e.cname,
  10101. ts: Math.floor(Date.now() / 1e3),
  10102. version: o.VERSION,
  10103. seq: 0,
  10104. requestId: 1
  10105. };
  10106. Object(o.getParameter)("PROXY_CS").map((function(c) {
  10107. var d = (new Date).getTime();
  10108. Be("https://" + c + "/api/v1", i, (function(i, u) {
  10109. if (i) return r.
  10110. default.debug("[" + e.clientId + "] Request proxy server failed: ", i),
  10111. a++,
  10112. s.b.requestProxyAppCenter(e.sid, {
  10113. lts: d,
  10114. succ: !1,
  10115. APAddr: c,
  10116. workerManagerList: null,
  10117. ec: JSON.stringify(i),
  10118. response: JSON.stringify({
  10119. err: i,
  10120. res: u
  10121. })
  10122. }),
  10123. void(a >= Object(o.getParameter)("PROXY_CS").length && t && t("Get proxy server failed: request all failed"));
  10124. if (!n) if ((u = JSON.parse(u)).json_body) {
  10125. var l = JSON.parse(u.json_body);
  10126. if (r.
  10127. default.debug("[" + e.clientId + "] App return:", l.servers), 200 !== l.code) {
  10128. i = "Get proxy server failed: response code [" + l.code + "], reason [ " + l.reason + "]";
  10129. r.
  10130. default.debug("[" + e.clientId + "] " + i),
  10131. s.b.requestProxyAppCenter(e.sid, {
  10132. lts: d,
  10133. succ: !1,
  10134. APAddr: c,
  10135. workerManagerList: null,
  10136. ec: i,
  10137. response: JSON.stringify({
  10138. err: i,
  10139. res: u
  10140. })
  10141. })
  10142. } else {
  10143. n = !0;
  10144. var p = We(l.servers);
  10145. s.b.requestProxyAppCenter(e.sid, {
  10146. lts: d,
  10147. succ: !0,
  10148. APAddr: c,
  10149. workerManagerList: JSON.stringify(p),
  10150. ec: null,
  10151. response: JSON.stringify({
  10152. res: u
  10153. })
  10154. }),
  10155. t && t(null, p)
  10156. }
  10157. } else r.
  10158. default.debug("[" + e.clientId + "] Get proxy server failed: no json_body"),
  10159. s.b.requestProxyAppCenter(e.sid, {
  10160. lts: d,
  10161. succ: !1,
  10162. APAddr: c,
  10163. workerManagerList: null,
  10164. ec: "Get proxy server failed: no json_body",
  10165. response: JSON.stringify({
  10166. res: u
  10167. })
  10168. })
  10169. }))
  10170. }))
  10171. },
  10172. Be = function(e, t, n) {
  10173. var a = {
  10174. service_name: "webrtc_proxy",
  10175. json_body: JSON.stringify(t)
  10176. };
  10177. Object(Ue.post)(e, a, (function(e) {
  10178. n && n(null, e)
  10179. }), (function(e) {
  10180. n && n(e)
  10181. }), {
  10182. "X-Packet-Service-Type": 0,
  10183. "X-Packet-URI": 61
  10184. })
  10185. },
  10186. Fe = function(e, t, n) {
  10187. var a = !1,
  10188. i = 0,
  10189. o = {
  10190. command: "request",
  10191. gatewayType: "http",
  10192. appId: e.appId,
  10193. cname: e.cname,
  10194. uid: e.uid + "",
  10195. sdkVersion: "2.3.1",
  10196. sid: e.sid,
  10197. seq: 1,
  10198. ts: +new Date,
  10199. requestId: 3,
  10200. clientRequest: {
  10201. appId: e.appId,
  10202. cname: e.cname,
  10203. uid: e.uid + "",
  10204. sid: e.sid
  10205. }
  10206. };
  10207. t.map((function(c) {
  10208. var d = (new Date).getTime(); !
  10209. function(e, t, n) {
  10210. Object(Ue.post)(e, t, (function(e) {
  10211. n && n(null, e)
  10212. }), (function(e) {
  10213. n && n(e)
  10214. }))
  10215. } ("https://" + c + ":4000/v2/machine", o, (function(o, u) {
  10216. if (o) return r.
  10217. default.debug("[" + e.clientId + "] Request worker manager failed: ", o),
  10218. i++,
  10219. s.b.requestProxyWorkerManager(e.sid, {
  10220. lts: d,
  10221. succ: !1,
  10222. workerManagerAddr: c,
  10223. ec: JSON.stringify(o),
  10224. response: JSON.stringify({
  10225. res: u
  10226. })
  10227. }),
  10228. void(i >= t.length && n && n("requeet worker manager server failed: request failed"));
  10229. if (!a) {
  10230. if (! (u = JSON.parse(u)).serverResponse) return n && n("requeet worker manager server failed: serverResponse is undefined");
  10231. a = !0,
  10232. s.b.requestProxyWorkerManager(e.sid, {
  10233. lts: d,
  10234. succ: !0,
  10235. workerManagerAddr: c,
  10236. ec: JSON.stringify(o),
  10237. response: JSON.stringify({
  10238. res: u
  10239. })
  10240. }),
  10241. n && n(null, {
  10242. address: c,
  10243. serverResponse: u.serverResponse
  10244. })
  10245. }
  10246. }))
  10247. }))
  10248. },
  10249. We = function(e) {
  10250. if (!e || [] instanceof Array == !1) return [];
  10251. var t = [];
  10252. return e.forEach((function(e) {
  10253. var n;
  10254. e.address && e.tcp ? (e.address.match(/^[\.\:\d]+$/) ? n = "".concat(e.address.replace(/[^\d]/g, "-"), ".edge.agora.io") : (r.
  10255. 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.
  10256. default.error("[" + joinInfo.clientId + "] Invalid address format ", e)
  10257. })),
  10258. t
  10259. },
  10260. Ge = function(e, t) {
  10261. var n = E()({},
  10262. e),
  10263. a = Object(o.getParameter)("CDS_AP"),
  10264. i = [],
  10265. r = !1; (a = a.map((function(e) {
  10266. return n.proxyServer ? "https://".concat(n.proxyServer, "/ap/?url=").concat(e + "/api/v1") : "https://".concat(e, "/api/v1?action=config")
  10267. }))).map((function(e) { !
  10268. function(e, t, n) {
  10269. var a = {
  10270. flag: 64,
  10271. cipher_method: 0,
  10272. timeout: 1e3,
  10273. features: t
  10274. };
  10275. Object(Ue.post)(e, a, (function(e) {
  10276. try {
  10277. var t = JSON.parse(e);
  10278. n && n(null, t)
  10279. } catch(e) {
  10280. n && n(e)
  10281. }
  10282. n && n(null, e)
  10283. }), (function(e) {
  10284. n && n(e)
  10285. }), {
  10286. "X-Packet-Service-Type": 0,
  10287. "X-Packet-URI": 54
  10288. })
  10289. } (e, n, (function(e, n) {
  10290. r || (e ? (i.push(e), i.length >= a.length && t && t("ALL_REQUEST_FAILED")) : (r = !0, t && t(null, n)))
  10291. }))
  10292. }))
  10293. },
  10294. He = a(18),
  10295. qe = {},
  10296. Je = {},
  10297. Ye = function(e) {
  10298. return qe[e]
  10299. },
  10300. Ke = function(e, t, n, a, i) {
  10301. var c = (new Date).getTime(),
  10302. d = t,
  10303. u = "";
  10304. t.multiIP && t.multiIP.gateway_ip && (u = {
  10305. vocs_ip: [t.multiIP.uni_lbs_ip],
  10306. vos_ip: [t.multiIP.gateway_ip]
  10307. });
  10308. var l = {
  10309. opid: 133,
  10310. flag: 4096,
  10311. ts: +new Date,
  10312. key: t.token,
  10313. cname: t.cname,
  10314. sid: t.sid,
  10315. detail: {
  10316. 6 : t.stringUid,
  10317. 11 : i
  10318. },
  10319. uid: t.uid || 0
  10320. };
  10321. u && (l.detail[5] = JSON.stringify(u)),
  10322. Object(Ue.post)(e + "".concat( - 1 === e.indexOf("?") ? "?": "&", "action=wrtc_gateway"), l, (function(i) {
  10323. try {
  10324. var u = JSON.parse(i);
  10325. u.res && (u = u.res);
  10326. var l = u.code
  10327. } catch(e) {
  10328. var p = "requestChooseServer failed with unexpected body " + i;
  10329. return r.
  10330. default.error("[" + d.clientId + "]", p),
  10331. a(p)
  10332. }
  10333. if (l) return v = new RegExp(/10102\d{2}$/).test(l) ? "NO_SERVICE_AVAILABLE": I.APErrorCode[u.code] || l,
  10334. s.b.joinChooseServer(t.sid, {
  10335. lts: c,
  10336. succ: !1,
  10337. csAddr: e,
  10338. serverList: null,
  10339. ec: v
  10340. }),
  10341. a("Get server node failed [" + v + "]", e, v);
  10342. var f = [],
  10343. g = Object(o.getParameter)("GATEWAY_DOMAINS"),
  10344. m = 0;
  10345. if (e.indexOf(g[1]) > -1 && (m = 1), u.addresses.forEach((function(e) {
  10346. var t;
  10347. e.ip && e.port ? (e.ip.match(/^[\.\:\d]+$/) ? t = "".concat(e.ip.replace(/[^\d]/g, "-"), ".").concat(g[m++%g.length], ":").concat(e.port) : (r.
  10348. 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.
  10349. default.error("[" + d.clientId + "] Invalid address format ", e)
  10350. })), !f.length) {
  10351. r.
  10352. default.error("[" + d.clientId + "] Empty Address response", u);
  10353. var v = "EMPTY_ADDRESS_RESPONSE";
  10354. return s.b.joinChooseServer(t.sid, {
  10355. lts: c,
  10356. succ: !1,
  10357. csAddr: e,
  10358. serverList: null,
  10359. ec: v
  10360. }),
  10361. a("Get server node failed [" + v + "]", e, v)
  10362. }
  10363. var S = {
  10364. gateway_addr: f,
  10365. uid: u.uid,
  10366. cid: u.cid,
  10367. vid: u.detail && u.detail[8],
  10368. res: u,
  10369. uni_lbs_ip: u.detail
  10370. };
  10371. return n(S, e)
  10372. }), (function(e, n) {
  10373. "timeout" === e.type ? (s.b.joinChooseServer(t.sid, {
  10374. lts: c,
  10375. succ: !1,
  10376. csAddr: n,
  10377. serverList: null,
  10378. ec: "timeout"
  10379. }), a("Connect choose server timeout", n)) : (s.b.joinChooseServer(t.sid, {
  10380. lts: c,
  10381. succ: !1,
  10382. csAddr: n,
  10383. serverList: null,
  10384. ec: "server_wrong"
  10385. }), a("Connect choose server error", n))
  10386. }), {
  10387. "X-Packet-Service-Type": 0,
  10388. "X-Packet-URI": 69
  10389. })
  10390. },
  10391. ze = function(e, t, n) {
  10392. var a = !1,
  10393. i = null,
  10394. c = 1,
  10395. d = 1,
  10396. u = null,
  10397. l = e.clientId,
  10398. p = function t(d, p) {
  10399. if (!a) {
  10400. var f = !1,
  10401. m = !1,
  10402. v = [],
  10403. S = g.getBrowserInfo() || {};
  10404. Ge({
  10405. device: S.name,
  10406. system: S.os,
  10407. vendor: e.appId,
  10408. version: o.VERSION,
  10409. cname: e.cname,
  10410. sid: e.sid,
  10411. session_id: Object(s.a)(),
  10412. detail: "",
  10413. proxyServer: d
  10414. },
  10415. (function(t, n) {
  10416. m = !0;
  10417. try {
  10418. var a = Object.keys(n.test_tags)[0],
  10419. i = JSON.parse(n.test_tags[a]);
  10420. u = i[1]
  10421. } catch(e) {
  10422. u = null
  10423. }
  10424. s.b.reportApiInvoke(e.sid, {
  10425. name: "_config-distribute-request",
  10426. options: {
  10427. err: t,
  10428. res: n
  10429. }
  10430. })(),
  10431. Je[l] !== st.DISCONNECTED && Je[l] !== st.DISCONNECTING ? f && p && p(v, u) : r.
  10432. default.debug("[".concat(e.clientId, "] Request config success when connection state is ").concat(Je[l]))
  10433. })),
  10434. function(e, t, n) {
  10435. 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) {
  10436. if (c) s.b.joinChooseServer(e.sid, {
  10437. lts: i,
  10438. succ: !0,
  10439. csAddr: a,
  10440. serverList: n.gateway_addr,
  10441. cid: n.cid + "",
  10442. uid: n.uid + "",
  10443. ec: null
  10444. },
  10445. !1);
  10446. else {
  10447. if (clearTimeout(_), c = !0, e.proxyServer) for (var o = n.gateway_addr,
  10448. r = 0; r < o.length; r++) {
  10449. var d = o[r].split(":");
  10450. n.gateway_addr[r] = e.proxyServer + "/ws/?h=" + d[0] + "&p=" + d[1]
  10451. }
  10452. t(n),
  10453. s.b.joinChooseServer(e.sid, {
  10454. lts: i,
  10455. succ: !0,
  10456. csAddr: a,
  10457. serverList: n.gateway_addr,
  10458. cid: n.cid + "",
  10459. uid: n.uid + "",
  10460. ec: null
  10461. },
  10462. !0)
  10463. }
  10464. },
  10465. g = function(t, i, o) {
  10466. u++,
  10467. r.
  10468. default.error("[" + e.clientId + "]", t, i, o),
  10469. o && -1 === I.JOIN_CS_RETRY_LIST.indexOf(o) && (d = !1, a = o),
  10470. u === l.length + p.length && n(a)
  10471. },
  10472. m = 0; m < l.length; ++m) {
  10473. var v;
  10474. if ("string" == typeof l[m]) {
  10475. var S = l[m];
  10476. v = e.proxyServer ? "https://".concat(e.proxyServer, "/ap/?url=").concat(S + "/api/v1") : "https://".concat(S, "/api/v1");
  10477. var E = Object(He.getAreaCodeByWebCS)(S);
  10478. r.
  10479. default.debug("[" + e.clientId + "] " + "Connect to choose_server: ".concat(v, ", ").concat(E)),
  10480. Ke(v, e, f, g, E)
  10481. } else r.
  10482. default.error("[" + e.clientId + "] Invalid Host", l[m])
  10483. }
  10484. var _ = setTimeout((function() {
  10485. if (!c) for (var t = 0; t < p.length; ++t) {
  10486. if ("string" == typeof p[t]) {
  10487. var n = p[t];
  10488. v = e.proxyServer ? "https://".concat(e.proxyServer, "/ap/?url=").concat(n + "/api/v1") : "https://".concat(n, "/api/v1");
  10489. var a = Object(He.getAreaCodeByWebCS)(n);
  10490. r.
  10491. default.debug("[" + e.clientId + "] " + "Connect to backup_choose_server: ".concat(v, ", ").concat(a)),
  10492. Ke(v, e, f, g, a)
  10493. } else r.
  10494. default.error("[" + e.clientId + "] Invalid Host", p[t])
  10495. }
  10496. }), 1e3);
  10497. setTimeout((function() { ! c && d && n()
  10498. }), Object(o.getParameter)("WEBCS_BACKUP_CONNECT_TIMEOUT"))
  10499. } (e, (function(t) {
  10500. a = !0,
  10501. f = !0,
  10502. v = t,
  10503. clearTimeout(i),
  10504. Je[l] !== st.DISCONNECTED && Je[l] !== st.DISCONNECTING ? m && p && p(v, u) : r.
  10505. default.debug("[".concat(e.clientId, "] Request gateway list success when connection state is ").concat(Je[l]))
  10506. }), (function(a) {
  10507. if (a) return r.
  10508. default.info("[" + e.clientId + "] Join failed: " + a),
  10509. void(n && n(a));
  10510. if (Je[l] === st.DISCONNECTED || Je[l] === st.DISCONNECTING) return r.
  10511. default.debug("[".concat(e.clientId, "] Request gateway list falied when connection state is ").concat(Je[l])),
  10512. void(n && n("OPERATION_ABORT"));
  10513. r.
  10514. default.debug("[" + e.clientId + "] Request gateway list will be restart in " + c + "s"),
  10515. i = setTimeout((function() {
  10516. t(d, p)
  10517. }), 1e3 * c),
  10518. qe[l] = i;
  10519. var s = Object(o.getParameter)("AP_BACKOFF_MAX_TIME");
  10520. c = c >= s ? s: 2 * c
  10521. }))
  10522. }
  10523. },
  10524. f = function n() { !
  10525. function(e, t) {
  10526. je(e, (function(n, a) {
  10527. if (n) return t && t(n);
  10528. r.
  10529. default.debug("[" + e.clientId + "] getProxyServerList: ", a),
  10530. Fe(e, a, t)
  10531. }))
  10532. } (e, (function(a, c) {
  10533. if (a) {
  10534. r.
  10535. default.debug("[" + e.clientId + "]", a),
  10536. r.
  10537. default.debug("[" + e.clientId + "] Request proxy will be restart in " + d + "s"),
  10538. i = setTimeout((function() {
  10539. n()
  10540. }), 1e3 * d),
  10541. qe[l] = i;
  10542. var u = Object(o.getParameter)("AP_BACKOFF_MAX_TIME");
  10543. d = d >= u ? u: 2 * d
  10544. } else {
  10545. clearTimeout(i);
  10546. var f = c.address;
  10547. e.proxyServer = f;
  10548. var g = {
  10549. mode: "manual",
  10550. url: c.address,
  10551. tcpport: c.serverResponse.tcpport || "3433",
  10552. udpport: c.serverResponse.udpport || "3478",
  10553. username: c.serverResponse.username || "test",
  10554. credential: c.serverResponse.password || Object(o.getParameter)("TURN_SERVER_PASSWORD"),
  10555. forceturn: !0
  10556. };
  10557. g.tcpport += "",
  10558. g.udpport += "",
  10559. e.turnServers = [],
  10560. e.turnServers.push(g),
  10561. s.b.setProxyServer(f),
  10562. r.
  10563. default.setProxyServer(f),
  10564. p(f, t)
  10565. }
  10566. }))
  10567. };
  10568. e.useProxyServer ? 1 == e.proxyServerType ? f() : 2 == e.proxyServerType ?
  10569. function n() { !
  10570. function(e, t) {
  10571. je(e, (function(n, a) {
  10572. return n ? t && t(n) : (r.
  10573. default.debug("[" + e.clientId + "] getProxyServerList: ", a), t && t(null, {
  10574. address: a[0],
  10575. serverResponse: {
  10576. tcpport: "443",
  10577. udpport: "3478",
  10578. username: "test",
  10579. password: "111111"
  10580. }
  10581. }))
  10582. }))
  10583. } (e, (function(a, c) {
  10584. if (a) return r.
  10585. default.debug("[" + e.clientId + "]", a),
  10586. r.
  10587. default.debug("[" + e.clientId + "] Request proxy will be restart in " + d + "s"),
  10588. i = setTimeout((function() {
  10589. n()
  10590. }), 1e3 * d),
  10591. qe[l] = i,
  10592. void(d = d >= 3600 ? 3600 : 2 * d);
  10593. clearTimeout(i);
  10594. var u = Object(o.getParameter)("PROXY_SERVER_TYPE2");
  10595. e.proxyServer = u;
  10596. var f = {
  10597. mode: "manual",
  10598. url: c.address,
  10599. tcpport: c.serverResponse.tcpport || "3433",
  10600. udpport: c.serverResponse.udpport || "3478",
  10601. username: c.serverResponse.username || "test",
  10602. credential: c.serverResponse.password || "111111",
  10603. forceturn: !0
  10604. };
  10605. f.tcpport += "",
  10606. f.udpport += "",
  10607. e.turnServers = [],
  10608. e.turnServers.push(f),
  10609. s.b.setProxyServer(u),
  10610. r.
  10611. default.setProxyServer(u),
  10612. p(u, t)
  10613. }))
  10614. } () : f() : p(null, t)
  10615. },
  10616. Xe = function(e, t, n, a) {
  10617. var i = Date.now();
  10618. a = a || t.stringUid;
  10619. var o = {
  10620. sid: t.sid,
  10621. opid: 10,
  10622. appid: t.appId,
  10623. string_uid: a
  10624. };
  10625. return new Promise((function(c, d) {
  10626. Object(Ue.post)(e + "".concat( - 1 === e.indexOf("?") ? "?": "&", "action=stringuid"), o, (function(u) {
  10627. try {
  10628. var l = JSON.parse(u),
  10629. p = l.code
  10630. } catch(c) {
  10631. var f = "requestUserAccount failed with unexpected body " + u;
  10632. return r.
  10633. default.error("[" + t.clientId + "]", f),
  10634. d({
  10635. retryable: !0,
  10636. info: f,
  10637. url: e
  10638. }),
  10639. n && n.dispatchEvent({
  10640. type: "error",
  10641. reason: "USER_ACCOUNT_BODY_NOT_JSON"
  10642. }),
  10643. void s.b.reqUserAccount(o.sid, {
  10644. lts: i,
  10645. success: !1,
  10646. serverAddress: e,
  10647. stringUid: a,
  10648. uid: null,
  10649. extend: u,
  10650. errorCode: "USER_ACCOUNT_BODY_NOT_JSON"
  10651. })
  10652. }
  10653. if (p) {
  10654. var g = I.StringUidErrorCode[l.code % 1e4] || "REQ_ACCOUNT_ERR_".concat(p);
  10655. return n && n.dispatchEvent({
  10656. type: "error",
  10657. reason: g
  10658. }),
  10659. s.b.reqUserAccount(o.sid, {
  10660. lts: i,
  10661. success: !1,
  10662. serverAddress: e,
  10663. stringUid: a,
  10664. uid: null,
  10665. errorCode: g,
  10666. extend: o
  10667. }),
  10668. d({
  10669. retryable: !1,
  10670. info: f = "Get String Uid Failed [" + g + "]",
  10671. url: e,
  10672. error: g
  10673. })
  10674. }
  10675. var m = l.uid;
  10676. if (! (m > 0 && m < Math.pow(2, 32))) {
  10677. r.
  10678. default.error("[" + t.clientId + "] " + "Invalid Uint Uid ".concat(a, " => ").concat(m), l);
  10679. g = "INVALID_UINT_UID_".concat(m);
  10680. return n && n.dispatchEvent({
  10681. type: "error",
  10682. reason: g
  10683. }),
  10684. s.b.reqUserAccount(o.sid, {
  10685. lts: i,
  10686. success: !1,
  10687. serverAddress: e,
  10688. stringUid: a,
  10689. uid: null,
  10690. errorCode: g,
  10691. extend: o
  10692. }),
  10693. d({
  10694. retryable: !0,
  10695. error: g,
  10696. info: "Get String Uid failed [" + g + "]",
  10697. url: e
  10698. })
  10699. }
  10700. c({
  10701. uid: m,
  10702. url: e
  10703. }),
  10704. s.b.reqUserAccount(o.sid, {
  10705. lts: i,
  10706. success: !0,
  10707. serverAddress: e,
  10708. stringUid: a,
  10709. uid: m,
  10710. errorCode: null,
  10711. extend: o
  10712. })
  10713. }), (function(e, t) {
  10714. if ("timeout" === e.type) {
  10715. var r = "USER_ACCOUNT_TIMEOUT";
  10716. n && n.dispatchEvent({
  10717. type: "error",
  10718. reason: r
  10719. }),
  10720. s.b.reqUserAccount(o.sid, {
  10721. lts: i,
  10722. success: !1,
  10723. serverAddress: t,
  10724. stringUid: a,
  10725. uid: null,
  10726. errorCode: r,
  10727. extend: o
  10728. }),
  10729. d({
  10730. retryable: !0,
  10731. info: r,
  10732. url: t
  10733. })
  10734. } else {
  10735. var c = "USER_ACCOUNT_SERVER_WRONG_".concat(e.type);
  10736. n && n.dispatchEvent({
  10737. type: "error",
  10738. reason: c
  10739. }),
  10740. s.b.reqUserAccount(o.sid, {
  10741. lts: i,
  10742. success: !1,
  10743. serverAddress: t,
  10744. stringUid: a,
  10745. uid: null,
  10746. errorCode: c,
  10747. extend: o
  10748. }),
  10749. d({
  10750. retryable: !0,
  10751. info: c,
  10752. url: t
  10753. })
  10754. }
  10755. }), {
  10756. "X-Packet-Service-Type": 0,
  10757. "X-Packet-URI": 72
  10758. })
  10759. }))
  10760. },
  10761. Qe = function(e, t, n) {
  10762. Date.now();
  10763. var a, s = Object(o.getParameter)("ACCOUNT_REGISTER"),
  10764. c = !1,
  10765. d = Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_TIMEOUT"),
  10766. u = null,
  10767. l = null,
  10768. p = new Promise(function() {
  10769. var p = ee()(Z.a.mark((function p(f, g) {
  10770. var m, v, S;
  10771. return Z.a.wrap((function(p) {
  10772. for (;;) switch (p.prev = p.next) {
  10773. case 0:
  10774. u = f,
  10775. l = g,
  10776. a = 0;
  10777. case 3:
  10778. if (! (a < Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_COUNT_MAX"))) {
  10779. p.next = 33;
  10780. break
  10781. }
  10782. if (!c) {
  10783. p.next = 6;
  10784. break
  10785. }
  10786. return p.abrupt("return");
  10787. case 6:
  10788. return m = s[a % s.length],
  10789. v = e.proxyServer ? "https://".concat(e.proxyServer, "/ap/?url=").concat(s[i] + "/api/v1") : "https://".concat(m, "/api/v1"),
  10790. p.prev = 8,
  10791. p.delegateYield(Z.a.mark((function a() {
  10792. var i;
  10793. return Z.a.wrap((function(a) {
  10794. for (;;) switch (a.prev = a.next) {
  10795. case 0:
  10796. return a.next = 2,
  10797. Xe(v, e, t, n);
  10798. case 2:
  10799. if (i = a.sent, !c) {
  10800. a.next = 5;
  10801. break
  10802. }
  10803. return a.abrupt("return", {
  10804. v: void 0
  10805. });
  10806. case 5:
  10807. c = !0,
  10808. setTimeout((function() {
  10809. r.
  10810. default.debug("Get UserAccount Successfully", i),
  10811. u(i)
  10812. }), 0);
  10813. case 7:
  10814. case "end":
  10815. return a.stop()
  10816. }
  10817. }), a)
  10818. }))(), "t0", 10);
  10819. case 10:
  10820. if (S = p.t0, "object" !== be()(S)) {
  10821. p.next = 13;
  10822. break
  10823. }
  10824. return p.abrupt("return", S.v);
  10825. case 13:
  10826. p.next = 30;
  10827. break;
  10828. case 15:
  10829. if (p.prev = 15, p.t1 = p.
  10830. catch(8), !c) {
  10831. p.next = 19;
  10832. break
  10833. }
  10834. return p.abrupt("return");
  10835. case 19:
  10836. if (!p.t1.retryable) {
  10837. p.next = 27;
  10838. break
  10839. }
  10840. 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")),
  10841. r.
  10842. default.error("".concat(p.t1.info, " ").concat(p.t1.url, " Will Fetch User Account in ").concat(d / 1e3, " seconds")),
  10843. p.next = 25,
  10844. new Promise((function(e) {
  10845. setTimeout(e, d)
  10846. }));
  10847. case 25:
  10848. p.next = 30;
  10849. break;
  10850. case 27:
  10851. r.
  10852. default.error("Get UserAccount Error: ".concat(p.t1.info, " ").concat(p.t1.url), p.t1.error),
  10853. c = !0,
  10854. l(p.t1);
  10855. case 30:
  10856. a++,
  10857. p.next = 3;
  10858. break;
  10859. case 33:
  10860. case "end":
  10861. return p.stop()
  10862. }
  10863. }), p, null, [[8, 15]])
  10864. })));
  10865. return function(e, t) {
  10866. return p.apply(this, arguments)
  10867. }
  10868. } ());
  10869. return p.cancel = function() {
  10870. c || (c = !0, l({
  10871. info: "Request Cancelled",
  10872. retryable: !1
  10873. }))
  10874. },
  10875. p.isFinished = function() {
  10876. return c
  10877. },
  10878. p
  10879. },
  10880. Ze = {
  10881. ERR_NO_VOCS_AVAILABLE: "tryNext",
  10882. ERR_NO_VOS_AVAILABLE: "tryNext",
  10883. ERR_JOIN_CHANNEL_TIMEOUT: "tryNext",
  10884. WARN_REPEAT_JOIN: "quit",
  10885. ERR_JOIN_BY_MULTI_IP: "recover",
  10886. WARN_LOOKUP_CHANNEL_TIMEOUT: "tryNext",
  10887. WARN_OPEN_CHANNEL_TIMEOUT: "tryNext",
  10888. ERR_VOM_SERVICE_UNAVAILABLE: "tryNext",
  10889. ERR_TOO_MANY_USERS: "tryNext",
  10890. ERR_MASTER_VOCS_UNAVAILABLE: "tryNext",
  10891. ERR_INTERNAL_ERROR: "tryNext",
  10892. K_SERVICE_NOT_READY: "recover",
  10893. K_SERVICE_TOO_HEAVY: "tryNext",
  10894. notification_test_recover: "recover",
  10895. notification_test_tryNext: "tryNext",
  10896. notification_test_retry: "retry"
  10897. },
  10898. $e = {
  10899. googActualEncBitrate: "A_aeb",
  10900. googAvailableSendBandwidth: "A_asb",
  10901. googRetransmitBitrate: "A_rb",
  10902. googAvailableReceiveBandwidth: "A_arb",
  10903. googTargetEncBitrate: "A_teb",
  10904. googBucketDelay: "A_bd",
  10905. googTransmitBitrate: "A_tb",
  10906. googCodecName: "A_cn",
  10907. bytesSent: "bytesSent",
  10908. packetsLost: "packetsLost",
  10909. packetsSent: "packetsSent",
  10910. googAdaptationChanges: "A_ac",
  10911. googAvgEncodeMs: "A_aem",
  10912. googEncodeUsagePercent: "A_eup",
  10913. googFirsReceived: "A_fr",
  10914. googFrameHeightInput: "A_fhi",
  10915. googFrameHeightSent: "A_fhs",
  10916. googFrameRateInput: "A_fri",
  10917. googFrameRateSent: "A_frs",
  10918. googFrameWidthInput: "A_fwi",
  10919. googFrameWidthSent: "A_fws",
  10920. googNacksReceived: "A_nr",
  10921. googPlisReceived: "A_pr",
  10922. googRtt: "A_rtt",
  10923. aecDivergentFilterFraction: "A_adff",
  10924. audioInputLevel: "A_ail",
  10925. googEchoCancellationReturnLoss: "A_ecrl",
  10926. googEchoCancellationReturnLossEnhancement: "A_ecrle",
  10927. googResidualEchoLikelihood: "A_rel",
  10928. googResidualEchoLikelihoodRecentMax: "A_relrm",
  10929. googTargetDelayMs: "A_tdm",
  10930. bytesReceived: "bytesReceived",
  10931. packetsReceived: "packetsReceived",
  10932. googDecodeMs: "A_dm",
  10933. googMaxDecodeMs: "A_mdm",
  10934. googRenderDelayMs: "A_rdm",
  10935. googFrameWidthReceived: "A_fwr",
  10936. googFrameHeightReceived: "A_fhr",
  10937. googFrameRateReceived: "A_frr",
  10938. googFrameRateDecoded: "A_frd",
  10939. googFrameRateOutput: "A_fro",
  10940. googJitterBufferMs: "A_jbm",
  10941. googCurrentDelayMs: "A_cdm",
  10942. googMinPlayoutDelayMs: "A_mpdm",
  10943. googNacksSent: "A_ns",
  10944. googPlisSent: "A_ps",
  10945. googFirsSent: "A_fs",
  10946. audioOutputLevel: "A_aol",
  10947. googAccelerateRate: "A_ar",
  10948. googDecodingCNG: "A_dcng",
  10949. googDecodingCTN: "A_dctn",
  10950. googDecodingCTSG: "A_dctsg",
  10951. googDecodingNormal: "A_dn",
  10952. googDecodingPLC: "A_dplc",
  10953. googDecodingPLCCNG: "A_dplccng",
  10954. googExpandRate: "A_er",
  10955. googJitterReceived: "A_jr",
  10956. googPreemptiveExpandRate: "A_per",
  10957. googPreferredJitterBufferMs: "A_pjbm",
  10958. googSecondaryDecodedRate: "A_sdr",
  10959. googSpeechExpandRate: "A_ser",
  10960. uplink_fraction_lost: "B_ufl",
  10961. uplink_cumulative_lost: "B_ucl",
  10962. uplink_available_bandwidth: "B_uab",
  10963. period_fir: "B_fir",
  10964. access_delay: "B_acd",
  10965. uplink_network_quality: "B_unq",
  10966. downlink_network_quality: "B_dnq",
  10967. pub_audio_lost_ratio_400ms: "B_palr4",
  10968. pub_video_lost_ratio_400ms: "B_pvlr4",
  10969. e2e_delay: "B_ed",
  10970. audio_delay: "B_ad",
  10971. video_delay: "B_vd",
  10972. stream_type: "B_st",
  10973. e2e_audio_lost_ratio_400ms: "B_ealr4",
  10974. e2e_video_lost_ratio_400ms: "B_evlr4",
  10975. downlink_estimate_bandwidth: "B_deb",
  10976. peer_publish_audio_duration: "B_ppad",
  10977. peer_publish_video_duration: "B_ppvd"
  10978. },
  10979. et = {};
  10980. for (var tt in $e) {
  10981. var nt = $e[tt];
  10982. et[nt] && r.
  10983. default.error("Key Conflict: ".concat(nt, ": ").concat($e[nt], "| ").concat(tt)),
  10984. et[nt] = tt
  10985. }
  10986. var at = function(e) {
  10987. return $e[e] || e
  10988. },
  10989. it = function(e) {
  10990. return et[e] || e
  10991. };
  10992. var ot = function t(n) {
  10993. var a = !1,
  10994. i = function(e) {
  10995. return {
  10996. _type: "control",
  10997. _message: e
  10998. }
  10999. },
  11000. d = function(e, t) {
  11001. var n = {};
  11002. return Object.keys(t).forEach((function(e) {
  11003. Object(o.getParameter)("STATS_FILTER")[e] || (n[at(e)] = t[e])
  11004. })),
  11005. {
  11006. _type: "subscribe_related_stats",
  11007. _message: {
  11008. stream_type: "high",
  11009. stream_id: e,
  11010. stats: n
  11011. }
  11012. }
  11013. },
  11014. m = function(e) {
  11015. return {
  11016. _type: "publish",
  11017. _message: e
  11018. }
  11019. },
  11020. v = function(e, t) {
  11021. var n = {};
  11022. return Object.keys(t).forEach((function(e) {
  11023. Object(o.getParameter)("STATS_FILTER")[e] || (n[at(e)] = t[e])
  11024. })),
  11025. {
  11026. _type: "subscribe_stats",
  11027. _message: {
  11028. stream_id: e,
  11029. stats: n
  11030. }
  11031. }
  11032. },
  11033. S = t.DISCONNECTED,
  11034. _ = t.CONNECTING,
  11035. h = t.CONNECTED,
  11036. b = t.DISCONNECTING,
  11037. T = S,
  11038. R = c();
  11039. Object.defineProperty(R, "state", {
  11040. set: function(e) {
  11041. var n = T;
  11042. T = e,
  11043. function(e, t) {
  11044. Je[e] = t
  11045. } (R.clientId, e),
  11046. e !== t.CONNECTED && (R.hasJoined = !1),
  11047. n !== e && R.dispatchEvent({
  11048. type: "connection-state-change",
  11049. prevState: t.connetionStateMap[n],
  11050. curState: t.connetionStateMap[e]
  11051. })
  11052. },
  11053. get: function() {
  11054. return T
  11055. }
  11056. }),
  11057. R.socket = void 0,
  11058. R.state = S,
  11059. R.mode = n.mode,
  11060. R.role = n.role,
  11061. R.codec = n.codec,
  11062. R.config = {},
  11063. R.timers = {},
  11064. R.timer_counter = {},
  11065. R.localStreams = {},
  11066. R.remoteStreams = {},
  11067. R.remoteMuteState = {},
  11068. R.attemps = 1,
  11069. R.p2p_attemps = 1,
  11070. R.audioLevel = {},
  11071. R.activeSpeaker = void 0,
  11072. R.reconnectMode = "tryNext",
  11073. R.rejoinAttempt = 0,
  11074. R.hasChangeBGPAddress = !1,
  11075. R.traffic_stats = {},
  11076. R.clientId = n.clientId,
  11077. R.pingpongCounter = 0,
  11078. R.hasInvokeLeave = !1,
  11079. R.p2ps = new Map,
  11080. R.liveStreams = new Map,
  11081. R.injectLiveStreams = new Map,
  11082. R.remoteStreamsInChannel = new Set,
  11083. R.subscribeRequestId = new Map,
  11084. R.publishRequestId = 0,
  11085. R.hasJoined = !1,
  11086. R.isFirstSuccess = !0,
  11087. function(e) {
  11088. var t = Me;
  11089. e.makeRequest = function(n, a, i) {
  11090. if (void 0 === e.socket) return r.
  11091. default.debug("[".concat(e.clientId, "] No socket available")),
  11092. void t(i, I.
  11093. default.INVALID_OPERATION);
  11094. try {
  11095. e.socket.emitRequest(n, (function(e, t) {
  11096. var n;
  11097. "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))
  11098. }))
  11099. } catch(a) {
  11100. r.
  11101. default.debug("[".concat(e.clientId, "] Socket emit message failed ").concat(JSON.stringify(n))),
  11102. r.
  11103. default.debug("[".concat(e.clientId, "] "), a),
  11104. t(i, I.
  11105. default.SOCKET_ERROR)
  11106. }
  11107. },
  11108. e.makeReport = function(t) {
  11109. void 0 === e.socket && r.
  11110. default.debug("[".concat(e.clientId, "] No socket available"));
  11111. try {
  11112. e.socket.emitReport(t)
  11113. } catch(n) {
  11114. r.
  11115. default.debug("[".concat(e.clientId, "] Socket emit report failed ").concat(JSON.stringify(t)))
  11116. }
  11117. }
  11118. } (R),
  11119. R.inChannelInfo = {
  11120. joinAt: null,
  11121. duration: 0
  11122. },
  11123. R._sendMessage = function(e, t) {
  11124. switch (e) {
  11125. case "SubscribeStats":
  11126. R.makeReport(v.apply(void 0, Pe()(t)));
  11127. break;
  11128. case "SubscribeRelatedStats":
  11129. R.makeReport(d.apply(void 0, Pe()(t)))
  11130. }
  11131. };
  11132. var A = Me;
  11133. R.p2pCounter = Object(H.random)(1e5),
  11134. R.generateP2PId = function() {
  11135. return++R.p2pCounter
  11136. },
  11137. R.audioVolumeIndication = {
  11138. enabled: !1,
  11139. sortedAudioVolumes: [],
  11140. smooth: 3,
  11141. interval: 2e3
  11142. },
  11143. R.remoteVideoStreamTypes = {
  11144. REMOTE_VIDEO_STREAM_HIGH: 0,
  11145. REMOTE_VIDEO_STREAM_LOW: 1,
  11146. REMOTE_VIDEO_STREAM_MEDIUM: 2
  11147. },
  11148. R.streamFallbackTypes = {
  11149. STREAM_FALLBACK_OPTION_DISABLED: 0,
  11150. STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW: 1,
  11151. STREAM_FALLBACK_OPTION_AUDIO_ONLY: 2
  11152. },
  11153. R.configPublisher = function(e) {
  11154. R.config = e
  11155. },
  11156. R.getGatewayInfo = function(e, t) {
  11157. R.makeRequest({
  11158. _type: "gateway_info"
  11159. },
  11160. e, t)
  11161. },
  11162. R.setClientRole = function(e, t) {
  11163. r.
  11164. default.debug("[".concat(R.clientId, "] setClientRole to ").concat(e));
  11165. var n = s.b.reportApiInvoke(R.joinInfo.sid, {
  11166. name: "_setClientRole",
  11167. callback: t
  11168. });
  11169. R.makeRequest({
  11170. _type: "set_client_role",
  11171. _message: {
  11172. role: e
  11173. }
  11174. },
  11175. (function() {
  11176. R.role = e,
  11177. R.dispatchEvent({
  11178. type: "client-role-changed",
  11179. role: e
  11180. }),
  11181. n && n(null, {
  11182. role: e
  11183. })
  11184. }), (function(t, a) {
  11185. 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);
  11186. r.
  11187. default.error("set Client role error to " + e + ": " + t),
  11188. n && n(t)
  11189. }))
  11190. },
  11191. R.join = function(e, t, a, i) {
  11192. R.hasInvokeLeave = !1,
  11193. e.useProxyServer && (R.hasChangeBGPAddress = !0);
  11194. var c = (new Date).getTime(),
  11195. d = e.uid;
  11196. if (R.inChannelInfo.joinAt && (R.inChannelInfo.duration += c - R.inChannelInfo.joinAt), R.inChannelInfo.joinAt = c, R.state !== _) return r.
  11197. default.error("[".concat(R.clientId, "] GatewayClient.join Failed: state "), R.state),
  11198. i && i(I.
  11199. default.INVALID_OPERATION),
  11200. void s.b.joinGateway(e.sid, {
  11201. lts: c,
  11202. succ: !1,
  11203. ec: I.
  11204. default.INVALID_OPERATION,
  11205. addr: null
  11206. });
  11207. if (null != d && parseInt(d) !== d) return r.
  11208. default.error("[".concat(R.clientId, "] Input uid is invalid")),
  11209. R.state = S,
  11210. i && i(I.
  11211. default.INVALID_PARAMETER),
  11212. void s.b.joinGateway(e.sid, {
  11213. lts: c,
  11214. succ: !1,
  11215. ec: I.
  11216. default.INVALID_PARAMETER,
  11217. addr: null
  11218. });
  11219. var u = rt.register(R, {
  11220. uid: d,
  11221. cname: e && e.cname
  11222. });
  11223. if (u) return R.state = S,
  11224. i && i(u),
  11225. void s.b.joinGateway(e.sid, {
  11226. lts: c,
  11227. succ: !1,
  11228. ec: u,
  11229. addr: null
  11230. });
  11231. R.joinInfo = E()({},
  11232. e),
  11233. R.uid = d,
  11234. R.key = t,
  11235. R.pingpongCounter = 0,
  11236. N(e, (function(t) {
  11237. if (R.state === b || R.state === S) return i && i("LEAVE_BEFORE_JOIN_SUCCESS");
  11238. R.state = h,
  11239. r.
  11240. default.debug("[".concat(R.clientId, "] Connected to gateway server")),
  11241. clearInterval(R.pingTimer),
  11242. R.pingTimer = setInterval((function() {
  11243. var e = Object(o.getParameter)("PING_PONG_TIME_OUT");
  11244. if (++R.pingpongCounter >= e) {
  11245. var t = Date.now();
  11246. R.socket && r.
  11247. default.warning("PINGPONG Timeout. Last Socket Message: ".concat(t - R.socket.getLastMsgTime(), "ms")),
  11248. 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({
  11249. type: "disconnect",
  11250. event: {
  11251. msg: "PING_PONG_TIME_OUT"
  11252. }
  11253. })))
  11254. }
  11255. var n = Date.now();
  11256. R.makeRequest({
  11257. _type: "ping"
  11258. },
  11259. (function() {
  11260. R.pingpongCounter = 0;
  11261. var e = Date.now() - n;
  11262. setTimeout((function() {
  11263. Object(o.getParameter)("REPORT_STATS") && R.makeRequest({
  11264. _type: "ping_back",
  11265. _message: {
  11266. pingpongElapse: e
  11267. }
  11268. })
  11269. }), 1e3)
  11270. }), (function(e, t) {
  11271. "TIMEOUT" !== e && (r.
  11272. 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.
  11273. default.info("Disconnecting websocket connection"), R.socket.signal.connection.close()))
  11274. }))
  11275. }), 3e3),
  11276. R.makeRequest(function(e) {
  11277. var t = e.role,
  11278. a = E()({},
  11279. R.joinInfo.apResponse),
  11280. i = {
  11281. session_id: R.joinInfo.sid,
  11282. app_id: n.appId,
  11283. channel_key: R.key,
  11284. channel_name: R.joinInfo.cname,
  11285. sdk_version: o.VERSION,
  11286. browser: navigator.userAgent,
  11287. process_id: Object(s.a)(),
  11288. mode: R.mode,
  11289. codec: R.codec,
  11290. role: t,
  11291. has_changed_gateway: Object(o.getParameter)("FORCE_CHANGED_GATEWAY_FLAG") || R.hasChangeBGPAddress,
  11292. ap_response: a,
  11293. extend: Object(o.getParameter)("JOIN_EXTEND"),
  11294. details: {}
  11295. };
  11296. 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)) {
  11297. var r = {
  11298. username: "test",
  11299. credential: Object(o.getParameter)("TURN_SERVER_PASSWORD"),
  11300. forceturn: Object(o.getParameter)("FORCE_TURN")
  11301. };
  11302. r.url = R.socket.signal.turnConfig.url,
  11303. R.socket.signal.turnConfig.tcpport && (r.tcpport = "" + R.socket.signal.turnConfig.tcpport),
  11304. R.socket.signal.turnConfig.udpport && (r.udpport = "" + R.socket.signal.turnConfig.udpport),
  11305. R.joinInfo.turnServers.push(r)
  11306. }
  11307. return R.dispatchEvent({
  11308. type: "join-message-hook",
  11309. joinMessage: i
  11310. }),
  11311. {
  11312. _type: "join",
  11313. _message: i
  11314. }
  11315. } ({
  11316. role: R.role
  11317. }), (function(t) {
  11318. if (s.b.joinGateway(e.sid, {
  11319. lts: c,
  11320. succ: !0,
  11321. ec: null,
  11322. vid: e.vid,
  11323. addr: R.socket.getURL(),
  11324. firstSuccess: R.isFirstSuccess
  11325. }), 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")) {
  11326. var n = null;
  11327. try {
  11328. n = R.socket.signal.connection.url
  11329. } catch(e) {
  11330. r.
  11331. default.debug("[".concat(R.clientId, "] Can not get gateway ip: ").concat(e))
  11332. }
  11333. n ? Object(o.setParameter)("LIVE_SERVER_LIST", [n]) : Object(o.setParameter)("LIVE_SERVER_LIST", [])
  11334. }
  11335. R.dispatchEvent({
  11336. type: "join"
  11337. }),
  11338. clearInterval(R.timers.trafficStats),
  11339. R.timers.trafficStats = setInterval((function() {
  11340. R.makeRequest({
  11341. _type: "traffic_stats"
  11342. },
  11343. (function(e) {
  11344. var t = {};
  11345. for (var n in e) t[it(n)] = e[n];
  11346. if (t.peer_delay && t.peer_delay.length) {
  11347. var a = [];
  11348. t.peer_delay.forEach((function(e) {
  11349. var t = {};
  11350. for (var n in e) t[it(n)] = e[n];
  11351. a.push(t)
  11352. })),
  11353. t.peer_delay = a
  11354. }
  11355. R.traffic_stats = t,
  11356. R.traffic_stats.timestamp = Date.now();
  11357. var i = R.joinInfo.stringUid,
  11358. o = R.localStreams[d] || R.localStreams[i];
  11359. o && (o.traffic_stats = {
  11360. access_delay: t.access_delay
  11361. }),
  11362. t.peer_delay && t.peer_delay.forEach((function(e) {
  11363. var n = R.remoteStreams[e.peer_uid];
  11364. n && (n.traffic_stats = {
  11365. access_delay: t.access_delay,
  11366. e2e_delay: e.e2e_delay,
  11367. audio_delay: e.audio_delay,
  11368. video_delay: e.video_delay
  11369. })
  11370. })),
  11371. R.dispatchEvent({
  11372. type: "after-getTrafficStats",
  11373. trafficStats: t
  11374. })
  11375. }))
  11376. }), 3e3)
  11377. }), (function(t, n) {
  11378. if (r.
  11379. default.error("[".concat(R.clientId, "] User join failed [").concat(t, "]")), "ERR_JOIN_BY_MULTI_IP" === t) {
  11380. try {
  11381. s.b.joinGateway(e.sid, {
  11382. lts: c,
  11383. succ: !1,
  11384. ec: "ERR_JOIN_BY_MULTI_IP",
  11385. addr: R.socket.getURL()
  11386. })
  11387. } catch(e) {}
  11388. return R.dispatchEvent({
  11389. type: "onMultiIP",
  11390. option: n.option
  11391. })
  11392. }
  11393. Ze[t] && R.rejoinAttempt < 4 ? R._doWithAction(Ze[t], a, i) : i && i(t),
  11394. s.b.joinGateway(e.sid, {
  11395. lts: c,
  11396. succ: !1,
  11397. ec: t,
  11398. addr: R.socket && R.socket.getURL()
  11399. })
  11400. }))
  11401. }), (function(t) {
  11402. r.
  11403. default.error("[".concat(R.clientId, "] User join failed [").concat(t, "]")),
  11404. i && i(t),
  11405. s.b.joinGateway(e.sid, {
  11406. lts: c,
  11407. succ: !1,
  11408. ec: t,
  11409. addr: R.socket.getURL()
  11410. })
  11411. })),
  11412. this.remoteMuteState = {},
  11413. R.resetAudioVolumeIndication()
  11414. },
  11415. R.leave = function(e, t) {
  11416. var n = rt.unregister(R);
  11417. switch (n && r.
  11418. default.debug("[".concat(R.clientId, "] "), n), R.state) {
  11419. case S:
  11420. return r.
  11421. default.debug("[".concat(R.clientId, "] Client Already in DISCONNECTED status")),
  11422. void A(e);
  11423. case b:
  11424. return r.
  11425. default.debug("[".concat(R.clientId, "] Client Already in DISCONNECTING status")),
  11426. void A(t, I.
  11427. default.INVALID_OPERATION);
  11428. case _:
  11429. return R.socket && R.socket.close(),
  11430. R.socket = void 0,
  11431. r.
  11432. default.info("[".concat(R.clientId, "] Client connecting, Leave channel success")),
  11433. R.state = S,
  11434. e && e()
  11435. }
  11436. for (var a in R.state = b,
  11437. 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]);
  11438. for (var a in R.inChannelInfo.joinAt && (R.inChannelInfo.duration += Date.now() - R.inChannelInfo.joinAt, R.inChannelInfo.joinAt = null), R.hasJoined ? R.makeRequest({
  11439. _type: "leave"
  11440. },
  11441. (function(t) {
  11442. R.socket.close(),
  11443. R.socket = void 0,
  11444. r.
  11445. default.info("[".concat(R.clientId, "] Leave channel success")),
  11446. R.state = S,
  11447. e && e(t)
  11448. }), (function(e) {
  11449. "TIMEOUT" !== e && (r.
  11450. default.error("[".concat(R.clientId, "] Leave Channel Failed"), e), R.state = h, t && t(e))
  11451. })) : (R.socket && (R.socket.close(), R.socket = void 0), r.
  11452. default.info("[".concat(R.clientId, "] Leave channel before joined")), R.state = S, e && e()), R.localStreams) if (R.localStreams.hasOwnProperty(a)) {
  11453. var i = R.localStreams[a];
  11454. delete R.localStreams[a],
  11455. void 0 !== i.pc && (i.pc.close(), i.pc = void 0)
  11456. }
  11457. k()
  11458. },
  11459. R.publish = function(e, t, n, a) {
  11460. var c = (new Date).getTime(),
  11461. d = !1;
  11462. if (e.publishLTS = c, "object" !== be()(e) || null === e) return r.
  11463. default.error("[".concat(R.clientId, "] Invalid local stream")),
  11464. a && a(I.
  11465. default.INVALID_LOCAL_STREAM),
  11466. void s.b.publish(R.joinInfo.sid, {
  11467. lts: c,
  11468. succ: !1,
  11469. audio: !1,
  11470. video: !1,
  11471. screenshare: !1,
  11472. audioName: "",
  11473. videoName: "",
  11474. screenName: "",
  11475. ec: I.
  11476. default.INVALID_LOCAL_STREAM
  11477. });
  11478. if (!e.stream && void 0 === e.url) return r.
  11479. default.error("[".concat(R.clientId, "] Invalid local media stream")),
  11480. a && a(I.
  11481. default.INVALID_LOCAL_STREAM),
  11482. void s.b.publish(R.joinInfo.sid, {
  11483. lts: c,
  11484. succ: !1,
  11485. audio: !1,
  11486. video: !1,
  11487. screenshare: !1,
  11488. audioName: "",
  11489. videoName: "",
  11490. screenName: "",
  11491. ec: I.
  11492. default.INVALID_LOCAL_STREAM
  11493. });
  11494. if (R.state !== h) return r.
  11495. default.error("[".concat(R.clientId, "] User is not in the session")),
  11496. a && a(I.
  11497. default.INVALID_OPERATION),
  11498. void s.b.publish(R.joinInfo.sid, {
  11499. lts: c,
  11500. succ: !1,
  11501. audio: e.hasAudio(),
  11502. video: e.hasVideo(),
  11503. screenshare: e.hasScreen(),
  11504. audioName: e.hasAudio() && e.audioName,
  11505. videoName: e.hasVideo() && e.videoName,
  11506. screenName: e.hasScreen() && e.screenName,
  11507. ec: I.
  11508. default.INVALID_OPERATION
  11509. });
  11510. var u = e.getAttributes() || {};
  11511. if (e.local && void 0 === R.localStreams[e.getId()] && (e.hasAudio() || e.hasVideo() || e.hasScreen())) {
  11512. var p = R.generateP2PId();
  11513. if (R.p2ps.set(p, e), e.p2pId = p, void 0 !== e.url) w(m({
  11514. state: "url",
  11515. audio: e.hasAudio(),
  11516. video: e.hasVideo(),
  11517. attributes: e.getAttributes()
  11518. },
  11519. e.url), (function(t, n) {
  11520. "success" === t ? (e.getUserId() !== n && e.setUserId(n), R.localStreams[n] = e, e.onClose = function() {
  11521. R.unpublish(e)
  11522. }) : r.
  11523. default.error("[".concat(R.clientId, "] Publish local stream failed"), t)
  11524. }));
  11525. else {
  11526. R.localStreams[e.getId()] = e,
  11527. e.connectionSpec = {
  11528. callback: function(u) {
  11529. R.makeRequest(m({
  11530. state: "offer",
  11531. stream_type: 1 == t.streamType ? "low": "high",
  11532. p2p_id: p,
  11533. sdp: u,
  11534. audio: e.audio || e.screenAudio,
  11535. video: e.screen || e.video,
  11536. screen: e.screen,
  11537. attributes: e.getAttributes(),
  11538. dtx: e.DTX,
  11539. hq: e.highQuality,
  11540. lq: e.lowQuality,
  11541. stereo: e.stereo,
  11542. speech: e.speech,
  11543. codec: R.codec,
  11544. extend: Object(o.getParameter)("PUB_EXTEND")
  11545. }), (function(t) {
  11546. e.getUserId() !== t.uid && e.setUserId(t.uid),
  11547. r.
  11548. default.info("[".concat(R.clientId, "] Local stream published with uid"), t.uid),
  11549. e.onClose = function() {
  11550. R.unpublish(e)
  11551. },
  11552. e._onAudioUnmute = function() {
  11553. R.makeReport(i({
  11554. action: "unmute_local_audio",
  11555. stream_id: e.getId()
  11556. }))
  11557. },
  11558. e._onVideoUnmute = function() {
  11559. R.makeReport(i({
  11560. action: "unmute_local_video",
  11561. stream_id: e.getId()
  11562. }))
  11563. },
  11564. e._onAudioMute = function() {
  11565. R.makeReport(i({
  11566. action: "mute_local_audio",
  11567. stream_id: e.getId()
  11568. }))
  11569. },
  11570. e._onVideoMute = function() {
  11571. R.makeReport(i({
  11572. action: "mute_local_video",
  11573. stream_id: e.getId()
  11574. }))
  11575. },
  11576. e.getId() === e.getUserId() && (e.isAudioOn() || e.hasAudio() && (r.
  11577. default.debug("[".concat(R.clientId, "] local stream audio mute")), e._onAudioMute()), e.isVideoOn() || (e.hasVideo() || e.hasScreen()) && (r.
  11578. default.debug("[".concat(R.clientId, "] local stream video mute")), e._onVideoMute())),
  11579. e.pc.oniceconnectionstatechange = function(t) {
  11580. if ("failed" === t) {
  11581. if (null != R.timers[e.getId()] && (clearInterval(R.timers[e.getId()]), clearInterval(R.timers[e.getId()] + "_RelatedStats")), r.
  11582. default.error("[".concat(R.clientId, "] Publisher connection is lost -- streamId: ").concat(e.getId(), ", p2pId: ").concat(p)), R.p2ps.delete(p), r.
  11583. default.debug("[".concat(R.clientId, "] publish p2p failed: "), R.p2ps), !d) return d = !0,
  11584. s.b.publish(R.joinInfo.sid, {
  11585. lts: c,
  11586. succ: !1,
  11587. audio: e.hasAudio(),
  11588. video: e.hasVideo(),
  11589. screenshare: e.hasScreen(),
  11590. audioName: e.hasAudio() && e.audioName,
  11591. videoName: e.hasVideo() && e.videoName,
  11592. screenName: e.hasScreen() && e.screenName,
  11593. ec: I.
  11594. default.PEERCONNECTION_FAILED,
  11595. publishRequestid: R.publishRequestId || 0,
  11596. p2pid: p
  11597. }),
  11598. R.dispatchEvent(l({
  11599. type: "pubP2PLost",
  11600. stream: e
  11601. })),
  11602. a && a(I.
  11603. default.PEERCONNECTION_FAILED);
  11604. R.dispatchEvent(l({
  11605. type:
  11606. "pubP2PLost",
  11607. stream: e
  11608. }))
  11609. } else if ("connected" === t && (r.
  11610. default.debug("[".concat(R.clientId, "] publish p2p connected: "), R.p2ps), e.getId() === e.getUserId() && (e._isAudioMuted() ? R.makeReport(i({
  11611. action: "mute_local_audio",
  11612. stream_id: e.getId()
  11613. })) : R.makeReport(i({
  11614. action: "unmute_local_audio",
  11615. stream_id: e.getId()
  11616. })), e._isVideoMuted() ? R.makeReport(i({
  11617. action: "mute_local_video",
  11618. stream_id: e.getId()
  11619. })) : R.makeReport(i({
  11620. action: "unmute_local_video",
  11621. stream_id: e.getId()
  11622. }))), !d)) return d = !0,
  11623. s.b.publish(R.joinInfo.sid, {
  11624. lts: c,
  11625. succ: !0,
  11626. audio: e.hasAudio(),
  11627. video: e.hasVideo(),
  11628. screenshare: e.hasScreen(),
  11629. audioName: e.hasAudio() && e.audioName,
  11630. videoName: e.hasVideo() && e.videoName,
  11631. screenName: e.hasScreen() && e.screenName,
  11632. ec: null,
  11633. publishRequestid: R.publishRequestId || 0,
  11634. p2pid: p
  11635. }),
  11636. n && n()
  11637. },
  11638. e.pc.processSignalingMessage(t.sdp)
  11639. }), (function(t, n) {
  11640. r.
  11641. default.error("Publish Failed: ".concat(t)),
  11642. s.b.publish(R.joinInfo.sid, {
  11643. lts: c,
  11644. succ: !1,
  11645. audio: e.hasAudio(),
  11646. video: e.hasVideo(),
  11647. screenshare: e.hasScreen(),
  11648. audioName: e.hasAudio() && e.audioName,
  11649. videoName: e.hasVideo() && e.videoName,
  11650. screenName: e.hasScreen() && e.screenName,
  11651. ec: t,
  11652. publishRequestid: R.publishRequestId || 0,
  11653. p2pid: p
  11654. }),
  11655. "TIMEOUT" != t && (R.processPublishFailure(e), a && a(t))
  11656. }))
  11657. },
  11658. audio: e.hasAudio(),
  11659. video: e.hasVideo(),
  11660. screen: e.hasScreen(),
  11661. isSubscriber: !1,
  11662. stunServerUrl: R.stunServerUrl,
  11663. turnServers: R.joinInfo.turnServers,
  11664. maxAudioBW: u.maxAudioBW,
  11665. minVideoBW: u.minVideoBW,
  11666. maxVideoBW: u.maxVideoBW,
  11667. mode: R.mode,
  11668. codec: R.codec,
  11669. isVideoMute: e.userMuteVideo || e.peerMuteVideo,
  11670. isAudioMute: e.userMuteAudio || e.peerMuteAudio,
  11671. maxFrameRate: e.attributes.maxFrameRate,
  11672. clientId: R.clientId
  11673. },
  11674. e.pc = W(e.connectionSpec),
  11675. e.pc.addStream(e.stream),
  11676. r.
  11677. default.debug("[".concat(R.clientId, "] PeerConnection add stream :"), e.stream),
  11678. e.pc.onnegotiationneeded = function(n) {
  11679. var a = {
  11680. state: "negotiation",
  11681. stream_type: 1 === t.streamType ? "low": "high",
  11682. p2p_id: p,
  11683. sdp: n
  11684. };
  11685. R.makeRequest(m(a), (function(t) {
  11686. r.
  11687. default.debug("Negotating Stream ".concat(e.getId())),
  11688. e.pc.processSignalingMessage(t.sdp)
  11689. }), (function(e, t) {
  11690. r.
  11691. default.error("Negotiation failed ".concat(e), t, a)
  11692. }))
  11693. },
  11694. clearInterval(R.timers[e.getId()]),
  11695. R.timers[e.getId()] = setInterval((function() {
  11696. if (Object(o.getParameter)("REPORT_STATS")) {
  11697. var t = 0;
  11698. e && e.pc && e.pc.getStats && e.pc.getStatsRate((function(n) {
  11699. n.forEach((function(n) {
  11700. if (n && n.id && !/_recv$/.test(n.id) && !/^time$/.test(n.id) && e.getUserId()) {
  11701. 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 {
  11702. var a = e.stream.getVideoTracks()[0];
  11703. n.A_vstd = a.enabled ? "0": "1"
  11704. } catch(e) {}
  11705. if ("audio" === n.mediaType) try {
  11706. var i = e.stream.getAudioTracks()[0];
  11707. n.A_astd = i.enabled ? "0": "1"
  11708. } catch(e) {}
  11709. if (e.getId() == e.getUserId()) {
  11710. var s = 200 * t;
  11711. t++,
  11712. setTimeout((function() {
  11713. var e = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11714. e > Object(o.getParameter)("REPORT_STATS_TIMEOUT") ? r.
  11715. default.debug("PublishStats report blocked by REPORT_STATS_TIMEOUT ".concat(e)):
  11716. R.makeReport(function(e) {
  11717. var t = {};
  11718. return Object.keys(e).forEach((function(n) {
  11719. Object(o.getParameter)("STATS_FILTER")[n] || (t[at(n)] = e[n])
  11720. })),
  11721. {
  11722. _type: "publish_stats",
  11723. _message: {
  11724. stream_type: "high",
  11725. stats: t
  11726. }
  11727. }
  11728. } (n))
  11729. }), s)
  11730. } else {
  11731. s = 200 * t;
  11732. t++,
  11733. setTimeout((function() {
  11734. var e = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11735. e > Object(o.getParameter)("REPORT_STATS_TIMEOUT") ? r.
  11736. default.debug("PublishStatsLow report blocked by REPORT_STATS_TIMEOUT ".concat(e)):
  11737. R.makeReport(function(e) {
  11738. var t = {};
  11739. return Object.keys(e).forEach((function(n) {
  11740. Object(o.getParameter)("STATS_FILTER")[n] || (t[at(n)] = e[n])
  11741. })),
  11742. {
  11743. _type: "publish_stats",
  11744. _message: {
  11745. stream_type: "low",
  11746. stats: t
  11747. }
  11748. }
  11749. } (n))
  11750. }), s)
  11751. }
  11752. }
  11753. }))
  11754. }))
  11755. }
  11756. }), 3e3);
  11757. var f = function() {
  11758. Object(o.getParameter)("REPORT_STATS") && e && e.pc && e.pc.getVideoRelatedStats && e.pc.getVideoRelatedStats((function(t) {
  11759. var n, a, i = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11760. i > Object(o.getParameter)("REPORT_STATS_TIMEOUT") ? r.
  11761. default.debug("PublishRelatedStats report blocked by REPORT_STATS_TIMEOUT ".concat(i)):
  11762. e.getId() === e.getUserId() ? R.makeReport((n = t, a = {},
  11763. Object.keys(n).forEach((function(e) {
  11764. Object(o.getParameter)("STATS_FILTER")[e] || (a[at(e)] = n[e])
  11765. })), {
  11766. _type: "publish_related_stats",
  11767. _message: {
  11768. stream_type: "high",
  11769. stats: a
  11770. }
  11771. })) : R.makeReport(function(e) {
  11772. var t = {};
  11773. return Object.keys(e).forEach((function(n) {
  11774. Object(o.getParameter)("STATS_FILTER")[n] || (t[at(n)] = e[n])
  11775. })),
  11776. {
  11777. _type: "publish_related_stats",
  11778. _message: {
  11779. stream_type: "low",
  11780. stats: t
  11781. }
  11782. }
  11783. } (t))
  11784. }))
  11785. };
  11786. f(),
  11787. clearInterval(R.timers[e.getId() + "_RelatedStats"]),
  11788. R.timers[e.getId() + "_RelatedStats"] = setInterval(f, 1e3)
  11789. }
  11790. }
  11791. },
  11792. R.unpublish = function(e, t, n, a) {
  11793. if ("object" !== be()(e) || null === e) return r.
  11794. default.error("[".concat(R.clientId, "] Invalid local stream")),
  11795. void A(a, I.
  11796. default.INVALID_LOCAL_STREAM);
  11797. if (R.state !== h) return r.
  11798. default.error("[".concat(R.clientId, "] User not in the session")),
  11799. void A(a, I.
  11800. default.INVALID_OPERATION);
  11801. 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()]) {
  11802. delete R.localStreams[e.getId()];
  11803. var i = {
  11804. stream_id: e.getUserId(),
  11805. stream_type: 1 === t.streamType ? "low": "high"
  11806. };
  11807. R.makeRequest({
  11808. _type: "unpublish",
  11809. _message: i
  11810. }),
  11811. (e.hasAudio() || e.hasVideo() || e.hasScreen()) && void 0 === e.url && void 0 !== e.pc && (e.pc.close(), e.pc = void 0),
  11812. e.onClose = void 0,
  11813. e._onAudioMute = void 0,
  11814. e._onAudioUnute = void 0,
  11815. e._onVideoMute = void 0,
  11816. e._onVideoUnmute = void 0,
  11817. R.p2ps.delete(e.p2pId),
  11818. R.dispatchEvent({
  11819. type: "stream-unpublished",
  11820. stream: e,
  11821. options: t
  11822. }),
  11823. n && n()
  11824. } else r.
  11825. default.error("[".concat(R.clientId, "] Invalid local stream")),
  11826. A(a, I.
  11827. default.INVALID_LOCAL_STREAM);
  11828. else r.
  11829. default.error("[".concat(R.clientId, "] User not in the session")),
  11830. A(a, I.
  11831. default.INVALID_OPERATION)
  11832. },
  11833. R.subscribe = function(e, t, n) {
  11834. var a = (new Date).getTime();
  11835. e.subscribeLTS = a;
  11836. var c = !1;
  11837. if (r.
  11838. 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.
  11839. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  11840. n && n(I.
  11841. default.INVALID_REMOTE_STREAM),
  11842. void s.b.subscribe(R.joinInfo.sid, {
  11843. lts: a,
  11844. succ: !1,
  11845. video: e.subscribeOptions && e.subscribeOptions.video,
  11846. audio: e.subscribeOptions && e.subscribeOptions.audio,
  11847. peerid: e.getId(),
  11848. ec: I.
  11849. default.INVALID_REMOTE_STREAM
  11850. });
  11851. if (R.state !== h && (r.
  11852. default.error("[".concat(R.clientId, "] User is not in the session")), !c)) return c = !0,
  11853. s.b.subscribe(R.joinInfo.sid, {
  11854. lts: a,
  11855. succ: !1,
  11856. video: e.subscribeOptions && e.subscribeOptions.video,
  11857. audio: e.subscribeOptions && e.subscribeOptions.audio,
  11858. peerid: e.getId(),
  11859. ec: I.
  11860. default.INVALID_OPERATION
  11861. }),
  11862. n && n(I.
  11863. default.INVALID_OPERATION);
  11864. if (!e.local && R.remoteStreams.hasOwnProperty(e.getId())) if (e.hasAudio() || e.hasVideo() || e.hasScreen()) {
  11865. var p = R.generateP2PId();
  11866. R.p2ps.set(p, e),
  11867. e.p2pId = p,
  11868. e.pc = W({
  11869. callback: function(t) {
  11870. var i = {
  11871. stream_id: e.getId(),
  11872. audio: !e.subscribeOptions || e.subscribeOptions.audio,
  11873. video: !e.subscribeOptions || e.subscribeOptions.video,
  11874. codec: R.codec,
  11875. p2p_id: p,
  11876. sdp: t,
  11877. tcc: Object(o.getParameter)("SUBSCRIBE_TCC"),
  11878. extend: Object(o.getParameter)("SUB_EXTEND")
  11879. };
  11880. R.makeRequest({
  11881. _type: "subscribe",
  11882. _message: i
  11883. },
  11884. (function(t) {
  11885. e.pc.processSignalingMessage(t.sdp)
  11886. }), (function(t, i) {
  11887. r.
  11888. default.error("[".concat(R.clientId, "] Subscribe remote stream Failed: ").concat(t, ", closing stream "), e.getId(), i),
  11889. s.b.subscribe(R.joinInfo.sid, {
  11890. lts: a,
  11891. succ: !1,
  11892. video: e.subscribeOptions && e.subscribeOptions.video,
  11893. audio: e.subscribeOptions && e.subscribeOptions.audio,
  11894. peerid: e.getId(),
  11895. ec: t
  11896. }),
  11897. "TIMEOUT" != t && (R.processSubscribeFailure(e), n && n(t))
  11898. }))
  11899. },
  11900. nop2p: !0,
  11901. audio: !0,
  11902. video: !0,
  11903. screen: e.hasScreen(),
  11904. isSubscriber: !0,
  11905. stunServerUrl: R.stunServerUrl,
  11906. turnServers: R.joinInfo.turnServers,
  11907. isVideoMute: e.userMuteVideo,
  11908. isAudioMute: e.userMuteAudio,
  11909. uid: e.getId(),
  11910. clientId: R.clientId
  11911. }),
  11912. e.pc.onaddstream = function(t, n) {
  11913. if (e._onAudioUnmute = function() {
  11914. R.makeReport(i({
  11915. action: "unmute_remote_audio",
  11916. stream_id: e.getId()
  11917. }), (function() {}), (function() {}))
  11918. },
  11919. e._onAudioMute = function() {
  11920. R.makeReport(i({
  11921. action: "mute_remote_audio",
  11922. stream_id: e.getId()
  11923. }), (function() {}), (function() {}))
  11924. },
  11925. e._onVideoUnmute = function() {
  11926. R.makeReport(i({
  11927. action: "unmute_remote_video",
  11928. stream_id: e.getId()
  11929. }), (function() {}), (function() {}))
  11930. },
  11931. e._onVideoMute = function() {
  11932. R.makeReport(i({
  11933. action: "mute_remote_video",
  11934. stream_id: e.getId()
  11935. }), (function() {}), (function() {}))
  11936. },
  11937. "ontrack" === n && "video" === t.track.kind || "onaddstream" === n) {
  11938. r.
  11939. default.info("[".concat(R.clientId, "] Remote stream subscribed with uid "), e.getId());
  11940. var a = R.remoteStreams[e.getId()];
  11941. if (R.remoteStreams[e.getId()].stream = "onaddstream" === n ? t.stream: t.streams[0], R.remoteStreams[e.getId()].hasVideo()) {
  11942. if (Object(g.isFireFox)() || Object(g.isSafari)()) {
  11943. var o = R.remoteStreams[e.getId()].stream;
  11944. Object(H.vsResHack)(o, (function(t, n) {
  11945. e.videoWidth = t,
  11946. e.videoHeight = n
  11947. }), (function(e) {
  11948. return r.
  11949. default.warning("[".concat(R.clientId, "] vsResHack failed: ") + e)
  11950. }))
  11951. }
  11952. } else {
  11953. var s = R.remoteStreams[e.getId()];
  11954. s.peerMuteVideo = !0,
  11955. R._adjustPCMuteStatus(s)
  11956. }
  11957. a && a.isPlaying() && a.elementID && (r.
  11958. 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)),
  11959. delete e.audioLevelHelper;
  11960. var c = u({
  11961. type: "stream-subscribed",
  11962. stream: R.remoteStreams[e.getId()]
  11963. });
  11964. R.dispatchEvent(c)
  11965. }
  11966. },
  11967. clearInterval(R.timers[e.getId()]),
  11968. R.timers[e.getId()] = setInterval((function() {
  11969. if (Object(o.getParameter)("REPORT_STATS")) {
  11970. var t = 0;
  11971. e && e.pc && e.pc.getStats && e.pc.getStatsRate((function(n) {
  11972. n.forEach((function(n) {
  11973. if (n && n.id) {
  11974. 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 + "");
  11975. var a = 200 * t;
  11976. t++;
  11977. var i = e.getId();
  11978. setTimeout((function() {
  11979. var t = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  11980. if (t > Object(o.getParameter)("REPORT_STATS_TIMEOUT")) r.
  11981. default.debug("SubscribeStats report blocked by REPORT_STATS_TIMEOUT ".concat(t));
  11982. else {
  11983. if ("video" === n.mediaType) try {
  11984. var a = e.stream.getVideoTracks()[0];
  11985. n.A_vrtd = a.enabled ? "0": "1"
  11986. } catch(e) {}
  11987. if ("audio" === n.mediaType) try {
  11988. var s = e.stream.getAudioTracks()[0];
  11989. n.A_artd = s.enabled ? "0": "1"
  11990. } catch(e) {}
  11991. R.makeReport(v(i, n))
  11992. }
  11993. }), a)
  11994. } else;
  11995. }))
  11996. }))
  11997. }
  11998. }), 3e3),
  11999. clearInterval(R.timers[e.getId() + "_RelatedStats"]),
  12000. R.timers[e.getId() + "_RelatedStats"] = setInterval((function() {
  12001. if (Object(o.getParameter)("REPORT_STATS") && e && e.pc) {
  12002. var t = R.socket && R.socket.getLastMsgTime() && Date.now() - R.socket.getLastMsgTime();
  12003. if (t > Object(o.getParameter)("REPORT_STATS_TIMEOUT")) return void r.
  12004. default.debug("SubscribeRelatedStats report blocked by REPORT_STATS_TIMEOUT ".concat(t));
  12005. e.pc.getVideoRelatedStats && e.pc.getVideoRelatedStats((function(t) {
  12006. e.player && (t.isFreeze = e.player.freezeCount > e.player.lastFreezeCount, e.player.lastFreezeCount = e.player.freezeCount),
  12007. R.makeReport(d(e.getId(), t))
  12008. })),
  12009. e.pc.getAudioRelatedStats && e.pc.getAudioRelatedStats((function(t) {
  12010. R.makeReport(d(e.getId(), t))
  12011. }))
  12012. }
  12013. }), 1e3),
  12014. R.audioLevel[e.getId()] = 0,
  12015. clearInterval(R.timers[e.getId() + "audio"]),
  12016. R.timers[e.getId() + "audio"] = setInterval((function() {
  12017. R.hasListeners("active-speaker") && e && e.pc && "established" === e.pc.state && e.pc.getStats && e.pc.getStats((function(t) {
  12018. t.forEach((function(t) {
  12019. if ("audio" === t.mediaType) {
  12020. 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);
  12021. var a = Object.keys(R.audioLevel).sort((function(e, t) {
  12022. return R.audioLevel[t] - R.audioLevel[e]
  12023. }));
  12024. if (R.activeSpeaker !== a[0]) {
  12025. var i = l({
  12026. type: "active-speaker",
  12027. uid: a[0]
  12028. });
  12029. R.dispatchEvent(i),
  12030. R.activeSpeaker = a[0],
  12031. r.
  12032. default.debug("[".concat(R.clientId, "] Update active speaker: ").concat(R.activeSpeaker))
  12033. }
  12034. }
  12035. }))
  12036. }), 50)
  12037. }), 50),
  12038. e.pc.oniceconnectionstatechange = function(i) {
  12039. if ("failed" === i) null != R.timers[e.getId()] && (clearInterval(R.timers[e.getId()]), clearInterval(R.timers[e.getId()] + "audio")),
  12040. r.
  12041. default.error("[".concat(R.clientId, "] Subscriber connection is lost -- streamId: ").concat(e.getId(), ", p2pId: ").concat(p)),
  12042. r.
  12043. default.debug("[".concat(R.clientId, "] subscribe p2p failed: "), R.p2ps),
  12044. c || (c = !0, n && n(I.
  12045. default.PEERCONNECTION_FAILED), s.b.subscribe(R.joinInfo.sid, {
  12046. lts: a,
  12047. succ: !1,
  12048. video: e.subscribeOptions && e.subscribeOptions.video,
  12049. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12050. peerid: e.getId(),
  12051. ec: I.
  12052. default.PEERCONNECTION_FAILED,
  12053. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12054. p2pid: p
  12055. })),
  12056. R.remoteStreams[e.getId()] && R.p2ps.has(p) && (R.p2ps.delete(p), R.dispatchEvent(l({
  12057. type: "subP2PLost",
  12058. stream: e
  12059. })));
  12060. else if ("connected" === i && (r.
  12061. default.debug("[".concat(R.clientId, "] subscribe p2p connected: "), R.p2ps), !c)) {
  12062. c = !0,
  12063. s.b.subscribe(R.joinInfo.sid, {
  12064. lts: a,
  12065. succ: !0,
  12066. video: e.subscribeOptions && e.subscribeOptions.video,
  12067. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12068. peerid: e.getId(),
  12069. ec: null,
  12070. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12071. p2pid: p
  12072. }),
  12073. R._adjustPCMuteStatus(e);
  12074. var o = !1,
  12075. d = !1,
  12076. u = !1,
  12077. f = setInterval((function() {
  12078. o && d || (e.pc ? e.pc.getStats((function(t) {
  12079. t.forEach((function(t) {
  12080. 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) {
  12081. if ((t.googDecodingNormal > 0 || t.audioOutputLevel > 0) && !o) {
  12082. o = !0,
  12083. R.dispatchEvent({
  12084. type: "first-audio-frame-decode",
  12085. stream: e
  12086. }),
  12087. o && d && clearInterval(f);
  12088. var n = Date.now(),
  12089. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12090. s.b.firstAudioDecode(R.joinInfo.sid, {
  12091. peerid: e.uintId,
  12092. uid: R.uid,
  12093. elapse: n - a,
  12094. subscribeElapse: n - e.subscribeLTS,
  12095. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12096. p2pid: p
  12097. })
  12098. }
  12099. if (parseInt(t.packetsReceived) > 0 && !d) {
  12100. d = !0,
  12101. R.dispatchEvent({
  12102. type: "first-audio-packet-received",
  12103. stream: e
  12104. }),
  12105. o && d && clearInterval(f);
  12106. n = Date.now(),
  12107. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12108. s.b.firstAudioReceived(R.joinInfo.sid, {
  12109. peerid: e.uintId,
  12110. uid: R.uid,
  12111. elapse: n - a,
  12112. subscribeElapse: n - e.subscribeLTS,
  12113. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12114. p2pid: p
  12115. })
  12116. }
  12117. }
  12118. }))
  12119. }), 100) : clearInterval(f))
  12120. }), 100),
  12121. g = !1,
  12122. m = !1,
  12123. v = setInterval((function() {
  12124. g && m || (e.pc ? e.pc.getStats((function(t) {
  12125. t.forEach((function(t) {
  12126. 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) {
  12127. if ((t.framesDecoded > 0 || t.googFramesDecoded > 0) && !g) {
  12128. g = !0,
  12129. R.dispatchEvent({
  12130. type: "first-video-frame-decode",
  12131. stream: e
  12132. }),
  12133. g && m && clearInterval(v);
  12134. var n = Date.now(),
  12135. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12136. e.firstFrameTime = (new Date).getTime() - e.subscribeLTS,
  12137. s.b.firstVideoDecode(R.joinInfo.sid, {
  12138. peerid: e.uintId,
  12139. width: parseInt(t.googFrameWidthReceived) || 0,
  12140. height: parseInt(t.googFrameHeightReceived) || 0,
  12141. uid: R.uid,
  12142. elapse: n - a,
  12143. subscribeElapse: n - e.subscribeLTS,
  12144. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12145. p2pid: p
  12146. })
  12147. }
  12148. if (t.packetsReceived > 0 && !m) {
  12149. m = !0,
  12150. R.dispatchEvent({
  12151. type: "first-video-packet-received",
  12152. stream: e
  12153. }),
  12154. g && m && clearInterval(v);
  12155. n = Date.now(),
  12156. a = s.b.getSessionStartTime(R.joinInfo.sid);
  12157. s.b.firstVideoReceived(R.joinInfo.sid, {
  12158. peerid: e.uintId,
  12159. uid: R.uid,
  12160. elapse: n - a,
  12161. subscribeElapse: n - e.subscribeLTS,
  12162. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12163. p2pid: p
  12164. })
  12165. }
  12166. }
  12167. }))
  12168. }), 100) : clearInterval(v))
  12169. }), 100),
  12170. S = setInterval((function() {
  12171. if (!u) {
  12172. var t = e.getId(),
  12173. n = R.traffic_stats;
  12174. if (n && n.peer_delay) {
  12175. var a = n.peer_delay.find((function(e) {
  12176. return e.peer_uid == t
  12177. }));
  12178. if (a) {
  12179. u = !0;
  12180. var i = s.b.getSessionStartTime(R.joinInfo.sid),
  12181. o = a.peer_publish_audio_duration + (Date.now() - n.timestamp),
  12182. r = Date.now();
  12183. s.b.peerPublishStatus({
  12184. lts: r,
  12185. sid: R.joinInfo.sid,
  12186. cname: R.joinInfo.cname,
  12187. cid: R.joinInfo.cid,
  12188. uid: R.joinInfo.uid,
  12189. elapse: r - i,
  12190. peer: t,
  12191. peerPublishDuration: o,
  12192. joinChannelSuccessElapse: r - R.joinSuccessLts,
  12193. subscribeElapse: r - e.subscribeLTS
  12194. }),
  12195. clearInterval(S)
  12196. }
  12197. }
  12198. }
  12199. }), 1e3);
  12200. return e.sid = R.joinInfo.sid,
  12201. t && t()
  12202. }
  12203. }
  12204. } else r.
  12205. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  12206. c || (c = !0, n && n(I.
  12207. default.INVALID_REMOTE_STREAM), s.b.subscribe(R.joinInfo.sid, {
  12208. lts: a,
  12209. succ: !1,
  12210. video: e.subscribeOptions && e.subscribeOptions.video,
  12211. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12212. peerid: e.getId(),
  12213. ec: I.
  12214. default.INVALID_REMOTE_STREAM
  12215. }));
  12216. else r.
  12217. default.error("[".concat(R.clientId, "] No such remote stream")),
  12218. c || (c = !0, n && n(I.
  12219. default.NO_SUCH_REMOTE_STREAM), s.b.subscribe(R.joinInfo.sid, {
  12220. lts: a,
  12221. succ: !1,
  12222. video: e.subscribeOptions && e.subscribeOptions.video,
  12223. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12224. peerid: e.getId(),
  12225. ec: I.
  12226. default.NO_SUCH_REMOTE_STREAM
  12227. }))
  12228. },
  12229. R.subscribeChange = function(e, t, n) {
  12230. var a = Date.now();
  12231. r.
  12232. default.info("[".concat(R.clientId, "] Gatewayclient ").concat(R.uid, " SubscribeChange ").concat(e.getId(), ": ").concat(JSON.stringify(e.subscribeOptions))),
  12233. R._adjustPCMuteStatus(e);
  12234. var i = {
  12235. stream_id: e.getId(),
  12236. audio: e.subscribeOptions.audio,
  12237. video: e.subscribeOptions.video
  12238. };
  12239. R.makeRequest({
  12240. _type: "subscribe_change",
  12241. _message: i
  12242. },
  12243. (function(n) {
  12244. var i = u({
  12245. type: "stream-subscribe-changed",
  12246. stream: R.remoteStreams[e.getId()]
  12247. });
  12248. s.b.subscribe(R.joinInfo.sid, {
  12249. lts: a,
  12250. succ: !0,
  12251. video: e.subscribeOptions && e.subscribeOptions.video,
  12252. audio: e.subscribeOptions && e.subscribeOptions.audio,
  12253. peerid: e.getId(),
  12254. ec: null,
  12255. subscribeRequestid: R.subscribeRequestId.get(e.getId()) || 0,
  12256. p2pid: R.p2ps.get(e.getId())
  12257. }),
  12258. R.dispatchEvent(i),
  12259. t && t()
  12260. }), (function(t, a) {
  12261. r.
  12262. default.error("[".concat(R.clientId, "] Subscribe Change Failed ").concat(e.getId()), t, a),
  12263. n && n(t, a)
  12264. }))
  12265. },
  12266. R.processPublishFailure = function(e) {
  12267. e.publishLTS = null,
  12268. e.p2pId && R.p2ps.get(e.p2pId) === e && R.p2ps.delete(e.p2pId),
  12269. R.localStreams[e.getUserId()] === e && delete R.localStreams[e.getUserId()],
  12270. R.localStreams[e.getId()] === e && delete R.localStreams[e.getId()],
  12271. e.pc && (e.pc.processSignalingMessage = function() {},
  12272. e.pc.oniceconnectionstatechange = function() {},
  12273. e.pc.close(), delete e.pc),
  12274. delete e.onClose,
  12275. delete e._onAudioUnmute,
  12276. delete e._onVideoUnmute,
  12277. delete e._onAudioMute,
  12278. delete e._onVideoMute,
  12279. delete e._onAudioUnmute
  12280. },
  12281. R.processSubscribeFailure = function(e) {
  12282. e.p2pId && R.p2ps.get(e.p2pId) === e && R.p2ps.delete(e.p2pId),
  12283. e.pc && (e.pc.onaddstream = function() {},
  12284. e.pc.processSignalingMessage = function() {},
  12285. e.pc.oniceconnectionstatechange = function() {},
  12286. e.pc.close(), delete e.pc),
  12287. delete e.onClose,
  12288. delete e._onAudioUnmute,
  12289. delete e._onVideoUnmute,
  12290. delete e._onAudioMute,
  12291. delete e._onVideoMute,
  12292. delete e._onAudioUnmute
  12293. },
  12294. R._adjustPCMuteStatus = function(e) { ! e.local && e.pc && e.pc.peerConnection.getReceivers && e.pc.peerConnection.getReceivers().forEach((function(t) {
  12295. if (t && t.track && "audio" === t.track.kind) {
  12296. var n = !e.userMuteAudio && !e.peerMuteAudio;
  12297. e.subscribeOptions && !e.subscribeOptions.audio && (n = !1),
  12298. t.track.enabled = !!n
  12299. } else if (t && t.track && "video" === t.track.kind) {
  12300. var a = !e.userMuteVideo && !e.peerMuteVideo;
  12301. e.subscribeOptions && !e.subscribeOptions.video && (a = !1),
  12302. t.track.enabled = !!a
  12303. }
  12304. }))
  12305. },
  12306. R.unsubscribe = function(e, t, n) {
  12307. if ("object" !== be()(e) || null === e) return r.
  12308. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  12309. void A(n, I.
  12310. default.INVALID_REMOTE_STREAM);
  12311. if (R.state !== h) return r.
  12312. default.error("[".concat(R.clientId, "] User is not in the session")),
  12313. void A(n, I.
  12314. default.INVALID_OPERATION);
  12315. 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())) {
  12316. if (!R.socket) return r.
  12317. default.error("[".concat(R.clientId, "] User is not in the session")),
  12318. void A(n, I.
  12319. default.INVALID_OPERATION);
  12320. if (e.local) return r.
  12321. default.error("[".concat(R.clientId, "] Invalid remote stream")),
  12322. void A(n, I.
  12323. default.INVALID_REMOTE_STREAM);
  12324. e.close(),
  12325. e.stop();
  12326. var a = {
  12327. stream_id: e.getId()
  12328. };
  12329. R.makeRequest({
  12330. _type: "unsubscribe",
  12331. _message: a
  12332. }),
  12333. void 0 !== e.pc && (e.pc.close(), e.pc = void 0),
  12334. e.onClose = void 0,
  12335. e._onAudioMute = void 0,
  12336. e._onAudioUnute = void 0,
  12337. e._onVideoMute = void 0,
  12338. e._onVideoUnmute = void 0,
  12339. delete e.subscribeOptions,
  12340. R.p2ps.delete(e.p2pId),
  12341. r.
  12342. default.info("[".concat(R.clientId, "] Unsubscribe stream success")),
  12343. t && t()
  12344. } else A(n, I.
  12345. default.NO_SUCH_REMOTE_STREAM)
  12346. },
  12347. R.setRemoteVideoStreamType = function(e, t) {
  12348. if (r.
  12349. default.debug("[".concat(R.clientId, "] Switching remote video stream ").concat(e.getId(), " to ").concat(t)), "object" === be()(e) && null !== e) if (R.state === h) {
  12350. if (!e.local) {
  12351. switch (t) {
  12352. case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_HIGH:
  12353. case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_LOW:
  12354. case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_MEDIUM:
  12355. break;
  12356. default:
  12357. return
  12358. }
  12359. var n = {
  12360. stream_id: e.getId(),
  12361. stream_type: t
  12362. };
  12363. R.makeRequest({
  12364. _type: "switch_video_stream",
  12365. _message: n
  12366. },
  12367. (function() {
  12368. r.
  12369. default.debug("SwitchVideoStream Success ".concat(n.stream_id, " ").concat(n.stream_type))
  12370. }), (function(e, t) {
  12371. r.
  12372. default.error("SwitchVideoStream Error ".concat(e, " ").concat(n.stream_id, " ").concat(n.stream_type), t)
  12373. }))
  12374. }
  12375. } else r.
  12376. default.error("[".concat(R.clientId, "] User is not in the session"));
  12377. else r.
  12378. default.error("[".concat(R.clientId, "] Invalid remote stream"))
  12379. },
  12380. R.renewToken = function(e, t, n) {
  12381. e ? R.key ? R.state !== h ? (r.
  12382. default.debug("[".concat(R.clientId, "] Client is not connected. Trying to rejoin")), R.key = e, R.rejoin(), t && t()) : (r.
  12383. default.debug("[".concat(R.clientId, "] renewToken from ").concat(R.key, " to ").concat(e)), R.makeRequest({
  12384. _type: "renew_token",
  12385. _message: {
  12386. token: e
  12387. }
  12388. },
  12389. t, n)) : (r.
  12390. default.error("[".concat(R.clientId, "] Client is previously joined without token")), n && n(I.
  12391. default.INVALID_PARAMETER)):
  12392. (r.
  12393. default.error("[".concat(R.clientId, "] Invalid Token ").concat(e)), n && n(I.
  12394. default.INVALID_PARAMETER))
  12395. },
  12396. R.setStreamFallbackOption = function(e, t) {
  12397. if (r.
  12398. default.debug("[".concat(R.clientId, "] Set stream fallback option ").concat(e.getId(), " to ").concat(t)), "object" === be()(e) && null !== e) if (R.state === h) {
  12399. if (!e.local) {
  12400. switch (t) {
  12401. case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_DISABLED:
  12402. case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW:
  12403. case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_AUDIO_ONLY:
  12404. break;
  12405. default:
  12406. return
  12407. }
  12408. var n = {
  12409. stream_id: e.getId(),
  12410. fallback_type: t
  12411. };
  12412. R.makeRequest({
  12413. _type: "set_fallback_option",
  12414. _message: n
  12415. },
  12416. (function() {
  12417. r.
  12418. default.debug("SetStreamFallbackOption success ".concat(n.stream_id, " ").concat(t))
  12419. }), (function(e, a) {
  12420. r.
  12421. default.error("Failed to SetStreamFallbackOption ".concat(n.stream_id, " ").concat(t, " ").concat(e), a)
  12422. }))
  12423. }
  12424. } else r.
  12425. default.error("[".concat(R.clientId, "] User is not in the session"));
  12426. else r.
  12427. default.error("[".concat(R.clientId, "] Invalid remote stream"))
  12428. },
  12429. R.enableAudioVolumeIndicator = function(e, t) {
  12430. R.audioVolumeIndication.enabled = !0,
  12431. R.audioVolumeIndication.interval = e,
  12432. R.audioVolumeIndication.smooth = t,
  12433. R.resetAudioVolumeIndication()
  12434. },
  12435. R.resetAudioVolumeIndication = function() {
  12436. if (clearInterval(R.timers.audioVolumeIndication), clearInterval(R.timers.audioVolumeSampling), R.audioVolumeIndication.enabled && R.audioVolumeIndication.interval) {
  12437. var e = Math.floor(1e3 * R.audioVolumeIndication.smooth / 100);
  12438. clearInterval(R.timers.audioVolumeSampling),
  12439. R.timers.audioVolumeSampling = setInterval((function() {
  12440. R.audioVolumeSampling || (R.audioVolumeSampling = {});
  12441. var t = {};
  12442. for (var n in R.remoteStreams) {
  12443. var a = R.remoteStreams[n];
  12444. if (a.stream && a.hasAudio()) {
  12445. var i = a.getAudioLevel();
  12446. i > 0 && i < 1 && (i *= 100);
  12447. var o = R.audioVolumeSampling[n] || [];
  12448. for (o.push(i); o.length > e;) o.shift();
  12449. t[n] = o
  12450. }
  12451. }
  12452. R.audioVolumeSampling = t
  12453. }), 100),
  12454. clearInterval(R.timers.audioVolumeIndication),
  12455. R.timers.audioVolumeIndication = setInterval((function() {
  12456. if (R.socket && R.socket.signal && R.socket.signal.connection && R.socket.signal.connection.readyState === WebSocket.OPEN) {
  12457. var e = [];
  12458. for (var t in R.remoteStreams) if (R.audioVolumeSampling && R.audioVolumeSampling[t]) {
  12459. var n = R.audioVolumeSampling[t],
  12460. a = 0;
  12461. n.forEach((function(e) {
  12462. a += e
  12463. }));
  12464. var i = {
  12465. uid: t,
  12466. level: Math.floor(a / n.length)
  12467. };
  12468. i.level && e.push(i)
  12469. }
  12470. var o = e.sort((function(e, t) {
  12471. return e.level - t.level
  12472. }));
  12473. r.
  12474. default.debug("[".concat(R.clientId, "] volume-indicator "), JSON.stringify(o)),
  12475. R.audioVolumeIndication.sortedAudioVolumes = o;
  12476. var s = l({
  12477. type: "volume-indicator",
  12478. attr: o
  12479. });
  12480. R.dispatchEvent(s)
  12481. }
  12482. }), R.audioVolumeIndication.interval)
  12483. }
  12484. },
  12485. R.closeGateway = function() {
  12486. r.
  12487. default.debug("[".concat(R.clientId, "] close gateway")),
  12488. R.state = S,
  12489. R.socket.close(),
  12490. O()
  12491. },
  12492. R.startChannelMediaRelay = function() {
  12493. var e = ee()(Z.a.mark((function e(t) {
  12494. var n, a, i, o;
  12495. return Z.a.wrap((function(e) {
  12496. for (;;) switch (e.prev = e.next) {
  12497. case 0:
  12498. if (!R.channelMediaRelayController) {
  12499. e.next = 2;
  12500. break
  12501. }
  12502. throw new Ce.ChannelMediaError("RELAY_ALREADY_START", "", Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_ALREADY_START);
  12503. case 2:
  12504. return n = function(e) {
  12505. R.dispatchEvent({
  12506. type: "channel-media-relay-event",
  12507. code: e
  12508. })
  12509. },
  12510. a = function(e, t, n) {
  12511. e === Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE && t === Ce.CHANNEL_MEDIA_RELAY_ERROR.SERVER_CONNECTION_LOST && (R.channelMediaRelayController.dispose(), R.channelMediaRelayController = null),
  12512. R.dispatchEvent({
  12513. type: "channel-media-relay-state",
  12514. state: e,
  12515. code: t,
  12516. data: n
  12517. })
  12518. },
  12519. R.channelMediaRelayController = new Ne.a(R.joinInfo, R.clientId),
  12520. R.channelMediaRelayController.on("event", n),
  12521. R.channelMediaRelayController.on("state", a),
  12522. e.prev = 7,
  12523. e.next = 10,
  12524. R.channelMediaRelayController.startChannelMediaRelay(t);
  12525. case 10:
  12526. e.next = 22;
  12527. break;
  12528. case 12:
  12529. throw e.prev = 12,
  12530. e.t0 = e.
  12531. catch(7),
  12532. r.
  12533. default.debug("[".concat(R.clientId, "] startChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),
  12534. i = Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,
  12535. o = "",
  12536. 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",
  12537. R.dispatchEvent({
  12538. type: "channel-media-relay-state",
  12539. state: i,
  12540. code: Ce.CHANNEL_MEDIA_RELAY_ERROR[o]
  12541. }),
  12542. R.channelMediaRelayController && (R.channelMediaRelayController.dispose(), R.channelMediaConfig = null, R.channelMediaRelayController = null),
  12543. R.dispatchEvent({
  12544. type: "channel-media-relay-state",
  12545. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE
  12546. }),
  12547. new Ce.ChannelMediaError(o, null, Ce.CHANNEL_MEDIA_RELAY_ERROR[o]);
  12548. case 22:
  12549. R.dispatchEvent({
  12550. type:
  12551. "channel-media-relay-state",
  12552. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_RUNNING,
  12553. code: Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_OK
  12554. }),
  12555. R.channelMediaConfig = t;
  12556. case 24:
  12557. case "end":
  12558. return e.stop()
  12559. }
  12560. }), e, null, [[7, 12]])
  12561. })));
  12562. return function(t) {
  12563. return e.apply(this, arguments)
  12564. }
  12565. } (),
  12566. R.updateChannelMediaRelay = function() {
  12567. var t = ee()(Z.a.mark((function t(n) {
  12568. var a, i;
  12569. return Z.a.wrap((function(t) {
  12570. for (;;) switch (t.prev = t.next) {
  12571. case 0:
  12572. if (R.channelMediaRelayController) {
  12573. t.next = 2;
  12574. break
  12575. }
  12576. throw new Ce.ChannelMediaError("RELAY_NOT_START", null, Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);
  12577. case 2:
  12578. return t.prev = 2,
  12579. t.next = 5,
  12580. R.channelMediaRelayController.updateChannelMediaRelay(n);
  12581. case 5:
  12582. t.next = 18;
  12583. break;
  12584. case 7:
  12585. throw t.prev = 7,
  12586. t.t0 = t.
  12587. catch(2),
  12588. r.
  12589. default.debug("[".concat(R.clientId, "] updateChannelMediaRelay exception: ").concat(JSON.stringify(e))),
  12590. a = Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,
  12591. i = "",
  12592. 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",
  12593. R.dispatchEvent({
  12594. type: "channel-media-relay-event",
  12595. code: Ce.CHANNEL_MEDIA_RELAY_EVENT.PACKET_UPDATE_DEST_CHANNEL_REFUSED
  12596. }),
  12597. R.dispatchEvent({
  12598. type: "channel-media-relay-state",
  12599. state: a,
  12600. code: Ce.CHANNEL_MEDIA_RELAY_ERROR[i]
  12601. }),
  12602. R.channelMediaRelayController && (R.channelMediaRelayController.dispose(), R.channelMediaConfig = null, R.channelMediaRelayController = null),
  12603. R.dispatchEvent({
  12604. type: "channel-media-relay-state",
  12605. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE
  12606. }),
  12607. new Ce.ChannelMediaError(i, null, Ce.CHANNEL_MEDIA_RELAY_ERROR[i]);
  12608. case 18:
  12609. R.channelMediaConfig = n;
  12610. case 19:
  12611. case "end":
  12612. return t.stop()
  12613. }
  12614. }), t, null, [[2, 7]])
  12615. })));
  12616. return function(e) {
  12617. return t.apply(this, arguments)
  12618. }
  12619. } (),
  12620. R.stopChannelMediaRelay = ee()(Z.a.mark((function t() {
  12621. var n, a;
  12622. return Z.a.wrap((function(t) {
  12623. for (;;) switch (t.prev = t.next) {
  12624. case 0:
  12625. if (R.channelMediaRelayController) {
  12626. t.next = 2;
  12627. break
  12628. }
  12629. throw new Ce.ChannelMediaError("RELAY_NOT_START", null, Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);
  12630. case 2:
  12631. return t.prev = 2,
  12632. t.next = 5,
  12633. R.channelMediaRelayController.stopChannelMediaRelay();
  12634. case 5:
  12635. t.next = 17;
  12636. break;
  12637. case 7:
  12638. throw t.prev = 7,
  12639. t.t0 = t.
  12640. catch(2),
  12641. r.
  12642. default.debug("[".concat(R.clientId, "] stopChannelMediaRelay exception: ").concat(JSON.stringify(e))),
  12643. n = Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,
  12644. a = "",
  12645. 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",
  12646. R.dispatchEvent({
  12647. type: "channel-media-relay-state",
  12648. state: n,
  12649. code: Ce.CHANNEL_MEDIA_RELAY_ERROR[a]
  12650. }),
  12651. R.channelMediaRelayController && (R.channelMediaRelayController.dispose(), R.channelMediaConfig = null, R.channelMediaRelayController = null),
  12652. R.dispatchEvent({
  12653. type: "channel-media-relay-state",
  12654. state: Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE
  12655. }),
  12656. new Ce.ChannelMediaError(a, null, Ce.CHANNEL_MEDIA_RELAY_ERROR[a]);
  12657. case 17:
  12658. R.channelMediaConfig = null,
  12659. R.channelMediaRelayController = null;
  12660. case 19:
  12661. case "end":
  12662. return t.stop()
  12663. }
  12664. }), t, null, [[2, 7]])
  12665. }))),
  12666. R.sendMetadata = function(e, t) {
  12667. R.makeRequest(function(e) {
  12668. return {
  12669. _type: "send_metadata",
  12670. _message: {
  12671. session_id: R.joinInfo.sid,
  12672. metadata: window.btoa(unescape(encodeURIComponent(e)))
  12673. }
  12674. }
  12675. } (e), (function() {
  12676. r.
  12677. default.debug("[".concat(R.clientId, '] send metadata "').concat(e, '" success')),
  12678. t && t(null)
  12679. }), (function(n) {
  12680. r.
  12681. default.error("[".concat(R.clientId, '] send metadata "').concat(e, '" failed'), n),
  12682. t && t(n)
  12683. }))
  12684. };
  12685. var y = function() {
  12686. r.
  12687. default.debug("[".concat(R.clientId, "] Reconnect gateway")),
  12688. R.state = S,
  12689. R.socket.close(),
  12690. O(),
  12691. R.reconnectMode = "recover",
  12692. R.state = _,
  12693. C()
  12694. };
  12695. R.recover = y;
  12696. var O = function() {
  12697. for (var e in R.dispatchEvent({
  12698. type: "before-clear-connection"
  12699. }), R.timers) R.timers.hasOwnProperty(e) && clearInterval(R.timers[e]);
  12700. for (var e in R.remoteStreams) if (R.remoteStreams.hasOwnProperty(e)) {
  12701. var t = R.remoteStreams[e],
  12702. n = l({
  12703. type: "stream-removed",
  12704. uid: t.getId(),
  12705. stream: t
  12706. });
  12707. R.dispatchEvent(n)
  12708. }
  12709. R.p2ps.clear(),
  12710. k(),
  12711. D(),
  12712. clearInterval(R.pingTimer)
  12713. };
  12714. R.rejoin = function() {
  12715. R.socket && (clearInterval(R.pingTimer), R.socket.close(), R.socket = void 0),
  12716. R.state = _,
  12717. C()
  12718. };
  12719. var C = function(e, t) {
  12720. R.dispatchEvent(l({
  12721. type: "rejoin-start"
  12722. })),
  12723. e = e ||
  12724. function(e) {
  12725. r.
  12726. default.info("[".concat(R.clientId, "] User ").concat(e, " is re-joined to ").concat(R.joinInfo.cname)),
  12727. R.dispatchEvent(l({
  12728. type: "rejoin"
  12729. })),
  12730. R.channelMediaConfig && R.startChannelMediaRelay(R.channelMediaConfig).then((function() {
  12731. r.
  12732. default.debug("[".concat(R.clientId, "] restartChannelMediaRelay success"))
  12733. })).
  12734. catch((function(e) {
  12735. r.
  12736. default.debug("[".concat(R.clientId, "] restartChannelMediaRelay failed: ").concat(JSON.stringify(e)))
  12737. })),
  12738. R.liveStreams && R.liveStreams.size && R.liveStreams.forEach((function(e, t) {
  12739. e && R.setLiveTranscoding(R.transcoding),
  12740. R.startLiveStreaming(t, e)
  12741. })),
  12742. R.injectLiveStreams && R.injectLiveStreams.size && R.injectLiveStreams.forEach((function(e, t) {
  12743. R.addInjectStreamUrl(t, e)
  12744. }))
  12745. },
  12746. t = t ||
  12747. function(e) {
  12748. r.
  12749. default.error("[".concat(R.clientId, "] Re-join to channel failed "), e),
  12750. R.dispatchEvent(u({
  12751. type: "error",
  12752. reason: e
  12753. }))
  12754. },
  12755. R.key ? (++R.rejoinAttempt, R.join(R.joinInfo, R.key, e, t)) : r.
  12756. default.error("[".concat(R.clientId, "] Connection recover failed [Invalid channel key]"))
  12757. },
  12758. N = function(e, t, n) {
  12759. if (R.onConnect = t, R.socket) {
  12760. if (R.dispatchEvent({
  12761. type: "reconnect"
  12762. }), "retry" === R.reconnectMode) r.
  12763. default.debug("[".concat(R.clientId, "] Retry current gateway")),
  12764. R.socket.reconnect();
  12765. else if ("tryNext" === R.reconnectMode) r.
  12766. default.debug("[".concat(R.clientId, "] Try next gateway")),
  12767. R.socket.connectNext();
  12768. else if ("recover" === R.reconnectMode) {
  12769. r.
  12770. default.debug("[".concat(R.clientId, "] Recover gateway")),
  12771. r.
  12772. default.debug("[".concat(R.clientId, "] Try to reconnect choose server and get gateway list again ")),
  12773. R.reconnectingCS = !0;
  12774. var i = R.joinInfo && R.joinInfo.sid;
  12775. 0,
  12776. ze(R.joinInfo, (function(e) {
  12777. r.
  12778. default.debug("[".concat(R.clientId, "] session: ").concat(i, " get gateway list success")),
  12779. R.joinInfo.apResponse = e.res,
  12780. R.reconnectingCS ? R.socket.replaceHost(e.gateway_addr) : r.
  12781. default.debug("[".concat(R.clientId, "] session: ").concat(i, " already leave"))
  12782. }))
  12783. }
  12784. } else c = e.gatewayAddr,
  12785. R.socket = Ve(c, {
  12786. sid: R.joinInfo.sid,
  12787. clientId: R.clientId
  12788. }),
  12789. R.socket.on("start-connection", (function(e) {
  12790. R.ticket = e && e.msg && e.msg.ticket
  12791. })),
  12792. R.socket.on("on_uplink_stats", (function(e) {
  12793. var t = {};
  12794. for (var n in e) t[it(n)] = e[n];
  12795. if (R.OutgoingAvailableBandwidth = t.uplink_available_bandwidth, R.localStreams[R.uid]) {
  12796. var a = R.localStreams[R.uid].uplinkStats;
  12797. a && a.period_fir === t.period_fir || r.
  12798. default.debug("[".concat(R.clientId, "]: Period fir change to: ").concat(t.period_fir)),
  12799. R.localStreams[R.uid].uplinkStats = t
  12800. }
  12801. })),
  12802. R.socket.on("connect", (function() {
  12803. R.dispatchEvent({
  12804. type: "connected"
  12805. }),
  12806. R.attemps = 1,
  12807. R.onConnect()
  12808. })),
  12809. R.socket.on("recover", (function() {
  12810. R.state = _,
  12811. r.
  12812. default.debug("[".concat(R.clientId, "] Try to reconnect choose server and get gateway list again ")),
  12813. R.reconnectingCS = !0;
  12814. var e = R.joinInfo && R.joinInfo.sid;
  12815. ze(R.joinInfo, (function(t) {
  12816. r.
  12817. default.debug("[".concat(R.clientId, "] session: ").concat(e, " get gateway list success")),
  12818. R.reconnectingCS ? R.socket.replaceHost(t.gateway_addr) : r.
  12819. default.debug("[".concat(R.clientId, "] session: ").concat(e, " already leave"))
  12820. }))
  12821. })),
  12822. R.socket.on("disconnect", (function(e) {
  12823. if (r.
  12824. default.debug("[".concat(R.clientId, "] Receive disconnect message")), R.state !== S) {
  12825. R.state = S;
  12826. var t = u({
  12827. type: "error",
  12828. reason: I.
  12829. default.SOCKET_DISCONNECTED
  12830. });
  12831. 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) {
  12832. var n, i = (n = R.attemps, 1e3 * Math.min(30, Math.pow(2, n) - 1));
  12833. if (r.
  12834. 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.
  12835. default.debug("[".concat(R.clientId, "] No reconnection because Client.leave has been invoked")),
  12836. void(R.hasInvokeLeave = !1);
  12837. setTimeout((function() {
  12838. R.attemps++,
  12839. R.state = _,
  12840. R.inChannelInfo && Date.now() - R.inChannelInfo.joinAt > Object(o.getParameter)("TICKET_RENEW_TIMEOUT") ? (r.
  12841. default.debug("Recovering to renew ticket"), y()) : C()
  12842. }), i)
  12843. }
  12844. }
  12845. })),
  12846. R.socket.on("on_add_audio_stream", (function(e) {
  12847. if (r.
  12848. default.info("[".concat(R.clientId, "] Newly added audio stream with uid ").concat(e.uid)), R.joinInfo.stringUid && "string" != typeof e.uid && r.
  12849. default.error("StringUID is Mixed with UintUID"), R.remoteStreamsInChannel.has(e.uid) || R.remoteStreamsInChannel.add(e.uid), void 0 === R.remoteStreams[e.uid]) {
  12850. var t = ye({
  12851. streamID: e.uid,
  12852. local: !1,
  12853. audio: e.audio,
  12854. video: e.video,
  12855. uintUID: e.uint_id || e.uid
  12856. });
  12857. t.peerMuteVideo = !0,
  12858. R.remoteStreams[e.uid] = t;
  12859. var n = u({
  12860. type: "stream-added",
  12861. stream: t
  12862. });
  12863. R.dispatchEvent(n);
  12864. var a = R.remoteMuteState[e.uid];
  12865. if (a && a.audio) {
  12866. n = l({
  12867. type: "mute-audio",
  12868. uid: e.uid
  12869. });
  12870. R.dispatchEvent(n)
  12871. }
  12872. if (a && a.video) {
  12873. n = l({
  12874. type: "mute-video",
  12875. uid: e.uid
  12876. });
  12877. R.dispatchEvent(n)
  12878. }
  12879. }
  12880. s.b.onAddAudioStream(R.joinInfo.sid, {
  12881. peerid: e.uint_id || e.uid,
  12882. uid: R.uid
  12883. })
  12884. })),
  12885. R.socket.on("on_update_stream", (function(e) {
  12886. var t = R.remoteStreams[e.uid];
  12887. if (R.joinInfo.stringUid && "string" != typeof e.uid && r.
  12888. default.error("StringUID is Mixed with UintUID"), t) {
  12889. t.audio = e.audio,
  12890. t.video = e.video,
  12891. t.screen = e.screen,
  12892. t.pc && R._adjustPCMuteStatus(t);
  12893. var n = u({
  12894. type: "stream-updated",
  12895. stream: t
  12896. });
  12897. R.dispatchEvent(n)
  12898. } else r.
  12899. default.debug("[".concat(R.clientId, "] Ignoring onUpdateStream event before onAddStream for uid ").concat(e.uid));
  12900. s.b.onUpdateStream(R.joinInfo.sid, {
  12901. peerid: e.uint_id || e.uid,
  12902. audio: e.audio,
  12903. video: e.video,
  12904. uid: R.uid
  12905. })
  12906. })),
  12907. R.socket.on("on_add_video_stream", (function(e) {
  12908. if (r.
  12909. default.info("[".concat(R.clientId, "] Newly added remote stream with uid ").concat(e.uid, ".")), R.joinInfo.stringUid && "string" != typeof e.uid && r.
  12910. default.error("StringUID is Mixed with UintUID"), R.remoteStreamsInChannel.has(e.uid) || R.remoteStreamsInChannel.add(e.uid), void 0 === R.remoteStreams[e.uid]) {
  12911. var t = ye({
  12912. streamID: e.uid,
  12913. local: !1,
  12914. audio: e.audio,
  12915. video: e.video,
  12916. uintUID: e.uint_id || e.uid
  12917. });
  12918. R.remoteStreams[e.uid] = t;
  12919. var n = u({
  12920. type: "stream-added",
  12921. stream: t
  12922. });
  12923. R.dispatchEvent(n);
  12924. var a = R.remoteMuteState[e.uid];
  12925. if (a && a.audio) {
  12926. n = l({
  12927. type: "mute-audio",
  12928. uid: e.uid
  12929. });
  12930. R.dispatchEvent(n)
  12931. }
  12932. if (a && a.video) {
  12933. n = l({
  12934. type: "mute-video",
  12935. uid: e.uid
  12936. });
  12937. R.dispatchEvent(n)
  12938. }
  12939. } else {
  12940. var i = R.remoteStreams[e.uid];
  12941. if (void 0 !== i.stream) {
  12942. if ((t = R.remoteStreams[e.uid]).video = !0, t.peerMuteVideo = !1, t.pc && R._adjustPCMuteStatus(t), r.
  12943. default.info("[".concat(R.clientId, "] Stream changed: enable video ").concat(e.uid)), t.isPlaying()) {
  12944. var o = t.player.elementID;
  12945. t.stop(),
  12946. t.play(o, t.playOptions)
  12947. }
  12948. } else if (i.p2pId) R.remoteStreams[e.uid].video = !0;
  12949. else {
  12950. t = ye({
  12951. streamID: e.uid,
  12952. local: !1,
  12953. audio: !0,
  12954. video: !0,
  12955. uintUID: e.uint_id || e.uid
  12956. });
  12957. R.remoteStreams[e.uid] = t,
  12958. r.
  12959. default.info("[".concat(R.clientId, "] Stream changed: modify video ").concat(e.uid))
  12960. }
  12961. }
  12962. s.b.onAddVideoStream(R.joinInfo.sid, {
  12963. peerid: e.uint_id || e.uid,
  12964. uid: R.uid
  12965. })
  12966. })),
  12967. R.socket.on("on_remove_stream", (function(e) {
  12968. R.remoteStreamsInChannel.has(e.uid) && R.remoteStreamsInChannel.delete(e.uid);
  12969. var t = R.remoteStreams[e.uid];
  12970. if (t) {
  12971. delete R.remoteStreams[e.uid],
  12972. delete R.remoteMuteState[e.uid];
  12973. var n = u({
  12974. type: "stream-removed",
  12975. stream: t
  12976. });
  12977. R.dispatchEvent(n),
  12978. t.close(),
  12979. void 0 !== t.pc && (t.pc.close(), t.pc = void 0, R.p2ps.delete(t.p2pId)),
  12980. s.b.onRemoveStream(R.joinInfo.sid, {
  12981. peerid: e.uint_id || e.uid,
  12982. uid: R.uid
  12983. })
  12984. } else r.
  12985. default.error("ERROR stream ", e.uid, " not found onRemoveStream ", e)
  12986. })),
  12987. R.socket.on("on_publish_stream", (function(e) {
  12988. var t = R.localStreams[e.uid],
  12989. n = u({
  12990. type: "streamPublished",
  12991. stream: t
  12992. });
  12993. R.dispatchEvent(n)
  12994. })),
  12995. R.socket.on("mute_audio", (function(e) {
  12996. r.
  12997. default.info("[".concat(R.clientId, "] rcv peer mute audio: ").concat(e.uid)),
  12998. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  12999. audio: !1,
  13000. video: !1
  13001. },
  13002. R.remoteMuteState[e.uid].audio = !0;
  13003. var t = l({
  13004. type: "mute-audio",
  13005. uid: e.uid
  13006. }),
  13007. n = R.remoteStreams[e.uid];
  13008. n ? (n.peerMuteAudio = !0, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13009. default.debug("Ignoring event ".concat(e.type), e)
  13010. })),
  13011. R.socket.on("unmute_audio", (function(e) {
  13012. r.
  13013. default.info("[".concat(R.clientId, "] rcv peer unmute audio: ").concat(e.uid)),
  13014. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  13015. audio: !1,
  13016. video: !1
  13017. },
  13018. R.remoteMuteState[e.uid].audio = !1;
  13019. var t = l({
  13020. type: "unmute-audio",
  13021. uid: e.uid
  13022. }),
  13023. n = R.remoteStreams[e.uid];
  13024. n ? (n.peerMuteAudio = !1, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13025. default.debug("Ignoring event ".concat(e.type), e)
  13026. })),
  13027. R.socket.on("mute_video", (function(e) {
  13028. r.
  13029. default.info("[".concat(R.clientId, "] rcv peer mute video: ").concat(e.uid)),
  13030. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  13031. audio: !1,
  13032. video: !1
  13033. },
  13034. R.remoteMuteState[e.uid].video = !0;
  13035. var t = l({
  13036. type: "mute-video",
  13037. uid: e.uid
  13038. }),
  13039. n = R.remoteStreams[e.uid];
  13040. n ? (n.peerMuteVideo = !0, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13041. default.debug("Ignoring event ".concat(e.type), e)
  13042. })),
  13043. R.socket.on("unmute_video", (function(e) {
  13044. r.
  13045. default.info("[".concat(R.clientId, "] rcv peer unmute video: ").concat(e.uid)),
  13046. R.remoteMuteState[e.uid] = R.remoteMuteState[e.uid] || {
  13047. audio: !1,
  13048. video: !1
  13049. },
  13050. R.remoteMuteState[e.uid].video = !1;
  13051. var t = l({
  13052. type: "unmute-video",
  13053. uid: e.uid
  13054. }),
  13055. n = R.remoteStreams[e.uid];
  13056. n ? (n.peerMuteVideo = !1, n.pc && R._adjustPCMuteStatus(n), R.dispatchEvent(t)) : r.
  13057. default.debug("Ignoring event ".concat(e.type), e)
  13058. })),
  13059. R.socket.on("on_crypt_error", (function(e) {
  13060. r.
  13061. default.warning("[".concat(R.clientId, "] stream crypt error"));
  13062. var t = l({
  13063. type: "crypt-error",
  13064. cryptType: e.crypt_type
  13065. });
  13066. R.dispatchEvent(t)
  13067. })),
  13068. R.socket.on("on_user_banned", (function(e) {
  13069. r.
  13070. default.info("[".concat(R.clientId, "] user banned uid: ").concat(e.uid, " error: ").concat(e.error_code));
  13071. var t = l({
  13072. type: "client-banned",
  13073. uid: e.uid,
  13074. attr: e.error_code
  13075. });
  13076. R.dispatchEvent(t),
  13077. a = !0
  13078. })),
  13079. R.socket.on("on_stream_fallback_update", (function(e) {
  13080. r.
  13081. default.info("[".concat(R.clientId, "] stream fallback peerId: ").concat(e.stream_id, " type: ").concat(e.stream_type));
  13082. var t = l({
  13083. type: "stream-fallback",
  13084. uid: e.stream_id,
  13085. stream: e.stream_id,
  13086. attr: e.stream_type
  13087. });
  13088. R.dispatchEvent(t)
  13089. })),
  13090. R.socket.on("stream_recover", (function(e) {
  13091. r.
  13092. default.info("[".concat(R.clientId, "] stream recover uid: ").concat(e.id, " peerId: ").concat(e.peerid, " type: ").concat(e.type));
  13093. var t = l({
  13094. type: "stream-recover",
  13095. uid: e.id,
  13096. stream: e.peerid,
  13097. attr: e.type
  13098. });
  13099. R.dispatchEvent(t)
  13100. })),
  13101. R.socket.on("on_p2p_lost", (function(e) {
  13102. r.
  13103. default.debug("[".concat(R.clientId, "] p2plost: "), e, "p2ps:", R.p2ps);
  13104. 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, {
  13105. lts: t.publishLTS,
  13106. succ: !1,
  13107. audio: t.hasAudio(),
  13108. video: t.hasVideo(),
  13109. screenshare: t.hasScreen(),
  13110. audioName: t.hasAudio() && t.audioName,
  13111. videoName: t.hasVideo() && t.videoName,
  13112. screenName: t.hasScreen() && t.screenName,
  13113. ec: n,
  13114. publishRequestid: R.publishRequestId || 0,
  13115. p2pid: R.p2ps.get(t.getId())
  13116. }), "subscribe" === e.event && s.b.subscribe(R.joinInfo.sid, {
  13117. lts: t.subscribeLTS,
  13118. succ: !1,
  13119. video: t.subscribeOptions && t.subscribeOptions.video,
  13120. audio: t.subscribeOptions && t.subscribeOptions.audio,
  13121. peerid: e.uid + "",
  13122. ec: n,
  13123. subscribeRequestid: R.subscribeRequestId.get(t.getId()) || 0,
  13124. p2pid: R.p2ps.get(t.getId())
  13125. })) : r.
  13126. default.warning("P2PLost Stream Not found", e),
  13127. r.
  13128. default.debug("[".concat(R.clientId, "] p2plost:"), e.p2pid),
  13129. (t = R.p2ps.get(e.p2pid)) && (R.p2ps.delete(e.p2pid), t.local ? R.dispatchEvent(l({
  13130. type: "pubP2PLost",
  13131. stream: t,
  13132. attr: n
  13133. })) : R.remoteStreams[t.getId()] && R.dispatchEvent(l({
  13134. type: "subP2PLost",
  13135. stream: t,
  13136. attr: n
  13137. })))
  13138. })),
  13139. R.socket.on("on_token_privilege_will_expire", (function(e) {
  13140. r.
  13141. default.debug("[".concat(R.clientId, "] Received Message onTokenPrivilegeWillExpire")),
  13142. R.dispatchEvent(l({
  13143. type: "onTokenPrivilegeWillExpire"
  13144. }))
  13145. })),
  13146. R.socket.on("on_token_privilege_did_expire", (function() {
  13147. r.
  13148. default.warning("[".concat(R.clientId, "] Received Message onTokenPrivilegeDidExpire, please get new token and join again")),
  13149. R.closeGateway(),
  13150. R.dispatchEvent(l({
  13151. type: "onTokenPrivilegeDidExpire"
  13152. }))
  13153. })),
  13154. R.socket.on("enable_local_video", (function(e) {
  13155. R.dispatchEvent(l({
  13156. type: "enable-local-video",
  13157. uid: e.uid
  13158. }))
  13159. })),
  13160. R.socket.on("disable_local_video", (function(e) {
  13161. R.dispatchEvent(l({
  13162. type: "disable-local-video",
  13163. uid: e.uid
  13164. }))
  13165. })),
  13166. R._doWithAction = function(e, t, n) {
  13167. "tryNext" === e ?
  13168. function(e, t) {
  13169. r.
  13170. default.debug("[".concat(R.clientId, "] Connect next gateway")),
  13171. R.state = S,
  13172. R.socket.close(),
  13173. O(),
  13174. R.reconnectMode = "tryNext",
  13175. R.state = _,
  13176. C(e, t)
  13177. } (t, n) : "retry" === e ?
  13178. function(e, t) {
  13179. r.
  13180. default.debug("[".concat(R.clientId, "] Reconnect gateway")),
  13181. R.state = S,
  13182. R.socket.close(),
  13183. O(),
  13184. R.reconnectMode = "retry",
  13185. R.state = _,
  13186. C(e, t)
  13187. } (t, n) : "quit" === e ? (r.
  13188. default.debug("[".concat(R.clientId, "] quit gateway")), R.state = S, R.socket.close(), O()) : "recover" === e && y()
  13189. },
  13190. R.socket.on("on_notification", (function(e) {
  13191. // Fix by Adam 修正官方没有正确发起client-banned事件
  13192. if(e.detail === "ERR_REPEAT_JOIN") {
  13193. var t = l({
  13194. type: "client-banned",
  13195. uid: e.uid,
  13196. attr: "onMultiIP"
  13197. });
  13198. R.dispatchEvent(t)
  13199. }
  13200. if (r.
  13201. default.debug("[".concat(R.clientId, "] Receive notification: "), e), "ERR_JOIN_BY_MULTI_IP" === I.GatewayErrorCode[e.code]) return R.dispatchEvent({
  13202. type: "onMultiIP",
  13203. option: e.option
  13204. });
  13205. e.detail ? R._doWithAction(Ze[I.GatewayErrorCode[e.code]]) : e.action && R._doWithAction(e.action)
  13206. })),
  13207. R.socket.on("on_user_offline", (function(e) {
  13208. var t = l({
  13209. type: "peer-leave",
  13210. uid: e.uid
  13211. });
  13212. 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)) {
  13213. r.
  13214. default.info("[".concat(R.clientId, "] closing stream on peer leave"), e.uid);
  13215. var n = R.remoteStreams[e.uid];
  13216. n.close(),
  13217. delete R.remoteStreams[e.uid],
  13218. delete R.remoteMuteState[e.uid],
  13219. s.b.onRemoveStream(R.joinInfo.sid, {
  13220. peerid: e.uint_id || e.uid,
  13221. uid: R.uid
  13222. }),
  13223. void 0 !== n.pc && (n.pc.close(), n.pc = void 0, R.p2ps.delete(n.p2pId))
  13224. }
  13225. R.timers.hasOwnProperty(e.uid) && (clearInterval(R.timers[e.uid]), clearInterval(R.timers[e.uid] + "_RelatedStats"), delete R.timers[e.uid]),
  13226. null != R.audioLevel[e.uid] && delete R.audioLevel[e.uid],
  13227. null != R.timer_counter[e.uid] && delete R.timer_counter[e.uid]
  13228. })),
  13229. R.socket.on("onUplinkStats", (function(e) {})),
  13230. R.socket.on("liveStreamingStarted", (function(e) {
  13231. var t = f({
  13232. type: "liveStreamingStarted",
  13233. url: e.url
  13234. });
  13235. R.dispatchEvent(t)
  13236. })),
  13237. R.socket.on("liveStreamingFailed", (function(e) {
  13238. var t = f({
  13239. type: "liveStreamingFailed",
  13240. url: e.url
  13241. });
  13242. R.dispatchEvent(t)
  13243. })),
  13244. R.socket.on("liveStreamingStopped", (function(e) {
  13245. var t = f({
  13246. type: "liveStreamingStopped",
  13247. url: e.url
  13248. });
  13249. R.dispatchEvent(t)
  13250. })),
  13251. R.socket.on("liveTranscodingUpdated", (function(e) {
  13252. var t = f({
  13253. type: "liveTranscodingUpdated",
  13254. reason: e.reason
  13255. });
  13256. R.dispatchEvent(t)
  13257. })),
  13258. R.socket.on("streamInjectedStatus", (function(e) {
  13259. var t = f({
  13260. type: "streamInjectedStatus",
  13261. url: e.url,
  13262. uid: e.uid,
  13263. status: e.status
  13264. });
  13265. R.dispatchEvent(t)
  13266. })),
  13267. R.socket.on("on_user_online", (function(e) {
  13268. R.joinInfo.stringUid && "string" != typeof e.uid && r.
  13269. default.error("StringUID is Mixed with UintUID"),
  13270. R.dispatchEvent({
  13271. type: "peer-online",
  13272. uid: e.uid
  13273. })
  13274. })),
  13275. R.socket.on("receive_metadata", (function(e) {
  13276. R.joinInfo.stringUid && "string" != typeof e.uid && r.
  13277. default.error("StringUID is Mixed with UintUID");
  13278. var t = decodeURIComponent(escape(window.atob(e.metadata)));
  13279. r.
  13280. default.debug("[".concat(R.clientId, "] received ").concat(e.uid, " metadata: ").concat(t)),
  13281. R.dispatchEvent({
  13282. type: "receive-metadata",
  13283. uid: e.uid,
  13284. metadata: t
  13285. })
  13286. }));
  13287. var c
  13288. }, w = function(e, t) {
  13289. if (void 0 !== R.socket) try {
  13290. R.socket.emitSimpleMessage(e, (function(e, n) {
  13291. t && t(e, n)
  13292. }))
  13293. } catch(e) {
  13294. r.
  13295. default.error("[".concat(R.clientId, "] Error in sendSimpleSdp [").concat(e, "]"))
  13296. } else r.
  13297. default.error("[".concat(R.clientId, "] Error in sendSimpleSdp [socket not ready]"))
  13298. },
  13299. D = function() {
  13300. for (var e in R.localStreams) if (void 0 !== R.localStreams[e]) {
  13301. var t = R.localStreams[e];
  13302. delete R.localStreams[e],
  13303. void 0 !== t.pc && (t.pc.close(), t.pc = void 0)
  13304. }
  13305. },
  13306. k = function() {
  13307. for (var e in R.remoteStreamsInChannel.clear(), R.remoteStreams) if (R.remoteStreams.hasOwnProperty(e)) {
  13308. var t = R.remoteStreams[e];
  13309. t.isPlaying() && t.stop(),
  13310. t.close(),
  13311. delete R.remoteStreams[e],
  13312. void 0 !== t.pc && (t.pc.close(), t.pc = void 0)
  13313. }
  13314. };
  13315. return R
  13316. },
  13317. rt = {
  13318. _gatewayClients: {},
  13319. register: function(e, t) {
  13320. if (!t.uid) {
  13321. var n = "NO_UID_PROVIDED";
  13322. return r.
  13323. default.error("[".concat(e.clientId, "] "), n, t),
  13324. n
  13325. }
  13326. if (t.cname) {
  13327. if (this._gatewayClients[t.cname] && this._gatewayClients[t.cname][t.uid] && this._gatewayClients[t.cname][t.uid] !== e) {
  13328. n = "UID_CONFLICT";
  13329. return r.
  13330. default.error("[".concat(e.clientId, "] "), n, t),
  13331. n
  13332. }
  13333. return r.
  13334. default.debug("[".concat(e.clientId, "] register client Channel"), t.cname, "Uid", t.uid),
  13335. this._gatewayClients[t.cname] || (this._gatewayClients[t.cname] = {}),
  13336. this._gatewayClients[t.cname][t.uid] = e,
  13337. null
  13338. }
  13339. var n = "NO_CHANNEL_PROVIDED";
  13340. return r.
  13341. default.error("[".concat(e.clientId, "] "), n, t),
  13342. n
  13343. },
  13344. unregister: function(e) {
  13345. var t = e && e.uid,
  13346. n = e.joinInfo && e.joinInfo.cname;
  13347. if (!t || !n) {
  13348. var a = "INVALID_GATEWAYCLIENT";
  13349. return r.
  13350. default.error("[".concat(e.clientId, "] "), a),
  13351. a
  13352. }
  13353. if (this._gatewayClients[n] && this._gatewayClients[n][t]) {
  13354. if (this._gatewayClients[n][t] !== e) {
  13355. a = "GATEWAYCLIENT_UID_CONFLICT";
  13356. return r.
  13357. default.error("[".concat(e.clientId, "] "), a),
  13358. a
  13359. }
  13360. return r.
  13361. default.debug("[".concat(e.clientId, "] unregister client "), e.uid),
  13362. delete this._gatewayClients[n][t],
  13363. null
  13364. }
  13365. var a = "GATEWEAY_CLIENT_UNREGISTERED";
  13366. r.
  13367. default.error("[".concat(e.clientId, "] "), a)
  13368. }
  13369. };
  13370. ot.DISCONNECTED = 0,
  13371. ot.CONNECTING = 1,
  13372. ot.CONNECTED = 2,
  13373. ot.DISCONNECTING = 3,
  13374. ot.connetionStateMap = {
  13375. 0 : "DISCONNECTED",
  13376. 1 : "CONNECTING",
  13377. 2 : "CONNECTED",
  13378. 3 : "DISCONNECTING"
  13379. };
  13380. var st = ot,
  13381. ct = {
  13382. 1001 : "FRAMERATE_INPUT_TOO_LOW",
  13383. 1002 : "FRAMERATE_SENT_TOO_LOW",
  13384. 1003 : "SEND_VIDEO_BITRATE_TOO_LOW",
  13385. 1005 : "RECV_VIDEO_DECODE_FAILED",
  13386. 2001 : "AUDIO_INPUT_LEVEL_TOO_LOW",
  13387. 2002 : "AUDIO_OUTPUT_LEVEL_TOO_LOW",
  13388. 2003 : "SEND_AUDIO_BITRATE_TOO_LOW",
  13389. 2005 : "RECV_AUDIO_DECODE_FAILED",
  13390. 3001 : "FRAMERATE_INPUT_TOO_LOW_RECOVER",
  13391. 3002 : "FRAMERATE_SENT_TOO_LOW_RECOVER",
  13392. 3003 : "SEND_VIDEO_BITRATE_TOO_LOW_RECOVER",
  13393. 3005 : "RECV_VIDEO_DECODE_FAILED_RECOVER",
  13394. 4001 : "AUDIO_INPUT_LEVEL_TOO_LOW_RECOVER",
  13395. 4002 : "AUDIO_OUTPUT_LEVEL_TOO_LOW_RECOVER",
  13396. 4003 : "SEND_AUDIO_BITRATE_TOO_LOW_RECOVER",
  13397. 4005 : "RECV_AUDIO_DECODE_FAILED_RECOVER"
  13398. },
  13399. dt = {
  13400. FramerateInput: 1001,
  13401. FramerateSent: 1002,
  13402. SendVideoBitrate: 1003,
  13403. VideoDecode: 1005,
  13404. AudioIntputLevel: 2001,
  13405. AudioOutputLevel: 2002,
  13406. SendAudioBitrate: 2003,
  13407. AudioDecode: 2005
  13408. },
  13409. ut = function(e) {
  13410. var t = {
  13411. remoteStreamStorage: {},
  13412. localStreamStorage: {}
  13413. };
  13414. return t.gatewayClient = e,
  13415. t.checkAudioOutputLevel = function(e) {
  13416. return ! (e && parseInt(e.audioRecvBytesDelta) > 0 && parseInt(e.audioDecodingNormalDelta) > 0 && 0 === parseInt(e.audioOutputLevel))
  13417. },
  13418. t.checkAudioIntputLevel = function(e) {
  13419. return ! e || 0 !== parseInt(e.audioInputLevel)
  13420. },
  13421. t.checkFramerateInput = function(e, t) {
  13422. if (!e || !t.attributes) return ! 0;
  13423. var n = parseInt(t.attributes.maxFrameRate),
  13424. a = parseInt(e.googFrameRateInput);
  13425. return ! n || !a || !(n > 10 && a < 5 || n < 10 && n >= 5 && a <= 1)
  13426. },
  13427. t.checkFramerateSent = function(e) {
  13428. return ! (e && parseInt(e.googFrameRateInput) > 5 && parseInt(e.googFrameRateSent) <= 1)
  13429. },
  13430. t.checkSendVideoBitrate = function(e) {
  13431. return ! e || 0 !== parseInt(e.videoSendBytesDelta)
  13432. },
  13433. t.checkSendAudioBitrate = function(e) {
  13434. return ! e || 0 !== parseInt(e.audioSendBytesDelta)
  13435. },
  13436. t.checkVideoDecode = function(e) {
  13437. return ! e || 0 === parseInt(e.videoRecvBytesDelta) || 0 !== parseInt(e.googFrameRateDecoded)
  13438. },
  13439. t.checkAudioDecode = function(e) {
  13440. return ! e || 0 === parseInt(e.audioRecvBytesDelta) || 0 !== parseInt(e.audioDecodingNormalDelta)
  13441. },
  13442. t.record = function(e, n, a, i, o) {
  13443. a[e] || (a[e] = {
  13444. isPrevNormal: !0,
  13445. record: []
  13446. });
  13447. var r = a[e],
  13448. s = t["check" + e](n, o);
  13449. if (r.record.push(s), r.record.length >= 5) {
  13450. r.isCurNormal = -1 !== r.record.indexOf(!0);
  13451. var c = dt[e];
  13452. r.isPrevNormal && !r.isCurNormal && t.gatewayClient.dispatchEvent({
  13453. type: "exception",
  13454. code: c,
  13455. msg: ct[c],
  13456. uid: i
  13457. }),
  13458. !r.isPrevNormal && r.isCurNormal && t.gatewayClient.dispatchEvent({
  13459. type: "exception",
  13460. code: c + 2e3,
  13461. msg: ct[c + 2e3],
  13462. uid: i
  13463. }),
  13464. r.isPrevNormal = r.isCurNormal,
  13465. r.record = []
  13466. }
  13467. },
  13468. t.setLocalStats = function(e) {
  13469. var n = {};
  13470. Object.keys(e).map((function(a) {
  13471. var i = e[a],
  13472. o = t.gatewayClient.localStreams[parseInt(a)],
  13473. r = t.localStreamStorage[a] || {};
  13474. 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)),
  13475. o && o.hasAudio() && (t.record("AudioIntputLevel", i.audioStats, r, a), t.record("SendAudioBitrate", i.audioStats, r, a)),
  13476. n[a] = r
  13477. })),
  13478. t.localStreamStorage = n
  13479. },
  13480. t.setRemoteStats = function(n) {
  13481. var a = {};
  13482. Object.keys(n).map((function(i) {
  13483. var o = n[i],
  13484. r = e.remoteStreams[i],
  13485. s = t.remoteStreamStorage[i] || {};
  13486. r && r.hasVideo() && r.isPlaying() && t.record("VideoDecode", o.videoStats, s, i),
  13487. r && r.hasAudio() && r.isPlaying() && (t.record("AudioOutputLevel", o.audioStats, s, i), t.record("AudioDecode", o.audioStats, s, i)),
  13488. a[i] = s
  13489. })),
  13490. t.remoteStreamStorage = a
  13491. },
  13492. t
  13493. };
  13494. function lt(e) {
  13495. if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
  13496. if (Array.isArray(e) || (e = function(e, t) {
  13497. if (!e) return;
  13498. if ("string" == typeof e) return pt(e, t);
  13499. var n = Object.prototype.toString.call(e).slice(8, -1);
  13500. "Object" === n && e.constructor && (n = e.constructor.name);
  13501. if ("Map" === n || "Set" === n) return Array.from(n);
  13502. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pt(e, t)
  13503. } (e))) {
  13504. var t = 0,
  13505. n = function() {};
  13506. return {
  13507. s: n,
  13508. n: function() {
  13509. return t >= e.length ? {
  13510. done: !0
  13511. }: {
  13512. done: !1,
  13513. value: e[t++]
  13514. }
  13515. },
  13516. e: function(e) {
  13517. throw e
  13518. },
  13519. f: n
  13520. }
  13521. }
  13522. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  13523. }
  13524. var a, i, o = !0,
  13525. r = !1;
  13526. return {
  13527. s: function() {
  13528. a = e[Symbol.iterator]()
  13529. },
  13530. n: function() {
  13531. var e = a.next();
  13532. return o = e.done,
  13533. e
  13534. },
  13535. e: function(e) {
  13536. r = !0,
  13537. i = e
  13538. },
  13539. f: function() {
  13540. try {
  13541. o || null == a.
  13542. return || a.
  13543. return ()
  13544. } finally {
  13545. if (r) throw i
  13546. }
  13547. }
  13548. }
  13549. }
  13550. function pt(e, t) { (null == t || t > e.length) && (t = e.length);
  13551. for (var n = 0,
  13552. a = new Array(t); n < t; n++) a[n] = e[n];
  13553. return a
  13554. }
  13555. var ft = new
  13556. function() {
  13557. var e = c();
  13558. return e.states = {
  13559. UNINIT: "UNINIT",
  13560. INITING: "INITING",
  13561. INITED: "INITED"
  13562. },
  13563. e.state = e.states.UNINIT,
  13564. e.type = null,
  13565. e.lastConnectedAt = null,
  13566. e.lastDisconnectedAt = null,
  13567. e.lastTypeChangedAt = null,
  13568. e.networkChangeTimer = null,
  13569. e._init = function(t, n) {
  13570. if (e.state = e.states.INITING, navigator.connection && navigator.connection.addEventListener) {
  13571. var a = e._getNetworkInfo();
  13572. e.type = a && a.type,
  13573. e.state = e.states.INITED,
  13574. t && t()
  13575. } else e.state = e.states.UNINIT,
  13576. n && n("DO_NOT_SUPPORT")
  13577. },
  13578. e._getNetworkInfo = function() {
  13579. return navigator.connection
  13580. },
  13581. e._reloadNetworkInfo = function() {
  13582. var t = e._getNetworkInfo(),
  13583. n = t && t.type || "UNSUPPORTED",
  13584. a = Date.now();
  13585. if (n !== e.type) {
  13586. e.lastTypeChangedAt = a,
  13587. "none" == n ? e.lastDisconnectedAt = a: "none" == e.type && (e.lastConnectedAt = a),
  13588. e.type = n;
  13589. var i = {
  13590. type: "networkTypeChanged",
  13591. networkType: n
  13592. };
  13593. e.dispatchEvent(i)
  13594. }
  13595. },
  13596. e.getStats = function(t, n) {
  13597. var a = {},
  13598. i = e._getNetworkInfo();
  13599. i && (a.NetworkType = i.type || "UNSUPPORTED"),
  13600. setTimeout((function() {
  13601. t(a)
  13602. }), 0)
  13603. },
  13604. e._init((function() {
  13605. navigator.connection.addEventListener("change", (function() {
  13606. e._reloadNetworkInfo()
  13607. })),
  13608. e.networkChangeTimer = setInterval((function() {
  13609. e._reloadNetworkInfo()
  13610. }), 5e3)
  13611. }), (function(e) {})),
  13612. e
  13613. },
  13614. gt = "DISCONNECTING",
  13615. mt = "DISCONNECTED",
  13616. vt = "CONNECTED",
  13617. St = "INIT",
  13618. Et = [],
  13619. _t = (setInterval((function() {
  13620. Date.now();
  13621. Et.forEach((function(e) {
  13622. for (var t = e.requests.length - 1; t >= 0; t--) {
  13623. var n = e.requests[t];
  13624. n.timeoutCnt++,
  13625. n.timeoutCnt >= 15 && (e.requests.splice(t, 1), n.promises.reject({
  13626. reason: "TIMEOUT",
  13627. code: 499
  13628. }))
  13629. }
  13630. }))
  13631. }), 1e3), 1),
  13632. ht = 1,
  13633. It = 1,
  13634. bt = function() {
  13635. var e = ee()(Z.a.mark((function e(t) {
  13636. var n, a, i, s, c, d, u;
  13637. return Z.a.wrap((function(e) {
  13638. for (;;) switch (e.prev = e.next) {
  13639. case 0:
  13640. return n = t.uid,
  13641. a = t.url,
  13642. i = t.serviceName,
  13643. s = t.sid,
  13644. c = t.appId,
  13645. d = t.cname,
  13646. u = t.timeout,
  13647. e.abrupt("return", new Promise((function(e, t) {
  13648. var l = !1,
  13649. p = new XMLHttpRequest;
  13650. p.open("POST", a, !0),
  13651. p.setRequestHeader("Content-Type", "application/json; charset=utf-8"),
  13652. p.setRequestHeader("X-Packet-Service-Type", "0"),
  13653. p.setRequestHeader("X-Packet-URI", "61"),
  13654. p.onload = function() {
  13655. if (!l) {
  13656. var n = null,
  13657. a = null;
  13658. try {
  13659. n = JSON.parse(p.responseText)
  13660. } catch(e) {
  13661. var i = "Invalid text ".concat(p.responseText);
  13662. return r.
  13663. default.error(i),
  13664. l = !0,
  13665. t(i)
  13666. }
  13667. if (n.code) {
  13668. var o = "AP_ERR_".concat(n.code);
  13669. return r.
  13670. default.error(o, n),
  13671. l = !0,
  13672. t(o)
  13673. }
  13674. try {
  13675. a = JSON.parse(n.json_body || n.json)
  13676. } catch(e) {
  13677. var s = "Invalid json_body ".concat(p.responseText);
  13678. return r.
  13679. default.error(s),
  13680. l = !0,
  13681. t(s)
  13682. }
  13683. if (200 !== a.code) {
  13684. var c = "APPCENTER_CODE_".concat(a.code);
  13685. return r.
  13686. default.error(c, a),
  13687. l = !0,
  13688. t(c)
  13689. }
  13690. if (! (a.servers && a.servers.length > 0)) {
  13691. return r.
  13692. default.error("APPCENTER_EMPTY_SERVER", a),
  13693. l = !0,
  13694. t("APPCENTER_EMPTY_SERVER")
  13695. }
  13696. return l = !0,
  13697. e(a)
  13698. }
  13699. },
  13700. p.onerror = function(e) {
  13701. var n = "AP_REUEST_".concat(e.type);
  13702. r.
  13703. default.error(n, a, e),
  13704. l || (l = !0, t(n))
  13705. },
  13706. p.ontimeout = function(e) {
  13707. r.
  13708. default.error("AP_REUEST_TIMEOUT", a, e),
  13709. l || (l = !0, t("AP_REUEST_TIMEOUT"))
  13710. },
  13711. u && (p.timeout = u),
  13712. p.send(JSON.stringify({
  13713. service_name: i,
  13714. json_body: JSON.stringify({
  13715. command: "convergeAllocateEdge",
  13716. sid: s,
  13717. uid: n + "",
  13718. appId: c,
  13719. ts: Math.floor(Date.now() / 1e3),
  13720. seq: _t++,
  13721. cname: d,
  13722. version: o.VERSION,
  13723. requestId: ht++
  13724. })
  13725. }))
  13726. })));
  13727. case 2:
  13728. case "end":
  13729. return e.stop()
  13730. }
  13731. }), e)
  13732. })));
  13733. return function(t) {
  13734. return e.apply(this, arguments)
  13735. }
  13736. } (),
  13737. Tt = function() {
  13738. var e = ee()(Z.a.mark((function e(t) {
  13739. var n, a, i, s, c, d, u, l, p, f, g, m, v;
  13740. return Z.a.wrap((function(e) {
  13741. for (;;) switch (e.prev = e.next) {
  13742. case 0:
  13743. n = t.serviceName,
  13744. a = t.sid,
  13745. i = t.appId,
  13746. s = t.cname,
  13747. c = t.uid,
  13748. d = t.proxyServer,
  13749. u = null,
  13750. e.t0 = Z.a.keys(Object(o.getParameter)("UAP_AP"));
  13751. case 3:
  13752. if ((e.t1 = e.t0()).done) {
  13753. e.next = 34;
  13754. break
  13755. }
  13756. return l = e.t1.value,
  13757. 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"),
  13758. f = void 0,
  13759. e.prev = 7,
  13760. e.next = 10,
  13761. bt({
  13762. uid: c,
  13763. url: p,
  13764. appId: i,
  13765. sid: a,
  13766. serviceName: n,
  13767. cname: s,
  13768. timeout: Object(o.getParameter)("HTTP_CONNECT_TIMEOUT")
  13769. });
  13770. case 10:
  13771. f = e.sent,
  13772. e.next = 18;
  13773. break;
  13774. case 13:
  13775. return e.prev = 13,
  13776. e.t2 = e.
  13777. catch(7),
  13778. r.
  13779. default.error(e.t2),
  13780. u = e.t2,
  13781. e.abrupt("continue", 3);
  13782. case 18:
  13783. g = Z.a.mark((function e(t) {
  13784. var a, i, o;
  13785. return Z.a.wrap((function(e) {
  13786. for (;;) switch (e.prev = e.next) {
  13787. case 0:
  13788. 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) {
  13789. e.next = 6;
  13790. break
  13791. }
  13792. return r.
  13793. default.error("Invalid server response", a),
  13794. e.abrupt("return", "continue");
  13795. case 6:
  13796. return e.prev = 6,
  13797. e.next = 9,
  13798. new Promise((function(e, t) {
  13799. var n = new WebSocket(i),
  13800. a = !1;
  13801. n.addEventListener("open", (function() {
  13802. a || (a = !0, e(n))
  13803. })),
  13804. n.addEventListener("error", (function(e) {
  13805. a || (a = !0, t(e))
  13806. }))
  13807. }));
  13808. case 9:
  13809. return (o = e.sent).workerToken = f.workerToken,
  13810. e.abrupt("return", {
  13811. v: o
  13812. });
  13813. case 14:
  13814. e.prev = 14,
  13815. e.t0 = e.
  13816. catch(6),
  13817. r.
  13818. default.error(e.t0),
  13819. u = e.t0;
  13820. case 18:
  13821. case "end":
  13822. return e.stop()
  13823. }
  13824. }), e, null, [[6, 14]])
  13825. })),
  13826. m = 0;
  13827. case 20:
  13828. if (! (m < f.servers.length)) {
  13829. e.next = 32;
  13830. break
  13831. }
  13832. return e.delegateYield(g(m), "t3", 22);
  13833. case 22:
  13834. v = e.t3,
  13835. e.t4 = v,
  13836. e.next = "continue" === e.t4 ? 26 : 27;
  13837. break;
  13838. case 26:
  13839. return e.abrupt("continue", 29);
  13840. case 27:
  13841. if ("object" !== be()(v)) {
  13842. e.next = 29;
  13843. break
  13844. }
  13845. return e.abrupt("return", v.v);
  13846. case 29:
  13847. m++,
  13848. e.next = 20;
  13849. break;
  13850. case 32:
  13851. e.next = 3;
  13852. break;
  13853. case 34:
  13854. throw u;
  13855. case 35:
  13856. case "end":
  13857. return e.stop()
  13858. }
  13859. }), e, null, [[7, 13]])
  13860. })));
  13861. return function(t) {
  13862. return e.apply(this, arguments)
  13863. }
  13864. } (),
  13865. Rt = {},
  13866. At = function(e) {
  13867. return Rt[e] ? (Rt[e] += 1, Rt[e]) : (Rt[e] = 1, Rt[e])
  13868. },
  13869. yt = {},
  13870. Ot = function(e) {
  13871. return yt[e] ? (yt[e] += 1, yt[e]) : (yt[e] = 1, yt[e])
  13872. },
  13873. Ct = function(e) {
  13874. var t = e.appId,
  13875. n = e.cname,
  13876. a = e.uid,
  13877. i = e.sid,
  13878. s = c();
  13879. return s.status = St,
  13880. s.pingpongTimer = null,
  13881. s.connection = null,
  13882. s.requests = [],
  13883. s.appId = t,
  13884. s.cname = n,
  13885. s.uid = a,
  13886. s.sid = i,
  13887. s.connection = null,
  13888. s.connectionId = It++,
  13889. s.connect = function() {
  13890. var e = ee()(Z.a.mark((function e(t) {
  13891. var n;
  13892. return Z.a.wrap((function(e) {
  13893. for (;;) switch (e.prev = e.next) {
  13894. case 0:
  13895. if (n = t.wsClient, s.status === St) {
  13896. e.next = 4;
  13897. break
  13898. }
  13899. return r.
  13900. default.debug("Ignored UapConnection.connect: ".concat(s.status)),
  13901. e.abrupt("return");
  13902. case 4:
  13903. s.connection = n,
  13904. s.status = vt,
  13905. s._flush(),
  13906. s.startPingpong(),
  13907. n.addEventListener("close", (function(e) {
  13908. if (console.log("Weboskcet closed", e), n === s.connection) {
  13909. var t = {
  13910. type: "close",
  13911. evt: e
  13912. };
  13913. s.dispatchEvent(t)
  13914. }
  13915. })),
  13916. n.addEventListener("message", (function(e) {
  13917. if (e.data) {
  13918. var t = null;
  13919. try {
  13920. t = JSON.parse(e.data)
  13921. } catch(e) {
  13922. return void r.
  13923. default.error("Invalid data from worker manager", t)
  13924. }
  13925. if (t.requestId) for (var n = s.requests.length - 1; n >= 0; n--) {
  13926. var a = s.requests[n];
  13927. if (a.reqData.requestId === t.requestId) {
  13928. s.requests.splice(n, 1),
  13929. t.code < 400 && t.code >= 200 ? a.promises.resolve(t) : a.promises.reject(t);
  13930. break
  13931. }
  13932. } else t.type = "notification",
  13933. s.dispatchEvent(t)
  13934. }
  13935. }));
  13936. case 10:
  13937. case "end":
  13938. return e.stop()
  13939. }
  13940. }), e)
  13941. })));
  13942. return function(t) {
  13943. return e.apply(this, arguments)
  13944. }
  13945. } (),
  13946. s.disconnect = ee()(Z.a.mark((function e() {
  13947. var t;
  13948. return Z.a.wrap((function(e) {
  13949. for (;;) switch (e.prev = e.next) {
  13950. case 0:
  13951. for (t in s.status = gt, clearInterval(s.pingpongTimer), s.pingpongTimer = null, s.requests) s.requests[t].promises.reject("DISCONNECTED");
  13952. return s.requests = [],
  13953. null,
  13954. s.connection && (s.connection.close(), s.connection = null),
  13955. s.status = mt,
  13956. e.abrupt("return", null);
  13957. case 9:
  13958. case "end":
  13959. return e.stop()
  13960. }
  13961. }), e)
  13962. }))),
  13963. s.request = function() {
  13964. var e = ee()(Z.a.mark((function e(t) {
  13965. var n, a, i, c;
  13966. return Z.a.wrap((function(e) {
  13967. for (;;) switch (e.prev = e.next) {
  13968. case 0:
  13969. if (n = E()({
  13970. command: "request",
  13971. sdkVersion: o.VERSION,
  13972. seq: Ot(s.sid),
  13973. appId: s.appId,
  13974. cname: s.cname,
  13975. uid: "" + s.uid,
  13976. sid: s.sid,
  13977. requestId: At(s.sid),
  13978. ts: Math.floor(Date.now() / 1e3)
  13979. },
  13980. t), "INIT" !== s.status) {
  13981. e.next = 5;
  13982. break
  13983. }
  13984. return e.abrupt("return", new Promise((function(e, t) {
  13985. var a = {
  13986. reqData: n,
  13987. stalledTs: Date.now(),
  13988. timeoutCnt: 0,
  13989. promises: {
  13990. resolve: e,
  13991. reject: t
  13992. }
  13993. };
  13994. s.requests.push(a)
  13995. })));
  13996. case 5:
  13997. if (s.connection) {
  13998. e.next = 11;
  13999. break
  14000. }
  14001. throw a = "NO_WEBSOCKET_CONNECTION",
  14002. r.
  14003. default.error(a),
  14004. new Error(a);
  14005. case 11:
  14006. if (s.status !== gt || t.clientRequest && "DestroyWorker" === t.clientRequest.command) {
  14007. e.next = 17;
  14008. break
  14009. }
  14010. throw i = "WEBSOCKET_DISCONNECTING",
  14011. r.
  14012. default.error(i),
  14013. new Error(i);
  14014. case 17:
  14015. if ("DISCONNECTED" !== s.status) {
  14016. e.next = 23;
  14017. break
  14018. }
  14019. throw c = "WEBSOCKET_DISCONNECTED",
  14020. r.
  14021. default.error(c),
  14022. new Error(c);
  14023. case 23:
  14024. return e.abrupt("return", new Promise((function(e, t) {
  14025. var a = {
  14026. reqData: n,
  14027. stalledTs: Date.now(),
  14028. timeoutCnt: 0,
  14029. promises: {
  14030. resolve: e,
  14031. reject: t
  14032. }
  14033. };
  14034. s.requests.push(a),
  14035. s._flush()
  14036. })));
  14037. case 24:
  14038. case "end":
  14039. return e.stop()
  14040. }
  14041. }), e)
  14042. })));
  14043. return function(t) {
  14044. return e.apply(this, arguments)
  14045. }
  14046. } (),
  14047. s._flush = function() {
  14048. s.connection && s.status === vt && s.requests.forEach((function(e) {
  14049. e.sentTs || (e.sentTs = Date.now(), e.reqData.clientRequest && (e.reqData.clientRequest.workerToken = s.connection.workerToken), s.connection.send(JSON.stringify(e.reqData)))
  14050. }))
  14051. },
  14052. s.startPingpong = function() {
  14053. clearInterval(s.pingpongTimer),
  14054. s.pingpongTimer = setInterval(ee()(Z.a.mark((function e() {
  14055. return Z.a.wrap((function(e) {
  14056. for (;;) switch (e.prev = e.next) {
  14057. case 0:
  14058. if (s.status !== vt || !s.connection || 1 !== s.connection.readyState) {
  14059. e.next = 9;
  14060. break
  14061. }
  14062. return e.prev = 1,
  14063. e.next = 4,
  14064. s.request({
  14065. command: "ping"
  14066. });
  14067. case 4:
  14068. e.next = 9;
  14069. break;
  14070. case 6:
  14071. e.prev = 6,
  14072. e.t0 = e.
  14073. catch(1),
  14074. r.
  14075. default.error("pingpong", e.t0);
  14076. case 9:
  14077. case "end":
  14078. return e.stop()
  14079. }
  14080. }), e, null, [[1, 6]])
  14081. }))), 6e3)
  14082. },
  14083. s._flush(),
  14084. s.startPingpong(),
  14085. Et.push(s),
  14086. s
  14087. },
  14088. Nt = function(e) {
  14089. e.disconnect();
  14090. var t = Et.find((function(t) {
  14091. return e.connectionId === t.connectionId
  14092. }));
  14093. Et.splice(t, 1)
  14094. },
  14095. wt = function(e) {
  14096. return "number" == typeof e && 0 <= e && e <= 4294967295
  14097. };
  14098. var Dt = function(e) {
  14099. var t = e;
  14100. if (Object(o.getParameter)("LIVESTREAMING_ALIGN")) switch (e) {
  14101. case 200:
  14102. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_SUCCESS;
  14103. break;
  14104. case 451:
  14105. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_ALREADY_EXISTS;
  14106. break;
  14107. case 453:
  14108. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_UNAUTHORIZED;
  14109. break;
  14110. case 470:
  14111. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_BROKEN;
  14112. break;
  14113. case 499:
  14114. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_TIMEDOUT;
  14115. break;
  14116. default:
  14117. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_FAILED
  14118. }
  14119. return t
  14120. },
  14121. kt = function(e) {
  14122. var t = e;
  14123. if (Object(o.getParameter)("LIVESTREAMING_ALIGN")) switch (e) {
  14124. case 200:
  14125. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_SUCCESS;
  14126. break;
  14127. case 404:
  14128. case 452:
  14129. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_NOT_FOUND;
  14130. break;
  14131. case 453:
  14132. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_UNAUTHORIZED;
  14133. break;
  14134. case 499:
  14135. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_TIMEDOUT;
  14136. break;
  14137. default:
  14138. t = I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_FAILED
  14139. }
  14140. return t
  14141. },
  14142. Lt = a(28),
  14143. Pt = a.n(Lt),
  14144. Mt = a(16),
  14145. Ut = "host",
  14146. xt = function(e) {
  14147. var t = {
  14148. key: void 0,
  14149. highStream: null,
  14150. lowStream: null,
  14151. lowStreamParameter: null,
  14152. isDualStream: !1,
  14153. highStreamState: 2,
  14154. lowStreamState: 2,
  14155. proxyServer: null,
  14156. turnServers: [],
  14157. useProxyServer: !1
  14158. };
  14159. t.mode = e.mode,
  14160. t.codec = e.codec,
  14161. t.clientId = Object(H.generateSessionId)().slice(0, 5),
  14162. t.uintUid = null,
  14163. t.customReportCount = 0;
  14164. e = E()({},
  14165. e);
  14166. if (t.aespassword = null, t.aesmode = "none", t.hasPublished = !1, t.getSessionId = function() {
  14167. return e.sessionId
  14168. },
  14169. t.startChannelMediaRelay = function(n, a) {
  14170. var i = s.b.reportApiInvoke(e.sessionId, {
  14171. callback: function(e) {
  14172. if (e) return a && a(e);
  14173. a && a()
  14174. },
  14175. name: "Client.startChannelMediaRelay",
  14176. options: arguments,
  14177. tag: "tracer"
  14178. });
  14179. if (! (n instanceof Ce.ChannelMediaRelayConfiguration)) throw "Configration should be instance of [ChannelMediaRelayConfiguration]";
  14180. var o = n.getSrcChannelMediaInfo(),
  14181. r = n.getDestChannelMediaInfos();
  14182. if (Object(z.isEmpty)(o)) throw "srcChannelMediaInfo should not be empty";
  14183. if (Object(z.isEmpty)(r) || 0 === r.length) throw "destChannelMediaInfos should not be empty";
  14184. if (!Object(H.is32Uint)(o.uid)) throw "Invalid uid in srcChannelMediaInfo";
  14185. if (!Object(z.isValidChannelName)(o.channelName)) throw "Invalid channelName in srcChannelMediaInfo";
  14186. if (o.token && !Object(z.isValidToken)(o.token)) throw "Invalid token in srcChannelMediaInfo";
  14187. if (r.forEach((function(e) {
  14188. if (!Object(H.is32Uint)(e.uid)) throw "Invalid uid in destChannelMediaInfo";
  14189. if (!Object(z.isValidChannelName)(e.channelName)) throw "Invalid channelName in destChannelMediaInfo";
  14190. if (e.token && !Object(z.isValidToken)(e.token)) throw "Invalid token in destChannelMediaInfo"
  14191. })), t.gatewayClient.state !== st.CONNECTED) throw "startChannelMediaRelay should be used after join";
  14192. t.gatewayClient.startChannelMediaRelay(n).then((function() {
  14193. i && i()
  14194. })).
  14195. catch((function(e) {
  14196. i && i(e)
  14197. }))
  14198. },
  14199. t.updateChannelMediaRelay = function(n, a) {
  14200. var i = s.b.reportApiInvoke(e.sessionId, {
  14201. callback: function(e) {
  14202. if (e) return a && a(e);
  14203. a && a()
  14204. },
  14205. name: "Client.updateChannelMediaRelay",
  14206. options: arguments,
  14207. tag: "tracer"
  14208. });
  14209. if (! (n instanceof Ce.ChannelMediaRelayConfiguration)) throw "Configration should be instance of [ChannelMediaRelayConfiguration]";
  14210. var o = n.getSrcChannelMediaInfo(),
  14211. r = n.getDestChannelMediaInfos();
  14212. if (Object(z.isEmpty)(o)) throw "srcChannelMediaInfo should not be empty";
  14213. if (Object(z.isEmpty)(r) || 0 === r.length) throw "destChannelMediaInfos should not be empty";
  14214. if (!Object(H.is32Uint)(o.uid)) throw "Invalid uid in srcChannelMediaInfo";
  14215. if (!Object(z.isValidChannelName)(o.channelName)) throw "Invalid channelName in srcChannelMediaInfo";
  14216. if (o.token && !Object(z.isValidToken)(o.token)) throw "Invalid token in srcChannelMediaInfo";
  14217. if (r.forEach((function(e) {
  14218. if (!Object(H.is32Uint)(e.uid)) throw "Invalid uid in destChannelMediaInfo";
  14219. if (!Object(z.isValidChannelName)(e.channelName)) throw "Invalid channelName in destChannelMediaInfo";
  14220. if (e.token && !Object(z.isValidToken)(e.token)) throw "Invalid token in destChannelMediaInfo"
  14221. })), t.gatewayClient.state !== st.CONNECTED) throw "updateChannelMediaRelay should be used after join";
  14222. t.gatewayClient.updateChannelMediaRelay(n).then((function() {
  14223. i && i()
  14224. })).
  14225. catch((function(e) {
  14226. i && i(e)
  14227. }))
  14228. },
  14229. t.stopChannelMediaRelay = function(n) {
  14230. var a = s.b.reportApiInvoke(e.sessionId, {
  14231. callback: function(e) {
  14232. if (e) return n && n(e);
  14233. n && n()
  14234. },
  14235. name: "Client.stopChannelMediaRelay",
  14236. options: arguments,
  14237. tag: "tracer"
  14238. });
  14239. t.gatewayClient.stopChannelMediaRelay().then((function() {
  14240. a && a()
  14241. })).
  14242. catch((function(e) {
  14243. a && a(e)
  14244. }))
  14245. },
  14246. t.getConnectionState = function() {
  14247. var n = s.b.reportApiInvoke(e.sessionId, {
  14248. name: "Client.getConnectionState",
  14249. options: arguments,
  14250. tag: "tracer"
  14251. }),
  14252. a = st.connetionStateMap[t.gatewayClient.state];
  14253. return n(),
  14254. a
  14255. },
  14256. t.setClientRole = function(n, a) {
  14257. var i = s.b.reportApiInvoke(e.sessionId, {
  14258. callback: a,
  14259. name: "Client.setClientRole",
  14260. options: arguments,
  14261. tag: "tracer"
  14262. });
  14263. if (Object(z.checkValidEnum)(n, "setClientRole", [Ut, "audience"]), "rtc" === t.mode) {
  14264. var o = "RTC mode can not use setClientRole";
  14265. return r.
  14266. default.warning("[".concat(t.clientId, "] ").concat(o)),
  14267. i && i(o)
  14268. }
  14269. t.gatewayClient && t.gatewayClient.state === st.CONNECTED ? ("audience" === n && (0 === this.highStreamState ? this._unpublish(this.highStream, (function() {
  14270. i && i(null, {
  14271. role: n
  14272. })
  14273. }), (function(e) {
  14274. i && i(e)
  14275. })) : t.gatewayClient.setClientRole("audience", i)), n === Ut && t.gatewayClient.setClientRole(Ut, i)) : (t.gatewayClient.role = n, i && i(null, {
  14276. role: n
  14277. }))
  14278. },
  14279. t.getGatewayInfo = function(e) {
  14280. if (t.gatewayClient.state !== st.CONNECTED) {
  14281. var n = "Client is not in connected state";
  14282. return r.
  14283. default.error("[".concat(t.clientId, "] ").concat(n)),
  14284. void e(n)
  14285. }
  14286. t.gatewayClient.getGatewayInfo((function(t) {
  14287. e(null, t)
  14288. }), e)
  14289. },
  14290. t.renewToken = function(n, a, i) {
  14291. var o = s.b.reportApiInvoke(e.sessionId, {
  14292. callback: function(e, t) {
  14293. if (e) return r.
  14294. default.error("Failed to renew token ".concat(e), t),
  14295. i && i(e);
  14296. a && a(t)
  14297. },
  14298. name: "Client.renewToken",
  14299. options: arguments,
  14300. tag: "tracer"
  14301. });
  14302. 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.");
  14303. return t.gatewayClient ? t.key ? (t.key = n, void t.gatewayClient.renewToken(n, (function(e) {
  14304. return o(null, e)
  14305. }), o)) : (r.
  14306. default.error("[".concat(t.clientId, "] renewToken should not be called before user join")), o(I.
  14307. default.INVALID_OPERATION)):
  14308. (r.
  14309. default.error("[".concat(t.clientId, "] renewToken Failed. GatewayClient not Exist")), o(I.
  14310. default.INVALID_OPERATION))
  14311. },
  14312. t.setLowStreamParameter = function(n) {
  14313. var a = s.b.reportApiInvoke(e.sessionId, {
  14314. name: "Client.setLowStreamParameter",
  14315. options: arguments,
  14316. tag: "tracer"
  14317. });
  14318. Object(z.checkValidObject)(n, "param");
  14319. var i = n.width,
  14320. o = n.height,
  14321. c = n.framerate,
  14322. d = n.bitrate;
  14323. Object(z.isEmpty)(i) || Object(z.checkValidNumber)(i, "width"),
  14324. Object(z.isEmpty)(o) || Object(z.checkValidNumber)(o, "height"),
  14325. Object(z.isEmpty)(c) || Object(z.checkValidNumber)(c, "framerate"),
  14326. Object(z.isEmpty)(d) || Object(z.checkValidNumber)(d, "bitrate", 1, 1e7),
  14327. (!i && o || i && !o) && r.
  14328. default.warning("[".concat(t.clientId, "] The width and height parameters take effect only when both are set")),
  14329. t.lowStreamParameter = n,
  14330. a()
  14331. },
  14332. t.init = function(t, n, a) {
  14333. var i = s.b.reportApiInvoke(e.sessionId, {
  14334. callback: function(e, t) {
  14335. if (e) return a && a(e);
  14336. n && n(t)
  14337. },
  14338. name: "Client.init",
  14339. options: arguments,
  14340. tag: "tracer"
  14341. });
  14342. Object(z.checkValidString)(t),
  14343. Object(g.isChromeKernel)() && Object(g.getChromeKernelVersion)() <= 48 ? a ? i(I.
  14344. default.BAD_ENVIRONMENT):
  14345. Object(H.popBanTip)():
  14346. (e.appId = t, e.sessionId = Object(H.generateSessionId)(), i())
  14347. },
  14348. t.setTurnServer = function(n) {
  14349. var a = s.b.reportApiInvoke(e.sessionId, {
  14350. name: "Client.setTurnServer",
  14351. options: arguments,
  14352. tag: "tracer"
  14353. });
  14354. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Set turn server before join channel");
  14355. if (t.useProxyServer) throw new Error("You have already set the proxy");
  14356. n instanceof Array || (n = [n]);
  14357. var i = [];
  14358. n.map((function(e, n) {
  14359. Object(z.checkValidObject)(e, "turnServer");
  14360. var a = e.turnServerURL,
  14361. o = e.username,
  14362. s = e.password,
  14363. c = e.udpport,
  14364. d = e.forceturn,
  14365. u = e.tcpport;
  14366. 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));
  14367. Object(z.isEmpty)(d) || Object(z.checkValidBoolean)(d, "forceturn");
  14368. var l = {
  14369. mode: "manual"
  14370. };
  14371. if (l.url = a, l.udpport = c, l.username = o, l.credential = s, l.forceturn = d || !1, !Object(z.isEmpty)(u)) {
  14372. if (Object(z.checkValidString)(u, "tcpport"), 0 === parseInt(u)) throw new Error("tcpport should not be ".concat(u));
  14373. l.tcpport = u,
  14374. r.
  14375. default.info("[".concat(t.clientId, "] Set turnserver[").concat(n, "] tcpurl. ").concat(l.url, ":").concat(l.tcpport))
  14376. }
  14377. r.
  14378. default.info("[".concat(t.clientId, "] Set turnserver[").concat(n, "] udpurl. ").concat(l.url, ":").concat(l.udpport, ",username: ").concat(l.username)),
  14379. i.push(l)
  14380. })),
  14381. t.turnServers = i,
  14382. a()
  14383. },
  14384. t.setProxyServer = function(n) {
  14385. var a = s.b.reportApiInvoke(e.sessionId, {
  14386. name: "Client.setProxyServer",
  14387. options: arguments,
  14388. tag: "tracer"
  14389. });
  14390. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Set proxy server before join channel");
  14391. if (!n) throw new Error("Do not set the proxyServer parameter as empty");
  14392. if (t.useProxyServer) throw new Error("You have already set the proxy");
  14393. Object(z.checkValidString)(n, "proxyServer"),
  14394. t.proxyServer = n,
  14395. s.b.setProxyServer(n),
  14396. r.
  14397. default.setProxyServer(n),
  14398. a()
  14399. },
  14400. t.startProxyServer = function(n) {
  14401. var a = s.b.reportApiInvoke(e.sessionId, {
  14402. name: "Client.startProxyServer",
  14403. options: arguments,
  14404. tag: "tracer"
  14405. });
  14406. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Start proxy server before join channel");
  14407. if (t.proxyServer) throw new Error("You have already set the proxy");
  14408. t.useProxyServer = !0,
  14409. t.proxyServerType = n || 1,
  14410. a()
  14411. },
  14412. t.stopProxyServer = function() {
  14413. var n = s.b.reportApiInvoke(e.sessionId, {
  14414. name: "Client.stopProxyServer",
  14415. options: arguments,
  14416. tag: "tracer"
  14417. });
  14418. if (t.gatewayClient && t.gatewayClient.state !== st.DISCONNECTED) throw new Error("Stop proxy server after leave channel");
  14419. s.b.setProxyServer(),
  14420. r.
  14421. default.setProxyServer(),
  14422. t.turnServers = [],
  14423. t.proxyServer = null,
  14424. t.useProxyServer = !1,
  14425. t.proxyServerType = null,
  14426. n()
  14427. },
  14428. t.setEncryptionSecret = function(n) {
  14429. var a = s.b.reportApiInvoke(e.sessionId, {
  14430. name: "Client.setEncryptionSecret",
  14431. options: arguments,
  14432. tag: "tracer"
  14433. });
  14434. Object(z.checkValidString)(n, "password"),
  14435. t.aespassword = n,
  14436. a()
  14437. },
  14438. t.setEncryptionMode = function(n) {
  14439. var a = s.b.reportApiInvoke(e.sessionId, {
  14440. name: "Client.setEncryptionMode",
  14441. options: arguments,
  14442. tag: "tracer"
  14443. });
  14444. 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"');
  14445. t.aesmode = n,
  14446. a()
  14447. },
  14448. t.configPublisher = function(n) {
  14449. var a = s.b.reportApiInvoke(e.sessionId, {
  14450. name: "Client.configPublisher",
  14451. options: arguments,
  14452. tag: "tracer"
  14453. });
  14454. Object(z.checkValidObject)(n, "config");
  14455. var i = n.width,
  14456. o = n.height,
  14457. r = n.framerate,
  14458. c = n.bitrate,
  14459. d = n.publisherUrl;
  14460. Object(z.checkValidNumber)(i, "width"),
  14461. Object(z.checkValidNumber)(o, "height"),
  14462. Object(z.checkValidNumber)(r, "framerate"),
  14463. Object(z.checkValidNumber)(c, "bitrate", 1, 1e7),
  14464. d && Object(z.checkValidString)(d, "publisherUrl"),
  14465. t.gatewayClient.configPublisher(n),
  14466. a()
  14467. },
  14468. t.enableDualStream = function(n, a) {
  14469. var i = s.b.reportApiInvoke(e.sessionId, {
  14470. callback: function(e, t) {
  14471. if (e) return a && a(e);
  14472. n && n(t)
  14473. },
  14474. name: "Client.enableDualStream",
  14475. options: arguments,
  14476. tag: "tracer"
  14477. });
  14478. return "iOS" === Object(g.getBrowserOS)() ? (s.b.streamSwitch(e.sessionId, {
  14479. lts: (new Date).getTime(),
  14480. isdual: !0,
  14481. succ: !1
  14482. }), i(I.
  14483. default.IOS_NOT_SUPPORT)):
  14484. Object(g.isWeChatBrowser)() ? (s.b.streamSwitch(e.sessionId, {
  14485. lts: (new Date).getTime(),
  14486. isdual: !0,
  14487. succ: !1
  14488. }), i(I.
  14489. default.WECHAT_NOT_SUPPORT)):
  14490. (s.b.streamSwitch(e.sessionId, {
  14491. lts: (new Date).getTime(),
  14492. isdual: !0,
  14493. succ: !0
  14494. }), t.isDualStream = !0, t.highStream && (t.highStream.isDualStream = !0), void(0 === t.highStreamState ? t._publishLowStream((function(e) {
  14495. return i(null, e)
  14496. }), (function(e) {
  14497. r.
  14498. default.warning("[".concat(t.clientId, "]"), e),
  14499. i(I.
  14500. default.ENABLE_DUALSTREAM_FAILED)
  14501. })):
  14502. 1 === t.highStreamState ? i(I.
  14503. default.STILL_ON_PUBLISHING):
  14504. i(null)))
  14505. },
  14506. t.disableDualStream = function(n, a) {
  14507. var i = s.b.reportApiInvoke(e.sessionId, {
  14508. callback: function(e, t) {
  14509. if (e) return a && a(e);
  14510. n && n(t)
  14511. },
  14512. name: "Client.disableDualStream",
  14513. options: arguments,
  14514. tag: "tracer"
  14515. });
  14516. s.b.streamSwitch(e.sessionId, {
  14517. lts: (new Date).getTime(),
  14518. isdual: !1,
  14519. succ: !0
  14520. }),
  14521. t.isDualStream = !1,
  14522. t.highStream && (t.highStream.isDualStream = !1),
  14523. 0 === t.highStreamState ? t._unpublishLowStream((function() {
  14524. t.highStream.lowStream = null,
  14525. i()
  14526. }), (function(e) {
  14527. r.
  14528. default.warning("[".concat(t.clientId, "]"), e),
  14529. i(I.
  14530. default.DISABLE_DUALSTREAM_FAILED)
  14531. })):
  14532. 1 === t.highStreamState ? i(I.
  14533. default.STILL_ON_PUBLISHING):
  14534. i()
  14535. },
  14536. t._getLowStream = function(e, n) {
  14537. t.lowStream ? e(t.lowStream) : t._createLowStream((function(n) {
  14538. t.lowStream = n,
  14539. e(t.lowStream)
  14540. }), n)
  14541. },
  14542. t._createLowStream = function(e, n) {
  14543. if (t.highStream && t.highStream.stream) {
  14544. var a = E()({},
  14545. t.highStream.params);
  14546. if (a.streamID += 1, a.audio = !1, a.video) if (t.highStream.stream.getVideoTracks()[0]) {
  14547. var i = new ye(a);
  14548. if (i.isLowStream = !0, i.streamId = t.highStream.getId() + 1, t.lowStreamParameter) {
  14549. var o = E()({},
  14550. t.lowStreamParameter);
  14551. o.width && o.height || (o.width = 160, o.height = 120),
  14552. o.framerate = o.framerate || 15,
  14553. o.bitrate = o.bitrate || 50,
  14554. i.setVideoProfileCustomPlus(o)
  14555. } else i.setVideoProfileCustom(function(e) {
  14556. var t;
  14557. switch (e) {
  14558. case "120p":
  14559. case "120p_1":
  14560. t = ["120p_1", "120p_1", "120p_1"];
  14561. break;
  14562. case "120p_3":
  14563. t = ["120p_3", "120p_3", "120p_3"];
  14564. break;
  14565. case "180p":
  14566. case "180p_1":
  14567. t = ["90p_1", "90p_1", "180p_1"];
  14568. break;
  14569. case "180p_3":
  14570. t = ["120p_3", "120p_3", "180p_3"];
  14571. break;
  14572. case "180p_4":
  14573. t = ["120p_1", "120p_1", "180p_4"];
  14574. break;
  14575. case "240p":
  14576. case "240p_1":
  14577. t = ["120p_1", "120p_1", "240p_1"];
  14578. break;
  14579. case "240p_3":
  14580. t = ["120p_3", "120p_3", "240p_3"];
  14581. break;
  14582. case "240p_4":
  14583. t = ["120p_4", "120p_4", "240p_4"];
  14584. break;
  14585. case "360p":
  14586. case "360p_1":
  14587. case "360p_4":
  14588. case "360p_9":
  14589. case "360p_10":
  14590. case "360p_11":
  14591. t = ["90p_1", "90p_1", "360p_1"];
  14592. break;
  14593. case "360p_3":
  14594. case "360p_6":
  14595. t = ["120p_3", "120p_3", "360p_3"];
  14596. break;
  14597. case "360p_7":
  14598. case "360p_8":
  14599. t = ["120p_1", "120p_1", "360p_7"];
  14600. break;
  14601. case "480p":
  14602. case "480p_1":
  14603. case "480p_2":
  14604. case "480p_4":
  14605. case "480p_10":
  14606. t = ["120p_1", "120p_1", "480p_1"];
  14607. break;
  14608. case "480p_3":
  14609. case "480p_6":
  14610. t = ["120p_3", "120p_3", "480p_3"];
  14611. break;
  14612. case "480p_8":
  14613. case "480p_9":
  14614. t = ["120p_4", "120p_4", "480p_8"];
  14615. break;
  14616. case "720p":
  14617. case "720p_1":
  14618. case "720p_2":
  14619. case "720p_3":
  14620. t = ["90p_1", "90p_1", "720p_1"];
  14621. break;
  14622. case "720p_5":
  14623. case "720p_6":
  14624. t = ["120p_1", "120p_1", "720p_5"];
  14625. break;
  14626. case "1080p":
  14627. case "1080p_1":
  14628. case "1080p_2":
  14629. case "1080p_3":
  14630. case "1080p_5":
  14631. t = ["90p_1", "90p_1", "1080p_1"];
  14632. break;
  14633. case "1440p":
  14634. case "1440p_1":
  14635. case "1440p_2":
  14636. t = ["90p_1", "90p_1", "1440p_1"];
  14637. break;
  14638. case "4k":
  14639. case "4k_1":
  14640. case "4k_3":
  14641. t = ["90p_1", "90p_1", "4k_1"];
  14642. break;
  14643. default:
  14644. t = ["120p_1", "120p_1", "360p_7"]
  14645. }
  14646. 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]
  14647. } (t.highStream.profile));
  14648. try {
  14649. console.log(i.videoConstraint);
  14650. var r = Pt()(t.highStream, {
  14651. width: i.videoConstraint.width.ideal,
  14652. height: i.videoConstraint.height.ideal,
  14653. framerate: i.videoConstraint.frameRate.max
  14654. });
  14655. return i.stream = r,
  14656. t.highStream.lowStream = i,
  14657. t.highStream.userMuteVideo && i.muteVideo(),
  14658. e && e(i)
  14659. } catch(e) {
  14660. return n && n(e)
  14661. }
  14662. } else n && n(I.
  14663. default.HIGH_STREAM_NOT_VIDEO_TRACE);
  14664. else n && n(I.
  14665. default.HIGH_STREAM_NOT_VIDEO_TRACE)
  14666. } else n && n(I.
  14667. default.HIGH_STREAM_NOT_VIDEO_TRACE)
  14668. },
  14669. t._publishLowStream = function(e, n) {
  14670. return 2 !== t.lowStreamState ? n && n(I.
  14671. default.LOW_STREAM_ALREADY_PUBLISHED):
  14672. t.highStream && t.highStream.hasScreen() ? n && n(I.
  14673. default.SHARING_SCREEN_NOT_SUPPORT):
  14674. void t._getLowStream((function(a) {
  14675. t.lowStreamState = 1,
  14676. t.gatewayClient.publish(a, {
  14677. streamType: 1
  14678. },
  14679. (function() {
  14680. t.lowStreamState = 0,
  14681. e && e()
  14682. }), (function(e) {
  14683. 1 === t.lowStreamState && (t.lowStreamState = 2),
  14684. r.
  14685. default.debug("[".concat(t.clientId, "] publish low stream failed")),
  14686. n && n(e)
  14687. }))
  14688. }), n)
  14689. },
  14690. t._unpublishLowStream = function(e, n) {
  14691. if (0 !== t.lowStreamState) return n && n(I.
  14692. default.LOW_STREAM_NOT_YET_PUBLISHED);
  14693. t.lowStream && (t.gatewayClient.unpublish(t.lowStream, {
  14694. streamType: 1
  14695. },
  14696. (function() {}), (function(e) {
  14697. r.
  14698. default.debug("[".concat(t.clientId, "] unpublish low stream failed")),
  14699. n && n(e)
  14700. })), t.lowStream.close(), t.lowStream = null, t.lowStreamState = 2, e && e())
  14701. },
  14702. t.join = function(n, a, i, o, c) {
  14703. var d = s.b.reportApiInvoke(e.sessionId, {
  14704. callback: function(e, t) {
  14705. if (e) return c && c(e);
  14706. o && o(t)
  14707. },
  14708. name: "Client.join",
  14709. options: arguments,
  14710. tag: "tracer"
  14711. });
  14712. if (n && !Object(z.isValidToken)(n)) return r.
  14713. default.warning("[".concat(t.clientId, "] Param channelKey should be string")),
  14714. d(I.
  14715. default.INVALID_PARAMETER);
  14716. if (!Object(z.isValidChannelName)(a)) return r.
  14717. default.error("Invalid Channel Name ".concat(a)),
  14718. r.
  14719. default.warning("[".concat(t.clientId, "] The length must be within 64 bytes. The supported characters: a-z,A-Z,0-9,space,!, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~, ,")),
  14720. d(I.
  14721. default.INVALID_PARAMETER);
  14722. if ("string" == typeof a && "" === a) return r.
  14723. default.warning("[".concat(t.clientId, "] Param channel should not be empty")),
  14724. d(I.
  14725. default.INVALID_PARAMETER);
  14726. if (i && !Object(H.is32Uint)(i) && !Object(z.isValidString)(i, 1, 255)) return r.
  14727. default.error("Invalid UID ".concat(i, " ").concat(be()(i))),
  14728. r.
  14729. default.warning("[".concat(t.clientId, "] [String uid] Length of the string: [1,255]. ASCII characters only. [Number uid] The value range is [0,10000]")),
  14730. d(I.
  14731. default.INVALID_PARAMETER);
  14732. if ("string" == typeof i && 0 == i.length) return r.
  14733. default.warning("[".concat(t.clientId, "] String uid should not be empty")),
  14734. d(I.
  14735. default.INVALID_PARAMETER);
  14736. if ("string" == typeof i && i.length > 256) return r.
  14737. default.warning("[".concat(t.clientId, "] Length of string uid should be less than 255")),
  14738. d(I.
  14739. default.INVALID_PARAMETER);
  14740. t.highStream = null,
  14741. t.lowStream = null,
  14742. t.lowStreamParameter = null,
  14743. t.isDualStream = !1,
  14744. t.highStreamState = 2,
  14745. t.lowStreamState = 2;
  14746. var u = Date.now(),
  14747. l = setTimeout((function() {
  14748. if (1 != t.gatewayClient.hasJoined) {
  14749. r.
  14750. default.debug("[".concat(t.clientId, "] The time to join the channel is greater than 5 seconds "));
  14751. var n = Date.now();
  14752. s.b.joinChannelTimeOut({
  14753. lts: n,
  14754. sid: e.sessionId,
  14755. cname: a,
  14756. cid: p.cid,
  14757. uid: p.uid || ("string" == typeof i ? void 0 : i),
  14758. elapse: n - u,
  14759. timeout: 5
  14760. })
  14761. }
  14762. }), 5e3),
  14763. p = {
  14764. clientId: t.clientId,
  14765. appId: e.appId,
  14766. sid: e.sessionId,
  14767. cname: a,
  14768. uid: i,
  14769. turnServers: t.turnServers.concat(),
  14770. proxyServer: t.proxyServer,
  14771. token: n || e.appId,
  14772. useProxyServer: t.useProxyServer,
  14773. proxyServerType: t.proxyServerType
  14774. };
  14775. 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, {
  14776. aespassword: t.aespassword,
  14777. aesmode: t.aesmode
  14778. }), s.b.sessionInit(e.sessionId, {
  14779. lts: (new Date).getTime(),
  14780. cname: a,
  14781. appid: e.appId,
  14782. mode: e.mode,
  14783. succ: !0
  14784. }), t.onSuccess = function(e) {
  14785. clearTimeout(l),
  14786. t.rtcStatsCollector.startNetworkQualityTimer(),
  14787. t.onSuccess = null,
  14788. d(null, e)
  14789. },
  14790. t.onFailure = function(e) {
  14791. return d(e)
  14792. },
  14793. t.channel = a, t.gatewayClient.state !== st.DISCONNECTED) return r.
  14794. default.error("[".concat(t.clientId, "] Client already in connecting/connected state")),
  14795. d(I.
  14796. default.INVALID_OPERATION),
  14797. void s.b.joinGateway(e.sessionId, {
  14798. lts: Date.now(),
  14799. succ: !1,
  14800. ec: I.
  14801. default.INVALID_OPERATION,
  14802. addr: null
  14803. });
  14804. t.gatewayClient.state = st.CONNECTING;
  14805. var f = function(i, o) {
  14806. r.
  14807. default.info("[".concat(t.clientId, "] Joining channel: ").concat(a)),
  14808. t.gatewayClient.dispatchEvent({
  14809. type: "config-distribute",
  14810. config: o,
  14811. joinInfo: p
  14812. }),
  14813. t.key = n || e.appId,
  14814. p.cid = i.cid,
  14815. p.uid || (p.uid = i.uid),
  14816. p.vid = i.vid,
  14817. p.clientId = t.clientId,
  14818. p.apResponse = i.res,
  14819. i.uni_lbs_ip && i.uni_lbs_ip[1] && (p.uni_lbs_ip = i.uni_lbs_ip[1]),
  14820. p.gatewayAddr = i.gateway_addr,
  14821. t.joinInfo = p,
  14822. t.gatewayClient.join(p, t.key, (function(e) {
  14823. r.
  14824. default.info("[".concat(t.clientId, "] Join channel ").concat(a, " success, join with uid: ").concat(e, ".")),
  14825. t.onSuccess = null,
  14826. t.rtcStatsCollector.startNetworkQualityTimer(),
  14827. d(null, e)
  14828. }), (function(e) {
  14829. return d(e)
  14830. }))
  14831. };
  14832. p.stringUid && !p.uid ? (t.userAccountReq && !t.userAccountReq.isFinished() && t.userAccountReq.cancel(), t.userAccountReq = Qe(p, t.gatewayClient), t.userAccountReq.then((function(e) {
  14833. r.
  14834. default.debug("getUserAccount Success ".concat(e.url, " ").concat(p.stringUid, " => ").concat(e.uid)),
  14835. p.uid = e.uid,
  14836. ze(p, f, (function(e) {
  14837. return d(e)
  14838. }))
  14839. })).
  14840. catch((function(e) {
  14841. r.
  14842. default.error("getUserAccount rejected", e),
  14843. d(e)
  14844. }))) : ze(p, f, (function(e) {
  14845. return d(e)
  14846. }))
  14847. },
  14848. t.renewChannelKey = function(n, a, i) {
  14849. var o = s.b.reportApiInvoke(e.sessionId, {
  14850. callback: function(e, t) {
  14851. if (e) return i && i(e);
  14852. a && a(t)
  14853. },
  14854. name: "Client.renewChannelKey",
  14855. options: arguments,
  14856. tag: "tracer"
  14857. });
  14858. Object(z.checkValidString)(n, "key", 1, 2047),
  14859. void 0 === t.key ? (r.
  14860. default.error("[".concat(t.clientId, "] renewChannelKey should not be called before user join")), o(I.
  14861. default.INVALID_OPERATION)):
  14862. (t.key = n, t.gatewayClient.joinInfo.token = n, t.gatewayClient.key = n, t.gatewayClient.recover(), o())
  14863. },
  14864. t.leave = function(n, a) {
  14865. t.gatewayClient.isFirstSuccess = !0,
  14866. t.gatewayClient.hasInvokeLeave = !0;
  14867. var i = !1,
  14868. c = s.b.reportApiInvoke(e.sessionId, {
  14869. callback: function(e, i) {
  14870. if (e) return a && a(e);
  14871. t.gatewayClient.reconnectingCS = !1,
  14872. t.gatewayClient.state = st.DISCONNECTED,
  14873. clearTimeout(Ye(t.clientId)),
  14874. t._renewSession(),
  14875. t.rtcStatsCollector.clearNetworkQualityTimer(),
  14876. n && n(i)
  14877. },
  14878. name: "Client.leave",
  14879. options: arguments,
  14880. tag: "tracer"
  14881. });
  14882. r.
  14883. default.info("[".concat(t.clientId, "] Leaving channel")),
  14884. t.userAccountReq && !t.userAccountReq.isFinished() && (t.userAccountReq.cancel(), t.gatewayClient.state === st.CONNECTING && (t.gatewayClient.state = st.DISCONNECTED)),
  14885. t.gatewayClient.leave((function(e) {
  14886. i = !0,
  14887. c(null, e)
  14888. }), c),
  14889. setTimeout((function() {
  14890. i || (t.gatewayClient.socket && (t.gatewayClient.socket.close(), t.gatewayClient.socket = null), t.gatewayClient.state = st.DISCONNECTED, c(null, "LEAVE_MSG_TIMEOUT"))
  14891. }), Object(o.getParameter)("LEAVE_MSG_TIMEOUT"))
  14892. },
  14893. t._renewSession = function() {
  14894. var n = Object(H.generateSessionId)();
  14895. if (r.
  14896. 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) {
  14897. var i = t.gatewayClient.localStreams[a];
  14898. i && (i.sid = n)
  14899. }
  14900. },
  14901. t._publish = function(n, a, i, s) {
  14902. if (2 !== t.highStreamState) return r.
  14903. default.warning("[".concat(t.clientId, "] Can't publish stream when stream already publish ").concat(n.getId())),
  14904. i && i(I.
  14905. default.STREAM_ALREADY_PUBLISHED);
  14906. 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");
  14907. r.
  14908. default.info("[".concat(t.clientId, "] Publishing stream, uid ").concat(n.getId())),
  14909. t.highStream = n,
  14910. t.highStreamState = 1,
  14911. t.highStream.streamId = t.joinInfo.stringUid || t.joinInfo.uid,
  14912. t.hasPublished = !1;
  14913. var c = function(n, a, i) {
  14914. t.gatewayClient.publish(n, {
  14915. streamType: 0
  14916. },
  14917. (function() {
  14918. n.sid = e.sessionId,
  14919. t.highStreamState = 0,
  14920. r.
  14921. default.info("[".concat(t.clientId, "] Publish success, uid: ").concat(n.getId())),
  14922. t.highStream && (t.highStream.isDualStream = t.isDualStream),
  14923. t.isDualStream ? t._publishLowStream((function() {
  14924. a && a()
  14925. }), (function(e) {
  14926. r.
  14927. default.warning("[".concat(t.clientId, "] "), e),
  14928. he.replaceWithCanvasTrack(n).then((function() {
  14929. a && a()
  14930. }))
  14931. })) : he.replaceWithCanvasTrack(n).then((function() {
  14932. a && a()
  14933. }))
  14934. }), i)
  14935. };
  14936. "audience" !== t.gatewayClient.role || "live" !== t.mode || s ? c(n, a, i) : t.gatewayClient.setClientRole(Ut, (function(e) {
  14937. if (e) return i && i(e);
  14938. c(n, a, i)
  14939. }))
  14940. },
  14941. t._unpublish = function(e, n, a, i) {
  14942. if (0 !== t.highStreamState) return r.
  14943. default.warning("[".concat(t.clientId, "] Can't unpublish stream when stream not publish")),
  14944. a && a(I.
  14945. default.STREAM_NOT_YET_PUBLISHED);
  14946. r.
  14947. default.info("[".concat(t.clientId, "] Unpublish stream, uid ").concat(e.getId()));
  14948. var o = function(e, n, a) {
  14949. t.isDualStream && t.lowStream && t._unpublishLowStream(null, a),
  14950. t.gatewayClient.unpublish(e, {
  14951. streamType: 0
  14952. },
  14953. (function() {
  14954. t.highStreamState = 2,
  14955. r.
  14956. default.info("[".concat(t.clientId, "] Unpublish stream success, uid: ").concat(e.getId())),
  14957. n && n()
  14958. }), (function(n) {
  14959. r.
  14960. default.info("[".concat(t.clientId, "] Unpublish stream fail, uid: ").concat(e.getId())),
  14961. a && a(n)
  14962. }))
  14963. };
  14964. t.gatewayClient.role !== Ut || "live" !== t.mode || i ? o(e, n, a) : t.gatewayClient.setClientRole("audience", (function(t) {
  14965. if (t) return a && a(t);
  14966. o(e, n, a)
  14967. }))
  14968. },
  14969. t.publish = function(n, a) {
  14970. var i = s.b.reportApiInvoke(e.sessionId, {
  14971. callback: function(e, n) {
  14972. if (e) return 1 === t.highStreamState && (t.highStreamState = 2),
  14973. a && a(e)
  14974. },
  14975. name: "Client.publish",
  14976. tag: "tracer",
  14977. options: {
  14978. stream: "too long to show",
  14979. onFailure: !!a
  14980. }
  14981. });
  14982. 2 === t.highStreamState ? n._hasVideoTracks() || n._hasAudioTracks() ? (t.gatewayClient.publishRequestId = Object(H.generateId)(), t._publish(n, (function(e) {
  14983. return i(null, e)
  14984. }), (function(e) {
  14985. return i(e)
  14986. }))) : i(I.
  14987. default.NO_TRACK_IN_STREAM):
  14988. i(I.
  14989. default.STREAM_ALREADY_PUBLISHED)
  14990. },
  14991. t.unpublish = function(n, a, i) {
  14992. var o = s.b.reportApiInvoke(e.sessionId, {
  14993. callback: function(e, t) {
  14994. if (e) return a && a(e);
  14995. i && i(t)
  14996. },
  14997. name: "Client.unpublish",
  14998. tag: "tracer",
  14999. options: {
  15000. stream: "too long to show",
  15001. onFailure: !!a
  15002. }
  15003. });
  15004. 0 === t.highStreamState ? (t.gatewayClient.publishRequestId = null, t._unpublish(n, (function(e) {
  15005. return o(null, e)
  15006. }), (function(e) {
  15007. return o(e)
  15008. }))) : o(I.
  15009. default.STREAM_NOT_YET_PUBLISHED)
  15010. },
  15011. t.subscribe = function(n, a, i) {
  15012. var o = s.b.reportApiInvoke(e.sessionId, {
  15013. callback: function(e, t) {
  15014. if (e) return i && i(e)
  15015. },
  15016. name: "Client.subscribe",
  15017. tag: "tracer",
  15018. options: {
  15019. stream: "too long to show",
  15020. options: a,
  15021. onFailure: !!i
  15022. }
  15023. });
  15024. "function" == typeof a && (i = a, a = null),
  15025. Object(z.checkValidObject)(n, "stream"),
  15026. 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"));
  15027. var c = {
  15028. video: !0,
  15029. audio: !0
  15030. };
  15031. if (!Object(z.isEmpty)(a)) {
  15032. if (Object(g.isSafari)() && (!a.video || !a.audio)) {
  15033. var d = "SAFARI_NOT_SUPPORTED_FOR_TRACK_SUBSCRIPTION";
  15034. return r.
  15035. default.error("[".concat(t.clientId, "] "), d),
  15036. void o(d)
  15037. }
  15038. 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) {
  15039. d = "INVALID_PARAMETER ".concat(JSON.stringify(a));
  15040. return r.
  15041. default.error("[".concat(t.clientId, "] "), d),
  15042. void o(d)
  15043. }
  15044. }
  15045. n.subscribeOptions ? (E()(n.subscribeOptions, c, a), t.gatewayClient.subscribeChange(n, (function(e) {
  15046. return o(null, e)
  15047. }), o)) : (t.gatewayClient.subscribeRequestId.set(n.getId(), Object(H.generateId)()), n.subscribeOptions = E()({},
  15048. c, a), t.gatewayClient.subscribe(n, (function(e) {
  15049. return o(null, e)
  15050. }), o))
  15051. },
  15052. t.unsubscribe = function(n, a) {
  15053. var i = s.b.reportApiInvoke(e.sessionId, {
  15054. callback: function(e, t) {
  15055. if (e) return a && a(e)
  15056. },
  15057. name: "Client.unsubscribe",
  15058. tag: "tracer",
  15059. options: {
  15060. stream: "too long to show",
  15061. onFailure: !!a
  15062. }
  15063. });
  15064. r.
  15065. default.info("[".concat(t.clientId, "] Unsubscribe stream, uid: ").concat(n.getId())),
  15066. t.gatewayClient.subscribeRequestId.delete(n.getId()),
  15067. t.gatewayClient.unsubscribe(n, (function(e) {
  15068. return i(null, e)
  15069. }), i)
  15070. },
  15071. t.setRemoteVideoStreamType = function(n, a) {
  15072. var i = s.b.reportApiInvoke(e.sessionId, {
  15073. name: "Client.setRemoteVideoStreamType",
  15074. tag: "tracer",
  15075. options: {
  15076. stream: "too long to show",
  15077. streamType: a
  15078. }
  15079. });
  15080. Object(z.checkValidEnum)(a, "streamType", [0, 1]),
  15081. t.gatewayClient.setRemoteVideoStreamType(n, a),
  15082. i()
  15083. },
  15084. t.setStreamFallbackOption = function(n, a) {
  15085. var i = s.b.reportApiInvoke(e.sessionId, {
  15086. name: "Client.setStreamFallbackOption",
  15087. tag: "tracer",
  15088. options: {
  15089. stream: "too long to show",
  15090. fallbackType: a
  15091. }
  15092. });
  15093. Object(z.checkValidEnum)(a, "fallbackType", [0, 1, 2]),
  15094. t.gatewayClient.setStreamFallbackOption(n, a),
  15095. i()
  15096. },
  15097. t.enableAudioVolumeIndicator = function(n, a) {
  15098. var i = s.b.reportApiInvoke(e.sessionId, {
  15099. name: "Client.enableAudioVolumeIndicator",
  15100. options: arguments,
  15101. tag: "tracer"
  15102. });
  15103. n = n || 2e3,
  15104. a = a || 3,
  15105. Object(z.checkValidNumber)(a, "smooth", 1, 100),
  15106. Object(z.checkValidNumber)(n, "interval", 50, 1e5),
  15107. t.audioVolumeIndication = t.audioVolumeIndication || {
  15108. enabled: !0
  15109. },
  15110. t.audioVolumeIndication.interval = n,
  15111. t.audioVolumeIndication.smooth = a,
  15112. t.audioVolumeIndication = {
  15113. interval: n,
  15114. smooth: a
  15115. },
  15116. r.
  15117. default.info("[".concat(t.clientId, "] enableAudioVolumeIndicator interval ").concat(n, " smooth ").concat(a)),
  15118. t.gatewayClient.enableAudioVolumeIndicator(n, a),
  15119. i()
  15120. },
  15121. t.getNetworkStats = function(e, n) {
  15122. return r.
  15123. default.deprecate("[".concat(t.clientId, "] client.getNetworkStats is deprecated. Use client.getTransportStats instead.")),
  15124. ft.getStats(e, n)
  15125. },
  15126. t.getSystemStats = function(e, t) {
  15127. return v.getStats(e, t)
  15128. },
  15129. t.getRecordingDevices = function(e, t) {
  15130. return K.getRecordingDevices(e, t)
  15131. },
  15132. t.getPlayoutDevices = function(e, t) {
  15133. return K.getPlayoutDevices(e, t)
  15134. },
  15135. t.getCameras = function(e, t) {
  15136. return K.getCameras(e, t)
  15137. },
  15138. t.getRemoteAudioStats = function(e, n) {
  15139. return t.rtcStatsCollector.getRemoteAudioStats(e, n)
  15140. },
  15141. t.getLocalAudioStats = function(e, n) {
  15142. return t.rtcStatsCollector.getLocalAudioStats(e, n)
  15143. },
  15144. t.getRemoteVideoStats = function(e, n) {
  15145. return t.rtcStatsCollector.getRemoteVideoStats(e, n)
  15146. },
  15147. t.getLocalVideoStats = function(e, n) {
  15148. return t.rtcStatsCollector.getLocalVideoStats(e, n)
  15149. },
  15150. t._getRemoteVideoQualityStats = function(e, n) {
  15151. return t.rtcStatsCollector.getRemoteVideoQualityStats(e, n)
  15152. },
  15153. t._getRemoteAudioQualityStats = function(e, n) {
  15154. return t.rtcStatsCollector.getRemoteAudioQualityStats(e, n)
  15155. },
  15156. t.getTransportStats = function(e, n) {
  15157. return t.rtcStatsCollector.getTransportStats((function(t) {
  15158. return ft.getStats((function(n) {
  15159. var a = E()({},
  15160. t, n);
  15161. e && e(a)
  15162. }), n)
  15163. }), n)
  15164. },
  15165. t.getSessionStats = function(e, n) {
  15166. return t.rtcStatsCollector.getSessionStats(e, n)
  15167. },
  15168. t.onNetworkQuality = function() {
  15169. return t.rtcStatsCollector.onNetworkQuality(onSuccess, onFailure)
  15170. },
  15171. t.sendMetadata = function(n, a) {
  15172. var i = s.b.reportApiInvoke(e.sessionId, {
  15173. name: "Client.sendMetadata",
  15174. tag: "tracer",
  15175. callback: function(e) {
  15176. if (e) return a && a(e);
  15177. a && a()
  15178. }
  15179. });
  15180. t.gatewayClient.sendMetadata(n, i)
  15181. },
  15182. t.sendCustomReportMessage = function(n, a, i, c, d, u) {
  15183. Object(o.getParameter)("CR") ? t.customReportCount > Object(o.getParameter)("CRL") ? u && u("REPORT_LIMITED") : (t.gatewayClient.hasJoined || (r.
  15184. default.WARNING("Should invoke Client.sendCustomReportMessage after join"), u && u("REPORT_BEFORE_JOINED")), t.customReportTimer || (t.customReportTimer = setInterval((function() {
  15185. t.customReportCount = 0
  15186. }), 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, {
  15187. reportId: n,
  15188. category: a,
  15189. event: i,
  15190. label: c,
  15191. value: d,
  15192. lts: Date.now()
  15193. },
  15194. (function(e) {
  15195. e ? u && u("REPORT_FAILED") : u && u()
  15196. }))) : u && u("REPORT_FORBIDDEN")
  15197. },
  15198. e.clientId = t.clientId, t.gatewayClient = st(e), t.listenerLoggerTimer = null, t.listenerLoggerCache = [], t.on = function(e, n) {
  15199. t.gatewayClient.on(e, n),
  15200. t.listenerLoggerCache.push("".concat(e).concat(n.name ? ":" + n.name: "")),
  15201. t.listenerLoggerTimer ? clearTimeout(t.listenerLoggerTimer) : r.
  15202. default.info("[".concat(t.clientId, "] Adding event handler on ").concat(e)),
  15203. t.listenerLoggerTimer = setTimeout((function() {
  15204. t.listenerLoggerCache.length && (t.listenerLoggerTimer = null, r.
  15205. default.info("[".concat(t.clientId, "] Added event handler on ").concat(t.listenerLoggerCache.join(", "))), t.listenerLoggerCache = [])
  15206. }), 0)
  15207. },
  15208. t.off = function(e, n) {
  15209. r.
  15210. default.info("remove event handler from [".concat(e, "]")),
  15211. t.gatewayClient.removeEventListener(e, n)
  15212. },
  15213. t.rtcStatsCollector = function(e) {
  15214. var t = c();
  15215. return t.gatewayClient = e,
  15216. t.exceptionMonitor = new ut(e),
  15217. t.localStats = {},
  15218. t.remoteStats = {},
  15219. t.session = {
  15220. sendBytes: 0,
  15221. recvBytes: 0,
  15222. WSSendBytes: 0,
  15223. WSSendBytesDelta: 0,
  15224. WSRecvBytes: 0,
  15225. WSRecvBytesDelta: 0,
  15226. HTTPSendBytes: 0,
  15227. HTTPSendBytesDelta: 0,
  15228. HTTPRecvBytes: 0,
  15229. HTTPRecvBytesDelta: 0
  15230. },
  15231. t.getRemoteAudioStats = function(e) {
  15232. var n = t.gatewayClient.traffic_stats,
  15233. a = {};
  15234. for (var i in t.remoteStats) {
  15235. var o = {},
  15236. r = t.remoteStats[i];
  15237. 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) {
  15238. var s = n.peer_delay.find((function(e) {
  15239. return e.peer_uid == i
  15240. }));
  15241. if (s) {
  15242. var c = s.peer_publish_audio_duration + (Date.now() - n.timestamp);
  15243. q(o, "AudioPublishDuration", c)
  15244. } else q(o, "AudioPublishDuration", -1)
  15245. }
  15246. a[i] = o
  15247. }
  15248. e && e(a)
  15249. },
  15250. t.getLocalAudioStats = function(e) {
  15251. var n = {};
  15252. for (var a in t.localStats) {
  15253. var i = {},
  15254. o = t.localStats[a];
  15255. q(i, "RecordingLevel", o.audioStats && o.audioStats.audioInputLevel),
  15256. q(i, "SendLevel", o.audioStats && o.audioStats.totalAudioEnergy),
  15257. q(i, "SamplingRate", o.audioStats && o.audioStats.totalSamplesDuration),
  15258. q(i, "SendBitrate", o.audioSendBitrate),
  15259. q(i, "CodecType", o.audioStats && o.audioStats.googCodecName),
  15260. q(i, "MuteState", o.audioDisabled),
  15261. q(i, "audioSendPacketsLost", o.audioStats && o.audioStats.packetsLost);
  15262. var r = t.gatewayClient.localStreams[a];
  15263. r && r.isPlaying() && q(i, "MuteState", r.userMuteAudio ? "1": "0"),
  15264. n[a] = i
  15265. }
  15266. e && e(n)
  15267. },
  15268. t.getRemoteVideoStats = function(e) {
  15269. var n = t.gatewayClient.traffic_stats,
  15270. a = {};
  15271. for (var i in t.remoteStats) {
  15272. var o = {},
  15273. r = t.remoteStats[i];
  15274. 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) {
  15275. var s = n.peer_delay.find((function(e) {
  15276. return e.peer_uid == i
  15277. }));
  15278. if (s) {
  15279. var c = s.peer_publish_video_duration + (Date.now() - n.timestamp);
  15280. q(o, "VideoPublishDuration", c)
  15281. } else q(o, "VideoPublishDuration", -1)
  15282. }
  15283. a[i] = o
  15284. }
  15285. e && e(a)
  15286. },
  15287. t.getLocalVideoStats = function(e) {
  15288. var n = {};
  15289. for (var a in t.localStats) {
  15290. var i = {},
  15291. o = t.localStats[a];
  15292. q(i, "TargetSendBitrate", o.videoTargetSendBitrate),
  15293. q(i, "SendFrameRate", o.videoStats && o.videoStats.googFrameRateSent),
  15294. q(i, "SendBitrate", o.videoSendBitrate),
  15295. q(i, "SendResolutionWidth", o.videoStats && o.videoStats.googFrameWidthSent),
  15296. q(i, "SendResolutionHeight", o.videoStats && o.videoStats.googFrameHeightSent),
  15297. q(i, "CaptureResolutionWidth", o.videoStats && o.videoStats.googFrameWidthInput),
  15298. q(i, "CaptureResolutionHeight", o.videoStats && o.videoStats.googFrameHeightInput),
  15299. q(i, "EncodeDelay", o.videoStats && o.videoStats.googAvgEncodeMs),
  15300. q(i, "MuteState", o.videoDisabled),
  15301. q(i, "TotalFreezeTime", o.videoStats && o.videoStats.videoTotalFreezeTime),
  15302. q(i, "TotalDuration", o.videoStats && o.videoStats.videoTotalPlayDuration),
  15303. q(i, "CaptureFrameRate", o.videoStats && o.videoStats.googFrameRateSent),
  15304. q(i, "videoSendPacketsLost", o.videoStats && o.videoStats.packetsLost),
  15305. o.videoStats && !o.videoStats.googFrameWidthInput && q(i, "CaptureResolutionWidth", o.videoStats && o.videoStats.renderLocalWidth),
  15306. o.videoStats && !o.videoStats.googFrameHeightInput && q(i, "CaptureResolutionHeight", o.videoStats && o.videoStats.renderLocalHeight),
  15307. n[a] = i
  15308. }
  15309. e && e(n)
  15310. },
  15311. t.getRemoteVideoQualityStats = function(e) {
  15312. var n = {};
  15313. for (var a in t.remoteStats) {
  15314. var i = {},
  15315. o = t.remoteStats[a];
  15316. q(i, "videoReceiveDelay", o.videoStats && o.videoStats.googCurrentDelayMs),
  15317. q(i, "VideoFreezeRate", o.videoStats && o.videoStats.videoFreezeRate),
  15318. q(i, "FirstFrameTime", o.firstFrameTime),
  15319. n[a] = i
  15320. }
  15321. e && e(n)
  15322. },
  15323. t.getRemoteAudioQualityStats = function(e) {
  15324. var n = {};
  15325. for (var a in t.remoteStats) {
  15326. var i = {},
  15327. o = t.remoteStats[a];
  15328. q(i, "audioReceiveDelay", o.audioStats && o.audioStats.googCurrentDelayMs),
  15329. q(i, "AudioFreezeRate", o.videoStats && o.videoStats.videoFreezeRate),
  15330. n[a] = i
  15331. }
  15332. e && e(n)
  15333. },
  15334. t.getTransportStats = function(e) {
  15335. var n = {},
  15336. a = {},
  15337. i = t.gatewayClient.traffic_stats,
  15338. o = i.peer_delay;
  15339. if (q(n, "OutgoingAvailableBandwidth", t.gatewayClient.OutgoingAvailableBandwidth / 1e3), q(n, "RTT", i && 2 * i.access_delay), o) {
  15340. var r, s = lt(o);
  15341. try {
  15342. for (s.s(); ! (r = s.n()).done;) {
  15343. var c = r.value;
  15344. c.downlink_estimate_bandwidth && (a[c.peer_uid] = c.downlink_estimate_bandwidth / 1e3 + "")
  15345. }
  15346. } catch(e) {
  15347. s.e(e)
  15348. } finally {
  15349. s.f()
  15350. }
  15351. }
  15352. n.IncomingAvailableBandwidth = a,
  15353. e && e(n)
  15354. },
  15355. t.getSessionStats = function(e) {
  15356. var n = {},
  15357. a = t.gatewayClient.traffic_stats,
  15358. i = t.gatewayClient.socket,
  15359. o = 0,
  15360. r = 0;
  15361. for (var s in t.remoteStats) { (c = t.remoteStats[s]) && c.videoStats && c.videoStats.videoRecvBytesDelta && (r += parseInt(c.videoStats.videoRecvBytesDelta)),
  15362. c && c.audioStats && c.audioStats.audioRecvBytesDelta && (r += parseInt(c.audioStats.audioRecvBytesDelta))
  15363. }
  15364. for (var s in t.localStats) {
  15365. var c; (c = t.localStats[s]) && c.videoStats && c.videoStats.videoSendBytesDelta && (o += parseInt(c.videoStats.videoSendBytesDelta)),
  15366. c && c.audioStats && c.audioStats.audioSendBytesDelta && (o += parseInt(c.audioStats.audioSendBytesDelta))
  15367. }
  15368. var d = o + t.session.WSSendBytesDelta + t.session.HTTPSendBytesDelta,
  15369. u = r + t.session.WSRecvBytesDelta + t.session.HTTPRecvBytesDelta,
  15370. l = t.session.sendBytes + Object(Ue.getHTTPSendBytes)(),
  15371. p = t.session.recvBytes + Object(Ue.getHTTPRecvBytes)();
  15372. t.gatewayClient.socket && t.gatewayClient.socket.state === t.gatewayClient.CONNECTED && (l += i.getSendBytes(), p += i.getRecvBytes());
  15373. var f = 1;
  15374. a.peer_delay && (f = a.peer_delay.length, f += 1),
  15375. q(n, "Duration", i.getDuration()),
  15376. q(n, "UserCount", f),
  15377. q(n, "SendBytes", l),
  15378. q(n, "RecvBytes", p),
  15379. q(n, "SendBitrate", 8 * d / 1e3),
  15380. q(n, "RecvBitrate", 8 * u / 1e3),
  15381. e && e(n)
  15382. },
  15383. t.isLocalVideoFreeze = function(e, t) {
  15384. var n = 0,
  15385. a = 0;
  15386. if (!e || !t) return ! 1;
  15387. if (Object(g.isChrome)() || Object(g.isOpera)()) n = e.googFrameRateInput,
  15388. a = e.googFrameRateSent;
  15389. else if (Object(g.isSafari)()) n = parseInt(e.framerateMean),
  15390. a = parseInt(e.framesEncoded) - parseInt(t.framesEncoded);
  15391. else {
  15392. if (!Object(g.isFireFox)()) return ! 1;
  15393. n = parseInt(e.framerateMean),
  15394. a = parseInt(e.framesEncoded) - parseInt(t.framesEncoded)
  15395. }
  15396. return n > 5 && a < 3
  15397. },
  15398. t.isRemoteVideoFreeze = function(e, t) {
  15399. var n = 0,
  15400. a = 0;
  15401. if (!e || !t) return ! 1;
  15402. if (Object(g.isChrome)() || Object(g.isOpera)()) n = e.googFrameRateReceived,
  15403. a = e.googFrameRateDecoded;
  15404. else if (Object(g.isSafari)()) n = e.framerateMean,
  15405. a = parseInt(e.framesDecoded) - parseInt(t.framesDecoded);
  15406. else {
  15407. if (!Object(g.isFireFox)()) return ! 1;
  15408. n = parseInt(e.framesReceived) - parseInt(t.framesReceived),
  15409. a = parseInt(e.framesDecoded) - parseInt(t.framesDecoded)
  15410. }
  15411. return n > 5 && n < 10 && a < 3 || (n > 10 && n < 20 && a < 4 || n > 20 && a < 5)
  15412. },
  15413. t.isAudioFreeze = function(e) {
  15414. if (Object(g.isChrome)() && e) {
  15415. if (e.googDecodingPLC && e.googDecodingPLCCNG && e.googDecodingCTN) return (parseInt(e.googDecodingPLC) + parseInt(e.googDecodingPLCCNG)) / parseInt(e.googDecodingCTN) > .2
  15416. } else if ((Object(g.isSafari)() || Object(g.isFireFox)()) && e.packetsLost && e.packetsReceived) return parseInt(e.packetsLost) / (parseInt(e.packetsLost) + parseInt(e.packetsReceived)) > .2;
  15417. return ! 1
  15418. },
  15419. t.isAudioDecodeFailed = function(e) {
  15420. return !! ((Object(g.isChrome)() || Object(g.isOpera)()) && e && parseInt(e.bytesReceived) > 0 && 0 === parseInt(e.googDecodingNormal))
  15421. },
  15422. t.startNetworkQualityTimer = function() {
  15423. t.clearNetworkQualityTimer(),
  15424. t.networkQualityTimer = setInterval((function() {
  15425. if (t.gatewayClient.state !== st.CONNECTED) t.gatewayClient.dispatchEvent({
  15426. type: "network-quality",
  15427. uplinkNetworkQuality: 0,
  15428. downlinkNetworkQuality: 0
  15429. });
  15430. else {
  15431. var e = t.gatewayClient.traffic_stats;
  15432. t.gatewayClient.dispatchEvent({
  15433. type: "network-quality",
  15434. uplinkNetworkQuality: t.networkQualityTrans(e.uplink_network_quality),
  15435. downlinkNetworkQuality: t.networkQualityTrans(e.downlink_network_quality)
  15436. })
  15437. }
  15438. }), 2e3)
  15439. },
  15440. t.clearNetworkQualityTimer = function() {
  15441. t.networkQualityTimer && clearInterval(t.networkQualityTimer)
  15442. },
  15443. t.networkQualityTrans = function(e) {
  15444. 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
  15445. },
  15446. t.getStatsTimer = setInterval((function() {
  15447. var e = t.gatewayClient.traffic_stats,
  15448. n = Date.now();
  15449. t.gatewayClient.dispatchEvent({
  15450. type: "_testException"
  15451. }),
  15452. Object.keys(t.localStats).length && t.exceptionMonitor.setLocalStats(t.localStats),
  15453. Object.keys(t.remoteStats).length && t.exceptionMonitor.setRemoteStats(t.remoteStats);
  15454. var a = {};
  15455. Object.keys(t.gatewayClient.remoteStreams).forEach((function(i) {
  15456. var o = t.gatewayClient.remoteStreams[i],
  15457. r = t.remoteStats[i],
  15458. s = {
  15459. id: i,
  15460. updatedAt: n
  15461. };
  15462. a[i] = s,
  15463. s.firstFrameTime = o.firstFrameTime,
  15464. 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);
  15465. var c = e && e.peer_delay && e.peer_delay.find((function(e) {
  15466. return e.peer_uid == i
  15467. }));
  15468. c && (s.peer_delay = c),
  15469. 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({
  15470. type: "streamTypeChange",
  15471. uid: i,
  15472. streamType: c.stream_type
  15473. }), o.pc && "established" == o.pc.state && o.pc.getStats((function(e) {
  15474. if (s.pcStats = e, s.audioStats = e.find((function(e) {
  15475. return "audio" == e.mediaType && (e.id.indexOf("_recv") > -1 || e.id.toLowerCase().indexOf("inbound") > -1)
  15476. })), s.videoStats = e.find((function(e) {
  15477. return "video" == e.mediaType && (e.id.indexOf("_recv") > -1 || e.id.toLowerCase().indexOf("inbound") > -1)
  15478. })), r && r.audioStats && s.audioStats) {
  15479. var n = parseInt(s.audioStats.bytesReceived) - parseInt(r.audioStats.bytesReceived),
  15480. a = parseInt(s.audioStats.googDecodingNormal) - parseInt(r.audioStats.googDecodingNormal);
  15481. if (s.audioStats.audioRecvBytesDelta = n, s.audioStats.audioDecodingNormalDelta = a, t.session.recvBytes += n, isFinite(n) && s.audioStats.timestamp) {
  15482. var i = s.audioStats.timestamp.getTime() - r.audioStats.timestamp.getTime();
  15483. s.audioRecvBitrate = Math.floor(8 * n / i)
  15484. }
  15485. t.isAudioFreeze(s.audioStats) && s.audioTotalPlayDuration > 10 && (s.audioTotalFreezeTime++, s.isAudioFreeze = !0),
  15486. t.isAudioDecodeFailed(s.audioStats) && s.audioTotalPlayDuration > 10 && (s.isAudioDecodeFailed = !0),
  15487. s.audioStats.audioTotalFreezeTime = s.audioTotalFreezeTime,
  15488. s.audioStats.audioTotalPlayDuration = s.audioTotalPlayDuration,
  15489. s.audioStats.audioFreezeRate = Math.ceil(100 * s.audioTotalFreezeTime / s.audioTotalPlayDuration)
  15490. }
  15491. if (r && r.videoStats && s.videoStats) {
  15492. var c = parseInt(s.videoStats.bytesReceived) - parseInt(r.videoStats.bytesReceived);
  15493. if (s.videoStats.videoRecvBytesDelta = c, t.session.recvBytes += c, isFinite(c) && s.videoStats.timestamp) {
  15494. i = s.videoStats.timestamp.getTime() - r.videoStats.timestamp.getTime();
  15495. s.videoRecvBitrate = Math.floor(8 * c / i)
  15496. }
  15497. t.isRemoteVideoFreeze(s.videoStats, r.videoStats) && (s.videoTotalFreezeTime++, s.isVideoFreeze = !0),
  15498. s.videoStats.videoTotalFreezeTime = s.videoTotalFreezeTime,
  15499. s.videoStats.videoTotalPlayDuration = s.videoTotalPlayDuration,
  15500. s.videoStats.videoFreezeRate = Math.ceil(100 * s.videoTotalFreezeTime / s.videoTotalPlayDuration),
  15501. 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)
  15502. }
  15503. })))
  15504. })),
  15505. t.remoteStats = a;
  15506. var i = {};
  15507. if (Object.keys(t.gatewayClient.localStreams).forEach((function(e) {
  15508. var a = t.gatewayClient.localStreams[e],
  15509. o = t.localStats[e],
  15510. r = {
  15511. id: e,
  15512. updatedAt: n
  15513. };
  15514. i[e] = r,
  15515. o ? (r.videoTotalPlayDuration = o.videoTotalPlayDuration + 1, r.videoTotalFreezeTime = o.videoTotalFreezeTime, r.isVideoFreeze = !1) : (r.videoTotalPlayDuration = 1, r.videoTotalFreezeTime = 0),
  15516. 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) {
  15517. if (r.pcStats = e.reverse(), r.audioStats = e.find((function(e) {
  15518. return "audio" == e.mediaType && (e.id.indexOf("_send") > -1 || e.id.toLowerCase().indexOf("outbound") > -1)
  15519. })), r.videoStats = e.find((function(e) {
  15520. return "video" == e.mediaType && (e.id.indexOf("_send") > -1 || e.id.toLowerCase().indexOf("outbound") > -1)
  15521. })), r.audioStats && o && o.audioStats) {
  15522. var n = parseInt(r.audioStats.bytesSent) - parseInt(o.audioStats.bytesSent);
  15523. if (r.audioStats.audioSendBytesDelta = n, t.session.sendBytes += n, isFinite(n) && r.audioStats.timestamp) {
  15524. var i = r.audioStats.timestamp.getTime() - o.audioStats.timestamp.getTime();
  15525. r.audioSendBitrate = Math.floor(8 * n / i)
  15526. }
  15527. }
  15528. if (r.videoStats && o && o.videoStats) {
  15529. var s = parseInt(r.videoStats.bytesSent) - parseInt(o.videoStats.bytesSent);
  15530. if (r.videoStats.videoSendBytesDelta = s, t.session.sendBytes += s, isFinite(s) && r.videoStats.timestamp) {
  15531. i = r.videoStats.timestamp.getTime() - o.videoStats.timestamp.getTime();
  15532. r.videoSendBitrate = Math.floor(8 * s / i)
  15533. }
  15534. t.isLocalVideoFreeze(r.videoStats, o.videoStats) && (r.videoTotalFreezeTime++, r.isVideoFreeze = !0),
  15535. r.videoStats.videoTotalFreezeTime = r.videoTotalFreezeTime,
  15536. r.videoStats.videoTotalPlayDuration = r.videoTotalPlayDuration,
  15537. r.videoStats.videoFreezeRate = Math.ceil(100 * r.videoTotalFreezeTime / r.videoTotalPlayDuration),
  15538. r.videoStats.renderLocalWidth = a.videoWidth || r.videoStats.googFrameWidthSent,
  15539. r.videoStats.renderLocalHeight = a.videoHeight || r.videoStats.googFrameHeightSent
  15540. }
  15541. })))
  15542. })), 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) {
  15543. var o = t.gatewayClient.socket;
  15544. t.session.WSSendBytesDelta = o.getSendBytes() - t.session.WSSendBytes,
  15545. t.session.WSSendBytes = o.getSendBytes(),
  15546. t.session.WSRecvBytesDelta = o.getRecvBytes() - t.session.WSRecvBytes,
  15547. t.session.WSRecvBytes = o.getRecvBytes()
  15548. }
  15549. }), 1e3),
  15550. t.gatewayClient.on("join", (function() {
  15551. t.session = {
  15552. sendBytes: 0,
  15553. recvBytes: 0,
  15554. WSSendBytes: 0,
  15555. WSSendBytesDelta: 0,
  15556. WSRecvBytes: 0,
  15557. WSRecvBytesDelta: 0,
  15558. HTTPSendBytes: 0,
  15559. HTTPSendBytesDelta: 0,
  15560. HTTPRecvBytes: 0,
  15561. HTTPRecvBytesDelta: 0
  15562. }
  15563. })),
  15564. t
  15565. } (t.gatewayClient), t.configDistributManager = function(e) {
  15566. var t = {};
  15567. return t.client = e,
  15568. t.client.gatewayClient && t.client.gatewayClient.on("config-distribute", (function(n) {
  15569. var a = n.joinInfo,
  15570. i = n.config;
  15571. if (i) {
  15572. Object(z.isEmpty)(i.uploadLog) || (Object(o.setParameter)("UPLOAD_LOG", i.uploadLog), s.b.reportApiInvoke(a.sid, {
  15573. name: "_configDistribute",
  15574. options: {
  15575. feature: "uploadLog",
  15576. value: i.uploadLog
  15577. }
  15578. })()),
  15579. Object(z.isEmpty)(i.dualStream) || (e.isDualStream = i.dualStream, s.b.reportApiInvoke(a.sid, {
  15580. name: "_configDistribute",
  15581. options: {
  15582. feature: "dualStream",
  15583. value: i.dualStream
  15584. }
  15585. })()),
  15586. Object(z.isEmpty)(i.streamFallbackOption) || t.client.gatewayClient && t.client.gatewayClient.on("stream-subscribed", (function(e) {
  15587. var n = e.stream;
  15588. n ? (t.client.gatewayClient.setStreamFallbackOption(n, i.streamFallbackOption), s.b.reportApiInvoke(a.sid, {
  15589. name: "_configDistribute",
  15590. options: {
  15591. feature: "streamFallbackOption",
  15592. value: i.streamFallbackOption,
  15593. streamId: n.getId()
  15594. }
  15595. })()) : s.b.reportApiInvoke(a.sid, {
  15596. name: "_configDistribute",
  15597. options: {
  15598. feature: "streamFallbackOption",
  15599. value: i.streamFallbackOption,
  15600. streamId: n.getId(),
  15601. err: "invalid stream"
  15602. }
  15603. })()
  15604. }));
  15605. try {
  15606. r.
  15607. default.debug("[".concat(e.clientId, "] setParameter in distribution: ").concat(JSON.stringify(i))),
  15608. Object.keys(i).map((function(e) {
  15609. return Object(o.setParameter)(e, i[e])
  15610. }))
  15611. } catch(t) {
  15612. r.
  15613. default.debug("[".concat(e.clientId, "] setParameter in distribution failed: ").concat(JSON.stringify(i)))
  15614. }
  15615. }
  15616. })),
  15617. t
  15618. } (t),
  15619. function(e, t) {
  15620. var n = arguments;
  15621. e.liveStreaming = c(),
  15622. e.liveStreaming.connections = {
  15623. inject_streaming: null,
  15624. mix_streaming: null,
  15625. raw_streaming: null
  15626. },
  15627. e.liveStreaming.connectionTypes = {
  15628. inject_streaming: "pull",
  15629. mix_streaming: "push",
  15630. raw_streaming: "push"
  15631. },
  15632. e.liveStreaming.pushStates = {},
  15633. e.liveStreaming.pullStates = {},
  15634. e.gatewayClient.addEventListener("join", (function(t) {
  15635. e.liveStreaming.resumeStates("pull")
  15636. })),
  15637. e.gatewayClient.addEventListener("stream-unpublished", (function(t) {
  15638. if (t.options && 0 === t.options.streamType) for (var n in e.liveStreaming.pushStates) {
  15639. var a = e.liveStreaming.pushStates[n];
  15640. a.url && e._stopLiveStreaming(a.url, a.transcodingEnabled, !0)
  15641. }
  15642. })),
  15643. e.gatewayClient.addEventListener("stream-published", (function(t) {
  15644. e.liveStreaming.resumeStates("push")
  15645. })),
  15646. e.liveStreaming.connect = function() {
  15647. var n = ee()(Z.a.mark((function n(a) {
  15648. var i, o;
  15649. return Z.a.wrap((function(n) {
  15650. for (;;) switch (n.prev = n.next) {
  15651. case 0:
  15652. if (e.joinInfo && e.joinInfo.uid && parseInt(e.joinInfo.vid, 10)) {
  15653. n.next = 3;
  15654. break
  15655. }
  15656. throw "CLIENT_NOT_JOINED",
  15657. new Error("CLIENT_NOT_JOINED");
  15658. case 3:
  15659. return i = new Ct({
  15660. appId: t.appId,
  15661. cname: e.channel,
  15662. sid: t.sessionId,
  15663. uid: e.joinInfo.uid
  15664. }),
  15665. e.liveStreaming.connections[a] = i,
  15666. n.next = 7,
  15667. Tt({
  15668. proxyServer: e.useProxyServer && e.joinInfo && e.joinInfo.proxyServer,
  15669. appId: t.appId,
  15670. cname: e.channel,
  15671. serviceName: a,
  15672. sid: t.sessionId,
  15673. uid: e.joinInfo.uid
  15674. });
  15675. case 7:
  15676. return o = n.sent,
  15677. n.next = 10,
  15678. i.connect({
  15679. wsClient: o
  15680. });
  15681. case 10:
  15682. return i.on("notification", (function(t) {
  15683. if (t.serviceName = a, e.liveStreaming.dispatchEvent(t), 503 === t.code);
  15684. else switch (t.serviceName) {
  15685. case "inject_streaming":
  15686. var n = {
  15687. reason: t && t.reason,
  15688. status: Dt(t && t.code),
  15689. type: "streamInjectedStatus",
  15690. uid: t && t.serverStatus && t.serverStatus.inject_uid,
  15691. url: t && t.serverStatus && t.serverStatus.url
  15692. };
  15693. e.gatewayClient.dispatchEvent(n);
  15694. break;
  15695. case "raw_streaming":
  15696. case "mix_streaming":
  15697. var i = {
  15698. reason: t && t.reason,
  15699. status: t && t.code,
  15700. type: t && 200 === t.code ? "liveStreamingStarted": "liveStreamingFailed",
  15701. uid: t && t.serverStatus && t.uid,
  15702. url: t && t.serverStatus && t.serverStatus.url
  15703. };
  15704. e.gatewayClient.dispatchEvent(i)
  15705. }
  15706. })),
  15707. i.on("close", (function(t) {
  15708. Nt(i),
  15709. r.
  15710. default.debug("Reconnect ".concat(a)),
  15711. e.liveStreaming.connect(a).
  15712. catch((function(t) {
  15713. e.liveStreaming.connections[a] = null,
  15714. e.gatewayClient.dispatchEvent({
  15715. type: "".concat(a.replace("_", "-"), "-disconnected")
  15716. })
  15717. }))
  15718. })),
  15719. r.
  15720. default.debug("".concat(a, " connected")),
  15721. n.abrupt("return", i);
  15722. case 14:
  15723. case "end":
  15724. return n.stop()
  15725. }
  15726. }), n)
  15727. })));
  15728. return function(e) {
  15729. return n.apply(this, arguments)
  15730. }
  15731. } (),
  15732. e.liveStreaming.disconnect = function() {
  15733. var t = ee()(Z.a.mark((function t(n) {
  15734. var a, i;
  15735. return Z.a.wrap((function(t) {
  15736. for (;;) switch (t.prev = t.next) {
  15737. case 0:
  15738. t.t0 = Z.a.keys(e.liveStreaming.connections);
  15739. case 1:
  15740. if ((t.t1 = t.t0()).done) {
  15741. t.next = 13;
  15742. break
  15743. }
  15744. if (a = t.t1.value, !e.liveStreaming.connections.hasOwnProperty(a)) {
  15745. t.next = 11;
  15746. break
  15747. }
  15748. if (! (i = e.liveStreaming.connections[a]) || n && n !== a) {
  15749. t.next = 11;
  15750. break
  15751. }
  15752. return r.
  15753. default.info("Disconnecting liveStreaming ".concat(a)),
  15754. t.next = 9,
  15755. i.disconnect();
  15756. case 9:
  15757. t.sent,
  15758. e.liveStreaming.connections[a] = null;
  15759. case 11:
  15760. t.next = 1;
  15761. break;
  15762. case 13:
  15763. case "end":
  15764. return t.stop()
  15765. }
  15766. }), t)
  15767. })));
  15768. return function(e) {
  15769. return t.apply(this, arguments)
  15770. }
  15771. } (),
  15772. e.liveStreaming.resumeStates = function() {
  15773. var t = ee()(Z.a.mark((function t(n) {
  15774. var a, i, o, s, c, d, u, l;
  15775. return Z.a.wrap((function(t) {
  15776. for (;;) switch (t.prev = t.next) {
  15777. case 0:
  15778. t.t0 = Z.a.keys(e.liveStreaming.connections);
  15779. case 1:
  15780. if ((t.t1 = t.t0()).done) {
  15781. t.next = 8;
  15782. break
  15783. }
  15784. if (a = t.t1.value, !n || e.liveStreaming.connectionTypes[a] === n) {
  15785. t.next = 5;
  15786. break
  15787. }
  15788. return t.abrupt("continue", 1);
  15789. case 5:
  15790. e.liveStreaming.connections.hasOwnProperty(a) && (i = e.liveStreaming.connections[a]) && (r.
  15791. default.info("LiveStreaming closing connection ".concat(a)), i.disconnect(), e.liveStreaming.connections[a] = null),
  15792. t.next = 1;
  15793. break;
  15794. case 8:
  15795. t.t2 = Z.a.keys(e.liveStreaming.pushStates);
  15796. case 9:
  15797. if ((t.t3 = t.t2()).done) {
  15798. t.next = 37;
  15799. break
  15800. }
  15801. if (o = t.t3.value, !n || "push" === n) {
  15802. t.next = 13;
  15803. break
  15804. }
  15805. return t.abrupt("continue", 9);
  15806. case 13:
  15807. if (!e.liveStreaming.pushStates.hasOwnProperty(o)) {
  15808. t.next = 35;
  15809. break
  15810. }
  15811. if (s = e.liveStreaming.pushStates[o], "audience" !== e.gatewayClient.role) {
  15812. t.next = 19;
  15813. break
  15814. }
  15815. r.
  15816. default.warning("Cannot resume LiveStreaming in audience mode. ".concat(s.url), s),
  15817. t.next = 35;
  15818. break;
  15819. case 19:
  15820. if (!s) {
  15821. t.next = 35;
  15822. break
  15823. }
  15824. return r.
  15825. default.debug("Resuming LiveStreaming ".concat(s.url), s),
  15826. t.prev = 21,
  15827. t.next = 24,
  15828. e._startLiveStreaming(s.url, s.transcodingEnabled);
  15829. case 24:
  15830. c = t.sent,
  15831. r.
  15832. default.debug("Resumed LiveStreaming ".concat(s.url, ": ").concat(c.reason)),
  15833. t.next = 35;
  15834. break;
  15835. case 28:
  15836. if (t.prev = 28, t.t4 = t.
  15837. catch(21), 454 !== t.t4.code) {
  15838. t.next = 34;
  15839. break
  15840. }
  15841. r.
  15842. default.debug("Resumed LiveStreaming ".concat(s.url, ": ").concat(t.t4.reason)),
  15843. t.next = 35;
  15844. break;
  15845. case 34:
  15846. throw t.t4;
  15847. case 35:
  15848. t.next = 9;
  15849. break;
  15850. case 37:
  15851. t.t5 = Z.a.keys(e.liveStreaming.pullStates);
  15852. case 38:
  15853. if ((t.t6 = t.t5()).done) {
  15854. t.next = 62;
  15855. break
  15856. }
  15857. if (d = t.t6.value, !n || "pull" === n) {
  15858. t.next = 42;
  15859. break
  15860. }
  15861. return t.abrupt("continue", 38);
  15862. case 42:
  15863. if (!e.liveStreaming.pullStates.hasOwnProperty(d)) {
  15864. t.next = 60;
  15865. break
  15866. }
  15867. if (u = e.liveStreaming.pullStates[d], "audience" !== e.gatewayClient.role) {
  15868. t.next = 48;
  15869. break
  15870. }
  15871. r.
  15872. default.warning("Cannot resume addInjectStreamUrl in audience mode. ".concat(u.url), u),
  15873. t.next = 60;
  15874. break;
  15875. case 48:
  15876. if (!u) {
  15877. t.next = 60;
  15878. break
  15879. }
  15880. return r.
  15881. default.debug("Resuming LiveStreaming pullStream ".concat(u.url), u),
  15882. t.prev = 50,
  15883. t.next = 53,
  15884. e._addInjectStreamUrl(u.url, u.transcodingConfig);
  15885. case 53:
  15886. l = t.sent,
  15887. r.
  15888. default.debug("Resumed LiveStreaming pullStream ".concat(u.url, ": ").concat(l.reason)),
  15889. t.next = 60;
  15890. break;
  15891. case 57:
  15892. t.prev = 57,
  15893. t.t7 = t.
  15894. catch(50),
  15895. 451 === t.t7.code && r.
  15896. default.debug("Resumed LiveStreaming pullStream ".concat(u.url, ": ").concat(t.t7.reason));
  15897. case 60:
  15898. t.next = 38;
  15899. break;
  15900. case 62:
  15901. case "end":
  15902. return t.stop()
  15903. }
  15904. }), t, null, [[21, 28], [50, 57]])
  15905. })));
  15906. return function(e) {
  15907. return t.apply(this, arguments)
  15908. }
  15909. } (),
  15910. e.liveStreaming.startOptions = {
  15911. autoDestroyTime: 30
  15912. },
  15913. e.liveStreaming.transcodingConfig = {
  15914. audioBitrate: 48,
  15915. audioChannels: 1,
  15916. audioSampleRate: 48e3,
  15917. backgroundColor: 0,
  15918. height: 360,
  15919. images: [],
  15920. lowLatency: !1,
  15921. metadata: "",
  15922. userConfigExtraInfo: "",
  15923. userConfigs: [],
  15924. videoBitrate: 400,
  15925. videoCodecProfile: 100,
  15926. videoCodecType: 1,
  15927. videoFramerate: 15,
  15928. videoGop: 30,
  15929. width: 640
  15930. },
  15931. e.startLiveStreaming = function(n, a) {
  15932. Object(z.isEmpty)(a) || Object(z.checkValidBoolean)(a, "transcodingEnabled"),
  15933. Object(z.checkValidString)(n, "url", 1, 1024);
  15934. var i = s.b.reportApiInvoke(t.sessionId, {
  15935. name: "Client.startLiveStreaming",
  15936. options: arguments,
  15937. tag: "tracer"
  15938. });
  15939. if (e.gatewayClient && "audience" === e.gatewayClient.role) {
  15940. var o = {
  15941. code: 403,
  15942. reason: "AUDIENCE_STREAMING_FORBIDDEN"
  15943. };
  15944. throw i(o),
  15945. o
  15946. }
  15947. var r = e._startLiveStreaming(n, a);
  15948. return r.then((function(e) {
  15949. i(null, e)
  15950. })).
  15951. catch((function(e) {
  15952. i(e)
  15953. })),
  15954. r
  15955. },
  15956. e._startLiveStreaming = function() {
  15957. var n = ee()(Z.a.mark((function n(a, i) {
  15958. var o, s, c, d;
  15959. return Z.a.wrap((function(n) {
  15960. for (;;) switch (n.prev = n.next) {
  15961. case 0:
  15962. return o = E()({
  15963. allocate: !0,
  15964. clientRequest: {
  15965. command: "PublishStream"
  15966. },
  15967. command: "request"
  15968. }),
  15969. r.
  15970. default.debug("startLiveStreaming ".concat(a, ", ").concat(i)),
  15971. E()(o.clientRequest, e.liveStreaming.startOptions, {
  15972. ts: Date.now(),
  15973. url: a,
  15974. vid: parseInt(e.joinInfo.vid, 10)
  15975. }),
  15976. s = null,
  15977. 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.
  15978. default.warning("VP8 is not supported by raw_streaming. Subscriber side will suffer"), "rtc" === t.mode && r.
  15979. 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),
  15980. c = null,
  15981. d = {},
  15982. n.prev = 7,
  15983. n.next = 10,
  15984. s.request(o);
  15985. case 10:
  15986. c = n.sent,
  15987. d.type = "liveStreamingStarted",
  15988. d.reason = c && c.reason,
  15989. d.status = c && c.code,
  15990. d.url = c && c.serverResponse && c.serverResponse.url,
  15991. e.gatewayClient.dispatchEvent(d),
  15992. n.next = 26;
  15993. break;
  15994. case 18:
  15995. throw n.prev = 18,
  15996. n.t0 = n.
  15997. catch(7),
  15998. d.type = "liveStreamingFailed",
  15999. d.reason = n.t0 && n.t0.reason,
  16000. d.status = n.t0 && n.t0.code,
  16001. d.url = n.t0 && n.t0.serverResponse && n.t0.serverResponse.url,
  16002. e.gatewayClient.dispatchEvent(d),
  16003. n.t0;
  16004. case 26:
  16005. return e.liveStreaming.pushStates[a] = {
  16006. transcodingEnabled: i,
  16007. url: a
  16008. },
  16009. n.abrupt("return", c);
  16010. case 28:
  16011. case "end":
  16012. return n.stop()
  16013. }
  16014. }), n, null, [[7, 18]])
  16015. })));
  16016. return function(e, t) {
  16017. return n.apply(this, arguments)
  16018. }
  16019. } (),
  16020. e.setLiveTranscoding = function(n, a) {
  16021. r.
  16022. default.debug("setLiveTranscoding: ".concat(JSON.stringify(n))),
  16023. Object(z.checkValidObject)(n, "transcoding");
  16024. var i = n,
  16025. o = i.width,
  16026. c = i.height,
  16027. d = i.videoBitrate,
  16028. u = i.videoFramerate,
  16029. l = i.lowLatency,
  16030. p = i.audioSampleRate,
  16031. f = i.audioBitrate,
  16032. g = i.audioChannels,
  16033. m = i.videoGop,
  16034. v = i.images,
  16035. S = i.videoCodecProfile,
  16036. E = i.userCount,
  16037. _ = i.backgroundColor,
  16038. h = i.transcodingUsers;
  16039. 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)) {
  16040. if (!Object(z.isArray)(h)) throw new Error("[transcodingUsers]: transcodingUsers should be Array");
  16041. if (h.length > 17) throw new Error("The length of transcodingUsers cannot greater than 17");
  16042. h.map((function(e, t) {
  16043. 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]");
  16044. 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;
  16045. 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]")
  16046. }))
  16047. }
  16048. if (!Object(z.isEmpty)(v)) {
  16049. if (!Object(z.isArray)(v)) throw new Error("[images]: images should be Array");
  16050. v.map((function(e, t) {
  16051. 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;
  16052. 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]")
  16053. }))
  16054. }
  16055. var I = s.b.reportApiInvoke(t.sessionId, {
  16056. name: "Client.setLiveTranscoding",
  16057. options: arguments,
  16058. tag: "tracer"
  16059. });
  16060. if ((n = JSON.parse(JSON.stringify(n))).transcodingUsers && (n.userConfigs = n.transcodingUsers, delete n.transcodingUsers), e.joinInfo.stringUid && n.userConfigs && n.userConfigs.length) {
  16061. var b = [];
  16062. n.userConfigs.forEach((function(t) {
  16063. b.push(Qe(e.joinInfo, e.gatewayClient, t.uid).then((function(e) {
  16064. t.uid = e.uid
  16065. })))
  16066. }));
  16067. var T = Promise.all(b).then((function() {
  16068. return e._setLiveTranscoding(n, a)
  16069. }));
  16070. return T.then((function(e) {
  16071. I(null, e)
  16072. })).
  16073. catch((function(e) {
  16074. I(e)
  16075. })),
  16076. T
  16077. }
  16078. var R = e._setLiveTranscoding(n, a);
  16079. return R.then((function(e) {
  16080. I(null, e)
  16081. })).
  16082. catch((function(e) {
  16083. I(e)
  16084. })),
  16085. R
  16086. },
  16087. e._setLiveTranscoding = function() {
  16088. var t = ee()(Z.a.mark((function t(n, a) {
  16089. var i, o, r;
  16090. return Z.a.wrap((function(t) {
  16091. for (;;) switch (t.prev = t.next) {
  16092. case 0:
  16093. if (e.liveStreaming.transcodingConfig = E()(e.liveStreaming.transcodingConfig, n), "boolean" != typeof a && (a = !!e.liveStreaming.connections.mix_streaming), i = JSON.parse(JSON.stringify({
  16094. allocate: !1,
  16095. clientRequest: {
  16096. command: "UpdateTranscoding",
  16097. transcodingConfig: e.liveStreaming.transcodingConfig
  16098. },
  16099. command: "request"
  16100. })), o = {},
  16101. !a) {
  16102. t.next = 16;
  16103. break
  16104. }
  16105. return e.liveStreaming.connections.mix_streaming || e.liveStreaming.connect("mix_streaming"),
  16106. t.next = 8,
  16107. e.liveStreaming.connections.mix_streaming.request(i);
  16108. case 8:
  16109. return r = t.sent,
  16110. o.type = "liveTranscodingUpdated",
  16111. o.reason = r.reason,
  16112. o.status = r.code,
  16113. e.gatewayClient.dispatchEvent(o),
  16114. t.abrupt("return", r);
  16115. case 16:
  16116. return t.abrupt("return", {
  16117. code: 200,
  16118. reason: "success"
  16119. });
  16120. case 17:
  16121. case "end":
  16122. return t.stop()
  16123. }
  16124. }), t)
  16125. })));
  16126. return function(e, n) {
  16127. return t.apply(this, arguments)
  16128. }
  16129. } (),
  16130. e.stopLiveStreaming = function(n, a) {
  16131. Object(z.checkValidString)(n, "url", 1, 1024);
  16132. var i = s.b.reportApiInvoke(t.sessionId, {
  16133. name: "Client.stopLiveStreaming",
  16134. options: arguments,
  16135. tag: "tracer"
  16136. }),
  16137. o = e._stopLiveStreaming(n, a);
  16138. return o.then((function(e) {
  16139. i(null, e)
  16140. })).
  16141. catch((function(e) {
  16142. i(e)
  16143. })),
  16144. o
  16145. },
  16146. e._stopLiveStreaming = function() {
  16147. var t = ee()(Z.a.mark((function t(n, a, i) {
  16148. var o, r, s, c, d, u;
  16149. return Z.a.wrap((function(t) {
  16150. for (;;) switch (t.prev = t.next) {
  16151. case 0:
  16152. return o = null,
  16153. r = e.liveStreaming.pushStates[n],
  16154. o = r ? r.transcodingEnabled ? "mix_streaming": "raw_streaming": a ? "mix_streaming": "raw_streaming",
  16155. s = {
  16156. allocate: !1,
  16157. clientRequest: {
  16158. command: "UnpublishStream",
  16159. url: n
  16160. },
  16161. command: "request"
  16162. },
  16163. e.liveStreaming.connections[o] || e.liveStreaming.connect(o),
  16164. c = null,
  16165. t.prev = 6,
  16166. t.next = 9,
  16167. e.liveStreaming.connections[o].request(s);
  16168. case 9:
  16169. c = t.sent,
  16170. (d = {}).type = "liveStreamingStopped",
  16171. d.reason = c && c.reason,
  16172. d.status = c && c.code,
  16173. d.url = c && c.serverResponse && c.serverResponse.url,
  16174. e.gatewayClient.dispatchEvent(d),
  16175. t.next = 27;
  16176. break;
  16177. case 18:
  16178. throw t.prev = 18,
  16179. t.t0 = t.
  16180. catch(6),
  16181. (u = {}).type = "liveStreamingStopped",
  16182. u.reason = t.t0 && t.t0.reason,
  16183. u.status = t.t0 && t.t0.code,
  16184. u.url = t.t0 && t.t0.serverResponse && t.t0.serverResponse.url,
  16185. e.gatewayClient.dispatchEvent(u),
  16186. t.t0;
  16187. case 27:
  16188. return i || delete e.liveStreaming.pushStates[n],
  16189. t.abrupt("return", c);
  16190. case 29:
  16191. case "end":
  16192. return t.stop()
  16193. }
  16194. }), t, null, [[6, 18]])
  16195. })));
  16196. return function(e, n, a) {
  16197. return t.apply(this, arguments)
  16198. }
  16199. } (),
  16200. e.liveStreaming.injectStreamTranscodingConfig = {
  16201. autoDestroyTime: 30,
  16202. audioBitrate: 48,
  16203. audioChannels: 1,
  16204. audioSampleRate: 44100,
  16205. height: 0,
  16206. videoBitrate: 400,
  16207. videoFramerate: 15,
  16208. videoGop: 30,
  16209. width: 0
  16210. },
  16211. e.addInjectStreamUrl = function(a, i) {
  16212. Object(z.checkValidString)(a, "url", 1, 1024),
  16213. Object(z.checkValidObject)(i, "config"),
  16214. !Object(z.isEmpty)(i && i.width) && Object(z.checkValidNumber)(i.width, "config.width", 0, 1e4),
  16215. !Object(z.isEmpty)(i && i.height) && Object(z.checkValidNumber)(i.height, "config.height", 0, 1e4),
  16216. !Object(z.isEmpty)(i && i.videoGop) && Object(z.checkValidNumber)(i.videoGop, "config.videoGop", 1, 1e4),
  16217. !Object(z.isEmpty)(i && i.videoFramerate) && Object(z.checkValidNumber)(i.videoFramerate, "config.videoFramerate", 1, 1e4),
  16218. !Object(z.isEmpty)(i && i.videoBitrate) && Object(z.checkValidNumber)(i.videoBitrate, "config.videoBitrate", 1, 1e4),
  16219. !Object(z.isEmpty)(i && i.audioSampleRate) && Object(z.checkValidEnum)(i.audioSampleRate, "config.audioSampleRate", [32e3, 44100, 48e3]),
  16220. !Object(z.isEmpty)(i && i.audioBitrate) && Object(z.checkValidNumber)(i.audioBitrate, "config.audioBitrate", 1, 1e4),
  16221. !Object(z.isEmpty)(i && i.audioChannels) && Object(z.checkValidNumber)(i.audioChannels, "config.audioChannels", 1, 2);
  16222. var o = s.b.reportApiInvoke(t.sessionId, {
  16223. name: "Client.addInjectStreamUrl",
  16224. options: n,
  16225. tag: "tracer"
  16226. });
  16227. if ("audience" === e.gatewayClient.role) {
  16228. var r = {
  16229. code: 403,
  16230. reason: "AUDIENCE_INJECTING_FORBIDDEN"
  16231. };
  16232. throw o(r),
  16233. r
  16234. }
  16235. var c = e._addInjectStreamUrl(a, i);
  16236. return c.then((function(e) {
  16237. o(null, e)
  16238. })).
  16239. catch((function(e) {
  16240. o(e)
  16241. })),
  16242. c
  16243. },
  16244. e._addInjectStreamUrl = function() {
  16245. var n = ee()(Z.a.mark((function n(a, i) {
  16246. var o, r, s, c, d;
  16247. return Z.a.wrap((function(n) {
  16248. for (;;) switch (n.prev = n.next) {
  16249. case 0:
  16250. return o = E()({},
  16251. e.liveStreaming.injectStreamTranscodingConfig, i),
  16252. r = {
  16253. allocate: !0,
  16254. clientRequest: {
  16255. cname: e.channel,
  16256. command: "InjectStream",
  16257. sid: t.sessionId,
  16258. transcodingConfig: o,
  16259. ts: Date.now(),
  16260. url: a,
  16261. vid: parseInt(e.joinInfo.vid, 10)
  16262. },
  16263. command: "request"
  16264. },
  16265. e.liveStreaming.connections.inject_streaming || e.liveStreaming.connect("inject_streaming"),
  16266. s = null,
  16267. n.prev = 4,
  16268. n.next = 7,
  16269. e.liveStreaming.connections.inject_streaming.request(r);
  16270. case 7:
  16271. s = n.sent,
  16272. c = {
  16273. reason: s && s.reason,
  16274. status: Dt(s && s.code),
  16275. type: "streamInjectedStatus",
  16276. uid: s && s.serverResponse && s.serverResponse.inject_uid,
  16277. url: s && s.serverResponse && s.serverResponse.url
  16278. },
  16279. e.gatewayClient.dispatchEvent(c),
  16280. n.next = 17;
  16281. break;
  16282. case 12:
  16283. throw n.prev = 12,
  16284. n.t0 = n.
  16285. catch(4),
  16286. d = {
  16287. reason: n.t0 && n.t0.reason,
  16288. status: Dt(n.t0 && n.t0.code),
  16289. type: "streamInjectedStatus",
  16290. uid: n.t0 && n.t0.serverResponse && n.t0.serverResponse.inject_uid,
  16291. url: n.t0 && n.t0.serverResponse && n.t0.serverResponse.url
  16292. },
  16293. e.gatewayClient.dispatchEvent(d),
  16294. n.t0;
  16295. case 17:
  16296. return e.liveStreaming.pullStates[a] = {
  16297. transcodingConfig: o,
  16298. url: a
  16299. },
  16300. n.abrupt("return", s);
  16301. case 19:
  16302. case "end":
  16303. return n.stop()
  16304. }
  16305. }), n, null, [[4, 12]])
  16306. })));
  16307. return function(e, t) {
  16308. return n.apply(this, arguments)
  16309. }
  16310. } (),
  16311. e.removeInjectStreamUrl = function() {
  16312. var n = ee()(Z.a.mark((function n(a) {
  16313. var i, o, r = arguments;
  16314. return Z.a.wrap((function(n) {
  16315. for (;;) switch (n.prev = n.next) {
  16316. case 0:
  16317. return Object(z.checkValidString)(a, "url", 1, 255),
  16318. i = s.b.reportApiInvoke(t.sessionId, {
  16319. name: "Client.removeInjectStreamUrl",
  16320. options: r,
  16321. tag: "tracer"
  16322. }),
  16323. (o = e._removeInjectStreamUrl(a)).then((function(e) {
  16324. i(null, e)
  16325. })).
  16326. catch((function(e) {
  16327. i(e)
  16328. })),
  16329. n.abrupt("return", o);
  16330. case 5:
  16331. case "end":
  16332. return n.stop()
  16333. }
  16334. }), n)
  16335. })));
  16336. return function(e) {
  16337. return n.apply(this, arguments)
  16338. }
  16339. } (),
  16340. e._removeInjectStreamUrl = function() {
  16341. var t = ee()(Z.a.mark((function t(n) {
  16342. var a, i, o, r;
  16343. return Z.a.wrap((function(t) {
  16344. for (;;) switch (t.prev = t.next) {
  16345. case 0:
  16346. return a = {
  16347. allocate: !1,
  16348. clientRequest: {
  16349. command: "UninjectStream",
  16350. url: n
  16351. },
  16352. command: "request"
  16353. },
  16354. e.liveStreaming.connections.inject_streaming || e.liveStreaming.connect("inject_streaming"),
  16355. i = null,
  16356. t.prev = 3,
  16357. t.next = 6,
  16358. e.liveStreaming.connections.inject_streaming.request(a);
  16359. case 6:
  16360. i = t.sent,
  16361. o = {
  16362. reason: i && i.reason,
  16363. status: kt(i && i.code),
  16364. type: "streamInjectedStatus",
  16365. uid: i && i.serverResponse && i.serverResponse.inject_uid,
  16366. url: i && i.serverResponse && i.serverResponse.url
  16367. },
  16368. e.gatewayClient.dispatchEvent(o),
  16369. t.next = 16;
  16370. break;
  16371. case 11:
  16372. throw t.prev = 11,
  16373. t.t0 = t.
  16374. catch(3),
  16375. r = {
  16376. reason: t.t0 && t.t0.reason,
  16377. status: kt(t.t0 && t.t0.code),
  16378. type: "streamInjectedStatus",
  16379. uid: t.t0 && t.t0.serverResponse && t.t0.serverResponse.inject_uid,
  16380. url: t.t0 && t.t0.serverResponse && t.t0.serverResponse.url
  16381. },
  16382. e.gatewayClient.dispatchEvent(r),
  16383. t.t0;
  16384. case 16:
  16385. return delete e.liveStreaming.pullStates[n],
  16386. t.abrupt("return", i);
  16387. case 18:
  16388. case "end":
  16389. return t.stop()
  16390. }
  16391. }), t, null, [[3, 11]])
  16392. })));
  16393. return function(e) {
  16394. return t.apply(this, arguments)
  16395. }
  16396. } ()
  16397. } (t, e), e.areaCode) {
  16398. var n = Object(Mt.getAreaDomainConfig)(e.areaCode);
  16399. Object.keys(n).map((function(e) {
  16400. "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])
  16401. }))
  16402. }
  16403. return Object(z.isEmpty)(e.turnServer) || t.setTurnServer(e.turnServer),
  16404. Object(z.isEmpty)(e.proxyServer) || t.setProxyServer(e.proxyServer),
  16405. "live" === t.mode && (t.gatewayClient.role = "audience"),
  16406. "rtc" === t.mode && (t.gatewayClient.role = Ut),
  16407. t.gatewayClient.on("onMultiIP", (function(e) {
  16408. t.gatewayClient.closeGateway(),
  16409. t.gatewayClient.socket = void 0,
  16410. t.gatewayClient.hasChangeBGPAddress = !0,
  16411. t.joinInfo.multiIP = e.option,
  16412. t.gatewayClient.state = st.CONNECTING;
  16413. var n = function(e) {
  16414. r.
  16415. default.info("[".concat(t.clientId, "] Joining channel: ").concat(t.channel)),
  16416. t.joinInfo.cid = e.cid,
  16417. t.joinInfo.uid || (t.joinInfo.uid = e.uid),
  16418. t.joinInfo.uni_lbs_ip = e.uni_lbs_ip,
  16419. t.joinInfo.gatewayAddr = e.gateway_addr,
  16420. t.onSuccess ? t.gatewayClient.join(t.joinInfo, t.key, (function(e) {
  16421. r.
  16422. default.info("[".concat(t.clientId, "] Join channel ").concat(t.channel, " success"));
  16423. var n = t.onSuccess;
  16424. t.onSuccess = null,
  16425. t.onFailure = null,
  16426. n(e)
  16427. }), t.onFailure) : (t.gatewayClient.joinInfo = E()({},
  16428. t.joinInfo), t.gatewayClient.rejoin())
  16429. };
  16430. 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) {
  16431. r.
  16432. default.error("getUserAccount Success ".concat(e.url, " ").concat(joinInfo.stringUid, " => ").concat(e.uid)),
  16433. t.joinInfo.uid = e.uid,
  16434. ze(t.joinInfo, n, t.onFailure)
  16435. })).
  16436. catch((function(e) {
  16437. r.
  16438. default.error("getUserAccount rejected", e),
  16439. t.onFailure(e)
  16440. }))) : ze(t.joinInfo, n, t.onFailure)
  16441. })),
  16442. t.gatewayClient.on("rejoin-start", (function() {
  16443. t._renewSession(),
  16444. s.b.sessionInit(e.sessionId, {
  16445. lts: (new Date).getTime(),
  16446. extend: {
  16447. rejoin: !0
  16448. },
  16449. cname: t.channel,
  16450. appid: e.appId,
  16451. mode: e.mode,
  16452. succ: !0
  16453. })
  16454. })),
  16455. t.gatewayClient.on("recover", (function() {
  16456. t._renewSession(),
  16457. console.log("recover", e.sessionId),
  16458. s.b.sessionInit(e.sessionId, {
  16459. lts: (new Date).getTime(),
  16460. extend: {
  16461. recover: !0
  16462. },
  16463. cname: t.channel,
  16464. appid: e.appId,
  16465. mode: e.mode,
  16466. succ: !0
  16467. })
  16468. })),
  16469. t.gatewayClient.on("rejoin", (function() {
  16470. var e = t.highStreamState;
  16471. if (r.
  16472. default.debug("[".concat(t.clientId, "] Client local stream preState: ").concat(e)), t.onSuccess) {
  16473. var n = t.onSuccess;
  16474. t.onSuccess = null,
  16475. t.onFailure = null,
  16476. n(t.joinInfo.uid)
  16477. } ! t.highStream || 0 !== e && 1 !== e || (r.
  16478. default.info("[".concat(t.clientId, "] publish after rejoin")), t.highStreamState = 2, t.lowStreamState = 2, t.publish(t.highStream, (function(e) {
  16479. e && r.
  16480. default.info("[".concat(t.clientId, "] "), e)
  16481. })))
  16482. })),
  16483. t.gatewayClient.on("streamPublished", (function(e) {
  16484. t.hasPublished || (t.hasPublished = !0, t.gatewayClient.dispatchEvent(u({
  16485. type: "stream-published",
  16486. stream: e.stream
  16487. })))
  16488. })),
  16489. t.gatewayClient.on("pubP2PLost", (function(e) {
  16490. r.
  16491. default.debug("[".concat(t.clientId, "] Start reconnect local peerConnection: ").concat(t.highStream.getId())),
  16492. t.gatewayClient.dispatchEvent({
  16493. type: "stream-reconnect-start",
  16494. uid: t.highStream.getId()
  16495. }),
  16496. 1 === t.highStreamState && (t.highStreamState = 0, t.lowStreamState = 0),
  16497. t._unpublish(t.highStream, (function() {
  16498. t._publish(t.highStream, (function() {
  16499. r.
  16500. default.debug("[".concat(t.clientId, "] Reconnect local peerConnection success: ").concat(t.highStream.getId())),
  16501. t.gatewayClient.dispatchEvent({
  16502. type: "stream-reconnect-end",
  16503. uid: t.highStream.getId(),
  16504. success: !0,
  16505. reason: ""
  16506. })
  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. }), (function(e) {
  16518. r.
  16519. default.debug("[".concat(t.clientId, "] Reconnect local peerConnection failed: ").concat(e)),
  16520. t.gatewayClient.dispatchEvent({
  16521. type: "stream-reconnect-end",
  16522. uid: t.highStream.getId(),
  16523. success: !1,
  16524. reason: e
  16525. })
  16526. }), !0)
  16527. })),
  16528. t.gatewayClient.on("subP2PLost", (function(e) {
  16529. r.
  16530. default.debug("[".concat(t.clientId, "] Start reconnect remote peerConnection: ").concat(e.stream.getId(), " ").concat(e.stream.subscribeOptions)),
  16531. t.gatewayClient.dispatchEvent({
  16532. type: "stream-reconnect-start",
  16533. uid: e.stream.getId()
  16534. });
  16535. var n = e.stream.subscribeOptions;
  16536. console.log("Re-subscribe stream", n, e.stream),
  16537. t.gatewayClient.unsubscribe(e.stream, (function() {
  16538. e.stream.subscribeOptions = n,
  16539. t.gatewayClient.subscribe(e.stream, (function() {
  16540. r.
  16541. default.debug("[".concat(t.clientId, "] Reconnect remote peerConnection success: ").concat(e.stream.getId())),
  16542. t.gatewayClient.dispatchEvent({
  16543. type: "stream-reconnect-end",
  16544. uid: e.stream.getId(),
  16545. success: !0,
  16546. reason: ""
  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. }), (function(n) {
  16559. r.
  16560. default.debug("[".concat(t.clientId, "] Reconnect remote peerConnection failed: "), n),
  16561. t.gatewayClient.dispatchEvent({
  16562. type: "stream-reconnect-end",
  16563. uid: e.stream.getId(),
  16564. success: !1,
  16565. reason: n
  16566. })
  16567. }))
  16568. })),
  16569. ft.on("networkTypeChanged", (function(e) {
  16570. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16571. var n = E()({},
  16572. e, {
  16573. type: "network-type-changed"
  16574. });
  16575. t.gatewayClient.dispatchEvent(n)
  16576. })),
  16577. K.on("recordingDeviceChanged", (function(e) {
  16578. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16579. var n = E()({},
  16580. e, {
  16581. type: "recording-device-changed"
  16582. });
  16583. t.gatewayClient.dispatchEvent(n)
  16584. })),
  16585. K.on("playoutDeviceChanged", (function(e) {
  16586. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16587. var n = E()({},
  16588. e, {
  16589. type: "playout-device-changed"
  16590. });
  16591. t.gatewayClient.dispatchEvent(n)
  16592. })),
  16593. K.on("cameraChanged", (function(e) {
  16594. t.gatewayClient && t.gatewayClient.dispatchEvent(e);
  16595. var n = E()({},
  16596. e, {
  16597. type: "camera-changed"
  16598. });
  16599. t.gatewayClient.dispatchEvent(n)
  16600. })),
  16601. t.gatewayClient.on("streamTypeChange", (function(n) {
  16602. var a = E()({},
  16603. n, {
  16604. type: "stream-type-changed"
  16605. });
  16606. t.gatewayClient.dispatchEvent(a),
  16607. s.b.reportApiInvoke(e.sessionId, {
  16608. name: "streamTypeChange"
  16609. })(null, JSON.stringify(n))
  16610. })),
  16611. t
  16612. },
  16613. Vt = {
  16614. width: 640,
  16615. height: 360,
  16616. videoBitrate: 400,
  16617. videoFramerate: 15,
  16618. lowLatency: !1,
  16619. audioSampleRate: 48e3,
  16620. audioBitrate: 48,
  16621. audioChannels: 1,
  16622. videoGop: 30,
  16623. videoCodecProfile: 100,
  16624. userCount: 0,
  16625. userConfigExtraInfo: {},
  16626. backgroundColor: 0,
  16627. transcodingUsers: []
  16628. },
  16629. jt = function(e) {
  16630. switch (e) {
  16631. case "h264_interop":
  16632. return "h264";
  16633. default:
  16634. return "vp8"
  16635. }
  16636. },
  16637. Bt = function(e) {
  16638. return - 1 === we.indexOf(e.mode) ? I.
  16639. default.INVALID_CLIENT_MODE:
  16640. -1 === De.indexOf(e.codec) ? I.
  16641. default.INVALID_CLIENT_CODEC:
  16642. "h264_interop" == e.mode && "h264" !== e.codec && I.
  16643. default.CLIENT_MODE_CODEC_MISMATCH
  16644. },
  16645. Ft = function(e) {
  16646. switch (e.mode) {
  16647. case "interop":
  16648. case "h264_interop":
  16649. e.mode = "live";
  16650. break;
  16651. case "web-only":
  16652. e.mode = "rtc"
  16653. }
  16654. },
  16655. Wt = K.getDevices,
  16656. Gt = V,
  16657. Ht = JSON.parse(JSON.stringify(o.SUPPORT_RESOLUTION_LIST));
  16658. n.
  16659. default = {
  16660. TranscodingUser: {
  16661. uid: 0,
  16662. x: 0,
  16663. y: 0,
  16664. width: 0,
  16665. height: 0,
  16666. zOrder: 0,
  16667. alpha: 1
  16668. },
  16669. LiveTranscoding: Vt,
  16670. createClient: function(e) {
  16671. var t = s.b.reportApiInvoke(null, {
  16672. name: "createClient",
  16673. options: arguments,
  16674. tag: "tracer"
  16675. }); (e = E()({},
  16676. e || {})).codec || (e.codec = jt(e.mode));
  16677. var n = Bt(e);
  16678. if (n) throw r.
  16679. default.error("Invalid parameter setting MODE: ".concat(e.mode, " CODEC: ").concat(e.codec, " ERROR ").concat(n)),
  16680. t(n),
  16681. new Error(n);
  16682. return r.
  16683. default.info("Creating client, MODE: ".concat(e.mode, " CODEC: ").concat(e.codec)),
  16684. Ft(e),
  16685. t(null, e),
  16686. xt(e)
  16687. },
  16688. createStream: function(e) {
  16689. var t = s.b.reportApiInvoke(null, {
  16690. name: "createStream",
  16691. options: arguments,
  16692. tag: "tracer",
  16693. getStates: function() {
  16694. return {
  16695. audioTrackEnable: e && e.audioSource ? e.audioSource.enabled: null,
  16696. videoTrackEnable: e && e.videoSource ? e.videoSource.enabled: null
  16697. }
  16698. }
  16699. });
  16700. Object(z.checkValidObject)(e, "StreamSpec");
  16701. var n = e.streamID,
  16702. a = e.audio,
  16703. i = e.video,
  16704. o = e.screen,
  16705. c = e.screenAudio,
  16706. d = (e.audioSource, e.videoSource, e.cameraId),
  16707. u = e.facingMode,
  16708. l = e.microphoneId,
  16709. p = e.mirror,
  16710. f = e.extensionId,
  16711. g = e.mediaSource,
  16712. m = e.audioProcessing;
  16713. 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");
  16714. 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)) {
  16715. var v = m.AGC,
  16716. S = m.AEC,
  16717. E = m.ANS;
  16718. Object(z.isEmpty)(v) || Object(z.checkValidBoolean)(v, "AGC"),
  16719. Object(z.isEmpty)(S) || Object(z.checkValidBoolean)(S, "AEC"),
  16720. Object(z.isEmpty)(E) || Object(z.checkValidBoolean)(E, "ANS")
  16721. }
  16722. r.
  16723. default.debug("Create stream"),
  16724. !0 === c && !0 === a && r.
  16725. default.warning("Do not set both 'screenAudio' and 'audio' to true at the same time");
  16726. var _ = ye(e);
  16727. return t(),
  16728. _
  16729. },
  16730. Logger: r.
  16731. default,
  16732. report: s.b,
  16733. getDevices: Wt,
  16734. getScreenSources: Gt,
  16735. getParameter: o.getParameter,
  16736. setParameter: o.setParameter,
  16737. checkSystemRequirements: function() {
  16738. var e = s.b.reportApiInvoke(null, {
  16739. name: "checkSystemRequirements",
  16740. options: arguments,
  16741. tag: "tracer"
  16742. }),
  16743. t = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection,
  16744. n = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia || navigator.mediaDevices && navigator.mediaDevices.getUserMedia,
  16745. a = window.WebSocket,
  16746. i = !!t && !!n && !!a,
  16747. o = !1;
  16748. g.isChrome() && g.getBrowserVersion() >= 58 && "iOS" !== g.getBrowserOS() && (o = !0),
  16749. g.isFireFox() && g.getBrowserVersion() >= 56 && (o = !0),
  16750. g.isOpera() && g.getBrowserVersion() >= 45 && (o = !0),
  16751. g.isSafari() && g.getBrowserVersion() >= 11 && (o = !0),
  16752. g.isEdge() && (o = !0),
  16753. (g.isWeChatBrowser() || g.isQQBrowser()) && "iOS" !== g.getBrowserOS() && (o = !0),
  16754. g.isSupportedPC() || g.isSupportedMobile() || (o = !1),
  16755. r.
  16756. default.debug(g.getBrowserInfo(), "isAPISupport: " + i + ", isVendorAndVersionSupport: " + o);
  16757. var c = i && o;
  16758. return e(null, c),
  16759. c
  16760. },
  16761. getSupportedCodec: Oe.getSupportedCodec,
  16762. ChannelMediaRelayConfiguration: Ce.ChannelMediaRelayConfiguration,
  16763. VERSION: o.VERSION,
  16764. BUILD: o.BUILD,
  16765. PROFILE_TABLE: Ht,
  16766. AUDIO_SAMPLE_RATE_32000: 32e3,
  16767. AUDIO_SAMPLE_RATE_44100: 44100,
  16768. AUDIO_SAMPLE_RATE_48000: 48e3,
  16769. VIDEO_CODEC_PROFILE_BASELINE: 66,
  16770. VIDEO_CODEC_PROFILE_MAIN: 77,
  16771. VIDEO_CODEC_PROFILE_HIGH: 100,
  16772. REMOTE_VIDEO_STREAM_HIGH: 0,
  16773. REMOTE_VIDEO_STREAM_LOW: 1,
  16774. REMOTE_VIDEO_STREAM_MEDIUM: 2,
  16775. AREAS: Mt.AREAS,
  16776. AREA_VERSION: "global"
  16777. }
  16778. }]).
  16779. default
  16780. }));