From e979b8b1bf8ab1bd0384ee1c6d33413fdb4028a2 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Sun, 30 Aug 2026 02:23:40 +0000 Subject: [PATCH 1/2] Stop the desktop player throwing away the buffer that would have smoothed it The web player stutters on a desktop, and it is the player doing it rather than the connection or the provider. `liveBufferLatencyChasing` was on, with `MinRemain` at one second. The library's own source calls that option "not recommended" in the first line of the file implementing it, and the implementation says why: it closes drift by assigning to `currentTime`. That is a hard seek, MSE tears down and rebuilds the decode pipeline on one, and it is evaluated on every appended fragment. So: buffer passes six seconds ahead, seek down to one second of headroom, one jitter spike underruns it, the refill passes six seconds, seek again. A visible hitch on every cycle. The stash made it worse. It was off with `stashInitialSize` at 128 bytes, on the reasoning that a laptop has bandwidth to spare. It does, but a transport stream still arrives through the proxy in bursts -- the provider's pacing, not ours -- and with nothing in front of the demuxer each gap between bursts had nothing to draw on. So the desktop now reads ahead 128KB (a third of the television's) and closes drift with `liveSync` instead: over six seconds behind it plays at 1.1x until it is back within three, then returns to 1x. No seek, nothing discarded, nothing rebuffered, and 1.1x is below where the pitch shift is noticeable -- 1.2, the library default, is not. Chasing is now off on both profiles. The television gets no liveSync: it is behind because it is struggling, and asking a CPU that is barely keeping up to decode faster is how a slow stream becomes a stopped one. `vendor-mpegts.js` is rebuilt in the same commit. The Dockerfile builds it at image build so production would have picked the change up regardless, but `bun run dev` serves public/ as committed, so leaving it stale is a fix nobody working locally can see. Not addressed here: @profullstack/player 0.3.1 carries a byte-identical copy of the old desktop profile, so every other consumer still has this. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01S5KxNHPQPY9Do9eWfJnGP4 --- apps/web/public/vendor-mpegts.js | 2 +- apps/web/src/client/tv.js | 91 ++++++++++++++++++++++++-------- test/player-codecs.test.js | 49 +++++++++++++++-- 3 files changed, 113 insertions(+), 29 deletions(-) diff --git a/apps/web/public/vendor-mpegts.js b/apps/web/public/vendor-mpegts.js index 1a77594..22a4553 100644 --- a/apps/web/public/vendor-mpegts.js +++ b/apps/web/public/vendor-mpegts.js @@ -1,3 +1,3 @@ var ci=Object.create;var{getPrototypeOf:hi,defineProperty:Dt,getOwnPropertyNames:fi}=Object;var pi=Object.prototype.hasOwnProperty;function mi(_e){return this[_e]}var gi,yi,vi=(_e,be,Me)=>{var se=_e!=null&&typeof _e==="object";if(se){var Q=be?gi??=new WeakMap:yi??=new WeakMap,D=Q.get(_e);if(D)return D}Me=_e!=null?ci(hi(_e)):{};let X=be||!_e||!_e.__esModule?Dt(Me,"default",{value:_e,enumerable:!0}):Me;if(_e&&typeof _e==="object"||typeof _e==="function"){for(let P of fi(_e))if(!pi.call(X,P))Dt(X,P,{get:mi.bind(_e,P),enumerable:!0})}if(se)Q.set(_e,X);return X};var Si=(_e,be)=>()=>(be||_e((be={exports:{}}).exports,be),be.exports);var Mt=Si(function(et,lt){/*! For license information please see mpegts.js.LICENSE.txt */(function(_e,be){typeof et=="object"&&typeof lt=="object"?lt.exports=be():typeof define=="function"&&define.amd?define([],be):typeof et=="object"?et.mpegts=be():_e.mpegts=be()})(et,function(){return function(){var _e={964:function(se,Q,D){se.exports=function(){function X(V){return typeof V=="function"}var P=Array.isArray?Array.isArray:function(V){return Object.prototype.toString.call(V)==="[object Array]"},_=0,S=void 0,R=void 0,v=function(V,Y){G[_]=V,G[_+1]=Y,(_+=2)===2&&(R?R(m):u())},I=typeof window<"u"?window:void 0,b=I||{},M=b.MutationObserver||b.WebKitMutationObserver,C=typeof self>"u"&&typeof process<"u"&&{}.toString.call(process)==="[object process]",B=typeof Uint8ClampedArray<"u"&&typeof importScripts<"u"&&typeof MessageChannel<"u";function A(){var V=setTimeout;return function(){return V(m,1)}}var G=Array(1000);function m(){for(var V=0;V<_;V+=2)(0,G[V])(G[V+1]),G[V]=void 0,G[V+1]=void 0;_=0}var U,x,W,L,u=void 0;function h(V,Y){var ie=this,oe=new this.constructor(K);oe[E]===void 0&&j(oe);var ue=ie._state;if(ue){var Ee=arguments[ue-1];v(function(){return c(ue,oe,Ee,ie._result)})}else ke(ie,oe,V,Y);return oe}function p(V){if(V&&typeof V=="object"&&V.constructor===this)return V;var Y=new this(K);return te(Y,V),Y}u=C?function(){return process.nextTick(m)}:M?(x=0,W=new M(m),L=document.createTextNode(""),W.observe(L,{characterData:!0}),function(){L.data=x=++x%2}):B?((U=new MessageChannel).port1.onmessage=m,function(){return U.port2.postMessage(0)}):I===void 0?function(){try{var V=Function("return this")().require("vertx");return(S=V.runOnLoop||V.runOnContext)!==void 0?function(){S(m)}:A()}catch(Y){return A()}}():A();var E=Math.random().toString(36).substring(2);function K(){}var z=void 0,de=1,le=2;function me(V,Y,ie){Y.constructor===V.constructor&&ie===h&&Y.constructor.resolve===p?function(oe,ue){ue._state===de?Re(oe,ue._result):ue._state===le?J(oe,ue._result):ke(ue,void 0,function(Ee){return te(oe,Ee)},function(Ee){return J(oe,Ee)})}(V,Y):ie===void 0?Re(V,Y):X(ie)?function(oe,ue,Ee){v(function(Pe){var Ue=!1,je=function(Fe,Xe,nt,Ne){try{Fe.call(Xe,nt,Ne)}catch(Qe){return Qe}}(Ee,ue,function(Fe){Ue||(Ue=!0,ue!==Fe?te(Pe,Fe):Re(Pe,Fe))},function(Fe){Ue||(Ue=!0,J(Pe,Fe))},Pe._label);!Ue&&je&&(Ue=!0,J(Pe,je))},oe)}(V,Y,ie):Re(V,Y)}function te(V,Y){if(V===Y)J(V,TypeError("You cannot resolve a promise with itself"));else if(ue=typeof(oe=Y),oe===null||ue!=="object"&&ue!=="function")Re(V,Y);else{var ie=void 0;try{ie=Y.then}catch(Ee){return void J(V,Ee)}me(V,Y,ie)}var oe,ue}function ee(V){V._onerror&&V._onerror(V._result),k(V)}function Re(V,Y){V._state===z&&(V._result=Y,V._state=de,V._subscribers.length!==0&&v(k,V))}function J(V,Y){V._state===z&&(V._state=le,V._result=Y,v(ee,V))}function ke(V,Y,ie,oe){var ue=V._subscribers,Ee=ue.length;V._onerror=null,ue[Ee]=Y,ue[Ee+de]=ie,ue[Ee+le]=oe,Ee===0&&V._state&&v(k,V)}function k(V){var{_subscribers:Y,_state:ie}=V;if(Y.length!==0){for(var oe=void 0,ue=void 0,Ee=V._result,Pe=0;Pe0&&h.length>L&&!h.warned){h.warned=!0;var E=Error("Possible EventEmitter memory leak detected. "+h.length+" "+String(U)+" listeners added. Use emitter.setMaxListeners() to increase limit");E.name="MaxListenersExceededWarning",E.emitter=m,E.type=U,E.count=h.length,p=E,console&&console.warn&&console.warn(p)}return m}function b(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function M(m,U,x){var W={fired:!1,wrapFn:void 0,target:m,type:U,listener:x},L=b.bind(W);return L.listener=x,W.wrapFn=L,L}function C(m,U,x){var W=m._events;if(W===void 0)return[];var L=W[U];return L===void 0?[]:typeof L=="function"?x?[L.listener||L]:[L]:x?function(u){for(var h=Array(u.length),p=0;p0&&(u=U[0]),u instanceof Error)throw u;var h=Error("Unhandled error."+(u?" ("+u.message+")":""));throw h.context=u,h}var p=L[m];if(p===void 0)return!1;if(typeof p=="function")X(p,this,U);else{var E=p.length,K=A(p,E);for(x=0;x=0;u--)if(x[u]===U||x[u].listener===U){h=x[u].listener,L=u;break}if(L<0)return this;L===0?x.shift():function(p,E){for(;E+1=0;W--)this.removeListener(m,U[W]);return this},_.prototype.listeners=function(m){return C(this,m,!0)},_.prototype.rawListeners=function(m){return C(this,m,!1)},_.listenerCount=function(m,U){return typeof m.listenerCount=="function"?m.listenerCount(U):B.call(m,U)},_.prototype.listenerCount=B,_.prototype.eventNames=function(){return this._eventsCount>0?Q(this._events):[]}},955:function(se,Q,D){D.r(Q);var X=function(){function P(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return P.prototype.isComplete=function(){var _=this.hasAudio===!1||this.hasAudio===!0&&this.audioCodec!=null&&this.audioSampleRate!=null&&this.audioChannelCount!=null,S=this.hasVideo===!1||this.hasVideo===!0&&this.videoCodec!=null&&this.width!=null&&this.height!=null&&this.fps!=null&&this.profile!=null&&this.level!=null&&this.refFrames!=null&&this.chromaFormat!=null&&this.sarNum!=null&&this.sarDen!=null;return this.mimeType!=null&&_&&S},P.prototype.isSeekable=function(){return this.hasKeyframesIndex===!0},P.prototype.getNearestKeyframe=function(_){if(this.keyframesIndex==null)return null;var S=this.keyframesIndex,R=this._search(S.times,_);return{index:R,milliseconds:S.times[R],fileposition:S.filepositions[R]}},P.prototype._search=function(_,S){var R=0,v=_.length-1,I=0,b=0,M=v;for(S<_[0]&&(R=0,b=M+1);b<=M;){if((I=b+Math.floor((M-b)/2))===v||S>=_[I]&&S<_[I+1]){R=I;break}_[I]0&&v[0].originalDts=I[C].dts&&vI[M].lastSample.originalDts&&v=I[M].lastSample.originalDts&&(M===I.length-1||M0&&(C=this._searchNearestSegmentBefore(b.originalBeginDts)+1),this._lastAppendLocation=C,this._list.splice(C,0,b)},R.prototype.getLastSegmentBefore=function(v){var I=this._searchNearestSegmentBefore(v);return I>=0?this._list[I]:null},R.prototype.getLastSampleBefore=function(v){var I=this.getLastSegmentBefore(v);return I!=null?I.lastSample:null},R.prototype.getLastSyncPointBefore=function(v){for(var I=this._searchNearestSegmentBefore(v),b=this._list[I].syncPoints;b.length===0&&I>0;)I--,b=this._list[I].syncPoints;return b.length>0?b[b.length-1]:null},R}()},346:function(se,Q,D){D.r(Q);var X=D(7),P=D.n(X),_=D(856),S=D(994),R=D(403),v=D(867),I=function(){function b(M){this.TAG="MSEController",this._config=M,this._emitter=new(P()),this._config.isLive&&this._config.autoCleanupSourceBuffer==null&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onStartStreaming:this._onStartStreaming.bind(this),onEndStreaming:this._onEndStreaming.bind(this),onQualityChange:this._onQualityChange.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._useManagedMediaSource=typeof self.ManagedMediaSource=="function"&&typeof self.MediaSource!="function",this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElementProxy=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]}}return b.prototype.destroy=function(){this._mediaSource&&this.shutdown(),this._mediaSourceObjectURL&&this.revokeObjectURL(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null},b.prototype.on=function(M,C){this._emitter.addListener(M,C)},b.prototype.off=function(M,C){this._emitter.removeListener(M,C)},b.prototype.initialize=function(M){if(this._mediaSource)throw new v.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");this._useManagedMediaSource&&_.default.v(this.TAG,"Using ManagedMediaSource");var C=this._mediaSource=this._useManagedMediaSource?new self.ManagedMediaSource:new self.MediaSource;C.addEventListener("sourceopen",this.e.onSourceOpen),C.addEventListener("sourceended",this.e.onSourceEnded),C.addEventListener("sourceclose",this.e.onSourceClose),this._useManagedMediaSource&&(C.addEventListener("startstreaming",this.e.onStartStreaming),C.addEventListener("endstreaming",this.e.onEndStreaming),C.addEventListener("qualitychange",this.e.onQualityChange)),this._mediaElementProxy=M},b.prototype.shutdown=function(){if(this._mediaSource){var M=this._mediaSource;for(var C in this._sourceBuffers){var B=this._pendingSegments[C];B.splice(0,B.length),this._pendingSegments[C]=null,this._pendingRemoveRanges[C]=null,this._lastInitSegments[C]=null;var A=this._sourceBuffers[C];if(A){if(M.readyState!=="closed"){try{M.removeSourceBuffer(A)}catch(G){_.default.e(this.TAG,G.message)}A.removeEventListener("error",this.e.onSourceBufferError),A.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[C]=null,this._sourceBuffers[C]=null}}if(M.readyState==="open")try{M.endOfStream()}catch(G){_.default.e(this.TAG,G.message)}this._mediaElementProxy=null,M.removeEventListener("sourceopen",this.e.onSourceOpen),M.removeEventListener("sourceended",this.e.onSourceEnded),M.removeEventListener("sourceclose",this.e.onSourceClose),this._useManagedMediaSource&&(M.removeEventListener("startstreaming",this.e.onStartStreaming),M.removeEventListener("endstreaming",this.e.onEndStreaming),M.removeEventListener("qualitychange",this.e.onQualityChange)),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._mediaSource=null}},b.prototype.isManagedMediaSource=function(){return this._useManagedMediaSource},b.prototype.getObject=function(){if(!this._mediaSource)throw new v.IllegalStateException("MediaSource has not been initialized yet!");return this._mediaSource},b.prototype.getHandle=function(){if(!this._mediaSource)throw new v.IllegalStateException("MediaSource has not been initialized yet!");return this._mediaSource.handle},b.prototype.getObjectURL=function(){if(!this._mediaSource)throw new v.IllegalStateException("MediaSource has not been initialized yet!");return this._mediaSourceObjectURL==null&&(this._mediaSourceObjectURL=URL.createObjectURL(this._mediaSource)),this._mediaSourceObjectURL},b.prototype.revokeObjectURL=function(){this._mediaSourceObjectURL&&(URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)},b.prototype.appendInitSegment=function(M,C){if(C===void 0&&(C=void 0),!this._mediaSource||this._mediaSource.readyState!=="open"||this._mediaSource.streaming===!1)return this._pendingSourceBufferInit.push(M),void this._pendingSegments[M.type].push(M);var B=M,A="".concat(B.container);B.codec&&B.codec.length>0&&(B.codec==="opus"&&S.default.safari&&(B.codec="Opus"),A+=";codecs=".concat(B.codec));var G=!1;if(_.default.v(this.TAG,"Received Initialization Segment, mimeType: "+A),this._lastInitSegments[B.type]=B,A!==this._mimeTypes[B.type]){if(this._mimeTypes[B.type])_.default.v(this.TAG,"Notice: ".concat(B.type," mimeType changed, origin: ").concat(this._mimeTypes[B.type],", target: ").concat(A));else{G=!0;try{var m=this._sourceBuffers[B.type]=this._mediaSource.addSourceBuffer(A);m.addEventListener("error",this.e.onSourceBufferError),m.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(U){return _.default.e(this.TAG,U.message),void this._emitter.emit(R.default.ERROR,{code:U.code,msg:U.message})}}this._mimeTypes[B.type]=A}C||this._pendingSegments[B.type].push(B),G||this._sourceBuffers[B.type]&&!this._sourceBuffers[B.type].updating&&this._doAppendSegments(),S.default.safari&&B.container==="audio/mpeg"&&B.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=B.mediaDuration/1000,this._updateMediaSourceDuration())},b.prototype.appendMediaSegment=function(M){var C=M;this._pendingSegments[C.type].push(C),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var B=this._sourceBuffers[C.type];!B||B.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},b.prototype.flush=function(){for(var M in this._sourceBuffers)if(this._sourceBuffers[M]){var C=this._sourceBuffers[M];if(this._mediaSource.readyState==="open")try{C.abort()}catch(x){_.default.e(this.TAG,x.message)}var B=this._pendingSegments[M];if(B.splice(0,B.length),this._mediaSource.readyState!=="closed"){for(var A=0;A=1&&M-A.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},b.prototype._doCleanupSourceBuffer=function(){var M=this._mediaElementProxy.getCurrentTime();for(var C in this._sourceBuffers){var B=this._sourceBuffers[C];if(B){for(var A=B.buffered,G=!1,m=0;m=this._config.autoCleanupMaxBackwardDuration){G=!0;var W=M-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[C].push({start:U,end:W})}}else x0&&(isNaN(C)||B>C)&&(_.default.v(this.TAG,"Update MediaSource duration from ".concat(C," to ").concat(B)),this._mediaSource.duration=B),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},b.prototype._doRemoveRanges=function(){for(var M in this._pendingRemoveRanges)if(this._sourceBuffers[M]&&!this._sourceBuffers[M].updating)for(var C=this._sourceBuffers[M],B=this._pendingRemoveRanges[M];B.length&&!C.updating;){var A=B.shift();C.remove(A.start,A.end)}},b.prototype._doAppendSegments=function(){var M=this._pendingSegments;for(var C in M)if(this._sourceBuffers[C]&&!this._sourceBuffers[C].updating&&this._mediaSource.streaming!==!1&&M[C].length>0){var B=M[C].shift();if(typeof B.timestampOffset=="number"&&isFinite(B.timestampOffset)){var A=this._sourceBuffers[C].timestampOffset,G=B.timestampOffset/1000;Math.abs(A-G)>0.1&&(_.default.v(this.TAG,"Update MPEG audio timestampOffset from ".concat(A," to ").concat(G)),this._sourceBuffers[C].timestampOffset=G),delete B.timestampOffset}if(!B.data||B.data.byteLength===0)continue;try{this._sourceBuffers[C].appendBuffer(B.data),this._isBufferFull=!1}catch(m){this._pendingSegments[C].unshift(B),m.code===22?(this._isBufferFull||this._emitter.emit(R.default.BUFFER_FULL),this._isBufferFull=!0):(_.default.e(this.TAG,m.message),this._emitter.emit(R.default.ERROR,{code:m.code,msg:m.message}))}}},b.prototype._onSourceOpen=function(){if(_.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var M=this._pendingSourceBufferInit;M.length;){var C=M.shift();this.appendInitSegment(C,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(R.default.SOURCE_OPEN)},b.prototype._onStartStreaming=function(){_.default.v(this.TAG,"ManagedMediaSource onStartStreaming"),this._emitter.emit(R.default.START_STREAMING)},b.prototype._onEndStreaming=function(){_.default.v(this.TAG,"ManagedMediaSource onEndStreaming"),this._emitter.emit(R.default.END_STREAMING)},b.prototype._onQualityChange=function(){_.default.v(this.TAG,"ManagedMediaSource onQualityChange")},b.prototype._onSourceEnded=function(){_.default.v(this.TAG,"MediaSource onSourceEnded")},b.prototype._onSourceClose=function(){_.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&this.e!=null&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose),this._useManagedMediaSource&&(this._mediaSource.removeEventListener("startstreaming",this.e.onStartStreaming),this._mediaSource.removeEventListener("endstreaming",this.e.onEndStreaming),this._mediaSource.removeEventListener("qualitychange",this.e.onQualityChange)))},b.prototype._hasPendingSegments=function(){var M=this._pendingSegments;return M.video.length>0||M.audio.length>0},b.prototype._hasPendingRemoveRanges=function(){var M=this._pendingRemoveRanges;return M.video.length>0||M.audio.length>0},b.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(R.default.UPDATE_END)},b.prototype._onSourceBufferError=function(M){_.default.e(this.TAG,"SourceBuffer Error: ".concat(M))},b}();Q.default=I},527:function(se,Q,D){D.r(Q);var X=D(7),P=D.n(X),_=D(861),S=D.n(_),R=D(856),v=D(947),I=D(886),b=D(726),M=(D(137),D(955)),C=function(){function B(A,G){if(this.TAG="Transmuxer",this._emitter=new(P()),G.enableWorker&&typeof Worker<"u")try{this._worker=S()(137),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[A,G]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},v.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:v.default.getConfig()})}catch(U){R.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new I.default(A,G)}else this._controller=new I.default(A,G);if(this._controller){var m=this._controller;m.on(b.default.IO_ERROR,this._onIOError.bind(this)),m.on(b.default.DEMUX_ERROR,this._onDemuxError.bind(this)),m.on(b.default.INIT_SEGMENT,this._onInitSegment.bind(this)),m.on(b.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),m.on(b.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),m.on(b.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),m.on(b.default.MEDIA_INFO,this._onMediaInfo.bind(this)),m.on(b.default.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),m.on(b.default.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),m.on(b.default.TIMED_ID3_METADATA_ARRIVED,this._onTimedID3MetadataArrived.bind(this)),m.on(b.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,this._onSynchronousKLVMetadataArrived.bind(this)),m.on(b.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,this._onAsynchronousKLVMetadataArrived.bind(this)),m.on(b.default.SMPTE2038_METADATA_ARRIVED,this._onSMPTE2038MetadataArrived.bind(this)),m.on(b.default.SEI_ARRIVED,this._onSEIArrived.bind(this)),m.on(b.default.SCTE35_METADATA_ARRIVED,this._onSCTE35MetadataArrived.bind(this)),m.on(b.default.PES_PRIVATE_DATA_DESCRIPTOR,this._onPESPrivateDataDescriptor.bind(this)),m.on(b.default.PES_PRIVATE_DATA_ARRIVED,this._onPESPrivateDataArrived.bind(this)),m.on(b.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),m.on(b.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return B.prototype.destroy=function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),v.default.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null},B.prototype.on=function(A,G){this._emitter.addListener(A,G)},B.prototype.off=function(A,G){this._emitter.removeListener(A,G)},B.prototype.hasWorker=function(){return this._worker!=null},B.prototype.open=function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()},B.prototype.close=function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()},B.prototype.seek=function(A){this._worker?this._worker.postMessage({cmd:"seek",param:A}):this._controller.seek(A)},B.prototype.pause=function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()},B.prototype.resume=function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()},B.prototype._onInitSegment=function(A,G){var m=this;Promise.resolve().then(function(){m._emitter.emit(b.default.INIT_SEGMENT,A,G)})},B.prototype._onMediaSegment=function(A,G){var m=this;Promise.resolve().then(function(){m._emitter.emit(b.default.MEDIA_SEGMENT,A,G)})},B.prototype._onLoadingComplete=function(){var A=this;Promise.resolve().then(function(){A._emitter.emit(b.default.LOADING_COMPLETE)})},B.prototype._onRecoveredEarlyEof=function(){var A=this;Promise.resolve().then(function(){A._emitter.emit(b.default.RECOVERED_EARLY_EOF)})},B.prototype._onMediaInfo=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.MEDIA_INFO,A)})},B.prototype._onMetaDataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.METADATA_ARRIVED,A)})},B.prototype._onScriptDataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.SCRIPTDATA_ARRIVED,A)})},B.prototype._onTimedID3MetadataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.TIMED_ID3_METADATA_ARRIVED,A)})},B.prototype._onPGSSubtitleArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.PGS_SUBTITLE_ARRIVED,A)})},B.prototype._onSynchronousKLVMetadataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,A)})},B.prototype._onAsynchronousKLVMetadataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,A)})},B.prototype._onSMPTE2038MetadataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.SMPTE2038_METADATA_ARRIVED,A)})},B.prototype._onSEIArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.SEI_ARRIVED,A)})},B.prototype._onSCTE35MetadataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.SCTE35_METADATA_ARRIVED,A)})},B.prototype._onPESPrivateDataDescriptor=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.PES_PRIVATE_DATA_DESCRIPTOR,A)})},B.prototype._onPESPrivateDataArrived=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.PES_PRIVATE_DATA_ARRIVED,A)})},B.prototype._onStatisticsInfo=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.STATISTICS_INFO,A)})},B.prototype._onIOError=function(A,G){var m=this;Promise.resolve().then(function(){m._emitter.emit(b.default.IO_ERROR,A,G)})},B.prototype._onDemuxError=function(A,G){var m=this;Promise.resolve().then(function(){m._emitter.emit(b.default.DEMUX_ERROR,A,G)})},B.prototype._onRecommendSeekpoint=function(A){var G=this;Promise.resolve().then(function(){G._emitter.emit(b.default.RECOMMEND_SEEKPOINT,A)})},B.prototype._onLoggingConfigChanged=function(A){this._worker&&this._worker.postMessage({cmd:"logging_config",param:A})},B.prototype._onWorkerMessage=function(A){var G=A.data,m=G.data;if(G.msg==="destroyed"||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(G.msg){case b.default.INIT_SEGMENT:case b.default.MEDIA_SEGMENT:this._emitter.emit(G.msg,m.type,m.data);break;case b.default.LOADING_COMPLETE:case b.default.RECOVERED_EARLY_EOF:this._emitter.emit(G.msg);break;case b.default.MEDIA_INFO:Object.setPrototypeOf(m,M.default.prototype),this._emitter.emit(G.msg,m);break;case b.default.METADATA_ARRIVED:case b.default.SCRIPTDATA_ARRIVED:case b.default.TIMED_ID3_METADATA_ARRIVED:case b.default.PGS_SUBTITLE_ARRIVED:case b.default.SYNCHRONOUS_KLV_METADATA_ARRIVED:case b.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED:case b.default.SMPTE2038_METADATA_ARRIVED:case b.default.SCTE35_METADATA_ARRIVED:case b.default.SEI_ARRIVED:case b.default.PES_PRIVATE_DATA_DESCRIPTOR:case b.default.PES_PRIVATE_DATA_ARRIVED:case b.default.STATISTICS_INFO:this._emitter.emit(G.msg,m);break;case b.default.IO_ERROR:case b.default.DEMUX_ERROR:this._emitter.emit(G.msg,m.type,m.info);break;case b.default.RECOMMEND_SEEKPOINT:this._emitter.emit(G.msg,m);break;case"logcat_callback":R.default.emitter.emit("log",m.type,m.logcat)}},B}();Q.default=C},886:function(se,Q,D){D.r(Q),D.d(Q,{default:function(){return li}});var X=D(7),P=D.n(X),_=D(856),S=D(994),R=D(955);function v(n,i,t){var e=n;if(i+t=128){i.push(String.fromCharCode(65535&o)),e+=2;continue}}else if(t[e]<240){if(v(t,e,2)&&(o=(15&t[e])<<12|(63&t[e+1])<<6|63&t[e+2])>=2048&&(63488&o)!=55296){i.push(String.fromCharCode(65535&o)),e+=3;continue}}else if(t[e]<248){var o;if(v(t,e,3)&&(o=(7&t[e])<<18|(63&t[e+1])<<12|(63&t[e+2])<<6|63&t[e+3])>65536&&o<1114112){o-=65536,i.push(String.fromCharCode(o>>>10|55296)),i.push(String.fromCharCode(1023&o|56320)),e+=4;continue}}i.push(String.fromCharCode(65533)),++e}return i.join("")},M=D(867),C=(I=new ArrayBuffer(2),new DataView(I).setInt16(0,256,!0),new Int16Array(I)[0]===256),B=function(){function n(){}return n.parseScriptData=function(i,t,e){var a={};try{var o=n.parseValue(i,t,e),r=n.parseValue(i,t+o.size,e-o.size);a[o.data]=r.data}catch(s){_.default.e("AMF",s.toString())}return a},n.parseObject=function(i,t,e){if(e<3)throw new M.IllegalStateException("Data not enough when parse ScriptDataObject");var a=n.parseString(i,t,e),o=n.parseValue(i,t+a.size,e-a.size),r=o.objectEnd;return{data:{name:a.data,value:o.data},size:a.size+o.size,objectEnd:r}},n.parseVariable=function(i,t,e){return n.parseObject(i,t,e)},n.parseString=function(i,t,e){if(e<2)throw new M.IllegalStateException("Data not enough when parse String");var a=new DataView(i,t,e).getUint16(0,!C);return{data:a>0?b(new Uint8Array(i,t+2,a)):"",size:2+a}},n.parseLongString=function(i,t,e){if(e<4)throw new M.IllegalStateException("Data not enough when parse LongString");var a=new DataView(i,t,e).getUint32(0,!C);return{data:a>0?b(new Uint8Array(i,t+4,a)):"",size:4+a}},n.parseDate=function(i,t,e){if(e<10)throw new M.IllegalStateException("Data size invalid when parse Date");var a=new DataView(i,t,e),o=a.getFloat64(0,!C),r=a.getInt16(8,!C);return{data:new Date(o+=60*r*1000),size:10}},n.parseValue=function(i,t,e){if(e<1)throw new M.IllegalStateException("Data not enough when parse Value");var a,o=new DataView(i,t,e),r=1,s=o.getUint8(0),d=!1;try{switch(s){case 0:a=o.getFloat64(1,!C),r+=8;break;case 1:a=!!o.getUint8(1),r+=1;break;case 2:var l=n.parseString(i,t+1,e-1);a=l.data,r+=l.size;break;case 3:a={};var y=0;for((16777215&o.getUint32(e-4,!C))==9&&(y=3);r32)throw new M.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(i<=this._current_word_bits_left){var t=this._current_word>>>32-i;return this._current_word<<=i,this._current_word_bits_left-=i,t}var e=this._current_word_bits_left?this._current_word:0;e>>>=32-this._current_word_bits_left;var a=i-this._current_word_bits_left;this._fillCurrentWord();var o=Math.min(a,this._current_word_bits_left),r=this._current_word>>>32-o;return this._current_word<<=o,this._current_word_bits_left-=o,e<>>i)return this._current_word<<=i,this._current_word_bits_left-=i,i;return this._fillCurrentWord(),i+this._skipLeadingZero()},n.prototype.readUEG=function(){var i=this._skipLeadingZero();return this.readBits(i+1)-1},n.prototype.readSEG=function(){var i=this.readUEG();return 1&i?i+1>>>1:-1*(i>>>1)},n}(),G=function(){function n(){}return n._ebsp2rbsp=function(i){for(var t=i,e=t.byteLength,a=new Uint8Array(e),o=0,r=0;r=2&&t[r]===3&&t[r-1]===0&&t[r-2]===0||(a[o]=t[r],o++);return new Uint8Array(a.buffer,0,o)},n.parseSPS=function(i){for(var t=i.subarray(1,4),e="avc1.",a=0;a<3;a++){var o=t[a].toString(16);o.length<2&&(o="0"+o),e+=o}var r=n._ebsp2rbsp(i),s=new A(r);s.readByte();var d=s.readByte();s.readByte();var l=s.readByte();s.readUEG();var y=n.getProfileString(d),f=n.getLevelString(l),g=1,T=420,O=8,F=8;if((d===100||d===110||d===122||d===244||d===44||d===83||d===86||d===118||d===128||d===138||d===144)&&((g=s.readUEG())===3&&s.readBits(1),g<=3&&(T=[0,420,422,444][g]),O=s.readUEG()+8,F=s.readUEG()+8,s.readBits(1),s.readBool()))for(var q=g!==3?8:12,Z=0;Z0&&ye<16?(Ce=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ye-1],we=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ye-1]):ye===255&&(Ce=s.readByte()<<8|s.readByte(),we=s.readByte()<<8|s.readByte())}if(s.readBool()&&s.readBool(),s.readBool()&&(s.readBits(4),s.readBool()&&s.readBits(24)),s.readBool()&&(s.readUEG(),s.readUEG()),s.readBool()){var Oe=s.readBits(32),Ve=s.readBits(32);pe=s.readBool(),Te=(Ae=Ve)/(Be=2*Oe)}}var xe=1;Ce===1&&we===1||(xe=Ce/we);var Ge=0,Le=0;g===0?(Ge=1,Le=2-ae):(Ge=g===3?1:2,Le=(g===1?2:1)*(2-ae));var He=16*(ve+1),qe=16*(ne+1)*(2-ae);He-=(ge+ce)*Ge,qe-=(De+Se)*Le;var tt=Math.ceil(He*xe);return s.destroy(),s=null,{codec_mimetype:e,profile_idc:d,level_idc:l,profile_string:y,level_string:f,chroma_format_idc:g,bit_depth:O,bit_depth_luma:O,bit_depth_chroma:F,ref_frames:he,chroma_format:T,chroma_format_string:n.getChromaFormatString(T),frame_rate:{fixed:pe,fps:Te,fps_den:Be,fps_num:Ae},sar_ratio:{width:Ce,height:we},codec_size:{width:He,height:qe},present_size:{width:tt,height:qe}}},n._skipScalingList=function(i,t){for(var e=8,a=8,o=0;o=2&&t[r]===3&&t[r-1]===0&&t[r-2]===0||(a[o]=t[r],o++);return new Uint8Array(a.buffer,0,o)},n.parseVPS=function(i){var t=n._ebsp2rbsp(i),e=new A(t);return e.readByte(),e.readByte(),e.readBits(4),e.readBits(2),e.readBits(6),{num_temporal_layers:e.readBits(3)+1,temporal_id_nested:e.readBool()}},n.parseSPS=function(i){var t=n._ebsp2rbsp(i),e=new A(t);e.readByte(),e.readByte();for(var a=0,o=0,r=0,s=0,d=(e.readBits(4),e.readBits(3)),l=(e.readBool(),e.readBits(2)),y=e.readBool(),f=e.readBits(5),g=e.readByte(),T=e.readByte(),O=e.readByte(),F=e.readByte(),q=e.readByte(),Z=e.readByte(),N=e.readByte(),H=e.readByte(),he=e.readByte(),ve=e.readByte(),ne=e.readByte(),ae=[],ge=[],ce=0;ce0)for(ce=d;ce<8;ce++)e.readBits(2);for(ce=0;ce1&&e.readSEG(),ce=0;ce0&&Ze<=16?($e=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][Ze-1],Je=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][Ze-1]):Ze===255&&($e=e.readBits(16),Je=e.readBits(16))}if(e.readBool()&&e.readBool(),e.readBool()&&(e.readBits(3),e.readBool(),e.readBool()&&(e.readByte(),e.readByte(),e.readByte())),e.readBool()&&(e.readUEG(),e.readUEG()),e.readBool(),e.readBool(),e.readBool(),e.readBool()&&(e.readUEG(),e.readUEG(),e.readUEG(),e.readUEG()),e.readBool()&&(at=e.readBits(32),rt=e.readBits(32),e.readBool()&&e.readUEG(),e.readBool())){var ot,st,it=!1;for(ot=e.readBool(),st=e.readBool(),(ot||st)&&((it=e.readBool())&&(e.readByte(),e.readBits(5),e.readBool(),e.readBits(5)),e.readBits(4),e.readBits(4),it&&e.readBits(4),e.readBits(5),e.readBits(5),e.readBits(5)),ce=0;ce<=d;ce++){var bt=e.readBool();Et=bt;var At=!0,dt=1;bt||(At=e.readBool());var Rt=!1;if(At?e.readUEG():Rt=e.readBool(),Rt||(dt=e.readUEG()+1),ot){for(Le=0;Le>3),r=!!(4&i[e]),s=!!(2&i[e]);i[e],e+=1,r&&(e+=1);var d=Number.POSITIVE_INFINITY;if(s){d=0;for(var l=0;;l++){var y=i[e++];if(d|=(127&y)<<7*l,!(128&y))break}}console.log(o),o===1?t=h(h({},n.parseSeuqneceHeader(i.subarray(e,e+d))),{sequence_header_data:i.subarray(a,e+d)}):(o==3&&t||o==6&&t)&&(t=n.parseOBUFrameHeader(i.subarray(e,e+d),0,0,t)),e+=d}return t},n.parseSeuqneceHeader=function(i){var t=new A(i),e=t.readBits(3),a=(t.readBool(),t.readBool()),o=!0,r=0,s=1,d=void 0,l=[];if(a)l.push({operating_point_idc:0,level:t.readBits(5),tier:0});else{if(t.readBool()){var y=t.readBits(32),f=t.readBits(32),g=t.readBool();if(g){for(var T=0;t.readBits(1)===0;)T+=1;T>=32||t.readBits(T)}r=f,s=y,o=g,t.readBool()&&(t.readBits(5),t.readBits(32),d=t.readBits(5),t.readBits(5))}for(var O=t.readBool(),F=t.readBits(5),q=0;q<=F;q++){var Z=t.readBits(12),N=t.readBits(5),H=N>7?t.readBits(1):0;l.push({operating_point_idc:Z,level:N,tier:H}),O&&t.readBool()&&t.readBits(4)}}var he=l[0],ve=he.level,ne=he.tier,ae=t.readBits(4),ge=t.readBits(4),ce=t.readBits(ae+1)+1,De=t.readBits(ge+1)+1,Se=!1;a||(Se=t.readBool()),Se&&(t.readBits(4),t.readBits(4)),t.readBool(),t.readBool(),t.readBool();var Ce=!1,we=2,Te=2,pe=0;a||(t.readBool(),t.readBool(),t.readBool(),t.readBool(),(Ce=t.readBool())&&(t.readBool(),t.readBool()),Te=(we=t.readBool()?2:t.readBits(1))?t.readBool()?2:t.readBits(1):2,pe=Ce?t.readBits(3)+1:0);var Ae=t.readBool(),Be=(t.readBool(),t.readBool(),t.readBool()),ye=8;ye=e===2&&Be?t.readBool()?12:10:Be?10:8;var Oe=!1;e!==1&&(Oe=t.readBool()),t.readBool()&&(t.readBits(8),t.readBits(8),t.readBits(8));var Ve=1,xe=1;return Oe?(t.readBits(1),Ve=1,xe=1):(t.readBits(1),e==0?(Ve=1,xe=1):e==1?(Ve=0,xe=0):ye==12?t.readBits(1)&&t.readBits(1):(Ve=1,xe=0),Ve&&xe&&t.readBits(2),t.readBits(1)),t.readBool(),t.destroy(),t=null,{codec_mimetype:"av01.".concat(e,".").concat(n.getLevelString(ve,ne),".").concat(ye.toString(10).padStart(2,"0")),level:ve,tier:ne,level_string:n.getLevelString(ve,ne),profile_idc:e,profile_string:"".concat(e),bit_depth:ye,ref_frames:1,chroma_format:n.getChromaFormat(Oe,Ve,xe),chroma_format_string:n.getChromaFormatString(Oe,Ve,xe),sequence_header:{frame_id_numbers_present_flag:Se,additional_frame_id_length_minus_1:void 0,delta_frame_id_length_minus_2:void 0,reduced_still_picture_header:a,decoder_model_info_present_flag:!1,operating_points:l,buffer_removal_time_length_minus_1:d,equal_picture_interval:o,seq_force_screen_content_tools:we,seq_force_integer_mv:Te,enable_order_hint:Ce,order_hint_bits:pe,enable_superres:Ae,frame_width_bit:ae+1,frame_height_bit:ge+1,max_frame_width:ce,max_frame_height:De},keyframe:void 0,frame_rate:{fixed:o,fps:r/s,fps_den:s,fps_num:r}}},n.parseOBUFrameHeader=function(i,t,e,a){var o=a.sequence_header,r=new A(i),s=(o.max_frame_width,o.max_frame_height,0);o.frame_id_numbers_present_flag&&(s=o.additional_frame_id_length_minus_1+o.delta_frame_id_length_minus_2+3);var d=0,l=!0,y=!0,f=!1;if(!o.reduced_still_picture_header){if(r.readBool())return a;l=(d=r.readBits(2))===2||d===0,(y=r.readBool())&&o.decoder_model_info_present_flag&&o.equal_picture_interval,y&&r.readBool(),f=!!(d===3||d===0&&y)||r.readBool()}a.keyframe=l,r.readBool();var g=o.seq_force_screen_content_tools;o.seq_force_screen_content_tools===2&&(g=r.readBits(1)),g&&(o.seq_force_integer_mv,o.seq_force_integer_mv==2&&r.readBits(1)),o.frame_id_numbers_present_flag&&r.readBits(s);var T;if(T=d==3||!o.reduced_still_picture_header&&r.readBool(),r.readBits(o.order_hint_bits),l||f||r.readBits(3),o.decoder_model_info_present_flag&&r.readBool()){for(var O=0;O<=o.operating_points_cnt_minus_1;O++)if(o.operating_points[O].decoder_model_present_for_this_op[O]){var F=o.operating_points[O].operating_point_idc;(F===0||F>>t&1&&F>>e+8&1)&&r.readBits(o.buffer_removal_time_length_minus_1+1)}}var q=255;if(d===3||d==0&&y||(q=r.readBits(8)),(l||q!==255)&&f&&o.enable_order_hint)for(var Z=0;Z<8;Z++)r.readBits(o.order_hint_bits);if(l){var N=n.frameSizeAndRenderSize(r,T,o);a.codec_size={width:N.FrameWidth,height:N.FrameHeight},a.present_size={width:N.RenderWidth,height:N.RenderHeight},a.sar_ratio={width:N.RenderWidth/N.FrameWidth,height:N.RenderHeight/N.FrameHeight}}return r.destroy(),r=null,a},n.frameSizeAndRenderSize=function(i,t,e){var{max_frame_width:a,max_frame_height:o}=e;t&&(a=i.readBits(e.frame_width_bit)+1,o=i.readBits(e.frame_height_bit)+1);var r=!1;e.enable_superres&&(r=i.readBool());var s=8;r&&(s=i.readBits(3)+9);var d=a;a=Math.floor((8*d+s/2)/s);var l=d,y=o;if(i.readBool()){var f=i.readBits(16)+1,g=i.readBits(16)+1;l=i.readBits(f)+1,y=i.readBits(g)+1}return{UpscaledWidth:d,FrameWidth:a,FrameHeight:o,RenderWidth:l,RenderHeight:y}},n.getLevelString=function(i,t){return"".concat(i.toString(10).padStart(2,"0")).concat(t===0?"M":"H")},n.getChromaFormat=function(i,t,e){return i?0:t===0&&e===0?3:t===1&&e===0?2:t===1&&e===1?1:Number.NaN},n.getChromaFormatString=function(i,t,e){return i?"4:0:0":t===0&&e===0?"4:4:4":t===1&&e===0?"4:2:2":t===1&&e===1?"4:2:0":"Unknown"},n}(),E=function(){};function K(n,i,t){if(!n||n.byteLength<2)return null;var e=1;t==="h265"&&(e=2);var a=function(y){for(var f=y,g=f.byteLength,T=new Uint8Array(g),O=0,F=0;F=2&&f[F]===3&&f[F-1]===0&&f[F-2]===0||(T[O]=f[F],O++);return new Uint8Array(T.buffer,0,O)}(n.subarray(e)),o=0;if(o===a.byteLength-1&&a[o]===128)return null;for(var r=0;o=a.byteLength)return null;r+=a[o++];for(var s=0;o=a.byteLength)return null;if(s+=a[o++],o+s>a.byteLength)return null;var d=new E;d.type=r,d.size=s;var l=a.subarray(o,o+s);return r===5&&s>=16&&(d.uuid=l.subarray(0,16),d.user_data=l.subarray(16)),i!==void 0&&(d.pts=i),d}var z,de=function(){function n(i,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._onSeiArrived=null,this._dataOffset=i.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=i.hasAudioTrack,this._hasVideo=i.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new R.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1000,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1000},this._flvSoundRateTable=[5500,11025,22050,44100,48000],this._mpegSamplingRates=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],this._mpegAudioV10SampleRateTable=[44100,48000,32000,0],this._mpegAudioV20SampleRateTable=[22050,24000,16000,0],this._mpegAudioV25SampleRateTable=[11025,12000,8000,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256}()}return n.prototype.destroy=function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._onSeiArrived=null},n.probe=function(i){var t=new Uint8Array(i);if(t.byteLength<9)return{needMoreData:!0};var e={match:!1};if(t[0]!==70||t[1]!==76||t[2]!==86||t[3]!==1)return e;var a,o=(4&t[4])>>>2!=0,r=!!(1&t[4]),s=(a=t)[5]<<24|a[6]<<16|a[7]<<8|a[8];return s<9?e:{match:!0,consumed:s,dataOffset:s,hasAudioTrack:o,hasVideoTrack:r}},n.prototype.bindDataSource=function(i){return i.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(n.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(i){this._onTrackMetadata=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(i){this._onMediaInfo=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(i){this._onMetaDataArrived=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(i){this._onScriptDataArrived=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"onSeiArrived",{get:function(){return this._onSeiArrived},set:function(i){this._onSeiArrived=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"onError",{get:function(){return this._onError},set:function(i){this._onError=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(i){this._onDataAvailable=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(i){this._timestampBase=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"overridedDuration",{get:function(){return this._duration},set:function(i){this._durationOverrided=!0,this._duration=i,this._mediaInfo.duration=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"overridedHasAudio",{set:function(i){this._hasAudioFlagOverrided=!0,this._hasAudio=i,this._mediaInfo.hasAudio=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"overridedHasVideo",{set:function(i){this._hasVideoFlagOverrided=!0,this._hasVideo=i,this._mediaInfo.hasVideo=i},enumerable:!1,configurable:!0}),n.prototype.resetMediaInfo=function(){this._mediaInfo=new R.default},n.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},n.prototype.parseChunks=function(i,t){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new M.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var e=0,a=this._littleEndian;if(t===0){if(!(i.byteLength>13))return 0;e=n.probe(i).dataOffset}for(this._firstParse&&(this._firstParse=!1,t+e!==this._dataOffset&&_.default.w(this.TAG,"First time parsing but chunk byteStart invalid!"),(o=new DataView(i,e)).getUint32(0,!a)!==0&&_.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),e+=4);ei.byteLength)break;var r=o.getUint8(0),s=16777215&o.getUint32(0,!a);if(e+11+s+4>i.byteLength)break;if(r===8||r===9||r===18){var d=o.getUint8(4),l=o.getUint8(5),y=o.getUint8(6)|l<<8|d<<16|o.getUint8(7)<<24;16777215&o.getUint32(7,!a)&&_.default.w(this.TAG,"Meet tag which has StreamID != 0!");var f=e+11;switch(r){case 8:this._parseAudioData(i,f,s,y);break;case 9:this._parseVideoData(i,f,s,y,t+e);break;case 18:this._parseScriptData(i,f,s)}var g=o.getUint32(11+s,!a);g!==11+s&&_.default.w(this.TAG,"Invalid PrevTagSize ".concat(g)),e+=11+s+4}else _.default.w(this.TAG,"Unsupported tag type ".concat(r,", skipped")),e+=11+s+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),e},n.prototype._parseScriptData=function(i,t,e){var a=B.parseScriptData(i,t,e);if(a.hasOwnProperty("onMetaData")){if(a.onMetaData==null||typeof a.onMetaData!="object")return void _.default.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&_.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=a;var o=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},o)),typeof o.hasAudio=="boolean"&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=o.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),typeof o.hasVideo=="boolean"&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=o.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),typeof o.audiodatarate=="number"&&(this._mediaInfo.audioDataRate=o.audiodatarate),typeof o.videodatarate=="number"&&(this._mediaInfo.videoDataRate=o.videodatarate),typeof o.width=="number"&&(this._mediaInfo.width=o.width),typeof o.height=="number"&&(this._mediaInfo.height=o.height),typeof o.duration=="number"){if(!this._durationOverrided){var r=Math.floor(o.duration*this._timescale);this._duration=r,this._mediaInfo.duration=r}}else this._mediaInfo.duration=0;if(typeof o.framerate=="number"){var s=Math.floor(1000*o.framerate);if(s>0){var d=s/1000;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=d,this._referenceFrameRate.fps_num=s,this._referenceFrameRate.fps_den=1000,this._mediaInfo.fps=d}}if(typeof o.keyframes=="object"){this._mediaInfo.hasKeyframesIndex=!0;var l=o.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(l),o.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=o,_.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(a).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},a))},n.prototype._parseSEIPayload=function(i,t,e){var a=K(i,t,e);a&&typeof this._onSeiArrived=="function"&&this._onSeiArrived(a)},n.prototype._parseKeyframesIndex=function(i){for(var t=[],e=[],a=1;a>>4;if(r!==9)if(r===2||r===3||r===10){var s=0,d=(12&o)>>>2;if(d>=0&&d<=4){s=this._flvSoundRateTable[d];var l=(2&o)>>>1,y=1&o,f=this._audioMetadata,g=this._audioTrack;if(f||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(f=this._audioMetadata={}).type="audio",f.id=g.id,f.timescale=this._timescale,f.duration=this._duration,f.audioSampleRate=s,f.channelCount=y===0?1:2),r===10){var T=this._parseAACAudioData(i,t+1,e-1);if(T==null)return;if(T.packetType===0){if(f.config){if(u(T.data.config,f.config))return;_.default.w(this.TAG,"AudioSpecificConfig has been changed, re-generate initialization segment")}var O=T.data;f.audioSampleRate=O.samplingRate,f.channelCount=O.channelCount,f.codec=O.codec,f.originalCodec=O.originalCodec,f.config=O.config,f.refSampleDuration=1024/f.audioSampleRate*f.timescale,_.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",f),(N=this._mediaInfo).audioCodec=f.originalCodec,N.audioSampleRate=f.audioSampleRate,N.audioChannelCount=f.channelCount,N.hasVideo?N.videoCodec!=null&&(N.mimeType='video/x-flv; codecs="'+N.videoCodec+","+N.audioCodec+'"'):N.mimeType='video/x-flv; codecs="'+N.audioCodec+'"',N.isComplete()&&this._onMediaInfo(N)}else if(T.packetType===1){var F=this._timestampBase+a,q={unit:T.data,length:T.data.byteLength,dts:F,pts:F};g.samples.push(q),g.length+=T.data.length}else _.default.e(this.TAG,"Flv: Unsupported AAC data type ".concat(T.packetType))}else if(r===2){if(!f.codec){if((O=this._parseMP3AudioData(i,t+1,e-1,!0))==null)return;f.audioSampleRate=O.samplingRate,f.channelCount=O.channelCount,f.codec=O.codec,f.originalCodec=O.originalCodec,f.refSampleDuration=1152/f.audioSampleRate*f.timescale,_.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",f),(N=this._mediaInfo).audioCodec=f.codec,N.audioSampleRate=f.audioSampleRate,N.audioChannelCount=f.channelCount,N.audioDataRate=O.bitRate,N.hasVideo?N.videoCodec!=null&&(N.mimeType='video/x-flv; codecs="'+N.videoCodec+","+N.audioCodec+'"'):N.mimeType='video/x-flv; codecs="'+N.audioCodec+'"',N.isComplete()&&this._onMediaInfo(N)}if((H=this._parseMP3AudioData(i,t+1,e-1,!1))==null)return;F=this._timestampBase+a;var Z={unit:H,length:H.byteLength,dts:F,pts:F};g.samples.push(Z),g.length+=H.length}else if(r===3){var N;f.codec||(f.audioSampleRate=s,f.sampleSize=8*(l+1),f.littleEndian=!0,f.codec="ipcm",f.originalCodec="ipcm",this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",f),(N=this._mediaInfo).audioCodec=f.codec,N.audioSampleRate=f.audioSampleRate,N.audioChannelCount=f.channelCount,N.audioDataRate=f.sampleSize*f.audioSampleRate,N.hasVideo?N.videoCodec!=null&&(N.mimeType='video/x-flv; codecs="'+N.videoCodec+","+N.audioCodec+'"'):N.mimeType='video/x-flv; codecs="'+N.audioCodec+'"',N.isComplete()&&this._onMediaInfo(N));var H=new Uint8Array(i,t+1,e-1),he=(F=this._timestampBase+a,{unit:H,length:H.byteLength,dts:F,pts:F});g.samples.push(he),g.length+=H.length}}else this._onError(m.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+d)}else this._onError(m.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+r);else{if(e<=5)return void _.default.w(this.TAG,"Flv: Invalid audio packet, missing AudioFourCC in Ehnanced FLV payload!");var ve=15&o,ne=String.fromCharCode.apply(String,new Uint8Array(i,t,e).slice(1,5));switch(ne){case"Opus":this._parseOpusAudioPacket(i,t+5,e-5,a,ve);break;case"fLaC":this._parseFlacAudioPacket(i,t+5,e-5,a,ve);break;default:this._onError(m.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec: "+ne)}}}},n.prototype._parseAACAudioData=function(i,t,e){if(!(e<=1)){var a={},o=new Uint8Array(i,t,e);return a.packetType=o[0],o[0]===0?a.data=this._parseAACAudioSpecificConfig(i,t+1,e-1):a.data=o.subarray(1),a}_.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},n.prototype._parseAACAudioSpecificConfig=function(i,t,e){var a,o,r=new Uint8Array(i,t,e),s=null,d=0,l=null;if(d=a=r[0]>>>3,(o=(7&r[0])<<1|r[1]>>>7)<0||o>=this._mpegSamplingRates.length)this._onError(m.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var y=this._mpegSamplingRates[o],f=(120&r[1])>>>3;if(!(f<0||f>=8)){d===5&&(l=(7&r[1])<<1|r[2]>>>7,r[2]);var g=self.navigator.userAgent.toLowerCase();return g.indexOf("firefox")!==-1?o>=6?(d=5,s=[,,,,],l=o-3):(d=2,s=[,,],l=o):g.indexOf("android")!==-1?(d=2,s=[,,],l=o):(d=5,l=o,s=[,,,,],o>=6?l=o-3:f===1&&(d=2,s=[,,],l=o)),s[0]=d<<3,s[0]|=(15&o)>>>1,s[1]=(15&o)<<7,s[1]|=(15&f)<<3,d===5&&(s[1]|=(15&l)>>>1,s[2]=(1&l)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:y,channelCount:f,codec:"mp4a.40."+d,originalCodec:"mp4a.40."+a}}this._onError(m.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},n.prototype._parseMP3AudioData=function(i,t,e,a){if(!(e<4)){this._littleEndian;var o=new Uint8Array(i,t,e),r=null;if(a){if(o[0]!==255)return;var s=o[1]>>>3&3,d=(6&o[1])>>1,l=(240&o[2])>>>4,y=(12&o[2])>>>2,f=3&~(o[3]>>>6)?2:1,g=0,T=0;switch(s){case 0:g=this._mpegAudioV25SampleRateTable[y];break;case 2:g=this._mpegAudioV20SampleRateTable[y];break;case 3:g=this._mpegAudioV10SampleRateTable[y]}switch(d){case 1:l>>16&255,O[2]=r.byteLength>>>8&255,O[3]=r.byteLength>>>0&255;var F={config:O,channelCount:g,samplingFrequence:f,sampleSize:T,codec:"flac",originalCodec:"flac"};if(a.config){if(u(F.config,a.config))return;_.default.w(this.TAG,"FlacSequenceHeader has been changed, re-generate initialization segment")}a.audioSampleRate=F.samplingFrequence,a.channelCount=F.channelCount,a.sampleSize=F.sampleSize,a.codec=F.codec,a.originalCodec=F.originalCodec,a.config=F.config,a.refSampleDuration=y!=null?1000*y/F.samplingFrequence:null,_.default.v(this.TAG,"Parsed FlacSequenceHeader"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",a);var q=this._mediaInfo;q.audioCodec=a.originalCodec,q.audioSampleRate=a.audioSampleRate,q.audioChannelCount=a.channelCount,q.hasVideo?q.videoCodec!=null&&(q.mimeType='video/x-flv; codecs="'+q.videoCodec+","+q.audioCodec+'"'):q.mimeType='video/x-flv; codecs="'+q.audioCodec+'"',q.isComplete()&&this._onMediaInfo(q)},n.prototype._parseFlacAudioData=function(i,t,e,a){var o=this._audioTrack,r=new Uint8Array(i,t,e),s=this._timestampBase+a,d={unit:r,length:r.byteLength,dts:s,pts:s};o.samples.push(d),o.length+=r.length},n.prototype._parseVideoData=function(i,t,e,a,o){if(e<=1)_.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");else if(this._hasVideoFlagOverrided!==!0||this._hasVideo!==!1){var r=new Uint8Array(i,t,e)[0],s=(112&r)>>>4;if(128&r){var d=15&r,l=String.fromCharCode.apply(String,new Uint8Array(i,t,e).slice(1,5));if(l==="hvc1")this._parseEnhancedHEVCVideoPacket(i,t+5,e-5,a,o,s,d);else{if(l!=="av01")return void this._onError(m.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: ".concat(l));this._parseEnhancedAV1VideoPacket(i,t+5,e-5,a,o,s,d)}}else{var y=15&r;if(y===7)this._parseAVCVideoPacket(i,t+1,e-1,a,o,s);else{if(y!==12)return void this._onError(m.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: ".concat(y));this._parseHEVCVideoPacket(i,t+1,e-1,a,o,s)}}}},n.prototype._parseAVCVideoPacket=function(i,t,e,a,o,r){if(e<4)_.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var s=this._littleEndian,d=new DataView(i,t,e),l=d.getUint8(0),y=(16777215&d.getUint32(0,!s))<<8>>8;if(l===0)this._parseAVCDecoderConfigurationRecord(i,t+4,e-4);else if(l===1)this._parseAVCVideoData(i,t+4,e-4,a,o,r,y);else if(l!==2)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(l))}},n.prototype._parseHEVCVideoPacket=function(i,t,e,a,o,r){if(e<4)_.default.w(this.TAG,"Flv: Invalid HEVC packet, missing HEVCPacketType or/and CompositionTime");else{var s=this._littleEndian,d=new DataView(i,t,e),l=d.getUint8(0),y=(16777215&d.getUint32(0,!s))<<8>>8;if(l===0)this._parseHEVCDecoderConfigurationRecord(i,t+4,e-4);else if(l===1)this._parseHEVCVideoData(i,t+4,e-4,a,o,r,y);else if(l!==2)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(l))}},n.prototype._parseEnhancedHEVCVideoPacket=function(i,t,e,a,o,r,s){var d=this._littleEndian,l=new DataView(i,t,e);if(s===0)this._parseHEVCDecoderConfigurationRecord(i,t,e);else if(s===1){var y=(4294967040&l.getUint32(0,!d))>>8;this._parseHEVCVideoData(i,t+3,e-3,a,o,r,y)}else if(s===3)this._parseHEVCVideoData(i,t,e,a,o,r,0);else if(s!==2)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(s))},n.prototype._parseEnhancedAV1VideoPacket=function(i,t,e,a,o,r,s){if(this._littleEndian,new DataView(i,t,e),s===0)this._parseAV1CodecConfigurationRecord(i,t,e);else if(s===1)this._parseAV1VideoData(i,t,e,a,o,r,0);else{if(s===5)return void this._onError(m.default.FORMAT_ERROR,"Flv: Not Supported MP2T AV1 video packet type ".concat(s));if(s!==2)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(s))}},n.prototype._parseAVCDecoderConfigurationRecord=function(i,t,e){if(e<7)_.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var a=this._videoMetadata,o=this._videoTrack,r=this._littleEndian,s=new DataView(i,t,e);if(a){if(a.avcc!==void 0){var d=new Uint8Array(i,t,e);if(u(d,a.avcc))return;_.default.w(this.TAG,"AVCDecoderConfigurationRecord has been changed, re-generate initialization segment")}}else this._hasVideo===!1&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(a=this._videoMetadata={}).type="video",a.id=o.id,a.timescale=this._timescale,a.duration=this._duration;var l=s.getUint8(0),y=s.getUint8(1);if(s.getUint8(2),s.getUint8(3),l===1&&y!==0)if(this._naluLengthSize=1+(3&s.getUint8(4)),this._naluLengthSize===3||this._naluLengthSize===4){var f=31&s.getUint8(5);if(f!==0){f>1&&_.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ".concat(f));for(var g=6,T=0;T1&&_.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ".concat(ge)),g++,T=0;T=e){_.default.w(this.TAG,"Malformed Nalu near timestamp ".concat(O,", offset = ").concat(g,", dataSize = ").concat(e));break}var q=l.getUint32(g,!d);if(T===3&&(q>>>=8),q>e-T)return void _.default.w(this.TAG,"Malformed Nalus near timestamp ".concat(O,", NaluSize > DataSize!"));var Z=31&l.getUint8(g+T);Z===5&&(F=!0);var N=new Uint8Array(i,t+g,T+q),H={type:Z,data:N};y.push(H),f+=N.byteLength,Z===6&&this._parseSEIPayload(N.subarray(T),O+s,"h264"),g+=T+q}if(y.length){var he=this._videoTrack,ve={units:y,length:f,isKeyframe:F,dts:O,cts:s,pts:O+s};F&&(ve.fileposition=o),he.samples.push(ve),he.length+=f}},n.prototype._parseHEVCVideoData=function(i,t,e,a,o,r,s){for(var d=this._littleEndian,l=new DataView(i,t,e),y=[],f=0,g=0,T=this._naluLengthSize,O=this._timestampBase+a,F=r===1;g=e){_.default.w(this.TAG,"Malformed Nalu near timestamp ".concat(O,", offset = ").concat(g,", dataSize = ").concat(e));break}var q=l.getUint32(g,!d);if(T===3&&(q>>>=8),q>e-T)return void _.default.w(this.TAG,"Malformed Nalus near timestamp ".concat(O,", NaluSize > DataSize!"));var Z=l.getUint8(g+T)>>1&63;Z!==19&&Z!==20&&Z!==21||(F=!0);var N=new Uint8Array(i,t+g,T+q),H={type:Z,data:N};y.push(H),f+=N.byteLength,Z!==39&&Z!==40||this._parseSEIPayload(N.subarray(T),O+s,"h265"),g+=T+q}if(y.length){var he=this._videoTrack,ve={units:y,length:f,isKeyframe:F,dts:O,cts:s,pts:O+s};F&&(ve.fileposition=o),he.samples.push(ve),he.length+=f}},n.prototype._parseAV1VideoData=function(i,t,e,a,o,r,s){this._littleEndian,new DataView(i,t,e);var d,l=[],y=this._timestampBase+a,f=r===1;if(f){var g=this._videoMetadata,T=p.parseOBUs(new Uint8Array(i,t,e),g.extra);if(T==null)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid AV1 VideoData");console.log(T),g.codecWidth=T.codec_size.width,g.codecHeight=T.codec_size.height,g.presentWidth=T.present_size.width,g.presentHeight=T.present_size.height,g.sarRatio=T.sar_ratio;var O=this._mediaInfo;O.width=g.codecWidth,O.height=g.codecHeight,O.sarNum=g.sarRatio.width,O.sarDen=g.sarRatio.height,_.default.v(this.TAG,"Parsed AV1DecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",g)}if(d=e,l.push({unitType:0,data:new Uint8Array(i,t+0,e)}),l.length){var F=this._videoTrack,q={units:l,length:d,isKeyframe:f,dts:y,cts:s,pts:y+s};f&&(q.fileposition=o),F.samples.push(q),F.length+=d}},n}(),le=de,me=function(){function n(){}return n.prototype.destroy=function(){this.onError=null,this.onMediaInfo=null,this.onMetaDataArrived=null,this.onTrackMetadata=null,this.onDataAvailable=null,this.onTimedID3Metadata=null,this.onPGSSubtitleData=null,this.onSynchronousKLVMetadata=null,this.onAsynchronousKLVMetadata=null,this.onSMPTE2038Metadata=null,this.onSEI=null,this.onSCTE35Metadata=null,this.onPESPrivateData=null,this.onPESPrivateDataDescriptor=null},n}(),te=function(){this.program_pmt_pid={}};(function(n){n[n.kMPEG1Audio=3]="kMPEG1Audio",n[n.kMPEG2Audio=4]="kMPEG2Audio",n[n.kPESPrivateData=6]="kPESPrivateData",n[n.kADTSAAC=15]="kADTSAAC",n[n.kLOASAAC=17]="kLOASAAC",n[n.kAC3=129]="kAC3",n[n.kEAC3=135]="kEAC3",n[n.kMetadata=21]="kMetadata",n[n.kSCTE35=134]="kSCTE35",n[n.kPGS=144]="kPGS",n[n.kH264=27]="kH264",n[n.kH265=36]="kH265"})(z||(z={}));var ee,Re=function(){this.pid_stream_type={},this.common_pids={h264:void 0,h265:void 0,av1:void 0,adts_aac:void 0,loas_aac:void 0,opus:void 0,ac3:void 0,eac3:void 0,mp3:void 0},this.pes_private_data_pids={},this.timed_id3_pids={},this.pgs_pids={},this.pgs_langs={},this.synchronous_klv_pids={},this.asynchronous_klv_pids={},this.scte_35_pids={},this.smpte2038_pids={}},J=function(){},ke=function(){},k=function(){this.slices=[],this.total_length=0,this.expected_length=0,this.file_position=0};(function(n){n[n.kUnspecified=0]="kUnspecified",n[n.kSliceNonIDR=1]="kSliceNonIDR",n[n.kSliceDPA=2]="kSliceDPA",n[n.kSliceDPB=3]="kSliceDPB",n[n.kSliceDPC=4]="kSliceDPC",n[n.kSliceIDR=5]="kSliceIDR",n[n.kSliceSEI=6]="kSliceSEI",n[n.kSliceSPS=7]="kSliceSPS",n[n.kSlicePPS=8]="kSlicePPS",n[n.kSliceAUD=9]="kSliceAUD",n[n.kEndOfSequence=10]="kEndOfSequence",n[n.kEndOfStream=11]="kEndOfStream",n[n.kFiller=12]="kFiller",n[n.kSPSExt=13]="kSPSExt",n[n.kReserved0=14]="kReserved0"})(ee||(ee={}));var c,w,j=function(){},fe=function(n){var i=n.data.byteLength;this.type=n.type,this.data=new Uint8Array(4+i),new DataView(this.data.buffer).setUint32(0,i),this.data.set(n.data,4)},re=function(){function n(i){this.TAG="H264AnnexBParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=i,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&_.default.e(this.TAG,"Could not find H264 startcode until payload end!")}return n.prototype.findNextStartCodeOffset=function(i){for(var t=i,e=this.data_;;){if(t+3>=e.byteLength)return this.eof_flag_=!0,e.byteLength;var a=e[t+0]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],o=e[t+0]<<16|e[t+1]<<8|e[t+2];if(a===1||o===1)return t;t++}},n.prototype.readNextNaluPayload=function(){for(var i=this.data_,t=null;t==null&&!this.eof_flag_;){var e=this.current_startcode_offset_,a=31&i[e+=(i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])==1?4:3],o=(128&i[e])>>>7,r=this.findNextStartCodeOffset(e);if(this.current_startcode_offset_=r,!(a>=ee.kReserved0)&&o===0){var s=i.subarray(e,r);(t=new j).type=a,t.data=s}}return t},n}(),V=function(){function n(i,t,e){var a=8+i.byteLength+1+2+t.byteLength,o=!1;i[3]!==66&&i[3]!==77&&i[3]!==88&&(o=!0,a+=4);var r=this.data=new Uint8Array(a);r[0]=1,r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=255,r[5]=225;var s=i.byteLength;r[6]=s>>>8,r[7]=255&s;var d=8;r.set(i,8),r[d+=s]=1;var l=t.byteLength;r[d+1]=l>>>8,r[d+2]=255&l,r.set(t,d+3),d+=3+l,o&&(r[d]=252|e.chroma_format_idc,r[d+1]=248|e.bit_depth_luma-8,r[d+2]=248|e.bit_depth_chroma-8,r[d+3]=0,d+=4)}return n.prototype.getData=function(){return this.data},n}();(function(n){n[n.kNull=0]="kNull",n[n.kAACMain=1]="kAACMain",n[n.kAAC_LC=2]="kAAC_LC",n[n.kAAC_SSR=3]="kAAC_SSR",n[n.kAAC_LTP=4]="kAAC_LTP",n[n.kAAC_SBR=5]="kAAC_SBR",n[n.kAAC_Scalable=6]="kAAC_Scalable",n[n.kLayer1=32]="kLayer1",n[n.kLayer2=33]="kLayer2",n[n.kLayer3=34]="kLayer3"})(c||(c={})),function(n){n[n.k96000Hz=0]="k96000Hz",n[n.k88200Hz=1]="k88200Hz",n[n.k64000Hz=2]="k64000Hz",n[n.k48000Hz=3]="k48000Hz",n[n.k44100Hz=4]="k44100Hz",n[n.k32000Hz=5]="k32000Hz",n[n.k24000Hz=6]="k24000Hz",n[n.k22050Hz=7]="k22050Hz",n[n.k16000Hz=8]="k16000Hz",n[n.k12000Hz=9]="k12000Hz",n[n.k11025Hz=10]="k11025Hz",n[n.k8000Hz=11]="k8000Hz",n[n.k7350Hz=12]="k7350Hz"}(w||(w={}));var Y,ie,oe=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],ue=(Y=function(n,i){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])},Y(n,i)},function(n,i){if(typeof i!="function"&&i!==null)throw TypeError("Class extends value "+String(i)+" is not a constructor or null");function t(){this.constructor=n}Y(n,i),n.prototype=i===null?Object.create(i):(t.prototype=i.prototype,new t)}),Ee=function(){},Pe=function(n){function i(){return n!==null&&n.apply(this,arguments)||this}return ue(i,n),i}(Ee),Ue=function(){function n(i){this.TAG="AACADTSParser",this.data_=i,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&_.default.e(this.TAG,"Could not found ADTS syncword until payload end")}return n.prototype.findNextSyncwordOffset=function(i){for(var t=i,e=this.data_;;){if(t+7>=e.byteLength)return this.eof_flag_=!0,e.byteLength;if((e[t+0]<<8|e[t+1])>>>4==4095)return t;t++}},n.prototype.readNextAACFrame=function(){for(var i=this.data_,t=null;t==null&&!this.eof_flag_;){var e=this.current_syncword_offset_,a=(8&i[e+1])>>>3,o=(6&i[e+1])>>>1,r=1&i[e+1],s=(192&i[e+2])>>>6,d=(60&i[e+2])>>>2,l=(1&i[e+2])<<2|(192&i[e+3])>>>6,y=(3&i[e+3])<<11|i[e+4]<<3|(224&i[e+5])>>>5;if(i[e+6],e+y>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var f=r===1?7:9,g=y-f;e+=f;var T=this.findNextSyncwordOffset(e+g);if(this.current_syncword_offset_=T,(a===0||a===1)&&o===0){var O=i.subarray(e,e+g);(t=new Ee).audio_object_type=s+1,t.sampling_freq_index=d,t.sampling_frequency=oe[d],t.channel_config=l,t.data=O}}return t},n.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},n.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},n}(),je=function(){function n(i){this.TAG="AACLOASParser",this.data_=i,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&_.default.e(this.TAG,"Could not found LOAS syncword until payload end")}return n.prototype.findNextSyncwordOffset=function(i){for(var t=i,e=this.data_;;){if(t+1>=e.byteLength)return this.eof_flag_=!0,e.byteLength;if((e[t+0]<<3|e[t+1]>>>5)==695)return t;t++}},n.prototype.getLATMValue=function(i){for(var t=i.readBits(2),e=0,a=0;a<=t;a++)e<<=8,e|=i.readByte();return e},n.prototype.readNextAACFrame=function(i){for(var t=this.data_,e=null;e==null&&!this.eof_flag_;){var a=this.current_syncword_offset_,o=(31&t[a+1])<<8|t[a+2];if(a+3+o>=this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var r=new A(t.subarray(a+3,a+3+o)),s=null;if(r.readBool()){if(i==null){_.default.w(this.TAG,"StreamMuxConfig Missing"),this.current_syncword_offset_=this.findNextSyncwordOffset(a+3+o),r.destroy();continue}s=i}else{var d=r.readBool();if(d&&r.readBool()){_.default.e(this.TAG,"audioMuxVersionA is Not Supported"),r.destroy();break}if(d&&this.getLATMValue(r),!r.readBool()){_.default.e(this.TAG,"allStreamsSameTimeFraming zero is Not Supported"),r.destroy();break}if(r.readBits(6)!==0){_.default.e(this.TAG,"more than 2 numSubFrames Not Supported"),r.destroy();break}if(r.readBits(4)!==0){_.default.e(this.TAG,"more than 2 numProgram Not Supported"),r.destroy();break}if(r.readBits(3)!==0){_.default.e(this.TAG,"more than 2 numLayer Not Supported"),r.destroy();break}var l=d?this.getLATMValue(r):0,y=r.readBits(5);l-=5;var f=r.readBits(4);l-=4;var g=r.readBits(4);l-=4,r.readBits(3),(l-=3)>0&&r.readBits(l);var T=r.readBits(3);if(T!==0){_.default.e(this.TAG,"frameLengthType = ".concat(T,". Only frameLengthType = 0 Supported")),r.destroy();break}r.readByte();var O=r.readBool();if(O)if(d)this.getLATMValue(r);else{for(var F=0;;){F<<=8;var q=r.readBool();if(F+=r.readByte(),!q)break}console.log(F)}r.readBool()&&r.readByte(),(s=new Pe).audio_object_type=y,s.sampling_freq_index=f,s.sampling_frequency=oe[s.sampling_freq_index],s.channel_config=g,s.other_data_present=O}for(var Z=0;;){var N=r.readByte();if(Z+=N,N!==255)break}for(var H=new Uint8Array(Z),he=0;he=6?(e=5,i=[,,,,],r=a-3):(e=2,i=[,,],r=a):s.indexOf("android")!==-1?(e=2,i=[,,],r=a):(e=5,r=a,i=[,,,,],a>=6?r=a-3:o===1&&(e=2,i=[,,],r=a)),i[0]=e<<3,i[0]|=(15&a)>>>1,i[1]=(15&a)<<7,i[1]|=(15&o)<<3,e===5&&(i[1]|=(15&r)>>>1,i[2]=(1&r)<<7,i[2]|=8,i[3]=0),this.config=i,this.sampling_rate=oe[a],this.channel_count=o,this.codec_mimetype="mp4a.40."+e,this.original_codec_mimetype="mp4a.40."+t},Xe=function(){},nt=function(){};(function(n){n[n.kSpliceNull=0]="kSpliceNull",n[n.kSpliceSchedule=4]="kSpliceSchedule",n[n.kSpliceInsert=5]="kSpliceInsert",n[n.kTimeSignal=6]="kTimeSignal",n[n.kBandwidthReservation=7]="kBandwidthReservation",n[n.kPrivateCommand=255]="kPrivateCommand"})(ie||(ie={}));var Ne,Qe=function(n){var i=n.readBool();return i?(n.readBits(6),{time_specified_flag:i,pts_time:4*n.readBits(31)+n.readBits(2)}):(n.readBits(7),{time_specified_flag:i})},ht=function(n){var i=n.readBool();return n.readBits(6),{auto_return:i,duration:4*n.readBits(31)+n.readBits(2)}},Ot=function(n,i){var t=i.readBits(8);return n?{component_tag:t}:{component_tag:t,splice_time:Qe(i)}},Pt=function(n){return{component_tag:n.readBits(8),utc_splice_time:n.readBits(32)}},xt=function(n){var i=n.readBits(32),t=n.readBool();n.readBits(7);var e={splice_event_id:i,splice_event_cancel_indicator:t};if(t)return e;if(e.out_of_network_indicator=n.readBool(),e.program_splice_flag=n.readBool(),e.duration_flag=n.readBool(),n.readBits(5),e.program_splice_flag)e.utc_splice_time=n.readBits(32);else{e.component_count=n.readBits(8),e.components=[];for(var a=0;a=e.byteLength)return this.eof_flag_=!0,e.byteLength;var a=e[t+0]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],o=e[t+0]<<16|e[t+1]<<8|e[t+2];if(a===1||o===1)return t;t++}},n.prototype.readNextNaluPayload=function(){for(var i=this.data_,t=null;t==null&&!this.eof_flag_;){var e=this.current_startcode_offset_,a=i[e+=(i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])==1?4:3]>>1&63,o=(128&i[e])>>>7,r=this.findNextStartCodeOffset(e);if(this.current_startcode_offset_=r,o===0){var s=i.subarray(e,r);(t=new Ht).type=a,t.data=s}}return t},n}(),Wt=function(){function n(i,t,e,a){var o=23+(5+i.byteLength)+(5+t.byteLength)+(5+e.byteLength),r=this.data=new Uint8Array(o);r[0]=1,r[1]=(3&a.general_profile_space)<<6|(a.general_tier_flag?1:0)<<5|31&a.general_profile_idc,r[2]=a.general_profile_compatibility_flags_1,r[3]=a.general_profile_compatibility_flags_2,r[4]=a.general_profile_compatibility_flags_3,r[5]=a.general_profile_compatibility_flags_4,r[6]=a.general_constraint_indicator_flags_1,r[7]=a.general_constraint_indicator_flags_2,r[8]=a.general_constraint_indicator_flags_3,r[9]=a.general_constraint_indicator_flags_4,r[10]=a.general_constraint_indicator_flags_5,r[11]=a.general_constraint_indicator_flags_6,r[12]=a.general_level_idc,r[13]=240|(3840&a.min_spatial_segmentation_idc)>>8,r[14]=255&a.min_spatial_segmentation_idc,r[15]=252|3&a.parallelismType,r[16]=252|3&a.chroma_format_idc,r[17]=248|7&a.bit_depth_luma_minus8,r[18]=248|7&a.bit_depth_chroma_minus8,r[19]=0,r[20]=0,r[21]=(3&a.constant_frame_rate)<<6|(7&a.num_temporal_layers)<<3|(a.temporal_id_nested?1:0)<<2|3,r[22]=3,r[23]=128|Ne.kSliceVPS,r[24]=0,r[25]=1,r[26]=(65280&i.byteLength)>>8,r[27]=255&i.byteLength,r.set(i,28),r[23+(5+i.byteLength)+0]=128|Ne.kSliceSPS,r[23+(5+i.byteLength)+1]=0,r[23+(5+i.byteLength)+2]=1,r[23+(5+i.byteLength)+3]=(65280&t.byteLength)>>8,r[23+(5+i.byteLength)+4]=255&t.byteLength,r.set(t,23+(5+i.byteLength)+5),r[23+(5+i.byteLength+5+t.byteLength)+0]=128|Ne.kSlicePPS,r[23+(5+i.byteLength+5+t.byteLength)+1]=0,r[23+(5+i.byteLength+5+t.byteLength)+2]=1,r[23+(5+i.byteLength+5+t.byteLength)+3]=(65280&e.byteLength)>>8,r[23+(5+i.byteLength+5+t.byteLength)+4]=255&e.byteLength,r.set(e,23+(5+i.byteLength+5+t.byteLength)+5)}return n.prototype.getData=function(){return this.data},n}(),Yt=function(){},Xt=function(){},Qt=function(){},$t=[[64,64,80,80,96,96,112,112,128,128,160,160,192,192,224,224,256,256,320,320,384,384,448,448,512,512,640,640,768,768,896,896,1024,1024,1152,1152,1280,1280],[69,70,87,88,104,105,121,122,139,140,174,175,208,209,243,244,278,279,348,349,417,418,487,488,557,558,696,697,835,836,975,976,1114,1115,1253,1254,1393,1394],[96,96,120,120,144,144,168,168,192,192,240,240,288,288,336,336,384,384,480,480,576,576,672,672,768,768,960,960,1152,1152,1344,1344,1536,1536,1728,1728,1920,1920]],Jt=function(){function n(i){this.TAG="AC3Parser",this.data_=i,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&_.default.e(this.TAG,"Could not found AC3 syncword until payload end")}return n.prototype.findNextSyncwordOffset=function(i){for(var t=i,e=this.data_;;){if(t+7>=e.byteLength)return this.eof_flag_=!0,e.byteLength;if((e[t+0]<<8|e[t+1])==2935)return t;t++}},n.prototype.readNextAC3Frame=function(){for(var i=this.data_,t=null;t==null&&!this.eof_flag_;){var e=this.current_syncword_offset_,a=i[e+4]>>6,o=[48000,44200,33000][a],r=63&i[e+4],s=2*$t[a][r];if(isNaN(s)||e+s>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var d=this.findNextSyncwordOffset(e+s);this.current_syncword_offset_=d;var l=i[e+5]>>3,y=7&i[e+5],f=i[e+6]>>5,g=0;1&f&&f!==1&&(g+=2),4&f&&(g+=2),f===2&&(g+=2);var T=(i[e+6]<<8|i[e+7])>>12-g&1,O=[2,1,2,3,3,4,4,5][f]+T;(t=new Qt).sampling_frequency=o,t.channel_count=O,t.channel_mode=f,t.bit_stream_identification=l,t.low_frequency_effects_channel_on=T,t.bit_stream_mode=y,t.frame_size_code=r,t.data=i.subarray(e,e+s)}return t},n.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},n.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},n}(),Zt=function(n){var i;i=[n.sampling_rate_code<<6|n.bit_stream_identification<<1|n.bit_stream_mode>>2,(3&n.bit_stream_mode)<<6|n.channel_mode<<3|n.low_frequency_effects_channel_on<<2|n.frame_size_code>>4,n.frame_size_code<<4&224],this.config=i,this.sampling_rate=n.sampling_frequency,this.bit_stream_identification=n.bit_stream_identification,this.bit_stream_mode=n.bit_stream_mode,this.low_frequency_effects_channel_on=n.low_frequency_effects_channel_on,this.channel_count=n.channel_count,this.channel_mode=n.channel_mode,this.codec_mimetype="ac-3",this.original_codec_mimetype="ac-3"},ei=function(){},ti=function(){function n(i){this.TAG="EAC3Parser",this.data_=i,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&_.default.e(this.TAG,"Could not found AC3 syncword until payload end")}return n.prototype.findNextSyncwordOffset=function(i){for(var t=i,e=this.data_;;){if(t+7>=e.byteLength)return this.eof_flag_=!0,e.byteLength;if((e[t+0]<<8|e[t+1])==2935)return t;t++}},n.prototype.readNextEAC3Frame=function(){for(var i=this.data_,t=null;t==null&&!this.eof_flag_;){var e=this.current_syncword_offset_,a=new A(i.subarray(e+2)),o=(a.readBits(2),a.readBits(3),a.readBits(11)+1<<1),r=a.readBits(2),s=null,d=null;r===3?(s=[24000,22060,16000][r=a.readBits(2)],d=3):(s=[48000,44100,32000][r],d=a.readBits(2));var l=a.readBits(3),y=a.readBits(1),f=a.readBits(5);if(e+o>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var g=this.findNextSyncwordOffset(e+o);this.current_syncword_offset_=g;var T=[2,1,2,3,3,4,4,5][l]+y;a.destroy(),(t=new ei).sampling_frequency=s,t.channel_count=T,t.channel_mode=l,t.bit_stream_identification=f,t.low_frequency_effects_channel_on=y,t.frame_size=o,t.num_blks=[1,2,3,6][d],t.data=i.subarray(e,e+o)}return t},n.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},n.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},n}(),ii=function(n){var i,t=Math.floor(n.frame_size*n.sampling_frequency/(16*n.num_blks));i=[255&t,248&t,n.sampling_rate_code<<6|n.bit_stream_identification<<1,n.channel_mode<<1|n.low_frequency_effects_channel_on,0],this.config=i,this.sampling_rate=n.sampling_frequency,this.bit_stream_identification=n.bit_stream_identification,this.num_blks=n.num_blks,this.low_frequency_effects_channel_on=n.low_frequency_effects_channel_on,this.channel_count=n.channel_count,this.channel_mode=n.channel_mode,this.codec_mimetype="ec-3",this.original_codec_mimetype="ec-3"},ni=function(){},ai=function(){function n(i){this.TAG="AV1OBUInMpegTsParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=i,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&_.default.e(this.TAG,"Could not find AV1 startcode until payload end!")}return n._ebsp2rbsp=function(i){for(var t=i,e=t.byteLength,a=new Uint8Array(e),o=0,r=0;r=2&&t[r]===3&&t[r-1]===0&&t[r-2]===0||(a[o]=t[r],o++);return new Uint8Array(a.buffer,0,o)},n.prototype.findNextStartCodeOffset=function(i){for(var t=i,e=this.data_;;){if(t+2>=e.byteLength)return this.eof_flag_=!0,e.byteLength;if((e[t+0]<<16|e[t+1]<<8|e[t+2])==1)return t;t++}},n.prototype.readNextOBUPayload=function(){for(var i=this.data_,t=null;t==null&&!this.eof_flag_;){var e=this.current_startcode_offset_+3,a=this.findNextStartCodeOffset(e);this.current_startcode_offset_=a,t=n._ebsp2rbsp(i.subarray(e,a))}return t},n}(),ri=function(){},oi=function(){var n=function(i,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o])},n(i,t)};return function(i,t){if(typeof t!="function"&&t!==null)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=i}n(i,t),i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}(),Ke=function(){return Ke=Object.assign||function(n){for(var i,t=1,e=arguments.length;t=4?(_.default.v("TSDemuxer","ts_packet_size = 192, m2ts mode"),a-=4):o===204&&_.default.v("TSDemuxer","ts_packet_size = 204, RS encoded MPEG2-TS stream"),{match:!0,consumed:0,ts_packet_size:o,sync_offset:a})},i.prototype.bindDataSource=function(t){return t.onDataArrival=this.parseChunks.bind(this),this},i.prototype.resetMediaInfo=function(){this.media_info_=new R.default},i.prototype.parseChunks=function(t,e){if(!(this.onError&&this.onMediaInfo&&this.onTrackMetadata&&this.onDataAvailable))throw new M.IllegalStateException("onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var a=0;for(this.first_parse_&&(this.first_parse_=!1,a=this.sync_offset_);a+this.ts_packet_size_<=t.byteLength;){var o=e+a;this.ts_packet_size_===192&&(a+=4);var r=new Uint8Array(t,a,188),s=r[0];if(s!==71){_.default.e(this.TAG,"sync_byte = ".concat(s,", not 0x47"));break}var d=(64&r[1])>>>6,l=(r[1],(31&r[1])<<8|r[2]),y=(48&r[3])>>>4,f=15&r[3],g=!(!this.pmt_||this.pmt_.pcr_pid!==l),T={},O=4;if(y==2||y==3){var F=r[4];if(F>0&&(g||y==3)&&(T.discontinuity_indicator=(128&r[5])>>>7,T.random_access_indicator=(64&r[5])>>>6,T.elementary_stream_priority_indicator=(32&r[5])>>>5,(16&r[5])>>>4)){var q=300*this.getPcrBase(r)+((1&r[10])<<8|r[11]);this.last_pcr_=q}if(y==2||5+F===188){a+=188,this.ts_packet_size_===204&&(a+=16);continue}O=5+F}if(y==1||y==3){if(l===0||l===this.current_pmt_pid_||this.pmt_!=null&&this.pmt_.pid_stream_type[l]===z.kSCTE35){var Z=188-O;this.handleSectionSlice(t,a+O,Z,{pid:l,file_position:o,payload_unit_start_indicator:d,continuity_conunter:f,random_access_indicator:T.random_access_indicator})}else if(this.pmt_!=null&&this.pmt_.pid_stream_type[l]!=null){Z=188-O;var N=this.pmt_.pid_stream_type[l];l!==this.pmt_.common_pids.h264&&l!==this.pmt_.common_pids.h265&&l!==this.pmt_.common_pids.av1&&l!==this.pmt_.common_pids.adts_aac&&l!==this.pmt_.common_pids.loas_aac&&l!==this.pmt_.common_pids.ac3&&l!==this.pmt_.common_pids.eac3&&l!==this.pmt_.common_pids.opus&&l!==this.pmt_.common_pids.mp3&&this.pmt_.pes_private_data_pids[l]!==!0&&this.pmt_.timed_id3_pids[l]!==!0&&this.pmt_.pgs_pids[l]!==!0&&this.pmt_.synchronous_klv_pids[l]!==!0&&this.pmt_.asynchronous_klv_pids[l]!==!0||this.handlePESSlice(t,a+O,Z,{pid:l,stream_type:N,file_position:o,payload_unit_start_indicator:d,continuity_conunter:f,random_access_indicator:T.random_access_indicator})}}a+=188,this.ts_packet_size_===204&&(a+=16)}return this.dispatchAudioVideoMediaSegment(),a},i.prototype.handleSectionSlice=function(t,e,a,o){var r=new Uint8Array(t,e,a),s=this.section_slice_queues_[o.pid];if(o.payload_unit_start_indicator){var d=r[0];if(s!=null&&s.total_length!==0){var l=new Uint8Array(t,e+1,Math.min(a,d));s.slices.push(l),s.total_length+=l.byteLength,s.total_length===s.expected_length?this.emitSectionSlices(s,o):this.clearSlices(s,o)}for(var y=1+d;y=s.expected_length&&this.clearSlices(s,o),y+=l.byteLength}}else s!=null&&s.total_length!==0&&(l=new Uint8Array(t,e,Math.min(a,s.expected_length-s.total_length)),s.slices.push(l),s.total_length+=l.byteLength,s.total_length===s.expected_length?this.emitSectionSlices(s,o):s.total_length>=s.expected_length&&this.clearSlices(s,o))},i.prototype.handlePESSlice=function(t,e,a,o){var r=new Uint8Array(t,e,a),s=r[0]<<16|r[1]<<8|r[2],d=(r[3],r[4]<<8|r[5]);if(o.payload_unit_start_indicator){if(s!==1)return void _.default.e(this.TAG,"handlePESSlice: packet_start_code_prefix should be 1 but with value ".concat(s));var l=this.pes_slice_queues_[o.pid];l&&(l.expected_length===0||l.expected_length===l.total_length?this.emitPESSlices(l,o):this.clearSlices(l,o)),this.pes_slice_queues_[o.pid]=new k,this.pes_slice_queues_[o.pid].file_position=o.file_position,this.pes_slice_queues_[o.pid].random_access_indicator=o.random_access_indicator}if(this.pes_slice_queues_[o.pid]!=null){var y=this.pes_slice_queues_[o.pid];y.slices.push(r),o.payload_unit_start_indicator&&(y.expected_length=d===0?0:d+6),y.total_length+=r.byteLength,y.expected_length>0&&y.expected_length===y.total_length?this.emitPESSlices(y,o):y.expected_length>0&&y.expected_length>>6,d=e[8],l=void 0,y=void 0;s!==2&&s!==3||(l=this.getTimestamp(e,9),y=s===3?this.getTimestamp(e,14):l);var f=9+d,g=void 0;if(r!==0){if(r<3+d)return void _.default.v(this.TAG,"Malformed PES: PES_packet_length < 3 + PES_header_data_length");g=r-3-d}else g=e.byteLength-f;var T=e.subarray(f,f+g);switch(t.stream_type){case z.kMPEG1Audio:case z.kMPEG2Audio:this.parseMP3Payload(T,l);break;case z.kPESPrivateData:this.pmt_.common_pids.av1===t.pid?this.parseAV1Payload(T,l,y,t.file_position,t.random_access_indicator):this.pmt_.common_pids.opus===t.pid?this.parseOpusPayload(T,l):this.pmt_.common_pids.ac3===t.pid?this.parseAC3Payload(T,l):this.pmt_.common_pids.eac3===t.pid?this.parseEAC3Payload(T,l):this.pmt_.asynchronous_klv_pids[t.pid]?this.parseAsynchronousKLVMetadataPayload(T,t.pid,o):this.pmt_.smpte2038_pids[t.pid]?this.parseSMPTE2038MetadataPayload(T,l,y,t.pid,o):this.parsePESPrivateDataPayload(T,l,y,t.pid,o);break;case z.kADTSAAC:this.parseADTSAACPayload(T,l);break;case z.kLOASAAC:this.parseLOASAACPayload(T,l);break;case z.kAC3:this.parseAC3Payload(T,l);break;case z.kEAC3:this.parseEAC3Payload(T,l);break;case z.kMetadata:this.pmt_.timed_id3_pids[t.pid]?this.parseTimedID3MetadataPayload(T,l,y,t.pid,o):this.pmt_.synchronous_klv_pids[t.pid]&&this.parseSynchronousKLVMetadataPayload(T,l,y,t.pid,o);break;case z.kPGS:this.parsePGSPayload(T,l,y,t.pid,o,this.pmt_.pgs_langs[t.pid]);break;case z.kH264:this.parseH264Payload(T,l,y,t.file_position,t.random_access_indicator);break;case z.kH265:this.parseH265Payload(T,l,y,t.file_position,t.random_access_indicator)}}else o!==188&&o!==191&&o!==240&&o!==241&&o!==255&&o!==242&&o!==248||t.stream_type!==z.kPESPrivateData||(f=6,g=void 0,g=r!==0?r:e.byteLength-f,T=e.subarray(f,f+g),this.parsePESPrivateDataPayload(T,void 0,void 0,t.pid,o));else _.default.e(this.TAG,"parsePES: packet_start_code_prefix should be 1 but with value ".concat(a))},i.prototype.parsePAT=function(t){var e=t[0];if(e===0){var a=(15&t[1])<<8|t[2],o=(t[3],t[4],(62&t[5])>>>1),r=1&t[5],s=t[6],d=(t[7],null);if(r===1&&s===0)(d=new te).version_number=o;else if((d=this.pat_)==null)return;for(var l=a-5-4,y=-1,f=-1,g=8;g<8+l;g+=4){var T=t[g]<<8|t[g+1],O=(31&t[g+2])<<8|t[g+3];T===0?d.network_pid=O:(d.program_pmt_pid[T]=O,y===-1&&(y=T),f===-1&&(f=O))}r===1&&s===0&&(this.pat_==null&&_.default.v(this.TAG,"Parsed first PAT: ".concat(JSON.stringify(d))),this.pat_=d,this.current_program_=y,this.current_pmt_pid_=f)}else _.default.e(this.TAG,"parsePAT: table_id ".concat(e," is not corresponded to PAT!"))},i.prototype.parsePMT=function(t){var e=t[0];if(e===2){var a=(15&t[1])<<8|t[2],o=t[3]<<8|t[4],r=(62&t[5])>>>1,s=1&t[5],d=t[6],l=(t[7],null);if(s===1&&d===0)(l=new Re).program_number=o,l.version_number=r,this.program_pmt_map_[o]=l;else if((l=this.program_pmt_map_[o])==null)return;l.pcr_pid=(31&t[8])<<8|t[9];for(var y=(15&t[10])<<8|t[11],f=12+y,g=a-9-y-4,T=f;T0){for(var H=T+5;H0)for(H=T+5;H0)for(H=T+5;H1&&(_.default.w(this.TAG,"AAC: Detected pts overlapped, "+"expected: ".concat(s,"ms, PES pts: ").concat(r,"ms")),r=s)}}for(var d,l=new Ue(t),y=null,f=r;(y=l.readNextAACFrame())!=null;){o=1024/y.sampling_frequency*1000;var g={codec:"aac",data:y};this.audio_init_segment_dispatched_==0?(this.audio_metadata_={codec:"aac",audio_object_type:y.audio_object_type,sampling_freq_index:y.sampling_freq_index,sampling_frequency:y.sampling_frequency,channel_config:y.channel_config},this.dispatchAudioInitSegment(g)):this.detectAudioMetadataChange(g)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(g)),d=f;var T=Math.floor(f),O={unit:y.data,length:y.data.byteLength,pts:T,dts:T};this.audio_track_.samples.push(O),this.audio_track_.length+=y.data.byteLength,f+=o}l.hasIncompleteData()&&(this.aac_last_incomplete_data_=l.getIncompleteData()),d&&(this.audio_last_sample_pts_=d)}},i.prototype.parseLOASAACPayload=function(t,e){var a;if(!this.has_video_||this.video_init_segment_dispatched_){if(this.aac_last_incomplete_data_){var o=new Uint8Array(t.byteLength+this.aac_last_incomplete_data_.byteLength);o.set(this.aac_last_incomplete_data_,0),o.set(t,this.aac_last_incomplete_data_.byteLength),t=o}var r,s;if(e!=null&&(s=e/this.timescale_),this.audio_metadata_.codec==="aac"){if(e==null&&this.audio_last_sample_pts_!=null)r=1024/this.audio_metadata_.sampling_frequency*1000,s=this.audio_last_sample_pts_+r;else if(e==null)return void _.default.w(this.TAG,"AAC: Unknown pts");if(this.aac_last_incomplete_data_&&this.audio_last_sample_pts_){r=1024/this.audio_metadata_.sampling_frequency*1000;var d=this.audio_last_sample_pts_+r;Math.abs(d-s)>1&&(_.default.w(this.TAG,"AAC: Detected pts overlapped, "+"expected: ".concat(d,"ms, PES pts: ").concat(s,"ms")),s=d)}}for(var l,y=new je(t),f=null,g=s;(f=y.readNextAACFrame((a=this.loas_previous_frame)!==null&&a!==void 0?a:void 0))!=null;){this.loas_previous_frame=f,r=1024/f.sampling_frequency*1000;var T={codec:"aac",data:f};this.audio_init_segment_dispatched_==0?(this.audio_metadata_={codec:"aac",audio_object_type:f.audio_object_type,sampling_freq_index:f.sampling_freq_index,sampling_frequency:f.sampling_frequency,channel_config:f.channel_config},this.dispatchAudioInitSegment(T)):this.detectAudioMetadataChange(T)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(T)),l=g;var O=Math.floor(g),F={unit:f.data,length:f.data.byteLength,pts:O,dts:O};this.audio_track_.samples.push(F),this.audio_track_.length+=f.data.byteLength,g+=r}y.hasIncompleteData()&&(this.aac_last_incomplete_data_=y.getIncompleteData()),l&&(this.audio_last_sample_pts_=l)}},i.prototype.parseAC3Payload=function(t,e){if(!this.has_video_||this.video_init_segment_dispatched_){var a,o;if(e!=null&&(o=e/this.timescale_),this.audio_metadata_.codec==="ac-3"){if(e==null&&this.audio_last_sample_pts_!=null)a=1536/this.audio_metadata_.sampling_frequency*1000,o=this.audio_last_sample_pts_+a;else if(e==null)return void _.default.w(this.TAG,"AC3: Unknown pts")}for(var r,s=new Jt(t),d=null,l=o;(d=s.readNextAC3Frame())!=null;){a=1536/d.sampling_frequency*1000;var y={codec:"ac-3",data:d};this.audio_init_segment_dispatched_==0?(this.audio_metadata_={codec:"ac-3",sampling_frequency:d.sampling_frequency,bit_stream_identification:d.bit_stream_identification,bit_stream_mode:d.bit_stream_mode,low_frequency_effects_channel_on:d.low_frequency_effects_channel_on,channel_mode:d.channel_mode},this.dispatchAudioInitSegment(y)):this.detectAudioMetadataChange(y)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(y)),r=l;var f=Math.floor(l),g={unit:d.data,length:d.data.byteLength,pts:f,dts:f};this.audio_track_.samples.push(g),this.audio_track_.length+=d.data.byteLength,l+=a}r&&(this.audio_last_sample_pts_=r)}},i.prototype.parseEAC3Payload=function(t,e){if(!this.has_video_||this.video_init_segment_dispatched_){var a,o;if(e!=null&&(o=e/this.timescale_),this.audio_metadata_.codec==="ec-3"){if(e==null&&this.audio_last_sample_pts_!=null)a=256*this.audio_metadata_.num_blks/this.audio_metadata_.sampling_frequency*1000,o=this.audio_last_sample_pts_+a;else if(e==null)return void _.default.w(this.TAG,"EAC3: Unknown pts")}for(var r,s=new ti(t),d=null,l=o;(d=s.readNextEAC3Frame())!=null;){a=1536/d.sampling_frequency*1000;var y={codec:"ec-3",data:d};this.audio_init_segment_dispatched_==0?(this.audio_metadata_={codec:"ec-3",sampling_frequency:d.sampling_frequency,bit_stream_identification:d.bit_stream_identification,low_frequency_effects_channel_on:d.low_frequency_effects_channel_on,num_blks:d.num_blks,channel_mode:d.channel_mode},this.dispatchAudioInitSegment(y)):this.detectAudioMetadataChange(y)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(y)),r=l;var f=Math.floor(l),g={unit:d.data,length:d.data.byteLength,pts:f,dts:f};this.audio_track_.samples.push(g),this.audio_track_.length+=d.data.byteLength,l+=a}r&&(this.audio_last_sample_pts_=r)}},i.prototype.parseOpusPayload=function(t,e){if(!this.has_video_||this.video_init_segment_dispatched_){var a,o;if(e!=null&&(o=e/this.timescale_),this.audio_metadata_.codec==="opus"){if(e==null&&this.audio_last_sample_pts_!=null)a=20,o=this.audio_last_sample_pts_+a;else if(e==null)return void _.default.w(this.TAG,"Opus: Unknown pts")}for(var r,s=o,d=0;d>>3&3,o=(6&t[1])>>1,r=(t[2],(12&t[2])>>>2),s=3&~(t[3]>>>6)?2:1,d=0,l=34;switch(a){case 0:d=[11025,12000,8000,0][r];break;case 2:d=[22050,24000,16000,0][r];break;case 3:d=[44100,48000,32000,0][r]}switch(o){case 1:l=34;break;case 2:l=33;break;case 3:l=32}var y=new Xt;y.object_type=l,y.sample_rate=d,y.channel_count=s,y.data=t;var f={codec:"mp3",data:y};this.audio_init_segment_dispatched_==0?(this.audio_metadata_={codec:"mp3",object_type:l,sample_rate:d,channel_count:s},this.dispatchAudioInitSegment(f)):this.detectAudioMetadataChange(f)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(f));var g={unit:t,length:t.byteLength,pts:e/this.timescale_,dts:e/this.timescale_};this.audio_track_.samples.push(g),this.audio_track_.length+=t.byteLength}},i.prototype.detectAudioMetadataChange=function(t){if(t.codec!==this.audio_metadata_.codec)return _.default.v(this.TAG,"Audio: Audio Codecs changed from "+"".concat(this.audio_metadata_.codec," to ").concat(t.codec)),!0;if(t.codec==="aac"&&this.audio_metadata_.codec==="aac"){if((e=t.data).audio_object_type!==this.audio_metadata_.audio_object_type)return _.default.v(this.TAG,"AAC: AudioObjectType changed from "+"".concat(this.audio_metadata_.audio_object_type," to ").concat(e.audio_object_type)),!0;if(e.sampling_freq_index!==this.audio_metadata_.sampling_freq_index)return _.default.v(this.TAG,"AAC: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sampling_freq_index," to ").concat(e.sampling_freq_index)),!0;if(e.channel_config!==this.audio_metadata_.channel_config)return _.default.v(this.TAG,"AAC: Channel configuration changed from "+"".concat(this.audio_metadata_.channel_config," to ").concat(e.channel_config)),!0}else if(t.codec==="ac-3"&&this.audio_metadata_.codec==="ac-3"){var e;if((e=t.data).sampling_frequency!==this.audio_metadata_.sampling_frequency)return _.default.v(this.TAG,"AC3: Sampling Frequency changed from "+"".concat(this.audio_metadata_.sampling_frequency," to ").concat(e.sampling_frequency)),!0;if(e.bit_stream_identification!==this.audio_metadata_.bit_stream_identification)return _.default.v(this.TAG,"AC3: Bit Stream Identification changed from "+"".concat(this.audio_metadata_.bit_stream_identification," to ").concat(e.bit_stream_identification)),!0;if(e.bit_stream_mode!==this.audio_metadata_.bit_stream_mode)return _.default.v(this.TAG,"AC3: BitStream Mode changed from "+"".concat(this.audio_metadata_.bit_stream_mode," to ").concat(e.bit_stream_mode)),!0;if(e.channel_mode!==this.audio_metadata_.channel_mode)return _.default.v(this.TAG,"AC3: Channel Mode changed from "+"".concat(this.audio_metadata_.channel_mode," to ").concat(e.channel_mode)),!0;if(e.low_frequency_effects_channel_on!==this.audio_metadata_.low_frequency_effects_channel_on)return _.default.v(this.TAG,"AC3: Low Frequency Effects Channel On changed from "+"".concat(this.audio_metadata_.low_frequency_effects_channel_on," to ").concat(e.low_frequency_effects_channel_on)),!0}else if(t.codec==="opus"&&this.audio_metadata_.codec==="opus"){if((a=t.meta).sample_rate!==this.audio_metadata_.sample_rate)return _.default.v(this.TAG,"Opus: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sample_rate," to ").concat(a.sample_rate)),!0;if(a.channel_count!==this.audio_metadata_.channel_count)return _.default.v(this.TAG,"Opus: Channel count changed from "+"".concat(this.audio_metadata_.channel_count," to ").concat(a.channel_count)),!0}else if(t.codec==="mp3"&&this.audio_metadata_.codec==="mp3"){var a;if((a=t.data).object_type!==this.audio_metadata_.object_type)return _.default.v(this.TAG,"MP3: AudioObjectType changed from "+"".concat(this.audio_metadata_.object_type," to ").concat(a.object_type)),!0;if(a.sample_rate!==this.audio_metadata_.sample_rate)return _.default.v(this.TAG,"MP3: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sample_rate," to ").concat(a.sample_rate)),!0;if(a.channel_count!==this.audio_metadata_.channel_count)return _.default.v(this.TAG,"MP3: Channel count changed from "+"".concat(this.audio_metadata_.channel_count," to ").concat(a.channel_count)),!0}return!1},i.prototype.dispatchAudioInitSegment=function(t){var e={type:"audio"};if(e.id=this.audio_track_.id,e.timescale=1000,e.duration=this.duration_,this.audio_metadata_.codec==="aac"){var a=t.codec==="aac"?t.data:null,o=new Fe(a);e.audioSampleRate=o.sampling_rate,e.channelCount=o.channel_count,e.codec=o.codec_mimetype,e.originalCodec=o.original_codec_mimetype,e.config=o.config,e.refSampleDuration=1024/e.audioSampleRate*e.timescale}else if(this.audio_metadata_.codec==="ac-3"){var r=t.codec==="ac-3"?t.data:null,s=new Zt(r);e.audioSampleRate=s.sampling_rate,e.channelCount=s.channel_count,e.codec=s.codec_mimetype,e.originalCodec=s.original_codec_mimetype,e.config=s.config,e.refSampleDuration=1536/e.audioSampleRate*e.timescale}else if(this.audio_metadata_.codec==="ec-3"){var d=t.codec==="ec-3"?t.data:null,l=new ii(d);e.audioSampleRate=l.sampling_rate,e.channelCount=l.channel_count,e.codec=l.codec_mimetype,e.originalCodec=l.original_codec_mimetype,e.config=l.config,e.refSampleDuration=256*l.num_blks/e.audioSampleRate*e.timescale}else this.audio_metadata_.codec==="opus"?(e.audioSampleRate=this.audio_metadata_.sample_rate,e.channelCount=this.audio_metadata_.channel_count,e.channelConfigCode=this.audio_metadata_.channel_config_code,e.codec="opus",e.originalCodec="opus",e.config=void 0,e.refSampleDuration=20):this.audio_metadata_.codec==="mp3"&&(e.audioSampleRate=this.audio_metadata_.sample_rate,e.channelCount=this.audio_metadata_.channel_count,e.codec="mp3",e.originalCodec="mp3",e.config=void 0);this.audio_init_segment_dispatched_==0&&_.default.v(this.TAG,"Generated first AudioSpecificConfig for mimeType: ".concat(e.codec)),this.onTrackMetadata("audio",e),this.audio_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var y=this.media_info_;y.hasAudio=!0,y.audioCodec=e.originalCodec,y.audioSampleRate=e.audioSampleRate,y.audioChannelCount=e.channelCount,y.hasVideo&&y.videoCodec?y.mimeType='video/mp2t; codecs="'.concat(y.videoCodec,",").concat(y.audioCodec,'"'):y.mimeType='video/mp2t; codecs="'.concat(y.audioCodec,'"'),y.isComplete()&&this.onMediaInfo(y)},i.prototype.dispatchPESPrivateDataDescriptor=function(t,e,a){var o=new nt;o.pid=t,o.stream_type=e,o.descriptor=a,this.onPESPrivateDataDescriptor&&this.onPESPrivateDataDescriptor(o)},i.prototype.parsePESPrivateDataPayload=function(t,e,a,o,r){var s=new Xe;if(s.pid=o,s.stream_id=r,s.len=t.byteLength,s.data=t,e!=null){var d=Math.floor(e/this.timescale_);s.pts=d}else s.nearest_pts=this.getNearestTimestampMilliseconds();if(a!=null){var l=Math.floor(a/this.timescale_);s.dts=l}this.onPESPrivateData&&this.onPESPrivateData(s)},i.prototype.parseTimedID3MetadataPayload=function(t,e,a,o,r){var s=new Xe;if(s.pid=o,s.stream_id=r,s.len=t.byteLength,s.data=t,e!=null){var d=Math.floor(e/this.timescale_);s.pts=d}if(a!=null){var l=Math.floor(a/this.timescale_);s.dts=l}this.onTimedID3Metadata&&this.onTimedID3Metadata(s)},i.prototype.parsePGSPayload=function(t,e,a,o,r,s){var d=new ri;if(d.pid=o,d.lang=s,d.stream_id=r,d.len=t.byteLength,d.data=t,e!=null){var l=Math.floor(e/this.timescale_);d.pts=l}if(a!=null){var y=Math.floor(a/this.timescale_);d.dts=y}this.onPGSSubtitleData&&this.onPGSSubtitleData(d)},i.prototype.parseSynchronousKLVMetadataPayload=function(t,e,a,o,r){var s=new ni;if(s.pid=o,s.stream_id=r,s.len=t.byteLength,s.data=t,e!=null){var d=Math.floor(e/this.timescale_);s.pts=d}if(a!=null){var l=Math.floor(a/this.timescale_);s.dts=l}s.access_units=function(y){for(var f=[],g=0;g+5>>24&255,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=255&t,e.set(i,4);var s=8;for(r=0;r>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t,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]))},n.trak=function(i){return n.box(n.types.trak,n.tkhd(i),n.mdia(i))},n.tkhd=function(i){var{id:t,duration:e,presentWidth:a,presentHeight:o}=i;return n.box(n.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>>8&255,255&a,0,0,o>>>8&255,255&o,0,0]))},n.mdia=function(i){return n.box(n.types.mdia,n.mdhd(i),n.hdlr(i),n.minf(i))},n.mdhd=function(i){var{timescale:t,duration:e}=i;return n.box(n.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,85,196,0,0]))},n.hdlr=function(i){var t;return t=i.type==="audio"?n.constants.HDLR_AUDIO:n.constants.HDLR_VIDEO,n.box(n.types.hdlr,t)},n.minf=function(i){var t;return t=i.type==="audio"?n.box(n.types.smhd,n.constants.SMHD):n.box(n.types.vmhd,n.constants.VMHD),n.box(n.types.minf,t,n.dinf(),n.stbl(i))},n.dinf=function(){return n.box(n.types.dinf,n.box(n.types.dref,n.constants.DREF))},n.stbl=function(i){return n.box(n.types.stbl,n.stsd(i),n.box(n.types.stts,n.constants.STTS),n.box(n.types.stsc,n.constants.STSC),n.box(n.types.stsz,n.constants.STSZ),n.box(n.types.stco,n.constants.STCO))},n.stsd=function(i){return i.type==="audio"?i.codec==="mp3"?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.mp3(i)):i.codec==="ac-3"?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.ac3(i)):i.codec==="ec-3"?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.ec3(i)):i.codec==="opus"?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.Opus(i)):i.codec=="flac"?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.fLaC(i)):i.codec=="ipcm"?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.ipcm(i)):n.box(n.types.stsd,n.constants.STSD_PREFIX,n.mp4a(i)):i.type==="video"&&i.codec.startsWith("hvc1")?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.hvc1(i)):i.type==="video"&&i.codec.startsWith("av01")?n.box(n.types.stsd,n.constants.STSD_PREFIX,n.av01(i)):n.box(n.types.stsd,n.constants.STSD_PREFIX,n.avc1(i))},n.mp3=function(i){var{channelCount:t,audioSampleRate:e}=i,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>>8&255,255&e,0,0]);return n.box(n.types[".mp3"],a)},n.mp4a=function(i){var{channelCount:t,audioSampleRate:e}=i,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>>8&255,255&e,0,0]);return n.box(n.types.mp4a,a,n.esds(i))},n.ac3=function(i){var{channelCount:t,audioSampleRate:e}=i,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>>8&255,255&e,0,0]);return n.box(n.types["ac-3"],a,n.box(n.types.dac3,new Uint8Array(i.config)))},n.ec3=function(i){var{channelCount:t,audioSampleRate:e}=i,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>>8&255,255&e,0,0]);return n.box(n.types["ec-3"],a,n.box(n.types.dec3,new Uint8Array(i.config)))},n.esds=function(i){var t=i.config||[],e=t.length,a=new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t).concat([6,1,2]));return n.box(n.types.esds,a)},n.Opus=function(i){var{channelCount:t,audioSampleRate:e}=i,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>>8&255,255&e,0,0]);return n.box(n.types.Opus,a,n.dOps(i))},n.dOps=function(i){var{channelCount:t,channelConfigCode:e,audioSampleRate:a}=i;if(i.config)return n.box(n.types.dOps,i.config);var o=[];switch(e){case 1:case 2:o=[0];break;case 0:o=[255,1,1,0,1];break;case 128:o=[255,2,0,0,1];break;case 3:o=[1,2,1,0,2,1];break;case 4:o=[1,2,2,0,1,2,3];break;case 5:o=[1,3,2,0,4,1,2,3];break;case 6:o=[1,4,2,0,4,1,2,3,5];break;case 7:o=[1,4,2,0,4,1,2,3,5,6];break;case 8:o=[1,5,3,0,6,1,2,3,4,5,7];break;case 130:o=[1,1,2,0,1];break;case 131:o=[1,1,3,0,1,2];break;case 132:o=[1,1,4,0,1,2,3];break;case 133:o=[1,1,5,0,1,2,3,4];break;case 134:o=[1,1,6,0,1,2,3,4,5];break;case 135:o=[1,1,7,0,1,2,3,4,5,6];break;case 136:o=[1,1,8,0,1,2,3,4,5,6,7]}var r=new Uint8Array(pt([0,t,0,0,a>>>24&255,a>>>17&255,a>>>8&255,a>>>0&255,0,0],o,!0));return n.box(n.types.dOps,r)},n.fLaC=function(i){var t=i.channelCount,e=Math.min(i.audioSampleRate,65535),a=i.sampleSize,o=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,a,0,0,0,0,e>>>8&255,255&e,0,0]);return n.box(n.types.fLaC,o,n.dfLa(i))},n.dfLa=function(i){var t=new Uint8Array(pt([0,0,0,0],i.config,!0));return n.box(n.types.dfLa,t)},n.ipcm=function(i){var t=i.channelCount,e=Math.min(i.audioSampleRate,65535),a=i.sampleSize,o=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,a,0,0,0,0,e>>>8&255,255&e,0,0]);return i.channelCount===1?n.box(n.types.ipcm,o,n.pcmC(i)):n.box(n.types.ipcm,o,n.chnl(i),n.pcmC(i))},n.chnl=function(i){var t=new Uint8Array([0,0,0,0,1,i.channelCount,0,0,0,0,0,0,0,0]);return n.box(n.types.chnl,t)},n.pcmC=function(i){var t=i.littleEndian?1:0,e=i.sampleSize,a=new Uint8Array([0,0,0,0,t,e]);return n.box(n.types.pcmC,a)},n.avc1=function(i){var{avcc:t,codecWidth:e,codecHeight:a}=i,o=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,e>>>8&255,255&e,a>>>8&255,255&a,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return n.box(n.types.avc1,o,n.box(n.types.avcC,t))},n.hvc1=function(i){var{hvcc:t,codecWidth:e,codecHeight:a}=i,o=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,e>>>8&255,255&e,a>>>8&255,255&a,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return n.box(n.types.hvc1,o,n.box(n.types.hvcC,t))},n.av01=function(i){var t=i.av1c,e=i.codecWidth||192,a=i.codecHeight||108,o=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,e>>>8&255,255&e,a>>>8&255,255&a,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return n.box(n.types.av01,o,n.box(n.types.av1C,t))},n.mvex=function(i){return n.box(n.types.mvex,n.trex(i))},n.trex=function(i){var t=i.id,e=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.box(n.types.trex,e)},n.moof=function(i,t){return n.box(n.types.moof,n.mfhd(i.sequenceNumber),n.traf(i,t))},n.mfhd=function(i){var t=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i]);return n.box(n.types.mfhd,t)},n.traf=function(i,t){var e=i.id,a=n.box(n.types.tfhd,new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e])),o=n.box(n.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),r=n.sdtp(i),s=n.trun(i,r.byteLength+16+16+8+16+8+8);return n.box(n.types.traf,a,o,s,r)},n.sdtp=function(i){for(var t=i.samples||[],e=t.length,a=new Uint8Array(4+e),o=0;o>>24&255,a>>>16&255,a>>>8&255,255&a,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(var s=0;s>>24&255,d>>>16&255,d>>>8&255,255&d,l>>>24&255,l>>>16&255,l>>>8&255,255&l,y.isLeading<<2|y.dependsOn,y.isDependedOn<<6|y.hasRedundancy<<4|y.isNonSync,0,0,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s)}return n.box(n.types.trun,r)},n.mdat=function(i){return n.box(n.types.mdat,i)},n}();mt.init();var We=mt,gt=function(){function n(){}return n.getSilentFrame=function(i,t){if(i==="mp4a.40.2"){if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},n}(),ze=D(47),yt=function(){function n(i){this.TAG="MP4Remuxer",this._config=i,this._isLive=i.isLive===!0,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new ze.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new ze.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!S.default.chrome||!(S.default.version.major<50||S.default.version.major===50&&S.default.version.build<2661)),this._fillSilentAfterSeek=S.default.msedge||S.default.msie,this._mp3UseMpegAudio=!S.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return n.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},n.prototype.bindDataSource=function(i){return i.onDataAvailable=this.remux.bind(this),i.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(n.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(i){this._onInitSegment=i},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(i){this._onMediaSegment=i},enumerable:!1,configurable:!0}),n.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},n.prototype.seek=function(i){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},n.prototype.remux=function(i,t){if(!this._onMediaSegment)throw new M.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(i,t),t&&this._remuxVideo(t),i&&this._remuxAudio(i)},n.prototype._onTrackMetadataReceived=function(i,t){var e=null,a="mp4",o=t.codec;if(i==="audio")this._audioMeta=t,t.codec==="mp3"&&this._mp3UseMpegAudio?(a="mpeg",o="",e=new Uint8Array):e=We.generateInitSegment(t);else{if(i!=="video")return;this._videoMeta=t,e=We.generateInitSegment(t)}if(!this._onInitSegment)throw new M.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(i,{type:i,data:e.buffer,codec:o,container:"".concat(i,"/").concat(a),mediaDuration:t.duration})},n.prototype._calculateDtsBase=function(i,t){this._dtsBaseInited||(i&&i.samples&&i.samples.length&&(this._audioDtsBase=i.samples[0].dts),t&&t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},n.prototype.getTimestampBase=function(){if(this._dtsBaseInited)return this._dtsBase},n.prototype.flushStashedSamples=function(){var i=this._videoStashedLastSample,t=this._audioStashedLastSample,e={type:"video",id:1,sequenceNumber:0,samples:[],length:0};i!=null&&(e.samples.push(i),e.length=i.length);var a={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};t!=null&&(a.samples.push(t),a.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(e,!0),this._remuxAudio(a,!0)},n.prototype._remuxAudio=function(i,t){if(this._audioMeta!=null){var e,a=i,o=a.samples,r=void 0,s=-1,d=this._audioMeta.refSampleDuration,l=this._audioMeta.codec==="mp3"&&this._mp3UseMpegAudio,y=this._dtsBaseInited&&this._audioNextDts===void 0,f=!1;if(o&&o.length!==0&&(o.length!==1||t)){var g=0,T=null,O=0;l?(g=0,O=a.length):(g=8,O=8+a.length);var F=null;if(o.length>1&&(O-=(F=o.pop()).length),this._audioStashedLastSample!=null){var q=this._audioStashedLastSample;this._audioStashedLastSample=null,o.unshift(q),O+=q.length}F!=null&&(this._audioStashedLastSample=F);var Z=o[0].dts-this._dtsBase;if(this._audioNextDts)r=Z-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())r=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(f=!0);else{var N=this._audioSegmentInfoList.getLastSampleBefore(Z);if(N!=null){var H=Z-(N.originalDts+N.duration);H<=3&&(H=0),r=Z-(N.dts+N.duration+H)}else r=0}if(f){var he=Z-r,ve=this._videoSegmentInfoList.getLastSegmentBefore(Z);if(ve!=null&&ve.beginDts=3*d&&this._fillAudioTimestampGap){Ce=!0;var Ae,Be=Math.floor(r/d);_.default.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync. `+"originalDts: ".concat(Se," ms, curRefDts: ").concat(pe," ms, ")+"dtsCorrection: ".concat(Math.round(r)," ms, generate: ").concat(Be," frames")),ne=Math.floor(pe),Te=Math.floor(pe+d)-ne,(Ae=gt.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount))==null&&(_.default.w(this.TAG,"Unable to generate silent frame for "+"".concat(this._audioMeta.originalCodec," with ").concat(this._audioMeta.channelCount," channels, repeat last frame")),Ae=De),we=[];for(var ye=0;ye=1?ge[ge.length-1].duration:Math.floor(d),this._audioNextDts=ne+Te;s===-1&&(s=ne),ge.push({dts:ne,pts:ne,cts:0,unit:q.unit,size:q.unit.byteLength,duration:Te,originalDts:Se,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),Ce&&ge.push.apply(ge,we)}}if(ge.length===0)return a.samples=[],void(a.length=0);for(l?T=new Uint8Array(O):((T=new Uint8Array(O))[0]=O>>>24&255,T[1]=O>>>16&255,T[2]=O>>>8&255,T[3]=255&O,T.set(We.types.mdat,4)),ce=0;ce1&&(g-=(T=r.pop()).length),this._videoStashedLastSample!=null){var O=this._videoStashedLastSample;this._videoStashedLastSample=null,r.unshift(O),g+=O.length}T!=null&&(this._videoStashedLastSample=T);var F=r[0].dts-this._dtsBase;if(this._videoNextDts)s=F-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())s=0;else{var q=this._videoSegmentInfoList.getLastSampleBefore(F);if(q!=null){var Z=F-(q.originalDts+q.duration);Z<=3&&(Z=0),s=F-(q.dts+q.duration+Z)}else s=0}for(var N=new ze.MediaSegmentInfo,H=[],he=0;he=1?H[H.length-1].duration:Math.floor(this._videoMeta.refSampleDuration),ne){var Se=new ze.SampleInfo(ae,ce,De,O.dts,!0);Se.fileposition=O.fileposition,N.appendSyncPoint(Se)}H.push({dts:ae,pts:ce,cts:ge,units:O.units,size:O.length,isKeyframe:ne,duration:De,originalDts:ve,flags:{isLeading:0,dependsOn:ne?2:1,isDependedOn:ne?1:0,hasRedundancy:0,isNonSync:ne?0:1}})}for((f=new Uint8Array(g))[0]=g>>>24&255,f[1]=g>>>16&255,f[2]=g>>>8&255,f[3]=255&g,f.set(We.types.mdat,4),he=0;he0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,a=this._demuxer.parseChunks(i,t);else{var o=null;(o=le.probe(i)).match&&(this._setupFLVDemuxerRemuxer(o),a=this._demuxer.parseChunks(i,t)),o.match||o.needMoreData||(o=ft.probe(i)).match&&(this._setupTSDemuxerRemuxer(o),a=this._demuxer.parseChunks(i,t)),o.match||o.needMoreData||(o=null,_.default.e(this.TAG,"Non MPEG-TS/FLV, Unsupported media type!"),Promise.resolve().then(function(){e._internalAbort()}),this._emitter.emit(Ie.default.DEMUX_ERROR,m.default.FORMAT_UNSUPPORTED,"Non MPEG-TS/FLV, Unsupported media type!"))}return a},n.prototype._setupFLVDemuxerRemuxer=function(i){this._demuxer=new le(i,this._config),this._remuxer||(this._remuxer=new yt(this._config));var t=this._mediaDataSource;t.duration==null||isNaN(t.duration)||(this._demuxer.overridedDuration=t.duration),typeof t.hasAudio=="boolean"&&(this._demuxer.overridedHasAudio=t.hasAudio),typeof t.hasVideo=="boolean"&&(this._demuxer.overridedHasVideo=t.hasVideo),this._demuxer.timestampBase=t.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._demuxer.onSeiArrived=this._onSEI.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this)},n.prototype._setupTSDemuxerRemuxer=function(i){var t=this._demuxer=new ft(i,this._config);this._remuxer||(this._remuxer=new yt(this._config)),t.onError=this._onDemuxException.bind(this),t.onMediaInfo=this._onMediaInfo.bind(this),t.onMetaDataArrived=this._onMetaDataArrived.bind(this),t.onTimedID3Metadata=this._onTimedID3Metadata.bind(this),t.onPGSSubtitleData=this._onPGSSubtitle.bind(this),t.onSynchronousKLVMetadata=this._onSynchronousKLVMetadata.bind(this),t.onAsynchronousKLVMetadata=this._onAsynchronousKLVMetadata.bind(this),t.onSMPTE2038Metadata=this._onSMPTE2038Metadata.bind(this),t.onSEI=this._onSEI.bind(this),t.onSCTE35Metadata=this._onSCTE35Metadata.bind(this),t.onPESPrivateDataDescriptor=this._onPESPrivateDataDescriptor.bind(this),t.onPESPrivateData=this._onPESPrivateData.bind(this),this._remuxer.bindDataSource(this._demuxer),this._demuxer.bindDataSource(this._ioctl),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this)},n.prototype._onMediaInfo=function(i){var t=this;this._mediaInfo==null&&(this._mediaInfo=Object.assign({},i),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,R.default.prototype));var e=Object.assign({},i);Object.setPrototypeOf(e,R.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=e,this._reportSegmentMediaInfo(this._currentSegmentIndex),this._pendingSeekTime!=null&&Promise.resolve().then(function(){var a=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(a)})},n.prototype._onMetaDataArrived=function(i){this._emitter.emit(Ie.default.METADATA_ARRIVED,i)},n.prototype._onScriptDataArrived=function(i){this._emitter.emit(Ie.default.SCRIPTDATA_ARRIVED,i)},n.prototype._onTimedID3Metadata=function(i){var t=this._remuxer.getTimestampBase();t!=null&&(i.pts!=null&&(i.pts-=t),i.dts!=null&&(i.dts-=t),this._emitter.emit(Ie.default.TIMED_ID3_METADATA_ARRIVED,i))},n.prototype._onPGSSubtitle=function(i){var t=this._remuxer.getTimestampBase();t!=null&&(i.pts!=null&&(i.pts-=t),i.dts!=null&&(i.dts-=t),this._emitter.emit(Ie.default.PGS_SUBTITLE_ARRIVED,i))},n.prototype._onSynchronousKLVMetadata=function(i){var t=this._remuxer.getTimestampBase();t!=null&&(i.pts!=null&&(i.pts-=t),i.dts!=null&&(i.dts-=t),this._emitter.emit(Ie.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,i))},n.prototype._onAsynchronousKLVMetadata=function(i){this._emitter.emit(Ie.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,i)},n.prototype._onSMPTE2038Metadata=function(i){var t=this._remuxer.getTimestampBase();t!=null&&(i.pts!=null&&(i.pts-=t),i.dts!=null&&(i.dts-=t),i.nearest_pts!=null&&(i.nearest_pts-=t),this._emitter.emit(Ie.default.SMPTE2038_METADATA_ARRIVED,i))},n.prototype._onSEI=function(i){var t=this._remuxer.getTimestampBase();t!=null&&(i.pts!=null&&(i.pts-=t),this._emitter.emit(Ie.default.SEI_ARRIVED,i))},n.prototype._onSCTE35Metadata=function(i){var t=this._remuxer.getTimestampBase();t!=null&&(i.pts!=null&&(i.pts-=t),i.nearest_pts!=null&&(i.nearest_pts-=t),this._emitter.emit(Ie.default.SCTE35_METADATA_ARRIVED,i))},n.prototype._onPESPrivateDataDescriptor=function(i){this._emitter.emit(Ie.default.PES_PRIVATE_DATA_DESCRIPTOR,i)},n.prototype._onPESPrivateData=function(i){var t=this._remuxer.getTimestampBase();t!=null&&(i.pts!=null&&(i.pts-=t),i.nearest_pts!=null&&(i.nearest_pts-=t),i.dts!=null&&(i.dts-=t),this._emitter.emit(Ie.default.PES_PRIVATE_DATA_ARRIVED,i))},n.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},n.prototype._onIOComplete=function(i){var t=i+1;t0&&e[0].originalDts===a&&(a=e[0].pts),this._emitter.emit(Ie.default.RECOMMEND_SEEKPOINT,a)}},n.prototype._enableStatisticsReporter=function(){this._statisticsReporter==null&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},n.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},n.prototype._reportSegmentMediaInfo=function(i){var t=this._mediaInfo.segments[i],e=Object.assign({},t);e.duration=this._mediaInfo.duration,e.segmentCount=this._mediaInfo.segmentCount,delete e.segments,delete e.keyframesIndex,this._emitter.emit(Ie.default.MEDIA_INFO,e)},n.prototype._reportStatisticsInfo=function(){var i={};i.url=this._ioctl.currentURL,i.hasRedirect=this._ioctl.hasRedirect,i.hasRedirect&&(i.redirectedURL=this._ioctl.currentRedirectedURL),i.speed=this._ioctl.currentSpeed,i.loaderType=this._ioctl.loaderType,i.currentSegmentIndex=this._currentSegmentIndex,i.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(Ie.default.STATISTICS_INFO,i)},n}())},137:function(se,Q,D){D.r(Q),D(856);var X=D(947),P=D(811),_=D(886),S=D(726);Q.default=function(R){var v=null,I=function(te,ee){R.postMessage({msg:"logcat_callback",data:{type:te,logcat:ee}})}.bind(this);function b(te,ee){var Re={msg:S.default.INIT_SEGMENT,data:{type:te,data:ee}};R.postMessage(Re,[ee.data])}function M(te,ee){var Re={msg:S.default.MEDIA_SEGMENT,data:{type:te,data:ee}};R.postMessage(Re,[ee.data])}function C(){var te={msg:S.default.LOADING_COMPLETE};R.postMessage(te)}function B(){var te={msg:S.default.RECOVERED_EARLY_EOF};R.postMessage(te)}function A(te){var ee={msg:S.default.MEDIA_INFO,data:te};R.postMessage(ee)}function G(te){var ee={msg:S.default.METADATA_ARRIVED,data:te};R.postMessage(ee)}function m(te){var ee={msg:S.default.SCRIPTDATA_ARRIVED,data:te};R.postMessage(ee)}function U(te){var ee={msg:S.default.TIMED_ID3_METADATA_ARRIVED,data:te};R.postMessage(ee)}function x(te){var ee={msg:S.default.PGS_SUBTITLE_ARRIVED,data:te};R.postMessage(ee)}function W(te){var ee={msg:S.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,data:te};R.postMessage(ee)}function L(te){var ee={msg:S.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,data:te};R.postMessage(ee)}function u(te){var ee={msg:S.default.SMPTE2038_METADATA_ARRIVED,data:te};R.postMessage(ee)}function h(te){var ee={msg:S.default.SEI_ARRIVED,data:te};R.postMessage(ee)}function p(te){var ee={msg:S.default.SCTE35_METADATA_ARRIVED,data:te};R.postMessage(ee)}function E(te){var ee={msg:S.default.PES_PRIVATE_DATA_DESCRIPTOR,data:te};R.postMessage(ee)}function K(te){var ee={msg:S.default.PES_PRIVATE_DATA_ARRIVED,data:te};R.postMessage(ee)}function z(te){var ee={msg:S.default.STATISTICS_INFO,data:te};R.postMessage(ee)}function de(te,ee){R.postMessage({msg:S.default.IO_ERROR,data:{type:te,info:ee}})}function le(te,ee){R.postMessage({msg:S.default.DEMUX_ERROR,data:{type:te,info:ee}})}function me(te){R.postMessage({msg:S.default.RECOMMEND_SEEKPOINT,data:te})}P.default.install(),R.addEventListener("message",function(te){switch(te.data.cmd){case"init":(v=new _.default(te.data.param[0],te.data.param[1])).on(S.default.IO_ERROR,de.bind(this)),v.on(S.default.DEMUX_ERROR,le.bind(this)),v.on(S.default.INIT_SEGMENT,b.bind(this)),v.on(S.default.MEDIA_SEGMENT,M.bind(this)),v.on(S.default.LOADING_COMPLETE,C.bind(this)),v.on(S.default.RECOVERED_EARLY_EOF,B.bind(this)),v.on(S.default.MEDIA_INFO,A.bind(this)),v.on(S.default.METADATA_ARRIVED,G.bind(this)),v.on(S.default.SCRIPTDATA_ARRIVED,m.bind(this)),v.on(S.default.TIMED_ID3_METADATA_ARRIVED,U.bind(this)),v.on(S.default.PGS_SUBTITLE_ARRIVED,x.bind(this)),v.on(S.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,W.bind(this)),v.on(S.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,L.bind(this)),v.on(S.default.SMPTE2038_METADATA_ARRIVED,u.bind(this)),v.on(S.default.SEI_ARRIVED,h.bind(this)),v.on(S.default.SCTE35_METADATA_ARRIVED,p.bind(this)),v.on(S.default.PES_PRIVATE_DATA_DESCRIPTOR,E.bind(this)),v.on(S.default.PES_PRIVATE_DATA_ARRIVED,K.bind(this)),v.on(S.default.STATISTICS_INFO,z.bind(this)),v.on(S.default.RECOMMEND_SEEKPOINT,me.bind(this));break;case"destroy":v&&(v.destroy(),v=null),R.postMessage({msg:"destroyed"});break;case"start":v.start();break;case"stop":v.stop();break;case"seek":v.seek(te.data.param);break;case"pause":v.pause();break;case"resume":v.resume();break;case"logging_config":var ee=te.data.param;X.default.applyConfig(ee),ee.enableCallback===!0?X.default.addLogListener(I):X.default.removeLogListener(I)}})}},827:function(se,Q,D){D.r(Q),Q.default={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"}},976:function(se,Q,D){se.exports=D(311).default},653:function(se,Q,D){D.r(Q),D.d(Q,{default:function(){return W}});var X,P=D(856),_=function(){function L(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return L.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},L.prototype.addBytes=function(u){this._firstCheckpoint===0?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=u,this._totalBytes+=u):this._now()-this._lastCheckpoint<1000?(this._intervalBytes+=u,this._totalBytes+=u):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=u,this._totalBytes+=u,this._lastCheckpoint=this._now())},Object.defineProperty(L.prototype,"currentKBps",{get:function(){this.addBytes(0);var u=(this._now()-this._lastCheckpoint)/1000;return u==0&&(u=1),this._intervalBytes/u/1024},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),this._lastSecondBytes!==0?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"averageKBps",{get:function(){var u=(this._now()-this._firstCheckpoint)/1000;return this._totalBytes/u/1024},enumerable:!1,configurable:!0}),L}(),S=D(470),R=D(994),v=D(867),I=(X=function(L,u){return X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,p){h.__proto__=p}||function(h,p){for(var E in p)Object.prototype.hasOwnProperty.call(p,E)&&(h[E]=p[E])},X(L,u)},function(L,u){if(typeof u!="function"&&u!==null)throw TypeError("Class extends value "+String(u)+" is not a constructor or null");function h(){this.constructor=L}X(L,u),L.prototype=u===null?Object.create(u):(h.prototype=u.prototype,new h)}),b=function(L){function u(h,p){var E=L.call(this,"fetch-stream-loader")||this;return E.TAG="FetchStreamLoader",E._seekHandler=h,E._config=p,E._needStash=!0,E._requestAbort=!1,E._abortController=null,E._contentLength=null,E._receivedLength=0,E}return I(u,L),u.isSupported=function(){try{var h=R.default.msedge&&R.default.version.minor>=15048,p=!R.default.msedge||h;return self.fetch&&self.ReadableStream&&p}catch(E){return!1}},u.prototype.destroy=function(){this.isWorking()&&this.abort(),L.prototype.destroy.call(this)},u.prototype.open=function(h,p){var E=this;this._dataSource=h,this._range=p;var K=h.url;this._config.reuseRedirectedURL&&h.redirectedURL!=null&&(K=h.redirectedURL);var z=this._seekHandler.getConfig(K,p),de=new self.Headers;if(typeof z.headers=="object"){var le=z.headers;for(var me in le)le.hasOwnProperty(me)&&de.append(me,le[me])}var te={method:"GET",headers:de,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if(typeof this._config.headers=="object")for(var me in this._config.headers)de.append(me,this._config.headers[me]);h.cors===!1&&(te.mode="same-origin"),h.withCredentials&&(te.credentials="include"),h.referrerPolicy&&(te.referrerPolicy=h.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,te.signal=this._abortController.signal),this._status=S.LoaderStatus.kConnecting,self.fetch(z.url,te).then(function(ee){if(E._requestAbort)return E._status=S.LoaderStatus.kIdle,void ee.body.cancel();if(ee.ok&&ee.status>=200&&ee.status<=299){if(ee.url!==z.url&&E._onURLRedirect){var Re=E._seekHandler.removeURLParameters(ee.url);E._onURLRedirect(Re)}var J=ee.headers.get("Content-Length");return J!=null&&(E._contentLength=parseInt(J),E._contentLength!==0&&E._onContentLengthKnown&&E._onContentLengthKnown(E._contentLength)),E._pump.call(E,ee.body.getReader())}if(E._status=S.LoaderStatus.kError,!E._onError)throw new v.RuntimeException("FetchStreamLoader: Http code invalid, "+ee.status+" "+ee.statusText);E._onError(S.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:ee.status,msg:ee.statusText})}).catch(function(ee){if(!E._abortController||!E._abortController.signal.aborted){if(E._status=S.LoaderStatus.kError,!E._onError)throw ee;E._onError(S.LoaderErrors.EXCEPTION,{code:-1,msg:ee.message})}})},u.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==S.LoaderStatus.kBuffering||!R.default.chrome)&&this._abortController)try{this._abortController.abort()}catch(h){}},u.prototype._pump=function(h){var p=this;return h.read().then(function(E){if(E.done)if(p._contentLength!==null&&p._receivedLength299)){if(this._status=S.LoaderStatus.kError,!this._onError)throw new v.RuntimeException("MozChunkedLoader: Http code invalid, "+p.status+" "+p.statusText);this._onError(S.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:p.status,msg:p.statusText})}else this._status=S.LoaderStatus.kBuffering}},u.prototype._onProgress=function(h){if(this._status!==S.LoaderStatus.kError){this._contentLength===null&&h.total!==null&&h.total!==0&&(this._contentLength=h.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var p=h.target.response,E=this._range.from+this._receivedLength;this._receivedLength+=p.byteLength,this._onDataArrival&&this._onDataArrival(p,E,this._receivedLength)}},u.prototype._onLoadEnd=function(h){this._requestAbort!==!0?this._status!==S.LoaderStatus.kError&&(this._status=S.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},u.prototype._onXhrError=function(h){this._status=S.LoaderStatus.kError;var p=0,E=null;if(this._contentLength&&h.loaded=this._contentLength&&(E=this._range.from+this._contentLength-1),this._currentRequestRange={from:p,to:E},this._internalOpen(this._dataSource,this._currentRequestRange)},u.prototype._internalOpen=function(h,p){this._lastTimeLoaded=0;var E=h.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?E=this._currentRedirectedURL:h.redirectedURL!=null&&(E=h.redirectedURL));var K=this._seekHandler.getConfig(E,p);this._currentRequestURL=K.url;var z=this._xhr=new XMLHttpRequest;if(z.open("GET",K.url,!0),z.responseType="arraybuffer",z.onreadystatechange=this._onReadyStateChange.bind(this),z.onprogress=this._onProgress.bind(this),z.onload=this._onLoad.bind(this),z.onerror=this._onXhrError.bind(this),h.withCredentials&&(z.withCredentials=!0),typeof K.headers=="object"){var de=K.headers;for(var le in de)de.hasOwnProperty(le)&&z.setRequestHeader(le,de[le])}if(typeof this._config.headers=="object")for(var le in de=this._config.headers)de.hasOwnProperty(le)&&z.setRequestHeader(le,de[le]);z.send()},u.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=S.LoaderStatus.kComplete},u.prototype._internalAbort=function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)},u.prototype._onReadyStateChange=function(h){var p=h.target;if(p.readyState===2){if(p.responseURL!=null){var E=this._seekHandler.removeURLParameters(p.responseURL);p.responseURL!==this._currentRequestURL&&E!==this._currentRedirectedURL&&(this._currentRedirectedURL=E,this._onURLRedirect&&this._onURLRedirect(E))}if(p.status>=200&&p.status<=299){if(this._waitForTotalLength)return;this._status=S.LoaderStatus.kBuffering}else{if(this._status=S.LoaderStatus.kError,!this._onError)throw new v.RuntimeException("RangeLoader: Http code invalid, "+p.status+" "+p.statusText);this._onError(S.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:p.status,msg:p.statusText})}}},u.prototype._onProgress=function(h){if(this._status!==S.LoaderStatus.kError){if(this._contentLength===null){var p=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,p=!0;var E=h.total;this._internalAbort(),E!=null&E!==0&&(this._totalLength=E)}if(this._range.to===-1?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,p)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var K=h.loaded-this._lastTimeLoaded;this._lastTimeLoaded=h.loaded,this._speedSampler.addBytes(K)}},u.prototype._normalizeSpeed=function(h){var p=this._chunkSizeKBList,E=p.length-1,K=0,z=0,de=E;if(h=p[K]&&h=3&&(p=this._speedSampler.currentKBps)),p!==0){var E=this._normalizeSpeed(p);this._currentSpeedNormalized!==E&&(this._currentSpeedNormalized=E,this._currentChunkSizeKB=E)}var K=h.target.response,z=this._range.from+this._receivedLength;this._receivedLength+=K.byteLength;var de=!1;this._contentLength!=null&&this._receivedLength0&&this._receivedLength0)for(var z=p.split("&"),de=0;de0;le[0]!==this._startName&&le[0]!==this._endName&&(me&&(K+="&"),K+=z[de])}return K.length===0?h:h+"?"+K},L}(),W=function(){function L(u,h,p){this.TAG="IOController",this._config=h,this._extraData=p,this._stashInitialSize=65536,h.stashInitialSize!=null&&h.stashInitialSize>0&&(this._stashInitialSize=h.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=Math.max(this._stashSize,3145728),this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,h.enableStashBuffer===!1&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=u,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(u.url),this._refTotalLength=u.filesize?u.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new _,this._speedNormalizeList=[32,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return L.prototype.destroy=function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null},L.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},L.prototype.isPaused=function(){return this._paused},Object.defineProperty(L.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"extraData",{get:function(){return this._extraData},set:function(u){this._extraData=u},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(u){this._onDataArrival=u},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(u){this._onSeeked=u},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onError",{get:function(){return this._onError},set:function(u){this._onError=u},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onComplete",{get:function(){return this._onComplete},set:function(u){this._onComplete=u},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(u){this._onRedirect=u},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(u){this._onRecoveredEarlyEof=u},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"hasRedirect",{get:function(){return this._redirectedURL!=null||this._dataSource.redirectedURL!=null},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"currentSpeed",{get:function(){return this._loaderClass===A?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),L.prototype._selectSeekHandler=function(){var u=this._config;if(u.seekType==="range")this._seekHandler=new U(this._config.rangeLoadZeroStart);else if(u.seekType==="param"){var h=u.seekParamStart||"bstart",p=u.seekParamEnd||"bend";this._seekHandler=new x(h,p)}else{if(u.seekType!=="custom")throw new v.InvalidArgumentException("Invalid seekType in config: ".concat(u.seekType));if(typeof u.customSeekHandler!="function")throw new v.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new u.customSeekHandler}},L.prototype._selectLoader=function(){if(this._config.customLoader!=null)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=m;else if(b.isSupported())this._loaderClass=b;else if(C.isSupported())this._loaderClass=C;else{if(!A.isSupported())throw new v.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=A}},L.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),this._loader.needStashBuffer===!1&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)},L.prototype.open=function(u){this._currentRange={from:0,to:-1},u&&(this._currentRange.from=u),this._speedSampler.reset(),u||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},L.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},L.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),this._stashUsed!==0?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)},L.prototype.resume=function(){if(this._paused){this._paused=!1;var u=this._resumeFrom;this._resumeFrom=0,this._internalSeek(u,!0)}},L.prototype.seek=function(u){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(u,!0)},L.prototype._internalSeek=function(u,h){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(h),this._loader.destroy(),this._loader=null;var p={from:u,to:-1};this._currentRange={from:p.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,p),this._onSeeked&&this._onSeeked()},L.prototype.updateUrl=function(u){if(!u||typeof u!="string"||u.length===0)throw new v.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=u},L.prototype._expandBuffer=function(u){for(var h=this._stashSize;h+10485760){var E=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(p,0,h).set(E,0)}this._stashBuffer=p,this._bufferSize=h}},L.prototype._normalizeSpeed=function(u){var h=this._speedNormalizeList,p=h.length-1,E=0,K=0,z=p;if(u=h[E]&&u=512&&u<=1024?Math.floor(1.5*u):2*u)>8192&&(h=8192);var p=1024*h+1048576;this._bufferSize0){var z=this._stashBuffer.slice(0,this._stashUsed);(me=this._dispatchChunks(z,this._stashByteStart))0&&(te=new Uint8Array(z,me),le.set(te,0),this._stashUsed=te.byteLength,this._stashByteStart+=me):(this._stashUsed=0,this._stashByteStart+=me),this._stashUsed+u.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+u.byteLength),le=new Uint8Array(this._stashBuffer,0,this._bufferSize)),le.set(new Uint8Array(u),this._stashUsed),this._stashUsed+=u.byteLength}else(me=this._dispatchChunks(u,h))this._bufferSize&&(this._expandBuffer(de),le=new Uint8Array(this._stashBuffer,0,this._bufferSize)),le.set(new Uint8Array(u,me),0),this._stashUsed+=de,this._stashByteStart=h+me);else if(this._stashUsed===0){var de;(me=this._dispatchChunks(u,h))this._bufferSize&&this._expandBuffer(de),(le=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(u,me),0),this._stashUsed+=de,this._stashByteStart=h+me)}else{var le,me;if(this._stashUsed+u.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+u.byteLength),(le=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(u),this._stashUsed),this._stashUsed+=u.byteLength,(me=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart))0){var te=new Uint8Array(this._stashBuffer,me);le.set(te,0)}this._stashUsed-=me,this._stashByteStart+=me}}},L.prototype._flushStashBuffer=function(u){if(this._stashUsed>0){var h=this._stashBuffer.slice(0,this._stashUsed),p=this._dispatchChunks(h,this._stashByteStart),E=h.byteLength-p;if(p0){var K=new Uint8Array(this._stashBuffer,0,this._bufferSize),z=new Uint8Array(h,p);K.set(z,0),this._stashUsed=z.byteLength,this._stashByteStart+=p}return 0}P.default.w(this.TAG,"".concat(E," bytes unconsumed data remain when flush buffer, dropped"))}return this._stashUsed=0,this._stashByteStart=0,E}return 0},L.prototype._onLoaderComplete=function(u,h){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},L.prototype._onLoaderError=function(u,h){switch(P.default.e(this.TAG,"Loader error, code = ".concat(h.code,", msg = ").concat(h.msg)),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,u=S.LoaderErrors.UNRECOVERABLE_EARLY_EOF),u){case S.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var p=this._currentRange.to+1;return void(p0){var fe=this._media_element.buffered.start(0);(fe<1&&c0){var fe=j.start(0);if(fe<1&&w=fe&&c0&&this._suspendTransmuxerIfBufferedPositionExceeded(j)},k.prototype._suspendTransmuxerIfBufferedPositionExceeded=function(c){c>=this._media_element.currentTime+this._config.lazyLoadMaxDuration&&!this._paused&&(b.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this.suspendTransmuxer(),this._media_element.addEventListener("timeupdate",this.e.onMediaTimeUpdate))},k.prototype.suspendTransmuxer=function(){this._paused=!0,this._on_pause_transmuxer()},k.prototype._resumeTransmuxerIfNeeded=function(){for(var c=this._media_element.buffered,w=this._media_element.currentTime,j=this._config.lazyLoadRecoverDuration,fe=!1,re=0;re=V&&w=Y-j&&(fe=!0);break}}fe&&(b.default.v(this.TAG,"Continue loading from paused position"),this.resumeTransmuxer(),this._media_element.removeEventListener("timeupdate",this.e.onMediaTimeUpdate))},k.prototype.resumeTransmuxer=function(){this._paused=!1,this._on_resume_transmuxer()},k}(),E=function(){function k(c,w){this.TAG="StartupStallJumper",this._media_element=null,this._on_direct_seek=null,this._canplay_received=!1,this.e=null,this._media_element=c,this._on_direct_seek=w,this.e={onMediaCanPlay:this._onMediaCanPlay.bind(this),onMediaStalled:this._onMediaStalled.bind(this),onMediaProgress:this._onMediaProgress.bind(this)},this._media_element.addEventListener("canplay",this.e.onMediaCanPlay),this._media_element.addEventListener("stalled",this.e.onMediaStalled),this._media_element.addEventListener("progress",this.e.onMediaProgress)}return k.prototype.destroy=function(){this._media_element.removeEventListener("canplay",this.e.onMediaCanPlay),this._media_element.removeEventListener("stalled",this.e.onMediaStalled),this._media_element.removeEventListener("progress",this.e.onMediaProgress),this._media_element=null,this._on_direct_seek=null},k.prototype._onMediaCanPlay=function(c){this._canplay_received=!0,this._media_element.removeEventListener("canplay",this.e.onMediaCanPlay)},k.prototype._onMediaStalled=function(c){this._detectAndFixStuckPlayback(!0)},k.prototype._onMediaProgress=function(c){this._detectAndFixStuckPlayback()},k.prototype._detectAndFixStuckPlayback=function(c){var w=this._media_element,j=w.buffered;c||!this._canplay_received||w.readyState<2?j.length>0&&w.currentTimethis._config.liveBufferLatencyMaxLatency&&fe-w>this._config.liveBufferLatencyMaxLatency){var re=fe-this._config.liveBufferLatencyMinRemain;this._on_direct_seek(re)}}},k}(),z=function(){function k(c,w){this._config=null,this._media_element=null,this.e=null,this._config=c,this._media_element=w,this.e={onMediaTimeUpdate:this._onMediaTimeUpdate.bind(this)},this._media_element.addEventListener("timeupdate",this.e.onMediaTimeUpdate)}return k.prototype.destroy=function(){this._media_element.removeEventListener("timeupdate",this.e.onMediaTimeUpdate),this._media_element=null,this._config=null},k.prototype._onMediaTimeUpdate=function(c){if(this._config.isLive&&this._config.liveSync){var w=this._getCurrentLatency();if(w>this._config.liveSyncMaxLatency){var j=Math.min(2,Math.max(1,this._config.liveSyncPlaybackRate));this._media_element.playbackRate=j}else w>this._config.liveSyncTargetLatency||this._media_element.playbackRate!==1&&this._media_element.playbackRate!==0&&(this._media_element.playbackRate=1)}},k.prototype._getCurrentLatency=function(){if(!this._media_element)return 0;var c=this._media_element.buffered,w=this._media_element.currentTime;return c.length==0?0:c.end(c.length-1)-w},k}(),de=function(){function k(c,w){this.TAG="PlayerEngineMainThread",this._emitter=new M,this._media_element=null,this._mse_controller=null,this._transmuxer=null,this._pending_seek_time=null,this._seeking_handler=null,this._loading_controller=null,this._startup_stall_jumper=null,this._live_latency_chaser=null,this._live_latency_synchronizer=null,this._mse_source_opened=!1,this._has_pending_load=!1,this._loaded_metadata_received=!1,this._media_info=null,this._statistics_info=null,this.e=null,this._media_data_source=c,this._config=S(),typeof w=="object"&&Object.assign(this._config,w),c.isLive===!0&&(this._config.isLive=!0),this.e={onMediaLoadedMetadata:this._onMediaLoadedMetadata.bind(this)}}return k.prototype.destroy=function(){this._emitter.emit(A.default.DESTROYING),this._transmuxer&&this.unload(),this._media_element&&this.detachMediaElement(),this.e=null,this._media_data_source=null,this._emitter.removeAllListeners(),this._emitter=null},k.prototype.on=function(c,w){var j=this;this._emitter.addListener(c,w),c===A.default.MEDIA_INFO&&this._media_info?Promise.resolve().then(function(){return j._emitter.emit(A.default.MEDIA_INFO,j.mediaInfo)}):c==A.default.STATISTICS_INFO&&this._statistics_info&&Promise.resolve().then(function(){return j._emitter.emit(A.default.STATISTICS_INFO,j.statisticsInfo)})},k.prototype.off=function(c,w){this._emitter.removeListener(c,w)},k.prototype.attachMediaElement=function(c){var w=this;this._media_element=c,c.src="",c.removeAttribute("src"),c.srcObject=null,c.load(),c.addEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._mse_controller=new B.default(this._config),this._mse_controller.on(m.default.UPDATE_END,this._onMSEUpdateEnd.bind(this)),this._mse_controller.on(m.default.BUFFER_FULL,this._onMSEBufferFull.bind(this)),this._mse_controller.on(m.default.SOURCE_OPEN,this._onMSESourceOpen.bind(this)),this._mse_controller.on(m.default.ERROR,this._onMSEError.bind(this)),this._mse_controller.on(m.default.START_STREAMING,this._onMSEStartStreaming.bind(this)),this._mse_controller.on(m.default.END_STREAMING,this._onMSEEndStreaming.bind(this)),this._mse_controller.initialize({getCurrentTime:function(){return w._media_element.currentTime},getReadyState:function(){return w._media_element.readyState}}),this._mse_controller.isManagedMediaSource()?(c.disableRemotePlayback=!0,c.srcObject=this._mse_controller.getObject()):c.src=this._mse_controller.getObjectURL()},k.prototype.detachMediaElement=function(){this._media_element&&(this._mse_controller.shutdown(),this._media_element.removeEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._media_element.src="",this._media_element.removeAttribute("src"),this._media_element.srcObject=null,this._media_element.load(),this._media_element=null,this._mse_controller.revokeObjectURL()),this._mse_controller&&(this._mse_controller.destroy(),this._mse_controller=null)},k.prototype.load=function(){var c=this;if(!this._media_element)throw new x.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new x.IllegalStateException("load() has been called, please call unload() first!");this._has_pending_load||(!this._config.deferLoadAfterSourceOpen||this._mse_source_opened?(this._transmuxer=new G.default(this._media_data_source,this._config),this._transmuxer.on(W.default.INIT_SEGMENT,function(w,j){c._mse_controller.appendInitSegment(j)}),this._transmuxer.on(W.default.MEDIA_SEGMENT,function(w,j){c._mse_controller.appendMediaSegment(j),!c._config.isLive&&w==="video"&&j.data&&j.data.byteLength>0&&"info"in j&&c._seeking_handler.appendSyncPoints(j.info.syncPoints),c._loading_controller.notifyBufferedPositionChanged(j.info.endDts/1000)}),this._transmuxer.on(W.default.LOADING_COMPLETE,function(){c._mse_controller.endOfStream(),c._emitter.emit(A.default.LOADING_COMPLETE)}),this._transmuxer.on(W.default.RECOVERED_EARLY_EOF,function(){c._emitter.emit(A.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(W.default.IO_ERROR,function(w,j){c._emitter.emit(A.default.ERROR,U.ErrorTypes.NETWORK_ERROR,w,j)}),this._transmuxer.on(W.default.DEMUX_ERROR,function(w,j){c._emitter.emit(A.default.ERROR,U.ErrorTypes.MEDIA_ERROR,w,j)}),this._transmuxer.on(W.default.MEDIA_INFO,function(w){c._media_info=w,c._emitter.emit(A.default.MEDIA_INFO,Object.assign({},w))}),this._transmuxer.on(W.default.STATISTICS_INFO,function(w){c._statistics_info=c._fillStatisticsInfo(w),c._emitter.emit(A.default.STATISTICS_INFO,Object.assign({},w))}),this._transmuxer.on(W.default.RECOMMEND_SEEKPOINT,function(w){c._media_element&&!c._config.accurateSeek&&c._seeking_handler.directSeek(w/1000)}),this._transmuxer.on(W.default.METADATA_ARRIVED,function(w){c._emitter.emit(A.default.METADATA_ARRIVED,w)}),this._transmuxer.on(W.default.SCRIPTDATA_ARRIVED,function(w){c._emitter.emit(A.default.SCRIPTDATA_ARRIVED,w)}),this._transmuxer.on(W.default.TIMED_ID3_METADATA_ARRIVED,function(w){c._emitter.emit(A.default.TIMED_ID3_METADATA_ARRIVED,w)}),this._transmuxer.on(W.default.PGS_SUBTITLE_ARRIVED,function(w){c._emitter.emit(A.default.PGS_SUBTITLE_ARRIVED,w)}),this._transmuxer.on(W.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,function(w){c._emitter.emit(A.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,w)}),this._transmuxer.on(W.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,function(w){c._emitter.emit(A.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,w)}),this._transmuxer.on(W.default.SMPTE2038_METADATA_ARRIVED,function(w){c._emitter.emit(A.default.SMPTE2038_METADATA_ARRIVED,w)}),this._transmuxer.on(W.default.SEI_ARRIVED,function(w){c._emitter.emit(A.default.SEI_ARRIVED,w)}),this._transmuxer.on(W.default.SCTE35_METADATA_ARRIVED,function(w){c._emitter.emit(A.default.SCTE35_METADATA_ARRIVED,w)}),this._transmuxer.on(W.default.PES_PRIVATE_DATA_DESCRIPTOR,function(w){c._emitter.emit(A.default.PES_PRIVATE_DATA_DESCRIPTOR,w)}),this._transmuxer.on(W.default.PES_PRIVATE_DATA_ARRIVED,function(w){c._emitter.emit(A.default.PES_PRIVATE_DATA_ARRIVED,w)}),this._seeking_handler=new h(this._config,this._media_element,this._onRequiredUnbufferedSeek.bind(this)),this._loading_controller=new p(this._config,this._media_element,this._onRequestPauseTransmuxer.bind(this),this._onRequestResumeTransmuxer.bind(this)),this._startup_stall_jumper=new E(this._media_element,this._onRequestDirectSeek.bind(this)),this._config.isLive&&this._config.liveBufferLatencyChasing&&(this._live_latency_chaser=new K(this._config,this._media_element,this._onRequestDirectSeek.bind(this))),this._config.isLive&&this._config.liveSync&&(this._live_latency_synchronizer=new z(this._config,this._media_element)),this._media_element.readyState>0&&this._seeking_handler.directSeek(0),this._transmuxer.open()):this._has_pending_load=!0)},k.prototype.unload=function(){var c,w,j,fe,re,V,Y,ie,oe;(c=this._media_element)===null||c===void 0||c.pause(),(w=this._live_latency_synchronizer)===null||w===void 0||w.destroy(),this._live_latency_synchronizer=null,(j=this._live_latency_chaser)===null||j===void 0||j.destroy(),this._live_latency_chaser=null,(fe=this._startup_stall_jumper)===null||fe===void 0||fe.destroy(),this._startup_stall_jumper=null,(re=this._loading_controller)===null||re===void 0||re.destroy(),this._loading_controller=null,(V=this._seeking_handler)===null||V===void 0||V.destroy(),this._seeking_handler=null,(Y=this._mse_controller)===null||Y===void 0||Y.flush(),(ie=this._transmuxer)===null||ie===void 0||ie.close(),(oe=this._transmuxer)===null||oe===void 0||oe.destroy(),this._transmuxer=null},k.prototype.play=function(){return this._media_element.play()},k.prototype.pause=function(){this._media_element.pause()},k.prototype.seek=function(c){this._media_element&&this._seeking_handler?this._seeking_handler.seek(c):this._pending_seek_time=c},Object.defineProperty(k.prototype,"mediaInfo",{get:function(){return Object.assign({},this._media_info)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"statisticsInfo",{get:function(){return Object.assign({},this._statistics_info)},enumerable:!1,configurable:!0}),k.prototype._onMSESourceOpen=function(){this._mse_source_opened=!0,this._has_pending_load&&(this._has_pending_load=!1,this.load())},k.prototype._onMSEUpdateEnd=function(){this._config.isLive&&this._config.liveBufferLatencyChasing&&this._live_latency_chaser&&this._live_latency_chaser.notifyBufferedRangeUpdate(),this._loading_controller.notifyBufferedPositionChanged()},k.prototype._onMSEBufferFull=function(){b.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._loading_controller.suspendTransmuxer()},k.prototype._onMSEError=function(c){this._emitter.emit(A.default.ERROR,U.ErrorTypes.MEDIA_ERROR,U.ErrorDetails.MEDIA_MSE_ERROR,c)},k.prototype._onMSEStartStreaming=function(){this._loaded_metadata_received&&(this._config.isLive||(b.default.v(this.TAG,"Resume transmuxing task due to ManagedMediaSource onStartStreaming"),this._loading_controller.resumeTransmuxer()))},k.prototype._onMSEEndStreaming=function(){this._config.isLive||(b.default.v(this.TAG,"Suspend transmuxing task due to ManagedMediaSource onEndStreaming"),this._loading_controller.suspendTransmuxer())},k.prototype._onMediaLoadedMetadata=function(c){this._loaded_metadata_received=!0,this._pending_seek_time!=null&&(this._seeking_handler.seek(this._pending_seek_time),this._pending_seek_time=null)},k.prototype._onRequestDirectSeek=function(c){this._seeking_handler.directSeek(c)},k.prototype._onRequiredUnbufferedSeek=function(c){this._mse_controller.flush(),this._transmuxer.seek(c)},k.prototype._onRequestPauseTransmuxer=function(){this._transmuxer.pause()},k.prototype._onRequestResumeTransmuxer=function(){this._transmuxer.resume()},k.prototype._fillStatisticsInfo=function(c){if(c.playerType="MSEPlayer",!(this._media_element instanceof HTMLVideoElement))return c;var w=!0,j=0,fe=0;if(this._media_element.getVideoPlaybackQuality){var re=this._media_element.getVideoPlaybackQuality();j=re.totalVideoFrames,fe=re.droppedVideoFrames}else this._media_element.webkitDecodedFrameCount!=null?(j=this._media_element.webkitDecodedFrameCount,fe=this._media_element.webkitDroppedFrameCount):w=!1;return w&&(c.decodedFrames=j,c.droppedFrames=fe),c},k}(),le=D(861),me=D(947),te=function(){function k(c,w){this.TAG="PlayerEngineDedicatedThread",this._emitter=new M,this._media_element=null,this._worker_destroying=!1,this._seeking_handler=null,this._loading_controller=null,this._startup_stall_jumper=null,this._live_latency_chaser=null,this._live_latency_synchronizer=null,this._pending_seek_time=null,this._media_info=null,this._statistics_info=null,this.e=null,this._media_data_source=c,this._config=S(),typeof w=="object"&&Object.assign(this._config,w),c.isLive===!0&&(this._config.isLive=!0),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this),onMediaLoadedMetadata:this._onMediaLoadedMetadata.bind(this),onMediaTimeUpdate:this._onMediaTimeUpdate.bind(this),onMediaReadyStateChanged:this._onMediaReadyStateChange.bind(this)},me.default.registerListener(this.e.onLoggingConfigChanged),this._worker=le(877,{all:!0}),this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",media_data_source:this._media_data_source,config:this._config}),this._worker.postMessage({cmd:"logging_config",logging_config:me.default.getConfig()})}return k.isSupported=function(){return!!(self.Worker&&(self.MediaSource&&("canConstructInDedicatedWorker"in self.MediaSource)&&self.MediaSource.canConstructInDedicatedWorker===!0||self.ManagedMediaSource&&("canConstructInDedicatedWorker"in self.ManagedMediaSource)&&self.ManagedMediaSource.canConstructInDedicatedWorker===!0))},k.prototype.destroy=function(){this._emitter.emit(A.default.DESTROYING),this.unload(),this.detachMediaElement(),this._worker_destroying=!0,this._worker.postMessage({cmd:"destroy"}),me.default.removeListener(this.e.onLoggingConfigChanged),this.e=null,this._media_data_source=null,this._emitter.removeAllListeners(),this._emitter=null},k.prototype.on=function(c,w){var j=this;this._emitter.addListener(c,w),c===A.default.MEDIA_INFO&&this._media_info?Promise.resolve().then(function(){return j._emitter.emit(A.default.MEDIA_INFO,j.mediaInfo)}):c==A.default.STATISTICS_INFO&&this._statistics_info&&Promise.resolve().then(function(){return j._emitter.emit(A.default.STATISTICS_INFO,j.statisticsInfo)})},k.prototype.off=function(c,w){this._emitter.removeListener(c,w)},k.prototype.attachMediaElement=function(c){this._media_element=c,this._media_element.src="",this._media_element.removeAttribute("src"),this._media_element.srcObject=null,this._media_element.load(),this._media_element.addEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._media_element.addEventListener("timeupdate",this.e.onMediaTimeUpdate),this._media_element.addEventListener("readystatechange",this.e.onMediaReadyStateChanged),this._worker.postMessage({cmd:"initialize_mse"})},k.prototype.detachMediaElement=function(){this._worker.postMessage({cmd:"shutdown_mse"}),this._media_element&&(this._media_element.removeEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._media_element.removeEventListener("timeupdate",this.e.onMediaTimeUpdate),this._media_element.removeEventListener("readystatechange",this.e.onMediaReadyStateChanged),this._media_element.src="",this._media_element.removeAttribute("src"),this._media_element.srcObject=null,this._media_element.load(),this._media_element=null)},k.prototype.load=function(){this._worker.postMessage({cmd:"load"}),this._seeking_handler=new h(this._config,this._media_element,this._onRequiredUnbufferedSeek.bind(this)),this._loading_controller=new p(this._config,this._media_element,this._onRequestPauseTransmuxer.bind(this),this._onRequestResumeTransmuxer.bind(this)),this._startup_stall_jumper=new E(this._media_element,this._onRequestDirectSeek.bind(this)),this._config.isLive&&this._config.liveBufferLatencyChasing&&(this._live_latency_chaser=new K(this._config,this._media_element,this._onRequestDirectSeek.bind(this))),this._config.isLive&&this._config.liveSync&&(this._live_latency_synchronizer=new z(this._config,this._media_element)),this._media_element.readyState>0&&this._seeking_handler.directSeek(0)},k.prototype.unload=function(){var c,w,j,fe,re,V;(c=this._media_element)===null||c===void 0||c.pause(),this._worker.postMessage({cmd:"unload"}),(w=this._live_latency_synchronizer)===null||w===void 0||w.destroy(),this._live_latency_synchronizer=null,(j=this._live_latency_chaser)===null||j===void 0||j.destroy(),this._live_latency_chaser=null,(fe=this._startup_stall_jumper)===null||fe===void 0||fe.destroy(),this._startup_stall_jumper=null,(re=this._loading_controller)===null||re===void 0||re.destroy(),this._loading_controller=null,(V=this._seeking_handler)===null||V===void 0||V.destroy(),this._seeking_handler=null},k.prototype.play=function(){return this._media_element.play()},k.prototype.pause=function(){this._media_element.pause()},k.prototype.seek=function(c){this._media_element&&this._seeking_handler?this._seeking_handler.seek(c):this._pending_seek_time=c},Object.defineProperty(k.prototype,"mediaInfo",{get:function(){return Object.assign({},this._media_info)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"statisticsInfo",{get:function(){return Object.assign({},this._statistics_info)},enumerable:!1,configurable:!0}),k.prototype._onLoggingConfigChanged=function(c){var w;(w=this._worker)===null||w===void 0||w.postMessage({cmd:"logging_config",logging_config:c})},k.prototype._onMSEUpdateEnd=function(){this._config.isLive&&this._config.liveBufferLatencyChasing&&this._live_latency_chaser&&this._live_latency_chaser.notifyBufferedRangeUpdate(),this._loading_controller.notifyBufferedPositionChanged()},k.prototype._onMSEBufferFull=function(){b.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._loading_controller.suspendTransmuxer()},k.prototype._onMediaLoadedMetadata=function(c){this._pending_seek_time!=null&&(this._seeking_handler.seek(this._pending_seek_time),this._pending_seek_time=null)},k.prototype._onRequestDirectSeek=function(c){this._seeking_handler.directSeek(c)},k.prototype._onRequiredUnbufferedSeek=function(c){this._worker.postMessage({cmd:"unbuffered_seek",milliseconds:c})},k.prototype._onRequestPauseTransmuxer=function(){this._worker.postMessage({cmd:"pause_transmuxer"})},k.prototype._onRequestResumeTransmuxer=function(){this._worker.postMessage({cmd:"resume_transmuxer"})},k.prototype._onMediaTimeUpdate=function(c){this._worker.postMessage({cmd:"timeupdate",current_time:c.target.currentTime})},k.prototype._onMediaReadyStateChange=function(c){this._worker.postMessage({cmd:"readystatechange",ready_state:c.target.readyState})},k.prototype._onWorkerMessage=function(c){var w,j=c.data,fe=j.msg;if(fe=="destroyed"||this._worker_destroying)return this._worker_destroying=!1,(w=this._worker)===null||w===void 0||w.terminate(),void(this._worker=null);switch(fe){case"mse_init":var re=j;typeof self.ManagedMediaSource=="function"&&typeof self.MediaSource!="function"&&(this._media_element.disableRemotePlayback=!0),this._media_element.srcObject=re.handle;break;case"mse_event":(re=j).event==m.default.UPDATE_END?this._onMSEUpdateEnd():re.event==m.default.BUFFER_FULL&&this._onMSEBufferFull();break;case"transmuxing_event":if((re=j).event==W.default.MEDIA_INFO){var V=j;this._media_info=V.info,this._emitter.emit(A.default.MEDIA_INFO,Object.assign({},V.info))}else if(re.event==W.default.STATISTICS_INFO){var Y=j;this._statistics_info=this._fillStatisticsInfo(Y.info),this._emitter.emit(A.default.STATISTICS_INFO,Object.assign({},Y.info))}else if(re.event==W.default.RECOMMEND_SEEKPOINT){var ie=j;this._media_element&&!this._config.accurateSeek&&this._seeking_handler.directSeek(ie.milliseconds/1000)}break;case"player_event":if((re=j).event==A.default.ERROR){var oe=j;this._emitter.emit(A.default.ERROR,oe.error_type,oe.error_detail,oe.info)}else if("extraData"in re){var ue=j;this._emitter.emit(ue.event,ue.extraData)}break;case"logcat_callback":re=j,b.default.emitter.emit("log",re.type,re.logcat);break;case"buffered_position_changed":re=j,this._loading_controller.notifyBufferedPositionChanged(re.buffered_position_milliseconds/1000)}},k.prototype._fillStatisticsInfo=function(c){if(c.playerType="MSEPlayer",!(this._media_element instanceof HTMLVideoElement))return c;var w=!0,j=0,fe=0;if(this._media_element.getVideoPlaybackQuality){var re=this._media_element.getVideoPlaybackQuality();j=re.totalVideoFrames,fe=re.droppedVideoFrames}else this._media_element.webkitDecodedFrameCount!=null?(j=this._media_element.webkitDecodedFrameCount,fe=this._media_element.webkitDroppedFrameCount):w=!1;return w&&(c.decodedFrames=j,c.droppedFrames=fe),c},k}(),ee=function(){function k(c,w){this.TAG="MSEPlayer",this._type="MSEPlayer",this._media_element=null,this._player_engine=null;var j=c.type.toLowerCase();if(j!=="mse"&&j!=="mpegts"&&j!=="m2ts"&&j!=="flv")throw new x.InvalidArgumentException("MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!");if(w&&w.enableWorkerForMSE&&te.isSupported())try{this._player_engine=new te(c,w)}catch(fe){b.default.e(this.TAG,"Error while initializing PlayerEngineDedicatedThread, fallback to PlayerEngineMainThread"),this._player_engine=new de(c,w)}else this._player_engine=new de(c,w)}return k.prototype.destroy=function(){this._player_engine.destroy(),this._player_engine=null,this._media_element=null},k.prototype.on=function(c,w){this._player_engine.on(c,w)},k.prototype.off=function(c,w){this._player_engine.off(c,w)},k.prototype.attachMediaElement=function(c){this._media_element=c,this._player_engine.attachMediaElement(c)},k.prototype.detachMediaElement=function(){this._media_element=null,this._player_engine.detachMediaElement()},k.prototype.load=function(){this._player_engine.load()},k.prototype.unload=function(){this._player_engine.unload()},k.prototype.play=function(){return this._player_engine.play()},k.prototype.pause=function(){this._player_engine.pause()},Object.defineProperty(k.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"buffered",{get:function(){return this._media_element.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"duration",{get:function(){return this._media_element.duration},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"volume",{get:function(){return this._media_element.volume},set:function(c){this._media_element.volume=c},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"muted",{get:function(){return this._media_element.muted},set:function(c){this._media_element.muted=c},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"currentTime",{get:function(){return this._media_element?this._media_element.currentTime:0},set:function(c){this._player_engine.seek(c)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"mediaInfo",{get:function(){return this._player_engine.mediaInfo},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"statisticsInfo",{get:function(){return this._player_engine.statisticsInfo},enumerable:!1,configurable:!0}),k}(),Re=function(){function k(c,w){this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new(C()),this._config=S(),typeof w=="object"&&Object.assign(this._config,w);var j=c.type.toLowerCase();if(j==="mse"||j==="mpegts"||j==="m2ts"||j==="flv")throw new x.InvalidArgumentException("NativePlayer does't support mse/mpegts/m2ts/flv MediaDataSource input!");if(c.hasOwnProperty("segments"))throw new x.InvalidArgumentException("NativePlayer(".concat(c.type,") doesn't support multipart playback!"));this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=c,this._mediaElement=null}return k.prototype.destroy=function(){this._emitter.emit(A.default.DESTROYING),this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},k.prototype.on=function(c,w){var j=this;c===A.default.MEDIA_INFO?this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){j._emitter.emit(A.default.MEDIA_INFO,j.mediaInfo)}):c===A.default.STATISTICS_INFO&&this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){j._emitter.emit(A.default.STATISTICS_INFO,j.statisticsInfo)}),this._emitter.addListener(c,w)},k.prototype.off=function(c,w){this._emitter.removeListener(c,w)},k.prototype.attachMediaElement=function(c){if(this._mediaElement=c,c.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._pendingSeekTime!=null)try{c.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(w){}},k.prototype.detachMediaElement=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},k.prototype.load=function(){if(!this._mediaElement)throw new x.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},k.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},k.prototype.play=function(){return this._mediaElement.play()},k.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(k.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(c){this._mediaElement.volume=c},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(c){this._mediaElement.muted=c},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(c){this._mediaElement?this._mediaElement.currentTime=c:this._pendingSeekTime=c},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"mediaInfo",{get:function(){var c={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(c.duration=Math.floor(1000*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(c.width=this._mediaElement.videoWidth,c.height=this._mediaElement.videoHeight)),c},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"statisticsInfo",{get:function(){var c={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return c;var w=!0,j=0,fe=0;if(this._mediaElement.getVideoPlaybackQuality){var re=this._mediaElement.getVideoPlaybackQuality();j=re.totalVideoFrames,fe=re.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(j=this._mediaElement.webkitDecodedFrameCount,fe=this._mediaElement.webkitDroppedFrameCount):w=!1;return w&&(c.decodedFrames=j,c.droppedFrames=fe),c},enumerable:!1,configurable:!0}),k.prototype._onvLoadedMetadata=function(c){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(A.default.MEDIA_INFO,this.mediaInfo)},k.prototype._reportStatisticsInfo=function(){this._emitter.emit(A.default.STATISTICS_INFO,this.statisticsInfo)},k}();X.default.install();var J={createPlayer:function(k,c){var w=k;if(w==null||typeof w!="object")throw new x.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!w.hasOwnProperty("type"))throw new x.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");switch(w.type){case"mse":case"mpegts":case"m2ts":case"flv":return new ee(w,c);default:return new Re(w,c)}},isSupported:function(){return v.supportMSEH264Playback()},getFeatureList:function(){return v.getFeatureList()}};J.BaseLoader=I.BaseLoader,J.LoaderStatus=I.LoaderStatus,J.LoaderErrors=I.LoaderErrors,J.Events=A.default,J.ErrorTypes=U.ErrorTypes,J.ErrorDetails=U.ErrorDetails,J.MSEPlayer=ee,J.NativePlayer=Re,J.LoggingControl=me.default,Object.defineProperty(J,"version",{enumerable:!0,get:function(){return"1.8.2"}});var ke=J},355:function(se,Q,D){D.r(Q),D.d(Q,{ErrorDetails:function(){return S},ErrorTypes:function(){return _}});var X=D(470),P=D(827),_={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},S={NETWORK_EXCEPTION:X.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:X.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:X.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:X.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:P.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:P.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:P.default.CODEC_UNSUPPORTED}},994:function(se,Q,D){D.r(Q);var X={};(function(){var P=self.navigator.userAgent.toLowerCase(),_=/(edge)\/([\w.]+)/.exec(P)||/(opr)[\/]([\w.]+)/.exec(P)||/(chrome)[ \/]([\w.]+)/.exec(P)||/(iemobile)[\/]([\w.]+)/.exec(P)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(P)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(P)||/(webkit)[ \/]([\w.]+)/.exec(P)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(P)||/(msie) ([\w.]+)/.exec(P)||P.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(P)||P.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(P)||[],S=/(ipad)/.exec(P)||/(ipod)/.exec(P)||/(windows phone)/.exec(P)||/(iphone)/.exec(P)||/(kindle)/.exec(P)||/(android)/.exec(P)||/(windows)/.exec(P)||/(mac)/.exec(P)||/(linux)/.exec(P)||/(cros)/.exec(P)||[],R={browser:_[5]||_[3]||_[1]||"",version:_[2]||_[4]||"0",majorVersion:_[4]||_[2]||"0",platform:S[0]||""},v={};if(R.browser){v[R.browser]=!0;var I=R.majorVersion.split(".");v.version={major:parseInt(R.majorVersion,10),string:R.version},I.length>1&&(v.version.minor=parseInt(I[1],10)),I.length>2&&(v.version.build=parseInt(I[2],10))}if(R.platform&&(v[R.platform]=!0),(v.chrome||v.opr||v.safari)&&(v.webkit=!0),v.rv||v.iemobile){v.rv&&delete v.rv;var b="msie";R.browser=b,v[b]=!0}if(v.edge){delete v.edge;var M="msedge";R.browser=M,v[M]=!0}if(v.opr){var C="opera";R.browser=C,v[C]=!0}if(v.safari&&v.android){var B="android";R.browser=B,v[B]=!0}for(var A in v.name=R.browser,v.platform=R.platform,X)X.hasOwnProperty(A)&&delete X[A];Object.assign(X,v)})(),Q.default=X},867:function(se,Q,D){D.r(Q),D.d(Q,{IllegalStateException:function(){return S},InvalidArgumentException:function(){return R},NotImplementedException:function(){return v},RuntimeException:function(){return _}});var X,P=(X=function(I,b){return X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(M,C){M.__proto__=C}||function(M,C){for(var B in C)Object.prototype.hasOwnProperty.call(C,B)&&(M[B]=C[B])},X(I,b)},function(I,b){if(typeof b!="function"&&b!==null)throw TypeError("Class extends value "+String(b)+" is not a constructor or null");function M(){this.constructor=I}X(I,b),I.prototype=b===null?Object.create(b):(M.prototype=b.prototype,new M)}),_=function(){function I(b){this._message=b}return Object.defineProperty(I.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),I.prototype.toString=function(){return this.name+": "+this.message},I}(),S=function(I){function b(M){return I.call(this,M)||this}return P(b,I),Object.defineProperty(b.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),b}(_),R=function(I){function b(M){return I.call(this,M)||this}return P(b,I),Object.defineProperty(b.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),b}(_),v=function(I){function b(M){return I.call(this,M)||this}return P(b,I),Object.defineProperty(b.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),b}(_)},856:function(se,Q,D){D.r(Q);var X=D(7),P=D.n(X),_=function(){function S(){}return S.e=function(R,v){R&&!S.FORCE_GLOBAL_TAG||(R=S.GLOBAL_TAG);var I="[".concat(R,"] > ").concat(v);S.ENABLE_CALLBACK&&S.emitter.emit("log","error",I),S.ENABLE_ERROR&&(console.error?console.error(I):console.warn?console.warn(I):console.log(I))},S.i=function(R,v){R&&!S.FORCE_GLOBAL_TAG||(R=S.GLOBAL_TAG);var I="[".concat(R,"] > ").concat(v);S.ENABLE_CALLBACK&&S.emitter.emit("log","info",I),S.ENABLE_INFO&&(console.info?console.info(I):console.log(I))},S.w=function(R,v){R&&!S.FORCE_GLOBAL_TAG||(R=S.GLOBAL_TAG);var I="[".concat(R,"] > ").concat(v);S.ENABLE_CALLBACK&&S.emitter.emit("log","warn",I),S.ENABLE_WARN&&(console.warn?console.warn(I):console.log(I))},S.d=function(R,v){R&&!S.FORCE_GLOBAL_TAG||(R=S.GLOBAL_TAG);var I="[".concat(R,"] > ").concat(v);S.ENABLE_CALLBACK&&S.emitter.emit("log","debug",I),S.ENABLE_DEBUG&&(console.debug?console.debug(I):console.log(I))},S.v=function(R,v){R&&!S.FORCE_GLOBAL_TAG||(R=S.GLOBAL_TAG);var I="[".concat(R,"] > ").concat(v);S.ENABLE_CALLBACK&&S.emitter.emit("log","verbose",I),S.ENABLE_VERBOSE&&console.log(I)},S}();_.GLOBAL_TAG="mpegts.js",_.FORCE_GLOBAL_TAG=!1,_.ENABLE_ERROR=!0,_.ENABLE_INFO=!0,_.ENABLE_WARN=!0,_.ENABLE_DEBUG=!0,_.ENABLE_VERBOSE=!0,_.ENABLE_CALLBACK=!1,_.emitter=new(P()),Q.default=_},947:function(se,Q,D){D.r(Q);var X=D(7),P=D.n(X),_=D(856),S=function(){function R(){}return Object.defineProperty(R,"forceGlobalTag",{get:function(){return _.default.FORCE_GLOBAL_TAG},set:function(v){_.default.FORCE_GLOBAL_TAG=v,R._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(R,"globalTag",{get:function(){return _.default.GLOBAL_TAG},set:function(v){_.default.GLOBAL_TAG=v,R._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(R,"enableAll",{get:function(){return _.default.ENABLE_VERBOSE&&_.default.ENABLE_DEBUG&&_.default.ENABLE_INFO&&_.default.ENABLE_WARN&&_.default.ENABLE_ERROR},set:function(v){_.default.ENABLE_VERBOSE=v,_.default.ENABLE_DEBUG=v,_.default.ENABLE_INFO=v,_.default.ENABLE_WARN=v,_.default.ENABLE_ERROR=v,R._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(R,"enableDebug",{get:function(){return _.default.ENABLE_DEBUG},set:function(v){_.default.ENABLE_DEBUG=v,R._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(R,"enableVerbose",{get:function(){return _.default.ENABLE_VERBOSE},set:function(v){_.default.ENABLE_VERBOSE=v,R._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(R,"enableInfo",{get:function(){return _.default.ENABLE_INFO},set:function(v){_.default.ENABLE_INFO=v,R._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(R,"enableWarn",{get:function(){return _.default.ENABLE_WARN},set:function(v){_.default.ENABLE_WARN=v,R._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(R,"enableError",{get:function(){return _.default.ENABLE_ERROR},set:function(v){_.default.ENABLE_ERROR=v,R._notifyChange()},enumerable:!1,configurable:!0}),R.getConfig=function(){return{globalTag:_.default.GLOBAL_TAG,forceGlobalTag:_.default.FORCE_GLOBAL_TAG,enableVerbose:_.default.ENABLE_VERBOSE,enableDebug:_.default.ENABLE_DEBUG,enableInfo:_.default.ENABLE_INFO,enableWarn:_.default.ENABLE_WARN,enableError:_.default.ENABLE_ERROR,enableCallback:_.default.ENABLE_CALLBACK}},R.applyConfig=function(v){_.default.GLOBAL_TAG=v.globalTag,_.default.FORCE_GLOBAL_TAG=v.forceGlobalTag,_.default.ENABLE_VERBOSE=v.enableVerbose,_.default.ENABLE_DEBUG=v.enableDebug,_.default.ENABLE_INFO=v.enableInfo,_.default.ENABLE_WARN=v.enableWarn,_.default.ENABLE_ERROR=v.enableError,_.default.ENABLE_CALLBACK=v.enableCallback},R._notifyChange=function(){var v=R.emitter;if(v.listenerCount("change")>0){var I=R.getConfig();v.emit("change",I)}},R.registerListener=function(v){R.emitter.addListener("change",v)},R.removeListener=function(v){R.emitter.removeListener("change",v)},R.addLogListener=function(v){_.default.emitter.addListener("log",v),_.default.emitter.listenerCount("log")>0&&(_.default.ENABLE_CALLBACK=!0,R._notifyChange())},R.removeLogListener=function(v){_.default.emitter.removeListener("log",v),_.default.emitter.listenerCount("log")===0&&(_.default.ENABLE_CALLBACK=!1,R._notifyChange())},R}();S.emitter=new(P()),Q.default=S},811:function(se,Q,D){D.r(Q);var X=function(){function P(){}return P.install=function(){Object.setPrototypeOf=Object.setPrototypeOf||function(_,S){return _.__proto__=S,_},Object.assign=Object.assign||function(_){if(_==null)throw TypeError("Cannot convert undefined or null to object");for(var S=Object(_),R=1;R0?0|S:0;return this.substring(R,R+_.length)===_}}),typeof self.Promise!="function"&&D(964).polyfill()},P}();X.install(),Q.default=X},861:function(se,Q,D){function X(b){var M={};function C(A){if(M[A])return M[A].exports;var G=M[A]={i:A,id:A,l:!1,loaded:!1,exports:{}};return b[A].call(G.exports,G,G.exports,C),G.l=!0,G.loaded=!0,G.exports}C.m=b,C.c=M,C.d=function(A,G){for(var m in G)C.o(G,m)&&!C.o(A,m)&&Object.defineProperty(A,m,{enumerable:!0,get:G[m]})},C.r=function(A){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})},C.n=function(A){var G=A&&A.__esModule?function(){return A.default}:function(){return A};return C.d(G,{a:G}),G},C.o=function(A,G){return Object.prototype.hasOwnProperty.call(A,G)},C.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||Function("return this")()}catch(A){if(typeof self=="object")return self}}(),C.p="/";var B=C(ENTRY_MODULE);return B.default||B}var P="[\\.|\\-|\\+|\\w|/|@]+",_="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+P+").*?\\)";function S(b){return(b+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function R(b){return!isNaN(1*b)}function v(b,M,C){var B={};B[C]=[];var A=M.toString(),G=A.match(/^(?:function\s*\w*\s*)?\(\s*\w+\s*,\s*\w+\s*,\s*(\w+)\s*\)/);if(!G)return B;for(var m,U=G[1],x=new RegExp("(\\\\n|\\W)"+S(U)+_,"g");m=x.exec(A);)m[3]!=="dll-reference"&&B[C].push(m[3]);for(x=new RegExp("\\("+S(U)+'\\("(dll-reference\\s('+P+'))"\\)\\)'+_,"g");m=x.exec(A);)b[m[2]]||(B[C].push(m[1]),b[m[2]]=D(m[1]).m),B[m[2]]=B[m[2]]||[],B[m[2]].push(m[4]);for(var W=Object.keys(B),L=0;L0},!1)}se.exports=function(b,M){M=M||{};var C={main:D.m},B=M.all?{main:Object.keys(C.main)}:function(x,W){for(var L={main:[W]},u={main:[]},h={main:{}};I(L);)for(var p=Object.keys(L),E=0;E{try{return be(R)}catch{return!1}})){let R=_t(_);if(R)D.push(R)}}if(D.length===0)return null;let X=D.length===1?D[0]:`${String(D[0])} and ${String(D[1])}`;return`This ${se} is ${String(X)}, which this browser cannot decode.${Me?` ${Me}`:""}`}var bi="VLC can — the button is beside Play.";function Ct(_e,be){return ct(_e,be,bi,"channel")}var Ai=[[/\bAFT[A-Z0-9]+\b/i,"firetv"],[/\bKF[A-Z]+\b/,"silk"],[/\bSilk\b/i,"silk"],[/\bAndroid TV\b/i,"androidtv"],[/\bGoogleTV\b/i,"googletv"],[/\bTizen\b/i,"tizen"],[/\bWeb0S\b/i,"webos"],[/\bRoku\b/i,"roku"],[/AppleTV/i,"appletv"],[/\bCrKey\b/i,"chromecast"],[/\bSMART-TV\b/i,"smarttv"],[/\bSmartTV\b/i,"smarttv"]];function Ri(_e){if(!_e)return null;for(let[be,Me]of Ai)if(be.test(_e))return Me;return null}function wt(_e){return Ri(_e)!==null}function It(_e){let be={lazyLoad:!1,autoCleanupSourceBuffer:!0,autoCleanupMaxBackwardDuration:30,autoCleanupMinBackwardDuration:10};if(_e)return{...be,enableStashBuffer:!0,stashInitialSize:393216,liveBufferLatencyChasing:!1,liveBufferLatencyMaxLatency:12,liveBufferLatencyMinRemain:2};return{...be,enableStashBuffer:!1,stashInitialSize:128,liveBufferLatencyChasing:!0,liveBufferLatencyMaxLatency:6,liveBufferLatencyMinRemain:1}}function Ti(){try{return Boolean(Ye.default.getFeatureList().mseLivePlayback)}catch{return!1}}var Bt=3,Li=1500,ki=5000,Di=3,Mi=30000;function Ci(_e,be,Me,se=()=>{}){let Q=It(wt(navigator.userAgent)),D=null,X=!1,P=0,_=null,S=null,R=0,v=-1,I=0,b=()=>{if(_)clearTimeout(_);if(S)clearInterval(S);_=null,S=null},M=()=>{if(!D)return;let U=D;D=null;try{U.destroy()}catch{}},C=(U)=>{if(X)return;X=!0,b(),M(),Me(U)},B=(U)=>{if(X)return;if(P>=Bt)return C(U);P+=1,b(),M(),se(`Reconnecting… (${P}/${Bt})`),_=setTimeout(()=>{if(_=null,!X)G()},Li*2**(P-1))},A=()=>{if(S)clearInterval(S);v=_e.currentTime,I=0,S=setInterval(()=>{if(X||!D)return;if(_e.paused||_e.ended||_e.seeking){I=0,v=_e.currentTime;return}if(_e.currentTime===v){if(I+=1,I>=Di)I=0,B("The stream stopped sending. Try VLC, or press Play again.");return}if(v=_e.currentTime,I=0,P>0&&Date.now()-R>Mi)P=0,se(null)},ki)};function G(){R=Date.now(),D=Ye.default.createPlayer({type:"mpegts",isLive:!0,url:be,withCredentials:!0},Q),D.on(Ye.default.Events.MEDIA_INFO,(U)=>{let x=Ct(U,(W)=>window.MediaSource?.isTypeSupported?.(W)??!1);if(x)C(x)}),D.on(Ye.default.Events.ERROR,(U,x,W)=>{let L=W?.code;if(L===429)return C("The line was busy. Try that again.");if(L===409)return C("Somebody else is watching that line right now. Try again in a bit.");if(L===404)return C("That channel is no longer on your list.");if(L===415)return C("That channel needs a different player. Try VLC.");if(L===502||L===504)return C("Your provider did not send a stream for that channel.");if(U===Ye.default.ErrorTypes.NETWORK_ERROR)return B("The stream stopped. Your provider may have dropped it, or you started another channel somewhere else.");B(x?`That stream could not be played here (${x}). Try VLC.`:"That stream could not be played here. Try VLC.")}),D.attachMediaElement(_e),D.load(),D.play()?.catch(()=>{}),A()}let m=()=>se(null);return _e.addEventListener("playing",m),G(),()=>{X=!0,b(),_e.removeEventListener("playing",m),M(),_e.removeAttribute("src"),_e.load()}}window.__tipoffPlayer={supported:Ti,attach:Ci}; +`}),A=A+"new (("+X.toString().replace("ENTRY_MODULE",JSON.stringify(b))+")({"+B.main.map(function(x){return JSON.stringify(x)+": "+C.main[x].toString()}).join(",")+"}))(self);";var G=new self.Blob([A],{type:"text/javascript"});if(M.bare)return G;var m=(self.URL||self.webkitURL||self.mozURL||self.msURL).createObjectURL(G),U=new self.Worker(m);return U.objectURL=m,U}},403:function(se,Q,D){var X;D.r(Q),function(P){P.ERROR="error",P.SOURCE_OPEN="source_open",P.UPDATE_END="update_end",P.BUFFER_FULL="buffer_full",P.START_STREAMING="start_streaming",P.END_STREAMING="end_streaming"}(X||(X={})),Q.default=X},726:function(se,Q,D){var X;D.r(Q),function(P){P.IO_ERROR="io_error",P.DEMUX_ERROR="demux_error",P.INIT_SEGMENT="init_segment",P.MEDIA_SEGMENT="media_segment",P.LOADING_COMPLETE="loading_complete",P.RECOVERED_EARLY_EOF="recovered_early_eof",P.MEDIA_INFO="media_info",P.METADATA_ARRIVED="metadata_arrived",P.SCRIPTDATA_ARRIVED="scriptdata_arrived",P.TIMED_ID3_METADATA_ARRIVED="timed_id3_metadata_arrived",P.PGS_SUBTITLE_ARRIVED="pgs_subtitle_arrived",P.SYNCHRONOUS_KLV_METADATA_ARRIVED="synchronous_klv_metadata_arrived",P.ASYNCHRONOUS_KLV_METADATA_ARRIVED="asynchronous_klv_metadata_arrived",P.SMPTE2038_METADATA_ARRIVED="smpte2038_metadata_arrived",P.SEI_ARRIVED="sei_arrived",P.SCTE35_METADATA_ARRIVED="scte35_metadata_arrived",P.PES_PRIVATE_DATA_DESCRIPTOR="pes_private_data_descriptor",P.PES_PRIVATE_DATA_ARRIVED="pes_private_data_arrived",P.STATISTICS_INFO="statistics_info",P.RECOMMEND_SEEKPOINT="recommend_seekpoint"}(X||(X={})),Q.default=X},877:function(se,Q,D){D.r(Q);var X=D(856),P=D(947),_=D(867),S=D(403),R=D(346),v=D(527),I=D(726),b=D(117),M=D(355);Q.default=function(C){var B="PlayerEngineWorker",A=function(J,ke){C.postMessage({msg:"logcat_callback",type:J,logcat:ke})}.bind(void 0),G=null,m=null,U=null,x=null,W=!1,L=!1,u=0,h=0,p=!1;function E(){U&&(U.shutdown(),U.destroy(),U=null)}function K(){if(G==null||m==null)throw new _.IllegalStateException("Worker not initialized");if(x)throw new _.IllegalStateException("Transmuxer has been initialized");L||(!m.deferLoadAfterSourceOpen||W?((x=new v.default(G,m)).on(I.default.INIT_SEGMENT,function(J,ke){U.appendInitSegment(ke)}),x.on(I.default.MEDIA_SEGMENT,function(J,ke){U.appendMediaSegment(ke),C.postMessage({msg:"buffered_position_changed",buffered_position_milliseconds:ke.info.endDts})}),x.on(I.default.LOADING_COMPLETE,function(){U.endOfStream(),C.postMessage({msg:"player_event",event:b.default.LOADING_COMPLETE})}),x.on(I.default.RECOVERED_EARLY_EOF,function(){C.postMessage({msg:"player_event",event:b.default.RECOVERED_EARLY_EOF})}),x.on(I.default.IO_ERROR,function(J,ke){C.postMessage({msg:"player_event",event:b.default.ERROR,error_type:M.ErrorTypes.NETWORK_ERROR,error_detail:J,info:ke})}),x.on(I.default.DEMUX_ERROR,function(J,ke){C.postMessage({msg:"player_event",event:b.default.ERROR,error_type:M.ErrorTypes.MEDIA_ERROR,error_detail:J,info:ke})}),x.on(I.default.MEDIA_INFO,function(J){ee(I.default.MEDIA_INFO,J)}),x.on(I.default.STATISTICS_INFO,function(J){ee(I.default.STATISTICS_INFO,J)}),x.on(I.default.RECOMMEND_SEEKPOINT,function(J){(function(ke){C.postMessage({msg:"transmuxing_event",event:I.default.RECOMMEND_SEEKPOINT,milliseconds:ke})})(J)}),x.on(I.default.METADATA_ARRIVED,function(J){Re(b.default.METADATA_ARRIVED,J)}),x.on(I.default.SCRIPTDATA_ARRIVED,function(J){Re(b.default.SCRIPTDATA_ARRIVED,J)}),x.on(I.default.TIMED_ID3_METADATA_ARRIVED,function(J){Re(b.default.TIMED_ID3_METADATA_ARRIVED,J)}),x.on(I.default.PGS_SUBTITLE_ARRIVED,function(J){Re(b.default.PGS_SUBTITLE_ARRIVED,J)}),x.on(I.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,function(J){Re(b.default.SYNCHRONOUS_KLV_METADATA_ARRIVED,J)}),x.on(I.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,function(J){Re(b.default.ASYNCHRONOUS_KLV_METADATA_ARRIVED,J)}),x.on(I.default.SMPTE2038_METADATA_ARRIVED,function(J){Re(b.default.SMPTE2038_METADATA_ARRIVED,J)}),x.on(I.default.SEI_ARRIVED,function(J){Re(b.default.SEI_ARRIVED,J)}),x.on(I.default.SCTE35_METADATA_ARRIVED,function(J){Re(b.default.SCTE35_METADATA_ARRIVED,J)}),x.on(I.default.PES_PRIVATE_DATA_DESCRIPTOR,function(J){Re(b.default.PES_PRIVATE_DATA_DESCRIPTOR,J)}),x.on(I.default.PES_PRIVATE_DATA_ARRIVED,function(J){Re(b.default.PES_PRIVATE_DATA_ARRIVED,J)}),x.open()):L=!0)}function z(){U&&U.flush(),x&&(x.close(),x.destroy(),x=null)}function de(){W=!0,L&&(L=!1,K())}function le(){C.postMessage({msg:"mse_event",event:S.default.UPDATE_END})}function me(){X.default.v(B,"MSE SourceBuffer is full, report to main thread"),C.postMessage({msg:"mse_event",event:S.default.BUFFER_FULL})}function te(J){C.postMessage({msg:"player_event",event:b.default.ERROR,error_type:M.ErrorTypes.MEDIA_ERROR,error_detail:M.ErrorTypes.MEDIA_MSE_ERROR,info:J})}function ee(J,ke){C.postMessage({msg:"transmuxing_event",event:J,info:ke})}function Re(J,ke){C.postMessage({msg:"player_event",event:J,extraData:ke})}C.addEventListener("message",function(J){if(!p){var ke=J.data;switch(ke.cmd){case"logging_config":var k=ke;P.default.applyConfig(k.logging_config),k.logging_config.enableCallback===!0?P.default.addLogListener(A):P.default.removeLogListener(A);break;case"init":G=(k=ke).media_data_source,m=k.config;break;case"destroy":x&&z(),U&&E(),p=!0,C.postMessage({msg:"destroyed"});break;case"initialize_mse":(function(){X.default.v(B,"Initializing MediaSource in DedicatedWorker"),(U=new R.default(m)).on(S.default.SOURCE_OPEN,de.bind(this)),U.on(S.default.UPDATE_END,le.bind(this)),U.on(S.default.BUFFER_FULL,me.bind(this)),U.on(S.default.ERROR,te.bind(this)),U.initialize({getCurrentTime:function(){return u},getReadyState:function(){return h}});var c=U.getHandle();C.postMessage({msg:"mse_init",handle:c},[c])})();break;case"shutdown_mse":E();break;case"load":K();break;case"unload":z();break;case"unbuffered_seek":k=ke,U.flush(),x.seek(k.milliseconds);break;case"timeupdate":u=(k=ke).current_time;break;case"readystatechange":h=(k=ke).ready_state;break;case"pause_transmuxer":x.pause();break;case"resume_transmuxer":x.resume()}}})}},117:function(se,Q,D){var X;D.r(Q),function(P){P.ERROR="error",P.LOADING_COMPLETE="loading_complete",P.RECOVERED_EARLY_EOF="recovered_early_eof",P.MEDIA_INFO="media_info",P.METADATA_ARRIVED="metadata_arrived",P.SCRIPTDATA_ARRIVED="scriptdata_arrived",P.TIMED_ID3_METADATA_ARRIVED="timed_id3_metadata_arrived",P.PGS_SUBTITLE_ARRIVED="pgs_subtitle_arrived",P.SYNCHRONOUS_KLV_METADATA_ARRIVED="synchronous_klv_metadata_arrived",P.ASYNCHRONOUS_KLV_METADATA_ARRIVED="asynchronous_klv_metadata_arrived",P.SMPTE2038_METADATA_ARRIVED="smpte2038_metadata_arrived",P.SEI_ARRIVED="sei_arrived",P.SCTE35_METADATA_ARRIVED="scte35_metadata_arrived",P.PES_PRIVATE_DATA_DESCRIPTOR="pes_private_data_descriptor",P.PES_PRIVATE_DATA_ARRIVED="pes_private_data_arrived",P.STATISTICS_INFO="statistics_info",P.DESTROYING="destroying"}(X||(X={})),Q.default=X}},be={};function Me(se){var Q=be[se];if(Q!==void 0)return Q.exports;var D=be[se]={exports:{}};return _e[se].call(D.exports,D,D.exports,Me),D.exports}return Me.m=_e,Me.n=function(se){var Q=se&&se.__esModule?function(){return se.default}:function(){return se};return Me.d(Q,{a:Q}),Q},Me.d=function(se,Q){if(Array.isArray(Q))for(var D=0;D{try{return be(R)}catch{return!1}})){let R=_t(_);if(R)D.push(R)}}if(D.length===0)return null;let X=D.length===1?D[0]:`${String(D[0])} and ${String(D[1])}`;return`This ${se} is ${String(X)}, which this browser cannot decode.${Me?` ${Me}`:""}`}var bi="VLC can — the button is beside Play.";function Ct(_e,be){return ct(_e,be,bi,"channel")}var Ai=[[/\bAFT[A-Z0-9]+\b/i,"firetv"],[/\bKF[A-Z]+\b/,"silk"],[/\bSilk\b/i,"silk"],[/\bAndroid TV\b/i,"androidtv"],[/\bGoogleTV\b/i,"googletv"],[/\bTizen\b/i,"tizen"],[/\bWeb0S\b/i,"webos"],[/\bRoku\b/i,"roku"],[/AppleTV/i,"appletv"],[/\bCrKey\b/i,"chromecast"],[/\bSMART-TV\b/i,"smarttv"],[/\bSmartTV\b/i,"smarttv"]];function Ri(_e){if(!_e)return null;for(let[be,Me]of Ai)if(be.test(_e))return Me;return null}function wt(_e){return Ri(_e)!==null}function It(_e){let be={lazyLoad:!1,autoCleanupSourceBuffer:!0,autoCleanupMaxBackwardDuration:30,autoCleanupMinBackwardDuration:10};if(_e)return{...be,enableStashBuffer:!0,stashInitialSize:393216,liveBufferLatencyChasing:!1,liveBufferLatencyMaxLatency:12,liveBufferLatencyMinRemain:2};return{...be,liveBufferLatencyChasing:!1,liveSync:!0,liveSyncMaxLatency:6,liveSyncTargetLatency:3,liveSyncPlaybackRate:1.1,enableStashBuffer:!0,stashInitialSize:131072}}function Ti(){try{return Boolean(Ye.default.getFeatureList().mseLivePlayback)}catch{return!1}}var Bt=3,Li=1500,ki=5000,Di=3,Mi=30000;function Ci(_e,be,Me,se=()=>{}){let Q=It(wt(navigator.userAgent)),D=null,X=!1,P=0,_=null,S=null,R=0,v=-1,I=0,b=()=>{if(_)clearTimeout(_);if(S)clearInterval(S);_=null,S=null},M=()=>{if(!D)return;let U=D;D=null;try{U.destroy()}catch{}},C=(U)=>{if(X)return;X=!0,b(),M(),Me(U)},B=(U)=>{if(X)return;if(P>=Bt)return C(U);P+=1,b(),M(),se(`Reconnecting… (${P}/${Bt})`),_=setTimeout(()=>{if(_=null,!X)G()},Li*2**(P-1))},A=()=>{if(S)clearInterval(S);v=_e.currentTime,I=0,S=setInterval(()=>{if(X||!D)return;if(_e.paused||_e.ended||_e.seeking){I=0,v=_e.currentTime;return}if(_e.currentTime===v){if(I+=1,I>=Di)I=0,B("The stream stopped sending. Try VLC, or press Play again.");return}if(v=_e.currentTime,I=0,P>0&&Date.now()-R>Mi)P=0,se(null)},ki)};function G(){R=Date.now(),D=Ye.default.createPlayer({type:"mpegts",isLive:!0,url:be,withCredentials:!0},Q),D.on(Ye.default.Events.MEDIA_INFO,(U)=>{let x=Ct(U,(W)=>window.MediaSource?.isTypeSupported?.(W)??!1);if(x)C(x)}),D.on(Ye.default.Events.ERROR,(U,x,W)=>{let L=W?.code;if(L===429)return C("The line was busy. Try that again.");if(L===409)return C("Somebody else is watching that line right now. Try again in a bit.");if(L===404)return C("That channel is no longer on your list.");if(L===415)return C("That channel needs a different player. Try VLC.");if(L===502||L===504)return C("Your provider did not send a stream for that channel.");if(U===Ye.default.ErrorTypes.NETWORK_ERROR)return B("The stream stopped. Your provider may have dropped it, or you started another channel somewhere else.");B(x?`That stream could not be played here (${x}). Try VLC.`:"That stream could not be played here. Try VLC.")}),D.attachMediaElement(_e),D.load(),D.play()?.catch(()=>{}),A()}let m=()=>se(null);return _e.addEventListener("playing",m),G(),()=>{X=!0,b(),_e.removeEventListener("playing",m),M(),_e.removeAttribute("src"),_e.load()}}window.__tipoffPlayer={supported:Ti,attach:Ci}; diff --git a/apps/web/src/client/tv.js b/apps/web/src/client/tv.js index 412bc6b..295b09c 100644 --- a/apps/web/src/client/tv.js +++ b/apps/web/src/client/tv.js @@ -4,14 +4,19 @@ * Asked for one reason: a Fire TV stick and a laptop want opposite things from * the same live stream, and the player has been tuned for the laptop. * - * On a desktop the connection is fast and steady, so reading ahead is wasted - * latency and chasing the live edge keeps a match from drifting minutes behind. - * On a stick behind household wifi, decoding a transport stream on a CPU an order - * of magnitude slower, both of those choices are actively harmful: with no - * read-ahead buffer every jitter spike is a stall, and latency chasing answers a - * stall by seeking forward, which is a stall the reader can see. The stream stops - * and starts until it is abandoned, which is what "it does not play on Silk" - * looks like from the sofa. + * A stick behind household wifi, decoding a transport stream on a CPU an order of + * magnitude slower, needs a read-ahead buffer to survive a jitter spike, and needs + * whatever closes the gap to the live edge to not do it by seeking -- a seek during + * a live stream is a rebuffer the viewer sees. Without both it stops and starts + * until it is abandoned, which is what "it does not play on Silk" looks like from + * the sofa. + * + * A desktop wants a smaller version of the same thing, not the opposite of it. It + * was given the opposite -- no buffer at all, and drift closed by seeking -- and + * that was its own kind of stutter: see the desktop branch below, where the whole + * sawtooth is written out. Both screens now read ahead and neither seeks; they + * differ in how much they hold and how close they sit to the edge, which is the + * only thing the device should have been deciding. * * So the buffering profile is picked per screen. There is no feature to detect * here -- the difference is the device, not the API surface -- so this is a user @@ -69,9 +74,8 @@ export function isTvBrowser(userAgent) { /** * mpegts.js settings for one screen or the other. * - * Everything here except the two buffering decisions is the same on both, and the - * comments on those live with the values rather than in the caller, because the - * reason a value differs is the only interesting thing about it. + * The comments live with the values rather than in the caller, because the reason + * a value differs between the two is the only interesting thing about it. * * @param {boolean} isTv */ @@ -103,11 +107,20 @@ export function playerConfig(isTv) { * a wifi hiccup and a stall, so it is on and generously sized. 384KB is * mpegts.js's own default and roughly a second of a broadcast bitrate. * - * Latency chasing is off for the same reason it is on below. Its answer to + * Latency chasing is off, and is now off on both screens. Its answer to * drift is to seek the media element forward; on a link that drifts because * it is struggling, that is a seek every few seconds, and a seek during a * live stream is a rebuffer. Being ten seconds behind is not a complaint * anybody makes. Stopping every ten seconds is. + * + * Nothing replaces it here. The desktop closes its drift with liveSync, but + * a stick is behind because it is struggling, and asking a CPU that is + * barely keeping up to decode at 1.1x is how you turn a slow stream into a + * stopped one. A television is allowed to run late. + * + * The two `liveBufferLatency*` numbers below are inert while chasing is off. + * They are kept because they are the bound anyone re-enabling it would want, + * and a bare `false` gives the next person nothing to reason from. */ enableStashBuffer: true, stashInitialSize: 384 * 1024, @@ -120,18 +133,50 @@ export function playerConfig(isTv) { return { ...shared, /* - * Live settings for a screen with a real connection, and each one is - * load-bearing. + * Live settings for a screen with a real connection. + * + * These used to be the opposite of the television's on every line, on the + * reasoning that a laptop has bandwidth to spare and should therefore sit as + * close to the live edge as it can. The first half of that is true and the + * second half is what made the picture stutter, because of how mpegts.js + * closes the gap when it decides you have drifted. + * + * `liveBufferLatencyChasing` -- which the library's own source calls "not + * recommended" in the first line of the file that implements it -- answers + * drift by assigning to `currentTime`. That is a hard seek, and a hard seek + * on Media Source Extensions tears down the decode pipeline and builds it + * again: one visible hitch, every time it fires. It is evaluated on every + * buffered range update, so on every appended fragment, and it fires whenever + * the buffer is more than `MaxLatency` ahead -- leaving `MinRemain` behind, + * which was one second. One second of buffer is one jitter spike from an + * underrun, the underrun refills past six seconds, and it seeks again. That + * sawtooth is what "choppy" was: not a slow connection and not the provider, + * but the player repeatedly throwing away the buffer that would have covered + * for both. + * + * So the seek is gone and `liveSync` does the same job the way a live player + * is supposed to: when it is more than six seconds behind it plays at 1.1x + * until it is back within three, and then returns to 1x. Nothing is + * discarded, nothing rebuffers, and 1.1x is slight enough that the pitch + * shift is not something a viewer notices -- 1.2, the library default, is. + */ + liveBufferLatencyChasing: false, + liveSync: true, + liveSyncMaxLatency: 6, + liveSyncTargetLatency: 3, + liveSyncPlaybackRate: 1.1, + /* + * And a stash, which is the other half of the same answer. * - * The stash exists to smooth a seekable file; here it is pure added latency, - * so it is off and the initial chunk is small. Latency chasing skips the - * player forward when it drifts behind -- without it a stall during a goal is - * never recovered from, the stream just plays permanently late. + * The stash is a read-ahead buffer in front of the demuxer. It was off here + * because it costs latency, and that was the right trade only while chasing + * was going to throw the buffer away anyway. A transport stream arriving + * through the proxy is delivered in bursts -- the provider's pacing, not + * ours -- and with no stash each burst is demuxed the instant it lands and + * each gap between bursts is an underrun. A third of the television's stash + * absorbs the gap; liveSync gives the latency back. */ - enableStashBuffer: false, - stashInitialSize: 128, - liveBufferLatencyChasing: true, - liveBufferLatencyMaxLatency: 6, - liveBufferLatencyMinRemain: 1, + enableStashBuffer: true, + stashInitialSize: 128 * 1024, }; } diff --git a/test/player-codecs.test.js b/test/player-codecs.test.js index d0553df..8c5cbb5 100644 --- a/test/player-codecs.test.js +++ b/test/player-codecs.test.js @@ -279,12 +279,51 @@ describe('the buffering profile follows the screen', () => { expect(tv.liveBufferLatencyChasing).toBe(false); }); - test('everything else keeps the settings it already had', () => { - // Changing the desktop profile was not the point and would be a regression. + test('a desktop reads ahead too, just less of it', () => { + // It used to run with no stash at all, on the theory that a laptop has + // bandwidth to spare. A transport stream arrives through the proxy in bursts + // whatever the bandwidth is, and with nothing in front of the demuxer each + // gap between bursts was an underrun. const desktop = playerConfig(false); - expect(desktop.enableStashBuffer).toBe(false); - expect(desktop.liveBufferLatencyChasing).toBe(true); - expect(desktop.liveBufferLatencyMaxLatency).toBe(6); + const tv = playerConfig(true); + expect(desktop.enableStashBuffer).toBe(true); + expect(desktop.stashInitialSize).toBeGreaterThan(64 * 1024); + expect(desktop.stashInitialSize).toBeLessThan(tv.stashInitialSize); + }); + + test('neither screen closes drift by seeking', () => { + /* + * This is the bug the desktop profile actually had, and it is worth stating + * as a rule rather than as a number. + * + * liveBufferLatencyChasing assigns to currentTime. That is a hard seek, it is + * evaluated on every appended fragment, and it leaves only liveBufferLatency- + * MinRemain seconds of buffer behind -- one second, as it was configured. One + * second is a single jitter spike from an underrun; the underrun refills past + * the six second ceiling; it seeks again. The picture hitches on every one of + * those seeks, which is what a viewer reports as choppy. + */ + for (const config of [playerConfig(true), playerConfig(false)]) { + expect(config.liveBufferLatencyChasing).toBe(false); + } + }); + + test('the desktop closes drift by playing slightly fast instead', () => { + // liveSync is the same correction without the seek: over the ceiling it plays + // at 1.1x until it is back to target, then returns to 1x. Nothing is + // discarded and nothing rebuffers. + const desktop = playerConfig(false); + expect(desktop.liveSync).toBe(true); + expect(desktop.liveSyncTargetLatency).toBeLessThan(desktop.liveSyncMaxLatency); + // Above 1 or it never catches up; 1.2 is the library default and is audible. + expect(desktop.liveSyncPlaybackRate).toBeGreaterThan(1); + expect(desktop.liveSyncPlaybackRate).toBeLessThan(1.2); + }); + + test('a television is allowed to run late rather than hurried', () => { + // Asking a CPU that is barely keeping up to decode faster is how a slow + // stream becomes a stopped one, so the stick gets no liveSync either. + expect(playerConfig(true).liveSync).toBeFalsy(); }); test('both profiles still drop what has been watched', () => { From 577deedacd22d8ef17be62d378b90ae7604cd70b Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Sun, 30 Aug 2026 03:07:45 +0000 Subject: [PATCH 2/2] Match media-streamer's live TV player, and go fullscreen on Play Streams died after a minute or two here while media-streamer played the same provider lines all evening. Comparing the two players says why, and it was not the demuxer. **The restart budget almost never came back, and that is what killed them.** It refilled only after thirty unbroken seconds, measured from the last restart and checked solely from inside the stall watcher. Three hiccups within half a minute therefore spent the whole allowance and the channel was given up on permanently -- even though all three restarts had worked and the picture was back within seconds each time. On a provider line that drops a connection now and then, which is all of them, that is a hard ceiling of three recoveries per stream, and reaching it takes about a minute. It now refills on `playing`, which is what media-streamer's live TV player does and is the right event: it fires when the media element genuinely resumed, so the budget is spent by failures to RECOVER rather than by failures. A channel that never plays still gives up after MAX_RESTARTS, because nothing ever fires it. MAX_RESTARTS goes 3 -> 5 and the backoff base 1.5s -> 2s to match. **The desktop buffering profile was the opposite of the one that works.** One profile now, media-streamer's, on every screen: worker on, 384KB stash, chasing off, lazyLoad off. The desktop half used to run with no stash (`stashInitialSize: 128` -- bytes) and `liveBufferLatencyChasing: true`, which closes drift by assigning to `currentTime`. That is a hard seek, MSE rebuilds the decode pipeline on each one, it is evaluated on every appended fragment, and it leaves one second of buffer behind -- so a jitter spike underruns, the refill passes the ceiling, and it seeks again. Every hitch in that sawtooth was also a chance to spend a restart, which is how a stutter became a stream that ended. A television already had all three settings right, which is why only desktops complained. This supersedes the liveSync approach in the first commit on this branch: liveSync is arguably gentler, but "the same as media-streamer" is the thing worth having, and chasing is off either way. **Pressing Play now fills the screen with the sound up.** The video still starts muted -- autoplay policy refuses audible video without a gesture and the refusal is a rejected play() that leaves a black rectangle, and this handler has already awaited the player bundle, which on a cold cache can outlast the activation the click granted. So the sound goes up on the first `playing` instead, and if the browser answers that by pausing (which is how Chrome disagrees) it goes back to muted and keeps the picture. Fullscreen is requested on the stage rather than the