@castlabs/prestoplay 6.17.1 → 6.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +7 -7
- package/cjs/cl.cast.js +111 -111
- package/cjs/cl.conviva.js +33 -33
- package/cjs/cl.core.js +566 -558
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +75 -74
- package/cjs/cl.externs.js +46 -46
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +71 -69
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +29 -29
- package/cjs/cl.ima.js +23 -23
- package/cjs/cl.mse.js +311 -311
- package/cjs/cl.muxdata.js +15 -15
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.sessions.js +15 -15
- package/cjs/cl.simid.js +15 -15
- package/cjs/cl.smooth.js +72 -72
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +69 -69
- package/cjs/cl.ttml.js +28 -28
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +13 -13
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.youbora.js +18 -18
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +5 -5
- package/cl.cast.js +87 -87
- package/cl.conviva.js +27 -27
- package/cl.core.js +456 -450
- package/cl.crypto.js +8 -8
- package/cl.dash.js +70 -69
- package/cl.externs.js +46 -46
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +72 -72
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +17 -17
- package/cl.mse.js +274 -273
- package/cl.muxdata.js +13 -13
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +10 -10
- package/cl.playlist.js +5 -5
- package/cl.sessions.js +10 -10
- package/cl.simid.js +13 -13
- package/cl.smooth.js +59 -59
- package/cl.thumbnails.js +19 -19
- package/cl.tizen.js +57 -57
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +15 -15
- package/cl.vtt.js +12 -12
- package/cl.youbora.js +15 -15
- package/package.json +2 -2
- package/typings.d.ts +37 -3
package/cl.crypto.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
g),b.onError(new _.H(1,7,7104,null,g)),c}try{const g=a.l?new
|
|
3
|
-
1001===g.code&&412===g.data.status&&a.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var tS=function(a){a=_.li(a);const b=new Uint32Array(4);for(let c=0;4>c;c++)b[c]=a.getUint32(4*c);return b},vS=function(a,b){return c=>_.x(function*(){const d=c.request||null;if(d&&2===d.type&&d.keyInfo&&c.data){const e=d.uris[0];a.g.debug("Decrypting AES-128-encrypted video segment",e);c.data=yield uS(a,b,c.data,d.keyInfo,e)}return c})},uS=function(a,b,c,d,e){return _.x(function*(){let f=new ArrayBuffer(0);try{f=yield wS(a,b,d.url)}catch(g){return a.g.warn("Could not fetch AES key",
|
|
2
|
+
g),b.onError(new _.H(1,7,7104,null,g)),c}try{const g=a.l?new xS:new yS;yield g.importKey(f);return yield g.decrypt(c,d.iv)}catch(g){return a.g.warn("Could not decrypt segment data!",e,g),b.onError(new _.H(1,3,3103,null,g)),c}})},wS=function(a,b,c){return _.x(function*(){const d=_.Si(c),e=(new _.Mh(c)).Pa.endsWith(".drmtoday.com");if(e){var f=b.getConfiguration();_.Yl(d,f)}f=c+JSON.stringify(d.headers);if(a.j[f])return a.j[f];try{const g=yield b.getNetworkEngine().fetch(d).R;return a.j[f]=g.data}catch(g){throw e&&
|
|
3
|
+
1001===g.code&&412===g.data.status&&a.g.warn("Wrong DRMtoday credentials, server responded with 412."),g;}})},yS=class{constructor(){this.B=[0,1,2,4,8,16,32,64,128,27,54];this.C=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.l=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.A=new Uint32Array(256);this.o=new Uint32Array(256);this.w=new Uint32Array(0);this.h=this.a=this.j=this.f=null;{const c=this.A,d=this.o;var a=
|
|
4
4
|
this.C;const e=a[0],f=a[1],g=a[2];a=a[3];var b=this.l;const h=b[0],k=b[1],l=b[2];b=b[3];const m=new Uint32Array(256);let n=0,q=0,u;for(u=0;256>u;u++)m[u]=128>u?u<<1:u<<1^283;for(u=0;256>u;u++){let v=q^q<<1^q<<2^q<<3^q<<4;v=v>>>8^v&255^99;c[n]=v;d[v]=n;const y=m[n],B=m[y],D=m[B];let M=257*m[v]^16843008*v;e[n]=M<<24|M>>>8;f[n]=M<<16|M>>>16;g[n]=M<<8|M>>>24;a[n]=M;M=16843009*D^65537*B^257*y^16843008*n;h[v]=M<<24|M>>>8;k[v]=M<<16|M>>>16;l[v]=M<<8|M>>>24;b[v]=M;n?(n=y^m[m[m[D^y]]],q^=m[m[q]]):n=q=1}}}importKey(a){a=
|
|
5
|
-
|
|
6
|
-
255],l^=d[e/this.a|0]<<24):6<this.a&&4===e%this.a&&(l=b[l>>>24]<<24|b[l>>>16&255]<<16|b[l>>>8&255]<<8|b[l&255]),k=(this.f[e-this.a]^l)>>>0,this.f[e]=k);for(a=0;a<this.
|
|
7
|
-
let v,y,B;let D,M,da,
|
|
8
|
-
255]^e[Wa];y=f[M>>>24]<<24^f[da>>16&255]<<16^f[ea>>8&255]<<8^f[D&255]^e[Wa+1];B=f[da>>>24]<<24^f[ea>>16&255]<<16^f[D>>8&255]<<8^f[M&255]^e[Wa+2];ea=f[ea>>>24]<<24^f[D>>16&255]<<16^f[M>>8&255]<<8^f[da&255]^e[Wa+3];Wa+=3;u[c]=Oc(v^b);u[c+1]=Oc(ea^n);u[c+2]=Oc(B^q);u[c+3]=Oc(y^m);b=
|
|
9
|
-
this.
|
|
5
|
+
tS(a);for(var b=!0,c=0;c<a.length&&b;)b=a[c]===this.w[c],c++;if(b)return new Promise(m=>m());this.w=a;this.a=a.length;if(4!==this.a&&6!==this.a&&8!==this.a)throw Error("Invalid aes key size\x3d"+this.a);this.h=4*(this.a+7);this.f=new Uint32Array(this.h);this.j=new Uint32Array(this.h);b=this.A;const d=this.B;var e=this.l;c=e[0];const f=e[1],g=e[2],h=e[3];let k=0,l=0;for(e=0;e<this.h;e++)e<this.a?k=this.f[e]=a[e]:(l=k,0===e%this.a?(l=l<<8|l>>>24,l=b[l>>>24]<<24|b[l>>>16&255]<<16|b[l>>>8&255]<<8|b[l&
|
|
6
|
+
255],l^=d[e/this.a|0]<<24):6<this.a&&4===e%this.a&&(l=b[l>>>24]<<24|b[l>>>16&255]<<16|b[l>>>8&255]<<8|b[l&255]),k=(this.f[e-this.a]^l)>>>0,this.f[e]=k);for(a=0;a<this.h;a++)e=this.h-a,l=a&3?this.f[e]:this.f[e-4],this.j[a]=4>a||4>=e?l:c[b[l>>>24]]^f[b[l>>>16&255]]^g[b[l>>>8&255]]^h[b[l&255]],this.j[a]>>>=0;return new Promise(m=>m())}decrypt(a,b){let c=0;const d=this.a+6,e=this.j,f=this.o;var g=this.l;const h=g[0],k=g[1],l=g[2];g=g[3];var m=tS(b);b=m[0];let n=m[1],q=m[2];m=m[3];a=_.ki(a);const u=new Int32Array(a.length);
|
|
7
|
+
let v,y,B;let D,M,da,vb,Ub,pd,kg,Wa,le;const Oc=this.F.bind(this);for(;c<a.length;){vb=Oc(a[c]);Ub=Oc(a[c+1]);pd=Oc(a[c+2]);kg=Oc(a[c+3]);D=vb^e[0];M=kg^e[1];da=pd^e[2];var ea=Ub^e[3];Wa=4;for(le=1;le<d;le++)v=h[D>>>24]^k[M>>16&255]^l[da>>8&255]^g[ea&255]^e[Wa],y=h[M>>>24]^k[da>>16&255]^l[ea>>8&255]^g[D&255]^e[Wa+1],B=h[da>>>24]^k[ea>>16&255]^l[D>>8&255]^g[M&255]^e[Wa+2],ea=h[ea>>>24]^k[D>>16&255]^l[M>>8&255]^g[da&255]^e[Wa+3],D=v,M=y,da=B,Wa+=4;v=f[D>>>24]<<24^f[M>>16&255]<<16^f[da>>8&255]<<8^f[ea&
|
|
8
|
+
255]^e[Wa];y=f[M>>>24]<<24^f[da>>16&255]<<16^f[ea>>8&255]<<8^f[D&255]^e[Wa+1];B=f[da>>>24]<<24^f[ea>>16&255]<<16^f[D>>8&255]<<8^f[M&255]^e[Wa+2];ea=f[ea>>>24]<<24^f[D>>16&255]<<16^f[M>>8&255]<<8^f[da&255]^e[Wa+3];Wa+=3;u[c]=Oc(v^b);u[c+1]=Oc(ea^n);u[c+2]=Oc(B^q);u[c+3]=Oc(y^m);b=vb;n=Ub;q=pd;m=kg;c+=4}return new Promise($a=>{{var Pa=u.buffer;const jb=Pa.byteLength,Rc=jb&&(new DataView(Pa)).getUint8(jb-1);Pa=Rc?Pa.slice(0,jb-Rc):Pa}$a(Pa)})}destroy(){this.B=this.j=this.f=this.l=this.C=this.o=this.A=
|
|
9
|
+
this.h=this.a=this.w=null;return new Promise(a=>a())}F(a){return a<<24|(a&65280)<<8|(a&16711680)>>8|a>>>24}};var xS=class{constructor(){this.a=null}importKey(a){const b=this;return _.x(function*(){b.a=yield crypto.subtle.importKey("raw",a,{name:"AES-CBC"},!1,["decrypt"])})}decrypt(a,b){const c=this;return _.x(function*(){return yield crypto.subtle.decrypt({name:"AES-CBC",iv:b},c.a,a)})}destroy(){this.a=null;return new Promise(a=>a())}};_.z("clpp.crypto.CryptoComponent",class extends _.Yt{constructor(){super();this.j={};this.l=!1;this.g=new _.R("clpp.crypto")}f(){if(window.crypto&&crypto.subtle){var a=crypto.subtle.decrypt;a=typeof crypto.subtle.importKey===_.Yd&&typeof a===_.Yd}else a=!1;(this.l=a)||this.g.warn("No WebCrypto APIs found. Will fallback to software AES")}o(a){const b=vS(this,a);a.getNetworkEngine().tc(b)}a(){this.j={}}id(){return"crypto"}});};f.call(g, window);
|
package/cl.dash.js
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
|
|
3
|
-
a.
|
|
4
|
-
c)?a.getAttributeNS(b,c):null},
|
|
5
|
-
Number(b[2]||null)+86400*Number(b[3]||null)+3600*Number(b[4]||null)+60*Number(b[5]||null)+Number(b[6]||null);return isFinite(a)?a:null},
|
|
6
|
-
Number(b[1])/Number(b[2]):Number(a);return isNaN(a)?null:a},
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var zK="Channel parsing failure! Ignoring scheme and value",AK="ContentProtection",BK="EssentialProperty",CK="Failed to parse UTCTiming tags.",DK="Missing \x3cms:pro/\x3e node in ContentProtection element",EK="No UTCTiming elements found.",FK="SegmentBase does not contain sufficient segment information:",GK="SegmentList does not contain sufficient segment information:",HK="SegmentTemplate does not contain sufficient segment information:",IK="SegmentTimeline",JK='The last "S" element cannot have a negative repeat',
|
|
2
|
+
KK="application",LK="duration",MK="http://dashif.org/guidelines/trickmode",NK="http://www.w3.org/1999/xlink",OK='ignoring the last "S" element.',PK='ignoring the remaining "S" elements.',QK="presentationTimeOffset",RK="schemeIdUri",SK="static",TK="timescale",UK="urn:microsoft:playready",VK="urn:mpeg:cenc:2013",WK="urn:mpeg:dash:utc:http-head:2014",XK="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95",YK="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",ZK=function(a,b){a.G=Math.max(a.G,b);a.g.debug("notifyAvailabilityTimeOffset: maxAvailabilityTimeOffset\x3d"+
|
|
3
|
+
a.G)},$K=function(a,b){return a.reduce(((c,d,e)=>d.catch(c.bind(null,e))).bind(null,b),Promise.reject())},aL=function(a){return new _.lo(Promise.reject(a),()=>Promise.resolve())},bL=function(a){return new _.lo(Promise.all(a.map(b=>b.R)),()=>Promise.all(a.map(b=>b.abort())))},cL=function(a,b,c){return Array.prototype.filter.call(a.childNodes,d=>d instanceof Element&&d.localName===c&&d.namespaceURI===b)},dL=function(a,b,c){a=cL(a,b,c);return 1!==a.length?null:a[0]},eL=function(a,b,c){return a.hasAttributeNS(b,
|
|
4
|
+
c)?a.getAttributeNS(b,c):null},fL=function(a,b,c,d=null){let e=null;a=a.getAttribute(b);null!=a&&(e=c(a));return null==e?d:e},gL=function(a){if(!a)return null;/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(a)&&(a+="Z");a=Date.parse(a);return isNaN(a)?null:Math.floor(a/1E3)},hL=function(a){if(!a)return null;const b=/^P(?:([0-9]*)Y)?(?:([0-9]*)M)?(?:([0-9]*)D)?(?:T(?:([0-9]*)H)?(?:([0-9]*)M)?(?:([0-9.]*)S)?)?$/.exec(a);if(!b)return _.C("Invalid duration string:",a),null;a=31536E3*Number(b[1]||null)+2592E3*
|
|
5
|
+
Number(b[2]||null)+86400*Number(b[3]||null)+3600*Number(b[4]||null)+60*Number(b[5]||null)+Number(b[6]||null);return isFinite(a)?a:null},iL=function(a){var b=/([0-9]+)-([0-9]+)/.exec(a);if(!b)return null;a=Number(b[1]);if(!isFinite(a))return null;b=Number(b[2]);return isFinite(b)?{start:a,end:b}:null},jL=function(a){a=Number(a);return 0===a%1?a:null},kL=function(a){a=Number(a);return 0===a%1&&0<a?a:null},lL=function(a){a=Number(a);return 0===a%1&&0<=a?a:null},mL=function(a){let b;a=(b=a.match(/^(\d+)\/(\d+)$/))?
|
|
6
|
+
Number(b[1])/Number(b[2]):Number(a);return isNaN(a)?null:a},nL=function(a,b){try{const c=_.oi(a);return _.rm(c,b)}catch(c){return null}},oL=function(a){var b=void 0===b?1024:b;if(!(a instanceof Uint8Array))return"";if(typeof b!==_.t||0>=b)b=1024;return(a.byteLength>b?a.subarray(0,b):a).toString()},pL=function(a,b,c,d,e){const f={RepresentationID:b,Number:c,Bandwidth:d,Time:e};return a.replace(/\$(RepresentationID|Number|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g,(g,h,k,l)=>{if("$$"===g)return"$";
|
|
7
7
|
let m=f[h];if(null==m)return _.C("URL template does not have an available substitution ","for identifier",'"'+h+'":',a),g;"RepresentationID"===h&&k&&(_.C("URL template should not contain a width specifier for identifier",'"RepresentationID":',a),k=void 0);"Time"===h&&(m=Math.round(m));switch(l){case void 0:case "d":case "i":case "u":g=m.toString();break;case "o":g=m.toString(8);break;case "x":g=m.toString(16);break;case "X":g=m.toString(16).toUpperCase();break;default:g=m.toString()}k=window.parseInt(k,
|
|
8
|
-
10)||1;return Array(Math.max(0,k-g.length)+1).join("0")+g})},
|
|
9
|
-
d,f=a.
|
|
10
|
-
'if the next "S" element does not have a valid start time:',
|
|
11
|
-
"the content may have errors in it.",u),B[B.length-1].end=v/l);for(u=0;u<=y;++u)q=v+M,B.push({start:v/l,end:q/l,
|
|
12
|
-
b,c,d,e,f){const g=
|
|
13
|
-
l.childNodes[0];l.removeChild(m);a.appendChild(m)}for(m=0;m<l.attributes.length;m++){const n=l.attributes[m].nodeName,q=l.getAttribute(n);a.setAttribute(n,q)}return
|
|
14
|
-
b,c,d,e,f)))}return
|
|
15
|
-
a=_.J(a);_.
|
|
16
|
-
31;l&=2147483647;const n=_.P(d.reader);d.reader.skip(4);if(1===m)throw _.
|
|
17
|
-
256*c+b[d];b=c;c=
|
|
18
|
-
a.a.getUint8(0)&224)throw new _.H(_.F,3,3001);let b=0;for(let c=0;c<a.a.byteLength;c++){const d=a.a.getUint8(c);b=256*b+d}return b},
|
|
19
|
-
new _.H(_.F,3,3013);a=
|
|
20
|
-
1);c=c/e||0;d=
|
|
21
|
-
"range",
|
|
22
|
-
d,e,f,g,h){const k=a.presentationTimeline,l=!a
|
|
23
|
-
y){return u.f(v,y)},getDuration:function(){return u.getDuration()},getLastSegmentEndTime:()=>n}},
|
|
24
|
-
adjustSegmentDurations:h.f.bind(h),getDuration:h.getDuration.bind(h),getLastSegmentEndTime:()=>_.
|
|
25
|
-
|
|
26
|
-
1
|
|
27
|
-
"webm"!==e)throw _.
|
|
28
|
-
findSegmentPosition:function(n){return 0>n||d&&n>=d?null:Math.floor(n/e)},getSegmentReference:function(n){const q=n+f;if(null!==g&&q>g)return null;const u=n*e;let v=u+e;d&&(v=Math.min(v,d));return 0>v||d&&u>=d?null:new _.
|
|
29
|
-
d[f].
|
|
30
|
-
getDuration:f.getDuration.bind(f),initSegmentReference:c,getLastSegmentEndTime:()=>_.
|
|
31
|
-
|
|
32
|
-
d.
|
|
33
|
-
|
|
34
|
-
c.push({scheme:
|
|
35
|
-
(a.
|
|
36
|
-
try{const f=yield
|
|
37
|
-
_.
|
|
38
|
-
|
|
39
|
-
a=_.
|
|
40
|
-
(a=
|
|
41
|
-
b,c,d,e){const f=
|
|
42
|
-
"ContentProtection element",a),null;b=b.toLowerCase();if(c&&(c=c.replace(/-/g,"").toLowerCase(),c.includes(" ")))throw new _.H(_.F,4,4009);let f=[];try{if(f=d.map(g=>({initDataType:_
|
|
43
|
-
c.getLastSegmentEndTime).map(c=>c.getLastSegmentEndTime());0<a.length&&(a=Math.min(...a),_.
|
|
44
|
-
d.uri&&!a.j.includes(d.uri)&&a.j.unshift(d.uri);b=null!=a.f;d=yield
|
|
45
|
-
d=yield d.
|
|
46
|
-
|
|
47
|
-
7,7001);
|
|
48
|
-
function(a,b,c,d){const e=
|
|
49
|
-
(a.C.push(k.id),a.f&&(a.D.filterNewPeriod(k),a.f.periods.push(k)));if(null==q){m!==d.length-1&&a.
|
|
50
|
-
b,c,d){b.
|
|
51
|
-
{y.trickPlay=!0});h=k.streams[0];e=k.
|
|
52
|
-
textStreams:n,thumbStreams:u,variants:k}},
|
|
53
|
-
a=
|
|
54
|
-
0;d=b+d/g-h/g;k=d+k/g;null!=c&&(d=Math.min(d,b+c),k=Math.min(k,b+c));let m=_.
|
|
55
|
-
|
|
56
|
-
_.
|
|
57
|
-
"CC"+e,e+=2,y=v;q.set(n,_.
|
|
58
|
-
|
|
59
|
-
0)+(f.bandwidth||0);g={id:a.o++,language:b.language,primary:b.
|
|
60
|
-
c.streams).flat().filter(c=>c.getLastSegmentEndTime).map(c=>c.getLastSegmentEndTime()),0<b.length?a.start+Math.min(...b):null):null},
|
|
61
|
-
"tag:dolby.com,2018:dash:EC3_ExtensionType:2018"===y.getAttribute(
|
|
62
|
-
getSegmentReference:n.getSegmentReference,initSegmentReference:n.initSegmentReference,adjustSegmentDurations:n.adjustSegmentDurations,getLastSegmentEndTime:n.getLastSegmentEndTime,getDuration:n.getDuration,segmentLookupStrategy:_.
|
|
63
|
-
roles:h,channelsCount:b.
|
|
64
|
-
"the Representation must contain one of SegmentBase, SegmentList,",'SegmentTemplate, or explicitly indicate that it is "text".',b);return!1}1!==c&&(a.
|
|
65
|
-
d=d===_.G||d===
|
|
66
|
-
initSegmentReference:null,
|
|
67
|
-
b,e);continue}return c;case "tag:dolby.com,2014:dash:audio_channel_configuration:2011":case "urn:dolby:dash:audio_channel_configuration:2011":c=parseInt(e,16);if(!c){a.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
8
|
+
10)||1;return Array(Math.max(0,k-g.length)+1).join("0")+g})},sL=function(a,b){var c=qL(a,b,TK);let d=1;c&&(d=kL(c)||1);c=qL(a,b,LK);(c=kL(c||""))&&(c/=d);let e=Number(qL(a,b,QK))||0,f=e/d||0;a.Rg&&null!=a.cd&&a.cd!==f&&(_.C("The stream is non-compliant with the DASH spec. The value of `presentationTimeOffset` has changed during the transition from dynamic to static manifest, which is not allowed. The last "+`value will be ignored. (Period ID: ${a.Sa.id}, `+`Representation ID: ${a.P.id})`),e=a.cd*
|
|
9
|
+
d,f=a.cd);var g=qL(a,b,"startNumber");let h=lL(g||"");if(null==g||null==h)h=1;g=qL(a,b,"endNumber");g=null!==g?lL(g||""):null;var k=rL(a,b,IK),l=null;if(k){{l=d;var m=e,n=a.za.duration||Infinity;k=_.om(k,"S");const B=[];var q=0;for(let D=0;D<k.length;++D){var u=k[D],v=fL(u,"t",lL);const M=fL(u,"d",lL);var y=fL(u,"r",jL);null!=v&&(v-=m);if(!M){_.C('"S" element must have a duration:',PK,u);break}v=null!=v?v:q;y=y||0;if(0>y)if(D+1<k.length){y=fL(k[D+1],"t",lL);if(null==y){_.C('An "S" element cannot have a negative repeat',
|
|
10
|
+
'if the next "S" element does not have a valid start time:',PK,u);break}else if(v>=y){_.C('An "S" element cannot have a negative repeat if its start ','time exceeds the next "S" element\'s start time:',PK,u);break}y=Math.ceil((y-v)/M)-1}else{if(Infinity===n){_.C(JK,"if the Period has an infinite duration:",OK,u);break}else if(v/l>=n){_.C(JK,"if its start time exceeds the Period's duration:",OK,u);break}y=Math.ceil((n*l-v)/M)-1}0<B.length&&v!==q&&(Math.abs((v-q)/l)>=_.Ms&&_.C("SegmentTimeline contains a large gap/overlap:",
|
|
11
|
+
"the content may have errors in it.",u),B[B.length-1].end=v/l);for(u=0;u<=y;++u)q=v+M,B.push({start:v/l,end:q/l,Ch:v}),v=q}l=B}}a=qL(a,b,"availabilityTimeOffset");b=Number(a||"");b=isNaN(b)?null:b;if(null==a||null==b)b=0;return{timescale:d,Ea:c,oc:h,ae:g,wb:f,Le:e,timeline:l,Sd:b}},qL=function(a,b,c){return[b(a.P),b(a.sa),b(a.Sa)].filter(_.Ih).map(d=>d.getAttribute(c)).reduce((d,e)=>d||e)},rL=function(a,b,c){return[b(a.P),b(a.sa),b(a.Sa)].filter(_.Ih).map(d=>_.pm(d,c)).reduce((d,e)=>d||e)},uL=function(a,
|
|
12
|
+
b,c,d,e,f){const g=eL(a,NK,"href"),h=eL(a,NK,"actuate")||"onRequest";for(let l=0;l<a.attributes.length;l++){const m=a.attributes[l];m.namespaceURI===NK&&(a.removeAttributeNS(m.namespaceURI,m.localName),--l)}if(5<=f)return aL(new _.H(_.F,4,4028));if("onLoad"!==h)return aL(new _.H(_.F,4,4027));const k=_.cB([d],[g]);d=_.Si(k,b);d.type=1;return e.fetch(d).qd(l=>{l=nL(l.data,a.tagName);if(!l)return aL(new _.H(_.F,4,4001,{uri:g}));for(;a.childNodes.length;)a.removeChild(a.childNodes[0]);for(;l.childNodes.length;){var m=
|
|
13
|
+
l.childNodes[0];l.removeChild(m);a.appendChild(m)}for(m=0;m<l.attributes.length;m++){const n=l.attributes[m].nodeName,q=l.getAttribute(n);a.setAttribute(n,q)}return tL(a,b,c,k[0],e,f+1)})},tL=function(a,b,c,d,e,f=0){if(eL(a,NK,"href")){var g=uL(a,b,c,d,e,f);c&&(g=g.qd(void 0,()=>tL(a,b,c,d,e,f)));return g}g=[];for(let h=0;h<a.childNodes.length;h++){const k=a.childNodes[h];k instanceof Element&&("urn:mpeg:dash:resolve-to-zero:2013"===eL(k,NK,"href")?(a.removeChild(k),--h):k.tagName!==IK&&g.push(tL(k,
|
|
14
|
+
b,c,d,e,f)))}return bL(g).qd(()=>a)},vL=function(a,b,c){const d=a.za.duration;var e=a.za.uf;if(!a.$d)return e=new _.kH(b),_.DB(e,d),e;{var f=a.Sa;const g=a.P;f=f&&f.id&&g&&g.id?`${f.id},${g.id}`:null}if(!a.vf||null==c[f])return a=new _.kH(b),e||_.DB(a,d),c[f]=a;c=c[f];e||_.DB(new _.kH(b),d);_.cC(c,b);_.dC(c,_.TB(a.presentationTimeline)-a.za.start);return c},wL=function(a,b){var c=a.presentationTimeline,d=[...b.a];c.l||0===d.length||(c.I=Math.floor(Math.max(c.I||0,d[d.length-1].endTime+a.za.start)));
|
|
15
|
+
a.vf||_.QB(a.presentationTimeline,[...b.a],a.za.start)},yL=function(a,b,c,d){let e;var f=(new _.Ml).ca("sidx",g=>{e=xL(b,d,c,g)});a&&f.parse(a);if(e)return e;{f=`${b}-${b+a.byteLength-1}`;const g=c[0];a=_.J(a);_.jh('Invalid box type. Expected "sidx", but received:',a,"from:",g,"byte range:",f);throw new _.H(_.F,3,3004,{url:g,Nh:f,size:a.byteLength,$h:oL(a)});}},xL=function(a,b,c,d){const e=[];d.reader.skip(4);const f=_.P(d.reader);if(0===f)throw _.jh("Invalid timescale."),new _.H(_.F,3,3005);if(0===
|
|
16
|
+
d.version){var g=_.P(d.reader);var h=_.P(d.reader)}else g=_.Al(d.reader),h=_.Al(d.reader);d.reader.skip(2);const k=_.yl(d.reader);a=a+d.size+h;for(h=0;h<k;h++){var l=_.P(d.reader);const m=(l&2147483648)>>>31;l&=2147483647;const n=_.P(d.reader);d.reader.skip(4);if(1===m)throw _.jh("Hierarchical SIDXs are not supported."),new _.H(_.F,3,3006);e.push(new _.bC(e.length,g/f-b,(g+n)/f-b,()=>c,a,a+l-1,b));g+=n;a+=l}d.parser.stop();return e},zL=function(a){var b=_.xl(a.a);let c;for(c=1;8>=c&&!(b&1<<8-c);c++);
|
|
17
|
+
if(8<c)throw new _.H(_.F,3,3002);const d=new Uint8Array(c);d[0]=b;for(b=1;b<c;b++)d[b]=_.xl(a.a);return d},CL=function(a){var b=zL(a);if(7<b.length)throw new _.H(_.F,3,3002);var c=0;for(var d=0;d<b.length;d++)c=256*c+b[d];b=c;c=zL(a);a:{for(e of AL)if(_.Hi(c,new Uint8Array(e))){var e=!0;break a}e=!1}if(e)c=a.f.byteLength-a.a.getPosition();else{if(8===c.length&&c[1]&224)throw new _.H(_.F,3,3001);e=c[0]&(1<<8-c.length)-1;for(d=1;d<c.length;d++)e=256*e+c[d];c=e}c=a.a.getPosition()+c<=a.f.byteLength?
|
|
18
|
+
c:a.f.byteLength-a.a.getPosition();e=new DataView(a.f.buffer,a.f.byteOffset+a.a.getPosition(),c);a.a.skip(c);return new BL(b,e)},DL=function(a){if(8<a.a.byteLength)throw new _.H(_.F,3,3002);if(8===a.a.byteLength&&a.a.getUint8(0)&224)throw new _.H(_.F,3,3001);let b=0;for(let c=0;c<a.a.byteLength;c++){const d=a.a.getUint8(c);b=256*b+d}return b},GL=function(a,b,c,d,e,f){const g=[],h=()=>e;a=new EL(a.a);let k=null,l=null;for(;_.vl(a.a);){var m=CL(a);if(187===m.id){var n=FL(m);n&&(m=c*n.Dh,n=b+n.jh,null!=
|
|
19
|
+
k&&g.push(new _.bC(g.length,k-f,m-f,h,l,n-1,f)),k=m,l=n)}}null!=k&&g.push(new _.bC(g.length,k-f,d-f,h,l,null,f));return g},FL=function(a){var b=new EL(a.a);a=CL(b);if(179!==a.id)throw _.C("Not a CueTime element."),new _.H(_.F,3,3013);a=DL(a);b=CL(b);if(183!==b.id)throw _.C("Not a CueTrackPositions element."),new _.H(_.F,3,3012);b=new EL(b.a);let c=0;for(;_.vl(b.a);){const d=CL(b);if(241===d.id){c=DL(d);break}}return{Dh:a,jh:c}},HL=function(a,b){b=rL(a,b,"Initialization");if(!b)return null;let c=a.P.bb;
|
|
20
|
+
var d=b.getAttribute("sourceURL");d&&(c=_.cB(a.P.bb,[d]));a=0;d=null;if(b=fL(b,"range",iL))a=b.start,d=b.end;return new _.gH(()=>c,a,d)},KL=function(a,b){var c=Number(qL(a,IL,QK))||0,d=qL(a,IL,TK),e=1;d&&(e=kL(d)||1);c=c/e||0;d=HL(a,IL);{e=a.P.mimeType.split("/")[1];if(a.P.contentType!==_.G&&"mp4"!==e&&"webm"!==e)throw _.jh("SegmentBase specifies an unsupported container type.",a.P),new _.H(_.F,4,4006);if("webm"===e&&!d)throw _.jh(FK,"the SegmentBase uses a WebM container,","but does not contain an Initialization element.",
|
|
21
|
+
a.P),new _.H(_.F,4,4005);const g=rL(a,IL,"RepresentationIndex");var f=qL(a,IL,"indexRange");let h=a.P.bb;f=iL(f||"");if(g){const k=g.getAttribute("sourceURL");k&&(h=_.cB(a.P.bb,[k]));f=fL(g,"range",iL,f)}if(!f)throw _.jh(FK,"the SegmentBase does not contain @indexRange","or a RepresentationIndex element.",a.P),new _.H(_.F,4,4002);a.presentationTimeline.B=null;a=JL(a,b,d,h,f.start,f.end,e,c)}return{createSegmentIndex:a.createSegmentIndex,findSegmentPosition:a.findSegmentPosition,getSegmentReference:a.getSegmentReference,
|
|
22
|
+
adjustSegmentDurations:a.adjustSegmentDurations,getDuration:a.getDuration,initSegmentReference:d,getLastSegmentEndTime:a.getLastSegmentEndTime,Aa:c}},IL=function(a){return a.jd},JL=function(a,b,c,d,e,f,g,h){const k=a.presentationTimeline,l=!a.$d||!a.za.uf,m=a.za.start,n=a.za.duration;let q=b,u=null;return{createSegmentIndex:function(v){return _.x(function*(){var y=[q(d,e,f,v),"webm"===g?q(c.Ra(),c.xa,c.ma,v):null];q=null;y=yield Promise.all(y);var B=y[0];const D=y[1]||null;B="mp4"===g?yL(B,e,d,h):
|
|
23
|
+
(new LL).parse(B,D,d,h);_.QB(k,B,m);u=new _.kH(B);l&&_.DB(u,n);return y})},findSegmentPosition:function(v){return u.find(v)},getSegmentReference:function(v){return u.get(v)},adjustSegmentDurations:function(v,y){return u.f(v,y)},getDuration:function(){return u.getDuration()},getLastSegmentEndTime:()=>n}},SL=function(a,b,c,d){const e=ML(a),f=NL(a);OL(a,f);let g=null;if(f.Yc)a.presentationTimeline.B=null,g=PL(a,b,e,f);else if(f.Ea)d||(a.presentationTimeline.B=null,ZK(a.presentationTimeline,f.Sd),_.RB(a.presentationTimeline,
|
|
24
|
+
f.Ea),_.OB(a.presentationTimeline,a.za.start)),g=QL(a,f);else{b=RL(a,f);const h=vL(a,b,c);wL(a,h);g={createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:h.find.bind(h),getSegmentReference:h.get.bind(h),adjustSegmentDurations:h.f.bind(h),getDuration:h.getDuration.bind(h),getLastSegmentEndTime:()=>_.aC(h)}}return{createSegmentIndex:g.createSegmentIndex,findSegmentPosition:g.findSegmentPosition,getSegmentReference:g.getSegmentReference,adjustSegmentDurations:g.adjustSegmentDurations,
|
|
25
|
+
getDuration:g.getDuration,initSegmentReference:e,getLastSegmentEndTime:g.getLastSegmentEndTime,Aa:f.wb}},ML=function(a){const b=qL(a,TL,"initialization");if(!b)return null;const c=a.P.id,d=a.bandwidth||null,e=a.P.bb;return new _.gH(function(){const f=pL(b,c,null,d,null);return _.cB(e,[f])},0,null)},NL=function(a){const b=sL(a,TL),c=qL(a,TL,"media");a=qL(a,TL,"index");return{Ea:b.Ea,timescale:b.timescale,oc:b.oc,ae:b.ae,wb:b.wb,Le:b.Le,timeline:b.timeline,ke:c,Yc:a,Sd:b.Sd}},OL=function(a,b){let c;
|
|
26
|
+
c=b.Yc?1:0;c+=b.timeline?1:0;c+=b.Ea?1:0;if(0===c)throw _.jh("SegmentTemplate does not contain any segment information:","the SegmentTemplate must contain either an index URL template","a SegmentTimeline, or a segment duration.",a.P),new _.H(_.F,4,4002);1!==c&&(_.C("SegmentTemplate contains multiple segment information sources:","the SegmentTemplate should only contain an index URL template,","a SegmentTimeline or a segment duration.",a.P),b.Yc?(_.hh("Using the index URL template by default."),b.timeline=
|
|
27
|
+
null):_.hh("Using the SegmentTimeline by default."),b.Ea=null);if(!b.Yc&&!b.ke)throw _.jh(HK,"the SegmentTemplate's media URL template is missing.",a.P),new _.H(_.F,4,4002);},PL=function(a,b,c,d){const e=a.P.mimeType.split("/")[1];if("mp4"!==e&&"webm"!==e)throw _.jh("SegmentTemplate specifies an unsupported container type.",a.P),new _.H(_.F,4,4006);if("webm"===e&&!c)throw _.jh(HK,"the SegmentTemplate uses a WebM container,","but does not contain an initialization URL template.",a.P),new _.H(_.F,4,
|
|
28
|
+
4005);var f=pL(d.Yc,a.P.id,null,a.bandwidth||null,null);f=_.cB(a.P.bb,[f]);return JL(a,b,c,f,0,null,e,d.wb)},QL=function(a,b){const c=b.ke,d=a.za.duration,e=b.Ea,f=b.oc,g=b.ae,h=b.timescale,k=a.bandwidth||null,l=a.P.id,m=a.P.bb;return{createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:function(n){return 0>n||d&&n>=d?null:Math.floor(n/e)},getSegmentReference:function(n){const q=n+f;if(null!==g&&q>g)return null;const u=n*e;let v=u+e;d&&(v=Math.min(v,d));return 0>v||d&&u>=d?null:new _.bC(n,
|
|
29
|
+
u,v,function(){const y=pL(c,l,q,k,u*h);return _.cB(m,[y])},0,null,b.wb)},adjustSegmentDurations:()=>{},getDuration:()=>d,getLastSegmentEndTime:()=>d}},RL=function(a,b){const c=b.ke,d=b.timeline;if(0===d.length)return[];const e=[];for(let f=0;f<d.length;f++){const g=f+b.oc,h=d[f].Ch+b.Le,k=a.P.id,l=a.bandwidth||null,m=a.P.bb;e.push(new _.bC(g,d[f].start,d[f].end,()=>{const n=pL(c,k,g,l,h);return _.cB(m,[n])},0,null,b.wb))}return e},TL=function(a){return a.Yb},YL=function(a,b){const c=HL(a,UL),d=VL(a);
|
|
30
|
+
WL(a,d);const e=XL(a.za.duration,d.oc,a.P.bb,d),f=vL(a,e,b);wL(a,f);return{createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:f.find.bind(f),getSegmentReference:f.get.bind(f),adjustSegmentDurations:f.f.bind(f),getDuration:f.getDuration.bind(f),initSegmentReference:c,getLastSegmentEndTime:()=>_.aC(f),Aa:d.wb}},UL=function(a){return a.Xb},VL=function(a){const b=ZL(a);a=sL(a,UL);let c=a.oc;0===c&&(_.C("SegmentList@startNumber must be \x3e 0"),c=1);let d=0;a.Ea?d=a.Ea*(c-1):a.timeline&&
|
|
31
|
+
0<a.timeline.length&&(d=a.timeline[0].start);return{Ea:a.Ea,startTime:d,oc:c,wb:a.wb,timeline:a.timeline,lc:b}},WL=function(a,b){if(!b.Ea&&!b.timeline&&1<b.lc.length)throw _.C(GK,"the SegmentList specifies multiple segments,","but does not specify a segment duration or timeline.",a.P),new _.H(_.F,4,4002);if(!b.Ea&&!a.za.duration&&!b.timeline&&1===b.lc.length)throw _.C(GK,"the SegmentList specifies one segment,","but does not specify a segment duration, period duration,","or timeline.",a.P),new _.H(_.F,
|
|
32
|
+
4,4002);if(b.timeline&&0===b.timeline.length)throw _.C(GK,"the SegmentList has an empty timeline.",a.P),new _.H(_.F,4,4002);},XL=function(a,b,c,d){let e=d.lc.length;d.timeline&&d.timeline.length!==d.lc.length&&(e=Math.min(d.timeline.length,d.lc.length),_.C("The number of items in the segment timeline and the number of","segment URLs do not match, truncating",d.lc.length,"to",e));const f=[];var g=d.startTime;for(let h=0;h<e;h++){const k=d.lc[h],l=_.cB(c,[k.Yg]);let m;m=null!=d.Ea?g+d.Ea:d.timeline?
|
|
33
|
+
d.timeline[h].end:g+a;f.push(new _.bC(h+b,g,m,()=>l,k.start,k.end,d.wb));g=m}return f},ZL=function(a){return[a.P.Xb,a.sa.Xb,a.Sa.Xb].filter(_.Ih).map(b=>_.om(b,"SegmentURL")).reduce((b,c)=>0<b.length?b:c).map(b=>{b.getAttribute("indexRange")&&!a.fe&&(a.fe=!0,_.C("We do not support the SegmentURL@indexRange attribute on SegmentList. We only use the SegmentList@duration attribute or SegmentTimeline, which must be accurate."));const c=b.getAttribute("media");b=fL(b,"mediaRange",iL,{start:0,end:null});
|
|
34
|
+
return{Yg:c,start:b.start,end:b.end}})},aM=function(a,b,c){c=c.map(e=>({scheme:e.getAttribute(RK),value:e.getAttribute(_.hg)}));const d=a.a.clockSyncUri;!c.length&&d&&(a.g.info("No UTCTiming elements found, falling back on clockSyncUri from config to synchronize clocks."),c.push({scheme:WK,value:d}));return 0===c.length?(a.g.warn(EK),Promise.reject(Error(EK))):$K(c,e=>{const f=e.scheme;e=e.value;switch(f){case WK:case "urn:mpeg:dash:utc:http-head:2012":return $L(a,b,e,"HEAD");case "urn:mpeg:dash:utc:http-xsdate:2014":case "urn:mpeg:dash:utc:http-iso:2014":case "urn:mpeg:dash:utc:http-xsdate:2012":case "urn:mpeg:dash:utc:http-iso:2012":return $L(a,
|
|
35
|
+
b,e,"GET");case "urn:mpeg:dash:utc:direct:2014":case "urn:mpeg:dash:utc:direct:2012":{const g=Date.parse(e);return isNaN(g)?(a.g.warn(`Invalid date for scheme ${f}, `+`value: ${e}`),Promise.reject()):Promise.resolve(g-Date.now())}case "urn:mpeg:dash:utc:http-ntp:2014":case "urn:mpeg:dash:utc:ntp:2014":case "urn:mpeg:dash:utc:sntp:2014":return a.g.warn("NTP UTCTiming scheme is not supported"),Promise.reject();default:return a.g.warn("Unrecognized scheme in UTCTiming element",f),Promise.reject()}}).catch(()=>
|
|
36
|
+
{a.g.warn(CK);return Promise.reject(Error(CK))})},bM=function(a,b,c,d){return _.x(function*(){const e=_.om(b,"UTCTiming");try{const f=yield aM(a,c,e);d.H=f;a.g.info("Clock synchronized. The difference between server and "+`client clock was ${f} ms.`)}catch(f){a.g.warn("Failed to synchronize clocks. This content may not play on clients with bad clocks!")}return d})},$L=function(a,b,c,d){return _.x(function*(){var e=_.cB(b,[c]);e=yield a.f(e,d);if("HEAD"===d){if(!e.headers||!e.headers.date)throw a.g.warn("UTC timing response is missing",
|
|
37
|
+
"expected date header"),Error("Date HTTP header missing.");e=e.headers.date}else e=_.oi(e.data);e=Date.parse(e);if(isNaN(e))throw a.g.warn("Unable to parse date from UTC timing response"),Error("Date value invalid.");return e-Date.now()})},dM=function(a,b){return a.find(c=>cM.get(c.Kb)===b)},fM=function(a){const b=dL(a.node,UK,"pro");if(!b)return eM.warn(DK,a),null;a=_.Ei(b.textContent);a=_.Fm(a);a=_.xm(a.a);return{keyId:null,Kb:YK,node:document.createElement("null"),init:[{initData:_.RA(a),initDataType:_.$c,
|
|
38
|
+
keyId:null}]}},gM=function(a,b){b=void 0===b?"4.0.0.0":b;const c=dL(a.node,VK,"pssh");if(!c)return _.C("Missing \x3ccenc:pssh/\x3e node in ContentProtection element",a),null;a=_.Ei(c.textContent);a=_.zm(a);return a?(b=_.SA(b,a.a))?{keyId:null,Kb:XK,node:document.createElement("null"),init:[{initData:_.RA(b),initDataType:_.$c,keyId:null}]}:null:(_.C("Unable to parse WV PSSH data. Can not create PR data!"),null)},hM=function(a,b){const c=dL(a.node,UK,"pro");if(!c)return _.C(DK,a),null;a=_.Ei(c.textContent);
|
|
39
|
+
a=_.Fm(a);return a.version!==b&&(_.ih(`Parsing from ${a.version} to ${b}.`),a=_.TA(a,b))?{keyId:null,Kb:XK,node:document.createElement("null"),init:[{initData:_.RA(a),initDataType:_.$c,keyId:null}]}:null},kM=function(a,b,c,d){const e=iM(a);let f=null;a=[];let g=[];const h=dM(e,_.zd),k=dM(e,_.xd);if(k&&d){var l=hM(k,d);l&&(e[e.indexOf(k)]=l)}k&&!h&&(l=fM(k))&&e.push(l);h&&!k&&(d=gM(h,d||void 0))&&e.push(d);d=new Set(e.map(m=>m.keyId));d.delete(null);if(1<d.size)throw new _.H(_.F,4,4010);b||(g=e.filter(m=>
|
|
40
|
+
"urn:mpeg:dash:mp4protection:2011"===m.Kb?(f=m.init||f,!1):!0),g.length&&(a=jM(f,g,c),0===a.length&&(a=[_.dB(_.Ee,f,c)])));if(e.length&&(b||!g.length)){a=[];for(const m of cM.values())m!==_.Ne&&a.push(_.dB(m,f,c))}if(b=Array.from(d)[0]||null)for(const m of a)for(const n of m.initData)n.keyId=b;return{Mc:b,Qh:f,drmInfos:a,ff:!0}},iM=function(a){const b=[];for(const c of a)(a=lM(c))&&b.push(a);return b},jM=function(a,b,c){const d=[];for(const f of b){var e=cM.get(f.Kb);if(e){b=_.dB(e,f.init||a,c);if(e=
|
|
41
|
+
mM.get(e))b.licenseServerUri=e(f);d.push(b)}}return d},nM=function(a,b,c,d,e){const f=kM(a,c,d,e);if(b.ff){a=1===b.drmInfos.length&&!b.drmInfos[0].keySystem;c=0===f.drmInfos.length;if(0===b.drmInfos.length||a&&!c)b.drmInfos=f.drmInfos;b.Mc=f.Mc||b.Mc;b.ff=!1}else if(0<f.drmInfos.length&&(b.drmInfos=b.drmInfos.filter(g=>f.drmInfos.some(h=>h.keySystem===g.keySystem)),0===b.drmInfos.length))throw new _.H(_.F,4,4008);return f.Mc||b.Mc},lM=function(a){let b=a.getAttribute(RK),c=eL(a,VK,"default_KID");
|
|
42
|
+
const d=cL(a,VK,"pssh").map(_.qm),e=dL(a,UK,"pro");if(!b)return _.jh("Missing required schemeIdUri attribute on","ContentProtection element",a),null;b=b.toLowerCase();if(c&&(c=c.replace(/-/g,"").toLowerCase(),c.includes(" ")))throw new _.H(_.F,4,4009);let f=[];try{if(f=d.map(g=>({initDataType:_.$c,initData:_.Ei(g),keyId:null})),0===f.length&&e)try{const g=_.Ei(e.textContent),h=_.Fm(g);f.push({initDataType:_.$c,initData:_.RA(h),keyId:null})}catch(g){_.C("Unable to parse ms:pro payload",g),f=[]}}catch(g){throw new _.H(_.F,
|
|
43
|
+
4,4007);}return{node:a,Kb:b,keyId:c,init:0<f.length?f:null}},pM=function(a,b){a=oM(a).filter(c=>c.getLastSegmentEndTime).map(c=>c.getLastSegmentEndTime());0<a.length&&(a=Math.min(...a),_.PB(b.presentationTimeline,a+b.za.start))},qM=function(a,b){return _.CC(_.Nj(a,b))?_.G:a.split("/")[0]},oM=function(a){const b=new Set;a.forEach(c=>{c.variants.forEach(d=>{d.audio&&b.add(d.audio);d.video&&b.add(d.video)})});return Array.from(b)},sM=function(a){return _.x(function*(){var b=_.Si(a.j,a.a.attemptParameters);
|
|
44
|
+
b.type=1;var c=Date.now();b=a.D.networkingEngine.fetch(b);_.Zi(a.l,b);var d=yield b.R;if(!a.D)return 0;d.uri&&!a.j.includes(d.uri)&&a.j.unshift(d.uri);b=null!=a.f;d=yield rM(a,d.data,d.uri);c=(Date.now()-c)/1E3;_.FB(a.G,1,c);if(b&&a.D.onUpdate)a.D.onUpdate(d.manifest);if(d.Ah){if(a.D.onTurnedStatic)a.D.onTurnedStatic();a.D.onEvent(new _.E(_.Ce))}return c})},tM=function(a,b){0>a.h||a.w.ha(Math.max(3,a.h-b,_.GB(a.G)))},rM=function(a,b,c){return _.x(function*(){var d=nL(b,"MPD");if(!d)throw new _.H(_.F,
|
|
45
|
+
4,4001,c);d=tL(d,a.a.attemptParameters,a.a.xlinkFailGracefully,c,a.D.networkingEngine);_.Zi(a.l,d);d=yield d.R;return uM(a,d,c)})},uM=function(a,b,c){return _.x(function*(){var d=[c],e=_.om(b,"Location").map(_.qm).filter(_.Ih);0<e.length&&(d=_.cB(d,e),a.j=d);e=_.om(b,"BaseURL").map(_.qm);var f=_.cB(d,e);d=b.getAttribute("type")||SK;a.h=fL(b,"minimumUpdatePeriod",hL,-1);d===SK&&0<=a.h&&(a.g.warn("Invalid manifest - a static manifest should not contain the `minimumUpdatePeriod` attribute. The attribute will be ignored."),
|
|
46
|
+
a.h=-1,a.w.stop());e=fL(b,"maxSegmentDuration",hL);const g=d===SK&&"dynamic"===a.A;g&&(a.g.info("MPD dynamic to static transition."),d="dynamic");const h=d===SK;var k="dynamic"===d;if(a.f)var l=a.f.presentationTimeline;else{l=a.a.timeline||{};var m=fL(b,"suggestedPresentationDelay",hL),n=fL(b,"minBufferTime",hL,0);m=null!=a.a.suggestedPresentationDelay?a.a.suggestedPresentationDelay:a.a.lowLatencyMode?0:null!=m?m:3*n;n=fL(b,"availabilityStartTime",gL);l=new _.jH(l,n,m,h,!!a.a.autoCorrectDrift,!!a.a.lowLatencyMode);
|
|
47
|
+
l=h?l:bM(a.H,b,f,l)}l=yield l;m=fL(b,"timeShiftBufferDepth",hL);m=k&&a.a.availabilityWindowOverride&&!isNaN(a.a.availabilityWindowOverride)?a.a.availabilityWindowOverride:null===m?Infinity:m;l.A=m;if(!a.D)throw new _.H(_.F,7,7001);k={$d:k,vf:null!=a.f,presentationTimeline:l,Sa:null,za:null,sa:null,P:null,bandwidth:0,fe:!1,Rg:g,Fe:null,cd:null};f=vM(a,k,f,b);m=f.duration;n=f.periods;g&&(pM(n,k),l.C=!0);if(h||!g&&!f.cf)l.f=m||Infinity,m&&_.IB(l.a,0,m);_.RB(l,e||1);l.isLive();a.f||(a.f={presentationTimeline:l,
|
|
48
|
+
periods:n,minBufferTime:0});a.A=d;return{manifest:a.f,Ah:g}})},vM=function(a,b,c,d){const e=fL(d,"mediaPresentationDuration",hL),f=a.f?a.f.periods[a.f.periods.length-1]||null:null,g=[];var h=0;d=_.om(d,"Period");for(let m=0;m<d.length;m++){var k=d[m];h=fL(k,_.Mf,hL,h);const n=fL(k,LK,hL);let q=null;if(m!==d.length-1){var l=fL(d[m+1],_.Mf,hL);null!=l&&(q=l-h)}else null!=e&&(q=e-h);l=_.Ms;q&&n&&Math.abs(q-n)>l&&a.g.warn("There is a gap/overlap between Periods",k);null==q&&(q=n);k=wM(a,b,c,{start:h,
|
|
49
|
+
duration:q,node:k,uf:null==q||m===d.length-1});g.push(k);a.C.includes(k.id)||(a.C.push(k.id),a.f&&(a.D.filterNewPeriod(k),a.f.periods.push(k)));if(null==q){m!==d.length-1&&a.g.warn("Skipping Period",m+1,"and any subsequent Periods:","Period",m+1,"does not have a valid start time.",g[m+1]);h=null;break}h+=q}null==a.f&&a.D.filterAllPeriods(g);f&&(b=g.find(m=>m.id===f.id))&&(f.endTime=b.endTime);return null!=e?(h!==e&&a.g.warn("@mediaPresentationDuration does not match the total duration of ","all Periods."),
|
|
50
|
+
{periods:g,duration:e,cf:!1}):{periods:g,duration:h,cf:!0}},wM=function(a,b,c,d){b.Sa=xM(a,d.node,null,c);b.za=d;c=b.Sa.id||`__clpp_period_${d.start}`;b.Sa.id||(a.g.info("No Period ID given for Period with start time "+d.start+`, Assigning a default: ${c}.`),b.Sa.id=c);var e=_.om(d.node,"EventStream");for(var f of e)yM(a,d.start,d.duration,f);f=_.om(d.node,_.ha).map(y=>zM(a,b,y)).filter(_.Ih);if(b.$d){e=[];for(var g of f)for(var h of g.lh)e.push(h);if(e.length!==(new Set(e)).size)throw new _.H(_.F,
|
|
51
|
+
4,4018);}g=f.filter(y=>!y.Ke);h=f.filter(y=>y.Ke);for(var k of h){k.streams.forEach(y=>{y.trickPlay=!0});h=k.streams[0];e=k.Ke;for(var l of g)if(e.includes(l.id))for(var m of l.streams)m.trickModeVideo=h}l=AM(f,_.w);m=AM(g,_.p);if(!l.length&&!m.length)throw new _.H(_.F,4,4004);m.length||(m=[null]);l.length||(l=[null]);k=[];for(var n of m)for(var q of l)BM(a,n,q,k);q=[...AM(g,_.G),...AM(g,_.MA)];n=[];for(var u of q)n.push.apply(n,u.streams);q=AM(g,_.de);u=[];for(var v of q)u.push.apply(u,v.streams);
|
|
52
|
+
v=CM(d,g);return{id:c,configurationId:a.D.configurationId,startTime:d.start,endTime:v,textStreams:n,thumbStreams:u,variants:k}},xM=function(a,b,c,d){c=c||{contentType:"",mimeType:"",codecs:"",emsgSchemeIdUris:[],frameRate:void 0,le:null};d=d||c.bb;const e=_.om(b,"BaseURL").map(_.qm);let f=b.getAttribute("contentType")||c.contentType;const g=b.getAttribute(_.ze)||c.mimeType,h=b.getAttribute(_.sd)||c.codecs,k=fL(b,"frameRate",mL)||c.frameRate;var l=_.om(b,"InbandEventStream");var m=c.emsgSchemeIdUris.slice();
|
|
53
|
+
for(var n of l)l=n.getAttribute(RK),m.includes(l)||m.push(l);n=_.om(b,"AudioChannelConfiguration");a=DM(a,n)||c.le;f||(f=qM(g,h));return{bb:_.cB(d,e),jd:_.pm(b,"SegmentBase")||c.jd,Xb:_.pm(b,"SegmentList")||c.Xb,Yb:_.pm(b,"SegmentTemplate")||c.Yb,width:fL(b,_.Cg,lL)||c.width,height:fL(b,_.Zd,lL)||c.height,contentType:f,mimeType:g,codecs:h,frameRate:k,emsgSchemeIdUris:m,id:b.getAttribute("id"),le:a}},yM=function(a,b,c,d){const e=d.getAttribute(RK)||"",f=d.getAttribute(_.hg)||"",g=fL(d,TK,lL)||1,h=
|
|
54
|
+
fL(d,QK,lL)||0;for(const l of _.om(d,"Event")){d=fL(l,"presentationTime",lL)||0;var k=fL(l,LK,lL)||0;d=b+d/g-h/g;k=d+k/g;null!=c&&(d=Math.min(d,b+c),k=Math.min(k,b+c));let m=_.rh;e.startsWith(_.dg)?m=_.th:"urn:mpeg:dash:event:callback:2015"===e&&(m=_.De);const n={configurationId:a.D.configurationId,schemeIdUri:e,value:f,startTime:d,endTime:k,id:l.getAttribute("id")||"",type:m,eventElement:l};n.type===_.De&&(n.Jd=()=>{if(n.eventElement){var q=n.eventElement.getAttribute("messageData")||"";q&&q.startsWith("http")&&
|
|
55
|
+
(q=_.Si(q),q.type=_.Ri,a.D.networkingEngine.fetch(q))}});a.D.onTimelineCueAdded(n)}},zM=function(a,b,c){b.sa=xM(a,c,b.Sa,null);let d=!1;var e=_.om(c,"Role");const f=e.map(da=>da.getAttribute(_.hg)).filter(_.Ih);let g=null;var h=_.om(c,"Label").map(da=>da.textContent).filter(_.Ih);h&&0<h.length&&(g=h[h.length-1]);let k=void 0;(h=b.sa.contentType===_.G)&&(k=_.MA);for(var l of e)if(e=l.getAttribute(RK),null==e||"urn:mpeg:dash:role:2011"===e||"urn:mpeg:dash:role"===e)switch(e=l.getAttribute(_.hg),e){case _.ue:d=
|
|
56
|
+
!0;break;case _.wA:case _.MA:k=e;break;case "forced-subtitle":case "forced_subtitle":case _.Wd:k=_.Wd}e=_.om(c,BK);l=null;for(var m of e){e=m.getAttribute(RK);var n=m.getAttribute(_.hg);if(e!==MK&&!EM.includes(e)||void 0===n)return null;e===MK&&(0===n.length&&(l=null),l=n.split(" "))}m=_.om(c,"Accessibility");const q=new Map;for(var u of m)if(e=u.getAttribute(RK),"urn:scte:dash:cc:cea-608:2015"===e||"urn:scte:dash:cc:cea-708:2015"===e)if(e=1,n=u.getAttribute(_.hg),null!=n)for(var v of n.split(";")){if(v.includes("\x3d")){var y=
|
|
57
|
+
v.split("\x3d");n=y[0].startsWith("CC")?y[0]:"CC"+y[0];y=y[1].split(",")[0].split(":").pop()}else n="CC"+e,e+=2,y=v;q.set(n,_.bi(y))}else q.set("CC1",_.ag);u=_.om(c,AK);const B=kM(u,a.a.ignoreDrmInfo,b.Sa.id,a.a.playreadyVersion||null),D=c.getAttribute("lang")||_.ag;u=_.bi(D);null==g&&(g=c.getAttribute("label"));v=_.om(c,_.Db);c=v.map(da=>FM(a,b,B,k,D,g,d,f,q,da)).filter(_.Ih);if(0===c.length){if(h)return null;throw new _.H(_.F,4,4003);}if(!b.sa.contentType||b.sa.contentType===KK){b.sa.contentType=
|
|
58
|
+
qM(c[0].mimeType,c[0].codecs);for(var M of c)M.type=b.sa.contentType}for(const da of c)for(const vb of B.drmInfos)da.keyId&&!vb.keyIds.includes(da.keyId)&&vb.keyIds.push(da.keyId);c=GM(c,b.sa.contentType,m);M=v.map(da=>da.getAttribute("id")).filter(_.Ih);return{id:b.sa.id||"__fake__"+a.o++,contentType:b.sa.contentType,language:u,originalLanguage:D,he:d,streams:c,drmInfos:B.drmInfos,Ke:l,lh:M}},AM=function(a,b){return a.filter(c=>c.contentType===b)},BM=function(a,b,c,d){if(b||c)if(b&&c){if(_.lB(b.drmInfos,
|
|
59
|
+
c.drmInfos)){var e=_.kB(b.drmInfos,c.drmInfos);for(var f of b.streams)for(const h of c.streams){var g=(h.bandwidth||0)+(f.bandwidth||0);g={id:a.o++,language:b.language,primary:b.he||c.he,audio:f,video:h,bandwidth:g,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0};d.push(g)}}}else{f=b||c;for(e of f.streams)g=e.bandwidth||0,g={id:a.o++,language:f.language||_.ag,primary:f.he,audio:b?e:null,video:c?e:null,bandwidth:g,drmInfos:f.drmInfos,allowedByApplication:!0,allowedByKeySystem:!0},d.push(g)}},
|
|
60
|
+
CM=function(a,b){return null!==a.duration?a.start+a.duration:0<b.length?(b=b.filter(c=>0<c.streams.length).map(c=>c.streams).flat().filter(c=>c.getLastSegmentEndTime).map(c=>c.getLastSegmentEndTime()),0<b.length?a.start+Math.min(...b):null):null},FM=function(a,b,c,d,e,f,g,h,k,l){const m=_.bi(e);b.P=xM(a,l,b.sa,null);if(!HM(a,b.P))return a.g.warn("Skipping Representation",b.P),null;b.Fe=`${b.Sa.id} ${b.P.id}`;b.cd=a.B.get(b.Fe);b.bandwidth=fL(l,"bandwidth",kL)||0;const n=IM(a,b);if(!n)return null;
|
|
61
|
+
a.B.set(b.Fe,n.Aa);var q=_.om(l,AK);a=nM(q,c,a.a.ignoreDrmInfo,b.Sa.id,a.a.playreadyVersion||null);q=!1;_.om(l,"SupplementalProperty").some(y=>"tag:dolby.com,2018:dash:EC3_ExtensionType:2018"===y.getAttribute(RK)&&"JOC"===y.getAttribute(_.hg))&&(b.P.mimeType="audio/eac3-joc",q=!0);let u=void 0;if(b.P.contentType===_.de){var v=(l=_.pm(l,BK))&&l.getAttribute(RK);v=v||"";if(JM.includes(v)&&(l=_.hB(l.getAttribute(_.hg)||""))&&(n.horizontalTiles=l.Uc,n.verticalTiles=l.ld,b.sa.Yb)){v=fL(b.sa.Yb,LK,lL)||
|
|
62
|
+
0;const y=fL(b.sa.Yb,TK,lL)||1;(v/=y)&&(u=v/l.xh)}}return{id:_.oH++,originalId:b.P.id,createSegmentIndex:n.createSegmentIndex,findSegmentPosition:n.findSegmentPosition,getSegmentReference:n.getSegmentReference,initSegmentReference:n.initSegmentReference,adjustSegmentDurations:n.adjustSegmentDurations,getLastSegmentEndTime:n.getLastSegmentEndTime,getDuration:n.getDuration,segmentLookupStrategy:_.AA,mimeType:b.P.mimeType,codecs:b.P.codecs,frameRate:b.P.frameRate,bandwidth:b.bandwidth,width:b.P.width,
|
|
63
|
+
height:b.P.height,kind:d,encrypted:0<c.drmInfos.length,keyId:a,language:m,originalLanguage:e,label:f,type:b.sa.contentType,primary:g,trickModeVideo:null,emsgSchemeIdUris:b.P.emsgSchemeIdUris,roles:h,channelsCount:b.P.le,spatialAudio:q,closedCaptions:k,horizontalTiles:n.horizontalTiles,verticalTiles:n.verticalTiles,durationPerTile:u}},GM=function(a,b,c){const d=b===_.MA?_.G:b;b=c.map(e=>({scheme:e.getAttribute(RK)||"",id:e.getAttribute("id")||void 0,value:e.getAttribute(_.hg)||"",protocol:"DASH",type:d}));
|
|
64
|
+
for(const e of a)e.accessibility=b;return a},HM=function(a,b){let c;c=b.jd?1:0;c+=b.Xb?1:0;c+=b.Yb?1:0;if(0===c){if(b.contentType===_.G||b.contentType===KK)return!0;a.g.warn("Representation does not contain a segment information source:","the Representation must contain one of SegmentBase, SegmentList,",'SegmentTemplate, or explicitly indicate that it is "text".',b);return!1}1!==c&&(a.g.warn("Representation contains multiple segment information sources:","the Representation should only contain one of SegmentBase,",
|
|
65
|
+
"SegmentList, or SegmentTemplate.",b),b.jd?(a.g.info("Using SegmentBase by default."),b.Xb=null):a.g.info("Using SegmentList by default."),b.Yb=null);return!0},IM=function(a,b){const c=a.a.attemptParameters;var d=b.P.contentType;d=d===_.G||d===KK;try{const e=(f,g,h,k)=>_.x(function*(){const l=_.HB(f,g,h,c);l.type=2;return(yield k.fetch(l)).data});if(b.P.jd)return KL(b,e);if(b.P.Xb)return YL(b,a.F);if(b.P.Yb)return SL(b,e,a.F,!!a.f);{const f=b.P.bb,g=b.za.duration||0;a=()=>g;return{createSegmentIndex:()=>
|
|
66
|
+
Promise.resolve(),findSegmentPosition:h=>0<=h&&h<g?1:null,getSegmentReference:h=>1!==h?null:new _.bC(1,0,g,()=>f,0,null,0),adjustSegmentDurations:()=>{},getDuration:a,getLastSegmentEndTime:a,verticalTiles:void 0,horizontalTiles:void 0,initSegmentReference:null,Aa:0}}}catch(e){if(d&&4002===e.code)return a.g.debug("Ignoring DASH_NO_SEGMENT_INFO error in a text stream",e),null;throw e;}},DM=function(a,b){for(const d of b){b=d.getAttribute(RK);if(!b)continue;const e=d.getAttribute(_.hg);if(e)switch(b){case "urn:mpeg:dash:outputChannelPositionList:2012":return e.trim().split(/ +/).length;
|
|
67
|
+
case "urn:mpeg:dash:23003:3:audio_channel_configuration:2011":case "urn:dts:dash:audio_channel_configuration:2012":var c=parseInt(e,10);if(!c){a.g.warn(zK,b,e);continue}return c;case "tag:dolby.com,2014:dash:audio_channel_configuration:2011":case "urn:dolby:dash:audio_channel_configuration:2011":c=parseInt(e,16);if(!c){a.g.warn(zK,b,e);continue}for(a=0;c;)c&1&&++a,c>>=1;return a;default:a.g.warn("Unrecognized audio channel scheme:",b,e)}}return null},JM=["http://dashif.org/thumbnail_tile","http://dashif.org/guidelines/thumbnail_tile"],
|
|
68
|
+
EM=["urn:mpeg:mpegB:cicp:ColourPrimaries","urn:mpeg:mpegB:cicp:MatrixCoefficients","urn:mpeg:mpegB:cicp:TransferCharacteristics"];var EL=class{constructor(a){this.f=a;this.a=new _.ym(a,!1)}},AL=[[255],[127,255],[63,255,255],[31,255,255,255],[15,255,255,255,255],[7,255,255,255,255,255],[3,255,255,255,255,255,255],[1,255,255,255,255,255,255,255]],BL=class{constructor(a,b){this.id=a;this.a=b}};var LL=class{parse(a,b,c,d){var e;b=new EL(new DataView(b));if(440786851!==CL(b).id)throw _.jh("Not an EBML element."),new _.H(_.F,3,3008);var f=CL(b);if(408125543!==f.id)throw _.jh("Not a Segment element."),new _.H(_.F,3,3009);b=f.a.byteOffset;f=new EL(f.a);for(e=null;_.vl(f.a);){var g=CL(f);if(357149030===g.id){e=g;break}}if(!e)throw _.jh("Not an Info element."),new _.H(_.F,3,3010);e=new EL(e.a);g=1E6;for(f=null;_.vl(e.a);){const h=CL(e);if(2807729===h.id)g=DL(h);else if(17545===h.id)if(f=h,4===
|
|
69
|
+
f.a.byteLength)f=f.a.getFloat32(0);else if(8===f.a.byteLength)f=f.a.getFloat64(0);else throw new _.H(_.F,3,3003);}if(null==f)throw new _.H(_.F,3,3011);e=g/=1E9;f*=g;a=CL(new EL(new DataView(a)));if(475249515!==a.id)throw _.jh("Not a Cues element."),new _.H(_.F,3,3007);return GL(a,b,e,f,c,d)}};var KM=class{constructor(a,b){this.g=a;this.f=b;this.a={clockSyncUri:void 0}}};var cM=(new Map).set("urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",_.Ne).set(YK,_.zd).set(XK,_.xd).set("urn:uuid:79f0049a-4098-8642-ab92-e65be0885f95",_.xd).set("urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2",_.vd).set("urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb",_.ud),mM=(new Map).set(_.zd,function(a){return(a=dL(a.node,"urn:microsoft","laurl"))?a.getAttribute("licenseUrl")||"":""}).set(_.xd,function(a){a=dL(a.node,UK,"pro");if(!a)return"";a=_.Ei(a.textContent);return _.Fm(a).h||""}),eM=new _.R("clpp.dash.ContentProtection");var LM=class{constructor(){this.D=this.a=null;this.j=[];this.f=null;this.C=[];this.o=1;this.F={};this.h=0;this.G=new _.hH(5);this.w=new _.Tj(()=>{this.Hb()});this.l=new _.Xs;this.g=new _.R("clpp.dash.DashParser");this.A=null;this.H=new KM(this.g,(a,b)=>{a=_.Si(a,this.a.attemptParameters);a.type=5;a.method=b;b=this.D.networkingEngine.fetch(a);_.Zi(this.l,b);return b.R});this.B=new Map;this.I=!1}configure(a){this.a=a;this.H.a={clockSyncUri:a.clockSyncUri}}start(a,b){const c=this;return _.x(function*(){c.j=
|
|
70
|
+
[a];c.D=b;const d=yield sM(c);c.D&&tM(c,d);if(!c.D)throw new _.H(_.F,7,7001);return c.f})}requestStop(){this.I=!0}stop(){this.a=this.D=null;this.j=[];this.f=null;this.C=[];this.F={};this.A=null;this.h=-1;this.w.stop();this.B.clear();return this.l.destroy()}update(){sM(this).catch(a=>{if(this.D&&a)this.D.onError(a)})}setCurrentVariant(){}Hb(){const a=this;return _.x(function*(){a.g.debug(_.rA);let b=0;try{b=yield sM(a)}catch(c){if(a.D&&c.a&&(a.D.onError(c),c.severity===_.F))return}a.D&&(a.I?yield a.stop():
|
|
71
|
+
tM(a,b))})}};_.z("clpp.dash.DashComponent",class extends _.Yt{f(){_.Br.mpd=LM;_.zr[_.zc]=LM}a(){_.AC("mpd");_.BC(_.zc)}id(){return"dash"}});};f.call(g, window);
|