@castlabs/prestoplay 6.17.1 → 6.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +7 -7
- package/cjs/cl.cast.js +111 -111
- package/cjs/cl.conviva.js +33 -33
- package/cjs/cl.core.js +566 -558
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +75 -74
- package/cjs/cl.externs.js +46 -46
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +71 -69
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +29 -29
- package/cjs/cl.ima.js +23 -23
- package/cjs/cl.mse.js +311 -311
- package/cjs/cl.muxdata.js +15 -15
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.sessions.js +15 -15
- package/cjs/cl.simid.js +15 -15
- package/cjs/cl.smooth.js +72 -72
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +69 -69
- package/cjs/cl.ttml.js +28 -28
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +13 -13
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.youbora.js +18 -18
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +5 -5
- package/cl.cast.js +87 -87
- package/cl.conviva.js +27 -27
- package/cl.core.js +456 -450
- package/cl.crypto.js +8 -8
- package/cl.dash.js +70 -69
- package/cl.externs.js +46 -46
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +72 -72
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +17 -17
- package/cl.mse.js +274 -273
- package/cl.muxdata.js +13 -13
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +10 -10
- package/cl.playlist.js +5 -5
- package/cl.sessions.js +10 -10
- package/cl.simid.js +13 -13
- package/cl.smooth.js +59 -59
- package/cl.thumbnails.js +19 -19
- package/cl.tizen.js +57 -57
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +15 -15
- package/cl.vtt.js +12 -12
- package/cl.youbora.js +15 -15
- package/package.json +2 -2
- package/typings.d.ts +37 -3
package/cl.freewheel.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});}
|
|
3
|
-
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.
|
|
4
|
-
a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},
|
|
5
|
-
!0),a.getSurface().hide(this.a);else a.onError(new _.H(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return
|
|
6
|
-
0}getSkipTimeOffset(){return 0}
|
|
7
|
-
case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.
|
|
8
|
-
Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.
|
|
9
|
-
Y.prototype.getMediaWidth=Y.prototype.
|
|
10
|
-
Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.
|
|
11
|
-
|
|
12
|
-
_.t||a.a.setSiteSection(b.siteSectionId);const c=yield
|
|
13
|
-
if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);
|
|
14
|
-
a.j&&(a.j.stop(),a.j=null);
|
|
15
|
-
9,10003,{errorType:0},void 0));this.l.resolve()}J(a){
|
|
16
|
-
_.
|
|
17
|
-
_.
|
|
18
|
-
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.o.findIndex(c=>c===this.f);this.o.splice(b,1);this.m.pause();
|
|
19
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var dS="clpp-freewheel",eS="clpp.freewheel.AdsManagerFactory",fS="freewheel",gS=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""}},hS=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Qf&&b.push("serverUrl");typeof a.profileId!==_.Qf&&b.push("profileId");typeof a.videoAssetId!==_.Qf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
|
|
2
|
+
if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},iS=function(){return _.x(function*(){var a=new _.qu;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})},jS=function(a){a.h.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.H.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.J.bind(a));a.h.on(a.a,
|
|
3
|
+
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.h.on(a.m,_.Xf,a.F.bind(a));a.h.on(a.m,_.Nf,a.C.bind(a))},mS=function(a){return _.x(function*(){a.B.length?(kS(a),a.f=a.B.shift(),a.f.play()):(lS(a),yield a.m.a.play())})},lS=function(a){const b=a.m.gc(fS).Ac();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},kS=function(a){const b=a.m.gc(fS).Ac();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(dS),
|
|
4
|
+
a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},nS=function(a){a.A.length?(kS(a),a.f=a.A.shift(),a.f.play()):lS(a)},oS=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new Y(a.a,c,d)});a.m.trigger(new _.E(b,d))},pS=class extends _.Au{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.uo(_.Gd,{id:dS}),this.f=_.uo(_.w,{"class":_.ed}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
|
|
5
|
+
!0),a.getSurface().hide(this.a);else a.onError(new _.H(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return fS}Ac(){return this.a}yg(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",pS);pS.prototype.getAdVideo=pS.prototype.yg;pS.prototype.getAdContainer=pS.prototype.Ac;pS.Id=fS;pS.AD_CONTAINER_ID=dS;_.dp(new class{create(){return new pS}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}yb(){return"FreeWheel AdManager SDK"}zb(){return tv.freewheel.SDK.version}Fb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Qf?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
|
|
6
|
+
0}getSkipTimeOffset(){return 0}kc(){return!1}Qb(){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():""}Cb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}Bb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}qb(){return 0}eb(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
|
|
7
|
+
case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.eb()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Rb(){switch(this.eb()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Sb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}Eb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
|
|
8
|
+
Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.Eb;Y.prototype.getPositionInSequence=Y.prototype.Sb;Y.prototype.getPodTimeOffset=Y.prototype.Rb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.eb;Y.prototype.getMediaBitrate=Y.prototype.qb;Y.prototype.getMediaHeight=Y.prototype.Bb;
|
|
9
|
+
Y.prototype.getMediaWidth=Y.prototype.Cb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.Qb;Y.prototype.isBumper=Y.prototype.kc;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;Y.prototype.getAdSystem=Y.prototype.getAdSystem;Y.prototype.getApiFramework=Y.prototype.getApiFramework;
|
|
10
|
+
Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.Fb;Y.prototype.getAdManagerVersion=Y.prototype.zb;Y.prototype.getAdManagerName=Y.prototype.yb;var qS=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Tb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}sb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
|
|
11
|
+
qS.prototype.hasPostroll=qS.prototype.sb;qS.prototype.hasPreroll=qS.prototype.Tb;qS.prototype.getCuePoints=qS.prototype.getCuePoints;var rS=class{constructor(a){this.g=new _.R("clpp.freewheel.AdsManager");this.m=a;this.h=new _.ts;this.w=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.B=[];this.o=[];this.A=[];this.l=new _.dn;this.j=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{hS(b)}catch(d){return a.m.onError(d),a.l.resolve(),a.l}a.w.setNetwork(b.networkId);a.w.setServer(b.serverUrl);a.a=a.w.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Qf&&typeof b.siteSectionId!==
|
|
12
|
+
_.t||a.a.setSiteSection(b.siteSectionId);const c=yield iS();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,gS(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Fe&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);
|
|
13
|
+
if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);jS(a);a.a.submitRequest();return a.l})}start(){const a=this;return _.x(function*(){yield mS(a)})}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}dispose(){const a=this;return _.x(function*(){a.h.release();
|
|
14
|
+
a.j&&(a.j.stop(),a.j=null);lS(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.o=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.E(_.uc,{adsTimeline:new qS(this.a)})),this.j=new _.ou(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.gc(fS).f);else this.m.onError(new _.H(1,
|
|
15
|
+
9,10003,{errorType:0},void 0));this.l.resolve()}J(a){oS(this,_.cc,a);this.j.start()}I(a){this.f=null;a=a.slot;oS(this,_.dc);this.j.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:mS(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:lS(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:nS(this)}}G(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:oS(this,_.qc,a);oS(this,
|
|
16
|
+
_.ic,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:oS(this,_.rc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:oS(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:oS(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:oS(this,_.sc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:oS(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:oS(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:oS(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:oS(this,
|
|
17
|
+
_.oc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:oS(this,_.pc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:oS(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:oS(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.H(1,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]}))}}F(){if(!this.f){var a=this.m.getPosition();if(this.f=this.o.find(b=>
|
|
18
|
+
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.o.findIndex(c=>c===this.f);this.o.splice(b,1);this.m.pause();kS(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Zn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Yn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.On:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);nS(this);break;case _.Wn:case _.Vn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
|
|
19
|
+
rS.prototype.getPosition=rS.prototype.getPosition;rS.prototype.setVolume=rS.prototype.setVolume;rS.prototype.getVolume=rS.prototype.getVolume;rS.prototype.skip=rS.prototype.skip;rS.prototype.pause=rS.prototype.pause;rS.prototype.resume=rS.prototype.resume;rS.prototype.start=rS.prototype.start;var sS=class{constructor(){this.a=new _.R(eS)}name(){return eS}isSupported(a,b){return a.namespace()===_.kd?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new rS(a)}};sS.prototype.create=sS.prototype.create;sS.prototype.isSupported=sS.prototype.isSupported;sS.prototype.name=sS.prototype.name;_.ro(new sS);};f.call(g, window);
|
package/cl.hls.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
a)return Number(a)},
|
|
3
|
-
c.add(d)})},
|
|
4
|
-
b,c){c=void 0===c?!0:c;a=new _.
|
|
5
|
-
|
|
6
|
-
4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{
|
|
7
|
-
return{duration:Number(a[0]),title:a[1]||null}},
|
|
8
|
-
b){const c=
|
|
9
|
-
c)=>b+c,0)},
|
|
10
|
-
new Map;a.forEach(c=>{var d
|
|
11
|
-
(a=_.
|
|
12
|
-
g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.H(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.H(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},
|
|
13
|
-
"EXT-X-DEFINE");
|
|
14
|
-
b)},
|
|
15
|
-
a.a.get(e);if(null==f)throw new _.H(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},
|
|
16
|
-
21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.F,4,4030);}
|
|
17
|
-
e+=10;e+=f}while(e<a.byteLength);return d()},
|
|
18
|
-
k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.H(_.F,4,4030,
|
|
19
|
-
|
|
20
|
-
((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},
|
|
21
|
-
a=null;b=_.J(b.data);try{a=_.
|
|
22
|
-
},
|
|
23
|
-
a.map(e=>
|
|
24
|
-
null,type:
|
|
25
|
-
e.uris[0]);try{return yield a.f(f)}catch(h){throw a.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
f.
|
|
29
|
-
|
|
30
|
-
d.drmInfos})},
|
|
31
|
-
b[0].startTime,b[b.length-1].endTime)},
|
|
32
|
-
_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");
|
|
33
|
-
|
|
34
|
-
a.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
b
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
f:null}}else d=null;if(e=d)d=e.
|
|
51
|
-
|
|
52
|
-
_.
|
|
53
|
-
|
|
54
|
-
h={frameRate:
|
|
55
|
-
|
|
56
|
-
l=null;f||(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},
|
|
60
|
-
[e],b.
|
|
61
|
-
|
|
62
|
-
var m=l.startTime+l.
|
|
63
|
-
l,h,k,m,g);a.
|
|
64
|
-
if(
|
|
65
|
-
const M=m[m.length-1]||null,da=0===y?0:M.endTime,
|
|
66
|
-
const k=yield
|
|
67
|
-
4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.F,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this
|
|
68
|
-
q,u
|
|
69
|
-
|
|
70
|
-
text:e}=yield
|
|
71
|
-
d=d.filter(g
|
|
72
|
-
_.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var yH="CLOSED-CAPTIONS",zH="Could not parse MP4 segment start time.",AH="DURATION",BH="EXT-X-STREAM-INF",CH="Failed to infer discontinuity number",DH="Guessing audio-only",EH="METHOD",FH="SAMPLE-AES-CTR",GH="SUBTITLES",HH="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",IH="application/vnd.apple.mpegurl",JH="sample",KH="whole-segment",LH=function(a,b){return _.I(a,b,void 0,{required:!0})},MH=function(a){if(1>a.a)throw _.wl();--a.a},NH=function(a){if(null!==a&&void 0!==
|
|
2
|
+
a)return Number(a)},OH=function(a,b){return a.filter(c=>c.name===b)},PH=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.I(d,"VALUE"),f=_.I(d,"NAME"),g=_.I(d,"IMPORT"),h=_.I(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.H(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);
|
|
3
|
+
c.add(d)})},QH=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=LH(d,_.Kb);return c.includes(d)})},RH=function(a,b){return a.some(c=>c.name===b)},SH=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.F,4,4024,{missingTag:b});return a},TH=function(a){var b=SH(a,"EXT-X-TILES");if(!b)return{Uc:1,ld:1,durationPerTile:null};a=_.I(b,"LAYOUT")||"1x1";b=_.I(b,AH);a=_.hB(a);return{Uc:a.Uc,ld:a.ld,durationPerTile:b?Number(b):null}},UH=function(a,
|
|
4
|
+
b,c){c=void 0===c?!0:c;a=new _.Mh(a);b=new _.Mh(b);b=a.resolve(b).toString();return c?b:decodeURI(b)},VH=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)},WH=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of VH(c))b(d,c)})},XH=function(a){return a.some(b=>RH(b.ba,_.Fa))},YH=function(a){return a.type===_.p||a.type===_.w},ZH=function(a,b){const c=
|
|
5
|
+
SH(a,_.Fa);if(b&&c)return _.Tb;a=SH(a,_.La);if(!a)return"LIVE";if(a.value===_.Tb)return _.Tb;if("EVENT"===a.value)return"EVENT";throw new _.H(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},$H=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.G,"CLOSED-CAPTIONS":_.G}[a.toUpperCase()];if(!a)throw new _.H(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},aI=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.H(_.F,
|
|
6
|
+
4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{xa:d,ma:e}},bI=function(a,b){a=SH(a,_.Ba);return aI(a?a.value:null,b)},cI=function(a){a=SH(a,"EXTINF",{required:!0}).value.split(",");
|
|
7
|
+
return{duration:Number(a[0]),title:a[1]||null}},dI=function(a,b){b=void 0===b?{}:b;const c={pd:!1,ig:!1,jg:null,Mg:null,Ef:null};a=SH(a,_.Oa,{required:b.If});if(!a)return c;const d=e=>null==e?null:Number(e);c.pd="YES"===_.I(a,"CAN-BLOCK-RELOAD");c.ig="YES"===_.I(a,"CAN-SKIP-DATERANGES");c.jg=d(_.I(a,"CAN-SKIP-UNTIL"));c.Mg=d(_.I(a,"HOLD-BACK"));c.Ef=d(_.I(a,"PART-HOLD-BACK",void 0,{required:b.If}));return c},eI=function(a,b,c){c=void 0===c?!1:c;a=_.I(a,"BYTERANGE");return aI(a,b,c)},gI=function(a,
|
|
8
|
+
b){const c=bI(a.ba,null);return new fI(0,0,0,()=>[a.a],c.xa,c.ma,0,b)},hI=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.Ii(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},iI=function(a){let b=Infinity,c=Infinity;VH(a).filter(YH).forEach(d=>{{d=d.V;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Fc:b,duration:c}},jI=function(a){return a.map(b=>{({duration:b}=iI(b));return b}).reduce((b,
|
|
9
|
+
c)=>b+c,0)},kI=function(a){return(a.video?a.video.Ba:"")+" - "+(a.audio?a.audio.Ba:"")},lI=function(a,b,c,d){if(b===_.Tb)return{delay:0,pc:0};b=SH(a,_.Ja);if(c&&b){c=Number(LH(b,"PART-TARGET"));if(null!=d)return{delay:d,pc:c};({Ef:d}=dI(a,{If:!0}));return{delay:d,pc:c}}a=SH(a,_.Qa,{required:!0});a=Number(a.value);return null!=d?{delay:d,pc:a}:{delay:3*a,pc:a}},mI=function(a){const b=[];WH(a,c=>{b.push(c.Ug)});return{delay:Math.max(...b.map(c=>c.delay)),pc:Math.min(...b.map(c=>c.pc))}},oI=function(a){const b=
|
|
10
|
+
new Map;a.forEach(c=>{var d=`${nI(c).type}:${nI(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},pI=function(a){const b=new Map;for(const c of a){a=_.I(c,_.cb);a=_.bi(a||_.ag);const d=LH(c,_.Va),e=LH(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},rI=function(a){a=a.audio.concat(a.video);for(const b of a)a=nI(b).codecs.split(",").filter(c=>"mp4a.40.34"!==c),qI(b,a)},sI=function(a,b){if(!a)return null;const c=a.Ba;return b.find(d=>nI(d).Ba===
|
|
11
|
+
c)||null},tI=function(a){for(const b of a)if(b.startsWith("#EXT-")&&(a=_.Ni(0,b),_.Ts.has(a.name)))return 1;return 0},uI=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.H(_.F,4,4044,`Undefined variable '${d}'`);return c})},vI=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=uI(d.value,b)})})},wI=function(a,b,c){vI(a,c);b.forEach(d=>{d.a&&(d.a=uI(d.a,c));vI(d.ba,c);vI(d.f,c)})},xI=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>
|
|
12
|
+
{var f=_.I(e,"NAME"),g=_.I(e,"QUERYPARAM");if(f)g=LH(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.H(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.H(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},AI=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=yI(a,b[e]);d.push(f);if(f.name===BH){const g=b[e+1];if(!g)throw new _.H(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");
|
|
13
|
+
f.attributes.push(new _.Li(_.Mb,g));e++}}b=OH(d,"EXT-X-DEFINE");PH(b);b=xI(b,c);a.a=b;wI(d,[],a.a);return new zI(c,0,d)},DI=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=yI(a,b[e]);if(_.Us.has(f.name))break;d.push(f);e++}b=BI(a,c,b.slice(e));e=b.V;d=d.concat(b.ba);a=CI(a,d,c);wI(d,e,a);return new zI(c,1,d,b.V)},EI=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 _.H(_.F,4,4015);return 0===
|
|
14
|
+
tI(b)?AI(a,b,c):DI(a,b,c)},yI=function(a,b){return _.Ni(a.f++,b)},BI=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=yI(a,h),_.Ts.has(h.name)||_.Ws.has(h.name)?d.push(h):_.Vs.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.Ma&&"PART"===_.I(h,_.Kb)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=UH(b,h.trim(),!1),e.push(new FI(h,f,g)),f=[],g=[])});0<g.length&&e.push(new FI(null,f,g));return{V:e,ba:d}},CI=function(a,b,c){b=OH(b,"EXT-X-DEFINE");PH(b);const d=xI(b,
|
|
15
|
+
c);b.map(e=>_.I(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.H(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},GI=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},HI=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},II=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+
|
|
16
|
+
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 _.H(_.F,4,4030);}HI(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|a[5]<<14|a[6]<<
|
|
17
|
+
6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}HI(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},JI=function(a,b){let c=null,d=0;try{(new _.Ml).M(_.Be,_.Fl).M(_.Yf,_.Fl).M(_.we,_.Fl).ca("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.P(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.su.error("Unable to find timescale in init segment!"),new _.H(_.F,4,4030,zH,c);let e=0,f=!1;try{(new _.Ml).M("moof",_.Fl).M("traf",_.Fl).ca("tfdt",g=>{var h=d;if(0===g.version)h=_.P(g.reader)/
|
|
18
|
+
h;else{{const k=_.P(g.reader),l=_.P(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.H(_.F,4,4030,zH,c);return e},KI=function(a){for(;a.getPosition()<a.Ha()-1;){const b=a.getPosition();if(71===_.xl(a))return MH(a),b}return-1},LI=function(a){function b(){d.seek(e+188);f=_.xl(d);71!==f&&(d.seek(e+192),
|
|
19
|
+
f=_.xl(d));71!==f&&(d.seek(e+204),f=_.xl(d));71!==f&&c();MH(d)}function c(){throw new _.H(_.F,4,4030);}const d=new _.ym(new DataView(a),!1);let e=0,f=0;e=KI(d);0>e&&(_.su.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.xl(d);71!==f&&c();a=_.yl(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.xl(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.xl(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.xl(d)>>6;0!==a&&1!==a||c();0===_.xl(d)&&
|
|
20
|
+
c();a=_.xl(d);const g=_.yl(d),h=_.yl(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},OI=function(a){const b=MI(a),c=NI(a);a.forEach(d=>{const e=d.V,f=e.findIndex(h=>h.ia===b);let g=e.findIndex(h=>h.ia===c+1);-1===g&&(g=e.length);d.V=e.slice(f,g)})},NI=function(a){a=a.map(b=>b.V[b.V.length-1].ia);return Math.min(...a)},MI=function(a){a=a.map(b=>b.V[0].ia);return Math.max(...a)},RI=function(a){var b=LH(a,EH);if(!PI.includes(b))return QI.error("PlayReady in HLS is only supported with [",
|
|
21
|
+
PI.join(", "),"], not",b),null;a=LH(a,_.Mb);b=_.as(a);a=null;b=_.J(b.data);try{a=_.RA(_.Fm(b))}catch(c){a=b}return _.dB(_.xd,[{initDataType:_.$c,initData:a}],"")},TI=function(a){if(0===a.length)return SI();if(a.some(c=>c.type===KH)||a.every(c=>c.type===_.Ee))return a[0];a=a.filter(c=>c.type===JH);const b=_.Eh(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:JH,drmInfos:b}},WI=function(a){a=UI(a);if(a.some(b=>VI(b))&&1<a.length)throw new _.H(_.F,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");
|
|
22
|
+
},VI=function(a){return OH(a.ba,_.Ga).some(b=>"AES-128"===_.I(b,EH))},YI=function(a,b,c){return UI(a).map(d=>XI(d.ba,b,c))},ZI=function(a){return a.filter(b=>RH(b.ba,_.Ga)).length},UI=function(a){return a.filter(b=>RH(b.ba,_.Ga))},XI=function(a,b,c){a=OH(a,_.Ga);if(0===a.length)return null;var d=LH(a[0],EH);if(1===a.length){if("NONE"===d)return SI();if("AES-128"===d)return a=a[0],d=_.I(a,"IV",""),{type:KH,keyInfo:{method:"AES-128",url:UH(b,LH(a,_.Mb)),iv:d?_.Fi((d||"0x").slice(2)):null},drmInfos:[],
|
|
23
|
+
keyId:null}}b=a.map(e=>LH(e,EH));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===FH))throw $I.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.F,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.I(e,"KEYFORMAT","identity");{const g=aJ[f]||null;e=g?g(e,c):null}e||$I.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.F,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),
|
|
24
|
+
[]).reverse()[0]||null,type:JH,drmInfos:b}},SI=function(){return{type:_.Ee,keyInfo:null,drmInfos:[],keyId:null}},bJ=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.HB(b.Ra(),b.xa,b.xa+2048-1,a.a.attemptParameters);e.type=2;const f=_.HB(b.Ra(),b.xa,b.ma,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.",
|
|
25
|
+
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 _.H(_.F,4,4030,"Failed to fetch the media segment.");}}})},cJ=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Ic||d===_.Hc)return 0;if(d===_.Gc){var g=yield bJ(a,c,f);const h=_.J(g.data);return HI(h)?II(h):LI(g.data)}if(d===_.mg||d===_.Jc)return g=[bJ(a,c,f)],b&&g.push(bJ(a,b,!0)),g=yield Promise.all(g),
|
|
26
|
+
JI(g[0].data,(g[1]||g[0]).data);if(d===_.lg)return g=yield bJ(a,c,f),LI(g.data);if(!_.Vp(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.F,4,4030);})},dJ=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},qI=function(a,b){a.streams.forEach(c=>{c.codecs=b.join(",")})},nI=function(a){return a.streams[0]},eJ=function(a,b){a.streams.forEach(c=>{c.Qd=b})},fJ=function(a,b){a.streams.forEach(c=>{c.width=b})},gJ=function(a,b){a.streams.forEach(c=>{c.height=b})},
|
|
27
|
+
hJ=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},iJ=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},jJ=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},kJ=function(a,b){const c=new Set(a.map(d=>d.ia));return b.filter(d=>!c.has(d.ia))},nJ=function(a,b){for(;a[0].ia<b[0].ia;)a.splice(0,1);var c=a[0];let d=b[0];lJ(c,d)||mJ(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&!lJ(c,d)&&mJ(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},oJ=function(a,b){const c=a[a.length-1];var d=b.findIndex(f=>
|
|
28
|
+
f.ia===c.ia);const e=b[d];lJ(c,e)||mJ(c,e);for(d+=1;d<b.length;d++)a.push(b[d])},tJ=function(a,b,c,d,e){var f=b[0].length();f=GI(f).map(g=>{var h=jJ(b,g)||[];const k=dJ(c,g)||[];g=dJ(d,g)||[];{const l=[...pJ(h),...k,...g].filter(Boolean);qJ(l);const {ia:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ia:m}}return h});e&&rJ(f[0]);sJ(f);return f},pJ=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},
|
|
29
|
+
rJ=function(a){const b=pJ(a.variants)[0].V[0].Aa;a.startTime+=b;a.endTime+=b},sJ=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}},lJ=function(a,b){return a.startTime===b.startTime&&a.endTime===b.endTime},mJ=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;uJ(a.variants,b.variants);vJ(VH(a),VH(b))},uJ=function(a,b){const c=new Map(a.map(d=>[kI(d),d]));b.forEach(d=>{c.get(kI(d)).drmInfos=
|
|
30
|
+
d.drmInfos})},vJ=function(a,b){const c=new Map(a.map(d=>[d.Ba,d]));b.forEach(d=>{const e=c.get(d.Ba);e.V=d.V;e.segmentIndex.replace(d.V);e.Fc=d.Fc;e.je=d.je;e.duration=d.duration;e.df=d.df;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},qJ=function(a){const b=wJ(a);a.forEach(c=>{_.DB(c.segmentIndex,b);c.duration=b;c.je=c.Fc+b})},wJ=function(a){let b=Infinity;a.filter(YH).forEach(c=>{b=Math.min(b,c.duration)});return b},xJ=function(a,b){WH(b,(c,d)=>{_.QB(a,c.V,d.startTime)});_.IB(a.a,
|
|
31
|
+
b[0].startTime,b[b.length-1].endTime)},yJ=function(a){return null===a.j?[]:[a.j.audio,a.j.video].filter(b=>b).map(b=>b.Ba)},zJ=function(a,b){return _.x(function*(){var c=_.Si([b],a.a.attemptParameters);c.type=1;c=yield a.G(c);let d="";try{d=_.oi(c.data)}catch(e){throw new _.H(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},FJ=function(a,b){return _.x(function*(){var c=AJ(a,b,a.w,"");if(1===c.type){c=_.Ps(c.V[0].a)||"";c=null!=_.Os.video[c]?_.w:null!=_.Os.audio[c]?
|
|
32
|
+
_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");c=a.L;var e=a.w;d=a.a.hlsDefaultCodecs||d;var f=[],g=[];g.push(new _.Li(_.ma,"0"));g.push(new _.Li(_.Mb,e));d.length&&g.push(new _.Li(_.pa,d));f.push(new _.Mi(c.f++,BH,g));c=new zI(e,0,f)}d=c.ba;c=OH(d,"EXT-X-MEDIA");e=OH(d,BH);d=OH(d,"EXT-X-IMAGE-STREAM-INF");c={Ec:{dg:QH(c,["AUDIO",_.Sb]),closedCaptions:QH(c,yH),wh:QH(c,GH)},md:e,ee:d};const {periods:h,ih:k,yh:l}=yield BJ(a,c);if(!a.D)throw new _.H(_.F,7,7001);c=mI(h[0]);CJ(a,h);
|
|
33
|
+
e=!0;d=null;f=0;DJ(a)||(e=!1,d=0,f=c.delay);g=a.a.timeline||{};g.type=void 0;d=new _.jH(g,d,f,!0,void 0,!!a.a.lowLatencyMode);_.MB(d,e);xJ(d,h);k&&_.LB(d,k);e=d;if(!DJ(a)){a.C=c.pc;c=0;for(var m of a.f.values())c=Math.max(c,m.streams[0].Fc);for(m=0;95443.7176888889<=c;)m+=95443.7176888889,c-=95443.7176888889;if(m){a.g.debug("Offsetting live streams by",m,"to compensate for rollover");for(var n of a.f.values())c=n.streams[0],95443.7176888889>c.Fc?(a.g.debug("Offset applied to",c.type),c.segmentIndex.offset(m)):
|
|
34
|
+
a.g.debug("Offset NOT applied to",c.type)}}n=jI(h);"LIVE"===a.l||"EVENT"===a.l?(n=Math.max(n,e.J),isNaN(a.a.availabilityWindowOverride)||(n=a.a.availabilityWindowOverride),e.A=n):a.l===_.Tb&&(e.f=n);EJ(a,l);n={presentationTimeline:e,adaptedPeriods:[...h],periods:h,minBufferTime:0};a.g.debug("HLS playlist parsed",n);return n})},HJ=function(a,b){return Promise.all(b.map(c=>GJ(a,c)))},JJ=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.a),e=!DJ(a),f=SH(c.ba,_.Ea);if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-
|
|
35
|
+
1].V,f=f[f.length-1].ia):f=0;if(e&&0<f)try{{const k=SH(c.ba,_.Ia);if(!k)throw IJ.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(CH);const l=Number(k.value),m=d.find(l);if(!m)throw IJ.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(CH);var h=m.ia}g=h;break a}catch(k){throw new _.H(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");
|
|
36
|
+
}g=0}}c=c.V||[];for(const k of c)RH(k.ba,_.Da)&&g++,k.ia=g});OI(b)},MJ=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,eg:e}=yield KJ(a,b);var f=a.o.periods[0].variants;a.a.lowLatencyMode&&null!==a.j&&(f=f.filter(g=>g.id===a.j.id));f=f.map(g=>{const h=sI(g.audio,e),k=sI(g.video,e);g=LJ(a,h,k,g.bandwidth);if(!g)throw new _.H(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",ai:k?nI(k).Ba:void 0,audio:h?nI(h).Ba:void 0});return g});return tJ(a.D.configurationId,
|
|
37
|
+
f,c,d,!0)})},CJ=function(a,b){DJ(a)||2!==a.a.timeline.version||(a.H||(a.H=b[0].startTime),_.nD(b,-a.H))},NJ=function(a,b){b=b.flatMap(d=>d.V[0].ba);b=SH(b,_.Na);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},OJ=function(a,b,c){b=b.find(d=>null!==SH(d.ba,_.Ca));if(!b)return[];if(null===c)throw new _.H(_.F,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");
|
|
38
|
+
return b.ba.filter(d=>d.name===_.Ca).map(d=>{a:{var e=a.A,f=!DJ(a),g=_.I(d,"ID"),h=_.I(d,"START-DATE");if(null===g||null===h)_.Ss.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);h=k.getTime()/1E3+e;g={id:g,startTime:h,startDate:k};f=NH(_.I(d,AH));void 0!==f&&0<=f&&(g.duration=f);var l=NH(_.I(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.I(d,"CLASS");null!==m&&(g.schemeIdUri=
|
|
39
|
+
m);var n=_.I(d,"END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var q=null;else{k={};for(q of v)q.name.startsWith("X-")&&(k[q.name]=q.value);q=_.Sg(k)?k:null}}q=q||{};if(k=_.I(d,"CUE"))q.Gh=k.split(",");if(m===_.wd){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.$b:m[_.$b]=u.value;break;case _.Zb:m[_.Zb]=u.value;break;case _.bc:m[_.bc]=NH(u.value);break;case _.ac:m[_.ac]=NH(u.value);break;case "X-SNAP":m["X-SNAP"]=
|
|
40
|
+
u.value.split(",");break;case "X-RESTRICT":m["X-SNAP"]=u.value.split(",")}m[_.$b]&&m[_.Zb]||!m[_.$b]&&!m[_.Zb]?(_.Ss.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.Sg(m)?m:null}if(null===u){_.Ss.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}q=Object.assign(q,u)}_.Sg(q)&&(g.ta=q);g.endTime=n?n.getTime()/1E3+e:f?h+f:l?h+l:h;g.type=_.ae;d=g}}return d}).filter(Boolean)},EJ=function(a,b){for(const c of b){if((b=
|
|
41
|
+
a.F.get(c.id))&&b.startTime!==c.startTime)a.D.onError(new _.H(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${c.id}`));b||(a.F.set(c.id,c),a.D.onTimelineCueAdded({configurationId:a.D.configurationId,schemeIdUri:c.schemeIdUri,ta:c.ta,value:"",startTime:c.startTime,endTime:c.endTime,id:c.id,type:_.ae,eventElement:null}))}},PJ=function(a,b,c){a.l=_.Tb;_.MB(b,!0);b.f=c[c.length-1].endTime},AJ=function(a,b,c,d){a=EI(a.L,b,c);a.a=d;return a},BJ=function(a,b){return _.x(function*(){var c=pI(b.Ec.closedCaptions),
|
|
42
|
+
d=QJ(a,b.md),e=yield RJ(a,b),f=Object.values(e).flat().map(g=>g.playlist);JJ(a,f);f=yield SJ(a,e.Ve,d);c=yield TJ(a,e.md,f,c);d=yield UJ(a,e.vh,d);f=yield VJ(a,e.ee);d=tJ(a.D.configurationId,c,d,f,!DJ(a));a.D.filterAllPeriods(d);c=[...e.md,...e.Ve].map(g=>g.playlist);e=NJ(a,c);c=OJ(a,c,e);return{periods:d,ih:e,yh:c}})},KJ=function(a,b){return _.x(function*(){const c=g=>nI(g.stream).type===_.w||nI(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=nI(h.stream);k={language:k.language,
|
|
43
|
+
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.Ba,Od:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return WJ(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);XJ(a,d.concat(f));e=f.filter(g=>nI(g).type===_.MA);f=f.filter(g=>nI(g).type===_.de);return{textStreams:e,thumbStreams:f,eg:d}})},LJ=function(a,
|
|
44
|
+
b,c,d){const e=[],f=(c||b).length();for(let m=0;m<f;m++){var g=b?b.streams[m]||null:null,h=c?c.streams[m]||null:null,k=g,l=h;k=k&&l?_.lB(k.drmInfos,l.drmInfos)?_.kB(k.drmInfos,l.drmInfos):null:k?k.drmInfos:l?l.drmInfos:null;if(!k)return null;l=d;g={id:a.O++,language:g?g.language:_.ag,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new YJ(e)},WJ=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,
|
|
45
|
+
e=b.type,f=b.$c,g=b.groupId,h=b.primary;var k=b.kind;const l=b.name,m=b.channelsCount,n=b.spatialAudio,q=b.closedCaptions,u=b.Od,v=_.bi(f||_.ag);if(1!==c.type)throw new _.H(_.F,4,4017);var y=ZH(c.ba,null==a.o);a.l=y;const B=lI(c.ba,y,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);y=yield ZJ(a,c,e,d);const D=a.a.lowLatencyMode?_.BA:_.AA;let M=k;e!==_.G||k||(M=_.MA);const {pd:da}=dI(c.ba);k=y.map(vb=>{const Ub=vb.V,pd=vb.pg,kg=vb.mimeType;vb=vb.ia;const Wa=Ub[0].startTime,le=Ub[Ub.length-1].endTime,
|
|
46
|
+
Oc=le-Wa,ea=new _.kH(Ub),$a=Ub[0].initSegment||null;return{id:_.oH++,originalId:l,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ea.find.bind(ea),getSegmentReference:ea.get.bind(ea),adjustSegmentDurations:ea.f.bind(ea),getDuration:ea.getDuration.bind(ea),segmentIndex:ea,segmentLookupStrategy:D,initSegmentReference:$a,mimeType:kg,codecs:d,kind:M,df:pd.type,encrypted:pd.type===JH,keyId:pd.keyId,language:v,originalLanguage:f||_.ag,label:l,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,
|
|
47
|
+
frameRate:u?u.frameRate:void 0,width:u?u.width:void 0,height:u?u.height:void 0,bandwidth:void 0,roles:[],channelsCount:m,spatialAudio:n,closedCaptions:q,keyInfo:pd.keyInfo,V:Ub,drmInfos:pd.drmInfos,ia:vb,Ba:c.a,Qd:c.f,Fc:Wa,je:le,duration:Oc,pd:da,groupId:g,Ug:B}});return new $J(k)})},XJ=function(a,b){b.forEach(c=>{a.f.a.set(nI(c).Ba,c)})},QJ=function(a,b){const c=new Map;for(const f of b){var d=_.I(f,"AUDIO");b=_.I(f,_.Sb);var e=_.I(f,GH);const g=aK(a,f);if(e){const h=_.zj(_.G,g);c.set(`${_.G}:${e}`,
|
|
48
|
+
h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=bK(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=bK(_.w,g),c.set(`${"video"}:${b}`,d))}return c},RJ=function(a,b){return _.x(function*(){const c=yield Promise.all([cK(a,b.Ec.dg),cK(a,b.Ec.wh),cK(a,b.md),cK(a,b.ee)]),[d,e,f,g]=c;return{Ve:d,vh:e,md:f,ee:g}})},SJ=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[dK(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>dK(a,e,c)));d=yield Promise.all(d);return oI(d)})},TJ=function(a,b,c,
|
|
49
|
+
d){return _.x(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(LH(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield eK(a,h,c,d,e);f=f.map(k=>eK(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.aB,[])})},UJ=function(a,b,c){return Promise.all(b.map(d=>dK(a,d,c)))},VJ=function(a,b){return Promise.all(b.map(c=>fK(a,c)))},DJ=function(a){return a.l===_.Tb},cK=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>
|
|
50
|
+
_.x(function*(){const d=yield gK(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},GJ=function(a,b){return _.x(function*(){var c=new _.Mh(nI(b).Qd);if(a.a.lowLatencyMode&&nI(b).pd){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={Xg:d.position,dh:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Xg,e=e.dh,f=_.lj(c.a.toString()),f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.kj(f,!0),
|
|
51
|
+
d=new _.Vh(d),_.Rh(c,d)}const {response:g,text:h}=yield zJ(a,c.toString());c=nI(b).Ba;d=nI(b).Qd;e=g.uri;d!==e&&(d=e,eJ(b,d));c=AJ(a,h,d,c);return{stream:b,playlist:c}})},aK=function(a,b){var c=_.I(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.qB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},bK=function(a,b){if(1===b.length)return b[0];a=_.zj(a,b);if(null!=a)return a;throw new _.H(_.F,4,4025,{codecList:b});
|
|
52
|
+
},dK=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return hK(a,e.a,()=>_.x(function*(){const f=LH(d,_.Va),g=$H(LH(d,_.Kb));var h=LH(d,_.Kb).toUpperCase();if($H(h)!==_.G)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.MA;h===yH&&(l=_.wA);k&&(l=_.Wd);h=l}k=c.get(`${g}:${f}`)||"";l=_.I(d,_.cb);const m=_.I(d,"NAME"),n=d.getAttribute("DEFAULT"),q=d.getAttribute("AUTOSELECT");var u=_.I(d,"CHANNELS");u=g===_.p?u?parseInt(u.split("/")[0],
|
|
53
|
+
10):null:null;var v=g===_.p?(v=_.I(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield WJ(a,{playlist:e,codecs:k,type:g,$c:l,primary:!!n&&!!q,name:m,channelsCount:u,spatialAudio:v,groupId:f,kind:h,closedCaptions:null,Od:null})}))})},fK=function(a,b){return _.x(function*(){const c=b.tag,d=b.playlist;return hK(a,d.a,()=>_.x(function*(){var e=_.I(c,_.pa)||"jpg",f=_.I(c,_.cb);const g=_.I(c,"NAME");e=yield WJ(a,{playlist:d,codecs:e,type:_.de,$c:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,
|
|
54
|
+
closedCaptions:null,groupId:null,Od:null});(f=_.I(c,_.ma))&&iJ(e,Number(f));return e}))})},eK=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(LH(f,_.ma));if(null!=f.getAttribute("FRAME-RATE")||null!=f.getAttribute(_.Cb)){var h=_.I(f,"FRAME-RATE");f=_.I(f,_.Cb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:NH(h),width:NH(k),height:NH(l)}}else h=null;if(f=yield iK(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 q of h){m=
|
|
55
|
+
(q?nI(q).Ba:"")+" - "+(n?nI(n).Ba:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=LJ(a,n,q,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})},iK=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist;let h=aK(a,f);var k=_.I(f,"AUDIO"),l=_.I(f,_.Sb);k=k?d.get(`${"audio"}:${k}`)||[]:[];var m=l?d.get(`${"video"}:${l}`)||[]:[];l=[...k,...m];k={audio:k,video:m};a.g.debug("Guessing stream type for",
|
|
56
|
+
f.toString());f=!1;const n=g.a;g=k.audio.find(q=>nI(q).Ba===n);m=_.zj(_.w,h);m=c||m;1!==h.length||m?!l.length&&1<h.length?(a.g.debug("Guessing multiplexed audio+video"),g=_.w,h=[h.join(",")]):k.audio.length&&g?(a.g.debug(DH),g=_.p,f=!0):k.video.length?(a.g.debug(DH),g=_.p):(a.g.debug("Guessing video-only"),g=_.w):(g=_.p,a.g.debug(DH));m=null;f||(m=yield jK(a,b,h,g,e,c));if(null==m)return null;k[g]=[m];g===_.p&&c&&l.forEach(q=>{fJ(q,c.width);gJ(q,c.height);hJ(q,c.frameRate)});rI(k);return k})},jK=
|
|
57
|
+
function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.playlist;return hK(a,h.a,()=>_.x(function*(){var k=_.I(g,yH);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=bK(d,c);return yield WJ(a,{playlist:h,codecs:k,type:d,closedCaptions:l,primary:!1,kind:null,$c:null,name:null,channelsCount:null,spatialAudio:!1,groupId:null,Od:f})}))})},hK=function(a,b,c){if(a.f.has(b))return a=a.f.get(b),Promise.resolve(a);if(a.f.f.has(b))return a.f.f.get(b)||null;c=c();a.f.set(b,c);return c},ZJ=function(a,
|
|
58
|
+
b,c,d){return _.x(function*(){var e=b.a,f=b.V;var g=void 0===g?0:g;var h=(h=SH(b.ba,_.Ia))?Number(h.value):g;g=[];!DJ(a)&&WI(f);e=yield kK(a,b.f,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)RH(m.ba,_.Da)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield lK(a,b.f,k,h,e,c,d,g[g.length-1]||null,f.length),g.push(l),h+=k.length;mK(g);return g})},gK=function(a,b){return _.x(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.I(b,_.Kb)===GH;c=_.I(b,
|
|
59
|
+
_.Mb,void 0,{required:c});if(!c)return null;const d=UH(a.w,c),{response:e,text:f}=yield zJ(a,d);return AJ(a,f,e.uri,c)})},mK=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},nK=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.I(c,_.Mb))||null).map(b=>_.Ps(b));if(1<(new Set(a)).size)throw new _.H(_.F,4,4044,"Unexpected change in file format.");},oK=function(a,b,c){a=
|
|
60
|
+
OH(a.ba,_.Ha);if(1<a.length)throw new _.H(_.F,4,4020);a=a[0];if(!a)return null;const d=LH(a,_.Mb),e=UH(b,d);b=eI(a,null,!0);return new _.gH(()=>[e],b.xa,b.ma,c)},pK=function(a,b,c,d,e,f,g){const h=[];for(const q of _.iB(b.f)){b=q.rf;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.I(u,AH));n=m+n;k=eI(u,k?null:l.ma,k);l=_.I(u,_.Mb);const v=(l=UH(g,l))?[l]:[];m=new fI(c,m,n,()=>v,k.xa,k.ma,e,f,!1,null,null,null,null);if("YES"===_.I(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},
|
|
61
|
+
qK=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var q=c.a;0<OH(n,_.Ha).length&&(m=oK(c,k,g));const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={xa:0,ma:null};let y=null;u?({duration:c}=cI(n),a=e+c,q=bI(n,b?b.ma:null)):(b=pK(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.de?TH(n):null;d=new fI(d,e,a,()=>v,q.xa,q.ma,f,g,!1,null,h?h.Uc:null,h?h.ld:null,h?h.durationPerTile:null,y,m);d.ia=l;return d},kK=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.A)return a.A;
|
|
62
|
+
if(!DJ(a)&&a.o)try{var k=a.f.get(c);var l=k?k.find(e)||null:null;if(!l)throw new _.H(_.F,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Aa;a.g.debug(`Setting playlist start time to ${m}.`);return a.A=m}catch(n){if(h=a.f.get(c))m=h.streams[h.streams.length-1].V,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].V[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.H(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
|
|
63
|
+
uri:c});}m=yield rK(a,f,g,h);k=XI(h.ba,a.w,m)||SI();l=oK(h,b,k.keyInfo);k=hI(k.keyInfo,e);h=yield sK(a,l,h,k,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.A=h})},lK=function(a,b,c,d,e,f,g,h,k){return _.x(function*(){var l=c[0],m=null==h;nK(c);const n=yield rK(a,f,g,l);var q=a.w,u=h?h.Tg:null;var v=1===k;if(c.slice(1).some(VI))throw new _.H(_.F,4,4046,v?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");
|
|
64
|
+
if(RH(c[0].ba,_.Ga)||null===u)if((u=XI(c[0].ba,q,n))&&u.type===KH){if(1<ZI(c))throw new _.H(_.F,4,4046,HH+`${v?"playlist":"discontinuity"}.`);v=[u]}else v=YI(c,q,n),v=0===v.length?[SI()]:v;else if(q=YI(c,q,n),u.type===_.Ee||u.type===JH)v=[u,...q];else{if(0<ZI(c))throw new _.H(_.F,4,4046,HH+`${v?"playlist":"discontinuity"}.`);v=[u]}q=v;v=q[q.length-1];q=TI(q);u=oK(l,b,q.keyInfo)||(h?h.Ng:null);var y=hI(q.keyInfo,d);const B=l.ia;l=m?e:yield tK(a,B,u,l,d,y,n,g);m=[];for(y=0;y<c.length;y++){var D=c[y];
|
|
65
|
+
const M=m[m.length-1]||null,da=0===y?0:M.endTime,vb=d+y,Ub=hI(q.keyInfo,vb);if(D=qK(a,M,D,vb,da,l,Ub,f,b,B,u))u=D.initSegment,m.push(D)}return{V:m,pg:q,Tg:v,mimeType:n,endTime:m[m.length-1].endTime,ia:B,Ng:u}})},rK=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=SH(d.ba,_.Ha);f=f?LH(f,_.Mb):null;return uK(a,b,c,e,f)})},sK=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=gI(c,d);return cJ(a.N,b,g,e,f,null!=d)})},tK=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.I.has(b))return a.I.get(b);
|
|
66
|
+
const k=yield sK(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.I.set(b,k);return k})},uK=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.Cj(f,b,c);if(g)return g;g=_.Si([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.G(g)).headers["content-type"];if(!g)throw new _.H(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},zI=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.F,4,
|
|
67
|
+
4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.F,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.ba=c;this.V=1===b?d:null}},FI=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=a;this.f=c;this.ia=-1}},fI=class extends _.bC{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===
|
|
68
|
+
q?null:q,u,void 0===v?null:v);this.ia=0}},vK=class{constructor(){this.f=0;this.a=new Map}},wK=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},IJ=new _.R("clpp.hls.DiscontinuityUtils");var aJ={"com.apple.streamingkeydelivery":function(a,b){if(b===_.lg)throw new _.H(_.F,4,4041);if(LH(a,EH)===FH)throw new _.H(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.dB(_.vd,[{initDataType:_.Jf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":RI,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":RI,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=LH(a,EH);if(!PI.includes(b))return QI.error("Widevine in HLS is only supported with [",
|
|
69
|
+
PI.join(", "),"], not",b),null;b=LH(a,_.Mb);b=_.as(b);b=_.J(b.data);b=_.dB(_.zd,[{initDataType:_.$c,initData:b}],"");if(a=_.I(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},PI=["SAMPLE-AES",FH],QI=new _.R("clpp.hls.DrmParser");var $I=new _.R("clpp.hls.EncryptionUtils");var xK=class{constructor(a){this.g=new _.R("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.Pi()}}};var $J=class{constructor(a){this.streams=a}length(){return this.streams.length}find(a){const b=this.streams.find(c=>{c=c.V;return c[0].position<=a&&a<=c[c.length-1].position});return null==b?null:b.V.find(c=>c.position===a)||null}};var YJ=class{constructor(a){this.a=a}length(){return this.a.length}};var yK=class{constructor(){this.a=this.D=null;this.O=1;this.f=new wK;this.w="";this.L=new vK;this.C=0;this.j=null;this.h=new _.Tj(()=>{this.Hb()});this.l=_.Tb;this.o=null;this.B=new _.Xs;this.A=null;this.g=new _.R("clpp.hls.HlsParser");this.I=new Map;this.N=new xK(this.G.bind(this));this.K=!1;this.H=null;this.J=!1;this.F=new Map}configure(a){this.a=a;this.N.a=a}setCurrentVariant(a){this.j=a}start(a,b){const c=this;return _.x(function*(){if(c.K)throw Error("start() may be called only once!");c.K=!0;
|
|
70
|
+
c.D=b;const {response:d,text:e}=yield zJ(c,a);c.w=d.uri;const f=yield FJ(c,e);c.o=f;const g=c.C;c.h&&0<g&&c.h.ha(g);return f})}requestStop(){this.J=!0}stop(){this.h&&(this.h.stop(),this.h=null);const a=[];this.B&&(a.push(this.B.destroy()),this.B=null);this.f.clear();this.o=this.a=this.D=this.j=null;this.F.clear();return Promise.all(a)}update(){const a=this;return _.x(function*(){const b=a.o;if(!DJ(a)&&b){var c=b.presentationTimeline;"LIVE"===a.l&&(a.A=null);var d=Array.from(a.f.values());if(a.a.lowLatencyMode&&
|
|
71
|
+
null!==a.j){const g=yJ(a);d=d.filter(h=>g.includes(nI(h).Ba))}var e=yield HJ(a,d);d=e.map(g=>g.playlist);JJ(a,d);e=yield MJ(a,e);kJ(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});CJ(a,e);var f=NJ(a,d);f=OJ(a,d,f);EJ(a,f);nJ(b.periods,e);oJ(b.adaptedPeriods,e);xJ(c,e);if(d=XH(d))!0!==a.a.keepTimelineLive&&PJ(a,c,e),a.h.stop(),a.h=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.J&&(yield a.stop())}})}Hb(){const a=this;return _.x(function*(){a.g.debug(_.rA);if(a.D)try{yield a.update(),
|
|
72
|
+
a.h&&0<a.C&&a.h.ha(a.C)}catch(b){if(!(b instanceof _.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.h&&a.h.ha(.1))}})}G(a){if(!this.B)throw new _.H(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.Zi(this.B,a);return a.R}};_.z("clpp.hls.HlsComponent",class extends _.Yt{f(){_.Br.m3u8=yK;_.zr[_.Ok]=yK;_.zr[IH]=yK}a(){_.AC("m3u8");_.BC(_.Ok);_.BC(IH)}id(){return"hls"}});};f.call(g, window);
|
package/cl.hlssmpte.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
else a.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var UR=function(a){a.a.one(a.m,_.re,()=>TR(a))},TR=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.tc,d=>VR(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.ye).forEach(d=>{VR(a,{track:d})});!WR(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),YR(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
|
|
2
|
+
else a.g.warn("A video element is not available. Skipping.")},VR=function(a,b){b=b.track;b.kind===_.ye&&(a.g.info("The metadata track has been added."),b.mode=_.$d,a.a.on(b,_.Cd,c=>ZR(a,c)))},WR=function(a){return a.some(b=>b.kind===_.ye)},YR=function(a,b){const c=a.m.getTrackManager(),d=c.na(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.wa(d);a.a.on(b.textTracks,_.tc,g=>{g.track.kind===_.ye&&(a.a.off(b.textTracks,_.tc,f),c.wa(d))});c.wa(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
ZR=function(a,b){const c=$R(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new aS(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.si(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},$R=function(a){return(a=a.m.getTrackManager().ua())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
aS=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.A(a)){a:{var b=a.info;if(_.Wg(b)&&(b=b.toLowerCase().match(/lang:(\w+)/))&&b[1]){b=b[1].toLowerCase();break a}b=null}this.f=b;a=a.data;this.a=a=_.Wg(a)?a:null}}};var bS=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.ts;this.h=(a=_.hs(_.Dc))?new a(this.m.getConfiguration()):null;this.g=new _.R("clpp.hlssmpte.ImageCueHandler");this.f=null;UR(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var cS=class extends _.Au{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.hk()){var b=a.getConfiguration();b=_.Qg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Pc&&(b.patchMetadataTrack=!1);_.Xg(b.timestampOffset)||(b.timestampOffset=0);this.a=new bS(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",cS);
|
|
5
|
+
cS.Id="hlssmpte";_.dp(new class{create(){return new cS}});};f.call(g, window);
|