@castlabs/prestoplay 6.25.2 → 6.26.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 +15 -0
- package/README.md +5 -5
- 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 +112 -112
- package/cjs/cl.conviva.js +32 -32
- package/cjs/cl.core.js +601 -600
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +89 -88
- package/cjs/cl.externs.js +37 -31
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +77 -77
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +23 -23
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +341 -334
- 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 +16 -16
- package/cjs/cl.simid.js +17 -17
- package/cjs/cl.smooth.js +72 -72
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +71 -71
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +12 -12
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.yospace.js +4 -4
- package/cjs/cl.youbora.js +38 -36
- 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 +489 -488
- package/cl.crypto.js +9 -9
- package/cl.dash.js +82 -82
- package/cl.externs.js +37 -31
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +79 -80
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +17 -17
- package/cl.mediatailor.js +3 -3
- package/cl.mse.js +299 -292
- 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 +14 -14
- package/cl.smooth.js +60 -60
- 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 +14 -14
- package/cl.vtt.js +12 -12
- package/cl.yospace.js +3 -3
- package/cl.youbora.js +28 -27
- package/package.json +3 -3
- package/typings.d.ts +41 -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 _.I(1,9,12001,{missingKeys:b.join(", ")});},
|
|
3
|
-
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.
|
|
4
|
-
a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},
|
|
5
|
-
!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return
|
|
6
|
-
0}getPosition(){return 0}getSkipTimeOffset(){return 0}Tb(){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():""}fb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}eb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}
|
|
7
|
-
case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.
|
|
8
|
-
Y.prototype.getVideoElement=Y.prototype.Sb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.canSeek=Y.prototype.canSeek;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.gb;Y.prototype.getPositionInSequence=Y.prototype.sb;Y.prototype.getPodTimeOffset=Y.prototype.Hb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.
|
|
9
|
-
Y.prototype.getMediaBitrate=Y.prototype.
|
|
10
|
-
Y.prototype.getAdSystem=Y.prototype.getAdSystem;Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Qb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.ub;Y.prototype.getAdManagerVersion=Y.prototype.pb;Y.prototype.getAdManagerName=Y.prototype.ob;var
|
|
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.w&&(a.w.stop(),a.w=null);
|
|
15
|
-
9,10003,{errorType:0},void 0));this.A.resolve()}M(a){
|
|
16
|
-
_
|
|
17
|
-
_.
|
|
18
|
-
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.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 aV="clpp-freewheel",bV="clpp.freewheel.AdsManagerFactory",cV="freewheel",dV=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""}},eV=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Pf&&b.push("serverUrl");typeof a.profileId!==_.Pf&&b.push("profileId");typeof a.videoAssetId!==_.Pf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
|
|
2
|
+
if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},fV=function(){return _.x(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})},gV=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
|
|
3
|
+
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.ag,a.I.bind(a));a.j.on(a.m,_.Mf,a.H.bind(a))},jV=function(a){return _.x(function*(){a.G.length?(hV(a),a.f=a.G.shift(),a.f.play()):(iV(a),yield a.m.a.play())})},iV=function(a){const b=a.m.kd(cV).Pc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},hV=function(a){const b=a.m.kd(cV).Pc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(aV),
|
|
4
|
+
a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},kV=function(a){a.F.length?(hV(a),a.f=a.F.shift(),a.f.play()):iV(a)},lV=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 _.F(b,d))},mV=class extends _.Sv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.rp(_.Cd,{id:aV}),this.f=_.rp(_.w,{"class":_.Zc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
|
|
5
|
+
!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return cV}Pc(){return this.a}xh(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",mV);mV.prototype.getAdVideo=mV.prototype.xh;mV.prototype.getAdContainer=mV.prototype.Pc;mV.Id=cV;mV.AD_CONTAINER_ID=aV;_.Mr(new class{create(){return new mV}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}ob(){return"FreeWheel AdManager SDK"}pb(){return tv.freewheel.SDK.version}ub(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Pf?a:""}Qb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
|
|
6
|
+
0}getPosition(){return 0}getSkipTimeOffset(){return 0}Tb(){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():""}fb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}eb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Qa(){return 0}Ra(){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.Ra()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Hb(){switch(this.Ra()){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}gb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Sb(){return null}};
|
|
8
|
+
Y.prototype.getVideoElement=Y.prototype.Sb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.canSeek=Y.prototype.canSeek;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.gb;Y.prototype.getPositionInSequence=Y.prototype.sb;Y.prototype.getPodTimeOffset=Y.prototype.Hb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Ra;
|
|
9
|
+
Y.prototype.getMediaBitrate=Y.prototype.Qa;Y.prototype.getMediaHeight=Y.prototype.eb;Y.prototype.getMediaWidth=Y.prototype.fb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.qb;Y.prototype.isBumper=Y.prototype.Tb;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getPosition=Y.prototype.getPosition;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;
|
|
10
|
+
Y.prototype.getAdSystem=Y.prototype.getAdSystem;Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Qb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.ub;Y.prototype.getAdManagerVersion=Y.prototype.pb;Y.prototype.getAdManagerName=Y.prototype.ob;var nV=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()}})}Kb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Jb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
|
|
11
|
+
nV.prototype.hasPostroll=nV.prototype.Jb;nV.prototype.hasPreroll=nV.prototype.Kb;nV.prototype.getCuePoints=nV.prototype.getCuePoints;var oV=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.j=new _.Rt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.Ij;this.w=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{eV(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Pf&&typeof b.siteSectionId!==
|
|
12
|
+
_.t||a.a.setSiteSection(b.siteSectionId);const c=yield fV();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,dV(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ee&&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);gV(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield jV(a)})}o(){}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}l(){return!0}h(){const a=this;return _.x(function*(){a.j.release();
|
|
14
|
+
a.w&&(a.w.stop(),a.w=null);iV(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.F(_.pc,{adsTimeline:new nV(this.a)})),this.w=new _.Iv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.kd(cV).f);else this.m.onError(new _.I(1,
|
|
15
|
+
9,10003,{errorType:0},void 0));this.A.resolve()}M(a){lV(this,_.Sb,a);this.w.start()}L(a){this.f=null;a=a.slot;lV(this,_.Tb);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:jV(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:iV(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:kV(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:lV(this,_.hc,a);lV(this,
|
|
16
|
+
_.ac,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:lV(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:lV(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:lV(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:lV(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:lV(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:lV(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:lV(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:lV(this,
|
|
17
|
+
_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:lV(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:lV(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:lV(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(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]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
|
|
18
|
+
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();hV(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Zo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Yo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Oo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);kV(this);break;case _.Wo:case _.Po:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
|
|
19
|
+
oV.prototype.getPosition=oV.prototype.getPosition;oV.prototype.setVolume=oV.prototype.setVolume;oV.prototype.getVolume=oV.prototype.getVolume;oV.prototype.skip=oV.prototype.skip;oV.prototype.pause=oV.prototype.pause;oV.prototype.resume=oV.prototype.resume;_.pp(new class{constructor(){this.Ta=new _.T(bV)}name(){return bV}a(a,b){return a.namespace()!==_.dd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Ta.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new oV(a)}});};f.call(g, window);
|
package/cl.hls.js
CHANGED
|
@@ -1,80 +1,79 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
--a.a},
|
|
3
|
-
/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.
|
|
4
|
-
_.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
b.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
c.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.ka(.1))}})}H(a){if(!this.F)throw new _.I(_.G,7,7001);a=this.D.networkingEngine.fetch(a);_.vj(this.F,a);return a.T}};_.z("clpp.hls.HlsComponent",class extends _.Av{f(){_.$s.m3u8=VM;_.Ys[_.kl]=VM;_.Ys[TJ]=VM}a(){_.RD("m3u8");_.SD(_.kl);_.SD(TJ)}id(){return"hls"}});};f.call(g, window);
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var NJ="CLOSED-CAPTIONS",OJ="Could not parse MP4 segment start time.",PJ="DURATION",QJ="EXT-X-DATERANGE",RJ="EXT-X-DISCONTINUITY",SJ="EXT-X-KEY",TJ="EXT-X-MAP",UJ="EXT-X-MEDIA",VJ="EXT-X-MEDIA-SEQUENCE",WJ="EXT-X-STREAM-INF",XJ="Failed to infer discontinuity number",YJ="Guessing audio-only",ZJ="METHOD",$J="SAMPLE-AES-CTR",aK="SUBTITLES",bK="application/vnd.apple.mpegurl",cK="manifestloaded",dK="sample",eK=function(a,b){return _.J(a,b,void 0,{required:!0})},fK=function(a){if(1>a.a)throw _.dm();
|
|
2
|
+
--a.a},gK=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ee&&e&&typeof e===_.Ee){if(!gK(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},hK=function(a,b){if(!gK(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Ee&&e&&typeof e===_.Ee&&hK(d,e))return!0}return!1},iK=function(a){if(null!==a&&void 0!==a)return Number(a)},jK=function(a,b){return a.filter(c=>c.name===b)},kK=function(a){const b=
|
|
3
|
+
/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.Ta),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.G,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},lK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=eK(d,
|
|
4
|
+
_.sb);return c.includes(d)})},mK=function(a,b){return a.some(c=>c.name===b)},nK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.G,4,4024,{missingTag:b});return a},oK=function(a){var b=nK(a,"EXT-X-TILES");if(!b)return{nd:1,Kd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,PJ);a=_.yC(a);return{nd:a.nd,Kd:a.Kd,durationPerTile:b?Number(b):null}},pK=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});
|
|
5
|
+
a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},qK=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of pK(c))b(d,c)})},rK=function(a){return a.some(b=>mK(b.ha,"EXT-X-ENDLIST"))},sK=function(a){return a.type===_.p||a.type===_.w},tK=function(a){if(nK(a,"EXT-X-ENDLIST"))return _.Db;a=nK(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.I(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);
|
|
6
|
+
},uK=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.H,"CLOSED-CAPTIONS":_.H}[a.toUpperCase()];if(!a)throw new _.I(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},vK=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 _.I(_.G,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.G,4,4044,"Invalid byte range, offset is required but missing.");
|
|
7
|
+
if(null==b)throw new _.I(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ma:d,ja:e}},wK=function(a,b){a=nK(a,"EXT-X-BYTERANGE");return vK(a?a.value:null,b)},xK=function(a){a=nK(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},yK=function(a,b){b=void 0===b?{}:b;const c={Lf:!1,gh:!1,hh:null,Nh:null,ug:null};a=nK(a,"EXT-X-SERVER-CONTROL",{required:b.Ag});if(!a)return c;const d=e=>null==e?null:Number(e);
|
|
8
|
+
c.Lf="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.gh="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.hh=d(_.J(a,"CAN-SKIP-UNTIL"));c.Nh=d(_.J(a,"HOLD-BACK"));c.ug=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.Ag}));return c},zK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return vK(a,b,c)},AK=function(a){const b=jK(a,UJ),c=jK(a,WJ);a=jK(a,"EXT-X-IMAGE-STREAM-INF");return{Bc:{Gf:lK(b,[_.uB,_.Cb]),closedCaptions:lK(b,NJ),Gi:lK(b,aK)},Ld:c,He:a}},CK=function(a,b){const c=wK(a.ha,null);return new BK(0,0,0,()=>
|
|
9
|
+
[a.a],c.ma,c.ja,0,b)},DK=function(a){let b=Infinity,c=Infinity;pK(a).filter(sK).forEach(d=>{{d=d.U;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{Vc:b,duration:c}},EK=function(a){return a.map(b=>{({duration:b}=DK(b));return b}).reduce((b,c)=>b+c,0)},FK=function(a){return(a.video?a.video.Da:"")+" - "+(a.audio?a.audio.Da:"")},GK=function(a,b,c,d,e){if(b===_.Db)return{delay:0,Jd:0};b=nK(a,"EXT-X-PART-INF");if(c&&b){e=Number(eK(b,"PART-TARGET"));
|
|
10
|
+
if(null!=d)return{delay:d,Jd:e};({ug:d}=yK(a,{Ag:!0}));return{delay:d,Jd:e}}a=nK(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,Jd:e}:{delay:3*a,Jd:e}},IK=function(a){const b=new Map;a.forEach(c=>{var d=`${HK(c).type}:${HK(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},JK=function(a){const b=new Map;for(const c of a){a=_.J(c,_.La);a=_.Di(a||_.fg);const d=eK(c,_.Fa),e=eK(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,
|
|
11
|
+
a)}return b},KK=function(a){return a.filter(b=>"mp4a.40.34"!==b)},LK=function(a,b){if(!a)return null;const c=a.Da;return b.find(d=>HK(d).Da===c)||null},MK=function(a){return(a=_.J(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},NK=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{fg:b,item:d,ji:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{fg:b,ji:c,item:d,next:void 0})},OK=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},PK=function(a,b){const c=new Map,d=new URL(b);
|
|
12
|
+
a.forEach(e=>{var f=_.J(e,_.Ta),g=_.J(e,"QUERYPARAM");if(f)g=eK(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.G,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.I(_.G,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},QK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.G,4,4044,`Undefined variable '${d}'`);return c})},
|
|
13
|
+
RK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=QK(d.value,b)})})},UK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=SK(a,b[e]);d.push(f);if(f.name===WJ){const g=b[e+1];if(!g)throw new _.I(_.G,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.kj(_.ub,g));e++}}b=jK(d,"EXT-X-DEFINE");kK(b);b=PK(b,c);a.a=b;RK(d,a.a);return new TK(c,0,d)},YK=function(a,b,c){const {vi:d,Kh:e,Pi:f}=VK(b),g=WK(a,f,c);b=e.map(k=>SK(a,k,g));const h=XK(a,c,d,g);return new TK(c,
|
|
14
|
+
1,b,h)},ZK=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(_.G,4,4015);b=b.slice(1);return 0===OK(b)?UK(a,b,c):YK(a,b,c)},VK=function(a){const b=[],c=[],d=[];for(const e of a)$K.test(e)?d.push(e):aL.test(e)?c.push(e):b.push(e);return{vi:b,Kh:c,Pi:d}},WK=function(a,b,c){b=b.map(e=>SK(a,e));kK(b);const d=PK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.G,
|
|
15
|
+
4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},SK=function(a,b,c){a=_.mj(a.h++,b);c&&RK([a],c);return a},XK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=SK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.J(h,_.sb)?g.push(h):f.push(h)):(mK(f,"EXT-X-GAP")||(h=QK(h,d),h=_.ij(h,b),e.push(new bL(h,f,g))),f=[],g=[])});0<g.length&&e.push(new bL(null,f,g));return e},cL=function(a,b,c){const d=
|
|
16
|
+
[],e=[];e.push(new _.kj(_.la,"0"));e.push(new _.kj(_.ub,b));c.length&&e.push(new _.kj(_.pa,c));d.push(new _.lj(a.h++,WJ,e));return new TK(b,0,d)},dL=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},eL=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},fL=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},gL=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+
|
|
17
|
+
("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(_.G,4,4030);}fL(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|
|
|
18
|
+
a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}fL(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},hL=function(a,b){let c=null,d=0;try{(new _.tm).N(_.Ae,_.mm).N(_.cg,_.mm).N(_.re,_.mm).ea("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 _.Mv.error("Unable to find timescale in init segment!"),new _.I(_.G,4,4030,OJ,c);let e=0,f=!1;try{(new _.tm).N("moof",_.mm).N("traf",_.mm).ea("tfdt",g=>{var h=d;if(0===g.version)h=
|
|
19
|
+
_.P(g.reader)/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 _.I(_.G,4,4030,OJ,c);return e},iL=function(a){for(;a.getPosition()<a.Pa()-1;){const b=a.getPosition();if(71===_.em(a))return fK(a),b}return-1},jL=function(a){function b(){d.seek(e+188);f=_.em(d);71!==f&&
|
|
20
|
+
(d.seek(e+192),f=_.em(d));71!==f&&(d.seek(e+204),f=_.em(d));71!==f&&c();fK(d)}function c(){throw new _.I(_.G,4,4030);}const d=new _.pn(new DataView(a),!1);let e=0,f=0;e=iL(d);0>e&&(_.Mv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.em(d);71!==f&&c();a=_.fm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.em(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.em(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.em(d)>>6;0!==a&&1!==a||c();
|
|
21
|
+
0===_.em(d)&&c();a=_.em(d);const g=_.fm(d),h=_.fm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},mL=function(a){const b=kL(a),c=lL(a);a.forEach(d=>{const e=d.U,f=e.findIndex(h=>h.ra===b);let g=e.findIndex(h=>h.ra===c+1);-1===g&&(g=e.length);d.U=e.slice(f,g)})},lL=function(a){a=a.map(b=>b.U[b.U.length-1].ra);return Math.min(...a)},kL=function(a){a=a.map(b=>b.U[0].ra);return Math.max(...a)},pL=function(a){var b=eK(a,ZJ);if(!nL.includes(b))return oL.error("PlayReady in HLS is only supported with [",
|
|
22
|
+
nL.join(", "),"], not",b),null;a=eK(a,_.ub);b=_.zt(a);a=null;b=_.K(b.data);try{a=_.gC(_.wn(b))}catch(c){a=b}return _.uC(_.rd,[{initDataType:_.Uc,initData:a}],"")},rL=function(a){if(0===a.length)return qL();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.De))return a[0];a=a.filter(c=>c.type===dK);const b=_.fi(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:dK,drmInfos:b}},uL=function(a,b){return sL(a).map(c=>tL(c.ha,b)).filter(Boolean)},sL=function(a){return a.filter(b=>
|
|
23
|
+
mK(b.ha,SJ))},tL=function(a,b){a=jK(a,SJ).filter(d=>"AES-128"!==eK(d,ZJ));if(0===a.length)return null;var c=eK(a[0],ZJ);if(1===a.length&&"NONE"===c)return qL();c=a.map(d=>eK(d,ZJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===$J))throw vL.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.J(d,"KEYFORMAT","identity");{const f=wL[e]||null;d=f?f(d,b):null}d||vL.warn("Unsupported HLS KEYFORMAT",
|
|
24
|
+
e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.G,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:dK,drmInfos:a}},qL=function(){return{type:_.De,drmInfos:[],keyId:null}},xL=function(a,b,c){a=jK(a,SJ)[0];if(!a||"AES-128"!==eK(a,ZJ))return null;var d=_.J(a,"IV","");d?c={iv:_.Pl((d||"0x").slice(2)),generatedIv:!1}:(d=_.J(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Sl(new Uint8Array(12),eL(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
|
|
25
|
+
generatedIv:f}=c;return{method:"AES-128",url:_.ij(eK(a,_.ub),b),iv:e,generatedIv:f}},yL=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.bD(b.Ea(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.bD(b.Ea(),b.ma,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.",
|
|
26
|
+
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(_.G,4,4030,"Failed to fetch the media segment.");}}})},zL=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Fc||d===_.Ec)return 0;if(d===_.Bc){var g=yield yL(a,c,f);g=_.K(g.data);if(!fL(g))throw new _.I(_.G,4,4030,"AAC segment does not contain an ID3 tag.");return gL(g)}if(d===_.rg||d===
|
|
27
|
+
_.Gc)return g=[yL(a,c,f)],b&&g.push(yL(a,b,!0)),g=yield Promise.all(g),hL(g[0].data,(g[1]||g[0]).data);if(d===_.qg)return g=yield yL(a,c,f),jL(g.data);if(!_.Ks(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.G,4,4030);})},AL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},BL=function(a,b){a=a.streams.find(c=>{c=c.U;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.U.find(c=>c.position===b)||null},HK=function(a){return a.streams[0]},
|
|
28
|
+
CL=function(a,b){a.streams.forEach(c=>{c.se=b})},DL=function(a,b){a.streams.forEach(c=>{c.width=b})},EL=function(a,b){a.streams.forEach(c=>{c.height=b})},FL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},GL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},HL=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},IL=function(a,b){const c=new Set(a.map(d=>d.ra));return b.filter(d=>!c.has(d.ra))},KL=function(a,b){for(;a[0].ra<b[0].ra;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
|
|
29
|
+
d.startTime&&c.endTime===d.endTime||JL(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&JL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},PL=function(a,b,c,d,e){var f=b[0].length();f=dL(f).map(g=>{var h=HL(b,g)||[];const k=AL(c,g)||[];g=AL(d,g)||[];{const l=[...LL(h),...k,...g].filter(Boolean);ML(l);const {ra:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ra:m}}return h});e&&NL(f[0]);
|
|
30
|
+
OL(f);return f},LL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},NL=function(a){const b=LL(a.variants)[0].U[0].Ca;a.startTime+=b;a.endTime+=b},OL=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}},JL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;QL(a.variants,b.variants);RL(pK(a),pK(b))},QL=function(a,b){const c=new Map(a.map(d=>[FK(d),
|
|
31
|
+
d]));b.forEach(d=>{c.get(FK(d)).drmInfos=d.drmInfos})},RL=function(a,b){const c=new Map(a.map(d=>[d.Da,d]));b.forEach(d=>{const e=c.get(d.Da);e.U=d.U;d.U.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.U);e.Vc=d.Vc;e.Le=d.Le;e.duration=d.duration;e.Tf=d.Tf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},ML=function(a){const b=SL(a);a.forEach(c=>{_.YC(c.segmentIndex,b);c.duration=b;c.Le=c.Vc+b})},SL=function(a){let b=Infinity;a.filter(sK).forEach(c=>{b=
|
|
32
|
+
Math.min(b,c.duration)});return b},TL=function(a,b){qK(b,(c,d)=>{_.kD(a,c.U,d.startTime)});_.cD(a.a,b[0].startTime,b[b.length-1].endTime)},UL=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Da)},VL=function(a,b){return _.x(function*(){var c=_.sj([b],a.a.attemptParameters);c.type=1;c=yield a.H(c);let d="";try{d=_.Si(c.data)}catch(e){throw new _.I(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},fM=function(a,b){return _.x(function*(){var c=
|
|
33
|
+
WL(a,b,a.w,"");if(1===c.type){var d=c.U[0].a;c=XL(d);if(!c)throw new _.I(_.G,4,4021,`Unknown file extension ${d}`);d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");c=cL(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=AK(c.ha);c=YL(d.Bc.Gf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield ZL(a,d);var f=e.Xh;const g=e.periods;var h=e.li;const k=e.Ii;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.G,7,7001);$L(a,g);h=aM(a,f.delay,g,h);bM(a)||(a.G=f.Jd,
|
|
34
|
+
cM(a));dM(a,h,g);f=eM(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})},hM=function(a,b){return Promise.all(b.map(c=>gM(a,c)))},jM=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!bM(a),f=nK(c.ha,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].U,f=f[f.length-1].ra):
|
|
35
|
+
f=0;if(e&&0<f)try{{const k=nK(c.ha,VJ);if(!k)throw iM.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(XJ);const l=Number(k.value),m=BL(d,l);if(!m)throw iM.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(XJ);var h=m.ra}g=h;break a}catch(k){throw new _.I(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=
|
|
36
|
+
c.U||[];for(const k of c)mK(k.ha,RJ)&&g++,k.ra=g});mL(b)},mM=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,ah:e}=yield kM(a,b);var f=a.f.periods[0].variants;a.a.lowLatencyMode&&null!==a.o&&(f=f.filter(g=>g.id===a.o.id));f=f.map(g=>{const h=LK(g.audio,e),k=LK(g.video,e);g=lM(a,h,k,g.bandwidth);if(!g)throw new _.I(_.G,4,4047,{message:"Video and audio are encrypted in an incompatible way.",rj:k?HK(k).Da:void 0,audio:h?HK(h).Da:void 0});return g});return PL(a.D.configurationId,
|
|
37
|
+
f,c,d,!0)})},$L=function(a,b){bM(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.xE(b,-a.I))},nM=function(a,b){b=b.flatMap(d=>d.U[0].ha);b=nK(b,"EXT-X-PROGRAM-DATE-TIME");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},oM=function(a,b,c){b=b.find(d=>null!==nK(d.ha,QJ));if(!b)return[];if(null===c)throw new _.I(_.G,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");
|
|
38
|
+
return b.ha.filter(d=>d.name===QJ).map(d=>{a:{var e=a.C,f=!bM(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.nu.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);f=k.getTime()/1E3+e;g={id:g,startTime:f,startDate:k,pe:h};h=iK(_.J(d,PJ));void 0!==h&&0<=h&&(g.duration=h);var l=iK(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=
|
|
39
|
+
m);var n=_.J(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.trim().startsWith("X-")&&(k[q.name]=q.value);q=_.ah(k)?k:null}}q=q||{};(k=_.J(d,"CUE"))&&(q.CUE=k.split(","));if(_.Bi(m)){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Lb:m[_.Lb]=u.value;break;case _.Kb:m[_.Kb]=u.value;break;case _.Qb:m[_.Qb]=iK(u.value);break;case _.Mb:m[_.Mb]=iK(u.value);break;
|
|
40
|
+
case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case _.Nb:m[_.Nb]=u.value.split(",")}m[_.Lb]&&m[_.Kb]||!m[_.Lb]&&!m[_.Kb]?(_.nu.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.ah(m)?m:null}if(null===u){_.nu.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}q=Object.assign(q,u)}_.ah(q)&&(g.customAttributes=q);g.endTime=n?n.getTime()/1E3+e:h?f+h:l?f+l:f;g.type=_.Sh;d=g}}return d}).filter(Boolean)},eM=function(a,
|
|
41
|
+
b){const c=new Set(b.map(d=>d.id));a.B.forEach((d,e)=>{c.has(e)||a.B.delete(e)});for(const d of b){if((b=a.B.get(d.id))&&b.pe!==d.pe)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,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,pe:d.pe,endTime:d.endTime,id:d.id,type:_.Sh,eventElement:null};b&&!hK(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},pM=function(a,b,
|
|
42
|
+
c){a.A=_.Db;_.gD(b,!0);b.f=c[c.length-1].endTime},WL=function(a,b,c,d){a=ZK(a.R,b,c);a.verbatimUri=d;return a},YL=function(a){return a.filter(b=>b.name===UJ&&_.J(b,_.sb)===_.uB&&!_.J(b,_.ub)).map(b=>{const c=MK(b),d=_.J(b,_.La)||_.fg;return{groupId:eK(b,_.Fa),id:_.xJ++,label:eK(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.J(b,"DEFAULT")}})},ZL=function(a,b){return _.x(function*(){var c=JK(b.Bc.closedCaptions),d=qM(a,b.Ld),e=yield rM(a,b),f=Object.values(e).flat().map(h=>h.playlist);jM(a,f);
|
|
43
|
+
f=f[0];var g=tK(f.ha);a.A=g;a.K=yK(f.ha);f=GK(f.ha,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield sM(a,e.Hf,d);c=yield tM(a,e.Ld,g,c);d=yield uM(a,e.Fi,d);g=yield vM(a,e.He);d=PL(a.D.configurationId,c,d,g,!bM(a));a.D.filterAllPeriods(d);c=[...e.Ld,...e.Hf].map(h=>h.playlist);e=nM(a,c);c=oM(a,c,e);return{periods:d,li:e,Ii:c,Xh:f}})},aM=function(a,b,c,d){let e=!0,f=null,g=0;bM(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.AJ(b,f,g,!0,void 0,!!a.a.lowLatencyMode);
|
|
44
|
+
_.gD(a,e);TL(a,c);d&&_.fD(a,d);return a},cM=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Vc);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.Vc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},dM=function(a,b,c){c=EK(c);"LIVE"===a.A||"EVENT"===a.A?(c=Math.max(c,
|
|
45
|
+
b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.A===_.Db&&(b.f=c)},kM=function(a,b){return _.x(function*(){const c=g=>HK(g.stream).type===_.w||HK(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=HK(h.stream);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.Da,
|
|
46
|
+
Md:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return wM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);xM(a,d.concat(f));e=f.filter(g=>HK(g).type===_.$B);f=f.filter(g=>HK(g).type===_.ce);return{textStreams:e,thumbStreams:f,ah:d}})},lM=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?_.AC(l.drmInfos,m.drmInfos)?_.zC(l.drmInfos,m.drmInfos):
|
|
47
|
+
null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.fg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new yM(f)},wM=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Tc,g=b.ic,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,q=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Md,A=_.Di(f||_.fg);if(1!==c.type)throw new _.I(_.G,
|
|
48
|
+
4,4017);const D=yield zM(a,c,e,d),E=a.a.lowLatencyMode?_.RB:_.QB;let oa=m;e!==_.H||m||(oa=_.$B);const te=tK(c.ha);m=D.map(ic=>{const Ob=ic.U,Xd=ic.nh,Pb=ic.mimeType,jc=ic.ra,kc=Ob[0].startTime,Gb=Ob[Ob.length-1].endTime,hb=Gb-kc,ua=new _.BJ(Ob),zb=Ob[0].initSegment||null;return{id:null===g?_.xJ++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ua.f.bind(ua),getSegmentReference:ua.get.bind(ua),adjustSegmentDurations:ua.h.bind(ua),getDuration:ua.getDuration.bind(ua),
|
|
49
|
+
segmentIndex:ua,segmentLookupStrategy:E,initSegmentReference:zb,mimeType:Pb,codecs:d,kind:oa,Tf:Xd.type,encrypted:Xd.type===dK,aesEncrypted:ic.aesEncrypted,keyId:Xd.keyId,language:A,originalLanguage:f||_.fg,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:q,spatialAudio:u,closedCaptions:v,U:Ob,drmInfos:Xd.drmInfos,ra:jc,Da:c.verbatimUri,se:c.a,Vc:kc,Le:Gb,duration:hb,
|
|
50
|
+
groupId:h,ij:te,muxedAudioId:k}});return new AM(m)})},xM=function(a,b){b.forEach(c=>{a.j.a.set(HK(c).Da,c)})},qM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,_.uB);b=_.J(f,_.Cb);var e=_.J(f,aK);const g=BM(a,f);if(e){const h=_.dk(_.H,g);c.set(`${_.H}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=CM(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=CM(_.w,g),c.set(`${"video"}:${b}`,d))}return c},rM=function(a,b){return _.x(function*(){const c=yield Promise.all([DM(a,b.Bc.Gf),DM(a,b.Bc.Gi),
|
|
51
|
+
DM(a,b.Ld),DM(a,b.He)]),[d,e,f,g]=c;return{Hf:d,Fi:e,Ld:f,He:g}})},sM=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[EM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>EM(a,e,c)));d=yield Promise.all(d);return IK(d)})},tM=function(a,b,c,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(eK(f[k].tag,_.la));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield FM(a,h,c,d,e);f=f.map(k=>FM(a,k,c,d,e));f=yield Promise.all(f);
|
|
52
|
+
f.splice(g,0,h);return f.reduce(_.rC,[])})},uM=function(a,b,c){return Promise.all(b.map(d=>EM(a,d,c)))},vM=function(a,b){return Promise.all(b.map(c=>GM(a,c)))},HM=function(a,b){return _.x(function*(){const c=_.ij(b.verbatimUri,a.w),{response:d,text:e}=yield VL(a,c);return WL(a,e,d.uri,b.verbatimUri)})},IM=function(a,b,c){return _.x(function*(){const d=yield wM(a,{playlist:c,codecs:b.codecs,type:b.type,Tc:b.originalLanguage,ic:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,
|
|
53
|
+
channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Md:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&GL(d,b.bandwidth);return d})},bM=function(a){return a.A===_.Db},DM=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield JM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gM=function(a,b){return _.x(function*(){var c=new _.oi(HK(b).se);if(a.a.lowLatencyMode&&a.K&&a.K.Lf){var d=
|
|
54
|
+
b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Yh:d.position,ei:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Yh,e=e.ei,f=_.hj(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=_.gj(f,!0),d=new _.vi(d),_.ri(c,d)}const {response:g,text:h}=yield VL(a,c.toString());c=HK(b).Da;d=HK(b).se;e=g.uri;d!==e&&(d=e,CL(b,d));c=WL(a,h,d,c);return{stream:b,playlist:c}})},BM=function(a,b){var c=_.J(b,
|
|
55
|
+
_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=KK(c);b=new Set;const d=[];for(const e of c)c=_.GC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},CM=function(a,b){if(1===b.length)return b[0];a=_.dk(a,b);if(null!=a)return a;throw new _.I(_.G,4,4025,{codecList:b});},EM=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return KM(a,e.verbatimUri,()=>_.x(function*(){const f=eK(d,_.Fa),g=uK(eK(d,_.sb));var h=eK(d,_.sb).toUpperCase();
|
|
56
|
+
if(uK(h)!==_.H)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.$B;h===NJ&&(l=_.MB);k&&(l=_.Ud);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.La);const m=_.J(d,_.Ta),n=_.J(d,"DEFAULT"),q=g===_.p?MK(d):null;var u=g===_.p?(u=_.J(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wM(a,{playlist:e,codecs:k,type:g,Tc:l,primary:"YES"===n,name:m,channelsCount:q,spatialAudio:u,groupId:f,kind:h,ic:null,closedCaptions:null,Md:null})}))})},GM=function(a,b){return _.x(function*(){const c=
|
|
57
|
+
b.tag,d=b.playlist;return KM(a,d.verbatimUri,()=>_.x(function*(){var e=_.J(c,_.pa)||"jpg",f=_.J(c,_.La);const g=_.J(c,_.Ta);e=yield wM(a,{playlist:d,codecs:e,type:_.ce,Tc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,ic:null,groupId:null,Md:null});(f=_.J(c,_.la))&&GL(e,Number(f));return e}))})},FM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(eK(f,_.la));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.lb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,
|
|
58
|
+
_.lb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:iK(h),width:iK(k),height:iK(l)}}else h=null;if(f=yield LM(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=(q?HK(q).Da:"")+" - "+(n?HK(n).Da:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=lM(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})},MM=function(a,
|
|
59
|
+
b,c,d,e,f){let g=BM(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.dk(_.w,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.w,g=[g.join(",")]):d&&f?(a.g.debug(YJ),c=_.p,b=!0):e?(a.g.debug(YJ),c=_.p):(a.g.debug("Guessing video-only"),c=_.w):(c=_.p,a.g.debug(YJ));return{type:c,Zg:g,Oh:b}},KM=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},LM=
|
|
60
|
+
function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist,h=_.J(f,_.uB),k=_.J(f,_.Cb);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=>HK(u).Da===l);const {type:m,Zg:n,Oh:q}=MM(a,f,c,k.audio.length,k.video.length,g);f=null;q||(f=yield NM(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.p&&c&&k.video.forEach(u=>{DL(u,c.width);EL(u,c.height);FL(u,c.frameRate)});return k})},NM=function(a,b,c,d,e,f){return _.x(function*(){const g=
|
|
61
|
+
b.tag,h=b.playlist;return KM(a,h.verbatimUri,()=>_.x(function*(){var k=_.J(g,NJ);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.J(g,_.uB)||void 0)&&a.J.has(k)?k:void 0;var m=CM(d,c);if(k){const n=CM(_.p,c);m+=`,${n}`}return yield wM(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Tc:null,name:null,channelsCount:null,spatialAudio:!1,ic:null,groupId:null,muxedAudioId:k,Md:f})}))})},zM=function(a,b,c,d){return _.x(function*(){var e=b.verbatimUri,f=b.U;var g=void 0===g?0:g;
|
|
62
|
+
var h=(h=nK(b.ha,VJ))?Number(h.value):g;g=[];e=yield OM(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)mK(m.ha,RJ)&&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 PM(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;QM(g);return g})},JM=function(a,b){return _.x(function*(){var c=b.name!==UJ?!0:_.J(b,_.sb)===aK;c=_.J(b,_.ub,void 0,{required:c});if(!c)return null;const d=_.ij(c,a.w),e=Date.now(),{response:f,text:g}=yield VL(a,
|
|
63
|
+
d);a.D.onEvent(new _.F(cK,{detail:{duration:Date.now()-e,type:"media"}}));return WL(a,g,f.uri,c)})},QM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},RM=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.J(c,_.ub))||null).map(b=>_.mu(b));if(1<(new Set(a)).size)throw new _.I(_.G,4,4044,"Unexpected change in file format.");},SM=function(a,b,c){a=jK(a.ha,TJ);if(1<a.length)throw new _.I(_.G,
|
|
64
|
+
4,4020);a=a[0];if(!a)return null;const d=eK(a,_.ub),e=_.ij(d,b);b=zK(a,null,!0);return new _.wJ(()=>[e],b.ma,b.ja,c)},TM=function(a,b,c,d,e,f,g){const h=[];for(const q of NK(b.f)){b=q.fg;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,PJ));n=m+n;k=zK(u,k?null:l.ja,k);l=_.J(u,_.ub);const v=(l=_.ij(l,g))?[l]:[];m=new BK(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},UM=function(a,b,c,d,e,f,g,h,k,l,m){const n=
|
|
65
|
+
c.ha;var q=c.a;0<jK(n,TJ).length&&(m=SM(c,k,g));const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={ma:0,ja:null};let y=null;u?({duration:c}=xK(n),a=e+c,q=wK(n,b?b.ja:null)):(b=TM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ce?oK(n):null;d=new BK(d,e,a,()=>v,q.ma,q.ja,f,g,!1,null,h?h.nd:null,h?h.Kd:null,h?h.durationPerTile:null,y,m);d.ra=l;return d},OM=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.C)return a.C;if(!bM(a)&&a.f)try{var k=a.j.get(c);
|
|
66
|
+
var l=k?BL(k,e)||null:null;if(!l)throw new _.I(_.G,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Ca;a.g.debug(`Setting playlist start time to ${m}.`);return a.C=m}catch(n){if(h=a.j.get(c))m=h.streams[h.streams.length-1].U,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].U[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.G,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
|
|
67
|
+
uri:c});}m=yield VM(a,f,g,h);l=xL(h.ha,a.w,e);k=SM(h,b,l);h=yield WM(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},PM=function(a,b,c,d,e,f,g,h){return _.x(function*(){var k=c[0],l=null==h;RM(c);const m=yield VM(a,f,g,k);var n=h?h.Vh:null;if(mK(c[0].ha,SJ)||null===n)n=uL(c,m),n=0===n.length?[qL()]:n;else{var q=uL(c,m);n=[n,...q]}q=n;n=q[q.length-1];q=rL(q);let u=h?h.Wh:null;var v=XM(u,k.ha,a.w,d);let y=SM(k,b,v)||(h?h.Ph:null);const A=k.ra;k=l?e:yield YM(a,A,y,k,d,
|
|
68
|
+
v,m,g);l=[];v=!1;for(let E=0;E<c.length;E++){var D=c[E];const oa=l[l.length-1]||null,te=0===E?0:oa.endTime,ic=d+E,Ob=XM(u,D.ha,a.w,ic);(u=Ob)&&(v=!0);if(D=UM(a,oa,D,ic,te,k,Ob,f,b,A,y))y=D.initSegment,l.push(D)}return{U:l,nh:q,Vh:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,ra:A,Ph:y,Wh:u}})},VM=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=nK(d.ha,TJ);f=f?eK(f,_.ub):null;return ZM(a,b,c,e,f)})},WM=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=
|
|
69
|
+
CK(c,d);return zL(a.S,b,g,e,f,null!=d)})},XM=function(a,b,c,d){return b.some(e=>e.name===SJ&&"NONE"===_.J(e,ZJ))?null:(b=xL(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Sl(new Uint8Array(12),eL(d))}):a},YM=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.L.has(b))return a.L.get(b);const k=yield WM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.L.set(b,k);return k})},ZM=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.gk(f,b,
|
|
70
|
+
c);if(g)return g;g=_.sj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.G,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},XL=a=>{a=_.mu(a)||"";return null!=_.lu.video[a]?_.w:null!=_.lu.audio[a]?_.p:null},TK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.G,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.G,4,4043,"Media playlist must have at least one full segment!");
|
|
71
|
+
}this.a=a;this.verbatimUri="";this.type=b;this.ha=c;this.U=1===b?d:null}},bL=class{constructor(a,b,c){c=void 0===c?[]:c;this.ha=b;this.a=a;this.f=c;this.ra=-1}},BK=class extends _.wD{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===q?null:q,u,void 0===v?null:v);this.ra=0}},$K=/^#EXT-X-DEFINE/,aL=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,
|
|
72
|
+
$M=class{constructor(){this.h=0;this.a=new Map}},aN=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()}},iM=new _.T("clpp.hls.DiscontinuityUtils");var wL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.qg)throw new _.I(_.G,4,4041);if(eK(a,ZJ)===$J)throw new _.I(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.uC(_.pd,[{initDataType:_.If,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":pL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":pL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=eK(a,ZJ);if(!nL.includes(b))return oL.error("Widevine in HLS is only supported with [",
|
|
73
|
+
nL.join(", "),"], not",b),null;b=eK(a,_.ub);b=_.zt(b);b=_.K(b.data);b=_.uC(_.td,[{initDataType:_.Uc,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},nL=["SAMPLE-AES",$J],oL=new _.T("clpp.hls.DrmParser");var vL=new _.T("clpp.hls.EncryptionUtils");var bN=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.oj()}}};var AM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var yM=class{constructor(a){this.a=a}length(){return this.a.length}};var cN=class{constructor(){this.a=this.D=null;this.h=1;this.j=new aN;this.w="";this.R=new $M;this.G=0;this.o=null;this.l=new _.wk(()=>{this.Vb()});this.A=_.Db;this.f=null;this.F=new _.pu;this.K=this.C=null;this.g=new _.T("clpp.hls.HlsParser");this.L=new Map;this.S=new bN(this.H.bind(this));this.P=!1;this.I=null;this.M=!1;this.B=new Map;this.J=new Set}configure(a){this.a=a;this.S.a=a}setCurrentVariant(a){this.o=a}start(a,b){const c=this;return _.x(function*(){if(c.P)throw Error("start() may be called only once!");
|
|
74
|
+
c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield VL(c,a);c.D.onEvent(new _.F(cK,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield fM(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.M=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=this.o=null;this.B.clear();this.J.clear();return Promise.all(a)}update(){const a=this;return _.x(function*(){const b=a.f;if(!bM(a)&&
|
|
75
|
+
b){var c=b.presentationTimeline;"LIVE"===a.A&&(a.C=null);var d=Array.from(a.j.values());if(a.a.lowLatencyMode&&null!==a.o){const g=UL(a);d=d.filter(h=>g.includes(HK(h).Da))}var e=yield hM(a,d);d=e.map(g=>g.playlist);jM(a,d);e=yield mM(a,e);IL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});$L(a,e);var f=nM(a,d);f=oM(a,d,f);b.cues=eM(a,f);KL(b.periods,e);TL(c,e);if(d=rK(d))!0!==a.a.keepTimelineLive&&pM(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();
|
|
76
|
+
a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.x(function*(){const d=a.id;var e=c.f.periods.find(k=>k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.li(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=KM(c,k.verbatimUri,()=>_.x(function*(){const l=yield HM(c,k);return IM(c,k,l)}))}if(e.video){const k=e.video;g=KM(c,k.verbatimUri,()=>_.x(function*(){const l=yield HM(c,
|
|
77
|
+
k);return IM(c,k,l)}))}f=yield f;g=yield g;e=lM(c,f,g,e.bandwidth,e.id);let h;e&&(e=PL(c.D.configurationId,[e],[],[],!bM(c)),c.D.filterAllPeriods(e),e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.li(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.x(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=
|
|
78
|
+
c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.li(`Could not load text stream with id: ${a}`);const g=yield KM(c,f.verbatimUri,()=>_.x(function*(){const h=yield HM(c,f);return IM(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.li(`Could not load text stream with id: ${a}`);return d})}Vb(){const a=this;return _.x(function*(){a.g.debug(_.GB);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
|
|
79
|
+
_.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}H(a){if(!this.F)throw new _.I(_.G,7,7001);a=this.D.networkingEngine.fetch(a);_.Bj(this.F,a);return a.T}};_.z("clpp.hls.HlsComponent",class extends _.Dv{f(){_.dt.m3u8=cN;_.bt[_.pl]=cN;_.bt[bK]=cN}a(){_.VD("m3u8");_.WD(_.pl);_.WD(bK)}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.g.warn("A video element is not available. Skipping.")},
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var SU=function(a){a.a.one(a.m,_.me,()=>RU(a))},RU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.oc,d=>TU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.ue).forEach(d=>{TU(a,{track:d})});!UU(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."),VU(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.")},TU=function(a,b){b=b.track;b.kind===_.ue&&(a.g.info("The metadata track has been added."),b.mode=_.$d,a.a.on(b,_.yd,c=>WU(a,c)))},UU=function(a){return a.some(b=>b.kind===_.ue)},VU=function(a,b){const c=a.m.getTrackManager(),d=c.oa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ya(d);a.a.on(b.textTracks,_.oc,g=>{g.track.kind===_.ue&&(a.a.off(b.textTracks,_.oc,f),c.ya(d))});c.ya(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
WU=function(a,b){const c=XU(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 YU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Wi(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)}}})},XU=function(a){return(a=a.m.getTrackManager().ta())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
YU=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.eh(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=_.eh(a)?a:null}}};var ZU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Rt;this.h=(a=_.Dt(_.yc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;SU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var $U=class extends _.Sv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Kk()){var b=a.getConfiguration();b=_.Zg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Mc&&(b.patchMetadataTrack=!1);_.fh(b.timestampOffset)||(b.timestampOffset=0);this.a=new ZU(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",$U);
|
|
5
|
+
$U.Id="hlssmpte";_.Mr(new class{create(){return new $U}});};f.call(g, window);
|