@castlabs/prestoplay 6.32.0-beta.2 → 6.32.0-beta.5
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/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +7 -7
- package/cjs/cl.cast.js +56 -56
- package/cjs/cl.cdn.js +5 -5
- package/cjs/cl.conviva.js +18 -18
- package/cjs/cl.core.js +191 -191
- package/cjs/cl.dash.js +51 -51
- package/cjs/cl.freewheel.js +9 -9
- package/cjs/cl.hls.js +54 -54
- package/cjs/cl.hlssmpte.js +1 -1
- package/cjs/cl.htmlcue.js +3 -3
- package/cjs/cl.ima.js +11 -11
- package/cjs/cl.mediatailor.js +2 -2
- package/cjs/cl.mse.js +125 -125
- package/cjs/cl.muxdata.js +8 -8
- package/cjs/cl.persistent.js +2 -2
- package/cjs/cl.playlist.js +5 -5
- package/cjs/cl.simid.js +3 -3
- package/cjs/cl.smooth.js +28 -28
- package/cjs/cl.thumbnails.js +3 -3
- package/cjs/cl.tizen.js +34 -34
- package/cjs/cl.ttml.js +3 -3
- package/cjs/cl.verimatrix.js +1 -1
- package/cjs/cl.vimond.js +8 -8
- package/cjs/cl.vr.js +7 -7
- package/cjs/cl.vtt.js +1 -1
- package/cjs/cl.yospace.js +2 -2
- package/cjs/cl.youbora.js +11 -11
- package/cl.airplay.js +1 -1
- package/cl.cast.js +29 -29
- package/cl.cdn.js +5 -5
- package/cl.conviva.js +3 -3
- package/cl.core.js +116 -116
- package/cl.dash.js +48 -48
- package/cl.freewheel.js +3 -3
- package/cl.hls.js +35 -35
- package/cl.htmlcue.js +1 -1
- package/cl.ima.js +1 -1
- package/cl.mediatailor.js +2 -2
- package/cl.mse.js +78 -78
- package/cl.muxdata.js +2 -2
- package/cl.persistent.js +1 -1
- package/cl.playlist.js +4 -4
- package/cl.simid.js +1 -1
- package/cl.smooth.js +22 -22
- package/cl.thumbnails.js +4 -4
- package/cl.tizen.js +15 -15
- package/cl.ttml.js +2 -2
- package/cl.verimatrix.js +1 -1
- package/cl.vimond.js +2 -2
- package/cl.vr.js +2 -2
- package/cl.vtt.js +2 -2
- package/cl.yospace.js +2 -2
- package/cl.youbora.js +8 -8
- package/package.json +1 -1
package/cl.dash.js
CHANGED
|
@@ -4,87 +4,87 @@ JM="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",KM=function(a,b){return _.Yg[
|
|
|
4
4
|
()=>e())},NM=function(a){return new _.Rs(Promise.reject(a),()=>Promise.resolve())},OM=function(a){return new _.Rs(Promise.all(a.map(b=>b.V)),()=>Promise.all(a.map(b=>b.abort())))},PM=function(a,b){return a.reduce(((c,d,e)=>d.catch(c.bind(null,e))).bind(null,b),Promise.reject())},QM=function(a){return a===_.q||a===_.t},RM=function(a){return 1>=a?0:Math.floor(Math.random()*a)},SM=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:
|
|
5
5
|
Math.floor(a/1E3)},TM=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 _.B("Invalid duration string:",a),null;a=31536E3*Number(b[1]||null)+2592E3*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},UM=function(a){var b=/([0-9]+)-([0-9]+)/.exec(a);if(!b)return null;a=Number(b[1]);if(!isFinite(a))return null;b=
|
|
6
6
|
Number(b[2]);return isFinite(b)?{start:a,end:b}:null},VM=function(a){a=Number(a);return 0===a%1?a:null},WM=function(a){a=Number(a);return 0===a%1&&0<a?a:null},XM=function(a){a=Number(a);return 0===a%1&&0<=a?a:null},YM=function(a){let b;a=(b=a.match(/^(\d+)\/(\d+)$/))?Number(b[1])/Number(b[2]):Number(a);return isNaN(a)?null:a},ZM=function(a){return a?"true"===a.toLowerCase():!1},$M=function(a){var b=void 0===b?1024:b;if(!(a instanceof Uint8Array))return"";if(typeof b!==_.r||0>=b)b=1024;return(a.byteLength>
|
|
7
|
-
b?a.subarray(0,b):a).toString()},aN=function(a,b){b-=a.l;return 0>b||b>=a.j?null:b},bN=function(a){let b=0;for(const c of a)!(0>=c.count)&&c.duration>b&&(b=c.duration);return b},cN=function(a,b){if(0>b||b>=a.a)throw new _.tl(`SegmentTimelineIndex: out of bounds: ${b}/${a.a}`);a:{var c=0;let d=a.f.length-1;for(;c<=d;){const e=Math.floor((c+d)/2),f=a.f[e],g=f.
|
|
8
|
-
a=c=a.f[c];b-=c.
|
|
7
|
+
b?a.subarray(0,b):a).toString()},aN=function(a,b){b-=a.l;return 0>b||b>=a.j?null:b},bN=function(a){let b=0;for(const c of a)!(0>=c.count)&&c.duration>b&&(b=c.duration);return b},cN=function(a,b){if(0>b||b>=a.a)throw new _.tl(`SegmentTimelineIndex: out of bounds: ${b}/${a.a}`);a:{var c=0;let d=a.f.length-1;for(;c<=d;){const e=Math.floor((c+d)/2),f=a.f[e],g=f.ue+f.count-1;if(b<f.ue)d=e-1;else if(b>g)c=e+1;else{c=e;break a}}c=-1}if(0>c)throw new _.tl(`SegmentTimelineIndex: index not found: ${b}/${a.a}`);
|
|
8
|
+
a=c=a.f[c];b-=c.ue;c=a.startTime+b*a.duration;return{startTime:c,endTime:b===a.count-1&&null!=a.Ed?a.Ed:c+a.duration,rj:a.qj+b*a.pj}},dN=function(a,b){if(0===a.a)return null;if(b<a.j)return 0;var c=a.f[a.f.length-1];if(b>=(null!=c.Ed?c.Ed:c.startTime+c.count*c.duration))return null;{c=0;let d=a.f.length-1,e=0;for(;c<=d;){const f=Math.floor((c+d)/2);b<a.f[f].startTime?d=f-1:(e=f,c=f+1)}c=e}a=a.f[c];b=Math.floor((b-a.startTime)/a.duration);0>b?b=0:b>=a.count&&(b=a.count-1);return a.ue+b},eN=function(a,
|
|
9
9
|
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"$";let m=f[h];if(null==m)return _.B("URL template does not have an available substitution ","for identifier",'"'+h+'":',a),g;"RepresentationID"===h&&k&&(_.B("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=
|
|
10
|
-
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,10)||1;return Array(Math.max(0,k-g.length)+1).join("0")+g})},iN=function(a,b){var c=fN(a,b,EM);let d=1;c&&(d=WM(c)||1);c=fN(a,b,vM);(c=WM(c||""))&&(c/=d);let e=Number(fN(a,b,BM))||0,f=e/d||0;a.
|
|
11
|
-
`value will be ignored. (Period ID: ${a.Ja.id}, `+`Representation ID: ${a.O.id})`),e=a.
|
|
10
|
+
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,10)||1;return Array(Math.max(0,k-g.length)+1).join("0")+g})},iN=function(a,b){var c=fN(a,b,EM);let d=1;c&&(d=WM(c)||1);c=fN(a,b,vM);(c=WM(c||""))&&(c/=d);let e=Number(fN(a,b,BM))||0,f=e/d||0;a.xi&&null!=a.Sd&&a.Sd!==f&&(_.B("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 "+
|
|
11
|
+
`value will be ignored. (Period ID: ${a.Ja.id}, `+`Representation ID: ${a.O.id})`),e=a.Sd*d,f=a.Sd);var g=fN(a,b,"startNumber");let h=XM(g||"");if(null==g||null==h)h=1;g=fN(a,b,"endNumber");g=null!==g?XM(g||""):null;var k=gN(a,b,rM),l=null;if(k){{l=d;var m=e,n=a.Za.duration||Infinity;const y=_.O;k=y.a(k,"S");const A=[];var p=0;let E=0;for(let F=0;F<k.length;++F){const C=k[F];var u=y.aa(C,"t",XM);const ja=y.aa(C,"d",XM);var v=y.aa(C,"r",VM);null!=u&&(u-=m);if(!ja){_.B('"S" element must have a duration:',
|
|
12
12
|
zM,C);break}u=null!=u?u:p;v=v||0;if(0>v)if(F+1<k.length){v=y.aa(k[F+1],"t",XM);if(null==v){_.B('An "S" element cannot have a negative repeat','if the next "S" element does not have a valid start time:',zM,C);break}else if(u>=v){_.B('An "S" element cannot have a negative repeat if its start ','time exceeds the next "S" element\'s start time:',zM,C);break}v=Math.ceil((v-u)/ja)-1}else{if(Infinity===n){_.B(tM,"if the Period has an infinite duration:",yM,C);break}else if(u/l>=n){_.B(tM,"if its start time exceeds the Period's duration:",
|
|
13
|
-
yM,C);break}v=Math.ceil((n*l-u)/ja)-1}0<A.length&&u!==p&&(Math.abs((u-p)/l)>=_.ou&&_.B("SegmentTimeline contains a large gap/overlap:","the content may have errors in it.",C),A[A.length-1].
|
|
14
|
-
d.getAttribute(c)).reduce((d,e)=>d||e)},gN=function(a,b,c){return[b(a.O),b(a.xa),b(a.Ja)].filter(_.Nm).map(d=>_.O.h(d,c)).reduce((d,e)=>d||e)},kN=function(a,b,c,d,e,f){const g=_.O,h=g.getAttributeNS(a,xM,"href"),k=g.getAttributeNS(a,xM,"actuate")||"onRequest";g.
|
|
15
|
-
g.
|
|
16
|
-
0,b.ac+c)));a.
|
|
17
|
-
c[0];a=_.G(a);_.Dh('Invalid box type. Expected "sidx", but received:',a,"from:",g,"byte range:",f);throw new _.I(_.D,3,3004,{url:g,
|
|
13
|
+
yM,C);break}v=Math.ceil((n*l-u)/ja)-1}0<A.length&&u!==p&&(Math.abs((u-p)/l)>=_.ou&&_.B("SegmentTimeline contains a large gap/overlap:","the content may have errors in it.",C),A[A.length-1].Ed=u/l);p=v+1;A.push({ue:E,count:p,startTime:u/l,duration:ja/l,qj:u,pj:ja,Ed:null});E+=p;p=u+p*ja}l=new hN(A)}}a=fN(a,b,"availabilityTimeOffset");b=Number(a||"");b=isNaN(b)?null:b;if(null==a||null==b)b=0;return{timescale:d,$a:c,Pc:h,df:g,Sb:f,Sf:e,wa:l,Xe:b}},fN=function(a,b,c){return[b(a.O),b(a.xa),b(a.Ja)].filter(_.Nm).map(d=>
|
|
14
|
+
d.getAttribute(c)).reduce((d,e)=>d||e)},gN=function(a,b,c){return[b(a.O),b(a.xa),b(a.Ja)].filter(_.Nm).map(d=>_.O.h(d,c)).reduce((d,e)=>d||e)},kN=function(a,b,c,d,e,f){const g=_.O,h=g.getAttributeNS(a,xM,"href"),k=g.getAttributeNS(a,xM,"actuate")||"onRequest";g.Le(a,xM);if(5<=f)return NM(new _.I(_.D,4,4028));if("onLoad"!==k)return NM(new _.I(_.D,4,4027));const l=_.qB([d],[h]);d=_.zk(l,b);d.type=1;return MM(e.fetch(d),m=>{m=_.ri(m.data);m=g.j(m,a.tagName);if(!m)return NM(new _.I(_.D,4,4001,{uri:h}));
|
|
15
|
+
g.Ke(a);g.Be(m,a);g.Ae(m,a);return jN(a,b,c,l[0],e,f+1)})},jN=function(a,b,c,d,e,f){f=void 0===f?0:f;var g=_.O;if(g.getAttributeNS(a,xM,"href"))return g=kN(a,b,c,d,e,f),c&&(g=MM(g,void 0,()=>jN(a,b,c,d,e,f))),g;const h=[],k=g.we(a);for(const l of k)"urn:mpeg:dash:resolve-to-zero:2013"===g.getAttributeNS(l,xM,"href")?g.removeChild(a,l):l.tagName!==rM&&h.push(jN(l,b,c,d,e,f));return MM(OM(h),()=>a)},lN=function(a,b){const c=a.Za.start;var d=a.presentationTimeline;d.o||(d.I=Math.floor(Math.max(d.I||
|
|
16
|
+
0,b.ac+c)));a.Kg||_.kC(a.presentationTimeline,{pc:b.pc+c,ac:b.ac+c,bc:b.bc},"notifySegmentSummary")},mN=function(a){return""===a.id?`${a.schemeIdUri}:${a.startTime}:${a.endTime}`:a.id},nN=function(a,b,c,d,e){return _.w(function*(){const f=_.ZB(a,b,c,e);f.type=2;return(yield _.tm(d,f,{objectType:"i"}).V).data})},oN=function(a,b){b-=a.h;return 0>b||b>=a.f?null:b},qN=function(a,b,c,d){let e;var f=(new _.np).fa("sidx",g=>{e=pN(b,d,c,g)});a&&f.parse(a);if(e)return e;{f=`${b}-${b+a.byteLength-1}`;const g=
|
|
17
|
+
c[0];a=_.G(a);_.Dh('Invalid box type. Expected "sidx", but received:',a,"from:",g,"byte range:",f);throw new _.I(_.D,3,3004,{url:g,Cj:f,size:a.byteLength,Sj:$M(a)});}},pN=function(a,b,c,d){const e=[];d.reader.skip(4);const f=_.N(d.reader);if(0===f)throw _.Dh("Invalid timescale."),new _.I(_.D,3,3005);if(0===d.version){var g=_.N(d.reader);var h=_.N(d.reader)}else g=_.bp(d.reader),h=_.bp(d.reader);d.reader.skip(2);const k=_.$o(d.reader);a=a+d.size+h;for(h=0;h<k;h++){var l=_.N(d.reader);const m=(l&2147483648)>>>
|
|
18
18
|
31;l&=2147483647;const n=_.N(d.reader);d.reader.skip(4);if(1===m)throw _.Dh("Hierarchical SIDXs are not supported."),new _.I(_.D,3,3006);e.push(new _.rI(e.length,g/f-b,(g+n)/f-b,()=>c,a,a+l-1,b));g+=n;a+=l}d.parser.stop();return e},rN=function(a){var b=_.Zo(a.a);let c;for(c=1;8>=c&&!(b&1<<8-c);c++);if(8<c)throw new _.I(_.D,3,3002);const d=new Uint8Array(c);d[0]=b;for(b=1;b<c;b++)d[b]=_.Zo(a.a);return d},uN=function(a){var b=rN(a);if(7<b.length)throw new _.I(_.D,3,3002);var c=0;for(var d=0;d<b.length;d++)c=
|
|
19
19
|
256*c+b[d];b=c;c=rN(a);a:{for(e of sN)if(_.hm(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 _.I(_.D,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?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 tN(b,e)},vN=function(a){if(8<a.a.byteLength)throw new _.I(_.D,3,3002);if(8===a.a.byteLength&&
|
|
20
|
-
a.a.getUint8(0)&224)throw new _.I(_.D,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},yN=function(a,b,c,d,e,f){const g=[],h=()=>e;a=new wN(a.a);let k=null,l=null;for(;_.Xo(a.a);){var m=uN(a);if(187===m.id){var n=xN(m);n&&(m=c*n.
|
|
21
|
-
new _.I(_.D,3,3013);a=vN(a);b=uN(b);if(183!==b.id)throw _.B("Not a CueTrackPositions element."),new _.I(_.D,3,3012);b=new wN(b.a);let c=0;for(;_.Xo(b.a);){const d=uN(b);if(241===d.id){c=vN(d);break}}return{
|
|
22
|
-
CN=function(a,b,c,d,e,f,g){const h=a.presentationTimeline,k=!a.
|
|
23
|
-
adjustSegmentDurations:function(p,u){return n.h(p,u)},getDuration:function(){return null!=m?m:n.getDuration()},getLastSegmentEndTime:()=>m}},DN=function(a){var b=a.a.o();if(0===b)return null;const c=a.a.w();b=c+b-1;a=Math.max(a.l,c);return a>b?null:{Kb:a,Zb:b}},EN=function(a,b){var c,d=a.a.B(b);if(!d)throw new _.tl(`Cannot get segment timing for source position ${b}`);if(!(0<a.h.length||null!=a.j))return d;var e=b+a.f;var f=c=0;for(const g of a.h)g.position<e?c+=g.
|
|
20
|
+
a.a.getUint8(0)&224)throw new _.I(_.D,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},yN=function(a,b,c,d,e,f){const g=[],h=()=>e;a=new wN(a.a);let k=null,l=null;for(;_.Xo(a.a);){var m=uN(a);if(187===m.id){var n=xN(m);n&&(m=c*n.sj,n=b+n.Ui,null!=k&&g.push(new _.rI(g.length,k-f,m-f,h,l,n-1,f)),k=m,l=n)}}null!=k&&g.push(new _.rI(g.length,k-f,d-f,h,l,null,f));return g},xN=function(a){var b=new wN(a.a);a=uN(b);if(179!==a.id)throw _.B("Not a CueTime element."),
|
|
21
|
+
new _.I(_.D,3,3013);a=vN(a);b=uN(b);if(183!==b.id)throw _.B("Not a CueTrackPositions element."),new _.I(_.D,3,3012);b=new wN(b.a);let c=0;for(;_.Xo(b.a);){const d=uN(b);if(241===d.id){c=vN(d);break}}return{sj:a,Ui:c}},zN=function(a,b){var c=gN(a,b,"Initialization");if(!c)return null;let d=a.O.qa;b=()=>"";const e=c.getAttribute("sourceURL")||void 0;e&&(d=_.qB(a.O.qa,[e]),b=()=>e);let f=0,g=null;if(c=_.O.aa(c,"range",UM))f=c.start,g=c.end;return new _.qI(()=>d,f,g,null,null,b,a.O.Ha)},AN=function(a){return a.$d},
|
|
22
|
+
CN=function(a,b,c,d,e,f,g){const h=a.presentationTimeline,k=!a.cf||!a.Za.vi,l=a.Za.start,m=a.Za.duration;let n=null;return{createSegmentIndex:function(p,u){return _.w(function*(){var v=[nN(c,d,e,p,u),"webm"===f?nN(b.Da(),b.na,b.ja,p,u):null];v=yield Promise.all(v);var y=v[0];const A=v[1]||null;y="mp4"===f?qN(y,d,c,g):(new BN).parse(y,A,c,g);QM(a.O.contentType)&&_.lC(h,y,l);n=new _.vI(y);k&&_.VB(n,m);return v})},findSegmentPosition:function(p){return n.f(p)},getSegmentReference:function(p){return n.get(p)},
|
|
23
|
+
adjustSegmentDurations:function(p,u){return n.h(p,u)},getDuration:function(){return null!=m?m:n.getDuration()},getLastSegmentEndTime:()=>m}},DN=function(a){var b=a.a.o();if(0===b)return null;const c=a.a.w();b=c+b-1;a=Math.max(a.l,c);return a>b?null:{Kb:a,Zb:b}},EN=function(a,b){var c,d=a.a.B(b);if(!d)throw new _.tl(`Cannot get segment timing for source position ${b}`);if(!(0<a.h.length||null!=a.j))return d;var e=b+a.f;var f=c=0;for(const g of a.h)g.position<e?c+=g.re:g.position===e&&(f+=g.re);e=c;
|
|
24
24
|
c=f;f=d.startTime+e;d=d.endTime+e+c;e=DN(a);a.j&&b===e.Zb&&(d+=a.j);return{startTime:f,endTime:d}},FN=function(a,b){return(a=DN(a))?b>=a.Kb&&b<=a.Zb:!1},GN=function(a){var b=DN(a);if(!b)return null;var c=b.Kb===a.a.w();if(!(0<a.h.length||null!=a.j)&&c)return a.a.C();c=EN(a,b.Kb);b=EN(a,b.Zb);return(a=a.a.C())?{pc:c.startTime,ac:b.endTime,bc:a.bc}:null},HN=function(a,b){if(null===b||Infinity===b)a.g.warn(`Period duration is ${b}. Skipping fit.`);else{var c=DN(a);c?(c=a.a.B(c.Zb),c.startTime>=b||(a.j=
|
|
25
25
|
b-c.endTime)):a.g.warn(sM)}},IN=function(a,b){var c=DN(a);if(c){var d=c.Kb;c=c.Zb;for(var e=c+1;d<=c;d++)if(EN(a,d).endTime>b){e=d;break}a.l=e}else a.g.warn(sM)},JN=function(a,b){const c=a.a.o(),d=b.o();if(0===c||0===d)return null;const e=a.a.w(),f=b.w();let g=0,h=0;for(;g<c&&h<d;){const k=e+g,l=f+h,m=a.a.B(k),n=b.B(l);if(!m||!n)break;const p=Math.abs(m.endTime-n.endTime);if(.1>=Math.abs(m.startTime-n.startTime)||.1>=p)return k-l+a.f;m.startTime<n.startTime?g++:h++}return null},KN=function(a,b){if(0===
|
|
26
|
-
b.o())a.g.warn("Source is empty. Skipping update.");else{var c=()=>{a.a=b;a.l=b.w();a.h=[];a.j=null};0===a.a.o()&&c();var d=JN(a,b);if(null!=d)a.f=d;else throw a.g.error("Segments could not be updated, overlapping position not found."),new _.I(_.D,4,4014);c()}},MN=function(a,b,c){const d=a.Za.duration;if(!a.
|
|
27
|
-
a.Za.start);HN(c,d);return c},ON=function(a){const b=fN(a,NN,"initialization");if(!b)return null;const c=a.O.id,d=a.bandwidth||null,e=a.O.qa,f=()=>eN(b,c,null,d,null);return new _.qI(function(){const g=f();return _.qB(e,[g])},0,null,null,null,f,a.O.Ha)},PN=function(a,b){const c=b.
|
|
26
|
+
b.o())a.g.warn("Source is empty. Skipping update.");else{var c=()=>{a.a=b;a.l=b.w();a.h=[];a.j=null};0===a.a.o()&&c();var d=JN(a,b);if(null!=d)a.f=d;else throw a.g.error("Segments could not be updated, overlapping position not found."),new _.I(_.D,4,4014);c()}},MN=function(a,b,c){const d=a.Za.duration;if(!a.cf)return a=new LN(b),IN(a,0),HN(a,d),a;{var e=a.Ja;const f=a.O;e=e&&e.id&&f&&f.id?`${e.id},${f.id}`:null}if(!a.Kg||null==c[e])return a=new LN(b),IN(a,0),HN(a,d),c[e]=a;c=c[e];KN(c,b);IN(c,_.oC(a.presentationTimeline)-
|
|
27
|
+
a.Za.start);HN(c,d);return c},ON=function(a){const b=fN(a,NN,"initialization");if(!b)return null;const c=a.O.id,d=a.bandwidth||null,e=a.O.qa,f=()=>eN(b,c,null,d,null);return new _.qI(function(){const g=f();return _.qB(e,[g])},0,null,null,null,f,a.O.Ha)},PN=function(a,b){const c=b.lf,d=a.Za.duration,e=b.$a,f=b.Pc,g=b.df,h=b.timescale,k=a.bandwidth||null,l=a.O.id,m=a.O.qa,n=a.O.Ha;return{createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:function(p){return 0>p||d&&p>=d?null:Math.floor(p/
|
|
28
28
|
e)},getSegmentReference:function(p){const u=p+f;if(null!==g&&u>g)return null;const v=p*e;let y=v+e;d&&(y=Math.min(y,d));if(0>y||d&&v>=d)return null;const A=()=>eN(c,l,u,k,v*h);return new _.rI(p,v,y,function(){const E=A();return _.qB(m,[E])},0,null,b.Sb,null,null,null,null,null,null,null,null,A,n)},adjustSegmentDurations:()=>{},getDuration:()=>d,getLastSegmentEndTime:()=>d}},NN=function(a){return a.uc},QN=function(a){return a.tc},RN=function(a){return[a.O.tc,a.xa.tc,a.Ja.tc].filter(_.Nm).map(b=>_.O.a(b,
|
|
29
|
-
"SegmentURL")).reduce((b,c)=>0<b.length?b:c).map(b=>{b.getAttribute("indexRange")&&!a.
|
|
29
|
+
"SegmentURL")).reduce((b,c)=>0<b.length?b:c).map(b=>{b.getAttribute("indexRange")&&!a.gf&&(a.gf=!0,_.B("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=_.O.aa(b,"mediaRange",UM,{start:0,end:null});return{Mg:c,start:b.start,end:b.end}})},TN=function(a,b,c){c=c.map(e=>({scheme:e.getAttribute(CM),value:e.getAttribute(_.vg)}));const d=a.a.clockSyncUri;
|
|
30
30
|
!c.length&&d&&(a.g.info("No UTCTiming elements found, falling back on clockSyncUri from config to synchronize clocks."),c.push({scheme:HM,value:d}));return 0===c.length?(a.g.warn(nM),Promise.reject(Error(nM))):PM(c,e=>{const f=e.scheme;e=e.value;switch(f){case HM:case "urn:mpeg:dash:utc:http-head:2012":return SN(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 SN(a,
|
|
31
31
|
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(()=>
|
|
32
32
|
{a.g.warn(kM);return Promise.reject(Error(kM))})},UN=function(a,b,c,d){return _.w(function*(){const e=_.O.a(b,"UTCTiming");try{const f=yield TN(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})},SN=function(a,b,c,d){return _.w(function*(){var e=_.qB(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",
|
|
33
33
|
"expected date header"),Error("Date HTTP header missing.");e=e.headers.date}else e=_.ri(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()})},WN=function(a,b){return a.find(c=>VN.get(c.fc)===b)},YN=function(a){const b=_.O;var c=b.Wb(a.node,FM,"pro");if(!c)return XN.warn(mM,a),null;c=b.f(c);if(!c)return XN.warn(eM,a),null;a=_.em(c);a=_.rq(a);a=_.jq(a.a);return{keyId:null,fc:JM,node:b.Vc(),init:[{initData:_.dB(a),
|
|
34
34
|
initDataType:_.Wc,keyId:null}]}},ZN=function(a,b){b=void 0===b?"4.0.0.0":b;const c=_.O;a=c.Wb(a.node,GM,"pssh");if(!a)return null;a=c.f(a);if(!a)return null;a=_.em(a);a=_.lq(a);return a?(b=_.eB(b,a.a))?{keyId:null,fc:IM,node:c.Vc(),init:[{initData:_.dB(b),initDataType:_.Wc,keyId:null}]}:null:(_.B("Unable to parse WV PSSH data. Can not create PR data!"),null)},$N=function(a,b){const c=_.O;var d=c.Wb(a.node,FM,"pro");if(!d)return _.B(mM,a),null;d=c.f(d);if(!d)return _.B(eM,a),null;a=_.em(d);a=_.rq(a);
|
|
35
35
|
return a.version!==b&&(_.Ch(`Parsing from ${a.version} to ${b}.`),a=_.fB(a,b))?{keyId:null,fc:IM,node:c.Vc(),init:[{initData:_.dB(a),initDataType:_.Wc,keyId:null}]}:null},cO=function(a,b,c,d){const e=aO(a);let f=null;a=[];let g=[];const h=WN(e,_.wd),k=WN(e,_.ud);if(k&&d){var l=$N(k,d);l&&(e[e.indexOf(k)]=l)}k&&!h&&(l=YN(k))&&e.push(l);h&&!k&&(d=ZN(h,d||void 0))&&e.push(d);d=new Set(e.map(m=>m.keyId));d.delete(null);if(1<d.size)throw new _.I(_.D,4,4010);b||(g=e.filter(m=>"urn:mpeg:dash:mp4protection:2011"===
|
|
36
|
-
m.fc?(f=m.init||f,!1):!0),g.length&&(a=bO(f,g,c),0===a.length&&(a=[_.rB(_.He,f,c)])));if(e.length&&(b||!g.length)){a=[];for(const m of VN.values())m!==_.Re&&a.push(_.rB(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{
|
|
37
|
-
e.licenseUrl,b.licenseServerUriOrigin=e.origin):b.licenseServerUri="";d.push(b)}}return d},fO=function(a,b,c,d,e){const f=cO(a,c,d,e);if(b.
|
|
36
|
+
m.fc?(f=m.init||f,!1):!0),g.length&&(a=bO(f,g,c),0===a.length&&(a=[_.rB(_.He,f,c)])));if(e.length&&(b||!g.length)){a=[];for(const m of VN.values())m!==_.Re&&a.push(_.rB(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{Bd:b,Fj:f,drmInfos:a,vg:!0}},aO=function(a){const b=[];for(const c of a)(a=dO(c))&&b.push(a);return b},bO=function(a,b,c){const d=[];for(const f of b){var e=VN.get(f.fc);if(e){b=_.rB(e,f.init||a,c);if(e=eO.get(e))(e=e(f))?(b.licenseServerUri=
|
|
37
|
+
e.licenseUrl,b.licenseServerUriOrigin=e.origin):b.licenseServerUri="";d.push(b)}}return d},fO=function(a,b,c,d,e){const f=cO(a,c,d,e);if(b.vg){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.Bd=f.Bd||b.Bd;b.vg=!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 _.I(_.D,4,4008);return f.Bd||b.Bd},gO=function(a){const b=_.O;a=
|
|
38
38
|
b.Ec(a.node,"https://dashif.org/CPS","Laurl").map(c=>b.f(c)).filter(Boolean);return 0===a.length?null:1===a.length?a[0]:a[RM(a.length)]},dO=function(a){const b=_.O;let c=a.getAttribute(CM),d=b.getAttributeNS(a,GM,"default_KID");const e=b.Ec(a,GM,"pssh").map(b.f),f=b.Wb(a,FM,"pro");if(!c)return _.Dh("Missing required schemeIdUri attribute on","ContentProtection element",a),null;c=c.toLowerCase();if(d&&(d=d.replace(/-/g,"").toLowerCase(),d.includes(" ")))throw new _.I(_.D,4,4009);let g=[];try{if(g=
|
|
39
39
|
e.map(h=>({initDataType:_.Wc,initData:_.em(h),keyId:null})),0===g.length&&f&&b.f(f))try{const h=b.f(f),k=_.em(h),l=_.rq(k);g.push({initDataType:_.Wc,initData:_.dB(l),keyId:null})}catch(h){_.B("Unable to parse ms:pro payload",h),g=[]}}catch(h){throw new _.I(_.D,4,4007);}return{node:a,fc:c,keyId:d,init:0<g.length?g:null}},hO=function(a,b,c){if(a.length){c=c||`${"__clpp_baseUriCollection_"}
|
|
40
40
|
${b.length}`;const d=[];a.forEach(e=>{const f=e.getAttribute("serviceLocation");e=_.O.f(e);f&&e&&d.push({serviceLocationId:f,uri:e,params:{}})});if(d.length)return a=new _.zI(c,d),b.push(a),a}return null},jO=function(a,b){a=iO(a).filter(c=>c.getLastSegmentEndTime).map(c=>c.getLastSegmentEndTime());0<a.length&&(a=Math.min(...a),_.jC(b.presentationTimeline,a+b.Za.start))},kO=function(a,b){return _.$B(_.Xm(a,b))?_.K:a.split("/")[0]},iO=function(a){const b=new Set;a.forEach(c=>{c.variants.forEach(d=>
|
|
41
41
|
{d.audio&&b.add(d.audio);d.video&&b.add(d.video)})});return Array.from(b)},mO=function(a){return _.w(function*(){var b=a.w?a.w.getBaseUriCollectionById(lM):null;var c=[];b&&(c=_.TC(b,""));0===c.length&&(c=a.o);var d=_.zk(c,a.a.attemptParameters);d.type=1;c=Date.now();d=a.D.networkingEngine.fetch(d);_.Jl(a.A,d);var e=yield d.V;if(!a.D)return 0;b||e.uri&&!a.o.includes(e.uri)&&a.o.unshift(e.uri);d=null!=a.f;const f=yield lO(a,e.data,e.uri);f.manifest.contentSteering&&(a.w=yield a.D.onContentSteeringInfoFound(f.manifest.contentSteering));
|
|
42
|
-
if(a.w&&b){0!==e.request.uriIndex&&a.w.banLocation(b.qa[0].serviceLocationId);var g=e.request,h=e.timeMs;e=e.data.byteLength;h&&e&&a.w.notifyThroughput(b.qa[g.uriIndex].serviceLocationId,h,e)}b=(Date.now()-c)/1E3;_.XB(a.I,1,b);if(d&&a.D.onUpdate)a.D.onUpdate(f.manifest);if(f.
|
|
42
|
+
if(a.w&&b){0!==e.request.uriIndex&&a.w.banLocation(b.qa[0].serviceLocationId);var g=e.request,h=e.timeMs;e=e.data.byteLength;h&&e&&a.w.notifyThroughput(b.qa[g.uriIndex].serviceLocationId,h,e)}b=(Date.now()-c)/1E3;_.XB(a.I,1,b);if(d&&a.D.onUpdate)a.D.onUpdate(f.manifest);if(f.oj){if(a.D.onTurnedStatic)a.D.onTurnedStatic();a.D.onEvent(new _.H(_.Fe))}return b})},nO=function(a,b){0>a.l||a.B.la(Math.max(3,a.l-b,_.YB(a.I)))},lO=function(a,b,c){return _.w(function*(){var d=_.ri(b);_.zm(AM);d=_.O.j(d,"MPD");
|
|
43
43
|
_.zm("parse.xml.end");_.Bm(AM,AM,"parse.xml.end");if(!d)throw new _.I(_.D,4,4001,c);d=jN(d,a.a.attemptParameters,a.a.xlinkFailGracefully,c,a.D.networkingEngine);_.Jl(a.A,d);d=yield d.V;return oO(a,d,c)})},oO=function(a,b,c){return _.w(function*(){var d=_.O;const e=[];var f=[c],g=d.a(b,lM),h=g.map(d.f).filter(_.Nm);0<h.length&&(f=_.qB(f,h),a.o=f,hO(g,e,lM));g=d.a(b,fM);h=g.map(d.f);var k=_.qB(f,h);hO(g,e,fM);f=b.getAttribute("type")||DM;a.l=d.aa(b,"minimumUpdatePeriod",TM,-1);f===DM&&0<=a.l&&(a.g.warn("Invalid manifest - a static manifest should not contain the `minimumUpdatePeriod` attribute. The attribute will be ignored."),
|
|
44
44
|
a.l=-1,a.B.stop());g=d.aa(b,"maxSegmentDuration",TM);if(d=f===DM&&"dynamic"===a.C)a.g.info("MPD dynamic to static transition."),f="dynamic";h=f===DM;var l="dynamic"===f;if(a.f)var m=a.f.presentationTimeline;else{var n=_.O;m=a.a.timeline||{};var p=n.aa(b,"suggestedPresentationDelay",TM),u=n.aa(b,"minBufferTime",TM,0);p=null!=a.a.suggestedPresentationDelay?a.a.suggestedPresentationDelay:a.a.lowLatencyMode?0:null!=p?p:3*u;n=n.aa(b,"availabilityStartTime",SM);m=new _.uI(m,n,p,h,!!a.a.autoCorrectDrift,
|
|
45
|
-
!!a.a.lowLatencyMode);m=h?m:UN(a.J,b,k,m)}m=yield m;n=_.O.aa(b,"timeShiftBufferDepth",TM);n=l&&a.a.availabilityWindowOverride&&!isNaN(a.a.availabilityWindowOverride)?a.a.availabilityWindowOverride:null===n?Infinity:n;m.A=n;if(!a.D)throw new _.I(_.D,7,7001);n={
|
|
45
|
+
!!a.a.lowLatencyMode);m=h?m:UN(a.J,b,k,m)}m=yield m;n=_.O.aa(b,"timeShiftBufferDepth",TM);n=l&&a.a.availabilityWindowOverride&&!isNaN(a.a.availabilityWindowOverride)?a.a.availabilityWindowOverride:null===n?Infinity:n;m.A=n;if(!a.D)throw new _.I(_.D,7,7001);n={cf:l,Kg:null!=a.f,presentationTimeline:m,Ja:null,Za:null,xa:null,O:null,bandwidth:0,gf:!1,xi:d,hc:null,Sd:null};k=pO(a,n,k,e,b);p=k.duration;l=k.periods;d&&(jO(l,n),m.C=!0);if(h||!d&&!k.sg)m.f=p||Infinity;if(2===a.a.timeline.version){h=p;n=l[0].startTime;
|
|
46
46
|
if(null==h||Infinity===h)h=qO(l);p=m.a;_.dC(p,n,n+h);d&&(p.f=!0)}_.mC(m,g||1);m.isLive()||Infinity!==m.f&&!m.o||2===m.j.version&&m.a.getDuration();if(!a.f){a.f={presentationTimeline:m,periods:l,minBufferTime:0,cues:[]};a:{l=_.O;if(m=l.h(b,"ContentSteering"))if(g=m.getAttribute("defaultServiceLocation")||"",h=l.f(m)){l=l.aa(m,"queryBeforeStart",ZM,!1);g={manifestType:_.vc,contentSteeringServerUri:h,defaultServiceLocation:g,queryBeforeStart:l||!1,baseUriCollections:[]};break a}g=null}g&&(a.f.contentSteering=
|
|
47
|
-
g,a.f.contentSteering.baseUriCollections=e)}a.f.cues=k.cues;a.C=f;return{manifest:a.f,
|
|
48
|
-
n);null==y&&(y=p);n=rO(a,b,c,d,{start:m,duration:y,node:n,
|
|
49
|
-
"all Periods."),{periods:l,duration:g,
|
|
50
|
-
_.fa).map(A=>vO(a,b,A)).filter(_.Nm);if(b.
|
|
47
|
+
g,a.f.contentSteering.baseUriCollections=e)}a.f.cues=k.cues;a.C=f;return{manifest:a.f,oj:d}})},pO=function(a,b,c,d,e){const f=_.O,g=f.aa(e,"mediaPresentationDuration",TM),h=a.f?a.f.periods[a.f.periods.length-1]||null:null;var k=[];const l=[];var m=0;e=f.a(e,"Period");for(let v=0;v<e.length;v++){var n=e[v];m=f.aa(n,_.Qf,TM,m);var p=f.aa(n,vM,TM);let y=null;if(v!==e.length-1){var u=f.aa(e[v+1],_.Qf,TM);null!=u&&(y=u-m)}else null!=g&&(y=g-m);u=_.ou;y&&p&&Math.abs(y-p)>u&&a.g.warn("There is a gap/overlap between Periods",
|
|
48
|
+
n);null==y&&(y=p);n=rO(a,b,c,d,{start:m,duration:y,node:n,vi:null==y||v===e.length-1});p=n.Ja;l.push(p);k=k.concat(n.cues);a.G.includes(p.id)||(a.G.push(p.id),a.f&&(a.D.filterNewPeriod(p),a.f.periods.push(p)));if(null==y){v!==e.length-1&&a.g.warn("Skipping Period",v+1,"and any subsequent Periods:","Period",v+1,"does not have a valid start time.",l[v+1]);m=null;break}m+=y}null==a.f&&a.D.filterAllPeriods(l);h&&(b=l.find(v=>v.id===h.id))&&(h.endTime=b.endTime);k=sO(a,k);return null!=g?(m!==g&&a.g.warn("@mediaPresentationDuration does not match the total duration of ",
|
|
49
|
+
"all Periods."),{periods:l,duration:g,sg:!1,cues:k}):{periods:l,duration:m,sg:!0,cues:k}},qO=function(a){return a.map(b=>b.variants[0].video||b.variants[0].audio).reduce((b,c)=>c?c.getDuration():0+b,0)},rO=function(a,b,c,d,e){var f=_.O;b.Ja=tO(a,e.node,null,c,d);b.Za=e;c=b.Ja.id||`__clpp_period_${e.start}`;b.Ja.id||(a.g.info("No Period ID given for Period with start time "+e.start+`, Assigning a default: ${c}.`),b.Ja.id=c);d=f.a(e.node,"EventStream").flatMap(A=>uO(a,e.start,e.duration,A));f=f.a(e.node,
|
|
50
|
+
_.fa).map(A=>vO(a,b,A)).filter(_.Nm);if(b.cf){var g=[];for(var h of f)for(var k of h.Wi)g.push(k);if(g.length!==(new Set(g)).size)throw new _.I(_.D,4,4018);}h=f.filter(A=>!A.Qf);k=f.filter(A=>A.Qf);for(var l of k){l.streams.forEach(A=>{A.trickPlay=!0});k=l.streams[0];g=l.Qf;for(var m of h)if(g.includes(m.id))for(var n of m.streams)n.trickModeVideo=k}m=wO(f,_.t);n=wO(h,_.q);if(!m.length&&!n.length)throw new _.I(_.D,4,4004);n.length||(n=[null]);m.length||(m=[null]);l=[];for(var p of n)for(var u of m)xO(a,
|
|
51
51
|
p,u,l);u=[...wO(h,_.K),...wO(h,_.VA)];p=[];for(var v of u)p.push.apply(p,v.streams);u=wO(h,_.he);v=[];for(var y of u)v.push.apply(v,y.streams);y=yO(e,h);return{Ja:{id:c,configurationId:a.D.configurationId,startTime:e.start,endTime:y,textStreams:p,thumbStreams:v,variants:l},cues:d}},sO=function(a,b){const c=new Set(b.map(mN));a.j.forEach((d,e)=>{c.has(e)||a.j.delete(e)});b.forEach(d=>{const e=mN(d);a.j.has(e)||a.j.set(e,d)});return Array.from(a.j.values())},tO=function(a,b,c,d,e){const f=_.O;c=c||
|
|
52
|
-
{contentType:"",mimeType:"",codecs:"",emsgSchemeIdUris:[],frameRate:void 0,
|
|
53
|
-
h),Ha:e||c.Ha
|
|
54
|
-
m=d+m/h;null!=c&&(d=Math.min(d,b+c),m=Math.min(m,b+c));let p=_.mg;f.startsWith(_.og)?p=_.Hf:"urn:mpeg:dash:event:callback:2015"===f&&(p=_.Ge);const u={configurationId:a.D.configurationId,schemeIdUri:f,value:g,startTime:d,endTime:m,id:n.getAttribute("id")||"",type:p,eventElement:e.
|
|
55
|
-
b,c){var d=_.O;b.xa=tO(a,c,b.Ja,null,null);var e=b.xa.contentType===_.K;const f=BO(c),{kind:g,
|
|
56
|
-
kO(c[0].mimeType,c[0].codecs);for(const y of c)y.type=b.xa.contentType}for(const y of c)for(const A of u.drmInfos)y.keyId&&!A.keyIds.includes(y.keyId)&&A.keyIds.push(y.keyId);c=GO(c,b.xa.contentType,m);e=d.map(y=>y.getAttribute("id")).filter(_.Nm);return{id:b.xa.id||"__fake__"+a.h++,contentType:b.xa.contentType,language:p,originalLanguage:v,
|
|
57
|
-
c.drmInfos)){var e=_.JB(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.h++,language:b.language,primary:b.
|
|
52
|
+
{contentType:"",mimeType:"",codecs:"",emsgSchemeIdUris:[],frameRate:void 0,mf:null,Ha:e?e.find(u=>u.id===fM)||null:null};d=d||c.qa;var g=f.a(b,fM);const h=g.map(f.f);e=e?hO(g,e,b.getAttribute("id")||void 0):null;g=b.getAttribute("contentType")||c.contentType;const k=b.getAttribute(_.Ce)||c.mimeType,l=b.getAttribute(_.pd)||c.codecs,m=f.aa(b,"frameRate",YM)||c.frameRate,n=zO(f.a(b,"InbandEventStream"),c.emsgSchemeIdUris),p=f.a(b,"AudioChannelConfiguration");a=AO(a,p)||c.mf;g||(g=kO(k,l));return{qa:_.qB(d,
|
|
53
|
+
h),Ha:e||c.Ha,$d:f.h(b,"SegmentBase")||c.$d,tc:f.h(b,"SegmentList")||c.tc,uc:f.h(b,"SegmentTemplate")||c.uc,width:f.aa(b,_.Ng,XM)||c.width,height:f.aa(b,_.be,XM)||c.height,contentType:g,mimeType:k,codecs:l,frameRate:m,emsgSchemeIdUris:n,id:b.getAttribute("id")||"",mf:a}},uO=function(a,b,c,d){const e=_.O,f=d.getAttribute(CM)||"",g=d.getAttribute(_.vg)||"",h=e.aa(d,EM,XM)||1,k=e.aa(d,BM,XM)||0,l=[];for(const n of e.a(d,"Event")){d=e.aa(n,"presentationTime",XM)||0;var m=e.aa(n,vM,XM)||0;d=b+d/h-k/h;
|
|
54
|
+
m=d+m/h;null!=c&&(d=Math.min(d,b+c),m=Math.min(m,b+c));let p=_.mg;f.startsWith(_.og)?p=_.Hf:"urn:mpeg:dash:event:callback:2015"===f&&(p=_.Ge);const u={configurationId:a.D.configurationId,schemeIdUri:f,value:g,startTime:d,endTime:m,id:n.getAttribute("id")||"",type:p,eventElement:e.ce(n)};u.type===_.Ge&&(u.Ee=()=>{if(u.eventElement){var v=u.eventElement.getAttribute("messageData")||"";v&&v.startsWith("http")&&(v=_.zk(v),v.type=_.yk,a.D.networkingEngine.fetch(v))}});l.push(u)}return l},vO=function(a,
|
|
55
|
+
b,c){var d=_.O;b.xa=tO(a,c,b.Ja,null,null);var e=b.xa.contentType===_.K;const f=BO(c),{kind:g,Ud:h,roles:k}=CO(c,e);let l=null;try{l=DO(c)}catch(y){return null}const m=d.a(c,"Accessibility"),n=EO(m);var p=d.a(c,hM);const u=cO(p,a.a.ignoreDrmInfo,b.Ja.id,a.a.playreadyVersion||null),v=c.getAttribute("lang")||_.lg;p=_.Kn(v);d=d.a(c,_.nb);c=d.map(y=>FO(a,b,u,g,v,f||"",h,k,n,y)).filter(_.Nm);if(0===c.length){if(e)return null;throw new _.I(_.D,4,4003);}if(!b.xa.contentType||b.xa.contentType===uM){b.xa.contentType=
|
|
56
|
+
kO(c[0].mimeType,c[0].codecs);for(const y of c)y.type=b.xa.contentType}for(const y of c)for(const A of u.drmInfos)y.keyId&&!A.keyIds.includes(y.keyId)&&A.keyIds.push(y.keyId);c=GO(c,b.xa.contentType,m);e=d.map(y=>y.getAttribute("id")).filter(_.Nm);return{id:b.xa.id||"__fake__"+a.h++,contentType:b.xa.contentType,language:p,originalLanguage:v,Ud:h,streams:c,drmInfos:u.drmInfos,Qf:l,Wi:e}},wO=function(a,b){return a.filter(c=>c.contentType===b)},xO=function(a,b,c,d){if(b||c)if(b&&c){if(_.KB(b.drmInfos,
|
|
57
|
+
c.drmInfos)){var e=_.JB(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.h++,language:b.language,primary:b.Ud||c.Ud,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.h++,language:f.language||_.lg,primary:f.Ud,audio:b?e:null,video:c?e:null,bandwidth:g,drmInfos:f.drmInfos,allowedByApplication:!0,allowedByKeySystem:!0},d.push(g)}},
|
|
58
58
|
yO=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},BO=function(a){let b=null;const c=_.O.a(a,"Label").map(_.O.f).filter(_.Nm);c&&0<c.length&&(b=c[c.length-1]);null==b&&(b=a.getAttribute("label"));return b},CO=function(a,b){let c=!1;const d=_.O.a(a,"Role");a=d.map(f=>f.getAttribute(_.vg)).filter(_.Nm);let e=
|
|
59
|
-
void 0;b&&(e=_.VA);for(const f of d)if(b=f.getAttribute(CM),null==b||"urn:mpeg:dash:role:2011"===b||"urn:mpeg:dash:role"===b)switch(b=f.getAttribute(_.vg),b){case _.ue:c=!0;break;case _.GA:case _.VA:e=b;break;case "forced-subtitle":case "forced_subtitle":case _.Zd:e=_.Zd}return{
|
|
59
|
+
void 0;b&&(e=_.VA);for(const f of d)if(b=f.getAttribute(CM),null==b||"urn:mpeg:dash:role:2011"===b||"urn:mpeg:dash:role"===b)switch(b=f.getAttribute(_.vg),b){case _.ue:c=!0;break;case _.GA:case _.VA:e=b;break;case "forced-subtitle":case "forced_subtitle":case _.Zd:e=_.Zd}return{Ud:c,roles:a,kind:e}},DO=function(a){var b=_.O.a(a,jM);a=null;for(const c of b){b=c.getAttribute(CM)||"";const d=c.getAttribute(_.vg);if(b!==wM&&!HO.includes(b)||void 0===d)throw new _.tl("Unrecognized essential property");
|
|
60
60
|
b===wM&&(a=d.split(" "))}return a},EO=function(a){const b=new Map;for(const e of a)if(a=e.getAttribute(CM),"urn:scte:dash:cc:cea-608:2015"===a||"urn:scte:dash:cc:cea-708:2015"===a){a=1;var c=e.getAttribute(_.vg);if(null!=c)for(const f of c.split(";")){if(f.includes("\x3d")){var d=f.split("\x3d");c=d[0].startsWith("CC")?d[0]:"CC"+d[0];d=d[1].split(",")[0].split(":").pop()}else c="CC"+a,a+=2,d=f;b.set(c,_.Kn(d))}else b.set("CC1",_.lg)}return b},FO=function(a,b,c,d,e,f,g,h,k,l){const m=_.O,n=_.Kn(e);
|
|
61
|
-
b.O=tO(a,l,b.xa,null,null);if(!IO(a,b.O))return a.g.warn("Skipping Representation",b.O),null;b.hc=`${b.Ja.id} ${b.O.id}`;b.
|
|
61
|
+
b.O=tO(a,l,b.xa,null,null);if(!IO(a,b.O))return a.g.warn("Skipping Representation",b.O),null;b.hc=`${b.Ja.id} ${b.O.id}`;b.Sd=a.F.get(b.hc);b.bandwidth=m.aa(l,"bandwidth",WM)||0;const p=JO(a,b);if(!p)return null;a.F.set(b.hc,p.Ka);var u=m.a(l,hM);a=fO(u,c,a.a.ignoreDrmInfo,b.Ja.id,a.a.playreadyVersion||null);u=!1;m.a(l,"SupplementalProperty").some(v=>"tag:dolby.com,2018:dash:EC3_ExtensionType:2018"===v.getAttribute(CM)&&"JOC"===v.getAttribute(_.vg))&&(b.O.mimeType="audio/eac3-joc",u=!0);l=KO(b,l);
|
|
62
62
|
return{id:_.pI++,originalId:b.O.id,createSegmentIndex:p.createSegmentIndex,findSegmentPosition:p.findSegmentPosition,getSegmentReference:p.getSegmentReference,initSegmentReference:p.initSegmentReference,adjustSegmentDurations:p.adjustSegmentDurations,getLastSegmentEndTime:p.getLastSegmentEndTime,getDuration:p.getDuration,segmentLookupStrategy:_.LA,mimeType:b.O.mimeType,codecs:b.O.codecs,frameRate:b.O.frameRate,bandwidth:b.bandwidth,width:b.O.width,height:b.O.height,kind:d,encrypted:0<c.drmInfos.length,
|
|
63
|
-
keyId:a,language:n,originalLanguage:e,label:f,type:b.xa.contentType,primary:g,trickModeVideo:null,emsgSchemeIdUris:b.O.emsgSchemeIdUris,roles:h,channelsCount:b.O.
|
|
64
|
-
b;return a},IO=function(a,b){let c;c=b
|
|
65
|
-
b),b
|
|
63
|
+
keyId:a,language:n,originalLanguage:e,label:f,type:b.xa.contentType,primary:g,trickModeVideo:null,emsgSchemeIdUris:b.O.emsgSchemeIdUris,roles:h,channelsCount:b.O.mf,spatialAudio:u,closedCaptions:k,horizontalTiles:l.horizontalTiles,verticalTiles:l.verticalTiles,durationPerTile:l.durationPerTile}},GO=function(a,b,c){const d=b===_.VA?_.K:b;b=c.map(e=>({scheme:e.getAttribute(CM)||"",id:e.getAttribute("id")||void 0,value:e.getAttribute(_.vg)||"",protocol:"DASH",type:d}));for(const e of a)e.accessibility=
|
|
64
|
+
b;return a},IO=function(a,b){let c;c=b.$d?1:0;c+=b.tc?1:0;c+=b.uc?1:0;if(0===c){if(b.contentType===_.K||b.contentType===uM)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,","SegmentList, or SegmentTemplate.",
|
|
65
|
+
b),b.$d?(a.g.info("Using SegmentBase by default."),b.tc=null):a.g.info("Using SegmentList by default."),b.uc=null);return!0},JO=function(a,b){var c=b.O.contentType;c=c===_.K||c===uM;try{if(b.O.$d){{const E=Number(fN(b,AN,BM))||0,F=fN(b,AN,EM);var d=1;F&&(d=WM(F)||1);var e=E/d||0,f=zN(b,AN);{d=f;var g=e;const C=b.O.mimeType.split("/")[1];if(b.O.contentType!==_.K&&"mp4"!==C&&"webm"!==C)throw _.Dh("SegmentBase specifies an unsupported container type.",b.O),new _.I(_.D,4,4006);if("webm"===C&&!d)throw _.Dh(oM,
|
|
66
66
|
"the SegmentBase uses a WebM container,","but does not contain an Initialization element.",b.O),new _.I(_.D,4,4005);const ja=gN(b,AN,"RepresentationIndex"),Ca=fN(b,AN,"indexRange");let Xa=b.O.qa,Jb=UM(Ca||"");if(ja){const vb=ja.getAttribute("sourceURL");vb&&(Xa=_.qB(b.O.qa,[vb]));Jb=_.O.aa(ja,"range",UM,Jb)}if(!Jb)throw _.Dh(oM,"the SegmentBase does not contain @indexRange","or a RepresentationIndex element.",b.O),new _.I(_.D,4,4002);QM(b.O.contentType)&&(b.presentationTimeline.B=null);var h=CN(b,
|
|
67
67
|
d,Xa,Jb.start,Jb.end,C,g)}var k={createSegmentIndex:h.createSegmentIndex,findSegmentPosition:h.findSegmentPosition,getSegmentReference:h.getSegmentReference,adjustSegmentDurations:h.adjustSegmentDurations,getDuration:h.getDuration,initSegmentReference:f,getLastSegmentEndTime:h.getLastSegmentEndTime,Ka:e}}}else{if(b.O.tc){{var l=a.H;const E=zN(b,QN);{const ja=RN(b),Ca=iN(b,QN);let Xa=Ca.Pc;0===Xa&&(_.B("SegmentList@startNumber must be \x3e 0"),Xa=1);h=0;Ca.$a?h=Ca.$a*(Xa-1):Ca.wa&&0<Ca.wa.a&&(h=Ca.wa.j);
|
|
68
68
|
var m={$a:Ca.$a,startTime:h,Pc:Xa,Sb:Ca.Sb,wa:Ca.wa,Nc:ja}}if(!m.$a&&!m.wa&&1<m.Nc.length)throw _.B(pM,"the SegmentList specifies multiple segments,","but does not specify a segment duration or timeline.",b.O),new _.I(_.D,4,4002);if(!m.$a&&!b.Za.duration&&!m.wa&&1===m.Nc.length)throw _.B(pM,"the SegmentList specifies one segment,","but does not specify a segment duration, period duration,","or timeline.",b.O),new _.I(_.D,4,4002);if(m.wa&&0===m.wa.a)throw _.B(pM,"the SegmentList has an empty timeline.",
|
|
69
69
|
b.O),new _.I(_.D,4,4002);{let ja=m.Nc.length;m.wa&&m.wa.a!==m.Nc.length&&(ja=Math.min(m.wa.a,m.Nc.length),_.B("The number of items in the segment timeline and the number of","segment URLs do not match, truncating",m.Nc.length,"to",ja));var n=ja}const F=new LO(m,b.O.qa,b.O.Ha,b.Za.duration,n),C=MN(b,F,l);if(QM(b.O.contentType)){const ja=GN(C);ja&&lN(b,ja)}d={createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:C.findSegmentPosition.bind(C),getSegmentReference:C.getSegmentReference.bind(C),
|
|
70
|
-
adjustSegmentDurations:C.adjustSegmentDurations.bind(C),getDuration:C.getDuration.bind(C),initSegmentReference:E,getLastSegmentEndTime:C.getLastSegmentEndTime.bind(C),Ka:m.Sb}}}else{if(b.O.uc){{var p=a.H,u=!!a.f;const E=ON(b);{const C=iN(b,NN),ja=fN(b,NN,"media"),Ca=fN(b,NN,"index");e={$a:C.$a,timescale:C.timescale,Pc:C.Pc,
|
|
71
|
-
"a SegmentTimeline, or a segment duration.",b.O),new _.I(_.D,4,4002);1!==C&&(_.B("SegmentTemplate contains multiple segment information sources:","the SegmentTemplate should only contain an index URL template,","a SegmentTimeline or a segment duration.",b.O),e.
|
|
72
|
-
QM(b.O.contentType);h=null;if(e.
|
|
73
|
-
F){b.presentationTimeline.B=null;var v=b.presentationTimeline;v.G=Math.max(v.G,e.
|
|
70
|
+
adjustSegmentDurations:C.adjustSegmentDurations.bind(C),getDuration:C.getDuration.bind(C),initSegmentReference:E,getLastSegmentEndTime:C.getLastSegmentEndTime.bind(C),Ka:m.Sb}}}else{if(b.O.uc){{var p=a.H,u=!!a.f;const E=ON(b);{const C=iN(b,NN),ja=fN(b,NN,"media"),Ca=fN(b,NN,"index");e={$a:C.$a,timescale:C.timescale,Pc:C.Pc,df:C.df,Sb:C.Sb,Sf:C.Sf,wa:C.wa,lf:ja,Pd:Ca,Xe:C.Xe}}{let C;C=e.Pd?1:0;C+=e.wa?1:0;C+=e.$a?1:0;if(0===C)throw _.Dh("SegmentTemplate does not contain any segment information:","the SegmentTemplate must contain either an index URL template",
|
|
71
|
+
"a SegmentTimeline, or a segment duration.",b.O),new _.I(_.D,4,4002);1!==C&&(_.B("SegmentTemplate contains multiple segment information sources:","the SegmentTemplate should only contain an index URL template,","a SegmentTimeline or a segment duration.",b.O),e.Pd?(_.Bh("Using the index URL template by default."),e.wa=null):_.Bh("Using the SegmentTimeline by default."),e.$a=null);if(!e.Pd&&!e.lf)throw _.Dh(qM,"the SegmentTemplate's media URL template is missing.",b.O),new _.I(_.D,4,4002);}const F=
|
|
72
|
+
QM(b.O.contentType);h=null;if(e.Pd){F&&(b.presentationTimeline.B=null);{f=E;const C=b.O.mimeType.split("/")[1];if("mp4"!==C&&"webm"!==C)throw _.Dh("SegmentTemplate specifies an unsupported container type.",b.O),new _.I(_.D,4,4006);if("webm"===C&&!f)throw _.Dh(qM,"the SegmentTemplate uses a WebM container,","but does not contain an initialization URL template.",b.O),new _.I(_.D,4,4005);const ja=eN(e.Pd,b.O.id,null,b.bandwidth||null,null),Ca=_.qB(b.O.qa,[ja]);h=CN(b,f,Ca,0,null,C,e.Sb)}}else if(e.$a){if(!u&&
|
|
73
|
+
F){b.presentationTimeline.B=null;var v=b.presentationTimeline;v.G=Math.max(v.G,e.Xe);v.g.debug("notifyAvailabilityTimeOffset: maxAvailabilityTimeOffset\x3d"+v.G);_.mC(b.presentationTimeline,e.$a);var y=b.presentationTimeline,A=b.Za.start;y.l=null==y.l?A:Math.min(y.l,A)}h=PN(b,e)}else{const C=MN(b,new MO(e,b.O.id,b.bandwidth||null,b.O.qa,b.O.Ha),p);if(F){const ja=GN(C);ja&&lN(b,ja)}h={createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:C.findSegmentPosition.bind(C),getSegmentReference:C.getSegmentReference.bind(C),
|
|
74
74
|
adjustSegmentDurations:C.adjustSegmentDurations.bind(C),getDuration:C.getDuration.bind(C),getLastSegmentEndTime:C.getLastSegmentEndTime.bind(C)}}g={createSegmentIndex:h.createSegmentIndex,findSegmentPosition:h.findSegmentPosition,getSegmentReference:h.getSegmentReference,adjustSegmentDurations:h.adjustSegmentDurations,getDuration:h.getDuration,initSegmentReference:E,getLastSegmentEndTime:h.getLastSegmentEndTime,Ka:e.Sb}}}else g=NO(b);d=g}k=d}return k}catch(E){if(c&&4002===E.code)return a.g.debug("Ignoring DASH_NO_SEGMENT_INFO error in a text stream",
|
|
75
|
-
E),null;throw E;}},KO=function(a,b){const c={};if(a.O.contentType===_.he){var d=(b=_.O.h(b,jM))&&b.getAttribute(CM);d=d||"";OO.includes(d)&&(b=_.DB(b.getAttribute(_.vg)||""))&&(c.horizontalTiles=b.
|
|
75
|
+
E),null;throw E;}},KO=function(a,b){const c={};if(a.O.contentType===_.he){var d=(b=_.O.h(b,jM))&&b.getAttribute(CM);d=d||"";OO.includes(d)&&(b=_.DB(b.getAttribute(_.vg)||""))&&(c.horizontalTiles=b.Md,c.verticalTiles=b.ee,a.xa.uc&&(d=_.O.aa(a.xa.uc,vM,XM)||0,a=_.O.aa(a.xa.uc,EM,XM)||1,a=d/a))&&(c.durationPerTile=a/b.kj)}return c},NO=function(a){const b=a.O.qa,c=a.Za.duration||0,d=()=>c;return{createSegmentIndex:()=>Promise.resolve(),findSegmentPosition:e=>0<=e&&e<c?1:null,getSegmentReference:e=>1!==
|
|
76
76
|
e?null:new _.rI(1,0,c,()=>b,0,null,0,null,null,null,null,null,null,null,null,()=>"",a.O.Ha),adjustSegmentDurations:()=>{},getDuration:d,getLastSegmentEndTime:d,verticalTiles:void 0,horizontalTiles:void 0,initSegmentReference:null,Ka:0}},zO=function(a,b){b=b.slice();for(const c of a)(a=c.getAttribute(CM))&&!b.includes(a)&&b.push(a);return b},AO=function(a,b){for(const d of b){b=d.getAttribute(CM);if(!b)continue;const e=d.getAttribute(_.vg);if(e)switch(b){case "urn:mpeg:dash:outputChannelPositionList:2012":return e.trim().split(/ +/).length;
|
|
77
|
-
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(gM,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(gM,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};_.hv.prototype.
|
|
78
|
-
_.HB.prototype.
|
|
79
|
-
_.hv.prototype.
|
|
80
|
-
_.HB.prototype.
|
|
81
|
-
_.HB.prototype.Vc=KM(8,function(){return new _.FB("NULL",null,{},[],null,null,new Map)});_.hv.prototype.
|
|
77
|
+
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(gM,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(gM,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};_.hv.prototype.ce=KM(19,function(a){return a});
|
|
78
|
+
_.HB.prototype.ce=KM(18,function(a){const b=Array.from(a.a.entries()).map(([d,e])=>`xmlns:${e}="${d}"`).join(" "),c=(new DOMParser).parseFromString(`<?xml version="1.0"?><${a.tagName} `+`${b}/>`,_.ag).childNodes[0];Object.keys(a.attributes).forEach(d=>{c.setAttribute(d,a.attributes[d])});a.childNodes.forEach(d=>{d.tagName===_.da?c.textContent+=d.textContent:c.appendChild(this.ce(d))});return c});
|
|
79
|
+
_.hv.prototype.Le=KM(17,function(a,b){Array.from(a.attributes).forEach(c=>{c.namespaceURI===b&&a.removeAttributeNS(c.namespaceURI,c.localName)})});_.HB.prototype.Le=KM(16,function(a,b){if(b=a.a.get(b)){var c=`${b}:`;Object.keys(a.attributes).forEach(d=>{d.startsWith(c)&&delete a.attributes[d]})}});_.hv.prototype.Ae=KM(15,function(a,b){for(const c of a.attributes)b.setAttributeNS(c.namespaceURI,c.nodeName,c.value)});
|
|
80
|
+
_.HB.prototype.Ae=KM(14,function(a,b){Object.keys(a.attributes).forEach(c=>{b.attributes[c]=a.attributes[c]})});_.hv.prototype.Be=KM(13,function(a,b){Array.from(a.childNodes).forEach(c=>{a.removeChild(c);b.appendChild(c)})});_.HB.prototype.Be=KM(12,function(a,b){b.childNodes.push(...a.childNodes);a.childNodes=[]});_.hv.prototype.Ke=KM(11,function(a){Array.from(a.childNodes).forEach(b=>{a.removeChild(b)})});_.HB.prototype.Ke=KM(10,function(a){a.childNodes=[]});_.hv.prototype.Vc=KM(9,function(){return document.createElement("null")});
|
|
81
|
+
_.HB.prototype.Vc=KM(8,function(){return new _.FB("NULL",null,{},[],null,null,new Map)});_.hv.prototype.we=KM(7,function(a){return Array.from(a.childNodes).filter(b=>b instanceof Element)});_.HB.prototype.we=KM(6,function(a){return a.childNodes});_.hv.prototype.aa=KM(5,function(a,b,c,d=null){let e=null;a=a.getAttribute(b);null!=a&&(e=c(a));return null==e?d:e});_.HB.prototype.aa=KM(4,function(a,b,c,d=null){let e=null;a=a.getAttribute(b);null!=a&&(e=c(a));return null==e?d:e});
|
|
82
82
|
_.hv.prototype.Ec=KM(3,function(a,b,c){return Array.from(a.childNodes).filter(d=>d instanceof Element&&d.localName===c&&d.namespaceURI===b)});_.HB.prototype.Ec=KM(2,function(a,b,c){b=a.a.get(b);if(!b)return[];const d=`${b}:${c}`;return a.childNodes.filter(e=>e.tagName===d)});_.hv.prototype.Wb=KM(1,function(a,b,c){a=this.Ec(a,b,c);return 1!==a.length?null:a[0]});_.HB.prototype.Wb=KM(0,function(a,b,c){a=this.Ec(a,b,c);return 1!==a.length?null:a[0]});var LO=class{constructor(a,b,c,d,e){this.l=a.Pc;this.j=e;this.I=a.Nc;this.a=a.startTime;this.h=a.$a;this.f=a.wa;this.H=a.Sb;this.G=b;this.F=c;this.A=d;this.g=new _.T("clpp.dash.SegmentListSource")}o(){return this.j}w(){return this.l}B(a){a=aN(this,a);return null==a?null:null!=this.h?(a=this.a+a*this.h,{startTime:a,endTime:a+this.h}):this.f?(a=cN(this.f,a),{startTime:a.startTime,endTime:a.endTime}):null==this.A?(this.g.warn(iM),null):{startTime:this.a,endTime:this.a+this.A}}findSegmentPosition(a){return 0<
|
|
83
|
-
this.j?a<this.a?this.l:null!=this.h?(a=this.l+Math.floor((a-this.a)/this.h),a>this.l+this.j-1?null:a):this.f?(a=dN(this.f,a),null==a?null:this.l+a):null==this.A?(this.g.warn(iM),null):a<this.a+this.A?this.l:null:null}getSegmentReference(a,b){const c=aN(this,a);if(null==c)return null;b=null==b?a:b;a=this.B(a);if(null==a)return null;const d=this.I[c],e=_.qB(this.G,[d.
|
|
84
|
-
this.j?null!=this.h?{pc:this.a,ac:this.a+this.j*this.h,bc:this.h}:this.f?{pc:cN(this.f,0).startTime,ac:cN(this.f,this.j-1).endTime,bc:this.f.h}:null==this.A?null:{pc:this.a,ac:this.a+this.A,bc:this.A}:null}};var hN=class{constructor(a){this.f=a;this.a=a.reduce((b,c)=>b+c.count,0);this.j=0<this.a?a[0].startTime:0;this.h=bN(a)}};var OO=["http://dashif.org/thumbnail_tile","http://dashif.org/guidelines/thumbnail_tile"],HO=["urn:mpeg:mpegB:cicp:ColourPrimaries","urn:mpeg:mpegB:cicp:MatrixCoefficients","urn:mpeg:mpegB:cicp:TransferCharacteristics"];var MO=class{constructor(a,b,c,d,e){const f=a.wa;this.h=a.Pc;this.f=f.a;this.a=f;this.G=a.
|
|
83
|
+
this.j?a<this.a?this.l:null!=this.h?(a=this.l+Math.floor((a-this.a)/this.h),a>this.l+this.j-1?null:a):this.f?(a=dN(this.f,a),null==a?null:this.l+a):null==this.A?(this.g.warn(iM),null):a<this.a+this.A?this.l:null:null}getSegmentReference(a,b){const c=aN(this,a);if(null==c)return null;b=null==b?a:b;a=this.B(a);if(null==a)return null;const d=this.I[c],e=_.qB(this.G,[d.Mg]);return new _.rI(b,a.startTime,a.endTime,()=>e,d.start,d.end,this.H,null,null,null,null,null,null,null,null,()=>d.Mg,this.F)}C(){return 0<
|
|
84
|
+
this.j?null!=this.h?{pc:this.a,ac:this.a+this.j*this.h,bc:this.h}:this.f?{pc:cN(this.f,0).startTime,ac:cN(this.f,this.j-1).endTime,bc:this.f.h}:null==this.A?null:{pc:this.a,ac:this.a+this.A,bc:this.A}:null}};var hN=class{constructor(a){this.f=a;this.a=a.reduce((b,c)=>b+c.count,0);this.j=0<this.a?a[0].startTime:0;this.h=bN(a)}};var OO=["http://dashif.org/thumbnail_tile","http://dashif.org/guidelines/thumbnail_tile"],HO=["urn:mpeg:mpegB:cicp:ColourPrimaries","urn:mpeg:mpegB:cicp:MatrixCoefficients","urn:mpeg:mpegB:cicp:TransferCharacteristics"];var MO=class{constructor(a,b,c,d,e){const f=a.wa;this.h=a.Pc;this.f=f.a;this.a=f;this.G=a.lf;this.H=b;this.j=c;this.A=d;this.l=e;this.F=a.Sb;this.I=a.Sf}o(){return this.f}w(){return this.h}B(a){a=oN(this,a);if(null==a)return null;a=cN(this.a,a);return{startTime:a.startTime,endTime:a.endTime}}findSegmentPosition(a){if(!(0<this.f))return null;a=dN(this.a,a);return null==a?null:this.h+a}getSegmentReference(a,b){var c=oN(this,a);if(null==c)return null;b=null==b?a:b;c=cN(this.a,c);const d=c.rj+this.I,
|
|
85
85
|
e=()=>eN(this.G,this.H,a,this.j,d);return new _.rI(b,c.startTime,c.endTime,()=>{const f=e();return _.qB(this.A,[f])},0,null,this.F,null,null,null,null,null,null,null,null,e,this.l)}C(){return 0<this.f?{pc:cN(this.a,0).startTime,ac:cN(this.a,this.f-1).endTime,bc:this.a.h}:null}};var wN=class{constructor(a){this.f=a;this.a=new _.kq(a,!1)}},sN=[[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]],tN=class{constructor(a,b){this.id=a;this.a=b}};var BN=class{parse(a,b,c,d){var e;b=new wN(new DataView(b));if(440786851!==uN(b).id)throw _.Dh("Not an EBML element."),new _.I(_.D,3,3008);var f=uN(b);if(408125543!==f.id)throw _.Dh("Not a Segment element."),new _.I(_.D,3,3009);b=f.a.byteOffset;f=new wN(f.a);for(e=null;_.Xo(f.a);){var g=uN(f);if(357149030===g.id){e=g;break}}if(!e)throw _.Dh("Not an Info element."),new _.I(_.D,3,3010);e=new wN(e.a);g=1E6;for(f=null;_.Xo(e.a);){const h=uN(e);if(2807729===h.id)g=vN(h);else if(17545===h.id)if(f=h,4===
|
|
86
86
|
f.a.byteLength)f=f.a.getFloat32(0);else if(8===f.a.byteLength)f=f.a.getFloat64(0);else throw new _.I(_.D,3,3003);}if(null==f)throw new _.I(_.D,3,3011);e=g/=1E9;f*=g;a=uN(new wN(new DataView(a)));if(475249515!==a.id)throw _.Dh("Not a Cues element."),new _.I(_.D,3,3007);return yN(a,b,e,f,c,d)}};var LN=class{constructor(a){this.a=a;this.f=0;this.l=0<a.o()?a.w():0;this.h=[];this.j=null;this.g=new _.T("clpp.dash.SegmentSourceAdapter")}findSegmentPosition(a){const b=DN(this);if(!b)return null;if(!(0<this.h.length||null!=this.j))return a=this.a.findSegmentPosition(a),null==a||a>b.Zb?null:a<b.Kb?b.Kb+this.f:a+this.f;for(var c=b.Zb;c>=b.Kb;c--){const d=EN(this,c);if(a>=d.startTime&&a<d.endTime)return c+this.f}c=EN(this,b.Kb);return a<c.startTime?b.Kb+this.f:null}getSegmentReference(a){var b=a-
|
|
87
|
-
this.f;if(!FN(this,b))return null;a=this.a.getSegmentReference(b,a);if(!a)return null;b=EN(this,b);return new _.rI(a.position,b.startTime,b.endTime,a.Da,a.na,a.ja,a.Ka,a.keyInfo,a.Xc,a.timescale,a.horizontalTiles,a.verticalTiles,a.durationPerTile,a.a,a.initSegment,a.cd,a.Ha)}adjustSegmentDurations(a,b){if(FN(this,a-this.f)){this.g.warn(`Adjusting segment duration by drift ${b} at ${a}`);var c=this.h.find(d=>d.position===a);c?c.
|
|
87
|
+
this.f;if(!FN(this,b))return null;a=this.a.getSegmentReference(b,a);if(!a)return null;b=EN(this,b);return new _.rI(a.position,b.startTime,b.endTime,a.Da,a.na,a.ja,a.Ka,a.keyInfo,a.Xc,a.timescale,a.horizontalTiles,a.verticalTiles,a.durationPerTile,a.a,a.initSegment,a.cd,a.Ha)}adjustSegmentDurations(a,b){if(FN(this,a-this.f)){this.g.warn(`Adjusting segment duration by drift ${b} at ${a}`);var c=this.h.find(d=>d.position===a);c?c.re+=b:this.h.push({position:a,re:b})}}getDuration(){const a=DN(this);if(!a)return 0;
|
|
88
88
|
const b=EN(this,a.Kb);return EN(this,a.Zb).endTime-b.startTime}getLastSegmentEndTime(){const a=DN(this);return a?EN(this,a.Zb).endTime:0}};var PO=class{constructor(a,b){this.g=a;this.f=b;this.a={clockSyncUri:void 0}}};var VN=(new Map).set("urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",_.Re).set(JM,_.wd).set(IM,_.ud).set("urn:uuid:79f0049a-4098-8642-ab92-e65be0885f95",_.ud).set("urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2",_.sd).set("urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb",_.rd),eO=(new Map).set(_.wd,function(a){const b=gO(a);if(b)return{licenseUrl:b,origin:_.JA};if(a=_.O.Wb(a.node,"urn:microsoft","laurl"))if(a=a.getAttribute("licenseUrl"))return{licenseUrl:a,origin:"ms:laurl"};return null}).set(_.ud,
|
|
89
89
|
function(a){var b=_.O;const c=gO(a);if(c)return{licenseUrl:c,origin:_.JA};a=b.Wb(a.node,FM,"pro");if(!a)return null;b=b.f(a);if(!b)return null;b=_.em(b);return(b=_.rq(b).h)?{licenseUrl:b,origin:"mspr:pro"}:null}),XN=new _.T("clpp.dash.ContentProtection");var QO=class{constructor(){this.D=this.a=null;this.o=[];this.f=null;this.G=[];this.h=1;this.H={};this.l=0;this.I=new _.sI(5);this.B=new _.Pi(()=>{this.dc()});this.A=new _.ju;this.j=new Map;this.g=new _.T("clpp.dash.DashParser");this.C=null;this.J=new PO(this.g,(a,b)=>{a=_.zk(a,this.a.attemptParameters);a.type=5;a.method=b;b=this.D.networkingEngine.fetch(a);_.Jl(this.A,b);return b.V});this.F=new Map;this.K=!1;this.w=null}configure(a){this.a=a;this.J.a={clockSyncUri:a.clockSyncUri}}start(a,b){const c=
|
|
90
90
|
this;return _.w(function*(){c.o=[a];c.D=b;const d=yield mO(c);c.D&&nO(c,d);if(!c.D)throw new _.I(_.D,7,7001);return c.f})}requestStop(){this.K=!0}stop(){this.a=this.D=null;this.o=[];this.f=null;this.G=[];this.H={};this.C=null;this.l=-1;this.B.stop();this.F.clear();this.j.clear();return this.A.destroy()}update(){mO(this).catch(a=>{if(this.D&&a)this.D.onError(a)})}setCurrentVariant(){}dc(){const a=this;return _.w(function*(){a.g.debug(_.BA);let b=0;try{b=yield mO(a)}catch(c){if(a.D&&c.a&&(a.D.onError(c),
|
package/cl.freewheel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var dU="clpp-freewheel",eU="clpp.freewheel.AdsManagerFactory",fU="freewheel",gU=function(a){switch(a){case 0:return tv.freewheel.SDK.ADUNIT_PREROLL;case 1:return tv.freewheel.SDK.ADUNIT_MIDROLL;case 2:return tv.freewheel.SDK.ADUNIT_POSTROLL;default:return""}},hU=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Uf&&b.push("serverUrl");typeof a.profileId!==_.Uf&&b.push("profileId");typeof a.videoAssetId!==_.Uf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
|
|
2
2
|
if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},iU=function(){return _.w(function*(){var a=new _.Kv;let b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_NONE;const c=yield a.canPlay(!1);a=yield a.canPlay(!0);c?b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED:a&&(b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED);return b})},jU=function(a){a.l.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.U.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.X.bind(a));a.l.on(a.a,
|
|
3
|
-
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.W.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_AD,a.S.bind(a));a.l.on(a.m,_.gg,a.R.bind(a));a.l.on(a.m,_.Rf,a.P.bind(a))},kU=function(a){const b=a.m.
|
|
3
|
+
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.W.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_AD,a.S.bind(a));a.l.on(a.m,_.gg,a.R.bind(a));a.l.on(a.m,_.Rf,a.P.bind(a))},kU=function(a){const b=a.m.Hd(fU).$c();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},lU=function(a){const b=a.m.Hd(fU).$c();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(dU),a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},mU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||
|
|
4
4
|
c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.H(b,d))},nU=class extends _.Uv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Fi(_.Fd,{id:dU}),this.f=_.Fi(_.t,{"class":_.ad}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),
|
|
5
|
-
this.f=this.a=null)}id(){return fU}$c(){return this.a}
|
|
5
|
+
this.f=this.a=null)}id(){return fU}$c(){return this.a}bi(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",nU);nU.prototype.getAdVideo=nU.prototype.bi;nU.prototype.getAdContainer=nU.prototype.$c;nU.Id=fU;nU.AD_CONTAINER_ID=dU;var oU=class{create(){return new nU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}eb(){return"FreeWheel AdManager SDK"}fb(){return tv.freewheel.SDK.version}hb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Uf?a:""}zb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
|
|
6
6
|
0}getPosition(){return 0}getSkipTimeOffset(){return 0}Bb(){return!1}Ra(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}Va(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}Ua(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Ba(){return 0}Ca(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
|
|
7
7
|
case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Ca()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}pb(){switch(this.Ca()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}gb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}Wa(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Ab(){return null}};
|
|
8
8
|
X.prototype.getVideoElement=X.prototype.Ab;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.Wa;X.prototype.getPositionInSequence=X.prototype.gb;X.prototype.getPodTimeOffset=X.prototype.pb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Ca;
|
|
@@ -12,7 +12,7 @@ pU.prototype.hasPostroll=pU.prototype.Pb;pU.prototype.hasPreroll=pU.prototype.Qb
|
|
|
12
12
|
typeof b.siteSectionId!==_.Uf&&typeof b.siteSectionId!==_.r||a.a.setSiteSection(b.siteSectionId);const c=yield iU();a.a.setVideoAsset(b.videoAssetId,a.m.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,gU(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ie&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,
|
|
13
13
|
!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);jU(a);a.a.submitRequest();return a.H})}j(){if(this.M.length){lU(this);this.f=this.M.shift();this.f.play();var a=!1}else this.f?(this.f.resume(),a=!1):(kU(this),a=!0);return a}A(){}jb(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getAdVolume(){return!this.a||this.C?this.G:this.a.getAdVolume()}h(a){this.G=a;this.C||this.a&&this.a.setAdVolume(a)}setMuted(a){this.C=
|
|
14
14
|
a;this.a&&(a?this.a.setAdVolume(0):this.a.setAdVolume(this.G))}isMuted(){return this.C}qb(){return this.J}isPaused(){return this.F}getPosition(){return this.f?this.f.getPlayheadTime():-1}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.jb()}resume(){this.j()}w(){return!0}o(){const a=this;return _.w(function*(){a.l.release();a.B&&(a.B.stop(),a.B=null);kU(a);a.a&&(a.a.dispose(),a.a=null)})}U(a){if(a.success)this.M=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),
|
|
15
|
-
this.I=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.L=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.qc,{adsTimeline:new pU(this.a)})),this.B=new _.Iv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.
|
|
15
|
+
this.I=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.L=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.qc,{adsTimeline:new pU(this.a)})),this.B=new _.Iv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.Hd(fU).f);else this.m.onError(new _.I(1,9,10003,{errorType:0},void 0));this.H.resolve()}X(a){mU(this,_.Ub,a);this.B.start()}W(a){this.f=null;a=a.slot;mU(this,_.Vb);this.B.stop();kU(this);a&&a.getTimePositionClass()===
|
|
16
16
|
tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL||this.m.play()}S(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:this.setMuted(this.C);this.h(this.G);this.J=!0;this.F=!1;mU(this,_.mc,a);mU(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:mU(this,_.nc,a);this.F=this.J=!1;break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:mU(this,_.Zb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:mU(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:mU(this,
|
|
17
17
|
_.oc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:mU(this,_.Yb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:mU(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:this.F=!0;mU(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:this.F=!1;mU(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:mU(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:mU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:mU(this,_.jc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,
|
|
18
18
|
9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}R(){if(!this.f){var a=this.m.getPosition();if(this.f=this.I.find(b=>.5>Math.abs(a-b.getTimePosition()))||null){const b=this.I.findIndex(c=>c===this.f);this.I.splice(b,1);this.m.pause();lU(this);this.f.play()}}}P(a){if((a=a.detail)&&this.a)switch(a.currentState){case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;
|
package/cl.hls.js
CHANGED
|
@@ -3,20 +3,20 @@ import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._
|
|
|
3
3
|
for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.Ie&&typeof d===_.Ie){if(gJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},hJ=function(a){if(null!==a&&void 0!==a)return Number(a)},iJ=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},jJ=function(a){return new Uint8Array([a>>
|
|
4
4
|
24&255,a>>16&255,a>>8&255,a&255])},kJ=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},lJ=function(a,b){return a.filter(c=>c.name===b)},mJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.L(d,"VALUE"),f=_.L(d,_.Ta),g=_.L(d,"IMPORT"),h=_.L(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.D,4,4044,{message:"Invalid tag.",text:d.toString()});
|
|
5
5
|
d=f||g||h;if(c.has(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},nJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=cJ(d,_.tb);return c.includes(d)})},oJ=function(a,b){return a.some(c=>c.name===b)},pJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.D,4,4024,{missingTag:b});return a},qJ=function(a){var b=pJ(a,
|
|
6
|
-
"EXT-X-TILES");if(!b)return{
|
|
6
|
+
"EXT-X-TILES");if(!b)return{Md:1,ee:1,durationPerTile:null};a=_.L(b,"LAYOUT")||"1x1";b=_.L(b,LI);a=_.DB(a);return{Md:a.Md,ee:a.ee,durationPerTile:b?Number(b):null}},rJ=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},sJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of rJ(c))b(d,c)})},tJ=function(a){return a.some(b=>oJ(b.ba,"EXT-X-ENDLIST"))},
|
|
7
7
|
uJ=function(a){return a.type===_.q||a.type===_.t},vJ=function(a){if(pJ(a,"EXT-X-ENDLIST"))return _.Fb;a=pJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Fb)return _.Fb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.D,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},wJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.K,"CLOSED-CAPTIONS":_.K}[a.toUpperCase()];if(!a)throw new _.I(_.D,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},xJ=function(a,b,c){c=void 0===
|
|
8
8
|
c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.D,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.D,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.D,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.D,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{na:d,ja:e}},yJ=function(a,b){a=pJ(a,"EXT-X-BYTERANGE");
|
|
9
|
-
return xJ(a?a.value:null,b)},zJ=function(a){a=pJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},AJ=function(a,b){b=void 0===b?{}:b;const c={
|
|
10
|
-
c.
|
|
11
|
-
const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{nd:b,duration:c}},GJ=function(a){return a.map(b=>{({duration:b}=FJ(b));return b}).reduce((b,c)=>b+c,0)},HJ=function(a){return(a.video?a.video.bb:"")+" - "+(a.audio?a.audio.bb:"")},IJ=function(a,b,c,d,e){if(b===_.Fb)return{delay:0,
|
|
12
|
-
a=Number(a.value);e=e||a;return null!=d?{delay:d,
|
|
13
|
-
e.schemeIdUri,h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.lv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,
|
|
9
|
+
return xJ(a?a.value:null,b)},zJ=function(a){a=pJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},AJ=function(a,b){b=void 0===b?{}:b;const c={kg:!1,Mh:!1,Nh:null,pi:null,Vg:null};a=pJ(a,"EXT-X-SERVER-CONTROL",{required:b.dh});if(!a)return c;const d=e=>null==e?null:Number(e);c.kg="YES"===_.L(a,"CAN-BLOCK-RELOAD");c.Mh="YES"===_.L(a,"CAN-SKIP-DATERANGES");c.Nh=d(_.L(a,"CAN-SKIP-UNTIL"));
|
|
10
|
+
c.pi=d(_.L(a,"HOLD-BACK"));c.Vg=d(_.L(a,"PART-HOLD-BACK",void 0,{required:b.dh}));return c},BJ=function(a,b,c){c=void 0===c?!1:c;a=_.L(a,"BYTERANGE");return xJ(a,b,c)},CJ=function(a){const b=lJ(a,QI),c=lJ(a,TI);a=lJ(a,"EXT-X-IMAGE-STREAM-INF");return{Oc:{eg:nJ(b,[_.pA,_.Eb]),closedCaptions:nJ(b,JI),jj:nJ(b,YI)},fe:c,ff:a}},EJ=function(a,b){const c=yJ(a.ba,null);return new DJ(0,0,0,()=>[a.a],c.na,c.ja,0,b)},FJ=function(a){let b=Infinity,c=Infinity;rJ(a).filter(uJ).forEach(d=>{{d=d.T;var e=d[0].startTime;
|
|
11
|
+
const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{nd:b,duration:c}},GJ=function(a){return a.map(b=>{({duration:b}=FJ(b));return b}).reduce((b,c)=>b+c,0)},HJ=function(a){return(a.video?a.video.bb:"")+" - "+(a.audio?a.audio.bb:"")},IJ=function(a,b,c,d,e){if(b===_.Fb)return{delay:0,de:0};b=pJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(cJ(b,"PART-TARGET"));if(null!=d)return{delay:d,de:e};({Vg:d}=AJ(a,{dh:!0}));return{delay:d,de:e}}a=pJ(a,"EXT-X-TARGETDURATION",{required:!0});
|
|
12
|
+
a=Number(a.value);e=e||a;return null!=d?{delay:d,de:e}:{delay:3*a,de:e}},JJ=function(a){const b=new Map;a.forEach(c=>{var d=`${c.Hc()}:${c.streams[0].groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},KJ=function(a){const b=new Map;for(const c of a){a=_.L(c,_.La);a=_.Kn(a||_.lg);const d=cJ(c,_.Fa),e=cJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},LJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},MJ=function(a,b,c,d,e){var f=e&&e.be,g=e&&
|
|
13
|
+
e.schemeIdUri,h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.lv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,be:f};f=hJ(_.L(a,LI));void 0!==f&&0<=f&&(h.duration=f);f=hJ(_.L(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.L(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.L(a,"END-DATE"))?new Date(f):
|
|
14
14
|
null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.kh(d)?d:null}k=k||{};(d=_.L(a,"CUE"))&&(k.CUE=d.split(","));if(_.jk(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Ob:d[_.Ob]=l.value;break;case _.Nb:d[_.Nb]=l.value;break;case _.Sb:d[_.Sb]=hJ(l.value);break;case _.Qb:d[_.Qb]=hJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;
|
|
15
15
|
case _.Rb:d[_.Rb]=l.value.split(",")}l=_.kh(d)?d:null}l&&(k=Object.assign(k,l))}_.kh(k)&&(h.customAttributes=k);if(gJ(e,h))return _.lv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.hh(e,h);if(_.jk(g)&&!_.kk(h.customAttributes))return _.lv.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=
|
|
16
16
|
m;h.type=_.de;return h},NJ=function(a,b){if(!a)return null;const c=a.bb;return b.find(d=>d.streams[0].bb===c)||null},OJ=function(a){return(a=_.L(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},PJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},QJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.L(e,_.Ta),g=_.L(e,"QUERYPARAM");if(f)g=cJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.D,4,4044,`Query param '${g}' missing in playlist URI.`);
|
|
17
17
|
if(!f)throw new _.I(_.D,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},RJ=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.D,4,4044,`Undefined variable '${d}'`);return c})},SJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=RJ(d.value,b)})})},VJ=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=TJ(a,b[e]);d.push(f);if(f.name===TI){const g=b[e+1];if(!g)throw new _.I(_.D,
|
|
18
|
-
4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.vr(_.wb,g));e++}}b=lJ(d,"EXT-X-DEFINE");mJ(b);b=QJ(b,c);a.a=b;SJ(d,a.a);return new UJ(c,0,d)},ZJ=function(a,b,c){const {
|
|
19
|
-
c):ZJ(a,b,c)},WJ=function(a){const b=[],c=[],d=[];for(const e of a)aK.test(e)?d.push(e):bK.test(e)?c.push(e):b.push(e);return{
|
|
18
|
+
4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.vr(_.wb,g));e++}}b=lJ(d,"EXT-X-DEFINE");mJ(b);b=QJ(b,c);a.a=b;SJ(d,a.a);return new UJ(c,0,d)},ZJ=function(a,b,c){const {Yi:d,oi:e,vj:f}=WJ(b),g=XJ(a,f,c);b=e.map(k=>TJ(a,k,g));const h=YJ(a,c,d,g);return new UJ(c,1,b,h)},$J=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.D,4,4015);b=b.slice(1);return 0===PJ(b)?VJ(a,b,
|
|
19
|
+
c):ZJ(a,b,c)},WJ=function(a){const b=[],c=[],d=[];for(const e of a)aK.test(e)?d.push(e):bK.test(e)?c.push(e):b.push(e);return{Yi:b,oi:c,vj:d}},XJ=function(a,b,c){b=b.map(e=>TJ(a,e));mJ(b);const d=QJ(b,c);b.map(e=>_.L(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.D,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},TJ=function(a,b,c){a=_.xr(a.h++,b);c&&SJ([a],c);return a},YJ=function(a,b,c,d){const e=
|
|
20
20
|
[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=TJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.tb)?g.push(h):f.push(h)):(oJ(f,"EXT-X-GAP")||(h=RJ(h,d),h=_.Tm(h,b),e.push(new cK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new cK(null,f,g));return e},dK=function(a,b,c){const d=[],e=[];e.push(new _.vr(_.ma,"0"));e.push(new _.vr(_.wb,b));c.length&&e.push(new _.vr(_.pa,c));d.push(new _.wr(a.h++,TI,e));return new UJ(b,0,d)},eK=function(a){function b(h,k,l){let m="";for(;k<
|
|
21
21
|
l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.I(_.D,4,4030);}kJ(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<
|
|
22
22
|
22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}kJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},fK=function(a,b){let c=null,d=0;try{(new _.np).N(_.Ee,_.gp).N(_.ig,_.gp).N(_.ze,_.gp).fa("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Sv.error("Unable to find timescale in init segment!"),new _.I(_.D,4,4030,KI,c);let e=0,f=!1;try{(new _.np).N("moof",_.gp).N("traf",_.gp).fa("tfdt",g=>{var h=d;if(0===
|
|
@@ -29,45 +29,45 @@ e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.D,4,4026);return{k
|
|
|
29
29
|
generatedIv:f}=c;return{method:"AES-128",url:_.Tm(cJ(a,_.wb),b),iv:e,generatedIv:f}},wK=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.ZB(b.Da(),b.na,b.na+2048-1,a.a.attemptParameters);e.type=2;const f=_.ZB(b.Da(),b.na,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
|
|
30
30
|
e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.D,4,4030,"Failed to fetch the media segment.");}}})},xK=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Gc||d===_.Fc)return 0;if(d===_.Ec){var g=yield wK(a,c,f);g=_.G(g.data);if(!kJ(g))throw new _.I(_.D,4,4030,"AAC segment does not contain an ID3 tag.");return eK(g)}if(d===_.Ag||d===
|
|
31
31
|
_.Hc)return g=[wK(a,c,f)],b&&g.push(wK(a,b,!0)),g=yield Promise.all(g),fK(g[0].data,(g[1]||g[0]).data);if(d===_.zg)return g=yield wK(a,c,f),hK(g.data);if(!_.rt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.D,4,4030);})},yK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},zK=function(a,b){a=a.streams.find(c=>{c=c.T;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.T.find(c=>c.position===b)||null},AK=function(a,b){a.streams.forEach(c=>
|
|
32
|
-
{c.
|
|
32
|
+
{c.Se=b})},BK=function(a,b){a.streams.forEach(c=>{c.width=b})},CK=function(a,b){a.streams.forEach(c=>{c.height=b})},DK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},EK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},FK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},GK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},IK=function(a,b){for(;a[0].ma<b[0].ma;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||
|
|
33
33
|
HK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&HK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},MK=function(a,b,c,d,e){var f=b[0].length();f=iJ(f).map(g=>{var h=FK(b,g)||[];const k=yK(c,g)||[];g=yK(d,g)||[];{const l=[...JK(h),...k,...g].filter(Boolean);KK(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});f[0].startTime+=e;f[0].endTime+=e;LK(f);return f},
|
|
34
34
|
JK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},LK=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},HK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;NK(a.variants,b.variants);OK(rJ(a),rJ(b))},NK=function(a,b){const c=new Map(a.map(d=>[HJ(d),d]));b.forEach(d=>{c.get(HJ(d)).drmInfos=d.drmInfos})},OK=function(a,b){const c=new Map(a.map(d=>
|
|
35
|
-
[d.bb,d]));b.forEach(d=>{const e=c.get(d.bb);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);e.nd=d.nd;e.
|
|
36
|
-
|
|
35
|
+
[d.bb,d]));b.forEach(d=>{const e=c.get(d.bb);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);e.nd=d.nd;e.kf=d.kf;e.duration=d.duration;e.tg=d.tg;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},KK=function(a){const b=PK(a);a.forEach(c=>{_.VB(c.segmentIndex,b);c.duration=b;c.kf=c.nd+b})},PK=function(a){let b=Infinity;a.filter(uJ).forEach(c=>{b=Math.min(b,c.duration)});return b},TK=function(a){if(!(2>a.length)&&QK(a)){a=a.map(e=>({playlist:e,
|
|
36
|
+
pg:RK(e.T[0])}));var b=a.map(e=>e.pg),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.pg;0<f.T.length&&1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;SK(g,h);h=RK(h);null!=h?e=h:({duration:h}=zJ(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.T.length))throw new _.I(_.D,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>e.T.length));a.forEach(e=>{for(;e.T.length>d;)e.T.pop()})}}},QK=function(a){return a.every(b=>
|
|
37
37
|
!!RK(b.T[0]))},SK=function(a,b){a&&b&&[PI,OI].forEach(c=>{if(!oJ(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},UK=function(a,b){sJ(b,(c,d)=>{_.lC(a,c.T,d.startTime)});_.dC(a.a,b[0].startTime,b[b.length-1].endTime)},VK=function(a,b){return _.w(function*(){var c=_.zk([b],a.a.attemptParameters);c.type=1;c=yield a.I(c);let d="";try{d=_.ri(c.data)}catch(e){throw new _.I(_.D,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},
|
|
38
|
-
fL=function(a,b){return _.w(function*(){var c=WK(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=XK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=dK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=CJ(c.ba);c=YK(d.Oc.
|
|
39
|
-
$K(a,g);h=aL(a,f.delay,g,h);bL(a)||(a.G=f.
|
|
38
|
+
fL=function(a,b){return _.w(function*(){var c=WK(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=XK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=dK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=CJ(c.ba);c=YK(d.Oc.eg);c.forEach(m=>{a.K.add(m.groupId)});var e=yield ZK(a,d);var f=e.Bi;const g=e.periods;var h=e.Si;const k=e.lj;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.D,7,7001);
|
|
39
|
+
$K(a,g);h=aL(a,f.delay,g,h);bL(a)||(a.G=f.de,a.g.info(`Update playlist each ${a.G} s`),cL(a));dL(a,h,g);f=eL(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},hL=function(a,b){return Promise.all(b.map(c=>gL(a,c)))},jL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!bL(a),f=pJ(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");
|
|
40
40
|
if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=pJ(c.ba,RI);if(!k)throw iL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(UI);const l=Number(k.value),m=zK(d,l);if(!m)throw iL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(UI);var h=m.ma}g=h;break a}catch(k){throw new _.I(_.D,4,4024,
|
|
41
|
-
"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)oJ(k.ba,NI)&&g++,k.ma=g});kK(b)},mL=function(a,b){return _.w(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,thumbStreams:d,
|
|
41
|
+
"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)oJ(k.ba,NI)&&g++,k.ma=g});kK(b)},mL=function(a,b){return _.w(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,thumbStreams:d,Hh:e}=yield kL(a,b),f=a.f.periods[0].variants.map(g=>{const h=NJ(g.audio,e),k=NJ(g.video,e);g=lL(a,h,k,g.bandwidth);if(!g)throw new _.I(_.D,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Zj:k?k.streams[0].bb:void 0,audio:h?
|
|
42
42
|
h.streams[0].bb:void 0});return g});return MK(a.D.configurationId,f,c,d,a.B)})},$K=function(a,b){bL(a)||2!==a.a.timeline.version||(a.J||(a.J=b[0].startTime),_.hD(b,-a.J))},nL=function(a,b){b=b.flatMap(d=>d.T[0].ba);b=pJ(b,SI);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},oL=function(a,b,c){b=b.find(e=>null!==pJ(e.ba,MI));if(!b)return[];if(null===c)throw new _.I(_.D,4,4024,
|
|
43
|
-
"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===MI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=MJ(e,c,a.B,!bL(a),d))&&b.set(d.id,d);return Array.from(b.values())},eL=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b.
|
|
44
|
-
schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,
|
|
45
|
-
label:cJ(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},ZK=function(a,b){return _.w(function*(){var c=KJ(b.Oc.closedCaptions),d=qL(a,b.
|
|
46
|
-
c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.
|
|
43
|
+
"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===MI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=MJ(e,c,a.B,!bL(a),d))&&b.set(d.id,d);return Array.from(b.values())},eL=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b.be!==d.be)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,
|
|
44
|
+
schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,be:d.be,endTime:d.endTime,id:d.id,type:_.de,eventElement:null};b&&!fJ(b,e)||a.A.set(d.id,e)}return Array.from(a.A.values())},pL=function(a,b,c){a.w=_.Fb;_.hC(b,!0);b.f=c[c.length-1].endTime},WK=function(a,b,c,d){a=$J(a.S,b,c);a.verbatimUri=d;return a},YK=function(a){return a.filter(b=>b.name===QI&&_.L(b,_.tb)===_.pA&&!_.L(b,_.wb)).map(b=>{const c=OJ(b),d=_.L(b,_.La)||_.lg;return{groupId:cJ(b,_.Fa),id:_.pI++,
|
|
45
|
+
label:cJ(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},ZK=function(a,b){return _.w(function*(){var c=KJ(b.Oc.closedCaptions),d=qL(a,b.fe),e=yield rL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=vJ(g.ba);a.w=h;h!==_.Fb&&(a.H=!0);jL(a,f);!bL(a)&&TK(f);a.L=AJ(g.ba);f=IJ(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield sL(a,e.fg,d);c=yield tL(a,e.fe,g,c);d=yield uL(a,e.ij,d);g=yield vL(a,e.ff);d=MK(a.D.configurationId,
|
|
46
|
+
c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.fe,...e.fg].map(k=>k.playlist);e=nL(a,c);c=oL(a,c,e);return{periods:d,Si:e,lj:c,Bi:f}})},aL=function(a,b,c,d){let e=!0,f=null,g=0;bL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.uI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.hC(a,e);UK(a,c);d&&_.gC(a,d);return a},cL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].nd);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",
|
|
47
47
|
c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.nd?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},dL=function(a,b,c){c=GJ(c);"LIVE"===a.w||"EVENT"===a.w?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.w===_.Fb&&(b.f=c)},kL=function(a,b){return _.w(function*(){const c=h=>h.stream.Hc()===_.t||h.stream.Hc()===_.q;var d=b.filter(c),e=b.filter(h=>
|
|
48
|
-
!c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.bb,
|
|
49
|
-
h.Hc()===_.VA);f=d.filter(h=>h.Hc()===_.he);return{textStreams:e,thumbStreams:f,
|
|
50
|
-
f.push(h)}return new yL(f)},wL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.kd,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.
|
|
51
|
-
1].endTime,kb=Kb-gc,ya=new _.vI(Xa),yb=Xa[0].initSegment||null;return{id:null==g?_.pI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ya.f.bind(ya),getSegmentReference:ya.get.bind(ya),adjustSegmentDurations:ya.h.bind(ya),getDuration:ya.getDuration.bind(ya),segmentIndex:ya,segmentLookupStrategy:F,initSegmentReference:yb,mimeType:vb,codecs:d,kind:C,
|
|
52
|
-
label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,T:Xa,drmInfos:Jb.drmInfos,ma:fc,bb:c.verbatimUri,
|
|
53
|
-
_.L(f,YI);const g=BL(a,f);if(e){const h=_.Or(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=CL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=CL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},rL=function(a,b){return _.w(function*(){const c=yield Promise.all([DL(a,b.Oc.
|
|
48
|
+
!c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.bb,ge:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist,hc:null},k);return wL(a,h)};const g=[];for(const h of d)g.push(yield f(h));d=[];for(const h of e)d.push(yield f(h));xL(a,g.concat(d));e=d.filter(h=>
|
|
49
|
+
h.Hc()===_.VA);f=d.filter(h=>h.Hc()===_.he);return{textStreams:e,thumbStreams:f,Hh:g}})},lL=function(a,b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||null:null,l=h,m=k;l=l&&m?_.KB(l.drmInfos,m.drmInfos)?_.JB(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.lg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};
|
|
50
|
+
f.push(h)}return new yL(f)},wL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.kd,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.ge,A=_.Kn(f||_.lg);if(1!==c.type)throw new _.I(_.D,4,4017);const E=yield zL(a,c,e,d),F=a.a.lowLatencyMode?_.MA:_.LA;let C=m;e!==_.K||m||(C=_.VA);const ja=vJ(c.ba);m=E.map(Ca=>{const Xa=Ca.T,Jb=Ca.Sh,vb=Ca.mimeType,fc=Ca.ma,gc=Xa[0].startTime,Kb=Xa[Xa.length-
|
|
51
|
+
1].endTime,kb=Kb-gc,ya=new _.vI(Xa),yb=Xa[0].initSegment||null;return{id:null==g?_.pI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ya.f.bind(ya),getSegmentReference:ya.get.bind(ya),adjustSegmentDurations:ya.h.bind(ya),getDuration:ya.getDuration.bind(ya),segmentIndex:ya,segmentLookupStrategy:F,initSegmentReference:yb,mimeType:vb,codecs:d,kind:C,tg:Jb.type,encrypted:Jb.type===bJ,aesEncrypted:Ca.aesEncrypted,keyId:Jb.keyId,language:A,originalLanguage:f||_.lg,
|
|
52
|
+
label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,T:Xa,drmInfos:Jb.drmInfos,ma:fc,bb:c.verbatimUri,Se:c.a,nd:gc,kf:Kb,duration:kb,groupId:h,Oj:ja,muxedAudioId:k}});return new AL(m)})},xL=function(a,b){b.forEach(c=>{a.j.a.set(c.streams[0].bb,c)})},qL=function(a,b){const c=new Map;for(const f of b){var d=_.L(f,_.pA);b=_.L(f,_.Eb);var e=
|
|
53
|
+
_.L(f,YI);const g=BL(a,f);if(e){const h=_.Or(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=CL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=CL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},rL=function(a,b){return _.w(function*(){const c=yield Promise.all([DL(a,b.Oc.eg),DL(a,b.Oc.jj),DL(a,b.fe),DL(a,b.ff)]),[d,e,f,g]=c;return{fg:d,ij:e,fe:f,ff:g}})},sL=function(a,b,c){return _.w(function*(){if(0===b.length)return new Map;var d=[EL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>
|
|
54
54
|
EL(a,e,c)));d=yield Promise.all(d);return JJ(d)})},tL=function(a,b,c,d){return _.w(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(cJ(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield FL(a,h,c,d,e);f=f.map(k=>FL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.oB,[])})},uL=function(a,b,c){return Promise.all(b.map(d=>EL(a,d,c)))},vL=function(a,b){return Promise.all(b.map(c=>GL(a,c)))},HL=function(a,b){return _.w(function*(){const c=
|
|
55
|
-
_.Tm(b.verbatimUri,a.o),{response:d,text:e}=yield VK(a,c);return WK(a,e,d.uri,b.verbatimUri)})},IL=function(a,b,c){return _.w(function*(){const d=yield wL(a,{playlist:c,codecs:b.codecs,type:b.type,kd:b.originalLanguage,hc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,
|
|
56
|
-
_.Fb},DL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield JL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gL=function(a,b){return _.w(function*(){var c=new URL(b.streams[0].
|
|
57
|
-
f&&d.get(ZI)&&d.delete(ZI),null!==f&&d.set(ZI,f.toString())}const {response:g,text:h}=yield VK(a,c.toString());c=b.streams[0].bb;d=b.streams[0].
|
|
55
|
+
_.Tm(b.verbatimUri,a.o),{response:d,text:e}=yield VK(a,c);return WK(a,e,d.uri,b.verbatimUri)})},IL=function(a,b,c){return _.w(function*(){const d=yield wL(a,{playlist:c,codecs:b.codecs,type:b.type,kd:b.originalLanguage,hc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,ge:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&EK(d,b.bandwidth);return d})},bL=function(a){return a.w===
|
|
56
|
+
_.Fb},DL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield JL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gL=function(a,b){return _.w(function*(){var c=new URL(b.streams[0].Se);if(a.a.lowLatencyMode&&a.L&&a.L.kg){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Ci:d.position,Ni:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Ni,d.set("_HLS_msn",e.Ci.toString()),null===
|
|
57
|
+
f&&d.get(ZI)&&d.delete(ZI),null!==f&&d.set(ZI,f.toString())}const {response:g,text:h}=yield VK(a,c.toString());c=b.streams[0].bb;d=b.streams[0].Se;e=g.uri;d!==e&&(d=e,AK(b,d));c=WK(a,h,d,c);return{stream:b,playlist:c}})},BL=function(a,b){var c=_.L(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=LJ(c);b=new Set;const d=[];for(const e of c)c=_.uB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},CL=function(a,b){if(1===b.length)return b[0];a=_.Or(a,
|
|
58
58
|
b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},EL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return KL(a,e.verbatimUri,()=>_.w(function*(){const f=cJ(d,_.Fa),g=wJ(cJ(d,_.tb));var h=cJ(d,_.tb).toUpperCase();if(wJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.VA;h===JI&&(l=_.GA);k&&(l=_.Zd);h=l}k=c.get(`${g}:${f}`)||"";l=_.L(d,_.La);const m=_.L(d,_.Ta),n=_.L(d,"DEFAULT"),p=g===_.q?OJ(d):null;var u=
|
|
59
|
-
g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wL(a,{playlist:e,codecs:k,type:g,kd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,
|
|
60
|
-
closedCaptions:null,hc:null,groupId:null,
|
|
59
|
+
g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wL(a,{playlist:e,codecs:k,type:g,kd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,ge:null})}))})},GL=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return KL(a,d.verbatimUri,()=>_.w(function*(){var e=_.L(c,_.pa)||"jpg",f=_.L(c,_.La);const g=_.L(c,_.Ta);e=yield wL(a,{playlist:d,codecs:e,type:_.he,kd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,
|
|
60
|
+
closedCaptions:null,hc:null,groupId:null,ge:null});(f=_.L(c,_.ma))&&EK(e,Number(f));return e}))})},FL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(cJ(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.mb)){var h=_.L(f,"FRAME-RATE");f=_.L(f,_.mb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:hJ(h),width:hJ(k),height:hJ(l)}}else h=null;if(f=yield LL(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=
|
|
61
61
|
(p?p.streams[0].bb:"")+" - "+(n?n.streams[0].bb:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=lL(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},ML=function(a,b,c,d,e,f){let g=BL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Or(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&
|
|
62
|
-
f?(a.g.debug(VI),c=_.q,b=!0):e?(a.g.debug(VI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(VI));return{type:c,
|
|
63
|
-
u.streams[0].bb===l);const {type:m,
|
|
64
|
-
CL(_.q,c);m+=`,${n}`}return yield wL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,kd:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,
|
|
62
|
+
f?(a.g.debug(VI),c=_.q,b=!0):e?(a.g.debug(VI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(VI));return{type:c,Eh:g,ri:b}},KL=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||null;c=c();a.j.set(b,c);return c},LL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.L(f,_.pA),k=_.L(f,_.Eb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>
|
|
63
|
+
u.streams[0].bb===l);const {type:m,Eh:n,ri:p}=ML(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield NL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{BK(u,c.width);CK(u,c.height);DK(u,c.frameRate)});return k})},NL=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return KL(a,h.verbatimUri,()=>_.w(function*(){var k=_.L(g,JI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.L(g,_.pA)||void 0)&&a.K.has(k)?k:void 0;var m=CL(d,c);if(k){const n=
|
|
64
|
+
CL(_.q,c);m+=`,${n}`}return yield wL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,kd:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,ge:f})}))})},zL=function(a,b,c,d){return _.w(function*(){var e=b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=pJ(b.ba,RI);var k=h?Number(h.value):g;g=[];h=null;if(a.H){a.H=!1;var l=a.B;a.B=yield OL(a,b.a,e,f,k,c,d);null!=l&&(h=a.B-l)}e=k;if(0===f.length)f=[];else{k=[];l=[];for(var m of f)oJ(m.ba,NI)&&0<l.length&&
|
|
65
65
|
(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield PL(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;QL(g);return g})},JL=function(a,b){return _.w(function*(){var c=b.name!==QI?!0:_.L(b,_.tb)===YI;c=_.L(b,_.wb,void 0,{required:c});if(!c)return null;const d=_.Tm(c,a.o),e=Date.now(),{response:f,text:g}=yield VK(a,d);a.D.onEvent(new _.H(aJ,{detail:{duration:Date.now()-e,type:"media"}}));return WK(a,g,f.uri,c)})},QL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.D,
|
|
66
66
|
4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},RL=function(a,b,c){a=lJ(a.ba,PI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=cJ(a,_.wb),e=_.Tm(d,b);b=BJ(a,null,!0);return new _.qI(()=>[e],b.na,b.ja,c)},SL=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.L(u,LI));n=m+n;k=BJ(u,k?null:l.ja,k);l=String(_.L(u,_.wb));
|
|
67
67
|
const v=(l=_.Tm(l,g))?[l]:[];m=new DJ(c,m,n,()=>v,k.na,k.ja,e,f,!1,null,null,null,null);if("YES"===_.L(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},TL=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<lJ(n,PI).length&&(m=RL(c,k,g));var u=null!=p;const v=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;let y=0,A={na:0,ja:null};p=null;u&&({duration:u}=zJ(n),y=e+u,A=yJ(n,b?b.ja:null));a.a.lowLatencyMode&&0<c.f.length&&(p=SL(b,c,d,e,f,g,k),0===y&&(y=p[p.length-1].endTime));a=h===_.he?qJ(n):
|
|
68
|
-
null;d=new DJ(d,e,y,()=>v,A.na,A.ja,f,g,!1,null,a?a.
|
|
69
|
-
uri:c});}k=yield VL(a,f,g,h);const l=vK(h.ba,a.o,e),m=RL(h,b,l);h=yield WL(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},PL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0];const l=yield VL(a,e,f,k);var m=g?g.
|
|
70
|
-
[];let A=!1;for(let F=0;F<c.length;F++){var E=c[F];const C=u[u.length-1]||null,ja=0===F?0:C.endTime,Ca=d+F,Xa=XL(p,E.ba,a.o,Ca);(p=Xa)&&(A=!0);if(E=TL(a,C,E,Ca,ja,k,Xa,e,b,y,v))v=E.initSegment,u.push(E)}return{T:u,
|
|
68
|
+
null;d=new DJ(d,e,y,()=>v,A.na,A.ja,f,g,!1,null,a?a.Md:null,a?a.ee:null,a?a.durationPerTile:null,p,m);d.ma=l;return d},OL=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(!bL(a)&&a.f)try{return UL(a,c,e)}catch(n){if(h=a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.I(_.D,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
|
|
69
|
+
uri:c});}k=yield VL(a,f,g,h);const l=vK(h.ba,a.o,e),m=RL(h,b,l);h=yield WL(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},PL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0];const l=yield VL(a,e,f,k);var m=g?g.zi:null;if(oJ(c[0].ba,OI)||null===m)m=sK(c,l),m=0===m.length?[oK()]:m;else{var n=sK(c,l);m=[m,...n]}n=m;m=n[n.length-1];n=pK(n);let p=g?g.Ai:null;var u=XL(p,k.ba,a.o,d);let v=RL(k,b,u)||(g?g.si:null);const y=k.ma;k=yield YL(a,y,v,k,d,u,l,f,h,null==g);u=
|
|
70
|
+
[];let A=!1;for(let F=0;F<c.length;F++){var E=c[F];const C=u[u.length-1]||null,ja=0===F?0:C.endTime,Ca=d+F,Xa=XL(p,E.ba,a.o,Ca);(p=Xa)&&(A=!0);if(E=TL(a,C,E,Ca,ja,k,Xa,e,b,y,v))v=E.initSegment,u.push(E)}return{T:u,Sh:n,zi:m,aesEncrypted:A,mimeType:l,endTime:u[u.length-1].endTime,ma:y,si:v,Ai:p}})},UL=function(a,b,c){const d=ZL(a,b,c);if(!d)throw new _.I(_.D,4,4030,"Segment not found in previous playlist update.");return a.f.periods.find(e=>e.ma===d.ma).startTime+d.startTime},VL=function(a,b,c,d){return _.w(function*(){const e=
|
|
71
71
|
d.a;var f=pJ(d.ba,PI);f=f?cJ(f,_.wb):null;return $L(a,b,c,e,f)})},WL=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=EJ(c,d);return xK(a.U,b,g,e,f,null!=d)})},XL=function(a,b,c,d){return b.some(e=>e.name===OI&&"NONE"===_.L(e,WI))?null:(b=vK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.im(new Uint8Array(12),jJ(d))}):a},YL=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){if(a.C.has(b)&&l&&a.M&&null!=k){var m=a.f.periods.filter(p=>p.ma<b).map(p=>p.duration).reduce((p,
|
|
72
72
|
u)=>p+u,0);m=k-m;const n=a.C.get(b);a.C.set(b,n+m);a.M=!1}if(a.C.has(b))return a.C.get(b);m=yield WL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,m);return m})},ZL=function(a,b,c){return(a=a.j.get(b))?zK(a,c)||null:null},$L=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Rr(f,b,c);if(g)return g;g=_.zk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.I(g)).headers["content-type"];if(!g)throw new _.I(_.D,4,4021,"Unknown MIME type of: "+
|
|
73
73
|
f.join(", "));return g.toLowerCase().split(";")[0]})},XK=a=>{a=_.Um(a)||"";return null!=_.Hu.video[a]?_.t:null!=_.Hu.audio[a]?_.q:null},UJ=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.D,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.D,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.T=1===b?d:null}},cK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=
|
package/cl.htmlcue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var MS="Unsupported unit",NS="clpp-text-plain",OS="clpp-text-ttml",PS="clpp.htmlcue.HtmlTextDisplayer",QS="initial",RS=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},SS=function(a){return _.gi(a,{
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var MS="Unsupported unit",NS="clpp-text-plain",OS="clpp-text-ttml",PS="clpp.htmlcue.HtmlTextDisplayer",QS="initial",RS=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},SS=function(a){return _.gi(a,{og:(b,c)=>b.Zc(c)})},TS=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},US=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
|
|
2
2
|
b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},WS=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>VS[c]);return a},YS=function(a,b){XS(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{XS(a,c)})},XS=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},ZS=function(a,b){return 0===a?"0":a+b},$S=function(a,b){return 1>Math.abs(a-b)||a<b},aT=function(a,b){return a<b&&1<Math.abs(a-b)},bT=function(a,b){return a>b&&1<Math.abs(a-b)},cT=
|
|
3
3
|
function(a,b){return 1>Math.abs(a-b)||a>b},eT=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new dT(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
4
|
d-e)},fT=function(a){return new dT(a.left,a.f,a.top,a.a,a.height,a.width)},gT=function(a,b){return b.some(c=>aT(a.left,c.f)&&bT(a.f,c.left)&&aT(a.top,c.a)&&bT(a.a,c.top))},hT=function(a,b){return cT(a.top,b.top)&&$S(a.a,b.a)&&cT(a.left,b.left)&&$S(a.f,b.f)},iT=function(a,b,c){switch(c){case "+x":return aT(a.left,b.left);case "-x":return bT(a.f,b.f);case "+y":return aT(a.top,b.top);case "-y":return bT(a.a,b.a);default:throw Error("Unknown axis");}},jT=function(a){return a.f.writingMode===_.vu},kT=
|
package/cl.ima.js
CHANGED
|
@@ -9,7 +9,7 @@ this.f.getIsBumper():!1}Ra(){let a=null;const b=this.a,c=Object.keys(b).find(d=>
|
|
|
9
9
|
W.prototype.getSequenceLength=W.prototype.Wa;W.prototype.getPositionInSequence=W.prototype.gb;W.prototype.getPodTimeOffset=W.prototype.pb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ca;W.prototype.getMediaBitrate=W.prototype.Ba;W.prototype.getMediaHeight=W.prototype.Ua;W.prototype.getMediaWidth=W.prototype.Va;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Ra;W.prototype.isBumper=W.prototype.Bb;
|
|
10
10
|
W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getPosition=W.prototype.getPosition;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;W.prototype.getSourceId=W.prototype.zb;W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;
|
|
11
11
|
W.prototype.getTechnology=W.prototype.hb;W.prototype.getAdManagerVersion=W.prototype.fb;W.prototype.getAdManagerName=W.prototype.eb;var HS=class{create(a){const b=google.ima.AdError.ErrorCode;switch(a){case b.VAST_LOAD_TIMEOUT:case b.VAST_MEDIA_LOAD_TIMEOUT:case b.FAILED_TO_REQUEST_ADS:return 0;case b.VIDEO_PLAY_ERROR:return 1;default:return 2}}};var IS=class{constructor(a){this.a=a}getCuePoints(){return this.a}Qb(){return 0<=this.a.indexOf(0)||0===this.a.length}Pb(){return 0<=this.a.indexOf(-1)}};IS.prototype.hasPostroll=IS.prototype.Pb;IS.prototype.hasPreroll=IS.prototype.Qb;IS.prototype.getCuePoints=IS.prototype.getCuePoints;var JS=class extends _.Uv{constructor(){super();this.a=this.h=this.f=null}onPlayerCreated(a){if(tS())return a.onError(new _.I(1,9,1E4));this.f=_.Fi(_.Fd,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.h=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.h);this.a.getSettings().setPlayerType(_.ra);this.a.getSettings().setPlayerVersion(_.ea);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
|
|
12
|
-
(this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}
|
|
12
|
+
(this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}ci(){return this.a}ai(){return this.h}$c(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",JS);JS.prototype.getAdContainer=JS.prototype.$c;JS.prototype.getAdDisplayContainer=JS.prototype.ai;JS.prototype.getAdsLoader=JS.prototype.ci;JS.Id="ima";JS.isSdkMissing=tS;var KS=class{create(){return new JS}};var LS=class{constructor(a){var b=a.Hd("ima");if(!b)throw Error("IMA plugin not created.");var c=b.$c(),d=b.h;b=b.a;if(!c||!d||!b)throw Error("IMA plugin not initialized.");const e=a.getSurface().getMedia();if(!e)throw Error("Missing media element.");this.m=a;this.F=e;a=this.m.getConfiguration();a=_.ih(a.ima||{});this.H=a=_.hh({disableCustomPlayback:!1},a);this.da=c;this.ia=d;this.B=b;this.X=new _.Kv;this.g=new _.T("clpp.ima");this.a=null;this.W=!1;this.l=null;this.f=new _.Kl;this.ca=!1;this.S=new _.Vt;
|
|
13
13
|
this.xc=new HS;this.G=null;this.C=this.U=!1;this.L=1;this.P=this.I=this.J=!1;this.M=this.R=null;this.K=!0;c=this.S;d=google.ima.AdErrorEvent.Type.AD_ERROR;c.one(this.B,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.hd.bind(this));c.on(this.B,d,this.Lc.bind(this));c.on(this.m,_.Wd,this.jd.bind(this))}hd(a){this.a=a.getAdsManager(this.F,uS(this));this.a.isCustomPlaybackUsed()&&!vS(this)?(this.g.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.I(1,
|
|
14
14
|
9,10002)),this.o()):(this.setMuted(this.C),this.h(this.L),this.l=new _.Iv(this.m.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.R=new IS(a),this.m.trigger(new _.H(_.qc,{adsTimeline:this.R})),wS(this));this.f.resolve()}Lc(a){xS(this,a.getError());this.f.resolve()}md(a){this.P=!0;yS(this)||(this.m.pause(),_.Hi(this.F,{visibility:_.ce}));zS(this,_.Ub,a);this.l.start()}yc(){yS(this)?CS(this):this.a.start()}lb(a){a.getAd().isLinear()?
|
|
15
15
|
zS(this,_.dc,a):(this.a.discardAdBreak(),this.J||(this.J=!0,this.m.play()))}Tb(a){this.U=!0;this.K=!1;this.G=a.getAd().getDuration();zS(this,_.mc,a);this.m.getSurface().show(this.da)}Dc(a){a=a.getAdData();xS(this,a?a.adError:null);DS(this)}Ib(a){zS(this,_.jc,a)}Ac(a){zS(this,_.Wb,a)}Ma(a){zS(this,_.Zb,a)}Fc(a){zS(this,_.ec,a)}Ub(a){zS(this,_.oc,a)}Ic(a){this.K=!0;zS(this,_.hc,a)}Jc(a){this.K=!1;zS(this,_.kc,a)}Aa(a){this.pause();zS(this,_.Xb,a)}Jb(a){zS(this,_.lc,a);DS(this)}cb(a){zS(this,_.cc,a)}Bc(a){zS(this,
|