· 6 years ago · Sep 06, 2019, 02:24 AM
1new ((function u(r){var n={};function i(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.m=r,i.c=n,i.i=function(e){return e},i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},i.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i.oe=function(e){throw console.error(e),e};var e=i(i.s="./src/demux/demuxer-worker.js");return e.default||e})({"./src/demux/demuxer-worker.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var a=r("./src/demux/demuxer-inline.js"),s=r("./src/events.js"),u=r("./src/utils/logger.js"),c=r("./node_modules/node-libs-browser/node_modules/events/events.js");t.default=function(i){var n=new c.EventEmitter;n.trigger=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];n.emit.apply(n,[e,e].concat(t))},n.off=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];n.removeListener.apply(n,[e].concat(t))};function o(e,t){i.postMessage({event:e,data:t})}i.addEventListener("message",function(e){var t=e.data;switch(t.cmd){case"init":var r=JSON.parse(t.config);i.demuxer=new a.default(n,t.typeSupported,r,t.vendor),u.enableLogs(r.debug),o("init",null);break;case"demux":i.demuxer.push(t.data,t.decryptdata,t.initSegment,t.audioCodec,t.videoCodec,t.timeOffset,t.discontinuity,t.trackSwitch,t.contiguous,t.duration,t.accurateTimeOffset,t.defaultInitPTS)}}),n.on(s.default.FRAG_DECRYPTED,o),n.on(s.default.FRAG_PARSING_INIT_SEGMENT,o),n.on(s.default.FRAG_PARSED,o),n.on(s.default.ERROR,o),n.on(s.default.FRAG_PARSING_METADATA,o),n.on(s.default.FRAG_PARSING_USERDATA,o),n.on(s.default.INIT_PTS_FOUND,o),n.on(s.default.FRAG_PARSING_DATA,function(e,t){var r=[],n={event:e,data:t};t.data1&&(n.data1=t.data1.buffer,r.push(t.data1.buffer),delete t.data1),t.data2&&(n.data2=t.data2.buffer,r.push(t.data2.buffer),delete t.data2),i.postMessage(n,r)})}},"./node_modules/node-libs-browser/node_modules/events/events.js": function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function u(e){return"function"==typeof e}function c(e){return"object"==typeof e&&null!==e}function l(e){return void 0===e}((e.exports=n).EventEmitter=n).prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!function(e){return"number"==typeof e}(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,i,o,a;if(this._events||(this._events={}),"error"===e&&(!this._events.error||c(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var s=new Error('Uncaught, unspecified "error" event. ('+t+")");throw s.context=t,s}if(l(r=this._events[e]))return!1;if(u(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(c(r))for(i=Array.prototype.slice.call(arguments,1),n=(a=r.slice()).length,o=0;o<n;o++)a[o].apply(this,i);return!0},n.prototype.on=n.prototype.addListener=function(e,t){var r;if(!u(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,u(t.listener)?t.listener:t),this._events[e]?c(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,c(this._events[e])&&!this._events[e].warned&&(r=l(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&0<r&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.once=function(e,t){if(!u(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,i,o;if(!u(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=(r=this._events[e]).length,n=-1,r===t||u(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(c(r)){for(o=i;0<o--;)if(r[o]===t||r[o].listener&&r[o].listener===t){n=o;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(u(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?u(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(u(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},"./src/utils/logger.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r("./src/utils/get-self-scope.js");function i(){}var o={trace:i,debug:i,log:i,warn:i,info:i,error:i},a=o;var s=n.getSelfScope();function u(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];e.forEach(function(e){a[e]=t[e]?t[e].bind(t):function(r){var n=s.console[r];return n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];e[0]&&(e[0]=function(e,t){return t="["+e+"] > "+t}(r,e[0])),n.apply(s.console,e)}:i}(e)})}t.enableLogs=function(e){if(!0===e||"object"==typeof e){u(e,"debug","log","info","warn","error");try{a.log()}catch(e){a=o}}else a=o},t.logger=a},"./src/utils/get-self-scope.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.getSelfScope=function(){return"undefined"==typeof window?self:window}},"./src/events.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"}},"./src/demux/demuxer-inline.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var v,S=r("./src/events.js"),T=r("./src/errors.js"),g=r("./src/crypt/decrypter.js"),C=r("./src/demux/aacdemuxer.js"),O=r("./src/demux/mp4demuxer.js"),A=r("./src/demux/tsdemuxer.js"),x=r("./src/demux/mp3demuxer.js"),D=r("./src/remux/mp4-remuxer.js"),P=r("./src/remux/passthrough-remuxer.js"),n=r("./src/utils/get-self-scope.js"),i=r("./src/utils/logger.js"),o=n.getSelfScope();try{v=o.performance.now.bind(o.performance)}catch(e){i.logger.debug("Unable to use Performance API on this environment"),v=o.Date.now}var a=(s.prototype.destroy=function(){var e=this.demuxer;e&&e.destroy()},s.prototype.push=function(e,r,n,i,o,a,s,u,c,l,f,p){var h=this;if(0<e.byteLength&&null!=r&&null!=r.key&&"AES-128"===r.method){var t=this.decrypter;null==t&&(t=this.decrypter=new g.default(this.observer,this.config));var d=v();t.decrypt(e,r.key.buffer,r.iv.buffer,function(e){var t=v();h.observer.trigger(S.default.FRAG_DECRYPTED,{stats:{tstart:d,tdecrypt:t}}),h.pushDecrypted(new Uint8Array(e),r,new Uint8Array(n),i,o,a,s,u,c,l,f,p)})}else this.pushDecrypted(new Uint8Array(e),r,new Uint8Array(n),i,o,a,s,u,c,l,f,p)},s.prototype.pushDecrypted=function(e,t,r,n,i,o,a,s,u,c,l,f){var p=this.demuxer;if(!p||(a||s)&&!this.probe(e)){for(var h=this.observer,d=this.typeSupported,v=this.config,g=[{demux:A.default,remux:D.default},{demux:O.default,remux:P.default},{demux:C.default,remux:D.default},{demux:x.default,remux:D.default}],y=0,m=g.length;y<m;y++){var _=g[y],b=_.demux.probe;if(b(e)){var w=this.remuxer=new _.remux(h,v,d,this.vendor);p=new _.demux(h,w,v,d),this.probe=b;break}}if(!p)return void h.trigger(S.default.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=p}var E=this.remuxer;(a||s)&&(p.resetInitSegment(r,n,i,c),E.resetInitSegment()),a&&(p.resetTimeStamp(f),E.resetTimeStamp(f)),"function"==typeof p.setDecryptData&&p.setDecryptData(t),p.append(e,o,u,l)},s);function s(e,t,r,n){this.observer=e,this.typeSupported=t,this.config=r,this.vendor=n}t.default=a},"./src/remux/passthrough-remuxer.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var l=r("./src/events.js"),n=(i.prototype.destroy=function(){},i.prototype.resetTimeStamp=function(){},i.prototype.resetInitSegment=function(){},i.prototype.remux=function(e,t,r,n,i,o,a,s){var u=this.observer,c="";e&&(c+="audio"),t&&(c+="video"),u.trigger(l.default.FRAG_PARSING_DATA,{data1:s,startPTS:i,startDTS:i,type:c,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),u.trigger(l.default.FRAG_PARSED)},i);function i(e){this.observer=e}t.default=n},"./src/remux/mp4-remuxer.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var q=r("./src/remux/aac-helper.js"),Q=r("./src/remux/mp4-generator.js"),Z=r("./src/events.js"),$=r("./src/errors.js"),X=r("./src/utils/logger.js"),n=(i.prototype.destroy=function(){},i.prototype.resetTimeStamp=function(e){this._initPTS=this._initDTS=e},i.prototype.resetInitSegment=function(){this.ISGenerated=!1},i.prototype.remux=function(e,t,r,n,i,o,a){if(this.ISGenerated||this.generateIS(e,t,i),this.ISGenerated){var s=e.samples.length,u=t.samples.length,c=i,l=i;if(s&&u){var f=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;c+=Math.max(0,f),l+=Math.max(0,-f)}if(s){e.timescale||(X.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,i));var p=this.remuxAudio(e,c,o,a);if(u){var h=void 0;p&&(h=p.endPTS-p.startPTS),t.timescale||(X.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,i)),this.remuxVideo(t,l,o,h,a)}}else if(u){var d=this.remuxVideo(t,l,o,0,a);d&&e.codec&&this.remuxEmptyAudio(e,c,o,d)}}r.samples.length&&this.remuxID3(r,i),n.samples.length&&this.remuxText(n,i),this.observer.trigger(Z.default.FRAG_PARSED)},i.prototype.generateIS=function(e,t,r){var n,i,o=this.observer,a=e.samples,s=t.samples,u=this.typeSupported,c="audio/mp4",l={},f={tracks:l},p=void 0===this._initPTS;if(p&&(n=i=1/0),e.config&&a.length&&(e.timescale=e.samplerate,X.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(u.mpeg?(c="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3")),l.audio={container:c,codec:e.codec,initSegment:!e.isAAC&&u.mpeg?new Uint8Array:Q.default.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(n=i=a[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&s.length){var h=t.inputTimeScale;t.timescale=h,l.video={container:"video/mp4",codec:t.codec,initSegment:Q.default.initSegment([t]),metadata:{width:t.width,height:t.height}},p&&(n=Math.min(n,s[0].pts-h*r),i=Math.min(i,s[0].dts-h*r),this.observer.trigger(Z.default.INIT_PTS_FOUND,{initPTS:n}))}Object.keys(l).length?(o.trigger(Z.default.FRAG_PARSING_INIT_SEGMENT,f),this.ISGenerated=!0,p&&(this._initPTS=n,this._initDTS=i)):o.trigger(Z.default.ERROR,{type:$.ErrorTypes.MEDIA_ERROR,details:$.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},i.prototype.remuxVideo=function(e,t,r,n,i){var o,a,s,u,c,l,f,p=8,h=e.timescale,d=e.samples,v=[],g=d.length,y=this._PTSNormalize,m=this._initPTS,_=this.nextAvcDts,b=this.isSafari;if(0!==g){b&&(r|=d.length&&_&&(i&&Math.abs(t-_/h)<.1||Math.abs(d[0].pts-_-m)<h/5)),r||(_=t*h),d.forEach(function(e){e.pts=y(e.pts-m,_),e.dts=y(e.dts-m,_)}),d.sort(function(e,t){var r=e.dts-t.dts,n=e.pts-t.pts;return r||n||e.id-t.id});var w=d.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-18e3)},0);if(w<0){X.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(w/90)+" ms to overcome this issue");for(var E=0;E<d.length;E++)d[E].dts+=w}var S=d[0];c=Math.max(S.dts,0),u=Math.max(S.pts,0);var T=Math.round((c-_)/90);r&&T&&(1<T?X.logger.log("AVC:"+T+" ms hole between fragments detected,filling it"):T<-1&&X.logger.log("AVC:"+-T+" ms overlapping between fragments detected"),c=_,d[0].dts=c,u=Math.max(u-T,_),d[0].pts=u,X.logger.log("Video/PTS/DTS adjusted: "+Math.round(u/90)+"/"+Math.round(c/90)+",delta:"+T+" ms")),S=d[d.length-1],f=Math.max(S.dts,0),l=Math.max(S.pts,0,f),b&&(o=Math.round((f-c)/(d.length-1)));var C=0,O=0;for(E=0;E<g;E++){for(var A=d[E],x=A.units,D=x.length,P=0,k=0;k<D;k++)P+=x[k].data.length;O+=P,C+=D,A.length=P,A.dts=b?c+E*o:Math.max(A.dts,c),A.pts=Math.max(A.pts,A.dts)}var I=O+4*C+8;try{a=new Uint8Array(I)}catch(e){return void this.observer.trigger(Z.default.ERROR,{type:$.ErrorTypes.MUX_ERROR,details:$.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:I,reason:"fail allocating video mdat "+I})}var R=new DataView(a.buffer);for(R.setUint32(0,I),a.set(Q.default.types.mdat,4),E=0;E<g;E++){var N=d[E],L=N.units,M=0,j=void 0;for(k=0,D=L.length;k<D;k++){var F=L[k],B=F.data,U=F.data.byteLength;R.setUint32(p,U),p+=4,a.set(B,p),p+=U,M+=4+U}if(b)j=Math.max(0,o*Math.round((N.pts-N.dts)/o));else{if(E<g-1)o=d[E+1].dts-N.dts;else{var V=this.config,H=N.dts-d[0<E?E-1:E].dts;if(V.stretchShortVideoTrack){var q=V.maxBufferHole,W=Math.floor(q*h),G=(n?u+n*h:this.nextAudioPts)-N.pts;W<G?((o=G-H)<0&&(o=H),X.logger.log("It is approximately "+G/90+" ms to the next segment; using duration "+o/90+" ms for the last video frame.")):o=H}else o=H}j=Math.round(N.pts-N.dts)}v.push({size:M,duration:o,cts:j,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:N.key?2:1,isNonSync:N.key?0:1}})}this.nextAvcDts=f+o;var z=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,v.length&&-1<navigator.userAgent.toLowerCase().indexOf("chrome")){var K=v[0].flags;K.dependsOn=2,K.isNonSync=0}e.samples=v,s=Q.default.moof(e.sequenceNumber++,c,e),e.samples=[];var Y={data1:s,data2:a,startPTS:u/h,endPTS:(l+o)/h,startDTS:c/h,endDTS:this.nextAvcDts/h,type:"video",hasAudio:!1,hasVideo:!0,nb:v.length,dropped:z};return this.observer.trigger(Z.default.FRAG_PARSING_DATA,Y),Y}},i.prototype.remuxAudio=function(e,t,r,n){var i,o,a,s,u,c,l,f=e.inputTimeScale,p=e.timescale,h=f/p,d=(e.isAAC?1024:1152)*h,v=this._PTSNormalize,g=this._initPTS,y=!e.isAAC&&this.typeSupported.mpeg,m=e.samples,_=[],b=this.nextAudioPts;if(r|=m.length&&b&&(n&&Math.abs(t-b/f)<.1||Math.abs(m[0].pts-b-g)<20*d),m.forEach(function(e){e.pts=e.dts=v(e.pts-g,t*f)}),0!==(m=m.filter(function(e){return 0<=e.pts})).length){if(r||(b=n?t*f:m[0].pts),e.isAAC)for(var w=this.config.maxAudioFramesDrift,E=0,S=b;E<m.length;){var T,C=m[E];T=(R=C.pts)-S;var O=Math.abs(1e3*T/f);if(T<=-w*d)X.logger.warn("Dropping 1 audio frame @ "+(S/f).toFixed(3)+"s due to "+Math.round(O)+" ms overlap."),m.splice(E,1),e.len-=C.unit.length;else if(w*d<=T&&O<1e4&&S){var A=Math.round(T/d);X.logger.warn("Injecting "+A+" audio frame @ "+(S/f).toFixed(3)+"s due to "+Math.round(1e3*T/f)+" ms gap.");for(var x=0;x<A;x++){var D=Math.max(S,0);(a=q.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(X.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),a=C.unit.subarray()),m.splice(E,0,{unit:a,pts:D,dts:D}),e.len+=a.length,S+=d,E++}C.pts=C.dts=S,S+=d,E++}else Math.abs(T),C.pts=C.dts=S,S+=d,E++}x=0;for(var P=m.length;x<P;x++){var k=m[x],I=k.unit,R=k.pts;if(void 0!==l)o.duration=Math.round((R-l)/h);else{var N=Math.round(1e3*(R-b)/f),L=0;if(r&&e.isAAC&&N){if(0<N&&N<1e4)L=Math.round((R-b)/d),X.logger.log(N+" ms hole between AAC samples detected,filling it"),0<L&&(a=(a=q.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||I.subarray(),e.len+=L*a.length);else if(N<-12){X.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(b/f).toFixed(3)+"s/"+(R/f).toFixed(3)+"s/"+-N+"ms"),e.len-=I.byteLength;continue}R=b}if(c=R,!(0<e.len))return;var M=y?e.len:e.len+8;i=y?0:8;try{s=new Uint8Array(M)}catch(e){return void this.observer.trigger(Z.default.ERROR,{type:$.ErrorTypes.MUX_ERROR,details:$.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:M,reason:"fail allocating audio mdat "+M})}for(y||(new DataView(s.buffer).setUint32(0,M),s.set(Q.default.types.mdat,4)),E=0;E<L;E++)(a=q.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(X.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),a=I.subarray()),s.set(a,i),i+=a.byteLength,o={size:a.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},_.push(o)}s.set(I,i);var j=I.byteLength;i+=j,o={size:j,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},_.push(o),l=R}var F=0,B=_.length;if(2<=B&&(F=_[B-2].duration,o.duration=F),B){this.nextAudioPts=b=l+h*F,e.len=0,e.samples=_,u=y?new Uint8Array:Q.default.moof(e.sequenceNumber++,c/h,e),e.samples=[];var U=c/f,V=b/f,H={data1:u,data2:s,startPTS:U,endPTS:V,startDTS:U,endDTS:V,type:"audio",hasAudio:!0,hasVideo:!1,nb:B};return this.observer.trigger(Z.default.FRAG_PARSING_DATA,H),H}return null}},i.prototype.remuxEmptyAudio=function(e,t,r,n){var i=e.inputTimeScale,o=i/(e.samplerate?e.samplerate:i),a=this.nextAudioPts,s=(void 0!==a?a:n.startDTS*i)+this._initDTS,u=n.endDTS*i+this._initDTS,c=1024*o,l=Math.ceil((u-s)/c),f=q.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(X.logger.warn("remux empty Audio"),f){for(var p=[],h=0;h<l;h++){var d=s+h*c;p.push({unit:f,pts:d,dts:d}),e.len+=f.length}e.samples=p,this.remuxAudio(e,t,r)}else X.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!")},i.prototype.remuxID3=function(e){var t,r=e.samples.length,n=e.inputTimeScale,i=this._initPTS,o=this._initDTS;if(r){for(var a=0;a<r;a++)(t=e.samples[a]).pts=(t.pts-i)/n,t.dts=(t.dts-o)/n;this.observer.trigger(Z.default.FRAG_PARSING_METADATA,{samples:e.samples})}e.samples=[]},i.prototype.remuxText=function(e){e.samples.sort(function(e,t){return e.pts-t.pts});var t,r=e.samples.length,n=e.inputTimeScale,i=this._initPTS;if(r){for(var o=0;o<r;o++)(t=e.samples[o]).pts=(t.pts-i)/n;this.observer.trigger(Z.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[]},i.prototype._PTSNormalize=function(e,t){var r;if(void 0===t)return e;for(r=t<e?-8589934592:8589934592;4294967296<Math.abs(e-t);)e+=r;return e},i);function i(e,t,r,n){this.observer=e,this.config=t,this.typeSupported=r;var i=navigator.userAgent;this.isSafari=n&&-1<n.indexOf("Apple")&&i&&!i.match("CriOS"),this.ISGenerated=!1}t.default=n},"./src/errors.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",KEY_SYSTEM_ERROR:"keySystemError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},t.ErrorDetails={KEY_SYSTEM_NO_KEYS:"keySystemNoKeys",KEY_SYSTEM_NO_ACCESS:"keySystemNoAccess",KEY_SYSTEM_NO_SESSION:"keySystemNoSession",KEY_SYSTEM_LICENSE_REQUEST_FAILED:"keySystemLicenseRequestFailed",MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",REMUX_ALLOC_ERROR:"remuxAllocError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",BUFFER_NUDGE_ON_STALL:"bufferNudgeOnStall",INTERNAL_EXCEPTION:"internalException"}},"./src/remux/mp4-generator.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var s=Math.pow(2,32)-1,n=(p.init=function(){var e;for(e in p.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]})p.types.hasOwnProperty(e)&&(p.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);p.HDLR_TYPES={video:t,audio:r};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);p.STTS=p.STSC=p.STCO=i,p.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),p.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),p.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),p.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),s=new Uint8Array([0,0,0,1]);p.FTYP=p.box(p.types.ftyp,o,s,o,a),p.DINF=p.box(p.types.dinf,p.box(p.types.dref,n))},p.box=function(e){for(var t,r=Array.prototype.slice.call(arguments,1),n=8,i=r.length,o=i;i--;)n+=r[i].byteLength;for((t=new Uint8Array(n))[0]=n>>24&255,t[1]=n>>16&255,t[2]=n>>8&255,t[3]=255&n,t.set(e,4),i=0,n=8;i<o;i++)t.set(r[i],n),n+=r[i].byteLength;return t},p.hdlr=function(e){return p.box(p.types.hdlr,p.HDLR_TYPES[e])},p.mdat=function(e){return p.box(p.types.mdat,e)},p.mdhd=function(e,t){t*=e;var r=Math.floor(t/(1+s)),n=Math.floor(t%(1+s));return p.box(p.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},p.mdia=function(e){return p.box(p.types.mdia,p.mdhd(e.timescale,e.duration),p.hdlr(e.type),p.minf(e))},p.mfhd=function(e){return p.box(p.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},p.minf=function(e){return"audio"===e.type?p.box(p.types.minf,p.box(p.types.smhd,p.SMHD),p.DINF,p.stbl(e)):p.box(p.types.minf,p.box(p.types.vmhd,p.VMHD),p.DINF,p.stbl(e))},p.moof=function(e,t,r){return p.box(p.types.moof,p.mfhd(e),p.traf(r,t))},p.moov=function(e){for(var t=e.length,r=[];t--;)r[t]=p.trak(e[t]);return p.box.apply(null,[p.types.moov,p.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(p.mvex(e)))},p.mvex=function(e){for(var t=e.length,r=[];t--;)r[t]=p.trex(e[t]);return p.box.apply(null,[p.types.mvex].concat(r))},p.mvhd=function(e,t){t*=e;var r=Math.floor(t/(1+s)),n=Math.floor(t%(1+s)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return p.box(p.types.mvhd,i)},p.sdtp=function(e){var t,r,n=e.samples||[],i=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)t=n[r].flags,i[r+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return p.box(p.types.sdtp,i)},p.stbl=function(e){return p.box(p.types.stbl,p.stsd(e),p.box(p.types.stts,p.STTS),p.box(p.types.stsc,p.STSC),p.box(p.types.stsz,p.STSZ),p.box(p.types.stco,p.STCO))},p.avc1=function(e){var t,r,n,i=[],o=[];for(t=0;t<e.sps.length;t++)n=(r=e.sps[t]).byteLength,i.push(n>>>8&255),i.push(255&n),i=i.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)n=(r=e.pps[t]).byteLength,o.push(n>>>8&255),o.push(255&n),o=o.concat(Array.prototype.slice.call(r));var a=p.box(p.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(o))),s=e.width,u=e.height,c=e.pixelRatio[0],l=e.pixelRatio[1];return p.box(p.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,s>>8&255,255&s,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,p.box(p.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),p.box(p.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,l>>24,l>>16&255,l>>8&255,255&l])))},p.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},p.mp4a=function(e){var t=e.samplerate;return p.box(p.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),p.box(p.types.esds,p.esds(e)))},p.mp3=function(e){var t=e.samplerate;return p.box(p.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},p.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?p.box(p.types.stsd,p.STSD,p.mp4a(e)):p.box(p.types.stsd,p.STSD,p.mp3(e)):p.box(p.types.stsd,p.STSD,p.avc1(e))},p.tkhd=function(e){var t=e.id,r=e.duration*e.timescale,n=e.width,i=e.height,o=Math.floor(r/(1+s)),a=Math.floor(r%(1+s));return p.box(p.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,a>>24,a>>16&255,a>>8&255,255&a,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,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]))},p.traf=function(e,t){var r=p.sdtp(e),n=e.id,i=Math.floor(t/(1+s)),o=Math.floor(t%(1+s));return p.box(p.types.traf,p.box(p.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),p.box(p.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,o>>24,o>>16&255,o>>8&255,255&o])),p.trun(e,r.length+16+20+8+16+8+8),r)},p.trak=function(e){return e.duration=e.duration||4294967295,p.box(p.types.trak,p.tkhd(e),p.mdia(e))},p.trex=function(e){var t=e.id;return p.box(p.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},p.trun=function(e,t){var r,n,i,o,a,s,u=e.samples||[],c=u.length,l=12+16*c,f=new Uint8Array(l);for(t+=8+l,f.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r<c;r++)i=(n=u[r]).duration,o=n.size,a=n.flags,s=n.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,o>>>24&255,o>>>16&255,o>>>8&255,255&o,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,61440&a.degradPrio,15&a.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*r);return p.box(p.types.trun,f)},p.initSegment=function(e){p.types||p.init();var t,r=p.moov(e);return(t=new Uint8Array(p.FTYP.byteLength+r.byteLength)).set(p.FTYP),t.set(r,p.FTYP.byteLength),t},p);function p(){}t.default=n},"./src/remux/aac-helper.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=(i.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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]);break;default:if(1===t)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(2===t)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(3===t)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},i);function i(){}t.default=n},"./src/demux/mp3demuxer.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var d=r("./src/demux/id3.js"),i=r("./src/utils/logger.js"),v=r("./src/demux/mpegaudio.js"),n=(o.prototype.resetInitSegment=function(e,t,r,n){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:n,inputTimeScale:9e4}},o.prototype.resetTimeStamp=function(){},o.probe=function(e){var t,r,n=d.default.getID3Data(e,0);if(n&&void 0!==d.default.getTimeStamp(n))for(t=n.length,r=Math.min(e.length-1,t+100);t<r;t++)if(v.default.probe(e,t))return i.logger.log("MPEG Audio sync word found !"),!0;return!1},o.prototype.append=function(e,t,r,n){for(var i=d.default.getID3Data(e,0),o=d.default.getTimeStamp(i),a=o?90*o:9e4*t,s=i.length,u=e.length,c=0,l=0,f=this._audioTrack,p=[{pts:a,dts:a,data:i}];s<u;)if(v.default.isHeader(e,s)){var h=v.default.appendFrame(f,e,s,a,c);if(!h)break;s+=h.length,l=h.sample.pts,c++}else d.default.isHeader(e,s)?(i=d.default.getID3Data(e,s),p.push({pts:l,dts:l,data:i}),s+=i.length):s++;this.remuxer.remux(f,{samples:[]},{samples:p,inputTimeScale:9e4},{samples:[]},t,r,n)},o.prototype.destroy=function(){},o);function o(e,t,r){this.observer=e,this.config=r,this.remuxer=t}t.default=n},"./src/demux/mpegaudio.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var v={BitratesMap:[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(e,t,r,n,i){if(!(r+24>t.length)){var o=this.parseHeader(t,r);if(o&&r+o.frameLength<=t.length){var a=n+i*(9e4*o.samplesPerFrame/o.sampleRate),s={unit:t.subarray(r,r+o.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=o.channelCount,e.samplerate=o.sampleRate,e.samples.push(s),e.len+=o.frameLength,{sample:s,length:o.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,n=e[t+1]>>1&3,i=e[t+2]>>4&15,o=e[t+2]>>2&3,a=e[t+2]>>1&1;if(1!=r&&0!=i&&15!=i&&3!=o){var s=3==r?3-n:3==n?3:4,u=1e3*v.BitratesMap[14*s+i-1],c=3==r?0:2==r?1:2,l=v.SamplingRateMap[3*c+o],f=e[t+3]>>6==3?1:2,p=v.SamplesCoefficients[r][n],h=v.BytesInSlot[n],d=8*p*h;return{sampleRate:l,channelCount:f,frameLength:parseInt(p*u/l+a,10)*h,samplesPerFrame:d}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1<e.length&&this.isHeaderPattern(e,t))},probe:function(e,t){if(t+1<e.length&&this.isHeaderPattern(e,t)){var r=this.parseHeader(e,t),n=4;r&&r.frameLength&&(n=r.frameLength);var i=t+n;if(i===e.length||i+1<e.length&&this.isHeaderPattern(e,i))return!0}return!1}};t.default=v},"./src/demux/id3.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=(s.isHeader=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},s.isFooter=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},s.getID3Data=function(e,t){for(var r=t,n=0;s.isHeader(e,t);)n+=10,n+=s._readSize(e,t+6),s.isFooter(e,t+10)&&(n+=10),t+=n;if(0<n)return e.subarray(r,r+n)},s._readSize=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},s.getTimeStamp=function(e){for(var t=s.getID3Frames(e),r=0;r<t.length;r++){var n=t[r];if(s.isTimeStampFrame(n))return s._readTimeStamp(n)}},s.isTimeStampFrame=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},s._getFrameData=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=s._readSize(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},s.getID3Frames=function(e){for(var t=0,r=[];s.isHeader(e,t);){for(var n=s._readSize(e,t+6),i=(t+=10)+n;t+8<i;){var o=s._getFrameData(e.subarray(t)),a=s._decodeFrame(o);a&&r.push(a),t+=o.size+10}s.isFooter(e,t)&&(t+=10)}return r},s._decodeFrame=function(e){return"PRIV"===e.type?s._decodePrivFrame(e):"T"===e.type[0]?s._decodeTextFrame(e):"W"===e.type[0]?s._decodeURLFrame(e):void 0},s._readTimeStamp=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,r&&(n+=47721858.84),Math.round(n)}},s._decodePrivFrame=function(e){if(!(e.size<2)){var t=s._utf8ArrayToStr(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},s._decodeTextFrame=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=s._utf8ArrayToStr(e.data.subarray(t));t+=r.length+1;var n=s._utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:n}}var i=s._utf8ArrayToStr(e.data.subarray(1));return{key:e.type,data:i}}},s._decodeURLFrame=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=s._utf8ArrayToStr(e.data.subarray(t));t+=r.length+1;var n=s._utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:n}}var i=s._utf8ArrayToStr(e.data);return{key:e.type,data:i}},s._utf8ArrayToStr=function(e,t){void 0===t&&(t=!1);for(var r,n,i,o=e.length,a="",s=0;s<o;){if(0===(r=e[s++])&&t)return a;if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(r);break;case 12:case 13:n=e[s++],a+=String.fromCharCode((31&r)<<6|63&n);break;case 14:n=e[s++],i=e[s++],a+=String.fromCharCode((15&r)<<12|(63&n)<<6|(63&i)<<0)}}return a},s);function s(){}var i=n._utf8ArrayToStr;t.utf8ArrayToStr=i,t.default=n},"./src/demux/tsdemuxer.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var g=r("./src/demux/adts.js"),s=r("./src/demux/mpegaudio.js"),k=r("./src/events.js"),T=r("./src/demux/exp-golomb.js"),n=r("./src/demux/sample-aes.js"),I=r("./src/utils/logger.js"),R=r("./src/errors.js"),i={video:1,audio:2,id3:3,text:4},o=(N.prototype.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new n.default(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},N.probe=function(e){var t=N._syncOffset(e);return!(t<0||(t&&I.logger.warn("MPEG2-TS detected but first sync word found @ offset "+t+", junk ahead ?"),0))},N._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r<t;){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1},N.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:i[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:"video"===e?0:void 0,isAAC:"audio"===e||void 0,duration:"audio"===e?t:void 0}},N.prototype.resetInitSegment=function(e,t,r,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=N.createTrack("video",n),this._audioTrack=N.createTrack("audio",n),this._id3Track=N.createTrack("id3",n),this._txtTrack=N.createTrack("text",n),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=t,this.videoCodec=r,this._duration=n},N.prototype.resetTimeStamp=function(){},N.prototype.append=function(e,t,r,n){var i,o,a,s,u,c=e.length,l=!1;this.contiguous=r;var f=this.pmtParsed,p=this._avcTrack,h=this._audioTrack,d=this._id3Track,v=p.pid,g=h.pid,y=d.pid,m=this._pmtId,_=p.pesData,b=h.pesData,w=d.pesData,E=this._parsePAT,S=this._parsePMT,T=this._parsePES,C=this._parseAVCPES.bind(this),O=this._parseAACPES.bind(this),A=this._parseMPEGPES.bind(this),x=this._parseID3PES.bind(this),D=N._syncOffset(e);for(c-=(c+D)%188,i=D;i<c;i+=188)if(71===e[i]){if(o=!!(64&e[i+1]),a=((31&e[i+1])<<8)+e[i+2],1<(48&e[i+3])>>4){if((s=i+5+e[i+4])===i+188)continue}else s=i+4;switch(a){case v:o&&(_&&(u=T(_))&&void 0!==u.pts&&C(u,!1),_={data:[],size:0}),_&&(_.data.push(e.subarray(s,i+188)),_.size+=i+188-s);break;case g:o&&(b&&(u=T(b))&&void 0!==u.pts&&(h.isAAC?O(u):A(u)),b={data:[],size:0}),b&&(b.data.push(e.subarray(s,i+188)),b.size+=i+188-s);break;case y:o&&(w&&(u=T(w))&&void 0!==u.pts&&x(u),w={data:[],size:0}),w&&(w.data.push(e.subarray(s,i+188)),w.size+=i+188-s);break;case 0:o&&(s+=e[s]+1),m=this._pmtId=E(e,s);break;case m:o&&(s+=e[s]+1);var P=S(e,s,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);0<(v=P.avc)&&(p.pid=v),0<(g=P.audio)&&(h.pid=g,h.isAAC=P.isAAC),0<(y=P.id3)&&(d.pid=y),l&&!f&&(I.logger.log("reparse from beginning"),l=!1,i=D-188),f=this.pmtParsed=!0;break;case 17:case 8191:break;default:l=!0}}else this.observer.trigger(k.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});_&&(u=T(_))&&void 0!==u.pts?(C(u,!0),p.pesData=null):p.pesData=_,b&&(u=T(b))&&void 0!==u.pts?(h.isAAC?O(u):A(u),h.pesData=null):(b&&b.size&&I.logger.log("last AAC PES packet truncated,might overlap between fragments"),h.pesData=b),w&&(u=T(w))&&void 0!==u.pts?(x(u),d.pesData=null):d.pesData=w,null==this.sampleAes?this.remuxer.remux(h,p,d,this._txtTrack,t,r,n):this.decryptAndRemux(h,p,d,this._txtTrack,t,r,n)},N.prototype.decryptAndRemux=function(e,t,r,n,i,o,a){if(e.samples&&e.isAAC){var s=this;this.sampleAes.decryptAacSamples(e.samples,0,function(){s.decryptAndRemuxAvc(e,t,r,n,i,o,a)})}else this.decryptAndRemuxAvc(e,t,r,n,i,o,a)},N.prototype.decryptAndRemuxAvc=function(e,t,r,n,i,o,a){if(t.samples){var s=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,function(){s.remuxer.remux(e,t,r,n,i,o,a)})}else this.remuxer.remux(e,t,r,n,i,o,a)},N.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},N.prototype._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},N.prototype._parsePMT=function(e,t,r,n){var i,o,a={audio:-1,avc:-1,id3:-1,isAAC:!0};for(i=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t<i;){switch(o=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!n){I.logger.log("unkown stream type:"+e[t]);break}case 15:-1===a.audio&&(a.audio=o);break;case 21:-1===a.id3&&(a.id3=o);break;case 219:if(!n){I.logger.log("unkown stream type:"+e[t]);break}case 27:-1===a.avc&&(a.avc=o);break;case 3:case 4:r?-1===a.audio&&(a.audio=o,a.isAAC=!1):I.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:I.logger.warn("HEVC stream type found, not supported for now");break;default:I.logger.log("unkown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return a},N.prototype._parsePES=function(e){var t,r,n,i,o,a,s,u,c=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&1<l.length;){var f=new Uint8Array(l[0].length+l[1].length);f.set(l[0]),f.set(l[1],l[0].length),l[0]=f,l.splice(1,1)}if(1!==((t=l[0])[0]<<16)+(t[1]<<8)+t[2])return null;if((n=(t[4]<<8)+t[5])&&n>e.size-6)return null;192&(r=t[7])&&(4294967295<(a=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2)&&(a-=8589934592),64&r?(4294967295<(s=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)&&(s-=8589934592),54e5<a-s&&(I.logger.warn(Math.round((a-s)/9e4)+"s delta between PTS and DTS, align them"),a=s)):s=a),u=(i=t[8])+9,e.size-=u,o=new Uint8Array(e.size);for(var p=0,h=l.length;p<h;p++){var d=(t=l[p]).byteLength;if(u){if(d<u){u-=d;continue}t=t.subarray(u),d-=u,u=0}o.set(t,c),c+=d}return n&&(n-=i+3),{data:o,pts:a,dts:s,len:n}},N.prototype.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,n=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(n||this.contiguous)?(e.id=n,r.push(e)):t.dropped++}e.debug.length&&I.logger.log(e.pts+"/"+e.dts+":"+e.debug)},N.prototype._parseAVCPES=function(d,e){function v(e,t,r,n){return{key:e,pts:t,dts:r,units:[],debug:n}}var g,y,m,_=this,b=this._avcTrack,t=this._parseAVCNALu(d.data),w=this.avcSample,E=!1,S=this.pushAccesUnit.bind(this);d.data=null,w&&t.length&&!b.audFound&&(S(w,b),w=this.avcSample=v(!1,d.pts,d.dts,"")),t.forEach(function(e){switch(e.type){case 1:y=!0,(w=w||(_.avcSample=v(!0,d.pts,d.dts,""))).frame=!0;var t=e.data;if(E&&4<t.length){var r=new T.default(t).readSliceType();2!==r&&4!==r&&7!==r&&9!==r||(w.key=!0)}break;case 5:y=!0,(w=w||(_.avcSample=v(!0,d.pts,d.dts,""))).key=!0,w.frame=!0;break;case 6:y=!0,(g=new T.default(_.discardEPB(e.data))).readUByte();for(var n=0,i=0,o=!1,a=0;!o&&1<g.bytesAvailable;){for(n=0;n+=a=g.readUByte(),255===a;);for(i=0;i+=a=g.readUByte(),255===a;);if(4===n&&0!==g.bytesAvailable){if(o=!0,181===g.readUByte()&&49===g.readUShort()&&1195456820===g.readUInt()&&3===g.readUByte()){var s=g.readUByte(),u=31&s,c=[s,g.readUByte()];for(m=0;m<u;m++)c.push(g.readUByte()),c.push(g.readUByte()),c.push(g.readUByte());_._insertSampleInOrder(_._txtTrack.samples,{type:3,pts:d.pts,bytes:c})}}else if(i<g.bytesAvailable)for(m=0;m<i;m++)g.readUByte()}break;case 7:if(E=y=!0,!b.sps){var l=(g=new T.default(e.data)).readSPS();b.width=l.width,b.height=l.height,b.pixelRatio=l.pixelRatio,b.sps=[e.data],b.duration=_._duration;var f=e.data.subarray(1,4),p="avc1.";for(m=0;m<3;m++){var h=f[m].toString(16);h.length<2&&(h="0"+h),p+=h}b.codec=p}break;case 8:y=!0,b.pps||(b.pps=[e.data]);break;case 9:y=!1,b.audFound=!0,w&&S(w,b),w=_.avcSample=v(!1,d.pts,d.dts,"");break;case 12:y=!1;break;default:y=!1,w&&(w.debug+="unknown NAL "+e.type+" ")}w&&y&&w.units.push(e)}),e&&w&&(S(w,b),this.avcSample=null)},N.prototype._insertSampleInOrder=function(e,t){var r=e.length;if(0<r){if(t.pts>=e[r-1].pts)e.push(t);else for(var n=r-1;0<=n;n--)if(t.pts<e[n].pts){e.splice(n,0,t);break}}else e.push(t)},N.prototype._getLastNalUnit=function(){var e,t=this.avcSample;if(!t||0===t.units.length){var r=this._avcTrack.samples;t=r[r.length-1]}if(t){var n=t.units;e=n[n.length-1]}return e},N.prototype._parseAVCNALu=function(e){var t,r,n,i,o=0,a=e.byteLength,s=this._avcTrack,u=s.naluState||0,c=u,l=[],f=-1;for(-1===u&&(i=31&e[f=0],u=0,o=1);o<a;)if(t=e[o++],u)if(1!==u)if(t)if(1===t){var p,h;0<=f?(n={data:e.subarray(f,o-u-1),type:i},l.push(n)):(p=this._getLastNalUnit())&&(c&&o<=4-c&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-c)),0<(r=o-u-1)&&((h=new Uint8Array(p.data.byteLength+r)).set(p.data,0),h.set(e.subarray(0,r),p.data.byteLength),p.data=h)),u=o<a?(i=31&e[f=o],0):-1}else u=0;else u=3;else u=t?0:2;else u=t?0:1;return 0<=f&&0<=u&&(n={data:e.subarray(f,a),type:i,state:u},l.push(n)),0!==l.length||(p=this._getLastNalUnit())&&((h=new Uint8Array(p.data.byteLength+e.byteLength)).set(p.data,0),h.set(e,p.data.byteLength),p.data=h),s.naluState=u,l},N.prototype.discardEPB=function(e){for(var t,r,n=e.byteLength,i=[],o=1;o<n-2;)0===e[o]&&0===e[o+1]&&3===e[o+2]?(i.push(o+2),o+=2):o++;if(0===i.length)return e;t=n-i.length,r=new Uint8Array(t);var a=0;for(o=0;o<t;a++,o++)a===i[0]&&(a++,i.shift()),r[o]=e[a];return r},N.prototype._parseAACPES=function(e){var t,r,n,i,o,a=this._audioTrack,s=e.data,u=e.pts,c=this.aacOverFlow,l=this.aacLastPTS;if(c){var f=new Uint8Array(c.byteLength+s.byteLength);f.set(c,0),f.set(s,c.byteLength),s=f}for(n=0,o=s.length;n<o-1&&!g.isHeader(s,n);n++);if(n){var p=void 0,h=void 0;if(h=n<o-1?(p="AAC PES did not start with ADTS header,offset:"+n,!1):(p="no ADTS header found in AAC PES",!0),I.logger.warn("parsing error:"+p),this.observer.trigger(k.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.FRAG_PARSING_ERROR,fatal:h,reason:p}),h)return}if(g.initTrackConfig(a,this.observer,s,n,this.audioCodec),r=0,t=g.getFrameDuration(a.samplerate),c&&l){var d=l+t;1<Math.abs(d-u)&&(I.logger.log("AAC: align PTS for overlapping frames by "+Math.round((d-u)/90)),u=d)}for(;n<o;)if(g.isHeader(s,n)&&n+5<o){var v=g.appendFrame(a,s,n,u,r);if(!v)break;n+=v.length,i=v.sample.pts,r++}else n++;c=n<o?s.subarray(n,o):null,this.aacOverFlow=c,this.aacLastPTS=i},N.prototype._parseMPEGPES=function(e){for(var t=e.data,r=t.length,n=0,i=0,o=e.pts;i<r;)if(s.default.isHeader(t,i)){var a=s.default.appendFrame(this._audioTrack,t,i,o,n);if(!a)break;i+=a.length,n++}else i++},N.prototype._parseID3PES=function(e){this._id3Track.samples.push(e)},N);function N(e,t,r,n){this.observer=e,this.config=r,this.typeSupported=n,this.remuxer=t,this.sampleAes=null}t.default=o},"./src/demux/sample-aes.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var i=r("./src/crypt/decrypter.js"),n=(o.prototype.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,t)},o.prototype.decryptAacSample=function(t,r,n,i){var o=t[r].unit,e=o.subarray(16,o.length-o.length%16),a=e.buffer.slice(e.byteOffset,e.byteOffset+e.length),s=this;this.decryptBuffer(a,function(e){e=new Uint8Array(e),o.set(e,16),i||s.decryptAacSamples(t,r+1,n)})},o.prototype.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var n=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,n),!n)return}}},o.prototype.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),n=0,i=32;i<=e.length-16;i+=160,n+=16)r.set(e.subarray(i,i+16),n);return r},o.prototype.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,n=32;n<=e.length-16;n+=160,r+=16)e.set(t.subarray(r,r+16),n);return e},o.prototype.decryptAvcSample=function(t,r,n,i,o,a){var s=this.discardEPB(o.data),e=this.getAvcEncryptedData(s),u=this;this.decryptBuffer(e.buffer,function(e){o.data=u.getAvcDecryptedUnit(s,e),a||u.decryptAvcSamples(t,r,n+1,i)})},o.prototype.decryptAvcSamples=function(e,t,r,n){for(;;t++,r=0){if(t>=e.length)return void n();for(var i=e[t].units;!(r>=i.length);r++){var o=i[r];if(!(o.length<=48||1!==o.type&&5!==o.type)){var a=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,n,o,a),!a)return}}}},o);function o(e,t,r,n){this.decryptdata=r,this.discardEPB=n,this.decrypter=new i.default(e,t,{removePKCS7Padding:!1})}t.default=n},"./src/crypt/decrypter.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var s=r("./src/crypt/aes-crypto.js"),u=r("./src/crypt/fast-aes-key.js"),c=r("./src/crypt/aes-decryptor.js"),o=r("./src/errors.js"),l=r("./src/utils/logger.js"),a=r("./src/events.js"),f=r("./src/utils/get-self-scope.js").getSelfScope(),n=(i.prototype.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},i.prototype.decrypt=function(t,r,n,i){var o=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(l.logger.log("JS AES decrypt"),this.logEnabled=!1);var e=this.decryptor;e||(this.decryptor=e=new c.default),e.expandKey(r),i(e.decrypt(t,0,n,this.removePKCS7Padding))}else{this.logEnabled&&(l.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var a=this.subtle;this.key!==r&&(this.key=r,this.fastAesKey=new u.default(a,r)),this.fastAesKey.expandKey().then(function(e){new s.default(a,n).decrypt(t,e).catch(function(e){o.onWebCryptoError(e,t,r,n,i)}).then(function(e){i(e)})}).catch(function(e){o.onWebCryptoError(e,t,r,n,i)})}},i.prototype.onWebCryptoError=function(e,t,r,n,i){this.config.enableSoftwareAES?(l.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,n,i)):(l.logger.error("decrypting error : "+e.message),this.observer.trigger(a.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))},i.prototype.destroy=function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)},i);function i(e,t,r){var n=(void 0===r?{}:r).removePKCS7Padding,i=void 0===n||n;if(this.logEnabled=!0,this.observer=e,this.config=t,this.removePKCS7Padding=i)try{var o=f.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}t.default=n},"./src/crypt/aes-decryptor.js": function(e,t,r){function N(e){var t=e.byteLength,r=t&&new DataView(e).getUint8(t-1);return r?e.slice(0,t-r):e}Object.defineProperty(t,"__esModule",{value:!0}),t.removePadding=N;var n=(i.prototype.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),n=0;n<4;n++)r[n]=t.getUint32(4*n);return r},i.prototype.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,n=r[0],i=r[1],o=r[2],a=r[3],s=this.invSubMix,u=s[0],c=s[1],l=s[2],f=s[3],p=new Uint32Array(256),h=0,d=0,v=0;for(v=0;v<256;v++)p[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var g=d^d<<1^d<<2^d<<3^d<<4;g=g>>>8^255&g^99;var y=p[t[e[h]=g]=h],m=p[y],_=p[m],b=257*p[g]^16843008*g;n[h]=b<<24|b>>>8,i[h]=b<<16|b>>>16,o[h]=b<<8|b>>>24,a[h]=b,b=16843009*_^65537*m^257*y^16843008*h,u[g]=b<<24|b>>>8,c[g]=b<<16|b>>>16,l[g]=b<<8|b>>>24,f[g]=b,h?(h=y^p[p[p[_^y]]],d^=p[p[d]]):h=d=1}},i.prototype.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n<t.length&&r;)r=t[n]===this.key[n],n++;if(!r){this.key=t;var i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);var o,a,s,u,c=this.ksRows=4*(i+6+1),l=this.keySchedule=new Uint32Array(c),f=this.invKeySchedule=new Uint32Array(c),p=this.sBox,h=this.rcon,d=this.invSubMix,v=d[0],g=d[1],y=d[2],m=d[3];for(o=0;o<c;o++)o<i?s=l[o]=t[o]:(u=s,o%i==0?(u=p[(u=u<<8|u>>>24)>>>24]<<24|p[u>>>16&255]<<16|p[u>>>8&255]<<8|p[255&u],u^=h[o/i|0]<<24):6<i&&o%i==4&&(u=p[u>>>24]<<24|p[u>>>16&255]<<16|p[u>>>8&255]<<8|p[255&u]),l[o]=s=(l[o-i]^u)>>>0);for(a=0;a<c;a++)o=c-a,u=3&a?l[o]:l[o-4],f[a]=a<4||o<=4?u:v[p[u>>>24]]^g[p[u>>>16&255]]^y[p[u>>>8&255]]^m[p[255&u]],f[a]=f[a]>>>0}},i.prototype.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},i.prototype.decrypt=function(e,t,r,n){for(var i,o,a,s,u,c,l,f,p,h,d,v,g,y,m=this.keySize+6,_=this.invKeySchedule,b=this.invSBox,w=this.invSubMix,E=w[0],S=w[1],T=w[2],C=w[3],O=this.uint8ArrayToUint32Array_(r),A=O[0],x=O[1],D=O[2],P=O[3],k=new Int32Array(e),I=new Int32Array(k.length),R=this.networkToHostOrderSwap;t<k.length;){for(p=R(k[t]),h=R(k[t+1]),d=R(k[t+2]),v=R(k[t+3]),u=p^_[0],c=v^_[1],l=d^_[2],f=h^_[3],g=4,y=1;y<m;y++)i=E[u>>>24]^S[c>>16&255]^T[l>>8&255]^C[255&f]^_[g],o=E[c>>>24]^S[l>>16&255]^T[f>>8&255]^C[255&u]^_[g+1],a=E[l>>>24]^S[f>>16&255]^T[u>>8&255]^C[255&c]^_[g+2],s=E[f>>>24]^S[u>>16&255]^T[c>>8&255]^C[255&l]^_[g+3],u=i,c=o,l=a,f=s,g+=4;i=b[u>>>24]<<24^b[c>>16&255]<<16^b[l>>8&255]<<8^b[255&f]^_[g],o=b[c>>>24]<<24^b[l>>16&255]<<16^b[f>>8&255]<<8^b[255&u]^_[g+1],a=b[l>>>24]<<24^b[f>>16&255]<<16^b[u>>8&255]<<8^b[255&c]^_[g+2],s=b[f>>>24]<<24^b[u>>16&255]<<16^b[c>>8&255]<<8^b[255&l]^_[g+3],g+=3,I[t]=R(i^A),I[t+1]=R(s^x),I[t+2]=R(a^D),I[t+3]=R(o^P),A=p,x=h,D=d,P=v,t+=4}return n?N(I.buffer):I.buffer},i.prototype.destroy=function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0},i);function i(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}t.default=n},"./src/crypt/fast-aes-key.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=(i.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},i);function i(e,t){this.subtle=e,this.key=t}t.default=n},"./src/crypt/aes-crypto.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=(i.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},i);function i(e,t){this.subtle=e,this.aesIV=t}t.default=n},"./src/demux/exp-golomb.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r("./src/utils/logger.js"),i=(o.prototype.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,n=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");n.set(e.subarray(r,r+i)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i},o.prototype.skipBits=function(e){var t;this.bitsAvailable>e||(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},o.prototype.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return 32<e&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,0<this.bitsAvailable?this.word<<=t:0<this.bytesAvailable&&this.loadWord(),0<(t=e-t)&&this.bitsAvailable?r<<t|this.readBits(t):r},o.prototype.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},o.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},o.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},o.prototype.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},o.prototype.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},o.prototype.readBoolean=function(){return 1===this.readBits(1)},o.prototype.readUByte=function(){return this.readBits(8)},o.prototype.readUShort=function(){return this.readBits(16)},o.prototype.readUInt=function(){return this.readBits(32)},o.prototype.skipScalingList=function(e){var t,r=8,n=8;for(t=0;t<e;t++)0!==n&&(n=(r+this.readEG()+256)%256),r=0===n?r:n},o.prototype.readSPS=function(){var e,t,r,n,i,o,a,s=0,u=0,c=0,l=0,f=this.readUByte.bind(this),p=this.readBits.bind(this),h=this.readUEG.bind(this),d=this.readBoolean.bind(this),v=this.skipBits.bind(this),g=this.skipEG.bind(this),y=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);if(f(),e=f(),p(5),v(3),f(),y(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var _=h();if(3===_&&v(1),y(),y(),v(1),d())for(o=3!==_?8:12,a=0;a<o;a++)d()&&m(a<6?16:64)}y();var b=h();if(0===b)h();else if(1===b)for(v(1),g(),g(),t=h(),a=0;a<t;a++)g();y(),v(1),r=h(),n=h(),0===(i=p(1))&&v(1),v(1),d()&&(s=h(),u=h(),c=h(),l=h());var w=[1,1];if(d()&&d())switch(f()){case 1:w=[1,1];break;case 2:w=[12,11];break;case 3:w=[10,11];break;case 4:w=[16,11];break;case 5:w=[40,33];break;case 6:w=[24,11];break;case 7:w=[20,11];break;case 8:w=[32,11];break;case 9:w=[80,33];break;case 10:w=[18,11];break;case 11:w=[15,11];break;case 12:w=[64,33];break;case 13:w=[160,99];break;case 14:w=[4,3];break;case 15:w=[3,2];break;case 16:w=[2,1];break;case 255:w=[f()<<8|f(),f()<<8|f()]}return{width:Math.ceil(16*(r+1)-2*s-2*u),height:(2-i)*(n+1)*16-(i?2:4)*(c+l),pixelRatio:w}},o.prototype.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},o);function o(e){this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}t.default=i},"./src/demux/adts.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var p=r("./src/utils/logger.js"),h=r("./src/errors.js"),d=r("./src/events.js");function a(e,t,r,n){var i,o,a,s,u,c=navigator.userAgent.toLowerCase(),l=n,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(i=1+((192&t[r+2])>>>6),o=(60&t[r+2])>>>2,!(f.length-1<o))return s=(1&t[r+2])<<2,s|=(192&t[r+3])>>>6,p.logger.log("manifest codec:"+n+",ADTS data:type:"+i+",sampleingIndex:"+o+"["+f[o]+"Hz],channelConfig:"+s),a=/firefox/i.test(c)?6<=o?(i=5,u=new Array(4),o-3):(i=2,u=new Array(2),o):-1!==c.indexOf("android")?(i=2,u=new Array(2),o):(i=5,u=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&6<=o?o-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(6<=o&&1==s||/vivaldi/i.test(c))||!n&&1==s)&&(i=2,u=new Array(2)),o)),u[0]=i<<3,u[0]|=(14&o)>>1,u[1]|=(1&o)<<7,u[1]|=s<<3,5===i&&(u[1]|=(14&a)>>1,u[2]=(1&a)<<7,u[2]|=8,u[3]=0),{config:u,samplerate:f[o],channelCount:s,codec:"mp4a.40."+i,manifestCodec:l};e.trigger(d.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o})}function i(e,t){return 255===e[t]&&240==(246&e[t+1])}function u(e,t){return 1&e[t+1]?7:9}function c(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function l(e){return 9216e4/e}function f(e,t,r,n,i){var o,a,s=e.length;if(o=u(e,t),a=c(e,t),0<(a-=o)&&t+o+a<=s)return{headerLength:o,frameLength:a,stamp:r+n*i}}t.getAudioConfig=a,t.isHeaderPattern=i,t.getHeaderLength=u,t.getFullFrameLength=c,t.isHeader=function(e,t){return!!(t+1<e.length&&i(e,t))},t.probe=function(e,t){if(t+1<e.length&&i(e,t)){var r=u(e,t);t+5<e.length&&(r=c(e,t));var n=t+r;if(n===e.length||n+1<e.length&&i(e,n))return!0}return!1},t.initTrackConfig=function(e,t,r,n,i){if(!e.samplerate){var o=a(t,r,n,i);e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,p.logger.log("parsed codec:"+e.codec+",rate:"+o.samplerate+",nb channel:"+o.channelCount)}},t.getFrameDuration=l,t.parseFrameHeader=f,t.appendFrame=function(e,t,r,n,i){var o=f(t,r,n,i,l(e.samplerate));if(o){var a=o.stamp,s=o.headerLength,u=o.frameLength,c={unit:t.subarray(r+s,r+s+u),pts:a,dts:a};return e.samples.push(c),e.len+=u,{sample:c,length:u+s}}}},"./src/demux/mp4demuxer.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var p=r("./src/utils/logger.js"),u=r("./src/events.js"),s=Math.pow(2,32)-1,n=(v.prototype.resetTimeStamp=function(e){this.initPTS=e},v.prototype.resetInitSegment=function(e,t,r,n){if(e&&e.byteLength){var i=this.initData=v.parseInitSegment(e);null==t&&(t="mp4a.40.5"),null==r&&(r="avc1.42e01e");var o={};i.audio&&i.video?o.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:n?e:null}:(i.audio&&(o.audio={container:"audio/mp4",codec:t,initSegment:n?e:null}),i.video&&(o.video={container:"video/mp4",codec:r,initSegment:n?e:null})),this.observer.trigger(u.default.FRAG_PARSING_INIT_SEGMENT,{tracks:o})}else t&&(this.audioCodec=t),r&&(this.videoCodec=r)},v.probe=function(e){return 0<v.findBox({data:e,start:0,end:Math.min(e.length,16384)},["moof"]).length},v.bin2str=function(e){return String.fromCharCode.apply(null,e)},v.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r},v.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r},v.writeUint32=function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},v.findBox=function(e,t){var r,n,i,o,a,s,u=[];if(e.data?(a=e.start,i=e.end,e=e.data):(a=0,i=e.byteLength),!t.length)return null;for(r=a;r<i;)s=1<(n=v.readUint32(e,r))?r+n:i,v.bin2str(e.subarray(r+4,r+8))===t[0]&&(1===t.length?u.push({data:e,start:r+8,end:s}):(o=v.findBox({data:e,start:r+8,end:s},t.slice(1))).length&&(u=u.concat(o))),r=s;return u},v.parseSegmentIndex=function(e){var t,r=v.findBox(e,["moov"])[0],n=r?r.end:null,i=0,o=v.findBox(e,["sidx"]);if(!o||!o[0])return null;t=[];var a=(o=o[0]).data[0],s=v.readUint32(o,i=0===a?8:16);i+=4,i+=0===a?8:16,i+=2;var u=o.end+0,c=v.readUint16(o,i);i+=2;for(var l=0;l<c;l++){var f=i,p=v.readUint32(o,f);f+=4;var h=2147483647&p;if(1==(2147483648&p)>>>31)return void console.warn("SIDX has hierarchical references (not supported)");var d=v.readUint32(o,f);f+=4,t.push({referenceSize:h,subsegmentDuration:d,info:{duration:d/s,start:u,end:u+h-1}}),u+=h,i=f+=4}return{earliestPresentationTime:0,timescale:s,version:a,referencesCount:c,references:t,moovEndOffset:n}},v.parseInitSegment=function(e){var f=[];return v.findBox(e,["moov","trak"]).forEach(function(e){var t=v.findBox(e,["tkhd"])[0];if(t){var r=t.data[t.start],n=0===r?12:20,i=v.readUint32(t,n),o=v.findBox(e,["mdia","mdhd"])[0];if(o){r=o.data[o.start];var a=v.readUint32(o,n=0===r?12:20),s=v.findBox(e,["mdia","hdlr"])[0];if(s){var u={soun:"audio",vide:"video"}[v.bin2str(s.data.subarray(s.start+8,s.start+12))];if(u){var c=v.findBox(e,["mdia","minf","stbl","stsd"]);if(c.length){c=c[0];var l=v.bin2str(c.data.subarray(c.start+12,c.start+16));p.logger.log("MP4Demuxer:"+u+":"+l+" found")}f[i]={timescale:a,type:u},f[u]={timescale:a,id:i}}}}}}),f},v.getStartDTS=function(i,e){var t,r,n;return t=v.findBox(e,["moof","traf"]),r=[].concat.apply([],t.map(function(n){return v.findBox(n,["tfhd"]).map(function(e){var t,r;return t=v.readUint32(e,4),r=i[t].timescale||9e4,v.findBox(n,["tfdt"]).map(function(e){var t,r;return t=e.data[e.start],r=v.readUint32(e,4),1===t&&(r*=Math.pow(2,32),r+=v.readUint32(e,8)),r})[0]/r})})),n=Math.min.apply(null,r),isFinite(n)?n:0},v.offsetStartDTS=function(n,e,a){v.findBox(e,["moof","traf"]).map(function(r){return v.findBox(r,["tfhd"]).map(function(e){var t=v.readUint32(e,4),o=n[t].timescale||9e4;v.findBox(r,["tfdt"]).map(function(e){var t=e.data[e.start],r=v.readUint32(e,4);if(0===t)v.writeUint32(e,4,r-a*o);else{r*=Math.pow(2,32),r+=v.readUint32(e,8),r-=a*o,r=Math.max(r,0);var n=Math.floor(r/(1+s)),i=Math.floor(r%(1+s));v.writeUint32(e,4,n),v.writeUint32(e,8,i)}})})})},v.prototype.append=function(e,t,r,n){var i=this.initData;i||(this.resetInitSegment(e,this.audioCodec,this.videoCodec,!1),i=this.initData);var o,a=this.initPTS;if(void 0===a){var s=v.getStartDTS(i,e);this.initPTS=a=s-t,this.observer.trigger(u.default.INIT_PTS_FOUND,{initPTS:a})}v.offsetStartDTS(i,e,a),o=v.getStartDTS(i,e),this.remuxer.remux(i.audio,i.video,null,null,o,r,n,e)},v.prototype.destroy=function(){},v);function v(e,t){this.observer=e,this.remuxer=t}t.default=n},"./src/demux/aacdemuxer.js": function(e,r,n){(function(d){Object.defineProperty(r,"__esModule",{value:!0});var v=n("./src/demux/adts.js"),g=n("./src/utils/logger.js"),y=n("./src/demux/id3.js"),e=(t.prototype.resetInitSegment=function(e,t,r,n){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:n,inputTimeScale:9e4}},t.prototype.resetTimeStamp=function(){},t.probe=function(e){if(!e)return!1;for(var t=(y.default.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(v.probe(e,t))return g.logger.log("ADTS sync word found !"),!0;return!1},t.prototype.append=function(e,t,r,n){for(var i=this._audioTrack,o=y.default.getID3Data(e,0)||[],a=y.default.getTimeStamp(o),s=d.isFinite(a)?90*a:9e4*t,u=0,c=s,l=e.length,f=o.length,p=[{pts:c,dts:c,data:o}];f<l-1;)if(v.isHeader(e,f)&&f+5<l){v.initTrackConfig(i,this.observer,e,f,i.manifestCodec);var h=v.appendFrame(i,e,f,s,u);if(!h){g.logger.log("Unable to parse AAC frame");break}f+=h.length,c=h.sample.pts,u++}else y.default.isHeader(e,f)?(o=y.default.getID3Data(e,f),p.push({pts:c,dts:c,data:o}),f+=o.length):f++;this.remuxer.remux(i,{samples:[]},{samples:p,inputTimeScale:9e4},{samples:[]},t,r,n)},t.prototype.destroy=function(){},t);function t(e,t,r){this.observer=e,this.config=r,this.remuxer=t}r.default=e}).call(this,n("./src/polyfills/number.js").Number)},"./src/polyfills/number.js": function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r("./src/utils/get-self-scope.js").getSelfScope().Number;(t.Number=n).isFinite=n.isFinite||function(e){return"number"==typeof e&&isFinite(e)}}}))(self);