/* VideoPlayer Worker version 1.3.0 */ !function(){"use strict";const t=function(){};var e="PLAYLIST_LOADED",r="FRAGMENT_DECRYPTED",s="FIRST_VIDEO_FRAME",n="RESOLUTION_SWITCHING",a="SEEK",o="PLAY",h="PAUSE",d="PLAYING",l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var u,f={exports:{}};u=f,function(t){function e(t){return parseInt(t)===t}function i(t){if(!e(t.length))return!1;for(var i=0;i255)return!1;return!0}function r(t,r){if(t.buffer&&"Uint8Array"===t.name)return r&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!i(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(e(t.length)&&i(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function s(t){return new Uint8Array(t)}function n(t,e,i,r,s){null==r&&null==s||(t=t.slice?t.slice(r,s):Array.prototype.slice.call(t,r,s)),e.set(t,i)}var a,o={toBytes:function(t){var e=[],i=0;for(t=encodeURI(t);i191&&r<224?(e.push(String.fromCharCode((31&r)<<6|63&t[i+1])),i+=2):(e.push(String.fromCharCode((15&r)<<12|(63&t[i+1])<<6|63&t[i+2])),i+=3)}return e.join("")}},h=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],i=0;i>4]+a[15&r])}return e.join("")}}),d={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],p=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],f=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],c=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],_=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],y=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],v=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],S=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],w=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],U=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],T=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],x=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function E(t){for(var e=[],i=0;i>2,this._Ke[i][e%4]=n[e],this._Kd[t-i][e%4]=n[e];for(var a,o=0,h=s;h>16&255]<<24^p[a>>8&255]<<16^p[255&a]<<8^p[a>>24&255]^l[o]<<24,o+=1,8!=s)for(e=1;e>8&255]<<8^p[a>>16&255]<<16^p[a>>24&255]<<24,e=s/2+1;e>2,f=h%4,this._Ke[u][f]=n[e],this._Kd[t-u][f]=n[e++],h++}for(var u=1;u>24&255]^U[a>>16&255]^T[a>>8&255]^x[255&a]},A.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,i=[0,0,0,0],r=E(t),n=0;n<4;n++)r[n]^=this._Ke[0][n];for(var a=1;a>24&255]^m[r[(n+1)%4]>>16&255]^g[r[(n+2)%4]>>8&255]^_[255&r[(n+3)%4]]^this._Ke[a][n];r=i.slice()}var o,h=s(16);for(n=0;n<4;n++)o=this._Ke[e][n],h[4*n]=255&(p[r[n]>>24&255]^o>>24),h[4*n+1]=255&(p[r[(n+1)%4]>>16&255]^o>>16),h[4*n+2]=255&(p[r[(n+2)%4]>>8&255]^o>>8),h[4*n+3]=255&(p[255&r[(n+3)%4]]^o);return h},A.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,i=[0,0,0,0],r=E(t),n=0;n<4;n++)r[n]^=this._Kd[0][n];for(var a=1;a>24&255]^b[r[(n+3)%4]>>16&255]^v[r[(n+2)%4]>>8&255]^S[255&r[(n+1)%4]]^this._Kd[a][n];r=i.slice()}var o,h=s(16);for(n=0;n<4;n++)o=this._Kd[e][n],h[4*n]=255&(f[r[n]>>24&255]^o>>24),h[4*n+1]=255&(f[r[(n+3)%4]>>16&255]^o>>16),h[4*n+2]=255&(f[r[(n+2)%4]>>8&255]^o>>8),h[4*n+3]=255&(f[255&r[(n+1)%4]]^o);return h};var k=function(t){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new A(t)};k.prototype.encrypt=function(t){if((t=r(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=s(t.length),i=s(16),a=0;aNumber.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var e=15;e>=0;--e)this._counter[e]=t%256,t=parseInt(t/256)},D.prototype.setBytes=function(t){if(16!=(t=r(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},D.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var P=function(t,e){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof D||(e=new D(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new A(t)};P.prototype.encrypt=function(t){for(var e=r(t,!0),i=0;i16)throw new Error("PKCS#7 padding byte out of range");for(var i=t.length-e,a=0;a-1)},this.trigger=function(e){var i,r,s,n;if(i=t[e])if(2===arguments.length)for(s=i.length,r=0;r>5,h=(o=1024*(1+(3&e[d+6])))*A/k[(60&e[d+2])>>>2],e.byteLength-d>>6&3),channelcount:(1&e[d+2])<<2|(192&e[d+3])>>>6,samplerate:k[(60&e[d+2])>>>2],samplingfrequencyindex:(60&e[d+2])>>>2,samplesize:16,data:e.subarray(d+7+n,d+s)}),i++,d+=s}else"number"!=typeof l&&(l=d),d++;"number"==typeof l&&(this.skipWarn_(l,d),l=null),e=e.subarray(d)}},this.flush=function(){i=0,this.trigger("done")},this.reset=function(){e=void 0,this.trigger("reset")},this.endTimeline=function(){e=void 0,this.trigger("endedtimeline")}}).prototype=new U;var C,I,B,D=x,P=U,L=function(t){var e=t.byteLength,i=0,r=0;this.length=function(){return 8*e},this.bitsAvailable=function(){return 8*e+r},this.loadWord=function(){var s=t.byteLength-e,n=new Uint8Array(4),a=Math.min(4,e);if(0===a)throw new Error("no bytes available");n.set(t.subarray(s,s+a)),i=new DataView(n.buffer).getUint32(0),r=8*a,e-=a},this.skipBits=function(t){var s;r>t?(i<<=t,r-=t):(t-=r,t-=8*(s=Math.floor(t/8)),e-=s,this.loadWord(),i<<=t,r-=t)},this.readBits=function(t){var s=Math.min(r,t),n=i>>>32-s;return(r-=s)>0?i<<=s:e>0&&this.loadWord(),(s=t-s)>0?n<>>t)return i<<=t,r-=t,t;return this.loadWord(),t+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var t=this.skipLeadingZeros();return this.readBits(t+1)-1},this.readExpGolomb=function(){var t=this.readUnsignedExpGolomb();return 1&t?1+t>>>1:-1*(t>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};(I=function(){var t,e,i=0;I.prototype.init.call(this),this.push=function(r){var s;e?((s=new Uint8Array(e.byteLength+r.data.byteLength)).set(e),s.set(r.data,e.byteLength),e=s):e=r.data;for(var n=e.byteLength;i3&&this.trigger("data",e.subarray(i+3)),e=null,i=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}}).prototype=new P,B={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},C=function(){var t,e,i,r,s,n,a,o=new I;C.prototype.init.call(this),t=this,this.push=function(t){"video"===t.type&&(e=t.trackId,i=t.pts,r=t.dts,o.push(t))},o.on("data",(function(a){var o={trackId:e,pts:i,dts:r,data:a,nalUnitTypeCode:31&a[0]};switch(o.nalUnitTypeCode){case 5:o.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:o.nalUnitType="sei_rbsp",o.escapedRBSP=s(a.subarray(1));break;case 7:o.nalUnitType="seq_parameter_set_rbsp",o.escapedRBSP=s(a.subarray(1)),o.config=n(o.escapedRBSP);break;case 8:o.nalUnitType="pic_parameter_set_rbsp";break;case 9:o.nalUnitType="access_unit_delimiter_rbsp"}t.trigger("data",o)})),o.on("done",(function(){t.trigger("done")})),o.on("partialdone",(function(){t.trigger("partialdone")})),o.on("reset",(function(){t.trigger("reset")})),o.on("endedtimeline",(function(){t.trigger("endedtimeline")})),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},a=function(t,e){var i,r=8,s=8;for(i=0;i>>1,t.samplingfrequencyindex<<7|t.channelcount<<3,6,1,2]))},X=function(t){return z(it.hdlr,ht[t])},K=function(t){var e=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,t.duration>>>24&255,t.duration>>>16&255,t.duration>>>8&255,255&t.duration,85,196,0,0]);return t.samplerate&&(e[12]=t.samplerate>>>24&255,e[13]=t.samplerate>>>16&255,e[14]=t.samplerate>>>8&255,e[15]=255&t.samplerate),z(it.mdhd,e)},q=function(t){return z(it.mdia,K(t),X(t.type),N(t))},M=function(t){return z(it.mfhd,new Uint8Array([0,0,0,0,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t]))},N=function(t){return z(it.minf,"video"===t.type?z(it.vmhd,dt):z(it.smhd,lt),F(),Q(t))},G=function(t,e){for(var i=[],r=e.length;r--;)i[r]=J(e[r]);return z.apply(null,[it.moof,M(t)].concat(i))},V=function(t){for(var e=t.length,i=[];e--;)i[e]=W(t[e]);return z.apply(null,[it.moov,Y(4294967295)].concat(i).concat(H(t)))},H=function(t){for(var e=t.length,i=[];e--;)i[e]=tt(t[e]);return z.apply(null,[it.mvex].concat(i))},Y=function(t){var e=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return z(it.mvhd,e)},Z=function(t){var e,i,r=t.samples||[],s=new Uint8Array(4+r.length);for(i=0;i>>8),n.push(255&r[e].byteLength),n=n.concat(Array.prototype.slice.call(r[e]));for(e=0;e>>8),a.push(255&s[e].byteLength),a=a.concat(Array.prototype.slice.call(s[e]));if(i=[it.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&t.width)>>8,255&t.width,(65280&t.height)>>8,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),z(it.avcC,new Uint8Array([1,t.profileIdc,t.profileCompatibility,t.levelIdc,255].concat([r.length],n,[s.length],a))),z(it.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],t.sarRatio){var o=t.sarRatio[0],h=t.sarRatio[1];i.push(z(it.pasp,new Uint8Array([(4278190080&o)>>24,(16711680&o)>>16,(65280&o)>>8,255&o,(4278190080&h)>>24,(16711680&h)>>16,(65280&h)>>8,255&h])))}return z.apply(null,i)},_t=function(t){return z(it.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&t.channelcount)>>8,255&t.channelcount,(65280&t.samplesize)>>8,255&t.samplesize,0,0,0,0,(65280&t.samplerate)>>8,255&t.samplerate,0,0]),R(t))},j=function(t){var e=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,0,(4278190080&t.duration)>>24,(16711680&t.duration)>>16,(65280&t.duration)>>8,255&t.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&t.width)>>8,255&t.width,0,0,(65280&t.height)>>8,255&t.height,0,0]);return z(it.tkhd,e)},J=function(t){var e,i,r,s,n,a;return e=z(it.tfhd,new Uint8Array([0,0,0,58,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),n=Math.floor(t.baseMediaDecodeTime/xt),a=Math.floor(t.baseMediaDecodeTime%xt),i=z(it.tfdt,new Uint8Array([1,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,a>>>24&255,a>>>16&255,a>>>8&255,255&a])),92,"audio"===t.type?(r=et(t,92),z(it.traf,e,i,r)):(s=Z(t),r=et(t,s.length+92),z(it.traf,e,i,r,s))},W=function(t){return t.duration=t.duration||4294967295,z(it.trak,j(t),q(t))},tt=function(t){var e=new Uint8Array([0,0,0,0,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==t.type&&(e[e.length-1]=0),z(it.trex,e)},vt=function(t,e){var i=0,r=0,s=0,n=0;return t.length&&(void 0!==t[0].duration&&(i=1),void 0!==t[0].size&&(r=2),void 0!==t[0].flags&&(s=4),void 0!==t[0].compositionTimeOffset&&(n=8)),[0,0,i|r|s|n,1,(4278190080&t.length)>>>24,(16711680&t.length)>>>16,(65280&t.length)>>>8,255&t.length,(4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e]},bt=function(t,e){var i,r,s,n,a,o;for(e+=20+16*(n=t.samples||[]).length,s=vt(n,e),(r=new Uint8Array(s.length+16*n.length)).set(s),i=s.length,o=0;o>>24,r[i++]=(16711680&a.duration)>>>16,r[i++]=(65280&a.duration)>>>8,r[i++]=255&a.duration,r[i++]=(4278190080&a.size)>>>24,r[i++]=(16711680&a.size)>>>16,r[i++]=(65280&a.size)>>>8,r[i++]=255&a.size,r[i++]=a.flags.isLeading<<2|a.flags.dependsOn,r[i++]=a.flags.isDependedOn<<6|a.flags.hasRedundancy<<4|a.flags.paddingValue<<1|a.flags.isNonSyncSample,r[i++]=61440&a.flags.degradationPriority,r[i++]=15&a.flags.degradationPriority,r[i++]=(4278190080&a.compositionTimeOffset)>>>24,r[i++]=(16711680&a.compositionTimeOffset)>>>16,r[i++]=(65280&a.compositionTimeOffset)>>>8,r[i++]=255&a.compositionTimeOffset;return z(it.trun,r)},yt=function(t,e){var i,r,s,n,a,o;for(e+=20+8*(n=t.samples||[]).length,s=vt(n,e),(i=new Uint8Array(s.length+8*n.length)).set(s),r=s.length,o=0;o>>24,i[r++]=(16711680&a.duration)>>>16,i[r++]=(65280&a.duration)>>>8,i[r++]=255&a.duration,i[r++]=(4278190080&a.size)>>>24,i[r++]=(16711680&a.size)>>>16,i[r++]=(65280&a.size)>>>8,i[r++]=255&a.size;return z(it.trun,i)},et=function(t,e){return"audio"===t.type?yt(t,e):bt(t,e)};var Et,At,kt,Ct,It,Bt,Dt,Pt,Lt={ftyp:O=function(){return z(it.ftyp,rt,st,rt,nt)},mdat:function(t){return z(it.mdat,t)},moof:G,moov:V,initSegment:function(t){var e,i=O(),r=V(t);return(e=new Uint8Array(i.byteLength+r.byteLength)).set(i),e.set(r,i.byteLength),e}},zt=function(t){return t>>>0},Ft=function(t){var e="";return e+=String.fromCharCode(t[0]),e+=String.fromCharCode(t[1]),e+=String.fromCharCode(t[2]),e+=String.fromCharCode(t[3])},Rt=zt,Ot=Ft,Mt=function t(e,i){var r,s,n,a,o,h=[];if(!i.length)return null;for(r=0;r1?r+s:e.byteLength,n===i[0]&&(1===i.length?h.push(e.subarray(r+8,a)):(o=t(e.subarray(r+8,a),i.slice(1))).length&&(h=h.concat(o))),r=a;return h},Nt=function(t){for(var e=0,i=String.fromCharCode(t[e]),r="";"\0"!==i;)r+=i,e++,i=String.fromCharCode(t[e]);return r+=i},Gt=Tt.getUint64,Vt=function(t,e){var i="\0"!==e.scheme_id_uri,r=0===t&&Ht(e.presentation_time_delta)&&i,s=1===t&&Ht(e.presentation_time)&&i;return!(t>1)&&r||s},Ht=function(t){return void 0!==t||null!==t},Yt={parseEmsgBox:function(t){var e,i,r,s,n,a,o,h=4,d=t[0];if(0===d)h+=(e=Nt(t.subarray(h))).length,h+=(i=Nt(t.subarray(h))).length,r=(l=new DataView(t.buffer)).getUint32(h),h+=4,n=l.getUint32(h),h+=4,a=l.getUint32(h),h+=4,o=l.getUint32(h),h+=4;else if(1===d){var l;r=(l=new DataView(t.buffer)).getUint32(h),h+=4,s=Gt(t.subarray(h)),h+=8,a=l.getUint32(h),h+=4,o=l.getUint32(h),h+=4,h+=(e=Nt(t.subarray(h))).length,h+=(i=Nt(t.subarray(h))).length}var p={scheme_id_uri:e,value:i,timescale:r||1,presentation_time:s,presentation_time_delta:n,event_duration:a,id:o,message_data:new Uint8Array(t.subarray(h,t.byteLength))};return Vt(d,p)?p:void 0},scaleTime:function(t,e,i,r){return t||0===t?t/e:r+i/e}};function Wt(){if(At)return Et;At=1;return Et=function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),r={version:t[0],flags:new Uint8Array(t.subarray(1,4)),trackId:i.getUint32(4)},s=1&r.flags[2],n=2&r.flags[2],a=8&r.flags[2],o=16&r.flags[2],h=32&r.flags[2],d=65536&r.flags[0],l=131072&r.flags[0];return e=8,s&&(e+=4,r.baseDataOffset=i.getUint32(12),e+=4),n&&(r.sampleDescriptionIndex=i.getUint32(e),e+=4),a&&(r.defaultSampleDuration=i.getUint32(e),e+=4),o&&(r.defaultSampleSize=i.getUint32(e),e+=4),h&&(r.defaultSampleFlags=i.getUint32(e)),d&&(r.durationIsEmpty=!0),!s&&l&&(r.baseDataOffsetIsMoof=!0),r}}function jt(){if(Bt)return It;Bt=1;var t=Ct?kt:(Ct=1,kt=function(t){return{isLeading:(12&t[0])>>>2,dependsOn:3&t[0],isDependedOn:(192&t[1])>>>6,hasRedundancy:(48&t[1])>>>4,paddingValue:(14&t[1])>>>1,isNonSyncSample:1&t[1],degradationPriority:t[2]<<8|t[3]}});return It=function(e){var i,r={version:e[0],flags:new Uint8Array(e.subarray(1,4)),samples:[]},s=new DataView(e.buffer,e.byteOffset,e.byteLength),n=1&r.flags[2],a=4&r.flags[2],o=1&r.flags[1],h=2&r.flags[1],d=4&r.flags[1],l=8&r.flags[1],p=s.getUint32(4),u=8;for(n&&(r.dataOffset=s.getInt32(u),u+=4),a&&p&&(i={flags:t(e.subarray(u,u+4))},u+=4,o&&(i.duration=s.getUint32(u),u+=4),h&&(i.size=s.getUint32(u),u+=4),l&&(1===r.version?i.compositionTimeOffset=s.getInt32(u):i.compositionTimeOffset=s.getUint32(u),u+=4),r.samples.push(i),p--);p--;)i={},o&&(i.duration=s.getUint32(u),u+=4),h&&(i.size=s.getUint32(u),u+=4),d&&(i.flags=t(e.subarray(u,u+4)),u+=4),l&&(1===r.version?i.compositionTimeOffset=s.getInt32(u):i.compositionTimeOffset=s.getUint32(u),u+=4),r.samples.push(i);return r}}function qt(){if(Pt)return Dt;Pt=1;var t=zt,e=Tt.getUint64;return Dt=function(i){var r={version:i[0],flags:new Uint8Array(i.subarray(1,4))};return 1===r.version?r.baseMediaDecodeTime=e(i.subarray(4)):r.baseMediaDecodeTime=t(i[4]<<24|i[5]<<16|i[6]<<8|i[7]),r}}var Kt,Xt,Zt,Qt,$t,Jt,te,ee="undefined"!=typeof window?window:void 0!==l?l:"undefined"!=typeof self?self:{},ie=function(t,e,i){if(!t)return-1;for(var r=i;r11?(s.codec+=".",s.codec+=ue(l[9]),s.codec+=ue(l[10]),s.codec+=ue(l[11])):s.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(s.codec)?(l=p.subarray(28),"esds"===ce(l.subarray(4,8))&&l.length>20&&0!==l[19]?(s.codec+="."+ue(l[19]),s.codec+="."+ue(l[20]>>>2&63).replace(/^0/,"")):s.codec="mp4a.40.2"):s.codec=s.codec.toLowerCase())}var u=fe(t,["mdia","mdhd"])[0];u&&(s.timescale=Jt(u)),i.push(s)})),i},te=function(t,e){return void 0===e&&(e=0),fe(t,["emsg"]).map((function(t){var i=me.parseEmsgBox(new Uint8Array(t)),r=Se(i.message_data);return{cueTime:me.scaleTime(i.presentation_time,i.timescale,i.presentation_time_delta,e),duration:me.scaleTime(i.event_duration,i.timescale),frames:r}}))};var we,Ue={findBox:fe,parseType:ce,timescale:Kt,startTime:Xt,compositionStartTime:Zt,videoTrackIds:Qt,tracks:$t,getTimescaleFromMediaHeader:Jt,getEmsgID3:te},Te=function(t,e){var i={size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}};return i.dataOffset=e,i.compositionTimeOffset=t.pts-t.dts,i.duration=t.duration,i.size=4*t.length,i.size+=t.byteLength,t.keyFrame&&(i.flags.dependsOn=2,i.flags.isNonSyncSample=0),i},xe={groupNalsIntoFrames:function(t){var e,i,r=[],s=[];for(s.byteLength=0,s.nalCount=0,s.duration=0,r.byteLength=0,e=0;e1&&(e=t.shift(),t.byteLength-=e.byteLength,t.nalCount-=e.nalCount,t[0][0].dts=e.dts,t[0][0].pts=e.pts,t[0][0].duration+=e.duration),t},generateSampleTable:function(t,e){var i,r,s,n,a,o=e||0,h=[];for(i=0;iIe.ONE_SECOND_IN_TS/2))){for((a=Ce()[t.samplerate])||(a=e[0].data),o=0;o=i?t:(e.minSegmentDts=1/0,t.filter((function(t){return t.dts>=i&&(e.minSegmentDts=Math.min(e.minSegmentDts,t.dts),e.minSegmentPts=e.minSegmentDts,!0)})))},generateSampleTable:function(t){var e,i,r=[];for(e=0;e=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(t),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},Ne.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},Ne.prototype.addText=function(t){this.rows[this.rowIdx]+=t},Ne.prototype.backspace=function(){if(!this.isEmpty()){var t=this.rows[this.rowIdx];this.rows[this.rowIdx]=t.substr(0,t.length-1)}};var Ge=function(t,e,i){this.serviceNum=t,this.text="",this.currentWindow=new Ne(-1),this.windows=[],this.stream=i,"string"==typeof e&&this.createTextDecoder(e)};Ge.prototype.init=function(t,e){this.startPts=t;for(var i=0;i<8;i++)this.windows[i]=new Ne(i),"function"==typeof e&&(this.windows[i].beforeRowOverflow=e)},Ge.prototype.setCurrentWindow=function(t){this.currentWindow=this.windows[t]},Ge.prototype.createTextDecoder=function(t){if("undefined"==typeof TextDecoder)this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(t)}catch(e){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+t+" encoding. "+e})}};var Ve=function t(e){e=e||{},t.prototype.init.call(this);var i,r=this,s=e.captionServices||{},n={};Object.keys(s).forEach((function(t){i=s[t],/^SERVICE/.test(t)&&(n[t]=i.encoding)})),this.serviceEncodings=n,this.current708Packet=null,this.services={},this.push=function(t){3===t.type?(r.new708Packet(),r.add708Bytes(t)):(null===r.current708Packet&&r.new708Packet(),r.add708Bytes(t))}};Ve.prototype=new ze,Ve.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},Ve.prototype.add708Bytes=function(t){var e=t.ccData,i=e>>>8,r=255&e;this.current708Packet.ptsVals.push(t.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(r)},Ve.prototype.push708Packet=function(){var t=this.current708Packet,e=t.data,i=null,r=null,s=0,n=e[s++];for(t.seq=n>>6,t.sizeCode=63&n;s>5)&&r>0&&(i=n=e[s++]),this.pushServiceBlock(i,s,r),r>0&&(s+=r-1)},Ve.prototype.pushServiceBlock=function(t,e,i){var r,s=e,n=this.current708Packet.data,a=this.services[t];for(a||(a=this.initService(t,s));s>5,n.rowLock=(16&r)>>4,n.columnLock=(8&r)>>3,n.priority=7&r,r=i[++t],n.relativePositioning=(128&r)>>7,n.anchorVertical=127&r,r=i[++t],n.anchorHorizontal=r,r=i[++t],n.anchorPoint=(240&r)>>4,n.rowCount=15&r,r=i[++t],n.columnCount=63&r,r=i[++t],n.windowStyle=(56&r)>>3,n.penStyle=7&r,n.virtualRowCount=n.rowCount+1,t},Ve.prototype.setWindowAttributes=function(t,e){var i=this.current708Packet.data,r=i[t],s=e.currentWindow.winAttr;return r=i[++t],s.fillOpacity=(192&r)>>6,s.fillRed=(48&r)>>4,s.fillGreen=(12&r)>>2,s.fillBlue=3&r,r=i[++t],s.borderType=(192&r)>>6,s.borderRed=(48&r)>>4,s.borderGreen=(12&r)>>2,s.borderBlue=3&r,r=i[++t],s.borderType+=(128&r)>>5,s.wordWrap=(64&r)>>6,s.printDirection=(48&r)>>4,s.scrollDirection=(12&r)>>2,s.justify=3&r,r=i[++t],s.effectSpeed=(240&r)>>4,s.effectDirection=(12&r)>>2,s.displayEffect=3&r,t},Ve.prototype.flushDisplayed=function(t,e){for(var i=[],r=0;r<8;r++)e.windows[r].visible&&!e.windows[r].isEmpty()&&i.push(e.windows[r].getText());e.endPts=t,e.text=i.join("\n\n"),this.pushCaption(e),e.startPts=t},Ve.prototype.pushCaption=function(t){""!==t.text&&(this.trigger("data",{startPts:t.startPts,endPts:t.endPts,text:t.text,stream:"cc708_"+t.serviceNum}),t.text="",t.startPts=t.endPts)},Ve.prototype.displayWindows=function(t,e){var i=this.current708Packet.data[++t],r=this.getPts(t);this.flushDisplayed(r,e);for(var s=0;s<8;s++)i&1<>4,s.offset=(12&r)>>2,s.penSize=3&r,r=i[++t],s.italics=(128&r)>>7,s.underline=(64&r)>>6,s.edgeType=(56&r)>>3,s.fontStyle=7&r,t},Ve.prototype.setPenColor=function(t,e){var i=this.current708Packet.data,r=i[t],s=e.currentWindow.penColor;return r=i[++t],s.fgOpacity=(192&r)>>6,s.fgRed=(48&r)>>4,s.fgGreen=(12&r)>>2,s.fgBlue=3&r,r=i[++t],s.bgOpacity=(192&r)>>6,s.bgRed=(48&r)>>4,s.bgGreen=(12&r)>>2,s.bgBlue=3&r,r=i[++t],s.edgeRed=(48&r)>>4,s.edgeGreen=(12&r)>>2,s.edgeBlue=3&r,t},Ve.prototype.setPenLocation=function(t,e){var i=this.current708Packet.data,r=i[t],s=e.currentWindow.penLoc;return e.currentWindow.pendingNewLine=!0,r=i[++t],s.row=15&r,r=i[++t],s.column=63&r,t},Ve.prototype.reset=function(t,e){var i=this.getPts(t);return this.flushDisplayed(i,e),this.initService(e.serviceNum,t)};var He={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Ye=function(t){return null===t?"":(t=He[t]||t,String.fromCharCode(t))},We=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],je=function(){for(var t=[],e=15;e--;)t.push({text:"",indent:0,offset:0});return t},qe=function t(e,i){t.prototype.init.call(this),this.field_=e||0,this.dataChannel_=i||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,r,s,n;if((e=32639&t.ccData)!==this.lastControlCode_){if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),r=e>>>8,s=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(t.pts);else if(e===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(t.pts);else if(e===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(t.pts);else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=je();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=je();else if(e===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(t.pts),this.displayed_=je()),this.mode_="paintOn",this.startPts_=t.pts;else if(this.isSpecialCharacter(r,s))n=Ye((r=(3&r)<<8)|s),this[this.mode_](t.pts,n),this.column_++;else if(this.isExtCharacter(r,s))"popOn"===this.mode_?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),n=Ye((r=(3&r)<<8)|s),this[this.mode_](t.pts,n),this.column_++;else if(this.isMidRowCode(r,s))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14&~s||this.addFormatting(t.pts,["i"]),1&~s||this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(r,s)){var a=3&s;this.nonDisplayed_[this.row_].offset=a,this.column_+=a}else if(this.isPAC(r,s)){var o=We.indexOf(7968&e);if("rollUp"===this.mode_&&(o-this.rollUpRows_+1<0&&(o=this.rollUpRows_-1),this.setRollUp(t.pts,o)),o!==this.row_&&o>=0&&o<=14&&(this.clearFormatting(t.pts),this.row_=o),1&s&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),!(16&~e)){var h=(14&e)>>1;this.column_=4*h,this.nonDisplayed_[this.row_].indent+=h}this.isColorPAC(s)&&(14&~s||this.addFormatting(t.pts,["i"]))}else this.isNormalChar(r)&&(0===s&&(s=null),n=Ye(r),n+=Ye(s),this[this.mode_](t.pts,n),this.column_+=n.length)}else this.lastControlCode_=null}};qe.prototype=new ze,qe.prototype.flushDisplayed=function(t){var e=this,i=function(t){e.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+t+"."})},r=[];this.displayed_.forEach((function(t,e){if(t&&t.text&&t.text.length){try{t.text=t.text.trim()}catch(t){i(e)}t.text.length&&r.push({text:t.text,line:e+1,position:10+Math.min(70,10*t.indent)+2.5*t.offset})}else null==t&&i(e)})),r.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,content:r,stream:this.name_})},qe.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=je(),this.nonDisplayed_=je(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},qe.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},qe.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},qe.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},qe.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},qe.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=33&&e<=35},qe.prototype.isPAC=function(t,e){return t>=this.BASE_&&t=64&&e<=127},qe.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},qe.prototype.isNormalChar=function(t){return t>=32&&t<=127},qe.prototype.setRollUp=function(t,e){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(t),this.nonDisplayed_=je(),this.displayed_=je()),void 0!==e&&e!==this.row_)for(var i=0;i"}),"");this[this.mode_](t,i)},qe.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce((function(t,e){return t+""}),"");this.formatting_=[],this[this.mode_](t,e)}},qe.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_].text;i+=e,this.nonDisplayed_[this.row_].text=i},qe.prototype.rollUp=function(t,e){var i=this.displayed_[this.row_].text;i+=e,this.displayed_[this.row_].text=i},qe.prototype.shiftRowsUp_=function(){var t;for(t=0;te&&(i=-1);Math.abs(e-t)>4294967296;)t+=8589934592*i;return t},$e=function t(e){var i,r;t.prototype.init.call(this),this.type_=e||Ze,this.push=function(t){"metadata"!==t.type?this.type_!==Ze&&t.type!==this.type_||(void 0===r&&(r=t.dts),t.dts=Qe(t.dts,r),t.pts=Qe(t.pts,r),i=t.dts,this.trigger("data",t)):this.trigger("data",t)},this.flush=function(){r=i,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){r=void 0,i=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};$e.prototype=new U;var Je,ti=$e,ei=Qe,ii=Xe,ri=le;(Je=function(t){var e,i={descriptor:t&&t.descriptor},r=0,s=[],n=0;if(Je.prototype.init.call(this),this.dispatchType=ii.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(e=0;e>>2;l*=4,l+=3&d[7],o.timeStamp=l,void 0===e.pts&&void 0===e.dts&&(e.pts=o.timeStamp,e.dts=o.timeStamp),this.trigger("timestamp",o)}e.frames.push(o),i+=10,i+=a}while(i>>4>1&&(r+=e[r]+1),0===i.pid)i.type="pat",t(e.subarray(r),i),this.trigger("data",i);else if(i.pid===this.pmtPid)for(i.type="pmt",t(e.subarray(r),i),this.trigger("data",i);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([e,r,i]):this.processPes_(e,r,i)},this.processPes_=function(t,e,i){i.pid===this.programMapTable.video?i.streamType=li.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=li.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=t.subarray(e),this.trigger("data",i)}},ni.prototype=new hi,ni.STREAM_TYPES={h264:27,adts:15},ai=function(){var t,e=this,i=!1,r={data:[],size:0},s={data:[],size:0},n={data:[],size:0},a=function(t,i,r){var s,n,a=new Uint8Array(t.size),o={type:i},h=0,d=0;if(t.data.length&&!(t.size<9)){for(o.trackId=t.data[0].pid,h=0;h>>3,p.pts*=4,p.pts+=(6&l[13])>>>1,p.dts=p.pts,64&u&&(p.dts=(14&l[14])<<27|(255&l[15])<<20|(254&l[16])<<12|(255&l[17])<<5|(254&l[18])>>>3,p.dts*=4,p.dts+=(6&l[18])>>>1)),p.data=l.subarray(9+l[8])),s="video"===i||o.packetLength<=t.size,(r||s)&&(t.size=0,t.data.length=0),s&&e.trigger("data",o)}};ai.prototype.init.call(this),this.push=function(o){({pat:function(){},pes:function(){var t,e;switch(o.streamType){case li.H264_STREAM_TYPE:t=r,e="video";break;case li.ADTS_STREAM_TYPE:t=s,e="audio";break;case li.METADATA_STREAM_TYPE:t=n,e="timed-metadata";break;default:return}o.payloadUnitStartIndicator&&a(t,e,!0),t.data.push(o),t.size+=o.data.byteLength},pmt:function(){var r={type:"metadata",tracks:[]};null!==(t=o.programMapTable).video&&r.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.video,codec:"avc",type:"video"}),null!==t.audio&&r.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.audio,codec:"adts",type:"audio"}),i=!0,e.trigger("data",r)}})[o.type]()},this.reset=function(){r.size=0,r.data.length=0,s.size=0,s.data.length=0,this.trigger("reset")},this.flushStreams_=function(){a(r,"video"),a(s,"audio"),a(n,"timed-metadata")},this.flush=function(){if(!i&&t){var r={type:"metadata",tracks:[]};null!==t.video&&r.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.video,codec:"avc",type:"video"}),null!==t.audio&&r.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.audio,codec:"adts",type:"audio"}),e.trigger("data",r)}i=!1,this.flushStreams_(),this.trigger("done")}},ai.prototype=new hi;var fi={PAT_PID:0,MP2T_PACKET_LENGTH:ui,TransportPacketStream:si,TransportParseStream:ni,ElementaryStream:ai,TimestampRolloverStream:pi,CaptionStream:di.CaptionStream,Cea608Stream:di.Cea608Stream,Cea708Stream:di.Cea708Stream,MetadataStream:oi};for(var ci in li)li.hasOwnProperty(ci)&&(fi[ci]=li[ci]);var mi,gi=fi,_i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],yi=function(t,e){var i=t[e+6]<<21|t[e+7]<<14|t[e+8]<<7|t[e+9];return i=i>=0?i:0,(16&t[e+5])>>4?i+20:i+10},bi=function t(e,i){return e.length-i<10||e[i]!=="I".charCodeAt(0)||e[i+1]!=="D".charCodeAt(0)||e[i+2]!=="3".charCodeAt(0)?i:t(e,i+=yi(e,i))},vi=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},Si={isLikelyAacData:function(t){var e=bi(t,0);return t.length>=e+2&&!(255&~t[e])&&!(240&~t[e+1])&&16==(22&t[e+1])},parseId3TagSize:yi,parseAdtsSize:function(t,e){var i=(224&t[e+5])>>5,r=t[e+4]<<3;return 6144&t[e+3]|r|i},parseType:function(t,e){return t[e]==="I".charCodeAt(0)&&t[e+1]==="D".charCodeAt(0)&&t[e+2]==="3".charCodeAt(0)?"timed-metadata":!0&t[e]&&!(240&~t[e+1])?"audio":null},parseSampleRate:function(t){for(var e=0;e+5>>2];e++}return null},parseAacTimestamp:function(t){var e,i,r;e=10,64&t[5]&&(e+=4,e+=vi(t.subarray(10,14)));do{if((i=vi(t.subarray(e+4,e+8)))<1)return null;if("PRIV"===String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3])){r=t.subarray(e+10,e+i+10);for(var s=0;s>>2;return o*=4,o+=3&a[7]}break}}e+=10,e+=i}while(e=3;)if(t[h]!=="I".charCodeAt(0)||t[h+1]!=="D".charCodeAt(0)||t[h+2]!=="3".charCodeAt(0))if(255&~t[h]||240&~t[h+1])h++;else{if(t.length-h<7)break;if(h+(o=wi.parseAdtsSize(t,h))>t.length)break;n={type:"audio",data:t.subarray(h,h+o),pts:e,dts:e},this.trigger("data",n),h+=o}else{if(t.length-h<10)break;if(h+(o=wi.parseId3TagSize(t,h))>t.length)break;s={type:"timed-metadata",data:t.subarray(h,h+o)},this.trigger("data",s),h+=o}r=t.length-h,t=r>0?t.subarray(h):new Uint8Array},this.reset=function(){t=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){t=new Uint8Array,this.trigger("endedtimeline")}}).prototype=new U;var Ui,Ti,xi,Ei,Ai=mi,ki=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Ci=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Ii=U,Bi=Lt,Di=xe,Pi=Be,Li=Pe,zi=gi,Fi=E,Ri=D,Oi=St.H264Stream,Mi=Ai,Ni=Si.isLikelyAacData,Gi=E.ONE_SECOND_IN_TS,Vi=ki,Hi=Ci,Yi=function(t,e){e.stream=t,this.trigger("log",e)},Wi=function(t,e){for(var i=Object.keys(e),r=0;r=-1e4&&i<=45e3&&(!r||o>i)&&(r=n,o=i));return r?r.gop:null},this.alignGopsAtStart_=function(t){var e,i,r,s,n,o,h,d;for(n=t.byteLength,o=t.nalCount,h=t.duration,e=i=0;er.pts?e++:(i++,n-=s.byteLength,o-=s.nalCount,h-=s.duration);return 0===i?t:i===t.length?null:((d=t.slice(i)).byteLength=n,d.duration=h,d.nalCount=o,d.pts=d[0].pts,d.dts=d[0].dts,d)},this.alignGopsAtEnd_=function(t){var e,i,r,s,n,o,h;for(e=a.length-1,i=t.length-1,n=null,o=!1;e>=0&&i>=0;){if(r=a[e],s=t[i],r.pts===s.pts){o=!0;break}r.pts>s.pts?e--:(e===a.length-1&&(n=i),i--)}if(!o&&null===n)return null;if(0===(h=o?i:n))return t;var d=t.slice(h),l=d.reduce((function(t,e){return t.byteLength+=e.byteLength,t.duration+=e.duration,t.nalCount+=e.nalCount,t}),{byteLength:0,duration:0,nalCount:0});return d.byteLength=l.byteLength,d.duration=l.duration,d.nalCount=l.nalCount,d.pts=d[0].pts,d.dts=d[0].dts,d},this.alignGopsWith=function(t){a=t}},Ui.prototype=new Ii,Ei=function(t,e){this.numberOfTracks=0,this.metadataStream=e,void 0!==(t=t||{}).remux?this.remuxTracks=!!t.remux:this.remuxTracks=!0,"boolean"==typeof t.keepOriginalTimestamps?this.keepOriginalTimestamps=t.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,Ei.prototype.init.call(this),this.push=function(t){return t.content||t.text?this.pendingCaptions.push(t):t.frames?this.pendingMetadata.push(t):(this.pendingTracks.push(t.track),this.pendingBytes+=t.boxes.byteLength,"video"===t.track.type&&(this.videoTrack=t.track,this.pendingBoxes.push(t.boxes)),void("audio"===t.track.type&&(this.audioTrack=t.track,this.pendingBoxes.unshift(t.boxes))))}},Ei.prototype=new Ii,Ei.prototype.flush=function(t){var e,i,r,s,n=0,a={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,Hi.forEach((function(t){a.info[t]=this.videoTrack[t]}),this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,Vi.forEach((function(t){a.info[t]=this.audioTrack[t]}),this)),this.videoTrack||this.audioTrack){for(1===this.pendingTracks.length?a.type=this.pendingTracks[0].type:a.type="combined",this.emittedTracks+=this.pendingTracks.length,r=Bi.initSegment(this.pendingTracks),a.initSegment=new Uint8Array(r.byteLength),a.initSegment.set(r),a.data=new Uint8Array(this.pendingBytes),s=0;s=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},Ei.prototype.setRemux=function(t){this.remuxTracks=t},(xi=function(t){var e,i,r=this,s=!0;xi.prototype.init.call(this),t=t||{},this.baseMediaDecodeTime=t.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var s={};this.transmuxPipeline_=s,s.type="aac",s.metadataStream=new zi.MetadataStream,s.aacStream=new Mi,s.audioTimestampRolloverStream=new zi.TimestampRolloverStream("audio"),s.timedMetadataTimestampRolloverStream=new zi.TimestampRolloverStream("timed-metadata"),s.adtsStream=new Ri,s.coalesceStream=new Ei(t,s.metadataStream),s.headOfPipeline=s.aacStream,s.aacStream.pipe(s.audioTimestampRolloverStream).pipe(s.adtsStream),s.aacStream.pipe(s.timedMetadataTimestampRolloverStream).pipe(s.metadataStream).pipe(s.coalesceStream),s.metadataStream.on("timestamp",(function(t){s.aacStream.setTimestamp(t.timeStamp)})),s.aacStream.on("data",(function(n){"timed-metadata"!==n.type&&"audio"!==n.type||s.audioSegmentStream||(i=i||{timelineStartInfo:{baseMediaDecodeTime:r.baseMediaDecodeTime},codec:"adts",type:"audio"},s.coalesceStream.numberOfTracks++,s.audioSegmentStream=new Ti(i,t),s.audioSegmentStream.on("log",r.getLogTrigger_("audioSegmentStream")),s.audioSegmentStream.on("timingInfo",r.trigger.bind(r,"audioTimingInfo")),s.adtsStream.pipe(s.audioSegmentStream).pipe(s.coalesceStream),r.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!e}))})),s.coalesceStream.on("data",this.trigger.bind(this,"data")),s.coalesceStream.on("done",this.trigger.bind(this,"done")),Wi(this,s)},this.setupTsPipeline=function(){var s={};this.transmuxPipeline_=s,s.type="ts",s.metadataStream=new zi.MetadataStream,s.packetStream=new zi.TransportPacketStream,s.parseStream=new zi.TransportParseStream,s.elementaryStream=new zi.ElementaryStream,s.timestampRolloverStream=new zi.TimestampRolloverStream,s.adtsStream=new Ri,s.h264Stream=new Oi,s.captionStream=new zi.CaptionStream(t),s.coalesceStream=new Ei(t,s.metadataStream),s.headOfPipeline=s.packetStream,s.packetStream.pipe(s.parseStream).pipe(s.elementaryStream).pipe(s.timestampRolloverStream),s.timestampRolloverStream.pipe(s.h264Stream),s.timestampRolloverStream.pipe(s.adtsStream),s.timestampRolloverStream.pipe(s.metadataStream).pipe(s.coalesceStream),s.h264Stream.pipe(s.captionStream).pipe(s.coalesceStream),s.elementaryStream.on("data",(function(n){var a;if("metadata"===n.type){for(a=n.tracks.length;a--;)e||"video"!==n.tracks[a].type?i||"audio"!==n.tracks[a].type||((i=n.tracks[a]).timelineStartInfo.baseMediaDecodeTime=r.baseMediaDecodeTime):(e=n.tracks[a]).timelineStartInfo.baseMediaDecodeTime=r.baseMediaDecodeTime;e&&!s.videoSegmentStream&&(s.coalesceStream.numberOfTracks++,s.videoSegmentStream=new Ui(e,t),s.videoSegmentStream.on("log",r.getLogTrigger_("videoSegmentStream")),s.videoSegmentStream.on("timelineStartInfo",(function(e){i&&!t.keepOriginalTimestamps&&(i.timelineStartInfo=e,s.audioSegmentStream.setEarliestDts(e.dts-r.baseMediaDecodeTime))})),s.videoSegmentStream.on("processedGopsInfo",r.trigger.bind(r,"gopInfo")),s.videoSegmentStream.on("segmentTimingInfo",r.trigger.bind(r,"videoSegmentTimingInfo")),s.videoSegmentStream.on("baseMediaDecodeTime",(function(t){i&&s.audioSegmentStream.setVideoBaseMediaDecodeTime(t)})),s.videoSegmentStream.on("timingInfo",r.trigger.bind(r,"videoTimingInfo")),s.h264Stream.pipe(s.videoSegmentStream).pipe(s.coalesceStream)),i&&!s.audioSegmentStream&&(s.coalesceStream.numberOfTracks++,s.audioSegmentStream=new Ti(i,t),s.audioSegmentStream.on("log",r.getLogTrigger_("audioSegmentStream")),s.audioSegmentStream.on("timingInfo",r.trigger.bind(r,"audioTimingInfo")),s.audioSegmentStream.on("segmentTimingInfo",r.trigger.bind(r,"audioSegmentTimingInfo")),s.adtsStream.pipe(s.audioSegmentStream).pipe(s.coalesceStream)),r.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!e})}})),s.coalesceStream.on("data",this.trigger.bind(this,"data")),s.coalesceStream.on("id3Frame",(function(t){t.dispatchType=s.metadataStream.dispatchType,r.trigger("id3Frame",t)})),s.coalesceStream.on("caption",this.trigger.bind(this,"caption")),s.coalesceStream.on("done",this.trigger.bind(this,"done")),Wi(this,s)},this.setBaseMediaDecodeTime=function(r){var s=this.transmuxPipeline_;t.keepOriginalTimestamps||(this.baseMediaDecodeTime=r),i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,Li.clearDtsInfo(i),s.audioTimestampRolloverStream&&s.audioTimestampRolloverStream.discontinuity()),e&&(s.videoSegmentStream&&(s.videoSegmentStream.gopCache_=[]),e.timelineStartInfo.dts=void 0,e.timelineStartInfo.pts=void 0,Li.clearDtsInfo(e),s.captionStream.reset()),s.timestampRolloverStream&&s.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(t){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(t)},this.setRemux=function(e){var i=this.transmuxPipeline_;t.remux=e,i&&i.coalesceStream&&i.coalesceStream.setRemux(e)},this.alignGopsWith=function(t){e&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(t)},this.getLogTrigger_=function(t){var e=this;return function(i){i.stream=t,e.trigger("log",i)}},this.push=function(t){if(s){var e=Ni(t);e&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():e||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),s=!1}this.transmuxPipeline_.headOfPipeline.push(t)},this.flush=function(){s=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}}).prototype=new Ii;var Ki,Xi={Transmuxer:xi,VideoSegmentStream:Ui,AudioSegmentStream:Ti,AUDIO_PROPERTIES:Vi,VIDEO_PROPERTIES:Hi,generateSegmentTimingInfo:qi},Zi=Le.discardEmulationPreventionBytes,Qi=Ke.CaptionStream,$i=Mt,Ji=qt(),tr=jt(),er=Wt(),ir=ee,rr=function(t,e){for(var i=t,r=0;r0?Ji(l[0]).baseMediaDecodeTime:0,u=$i(a,["trun"]);e===d&&u.length>0&&(i=function(t,e,i){var r=e,s=i.defaultSampleDuration||0,n=i.defaultSampleSize||0,a=i.trackId,o=[];return t.forEach((function(t){var e=tr(t).samples;e.forEach((function(t){void 0===t.duration&&(t.duration=s),void 0===t.size&&(t.size=n),t.trackId=a,t.dts=r,void 0===t.compositionTimeOffset&&(t.compositionTimeOffset=0),"bigint"==typeof r?(t.pts=r+ir.BigInt(t.compositionTimeOffset),r+=ir.BigInt(t.duration)):(t.pts=r+t.compositionTimeOffset,r+=t.duration)})),o=o.concat(e)})),o}(u,p,h),r=function(t,e,i){var r,s,n,a,o=new DataView(t.buffer,t.byteOffset,t.byteLength),h={logs:[],seiNals:[]};for(s=0;s+40;){var h=e.shift();this.parse(h,n,a)}return o=function(t,e,i){if(null===e)return null;var r=sr(t,e)[e]||{};return{seiNals:r.seiNals,logs:r.logs,timescale:i}}(t,i,r),o&&o.logs&&(s.logs=s.logs.concat(o.logs)),null!==o&&o.seiNals?(this.pushNals(o.seiNals),this.flushStream(),s):s.logs.length?{logs:s.logs,captions:[],captionStreams:[]}:null},this.pushNals=function(e){if(!this.isInitialized()||!e||0===e.length)return null;e.forEach((function(e){t.push(e)}))},this.flushStream=function(){if(!this.isInitialized())return null;n?t.partialFlush():t.flush()},this.clearParsedCaptions=function(){s.captions=[],s.captionStreams={},s.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;t.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){e=[],i=null,r=null,s?this.clearParsedCaptions():s={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},ar={generator:Lt,probe:Ue,Transmuxer:Xi.Transmuxer,AudioSegmentStream:Xi.AudioSegmentStream,VideoSegmentStream:Xi.VideoSegmentStream,CaptionParser:nr};Ki=function(t,e){var i,r=0,s=16384,n=function(t,e){var i,r=t.position+e;r0)throw new Error("Attempted to create new NAL wihout closing the old one");r=this.length,this.length+=4,this.position=this.length},this.endNalUnit=function(t){var e,i;this.length===r+4?this.length-=4:r>0&&(e=r+4,i=this.length-e,this.position=r,this.view.setUint32(this.position,i),this.position=this.length,t&&t.push(this.bytes.subarray(e,e+i))),r=0},this.writeMetaDataDouble=function(t,e){var i;if(n(this,2+t.length+9),this.view.setUint16(this.position,t.length),this.position+=2,"width"===t)this.bytes.set(a,this.position),this.position+=5;else if("height"===t)this.bytes.set(o,this.position),this.position+=6;else if("videocodecid"===t)this.bytes.set(h,this.position),this.position+=12;else for(i=0;i>>16,this.bytes[14]=(65280&t)>>>8,this.bytes[15]=(255&t)>>>0;break;case Ki.AUDIO_TAG:this.bytes[11]=175,this.bytes[12]=e?0:1;break;case Ki.METADATA_TAG:this.position=11,this.view.setUint8(this.position,2),this.position++,this.view.setUint16(this.position,10),this.position+=2,this.bytes.set([111,110,77,101,116,97,68,97,116,97],this.position),this.position+=10,this.bytes[this.position]=8,this.position++,this.view.setUint32(this.position,r),this.position=this.length,this.bytes.set([0,0,9],this.position),this.position+=3,this.length=this.position}return i=this.length-11,this.bytes[1]=(16711680&i)>>>16,this.bytes[2]=(65280&i)>>>8,this.bytes[3]=(255&i)>>>0,this.bytes[4]=(16711680&this.dts)>>>16,this.bytes[5]=(65280&this.dts)>>>8,this.bytes[6]=(255&this.dts)>>>0,this.bytes[7]=(4278190080&this.dts)>>>24,this.bytes[8]=0,this.bytes[9]=0,this.bytes[10]=0,n(this,4),this.view.setUint32(this.length,this.length),this.length+=4,this.position+=4,this.bytes=this.bytes.subarray(0,this.length),this.frameTime=Ki.frameTime(this.bytes),this}},Ki.AUDIO_TAG=8,Ki.VIDEO_TAG=9,Ki.METADATA_TAG=18,Ki.isAudioFrame=function(t){return Ki.AUDIO_TAG===t[0]},Ki.isVideoFrame=function(t){return Ki.VIDEO_TAG===t[0]},Ki.isMetaData=function(t){return Ki.METADATA_TAG===t[0]},Ki.isKeyFrame=function(t){return Ki.isVideoFrame(t)?23===t[11]:!!Ki.isAudioFrame(t)||!!Ki.isMetaData(t)},Ki.frameTime=function(t){var e=t[4]<<16;return e|=t[5]<<8,e|=t[6]|0,e|=t[7]<<24};var or=Ki,hr=function t(e){this.numberOfTracks=0,this.metadataStream=e.metadataStream,this.videoTags=[],this.audioTags=[],this.videoTrack=null,this.audioTrack=null,this.pendingCaptions=[],this.pendingMetadata=[],this.pendingTracks=0,this.processedTracks=0,t.prototype.init.call(this),this.push=function(t){return t.content||t.text?this.pendingCaptions.push(t):t.frames?this.pendingMetadata.push(t):("video"===t.track.type&&(this.videoTrack=t.track,this.videoTags=t.tags,this.pendingTracks++),void("audio"===t.track.type&&(this.audioTrack=t.track,this.audioTags=t.tags,this.pendingTracks++)))}};(hr.prototype=new U).flush=function(t){var e,i,r,s,n={tags:{},captions:[],captionStreams:{},metadata:[]};if(this.pendingTracks=r[0]&&(a=r.shift(),this.writeMetaDataTags(o,a)),(t.extraData!==e||s.pts-a>=1e3)&&(this.writeMetaDataTags(o,s.pts),e=t.extraData,a=s.pts),(n=new gr(gr.AUDIO_TAG)).pts=s.pts,n.dts=s.dts,n.writeBytes(s.data),o.push(n.finalize());r.length=0,e=null,this.trigger("data",{track:t,tags:o.list}),this.trigger("done","AudioSegmentStream")}else this.trigger("done","AudioSegmentStream")},this.writeMetaDataTags=function(e,i){var r;(r=new gr(gr.METADATA_TAG)).pts=i,r.dts=i,r.writeMetaDataDouble("audiocodecid",10),r.writeMetaDataBoolean("stereo",2===t.channelcount),r.writeMetaDataDouble("audiosamplerate",t.samplerate),r.writeMetaDataDouble("audiosamplesize",16),e.push(r.finalize()),(r=new gr(gr.AUDIO_TAG,!0)).pts=i,r.dts=i,r.view.setUint16(r.position,t.extraData),r.position+=2,r.length=Math.max(r.length,r.position),e.push(r.finalize())},this.onVideoKeyFrame=function(t){r.push(t)}}).prototype=new mr,(lr=function(t){var e,i,r=[];lr.prototype.init.call(this),this.finishFrame=function(r,s){if(s){if(e&&t&&t.newMetadata&&(s.keyFrame||0===r.length)){var n=fr(e,s.dts).finalize(),a=cr(t,s.dts).finalize();n.metaDataTag=a.metaDataTag=!0,r.push(n),r.push(a),t.newMetadata=!1,this.trigger("keyframe",s.dts)}s.endNalUnit(),r.push(s.finalize()),i=null}},this.push=function(e){ur(t,e),e.pts=Math.round(e.pts/90),e.dts=Math.round(e.dts/90),r.push(e)},this.flush=function(){for(var s,n=new Sr;r.length&&"access_unit_delimiter_rbsp"!==r[0].nalUnitType;)r.shift();if(0!==r.length){for(;r.length;)"seq_parameter_set_rbsp"===(s=r.shift()).nalUnitType?(t.newMetadata=!0,e=s.config,t.width=e.width,t.height=e.height,t.sps=[s.data],t.profileIdc=e.profileIdc,t.levelIdc=e.levelIdc,t.profileCompatibility=e.profileCompatibility,i.endNalUnit()):"pic_parameter_set_rbsp"===s.nalUnitType?(t.newMetadata=!0,t.pps=[s.data],i.endNalUnit()):"access_unit_delimiter_rbsp"===s.nalUnitType?(i&&this.finishFrame(n,i),(i=new gr(gr.VIDEO_TAG)).pts=s.pts,i.dts=s.dts):("slice_layer_without_partitioning_rbsp_idr"===s.nalUnitType&&(i.keyFrame=!0),i.endNalUnit()),i.startNalUnit(),i.writeBytes(s.data);i&&this.finishFrame(n,i),this.trigger("data",{track:t,tags:n.list}),this.trigger("done","VideoSegmentStream")}else this.trigger("done","VideoSegmentStream")}}).prototype=new mr,dr=function(t){var e,i,r,s,n,a,o,h,d,l,p,u,f=this;dr.prototype.init.call(this),t=t||{},this.metadataStream=new _r.MetadataStream,t.metadataStream=this.metadataStream,e=new _r.TransportPacketStream,i=new _r.TransportParseStream,r=new _r.ElementaryStream,s=new _r.TimestampRolloverStream("video"),n=new _r.TimestampRolloverStream("audio"),a=new _r.TimestampRolloverStream("timed-metadata"),o=new yr,h=new br,u=new vr(t),e.pipe(i).pipe(r),r.pipe(s).pipe(h),r.pipe(n).pipe(o),r.pipe(a).pipe(this.metadataStream).pipe(u),p=new _r.CaptionStream(t),h.pipe(p).pipe(u),r.on("data",(function(t){var e,i,r;if("metadata"===t.type){for(e=t.tracks.length;e--;)"video"===t.tracks[e].type?i=t.tracks[e]:"audio"===t.tracks[e].type&&(r=t.tracks[e]);i&&!d&&(u.numberOfTracks++,d=new lr(i),h.pipe(d).pipe(u)),r&&!l&&(u.numberOfTracks++,l=new pr(r),o.pipe(l).pipe(u),d&&d.on("keyframe",l.onVideoKeyFrame))}})),this.push=function(t){e.push(t)},this.flush=function(){e.flush()},this.resetCaptions=function(){p.reset()},u.on("data",(function(t){f.trigger("data",t)})),u.on("done",(function(){f.trigger("done")}))},dr.prototype=new mr;var wr=or,Ur={tag:or,Transmuxer:dr,getFlvHeader:function(t,e,i){var r,s,n,a=new Uint8Array(9),o=new DataView(a.buffer);return t=t||0,e=void 0===e||e,i=void 0===i||i,o.setUint8(0,70),o.setUint8(1,76),o.setUint8(2,86),o.setUint8(3,1),o.setUint8(4,(e?4:0)|(i?1:0)),o.setUint32(5,a.byteLength),t<=0?((s=new Uint8Array(a.byteLength+4)).set(a),s.set([0,0,0,0],a.byteLength),s):((r=new wr(wr.METADATA_TAG)).pts=r.dts=0,r.writeMetaDataDouble("duration",t),n=r.finalize().length,(s=new Uint8Array(a.byteLength+n)).set(a),s.set(o.byteLength,n),s)}},Tr=gi,xr=Lt,Er=Be,Ar=Pe,kr=E.ONE_SECOND_IN_TS,Cr=ki,Ir=function t(e,i){var r=[],s=0,n=0,a=0,o=1/0,h=null,d=null;i=i||{},t.prototype.init.call(this),this.push=function(t){Ar.collectDtsInfo(e,t),e&&Cr.forEach((function(i){e[i]=t[i]})),r.push(t)},this.setEarliestDts=function(t){n=t},this.setVideoBaseMediaDecodeTime=function(t){o=t},this.setAudioAppendStart=function(t){a=t},this.processFrames_=function(){var t,l,p,u,f;0!==r.length&&0!==(t=Er.trimAdtsFramesByEarliestDts(r,e,n)).length&&(e.baseMediaDecodeTime=Ar.calculateTrackBaseMediaDecodeTime(e,i.keepOriginalTimestamps),Er.prefixWithSilence(e,t,a,o),e.samples=Er.generateSampleTable(t),p=xr.mdat(Er.concatenateFrameData(t)),r=[],l=xr.moof(s,[e]),s++,e.initSegment=xr.initSegment([e]),(u=new Uint8Array(l.byteLength+p.byteLength)).set(l),u.set(p,l.byteLength),Ar.clearDtsInfo(e),null===h&&(d=h=t[0].pts),d+=t.length*(1024*kr/e.samplerate),f={start:h},this.trigger("timingInfo",f),this.trigger("data",{track:e,boxes:u}))},this.flush=function(){this.processFrames_(),this.trigger("timingInfo",{start:h,end:d}),this.resetTiming_(),this.trigger("done","AudioSegmentStream")},this.partialFlush=function(){this.processFrames_(),this.trigger("partialdone","AudioSegmentStream")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline","AudioSegmentStream")},this.resetTiming_=function(){Ar.clearDtsInfo(e),h=null,d=null},this.reset=function(){this.resetTiming_(),r=[],this.trigger("reset")}};Ir.prototype=new U;var Br=Ir,Dr=Lt,Pr=Pe,Lr=xe,zr=Ci,Fr=function t(e,i){var r,s,n,a=0,o=[],h=[],d=null,l=null,p=!0;i=i||{},t.prototype.init.call(this),this.push=function(t){Pr.collectDtsInfo(e,t),void 0===e.timelineStartInfo.dts&&(e.timelineStartInfo.dts=t.dts),"seq_parameter_set_rbsp"!==t.nalUnitType||r||(r=t.config,e.sps=[t.data],zr.forEach((function(t){e[t]=r[t]}),this)),"pic_parameter_set_rbsp"!==t.nalUnitType||s||(s=t.data,e.pps=[t.data]),o.push(t)},this.processNals_=function(t){var r;for(o=h.concat(o);o.length&&"access_unit_delimiter_rbsp"!==o[0].nalUnitType;)o.shift();if(0!==o.length){var s=Lr.groupNalsIntoFrames(o);if(s.length)if(h=s[s.length-1],t&&(s.pop(),s.duration-=h.duration,s.nalCount-=h.length,s.byteLength-=h.byteLength),s.length){if(this.trigger("timelineStartInfo",e.timelineStartInfo),p){if(!(n=Lr.groupFramesIntoGops(s))[0][0].keyFrame){if(!(n=Lr.extendFirstKeyFrame(n))[0][0].keyFrame)return o=[].concat.apply([],s).concat(h),void(h=[]);(s=[].concat.apply([],n)).duration=n.duration}p=!1}for(null===d&&(d=s[0].pts,l=d),l+=s.duration,this.trigger("timingInfo",{start:d,end:l}),r=0;rMALFORMED DATA");else switch(31&t[e]){case 1:s.push("slice_layer_without_partitioning_rbsp");break;case 5:s.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:s.push("sei_rbsp");break;case 7:s.push("seq_parameter_set_rbsp");break;case 8:s.push("pic_parameter_set_rbsp");break;case 9:s.push("access_unit_delimiter_rbsp");break;default:s.push("UNKNOWN NAL - "+t[e]&31)}return s},os={avc1:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{dataReferenceIndex:e.getUint16(6),width:e.getUint16(24),height:e.getUint16(26),horizresolution:e.getUint16(28)+e.getUint16(30)/16,vertresolution:e.getUint16(32)+e.getUint16(34)/16,frameCount:e.getUint16(40),depth:e.getUint16(74),config:Jr(t.subarray(78,t.byteLength))}},avcC:function(t){var e,i,r,s,n=new DataView(t.buffer,t.byteOffset,t.byteLength),a={configurationVersion:t[0],avcProfileIndication:t[1],profileCompatibility:t[2],avcLevelIndication:t[3],lengthSizeMinusOne:3&t[4],sps:[],pps:[]},o=31&t[5];for(r=6,s=0;s>>2&63,bufferSize:t[13]<<16|t[14]<<8|t[15],maxBitrate:t[16]<<24|t[17]<<16|t[18]<<8|t[19],avgBitrate:t[20]<<24|t[21]<<16|t[22]<<8|t[23],decoderConfigDescriptor:{tag:t[24],length:t[25],audioObjectType:t[26]>>>3&31,samplingFrequencyIndex:(7&t[26])<<1|t[27]>>>7&1,channelConfiguration:t[27]>>>3&15}}}},ftyp:function(t){for(var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={majorBrand:ss(t.subarray(0,4)),minorVersion:e.getUint32(4),compatibleBrands:[]},r=8;r>10)),s.language+=String.fromCharCode(96+((992&e)>>5)),s.language+=String.fromCharCode(96+(31&e)),s},mdia:function(t){return{boxes:Jr(t)}},mfhd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),sequenceNumber:t[4]<<24|t[5]<<16|t[6]<<8|t[7]}},minf:function(t){return{boxes:Jr(t)}},mp4a:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={dataReferenceIndex:e.getUint16(6),channelcount:e.getUint16(16),samplesize:e.getUint16(18),samplerate:e.getUint16(24)+e.getUint16(26)/65536};return t.byteLength>28&&(i.streamDescriptor=Jr(t.subarray(28))[0]),i},moof:function(t){return{boxes:Jr(t)}},moov:function(t){return{boxes:Jr(t)}},mvex:function(t){return{boxes:Jr(t)}},mvhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=4,r={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4))};return 1===r.version?(i+=4,r.creationTime=rs(e.getUint32(i)),i+=8,r.modificationTime=rs(e.getUint32(i)),i+=4,r.timescale=e.getUint32(i),i+=8,r.duration=e.getUint32(i)):(r.creationTime=rs(e.getUint32(i)),i+=4,r.modificationTime=rs(e.getUint32(i)),i+=4,r.timescale=e.getUint32(i),i+=4,r.duration=e.getUint32(i)),i+=4,r.rate=e.getUint16(i)+e.getUint16(i+2)/16,i+=4,r.volume=e.getUint8(i)+e.getUint8(i+1)/8,i+=2,i+=2,i+=8,r.matrix=new Uint32Array(t.subarray(i,i+36)),i+=36,i+=24,r.nextTrackId=e.getUint32(i),r},pdin:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),rate:e.getUint32(4),initialDelay:e.getUint32(8)}},sdtp:function(t){var e,i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),samples:[]};for(e=4;e>4,isDependedOn:(12&t[e])>>2,hasRedundancy:3&t[e]});return i},sidx:function(){if(Qr)return Zr;Qr=1;var t=Tt.getUint64;return Zr=function(e){var i=new DataView(e.buffer,e.byteOffset,e.byteLength),r={version:e[0],flags:new Uint8Array(e.subarray(1,4)),references:[],referenceId:i.getUint32(4),timescale:i.getUint32(8)},s=12;0===r.version?(r.earliestPresentationTime=i.getUint32(s),r.firstOffset=i.getUint32(s+4),s+=8):(r.earliestPresentationTime=t(e.subarray(s)),r.firstOffset=t(e.subarray(s+8)),s+=16),s+=2;var n=i.getUint16(s);for(s+=2;n>0;s+=12,n--)r.references.push({referenceType:(128&e[s])>>>7,referencedSize:2147483647&i.getUint32(s),subsegmentDuration:i.getUint32(s+4),startsWithSap:!!(128&e[s+8]),sapType:(112&e[s+8])>>>4,sapDeltaTime:268435455&i.getUint32(s+8)});return r}}(),smhd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),balance:t[4]+t[5]/256}},stbl:function(t){return{boxes:Jr(t)}},ctts:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),r={version:i.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),compositionOffsets:[]},s=i.getUint32(4);for(e=8;s;e+=8,s--)r.compositionOffsets.push({sampleCount:i.getUint32(e),sampleOffset:i[0===r.version?"getUint32":"getInt32"](e+4)});return r},stss:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),r={version:i.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),syncSamples:[]},s=i.getUint32(4);for(e=8;s;e+=4,s--)r.syncSamples.push(i.getUint32(e));return r},stco:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),r={version:t[0],flags:new Uint8Array(t.subarray(1,4)),chunkOffsets:[]},s=i.getUint32(4);for(e=8;s;e+=4,s--)r.chunkOffsets.push(i.getUint32(e));return r},stsc:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),r=i.getUint32(4),s={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleToChunks:[]};for(e=8;r;e+=12,r--)s.sampleToChunks.push({firstChunk:i.getUint32(e),samplesPerChunk:i.getUint32(e+4),sampleDescriptionIndex:i.getUint32(e+8)});return s},stsd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleDescriptions:Jr(t.subarray(8))}},stsz:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),r={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleSize:i.getUint32(4),entries:[]};for(e=12;e>6,sampleHasRedundancy:(48&t[21])>>4,samplePaddingValue:(14&t[21])>>1,sampleIsDifferenceSample:!!(1&t[21]),sampleDegradationPriority:e.getUint16(22)}},trun:jt(),"url ":function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4))}},vmhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),graphicsmode:e.getUint16(4),opcolor:new Uint16Array([e.getUint16(6),e.getUint16(8),e.getUint16(10)])}}};Jr=function(t){for(var e,i,r,s,n,a=0,o=[],h=new ArrayBuffer(t.length),d=new Uint8Array(h),l=0;l1?a+i:t.byteLength,(n=(os[r]||function(t){return{data:t}})(t.subarray(a+8,s))).size=i,n.type=r,o.push(n),a=s;return o};var hs={inspect:Jr,textify:ts=function(t,e){var i;return e=e||0,i=new Array(2*e+1).join(" "),t.map((function(t,r){return i+t.type+"\n"+Object.keys(t).filter((function(t){return"type"!==t&&"boxes"!==t})).map((function(e){var r=i+" "+e+": ",s=t[e];if(s instanceof Uint8Array||s instanceof Uint32Array){var n=Array.prototype.slice.call(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)).map((function(t){return" "+("00"+t.toString(16)).slice(-2)})).join("").match(/.{1,24}/g);return n?1===n.length?r+"<"+n.join("").slice(1)+">":r+"<\n"+n.map((function(t){return i+" "+t})).join("\n")+"\n"+i+" >":r+"<>"}return r+JSON.stringify(s,null,2).split("\n").map((function(t,e){return 0===e?t:i+" "+t})).join("\n")})).join("\n")+(t.boxes?"\n"+ts(t.boxes,e+1):"")})).join("\n")},parseType:ss,findBox:ns,parseTraf:os.traf,parseTfdt:os.tfdt,parseHdlr:os.hdlr,parseTfhd:os.tfhd,parseTrun:os.trun,parseSidx:os.sidx},ds={8:"audio",9:"video",18:"metadata"},ls=function(t){for(var e,i=[];t.byteLength>0;)e=0,i.push("0x"+("00"+t[e++].toString(16)).slice(-2).toUpperCase()),t=t.subarray(1);return i.join(" ")},ps=function(t,e){var i=t[0]&parseInt("00001111",2);return(e=e||{}).frameType=["Unknown","Keyframe (for AVC, a seekable frame)","Inter frame (for AVC, a nonseekable frame)","Disposable inter frame (H.263 only)","Generated keyframe (reserved for server use only)","Video info/command frame"][(t[0]&parseInt("11110000",2))>>>4],e.codecID=i,7===i?function(t,e){var i=t[1]&parseInt("01111111",2)<<16|t[2]<<8|t[3];return(e=e||{}).avcPacketType=["AVC Sequence Header","AVC NALU","AVC End-of-Sequence"][t[0]],e.CompositionTime=t[1]&parseInt("10000000",2)?-i:i,1===t[0]?e.nalUnitTypeRaw=ls(t.subarray(4,100)):e.data=ls(t.subarray(4)),e}(t.subarray(1),e):e},us=function(t,e){var i=(t[0]&parseInt("11110000",2))>>>4;return(e=e||{}).soundFormat=["Linear PCM, platform endian","ADPCM","MP3","Linear PCM, little endian","Nellymoser 16-kHz mono","Nellymoser 8-kHz mono","Nellymoser","G.711 A-law logarithmic PCM","G.711 mu-law logarithmic PCM","reserved","AAC","Speex","MP3 8-Khz","Device-specific sound"][i],e.soundRate=["5.5-kHz","11-kHz","22-kHz","44-kHz"][(t[0]&parseInt("00001100",2))>>>2],e.soundSize=(t[0]&parseInt("00000010",2))>>>1?"16-bit":"8-bit",e.soundType=t[0]&parseInt("00000001",2)?"Stereo":"Mono",10===i?function(t,e){return(e=e||{}).aacPacketType=["AAC Sequence Header","AAC Raw"][t[0]],e.data=ls(t.subarray(1)),e}(t.subarray(1),e):e},fs=function(t){var e=function(t){return{tagType:ds[t[0]],dataSize:t[1]<<16|t[2]<<8|t[3],timestamp:t[7]<<24|t[4]<<16|t[5]<<8|t[6],streamID:t[8]<<16|t[9]<<8|t[10]}}(t);switch(t[0]){case 8:us(t.subarray(11),e);break;case 9:ps(t.subarray(11),e)}return e},cs={inspectTag:fs,inspect:function(t){var e,i,r=9,s=[];for(r+=4;r>>4>1&&(e+=t[4]+1),e},bs=function(t){switch(t){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},vs={parseType:function(t,e){var i=gs(t);return 0===i?"pat":i===e?"pmt":e?"pes":null},parsePat:function(t){var e=_s(t),i=4+ys(t);return e&&(i+=t[i]+1),(31&t[i+10])<<8|t[i+11]},parsePmt:function(t){var e={},i=_s(t),r=4+ys(t);if(i&&(r+=t[r]+1),1&t[r+5]){var s;s=3+((15&t[r+1])<<8|t[r+2])-4;for(var n=12+((15&t[r+10])<<8|t[r+11]);n=t.byteLength)return null;var i,r=null;return 192&(i=t[e+7])&&((r={}).pts=(14&t[e+9])<<27|(255&t[e+10])<<20|(254&t[e+11])<<12|(255&t[e+12])<<5|(254&t[e+13])>>>3,r.pts*=4,r.pts+=(6&t[e+13])>>>1,r.dts=r.pts,64&i&&(r.dts=(14&t[e+14])<<27|(255&t[e+15])<<20|(254&t[e+16])<<12|(255&t[e+17])<<5|(254&t[e+18])>>>3,r.dts*=4,r.dts+=(6&t[e+18])>>>1)),r},videoPacketContainsKeyFrame:function(t){for(var e=4+ys(t),i=t.subarray(e),r=0,s=0,n=!1;s3&&"slice_layer_without_partitioning_rbsp_idr"===bs(31&i[s+3])&&(n=!0),n}},Ss=Xe,ws=ei,Us={};Us.ts=vs,Us.aac=Si;var Ts=E.ONE_SECOND_IN_TS,xs=188,Es=71,As=function(t,e,i){for(var r,s,n,a,o=0,h=xs,d=!1;h<=t.byteLength;)if(t[o]!==Es||t[h]!==Es&&h!==t.byteLength)o++,h++;else{if(r=t.subarray(o,h),"pes"===Us.ts.parseType(r,e.pid))s=Us.ts.parsePesType(r,e.table),n=Us.ts.parsePayloadUnitStartIndicator(r),"audio"===s&&n&&(a=Us.ts.parsePesTime(r))&&(a.type="audio",i.audio.push(a),d=!0);if(d)break;o+=xs,h+=xs}for(o=(h=t.byteLength)-xs,d=!1;o>=0;)if(t[o]!==Es||t[h]!==Es&&h!==t.byteLength)o--,h--;else{if(r=t.subarray(o,h),"pes"===Us.ts.parseType(r,e.pid))s=Us.ts.parsePesType(r,e.table),n=Us.ts.parsePayloadUnitStartIndicator(r),"audio"===s&&n&&(a=Us.ts.parsePesTime(r))&&(a.type="audio",i.audio.push(a),d=!0);if(d)break;o-=xs,h-=xs}},ks=function(t,e,i){for(var r,s,n,a,o,h,d,l=0,p=xs,u=!1,f={data:[],size:0};p=0;)if(t[l]!==Es||t[p]!==Es)l--,p--;else{if(r=t.subarray(l,p),"pes"===Us.ts.parseType(r,e.pid))s=Us.ts.parsePesType(r,e.table),n=Us.ts.parsePayloadUnitStartIndicator(r),"video"===s&&n&&(a=Us.ts.parsePesTime(r))&&(a.type="video",i.video.push(a),u=!0);if(u)break;l-=xs,p-=xs}},Cs=function(t){var e={pid:null,table:null},i={};for(var r in function(t,e){for(var i,r=0,s=xs;s=3;){switch(Us.aac.parseType(t,o)){case"timed-metadata":if(t.length-o<10){i=!0;break}if((a=Us.aac.parseId3TagSize(t,o))>t.length){i=!0;break}null===n&&(e=t.subarray(o,o+a),n=Us.aac.parseAacTimestamp(e)),o+=a;break;case"audio":if(t.length-o<7){i=!0;break}if((a=Us.aac.parseAdtsSize(t,o))>t.length){i=!0;break}null===s&&(e=t.subarray(o,o+a),s=Us.aac.parseSampleRate(e)),r++,o+=a;break;default:o++}if(i)return null}if(null===s||null===n)return null;var h=Ts/s;return{audio:[{type:"audio",dts:n,pts:n},{type:"audio",dts:n+1024*r*h,pts:n+1024*r*h}]}}(t):Cs(t),i&&(i.audio||i.video)?(function(t,e){if(t.audio&&t.audio.length){var i=e;(void 0===i||isNaN(i))&&(i=t.audio[0].dts),t.audio.forEach((function(t){t.dts=ws(t.dts,i),t.pts=ws(t.pts,i),t.dtsTime=t.dts/Ts,t.ptsTime=t.pts/Ts}))}if(t.video&&t.video.length){var r=e;if((void 0===r||isNaN(r))&&(r=t.video[0].dts),t.video.forEach((function(t){t.dts=ws(t.dts,r),t.pts=ws(t.pts,r),t.dtsTime=t.dts/Ts,t.ptsTime=t.pts/Ts})),t.firstKeyFrame){var s=t.firstKeyFrame;s.dts=ws(s.dts,r),s.pts=ws(s.pts,r),s.dtsTime=s.dts/Ts,s.ptsTime=s.pts/Ts}}}(i,e),i):null},parseAudioPes_:As},Bs={codecs:wt,mp4:ar,flv:Ur,mp2t:Tr,partial:$r};Bs.mp4.tools=hs,Bs.flv.tools=cs,Bs.mp2t.tools=Is;const Ds=new(p(Bs).mp4.Transmuxer)({remux:!1});var Ps={};!function(t){var e,r,s,n=(e=new Date,r=4,s={setLogLevel:function(t){r=t==this.debug?1:t==this.info?2:t==this.warn?3:(this.error,4)},debug:function(t,i){void 0===console.debug&&(console.debug=console.log),1>=r&&console.debug("["+n.getDurationString(new Date-e,1e3)+"]","["+t+"]",i)},log:function(t,e){this.debug(t.msg)},info:function(t,i){2>=r&&console.info("["+n.getDurationString(new Date-e,1e3)+"]","["+t+"]",i)},warn:function(t,i){3>=r&&console.warn("["+n.getDurationString(new Date-e,1e3)+"]","["+t+"]",i)},error:function(t,i){4>=r&&console.error("["+n.getDurationString(new Date-e,1e3)+"]","["+t+"]",i)}},s);n.getDurationString=function(t,e){var i;function r(t,e){for(var i=(""+t).split(".");i[0].length0){for(var i="",r=0;r0&&(i+=","),i+="["+n.getDurationString(t.start(r))+","+n.getDurationString(t.end(r))+"]";return i}return"(empty)"},t.Log=n;var a=function(t){if(!(t instanceof ArrayBuffer))throw"Needs an array buffer";this.buffer=t,this.dataview=new DataView(t),this.position=0};a.prototype.getPosition=function(){return this.position},a.prototype.getEndPosition=function(){return this.buffer.byteLength},a.prototype.getLength=function(){return this.buffer.byteLength},a.prototype.seek=function(t){var e=Math.max(0,Math.min(this.buffer.byteLength,t));return this.position=isNaN(e)||!isFinite(e)?0:e,!0},a.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},a.prototype.readAnyInt=function(t,e){var i=0;if(this.position+t<=this.buffer.byteLength){switch(t){case 1:i=e?this.dataview.getInt8(this.position):this.dataview.getUint8(this.position);break;case 2:i=e?this.dataview.getInt16(this.position):this.dataview.getUint16(this.position);break;case 3:if(e)throw"No method for reading signed 24 bits values";i=this.dataview.getUint8(this.position)<<16,i|=this.dataview.getUint8(this.position+1)<<8,i|=this.dataview.getUint8(this.position+2);break;case 4:i=e?this.dataview.getInt32(this.position):this.dataview.getUint32(this.position);break;case 8:if(e)throw"No method for reading signed 64 bits values";i=this.dataview.getUint32(this.position)<<32,i|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+t}return this.position+=t,i}throw"Not enough bytes in buffer"},a.prototype.readUint8=function(){return this.readAnyInt(1,!1)},a.prototype.readUint16=function(){return this.readAnyInt(2,!1)},a.prototype.readUint24=function(){return this.readAnyInt(3,!1)},a.prototype.readUint32=function(){return this.readAnyInt(4,!1)},a.prototype.readUint64=function(){return this.readAnyInt(8,!1)},a.prototype.readString=function(t){if(this.position+t<=this.buffer.byteLength){for(var e="",i=0;ithis._byteLength&&(this._byteLength=e);else{for(i<1&&(i=1);e>i;)i*=2;var r=new ArrayBuffer(i),s=new Uint8Array(this._buffer);new Uint8Array(r,0,s.length).set(s),this.buffer=r,this._byteLength=e}}},o.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var t=new ArrayBuffer(this._byteLength),e=new Uint8Array(t),i=new Uint8Array(this._buffer,0,e.length);e.set(i),this.buffer=t}},o.BIG_ENDIAN=!1,o.LITTLE_ENDIAN=!0,o.prototype._byteLength=0,Object.defineProperty(o.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(o.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(t){this._buffer=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(o.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(t){this._byteOffset=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(o.prototype,"dataView",{get:function(){return this._dataView},set:function(t){this._byteOffset=t.byteOffset,this._buffer=t.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+t.byteLength}}),o.prototype.seek=function(t){var e=Math.max(0,Math.min(this.byteLength,t));this.position=isNaN(e)||!isFinite(e)?0:e},o.prototype.isEof=function(){return this.position>=this._byteLength},o.prototype.mapUint8Array=function(t){this._realloc(1*t);var e=new Uint8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=1*t,e},o.prototype.readInt32Array=function(t,e){t=null==t?this.byteLength-this.position/4:t;var i=new Int32Array(t);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==e?this.endianness:e),this.position+=i.byteLength,i},o.prototype.readInt16Array=function(t,e){t=null==t?this.byteLength-this.position/2:t;var i=new Int16Array(t);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==e?this.endianness:e),this.position+=i.byteLength,i},o.prototype.readInt8Array=function(t){t=null==t?this.byteLength-this.position:t;var e=new Int8Array(t);return o.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e},o.prototype.readUint32Array=function(t,e){t=null==t?this.byteLength-this.position/4:t;var i=new Uint32Array(t);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==e?this.endianness:e),this.position+=i.byteLength,i},o.prototype.readUint16Array=function(t,e){t=null==t?this.byteLength-this.position/2:t;var i=new Uint16Array(t);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==e?this.endianness:e),this.position+=i.byteLength,i},o.prototype.readUint8Array=function(t){t=null==t?this.byteLength-this.position:t;var e=new Uint8Array(t);return o.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e},o.prototype.readFloat64Array=function(t,e){t=null==t?this.byteLength-this.position/8:t;var i=new Float64Array(t);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==e?this.endianness:e),this.position+=i.byteLength,i},o.prototype.readFloat32Array=function(t,e){t=null==t?this.byteLength-this.position/4:t;var i=new Float32Array(t);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==e?this.endianness:e),this.position+=i.byteLength,i},o.prototype.readInt32=function(t){var e=this._dataView.getInt32(this.position,null==t?this.endianness:t);return this.position+=4,e},o.prototype.readInt16=function(t){var e=this._dataView.getInt16(this.position,null==t?this.endianness:t);return this.position+=2,e},o.prototype.readInt8=function(){var t=this._dataView.getInt8(this.position);return this.position+=1,t},o.prototype.readUint32=function(t){var e=this._dataView.getUint32(this.position,null==t?this.endianness:t);return this.position+=4,e},o.prototype.readUint16=function(t){var e=this._dataView.getUint16(this.position,null==t?this.endianness:t);return this.position+=2,e},o.prototype.readUint8=function(){var t=this._dataView.getUint8(this.position);return this.position+=1,t},o.prototype.readFloat32=function(t){var e=this._dataView.getFloat32(this.position,null==t?this.endianness:t);return this.position+=4,e},o.prototype.readFloat64=function(t){var e=this._dataView.getFloat64(this.position,null==t?this.endianness:t);return this.position+=8,e},o.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,o.memcpy=function(t,e,i,r,s){var n=new Uint8Array(t,e,s),a=new Uint8Array(i,r,s);n.set(a)},o.arrayToNative=function(t,e){return e==this.endianness?t:this.flipArrayEndianness(t)},o.nativeToEndian=function(t,e){return this.endianness==e?t:this.flipArrayEndianness(t)},o.flipArrayEndianness=function(t){for(var e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=0;is;r--,s++){var n=e[s];e[s]=e[r],e[r]=n}return t},o.prototype.failurePosition=0,String.fromCharCodeUint8=function(t){for(var e=[],i=0;i>16),this.writeUint8((65280&t)>>8),this.writeUint8(255&t)},o.prototype.adjustUint32=function(t,e){var i=this.position;this.seek(t),this.writeUint32(e),this.seek(i)},o.prototype.mapInt32Array=function(t,e){this._realloc(4*t);var i=new Int32Array(this._buffer,this.byteOffset+this.position,t);return o.arrayToNative(i,null==e?this.endianness:e),this.position+=4*t,i},o.prototype.mapInt16Array=function(t,e){this._realloc(2*t);var i=new Int16Array(this._buffer,this.byteOffset+this.position,t);return o.arrayToNative(i,null==e?this.endianness:e),this.position+=2*t,i},o.prototype.mapInt8Array=function(t){this._realloc(1*t);var e=new Int8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=1*t,e},o.prototype.mapUint32Array=function(t,e){this._realloc(4*t);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,t);return o.arrayToNative(i,null==e?this.endianness:e),this.position+=4*t,i},o.prototype.mapUint16Array=function(t,e){this._realloc(2*t);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,t);return o.arrayToNative(i,null==e?this.endianness:e),this.position+=2*t,i},o.prototype.mapFloat64Array=function(t,e){this._realloc(8*t);var i=new Float64Array(this._buffer,this.byteOffset+this.position,t);return o.arrayToNative(i,null==e?this.endianness:e),this.position+=8*t,i},o.prototype.mapFloat32Array=function(t,e){this._realloc(4*t);var i=new Float32Array(this._buffer,this.byteOffset+this.position,t);return o.arrayToNative(i,null==e?this.endianness:e),this.position+=4*t,i};var d=function(t){this.buffers=[],this.bufferIndex=-1,t&&(this.insertBuffer(t),this.bufferIndex=0)};(d.prototype=new o(new ArrayBuffer,0,o.BIG_ENDIAN)).initialized=function(){var t;return this.bufferIndex>-1||(this.buffers.length>0?0===(t=this.buffers[0]).fileStart?(this.buffer=t,this.bufferIndex=0,n.debug("MultiBufferStream","Stream ready for parsing"),!0):(n.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1):(n.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1))},ArrayBuffer.concat=function(t,e){n.debug("ArrayBuffer","Trying to create a new buffer of size: "+(t.byteLength+e.byteLength));var i=new Uint8Array(t.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(e),t.byteLength),i.buffer},d.prototype.reduceBuffer=function(t,e,i){var r;return(r=new Uint8Array(i)).set(new Uint8Array(t,e,i)),r.buffer.fileStart=t.fileStart+e,r.buffer.usedBytes=0,r.buffer},d.prototype.insertBuffer=function(t){for(var e=!0,i=0;ir.byteLength){this.buffers.splice(i,1),i--;continue}n.warn("MultiBufferStream","Buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+") already appended, ignoring")}else t.fileStart+t.byteLength<=r.fileStart||(t=this.reduceBuffer(t,0,r.fileStart-t.fileStart)),n.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.splice(i,0,t),0===i&&(this.buffer=t);e=!1;break}if(t.fileStart0)){e=!1;break}t=this.reduceBuffer(t,s,a)}}e&&(n.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.push(t),0===i&&(this.buffer=t))},d.prototype.logBufferLevel=function(t){var e,i,r,s,a,o=[],h="";for(r=0,s=0,e=0;e0&&(h+=a.end-1+"]");var d=t?n.info:n.debug;0===this.buffers.length?d("MultiBufferStream","No more buffer in memory"):d("MultiBufferStream",this.buffers.length+" stored buffer(s) ("+r+"/"+s+" bytes), continuous ranges: "+h)},d.prototype.cleanBuffers=function(){var t,e;for(t=0;t"+this.buffer.byteLength+")"),!0}return!1}return!1},d.prototype.findPosition=function(t,e,i){var r,s=null,a=-1;for(r=!0===t?0:this.bufferIndex;r=e?(n.debug("MultiBufferStream","Found position in existing buffer #"+a),a):-1},d.prototype.findEndContiguousBuf=function(t){var e,i,r,s=void 0!==t?t:this.bufferIndex;if(i=this.buffers[s],this.buffers.length>s+1)for(e=s+1;e>3;return 31===r&&i.data.length>=2&&(r=32+((7&i.data[0])<<3)+((224&i.data[1])>>5)),r}return null},i.DecoderConfigDescriptor=function(t){i.Descriptor.call(this,4,t)},i.DecoderConfigDescriptor.prototype=new i.Descriptor,i.DecoderConfigDescriptor.prototype.parse=function(t){this.oti=t.readUint8(),this.streamType=t.readUint8(),this.bufferSize=t.readUint24(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32(),this.size-=13,this.parseRemainingDescriptors(t)},i.DecoderSpecificInfo=function(t){i.Descriptor.call(this,5,t)},i.DecoderSpecificInfo.prototype=new i.Descriptor,i.SLConfigDescriptor=function(t){i.Descriptor.call(this,6,t)},i.SLConfigDescriptor.prototype=new i.Descriptor,this};t.MPEG4DescriptorParser=l;var p={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"],["grpl"],["j2kH"],["etyp",["tyco"]]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){p.FullBox.prototype=new p.Box,p.ContainerBox.prototype=new p.Box,p.SampleEntry.prototype=new p.Box,p.TrackGroupTypeBox.prototype=new p.FullBox,p.BASIC_BOXES.forEach((function(t){p.createBoxCtor(t)})),p.FULL_BOXES.forEach((function(t){p.createFullBoxCtor(t)})),p.CONTAINER_BOXES.forEach((function(t){p.createContainerBoxCtor(t[0],null,t[1])}))},Box:function(t,e,i){this.type=t,this.size=e,this.uuid=i},FullBox:function(t,e,i){p.Box.call(this,t,e,i),this.flags=0,this.version=0},ContainerBox:function(t,e,i){p.Box.call(this,t,e,i),this.boxes=[]},SampleEntry:function(t,e,i,r){p.ContainerBox.call(this,t,e),this.hdr_size=i,this.start=r},SampleGroupEntry:function(t){this.grouping_type=t},TrackGroupTypeBox:function(t,e){p.FullBox.call(this,t,e)},createBoxCtor:function(t,e){p.boxCodes.push(t),p[t+"Box"]=function(e){p.Box.call(this,t,e)},p[t+"Box"].prototype=new p.Box,e&&(p[t+"Box"].prototype.parse=e)},createFullBoxCtor:function(t,e){p[t+"Box"]=function(e){p.FullBox.call(this,t,e)},p[t+"Box"].prototype=new p.FullBox,p[t+"Box"].prototype.parse=function(t){this.parseFullHeader(t),e&&e.call(this,t)}},addSubBoxArrays:function(t){if(t){this.subBoxNames=t;for(var e=t.length,i=0;ii?(n.error("BoxParser","Box of type '"+l+"' has a size "+d+" greater than its container size "+i),{code:p.ERR_NOT_ENOUGH_DATA,type:l,size:d,hdr_size:h,start:o}):0!==d&&o+d>t.getEndPosition()?(t.seek(o),n.info("BoxParser","Not enough data in stream to parse the entire '"+l+"' box"),{code:p.ERR_NOT_ENOUGH_DATA,type:l,size:d,hdr_size:h,start:o}):e?{code:p.OK,type:l,size:d,hdr_size:h,start:o}:(p[l+"Box"]?r=new p[l+"Box"](d):"uuid"!==l?(n.warn("BoxParser","Unknown box type: '"+l+"'"),(r=new p.Box(l,d)).has_unparsed_data=!0):p.UUIDBoxes[a]?r=new p.UUIDBoxes[a](d):(n.warn("BoxParser","Unknown uuid type: '"+a+"'"),(r=new p.Box(l,d)).uuid=a,r.has_unparsed_data=!0),r.hdr_size=h,r.start=o,r.write===p.Box.prototype.write&&"mdat"!==r.type&&(n.info("BoxParser","'"+u+"' box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(t)),r.parse(t),(s=t.getPosition()-(r.start+r.size))<0?(n.warn("BoxParser","Parsing of box '"+u+"' did not read the entire indicated box data size (missing "+-s+" bytes), seeking forward"),t.seek(r.start+r.size)):s>0&&(n.error("BoxParser","Parsing of box '"+u+"' read "+s+" more bytes than the indicated box data size, seeking backwards"),0!==r.size&&t.seek(r.start+r.size)),{code:p.OK,box:r,size:r.size})},p.Box.prototype.parse=function(t){"mdat"!=this.type?this.data=t.readUint8Array(this.size-this.hdr_size):0===this.size?t.seek(t.getEndPosition()):t.seek(this.start+this.size)},p.Box.prototype.parseDataAndRewind=function(t){this.data=t.readUint8Array(this.size-this.hdr_size),t.position-=this.size-this.hdr_size},p.FullBox.prototype.parseDataAndRewind=function(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,t.position-=this.size-this.hdr_size},p.FullBox.prototype.parseFullHeader=function(t){this.version=t.readUint8(),this.flags=t.readUint24(),this.hdr_size+=4},p.FullBox.prototype.parse=function(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)},p.ContainerBox.prototype.parse=function(t){for(var e,i;t.getPosition()>10&31,e[1]=this.language>>5&31,e[2]=31&this.language,this.languageString=String.fromCharCode(e[0]+96,e[1]+96,e[2]+96)},p.SAMPLE_ENTRY_TYPE_VISUAL="Visual",p.SAMPLE_ENTRY_TYPE_AUDIO="Audio",p.SAMPLE_ENTRY_TYPE_HINT="Hint",p.SAMPLE_ENTRY_TYPE_METADATA="Metadata",p.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",p.SAMPLE_ENTRY_TYPE_SYSTEM="System",p.SAMPLE_ENTRY_TYPE_TEXT="Text",p.SampleEntry.prototype.parseHeader=function(t){t.readUint8Array(6),this.data_reference_index=t.readUint16(),this.hdr_size+=8},p.SampleEntry.prototype.parse=function(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)},p.SampleEntry.prototype.parseDataAndRewind=function(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,t.position-=this.size-this.hdr_size},p.SampleEntry.prototype.parseFooter=function(t){p.ContainerBox.prototype.parse.call(this,t)},p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_HINT),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_METADATA),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SUBTITLE),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SYSTEM),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_TEXT),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,(function(t){var e;this.parseHeader(t),t.readUint16(),t.readUint16(),t.readUint32Array(3),this.width=t.readUint16(),this.height=t.readUint16(),this.horizresolution=t.readUint32(),this.vertresolution=t.readUint32(),t.readUint32(),this.frame_count=t.readUint16(),e=Math.min(31,t.readUint8()),this.compressorname=t.readString(e),e<31&&t.readString(31-e),this.depth=t.readUint16(),t.readUint16(),this.parseFooter(t)})),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,(function(t){this.parseHeader(t),t.readUint32Array(2),this.channel_count=t.readUint16(),this.samplesize=t.readUint16(),t.readUint16(),t.readUint16(),this.samplerate=t.readUint32()/65536,this.parseFooter(t)})),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"dav1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"hvt1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"lhe1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"dvh1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"dvhe"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avs3"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"j2ki"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"mjp2"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"mjpg"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"uncv"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"ac-4"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"mha1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"mha2"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"mhm1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"mhm2"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_TEXT,"enct"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_METADATA,"encm"),p.createBoxCtor("a1lx",(function(t){var e=16*(1+(1&(1&t.readUint8())));this.layer_size=[];for(var i=0;i<3;i++)this.layer_size[i]=16==e?t.readUint16():t.readUint32()})),p.createBoxCtor("a1op",(function(t){this.op_index=t.readUint8()})),p.createFullBoxCtor("auxC",(function(t){this.aux_type=t.readCString();var e=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=t.readUint8Array(e)})),p.createBoxCtor("av1C",(function(t){var e=t.readUint8();if(e>>7&!1)n.error("av1C marker problem");else if(this.version=127&e,1===this.version)if(e=t.readUint8(),this.seq_profile=e>>5&7,this.seq_level_idx_0=31&e,e=t.readUint8(),this.seq_tier_0=e>>7&1,this.high_bitdepth=e>>6&1,this.twelve_bit=e>>5&1,this.monochrome=e>>4&1,this.chroma_subsampling_x=e>>3&1,this.chroma_subsampling_y=e>>2&1,this.chroma_sample_position=3&e,e=t.readUint8(),this.reserved_1=e>>5&7,0===this.reserved_1){if(this.initial_presentation_delay_present=e>>4&1,1===this.initial_presentation_delay_present)this.initial_presentation_delay_minus_one=15&e;else if(this.reserved_2=15&e,0!==this.reserved_2)return void n.error("av1C reserved_2 parsing problem");var i=this.size-this.hdr_size-4;this.configOBUs=t.readUint8Array(i)}else n.error("av1C reserved_1 parsing problem");else n.error("av1C version "+this.version+" not supported")})),p.createBoxCtor("avcC",(function(t){var e,i;for(this.configurationVersion=t.readUint8(),this.AVCProfileIndication=t.readUint8(),this.profile_compatibility=t.readUint8(),this.AVCLevelIndication=t.readUint8(),this.lengthSizeMinusOne=3&t.readUint8(),this.nb_SPS_nalus=31&t.readUint8(),i=this.size-this.hdr_size-6,this.SPS=[],e=0;e0&&(this.ext=t.readUint8Array(i))})),p.createBoxCtor("btrt",(function(t){this.bufferSizeDB=t.readUint32(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32()})),p.createFullBoxCtor("ccst",(function(t){var e=t.readUint8();this.all_ref_pics_intra=!(128&~e),this.intra_pred_used=!(64&~e),this.max_ref_per_pic=(63&e)>>2,t.readUint24()})),p.createBoxCtor("cdef",(function(t){var e;for(this.channel_count=t.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[],e=0;e=32768&&this.component_type_urls.push(t.readCString())}})),p.createFullBoxCtor("co64",(function(t){var e,i;if(e=t.readUint32(),this.chunk_offsets=[],0===this.version)for(i=0;i>7}else("rICC"===this.colour_type||"prof"===this.colour_type)&&(this.ICC_profile=t.readUint8Array(this.size-4))})),p.createFullBoxCtor("cprt",(function(t){this.parseLanguage(t),this.notice=t.readCString()})),p.createFullBoxCtor("cslg",(function(t){0===this.version&&(this.compositionToDTSShift=t.readInt32(),this.leastDecodeToDisplayDelta=t.readInt32(),this.greatestDecodeToDisplayDelta=t.readInt32(),this.compositionStartTime=t.readInt32(),this.compositionEndTime=t.readInt32())})),p.createFullBoxCtor("ctts",(function(t){var e,i;if(e=t.readUint32(),this.sample_counts=[],this.sample_offsets=[],0===this.version)for(i=0;i>6,this.bsid=e>>1&31,this.bsmod=(1&e)<<2|i>>6&3,this.acmod=i>>3&7,this.lfeon=i>>2&1,this.bit_rate_code=3&i|r>>5&7})),p.createBoxCtor("dec3",(function(t){var e=t.readUint16();this.data_rate=e>>3,this.num_ind_sub=7&e,this.ind_subs=[];for(var i=0;i>6,r.bsid=s>>1&31,r.bsmod=(1&s)<<4|n>>4&15,r.acmod=n>>1&7,r.lfeon=1&n,r.num_dep_sub=a>>1&15,r.num_dep_sub>0&&(r.chan_loc=(1&a)<<8|t.readUint8())}})),p.createFullBoxCtor("dfLa",(function(t){var e=[],i=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];for(this.parseFullHeader(t);;){var r=t.readUint8(),s=Math.min(127&r,i.length-1);if(s?t.readUint8Array(t.readUint24()):(t.readUint8Array(13),this.samplerate=t.readUint32()>>12,t.readUint8Array(20)),e.push(i[s]),128&r)break}this.numMetadataBlocks=e.length+" ("+e.join(", ")+")"})),p.createBoxCtor("dimm",(function(t){this.bytessent=t.readUint64()})),p.createBoxCtor("dmax",(function(t){this.time=t.readUint32()})),p.createBoxCtor("dmed",(function(t){this.bytessent=t.readUint64()})),p.createBoxCtor("dOps",(function(t){if(this.Version=t.readUint8(),this.OutputChannelCount=t.readUint8(),this.PreSkip=t.readUint16(),this.InputSampleRate=t.readUint32(),this.OutputGain=t.readInt16(),this.ChannelMappingFamily=t.readUint8(),0!==this.ChannelMappingFamily){this.StreamCount=t.readUint8(),this.CoupledCount=t.readUint8(),this.ChannelMapping=[];for(var e=0;e=4;)this.compatible_brands[i]=t.readString(4),e-=4,i++})),p.createFullBoxCtor("hdlr",(function(t){0===this.version&&(t.readUint32(),this.handler=t.readString(4),t.readUint32Array(3),this.name=t.readString(this.size-this.hdr_size-20),"\0"===this.name[this.name.length-1]&&(this.name=this.name.slice(0,-1)))})),p.createBoxCtor("hvcC",(function(t){var e,i,r,s;this.configurationVersion=t.readUint8(),s=t.readUint8(),this.general_profile_space=s>>6,this.general_tier_flag=(32&s)>>5,this.general_profile_idc=31&s,this.general_profile_compatibility=t.readUint32(),this.general_constraint_indicator=t.readUint8Array(6),this.general_level_idc=t.readUint8(),this.min_spatial_segmentation_idc=4095&t.readUint16(),this.parallelismType=3&t.readUint8(),this.chroma_format_idc=3&t.readUint8(),this.bit_depth_luma_minus8=7&t.readUint8(),this.bit_depth_chroma_minus8=7&t.readUint8(),this.avgFrameRate=t.readUint16(),s=t.readUint8(),this.constantFrameRate=s>>6,this.numTemporalLayers=(13&s)>>3,this.temporalIdNested=(4&s)>>2,this.lengthSizeMinusOne=3&s,this.nalu_arrays=[];var n=t.readUint8();for(e=0;e>7,a.nalu_type=63&s;var o=t.readUint16();for(i=0;i>4&15,this.length_size=15&e,e=t.readUint8(),this.base_offset_size=e>>4&15,1===this.version||2===this.version?this.index_size=15&e:this.index_size=0,this.items=[];var i=0;if(this.version<2)i=t.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";i=t.readUint32()}for(var r=0;r>7,this.axis=1&e})),p.createFullBoxCtor("infe",(function(t){if(0!==this.version&&1!==this.version||(this.item_ID=t.readUint16(),this.item_protection_index=t.readUint16(),this.item_name=t.readCString(),this.content_type=t.readCString(),this.content_encoding=t.readCString()),1===this.version)return this.extension_type=t.readString(4),n.warn("BoxParser","Cannot parse extension type"),void t.seek(this.start+this.size);this.version>=2&&(2===this.version?this.item_ID=t.readUint16():3===this.version&&(this.item_ID=t.readUint32()),this.item_protection_index=t.readUint16(),this.item_type=t.readString(4),this.item_name=t.readCString(),"mime"===this.item_type?(this.content_type=t.readCString(),this.content_encoding=t.readCString()):"uri "===this.item_type&&(this.item_uri_type=t.readCString()))})),p.createFullBoxCtor("ipma",(function(t){var e,i;for(entry_count=t.readUint32(),this.associations=[],e=0;e>7==1,1&this.flags?a.property_index=(127&n)<<8|t.readUint8():a.property_index=127&n}}})),p.createFullBoxCtor("iref",(function(t){var e,i;for(this.references=[];t.getPosition()>7,r.assignment_type=127&s,r.assignment_type){case 0:r.grouping_type=t.readString(4);break;case 1:r.grouping_type=t.readString(4),r.grouping_type_parameter=t.readUint32();break;case 2:case 3:break;case 4:r.sub_track_id=t.readUint32();break;default:n.warn("BoxParser","Unknown leva assignement type")}}})),p.createBoxCtor("lsel",(function(t){this.layer_id=t.readUint16()})),p.createBoxCtor("maxr",(function(t){this.period=t.readUint32(),this.bytes=t.readUint32()})),p.createBoxCtor("mdcv",(function(t){this.display_primaries=[],this.display_primaries[0]={},this.display_primaries[0].x=t.readUint16(),this.display_primaries[0].y=t.readUint16(),this.display_primaries[1]={},this.display_primaries[1].x=t.readUint16(),this.display_primaries[1].y=t.readUint16(),this.display_primaries[2]={},this.display_primaries[2].x=t.readUint16(),this.display_primaries[2].y=t.readUint16(),this.white_point={},this.white_point.x=t.readUint16(),this.white_point.y=t.readUint16(),this.max_display_mastering_luminance=t.readUint32(),this.min_display_mastering_luminance=t.readUint32()})),p.createFullBoxCtor("mdhd",(function(t){1==this.version?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.parseLanguage(t),t.readUint16()})),p.createFullBoxCtor("mehd",(function(t){1&this.flags&&(n.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),1==this.version?this.fragment_duration=t.readUint64():this.fragment_duration=t.readUint32()})),p.createFullBoxCtor("meta",(function(t){this.boxes=[],p.ContainerBox.prototype.parse.call(this,t)})),p.createFullBoxCtor("mfhd",(function(t){this.sequence_number=t.readUint32()})),p.createFullBoxCtor("mfro",(function(t){this._size=t.readUint32()})),p.createFullBoxCtor("mvhd",(function(t){1==this.version?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.rate=t.readUint32(),this.volume=t.readUint16()>>8,t.readUint16(),t.readUint32Array(2),this.matrix=t.readUint32Array(9),t.readUint32Array(6),this.next_track_id=t.readUint32()})),p.createBoxCtor("npck",(function(t){this.packetssent=t.readUint32()})),p.createBoxCtor("nump",(function(t){this.packetssent=t.readUint64()})),p.createFullBoxCtor("padb",(function(t){var e=t.readUint32();this.padbits=[];for(var i=0;i0){var e=t.readUint32();this.kid=[];for(var i=0;i0&&(this.data=t.readUint8Array(r))})),p.createFullBoxCtor("clef",(function(t){this.width=t.readUint32(),this.height=t.readUint32()})),p.createFullBoxCtor("enof",(function(t){this.width=t.readUint32(),this.height=t.readUint32()})),p.createFullBoxCtor("prof",(function(t){this.width=t.readUint32(),this.height=t.readUint32()})),p.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),p.createBoxCtor("rtp ",(function(t){this.descriptionformat=t.readString(4),this.sdptext=t.readString(this.size-this.hdr_size-4)})),p.createFullBoxCtor("saio",(function(t){1&this.flags&&(this.aux_info_type=t.readUint32(),this.aux_info_type_parameter=t.readUint32());var e=t.readUint32();this.offset=[];for(var i=0;i>7,this.avgRateFlag=e>>6&1,this.durationFlag&&(this.duration=t.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()),this.dependency=[];for(var i=t.readUint8(),r=0;r>7,this.num_leading_samples=127&e})),p.createSampleGroupCtor("rash",(function(t){if(this.operation_point_count=t.readUint16(),this.description_length!==2+(1===this.operation_point_count?2:6*this.operation_point_count)+9)n.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=t.readUint8Array(this.description_length-2);else{if(1===this.operation_point_count)this.target_rate_share=t.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var e=0;e>4,this.skip_byte_block=15&e,this.isProtected=t.readUint8(),this.Per_Sample_IV_Size=t.readUint8(),this.KID=p.parseHex16(t),this.constant_IV_size=0,this.constant_IV=0,1===this.isProtected&&0===this.Per_Sample_IV_Size&&(this.constant_IV_size=t.readUint8(),this.constant_IV=t.readUint8Array(this.constant_IV_size))})),p.createSampleGroupCtor("stsa",(function(t){n.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("sync",(function(t){var e=t.readUint8();this.NAL_unit_type=63&e})),p.createSampleGroupCtor("tele",(function(t){var e=t.readUint8();this.level_independently_decodable=e>>7})),p.createSampleGroupCtor("tsas",(function(t){n.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("tscl",(function(t){n.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("vipr",(function(t){n.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createFullBoxCtor("sbgp",(function(t){this.grouping_type=t.readString(4),1===this.version?this.grouping_type_parameter=t.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var e=t.readUint32(),i=0;i>6,this.sample_depends_on[r]=e>>4&3,this.sample_is_depended_on[r]=e>>2&3,this.sample_has_redundancy[r]=3&e})),p.createFullBoxCtor("senc"),p.createFullBoxCtor("sgpd",(function(t){this.grouping_type=t.readString(4),n.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),1===this.version?this.default_length=t.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=t.readUint32()),this.entries=[];for(var e=t.readUint32(),i=0;i>31&1,r.referenced_size=2147483647&s,r.subsegment_duration=t.readUint32(),s=t.readUint32(),r.starts_with_SAP=s>>31&1,r.SAP_type=s>>28&7,r.SAP_delta_time=268435455&s}})),p.SingleItemTypeReferenceBox=function(t,e,i,r){p.Box.call(this,t,e),this.hdr_size=i,this.start=r},p.SingleItemTypeReferenceBox.prototype=new p.Box,p.SingleItemTypeReferenceBox.prototype.parse=function(t){this.from_item_ID=t.readUint16();var e=t.readUint16();this.references=[];for(var i=0;i>4&15,this.sample_sizes[e+1]=15&r}else if(8===this.field_size)for(e=0;e0)for(i=0;i>4&15,this.default_skip_byte_block=15&e}this.default_isProtected=t.readUint8(),this.default_Per_Sample_IV_Size=t.readUint8(),this.default_KID=p.parseHex16(t),1===this.default_isProtected&&0===this.default_Per_Sample_IV_Size&&(this.default_constant_IV_size=t.readUint8(),this.default_constant_IV=t.readUint8Array(this.default_constant_IV_size))})),p.createFullBoxCtor("tfdt",(function(t){1==this.version?this.baseMediaDecodeTime=t.readUint64():this.baseMediaDecodeTime=t.readUint32()})),p.createFullBoxCtor("tfhd",(function(t){var e=0;this.track_id=t.readUint32(),this.size-this.hdr_size>e&&this.flags&p.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=t.readUint64(),e+=8):this.base_data_offset=0,this.size-this.hdr_size>e&&this.flags&p.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=t.readUint32(),e+=4):this.default_sample_description_index=0,this.size-this.hdr_size>e&&this.flags&p.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=t.readUint32(),e+=4):this.default_sample_duration=0,this.size-this.hdr_size>e&&this.flags&p.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=t.readUint32(),e+=4):this.default_sample_size=0,this.size-this.hdr_size>e&&this.flags&p.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=t.readUint32(),e+=4):this.default_sample_flags=0})),p.createFullBoxCtor("tfra",(function(t){this.track_ID=t.readUint32(),t.readUint24();var e=t.readUint8();this.length_size_of_traf_num=e>>4&3,this.length_size_of_trun_num=e>>2&3,this.length_size_of_sample_num=3&e,this.entries=[];for(var i=t.readUint32(),r=0;r>8,t.readUint16(),this.matrix=t.readInt32Array(9),this.width=t.readUint32(),this.height=t.readUint32()})),p.createBoxCtor("tmax",(function(t){this.time=t.readUint32()})),p.createBoxCtor("tmin",(function(t){this.time=t.readUint32()})),p.createBoxCtor("totl",(function(t){this.bytessent=t.readUint32()})),p.createBoxCtor("tpay",(function(t){this.bytessent=t.readUint32()})),p.createBoxCtor("tpyl",(function(t){this.bytessent=t.readUint64()})),p.TrackGroupTypeBox.prototype.parse=function(t){this.parseFullHeader(t),this.track_group_id=t.readUint32()},p.createTrackGroupCtor("msrc"),p.TrackReferenceTypeBox=function(t,e,i,r){p.Box.call(this,t,e),this.hdr_size=i,this.start=r},p.TrackReferenceTypeBox.prototype=new p.Box,p.TrackReferenceTypeBox.prototype.parse=function(t){this.track_ids=t.readUint32Array((this.size-this.hdr_size)/4)},p.trefBox.prototype.parse=function(t){for(var e,i;t.getPosition()e&&this.flags&p.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=t.readInt32(),e+=4):this.data_offset=0,this.size-this.hdr_size>e&&this.flags&p.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=t.readUint32(),e+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>e)for(var i=0;i>7&1,this.block_pad_lsb=i>>6&1,this.block_little_endian=i>>5&1,this.block_reversed=i>>4&1,this.pad_unknown=i>>3&1,this.pixel_size=t.readUint8(),this.row_align_size=t.readUint32(),this.tile_align_size=t.readUint32(),this.num_tile_cols_minus_one=t.readUint32(),this.num_tile_rows_minus_one=t.readUint32()})),p.createFullBoxCtor("url ",(function(t){1!==this.flags&&(this.location=t.readCString())})),p.createFullBoxCtor("urn ",(function(t){this.name=t.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=t.readCString())})),p.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,(function(t){this.LiveServerManifest=t.readString(this.size-this.hdr_size).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")})),p.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,(function(t){this.system_id=p.parseHex16(t);var e=t.readUint32();e>0&&(this.data=t.readUint8Array(e))})),p.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),p.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,(function(t){this.default_AlgorithmID=t.readUint24(),this.default_IV_size=t.readUint8(),this.default_KID=p.parseHex16(t)})),p.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,(function(t){this.fragment_count=t.readUint8(),this.entries=[];for(var e=0;e>4,this.chromaSubsampling=e>>1&7,this.videoFullRangeFlag=1&e,this.colourPrimaries=t.readUint8(),this.transferCharacteristics=t.readUint8(),this.matrixCoefficients=t.readUint8(),this.codecIntializationDataSize=t.readUint16(),this.codecIntializationData=t.readUint8Array(this.codecIntializationDataSize)):(this.profile=t.readUint8(),this.level=t.readUint8(),e=t.readUint8(),this.bitDepth=e>>4&15,this.colorSpace=15&e,e=t.readUint8(),this.chromaSubsampling=e>>4&15,this.transferFunction=e>>1&7,this.videoFullRangeFlag=1&e,this.codecIntializationDataSize=t.readUint16(),this.codecIntializationData=t.readUint8Array(this.codecIntializationDataSize))})),p.createBoxCtor("vttC",(function(t){this.text=t.readString(this.size-this.hdr_size)})),p.createFullBoxCtor("vvcC",(function(t){var e,i,r={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(t){this.held_bits=t.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(t){this.held_bits=t.readUint16(),this.num_held_bits=16},extract_bits:function(t){var e=this.held_bits>>this.num_held_bits-t&(1<1){for(r.stream_read_1_bytes(t),this.ptl_sublayer_present_mask=0,i=this.num_sublayers-2;i>=0;--i){var a=r.extract_bits(1);this.ptl_sublayer_present_mask|=a<1;++i)r.extract_bits(1);for(this.sublayer_level_idc=[],i=this.num_sublayers-2;i>=0;--i)this.ptl_sublayer_present_mask&1<>=1;e+=p.decimalToHex(r,0),e+=".",0===this.hvcC.general_tier_flag?e+="L":e+="H",e+=this.hvcC.general_level_idc;var s=!1,n="";for(t=5;t>=0;t--)(this.hvcC.general_constraint_indicator[t]||s)&&(n="."+p.decimalToHex(this.hvcC.general_constraint_indicator[t],0)+n,s=!0);e+=n}return e},p.vvc1SampleEntry.prototype.getCodec=p.vvi1SampleEntry.prototype.getCodec=function(){var t,e=p.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){e+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?e+=".H":e+=".L",e+=this.vvcC.general_level_idc;var i="";if(this.vvcC.general_constraint_info){var r,s=[],n=0;for(n|=this.vvcC.ptl_frame_only_constraint<<7,n|=this.vvcC.ptl_multilayer_enabled<<6,t=0;t>2&63,s.push(n),n&&(r=t),n=this.vvcC.general_constraint_info[t]>>2&3;if(void 0===r)i=".CA";else{i=".C";var a="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",o=0,h=0;for(t=0;t<=r;++t)for(o=o<<8|s[t],h+=8;h>=5;){i+=a[o>>h-5&31],o&=(1<<(h-=5))-1}h&&(i+=a[31&(o<<=5-h)])}}e+=i}return e},p.mp4aSampleEntry.prototype.getCodec=function(){var t=p.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var e=this.esds.esd.getOTI(),i=this.esds.esd.getAudioConfig();return t+"."+p.decimalToHex(e)+(i?"."+i:"")}return t},p.stxtSampleEntry.prototype.getCodec=function(){var t=p.SampleEntry.prototype.getCodec.call(this);return this.mime_format?t+"."+this.mime_format:t},p.vp08SampleEntry.prototype.getCodec=p.vp09SampleEntry.prototype.getCodec=function(){var t=p.SampleEntry.prototype.getCodec.call(this),e=this.vpcC.level;0==e&&(e="00");var i=this.vpcC.bitDepth;return 8==i&&(i="08"),t+".0"+this.vpcC.profile+"."+e+"."+i},p.av01SampleEntry.prototype.getCodec=function(){var t,e=p.SampleEntry.prototype.getCodec.call(this),i=this.av1C.seq_level_idx_0;return i<10&&(i="0"+i),2===this.av1C.seq_profile&&1===this.av1C.high_bitdepth?t=1===this.av1C.twelve_bit?"12":"10":this.av1C.seq_profile<=2&&(t=1===this.av1C.high_bitdepth?"10":"08"),e+"."+this.av1C.seq_profile+"."+i+(this.av1C.seq_tier_0?"H":"M")+"."+t},p.Box.prototype.writeHeader=function(t,e){this.size+=8,this.size>h&&(this.size+=8),"uuid"===this.type&&(this.size+=16),n.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+t.getPosition()+(e||"")),this.size>h?t.writeUint32(1):(this.sizePosition=t.getPosition(),t.writeUint32(this.size)),t.writeString(this.type,null,4),"uuid"===this.type&&t.writeUint8Array(this.uuid),this.size>h&&t.writeUint64(this.size)},p.FullBox.prototype.writeHeader=function(t){this.size+=4,p.Box.prototype.writeHeader.call(this,t," v="+this.version+" f="+this.flags),t.writeUint8(this.version),t.writeUint24(this.flags)},p.Box.prototype.write=function(t){"mdat"===this.type?this.data&&(this.size=this.data.length,this.writeHeader(t),t.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(t),this.data&&t.writeUint8Array(this.data))},p.ContainerBox.prototype.write=function(t){this.size=0,this.writeHeader(t);for(var e=0;e=2&&t.writeUint32(this.default_sample_description_index),t.writeUint32(this.entries.length),e=0;e0)for(e=0;e+1e?1:0,this.flags=0,this.size=4,1===this.version&&(this.size+=4),this.writeHeader(t),1===this.version?t.writeUint64(this.baseMediaDecodeTime):t.writeUint32(this.baseMediaDecodeTime)},p.tfhdBox.prototype.write=function(t){this.version=0,this.size=4,this.flags&p.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&p.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&p.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&p.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&p.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(t),t.writeUint32(this.track_id),this.flags&p.TFHD_FLAG_BASE_DATA_OFFSET&&t.writeUint64(this.base_data_offset),this.flags&p.TFHD_FLAG_SAMPLE_DESC&&t.writeUint32(this.default_sample_description_index),this.flags&p.TFHD_FLAG_SAMPLE_DUR&&t.writeUint32(this.default_sample_duration),this.flags&p.TFHD_FLAG_SAMPLE_SIZE&&t.writeUint32(this.default_sample_size),this.flags&p.TFHD_FLAG_SAMPLE_FLAGS&&t.writeUint32(this.default_sample_flags)},p.tkhdBox.prototype.write=function(t){this.version=0,this.size=80,this.writeHeader(t),t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.track_id),t.writeUint32(0),t.writeUint32(this.duration),t.writeUint32(0),t.writeUint32(0),t.writeInt16(this.layer),t.writeInt16(this.alternate_group),t.writeInt16(this.volume<<8),t.writeUint16(0),t.writeInt32Array(this.matrix),t.writeUint32(this.width),t.writeUint32(this.height)},p.trexBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=20,this.writeHeader(t),t.writeUint32(this.track_id),t.writeUint32(this.default_sample_description_index),t.writeUint32(this.default_sample_duration),t.writeUint32(this.default_sample_size),t.writeUint32(this.default_sample_flags)},p.trunBox.prototype.write=function(t){this.version=0,this.size=4,this.flags&p.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&p.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&p.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&p.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&p.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&p.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(t),t.writeUint32(this.sample_count),this.flags&p.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=t.getPosition(),t.writeInt32(this.data_offset)),this.flags&p.TRUN_FLAGS_FIRST_FLAG&&t.writeUint32(this.first_sample_flags);for(var e=0;e-1||t[i]instanceof p.Box||e[i]instanceof p.Box||void 0===t[i]||void 0===e[i]||"function"==typeof t[i]||"function"==typeof e[i]||t.subBoxNames&&t.subBoxNames.indexOf(i.slice(0,4))>-1||e.subBoxNames&&e.subBoxNames.indexOf(i.slice(0,4))>-1||"data"===i||"start"===i||"size"===i||"creation_time"===i||"modification_time"===i||p.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(i)>-1||t[i]===e[i]))return!1;return!0},p.boxEqual=function(t,e){if(!p.boxEqualFields(t,e))return!1;for(var i=0;i1)for(e=1;e-1&&this.fragmentedTracks.splice(e,1)},c.prototype.setExtractionOptions=function(t,e,i){var r=this.getTrackById(t);if(r){var s={};this.extractedTracks.push(s),s.id=t,s.user=e,s.trak=r,r.nextSample=0,s.nb_samples=1e3,s.samples=[],i&&i.nbSamples&&(s.nb_samples=i.nbSamples)}},c.prototype.unsetExtractionOptions=function(t){for(var e=-1,i=0;i-1&&this.extractedTracks.splice(e,1)},c.prototype.parse=function(){var t,e;if(!this.restoreParsePosition||this.restoreParsePosition())for(;;){if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}if(this.saveParsePosition&&this.saveParsePosition(),(t=p.parseOneBox(this.stream,false)).code===p.ERR_NOT_ENOUGH_DATA){if(this.processIncompleteBox){if(this.processIncompleteBox(t))continue;return}return}var i;switch(i="uuid"!==(e=t.box).type?e.type:e.uuid,this.boxes.push(e),i){case"mdat":this.mdats.push(e);break;case"moof":this.moofs.push(e);break;case"moov":this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0);default:void 0!==this[i]&&n.warn("ISOFile","Duplicate Box of type: "+i+", overriding previous occurrence"),this[i]=e}this.updateUsedBytes&&this.updateUsedBytes(e,t)}},c.prototype.checkBuffer=function(t){if(null==t)throw"Buffer must be defined and non empty";if(void 0===t.fileStart)throw"Buffer must have a fileStart property";return 0===t.byteLength?(n.warn("ISOFile","Ignoring empty buffer (fileStart: "+t.fileStart+")"),this.stream.logBufferLevel(),!1):(n.info("ISOFile","Processing buffer (fileStart: "+t.fileStart+")"),t.usedBytes=0,this.stream.insertBuffer(t),this.stream.logBufferLevel(),!!this.stream.initialized()||(n.warn("ISOFile","Not ready to start parsing"),!1))},c.prototype.appendBuffer=function(t,e){var i;if(this.checkBuffer(t))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(e),this.nextSeekPosition?(i=this.nextSeekPosition,this.nextSeekPosition=void 0):i=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(i=this.stream.getEndFilePositionAfter(i))):i=this.nextParsePosition?this.nextParsePosition:0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(n.info("ISOFile","Done processing buffer (fileStart: "+t.fileStart+") - next buffer to fetch should have a fileStart position of "+i),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),n.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i},c.prototype.getInfo=function(){var t,e,i,r,s,n,a={},o=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(a.hasMoov=!0,a.duration=this.moov.mvhd.duration,a.timescale=this.moov.mvhd.timescale,a.isFragmented=null!=this.moov.mvex,a.isFragmented&&this.moov.mvex.mehd&&(a.fragment_duration=this.moov.mvex.mehd.fragment_duration),a.isProgressive=this.isProgressive,a.hasIOD=null!=this.moov.iods,a.brands=[],a.brands.push(this.ftyp.major_brand),a.brands=a.brands.concat(this.ftyp.compatible_brands),a.created=new Date(o+1e3*this.moov.mvhd.creation_time),a.modified=new Date(o+1e3*this.moov.mvhd.modification_time),a.tracks=[],a.audioTracks=[],a.videoTracks=[],a.subtitleTracks=[],a.metadataTracks=[],a.hintTracks=[],a.otherTracks=[],t=0;t0?a.mime+='video/mp4; codecs="':a.audioTracks&&a.audioTracks.length>0?a.mime+='audio/mp4; codecs="':a.mime+='application/mp4; codecs="',t=0;t=i.samples.length)&&(n.info("ISOFile","Sending fragmented data on track #"+r.id+" for samples ["+Math.max(0,i.nextSample-r.nb_samples)+","+(i.nextSample-1)+"]"),n.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(r.id,r.user,r.segmentStream.buffer,i.nextSample,t||i.nextSample>=i.samples.length),r.segmentStream=null,r!==this.fragmentedTracks[e]))break}}if(null!==this.onSamples)for(e=0;e=i.samples.length)&&(n.debug("ISOFile","Sending samples on track #"+a.id+" for sample "+i.nextSample),this.onSamples&&this.onSamples(a.id,a.user,a.samples),a.samples=[],a!==this.extractedTracks[e]))break}}}},c.prototype.getBox=function(t){var e=this.getBoxes(t,!0);return e.length?e[0]:null},c.prototype.getBoxes=function(t,e){var i=[];return c._sweep.call(this,t,i,e),i},c._sweep=function(t,e,i){for(var r in this.type&&this.type==t&&e.push(this),this.boxes){if(e.length&&i)return;c._sweep.call(this.boxes[r],t,e,i)}},c.prototype.getTrackSamplesInfo=function(t){var e=this.getTrackById(t);return e?e.samples:void 0},c.prototype.getTrackSample=function(t,e){var i=this.getTrackById(t);return this.getSample(i,e)},c.prototype.releaseUsedSamples=function(t,e){var i=0,r=this.getTrackById(t);r.lastValidSample||(r.lastValidSample=0);for(var s=r.lastValidSample;st*s.timescale){d=r-1;break}e&&s.is_sync&&(h=r)}for(e&&(d=h),t=i.samples[d].cts,i.nextSample=d;i.samples[d].alreadyRead===i.samples[d].size&&i.samples[d+1];)d++;return a=i.samples[d].offset+i.samples[d].alreadyRead,n.info("ISOFile","Seeking to "+(e?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+n.getDurationString(t,o)+" and offset: "+a),{offset:a,time:t/o}},c.prototype.getTrackDuration=function(t){var e;return t.samples?((e=t.samples[t.samples.length-1]).cts+e.duration)/e.timescale:1/0},c.prototype.seek=function(t,e){var i,r,s,a=this.moov,o={offset:1/0,time:1/0};if(this.moov){for(s=0;sthis.getTrackDuration(i)||((r=this.seekTrack(t,e,i)).offset-1){o=h;break}switch(o){case"Visual":if(s.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),n.set("width",e.width).set("height",e.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",e.type+" Compressor").set("depth",24),e.avcDecoderConfigRecord){var u=new p.avcCBox;u.parse(new a(e.avcDecoderConfigRecord)),n.addBox(u)}else if(e.hevcDecoderConfigRecord){var f=new p.hvcCBox;f.parse(new a(e.hevcDecoderConfigRecord)),n.addBox(f)}break;case"Audio":s.add("smhd").set("balance",e.balance||0),n.set("channel_count",e.channel_count||2).set("samplesize",e.samplesize||16).set("samplerate",e.samplerate||65536);break;case"Hint":s.add("hmhd");break;case"Subtitle":if(s.add("sthd"),"stpp"===e.type)n.set("namespace",e.namespace||"nonamespace").set("schema_location",e.schema_location||"").set("auxiliary_mime_types",e.auxiliary_mime_types||"");break;default:s.add("nmhd")}e.description&&n.addBox(e.description),e.description_boxes&&e.description_boxes.forEach((function(t){n.addBox(t)})),s.add("dinf").add("dref").addEntry((new p["url Box"]).set("flags",1));var c=s.add("stbl");return c.add("stsd").addEntry(n),c.add("stts").set("sample_counts",[]).set("sample_deltas",[]),c.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),c.add("stco").set("chunk_offsets",[]),c.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",e.id).set("default_sample_description_index",e.default_sample_description_index||1).set("default_sample_duration",e.default_sample_duration||0).set("default_sample_size",e.default_sample_size||0).set("default_sample_flags",e.default_sample_flags||0),this.buildTrakSampleLists(i),e.id}},p.Box.prototype.computeSize=function(t){var e=t||new o;e.endianness=o.BIG_ENDIAN,this.write(e)},c.prototype.addSample=function(t,e,i){var r=i||{},s={},n=this.getTrackById(t);if(null!==n){s.number=n.samples.length,s.track_id=n.tkhd.track_id,s.timescale=n.mdia.mdhd.timescale,s.description_index=r.sample_description_index?r.sample_description_index-1:0,s.description=n.mdia.minf.stbl.stsd.entries[s.description_index],s.data=e,s.size=e.byteLength,s.alreadyRead=s.size,s.duration=r.duration||1,s.cts=r.cts||0,s.dts=r.dts||0,s.is_sync=r.is_sync||!1,s.is_leading=r.is_leading||0,s.depends_on=r.depends_on||0,s.is_depended_on=r.is_depended_on||0,s.has_redundancy=r.has_redundancy||0,s.degradation_priority=r.degradation_priority||0,s.offset=0,s.subsamples=r.subsamples,n.samples.push(s),n.samples_size+=s.size,n.samples_duration+=s.duration,void 0===n.first_dts&&(n.first_dts=r.dts),this.processSamples();var a=this.createSingleSampleMoof(s);return this.addBox(a),a.computeSize(),a.trafs[0].truns[0].data_offset=a.size+8,this.add("mdat").data=new Uint8Array(e),s}},c.prototype.createSingleSampleMoof=function(t){var e=0;e=t.is_sync?1<<25:65536;var i=new p.moofBox;i.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var r=i.add("traf"),s=this.getTrackById(t.track_id);return r.add("tfhd").set("track_id",t.track_id).set("flags",p.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),r.add("tfdt").set("baseMediaDecodeTime",t.dts-(s.first_dts||0)),r.add("trun").set("flags",p.TRUN_FLAGS_DATA_OFFSET|p.TRUN_FLAGS_DURATION|p.TRUN_FLAGS_SIZE|p.TRUN_FLAGS_FLAGS|p.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[t.duration]).set("sample_size",[t.size]).set("sample_flags",[e]).set("sample_composition_time_offset",[t.cts-t.dts]),i},c.prototype.lastMoofIndex=0,c.prototype.samplesDataSize=0,c.prototype.resetTables=function(){var t,e,i,r,s,n;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,t=0;t=2&&(h=s[a].grouping_type+"/0",(o=new d(s[a].grouping_type,0)).is_fragment=!0,e.sample_groups_info[h]||(e.sample_groups_info[h]=o))}else for(a=0;a=2&&(h=r[a].grouping_type+"/0",o=new d(r[a].grouping_type,0),t.sample_groups_info[h]||(t.sample_groups_info[h]=o))},c.setSampleGroupProperties=function(t,e,i,r){var s,n;for(s in e.sample_groups=[],r){var a;if(e.sample_groups[s]={},e.sample_groups[s].grouping_type=r[s].grouping_type,e.sample_groups[s].grouping_type_parameter=r[s].grouping_type_parameter,i>=r[s].last_sample_in_run&&(r[s].last_sample_in_run<0&&(r[s].last_sample_in_run=0),r[s].entry_index++,r[s].entry_index<=r[s].sbgp.entries.length-1&&(r[s].last_sample_in_run+=r[s].sbgp.entries[r[s].entry_index].sample_count)),r[s].entry_index<=r[s].sbgp.entries.length-1?e.sample_groups[s].group_description_index=r[s].sbgp.entries[r[s].entry_index].group_description_index:e.sample_groups[s].group_description_index=-1,0!==e.sample_groups[s].group_description_index)a=r[s].fragment_description?r[s].fragment_description:r[s].description,e.sample_groups[s].group_description_index>0?(n=e.sample_groups[s].group_description_index>65535?(e.sample_groups[s].group_description_index>>16)-1:e.sample_groups[s].group_description_index-1,a&&n>=0&&(e.sample_groups[s].description=a.entries[n])):a&&a.version>=2&&a.default_group_description_index>0&&(e.sample_groups[s].description=a.entries[a.default_group_description_index-1])}},c.process_sdtp=function(t,e,i){e&&(t?(e.is_leading=t.is_leading[i],e.depends_on=t.sample_depends_on[i],e.is_depended_on=t.sample_is_depended_on[i],e.has_redundancy=t.sample_has_redundancy[i]):(e.is_leading=0,e.depends_on=0,e.is_depended_on=0,e.has_redundancy=0))},c.prototype.buildSampleLists=function(){var t,e;for(t=0;tb&&(v++,b<0&&(b=0),b+=n.sample_counts[v]),e>0?(t.samples[e-1].duration=n.sample_deltas[v],t.samples_duration+=t.samples[e-1].duration,E.dts=t.samples[e-1].dts+t.samples[e-1].duration):E.dts=0,a?(e>=S&&(w++,S<0&&(S=0),S+=a.sample_counts[w]),E.cts=t.samples[e].dts+a.sample_offsets[w]):E.cts=E.dts,o?(e==o.sample_numbers[U]-1?(E.is_sync=!0,U++):(E.is_sync=!1,E.degradation_priority=0),d&&d.entries[T].sample_delta+x==e+1&&(E.subsamples=d.entries[T].subsamples,x+=d.entries[T].sample_delta,T++)):E.is_sync=!0,c.process_sdtp(t.mdia.minf.stbl.sdtp,E,E.number),E.degradation_priority=u?u.priority[e]:0,d&&d.entries[T].sample_delta+x==e&&(E.subsamples=d.entries[T].subsamples,x+=d.entries[T].sample_delta),(l.length>0||p.length>0)&&c.setSampleGroupProperties(t,E,e,t.sample_groups_info)}e>0&&(t.samples[e-1].duration=Math.max(t.mdia.mdhd.duration-t.samples[e-1].dts,0),t.samples_duration+=t.samples[e-1].duration)}},c.prototype.updateSampleLists=function(){var t,e,i,r,s,n,a,o,h,d,l,u,f,m,g;if(void 0!==this.moov)for(;this.lastMoofIndex0&&c.initSampleGroups(u,l,l.sbgps,u.mdia.minf.stbl.sgpds,l.sgpds),e=0;e0?m.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(l.tfdt?m.dts=l.tfdt.baseMediaDecodeTime:m.dts=0,u.first_traf_merged=!0),m.cts=m.dts,_.flags&p.TRUN_FLAGS_CTS_OFFSET&&(m.cts=m.dts+_.sample_composition_time_offset[i]),g=a,_.flags&p.TRUN_FLAGS_FLAGS?g=_.sample_flags[i]:0===i&&_.flags&p.TRUN_FLAGS_FIRST_FLAG&&(g=_.first_sample_flags),m.is_sync=!(g>>16&1),m.is_leading=g>>26&3,m.depends_on=g>>24&3,m.is_depended_on=g>>22&3,m.has_redundancy=g>>20&3,m.degradation_priority=65535&g;var y=!!(l.tfhd.flags&p.TFHD_FLAG_BASE_DATA_OFFSET),b=!!(l.tfhd.flags&p.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),v=!!(_.flags&p.TRUN_FLAGS_DATA_OFFSET),S=0;S=y?l.tfhd.base_data_offset:b||0===e?d.start:o,m.offset=0===e&&0===i?v?S+_.data_offset:S:o,o=m.offset+m.size,(l.sbgps.length>0||l.sgpds.length>0||u.mdia.minf.stbl.sbgps.length>0||u.mdia.minf.stbl.sgpds.length>0)&&c.setSampleGroupProperties(u,m,m.number_in_traf,l.sample_groups_info)}}if(l.subs){u.has_fragment_subsamples=!0;var w=l.first_sample_index;for(e=0;e-1))return null;var a=(i=this.stream.buffers[s]).byteLength-(r.offset+r.alreadyRead-i.fileStart);if(r.size-r.alreadyRead<=a)return n.debug("ISOFile","Getting sample #"+e+" data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-i.fileStart)+" read size: "+(r.size-r.alreadyRead)+" full size: "+r.size+")"),o.memcpy(r.data.buffer,r.alreadyRead,i,r.offset+r.alreadyRead-i.fileStart,r.size-r.alreadyRead),i.usedBytes+=r.size-r.alreadyRead,this.stream.logBufferLevel(),r.alreadyRead=r.size,r;if(0===a)return null;n.debug("ISOFile","Getting sample #"+e+" partial data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-i.fileStart)+" read size: "+a+" full size: "+r.size+")"),o.memcpy(r.data.buffer,r.alreadyRead,i,r.offset+r.alreadyRead-i.fileStart,a),r.alreadyRead+=a,i.usedBytes+=a,this.stream.logBufferLevel()}},c.prototype.releaseSample=function(t,e){var i=t.samples[e];return i.data?(this.samplesDataSize-=i.size,i.data=null,i.alreadyRead=0,i.size):0},c.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},c.prototype.getCodecs=function(){var t,e="";for(t=0;t0&&(e+=","),e+=this.moov.traks[t].mdia.minf.stbl.stsd.entries[0].getCodec()}return e},c.prototype.getTrexById=function(t){var e;if(!this.moov||!this.moov.mvex)return null;for(e=0;e0&&(i.protection=s.ipro.protections[s.iinf.item_infos[t].protection_index-1]),s.iinf.item_infos[t].item_type?i.type=s.iinf.item_infos[t].item_type:i.type="mime",i.content_type=s.iinf.item_infos[t].content_type,i.content_encoding=s.iinf.item_infos[t].content_encoding;if(s.iloc)for(t=0;t0&&p.property_index-1-1))return null;var h=(e=this.stream.buffers[a]).byteLength-(s.offset+s.alreadyRead-e.fileStart);if(!(s.length-s.alreadyRead<=h))return n.debug("ISOFile","Getting item #"+t+" extent #"+r+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-e.fileStart)+" read size: "+h+" full extent size: "+s.length+" full item size: "+i.size+")"),o.memcpy(i.data.buffer,i.alreadyRead,e,s.offset+s.alreadyRead-e.fileStart,h),s.alreadyRead+=h,i.alreadyRead+=h,e.usedBytes+=h,this.stream.logBufferLevel(),null;n.debug("ISOFile","Getting item #"+t+" extent #"+r+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-e.fileStart)+" read size: "+(s.length-s.alreadyRead)+" full extent size: "+s.length+" full item size: "+i.size+")"),o.memcpy(i.data.buffer,i.alreadyRead,e,s.offset+s.alreadyRead-e.fileStart,s.length-s.alreadyRead),e.usedBytes+=s.length-s.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead+=s.length-s.alreadyRead,s.alreadyRead=s.length}}return i.alreadyRead===i.size?i:null},c.prototype.releaseItem=function(t){var e=this.items[t];if(e.data){this.itemsDataSize-=e.size,e.data=null,e.alreadyRead=0;for(var i=0;i0?this.moov.traks[t].samples[0].duration:0),e.push(r)}return e},p.Box.prototype.printHeader=function(t){this.size+=8,this.size>h&&(this.size+=8),"uuid"===this.type&&(this.size+=16),t.log(t.indent+"size:"+this.size),t.log(t.indent+"type:"+this.type)},p.FullBox.prototype.printHeader=function(t){this.size+=4,p.Box.prototype.printHeader.call(this,t),t.log(t.indent+"version:"+this.version),t.log(t.indent+"flags:"+this.flags)},p.Box.prototype.print=function(t){this.printHeader(t)},p.ContainerBox.prototype.print=function(t){this.printHeader(t);for(var e=0;e>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"next_track_id: "+this.next_track_id)},p.tkhdBox.prototype.print=function(t){p.FullBox.prototype.printHeader.call(this,t),t.log(t.indent+"creation_time: "+this.creation_time),t.log(t.indent+"modification_time: "+this.modification_time),t.log(t.indent+"track_id: "+this.track_id),t.log(t.indent+"duration: "+this.duration),t.log(t.indent+"volume: "+(this.volume>>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"layer: "+this.layer),t.log(t.indent+"alternate_group: "+this.alternate_group),t.log(t.indent+"width: "+this.width),t.log(t.indent+"height: "+this.height)};var m={createFile:function(t,e){var i=void 0===t||t,r=new c(e);return r.discardMdatData=!i,r}};t.createFile=m.createFile}(Ps);var Ls=p(Ps);const zs=()=>{let t;self.onmessage=e=>{"start"===e.data.event&&(self.clearInterval(t),t=self.setInterval((()=>{self.postMessage({})}),16.6)),"stop"===e.data.event&&self.clearInterval(t)}},Fs=new Map;let Rs=1;const Os=(()=>{const t=new Blob([`(${zs.toString()})()`]),e=URL.createObjectURL(t);return new Worker(e)})();Os.onmessage=()=>{Rs+=1;for(const[t,e]of Fs.entries())Rs%t==0&&e.forEach((t=>t()))};function Ms(t,e={onChunk:onChunk,onDone:onDone}){let i=!1;return async function(){const r=t.getReader();for(;!i;){const{value:t,done:i}=await r.read();if(i)return void(e.onDone&&e.onDone());await e.onChunk(t)}r.releaseLock(),await t.cancel()}().catch(console.error),()=>{i=!0}}class Ns{readable;writable;#t=0;constructor(){const t=Ls.createFile();let e=0,i=!1;this.readable=new ReadableStream({start:i=>{t.onReady=e=>{const r=e.videoTracks[0]?.id;null!=r&&t.setExtractionOptions(r,"video",{nbSamples:100});const s=e.audioTracks[0]?.id;null!=s&&t.setExtractionOptions(s,"audio",{nbSamples:100}),i.enqueue({chunkType:"ready",data:{info:e,file:t}}),t.start()},t.onSamples=(t,r,s)=>{i.enqueue({chunkType:"samples",data:{id:t,type:r,samples:s}}),e=i.desiredSize??0},t.onFlush=()=>{i.close()}},pull:t=>{e=t.desiredSize??0},cancel:()=>{t.stop(),i=!0}},{highWaterMark:50}),this.writable=new WritableStream({write:async r=>{if(i)return void this.writable.abort();const s=r.buffer;for(s.fileStart=this.#t,this.#t+=s.byteLength,t.appendBuffer(s);e<0;)console.warn("outCtrlDesiredSize < 0::sleep"),await Hs(50)},close:()=>{t.flush(),t.stop(),t.onFlush?.()}})}}function Gs(t){return{type:t.is_sync?"key":"delta",timestamp:1e6*t.cts/t.timescale,duration:1e6*t.duration/t.timescale,data:t.data}}function Vs(t,e){const i=e.videoTracks[0],r={};if(null!=i){const s=function(t){for(const e of t.mdia.minf.stbl.stsd.entries){const t=e.avcC??e.hvcC??e.vpcC;if(null!=t){const e=new Ls.DataStream(void 0,0,Ls.DataStream.BIG_ENDIAN);return t.write(e),new Uint8Array(e.buffer.slice(8))}}throw Error("avcC, hvcC or VPX not found")}(t.getTrackById(i.id)).buffer,{descKey:n,type:a}=i.codec.startsWith("avc1")?{descKey:"avcDecoderConfigRecord",type:"avc1"}:i.codec.startsWith("hvc1")?{descKey:"hevcDecoderConfigRecord",type:"hvc1"}:{descKey:"",type:""};""!==n&&(r.videoTrackConf={timescale:i.timescale,duration:i.duration,width:i.video.width,height:i.video.height,brands:e.brands,type:a,[n]:s}),r.videoDecoderConf={codec:i.codec,codedHeight:i.video.height,codedWidth:i.video.width,description:s}}return r}function Hs(t){return new Promise((e=>{const i=((t,e)=>{const i=Math.round(e/16.6),r=Fs.get(i)??new Set;return r.add(t),Fs.set(i,r),1===Fs.size&&1===r.size&&Os.postMessage({event:"start"}),()=>{r.delete(t),0===r.size&&Fs.delete(i),0===Fs.size&&(Rs=0,Os.postMessage({event:"stop"}))}})((()=>{i(),e()}),t)}))}class Ys{constructor({onOutput:t,onError:e}){this.stopReadStream=null,this.mp4File=null,this.vdecoder=new VideoDecoder({output:e=>{t&&t(e)},error:t=>{e&&e(t)}})}async decode({data:t,start:e,end:i,onReady:r,onDone:s}){return await new Promise((async n=>{if(!t)return n();const a=new ReadableStream({start(e){e.enqueue(t),e.close()}});let o=!0,h=!0,d=0;this.stopReadStream=Ms(a.pipeThrough(new Ns),{onChunk:async({chunkType:t,data:s})=>{if("ready"===t){this.mp4File=s.file,s.info;const{videoDecoderConf:t}=Vs(s.file,s.info);return this.vdecoder.configure(t),void(r&&r(s.info))}if("samples"===t){const{id:t,type:r,samples:n}=s,a=n.length,l=n[a-1],p=1e6*l.cts/l.timescale;let u=0;if(e>p){if(u=n.findLastIndex((t=>t.is_sync)),u>=0)for(let t=u;ti)&&"video"===r){if(h&&0===t&&0!==s.cts?(s.cts=0,h=!1):h=!0,o&&!s.is_sync)for(let e=d;e{try{"configured"===this.vdecoder.state&&await this.vdecoder.flush(),this.mp4File.stream.cleanBuffers(),this.mp4File.stream=null,this.mp4File=null,s&&s()}catch(t){console.warn("videoDecode::onDone",t)}n()}})}))}destroy(){try{this.stopReadStream&&this.stopReadStream(),this.mp4File?.stop();for(const t in this.mp4File)Object.hasOwnProperty.call(this.mp4File,t)&&(this.mp4File[t]=null);this.mp4File=null,this.vdecoder.close(),this.vdecoder=null}catch(t){console.warn(t)}}}const Ws=t=>new Promise(((e,i)=>{const r=function(t){const e=188,i=71,r=t;let s=[],n=0,a=0;for(let t=0;t+e<=r.length;t+=e){const o=r.subarray(t,t+e);o[0]===i?(n++,s.push(o)):(a=n,console.error(`同步字节错误:在位置 ${t} 未找到 0x47`))}if(a>0)return void console.error(`发现 ${a} 个错误的包`);return s}(t);if(!r)return void i();let s,n=[],a=[];for(let t=0;t>7,pusi:(64&e[1])>>6,transportPriority:(32&e[1])>>5,pid:(31&e[1])<<8|e[2],scramblingControl:(192&e[3])>>6,adaptationFieldControl:(48&e[3])>>4,continuityCounter:15&e[3]}}}function qs(t){if(0!==t[0]||0!==t[1]||1!==t[2])throw new Error("Invalid PES start code");const e=t[3],i=t[4]<<8|t[5];let r=6;if(190!==e&&191!==e){r+=3+t[8]}const s=new Uint8Array(t.slice(r,r+i));let n=null,a=null;if(190!==e&&191!==e){const e=t[7],i=(64&e)>>6;(128&e)>>7&&(n=Xs(t,9)),i&&(a=Xs(t,14))}return{pesHeaderInfo:{streamId:e,pesLength:i,pts:n,dts:a},payload:s}}function Ks(t){let e=4;const i=(48&t[3])>>4;if(2===i||3===i){e+=t[4]+1}if(1===i||3===i)return t.subarray(e)}function Xs(t,e){return(14&t[e])<<29|(255&t[e+1])<<22|(254&t[e+2])<<14|(255&t[e+3])<<7|(254&t[e+4])>>1}new class{constructor(t={}){this.config(t),this.init()}init(){["debug","log","info","warn","error"].forEach((e=>{this[e]=this.enable?self.console[e].bind(self.console,this.prefix):t}))}config({prefix:t="[video-player]::",debug:e=!1}){this.prefix=t,this.enable=e,this.init()}}({prefix:"[player-worker]::",debug:!0}).log("player worker loaded"),self.postLog=(...t)=>{self.debug&&self.postMessage({event:"log",data:t})};const Zs=new function(t){return{all:t=t||new Map,on:function(e,i){var r=t.get(e);r?r.push(i):t.set(e,[i])},off:function(e,i){var r=t.get(e);r&&(i?r.splice(r.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var r=t.get(e);r&&r.slice().map((function(t){t(i)})),(r=t.get("*"))&&r.slice().map((function(t){t(e,i)}))}}},Qs={Loader:new class{constructor({Emitter:t}){this.Emitter=t,this.playList=[],this.duration=0,this.loadedDuration=-1,this.maxBufferLength=10,this.seekTime=null,this.Emitter.on(a,this.seek.bind(this))}setPlayList(t){this.playList.forEach((t=>{t.loading&&t.controller&&t.controller.abort()})),this.playList=t;const e=t[t.length-1];this.duration=e.startTime+e.duration,self.duration=this.duration;const i=Math.max(this.loadedDuration,self.currentTime);this.loadFragmentByTime(i)}seek(t){this.seekTime=t,this.loadedDuration=0,this.abortFetchOutTime(t),this.loadFragmentByTime(t)}queueHandler(){this.loadedDuration>=self.currentTime+this.maxBufferLength||this.loadedDuration>=this.duration||this.loadFragmentByTime(this.seekTime||this.loadedDuration)}loadFragmentByTime(t){if(t{const{startTime:r,duration:s}=e;if(r<=t&&tt.arrayBuffer())).then((n=>{if(t.loading=!1,a+othis.seekTime)return;this.seekTime=null}if(this.loadedDuration>=a+o)return;this.loadedDuration=a+o;let h=i&&s?((t,e,i)=>new c.ModeOfOperation.cbc(e,i).decrypt(new Uint8Array(t)))(n,i,s):new Uint8Array(n);this.Emitter.emit(r,{startTime:a,duration:o,url:e,data:h}),h=null,this.queueHandler()})).catch((t=>{console.warn("loadFragment",t,a),self.postLog(t)})))}abortFetchOutTime(t){this.playList.forEach((e=>{const{startTime:i,duration:r,controller:s,loading:n}=e;n&&(i<=t&&t{t.loading=!1}))}}({Emitter:Zs}),DecodeAudio:new class{constructor({Emitter:t}){this.Emitter=t,this.Emitter.on(r,this.onFragment.bind(this))}onFragment(t){const{startTime:e,duration:i,url:r,data:s}=t;e+i{const{aacData:s,reallyStartTime:n}=t;self.postMessage({event:"demux-audio",data:{startTime:e,duration:i,url:r,reallyStartTime:n,aacData:s}})}))}}({Emitter:Zs}),DecodeVideo:new class{constructor({Emitter:t}){this.Emitter=t,this.queue=[],this.seekTime=null,this.decoding=!1,this.maxDecodLength=2,this.prevTimestamp=0,this.startTime=0,this.endTime=0,this.decodedDuration=0,this.errorValue=1e-5,this.decoder=new Ys({onOutput:this.decodeOutput.bind(this),onError:this.decodeError.bind(this)}),this.Emitter.on(r,this.onFragment.bind(this))}seek(t){this.seekTime=t,this.decodedDuration=0,this.prevTimestamp=0;const e=this.queue.findIndex((({startTime:e,duration:i})=>t>=e&&t=0)return e>0&&this.queue.splice(0,e),this.decoder.stopReadStream(),void this.decodeQueue();this.queue=[],this.Emitter.emit(a,t)}onFragment(t){const{startTime:e,duration:i,data:r}=t;e+inew Promise(((e,i)=>{Ds.on("data",(async t=>{if("video"===t.type){const i=new Uint8Array(t.initSegment.byteLength+t.data.byteLength);i.set(t.initSegment,0),i.set(t.data,t.initSegment.byteLength),e(i)}})),Ds.on("done",(()=>{Ds.reset()})),Ds.push(t),Ds.flush()})))(r).then((r=>{t.data=null,this.queue.push({data:r,startTime:e,duration:i}),this.decodeQueueHandler()}))}decodeQueueHandler(){self.isIphone?this.decodedDuration-self.currentTime<=this.maxDecodLength-this.errorValue&&this.decodeQueue():!this.decoding&&this.queue.length&&this.decodeQueue()}decodeQueue(){if(0==this.queue.length)return;if(this.decoding)return;const t=1e6*self.currentTime;let e=this.queue[0];const{startTime:i,duration:r}=e,s=i+r;if(this.decodeStart=Math.max(1e6*this.decodedDuration,t),null!=this.seekTime){if(e.startTime>this.seekTime||this.seekTime>s)return e.data=null,this.queue.shift(),void this.decodeQueue();this.decodeStart=1e6*this.seekTime,self.postMessage({event:"decodeSeek",data:this.seekTime})}this.decodeEnd=self.isIphone?this.decodeStart+1e6*this.maxDecodLength:1e6*s,this.decoding=!0,this.decoder.decode({data:e.data,start:this.decodeStart,end:this.decodeEnd,onReady:t=>{},onDone:async()=>{this.decoding=!1,(this.decodeEnd/1e6>=s||self.currentTime>s||i>self.currentTime+2*this.maxDecodLength)&&(e===this.queue[0]&&this.queue.shift(),e.data=null,e=null,this.decodeQueueHandler())}})}async decodeOutput(t){if(!t)return;let{timestamp:e,duration:i}=t;i||this.prevTimestamp&&(i=e-this.prevTimestamp);const r=1e6*self.currentTime;if(!e)return 0!=r||self.firstVideoFrame?void t.close():(self.firstVideoFrame=!0,void self.postMessage({event:s,data:t},[t]));if(null!=this.seekTime){const r=1e6*this.seekTime;if(!(e-r<=2e5&&re+i)return void t.close();if(1e6*this.decodedDuration>e+i)return void t.close();if(this.decodedDuration=Math.max(this.decodedDuration,(e+(i||0))/1e6),e&&(this.prevTimestamp=e),self.isIphone)return void self.postMessage({event:"videoFrame",data:t},[t]);const n={timestamp:e,duration:i,imageBitmap:await this.getImageBitmap(t)};self.postMessage({event:"videoFrame",data:n})}async getImageBitmap(t){if(!t)return;const e=t.displayWidth,i=t.displayHeight,r=new OffscreenCanvas(e,i);r.getContext("2d").drawImage(t,0,0,e,i),t.close();return await createImageBitmap(r)}decodeError(t){self.postLog(t)}}({Emitter:Zs})};let $s;self.currentTime=0,self.onmessage=t=>{!function({event:t,data:i}){switch(t){case"init":self.debug=i.debug,self.isIphone=i.isIphone;break;case e:case n:Qs.Loader.setPlayList(i);break;case d:!async function(t){self.currentTime=t,Qs.DecodeVideo.decodeQueueHandler()}(i);break;case o:!function(){$s&&clearInterval($s);$s=setInterval((()=>{Qs.Loader.queueHandler()}),1e3)}();break;case h:break;case a:r=i,self.currentTime=r,Qs.DecodeVideo.seek(r)}var r}(t.data)}}();