(function(nt){if(typeof exports=="object"&&typeof module!="undefined")module.exports=nt();else if(typeof define=="function"&&define.amd)define([],nt);else{var I;I=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this,I.videojsContribHls=nt()}})(function(){var nt;return function I(j,C,k){function E(S,m){if(!C[S]){if(!j[S]){var v=typeof require=="function"&&require;if(!m&&v)return v(S,!0);if(P)return P(S,!0);var c=new Error("Cannot find module '"+S+"'");throw c.code="MODULE_NOT_FOUND",c}var a=C[S]={exports:{}};j[S][0].call(a.exports,function(s){var l=j[S][1][s];return E(l||s)},a,a.exports,I,j,C,k)}return C[S].exports}for(var P=typeof require=="function"&&require,O=0;O=l.adStartTime&&c<=l.adEndTime)return l}return null},m=function(v,c){var a=arguments.length<=2||arguments[2]===void 0?0:arguments[2];if(v.segments)for(var s=a,l=void 0,r=0;r=32&&m<126?String.fromCharCode(m):"."},O=function(m){var v={};return Object.keys(m).forEach(function(c){var a=m[c];ArrayBuffer.isView(a)?v[c]={bytes:a.buffer,byteOffset:a.byteOffset,byteLength:a.byteLength}:v[c]=a}),v},S={hexDump:function(m){for(var v=Array.prototype.slice.call(m),c=16,a="",s=void 0,l=void 0,r=0;rM.start(0)?N.start(0):M.start(0),N.end(0)0&&(N=Math.max(N,G.end(G.length-1))),M!==N&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",W):W())}},{key:"dispose",value:function(){this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.audioPlaylistLoader_&&this.audioPlaylistLoader_.dispose(),this.audioSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var x=this.masterPlaylistLoader_.media(),M=void 0;if(x&&this.mediaSource.readyState==="open"){if(M=T(this.masterPlaylistLoader_.master,x),M.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+x.resolvedUri,this.mediaSource.endOfStream("decode");this.mainSegmentLoader_.mimeType(M[0]),M[1]&&this.audioSegmentLoader_.mimeType(M[1]),this.excludeIncompatibleVariants_(x)}}},{key:"excludeIncompatibleVariants_",value:function(x){var M=this.masterPlaylistLoader_.master,N=2,G=null,W=void 0;x.attributes&&x.attributes.CODECS&&(W=w(x.attributes.CODECS),G=W.videoCodec,N=W.codecCount),M.playlists.forEach(function(B){var F={codecCount:2,videoCodec:null};if(B.attributes&&B.attributes.CODECS){var H=B.attributes.CODECS;F=w(H),window.MediaSource&&window.MediaSource.isTypeSupported&&!window.MediaSource.isTypeSupported('video/mp4; codecs="'+y(H)+'"')&&(B.excludeUntil=1/0)}F.codecCount!==N&&(B.excludeUntil=1/0),F.videoCodec!==G&&(B.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(x){var M=0,N=this.seekable();N.length&&(M=N.start(0)),i.default.updateAdCues(x,this.cueTagsTrack_,M)}}]),D}(d.default.EventTarget);C.MasterPlaylistController=U}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./ad-cue-tags":1,"./decrypter-worker":4,"./playlist-loader":7,"./ranges":9,"./segment-loader":13,"./sync-controller":16,"videojs-contrib-media-sources/es5/codec-utils":44,webworkify:77}],6:[function(I,j,C){(function(k){"use strict";function E(l){return l&&l.__esModule?l:{default:l}}function P(l,r){if(!(l instanceof r))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(C,"__esModule",{value:!0});var O=function(){function l(r,h){for(var d=0;d")),this.logger_("initialize");var d=function(){return h.waiting_()},t=function(){return h.cancelTimer_()};this.tech_.on("waiting",d),this.tech_.on(a,t),this.monitorCurrentTime_(),this.dispose=function(){h.logger_("dispose"),h.tech_.off("waiting",d),h.tech_.off(a,t),h.checkCurrentTimeTimeout_&&clearTimeout(h.checkCurrentTimeTimeout_),h.cancelTimer_()}}return O(l,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(!this.tech_.paused()&&!this.tech_.seeking()){var r=this.tech_.currentTime();this.consecutiveUpdates>=5&&r===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):r===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=r)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"waiting_",value:function(){var r=this.seekable(),h=this.tech_.currentTime();if(!this.tech_.seeking()&&this.timer_===null){if(this.fellOutOfLiveWindow_(r,h)){var d=r.end(r.length-1);return this.logger_("Fell out of live window at time "+h+". Seeking to live point (seekable end) "+d),this.cancelTimer_(),this.tech_.setCurrentTime(d),void this.tech_.trigger("liveresync")}var t=this.tech_.buffered(),i=m.default.findNextRange(t,h);if(this.videoUnderflow_(i,t,h))return this.cancelTimer_(),this.tech_.setCurrentTime(h),void this.tech_.trigger("videounderflow");if(i.length>0){var o=i.start(0)-h;this.logger_("Stopped at "+h+", setting timer for "+o+", seeking to "+i.start(0)),this.timer_=setTimeout(this.skipTheGap_.bind(this),1e3*o,h)}}}},{key:"fellOutOfLiveWindow_",value:function(r,h){return!!(r.length&&r.start(0)>0&&h2)return{start:i,end:o}}return null}},{key:"logger_",value:function(){}}]),l}();C.default=s,j.exports=C.default}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./ranges":9}],7:[function(I,j,C){(function(k){"use strict";function E(i){return i&&i.__esModule?i:{default:i}}Object.defineProperty(C,"__esModule",{value:!0});var P=I("./resolve-url"),O=E(P),S=typeof window!="undefined"?window.videojs:typeof k!="undefined"?k.videojs:null,m=I("./playlist.js"),v=I("./stream"),c=E(v),a=I("m3u8-parser"),s=E(a),l=I("global/window"),r=E(l),h=function(i,o,p){var u=o.slice(),g=void 0,f=void 0;for(p=p||0,g=Math.min(i.length,o.length+p),f=p;f=500?4:2},f.trigger("error")},A=function(w,y){var T=void 0,U=void 0,L=void 0;f.setBandwidth(_||w),_=null,f.state="HAVE_METADATA",T=new s.default.Parser,T.push(w.responseText),T.end(),T.manifest.uri=y,L=d(f.master,T.manifest),U=1e3*(T.manifest.targetDuration||10),f.targetDuration=T.manifest.targetDuration,L?(f.master=L,f.media_=f.master.playlists[T.manifest.uri]):U/=2,f.media().endList||(r.default.clearTimeout(e),e=r.default.setTimeout(function(){f.trigger("mediaupdatetimeout")},U)),f.trigger("loadedplaylist")},f.state="HAVE_NOTHING",n=this.dispose,f.dispose=function(){f.stopRequest(),r.default.clearTimeout(e),n.call(this)},f.stopRequest=function(){if(_){var w=_;_=null,w.onreadystatechange=null,w.abort()}},f.enabledPlaylists_=function(){return f.master.playlists.filter(m.isEnabled).length},f.isLowestEnabledRendition_=function(){var w=f.media();if(!w||!w.attributes)return!1;var y=f.media().attributes.BANDWIDTH||0;return!(f.master.playlists.filter(function(T){var U=(0,m.isEnabled)(T);if(!U)return!1;var L=0;return T&&T.attributes&&(L=T.attributes.BANDWIDTH),L<=y}).length>1)},f.media=function(w){var y=f.state,T=void 0;if(!w)return f.media_;if(f.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+f.state);if(typeof w=="string"){if(!f.master.playlists[w])throw new Error("Unknown playlist URI: "+w);w=f.master.playlists[w]}if(T=!f.media_||w.uri!==f.media_.uri,f.master.playlists[w.uri].endList)return _&&(_.onreadystatechange=null,_.abort(),_=null),f.state="HAVE_METADATA",f.media_=w,void(T&&(f.trigger("mediachanging"),f.trigger("mediachange")));if(T){if(f.state="SWITCHING_MEDIA",_){if((0,O.default)(f.master.uri,w.uri)===_.url)return;_.onreadystatechange=null,_.abort(),_=null}this.media_&&this.trigger("mediachanging"),_=this.hls_.xhr({uri:(0,O.default)(f.master.uri,w.uri),withCredentials:u},function(U,L){if(_){if(U)return b(_,w.uri,y);A(L,w.uri),y==="HAVE_MASTER"?f.trigger("loadedmetadata"):f.trigger("mediachange")}})}},f.setBandwidth=function(w){f.bandwidth=w.bandwidth},f.on("mediaupdatetimeout",function(){f.state==="HAVE_METADATA"&&(f.state="HAVE_CURRENT_METADATA",_=this.hls_.xhr({uri:(0,O.default)(f.master.uri,f.media().uri),withCredentials:u},function(w,y){if(_)return w?b(_,f.media().uri):void A(_,f.media().uri)}))}),f.on("firstplay",function(){var w=f.media();w&&(w.syncInfo={mediaSequence:w.mediaSequence,time:0})}),f.pause=function(){f.stopRequest(),r.default.clearTimeout(e)},f.load=function(){f.started?f.media().endList?f.trigger("loadedplaylist"):f.trigger("mediaupdatetimeout"):f.start()},f.start=function(){f.started=!0,_=g.hls_.xhr({uri:o,withCredentials:u},function(w,y){var T=void 0,U=void 0,L=void 0;if(_){if(_=null,w)return f.error={status:y.status,message:"HLS playlist request error at URL: "+o,responseText:y.responseText,code:2},f.trigger("error");if(T=new s.default.Parser,T.push(y.responseText),T.end(),f.state="HAVE_MASTER",T.manifest.uri=o,T.manifest.playlists){for(f.master=T.manifest,L=f.master.playlists.length;L--;)U=f.master.playlists[L],f.master.playlists[U.uri]=U,U.resolvedUri=(0,O.default)(f.master.uri,U.uri);for(var D in f.master.mediaGroups.AUDIO)for(var x in f.master.mediaGroups.AUDIO[D]){var M=f.master.mediaGroups.AUDIO[D][x];M.uri&&(M.resolvedUri=(0,O.default)(f.master.uri,M.uri))}return f.trigger("loadedplaylist"),void(_||f.media(T.manifest.playlists[0]))}return f.master={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:r.default.location.href,playlists:[{uri:o}]},f.master.playlists[o]=f.master.playlists[0],f.master.playlists[0].resolvedUri=o,A(y,o),f.trigger("loadedmetadata")}})}};t.prototype=new c.default,C.default=t,j.exports=C.default}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./playlist.js":8,"./resolve-url":12,"./stream":15,"global/window":28,"m3u8-parser":29}],8:[function(I,j,C){(function(k){"use strict";function E(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(C,"__esModule",{value:!0});var P=typeof window!="undefined"?window.videojs:typeof k!="undefined"?k.videojs:null,O=I("global/window"),S=E(O),m={UNSAFE_LIVE_SEGMENTS:3},v=function(n,e){var _=0,b=e-n.mediaSequence,A=n.segments[b];if(A){if(typeof A.start!="undefined")return{result:A.start,precise:!0};if(typeof A.end!="undefined")return{result:A.end-A.duration,precise:!0}}for(;b--;){if(A=n.segments[b],typeof A.end!="undefined")return{result:_+A.end,precise:!0};if(_+=A.duration,typeof A.start!="undefined")return{result:_+A.start,precise:!0}}return{result:_,precise:!1}},c=function(n,e){for(var _=0,b=void 0,A=e-n.mediaSequence;A_){var A=[_,e];e=A[0],_=A[1]}if(e<0){for(var w=e;wMath.abs(A)?(w=A,y=-_.time):(w=b,y=e.time),Math.abs(y+l(n,w,0))}if(e){var w=e.mediaSequence-n.mediaSequence;return e.time+l(n,w,0)}if(_){var w=_.mediaSequence-n.mediaSequence;return _.time-l(n,w,0)}},d=function(n){if(!n||!n.segments)return(0,P.createTimeRange)();if(n.endList)return(0,P.createTimeRange)(0,s(n));var e=r(n),_=e.expiredSync,b=e.segmentSync;if(!_&&!b)return(0,P.createTimeRange)();var A=h(n,_,b),w=A,y=Math.max(0,n.segments.length-m.UNSAFE_LIVE_SEGMENTS),T=a(n,n.mediaSequence+y,A);return(0,P.createTimeRange)(w,T)};C.seekable=d;var t=function(n){return n-Math.floor(n)==0},i=function(n,e){if(t(e))return e+.1*n;for(var _=e.toString().split(".")[1].length,b=1;b<=_;b++){var A=Math.pow(10,b),w=e*A;if(t(w)||b===_)return(w+n)/A}},o=i.bind(null,1),p=i.bind(null,-1),u=function(n,e,_,b){var A=void 0,w=void 0,y=n.segments.length,T=e-b;if(T<0){if(_>0){for(A=_-1;A>=0;A--)if(w=n.segments[A],T+=p(w.duration),T>0)return{mediaIndex:A,startTime:b-l(n,_,A)}}return{mediaIndex:0,startTime:e}}if(_<0){for(A=_;A<0;A++)if(T-=n.targetDuration,T<0)return{mediaIndex:0,startTime:e};_=0}for(A=_;ADate.now()};C.isBlacklisted=g;var f=function(n){var e=g(n);return!n.disabled&&!e};C.isEnabled=f,m.duration=s,m.seekable=d,m.getMediaInfoForTime_=u,m.isEnabled=f,m.isBlacklisted=g,C.default=m}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"global/window":28}],9:[function(I,j,C){(function(k){"use strict";function E(i){return i&&i.__esModule?i:{default:i}}Object.defineProperty(C,"__esModule",{value:!0});var P=function(){function i(o,p){var u=[],g=!0,f=!1,n=void 0;try{for(var e,_=o[Symbol.iterator]();!(g=(e=_.next()).done)&&(u.push(e.value),!p||u.length!==p);g=!0);}catch(b){f=!0,n=b}finally{try{!g&&_.return&&_.return()}finally{if(f)throw n}}return u}return function(o,p){if(Array.isArray(o))return o;if(Symbol.iterator in Object(o))return i(o,p);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),O=typeof window!="undefined"?window.videojs:typeof k!="undefined"?k.videojs:null,S=E(O),m=1/30,v=function(i,o){var p=P(o,2),u=p[0],g=p[1];return Math.min(Math.max(u,i),g)},c=function(i,o){var p=[],u=void 0;if(i&&i.length)for(u=0;u=o})},s=function(i,o){return c(i,function(p){return p-m>=o})},l=function(i){if(i.length<2)return S.default.createTimeRanges();for(var o=[],p=1;p=g};if(i)for(p=0;p=0&&(U.segment=w.segments[U.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(T,w)}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(t.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function(w){this.mimeType_||(this.mimeType_=w,this.playlist_&&this.state==="INIT"&&!this.paused()&&this.init_())}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&t.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=t.default.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&t.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=t.default.setTimeout(this.monitorBufferTick_.bind(this),o)}},{key:"getSyncSegmentCandidate_",value:function(w){var y=this;if(this.currentTimeline_===-1)return 0;var T=w.segments.map(function(U,L){return{timeline:U.timeline,segmentIndex:L}}).filter(function(U){return U.timeline===y.currentTimeline_});return T.length?T[Math.min(T.length-1,1)].segmentIndex:Math.max(w.segments.length-1,0)}},{key:"checkBuffer_",value:function(w,y,T,U,L,D){var x=0,M=void 0;w.length&&(x=w.end(w.length-1));var N=Math.max(0,x-L);if(!y.segments.length||(u("cB_","mediaIndex:",T,"hasPlayed:",U,"currentTime:",L,"syncPoint:",D,"fetchAtBuffer:",this.fetchAtBuffer_),u("cB_ 2","bufferedTime:",N),N>=h.default.GOAL_BUFFER_LENGTH)||!U&&N>=1)return null;if(D===null)return T=this.getSyncSegmentCandidate_(y),u("getSync",T),this.generateSegmentInfo_(y,T,null,!0);if(T!==null){u("++",T+1);var G=y.segments[T];return M=G&&G.end?G.end:x,this.generateSegmentInfo_(y,T+1,M,!1)}if(this.fetchAtBuffer_){var W=(0,v.getMediaInfoForTime_)(y,x,D.segmentIndex,D.time);T=W.mediaIndex,M=W.startTime}else{var W=(0,v.getMediaInfoForTime_)(y,L,D.segmentIndex,D.time);T=W.mediaIndex,M=W.startTime}return u("gMIFT",T,"sos",M),this.generateSegmentInfo_(y,T,M,!1)}},{key:"generateSegmentInfo_",value:function(w,y,T,U){if(y<0||y>=w.segments.length)return null;var L=w.segments[y];return{uri:L.resolvedUri,mediaIndex:y,isSyncRequest:U,startOfSegment:T,playlist:w,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:L.timeline,duration:L.duration,segment:L}}},{key:"abort_",value:function(){this.xhr_&&this.xhr_.abort(),this.pendingSegment_=null}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new l.default(this.mediaSource_,this.mimeType_),this.resetEverything(),this.monitorBuffer_()}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.mediaSource_.duration,this.currentTimeline_));var w=this.checkBuffer_(this.sourceUpdater_.buffered(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(w){var y=g(this.playlist_,this.mediaSource_,w.mediaIndex);return y?void this.mediaSource_.endOfStream():void((w.mediaIndex!==this.playlist_.segments.length-1||this.mediaSource_.readyState!=="ended"||this.seeking_())&&((w.timeline!==this.currentTimeline_||w.startOfSegment!==null&&w.startOfSegment0&&y.start(0)0&&this.sourceUpdater_.remove(0,x),T=w.segment,T.key){var M=a.default.mergeOptions(this.xhrOptions_,{uri:T.key.resolvedUri,responseType:"arraybuffer"});U=this.hls_.xhr(M,this.handleResponse_.bind(this))}if(T.map&&!this.initSegments_[e(T.map)]){var N=a.default.mergeOptions(this.xhrOptions_,{uri:T.map.resolvedUri,responseType:"arraybuffer",headers:n(T.map)});L=this.hls_.xhr(N,this.handleResponse_.bind(this))}this.pendingSegment_=w;var G=a.default.mergeOptions(this.xhrOptions_,{uri:w.uri,responseType:"arraybuffer",headers:n(T)});D=this.hls_.xhr(G,this.handleResponse_.bind(this)),D.addEventListener("progress",function(W){y.trigger(W)}),this.xhr_={keyXhr:U,initSegmentXhr:L,segmentXhr:D,abort:function(){this.segmentXhr&&(this.segmentXhr.onreadystatechange=null,this.segmentXhr.abort(),this.segmentXhr=null),this.initSegmentXhr&&(this.initSegmentXhr.onreadystatechange=null,this.initSegmentXhr.abort(),this.initSegmentXhr=null),this.keyXhr&&(this.keyXhr.onreadystatechange=null,this.keyXhr.abort(),this.keyXhr=null)}},this.state="WAITING"}},{key:"handleResponse_",value:function(w,y){var T=void 0,U=void 0,L=void 0;if(this.xhr_&&(y===this.xhr_.segmentXhr||y===this.xhr_.keyXhr||y===this.xhr_.initSegmentXhr)){if(T=this.pendingSegment_,U=T.segment,y.timedout)return this.abort_(),this.bandwidth=1,this.roundTrip=NaN,this.state="READY",this.trigger("progress");if(!y.aborted&&w){var D=this.xhr_.keyXhr;return this.abort_(),this.error({status:y.status,message:y===D?"HLS key request error at URL: "+U.key.uri:"HLS segment request error at URL: "+T.uri,code:2,xhr:y}),this.state="READY",this.pause(),this.trigger("error")}if(!y.response)return void this.abort_();if(y===this.xhr_.segmentXhr&&(this.xhr_.segmentXhr=null,T.startOfAppend=Date.now(),this.roundTrip=y.roundTripTime,this.bandwidth=y.bandwidth,this.mediaBytesTransferred+=y.bytesReceived||0,this.mediaRequests+=1,this.mediaTransferDuration+=y.roundTripTime||0,U.key?T.encryptedBytes=new Uint8Array(y.response):T.bytes=new Uint8Array(y.response)),y===this.xhr_.keyXhr){if(this.xhr_.keyXhr=null,y.response.byteLength!==16)return this.abort_(),this.error({status:y.status,message:"Invalid HLS key at URL: "+U.key.uri,code:2,xhr:y}),this.state="READY",this.pause(),this.trigger("error");L=new DataView(y.response),U.key.bytes=new Uint32Array([L.getUint32(0),L.getUint32(4),L.getUint32(8),L.getUint32(12)]),U.key.iv=U.key.iv||new Uint32Array([0,0,0,T.mediaIndex+T.playlist.mediaSequence])}y===this.xhr_.initSegmentXhr&&(this.xhr_.initSegmentXhr=null,U.map.bytes=new Uint8Array(y.response),this.initSegments_[e(U.map)]=U.map),this.xhr_.segmentXhr||this.xhr_.keyXhr||this.xhr_.initSegmentXhr||(this.xhr_=null,this.processResponse_())}}},{key:"resetEverything",value:function(){this.resetLoader(),this.remove(0,1/0)}},{key:"resetLoader",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:"resyncLoader",value:function(){this.mediaIndex=null,this.syncPoint_=null}},{key:"remove",value:function(w,y){this.sourceUpdater_&&this.sourceUpdater_.remove(w,y)}},{key:"processResponse_",value:function(){if(!this.pendingSegment_)return void(this.state="READY");this.state="DECRYPTING";var w=this.pendingSegment_,y=w.segment;y.key?this.decrypter_.postMessage((0,i.createTransferableMessage)({source:this.loaderType_,encrypted:w.encryptedBytes,key:y.key.bytes,iv:y.key.iv}),[w.encryptedBytes.buffer,y.key.bytes.buffer]):this.handleSegment_()}},{key:"handleDecrypted_",value:function(w){var y=this.pendingSegment_,T=w.decrypted;y&&(y.bytes=new Uint8Array(T.bytes,T.byteOffset,T.byteLength)),this.handleSegment_()}},{key:"handleSegment_",value:function(){var w=this;if(!this.pendingSegment_)return void(this.state="READY");this.state="APPENDING";var y=this.pendingSegment_,T=y.segment;return this.syncController_.probeSegmentInfo(y),y.isSyncRequest?(this.pendingSegment_=null,void(this.state="READY")):(y.timestampOffset!==null&&y.timestampOffset!==this.sourceUpdater_.timestampOffset()&&this.sourceUpdater_.timestampOffset(y.timestampOffset),T.map&&function(){var U=e(T.map);if(!w.activeInitSegmentId_||w.activeInitSegmentId_!==U){var L=w.initSegments_[U];w.sourceUpdater_.appendBuffer(L.bytes,function(){w.activeInitSegmentId_=U})}}(),y.byteLength=y.bytes.byteLength,typeof T.start=="number"&&typeof T.end=="number"?this.mediaSecondsLoaded+=T.end-T.start:this.mediaSecondsLoaded+=T.duration,void this.sourceUpdater_.appendBuffer(y.bytes,this.handleUpdateEnd_.bind(this)))}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());var w=this.pendingSegment_;this.pendingSegment_=null,this.recordThroughput_(w),this.mediaIndex=w.mediaIndex,this.fetchAtBuffer_=!0,u("handleUpdateEnd_",this.mediaIndex);var y=g(w.playlist,this.mediaSource_,this.mediaIndex+1);y&&this.mediaSource_.endOfStream(),this.state="READY",this.trigger("progress"),this.paused()||this.monitorBuffer_()}},{key:"recordThroughput_",value:function(w){var y=this.throughput.rate,T=Date.now()-w.startOfAppend+1,U=Math.floor(w.byteLength/T*8*1e3);this.throughput.rate+=(U-y)/++this.throughput.count}}]),A}(a.default.EventTarget);C.default=_,j.exports=C.default}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./bin-utils":2,"./config":3,"./playlist":8,"./source-updater":14,"global/window":28}],14:[function(I,j,C){(function(k){"use strict";function E(c){return c&&c.__esModule?c:{default:c}}function P(c,a){if(!(c instanceof a))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(C,"__esModule",{value:!0});var O=function(){function c(a,s){for(var l=0;l-1)}},{key:"trigger",value:function(S){var m=void 0,v=void 0,c=void 0,a=void 0;if(m=this.listeners[S])if(arguments.length===2)for(c=m.length,v=0;v=0;n--){var e=f[n];if(e.timeline===g&&typeof e.start!="undefined"){var _={time:e.start,segmentIndex:n};return _}}return null}},{name:"Discontinuity",run:function(o,p,u,g){if(p.discontinuityStarts.length)for(var f=0;f:",_),_}return null}},{key:"saveExpiredSegmentInfo",value:function(u,g){for(var f=g.mediaSequence-u.mediaSequence,n=f-1;n>=0;n--){var e=u.segments[n];if(typeof e.start!="undefined"){g.syncInfo={mediaSequence:u.mediaSequence+n,time:e.start},d("playlist sync:",g.syncInfo),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(u){if(!this.datetimeToDisplayTime&&u.dateTimeObject){var g=u.dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-g}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(u){var g=u.segment,f=void 0;f=g.map?this.probeMp4Segment_(u):this.probeTsSegment_(u),f&&this.calculateSegmentTimeMapping_(u,f)&&this.saveDiscontinuitySyncInfo_(u)}},{key:"probeMp4Segment_",value:function(u){var g=u.segment,f=c.default.timescale(g.map.bytes),n=c.default.startTime(f,u.bytes);return u.timestampOffset!==null&&(u.timestampOffset-=n),{start:n,end:n+g.duration}}},{key:"probeTsSegment_",value:function(u){var g=(0,a.inspect)(u.bytes,this.inspectCache_),f=void 0,n=void 0;return g?(g.video&&g.video.length===2?(this.inspectCache_=g.video[1].dts,f=g.video[0].dtsTime,n=g.video[1].dtsTime):g.audio&&g.audio.length===2&&(this.inspectCache_=g.audio[1].dts,f=g.audio[0].dtsTime,n=g.audio[1].dtsTime),{start:f,end:n}):null}},{key:"calculateSegmentTimeMapping_",value:function(u,g){var f=u.segment,n=this.timelines[u.timeline];if(u.timestampOffset!==null)d("tsO:",u.timestampOffset),n={time:u.timestampOffset,mapping:u.timestampOffset-g.start},this.timelines[u.timeline]=n,f.start=u.timestampOffset,f.end=g.end+n.mapping;else{if(!n)return!1;f.start=g.start+n.mapping,f.end=g.end+n.mapping}return this.trigger("syncinfoupdate"),!0}},{key:"saveDiscontinuitySyncInfo_",value:function(u){var g=u.playlist,f=u.segment;if(f.discontinuity)this.discontinuities[f.timeline]={time:f.start,accuracy:0};else if(g.discontinuityStarts.length)for(var n=0;n0&&(!this.discontinuities[_]||this.discontinuities[_].accuracy>b)&&(this.discontinuities[_]={time:f.end+(0,s.sumDurations)(g,u.mediaIndex+1,e),accuracy:b})}}}]),p}(r.default.EventTarget);C.default=i}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./playlist":8,"mux.js/lib/mp4/probe":38,"mux.js/lib/tools/ts-inspector.js":39}],17:[function(I,j,C){(function(k){"use strict";Object.defineProperty(C,"__esModule",{value:!0});var E=typeof window!="undefined"?window.videojs:typeof k!="undefined"?k.videojs:null,P=function(){var O=function S(m,v){if(m=(0,E.mergeOptions)({timeout:45e3},m),S.beforeRequest&&typeof S.beforeRequest=="function"){var c=S.beforeRequest(m);c&&(m=c)}var a=(0,E.xhr)(m,function(s,l){!s&&a.response&&(a.responseTime=Date.now(),a.roundTripTime=a.responseTime-a.requestTime,a.bytesReceived=a.response.byteLength||a.response.length,a.bandwidth||(a.bandwidth=Math.floor(a.bytesReceived/a.roundTripTime*8*1e3))),s||a.timedout?a.timedout=a.timedout||s.code==="ETIMEDOUT":a.timedout=!1,s||l.statusCode===200||l.statusCode===206||l.statusCode===0||(s=new Error("XHR Failed with a response of: "+(a&&(a.response||a.responseText)))),v(s,a)});return a.requestTime=Date.now(),a};return O};C.default=P,j.exports=C.default}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],18:[function(I,j,C){"use strict";function k(m,v){if(!(m instanceof v))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(C,"__esModule",{value:!0});var E=function(){function m(v,c){for(var a=0;a>7))^l]=l;for(r=h=0;!a[r];r^=i||1,h=t[h]||1)for(u=h^h<<1^h<<2^h<<3^h<<4,u=u>>8^255&u^99,a[r]=u,s[u]=r,p=d[o=d[i=d[r]]],f=16843009*p^65537*o^257*i^16843008*r,g=257*d[u]^16843008*u,l=0;l<4;l++)v[l][r]=g=g<<24^g>>>8,c[l][u]=f=f<<24^f>>>8;for(l=0;l<5;l++)v[l]=v[l].slice(0),c[l]=c[l].slice(0);return m},O=null,S=function(){function m(v){k(this,m),O||(O=P()),this._tables=[[O[0][0].slice(),O[0][1].slice(),O[0][2].slice(),O[0][3].slice(),O[0][4].slice()],[O[1][0].slice(),O[1][1].slice(),O[1][2].slice(),O[1][3].slice(),O[1][4].slice()]];var c=void 0,a=void 0,s=void 0,l=void 0,r=void 0,h=this._tables[0][4],d=this._tables[1],t=v.length,i=1;if(t!==4&&t!==6&&t!==8)throw new Error("Invalid aes key size");for(l=v.slice(0),r=[],this._key=[l,r],c=t;c<4*t+28;c++)s=l[c-1],(c%t==0||t===8&&c%t==4)&&(s=h[s>>>24]<<24^h[s>>16&255]<<16^h[s>>8&255]<<8^h[255&s],c%t==0&&(s=s<<8^s>>>24^i<<24,i=i<<1^283*(i>>7))),l[c]=l[c-t]^s;for(a=0;c;a++,c--)s=l[3&a?c:c-4],c<=4||a<4?r[a]=s:r[a]=d[0][h[s>>>24]]^d[1][h[s>>16&255]]^d[2][h[s>>8&255]]^d[3][h[255&s]]}return E(m,[{key:"decrypt",value:function(v,c,a,s,l,r){var h=this._key[1],d=v^h[0],t=s^h[1],i=a^h[2],o=c^h[3],p=void 0,u=void 0,g=void 0,f=h.length/4-2,n=void 0,e=4,_=this._tables[1],b=_[0],A=_[1],w=_[2],y=_[3],T=_[4];for(n=0;n>>24]^A[t>>16&255]^w[i>>8&255]^y[255&o]^h[e],u=b[t>>>24]^A[i>>16&255]^w[o>>8&255]^y[255&d]^h[e+1],g=b[i>>>24]^A[o>>16&255]^w[d>>8&255]^y[255&t]^h[e+2],o=b[o>>>24]^A[d>>16&255]^w[t>>8&255]^y[255&i]^h[e+3],e+=4,d=p,t=u,i=g;for(n=0;n<4;n++)l[(3&-n)+r]=T[d>>>24]<<24^T[t>>16&255]<<16^T[i>>8&255]<<8^T[255&o]^h[e++],p=d,d=t,t=i,i=o,o=p}}]),m}();C.default=S,j.exports=C.default},{}],19:[function(I,j,C){"use strict";function k(a){return a&&a.__esModule?a:{default:a}}function E(a,s){if(!(a instanceof s))throw new TypeError("Cannot call a class as a function")}function P(a,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);a.prototype=Object.create(s&&s.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(a,s):a.__proto__=s)}Object.defineProperty(C,"__esModule",{value:!0});var O=function(){function a(s,l){for(var r=0;r>8|r>>>24},s=function(r,h,d){var t=new Int32Array(r.buffer,r.byteOffset,r.byteLength>>2),i=new S.default(Array.prototype.slice.call(h)),o=new Uint8Array(r.byteLength),p=new Int32Array(o.buffer),u=void 0,g=void 0,f=void 0,n=void 0,e=void 0,_=void 0,b=void 0,A=void 0,w=void 0;for(u=d[0],g=d[1],f=d[2],n=d[3],w=0;w-1;r=this.buffer.indexOf(` `))this.trigger("data",this.buffer.substring(0,r)),this.buffer=this.buffer.substring(r+1)}}]),s}(v.default);C.default=c},{"./stream":33}],31:[function(I,j,C){"use strict";function k(r){return r&&r.__esModule?r:{default:r}}function E(r,h){if(!(r instanceof h))throw new TypeError("Cannot call a class as a function")}function P(r,h){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!h||typeof h!="object"&&typeof h!="function"?r:h}function O(r,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof h);r.prototype=Object.create(h&&h.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h&&(Object.setPrototypeOf?Object.setPrototypeOf(r,h):r.__proto__=h)}Object.defineProperty(C,"__esModule",{value:!0});var S=function(){function r(h,d){var t=[],i=!0,o=!1,p=void 0;try{for(var u,g=h[Symbol.iterator]();!(i=(u=g.next()).done)&&(t.push(u.value),!d||t.length!==d);i=!0);}catch(f){o=!0,p=f}finally{try{!i&&g.return&&g.return()}finally{if(o)throw p}}return t}return function(h,d){if(Array.isArray(h))return h;if(Symbol.iterator in Object(h))return r(h,d);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),m=function(){function r(h,d){for(var t=0;t0&&(u.duration=b.duration),b.duration===0&&(u.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=p},key:function(){return b.attributes?b.attributes.METHOD==="NONE"?void(f=null):b.attributes.URI?(b.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),f={method:b.attributes.METHOD||"AES-128",uri:b.attributes.URI},void(typeof b.attributes.IV!="undefined"&&(f.iv=b.attributes.IV))):void this.trigger("warn",{message:"ignoring key declaration without URI"}):void this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){return isFinite(b.number)?void(this.manifest.mediaSequence=b.number):void this.trigger("warn",{message:"ignoring invalid media sequence: "+b.number})},"discontinuity-sequence":function(){return isFinite(b.number)?(this.manifest.discontinuitySequence=b.number,void(_=b.number)):void this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+b.number})},"playlist-type":function(){return/VOD|EVENT/.test(b.playlistType)?void(this.manifest.playlistType=b.playlistType):void this.trigger("warn",{message:"ignoring unknown playlist type: "+b.playlist})},map:function(){g={},b.uri&&(g.uri=b.uri),b.byterange&&(g.byterange=b.byterange)},"stream-inf":function(){return this.manifest.playlists=p,this.manifest.mediaGroups=this.manifest.mediaGroups||e,b.attributes?(u.attributes||(u.attributes={}),void S(u.attributes,b.attributes)):void this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||e,!(b.attributes&&b.attributes.TYPE&&b.attributes["GROUP-ID"]&&b.attributes.NAME))return void this.trigger("warn",{message:"ignoring incomplete or missing media group"});var y=this.manifest.mediaGroups[b.attributes.TYPE];y[b.attributes["GROUP-ID"]]=y[b.attributes["GROUP-ID"]]||{},A=y[b.attributes["GROUP-ID"]],w={default:/yes/i.test(b.attributes.DEFAULT)},w.default?w.autoselect=!0:w.autoselect=/yes/i.test(b.attributes.AUTOSELECT),b.attributes.LANGUAGE&&(w.language=b.attributes.LANGUAGE),b.attributes.URI&&(w.uri=b.attributes.URI),b.attributes["INSTREAM-ID"]&&(w.instreamId=b.attributes["INSTREAM-ID"]),A[b.attributes.NAME]=w},discontinuity:function(){_+=1,u.discontinuity=!0,this.manifest.discontinuityStarts.push(p.length)},"program-date-time":function(){this.manifest.dateTimeString=b.dateTimeString,this.manifest.dateTimeObject=b.dateTimeObject},targetduration:function(){return!isFinite(b.duration)||b.duration<0?void this.trigger("warn",{message:"ignoring invalid target duration: "+b.duration}):void(this.manifest.targetDuration=b.duration)},totalduration:function(){return!isFinite(b.duration)||b.duration<0?void this.trigger("warn",{message:"ignoring invalid total duration: "+b.duration}):void(this.manifest.totalDuration=b.duration)},"cue-out":function(){u.cueOut=b.data},"cue-out-cont":function(){u.cueOutCont=b.data},"cue-in":function(){u.cueIn=b.data}}[b.tagType]||n).call(o)},uri:function(){u.uri=b.uri,p.push(u),!this.manifest.targetDuration||"duration"in u||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),u.duration=this.manifest.targetDuration),f&&(u.key=f),u.timeline=_,g&&(u.map=g),u={}},comment:function(){}})[b.type].call(o)}),i}return O(t,d),m(t,[{key:"push",value:function(i){this.lineStream.push(i)}},{key:"end",value:function(){this.lineStream.push(` `)}}]),t}(c.default);C.default=h},{"./line-stream":30,"./parse-stream":31,"./stream":33}],33:[function(I,j,C){"use strict";function k(O,S){if(!(O instanceof S))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(C,"__esModule",{value:!0});var E=function(){function O(S,m){for(var v=0;v-1}},{key:"trigger",value:function(S){var m=this.listeners[S],v=void 0,c=void 0,a=void 0;if(m)if(arguments.length===2)for(c=m.length,v=0;v>4;return d?r+20:r+10},m=function(s,l){var r=(224&s[l+5])>>5,h=s[l+4]<<3,d=6144&s[l+3];return d|h|r},v=function(s,l){return s[l]==="I".charCodeAt(0)&&s[l+1]==="D".charCodeAt(0)&&s[l+2]==="3".charCodeAt(0)?"timed-metadata":s[l]&!0&&(240&s[l+1])==240?"audio":null},c=function(s){for(var l=0;l+5>>2];l++}return null},a=function(s){var l,r,h,d;l=10,64&s[5]&&(l+=4,l+=E(s.subarray(10,14)));do{if(r=E(s.subarray(l+4,l+8)),r<1)return null;if(d=String.fromCharCode(s[l],s[l+1],s[l+2],s[l+3]),d==="PRIV"){h=s.subarray(l+10,l+r+10);for(var t=0;t>>2;return p*=4,p+=3&o[7]}break}}l+=10,l+=r}while(l>>4>1&&(h+=r[4]+1),h},S=function(r,h){var d=E(r);return d===0?"pat":d===h?"pmt":h?"pes":null},m=function(r){var h=P(r),d=4+O(r);return h&&(d+=r[d]+1),(31&r[d+10])<<8|r[d+11]},v=function(r){var h={},d=P(r),t=4+O(r);if(d&&(t+=r[t]+1),1&r[t+5]){var i,o,p;i=(15&r[t+1])<<8|r[t+2],o=3+i-4,p=(15&r[t+10])<<8|r[t+11];for(var u=12+p;u>>3,i.pts*=4,i.pts+=(6&r[t+13])>>>1,i.dts=i.pts,64&d&&(i.dts=(14&r[t+14])<<27|(255&r[t+15])<<20|(254&r[t+16])<<12|(255&r[t+17])<<5|(254&r[t+18])>>>3,i.dts*=4,i.dts+=(6&r[t+18])>>>1)),i},s=function(r){switch(r){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},l=function(r){for(var h,d=4+O(r),t=r.subarray(d),i=0,o=0,p=!1;o3&&(h=s(31&t[o+3]),h==="slice_layer_without_partitioning_rbsp_idr"&&(p=!0)),p};j.exports={parseType:S,parsePat:m,parsePmt:v,parsePayloadUnitStartIndicator:P,parsePesType:c,parsePesTime:a,videoPacketContainsKeyFrame:l}},{"./stream-types.js":36}],36:[function(I,j,C){"use strict";j.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],37:[function(I,j,C){"use strict";var k=I("../utils/stream"),E=8589934592,P=4294967296,O=function(m,v){var c=1;for(m>v&&(c=-1);Math.abs(v-m)>P;)m+=c*E;return m},S=function(m){var v,c;S.prototype.init.call(this),this.type_=m,this.push=function(a){a.type===this.type_&&(c===void 0&&(c=a.dts),a.dts=O(a.dts,c),a.pts=O(a.pts,c),v=a.dts,this.trigger("data",a))},this.flush=function(){c=v,this.trigger("done")}};S.prototype=new k,j.exports={TimestampRolloverStream:S,handleRollover:O}},{"../utils/stream":40}],38:[function(I,j,C){"use strict";var k,E,P,O;k=function(S,m){var v,c,a,s,l,r=[];if(!m.length)return null;for(v=0;v1?v+c:S.byteLength,a===m[0]&&(m.length===1?r.push(S.subarray(v+8,s)):(l=k(S.subarray(v+8,s),m.slice(1)),l.length&&(r=r.concat(l)))),v=s;return r},E=function(S){var m="";return m+=String.fromCharCode(S[0]),m+=String.fromCharCode(S[1]),m+=String.fromCharCode(S[2]),m+=String.fromCharCode(S[3])},P=function(S){var m={},v=k(S,["moov","trak"]);return v.reduce(function(c,a){var s,l,r,h,d;return(s=k(a,["tkhd"])[0])?(l=s[0],r=l===0?12:20,h=s[r]<<24|s[r+1]<<16|s[r+2]<<8|s[r+3],(d=k(a,["mdia","mdhd"])[0])?(l=d[0],r=l===0?12:20,c[h]=d[r]<<24|d[r+1]<<16|d[r+2]<<8|d[r+3],c):null):null},m)},O=function(S,m){var v,c,a;return v=k(m,["moof","traf"]),c=[].concat.apply([],v.map(function(s){return k(s,["tfhd"]).map(function(l){var r,h,d;return r=l[4]<<24|l[5]<<16|l[6]<<8|l[7],h=S[r]||9e4,d=k(s,["tfdt"]).map(function(t){var i,o;return i=t[0],o=t[4]<<24|t[5]<<16|t[6]<<8|t[7],i===1&&(o*=Math.pow(2,32),o+=t[8]<<24|t[9]<<16|t[10]<<8|t[11]),o})[0],d=d||1/0,d/h})})),a=Math.min.apply(null,c),isFinite(a)?a:0},j.exports={parseType:E,timescale:P,startTime:O}},{}],39:[function(I,j,C){"use strict";var k=I("../m2ts/stream-types.js"),E=I("../m2ts/timestamp-rollover-stream.js").handleRollover,P={};P.ts=I("../m2ts/probe.js"),P.aac=I("../aac/probe.js");var O=9e4,S=188,m=71,v=function(t){return t[0]==="I".charCodeAt(0)&&t[1]==="D".charCodeAt(0)&&t[2]==="3".charCodeAt(0)},c=function(t,i){for(var o,p,u=0,g=S;g=0;)if(t[e]!==m||t[_]!==m)e--,_--;else{switch(p=t.subarray(e,_),u=P.ts.parseType(p,i.pid)){case"pes":g=P.ts.parsePesType(p,i.table),f=P.ts.parsePayloadUnitStartIndicator(p),g==="audio"&&f&&(n=P.ts.parsePesTime(p),n.type="audio",o.audio.push(n),b=!0)}if(b)break;e-=S,_-=S}},s=function(t,i,o){for(var p,u,g,f,n,e,_,b,A=0,w=S,y=!1,T={data:[],size:0};w=0;)if(t[A]!==m||t[w]!==m)A--,w--;else{switch(p=t.subarray(A,w),u=P.ts.parseType(p,i.pid)){case"pes":g=P.ts.parsePesType(p,i.table),f=P.ts.parsePayloadUnitStartIndicator(p),g==="video"&&f&&(n=P.ts.parsePesTime(p),n.type="video",o.video.push(n),y=!0)}if(y)break;A-=S,w-=S}},l=function(t,i){if(t.audio&&t.audio.length){var o=i;typeof o=="undefined"&&(o=t.audio[0].dts),t.audio.forEach(function(g){g.dts=E(g.dts,o),g.pts=E(g.pts,o),g.dtsTime=g.dts/O,g.ptsTime=g.pts/O})}if(t.video&&t.video.length){var p=i;if(typeof p=="undefined"&&(p=t.video[0].dts),t.video.forEach(function(g){g.dts=E(g.dts,p),g.pts=E(g.pts,p),g.dtsTime=g.dts/O,g.ptsTime=g.pts/O}),t.firstKeyFrame){var u=t.firstKeyFrame;u.dts=E(u.dts,p),u.pts=E(u.pts,p),u.dtsTime=u.dts/O,u.ptsTime=u.dts/O}}},r=function(t){for(var i,o=!1,p=0,u=null,g=null,f=0,n=0;t.length-n>=3;){var e=P.aac.parseType(t,n);switch(e){case"timed-metadata":if(t.length-n<10){o=!0;break}if(f=P.aac.parseId3TagSize(t,n),f>t.length){o=!0;break}g===null&&(i=t.subarray(n,n+f),g=P.aac.parseAacTimestamp(i)),n+=f;break;case"audio":if(t.length-n<7){o=!0;break}if(f=P.aac.parseAdtsSize(t,n),f>t.length){o=!0;break}u===null&&(i=t.subarray(n,n+f),u=P.aac.parseSampleRate(i)),p++,n+=f;break;default:n++}if(o)return null}if(u===null||g===null)return null;var _=O/u,b={audio:[{type:"audio",dts:g,pts:g},{type:"audio",dts:g+1024*p*_,pts:g+1024*p*_}]};return b},h=function(t){var i={pid:null,table:null},o={};c(t,i);for(var p in i.table)if(i.table.hasOwnProperty(p)){var u=i.table[p];switch(u){case k.H264_STREAM_TYPE:o.video=[],s(t,i,o),o.video.length===0&&delete o.video;break;case k.ADTS_STREAM_TYPE:o.audio=[],a(t,i,o),o.audio.length===0&&delete o.audio}}return o},d=function(t,i){var o,p=v(t);return o=p?r(t):h(t),o&&(o.audio||o.video)?(l(o,i),o):null};j.exports={inspect:d}},{"../aac/probe.js":34,"../m2ts/probe.js":35,"../m2ts/stream-types.js":36,"../m2ts/timestamp-rollover-stream.js":37}],40:[function(I,j,C){"use strict";var k=function(){this.init=function(){var E={};this.on=function(P,O){E[P]||(E[P]=[]),E[P]=E[P].concat(O)},this.off=function(P,O){var S;return!!E[P]&&(S=E[P].indexOf(O),E[P]=E[P].slice(),E[P].splice(S,1),S>-1)},this.trigger=function(P){var O,S,m,v;if(O=E[P])if(arguments.length===2)for(m=O.length,S=0;S-1;h=a+c)c=/^\/(?:\.\.\/)*/.exec(r.slice(a))[0].length,l=(l+r.substring(h,a)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(c-1)/3+"}$"),"/");return l+r.substr(h)}};typeof C=="object"&&typeof j=="object"?j.exports=S:typeof nt=="function"&&nt.amd?nt([],function(){return S}):typeof C=="object"?C.URLToolkit=S:k.URLToolkit=S})(this)},{}],42:[function(I,j,C){(function(k){"use strict";function E(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(C,"__esModule",{value:!0});var P=I("global/window"),O=E(P),S=typeof window!="undefined"?window.videojs:typeof k!="undefined"?k.videojs:null,m=E(S),v=function(s){Object.defineProperties(s.frame,{id:{get:function(){return m.default.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),s.value.key}},value:{get:function(){return m.default.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),s.value.data}},privateData:{get:function(){return m.default.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),s.value.data}}})},c=function(s){var l=void 0;return l=isNaN(s)||Math.abs(s)===1/0?Number.MAX_VALUE:s},a=function(s,l,r){var h=O.default.WebKitDataCue||O.default.VTTCue;if(l&&l.forEach(function(u){this.inbandTextTrack_.addCue(new h(u.startTime+this.timestampOffset,u.endTime+this.timestampOffset,u.text))},s),r){var d=c(s.mediaSource_.duration);if(r.forEach(function(u){var g=u.cueTime+this.timestampOffset;u.frames.forEach(function(f){var n=new h(g,g,f.value||f.url||f.data||"");n.frame=f,n.value=f,v(n),this.metadataTrack_.addCue(n)},this)},s),s.metadataTrack_&&s.metadataTrack_.cues&&s.metadataTrack_.cues.length){for(var t=s.metadataTrack_.cues,i=[],o=0;o1){var s=a[0].replace(/"/g,"").trim(),l=a[1].replace(/"/g,"").trim();m.parameters[s]=l}}),m},O=function(S){return S.map(function(m){return m.replace(/avc1\.(\d+)\.(\d+)/i,function(v,c,a){var s=("00"+Number(c).toString(16)).slice(-2),l=("00"+Number(a).toString(16)).slice(-2);return"avc1."+s+"00"+l})})};C.default={isAudioCodec:k,parseContentType:P,isVideoCodec:E,translateLegacyCodecs:O},j.exports=C.default},{}],45:[function(I,j,C){"use strict";Object.defineProperty(C,"__esModule",{value:!0});var k=I("./cleanup-text-tracks"),E=function(P,O,S){var m=O.player_;S.captions&&S.captions.length&&!P.inbandTextTrack_&&((0,k.removeExistingTrack)(m,"captions","cc1"),P.inbandTextTrack_=m.addRemoteTextTrack({kind:"captions",label:"cc1"},!1).track),S.metadata&&S.metadata.length&&!P.metadataTrack_&&((0,k.removeExistingTrack)(m,"metadata","Timed Metadata",!0),P.metadataTrack_=m.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,P.metadataTrack_.inBandMetadataTrackDispatchType=S.metadata.dispatchType)};C.default=E,j.exports=C.default},{"./cleanup-text-tracks":43}],46:[function(I,j,C){"use strict";Object.defineProperty(C,"__esModule",{value:!0});var k={TIME_BETWEEN_CHUNKS:1,BYTES_PER_CHUNK:32768};C.default=k,j.exports=C.default},{}],47:[function(I,j,C){(function(k){"use strict";function E(u){return u&&u.__esModule?u:{default:u}}function P(u,g){if(!(u instanceof g))throw new TypeError("Cannot call a class as a function")}function O(u,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);u.prototype=Object.create(g&&g.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(u,g):u.__proto__=g)}Object.defineProperty(C,"__esModule",{value:!0});var S=function(){function u(g,f){for(var n=0;n=0&&(this.timestampOffset_=M,this.mediaSource_.swfObj.vjs_discontinuity(),this.basePtsOffset_=NaN,this.transmuxer_.postMessage({action:"reset"}))}}),Object.defineProperty(this,"buffered",{get:function(){if(!(this.mediaSource_&&this.mediaSource_.swfObj&&"vjs_getProperty"in this.mediaSource_.swfObj))return s.default.createTimeRange();var M=this.mediaSource_.swfObj.vjs_getProperty("buffered");return M&&M.length&&(M[0][0]=A(M[0][0],3),M[0][1]=A(M[0][1],3)),s.default.createTimeRanges(M)}}),this.mediaSource_.player_.on("seeked",function(){(0,d.default)(0,1/0,L.metadataTrack_),(0,d.default)(0,1/0,L.inbandTextTrack_)}),this.mediaSource_.player_.tech_.hls.on("dispose",function(){L.transmuxer_.terminate()})}return O(T,y),S(T,[{key:"appendBuffer",value:function(U){var L=void 0;if(this.updating)throw L=new Error("SourceBuffer.append() cannot be called while an update is in progress"),L.name="InvalidStateError",L.code=11,L;this.updating=!0,this.mediaSource_.readyState="open",this.trigger({type:"update"}),this.transmuxer_.postMessage({action:"push",data:U.buffer,byteOffset:U.byteOffset,byteLength:U.byteLength},[U.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"abort",value:function(){this.buffer_=[],this.bufferSize_=0,this.mediaSource_.swfObj.vjs_abort(),this.updating&&(this.updating=!1,this.trigger({type:"updateend"}))}},{key:"remove",value:function(U,L){(0,d.default)(U,L,this.metadataTrack_),(0,d.default)(U,L,this.inbandTextTrack_),this.trigger({type:"update"}),this.trigger({type:"updateend"})}},{key:"receiveBuffer_",value:function(U){var L=this;(0,i.default)(this,this.mediaSource_,U),(0,o.addTextTrackData)(this,U.captions,U.metadata),_(function(){var D=L.convertTagsToData_(U);L.buffer_.length===0&&_(L.processBuffer_.bind(L)),D&&(L.buffer_.push(D),L.bufferSize_+=D.byteLength)})}},{key:"processBuffer_",value:function(){var U=this,L=e.default.BYTES_PER_CHUNK;if(!this.buffer_.length)return void(this.updating!==!1&&(this.updating=!1,this.trigger({type:"updateend"})));var D=this.buffer_[0].subarray(0,L);D.byteLength=x&&N.push(B[X]);for(var Y=0;Y=x)G.push($);else if($.keyFrame){for(var Q=Y+1,R=!1;Q=x)break;if(q.keyFrame){R=!0;break}Q++}if(R)Y=Q;else for(;Ythis.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=n)}},{key:"addSourceBuffer",value:function(f){var n=void 0,e=(0,i.parseContentType)(f);if(/^(video|audio)\/mp2t$/i.test(e.type)){var _=[];e.parameters&&e.parameters.codecs&&(_=e.parameters.codecs.split(","),_=(0,i.translateLegacyCodecs)(_),_=_.filter(function(b){return(0,i.isAudioCodec)(b)||(0,i.isVideoCodec)(b)})),_.length===0&&(_=["avc1.4d400d","mp4a.40.2"]),n=new d.default(this,_),this.sourceBuffers.length!==0&&(this.sourceBuffers[0].createRealSourceBuffers_(),n.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else n=this.nativeMediaSource_.addSourceBuffer(f);return this.sourceBuffers.push(n),n}}]),g}(r.default.EventTarget);C.default=p,j.exports=C.default}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./add-text-track-data":42,"./cleanup-text-tracks":43,"./codec-utils":44,"./virtual-source-buffer":54,"global/document":27,"global/window":28}],51:[function(I,j,C){"use strict";Object.defineProperty(C,"__esModule",{value:!0});var k=function(E,P,O){var S=void 0,m=void 0;if(O&&O.cues)for(S=O.cues.length;S--;)m=O.cues[S],m.startTime<=P&&m.endTime>=E&&O.removeCue(m)};C.default=k,j.exports=C.default},{}],52:[function(I,j,C){"use strict";function k(l){return l&&l.__esModule?l:{default:l}}function E(l,r){if(!(l instanceof r))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(C,"__esModule",{value:!0});var P=function(){function l(r,h){for(var d=0;d=0&&(this.timestampOffset_=A,this.appendAudioInitSegment_=!0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:A}))}}),Object.defineProperty(this,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(A){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=A),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=A)}}),Object.defineProperty(this,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(this,"buffered",{get:function(){var A=null,w=null,y=0,T=[],U=[];if(!this.videoBuffer_&&!this.audioBuffer_)return c.default.createTimeRange();if(!this.videoBuffer_)return this.audioBuffer_.buffered;if(!this.audioBuffer_)return this.videoBuffer_.buffered;if(this.audioDisabled_)return this.videoBuffer_.buffered;if(this.videoBuffer_.buffered.length===0&&this.audioBuffer_.buffered.length===0)return c.default.createTimeRange();for(var L=this.videoBuffer_.buffered,D=this.audioBuffer_.buffered,x=L.length;x--;)T.push({time:L.start(x),type:"start"}),T.push({time:L.end(x),type:"end"});for(x=D.length;x--;)T.push({time:D.start(x),type:"start"}),T.push({time:D.end(x),type:"end"});for(T.sort(function(M,N){return M.time-N.time}),x=0;x>4;return a?v+20:v+10},this.parseAdtsSize=function(S,m){var v=(224&S[m+5])>>5,c=S[m+4]<<3,a=6144&S[m+3];return a|c|v},this.push=function(S){var m,v,c,a,s=0,l=0;for(P.length?(a=P.length,P=new Uint8Array(S.byteLength+a),P.set(P.subarray(0,a)),P.set(S,a)):P=S;P.length-l>=3;)if(P[l]!=="I".charCodeAt(0)||P[l+1]!=="D".charCodeAt(0)||P[l+2]!=="3".charCodeAt(0))if(P[l]&!0&&(240&P[l+1])==240){if(P.length-l<7||(s=this.parseAdtsSize(P,l),s>P.length))break;c={type:"audio",data:P.subarray(l,l+s),pts:O,dts:O},this.trigger("data",c),l+=s}else l++;else{if(P.length-l<10||(s=this.parseId3TagSize(P,l),s>P.length))break;v={type:"timed-metadata",data:P.subarray(l,l+s)},this.trigger("data",v),l+=s}m=P.length-l,P=m>0?P.subarray(l):new Uint8Array}},k.prototype=new E,j.exports=k},{"../utils/stream.js":75}],56:[function(I,j,C){"use strict";var k,E=I("../utils/stream.js"),P=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];k=function(){var O;k.prototype.init.call(this),this.push=function(S){var m,v,c,a,s,l,r=0,h=0;if(S.type==="audio")for(O?(a=O,O=new Uint8Array(a.byteLength+S.data.byteLength),O.set(a),O.set(S.data,a.byteLength)):O=S.data;r+5>5,s=1024*((3&O[r+6])+1),l=9e4*s/P[(60&O[r+2])>>>2],c=r+m,O.byteLength>>6&3)+1,channelcount:(1&O[r+2])<<2|(192&O[r+3])>>>6,samplerate:P[(60&O[r+2])>>>2],samplingfrequencyindex:(60&O[r+2])>>>2,samplesize:16,data:O.subarray(r+7+v,c)}),O.byteLength===c)return void(O=void 0);h++,O=O.subarray(c)}else r++},this.flush=function(){this.trigger("done")}},k.prototype=new E,j.exports=k},{"../utils/stream.js":75}],57:[function(I,j,C){"use strict";var k,E,P,O=I("../utils/stream.js"),S=I("../utils/exp-golomb.js");E=function(){var m,v,c=0;E.prototype.init.call(this),this.push=function(a){var s;for(v?(s=new Uint8Array(v.byteLength+a.data.byteLength),s.set(v),s.set(a.data,v.byteLength),v=s):v=a.data;c3&&this.trigger("data",v.subarray(c+3)),v=null,c=0,this.trigger("done")}},E.prototype=new O,P={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},k=function(){var m,v,c,a,s,l,r,h=new E;k.prototype.init.call(this),m=this,this.push=function(d){d.type==="video"&&(v=d.trackId,c=d.pts,a=d.dts,h.push(d))},h.on("data",function(d){var t={trackId:v,pts:c,dts:a,data:d};switch(31&d[0]){case 5:t.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:t.nalUnitType="sei_rbsp",t.escapedRBSP=s(d.subarray(1));break;case 7:t.nalUnitType="seq_parameter_set_rbsp",t.escapedRBSP=s(d.subarray(1)),t.config=l(t.escapedRBSP);break;case 8:t.nalUnitType="pic_parameter_set_rbsp";break;case 9:t.nalUnitType="access_unit_delimiter_rbsp"}m.trigger("data",t)}),h.on("done",function(){m.trigger("done")}),this.flush=function(){h.flush()},r=function(d,t){var i,o,p=8,u=8;for(i=0;i0)throw new Error("Attempted to create new NAL wihout closing the old one");S=this.length,this.length+=4,this.position=this.length},this.endNalUnit=function(l){var r,h;this.length===S+4?this.length-=4:S>0&&(r=S+4,h=this.length-r,this.position=S,this.view.setUint32(this.position,h),this.position=this.length,l&&l.push(this.bytes.subarray(r,r+h))),S=0},this.writeMetaDataDouble=function(l,r){var h;if(v(this,2+l.length+9),this.view.setUint16(this.position,l.length),this.position+=2,l==="width")this.bytes.set(c,this.position),this.position+=5;else if(l==="height")this.bytes.set(a,this.position),this.position+=6;else if(l==="videocodecid")this.bytes.set(s,this.position),this.position+=12;else for(h=0;h>>16,this.bytes[14]=(65280&l)>>>8,this.bytes[15]=(255&l)>>>0;break;case k.AUDIO_TAG:this.bytes[11]=175,this.bytes[12]=P?0:1;break;case k.METADATA_TAG:this.position=11,this.view.setUint8(this.position,2),this.position++,this.view.setUint16(this.position,10),this.position+=2,this.bytes.set([111,110,77,101,116,97,68,97,116,97],this.position),this.position+=10,this.bytes[this.position]=8,this.position++,this.view.setUint32(this.position,S),this.position=this.length,this.bytes.set([0,0,9],this.position),this.position+=3,this.length=this.position}return r=this.length-11,this.bytes[1]=(16711680&r)>>>16,this.bytes[2]=(65280&r)>>>8,this.bytes[3]=(255&r)>>>0,this.bytes[4]=(16711680&this.dts)>>>16,this.bytes[5]=(65280&this.dts)>>>8,this.bytes[6]=(255&this.dts)>>>0,this.bytes[7]=(4278190080&this.dts)>>>24,this.bytes[8]=0,this.bytes[9]=0,this.bytes[10]=0,v(this,4),this.view.setUint32(this.length,this.length),this.length+=4,this.position+=4,this.bytes=this.bytes.subarray(0,this.length),this.frameTime=k.frameTime(this.bytes),this}},k.AUDIO_TAG=8,k.VIDEO_TAG=9,k.METADATA_TAG=18,k.isAudioFrame=function(E){return k.AUDIO_TAG===E[0]},k.isVideoFrame=function(E){return k.VIDEO_TAG===E[0]},k.isMetaData=function(E){return k.METADATA_TAG===E[0]},k.isKeyFrame=function(E){return k.isVideoFrame(E)?E[11]===23:!!k.isAudioFrame(E)||!!k.isMetaData(E)},k.frameTime=function(E){var P=E[4]<<16;return P|=E[5]<<8,P|=E[6]<<0,P|=E[7]<<24},j.exports=k},{}],62:[function(I,j,C){j.exports={tag:I("./flv-tag"),Transmuxer:I("./transmuxer"),getFlvHeader:I("./flv-header")}},{"./flv-header":60,"./flv-tag":61,"./transmuxer":64}],63:[function(I,j,C){"use strict";var k=function(){var E=this;this.list=[],this.push=function(P){this.list.push({bytes:P.bytes,dts:P.dts,pts:P.pts})},Object.defineProperty(this,"length",{get:function(){return E.list.length}})};j.exports=k},{}],64:[function(I,j,C){"use strict";var k,E,P,O,S,m,v=I("../utils/stream.js"),c=I("./flv-tag.js"),a=I("../m2ts/m2ts.js"),s=I("../codecs/adts.js"),l=I("../codecs/h264").H264Stream,r=I("./coalesce-stream.js"),h=I("./tag-list.js");O=function(d,t){typeof t.pts=="number"&&(d.timelineStartInfo.pts===void 0?d.timelineStartInfo.pts=t.pts:d.timelineStartInfo.pts=Math.min(d.timelineStartInfo.pts,t.pts)),typeof t.dts=="number"&&(d.timelineStartInfo.dts===void 0?d.timelineStartInfo.dts=t.dts:d.timelineStartInfo.dts=Math.min(d.timelineStartInfo.dts,t.dts))},S=function(d,t){var i=new c(c.METADATA_TAG);return i.dts=t,i.pts=t,i.writeMetaDataDouble("videocodecid",7),i.writeMetaDataDouble("width",d.width),i.writeMetaDataDouble("height",d.height),i},m=function(d,t){var i,o=new c(c.VIDEO_TAG,!0);for(o.dts=t,o.pts=t,o.writeByte(1),o.writeByte(d.profileIdc),o.writeByte(d.profileCompatibility),o.writeByte(d.levelIdc),o.writeByte(255),o.writeByte(225),o.writeShort(d.sps[0].length),o.writeBytes(d.sps[0]),o.writeByte(d.pps.length),i=0;i=1e3)&&(p=new c(c.METADATA_TAG),p.pts=o.pts,p.dts=o.dts,p.writeMetaDataDouble("audiocodecid",10),p.writeMetaDataBoolean("stereo",d.channelcount===2),p.writeMetaDataDouble("audiosamplerate",d.samplerate),p.writeMetaDataDouble("audiosamplesize",16),g.push(p.finalize()),t=d.extraData,p=new c(c.AUDIO_TAG,!0),p.pts=o.pts,p.dts=o.dts,p.view.setUint16(p.position,d.extraData),p.position+=2,p.length=Math.max(p.length,p.position),g.push(p.finalize()),u=o.pts),p=new c(c.AUDIO_TAG),p.pts=o.pts,p.dts=o.dts,p.writeBytes(o.data),g.push(p.finalize());t=null,this.trigger("data",{track:d,tags:g.list}),this.trigger("done","AudioSegmentStream")}},P.prototype=new v,E=function(d){var t,i,o=[];E.prototype.init.call(this),this.finishFrame=function(p,u){u&&(t&&d&&d.newMetadata&&(u.keyFrame||p.length===0)&&(p.push(S(t,u.dts).finalize()),p.push(m(d,u.dts).finalize()),d.newMetadata=!1),u.endNalUnit(),p.push(u.finalize()),i=null)},this.push=function(p){O(d,p),p.pts=Math.round(p.pts/90),p.dts=Math.round(p.dts/90),o.push(p)},this.flush=function(){for(var p,u=new h;o.length&&o[0].nalUnitType!=="access_unit_delimiter_rbsp";)o.shift();if(o.length===0)return void this.trigger("done","VideoSegmentStream");for(;o.length;)p=o.shift(),p.nalUnitType==="seq_parameter_set_rbsp"?(d.newMetadata=!0,t=p.config,d.width=t.width,d.height=t.height,d.sps=[p.data],d.profileIdc=t.profileIdc,d.levelIdc=t.levelIdc,d.profileCompatibility=t.profileCompatibility,i.endNalUnit()):p.nalUnitType==="pic_parameter_set_rbsp"?(d.newMetadata=!0,d.pps=[p.data],i.endNalUnit()):p.nalUnitType==="access_unit_delimiter_rbsp"?(i&&this.finishFrame(u,i),i=new c(c.VIDEO_TAG),i.pts=p.pts,i.dts=p.dts):(p.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(i.keyFrame=!0),i.endNalUnit()),i.startNalUnit(),i.writeBytes(p.data);i&&this.finishFrame(u,i),this.trigger("data",{track:d,tags:u.list}),this.trigger("done","VideoSegmentStream")}},E.prototype=new v,k=function(d){var t,i,o,p,u,g,f,n,e,_,b,A,w=this;k.prototype.init.call(this),d=d||{},this.metadataStream=new a.MetadataStream,d.metadataStream=this.metadataStream,t=new a.TransportPacketStream,i=new a.TransportParseStream,o=new a.ElementaryStream,p=new a.TimestampRolloverStream("video"),u=new a.TimestampRolloverStream("audio"),g=new a.TimestampRolloverStream("timed-metadata"),f=new s,n=new l,A=new r(d),t.pipe(i).pipe(o),o.pipe(p).pipe(n),o.pipe(u).pipe(f),o.pipe(g).pipe(this.metadataStream).pipe(A),b=new a.CaptionStream,n.pipe(b).pipe(A),o.on("data",function(y){var T,U,L;if(y.type==="metadata"){for(T=y.tracks.length;T--;)y.tracks[T].type==="video"?U=y.tracks[T]:y.tracks[T].type==="audio"&&(L=y.tracks[T]);U&&!e&&(A.numberOfTracks++,e=new E(U),n.pipe(e).pipe(A)),L&&!_&&(A.numberOfTracks++,_=new P(L),f.pipe(_).pipe(A))}}),this.push=function(y){t.push(y)},this.flush=function(){t.flush()},A.on("data",function(y){w.trigger("data",y)}),A.on("done",function(){w.trigger("done")})},k.prototype=new v,j.exports=k},{"../codecs/adts.js":56,"../codecs/h264":57,"../m2ts/m2ts.js":66,"../utils/stream.js":75,"./coalesce-stream.js":59,"./flv-tag.js":61,"./tag-list.js":63}],65:[function(I,j,C){"use strict";var k=4,E=128,P=I("../utils/stream"),O=function(e){for(var _=0,b={payloadType:-1,payloadSize:0},A=0,w=0;_>>8,w=255&_,A>=16&&A<=23&&w>=64&&w<=127&&(A!==16||w<96)&&(A=32,w=null),(A===17||A===25)&&w>=48&&w<=63&&(A=9834,w=""),(240&A)==16)return;A===0&&(A=null),w===0&&(w=null),this[this.mode_](e.pts,A,w)}}}};n.prototype=new P,n.prototype.flushDisplayed=function(e){var _=this.displayed_.map(function(b){return b.trim()}).filter(function(b){return b.length}).join(` `);_.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:_})},n.prototype.popOn=function(e,_,b){var A=this.nonDisplayed_[g];A+=a(_),A+=a(b),this.nonDisplayed_[g]=A},n.prototype.rollUp=function(e,_,b){var A=this.displayed_[g];A===""&&(this.flushDisplayed(e),this.startPts_=e),A+=a(_),A+=a(b),this.displayed_[g]=A},n.prototype.shiftRowsUp_=function(){var e;for(e=0;e>>4>1&&(u+=o[u]+1),p.pid===0?(p.type="pat",h(o.subarray(u),p),this.trigger("data",p)):p.pid===this.pmtPid?(p.type="pmt",h(o.subarray(u),p),this.trigger("data",p)):this.programMapTable===void 0?this.packetsWaitingForPmt.push([o,u,p]):this.processPes_(o,u,p)},this.processPes_=function(o,p,u){u.streamType=this.programMapTable[u.pid],u.type="pes",u.data=o.subarray(p),this.trigger("data",u)}},E.prototype=new O,E.STREAM_TYPES={h264:27,adts:15},P=function(){var h=this,d={data:[],size:0},t={data:[],size:0},i={data:[],size:0},o=function(u,g){var f;g.dataAlignmentIndicator=(4&u[6])!=0,f=u[7],192&f&&(g.pts=(14&u[9])<<27|(255&u[10])<<20|(254&u[11])<<12|(255&u[12])<<5|(254&u[13])>>>3,g.pts*=4,g.pts+=(6&u[13])>>>1,g.dts=g.pts,64&f&&(g.dts=(14&u[14])<<27|(255&u[15])<<20|(254&u[16])<<12|(255&u[17])<<5|(254&u[18])>>>3,g.dts*=4,g.dts+=(6&u[18])>>>1)),g.data=u.subarray(9+u[8])},p=function(u,g){var f,n=new Uint8Array(u.size),e={type:g},_=0;if(u.data.length){for(e.trackId=u.data[0].pid;u.data.length;)f=u.data.shift(),n.set(f.data,_),_+=f.data.byteLength;o(n,e),u.size=0,h.trigger("data",e)}};P.prototype.init.call(this),this.push=function(u){({pat:function(){},pes:function(){var g,f;switch(u.streamType){case m.H264_STREAM_TYPE:case c.H264_STREAM_TYPE:g=d,f="video";break;case m.ADTS_STREAM_TYPE:g=t,f="audio";break;case m.METADATA_STREAM_TYPE:g=i,f="timed-metadata";break;default:return}u.payloadUnitStartIndicator&&p(g,f),g.data.push(u),g.size+=u.data.byteLength},pmt:function(){var g,f,n={type:"metadata",tracks:[]},e=u.programMapTable;for(g in e)e.hasOwnProperty(g)&&(f={timelineStartInfo:{baseMediaDecodeTime:0}},f.id=+g,e[g]===c.H264_STREAM_TYPE?(f.codec="avc",f.type="video"):e[g]===c.ADTS_STREAM_TYPE&&(f.codec="adts",f.type="audio"),n.tracks.push(f));h.trigger("data",n)}})[u.type]()},this.flush=function(){p(d,"video"),p(t,"audio"),p(i,"timed-metadata"),this.trigger("done")}},P.prototype=new O;var l={PAT_PID:0,MP2T_PACKET_LENGTH:a,TransportPacketStream:k,TransportParseStream:E,ElementaryStream:P,TimestampRolloverStream:v,CaptionStream:S.CaptionStream,Cea608Stream:S.Cea608Stream,MetadataStream:I("./metadata-stream")};for(var r in m)m.hasOwnProperty(r)&&(l[r]=m[r]);j.exports=l},{"../utils/stream.js":75,"./caption-stream":65,"./metadata-stream":67,"./stream-types":68,"./stream-types.js":68,"./timestamp-rollover-stream":69}],67:[function(I,j,C){"use strict";var k,E=I("../utils/stream"),P=I("./stream-types"),O=function(a,s,l){var r,h="";for(r=s;r>>2;e*=4,e+=3&n[7],u.timeStamp=e,i.pts===void 0&&i.dts===void 0&&(i.pts=u.timeStamp,i.dts=u.timeStamp),this.trigger("timestamp",u)}i.frames.push(u),o+=10,o+=p}while(o>>1,B.samplingfrequencyindex<<7|B.channelcount<<3,6,1,2]))},O=function(){return k(e.ftyp,_,b,_,A)},i=function(B){return k(e.hdlr,T[B])},S=function(B){return k(e.mdat,B)},t=function(B){var F=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,B.duration>>>24&255,B.duration>>>16&255,B.duration>>>8&255,255&B.duration,85,196,0,0]);return B.samplerate&&(F[12]=B.samplerate>>>24&255,F[13]=B.samplerate>>>16&255,F[14]=B.samplerate>>>8&255,F[15]=255&B.samplerate),k(e.mdhd,F)},d=function(B){return k(e.mdia,t(B),i(B.type),v(B))},m=function(B){return k(e.mfhd,new Uint8Array([0,0,0,0,(4278190080&B)>>24,(16711680&B)>>16,(65280&B)>>8,255&B]))},v=function(B){return k(e.minf,B.type==="video"?k(e.vmhd,U):k(e.smhd,L),E(),p(B))},c=function(B,F){for(var H=[],X=F.length;X--;)H[X]=g(F[X]);return k.apply(null,[e.moof,m(B)].concat(H))},a=function(B){for(var F=B.length,H=[];F--;)H[F]=r(B[F]);return k.apply(null,[e.moov,l(4294967295)].concat(H).concat(s(B)))},s=function(B){for(var F=B.length,H=[];F--;)H[F]=f(B[F]);return k.apply(null,[e.mvex].concat(H))},l=function(B){var F=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&B)>>24,(16711680&B)>>16,(65280&B)>>8,255&B,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return k(e.mvhd,F)},o=function(B){var F,H,X=B.samples||[],Y=new Uint8Array(4+X.length);for(H=0;H>>8),Q.push(255&Y[X].byteLength),Q=Q.concat(Array.prototype.slice.call(Y[X]));for(X=0;X<$.length;X++)R.push((65280&$[X].byteLength)>>>8),R.push(255&$[X].byteLength),R=R.concat(Array.prototype.slice.call($[X]));return k(e.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&H.width)>>8,255&H.width,(65280&H.height)>>8,255&H.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),k(e.avcC,new Uint8Array([1,H.profileIdc,H.profileCompatibility,H.levelIdc,255].concat([Y.length]).concat(Q).concat([$.length]).concat(R))),k(e.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))},F=function(H){return k(e.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&H.channelcount)>>8,255&H.channelcount,(65280&H.samplesize)>>8,255&H.samplesize,0,0,0,0,(65280&H.samplerate)>>8,255&H.samplerate,0,0]),P(H))}}(),h=function(B){var F=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&B.id)>>24,(16711680&B.id)>>16,(65280&B.id)>>8,255&B.id,0,0,0,0,(4278190080&B.duration)>>24,(16711680&B.duration)>>16,(65280&B.duration)>>8,255&B.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&B.width)>>8,255&B.width,0,0,(65280&B.height)>>8,255&B.height,0,0]);return k(e.tkhd,F)},g=function(B){var F,H,X,Y,$,Q,R;return F=k(e.tfhd,new Uint8Array([0,0,0,58,(4278190080&B.id)>>24,(16711680&B.id)>>16,(65280&B.id)>>8,255&B.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),Q=Math.floor(B.baseMediaDecodeTime/(W+1)),R=Math.floor(B.baseMediaDecodeTime%(W+1)),H=k(e.tfdt,new Uint8Array([1,0,0,0,Q>>>24&255,Q>>>16&255,Q>>>8&255,255&Q,R>>>24&255,R>>>16&255,R>>>8&255,255&R])),$=92,B.type==="audio"?(X=n(B,$),k(e.traf,F,H,X)):(Y=o(B),X=n(B,Y.length+$),k(e.traf,F,H,X,Y))},r=function(B){return B.duration=B.duration||4294967295,k(e.trak,h(B),d(B))},f=function(B){var F=new Uint8Array([0,0,0,0,(4278190080&B.id)>>24,(16711680&B.id)>>16,(65280&B.id)>>8,255&B.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return B.type!=="video"&&(F[F.length-1]=0),k(e.trex,F)},function(){var B,F,H;H=function(X,Y){var $=0,Q=0,R=0,q=0;return X.length&&(X[0].duration!==void 0&&($=1),X[0].size!==void 0&&(Q=2),X[0].flags!==void 0&&(R=4),X[0].compositionTimeOffset!==void 0&&(q=8)),[0,0,$|Q|R|q,1,(4278190080&X.length)>>>24,(16711680&X.length)>>>16,(65280&X.length)>>>8,255&X.length,(4278190080&Y)>>>24,(16711680&Y)>>>16,(65280&Y)>>>8,255&Y]},F=function(X,Y){var $,Q,R,q;for(Q=X.samples||[],Y+=20+16*Q.length,$=H(Q,Y),q=0;q>>24,(16711680&R.duration)>>>16,(65280&R.duration)>>>8,255&R.duration,(4278190080&R.size)>>>24,(16711680&R.size)>>>16,(65280&R.size)>>>8,255&R.size,R.flags.isLeading<<2|R.flags.dependsOn,R.flags.isDependedOn<<6|R.flags.hasRedundancy<<4|R.flags.paddingValue<<1|R.flags.isNonSyncSample,61440&R.flags.degradationPriority,15&R.flags.degradationPriority,(4278190080&R.compositionTimeOffset)>>>24,(16711680&R.compositionTimeOffset)>>>16,(65280&R.compositionTimeOffset)>>>8,255&R.compositionTimeOffset]);return k(e.trun,new Uint8Array($))},B=function(X,Y){var $,Q,R,q;for(Q=X.samples||[],Y+=20+8*Q.length,$=H(Q,Y),q=0;q>>24,(16711680&R.duration)>>>16,(65280&R.duration)>>>8,255&R.duration,(4278190080&R.size)>>>24,(16711680&R.size)>>>16,(65280&R.size)>>>8,255&R.size]);return k(e.trun,new Uint8Array($))},n=function(X,Y){return X.type==="audio"?B(X,Y):F(X,Y)}}(),j.exports={ftyp:O,mdat:S,moof:c,moov:a,initSegment:function(B){var F,H=O(),X=a(B);return F=new Uint8Array(H.byteLength+X.byteLength),F.set(H),F.set(X,H.byteLength),F}}},{}],72:[function(I,j,C){"use strict";var k,E,P,O,S,m,v,c,a,s,l,r=I("../utils/stream.js"),h=I("./mp4-generator.js"),d=I("../m2ts/m2ts.js"),t=I("../codecs/adts.js"),i=I("../codecs/h264").H264Stream,o=I("../aac"),p=I("../data/silence"),u=I("../utils/clock"),g=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],f=["width","height","profileIdc","levelIdc","profileCompatibility"],n=9e4;S=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0}}},m=function(e){return e[0]==="I".charCodeAt(0)&&e[1]==="D".charCodeAt(0)&&e[2]==="3".charCodeAt(0)},s=function(e,_){var b;if(e.length!==_.length)return!1;for(b=0;bn/2))){for(D=p[T.samplerate],D||(D=U[0].data),x=0;x=A?T:(e.minSegmentDts=1/0,T.filter(function(U){return U.dts>=A&&(e.minSegmentDts=Math.min(e.minSegmentDts,U.dts),e.minSegmentPts=e.minSegmentDts,!0)}))},this.generateSampleTable_=function(T){var U,L,D=[];for(U=0;U=-N&&T<=M&&(!U||G>T)&&(U=D,G=T)));return U?U.gop:null},this.extendFirstKeyFrame_=function(y){var T;return y[0][0].keyFrame||(T=y.shift(),y.byteLength-=T.byteLength,y.nalCount-=T.nalCount,y[0][0].dts=T.dts,y[0][0].pts=T.pts,y[0][0].duration+=T.duration),y},this.groupNalsIntoFrames_=function(y){var T,U,L=[],D=[];for(L.byteLength=0,T=0;T=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}for(this.videoTrack?(U=this.videoTrack.timelineStartInfo.pts,f.forEach(function(L){T.info[L]=this.videoTrack[L]},this)):this.audioTrack&&(U=this.audioTrack.timelineStartInfo.pts,g.forEach(function(L){T.info[L]=this.audioTrack[L]},this)),this.pendingTracks.length===1?T.type=this.pendingTracks[0].type:T.type="combined",this.emittedTracks+=this.pendingTracks.length,A=h.initSegment(this.pendingTracks),T.initSegment=new Uint8Array(A.byteLength),T.initSegment.set(A),T.data=new Uint8Array(this.pendingBytes),w=0;w=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},P=function(e){var _,b,A=this,w=!0;P.prototype.init.call(this),e=e||{},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="aac",y.metadataStream=new d.MetadataStream,y.aacStream=new o,y.audioTimestampRolloverStream=new d.TimestampRolloverStream("audio"),y.timedMetadataTimestampRolloverStream=new d.TimestampRolloverStream("timed-metadata"),y.adtsStream=new t,y.coalesceStream=new O(e,y.metadataStream),y.headOfPipeline=y.aacStream,y.aacStream.pipe(y.audioTimestampRolloverStream).pipe(y.adtsStream),y.aacStream.pipe(y.timedMetadataTimestampRolloverStream).pipe(y.metadataStream).pipe(y.coalesceStream),y.metadataStream.on("timestamp",function(T){y.aacStream.setTimestamp(T.timeStamp)}),y.aacStream.on("data",function(T){T.type!=="timed-metadata"||y.audioSegmentStream||(b=b||{timelineStartInfo:{baseMediaDecodeTime:A.baseMediaDecodeTime},codec:"adts",type:"audio"},y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new E(b),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream))}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="ts",y.metadataStream=new d.MetadataStream,y.packetStream=new d.TransportPacketStream,y.parseStream=new d.TransportParseStream,y.elementaryStream=new d.ElementaryStream,y.videoTimestampRolloverStream=new d.TimestampRolloverStream("video"),y.audioTimestampRolloverStream=new d.TimestampRolloverStream("audio"),y.timedMetadataTimestampRolloverStream=new d.TimestampRolloverStream("timed-metadata"),y.adtsStream=new t,y.h264Stream=new i,y.captionStream=new d.CaptionStream,y.coalesceStream=new O(e,y.metadataStream),y.headOfPipeline=y.packetStream,y.packetStream.pipe(y.parseStream).pipe(y.elementaryStream),y.elementaryStream.pipe(y.videoTimestampRolloverStream).pipe(y.h264Stream),y.elementaryStream.pipe(y.audioTimestampRolloverStream).pipe(y.adtsStream),y.elementaryStream.pipe(y.timedMetadataTimestampRolloverStream).pipe(y.metadataStream).pipe(y.coalesceStream),y.h264Stream.pipe(y.captionStream).pipe(y.coalesceStream),y.elementaryStream.on("data",function(T){var U;if(T.type==="metadata"){for(U=T.tracks.length;U--;)_||T.tracks[U].type!=="video"?b||T.tracks[U].type!=="audio"||(b=T.tracks[U],b.timelineStartInfo.baseMediaDecodeTime=A.baseMediaDecodeTime):(_=T.tracks[U],_.timelineStartInfo.baseMediaDecodeTime=A.baseMediaDecodeTime);_&&!y.videoSegmentStream&&(y.coalesceStream.numberOfTracks++,y.videoSegmentStream=new k(_),y.videoSegmentStream.on("timelineStartInfo",function(L){b&&(b.timelineStartInfo=L,y.audioSegmentStream.setEarliestDts(L.dts))}),y.videoSegmentStream.on("baseMediaDecodeTime",function(L){b&&y.audioSegmentStream.setVideoBaseMediaDecodeTime(L)}),y.h264Stream.pipe(y.videoSegmentStream).pipe(y.coalesceStream)),b&&!y.audioSegmentStream&&(y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new E(b),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream))}}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(y){var T=this.transmuxPipeline_;this.baseMediaDecodeTime=y,b&&(b.timelineStartInfo.dts=void 0,b.timelineStartInfo.pts=void 0,c(b),b.timelineStartInfo.baseMediaDecodeTime=y),_&&(T.videoSegmentStream&&(T.videoSegmentStream.gopCache_=[]),_.timelineStartInfo.dts=void 0,_.timelineStartInfo.pts=void 0,c(_),_.timelineStartInfo.baseMediaDecodeTime=y)},this.setAudioAppendStart=function(y){b&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(y)},this.push=function(y){if(w){var T=m(y);T&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():T||this.transmuxPipeline_.type==="ts"||this.setupTsPipeline(),w=!1}this.transmuxPipeline_.headOfPipeline.push(y)},this.flush=function(){w=!0,this.transmuxPipeline_.headOfPipeline.flush()}},P.prototype=new r,j.exports={Transmuxer:P,VideoSegmentStream:k,AudioSegmentStream:E,AUDIO_PROPERTIES:g,VIDEO_PROPERTIES:f}},{"../aac":55,"../codecs/adts.js":56,"../codecs/h264":57,"../data/silence":58,"../m2ts/m2ts.js":66,"../utils/clock":73,"../utils/stream.js":75,"./mp4-generator.js":71}],73:[function(I,j,C){var k,E,P,O,S,m,v=9e4;k=function(c){return c*v},E=function(c,a){return c*a},P=function(c){return c/v},O=function(c,a){return c/a},S=function(c,a){return k(O(c,a))},m=function(c,a){return E(P(c),a)},j.exports={secondsToVideoTs:k,secondsToAudioTs:E,videoTsToSeconds:P,audioTsToSeconds:O,audioTsToVideoTs:S,videoTsToAudioTs:m}},{}],74:[function(I,j,C){"use strict";var k;k=function(E){var P=E.byteLength,O=0,S=0;this.length=function(){return 8*P},this.bitsAvailable=function(){return 8*P+S},this.loadWord=function(){var m=E.byteLength-P,v=new Uint8Array(4),c=Math.min(4,P);if(c===0)throw new Error("no bytes available");v.set(E.subarray(m,m+c)),O=new DataView(v.buffer).getUint32(0),S=8*c,P-=c},this.skipBits=function(m){var v;S>m?(O<<=m,S-=m):(m-=S,v=Math.floor(m/8),m-=8*v,P-=v,this.loadWord(),O<<=m,S-=m)},this.readBits=function(m){var v=Math.min(S,m),c=O>>>32-v;return S-=v,S>0?O<<=v:P>0&&this.loadWord(),v=m-v,v>0?c<>>m)!=0)return O<<=m,S-=m,m;return this.loadWord(),m+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var m=this.skipLeadingZeros();return this.readBits(m+1)-1},this.readExpGolomb=function(){var m=this.readUnsignedExpGolomb();return 1&m?1+m>>>1:-1*(m>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()},j.exports=k},{}],75:[function(I,j,C){arguments[4][40][0].apply(C,arguments)},{dup:40}],76:[function(I,j,C){var k=arguments[3],E=arguments[4],P=arguments[5],O=JSON.stringify;j.exports=function(S){for(var m,v=Object.keys(P),c=0,a=v.length;cJ||Z.attributes.RESOLUTION.height>tt}),at=rt.filter(function(Z){return Z.attributes.RESOLUTION.width===rt[0].attributes.RESOLUTION.width&&Z.attributes.RESOLUTION.height===rt[0].attributes.RESOLUTION.height}),V=at.filter(function(Z){return Z.attributes.BANDWIDTH===at[at.length-1].attributes.BANDWIDTH})[0]),V||K||z||R[0]},M.canPlaySource=function(){return n.default.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")},M.supportsNativeHls=function(){var R=c.default.createElement("video");if(!n.default.getTech("Html5").isSupported())return!1;var q=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return q.some(function(z){return/maybe|probably/i.test(R.canPlayType(z))})}(),M.isSupported=function(){return n.default.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var H=T.default.navigator&&T.default.navigator.userAgent||"";M.supportsAudioInfoChange_=function(){if(n.default.browser.IS_FIREFOX){var R=/Firefox\/([\d.]+)/i.exec(H),q=parseInt(R[1],10);return q>=49}return!0};var X=n.default.getComponent("Component"),Y=function(R){function q(z,V,K){var J=this;if(P(this,q),m(Object.getPrototypeOf(q.prototype),"constructor",this).call(this,V),V.options_&&V.options_.playerId){var tt=(0,n.default)(V.options_.playerId);tt.hasOwnProperty("hls")||Object.defineProperty(tt,"hls",{get:function(){return n.default.log.warn("player.hls is deprecated. Use player.tech_.hls instead."),J}})}if(n.default.options.hls.overrideNative&&(V.featuresNativeVideoTracks||V.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");this.tech_=V,this.source_=z,this.stats={},this.ignoreNextSeekingEvent_=!1,this.options_=n.default.mergeOptions(n.default.options.hls||{},K.hls),this.setOptions_(),this.on(c.default,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(et){var it=c.default.fullscreenElement||c.default.webkitFullscreenElement||c.default.mozFullScreenElement||c.default.msFullscreenElement;it&&it.contains(J.tech_.el())&&J.masterPlaylistController_.fastQualityChange_()}),this.on(this.tech_,"seeking",function(){return this.ignoreNextSeekingEvent_?void(this.ignoreNextSeekingEvent_=!1):void this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),this.audioTrackChange_=function(){J.masterPlaylistController_.setupAudio()},this.on(this.tech_,"play",this.play)}return O(q,R),S(q,[{key:"setOptions_",value:function(){var z=this;this.options_.withCredentials=this.options_.withCredentials||!1,typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=4194304),["withCredentials","bandwidth"].forEach(function(V){typeof z.source_[V]!="undefined"&&(z.options_[V]=z.source_[V])}),this.bandwidth=this.options_.bandwidth}},{key:"src",value:function(z){var V=this;z&&(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=M,this.masterPlaylistController_=new e.MasterPlaylistController(this.options_),this.playbackWatcher_=new L.default(n.default.mergeOptions(this.options_,{seekable:function(){return V.seekable()}})),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):M.STANDARD_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(K){this.masterPlaylistController_.selectPlaylist=K.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(K){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=K,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(K){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=K,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var K=1/(this.bandwidth||1),J=void 0;J=this.throughput>0?1/this.throughput:0;var tt=Math.floor(1/(K+J));return tt},set:function(){n.default.log.error('The "systemBandwidth" property is read-only')}}}),Object.defineProperties(this.stats,{bandwidth:{get:function(){return V.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return V.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return V.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return V.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return V.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.masterPlaylistController_.on("sourceopen",function(){V.tech_.audioTracks().addEventListener("change",V.audioTrackChange_)}),this.masterPlaylistController_.on("selectedinitialmedia",function(){(0,w.default)(V)}),this.masterPlaylistController_.on("audioupdate",function(){V.tech_.clearTracks("audio"),V.masterPlaylistController_.activeAudioGroup().forEach(function(K){V.tech_.audioTracks().addTrack(K)})}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.masterPlaylistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.tech_.ready(function(){return V.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(n.default.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var z=this,V=n.default.players[this.tech_.options_.playerId];V&&V.qualityLevels&&(this.qualityLevels_=V.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){B(z.qualityLevels_,z)}),this.playlists.on("mediachange",function(){W(z.qualityLevels_,z.playlists)}))}},{key:"activeAudioGroup_",value:function(){return this.masterPlaylistController_.activeAudioGroup()}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(z){this.masterPlaylistController_.setCurrentTime(z)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),typeof this.tech_.audioTracks=="function"&&this.tech_.audioTracks().removeEventListener("change",this.audioTrackChange_),m(Object.getPrototypeOf(q.prototype),"dispose",this).call(this)}}]),q}(X),$=function R(q){return{canHandleSource:function(z){return(!n.default.options.hls||!n.default.options.hls.mode||n.default.options.hls.mode===q)&&R.canPlayType(z.type)},handleSource:function(z,V,K){q==="flash"&&V.setTimeout(function(){V.trigger("loadstart")},1);var J=n.default.mergeOptions(K,{hls:{mode:q}});return V.hls=new Y(z,V,J),V.hls.xhr=(0,d.default)(),n.default.Hls.xhr.beforeRequest&&(V.hls.xhr.beforeRequest=n.default.Hls.xhr.beforeRequest),V.hls.src(z.src),V.hls},canPlayType:function(z){return R.canPlayType(z)?"maybe":""}}};M.comparePlaylistBandwidth=function(R,q){var z=void 0,V=void 0;return R.attributes&&R.attributes.BANDWIDTH&&(z=R.attributes.BANDWIDTH),z=z||T.default.Number.MAX_VALUE,q.attributes&&q.attributes.BANDWIDTH&&(V=q.attributes.BANDWIDTH),V=V||T.default.Number.MAX_VALUE,z-V},M.comparePlaylistResolution=function(R,q){var z=void 0,V=void 0;return R.attributes&&R.attributes.RESOLUTION&&R.attributes.RESOLUTION.width&&(z=R.attributes.RESOLUTION.width),z=z||T.default.Number.MAX_VALUE,q.attributes&&q.attributes.RESOLUTION&&q.attributes.RESOLUTION.width&&(V=q.attributes.RESOLUTION.width),V=V||T.default.Number.MAX_VALUE,z===V&&R.attributes.BANDWIDTH&&q.attributes.BANDWIDTH?R.attributes.BANDWIDTH-q.attributes.BANDWIDTH:z-V},$.canPlayType=function(R){if(n.default.browser.IE_VERSION&&n.default.browser.IE_VERSION<=10)return!1;var q=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;return!(!n.default.options.hls.overrideNative&&M.supportsNativeHls)&&q.test(R)},typeof n.default.MediaSource!="undefined"&&typeof n.default.URL!="undefined"||(n.default.MediaSource=p.MediaSource,n.default.URL=p.URL);var Q=n.default.getTech("Flash");p.MediaSource.supportsNativeMediaSources()&&n.default.getTech("Html5").registerSourceHandler($("html5"),0),T.default.Uint8Array&&Q&&Q.registerSourceHandler($("flash")),n.default.HlsHandler=Y,n.default.HlsSourceHandler=$,n.default.Hls=M,n.default.use||n.default.registerComponent("Hls",M),n.default.m3u8=g.default,n.default.options.hls=n.default.options.hls||{},n.default.registerPlugin?n.default.registerPlugin("reloadSourceOnError",x.default):n.default.plugin("reloadSourceOnError",x.default),j.exports={Hls:M,HlsHandler:Y,HlsSourceHandler:$}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./bin-utils":2,"./config":3,"./master-playlist-controller":5,"./playback-watcher":6,"./playlist":8,"./playlist-loader":7,"./reload-source-on-error":10,"./rendition-mixin":11,"./xhr":17,"aes-decrypter":21,"global/document":27,"global/window":28,"m3u8-parser":29,"videojs-contrib-media-sources":53}]},{},[78])(78)});