diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index a91bd8c1f5..8d3779a56d 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v5.0, 2022-11-22, Merge [#3268](https://github.com/ossrs/srs/pull/3268): H265: Update mpegts.js to play HEVC over HTTP-TS/FLV. v6.0.1 * v6.0, 2022-11-22, Init SRS 6. v6.0.0 diff --git a/trunk/research/players/js/mpegts-1.6.10.min.js b/trunk/research/players/js/mpegts-1.6.10.min.js deleted file mode 100644 index 74c6db0fb4..0000000000 --- a/trunk/research/players/js/mpegts-1.6.10.min.js +++ /dev/null @@ -1,9 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mpegts=t():e.mpegts=t()}(window,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},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(i.s=14)}([function(e,t,i){"use strict";var n=i(6),r=i.n(n),s=function(){function e(){}return e.e=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",n),e.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))},e.i=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",n),e.ENABLE_INFO&&(console.info?console.info(n):console.log(n))},e.w=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",n),e.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))},e.d=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",n),e.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))},e.v=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",n),e.ENABLE_VERBOSE&&console.log(n)},e}();s.GLOBAL_TAG="mpegts.js",s.FORCE_GLOBAL_TAG=!1,s.ENABLE_ERROR=!0,s.ENABLE_INFO=!0,s.ENABLE_WARN=!0,s.ENABLE_DEBUG=!0,s.ENABLE_VERBOSE=!0,s.ENABLE_CALLBACK=!1,s.emitter=new r.a,t.a=s},function(e,t,i){"use strict";t.a={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",TIMED_ID3_METADATA_ARRIVED:"timed_id3_metadata_arrived",PES_PRIVATE_DATA_DESCRIPTOR:"pes_private_data_descriptor",PES_PRIVATE_DATA_ARRIVED:"pes_private_data_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"}},function(e,t,i){"use strict";i.d(t,"c",(function(){return r})),i.d(t,"b",(function(){return s})),i.d(t,"a",(function(){return a}));var n=i(3),r={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},s={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},a=function(){function e(e){this._type=e||"undefined",this._status=r.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return e.prototype.destroy=function(){this._status=r.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===r.kConnecting||this._status===r.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),e.prototype.open=function(e,t){throw new n.c("Unimplemented abstract function!")},e.prototype.abort=function(){throw new n.c("Unimplemented abstract function!")},e}()},function(e,t,i){"use strict";i.d(t,"d",(function(){return s})),i.d(t,"a",(function(){return a})),i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return h}));var n,r=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),a=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),t}(s),o=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),t}(s),h=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),t}(s)},function(e,t,i){"use strict";var n={};!function(){var e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},s={};if(r.browser){s[r.browser]=!0;var a=r.majorVersion.split(".");s.version={major:parseInt(r.majorVersion,10),string:r.version},a.length>1&&(s.version.minor=parseInt(a[1],10)),a.length>2&&(s.version.build=parseInt(a[2],10))}if(r.platform&&(s[r.platform]=!0),(s.chrome||s.opr||s.safari)&&(s.webkit=!0),s.rv||s.iemobile){s.rv&&delete s.rv;r.browser="msie",s.msie=!0}if(s.edge){delete s.edge;r.browser="msedge",s.msedge=!0}if(s.opr){r.browser="opera",s.opera=!0}if(s.safari&&s.android){r.browser="android",s.android=!0}for(var o in s.name=r.browser,s.platform=r.platform,n)n.hasOwnProperty(o)&&delete n[o];Object.assign(n,s)}(),t.a=n},function(e,t,i){"use strict";t.a={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"}},function(e,t,i){"use strict";var n,r="object"==typeof Reflect?Reflect:null,s=r&&"function"==typeof r.apply?r.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};n=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(i,n){function r(i){e.removeListener(t,s),n(i)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}g(e,t,s,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&g(e,"error",t,i)}(e,r,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var h=10;function d(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function _(e,t,i,n){var r,s,a,o;if(d(i),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),s=e._events),a=s[t]),void 0===a)a=s[t]=i,++e._eventsCount;else if("function"==typeof a?a=s[t]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),(r=u(e))>0&&a.length>r&&!a.warned){a.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=a.length,o=h,console&&console.warn&&console.warn(o)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=l.bind(n);return r.listener=i,n.wrapFn=r,r}function f(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i0&&(a=t[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var h=r[e];if(void 0===h)return!1;if("function"==typeof h)s(h,this,t);else{var d=h.length,u=m(h,d);for(i=0;i=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,r=s;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,i){"use strict";i.d(t,"d",(function(){return n})),i.d(t,"b",(function(){return r})),i.d(t,"a",(function(){return s})),i.d(t,"c",(function(){return a}));var n=function(e,t,i,n,r){this.dts=e,this.pts=t,this.duration=i,this.originalDts=n,this.isSyncPoint=r,this.fileposition=null},r=function(){function e(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return e.prototype.appendSyncPoint=function(e){e.isSyncPoint=!0,this.syncPoints.push(e)},e}(),s=function(){function e(){this._list=[]}return e.prototype.clear=function(){this._list=[]},e.prototype.appendArray=function(e){var t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts=t[r].dts&&et[n].lastSample.originalDts&&e=t[n].lastSample.originalDts&&(n===t.length-1||n0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)},e.prototype.getLastSegmentBefore=function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null},e.prototype.getLastSampleBefore=function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){for(var t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;0===i.length&&t>0;)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null},e}()},function(e,t,i){"use strict";var n=function(){function e(){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 e.prototype.isComplete=function(){var e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=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;return null!=this.mimeType&&e&&t},e.prototype.isSeekable=function(){return!0===this.hasKeyframesIndex},e.prototype.getNearestKeyframe=function(e){if(null==this.keyframesIndex)return null;var t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}},e.prototype._search=function(e,t){var i=0,n=e.length-1,r=0,s=0,a=n;for(t=e[r]&&t0){var i=e.getConfig();t.emit("change",i)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){s.a.emitter.addListener("log",t),s.a.emitter.listenerCount("log")>0&&(s.a.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){s.a.emitter.removeListener("log",t),0===s.a.emitter.listenerCount("log")&&(s.a.ENABLE_CALLBACK=!1,e._notifyChange())},e}();a.emitter=new r.a,t.a=a},function(e,t,i){"use strict";var n=i(6),r=i.n(n),s=i(0),a=i(4),o=i(8);function h(e,t,i){var n=e;if(t+i=128){t.push(String.fromCharCode(65535&s)),n+=2;continue}}else if(i[n]<240){if(h(i,n,2))if((s=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2])>=2048&&55296!=(63488&s)){t.push(String.fromCharCode(65535&s)),n+=3;continue}}else if(i[n]<248){var s;if(h(i,n,3))if((s=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3])>65536&&s<1114112){s-=65536,t.push(String.fromCharCode(s>>>10|55296)),t.push(String.fromCharCode(1023&s|56320)),n+=4;continue}}t.push(String.fromCharCode(65533)),++n}return t.join("")},_=i(3),l=(d=new ArrayBuffer(2),new DataView(d).setInt16(0,256,!0),256===new Int16Array(d)[0]),c=function(){function e(){}return e.parseScriptData=function(t,i,n){var r={};try{var a=e.parseValue(t,i,n),o=e.parseValue(t,i+a.size,n-a.size);r[a.data]=o.data}catch(e){s.a.e("AMF",e.toString())}return r},e.parseObject=function(t,i,n){if(n<3)throw new _.a("Data not enough when parse ScriptDataObject");var r=e.parseString(t,i,n),s=e.parseValue(t,i+r.size,n-r.size),a=s.objectEnd;return{data:{name:r.data,value:s.data},size:r.size+s.size,objectEnd:a}},e.parseVariable=function(t,i,n){return e.parseObject(t,i,n)},e.parseString=function(e,t,i){if(i<2)throw new _.a("Data not enough when parse String");var n=new DataView(e,t,i).getUint16(0,!l);return{data:n>0?u(new Uint8Array(e,t+2,n)):"",size:2+n}},e.parseLongString=function(e,t,i){if(i<4)throw new _.a("Data not enough when parse LongString");var n=new DataView(e,t,i).getUint32(0,!l);return{data:n>0?u(new Uint8Array(e,t+4,n)):"",size:4+n}},e.parseDate=function(e,t,i){if(i<10)throw new _.a("Data size invalid when parse Date");var n=new DataView(e,t,i),r=n.getFloat64(0,!l),s=n.getInt16(8,!l);return{data:new Date(r+=60*s*1e3),size:10}},e.parseValue=function(t,i,n){if(n<1)throw new _.a("Data not enough when parse Value");var r,a=new DataView(t,i,n),o=1,h=a.getUint8(0),d=!1;try{switch(h){case 0:r=a.getFloat64(1,!l),o+=8;break;case 1:r=!!a.getUint8(1),o+=1;break;case 2:var u=e.parseString(t,i+1,n-1);r=u.data,o+=u.size;break;case 3:r={};var c=0;for(9==(16777215&a.getUint32(n-4,!l))&&(c=3);o32)throw new _.b("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var i=this._current_word_bits_left?this._current_word:0;i>>>=32-this._current_word_bits_left;var n=e-this._current_word_bits_left;this._fillCurrentWord();var r=Math.min(n,this._current_word_bits_left),s=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,i=i<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}(),p=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,n=new Uint8Array(i),r=0,s=0;s=2&&3===t[s]&&0===t[s-1]&&0===t[s-2]||(n[r]=t[s],r++);return new Uint8Array(n.buffer,0,r)},e.parseSPS=function(t){for(var i=t.subarray(1,4),n="avc1.",r=0;r<3;r++){var s=i[r].toString(16);s.length<2&&(s="0"+s),n+=s}var a=e._ebsp2rbsp(t),o=new f(a);o.readByte();var h=o.readByte();o.readByte();var d=o.readByte();o.readUEG();var u=e.getProfileString(h),_=e.getLevelString(d),l=1,c=420,p=8,m=8;if((100===h||110===h||122===h||244===h||44===h||83===h||86===h||118===h||128===h||138===h||144===h)&&(3===(l=o.readUEG())&&o.readBits(1),l<=3&&(c=[0,420,422,444][l]),p=o.readUEG()+8,m=o.readUEG()+8,o.readBits(1),o.readBool()))for(var g=3!==l?8:12,v=0;v0&&x<16?(k=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][x-1],C=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][x-1]):255===x&&(k=o.readByte()<<8|o.readByte(),C=o.readByte()<<8|o.readByte())}if(o.readBool()&&o.readBool(),o.readBool()&&(o.readBits(4),o.readBool()&&o.readBits(24)),o.readBool()&&(o.readUEG(),o.readUEG()),o.readBool()){var B=o.readBits(32),U=o.readBits(32);O=o.readBool(),I=(P=U)/(M=2*B)}}var N=1;1===k&&1===C||(N=k/C);var F=0,G=0;0===l?(F=1,G=2-R):(F=3===l?1:2,G=(1===l?2:1)*(2-R));var V=16*(S+1),j=16*(A+1)*(2-R);V-=(L+T)*F,j-=(w+D)*G;var z=Math.ceil(V*N);return o.destroy(),o=null,{codec_mimetype:n,profile_idc:h,level_idc:d,profile_string:u,level_string:_,chroma_format_idc:l,bit_depth:p,bit_depth_luma:p,bit_depth_chroma:m,ref_frames:b,chroma_format:c,chroma_format_string:e.getChromaFormatString(c),frame_rate:{fixed:O,fps:I,fps_den:M,fps_num:P},sar_ratio:{width:k,height:C},codec_size:{width:V,height:j},present_size:{width:z,height:j}}},e._skipScalingList=function(e,t){for(var i=8,n=8,r=0;r>>2!=0,a=0!=(1&t[4]),o=(n=t)[r=5]<<24|n[r+1]<<16|n[r+2]<<8|n[r+3];return o<9?i:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:s,hasVideoTrack:a}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new o.a},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(t,i){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new _.a("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var n=0,r=this._littleEndian;if(0===i){if(!(t.byteLength>13))return 0;n=e.probe(t).dataOffset}this._firstParse&&(this._firstParse=!1,i+n!==this._dataOffset&&s.a.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==(a=new DataView(t,n)).getUint32(0,!r)&&s.a.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4);for(;nt.byteLength)break;var o=a.getUint8(0),h=16777215&a.getUint32(0,!r);if(n+11+h+4>t.byteLength)break;if(8===o||9===o||18===o){var d=a.getUint8(4),u=a.getUint8(5),l=a.getUint8(6)|u<<8|d<<16|a.getUint8(7)<<24;0!==(16777215&a.getUint32(7,!r))&&s.a.w(this.TAG,"Meet tag which has StreamID != 0!");var c=n+11;switch(o){case 8:this._parseAudioData(t,c,h,l);break;case 9:this._parseVideoData(t,c,h,l,i+n);break;case 18:this._parseScriptData(t,c,h)}var f=a.getUint32(11+h,!r);f!==11+h&&s.a.w(this.TAG,"Invalid PrevTagSize "+f),n+=11+h+4}else s.a.w(this.TAG,"Unsupported tag type "+o+", skipped"),n+=11+h+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n},e.prototype._parseScriptData=function(e,t,i){var n=c.parseScriptData(e,t,i);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!=typeof n.onMetaData)return void s.a.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&s.a.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;var r=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},r)),"boolean"==typeof r.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=r.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof r.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=r.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof r.audiodatarate&&(this._mediaInfo.audioDataRate=r.audiodatarate),"number"==typeof r.videodatarate&&(this._mediaInfo.videoDataRate=r.videodatarate),"number"==typeof r.width&&(this._mediaInfo.width=r.width),"number"==typeof r.height&&(this._mediaInfo.height=r.height),"number"==typeof r.duration){if(!this._durationOverrided){var a=Math.floor(r.duration*this._timescale);this._duration=a,this._mediaInfo.duration=a}}else this._mediaInfo.duration=0;if("number"==typeof r.framerate){var o=Math.floor(1e3*r.framerate);if(o>0){var h=o/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=h,this._referenceFrameRate.fps_num=o,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=h}}if("object"==typeof r.keyframes){this._mediaInfo.hasKeyframesIndex=!0;var d=r.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(d),r.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=r,s.a.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(n).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},n))},e.prototype._parseKeyframesIndex=function(e){for(var t=[],i=[],n=1;n>>4;if(2===a||10===a){var o=0,h=(12&r)>>>2;if(h>=0&&h<=4){o=this._flvSoundRateTable[h];var d=1&r,u=this._audioMetadata,_=this._audioTrack;if(u||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(u=this._audioMetadata={}).type="audio",u.id=_.id,u.timescale=this._timescale,u.duration=this._duration,u.audioSampleRate=o,u.channelCount=0===d?1:2),10===a){var l=this._parseAACAudioData(e,t+1,i-1);if(null==l)return;if(0===l.packetType){u.config&&s.a.w(this.TAG,"Found another AudioSpecificConfig!");var c=l.data;u.audioSampleRate=c.samplingRate,u.channelCount=c.channelCount,u.codec=c.codec,u.originalCodec=c.originalCodec,u.config=c.config,u.refSampleDuration=1024/u.audioSampleRate*u.timescale,s.a.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",u),(g=this._mediaInfo).audioCodec=u.originalCodec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}else if(1===l.packetType){var f=this._timestampBase+n,p={unit:l.data,length:l.data.byteLength,dts:f,pts:f};_.samples.push(p),_.length+=l.data.length}else s.a.e(this.TAG,"Flv: Unsupported AAC data type "+l.packetType)}else if(2===a){if(!u.codec){var g;if(null==(c=this._parseMP3AudioData(e,t+1,i-1,!0)))return;u.audioSampleRate=c.samplingRate,u.channelCount=c.channelCount,u.codec=c.codec,u.originalCodec=c.originalCodec,u.refSampleDuration=1152/u.audioSampleRate*u.timescale,s.a.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",u),(g=this._mediaInfo).audioCodec=u.codec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.audioDataRate=c.bitRate,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}var v=this._parseMP3AudioData(e,t+1,i-1,!1);if(null==v)return;f=this._timestampBase+n;var y={unit:v,length:v.byteLength,dts:f,pts:f};_.samples.push(y),_.length+=v.length}}else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+h)}else this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+a)}},e.prototype._parseAACAudioData=function(e,t,i){if(!(i<=1)){var n={},r=new Uint8Array(e,t,i);return n.packetType=r[0],0===r[0]?n.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):n.data=r.subarray(1),n}s.a.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,t,i){var n,r,s=new Uint8Array(e,t,i),a=null,o=0,h=null;if(o=n=s[0]>>>3,(r=(7&s[0])<<1|s[1]>>>7)<0||r>=this._mpegSamplingRates.length)this._onError(m.a.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var d=this._mpegSamplingRates[r],u=(120&s[1])>>>3;if(!(u<0||u>=8)){5===o&&(h=(7&s[1])<<1|s[2]>>>7,(124&s[2])>>>2);var _=self.navigator.userAgent.toLowerCase();return-1!==_.indexOf("firefox")?r>=6?(o=5,a=new Array(4),h=r-3):(o=2,a=new Array(2),h=r):-1!==_.indexOf("android")?(o=2,a=new Array(2),h=r):(o=5,h=r,a=new Array(4),r>=6?h=r-3:1===u&&(o=2,a=new Array(2),h=r)),a[0]=o<<3,a[0]|=(15&r)>>>1,a[1]=(15&r)<<7,a[1]|=(15&u)<<3,5===o&&(a[1]|=(15&h)>>>1,a[2]=(1&h)<<7,a[2]|=8,a[3]=0),{config:a,samplingRate:d,channelCount:u,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+n}}this._onError(m.a.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,t,i,n){if(!(i<4)){this._littleEndian;var r=new Uint8Array(e,t,i),a=null;if(n){if(255!==r[0])return;var o=r[1]>>>3&3,h=(6&r[1])>>1,d=(240&r[2])>>>4,u=(12&r[2])>>>2,_=3!==(r[3]>>>6&3)?2:1,l=0,c=0;switch(o){case 0:l=this._mpegAudioV25SampleRateTable[u];break;case 2:l=this._mpegAudioV20SampleRateTable[u];break;case 3:l=this._mpegAudioV10SampleRateTable[u]}switch(h){case 1:34,d>>4,h=15&a;7===h?this._parseAVCVideoPacket(e,t+1,i-1,n,r,o):this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+h)}},e.prototype._parseAVCVideoPacket=function(e,t,i,n,r,a){if(i<4)s.a.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var o=this._littleEndian,h=new DataView(e,t,i),d=h.getUint8(0),u=(16777215&h.getUint32(0,!o))<<8>>8;if(0===d)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===d)this._parseAVCVideoData(e,t+4,i-4,n,r,a,u);else if(2!==d)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type "+d)}},e.prototype._parseAVCDecoderConfigurationRecord=function(e,t,i){if(i<7)s.a.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var n=this._videoMetadata,r=this._videoTrack,a=this._littleEndian,o=new DataView(e,t,i);n?void 0!==n.avcc&&s.a.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(n=this._videoMetadata={}).type="video",n.id=r.id,n.timescale=this._timescale,n.duration=this._duration);var h=o.getUint8(0),d=o.getUint8(1);o.getUint8(2),o.getUint8(3);if(1===h&&0!==d)if(this._naluLengthSize=1+(3&o.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var u=31&o.getUint8(5);if(0!==u){u>1&&s.a.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+u);for(var _=6,l=0;l1&&s.a.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+L),_++;for(l=0;l=i){s.a.w(this.TAG,"Malformed Nalu near timestamp "+f+", offset = "+l+", dataSize = "+i);break}var m=d.getUint32(l,!h);if(3===c&&(m>>>=8),m>i-c)return void s.a.w(this.TAG,"Malformed Nalus near timestamp "+f+", NaluSize > DataSize!");var g=31&d.getUint8(l+c);5===g&&(p=!0);var v=new Uint8Array(e,t+l,c+m),y={type:g,data:v};u.push(y),_+=v.byteLength,l+=c+m}if(u.length){var E=this._videoTrack,b={units:u,length:_,isKeyframe:p,dts:f,cts:o,pts:f+o};p&&(b.fileposition=r),E.samples.push(b),E.length+=_}},e}(),y=function(){function e(){}return e.prototype.destroy=function(){this.onError=null,this.onMediaInfo=null,this.onMetaDataArrived=null,this.onTrackMetadata=null,this.onDataAvailable=null,this.onTimedID3Metadata=null,this.onPESPrivateData=null,this.onPESPrivateDataDescriptor=null},e}(),E=function(){this.program_pmt_pid={}};!function(e){e[e.kMPEG1Audio=3]="kMPEG1Audio",e[e.kMPEG2Audio=4]="kMPEG2Audio",e[e.kPESPrivateData=6]="kPESPrivateData",e[e.kADTSAAC=15]="kADTSAAC",e[e.kID3=21]="kID3",e[e.kH264=27]="kH264",e[e.kH265=36]="kH265"}(g||(g={}));var b,S=function(){this.pid_stream_type={},this.common_pids={h264:void 0,adts_aac:void 0},this.pes_private_data_pids={},this.timed_id3_pids={}},A=function(){},R=function(){this.slices=[],this.total_length=0,this.expected_length=0,this.file_position=0};!function(e){e[e.kUnspecified=0]="kUnspecified",e[e.kSliceNonIDR=1]="kSliceNonIDR",e[e.kSliceDPA=2]="kSliceDPA",e[e.kSliceDPB=3]="kSliceDPB",e[e.kSliceDPC=4]="kSliceDPC",e[e.kSliceIDR=5]="kSliceIDR",e[e.kSliceSEI=6]="kSliceSEI",e[e.kSliceSPS=7]="kSliceSPS",e[e.kSlicePPS=8]="kSlicePPS",e[e.kSliceAUD=9]="kSliceAUD",e[e.kEndOfSequence=10]="kEndOfSequence",e[e.kEndOfStream=11]="kEndOfStream",e[e.kFiller=12]="kFiller",e[e.kSPSExt=13]="kSPSExt",e[e.kReserved0=14]="kReserved0"}(b||(b={}));var L,T,w=function(){},D=function(e){var t=e.data.byteLength;this.type=e.type,this.data=new Uint8Array(4+t),new DataView(this.data.buffer).setUint32(0,t),this.data.set(e.data,4)},k=function(){function e(e){this.TAG="H264AnnexBParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=e,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&s.a.e(this.TAG,"Could not found H264 startcode until payload end!")}return e.prototype.findNextStartCodeOffset=function(e){for(var t=e,i=this.data_;;){if(t+3>=i.byteLength)return this.eof_flag_=!0,i.byteLength;var n=i[t+0]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3],r=i[t+0]<<16|i[t+1]<<8|i[t+2];if(1===n||1===r)return t;t++}},e.prototype.readNextNaluPayload=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_startcode_offset_,n=31&e[i+=1===(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])?4:3],r=(128&e[i])>>>7,s=this.findNextStartCodeOffset(i);if(this.current_startcode_offset_=s,!(n>=b.kReserved0)&&0===r){var a=e.subarray(i,s);(t=new w).type=n,t.data=a}}return t},e}(),C=function(){function e(e,t,i){var n=8+e.byteLength+1+2+t.byteLength,r=!1;66!==e[3]&&77!==e[3]&&88!==e[3]&&(r=!0,n+=4);var s=this.data=new Uint8Array(n);s[0]=1,s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=255,s[5]=225;var a=e.byteLength;s[6]=a>>>8,s[7]=255&a;var o=8;s.set(e,8),s[o+=a]=1;var h=t.byteLength;s[o+1]=h>>>8,s[o+2]=255&h,s.set(t,o+3),o+=3+h,r&&(s[o]=252|i.chroma_format_idc,s[o+1]=248|i.bit_depth_luma-8,s[o+2]=248|i.bit_depth_chroma-8,s[o+3]=0,o+=4)}return e.prototype.getData=function(){return this.data},e}();!function(e){e[e.kNull=0]="kNull",e[e.kAACMain=1]="kAACMain",e[e.kAAC_LC=2]="kAAC_LC",e[e.kAAC_SSR=3]="kAAC_SSR",e[e.kAAC_LTP=4]="kAAC_LTP",e[e.kAAC_SBR=5]="kAAC_SBR",e[e.kAAC_Scalable=6]="kAAC_Scalable",e[e.kLayer1=32]="kLayer1",e[e.kLayer2=33]="kLayer2",e[e.kLayer3=34]="kLayer3"}(L||(L={})),function(e){e[e.k96000Hz=0]="k96000Hz",e[e.k88200Hz=1]="k88200Hz",e[e.k64000Hz=2]="k64000Hz",e[e.k48000Hz=3]="k48000Hz",e[e.k44100Hz=4]="k44100Hz",e[e.k32000Hz=5]="k32000Hz",e[e.k24000Hz=6]="k24000Hz",e[e.k22050Hz=7]="k22050Hz",e[e.k16000Hz=8]="k16000Hz",e[e.k12000Hz=9]="k12000Hz",e[e.k11025Hz=10]="k11025Hz",e[e.k8000Hz=11]="k8000Hz",e[e.k7350Hz=12]="k7350Hz"}(T||(T={}));var I,O=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],P=function(){},M=function(){function e(e){this.TAG="AACADTSParser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&s.a.e(this.TAG,"Could not found ADTS syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var t=e,i=this.data_;;){if(t+7>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(4095===(i[t+0]<<8|i[t+1])>>>4)return t;t++}},e.prototype.readNextAACFrame=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_syncword_offset_,n=(8&e[i+1])>>>3,r=(6&e[i+1])>>>1,s=1&e[i+1],a=(192&e[i+2])>>>6,o=(60&e[i+2])>>>2,h=(1&e[i+2])<<2|(192&e[i+3])>>>6,d=(3&e[i+3])<<11|e[i+4]<<3|(224&e[i+5])>>>5;e[i+6];if(i+d>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var u=1===s?7:9,_=d-u;i+=u;var l=this.findNextSyncwordOffset(i+_);if(this.current_syncword_offset_=l,(0===n||1===n)&&0===r){var c=e.subarray(i,i+_);(t=new P).audio_object_type=a+1,t.sampling_freq_index=o,t.sampling_frequency=O[o],t.channel_config=h,t.data=c}}return t},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),x=function(e){var t=null,i=e.audio_object_type,n=e.audio_object_type,r=e.sampling_freq_index,s=e.channel_config,a=0,o=navigator.userAgent.toLowerCase();-1!==o.indexOf("firefox")?r>=6?(n=5,t=new Array(4),a=r-3):(n=2,t=new Array(2),a=r):-1!==o.indexOf("android")?(n=2,t=new Array(2),a=r):(n=5,a=r,t=new Array(4),r>=6?a=r-3:1===s&&(n=2,t=new Array(2),a=r)),t[0]=n<<3,t[0]|=(15&r)>>>1,t[1]=(15&r)<<7,t[1]|=(15&s)<<3,5===n&&(t[1]|=(15&a)>>>1,t[2]=(1&a)<<7,t[2]|=8,t[3]=0),this.config=t,this.sampling_rate=O[r],this.channel_count=s,this.codec_mimetype="mp4a.40."+n,this.original_codec_mimetype="mp4a.40."+i},B=function(){},U=function(){},N=(I=function(e,t){return(I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}I(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),F=function(e){function t(t,i){var n=e.call(this)||this;return n.TAG="TSDemuxer",n.first_parse_=!0,n.media_info_=new o.a,n.timescale_=90,n.duration_=0,n.current_pmt_pid_=-1,n.program_pmt_map_={},n.pes_slice_queues_={},n.video_metadata_={sps:void 0,pps:void 0,sps_details:void 0},n.audio_metadata_={audio_object_type:void 0,sampling_freq_index:void 0,sampling_frequency:void 0,channel_config:void 0},n.aac_last_sample_pts_=void 0,n.aac_last_incomplete_data_=null,n.has_video_=!1,n.has_audio_=!1,n.video_init_segment_dispatched_=!1,n.audio_init_segment_dispatched_=!1,n.video_metadata_changed_=!1,n.audio_metadata_changed_=!1,n.video_track_={type:"video",id:1,sequenceNumber:0,samples:[],length:0},n.audio_track_={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},n.ts_packet_size_=t.ts_packet_size,n.sync_offset_=t.sync_offset,n.config_=i,n}return N(t,e),t.prototype.destroy=function(){this.media_info_=null,this.pes_slice_queues_=null,this.video_metadata_=null,this.audio_metadata_=null,this.aac_last_incomplete_data_=null,this.video_track_=null,this.audio_track_=null,e.prototype.destroy.call(this)},t.probe=function(e){var t=new Uint8Array(e),i=-1,n=188;if(t.byteLength<=3*n)return s.a.e("TSDemuxer","Probe data "+t.byteLength+" bytes is too few for judging MPEG-TS stream format!"),{match:!1};for(;-1===i;){for(var r=Math.min(1e3,t.byteLength-3*n),a=0;a=4?(s.a.v("TSDemuxer","ts_packet_size = 192, m2ts mode"),i-=4):204===n&&s.a.v("TSDemuxer","ts_packet_size = 204, RS encoded MPEG2-TS stream"),{match:!0,consumed:0,ts_packet_size:n,sync_offset:i})},t.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},t.prototype.resetMediaInfo=function(){this.media_info_=new o.a},t.prototype.parseChunks=function(e,t){if(!(this.onError&&this.onMediaInfo&&this.onTrackMetadata&&this.onDataAvailable))throw new _.a("onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var i=0;for(this.first_parse_&&(this.first_parse_=!1,i=this.sync_offset_);i+this.ts_packet_size_<=e.byteLength;){var n=t+i;192===this.ts_packet_size_&&(i+=4);var r=new Uint8Array(e,i,188),a=r[0];if(71!==a){s.a.e(this.TAG,"sync_byte = "+a+", not 0x47");break}var o=(64&r[1])>>>6,h=(r[1],(31&r[1])<<8|r[2]),d=(48&r[3])>>>4,u=15&r[3],l={},c=4;if(2==d||3==d){var f=r[4];if(5+f===188){i+=188,204===this.ts_packet_size_&&(i+=16);continue}f>0&&(l=this.parseAdaptationField(e,i+4,1+f)),c=5+f}if(1==d||3==d)if(0===h||h===this.current_pmt_pid_){if(o)c+=1+r[c];var p=188-c;0===h?this.parsePAT(e,i+c,p,{payload_unit_start_indicator:o,continuity_conunter:u}):this.parsePMT(e,i+c,p,{payload_unit_start_indicator:o,continuity_conunter:u})}else if(null!=this.pmt_&&null!=this.pmt_.pid_stream_type[h]){p=188-c;var m=this.pmt_.pid_stream_type[h];h!==this.pmt_.common_pids.h264&&h!==this.pmt_.common_pids.adts_aac&&!0!==this.pmt_.pes_private_data_pids[h]&&!0!==this.pmt_.timed_id3_pids[h]||this.handlePESSlice(e,i+c,p,{pid:h,stream_type:m,file_position:n,payload_unit_start_indicator:o,continuity_conunter:u,random_access_indicator:l.random_access_indicator})}i+=188,204===this.ts_packet_size_&&(i+=16)}return this.dispatchAudioVideoMediaSegment(),i},t.prototype.parseAdaptationField=function(e,t,i){var n=new Uint8Array(e,t,i),r=n[0];return r>0?r>183?(s.a.w(this.TAG,"Illegal adaptation_field_length: "+r),{}):{discontinuity_indicator:(128&n[1])>>>7,random_access_indicator:(64&n[1])>>>6,elementary_stream_priority_indicator:(32&n[1])>>>5}:{}},t.prototype.parsePAT=function(e,t,i,n){var r=new Uint8Array(e,t,i),a=r[0];if(0===a){var o=(15&r[1])<<8|r[2],h=(r[3],r[4],(62&r[5])>>>1),d=1&r[5],u=r[6],_=(r[7],null);if(1===d&&0===u)(_=new E).version_number=h;else if(null==(_=this.pat_))return;for(var l=o-5-4,c=-1,f=-1,p=8;p<8+l;p+=4){var m=r[p]<<8|r[p+1],g=(31&r[p+2])<<8|r[p+3];0===m?_.network_pid=g:(_.program_pmt_pid[m]=g,-1===c&&(c=m),-1===f&&(f=g))}1===d&&0===u&&(null==this.pat_&&s.a.v(this.TAG,"Parsed first PAT: "+JSON.stringify(_)),this.pat_=_,this.current_program_=c,this.current_pmt_pid_=f)}else s.a.e(this.TAG,"parsePAT: table_id "+a+" is not corresponded to PAT!")},t.prototype.parsePMT=function(e,t,i,n){var r=new Uint8Array(e,t,i),a=r[0];if(2===a){var o=(15&r[1])<<8|r[2],h=r[3]<<8|r[4],d=(62&r[5])>>>1,u=1&r[5],_=r[6],l=(r[7],null);if(1===u&&0===_)(l=new S).program_number=h,l.version_number=d,this.program_pmt_map_[h]=l;else if(null==(l=this.program_pmt_map_[h]))return;r[8],r[9];for(var c=(15&r[10])<<8|r[11],f=12+c,p=o-9-c-4,m=f;m0){var b=r.subarray(m+5,m+5+E);this.dispatchPESPrivateDataDescriptor(y,v,b)}}else v===g.kID3&&(l.timed_id3_pids[y]=!0);else l.common_pids.adts_aac=y;else l.common_pids.h264=y;m+=5+E}h===this.current_program_&&(null==this.pmt_&&s.a.v(this.TAG,"Parsed first PMT: "+JSON.stringify(l)),this.pmt_=l,l.common_pids.h264&&(this.has_video_=!0),l.common_pids.adts_aac&&(this.has_audio_=!0))}else s.a.e(this.TAG,"parsePMT: table_id "+a+" is not corresponded to PMT!")},t.prototype.handlePESSlice=function(e,t,i,n){var r=new Uint8Array(e,t,i),a=r[0]<<16|r[1]<<8|r[2],o=(r[3],r[4]<<8|r[5]);if(n.payload_unit_start_indicator){if(1!==a)return void s.a.e(this.TAG,"handlePESSlice: packet_start_code_prefix should be 1 but with value "+a);var h=this.pes_slice_queues_[n.pid];h&&(0===h.expected_length||h.expected_length===h.total_length?this.emitPESSlices(h,n):this.cleanPESSlices(h,n)),this.pes_slice_queues_[n.pid]=new R,this.pes_slice_queues_[n.pid].file_position=n.file_position,this.pes_slice_queues_[n.pid].random_access_indicator=n.random_access_indicator}if(null!=this.pes_slice_queues_[n.pid]){var d=this.pes_slice_queues_[n.pid];d.slices.push(r),n.payload_unit_start_indicator&&(d.expected_length=0===o?0:o+6),d.total_length+=r.byteLength,d.expected_length>0&&d.expected_length===d.total_length?this.emitPESSlices(d,n):d.expected_length>0&&d.expected_length>>6,o=t[8],h=void 0,d=void 0;2!==a&&3!==a||(h=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,d=3===a?536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2:h);var u=9+o,_=void 0;if(0!==r){if(r<3+o)return void s.a.v(this.TAG,"Malformed PES: PES_packet_length < 3 + PES_header_data_length");_=r-3-o}else _=t.byteLength-u;var l=t.subarray(u,u+_);switch(e.stream_type){case g.kMPEG1Audio:case g.kMPEG2Audio:break;case g.kPESPrivateData:this.parsePESPrivateDataPayload(l,h,d,e.pid,n);break;case g.kADTSAAC:this.parseAACPayload(l,h);break;case g.kID3:this.parseTimedID3MetadataPayload(l,h,d,e.pid,n);break;case g.kH264:this.parseH264Payload(l,h,d,e.file_position,e.random_access_indicator);break;case g.kH265:}}else if((188===n||191===n||240===n||241===n||255===n||242===n||248===n)&&e.stream_type===g.kPESPrivateData){u=6,_=void 0;_=0!==r?r:t.byteLength-u;l=t.subarray(u,u+_);this.parsePESPrivateDataPayload(l,void 0,void 0,e.pid,n)}}else s.a.e(this.TAG,"parsePES: packet_start_code_prefix should be 1 but with value "+i)},t.prototype.parseH264Payload=function(e,t,i,n,r){for(var a=new k(e),o=null,h=[],d=0,u=!1;null!=(o=a.readNextNaluPayload());){var _=new D(o);if(_.type===b.kSliceSPS){var l=p.parseSPS(o.data);this.video_init_segment_dispatched_?!0===this.detectVideoMetadataChange(_,l)&&(s.a.v(this.TAG,"H264: Critical h264 metadata has been changed, attempt to re-generate InitSegment"),this.video_metadata_changed_=!0,this.video_metadata_={sps:_,pps:void 0,sps_details:l}):(this.video_metadata_.sps=_,this.video_metadata_.sps_details=l)}else _.type===b.kSlicePPS?this.video_init_segment_dispatched_&&!this.video_metadata_changed_||(this.video_metadata_.pps=_,this.video_metadata_.sps&&this.video_metadata_.pps&&(this.video_metadata_changed_&&this.dispatchVideoMediaSegment(),this.dispatchVideoInitSegment())):(_.type===b.kSliceIDR||_.type===b.kSliceNonIDR&&1===r)&&(u=!0);this.video_init_segment_dispatched_&&(h.push(_),d+=_.data.byteLength)}var c=Math.floor(t/this.timescale_),f=Math.floor(i/this.timescale_);if(h.length){var m=this.video_track_,g={units:h,length:d,isKeyframe:u,dts:f,pts:c,cts:c-f,file_position:n};m.samples.push(g),m.length+=d}},t.prototype.detectVideoMetadataChange=function(e,t){if(t.codec_mimetype!==this.video_metadata_.sps_details.codec_mimetype)return s.a.v(this.TAG,"H264: Codec mimeType changed from "+this.video_metadata_.sps_details.codec_mimetype+" to "+t.codec_mimetype),!0;if(t.codec_size.width!==this.video_metadata_.sps_details.codec_size.width||t.codec_size.height!==this.video_metadata_.sps_details.codec_size.height){var i=this.video_metadata_.sps_details.codec_size,n=t.codec_size;return s.a.v(this.TAG,"H264: Coded Resolution changed from "+i.width+"x"+i.height+" to "+n.width+"x"+n.height),!0}return t.present_size.width!==this.video_metadata_.sps_details.present_size.width&&(s.a.v(this.TAG,"H264: Present resolution width changed from "+this.video_metadata_.sps_details.present_size.width+" to "+t.present_size.width),!0)},t.prototype.isInitSegmentDispatched=function(){return this.has_video_&&this.has_audio_?this.video_init_segment_dispatched_&&this.audio_init_segment_dispatched_:this.has_video_&&!this.has_audio_?this.video_init_segment_dispatched_:!(this.has_video_||!this.has_audio_)&&this.audio_init_segment_dispatched_},t.prototype.dispatchVideoInitSegment=function(){var e=this.video_metadata_.sps_details,t={type:"video"};t.id=this.video_track_.id,t.timescale=1e3,t.duration=this.duration_,t.codecWidth=e.codec_size.width,t.codecHeight=e.codec_size.height,t.presentWidth=e.present_size.width,t.presentHeight=e.present_size.height,t.profile=e.profile_string,t.level=e.level_string,t.bitDepth=e.bit_depth,t.chromaFormat=e.chroma_format,t.sarRatio=e.sar_ratio,t.frameRate=e.frame_rate;var i=t.frameRate.fps_den,n=t.frameRate.fps_num;t.refSampleDuration=i/n*1e3,t.codec=e.codec_mimetype;var r=this.video_metadata_.sps.data.subarray(4),a=this.video_metadata_.pps.data.subarray(4),o=new C(r,a,e);t.avcc=o.getData(),0==this.video_init_segment_dispatched_&&s.a.v(this.TAG,"Generated first AVCDecoderConfigurationRecord for mimeType: "+t.codec),this.onTrackMetadata("video",t),this.video_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var h=this.media_info_;h.hasVideo=!0,h.width=t.codecWidth,h.height=t.codecHeight,h.fps=t.frameRate.fps,h.profile=t.profile,h.level=t.level,h.refFrames=e.ref_frames,h.chromaFormat=e.chroma_format_string,h.sarNum=t.sarRatio.width,h.sarDen=t.sarRatio.height,h.videoCodec=t.codec,h.hasAudio&&h.audioCodec?h.mimeType='video/mp2t; codecs="'+h.videoCodec+","+h.audioCodec+'"':h.mimeType='video/mp2t; codecs="'+h.videoCodec+'"',h.isComplete()&&this.onMediaInfo(h)},t.prototype.dispatchVideoMediaSegment=function(){this.isInitSegmentDispatched()&&this.video_track_.length&&this.onDataAvailable(null,this.video_track_)},t.prototype.dispatchAudioMediaSegment=function(){this.isInitSegmentDispatched()&&this.audio_track_.length&&this.onDataAvailable(this.audio_track_,null)},t.prototype.dispatchAudioVideoMediaSegment=function(){this.isInitSegmentDispatched()&&(this.audio_track_.length||this.video_track_.length)&&this.onDataAvailable(this.audio_track_,this.video_track_)},t.prototype.parseAACPayload=function(e,t){if(!this.has_video_||this.video_init_segment_dispatched_){if(this.aac_last_incomplete_data_){var i=new Uint8Array(e.byteLength+this.aac_last_incomplete_data_.byteLength);i.set(this.aac_last_incomplete_data_,0),i.set(e,this.aac_last_incomplete_data_.byteLength),e=i}var n,r;if(null!=t)r=t/this.timescale_;else{if(null==this.aac_last_sample_pts_)return void s.a.w(this.TAG,"AAC: Unknown pts");n=1024/this.audio_metadata_.sampling_frequency*1e3,r=this.aac_last_sample_pts_+n}if(this.aac_last_incomplete_data_&&this.aac_last_sample_pts_){n=1024/this.audio_metadata_.sampling_frequency*1e3;var a=this.aac_last_sample_pts_+n;Math.abs(a-r)>1&&(s.a.w(this.TAG,"AAC: Detected pts overlapped, expected: "+a+"ms, PES pts: "+r+"ms"),r=a)}for(var o,h=new M(e),d=null,u=r;null!=(d=h.readNextAACFrame());){n=1024/d.sampling_frequency*1e3,0==this.audio_init_segment_dispatched_?(this.audio_metadata_.audio_object_type=d.audio_object_type,this.audio_metadata_.sampling_freq_index=d.sampling_freq_index,this.audio_metadata_.sampling_frequency=d.sampling_frequency,this.audio_metadata_.channel_config=d.channel_config,this.dispatchAudioInitSegment(d)):this.detectAudioMetadataChange(d)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(d)),o=u;var _=Math.floor(u),l={unit:d.data,length:d.data.byteLength,pts:_,dts:_};this.audio_track_.samples.push(l),this.audio_track_.length+=d.data.byteLength,u+=n}h.hasIncompleteData()&&(this.aac_last_incomplete_data_=h.getIncompleteData()),o&&(this.aac_last_sample_pts_=o)}},t.prototype.detectAudioMetadataChange=function(e){return e.audio_object_type!==this.audio_metadata_.audio_object_type?(s.a.v(this.TAG,"AAC: AudioObjectType changed from "+this.audio_metadata_.audio_object_type+" to "+e.audio_object_type),!0):e.sampling_freq_index!==this.audio_metadata_.sampling_freq_index?(s.a.v(this.TAG,"AAC: SamplingFrequencyIndex changed from "+this.audio_metadata_.sampling_freq_index+" to "+e.sampling_freq_index),!0):e.channel_config!==this.audio_metadata_.channel_config&&(s.a.v(this.TAG,"AAC: Channel configuration changed from "+this.audio_metadata_.channel_config+" to "+e.channel_config),!0)},t.prototype.dispatchAudioInitSegment=function(e){var t=new x(e),i={type:"audio"};i.id=this.audio_track_.id,i.timescale=1e3,i.duration=this.duration_,i.audioSampleRate=t.sampling_rate,i.channelCount=t.channel_count,i.codec=t.codec_mimetype,i.originalCodec=t.original_codec_mimetype,i.config=t.config,i.refSampleDuration=1024/i.audioSampleRate*i.timescale,0==this.audio_init_segment_dispatched_&&s.a.v(this.TAG,"Generated first AudioSpecificConfig for mimeType: "+i.codec),this.onTrackMetadata("audio",i),this.audio_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var n=this.media_info_;n.hasAudio=!0,n.audioCodec=i.originalCodec,n.audioSampleRate=i.audioSampleRate,n.audioChannelCount=i.channelCount,n.hasVideo&&n.videoCodec?n.mimeType='video/mp2t; codecs="'+n.videoCodec+","+n.audioCodec+'"':n.mimeType='video/mp2t; codecs="'+n.audioCodec+'"',n.isComplete()&&this.onMediaInfo(n)},t.prototype.dispatchPESPrivateDataDescriptor=function(e,t,i){var n=new U;n.pid=e,n.stream_type=t,n.descriptor=i,this.onPESPrivateDataDescriptor&&this.onPESPrivateDataDescriptor(n)},t.prototype.parsePESPrivateDataPayload=function(e,t,i,n,r){var s=new B;if(s.pid=n,s.stream_id=r,s.len=e.byteLength,s.data=e,null!=t){var a=Math.floor(t/this.timescale_);s.pts=a}else s.nearest_pts=this.aac_last_sample_pts_;if(null!=i){var o=Math.floor(i/this.timescale_);s.dts=o}this.onPESPrivateData&&this.onPESPrivateData(s)},t.prototype.parseTimedID3MetadataPayload=function(e,t,i,n,r){var s=new B;if(s.pid=n,s.stream_id=r,s.len=e.byteLength,s.data=e,null!=t){var a=Math.floor(t/this.timescale_);s.pts=a}if(null!=i){var o=Math.floor(i/this.timescale_);s.dts=o}this.onTimedID3Metadata&&this.onTimedID3Metadata(s)},t}(y),G=function(){function e(){}return e.init=function(){for(var t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=e.constants={};i.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),i.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),i.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSC=i.STCO=i.STTS,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.HDLR_VIDEO=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]),i.HDLR_AUDIO=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]),i.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=8,i=null,n=Array.prototype.slice.call(arguments,1),r=n.length,s=0;s>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);var a=8;for(s=0;s>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var i=t.id,n=t.duration,r=t.presentWidth,s=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,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,r>>>8&255,255&r,0,0,s>>>8&255,255&s,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var i=t.timescale,n=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))},e.hdlr=function(t){var i=null;return i="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,i)},e.minf=function(t){var i=null;return i="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,i,e.dinf(),e.stbl(t))},e.dinf=function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types[".mp3"],r)},e.mp4a=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types.mp4a,r,e.esds(t))},e.esds=function(t){var i=t.config||[],n=i.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(i).concat([6,1,2]));return e.box(e.types.esds,r)},e.avc1=function(t){var i=t.avcc,n=t.codecWidth,r=t.codecHeight,s=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,n>>>8&255,255&n,r>>>8&255,255&r,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 e.box(e.types.avc1,s,e.box(e.types.avcC,i))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var i=t.id,n=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,n)},e.moof=function(t,i){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,i))},e.mfhd=function(t){var i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,i)},e.traf=function(t,i){var n=t.id,r=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),s=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),a=e.sdtp(t),o=e.trun(t,a.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,r,s,o,a)},e.sdtp=function(t){for(var i=t.samples||[],n=i.length,r=new Uint8Array(4+n),s=0;s>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0);for(var o=0;o>>24&255,h>>>16&255,h>>>8&255,255&h,d>>>24&255,d>>>16&255,d>>>8&255,255&d,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.isNonSync,0,0,_>>>24&255,_>>>16&255,_>>>8&255,255&_],12+16*o)}return e.box(e.types.trun,a)},e.mdat=function(t){return e.box(e.types.mdat,t)},e}();G.init();var V=G,j=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){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])}else{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},e}(),z=i(7),H=function(){function e(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,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 z.c("audio"),this._videoSegmentInfoList=new z.c("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!a.a.chrome||!(a.a.version.major<50||50===a.a.version.major&&a.a.version.build<2661)),this._fillSilentAfterSeek=a.a.msedge||a.a.msie,this._mp3UseMpegAudio=!a.a.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.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},e.prototype.bindDataSource=function(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,t){if(!this._onMediaSegment)throw new _.a("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),t&&this._remuxVideo(t),e&&this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,t){var i=null,n="mp4",r=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(n="mpeg",r="",i=new Uint8Array):i=V.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=V.generateInitSegment(t)}if(!this._onInitSegment)throw new _.a("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:r,container:e+"/"+n,mediaDuration:t.duration})},e.prototype._calculateDtsBase=function(e,t){this._dtsBaseInited||(e&&e.samples&&e.samples.length&&(this._audioDtsBase=e.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)},e.prototype.getTimestampBase=function(){if(this._dtsBaseInited)return this._dtsBase},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);var n={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(n.samples.push(t),n.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(n,!0)},e.prototype._remuxAudio=function(e,t){if(null!=this._audioMeta){var i,n=e,r=n.samples,o=void 0,h=-1,d=this._audioMeta.refSampleDuration,u="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,_=this._dtsBaseInited&&void 0===this._audioNextDts,l=!1;if(r&&0!==r.length&&(1!==r.length||t)){var c=0,f=null,p=0;u?(c=0,p=n.length):(c=8,p=8+n.length);var m=null;if(r.length>1&&(p-=(m=r.pop()).length),null!=this._audioStashedLastSample){var g=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(g),p+=g.length}null!=m&&(this._audioStashedLastSample=m);var v=r[0].dts-this._dtsBase;if(this._audioNextDts)o=v-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())o=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(l=!0);else{var y=this._audioSegmentInfoList.getLastSampleBefore(v);if(null!=y){var E=v-(y.originalDts+y.duration);E<=3&&(E=0),o=v-(y.dts+y.duration+E)}else o=0}if(l){var b=v-o,S=this._videoSegmentInfoList.getLastSegmentBefore(v);if(null!=S&&S.beginDts=3*d&&this._fillAudioTimestampGap&&!a.a.safari){k=!0;var P,M=Math.floor(o/d);s.a.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\noriginalDts: "+D+" ms, curRefDts: "+O+" ms, dtsCorrection: "+Math.round(o)+" ms, generate: "+M+" frames"),A=Math.floor(O),I=Math.floor(O+d)-A,null==(P=j.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount))&&(s.a.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),P=w),C=[];for(var x=0;x=1?L[L.length-1].duration:Math.floor(d);this._audioNextDts=A+I}-1===h&&(h=A),L.push({dts:A,pts:A,cts:0,unit:g.unit,size:g.unit.byteLength,duration:I,originalDts:D,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),k&&L.push.apply(L,C)}}if(0===L.length)return n.samples=[],void(n.length=0);u?f=new Uint8Array(p):((f=new Uint8Array(p))[0]=p>>>24&255,f[1]=p>>>16&255,f[2]=p>>>8&255,f[3]=255&p,f.set(V.types.mdat,4));for(T=0;T1&&(_-=(l=s.pop()).length),null!=this._videoStashedLastSample){var c=this._videoStashedLastSample;this._videoStashedLastSample=null,s.unshift(c),_+=c.length}null!=l&&(this._videoStashedLastSample=l);var f=s[0].dts-this._dtsBase;if(this._videoNextDts)a=f-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())a=0;else{var p=this._videoSegmentInfoList.getLastSampleBefore(f);if(null!=p){var m=f-(p.originalDts+p.duration);m<=3&&(m=0),a=f-(p.dts+p.duration+m)}else a=0}for(var g=new z.b,v=[],y=0;y=1?v[v.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(b){var T=new z.d(S,R,L,c.dts,!0);T.fileposition=c.fileposition,g.appendSyncPoint(T)}v.push({dts:S,pts:R,cts:A,units:c.units,size:c.length,isKeyframe:b,duration:L,originalDts:E,flags:{isLeading:0,dependsOn:b?2:1,isDependedOn:b?1:0,hasRedundancy:0,isNonSync:b?0:1}})}(u=new Uint8Array(_))[0]=_>>>24&255,u[1]=_>>>16&255,u[2]=_>>>8&255,u[3]=255&_,u.set(V.types.mdat,4);for(y=0;y0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=F.probe(e)).match){var a=this._demuxer=new F(n,this._config);this._remuxer||(this._remuxer=new H(this._config)),a.onError=this._onDemuxException.bind(this),a.onMediaInfo=this._onMediaInfo.bind(this),a.onMetaDataArrived=this._onMetaDataArrived.bind(this),a.onTimedID3Metadata=this._onTimedID3Metadata.bind(this),a.onPESPrivateDataDescriptor=this._onPESPrivateDataDescriptor.bind(this),a.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),r=this._demuxer.parseChunks(e,t)}else if((n=v.probe(e)).match){this._demuxer=new v(n,this._config),this._remuxer||(this._remuxer=new H(this._config));var o=this._mediaDataSource;null==o.duration||isNaN(o.duration)||(this._demuxer.overridedDuration=o.duration),"boolean"==typeof o.hasAudio&&(this._demuxer.overridedHasAudio=o.hasAudio),"boolean"==typeof o.hasVideo&&(this._demuxer.overridedHasVideo=o.hasVideo),this._demuxer.timestampBase=o.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._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),r=this._demuxer.parseChunks(e,t)}else n=null,s.a.e(this.TAG,"Non MPEG-TS/FLV, Unsupported media type!"),Promise.resolve().then((function(){i._internalAbort()})),this._emitter.emit(K.a.DEMUX_ERROR,m.a.FORMAT_UNSUPPORTED,"Non MPEG-TS/FLV, Unsupported media type!"),r=0;return r},e.prototype._onMediaInfo=function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,o.a.prototype));var i=Object.assign({},e);Object.setPrototypeOf(i,o.a.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=i,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(K.a.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(K.a.SCRIPTDATA_ARRIVED,e)},e.prototype._onTimedID3Metadata=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.dts&&(e.dts-=t),this._emitter.emit(K.a.TIMED_ID3_METADATA_ARRIVED,e))},e.prototype._onPESPrivateDataDescriptor=function(e){this._emitter.emit(K.a.PES_PRIVATE_DATA_DESCRIPTOR,e)},e.prototype._onPESPrivateData=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.nearest_pts&&(e.nearest_pts-=t),null!=e.dts&&(e.dts-=t),this._emitter.emit(K.a.PES_PRIVATE_DATA_ARRIVED,e))},e.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e+1;t0&&i[0].originalDts===n&&(n=i[0].pts),this._emitter.emit(K.a.RECOMMEND_SEEKPOINT,n)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(K.a.MEDIA_INFO,i)},e.prototype._reportStatisticsInfo=function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(K.a.STATISTICS_INFO,e)},e}();t.a=W},function(e,t,i){"use strict";var n,r=i(0),s=function(){function e(){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 e.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},e.prototype.addBytes=function(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())},Object.defineProperty(e.prototype,"currentKBps",{get:function(){this.addBytes(0);var e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}(),a=i(2),o=i(4),h=i(3),d=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),u=function(e){function t(t,i){var n=e.call(this,"fetch-stream-loader")||this;return n.TAG="FetchStreamLoader",n._seekHandler=t,n._config=i,n._needStash=!0,n._requestAbort=!1,n._abortController=null,n._contentLength=null,n._receivedLength=0,n}return d(t,e),t.isSupported=function(){try{var e=o.a.msedge&&o.a.version.minor>=15048,t=!o.a.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){var i=this;this._dataSource=e,this._range=t;var n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);var r=this._seekHandler.getConfig(n,t),s=new self.Headers;if("object"==typeof r.headers){var o=r.headers;for(var d in o)o.hasOwnProperty(d)&&s.append(d,o[d])}var u={method:"GET",headers:s,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(var d in this._config.headers)s.append(d,this._config.headers[d]);!1===e.cors&&(u.mode="same-origin"),e.withCredentials&&(u.credentials="include"),e.referrerPolicy&&(u.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,u.signal=this._abortController.signal),this._status=a.c.kConnecting,self.fetch(r.url,u).then((function(e){if(i._requestAbort)return i._status=a.c.kIdle,void e.body.cancel();if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&i._onURLRedirect){var t=i._seekHandler.removeURLParameters(e.url);i._onURLRedirect(t)}var n=e.headers.get("Content-Length");return null!=n&&(i._contentLength=parseInt(n),0!==i._contentLength&&i._onContentLengthKnown&&i._onContentLengthKnown(i._contentLength)),i._pump.call(i,e.body.getReader())}if(i._status=a.c.kError,!i._onError)throw new h.d("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);i._onError(a.b.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){if(!i._abortController||!i._abortController.signal.aborted){if(i._status=a.c.kError,!i._onError)throw e;i._onError(a.b.EXCEPTION,{code:-1,msg:e.message})}}))},t.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==a.c.kBuffering||!o.a.chrome)&&this._abortController)try{this._abortController.abort()}catch(e){}},t.prototype._pump=function(e){var t=this;return e.read().then((function(i){if(i.done)if(null!==t._contentLength&&t._receivedLength299)){if(this._status=a.c.kError,!this._onError)throw new h.d("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(a.b.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=a.c.kBuffering}},t.prototype._onProgress=function(e){if(this._status!==a.c.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}},t.prototype._onLoadEnd=function(e){!0!==this._requestAbort?this._status!==a.c.kError&&(this._status=a.c.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},t.prototype._onXhrError=function(e){this._status=a.c.kError;var t=0,i=null;if(this._contentLength&&e.loaded=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)},t.prototype._internalOpen=function(e,t){this._lastTimeLoaded=0;var i=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?i=this._currentRedirectedURL:null!=e.redirectedURL&&(i=e.redirectedURL));var n=this._seekHandler.getConfig(i,t);this._currentRequestURL=n.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",n.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"==typeof n.headers){var s=n.headers;for(var a in s)s.hasOwnProperty(a)&&r.setRequestHeader(a,s[a])}if("object"==typeof this._config.headers){s=this._config.headers;for(var a in s)s.hasOwnProperty(a)&&r.setRequestHeader(a,s[a])}r.send()},t.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=a.c.kComplete},t.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)},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(null!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=a.c.kBuffering}else{if(this._status=a.c.kError,!this._onError)throw new h.d("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(a.b.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}},t.prototype._onProgress=function(e){if(this._status!==a.c.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var n=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(n)}},t.prototype._normalizeSpeed=function(e){var t=this._chunkSizeKBList,i=t.length-1,n=0,r=0,s=i;if(e=t[n]&&e=3&&(t=this._speedSampler.currentKBps)),0!==t){var i=this._normalizeSpeed(t);this._currentSpeedNormalized!==i&&(this._currentSpeedNormalized=i,this._currentChunkSizeKB=i)}var n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;var s=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength0)for(var s=i.split("&"),a=0;a0;o[0]!==this._startName&&o[0]!==this._endName&&(h&&(r+="&"),r+=s[a])}return 0===r.length?t:t+"?"+r},e}(),y=function(){function e(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=65536,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new s,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 e.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},e.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){return this._loaderClass===f?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new g(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new v(t,i)}else{if("custom"!==e.seekType)throw new h.b("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new h.b("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=m;else if(u.isSupported())this._loaderClass=u;else if(l.isSupported())this._loaderClass=l;else{if(!f.isSupported())throw new h.d("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=f}},e.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(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)},e.prototype.open=function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(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)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!=typeof e||0===e.length)throw new h.b("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){for(var t=this._stashSize;t+10485760){var n=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(i,0,t).set(n,0)}this._stashBuffer=i,this._bufferSize=t}},e.prototype._normalizeSpeed=function(e){var t=this._speedNormalizeList,i=t.length-1,n=0,r=0,s=i;if(e=t[n]&&e=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(t=8192);var i=1024*t+1048576;this._bufferSize0){var s=this._stashBuffer.slice(0,this._stashUsed);if((d=this._dispatchChunks(s,this._stashByteStart))0){u=new Uint8Array(s,d);o.set(u,0),this._stashUsed=u.byteLength,this._stashByteStart+=d}}else this._stashUsed=0,this._stashByteStart+=d;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{if((d=this._dispatchChunks(e,t))this._bufferSize&&(this._expandBuffer(a),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e,d),0),this._stashUsed+=a,this._stashByteStart=t+d}}else if(0===this._stashUsed){var a;if((d=this._dispatchChunks(e,t))this._bufferSize&&this._expandBuffer(a),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e,d),0),this._stashUsed+=a,this._stashByteStart=t+d}else{var o,d;if(this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength,(d=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart))0){var u=new Uint8Array(this._stashBuffer,d);o.set(u,0)}this._stashUsed-=d,this._stashByteStart+=d}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),n=t.byteLength-i;if(i0){var s=new Uint8Array(this._stashBuffer,0,this._bufferSize),a=new Uint8Array(t,i);s.set(a,0),this._stashUsed=a.byteLength,this._stashByteStart+=i}return 0}r.a.w(this.TAG,n+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,n}return 0},e.prototype._onLoaderComplete=function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,t){switch(r.a.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=a.b.UNRECOVERABLE_EARLY_EOF),e){case a.b.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var i=this._currentRange.to+1;return void(i0}),!1)}e.exports=function(e,t){t=t||{};var r={main:i.m},o=t.all?{main:Object.keys(r.main)}:function(e,t){for(var i={main:[t]},n={main:[]},r={main:{}};a(i);)for(var o=Object.keys(i),h=0;h1)for(var i=1;i0&&(n+=";codecs="+i.codec);var r=!1;if(_.a.v(this.TAG,"Received Initialization Segment, mimeType: "+n),this._lastInitSegments[i.type]=i,n!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])_.a.v(this.TAG,"Notice: "+i.type+" mimeType changed, origin: "+this._mimeTypes[i.type]+", target: "+n);else{r=!0;try{var s=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(n);s.addEventListener("error",this.e.onSourceBufferError),s.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return _.a.e(this.TAG,e.message),void this._emitter.emit(b.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=n}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),l.a.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.seek=function(e){for(var t in this._sourceBuffers)if(this._sourceBuffers[t]){var i=this._sourceBuffers[t];if("open"===this._mediaSource.readyState)try{i.abort()}catch(e){_.a.e(this.TAG,e.message)}this._idrList.clear();var n=this._pendingSegments[t];if(n.splice(0,n.length),"closed"!==this._mediaSource.readyState){for(var r=0;r=1&&e-n.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){for(var n=i.buffered,r=!1,s=0;s=this._config.autoCleanupMaxBackwardDuration){r=!0;var h=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:a,end:h})}}else o0&&(isNaN(t)||i>t)&&(_.a.v(this.TAG,"Update MediaSource duration from "+t+" to "+i),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(var t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];i.length&&!t.updating;){var n=i.shift();t.remove(n.start,n.end)}},e.prototype._doAppendSegments=function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var i=e[t].shift();if(i.timestampOffset){var n=this._sourceBuffers[t].timestampOffset,r=i.timestampOffset/1e3;Math.abs(n-r)>.1&&(_.a.v(this.TAG,"Update MPEG audio timestampOffset from "+n+" to "+r),this._sourceBuffers[t].timestampOffset=r),delete i.timestampOffset}if(!i.data||0===i.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(i.data),this._isBufferFull=!1,"video"===t&&i.hasOwnProperty("info")&&this._idrList.appendArray(i.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(i),22===e.code?(this._isBufferFull||this._emitter.emit(b.BUFFER_FULL),this._isBufferFull=!0):(_.a.e(this.TAG,e.message),this._emitter.emit(b.ERROR,{code:e.code,msg:e.message}))}}},e.prototype._onSourceOpen=function(){if(_.a.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var e=this._pendingSourceBufferInit;e.length;){var t=e.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(b.SOURCE_OPEN)},e.prototype._onSourceEnded=function(){_.a.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){_.a.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(b.UPDATE_END)},e.prototype._onSourceBufferError=function(e){_.a.e(this.TAG,"SourceBuffer Error: "+e)},e}(),L=i(5),T={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},w={NETWORK_EXCEPTION:h.b.EXCEPTION,NETWORK_STATUS_CODE_INVALID:h.b.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:h.b.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:h.b.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:L.a.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:L.a.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:L.a.CODEC_UNSUPPORTED},D=function(){function e(e,t){this.TAG="MSEPlayer",this._type="MSEPlayer",this._emitter=new u.a,this._config=a(),"object"==typeof t&&Object.assign(this._config,t);var i=e.type.toLowerCase();if("mse"!==i&&"mpegts"!==i&&"m2ts"!==i&&"flv"!==i)throw new A.b("MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var n=l.a.chrome&&(l.a.version.major<50||50===l.a.version.major&&l.a.version.build<2661);this._alwaysSeekKeyframe=!!(n||l.a.msedge||l.a.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return e.prototype.destroy=function(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;e===c.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then((function(){i._emitter.emit(c.MEDIA_INFO,i.mediaInfo)})):e===c.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then((function(){i._emitter.emit(c.STATISTICS_INFO,i.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){var t=this;if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new R(this._config),this._msectl.on(b.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(b.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(b.SOURCE_OPEN,(function(){t._mseSourceOpened=!0,t._hasPendingLoad&&(t._hasPendingLoad=!1,t.load())})),this._msectl.on(b.ERROR,(function(e){t._emitter.emit(c.ERROR,T.MEDIA_ERROR,w.MEDIA_MSE_ERROR,e)})),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},e.prototype.load=function(){var e=this;if(!this._mediaElement)throw new A.a("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new A.a("MSEPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new E(this._mediaDataSource,this._config),this._transmuxer.on(v.a.INIT_SEGMENT,(function(t,i){e._msectl.appendInitSegment(i)})),this._transmuxer.on(v.a.MEDIA_SEGMENT,(function(t,i){if(e._msectl.appendMediaSegment(i),e._config.lazyLoad&&!e._config.isLive){var n=e._mediaElement.currentTime;i.info.endDts>=1e3*(n+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(_.a.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}})),this._transmuxer.on(v.a.LOADING_COMPLETE,(function(){e._msectl.endOfStream(),e._emitter.emit(c.LOADING_COMPLETE)})),this._transmuxer.on(v.a.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(c.RECOVERED_EARLY_EOF)})),this._transmuxer.on(v.a.IO_ERROR,(function(t,i){e._emitter.emit(c.ERROR,T.NETWORK_ERROR,t,i)})),this._transmuxer.on(v.a.DEMUX_ERROR,(function(t,i){e._emitter.emit(c.ERROR,T.MEDIA_ERROR,t,{code:-1,msg:i})})),this._transmuxer.on(v.a.MEDIA_INFO,(function(t){e._mediaInfo=t,e._emitter.emit(c.MEDIA_INFO,Object.assign({},t))})),this._transmuxer.on(v.a.METADATA_ARRIVED,(function(t){e._emitter.emit(c.METADATA_ARRIVED,t)})),this._transmuxer.on(v.a.SCRIPTDATA_ARRIVED,(function(t){e._emitter.emit(c.SCRIPTDATA_ARRIVED,t)})),this._transmuxer.on(v.a.TIMED_ID3_METADATA_ARRIVED,(function(t){e._emitter.emit(c.TIMED_ID3_METADATA_ARRIVED,t)})),this._transmuxer.on(v.a.PES_PRIVATE_DATA_DESCRIPTOR,(function(t){e._emitter.emit(c.PES_PRIVATE_DATA_DESCRIPTOR,t)})),this._transmuxer.on(v.a.PES_PRIVATE_DATA_ARRIVED,(function(t){e._emitter.emit(c.PES_PRIVATE_DATA_ARRIVED,t)})),this._transmuxer.on(v.a.STATISTICS_INFO,(function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(c.STATISTICS_INFO,Object.assign({},e._statisticsInfo))})),this._transmuxer.on(v.a.RECOMMEND_SEEKPOINT,(function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)})),this._transmuxer.open()))},e.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._mediaInfo)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)},enumerable:!1,configurable:!0}),e.prototype._fillStatisticsInfo=function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e},e.prototype._onmseUpdateEnd=function(){var e=this._mediaElement.buffered,t=this._mediaElement.currentTime;if(this._config.isLive&&this._config.liveBufferLatencyChasing&&e.length>0&&!this._mediaElement.paused){var i=e.end(e.length-1);if(i>this._config.liveBufferLatencyMaxLatency&&i-t>this._config.liveBufferLatencyMaxLatency){var n=i-this._config.liveBufferLatencyMinRemain;this.currentTime=n}}if(this._config.lazyLoad&&!this._config.isLive){for(var r=0,s=0;s=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(_.a.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},e.prototype._onmseBufferFull=function(){_.a.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()},e.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},e.prototype._checkProgressAndResume=function(){for(var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1,n=0;n=r&&e=s-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(_.a.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))},e.prototype._isTimepointBuffered=function(e){for(var t=this._mediaElement.buffered,i=0;i=n&&e0){var r=this._mediaElement.buffered.start(0);(r<1&&e0&&t.currentTime0){var n=i.start(0);if(n<1&&t0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){var e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e},enumerable:!1,configurable:!0}),e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(c.MEDIA_INFO,this.mediaInfo)},e.prototype._reportStatisticsInfo=function(){this._emitter.emit(c.STATISTICS_INFO,this.statisticsInfo)},e}();n.a.install();var C={createPlayer:function(e,t){var i=e;if(null==i||"object"!=typeof i)throw new A.b("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new A.b("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"mse":case"mpegts":case"m2ts":case"flv":return new D(i,t);default:return new k(i,t)}},isSupported:function(){return o.supportMSEH264Playback()},getFeatureList:function(){return o.getFeatureList()}};C.BaseLoader=h.a,C.LoaderStatus=h.c,C.LoaderErrors=h.b,C.Events=c,C.ErrorTypes=T,C.ErrorDetails=w,C.MSEPlayer=D,C.NativePlayer=k,C.LoggingControl=m.a,Object.defineProperty(C,"version",{enumerable:!0,get:function(){return"1.6.10"}});t.default=C}])})); -//# sourceMappingURL=mpegts.js.map \ No newline at end of file diff --git a/trunk/research/players/js/mpegts-1.6.10.min.js.map b/trunk/research/players/js/mpegts-1.6.10.min.js.map deleted file mode 100644 index 63f8bc3045..0000000000 --- a/trunk/research/players/js/mpegts-1.6.10.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["webpack://mpegts/webpack/universalModuleDefinition","webpack://mpegts/webpack/bootstrap","webpack://mpegts/./src/utils/logger.js","webpack://mpegts/./src/core/transmuxing-events.js","webpack://mpegts/./src/io/loader.js","webpack://mpegts/./src/utils/exception.js","webpack://mpegts/./src/utils/browser.js","webpack://mpegts/./src/demux/demux-errors.js","webpack://mpegts/./node_modules/events/events.js","webpack://mpegts/./src/core/media-segment-info.js","webpack://mpegts/./src/core/media-info.js","webpack://mpegts/./src/utils/logging-control.js","webpack://mpegts/./src/utils/utf8-conv.js","webpack://mpegts/./src/demux/amf-parser.js","webpack://mpegts/./src/demux/exp-golomb.js","webpack://mpegts/./src/demux/sps-parser.js","webpack://mpegts/./src/demux/flv-demuxer.js","webpack://mpegts/./src/demux/pat-pmt-pes.ts","webpack://mpegts/./src/demux/base-demuxer.ts","webpack://mpegts/./src/demux/h264.ts","webpack://mpegts/./src/demux/mpeg4-audio.ts","webpack://mpegts/./src/demux/aac.ts","webpack://mpegts/./src/demux/pes-private-data.ts","webpack://mpegts/./src/demux/ts-demuxer.ts","webpack://mpegts/./src/remux/mp4-generator.js","webpack://mpegts/./src/remux/aac-silent.js","webpack://mpegts/./src/remux/mp4-remuxer.js","webpack://mpegts/./src/core/transmuxing-controller.js","webpack://mpegts/./src/io/speed-sampler.js","webpack://mpegts/./src/io/fetch-stream-loader.js","webpack://mpegts/./src/io/xhr-moz-chunked-loader.js","webpack://mpegts/./src/io/xhr-range-loader.js","webpack://mpegts/./src/io/websocket-loader.js","webpack://mpegts/./src/io/range-seek-handler.js","webpack://mpegts/./src/io/param-seek-handler.js","webpack://mpegts/./src/io/io-controller.js","webpack://mpegts/./src/utils/polyfill.js","webpack://mpegts/./node_modules/webworkify-webpack/index.js","webpack://mpegts/./src/index.js","webpack://mpegts/./node_modules/es6-promise/dist/es6-promise.js","webpack://mpegts/./node_modules/process/browser.js","webpack://mpegts/(webpack)/buildin/global.js","webpack://mpegts/./src/core/transmuxing-worker.js","webpack://mpegts/./src/config.js","webpack://mpegts/./src/core/features.js","webpack://mpegts/./src/player/player-events.js","webpack://mpegts/./src/core/transmuxer.js","webpack://mpegts/./src/core/mse-events.js","webpack://mpegts/./src/core/mse-controller.js","webpack://mpegts/./src/player/player-errors.js","webpack://mpegts/./src/player/mse-player.js","webpack://mpegts/./src/player/native-player.js","webpack://mpegts/./src/mpegts.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","e","tag","msg","Log","FORCE_GLOBAL_TAG","GLOBAL_TAG","str","ENABLE_CALLBACK","emitter","emit","ENABLE_ERROR","console","error","warn","log","ENABLE_INFO","info","w","ENABLE_WARN","ENABLE_DEBUG","debug","v","ENABLE_VERBOSE","IO_ERROR","DEMUX_ERROR","INIT_SEGMENT","MEDIA_SEGMENT","LOADING_COMPLETE","RECOVERED_EARLY_EOF","MEDIA_INFO","METADATA_ARRIVED","SCRIPTDATA_ARRIVED","TIMED_ID3_METADATA_ARRIVED","PES_PRIVATE_DATA_DESCRIPTOR","PES_PRIVATE_DATA_ARRIVED","STATISTICS_INFO","RECOMMEND_SEEKPOINT","LoaderStatus","kIdle","kConnecting","kBuffering","kError","kComplete","LoaderErrors","OK","EXCEPTION","HTTP_STATUS_CODE_INVALID","CONNECTING_TIMEOUT","EARLY_EOF","UNRECOVERABLE_EARLY_EOF","typeName","this","_type","_status","_needStash","_onContentLengthKnown","_onURLRedirect","_onDataArrival","_onError","_onComplete","destroy","isWorking","callback","open","dataSource","range","abort","message","_message","toString","RuntimeException","Browser","ua","self","navigator","userAgent","toLowerCase","match","exec","indexOf","platform_match","matched","browser","version","majorVersion","platform","versionArray","split","major","parseInt","string","length","minor","build","chrome","opr","safari","webkit","rv","iemobile","edge","android","assign","detect","FORMAT_ERROR","FORMAT_UNSUPPORTED","CODEC_UNSUPPORTED","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","EventEmitter","init","once","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","events","existing","warning","newListener","unshift","push","warned","Error","String","count","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","_listeners","unwrap","evlistener","arr","ret","Array","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","er","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","keys","rawListeners","eventNames","dts","pts","duration","originalDts","isSync","isSyncPoint","fileposition","beginDts","endDts","beginPts","endPts","originalBeginDts","originalEndDts","syncPoints","firstSample","lastSample","appendSyncPoint","sampleInfo","_list","clear","appendArray","getLastSyncPointBeforeDts","idx","last","mid","lbound","ubound","Math","floor","_lastAppendLocation","isEmpty","_searchNearestSegmentBefore","_searchNearestSegmentAfter","append","mediaSegmentInfo","msi","lastAppendIdx","insertIdx","splice","getLastSegmentBefore","getLastSampleBefore","segment","getLastSyncPointBefore","segmentIdx","mimeType","hasAudio","hasVideo","audioCodec","videoCodec","audioDataRate","videoDataRate","audioSampleRate","audioChannelCount","width","height","fps","profile","level","refFrames","chromaFormat","sarNum","sarDen","metadata","segments","segmentCount","hasKeyframesIndex","keyframesIndex","isComplete","audioInfoComplete","videoInfoComplete","isSeekable","getNearestKeyframe","milliseconds","table","keyframeIdx","_search","times","filepositions","enable","LoggingControl","_notifyChange","getConfig","globalTag","forceGlobalTag","enableVerbose","enableDebug","enableInfo","enableWarn","enableError","enableCallback","applyConfig","config","registerListener","addLogListener","removeLogListener","checkContinuation","uint8array","start","checkLength","array","buf","out","input","fromCharCode","ucs4","join","ArrayBuffer","DataView","setInt16","Int16Array","parseScriptData","arrayBuffer","dataOffset","dataSize","data","AMF","parseValue","size","parseObject","parseString","isObjectEnd","objectEnd","parseVariable","getUint16","Uint8Array","parseLongString","getUint32","parseDate","timestamp","getFloat64","localTimeOffset","getInt16","Date","offset","getUint8","amfstr","terminal","amfobj","amfvar","strictArrayLength","val","date","amfLongStr","TAG","_buffer","_buffer_index","_total_bytes","byteLength","_total_bits","_current_word","_current_word_bits_left","_fillCurrentWord","buffer_bytes_left","bytes_read","min","word","subarray","buffer","readBits","bits","result","bits_need_left","bits_read_next","result2","readBool","readByte","_skipLeadingZero","zero_count","readUEG","leading_zeros","readSEG","_ebsp2rbsp","src","src_length","dst","dst_idx","parseSPS","codec_array","codec_mimetype","j","h","rbsp","SPSParser","gb","profile_idc","level_idc","profile_string","getProfileString","level_string","getLevelString","chroma_format_idc","chroma_format","bit_depth_luma","bit_depth_chroma","scaling_list_count","_skipScalingList","pic_order_cnt_type","num_ref_frames_in_pic_order_cnt_cycle","ref_frames","pic_width_in_mbs_minus1","pic_height_in_map_units_minus1","frame_mbs_only_flag","frame_crop_left_offset","frame_crop_right_offset","frame_crop_top_offset","frame_crop_bottom_offset","sar_width","sar_height","fps_fixed","fps_num","fps_den","aspect_ratio_idc","num_units_in_tick","time_scale","sarScale","crop_unit_x","crop_unit_y","codec_width","codec_height","present_width","ceil","bit_depth","chroma_format_string","getChromaFormatString","frame_rate","fixed","sar_ratio","codec_size","present_size","last_scale","next_scale","toFixed","chroma","StreamType","probeData","_config","_onMediaInfo","_onMetaDataArrived","_onScriptDataArrived","_onTrackMetadata","_onDataAvailable","_dataOffset","_firstParse","_dispatch","_hasAudio","hasAudioTrack","_hasVideo","hasVideoTrack","_hasAudioFlagOverrided","_hasVideoFlagOverrided","_audioInitialMetadataDispatched","_videoInitialMetadataDispatched","_mediaInfo","_metadata","_audioMetadata","_videoMetadata","_naluLengthSize","_timestampBase","_timescale","_duration","_durationOverrided","_referenceFrameRate","_flvSoundRateTable","_mpegSamplingRates","_mpegAudioV10SampleRateTable","_mpegAudioV20SampleRateTable","_mpegAudioV25SampleRateTable","_mpegAudioL1BitRateTable","_mpegAudioL2BitRateTable","_mpegAudioL3BitRateTable","_videoTrack","id","sequenceNumber","samples","_audioTrack","_littleEndian","probe","mismatch","consumed","bindDataSource","loader","onDataArrival","parseChunks","base","resetMediaInfo","_isInitialMetadataDispatched","chunk","byteStart","le","FLVDemuxer","tagType","ts2","ts1","_parseAudioData","_parseVideoData","_parseScriptData","prevTagSize","scriptData","onMetaData","audiodatarate","videodatarate","framerate","keyframes","_parseKeyframesIndex","time","tagTimestamp","soundSpec","soundFormat","soundRate","soundRateIndex","soundType","meta","track","timescale","channelCount","aacData","_parseAACAudioData","packetType","misc","samplingRate","codec","originalCodec","refSampleDuration","mi","aacSample","unit","_parseMP3AudioData","bitRate","mp3Sample","_parseAACAudioSpecificConfig","originalAudioObjectType","samplingIndex","audioObjectType","extensionSamplingIndex","samplingFrequence","channelConfig","requestHeader","ver","layer","bitrate_index","sampling_freq_index","channel_count","sample_rate","bit_rate","tagPosition","spec","frameType","codecId","_parseAVCVideoPacket","cts","_parseAVCDecoderConfigurationRecord","_parseAVCVideoData","avcc","avcProfile","spsCount","sps","codecWidth","codecHeight","presentWidth","presentHeight","bitDepth","sarRatio","frameRate","codecArray","codecString","ppsCount","units","lengthSize","keyframe","naluSize","unitType","avcSample","isKeyframe","onError","onMediaInfo","onMetaDataArrived","onTrackMetadata","onDataAvailable","onTimedID3Metadata","onPESPrivateData","onPESPrivateDataDescriptor","program_pmt_pid","H264NaluType","pid_stream_type","common_pids","h264","adts_aac","pes_private_data_pids","timed_id3_pids","slices","total_length","expected_length","file_position","MPEG4AudioObjectTypes","MPEG4SamplingFrequencyIndex","nalu","nalu_size","setUint32","current_startcode_offset_","eof_flag_","data_","findNextStartCodeOffset","start_offset","uint32","uint24","readNextNaluPayload","nalu_payload","nalu_type","forbidden_bit","next_startcode_offset","kReserved0","payload_data","H264NaluPayload","pps","sps_details","need_extra_fields","sps_length","pps_length","getData","MPEG4SamplingFrequencies","current_syncword_offset_","findNextSyncwordOffset","syncword_offset","readNextAACFrame","aac_frame","ID","protection_absent","sampling_frequency_index","channel_configuration","aac_frame_length","has_last_incomplete_data","adts_header_length","adts_frame_payload_length","next_syncword_offset","frame_data","AACFrame","audio_object_type","sampling_frequency","channel_config","hasIncompleteData","getIncompleteData","frame","original_audio_object_type","sampling_index","extension_sampling_index","sampling_rate","original_codec_mimetype","probe_data","first_parse_","media_info_","timescale_","duration_","current_pmt_pid_","program_pmt_map_","pes_slice_queues_","video_metadata_","audio_metadata_","aac_last_sample_pts_","aac_last_incomplete_data_","has_video_","has_audio_","video_init_segment_dispatched_","audio_init_segment_dispatched_","video_metadata_changed_","audio_metadata_changed_","video_track_","audio_track_","ts_packet_size_","ts_packet_size","sync_offset_","sync_offset","config_","scan_window","byte_start","sync_byte","payload_unit_start_indicator","pid","adaptation_field_control","continuity_conunter","adaptation_field_info","ts_payload_start_index","adaptation_field_length","parseAdaptationField","ts_payload_length","parsePAT","parsePMT","pmt_","stream_type","handlePESSlice","random_access_indicator","dispatchAudioVideoMediaSegment","discontinuity_indicator","elementary_stream_priority_indicator","table_id","section_length","version_number","current_next_indicator","section_number","pat","PAT","pat_","program_bytes","first_program_number","first_pmt_pid","program_number","network_pid","JSON","stringify","current_program_","pmt","PMT","program_info_length","info_start_index","info_bytes","elementary_PID","ES_info_length","kH264","kADTSAAC","kPESPrivateData","descriptor","dispatchPESPrivateDataDescriptor","kID3","packet_start_code_prefix","PES_packet_length","emitPESSlices","cleanPESSlices","SliceQueue","slice_queue","pes_data","PESData","parsePES","stream_id","PTS_DTS_flags","PES_header_data_length","payload_start_index","payload_length","payload","kMPEG1Audio","kMPEG2Audio","parsePESPrivateDataPayload","parseAACPayload","parseTimedID3MetadataPayload","parseH264Payload","kH265","annexb_parser","nalu_avc1","H264NaluAVC1","kSliceSPS","detectVideoMetadataChange","kSlicePPS","dispatchVideoMediaSegment","dispatchVideoInitSegment","kSliceIDR","kSliceNonIDR","pts_ms","dts_ms","avc_sample","new_sps","new_sps_details","old_size","new_size","isInitSegmentDispatched","sps_without_header","pps_without_header","AVCDecoderConfigurationRecord","dispatchAudioMediaSegment","ref_sample_duration","base_pts_ms","new_pts_ms","abs","last_sample_pts_ms","adts_parser","sample_pts_ms","dispatchAudioInitSegment","detectAudioMetadataChange","sample_pts_ms_int","aac_sample","audio_specific_config","desc","PESPrivateDataDescriptor","private_data","PESPrivateData","nearest_pts","timed_id3_metadata","MP4","types","avc1","avcC","btrt","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","sdtp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trun","trex","tkhd","vmhd","smhd","charCodeAt","constants","FTYP","STSD_PREFIX","STTS","STSC","STCO","STSZ","HDLR_VIDEO","HDLR_AUDIO","DREF","SMHD","VMHD","box","datas","arrayCount","generateInitSegment","trackId","xmhd","mp3","sampleRate","configSize","baseMediaDecodeTime","sampleCount","isLeading","dependsOn","isDependedOn","hasRedundancy","isNonSync","getSilentFrame","_isLive","isLive","_dtsBase","_dtsBaseInited","_audioDtsBase","Infinity","_videoDtsBase","_audioNextDts","_videoNextDts","_audioStashedLastSample","_videoStashedLastSample","_audioMeta","_videoMeta","_audioSegmentInfoList","_videoSegmentInfoList","_onInitSegment","_onMediaSegment","_forceFirstIDR","_fillSilentAfterSeek","msedge","msie","_mp3UseMpegAudio","firefox","_fillAudioTimestampGap","fixAudioTimestampGap","producer","remux","_onTrackMetadataReceived","insertDiscontinuity","seek","audioTrack","videoTrack","_calculateDtsBase","_remuxVideo","_remuxAudio","metabox","container","mediaDuration","getTimestampBase","flushStashedSamples","videoSample","audioSample","force","lastDts","dtsCorrection","firstDts","mpegRawTrack","firstSegmentAfterSeek","insertPrefixSilentFrame","mdatbox","mdatBytes","sample","firstSampleOriginalDts","distance","firstSampleDts","videoSegment","silentUnit","silentFrameDuration","mp4Samples","needFillSilentFrames","silentFrames","sampleDuration","curRefDts","frameCount","round","intDts","intDuration","latest","moofbox","_mergeBoxes","timestampOffset","lastPts","firstPts","syncPoint","mediaDataSource","_emitter","filesize","url","cors","withCredentials","_mediaDataSource","_currentSegmentIndex","totalDuration","forEach","timestampBase","referrerPolicy","_demuxer","_remuxer","_ioctl","_pendingSeekTime","_pendingResolveSeekPoint","_statisticsReporter","_disableStatisticsReporter","event","_loadSegment","_enableStatisticsReporter","segmentIndex","optionalFrom","ioctl","_onIOException","onSeeked","_onIOSeeked","onComplete","_onIOComplete","onRedirect","_onIORedirect","onRecoveredEarlyEof","_onIORecoveredEarlyEof","_onInitChunkArrival","stop","_internalAbort","pause","resume","isPaused","targetSegmentIndex","_searchSegmentIndexContains","segmentInfo","targetSegmentInfo","_reportSegmentMediaInfo","demuxer","_onDemuxException","_onTimedID3Metadata","_onPESPrivateDataDescriptor","_onPESPrivateData","onInitSegment","_onRemuxerInitSegmentArrival","onMediaSegment","_onRemuxerMediaSegmentArrival","mds","overridedDuration","overridedHasAudio","overridedHasVideo","onScriptDataArrived","then","mediaInfo","setPrototypeOf","timestamp_base","extraData","nextSegmentIndex","redirectedURL","code","initSegment","mediaSegment","seekpoint","setInterval","_reportStatisticsInfo","statisticsInfoReportInterval","clearInterval","exportInfo","currentURL","hasRedirect","currentRedirectedURL","speed","currentSpeed","loaderType","currentSegmentIndex","totalSegmentCount","_firstCheckpoint","_lastCheckpoint","_intervalBytes","_totalBytes","_lastSecondBytes","performance","now","_now","reset","addBytes","bytes","durationSeconds","currentKBps","seekHandler","_seekHandler","_requestAbort","_abortController","_contentLength","_receivedLength","isSupported","isWorkWellEdge","browserNotBlacklisted","fetch","ReadableStream","_dataSource","_range","sourceURL","reuseRedirectedURL","seekConfig","headers","Headers","configHeaders","params","method","cache","credentials","AbortController","signal","res","body","cancel","ok","status","removeURLParameters","lengthHeader","_pump","getReader","statusText","catch","aborted","reader","read","done","from","_xhr","xhr","XMLHttpRequest","responseType","onreadystatechange","onprogress","onloadend","onerror","_requestURL","_onReadyStateChange","_onProgress","_onLoadEnd","_onXhrError","setRequestHeader","send","readyState","responseURL","total","response","loaded","constructor","_chunkSizeKBList","_currentChunkSizeKB","_currentSpeedNormalized","_zeroSpeedChunkCount","_speedSampler","_waitForTotalLength","_totalLengthReceived","_currentRequestURL","_currentRedirectedURL","_currentRequestRange","_totalLength","_lastTimeLoaded","onload","lastSecondKBps","useRefTotalLength","_openSubRange","_internalOpen","to","chunkSize","_onLoad","openNextRange","delta","_normalizeSpeed","KBps","normalized","reportComplete","_ws","WebSocket","ws","binaryType","onopen","_onWebSocketOpen","onclose","_onWebSocketClose","onmessage","_onWebSocketMessage","_onWebSocketError","close","_dispatchArrayBuffer","Blob","FileReader","readAsArrayBuffer","arraybuffer","zeroStart","_zeroStart","param","seekedURL","paramStart","paramEnd","_startName","_endName","baseUrl","needAnd","baseURL","queryIndex","substring","resultParams","pairs","pair","requireAnd","_extraData","_stashInitialSize","stashInitialSize","_stashUsed","_stashSize","_bufferSize","_stashBuffer","_stashByteStart","_enableStash","enableStashBuffer","_loader","_loaderClass","_isWebSocketURL","test","_refTotalLength","_fullRequestFlag","_currentRange","_redirectedURL","_speedNormalized","_speedNormalizeList","_isEarlyEofReconnecting","_paused","_resumeFrom","_onSeeked","_onRedirect","_onRecoveredEarlyEof","_selectSeekHandler","_selectLoader","_createLoader","seekType","rangeLoadZeroStart","seekParamStart","seekParamEnd","customSeekHandler","customLoader","needStashBuffer","onContentLengthKnown","onURLRedirect","_onLoaderChunkArrival","_onLoaderComplete","_onLoaderError","_internalSeek","dropUnconsumed","_flushStashBuffer","requestRange","updateUrl","_expandBuffer","expectedBytes","bufferNewSize","newBuffer","stashOldArray","_adjustStashSize","stashSizeKB","bufferSize","_dispatchChunks","chunks","contentLength","receivedLength","stashArray","remainArray","remain","nextFrom","install","obj","proto","__proto__","output","source","polyfill","Polyfill","webpackBootstrapFunc","configurable","oe","f","ENTRY_MODULE","default","quoteRegExp","replace","getModuleDependencies","sources","queueName","retval","fnString","wrapperSignature","webpackRequireName","re","RegExp","hasValuesInQueues","queues","reduce","hasValues","options","main","requiredModules","all","modulesQueue","seenModules","moduleToCheck","newModules","newModulesKeys","getRequiredModules","filter","entryModule","map","blob","bare","workerUrl","URL","webkitURL","mozURL","msURL","createObjectURL","worker","Worker","objectURL","isFunction","x","isArray","vertxNext","customSchedulerFn","asap","queue","flush","scheduleFlush","browserWindow","browserGlobal","BrowserMutationObserver","MutationObserver","WebKitMutationObserver","isNode","process","isWorker","Uint8ClampedArray","importScripts","MessageChannel","useSetTimeout","globalSetTimeout","setTimeout","channel","iterations","observer","node","onFulfillment","onRejection","parent","child","noop","PROMISE_ID","makePromise","_state","invokeCallback","_result","subscribe","resolve$1","promise","nextTick","document","createTextNode","observe","characterData","port1","port2","postMessage","vertx","require","runOnLoop","runOnContext","attemptVertx","random","handleMaybeThenable","maybeThenable","then$$1","thenable","fulfill","reason","handleOwnThenable","sealed","fulfillmentHandler","rejectionHandler","tryThen","_label","handleForeignThenable","publishRejection","_onerror","publish","_subscribers","subscribers","settled","detail","hasCallback","succeeded","Enumerator","Constructor","_instanceConstructor","_remaining","_enumerate","_eachEntry","entry","resolve$$1","_then","didError","_settledAt","Promise$1","_willSettleAt","enumerator","needsResolver","initializePromise","needsNew","finally","entries","race","_","_setScheduler","scheduleFn","_setAsap","asapFn","_asap","local","global","P","promiseToString","cast","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","runTimeout","fun","clearTimeout","currentQueue","draining","queueIndex","cleanUpNextTick","drainQueue","timeout","run","marker","runClearTimeout","Item","title","env","argv","versions","binding","cwd","chdir","dir","umask","g","controller","logcatListener","logcat","onLoadingComplete","onTimedID3MetadataArrived","onPESPrivateDataArrived","onStatisticsInfo","statInfo","onIOError","onDemuxError","onRecommendSeekpoint","cmd","defaultConfig","enableWorker","liveBufferLatencyChasing","liveBufferLatencyMaxLatency","liveBufferLatencyMinRemain","lazyLoad","lazyLoadMaxDuration","lazyLoadRecoverDuration","deferLoadAfterSourceOpen","autoCleanupMaxBackwardDuration","autoCleanupMinBackwardDuration","accurateSeek","createDefaultConfig","supportMSEH264Playback","MediaSource","isTypeSupported","supportNetworkStreamIO","getNetworkLoaderTypeName","supportNativeMediaPlayback","Features","videoElement","createElement","canPlay","canPlayType","getFeatureList","features","msePlayback","mseLivePlayback","networkStreamIO","networkLoaderName","nativeMP4H264Playback","nativeWebmVP8Playback","nativeWebmVP9Playback","ERROR","_worker","_workerDestroying","_onWorkerMessage","onLoggingConfigChanged","_onLoggingConfigChanged","_controller","ctl","_onIOError","_onDemuxError","_onLoadingComplete","_onTimedID3MetadataArrived","_onPESPrivateDataArrived","_onStatisticsInfo","_onRecommendSeekpoint","hasWorker","statisticsInfo","terminate","SOURCE_OPEN","UPDATE_END","BUFFER_FULL","autoCleanupSourceBuffer","onSourceOpen","_onSourceOpen","onSourceEnded","_onSourceEnded","onSourceClose","_onSourceClose","onSourceBufferError","_onSourceBufferError","onSourceBufferUpdateEnd","_onSourceBufferUpdateEnd","_mediaSource","_mediaSourceObjectURL","_mediaElement","_isBufferFull","_hasPendingEos","_requireSetMediaDuration","_pendingMediaDuration","_pendingSourceBufferInit","_mimeTypes","video","audio","_sourceBuffers","_lastInitSegments","_pendingSegments","_pendingRemoveRanges","_idrList","detachMediaElement","attachMediaElement","mediaElement","ms","ps","sb","removeSourceBuffer","endOfStream","removeAttribute","revokeObjectURL","appendInitSegment","deferred","is","firstInitSegment","addSourceBuffer","updating","_doAppendSegments","_updateMediaSourceDuration","appendMediaSegment","_needCleanupSourceBuffer","_doCleanupSourceBuffer","_hasPendingRemoveRanges","seconds","buffered","end","_doRemoveRanges","lastInitSegment","_hasPendingSegments","currentTime","doRemove","removeEnd","current","ranges","remove","pendingSegments","currentOffset","targetOffset","appendBuffer","pendings","prr","ErrorTypes","NETWORK_ERROR","MEDIA_ERROR","OTHER_ERROR","ErrorDetails","NETWORK_EXCEPTION","NETWORK_STATUS_CODE_INVALID","NETWORK_TIMEOUT","NETWORK_UNRECOVERABLE_EARLY_EOF","MEDIA_MSE_ERROR","MEDIA_FORMAT_ERROR","MEDIA_FORMAT_UNSUPPORTED","MEDIA_CODEC_UNSUPPORTED","typeLowerCase","onvLoadedMetadata","_onvLoadedMetadata","onvSeeking","_onvSeeking","onvCanPlay","_onvCanPlay","onvStalled","_onvStalled","onvProgress","_onvProgress","_requestSetTime","_seekpointRecord","_progressChecker","_msectl","_transmuxer","_mseSourceOpened","_hasPendingLoad","_receivedCanPlay","_statisticsInfo","chromeNeedIDRFix","_alwaysSeekKeyframe","unload","_onmseUpdateEnd","_onmseBufferFull","load","_suspendTransmuxer","_fillStatisticsInfo","play","volume","muted","playerType","HTMLVideoElement","hasQualityInfo","decoded","dropped","getVideoPlaybackQuality","quality","totalVideoFrames","droppedVideoFrames","webkitDecodedFrameCount","webkitDroppedFrameCount","decodedFrames","droppedFrames","paused","buffered_end","target_time","currentRangeEnd","_checkProgressAndResume","needResume","_isTimepointBuffered","directSeek","directSeekBegin","directSeekBeginTime","videoBeginTime","idr","_checkAndApplyUnbufferedSeekpoint","recordTime","_checkAndResumeStuckPlayback","stalled","media","seekPoint","preload","HTMLAudioElement","videoWidth","videoHeight","mpegts","optionalConfig","BaseLoader","Events","MSEPlayer","NativePlayer"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQnB,EAAoBmB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFAxB,EAAoBgB,EAAEO,GACtBX,OAA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,KAAKg4B,iBACtCh4B,KAAKg4B,iBAAmB,MAE5Bh4B,KAAKk3B,SAAS55B,KAAK,EAAaoB,WAAYsB,KAAK66B,YAGrD,YAAAW,sBAAA,WACIx7B,KAAKk3B,SAAS55B,KAAK,EAAa0B,gBAAiBgB,KAAKi4C,iBAG9D,EA1OA,GCOA,IAASxP,UAqCT,IAAI+Y,EAAS,CAEb,aAnCA,SAAsBvqB,EAAiBwqB,GACnC,IAAIlnB,EAAMtD,EACV,GAAW,MAAPsD,GAA8B,iBAARA,EACtB,MAAM,IAAI,IAAyB,iDAGvC,IAAKA,EAAI79B,eAAe,QACpB,MAAM,IAAI,IAAyB,oEAGvC,OAAQ69B,EAAIn0B,MACR,IAAK,MACL,IAAK,SACL,IAAK,OACL,IAAK,MACD,OAAO,IAAI,EAAUm0B,EAAKknB,GAC9B,QACI,OAAO,IAAI,EAAalnB,EAAKknB,KAmBzC,YAbA,WACI,OAAO,EAAS5L,0BAapB,eAVA,WACI,OAAO,EAASW,mBAWpBgL,EAAOE,WAAa,IACpBF,EAAOtiD,aAAe,IACtBsiD,EAAOhiD,aAAe,IAEtBgiD,EAAOG,OAAS,EAChBH,EAAO/E,WAAaA,EACpB+E,EAAO3E,aAAeA,EAEtB2E,EAAOI,UAAY,EACnBJ,EAAOK,aAAe,EACtBL,EAAO5yC,eAAiB,IAExBrT,OAAOC,eAAegmD,EAAQ,UAAW,CACrC/lD,YAAY,EACZC,IAAK,WAED,MAAO,YAIA","file":"mpegts.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"mpegts\"] = factory();\n\telse\n\t\troot[\"mpegts\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 14);\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\n\nclass Log {\n\n static e(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'error', str);\n }\n\n if (!Log.ENABLE_ERROR) {\n return;\n }\n\n if (console.error) {\n console.error(str);\n } else if (console.warn) {\n console.warn(str);\n } else {\n console.log(str);\n }\n }\n\n static i(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'info', str);\n }\n\n if (!Log.ENABLE_INFO) {\n return;\n }\n\n if (console.info) {\n console.info(str);\n } else {\n console.log(str);\n }\n }\n\n static w(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'warn', str);\n }\n\n if (!Log.ENABLE_WARN) {\n return;\n }\n\n if (console.warn) {\n console.warn(str);\n } else {\n console.log(str);\n }\n }\n\n static d(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'debug', str);\n }\n\n if (!Log.ENABLE_DEBUG) {\n return;\n }\n\n if (console.debug) {\n console.debug(str);\n } else {\n console.log(str);\n }\n }\n\n static v(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'verbose', str);\n }\n\n if (!Log.ENABLE_VERBOSE) {\n return;\n }\n\n console.log(str);\n }\n\n}\n\nLog.GLOBAL_TAG = 'mpegts.js';\nLog.FORCE_GLOBAL_TAG = false;\nLog.ENABLE_ERROR = true;\nLog.ENABLE_INFO = true;\nLog.ENABLE_WARN = true;\nLog.ENABLE_DEBUG = true;\nLog.ENABLE_VERBOSE = true;\n\nLog.ENABLE_CALLBACK = false;\n\nLog.emitter = new EventEmitter();\n\nexport default Log;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst TransmuxingEvents = {\n IO_ERROR: 'io_error',\n DEMUX_ERROR: 'demux_error',\n INIT_SEGMENT: 'init_segment',\n MEDIA_SEGMENT: 'media_segment',\n LOADING_COMPLETE: 'loading_complete',\n RECOVERED_EARLY_EOF: 'recovered_early_eof',\n MEDIA_INFO: 'media_info',\n METADATA_ARRIVED: 'metadata_arrived',\n SCRIPTDATA_ARRIVED: 'scriptdata_arrived',\n TIMED_ID3_METADATA_ARRIVED: 'timed_id3_metadata_arrived',\n PES_PRIVATE_DATA_DESCRIPTOR: 'pes_private_data_descriptor',\n PES_PRIVATE_DATA_ARRIVED: 'pes_private_data_arrived',\n STATISTICS_INFO: 'statistics_info',\n RECOMMEND_SEEKPOINT: 'recommend_seekpoint'\n};\n\nexport default TransmuxingEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NotImplementedException} from '../utils/exception.js';\n\nexport const LoaderStatus = {\n kIdle: 0,\n kConnecting: 1,\n kBuffering: 2,\n kError: 3,\n kComplete: 4\n};\n\nexport const LoaderErrors = {\n OK: 'OK',\n EXCEPTION: 'Exception',\n HTTP_STATUS_CODE_INVALID: 'HttpStatusCodeInvalid',\n CONNECTING_TIMEOUT: 'ConnectingTimeout',\n EARLY_EOF: 'EarlyEof',\n UNRECOVERABLE_EARLY_EOF: 'UnrecoverableEarlyEof'\n};\n\n/* Loader has callbacks which have following prototypes:\n * function onContentLengthKnown(contentLength: number): void\n * function onURLRedirect(url: string): void\n * function onDataArrival(chunk: ArrayBuffer, byteStart: number, receivedLength: number): void\n * function onError(errorType: number, errorInfo: {code: number, msg: string}): void\n * function onComplete(rangeFrom: number, rangeTo: number): void\n */\nexport class BaseLoader {\n\n constructor(typeName) {\n this._type = typeName || 'undefined';\n this._status = LoaderStatus.kIdle;\n this._needStash = false;\n // callbacks\n this._onContentLengthKnown = null;\n this._onURLRedirect = null;\n this._onDataArrival = null;\n this._onError = null;\n this._onComplete = null;\n }\n\n destroy() {\n this._status = LoaderStatus.kIdle;\n this._onContentLengthKnown = null;\n this._onURLRedirect = null;\n this._onDataArrival = null;\n this._onError = null;\n this._onComplete = null;\n }\n\n isWorking() {\n return this._status === LoaderStatus.kConnecting || this._status === LoaderStatus.kBuffering;\n }\n\n get type() {\n return this._type;\n }\n\n get status() {\n return this._status;\n }\n\n get needStashBuffer() {\n return this._needStash;\n }\n\n get onContentLengthKnown() {\n return this._onContentLengthKnown;\n }\n\n set onContentLengthKnown(callback) {\n this._onContentLengthKnown = callback;\n }\n\n get onURLRedirect() {\n return this._onURLRedirect;\n }\n\n set onURLRedirect(callback) {\n this._onURLRedirect = callback;\n }\n\n get onDataArrival() {\n return this._onDataArrival;\n }\n\n set onDataArrival(callback) {\n this._onDataArrival = callback;\n }\n\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n get onComplete() {\n return this._onComplete;\n }\n\n set onComplete(callback) {\n this._onComplete = callback;\n }\n\n // pure virtual\n open(dataSource, range) {\n throw new NotImplementedException('Unimplemented abstract function!');\n }\n\n abort() {\n throw new NotImplementedException('Unimplemented abstract function!');\n }\n\n\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class RuntimeException {\n\n constructor(message) {\n this._message = message;\n }\n\n get name() {\n return 'RuntimeException';\n }\n\n get message() {\n return this._message;\n }\n\n toString() {\n return this.name + ': ' + this.message;\n }\n\n}\n\nexport class IllegalStateException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'IllegalStateException';\n }\n\n}\n\nexport class InvalidArgumentException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'InvalidArgumentException';\n }\n\n}\n\nexport class NotImplementedException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'NotImplementedException';\n }\n\n}\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet Browser = {};\n\nfunction detect() {\n // modified from jquery-browser-plugin\n\n let ua = self.navigator.userAgent.toLowerCase();\n\n let match = /(edge)\\/([\\w.]+)/.exec(ua) ||\n /(opr)[\\/]([\\w.]+)/.exec(ua) ||\n /(chrome)[ \\/]([\\w.]+)/.exec(ua) ||\n /(iemobile)[\\/]([\\w.]+)/.exec(ua) ||\n /(version)(applewebkit)[ \\/]([\\w.]+).*(safari)[ \\/]([\\w.]+)/.exec(ua) ||\n /(webkit)[ \\/]([\\w.]+).*(version)[ \\/]([\\w.]+).*(safari)[ \\/]([\\w.]+)/.exec(ua) ||\n /(webkit)[ \\/]([\\w.]+)/.exec(ua) ||\n /(opera)(?:.*version|)[ \\/]([\\w.]+)/.exec(ua) ||\n /(msie) ([\\w.]+)/.exec(ua) ||\n ua.indexOf('trident') >= 0 && /(rv)(?::| )([\\w.]+)/.exec(ua) ||\n ua.indexOf('compatible') < 0 && /(firefox)[ \\/]([\\w.]+)/.exec(ua) ||\n [];\n\n let platform_match = /(ipad)/.exec(ua) ||\n /(ipod)/.exec(ua) ||\n /(windows phone)/.exec(ua) ||\n /(iphone)/.exec(ua) ||\n /(kindle)/.exec(ua) ||\n /(android)/.exec(ua) ||\n /(windows)/.exec(ua) ||\n /(mac)/.exec(ua) ||\n /(linux)/.exec(ua) ||\n /(cros)/.exec(ua) ||\n [];\n\n let matched = {\n browser: match[5] || match[3] || match[1] || '',\n version: match[2] || match[4] || '0',\n majorVersion: match[4] || match[2] || '0',\n platform: platform_match[0] || ''\n };\n\n let browser = {};\n if (matched.browser) {\n browser[matched.browser] = true;\n\n let versionArray = matched.majorVersion.split('.');\n browser.version = {\n major: parseInt(matched.majorVersion, 10),\n string: matched.version\n };\n if (versionArray.length > 1) {\n browser.version.minor = parseInt(versionArray[1], 10);\n }\n if (versionArray.length > 2) {\n browser.version.build = parseInt(versionArray[2], 10);\n }\n }\n\n if (matched.platform) {\n browser[matched.platform] = true;\n }\n\n if (browser.chrome || browser.opr || browser.safari) {\n browser.webkit = true;\n }\n\n // MSIE. IE11 has 'rv' identifer\n if (browser.rv || browser.iemobile) {\n if (browser.rv) {\n delete browser.rv;\n }\n let msie = 'msie';\n matched.browser = msie;\n browser[msie] = true;\n }\n\n // Microsoft Edge\n if (browser.edge) {\n delete browser.edge;\n let msedge = 'msedge';\n matched.browser = msedge;\n browser[msedge] = true;\n }\n\n // Opera 15+\n if (browser.opr) {\n let opera = 'opera';\n matched.browser = opera;\n browser[opera] = true;\n }\n\n // Stock android browsers are marked as Safari\n if (browser.safari && browser.android) {\n let android = 'android';\n matched.browser = android;\n browser[android] = true;\n }\n\n browser.name = matched.browser;\n browser.platform = matched.platform;\n\n for (let key in Browser) {\n if (Browser.hasOwnProperty(key)) {\n delete Browser[key];\n }\n }\n Object.assign(Browser, browser);\n}\n\ndetect();\n\nexport default Browser;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst DemuxErrors = {\n OK: 'OK',\n FORMAT_ERROR: 'FormatError',\n FORMAT_UNSUPPORTED: 'FormatUnsupported',\n CODEC_UNSUPPORTED: 'CodecUnsupported'\n};\n\nexport default DemuxErrors;","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Represents an media sample (audio / video)\nexport class SampleInfo {\n\n constructor(dts, pts, duration, originalDts, isSync) {\n this.dts = dts;\n this.pts = pts;\n this.duration = duration;\n this.originalDts = originalDts;\n this.isSyncPoint = isSync;\n this.fileposition = null;\n }\n\n}\n\n// Media Segment concept is defined in Media Source Extensions spec.\n// Particularly in ISO BMFF format, an Media Segment contains a moof box followed by a mdat box.\nexport class MediaSegmentInfo {\n\n constructor() {\n this.beginDts = 0;\n this.endDts = 0;\n this.beginPts = 0;\n this.endPts = 0;\n this.originalBeginDts = 0;\n this.originalEndDts = 0;\n this.syncPoints = []; // SampleInfo[n], for video IDR frames only\n this.firstSample = null; // SampleInfo\n this.lastSample = null; // SampleInfo\n }\n\n appendSyncPoint(sampleInfo) { // also called Random Access Point\n sampleInfo.isSyncPoint = true;\n this.syncPoints.push(sampleInfo);\n }\n\n}\n\n// Ordered list for recording video IDR frames, sorted by originalDts\nexport class IDRSampleList {\n\n constructor() {\n this._list = [];\n }\n\n clear() {\n this._list = [];\n }\n\n appendArray(syncPoints) {\n let list = this._list;\n\n if (syncPoints.length === 0) {\n return;\n }\n\n if (list.length > 0 && syncPoints[0].originalDts < list[list.length - 1].originalDts) {\n this.clear();\n }\n\n Array.prototype.push.apply(list, syncPoints);\n }\n\n getLastSyncPointBeforeDts(dts) {\n if (this._list.length == 0) {\n return null;\n }\n\n let list = this._list;\n let idx = 0;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (dts < list[0].dts) {\n idx = 0;\n lbound = ubound + 1;\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (dts >= list[mid].dts && dts < list[mid + 1].dts)) {\n idx = mid;\n break;\n } else if (list[mid].dts < dts) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n return this._list[idx];\n }\n\n}\n\n// Data structure for recording information of media segments in single track.\nexport class MediaSegmentInfoList {\n\n constructor(type) {\n this._type = type;\n this._list = [];\n this._lastAppendLocation = -1; // cached last insert location\n }\n\n get type() {\n return this._type;\n }\n\n get length() {\n return this._list.length;\n }\n\n isEmpty() {\n return this._list.length === 0;\n }\n\n clear() {\n this._list = [];\n this._lastAppendLocation = -1;\n }\n\n _searchNearestSegmentBefore(originalBeginDts) {\n let list = this._list;\n if (list.length === 0) {\n return -2;\n }\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n let idx = 0;\n\n if (originalBeginDts < list[0].originalBeginDts) {\n idx = -1;\n return idx;\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (originalBeginDts > list[mid].lastSample.originalDts &&\n (originalBeginDts < list[mid + 1].originalBeginDts))) {\n idx = mid;\n break;\n } else if (list[mid].originalBeginDts < originalBeginDts) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n return idx;\n }\n\n _searchNearestSegmentAfter(originalBeginDts) {\n return this._searchNearestSegmentBefore(originalBeginDts) + 1;\n }\n\n append(mediaSegmentInfo) {\n let list = this._list;\n let msi = mediaSegmentInfo;\n let lastAppendIdx = this._lastAppendLocation;\n let insertIdx = 0;\n\n if (lastAppendIdx !== -1 && lastAppendIdx < list.length &&\n msi.originalBeginDts >= list[lastAppendIdx].lastSample.originalDts &&\n ((lastAppendIdx === list.length - 1) ||\n (lastAppendIdx < list.length - 1 &&\n msi.originalBeginDts < list[lastAppendIdx + 1].originalBeginDts))) {\n insertIdx = lastAppendIdx + 1; // use cached location idx\n } else {\n if (list.length > 0) {\n insertIdx = this._searchNearestSegmentBefore(msi.originalBeginDts) + 1;\n }\n }\n\n this._lastAppendLocation = insertIdx;\n this._list.splice(insertIdx, 0, msi);\n }\n\n getLastSegmentBefore(originalBeginDts) {\n let idx = this._searchNearestSegmentBefore(originalBeginDts);\n if (idx >= 0) {\n return this._list[idx];\n } else { // -1\n return null;\n }\n }\n\n getLastSampleBefore(originalBeginDts) {\n let segment = this.getLastSegmentBefore(originalBeginDts);\n if (segment != null) {\n return segment.lastSample;\n } else {\n return null;\n }\n }\n\n getLastSyncPointBefore(originalBeginDts) {\n let segmentIdx = this._searchNearestSegmentBefore(originalBeginDts);\n let syncPoints = this._list[segmentIdx].syncPoints;\n while (syncPoints.length === 0 && segmentIdx > 0) {\n segmentIdx--;\n syncPoints = this._list[segmentIdx].syncPoints;\n }\n if (syncPoints.length > 0) {\n return syncPoints[syncPoints.length - 1];\n } else {\n return null;\n }\n }\n\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass MediaInfo {\n\n constructor() {\n this.mimeType = null;\n this.duration = null;\n\n this.hasAudio = null;\n this.hasVideo = null;\n this.audioCodec = null;\n this.videoCodec = null;\n this.audioDataRate = null;\n this.videoDataRate = null;\n\n this.audioSampleRate = null;\n this.audioChannelCount = null;\n\n this.width = null;\n this.height = null;\n this.fps = null;\n this.profile = null;\n this.level = null;\n this.refFrames = null;\n this.chromaFormat = null;\n this.sarNum = null;\n this.sarDen = null;\n\n this.metadata = null;\n this.segments = null; // MediaInfo[]\n this.segmentCount = null;\n this.hasKeyframesIndex = null;\n this.keyframesIndex = null;\n }\n\n isComplete() {\n let audioInfoComplete = (this.hasAudio === false) ||\n (this.hasAudio === true &&\n this.audioCodec != null &&\n this.audioSampleRate != null &&\n this.audioChannelCount != null);\n\n let videoInfoComplete = (this.hasVideo === false) ||\n (this.hasVideo === true &&\n this.videoCodec != null &&\n this.width != null &&\n this.height != null &&\n this.fps != null &&\n this.profile != null &&\n this.level != null &&\n this.refFrames != null &&\n this.chromaFormat != null &&\n this.sarNum != null &&\n this.sarDen != null);\n\n // keyframesIndex may not be present\n return this.mimeType != null &&\n audioInfoComplete &&\n videoInfoComplete;\n }\n\n isSeekable() {\n return this.hasKeyframesIndex === true;\n }\n\n getNearestKeyframe(milliseconds) {\n if (this.keyframesIndex == null) {\n return null;\n }\n\n let table = this.keyframesIndex;\n let keyframeIdx = this._search(table.times, milliseconds);\n\n return {\n index: keyframeIdx,\n milliseconds: table.times[keyframeIdx],\n fileposition: table.filepositions[keyframeIdx]\n };\n }\n\n _search(list, value) {\n let idx = 0;\n\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (value < list[0]) {\n idx = 0;\n lbound = ubound + 1; // skip search\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (value >= list[mid] && value < list[mid + 1])) {\n idx = mid;\n break;\n } else if (list[mid] < value) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n\n return idx;\n }\n\n}\n\nexport default MediaInfo;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from './logger.js';\n\nclass LoggingControl {\n\n static get forceGlobalTag() {\n return Log.FORCE_GLOBAL_TAG;\n }\n\n static set forceGlobalTag(enable) {\n Log.FORCE_GLOBAL_TAG = enable;\n LoggingControl._notifyChange();\n }\n\n static get globalTag() {\n return Log.GLOBAL_TAG;\n }\n\n static set globalTag(tag) {\n Log.GLOBAL_TAG = tag;\n LoggingControl._notifyChange();\n }\n\n static get enableAll() {\n return Log.ENABLE_VERBOSE\n && Log.ENABLE_DEBUG\n && Log.ENABLE_INFO\n && Log.ENABLE_WARN\n && Log.ENABLE_ERROR;\n }\n\n static set enableAll(enable) {\n Log.ENABLE_VERBOSE = enable;\n Log.ENABLE_DEBUG = enable;\n Log.ENABLE_INFO = enable;\n Log.ENABLE_WARN = enable;\n Log.ENABLE_ERROR = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableDebug() {\n return Log.ENABLE_DEBUG;\n }\n\n static set enableDebug(enable) {\n Log.ENABLE_DEBUG = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableVerbose() {\n return Log.ENABLE_VERBOSE;\n }\n\n static set enableVerbose(enable) {\n Log.ENABLE_VERBOSE = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableInfo() {\n return Log.ENABLE_INFO;\n }\n\n static set enableInfo(enable) {\n Log.ENABLE_INFO = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableWarn() {\n return Log.ENABLE_WARN;\n }\n\n static set enableWarn(enable) {\n Log.ENABLE_WARN = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableError() {\n return Log.ENABLE_ERROR;\n }\n\n static set enableError(enable) {\n Log.ENABLE_ERROR = enable;\n LoggingControl._notifyChange();\n }\n\n static getConfig() {\n return {\n globalTag: Log.GLOBAL_TAG,\n forceGlobalTag: Log.FORCE_GLOBAL_TAG,\n enableVerbose: Log.ENABLE_VERBOSE,\n enableDebug: Log.ENABLE_DEBUG,\n enableInfo: Log.ENABLE_INFO,\n enableWarn: Log.ENABLE_WARN,\n enableError: Log.ENABLE_ERROR,\n enableCallback: Log.ENABLE_CALLBACK\n };\n }\n\n static applyConfig(config) {\n Log.GLOBAL_TAG = config.globalTag;\n Log.FORCE_GLOBAL_TAG = config.forceGlobalTag;\n Log.ENABLE_VERBOSE = config.enableVerbose;\n Log.ENABLE_DEBUG = config.enableDebug;\n Log.ENABLE_INFO = config.enableInfo;\n Log.ENABLE_WARN = config.enableWarn;\n Log.ENABLE_ERROR = config.enableError;\n Log.ENABLE_CALLBACK = config.enableCallback;\n }\n\n static _notifyChange() {\n let emitter = LoggingControl.emitter;\n\n if (emitter.listenerCount('change') > 0) {\n let config = LoggingControl.getConfig();\n emitter.emit('change', config);\n }\n }\n\n static registerListener(listener) {\n LoggingControl.emitter.addListener('change', listener);\n }\n\n static removeListener(listener) {\n LoggingControl.emitter.removeListener('change', listener);\n }\n\n static addLogListener(listener) {\n Log.emitter.addListener('log', listener);\n if (Log.emitter.listenerCount('log') > 0) {\n Log.ENABLE_CALLBACK = true;\n LoggingControl._notifyChange();\n }\n }\n\n static removeLogListener(listener) {\n Log.emitter.removeListener('log', listener);\n if (Log.emitter.listenerCount('log') === 0) {\n Log.ENABLE_CALLBACK = false;\n LoggingControl._notifyChange();\n }\n }\n\n}\n\nLoggingControl.emitter = new EventEmitter();\n\nexport default LoggingControl;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is derived from C++ project libWinTF8 (https://github.com/m13253/libWinTF8)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nfunction checkContinuation(uint8array, start, checkLength) {\n let array = uint8array;\n if (start + checkLength < array.length) {\n while (checkLength--) {\n if ((array[++start] & 0xC0) !== 0x80)\n return false;\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction decodeUTF8(uint8array) {\n let out = [];\n let input = uint8array;\n let i = 0;\n let length = uint8array.length;\n\n while (i < length) {\n if (input[i] < 0x80) {\n out.push(String.fromCharCode(input[i]));\n ++i;\n continue;\n } else if (input[i] < 0xC0) {\n // fallthrough\n } else if (input[i] < 0xE0) {\n if (checkContinuation(input, i, 1)) {\n let ucs4 = (input[i] & 0x1F) << 6 | (input[i + 1] & 0x3F);\n if (ucs4 >= 0x80) {\n out.push(String.fromCharCode(ucs4 & 0xFFFF));\n i += 2;\n continue;\n }\n }\n } else if (input[i] < 0xF0) {\n if (checkContinuation(input, i, 2)) {\n let ucs4 = (input[i] & 0xF) << 12 | (input[i + 1] & 0x3F) << 6 | input[i + 2] & 0x3F;\n if (ucs4 >= 0x800 && (ucs4 & 0xF800) !== 0xD800) {\n out.push(String.fromCharCode(ucs4 & 0xFFFF));\n i += 3;\n continue;\n }\n }\n } else if (input[i] < 0xF8) {\n if (checkContinuation(input, i, 3)) {\n let ucs4 = (input[i] & 0x7) << 18 | (input[i + 1] & 0x3F) << 12\n | (input[i + 2] & 0x3F) << 6 | (input[i + 3] & 0x3F);\n if (ucs4 > 0x10000 && ucs4 < 0x110000) {\n ucs4 -= 0x10000;\n out.push(String.fromCharCode((ucs4 >>> 10) | 0xD800));\n out.push(String.fromCharCode((ucs4 & 0x3FF) | 0xDC00));\n i += 4;\n continue;\n }\n }\n }\n out.push(String.fromCharCode(0xFFFD));\n ++i;\n }\n\n return out.join('');\n}\n\nexport default decodeUTF8;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport decodeUTF8 from '../utils/utf8-conv.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\nlet le = (function () {\n let buf = new ArrayBuffer(2);\n (new DataView(buf)).setInt16(0, 256, true); // little-endian write\n return (new Int16Array(buf))[0] === 256; // platform-spec read, if equal then LE\n})();\n\nclass AMF {\n\n static parseScriptData(arrayBuffer, dataOffset, dataSize) {\n let data = {};\n\n try {\n let name = AMF.parseValue(arrayBuffer, dataOffset, dataSize);\n let value = AMF.parseValue(arrayBuffer, dataOffset + name.size, dataSize - name.size);\n\n data[name.data] = value.data;\n } catch (e) {\n Log.e('AMF', e.toString());\n }\n\n return data;\n }\n\n static parseObject(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 3) {\n throw new IllegalStateException('Data not enough when parse ScriptDataObject');\n }\n let name = AMF.parseString(arrayBuffer, dataOffset, dataSize);\n let value = AMF.parseValue(arrayBuffer, dataOffset + name.size, dataSize - name.size);\n let isObjectEnd = value.objectEnd;\n\n return {\n data: {\n name: name.data,\n value: value.data\n },\n size: name.size + value.size,\n objectEnd: isObjectEnd\n };\n }\n\n static parseVariable(arrayBuffer, dataOffset, dataSize) {\n return AMF.parseObject(arrayBuffer, dataOffset, dataSize);\n }\n\n static parseString(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 2) {\n throw new IllegalStateException('Data not enough when parse String');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let length = v.getUint16(0, !le);\n\n let str;\n if (length > 0) {\n str = decodeUTF8(new Uint8Array(arrayBuffer, dataOffset + 2, length));\n } else {\n str = '';\n }\n\n return {\n data: str,\n size: 2 + length\n };\n }\n\n static parseLongString(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 4) {\n throw new IllegalStateException('Data not enough when parse LongString');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let length = v.getUint32(0, !le);\n\n let str;\n if (length > 0) {\n str = decodeUTF8(new Uint8Array(arrayBuffer, dataOffset + 4, length));\n } else {\n str = '';\n }\n\n return {\n data: str,\n size: 4 + length\n };\n }\n\n static parseDate(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 10) {\n throw new IllegalStateException('Data size invalid when parse Date');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let timestamp = v.getFloat64(0, !le);\n let localTimeOffset = v.getInt16(8, !le);\n timestamp += localTimeOffset * 60 * 1000; // get UTC time\n\n return {\n data: new Date(timestamp),\n size: 8 + 2\n };\n }\n\n static parseValue(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 1) {\n throw new IllegalStateException('Data not enough when parse Value');\n }\n\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let offset = 1;\n let type = v.getUint8(0);\n let value;\n let objectEnd = false;\n\n try {\n switch (type) {\n case 0: // Number(Double) type\n value = v.getFloat64(1, !le);\n offset += 8;\n break;\n case 1: { // Boolean type\n let b = v.getUint8(1);\n value = b ? true : false;\n offset += 1;\n break;\n }\n case 2: { // String type\n let amfstr = AMF.parseString(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = amfstr.data;\n offset += amfstr.size;\n break;\n }\n case 3: { // Object(s) type\n value = {};\n let terminal = 0; // workaround for malformed Objects which has missing ScriptDataObjectEnd\n if ((v.getUint32(dataSize - 4, !le) & 0x00FFFFFF) === 9) {\n terminal = 3;\n }\n while (offset < dataSize - 4) { // 4 === type(UI8) + ScriptDataObjectEnd(UI24)\n let amfobj = AMF.parseObject(arrayBuffer, dataOffset + offset, dataSize - offset - terminal);\n if (amfobj.objectEnd)\n break;\n value[amfobj.data.name] = amfobj.data.value;\n offset += amfobj.size;\n }\n if (offset <= dataSize - 3) {\n let marker = v.getUint32(offset - 1, !le) & 0x00FFFFFF;\n if (marker === 9) {\n offset += 3;\n }\n }\n break;\n }\n case 8: { // ECMA array type (Mixed array)\n value = {};\n offset += 4; // ECMAArrayLength(UI32)\n let terminal = 0; // workaround for malformed MixedArrays which has missing ScriptDataObjectEnd\n if ((v.getUint32(dataSize - 4, !le) & 0x00FFFFFF) === 9) {\n terminal = 3;\n }\n while (offset < dataSize - 8) { // 8 === type(UI8) + ECMAArrayLength(UI32) + ScriptDataVariableEnd(UI24)\n let amfvar = AMF.parseVariable(arrayBuffer, dataOffset + offset, dataSize - offset - terminal);\n if (amfvar.objectEnd)\n break;\n value[amfvar.data.name] = amfvar.data.value;\n offset += amfvar.size;\n }\n if (offset <= dataSize - 3) {\n let marker = v.getUint32(offset - 1, !le) & 0x00FFFFFF;\n if (marker === 9) {\n offset += 3;\n }\n }\n break;\n }\n case 9: // ScriptDataObjectEnd\n value = undefined;\n offset = 1;\n objectEnd = true;\n break;\n case 10: { // Strict array type\n // ScriptDataValue[n]. NOTE: according to video_file_format_spec_v10_1.pdf\n value = [];\n let strictArrayLength = v.getUint32(1, !le);\n offset += 4;\n for (let i = 0; i < strictArrayLength; i++) {\n let val = AMF.parseValue(arrayBuffer, dataOffset + offset, dataSize - offset);\n value.push(val.data);\n offset += val.size;\n }\n break;\n }\n case 11: { // Date type\n let date = AMF.parseDate(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = date.data;\n offset += date.size;\n break;\n }\n case 12: { // Long string type\n let amfLongStr = AMF.parseString(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = amfLongStr.data;\n offset += amfLongStr.size;\n break;\n }\n default:\n // ignore and skip\n offset = dataSize;\n Log.w('AMF', 'Unsupported AMF value type ' + type);\n }\n } catch (e) {\n Log.e('AMF', e.toString());\n }\n\n return {\n data: value,\n size: offset,\n objectEnd: objectEnd\n };\n }\n\n}\n\nexport default AMF;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {IllegalStateException, InvalidArgumentException} from '../utils/exception.js';\n\n// Exponential-Golomb buffer decoder\nclass ExpGolomb {\n\n constructor(uint8array) {\n this.TAG = 'ExpGolomb';\n\n this._buffer = uint8array;\n this._buffer_index = 0;\n this._total_bytes = uint8array.byteLength;\n this._total_bits = uint8array.byteLength * 8;\n this._current_word = 0;\n this._current_word_bits_left = 0;\n }\n\n destroy() {\n this._buffer = null;\n }\n\n _fillCurrentWord() {\n let buffer_bytes_left = this._total_bytes - this._buffer_index;\n if (buffer_bytes_left <= 0)\n throw new IllegalStateException('ExpGolomb: _fillCurrentWord() but no bytes available');\n\n let bytes_read = Math.min(4, buffer_bytes_left);\n let word = new Uint8Array(4);\n word.set(this._buffer.subarray(this._buffer_index, this._buffer_index + bytes_read));\n this._current_word = new DataView(word.buffer).getUint32(0, false);\n\n this._buffer_index += bytes_read;\n this._current_word_bits_left = bytes_read * 8;\n }\n\n readBits(bits) {\n if (bits > 32)\n throw new InvalidArgumentException('ExpGolomb: readBits() bits exceeded max 32bits!');\n\n if (bits <= this._current_word_bits_left) {\n let result = this._current_word >>> (32 - bits);\n this._current_word <<= bits;\n this._current_word_bits_left -= bits;\n return result;\n }\n\n let result = this._current_word_bits_left ? this._current_word : 0;\n result = result >>> (32 - this._current_word_bits_left);\n let bits_need_left = bits - this._current_word_bits_left;\n\n this._fillCurrentWord();\n let bits_read_next = Math.min(bits_need_left, this._current_word_bits_left);\n\n let result2 = this._current_word >>> (32 - bits_read_next);\n this._current_word <<= bits_read_next;\n this._current_word_bits_left -= bits_read_next;\n\n result = (result << bits_read_next) | result2;\n return result;\n }\n\n readBool() {\n return this.readBits(1) === 1;\n }\n\n readByte() {\n return this.readBits(8);\n }\n\n _skipLeadingZero() {\n let zero_count;\n for (zero_count = 0; zero_count < this._current_word_bits_left; zero_count++) {\n if (0 !== (this._current_word & (0x80000000 >>> zero_count))) {\n this._current_word <<= zero_count;\n this._current_word_bits_left -= zero_count;\n return zero_count;\n }\n }\n this._fillCurrentWord();\n return zero_count + this._skipLeadingZero();\n }\n\n readUEG() { // unsigned exponential golomb\n let leading_zeros = this._skipLeadingZero();\n return this.readBits(leading_zeros + 1) - 1;\n }\n\n readSEG() { // signed exponential golomb\n let value = this.readUEG();\n if (value & 0x01) {\n return (value + 1) >>> 1;\n } else {\n return -1 * (value >>> 1);\n }\n }\n\n}\n\nexport default ExpGolomb;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ExpGolomb from './exp-golomb.js';\n\nclass SPSParser {\n\n static _ebsp2rbsp(uint8array) {\n let src = uint8array;\n let src_length = src.byteLength;\n let dst = new Uint8Array(src_length);\n let dst_idx = 0;\n\n for (let i = 0; i < src_length; i++) {\n if (i >= 2) {\n // Unescape: Skip 0x03 after 00 00\n if (src[i] === 0x03 && src[i - 1] === 0x00 && src[i - 2] === 0x00) {\n continue;\n }\n }\n dst[dst_idx] = src[i];\n dst_idx++;\n }\n\n return new Uint8Array(dst.buffer, 0, dst_idx);\n }\n\n static parseSPS(uint8array) {\n let codec_array = uint8array.subarray(1, 4);\n let codec_mimetype = 'avc1.';\n for (let j = 0; j < 3; j++) {\n let h = codec_array[j].toString(16);\n if (h.length < 2) {\n h = '0' + h;\n }\n codec_mimetype += h;\n }\n\n let rbsp = SPSParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n gb.readByte();\n let profile_idc = gb.readByte(); // profile_idc\n gb.readByte(); // constraint_set_flags[5] + reserved_zero[3]\n let level_idc = gb.readByte(); // level_idc\n gb.readUEG(); // seq_parameter_set_id\n\n let profile_string = SPSParser.getProfileString(profile_idc);\n let level_string = SPSParser.getLevelString(level_idc);\n let chroma_format_idc = 1;\n let chroma_format = 420;\n let chroma_format_table = [0, 420, 422, 444];\n let bit_depth_luma = 8;\n let bit_depth_chroma = 8;\n\n if (profile_idc === 100 || profile_idc === 110 || profile_idc === 122 ||\n profile_idc === 244 || profile_idc === 44 || profile_idc === 83 ||\n profile_idc === 86 || profile_idc === 118 || profile_idc === 128 ||\n profile_idc === 138 || profile_idc === 144) {\n\n chroma_format_idc = gb.readUEG();\n if (chroma_format_idc === 3) {\n gb.readBits(1); // separate_colour_plane_flag\n }\n if (chroma_format_idc <= 3) {\n chroma_format = chroma_format_table[chroma_format_idc];\n }\n\n bit_depth_luma = gb.readUEG() + 8; // bit_depth_luma_minus8\n bit_depth_chroma = gb.readUEG() + 8; // bit_depth_chroma_minus8\n gb.readBits(1); // qpprime_y_zero_transform_bypass_flag\n if (gb.readBool()) { // seq_scaling_matrix_present_flag\n let scaling_list_count = (chroma_format_idc !== 3) ? 8 : 12;\n for (let i = 0; i < scaling_list_count; i++) {\n if (gb.readBool()) { // seq_scaling_list_present_flag\n if (i < 6) {\n SPSParser._skipScalingList(gb, 16);\n } else {\n SPSParser._skipScalingList(gb, 64);\n }\n }\n }\n }\n }\n gb.readUEG(); // log2_max_frame_num_minus4\n let pic_order_cnt_type = gb.readUEG();\n if (pic_order_cnt_type === 0) {\n gb.readUEG(); // log2_max_pic_order_cnt_lsb_minus_4\n } else if (pic_order_cnt_type === 1) {\n gb.readBits(1); // delta_pic_order_always_zero_flag\n gb.readSEG(); // offset_for_non_ref_pic\n gb.readSEG(); // offset_for_top_to_bottom_field\n let num_ref_frames_in_pic_order_cnt_cycle = gb.readUEG();\n for (let i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {\n gb.readSEG(); // offset_for_ref_frame\n }\n }\n let ref_frames = gb.readUEG(); // max_num_ref_frames\n gb.readBits(1); // gaps_in_frame_num_value_allowed_flag\n\n let pic_width_in_mbs_minus1 = gb.readUEG();\n let pic_height_in_map_units_minus1 = gb.readUEG();\n\n let frame_mbs_only_flag = gb.readBits(1);\n if (frame_mbs_only_flag === 0) {\n gb.readBits(1); // mb_adaptive_frame_field_flag\n }\n gb.readBits(1); // direct_8x8_inference_flag\n\n let frame_crop_left_offset = 0;\n let frame_crop_right_offset = 0;\n let frame_crop_top_offset = 0;\n let frame_crop_bottom_offset = 0;\n\n let frame_cropping_flag = gb.readBool();\n if (frame_cropping_flag) {\n frame_crop_left_offset = gb.readUEG();\n frame_crop_right_offset = gb.readUEG();\n frame_crop_top_offset = gb.readUEG();\n frame_crop_bottom_offset = gb.readUEG();\n }\n\n let sar_width = 1, sar_height = 1;\n let fps = 0, fps_fixed = true, fps_num = 0, fps_den = 0;\n\n let vui_parameters_present_flag = gb.readBool();\n if (vui_parameters_present_flag) {\n if (gb.readBool()) { // aspect_ratio_info_present_flag\n let aspect_ratio_idc = gb.readByte();\n let sar_w_table = [1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2];\n let sar_h_table = [1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1];\n\n if (aspect_ratio_idc > 0 && aspect_ratio_idc < 16) {\n sar_width = sar_w_table[aspect_ratio_idc - 1];\n sar_height = sar_h_table[aspect_ratio_idc - 1];\n } else if (aspect_ratio_idc === 255) {\n sar_width = gb.readByte() << 8 | gb.readByte();\n sar_height = gb.readByte() << 8 | gb.readByte();\n }\n }\n\n if (gb.readBool()) { // overscan_info_present_flag\n gb.readBool(); // overscan_appropriate_flag\n }\n if (gb.readBool()) { // video_signal_type_present_flag\n gb.readBits(4); // video_format & video_full_range_flag\n if (gb.readBool()) { // colour_description_present_flag\n gb.readBits(24); // colour_primaries & transfer_characteristics & matrix_coefficients\n }\n }\n if (gb.readBool()) { // chroma_loc_info_present_flag\n gb.readUEG(); // chroma_sample_loc_type_top_field\n gb.readUEG(); // chroma_sample_loc_type_bottom_field\n }\n if (gb.readBool()) { // timing_info_present_flag\n let num_units_in_tick = gb.readBits(32);\n let time_scale = gb.readBits(32);\n fps_fixed = gb.readBool(); // fixed_frame_rate_flag\n\n fps_num = time_scale;\n fps_den = num_units_in_tick * 2;\n fps = fps_num / fps_den;\n }\n }\n\n let sarScale = 1;\n if (sar_width !== 1 || sar_height !== 1) {\n sarScale = sar_width / sar_height;\n }\n\n let crop_unit_x = 0, crop_unit_y = 0;\n if (chroma_format_idc === 0) {\n crop_unit_x = 1;\n crop_unit_y = 2 - frame_mbs_only_flag;\n } else {\n let sub_wc = (chroma_format_idc === 3) ? 1 : 2;\n let sub_hc = (chroma_format_idc === 1) ? 2 : 1;\n crop_unit_x = sub_wc;\n crop_unit_y = sub_hc * (2 - frame_mbs_only_flag);\n }\n\n let codec_width = (pic_width_in_mbs_minus1 + 1) * 16;\n let codec_height = (2 - frame_mbs_only_flag) * ((pic_height_in_map_units_minus1 + 1) * 16);\n\n codec_width -= (frame_crop_left_offset + frame_crop_right_offset) * crop_unit_x;\n codec_height -= (frame_crop_top_offset + frame_crop_bottom_offset) * crop_unit_y;\n\n let present_width = Math.ceil(codec_width * sarScale);\n\n gb.destroy();\n gb = null;\n\n return {\n codec_mimetype,\n profile_idc,\n level_idc,\n profile_string, // baseline, high, high10, ...\n level_string, // 3, 3.1, 4, 4.1, 5, 5.1, ...\n chroma_format_idc,\n bit_depth: bit_depth_luma, // 8bit, 10bit, ...\n bit_depth_luma,\n bit_depth_chroma,\n ref_frames,\n chroma_format, // 4:2:0, 4:2:2, ...\n chroma_format_string: SPSParser.getChromaFormatString(chroma_format),\n\n frame_rate: {\n fixed: fps_fixed,\n fps: fps,\n fps_den: fps_den,\n fps_num: fps_num\n },\n\n sar_ratio: {\n width: sar_width,\n height: sar_height\n },\n\n codec_size: {\n width: codec_width,\n height: codec_height\n },\n\n present_size: {\n width: present_width,\n height: codec_height\n }\n };\n }\n\n static _skipScalingList(gb, count) {\n let last_scale = 8, next_scale = 8;\n let delta_scale = 0;\n for (let i = 0; i < count; i++) {\n if (next_scale !== 0) {\n delta_scale = gb.readSEG();\n next_scale = (last_scale + delta_scale + 256) % 256;\n }\n last_scale = (next_scale === 0) ? last_scale : next_scale;\n }\n }\n\n static getProfileString(profile_idc) {\n switch (profile_idc) {\n case 66:\n return 'Baseline';\n case 77:\n return 'Main';\n case 88:\n return 'Extended';\n case 100:\n return 'High';\n case 110:\n return 'High10';\n case 122:\n return 'High422';\n case 244:\n return 'High444';\n default:\n return 'Unknown';\n }\n }\n\n static getLevelString(level_idc) {\n return (level_idc / 10).toFixed(1);\n }\n\n static getChromaFormatString(chroma) {\n switch (chroma) {\n case 420:\n return '4:2:0';\n case 422:\n return '4:2:2';\n case 444:\n return '4:4:4';\n default:\n return 'Unknown';\n }\n }\n\n}\n\nexport default SPSParser;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport AMF from './amf-parser.js';\nimport SPSParser from './sps-parser.js';\nimport DemuxErrors from './demux-errors.js';\nimport MediaInfo from '../core/media-info.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\nfunction Swap16(src) {\n return (((src >>> 8) & 0xFF) |\n ((src & 0xFF) << 8));\n}\n\nfunction Swap32(src) {\n return (((src & 0xFF000000) >>> 24) |\n ((src & 0x00FF0000) >>> 8) |\n ((src & 0x0000FF00) << 8) |\n ((src & 0x000000FF) << 24));\n}\n\nfunction ReadBig32(array, index) {\n return ((array[index] << 24) |\n (array[index + 1] << 16) |\n (array[index + 2] << 8) |\n (array[index + 3]));\n}\n\n\nclass FLVDemuxer {\n\n constructor(probeData, config) {\n this.TAG = 'FLVDemuxer';\n\n this._config = config;\n\n this._onError = null;\n this._onMediaInfo = null;\n this._onMetaDataArrived = null;\n this._onScriptDataArrived = null;\n this._onTrackMetadata = null;\n this._onDataAvailable = null;\n\n this._dataOffset = probeData.dataOffset;\n this._firstParse = true;\n this._dispatch = false;\n\n this._hasAudio = probeData.hasAudioTrack;\n this._hasVideo = probeData.hasVideoTrack;\n\n this._hasAudioFlagOverrided = false;\n this._hasVideoFlagOverrided = false;\n\n this._audioInitialMetadataDispatched = false;\n this._videoInitialMetadataDispatched = false;\n\n this._mediaInfo = new MediaInfo();\n this._mediaInfo.hasAudio = this._hasAudio;\n this._mediaInfo.hasVideo = this._hasVideo;\n this._metadata = null;\n this._audioMetadata = null;\n this._videoMetadata = null;\n\n this._naluLengthSize = 4;\n this._timestampBase = 0; // int32, in milliseconds\n this._timescale = 1000;\n this._duration = 0; // int32, in milliseconds\n this._durationOverrided = false;\n this._referenceFrameRate = {\n fixed: true,\n fps: 23.976,\n fps_num: 23976,\n fps_den: 1000\n };\n\n this._flvSoundRateTable = [5500, 11025, 22050, 44100, 48000];\n\n this._mpegSamplingRates = [\n 96000, 88200, 64000, 48000, 44100, 32000,\n 24000, 22050, 16000, 12000, 11025, 8000, 7350\n ];\n\n this._mpegAudioV10SampleRateTable = [44100, 48000, 32000, 0];\n this._mpegAudioV20SampleRateTable = [22050, 24000, 16000, 0];\n this._mpegAudioV25SampleRateTable = [11025, 12000, 8000, 0];\n\n this._mpegAudioL1BitRateTable = [0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1];\n this._mpegAudioL2BitRateTable = [0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1];\n this._mpegAudioL3BitRateTable = [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1];\n\n this._videoTrack = {type: 'video', id: 1, sequenceNumber: 0, samples: [], length: 0};\n this._audioTrack = {type: 'audio', id: 2, sequenceNumber: 0, samples: [], length: 0};\n\n this._littleEndian = (function () {\n let buf = new ArrayBuffer(2);\n (new DataView(buf)).setInt16(0, 256, true); // little-endian write\n return (new Int16Array(buf))[0] === 256; // platform-spec read, if equal then LE\n })();\n }\n\n destroy() {\n this._mediaInfo = null;\n this._metadata = null;\n this._audioMetadata = null;\n this._videoMetadata = null;\n this._videoTrack = null;\n this._audioTrack = null;\n\n this._onError = null;\n this._onMediaInfo = null;\n this._onMetaDataArrived = null;\n this._onScriptDataArrived = null;\n this._onTrackMetadata = null;\n this._onDataAvailable = null;\n }\n\n static probe(buffer) {\n let data = new Uint8Array(buffer);\n let mismatch = {match: false};\n\n if (data[0] !== 0x46 || data[1] !== 0x4C || data[2] !== 0x56 || data[3] !== 0x01) {\n return mismatch;\n }\n\n let hasAudio = ((data[4] & 4) >>> 2) !== 0;\n let hasVideo = (data[4] & 1) !== 0;\n\n let offset = ReadBig32(data, 5);\n\n if (offset < 9) {\n return mismatch;\n }\n\n return {\n match: true,\n consumed: offset,\n dataOffset: offset,\n hasAudioTrack: hasAudio,\n hasVideoTrack: hasVideo\n };\n }\n\n bindDataSource(loader) {\n loader.onDataArrival = this.parseChunks.bind(this);\n return this;\n }\n\n // prototype: function(type: string, metadata: any): void\n get onTrackMetadata() {\n return this._onTrackMetadata;\n }\n\n set onTrackMetadata(callback) {\n this._onTrackMetadata = callback;\n }\n\n // prototype: function(mediaInfo: MediaInfo): void\n get onMediaInfo() {\n return this._onMediaInfo;\n }\n\n set onMediaInfo(callback) {\n this._onMediaInfo = callback;\n }\n\n get onMetaDataArrived() {\n return this._onMetaDataArrived;\n }\n\n set onMetaDataArrived(callback) {\n this._onMetaDataArrived = callback;\n }\n\n get onScriptDataArrived() {\n return this._onScriptDataArrived;\n }\n\n set onScriptDataArrived(callback) {\n this._onScriptDataArrived = callback;\n }\n\n // prototype: function(type: number, info: string): void\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n // prototype: function(videoTrack: any, audioTrack: any): void\n get onDataAvailable() {\n return this._onDataAvailable;\n }\n\n set onDataAvailable(callback) {\n this._onDataAvailable = callback;\n }\n\n // timestamp base for output samples, must be in milliseconds\n get timestampBase() {\n return this._timestampBase;\n }\n\n set timestampBase(base) {\n this._timestampBase = base;\n }\n\n get overridedDuration() {\n return this._duration;\n }\n\n // Force-override media duration. Must be in milliseconds, int32\n set overridedDuration(duration) {\n this._durationOverrided = true;\n this._duration = duration;\n this._mediaInfo.duration = duration;\n }\n\n // Force-override audio track present flag, boolean\n set overridedHasAudio(hasAudio) {\n this._hasAudioFlagOverrided = true;\n this._hasAudio = hasAudio;\n this._mediaInfo.hasAudio = hasAudio;\n }\n\n // Force-override video track present flag, boolean\n set overridedHasVideo(hasVideo) {\n this._hasVideoFlagOverrided = true;\n this._hasVideo = hasVideo;\n this._mediaInfo.hasVideo = hasVideo;\n }\n\n resetMediaInfo() {\n this._mediaInfo = new MediaInfo();\n }\n\n _isInitialMetadataDispatched() {\n if (this._hasAudio && this._hasVideo) { // both audio & video\n return this._audioInitialMetadataDispatched && this._videoInitialMetadataDispatched;\n }\n if (this._hasAudio && !this._hasVideo) { // audio only\n return this._audioInitialMetadataDispatched;\n }\n if (!this._hasAudio && this._hasVideo) { // video only\n return this._videoInitialMetadataDispatched;\n }\n return false;\n }\n\n // function parseChunks(chunk: ArrayBuffer, byteStart: number): number;\n parseChunks(chunk, byteStart) {\n if (!this._onError || !this._onMediaInfo || !this._onTrackMetadata || !this._onDataAvailable) {\n throw new IllegalStateException('Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified');\n }\n\n let offset = 0;\n let le = this._littleEndian;\n\n if (byteStart === 0) { // buffer with FLV header\n if (chunk.byteLength > 13) {\n let probeData = FLVDemuxer.probe(chunk);\n offset = probeData.dataOffset;\n } else {\n return 0;\n }\n }\n\n if (this._firstParse) { // handle PreviousTagSize0 before Tag1\n this._firstParse = false;\n if (byteStart + offset !== this._dataOffset) {\n Log.w(this.TAG, 'First time parsing but chunk byteStart invalid!');\n }\n\n let v = new DataView(chunk, offset);\n let prevTagSize0 = v.getUint32(0, !le);\n if (prevTagSize0 !== 0) {\n Log.w(this.TAG, 'PrevTagSize0 !== 0 !!!');\n }\n offset += 4;\n }\n\n while (offset < chunk.byteLength) {\n this._dispatch = true;\n\n let v = new DataView(chunk, offset);\n\n if (offset + 11 + 4 > chunk.byteLength) {\n // data not enough for parsing an flv tag\n break;\n }\n\n let tagType = v.getUint8(0);\n let dataSize = v.getUint32(0, !le) & 0x00FFFFFF;\n\n if (offset + 11 + dataSize + 4 > chunk.byteLength) {\n // data not enough for parsing actual data body\n break;\n }\n\n if (tagType !== 8 && tagType !== 9 && tagType !== 18) {\n Log.w(this.TAG, `Unsupported tag type ${tagType}, skipped`);\n // consume the whole tag (skip it)\n offset += 11 + dataSize + 4;\n continue;\n }\n\n let ts2 = v.getUint8(4);\n let ts1 = v.getUint8(5);\n let ts0 = v.getUint8(6);\n let ts3 = v.getUint8(7);\n\n let timestamp = ts0 | (ts1 << 8) | (ts2 << 16) | (ts3 << 24);\n\n let streamId = v.getUint32(7, !le) & 0x00FFFFFF;\n if (streamId !== 0) {\n Log.w(this.TAG, 'Meet tag which has StreamID != 0!');\n }\n\n let dataOffset = offset + 11;\n\n switch (tagType) {\n case 8: // Audio\n this._parseAudioData(chunk, dataOffset, dataSize, timestamp);\n break;\n case 9: // Video\n this._parseVideoData(chunk, dataOffset, dataSize, timestamp, byteStart + offset);\n break;\n case 18: // ScriptDataObject\n this._parseScriptData(chunk, dataOffset, dataSize);\n break;\n }\n\n let prevTagSize = v.getUint32(11 + dataSize, !le);\n if (prevTagSize !== 11 + dataSize) {\n Log.w(this.TAG, `Invalid PrevTagSize ${prevTagSize}`);\n }\n\n offset += 11 + dataSize + 4; // tagBody + dataSize + prevTagSize\n }\n\n // dispatch parsed frames to consumer (typically, the remuxer)\n if (this._isInitialMetadataDispatched()) {\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n }\n\n return offset; // consumed bytes, just equals latest offset index\n }\n\n _parseScriptData(arrayBuffer, dataOffset, dataSize) {\n let scriptData = AMF.parseScriptData(arrayBuffer, dataOffset, dataSize);\n\n if (scriptData.hasOwnProperty('onMetaData')) {\n if (scriptData.onMetaData == null || typeof scriptData.onMetaData !== 'object') {\n Log.w(this.TAG, 'Invalid onMetaData structure!');\n return;\n }\n if (this._metadata) {\n Log.w(this.TAG, 'Found another onMetaData tag!');\n }\n this._metadata = scriptData;\n let onMetaData = this._metadata.onMetaData;\n\n if (this._onMetaDataArrived) {\n this._onMetaDataArrived(Object.assign({}, onMetaData));\n }\n\n if (typeof onMetaData.hasAudio === 'boolean') { // hasAudio\n if (this._hasAudioFlagOverrided === false) {\n this._hasAudio = onMetaData.hasAudio;\n this._mediaInfo.hasAudio = this._hasAudio;\n }\n }\n if (typeof onMetaData.hasVideo === 'boolean') { // hasVideo\n if (this._hasVideoFlagOverrided === false) {\n this._hasVideo = onMetaData.hasVideo;\n this._mediaInfo.hasVideo = this._hasVideo;\n }\n }\n if (typeof onMetaData.audiodatarate === 'number') { // audiodatarate\n this._mediaInfo.audioDataRate = onMetaData.audiodatarate;\n }\n if (typeof onMetaData.videodatarate === 'number') { // videodatarate\n this._mediaInfo.videoDataRate = onMetaData.videodatarate;\n }\n if (typeof onMetaData.width === 'number') { // width\n this._mediaInfo.width = onMetaData.width;\n }\n if (typeof onMetaData.height === 'number') { // height\n this._mediaInfo.height = onMetaData.height;\n }\n if (typeof onMetaData.duration === 'number') { // duration\n if (!this._durationOverrided) {\n let duration = Math.floor(onMetaData.duration * this._timescale);\n this._duration = duration;\n this._mediaInfo.duration = duration;\n }\n } else {\n this._mediaInfo.duration = 0;\n }\n if (typeof onMetaData.framerate === 'number') { // framerate\n let fps_num = Math.floor(onMetaData.framerate * 1000);\n if (fps_num > 0) {\n let fps = fps_num / 1000;\n this._referenceFrameRate.fixed = true;\n this._referenceFrameRate.fps = fps;\n this._referenceFrameRate.fps_num = fps_num;\n this._referenceFrameRate.fps_den = 1000;\n this._mediaInfo.fps = fps;\n }\n }\n if (typeof onMetaData.keyframes === 'object') { // keyframes\n this._mediaInfo.hasKeyframesIndex = true;\n let keyframes = onMetaData.keyframes;\n this._mediaInfo.keyframesIndex = this._parseKeyframesIndex(keyframes);\n onMetaData.keyframes = null; // keyframes has been extracted, remove it\n } else {\n this._mediaInfo.hasKeyframesIndex = false;\n }\n this._dispatch = false;\n this._mediaInfo.metadata = onMetaData;\n Log.v(this.TAG, 'Parsed onMetaData');\n if (this._mediaInfo.isComplete()) {\n this._onMediaInfo(this._mediaInfo);\n }\n }\n\n if (Object.keys(scriptData).length > 0) {\n if (this._onScriptDataArrived) {\n this._onScriptDataArrived(Object.assign({}, scriptData));\n }\n }\n }\n\n _parseKeyframesIndex(keyframes) {\n let times = [];\n let filepositions = [];\n\n // ignore first keyframe which is actually AVC Sequence Header (AVCDecoderConfigurationRecord)\n for (let i = 1; i < keyframes.times.length; i++) {\n let time = this._timestampBase + Math.floor(keyframes.times[i] * 1000);\n times.push(time);\n filepositions.push(keyframes.filepositions[i]);\n }\n\n return {\n times: times,\n filepositions: filepositions\n };\n }\n\n _parseAudioData(arrayBuffer, dataOffset, dataSize, tagTimestamp) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid audio packet, missing SoundData payload!');\n return;\n }\n\n if (this._hasAudioFlagOverrided === true && this._hasAudio === false) {\n // If hasAudio: false indicated explicitly in MediaDataSource,\n // Ignore all the audio packets\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let soundSpec = v.getUint8(0);\n\n let soundFormat = soundSpec >>> 4;\n if (soundFormat !== 2 && soundFormat !== 10) { // MP3 or AAC\n this._onError(DemuxErrors.CODEC_UNSUPPORTED, 'Flv: Unsupported audio codec idx: ' + soundFormat);\n return;\n }\n\n let soundRate = 0;\n let soundRateIndex = (soundSpec & 12) >>> 2;\n if (soundRateIndex >= 0 && soundRateIndex <= 4) {\n soundRate = this._flvSoundRateTable[soundRateIndex];\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid audio sample rate idx: ' + soundRateIndex);\n return;\n }\n\n let soundSize = (soundSpec & 2) >>> 1; // unused\n let soundType = (soundSpec & 1);\n\n\n let meta = this._audioMetadata;\n let track = this._audioTrack;\n\n if (!meta) {\n if (this._hasAudio === false && this._hasAudioFlagOverrided === false) {\n this._hasAudio = true;\n this._mediaInfo.hasAudio = true;\n }\n\n // initial metadata\n meta = this._audioMetadata = {};\n meta.type = 'audio';\n meta.id = track.id;\n meta.timescale = this._timescale;\n meta.duration = this._duration;\n meta.audioSampleRate = soundRate;\n meta.channelCount = (soundType === 0 ? 1 : 2);\n }\n\n if (soundFormat === 10) { // AAC\n let aacData = this._parseAACAudioData(arrayBuffer, dataOffset + 1, dataSize - 1);\n if (aacData == undefined) {\n return;\n }\n\n if (aacData.packetType === 0) { // AAC sequence header (AudioSpecificConfig)\n if (meta.config) {\n Log.w(this.TAG, 'Found another AudioSpecificConfig!');\n }\n let misc = aacData.data;\n meta.audioSampleRate = misc.samplingRate;\n meta.channelCount = misc.channelCount;\n meta.codec = misc.codec;\n meta.originalCodec = misc.originalCodec;\n meta.config = misc.config;\n // The decode result of an aac sample is 1024 PCM samples\n meta.refSampleDuration = 1024 / meta.audioSampleRate * meta.timescale;\n Log.v(this.TAG, 'Parsed AudioSpecificConfig');\n\n if (this._isInitialMetadataDispatched()) {\n // Non-initial metadata, force dispatch (or flush) parsed frames to remuxer\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n } else {\n this._audioInitialMetadataDispatched = true;\n }\n // then notify new metadata\n this._dispatch = false;\n this._onTrackMetadata('audio', meta);\n\n let mi = this._mediaInfo;\n mi.audioCodec = meta.originalCodec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n if (mi.hasVideo) {\n if (mi.videoCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.audioCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n } else if (aacData.packetType === 1) { // AAC raw frame data\n let dts = this._timestampBase + tagTimestamp;\n let aacSample = {unit: aacData.data, length: aacData.data.byteLength, dts: dts, pts: dts};\n track.samples.push(aacSample);\n track.length += aacData.data.length;\n } else {\n Log.e(this.TAG, `Flv: Unsupported AAC data type ${aacData.packetType}`);\n }\n } else if (soundFormat === 2) { // MP3\n if (!meta.codec) {\n // We need metadata for mp3 audio track, extract info from frame header\n let misc = this._parseMP3AudioData(arrayBuffer, dataOffset + 1, dataSize - 1, true);\n if (misc == undefined) {\n return;\n }\n meta.audioSampleRate = misc.samplingRate;\n meta.channelCount = misc.channelCount;\n meta.codec = misc.codec;\n meta.originalCodec = misc.originalCodec;\n // The decode result of an mp3 sample is 1152 PCM samples\n meta.refSampleDuration = 1152 / meta.audioSampleRate * meta.timescale;\n Log.v(this.TAG, 'Parsed MPEG Audio Frame Header');\n\n this._audioInitialMetadataDispatched = true;\n this._onTrackMetadata('audio', meta);\n\n let mi = this._mediaInfo;\n mi.audioCodec = meta.codec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n mi.audioDataRate = misc.bitRate;\n if (mi.hasVideo) {\n if (mi.videoCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.audioCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n }\n\n // This packet is always a valid audio packet, extract it\n let data = this._parseMP3AudioData(arrayBuffer, dataOffset + 1, dataSize - 1, false);\n if (data == undefined) {\n return;\n }\n let dts = this._timestampBase + tagTimestamp;\n let mp3Sample = {unit: data, length: data.byteLength, dts: dts, pts: dts};\n track.samples.push(mp3Sample);\n track.length += data.length;\n }\n }\n\n _parseAACAudioData(arrayBuffer, dataOffset, dataSize) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid AAC packet, missing AACPacketType or/and Data!');\n return;\n }\n\n let result = {};\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n\n result.packetType = array[0];\n\n if (array[0] === 0) {\n result.data = this._parseAACAudioSpecificConfig(arrayBuffer, dataOffset + 1, dataSize - 1);\n } else {\n result.data = array.subarray(1);\n }\n\n return result;\n }\n\n _parseAACAudioSpecificConfig(arrayBuffer, dataOffset, dataSize) {\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n let config = null;\n\n /* Audio Object Type:\n 0: Null\n 1: AAC Main\n 2: AAC LC\n 3: AAC SSR (Scalable Sample Rate)\n 4: AAC LTP (Long Term Prediction)\n 5: HE-AAC / SBR (Spectral Band Replication)\n 6: AAC Scalable\n */\n\n let audioObjectType = 0;\n let originalAudioObjectType = 0;\n let audioExtensionObjectType = null;\n let samplingIndex = 0;\n let extensionSamplingIndex = null;\n\n // 5 bits\n audioObjectType = originalAudioObjectType = array[0] >>> 3;\n // 4 bits\n samplingIndex = ((array[0] & 0x07) << 1) | (array[1] >>> 7);\n if (samplingIndex < 0 || samplingIndex >= this._mpegSamplingRates.length) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: AAC invalid sampling frequency index!');\n return;\n }\n\n let samplingFrequence = this._mpegSamplingRates[samplingIndex];\n\n // 4 bits\n let channelConfig = (array[1] & 0x78) >>> 3;\n if (channelConfig < 0 || channelConfig >= 8) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: AAC invalid channel configuration');\n return;\n }\n\n if (audioObjectType === 5) { // HE-AAC?\n // 4 bits\n extensionSamplingIndex = ((array[1] & 0x07) << 1) | (array[2] >>> 7);\n // 5 bits\n audioExtensionObjectType = (array[2] & 0x7C) >>> 2;\n }\n\n // workarounds for various browsers\n let userAgent = self.navigator.userAgent.toLowerCase();\n\n if (userAgent.indexOf('firefox') !== -1) {\n // firefox: use SBR (HE-AAC) if freq less than 24kHz\n if (samplingIndex >= 6) {\n audioObjectType = 5;\n config = new Array(4);\n extensionSamplingIndex = samplingIndex - 3;\n } else { // use LC-AAC\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n }\n } else if (userAgent.indexOf('android') !== -1) {\n // android: always use LC-AAC\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n } else {\n // for other browsers, e.g. chrome...\n // Always use HE-AAC to make it easier to switch aac codec profile\n audioObjectType = 5;\n extensionSamplingIndex = samplingIndex;\n config = new Array(4);\n\n if (samplingIndex >= 6) {\n extensionSamplingIndex = samplingIndex - 3;\n } else if (channelConfig === 1) { // Mono channel\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n }\n }\n\n config[0] = audioObjectType << 3;\n config[0] |= (samplingIndex & 0x0F) >>> 1;\n config[1] = (samplingIndex & 0x0F) << 7;\n config[1] |= (channelConfig & 0x0F) << 3;\n if (audioObjectType === 5) {\n config[1] |= ((extensionSamplingIndex & 0x0F) >>> 1);\n config[2] = (extensionSamplingIndex & 0x01) << 7;\n // extended audio object type: force to 2 (LC-AAC)\n config[2] |= (2 << 2);\n config[3] = 0;\n }\n\n return {\n config: config,\n samplingRate: samplingFrequence,\n channelCount: channelConfig,\n codec: 'mp4a.40.' + audioObjectType,\n originalCodec: 'mp4a.40.' + originalAudioObjectType\n };\n }\n\n _parseMP3AudioData(arrayBuffer, dataOffset, dataSize, requestHeader) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid MP3 packet, header missing!');\n return;\n }\n\n let le = this._littleEndian;\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n let result = null;\n\n if (requestHeader) {\n if (array[0] !== 0xFF) {\n return;\n }\n let ver = (array[1] >>> 3) & 0x03;\n let layer = (array[1] & 0x06) >> 1;\n\n let bitrate_index = (array[2] & 0xF0) >>> 4;\n let sampling_freq_index = (array[2] & 0x0C) >>> 2;\n\n let channel_mode = (array[3] >>> 6) & 0x03;\n let channel_count = channel_mode !== 3 ? 2 : 1;\n\n let sample_rate = 0;\n let bit_rate = 0;\n let object_type = 34; // Layer-3, listed in MPEG-4 Audio Object Types\n\n let codec = 'mp3';\n\n switch (ver) {\n case 0: // MPEG 2.5\n sample_rate = this._mpegAudioV25SampleRateTable[sampling_freq_index];\n break;\n case 2: // MPEG 2\n sample_rate = this._mpegAudioV20SampleRateTable[sampling_freq_index];\n break;\n case 3: // MPEG 1\n sample_rate = this._mpegAudioV10SampleRateTable[sampling_freq_index];\n break;\n }\n\n switch (layer) {\n case 1: // Layer 3\n object_type = 34;\n if (bitrate_index < this._mpegAudioL3BitRateTable.length) {\n bit_rate = this._mpegAudioL3BitRateTable[bitrate_index];\n }\n break;\n case 2: // Layer 2\n object_type = 33;\n if (bitrate_index < this._mpegAudioL2BitRateTable.length) {\n bit_rate = this._mpegAudioL2BitRateTable[bitrate_index];\n }\n break;\n case 3: // Layer 1\n object_type = 32;\n if (bitrate_index < this._mpegAudioL1BitRateTable.length) {\n bit_rate = this._mpegAudioL1BitRateTable[bitrate_index];\n }\n break;\n }\n\n result = {\n bitRate: bit_rate,\n samplingRate: sample_rate,\n channelCount: channel_count,\n codec: codec,\n originalCodec: codec\n };\n } else {\n result = array;\n }\n\n return result;\n }\n\n _parseVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid video packet, missing VideoData payload!');\n return;\n }\n\n if (this._hasVideoFlagOverrided === true && this._hasVideo === false) {\n // If hasVideo: false indicated explicitly in MediaDataSource,\n // Ignore all the video packets\n return;\n }\n\n let spec = (new Uint8Array(arrayBuffer, dataOffset, dataSize))[0];\n\n let frameType = (spec & 240) >>> 4;\n let codecId = spec & 15;\n\n if (codecId !== 7) {\n this._onError(DemuxErrors.CODEC_UNSUPPORTED, `Flv: Unsupported codec in video frame: ${codecId}`);\n return;\n }\n\n this._parseAVCVideoPacket(arrayBuffer, dataOffset + 1, dataSize - 1, tagTimestamp, tagPosition, frameType);\n }\n\n _parseAVCVideoPacket(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime');\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let packetType = v.getUint8(0);\n let cts_unsigned = v.getUint32(0, !le) & 0x00FFFFFF;\n let cts = (cts_unsigned << 8) >> 8; // convert to 24-bit signed int\n\n if (packetType === 0) { // AVCDecoderConfigurationRecord\n this._parseAVCDecoderConfigurationRecord(arrayBuffer, dataOffset + 4, dataSize - 4);\n } else if (packetType === 1) { // One or more Nalus\n this._parseAVCVideoData(arrayBuffer, dataOffset + 4, dataSize - 4, tagTimestamp, tagPosition, frameType, cts);\n } else if (packetType === 2) {\n // empty, AVC end of sequence\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Invalid video packet type ${packetType}`);\n return;\n }\n }\n\n _parseAVCDecoderConfigurationRecord(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 7) {\n Log.w(this.TAG, 'Flv: Invalid AVCDecoderConfigurationRecord, lack of data!');\n return;\n }\n\n let meta = this._videoMetadata;\n let track = this._videoTrack;\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n if (!meta) {\n if (this._hasVideo === false && this._hasVideoFlagOverrided === false) {\n this._hasVideo = true;\n this._mediaInfo.hasVideo = true;\n }\n\n meta = this._videoMetadata = {};\n meta.type = 'video';\n meta.id = track.id;\n meta.timescale = this._timescale;\n meta.duration = this._duration;\n } else {\n if (typeof meta.avcc !== 'undefined') {\n Log.w(this.TAG, 'Found another AVCDecoderConfigurationRecord!');\n }\n }\n\n let version = v.getUint8(0); // configurationVersion\n let avcProfile = v.getUint8(1); // avcProfileIndication\n let profileCompatibility = v.getUint8(2); // profile_compatibility\n let avcLevel = v.getUint8(3); // AVCLevelIndication\n\n if (version !== 1 || avcProfile === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord');\n return;\n }\n\n this._naluLengthSize = (v.getUint8(4) & 3) + 1; // lengthSizeMinusOne\n if (this._naluLengthSize !== 3 && this._naluLengthSize !== 4) { // holy shit!!!\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Strange NaluLengthSizeMinusOne: ${this._naluLengthSize - 1}`);\n return;\n }\n\n let spsCount = v.getUint8(5) & 31; // numOfSequenceParameterSets\n if (spsCount === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord: No SPS');\n return;\n } else if (spsCount > 1) {\n Log.w(this.TAG, `Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ${spsCount}`);\n }\n\n let offset = 6;\n\n for (let i = 0; i < spsCount; i++) {\n let len = v.getUint16(offset, !le); // sequenceParameterSetLength\n offset += 2;\n\n if (len === 0) {\n continue;\n }\n\n // Notice: Nalu without startcode header (00 00 00 01)\n let sps = new Uint8Array(arrayBuffer, dataOffset + offset, len);\n offset += len;\n\n let config = SPSParser.parseSPS(sps);\n if (i !== 0) {\n // ignore other sps's config\n continue;\n }\n\n meta.codecWidth = config.codec_size.width;\n meta.codecHeight = config.codec_size.height;\n meta.presentWidth = config.present_size.width;\n meta.presentHeight = config.present_size.height;\n\n meta.profile = config.profile_string;\n meta.level = config.level_string;\n meta.bitDepth = config.bit_depth;\n meta.chromaFormat = config.chroma_format;\n meta.sarRatio = config.sar_ratio;\n meta.frameRate = config.frame_rate;\n\n if (config.frame_rate.fixed === false ||\n config.frame_rate.fps_num === 0 ||\n config.frame_rate.fps_den === 0) {\n meta.frameRate = this._referenceFrameRate;\n }\n\n let fps_den = meta.frameRate.fps_den;\n let fps_num = meta.frameRate.fps_num;\n meta.refSampleDuration = meta.timescale * (fps_den / fps_num);\n\n let codecArray = sps.subarray(1, 4);\n let codecString = 'avc1.';\n for (let j = 0; j < 3; j++) {\n let h = codecArray[j].toString(16);\n if (h.length < 2) {\n h = '0' + h;\n }\n codecString += h;\n }\n meta.codec = codecString;\n\n let mi = this._mediaInfo;\n mi.width = meta.codecWidth;\n mi.height = meta.codecHeight;\n mi.fps = meta.frameRate.fps;\n mi.profile = meta.profile;\n mi.level = meta.level;\n mi.refFrames = config.ref_frames;\n mi.chromaFormat = config.chroma_format_string;\n mi.sarNum = meta.sarRatio.width;\n mi.sarDen = meta.sarRatio.height;\n mi.videoCodec = codecString;\n\n if (mi.hasAudio) {\n if (mi.audioCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n }\n\n let ppsCount = v.getUint8(offset); // numOfPictureParameterSets\n if (ppsCount === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord: No PPS');\n return;\n } else if (ppsCount > 1) {\n Log.w(this.TAG, `Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ${ppsCount}`);\n }\n\n offset++;\n\n for (let i = 0; i < ppsCount; i++) {\n let len = v.getUint16(offset, !le); // pictureParameterSetLength\n offset += 2;\n\n if (len === 0) {\n continue;\n }\n\n // pps is useless for extracting video information\n offset += len;\n }\n\n meta.avcc = new Uint8Array(dataSize);\n meta.avcc.set(new Uint8Array(arrayBuffer, dataOffset, dataSize), 0);\n Log.v(this.TAG, 'Parsed AVCDecoderConfigurationRecord');\n\n if (this._isInitialMetadataDispatched()) {\n // flush parsed frames\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n } else {\n this._videoInitialMetadataDispatched = true;\n }\n // notify new metadata\n this._dispatch = false;\n this._onTrackMetadata('video', meta);\n }\n\n _parseAVCVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType, cts) {\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let units = [], length = 0;\n\n let offset = 0;\n const lengthSize = this._naluLengthSize;\n let dts = this._timestampBase + tagTimestamp;\n let keyframe = (frameType === 1); // from FLV Frame Type constants\n\n while (offset < dataSize) {\n if (offset + 4 >= dataSize) {\n Log.w(this.TAG, `Malformed Nalu near timestamp ${dts}, offset = ${offset}, dataSize = ${dataSize}`);\n break; // data not enough for next Nalu\n }\n // Nalu with length-header (AVC1)\n let naluSize = v.getUint32(offset, !le); // Big-Endian read\n if (lengthSize === 3) {\n naluSize >>>= 8;\n }\n if (naluSize > dataSize - lengthSize) {\n Log.w(this.TAG, `Malformed Nalus near timestamp ${dts}, NaluSize > DataSize!`);\n return;\n }\n\n let unitType = v.getUint8(offset + lengthSize) & 0x1F;\n\n if (unitType === 5) { // IDR\n keyframe = true;\n }\n\n let data = new Uint8Array(arrayBuffer, dataOffset + offset, lengthSize + naluSize);\n let unit = {type: unitType, data: data};\n units.push(unit);\n length += data.byteLength;\n\n offset += lengthSize + naluSize;\n }\n\n if (units.length) {\n let track = this._videoTrack;\n let avcSample = {\n units: units,\n length: length,\n isKeyframe: keyframe,\n dts: dts,\n cts: cts,\n pts: (dts + cts)\n };\n if (keyframe) {\n avcSample.fileposition = tagPosition;\n }\n track.samples.push(avcSample);\n track.length += length;\n }\n }\n\n}\n\nexport default FLVDemuxer;","interface ProgramToPMTPIDMap {\n [program: number]: number;\n}\n\nexport class PAT {\n version_number: number;\n network_pid: number;\n // program_number -> pmt_pid\n program_pmt_pid: ProgramToPMTPIDMap = {};\n}\n\nexport enum StreamType {\n kMPEG1Audio = 0x03,\n kMPEG2Audio = 0x04,\n kPESPrivateData = 0x06,\n kADTSAAC = 0x0F,\n kID3 = 0x15,\n kH264 = 0x1b,\n kH265 = 0x24\n}\n\ninterface PIDToStreamTypeMap {\n [pid: number]: StreamType;\n}\n\nexport class PMT {\n program_number: number;\n version_number: number;\n pcr_pid: number;\n // pid -> stream_type\n pid_stream_type: PIDToStreamTypeMap = {};\n\n common_pids: {\n h264: number | undefined,\n adts_aac: number | undefined\n } = {\n h264: undefined,\n adts_aac: undefined\n };\n\n pes_private_data_pids: {\n [pid: number]: boolean\n } = {};\n\n timed_id3_pids: {\n [pid: number]: boolean\n } = {};\n}\n\nexport interface ProgramToPMTMap {\n [program: number]: PMT;\n}\n\nexport class PESData {\n pid: number;\n data: Uint8Array;\n stream_type: StreamType;\n file_position: number;\n random_access_indicator: number;\n}\n\nexport class SliceQueue {\n slices: Uint8Array[] = [];\n total_length: number = 0;\n expected_length: number = 0;\n file_position: number = 0;\n random_access_indicator: 0;\n}\n\nexport interface PIDToSliceQueues {\n [pid: number]: SliceQueue;\n}\n","import MediaInfo from '../core/media-info';\nimport { PESPrivateData, PESPrivateDataDescriptor } from './pes-private-data';\n\ntype OnErrorCallback = (type: string, info: string) => void;\ntype OnMediaInfoCallback = (mediaInfo: MediaInfo) => void;\ntype OnMetaDataArrivedCallback = (metadata: any) => void;\ntype OnTrackMetadataCallback = (type: string, metadata: any) => void;\ntype OnDataAvailableCallback = (videoTrack: any, audioTrack: any) => void;\ntype OnTimedID3MetadataCallback = (timed_id3_data: PESPrivateData) => void;\ntype OnPESPrivateDataCallback = (private_data: PESPrivateData) => void;\ntype OnPESPrivateDataDescriptorCallback = (private_data_descriptor: PESPrivateDataDescriptor) => void;\n\nexport default abstract class BaseDemuxer {\n\n public onError: OnErrorCallback;\n public onMediaInfo: OnMediaInfoCallback;\n public onMetaDataArrived: OnMetaDataArrivedCallback;\n public onTrackMetadata: OnTrackMetadataCallback;\n public onDataAvailable: OnDataAvailableCallback;\n public onTimedID3Metadata: OnTimedID3MetadataCallback;\n public onPESPrivateData: OnPESPrivateDataCallback;\n public onPESPrivateDataDescriptor: OnPESPrivateDataDescriptorCallback;\n\n public constructor() {}\n\n public destroy(): void {\n this.onError = null;\n this.onMediaInfo = null;\n this.onMetaDataArrived = null;\n this.onTrackMetadata = null;\n this.onDataAvailable = null;\n this.onTimedID3Metadata = null;\n this.onPESPrivateData = null;\n this.onPESPrivateDataDescriptor = null;\n }\n\n abstract parseChunks(chunk: ArrayBuffer, byteStart: number): number;\n\n}\n","import Log from \"../utils/logger\";\n\nexport enum H264NaluType {\n kUnspecified = 0,\n kSliceNonIDR,\n kSliceDPA,\n kSliceDPB,\n kSliceDPC,\n kSliceIDR,\n kSliceSEI,\n kSliceSPS,\n kSlicePPS,\n kSliceAUD,\n kEndOfSequence,\n kEndOfStream,\n kFiller,\n kSPSExt,\n kReserved0\n}\n\nexport class H264NaluPayload {\n type: H264NaluType;\n data: Uint8Array;\n}\n\nexport class H264NaluAVC1 {\n type: H264NaluType;\n data: Uint8Array;\n\n constructor(nalu: H264NaluPayload) {\n let nalu_size = nalu.data.byteLength;\n\n this.type = nalu.type;\n this.data = new Uint8Array(4 + nalu_size); // 4 byte length-header + nalu payload\n\n let v = new DataView(this.data.buffer);\n // Fill 4 byte length-header\n v.setUint32(0, nalu_size);\n // Copy payload\n this.data.set(nalu.data, 4);\n }\n}\n\nexport class H264AnnexBParser {\n\n private readonly TAG: string = \"H264AnnexBParser\";\n\n private data_: Uint8Array;\n private current_startcode_offset_: number = 0;\n private eof_flag_: boolean = false;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_startcode_offset_ = this.findNextStartCodeOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, \"Could not found H264 startcode until payload end!\");\n }\n }\n\n private findNextStartCodeOffset(start_offset: number) {\n let i = start_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 3 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 00 00 00 01 or 00 00 01\n let uint32 = (data[i + 0] << 24)\n | (data[i + 1] << 16)\n | (data[i + 2] << 8)\n | (data[i + 3]);\n let uint24 = (data[i + 0] << 16)\n | (data[i + 1] << 8)\n | (data[i + 2]);\n if (uint32 === 0x00000001 || uint24 === 0x000001) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextNaluPayload(): H264NaluPayload | null {\n let data = this.data_;\n let nalu_payload: H264NaluPayload = null;\n\n while (nalu_payload == null) {\n if (this.eof_flag_) {\n break;\n }\n // offset pointed to start code\n let startcode_offset = this.current_startcode_offset_;\n\n // nalu payload start offset\n let offset = startcode_offset;\n let u32 = (data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | (data[offset + 3]);\n if (u32 === 0x00000001) {\n offset += 4;\n } else {\n offset += 3;\n }\n\n let nalu_type: H264NaluType = data[offset] & 0x1F;\n let forbidden_bit = (data[offset] & 0x80) >>> 7;\n\n let next_startcode_offset = this.findNextStartCodeOffset(offset);\n this.current_startcode_offset_ = next_startcode_offset;\n\n if (nalu_type >= H264NaluType.kReserved0) {\n continue;\n }\n if (forbidden_bit !== 0) {\n // Log.e(this.TAG, `forbidden_bit near offset ${offset} should be 0 but has value ${forbidden_bit}`);\n continue;\n }\n\n let payload_data = data.subarray(offset, next_startcode_offset);\n\n nalu_payload = new H264NaluPayload();\n nalu_payload.type = nalu_type;\n nalu_payload.data = payload_data;\n }\n\n return nalu_payload;\n }\n\n}\n\n\nexport class AVCDecoderConfigurationRecord {\n\n private data: Uint8Array;\n\n // sps, pps: require Nalu without 4 byte length-header\n public constructor(sps: Uint8Array, pps: Uint8Array, sps_details: any) {\n let length = 6 + 2 + sps.byteLength + 1 + 2 + pps.byteLength;\n let need_extra_fields = false;\n\n if (sps[3] !== 66 && sps[3] !== 77 && sps[3] !== 88) {\n need_extra_fields = true;\n length += 4;\n }\n\n let data = this.data = new Uint8Array(length);\n\n data[0] = 0x01; // configurationVersion\n data[1] = sps[1]; // AVCProfileIndication\n data[2] = sps[2]; // profile_compatibility\n data[3] = sps[3]; // AVCLevelIndication\n data[4] = 0xFF; // 111111 + lengthSizeMinusOne(3)\n\n data[5] = 0xE0 | 0x01 // 111 + numOfSequenceParameterSets\n\n let sps_length = sps.byteLength;\n data[6] = sps_length >>> 8; // sequenceParameterSetLength\n data[7] = sps_length & 0xFF;\n\n let offset = 8;\n data.set(sps, 8);\n offset += sps_length;\n\n data[offset] = 1; // numOfPictureParameterSets\n\n let pps_length = pps.byteLength;\n data[offset + 1] = pps_length >>> 8; // pictureParameterSetLength\n data[offset + 2] = pps_length & 0xFF;\n\n data.set(pps, offset + 3);\n offset += 3 + pps_length;\n\n if (need_extra_fields) {\n data[offset] = 0xFC | sps_details.chroma_format_idc;\n data[offset + 1] = 0xF8 | (sps_details.bit_depth_luma - 8);\n data[offset + 2] = 0xF8 | (sps_details.bit_depth_chroma - 8);\n data[offset + 3] = 0x00; // number of sps ext\n offset += 4;\n }\n }\n\n public getData() {\n return this.data;\n }\n\n}\n","export enum MPEG4AudioObjectTypes {\n kNull = 0,\n kAACMain,\n kAAC_LC, // LC-AAC\n kAAC_SSR,\n kAAC_LTP,\n kAAC_SBR, // HE-AAC\n kAAC_Scalable,\n\n kLayer1 = 32,\n kLayer2,\n kLayer3, // MP3\n}\n\nexport enum MPEG4SamplingFrequencyIndex {\n k96000Hz = 0,\n k88200Hz,\n k64000Hz,\n k48000Hz,\n k44100Hz,\n k32000Hz,\n k24000Hz,\n k22050Hz,\n k16000Hz,\n k12000Hz,\n k11025Hz,\n k8000Hz,\n k7350Hz,\n}\n\nexport const MPEG4SamplingFrequencies = [\n 96000,\n 88200,\n 64000,\n 48000,\n 44100,\n 32000,\n 24000,\n 22050,\n 16000,\n 12000,\n 11025,\n 8000,\n 7350,\n];\n","import Log from \"../utils/logger\";\nimport { MPEG4AudioObjectTypes, MPEG4SamplingFrequencies, MPEG4SamplingFrequencyIndex } from \"./mpeg4-audio\";\n\nexport class AACFrame {\n audio_object_type: MPEG4AudioObjectTypes;\n sampling_freq_index: MPEG4SamplingFrequencyIndex;\n sampling_frequency: number;\n channel_config: number;\n\n data: Uint8Array;\n}\n\nexport class AACADTSParser {\n\n private readonly TAG: string = \"AACADTSParser\";\n\n private data_: Uint8Array;\n private current_syncword_offset_: number;\n private eof_flag_: boolean;\n private has_last_incomplete_data: boolean;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_syncword_offset_ = this.findNextSyncwordOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, `Could not found ADTS syncword until payload end`);\n }\n }\n\n private findNextSyncwordOffset(syncword_offset: number): number {\n let i = syncword_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 7 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 12-bit 0xFFF syncword\n let syncword = ((data[i + 0] << 8) | data[i + 1]) >>> 4;\n if (syncword === 0xFFF) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextAACFrame(): AACFrame | null {\n let data = this.data_;\n let aac_frame: AACFrame = null;\n\n while (aac_frame == null) {\n if (this.eof_flag_) {\n break;\n }\n\n let syncword_offset = this.current_syncword_offset_;\n let offset = syncword_offset;\n\n // adts_fixed_header()\n // syncword 0xFFF: 12-bit\n let ID = (data[offset + 1] & 0x08) >>> 3;\n let layer = (data[offset + 1] & 0x06) >>> 1;\n let protection_absent = data[offset + 1] & 0x01;\n let profile = (data[offset + 2] & 0xC0) >>> 6;\n let sampling_frequency_index = (data[offset + 2] & 0x3C) >>> 2;\n let channel_configuration = ((data[offset + 2] & 0x01) << 2)\n | ((data[offset + 3] & 0xC0) >>> 6);\n\n // adts_variable_header()\n let aac_frame_length = ((data[offset + 3] & 0x03) << 11)\n | (data[offset + 4] << 3)\n | ((data[offset + 5] & 0xE0) >>> 5);\n let number_of_raw_data_blocks_in_frame = data[offset + 6] & 0x03;\n\n if (offset + aac_frame_length > this.data_.byteLength) {\n // data not enough for extracting last sample\n this.eof_flag_ = true;\n this.has_last_incomplete_data = true;\n break;\n }\n\n let adts_header_length = (protection_absent === 1) ? 7 : 9;\n let adts_frame_payload_length = aac_frame_length - adts_header_length;\n\n offset += adts_header_length;\n\n let next_syncword_offset = this.findNextSyncwordOffset(offset + adts_frame_payload_length);\n this.current_syncword_offset_ = next_syncword_offset;\n\n if ((ID !== 0 && ID !== 1) || layer !== 0) {\n // invalid adts frame ?\n continue;\n }\n\n let frame_data = data.subarray(offset, offset + adts_frame_payload_length);\n\n aac_frame = new AACFrame();\n aac_frame.audio_object_type = (profile + 1) as MPEG4AudioObjectTypes;\n aac_frame.sampling_freq_index = sampling_frequency_index as MPEG4SamplingFrequencyIndex;\n aac_frame.sampling_frequency = MPEG4SamplingFrequencies[sampling_frequency_index];\n aac_frame.channel_config = channel_configuration;\n aac_frame.data = frame_data;\n }\n\n return aac_frame;\n }\n\n public hasIncompleteData(): boolean {\n return this.has_last_incomplete_data;\n }\n\n public getIncompleteData(): Uint8Array {\n if (!this.has_last_incomplete_data) {\n return null;\n }\n\n return this.data_.subarray(this.current_syncword_offset_);\n }\n}\n\nexport class AudioSpecificConfig {\n\n public config: Array;\n public sampling_rate: number;\n public channel_count: number;\n public codec_mimetype: string;\n public original_codec_mimetype: string;\n\n public constructor(frame: AACFrame) {\n let config: Array = null;\n\n let original_audio_object_type = frame.audio_object_type;\n let audio_object_type = frame.audio_object_type;\n let sampling_index = frame.sampling_freq_index;\n let channel_config = frame.channel_config;\n let extension_sampling_index = 0;\n\n let userAgent = navigator.userAgent.toLowerCase();\n\n if (userAgent.indexOf('firefox') !== -1) {\n // firefox: use SBR (HE-AAC) if freq less than 24kHz\n if (sampling_index >= 6) {\n audio_object_type = 5;\n config = new Array(4);\n extension_sampling_index = sampling_index - 3;\n } else { // use LC-AAC\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n }\n } else if (userAgent.indexOf('android') !== -1) {\n // android: always use LC-AAC\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n } else {\n // for other browsers, e.g. chrome...\n // Always use HE-AAC to make it easier to switch aac codec profile\n audio_object_type = 5;\n extension_sampling_index = sampling_index;\n config = new Array(4);\n\n if (sampling_index >= 6) {\n extension_sampling_index = sampling_index - 3;\n } else if (channel_config === 1) { // Mono channel\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n }\n }\n\n config[0] = audio_object_type << 3;\n config[0] |= (sampling_index & 0x0F) >>> 1;\n config[1] = (sampling_index & 0x0F) << 7;\n config[1] |= (channel_config & 0x0F) << 3;\n if (audio_object_type === 5) {\n config[1] |= ((extension_sampling_index & 0x0F) >>> 1);\n config[2] = (extension_sampling_index & 0x01) << 7;\n // extended audio object type: force to 2 (LC-AAC)\n config[2] |= (2 << 2);\n config[3] = 0;\n }\n\n this.config = config;\n this.sampling_rate = MPEG4SamplingFrequencies[sampling_index];\n this.channel_count = channel_config;\n this.codec_mimetype = 'mp4a.40.' + audio_object_type;\n this.original_codec_mimetype = 'mp4a.40.' + original_audio_object_type;\n }\n\n}\n","// ISO/IEC 13818-1 PES packets containing private data (stream_type=0x06)\nexport class PESPrivateData {\n pid: number;\n stream_id: number;\n pts?: number;\n dts?: number;\n nearest_pts?: number;\n data: Uint8Array;\n len: number;\n}\n\nexport class PESPrivateDataDescriptor {\n pid: number;\n stream_type: number;\n descriptor: Uint8Array;\n}\n","/*\n * Copyright (C) 2021 magicxqq. All Rights Reserved.\n *\n * @author magicxqq \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger';\nimport DemuxErrors from './demux-errors';\nimport MediaInfo from '../core/media-info';\nimport {IllegalStateException} from '../utils/exception';\nimport BaseDemuxer from './base-demuxer';\nimport { PAT, PESData, SliceQueue, PIDToSliceQueues, PMT, ProgramToPMTMap, StreamType } from './pat-pmt-pes';\nimport { AVCDecoderConfigurationRecord, H264AnnexBParser, H264NaluAVC1, H264NaluPayload, H264NaluType } from './h264';\nimport SPSParser from './sps-parser';\nimport { AACADTSParser, AACFrame, AudioSpecificConfig } from './aac';\nimport { MPEG4AudioObjectTypes, MPEG4SamplingFrequencyIndex } from './mpeg4-audio';\nimport { PESPrivateData, PESPrivateDataDescriptor } from './pes-private-data';\n\nclass TSDemuxer extends BaseDemuxer {\n\n private readonly TAG: string = 'TSDemuxer';\n\n private config_: any;\n private ts_packet_size_: number;\n private sync_offset_: number;\n private first_parse_: boolean = true;\n\n private media_info_ = new MediaInfo();\n\n private timescale_ = 90;\n private duration_ = 0;\n\n private pat_: PAT;\n private current_program_: number;\n private current_pmt_pid_: number = -1;\n private pmt_: PMT;\n private program_pmt_map_: ProgramToPMTMap = {};\n\n private pes_slice_queues_: PIDToSliceQueues = {};\n\n private video_metadata_: {\n sps: H264NaluAVC1 | undefined,\n pps: H264NaluAVC1 | undefined,\n sps_details: any\n } = {\n sps: undefined,\n pps: undefined,\n sps_details: undefined\n };\n\n private audio_metadata_: {\n audio_object_type: MPEG4AudioObjectTypes;\n sampling_freq_index: MPEG4SamplingFrequencyIndex;\n sampling_frequency: number;\n channel_config: number;\n } = {\n audio_object_type: undefined,\n sampling_freq_index: undefined,\n sampling_frequency: undefined,\n channel_config: undefined\n };\n\n private aac_last_sample_pts_: number = undefined;\n private aac_last_incomplete_data_: Uint8Array = null;\n\n private has_video_ = false;\n private has_audio_ = false;\n private video_init_segment_dispatched_ = false;\n private audio_init_segment_dispatched_ = false;\n private video_metadata_changed_ = false;\n private audio_metadata_changed_ = false;\n\n private video_track_ = {type: 'video', id: 1, sequenceNumber: 0, samples: [], length: 0};\n private audio_track_ = {type: 'audio', id: 2, sequenceNumber: 0, samples: [], length: 0};\n\n public constructor(probe_data: any, config: any) {\n super();\n\n this.ts_packet_size_ = probe_data.ts_packet_size;\n this.sync_offset_ = probe_data.sync_offset;\n this.config_ = config;\n }\n\n public destroy() {\n this.media_info_ = null;\n this.pes_slice_queues_ = null;\n\n this.video_metadata_ = null;\n this.audio_metadata_ = null;\n this.aac_last_incomplete_data_ = null;\n\n this.video_track_ = null;\n this.audio_track_ = null;\n\n super.destroy();\n }\n\n public static probe(buffer: ArrayBuffer) {\n let data = new Uint8Array(buffer);\n let sync_offset = -1;\n let ts_packet_size = 188;\n\n if (data.byteLength <= 3 * ts_packet_size) {\n Log.e('TSDemuxer', `Probe data ${data.byteLength} bytes is too few for judging MPEG-TS stream format!`);\n return {match: false};\n }\n\n while (sync_offset === -1) {\n let scan_window = Math.min(1000, data.byteLength - 3 * ts_packet_size);\n\n for (let i = 0; i < scan_window; ) {\n // sync_byte should all be 0x47\n if (data[i] === 0x47\n && data[i + ts_packet_size] === 0x47\n && data[i + 2 * ts_packet_size] === 0x47) {\n sync_offset = i;\n break;\n } else {\n i++;\n }\n }\n\n // find sync_offset failed in previous ts_packet_size\n if (sync_offset === -1) {\n if (ts_packet_size === 188) {\n // try 192 packet size (BDAV, etc.)\n ts_packet_size = 192;\n } else if (ts_packet_size === 192) {\n // try 204 packet size (European DVB, etc.)\n ts_packet_size = 204;\n } else {\n // 192, 204 also failed, exit\n break;\n }\n }\n }\n\n if (sync_offset === -1) {\n // both 188, 192, 204 failed, Non MPEG-TS\n return {match: false};\n }\n\n if (ts_packet_size === 192 && sync_offset >= 4) {\n Log.v('TSDemuxer', `ts_packet_size = 192, m2ts mode`);\n sync_offset -= 4;\n } else if (ts_packet_size === 204) {\n Log.v('TSDemuxer', `ts_packet_size = 204, RS encoded MPEG2-TS stream`);\n }\n\n return {\n match: true,\n consumed: 0,\n ts_packet_size,\n sync_offset\n };\n }\n\n public bindDataSource(loader) {\n loader.onDataArrival = this.parseChunks.bind(this);\n return this;\n }\n\n public resetMediaInfo() {\n this.media_info_ = new MediaInfo();\n }\n\n public parseChunks(chunk: ArrayBuffer, byte_start: number): number {\n if (!this.onError\n || !this.onMediaInfo\n || !this.onTrackMetadata\n || !this.onDataAvailable) {\n throw new IllegalStateException('onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified');\n }\n\n let offset = 0;\n\n if (this.first_parse_) {\n this.first_parse_ = false;\n offset = this.sync_offset_;\n }\n\n while (offset + this.ts_packet_size_ <= chunk.byteLength) {\n let file_position = byte_start + offset;\n\n if (this.ts_packet_size_ === 192) {\n // skip ATS field (2-bits copy-control + 30-bits timestamp) for m2ts\n offset += 4;\n }\n\n let data = new Uint8Array(chunk, offset, 188);\n\n let sync_byte = data[0];\n if (sync_byte !== 0x47) {\n Log.e(this.TAG, `sync_byte = ${sync_byte}, not 0x47`);\n break;\n }\n\n let payload_unit_start_indicator = (data[1] & 0x40) >>> 6;\n let transport_priority = (data[1] & 0x20) >>> 5;\n let pid = ((data[1] & 0x1F) << 8) | data[2];\n let adaptation_field_control = (data[3] & 0x30) >>> 4;\n let continuity_conunter = (data[3] & 0x0F);\n\n let adaptation_field_info: {\n discontinuity_indicator?: number,\n random_access_indicator?: number,\n elementary_stream_priority_indicator?: number\n } = {};\n let ts_payload_start_index = 4;\n\n if (adaptation_field_control == 0x02 || adaptation_field_control == 0x03) {\n let adaptation_field_length = data[4];\n if (5 + adaptation_field_length === 188) {\n // TS packet only has adaption field, jump to next\n offset += 188;\n if (this.ts_packet_size_ === 204) {\n // skip parity word (16 bytes) for RS encoded TS\n offset += 16;\n }\n continue;\n } else {\n // parse leading adaptation_field if has payload\n if (adaptation_field_length > 0) {\n adaptation_field_info = this.parseAdaptationField(chunk,\n offset + 4,\n 1 + adaptation_field_length);\n }\n ts_payload_start_index = 4 + 1 + adaptation_field_length;\n }\n }\n\n if (adaptation_field_control == 0x01 || adaptation_field_control == 0x03) {\n if (pid === 0 || pid === this.current_pmt_pid_) { // PAT(pid === 0) or PMT\n if (payload_unit_start_indicator) {\n let pointer_field = data[ts_payload_start_index];\n // skip pointer_field and strange data\n ts_payload_start_index += 1 + pointer_field;\n }\n let ts_payload_length = 188 - ts_payload_start_index;\n\n if (pid === 0) {\n this.parsePAT(chunk,\n offset + ts_payload_start_index,\n ts_payload_length,\n {payload_unit_start_indicator, continuity_conunter});\n } else {\n this.parsePMT(chunk,\n offset + ts_payload_start_index,\n ts_payload_length,\n {payload_unit_start_indicator, continuity_conunter});\n }\n } else if (this.pmt_ != undefined && this.pmt_.pid_stream_type[pid] != undefined) {\n // PES\n let ts_payload_length = 188 - ts_payload_start_index;\n let stream_type = this.pmt_.pid_stream_type[pid];\n\n // process PES only for known common_pids\n if (pid === this.pmt_.common_pids.h264\n || pid === this.pmt_.common_pids.adts_aac\n || this.pmt_.pes_private_data_pids[pid] === true\n || this.pmt_.timed_id3_pids[pid] === true) {\n this.handlePESSlice(chunk,\n offset + ts_payload_start_index,\n ts_payload_length,\n {\n pid,\n stream_type,\n file_position,\n payload_unit_start_indicator,\n continuity_conunter,\n random_access_indicator: adaptation_field_info.random_access_indicator\n });\n }\n }\n }\n\n offset += 188;\n\n if (this.ts_packet_size_ === 204) {\n // skip parity word (16 bytes) for RS encoded TS\n offset += 16;\n }\n }\n\n // dispatch parsed frames to the remuxer (consumer)\n this.dispatchAudioVideoMediaSegment();\n\n return offset; // consumed bytes\n }\n\n private parseAdaptationField(buffer: ArrayBuffer, offset: number, length: number): {\n discontinuity_indicator?: number,\n random_access_indicator?: number,\n elementary_stream_priority_indicator?: number\n } {\n let data = new Uint8Array(buffer, offset, length);\n\n let adaptation_field_length = data[0];\n if (adaptation_field_length > 0) {\n if (adaptation_field_length > 183) {\n Log.w(this.TAG, `Illegal adaptation_field_length: ${adaptation_field_length}`);\n return {};\n }\n\n let discontinuity_indicator: number = (data[1] & 0x80) >>> 7;\n let random_access_indicator: number = (data[1] & 0x40) >>> 6;\n let elementary_stream_priority_indicator: number = (data[1] & 0x20) >>> 5;\n\n return {\n discontinuity_indicator,\n random_access_indicator,\n elementary_stream_priority_indicator\n };\n }\n\n return {};\n }\n\n private parsePAT(buffer: ArrayBuffer, offset: number, length: number, misc: any): void {\n let data = new Uint8Array(buffer, offset, length);\n\n let table_id = data[0];\n if (table_id !== 0x00) {\n Log.e(this.TAG, `parsePAT: table_id ${table_id} is not corresponded to PAT!`);\n return;\n }\n\n let section_length = ((data[1] & 0x0F) << 8) | data[2];\n\n let transport_stream_id = (data[3] << 8) | data[4];\n let version_number = (data[5] & 0x3E) >>> 1;\n let current_next_indicator = data[5] & 0x01;\n let section_number = data[6];\n let last_section_number = data[7];\n\n let pat: PAT = null;\n\n if (current_next_indicator === 1 && section_number === 0) {\n pat = new PAT();\n pat.version_number = version_number;\n } else {\n pat = this.pat_;\n if (pat == undefined) {\n return;\n }\n }\n\n let program_start_index = 8;\n let program_bytes = section_length - 5 - 4; // section_length - (headers + crc)\n let first_program_number = -1;\n let first_pmt_pid = -1;\n\n for (let i = program_start_index; i < program_start_index + program_bytes; i += 4) {\n let program_number = (data[i] << 8) | data[i + 1];\n let pid = ((data[i + 2] & 0x1F) << 8) | data[i + 3];\n\n if (program_number === 0) {\n // network_PID\n pat.network_pid = pid;\n } else {\n // program_map_PID\n pat.program_pmt_pid[program_number] = pid;\n\n if (first_program_number === -1) {\n first_program_number = program_number;\n }\n\n if (first_pmt_pid === -1) {\n first_pmt_pid = pid;\n }\n }\n }\n\n // Currently we only deal with first appeared PMT pid\n if (current_next_indicator === 1 && section_number === 0) {\n if (this.pat_ == undefined) {\n Log.v(this.TAG, `Parsed first PAT: ${JSON.stringify(pat)}`);\n }\n this.pat_ = pat;\n this.current_program_ = first_program_number;\n this.current_pmt_pid_ = first_pmt_pid;\n }\n }\n\n private parsePMT(buffer: ArrayBuffer, offset: number, length: number, misc: any): void {\n let data = new Uint8Array(buffer, offset, length);\n\n let table_id = data[0];\n if (table_id !== 0x02) {\n Log.e(this.TAG, `parsePMT: table_id ${table_id} is not corresponded to PMT!`);\n return;\n }\n\n let section_length = ((data[1] & 0x0F) << 8) | data[2];\n\n let program_number = (data[3] << 8) | data[4];\n let version_number = (data[5] & 0x3E) >>> 1;\n let current_next_indicator = data[5] & 0x01;\n let section_number = data[6];\n let last_section_number = data[7];\n\n let pmt: PMT = null;\n\n if (current_next_indicator === 1 && section_number === 0) {\n pmt = new PMT();\n pmt.program_number = program_number;\n pmt.version_number = version_number;\n this.program_pmt_map_[program_number] = pmt;\n } else {\n pmt = this.program_pmt_map_[program_number];\n if (pmt == undefined) {\n return;\n }\n }\n\n let PCR_PID = ((data[8] & 0x1F) << 8) | data[9];\n let program_info_length = ((data[10] & 0x0F) << 8) | data[11];\n\n let info_start_index = 12 + program_info_length;\n let info_bytes = section_length - 9 - program_info_length - 4;\n\n for (let i = info_start_index; i < info_start_index + info_bytes; ) {\n let stream_type = data[i] as StreamType;\n let elementary_PID = ((data[i + 1] & 0x1F) << 8) | data[i + 2];\n let ES_info_length = ((data[i + 3] & 0x0F) << 8) | data[i + 4];\n\n pmt.pid_stream_type[elementary_PID] = stream_type;\n\n if (stream_type === StreamType.kH264 && !pmt.common_pids.h264) {\n pmt.common_pids.h264 = elementary_PID;\n } else if (stream_type === StreamType.kADTSAAC && !pmt.common_pids.adts_aac) {\n pmt.common_pids.adts_aac = elementary_PID;\n } else if (stream_type === StreamType.kPESPrivateData) {\n pmt.pes_private_data_pids[elementary_PID] = true;\n if (ES_info_length > 0) {\n // provide descriptor for PES private data via callback\n let descriptor = data.subarray(i + 5, i + 5 + ES_info_length);\n this.dispatchPESPrivateDataDescriptor(elementary_PID, stream_type, descriptor);\n }\n } else if (stream_type === StreamType.kID3) {\n pmt.timed_id3_pids[elementary_PID] = true;\n }\n\n i += 5 + ES_info_length;\n }\n\n if (program_number === this.current_program_) {\n if (this.pmt_ == undefined) {\n Log.v(this.TAG, `Parsed first PMT: ${JSON.stringify(pmt)}`);\n }\n this.pmt_ = pmt;\n if (pmt.common_pids.h264) {\n this.has_video_ = true;\n }\n if (pmt.common_pids.adts_aac) {\n this.has_audio_ = true;\n }\n }\n }\n\n private handlePESSlice(buffer: ArrayBuffer, offset: number, length: number, misc: any): void {\n let data = new Uint8Array(buffer, offset, length);\n\n let packet_start_code_prefix = (data[0] << 16) | (data[1] << 8) | (data[2]);\n let stream_id = data[3];\n let PES_packet_length = (data[4] << 8) | data[5];\n\n if (misc.payload_unit_start_indicator) {\n if (packet_start_code_prefix !== 1) {\n Log.e(this.TAG, `handlePESSlice: packet_start_code_prefix should be 1 but with value ${packet_start_code_prefix}`);\n return;\n }\n\n // handle queued PES slices:\n // Merge into a big Uint8Array then call parsePES()\n let slice_queue = this.pes_slice_queues_[misc.pid];\n if (slice_queue) {\n if (slice_queue.expected_length === 0 || slice_queue.expected_length === slice_queue.total_length) {\n this.emitPESSlices(slice_queue, misc);\n } else {\n this.cleanPESSlices(slice_queue, misc);\n }\n }\n\n // Make a new PES queue for new PES slices\n this.pes_slice_queues_[misc.pid] = new SliceQueue();\n this.pes_slice_queues_[misc.pid].file_position = misc.file_position;\n this.pes_slice_queues_[misc.pid].random_access_indicator = misc.random_access_indicator;\n }\n\n if (this.pes_slice_queues_[misc.pid] == undefined) {\n // ignore PES slices without [PES slice that has payload_unit_start_indicator]\n return;\n }\n\n // push subsequent PES slices into pes_queue\n let slice_queue = this.pes_slice_queues_[misc.pid];\n slice_queue.slices.push(data);\n if (misc.payload_unit_start_indicator) {\n slice_queue.expected_length = PES_packet_length === 0 ? 0 : PES_packet_length + 6;\n }\n slice_queue.total_length += data.byteLength;\n\n if (slice_queue.expected_length > 0 && slice_queue.expected_length === slice_queue.total_length) {\n this.emitPESSlices(slice_queue, misc);\n } else if (slice_queue.expected_length > 0 && slice_queue.expected_length < slice_queue.total_length) {\n this.cleanPESSlices(slice_queue, misc);\n }\n }\n\n private emitPESSlices(slice_queue: SliceQueue, misc: any): void {\n let data = new Uint8Array(slice_queue.total_length);\n for (let i = 0, offset = 0; i < slice_queue.slices.length; i++) {\n let slice = slice_queue.slices[i];\n data.set(slice, offset);\n offset += slice.byteLength;\n }\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n\n let pes_data = new PESData();\n pes_data.pid = misc.pid;\n pes_data.data = data;\n pes_data.stream_type = misc.stream_type;\n pes_data.file_position = slice_queue.file_position;\n pes_data.random_access_indicator = slice_queue.random_access_indicator;\n this.parsePES(pes_data);\n }\n\n private cleanPESSlices(slice_queue: SliceQueue, misc: any): void {\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n }\n\n private parsePES(pes_data: PESData): void {\n let data = pes_data.data;\n let packet_start_code_prefix = (data[0] << 16) | (data[1] << 8) | (data[2]);\n let stream_id = data[3];\n let PES_packet_length = (data[4] << 8) | data[5];\n\n if (packet_start_code_prefix !== 1) {\n Log.e(this.TAG, `parsePES: packet_start_code_prefix should be 1 but with value ${packet_start_code_prefix}`);\n return;\n }\n\n if (stream_id !== 0xBC // program_stream_map\n && stream_id !== 0xBE // padding_stream\n && stream_id !== 0xBF // private_stream_2\n && stream_id !== 0xF0 // ECM\n && stream_id !== 0xF1 // EMM\n && stream_id !== 0xFF // program_stream_directory\n && stream_id !== 0xF2 // DSMCC\n && stream_id !== 0xF8) {\n let PES_scrambling_control = (data[6] & 0x30) >>> 4;\n let PTS_DTS_flags = (data[7] & 0xC0) >>> 6;\n let PES_header_data_length = data[8];\n\n let pts: number | undefined;\n let dts: number | undefined;\n\n if (PTS_DTS_flags === 0x02 || PTS_DTS_flags === 0x03) {\n pts = (data[9] & 0x0E) * 536870912 + // 1 << 29\n (data[10] & 0xFF) * 4194304 + // 1 << 22\n (data[11] & 0xFE) * 16384 + // 1 << 14\n (data[12] & 0xFF) * 128 + // 1 << 7\n (data[13] & 0xFE) / 2;\n\n if (PTS_DTS_flags === 0x03) {\n dts = (data[14] & 0x0E) * 536870912 + // 1 << 29\n (data[15] & 0xFF) * 4194304 + // 1 << 22\n (data[16] & 0xFE) * 16384 + // 1 << 14\n (data[17] & 0xFF) * 128 + // 1 << 7\n (data[18] & 0xFE) / 2;\n } else {\n dts = pts;\n }\n }\n\n let payload_start_index = 6 + 3 + PES_header_data_length;\n let payload_length: number;\n\n if (PES_packet_length !== 0) {\n if (PES_packet_length < 3 + PES_header_data_length) {\n Log.v(this.TAG, `Malformed PES: PES_packet_length < 3 + PES_header_data_length`);\n return;\n }\n payload_length = PES_packet_length - 3 - PES_header_data_length;\n } else { // PES_packet_length === 0\n payload_length = data.byteLength - payload_start_index;\n }\n\n let payload = data.subarray(payload_start_index, payload_start_index + payload_length);\n\n switch (pes_data.stream_type) {\n case StreamType.kMPEG1Audio:\n case StreamType.kMPEG2Audio:\n break;\n case StreamType.kPESPrivateData:\n this.parsePESPrivateDataPayload(payload, pts, dts, pes_data.pid, stream_id);\n break;\n case StreamType.kADTSAAC:\n this.parseAACPayload(payload, pts);\n break;\n case StreamType.kID3:\n this.parseTimedID3MetadataPayload(payload, pts, dts, pes_data.pid, stream_id);\n break;\n case StreamType.kH264:\n this.parseH264Payload(payload, pts, dts, pes_data.file_position, pes_data.random_access_indicator);\n break;\n case StreamType.kH265:\n default:\n break;\n }\n } else if (stream_id === 0xBC // program_stream_map\n || stream_id === 0xBF // private_stream_2\n || stream_id === 0xF0 // ECM\n || stream_id === 0xF1 // EMM\n || stream_id === 0xFF // program_stream_directory\n || stream_id === 0xF2 // DSMCC_stream\n || stream_id === 0xF8) { // ITU-T Rec. H.222.1 type E stream\n if (pes_data.stream_type === StreamType.kPESPrivateData) {\n let payload_start_index = 6;\n let payload_length: number;\n\n if (PES_packet_length !== 0) {\n payload_length = PES_packet_length;\n } else { // PES_packet_length === 0\n payload_length = data.byteLength - payload_start_index;\n }\n\n let payload = data.subarray(payload_start_index, payload_start_index + payload_length);\n this.parsePESPrivateDataPayload(payload, undefined, undefined, pes_data.pid, stream_id);\n }\n }\n }\n\n private parseH264Payload(data: Uint8Array, pts: number, dts: number, file_position: number, random_access_indicator: number) {\n let annexb_parser = new H264AnnexBParser(data);\n let nalu_payload: H264NaluPayload = null;\n let units: {type: H264NaluType, data: Uint8Array}[] = [];\n let length = 0;\n let keyframe = false;\n\n while ((nalu_payload = annexb_parser.readNextNaluPayload()) != null) {\n let nalu_avc1 = new H264NaluAVC1(nalu_payload);\n\n if (nalu_avc1.type === H264NaluType.kSliceSPS) {\n // Notice: parseSPS requires Nalu without startcode or length-header\n let sps_details = SPSParser.parseSPS(nalu_payload.data);\n if (!this.video_init_segment_dispatched_) {\n this.video_metadata_.sps = nalu_avc1;\n this.video_metadata_.sps_details = sps_details;\n } else if (this.detectVideoMetadataChange(nalu_avc1, sps_details) === true) {\n Log.v(this.TAG, `H264: Critical h264 metadata has been changed, attempt to re-generate InitSegment`);\n this.video_metadata_changed_ = true;\n this.video_metadata_ = {sps: nalu_avc1, pps: undefined, sps_details: sps_details};\n }\n } else if (nalu_avc1.type === H264NaluType.kSlicePPS) {\n if (!this.video_init_segment_dispatched_ || this.video_metadata_changed_) {\n this.video_metadata_.pps = nalu_avc1;\n if (this.video_metadata_.sps && this.video_metadata_.pps) {\n if (this.video_metadata_changed_) {\n // flush stashed frames before changing codec metadata\n this.dispatchVideoMediaSegment();\n }\n // notify new codec metadata (maybe changed)\n this.dispatchVideoInitSegment();\n }\n }\n } else if (nalu_avc1.type === H264NaluType.kSliceIDR) {\n keyframe = true;\n } else if (nalu_avc1.type === H264NaluType.kSliceNonIDR && random_access_indicator === 1) {\n // For open-gop stream, use random_access_indicator to identify keyframe\n keyframe = true;\n }\n\n // Push samples to remuxer only if initialization metadata has been dispatched\n if (this.video_init_segment_dispatched_) {\n units.push(nalu_avc1);\n length += nalu_avc1.data.byteLength;\n }\n }\n\n let pts_ms = Math.floor(pts / this.timescale_);\n let dts_ms = Math.floor(dts / this.timescale_);\n\n if (units.length) {\n let track = this.video_track_;\n let avc_sample = {\n units,\n length,\n isKeyframe: keyframe,\n dts: dts_ms,\n pts: pts_ms,\n cts: pts_ms - dts_ms,\n file_position\n };\n track.samples.push(avc_sample);\n track.length += length;\n }\n }\n\n private detectVideoMetadataChange(new_sps: H264NaluAVC1, new_sps_details: any): boolean {\n if (new_sps_details.codec_mimetype !== this.video_metadata_.sps_details.codec_mimetype) {\n Log.v(this.TAG, `H264: Codec mimeType changed from ` +\n `${this.video_metadata_.sps_details.codec_mimetype} to ${new_sps_details.codec_mimetype}`);\n return true;\n }\n\n if (new_sps_details.codec_size.width !== this.video_metadata_.sps_details.codec_size.width\n || new_sps_details.codec_size.height !== this.video_metadata_.sps_details.codec_size.height) {\n let old_size = this.video_metadata_.sps_details.codec_size;\n let new_size = new_sps_details.codec_size;\n Log.v(this.TAG, `H264: Coded Resolution changed from ` +\n `${old_size.width}x${old_size.height} to ${new_size.width}x${new_size.height}`);\n return true;\n }\n\n if (new_sps_details.present_size.width !== this.video_metadata_.sps_details.present_size.width) {\n Log.v(this.TAG, `H264: Present resolution width changed from ` +\n `${this.video_metadata_.sps_details.present_size.width} to ${new_sps_details.present_size.width}`);\n return true;\n }\n\n return false;\n }\n\n private isInitSegmentDispatched(): boolean {\n if (this.has_video_ && this.has_audio_) { // both video & audio\n return this.video_init_segment_dispatched_ && this.audio_init_segment_dispatched_;\n }\n if (this.has_video_ && !this.has_audio_) { // video only\n return this.video_init_segment_dispatched_;\n }\n if (!this.has_video_ && this.has_audio_) { // audio only\n return this.audio_init_segment_dispatched_;\n }\n return false;\n }\n\n private dispatchVideoInitSegment() {\n let sps_details = this.video_metadata_.sps_details;\n let meta: any = {};\n\n meta.type = 'video';\n meta.id = this.video_track_.id;\n meta.timescale = 1000;\n meta.duration = this.duration_;\n\n meta.codecWidth = sps_details.codec_size.width;\n meta.codecHeight = sps_details.codec_size.height;\n meta.presentWidth = sps_details.present_size.width;\n meta.presentHeight = sps_details.present_size.height;\n\n meta.profile = sps_details.profile_string;\n meta.level = sps_details.level_string;\n meta.bitDepth = sps_details.bit_depth;\n meta.chromaFormat = sps_details.chroma_format;\n meta.sarRatio = sps_details.sar_ratio;\n meta.frameRate = sps_details.frame_rate;\n\n let fps_den = meta.frameRate.fps_den;\n let fps_num = meta.frameRate.fps_num;\n meta.refSampleDuration = 1000 * (fps_den / fps_num);\n\n meta.codec = sps_details.codec_mimetype;\n\n let sps_without_header = this.video_metadata_.sps.data.subarray(4);\n let pps_without_header = this.video_metadata_.pps.data.subarray(4);\n\n let avcc = new AVCDecoderConfigurationRecord(sps_without_header, pps_without_header, sps_details);\n meta.avcc = avcc.getData();\n\n if (this.video_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first AVCDecoderConfigurationRecord for mimeType: ${meta.codec}`);\n }\n\n this.onTrackMetadata('video', meta);\n this.video_init_segment_dispatched_ = true;\n this.video_metadata_changed_ = false;\n\n // notify new MediaInfo\n let mi = this.media_info_;\n mi.hasVideo = true;\n mi.width = meta.codecWidth;\n mi.height = meta.codecHeight;\n mi.fps = meta.frameRate.fps;\n mi.profile = meta.profile;\n mi.level = meta.level;\n mi.refFrames = sps_details.ref_frames;\n mi.chromaFormat = sps_details.chroma_format_string;\n mi.sarNum = meta.sarRatio.width;\n mi.sarDen = meta.sarRatio.height;\n mi.videoCodec = meta.codec;\n\n if (mi.hasAudio && mi.audioCodec) {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec},${mi.audioCodec}\"`;\n } else {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec}\"`;\n }\n\n if (mi.isComplete()) {\n this.onMediaInfo(mi);\n }\n }\n\n private dispatchVideoMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.video_track_.length) {\n this.onDataAvailable(null, this.video_track_);\n }\n }\n }\n\n private dispatchAudioMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.audio_track_.length) {\n this.onDataAvailable(this.audio_track_, null);\n }\n }\n }\n\n private dispatchAudioVideoMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.audio_track_.length || this.video_track_.length) {\n this.onDataAvailable(this.audio_track_, this.video_track_);\n }\n }\n }\n\n private parseAACPayload(data: Uint8Array, pts: number) {\n if (this.has_video_ && !this.video_init_segment_dispatched_) {\n // If first video IDR frame hasn't been detected,\n // Wait for first IDR frame and video init segment being dispatched\n return;\n }\n\n if (this.aac_last_incomplete_data_) {\n let buf = new Uint8Array(data.byteLength + this.aac_last_incomplete_data_.byteLength);\n buf.set(this.aac_last_incomplete_data_, 0);\n buf.set(data, this.aac_last_incomplete_data_.byteLength);\n data = buf;\n }\n\n let ref_sample_duration: number;\n let base_pts_ms: number;\n\n if (pts != undefined) {\n base_pts_ms = pts / this.timescale_;\n } else if (this.aac_last_sample_pts_ != undefined) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n base_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n } else {\n Log.w(this.TAG, `AAC: Unknown pts`);\n return;\n }\n\n if (this.aac_last_incomplete_data_ && this.aac_last_sample_pts_) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n let new_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n\n if (Math.abs(new_pts_ms - base_pts_ms) > 1) {\n Log.w(this.TAG, `AAC: Detected pts overlapped, ` +\n `expected: ${new_pts_ms}ms, PES pts: ${base_pts_ms}ms`);\n base_pts_ms = new_pts_ms;\n }\n }\n\n let adts_parser = new AACADTSParser(data);\n let aac_frame: AACFrame = null;\n let sample_pts_ms = base_pts_ms;\n let last_sample_pts_ms: number;\n\n while ((aac_frame = adts_parser.readNextAACFrame()) != null) {\n ref_sample_duration = 1024 / aac_frame.sampling_frequency * 1000;\n\n if (this.audio_init_segment_dispatched_ == false) {\n this.audio_metadata_.audio_object_type = aac_frame.audio_object_type;\n this.audio_metadata_.sampling_freq_index = aac_frame.sampling_freq_index;\n this.audio_metadata_.sampling_frequency = aac_frame.sampling_frequency;\n this.audio_metadata_.channel_config = aac_frame.channel_config;\n this.dispatchAudioInitSegment(aac_frame);\n } else if (this.detectAudioMetadataChange(aac_frame)) {\n // flush stashed frames before notify new AudioSpecificConfig\n this.dispatchAudioMediaSegment();\n // notify new AAC AudioSpecificConfig\n this.dispatchAudioInitSegment(aac_frame);\n }\n\n last_sample_pts_ms = sample_pts_ms;\n let sample_pts_ms_int = Math.floor(sample_pts_ms);\n\n let aac_sample = {\n unit: aac_frame.data,\n length: aac_frame.data.byteLength,\n pts: sample_pts_ms_int,\n dts: sample_pts_ms_int\n };\n this.audio_track_.samples.push(aac_sample);\n this.audio_track_.length += aac_frame.data.byteLength;\n\n sample_pts_ms += ref_sample_duration;\n }\n\n if (adts_parser.hasIncompleteData()) {\n this.aac_last_incomplete_data_ = adts_parser.getIncompleteData();\n }\n\n if (last_sample_pts_ms) {\n this.aac_last_sample_pts_ = last_sample_pts_ms;\n }\n }\n\n private detectAudioMetadataChange(frame: AACFrame): boolean {\n if (frame.audio_object_type !== this.audio_metadata_.audio_object_type) {\n Log.v(this.TAG, `AAC: AudioObjectType changed from ` +\n `${this.audio_metadata_.audio_object_type} to ${frame.audio_object_type}`);\n return true;\n }\n\n if (frame.sampling_freq_index !== this.audio_metadata_.sampling_freq_index) {\n Log.v(this.TAG, `AAC: SamplingFrequencyIndex changed from ` +\n `${this.audio_metadata_.sampling_freq_index} to ${frame.sampling_freq_index}`);\n return true;\n }\n\n if (frame.channel_config !== this.audio_metadata_.channel_config) {\n Log.v(this.TAG, `AAC: Channel configuration changed from ` +\n `${this.audio_metadata_.channel_config} to ${frame.channel_config}`);\n return true;\n }\n\n return false;\n }\n\n private dispatchAudioInitSegment(aac_frame: AACFrame) {\n let audio_specific_config = new AudioSpecificConfig(aac_frame);\n let meta: any = {};\n\n meta.type = 'audio';\n meta.id = this.audio_track_.id;\n meta.timescale = 1000;\n meta.duration = this.duration_;\n\n meta.audioSampleRate = audio_specific_config.sampling_rate;\n meta.channelCount = audio_specific_config.channel_count;\n meta.codec = audio_specific_config.codec_mimetype;\n meta.originalCodec = audio_specific_config.original_codec_mimetype;\n meta.config = audio_specific_config.config;\n\n meta.refSampleDuration = 1024 / meta.audioSampleRate * meta.timescale;\n\n if (this.audio_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first AudioSpecificConfig for mimeType: ${meta.codec}`);\n }\n\n this.onTrackMetadata('audio', meta);\n this.audio_init_segment_dispatched_ = true;\n this.video_metadata_changed_ = false;\n\n // notify new MediaInfo\n let mi = this.media_info_;\n mi.hasAudio = true;\n mi.audioCodec = meta.originalCodec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n\n if (mi.hasVideo && mi.videoCodec) {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec},${mi.audioCodec}\"`;\n } else {\n mi.mimeType = `video/mp2t; codecs=\"${mi.audioCodec}\"`;\n }\n\n if (mi.isComplete()) {\n this.onMediaInfo(mi);\n }\n }\n\n private dispatchPESPrivateDataDescriptor(pid: number, stream_type: number, descriptor: Uint8Array) {\n let desc = new PESPrivateDataDescriptor();\n desc.pid = pid;\n desc.stream_type = stream_type;\n desc.descriptor = descriptor;\n\n if (this.onPESPrivateDataDescriptor) {\n this.onPESPrivateDataDescriptor(desc);\n }\n }\n\n private parsePESPrivateDataPayload(data: Uint8Array, pts: number, dts: number, pid: number, stream_id: number) {\n let private_data = new PESPrivateData();\n\n private_data.pid = pid;\n private_data.stream_id = stream_id;\n private_data.len = data.byteLength;\n private_data.data = data;\n\n if (pts != undefined) {\n let pts_ms = Math.floor(pts / this.timescale_);\n private_data.pts = pts_ms;\n } else {\n private_data.nearest_pts = this.aac_last_sample_pts_;\n }\n\n if (dts != undefined) {\n let dts_ms = Math.floor(dts / this.timescale_);\n private_data.dts = dts_ms;\n }\n\n if (this.onPESPrivateData) {\n this.onPESPrivateData(private_data);\n }\n }\n\n private parseTimedID3MetadataPayload(data: Uint8Array, pts: number, dts: number, pid: number, stream_id: number) {\n let timed_id3_metadata = new PESPrivateData();\n\n timed_id3_metadata.pid = pid;\n timed_id3_metadata.stream_id = stream_id;\n timed_id3_metadata.len = data.byteLength;\n timed_id3_metadata.data = data;\n\n if (pts != undefined) {\n let pts_ms = Math.floor(pts / this.timescale_);\n timed_id3_metadata.pts = pts_ms;\n } \n\n if (dts != undefined) {\n let dts_ms = Math.floor(dts / this.timescale_);\n timed_id3_metadata.dts = dts_ms;\n }\n\n if (this.onTimedID3Metadata) {\n this.onTimedID3Metadata(timed_id3_metadata);\n }\n }\n}\n\nexport default TSDemuxer;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is derived from dailymotion's hls.js library (hls.js/src/remux/mp4-generator.js)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// MP4 boxes generator for ISO BMFF (ISO Base Media File Format, defined in ISO/IEC 14496-12)\nclass MP4 {\n\n static init() {\n MP4.types = {\n avc1: [], avcC: [], btrt: [], dinf: [],\n dref: [], esds: [], ftyp: [], hdlr: [],\n mdat: [], mdhd: [], mdia: [], mfhd: [],\n minf: [], moof: [], moov: [], mp4a: [],\n mvex: [], mvhd: [], sdtp: [], stbl: [],\n stco: [], stsc: [], stsd: [], stsz: [],\n stts: [], tfdt: [], tfhd: [], traf: [],\n trak: [], trun: [], trex: [], tkhd: [],\n vmhd: [], smhd: [], '.mp3': []\n };\n\n for (let name in MP4.types) {\n if (MP4.types.hasOwnProperty(name)) {\n MP4.types[name] = [\n name.charCodeAt(0),\n name.charCodeAt(1),\n name.charCodeAt(2),\n name.charCodeAt(3)\n ];\n }\n }\n\n let constants = MP4.constants = {};\n\n constants.FTYP = new Uint8Array([\n 0x69, 0x73, 0x6F, 0x6D, // major_brand: isom\n 0x0, 0x0, 0x0, 0x1, // minor_version: 0x01\n 0x69, 0x73, 0x6F, 0x6D, // isom\n 0x61, 0x76, 0x63, 0x31 // avc1\n ]);\n\n constants.STSD_PREFIX = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x01 // entry_count\n ]);\n\n constants.STTS = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00 // entry_count\n ]);\n\n constants.STSC = constants.STCO = constants.STTS;\n\n constants.STSZ = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // sample_size\n 0x00, 0x00, 0x00, 0x00 // sample_count\n ]);\n\n constants.HDLR_VIDEO = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // pre_defined\n 0x76, 0x69, 0x64, 0x65, // handler_type: 'vide'\n 0x00, 0x00, 0x00, 0x00, // reserved: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x56, 0x69, 0x64, 0x65,\n 0x6F, 0x48, 0x61, 0x6E,\n 0x64, 0x6C, 0x65, 0x72, 0x00 // name: VideoHandler\n ]);\n\n constants.HDLR_AUDIO = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // pre_defined\n 0x73, 0x6F, 0x75, 0x6E, // handler_type: 'soun'\n 0x00, 0x00, 0x00, 0x00, // reserved: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x53, 0x6F, 0x75, 0x6E,\n 0x64, 0x48, 0x61, 0x6E,\n 0x64, 0x6C, 0x65, 0x72, 0x00 // name: SoundHandler\n ]);\n\n constants.DREF = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x01, // entry_count\n 0x00, 0x00, 0x00, 0x0C, // entry_size\n 0x75, 0x72, 0x6C, 0x20, // type 'url '\n 0x00, 0x00, 0x00, 0x01 // version(0) + flags\n ]);\n\n // Sound media header\n constants.SMHD = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00 // balance(2) + reserved(2)\n ]);\n\n // video media header\n constants.VMHD = new Uint8Array([\n 0x00, 0x00, 0x00, 0x01, // version(0) + flags\n 0x00, 0x00, // graphicsmode: 2 bytes\n 0x00, 0x00, 0x00, 0x00, // opcolor: 3 * 2 bytes\n 0x00, 0x00\n ]);\n }\n\n // Generate a box\n static box(type) {\n let size = 8;\n let result = null;\n let datas = Array.prototype.slice.call(arguments, 1);\n let arrayCount = datas.length;\n\n for (let i = 0; i < arrayCount; i++) {\n size += datas[i].byteLength;\n }\n\n result = new Uint8Array(size);\n result[0] = (size >>> 24) & 0xFF; // size\n result[1] = (size >>> 16) & 0xFF;\n result[2] = (size >>> 8) & 0xFF;\n result[3] = (size) & 0xFF;\n\n result.set(type, 4); // type\n\n let offset = 8;\n for (let i = 0; i < arrayCount; i++) { // data body\n result.set(datas[i], offset);\n offset += datas[i].byteLength;\n }\n\n return result;\n }\n\n // emit ftyp & moov\n static generateInitSegment(meta) {\n let ftyp = MP4.box(MP4.types.ftyp, MP4.constants.FTYP);\n let moov = MP4.moov(meta);\n\n let result = new Uint8Array(ftyp.byteLength + moov.byteLength);\n result.set(ftyp, 0);\n result.set(moov, ftyp.byteLength);\n return result;\n }\n\n // Movie metadata box\n static moov(meta) {\n let mvhd = MP4.mvhd(meta.timescale, meta.duration);\n let trak = MP4.trak(meta);\n let mvex = MP4.mvex(meta);\n return MP4.box(MP4.types.moov, mvhd, trak, mvex);\n }\n\n // Movie header box\n static mvhd(timescale, duration) {\n return MP4.box(MP4.types.mvhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (timescale >>> 24) & 0xFF, // timescale: 4 bytes\n (timescale >>> 16) & 0xFF,\n (timescale >>> 8) & 0xFF,\n (timescale) & 0xFF,\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x00, 0x01, 0x00, 0x00, // Preferred rate: 1.0\n 0x01, 0x00, 0x00, 0x00, // PreferredVolume(1.0, 2bytes) + reserved(2bytes)\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 + 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00, // ----begin composition matrix----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x40, 0x00, 0x00, 0x00, // ----end composition matrix----\n 0x00, 0x00, 0x00, 0x00, // ----begin pre_defined 6 * 4 bytes----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, // ----end pre_defined 6 * 4 bytes----\n 0xFF, 0xFF, 0xFF, 0xFF // next_track_ID\n ]));\n }\n\n // Track box\n static trak(meta) {\n return MP4.box(MP4.types.trak, MP4.tkhd(meta), MP4.mdia(meta));\n }\n\n // Track header box\n static tkhd(meta) {\n let trackId = meta.id, duration = meta.duration;\n let width = meta.presentWidth, height = meta.presentHeight;\n\n return MP4.box(MP4.types.tkhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x07, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (trackId >>> 24) & 0xFF, // track_ID: 4 bytes\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF,\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, // layer(2bytes) + alternate_group(2bytes)\n 0x00, 0x00, 0x00, 0x00, // volume(2bytes) + reserved(2bytes)\n 0x00, 0x01, 0x00, 0x00, // ----begin composition matrix----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x40, 0x00, 0x00, 0x00, // ----end composition matrix----\n (width >>> 8) & 0xFF, // width and height\n (width) & 0xFF,\n 0x00, 0x00,\n (height >>> 8) & 0xFF,\n (height) & 0xFF,\n 0x00, 0x00\n ]));\n }\n\n // Media Box\n static mdia(meta) {\n return MP4.box(MP4.types.mdia, MP4.mdhd(meta), MP4.hdlr(meta), MP4.minf(meta));\n }\n\n // Media header box\n static mdhd(meta) {\n let timescale = meta.timescale;\n let duration = meta.duration;\n return MP4.box(MP4.types.mdhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (timescale >>> 24) & 0xFF, // timescale: 4 bytes\n (timescale >>> 16) & 0xFF,\n (timescale >>> 8) & 0xFF,\n (timescale) & 0xFF,\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x55, 0xC4, // language: und (undetermined)\n 0x00, 0x00 // pre_defined = 0\n ]));\n }\n\n // Media handler reference box\n static hdlr(meta) {\n let data = null;\n if (meta.type === 'audio') {\n data = MP4.constants.HDLR_AUDIO;\n } else {\n data = MP4.constants.HDLR_VIDEO;\n }\n return MP4.box(MP4.types.hdlr, data);\n }\n\n // Media infomation box\n static minf(meta) {\n let xmhd = null;\n if (meta.type === 'audio') {\n xmhd = MP4.box(MP4.types.smhd, MP4.constants.SMHD);\n } else {\n xmhd = MP4.box(MP4.types.vmhd, MP4.constants.VMHD);\n }\n return MP4.box(MP4.types.minf, xmhd, MP4.dinf(), MP4.stbl(meta));\n }\n\n // Data infomation box\n static dinf() {\n let result = MP4.box(MP4.types.dinf,\n MP4.box(MP4.types.dref, MP4.constants.DREF)\n );\n return result;\n }\n\n // Sample table box\n static stbl(meta) {\n let result = MP4.box(MP4.types.stbl, // type: stbl\n MP4.stsd(meta), // Sample Description Table\n MP4.box(MP4.types.stts, MP4.constants.STTS), // Time-To-Sample\n MP4.box(MP4.types.stsc, MP4.constants.STSC), // Sample-To-Chunk\n MP4.box(MP4.types.stsz, MP4.constants.STSZ), // Sample size\n MP4.box(MP4.types.stco, MP4.constants.STCO) // Chunk offset\n ); \n return result; \n }\n\n // Sample description box\n static stsd(meta) {\n if (meta.type === 'audio') {\n if (meta.codec === 'mp3') {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.mp3(meta));\n }\n // else: aac -> mp4a\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.mp4a(meta));\n } else {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.avc1(meta));\n }\n }\n\n static mp3(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types['.mp3'], data);\n }\n\n static mp4a(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types.mp4a, data, MP4.esds(meta));\n }\n\n static esds(meta) {\n let config = meta.config || [];\n let configSize = config.length;\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version 0 + flags\n\n 0x03, // descriptor_type\n 0x17 + configSize, // length3\n 0x00, 0x01, // es_id\n 0x00, // stream_priority\n\n 0x04, // descriptor_type\n 0x0F + configSize, // length\n 0x40, // codec: mpeg4_audio\n 0x15, // stream_type: Audio\n 0x00, 0x00, 0x00, // buffer_size\n 0x00, 0x00, 0x00, 0x00, // maxBitrate\n 0x00, 0x00, 0x00, 0x00, // avgBitrate\n\n 0x05 // descriptor_type\n ].concat([\n configSize\n ]).concat(\n config\n ).concat([\n 0x06, 0x01, 0x02 // GASpecificConfig\n ]));\n return MP4.box(MP4.types.esds, data);\n }\n\n static avc1(meta) {\n let avcc = meta.avcc;\n let width = meta.codecWidth, height = meta.codecHeight;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined(2) + reserved(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n (width >>> 8) & 0xFF, // width: 2 bytes\n (width) & 0xFF,\n (height >>> 8) & 0xFF, // height: 2 bytes\n (height) & 0xFF,\n 0x00, 0x48, 0x00, 0x00, // horizresolution: 4 bytes\n 0x00, 0x48, 0x00, 0x00, // vertresolution: 4 bytes\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n 0x00, 0x01, // frame_count\n 0x0A, // strlen\n 0x78, 0x71, 0x71, 0x2F, // compressorname: 32 bytes\n 0x66, 0x6C, 0x76, 0x2E,\n 0x6A, 0x73, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00,\n 0x00, 0x18, // depth\n 0xFF, 0xFF // pre_defined = -1\n ]);\n return MP4.box(MP4.types.avc1, data, MP4.box(MP4.types.avcC, avcc));\n }\n\n // Movie Extends box\n static mvex(meta) {\n return MP4.box(MP4.types.mvex, MP4.trex(meta));\n }\n\n // Track Extends box\n static trex(meta) {\n let trackId = meta.id;\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n (trackId >>> 24) & 0xFF, // track_ID\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF,\n 0x00, 0x00, 0x00, 0x01, // default_sample_description_index\n 0x00, 0x00, 0x00, 0x00, // default_sample_duration\n 0x00, 0x00, 0x00, 0x00, // default_sample_size\n 0x00, 0x01, 0x00, 0x01 // default_sample_flags\n ]);\n return MP4.box(MP4.types.trex, data);\n }\n\n // Movie fragment box\n static moof(track, baseMediaDecodeTime) {\n return MP4.box(MP4.types.moof, MP4.mfhd(track.sequenceNumber), MP4.traf(track, baseMediaDecodeTime));\n }\n\n static mfhd(sequenceNumber) {\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00,\n (sequenceNumber >>> 24) & 0xFF, // sequence_number: int32\n (sequenceNumber >>> 16) & 0xFF,\n (sequenceNumber >>> 8) & 0xFF,\n (sequenceNumber) & 0xFF\n ]);\n return MP4.box(MP4.types.mfhd, data);\n }\n\n // Track fragment box\n static traf(track, baseMediaDecodeTime) {\n let trackId = track.id;\n\n // Track fragment header box\n let tfhd = MP4.box(MP4.types.tfhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) & flags\n (trackId >>> 24) & 0xFF, // track_ID\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF\n ]));\n // Track Fragment Decode Time\n let tfdt = MP4.box(MP4.types.tfdt, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) & flags\n (baseMediaDecodeTime >>> 24) & 0xFF, // baseMediaDecodeTime: int32\n (baseMediaDecodeTime >>> 16) & 0xFF,\n (baseMediaDecodeTime >>> 8) & 0xFF,\n (baseMediaDecodeTime) & 0xFF\n ]));\n let sdtp = MP4.sdtp(track);\n let trun = MP4.trun(track, sdtp.byteLength + 16 + 16 + 8 + 16 + 8 + 8);\n\n return MP4.box(MP4.types.traf, tfhd, tfdt, trun, sdtp);\n }\n\n // Sample Dependency Type box\n static sdtp(track) {\n let samples = track.samples || [];\n let sampleCount = samples.length;\n let data = new Uint8Array(4 + sampleCount);\n // 0~4 bytes: version(0) & flags\n for (let i = 0; i < sampleCount; i++) {\n let flags = samples[i].flags;\n data[i + 4] = (flags.isLeading << 6) // is_leading: 2 (bit)\n | (flags.dependsOn << 4) // sample_depends_on\n | (flags.isDependedOn << 2) // sample_is_depended_on\n | (flags.hasRedundancy); // sample_has_redundancy\n }\n return MP4.box(MP4.types.sdtp, data);\n }\n\n // Track fragment run box\n static trun(track, offset) {\n let samples = track.samples || [];\n let sampleCount = samples.length;\n let dataSize = 12 + 16 * sampleCount;\n let data = new Uint8Array(dataSize);\n offset += 8 + dataSize;\n\n data.set([\n 0x00, 0x00, 0x0F, 0x01, // version(0) & flags\n (sampleCount >>> 24) & 0xFF, // sample_count\n (sampleCount >>> 16) & 0xFF,\n (sampleCount >>> 8) & 0xFF,\n (sampleCount) & 0xFF,\n (offset >>> 24) & 0xFF, // data_offset\n (offset >>> 16) & 0xFF,\n (offset >>> 8) & 0xFF,\n (offset) & 0xFF\n ], 0);\n\n for (let i = 0; i < sampleCount; i++) {\n let duration = samples[i].duration;\n let size = samples[i].size;\n let flags = samples[i].flags;\n let cts = samples[i].cts;\n data.set([\n (duration >>> 24) & 0xFF, // sample_duration\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n (size >>> 24) & 0xFF, // sample_size\n (size >>> 16) & 0xFF,\n (size >>> 8) & 0xFF,\n (size) & 0xFF,\n (flags.isLeading << 2) | flags.dependsOn, // sample_flags\n (flags.isDependedOn << 6) | (flags.hasRedundancy << 4) | flags.isNonSync,\n 0x00, 0x00, // sample_degradation_priority\n (cts >>> 24) & 0xFF, // sample_composition_time_offset\n (cts >>> 16) & 0xFF,\n (cts >>> 8) & 0xFF,\n (cts) & 0xFF\n ], 12 + 16 * i);\n }\n return MP4.box(MP4.types.trun, data);\n }\n\n static mdat(data) {\n return MP4.box(MP4.types.mdat, data);\n }\n\n}\n\nMP4.init();\n\nexport default MP4;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is modified from dailymotion's hls.js library (hls.js/src/helper/aac.js)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass AAC {\n\n static getSilentFrame(codec, channelCount) {\n if (codec === 'mp4a.40.2') {\n // handle LC-AAC\n if (channelCount === 1) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x23, 0x80]);\n } else if (channelCount === 2) {\n return new Uint8Array([0x21, 0x00, 0x49, 0x90, 0x02, 0x19, 0x00, 0x23, 0x80]);\n } else if (channelCount === 3) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x8e]);\n } else if (channelCount === 4) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x80, 0x2c, 0x80, 0x08, 0x02, 0x38]);\n } else if (channelCount === 5) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x82, 0x30, 0x04, 0x99, 0x00, 0x21, 0x90, 0x02, 0x38]);\n } else if (channelCount === 6) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x82, 0x30, 0x04, 0x99, 0x00, 0x21, 0x90, 0x02, 0x00, 0xb2, 0x00, 0x20, 0x08, 0xe0]);\n }\n } else {\n // handle HE-AAC (mp4a.40.5 / mp4a.40.29)\n if (channelCount === 1) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0:d=0.05\" -c:a libfdk_aac -profile:a aac_he -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x4e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x1c, 0x6, 0xf1, 0xc1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n } else if (channelCount === 2) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0|0:d=0.05\" -c:a libfdk_aac -profile:a aac_he_v2 -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x5e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x0, 0x95, 0x0, 0x6, 0xf1, 0xa1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n } else if (channelCount === 3) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0|0|0:d=0.05\" -c:a libfdk_aac -profile:a aac_he_v2 -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x5e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x0, 0x95, 0x0, 0x6, 0xf1, 0xa1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n }\n }\n return null;\n }\n\n}\n\nexport default AAC;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport MP4 from './mp4-generator.js';\nimport AAC from './aac-silent.js';\nimport Browser from '../utils/browser.js';\nimport { SampleInfo, MediaSegmentInfo, MediaSegmentInfoList } from '../core/media-segment-info.js';\nimport { IllegalStateException } from '../utils/exception.js';\n\n\n// Fragmented mp4 remuxer\nclass MP4Remuxer {\n\n constructor(config) {\n this.TAG = 'MP4Remuxer';\n\n this._config = config;\n this._isLive = (config.isLive === true) ? true : false;\n\n this._dtsBase = -1;\n this._dtsBaseInited = false;\n this._audioDtsBase = Infinity;\n this._videoDtsBase = Infinity;\n this._audioNextDts = undefined;\n this._videoNextDts = undefined;\n this._audioStashedLastSample = null;\n this._videoStashedLastSample = null;\n\n this._audioMeta = null;\n this._videoMeta = null;\n\n this._audioSegmentInfoList = new MediaSegmentInfoList('audio');\n this._videoSegmentInfoList = new MediaSegmentInfoList('video');\n\n this._onInitSegment = null;\n this._onMediaSegment = null;\n\n // Workaround for chrome < 50: Always force first sample as a Random Access Point in media segment\n // see https://bugs.chromium.org/p/chromium/issues/detail?id=229412\n this._forceFirstIDR = (Browser.chrome &&\n (Browser.version.major < 50 ||\n (Browser.version.major === 50 && Browser.version.build < 2661))) ? true : false;\n\n // Workaround for IE11/Edge: Fill silent aac frame after keyframe-seeking\n // Make audio beginDts equals with video beginDts, in order to fix seek freeze\n this._fillSilentAfterSeek = (Browser.msedge || Browser.msie);\n\n // While only FireFox supports 'audio/mp4, codecs=\"mp3\"', use 'audio/mpeg' for chrome, safari, ...\n this._mp3UseMpegAudio = !Browser.firefox;\n\n this._fillAudioTimestampGap = this._config.fixAudioTimestampGap;\n }\n\n destroy() {\n this._dtsBase = -1;\n this._dtsBaseInited = false;\n this._audioMeta = null;\n this._videoMeta = null;\n this._audioSegmentInfoList.clear();\n this._audioSegmentInfoList = null;\n this._videoSegmentInfoList.clear();\n this._videoSegmentInfoList = null;\n this._onInitSegment = null;\n this._onMediaSegment = null;\n }\n\n bindDataSource(producer) {\n producer.onDataAvailable = this.remux.bind(this);\n producer.onTrackMetadata = this._onTrackMetadataReceived.bind(this);\n return this;\n }\n\n /* prototype: function onInitSegment(type: string, initSegment: ArrayBuffer): void\n InitSegment: {\n type: string,\n data: ArrayBuffer,\n codec: string,\n container: string\n }\n */\n get onInitSegment() {\n return this._onInitSegment;\n }\n\n set onInitSegment(callback) {\n this._onInitSegment = callback;\n }\n\n /* prototype: function onMediaSegment(type: string, mediaSegment: MediaSegment): void\n MediaSegment: {\n type: string,\n data: ArrayBuffer,\n sampleCount: int32\n info: MediaSegmentInfo\n }\n */\n get onMediaSegment() {\n return this._onMediaSegment;\n }\n\n set onMediaSegment(callback) {\n this._onMediaSegment = callback;\n }\n\n insertDiscontinuity() {\n this._audioNextDts = this._videoNextDts = undefined;\n }\n\n seek(originalDts) {\n this._audioStashedLastSample = null;\n this._videoStashedLastSample = null;\n this._videoSegmentInfoList.clear();\n this._audioSegmentInfoList.clear();\n }\n\n remux(audioTrack, videoTrack) {\n if (!this._onMediaSegment) {\n throw new IllegalStateException('MP4Remuxer: onMediaSegment callback must be specificed!');\n }\n if (!this._dtsBaseInited) {\n this._calculateDtsBase(audioTrack, videoTrack);\n }\n if (videoTrack) {\n this._remuxVideo(videoTrack);\n }\n if (audioTrack) {\n this._remuxAudio(audioTrack);\n }\n }\n\n _onTrackMetadataReceived(type, metadata) {\n let metabox = null;\n\n let container = 'mp4';\n let codec = metadata.codec;\n\n if (type === 'audio') {\n this._audioMeta = metadata;\n if (metadata.codec === 'mp3' && this._mp3UseMpegAudio) {\n // 'audio/mpeg' for MP3 audio track\n container = 'mpeg';\n codec = '';\n metabox = new Uint8Array();\n } else {\n // 'audio/mp4, codecs=\"codec\"'\n metabox = MP4.generateInitSegment(metadata);\n }\n } else if (type === 'video') {\n this._videoMeta = metadata;\n metabox = MP4.generateInitSegment(metadata);\n } else {\n return;\n }\n\n // dispatch metabox (Initialization Segment)\n if (!this._onInitSegment) {\n throw new IllegalStateException('MP4Remuxer: onInitSegment callback must be specified!');\n }\n this._onInitSegment(type, {\n type: type,\n data: metabox.buffer,\n codec: codec,\n container: `${type}/${container}`,\n mediaDuration: metadata.duration // in timescale 1000 (milliseconds)\n });\n }\n\n _calculateDtsBase(audioTrack, videoTrack) {\n if (this._dtsBaseInited) {\n return;\n }\n\n if (audioTrack && audioTrack.samples && audioTrack.samples.length) {\n this._audioDtsBase = audioTrack.samples[0].dts;\n }\n if (videoTrack && videoTrack.samples && videoTrack.samples.length) {\n this._videoDtsBase = videoTrack.samples[0].dts;\n }\n\n this._dtsBase = Math.min(this._audioDtsBase, this._videoDtsBase);\n this._dtsBaseInited = true;\n }\n\n getTimestampBase() {\n if (!this._dtsBaseInited) {\n return undefined;\n }\n return this._dtsBase;\n }\n\n flushStashedSamples() {\n let videoSample = this._videoStashedLastSample;\n let audioSample = this._audioStashedLastSample;\n\n let videoTrack = {\n type: 'video',\n id: 1,\n sequenceNumber: 0,\n samples: [],\n length: 0\n };\n\n if (videoSample != null) {\n videoTrack.samples.push(videoSample);\n videoTrack.length = videoSample.length;\n }\n\n let audioTrack = {\n type: 'audio',\n id: 2,\n sequenceNumber: 0,\n samples: [],\n length: 0\n };\n\n if (audioSample != null) {\n audioTrack.samples.push(audioSample);\n audioTrack.length = audioSample.length;\n }\n\n this._videoStashedLastSample = null;\n this._audioStashedLastSample = null;\n\n this._remuxVideo(videoTrack, true);\n this._remuxAudio(audioTrack, true);\n }\n\n _remuxAudio(audioTrack, force) {\n if (this._audioMeta == null) {\n return;\n }\n\n let track = audioTrack;\n let samples = track.samples;\n let dtsCorrection = undefined;\n let firstDts = -1, lastDts = -1, lastPts = -1;\n let refSampleDuration = this._audioMeta.refSampleDuration;\n\n let mpegRawTrack = this._audioMeta.codec === 'mp3' && this._mp3UseMpegAudio;\n let firstSegmentAfterSeek = this._dtsBaseInited && this._audioNextDts === undefined;\n\n let insertPrefixSilentFrame = false;\n\n if (!samples || samples.length === 0) {\n return;\n }\n if (samples.length === 1 && !force) {\n // If [sample count in current batch] === 1 && (force != true)\n // Ignore and keep in demuxer's queue\n return;\n } // else if (force === true) do remux\n\n let offset = 0;\n let mdatbox = null;\n let mdatBytes = 0;\n\n // calculate initial mdat size\n if (mpegRawTrack) {\n // for raw mpeg buffer\n offset = 0;\n mdatBytes = track.length;\n } else {\n // for fmp4 mdat box\n offset = 8; // size + type\n mdatBytes = 8 + track.length;\n }\n\n\n let lastSample = null;\n\n // Pop the lastSample and waiting for stash\n if (samples.length > 1) {\n lastSample = samples.pop();\n mdatBytes -= lastSample.length;\n }\n\n // Insert [stashed lastSample in the previous batch] to the front\n if (this._audioStashedLastSample != null) {\n let sample = this._audioStashedLastSample;\n this._audioStashedLastSample = null;\n samples.unshift(sample);\n mdatBytes += sample.length;\n }\n\n // Stash the lastSample of current batch, waiting for next batch\n if (lastSample != null) {\n this._audioStashedLastSample = lastSample;\n }\n\n\n let firstSampleOriginalDts = samples[0].dts - this._dtsBase;\n\n // calculate dtsCorrection\n if (this._audioNextDts) {\n dtsCorrection = firstSampleOriginalDts - this._audioNextDts;\n } else { // this._audioNextDts == undefined\n if (this._audioSegmentInfoList.isEmpty()) {\n dtsCorrection = 0;\n if (this._fillSilentAfterSeek && !this._videoSegmentInfoList.isEmpty()) {\n if (this._audioMeta.originalCodec !== 'mp3') {\n insertPrefixSilentFrame = true;\n }\n }\n } else {\n let lastSample = this._audioSegmentInfoList.getLastSampleBefore(firstSampleOriginalDts);\n if (lastSample != null) {\n let distance = (firstSampleOriginalDts - (lastSample.originalDts + lastSample.duration));\n if (distance <= 3) {\n distance = 0;\n }\n let expectedDts = lastSample.dts + lastSample.duration + distance;\n dtsCorrection = firstSampleOriginalDts - expectedDts;\n } else { // lastSample == null, cannot found\n dtsCorrection = 0;\n }\n }\n }\n\n if (insertPrefixSilentFrame) {\n // align audio segment beginDts to match with current video segment's beginDts\n let firstSampleDts = firstSampleOriginalDts - dtsCorrection;\n let videoSegment = this._videoSegmentInfoList.getLastSegmentBefore(firstSampleOriginalDts);\n if (videoSegment != null && videoSegment.beginDts < firstSampleDts) {\n let silentUnit = AAC.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);\n if (silentUnit) {\n let dts = videoSegment.beginDts;\n let silentFrameDuration = firstSampleDts - videoSegment.beginDts;\n Log.v(this.TAG, `InsertPrefixSilentAudio: dts: ${dts}, duration: ${silentFrameDuration}`);\n samples.unshift({ unit: silentUnit, dts: dts, pts: dts });\n mdatBytes += silentUnit.byteLength;\n } // silentUnit == null: Cannot generate, skip\n } else {\n insertPrefixSilentFrame = false;\n }\n }\n\n let mp4Samples = [];\n\n // Correct dts for each sample, and calculate sample duration. Then output to mp4Samples\n for (let i = 0; i < samples.length; i++) {\n let sample = samples[i];\n let unit = sample.unit;\n let originalDts = sample.dts - this._dtsBase;\n let dts = originalDts;\n let needFillSilentFrames = false;\n let silentFrames = null;\n let sampleDuration = 0;\n\n if (originalDts < -0.001) {\n continue; //pass the first sample with the invalid dts\n }\n\n if (this._audioMeta.codec !== 'mp3') {\n // for AAC codec, we need to keep dts increase based on refSampleDuration\n let curRefDts = originalDts;\n const maxAudioFramesDrift = 3;\n if (this._audioNextDts) {\n curRefDts = this._audioNextDts;\n }\n\n dtsCorrection = originalDts - curRefDts;\n if (dtsCorrection <= -maxAudioFramesDrift * refSampleDuration) {\n // If we're overlapping by more than maxAudioFramesDrift number of frame, drop this sample\n Log.w(this.TAG, `Dropping 1 audio frame (originalDts: ${originalDts} ms ,curRefDts: ${curRefDts} ms) due to dtsCorrection: ${dtsCorrection} ms overlap.`);\n continue;\n }\n else if (dtsCorrection >= maxAudioFramesDrift * refSampleDuration && this._fillAudioTimestampGap && !Browser.safari) {\n // Silent frame generation, if large timestamp gap detected && config.fixAudioTimestampGap\n needFillSilentFrames = true;\n // We need to insert silent frames to fill timestamp gap\n let frameCount = Math.floor(dtsCorrection / refSampleDuration);\n Log.w(this.TAG, 'Large audio timestamp gap detected, may cause AV sync to drift. ' +\n 'Silent frames will be generated to avoid unsync.\\n' +\n `originalDts: ${originalDts} ms, curRefDts: ${curRefDts} ms, ` +\n `dtsCorrection: ${Math.round(dtsCorrection)} ms, generate: ${frameCount} frames`);\n\n\n dts = Math.floor(curRefDts);\n sampleDuration = Math.floor(curRefDts + refSampleDuration) - dts;\n\n let silentUnit = AAC.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);\n if (silentUnit == null) {\n Log.w(this.TAG, 'Unable to generate silent frame for ' +\n `${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`);\n // Repeat last frame\n silentUnit = unit;\n }\n silentFrames = [];\n\n for (let j = 0; j < frameCount; j++) {\n curRefDts = curRefDts + refSampleDuration;\n let intDts = Math.floor(curRefDts); // change to integer\n let intDuration = Math.floor(curRefDts + refSampleDuration) - intDts;\n let frame = {\n dts: intDts,\n pts: intDts,\n cts: 0,\n unit: silentUnit,\n size: silentUnit.byteLength,\n duration: intDuration, // wait for next sample\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: 1,\n isDependedOn: 0,\n hasRedundancy: 0\n }\n };\n silentFrames.push(frame);\n mdatBytes += frame.size;;\n\n }\n\n this._audioNextDts = curRefDts + refSampleDuration;\n\n } else {\n\n dts = Math.floor(curRefDts);\n sampleDuration = Math.floor(curRefDts + refSampleDuration) - dts;\n this._audioNextDts = curRefDts + refSampleDuration;\n\n }\n } else {\n // keep the original dts calculate algorithm for mp3\n dts = originalDts - dtsCorrection;\n\n\n if (i !== samples.length - 1) {\n let nextDts = samples[i + 1].dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else { // the last sample\n if (lastSample != null) { // use stashed sample's dts to calculate sample duration\n let nextDts = lastSample.dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else if (mp4Samples.length >= 1) { // use second last sample duration\n sampleDuration = mp4Samples[mp4Samples.length - 1].duration;\n } else { // the only one sample, use reference sample duration\n sampleDuration = Math.floor(refSampleDuration);\n }\n }\n this._audioNextDts = dts + sampleDuration;\n }\n\n if (firstDts === -1) {\n firstDts = dts;\n }\n mp4Samples.push({\n dts: dts,\n pts: dts,\n cts: 0,\n unit: sample.unit,\n size: sample.unit.byteLength,\n duration: sampleDuration,\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: 1,\n isDependedOn: 0,\n hasRedundancy: 0\n }\n });\n\n if (needFillSilentFrames) {\n // Silent frames should be inserted after wrong-duration frame\n mp4Samples.push.apply(mp4Samples, silentFrames);\n }\n }\n\n if (mp4Samples.length === 0) {\n //no samples need to remux\n track.samples = [];\n track.length = 0;\n return;\n }\n\n // allocate mdatbox\n if (mpegRawTrack) {\n // allocate for raw mpeg buffer\n mdatbox = new Uint8Array(mdatBytes);\n } else {\n // allocate for fmp4 mdat box\n mdatbox = new Uint8Array(mdatBytes);\n // size field\n mdatbox[0] = (mdatBytes >>> 24) & 0xFF;\n mdatbox[1] = (mdatBytes >>> 16) & 0xFF;\n mdatbox[2] = (mdatBytes >>> 8) & 0xFF;\n mdatbox[3] = (mdatBytes) & 0xFF;\n // type field (fourCC)\n mdatbox.set(MP4.types.mdat, 4);\n }\n\n // Write samples into mdatbox\n for (let i = 0; i < mp4Samples.length; i++) {\n let unit = mp4Samples[i].unit;\n mdatbox.set(unit, offset);\n offset += unit.byteLength;\n }\n\n let latest = mp4Samples[mp4Samples.length - 1];\n lastDts = latest.dts + latest.duration;\n //this._audioNextDts = lastDts;\n\n // fill media segment info & add to info list\n let info = new MediaSegmentInfo();\n info.beginDts = firstDts;\n info.endDts = lastDts;\n info.beginPts = firstDts;\n info.endPts = lastDts;\n info.originalBeginDts = mp4Samples[0].originalDts;\n info.originalEndDts = latest.originalDts + latest.duration;\n info.firstSample = new SampleInfo(mp4Samples[0].dts,\n mp4Samples[0].pts,\n mp4Samples[0].duration,\n mp4Samples[0].originalDts,\n false);\n info.lastSample = new SampleInfo(latest.dts,\n latest.pts,\n latest.duration,\n latest.originalDts,\n false);\n if (!this._isLive) {\n this._audioSegmentInfoList.append(info);\n }\n\n track.samples = mp4Samples;\n track.sequenceNumber++;\n\n let moofbox = null;\n\n if (mpegRawTrack) {\n // Generate empty buffer, because useless for raw mpeg\n moofbox = new Uint8Array();\n } else {\n // Generate moof for fmp4 segment\n moofbox = MP4.moof(track, firstDts);\n }\n\n track.samples = [];\n track.length = 0;\n\n let segment = {\n type: 'audio',\n data: this._mergeBoxes(moofbox, mdatbox).buffer,\n sampleCount: mp4Samples.length,\n info: info\n };\n\n if (mpegRawTrack && firstSegmentAfterSeek) {\n // For MPEG audio stream in MSE, if seeking occurred, before appending new buffer\n // We need explicitly set timestampOffset to the desired point in timeline for mpeg SourceBuffer.\n segment.timestampOffset = firstDts;\n }\n\n this._onMediaSegment('audio', segment);\n }\n\n _remuxVideo(videoTrack, force) {\n if (this._videoMeta == null) {\n return;\n }\n\n let track = videoTrack;\n let samples = track.samples;\n let dtsCorrection = undefined;\n let firstDts = -1, lastDts = -1;\n let firstPts = -1, lastPts = -1;\n\n if (!samples || samples.length === 0) {\n return;\n }\n if (samples.length === 1 && !force) {\n // If [sample count in current batch] === 1 && (force != true)\n // Ignore and keep in demuxer's queue\n return;\n } // else if (force === true) do remux\n\n let offset = 8;\n let mdatbox = null;\n let mdatBytes = 8 + videoTrack.length;\n\n\n let lastSample = null;\n\n // Pop the lastSample and waiting for stash\n if (samples.length > 1) {\n lastSample = samples.pop();\n mdatBytes -= lastSample.length;\n }\n\n // Insert [stashed lastSample in the previous batch] to the front\n if (this._videoStashedLastSample != null) {\n let sample = this._videoStashedLastSample;\n this._videoStashedLastSample = null;\n samples.unshift(sample);\n mdatBytes += sample.length;\n }\n\n // Stash the lastSample of current batch, waiting for next batch\n if (lastSample != null) {\n this._videoStashedLastSample = lastSample;\n }\n\n\n let firstSampleOriginalDts = samples[0].dts - this._dtsBase;\n\n // calculate dtsCorrection\n if (this._videoNextDts) {\n dtsCorrection = firstSampleOriginalDts - this._videoNextDts;\n } else { // this._videoNextDts == undefined\n if (this._videoSegmentInfoList.isEmpty()) {\n dtsCorrection = 0;\n } else {\n let lastSample = this._videoSegmentInfoList.getLastSampleBefore(firstSampleOriginalDts);\n if (lastSample != null) {\n let distance = (firstSampleOriginalDts - (lastSample.originalDts + lastSample.duration));\n if (distance <= 3) {\n distance = 0;\n }\n let expectedDts = lastSample.dts + lastSample.duration + distance;\n dtsCorrection = firstSampleOriginalDts - expectedDts;\n } else { // lastSample == null, cannot found\n dtsCorrection = 0;\n }\n }\n }\n\n let info = new MediaSegmentInfo();\n let mp4Samples = [];\n\n // Correct dts for each sample, and calculate sample duration. Then output to mp4Samples\n for (let i = 0; i < samples.length; i++) {\n let sample = samples[i];\n let originalDts = sample.dts - this._dtsBase;\n let isKeyframe = sample.isKeyframe;\n let dts = originalDts - dtsCorrection;\n let cts = sample.cts;\n let pts = dts + cts;\n\n if (firstDts === -1) {\n firstDts = dts;\n firstPts = pts;\n }\n\n let sampleDuration = 0;\n\n if (i !== samples.length - 1) {\n let nextDts = samples[i + 1].dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else { // the last sample\n if (lastSample != null) { // use stashed sample's dts to calculate sample duration\n let nextDts = lastSample.dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else if (mp4Samples.length >= 1) { // use second last sample duration\n sampleDuration = mp4Samples[mp4Samples.length - 1].duration;\n } else { // the only one sample, use reference sample duration\n sampleDuration = Math.floor(this._videoMeta.refSampleDuration);\n }\n }\n\n if (isKeyframe) {\n let syncPoint = new SampleInfo(dts, pts, sampleDuration, sample.dts, true);\n syncPoint.fileposition = sample.fileposition;\n info.appendSyncPoint(syncPoint);\n }\n\n mp4Samples.push({\n dts: dts,\n pts: pts,\n cts: cts,\n units: sample.units,\n size: sample.length,\n isKeyframe: isKeyframe,\n duration: sampleDuration,\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: isKeyframe ? 2 : 1,\n isDependedOn: isKeyframe ? 1 : 0,\n hasRedundancy: 0,\n isNonSync: isKeyframe ? 0 : 1\n }\n });\n }\n\n // allocate mdatbox\n mdatbox = new Uint8Array(mdatBytes);\n mdatbox[0] = (mdatBytes >>> 24) & 0xFF;\n mdatbox[1] = (mdatBytes >>> 16) & 0xFF;\n mdatbox[2] = (mdatBytes >>> 8) & 0xFF;\n mdatbox[3] = (mdatBytes) & 0xFF;\n mdatbox.set(MP4.types.mdat, 4);\n\n // Write samples into mdatbox\n for (let i = 0; i < mp4Samples.length; i++) {\n let units = mp4Samples[i].units;\n while (units.length) {\n let unit = units.shift();\n let data = unit.data;\n mdatbox.set(data, offset);\n offset += data.byteLength;\n }\n }\n\n let latest = mp4Samples[mp4Samples.length - 1];\n lastDts = latest.dts + latest.duration;\n lastPts = latest.pts + latest.duration;\n this._videoNextDts = lastDts;\n\n // fill media segment info & add to info list\n info.beginDts = firstDts;\n info.endDts = lastDts;\n info.beginPts = firstPts;\n info.endPts = lastPts;\n info.originalBeginDts = mp4Samples[0].originalDts;\n info.originalEndDts = latest.originalDts + latest.duration;\n info.firstSample = new SampleInfo(mp4Samples[0].dts,\n mp4Samples[0].pts,\n mp4Samples[0].duration,\n mp4Samples[0].originalDts,\n mp4Samples[0].isKeyframe);\n info.lastSample = new SampleInfo(latest.dts,\n latest.pts,\n latest.duration,\n latest.originalDts,\n latest.isKeyframe);\n if (!this._isLive) {\n this._videoSegmentInfoList.append(info);\n }\n\n track.samples = mp4Samples;\n track.sequenceNumber++;\n\n // workaround for chrome < 50: force first sample as a random access point\n // see https://bugs.chromium.org/p/chromium/issues/detail?id=229412\n if (this._forceFirstIDR) {\n let flags = mp4Samples[0].flags;\n flags.dependsOn = 2;\n flags.isNonSync = 0;\n }\n\n let moofbox = MP4.moof(track, firstDts);\n track.samples = [];\n track.length = 0;\n\n this._onMediaSegment('video', {\n type: 'video',\n data: this._mergeBoxes(moofbox, mdatbox).buffer,\n sampleCount: mp4Samples.length,\n info: info\n });\n }\n\n _mergeBoxes(moof, mdat) {\n let result = new Uint8Array(moof.byteLength + mdat.byteLength);\n result.set(moof, 0);\n result.set(mdat, moof.byteLength);\n return result;\n }\n\n}\n\nexport default MP4Remuxer;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport MediaInfo from './media-info.js';\nimport FLVDemuxer from '../demux/flv-demuxer.js';\nimport TSDemuxer from '../demux/ts-demuxer';\nimport MP4Remuxer from '../remux/mp4-remuxer.js';\nimport DemuxErrors from '../demux/demux-errors.js';\nimport IOController from '../io/io-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\nimport {LoaderStatus, LoaderErrors} from '../io/loader.js';\n\n// Transmuxing (IO, Demuxing, Remuxing) controller, with multipart support\nclass TransmuxingController {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'TransmuxingController';\n this._emitter = new EventEmitter();\n\n this._config = config;\n\n // treat single part media as multipart media, which has only one segment\n if (!mediaDataSource.segments) {\n mediaDataSource.segments = [{\n duration: mediaDataSource.duration,\n filesize: mediaDataSource.filesize,\n url: mediaDataSource.url\n }];\n }\n\n // fill in default IO params if not exists\n if (typeof mediaDataSource.cors !== 'boolean') {\n mediaDataSource.cors = true;\n }\n if (typeof mediaDataSource.withCredentials !== 'boolean') {\n mediaDataSource.withCredentials = false;\n }\n\n this._mediaDataSource = mediaDataSource;\n this._currentSegmentIndex = 0;\n let totalDuration = 0;\n\n this._mediaDataSource.segments.forEach((segment) => {\n // timestampBase for each segment, and calculate total duration\n segment.timestampBase = totalDuration;\n totalDuration += segment.duration;\n // params needed by IOController\n segment.cors = mediaDataSource.cors;\n segment.withCredentials = mediaDataSource.withCredentials;\n // referrer policy control, if exist\n if (config.referrerPolicy) {\n segment.referrerPolicy = config.referrerPolicy;\n }\n });\n\n if (!isNaN(totalDuration) && this._mediaDataSource.duration !== totalDuration) {\n this._mediaDataSource.duration = totalDuration;\n }\n\n this._mediaInfo = null;\n this._demuxer = null;\n this._remuxer = null;\n this._ioctl = null;\n\n this._pendingSeekTime = null;\n this._pendingResolveSeekPoint = null;\n\n this._statisticsReporter = null;\n }\n\n destroy() {\n this._mediaInfo = null;\n this._mediaDataSource = null;\n\n if (this._statisticsReporter) {\n this._disableStatisticsReporter();\n }\n if (this._ioctl) {\n this._ioctl.destroy();\n this._ioctl = null;\n }\n if (this._demuxer) {\n this._demuxer.destroy();\n this._demuxer = null;\n }\n if (this._remuxer) {\n this._remuxer.destroy();\n this._remuxer = null;\n }\n\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n start() {\n this._loadSegment(0);\n this._enableStatisticsReporter();\n }\n\n _loadSegment(segmentIndex, optionalFrom) {\n this._currentSegmentIndex = segmentIndex;\n let dataSource = this._mediaDataSource.segments[segmentIndex];\n\n let ioctl = this._ioctl = new IOController(dataSource, this._config, segmentIndex);\n ioctl.onError = this._onIOException.bind(this);\n ioctl.onSeeked = this._onIOSeeked.bind(this);\n ioctl.onComplete = this._onIOComplete.bind(this);\n ioctl.onRedirect = this._onIORedirect.bind(this);\n ioctl.onRecoveredEarlyEof = this._onIORecoveredEarlyEof.bind(this);\n\n if (optionalFrom) {\n this._demuxer.bindDataSource(this._ioctl);\n } else {\n ioctl.onDataArrival = this._onInitChunkArrival.bind(this);\n }\n\n ioctl.open(optionalFrom);\n }\n\n stop() {\n this._internalAbort();\n this._disableStatisticsReporter();\n }\n\n _internalAbort() {\n if (this._ioctl) {\n this._ioctl.destroy();\n this._ioctl = null;\n }\n }\n\n pause() { // take a rest\n if (this._ioctl && this._ioctl.isWorking()) {\n this._ioctl.pause();\n this._disableStatisticsReporter();\n }\n }\n\n resume() {\n if (this._ioctl && this._ioctl.isPaused()) {\n this._ioctl.resume();\n this._enableStatisticsReporter();\n }\n }\n\n seek(milliseconds) {\n if (this._mediaInfo == null || !this._mediaInfo.isSeekable()) {\n return;\n }\n\n let targetSegmentIndex = this._searchSegmentIndexContains(milliseconds);\n\n if (targetSegmentIndex === this._currentSegmentIndex) {\n // intra-segment seeking\n let segmentInfo = this._mediaInfo.segments[targetSegmentIndex];\n\n if (segmentInfo == undefined) {\n // current segment loading started, but mediainfo hasn't received yet\n // wait for the metadata loaded, then seek to expected position\n this._pendingSeekTime = milliseconds;\n } else {\n let keyframe = segmentInfo.getNearestKeyframe(milliseconds);\n this._remuxer.seek(keyframe.milliseconds);\n this._ioctl.seek(keyframe.fileposition);\n // Will be resolved in _onRemuxerMediaSegmentArrival()\n this._pendingResolveSeekPoint = keyframe.milliseconds;\n }\n } else {\n // cross-segment seeking\n let targetSegmentInfo = this._mediaInfo.segments[targetSegmentIndex];\n\n if (targetSegmentInfo == undefined) {\n // target segment hasn't been loaded. We need metadata then seek to expected time\n this._pendingSeekTime = milliseconds;\n this._internalAbort();\n this._remuxer.seek();\n this._remuxer.insertDiscontinuity();\n this._loadSegment(targetSegmentIndex);\n // Here we wait for the metadata loaded, then seek to expected position\n } else {\n // We have target segment's metadata, direct seek to target position\n let keyframe = targetSegmentInfo.getNearestKeyframe(milliseconds);\n this._internalAbort();\n this._remuxer.seek(milliseconds);\n this._remuxer.insertDiscontinuity();\n this._demuxer.resetMediaInfo();\n this._demuxer.timestampBase = this._mediaDataSource.segments[targetSegmentIndex].timestampBase;\n this._loadSegment(targetSegmentIndex, keyframe.fileposition);\n this._pendingResolveSeekPoint = keyframe.milliseconds;\n this._reportSegmentMediaInfo(targetSegmentIndex);\n }\n }\n\n this._enableStatisticsReporter();\n }\n\n _searchSegmentIndexContains(milliseconds) {\n let segments = this._mediaDataSource.segments;\n let idx = segments.length - 1;\n\n for (let i = 0; i < segments.length; i++) {\n if (milliseconds < segments[i].timestampBase) {\n idx = i - 1;\n break;\n }\n }\n return idx;\n }\n\n _onInitChunkArrival(data, byteStart) {\n let probeData = null;\n let consumed = 0;\n\n if (byteStart > 0) {\n // IOController seeked immediately after opened, byteStart > 0 callback may received\n this._demuxer.bindDataSource(this._ioctl);\n this._demuxer.timestampBase = this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase;\n\n consumed = this._demuxer.parseChunks(data, byteStart);\n } else if ((probeData = TSDemuxer.probe(data)).match) {\n let demuxer = this._demuxer = new TSDemuxer(probeData, this._config);\n\n if (!this._remuxer) {\n this._remuxer = new MP4Remuxer(this._config);\n }\n\n demuxer.onError = this._onDemuxException.bind(this);\n demuxer.onMediaInfo = this._onMediaInfo.bind(this);\n demuxer.onMetaDataArrived = this._onMetaDataArrived.bind(this);\n demuxer.onTimedID3Metadata = this._onTimedID3Metadata.bind(this);\n demuxer.onPESPrivateDataDescriptor = this._onPESPrivateDataDescriptor.bind(this);\n demuxer.onPESPrivateData = this._onPESPrivateData.bind(this);\n\n this._remuxer.bindDataSource(this._demuxer);\n this._demuxer.bindDataSource(this._ioctl);\n\n this._remuxer.onInitSegment = this._onRemuxerInitSegmentArrival.bind(this);\n this._remuxer.onMediaSegment = this._onRemuxerMediaSegmentArrival.bind(this);\n\n consumed = this._demuxer.parseChunks(data, byteStart);\n } else if ((probeData = FLVDemuxer.probe(data)).match) {\n // Always create new FLVDemuxer\n this._demuxer = new FLVDemuxer(probeData, this._config);\n\n if (!this._remuxer) {\n this._remuxer = new MP4Remuxer(this._config);\n }\n\n let mds = this._mediaDataSource;\n if (mds.duration != undefined && !isNaN(mds.duration)) {\n this._demuxer.overridedDuration = mds.duration;\n }\n if (typeof mds.hasAudio === 'boolean') {\n this._demuxer.overridedHasAudio = mds.hasAudio;\n }\n if (typeof mds.hasVideo === 'boolean') {\n this._demuxer.overridedHasVideo = mds.hasVideo;\n }\n\n this._demuxer.timestampBase = mds.segments[this._currentSegmentIndex].timestampBase;\n\n this._demuxer.onError = this._onDemuxException.bind(this);\n this._demuxer.onMediaInfo = this._onMediaInfo.bind(this);\n this._demuxer.onMetaDataArrived = this._onMetaDataArrived.bind(this);\n this._demuxer.onScriptDataArrived = this._onScriptDataArrived.bind(this);\n\n this._remuxer.bindDataSource(this._demuxer\n .bindDataSource(this._ioctl\n ));\n\n this._remuxer.onInitSegment = this._onRemuxerInitSegmentArrival.bind(this);\n this._remuxer.onMediaSegment = this._onRemuxerMediaSegmentArrival.bind(this);\n\n consumed = this._demuxer.parseChunks(data, byteStart);\n } else {\n probeData = null;\n Log.e(this.TAG, 'Non MPEG-TS/FLV, Unsupported media type!');\n Promise.resolve().then(() => {\n this._internalAbort();\n });\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, DemuxErrors.FORMAT_UNSUPPORTED, 'Non MPEG-TS/FLV, Unsupported media type!');\n\n consumed = 0;\n }\n\n return consumed;\n }\n\n _onMediaInfo(mediaInfo) {\n if (this._mediaInfo == null) {\n // Store first segment's mediainfo as global mediaInfo\n this._mediaInfo = Object.assign({}, mediaInfo);\n this._mediaInfo.keyframesIndex = null;\n this._mediaInfo.segments = [];\n this._mediaInfo.segmentCount = this._mediaDataSource.segments.length;\n Object.setPrototypeOf(this._mediaInfo, MediaInfo.prototype);\n }\n\n let segmentInfo = Object.assign({}, mediaInfo);\n Object.setPrototypeOf(segmentInfo, MediaInfo.prototype);\n this._mediaInfo.segments[this._currentSegmentIndex] = segmentInfo;\n\n // notify mediaInfo update\n this._reportSegmentMediaInfo(this._currentSegmentIndex);\n\n if (this._pendingSeekTime != null) {\n Promise.resolve().then(() => {\n let target = this._pendingSeekTime;\n this._pendingSeekTime = null;\n this.seek(target);\n });\n }\n }\n\n _onMetaDataArrived(metadata) {\n this._emitter.emit(TransmuxingEvents.METADATA_ARRIVED, metadata);\n }\n\n _onScriptDataArrived(data) {\n this._emitter.emit(TransmuxingEvents.SCRIPTDATA_ARRIVED, data);\n }\n\n _onTimedID3Metadata(timed_id3_metadata) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (timed_id3_metadata.pts != undefined) {\n timed_id3_metadata.pts -= timestamp_base;\n }\n\n if (timed_id3_metadata.dts != undefined) {\n timed_id3_metadata.dts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, timed_id3_metadata);\n }\n\n _onPESPrivateDataDescriptor(descriptor) {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, descriptor);\n }\n\n _onPESPrivateData(private_data) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (private_data.pts != undefined) {\n private_data.pts -= timestamp_base;\n }\n\n if (private_data.nearest_pts != undefined) {\n private_data.nearest_pts -= timestamp_base;\n }\n\n if (private_data.dts != undefined) {\n private_data.dts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, private_data);\n }\n\n _onIOSeeked() {\n this._remuxer.insertDiscontinuity();\n }\n\n _onIOComplete(extraData) {\n let segmentIndex = extraData;\n let nextSegmentIndex = segmentIndex + 1;\n\n if (nextSegmentIndex < this._mediaDataSource.segments.length) {\n this._internalAbort();\n if (this._remuxer) {\n this._remuxer.flushStashedSamples();\n }\n this._loadSegment(nextSegmentIndex);\n } else {\n if (this._remuxer) {\n this._remuxer.flushStashedSamples();\n }\n this._emitter.emit(TransmuxingEvents.LOADING_COMPLETE);\n this._disableStatisticsReporter();\n }\n }\n\n _onIORedirect(redirectedURL) {\n let segmentIndex = this._ioctl.extraData;\n this._mediaDataSource.segments[segmentIndex].redirectedURL = redirectedURL;\n }\n\n _onIORecoveredEarlyEof() {\n this._emitter.emit(TransmuxingEvents.RECOVERED_EARLY_EOF);\n }\n\n _onIOException(type, info) {\n Log.e(this.TAG, `IOException: type = ${type}, code = ${info.code}, msg = ${info.msg}`);\n this._emitter.emit(TransmuxingEvents.IO_ERROR, type, info);\n this._disableStatisticsReporter();\n }\n\n _onDemuxException(type, info) {\n Log.e(this.TAG, `DemuxException: type = ${type}, info = ${info}`);\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, type, info);\n }\n\n _onRemuxerInitSegmentArrival(type, initSegment) {\n this._emitter.emit(TransmuxingEvents.INIT_SEGMENT, type, initSegment);\n }\n\n _onRemuxerMediaSegmentArrival(type, mediaSegment) {\n if (this._pendingSeekTime != null) {\n // Media segments after new-segment cross-seeking should be dropped.\n return;\n }\n this._emitter.emit(TransmuxingEvents.MEDIA_SEGMENT, type, mediaSegment);\n\n // Resolve pending seekPoint\n if (this._pendingResolveSeekPoint != null && type === 'video') {\n let syncPoints = mediaSegment.info.syncPoints;\n let seekpoint = this._pendingResolveSeekPoint;\n this._pendingResolveSeekPoint = null;\n\n // Safari: Pass PTS for recommend_seekpoint\n if (Browser.safari && syncPoints.length > 0 && syncPoints[0].originalDts === seekpoint) {\n seekpoint = syncPoints[0].pts;\n }\n // else: use original DTS (keyframe.milliseconds)\n\n this._emitter.emit(TransmuxingEvents.RECOMMEND_SEEKPOINT, seekpoint);\n }\n }\n\n _enableStatisticsReporter() {\n if (this._statisticsReporter == null) {\n this._statisticsReporter = self.setInterval(\n this._reportStatisticsInfo.bind(this),\n this._config.statisticsInfoReportInterval);\n }\n }\n\n _disableStatisticsReporter() {\n if (this._statisticsReporter) {\n self.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n _reportSegmentMediaInfo(segmentIndex) {\n let segmentInfo = this._mediaInfo.segments[segmentIndex];\n let exportInfo = Object.assign({}, segmentInfo);\n\n exportInfo.duration = this._mediaInfo.duration;\n exportInfo.segmentCount = this._mediaInfo.segmentCount;\n delete exportInfo.segments;\n delete exportInfo.keyframesIndex;\n\n this._emitter.emit(TransmuxingEvents.MEDIA_INFO, exportInfo);\n }\n\n _reportStatisticsInfo() {\n let info = {};\n\n info.url = this._ioctl.currentURL;\n info.hasRedirect = this._ioctl.hasRedirect;\n if (info.hasRedirect) {\n info.redirectedURL = this._ioctl.currentRedirectedURL;\n }\n\n info.speed = this._ioctl.currentSpeed;\n info.loaderType = this._ioctl.loaderType;\n info.currentSegmentIndex = this._currentSegmentIndex;\n info.totalSegmentCount = this._mediaDataSource.segments.length;\n\n this._emitter.emit(TransmuxingEvents.STATISTICS_INFO, info);\n }\n\n}\n\nexport default TransmuxingController;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Utility class to calculate realtime network I/O speed\nclass SpeedSampler {\n\n constructor() {\n // milliseconds\n this._firstCheckpoint = 0;\n this._lastCheckpoint = 0;\n this._intervalBytes = 0;\n this._totalBytes = 0;\n this._lastSecondBytes = 0;\n\n // compatibility detection\n if (self.performance && self.performance.now) {\n this._now = self.performance.now.bind(self.performance);\n } else {\n this._now = Date.now;\n }\n }\n\n reset() {\n this._firstCheckpoint = this._lastCheckpoint = 0;\n this._totalBytes = this._intervalBytes = 0;\n this._lastSecondBytes = 0;\n }\n\n addBytes(bytes) {\n if (this._firstCheckpoint === 0) {\n this._firstCheckpoint = this._now();\n this._lastCheckpoint = this._firstCheckpoint;\n this._intervalBytes += bytes;\n this._totalBytes += bytes;\n } else if (this._now() - this._lastCheckpoint < 1000) {\n this._intervalBytes += bytes;\n this._totalBytes += bytes;\n } else { // duration >= 1000\n this._lastSecondBytes = this._intervalBytes;\n this._intervalBytes = bytes;\n this._totalBytes += bytes;\n this._lastCheckpoint = this._now();\n }\n }\n\n get currentKBps() {\n this.addBytes(0);\n\n let durationSeconds = (this._now() - this._lastCheckpoint) / 1000;\n if (durationSeconds == 0) durationSeconds = 1;\n return (this._intervalBytes / durationSeconds) / 1024;\n }\n\n get lastSecondKBps() {\n this.addBytes(0);\n\n if (this._lastSecondBytes !== 0) {\n return this._lastSecondBytes / 1024;\n } else { // lastSecondBytes === 0\n if (this._now() - this._lastCheckpoint >= 500) {\n // if time interval since last checkpoint has exceeded 500ms\n // the speed is nearly accurate\n return this.currentKBps;\n } else {\n // We don't know\n return 0;\n }\n }\n }\n\n get averageKBps() {\n let durationSeconds = (this._now() - this._firstCheckpoint) / 1000;\n return (this._totalBytes / durationSeconds) / 1024;\n }\n\n}\n\nexport default SpeedSampler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n/* fetch + stream IO loader. Currently working on chrome 43+.\n * fetch provides a better alternative http API to XMLHttpRequest\n *\n * fetch spec https://fetch.spec.whatwg.org/\n * stream spec https://streams.spec.whatwg.org/\n */\nclass FetchStreamLoader extends BaseLoader {\n\n static isSupported() {\n try {\n // fetch + stream is broken on Microsoft Edge. Disable before build 15048.\n // see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8196907/\n // Fixed in Jan 10, 2017. Build 15048+ removed from blacklist.\n let isWorkWellEdge = Browser.msedge && Browser.version.minor >= 15048;\n let browserNotBlacklisted = Browser.msedge ? isWorkWellEdge : true;\n return (self.fetch && self.ReadableStream && browserNotBlacklisted);\n } catch (e) {\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('fetch-stream-loader');\n this.TAG = 'FetchStreamLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = true;\n\n this._requestAbort = false;\n this._abortController = null;\n this._contentLength = null;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n super.destroy();\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL && dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n\n let headers = new self.Headers();\n\n if (typeof seekConfig.headers === 'object') {\n let configHeaders = seekConfig.headers;\n for (let key in configHeaders) {\n if (configHeaders.hasOwnProperty(key)) {\n headers.append(key, configHeaders[key]);\n }\n }\n }\n\n let params = {\n method: 'GET',\n headers: headers,\n mode: 'cors',\n cache: 'default',\n // The default policy of Fetch API in the whatwg standard\n // Safari incorrectly indicates 'no-referrer' as default policy, fuck it\n referrerPolicy: 'no-referrer-when-downgrade'\n };\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n for (let key in this._config.headers) {\n headers.append(key, this._config.headers[key]);\n }\n }\n\n // cors is enabled by default\n if (dataSource.cors === false) {\n // no-cors means 'disregard cors policy', which can only be used in ServiceWorker\n params.mode = 'same-origin';\n }\n\n // withCredentials is disabled by default\n if (dataSource.withCredentials) {\n params.credentials = 'include';\n }\n\n // referrerPolicy from config\n if (dataSource.referrerPolicy) {\n params.referrerPolicy = dataSource.referrerPolicy;\n }\n\n if (self.AbortController) {\n this._abortController = new self.AbortController();\n params.signal = this._abortController.signal;\n }\n\n this._status = LoaderStatus.kConnecting;\n self.fetch(seekConfig.url, params).then((res) => {\n if (this._requestAbort) {\n this._status = LoaderStatus.kIdle;\n res.body.cancel();\n return;\n }\n if (res.ok && (res.status >= 200 && res.status <= 299)) {\n if (res.url !== seekConfig.url) {\n if (this._onURLRedirect) {\n let redirectedURL = this._seekHandler.removeURLParameters(res.url);\n this._onURLRedirect(redirectedURL);\n }\n }\n\n let lengthHeader = res.headers.get('Content-Length');\n if (lengthHeader != null) {\n this._contentLength = parseInt(lengthHeader);\n if (this._contentLength !== 0) {\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n }\n\n return this._pump.call(this, res.body.getReader());\n } else {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: res.status, msg: res.statusText});\n } else {\n throw new RuntimeException('FetchStreamLoader: Http code invalid, ' + res.status + ' ' + res.statusText);\n }\n }\n }).catch((e) => {\n if (this._abortController && this._abortController.signal.aborted) {\n return;\n }\n\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, {code: -1, msg: e.message});\n } else {\n throw e;\n }\n });\n }\n\n abort() {\n this._requestAbort = true;\n\n if (this._status !== LoaderStatus.kBuffering || !Browser.chrome) {\n // Chrome may throw Exception-like things here, avoid using if is buffering\n if (this._abortController) {\n try {\n this._abortController.abort();\n } catch (e) {}\n }\n }\n }\n\n _pump(reader) { // ReadableStreamReader\n return reader.read().then((result) => {\n if (result.done) {\n // First check received length\n if (this._contentLength !== null && this._receivedLength < this._contentLength) {\n // Report Early-EOF\n this._status = LoaderStatus.kError;\n let type = LoaderErrors.EARLY_EOF;\n let info = {code: -1, msg: 'Fetch stream meet Early-EOF'};\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n } else {\n // OK. Download complete\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n } else {\n if (this._abortController && this._abortController.signal.aborted) {\n this._status = LoaderStatus.kComplete;\n return;\n } else if (this._requestAbort === true) {\n this._status = LoaderStatus.kComplete;\n return reader.cancel();\n }\n\n this._status = LoaderStatus.kBuffering;\n\n let chunk = result.value.buffer;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n\n this._pump(reader);\n }\n }).catch((e) => {\n if (this._abortController && this._abortController.signal.aborted) {\n this._status = LoaderStatus.kComplete;\n return;\n }\n\n if (e.code === 11 && Browser.msedge) { // InvalidStateError on Microsoft Edge\n // Workaround: Edge may throw InvalidStateError after ReadableStreamReader.cancel() call\n // Ignore the unknown exception.\n // Related issue: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11265202/\n return;\n }\n\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if ((e.code === 19 || e.message === 'network error') && // NETWORK_ERR\n (this._contentLength === null ||\n (this._contentLength !== null && this._receivedLength < this._contentLength))) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: e.code, msg: 'Fetch stream meet Early-EOF'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: e.code, msg: e.message};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n });\n }\n\n}\n\nexport default FetchStreamLoader;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// For FireFox browser which supports `xhr.responseType = 'moz-chunked-arraybuffer'`\nclass MozChunkedLoader extends BaseLoader {\n\n static isSupported() {\n try {\n let xhr = new XMLHttpRequest();\n // Firefox 37- requires .open() to be called before setting responseType\n xhr.open('GET', 'https://example.com', true);\n xhr.responseType = 'moz-chunked-arraybuffer';\n return (xhr.responseType === 'moz-chunked-arraybuffer');\n } catch (e) {\n Log.w('MozChunkedLoader', e.message);\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('xhr-moz-chunked-loader');\n this.TAG = 'MozChunkedLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = true;\n\n this._xhr = null;\n this._requestAbort = false;\n this._contentLength = null;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onloadend = null;\n this._xhr.onerror = null;\n this._xhr = null;\n }\n super.destroy();\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL && dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n this._requestURL = seekConfig.url;\n\n let xhr = this._xhr = new XMLHttpRequest();\n xhr.open('GET', seekConfig.url, true);\n xhr.responseType = 'moz-chunked-arraybuffer';\n xhr.onreadystatechange = this._onReadyStateChange.bind(this);\n xhr.onprogress = this._onProgress.bind(this);\n xhr.onloadend = this._onLoadEnd.bind(this);\n xhr.onerror = this._onXhrError.bind(this);\n\n // cors is auto detected and enabled by xhr\n\n // withCredentials is disabled by default\n if (dataSource.withCredentials) {\n xhr.withCredentials = true;\n }\n\n if (typeof seekConfig.headers === 'object') {\n let headers = seekConfig.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n let headers = this._config.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n this._status = LoaderStatus.kConnecting;\n xhr.send();\n }\n\n abort() {\n this._requestAbort = true;\n if (this._xhr) {\n this._xhr.abort();\n }\n this._status = LoaderStatus.kComplete;\n }\n\n _onReadyStateChange(e) {\n let xhr = e.target;\n\n if (xhr.readyState === 2) { // HEADERS_RECEIVED\n if (xhr.responseURL != undefined && xhr.responseURL !== this._requestURL) {\n if (this._onURLRedirect) {\n let redirectedURL = this._seekHandler.removeURLParameters(xhr.responseURL);\n this._onURLRedirect(redirectedURL);\n }\n }\n\n if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: xhr.status, msg: xhr.statusText});\n } else {\n throw new RuntimeException('MozChunkedLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText);\n }\n } else {\n this._status = LoaderStatus.kBuffering;\n }\n }\n }\n\n _onProgress(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._contentLength === null) {\n if (e.total !== null && e.total !== 0) {\n this._contentLength = e.total;\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n }\n\n let chunk = e.target.response;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n }\n\n _onLoadEnd(e) {\n if (this._requestAbort === true) {\n this._requestAbort = false;\n return;\n } else if (this._status === LoaderStatus.kError) {\n return;\n }\n\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n\n _onXhrError(e) {\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if (this._contentLength && e.loaded < this._contentLength) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: -1, msg: 'Moz-Chunked stream meet Early-Eof'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: -1, msg: e.constructor.name + ' ' + e.type};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default MozChunkedLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport SpeedSampler from './speed-sampler.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// Universal IO Loader, implemented by adding Range header in xhr's request header\nclass RangeLoader extends BaseLoader {\n\n static isSupported() {\n try {\n let xhr = new XMLHttpRequest();\n xhr.open('GET', 'https://example.com', true);\n xhr.responseType = 'arraybuffer';\n return (xhr.responseType === 'arraybuffer');\n } catch (e) {\n Log.w('RangeLoader', e.message);\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('xhr-range-loader');\n this.TAG = 'RangeLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = false;\n\n this._chunkSizeKBList = [\n 128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 5120, 6144, 7168, 8192\n ];\n this._currentChunkSizeKB = 384;\n this._currentSpeedNormalized = 0;\n this._zeroSpeedChunkCount = 0;\n\n this._xhr = null;\n this._speedSampler = new SpeedSampler();\n\n this._requestAbort = false;\n this._waitForTotalLength = false;\n this._totalLengthReceived = false;\n\n this._currentRequestURL = null;\n this._currentRedirectedURL = null;\n this._currentRequestRange = null;\n this._totalLength = null; // size of the entire file\n this._contentLength = null; // Content-Length of entire request range\n this._receivedLength = 0; // total received bytes\n this._lastTimeLoaded = 0; // received bytes of current request sub-range\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onload = null;\n this._xhr.onerror = null;\n this._xhr = null;\n }\n super.destroy();\n }\n\n get currentSpeed() {\n return this._speedSampler.lastSecondKBps;\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n this._status = LoaderStatus.kConnecting;\n\n let useRefTotalLength = false;\n if (this._dataSource.filesize != undefined && this._dataSource.filesize !== 0) {\n useRefTotalLength = true;\n this._totalLength = this._dataSource.filesize;\n }\n\n if (!this._totalLengthReceived && !useRefTotalLength) {\n // We need total filesize\n this._waitForTotalLength = true;\n this._internalOpen(this._dataSource, {from: 0, to: -1});\n } else {\n // We have filesize, start loading\n this._openSubRange();\n }\n }\n\n _openSubRange() {\n let chunkSize = this._currentChunkSizeKB * 1024;\n\n let from = this._range.from + this._receivedLength;\n let to = from + chunkSize;\n\n if (this._contentLength != null) {\n if (to - this._range.from >= this._contentLength) {\n to = this._range.from + this._contentLength - 1;\n }\n }\n\n this._currentRequestRange = {from, to};\n this._internalOpen(this._dataSource, this._currentRequestRange);\n }\n\n _internalOpen(dataSource, range) {\n this._lastTimeLoaded = 0;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL) {\n if (this._currentRedirectedURL != undefined) {\n sourceURL = this._currentRedirectedURL;\n } else if (dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n this._currentRequestURL = seekConfig.url;\n\n let xhr = this._xhr = new XMLHttpRequest();\n xhr.open('GET', seekConfig.url, true);\n xhr.responseType = 'arraybuffer';\n xhr.onreadystatechange = this._onReadyStateChange.bind(this);\n xhr.onprogress = this._onProgress.bind(this);\n xhr.onload = this._onLoad.bind(this);\n xhr.onerror = this._onXhrError.bind(this);\n\n if (dataSource.withCredentials) {\n xhr.withCredentials = true;\n }\n\n if (typeof seekConfig.headers === 'object') {\n let headers = seekConfig.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n let headers = this._config.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n xhr.send();\n }\n\n abort() {\n this._requestAbort = true;\n this._internalAbort();\n this._status = LoaderStatus.kComplete;\n }\n\n _internalAbort() {\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onload = null;\n this._xhr.onerror = null;\n this._xhr.abort();\n this._xhr = null;\n }\n }\n\n _onReadyStateChange(e) {\n let xhr = e.target;\n\n if (xhr.readyState === 2) { // HEADERS_RECEIVED\n if (xhr.responseURL != undefined) { // if the browser support this property\n let redirectedURL = this._seekHandler.removeURLParameters(xhr.responseURL);\n if (xhr.responseURL !== this._currentRequestURL && redirectedURL !== this._currentRedirectedURL) {\n this._currentRedirectedURL = redirectedURL;\n if (this._onURLRedirect) {\n this._onURLRedirect(redirectedURL);\n }\n }\n }\n\n if ((xhr.status >= 200 && xhr.status <= 299)) {\n if (this._waitForTotalLength) {\n return;\n }\n this._status = LoaderStatus.kBuffering;\n } else {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: xhr.status, msg: xhr.statusText});\n } else {\n throw new RuntimeException('RangeLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText);\n }\n }\n }\n }\n\n _onProgress(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._contentLength === null) {\n let openNextRange = false;\n\n if (this._waitForTotalLength) {\n this._waitForTotalLength = false;\n this._totalLengthReceived = true;\n openNextRange = true;\n\n let total = e.total;\n this._internalAbort();\n if (total != null & total !== 0) {\n this._totalLength = total;\n }\n }\n\n // calculate currrent request range's contentLength\n if (this._range.to === -1) {\n this._contentLength = this._totalLength - this._range.from;\n } else { // to !== -1\n this._contentLength = this._range.to - this._range.from + 1;\n }\n\n if (openNextRange) {\n this._openSubRange();\n return;\n }\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n\n let delta = e.loaded - this._lastTimeLoaded;\n this._lastTimeLoaded = e.loaded;\n this._speedSampler.addBytes(delta);\n }\n\n _normalizeSpeed(input) {\n let list = this._chunkSizeKBList;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (input < list[0]) {\n return list[0];\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (input >= list[mid] && input < list[mid + 1])) {\n return list[mid];\n } else if (list[mid] < input) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n }\n\n _onLoad(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._waitForTotalLength) {\n this._waitForTotalLength = false;\n return;\n }\n\n this._lastTimeLoaded = 0;\n let KBps = this._speedSampler.lastSecondKBps;\n if (KBps === 0) {\n this._zeroSpeedChunkCount++;\n if (this._zeroSpeedChunkCount >= 3) {\n // Try get currentKBps after 3 chunks\n KBps = this._speedSampler.currentKBps;\n }\n }\n\n if (KBps !== 0) {\n let normalized = this._normalizeSpeed(KBps);\n if (this._currentSpeedNormalized !== normalized) {\n this._currentSpeedNormalized = normalized;\n this._currentChunkSizeKB = normalized;\n }\n }\n\n let chunk = e.target.response;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n let reportComplete = false;\n\n if (this._contentLength != null && this._receivedLength < this._contentLength) {\n // continue load next chunk\n this._openSubRange();\n } else {\n reportComplete = true;\n }\n\n // dispatch received chunk\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n\n if (reportComplete) {\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n }\n\n _onXhrError(e) {\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if (this._contentLength && this._receivedLength > 0\n && this._receivedLength < this._contentLength) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: -1, msg: 'RangeLoader meet Early-Eof'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: -1, msg: e.constructor.name + ' ' + e.type};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default RangeLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// For MPEG-TS/FLV over WebSocket live stream\nclass WebSocketLoader extends BaseLoader {\n\n static isSupported() {\n try {\n return (typeof self.WebSocket !== 'undefined');\n } catch (e) {\n return false;\n }\n }\n\n constructor() {\n super('websocket-loader');\n this.TAG = 'WebSocketLoader';\n\n this._needStash = true;\n\n this._ws = null;\n this._requestAbort = false;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this._ws) {\n this.abort();\n }\n super.destroy();\n }\n\n open(dataSource) {\n try {\n let ws = this._ws = new self.WebSocket(dataSource.url);\n ws.binaryType = 'arraybuffer';\n ws.onopen = this._onWebSocketOpen.bind(this);\n ws.onclose = this._onWebSocketClose.bind(this);\n ws.onmessage = this._onWebSocketMessage.bind(this);\n ws.onerror = this._onWebSocketError.bind(this);\n\n this._status = LoaderStatus.kConnecting;\n } catch (e) {\n this._status = LoaderStatus.kError;\n\n let info = {code: e.code, msg: e.message};\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n }\n\n abort() {\n let ws = this._ws;\n if (ws && (ws.readyState === 0 || ws.readyState === 1)) { // CONNECTING || OPEN\n this._requestAbort = true;\n ws.close();\n }\n\n this._ws = null;\n this._status = LoaderStatus.kComplete;\n }\n\n _onWebSocketOpen(e) {\n this._status = LoaderStatus.kBuffering;\n }\n\n _onWebSocketClose(e) {\n if (this._requestAbort === true) {\n this._requestAbort = false;\n return;\n }\n\n this._status = LoaderStatus.kComplete;\n\n if (this._onComplete) {\n this._onComplete(0, this._receivedLength - 1);\n }\n }\n\n _onWebSocketMessage(e) {\n if (e.data instanceof ArrayBuffer) {\n this._dispatchArrayBuffer(e.data);\n } else if (e.data instanceof Blob) {\n let reader = new FileReader();\n reader.onload = () => {\n this._dispatchArrayBuffer(reader.result);\n };\n reader.readAsArrayBuffer(e.data);\n } else {\n this._status = LoaderStatus.kError;\n let info = {code: -1, msg: 'Unsupported WebSocket message type: ' + e.data.constructor.name};\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n }\n\n _dispatchArrayBuffer(arraybuffer) {\n let chunk = arraybuffer;\n let byteStart = this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n }\n\n _onWebSocketError(e) {\n this._status = LoaderStatus.kError;\n\n let info = {\n code: e.code,\n msg: e.message\n };\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default WebSocketLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass RangeSeekHandler {\n\n constructor(zeroStart) {\n this._zeroStart = zeroStart || false;\n }\n\n getConfig(url, range) {\n let headers = {};\n\n if (range.from !== 0 || range.to !== -1) {\n let param;\n if (range.to !== -1) {\n param = `bytes=${range.from.toString()}-${range.to.toString()}`;\n } else {\n param = `bytes=${range.from.toString()}-`;\n }\n headers['Range'] = param;\n } else if (this._zeroStart) {\n headers['Range'] = 'bytes=0-';\n }\n\n return {\n url: url,\n headers: headers\n };\n }\n\n removeURLParameters(seekedURL) {\n return seekedURL;\n }\n\n}\n\nexport default RangeSeekHandler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass ParamSeekHandler {\n\n constructor(paramStart, paramEnd) {\n this._startName = paramStart;\n this._endName = paramEnd;\n }\n\n getConfig(baseUrl, range) {\n let url = baseUrl;\n\n if (range.from !== 0 || range.to !== -1) {\n let needAnd = true;\n if (url.indexOf('?') === -1) {\n url += '?';\n needAnd = false;\n }\n\n if (needAnd) {\n url += '&';\n }\n\n url += `${this._startName}=${range.from.toString()}`;\n\n if (range.to !== -1) {\n url += `&${this._endName}=${range.to.toString()}`;\n }\n }\n\n return {\n url: url,\n headers: {}\n };\n }\n\n removeURLParameters(seekedURL) {\n let baseURL = seekedURL.split('?')[0];\n let params = undefined;\n\n let queryIndex = seekedURL.indexOf('?');\n if (queryIndex !== -1) {\n params = seekedURL.substring(queryIndex + 1);\n }\n\n let resultParams = '';\n\n if (params != undefined && params.length > 0) {\n let pairs = params.split('&');\n\n for (let i = 0; i < pairs.length; i++) {\n let pair = pairs[i].split('=');\n let requireAnd = (i > 0);\n\n if (pair[0] !== this._startName && pair[0] !== this._endName) {\n if (requireAnd) {\n resultParams += '&';\n }\n resultParams += pairs[i];\n }\n }\n }\n\n return (resultParams.length === 0) ? baseURL : baseURL + '?' + resultParams;\n }\n\n}\n\nexport default ParamSeekHandler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport SpeedSampler from './speed-sampler.js';\nimport {LoaderStatus, LoaderErrors} from './loader.js';\nimport FetchStreamLoader from './fetch-stream-loader.js';\nimport MozChunkedLoader from './xhr-moz-chunked-loader.js';\nimport MSStreamLoader from './xhr-msstream-loader.js';\nimport RangeLoader from './xhr-range-loader.js';\nimport WebSocketLoader from './websocket-loader.js';\nimport RangeSeekHandler from './range-seek-handler.js';\nimport ParamSeekHandler from './param-seek-handler.js';\nimport {RuntimeException, IllegalStateException, InvalidArgumentException} from '../utils/exception.js';\n\n/**\n * DataSource: {\n * url: string,\n * filesize: number,\n * cors: boolean,\n * withCredentials: boolean\n * }\n * \n */\n\n// Manage IO Loaders\nclass IOController {\n\n constructor(dataSource, config, extraData) {\n this.TAG = 'IOController';\n\n this._config = config;\n this._extraData = extraData;\n\n this._stashInitialSize = 64 * 1024; // default initial size: 64KB\n if (config.stashInitialSize != undefined && config.stashInitialSize > 0) {\n // apply from config\n this._stashInitialSize = config.stashInitialSize;\n }\n\n this._stashUsed = 0;\n this._stashSize = this._stashInitialSize;\n this._bufferSize = 1024 * 1024 * 3; // initial size: 3MB\n this._stashBuffer = new ArrayBuffer(this._bufferSize);\n this._stashByteStart = 0;\n this._enableStash = true;\n if (config.enableStashBuffer === false) {\n this._enableStash = false;\n }\n\n this._loader = null;\n this._loaderClass = null;\n this._seekHandler = null;\n\n this._dataSource = dataSource;\n this._isWebSocketURL = /wss?:\\/\\/(.+?)/.test(dataSource.url);\n this._refTotalLength = dataSource.filesize ? dataSource.filesize : null;\n this._totalLength = this._refTotalLength;\n this._fullRequestFlag = false;\n this._currentRange = null;\n this._redirectedURL = null;\n\n this._speedNormalized = 0;\n this._speedSampler = new SpeedSampler();\n this._speedNormalizeList = [32, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096];\n\n this._isEarlyEofReconnecting = false;\n\n this._paused = false;\n this._resumeFrom = 0;\n\n this._onDataArrival = null;\n this._onSeeked = null;\n this._onError = null;\n this._onComplete = null;\n this._onRedirect = null;\n this._onRecoveredEarlyEof = null;\n\n this._selectSeekHandler();\n this._selectLoader();\n this._createLoader();\n }\n\n destroy() {\n if (this._loader.isWorking()) {\n this._loader.abort();\n }\n this._loader.destroy();\n this._loader = null;\n this._loaderClass = null;\n this._dataSource = null;\n this._stashBuffer = null;\n this._stashUsed = this._stashSize = this._bufferSize = this._stashByteStart = 0;\n this._currentRange = null;\n this._speedSampler = null;\n\n this._isEarlyEofReconnecting = false;\n\n this._onDataArrival = null;\n this._onSeeked = null;\n this._onError = null;\n this._onComplete = null;\n this._onRedirect = null;\n this._onRecoveredEarlyEof = null;\n\n this._extraData = null;\n }\n\n isWorking() {\n return this._loader && this._loader.isWorking() && !this._paused;\n }\n\n isPaused() {\n return this._paused;\n }\n\n get status() {\n return this._loader.status;\n }\n\n get extraData() {\n return this._extraData;\n }\n\n set extraData(data) {\n this._extraData = data;\n }\n\n // prototype: function onDataArrival(chunks: ArrayBuffer, byteStart: number): number\n get onDataArrival() {\n return this._onDataArrival;\n }\n\n set onDataArrival(callback) {\n this._onDataArrival = callback;\n }\n\n get onSeeked() {\n return this._onSeeked;\n }\n\n set onSeeked(callback) {\n this._onSeeked = callback;\n }\n\n // prototype: function onError(type: number, info: {code: number, msg: string}): void\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n get onComplete() {\n return this._onComplete;\n }\n\n set onComplete(callback) {\n this._onComplete = callback;\n }\n\n get onRedirect() {\n return this._onRedirect;\n }\n\n set onRedirect(callback) {\n this._onRedirect = callback;\n }\n\n get onRecoveredEarlyEof() {\n return this._onRecoveredEarlyEof;\n }\n\n set onRecoveredEarlyEof(callback) {\n this._onRecoveredEarlyEof = callback;\n }\n\n get currentURL() {\n return this._dataSource.url;\n }\n\n get hasRedirect() {\n return (this._redirectedURL != null || this._dataSource.redirectedURL != undefined);\n }\n\n get currentRedirectedURL() {\n return this._redirectedURL || this._dataSource.redirectedURL;\n }\n\n // in KB/s\n get currentSpeed() {\n if (this._loaderClass === RangeLoader) {\n // SpeedSampler is inaccuracy if loader is RangeLoader\n return this._loader.currentSpeed;\n }\n return this._speedSampler.lastSecondKBps;\n }\n\n get loaderType() {\n return this._loader.type;\n }\n\n _selectSeekHandler() {\n let config = this._config;\n\n if (config.seekType === 'range') {\n this._seekHandler = new RangeSeekHandler(this._config.rangeLoadZeroStart);\n } else if (config.seekType === 'param') {\n let paramStart = config.seekParamStart || 'bstart';\n let paramEnd = config.seekParamEnd || 'bend';\n\n this._seekHandler = new ParamSeekHandler(paramStart, paramEnd);\n } else if (config.seekType === 'custom') {\n if (typeof config.customSeekHandler !== 'function') {\n throw new InvalidArgumentException('Custom seekType specified in config but invalid customSeekHandler!');\n }\n this._seekHandler = new config.customSeekHandler();\n } else {\n throw new InvalidArgumentException(`Invalid seekType in config: ${config.seekType}`);\n }\n }\n\n _selectLoader() {\n if (this._config.customLoader != null) {\n this._loaderClass = this._config.customLoader;\n } else if (this._isWebSocketURL) {\n this._loaderClass = WebSocketLoader;\n } else if (FetchStreamLoader.isSupported()) {\n this._loaderClass = FetchStreamLoader;\n } else if (MozChunkedLoader.isSupported()) {\n this._loaderClass = MozChunkedLoader;\n } else if (RangeLoader.isSupported()) {\n this._loaderClass = RangeLoader;\n } else {\n throw new RuntimeException('Your browser doesn\\'t support xhr with arraybuffer responseType!');\n }\n }\n\n _createLoader() {\n this._loader = new this._loaderClass(this._seekHandler, this._config);\n if (this._loader.needStashBuffer === false) {\n this._enableStash = false;\n }\n this._loader.onContentLengthKnown = this._onContentLengthKnown.bind(this);\n this._loader.onURLRedirect = this._onURLRedirect.bind(this);\n this._loader.onDataArrival = this._onLoaderChunkArrival.bind(this);\n this._loader.onComplete = this._onLoaderComplete.bind(this);\n this._loader.onError = this._onLoaderError.bind(this);\n }\n\n open(optionalFrom) {\n this._currentRange = {from: 0, to: -1};\n if (optionalFrom) {\n this._currentRange.from = optionalFrom;\n }\n\n this._speedSampler.reset();\n if (!optionalFrom) {\n this._fullRequestFlag = true;\n }\n\n this._loader.open(this._dataSource, Object.assign({}, this._currentRange));\n }\n\n abort() {\n this._loader.abort();\n\n if (this._paused) {\n this._paused = false;\n this._resumeFrom = 0;\n }\n }\n\n pause() {\n if (this.isWorking()) {\n this._loader.abort();\n\n if (this._stashUsed !== 0) {\n this._resumeFrom = this._stashByteStart;\n this._currentRange.to = this._stashByteStart - 1;\n } else {\n this._resumeFrom = this._currentRange.to + 1;\n }\n this._stashUsed = 0;\n this._stashByteStart = 0;\n this._paused = true;\n }\n }\n\n resume() {\n if (this._paused) {\n this._paused = false;\n let bytes = this._resumeFrom;\n this._resumeFrom = 0;\n this._internalSeek(bytes, true);\n }\n }\n\n seek(bytes) {\n this._paused = false;\n this._stashUsed = 0;\n this._stashByteStart = 0;\n this._internalSeek(bytes, true);\n }\n\n /**\n * When seeking request is from media seeking, unconsumed stash data should be dropped\n * However, stash data shouldn't be dropped if seeking requested from http reconnection\n *\n * @dropUnconsumed: Ignore and discard all unconsumed data in stash buffer\n */\n _internalSeek(bytes, dropUnconsumed) {\n if (this._loader.isWorking()) {\n this._loader.abort();\n }\n\n // dispatch & flush stash buffer before seek\n this._flushStashBuffer(dropUnconsumed);\n\n this._loader.destroy();\n this._loader = null;\n\n let requestRange = {from: bytes, to: -1};\n this._currentRange = {from: requestRange.from, to: -1};\n\n this._speedSampler.reset();\n this._stashSize = this._stashInitialSize;\n this._createLoader();\n this._loader.open(this._dataSource, requestRange);\n\n if (this._onSeeked) {\n this._onSeeked();\n }\n }\n\n updateUrl(url) {\n if (!url || typeof url !== 'string' || url.length === 0) {\n throw new InvalidArgumentException('Url must be a non-empty string!');\n }\n\n this._dataSource.url = url;\n\n // TODO: replace with new url\n }\n\n _expandBuffer(expectedBytes) {\n let bufferNewSize = this._stashSize;\n while (bufferNewSize + 1024 * 1024 * 1 < expectedBytes) {\n bufferNewSize *= 2;\n }\n\n bufferNewSize += 1024 * 1024 * 1; // bufferSize = stashSize + 1MB\n if (bufferNewSize === this._bufferSize) {\n return;\n }\n\n let newBuffer = new ArrayBuffer(bufferNewSize);\n\n if (this._stashUsed > 0) { // copy existing data into new buffer\n let stashOldArray = new Uint8Array(this._stashBuffer, 0, this._stashUsed);\n let stashNewArray = new Uint8Array(newBuffer, 0, bufferNewSize);\n stashNewArray.set(stashOldArray, 0);\n }\n\n this._stashBuffer = newBuffer;\n this._bufferSize = bufferNewSize;\n }\n\n _normalizeSpeed(input) {\n let list = this._speedNormalizeList;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (input < list[0]) {\n return list[0];\n }\n\n // binary search\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (input >= list[mid] && input < list[mid + 1])) {\n return list[mid];\n } else if (list[mid] < input) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n }\n\n _adjustStashSize(normalized) {\n let stashSizeKB = 0;\n\n if (this._config.isLive) {\n // live stream: always use 1/8 normalized speed for size of stashSizeKB\n stashSizeKB = normalized / 8;\n } else {\n if (normalized < 512) {\n stashSizeKB = normalized;\n } else if (normalized >= 512 && normalized <= 1024) {\n stashSizeKB = Math.floor(normalized * 1.5);\n } else {\n stashSizeKB = normalized * 2;\n }\n }\n\n if (stashSizeKB > 8192) {\n stashSizeKB = 8192;\n }\n\n let bufferSize = stashSizeKB * 1024 + 1024 * 1024 * 1; // stashSize + 1MB\n if (this._bufferSize < bufferSize) {\n this._expandBuffer(bufferSize);\n }\n this._stashSize = stashSizeKB * 1024;\n }\n\n _dispatchChunks(chunks, byteStart) {\n this._currentRange.to = byteStart + chunks.byteLength - 1;\n return this._onDataArrival(chunks, byteStart);\n }\n\n _onURLRedirect(redirectedURL) {\n this._redirectedURL = redirectedURL;\n if (this._onRedirect) {\n this._onRedirect(redirectedURL);\n }\n }\n\n _onContentLengthKnown(contentLength) {\n if (contentLength && this._fullRequestFlag) {\n this._totalLength = contentLength;\n this._fullRequestFlag = false;\n }\n }\n\n _onLoaderChunkArrival(chunk, byteStart, receivedLength) {\n if (!this._onDataArrival) {\n throw new IllegalStateException('IOController: No existing consumer (onDataArrival) callback!');\n }\n if (this._paused) {\n return;\n }\n if (this._isEarlyEofReconnecting) {\n // Auto-reconnect for EarlyEof succeed, notify to upper-layer by callback\n this._isEarlyEofReconnecting = false;\n if (this._onRecoveredEarlyEof) {\n this._onRecoveredEarlyEof();\n }\n }\n\n this._speedSampler.addBytes(chunk.byteLength);\n\n // adjust stash buffer size according to network speed dynamically\n let KBps = this._speedSampler.lastSecondKBps;\n if (KBps !== 0) {\n let normalized = this._normalizeSpeed(KBps);\n if (this._speedNormalized !== normalized) {\n this._speedNormalized = normalized;\n this._adjustStashSize(normalized);\n }\n }\n\n if (!this._enableStash) { // disable stash\n if (this._stashUsed === 0) {\n // dispatch chunk directly to consumer;\n // check ret value (consumed bytes) and stash unconsumed to stashBuffer\n let consumed = this._dispatchChunks(chunk, byteStart);\n if (consumed < chunk.byteLength) { // unconsumed data remain.\n let remain = chunk.byteLength - consumed;\n if (remain > this._bufferSize) {\n this._expandBuffer(remain);\n }\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n stashArray.set(new Uint8Array(chunk, consumed), 0);\n this._stashUsed += remain;\n this._stashByteStart = byteStart + consumed;\n }\n } else {\n // else: Merge chunk into stashBuffer, and dispatch stashBuffer to consumer.\n if (this._stashUsed + chunk.byteLength > this._bufferSize) {\n this._expandBuffer(this._stashUsed + chunk.byteLength);\n }\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n let consumed = this._dispatchChunks(this._stashBuffer.slice(0, this._stashUsed), this._stashByteStart);\n if (consumed < this._stashUsed && consumed > 0) { // unconsumed data remain\n let remainArray = new Uint8Array(this._stashBuffer, consumed);\n stashArray.set(remainArray, 0);\n }\n this._stashUsed -= consumed;\n this._stashByteStart += consumed;\n }\n } else { // enable stash\n if (this._stashUsed === 0 && this._stashByteStart === 0) { // seeked? or init chunk?\n // This is the first chunk after seek action\n this._stashByteStart = byteStart;\n }\n if (this._stashUsed + chunk.byteLength <= this._stashSize) {\n // just stash\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._stashSize);\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n } else { // stashUsed + chunkSize > stashSize, size limit exceeded\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n if (this._stashUsed > 0) { // There're stash datas in buffer\n // dispatch the whole stashBuffer, and stash remain data\n // then append chunk to stashBuffer (stash)\n let buffer = this._stashBuffer.slice(0, this._stashUsed);\n let consumed = this._dispatchChunks(buffer, this._stashByteStart);\n if (consumed < buffer.byteLength) {\n if (consumed > 0) {\n let remainArray = new Uint8Array(buffer, consumed);\n stashArray.set(remainArray, 0);\n this._stashUsed = remainArray.byteLength;\n this._stashByteStart += consumed;\n }\n } else {\n this._stashUsed = 0;\n this._stashByteStart += consumed;\n }\n if (this._stashUsed + chunk.byteLength > this._bufferSize) {\n this._expandBuffer(this._stashUsed + chunk.byteLength);\n stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n }\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n } else { // stash buffer empty, but chunkSize > stashSize (oh, holy shit)\n // dispatch chunk directly and stash remain data\n let consumed = this._dispatchChunks(chunk, byteStart);\n if (consumed < chunk.byteLength) {\n let remain = chunk.byteLength - consumed;\n if (remain > this._bufferSize) {\n this._expandBuffer(remain);\n stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n }\n stashArray.set(new Uint8Array(chunk, consumed), 0);\n this._stashUsed += remain;\n this._stashByteStart = byteStart + consumed;\n }\n }\n }\n }\n }\n\n _flushStashBuffer(dropUnconsumed) {\n if (this._stashUsed > 0) {\n let buffer = this._stashBuffer.slice(0, this._stashUsed);\n let consumed = this._dispatchChunks(buffer, this._stashByteStart);\n let remain = buffer.byteLength - consumed;\n\n if (consumed < buffer.byteLength) {\n if (dropUnconsumed) {\n Log.w(this.TAG, `${remain} bytes unconsumed data remain when flush buffer, dropped`);\n } else {\n if (consumed > 0) {\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n let remainArray = new Uint8Array(buffer, consumed);\n stashArray.set(remainArray, 0);\n this._stashUsed = remainArray.byteLength;\n this._stashByteStart += consumed;\n }\n return 0;\n }\n }\n this._stashUsed = 0;\n this._stashByteStart = 0;\n return remain;\n }\n return 0;\n }\n\n _onLoaderComplete(from, to) {\n // Force-flush stash buffer, and drop unconsumed data\n this._flushStashBuffer(true);\n\n if (this._onComplete) {\n this._onComplete(this._extraData);\n }\n }\n\n _onLoaderError(type, data) {\n Log.e(this.TAG, `Loader error, code = ${data.code}, msg = ${data.msg}`);\n\n this._flushStashBuffer(false);\n\n if (this._isEarlyEofReconnecting) {\n // Auto-reconnect for EarlyEof failed, throw UnrecoverableEarlyEof error to upper-layer\n this._isEarlyEofReconnecting = false;\n type = LoaderErrors.UNRECOVERABLE_EARLY_EOF;\n }\n\n switch (type) {\n case LoaderErrors.EARLY_EOF: {\n if (!this._config.isLive) {\n // Do internal http reconnect if not live stream\n if (this._totalLength) {\n let nextFrom = this._currentRange.to + 1;\n if (nextFrom < this._totalLength) {\n Log.w(this.TAG, 'Connection lost, trying reconnect...');\n this._isEarlyEofReconnecting = true;\n this._internalSeek(nextFrom, false);\n }\n return;\n }\n // else: We don't know totalLength, throw UnrecoverableEarlyEof\n }\n // live stream: throw UnrecoverableEarlyEof error to upper-layer\n type = LoaderErrors.UNRECOVERABLE_EARLY_EOF;\n break;\n }\n case LoaderErrors.UNRECOVERABLE_EARLY_EOF:\n case LoaderErrors.CONNECTING_TIMEOUT:\n case LoaderErrors.HTTP_STATUS_CODE_INVALID:\n case LoaderErrors.EXCEPTION:\n break;\n }\n\n if (this._onError) {\n this._onError(type, data);\n } else {\n throw new RuntimeException('IOException: ' + data.msg);\n }\n }\n\n}\n\nexport default IOController;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass Polyfill {\n\n static install() {\n // ES6 Object.setPrototypeOf\n Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {\n obj.__proto__ = proto;\n return obj;\n };\n\n // ES6 Object.assign\n Object.assign = Object.assign || function (target) {\n if (target === undefined || target === null) {\n throw new TypeError('Cannot convert undefined or null to object');\n }\n\n let output = Object(target);\n for (let i = 1; i < arguments.length; i++) {\n let source = arguments[i];\n if (source !== undefined && source !== null) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n output[key] = source[key];\n }\n }\n }\n }\n return output;\n };\n\n // ES6 Promise (missing support in IE11)\n if (typeof self.Promise !== 'function') {\n require('es6-promise').polyfill();\n }\n }\n\n}\n\nPolyfill.install();\n\nexport default Polyfill;","function webpackBootstrapFunc (modules) {\n/******/ // The module cache\n/******/ var installedModules = {};\n\n/******/ // The require function\n/******/ function __webpack_require__(moduleId) {\n\n/******/ // Check if module is in cache\n/******/ if(installedModules[moduleId])\n/******/ return installedModules[moduleId].exports;\n\n/******/ // Create a new module (and put it into the cache)\n/******/ var module = installedModules[moduleId] = {\n/******/ i: moduleId,\n/******/ l: false,\n/******/ exports: {}\n/******/ };\n\n/******/ // Execute the module function\n/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n/******/ // Flag the module as loaded\n/******/ module.l = true;\n\n/******/ // Return the exports of the module\n/******/ return module.exports;\n/******/ }\n\n/******/ // expose the modules object (__webpack_modules__)\n/******/ __webpack_require__.m = modules;\n\n/******/ // expose the module cache\n/******/ __webpack_require__.c = installedModules;\n\n/******/ // identity function for calling harmony imports with the correct context\n/******/ __webpack_require__.i = function(value) { return value; };\n\n/******/ // define getter function for harmony exports\n/******/ __webpack_require__.d = function(exports, name, getter) {\n/******/ if(!__webpack_require__.o(exports, name)) {\n/******/ Object.defineProperty(exports, name, {\n/******/ configurable: false,\n/******/ enumerable: true,\n/******/ get: getter\n/******/ });\n/******/ }\n/******/ };\n\n/******/ // define __esModule on exports\n/******/ __webpack_require__.r = function(exports) {\n/******/ Object.defineProperty(exports, '__esModule', { value: true });\n/******/ };\n\n/******/ // getDefaultExport function for compatibility with non-harmony modules\n/******/ __webpack_require__.n = function(module) {\n/******/ var getter = module && module.__esModule ?\n/******/ function getDefault() { return module['default']; } :\n/******/ function getModuleExports() { return module; };\n/******/ __webpack_require__.d(getter, 'a', getter);\n/******/ return getter;\n/******/ };\n\n/******/ // Object.prototype.hasOwnProperty.call\n/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n/******/ // __webpack_public_path__\n/******/ __webpack_require__.p = \"/\";\n\n/******/ // on error function for async loading\n/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n var f = __webpack_require__(__webpack_require__.s = ENTRY_MODULE)\n return f.default || f // try to call default if defined to also support babel esmodule exports\n}\n\nvar moduleNameReqExp = '[\\\\.|\\\\-|\\\\+|\\\\w|\\/|@]+'\nvar dependencyRegExp = '\\\\(\\\\s*(\\/\\\\*.*?\\\\*\\/)?\\\\s*.*?(' + moduleNameReqExp + ').*?\\\\)' // additional chars when output.pathinfo is true\n\n// http://stackoverflow.com/a/2593661/130442\nfunction quoteRegExp (str) {\n return (str + '').replace(/[.?*+^$[\\]\\\\(){}|-]/g, '\\\\$&')\n}\n\nfunction isNumeric(n) {\n return !isNaN(1 * n); // 1 * n converts integers, integers as string (\"123\"), 1e3 and \"1e3\" to integers and strings to NaN\n}\n\nfunction getModuleDependencies (sources, module, queueName) {\n var retval = {}\n retval[queueName] = []\n\n var fnString = module.toString()\n var wrapperSignature = fnString.match(/^function\\s?\\w*\\(\\w+,\\s*\\w+,\\s*(\\w+)\\)/)\n if (!wrapperSignature) return retval\n var webpackRequireName = wrapperSignature[1]\n\n // main bundle deps\n var re = new RegExp('(\\\\\\\\n|\\\\W)' + quoteRegExp(webpackRequireName) + dependencyRegExp, 'g')\n var match\n while ((match = re.exec(fnString))) {\n if (match[3] === 'dll-reference') continue\n retval[queueName].push(match[3])\n }\n\n // dll deps\n re = new RegExp('\\\\(' + quoteRegExp(webpackRequireName) + '\\\\(\"(dll-reference\\\\s(' + moduleNameReqExp + '))\"\\\\)\\\\)' + dependencyRegExp, 'g')\n while ((match = re.exec(fnString))) {\n if (!sources[match[2]]) {\n retval[queueName].push(match[1])\n sources[match[2]] = __webpack_require__(match[1]).m\n }\n retval[match[2]] = retval[match[2]] || []\n retval[match[2]].push(match[4])\n }\n\n // convert 1e3 back to 1000 - this can be important after uglify-js converted 1000 to 1e3\n var keys = Object.keys(retval);\n for (var i = 0; i < keys.length; i++) {\n for (var j = 0; j < retval[keys[i]].length; j++) {\n if (isNumeric(retval[keys[i]][j])) {\n retval[keys[i]][j] = 1 * retval[keys[i]][j];\n }\n }\n }\n\n return retval\n}\n\nfunction hasValuesInQueues (queues) {\n var keys = Object.keys(queues)\n return keys.reduce(function (hasValues, key) {\n return hasValues || queues[key].length > 0\n }, false)\n}\n\nfunction getRequiredModules (sources, moduleId) {\n var modulesQueue = {\n main: [moduleId]\n }\n var requiredModules = {\n main: []\n }\n var seenModules = {\n main: {}\n }\n\n while (hasValuesInQueues(modulesQueue)) {\n var queues = Object.keys(modulesQueue)\n for (var i = 0; i < queues.length; i++) {\n var queueName = queues[i]\n var queue = modulesQueue[queueName]\n var moduleToCheck = queue.pop()\n seenModules[queueName] = seenModules[queueName] || {}\n if (seenModules[queueName][moduleToCheck] || !sources[queueName][moduleToCheck]) continue\n seenModules[queueName][moduleToCheck] = true\n requiredModules[queueName] = requiredModules[queueName] || []\n requiredModules[queueName].push(moduleToCheck)\n var newModules = getModuleDependencies(sources, sources[queueName][moduleToCheck], queueName)\n var newModulesKeys = Object.keys(newModules)\n for (var j = 0; j < newModulesKeys.length; j++) {\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]] || []\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])\n }\n }\n }\n\n return requiredModules\n}\n\nmodule.exports = function (moduleId, options) {\n options = options || {}\n var sources = {\n main: __webpack_modules__\n }\n\n var requiredModules = options.all ? { main: Object.keys(sources.main) } : getRequiredModules(sources, moduleId)\n\n var src = ''\n\n Object.keys(requiredModules).filter(function (m) { return m !== 'main' }).forEach(function (module) {\n var entryModule = 0\n while (requiredModules[module][entryModule]) {\n entryModule++\n }\n requiredModules[module].push(entryModule)\n sources[module][entryModule] = '(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })'\n src = src + 'var ' + module + ' = (' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(entryModule)) + ')({' + requiredModules[module].map(function (id) { return '' + JSON.stringify(id) + ': ' + sources[module][id].toString() }).join(',') + '});\\n'\n })\n\n src = src + 'new ((' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(moduleId)) + ')({' + requiredModules.main.map(function (id) { return '' + JSON.stringify(id) + ': ' + sources.main[id].toString() }).join(',') + '}))(self);'\n\n var blob = new window.Blob([src], { type: 'text/javascript' })\n if (options.bare) { return blob }\n\n var URL = window.URL || window.webkitURL || window.mozURL || window.msURL\n\n var workerUrl = URL.createObjectURL(blob)\n var worker = new window.Worker(workerUrl)\n worker.objectURL = workerUrl\n\n return worker\n}\n","// entry/index file\n\n// make it compatible with browserify's umd wrapper\nmodule.exports = require('./mpegts.js').default;\n","/*!\n * @overview es6-promise - a tiny implementation of Promises/A+.\n * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)\n * @license Licensed under MIT license\n * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE\n * @version v4.2.8+1e68dce6\n */\n\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.ES6Promise = factory());\n}(this, (function () { 'use strict';\n\nfunction objectOrFunction(x) {\n var type = typeof x;\n return x !== null && (type === 'object' || type === 'function');\n}\n\nfunction isFunction(x) {\n return typeof x === 'function';\n}\n\n\n\nvar _isArray = void 0;\nif (Array.isArray) {\n _isArray = Array.isArray;\n} else {\n _isArray = function (x) {\n return Object.prototype.toString.call(x) === '[object Array]';\n };\n}\n\nvar isArray = _isArray;\n\nvar len = 0;\nvar vertxNext = void 0;\nvar customSchedulerFn = void 0;\n\nvar asap = function asap(callback, arg) {\n queue[len] = callback;\n queue[len + 1] = arg;\n len += 2;\n if (len === 2) {\n // If len is 2, that means that we need to schedule an async flush.\n // If additional callbacks are queued before the queue is flushed, they\n // will be processed by this flush that we are scheduling.\n if (customSchedulerFn) {\n customSchedulerFn(flush);\n } else {\n scheduleFlush();\n }\n }\n};\n\nfunction setScheduler(scheduleFn) {\n customSchedulerFn = scheduleFn;\n}\n\nfunction setAsap(asapFn) {\n asap = asapFn;\n}\n\nvar browserWindow = typeof window !== 'undefined' ? window : undefined;\nvar browserGlobal = browserWindow || {};\nvar BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;\nvar isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';\n\n// test for web worker but not in IE10\nvar isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';\n\n// node\nfunction useNextTick() {\n // node version 0.10.x displays a deprecation warning when nextTick is used recursively\n // see https://github.com/cujojs/when/issues/410 for details\n return function () {\n return process.nextTick(flush);\n };\n}\n\n// vertx\nfunction useVertxTimer() {\n if (typeof vertxNext !== 'undefined') {\n return function () {\n vertxNext(flush);\n };\n }\n\n return useSetTimeout();\n}\n\nfunction useMutationObserver() {\n var iterations = 0;\n var observer = new BrowserMutationObserver(flush);\n var node = document.createTextNode('');\n observer.observe(node, { characterData: true });\n\n return function () {\n node.data = iterations = ++iterations % 2;\n };\n}\n\n// web worker\nfunction useMessageChannel() {\n var channel = new MessageChannel();\n channel.port1.onmessage = flush;\n return function () {\n return channel.port2.postMessage(0);\n };\n}\n\nfunction useSetTimeout() {\n // Store setTimeout reference so es6-promise will be unaffected by\n // other code modifying setTimeout (like sinon.useFakeTimers())\n var globalSetTimeout = setTimeout;\n return function () {\n return globalSetTimeout(flush, 1);\n };\n}\n\nvar queue = new Array(1000);\nfunction flush() {\n for (var i = 0; i < len; i += 2) {\n var callback = queue[i];\n var arg = queue[i + 1];\n\n callback(arg);\n\n queue[i] = undefined;\n queue[i + 1] = undefined;\n }\n\n len = 0;\n}\n\nfunction attemptVertx() {\n try {\n var vertx = Function('return this')().require('vertx');\n vertxNext = vertx.runOnLoop || vertx.runOnContext;\n return useVertxTimer();\n } catch (e) {\n return useSetTimeout();\n }\n}\n\nvar scheduleFlush = void 0;\n// Decide what async method to use to triggering processing of queued callbacks:\nif (isNode) {\n scheduleFlush = useNextTick();\n} else if (BrowserMutationObserver) {\n scheduleFlush = useMutationObserver();\n} else if (isWorker) {\n scheduleFlush = useMessageChannel();\n} else if (browserWindow === undefined && typeof require === 'function') {\n scheduleFlush = attemptVertx();\n} else {\n scheduleFlush = useSetTimeout();\n}\n\nfunction then(onFulfillment, onRejection) {\n var parent = this;\n\n var child = new this.constructor(noop);\n\n if (child[PROMISE_ID] === undefined) {\n makePromise(child);\n }\n\n var _state = parent._state;\n\n\n if (_state) {\n var callback = arguments[_state - 1];\n asap(function () {\n return invokeCallback(_state, child, callback, parent._result);\n });\n } else {\n subscribe(parent, child, onFulfillment, onRejection);\n }\n\n return child;\n}\n\n/**\n `Promise.resolve` returns a promise that will become resolved with the\n passed `value`. It is shorthand for the following:\n\n ```javascript\n let promise = new Promise(function(resolve, reject){\n resolve(1);\n });\n\n promise.then(function(value){\n // value === 1\n });\n ```\n\n Instead of writing the above, your code now simply becomes the following:\n\n ```javascript\n let promise = Promise.resolve(1);\n\n promise.then(function(value){\n // value === 1\n });\n ```\n\n @method resolve\n @static\n @param {Any} value value that the returned promise will be resolved with\n Useful for tooling.\n @return {Promise} a promise that will become fulfilled with the given\n `value`\n*/\nfunction resolve$1(object) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (object && typeof object === 'object' && object.constructor === Constructor) {\n return object;\n }\n\n var promise = new Constructor(noop);\n resolve(promise, object);\n return promise;\n}\n\nvar PROMISE_ID = Math.random().toString(36).substring(2);\n\nfunction noop() {}\n\nvar PENDING = void 0;\nvar FULFILLED = 1;\nvar REJECTED = 2;\n\nfunction selfFulfillment() {\n return new TypeError(\"You cannot resolve a promise with itself\");\n}\n\nfunction cannotReturnOwn() {\n return new TypeError('A promises callback cannot return that same promise.');\n}\n\nfunction tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {\n try {\n then$$1.call(value, fulfillmentHandler, rejectionHandler);\n } catch (e) {\n return e;\n }\n}\n\nfunction handleForeignThenable(promise, thenable, then$$1) {\n asap(function (promise) {\n var sealed = false;\n var error = tryThen(then$$1, thenable, function (value) {\n if (sealed) {\n return;\n }\n sealed = true;\n if (thenable !== value) {\n resolve(promise, value);\n } else {\n fulfill(promise, value);\n }\n }, function (reason) {\n if (sealed) {\n return;\n }\n sealed = true;\n\n reject(promise, reason);\n }, 'Settle: ' + (promise._label || ' unknown promise'));\n\n if (!sealed && error) {\n sealed = true;\n reject(promise, error);\n }\n }, promise);\n}\n\nfunction handleOwnThenable(promise, thenable) {\n if (thenable._state === FULFILLED) {\n fulfill(promise, thenable._result);\n } else if (thenable._state === REJECTED) {\n reject(promise, thenable._result);\n } else {\n subscribe(thenable, undefined, function (value) {\n return resolve(promise, value);\n }, function (reason) {\n return reject(promise, reason);\n });\n }\n}\n\nfunction handleMaybeThenable(promise, maybeThenable, then$$1) {\n if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {\n handleOwnThenable(promise, maybeThenable);\n } else {\n if (then$$1 === undefined) {\n fulfill(promise, maybeThenable);\n } else if (isFunction(then$$1)) {\n handleForeignThenable(promise, maybeThenable, then$$1);\n } else {\n fulfill(promise, maybeThenable);\n }\n }\n}\n\nfunction resolve(promise, value) {\n if (promise === value) {\n reject(promise, selfFulfillment());\n } else if (objectOrFunction(value)) {\n var then$$1 = void 0;\n try {\n then$$1 = value.then;\n } catch (error) {\n reject(promise, error);\n return;\n }\n handleMaybeThenable(promise, value, then$$1);\n } else {\n fulfill(promise, value);\n }\n}\n\nfunction publishRejection(promise) {\n if (promise._onerror) {\n promise._onerror(promise._result);\n }\n\n publish(promise);\n}\n\nfunction fulfill(promise, value) {\n if (promise._state !== PENDING) {\n return;\n }\n\n promise._result = value;\n promise._state = FULFILLED;\n\n if (promise._subscribers.length !== 0) {\n asap(publish, promise);\n }\n}\n\nfunction reject(promise, reason) {\n if (promise._state !== PENDING) {\n return;\n }\n promise._state = REJECTED;\n promise._result = reason;\n\n asap(publishRejection, promise);\n}\n\nfunction subscribe(parent, child, onFulfillment, onRejection) {\n var _subscribers = parent._subscribers;\n var length = _subscribers.length;\n\n\n parent._onerror = null;\n\n _subscribers[length] = child;\n _subscribers[length + FULFILLED] = onFulfillment;\n _subscribers[length + REJECTED] = onRejection;\n\n if (length === 0 && parent._state) {\n asap(publish, parent);\n }\n}\n\nfunction publish(promise) {\n var subscribers = promise._subscribers;\n var settled = promise._state;\n\n if (subscribers.length === 0) {\n return;\n }\n\n var child = void 0,\n callback = void 0,\n detail = promise._result;\n\n for (var i = 0; i < subscribers.length; i += 3) {\n child = subscribers[i];\n callback = subscribers[i + settled];\n\n if (child) {\n invokeCallback(settled, child, callback, detail);\n } else {\n callback(detail);\n }\n }\n\n promise._subscribers.length = 0;\n}\n\nfunction invokeCallback(settled, promise, callback, detail) {\n var hasCallback = isFunction(callback),\n value = void 0,\n error = void 0,\n succeeded = true;\n\n if (hasCallback) {\n try {\n value = callback(detail);\n } catch (e) {\n succeeded = false;\n error = e;\n }\n\n if (promise === value) {\n reject(promise, cannotReturnOwn());\n return;\n }\n } else {\n value = detail;\n }\n\n if (promise._state !== PENDING) {\n // noop\n } else if (hasCallback && succeeded) {\n resolve(promise, value);\n } else if (succeeded === false) {\n reject(promise, error);\n } else if (settled === FULFILLED) {\n fulfill(promise, value);\n } else if (settled === REJECTED) {\n reject(promise, value);\n }\n}\n\nfunction initializePromise(promise, resolver) {\n try {\n resolver(function resolvePromise(value) {\n resolve(promise, value);\n }, function rejectPromise(reason) {\n reject(promise, reason);\n });\n } catch (e) {\n reject(promise, e);\n }\n}\n\nvar id = 0;\nfunction nextId() {\n return id++;\n}\n\nfunction makePromise(promise) {\n promise[PROMISE_ID] = id++;\n promise._state = undefined;\n promise._result = undefined;\n promise._subscribers = [];\n}\n\nfunction validationError() {\n return new Error('Array Methods must be provided an Array');\n}\n\nvar Enumerator = function () {\n function Enumerator(Constructor, input) {\n this._instanceConstructor = Constructor;\n this.promise = new Constructor(noop);\n\n if (!this.promise[PROMISE_ID]) {\n makePromise(this.promise);\n }\n\n if (isArray(input)) {\n this.length = input.length;\n this._remaining = input.length;\n\n this._result = new Array(this.length);\n\n if (this.length === 0) {\n fulfill(this.promise, this._result);\n } else {\n this.length = this.length || 0;\n this._enumerate(input);\n if (this._remaining === 0) {\n fulfill(this.promise, this._result);\n }\n }\n } else {\n reject(this.promise, validationError());\n }\n }\n\n Enumerator.prototype._enumerate = function _enumerate(input) {\n for (var i = 0; this._state === PENDING && i < input.length; i++) {\n this._eachEntry(input[i], i);\n }\n };\n\n Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {\n var c = this._instanceConstructor;\n var resolve$$1 = c.resolve;\n\n\n if (resolve$$1 === resolve$1) {\n var _then = void 0;\n var error = void 0;\n var didError = false;\n try {\n _then = entry.then;\n } catch (e) {\n didError = true;\n error = e;\n }\n\n if (_then === then && entry._state !== PENDING) {\n this._settledAt(entry._state, i, entry._result);\n } else if (typeof _then !== 'function') {\n this._remaining--;\n this._result[i] = entry;\n } else if (c === Promise$1) {\n var promise = new c(noop);\n if (didError) {\n reject(promise, error);\n } else {\n handleMaybeThenable(promise, entry, _then);\n }\n this._willSettleAt(promise, i);\n } else {\n this._willSettleAt(new c(function (resolve$$1) {\n return resolve$$1(entry);\n }), i);\n }\n } else {\n this._willSettleAt(resolve$$1(entry), i);\n }\n };\n\n Enumerator.prototype._settledAt = function _settledAt(state, i, value) {\n var promise = this.promise;\n\n\n if (promise._state === PENDING) {\n this._remaining--;\n\n if (state === REJECTED) {\n reject(promise, value);\n } else {\n this._result[i] = value;\n }\n }\n\n if (this._remaining === 0) {\n fulfill(promise, this._result);\n }\n };\n\n Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {\n var enumerator = this;\n\n subscribe(promise, undefined, function (value) {\n return enumerator._settledAt(FULFILLED, i, value);\n }, function (reason) {\n return enumerator._settledAt(REJECTED, i, reason);\n });\n };\n\n return Enumerator;\n}();\n\n/**\n `Promise.all` accepts an array of promises, and returns a new promise which\n is fulfilled with an array of fulfillment values for the passed promises, or\n rejected with the reason of the first passed promise to be rejected. It casts all\n elements of the passed iterable to promises as it runs this algorithm.\n\n Example:\n\n ```javascript\n let promise1 = resolve(1);\n let promise2 = resolve(2);\n let promise3 = resolve(3);\n let promises = [ promise1, promise2, promise3 ];\n\n Promise.all(promises).then(function(array){\n // The array here would be [ 1, 2, 3 ];\n });\n ```\n\n If any of the `promises` given to `all` are rejected, the first promise\n that is rejected will be given as an argument to the returned promises's\n rejection handler. For example:\n\n Example:\n\n ```javascript\n let promise1 = resolve(1);\n let promise2 = reject(new Error(\"2\"));\n let promise3 = reject(new Error(\"3\"));\n let promises = [ promise1, promise2, promise3 ];\n\n Promise.all(promises).then(function(array){\n // Code here never runs because there are rejected promises!\n }, function(error) {\n // error.message === \"2\"\n });\n ```\n\n @method all\n @static\n @param {Array} entries array of promises\n @param {String} label optional string for labeling the promise.\n Useful for tooling.\n @return {Promise} promise that is fulfilled when all `promises` have been\n fulfilled, or rejected if any of them become rejected.\n @static\n*/\nfunction all(entries) {\n return new Enumerator(this, entries).promise;\n}\n\n/**\n `Promise.race` returns a new promise which is settled in the same way as the\n first passed promise to settle.\n\n Example:\n\n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n\n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 2');\n }, 100);\n });\n\n Promise.race([promise1, promise2]).then(function(result){\n // result === 'promise 2' because it was resolved before promise1\n // was resolved.\n });\n ```\n\n `Promise.race` is deterministic in that only the state of the first\n settled promise matters. For example, even if other promises given to the\n `promises` array argument are resolved, but the first settled promise has\n become rejected before the other promises became fulfilled, the returned\n promise will become rejected:\n\n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n\n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n reject(new Error('promise 2'));\n }, 100);\n });\n\n Promise.race([promise1, promise2]).then(function(result){\n // Code here never runs\n }, function(reason){\n // reason.message === 'promise 2' because promise 2 became rejected before\n // promise 1 became fulfilled\n });\n ```\n\n An example real-world use case is implementing timeouts:\n\n ```javascript\n Promise.race([ajax('foo.json'), timeout(5000)])\n ```\n\n @method race\n @static\n @param {Array} promises array of promises to observe\n Useful for tooling.\n @return {Promise} a promise which settles in the same way as the first passed\n promise to settle.\n*/\nfunction race(entries) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (!isArray(entries)) {\n return new Constructor(function (_, reject) {\n return reject(new TypeError('You must pass an array to race.'));\n });\n } else {\n return new Constructor(function (resolve, reject) {\n var length = entries.length;\n for (var i = 0; i < length; i++) {\n Constructor.resolve(entries[i]).then(resolve, reject);\n }\n });\n }\n}\n\n/**\n `Promise.reject` returns a promise rejected with the passed `reason`.\n It is shorthand for the following:\n\n ```javascript\n let promise = new Promise(function(resolve, reject){\n reject(new Error('WHOOPS'));\n });\n\n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n\n Instead of writing the above, your code now simply becomes the following:\n\n ```javascript\n let promise = Promise.reject(new Error('WHOOPS'));\n\n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n\n @method reject\n @static\n @param {Any} reason value that the returned promise will be rejected with.\n Useful for tooling.\n @return {Promise} a promise rejected with the given `reason`.\n*/\nfunction reject$1(reason) {\n /*jshint validthis:true */\n var Constructor = this;\n var promise = new Constructor(noop);\n reject(promise, reason);\n return promise;\n}\n\nfunction needsResolver() {\n throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');\n}\n\nfunction needsNew() {\n throw new TypeError(\"Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.\");\n}\n\n/**\n Promise objects represent the eventual result of an asynchronous operation. The\n primary way of interacting with a promise is through its `then` method, which\n registers callbacks to receive either a promise's eventual value or the reason\n why the promise cannot be fulfilled.\n\n Terminology\n -----------\n\n - `promise` is an object or function with a `then` method whose behavior conforms to this specification.\n - `thenable` is an object or function that defines a `then` method.\n - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).\n - `exception` is a value that is thrown using the throw statement.\n - `reason` is a value that indicates why a promise was rejected.\n - `settled` the final resting state of a promise, fulfilled or rejected.\n\n A promise can be in one of three states: pending, fulfilled, or rejected.\n\n Promises that are fulfilled have a fulfillment value and are in the fulfilled\n state. Promises that are rejected have a rejection reason and are in the\n rejected state. A fulfillment value is never a thenable.\n\n Promises can also be said to *resolve* a value. If this value is also a\n promise, then the original promise's settled state will match the value's\n settled state. So a promise that *resolves* a promise that rejects will\n itself reject, and a promise that *resolves* a promise that fulfills will\n itself fulfill.\n\n\n Basic Usage:\n ------------\n\n ```js\n let promise = new Promise(function(resolve, reject) {\n // on success\n resolve(value);\n\n // on failure\n reject(reason);\n });\n\n promise.then(function(value) {\n // on fulfillment\n }, function(reason) {\n // on rejection\n });\n ```\n\n Advanced Usage:\n ---------------\n\n Promises shine when abstracting away asynchronous interactions such as\n `XMLHttpRequest`s.\n\n ```js\n function getJSON(url) {\n return new Promise(function(resolve, reject){\n let xhr = new XMLHttpRequest();\n\n xhr.open('GET', url);\n xhr.onreadystatechange = handler;\n xhr.responseType = 'json';\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send();\n\n function handler() {\n if (this.readyState === this.DONE) {\n if (this.status === 200) {\n resolve(this.response);\n } else {\n reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));\n }\n }\n };\n });\n }\n\n getJSON('/posts.json').then(function(json) {\n // on fulfillment\n }, function(reason) {\n // on rejection\n });\n ```\n\n Unlike callbacks, promises are great composable primitives.\n\n ```js\n Promise.all([\n getJSON('/posts'),\n getJSON('/comments')\n ]).then(function(values){\n values[0] // => postsJSON\n values[1] // => commentsJSON\n\n return values;\n });\n ```\n\n @class Promise\n @param {Function} resolver\n Useful for tooling.\n @constructor\n*/\n\nvar Promise$1 = function () {\n function Promise(resolver) {\n this[PROMISE_ID] = nextId();\n this._result = this._state = undefined;\n this._subscribers = [];\n\n if (noop !== resolver) {\n typeof resolver !== 'function' && needsResolver();\n this instanceof Promise ? initializePromise(this, resolver) : needsNew();\n }\n }\n\n /**\n The primary way of interacting with a promise is through its `then` method,\n which registers callbacks to receive either a promise's eventual value or the\n reason why the promise cannot be fulfilled.\n ```js\n findUser().then(function(user){\n // user is available\n }, function(reason){\n // user is unavailable, and you are given the reason why\n });\n ```\n Chaining\n --------\n The return value of `then` is itself a promise. This second, 'downstream'\n promise is resolved with the return value of the first promise's fulfillment\n or rejection handler, or rejected if the handler throws an exception.\n ```js\n findUser().then(function (user) {\n return user.name;\n }, function (reason) {\n return 'default name';\n }).then(function (userName) {\n // If `findUser` fulfilled, `userName` will be the user's name, otherwise it\n // will be `'default name'`\n });\n findUser().then(function (user) {\n throw new Error('Found user, but still unhappy');\n }, function (reason) {\n throw new Error('`findUser` rejected and we're unhappy');\n }).then(function (value) {\n // never reached\n }, function (reason) {\n // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.\n // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.\n });\n ```\n If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.\n ```js\n findUser().then(function (user) {\n throw new PedagogicalException('Upstream error');\n }).then(function (value) {\n // never reached\n }).then(function (value) {\n // never reached\n }, function (reason) {\n // The `PedgagocialException` is propagated all the way down to here\n });\n ```\n Assimilation\n ------------\n Sometimes the value you want to propagate to a downstream promise can only be\n retrieved asynchronously. This can be achieved by returning a promise in the\n fulfillment or rejection handler. The downstream promise will then be pending\n until the returned promise is settled. This is called *assimilation*.\n ```js\n findUser().then(function (user) {\n return findCommentsByAuthor(user);\n }).then(function (comments) {\n // The user's comments are now available\n });\n ```\n If the assimliated promise rejects, then the downstream promise will also reject.\n ```js\n findUser().then(function (user) {\n return findCommentsByAuthor(user);\n }).then(function (comments) {\n // If `findCommentsByAuthor` fulfills, we'll have the value here\n }, function (reason) {\n // If `findCommentsByAuthor` rejects, we'll have the reason here\n });\n ```\n Simple Example\n --------------\n Synchronous Example\n ```javascript\n let result;\n try {\n result = findResult();\n // success\n } catch(reason) {\n // failure\n }\n ```\n Errback Example\n ```js\n findResult(function(result, err){\n if (err) {\n // failure\n } else {\n // success\n }\n });\n ```\n Promise Example;\n ```javascript\n findResult().then(function(result){\n // success\n }, function(reason){\n // failure\n });\n ```\n Advanced Example\n --------------\n Synchronous Example\n ```javascript\n let author, books;\n try {\n author = findAuthor();\n books = findBooksByAuthor(author);\n // success\n } catch(reason) {\n // failure\n }\n ```\n Errback Example\n ```js\n function foundBooks(books) {\n }\n function failure(reason) {\n }\n findAuthor(function(author, err){\n if (err) {\n failure(err);\n // failure\n } else {\n try {\n findBoooksByAuthor(author, function(books, err) {\n if (err) {\n failure(err);\n } else {\n try {\n foundBooks(books);\n } catch(reason) {\n failure(reason);\n }\n }\n });\n } catch(error) {\n failure(err);\n }\n // success\n }\n });\n ```\n Promise Example;\n ```javascript\n findAuthor().\n then(findBooksByAuthor).\n then(function(books){\n // found books\n }).catch(function(reason){\n // something went wrong\n });\n ```\n @method then\n @param {Function} onFulfilled\n @param {Function} onRejected\n Useful for tooling.\n @return {Promise}\n */\n\n /**\n `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same\n as the catch block of a try/catch statement.\n ```js\n function findAuthor(){\n throw new Error('couldn't find that author');\n }\n // synchronous\n try {\n findAuthor();\n } catch(reason) {\n // something went wrong\n }\n // async with promises\n findAuthor().catch(function(reason){\n // something went wrong\n });\n ```\n @method catch\n @param {Function} onRejection\n Useful for tooling.\n @return {Promise}\n */\n\n\n Promise.prototype.catch = function _catch(onRejection) {\n return this.then(null, onRejection);\n };\n\n /**\n `finally` will be invoked regardless of the promise's fate just as native\n try/catch/finally behaves\n \n Synchronous example:\n \n ```js\n findAuthor() {\n if (Math.random() > 0.5) {\n throw new Error();\n }\n return new Author();\n }\n \n try {\n return findAuthor(); // succeed or fail\n } catch(error) {\n return findOtherAuther();\n } finally {\n // always runs\n // doesn't affect the return value\n }\n ```\n \n Asynchronous example:\n \n ```js\n findAuthor().catch(function(reason){\n return findOtherAuther();\n }).finally(function(){\n // author was either found, or not\n });\n ```\n \n @method finally\n @param {Function} callback\n @return {Promise}\n */\n\n\n Promise.prototype.finally = function _finally(callback) {\n var promise = this;\n var constructor = promise.constructor;\n\n if (isFunction(callback)) {\n return promise.then(function (value) {\n return constructor.resolve(callback()).then(function () {\n return value;\n });\n }, function (reason) {\n return constructor.resolve(callback()).then(function () {\n throw reason;\n });\n });\n }\n\n return promise.then(callback, callback);\n };\n\n return Promise;\n}();\n\nPromise$1.prototype.then = then;\nPromise$1.all = all;\nPromise$1.race = race;\nPromise$1.resolve = resolve$1;\nPromise$1.reject = reject$1;\nPromise$1._setScheduler = setScheduler;\nPromise$1._setAsap = setAsap;\nPromise$1._asap = asap;\n\n/*global self*/\nfunction polyfill() {\n var local = void 0;\n\n if (typeof global !== 'undefined') {\n local = global;\n } else if (typeof self !== 'undefined') {\n local = self;\n } else {\n try {\n local = Function('return this')();\n } catch (e) {\n throw new Error('polyfill failed because global object is unavailable in this environment');\n }\n }\n\n var P = local.Promise;\n\n if (P) {\n var promiseToString = null;\n try {\n promiseToString = Object.prototype.toString.call(P.resolve());\n } catch (e) {\n // silently ignored\n }\n\n if (promiseToString === '[object Promise]' && !P.cast) {\n return;\n }\n }\n\n local.Promise = Promise$1;\n}\n\n// Strange compat..\nPromise$1.polyfill = polyfill;\nPromise$1.Promise = Promise$1;\n\nreturn Promise$1;\n\n})));\n\n\n\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport LoggingControl from '../utils/logging-control.js';\nimport Polyfill from '../utils/polyfill.js';\nimport TransmuxingController from './transmuxing-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\n\n/* post message to worker:\n data: {\n cmd: string\n param: any\n }\n\n receive message from worker:\n data: {\n msg: string,\n data: any\n }\n */\n\nlet TransmuxingWorker = function (self) {\n\n let TAG = 'TransmuxingWorker';\n let controller = null;\n let logcatListener = onLogcatCallback.bind(this);\n\n Polyfill.install();\n\n self.addEventListener('message', function (e) {\n switch (e.data.cmd) {\n case 'init':\n controller = new TransmuxingController(e.data.param[0], e.data.param[1]);\n controller.on(TransmuxingEvents.IO_ERROR, onIOError.bind(this));\n controller.on(TransmuxingEvents.DEMUX_ERROR, onDemuxError.bind(this));\n controller.on(TransmuxingEvents.INIT_SEGMENT, onInitSegment.bind(this));\n controller.on(TransmuxingEvents.MEDIA_SEGMENT, onMediaSegment.bind(this));\n controller.on(TransmuxingEvents.LOADING_COMPLETE, onLoadingComplete.bind(this));\n controller.on(TransmuxingEvents.RECOVERED_EARLY_EOF, onRecoveredEarlyEof.bind(this));\n controller.on(TransmuxingEvents.MEDIA_INFO, onMediaInfo.bind(this));\n controller.on(TransmuxingEvents.METADATA_ARRIVED, onMetaDataArrived.bind(this));\n controller.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, onScriptDataArrived.bind(this));\n controller.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, onTimedID3MetadataArrived.bind(this));\n controller.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, onPESPrivateDataDescriptor.bind(this));\n controller.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, onPESPrivateDataArrived.bind(this));\n controller.on(TransmuxingEvents.STATISTICS_INFO, onStatisticsInfo.bind(this));\n controller.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, onRecommendSeekpoint.bind(this));\n break;\n case 'destroy':\n if (controller) {\n controller.destroy();\n controller = null;\n }\n self.postMessage({msg: 'destroyed'});\n break;\n case 'start':\n controller.start();\n break;\n case 'stop':\n controller.stop();\n break;\n case 'seek':\n controller.seek(e.data.param);\n break;\n case 'pause':\n controller.pause();\n break;\n case 'resume':\n controller.resume();\n break;\n case 'logging_config': {\n let config = e.data.param;\n LoggingControl.applyConfig(config);\n\n if (config.enableCallback === true) {\n LoggingControl.addLogListener(logcatListener);\n } else {\n LoggingControl.removeLogListener(logcatListener);\n }\n break;\n }\n }\n });\n\n function onInitSegment(type, initSegment) {\n let obj = {\n msg: TransmuxingEvents.INIT_SEGMENT,\n data: {\n type: type,\n data: initSegment\n }\n };\n self.postMessage(obj, [initSegment.data]); // data: ArrayBuffer\n }\n\n function onMediaSegment(type, mediaSegment) {\n let obj = {\n msg: TransmuxingEvents.MEDIA_SEGMENT,\n data: {\n type: type,\n data: mediaSegment\n }\n };\n self.postMessage(obj, [mediaSegment.data]); // data: ArrayBuffer\n }\n\n function onLoadingComplete() {\n let obj = {\n msg: TransmuxingEvents.LOADING_COMPLETE\n };\n self.postMessage(obj);\n }\n\n function onRecoveredEarlyEof() {\n let obj = {\n msg: TransmuxingEvents.RECOVERED_EARLY_EOF\n };\n self.postMessage(obj);\n }\n\n function onMediaInfo(mediaInfo) {\n let obj = {\n msg: TransmuxingEvents.MEDIA_INFO,\n data: mediaInfo\n };\n self.postMessage(obj);\n }\n\n function onMetaDataArrived(metadata) {\n let obj = {\n msg: TransmuxingEvents.METADATA_ARRIVED,\n data: metadata\n };\n self.postMessage(obj);\n }\n\n function onScriptDataArrived(data) {\n let obj = {\n msg: TransmuxingEvents.SCRIPTDATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onTimedID3MetadataArrived (data) {\n let obj = {\n msg: TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onPESPrivateDataDescriptor(data) {\n let obj = {\n msg: TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onPESPrivateDataArrived(data) {\n let obj = {\n msg: TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onStatisticsInfo(statInfo) {\n let obj = {\n msg: TransmuxingEvents.STATISTICS_INFO,\n data: statInfo\n };\n self.postMessage(obj);\n }\n\n function onIOError(type, info) {\n self.postMessage({\n msg: TransmuxingEvents.IO_ERROR,\n data: {\n type: type,\n info: info\n }\n });\n }\n\n function onDemuxError(type, info) {\n self.postMessage({\n msg: TransmuxingEvents.DEMUX_ERROR,\n data: {\n type: type,\n info: info\n }\n });\n }\n\n function onRecommendSeekpoint(milliseconds) {\n self.postMessage({\n msg: TransmuxingEvents.RECOMMEND_SEEKPOINT,\n data: milliseconds\n });\n }\n\n function onLogcatCallback(type, str) {\n self.postMessage({\n msg: 'logcat_callback',\n data: {\n type: type,\n logcat: str\n }\n });\n }\n\n};\n\nexport default TransmuxingWorker;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const defaultConfig = {\n enableWorker: false,\n enableStashBuffer: true,\n stashInitialSize: undefined,\n\n isLive: false,\n\n liveBufferLatencyChasing: false,\n liveBufferLatencyMaxLatency: 1.5,\n liveBufferLatencyMinRemain: 0.5,\n\n lazyLoad: true,\n lazyLoadMaxDuration: 3 * 60,\n lazyLoadRecoverDuration: 30,\n deferLoadAfterSourceOpen: true,\n\n // autoCleanupSourceBuffer: default as false, leave unspecified\n autoCleanupMaxBackwardDuration: 3 * 60,\n autoCleanupMinBackwardDuration: 2 * 60,\n\n statisticsInfoReportInterval: 600,\n\n fixAudioTimestampGap: true,\n\n accurateSeek: false,\n seekType: 'range', // [range, param, custom]\n seekParamStart: 'bstart',\n seekParamEnd: 'bend',\n rangeLoadZeroStart: false,\n customSeekHandler: undefined,\n reuseRedirectedURL: false,\n // referrerPolicy: leave as unspecified\n\n headers: undefined,\n customLoader: undefined\n};\n\nexport function createDefaultConfig() {\n return Object.assign({}, defaultConfig);\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport IOController from '../io/io-controller.js';\nimport {createDefaultConfig} from '../config.js';\n\nclass Features {\n\n static supportMSEH264Playback() {\n return window.MediaSource &&\n window.MediaSource.isTypeSupported('video/mp4; codecs=\"avc1.42E01E,mp4a.40.2\"');\n }\n\n static supportNetworkStreamIO() {\n let ioctl = new IOController({}, createDefaultConfig());\n let loaderType = ioctl.loaderType;\n ioctl.destroy();\n return loaderType == 'fetch-stream-loader' || loaderType == 'xhr-moz-chunked-loader';\n }\n\n static getNetworkLoaderTypeName() {\n let ioctl = new IOController({}, createDefaultConfig());\n let loaderType = ioctl.loaderType;\n ioctl.destroy();\n return loaderType;\n }\n\n static supportNativeMediaPlayback(mimeType) {\n if (Features.videoElement == undefined) {\n Features.videoElement = window.document.createElement('video');\n }\n let canPlay = Features.videoElement.canPlayType(mimeType);\n return canPlay === 'probably' || canPlay == 'maybe';\n }\n\n static getFeatureList() {\n let features = {\n msePlayback: false,\n mseLivePlayback: false,\n networkStreamIO: false,\n networkLoaderName: '',\n nativeMP4H264Playback: false,\n nativeWebmVP8Playback: false,\n nativeWebmVP9Playback: false\n };\n\n features.msePlayback = Features.supportMSEH264Playback();\n features.networkStreamIO = Features.supportNetworkStreamIO();\n features.networkLoaderName = Features.getNetworkLoaderTypeName();\n features.mseLivePlayback = features.msePlayback && features.networkStreamIO;\n features.nativeMP4H264Playback = Features.supportNativeMediaPlayback('video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"');\n features.nativeWebmVP8Playback = Features.supportNativeMediaPlayback('video/webm; codecs=\"vp8.0, vorbis\"');\n features.nativeWebmVP9Playback = Features.supportNativeMediaPlayback('video/webm; codecs=\"vp9\"');\n\n return features;\n }\n\n}\n\nexport default Features;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PlayerEvents = {\n ERROR: 'error',\n LOADING_COMPLETE: 'loading_complete',\n RECOVERED_EARLY_EOF: 'recovered_early_eof',\n MEDIA_INFO: 'media_info',\n METADATA_ARRIVED: 'metadata_arrived',\n SCRIPTDATA_ARRIVED: 'scriptdata_arrived',\n TIMED_ID3_METADATA_ARRIVED: 'timed_id3_metadata_arrived',\n PES_PRIVATE_DATA_DESCRIPTOR: 'pes_private_data_descriptor',\n PES_PRIVATE_DATA_ARRIVED: 'pes_private_data_arrived',\n STATISTICS_INFO: 'statistics_info'\n};\n\nexport default PlayerEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport work from 'webworkify-webpack';\nimport Log from '../utils/logger.js';\nimport LoggingControl from '../utils/logging-control.js';\nimport TransmuxingController from './transmuxing-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\nimport TransmuxingWorker from './transmuxing-worker.js';\nimport MediaInfo from './media-info.js';\n\nclass Transmuxer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'Transmuxer';\n this._emitter = new EventEmitter();\n\n if (config.enableWorker && typeof (Worker) !== 'undefined') {\n try {\n this._worker = work(require.resolve('./transmuxing-worker'));\n this._workerDestroying = false;\n this._worker.addEventListener('message', this._onWorkerMessage.bind(this));\n this._worker.postMessage({cmd: 'init', param: [mediaDataSource, config]});\n this.e = {\n onLoggingConfigChanged: this._onLoggingConfigChanged.bind(this)\n };\n LoggingControl.registerListener(this.e.onLoggingConfigChanged);\n this._worker.postMessage({cmd: 'logging_config', param: LoggingControl.getConfig()});\n } catch (error) {\n Log.e(this.TAG, 'Error while initialize transmuxing worker, fallback to inline transmuxing');\n this._worker = null;\n this._controller = new TransmuxingController(mediaDataSource, config);\n }\n } else {\n this._controller = new TransmuxingController(mediaDataSource, config);\n }\n\n if (this._controller) {\n let ctl = this._controller;\n ctl.on(TransmuxingEvents.IO_ERROR, this._onIOError.bind(this));\n ctl.on(TransmuxingEvents.DEMUX_ERROR, this._onDemuxError.bind(this));\n ctl.on(TransmuxingEvents.INIT_SEGMENT, this._onInitSegment.bind(this));\n ctl.on(TransmuxingEvents.MEDIA_SEGMENT, this._onMediaSegment.bind(this));\n ctl.on(TransmuxingEvents.LOADING_COMPLETE, this._onLoadingComplete.bind(this));\n ctl.on(TransmuxingEvents.RECOVERED_EARLY_EOF, this._onRecoveredEarlyEof.bind(this));\n ctl.on(TransmuxingEvents.MEDIA_INFO, this._onMediaInfo.bind(this));\n ctl.on(TransmuxingEvents.METADATA_ARRIVED, this._onMetaDataArrived.bind(this));\n ctl.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, this._onScriptDataArrived.bind(this));\n ctl.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, this._onTimedID3MetadataArrived.bind(this));\n ctl.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, this._onPESPrivateDataDescriptor.bind(this));\n ctl.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, this._onPESPrivateDataArrived.bind(this));\n ctl.on(TransmuxingEvents.STATISTICS_INFO, this._onStatisticsInfo.bind(this));\n ctl.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, this._onRecommendSeekpoint.bind(this));\n }\n }\n\n destroy() {\n if (this._worker) {\n if (!this._workerDestroying) {\n this._workerDestroying = true;\n this._worker.postMessage({cmd: 'destroy'});\n LoggingControl.removeListener(this.e.onLoggingConfigChanged);\n this.e = null;\n }\n } else {\n this._controller.destroy();\n this._controller = null;\n }\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n hasWorker() {\n return this._worker != null;\n }\n\n open() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'start'});\n } else {\n this._controller.start();\n }\n }\n\n close() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'stop'});\n } else {\n this._controller.stop();\n }\n }\n\n seek(milliseconds) {\n if (this._worker) {\n this._worker.postMessage({cmd: 'seek', param: milliseconds});\n } else {\n this._controller.seek(milliseconds);\n }\n }\n\n pause() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'pause'});\n } else {\n this._controller.pause();\n }\n }\n\n resume() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'resume'});\n } else {\n this._controller.resume();\n }\n }\n\n _onInitSegment(type, initSegment) {\n // do async invoke\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.INIT_SEGMENT, type, initSegment);\n });\n }\n\n _onMediaSegment(type, mediaSegment) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.MEDIA_SEGMENT, type, mediaSegment);\n });\n }\n\n _onLoadingComplete() {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.LOADING_COMPLETE);\n });\n }\n\n _onRecoveredEarlyEof() {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.RECOVERED_EARLY_EOF);\n });\n }\n\n _onMediaInfo(mediaInfo) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.MEDIA_INFO, mediaInfo);\n });\n }\n\n _onMetaDataArrived(metadata) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.METADATA_ARRIVED, metadata);\n });\n }\n\n _onScriptDataArrived(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.SCRIPTDATA_ARRIVED, data);\n });\n }\n\n _onTimedID3MetadataArrived (data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, data);\n })\n }\n\n _onPESPrivateDataDescriptor(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, data);\n });\n }\n\n _onPESPrivateDataArrived(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, data);\n });\n }\n\n _onStatisticsInfo(statisticsInfo) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.STATISTICS_INFO, statisticsInfo);\n });\n }\n\n _onIOError(type, info) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.IO_ERROR, type, info);\n });\n }\n\n _onDemuxError(type, info) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, type, info);\n });\n }\n\n _onRecommendSeekpoint(milliseconds) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.RECOMMEND_SEEKPOINT, milliseconds);\n });\n }\n\n _onLoggingConfigChanged(config) {\n if (this._worker) {\n this._worker.postMessage({cmd: 'logging_config', param: config});\n }\n }\n\n _onWorkerMessage(e) {\n let message = e.data;\n let data = message.data;\n\n if (message.msg === 'destroyed' || this._workerDestroying) {\n this._workerDestroying = false;\n this._worker.terminate();\n this._worker = null;\n return;\n }\n\n switch (message.msg) {\n case TransmuxingEvents.INIT_SEGMENT:\n case TransmuxingEvents.MEDIA_SEGMENT:\n this._emitter.emit(message.msg, data.type, data.data);\n break;\n case TransmuxingEvents.LOADING_COMPLETE:\n case TransmuxingEvents.RECOVERED_EARLY_EOF:\n this._emitter.emit(message.msg);\n break;\n case TransmuxingEvents.MEDIA_INFO:\n Object.setPrototypeOf(data, MediaInfo.prototype);\n this._emitter.emit(message.msg, data);\n break;\n case TransmuxingEvents.METADATA_ARRIVED:\n case TransmuxingEvents.SCRIPTDATA_ARRIVED:\n case TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED:\n case TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR:\n case TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED:\n case TransmuxingEvents.STATISTICS_INFO:\n this._emitter.emit(message.msg, data);\n break;\n case TransmuxingEvents.IO_ERROR:\n case TransmuxingEvents.DEMUX_ERROR:\n this._emitter.emit(message.msg, data.type, data.info);\n break;\n case TransmuxingEvents.RECOMMEND_SEEKPOINT:\n this._emitter.emit(message.msg, data);\n break;\n case 'logcat_callback':\n Log.emitter.emit('log', data.type, data.logcat);\n break;\n default:\n break;\n }\n }\n\n}\n\nexport default Transmuxer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst MSEEvents = {\n ERROR: 'error',\n SOURCE_OPEN: 'source_open',\n UPDATE_END: 'update_end',\n BUFFER_FULL: 'buffer_full'\n};\n\nexport default MSEEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport MSEEvents from './mse-events.js';\nimport {SampleInfo, IDRSampleList} from './media-segment-info.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\n// Media Source Extensions controller\nclass MSEController {\n\n constructor(config) {\n this.TAG = 'MSEController';\n\n this._config = config;\n this._emitter = new EventEmitter();\n\n if (this._config.isLive && this._config.autoCleanupSourceBuffer == undefined) {\n // For live stream, do auto cleanup by default\n this._config.autoCleanupSourceBuffer = true;\n }\n\n this.e = {\n onSourceOpen: this._onSourceOpen.bind(this),\n onSourceEnded: this._onSourceEnded.bind(this),\n onSourceClose: this._onSourceClose.bind(this),\n onSourceBufferError: this._onSourceBufferError.bind(this),\n onSourceBufferUpdateEnd: this._onSourceBufferUpdateEnd.bind(this)\n };\n\n this._mediaSource = null;\n this._mediaSourceObjectURL = null;\n this._mediaElement = null;\n\n this._isBufferFull = false;\n this._hasPendingEos = false;\n\n this._requireSetMediaDuration = false;\n this._pendingMediaDuration = 0;\n\n this._pendingSourceBufferInit = [];\n this._mimeTypes = {\n video: null,\n audio: null\n };\n this._sourceBuffers = {\n video: null,\n audio: null\n };\n this._lastInitSegments = {\n video: null,\n audio: null\n };\n this._pendingSegments = {\n video: [],\n audio: []\n };\n this._pendingRemoveRanges = {\n video: [],\n audio: []\n };\n this._idrList = new IDRSampleList();\n }\n\n destroy() {\n if (this._mediaElement || this._mediaSource) {\n this.detachMediaElement();\n }\n this.e = null;\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n if (this._mediaSource) {\n throw new IllegalStateException('MediaSource has been attached to an HTMLMediaElement!');\n }\n let ms = this._mediaSource = new window.MediaSource();\n ms.addEventListener('sourceopen', this.e.onSourceOpen);\n ms.addEventListener('sourceended', this.e.onSourceEnded);\n ms.addEventListener('sourceclose', this.e.onSourceClose);\n\n this._mediaElement = mediaElement;\n this._mediaSourceObjectURL = window.URL.createObjectURL(this._mediaSource);\n mediaElement.src = this._mediaSourceObjectURL;\n }\n\n detachMediaElement() {\n if (this._mediaSource) {\n let ms = this._mediaSource;\n for (let type in this._sourceBuffers) {\n // pending segments should be discard\n let ps = this._pendingSegments[type];\n ps.splice(0, ps.length);\n this._pendingSegments[type] = null;\n this._pendingRemoveRanges[type] = null;\n this._lastInitSegments[type] = null;\n\n // remove all sourcebuffers\n let sb = this._sourceBuffers[type];\n if (sb) {\n if (ms.readyState !== 'closed') {\n // ms edge can throw an error: Unexpected call to method or property access\n try {\n ms.removeSourceBuffer(sb);\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n sb.removeEventListener('error', this.e.onSourceBufferError);\n sb.removeEventListener('updateend', this.e.onSourceBufferUpdateEnd);\n }\n this._mimeTypes[type] = null;\n this._sourceBuffers[type] = null;\n }\n }\n if (ms.readyState === 'open') {\n try {\n ms.endOfStream();\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n }\n ms.removeEventListener('sourceopen', this.e.onSourceOpen);\n ms.removeEventListener('sourceended', this.e.onSourceEnded);\n ms.removeEventListener('sourceclose', this.e.onSourceClose);\n this._pendingSourceBufferInit = [];\n this._isBufferFull = false;\n this._idrList.clear();\n this._mediaSource = null;\n }\n\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n this._mediaElement = null;\n }\n if (this._mediaSourceObjectURL) {\n window.URL.revokeObjectURL(this._mediaSourceObjectURL);\n this._mediaSourceObjectURL = null;\n }\n }\n\n appendInitSegment(initSegment, deferred) {\n if (!this._mediaSource || this._mediaSource.readyState !== 'open') {\n // sourcebuffer creation requires mediaSource.readyState === 'open'\n // so we defer the sourcebuffer creation, until sourceopen event triggered\n this._pendingSourceBufferInit.push(initSegment);\n // make sure that this InitSegment is in the front of pending segments queue\n this._pendingSegments[initSegment.type].push(initSegment);\n return;\n }\n\n let is = initSegment;\n let mimeType = `${is.container}`;\n if (is.codec && is.codec.length > 0) {\n mimeType += `;codecs=${is.codec}`;\n }\n\n let firstInitSegment = false;\n\n Log.v(this.TAG, 'Received Initialization Segment, mimeType: ' + mimeType);\n this._lastInitSegments[is.type] = is;\n\n if (mimeType !== this._mimeTypes[is.type]) {\n if (!this._mimeTypes[is.type]) { // empty, first chance create sourcebuffer\n firstInitSegment = true;\n try {\n let sb = this._sourceBuffers[is.type] = this._mediaSource.addSourceBuffer(mimeType);\n sb.addEventListener('error', this.e.onSourceBufferError);\n sb.addEventListener('updateend', this.e.onSourceBufferUpdateEnd);\n } catch (error) {\n Log.e(this.TAG, error.message);\n this._emitter.emit(MSEEvents.ERROR, {code: error.code, msg: error.message});\n return;\n }\n } else {\n Log.v(this.TAG, `Notice: ${is.type} mimeType changed, origin: ${this._mimeTypes[is.type]}, target: ${mimeType}`);\n }\n this._mimeTypes[is.type] = mimeType;\n }\n\n if (!deferred) {\n // deferred means this InitSegment has been pushed to pendingSegments queue\n this._pendingSegments[is.type].push(is);\n }\n if (!firstInitSegment) { // append immediately only if init segment in subsequence\n if (this._sourceBuffers[is.type] && !this._sourceBuffers[is.type].updating) {\n this._doAppendSegments();\n }\n }\n if (Browser.safari && is.container === 'audio/mpeg' && is.mediaDuration > 0) {\n // 'audio/mpeg' track under Safari may cause MediaElement's duration to be NaN\n // Manually correct MediaSource.duration to make progress bar seekable, and report right duration\n this._requireSetMediaDuration = true;\n this._pendingMediaDuration = is.mediaDuration / 1000; // in seconds\n this._updateMediaSourceDuration();\n }\n }\n\n appendMediaSegment(mediaSegment) {\n let ms = mediaSegment;\n this._pendingSegments[ms.type].push(ms);\n\n if (this._config.autoCleanupSourceBuffer && this._needCleanupSourceBuffer()) {\n this._doCleanupSourceBuffer();\n }\n\n let sb = this._sourceBuffers[ms.type];\n if (sb && !sb.updating && !this._hasPendingRemoveRanges()) {\n this._doAppendSegments();\n }\n }\n\n seek(seconds) {\n // remove all appended buffers\n for (let type in this._sourceBuffers) {\n if (!this._sourceBuffers[type]) {\n continue;\n }\n\n // abort current buffer append algorithm\n let sb = this._sourceBuffers[type];\n if (this._mediaSource.readyState === 'open') {\n try {\n // If range removal algorithm is running, InvalidStateError will be throwed\n // Ignore it.\n sb.abort();\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n }\n\n // IDRList should be clear\n this._idrList.clear();\n\n // pending segments should be discard\n let ps = this._pendingSegments[type];\n ps.splice(0, ps.length);\n\n if (this._mediaSource.readyState === 'closed') {\n // Parent MediaSource object has been detached from HTMLMediaElement\n continue;\n }\n\n // record ranges to be remove from SourceBuffer\n for (let i = 0; i < sb.buffered.length; i++) {\n let start = sb.buffered.start(i);\n let end = sb.buffered.end(i);\n this._pendingRemoveRanges[type].push({start, end});\n }\n\n // if sb is not updating, let's remove ranges now!\n if (!sb.updating) {\n this._doRemoveRanges();\n }\n\n // Safari 10 may get InvalidStateError in the later appendBuffer() after SourceBuffer.remove() call\n // Internal parser's state may be invalid at this time. Re-append last InitSegment to workaround.\n // Related issue: https://bugs.webkit.org/show_bug.cgi?id=159230\n if (Browser.safari) {\n let lastInitSegment = this._lastInitSegments[type];\n if (lastInitSegment) {\n this._pendingSegments[type].push(lastInitSegment);\n if (!sb.updating) {\n this._doAppendSegments();\n }\n }\n }\n }\n }\n\n endOfStream() {\n let ms = this._mediaSource;\n let sb = this._sourceBuffers;\n if (!ms || ms.readyState !== 'open') {\n if (ms && ms.readyState === 'closed' && this._hasPendingSegments()) {\n // If MediaSource hasn't turned into open state, and there're pending segments\n // Mark pending endOfStream, defer call until all pending segments appended complete\n this._hasPendingEos = true;\n }\n return;\n }\n if (sb.video && sb.video.updating || sb.audio && sb.audio.updating) {\n // If any sourcebuffer is updating, defer endOfStream operation\n // See _onSourceBufferUpdateEnd()\n this._hasPendingEos = true;\n } else {\n this._hasPendingEos = false;\n // Notify media data loading complete\n // This is helpful for correcting total duration to match last media segment\n // Otherwise MediaElement's ended event may not be triggered\n ms.endOfStream();\n }\n }\n\n getNearestKeyframe(dts) {\n return this._idrList.getLastSyncPointBeforeDts(dts);\n }\n\n _needCleanupSourceBuffer() {\n if (!this._config.autoCleanupSourceBuffer) {\n return false;\n }\n\n let currentTime = this._mediaElement.currentTime;\n\n for (let type in this._sourceBuffers) {\n let sb = this._sourceBuffers[type];\n if (sb) {\n let buffered = sb.buffered;\n if (buffered.length >= 1) {\n if (currentTime - buffered.start(0) >= this._config.autoCleanupMaxBackwardDuration) {\n return true;\n }\n }\n }\n }\n\n return false;\n }\n\n _doCleanupSourceBuffer() {\n let currentTime = this._mediaElement.currentTime;\n\n for (let type in this._sourceBuffers) {\n let sb = this._sourceBuffers[type];\n if (sb) {\n let buffered = sb.buffered;\n let doRemove = false;\n\n for (let i = 0; i < buffered.length; i++) {\n let start = buffered.start(i);\n let end = buffered.end(i);\n\n if (start <= currentTime && currentTime < end + 3) { // padding 3 seconds\n if (currentTime - start >= this._config.autoCleanupMaxBackwardDuration) {\n doRemove = true;\n let removeEnd = currentTime - this._config.autoCleanupMinBackwardDuration;\n this._pendingRemoveRanges[type].push({start: start, end: removeEnd});\n }\n } else if (end < currentTime) {\n doRemove = true;\n this._pendingRemoveRanges[type].push({start: start, end: end});\n }\n }\n\n if (doRemove && !sb.updating) {\n this._doRemoveRanges();\n }\n }\n }\n }\n\n _updateMediaSourceDuration() {\n let sb = this._sourceBuffers;\n if (this._mediaElement.readyState === 0 || this._mediaSource.readyState !== 'open') {\n return;\n }\n if ((sb.video && sb.video.updating) || (sb.audio && sb.audio.updating)) {\n return;\n }\n\n let current = this._mediaSource.duration;\n let target = this._pendingMediaDuration;\n\n if (target > 0 && (isNaN(current) || target > current)) {\n Log.v(this.TAG, `Update MediaSource duration from ${current} to ${target}`);\n this._mediaSource.duration = target;\n }\n\n this._requireSetMediaDuration = false;\n this._pendingMediaDuration = 0;\n }\n\n _doRemoveRanges() {\n for (let type in this._pendingRemoveRanges) {\n if (!this._sourceBuffers[type] || this._sourceBuffers[type].updating) {\n continue;\n }\n let sb = this._sourceBuffers[type];\n let ranges = this._pendingRemoveRanges[type];\n while (ranges.length && !sb.updating) {\n let range = ranges.shift();\n sb.remove(range.start, range.end);\n }\n }\n }\n\n _doAppendSegments() {\n let pendingSegments = this._pendingSegments;\n\n for (let type in pendingSegments) {\n if (!this._sourceBuffers[type] || this._sourceBuffers[type].updating) {\n continue;\n }\n\n if (pendingSegments[type].length > 0) {\n let segment = pendingSegments[type].shift();\n\n if (segment.timestampOffset) {\n // For MPEG audio stream in MSE, if unbuffered-seeking occurred\n // We need explicitly set timestampOffset to the desired point in timeline for mpeg SourceBuffer.\n let currentOffset = this._sourceBuffers[type].timestampOffset;\n let targetOffset = segment.timestampOffset / 1000; // in seconds\n\n let delta = Math.abs(currentOffset - targetOffset);\n if (delta > 0.1) { // If time delta > 100ms\n Log.v(this.TAG, `Update MPEG audio timestampOffset from ${currentOffset} to ${targetOffset}`);\n this._sourceBuffers[type].timestampOffset = targetOffset;\n }\n delete segment.timestampOffset;\n }\n\n if (!segment.data || segment.data.byteLength === 0) {\n // Ignore empty buffer\n continue;\n }\n\n try {\n this._sourceBuffers[type].appendBuffer(segment.data);\n this._isBufferFull = false;\n if (type === 'video' && segment.hasOwnProperty('info')) {\n this._idrList.appendArray(segment.info.syncPoints);\n }\n } catch (error) {\n this._pendingSegments[type].unshift(segment);\n if (error.code === 22) { // QuotaExceededError\n /* Notice that FireFox may not throw QuotaExceededError if SourceBuffer is full\n * Currently we can only do lazy-load to avoid SourceBuffer become scattered.\n * SourceBuffer eviction policy may be changed in future version of FireFox.\n *\n * Related issues:\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1279885\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1280023\n */\n\n // report buffer full, abort network IO\n if (!this._isBufferFull) {\n this._emitter.emit(MSEEvents.BUFFER_FULL);\n }\n this._isBufferFull = true;\n } else {\n Log.e(this.TAG, error.message);\n this._emitter.emit(MSEEvents.ERROR, {code: error.code, msg: error.message});\n }\n }\n }\n }\n }\n\n _onSourceOpen() {\n Log.v(this.TAG, 'MediaSource onSourceOpen');\n this._mediaSource.removeEventListener('sourceopen', this.e.onSourceOpen);\n // deferred sourcebuffer creation / initialization\n if (this._pendingSourceBufferInit.length > 0) {\n let pendings = this._pendingSourceBufferInit;\n while (pendings.length) {\n let segment = pendings.shift();\n this.appendInitSegment(segment, true);\n }\n }\n // there may be some pending media segments, append them\n if (this._hasPendingSegments()) {\n this._doAppendSegments();\n }\n this._emitter.emit(MSEEvents.SOURCE_OPEN);\n }\n\n _onSourceEnded() {\n // fired on endOfStream\n Log.v(this.TAG, 'MediaSource onSourceEnded');\n }\n\n _onSourceClose() {\n // fired on detaching from media element\n Log.v(this.TAG, 'MediaSource onSourceClose');\n if (this._mediaSource && this.e != null) {\n this._mediaSource.removeEventListener('sourceopen', this.e.onSourceOpen);\n this._mediaSource.removeEventListener('sourceended', this.e.onSourceEnded);\n this._mediaSource.removeEventListener('sourceclose', this.e.onSourceClose);\n }\n }\n\n _hasPendingSegments() {\n let ps = this._pendingSegments;\n return ps.video.length > 0 || ps.audio.length > 0;\n }\n\n _hasPendingRemoveRanges() {\n let prr = this._pendingRemoveRanges;\n return prr.video.length > 0 || prr.audio.length > 0;\n }\n\n _onSourceBufferUpdateEnd() {\n if (this._requireSetMediaDuration) {\n this._updateMediaSourceDuration();\n } else if (this._hasPendingRemoveRanges()) {\n this._doRemoveRanges();\n } else if (this._hasPendingSegments()) {\n this._doAppendSegments();\n } else if (this._hasPendingEos) {\n this.endOfStream();\n }\n this._emitter.emit(MSEEvents.UPDATE_END);\n }\n\n _onSourceBufferError(e) {\n Log.e(this.TAG, `SourceBuffer Error: ${e}`);\n // this error might not always be fatal, just ignore it\n }\n\n}\n\nexport default MSEController;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {LoaderErrors} from '../io/loader.js';\nimport DemuxErrors from '../demux/demux-errors.js';\n\nexport const ErrorTypes = {\n NETWORK_ERROR: 'NetworkError',\n MEDIA_ERROR: 'MediaError',\n OTHER_ERROR: 'OtherError'\n};\n\nexport const ErrorDetails = {\n NETWORK_EXCEPTION: LoaderErrors.EXCEPTION,\n NETWORK_STATUS_CODE_INVALID: LoaderErrors.HTTP_STATUS_CODE_INVALID,\n NETWORK_TIMEOUT: LoaderErrors.CONNECTING_TIMEOUT,\n NETWORK_UNRECOVERABLE_EARLY_EOF: LoaderErrors.UNRECOVERABLE_EARLY_EOF,\n\n MEDIA_MSE_ERROR: 'MediaMSEError',\n\n MEDIA_FORMAT_ERROR: DemuxErrors.FORMAT_ERROR,\n MEDIA_FORMAT_UNSUPPORTED: DemuxErrors.FORMAT_UNSUPPORTED,\n MEDIA_CODEC_UNSUPPORTED: DemuxErrors.CODEC_UNSUPPORTED\n};","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport PlayerEvents from './player-events.js';\nimport Transmuxer from '../core/transmuxer.js';\nimport TransmuxingEvents from '../core/transmuxing-events.js';\nimport MSEController from '../core/mse-controller.js';\nimport MSEEvents from '../core/mse-events.js';\nimport {ErrorTypes, ErrorDetails} from './player-errors.js';\nimport {createDefaultConfig} from '../config.js';\nimport {InvalidArgumentException, IllegalStateException} from '../utils/exception.js';\n\nclass MSEPlayer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'MSEPlayer';\n this._type = 'MSEPlayer';\n this._emitter = new EventEmitter();\n\n this._config = createDefaultConfig();\n if (typeof config === 'object') {\n Object.assign(this._config, config);\n }\n\n let typeLowerCase = mediaDataSource.type.toLowerCase();\n if (typeLowerCase !== 'mse'\n && typeLowerCase !== 'mpegts'\n && typeLowerCase !== 'm2ts'\n && typeLowerCase !== 'flv') {\n throw new InvalidArgumentException('MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!');\n }\n\n if (mediaDataSource.isLive === true) {\n this._config.isLive = true;\n }\n\n this.e = {\n onvLoadedMetadata: this._onvLoadedMetadata.bind(this),\n onvSeeking: this._onvSeeking.bind(this),\n onvCanPlay: this._onvCanPlay.bind(this),\n onvStalled: this._onvStalled.bind(this),\n onvProgress: this._onvProgress.bind(this)\n };\n\n if (self.performance && self.performance.now) {\n this._now = self.performance.now.bind(self.performance);\n } else {\n this._now = Date.now;\n }\n\n this._pendingSeekTime = null; // in seconds\n this._requestSetTime = false;\n this._seekpointRecord = null;\n this._progressChecker = null;\n\n this._mediaDataSource = mediaDataSource;\n this._mediaElement = null;\n this._msectl = null;\n this._transmuxer = null;\n\n this._mseSourceOpened = false;\n this._hasPendingLoad = false;\n this._receivedCanPlay = false;\n\n this._mediaInfo = null;\n this._statisticsInfo = null;\n\n let chromeNeedIDRFix = (Browser.chrome &&\n (Browser.version.major < 50 ||\n (Browser.version.major === 50 && Browser.version.build < 2661)));\n this._alwaysSeekKeyframe = (chromeNeedIDRFix || Browser.msedge || Browser.msie) ? true : false;\n\n if (this._alwaysSeekKeyframe) {\n this._config.accurateSeek = false;\n }\n }\n\n destroy() {\n if (this._progressChecker != null) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n }\n if (this._transmuxer) {\n this.unload();\n }\n if (this._mediaElement) {\n this.detachMediaElement();\n }\n this.e = null;\n this._mediaDataSource = null;\n\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n if (event === PlayerEvents.MEDIA_INFO) {\n if (this._mediaInfo != null) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n });\n }\n } else if (event === PlayerEvents.STATISTICS_INFO) {\n if (this._statisticsInfo != null) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n });\n }\n }\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n this._mediaElement = mediaElement;\n mediaElement.addEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n mediaElement.addEventListener('seeking', this.e.onvSeeking);\n mediaElement.addEventListener('canplay', this.e.onvCanPlay);\n mediaElement.addEventListener('stalled', this.e.onvStalled);\n mediaElement.addEventListener('progress', this.e.onvProgress);\n\n this._msectl = new MSEController(this._config);\n\n this._msectl.on(MSEEvents.UPDATE_END, this._onmseUpdateEnd.bind(this));\n this._msectl.on(MSEEvents.BUFFER_FULL, this._onmseBufferFull.bind(this));\n this._msectl.on(MSEEvents.SOURCE_OPEN, () => {\n this._mseSourceOpened = true;\n if (this._hasPendingLoad) {\n this._hasPendingLoad = false;\n this.load();\n }\n });\n this._msectl.on(MSEEvents.ERROR, (info) => {\n this._emitter.emit(PlayerEvents.ERROR,\n ErrorTypes.MEDIA_ERROR,\n ErrorDetails.MEDIA_MSE_ERROR,\n info\n );\n });\n\n this._msectl.attachMediaElement(mediaElement);\n\n if (this._pendingSeekTime != null) {\n try {\n mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n } catch (e) {\n // IE11 may throw InvalidStateError if readyState === 0\n // We can defer set currentTime operation after loadedmetadata\n }\n }\n }\n\n detachMediaElement() {\n if (this._mediaElement) {\n this._msectl.detachMediaElement();\n this._mediaElement.removeEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n this._mediaElement.removeEventListener('seeking', this.e.onvSeeking);\n this._mediaElement.removeEventListener('canplay', this.e.onvCanPlay);\n this._mediaElement.removeEventListener('stalled', this.e.onvStalled);\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n this._mediaElement = null;\n }\n if (this._msectl) {\n this._msectl.destroy();\n this._msectl = null;\n }\n }\n\n load() {\n if (!this._mediaElement) {\n throw new IllegalStateException('HTMLMediaElement must be attached before load()!');\n }\n if (this._transmuxer) {\n throw new IllegalStateException('MSEPlayer.load() has been called, please call unload() first!');\n }\n if (this._hasPendingLoad) {\n return;\n }\n\n if (this._config.deferLoadAfterSourceOpen && this._mseSourceOpened === false) {\n this._hasPendingLoad = true;\n return;\n }\n\n if (this._mediaElement.readyState > 0) {\n this._requestSetTime = true;\n // IE11 may throw InvalidStateError if readyState === 0\n this._mediaElement.currentTime = 0;\n }\n\n this._transmuxer = new Transmuxer(this._mediaDataSource, this._config);\n\n this._transmuxer.on(TransmuxingEvents.INIT_SEGMENT, (type, is) => {\n this._msectl.appendInitSegment(is);\n });\n this._transmuxer.on(TransmuxingEvents.MEDIA_SEGMENT, (type, ms) => {\n this._msectl.appendMediaSegment(ms);\n\n // lazyLoad check\n if (this._config.lazyLoad && !this._config.isLive) {\n let currentTime = this._mediaElement.currentTime;\n if (ms.info.endDts >= (currentTime + this._config.lazyLoadMaxDuration) * 1000) {\n if (this._progressChecker == null) {\n Log.v(this.TAG, 'Maximum buffering duration exceeded, suspend transmuxing task');\n this._suspendTransmuxer();\n }\n }\n }\n });\n this._transmuxer.on(TransmuxingEvents.LOADING_COMPLETE, () => {\n this._msectl.endOfStream();\n this._emitter.emit(PlayerEvents.LOADING_COMPLETE);\n });\n this._transmuxer.on(TransmuxingEvents.RECOVERED_EARLY_EOF, () => {\n this._emitter.emit(PlayerEvents.RECOVERED_EARLY_EOF);\n });\n this._transmuxer.on(TransmuxingEvents.IO_ERROR, (detail, info) => {\n this._emitter.emit(PlayerEvents.ERROR, ErrorTypes.NETWORK_ERROR, detail, info);\n });\n this._transmuxer.on(TransmuxingEvents.DEMUX_ERROR, (detail, info) => {\n this._emitter.emit(PlayerEvents.ERROR, ErrorTypes.MEDIA_ERROR, detail, {code: -1, msg: info});\n });\n this._transmuxer.on(TransmuxingEvents.MEDIA_INFO, (mediaInfo) => {\n this._mediaInfo = mediaInfo;\n this._emitter.emit(PlayerEvents.MEDIA_INFO, Object.assign({}, mediaInfo));\n });\n this._transmuxer.on(TransmuxingEvents.METADATA_ARRIVED, (metadata) => {\n this._emitter.emit(PlayerEvents.METADATA_ARRIVED, metadata);\n });\n this._transmuxer.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, (data) => {\n this._emitter.emit(PlayerEvents.SCRIPTDATA_ARRIVED, data);\n });\n this._transmuxer.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, (timed_id3_metadata) => {\n this._emitter.emit(PlayerEvents.TIMED_ID3_METADATA_ARRIVED, timed_id3_metadata);\n });\n this._transmuxer.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, (descriptor) => {\n this._emitter.emit(PlayerEvents.PES_PRIVATE_DATA_DESCRIPTOR, descriptor);\n });\n this._transmuxer.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, (private_data) => {\n this._emitter.emit(PlayerEvents.PES_PRIVATE_DATA_ARRIVED, private_data);\n });\n this._transmuxer.on(TransmuxingEvents.STATISTICS_INFO, (statInfo) => {\n this._statisticsInfo = this._fillStatisticsInfo(statInfo);\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, Object.assign({}, this._statisticsInfo));\n });\n this._transmuxer.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, (milliseconds) => {\n if (this._mediaElement && !this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = milliseconds / 1000;\n }\n });\n\n this._transmuxer.open();\n }\n\n unload() {\n if (this._mediaElement) {\n this._mediaElement.pause();\n }\n if (this._msectl) {\n this._msectl.seek(0);\n }\n if (this._transmuxer) {\n this._transmuxer.close();\n this._transmuxer.destroy();\n this._transmuxer = null;\n }\n }\n\n play() {\n return this._mediaElement.play();\n }\n\n pause() {\n this._mediaElement.pause();\n }\n\n get type() {\n return this._type;\n }\n\n get buffered() {\n return this._mediaElement.buffered;\n }\n\n get duration() {\n return this._mediaElement.duration;\n }\n\n get volume() {\n return this._mediaElement.volume;\n }\n\n set volume(value) {\n this._mediaElement.volume = value;\n }\n\n get muted() {\n return this._mediaElement.muted;\n }\n\n set muted(muted) {\n this._mediaElement.muted = muted;\n }\n\n get currentTime() {\n if (this._mediaElement) {\n return this._mediaElement.currentTime;\n }\n return 0;\n }\n\n set currentTime(seconds) {\n if (this._mediaElement) {\n this._internalSeek(seconds);\n } else {\n this._pendingSeekTime = seconds;\n }\n }\n\n get mediaInfo() {\n return Object.assign({}, this._mediaInfo);\n }\n\n get statisticsInfo() {\n if (this._statisticsInfo == null) {\n this._statisticsInfo = {};\n }\n this._statisticsInfo = this._fillStatisticsInfo(this._statisticsInfo);\n return Object.assign({}, this._statisticsInfo);\n }\n\n _fillStatisticsInfo(statInfo) {\n statInfo.playerType = this._type;\n\n if (!(this._mediaElement instanceof HTMLVideoElement)) {\n return statInfo;\n }\n\n let hasQualityInfo = true;\n let decoded = 0;\n let dropped = 0;\n\n if (this._mediaElement.getVideoPlaybackQuality) {\n let quality = this._mediaElement.getVideoPlaybackQuality();\n decoded = quality.totalVideoFrames;\n dropped = quality.droppedVideoFrames;\n } else if (this._mediaElement.webkitDecodedFrameCount != undefined) {\n decoded = this._mediaElement.webkitDecodedFrameCount;\n dropped = this._mediaElement.webkitDroppedFrameCount;\n } else {\n hasQualityInfo = false;\n }\n\n if (hasQualityInfo) {\n statInfo.decodedFrames = decoded;\n statInfo.droppedFrames = dropped;\n }\n\n return statInfo;\n }\n\n _onmseUpdateEnd() {\n let buffered = this._mediaElement.buffered;\n let currentTime = this._mediaElement.currentTime;\n\n if (this._config.isLive\n && this._config.liveBufferLatencyChasing\n && buffered.length > 0\n && !this._mediaElement.paused) {\n let buffered_end = buffered.end(buffered.length - 1);\n if (buffered_end > this._config.liveBufferLatencyMaxLatency) {\n // Ensure there's enough buffered data\n if (buffered_end - currentTime > this._config.liveBufferLatencyMaxLatency) {\n // if remained data duration has larger than config.liveBufferLatencyMaxLatency\n let target_time = buffered_end - this._config.liveBufferLatencyMinRemain;\n this.currentTime = target_time;\n }\n }\n }\n\n if (!this._config.lazyLoad || this._config.isLive) {\n return;\n }\n\n let currentRangeStart = 0;\n let currentRangeEnd = 0;\n\n for (let i = 0; i < buffered.length; i++) {\n let start = buffered.start(i);\n let end = buffered.end(i);\n if (start <= currentTime && currentTime < end) {\n currentRangeStart = start;\n currentRangeEnd = end;\n break;\n }\n }\n\n if (currentRangeEnd >= currentTime + this._config.lazyLoadMaxDuration && this._progressChecker == null) {\n Log.v(this.TAG, 'Maximum buffering duration exceeded, suspend transmuxing task');\n this._suspendTransmuxer();\n }\n }\n\n _onmseBufferFull() {\n Log.v(this.TAG, 'MSE SourceBuffer is full, suspend transmuxing task');\n if (this._progressChecker == null) {\n this._suspendTransmuxer();\n }\n }\n\n _suspendTransmuxer() {\n if (this._transmuxer) {\n this._transmuxer.pause();\n\n if (this._progressChecker == null) {\n this._progressChecker = window.setInterval(this._checkProgressAndResume.bind(this), 1000);\n }\n }\n }\n\n _checkProgressAndResume() {\n let currentTime = this._mediaElement.currentTime;\n let buffered = this._mediaElement.buffered;\n\n let needResume = false;\n\n for (let i = 0; i < buffered.length; i++) {\n let from = buffered.start(i);\n let to = buffered.end(i);\n if (currentTime >= from && currentTime < to) {\n if (currentTime >= to - this._config.lazyLoadRecoverDuration) {\n needResume = true;\n }\n break;\n }\n }\n\n if (needResume) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n if (needResume) {\n Log.v(this.TAG, 'Continue loading from paused position');\n this._transmuxer.resume();\n }\n }\n }\n\n _isTimepointBuffered(seconds) {\n let buffered = this._mediaElement.buffered;\n\n for (let i = 0; i < buffered.length; i++) {\n let from = buffered.start(i);\n let to = buffered.end(i);\n if (seconds >= from && seconds < to) {\n return true;\n }\n }\n return false;\n }\n\n _internalSeek(seconds) {\n let directSeek = this._isTimepointBuffered(seconds);\n\n let directSeekBegin = false;\n let directSeekBeginTime = 0;\n\n if (seconds < 1.0 && this._mediaElement.buffered.length > 0) {\n let videoBeginTime = this._mediaElement.buffered.start(0);\n if ((videoBeginTime < 1.0 && seconds < videoBeginTime) || Browser.safari) {\n directSeekBegin = true;\n // also workaround for Safari: Seek to 0 may cause video stuck, use 0.1 to avoid\n directSeekBeginTime = Browser.safari ? 0.1 : videoBeginTime;\n }\n }\n\n if (directSeekBegin) { // seek to video begin, set currentTime directly if beginPTS buffered\n this._requestSetTime = true;\n this._mediaElement.currentTime = directSeekBeginTime;\n } else if (directSeek) { // buffered position\n if (!this._alwaysSeekKeyframe) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = seconds;\n } else {\n let idr = this._msectl.getNearestKeyframe(Math.floor(seconds * 1000));\n this._requestSetTime = true;\n if (idr != null) {\n this._mediaElement.currentTime = idr.dts / 1000;\n } else {\n this._mediaElement.currentTime = seconds;\n }\n }\n if (this._progressChecker != null) {\n this._checkProgressAndResume();\n }\n } else {\n if (this._progressChecker != null) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n }\n this._msectl.seek(seconds);\n this._transmuxer.seek(Math.floor(seconds * 1000)); // in milliseconds\n // no need to set mediaElement.currentTime if non-accurateSeek,\n // just wait for the recommend_seekpoint callback\n if (this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = seconds;\n }\n }\n }\n\n _checkAndApplyUnbufferedSeekpoint() {\n if (this._seekpointRecord) {\n if (this._seekpointRecord.recordTime <= this._now() - 100) {\n let target = this._mediaElement.currentTime;\n this._seekpointRecord = null;\n if (!this._isTimepointBuffered(target)) {\n if (this._progressChecker != null) {\n window.clearTimeout(this._progressChecker);\n this._progressChecker = null;\n }\n // .currentTime is consists with .buffered timestamp\n // Chrome/Edge use DTS, while FireFox/Safari use PTS\n this._msectl.seek(target);\n this._transmuxer.seek(Math.floor(target * 1000));\n // set currentTime if accurateSeek, or wait for recommend_seekpoint callback\n if (this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = target;\n }\n }\n } else {\n window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50);\n }\n }\n }\n\n _checkAndResumeStuckPlayback(stalled) {\n let media = this._mediaElement;\n if (stalled || !this._receivedCanPlay || media.readyState < 2) { // HAVE_CURRENT_DATA\n let buffered = media.buffered;\n if (buffered.length > 0 && media.currentTime < buffered.start(0)) {\n Log.w(this.TAG, `Playback seems stuck at ${media.currentTime}, seek to ${buffered.start(0)}`);\n this._requestSetTime = true;\n this._mediaElement.currentTime = buffered.start(0);\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n }\n } else {\n // Playback didn't stuck, remove progress event listener\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n }\n }\n\n _onvLoadedMetadata(e) {\n if (this._pendingSeekTime != null) {\n this._mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n }\n }\n\n _onvSeeking(e) { // handle seeking request from browser's progress bar\n let target = this._mediaElement.currentTime;\n let buffered = this._mediaElement.buffered;\n\n if (this._requestSetTime) {\n this._requestSetTime = false;\n return;\n }\n\n if (target < 1.0 && buffered.length > 0) {\n // seek to video begin, set currentTime directly if beginPTS buffered\n let videoBeginTime = buffered.start(0);\n if ((videoBeginTime < 1.0 && target < videoBeginTime) || Browser.safari) {\n this._requestSetTime = true;\n // also workaround for Safari: Seek to 0 may cause video stuck, use 0.1 to avoid\n this._mediaElement.currentTime = Browser.safari ? 0.1 : videoBeginTime;\n return;\n }\n }\n\n if (this._isTimepointBuffered(target)) {\n if (this._alwaysSeekKeyframe) {\n let idr = this._msectl.getNearestKeyframe(Math.floor(target * 1000));\n if (idr != null) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = idr.dts / 1000;\n }\n }\n if (this._progressChecker != null) {\n this._checkProgressAndResume();\n }\n return;\n }\n\n this._seekpointRecord = {\n seekPoint: target,\n recordTime: this._now()\n };\n window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50);\n }\n\n _onvCanPlay(e) {\n this._receivedCanPlay = true;\n this._mediaElement.removeEventListener('canplay', this.e.onvCanPlay);\n }\n\n _onvStalled(e) {\n this._checkAndResumeStuckPlayback(true);\n }\n\n _onvProgress(e) {\n this._checkAndResumeStuckPlayback();\n }\n\n}\n\nexport default MSEPlayer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport PlayerEvents from './player-events.js';\nimport {createDefaultConfig} from '../config.js';\nimport {InvalidArgumentException, IllegalStateException} from '../utils/exception.js';\n\n// Player wrapper for browser's native player (HTMLVideoElement) without MediaSource src. \nclass NativePlayer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'NativePlayer';\n this._type = 'NativePlayer';\n this._emitter = new EventEmitter();\n\n this._config = createDefaultConfig();\n if (typeof config === 'object') {\n Object.assign(this._config, config);\n }\n\n let typeLowerCase = mediaDataSource.type.toLowerCase();\n\n if (typeLowerCase === 'mse'\n || typeLowerCase === 'mpegts'\n || typeLowerCase === 'm2ts'\n || typeLowerCase === 'flv') {\n throw new InvalidArgumentException('NativePlayer does\\'t support mse/mpegts/m2ts/flv MediaDataSource input!');\n }\n if (mediaDataSource.hasOwnProperty('segments')) {\n throw new InvalidArgumentException(`NativePlayer(${mediaDataSource.type}) doesn't support multipart playback!`);\n }\n\n this.e = {\n onvLoadedMetadata: this._onvLoadedMetadata.bind(this)\n };\n\n this._pendingSeekTime = null;\n this._statisticsReporter = null;\n\n this._mediaDataSource = mediaDataSource;\n this._mediaElement = null;\n }\n\n destroy() {\n if (this._mediaElement) {\n this.unload();\n this.detachMediaElement();\n }\n this.e = null;\n this._mediaDataSource = null;\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n if (event === PlayerEvents.MEDIA_INFO) {\n if (this._mediaElement != null && this._mediaElement.readyState !== 0) { // HAVE_NOTHING\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n });\n }\n } else if (event === PlayerEvents.STATISTICS_INFO) {\n if (this._mediaElement != null && this._mediaElement.readyState !== 0) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n });\n }\n }\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n this._mediaElement = mediaElement;\n mediaElement.addEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n\n if (this._pendingSeekTime != null) {\n try {\n mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n } catch (e) {\n // IE11 may throw InvalidStateError if readyState === 0\n // Defer set currentTime operation after loadedmetadata\n }\n }\n }\n\n detachMediaElement() {\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n this._mediaElement.removeEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n this._mediaElement = null;\n }\n if (this._statisticsReporter != null) {\n window.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n load() {\n if (!this._mediaElement) {\n throw new IllegalStateException('HTMLMediaElement must be attached before load()!');\n }\n this._mediaElement.src = this._mediaDataSource.url;\n\n if (this._mediaElement.readyState > 0) {\n this._mediaElement.currentTime = 0;\n }\n\n this._mediaElement.preload = 'auto';\n this._mediaElement.load();\n this._statisticsReporter = window.setInterval(\n this._reportStatisticsInfo.bind(this),\n this._config.statisticsInfoReportInterval);\n }\n\n unload() {\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n }\n if (this._statisticsReporter != null) {\n window.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n play() {\n return this._mediaElement.play();\n }\n\n pause() {\n this._mediaElement.pause();\n }\n\n get type() {\n return this._type;\n }\n\n get buffered() {\n return this._mediaElement.buffered;\n }\n\n get duration() {\n return this._mediaElement.duration;\n }\n\n get volume() {\n return this._mediaElement.volume;\n }\n\n set volume(value) {\n this._mediaElement.volume = value;\n }\n\n get muted() {\n return this._mediaElement.muted;\n }\n\n set muted(muted) {\n this._mediaElement.muted = muted;\n }\n\n get currentTime() {\n if (this._mediaElement) {\n return this._mediaElement.currentTime;\n }\n return 0;\n }\n\n set currentTime(seconds) {\n if (this._mediaElement) {\n this._mediaElement.currentTime = seconds;\n } else {\n this._pendingSeekTime = seconds;\n }\n }\n\n get mediaInfo() {\n let mediaPrefix = (this._mediaElement instanceof HTMLAudioElement) ? 'audio/' : 'video/';\n let info = {\n mimeType: mediaPrefix + this._mediaDataSource.type\n };\n if (this._mediaElement) {\n info.duration = Math.floor(this._mediaElement.duration * 1000);\n if (this._mediaElement instanceof HTMLVideoElement) {\n info.width = this._mediaElement.videoWidth;\n info.height = this._mediaElement.videoHeight;\n }\n }\n return info;\n }\n\n get statisticsInfo() {\n let info = {\n playerType: this._type,\n url: this._mediaDataSource.url\n };\n\n if (!(this._mediaElement instanceof HTMLVideoElement)) {\n return info;\n }\n\n let hasQualityInfo = true;\n let decoded = 0;\n let dropped = 0;\n\n if (this._mediaElement.getVideoPlaybackQuality) {\n let quality = this._mediaElement.getVideoPlaybackQuality();\n decoded = quality.totalVideoFrames;\n dropped = quality.droppedVideoFrames;\n } else if (this._mediaElement.webkitDecodedFrameCount != undefined) {\n decoded = this._mediaElement.webkitDecodedFrameCount;\n dropped = this._mediaElement.webkitDroppedFrameCount;\n } else {\n hasQualityInfo = false;\n }\n\n if (hasQualityInfo) {\n info.decodedFrames = decoded;\n info.droppedFrames = dropped;\n }\n \n return info;\n }\n\n _onvLoadedMetadata(e) {\n if (this._pendingSeekTime != null) {\n this._mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n }\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n }\n\n _reportStatisticsInfo() {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n }\n\n}\n\nexport default NativePlayer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Polyfill from './utils/polyfill.js';\nimport Features from './core/features.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './io/loader.js';\nimport MSEPlayer from './player/mse-player.js';\nimport NativePlayer from './player/native-player.js';\nimport PlayerEvents from './player/player-events.js';\nimport {ErrorTypes, ErrorDetails} from './player/player-errors.js';\nimport LoggingControl from './utils/logging-control.js';\nimport {InvalidArgumentException} from './utils/exception.js';\n\n// here are all the interfaces\n\n// install polyfills\nPolyfill.install();\n\n\n// factory method\nfunction createPlayer(mediaDataSource, optionalConfig) {\n let mds = mediaDataSource;\n if (mds == null || typeof mds !== 'object') {\n throw new InvalidArgumentException('MediaDataSource must be an javascript object!');\n }\n\n if (!mds.hasOwnProperty('type')) {\n throw new InvalidArgumentException('MediaDataSource must has type field to indicate video file type!');\n }\n\n switch (mds.type) {\n case 'mse':\n case 'mpegts':\n case 'm2ts':\n case 'flv':\n return new MSEPlayer(mds, optionalConfig);\n default:\n return new NativePlayer(mds, optionalConfig);\n }\n}\n\n\n// feature detection\nfunction isSupported() {\n return Features.supportMSEH264Playback();\n}\n\nfunction getFeatureList() {\n return Features.getFeatureList();\n}\n\n\n// interfaces\nlet mpegts = {};\n\nmpegts.createPlayer = createPlayer;\nmpegts.isSupported = isSupported;\nmpegts.getFeatureList = getFeatureList;\n\nmpegts.BaseLoader = BaseLoader;\nmpegts.LoaderStatus = LoaderStatus;\nmpegts.LoaderErrors = LoaderErrors;\n\nmpegts.Events = PlayerEvents;\nmpegts.ErrorTypes = ErrorTypes;\nmpegts.ErrorDetails = ErrorDetails;\n\nmpegts.MSEPlayer = MSEPlayer;\nmpegts.NativePlayer = NativePlayer;\nmpegts.LoggingControl = LoggingControl;\n\nObject.defineProperty(mpegts, 'version', {\n enumerable: true,\n get: function () {\n // replaced by webpack.DefinePlugin\n return __VERSION__;\n }\n});\n\nexport default mpegts;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/trunk/research/players/js/mpegts-1.6.11.min.js b/trunk/research/players/js/mpegts-1.6.11.min.js new file mode 100644 index 0000000000..7a05b9e9af --- /dev/null +++ b/trunk/research/players/js/mpegts-1.6.11.min.js @@ -0,0 +1,9 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mpegts=t():e.mpegts=t()}(window,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},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(i.s=14)}([function(e,t,i){"use strict";var n=i(6),r=i.n(n),a=function(){function e(){}return e.e=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",n),e.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))},e.i=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",n),e.ENABLE_INFO&&(console.info?console.info(n):console.log(n))},e.w=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",n),e.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))},e.d=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",n),e.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))},e.v=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",n),e.ENABLE_VERBOSE&&console.log(n)},e}();a.GLOBAL_TAG="mpegts.js",a.FORCE_GLOBAL_TAG=!1,a.ENABLE_ERROR=!0,a.ENABLE_INFO=!0,a.ENABLE_WARN=!0,a.ENABLE_DEBUG=!0,a.ENABLE_VERBOSE=!0,a.ENABLE_CALLBACK=!1,a.emitter=new r.a,t.a=a},function(e,t,i){"use strict";t.a={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",TIMED_ID3_METADATA_ARRIVED:"timed_id3_metadata_arrived",SCTE35_METADATA_ARRIVED:"scte35_metadata_arrived",PES_PRIVATE_DATA_DESCRIPTOR:"pes_private_data_descriptor",PES_PRIVATE_DATA_ARRIVED:"pes_private_data_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"}},function(e,t,i){"use strict";i.d(t,"c",(function(){return r})),i.d(t,"b",(function(){return a})),i.d(t,"a",(function(){return s}));var n=i(3),r={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},a={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},s=function(){function e(e){this._type=e||"undefined",this._status=r.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return e.prototype.destroy=function(){this._status=r.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===r.kConnecting||this._status===r.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),e.prototype.open=function(e,t){throw new n.c("Unimplemented abstract function!")},e.prototype.abort=function(){throw new n.c("Unimplemented abstract function!")},e}()},function(e,t,i){"use strict";i.d(t,"d",(function(){return a})),i.d(t,"a",(function(){return s})),i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return d}));var n,r=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),a=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),s=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),t}(a),o=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),t}(a),d=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),t}(a)},function(e,t,i){"use strict";var n={};!function(){var e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},a={};if(r.browser){a[r.browser]=!0;var s=r.majorVersion.split(".");a.version={major:parseInt(r.majorVersion,10),string:r.version},s.length>1&&(a.version.minor=parseInt(s[1],10)),s.length>2&&(a.version.build=parseInt(s[2],10))}if(r.platform&&(a[r.platform]=!0),(a.chrome||a.opr||a.safari)&&(a.webkit=!0),a.rv||a.iemobile){a.rv&&delete a.rv;r.browser="msie",a.msie=!0}if(a.edge){delete a.edge;r.browser="msedge",a.msedge=!0}if(a.opr){r.browser="opera",a.opera=!0}if(a.safari&&a.android){r.browser="android",a.android=!0}for(var o in a.name=r.browser,a.platform=r.platform,n)n.hasOwnProperty(o)&&delete n[o];Object.assign(n,a)}(),t.a=n},function(e,t,i){"use strict";t.a={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"}},function(e,t,i){"use strict";var n,r="object"==typeof Reflect?Reflect:null,a=r&&"function"==typeof r.apply?r.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};n=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(i,n){function r(i){e.removeListener(t,a),n(i)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}g(e,t,a,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&g(e,"error",t,i)}(e,r,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var d=10;function h(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function _(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,i,n){var r,a,s,o;if(h(i),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),a=e._events),s=a[t]),void 0===s)s=a[t]=i,++e._eventsCount;else if("function"==typeof s?s=a[t]=n?[i,s]:[s,i]:n?s.unshift(i):s.push(i),(r=_(e))>0&&s.length>r&&!s.warned){s.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=s.length,o=d,console&&console.warn&&console.warn(o)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=l.bind(n);return r.listener=i,n.wrapFn=r,r}function f(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var d=r[e];if(void 0===d)return!1;if("function"==typeof d)a(d,this,t);else{var h=d.length,_=m(d,h);for(i=0;i=0;a--)if(i[a]===t||i[a].listener===t){s=i[a].listener,r=a;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,i){"use strict";i.d(t,"d",(function(){return n})),i.d(t,"b",(function(){return r})),i.d(t,"a",(function(){return a})),i.d(t,"c",(function(){return s}));var n=function(e,t,i,n,r){this.dts=e,this.pts=t,this.duration=i,this.originalDts=n,this.isSyncPoint=r,this.fileposition=null},r=function(){function e(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return e.prototype.appendSyncPoint=function(e){e.isSyncPoint=!0,this.syncPoints.push(e)},e}(),a=function(){function e(){this._list=[]}return e.prototype.clear=function(){this._list=[]},e.prototype.appendArray=function(e){var t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts=t[r].dts&&et[n].lastSample.originalDts&&e=t[n].lastSample.originalDts&&(n===t.length-1||n0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)},e.prototype.getLastSegmentBefore=function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null},e.prototype.getLastSampleBefore=function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){for(var t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;0===i.length&&t>0;)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null},e}()},function(e,t,i){"use strict";var n=function(){function e(){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 e.prototype.isComplete=function(){var e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=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;return null!=this.mimeType&&e&&t},e.prototype.isSeekable=function(){return!0===this.hasKeyframesIndex},e.prototype.getNearestKeyframe=function(e){if(null==this.keyframesIndex)return null;var t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}},e.prototype._search=function(e,t){var i=0,n=e.length-1,r=0,a=0,s=n;for(t=e[r]&&t0){var i=e.getConfig();t.emit("change",i)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){a.a.emitter.addListener("log",t),a.a.emitter.listenerCount("log")>0&&(a.a.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){a.a.emitter.removeListener("log",t),0===a.a.emitter.listenerCount("log")&&(a.a.ENABLE_CALLBACK=!1,e._notifyChange())},e}();s.emitter=new r.a,t.a=s},function(e,t,i){"use strict";var n=i(6),r=i.n(n),a=i(0),s=i(4),o=i(8);function d(e,t,i){var n=e;if(t+i=128){t.push(String.fromCharCode(65535&a)),n+=2;continue}}else if(i[n]<240){if(d(i,n,2))if((a=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2])>=2048&&55296!=(63488&a)){t.push(String.fromCharCode(65535&a)),n+=3;continue}}else if(i[n]<248){var a;if(d(i,n,3))if((a=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3])>65536&&a<1114112){a-=65536,t.push(String.fromCharCode(a>>>10|55296)),t.push(String.fromCharCode(1023&a|56320)),n+=4;continue}}t.push(String.fromCharCode(65533)),++n}return t.join("")},u=i(3),l=(h=new ArrayBuffer(2),new DataView(h).setInt16(0,256,!0),256===new Int16Array(h)[0]),c=function(){function e(){}return e.parseScriptData=function(t,i,n){var r={};try{var s=e.parseValue(t,i,n),o=e.parseValue(t,i+s.size,n-s.size);r[s.data]=o.data}catch(e){a.a.e("AMF",e.toString())}return r},e.parseObject=function(t,i,n){if(n<3)throw new u.a("Data not enough when parse ScriptDataObject");var r=e.parseString(t,i,n),a=e.parseValue(t,i+r.size,n-r.size),s=a.objectEnd;return{data:{name:r.data,value:a.data},size:r.size+a.size,objectEnd:s}},e.parseVariable=function(t,i,n){return e.parseObject(t,i,n)},e.parseString=function(e,t,i){if(i<2)throw new u.a("Data not enough when parse String");var n=new DataView(e,t,i).getUint16(0,!l);return{data:n>0?_(new Uint8Array(e,t+2,n)):"",size:2+n}},e.parseLongString=function(e,t,i){if(i<4)throw new u.a("Data not enough when parse LongString");var n=new DataView(e,t,i).getUint32(0,!l);return{data:n>0?_(new Uint8Array(e,t+4,n)):"",size:4+n}},e.parseDate=function(e,t,i){if(i<10)throw new u.a("Data size invalid when parse Date");var n=new DataView(e,t,i),r=n.getFloat64(0,!l),a=n.getInt16(8,!l);return{data:new Date(r+=60*a*1e3),size:10}},e.parseValue=function(t,i,n){if(n<1)throw new u.a("Data not enough when parse Value");var r,s=new DataView(t,i,n),o=1,d=s.getUint8(0),h=!1;try{switch(d){case 0:r=s.getFloat64(1,!l),o+=8;break;case 1:r=!!s.getUint8(1),o+=1;break;case 2:var _=e.parseString(t,i+1,n-1);r=_.data,o+=_.size;break;case 3:r={};var c=0;for(9==(16777215&s.getUint32(n-4,!l))&&(c=3);o32)throw new u.b("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var i=this._current_word_bits_left?this._current_word:0;i>>>=32-this._current_word_bits_left;var n=e-this._current_word_bits_left;this._fillCurrentWord();var r=Math.min(n,this._current_word_bits_left),a=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,i=i<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}(),p=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,n=new Uint8Array(i),r=0,a=0;a=2&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(n[r]=t[a],r++);return new Uint8Array(n.buffer,0,r)},e.parseSPS=function(t){for(var i=t.subarray(1,4),n="avc1.",r=0;r<3;r++){var a=i[r].toString(16);a.length<2&&(a="0"+a),n+=a}var s=e._ebsp2rbsp(t),o=new f(s);o.readByte();var d=o.readByte();o.readByte();var h=o.readByte();o.readUEG();var _=e.getProfileString(d),u=e.getLevelString(h),l=1,c=420,p=8,m=8;if((100===d||110===d||122===d||244===d||44===d||83===d||86===d||118===d||128===d||138===d||144===d)&&(3===(l=o.readUEG())&&o.readBits(1),l<=3&&(c=[0,420,422,444][l]),p=o.readUEG()+8,m=o.readUEG()+8,o.readBits(1),o.readBool()))for(var g=3!==l?8:12,v=0;v0&&M<16?(D=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][M-1],C=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][M-1]):255===M&&(D=o.readByte()<<8|o.readByte(),C=o.readByte()<<8|o.readByte())}if(o.readBool()&&o.readBool(),o.readBool()&&(o.readBits(4),o.readBool()&&o.readBits(24)),o.readBool()&&(o.readUEG(),o.readUEG()),o.readBool()){var x=o.readBits(32),U=o.readBits(32);I=o.readBool(),B=(O=U)/(P=2*x)}}var N=1;1===D&&1===C||(N=D/C);var G=0,V=0;0===l?(G=1,V=2-R):(G=3===l?1:2,V=(1===l?2:1)*(2-R));var F=16*(b+1),j=16*(A+1)*(2-R);F-=(T+L)*G,j-=(w+k)*V;var z=Math.ceil(F*N);return o.destroy(),o=null,{codec_mimetype:n,profile_idc:d,level_idc:h,profile_string:_,level_string:u,chroma_format_idc:l,bit_depth:p,bit_depth_luma:p,bit_depth_chroma:m,ref_frames:S,chroma_format:c,chroma_format_string:e.getChromaFormatString(c),frame_rate:{fixed:I,fps:B,fps_den:P,fps_num:O},sar_ratio:{width:D,height:C},codec_size:{width:F,height:j},present_size:{width:z,height:j}}},e._skipScalingList=function(e,t){for(var i=8,n=8,r=0;r=2&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(n[r]=t[a],r++);return new Uint8Array(n.buffer,0,r)},e.parseVPS=function(t){var i=e._ebsp2rbsp(t),n=new f(i);n.readByte(),n.readByte();n.readBits(4);n.readBits(2);n.readBits(6);return{num_temporal_layers:n.readBits(3)+1,temporal_id_nested:n.readBool()}},e.parseSPS=function(t){var i=e._ebsp2rbsp(t),n=new f(i);n.readByte(),n.readByte();n.readBits(4);for(var r=n.readBits(3),a=(n.readBool(),n.readBits(2)),s=n.readBool(),o=n.readBits(5),d=n.readByte(),h=n.readByte(),_=n.readByte(),u=n.readByte(),l=n.readByte(),c=n.readByte(),p=n.readByte(),m=n.readByte(),g=n.readByte(),v=n.readByte(),y=n.readByte(),E=[],S=[],b=0;b0)for(b=r;b<8;b++)n.readBits(2);for(b=0;b1&&n.readSEG();for(b=0;b0&&X<16?(z=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][X-1],H=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][X-1]):255===X&&(z=n.readBits(16),H=n.readBits(16))}if(n.readBool()&&n.readBool(),n.readBool())n.readBits(3),n.readBool(),n.readBool()&&(n.readByte(),n.readByte(),n.readByte());n.readBool()&&(n.readUEG(),n.readUEG());n.readBool(),n.readBool(),n.readBool();if(n.readBool()&&(n.readUEG(),n.readUEG(),n.readUEG(),n.readUEG()),n.readBool())if(K=n.readBits(32),W=n.readBits(32),n.readBool())if(n.readUEG(),n.readBool()){var Y=!1,Z=!1;if(Y=n.readBool(),Z=n.readBool(),Y||Z){var J=n.readBool();J&&(n.readByte(),n.readBits(5),n.readBool(),n.readBits(5));n.readBits(4),n.readBits(4);J&&n.readBits(4),n.readBits(5),n.readBits(5),n.readBits(5)}for(b=0;b<=r;b++){var Q=n.readBool();q=Q;var $=!1;Q||($=n.readBool());var ee=!1;if($?n.readSEG():ee=n.readBool(),ee||(cpbcnt=n.readUEG()+1),Y)for(x=0;x<1;x++)n.readUEG(),n.readUEG(),J&&(n.readUEG(),n.readUEG());if(Z)for(x=0;x<1;x++)n.readUEG(),n.readUEG(),J&&(n.readUEG(),n.readUEG())}}if(n.readBool()){n.readBool(),n.readBool(),n.readBool();j=n.readUEG();n.readUEG(),n.readUEG(),n.readUEG(),n.readUEG()}}n.readBool();var te="hvc1."+o+".1.L"+y+".B0",ie=R,ne=T,re=1;return 1!==z&&1!==H&&(re=z/H),n.destroy(),n=null,{codec_mimetype:te,level_string:e.getLevelString(y),profile_idc:o,bit_depth:L+8,ref_frames:1,chroma_format:A,chroma_format_string:e.getChromaFormatString(A),general_level_idc:y,general_profile_space:a,general_tier_flag:s,general_profile_idc:o,general_profile_compatibility_flags_1:d,general_profile_compatibility_flags_2:h,general_profile_compatibility_flags_3:_,general_profile_compatibility_flags_4:u,general_constraint_indicator_flags_1:l,general_constraint_indicator_flags_2:c,general_constraint_indicator_flags_3:p,general_constraint_indicator_flags_4:m,general_constraint_indicator_flags_5:g,general_constraint_indicator_flags_6:v,min_spatial_segmentation_idc:j,constant_frame_rate:0,chroma_format_idc:A,bit_depth_luma_minus8:L,bit_depth_chroma_minus8:w,frame_rate:{fixed:q,fps:W/K,fps_den:K,fps_num:W},sar_ratio:{width:z,height:H},codec_size:{width:ie,height:ne},present_size:{width:ie*re,height:ne}}},e.parsePPS=function(t){var i=e._ebsp2rbsp(t),n=new f(i);n.readByte(),n.readByte();n.readUEG(),n.readUEG(),n.readBool(),n.readBool(),n.readBits(3),n.readBool(),n.readBool(),n.readUEG(),n.readUEG(),n.readSEG(),n.readBool(),n.readBool();if(n.readBool())n.readUEG();n.readSEG(),n.readSEG(),n.readBool(),n.readBool(),n.readBool(),n.readBool();var r=n.readBool(),a=n.readBool(),s=1;return a&&r?s=0:a?s=3:r&&(s=2),{parallelismType:s}},e.getChromaFormatString=function(e){switch(e){case 0:return"4:0:0";case 1:return"4:2:0";case 2:return"4:2:2";case 3:return"4:4:4";default:return"Unknown"}},e.getProfileString=function(e){switch(e){case 1:return"Main";case 2:return"Main10";case 3:return"MainSP";case 4:return"Rext";case 9:return"SCC";default:return"Unknown"}},e.getLevelString=function(e){return(e/30).toFixed(1)},e}();var v,y=function(){function e(e,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._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new o.a,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=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,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),256===new Int16Array(e)[0]}()}return e.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},e.probe=function(e){var t=new Uint8Array(e),i={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return i;var n,r,a=(4&t[4])>>>2!=0,s=0!=(1&t[4]),o=(n=t)[r=5]<<24|n[r+1]<<16|n[r+2]<<8|n[r+3];return o<9?i:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:a,hasVideoTrack:s}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new o.a},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(t,i){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new u.a("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var n=0,r=this._littleEndian;if(0===i){if(!(t.byteLength>13))return 0;n=e.probe(t).dataOffset}this._firstParse&&(this._firstParse=!1,i+n!==this._dataOffset&&a.a.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==(s=new DataView(t,n)).getUint32(0,!r)&&a.a.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4);for(;nt.byteLength)break;var o=s.getUint8(0),d=16777215&s.getUint32(0,!r);if(n+11+d+4>t.byteLength)break;if(8===o||9===o||18===o){var h=s.getUint8(4),_=s.getUint8(5),l=s.getUint8(6)|_<<8|h<<16|s.getUint8(7)<<24;0!==(16777215&s.getUint32(7,!r))&&a.a.w(this.TAG,"Meet tag which has StreamID != 0!");var c=n+11;switch(o){case 8:this._parseAudioData(t,c,d,l);break;case 9:this._parseVideoData(t,c,d,l,i+n);break;case 18:this._parseScriptData(t,c,d)}var f=s.getUint32(11+d,!r);f!==11+d&&a.a.w(this.TAG,"Invalid PrevTagSize "+f),n+=11+d+4}else a.a.w(this.TAG,"Unsupported tag type "+o+", skipped"),n+=11+d+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n},e.prototype._parseScriptData=function(e,t,i){var n=c.parseScriptData(e,t,i);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!=typeof n.onMetaData)return void a.a.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&a.a.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;var r=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},r)),"boolean"==typeof r.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=r.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof r.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=r.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof r.audiodatarate&&(this._mediaInfo.audioDataRate=r.audiodatarate),"number"==typeof r.videodatarate&&(this._mediaInfo.videoDataRate=r.videodatarate),"number"==typeof r.width&&(this._mediaInfo.width=r.width),"number"==typeof r.height&&(this._mediaInfo.height=r.height),"number"==typeof r.duration){if(!this._durationOverrided){var s=Math.floor(r.duration*this._timescale);this._duration=s,this._mediaInfo.duration=s}}else this._mediaInfo.duration=0;if("number"==typeof r.framerate){var o=Math.floor(1e3*r.framerate);if(o>0){var d=o/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=d,this._referenceFrameRate.fps_num=o,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=d}}if("object"==typeof r.keyframes){this._mediaInfo.hasKeyframesIndex=!0;var h=r.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(h),r.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=r,a.a.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(n).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},n))},e.prototype._parseKeyframesIndex=function(e){for(var t=[],i=[],n=1;n>>4;if(2===s||10===s){var o=0,d=(12&r)>>>2;if(d>=0&&d<=4){o=this._flvSoundRateTable[d];var h=1&r,_=this._audioMetadata,u=this._audioTrack;if(_||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(_=this._audioMetadata={}).type="audio",_.id=u.id,_.timescale=this._timescale,_.duration=this._duration,_.audioSampleRate=o,_.channelCount=0===h?1:2),10===s){var l=this._parseAACAudioData(e,t+1,i-1);if(null==l)return;if(0===l.packetType){_.config&&a.a.w(this.TAG,"Found another AudioSpecificConfig!");var c=l.data;_.audioSampleRate=c.samplingRate,_.channelCount=c.channelCount,_.codec=c.codec,_.originalCodec=c.originalCodec,_.config=c.config,_.refSampleDuration=1024/_.audioSampleRate*_.timescale,a.a.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",_),(g=this._mediaInfo).audioCodec=_.originalCodec,g.audioSampleRate=_.audioSampleRate,g.audioChannelCount=_.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}else if(1===l.packetType){var f=this._timestampBase+n,p={unit:l.data,length:l.data.byteLength,dts:f,pts:f};u.samples.push(p),u.length+=l.data.length}else a.a.e(this.TAG,"Flv: Unsupported AAC data type "+l.packetType)}else if(2===s){if(!_.codec){var g;if(null==(c=this._parseMP3AudioData(e,t+1,i-1,!0)))return;_.audioSampleRate=c.samplingRate,_.channelCount=c.channelCount,_.codec=c.codec,_.originalCodec=c.originalCodec,_.refSampleDuration=1152/_.audioSampleRate*_.timescale,a.a.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",_),(g=this._mediaInfo).audioCodec=_.codec,g.audioSampleRate=_.audioSampleRate,g.audioChannelCount=_.channelCount,g.audioDataRate=c.bitRate,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}var v=this._parseMP3AudioData(e,t+1,i-1,!1);if(null==v)return;f=this._timestampBase+n;var y={unit:v,length:v.byteLength,dts:f,pts:f};u.samples.push(y),u.length+=v.length}}else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+d)}else this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+s)}},e.prototype._parseAACAudioData=function(e,t,i){if(!(i<=1)){var n={},r=new Uint8Array(e,t,i);return n.packetType=r[0],0===r[0]?n.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):n.data=r.subarray(1),n}a.a.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,t,i){var n,r,a=new Uint8Array(e,t,i),s=null,o=0,d=null;if(o=n=a[0]>>>3,(r=(7&a[0])<<1|a[1]>>>7)<0||r>=this._mpegSamplingRates.length)this._onError(m.a.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var h=this._mpegSamplingRates[r],_=(120&a[1])>>>3;if(!(_<0||_>=8)){5===o&&(d=(7&a[1])<<1|a[2]>>>7,(124&a[2])>>>2);var u=self.navigator.userAgent.toLowerCase();return-1!==u.indexOf("firefox")?r>=6?(o=5,s=new Array(4),d=r-3):(o=2,s=new Array(2),d=r):-1!==u.indexOf("android")?(o=2,s=new Array(2),d=r):(o=5,d=r,s=new Array(4),r>=6?d=r-3:1===_&&(o=2,s=new Array(2),d=r)),s[0]=o<<3,s[0]|=(15&r)>>>1,s[1]=(15&r)<<7,s[1]|=(15&_)<<3,5===o&&(s[1]|=(15&d)>>>1,s[2]=(1&d)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:h,channelCount:_,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+n}}this._onError(m.a.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,t,i,n){if(!(i<4)){this._littleEndian;var r=new Uint8Array(e,t,i),s=null;if(n){if(255!==r[0])return;var o=r[1]>>>3&3,d=(6&r[1])>>1,h=(240&r[2])>>>4,_=(12&r[2])>>>2,u=3!==(r[3]>>>6&3)?2:1,l=0,c=0;switch(o){case 0:l=this._mpegAudioV25SampleRateTable[_];break;case 2:l=this._mpegAudioV20SampleRateTable[_];break;case 3:l=this._mpegAudioV10SampleRateTable[_]}switch(d){case 1:34,h>>4,d=15&s;if(7===d)this._parseAVCVideoPacket(e,t+1,i-1,n,r,o);else{if(12!==d)return void this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+d);this._parseHEVCVideoPacket(e,t+1,i-1,n,r,o)}}},e.prototype._parseAVCVideoPacket=function(e,t,i,n,r,s){if(i<4)a.a.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var o=this._littleEndian,d=new DataView(e,t,i),h=d.getUint8(0),_=(16777215&d.getUint32(0,!o))<<8>>8;if(0===h)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===h)this._parseAVCVideoData(e,t+4,i-4,n,r,s,_);else if(2!==h)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type "+h)}},e.prototype._parseHEVCVideoPacket=function(e,t,i,n,r,s){if(i<4)a.a.w(this.TAG,"Flv: Invalid HEVC packet, missing HEVCPacketType or/and CompositionTime");else{var o=this._littleEndian,d=new DataView(e,t,i),h=d.getUint8(0),_=(16777215&d.getUint32(0,!o))<<8>>8;if(0===h)this._parseHEVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===h)this._parseHEVCVideoData(e,t+4,i-4,n,r,s,_);else if(2!==h)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type "+h)}},e.prototype._parseAVCDecoderConfigurationRecord=function(e,t,i){if(i<7)a.a.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var n=this._videoMetadata,r=this._videoTrack,s=this._littleEndian,o=new DataView(e,t,i);n?void 0!==n.avcc&&a.a.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(n=this._videoMetadata={}).type="video",n.id=r.id,n.timescale=this._timescale,n.duration=this._duration);var d=o.getUint8(0),h=o.getUint8(1);o.getUint8(2),o.getUint8(3);if(1===d&&0!==h)if(this._naluLengthSize=1+(3&o.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var _=31&o.getUint8(5);if(0!==_){_>1&&a.a.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+_);for(var u=6,l=0;l<_;l++){var c=o.getUint16(u,!s);if(u+=2,0!==c){var f=new Uint8Array(e,t+u,c);u+=c;var g=p.parseSPS(f);if(0===l){n.codecWidth=g.codec_size.width,n.codecHeight=g.codec_size.height,n.presentWidth=g.present_size.width,n.presentHeight=g.present_size.height,n.profile=g.profile_string,n.level=g.level_string,n.bitDepth=g.bit_depth,n.chromaFormat=g.chroma_format,n.sarRatio=g.sar_ratio,n.frameRate=g.frame_rate,!1!==g.frame_rate.fixed&&0!==g.frame_rate.fps_num&&0!==g.frame_rate.fps_den||(n.frameRate=this._referenceFrameRate);var v=n.frameRate.fps_den,y=n.frameRate.fps_num;n.refSampleDuration=n.timescale*(v/y);for(var E=f.subarray(1,4),S="avc1.",b=0;b<3;b++){var A=E[b].toString(16);A.length<2&&(A="0"+A),S+=A}n.codec=S;var R=this._mediaInfo;R.width=n.codecWidth,R.height=n.codecHeight,R.fps=n.frameRate.fps,R.profile=n.profile,R.level=n.level,R.refFrames=g.ref_frames,R.chromaFormat=g.chroma_format_string,R.sarNum=n.sarRatio.width,R.sarDen=n.sarRatio.height,R.videoCodec=S,R.hasAudio?null!=R.audioCodec&&(R.mimeType='video/x-flv; codecs="'+R.videoCodec+","+R.audioCodec+'"'):R.mimeType='video/x-flv; codecs="'+R.videoCodec+'"',R.isComplete()&&this._onMediaInfo(R)}}}var T=o.getUint8(u);if(0!==T){T>1&&a.a.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+T),u++;for(l=0;l=i){a.a.w(this.TAG,"Malformed Nalu near timestamp "+f+", offset = "+l+", dataSize = "+i);break}var m=h.getUint32(l,!d);if(3===c&&(m>>>=8),m>i-c)return void a.a.w(this.TAG,"Malformed Nalus near timestamp "+f+", NaluSize > DataSize!");var g=31&h.getUint8(l+c);5===g&&(p=!0);var v=new Uint8Array(e,t+l,c+m),y={type:g,data:v};_.push(y),u+=v.byteLength,l+=c+m}if(_.length){var E=this._videoTrack,S={units:_,length:u,isKeyframe:p,dts:f,cts:o,pts:f+o};p&&(S.fileposition=r),E.samples.push(S),E.length+=u}},e.prototype._parseHEVCVideoData=function(e,t,i,n,r,s,o){for(var d=this._littleEndian,h=new DataView(e,t,i),_=[],u=0,l=0,c=this._naluLengthSize,f=this._timestampBase+n,p=1===s;l=i){a.a.w(this.TAG,"Malformed Nalu near timestamp "+f+", offset = "+l+", dataSize = "+i);break}var m=h.getUint32(l,!d);if(3===c&&(m>>>=8),m>i-c)return void a.a.w(this.TAG,"Malformed Nalus near timestamp "+f+", NaluSize > DataSize!");var g=31&h.getUint8(l+c);19!==g&&20!==g||(p=!0);var v=new Uint8Array(e,t+l,c+m),y={type:g,data:v};_.push(y),u+=v.byteLength,l+=c+m}if(_.length){var E=this._videoTrack,S={units:_,length:u,isKeyframe:p,dts:f,cts:o,pts:f+o};p&&(S.fileposition=r),E.samples.push(S),E.length+=u}},e}(),E=function(){function e(){}return e.prototype.destroy=function(){this.onError=null,this.onMediaInfo=null,this.onMetaDataArrived=null,this.onTrackMetadata=null,this.onDataAvailable=null,this.onTimedID3Metadata=null,this.onSCTE35Metadata=null,this.onPESPrivateData=null,this.onPESPrivateDataDescriptor=null},e}(),S=function(){this.program_pmt_pid={}};!function(e){e[e.kMPEG1Audio=3]="kMPEG1Audio",e[e.kMPEG2Audio=4]="kMPEG2Audio",e[e.kPESPrivateData=6]="kPESPrivateData",e[e.kADTSAAC=15]="kADTSAAC",e[e.kID3=21]="kID3",e[e.kSCTE35=134]="kSCTE35",e[e.kH264=27]="kH264",e[e.kH265=36]="kH265"}(v||(v={}));var b,A=function(){this.pid_stream_type={},this.common_pids={h264:void 0,h265:void 0,adts_aac:void 0},this.pes_private_data_pids={},this.timed_id3_pids={},this.scte_35_pids={}},R=function(){},T=function(){},L=function(){this.slices=[],this.total_length=0,this.expected_length=0,this.file_position=0};!function(e){e[e.kUnspecified=0]="kUnspecified",e[e.kSliceNonIDR=1]="kSliceNonIDR",e[e.kSliceDPA=2]="kSliceDPA",e[e.kSliceDPB=3]="kSliceDPB",e[e.kSliceDPC=4]="kSliceDPC",e[e.kSliceIDR=5]="kSliceIDR",e[e.kSliceSEI=6]="kSliceSEI",e[e.kSliceSPS=7]="kSliceSPS",e[e.kSlicePPS=8]="kSlicePPS",e[e.kSliceAUD=9]="kSliceAUD",e[e.kEndOfSequence=10]="kEndOfSequence",e[e.kEndOfStream=11]="kEndOfStream",e[e.kFiller=12]="kFiller",e[e.kSPSExt=13]="kSPSExt",e[e.kReserved0=14]="kReserved0"}(b||(b={}));var w,k,D=function(){},C=function(e){var t=e.data.byteLength;this.type=e.type,this.data=new Uint8Array(4+t),new DataView(this.data.buffer).setUint32(0,t),this.data.set(e.data,4)},B=function(){function e(e){this.TAG="H264AnnexBParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=e,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&a.a.e(this.TAG,"Could not find H264 startcode until payload end!")}return e.prototype.findNextStartCodeOffset=function(e){for(var t=e,i=this.data_;;){if(t+3>=i.byteLength)return this.eof_flag_=!0,i.byteLength;var n=i[t+0]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3],r=i[t+0]<<16|i[t+1]<<8|i[t+2];if(1===n||1===r)return t;t++}},e.prototype.readNextNaluPayload=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_startcode_offset_,n=31&e[i+=1===(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])?4:3],r=(128&e[i])>>>7,a=this.findNextStartCodeOffset(i);if(this.current_startcode_offset_=a,!(n>=b.kReserved0)&&0===r){var s=e.subarray(i,a);(t=new D).type=n,t.data=s}}return t},e}(),I=function(){function e(e,t,i){var n=8+e.byteLength+1+2+t.byteLength,r=!1;66!==e[3]&&77!==e[3]&&88!==e[3]&&(r=!0,n+=4);var a=this.data=new Uint8Array(n);a[0]=1,a[1]=e[1],a[2]=e[2],a[3]=e[3],a[4]=255,a[5]=225;var s=e.byteLength;a[6]=s>>>8,a[7]=255&s;var o=8;a.set(e,8),a[o+=s]=1;var d=t.byteLength;a[o+1]=d>>>8,a[o+2]=255&d,a.set(t,o+3),o+=3+d,r&&(a[o]=252|i.chroma_format_idc,a[o+1]=248|i.bit_depth_luma-8,a[o+2]=248|i.bit_depth_chroma-8,a[o+3]=0,o+=4)}return e.prototype.getData=function(){return this.data},e}();!function(e){e[e.kNull=0]="kNull",e[e.kAACMain=1]="kAACMain",e[e.kAAC_LC=2]="kAAC_LC",e[e.kAAC_SSR=3]="kAAC_SSR",e[e.kAAC_LTP=4]="kAAC_LTP",e[e.kAAC_SBR=5]="kAAC_SBR",e[e.kAAC_Scalable=6]="kAAC_Scalable",e[e.kLayer1=32]="kLayer1",e[e.kLayer2=33]="kLayer2",e[e.kLayer3=34]="kLayer3"}(w||(w={})),function(e){e[e.k96000Hz=0]="k96000Hz",e[e.k88200Hz=1]="k88200Hz",e[e.k64000Hz=2]="k64000Hz",e[e.k48000Hz=3]="k48000Hz",e[e.k44100Hz=4]="k44100Hz",e[e.k32000Hz=5]="k32000Hz",e[e.k24000Hz=6]="k24000Hz",e[e.k22050Hz=7]="k22050Hz",e[e.k16000Hz=8]="k16000Hz",e[e.k12000Hz=9]="k12000Hz",e[e.k11025Hz=10]="k11025Hz",e[e.k8000Hz=11]="k8000Hz",e[e.k7350Hz=12]="k7350Hz"}(k||(k={}));var O,P=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],M=function(){},x=function(){function e(e){this.TAG="AACADTSParser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&a.a.e(this.TAG,"Could not found ADTS syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var t=e,i=this.data_;;){if(t+7>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(4095===(i[t+0]<<8|i[t+1])>>>4)return t;t++}},e.prototype.readNextAACFrame=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_syncword_offset_,n=(8&e[i+1])>>>3,r=(6&e[i+1])>>>1,a=1&e[i+1],s=(192&e[i+2])>>>6,o=(60&e[i+2])>>>2,d=(1&e[i+2])<<2|(192&e[i+3])>>>6,h=(3&e[i+3])<<11|e[i+4]<<3|(224&e[i+5])>>>5;e[i+6];if(i+h>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var _=1===a?7:9,u=h-_;i+=_;var l=this.findNextSyncwordOffset(i+u);if(this.current_syncword_offset_=l,(0===n||1===n)&&0===r){var c=e.subarray(i,i+u);(t=new M).audio_object_type=s+1,t.sampling_freq_index=o,t.sampling_frequency=P[o],t.channel_config=d,t.data=c}}return t},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),U=function(e){var t=null,i=e.audio_object_type,n=e.audio_object_type,r=e.sampling_freq_index,a=e.channel_config,s=0,o=navigator.userAgent.toLowerCase();-1!==o.indexOf("firefox")?r>=6?(n=5,t=new Array(4),s=r-3):(n=2,t=new Array(2),s=r):-1!==o.indexOf("android")?(n=2,t=new Array(2),s=r):(n=5,s=r,t=new Array(4),r>=6?s=r-3:1===a&&(n=2,t=new Array(2),s=r)),t[0]=n<<3,t[0]|=(15&r)>>>1,t[1]=(15&r)<<7,t[1]|=(15&a)<<3,5===n&&(t[1]|=(15&s)>>>1,t[2]=(1&s)<<7,t[2]|=8,t[3]=0),this.config=t,this.sampling_rate=P[r],this.channel_count=a,this.codec_mimetype="mp4a.40."+n,this.original_codec_mimetype="mp4a.40."+i},N=function(){},G=function(){};!function(e){e[e.kSpliceNull=0]="kSpliceNull",e[e.kSpliceSchedule=4]="kSpliceSchedule",e[e.kSpliceInsert=5]="kSpliceInsert",e[e.kTimeSignal=6]="kTimeSignal",e[e.kBandwidthReservation=7]="kBandwidthReservation",e[e.kPrivateCommand=255]="kPrivateCommand"}(O||(O={}));var V,F=function(e){var t=e.readBool();return t?(e.readBits(6),{time_specified_flag:t,pts_time:4*e.readBits(31)+e.readBits(2)}):(e.readBits(7),{time_specified_flag:t})},j=function(e){var t=e.readBool();return e.readBits(6),{auto_return:t,duration:4*e.readBits(31)+e.readBits(2)}},z=function(e,t){var i=t.readBits(8);return e?{component_tag:i}:{component_tag:i,splice_time:F(t)}},H=function(e){return{component_tag:e.readBits(8),utc_splice_time:e.readBits(32)}},q=function(e){var t=e.readBits(32),i=e.readBool();e.readBits(7);var n={splice_event_id:t,splice_event_cancel_indicator:i};if(i)return n;if(n.out_of_network_indicator=e.readBool(),n.program_splice_flag=e.readBool(),n.duration_flag=e.readBool(),e.readBits(5),n.program_splice_flag)n.utc_splice_time=e.readBits(32);else{n.component_count=e.readBits(8),n.components=[];for(var r=0;r=i.byteLength)return this.eof_flag_=!0,i.byteLength;var n=i[t+0]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3],r=i[t+0]<<16|i[t+1]<<8|i[t+2];if(1===n||1===r)return t;t++}},e.prototype.readNextNaluPayload=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_startcode_offset_,n=e[i+=1===(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])?4:3]>>1&63,r=(128&e[i])>>>7,a=this.findNextStartCodeOffset(i);if(this.current_startcode_offset_=a,0===r){var s=e.subarray(i,a);(t=new te).type=n,t.data=s}}return t},e}(),re=function(){function e(e,t,i,n){var r=23+(5+e.byteLength)+(5+t.byteLength)+(5+i.byteLength),a=this.data=new Uint8Array(r);a[0]=1,a[1]=(3&n.general_profile_space)<<6|(n.general_tier_flag?1:0)<<5|31&n.general_profile_idc,a[2]=n.general_profile_compatibility_flags_1,a[3]=n.general_profile_compatibility_flags_2,a[4]=n.general_profile_compatibility_flags_3,a[5]=n.general_profile_compatibility_flags_4,a[6]=n.general_constraint_indicator_flags_1,a[7]=n.general_constraint_indicator_flags_2,a[8]=n.general_constraint_indicator_flags_3,a[9]=n.general_constraint_indicator_flags_4,a[10]=n.general_constraint_indicator_flags_5,a[11]=n.general_constraint_indicator_flags_6,a[12]=60,a[13]=240|(3840&n.min_spatial_segmentation_idc)>>8,a[14]=255&n.min_spatial_segmentation_idc,a[15]=252|3&n.parallelismType,a[16]=252|3&n.chroma_format_idc,a[17]=248|7&n.bit_depth_luma_minus8,a[18]=248|7&n.bit_depth_chroma_minus8,a[19]=0,a[20]=0,a[21]=(3&n.constant_frame_rate)<<6|(7&n.num_temporal_layers)<<3|(n.temporal_id_nested?1:0)<<2|3,a[22]=3,a[23]=128|V.kSliceVPS,a[24]=0,a[25]=1,a[26]=(65280&e.byteLength)>>8,a[27]=(255&e.byteLength)>>0,a.set(e,28),a[23+(5+e.byteLength)+0]=128|V.kSliceSPS,a[23+(5+e.byteLength)+1]=0,a[23+(5+e.byteLength)+2]=1,a[23+(5+e.byteLength)+3]=(65280&t.byteLength)>>8,a[23+(5+e.byteLength)+4]=(255&t.byteLength)>>0,a.set(t,23+(5+e.byteLength)+5),a[23+(5+e.byteLength+5+t.byteLength)+0]=128|V.kSlicePPS,a[23+(5+e.byteLength+5+t.byteLength)+1]=0,a[23+(5+e.byteLength+5+t.byteLength)+2]=1,a[23+(5+e.byteLength+5+t.byteLength)+3]=(65280&i.byteLength)>>8,a[23+(5+e.byteLength+5+t.byteLength)+4]=(255&i.byteLength)>>0,a.set(i,23+(5+e.byteLength+5+t.byteLength)+5)}return e.prototype.getData=function(){return this.data},e}(),ae=(ee=function(e,t){return(ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}ee(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),se=function(){return(se=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=4?(a.a.v("TSDemuxer","ts_packet_size = 192, m2ts mode"),i-=4):204===n&&a.a.v("TSDemuxer","ts_packet_size = 204, RS encoded MPEG2-TS stream"),{match:!0,consumed:0,ts_packet_size:n,sync_offset:i})},t.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},t.prototype.resetMediaInfo=function(){this.media_info_=new o.a},t.prototype.parseChunks=function(e,t){if(!(this.onError&&this.onMediaInfo&&this.onTrackMetadata&&this.onDataAvailable))throw new u.a("onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var i=0;for(this.first_parse_&&(this.first_parse_=!1,i=this.sync_offset_);i+this.ts_packet_size_<=e.byteLength;){var n=t+i;192===this.ts_packet_size_&&(i+=4);var r=new Uint8Array(e,i,188),s=r[0];if(71!==s){a.a.e(this.TAG,"sync_byte = "+s+", not 0x47");break}var o=(64&r[1])>>>6,d=(r[1],(31&r[1])<<8|r[2]),h=(48&r[3])>>>4,_=15&r[3],l={},c=4;if(2==h||3==h){var f=r[4];if(5+f===188){i+=188,204===this.ts_packet_size_&&(i+=16);continue}f>0&&(l=this.parseAdaptationField(e,i+4,1+f)),c=5+f}if(1==h||3==h)if(0===d||d===this.current_pmt_pid_||null!=this.pmt_&&this.pmt_.pid_stream_type[d]===v.kSCTE35){var p=188-c;this.handleSectionSlice(e,i+c,p,{pid:d,file_position:n,payload_unit_start_indicator:o,continuity_conunter:_,random_access_indicator:l.random_access_indicator})}else if(null!=this.pmt_&&null!=this.pmt_.pid_stream_type[d]){p=188-c;var m=this.pmt_.pid_stream_type[d];d!==this.pmt_.common_pids.h264&&d!==this.pmt_.common_pids.h265&&d!==this.pmt_.common_pids.adts_aac&&!0!==this.pmt_.pes_private_data_pids[d]&&!0!==this.pmt_.timed_id3_pids[d]||this.handlePESSlice(e,i+c,p,{pid:d,stream_type:m,file_position:n,payload_unit_start_indicator:o,continuity_conunter:_,random_access_indicator:l.random_access_indicator})}i+=188,204===this.ts_packet_size_&&(i+=16)}return this.dispatchAudioVideoMediaSegment(),i},t.prototype.parseAdaptationField=function(e,t,i){var n=new Uint8Array(e,t,i),r=n[0];return r>0?r>183?(a.a.w(this.TAG,"Illegal adaptation_field_length: "+r),{}):{discontinuity_indicator:(128&n[1])>>>7,random_access_indicator:(64&n[1])>>>6,elementary_stream_priority_indicator:(32&n[1])>>>5}:{}},t.prototype.handleSectionSlice=function(e,t,i,n){var r=new Uint8Array(e,t,i),a=this.section_slice_queues_[n.pid];if(n.payload_unit_start_indicator){var s=r[0];if(null!=a&&0!==a.total_length){var o=new Uint8Array(e,t+1,Math.min(i,s));a.slices.push(o),a.total_length+=o.byteLength,a.total_length===a.expected_length?this.emitSectionSlices(a,n):this.clearSlices(a,n)}for(var d=1+s;d=a.expected_length&&this.clearSlices(a,n),d+=o.byteLength}}else if(null!=a&&0!==a.total_length){o=new Uint8Array(e,t,Math.min(i,a.expected_length-a.total_length));a.slices.push(o),a.total_length+=o.byteLength,a.total_length===a.expected_length?this.emitSectionSlices(a,n):a.total_length>=a.expected_length&&this.clearSlices(a,n)}},t.prototype.handlePESSlice=function(e,t,i,n){var r=new Uint8Array(e,t,i),s=r[0]<<16|r[1]<<8|r[2],o=(r[3],r[4]<<8|r[5]);if(n.payload_unit_start_indicator){if(1!==s)return void a.a.e(this.TAG,"handlePESSlice: packet_start_code_prefix should be 1 but with value "+s);var d=this.pes_slice_queues_[n.pid];d&&(0===d.expected_length||d.expected_length===d.total_length?this.emitPESSlices(d,n):this.clearSlices(d,n)),this.pes_slice_queues_[n.pid]=new L,this.pes_slice_queues_[n.pid].file_position=n.file_position,this.pes_slice_queues_[n.pid].random_access_indicator=n.random_access_indicator}if(null!=this.pes_slice_queues_[n.pid]){var h=this.pes_slice_queues_[n.pid];h.slices.push(r),n.payload_unit_start_indicator&&(h.expected_length=0===o?0:o+6),h.total_length+=r.byteLength,h.expected_length>0&&h.expected_length===h.total_length?this.emitPESSlices(h,n):h.expected_length>0&&h.expected_length>>6,o=t[8],d=void 0,h=void 0;2!==s&&3!==s||(d=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,h=3===s?536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2:d);var _=9+o,u=void 0;if(0!==r){if(r<3+o)return void a.a.v(this.TAG,"Malformed PES: PES_packet_length < 3 + PES_header_data_length");u=r-3-o}else u=t.byteLength-_;var l=t.subarray(_,_+u);switch(e.stream_type){case v.kMPEG1Audio:case v.kMPEG2Audio:break;case v.kPESPrivateData:this.parsePESPrivateDataPayload(l,d,h,e.pid,n);break;case v.kADTSAAC:this.parseAACPayload(l,d);break;case v.kID3:this.parseTimedID3MetadataPayload(l,d,h,e.pid,n);break;case v.kH264:this.parseH264Payload(l,d,h,e.file_position,e.random_access_indicator);break;case v.kH265:this.parseH265Payload(l,d,h,e.file_position,e.random_access_indicator)}}else if((188===n||191===n||240===n||241===n||255===n||242===n||248===n)&&e.stream_type===v.kPESPrivateData){_=6,u=void 0;u=0!==r?r:t.byteLength-_;l=t.subarray(_,_+u);this.parsePESPrivateDataPayload(l,void 0,void 0,e.pid,n)}}else a.a.e(this.TAG,"parsePES: packet_start_code_prefix should be 1 but with value "+i)},t.prototype.parsePAT=function(e){var t=e[0];if(0===t){var i=(15&e[1])<<8|e[2],n=(e[3],e[4],(62&e[5])>>>1),r=1&e[5],s=e[6],o=(e[7],null);if(1===r&&0===s)(o=new S).version_number=n;else if(null==(o=this.pat_))return;for(var d=i-5-4,h=-1,_=-1,u=8;u<8+d;u+=4){var l=e[u]<<8|e[u+1],c=(31&e[u+2])<<8|e[u+3];0===l?o.network_pid=c:(o.program_pmt_pid[l]=c,-1===h&&(h=l),-1===_&&(_=c))}1===r&&0===s&&(null==this.pat_&&a.a.v(this.TAG,"Parsed first PAT: "+JSON.stringify(o)),this.pat_=o,this.current_program_=h,this.current_pmt_pid_=_)}else a.a.e(this.TAG,"parsePAT: table_id "+t+" is not corresponded to PAT!")},t.prototype.parsePMT=function(e){var t=e[0];if(2===t){var i=(15&e[1])<<8|e[2],n=e[3]<<8|e[4],r=(62&e[5])>>>1,s=1&e[5],o=e[6],d=(e[7],null);if(1===s&&0===o)(d=new A).program_number=n,d.version_number=r,this.program_pmt_map_[n]=d;else if(null==(d=this.program_pmt_map_[n]))return;e[8],e[9];for(var h=(15&e[10])<<8|e[11],_=12+h,u=i-9-h-4,l=_;l<_+u;){var c=e[l],f=(31&e[l+1])<<8|e[l+2],p=(15&e[l+3])<<8|e[l+4];if(d.pid_stream_type[f]=c,c!==v.kH264||d.common_pids.h264||d.common_pids.h265)if(c!==v.kH265||d.common_pids.h264||d.common_pids.h265)if(c!==v.kADTSAAC||d.common_pids.adts_aac)if(c===v.kPESPrivateData){if(d.pes_private_data_pids[f]=!0,p>0){var m=e.subarray(l+5,l+5+p);this.dispatchPESPrivateDataDescriptor(f,c,m)}}else c===v.kID3?d.timed_id3_pids[f]=!0:c===v.kSCTE35&&(d.scte_35_pids[f]=!0);else d.common_pids.adts_aac=f;else d.common_pids.h265=f;else d.common_pids.h264=f;l+=5+p}n===this.current_program_&&(null==this.pmt_&&a.a.v(this.TAG,"Parsed first PMT: "+JSON.stringify(d)),this.pmt_=d,(d.common_pids.h264||d.common_pids.h265)&&(this.has_video_=!0),d.common_pids.adts_aac&&(this.has_audio_=!0))}else a.a.e(this.TAG,"parsePMT: table_id "+t+" is not corresponded to PMT!")},t.prototype.parseSCTE35=function(e){var t=$(e);if(null!=t.pts){var i=Math.floor(t.pts/this.timescale_);t.pts=i}else t.nearest_pts=this.aac_last_sample_pts_;this.onSCTE35Metadata&&this.onSCTE35Metadata(t)},t.prototype.parseH264Payload=function(e,t,i,n,r){for(var s=new B(e),o=null,d=[],h=0,_=!1;null!=(o=s.readNextNaluPayload());){var u=new C(o);if(u.type===b.kSliceSPS){var l=p.parseSPS(o.data);this.video_init_segment_dispatched_?!0===this.detectVideoMetadataChange(u,l)&&(a.a.v(this.TAG,"H264: Critical h264 metadata has been changed, attempt to re-generate InitSegment"),this.video_metadata_changed_=!0,this.video_metadata_={vps:void 0,sps:u,pps:void 0,details:l}):(this.video_metadata_.sps=u,this.video_metadata_.details=l)}else u.type===b.kSlicePPS?this.video_init_segment_dispatched_&&!this.video_metadata_changed_||(this.video_metadata_.pps=u,this.video_metadata_.sps&&this.video_metadata_.pps&&(this.video_metadata_changed_&&this.dispatchVideoMediaSegment(),this.dispatchVideoInitSegment())):(u.type===b.kSliceIDR||u.type===b.kSliceNonIDR&&1===r)&&(_=!0);this.video_init_segment_dispatched_&&(d.push(u),h+=u.data.byteLength)}var c=Math.floor(t/this.timescale_),f=Math.floor(i/this.timescale_);if(d.length){var m=this.video_track_,g={units:d,length:h,isKeyframe:_,dts:f,pts:c,cts:c-f,file_position:n};m.samples.push(g),m.length+=h}},t.prototype.parseH265Payload=function(e,t,i,n,r){for(var s=new ne(e),o=null,d=[],h=0,_=!1;null!=(o=s.readNextNaluPayload());){var u=new ie(o);if(u.type===V.kSliceVPS){if(!this.video_init_segment_dispatched_){var l=g.parseVPS(o.data);this.video_metadata_.vps=u,this.video_metadata_.details=se(se({},this.video_metadata_.details),l)}}else if(u.type===V.kSliceSPS){l=g.parseSPS(o.data);this.video_init_segment_dispatched_?!0===this.detectVideoMetadataChange(u,l)&&(a.a.v(this.TAG,"H265: Critical h265 metadata has been changed, attempt to re-generate InitSegment"),this.video_metadata_changed_=!0,this.video_metadata_={vps:void 0,sps:u,pps:void 0,details:l}):(this.video_metadata_.sps=u,this.video_metadata_.details=se(se({},this.video_metadata_.details),l))}else if(u.type===V.kSlicePPS){if(!this.video_init_segment_dispatched_||this.video_metadata_changed_){l=g.parsePPS(o.data);this.video_metadata_.pps=u,this.video_metadata_.details=se(se({},this.video_metadata_.details),l),this.video_metadata_.vps&&this.video_metadata_.sps&&this.video_metadata_.pps&&(this.video_metadata_changed_&&this.dispatchVideoMediaSegment(),this.dispatchVideoInitSegment())}}else u.type!==V.kSliceIDR_W_RADL&&u.type!==V.kSliceIDR_N_LP||(_=!0);this.video_init_segment_dispatched_&&(d.push(u),h+=u.data.byteLength)}var c=Math.floor(t/this.timescale_),f=Math.floor(i/this.timescale_);if(d.length){var p=this.video_track_,m={units:d,length:h,isKeyframe:_,dts:f,pts:c,cts:c-f,file_position:n};p.samples.push(m),p.length+=h}},t.prototype.detectVideoMetadataChange=function(e,t){if(t.codec_mimetype!==this.video_metadata_.details.codec_mimetype)return a.a.v(this.TAG,"Video: Codec mimeType changed from "+this.video_metadata_.details.codec_mimetype+" to "+t.codec_mimetype),!0;if(t.codec_size.width!==this.video_metadata_.details.codec_size.width||t.codec_size.height!==this.video_metadata_.details.codec_size.height){var i=this.video_metadata_.details.codec_size,n=t.codec_size;return a.a.v(this.TAG,"Video: Coded Resolution changed from "+i.width+"x"+i.height+" to "+n.width+"x"+n.height),!0}return t.present_size.width!==this.video_metadata_.details.present_size.width&&(a.a.v(this.TAG,"Video: Present resolution width changed from "+this.video_metadata_.details.present_size.width+" to "+t.present_size.width),!0)},t.prototype.isInitSegmentDispatched=function(){return this.has_video_&&this.has_audio_?this.video_init_segment_dispatched_&&this.audio_init_segment_dispatched_:this.has_video_&&!this.has_audio_?this.video_init_segment_dispatched_:!(this.has_video_||!this.has_audio_)&&this.audio_init_segment_dispatched_},t.prototype.dispatchVideoInitSegment=function(){var e=this.video_metadata_.details,t={type:"video"};t.id=this.video_track_.id,t.timescale=1e3,t.duration=this.duration_,t.codecWidth=e.codec_size.width,t.codecHeight=e.codec_size.height,t.presentWidth=e.present_size.width,t.presentHeight=e.present_size.height,t.profile=e.profile_string,t.level=e.level_string,t.bitDepth=e.bit_depth,t.chromaFormat=e.chroma_format,t.sarRatio=e.sar_ratio,t.frameRate=e.frame_rate;var i=t.frameRate.fps_den,n=t.frameRate.fps_num;if(t.refSampleDuration=i/n*1e3,t.codec=e.codec_mimetype,this.video_metadata_.vps){var r=this.video_metadata_.vps.data.subarray(4),s=this.video_metadata_.sps.data.subarray(4),o=this.video_metadata_.pps.data.subarray(4),d=new re(r,s,o,e);t.hvcc=d.getData(),0==this.video_init_segment_dispatched_&&a.a.v(this.TAG,"Generated first HEVCDecoderConfigurationRecord for mimeType: "+t.codec)}else{s=this.video_metadata_.sps.data.subarray(4),o=this.video_metadata_.pps.data.subarray(4);var h=new I(s,o,e);t.avcc=h.getData(),0==this.video_init_segment_dispatched_&&a.a.v(this.TAG,"Generated first AVCDecoderConfigurationRecord for mimeType: "+t.codec)}this.onTrackMetadata("video",t),this.video_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var _=this.media_info_;_.hasVideo=!0,_.width=t.codecWidth,_.height=t.codecHeight,_.fps=t.frameRate.fps,_.profile=t.profile,_.level=t.level,_.refFrames=e.ref_frames,_.chromaFormat=e.chroma_format_string,_.sarNum=t.sarRatio.width,_.sarDen=t.sarRatio.height,_.videoCodec=t.codec,_.hasAudio&&_.audioCodec?_.mimeType='video/mp2t; codecs="'+_.videoCodec+","+_.audioCodec+'"':_.mimeType='video/mp2t; codecs="'+_.videoCodec+'"',_.isComplete()&&this.onMediaInfo(_)},t.prototype.dispatchVideoMediaSegment=function(){this.isInitSegmentDispatched()&&this.video_track_.length&&this.onDataAvailable(null,this.video_track_)},t.prototype.dispatchAudioMediaSegment=function(){this.isInitSegmentDispatched()&&this.audio_track_.length&&this.onDataAvailable(this.audio_track_,null)},t.prototype.dispatchAudioVideoMediaSegment=function(){this.isInitSegmentDispatched()&&(this.audio_track_.length||this.video_track_.length)&&this.onDataAvailable(this.audio_track_,this.video_track_)},t.prototype.parseAACPayload=function(e,t){if(!this.has_video_||this.video_init_segment_dispatched_){if(this.aac_last_incomplete_data_){var i=new Uint8Array(e.byteLength+this.aac_last_incomplete_data_.byteLength);i.set(this.aac_last_incomplete_data_,0),i.set(e,this.aac_last_incomplete_data_.byteLength),e=i}var n,r;if(null!=t)r=t/this.timescale_;else{if(null==this.aac_last_sample_pts_)return void a.a.w(this.TAG,"AAC: Unknown pts");n=1024/this.audio_metadata_.sampling_frequency*1e3,r=this.aac_last_sample_pts_+n}if(this.aac_last_incomplete_data_&&this.aac_last_sample_pts_){n=1024/this.audio_metadata_.sampling_frequency*1e3;var s=this.aac_last_sample_pts_+n;Math.abs(s-r)>1&&(a.a.w(this.TAG,"AAC: Detected pts overlapped, expected: "+s+"ms, PES pts: "+r+"ms"),r=s)}for(var o,d=new x(e),h=null,_=r;null!=(h=d.readNextAACFrame());){n=1024/h.sampling_frequency*1e3,0==this.audio_init_segment_dispatched_?(this.audio_metadata_.audio_object_type=h.audio_object_type,this.audio_metadata_.sampling_freq_index=h.sampling_freq_index,this.audio_metadata_.sampling_frequency=h.sampling_frequency,this.audio_metadata_.channel_config=h.channel_config,this.dispatchAudioInitSegment(h)):this.detectAudioMetadataChange(h)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(h)),o=_;var u=Math.floor(_),l={unit:h.data,length:h.data.byteLength,pts:u,dts:u};this.audio_track_.samples.push(l),this.audio_track_.length+=h.data.byteLength,_+=n}d.hasIncompleteData()&&(this.aac_last_incomplete_data_=d.getIncompleteData()),o&&(this.aac_last_sample_pts_=o)}},t.prototype.detectAudioMetadataChange=function(e){return e.audio_object_type!==this.audio_metadata_.audio_object_type?(a.a.v(this.TAG,"AAC: AudioObjectType changed from "+this.audio_metadata_.audio_object_type+" to "+e.audio_object_type),!0):e.sampling_freq_index!==this.audio_metadata_.sampling_freq_index?(a.a.v(this.TAG,"AAC: SamplingFrequencyIndex changed from "+this.audio_metadata_.sampling_freq_index+" to "+e.sampling_freq_index),!0):e.channel_config!==this.audio_metadata_.channel_config&&(a.a.v(this.TAG,"AAC: Channel configuration changed from "+this.audio_metadata_.channel_config+" to "+e.channel_config),!0)},t.prototype.dispatchAudioInitSegment=function(e){var t=new U(e),i={type:"audio"};i.id=this.audio_track_.id,i.timescale=1e3,i.duration=this.duration_,i.audioSampleRate=t.sampling_rate,i.channelCount=t.channel_count,i.codec=t.codec_mimetype,i.originalCodec=t.original_codec_mimetype,i.config=t.config,i.refSampleDuration=1024/i.audioSampleRate*i.timescale,0==this.audio_init_segment_dispatched_&&a.a.v(this.TAG,"Generated first AudioSpecificConfig for mimeType: "+i.codec),this.onTrackMetadata("audio",i),this.audio_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var n=this.media_info_;n.hasAudio=!0,n.audioCodec=i.originalCodec,n.audioSampleRate=i.audioSampleRate,n.audioChannelCount=i.channelCount,n.hasVideo&&n.videoCodec?n.mimeType='video/mp2t; codecs="'+n.videoCodec+","+n.audioCodec+'"':n.mimeType='video/mp2t; codecs="'+n.audioCodec+'"',n.isComplete()&&this.onMediaInfo(n)},t.prototype.dispatchPESPrivateDataDescriptor=function(e,t,i){var n=new G;n.pid=e,n.stream_type=t,n.descriptor=i,this.onPESPrivateDataDescriptor&&this.onPESPrivateDataDescriptor(n)},t.prototype.parsePESPrivateDataPayload=function(e,t,i,n,r){var a=new N;if(a.pid=n,a.stream_id=r,a.len=e.byteLength,a.data=e,null!=t){var s=Math.floor(t/this.timescale_);a.pts=s}else a.nearest_pts=this.aac_last_sample_pts_;if(null!=i){var o=Math.floor(i/this.timescale_);a.dts=o}this.onPESPrivateData&&this.onPESPrivateData(a)},t.prototype.parseTimedID3MetadataPayload=function(e,t,i,n,r){var a=new N;if(a.pid=n,a.stream_id=r,a.len=e.byteLength,a.data=e,null!=t){var s=Math.floor(t/this.timescale_);a.pts=s}if(null!=i){var o=Math.floor(i/this.timescale_);a.dts=o}this.onTimedID3Metadata&&this.onTimedID3Metadata(a)},t}(E),de=function(){function e(){}return e.init=function(){for(var t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],hvc1:[],hvcC:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=e.constants={};i.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),i.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),i.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSC=i.STCO=i.STTS,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.HDLR_VIDEO=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]),i.HDLR_AUDIO=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]),i.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=8,i=null,n=Array.prototype.slice.call(arguments,1),r=n.length,a=0;a>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);var s=8;for(a=0;a>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var i=t.id,n=t.duration,r=t.presentWidth,a=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,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,r>>>8&255,255&r,0,0,a>>>8&255,255&a,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var i=t.timescale,n=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))},e.hdlr=function(t){var i=null;return i="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,i)},e.minf=function(t){var i=null;return i="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,i,e.dinf(),e.stbl(t))},e.dinf=function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):"video"===t.type&&t.codec.startsWith("hvc1")?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.hvc1(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types[".mp3"],r)},e.mp4a=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types.mp4a,r,e.esds(t))},e.esds=function(t){var i=t.config||[],n=i.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(i).concat([6,1,2]));return e.box(e.types.esds,r)},e.avc1=function(t){var i=t.avcc,n=t.codecWidth,r=t.codecHeight,a=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,n>>>8&255,255&n,r>>>8&255,255&r,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 e.box(e.types.avc1,a,e.box(e.types.avcC,i))},e.hvc1=function(t){var i=t.hvcc,n=t.codecWidth,r=t.codecHeight,a=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,n>>>8&255,255&n,r>>>8&255,255&r,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 e.box(e.types.hvc1,a,e.box(e.types.hvcC,i))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var i=t.id,n=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,n)},e.moof=function(t,i){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,i))},e.mfhd=function(t){var i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,i)},e.traf=function(t,i){var n=t.id,r=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),a=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),s=e.sdtp(t),o=e.trun(t,s.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,r,a,o,s)},e.sdtp=function(t){for(var i=t.samples||[],n=i.length,r=new Uint8Array(4+n),a=0;a>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0);for(var o=0;o>>24&255,d>>>16&255,d>>>8&255,255&d,h>>>24&255,h>>>16&255,h>>>8&255,255&h,_.isLeading<<2|_.dependsOn,_.isDependedOn<<6|_.hasRedundancy<<4|_.isNonSync,0,0,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*o)}return e.box(e.types.trun,s)},e.mdat=function(t){return e.box(e.types.mdat,t)},e}();de.init();var he=de,_e=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){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])}else{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},e}(),ue=i(7),le=function(){function e(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,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 ue.c("audio"),this._videoSegmentInfoList=new ue.c("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!s.a.chrome||!(s.a.version.major<50||50===s.a.version.major&&s.a.version.build<2661)),this._fillSilentAfterSeek=s.a.msedge||s.a.msie,this._mp3UseMpegAudio=!s.a.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.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},e.prototype.bindDataSource=function(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,t){if(!this._onMediaSegment)throw new u.a("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),t&&this._remuxVideo(t),e&&this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,t){var i=null,n="mp4",r=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(n="mpeg",r="",i=new Uint8Array):i=he.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=he.generateInitSegment(t)}if(!this._onInitSegment)throw new u.a("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:r,container:e+"/"+n,mediaDuration:t.duration})},e.prototype._calculateDtsBase=function(e,t){this._dtsBaseInited||(e&&e.samples&&e.samples.length&&(this._audioDtsBase=e.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)},e.prototype.getTimestampBase=function(){if(this._dtsBaseInited)return this._dtsBase},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);var n={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(n.samples.push(t),n.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(n,!0)},e.prototype._remuxAudio=function(e,t){if(null!=this._audioMeta){var i,n=e,r=n.samples,o=void 0,d=-1,h=this._audioMeta.refSampleDuration,_="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,u=this._dtsBaseInited&&void 0===this._audioNextDts,l=!1;if(r&&0!==r.length&&(1!==r.length||t)){var c=0,f=null,p=0;_?(c=0,p=n.length):(c=8,p=8+n.length);var m=null;if(r.length>1&&(p-=(m=r.pop()).length),null!=this._audioStashedLastSample){var g=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(g),p+=g.length}null!=m&&(this._audioStashedLastSample=m);var v=r[0].dts-this._dtsBase;if(this._audioNextDts)o=v-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())o=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(l=!0);else{var y=this._audioSegmentInfoList.getLastSampleBefore(v);if(null!=y){var E=v-(y.originalDts+y.duration);E<=3&&(E=0),o=v-(y.dts+y.duration+E)}else o=0}if(l){var S=v-o,b=this._videoSegmentInfoList.getLastSegmentBefore(v);if(null!=b&&b.beginDts=3*h&&this._fillAudioTimestampGap&&!s.a.safari){D=!0;var O,P=Math.floor(o/h);a.a.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\noriginalDts: "+k+" ms, curRefDts: "+I+" ms, dtsCorrection: "+Math.round(o)+" ms, generate: "+P+" frames"),A=Math.floor(I),B=Math.floor(I+h)-A,null==(O=_e.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount))&&(a.a.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),O=w),C=[];for(var M=0;M=1?T[T.length-1].duration:Math.floor(h);this._audioNextDts=A+B}-1===d&&(d=A),T.push({dts:A,pts:A,cts:0,unit:g.unit,size:g.unit.byteLength,duration:B,originalDts:k,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),D&&T.push.apply(T,C)}}if(0===T.length)return n.samples=[],void(n.length=0);_?f=new Uint8Array(p):((f=new Uint8Array(p))[0]=p>>>24&255,f[1]=p>>>16&255,f[2]=p>>>8&255,f[3]=255&p,f.set(he.types.mdat,4));for(L=0;L1&&(u-=(l=a.pop()).length),null!=this._videoStashedLastSample){var c=this._videoStashedLastSample;this._videoStashedLastSample=null,a.unshift(c),u+=c.length}null!=l&&(this._videoStashedLastSample=l);var f=a[0].dts-this._dtsBase;if(this._videoNextDts)s=f-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())s=0;else{var p=this._videoSegmentInfoList.getLastSampleBefore(f);if(null!=p){var m=f-(p.originalDts+p.duration);m<=3&&(m=0),s=f-(p.dts+p.duration+m)}else s=0}for(var g=new ue.b,v=[],y=0;y=1?v[v.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(S){var L=new ue.d(b,R,T,c.dts,!0);L.fileposition=c.fileposition,g.appendSyncPoint(L)}v.push({dts:b,pts:R,cts:A,units:c.units,size:c.length,isKeyframe:S,duration:T,originalDts:E,flags:{isLeading:0,dependsOn:S?2:1,isDependedOn:S?1:0,hasRedundancy:0,isNonSync:S?0:1}})}(_=new Uint8Array(u))[0]=u>>>24&255,_[1]=u>>>16&255,_[2]=u>>>8&255,_[3]=255&u,_.set(he.types.mdat,4);for(y=0;y0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=oe.probe(e)).match){var s=this._demuxer=new oe(n,this._config);this._remuxer||(this._remuxer=new le(this._config)),s.onError=this._onDemuxException.bind(this),s.onMediaInfo=this._onMediaInfo.bind(this),s.onMetaDataArrived=this._onMetaDataArrived.bind(this),s.onTimedID3Metadata=this._onTimedID3Metadata.bind(this),s.onSCTE35Metadata=this._onSCTE35Metadata.bind(this),s.onPESPrivateDataDescriptor=this._onPESPrivateDataDescriptor.bind(this),s.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),r=this._demuxer.parseChunks(e,t)}else if((n=y.probe(e)).match){this._demuxer=new y(n,this._config),this._remuxer||(this._remuxer=new le(this._config));var o=this._mediaDataSource;null==o.duration||isNaN(o.duration)||(this._demuxer.overridedDuration=o.duration),"boolean"==typeof o.hasAudio&&(this._demuxer.overridedHasAudio=o.hasAudio),"boolean"==typeof o.hasVideo&&(this._demuxer.overridedHasVideo=o.hasVideo),this._demuxer.timestampBase=o.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._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),r=this._demuxer.parseChunks(e,t)}else n=null,a.a.e(this.TAG,"Non MPEG-TS/FLV, Unsupported media type!"),Promise.resolve().then((function(){i._internalAbort()})),this._emitter.emit(fe.a.DEMUX_ERROR,m.a.FORMAT_UNSUPPORTED,"Non MPEG-TS/FLV, Unsupported media type!"),r=0;return r},e.prototype._onMediaInfo=function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,o.a.prototype));var i=Object.assign({},e);Object.setPrototypeOf(i,o.a.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=i,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(fe.a.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(fe.a.SCRIPTDATA_ARRIVED,e)},e.prototype._onTimedID3Metadata=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.dts&&(e.dts-=t),this._emitter.emit(fe.a.TIMED_ID3_METADATA_ARRIVED,e))},e.prototype._onSCTE35Metadata=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.nearest_pts&&(e.nearest_pts-=t),this._emitter.emit(fe.a.SCTE35_METADATA_ARRIVED,e))},e.prototype._onPESPrivateDataDescriptor=function(e){this._emitter.emit(fe.a.PES_PRIVATE_DATA_DESCRIPTOR,e)},e.prototype._onPESPrivateData=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.nearest_pts&&(e.nearest_pts-=t),null!=e.dts&&(e.dts-=t),this._emitter.emit(fe.a.PES_PRIVATE_DATA_ARRIVED,e))},e.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e+1;t0&&i[0].originalDts===n&&(n=i[0].pts),this._emitter.emit(fe.a.RECOMMEND_SEEKPOINT,n)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(fe.a.MEDIA_INFO,i)},e.prototype._reportStatisticsInfo=function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(fe.a.STATISTICS_INFO,e)},e}();t.a=pe},function(e,t,i){"use strict";var n,r=i(0),a=function(){function e(){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 e.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},e.prototype.addBytes=function(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())},Object.defineProperty(e.prototype,"currentKBps",{get:function(){this.addBytes(0);var e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}(),s=i(2),o=i(4),d=i(3),h=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),_=function(e){function t(t,i){var n=e.call(this,"fetch-stream-loader")||this;return n.TAG="FetchStreamLoader",n._seekHandler=t,n._config=i,n._needStash=!0,n._requestAbort=!1,n._abortController=null,n._contentLength=null,n._receivedLength=0,n}return h(t,e),t.isSupported=function(){try{var e=o.a.msedge&&o.a.version.minor>=15048,t=!o.a.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){var i=this;this._dataSource=e,this._range=t;var n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);var r=this._seekHandler.getConfig(n,t),a=new self.Headers;if("object"==typeof r.headers){var o=r.headers;for(var h in o)o.hasOwnProperty(h)&&a.append(h,o[h])}var _={method:"GET",headers:a,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(var h in this._config.headers)a.append(h,this._config.headers[h]);!1===e.cors&&(_.mode="same-origin"),e.withCredentials&&(_.credentials="include"),e.referrerPolicy&&(_.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,_.signal=this._abortController.signal),this._status=s.c.kConnecting,self.fetch(r.url,_).then((function(e){if(i._requestAbort)return i._status=s.c.kIdle,void e.body.cancel();if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&i._onURLRedirect){var t=i._seekHandler.removeURLParameters(e.url);i._onURLRedirect(t)}var n=e.headers.get("Content-Length");return null!=n&&(i._contentLength=parseInt(n),0!==i._contentLength&&i._onContentLengthKnown&&i._onContentLengthKnown(i._contentLength)),i._pump.call(i,e.body.getReader())}if(i._status=s.c.kError,!i._onError)throw new d.d("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);i._onError(s.b.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){if(!i._abortController||!i._abortController.signal.aborted){if(i._status=s.c.kError,!i._onError)throw e;i._onError(s.b.EXCEPTION,{code:-1,msg:e.message})}}))},t.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==s.c.kBuffering||!o.a.chrome)&&this._abortController)try{this._abortController.abort()}catch(e){}},t.prototype._pump=function(e){var t=this;return e.read().then((function(i){if(i.done)if(null!==t._contentLength&&t._receivedLength299)){if(this._status=s.c.kError,!this._onError)throw new d.d("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.b.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=s.c.kBuffering}},t.prototype._onProgress=function(e){if(this._status!==s.c.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}},t.prototype._onLoadEnd=function(e){!0!==this._requestAbort?this._status!==s.c.kError&&(this._status=s.c.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},t.prototype._onXhrError=function(e){this._status=s.c.kError;var t=0,i=null;if(this._contentLength&&e.loaded=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)},t.prototype._internalOpen=function(e,t){this._lastTimeLoaded=0;var i=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?i=this._currentRedirectedURL:null!=e.redirectedURL&&(i=e.redirectedURL));var n=this._seekHandler.getConfig(i,t);this._currentRequestURL=n.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",n.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"==typeof n.headers){var a=n.headers;for(var s in a)a.hasOwnProperty(s)&&r.setRequestHeader(s,a[s])}if("object"==typeof this._config.headers){a=this._config.headers;for(var s in a)a.hasOwnProperty(s)&&r.setRequestHeader(s,a[s])}r.send()},t.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=s.c.kComplete},t.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)},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(null!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=s.c.kBuffering}else{if(this._status=s.c.kError,!this._onError)throw new d.d("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.b.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}},t.prototype._onProgress=function(e){if(this._status!==s.c.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var n=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(n)}},t.prototype._normalizeSpeed=function(e){var t=this._chunkSizeKBList,i=t.length-1,n=0,r=0,a=i;if(e=t[n]&&e=3&&(t=this._speedSampler.currentKBps)),0!==t){var i=this._normalizeSpeed(t);this._currentSpeedNormalized!==i&&(this._currentSpeedNormalized=i,this._currentChunkSizeKB=i)}var n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;var a=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength0)for(var a=i.split("&"),s=0;s0;o[0]!==this._startName&&o[0]!==this._endName&&(d&&(r+="&"),r+=a[s])}return 0===r.length?t:t+"?"+r},e}(),y=function(){function e(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=65536,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new a,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 e.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},e.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){return this._loaderClass===f?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new g(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new v(t,i)}else{if("custom"!==e.seekType)throw new d.b("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new d.b("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=m;else if(_.isSupported())this._loaderClass=_;else if(l.isSupported())this._loaderClass=l;else{if(!f.isSupported())throw new d.d("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=f}},e.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(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)},e.prototype.open=function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(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)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!=typeof e||0===e.length)throw new d.b("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){for(var t=this._stashSize;t+10485760){var n=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(i,0,t).set(n,0)}this._stashBuffer=i,this._bufferSize=t}},e.prototype._normalizeSpeed=function(e){var t=this._speedNormalizeList,i=t.length-1,n=0,r=0,a=i;if(e=t[n]&&e=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(t=8192);var i=1024*t+1048576;this._bufferSize0){var a=this._stashBuffer.slice(0,this._stashUsed);if((h=this._dispatchChunks(a,this._stashByteStart))0){_=new Uint8Array(a,h);o.set(_,0),this._stashUsed=_.byteLength,this._stashByteStart+=h}}else this._stashUsed=0,this._stashByteStart+=h;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{if((h=this._dispatchChunks(e,t))this._bufferSize&&(this._expandBuffer(s),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e,h),0),this._stashUsed+=s,this._stashByteStart=t+h}}else if(0===this._stashUsed){var s;if((h=this._dispatchChunks(e,t))this._bufferSize&&this._expandBuffer(s),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e,h),0),this._stashUsed+=s,this._stashByteStart=t+h}else{var o,h;if(this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength,(h=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart))0){var _=new Uint8Array(this._stashBuffer,h);o.set(_,0)}this._stashUsed-=h,this._stashByteStart+=h}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),n=t.byteLength-i;if(i0){var a=new Uint8Array(this._stashBuffer,0,this._bufferSize),s=new Uint8Array(t,i);a.set(s,0),this._stashUsed=s.byteLength,this._stashByteStart+=i}return 0}r.a.w(this.TAG,n+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,n}return 0},e.prototype._onLoaderComplete=function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,t){switch(r.a.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=s.b.UNRECOVERABLE_EARLY_EOF),e){case s.b.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var i=this._currentRange.to+1;return void(i0}),!1)}e.exports=function(e,t){t=t||{};var r={main:i.m},o=t.all?{main:Object.keys(r.main)}:function(e,t){for(var i={main:[t]},n={main:[]},r={main:{}};s(i);)for(var o=Object.keys(i),d=0;d1)for(var i=1;i0&&(n+=";codecs="+i.codec);var r=!1;if(u.a.v(this.TAG,"Received Initialization Segment, mimeType: "+n),this._lastInitSegments[i.type]=i,n!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])u.a.v(this.TAG,"Notice: "+i.type+" mimeType changed, origin: "+this._mimeTypes[i.type]+", target: "+n);else{r=!0;try{var a=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(n);a.addEventListener("error",this.e.onSourceBufferError),a.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return u.a.e(this.TAG,e.message),void this._emitter.emit(S.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=n}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),l.a.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.seek=function(e){for(var t in this._sourceBuffers)if(this._sourceBuffers[t]){var i=this._sourceBuffers[t];if("open"===this._mediaSource.readyState)try{i.abort()}catch(e){u.a.e(this.TAG,e.message)}this._idrList.clear();var n=this._pendingSegments[t];if(n.splice(0,n.length),"closed"!==this._mediaSource.readyState){for(var r=0;r=1&&e-n.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){for(var n=i.buffered,r=!1,a=0;a=this._config.autoCleanupMaxBackwardDuration){r=!0;var d=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:s,end:d})}}else o0&&(isNaN(t)||i>t)&&(u.a.v(this.TAG,"Update MediaSource duration from "+t+" to "+i),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(var t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];i.length&&!t.updating;){var n=i.shift();t.remove(n.start,n.end)}},e.prototype._doAppendSegments=function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var i=e[t].shift();if(i.timestampOffset){var n=this._sourceBuffers[t].timestampOffset,r=i.timestampOffset/1e3;Math.abs(n-r)>.1&&(u.a.v(this.TAG,"Update MPEG audio timestampOffset from "+n+" to "+r),this._sourceBuffers[t].timestampOffset=r),delete i.timestampOffset}if(!i.data||0===i.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(i.data),this._isBufferFull=!1,"video"===t&&i.hasOwnProperty("info")&&this._idrList.appendArray(i.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(i),22===e.code?(this._isBufferFull||this._emitter.emit(S.BUFFER_FULL),this._isBufferFull=!0):(u.a.e(this.TAG,e.message),this._emitter.emit(S.ERROR,{code:e.code,msg:e.message}))}}},e.prototype._onSourceOpen=function(){if(u.a.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var e=this._pendingSourceBufferInit;e.length;){var t=e.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(S.SOURCE_OPEN)},e.prototype._onSourceEnded=function(){u.a.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){u.a.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(S.UPDATE_END)},e.prototype._onSourceBufferError=function(e){u.a.e(this.TAG,"SourceBuffer Error: "+e)},e}(),T=i(5),L={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},w={NETWORK_EXCEPTION:d.b.EXCEPTION,NETWORK_STATUS_CODE_INVALID:d.b.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:d.b.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:d.b.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:T.a.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:T.a.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:T.a.CODEC_UNSUPPORTED},k=function(){function e(e,t){this.TAG="MSEPlayer",this._type="MSEPlayer",this._emitter=new _.a,this._config=s(),"object"==typeof t&&Object.assign(this._config,t);var i=e.type.toLowerCase();if("mse"!==i&&"mpegts"!==i&&"m2ts"!==i&&"flv"!==i)throw new A.b("MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var n=l.a.chrome&&(l.a.version.major<50||50===l.a.version.major&&l.a.version.build<2661);this._alwaysSeekKeyframe=!!(n||l.a.msedge||l.a.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return e.prototype.destroy=function(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;e===c.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then((function(){i._emitter.emit(c.MEDIA_INFO,i.mediaInfo)})):e===c.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then((function(){i._emitter.emit(c.STATISTICS_INFO,i.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){var t=this;if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new R(this._config),this._msectl.on(S.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(S.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(S.SOURCE_OPEN,(function(){t._mseSourceOpened=!0,t._hasPendingLoad&&(t._hasPendingLoad=!1,t.load())})),this._msectl.on(S.ERROR,(function(e){t._emitter.emit(c.ERROR,L.MEDIA_ERROR,w.MEDIA_MSE_ERROR,e)})),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},e.prototype.load=function(){var e=this;if(!this._mediaElement)throw new A.a("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new A.a("MSEPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new E(this._mediaDataSource,this._config),this._transmuxer.on(v.a.INIT_SEGMENT,(function(t,i){e._msectl.appendInitSegment(i)})),this._transmuxer.on(v.a.MEDIA_SEGMENT,(function(t,i){if(e._msectl.appendMediaSegment(i),e._config.lazyLoad&&!e._config.isLive){var n=e._mediaElement.currentTime;i.info.endDts>=1e3*(n+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(u.a.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}})),this._transmuxer.on(v.a.LOADING_COMPLETE,(function(){e._msectl.endOfStream(),e._emitter.emit(c.LOADING_COMPLETE)})),this._transmuxer.on(v.a.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(c.RECOVERED_EARLY_EOF)})),this._transmuxer.on(v.a.IO_ERROR,(function(t,i){e._emitter.emit(c.ERROR,L.NETWORK_ERROR,t,i)})),this._transmuxer.on(v.a.DEMUX_ERROR,(function(t,i){e._emitter.emit(c.ERROR,L.MEDIA_ERROR,t,{code:-1,msg:i})})),this._transmuxer.on(v.a.MEDIA_INFO,(function(t){e._mediaInfo=t,e._emitter.emit(c.MEDIA_INFO,Object.assign({},t))})),this._transmuxer.on(v.a.METADATA_ARRIVED,(function(t){e._emitter.emit(c.METADATA_ARRIVED,t)})),this._transmuxer.on(v.a.SCRIPTDATA_ARRIVED,(function(t){e._emitter.emit(c.SCRIPTDATA_ARRIVED,t)})),this._transmuxer.on(v.a.TIMED_ID3_METADATA_ARRIVED,(function(t){e._emitter.emit(c.TIMED_ID3_METADATA_ARRIVED,t)})),this._transmuxer.on(v.a.SCTE35_METADATA_ARRIVED,(function(t){e._emitter.emit(c.SCTE35_METADATA_ARRIVED,t)})),this._transmuxer.on(v.a.PES_PRIVATE_DATA_DESCRIPTOR,(function(t){e._emitter.emit(c.PES_PRIVATE_DATA_DESCRIPTOR,t)})),this._transmuxer.on(v.a.PES_PRIVATE_DATA_ARRIVED,(function(t){e._emitter.emit(c.PES_PRIVATE_DATA_ARRIVED,t)})),this._transmuxer.on(v.a.STATISTICS_INFO,(function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(c.STATISTICS_INFO,Object.assign({},e._statisticsInfo))})),this._transmuxer.on(v.a.RECOMMEND_SEEKPOINT,(function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)})),this._transmuxer.open()))},e.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._mediaInfo)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)},enumerable:!1,configurable:!0}),e.prototype._fillStatisticsInfo=function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e},e.prototype._onmseUpdateEnd=function(){var e=this._mediaElement.buffered,t=this._mediaElement.currentTime;if(this._config.isLive&&this._config.liveBufferLatencyChasing&&e.length>0&&!this._mediaElement.paused){var i=e.end(e.length-1);if(i>this._config.liveBufferLatencyMaxLatency&&i-t>this._config.liveBufferLatencyMaxLatency){var n=i-this._config.liveBufferLatencyMinRemain;this.currentTime=n}}if(this._config.lazyLoad&&!this._config.isLive){for(var r=0,a=0;a=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(u.a.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},e.prototype._onmseBufferFull=function(){u.a.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()},e.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},e.prototype._checkProgressAndResume=function(){for(var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1,n=0;n=r&&e=a-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(u.a.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))},e.prototype._isTimepointBuffered=function(e){for(var t=this._mediaElement.buffered,i=0;i=n&&e0){var r=this._mediaElement.buffered.start(0);(r<1&&e0&&t.currentTime0){var n=i.start(0);if(n<1&&t0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){var e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e},enumerable:!1,configurable:!0}),e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(c.MEDIA_INFO,this.mediaInfo)},e.prototype._reportStatisticsInfo=function(){this._emitter.emit(c.STATISTICS_INFO,this.statisticsInfo)},e}();n.a.install();var C={createPlayer:function(e,t){var i=e;if(null==i||"object"!=typeof i)throw new A.b("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new A.b("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"mse":case"mpegts":case"m2ts":case"flv":return new k(i,t);default:return new D(i,t)}},isSupported:function(){return o.supportMSEH264Playback()},getFeatureList:function(){return o.getFeatureList()}};C.BaseLoader=d.a,C.LoaderStatus=d.c,C.LoaderErrors=d.b,C.Events=c,C.ErrorTypes=L,C.ErrorDetails=w,C.MSEPlayer=k,C.NativePlayer=D,C.LoggingControl=m.a,Object.defineProperty(C,"version",{enumerable:!0,get:function(){return"1.6.10"}});t.default=C}])})); +//# sourceMappingURL=mpegts.js.map \ No newline at end of file diff --git a/trunk/research/players/js/mpegts.js.map b/trunk/research/players/js/mpegts.js.map new file mode 100644 index 0000000000..a288f750d5 --- /dev/null +++ b/trunk/research/players/js/mpegts.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://mpegts/webpack/universalModuleDefinition","webpack://mpegts/webpack/bootstrap","webpack://mpegts/./src/utils/logger.js","webpack://mpegts/./src/core/transmuxing-events.js","webpack://mpegts/./src/io/loader.js","webpack://mpegts/./src/utils/exception.js","webpack://mpegts/./src/utils/browser.js","webpack://mpegts/./src/demux/demux-errors.js","webpack://mpegts/./node_modules/events/events.js","webpack://mpegts/./src/core/media-segment-info.js","webpack://mpegts/./src/core/media-info.js","webpack://mpegts/./src/utils/logging-control.js","webpack://mpegts/./src/utils/utf8-conv.js","webpack://mpegts/./src/demux/amf-parser.js","webpack://mpegts/./src/demux/exp-golomb.js","webpack://mpegts/./src/demux/sps-parser.js","webpack://mpegts/./src/demux/flv-demuxer.js","webpack://mpegts/./src/demux/pat-pmt-pes.ts","webpack://mpegts/./src/demux/base-demuxer.ts","webpack://mpegts/./src/demux/h264.ts","webpack://mpegts/./src/demux/mpeg4-audio.ts","webpack://mpegts/./src/demux/scte35.ts","webpack://mpegts/./src/demux/aac.ts","webpack://mpegts/./src/demux/pes-private-data.ts","webpack://mpegts/./src/demux/h265.ts","webpack://mpegts/./src/demux/h265-parser.js","webpack://mpegts/./src/demux/ts-demuxer.ts","webpack://mpegts/./src/remux/mp4-generator.js","webpack://mpegts/./src/remux/aac-silent.js","webpack://mpegts/./src/remux/mp4-remuxer.js","webpack://mpegts/./src/core/transmuxing-controller.js","webpack://mpegts/./src/io/speed-sampler.js","webpack://mpegts/./src/io/fetch-stream-loader.js","webpack://mpegts/./src/io/xhr-moz-chunked-loader.js","webpack://mpegts/./src/io/xhr-range-loader.js","webpack://mpegts/./src/io/websocket-loader.js","webpack://mpegts/./src/io/range-seek-handler.js","webpack://mpegts/./src/io/param-seek-handler.js","webpack://mpegts/./src/io/io-controller.js","webpack://mpegts/./src/utils/polyfill.js","webpack://mpegts/./node_modules/webworkify-webpack/index.js","webpack://mpegts/./src/index.js","webpack://mpegts/./node_modules/es6-promise/dist/es6-promise.js","webpack://mpegts/./node_modules/process/browser.js","webpack://mpegts/(webpack)/buildin/global.js","webpack://mpegts/./src/core/transmuxing-worker.js","webpack://mpegts/./src/config.js","webpack://mpegts/./src/core/features.js","webpack://mpegts/./src/player/player-events.js","webpack://mpegts/./src/core/transmuxer.js","webpack://mpegts/./src/core/mse-events.js","webpack://mpegts/./src/core/mse-controller.js","webpack://mpegts/./src/player/player-errors.js","webpack://mpegts/./src/player/mse-player.js","webpack://mpegts/./src/player/native-player.js","webpack://mpegts/./src/mpegts.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","e","tag","msg","Log","FORCE_GLOBAL_TAG","GLOBAL_TAG","str","ENABLE_CALLBACK","emitter","emit","ENABLE_ERROR","console","error","warn","log","ENABLE_INFO","info","w","ENABLE_WARN","ENABLE_DEBUG","debug","v","ENABLE_VERBOSE","IO_ERROR","DEMUX_ERROR","INIT_SEGMENT","MEDIA_SEGMENT","LOADING_COMPLETE","RECOVERED_EARLY_EOF","MEDIA_INFO","METADATA_ARRIVED","SCRIPTDATA_ARRIVED","TIMED_ID3_METADATA_ARRIVED","SCTE35_METADATA_ARRIVED","PES_PRIVATE_DATA_DESCRIPTOR","PES_PRIVATE_DATA_ARRIVED","STATISTICS_INFO","RECOMMEND_SEEKPOINT","LoaderStatus","kIdle","kConnecting","kBuffering","kError","kComplete","LoaderErrors","OK","EXCEPTION","HTTP_STATUS_CODE_INVALID","CONNECTING_TIMEOUT","EARLY_EOF","UNRECOVERABLE_EARLY_EOF","typeName","this","_type","_status","_needStash","_onContentLengthKnown","_onURLRedirect","_onDataArrival","_onError","_onComplete","destroy","isWorking","callback","open","dataSource","range","abort","message","_message","toString","RuntimeException","Browser","ua","self","navigator","userAgent","toLowerCase","match","exec","indexOf","platform_match","matched","browser","version","majorVersion","platform","versionArray","split","major","parseInt","string","length","minor","build","chrome","opr","safari","webkit","rv","iemobile","edge","android","assign","detect","FORMAT_ERROR","FORMAT_UNSUPPORTED","CODEC_UNSUPPORTED","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","EventEmitter","init","once","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","events","existing","warning","newListener","unshift","push","warned","Error","String","count","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","_listeners","unwrap","evlistener","arr","ret","Array","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","er","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","keys","rawListeners","eventNames","dts","pts","duration","originalDts","isSync","isSyncPoint","fileposition","beginDts","endDts","beginPts","endPts","originalBeginDts","originalEndDts","syncPoints","firstSample","lastSample","appendSyncPoint","sampleInfo","_list","clear","appendArray","getLastSyncPointBeforeDts","idx","last","mid","lbound","ubound","Math","floor","_lastAppendLocation","isEmpty","_searchNearestSegmentBefore","_searchNearestSegmentAfter","append","mediaSegmentInfo","msi","lastAppendIdx","insertIdx","splice","getLastSegmentBefore","getLastSampleBefore","segment","getLastSyncPointBefore","segmentIdx","mimeType","hasAudio","hasVideo","audioCodec","videoCodec","audioDataRate","videoDataRate","audioSampleRate","audioChannelCount","width","height","fps","profile","level","refFrames","chromaFormat","sarNum","sarDen","metadata","segments","segmentCount","hasKeyframesIndex","keyframesIndex","isComplete","audioInfoComplete","videoInfoComplete","isSeekable","getNearestKeyframe","milliseconds","table","keyframeIdx","_search","times","filepositions","enable","LoggingControl","_notifyChange","getConfig","globalTag","forceGlobalTag","enableVerbose","enableDebug","enableInfo","enableWarn","enableError","enableCallback","applyConfig","config","registerListener","addLogListener","removeLogListener","checkContinuation","uint8array","start","checkLength","array","buf","out","input","fromCharCode","ucs4","join","ArrayBuffer","DataView","setInt16","Int16Array","parseScriptData","arrayBuffer","dataOffset","dataSize","data","AMF","parseValue","size","parseObject","parseString","isObjectEnd","objectEnd","parseVariable","getUint16","Uint8Array","parseLongString","getUint32","parseDate","timestamp","getFloat64","localTimeOffset","getInt16","Date","offset","getUint8","amfstr","terminal","amfobj","amfvar","strictArrayLength","val","date","amfLongStr","TAG","_buffer","_buffer_index","_total_bytes","byteLength","_total_bits","_current_word","_current_word_bits_left","_fillCurrentWord","buffer_bytes_left","bytes_read","min","word","subarray","buffer","readBits","bits","result","bits_need_left","bits_read_next","result2","readBool","readByte","_skipLeadingZero","zero_count","readUEG","leading_zeros","readSEG","_ebsp2rbsp","src","src_length","dst","dst_idx","parseSPS","codec_array","codec_mimetype","j","h","rbsp","SPSParser","gb","profile_idc","level_idc","profile_string","getProfileString","level_string","getLevelString","chroma_format_idc","chroma_format","bit_depth_luma","bit_depth_chroma","scaling_list_count","_skipScalingList","pic_order_cnt_type","num_ref_frames_in_pic_order_cnt_cycle","ref_frames","pic_width_in_mbs_minus1","pic_height_in_map_units_minus1","frame_mbs_only_flag","frame_crop_left_offset","frame_crop_right_offset","frame_crop_top_offset","frame_crop_bottom_offset","sar_width","sar_height","fps_fixed","fps_num","fps_den","aspect_ratio_idc","num_units_in_tick","time_scale","sarScale","crop_unit_x","crop_unit_y","codec_width","codec_height","present_width","ceil","bit_depth","chroma_format_string","getChromaFormatString","frame_rate","fixed","sar_ratio","codec_size","present_size","last_scale","next_scale","toFixed","chroma","StreamType","probeData","_config","_onMediaInfo","_onMetaDataArrived","_onScriptDataArrived","_onTrackMetadata","_onDataAvailable","_dataOffset","_firstParse","_dispatch","_hasAudio","hasAudioTrack","_hasVideo","hasVideoTrack","_hasAudioFlagOverrided","_hasVideoFlagOverrided","_audioInitialMetadataDispatched","_videoInitialMetadataDispatched","_mediaInfo","_metadata","_audioMetadata","_videoMetadata","_naluLengthSize","_timestampBase","_timescale","_duration","_durationOverrided","_referenceFrameRate","_flvSoundRateTable","_mpegSamplingRates","_mpegAudioV10SampleRateTable","_mpegAudioV20SampleRateTable","_mpegAudioV25SampleRateTable","_mpegAudioL1BitRateTable","_mpegAudioL2BitRateTable","_mpegAudioL3BitRateTable","_videoTrack","id","sequenceNumber","samples","_audioTrack","_littleEndian","probe","mismatch","consumed","bindDataSource","loader","onDataArrival","parseChunks","base","resetMediaInfo","_isInitialMetadataDispatched","chunk","byteStart","le","FLVDemuxer","tagType","ts2","ts1","_parseAudioData","_parseVideoData","_parseScriptData","prevTagSize","scriptData","onMetaData","audiodatarate","videodatarate","framerate","keyframes","_parseKeyframesIndex","time","tagTimestamp","soundSpec","soundFormat","soundRate","soundRateIndex","soundType","meta","track","timescale","channelCount","aacData","_parseAACAudioData","packetType","misc","samplingRate","codec","originalCodec","refSampleDuration","mi","aacSample","unit","_parseMP3AudioData","bitRate","mp3Sample","_parseAACAudioSpecificConfig","originalAudioObjectType","samplingIndex","audioObjectType","extensionSamplingIndex","samplingFrequence","channelConfig","requestHeader","ver","layer","bitrate_index","sampling_freq_index","channel_count","sample_rate","bit_rate","tagPosition","spec","frameType","codecId","_parseAVCVideoPacket","cts","_parseAVCDecoderConfigurationRecord","_parseAVCVideoData","avcc","avcProfile","spsCount","sps","codecWidth","codecHeight","presentWidth","presentHeight","bitDepth","sarRatio","frameRate","codecArray","codecString","ppsCount","units","lengthSize","keyframe","naluSize","unitType","avcSample","isKeyframe","onError","onMediaInfo","onMetaDataArrived","onTrackMetadata","onDataAvailable","onTimedID3Metadata","onSCTE35Metadata","onPESPrivateData","onPESPrivateDataDescriptor","program_pmt_pid","H264NaluType","pid_stream_type","common_pids","h264","h265","adts_aac","pes_private_data_pids","timed_id3_pids","scte_35_pids","slices","total_length","expected_length","file_position","MPEG4AudioObjectTypes","MPEG4SamplingFrequencyIndex","nalu","nalu_size","setUint32","current_startcode_offset_","eof_flag_","data_","findNextStartCodeOffset","start_offset","uint32","uint24","readNextNaluPayload","nalu_payload","nalu_type","forbidden_bit","next_startcode_offset","kReserved0","payload_data","H264NaluPayload","pps","sps_details","need_extra_fields","sps_length","pps_length","getData","SCTE35CommandType","MPEG4SamplingFrequencies","current_syncword_offset_","findNextSyncwordOffset","syncword_offset","readNextAACFrame","aac_frame","ID","protection_absent","sampling_frequency_index","channel_configuration","aac_frame_length","has_last_incomplete_data","adts_header_length","adts_frame_payload_length","next_syncword_offset","frame_data","AACFrame","audio_object_type","sampling_frequency","channel_config","hasIncompleteData","getIncompleteData","frame","original_audio_object_type","sampling_index","extension_sampling_index","sampling_rate","original_codec_mimetype","H265NaluType","parseSpliceTime","reader","time_specified_flag","pts_time","parseBreakDuration","auto_return","parseSpliceInsertComponent","splice_immediate_flag","component_tag","splice_time","parseSpliceScheduleEventComponent","utc_splice_time","parseSpliceScheduleEvent","splice_event_id","splice_event_cancel_indicator","spliceScheduleEvent","out_of_network_indicator","program_splice_flag","duration_flag","component_count","components","break_duration","unique_program_id","avail_num","avails_expected","parseAvailDescriptor","descriptor_tag","descriptor_length","identifier","provider_avail_id","parseDTMFDescriptor","preroll","dtmf_count","DTMF_char","parseSegmentationDescriptorComponent","pts_offset","parseSegmentationDescriptor","segmentation_event_id","segmentation_event_cancel_indicator","segmentationDescriptor","program_segmentation_flag","segmentation_duration_flag","delivery_not_restricted_flag","web_delivery_allowed_flag","no_regional_blackout_flag","archive_allowed_flag","device_restrictions","segmentation_duration","segmentation_upid_type","segmentation_upid_length","upid","segmentation_upid","segmentation_type_id","segment_num","segments_expected","sub_segment_num","sub_segments_expected","parseTimeDescriptor","TAI_seconds","TAI_ns","UTC_offset","parseAudioDescriptorComponent","ISO_code","Bit_Stream_Mode","Num_Channels","Full_Srvc_Audio","parseAudioDescriptor","audio_count","readSCTE35","table_id","section_syntax_indicator","private_indicator","section_length","protocol_version","encrypted_packet","encryption_algorithm","pts_adjustment","cw_index","tier","splice_command_length","splice_command_type","splice_command","kSpliceNull","kSpliceSchedule","splice_count","parseSpliceSchedule","kSpliceInsert","spliceInsert","parseSpliceInsert","kTimeSignal","parseTimeSignal","kBandwidthReservation","kPrivateCommand","private_data","parsePrivateCommand","splice_descriptors","descriptor_loop_length","detail","E_CRC32","CRC32","duraiton","timeSignal","H265NaluPayload","vps","general_profile_space","general_tier_flag","general_profile_idc","general_profile_compatibility_flags_1","general_profile_compatibility_flags_2","general_profile_compatibility_flags_3","general_profile_compatibility_flags_4","general_constraint_indicator_flags_1","general_constraint_indicator_flags_2","general_constraint_indicator_flags_3","general_constraint_indicator_flags_4","general_constraint_indicator_flags_5","general_constraint_indicator_flags_6","min_spatial_segmentation_idc","parallelismType","bit_depth_luma_minus8","bit_depth_chroma_minus8","constant_frame_rate","num_temporal_layers","temporal_id_nested","kSliceVPS","kSliceSPS","kSlicePPS","parseVPS","H265NaluParser","max_sub_layers_minus1","general_level_idc","sub_layer_profile_present_flag","sub_layer_level_present_flag","pic_width_in_luma_samples","pic_height_in_luma_samples","log2_max_pic_order_cnt_lsb_minus4","sizeId","matrixId","coefNum","num_short_term_ref_pic_sets","num_delta_pocs","inter_ref_pic_set_prediction_flag","next_num_delta_pocs","used_by_curr_pic_flag","use_delta_flag","num_negative_pics","num_positive_pics","num_long_term_ref_pics_sps","nal_hrd_parameters_present_flag","vcl_hrd_parameters_present_flag","sub_pic_hrd_params_present_flag","fixed_pic_rate_general_flag","fixed_pic_rate_within_cvs_flag","low_delay_hrd_flag","cpbcnt","sar_scale","parsePPS","tiles_enabled_flag","entropy_coding_sync_enabled_flag","chroma_idc","probe_data","first_parse_","media_info_","timescale_","duration_","current_pmt_pid_","program_pmt_map_","pes_slice_queues_","section_slice_queues_","video_metadata_","details","audio_metadata_","aac_last_sample_pts_","aac_last_incomplete_data_","has_video_","has_audio_","video_init_segment_dispatched_","audio_init_segment_dispatched_","video_metadata_changed_","audio_metadata_changed_","video_track_","audio_track_","ts_packet_size_","ts_packet_size","sync_offset_","sync_offset","config_","scan_window","byte_start","sync_byte","payload_unit_start_indicator","pid","adaptation_field_control","continuity_conunter","adaptation_field_info","ts_payload_start_index","adaptation_field_length","parseAdaptationField","pmt_","kSCTE35","ts_payload_length","handleSectionSlice","random_access_indicator","stream_type","handlePESSlice","dispatchAudioVideoMediaSegment","discontinuity_indicator","elementary_stream_priority_indicator","slice_queue","pointer_field","remain_section","emitSectionSlices","clearSlices","SliceQueue","packet_start_code_prefix","PES_packet_length","emitPESSlices","section_data","SectionData","parseSection","pes_data","PESData","parsePES","parsePAT","parsePMT","parseSCTE35","stream_id","PTS_DTS_flags","PES_header_data_length","payload_start_index","payload_length","payload","kMPEG1Audio","kMPEG2Audio","kPESPrivateData","parsePESPrivateDataPayload","kADTSAAC","parseAACPayload","kID3","parseTimedID3MetadataPayload","kH264","parseH264Payload","kH265","parseH265Payload","version_number","current_next_indicator","section_number","pat","PAT","pat_","program_bytes","first_program_number","first_pmt_pid","program_number","network_pid","JSON","stringify","current_program_","pmt","PMT","program_info_length","info_start_index","info_bytes","elementary_PID","ES_info_length","descriptor","dispatchPESPrivateDataDescriptor","scte35","pts_ms","nearest_pts","annexb_parser","nalu_avc1","H264NaluAVC1","detectVideoMetadataChange","dispatchVideoMediaSegment","dispatchVideoInitSegment","kSliceIDR","kSliceNonIDR","dts_ms","avc_sample","nalu_hvc1","H265NaluHVC1","kSliceIDR_W_RADL","kSliceIDR_N_LP","hvc_sample","new_sps","new_details","old_size","new_size","isInitSegmentDispatched","vps_without_header","sps_without_header","pps_without_header","hvcc","HEVCDecoderConfigurationRecord","AVCDecoderConfigurationRecord","dispatchAudioMediaSegment","ref_sample_duration","base_pts_ms","new_pts_ms","abs","last_sample_pts_ms","adts_parser","sample_pts_ms","dispatchAudioInitSegment","detectAudioMetadataChange","sample_pts_ms_int","aac_sample","audio_specific_config","desc","PESPrivateDataDescriptor","PESPrivateData","timed_id3_metadata","MP4","types","avc1","avcC","btrt","dinf","dref","esds","ftyp","hdlr","hvc1","hvcC","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","sdtp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trun","trex","tkhd","vmhd","smhd","charCodeAt","constants","FTYP","STSD_PREFIX","STTS","STSC","STCO","STSZ","HDLR_VIDEO","HDLR_AUDIO","DREF","SMHD","VMHD","box","datas","arrayCount","generateInitSegment","trackId","xmhd","mp3","startsWith","sampleRate","configSize","baseMediaDecodeTime","sampleCount","isLeading","dependsOn","isDependedOn","hasRedundancy","isNonSync","getSilentFrame","_isLive","isLive","_dtsBase","_dtsBaseInited","_audioDtsBase","Infinity","_videoDtsBase","_audioNextDts","_videoNextDts","_audioStashedLastSample","_videoStashedLastSample","_audioMeta","_videoMeta","_audioSegmentInfoList","_videoSegmentInfoList","_onInitSegment","_onMediaSegment","_forceFirstIDR","_fillSilentAfterSeek","msedge","msie","_mp3UseMpegAudio","firefox","_fillAudioTimestampGap","fixAudioTimestampGap","producer","remux","_onTrackMetadataReceived","insertDiscontinuity","seek","audioTrack","videoTrack","_calculateDtsBase","_remuxVideo","_remuxAudio","metabox","container","mediaDuration","getTimestampBase","flushStashedSamples","videoSample","audioSample","force","lastDts","dtsCorrection","firstDts","mpegRawTrack","firstSegmentAfterSeek","insertPrefixSilentFrame","mdatbox","mdatBytes","sample","firstSampleOriginalDts","distance","firstSampleDts","videoSegment","silentUnit","silentFrameDuration","mp4Samples","needFillSilentFrames","silentFrames","sampleDuration","curRefDts","frameCount","round","intDts","intDuration","latest","moofbox","_mergeBoxes","timestampOffset","lastPts","firstPts","syncPoint","mediaDataSource","_emitter","filesize","url","cors","withCredentials","_mediaDataSource","_currentSegmentIndex","totalDuration","forEach","timestampBase","referrerPolicy","_demuxer","_remuxer","_ioctl","_pendingSeekTime","_pendingResolveSeekPoint","_statisticsReporter","_disableStatisticsReporter","event","_loadSegment","_enableStatisticsReporter","segmentIndex","optionalFrom","ioctl","_onIOException","onSeeked","_onIOSeeked","onComplete","_onIOComplete","onRedirect","_onIORedirect","onRecoveredEarlyEof","_onIORecoveredEarlyEof","_onInitChunkArrival","stop","_internalAbort","pause","resume","isPaused","targetSegmentIndex","_searchSegmentIndexContains","segmentInfo","targetSegmentInfo","_reportSegmentMediaInfo","demuxer","_onDemuxException","_onTimedID3Metadata","_onSCTE35Metadata","_onPESPrivateDataDescriptor","_onPESPrivateData","onInitSegment","_onRemuxerInitSegmentArrival","onMediaSegment","_onRemuxerMediaSegmentArrival","mds","overridedDuration","overridedHasAudio","overridedHasVideo","onScriptDataArrived","then","mediaInfo","setPrototypeOf","timestamp_base","extraData","nextSegmentIndex","redirectedURL","code","initSegment","mediaSegment","seekpoint","setInterval","_reportStatisticsInfo","statisticsInfoReportInterval","clearInterval","exportInfo","currentURL","hasRedirect","currentRedirectedURL","speed","currentSpeed","loaderType","currentSegmentIndex","totalSegmentCount","_firstCheckpoint","_lastCheckpoint","_intervalBytes","_totalBytes","_lastSecondBytes","performance","now","_now","reset","addBytes","bytes","durationSeconds","currentKBps","seekHandler","_seekHandler","_requestAbort","_abortController","_contentLength","_receivedLength","isSupported","isWorkWellEdge","browserNotBlacklisted","fetch","ReadableStream","_dataSource","_range","sourceURL","reuseRedirectedURL","seekConfig","headers","Headers","configHeaders","params","method","cache","credentials","AbortController","signal","res","body","cancel","ok","status","removeURLParameters","lengthHeader","_pump","getReader","statusText","catch","aborted","read","done","from","_xhr","xhr","XMLHttpRequest","responseType","onreadystatechange","onprogress","onloadend","onerror","_requestURL","_onReadyStateChange","_onProgress","_onLoadEnd","_onXhrError","setRequestHeader","send","readyState","responseURL","total","response","loaded","constructor","_chunkSizeKBList","_currentChunkSizeKB","_currentSpeedNormalized","_zeroSpeedChunkCount","_speedSampler","_waitForTotalLength","_totalLengthReceived","_currentRequestURL","_currentRedirectedURL","_currentRequestRange","_totalLength","_lastTimeLoaded","onload","lastSecondKBps","useRefTotalLength","_openSubRange","_internalOpen","to","chunkSize","_onLoad","openNextRange","delta","_normalizeSpeed","KBps","normalized","reportComplete","_ws","WebSocket","ws","binaryType","onopen","_onWebSocketOpen","onclose","_onWebSocketClose","onmessage","_onWebSocketMessage","_onWebSocketError","close","_dispatchArrayBuffer","Blob","FileReader","readAsArrayBuffer","arraybuffer","zeroStart","_zeroStart","param","seekedURL","paramStart","paramEnd","_startName","_endName","baseUrl","needAnd","baseURL","queryIndex","substring","resultParams","pairs","pair","requireAnd","_extraData","_stashInitialSize","stashInitialSize","_stashUsed","_stashSize","_bufferSize","_stashBuffer","_stashByteStart","_enableStash","enableStashBuffer","_loader","_loaderClass","_isWebSocketURL","test","_refTotalLength","_fullRequestFlag","_currentRange","_redirectedURL","_speedNormalized","_speedNormalizeList","_isEarlyEofReconnecting","_paused","_resumeFrom","_onSeeked","_onRedirect","_onRecoveredEarlyEof","_selectSeekHandler","_selectLoader","_createLoader","seekType","rangeLoadZeroStart","seekParamStart","seekParamEnd","customSeekHandler","customLoader","needStashBuffer","onContentLengthKnown","onURLRedirect","_onLoaderChunkArrival","_onLoaderComplete","_onLoaderError","_internalSeek","dropUnconsumed","_flushStashBuffer","requestRange","updateUrl","_expandBuffer","expectedBytes","bufferNewSize","newBuffer","stashOldArray","_adjustStashSize","stashSizeKB","bufferSize","_dispatchChunks","chunks","contentLength","receivedLength","stashArray","remainArray","remain","nextFrom","install","obj","proto","__proto__","output","source","polyfill","Polyfill","webpackBootstrapFunc","configurable","oe","f","ENTRY_MODULE","default","quoteRegExp","replace","getModuleDependencies","sources","queueName","retval","fnString","wrapperSignature","webpackRequireName","re","RegExp","hasValuesInQueues","queues","reduce","hasValues","options","main","requiredModules","all","modulesQueue","seenModules","moduleToCheck","newModules","newModulesKeys","getRequiredModules","filter","entryModule","map","blob","bare","workerUrl","URL","webkitURL","mozURL","msURL","createObjectURL","worker","Worker","objectURL","isFunction","x","isArray","vertxNext","customSchedulerFn","asap","queue","flush","scheduleFlush","browserWindow","browserGlobal","BrowserMutationObserver","MutationObserver","WebKitMutationObserver","isNode","process","isWorker","Uint8ClampedArray","importScripts","MessageChannel","useSetTimeout","globalSetTimeout","setTimeout","channel","iterations","observer","node","onFulfillment","onRejection","parent","child","noop","PROMISE_ID","makePromise","_state","invokeCallback","_result","subscribe","resolve$1","promise","nextTick","document","createTextNode","observe","characterData","port1","port2","postMessage","vertx","require","runOnLoop","runOnContext","attemptVertx","random","handleMaybeThenable","maybeThenable","then$$1","thenable","fulfill","reason","handleOwnThenable","sealed","fulfillmentHandler","rejectionHandler","tryThen","_label","handleForeignThenable","publishRejection","_onerror","publish","_subscribers","subscribers","settled","hasCallback","succeeded","Enumerator","Constructor","_instanceConstructor","_remaining","_enumerate","_eachEntry","entry","resolve$$1","_then","didError","_settledAt","Promise$1","_willSettleAt","enumerator","needsResolver","initializePromise","needsNew","finally","entries","race","_","_setScheduler","scheduleFn","_setAsap","asapFn","_asap","local","global","P","promiseToString","cast","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","runTimeout","fun","clearTimeout","currentQueue","draining","queueIndex","cleanUpNextTick","drainQueue","timeout","run","marker","runClearTimeout","Item","title","env","argv","versions","binding","cwd","chdir","dir","umask","g","controller","logcatListener","logcat","onLoadingComplete","onTimedID3MetadataArrived","onSCTE35MetadataArrived","onPESPrivateDataArrived","onStatisticsInfo","statInfo","onIOError","onDemuxError","onRecommendSeekpoint","cmd","defaultConfig","enableWorker","liveBufferLatencyChasing","liveBufferLatencyMaxLatency","liveBufferLatencyMinRemain","lazyLoad","lazyLoadMaxDuration","lazyLoadRecoverDuration","deferLoadAfterSourceOpen","autoCleanupMaxBackwardDuration","autoCleanupMinBackwardDuration","accurateSeek","createDefaultConfig","supportMSEH264Playback","MediaSource","isTypeSupported","supportNetworkStreamIO","getNetworkLoaderTypeName","supportNativeMediaPlayback","Features","videoElement","createElement","canPlay","canPlayType","getFeatureList","features","msePlayback","mseLivePlayback","networkStreamIO","networkLoaderName","nativeMP4H264Playback","nativeWebmVP8Playback","nativeWebmVP9Playback","ERROR","_worker","_workerDestroying","_onWorkerMessage","onLoggingConfigChanged","_onLoggingConfigChanged","_controller","ctl","_onIOError","_onDemuxError","_onLoadingComplete","_onTimedID3MetadataArrived","_onSCTE35MetadataArrived","_onPESPrivateDataArrived","_onStatisticsInfo","_onRecommendSeekpoint","hasWorker","statisticsInfo","terminate","SOURCE_OPEN","UPDATE_END","BUFFER_FULL","autoCleanupSourceBuffer","onSourceOpen","_onSourceOpen","onSourceEnded","_onSourceEnded","onSourceClose","_onSourceClose","onSourceBufferError","_onSourceBufferError","onSourceBufferUpdateEnd","_onSourceBufferUpdateEnd","_mediaSource","_mediaSourceObjectURL","_mediaElement","_isBufferFull","_hasPendingEos","_requireSetMediaDuration","_pendingMediaDuration","_pendingSourceBufferInit","_mimeTypes","video","audio","_sourceBuffers","_lastInitSegments","_pendingSegments","_pendingRemoveRanges","_idrList","detachMediaElement","attachMediaElement","mediaElement","ms","ps","sb","removeSourceBuffer","endOfStream","removeAttribute","revokeObjectURL","appendInitSegment","deferred","is","firstInitSegment","addSourceBuffer","updating","_doAppendSegments","_updateMediaSourceDuration","appendMediaSegment","_needCleanupSourceBuffer","_doCleanupSourceBuffer","_hasPendingRemoveRanges","seconds","buffered","end","_doRemoveRanges","lastInitSegment","_hasPendingSegments","currentTime","doRemove","removeEnd","current","ranges","remove","pendingSegments","currentOffset","targetOffset","appendBuffer","pendings","prr","ErrorTypes","NETWORK_ERROR","MEDIA_ERROR","OTHER_ERROR","ErrorDetails","NETWORK_EXCEPTION","NETWORK_STATUS_CODE_INVALID","NETWORK_TIMEOUT","NETWORK_UNRECOVERABLE_EARLY_EOF","MEDIA_MSE_ERROR","MEDIA_FORMAT_ERROR","MEDIA_FORMAT_UNSUPPORTED","MEDIA_CODEC_UNSUPPORTED","typeLowerCase","onvLoadedMetadata","_onvLoadedMetadata","onvSeeking","_onvSeeking","onvCanPlay","_onvCanPlay","onvStalled","_onvStalled","onvProgress","_onvProgress","_requestSetTime","_seekpointRecord","_progressChecker","_msectl","_transmuxer","_mseSourceOpened","_hasPendingLoad","_receivedCanPlay","_statisticsInfo","chromeNeedIDRFix","_alwaysSeekKeyframe","unload","_onmseUpdateEnd","_onmseBufferFull","load","_suspendTransmuxer","scte35_metadata","_fillStatisticsInfo","play","volume","muted","playerType","HTMLVideoElement","hasQualityInfo","decoded","dropped","getVideoPlaybackQuality","quality","totalVideoFrames","droppedVideoFrames","webkitDecodedFrameCount","webkitDroppedFrameCount","decodedFrames","droppedFrames","paused","buffered_end","target_time","currentRangeEnd","_checkProgressAndResume","needResume","_isTimepointBuffered","directSeek","directSeekBegin","directSeekBeginTime","videoBeginTime","idr","_checkAndApplyUnbufferedSeekpoint","recordTime","_checkAndResumeStuckPlayback","stalled","media","seekPoint","preload","HTMLAudioElement","videoWidth","videoHeight","mpegts","optionalConfig","BaseLoader","Events","MSEPlayer","NativePlayer"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,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AAe2xD,EAAQ,UAAW,CACrC1xD,YAAY,EACZC,IAAK,WAED,MAAO,YAIA","file":"mpegts.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"mpegts\"] = factory();\n\telse\n\t\troot[\"mpegts\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 14);\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\n\nclass Log {\n\n static e(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'error', str);\n }\n\n if (!Log.ENABLE_ERROR) {\n return;\n }\n\n if (console.error) {\n console.error(str);\n } else if (console.warn) {\n console.warn(str);\n } else {\n console.log(str);\n }\n }\n\n static i(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'info', str);\n }\n\n if (!Log.ENABLE_INFO) {\n return;\n }\n\n if (console.info) {\n console.info(str);\n } else {\n console.log(str);\n }\n }\n\n static w(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'warn', str);\n }\n\n if (!Log.ENABLE_WARN) {\n return;\n }\n\n if (console.warn) {\n console.warn(str);\n } else {\n console.log(str);\n }\n }\n\n static d(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'debug', str);\n }\n\n if (!Log.ENABLE_DEBUG) {\n return;\n }\n\n if (console.debug) {\n console.debug(str);\n } else {\n console.log(str);\n }\n }\n\n static v(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'verbose', str);\n }\n\n if (!Log.ENABLE_VERBOSE) {\n return;\n }\n\n console.log(str);\n }\n\n}\n\nLog.GLOBAL_TAG = 'mpegts.js';\nLog.FORCE_GLOBAL_TAG = false;\nLog.ENABLE_ERROR = true;\nLog.ENABLE_INFO = true;\nLog.ENABLE_WARN = true;\nLog.ENABLE_DEBUG = true;\nLog.ENABLE_VERBOSE = true;\n\nLog.ENABLE_CALLBACK = false;\n\nLog.emitter = new EventEmitter();\n\nexport default Log;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst TransmuxingEvents = {\n IO_ERROR: 'io_error',\n DEMUX_ERROR: 'demux_error',\n INIT_SEGMENT: 'init_segment',\n MEDIA_SEGMENT: 'media_segment',\n LOADING_COMPLETE: 'loading_complete',\n RECOVERED_EARLY_EOF: 'recovered_early_eof',\n MEDIA_INFO: 'media_info',\n METADATA_ARRIVED: 'metadata_arrived',\n SCRIPTDATA_ARRIVED: 'scriptdata_arrived',\n TIMED_ID3_METADATA_ARRIVED: 'timed_id3_metadata_arrived',\n SCTE35_METADATA_ARRIVED: 'scte35_metadata_arrived',\n PES_PRIVATE_DATA_DESCRIPTOR: 'pes_private_data_descriptor',\n PES_PRIVATE_DATA_ARRIVED: 'pes_private_data_arrived',\n STATISTICS_INFO: 'statistics_info',\n RECOMMEND_SEEKPOINT: 'recommend_seekpoint'\n};\n\nexport default TransmuxingEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NotImplementedException} from '../utils/exception.js';\n\nexport const LoaderStatus = {\n kIdle: 0,\n kConnecting: 1,\n kBuffering: 2,\n kError: 3,\n kComplete: 4\n};\n\nexport const LoaderErrors = {\n OK: 'OK',\n EXCEPTION: 'Exception',\n HTTP_STATUS_CODE_INVALID: 'HttpStatusCodeInvalid',\n CONNECTING_TIMEOUT: 'ConnectingTimeout',\n EARLY_EOF: 'EarlyEof',\n UNRECOVERABLE_EARLY_EOF: 'UnrecoverableEarlyEof'\n};\n\n/* Loader has callbacks which have following prototypes:\n * function onContentLengthKnown(contentLength: number): void\n * function onURLRedirect(url: string): void\n * function onDataArrival(chunk: ArrayBuffer, byteStart: number, receivedLength: number): void\n * function onError(errorType: number, errorInfo: {code: number, msg: string}): void\n * function onComplete(rangeFrom: number, rangeTo: number): void\n */\nexport class BaseLoader {\n\n constructor(typeName) {\n this._type = typeName || 'undefined';\n this._status = LoaderStatus.kIdle;\n this._needStash = false;\n // callbacks\n this._onContentLengthKnown = null;\n this._onURLRedirect = null;\n this._onDataArrival = null;\n this._onError = null;\n this._onComplete = null;\n }\n\n destroy() {\n this._status = LoaderStatus.kIdle;\n this._onContentLengthKnown = null;\n this._onURLRedirect = null;\n this._onDataArrival = null;\n this._onError = null;\n this._onComplete = null;\n }\n\n isWorking() {\n return this._status === LoaderStatus.kConnecting || this._status === LoaderStatus.kBuffering;\n }\n\n get type() {\n return this._type;\n }\n\n get status() {\n return this._status;\n }\n\n get needStashBuffer() {\n return this._needStash;\n }\n\n get onContentLengthKnown() {\n return this._onContentLengthKnown;\n }\n\n set onContentLengthKnown(callback) {\n this._onContentLengthKnown = callback;\n }\n\n get onURLRedirect() {\n return this._onURLRedirect;\n }\n\n set onURLRedirect(callback) {\n this._onURLRedirect = callback;\n }\n\n get onDataArrival() {\n return this._onDataArrival;\n }\n\n set onDataArrival(callback) {\n this._onDataArrival = callback;\n }\n\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n get onComplete() {\n return this._onComplete;\n }\n\n set onComplete(callback) {\n this._onComplete = callback;\n }\n\n // pure virtual\n open(dataSource, range) {\n throw new NotImplementedException('Unimplemented abstract function!');\n }\n\n abort() {\n throw new NotImplementedException('Unimplemented abstract function!');\n }\n\n\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class RuntimeException {\n\n constructor(message) {\n this._message = message;\n }\n\n get name() {\n return 'RuntimeException';\n }\n\n get message() {\n return this._message;\n }\n\n toString() {\n return this.name + ': ' + this.message;\n }\n\n}\n\nexport class IllegalStateException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'IllegalStateException';\n }\n\n}\n\nexport class InvalidArgumentException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'InvalidArgumentException';\n }\n\n}\n\nexport class NotImplementedException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'NotImplementedException';\n }\n\n}\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet Browser = {};\n\nfunction detect() {\n // modified from jquery-browser-plugin\n\n let ua = self.navigator.userAgent.toLowerCase();\n\n let match = /(edge)\\/([\\w.]+)/.exec(ua) ||\n /(opr)[\\/]([\\w.]+)/.exec(ua) ||\n /(chrome)[ \\/]([\\w.]+)/.exec(ua) ||\n /(iemobile)[\\/]([\\w.]+)/.exec(ua) ||\n /(version)(applewebkit)[ \\/]([\\w.]+).*(safari)[ \\/]([\\w.]+)/.exec(ua) ||\n /(webkit)[ \\/]([\\w.]+).*(version)[ \\/]([\\w.]+).*(safari)[ \\/]([\\w.]+)/.exec(ua) ||\n /(webkit)[ \\/]([\\w.]+)/.exec(ua) ||\n /(opera)(?:.*version|)[ \\/]([\\w.]+)/.exec(ua) ||\n /(msie) ([\\w.]+)/.exec(ua) ||\n ua.indexOf('trident') >= 0 && /(rv)(?::| )([\\w.]+)/.exec(ua) ||\n ua.indexOf('compatible') < 0 && /(firefox)[ \\/]([\\w.]+)/.exec(ua) ||\n [];\n\n let platform_match = /(ipad)/.exec(ua) ||\n /(ipod)/.exec(ua) ||\n /(windows phone)/.exec(ua) ||\n /(iphone)/.exec(ua) ||\n /(kindle)/.exec(ua) ||\n /(android)/.exec(ua) ||\n /(windows)/.exec(ua) ||\n /(mac)/.exec(ua) ||\n /(linux)/.exec(ua) ||\n /(cros)/.exec(ua) ||\n [];\n\n let matched = {\n browser: match[5] || match[3] || match[1] || '',\n version: match[2] || match[4] || '0',\n majorVersion: match[4] || match[2] || '0',\n platform: platform_match[0] || ''\n };\n\n let browser = {};\n if (matched.browser) {\n browser[matched.browser] = true;\n\n let versionArray = matched.majorVersion.split('.');\n browser.version = {\n major: parseInt(matched.majorVersion, 10),\n string: matched.version\n };\n if (versionArray.length > 1) {\n browser.version.minor = parseInt(versionArray[1], 10);\n }\n if (versionArray.length > 2) {\n browser.version.build = parseInt(versionArray[2], 10);\n }\n }\n\n if (matched.platform) {\n browser[matched.platform] = true;\n }\n\n if (browser.chrome || browser.opr || browser.safari) {\n browser.webkit = true;\n }\n\n // MSIE. IE11 has 'rv' identifer\n if (browser.rv || browser.iemobile) {\n if (browser.rv) {\n delete browser.rv;\n }\n let msie = 'msie';\n matched.browser = msie;\n browser[msie] = true;\n }\n\n // Microsoft Edge\n if (browser.edge) {\n delete browser.edge;\n let msedge = 'msedge';\n matched.browser = msedge;\n browser[msedge] = true;\n }\n\n // Opera 15+\n if (browser.opr) {\n let opera = 'opera';\n matched.browser = opera;\n browser[opera] = true;\n }\n\n // Stock android browsers are marked as Safari\n if (browser.safari && browser.android) {\n let android = 'android';\n matched.browser = android;\n browser[android] = true;\n }\n\n browser.name = matched.browser;\n browser.platform = matched.platform;\n\n for (let key in Browser) {\n if (Browser.hasOwnProperty(key)) {\n delete Browser[key];\n }\n }\n Object.assign(Browser, browser);\n}\n\ndetect();\n\nexport default Browser;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst DemuxErrors = {\n OK: 'OK',\n FORMAT_ERROR: 'FormatError',\n FORMAT_UNSUPPORTED: 'FormatUnsupported',\n CODEC_UNSUPPORTED: 'CodecUnsupported'\n};\n\nexport default DemuxErrors;","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Represents an media sample (audio / video)\nexport class SampleInfo {\n\n constructor(dts, pts, duration, originalDts, isSync) {\n this.dts = dts;\n this.pts = pts;\n this.duration = duration;\n this.originalDts = originalDts;\n this.isSyncPoint = isSync;\n this.fileposition = null;\n }\n\n}\n\n// Media Segment concept is defined in Media Source Extensions spec.\n// Particularly in ISO BMFF format, an Media Segment contains a moof box followed by a mdat box.\nexport class MediaSegmentInfo {\n\n constructor() {\n this.beginDts = 0;\n this.endDts = 0;\n this.beginPts = 0;\n this.endPts = 0;\n this.originalBeginDts = 0;\n this.originalEndDts = 0;\n this.syncPoints = []; // SampleInfo[n], for video IDR frames only\n this.firstSample = null; // SampleInfo\n this.lastSample = null; // SampleInfo\n }\n\n appendSyncPoint(sampleInfo) { // also called Random Access Point\n sampleInfo.isSyncPoint = true;\n this.syncPoints.push(sampleInfo);\n }\n\n}\n\n// Ordered list for recording video IDR frames, sorted by originalDts\nexport class IDRSampleList {\n\n constructor() {\n this._list = [];\n }\n\n clear() {\n this._list = [];\n }\n\n appendArray(syncPoints) {\n let list = this._list;\n\n if (syncPoints.length === 0) {\n return;\n }\n\n if (list.length > 0 && syncPoints[0].originalDts < list[list.length - 1].originalDts) {\n this.clear();\n }\n\n Array.prototype.push.apply(list, syncPoints);\n }\n\n getLastSyncPointBeforeDts(dts) {\n if (this._list.length == 0) {\n return null;\n }\n\n let list = this._list;\n let idx = 0;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (dts < list[0].dts) {\n idx = 0;\n lbound = ubound + 1;\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (dts >= list[mid].dts && dts < list[mid + 1].dts)) {\n idx = mid;\n break;\n } else if (list[mid].dts < dts) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n return this._list[idx];\n }\n\n}\n\n// Data structure for recording information of media segments in single track.\nexport class MediaSegmentInfoList {\n\n constructor(type) {\n this._type = type;\n this._list = [];\n this._lastAppendLocation = -1; // cached last insert location\n }\n\n get type() {\n return this._type;\n }\n\n get length() {\n return this._list.length;\n }\n\n isEmpty() {\n return this._list.length === 0;\n }\n\n clear() {\n this._list = [];\n this._lastAppendLocation = -1;\n }\n\n _searchNearestSegmentBefore(originalBeginDts) {\n let list = this._list;\n if (list.length === 0) {\n return -2;\n }\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n let idx = 0;\n\n if (originalBeginDts < list[0].originalBeginDts) {\n idx = -1;\n return idx;\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (originalBeginDts > list[mid].lastSample.originalDts &&\n (originalBeginDts < list[mid + 1].originalBeginDts))) {\n idx = mid;\n break;\n } else if (list[mid].originalBeginDts < originalBeginDts) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n return idx;\n }\n\n _searchNearestSegmentAfter(originalBeginDts) {\n return this._searchNearestSegmentBefore(originalBeginDts) + 1;\n }\n\n append(mediaSegmentInfo) {\n let list = this._list;\n let msi = mediaSegmentInfo;\n let lastAppendIdx = this._lastAppendLocation;\n let insertIdx = 0;\n\n if (lastAppendIdx !== -1 && lastAppendIdx < list.length &&\n msi.originalBeginDts >= list[lastAppendIdx].lastSample.originalDts &&\n ((lastAppendIdx === list.length - 1) ||\n (lastAppendIdx < list.length - 1 &&\n msi.originalBeginDts < list[lastAppendIdx + 1].originalBeginDts))) {\n insertIdx = lastAppendIdx + 1; // use cached location idx\n } else {\n if (list.length > 0) {\n insertIdx = this._searchNearestSegmentBefore(msi.originalBeginDts) + 1;\n }\n }\n\n this._lastAppendLocation = insertIdx;\n this._list.splice(insertIdx, 0, msi);\n }\n\n getLastSegmentBefore(originalBeginDts) {\n let idx = this._searchNearestSegmentBefore(originalBeginDts);\n if (idx >= 0) {\n return this._list[idx];\n } else { // -1\n return null;\n }\n }\n\n getLastSampleBefore(originalBeginDts) {\n let segment = this.getLastSegmentBefore(originalBeginDts);\n if (segment != null) {\n return segment.lastSample;\n } else {\n return null;\n }\n }\n\n getLastSyncPointBefore(originalBeginDts) {\n let segmentIdx = this._searchNearestSegmentBefore(originalBeginDts);\n let syncPoints = this._list[segmentIdx].syncPoints;\n while (syncPoints.length === 0 && segmentIdx > 0) {\n segmentIdx--;\n syncPoints = this._list[segmentIdx].syncPoints;\n }\n if (syncPoints.length > 0) {\n return syncPoints[syncPoints.length - 1];\n } else {\n return null;\n }\n }\n\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass MediaInfo {\n\n constructor() {\n this.mimeType = null;\n this.duration = null;\n\n this.hasAudio = null;\n this.hasVideo = null;\n this.audioCodec = null;\n this.videoCodec = null;\n this.audioDataRate = null;\n this.videoDataRate = null;\n\n this.audioSampleRate = null;\n this.audioChannelCount = null;\n\n this.width = null;\n this.height = null;\n this.fps = null;\n this.profile = null;\n this.level = null;\n this.refFrames = null;\n this.chromaFormat = null;\n this.sarNum = null;\n this.sarDen = null;\n\n this.metadata = null;\n this.segments = null; // MediaInfo[]\n this.segmentCount = null;\n this.hasKeyframesIndex = null;\n this.keyframesIndex = null;\n }\n\n isComplete() {\n let audioInfoComplete = (this.hasAudio === false) ||\n (this.hasAudio === true &&\n this.audioCodec != null &&\n this.audioSampleRate != null &&\n this.audioChannelCount != null);\n\n let videoInfoComplete = (this.hasVideo === false) ||\n (this.hasVideo === true &&\n this.videoCodec != null &&\n this.width != null &&\n this.height != null &&\n this.fps != null &&\n this.profile != null &&\n this.level != null &&\n this.refFrames != null &&\n this.chromaFormat != null &&\n this.sarNum != null &&\n this.sarDen != null);\n\n // keyframesIndex may not be present\n return this.mimeType != null &&\n audioInfoComplete &&\n videoInfoComplete;\n }\n\n isSeekable() {\n return this.hasKeyframesIndex === true;\n }\n\n getNearestKeyframe(milliseconds) {\n if (this.keyframesIndex == null) {\n return null;\n }\n\n let table = this.keyframesIndex;\n let keyframeIdx = this._search(table.times, milliseconds);\n\n return {\n index: keyframeIdx,\n milliseconds: table.times[keyframeIdx],\n fileposition: table.filepositions[keyframeIdx]\n };\n }\n\n _search(list, value) {\n let idx = 0;\n\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (value < list[0]) {\n idx = 0;\n lbound = ubound + 1; // skip search\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (value >= list[mid] && value < list[mid + 1])) {\n idx = mid;\n break;\n } else if (list[mid] < value) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n\n return idx;\n }\n\n}\n\nexport default MediaInfo;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from './logger.js';\n\nclass LoggingControl {\n\n static get forceGlobalTag() {\n return Log.FORCE_GLOBAL_TAG;\n }\n\n static set forceGlobalTag(enable) {\n Log.FORCE_GLOBAL_TAG = enable;\n LoggingControl._notifyChange();\n }\n\n static get globalTag() {\n return Log.GLOBAL_TAG;\n }\n\n static set globalTag(tag) {\n Log.GLOBAL_TAG = tag;\n LoggingControl._notifyChange();\n }\n\n static get enableAll() {\n return Log.ENABLE_VERBOSE\n && Log.ENABLE_DEBUG\n && Log.ENABLE_INFO\n && Log.ENABLE_WARN\n && Log.ENABLE_ERROR;\n }\n\n static set enableAll(enable) {\n Log.ENABLE_VERBOSE = enable;\n Log.ENABLE_DEBUG = enable;\n Log.ENABLE_INFO = enable;\n Log.ENABLE_WARN = enable;\n Log.ENABLE_ERROR = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableDebug() {\n return Log.ENABLE_DEBUG;\n }\n\n static set enableDebug(enable) {\n Log.ENABLE_DEBUG = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableVerbose() {\n return Log.ENABLE_VERBOSE;\n }\n\n static set enableVerbose(enable) {\n Log.ENABLE_VERBOSE = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableInfo() {\n return Log.ENABLE_INFO;\n }\n\n static set enableInfo(enable) {\n Log.ENABLE_INFO = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableWarn() {\n return Log.ENABLE_WARN;\n }\n\n static set enableWarn(enable) {\n Log.ENABLE_WARN = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableError() {\n return Log.ENABLE_ERROR;\n }\n\n static set enableError(enable) {\n Log.ENABLE_ERROR = enable;\n LoggingControl._notifyChange();\n }\n\n static getConfig() {\n return {\n globalTag: Log.GLOBAL_TAG,\n forceGlobalTag: Log.FORCE_GLOBAL_TAG,\n enableVerbose: Log.ENABLE_VERBOSE,\n enableDebug: Log.ENABLE_DEBUG,\n enableInfo: Log.ENABLE_INFO,\n enableWarn: Log.ENABLE_WARN,\n enableError: Log.ENABLE_ERROR,\n enableCallback: Log.ENABLE_CALLBACK\n };\n }\n\n static applyConfig(config) {\n Log.GLOBAL_TAG = config.globalTag;\n Log.FORCE_GLOBAL_TAG = config.forceGlobalTag;\n Log.ENABLE_VERBOSE = config.enableVerbose;\n Log.ENABLE_DEBUG = config.enableDebug;\n Log.ENABLE_INFO = config.enableInfo;\n Log.ENABLE_WARN = config.enableWarn;\n Log.ENABLE_ERROR = config.enableError;\n Log.ENABLE_CALLBACK = config.enableCallback;\n }\n\n static _notifyChange() {\n let emitter = LoggingControl.emitter;\n\n if (emitter.listenerCount('change') > 0) {\n let config = LoggingControl.getConfig();\n emitter.emit('change', config);\n }\n }\n\n static registerListener(listener) {\n LoggingControl.emitter.addListener('change', listener);\n }\n\n static removeListener(listener) {\n LoggingControl.emitter.removeListener('change', listener);\n }\n\n static addLogListener(listener) {\n Log.emitter.addListener('log', listener);\n if (Log.emitter.listenerCount('log') > 0) {\n Log.ENABLE_CALLBACK = true;\n LoggingControl._notifyChange();\n }\n }\n\n static removeLogListener(listener) {\n Log.emitter.removeListener('log', listener);\n if (Log.emitter.listenerCount('log') === 0) {\n Log.ENABLE_CALLBACK = false;\n LoggingControl._notifyChange();\n }\n }\n\n}\n\nLoggingControl.emitter = new EventEmitter();\n\nexport default LoggingControl;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is derived from C++ project libWinTF8 (https://github.com/m13253/libWinTF8)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nfunction checkContinuation(uint8array, start, checkLength) {\n let array = uint8array;\n if (start + checkLength < array.length) {\n while (checkLength--) {\n if ((array[++start] & 0xC0) !== 0x80)\n return false;\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction decodeUTF8(uint8array) {\n let out = [];\n let input = uint8array;\n let i = 0;\n let length = uint8array.length;\n\n while (i < length) {\n if (input[i] < 0x80) {\n out.push(String.fromCharCode(input[i]));\n ++i;\n continue;\n } else if (input[i] < 0xC0) {\n // fallthrough\n } else if (input[i] < 0xE0) {\n if (checkContinuation(input, i, 1)) {\n let ucs4 = (input[i] & 0x1F) << 6 | (input[i + 1] & 0x3F);\n if (ucs4 >= 0x80) {\n out.push(String.fromCharCode(ucs4 & 0xFFFF));\n i += 2;\n continue;\n }\n }\n } else if (input[i] < 0xF0) {\n if (checkContinuation(input, i, 2)) {\n let ucs4 = (input[i] & 0xF) << 12 | (input[i + 1] & 0x3F) << 6 | input[i + 2] & 0x3F;\n if (ucs4 >= 0x800 && (ucs4 & 0xF800) !== 0xD800) {\n out.push(String.fromCharCode(ucs4 & 0xFFFF));\n i += 3;\n continue;\n }\n }\n } else if (input[i] < 0xF8) {\n if (checkContinuation(input, i, 3)) {\n let ucs4 = (input[i] & 0x7) << 18 | (input[i + 1] & 0x3F) << 12\n | (input[i + 2] & 0x3F) << 6 | (input[i + 3] & 0x3F);\n if (ucs4 > 0x10000 && ucs4 < 0x110000) {\n ucs4 -= 0x10000;\n out.push(String.fromCharCode((ucs4 >>> 10) | 0xD800));\n out.push(String.fromCharCode((ucs4 & 0x3FF) | 0xDC00));\n i += 4;\n continue;\n }\n }\n }\n out.push(String.fromCharCode(0xFFFD));\n ++i;\n }\n\n return out.join('');\n}\n\nexport default decodeUTF8;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport decodeUTF8 from '../utils/utf8-conv.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\nlet le = (function () {\n let buf = new ArrayBuffer(2);\n (new DataView(buf)).setInt16(0, 256, true); // little-endian write\n return (new Int16Array(buf))[0] === 256; // platform-spec read, if equal then LE\n})();\n\nclass AMF {\n\n static parseScriptData(arrayBuffer, dataOffset, dataSize) {\n let data = {};\n\n try {\n let name = AMF.parseValue(arrayBuffer, dataOffset, dataSize);\n let value = AMF.parseValue(arrayBuffer, dataOffset + name.size, dataSize - name.size);\n\n data[name.data] = value.data;\n } catch (e) {\n Log.e('AMF', e.toString());\n }\n\n return data;\n }\n\n static parseObject(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 3) {\n throw new IllegalStateException('Data not enough when parse ScriptDataObject');\n }\n let name = AMF.parseString(arrayBuffer, dataOffset, dataSize);\n let value = AMF.parseValue(arrayBuffer, dataOffset + name.size, dataSize - name.size);\n let isObjectEnd = value.objectEnd;\n\n return {\n data: {\n name: name.data,\n value: value.data\n },\n size: name.size + value.size,\n objectEnd: isObjectEnd\n };\n }\n\n static parseVariable(arrayBuffer, dataOffset, dataSize) {\n return AMF.parseObject(arrayBuffer, dataOffset, dataSize);\n }\n\n static parseString(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 2) {\n throw new IllegalStateException('Data not enough when parse String');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let length = v.getUint16(0, !le);\n\n let str;\n if (length > 0) {\n str = decodeUTF8(new Uint8Array(arrayBuffer, dataOffset + 2, length));\n } else {\n str = '';\n }\n\n return {\n data: str,\n size: 2 + length\n };\n }\n\n static parseLongString(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 4) {\n throw new IllegalStateException('Data not enough when parse LongString');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let length = v.getUint32(0, !le);\n\n let str;\n if (length > 0) {\n str = decodeUTF8(new Uint8Array(arrayBuffer, dataOffset + 4, length));\n } else {\n str = '';\n }\n\n return {\n data: str,\n size: 4 + length\n };\n }\n\n static parseDate(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 10) {\n throw new IllegalStateException('Data size invalid when parse Date');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let timestamp = v.getFloat64(0, !le);\n let localTimeOffset = v.getInt16(8, !le);\n timestamp += localTimeOffset * 60 * 1000; // get UTC time\n\n return {\n data: new Date(timestamp),\n size: 8 + 2\n };\n }\n\n static parseValue(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 1) {\n throw new IllegalStateException('Data not enough when parse Value');\n }\n\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let offset = 1;\n let type = v.getUint8(0);\n let value;\n let objectEnd = false;\n\n try {\n switch (type) {\n case 0: // Number(Double) type\n value = v.getFloat64(1, !le);\n offset += 8;\n break;\n case 1: { // Boolean type\n let b = v.getUint8(1);\n value = b ? true : false;\n offset += 1;\n break;\n }\n case 2: { // String type\n let amfstr = AMF.parseString(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = amfstr.data;\n offset += amfstr.size;\n break;\n }\n case 3: { // Object(s) type\n value = {};\n let terminal = 0; // workaround for malformed Objects which has missing ScriptDataObjectEnd\n if ((v.getUint32(dataSize - 4, !le) & 0x00FFFFFF) === 9) {\n terminal = 3;\n }\n while (offset < dataSize - 4) { // 4 === type(UI8) + ScriptDataObjectEnd(UI24)\n let amfobj = AMF.parseObject(arrayBuffer, dataOffset + offset, dataSize - offset - terminal);\n if (amfobj.objectEnd)\n break;\n value[amfobj.data.name] = amfobj.data.value;\n offset += amfobj.size;\n }\n if (offset <= dataSize - 3) {\n let marker = v.getUint32(offset - 1, !le) & 0x00FFFFFF;\n if (marker === 9) {\n offset += 3;\n }\n }\n break;\n }\n case 8: { // ECMA array type (Mixed array)\n value = {};\n offset += 4; // ECMAArrayLength(UI32)\n let terminal = 0; // workaround for malformed MixedArrays which has missing ScriptDataObjectEnd\n if ((v.getUint32(dataSize - 4, !le) & 0x00FFFFFF) === 9) {\n terminal = 3;\n }\n while (offset < dataSize - 8) { // 8 === type(UI8) + ECMAArrayLength(UI32) + ScriptDataVariableEnd(UI24)\n let amfvar = AMF.parseVariable(arrayBuffer, dataOffset + offset, dataSize - offset - terminal);\n if (amfvar.objectEnd)\n break;\n value[amfvar.data.name] = amfvar.data.value;\n offset += amfvar.size;\n }\n if (offset <= dataSize - 3) {\n let marker = v.getUint32(offset - 1, !le) & 0x00FFFFFF;\n if (marker === 9) {\n offset += 3;\n }\n }\n break;\n }\n case 9: // ScriptDataObjectEnd\n value = undefined;\n offset = 1;\n objectEnd = true;\n break;\n case 10: { // Strict array type\n // ScriptDataValue[n]. NOTE: according to video_file_format_spec_v10_1.pdf\n value = [];\n let strictArrayLength = v.getUint32(1, !le);\n offset += 4;\n for (let i = 0; i < strictArrayLength; i++) {\n let val = AMF.parseValue(arrayBuffer, dataOffset + offset, dataSize - offset);\n value.push(val.data);\n offset += val.size;\n }\n break;\n }\n case 11: { // Date type\n let date = AMF.parseDate(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = date.data;\n offset += date.size;\n break;\n }\n case 12: { // Long string type\n let amfLongStr = AMF.parseString(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = amfLongStr.data;\n offset += amfLongStr.size;\n break;\n }\n default:\n // ignore and skip\n offset = dataSize;\n Log.w('AMF', 'Unsupported AMF value type ' + type);\n }\n } catch (e) {\n Log.e('AMF', e.toString());\n }\n\n return {\n data: value,\n size: offset,\n objectEnd: objectEnd\n };\n }\n\n}\n\nexport default AMF;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {IllegalStateException, InvalidArgumentException} from '../utils/exception.js';\n\n// Exponential-Golomb buffer decoder\nclass ExpGolomb {\n\n constructor(uint8array) {\n this.TAG = 'ExpGolomb';\n\n this._buffer = uint8array;\n this._buffer_index = 0;\n this._total_bytes = uint8array.byteLength;\n this._total_bits = uint8array.byteLength * 8;\n this._current_word = 0;\n this._current_word_bits_left = 0;\n }\n\n destroy() {\n this._buffer = null;\n }\n\n _fillCurrentWord() {\n let buffer_bytes_left = this._total_bytes - this._buffer_index;\n if (buffer_bytes_left <= 0)\n throw new IllegalStateException('ExpGolomb: _fillCurrentWord() but no bytes available');\n\n let bytes_read = Math.min(4, buffer_bytes_left);\n let word = new Uint8Array(4);\n word.set(this._buffer.subarray(this._buffer_index, this._buffer_index + bytes_read));\n this._current_word = new DataView(word.buffer).getUint32(0, false);\n\n this._buffer_index += bytes_read;\n this._current_word_bits_left = bytes_read * 8;\n }\n\n readBits(bits) {\n if (bits > 32)\n throw new InvalidArgumentException('ExpGolomb: readBits() bits exceeded max 32bits!');\n\n if (bits <= this._current_word_bits_left) {\n let result = this._current_word >>> (32 - bits);\n this._current_word <<= bits;\n this._current_word_bits_left -= bits;\n return result;\n }\n\n let result = this._current_word_bits_left ? this._current_word : 0;\n result = result >>> (32 - this._current_word_bits_left);\n let bits_need_left = bits - this._current_word_bits_left;\n\n this._fillCurrentWord();\n let bits_read_next = Math.min(bits_need_left, this._current_word_bits_left);\n\n let result2 = this._current_word >>> (32 - bits_read_next);\n this._current_word <<= bits_read_next;\n this._current_word_bits_left -= bits_read_next;\n\n result = (result << bits_read_next) | result2;\n return result;\n }\n\n readBool() {\n return this.readBits(1) === 1;\n }\n\n readByte() {\n return this.readBits(8);\n }\n\n _skipLeadingZero() {\n let zero_count;\n for (zero_count = 0; zero_count < this._current_word_bits_left; zero_count++) {\n if (0 !== (this._current_word & (0x80000000 >>> zero_count))) {\n this._current_word <<= zero_count;\n this._current_word_bits_left -= zero_count;\n return zero_count;\n }\n }\n this._fillCurrentWord();\n return zero_count + this._skipLeadingZero();\n }\n\n readUEG() { // unsigned exponential golomb\n let leading_zeros = this._skipLeadingZero();\n return this.readBits(leading_zeros + 1) - 1;\n }\n\n readSEG() { // signed exponential golomb\n let value = this.readUEG();\n if (value & 0x01) {\n return (value + 1) >>> 1;\n } else {\n return -1 * (value >>> 1);\n }\n }\n\n}\n\nexport default ExpGolomb;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ExpGolomb from './exp-golomb.js';\n\nclass SPSParser {\n\n static _ebsp2rbsp(uint8array) {\n let src = uint8array;\n let src_length = src.byteLength;\n let dst = new Uint8Array(src_length);\n let dst_idx = 0;\n\n for (let i = 0; i < src_length; i++) {\n if (i >= 2) {\n // Unescape: Skip 0x03 after 00 00\n if (src[i] === 0x03 && src[i - 1] === 0x00 && src[i - 2] === 0x00) {\n continue;\n }\n }\n dst[dst_idx] = src[i];\n dst_idx++;\n }\n\n return new Uint8Array(dst.buffer, 0, dst_idx);\n }\n\n static parseSPS(uint8array) {\n let codec_array = uint8array.subarray(1, 4);\n let codec_mimetype = 'avc1.';\n for (let j = 0; j < 3; j++) {\n let h = codec_array[j].toString(16);\n if (h.length < 2) {\n h = '0' + h;\n }\n codec_mimetype += h;\n }\n\n let rbsp = SPSParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n gb.readByte();\n let profile_idc = gb.readByte(); // profile_idc\n gb.readByte(); // constraint_set_flags[5] + reserved_zero[3]\n let level_idc = gb.readByte(); // level_idc\n gb.readUEG(); // seq_parameter_set_id\n\n let profile_string = SPSParser.getProfileString(profile_idc);\n let level_string = SPSParser.getLevelString(level_idc);\n let chroma_format_idc = 1;\n let chroma_format = 420;\n let chroma_format_table = [0, 420, 422, 444];\n let bit_depth_luma = 8;\n let bit_depth_chroma = 8;\n\n if (profile_idc === 100 || profile_idc === 110 || profile_idc === 122 ||\n profile_idc === 244 || profile_idc === 44 || profile_idc === 83 ||\n profile_idc === 86 || profile_idc === 118 || profile_idc === 128 ||\n profile_idc === 138 || profile_idc === 144) {\n\n chroma_format_idc = gb.readUEG();\n if (chroma_format_idc === 3) {\n gb.readBits(1); // separate_colour_plane_flag\n }\n if (chroma_format_idc <= 3) {\n chroma_format = chroma_format_table[chroma_format_idc];\n }\n\n bit_depth_luma = gb.readUEG() + 8; // bit_depth_luma_minus8\n bit_depth_chroma = gb.readUEG() + 8; // bit_depth_chroma_minus8\n gb.readBits(1); // qpprime_y_zero_transform_bypass_flag\n if (gb.readBool()) { // seq_scaling_matrix_present_flag\n let scaling_list_count = (chroma_format_idc !== 3) ? 8 : 12;\n for (let i = 0; i < scaling_list_count; i++) {\n if (gb.readBool()) { // seq_scaling_list_present_flag\n if (i < 6) {\n SPSParser._skipScalingList(gb, 16);\n } else {\n SPSParser._skipScalingList(gb, 64);\n }\n }\n }\n }\n }\n gb.readUEG(); // log2_max_frame_num_minus4\n let pic_order_cnt_type = gb.readUEG();\n if (pic_order_cnt_type === 0) {\n gb.readUEG(); // log2_max_pic_order_cnt_lsb_minus_4\n } else if (pic_order_cnt_type === 1) {\n gb.readBits(1); // delta_pic_order_always_zero_flag\n gb.readSEG(); // offset_for_non_ref_pic\n gb.readSEG(); // offset_for_top_to_bottom_field\n let num_ref_frames_in_pic_order_cnt_cycle = gb.readUEG();\n for (let i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {\n gb.readSEG(); // offset_for_ref_frame\n }\n }\n let ref_frames = gb.readUEG(); // max_num_ref_frames\n gb.readBits(1); // gaps_in_frame_num_value_allowed_flag\n\n let pic_width_in_mbs_minus1 = gb.readUEG();\n let pic_height_in_map_units_minus1 = gb.readUEG();\n\n let frame_mbs_only_flag = gb.readBits(1);\n if (frame_mbs_only_flag === 0) {\n gb.readBits(1); // mb_adaptive_frame_field_flag\n }\n gb.readBits(1); // direct_8x8_inference_flag\n\n let frame_crop_left_offset = 0;\n let frame_crop_right_offset = 0;\n let frame_crop_top_offset = 0;\n let frame_crop_bottom_offset = 0;\n\n let frame_cropping_flag = gb.readBool();\n if (frame_cropping_flag) {\n frame_crop_left_offset = gb.readUEG();\n frame_crop_right_offset = gb.readUEG();\n frame_crop_top_offset = gb.readUEG();\n frame_crop_bottom_offset = gb.readUEG();\n }\n\n let sar_width = 1, sar_height = 1;\n let fps = 0, fps_fixed = true, fps_num = 0, fps_den = 0;\n\n let vui_parameters_present_flag = gb.readBool();\n if (vui_parameters_present_flag) {\n if (gb.readBool()) { // aspect_ratio_info_present_flag\n let aspect_ratio_idc = gb.readByte();\n let sar_w_table = [1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2];\n let sar_h_table = [1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1];\n\n if (aspect_ratio_idc > 0 && aspect_ratio_idc < 16) {\n sar_width = sar_w_table[aspect_ratio_idc - 1];\n sar_height = sar_h_table[aspect_ratio_idc - 1];\n } else if (aspect_ratio_idc === 255) {\n sar_width = gb.readByte() << 8 | gb.readByte();\n sar_height = gb.readByte() << 8 | gb.readByte();\n }\n }\n\n if (gb.readBool()) { // overscan_info_present_flag\n gb.readBool(); // overscan_appropriate_flag\n }\n if (gb.readBool()) { // video_signal_type_present_flag\n gb.readBits(4); // video_format & video_full_range_flag\n if (gb.readBool()) { // colour_description_present_flag\n gb.readBits(24); // colour_primaries & transfer_characteristics & matrix_coefficients\n }\n }\n if (gb.readBool()) { // chroma_loc_info_present_flag\n gb.readUEG(); // chroma_sample_loc_type_top_field\n gb.readUEG(); // chroma_sample_loc_type_bottom_field\n }\n if (gb.readBool()) { // timing_info_present_flag\n let num_units_in_tick = gb.readBits(32);\n let time_scale = gb.readBits(32);\n fps_fixed = gb.readBool(); // fixed_frame_rate_flag\n\n fps_num = time_scale;\n fps_den = num_units_in_tick * 2;\n fps = fps_num / fps_den;\n }\n }\n\n let sarScale = 1;\n if (sar_width !== 1 || sar_height !== 1) {\n sarScale = sar_width / sar_height;\n }\n\n let crop_unit_x = 0, crop_unit_y = 0;\n if (chroma_format_idc === 0) {\n crop_unit_x = 1;\n crop_unit_y = 2 - frame_mbs_only_flag;\n } else {\n let sub_wc = (chroma_format_idc === 3) ? 1 : 2;\n let sub_hc = (chroma_format_idc === 1) ? 2 : 1;\n crop_unit_x = sub_wc;\n crop_unit_y = sub_hc * (2 - frame_mbs_only_flag);\n }\n\n let codec_width = (pic_width_in_mbs_minus1 + 1) * 16;\n let codec_height = (2 - frame_mbs_only_flag) * ((pic_height_in_map_units_minus1 + 1) * 16);\n\n codec_width -= (frame_crop_left_offset + frame_crop_right_offset) * crop_unit_x;\n codec_height -= (frame_crop_top_offset + frame_crop_bottom_offset) * crop_unit_y;\n\n let present_width = Math.ceil(codec_width * sarScale);\n\n gb.destroy();\n gb = null;\n\n return {\n codec_mimetype,\n profile_idc,\n level_idc,\n profile_string, // baseline, high, high10, ...\n level_string, // 3, 3.1, 4, 4.1, 5, 5.1, ...\n chroma_format_idc,\n bit_depth: bit_depth_luma, // 8bit, 10bit, ...\n bit_depth_luma,\n bit_depth_chroma,\n ref_frames,\n chroma_format, // 4:2:0, 4:2:2, ...\n chroma_format_string: SPSParser.getChromaFormatString(chroma_format),\n\n frame_rate: {\n fixed: fps_fixed,\n fps: fps,\n fps_den: fps_den,\n fps_num: fps_num\n },\n\n sar_ratio: {\n width: sar_width,\n height: sar_height\n },\n\n codec_size: {\n width: codec_width,\n height: codec_height\n },\n\n present_size: {\n width: present_width,\n height: codec_height\n }\n };\n }\n\n static _skipScalingList(gb, count) {\n let last_scale = 8, next_scale = 8;\n let delta_scale = 0;\n for (let i = 0; i < count; i++) {\n if (next_scale !== 0) {\n delta_scale = gb.readSEG();\n next_scale = (last_scale + delta_scale + 256) % 256;\n }\n last_scale = (next_scale === 0) ? last_scale : next_scale;\n }\n }\n\n static getProfileString(profile_idc) {\n switch (profile_idc) {\n case 66:\n return 'Baseline';\n case 77:\n return 'Main';\n case 88:\n return 'Extended';\n case 100:\n return 'High';\n case 110:\n return 'High10';\n case 122:\n return 'High422';\n case 244:\n return 'High444';\n default:\n return 'Unknown';\n }\n }\n\n static getLevelString(level_idc) {\n return (level_idc / 10).toFixed(1);\n }\n\n static getChromaFormatString(chroma) {\n switch (chroma) {\n case 420:\n return '4:2:0';\n case 422:\n return '4:2:2';\n case 444:\n return '4:4:4';\n default:\n return 'Unknown';\n }\n }\n\n}\n\nexport default SPSParser;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport AMF from './amf-parser.js';\nimport SPSParser from './sps-parser.js';\nimport DemuxErrors from './demux-errors.js';\nimport MediaInfo from '../core/media-info.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\nfunction Swap16(src) {\n return (((src >>> 8) & 0xFF) |\n ((src & 0xFF) << 8));\n}\n\nfunction Swap32(src) {\n return (((src & 0xFF000000) >>> 24) |\n ((src & 0x00FF0000) >>> 8) |\n ((src & 0x0000FF00) << 8) |\n ((src & 0x000000FF) << 24));\n}\n\nfunction ReadBig32(array, index) {\n return ((array[index] << 24) |\n (array[index + 1] << 16) |\n (array[index + 2] << 8) |\n (array[index + 3]));\n}\n\n\nclass FLVDemuxer {\n\n constructor(probeData, config) {\n this.TAG = 'FLVDemuxer';\n\n this._config = config;\n\n this._onError = null;\n this._onMediaInfo = null;\n this._onMetaDataArrived = null;\n this._onScriptDataArrived = null;\n this._onTrackMetadata = null;\n this._onDataAvailable = null;\n\n this._dataOffset = probeData.dataOffset;\n this._firstParse = true;\n this._dispatch = false;\n\n this._hasAudio = probeData.hasAudioTrack;\n this._hasVideo = probeData.hasVideoTrack;\n\n this._hasAudioFlagOverrided = false;\n this._hasVideoFlagOverrided = false;\n\n this._audioInitialMetadataDispatched = false;\n this._videoInitialMetadataDispatched = false;\n\n this._mediaInfo = new MediaInfo();\n this._mediaInfo.hasAudio = this._hasAudio;\n this._mediaInfo.hasVideo = this._hasVideo;\n this._metadata = null;\n this._audioMetadata = null;\n this._videoMetadata = null;\n\n this._naluLengthSize = 4;\n this._timestampBase = 0; // int32, in milliseconds\n this._timescale = 1000;\n this._duration = 0; // int32, in milliseconds\n this._durationOverrided = false;\n this._referenceFrameRate = {\n fixed: true,\n fps: 23.976,\n fps_num: 23976,\n fps_den: 1000\n };\n\n this._flvSoundRateTable = [5500, 11025, 22050, 44100, 48000];\n\n this._mpegSamplingRates = [\n 96000, 88200, 64000, 48000, 44100, 32000,\n 24000, 22050, 16000, 12000, 11025, 8000, 7350\n ];\n\n this._mpegAudioV10SampleRateTable = [44100, 48000, 32000, 0];\n this._mpegAudioV20SampleRateTable = [22050, 24000, 16000, 0];\n this._mpegAudioV25SampleRateTable = [11025, 12000, 8000, 0];\n\n this._mpegAudioL1BitRateTable = [0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1];\n this._mpegAudioL2BitRateTable = [0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1];\n this._mpegAudioL3BitRateTable = [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1];\n\n this._videoTrack = {type: 'video', id: 1, sequenceNumber: 0, samples: [], length: 0};\n this._audioTrack = {type: 'audio', id: 2, sequenceNumber: 0, samples: [], length: 0};\n\n this._littleEndian = (function () {\n let buf = new ArrayBuffer(2);\n (new DataView(buf)).setInt16(0, 256, true); // little-endian write\n return (new Int16Array(buf))[0] === 256; // platform-spec read, if equal then LE\n })();\n }\n\n destroy() {\n this._mediaInfo = null;\n this._metadata = null;\n this._audioMetadata = null;\n this._videoMetadata = null;\n this._videoTrack = null;\n this._audioTrack = null;\n\n this._onError = null;\n this._onMediaInfo = null;\n this._onMetaDataArrived = null;\n this._onScriptDataArrived = null;\n this._onTrackMetadata = null;\n this._onDataAvailable = null;\n }\n\n static probe(buffer) {\n let data = new Uint8Array(buffer);\n let mismatch = {match: false};\n\n if (data[0] !== 0x46 || data[1] !== 0x4C || data[2] !== 0x56 || data[3] !== 0x01) {\n return mismatch;\n }\n\n let hasAudio = ((data[4] & 4) >>> 2) !== 0;\n let hasVideo = (data[4] & 1) !== 0;\n\n let offset = ReadBig32(data, 5);\n\n if (offset < 9) {\n return mismatch;\n }\n\n return {\n match: true,\n consumed: offset,\n dataOffset: offset,\n hasAudioTrack: hasAudio,\n hasVideoTrack: hasVideo\n };\n }\n\n bindDataSource(loader) {\n loader.onDataArrival = this.parseChunks.bind(this);\n return this;\n }\n\n // prototype: function(type: string, metadata: any): void\n get onTrackMetadata() {\n return this._onTrackMetadata;\n }\n\n set onTrackMetadata(callback) {\n this._onTrackMetadata = callback;\n }\n\n // prototype: function(mediaInfo: MediaInfo): void\n get onMediaInfo() {\n return this._onMediaInfo;\n }\n\n set onMediaInfo(callback) {\n this._onMediaInfo = callback;\n }\n\n get onMetaDataArrived() {\n return this._onMetaDataArrived;\n }\n\n set onMetaDataArrived(callback) {\n this._onMetaDataArrived = callback;\n }\n\n get onScriptDataArrived() {\n return this._onScriptDataArrived;\n }\n\n set onScriptDataArrived(callback) {\n this._onScriptDataArrived = callback;\n }\n\n // prototype: function(type: number, info: string): void\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n // prototype: function(videoTrack: any, audioTrack: any): void\n get onDataAvailable() {\n return this._onDataAvailable;\n }\n\n set onDataAvailable(callback) {\n this._onDataAvailable = callback;\n }\n\n // timestamp base for output samples, must be in milliseconds\n get timestampBase() {\n return this._timestampBase;\n }\n\n set timestampBase(base) {\n this._timestampBase = base;\n }\n\n get overridedDuration() {\n return this._duration;\n }\n\n // Force-override media duration. Must be in milliseconds, int32\n set overridedDuration(duration) {\n this._durationOverrided = true;\n this._duration = duration;\n this._mediaInfo.duration = duration;\n }\n\n // Force-override audio track present flag, boolean\n set overridedHasAudio(hasAudio) {\n this._hasAudioFlagOverrided = true;\n this._hasAudio = hasAudio;\n this._mediaInfo.hasAudio = hasAudio;\n }\n\n // Force-override video track present flag, boolean\n set overridedHasVideo(hasVideo) {\n this._hasVideoFlagOverrided = true;\n this._hasVideo = hasVideo;\n this._mediaInfo.hasVideo = hasVideo;\n }\n\n resetMediaInfo() {\n this._mediaInfo = new MediaInfo();\n }\n\n _isInitialMetadataDispatched() {\n if (this._hasAudio && this._hasVideo) { // both audio & video\n return this._audioInitialMetadataDispatched && this._videoInitialMetadataDispatched;\n }\n if (this._hasAudio && !this._hasVideo) { // audio only\n return this._audioInitialMetadataDispatched;\n }\n if (!this._hasAudio && this._hasVideo) { // video only\n return this._videoInitialMetadataDispatched;\n }\n return false;\n }\n\n // function parseChunks(chunk: ArrayBuffer, byteStart: number): number;\n parseChunks(chunk, byteStart) {\n if (!this._onError || !this._onMediaInfo || !this._onTrackMetadata || !this._onDataAvailable) {\n throw new IllegalStateException('Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified');\n }\n\n let offset = 0;\n let le = this._littleEndian;\n\n if (byteStart === 0) { // buffer with FLV header\n if (chunk.byteLength > 13) {\n let probeData = FLVDemuxer.probe(chunk);\n offset = probeData.dataOffset;\n } else {\n return 0;\n }\n }\n\n if (this._firstParse) { // handle PreviousTagSize0 before Tag1\n this._firstParse = false;\n if (byteStart + offset !== this._dataOffset) {\n Log.w(this.TAG, 'First time parsing but chunk byteStart invalid!');\n }\n\n let v = new DataView(chunk, offset);\n let prevTagSize0 = v.getUint32(0, !le);\n if (prevTagSize0 !== 0) {\n Log.w(this.TAG, 'PrevTagSize0 !== 0 !!!');\n }\n offset += 4;\n }\n\n while (offset < chunk.byteLength) {\n this._dispatch = true;\n\n let v = new DataView(chunk, offset);\n\n if (offset + 11 + 4 > chunk.byteLength) {\n // data not enough for parsing an flv tag\n break;\n }\n\n let tagType = v.getUint8(0);\n let dataSize = v.getUint32(0, !le) & 0x00FFFFFF;\n\n if (offset + 11 + dataSize + 4 > chunk.byteLength) {\n // data not enough for parsing actual data body\n break;\n }\n\n if (tagType !== 8 && tagType !== 9 && tagType !== 18) {\n Log.w(this.TAG, `Unsupported tag type ${tagType}, skipped`);\n // consume the whole tag (skip it)\n offset += 11 + dataSize + 4;\n continue;\n }\n\n let ts2 = v.getUint8(4);\n let ts1 = v.getUint8(5);\n let ts0 = v.getUint8(6);\n let ts3 = v.getUint8(7);\n\n let timestamp = ts0 | (ts1 << 8) | (ts2 << 16) | (ts3 << 24);\n\n let streamId = v.getUint32(7, !le) & 0x00FFFFFF;\n if (streamId !== 0) {\n Log.w(this.TAG, 'Meet tag which has StreamID != 0!');\n }\n\n let dataOffset = offset + 11;\n\n switch (tagType) {\n case 8: // Audio\n this._parseAudioData(chunk, dataOffset, dataSize, timestamp);\n break;\n case 9: // Video\n this._parseVideoData(chunk, dataOffset, dataSize, timestamp, byteStart + offset);\n break;\n case 18: // ScriptDataObject\n this._parseScriptData(chunk, dataOffset, dataSize);\n break;\n }\n\n let prevTagSize = v.getUint32(11 + dataSize, !le);\n if (prevTagSize !== 11 + dataSize) {\n Log.w(this.TAG, `Invalid PrevTagSize ${prevTagSize}`);\n }\n\n offset += 11 + dataSize + 4; // tagBody + dataSize + prevTagSize\n }\n\n // dispatch parsed frames to consumer (typically, the remuxer)\n if (this._isInitialMetadataDispatched()) {\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n }\n\n return offset; // consumed bytes, just equals latest offset index\n }\n\n _parseScriptData(arrayBuffer, dataOffset, dataSize) {\n let scriptData = AMF.parseScriptData(arrayBuffer, dataOffset, dataSize);\n\n if (scriptData.hasOwnProperty('onMetaData')) {\n if (scriptData.onMetaData == null || typeof scriptData.onMetaData !== 'object') {\n Log.w(this.TAG, 'Invalid onMetaData structure!');\n return;\n }\n if (this._metadata) {\n Log.w(this.TAG, 'Found another onMetaData tag!');\n }\n this._metadata = scriptData;\n let onMetaData = this._metadata.onMetaData;\n\n if (this._onMetaDataArrived) {\n this._onMetaDataArrived(Object.assign({}, onMetaData));\n }\n\n if (typeof onMetaData.hasAudio === 'boolean') { // hasAudio\n if (this._hasAudioFlagOverrided === false) {\n this._hasAudio = onMetaData.hasAudio;\n this._mediaInfo.hasAudio = this._hasAudio;\n }\n }\n if (typeof onMetaData.hasVideo === 'boolean') { // hasVideo\n if (this._hasVideoFlagOverrided === false) {\n this._hasVideo = onMetaData.hasVideo;\n this._mediaInfo.hasVideo = this._hasVideo;\n }\n }\n if (typeof onMetaData.audiodatarate === 'number') { // audiodatarate\n this._mediaInfo.audioDataRate = onMetaData.audiodatarate;\n }\n if (typeof onMetaData.videodatarate === 'number') { // videodatarate\n this._mediaInfo.videoDataRate = onMetaData.videodatarate;\n }\n if (typeof onMetaData.width === 'number') { // width\n this._mediaInfo.width = onMetaData.width;\n }\n if (typeof onMetaData.height === 'number') { // height\n this._mediaInfo.height = onMetaData.height;\n }\n if (typeof onMetaData.duration === 'number') { // duration\n if (!this._durationOverrided) {\n let duration = Math.floor(onMetaData.duration * this._timescale);\n this._duration = duration;\n this._mediaInfo.duration = duration;\n }\n } else {\n this._mediaInfo.duration = 0;\n }\n if (typeof onMetaData.framerate === 'number') { // framerate\n let fps_num = Math.floor(onMetaData.framerate * 1000);\n if (fps_num > 0) {\n let fps = fps_num / 1000;\n this._referenceFrameRate.fixed = true;\n this._referenceFrameRate.fps = fps;\n this._referenceFrameRate.fps_num = fps_num;\n this._referenceFrameRate.fps_den = 1000;\n this._mediaInfo.fps = fps;\n }\n }\n if (typeof onMetaData.keyframes === 'object') { // keyframes\n this._mediaInfo.hasKeyframesIndex = true;\n let keyframes = onMetaData.keyframes;\n this._mediaInfo.keyframesIndex = this._parseKeyframesIndex(keyframes);\n onMetaData.keyframes = null; // keyframes has been extracted, remove it\n } else {\n this._mediaInfo.hasKeyframesIndex = false;\n }\n this._dispatch = false;\n this._mediaInfo.metadata = onMetaData;\n Log.v(this.TAG, 'Parsed onMetaData');\n if (this._mediaInfo.isComplete()) {\n this._onMediaInfo(this._mediaInfo);\n }\n }\n\n if (Object.keys(scriptData).length > 0) {\n if (this._onScriptDataArrived) {\n this._onScriptDataArrived(Object.assign({}, scriptData));\n }\n }\n }\n\n _parseKeyframesIndex(keyframes) {\n let times = [];\n let filepositions = [];\n\n // ignore first keyframe which is actually AVC Sequence Header (AVCDecoderConfigurationRecord)\n for (let i = 1; i < keyframes.times.length; i++) {\n let time = this._timestampBase + Math.floor(keyframes.times[i] * 1000);\n times.push(time);\n filepositions.push(keyframes.filepositions[i]);\n }\n\n return {\n times: times,\n filepositions: filepositions\n };\n }\n\n _parseAudioData(arrayBuffer, dataOffset, dataSize, tagTimestamp) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid audio packet, missing SoundData payload!');\n return;\n }\n\n if (this._hasAudioFlagOverrided === true && this._hasAudio === false) {\n // If hasAudio: false indicated explicitly in MediaDataSource,\n // Ignore all the audio packets\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let soundSpec = v.getUint8(0);\n\n let soundFormat = soundSpec >>> 4;\n if (soundFormat !== 2 && soundFormat !== 10) { // MP3 or AAC\n this._onError(DemuxErrors.CODEC_UNSUPPORTED, 'Flv: Unsupported audio codec idx: ' + soundFormat);\n return;\n }\n\n let soundRate = 0;\n let soundRateIndex = (soundSpec & 12) >>> 2;\n if (soundRateIndex >= 0 && soundRateIndex <= 4) {\n soundRate = this._flvSoundRateTable[soundRateIndex];\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid audio sample rate idx: ' + soundRateIndex);\n return;\n }\n\n let soundSize = (soundSpec & 2) >>> 1; // unused\n let soundType = (soundSpec & 1);\n\n\n let meta = this._audioMetadata;\n let track = this._audioTrack;\n\n if (!meta) {\n if (this._hasAudio === false && this._hasAudioFlagOverrided === false) {\n this._hasAudio = true;\n this._mediaInfo.hasAudio = true;\n }\n\n // initial metadata\n meta = this._audioMetadata = {};\n meta.type = 'audio';\n meta.id = track.id;\n meta.timescale = this._timescale;\n meta.duration = this._duration;\n meta.audioSampleRate = soundRate;\n meta.channelCount = (soundType === 0 ? 1 : 2);\n }\n\n if (soundFormat === 10) { // AAC\n let aacData = this._parseAACAudioData(arrayBuffer, dataOffset + 1, dataSize - 1);\n if (aacData == undefined) {\n return;\n }\n\n if (aacData.packetType === 0) { // AAC sequence header (AudioSpecificConfig)\n if (meta.config) {\n Log.w(this.TAG, 'Found another AudioSpecificConfig!');\n }\n let misc = aacData.data;\n meta.audioSampleRate = misc.samplingRate;\n meta.channelCount = misc.channelCount;\n meta.codec = misc.codec;\n meta.originalCodec = misc.originalCodec;\n meta.config = misc.config;\n // The decode result of an aac sample is 1024 PCM samples\n meta.refSampleDuration = 1024 / meta.audioSampleRate * meta.timescale;\n Log.v(this.TAG, 'Parsed AudioSpecificConfig');\n\n if (this._isInitialMetadataDispatched()) {\n // Non-initial metadata, force dispatch (or flush) parsed frames to remuxer\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n } else {\n this._audioInitialMetadataDispatched = true;\n }\n // then notify new metadata\n this._dispatch = false;\n this._onTrackMetadata('audio', meta);\n\n let mi = this._mediaInfo;\n mi.audioCodec = meta.originalCodec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n if (mi.hasVideo) {\n if (mi.videoCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.audioCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n } else if (aacData.packetType === 1) { // AAC raw frame data\n let dts = this._timestampBase + tagTimestamp;\n let aacSample = {unit: aacData.data, length: aacData.data.byteLength, dts: dts, pts: dts};\n track.samples.push(aacSample);\n track.length += aacData.data.length;\n } else {\n Log.e(this.TAG, `Flv: Unsupported AAC data type ${aacData.packetType}`);\n }\n } else if (soundFormat === 2) { // MP3\n if (!meta.codec) {\n // We need metadata for mp3 audio track, extract info from frame header\n let misc = this._parseMP3AudioData(arrayBuffer, dataOffset + 1, dataSize - 1, true);\n if (misc == undefined) {\n return;\n }\n meta.audioSampleRate = misc.samplingRate;\n meta.channelCount = misc.channelCount;\n meta.codec = misc.codec;\n meta.originalCodec = misc.originalCodec;\n // The decode result of an mp3 sample is 1152 PCM samples\n meta.refSampleDuration = 1152 / meta.audioSampleRate * meta.timescale;\n Log.v(this.TAG, 'Parsed MPEG Audio Frame Header');\n\n this._audioInitialMetadataDispatched = true;\n this._onTrackMetadata('audio', meta);\n\n let mi = this._mediaInfo;\n mi.audioCodec = meta.codec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n mi.audioDataRate = misc.bitRate;\n if (mi.hasVideo) {\n if (mi.videoCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.audioCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n }\n\n // This packet is always a valid audio packet, extract it\n let data = this._parseMP3AudioData(arrayBuffer, dataOffset + 1, dataSize - 1, false);\n if (data == undefined) {\n return;\n }\n let dts = this._timestampBase + tagTimestamp;\n let mp3Sample = {unit: data, length: data.byteLength, dts: dts, pts: dts};\n track.samples.push(mp3Sample);\n track.length += data.length;\n }\n }\n\n _parseAACAudioData(arrayBuffer, dataOffset, dataSize) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid AAC packet, missing AACPacketType or/and Data!');\n return;\n }\n\n let result = {};\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n\n result.packetType = array[0];\n\n if (array[0] === 0) {\n result.data = this._parseAACAudioSpecificConfig(arrayBuffer, dataOffset + 1, dataSize - 1);\n } else {\n result.data = array.subarray(1);\n }\n\n return result;\n }\n\n _parseAACAudioSpecificConfig(arrayBuffer, dataOffset, dataSize) {\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n let config = null;\n\n /* Audio Object Type:\n 0: Null\n 1: AAC Main\n 2: AAC LC\n 3: AAC SSR (Scalable Sample Rate)\n 4: AAC LTP (Long Term Prediction)\n 5: HE-AAC / SBR (Spectral Band Replication)\n 6: AAC Scalable\n */\n\n let audioObjectType = 0;\n let originalAudioObjectType = 0;\n let audioExtensionObjectType = null;\n let samplingIndex = 0;\n let extensionSamplingIndex = null;\n\n // 5 bits\n audioObjectType = originalAudioObjectType = array[0] >>> 3;\n // 4 bits\n samplingIndex = ((array[0] & 0x07) << 1) | (array[1] >>> 7);\n if (samplingIndex < 0 || samplingIndex >= this._mpegSamplingRates.length) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: AAC invalid sampling frequency index!');\n return;\n }\n\n let samplingFrequence = this._mpegSamplingRates[samplingIndex];\n\n // 4 bits\n let channelConfig = (array[1] & 0x78) >>> 3;\n if (channelConfig < 0 || channelConfig >= 8) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: AAC invalid channel configuration');\n return;\n }\n\n if (audioObjectType === 5) { // HE-AAC?\n // 4 bits\n extensionSamplingIndex = ((array[1] & 0x07) << 1) | (array[2] >>> 7);\n // 5 bits\n audioExtensionObjectType = (array[2] & 0x7C) >>> 2;\n }\n\n // workarounds for various browsers\n let userAgent = self.navigator.userAgent.toLowerCase();\n\n if (userAgent.indexOf('firefox') !== -1) {\n // firefox: use SBR (HE-AAC) if freq less than 24kHz\n if (samplingIndex >= 6) {\n audioObjectType = 5;\n config = new Array(4);\n extensionSamplingIndex = samplingIndex - 3;\n } else { // use LC-AAC\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n }\n } else if (userAgent.indexOf('android') !== -1) {\n // android: always use LC-AAC\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n } else {\n // for other browsers, e.g. chrome...\n // Always use HE-AAC to make it easier to switch aac codec profile\n audioObjectType = 5;\n extensionSamplingIndex = samplingIndex;\n config = new Array(4);\n\n if (samplingIndex >= 6) {\n extensionSamplingIndex = samplingIndex - 3;\n } else if (channelConfig === 1) { // Mono channel\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n }\n }\n\n config[0] = audioObjectType << 3;\n config[0] |= (samplingIndex & 0x0F) >>> 1;\n config[1] = (samplingIndex & 0x0F) << 7;\n config[1] |= (channelConfig & 0x0F) << 3;\n if (audioObjectType === 5) {\n config[1] |= ((extensionSamplingIndex & 0x0F) >>> 1);\n config[2] = (extensionSamplingIndex & 0x01) << 7;\n // extended audio object type: force to 2 (LC-AAC)\n config[2] |= (2 << 2);\n config[3] = 0;\n }\n\n return {\n config: config,\n samplingRate: samplingFrequence,\n channelCount: channelConfig,\n codec: 'mp4a.40.' + audioObjectType,\n originalCodec: 'mp4a.40.' + originalAudioObjectType\n };\n }\n\n _parseMP3AudioData(arrayBuffer, dataOffset, dataSize, requestHeader) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid MP3 packet, header missing!');\n return;\n }\n\n let le = this._littleEndian;\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n let result = null;\n\n if (requestHeader) {\n if (array[0] !== 0xFF) {\n return;\n }\n let ver = (array[1] >>> 3) & 0x03;\n let layer = (array[1] & 0x06) >> 1;\n\n let bitrate_index = (array[2] & 0xF0) >>> 4;\n let sampling_freq_index = (array[2] & 0x0C) >>> 2;\n\n let channel_mode = (array[3] >>> 6) & 0x03;\n let channel_count = channel_mode !== 3 ? 2 : 1;\n\n let sample_rate = 0;\n let bit_rate = 0;\n let object_type = 34; // Layer-3, listed in MPEG-4 Audio Object Types\n\n let codec = 'mp3';\n\n switch (ver) {\n case 0: // MPEG 2.5\n sample_rate = this._mpegAudioV25SampleRateTable[sampling_freq_index];\n break;\n case 2: // MPEG 2\n sample_rate = this._mpegAudioV20SampleRateTable[sampling_freq_index];\n break;\n case 3: // MPEG 1\n sample_rate = this._mpegAudioV10SampleRateTable[sampling_freq_index];\n break;\n }\n\n switch (layer) {\n case 1: // Layer 3\n object_type = 34;\n if (bitrate_index < this._mpegAudioL3BitRateTable.length) {\n bit_rate = this._mpegAudioL3BitRateTable[bitrate_index];\n }\n break;\n case 2: // Layer 2\n object_type = 33;\n if (bitrate_index < this._mpegAudioL2BitRateTable.length) {\n bit_rate = this._mpegAudioL2BitRateTable[bitrate_index];\n }\n break;\n case 3: // Layer 1\n object_type = 32;\n if (bitrate_index < this._mpegAudioL1BitRateTable.length) {\n bit_rate = this._mpegAudioL1BitRateTable[bitrate_index];\n }\n break;\n }\n\n result = {\n bitRate: bit_rate,\n samplingRate: sample_rate,\n channelCount: channel_count,\n codec: codec,\n originalCodec: codec\n };\n } else {\n result = array;\n }\n\n return result;\n }\n\n _parseVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid video packet, missing VideoData payload!');\n return;\n }\n\n if (this._hasVideoFlagOverrided === true && this._hasVideo === false) {\n // If hasVideo: false indicated explicitly in MediaDataSource,\n // Ignore all the video packets\n return;\n }\n\n let spec = (new Uint8Array(arrayBuffer, dataOffset, dataSize))[0];\n\n let frameType = (spec & 240) >>> 4;\n let codecId = spec & 15;\n\n if (codecId !== 7) {\n this._onError(DemuxErrors.CODEC_UNSUPPORTED, `Flv: Unsupported codec in video frame: ${codecId}`);\n return;\n }\n\n this._parseAVCVideoPacket(arrayBuffer, dataOffset + 1, dataSize - 1, tagTimestamp, tagPosition, frameType);\n }\n\n _parseAVCVideoPacket(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime');\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let packetType = v.getUint8(0);\n let cts_unsigned = v.getUint32(0, !le) & 0x00FFFFFF;\n let cts = (cts_unsigned << 8) >> 8; // convert to 24-bit signed int\n\n if (packetType === 0) { // AVCDecoderConfigurationRecord\n this._parseAVCDecoderConfigurationRecord(arrayBuffer, dataOffset + 4, dataSize - 4);\n } else if (packetType === 1) { // One or more Nalus\n this._parseAVCVideoData(arrayBuffer, dataOffset + 4, dataSize - 4, tagTimestamp, tagPosition, frameType, cts);\n } else if (packetType === 2) {\n // empty, AVC end of sequence\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Invalid video packet type ${packetType}`);\n return;\n }\n }\n\n _parseAVCDecoderConfigurationRecord(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 7) {\n Log.w(this.TAG, 'Flv: Invalid AVCDecoderConfigurationRecord, lack of data!');\n return;\n }\n\n let meta = this._videoMetadata;\n let track = this._videoTrack;\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n if (!meta) {\n if (this._hasVideo === false && this._hasVideoFlagOverrided === false) {\n this._hasVideo = true;\n this._mediaInfo.hasVideo = true;\n }\n\n meta = this._videoMetadata = {};\n meta.type = 'video';\n meta.id = track.id;\n meta.timescale = this._timescale;\n meta.duration = this._duration;\n } else {\n if (typeof meta.avcc !== 'undefined') {\n Log.w(this.TAG, 'Found another AVCDecoderConfigurationRecord!');\n }\n }\n\n let version = v.getUint8(0); // configurationVersion\n let avcProfile = v.getUint8(1); // avcProfileIndication\n let profileCompatibility = v.getUint8(2); // profile_compatibility\n let avcLevel = v.getUint8(3); // AVCLevelIndication\n\n if (version !== 1 || avcProfile === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord');\n return;\n }\n\n this._naluLengthSize = (v.getUint8(4) & 3) + 1; // lengthSizeMinusOne\n if (this._naluLengthSize !== 3 && this._naluLengthSize !== 4) { // holy shit!!!\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Strange NaluLengthSizeMinusOne: ${this._naluLengthSize - 1}`);\n return;\n }\n\n let spsCount = v.getUint8(5) & 31; // numOfSequenceParameterSets\n if (spsCount === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord: No SPS');\n return;\n } else if (spsCount > 1) {\n Log.w(this.TAG, `Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ${spsCount}`);\n }\n\n let offset = 6;\n\n for (let i = 0; i < spsCount; i++) {\n let len = v.getUint16(offset, !le); // sequenceParameterSetLength\n offset += 2;\n\n if (len === 0) {\n continue;\n }\n\n // Notice: Nalu without startcode header (00 00 00 01)\n let sps = new Uint8Array(arrayBuffer, dataOffset + offset, len);\n offset += len;\n\n let config = SPSParser.parseSPS(sps);\n if (i !== 0) {\n // ignore other sps's config\n continue;\n }\n\n meta.codecWidth = config.codec_size.width;\n meta.codecHeight = config.codec_size.height;\n meta.presentWidth = config.present_size.width;\n meta.presentHeight = config.present_size.height;\n\n meta.profile = config.profile_string;\n meta.level = config.level_string;\n meta.bitDepth = config.bit_depth;\n meta.chromaFormat = config.chroma_format;\n meta.sarRatio = config.sar_ratio;\n meta.frameRate = config.frame_rate;\n\n if (config.frame_rate.fixed === false ||\n config.frame_rate.fps_num === 0 ||\n config.frame_rate.fps_den === 0) {\n meta.frameRate = this._referenceFrameRate;\n }\n\n let fps_den = meta.frameRate.fps_den;\n let fps_num = meta.frameRate.fps_num;\n meta.refSampleDuration = meta.timescale * (fps_den / fps_num);\n\n let codecArray = sps.subarray(1, 4);\n let codecString = 'avc1.';\n for (let j = 0; j < 3; j++) {\n let h = codecArray[j].toString(16);\n if (h.length < 2) {\n h = '0' + h;\n }\n codecString += h;\n }\n meta.codec = codecString;\n\n let mi = this._mediaInfo;\n mi.width = meta.codecWidth;\n mi.height = meta.codecHeight;\n mi.fps = meta.frameRate.fps;\n mi.profile = meta.profile;\n mi.level = meta.level;\n mi.refFrames = config.ref_frames;\n mi.chromaFormat = config.chroma_format_string;\n mi.sarNum = meta.sarRatio.width;\n mi.sarDen = meta.sarRatio.height;\n mi.videoCodec = codecString;\n\n if (mi.hasAudio) {\n if (mi.audioCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n }\n\n let ppsCount = v.getUint8(offset); // numOfPictureParameterSets\n if (ppsCount === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord: No PPS');\n return;\n } else if (ppsCount > 1) {\n Log.w(this.TAG, `Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ${ppsCount}`);\n }\n\n offset++;\n\n for (let i = 0; i < ppsCount; i++) {\n let len = v.getUint16(offset, !le); // pictureParameterSetLength\n offset += 2;\n\n if (len === 0) {\n continue;\n }\n\n // pps is useless for extracting video information\n offset += len;\n }\n\n meta.avcc = new Uint8Array(dataSize);\n meta.avcc.set(new Uint8Array(arrayBuffer, dataOffset, dataSize), 0);\n Log.v(this.TAG, 'Parsed AVCDecoderConfigurationRecord');\n\n if (this._isInitialMetadataDispatched()) {\n // flush parsed frames\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n } else {\n this._videoInitialMetadataDispatched = true;\n }\n // notify new metadata\n this._dispatch = false;\n this._onTrackMetadata('video', meta);\n }\n\n _parseAVCVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType, cts) {\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let units = [], length = 0;\n\n let offset = 0;\n const lengthSize = this._naluLengthSize;\n let dts = this._timestampBase + tagTimestamp;\n let keyframe = (frameType === 1); // from FLV Frame Type constants\n\n while (offset < dataSize) {\n if (offset + 4 >= dataSize) {\n Log.w(this.TAG, `Malformed Nalu near timestamp ${dts}, offset = ${offset}, dataSize = ${dataSize}`);\n break; // data not enough for next Nalu\n }\n // Nalu with length-header (AVC1)\n let naluSize = v.getUint32(offset, !le); // Big-Endian read\n if (lengthSize === 3) {\n naluSize >>>= 8;\n }\n if (naluSize > dataSize - lengthSize) {\n Log.w(this.TAG, `Malformed Nalus near timestamp ${dts}, NaluSize > DataSize!`);\n return;\n }\n\n let unitType = v.getUint8(offset + lengthSize) & 0x1F;\n\n if (unitType === 5) { // IDR\n keyframe = true;\n }\n\n let data = new Uint8Array(arrayBuffer, dataOffset + offset, lengthSize + naluSize);\n let unit = {type: unitType, data: data};\n units.push(unit);\n length += data.byteLength;\n\n offset += lengthSize + naluSize;\n }\n\n if (units.length) {\n let track = this._videoTrack;\n let avcSample = {\n units: units,\n length: length,\n isKeyframe: keyframe,\n dts: dts,\n cts: cts,\n pts: (dts + cts)\n };\n if (keyframe) {\n avcSample.fileposition = tagPosition;\n }\n track.samples.push(avcSample);\n track.length += length;\n }\n }\n\n}\n\nexport default FLVDemuxer;","interface ProgramToPMTPIDMap {\n [program: number]: number;\n}\n\nexport class PAT {\n version_number: number;\n network_pid: number;\n // program_number -> pmt_pid\n program_pmt_pid: ProgramToPMTPIDMap = {};\n}\n\nexport enum StreamType {\n kMPEG1Audio = 0x03,\n kMPEG2Audio = 0x04,\n kPESPrivateData = 0x06,\n kADTSAAC = 0x0F,\n kID3 = 0x15,\n kSCTE35 = 0x86,\n kH264 = 0x1b,\n kH265 = 0x24\n}\n\ninterface PIDToStreamTypeMap {\n [pid: number]: StreamType;\n}\n\nexport class PMT {\n program_number: number;\n version_number: number;\n pcr_pid: number;\n // pid -> stream_type\n pid_stream_type: PIDToStreamTypeMap = {};\n\n common_pids: {\n h264: number | undefined,\n h265: number | undefined;\n adts_aac: number | undefined\n } = {\n h264: undefined,\n h265: undefined,\n adts_aac: undefined\n };\n\n pes_private_data_pids: {\n [pid: number]: boolean\n } = {};\n\n timed_id3_pids: {\n [pid: number]: boolean\n } = {};\n\n scte_35_pids: {\n [pid: number]: boolean\n } = {};\n}\n\nexport interface ProgramToPMTMap {\n [program: number]: PMT;\n}\n\nexport class PESData {\n pid: number;\n data: Uint8Array;\n stream_type: StreamType;\n file_position: number;\n random_access_indicator: number;\n}\n\nexport class SectionData {\n pid: number;\n data: Uint8Array;\n file_position: number;\n random_access_indicator: number;\n}\n\nexport class SliceQueue {\n slices: Uint8Array[] = [];\n total_length: number = 0;\n expected_length: number = 0;\n file_position: number = 0;\n random_access_indicator: 0;\n}\n\nexport interface PIDToSliceQueues {\n [pid: number]: SliceQueue;\n}\n","import MediaInfo from '../core/media-info';\nimport { PESPrivateData, PESPrivateDataDescriptor } from './pes-private-data';\nimport { SCTE35Data } from './scte35';\n\ntype OnErrorCallback = (type: string, info: string) => void;\ntype OnMediaInfoCallback = (mediaInfo: MediaInfo) => void;\ntype OnMetaDataArrivedCallback = (metadata: any) => void;\ntype OnTrackMetadataCallback = (type: string, metadata: any) => void;\ntype OnDataAvailableCallback = (videoTrack: any, audioTrack: any) => void;\ntype OnTimedID3MetadataCallback = (timed_id3_data: PESPrivateData) => void;\ntype OnSCTE35MetadataCallback = (scte35_data: SCTE35Data) => void;\ntype OnPESPrivateDataCallback = (private_data: PESPrivateData) => void;\ntype OnPESPrivateDataDescriptorCallback = (private_data_descriptor: PESPrivateDataDescriptor) => void;\n\nexport default abstract class BaseDemuxer {\n\n public onError: OnErrorCallback;\n public onMediaInfo: OnMediaInfoCallback;\n public onMetaDataArrived: OnMetaDataArrivedCallback;\n public onTrackMetadata: OnTrackMetadataCallback;\n public onDataAvailable: OnDataAvailableCallback;\n public onTimedID3Metadata: OnTimedID3MetadataCallback;\n public onSCTE35Metadata: OnSCTE35MetadataCallback;\n public onPESPrivateData: OnPESPrivateDataCallback;\n public onPESPrivateDataDescriptor: OnPESPrivateDataDescriptorCallback;\n\n public constructor() {}\n\n public destroy(): void {\n this.onError = null;\n this.onMediaInfo = null;\n this.onMetaDataArrived = null;\n this.onTrackMetadata = null;\n this.onDataAvailable = null;\n this.onTimedID3Metadata = null;\n this.onSCTE35Metadata = null;\n this.onPESPrivateData = null;\n this.onPESPrivateDataDescriptor = null;\n }\n\n abstract parseChunks(chunk: ArrayBuffer, byteStart: number): number;\n\n}\n","import Log from \"../utils/logger\";\n\nexport enum H264NaluType {\n kUnspecified = 0,\n kSliceNonIDR,\n kSliceDPA,\n kSliceDPB,\n kSliceDPC,\n kSliceIDR,\n kSliceSEI,\n kSliceSPS,\n kSlicePPS,\n kSliceAUD,\n kEndOfSequence,\n kEndOfStream,\n kFiller,\n kSPSExt,\n kReserved0\n}\n\nexport class H264NaluPayload {\n type: H264NaluType;\n data: Uint8Array;\n}\n\nexport class H264NaluAVC1 {\n type: H264NaluType;\n data: Uint8Array;\n\n constructor(nalu: H264NaluPayload) {\n let nalu_size = nalu.data.byteLength;\n\n this.type = nalu.type;\n this.data = new Uint8Array(4 + nalu_size); // 4 byte length-header + nalu payload\n\n let v = new DataView(this.data.buffer);\n // Fill 4 byte length-header\n v.setUint32(0, nalu_size);\n // Copy payload\n this.data.set(nalu.data, 4);\n }\n}\n\nexport class H264AnnexBParser {\n\n private readonly TAG: string = \"H264AnnexBParser\";\n\n private data_: Uint8Array;\n private current_startcode_offset_: number = 0;\n private eof_flag_: boolean = false;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_startcode_offset_ = this.findNextStartCodeOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, \"Could not find H264 startcode until payload end!\");\n }\n }\n\n private findNextStartCodeOffset(start_offset: number) {\n let i = start_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 3 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 00 00 00 01 or 00 00 01\n let uint32 = (data[i + 0] << 24)\n | (data[i + 1] << 16)\n | (data[i + 2] << 8)\n | (data[i + 3]);\n let uint24 = (data[i + 0] << 16)\n | (data[i + 1] << 8)\n | (data[i + 2]);\n if (uint32 === 0x00000001 || uint24 === 0x000001) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextNaluPayload(): H264NaluPayload | null {\n let data = this.data_;\n let nalu_payload: H264NaluPayload = null;\n\n while (nalu_payload == null) {\n if (this.eof_flag_) {\n break;\n }\n // offset pointed to start code\n let startcode_offset = this.current_startcode_offset_;\n\n // nalu payload start offset\n let offset = startcode_offset;\n let u32 = (data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | (data[offset + 3]);\n if (u32 === 0x00000001) {\n offset += 4;\n } else {\n offset += 3;\n }\n\n let nalu_type: H264NaluType = data[offset] & 0x1F;\n let forbidden_bit = (data[offset] & 0x80) >>> 7;\n\n let next_startcode_offset = this.findNextStartCodeOffset(offset);\n this.current_startcode_offset_ = next_startcode_offset;\n\n if (nalu_type >= H264NaluType.kReserved0) {\n continue;\n }\n if (forbidden_bit !== 0) {\n // Log.e(this.TAG, `forbidden_bit near offset ${offset} should be 0 but has value ${forbidden_bit}`);\n continue;\n }\n\n let payload_data = data.subarray(offset, next_startcode_offset);\n\n nalu_payload = new H264NaluPayload();\n nalu_payload.type = nalu_type;\n nalu_payload.data = payload_data;\n }\n\n return nalu_payload;\n }\n\n}\n\n\nexport class AVCDecoderConfigurationRecord {\n\n private data: Uint8Array;\n\n // sps, pps: require Nalu without 4 byte length-header\n public constructor(sps: Uint8Array, pps: Uint8Array, sps_details: any) {\n let length = 6 + 2 + sps.byteLength + 1 + 2 + pps.byteLength;\n let need_extra_fields = false;\n\n if (sps[3] !== 66 && sps[3] !== 77 && sps[3] !== 88) {\n need_extra_fields = true;\n length += 4;\n }\n\n let data = this.data = new Uint8Array(length);\n\n data[0] = 0x01; // configurationVersion\n data[1] = sps[1]; // AVCProfileIndication\n data[2] = sps[2]; // profile_compatibility\n data[3] = sps[3]; // AVCLevelIndication\n data[4] = 0xFF; // 111111 + lengthSizeMinusOne(3)\n\n data[5] = 0xE0 | 0x01 // 111 + numOfSequenceParameterSets\n\n let sps_length = sps.byteLength;\n data[6] = sps_length >>> 8; // sequenceParameterSetLength\n data[7] = sps_length & 0xFF;\n\n let offset = 8;\n data.set(sps, 8);\n offset += sps_length;\n\n data[offset] = 1; // numOfPictureParameterSets\n\n let pps_length = pps.byteLength;\n data[offset + 1] = pps_length >>> 8; // pictureParameterSetLength\n data[offset + 2] = pps_length & 0xFF;\n\n data.set(pps, offset + 3);\n offset += 3 + pps_length;\n\n if (need_extra_fields) {\n data[offset] = 0xFC | sps_details.chroma_format_idc;\n data[offset + 1] = 0xF8 | (sps_details.bit_depth_luma - 8);\n data[offset + 2] = 0xF8 | (sps_details.bit_depth_chroma - 8);\n data[offset + 3] = 0x00; // number of sps ext\n offset += 4;\n }\n }\n\n public getData() {\n return this.data;\n }\n\n}\n","export enum MPEG4AudioObjectTypes {\n kNull = 0,\n kAACMain,\n kAAC_LC, // LC-AAC\n kAAC_SSR,\n kAAC_LTP,\n kAAC_SBR, // HE-AAC\n kAAC_Scalable,\n\n kLayer1 = 32,\n kLayer2,\n kLayer3, // MP3\n}\n\nexport enum MPEG4SamplingFrequencyIndex {\n k96000Hz = 0,\n k88200Hz,\n k64000Hz,\n k48000Hz,\n k44100Hz,\n k32000Hz,\n k24000Hz,\n k22050Hz,\n k16000Hz,\n k12000Hz,\n k11025Hz,\n k8000Hz,\n k7350Hz,\n}\n\nexport const MPEG4SamplingFrequencies = [\n 96000,\n 88200,\n 64000,\n 48000,\n 44100,\n 32000,\n 24000,\n 22050,\n 16000,\n 12000,\n 11025,\n 8000,\n 7350,\n];\n","import ExpGolomb from './exp-golomb.js';\n\nexport type SCTE35Data = {\n splice_command_type: SCTE35CommandType.kSpliceInsert\n pts?: number,\n nearest_pts?: number\n auto_return?: boolean\n duraiton?: number,\n detail: SCTE35Detail\n data: Uint8Array\n} | {\n splice_command_type: SCTE35CommandType.kTimeSignal\n pts?: number,\n nearest_pts?: number\n detail: SCTE35Detail\n data: Uint8Array\n} | {\n splice_command_type: SCTE35CommandType.kSpliceNull | SCTE35CommandType.kBandwidthReservation | SCTE35CommandType.kSpliceSchedule | SCTE35CommandType.kPrivateCommand\n pts: undefined,\n nearest_pts?: number\n detail: SCTE35Detail\n data: Uint8Array\n}\n\ntype SCTE35Detail = {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kSpliceNull\n splice_command: SpliceNull\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kSpliceSchedule\n splice_command: SpliceSchedule\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kSpliceInsert\n splice_command: SpliceInsert\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kTimeSignal\n splice_command: TimeSignal\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kBandwidthReservation\n splice_command: BandwidthReservation\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kPrivateCommand\n splice_command: PrivateCommand\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[],\n E_CRC32?: number\n CRC32: number\n};\n\nexport enum SCTE35CommandType {\n kSpliceNull = 0x0,\n kSpliceSchedule = 0x4,\n kSpliceInsert = 0x5,\n kTimeSignal = 0x6,\n kBandwidthReservation = 0x07,\n kPrivateCommand = 0xff\n}\n\ntype SpliceTime = {\n time_specified_flag: boolean,\n pts_time?: number\n}\n\nconst parseSpliceTime = (reader: ExpGolomb): SpliceTime => {\n const time_specified_flag = reader.readBool()\n\n if (!time_specified_flag) {\n reader.readBits(7);\n return { time_specified_flag }\n } else {\n reader.readBits(6)\n const pts_time = reader.readBits(31) * 4 + reader.readBits(2);\n return {\n time_specified_flag,\n pts_time\n }\n }\n}\n\ntype BreakDuration = {\n auto_return: boolean,\n duration: number\n}\nconst parseBreakDuration = (reader: ExpGolomb): BreakDuration => {\n const auto_return = reader.readBool();\n reader.readBits(6);\n const duration = reader.readBits(31) * 4 + reader.readBits(2);\n return {\n auto_return,\n duration\n };\n}\n\ntype SpliceInsertComponent = {\n component_tag: number,\n splice_time?: SpliceTime\n}\nconst parseSpliceInsertComponent = (splice_immediate_flag: boolean, reader: ExpGolomb): SpliceInsertComponent => {\n const component_tag = reader.readBits(8);\n if (splice_immediate_flag) {\n return { component_tag };\n }\n\n const splice_time = parseSpliceTime(reader);\n return {\n component_tag,\n splice_time\n };\n}\ntype SpliceScheduleEventComponent = {\n component_tag: number,\n utc_splice_time: number\n}\nconst parseSpliceScheduleEventComponent = (reader: ExpGolomb): SpliceScheduleEventComponent => {\n const component_tag = reader.readBits(8);\n const utc_splice_time = reader.readBits(32);\n return {\n component_tag,\n utc_splice_time\n };\n}\n\ntype SpliceScheduleEvent = {\n splice_event_id: number,\n splice_event_cancel_indicator: boolean,\n out_of_network_indicator?: boolean,\n program_splice_flag?: boolean,\n duration_flag?: boolean,\n utc_splice_time?: number,\n component_count?: number,\n components?: SpliceScheduleEventComponent[]\n break_duration?: BreakDuration,\n unique_program_id?: number\n avail_num?: number,\n avails_expected?: number\n}\nconst parseSpliceScheduleEvent = (reader: ExpGolomb): SpliceScheduleEvent => {\n const splice_event_id = reader.readBits(32);\n const splice_event_cancel_indicator = reader.readBool();\n reader.readBits(7);\n\n const spliceScheduleEvent: SpliceScheduleEvent = {\n splice_event_id,\n splice_event_cancel_indicator\n }\n\n if (splice_event_cancel_indicator) {\n return spliceScheduleEvent;\n }\n\n spliceScheduleEvent.out_of_network_indicator = reader.readBool()\n spliceScheduleEvent.program_splice_flag = reader.readBool()\n spliceScheduleEvent.duration_flag = reader.readBool()\n reader.readBits(5)\n\n if (spliceScheduleEvent.program_splice_flag) {\n spliceScheduleEvent.utc_splice_time = reader.readBits(32);\n } else {\n spliceScheduleEvent.component_count = reader.readBits(8);\n spliceScheduleEvent.components = [];\n for (let i = 0; i < spliceScheduleEvent.component_count; i++) {\n spliceScheduleEvent.components.push(parseSpliceScheduleEventComponent(reader));\n }\n }\n\n if (spliceScheduleEvent.duration_flag) {\n spliceScheduleEvent.break_duration = parseBreakDuration(reader);\n }\n\n spliceScheduleEvent.unique_program_id = reader.readBits(16);\n spliceScheduleEvent.avail_num = reader.readBits(8);\n spliceScheduleEvent.avails_expected = reader.readBits(8);\n\n return spliceScheduleEvent;\n}\n\ntype SpliceNull = {}\ntype SpliceSchedule = {\n splice_count: number,\n events: SpliceScheduleEvent[],\n}\ntype SpliceInsert = {\n splice_event_id: number,\n splice_event_cancel_indicator: boolean,\n out_of_network_indicator?: boolean,\n program_splice_flag?: boolean,\n duration_flag?: boolean,\n splice_immediate_flag?: boolean,\n splice_time?: SpliceTime,\n component_count?: number,\n components?: SpliceInsertComponent[],\n break_duration?: BreakDuration,\n unique_program_id?: number,\n avail_num?: number,\n avails_expected?: number\n}\ntype TimeSignal = {\n splice_time: SpliceTime\n}\ntype BandwidthReservation = {}\ntype PrivateCommand = {\n identifier: string,\n private_data: ArrayBuffer\n}\n\ntype SpliceCommand = SpliceNull | SpliceSchedule | SpliceInsert | TimeSignal | BandwidthReservation | PrivateCommand\n\nconst parseSpliceNull = (): SpliceNull => {\n return {};\n};\nconst parseSpliceSchedule = (reader: ExpGolomb): SpliceSchedule => {\n const splice_count = reader.readBits(8)\n const events: SpliceScheduleEvent[] = [];\n for (let i = 0; i < splice_count; i++) {\n events.push(parseSpliceScheduleEvent(reader));\n }\n return {\n splice_count,\n events\n };\n}\nconst parseSpliceInsert = (reader: ExpGolomb): SpliceInsert => {\n const splice_event_id = reader.readBits(32);\n const splice_event_cancel_indicator = reader.readBool();\n reader.readBits(7);\n\n const spliceInsert: SpliceInsert = {\n splice_event_id,\n splice_event_cancel_indicator\n }\n\n if (splice_event_cancel_indicator) {\n return spliceInsert;\n }\n\n spliceInsert.out_of_network_indicator = reader.readBool()\n spliceInsert.program_splice_flag = reader.readBool()\n spliceInsert.duration_flag = reader.readBool()\n spliceInsert.splice_immediate_flag = reader.readBool()\n reader.readBits(4)\n\n if (spliceInsert.program_splice_flag && !spliceInsert.splice_immediate_flag) {\n spliceInsert.splice_time = parseSpliceTime(reader);\n }\n if (!spliceInsert.program_splice_flag) {\n spliceInsert.component_count = reader.readBits(8)\n spliceInsert.components = [];\n for (let i = 0; i < spliceInsert.component_count; i++) {\n spliceInsert.components.push(parseSpliceInsertComponent(spliceInsert.splice_immediate_flag, reader));\n }\n }\n\n if (spliceInsert.duration_flag) {\n spliceInsert.break_duration = parseBreakDuration(reader);\n }\n\n spliceInsert.unique_program_id = reader.readBits(16);\n spliceInsert.avail_num = reader.readBits(8);\n spliceInsert.avails_expected = reader.readBits(8);\n\n return spliceInsert;\n}\nconst parseTimeSignal = (reader: ExpGolomb): TimeSignal => {\n return {\n splice_time: parseSpliceTime(reader)\n };\n}\nconst parseBandwidthReservation = (): BandwidthReservation => {\n return {};\n}\nconst parsePrivateCommand = (splice_command_length: number, reader: ExpGolomb): PrivateCommand => {\n const identifier = String.fromCharCode(reader.readBits(8), reader.readBits(8), reader.readBits(8), reader.readBits(8))\n const data = new Uint8Array(splice_command_length - 4);\n for (let i = 0; i < splice_command_length - 4; i++) {\n data[i] = reader.readBits(8);\n }\n\n return {\n identifier,\n private_data: data.buffer\n }\n}\n\ntype Descriptor = {\n descriptor_tag: number,\n descriptor_length: number,\n identifier: string\n}\ntype AvailDescriptor = Descriptor & {\n provider_avail_id: number\n}\nconst parseAvailDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): AvailDescriptor => {\n const provider_avail_id = reader.readBits(32);\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n provider_avail_id\n }\n}\ntype DTMFDescriptor = Descriptor & {\n preroll: number,\n dtmf_count: number,\n DTMF_char: string\n}\nconst parseDTMFDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): DTMFDescriptor => {\n const preroll = reader.readBits(8);\n const dtmf_count = reader.readBits(3);\n reader.readBits(5);\n let DTMF_char = '';\n for (let i = 0; i < dtmf_count; i++) {\n DTMF_char += String.fromCharCode(reader.readBits(8));\n }\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n preroll,\n dtmf_count,\n DTMF_char\n };\n}\ntype SegmentationDescriptorComponent = {\n component_tag: number,\n pts_offset: number\n}\nconst parseSegmentationDescriptorComponent = (reader: ExpGolomb): SegmentationDescriptorComponent => {\n const component_tag = reader.readBits(8);\n reader.readBits(7)\n const pts_offset = reader.readBits(31) * 4 + reader.readBits(2);\n return {\n component_tag,\n pts_offset\n };\n}\ntype SegmentationDescriptor = Descriptor & {\n segmentation_event_id: number,\n segmentation_event_cancel_indicator: boolean,\n program_segmentation_flag?: boolean,\n segmentation_duration_flag?: boolean\n delivery_not_restricted_flag?: boolean\n web_delivery_allowed_flag?: boolean\n no_regional_blackout_flag?: boolean,\n archive_allowed_flag?: boolean,\n device_restrictions?: number\n component_count?: number,\n components?: any[]\n segmentation_duration?: number\n segmentation_upid_type?: number,\n segmentation_upid_length?: number,\n segmentation_upid?: ArrayBuffer,\n segmentation_type_id?: number,\n segment_num?: number,\n segments_expected?: number,\n sub_segment_num?: number,\n sub_segments_expected?: number\n}\nconst parseSegmentationDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): SegmentationDescriptor => {\n const segmentation_event_id = reader.readBits(32);\n const segmentation_event_cancel_indicator = reader.readBool();\n reader.readBits(7);\n\n const segmentationDescriptor: SegmentationDescriptor = {\n descriptor_tag,\n descriptor_length,\n identifier,\n segmentation_event_id,\n segmentation_event_cancel_indicator\n }\n\n if (segmentation_event_cancel_indicator) {\n return segmentationDescriptor;\n }\n\n segmentationDescriptor.program_segmentation_flag = reader.readBool();\n segmentationDescriptor.segmentation_duration_flag = reader.readBool();\n segmentationDescriptor.delivery_not_restricted_flag = reader.readBool();\n\n if (!segmentationDescriptor.delivery_not_restricted_flag) {\n segmentationDescriptor.web_delivery_allowed_flag = reader.readBool();\n segmentationDescriptor.no_regional_blackout_flag = reader.readBool();\n segmentationDescriptor.archive_allowed_flag = reader.readBool();\n segmentationDescriptor.device_restrictions = reader.readBits(2);\n } else {\n reader.readBits(5);\n }\n\n if (!segmentationDescriptor.program_segmentation_flag) {\n segmentationDescriptor.component_count = reader.readBits(8);\n segmentationDescriptor.components = [];\n for (let i = 0; i < segmentationDescriptor.component_count; i++) {\n segmentationDescriptor.components.push(parseSegmentationDescriptorComponent(reader));\n }\n }\n\n if (segmentationDescriptor.segmentation_duration_flag) {\n segmentationDescriptor.segmentation_duration = reader.readBits(40);\n }\n\n segmentationDescriptor.segmentation_upid_type = reader.readBits(8);\n segmentationDescriptor.segmentation_upid_length = reader.readBits(8);\n {\n const upid = new Uint8Array(segmentationDescriptor.segmentation_upid_length)\n for (let i = 0; i < segmentationDescriptor.segmentation_upid_length; i++) {\n upid[i] = reader.readBits(8);\n }\n segmentationDescriptor.segmentation_upid = upid.buffer;\n }\n segmentationDescriptor.segmentation_type_id = reader.readBits(8);\n segmentationDescriptor.segment_num = reader.readBits(8);\n segmentationDescriptor.segments_expected = reader.readBits(8);\n if (\n segmentationDescriptor.segmentation_type_id === 0x34 ||\n segmentationDescriptor.segmentation_type_id === 0x36 ||\n segmentationDescriptor.segmentation_type_id === 0x38 ||\n segmentationDescriptor.segmentation_type_id === 0x3A\n ) {\n segmentationDescriptor.sub_segment_num = reader.readBits(8);\n segmentationDescriptor.sub_segments_expected = reader.readBits(8);\n }\n\n return segmentationDescriptor;\n}\ntype TimeDescriptor = Descriptor & {\n TAI_seconds: number,\n TAI_ns: number,\n UTC_offset: number\n}\nconst parseTimeDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): TimeDescriptor => {\n const TAI_seconds = reader.readBits(48);\n const TAI_ns = reader.readBits(32);\n const UTC_offset = reader.readBits(16);\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n TAI_seconds,\n TAI_ns,\n UTC_offset\n };\n}\ntype AudioDescriptorComponent = {\n component_tag: number,\n ISO_code: string\n Bit_Stream_Mode: number\n Num_Channels: number,\n Full_Srvc_Audio: boolean\n}\nconst parseAudioDescriptorComponent = (reader: ExpGolomb): AudioDescriptorComponent => {\n const component_tag = reader.readBits(8)\n const ISO_code = String.fromCharCode(reader.readBits(8), reader.readBits(8), reader.readBits(8));\n const Bit_Stream_Mode = reader.readBits(3);\n const Num_Channels = reader.readBits(4);\n const Full_Srvc_Audio = reader.readBool();\n\n return {\n component_tag,\n ISO_code,\n Bit_Stream_Mode,\n Num_Channels,\n Full_Srvc_Audio\n };\n}\ntype AudioDescriptor = Descriptor & {\n audio_count: number,\n components: AudioDescriptorComponent[]\n}\nconst parseAudioDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): AudioDescriptor => {\n const audio_count = reader.readBits(4);\n const components: AudioDescriptorComponent[] = [];\n for (let i = 0; i < audio_count; i++) {\n components.push(parseAudioDescriptorComponent(reader));\n }\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n audio_count,\n components\n };\n}\n\ntype SpliceDescriptor = AvailDescriptor | DTMFDescriptor | SegmentationDescriptor | TimeDescriptor | AudioDescriptor;\n\nexport const readSCTE35 = (data: Uint8Array): SCTE35Data => {\n const reader = new ExpGolomb(data);\n\n const table_id = reader.readBits(8);\n const section_syntax_indicator = reader.readBool();\n const private_indicator = reader.readBool();\n reader.readBits(2);\n const section_length = reader.readBits(12);\n const protocol_version = reader.readBits(8);\n const encrypted_packet = reader.readBool();\n const encryption_algorithm = reader.readBits(6);\n const pts_adjustment = reader.readBits(31) * 4 + reader.readBits(2);\n const cw_index = reader.readBits(8);\n const tier = reader.readBits(12);\n const splice_command_length = reader.readBits(12)\n const splice_command_type = reader.readBits(8)\n\n let splice_command: SpliceCommand | null = null;\n if (splice_command_type === SCTE35CommandType.kSpliceNull) {\n splice_command = parseSpliceNull();\n } else if (splice_command_type === SCTE35CommandType.kSpliceSchedule) {\n splice_command = parseSpliceSchedule(reader);\n } else if (splice_command_type === SCTE35CommandType.kSpliceInsert) {\n splice_command = parseSpliceInsert(reader);\n } else if (splice_command_type === SCTE35CommandType.kTimeSignal) {\n splice_command = parseTimeSignal(reader);\n } else if (splice_command_type === SCTE35CommandType.kBandwidthReservation) {\n splice_command = parseBandwidthReservation();\n } else if (splice_command_type === SCTE35CommandType.kPrivateCommand) {\n splice_command = parsePrivateCommand(splice_command_length, reader)\n } else {\n reader.readBits(splice_command_length * 8);\n }\n\n const splice_descriptors: SpliceDescriptor[] = [];\n\n const descriptor_loop_length = reader.readBits(16);\n for (let length = 0; length < descriptor_loop_length;) {\n const descriptor_tag = reader.readBits(8);\n const descriptor_length = reader.readBits(8);\n const identifier = String.fromCharCode(reader.readBits(8), reader.readBits(8), reader.readBits(8), reader.readBits(8));\n\n if (descriptor_tag === 0x00) {\n splice_descriptors.push(parseAvailDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x01) {\n splice_descriptors.push(parseDTMFDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x02) {\n splice_descriptors.push(parseSegmentationDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x03) {\n splice_descriptors.push(parseTimeDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x04) {\n splice_descriptors.push(parseAudioDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else {\n reader.readBits((descriptor_length - 4) * 8);\n }\n\n length += 2 + descriptor_length;\n }\n\n const E_CRC32 = encrypted_packet ? reader.readBits(32) : undefined;\n const CRC32 = reader.readBits(32);\n\n const detail = {\n table_id,\n section_syntax_indicator,\n private_indicator,\n section_length,\n protocol_version,\n encrypted_packet,\n encryption_algorithm,\n pts_adjustment,\n cw_index,\n tier,\n splice_command_length,\n splice_command_type,\n splice_command,\n descriptor_loop_length,\n splice_descriptors,\n E_CRC32,\n CRC32\n };\n\n if (splice_command_type === SCTE35CommandType.kSpliceInsert) {\n const spliceInsert = splice_command as SpliceInsert;\n\n if (spliceInsert.splice_event_cancel_indicator) {\n return {\n splice_command_type,\n detail,\n data\n }\n } else if (spliceInsert.program_splice_flag && !spliceInsert.splice_immediate_flag) {\n const auto_return = spliceInsert.duration_flag ? spliceInsert.break_duration.auto_return : undefined;\n const duraiton = spliceInsert.duration_flag ? spliceInsert.break_duration.duration / 90 : undefined;\n\n if (spliceInsert.splice_time.time_specified_flag) {\n return {\n splice_command_type,\n pts: (pts_adjustment + spliceInsert.splice_time.pts_time) % (2 ** 33),\n auto_return,\n duraiton,\n detail,\n data\n }\n } else {\n return {\n splice_command_type,\n auto_return,\n duraiton,\n detail,\n data\n } \n }\n } else {\n const auto_return = spliceInsert.duration_flag ? spliceInsert.break_duration.auto_return : undefined;\n const duraiton = spliceInsert.duration_flag ? spliceInsert.break_duration.duration / 90 : undefined;\n\n return {\n splice_command_type,\n auto_return,\n duraiton,\n detail,\n data\n }\n }\n } else if (splice_command_type === SCTE35CommandType.kTimeSignal) {\n const timeSignal = splice_command as TimeSignal;\n\n if (timeSignal.splice_time.time_specified_flag) {\n return {\n splice_command_type,\n pts: (pts_adjustment + timeSignal.splice_time.pts_time) % (2 ** 33),\n detail,\n data\n }\n } else {\n return {\n splice_command_type,\n detail,\n data\n }\n }\n } else {\n return {\n splice_command_type,\n detail,\n data\n }\n }\n}","import Log from \"../utils/logger\";\nimport { MPEG4AudioObjectTypes, MPEG4SamplingFrequencies, MPEG4SamplingFrequencyIndex } from \"./mpeg4-audio\";\n\nexport class AACFrame {\n audio_object_type: MPEG4AudioObjectTypes;\n sampling_freq_index: MPEG4SamplingFrequencyIndex;\n sampling_frequency: number;\n channel_config: number;\n\n data: Uint8Array;\n}\n\nexport class AACADTSParser {\n\n private readonly TAG: string = \"AACADTSParser\";\n\n private data_: Uint8Array;\n private current_syncword_offset_: number;\n private eof_flag_: boolean;\n private has_last_incomplete_data: boolean;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_syncword_offset_ = this.findNextSyncwordOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, `Could not found ADTS syncword until payload end`);\n }\n }\n\n private findNextSyncwordOffset(syncword_offset: number): number {\n let i = syncword_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 7 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 12-bit 0xFFF syncword\n let syncword = ((data[i + 0] << 8) | data[i + 1]) >>> 4;\n if (syncword === 0xFFF) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextAACFrame(): AACFrame | null {\n let data = this.data_;\n let aac_frame: AACFrame = null;\n\n while (aac_frame == null) {\n if (this.eof_flag_) {\n break;\n }\n\n let syncword_offset = this.current_syncword_offset_;\n let offset = syncword_offset;\n\n // adts_fixed_header()\n // syncword 0xFFF: 12-bit\n let ID = (data[offset + 1] & 0x08) >>> 3;\n let layer = (data[offset + 1] & 0x06) >>> 1;\n let protection_absent = data[offset + 1] & 0x01;\n let profile = (data[offset + 2] & 0xC0) >>> 6;\n let sampling_frequency_index = (data[offset + 2] & 0x3C) >>> 2;\n let channel_configuration = ((data[offset + 2] & 0x01) << 2)\n | ((data[offset + 3] & 0xC0) >>> 6);\n\n // adts_variable_header()\n let aac_frame_length = ((data[offset + 3] & 0x03) << 11)\n | (data[offset + 4] << 3)\n | ((data[offset + 5] & 0xE0) >>> 5);\n let number_of_raw_data_blocks_in_frame = data[offset + 6] & 0x03;\n\n if (offset + aac_frame_length > this.data_.byteLength) {\n // data not enough for extracting last sample\n this.eof_flag_ = true;\n this.has_last_incomplete_data = true;\n break;\n }\n\n let adts_header_length = (protection_absent === 1) ? 7 : 9;\n let adts_frame_payload_length = aac_frame_length - adts_header_length;\n\n offset += adts_header_length;\n\n let next_syncword_offset = this.findNextSyncwordOffset(offset + adts_frame_payload_length);\n this.current_syncword_offset_ = next_syncword_offset;\n\n if ((ID !== 0 && ID !== 1) || layer !== 0) {\n // invalid adts frame ?\n continue;\n }\n\n let frame_data = data.subarray(offset, offset + adts_frame_payload_length);\n\n aac_frame = new AACFrame();\n aac_frame.audio_object_type = (profile + 1) as MPEG4AudioObjectTypes;\n aac_frame.sampling_freq_index = sampling_frequency_index as MPEG4SamplingFrequencyIndex;\n aac_frame.sampling_frequency = MPEG4SamplingFrequencies[sampling_frequency_index];\n aac_frame.channel_config = channel_configuration;\n aac_frame.data = frame_data;\n }\n\n return aac_frame;\n }\n\n public hasIncompleteData(): boolean {\n return this.has_last_incomplete_data;\n }\n\n public getIncompleteData(): Uint8Array {\n if (!this.has_last_incomplete_data) {\n return null;\n }\n\n return this.data_.subarray(this.current_syncword_offset_);\n }\n}\n\nexport class AudioSpecificConfig {\n\n public config: Array;\n public sampling_rate: number;\n public channel_count: number;\n public codec_mimetype: string;\n public original_codec_mimetype: string;\n\n public constructor(frame: AACFrame) {\n let config: Array = null;\n\n let original_audio_object_type = frame.audio_object_type;\n let audio_object_type = frame.audio_object_type;\n let sampling_index = frame.sampling_freq_index;\n let channel_config = frame.channel_config;\n let extension_sampling_index = 0;\n\n let userAgent = navigator.userAgent.toLowerCase();\n\n if (userAgent.indexOf('firefox') !== -1) {\n // firefox: use SBR (HE-AAC) if freq less than 24kHz\n if (sampling_index >= 6) {\n audio_object_type = 5;\n config = new Array(4);\n extension_sampling_index = sampling_index - 3;\n } else { // use LC-AAC\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n }\n } else if (userAgent.indexOf('android') !== -1) {\n // android: always use LC-AAC\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n } else {\n // for other browsers, e.g. chrome...\n // Always use HE-AAC to make it easier to switch aac codec profile\n audio_object_type = 5;\n extension_sampling_index = sampling_index;\n config = new Array(4);\n\n if (sampling_index >= 6) {\n extension_sampling_index = sampling_index - 3;\n } else if (channel_config === 1) { // Mono channel\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n }\n }\n\n config[0] = audio_object_type << 3;\n config[0] |= (sampling_index & 0x0F) >>> 1;\n config[1] = (sampling_index & 0x0F) << 7;\n config[1] |= (channel_config & 0x0F) << 3;\n if (audio_object_type === 5) {\n config[1] |= ((extension_sampling_index & 0x0F) >>> 1);\n config[2] = (extension_sampling_index & 0x01) << 7;\n // extended audio object type: force to 2 (LC-AAC)\n config[2] |= (2 << 2);\n config[3] = 0;\n }\n\n this.config = config;\n this.sampling_rate = MPEG4SamplingFrequencies[sampling_index];\n this.channel_count = channel_config;\n this.codec_mimetype = 'mp4a.40.' + audio_object_type;\n this.original_codec_mimetype = 'mp4a.40.' + original_audio_object_type;\n }\n\n}\n","// ISO/IEC 13818-1 PES packets containing private data (stream_type=0x06)\nexport class PESPrivateData {\n pid: number;\n stream_id: number;\n pts?: number;\n dts?: number;\n nearest_pts?: number;\n data: Uint8Array;\n len: number;\n}\n\nexport class PESPrivateDataDescriptor {\n pid: number;\n stream_type: number;\n descriptor: Uint8Array;\n}\n","import Log from \"../utils/logger\";\n\nexport enum H265NaluType {\n kSliceIDR_W_RADL = 19,\n kSliceIDR_N_LP = 20,\n kSliceVPS = 32,\n kSliceSPS = 33,\n kSlicePPS = 34,\n kSliceAUD = 35,\n}\n\nexport class H265NaluPayload {\n type: H265NaluType;\n data: Uint8Array;\n}\n\nexport class H265NaluHVC1 {\n type: H265NaluType;\n data: Uint8Array;\n\n constructor(nalu: H265NaluPayload) {\n let nalu_size = nalu.data.byteLength;\n\n this.type = nalu.type;\n this.data = new Uint8Array(4 + nalu_size); // 4 byte length-header + nalu payload\n\n let v = new DataView(this.data.buffer);\n // Fill 4 byte length-header\n v.setUint32(0, nalu_size);\n // Copy payload\n this.data.set(nalu.data, 4);\n }\n}\n\nexport class H265AnnexBParser {\n\n private readonly TAG: string = \"H265AnnexBParser\";\n\n private data_: Uint8Array;\n private current_startcode_offset_: number = 0;\n private eof_flag_: boolean = false;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_startcode_offset_ = this.findNextStartCodeOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, \"Could not find H265 startcode until payload end!\");\n }\n }\n\n private findNextStartCodeOffset(start_offset: number) {\n let i = start_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 3 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 00 00 00 01 or 00 00 01\n let uint32 = (data[i + 0] << 24)\n | (data[i + 1] << 16)\n | (data[i + 2] << 8)\n | (data[i + 3]);\n let uint24 = (data[i + 0] << 16)\n | (data[i + 1] << 8)\n | (data[i + 2]);\n if (uint32 === 0x00000001 || uint24 === 0x000001) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextNaluPayload(): H265NaluPayload | null {\n let data = this.data_;\n let nalu_payload: H265NaluPayload = null;\n\n while (nalu_payload == null) {\n if (this.eof_flag_) {\n break;\n }\n // offset pointed to start code\n let startcode_offset = this.current_startcode_offset_;\n\n // nalu payload start offset\n let offset = startcode_offset;\n let u32 = (data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | (data[offset + 3]);\n if (u32 === 0x00000001) {\n offset += 4;\n } else {\n offset += 3;\n }\n\n let nalu_type: H265NaluType = (data[offset] >> 1) & 0x3F;\n let forbidden_bit = (data[offset] & 0x80) >>> 7;\n\n let next_startcode_offset = this.findNextStartCodeOffset(offset);\n this.current_startcode_offset_ = next_startcode_offset;\n\n if (forbidden_bit !== 0) {\n // Log.e(this.TAG, `forbidden_bit near offset ${offset} should be 0 but has value ${forbidden_bit}`);\n continue;\n }\n\n let payload_data = data.subarray(offset, next_startcode_offset);\n\n nalu_payload = new H265NaluPayload();\n nalu_payload.type = nalu_type;\n nalu_payload.data = payload_data;\n }\n\n return nalu_payload;\n }\n\n}\n\nexport type HEVCDecoderConfigurationRecordType = {\n configurationVersion: 1;\n} & VPSHEVCDecoderConfigurationRecordType & SPSHEVCDecoderConfigurationRecordType & PPSHEVCDecoderConfigurationRecordType;\n\nexport type VPSHEVCDecoderConfigurationRecordType = {\n num_temporal_layers: number;\n temporal_id_nested: boolean;\n}\n\nexport type SPSHEVCDecoderConfigurationRecordType = {\n general_profile_space: number;\n general_tier_flag: number;\n general_profile_idc: number;\n general_profile_compatibility_flags_1: number;\n general_profile_compatibility_flags_2: number;\n general_profile_compatibility_flags_3: number;\n general_profile_compatibility_flags_4: number;\n general_constraint_indicator_flags_1: number;\n general_constraint_indicator_flags_2: number;\n general_constraint_indicator_flags_3: number;\n general_constraint_indicator_flags_4: number;\n general_constraint_indicator_flags_5: number;\n general_constraint_indicator_flags_6: number;\n constant_frame_rate: number;\n min_spatial_segmentation_idc: number;\n chroma_format_idc: number,\n bit_depth_luma_minus8: number,\n bit_depth_chroma_minus8: number,\n}\n\nexport type PPSHEVCDecoderConfigurationRecordType = {\n parallelismType: number;\n}\n\nexport class HEVCDecoderConfigurationRecord {\n\n private data: Uint8Array;\n\n // sps, pps: require Nalu without 4 byte length-header\n public constructor(vps: Uint8Array, sps: Uint8Array, pps: Uint8Array, detail: HEVCDecoderConfigurationRecordType) {\n let length = 23 + (3 + 2 + vps.byteLength) + (3 + 2 + sps.byteLength) + (3 + 2 + pps.byteLength);\n let data = this.data = new Uint8Array(length);\n\n data[0] = 0x01; // configurationVersion\n data[1] = ((detail.general_profile_space & 0x03) << 6) | ((detail.general_tier_flag ? 1 : 0) << 5) | ((detail.general_profile_idc & 0x1F));\n data[2] = detail.general_profile_compatibility_flags_1;\n data[3] = detail.general_profile_compatibility_flags_2;\n data[4] = detail.general_profile_compatibility_flags_3;\n data[5] = detail.general_profile_compatibility_flags_4;\n data[6] = detail.general_constraint_indicator_flags_1;\n data[7] = detail.general_constraint_indicator_flags_2;\n data[8] = detail.general_constraint_indicator_flags_3;\n data[9] = detail.general_constraint_indicator_flags_4;\n data[10] = detail.general_constraint_indicator_flags_5;\n data[11] = detail.general_constraint_indicator_flags_6;\n data[12] = 0x3C;\n data[13] = 0xF0 | ((detail.min_spatial_segmentation_idc & 0x0F00) >> 8)\n data[14] = (detail.min_spatial_segmentation_idc & 0xFF);\n data[15] = 0xFC | (detail.parallelismType & 0x03);\n data[16] = 0xFC | (detail.chroma_format_idc & 0x03);\n data[17] = 0xF8 | (detail.bit_depth_luma_minus8 & 0x07);\n data[18] = 0xF8 | (detail.bit_depth_chroma_minus8 & 0x07);\n data[19] = 0;\n data[20] = 0;\n data[21] = ((detail.constant_frame_rate & 0x03) << 6) | ((detail.num_temporal_layers & 0x07) << 3) | ((detail.temporal_id_nested ? 1 : 0) << 2) | 3;\n data[22] = 3;\n data[23 + 0 + 0] = 0x80 | H265NaluType.kSliceVPS;\n data[23 + 0 + 1] = 0;\n data[23 + 0 + 2] = 1;\n data[23 + 0 + 3] = (vps.byteLength & 0xFF00) >> 8;\n data[23 + 0 + 4] = (vps.byteLength & 0x00FF) >> 0;\n data.set(vps, 23 + 0 + 5);\n data[23 + (5 + vps.byteLength) + 0] = 0x80 | H265NaluType.kSliceSPS;\n data[23 + (5 + vps.byteLength) + 1] = 0;\n data[23 + (5 + vps.byteLength) + 2] = 1;\n data[23 + (5 + vps.byteLength) + 3] = (sps.byteLength & 0xFF00) >> 8;\n data[23 + (5 + vps.byteLength) + 4] = (sps.byteLength & 0x00FF) >> 0;\n data.set(sps, 23 + (5 + vps.byteLength) + 5);\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 0] = 0x80 | H265NaluType.kSlicePPS;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 1] = 0;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 2] = 1;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 3] = (pps.byteLength & 0xFF00) >> 8;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 4] = (pps.byteLength & 0x00FF) >> 0;\n data.set(pps, 23 + (5 + vps.byteLength + 5 + sps.byteLength) + 5);\n }\n\n public getData() {\n return this.data;\n }\n\n}\n","/*\n * Copyright (C) 2022 もにょてっく. All Rights Reserved.\n *\n * @author もにょ〜ん \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ExpGolomb from './exp-golomb.js';\n\nclass H265NaluParser {\n\n static _ebsp2rbsp(uint8array) {\n let src = uint8array;\n let src_length = src.byteLength;\n let dst = new Uint8Array(src_length);\n let dst_idx = 0;\n\n for (let i = 0; i < src_length; i++) {\n if (i >= 2) {\n // Unescape: Skip 0x03 after 00 00\n if (src[i] === 0x03 && src[i - 1] === 0x00 && src[i - 2] === 0x00) {\n continue;\n }\n }\n dst[dst_idx] = src[i];\n dst_idx++;\n }\n\n return new Uint8Array(dst.buffer, 0, dst_idx);\n }\n\n static parseVPS(uint8array) {\n let rbsp = H265NaluParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n /* remove NALu Header */\n gb.readByte();\n gb.readByte();\n\n // VPS\n let video_parameter_set_id = gb.readBits(4);\n gb.readBits(2);\n let max_layers_minus1 = gb.readBits(6);\n let max_sub_layers_minus1 = gb.readBits(3);\n let temporal_id_nesting_flag = gb.readBool();\n // and more ...\n\n return {\n num_temporal_layers: max_sub_layers_minus1 + 1,\n temporal_id_nested: temporal_id_nesting_flag\n }\n }\n\n static parseSPS(uint8array) {\n let rbsp = H265NaluParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n /* remove NALu Header */\n gb.readByte();\n gb.readByte();\n\n let left_offset = 0, right_offset = 0, top_offset = 0, bottom_offset = 0;\n\n // SPS\n let video_paramter_set_id = gb.readBits(4);\n let max_sub_layers_minus1 = gb.readBits(3);\n let temporal_id_nesting_flag = gb.readBool();\n\n // profile_tier_level begin\n let general_profile_space = gb.readBits(2);\n let general_tier_flag = gb.readBool();\n let general_profile_idc = gb.readBits(5);\n let general_profile_compatibility_flags_1 = gb.readByte();\n let general_profile_compatibility_flags_2 = gb.readByte();\n let general_profile_compatibility_flags_3 = gb.readByte();\n let general_profile_compatibility_flags_4 = gb.readByte();\n let general_constraint_indicator_flags_1 = gb.readByte();\n let general_constraint_indicator_flags_2 = gb.readByte();\n let general_constraint_indicator_flags_3 = gb.readByte();\n let general_constraint_indicator_flags_4 = gb.readByte();\n let general_constraint_indicator_flags_5 = gb.readByte();\n let general_constraint_indicator_flags_6 = gb.readByte();\n let general_level_idc = gb.readByte();\n let sub_layer_profile_present_flag = [];\n let sub_layer_level_present_flag = [];\n for (let i = 0; i < max_sub_layers_minus1; i++) {\n sub_layer_profile_present_flag.push(gb.readBool());\n sub_layer_level_present_flag.push(gb.readBool());\n }\n if (max_sub_layers_minus1 > 0) {\n for (let i = max_sub_layers_minus1; i < 8; i++) { gb.readBits(2); }\n }\n for (let i = 0; i < max_sub_layers_minus1; i++) {\n if (sub_layer_profile_present_flag[i]) {\n gb.readByte(); // sub_layer_profile_space, sub_layer_tier_flag, sub_layer_profile_idc\n gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte(); // sub_layer_profile_compatibility_flag\n gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte();\n }\n if (sub_layer_profile_present_flag[i]) {\n gb.readByte();\n }\n }\n // profile_tier_level end\n\n let seq_parameter_set_id = gb.readUEG();\n let chroma_format_idc = gb.readUEG();\n if (chroma_format_idc == 3) {\n gb.readBits(1); // separate_colour_plane_flag\n }\n let pic_width_in_luma_samples = gb.readUEG();\n let pic_height_in_luma_samples = gb.readUEG();\n let conformance_window_flag = gb.readBool();\n if (conformance_window_flag) {\n left_offset += gb.readUEG();\n right_offset += gb.readUEG();\n top_offset += gb.readUEG();\n bottom_offset += gb.readUEG();\n }\n let bit_depth_luma_minus8 = gb.readUEG();\n let bit_depth_chroma_minus8 = gb.readUEG();\n let log2_max_pic_order_cnt_lsb_minus4 = gb.readUEG();\n let sub_layer_ordering_info_present_flag = gb.readBool();\n for (let i = sub_layer_ordering_info_present_flag ? 0 : max_sub_layers_minus1; i <= max_sub_layers_minus1; i++) {\n gb.readUEG(); // max_dec_pic_buffering_minus1[i]\n gb.readUEG(); // max_num_reorder_pics[i]\n gb.readUEG(); // max_latency_increase_plus1[i]\n }\n let log2_min_luma_coding_block_size_minus3 = gb.readUEG();\n let log2_diff_max_min_luma_coding_block_size = gb.readUEG();\n let log2_min_transform_block_size_minus2 = gb.readUEG();\n let log2_diff_max_min_transform_block_size = gb.readUEG();\n let max_transform_hierarchy_depth_inter = gb.readUEG();\n let max_transform_hierarchy_depth_intra = gb.readUEG();\n let scaling_list_enabled_flag = gb.readBool();\n if (scaling_list_enabled_flag) {\n let sps_scaling_list_data_present_flag = gb.readBool();\n if (sps_scaling_list_data_present_flag) {\n for (let sizeId = 0; sizeId < 4; sizeId++) {\n for(let matrixId = 0; matrixId < ((sizeId === 3) ? 2 : 6); matrixId++){\n let scaling_list_pred_mode_flag = gb.readBool();\n if (!scaling_list_pred_mode_flag) {\n gb.readUEG(); // scaling_list_pred_matrix_id_delta\n } else {\n let coefNum = Math.min(64, (1 << (4 + (sizeId << 1))));\n if (sizeId > 1) { gb.readSEG() }\n for (let i = 0; i < coefNum; i++) { gb.readSEG(); }\n }\n }\n }\n }\n }\n let amp_enabled_flag = gb.readBool();\n let sample_adaptive_offset_enabled_flag = gb.readBool();\n let pcm_enabled_flag = gb.readBool();\n if (pcm_enabled_flag) {\n gb.readByte();\n gb.readUEG();\n gb.readUEG();\n gb.readBool();\n }\n let num_short_term_ref_pic_sets = gb.readUEG();\n let num_delta_pocs = 0;\n for (let i = 0; i < num_short_term_ref_pic_sets; i++) {\n let inter_ref_pic_set_prediction_flag = false;\n if (i !== 0) { inter_ref_pic_set_prediction_flag = gb.readBool(); }\n if (inter_ref_pic_set_prediction_flag) {\n if (i === num_short_term_ref_pic_sets) { gb.readUEG(); }\n gb.readBool();\n gb.readUEG();\n let next_num_delta_pocs = 0;\n for (let j = 0; j <= num_delta_pocs; j++) {\n let used_by_curr_pic_flag = gb.readBool();\n let use_delta_flag = false;\n if (!used_by_curr_pic_flag) {\n use_delta_flag = gb.readBool();\n }\n if (used_by_curr_pic_flag || use_delta_flag) {\n next_num_delta_pocs++;\n }\n }\n num_delta_pocs = next_num_delta_pocs;\n } else {\n let num_negative_pics = gb.readUEG();\n let num_positive_pics = gb.readUEG();\n num_delta_pocs = num_negative_pics + num_positive_pics;\n for (let j = 0; j < num_negative_pics; j++) {\n gb.readUEG();\n gb.readBool();\n }\n for (let j = 0; j < num_positive_pics; j++) {\n gb.readUEG();\n gb.readBool();\n }\n }\n }\n let long_term_ref_pics_present_flag = gb.readBool();\n if (long_term_ref_pics_present_flag) {\n let num_long_term_ref_pics_sps = gb.readUEG();\n for (let i = 0; i < num_long_term_ref_pics_sps; i++) {\n for (let j = 0; j < (log2_max_pic_order_cnt_lsb_minus4 + 4); j++) { gb.readBits(1); }\n gb.readBits(1);\n }\n }\n //*\n let default_display_window_flag = false; // for calc offset\n let min_spatial_segmentation_idc = 0; // for hvcC\n let sar_width = 1, sar_height = 1;\n let fps_fixed = false, fps_den = 1, fps_num = 1;\n //*/\n let sps_temporal_mvp_enabled_flag = gb.readBool();\n let strong_intra_smoothing_enabled_flag = gb.readBool();\n let vui_parameters_present_flag = gb.readBool();\n if (vui_parameters_present_flag) {\n let aspect_ratio_info_present_flag = gb.readBool();\n if (aspect_ratio_info_present_flag) {\n let aspect_ratio_idc = gb.readByte();\n\n let sar_w_table = [1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2];\n let sar_h_table = [1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1];\n\n if (aspect_ratio_idc > 0 && aspect_ratio_idc < 16) {\n sar_width = sar_w_table[aspect_ratio_idc - 1];\n sar_height = sar_h_table[aspect_ratio_idc - 1];\n } else if (aspect_ratio_idc === 255) {\n sar_width = gb.readBits(16);\n sar_height = gb.readBits(16);\n }\n }\n let overscan_info_present_flag = gb.readBool();\n if (overscan_info_present_flag) {\n gb.readBool();\n }\n let video_signal_type_present_flag = gb.readBool();\n if (video_signal_type_present_flag) {\n gb.readBits(3);\n gb.readBool();\n let colour_description_present_flag = gb.readBool();\n if (colour_description_present_flag) {\n gb.readByte();\n gb.readByte();\n gb.readByte();\n }\n }\n let chroma_loc_info_present_flag = gb.readBool();\n if (chroma_loc_info_present_flag) {\n gb.readUEG();\n gb.readUEG();\n }\n let neutral_chroma_indication_flag = gb.readBool();\n let field_seq_flag = gb.readBool();\n let frame_field_info_present_flag = gb.readBool();\n default_display_window_flag = gb.readBool();\n if (default_display_window_flag) {\n left_offset += gb.readUEG();\n right_offset += gb.readUEG();\n top_offset += gb.readUEG();\n bottom_offset += gb.readUEG();\n }\n let vui_timing_info_present_flag = gb.readBool();\n if (vui_timing_info_present_flag) {\n fps_den = gb.readBits(32);\n fps_num = gb.readBits(32);\n let vui_poc_proportional_to_timing_flag = gb.readBool();\n if (vui_poc_proportional_to_timing_flag) {\n gb.readUEG();\n let vui_hrd_parameters_present_flag = gb.readBool();\n if (vui_hrd_parameters_present_flag) {\n let commonInfPresentFlag = 1;\n let nal_hrd_parameters_present_flag = false;\n let vcl_hrd_parameters_present_flag = false;\n if (commonInfPresentFlag) {\n nal_hrd_parameters_present_flag = gb.readBool();\n vcl_hrd_parameters_present_flag = gb.readBool();\n if( nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag ){\n let sub_pic_hrd_params_present_flag = gb.readBool();\n if (sub_pic_hrd_params_present_flag) {\n gb.readByte();\n gb.readBits(5);\n gb.readBool();\n gb.readBits(5);\n }\n let bit_rate_scale = gb.readBits(4);\n let cpb_size_scale = gb.readBits(4);\n if (sub_pic_hrd_params_present_flag) {\n gb.readBits(4);\n }\n gb.readBits(5);\n gb.readBits(5);\n gb.readBits(5);\n }\n }\n for (let i = 0; i <= max_sub_layers_minus1; i++) {\n let fixed_pic_rate_general_flag = gb.readBool();\n fps_fixed = fixed_pic_rate_general_flag;\n let fixed_pic_rate_within_cvs_flag = false;\n let cpbCnt = 1;\n if (!fixed_pic_rate_general_flag) {\n fixed_pic_rate_within_cvs_flag = gb.readBool();\n }\n let low_delay_hrd_flag = false;\n if (fixed_pic_rate_within_cvs_flag) {\n gb.readSEG();\n } else {\n low_delay_hrd_flag = gb.readBool();\n }\n if (!low_delay_hrd_flag) {\n cpbcnt = gb.readUEG() + 1;\n }\n if (nal_hrd_parameters_present_flag) {\n for (let j = 0; j < cpbCnt; j++) {\n gb.readUEG(); gb.readUEG();\n if (sub_pic_hrd_params_present_flag) {\n gb.readUEG(); gb.readUEG();\n }\n }\n }\n if (vcl_hrd_parameters_present_flag) {\n for (let j = 0; j < cpbCnt; j++) {\n gb.readUEG(); gb.readUEG();\n if (sub_pic_hrd_params_present_flag) {\n gb.readUEG(); gb.readUEG();\n }\n }\n }\n }\n }\n }\n }\n let bitstream_restriction_flag = gb.readBool();\n if (bitstream_restriction_flag) {\n let tiles_fixed_structure_flag = gb.readBool()\n let motion_vectors_over_pic_boundaries_flag = gb.readBool()\n let restricted_ref_pic_lists_flag = gb.readBool();\n min_spatial_segmentation_idc = gb.readUEG();\n let max_bytes_per_pic_denom = gb.readUEG();\n let max_bits_per_min_cu_denom = gb.readUEG();\n let log2_max_mv_length_horizontal = gb.readUEG();\n let log2_max_mv_length_vertical = gb.readUEG();\n }\n }\n let sps_extension_flag = gb.readBool(); // ignore...\n\n // for meta data\n let codec_mimetype = `hvc1.${general_profile_idc}.1.L${general_level_idc}.B0`;\n let codec_width = pic_width_in_luma_samples;\n let codec_height = pic_height_in_luma_samples;\n let sar_scale = 1;\n if (sar_width !== 1 && sar_height !== 1) {\n sar_scale = sar_width / sar_height;\n }\n\n gb.destroy();\n gb = null;\n\n return {\n codec_mimetype,\n level_string: H265NaluParser.getLevelString(general_level_idc),\n profile_idc: general_profile_idc,\n bit_depth: bit_depth_luma_minus8 + 8,\n ref_frames: 1, // FIXME!!!\n chroma_format: chroma_format_idc,\n chroma_format_string: H265NaluParser.getChromaFormatString(chroma_format_idc),\n\n general_level_idc,\n general_profile_space,\n general_tier_flag,\n general_profile_idc,\n general_profile_compatibility_flags_1,\n general_profile_compatibility_flags_2,\n general_profile_compatibility_flags_3,\n general_profile_compatibility_flags_4,\n general_constraint_indicator_flags_1,\n general_constraint_indicator_flags_2,\n general_constraint_indicator_flags_3,\n general_constraint_indicator_flags_4,\n general_constraint_indicator_flags_5,\n general_constraint_indicator_flags_6,\n min_spatial_segmentation_idc,\n constant_frame_rate: 0 /* FIXME!! fps_fixed ? 1 : 0? */,\n chroma_format_idc,\n bit_depth_luma_minus8,\n bit_depth_chroma_minus8,\n\n frame_rate: {\n fixed: fps_fixed,\n fps: fps_num / fps_den,\n fps_den: fps_den,\n fps_num: fps_num,\n },\n\n sar_ratio: {\n width: sar_width,\n height: sar_height\n },\n\n codec_size: {\n width: codec_width,\n height: codec_height\n },\n\n present_size: {\n width: codec_width * sar_scale,\n height: codec_height\n }\n };\n }\n\n static parsePPS(uint8array) {\n let rbsp = H265NaluParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n /* remove NALu Header */\n gb.readByte();\n gb.readByte();\n\n let pic_parameter_set_id = gb.readUEG();\n let seq_parameter_set_id = gb.readUEG();\n let dependent_slice_segments_enabled_flag = gb.readBool();\n let output_flag_present_flag = gb.readBool();\n let num_extra_slice_header_bits = gb.readBits(3);\n let sign_data_hiding_enabled_flag = gb.readBool();\n let cabac_init_present_flag = gb.readBool();\n let num_ref_idx_l0_default_active_minus1 = gb.readUEG();\n let num_ref_idx_l1_default_active_minus1 = gb.readUEG();\n let init_qp_minus26 = gb.readSEG();\n let constrained_intra_pred_flag = gb.readBool();\n let transform_skip_enabled_flag = gb.readBool();\n let cu_qp_delta_enabled_flag = gb.readBool();\n if (cu_qp_delta_enabled_flag) {\n let diff_cu_qp_delta_depth = gb.readUEG();\n }\n let cb_qp_offset = gb.readSEG();\n let cr_qp_offset = gb.readSEG();\n let pps_slice_chroma_qp_offsets_present_flag = gb.readBool();\n let weighted_pred_flag = gb.readBool();\n let weighted_bipred_flag = gb.readBool();\n let transquant_bypass_enabled_flag = gb.readBool();\n let tiles_enabled_flag = gb.readBool();\n let entropy_coding_sync_enabled_flag = gb.readBool();\n // and more ...\n\n // needs hvcC\n let parallelismType = 1; // slice-based parallel decoding\n if (entropy_coding_sync_enabled_flag && tiles_enabled_flag) {\n parallelismType = 0; // mixed-type parallel decoding\n } else if (entropy_coding_sync_enabled_flag) {\n parallelismType = 3; // wavefront-based parallel decoding\n } else if (tiles_enabled_flag) {\n parallelismType = 2; // tile-based parallel decoding\n }\n\n return {\n parallelismType\n }\n }\n\n static getChromaFormatString(chroma_idc) {\n switch (chroma_idc) {\n case 0: return '4:0:0';\n case 1: return '4:2:0';\n case 2: return '4:2:2';\n case 3: return '4:4:4';\n default: return 'Unknown';\n }\n }\n\n static getProfileString(profile_idc) {\n switch (profile_idc) {\n case 1: return 'Main';\n case 2: return 'Main10';\n case 3: return 'MainSP';\n case 4: return 'Rext';\n case 9: return 'SCC';\n default: return 'Unknown';\n }\n }\n\n static getLevelString(level_idc) {\n return (level_idc / 30).toFixed(1);\n }\n}\n\nexport default H265NaluParser;","/*\n * Copyright (C) 2021 magicxqq. All Rights Reserved.\n *\n * @author magicxqq \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger';\nimport DemuxErrors from './demux-errors';\nimport MediaInfo from '../core/media-info';\nimport {IllegalStateException} from '../utils/exception';\nimport BaseDemuxer from './base-demuxer';\nimport { PAT, PESData, SectionData, SliceQueue, PIDToSliceQueues, PMT, ProgramToPMTMap, StreamType } from './pat-pmt-pes';\nimport { AVCDecoderConfigurationRecord, H264AnnexBParser, H264NaluAVC1, H264NaluPayload, H264NaluType } from './h264';\nimport SPSParser from './sps-parser';\nimport { AACADTSParser, AACFrame, AudioSpecificConfig } from './aac';\nimport { MPEG4AudioObjectTypes, MPEG4SamplingFrequencyIndex } from './mpeg4-audio';\nimport { PESPrivateData, PESPrivateDataDescriptor } from './pes-private-data';\nimport { readSCTE35, SCTE35Data } from './scte35';\nimport { H265AnnexBParser, H265NaluHVC1, H265NaluPayload, H265NaluType, HEVCDecoderConfigurationRecord } from './h265';\nimport H265Parser from './h265-parser';\n\nclass TSDemuxer extends BaseDemuxer {\n\n private readonly TAG: string = 'TSDemuxer';\n\n private config_: any;\n private ts_packet_size_: number;\n private sync_offset_: number;\n private first_parse_: boolean = true;\n\n private media_info_ = new MediaInfo();\n\n private timescale_ = 90;\n private duration_ = 0;\n\n private pat_: PAT;\n private current_program_: number;\n private current_pmt_pid_: number = -1;\n private pmt_: PMT;\n private program_pmt_map_: ProgramToPMTMap = {};\n\n private pes_slice_queues_: PIDToSliceQueues = {};\n private section_slice_queues_: PIDToSliceQueues = {};\n\n private video_metadata_: {\n vps: H265NaluHVC1 | undefined,\n sps: H264NaluAVC1 | H265NaluHVC1 | undefined,\n pps: H264NaluAVC1 | H265NaluHVC1 | undefined,\n details: any\n } = {\n vps: undefined,\n sps: undefined,\n pps: undefined,\n details: undefined\n };\n\n private audio_metadata_: {\n audio_object_type: MPEG4AudioObjectTypes;\n sampling_freq_index: MPEG4SamplingFrequencyIndex;\n sampling_frequency: number;\n channel_config: number;\n } = {\n audio_object_type: undefined,\n sampling_freq_index: undefined,\n sampling_frequency: undefined,\n channel_config: undefined\n };\n\n private aac_last_sample_pts_: number = undefined;\n private aac_last_incomplete_data_: Uint8Array = null;\n\n private has_video_ = false;\n private has_audio_ = false;\n private video_init_segment_dispatched_ = false;\n private audio_init_segment_dispatched_ = false;\n private video_metadata_changed_ = false;\n private audio_metadata_changed_ = false;\n\n private video_track_ = {type: 'video', id: 1, sequenceNumber: 0, samples: [], length: 0};\n private audio_track_ = {type: 'audio', id: 2, sequenceNumber: 0, samples: [], length: 0};\n\n public constructor(probe_data: any, config: any) {\n super();\n\n this.ts_packet_size_ = probe_data.ts_packet_size;\n this.sync_offset_ = probe_data.sync_offset;\n this.config_ = config;\n }\n\n public destroy() {\n this.media_info_ = null;\n this.pes_slice_queues_ = null;\n this.section_slice_queues_ = null;\n\n this.video_metadata_ = null;\n this.audio_metadata_ = null;\n this.aac_last_incomplete_data_ = null;\n\n this.video_track_ = null;\n this.audio_track_ = null;\n\n super.destroy();\n }\n\n public static probe(buffer: ArrayBuffer) {\n let data = new Uint8Array(buffer);\n let sync_offset = -1;\n let ts_packet_size = 188;\n\n if (data.byteLength <= 3 * ts_packet_size) {\n Log.e('TSDemuxer', `Probe data ${data.byteLength} bytes is too few for judging MPEG-TS stream format!`);\n return {match: false};\n }\n\n while (sync_offset === -1) {\n let scan_window = Math.min(1000, data.byteLength - 3 * ts_packet_size);\n\n for (let i = 0; i < scan_window; ) {\n // sync_byte should all be 0x47\n if (data[i] === 0x47\n && data[i + ts_packet_size] === 0x47\n && data[i + 2 * ts_packet_size] === 0x47) {\n sync_offset = i;\n break;\n } else {\n i++;\n }\n }\n\n // find sync_offset failed in previous ts_packet_size\n if (sync_offset === -1) {\n if (ts_packet_size === 188) {\n // try 192 packet size (BDAV, etc.)\n ts_packet_size = 192;\n } else if (ts_packet_size === 192) {\n // try 204 packet size (European DVB, etc.)\n ts_packet_size = 204;\n } else {\n // 192, 204 also failed, exit\n break;\n }\n }\n }\n\n if (sync_offset === -1) {\n // both 188, 192, 204 failed, Non MPEG-TS\n return {match: false};\n }\n\n if (ts_packet_size === 192 && sync_offset >= 4) {\n Log.v('TSDemuxer', `ts_packet_size = 192, m2ts mode`);\n sync_offset -= 4;\n } else if (ts_packet_size === 204) {\n Log.v('TSDemuxer', `ts_packet_size = 204, RS encoded MPEG2-TS stream`);\n }\n\n return {\n match: true,\n consumed: 0,\n ts_packet_size,\n sync_offset\n };\n }\n\n public bindDataSource(loader) {\n loader.onDataArrival = this.parseChunks.bind(this);\n return this;\n }\n\n public resetMediaInfo() {\n this.media_info_ = new MediaInfo();\n }\n\n public parseChunks(chunk: ArrayBuffer, byte_start: number): number {\n if (!this.onError\n || !this.onMediaInfo\n || !this.onTrackMetadata\n || !this.onDataAvailable) {\n throw new IllegalStateException('onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified');\n }\n\n let offset = 0;\n\n if (this.first_parse_) {\n this.first_parse_ = false;\n offset = this.sync_offset_;\n }\n\n while (offset + this.ts_packet_size_ <= chunk.byteLength) {\n let file_position = byte_start + offset;\n\n if (this.ts_packet_size_ === 192) {\n // skip ATS field (2-bits copy-control + 30-bits timestamp) for m2ts\n offset += 4;\n }\n\n let data = new Uint8Array(chunk, offset, 188);\n\n let sync_byte = data[0];\n if (sync_byte !== 0x47) {\n Log.e(this.TAG, `sync_byte = ${sync_byte}, not 0x47`);\n break;\n }\n\n let payload_unit_start_indicator = (data[1] & 0x40) >>> 6;\n let transport_priority = (data[1] & 0x20) >>> 5;\n let pid = ((data[1] & 0x1F) << 8) | data[2];\n let adaptation_field_control = (data[3] & 0x30) >>> 4;\n let continuity_conunter = (data[3] & 0x0F);\n\n let adaptation_field_info: {\n discontinuity_indicator?: number,\n random_access_indicator?: number,\n elementary_stream_priority_indicator?: number\n } = {};\n let ts_payload_start_index = 4;\n\n if (adaptation_field_control == 0x02 || adaptation_field_control == 0x03) {\n let adaptation_field_length = data[4];\n if (5 + adaptation_field_length === 188) {\n // TS packet only has adaption field, jump to next\n offset += 188;\n if (this.ts_packet_size_ === 204) {\n // skip parity word (16 bytes) for RS encoded TS\n offset += 16;\n }\n continue;\n } else {\n // parse leading adaptation_field if has payload\n if (adaptation_field_length > 0) {\n adaptation_field_info = this.parseAdaptationField(chunk,\n offset + 4,\n 1 + adaptation_field_length);\n }\n ts_payload_start_index = 4 + 1 + adaptation_field_length;\n }\n }\n\n if (adaptation_field_control == 0x01 || adaptation_field_control == 0x03) {\n if (pid === 0 || pid === this.current_pmt_pid_ || (this.pmt_ != undefined && this.pmt_.pid_stream_type[pid] === StreamType.kSCTE35)) { // PAT(pid === 0) or PMT or SCTE35\n let ts_payload_length = 188 - ts_payload_start_index;\n\n this.handleSectionSlice(chunk,\n offset + ts_payload_start_index,\n ts_payload_length,\n {\n pid,\n file_position,\n payload_unit_start_indicator,\n continuity_conunter,\n random_access_indicator: adaptation_field_info.random_access_indicator\n });\n } else if (this.pmt_ != undefined && this.pmt_.pid_stream_type[pid] != undefined) {\n // PES\n let ts_payload_length = 188 - ts_payload_start_index;\n let stream_type = this.pmt_.pid_stream_type[pid];\n\n // process PES only for known common_pids\n if (pid === this.pmt_.common_pids.h264\n || pid === this.pmt_.common_pids.h265\n || pid === this.pmt_.common_pids.adts_aac\n || this.pmt_.pes_private_data_pids[pid] === true\n || this.pmt_.timed_id3_pids[pid] === true) {\n this.handlePESSlice(chunk,\n offset + ts_payload_start_index,\n ts_payload_length,\n {\n pid,\n stream_type,\n file_position,\n payload_unit_start_indicator,\n continuity_conunter,\n random_access_indicator: adaptation_field_info.random_access_indicator\n });\n }\n }\n }\n\n offset += 188;\n\n if (this.ts_packet_size_ === 204) {\n // skip parity word (16 bytes) for RS encoded TS\n offset += 16;\n }\n }\n\n // dispatch parsed frames to the remuxer (consumer)\n this.dispatchAudioVideoMediaSegment();\n\n return offset; // consumed bytes\n }\n\n private parseAdaptationField(buffer: ArrayBuffer, offset: number, length: number): {\n discontinuity_indicator?: number,\n random_access_indicator?: number,\n elementary_stream_priority_indicator?: number\n } {\n let data = new Uint8Array(buffer, offset, length);\n\n let adaptation_field_length = data[0];\n if (adaptation_field_length > 0) {\n if (adaptation_field_length > 183) {\n Log.w(this.TAG, `Illegal adaptation_field_length: ${adaptation_field_length}`);\n return {};\n }\n\n let discontinuity_indicator: number = (data[1] & 0x80) >>> 7;\n let random_access_indicator: number = (data[1] & 0x40) >>> 6;\n let elementary_stream_priority_indicator: number = (data[1] & 0x20) >>> 5;\n\n return {\n discontinuity_indicator,\n random_access_indicator,\n elementary_stream_priority_indicator\n };\n }\n\n return {};\n }\n\n private handleSectionSlice(buffer: ArrayBuffer, offset: number, length: number, misc: any): void {\n let data = new Uint8Array(buffer, offset, length);\n let slice_queue = this.section_slice_queues_[misc.pid];\n\n if (misc.payload_unit_start_indicator) {\n let pointer_field = data[0];\n\n if (slice_queue != undefined && slice_queue.total_length !== 0) {\n let remain_section = new Uint8Array(buffer, offset + 1, Math.min(length, pointer_field));\n slice_queue.slices.push(remain_section);\n slice_queue.total_length += remain_section.byteLength;\n\n if (slice_queue.total_length === slice_queue.expected_length) {\n this.emitSectionSlices(slice_queue, misc);\n } else {\n this.clearSlices(slice_queue, misc);\n }\n }\n\n for (let i = 1 + pointer_field; i < data.byteLength; ){\n let table_id = data[i + 0];\n if (table_id === 0xFF) { break; }\n\n let section_length = ((data[i + 1] & 0x0F) << 8) | data[i + 2];\n\n this.section_slice_queues_[misc.pid] = new SliceQueue();\n slice_queue = this.section_slice_queues_[misc.pid];\n\n slice_queue.expected_length = section_length + 3;\n slice_queue.file_position = misc.file_position;\n slice_queue.random_access_indicator = misc.random_access_indicator;\n\n let remain_section = new Uint8Array(buffer, offset + i, Math.min(length - i, slice_queue.expected_length - slice_queue.total_length));\n slice_queue.slices.push(remain_section);\n slice_queue.total_length += remain_section.byteLength;\n\n if (slice_queue.total_length === slice_queue.expected_length) {\n this.emitSectionSlices(slice_queue, misc);\n } else if (slice_queue.total_length >= slice_queue.expected_length) {\n this.clearSlices(slice_queue, misc);\n }\n\n i += remain_section.byteLength;\n }\n } else if (slice_queue != undefined && slice_queue.total_length !== 0) {\n let remain_section = new Uint8Array(buffer, offset, Math.min(length, slice_queue.expected_length - slice_queue.total_length));\n slice_queue.slices.push(remain_section);\n slice_queue.total_length += remain_section.byteLength;\n\n if (slice_queue.total_length === slice_queue.expected_length) {\n this.emitSectionSlices(slice_queue, misc);\n } else if (slice_queue.total_length >= slice_queue.expected_length) {\n this.clearSlices(slice_queue, misc);\n }\n }\n }\n\n private handlePESSlice(buffer: ArrayBuffer, offset: number, length: number, misc: any): void {\n let data = new Uint8Array(buffer, offset, length);\n\n let packet_start_code_prefix = (data[0] << 16) | (data[1] << 8) | (data[2]);\n let stream_id = data[3];\n let PES_packet_length = (data[4] << 8) | data[5];\n\n if (misc.payload_unit_start_indicator) {\n if (packet_start_code_prefix !== 1) {\n Log.e(this.TAG, `handlePESSlice: packet_start_code_prefix should be 1 but with value ${packet_start_code_prefix}`);\n return;\n }\n\n // handle queued PES slices:\n // Merge into a big Uint8Array then call parsePES()\n let slice_queue = this.pes_slice_queues_[misc.pid];\n if (slice_queue) {\n if (slice_queue.expected_length === 0 || slice_queue.expected_length === slice_queue.total_length) {\n this.emitPESSlices(slice_queue, misc);\n } else {\n this.clearSlices(slice_queue, misc);\n }\n }\n\n // Make a new PES queue for new PES slices\n this.pes_slice_queues_[misc.pid] = new SliceQueue();\n this.pes_slice_queues_[misc.pid].file_position = misc.file_position;\n this.pes_slice_queues_[misc.pid].random_access_indicator = misc.random_access_indicator;\n }\n\n if (this.pes_slice_queues_[misc.pid] == undefined) {\n // ignore PES slices without [PES slice that has payload_unit_start_indicator]\n return;\n }\n\n // push subsequent PES slices into pes_queue\n let slice_queue = this.pes_slice_queues_[misc.pid];\n slice_queue.slices.push(data);\n if (misc.payload_unit_start_indicator) {\n slice_queue.expected_length = PES_packet_length === 0 ? 0 : PES_packet_length + 6;\n }\n slice_queue.total_length += data.byteLength;\n\n if (slice_queue.expected_length > 0 && slice_queue.expected_length === slice_queue.total_length) {\n this.emitPESSlices(slice_queue, misc);\n } else if (slice_queue.expected_length > 0 && slice_queue.expected_length < slice_queue.total_length) {\n this.clearSlices(slice_queue, misc);\n }\n }\n\n private emitSectionSlices(slice_queue: SliceQueue, misc: any): void {\n let data = new Uint8Array(slice_queue.total_length);\n for (let i = 0, offset = 0; i < slice_queue.slices.length; i++) {\n let slice = slice_queue.slices[i];\n data.set(slice, offset);\n offset += slice.byteLength;\n }\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n\n let section_data = new SectionData();\n section_data.pid = misc.pid;\n section_data.data = data;\n section_data.file_position = slice_queue.file_position;\n section_data.random_access_indicator = slice_queue.random_access_indicator;\n this.parseSection(section_data);\n }\n\n private emitPESSlices(slice_queue: SliceQueue, misc: any): void {\n let data = new Uint8Array(slice_queue.total_length);\n for (let i = 0, offset = 0; i < slice_queue.slices.length; i++) {\n let slice = slice_queue.slices[i];\n data.set(slice, offset);\n offset += slice.byteLength;\n }\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n\n let pes_data = new PESData();\n pes_data.pid = misc.pid;\n pes_data.data = data;\n pes_data.stream_type = misc.stream_type;\n pes_data.file_position = slice_queue.file_position;\n pes_data.random_access_indicator = slice_queue.random_access_indicator;\n this.parsePES(pes_data);\n }\n\n private clearSlices(slice_queue: SliceQueue, misc: any): void {\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n }\n\n private parseSection(section_data: SectionData): void {\n let data = section_data.data;\n let pid = section_data.pid;\n\n if (pid === 0x00) {\n this.parsePAT(data);\n } else if (pid === this.current_pmt_pid_) {\n this.parsePMT(data);\n } else if (this.pmt_ != undefined && this.pmt_.scte_35_pids[pid]) {\n this.parseSCTE35(data);\n }\n }\n\n private parsePES(pes_data: PESData): void {\n let data = pes_data.data;\n let packet_start_code_prefix = (data[0] << 16) | (data[1] << 8) | (data[2]);\n let stream_id = data[3];\n let PES_packet_length = (data[4] << 8) | data[5];\n\n if (packet_start_code_prefix !== 1) {\n Log.e(this.TAG, `parsePES: packet_start_code_prefix should be 1 but with value ${packet_start_code_prefix}`);\n return;\n }\n\n if (stream_id !== 0xBC // program_stream_map\n && stream_id !== 0xBE // padding_stream\n && stream_id !== 0xBF // private_stream_2\n && stream_id !== 0xF0 // ECM\n && stream_id !== 0xF1 // EMM\n && stream_id !== 0xFF // program_stream_directory\n && stream_id !== 0xF2 // DSMCC\n && stream_id !== 0xF8) {\n let PES_scrambling_control = (data[6] & 0x30) >>> 4;\n let PTS_DTS_flags = (data[7] & 0xC0) >>> 6;\n let PES_header_data_length = data[8];\n\n let pts: number | undefined;\n let dts: number | undefined;\n\n if (PTS_DTS_flags === 0x02 || PTS_DTS_flags === 0x03) {\n pts = (data[9] & 0x0E) * 536870912 + // 1 << 29\n (data[10] & 0xFF) * 4194304 + // 1 << 22\n (data[11] & 0xFE) * 16384 + // 1 << 14\n (data[12] & 0xFF) * 128 + // 1 << 7\n (data[13] & 0xFE) / 2;\n\n if (PTS_DTS_flags === 0x03) {\n dts = (data[14] & 0x0E) * 536870912 + // 1 << 29\n (data[15] & 0xFF) * 4194304 + // 1 << 22\n (data[16] & 0xFE) * 16384 + // 1 << 14\n (data[17] & 0xFF) * 128 + // 1 << 7\n (data[18] & 0xFE) / 2;\n } else {\n dts = pts;\n }\n }\n\n let payload_start_index = 6 + 3 + PES_header_data_length;\n let payload_length: number;\n\n if (PES_packet_length !== 0) {\n if (PES_packet_length < 3 + PES_header_data_length) {\n Log.v(this.TAG, `Malformed PES: PES_packet_length < 3 + PES_header_data_length`);\n return;\n }\n payload_length = PES_packet_length - 3 - PES_header_data_length;\n } else { // PES_packet_length === 0\n payload_length = data.byteLength - payload_start_index;\n }\n\n let payload = data.subarray(payload_start_index, payload_start_index + payload_length);\n\n switch (pes_data.stream_type) {\n case StreamType.kMPEG1Audio:\n case StreamType.kMPEG2Audio:\n break;\n case StreamType.kPESPrivateData:\n this.parsePESPrivateDataPayload(payload, pts, dts, pes_data.pid, stream_id);\n break;\n case StreamType.kADTSAAC:\n this.parseAACPayload(payload, pts);\n break;\n case StreamType.kID3:\n this.parseTimedID3MetadataPayload(payload, pts, dts, pes_data.pid, stream_id);\n break;\n case StreamType.kH264:\n this.parseH264Payload(payload, pts, dts, pes_data.file_position, pes_data.random_access_indicator);\n break;\n case StreamType.kH265:\n this.parseH265Payload(payload, pts, dts, pes_data.file_position, pes_data.random_access_indicator);\n break;\n default:\n break;\n }\n } else if (stream_id === 0xBC // program_stream_map\n || stream_id === 0xBF // private_stream_2\n || stream_id === 0xF0 // ECM\n || stream_id === 0xF1 // EMM\n || stream_id === 0xFF // program_stream_directory\n || stream_id === 0xF2 // DSMCC_stream\n || stream_id === 0xF8) { // ITU-T Rec. H.222.1 type E stream\n if (pes_data.stream_type === StreamType.kPESPrivateData) {\n let payload_start_index = 6;\n let payload_length: number;\n\n if (PES_packet_length !== 0) {\n payload_length = PES_packet_length;\n } else { // PES_packet_length === 0\n payload_length = data.byteLength - payload_start_index;\n }\n\n let payload = data.subarray(payload_start_index, payload_start_index + payload_length);\n this.parsePESPrivateDataPayload(payload, undefined, undefined, pes_data.pid, stream_id);\n }\n }\n }\n\n private parsePAT(data: Uint8Array): void {\n let table_id = data[0];\n if (table_id !== 0x00) {\n Log.e(this.TAG, `parsePAT: table_id ${table_id} is not corresponded to PAT!`);\n return;\n }\n\n let section_length = ((data[1] & 0x0F) << 8) | data[2];\n\n let transport_stream_id = (data[3] << 8) | data[4];\n let version_number = (data[5] & 0x3E) >>> 1;\n let current_next_indicator = data[5] & 0x01;\n let section_number = data[6];\n let last_section_number = data[7];\n\n let pat: PAT = null;\n\n if (current_next_indicator === 1 && section_number === 0) {\n pat = new PAT();\n pat.version_number = version_number;\n } else {\n pat = this.pat_;\n if (pat == undefined) {\n return;\n }\n }\n\n let program_start_index = 8;\n let program_bytes = section_length - 5 - 4; // section_length - (headers + crc)\n let first_program_number = -1;\n let first_pmt_pid = -1;\n\n for (let i = program_start_index; i < program_start_index + program_bytes; i += 4) {\n let program_number = (data[i] << 8) | data[i + 1];\n let pid = ((data[i + 2] & 0x1F) << 8) | data[i + 3];\n\n if (program_number === 0) {\n // network_PID\n pat.network_pid = pid;\n } else {\n // program_map_PID\n pat.program_pmt_pid[program_number] = pid;\n\n if (first_program_number === -1) {\n first_program_number = program_number;\n }\n\n if (first_pmt_pid === -1) {\n first_pmt_pid = pid;\n }\n }\n }\n\n // Currently we only deal with first appeared PMT pid\n if (current_next_indicator === 1 && section_number === 0) {\n if (this.pat_ == undefined) {\n Log.v(this.TAG, `Parsed first PAT: ${JSON.stringify(pat)}`);\n }\n this.pat_ = pat;\n this.current_program_ = first_program_number;\n this.current_pmt_pid_ = first_pmt_pid;\n }\n }\n\n private parsePMT(data: Uint8Array): void {\n let table_id = data[0];\n if (table_id !== 0x02) {\n Log.e(this.TAG, `parsePMT: table_id ${table_id} is not corresponded to PMT!`);\n return;\n }\n\n let section_length = ((data[1] & 0x0F) << 8) | data[2];\n\n let program_number = (data[3] << 8) | data[4];\n let version_number = (data[5] & 0x3E) >>> 1;\n let current_next_indicator = data[5] & 0x01;\n let section_number = data[6];\n let last_section_number = data[7];\n\n let pmt: PMT = null;\n\n if (current_next_indicator === 1 && section_number === 0) {\n pmt = new PMT();\n pmt.program_number = program_number;\n pmt.version_number = version_number;\n this.program_pmt_map_[program_number] = pmt;\n } else {\n pmt = this.program_pmt_map_[program_number];\n if (pmt == undefined) {\n return;\n }\n }\n\n let PCR_PID = ((data[8] & 0x1F) << 8) | data[9];\n let program_info_length = ((data[10] & 0x0F) << 8) | data[11];\n\n let info_start_index = 12 + program_info_length;\n let info_bytes = section_length - 9 - program_info_length - 4;\n\n for (let i = info_start_index; i < info_start_index + info_bytes; ) {\n let stream_type = data[i] as StreamType;\n let elementary_PID = ((data[i + 1] & 0x1F) << 8) | data[i + 2];\n let ES_info_length = ((data[i + 3] & 0x0F) << 8) | data[i + 4];\n\n pmt.pid_stream_type[elementary_PID] = stream_type;\n\n if (stream_type === StreamType.kH264 && !pmt.common_pids.h264 && !pmt.common_pids.h265) {\n pmt.common_pids.h264 = elementary_PID;\n } else if (stream_type === StreamType.kH265 && !pmt.common_pids.h264 && !pmt.common_pids.h265) {\n pmt.common_pids.h265 = elementary_PID;\n } else if (stream_type === StreamType.kADTSAAC && !pmt.common_pids.adts_aac) {\n pmt.common_pids.adts_aac = elementary_PID;\n } else if (stream_type === StreamType.kPESPrivateData) {\n pmt.pes_private_data_pids[elementary_PID] = true;\n if (ES_info_length > 0) {\n // provide descriptor for PES private data via callback\n let descriptor = data.subarray(i + 5, i + 5 + ES_info_length);\n this.dispatchPESPrivateDataDescriptor(elementary_PID, stream_type, descriptor);\n }\n } else if (stream_type === StreamType.kID3) {\n pmt.timed_id3_pids[elementary_PID] = true;\n } else if (stream_type === StreamType.kSCTE35) {\n pmt.scte_35_pids[elementary_PID] = true;\n }\n\n i += 5 + ES_info_length;\n }\n\n if (program_number === this.current_program_) {\n if (this.pmt_ == undefined) {\n Log.v(this.TAG, `Parsed first PMT: ${JSON.stringify(pmt)}`);\n }\n this.pmt_ = pmt;\n if (pmt.common_pids.h264 || pmt.common_pids.h265) {\n this.has_video_ = true;\n }\n if (pmt.common_pids.adts_aac) {\n this.has_audio_ = true;\n }\n }\n }\n\n private parseSCTE35(data: Uint8Array): void {\n const scte35 = readSCTE35(data);\n\n if (scte35.pts != undefined) {\n let pts_ms = Math.floor(scte35.pts / this.timescale_);\n scte35.pts = pts_ms;\n } else {\n scte35.nearest_pts = this.aac_last_sample_pts_;\n }\n\n if (this.onSCTE35Metadata) {\n this.onSCTE35Metadata(scte35);\n }\n }\n\n private parseH264Payload(data: Uint8Array, pts: number, dts: number, file_position: number, random_access_indicator: number) {\n let annexb_parser = new H264AnnexBParser(data);\n let nalu_payload: H264NaluPayload = null;\n let units: {type: H264NaluType, data: Uint8Array}[] = [];\n let length = 0;\n let keyframe = false;\n\n while ((nalu_payload = annexb_parser.readNextNaluPayload()) != null) {\n let nalu_avc1 = new H264NaluAVC1(nalu_payload);\n\n if (nalu_avc1.type === H264NaluType.kSliceSPS) {\n // Notice: parseSPS requires Nalu without startcode or length-header\n let details = SPSParser.parseSPS(nalu_payload.data);\n if (!this.video_init_segment_dispatched_) {\n this.video_metadata_.sps = nalu_avc1;\n this.video_metadata_.details = details;\n } else if (this.detectVideoMetadataChange(nalu_avc1, details) === true) {\n Log.v(this.TAG, `H264: Critical h264 metadata has been changed, attempt to re-generate InitSegment`);\n this.video_metadata_changed_ = true;\n this.video_metadata_ = {vps: undefined, sps: nalu_avc1, pps: undefined, details: details};\n }\n } else if (nalu_avc1.type === H264NaluType.kSlicePPS) {\n if (!this.video_init_segment_dispatched_ || this.video_metadata_changed_) {\n this.video_metadata_.pps = nalu_avc1;\n if (this.video_metadata_.sps && this.video_metadata_.pps) {\n if (this.video_metadata_changed_) {\n // flush stashed frames before changing codec metadata\n this.dispatchVideoMediaSegment();\n }\n // notify new codec metadata (maybe changed)\n this.dispatchVideoInitSegment();\n }\n }\n } else if (nalu_avc1.type === H264NaluType.kSliceIDR) {\n keyframe = true;\n } else if (nalu_avc1.type === H264NaluType.kSliceNonIDR && random_access_indicator === 1) {\n // For open-gop stream, use random_access_indicator to identify keyframe\n keyframe = true;\n }\n\n // Push samples to remuxer only if initialization metadata has been dispatched\n if (this.video_init_segment_dispatched_) {\n units.push(nalu_avc1);\n length += nalu_avc1.data.byteLength;\n }\n }\n\n let pts_ms = Math.floor(pts / this.timescale_);\n let dts_ms = Math.floor(dts / this.timescale_);\n\n if (units.length) {\n let track = this.video_track_;\n let avc_sample = {\n units,\n length,\n isKeyframe: keyframe,\n dts: dts_ms,\n pts: pts_ms,\n cts: pts_ms - dts_ms,\n file_position\n };\n track.samples.push(avc_sample);\n track.length += length;\n }\n }\n\n private parseH265Payload(data: Uint8Array, pts: number, dts: number, file_position: number, random_access_indicator: number) {\n let annexb_parser = new H265AnnexBParser(data);\n let nalu_payload: H265NaluPayload = null;\n let units: {type: H265NaluType, data: Uint8Array}[] = [];\n let length = 0;\n let keyframe = false;\n\n while ((nalu_payload = annexb_parser.readNextNaluPayload()) != null) {\n let nalu_hvc1 = new H265NaluHVC1(nalu_payload);\n\n if (nalu_hvc1.type === H265NaluType.kSliceVPS) {\n if (!this.video_init_segment_dispatched_) {\n let details = H265Parser.parseVPS(nalu_payload.data);\n this.video_metadata_.vps = nalu_hvc1;\n this.video_metadata_.details = {\n ... this.video_metadata_.details,\n ... details\n };\n }\n } else if (nalu_hvc1.type === H265NaluType.kSliceSPS) {\n let details = H265Parser.parseSPS(nalu_payload.data);\n if (!this.video_init_segment_dispatched_) {\n this.video_metadata_.sps = nalu_hvc1;\n this.video_metadata_.details = {\n ... this.video_metadata_.details,\n ... details\n };\n } else if (this.detectVideoMetadataChange(nalu_hvc1, details) === true) {\n Log.v(this.TAG, `H265: Critical h265 metadata has been changed, attempt to re-generate InitSegment`);\n this.video_metadata_changed_ = true;\n this.video_metadata_ = { vps: undefined, sps: nalu_hvc1, pps: undefined, details: details};\n }\n } else if (nalu_hvc1.type === H265NaluType.kSlicePPS) {\n if (!this.video_init_segment_dispatched_ || this.video_metadata_changed_) {\n let details = H265Parser.parsePPS(nalu_payload.data);\n this.video_metadata_.pps = nalu_hvc1;\n this.video_metadata_.details = {\n ... this.video_metadata_.details,\n ... details\n };\n\n if (this.video_metadata_.vps && this.video_metadata_.sps && this.video_metadata_.pps) {\n if (this.video_metadata_changed_) {\n // flush stashed frames before changing codec metadata\n this.dispatchVideoMediaSegment();\n }\n // notify new codec metadata (maybe changed)\n this.dispatchVideoInitSegment();\n }\n }\n } else if (nalu_hvc1.type === H265NaluType.kSliceIDR_W_RADL || nalu_hvc1.type === H265NaluType.kSliceIDR_N_LP) {\n keyframe = true;\n }\n\n // Push samples to remuxer only if initialization metadata has been dispatched\n if (this.video_init_segment_dispatched_) {\n units.push(nalu_hvc1);\n length += nalu_hvc1.data.byteLength;\n }\n }\n\n let pts_ms = Math.floor(pts / this.timescale_);\n let dts_ms = Math.floor(dts / this.timescale_);\n\n if (units.length) {\n let track = this.video_track_;\n let hvc_sample = {\n units,\n length,\n isKeyframe: keyframe,\n dts: dts_ms,\n pts: pts_ms,\n cts: pts_ms - dts_ms,\n file_position\n };\n track.samples.push(hvc_sample);\n track.length += length;\n }\n }\n\n private detectVideoMetadataChange(new_sps: H264NaluAVC1 | H265NaluHVC1, new_details: any): boolean {\n if (new_details.codec_mimetype !== this.video_metadata_.details.codec_mimetype) {\n Log.v(this.TAG, `Video: Codec mimeType changed from ` +\n `${this.video_metadata_.details.codec_mimetype} to ${new_details.codec_mimetype}`);\n return true;\n }\n\n if (new_details.codec_size.width !== this.video_metadata_.details.codec_size.width\n || new_details.codec_size.height !== this.video_metadata_.details.codec_size.height) {\n let old_size = this.video_metadata_.details.codec_size;\n let new_size = new_details.codec_size;\n Log.v(this.TAG, `Video: Coded Resolution changed from ` +\n `${old_size.width}x${old_size.height} to ${new_size.width}x${new_size.height}`);\n return true;\n }\n\n if (new_details.present_size.width !== this.video_metadata_.details.present_size.width) {\n Log.v(this.TAG, `Video: Present resolution width changed from ` +\n `${this.video_metadata_.details.present_size.width} to ${new_details.present_size.width}`);\n return true;\n }\n\n return false;\n }\n\n private isInitSegmentDispatched(): boolean {\n if (this.has_video_ && this.has_audio_) { // both video & audio\n return this.video_init_segment_dispatched_ && this.audio_init_segment_dispatched_;\n }\n if (this.has_video_ && !this.has_audio_) { // video only\n return this.video_init_segment_dispatched_;\n }\n if (!this.has_video_ && this.has_audio_) { // audio only\n return this.audio_init_segment_dispatched_;\n }\n return false;\n }\n\n private dispatchVideoInitSegment() {\n let details = this.video_metadata_.details;\n let meta: any = {};\n\n meta.type = 'video';\n meta.id = this.video_track_.id;\n meta.timescale = 1000;\n meta.duration = this.duration_;\n\n meta.codecWidth = details.codec_size.width;\n meta.codecHeight = details.codec_size.height;\n meta.presentWidth = details.present_size.width;\n meta.presentHeight = details.present_size.height;\n\n meta.profile = details.profile_string;\n meta.level = details.level_string;\n meta.bitDepth = details.bit_depth;\n meta.chromaFormat = details.chroma_format;\n meta.sarRatio = details.sar_ratio;\n meta.frameRate = details.frame_rate;\n\n let fps_den = meta.frameRate.fps_den;\n let fps_num = meta.frameRate.fps_num;\n meta.refSampleDuration = 1000 * (fps_den / fps_num);\n\n meta.codec = details.codec_mimetype;\n\n if (this.video_metadata_.vps) {\n let vps_without_header = this.video_metadata_.vps.data.subarray(4);\n let sps_without_header = this.video_metadata_.sps.data.subarray(4);\n let pps_without_header = this.video_metadata_.pps.data.subarray(4);\n let hvcc = new HEVCDecoderConfigurationRecord(vps_without_header, sps_without_header, pps_without_header, details);\n meta.hvcc = hvcc.getData();\n\n if (this.video_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first HEVCDecoderConfigurationRecord for mimeType: ${meta.codec}`);\n }\n } else {\n let sps_without_header = this.video_metadata_.sps.data.subarray(4);\n let pps_without_header = this.video_metadata_.pps.data.subarray(4);\n let avcc = new AVCDecoderConfigurationRecord(sps_without_header, pps_without_header, details);\n meta.avcc = avcc.getData();\n\n if (this.video_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first AVCDecoderConfigurationRecord for mimeType: ${meta.codec}`);\n }\n }\n this.onTrackMetadata('video', meta);\n this.video_init_segment_dispatched_ = true;\n this.video_metadata_changed_ = false;\n\n // notify new MediaInfo\n let mi = this.media_info_;\n mi.hasVideo = true;\n mi.width = meta.codecWidth;\n mi.height = meta.codecHeight;\n mi.fps = meta.frameRate.fps;\n mi.profile = meta.profile;\n mi.level = meta.level;\n mi.refFrames = details.ref_frames;\n mi.chromaFormat = details.chroma_format_string;\n mi.sarNum = meta.sarRatio.width;\n mi.sarDen = meta.sarRatio.height;\n mi.videoCodec = meta.codec;\n\n if (mi.hasAudio && mi.audioCodec) {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec},${mi.audioCodec}\"`;\n } else {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec}\"`;\n }\n\n if (mi.isComplete()) {\n this.onMediaInfo(mi);\n }\n }\n\n private dispatchVideoMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.video_track_.length) {\n this.onDataAvailable(null, this.video_track_);\n }\n }\n }\n\n private dispatchAudioMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.audio_track_.length) {\n this.onDataAvailable(this.audio_track_, null);\n }\n }\n }\n\n private dispatchAudioVideoMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.audio_track_.length || this.video_track_.length) {\n this.onDataAvailable(this.audio_track_, this.video_track_);\n }\n }\n }\n\n private parseAACPayload(data: Uint8Array, pts: number) {\n if (this.has_video_ && !this.video_init_segment_dispatched_) {\n // If first video IDR frame hasn't been detected,\n // Wait for first IDR frame and video init segment being dispatched\n return;\n }\n\n if (this.aac_last_incomplete_data_) {\n let buf = new Uint8Array(data.byteLength + this.aac_last_incomplete_data_.byteLength);\n buf.set(this.aac_last_incomplete_data_, 0);\n buf.set(data, this.aac_last_incomplete_data_.byteLength);\n data = buf;\n }\n\n let ref_sample_duration: number;\n let base_pts_ms: number;\n\n if (pts != undefined) {\n base_pts_ms = pts / this.timescale_;\n } else if (this.aac_last_sample_pts_ != undefined) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n base_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n } else {\n Log.w(this.TAG, `AAC: Unknown pts`);\n return;\n }\n\n if (this.aac_last_incomplete_data_ && this.aac_last_sample_pts_) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n let new_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n\n if (Math.abs(new_pts_ms - base_pts_ms) > 1) {\n Log.w(this.TAG, `AAC: Detected pts overlapped, ` +\n `expected: ${new_pts_ms}ms, PES pts: ${base_pts_ms}ms`);\n base_pts_ms = new_pts_ms;\n }\n }\n\n let adts_parser = new AACADTSParser(data);\n let aac_frame: AACFrame = null;\n let sample_pts_ms = base_pts_ms;\n let last_sample_pts_ms: number;\n\n while ((aac_frame = adts_parser.readNextAACFrame()) != null) {\n ref_sample_duration = 1024 / aac_frame.sampling_frequency * 1000;\n\n if (this.audio_init_segment_dispatched_ == false) {\n this.audio_metadata_.audio_object_type = aac_frame.audio_object_type;\n this.audio_metadata_.sampling_freq_index = aac_frame.sampling_freq_index;\n this.audio_metadata_.sampling_frequency = aac_frame.sampling_frequency;\n this.audio_metadata_.channel_config = aac_frame.channel_config;\n this.dispatchAudioInitSegment(aac_frame);\n } else if (this.detectAudioMetadataChange(aac_frame)) {\n // flush stashed frames before notify new AudioSpecificConfig\n this.dispatchAudioMediaSegment();\n // notify new AAC AudioSpecificConfig\n this.dispatchAudioInitSegment(aac_frame);\n }\n\n last_sample_pts_ms = sample_pts_ms;\n let sample_pts_ms_int = Math.floor(sample_pts_ms);\n\n let aac_sample = {\n unit: aac_frame.data,\n length: aac_frame.data.byteLength,\n pts: sample_pts_ms_int,\n dts: sample_pts_ms_int\n };\n this.audio_track_.samples.push(aac_sample);\n this.audio_track_.length += aac_frame.data.byteLength;\n\n sample_pts_ms += ref_sample_duration;\n }\n\n if (adts_parser.hasIncompleteData()) {\n this.aac_last_incomplete_data_ = adts_parser.getIncompleteData();\n }\n\n if (last_sample_pts_ms) {\n this.aac_last_sample_pts_ = last_sample_pts_ms;\n }\n }\n\n private detectAudioMetadataChange(frame: AACFrame): boolean {\n if (frame.audio_object_type !== this.audio_metadata_.audio_object_type) {\n Log.v(this.TAG, `AAC: AudioObjectType changed from ` +\n `${this.audio_metadata_.audio_object_type} to ${frame.audio_object_type}`);\n return true;\n }\n\n if (frame.sampling_freq_index !== this.audio_metadata_.sampling_freq_index) {\n Log.v(this.TAG, `AAC: SamplingFrequencyIndex changed from ` +\n `${this.audio_metadata_.sampling_freq_index} to ${frame.sampling_freq_index}`);\n return true;\n }\n\n if (frame.channel_config !== this.audio_metadata_.channel_config) {\n Log.v(this.TAG, `AAC: Channel configuration changed from ` +\n `${this.audio_metadata_.channel_config} to ${frame.channel_config}`);\n return true;\n }\n\n return false;\n }\n\n private dispatchAudioInitSegment(aac_frame: AACFrame) {\n let audio_specific_config = new AudioSpecificConfig(aac_frame);\n let meta: any = {};\n\n meta.type = 'audio';\n meta.id = this.audio_track_.id;\n meta.timescale = 1000;\n meta.duration = this.duration_;\n\n meta.audioSampleRate = audio_specific_config.sampling_rate;\n meta.channelCount = audio_specific_config.channel_count;\n meta.codec = audio_specific_config.codec_mimetype;\n meta.originalCodec = audio_specific_config.original_codec_mimetype;\n meta.config = audio_specific_config.config;\n\n meta.refSampleDuration = 1024 / meta.audioSampleRate * meta.timescale;\n\n if (this.audio_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first AudioSpecificConfig for mimeType: ${meta.codec}`);\n }\n\n this.onTrackMetadata('audio', meta);\n this.audio_init_segment_dispatched_ = true;\n this.video_metadata_changed_ = false;\n\n // notify new MediaInfo\n let mi = this.media_info_;\n mi.hasAudio = true;\n mi.audioCodec = meta.originalCodec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n\n if (mi.hasVideo && mi.videoCodec) {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec},${mi.audioCodec}\"`;\n } else {\n mi.mimeType = `video/mp2t; codecs=\"${mi.audioCodec}\"`;\n }\n\n if (mi.isComplete()) {\n this.onMediaInfo(mi);\n }\n }\n\n private dispatchPESPrivateDataDescriptor(pid: number, stream_type: number, descriptor: Uint8Array) {\n let desc = new PESPrivateDataDescriptor();\n desc.pid = pid;\n desc.stream_type = stream_type;\n desc.descriptor = descriptor;\n\n if (this.onPESPrivateDataDescriptor) {\n this.onPESPrivateDataDescriptor(desc);\n }\n }\n\n private parsePESPrivateDataPayload(data: Uint8Array, pts: number, dts: number, pid: number, stream_id: number) {\n let private_data = new PESPrivateData();\n\n private_data.pid = pid;\n private_data.stream_id = stream_id;\n private_data.len = data.byteLength;\n private_data.data = data;\n\n if (pts != undefined) {\n let pts_ms = Math.floor(pts / this.timescale_);\n private_data.pts = pts_ms;\n } else {\n private_data.nearest_pts = this.aac_last_sample_pts_;\n }\n\n if (dts != undefined) {\n let dts_ms = Math.floor(dts / this.timescale_);\n private_data.dts = dts_ms;\n }\n\n if (this.onPESPrivateData) {\n this.onPESPrivateData(private_data);\n }\n }\n\n private parseTimedID3MetadataPayload(data: Uint8Array, pts: number, dts: number, pid: number, stream_id: number) {\n let timed_id3_metadata = new PESPrivateData();\n\n timed_id3_metadata.pid = pid;\n timed_id3_metadata.stream_id = stream_id;\n timed_id3_metadata.len = data.byteLength;\n timed_id3_metadata.data = data;\n\n if (pts != undefined) {\n let pts_ms = Math.floor(pts / this.timescale_);\n timed_id3_metadata.pts = pts_ms;\n } \n\n if (dts != undefined) {\n let dts_ms = Math.floor(dts / this.timescale_);\n timed_id3_metadata.dts = dts_ms;\n }\n\n if (this.onTimedID3Metadata) {\n this.onTimedID3Metadata(timed_id3_metadata);\n }\n }\n}\n\nexport default TSDemuxer;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is derived from dailymotion's hls.js library (hls.js/src/remux/mp4-generator.js)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// MP4 boxes generator for ISO BMFF (ISO Base Media File Format, defined in ISO/IEC 14496-12)\nclass MP4 {\n\n static init() {\n MP4.types = {\n avc1: [], avcC: [], btrt: [], dinf: [],\n dref: [], esds: [], ftyp: [], hdlr: [],\n hvc1: [], hvcC: [],\n mdat: [], mdhd: [], mdia: [], mfhd: [],\n minf: [], moof: [], moov: [], mp4a: [],\n mvex: [], mvhd: [], sdtp: [], stbl: [],\n stco: [], stsc: [], stsd: [], stsz: [],\n stts: [], tfdt: [], tfhd: [], traf: [],\n trak: [], trun: [], trex: [], tkhd: [],\n vmhd: [], smhd: [], '.mp3': []\n };\n\n for (let name in MP4.types) {\n if (MP4.types.hasOwnProperty(name)) {\n MP4.types[name] = [\n name.charCodeAt(0),\n name.charCodeAt(1),\n name.charCodeAt(2),\n name.charCodeAt(3)\n ];\n }\n }\n\n let constants = MP4.constants = {};\n\n constants.FTYP = new Uint8Array([\n 0x69, 0x73, 0x6F, 0x6D, // major_brand: isom\n 0x0, 0x0, 0x0, 0x1, // minor_version: 0x01\n 0x69, 0x73, 0x6F, 0x6D, // isom\n 0x61, 0x76, 0x63, 0x31 // avc1\n ]);\n\n constants.STSD_PREFIX = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x01 // entry_count\n ]);\n\n constants.STTS = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00 // entry_count\n ]);\n\n constants.STSC = constants.STCO = constants.STTS;\n\n constants.STSZ = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // sample_size\n 0x00, 0x00, 0x00, 0x00 // sample_count\n ]);\n\n constants.HDLR_VIDEO = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // pre_defined\n 0x76, 0x69, 0x64, 0x65, // handler_type: 'vide'\n 0x00, 0x00, 0x00, 0x00, // reserved: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x56, 0x69, 0x64, 0x65,\n 0x6F, 0x48, 0x61, 0x6E,\n 0x64, 0x6C, 0x65, 0x72, 0x00 // name: VideoHandler\n ]);\n\n constants.HDLR_AUDIO = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // pre_defined\n 0x73, 0x6F, 0x75, 0x6E, // handler_type: 'soun'\n 0x00, 0x00, 0x00, 0x00, // reserved: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x53, 0x6F, 0x75, 0x6E,\n 0x64, 0x48, 0x61, 0x6E,\n 0x64, 0x6C, 0x65, 0x72, 0x00 // name: SoundHandler\n ]);\n\n constants.DREF = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x01, // entry_count\n 0x00, 0x00, 0x00, 0x0C, // entry_size\n 0x75, 0x72, 0x6C, 0x20, // type 'url '\n 0x00, 0x00, 0x00, 0x01 // version(0) + flags\n ]);\n\n // Sound media header\n constants.SMHD = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00 // balance(2) + reserved(2)\n ]);\n\n // video media header\n constants.VMHD = new Uint8Array([\n 0x00, 0x00, 0x00, 0x01, // version(0) + flags\n 0x00, 0x00, // graphicsmode: 2 bytes\n 0x00, 0x00, 0x00, 0x00, // opcolor: 3 * 2 bytes\n 0x00, 0x00\n ]);\n }\n\n // Generate a box\n static box(type) {\n let size = 8;\n let result = null;\n let datas = Array.prototype.slice.call(arguments, 1);\n let arrayCount = datas.length;\n\n for (let i = 0; i < arrayCount; i++) {\n size += datas[i].byteLength;\n }\n\n result = new Uint8Array(size);\n result[0] = (size >>> 24) & 0xFF; // size\n result[1] = (size >>> 16) & 0xFF;\n result[2] = (size >>> 8) & 0xFF;\n result[3] = (size) & 0xFF;\n\n result.set(type, 4); // type\n\n let offset = 8;\n for (let i = 0; i < arrayCount; i++) { // data body\n result.set(datas[i], offset);\n offset += datas[i].byteLength;\n }\n\n return result;\n }\n\n // emit ftyp & moov\n static generateInitSegment(meta) {\n let ftyp = MP4.box(MP4.types.ftyp, MP4.constants.FTYP);\n let moov = MP4.moov(meta);\n\n let result = new Uint8Array(ftyp.byteLength + moov.byteLength);\n result.set(ftyp, 0);\n result.set(moov, ftyp.byteLength);\n return result;\n }\n\n // Movie metadata box\n static moov(meta) {\n let mvhd = MP4.mvhd(meta.timescale, meta.duration);\n let trak = MP4.trak(meta);\n let mvex = MP4.mvex(meta);\n return MP4.box(MP4.types.moov, mvhd, trak, mvex);\n }\n\n // Movie header box\n static mvhd(timescale, duration) {\n return MP4.box(MP4.types.mvhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (timescale >>> 24) & 0xFF, // timescale: 4 bytes\n (timescale >>> 16) & 0xFF,\n (timescale >>> 8) & 0xFF,\n (timescale) & 0xFF,\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x00, 0x01, 0x00, 0x00, // Preferred rate: 1.0\n 0x01, 0x00, 0x00, 0x00, // PreferredVolume(1.0, 2bytes) + reserved(2bytes)\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 + 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00, // ----begin composition matrix----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x40, 0x00, 0x00, 0x00, // ----end composition matrix----\n 0x00, 0x00, 0x00, 0x00, // ----begin pre_defined 6 * 4 bytes----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, // ----end pre_defined 6 * 4 bytes----\n 0xFF, 0xFF, 0xFF, 0xFF // next_track_ID\n ]));\n }\n\n // Track box\n static trak(meta) {\n return MP4.box(MP4.types.trak, MP4.tkhd(meta), MP4.mdia(meta));\n }\n\n // Track header box\n static tkhd(meta) {\n let trackId = meta.id, duration = meta.duration;\n let width = meta.presentWidth, height = meta.presentHeight;\n\n return MP4.box(MP4.types.tkhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x07, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (trackId >>> 24) & 0xFF, // track_ID: 4 bytes\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF,\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, // layer(2bytes) + alternate_group(2bytes)\n 0x00, 0x00, 0x00, 0x00, // volume(2bytes) + reserved(2bytes)\n 0x00, 0x01, 0x00, 0x00, // ----begin composition matrix----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x40, 0x00, 0x00, 0x00, // ----end composition matrix----\n (width >>> 8) & 0xFF, // width and height\n (width) & 0xFF,\n 0x00, 0x00,\n (height >>> 8) & 0xFF,\n (height) & 0xFF,\n 0x00, 0x00\n ]));\n }\n\n // Media Box\n static mdia(meta) {\n return MP4.box(MP4.types.mdia, MP4.mdhd(meta), MP4.hdlr(meta), MP4.minf(meta));\n }\n\n // Media header box\n static mdhd(meta) {\n let timescale = meta.timescale;\n let duration = meta.duration;\n return MP4.box(MP4.types.mdhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (timescale >>> 24) & 0xFF, // timescale: 4 bytes\n (timescale >>> 16) & 0xFF,\n (timescale >>> 8) & 0xFF,\n (timescale) & 0xFF,\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x55, 0xC4, // language: und (undetermined)\n 0x00, 0x00 // pre_defined = 0\n ]));\n }\n\n // Media handler reference box\n static hdlr(meta) {\n let data = null;\n if (meta.type === 'audio') {\n data = MP4.constants.HDLR_AUDIO;\n } else {\n data = MP4.constants.HDLR_VIDEO;\n }\n return MP4.box(MP4.types.hdlr, data);\n }\n\n // Media infomation box\n static minf(meta) {\n let xmhd = null;\n if (meta.type === 'audio') {\n xmhd = MP4.box(MP4.types.smhd, MP4.constants.SMHD);\n } else {\n xmhd = MP4.box(MP4.types.vmhd, MP4.constants.VMHD);\n }\n return MP4.box(MP4.types.minf, xmhd, MP4.dinf(), MP4.stbl(meta));\n }\n\n // Data infomation box\n static dinf() {\n let result = MP4.box(MP4.types.dinf,\n MP4.box(MP4.types.dref, MP4.constants.DREF)\n );\n return result;\n }\n\n // Sample table box\n static stbl(meta) {\n let result = MP4.box(MP4.types.stbl, // type: stbl\n MP4.stsd(meta), // Sample Description Table\n MP4.box(MP4.types.stts, MP4.constants.STTS), // Time-To-Sample\n MP4.box(MP4.types.stsc, MP4.constants.STSC), // Sample-To-Chunk\n MP4.box(MP4.types.stsz, MP4.constants.STSZ), // Sample size\n MP4.box(MP4.types.stco, MP4.constants.STCO) // Chunk offset\n ); \n return result; \n }\n\n // Sample description box\n static stsd(meta) {\n if (meta.type === 'audio') {\n if (meta.codec === 'mp3') {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.mp3(meta));\n }\n // else: aac -> mp4a\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.mp4a(meta));\n } else if (meta.type === 'video' && meta.codec.startsWith('hvc1')) {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.hvc1(meta));\n } else {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.avc1(meta));\n }\n }\n\n static mp3(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types['.mp3'], data);\n }\n\n static mp4a(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types.mp4a, data, MP4.esds(meta));\n }\n\n static esds(meta) {\n let config = meta.config || [];\n let configSize = config.length;\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version 0 + flags\n\n 0x03, // descriptor_type\n 0x17 + configSize, // length3\n 0x00, 0x01, // es_id\n 0x00, // stream_priority\n\n 0x04, // descriptor_type\n 0x0F + configSize, // length\n 0x40, // codec: mpeg4_audio\n 0x15, // stream_type: Audio\n 0x00, 0x00, 0x00, // buffer_size\n 0x00, 0x00, 0x00, 0x00, // maxBitrate\n 0x00, 0x00, 0x00, 0x00, // avgBitrate\n\n 0x05 // descriptor_type\n ].concat([\n configSize\n ]).concat(\n config\n ).concat([\n 0x06, 0x01, 0x02 // GASpecificConfig\n ]));\n return MP4.box(MP4.types.esds, data);\n }\n\n static avc1(meta) {\n let avcc = meta.avcc;\n let width = meta.codecWidth, height = meta.codecHeight;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined(2) + reserved(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n (width >>> 8) & 0xFF, // width: 2 bytes\n (width) & 0xFF,\n (height >>> 8) & 0xFF, // height: 2 bytes\n (height) & 0xFF,\n 0x00, 0x48, 0x00, 0x00, // horizresolution: 4 bytes\n 0x00, 0x48, 0x00, 0x00, // vertresolution: 4 bytes\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n 0x00, 0x01, // frame_count\n 0x0A, // strlen\n 0x78, 0x71, 0x71, 0x2F, // compressorname: 32 bytes\n 0x66, 0x6C, 0x76, 0x2E,\n 0x6A, 0x73, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00,\n 0x00, 0x18, // depth\n 0xFF, 0xFF // pre_defined = -1\n ]);\n return MP4.box(MP4.types.avc1, data, MP4.box(MP4.types.avcC, avcc));\n }\n\n static hvc1(meta) {\n let hvcc = meta.hvcc;\n let width = meta.codecWidth, height = meta.codecHeight;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined(2) + reserved(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n (width >>> 8) & 0xFF, // width: 2 bytes\n (width) & 0xFF,\n (height >>> 8) & 0xFF, // height: 2 bytes\n (height) & 0xFF,\n 0x00, 0x48, 0x00, 0x00, // horizresolution: 4 bytes\n 0x00, 0x48, 0x00, 0x00, // vertresolution: 4 bytes\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n 0x00, 0x01, // frame_count\n 0x0A, // strlen\n 0x78, 0x71, 0x71, 0x2F, // compressorname: 32 bytes\n 0x66, 0x6C, 0x76, 0x2E,\n 0x6A, 0x73, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00,\n 0x00, 0x18, // depth\n 0xFF, 0xFF // pre_defined = -1\n ]);\n return MP4.box(MP4.types.hvc1, data, MP4.box(MP4.types.hvcC, hvcc));\n }\n\n // Movie Extends box\n static mvex(meta) {\n return MP4.box(MP4.types.mvex, MP4.trex(meta));\n }\n\n // Track Extends box\n static trex(meta) {\n let trackId = meta.id;\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n (trackId >>> 24) & 0xFF, // track_ID\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF,\n 0x00, 0x00, 0x00, 0x01, // default_sample_description_index\n 0x00, 0x00, 0x00, 0x00, // default_sample_duration\n 0x00, 0x00, 0x00, 0x00, // default_sample_size\n 0x00, 0x01, 0x00, 0x01 // default_sample_flags\n ]);\n return MP4.box(MP4.types.trex, data);\n }\n\n // Movie fragment box\n static moof(track, baseMediaDecodeTime) {\n return MP4.box(MP4.types.moof, MP4.mfhd(track.sequenceNumber), MP4.traf(track, baseMediaDecodeTime));\n }\n\n static mfhd(sequenceNumber) {\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00,\n (sequenceNumber >>> 24) & 0xFF, // sequence_number: int32\n (sequenceNumber >>> 16) & 0xFF,\n (sequenceNumber >>> 8) & 0xFF,\n (sequenceNumber) & 0xFF\n ]);\n return MP4.box(MP4.types.mfhd, data);\n }\n\n // Track fragment box\n static traf(track, baseMediaDecodeTime) {\n let trackId = track.id;\n\n // Track fragment header box\n let tfhd = MP4.box(MP4.types.tfhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) & flags\n (trackId >>> 24) & 0xFF, // track_ID\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF\n ]));\n // Track Fragment Decode Time\n let tfdt = MP4.box(MP4.types.tfdt, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) & flags\n (baseMediaDecodeTime >>> 24) & 0xFF, // baseMediaDecodeTime: int32\n (baseMediaDecodeTime >>> 16) & 0xFF,\n (baseMediaDecodeTime >>> 8) & 0xFF,\n (baseMediaDecodeTime) & 0xFF\n ]));\n let sdtp = MP4.sdtp(track);\n let trun = MP4.trun(track, sdtp.byteLength + 16 + 16 + 8 + 16 + 8 + 8);\n\n return MP4.box(MP4.types.traf, tfhd, tfdt, trun, sdtp);\n }\n\n // Sample Dependency Type box\n static sdtp(track) {\n let samples = track.samples || [];\n let sampleCount = samples.length;\n let data = new Uint8Array(4 + sampleCount);\n // 0~4 bytes: version(0) & flags\n for (let i = 0; i < sampleCount; i++) {\n let flags = samples[i].flags;\n data[i + 4] = (flags.isLeading << 6) // is_leading: 2 (bit)\n | (flags.dependsOn << 4) // sample_depends_on\n | (flags.isDependedOn << 2) // sample_is_depended_on\n | (flags.hasRedundancy); // sample_has_redundancy\n }\n return MP4.box(MP4.types.sdtp, data);\n }\n\n // Track fragment run box\n static trun(track, offset) {\n let samples = track.samples || [];\n let sampleCount = samples.length;\n let dataSize = 12 + 16 * sampleCount;\n let data = new Uint8Array(dataSize);\n offset += 8 + dataSize;\n\n data.set([\n 0x00, 0x00, 0x0F, 0x01, // version(0) & flags\n (sampleCount >>> 24) & 0xFF, // sample_count\n (sampleCount >>> 16) & 0xFF,\n (sampleCount >>> 8) & 0xFF,\n (sampleCount) & 0xFF,\n (offset >>> 24) & 0xFF, // data_offset\n (offset >>> 16) & 0xFF,\n (offset >>> 8) & 0xFF,\n (offset) & 0xFF\n ], 0);\n\n for (let i = 0; i < sampleCount; i++) {\n let duration = samples[i].duration;\n let size = samples[i].size;\n let flags = samples[i].flags;\n let cts = samples[i].cts;\n data.set([\n (duration >>> 24) & 0xFF, // sample_duration\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n (size >>> 24) & 0xFF, // sample_size\n (size >>> 16) & 0xFF,\n (size >>> 8) & 0xFF,\n (size) & 0xFF,\n (flags.isLeading << 2) | flags.dependsOn, // sample_flags\n (flags.isDependedOn << 6) | (flags.hasRedundancy << 4) | flags.isNonSync,\n 0x00, 0x00, // sample_degradation_priority\n (cts >>> 24) & 0xFF, // sample_composition_time_offset\n (cts >>> 16) & 0xFF,\n (cts >>> 8) & 0xFF,\n (cts) & 0xFF\n ], 12 + 16 * i);\n }\n return MP4.box(MP4.types.trun, data);\n }\n\n static mdat(data) {\n return MP4.box(MP4.types.mdat, data);\n }\n\n}\n\nMP4.init();\n\nexport default MP4;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is modified from dailymotion's hls.js library (hls.js/src/helper/aac.js)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass AAC {\n\n static getSilentFrame(codec, channelCount) {\n if (codec === 'mp4a.40.2') {\n // handle LC-AAC\n if (channelCount === 1) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x23, 0x80]);\n } else if (channelCount === 2) {\n return new Uint8Array([0x21, 0x00, 0x49, 0x90, 0x02, 0x19, 0x00, 0x23, 0x80]);\n } else if (channelCount === 3) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x8e]);\n } else if (channelCount === 4) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x80, 0x2c, 0x80, 0x08, 0x02, 0x38]);\n } else if (channelCount === 5) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x82, 0x30, 0x04, 0x99, 0x00, 0x21, 0x90, 0x02, 0x38]);\n } else if (channelCount === 6) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x82, 0x30, 0x04, 0x99, 0x00, 0x21, 0x90, 0x02, 0x00, 0xb2, 0x00, 0x20, 0x08, 0xe0]);\n }\n } else {\n // handle HE-AAC (mp4a.40.5 / mp4a.40.29)\n if (channelCount === 1) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0:d=0.05\" -c:a libfdk_aac -profile:a aac_he -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x4e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x1c, 0x6, 0xf1, 0xc1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n } else if (channelCount === 2) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0|0:d=0.05\" -c:a libfdk_aac -profile:a aac_he_v2 -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x5e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x0, 0x95, 0x0, 0x6, 0xf1, 0xa1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n } else if (channelCount === 3) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0|0|0:d=0.05\" -c:a libfdk_aac -profile:a aac_he_v2 -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x5e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x0, 0x95, 0x0, 0x6, 0xf1, 0xa1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n }\n }\n return null;\n }\n\n}\n\nexport default AAC;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport MP4 from './mp4-generator.js';\nimport AAC from './aac-silent.js';\nimport Browser from '../utils/browser.js';\nimport { SampleInfo, MediaSegmentInfo, MediaSegmentInfoList } from '../core/media-segment-info.js';\nimport { IllegalStateException } from '../utils/exception.js';\n\n\n// Fragmented mp4 remuxer\nclass MP4Remuxer {\n\n constructor(config) {\n this.TAG = 'MP4Remuxer';\n\n this._config = config;\n this._isLive = (config.isLive === true) ? true : false;\n\n this._dtsBase = -1;\n this._dtsBaseInited = false;\n this._audioDtsBase = Infinity;\n this._videoDtsBase = Infinity;\n this._audioNextDts = undefined;\n this._videoNextDts = undefined;\n this._audioStashedLastSample = null;\n this._videoStashedLastSample = null;\n\n this._audioMeta = null;\n this._videoMeta = null;\n\n this._audioSegmentInfoList = new MediaSegmentInfoList('audio');\n this._videoSegmentInfoList = new MediaSegmentInfoList('video');\n\n this._onInitSegment = null;\n this._onMediaSegment = null;\n\n // Workaround for chrome < 50: Always force first sample as a Random Access Point in media segment\n // see https://bugs.chromium.org/p/chromium/issues/detail?id=229412\n this._forceFirstIDR = (Browser.chrome &&\n (Browser.version.major < 50 ||\n (Browser.version.major === 50 && Browser.version.build < 2661))) ? true : false;\n\n // Workaround for IE11/Edge: Fill silent aac frame after keyframe-seeking\n // Make audio beginDts equals with video beginDts, in order to fix seek freeze\n this._fillSilentAfterSeek = (Browser.msedge || Browser.msie);\n\n // While only FireFox supports 'audio/mp4, codecs=\"mp3\"', use 'audio/mpeg' for chrome, safari, ...\n this._mp3UseMpegAudio = !Browser.firefox;\n\n this._fillAudioTimestampGap = this._config.fixAudioTimestampGap;\n }\n\n destroy() {\n this._dtsBase = -1;\n this._dtsBaseInited = false;\n this._audioMeta = null;\n this._videoMeta = null;\n this._audioSegmentInfoList.clear();\n this._audioSegmentInfoList = null;\n this._videoSegmentInfoList.clear();\n this._videoSegmentInfoList = null;\n this._onInitSegment = null;\n this._onMediaSegment = null;\n }\n\n bindDataSource(producer) {\n producer.onDataAvailable = this.remux.bind(this);\n producer.onTrackMetadata = this._onTrackMetadataReceived.bind(this);\n return this;\n }\n\n /* prototype: function onInitSegment(type: string, initSegment: ArrayBuffer): void\n InitSegment: {\n type: string,\n data: ArrayBuffer,\n codec: string,\n container: string\n }\n */\n get onInitSegment() {\n return this._onInitSegment;\n }\n\n set onInitSegment(callback) {\n this._onInitSegment = callback;\n }\n\n /* prototype: function onMediaSegment(type: string, mediaSegment: MediaSegment): void\n MediaSegment: {\n type: string,\n data: ArrayBuffer,\n sampleCount: int32\n info: MediaSegmentInfo\n }\n */\n get onMediaSegment() {\n return this._onMediaSegment;\n }\n\n set onMediaSegment(callback) {\n this._onMediaSegment = callback;\n }\n\n insertDiscontinuity() {\n this._audioNextDts = this._videoNextDts = undefined;\n }\n\n seek(originalDts) {\n this._audioStashedLastSample = null;\n this._videoStashedLastSample = null;\n this._videoSegmentInfoList.clear();\n this._audioSegmentInfoList.clear();\n }\n\n remux(audioTrack, videoTrack) {\n if (!this._onMediaSegment) {\n throw new IllegalStateException('MP4Remuxer: onMediaSegment callback must be specificed!');\n }\n if (!this._dtsBaseInited) {\n this._calculateDtsBase(audioTrack, videoTrack);\n }\n if (videoTrack) {\n this._remuxVideo(videoTrack);\n }\n if (audioTrack) {\n this._remuxAudio(audioTrack);\n }\n }\n\n _onTrackMetadataReceived(type, metadata) {\n let metabox = null;\n\n let container = 'mp4';\n let codec = metadata.codec;\n\n if (type === 'audio') {\n this._audioMeta = metadata;\n if (metadata.codec === 'mp3' && this._mp3UseMpegAudio) {\n // 'audio/mpeg' for MP3 audio track\n container = 'mpeg';\n codec = '';\n metabox = new Uint8Array();\n } else {\n // 'audio/mp4, codecs=\"codec\"'\n metabox = MP4.generateInitSegment(metadata);\n }\n } else if (type === 'video') {\n this._videoMeta = metadata;\n metabox = MP4.generateInitSegment(metadata);\n } else {\n return;\n }\n\n // dispatch metabox (Initialization Segment)\n if (!this._onInitSegment) {\n throw new IllegalStateException('MP4Remuxer: onInitSegment callback must be specified!');\n }\n this._onInitSegment(type, {\n type: type,\n data: metabox.buffer,\n codec: codec,\n container: `${type}/${container}`,\n mediaDuration: metadata.duration // in timescale 1000 (milliseconds)\n });\n }\n\n _calculateDtsBase(audioTrack, videoTrack) {\n if (this._dtsBaseInited) {\n return;\n }\n\n if (audioTrack && audioTrack.samples && audioTrack.samples.length) {\n this._audioDtsBase = audioTrack.samples[0].dts;\n }\n if (videoTrack && videoTrack.samples && videoTrack.samples.length) {\n this._videoDtsBase = videoTrack.samples[0].dts;\n }\n\n this._dtsBase = Math.min(this._audioDtsBase, this._videoDtsBase);\n this._dtsBaseInited = true;\n }\n\n getTimestampBase() {\n if (!this._dtsBaseInited) {\n return undefined;\n }\n return this._dtsBase;\n }\n\n flushStashedSamples() {\n let videoSample = this._videoStashedLastSample;\n let audioSample = this._audioStashedLastSample;\n\n let videoTrack = {\n type: 'video',\n id: 1,\n sequenceNumber: 0,\n samples: [],\n length: 0\n };\n\n if (videoSample != null) {\n videoTrack.samples.push(videoSample);\n videoTrack.length = videoSample.length;\n }\n\n let audioTrack = {\n type: 'audio',\n id: 2,\n sequenceNumber: 0,\n samples: [],\n length: 0\n };\n\n if (audioSample != null) {\n audioTrack.samples.push(audioSample);\n audioTrack.length = audioSample.length;\n }\n\n this._videoStashedLastSample = null;\n this._audioStashedLastSample = null;\n\n this._remuxVideo(videoTrack, true);\n this._remuxAudio(audioTrack, true);\n }\n\n _remuxAudio(audioTrack, force) {\n if (this._audioMeta == null) {\n return;\n }\n\n let track = audioTrack;\n let samples = track.samples;\n let dtsCorrection = undefined;\n let firstDts = -1, lastDts = -1, lastPts = -1;\n let refSampleDuration = this._audioMeta.refSampleDuration;\n\n let mpegRawTrack = this._audioMeta.codec === 'mp3' && this._mp3UseMpegAudio;\n let firstSegmentAfterSeek = this._dtsBaseInited && this._audioNextDts === undefined;\n\n let insertPrefixSilentFrame = false;\n\n if (!samples || samples.length === 0) {\n return;\n }\n if (samples.length === 1 && !force) {\n // If [sample count in current batch] === 1 && (force != true)\n // Ignore and keep in demuxer's queue\n return;\n } // else if (force === true) do remux\n\n let offset = 0;\n let mdatbox = null;\n let mdatBytes = 0;\n\n // calculate initial mdat size\n if (mpegRawTrack) {\n // for raw mpeg buffer\n offset = 0;\n mdatBytes = track.length;\n } else {\n // for fmp4 mdat box\n offset = 8; // size + type\n mdatBytes = 8 + track.length;\n }\n\n\n let lastSample = null;\n\n // Pop the lastSample and waiting for stash\n if (samples.length > 1) {\n lastSample = samples.pop();\n mdatBytes -= lastSample.length;\n }\n\n // Insert [stashed lastSample in the previous batch] to the front\n if (this._audioStashedLastSample != null) {\n let sample = this._audioStashedLastSample;\n this._audioStashedLastSample = null;\n samples.unshift(sample);\n mdatBytes += sample.length;\n }\n\n // Stash the lastSample of current batch, waiting for next batch\n if (lastSample != null) {\n this._audioStashedLastSample = lastSample;\n }\n\n\n let firstSampleOriginalDts = samples[0].dts - this._dtsBase;\n\n // calculate dtsCorrection\n if (this._audioNextDts) {\n dtsCorrection = firstSampleOriginalDts - this._audioNextDts;\n } else { // this._audioNextDts == undefined\n if (this._audioSegmentInfoList.isEmpty()) {\n dtsCorrection = 0;\n if (this._fillSilentAfterSeek && !this._videoSegmentInfoList.isEmpty()) {\n if (this._audioMeta.originalCodec !== 'mp3') {\n insertPrefixSilentFrame = true;\n }\n }\n } else {\n let lastSample = this._audioSegmentInfoList.getLastSampleBefore(firstSampleOriginalDts);\n if (lastSample != null) {\n let distance = (firstSampleOriginalDts - (lastSample.originalDts + lastSample.duration));\n if (distance <= 3) {\n distance = 0;\n }\n let expectedDts = lastSample.dts + lastSample.duration + distance;\n dtsCorrection = firstSampleOriginalDts - expectedDts;\n } else { // lastSample == null, cannot found\n dtsCorrection = 0;\n }\n }\n }\n\n if (insertPrefixSilentFrame) {\n // align audio segment beginDts to match with current video segment's beginDts\n let firstSampleDts = firstSampleOriginalDts - dtsCorrection;\n let videoSegment = this._videoSegmentInfoList.getLastSegmentBefore(firstSampleOriginalDts);\n if (videoSegment != null && videoSegment.beginDts < firstSampleDts) {\n let silentUnit = AAC.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);\n if (silentUnit) {\n let dts = videoSegment.beginDts;\n let silentFrameDuration = firstSampleDts - videoSegment.beginDts;\n Log.v(this.TAG, `InsertPrefixSilentAudio: dts: ${dts}, duration: ${silentFrameDuration}`);\n samples.unshift({ unit: silentUnit, dts: dts, pts: dts });\n mdatBytes += silentUnit.byteLength;\n } // silentUnit == null: Cannot generate, skip\n } else {\n insertPrefixSilentFrame = false;\n }\n }\n\n let mp4Samples = [];\n\n // Correct dts for each sample, and calculate sample duration. Then output to mp4Samples\n for (let i = 0; i < samples.length; i++) {\n let sample = samples[i];\n let unit = sample.unit;\n let originalDts = sample.dts - this._dtsBase;\n let dts = originalDts;\n let needFillSilentFrames = false;\n let silentFrames = null;\n let sampleDuration = 0;\n\n if (originalDts < -0.001) {\n continue; //pass the first sample with the invalid dts\n }\n\n if (this._audioMeta.codec !== 'mp3') {\n // for AAC codec, we need to keep dts increase based on refSampleDuration\n let curRefDts = originalDts;\n const maxAudioFramesDrift = 3;\n if (this._audioNextDts) {\n curRefDts = this._audioNextDts;\n }\n\n dtsCorrection = originalDts - curRefDts;\n if (dtsCorrection <= -maxAudioFramesDrift * refSampleDuration) {\n // If we're overlapping by more than maxAudioFramesDrift number of frame, drop this sample\n Log.w(this.TAG, `Dropping 1 audio frame (originalDts: ${originalDts} ms ,curRefDts: ${curRefDts} ms) due to dtsCorrection: ${dtsCorrection} ms overlap.`);\n continue;\n }\n else if (dtsCorrection >= maxAudioFramesDrift * refSampleDuration && this._fillAudioTimestampGap && !Browser.safari) {\n // Silent frame generation, if large timestamp gap detected && config.fixAudioTimestampGap\n needFillSilentFrames = true;\n // We need to insert silent frames to fill timestamp gap\n let frameCount = Math.floor(dtsCorrection / refSampleDuration);\n Log.w(this.TAG, 'Large audio timestamp gap detected, may cause AV sync to drift. ' +\n 'Silent frames will be generated to avoid unsync.\\n' +\n `originalDts: ${originalDts} ms, curRefDts: ${curRefDts} ms, ` +\n `dtsCorrection: ${Math.round(dtsCorrection)} ms, generate: ${frameCount} frames`);\n\n\n dts = Math.floor(curRefDts);\n sampleDuration = Math.floor(curRefDts + refSampleDuration) - dts;\n\n let silentUnit = AAC.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);\n if (silentUnit == null) {\n Log.w(this.TAG, 'Unable to generate silent frame for ' +\n `${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`);\n // Repeat last frame\n silentUnit = unit;\n }\n silentFrames = [];\n\n for (let j = 0; j < frameCount; j++) {\n curRefDts = curRefDts + refSampleDuration;\n let intDts = Math.floor(curRefDts); // change to integer\n let intDuration = Math.floor(curRefDts + refSampleDuration) - intDts;\n let frame = {\n dts: intDts,\n pts: intDts,\n cts: 0,\n unit: silentUnit,\n size: silentUnit.byteLength,\n duration: intDuration, // wait for next sample\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: 1,\n isDependedOn: 0,\n hasRedundancy: 0\n }\n };\n silentFrames.push(frame);\n mdatBytes += frame.size;;\n\n }\n\n this._audioNextDts = curRefDts + refSampleDuration;\n\n } else {\n\n dts = Math.floor(curRefDts);\n sampleDuration = Math.floor(curRefDts + refSampleDuration) - dts;\n this._audioNextDts = curRefDts + refSampleDuration;\n\n }\n } else {\n // keep the original dts calculate algorithm for mp3\n dts = originalDts - dtsCorrection;\n\n\n if (i !== samples.length - 1) {\n let nextDts = samples[i + 1].dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else { // the last sample\n if (lastSample != null) { // use stashed sample's dts to calculate sample duration\n let nextDts = lastSample.dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else if (mp4Samples.length >= 1) { // use second last sample duration\n sampleDuration = mp4Samples[mp4Samples.length - 1].duration;\n } else { // the only one sample, use reference sample duration\n sampleDuration = Math.floor(refSampleDuration);\n }\n }\n this._audioNextDts = dts + sampleDuration;\n }\n\n if (firstDts === -1) {\n firstDts = dts;\n }\n mp4Samples.push({\n dts: dts,\n pts: dts,\n cts: 0,\n unit: sample.unit,\n size: sample.unit.byteLength,\n duration: sampleDuration,\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: 1,\n isDependedOn: 0,\n hasRedundancy: 0\n }\n });\n\n if (needFillSilentFrames) {\n // Silent frames should be inserted after wrong-duration frame\n mp4Samples.push.apply(mp4Samples, silentFrames);\n }\n }\n\n if (mp4Samples.length === 0) {\n //no samples need to remux\n track.samples = [];\n track.length = 0;\n return;\n }\n\n // allocate mdatbox\n if (mpegRawTrack) {\n // allocate for raw mpeg buffer\n mdatbox = new Uint8Array(mdatBytes);\n } else {\n // allocate for fmp4 mdat box\n mdatbox = new Uint8Array(mdatBytes);\n // size field\n mdatbox[0] = (mdatBytes >>> 24) & 0xFF;\n mdatbox[1] = (mdatBytes >>> 16) & 0xFF;\n mdatbox[2] = (mdatBytes >>> 8) & 0xFF;\n mdatbox[3] = (mdatBytes) & 0xFF;\n // type field (fourCC)\n mdatbox.set(MP4.types.mdat, 4);\n }\n\n // Write samples into mdatbox\n for (let i = 0; i < mp4Samples.length; i++) {\n let unit = mp4Samples[i].unit;\n mdatbox.set(unit, offset);\n offset += unit.byteLength;\n }\n\n let latest = mp4Samples[mp4Samples.length - 1];\n lastDts = latest.dts + latest.duration;\n //this._audioNextDts = lastDts;\n\n // fill media segment info & add to info list\n let info = new MediaSegmentInfo();\n info.beginDts = firstDts;\n info.endDts = lastDts;\n info.beginPts = firstDts;\n info.endPts = lastDts;\n info.originalBeginDts = mp4Samples[0].originalDts;\n info.originalEndDts = latest.originalDts + latest.duration;\n info.firstSample = new SampleInfo(mp4Samples[0].dts,\n mp4Samples[0].pts,\n mp4Samples[0].duration,\n mp4Samples[0].originalDts,\n false);\n info.lastSample = new SampleInfo(latest.dts,\n latest.pts,\n latest.duration,\n latest.originalDts,\n false);\n if (!this._isLive) {\n this._audioSegmentInfoList.append(info);\n }\n\n track.samples = mp4Samples;\n track.sequenceNumber++;\n\n let moofbox = null;\n\n if (mpegRawTrack) {\n // Generate empty buffer, because useless for raw mpeg\n moofbox = new Uint8Array();\n } else {\n // Generate moof for fmp4 segment\n moofbox = MP4.moof(track, firstDts);\n }\n\n track.samples = [];\n track.length = 0;\n\n let segment = {\n type: 'audio',\n data: this._mergeBoxes(moofbox, mdatbox).buffer,\n sampleCount: mp4Samples.length,\n info: info\n };\n\n if (mpegRawTrack && firstSegmentAfterSeek) {\n // For MPEG audio stream in MSE, if seeking occurred, before appending new buffer\n // We need explicitly set timestampOffset to the desired point in timeline for mpeg SourceBuffer.\n segment.timestampOffset = firstDts;\n }\n\n this._onMediaSegment('audio', segment);\n }\n\n _remuxVideo(videoTrack, force) {\n if (this._videoMeta == null) {\n return;\n }\n\n let track = videoTrack;\n let samples = track.samples;\n let dtsCorrection = undefined;\n let firstDts = -1, lastDts = -1;\n let firstPts = -1, lastPts = -1;\n\n if (!samples || samples.length === 0) {\n return;\n }\n if (samples.length === 1 && !force) {\n // If [sample count in current batch] === 1 && (force != true)\n // Ignore and keep in demuxer's queue\n return;\n } // else if (force === true) do remux\n\n let offset = 8;\n let mdatbox = null;\n let mdatBytes = 8 + videoTrack.length;\n\n\n let lastSample = null;\n\n // Pop the lastSample and waiting for stash\n if (samples.length > 1) {\n lastSample = samples.pop();\n mdatBytes -= lastSample.length;\n }\n\n // Insert [stashed lastSample in the previous batch] to the front\n if (this._videoStashedLastSample != null) {\n let sample = this._videoStashedLastSample;\n this._videoStashedLastSample = null;\n samples.unshift(sample);\n mdatBytes += sample.length;\n }\n\n // Stash the lastSample of current batch, waiting for next batch\n if (lastSample != null) {\n this._videoStashedLastSample = lastSample;\n }\n\n\n let firstSampleOriginalDts = samples[0].dts - this._dtsBase;\n\n // calculate dtsCorrection\n if (this._videoNextDts) {\n dtsCorrection = firstSampleOriginalDts - this._videoNextDts;\n } else { // this._videoNextDts == undefined\n if (this._videoSegmentInfoList.isEmpty()) {\n dtsCorrection = 0;\n } else {\n let lastSample = this._videoSegmentInfoList.getLastSampleBefore(firstSampleOriginalDts);\n if (lastSample != null) {\n let distance = (firstSampleOriginalDts - (lastSample.originalDts + lastSample.duration));\n if (distance <= 3) {\n distance = 0;\n }\n let expectedDts = lastSample.dts + lastSample.duration + distance;\n dtsCorrection = firstSampleOriginalDts - expectedDts;\n } else { // lastSample == null, cannot found\n dtsCorrection = 0;\n }\n }\n }\n\n let info = new MediaSegmentInfo();\n let mp4Samples = [];\n\n // Correct dts for each sample, and calculate sample duration. Then output to mp4Samples\n for (let i = 0; i < samples.length; i++) {\n let sample = samples[i];\n let originalDts = sample.dts - this._dtsBase;\n let isKeyframe = sample.isKeyframe;\n let dts = originalDts - dtsCorrection;\n let cts = sample.cts;\n let pts = dts + cts;\n\n if (firstDts === -1) {\n firstDts = dts;\n firstPts = pts;\n }\n\n let sampleDuration = 0;\n\n if (i !== samples.length - 1) {\n let nextDts = samples[i + 1].dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else { // the last sample\n if (lastSample != null) { // use stashed sample's dts to calculate sample duration\n let nextDts = lastSample.dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else if (mp4Samples.length >= 1) { // use second last sample duration\n sampleDuration = mp4Samples[mp4Samples.length - 1].duration;\n } else { // the only one sample, use reference sample duration\n sampleDuration = Math.floor(this._videoMeta.refSampleDuration);\n }\n }\n\n if (isKeyframe) {\n let syncPoint = new SampleInfo(dts, pts, sampleDuration, sample.dts, true);\n syncPoint.fileposition = sample.fileposition;\n info.appendSyncPoint(syncPoint);\n }\n\n mp4Samples.push({\n dts: dts,\n pts: pts,\n cts: cts,\n units: sample.units,\n size: sample.length,\n isKeyframe: isKeyframe,\n duration: sampleDuration,\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: isKeyframe ? 2 : 1,\n isDependedOn: isKeyframe ? 1 : 0,\n hasRedundancy: 0,\n isNonSync: isKeyframe ? 0 : 1\n }\n });\n }\n\n // allocate mdatbox\n mdatbox = new Uint8Array(mdatBytes);\n mdatbox[0] = (mdatBytes >>> 24) & 0xFF;\n mdatbox[1] = (mdatBytes >>> 16) & 0xFF;\n mdatbox[2] = (mdatBytes >>> 8) & 0xFF;\n mdatbox[3] = (mdatBytes) & 0xFF;\n mdatbox.set(MP4.types.mdat, 4);\n\n // Write samples into mdatbox\n for (let i = 0; i < mp4Samples.length; i++) {\n let units = mp4Samples[i].units;\n while (units.length) {\n let unit = units.shift();\n let data = unit.data;\n mdatbox.set(data, offset);\n offset += data.byteLength;\n }\n }\n\n let latest = mp4Samples[mp4Samples.length - 1];\n lastDts = latest.dts + latest.duration;\n lastPts = latest.pts + latest.duration;\n this._videoNextDts = lastDts;\n\n // fill media segment info & add to info list\n info.beginDts = firstDts;\n info.endDts = lastDts;\n info.beginPts = firstPts;\n info.endPts = lastPts;\n info.originalBeginDts = mp4Samples[0].originalDts;\n info.originalEndDts = latest.originalDts + latest.duration;\n info.firstSample = new SampleInfo(mp4Samples[0].dts,\n mp4Samples[0].pts,\n mp4Samples[0].duration,\n mp4Samples[0].originalDts,\n mp4Samples[0].isKeyframe);\n info.lastSample = new SampleInfo(latest.dts,\n latest.pts,\n latest.duration,\n latest.originalDts,\n latest.isKeyframe);\n if (!this._isLive) {\n this._videoSegmentInfoList.append(info);\n }\n\n track.samples = mp4Samples;\n track.sequenceNumber++;\n\n // workaround for chrome < 50: force first sample as a random access point\n // see https://bugs.chromium.org/p/chromium/issues/detail?id=229412\n if (this._forceFirstIDR) {\n let flags = mp4Samples[0].flags;\n flags.dependsOn = 2;\n flags.isNonSync = 0;\n }\n\n let moofbox = MP4.moof(track, firstDts);\n track.samples = [];\n track.length = 0;\n\n this._onMediaSegment('video', {\n type: 'video',\n data: this._mergeBoxes(moofbox, mdatbox).buffer,\n sampleCount: mp4Samples.length,\n info: info\n });\n }\n\n _mergeBoxes(moof, mdat) {\n let result = new Uint8Array(moof.byteLength + mdat.byteLength);\n result.set(moof, 0);\n result.set(mdat, moof.byteLength);\n return result;\n }\n\n}\n\nexport default MP4Remuxer;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport MediaInfo from './media-info.js';\nimport FLVDemuxer from '../demux/flv-demuxer.js';\nimport TSDemuxer from '../demux/ts-demuxer';\nimport MP4Remuxer from '../remux/mp4-remuxer.js';\nimport DemuxErrors from '../demux/demux-errors.js';\nimport IOController from '../io/io-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\nimport {LoaderStatus, LoaderErrors} from '../io/loader.js';\n\n// Transmuxing (IO, Demuxing, Remuxing) controller, with multipart support\nclass TransmuxingController {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'TransmuxingController';\n this._emitter = new EventEmitter();\n\n this._config = config;\n\n // treat single part media as multipart media, which has only one segment\n if (!mediaDataSource.segments) {\n mediaDataSource.segments = [{\n duration: mediaDataSource.duration,\n filesize: mediaDataSource.filesize,\n url: mediaDataSource.url\n }];\n }\n\n // fill in default IO params if not exists\n if (typeof mediaDataSource.cors !== 'boolean') {\n mediaDataSource.cors = true;\n }\n if (typeof mediaDataSource.withCredentials !== 'boolean') {\n mediaDataSource.withCredentials = false;\n }\n\n this._mediaDataSource = mediaDataSource;\n this._currentSegmentIndex = 0;\n let totalDuration = 0;\n\n this._mediaDataSource.segments.forEach((segment) => {\n // timestampBase for each segment, and calculate total duration\n segment.timestampBase = totalDuration;\n totalDuration += segment.duration;\n // params needed by IOController\n segment.cors = mediaDataSource.cors;\n segment.withCredentials = mediaDataSource.withCredentials;\n // referrer policy control, if exist\n if (config.referrerPolicy) {\n segment.referrerPolicy = config.referrerPolicy;\n }\n });\n\n if (!isNaN(totalDuration) && this._mediaDataSource.duration !== totalDuration) {\n this._mediaDataSource.duration = totalDuration;\n }\n\n this._mediaInfo = null;\n this._demuxer = null;\n this._remuxer = null;\n this._ioctl = null;\n\n this._pendingSeekTime = null;\n this._pendingResolveSeekPoint = null;\n\n this._statisticsReporter = null;\n }\n\n destroy() {\n this._mediaInfo = null;\n this._mediaDataSource = null;\n\n if (this._statisticsReporter) {\n this._disableStatisticsReporter();\n }\n if (this._ioctl) {\n this._ioctl.destroy();\n this._ioctl = null;\n }\n if (this._demuxer) {\n this._demuxer.destroy();\n this._demuxer = null;\n }\n if (this._remuxer) {\n this._remuxer.destroy();\n this._remuxer = null;\n }\n\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n start() {\n this._loadSegment(0);\n this._enableStatisticsReporter();\n }\n\n _loadSegment(segmentIndex, optionalFrom) {\n this._currentSegmentIndex = segmentIndex;\n let dataSource = this._mediaDataSource.segments[segmentIndex];\n\n let ioctl = this._ioctl = new IOController(dataSource, this._config, segmentIndex);\n ioctl.onError = this._onIOException.bind(this);\n ioctl.onSeeked = this._onIOSeeked.bind(this);\n ioctl.onComplete = this._onIOComplete.bind(this);\n ioctl.onRedirect = this._onIORedirect.bind(this);\n ioctl.onRecoveredEarlyEof = this._onIORecoveredEarlyEof.bind(this);\n\n if (optionalFrom) {\n this._demuxer.bindDataSource(this._ioctl);\n } else {\n ioctl.onDataArrival = this._onInitChunkArrival.bind(this);\n }\n\n ioctl.open(optionalFrom);\n }\n\n stop() {\n this._internalAbort();\n this._disableStatisticsReporter();\n }\n\n _internalAbort() {\n if (this._ioctl) {\n this._ioctl.destroy();\n this._ioctl = null;\n }\n }\n\n pause() { // take a rest\n if (this._ioctl && this._ioctl.isWorking()) {\n this._ioctl.pause();\n this._disableStatisticsReporter();\n }\n }\n\n resume() {\n if (this._ioctl && this._ioctl.isPaused()) {\n this._ioctl.resume();\n this._enableStatisticsReporter();\n }\n }\n\n seek(milliseconds) {\n if (this._mediaInfo == null || !this._mediaInfo.isSeekable()) {\n return;\n }\n\n let targetSegmentIndex = this._searchSegmentIndexContains(milliseconds);\n\n if (targetSegmentIndex === this._currentSegmentIndex) {\n // intra-segment seeking\n let segmentInfo = this._mediaInfo.segments[targetSegmentIndex];\n\n if (segmentInfo == undefined) {\n // current segment loading started, but mediainfo hasn't received yet\n // wait for the metadata loaded, then seek to expected position\n this._pendingSeekTime = milliseconds;\n } else {\n let keyframe = segmentInfo.getNearestKeyframe(milliseconds);\n this._remuxer.seek(keyframe.milliseconds);\n this._ioctl.seek(keyframe.fileposition);\n // Will be resolved in _onRemuxerMediaSegmentArrival()\n this._pendingResolveSeekPoint = keyframe.milliseconds;\n }\n } else {\n // cross-segment seeking\n let targetSegmentInfo = this._mediaInfo.segments[targetSegmentIndex];\n\n if (targetSegmentInfo == undefined) {\n // target segment hasn't been loaded. We need metadata then seek to expected time\n this._pendingSeekTime = milliseconds;\n this._internalAbort();\n this._remuxer.seek();\n this._remuxer.insertDiscontinuity();\n this._loadSegment(targetSegmentIndex);\n // Here we wait for the metadata loaded, then seek to expected position\n } else {\n // We have target segment's metadata, direct seek to target position\n let keyframe = targetSegmentInfo.getNearestKeyframe(milliseconds);\n this._internalAbort();\n this._remuxer.seek(milliseconds);\n this._remuxer.insertDiscontinuity();\n this._demuxer.resetMediaInfo();\n this._demuxer.timestampBase = this._mediaDataSource.segments[targetSegmentIndex].timestampBase;\n this._loadSegment(targetSegmentIndex, keyframe.fileposition);\n this._pendingResolveSeekPoint = keyframe.milliseconds;\n this._reportSegmentMediaInfo(targetSegmentIndex);\n }\n }\n\n this._enableStatisticsReporter();\n }\n\n _searchSegmentIndexContains(milliseconds) {\n let segments = this._mediaDataSource.segments;\n let idx = segments.length - 1;\n\n for (let i = 0; i < segments.length; i++) {\n if (milliseconds < segments[i].timestampBase) {\n idx = i - 1;\n break;\n }\n }\n return idx;\n }\n\n _onInitChunkArrival(data, byteStart) {\n let probeData = null;\n let consumed = 0;\n\n if (byteStart > 0) {\n // IOController seeked immediately after opened, byteStart > 0 callback may received\n this._demuxer.bindDataSource(this._ioctl);\n this._demuxer.timestampBase = this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase;\n\n consumed = this._demuxer.parseChunks(data, byteStart);\n } else if ((probeData = TSDemuxer.probe(data)).match) {\n let demuxer = this._demuxer = new TSDemuxer(probeData, this._config);\n\n if (!this._remuxer) {\n this._remuxer = new MP4Remuxer(this._config);\n }\n\n demuxer.onError = this._onDemuxException.bind(this);\n demuxer.onMediaInfo = this._onMediaInfo.bind(this);\n demuxer.onMetaDataArrived = this._onMetaDataArrived.bind(this);\n demuxer.onTimedID3Metadata = this._onTimedID3Metadata.bind(this);\n demuxer.onSCTE35Metadata = this._onSCTE35Metadata.bind(this);\n demuxer.onPESPrivateDataDescriptor = this._onPESPrivateDataDescriptor.bind(this);\n demuxer.onPESPrivateData = this._onPESPrivateData.bind(this);\n\n this._remuxer.bindDataSource(this._demuxer);\n this._demuxer.bindDataSource(this._ioctl);\n\n this._remuxer.onInitSegment = this._onRemuxerInitSegmentArrival.bind(this);\n this._remuxer.onMediaSegment = this._onRemuxerMediaSegmentArrival.bind(this);\n\n consumed = this._demuxer.parseChunks(data, byteStart);\n } else if ((probeData = FLVDemuxer.probe(data)).match) {\n // Always create new FLVDemuxer\n this._demuxer = new FLVDemuxer(probeData, this._config);\n\n if (!this._remuxer) {\n this._remuxer = new MP4Remuxer(this._config);\n }\n\n let mds = this._mediaDataSource;\n if (mds.duration != undefined && !isNaN(mds.duration)) {\n this._demuxer.overridedDuration = mds.duration;\n }\n if (typeof mds.hasAudio === 'boolean') {\n this._demuxer.overridedHasAudio = mds.hasAudio;\n }\n if (typeof mds.hasVideo === 'boolean') {\n this._demuxer.overridedHasVideo = mds.hasVideo;\n }\n\n this._demuxer.timestampBase = mds.segments[this._currentSegmentIndex].timestampBase;\n\n this._demuxer.onError = this._onDemuxException.bind(this);\n this._demuxer.onMediaInfo = this._onMediaInfo.bind(this);\n this._demuxer.onMetaDataArrived = this._onMetaDataArrived.bind(this);\n this._demuxer.onScriptDataArrived = this._onScriptDataArrived.bind(this);\n\n this._remuxer.bindDataSource(this._demuxer\n .bindDataSource(this._ioctl\n ));\n\n this._remuxer.onInitSegment = this._onRemuxerInitSegmentArrival.bind(this);\n this._remuxer.onMediaSegment = this._onRemuxerMediaSegmentArrival.bind(this);\n\n consumed = this._demuxer.parseChunks(data, byteStart);\n } else {\n probeData = null;\n Log.e(this.TAG, 'Non MPEG-TS/FLV, Unsupported media type!');\n Promise.resolve().then(() => {\n this._internalAbort();\n });\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, DemuxErrors.FORMAT_UNSUPPORTED, 'Non MPEG-TS/FLV, Unsupported media type!');\n\n consumed = 0;\n }\n\n return consumed;\n }\n\n _onMediaInfo(mediaInfo) {\n if (this._mediaInfo == null) {\n // Store first segment's mediainfo as global mediaInfo\n this._mediaInfo = Object.assign({}, mediaInfo);\n this._mediaInfo.keyframesIndex = null;\n this._mediaInfo.segments = [];\n this._mediaInfo.segmentCount = this._mediaDataSource.segments.length;\n Object.setPrototypeOf(this._mediaInfo, MediaInfo.prototype);\n }\n\n let segmentInfo = Object.assign({}, mediaInfo);\n Object.setPrototypeOf(segmentInfo, MediaInfo.prototype);\n this._mediaInfo.segments[this._currentSegmentIndex] = segmentInfo;\n\n // notify mediaInfo update\n this._reportSegmentMediaInfo(this._currentSegmentIndex);\n\n if (this._pendingSeekTime != null) {\n Promise.resolve().then(() => {\n let target = this._pendingSeekTime;\n this._pendingSeekTime = null;\n this.seek(target);\n });\n }\n }\n\n _onMetaDataArrived(metadata) {\n this._emitter.emit(TransmuxingEvents.METADATA_ARRIVED, metadata);\n }\n\n _onScriptDataArrived(data) {\n this._emitter.emit(TransmuxingEvents.SCRIPTDATA_ARRIVED, data);\n }\n\n _onTimedID3Metadata(timed_id3_metadata) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (timed_id3_metadata.pts != undefined) {\n timed_id3_metadata.pts -= timestamp_base;\n }\n\n if (timed_id3_metadata.dts != undefined) {\n timed_id3_metadata.dts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, timed_id3_metadata);\n }\n\n _onSCTE35Metadata(scte35) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (scte35.pts != undefined) {\n scte35.pts -= timestamp_base;\n }\n\n if (scte35.nearest_pts != undefined) {\n scte35.nearest_pts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.SCTE35_METADATA_ARRIVED, scte35);\n }\n\n _onPESPrivateDataDescriptor(descriptor) {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, descriptor);\n }\n\n _onPESPrivateData(private_data) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (private_data.pts != undefined) {\n private_data.pts -= timestamp_base;\n }\n\n if (private_data.nearest_pts != undefined) {\n private_data.nearest_pts -= timestamp_base;\n }\n\n if (private_data.dts != undefined) {\n private_data.dts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, private_data);\n }\n\n _onIOSeeked() {\n this._remuxer.insertDiscontinuity();\n }\n\n _onIOComplete(extraData) {\n let segmentIndex = extraData;\n let nextSegmentIndex = segmentIndex + 1;\n\n if (nextSegmentIndex < this._mediaDataSource.segments.length) {\n this._internalAbort();\n if (this._remuxer) {\n this._remuxer.flushStashedSamples();\n }\n this._loadSegment(nextSegmentIndex);\n } else {\n if (this._remuxer) {\n this._remuxer.flushStashedSamples();\n }\n this._emitter.emit(TransmuxingEvents.LOADING_COMPLETE);\n this._disableStatisticsReporter();\n }\n }\n\n _onIORedirect(redirectedURL) {\n let segmentIndex = this._ioctl.extraData;\n this._mediaDataSource.segments[segmentIndex].redirectedURL = redirectedURL;\n }\n\n _onIORecoveredEarlyEof() {\n this._emitter.emit(TransmuxingEvents.RECOVERED_EARLY_EOF);\n }\n\n _onIOException(type, info) {\n Log.e(this.TAG, `IOException: type = ${type}, code = ${info.code}, msg = ${info.msg}`);\n this._emitter.emit(TransmuxingEvents.IO_ERROR, type, info);\n this._disableStatisticsReporter();\n }\n\n _onDemuxException(type, info) {\n Log.e(this.TAG, `DemuxException: type = ${type}, info = ${info}`);\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, type, info);\n }\n\n _onRemuxerInitSegmentArrival(type, initSegment) {\n this._emitter.emit(TransmuxingEvents.INIT_SEGMENT, type, initSegment);\n }\n\n _onRemuxerMediaSegmentArrival(type, mediaSegment) {\n if (this._pendingSeekTime != null) {\n // Media segments after new-segment cross-seeking should be dropped.\n return;\n }\n this._emitter.emit(TransmuxingEvents.MEDIA_SEGMENT, type, mediaSegment);\n\n // Resolve pending seekPoint\n if (this._pendingResolveSeekPoint != null && type === 'video') {\n let syncPoints = mediaSegment.info.syncPoints;\n let seekpoint = this._pendingResolveSeekPoint;\n this._pendingResolveSeekPoint = null;\n\n // Safari: Pass PTS for recommend_seekpoint\n if (Browser.safari && syncPoints.length > 0 && syncPoints[0].originalDts === seekpoint) {\n seekpoint = syncPoints[0].pts;\n }\n // else: use original DTS (keyframe.milliseconds)\n\n this._emitter.emit(TransmuxingEvents.RECOMMEND_SEEKPOINT, seekpoint);\n }\n }\n\n _enableStatisticsReporter() {\n if (this._statisticsReporter == null) {\n this._statisticsReporter = self.setInterval(\n this._reportStatisticsInfo.bind(this),\n this._config.statisticsInfoReportInterval);\n }\n }\n\n _disableStatisticsReporter() {\n if (this._statisticsReporter) {\n self.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n _reportSegmentMediaInfo(segmentIndex) {\n let segmentInfo = this._mediaInfo.segments[segmentIndex];\n let exportInfo = Object.assign({}, segmentInfo);\n\n exportInfo.duration = this._mediaInfo.duration;\n exportInfo.segmentCount = this._mediaInfo.segmentCount;\n delete exportInfo.segments;\n delete exportInfo.keyframesIndex;\n\n this._emitter.emit(TransmuxingEvents.MEDIA_INFO, exportInfo);\n }\n\n _reportStatisticsInfo() {\n let info = {};\n\n info.url = this._ioctl.currentURL;\n info.hasRedirect = this._ioctl.hasRedirect;\n if (info.hasRedirect) {\n info.redirectedURL = this._ioctl.currentRedirectedURL;\n }\n\n info.speed = this._ioctl.currentSpeed;\n info.loaderType = this._ioctl.loaderType;\n info.currentSegmentIndex = this._currentSegmentIndex;\n info.totalSegmentCount = this._mediaDataSource.segments.length;\n\n this._emitter.emit(TransmuxingEvents.STATISTICS_INFO, info);\n }\n\n}\n\nexport default TransmuxingController;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Utility class to calculate realtime network I/O speed\nclass SpeedSampler {\n\n constructor() {\n // milliseconds\n this._firstCheckpoint = 0;\n this._lastCheckpoint = 0;\n this._intervalBytes = 0;\n this._totalBytes = 0;\n this._lastSecondBytes = 0;\n\n // compatibility detection\n if (self.performance && self.performance.now) {\n this._now = self.performance.now.bind(self.performance);\n } else {\n this._now = Date.now;\n }\n }\n\n reset() {\n this._firstCheckpoint = this._lastCheckpoint = 0;\n this._totalBytes = this._intervalBytes = 0;\n this._lastSecondBytes = 0;\n }\n\n addBytes(bytes) {\n if (this._firstCheckpoint === 0) {\n this._firstCheckpoint = this._now();\n this._lastCheckpoint = this._firstCheckpoint;\n this._intervalBytes += bytes;\n this._totalBytes += bytes;\n } else if (this._now() - this._lastCheckpoint < 1000) {\n this._intervalBytes += bytes;\n this._totalBytes += bytes;\n } else { // duration >= 1000\n this._lastSecondBytes = this._intervalBytes;\n this._intervalBytes = bytes;\n this._totalBytes += bytes;\n this._lastCheckpoint = this._now();\n }\n }\n\n get currentKBps() {\n this.addBytes(0);\n\n let durationSeconds = (this._now() - this._lastCheckpoint) / 1000;\n if (durationSeconds == 0) durationSeconds = 1;\n return (this._intervalBytes / durationSeconds) / 1024;\n }\n\n get lastSecondKBps() {\n this.addBytes(0);\n\n if (this._lastSecondBytes !== 0) {\n return this._lastSecondBytes / 1024;\n } else { // lastSecondBytes === 0\n if (this._now() - this._lastCheckpoint >= 500) {\n // if time interval since last checkpoint has exceeded 500ms\n // the speed is nearly accurate\n return this.currentKBps;\n } else {\n // We don't know\n return 0;\n }\n }\n }\n\n get averageKBps() {\n let durationSeconds = (this._now() - this._firstCheckpoint) / 1000;\n return (this._totalBytes / durationSeconds) / 1024;\n }\n\n}\n\nexport default SpeedSampler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n/* fetch + stream IO loader. Currently working on chrome 43+.\n * fetch provides a better alternative http API to XMLHttpRequest\n *\n * fetch spec https://fetch.spec.whatwg.org/\n * stream spec https://streams.spec.whatwg.org/\n */\nclass FetchStreamLoader extends BaseLoader {\n\n static isSupported() {\n try {\n // fetch + stream is broken on Microsoft Edge. Disable before build 15048.\n // see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8196907/\n // Fixed in Jan 10, 2017. Build 15048+ removed from blacklist.\n let isWorkWellEdge = Browser.msedge && Browser.version.minor >= 15048;\n let browserNotBlacklisted = Browser.msedge ? isWorkWellEdge : true;\n return (self.fetch && self.ReadableStream && browserNotBlacklisted);\n } catch (e) {\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('fetch-stream-loader');\n this.TAG = 'FetchStreamLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = true;\n\n this._requestAbort = false;\n this._abortController = null;\n this._contentLength = null;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n super.destroy();\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL && dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n\n let headers = new self.Headers();\n\n if (typeof seekConfig.headers === 'object') {\n let configHeaders = seekConfig.headers;\n for (let key in configHeaders) {\n if (configHeaders.hasOwnProperty(key)) {\n headers.append(key, configHeaders[key]);\n }\n }\n }\n\n let params = {\n method: 'GET',\n headers: headers,\n mode: 'cors',\n cache: 'default',\n // The default policy of Fetch API in the whatwg standard\n // Safari incorrectly indicates 'no-referrer' as default policy, fuck it\n referrerPolicy: 'no-referrer-when-downgrade'\n };\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n for (let key in this._config.headers) {\n headers.append(key, this._config.headers[key]);\n }\n }\n\n // cors is enabled by default\n if (dataSource.cors === false) {\n // no-cors means 'disregard cors policy', which can only be used in ServiceWorker\n params.mode = 'same-origin';\n }\n\n // withCredentials is disabled by default\n if (dataSource.withCredentials) {\n params.credentials = 'include';\n }\n\n // referrerPolicy from config\n if (dataSource.referrerPolicy) {\n params.referrerPolicy = dataSource.referrerPolicy;\n }\n\n if (self.AbortController) {\n this._abortController = new self.AbortController();\n params.signal = this._abortController.signal;\n }\n\n this._status = LoaderStatus.kConnecting;\n self.fetch(seekConfig.url, params).then((res) => {\n if (this._requestAbort) {\n this._status = LoaderStatus.kIdle;\n res.body.cancel();\n return;\n }\n if (res.ok && (res.status >= 200 && res.status <= 299)) {\n if (res.url !== seekConfig.url) {\n if (this._onURLRedirect) {\n let redirectedURL = this._seekHandler.removeURLParameters(res.url);\n this._onURLRedirect(redirectedURL);\n }\n }\n\n let lengthHeader = res.headers.get('Content-Length');\n if (lengthHeader != null) {\n this._contentLength = parseInt(lengthHeader);\n if (this._contentLength !== 0) {\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n }\n\n return this._pump.call(this, res.body.getReader());\n } else {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: res.status, msg: res.statusText});\n } else {\n throw new RuntimeException('FetchStreamLoader: Http code invalid, ' + res.status + ' ' + res.statusText);\n }\n }\n }).catch((e) => {\n if (this._abortController && this._abortController.signal.aborted) {\n return;\n }\n\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, {code: -1, msg: e.message});\n } else {\n throw e;\n }\n });\n }\n\n abort() {\n this._requestAbort = true;\n\n if (this._status !== LoaderStatus.kBuffering || !Browser.chrome) {\n // Chrome may throw Exception-like things here, avoid using if is buffering\n if (this._abortController) {\n try {\n this._abortController.abort();\n } catch (e) {}\n }\n }\n }\n\n _pump(reader) { // ReadableStreamReader\n return reader.read().then((result) => {\n if (result.done) {\n // First check received length\n if (this._contentLength !== null && this._receivedLength < this._contentLength) {\n // Report Early-EOF\n this._status = LoaderStatus.kError;\n let type = LoaderErrors.EARLY_EOF;\n let info = {code: -1, msg: 'Fetch stream meet Early-EOF'};\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n } else {\n // OK. Download complete\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n } else {\n if (this._abortController && this._abortController.signal.aborted) {\n this._status = LoaderStatus.kComplete;\n return;\n } else if (this._requestAbort === true) {\n this._status = LoaderStatus.kComplete;\n return reader.cancel();\n }\n\n this._status = LoaderStatus.kBuffering;\n\n let chunk = result.value.buffer;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n\n this._pump(reader);\n }\n }).catch((e) => {\n if (this._abortController && this._abortController.signal.aborted) {\n this._status = LoaderStatus.kComplete;\n return;\n }\n\n if (e.code === 11 && Browser.msedge) { // InvalidStateError on Microsoft Edge\n // Workaround: Edge may throw InvalidStateError after ReadableStreamReader.cancel() call\n // Ignore the unknown exception.\n // Related issue: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11265202/\n return;\n }\n\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if ((e.code === 19 || e.message === 'network error') && // NETWORK_ERR\n (this._contentLength === null ||\n (this._contentLength !== null && this._receivedLength < this._contentLength))) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: e.code, msg: 'Fetch stream meet Early-EOF'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: e.code, msg: e.message};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n });\n }\n\n}\n\nexport default FetchStreamLoader;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// For FireFox browser which supports `xhr.responseType = 'moz-chunked-arraybuffer'`\nclass MozChunkedLoader extends BaseLoader {\n\n static isSupported() {\n try {\n let xhr = new XMLHttpRequest();\n // Firefox 37- requires .open() to be called before setting responseType\n xhr.open('GET', 'https://example.com', true);\n xhr.responseType = 'moz-chunked-arraybuffer';\n return (xhr.responseType === 'moz-chunked-arraybuffer');\n } catch (e) {\n Log.w('MozChunkedLoader', e.message);\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('xhr-moz-chunked-loader');\n this.TAG = 'MozChunkedLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = true;\n\n this._xhr = null;\n this._requestAbort = false;\n this._contentLength = null;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onloadend = null;\n this._xhr.onerror = null;\n this._xhr = null;\n }\n super.destroy();\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL && dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n this._requestURL = seekConfig.url;\n\n let xhr = this._xhr = new XMLHttpRequest();\n xhr.open('GET', seekConfig.url, true);\n xhr.responseType = 'moz-chunked-arraybuffer';\n xhr.onreadystatechange = this._onReadyStateChange.bind(this);\n xhr.onprogress = this._onProgress.bind(this);\n xhr.onloadend = this._onLoadEnd.bind(this);\n xhr.onerror = this._onXhrError.bind(this);\n\n // cors is auto detected and enabled by xhr\n\n // withCredentials is disabled by default\n if (dataSource.withCredentials) {\n xhr.withCredentials = true;\n }\n\n if (typeof seekConfig.headers === 'object') {\n let headers = seekConfig.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n let headers = this._config.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n this._status = LoaderStatus.kConnecting;\n xhr.send();\n }\n\n abort() {\n this._requestAbort = true;\n if (this._xhr) {\n this._xhr.abort();\n }\n this._status = LoaderStatus.kComplete;\n }\n\n _onReadyStateChange(e) {\n let xhr = e.target;\n\n if (xhr.readyState === 2) { // HEADERS_RECEIVED\n if (xhr.responseURL != undefined && xhr.responseURL !== this._requestURL) {\n if (this._onURLRedirect) {\n let redirectedURL = this._seekHandler.removeURLParameters(xhr.responseURL);\n this._onURLRedirect(redirectedURL);\n }\n }\n\n if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: xhr.status, msg: xhr.statusText});\n } else {\n throw new RuntimeException('MozChunkedLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText);\n }\n } else {\n this._status = LoaderStatus.kBuffering;\n }\n }\n }\n\n _onProgress(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._contentLength === null) {\n if (e.total !== null && e.total !== 0) {\n this._contentLength = e.total;\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n }\n\n let chunk = e.target.response;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n }\n\n _onLoadEnd(e) {\n if (this._requestAbort === true) {\n this._requestAbort = false;\n return;\n } else if (this._status === LoaderStatus.kError) {\n return;\n }\n\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n\n _onXhrError(e) {\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if (this._contentLength && e.loaded < this._contentLength) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: -1, msg: 'Moz-Chunked stream meet Early-Eof'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: -1, msg: e.constructor.name + ' ' + e.type};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default MozChunkedLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport SpeedSampler from './speed-sampler.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// Universal IO Loader, implemented by adding Range header in xhr's request header\nclass RangeLoader extends BaseLoader {\n\n static isSupported() {\n try {\n let xhr = new XMLHttpRequest();\n xhr.open('GET', 'https://example.com', true);\n xhr.responseType = 'arraybuffer';\n return (xhr.responseType === 'arraybuffer');\n } catch (e) {\n Log.w('RangeLoader', e.message);\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('xhr-range-loader');\n this.TAG = 'RangeLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = false;\n\n this._chunkSizeKBList = [\n 128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 5120, 6144, 7168, 8192\n ];\n this._currentChunkSizeKB = 384;\n this._currentSpeedNormalized = 0;\n this._zeroSpeedChunkCount = 0;\n\n this._xhr = null;\n this._speedSampler = new SpeedSampler();\n\n this._requestAbort = false;\n this._waitForTotalLength = false;\n this._totalLengthReceived = false;\n\n this._currentRequestURL = null;\n this._currentRedirectedURL = null;\n this._currentRequestRange = null;\n this._totalLength = null; // size of the entire file\n this._contentLength = null; // Content-Length of entire request range\n this._receivedLength = 0; // total received bytes\n this._lastTimeLoaded = 0; // received bytes of current request sub-range\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onload = null;\n this._xhr.onerror = null;\n this._xhr = null;\n }\n super.destroy();\n }\n\n get currentSpeed() {\n return this._speedSampler.lastSecondKBps;\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n this._status = LoaderStatus.kConnecting;\n\n let useRefTotalLength = false;\n if (this._dataSource.filesize != undefined && this._dataSource.filesize !== 0) {\n useRefTotalLength = true;\n this._totalLength = this._dataSource.filesize;\n }\n\n if (!this._totalLengthReceived && !useRefTotalLength) {\n // We need total filesize\n this._waitForTotalLength = true;\n this._internalOpen(this._dataSource, {from: 0, to: -1});\n } else {\n // We have filesize, start loading\n this._openSubRange();\n }\n }\n\n _openSubRange() {\n let chunkSize = this._currentChunkSizeKB * 1024;\n\n let from = this._range.from + this._receivedLength;\n let to = from + chunkSize;\n\n if (this._contentLength != null) {\n if (to - this._range.from >= this._contentLength) {\n to = this._range.from + this._contentLength - 1;\n }\n }\n\n this._currentRequestRange = {from, to};\n this._internalOpen(this._dataSource, this._currentRequestRange);\n }\n\n _internalOpen(dataSource, range) {\n this._lastTimeLoaded = 0;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL) {\n if (this._currentRedirectedURL != undefined) {\n sourceURL = this._currentRedirectedURL;\n } else if (dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n this._currentRequestURL = seekConfig.url;\n\n let xhr = this._xhr = new XMLHttpRequest();\n xhr.open('GET', seekConfig.url, true);\n xhr.responseType = 'arraybuffer';\n xhr.onreadystatechange = this._onReadyStateChange.bind(this);\n xhr.onprogress = this._onProgress.bind(this);\n xhr.onload = this._onLoad.bind(this);\n xhr.onerror = this._onXhrError.bind(this);\n\n if (dataSource.withCredentials) {\n xhr.withCredentials = true;\n }\n\n if (typeof seekConfig.headers === 'object') {\n let headers = seekConfig.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n let headers = this._config.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n xhr.send();\n }\n\n abort() {\n this._requestAbort = true;\n this._internalAbort();\n this._status = LoaderStatus.kComplete;\n }\n\n _internalAbort() {\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onload = null;\n this._xhr.onerror = null;\n this._xhr.abort();\n this._xhr = null;\n }\n }\n\n _onReadyStateChange(e) {\n let xhr = e.target;\n\n if (xhr.readyState === 2) { // HEADERS_RECEIVED\n if (xhr.responseURL != undefined) { // if the browser support this property\n let redirectedURL = this._seekHandler.removeURLParameters(xhr.responseURL);\n if (xhr.responseURL !== this._currentRequestURL && redirectedURL !== this._currentRedirectedURL) {\n this._currentRedirectedURL = redirectedURL;\n if (this._onURLRedirect) {\n this._onURLRedirect(redirectedURL);\n }\n }\n }\n\n if ((xhr.status >= 200 && xhr.status <= 299)) {\n if (this._waitForTotalLength) {\n return;\n }\n this._status = LoaderStatus.kBuffering;\n } else {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: xhr.status, msg: xhr.statusText});\n } else {\n throw new RuntimeException('RangeLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText);\n }\n }\n }\n }\n\n _onProgress(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._contentLength === null) {\n let openNextRange = false;\n\n if (this._waitForTotalLength) {\n this._waitForTotalLength = false;\n this._totalLengthReceived = true;\n openNextRange = true;\n\n let total = e.total;\n this._internalAbort();\n if (total != null & total !== 0) {\n this._totalLength = total;\n }\n }\n\n // calculate currrent request range's contentLength\n if (this._range.to === -1) {\n this._contentLength = this._totalLength - this._range.from;\n } else { // to !== -1\n this._contentLength = this._range.to - this._range.from + 1;\n }\n\n if (openNextRange) {\n this._openSubRange();\n return;\n }\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n\n let delta = e.loaded - this._lastTimeLoaded;\n this._lastTimeLoaded = e.loaded;\n this._speedSampler.addBytes(delta);\n }\n\n _normalizeSpeed(input) {\n let list = this._chunkSizeKBList;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (input < list[0]) {\n return list[0];\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (input >= list[mid] && input < list[mid + 1])) {\n return list[mid];\n } else if (list[mid] < input) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n }\n\n _onLoad(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._waitForTotalLength) {\n this._waitForTotalLength = false;\n return;\n }\n\n this._lastTimeLoaded = 0;\n let KBps = this._speedSampler.lastSecondKBps;\n if (KBps === 0) {\n this._zeroSpeedChunkCount++;\n if (this._zeroSpeedChunkCount >= 3) {\n // Try get currentKBps after 3 chunks\n KBps = this._speedSampler.currentKBps;\n }\n }\n\n if (KBps !== 0) {\n let normalized = this._normalizeSpeed(KBps);\n if (this._currentSpeedNormalized !== normalized) {\n this._currentSpeedNormalized = normalized;\n this._currentChunkSizeKB = normalized;\n }\n }\n\n let chunk = e.target.response;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n let reportComplete = false;\n\n if (this._contentLength != null && this._receivedLength < this._contentLength) {\n // continue load next chunk\n this._openSubRange();\n } else {\n reportComplete = true;\n }\n\n // dispatch received chunk\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n\n if (reportComplete) {\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n }\n\n _onXhrError(e) {\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if (this._contentLength && this._receivedLength > 0\n && this._receivedLength < this._contentLength) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: -1, msg: 'RangeLoader meet Early-Eof'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: -1, msg: e.constructor.name + ' ' + e.type};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default RangeLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// For MPEG-TS/FLV over WebSocket live stream\nclass WebSocketLoader extends BaseLoader {\n\n static isSupported() {\n try {\n return (typeof self.WebSocket !== 'undefined');\n } catch (e) {\n return false;\n }\n }\n\n constructor() {\n super('websocket-loader');\n this.TAG = 'WebSocketLoader';\n\n this._needStash = true;\n\n this._ws = null;\n this._requestAbort = false;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this._ws) {\n this.abort();\n }\n super.destroy();\n }\n\n open(dataSource) {\n try {\n let ws = this._ws = new self.WebSocket(dataSource.url);\n ws.binaryType = 'arraybuffer';\n ws.onopen = this._onWebSocketOpen.bind(this);\n ws.onclose = this._onWebSocketClose.bind(this);\n ws.onmessage = this._onWebSocketMessage.bind(this);\n ws.onerror = this._onWebSocketError.bind(this);\n\n this._status = LoaderStatus.kConnecting;\n } catch (e) {\n this._status = LoaderStatus.kError;\n\n let info = {code: e.code, msg: e.message};\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n }\n\n abort() {\n let ws = this._ws;\n if (ws && (ws.readyState === 0 || ws.readyState === 1)) { // CONNECTING || OPEN\n this._requestAbort = true;\n ws.close();\n }\n\n this._ws = null;\n this._status = LoaderStatus.kComplete;\n }\n\n _onWebSocketOpen(e) {\n this._status = LoaderStatus.kBuffering;\n }\n\n _onWebSocketClose(e) {\n if (this._requestAbort === true) {\n this._requestAbort = false;\n return;\n }\n\n this._status = LoaderStatus.kComplete;\n\n if (this._onComplete) {\n this._onComplete(0, this._receivedLength - 1);\n }\n }\n\n _onWebSocketMessage(e) {\n if (e.data instanceof ArrayBuffer) {\n this._dispatchArrayBuffer(e.data);\n } else if (e.data instanceof Blob) {\n let reader = new FileReader();\n reader.onload = () => {\n this._dispatchArrayBuffer(reader.result);\n };\n reader.readAsArrayBuffer(e.data);\n } else {\n this._status = LoaderStatus.kError;\n let info = {code: -1, msg: 'Unsupported WebSocket message type: ' + e.data.constructor.name};\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n }\n\n _dispatchArrayBuffer(arraybuffer) {\n let chunk = arraybuffer;\n let byteStart = this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n }\n\n _onWebSocketError(e) {\n this._status = LoaderStatus.kError;\n\n let info = {\n code: e.code,\n msg: e.message\n };\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default WebSocketLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass RangeSeekHandler {\n\n constructor(zeroStart) {\n this._zeroStart = zeroStart || false;\n }\n\n getConfig(url, range) {\n let headers = {};\n\n if (range.from !== 0 || range.to !== -1) {\n let param;\n if (range.to !== -1) {\n param = `bytes=${range.from.toString()}-${range.to.toString()}`;\n } else {\n param = `bytes=${range.from.toString()}-`;\n }\n headers['Range'] = param;\n } else if (this._zeroStart) {\n headers['Range'] = 'bytes=0-';\n }\n\n return {\n url: url,\n headers: headers\n };\n }\n\n removeURLParameters(seekedURL) {\n return seekedURL;\n }\n\n}\n\nexport default RangeSeekHandler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass ParamSeekHandler {\n\n constructor(paramStart, paramEnd) {\n this._startName = paramStart;\n this._endName = paramEnd;\n }\n\n getConfig(baseUrl, range) {\n let url = baseUrl;\n\n if (range.from !== 0 || range.to !== -1) {\n let needAnd = true;\n if (url.indexOf('?') === -1) {\n url += '?';\n needAnd = false;\n }\n\n if (needAnd) {\n url += '&';\n }\n\n url += `${this._startName}=${range.from.toString()}`;\n\n if (range.to !== -1) {\n url += `&${this._endName}=${range.to.toString()}`;\n }\n }\n\n return {\n url: url,\n headers: {}\n };\n }\n\n removeURLParameters(seekedURL) {\n let baseURL = seekedURL.split('?')[0];\n let params = undefined;\n\n let queryIndex = seekedURL.indexOf('?');\n if (queryIndex !== -1) {\n params = seekedURL.substring(queryIndex + 1);\n }\n\n let resultParams = '';\n\n if (params != undefined && params.length > 0) {\n let pairs = params.split('&');\n\n for (let i = 0; i < pairs.length; i++) {\n let pair = pairs[i].split('=');\n let requireAnd = (i > 0);\n\n if (pair[0] !== this._startName && pair[0] !== this._endName) {\n if (requireAnd) {\n resultParams += '&';\n }\n resultParams += pairs[i];\n }\n }\n }\n\n return (resultParams.length === 0) ? baseURL : baseURL + '?' + resultParams;\n }\n\n}\n\nexport default ParamSeekHandler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport SpeedSampler from './speed-sampler.js';\nimport {LoaderStatus, LoaderErrors} from './loader.js';\nimport FetchStreamLoader from './fetch-stream-loader.js';\nimport MozChunkedLoader from './xhr-moz-chunked-loader.js';\nimport MSStreamLoader from './xhr-msstream-loader.js';\nimport RangeLoader from './xhr-range-loader.js';\nimport WebSocketLoader from './websocket-loader.js';\nimport RangeSeekHandler from './range-seek-handler.js';\nimport ParamSeekHandler from './param-seek-handler.js';\nimport {RuntimeException, IllegalStateException, InvalidArgumentException} from '../utils/exception.js';\n\n/**\n * DataSource: {\n * url: string,\n * filesize: number,\n * cors: boolean,\n * withCredentials: boolean\n * }\n * \n */\n\n// Manage IO Loaders\nclass IOController {\n\n constructor(dataSource, config, extraData) {\n this.TAG = 'IOController';\n\n this._config = config;\n this._extraData = extraData;\n\n this._stashInitialSize = 64 * 1024; // default initial size: 64KB\n if (config.stashInitialSize != undefined && config.stashInitialSize > 0) {\n // apply from config\n this._stashInitialSize = config.stashInitialSize;\n }\n\n this._stashUsed = 0;\n this._stashSize = this._stashInitialSize;\n this._bufferSize = 1024 * 1024 * 3; // initial size: 3MB\n this._stashBuffer = new ArrayBuffer(this._bufferSize);\n this._stashByteStart = 0;\n this._enableStash = true;\n if (config.enableStashBuffer === false) {\n this._enableStash = false;\n }\n\n this._loader = null;\n this._loaderClass = null;\n this._seekHandler = null;\n\n this._dataSource = dataSource;\n this._isWebSocketURL = /wss?:\\/\\/(.+?)/.test(dataSource.url);\n this._refTotalLength = dataSource.filesize ? dataSource.filesize : null;\n this._totalLength = this._refTotalLength;\n this._fullRequestFlag = false;\n this._currentRange = null;\n this._redirectedURL = null;\n\n this._speedNormalized = 0;\n this._speedSampler = new SpeedSampler();\n this._speedNormalizeList = [32, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096];\n\n this._isEarlyEofReconnecting = false;\n\n this._paused = false;\n this._resumeFrom = 0;\n\n this._onDataArrival = null;\n this._onSeeked = null;\n this._onError = null;\n this._onComplete = null;\n this._onRedirect = null;\n this._onRecoveredEarlyEof = null;\n\n this._selectSeekHandler();\n this._selectLoader();\n this._createLoader();\n }\n\n destroy() {\n if (this._loader.isWorking()) {\n this._loader.abort();\n }\n this._loader.destroy();\n this._loader = null;\n this._loaderClass = null;\n this._dataSource = null;\n this._stashBuffer = null;\n this._stashUsed = this._stashSize = this._bufferSize = this._stashByteStart = 0;\n this._currentRange = null;\n this._speedSampler = null;\n\n this._isEarlyEofReconnecting = false;\n\n this._onDataArrival = null;\n this._onSeeked = null;\n this._onError = null;\n this._onComplete = null;\n this._onRedirect = null;\n this._onRecoveredEarlyEof = null;\n\n this._extraData = null;\n }\n\n isWorking() {\n return this._loader && this._loader.isWorking() && !this._paused;\n }\n\n isPaused() {\n return this._paused;\n }\n\n get status() {\n return this._loader.status;\n }\n\n get extraData() {\n return this._extraData;\n }\n\n set extraData(data) {\n this._extraData = data;\n }\n\n // prototype: function onDataArrival(chunks: ArrayBuffer, byteStart: number): number\n get onDataArrival() {\n return this._onDataArrival;\n }\n\n set onDataArrival(callback) {\n this._onDataArrival = callback;\n }\n\n get onSeeked() {\n return this._onSeeked;\n }\n\n set onSeeked(callback) {\n this._onSeeked = callback;\n }\n\n // prototype: function onError(type: number, info: {code: number, msg: string}): void\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n get onComplete() {\n return this._onComplete;\n }\n\n set onComplete(callback) {\n this._onComplete = callback;\n }\n\n get onRedirect() {\n return this._onRedirect;\n }\n\n set onRedirect(callback) {\n this._onRedirect = callback;\n }\n\n get onRecoveredEarlyEof() {\n return this._onRecoveredEarlyEof;\n }\n\n set onRecoveredEarlyEof(callback) {\n this._onRecoveredEarlyEof = callback;\n }\n\n get currentURL() {\n return this._dataSource.url;\n }\n\n get hasRedirect() {\n return (this._redirectedURL != null || this._dataSource.redirectedURL != undefined);\n }\n\n get currentRedirectedURL() {\n return this._redirectedURL || this._dataSource.redirectedURL;\n }\n\n // in KB/s\n get currentSpeed() {\n if (this._loaderClass === RangeLoader) {\n // SpeedSampler is inaccuracy if loader is RangeLoader\n return this._loader.currentSpeed;\n }\n return this._speedSampler.lastSecondKBps;\n }\n\n get loaderType() {\n return this._loader.type;\n }\n\n _selectSeekHandler() {\n let config = this._config;\n\n if (config.seekType === 'range') {\n this._seekHandler = new RangeSeekHandler(this._config.rangeLoadZeroStart);\n } else if (config.seekType === 'param') {\n let paramStart = config.seekParamStart || 'bstart';\n let paramEnd = config.seekParamEnd || 'bend';\n\n this._seekHandler = new ParamSeekHandler(paramStart, paramEnd);\n } else if (config.seekType === 'custom') {\n if (typeof config.customSeekHandler !== 'function') {\n throw new InvalidArgumentException('Custom seekType specified in config but invalid customSeekHandler!');\n }\n this._seekHandler = new config.customSeekHandler();\n } else {\n throw new InvalidArgumentException(`Invalid seekType in config: ${config.seekType}`);\n }\n }\n\n _selectLoader() {\n if (this._config.customLoader != null) {\n this._loaderClass = this._config.customLoader;\n } else if (this._isWebSocketURL) {\n this._loaderClass = WebSocketLoader;\n } else if (FetchStreamLoader.isSupported()) {\n this._loaderClass = FetchStreamLoader;\n } else if (MozChunkedLoader.isSupported()) {\n this._loaderClass = MozChunkedLoader;\n } else if (RangeLoader.isSupported()) {\n this._loaderClass = RangeLoader;\n } else {\n throw new RuntimeException('Your browser doesn\\'t support xhr with arraybuffer responseType!');\n }\n }\n\n _createLoader() {\n this._loader = new this._loaderClass(this._seekHandler, this._config);\n if (this._loader.needStashBuffer === false) {\n this._enableStash = false;\n }\n this._loader.onContentLengthKnown = this._onContentLengthKnown.bind(this);\n this._loader.onURLRedirect = this._onURLRedirect.bind(this);\n this._loader.onDataArrival = this._onLoaderChunkArrival.bind(this);\n this._loader.onComplete = this._onLoaderComplete.bind(this);\n this._loader.onError = this._onLoaderError.bind(this);\n }\n\n open(optionalFrom) {\n this._currentRange = {from: 0, to: -1};\n if (optionalFrom) {\n this._currentRange.from = optionalFrom;\n }\n\n this._speedSampler.reset();\n if (!optionalFrom) {\n this._fullRequestFlag = true;\n }\n\n this._loader.open(this._dataSource, Object.assign({}, this._currentRange));\n }\n\n abort() {\n this._loader.abort();\n\n if (this._paused) {\n this._paused = false;\n this._resumeFrom = 0;\n }\n }\n\n pause() {\n if (this.isWorking()) {\n this._loader.abort();\n\n if (this._stashUsed !== 0) {\n this._resumeFrom = this._stashByteStart;\n this._currentRange.to = this._stashByteStart - 1;\n } else {\n this._resumeFrom = this._currentRange.to + 1;\n }\n this._stashUsed = 0;\n this._stashByteStart = 0;\n this._paused = true;\n }\n }\n\n resume() {\n if (this._paused) {\n this._paused = false;\n let bytes = this._resumeFrom;\n this._resumeFrom = 0;\n this._internalSeek(bytes, true);\n }\n }\n\n seek(bytes) {\n this._paused = false;\n this._stashUsed = 0;\n this._stashByteStart = 0;\n this._internalSeek(bytes, true);\n }\n\n /**\n * When seeking request is from media seeking, unconsumed stash data should be dropped\n * However, stash data shouldn't be dropped if seeking requested from http reconnection\n *\n * @dropUnconsumed: Ignore and discard all unconsumed data in stash buffer\n */\n _internalSeek(bytes, dropUnconsumed) {\n if (this._loader.isWorking()) {\n this._loader.abort();\n }\n\n // dispatch & flush stash buffer before seek\n this._flushStashBuffer(dropUnconsumed);\n\n this._loader.destroy();\n this._loader = null;\n\n let requestRange = {from: bytes, to: -1};\n this._currentRange = {from: requestRange.from, to: -1};\n\n this._speedSampler.reset();\n this._stashSize = this._stashInitialSize;\n this._createLoader();\n this._loader.open(this._dataSource, requestRange);\n\n if (this._onSeeked) {\n this._onSeeked();\n }\n }\n\n updateUrl(url) {\n if (!url || typeof url !== 'string' || url.length === 0) {\n throw new InvalidArgumentException('Url must be a non-empty string!');\n }\n\n this._dataSource.url = url;\n\n // TODO: replace with new url\n }\n\n _expandBuffer(expectedBytes) {\n let bufferNewSize = this._stashSize;\n while (bufferNewSize + 1024 * 1024 * 1 < expectedBytes) {\n bufferNewSize *= 2;\n }\n\n bufferNewSize += 1024 * 1024 * 1; // bufferSize = stashSize + 1MB\n if (bufferNewSize === this._bufferSize) {\n return;\n }\n\n let newBuffer = new ArrayBuffer(bufferNewSize);\n\n if (this._stashUsed > 0) { // copy existing data into new buffer\n let stashOldArray = new Uint8Array(this._stashBuffer, 0, this._stashUsed);\n let stashNewArray = new Uint8Array(newBuffer, 0, bufferNewSize);\n stashNewArray.set(stashOldArray, 0);\n }\n\n this._stashBuffer = newBuffer;\n this._bufferSize = bufferNewSize;\n }\n\n _normalizeSpeed(input) {\n let list = this._speedNormalizeList;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (input < list[0]) {\n return list[0];\n }\n\n // binary search\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (input >= list[mid] && input < list[mid + 1])) {\n return list[mid];\n } else if (list[mid] < input) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n }\n\n _adjustStashSize(normalized) {\n let stashSizeKB = 0;\n\n if (this._config.isLive) {\n // live stream: always use 1/8 normalized speed for size of stashSizeKB\n stashSizeKB = normalized / 8;\n } else {\n if (normalized < 512) {\n stashSizeKB = normalized;\n } else if (normalized >= 512 && normalized <= 1024) {\n stashSizeKB = Math.floor(normalized * 1.5);\n } else {\n stashSizeKB = normalized * 2;\n }\n }\n\n if (stashSizeKB > 8192) {\n stashSizeKB = 8192;\n }\n\n let bufferSize = stashSizeKB * 1024 + 1024 * 1024 * 1; // stashSize + 1MB\n if (this._bufferSize < bufferSize) {\n this._expandBuffer(bufferSize);\n }\n this._stashSize = stashSizeKB * 1024;\n }\n\n _dispatchChunks(chunks, byteStart) {\n this._currentRange.to = byteStart + chunks.byteLength - 1;\n return this._onDataArrival(chunks, byteStart);\n }\n\n _onURLRedirect(redirectedURL) {\n this._redirectedURL = redirectedURL;\n if (this._onRedirect) {\n this._onRedirect(redirectedURL);\n }\n }\n\n _onContentLengthKnown(contentLength) {\n if (contentLength && this._fullRequestFlag) {\n this._totalLength = contentLength;\n this._fullRequestFlag = false;\n }\n }\n\n _onLoaderChunkArrival(chunk, byteStart, receivedLength) {\n if (!this._onDataArrival) {\n throw new IllegalStateException('IOController: No existing consumer (onDataArrival) callback!');\n }\n if (this._paused) {\n return;\n }\n if (this._isEarlyEofReconnecting) {\n // Auto-reconnect for EarlyEof succeed, notify to upper-layer by callback\n this._isEarlyEofReconnecting = false;\n if (this._onRecoveredEarlyEof) {\n this._onRecoveredEarlyEof();\n }\n }\n\n this._speedSampler.addBytes(chunk.byteLength);\n\n // adjust stash buffer size according to network speed dynamically\n let KBps = this._speedSampler.lastSecondKBps;\n if (KBps !== 0) {\n let normalized = this._normalizeSpeed(KBps);\n if (this._speedNormalized !== normalized) {\n this._speedNormalized = normalized;\n this._adjustStashSize(normalized);\n }\n }\n\n if (!this._enableStash) { // disable stash\n if (this._stashUsed === 0) {\n // dispatch chunk directly to consumer;\n // check ret value (consumed bytes) and stash unconsumed to stashBuffer\n let consumed = this._dispatchChunks(chunk, byteStart);\n if (consumed < chunk.byteLength) { // unconsumed data remain.\n let remain = chunk.byteLength - consumed;\n if (remain > this._bufferSize) {\n this._expandBuffer(remain);\n }\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n stashArray.set(new Uint8Array(chunk, consumed), 0);\n this._stashUsed += remain;\n this._stashByteStart = byteStart + consumed;\n }\n } else {\n // else: Merge chunk into stashBuffer, and dispatch stashBuffer to consumer.\n if (this._stashUsed + chunk.byteLength > this._bufferSize) {\n this._expandBuffer(this._stashUsed + chunk.byteLength);\n }\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n let consumed = this._dispatchChunks(this._stashBuffer.slice(0, this._stashUsed), this._stashByteStart);\n if (consumed < this._stashUsed && consumed > 0) { // unconsumed data remain\n let remainArray = new Uint8Array(this._stashBuffer, consumed);\n stashArray.set(remainArray, 0);\n }\n this._stashUsed -= consumed;\n this._stashByteStart += consumed;\n }\n } else { // enable stash\n if (this._stashUsed === 0 && this._stashByteStart === 0) { // seeked? or init chunk?\n // This is the first chunk after seek action\n this._stashByteStart = byteStart;\n }\n if (this._stashUsed + chunk.byteLength <= this._stashSize) {\n // just stash\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._stashSize);\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n } else { // stashUsed + chunkSize > stashSize, size limit exceeded\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n if (this._stashUsed > 0) { // There're stash datas in buffer\n // dispatch the whole stashBuffer, and stash remain data\n // then append chunk to stashBuffer (stash)\n let buffer = this._stashBuffer.slice(0, this._stashUsed);\n let consumed = this._dispatchChunks(buffer, this._stashByteStart);\n if (consumed < buffer.byteLength) {\n if (consumed > 0) {\n let remainArray = new Uint8Array(buffer, consumed);\n stashArray.set(remainArray, 0);\n this._stashUsed = remainArray.byteLength;\n this._stashByteStart += consumed;\n }\n } else {\n this._stashUsed = 0;\n this._stashByteStart += consumed;\n }\n if (this._stashUsed + chunk.byteLength > this._bufferSize) {\n this._expandBuffer(this._stashUsed + chunk.byteLength);\n stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n }\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n } else { // stash buffer empty, but chunkSize > stashSize (oh, holy shit)\n // dispatch chunk directly and stash remain data\n let consumed = this._dispatchChunks(chunk, byteStart);\n if (consumed < chunk.byteLength) {\n let remain = chunk.byteLength - consumed;\n if (remain > this._bufferSize) {\n this._expandBuffer(remain);\n stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n }\n stashArray.set(new Uint8Array(chunk, consumed), 0);\n this._stashUsed += remain;\n this._stashByteStart = byteStart + consumed;\n }\n }\n }\n }\n }\n\n _flushStashBuffer(dropUnconsumed) {\n if (this._stashUsed > 0) {\n let buffer = this._stashBuffer.slice(0, this._stashUsed);\n let consumed = this._dispatchChunks(buffer, this._stashByteStart);\n let remain = buffer.byteLength - consumed;\n\n if (consumed < buffer.byteLength) {\n if (dropUnconsumed) {\n Log.w(this.TAG, `${remain} bytes unconsumed data remain when flush buffer, dropped`);\n } else {\n if (consumed > 0) {\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n let remainArray = new Uint8Array(buffer, consumed);\n stashArray.set(remainArray, 0);\n this._stashUsed = remainArray.byteLength;\n this._stashByteStart += consumed;\n }\n return 0;\n }\n }\n this._stashUsed = 0;\n this._stashByteStart = 0;\n return remain;\n }\n return 0;\n }\n\n _onLoaderComplete(from, to) {\n // Force-flush stash buffer, and drop unconsumed data\n this._flushStashBuffer(true);\n\n if (this._onComplete) {\n this._onComplete(this._extraData);\n }\n }\n\n _onLoaderError(type, data) {\n Log.e(this.TAG, `Loader error, code = ${data.code}, msg = ${data.msg}`);\n\n this._flushStashBuffer(false);\n\n if (this._isEarlyEofReconnecting) {\n // Auto-reconnect for EarlyEof failed, throw UnrecoverableEarlyEof error to upper-layer\n this._isEarlyEofReconnecting = false;\n type = LoaderErrors.UNRECOVERABLE_EARLY_EOF;\n }\n\n switch (type) {\n case LoaderErrors.EARLY_EOF: {\n if (!this._config.isLive) {\n // Do internal http reconnect if not live stream\n if (this._totalLength) {\n let nextFrom = this._currentRange.to + 1;\n if (nextFrom < this._totalLength) {\n Log.w(this.TAG, 'Connection lost, trying reconnect...');\n this._isEarlyEofReconnecting = true;\n this._internalSeek(nextFrom, false);\n }\n return;\n }\n // else: We don't know totalLength, throw UnrecoverableEarlyEof\n }\n // live stream: throw UnrecoverableEarlyEof error to upper-layer\n type = LoaderErrors.UNRECOVERABLE_EARLY_EOF;\n break;\n }\n case LoaderErrors.UNRECOVERABLE_EARLY_EOF:\n case LoaderErrors.CONNECTING_TIMEOUT:\n case LoaderErrors.HTTP_STATUS_CODE_INVALID:\n case LoaderErrors.EXCEPTION:\n break;\n }\n\n if (this._onError) {\n this._onError(type, data);\n } else {\n throw new RuntimeException('IOException: ' + data.msg);\n }\n }\n\n}\n\nexport default IOController;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass Polyfill {\n\n static install() {\n // ES6 Object.setPrototypeOf\n Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {\n obj.__proto__ = proto;\n return obj;\n };\n\n // ES6 Object.assign\n Object.assign = Object.assign || function (target) {\n if (target === undefined || target === null) {\n throw new TypeError('Cannot convert undefined or null to object');\n }\n\n let output = Object(target);\n for (let i = 1; i < arguments.length; i++) {\n let source = arguments[i];\n if (source !== undefined && source !== null) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n output[key] = source[key];\n }\n }\n }\n }\n return output;\n };\n\n // ES6 Promise (missing support in IE11)\n if (typeof self.Promise !== 'function') {\n require('es6-promise').polyfill();\n }\n }\n\n}\n\nPolyfill.install();\n\nexport default Polyfill;","function webpackBootstrapFunc (modules) {\n/******/ // The module cache\n/******/ var installedModules = {};\n\n/******/ // The require function\n/******/ function __webpack_require__(moduleId) {\n\n/******/ // Check if module is in cache\n/******/ if(installedModules[moduleId])\n/******/ return installedModules[moduleId].exports;\n\n/******/ // Create a new module (and put it into the cache)\n/******/ var module = installedModules[moduleId] = {\n/******/ i: moduleId,\n/******/ l: false,\n/******/ exports: {}\n/******/ };\n\n/******/ // Execute the module function\n/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n/******/ // Flag the module as loaded\n/******/ module.l = true;\n\n/******/ // Return the exports of the module\n/******/ return module.exports;\n/******/ }\n\n/******/ // expose the modules object (__webpack_modules__)\n/******/ __webpack_require__.m = modules;\n\n/******/ // expose the module cache\n/******/ __webpack_require__.c = installedModules;\n\n/******/ // identity function for calling harmony imports with the correct context\n/******/ __webpack_require__.i = function(value) { return value; };\n\n/******/ // define getter function for harmony exports\n/******/ __webpack_require__.d = function(exports, name, getter) {\n/******/ if(!__webpack_require__.o(exports, name)) {\n/******/ Object.defineProperty(exports, name, {\n/******/ configurable: false,\n/******/ enumerable: true,\n/******/ get: getter\n/******/ });\n/******/ }\n/******/ };\n\n/******/ // define __esModule on exports\n/******/ __webpack_require__.r = function(exports) {\n/******/ Object.defineProperty(exports, '__esModule', { value: true });\n/******/ };\n\n/******/ // getDefaultExport function for compatibility with non-harmony modules\n/******/ __webpack_require__.n = function(module) {\n/******/ var getter = module && module.__esModule ?\n/******/ function getDefault() { return module['default']; } :\n/******/ function getModuleExports() { return module; };\n/******/ __webpack_require__.d(getter, 'a', getter);\n/******/ return getter;\n/******/ };\n\n/******/ // Object.prototype.hasOwnProperty.call\n/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n/******/ // __webpack_public_path__\n/******/ __webpack_require__.p = \"/\";\n\n/******/ // on error function for async loading\n/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n var f = __webpack_require__(__webpack_require__.s = ENTRY_MODULE)\n return f.default || f // try to call default if defined to also support babel esmodule exports\n}\n\nvar moduleNameReqExp = '[\\\\.|\\\\-|\\\\+|\\\\w|\\/|@]+'\nvar dependencyRegExp = '\\\\(\\\\s*(\\/\\\\*.*?\\\\*\\/)?\\\\s*.*?(' + moduleNameReqExp + ').*?\\\\)' // additional chars when output.pathinfo is true\n\n// http://stackoverflow.com/a/2593661/130442\nfunction quoteRegExp (str) {\n return (str + '').replace(/[.?*+^$[\\]\\\\(){}|-]/g, '\\\\$&')\n}\n\nfunction isNumeric(n) {\n return !isNaN(1 * n); // 1 * n converts integers, integers as string (\"123\"), 1e3 and \"1e3\" to integers and strings to NaN\n}\n\nfunction getModuleDependencies (sources, module, queueName) {\n var retval = {}\n retval[queueName] = []\n\n var fnString = module.toString()\n var wrapperSignature = fnString.match(/^function\\s?\\w*\\(\\w+,\\s*\\w+,\\s*(\\w+)\\)/)\n if (!wrapperSignature) return retval\n var webpackRequireName = wrapperSignature[1]\n\n // main bundle deps\n var re = new RegExp('(\\\\\\\\n|\\\\W)' + quoteRegExp(webpackRequireName) + dependencyRegExp, 'g')\n var match\n while ((match = re.exec(fnString))) {\n if (match[3] === 'dll-reference') continue\n retval[queueName].push(match[3])\n }\n\n // dll deps\n re = new RegExp('\\\\(' + quoteRegExp(webpackRequireName) + '\\\\(\"(dll-reference\\\\s(' + moduleNameReqExp + '))\"\\\\)\\\\)' + dependencyRegExp, 'g')\n while ((match = re.exec(fnString))) {\n if (!sources[match[2]]) {\n retval[queueName].push(match[1])\n sources[match[2]] = __webpack_require__(match[1]).m\n }\n retval[match[2]] = retval[match[2]] || []\n retval[match[2]].push(match[4])\n }\n\n // convert 1e3 back to 1000 - this can be important after uglify-js converted 1000 to 1e3\n var keys = Object.keys(retval);\n for (var i = 0; i < keys.length; i++) {\n for (var j = 0; j < retval[keys[i]].length; j++) {\n if (isNumeric(retval[keys[i]][j])) {\n retval[keys[i]][j] = 1 * retval[keys[i]][j];\n }\n }\n }\n\n return retval\n}\n\nfunction hasValuesInQueues (queues) {\n var keys = Object.keys(queues)\n return keys.reduce(function (hasValues, key) {\n return hasValues || queues[key].length > 0\n }, false)\n}\n\nfunction getRequiredModules (sources, moduleId) {\n var modulesQueue = {\n main: [moduleId]\n }\n var requiredModules = {\n main: []\n }\n var seenModules = {\n main: {}\n }\n\n while (hasValuesInQueues(modulesQueue)) {\n var queues = Object.keys(modulesQueue)\n for (var i = 0; i < queues.length; i++) {\n var queueName = queues[i]\n var queue = modulesQueue[queueName]\n var moduleToCheck = queue.pop()\n seenModules[queueName] = seenModules[queueName] || {}\n if (seenModules[queueName][moduleToCheck] || !sources[queueName][moduleToCheck]) continue\n seenModules[queueName][moduleToCheck] = true\n requiredModules[queueName] = requiredModules[queueName] || []\n requiredModules[queueName].push(moduleToCheck)\n var newModules = getModuleDependencies(sources, sources[queueName][moduleToCheck], queueName)\n var newModulesKeys = Object.keys(newModules)\n for (var j = 0; j < newModulesKeys.length; j++) {\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]] || []\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])\n }\n }\n }\n\n return requiredModules\n}\n\nmodule.exports = function (moduleId, options) {\n options = options || {}\n var sources = {\n main: __webpack_modules__\n }\n\n var requiredModules = options.all ? { main: Object.keys(sources.main) } : getRequiredModules(sources, moduleId)\n\n var src = ''\n\n Object.keys(requiredModules).filter(function (m) { return m !== 'main' }).forEach(function (module) {\n var entryModule = 0\n while (requiredModules[module][entryModule]) {\n entryModule++\n }\n requiredModules[module].push(entryModule)\n sources[module][entryModule] = '(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })'\n src = src + 'var ' + module + ' = (' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(entryModule)) + ')({' + requiredModules[module].map(function (id) { return '' + JSON.stringify(id) + ': ' + sources[module][id].toString() }).join(',') + '});\\n'\n })\n\n src = src + 'new ((' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(moduleId)) + ')({' + requiredModules.main.map(function (id) { return '' + JSON.stringify(id) + ': ' + sources.main[id].toString() }).join(',') + '}))(self);'\n\n var blob = new window.Blob([src], { type: 'text/javascript' })\n if (options.bare) { return blob }\n\n var URL = window.URL || window.webkitURL || window.mozURL || window.msURL\n\n var workerUrl = URL.createObjectURL(blob)\n var worker = new window.Worker(workerUrl)\n worker.objectURL = workerUrl\n\n return worker\n}\n","// entry/index file\n\n// make it compatible with browserify's umd wrapper\nmodule.exports = require('./mpegts.js').default;\n","/*!\n * @overview es6-promise - a tiny implementation of Promises/A+.\n * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)\n * @license Licensed under MIT license\n * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE\n * @version v4.2.8+1e68dce6\n */\n\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.ES6Promise = factory());\n}(this, (function () { 'use strict';\n\nfunction objectOrFunction(x) {\n var type = typeof x;\n return x !== null && (type === 'object' || type === 'function');\n}\n\nfunction isFunction(x) {\n return typeof x === 'function';\n}\n\n\n\nvar _isArray = void 0;\nif (Array.isArray) {\n _isArray = Array.isArray;\n} else {\n _isArray = function (x) {\n return Object.prototype.toString.call(x) === '[object Array]';\n };\n}\n\nvar isArray = _isArray;\n\nvar len = 0;\nvar vertxNext = void 0;\nvar customSchedulerFn = void 0;\n\nvar asap = function asap(callback, arg) {\n queue[len] = callback;\n queue[len + 1] = arg;\n len += 2;\n if (len === 2) {\n // If len is 2, that means that we need to schedule an async flush.\n // If additional callbacks are queued before the queue is flushed, they\n // will be processed by this flush that we are scheduling.\n if (customSchedulerFn) {\n customSchedulerFn(flush);\n } else {\n scheduleFlush();\n }\n }\n};\n\nfunction setScheduler(scheduleFn) {\n customSchedulerFn = scheduleFn;\n}\n\nfunction setAsap(asapFn) {\n asap = asapFn;\n}\n\nvar browserWindow = typeof window !== 'undefined' ? window : undefined;\nvar browserGlobal = browserWindow || {};\nvar BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;\nvar isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';\n\n// test for web worker but not in IE10\nvar isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';\n\n// node\nfunction useNextTick() {\n // node version 0.10.x displays a deprecation warning when nextTick is used recursively\n // see https://github.com/cujojs/when/issues/410 for details\n return function () {\n return process.nextTick(flush);\n };\n}\n\n// vertx\nfunction useVertxTimer() {\n if (typeof vertxNext !== 'undefined') {\n return function () {\n vertxNext(flush);\n };\n }\n\n return useSetTimeout();\n}\n\nfunction useMutationObserver() {\n var iterations = 0;\n var observer = new BrowserMutationObserver(flush);\n var node = document.createTextNode('');\n observer.observe(node, { characterData: true });\n\n return function () {\n node.data = iterations = ++iterations % 2;\n };\n}\n\n// web worker\nfunction useMessageChannel() {\n var channel = new MessageChannel();\n channel.port1.onmessage = flush;\n return function () {\n return channel.port2.postMessage(0);\n };\n}\n\nfunction useSetTimeout() {\n // Store setTimeout reference so es6-promise will be unaffected by\n // other code modifying setTimeout (like sinon.useFakeTimers())\n var globalSetTimeout = setTimeout;\n return function () {\n return globalSetTimeout(flush, 1);\n };\n}\n\nvar queue = new Array(1000);\nfunction flush() {\n for (var i = 0; i < len; i += 2) {\n var callback = queue[i];\n var arg = queue[i + 1];\n\n callback(arg);\n\n queue[i] = undefined;\n queue[i + 1] = undefined;\n }\n\n len = 0;\n}\n\nfunction attemptVertx() {\n try {\n var vertx = Function('return this')().require('vertx');\n vertxNext = vertx.runOnLoop || vertx.runOnContext;\n return useVertxTimer();\n } catch (e) {\n return useSetTimeout();\n }\n}\n\nvar scheduleFlush = void 0;\n// Decide what async method to use to triggering processing of queued callbacks:\nif (isNode) {\n scheduleFlush = useNextTick();\n} else if (BrowserMutationObserver) {\n scheduleFlush = useMutationObserver();\n} else if (isWorker) {\n scheduleFlush = useMessageChannel();\n} else if (browserWindow === undefined && typeof require === 'function') {\n scheduleFlush = attemptVertx();\n} else {\n scheduleFlush = useSetTimeout();\n}\n\nfunction then(onFulfillment, onRejection) {\n var parent = this;\n\n var child = new this.constructor(noop);\n\n if (child[PROMISE_ID] === undefined) {\n makePromise(child);\n }\n\n var _state = parent._state;\n\n\n if (_state) {\n var callback = arguments[_state - 1];\n asap(function () {\n return invokeCallback(_state, child, callback, parent._result);\n });\n } else {\n subscribe(parent, child, onFulfillment, onRejection);\n }\n\n return child;\n}\n\n/**\n `Promise.resolve` returns a promise that will become resolved with the\n passed `value`. It is shorthand for the following:\n\n ```javascript\n let promise = new Promise(function(resolve, reject){\n resolve(1);\n });\n\n promise.then(function(value){\n // value === 1\n });\n ```\n\n Instead of writing the above, your code now simply becomes the following:\n\n ```javascript\n let promise = Promise.resolve(1);\n\n promise.then(function(value){\n // value === 1\n });\n ```\n\n @method resolve\n @static\n @param {Any} value value that the returned promise will be resolved with\n Useful for tooling.\n @return {Promise} a promise that will become fulfilled with the given\n `value`\n*/\nfunction resolve$1(object) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (object && typeof object === 'object' && object.constructor === Constructor) {\n return object;\n }\n\n var promise = new Constructor(noop);\n resolve(promise, object);\n return promise;\n}\n\nvar PROMISE_ID = Math.random().toString(36).substring(2);\n\nfunction noop() {}\n\nvar PENDING = void 0;\nvar FULFILLED = 1;\nvar REJECTED = 2;\n\nfunction selfFulfillment() {\n return new TypeError(\"You cannot resolve a promise with itself\");\n}\n\nfunction cannotReturnOwn() {\n return new TypeError('A promises callback cannot return that same promise.');\n}\n\nfunction tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {\n try {\n then$$1.call(value, fulfillmentHandler, rejectionHandler);\n } catch (e) {\n return e;\n }\n}\n\nfunction handleForeignThenable(promise, thenable, then$$1) {\n asap(function (promise) {\n var sealed = false;\n var error = tryThen(then$$1, thenable, function (value) {\n if (sealed) {\n return;\n }\n sealed = true;\n if (thenable !== value) {\n resolve(promise, value);\n } else {\n fulfill(promise, value);\n }\n }, function (reason) {\n if (sealed) {\n return;\n }\n sealed = true;\n\n reject(promise, reason);\n }, 'Settle: ' + (promise._label || ' unknown promise'));\n\n if (!sealed && error) {\n sealed = true;\n reject(promise, error);\n }\n }, promise);\n}\n\nfunction handleOwnThenable(promise, thenable) {\n if (thenable._state === FULFILLED) {\n fulfill(promise, thenable._result);\n } else if (thenable._state === REJECTED) {\n reject(promise, thenable._result);\n } else {\n subscribe(thenable, undefined, function (value) {\n return resolve(promise, value);\n }, function (reason) {\n return reject(promise, reason);\n });\n }\n}\n\nfunction handleMaybeThenable(promise, maybeThenable, then$$1) {\n if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {\n handleOwnThenable(promise, maybeThenable);\n } else {\n if (then$$1 === undefined) {\n fulfill(promise, maybeThenable);\n } else if (isFunction(then$$1)) {\n handleForeignThenable(promise, maybeThenable, then$$1);\n } else {\n fulfill(promise, maybeThenable);\n }\n }\n}\n\nfunction resolve(promise, value) {\n if (promise === value) {\n reject(promise, selfFulfillment());\n } else if (objectOrFunction(value)) {\n var then$$1 = void 0;\n try {\n then$$1 = value.then;\n } catch (error) {\n reject(promise, error);\n return;\n }\n handleMaybeThenable(promise, value, then$$1);\n } else {\n fulfill(promise, value);\n }\n}\n\nfunction publishRejection(promise) {\n if (promise._onerror) {\n promise._onerror(promise._result);\n }\n\n publish(promise);\n}\n\nfunction fulfill(promise, value) {\n if (promise._state !== PENDING) {\n return;\n }\n\n promise._result = value;\n promise._state = FULFILLED;\n\n if (promise._subscribers.length !== 0) {\n asap(publish, promise);\n }\n}\n\nfunction reject(promise, reason) {\n if (promise._state !== PENDING) {\n return;\n }\n promise._state = REJECTED;\n promise._result = reason;\n\n asap(publishRejection, promise);\n}\n\nfunction subscribe(parent, child, onFulfillment, onRejection) {\n var _subscribers = parent._subscribers;\n var length = _subscribers.length;\n\n\n parent._onerror = null;\n\n _subscribers[length] = child;\n _subscribers[length + FULFILLED] = onFulfillment;\n _subscribers[length + REJECTED] = onRejection;\n\n if (length === 0 && parent._state) {\n asap(publish, parent);\n }\n}\n\nfunction publish(promise) {\n var subscribers = promise._subscribers;\n var settled = promise._state;\n\n if (subscribers.length === 0) {\n return;\n }\n\n var child = void 0,\n callback = void 0,\n detail = promise._result;\n\n for (var i = 0; i < subscribers.length; i += 3) {\n child = subscribers[i];\n callback = subscribers[i + settled];\n\n if (child) {\n invokeCallback(settled, child, callback, detail);\n } else {\n callback(detail);\n }\n }\n\n promise._subscribers.length = 0;\n}\n\nfunction invokeCallback(settled, promise, callback, detail) {\n var hasCallback = isFunction(callback),\n value = void 0,\n error = void 0,\n succeeded = true;\n\n if (hasCallback) {\n try {\n value = callback(detail);\n } catch (e) {\n succeeded = false;\n error = e;\n }\n\n if (promise === value) {\n reject(promise, cannotReturnOwn());\n return;\n }\n } else {\n value = detail;\n }\n\n if (promise._state !== PENDING) {\n // noop\n } else if (hasCallback && succeeded) {\n resolve(promise, value);\n } else if (succeeded === false) {\n reject(promise, error);\n } else if (settled === FULFILLED) {\n fulfill(promise, value);\n } else if (settled === REJECTED) {\n reject(promise, value);\n }\n}\n\nfunction initializePromise(promise, resolver) {\n try {\n resolver(function resolvePromise(value) {\n resolve(promise, value);\n }, function rejectPromise(reason) {\n reject(promise, reason);\n });\n } catch (e) {\n reject(promise, e);\n }\n}\n\nvar id = 0;\nfunction nextId() {\n return id++;\n}\n\nfunction makePromise(promise) {\n promise[PROMISE_ID] = id++;\n promise._state = undefined;\n promise._result = undefined;\n promise._subscribers = [];\n}\n\nfunction validationError() {\n return new Error('Array Methods must be provided an Array');\n}\n\nvar Enumerator = function () {\n function Enumerator(Constructor, input) {\n this._instanceConstructor = Constructor;\n this.promise = new Constructor(noop);\n\n if (!this.promise[PROMISE_ID]) {\n makePromise(this.promise);\n }\n\n if (isArray(input)) {\n this.length = input.length;\n this._remaining = input.length;\n\n this._result = new Array(this.length);\n\n if (this.length === 0) {\n fulfill(this.promise, this._result);\n } else {\n this.length = this.length || 0;\n this._enumerate(input);\n if (this._remaining === 0) {\n fulfill(this.promise, this._result);\n }\n }\n } else {\n reject(this.promise, validationError());\n }\n }\n\n Enumerator.prototype._enumerate = function _enumerate(input) {\n for (var i = 0; this._state === PENDING && i < input.length; i++) {\n this._eachEntry(input[i], i);\n }\n };\n\n Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {\n var c = this._instanceConstructor;\n var resolve$$1 = c.resolve;\n\n\n if (resolve$$1 === resolve$1) {\n var _then = void 0;\n var error = void 0;\n var didError = false;\n try {\n _then = entry.then;\n } catch (e) {\n didError = true;\n error = e;\n }\n\n if (_then === then && entry._state !== PENDING) {\n this._settledAt(entry._state, i, entry._result);\n } else if (typeof _then !== 'function') {\n this._remaining--;\n this._result[i] = entry;\n } else if (c === Promise$1) {\n var promise = new c(noop);\n if (didError) {\n reject(promise, error);\n } else {\n handleMaybeThenable(promise, entry, _then);\n }\n this._willSettleAt(promise, i);\n } else {\n this._willSettleAt(new c(function (resolve$$1) {\n return resolve$$1(entry);\n }), i);\n }\n } else {\n this._willSettleAt(resolve$$1(entry), i);\n }\n };\n\n Enumerator.prototype._settledAt = function _settledAt(state, i, value) {\n var promise = this.promise;\n\n\n if (promise._state === PENDING) {\n this._remaining--;\n\n if (state === REJECTED) {\n reject(promise, value);\n } else {\n this._result[i] = value;\n }\n }\n\n if (this._remaining === 0) {\n fulfill(promise, this._result);\n }\n };\n\n Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {\n var enumerator = this;\n\n subscribe(promise, undefined, function (value) {\n return enumerator._settledAt(FULFILLED, i, value);\n }, function (reason) {\n return enumerator._settledAt(REJECTED, i, reason);\n });\n };\n\n return Enumerator;\n}();\n\n/**\n `Promise.all` accepts an array of promises, and returns a new promise which\n is fulfilled with an array of fulfillment values for the passed promises, or\n rejected with the reason of the first passed promise to be rejected. It casts all\n elements of the passed iterable to promises as it runs this algorithm.\n\n Example:\n\n ```javascript\n let promise1 = resolve(1);\n let promise2 = resolve(2);\n let promise3 = resolve(3);\n let promises = [ promise1, promise2, promise3 ];\n\n Promise.all(promises).then(function(array){\n // The array here would be [ 1, 2, 3 ];\n });\n ```\n\n If any of the `promises` given to `all` are rejected, the first promise\n that is rejected will be given as an argument to the returned promises's\n rejection handler. For example:\n\n Example:\n\n ```javascript\n let promise1 = resolve(1);\n let promise2 = reject(new Error(\"2\"));\n let promise3 = reject(new Error(\"3\"));\n let promises = [ promise1, promise2, promise3 ];\n\n Promise.all(promises).then(function(array){\n // Code here never runs because there are rejected promises!\n }, function(error) {\n // error.message === \"2\"\n });\n ```\n\n @method all\n @static\n @param {Array} entries array of promises\n @param {String} label optional string for labeling the promise.\n Useful for tooling.\n @return {Promise} promise that is fulfilled when all `promises` have been\n fulfilled, or rejected if any of them become rejected.\n @static\n*/\nfunction all(entries) {\n return new Enumerator(this, entries).promise;\n}\n\n/**\n `Promise.race` returns a new promise which is settled in the same way as the\n first passed promise to settle.\n\n Example:\n\n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n\n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 2');\n }, 100);\n });\n\n Promise.race([promise1, promise2]).then(function(result){\n // result === 'promise 2' because it was resolved before promise1\n // was resolved.\n });\n ```\n\n `Promise.race` is deterministic in that only the state of the first\n settled promise matters. For example, even if other promises given to the\n `promises` array argument are resolved, but the first settled promise has\n become rejected before the other promises became fulfilled, the returned\n promise will become rejected:\n\n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n\n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n reject(new Error('promise 2'));\n }, 100);\n });\n\n Promise.race([promise1, promise2]).then(function(result){\n // Code here never runs\n }, function(reason){\n // reason.message === 'promise 2' because promise 2 became rejected before\n // promise 1 became fulfilled\n });\n ```\n\n An example real-world use case is implementing timeouts:\n\n ```javascript\n Promise.race([ajax('foo.json'), timeout(5000)])\n ```\n\n @method race\n @static\n @param {Array} promises array of promises to observe\n Useful for tooling.\n @return {Promise} a promise which settles in the same way as the first passed\n promise to settle.\n*/\nfunction race(entries) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (!isArray(entries)) {\n return new Constructor(function (_, reject) {\n return reject(new TypeError('You must pass an array to race.'));\n });\n } else {\n return new Constructor(function (resolve, reject) {\n var length = entries.length;\n for (var i = 0; i < length; i++) {\n Constructor.resolve(entries[i]).then(resolve, reject);\n }\n });\n }\n}\n\n/**\n `Promise.reject` returns a promise rejected with the passed `reason`.\n It is shorthand for the following:\n\n ```javascript\n let promise = new Promise(function(resolve, reject){\n reject(new Error('WHOOPS'));\n });\n\n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n\n Instead of writing the above, your code now simply becomes the following:\n\n ```javascript\n let promise = Promise.reject(new Error('WHOOPS'));\n\n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n\n @method reject\n @static\n @param {Any} reason value that the returned promise will be rejected with.\n Useful for tooling.\n @return {Promise} a promise rejected with the given `reason`.\n*/\nfunction reject$1(reason) {\n /*jshint validthis:true */\n var Constructor = this;\n var promise = new Constructor(noop);\n reject(promise, reason);\n return promise;\n}\n\nfunction needsResolver() {\n throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');\n}\n\nfunction needsNew() {\n throw new TypeError(\"Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.\");\n}\n\n/**\n Promise objects represent the eventual result of an asynchronous operation. The\n primary way of interacting with a promise is through its `then` method, which\n registers callbacks to receive either a promise's eventual value or the reason\n why the promise cannot be fulfilled.\n\n Terminology\n -----------\n\n - `promise` is an object or function with a `then` method whose behavior conforms to this specification.\n - `thenable` is an object or function that defines a `then` method.\n - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).\n - `exception` is a value that is thrown using the throw statement.\n - `reason` is a value that indicates why a promise was rejected.\n - `settled` the final resting state of a promise, fulfilled or rejected.\n\n A promise can be in one of three states: pending, fulfilled, or rejected.\n\n Promises that are fulfilled have a fulfillment value and are in the fulfilled\n state. Promises that are rejected have a rejection reason and are in the\n rejected state. A fulfillment value is never a thenable.\n\n Promises can also be said to *resolve* a value. If this value is also a\n promise, then the original promise's settled state will match the value's\n settled state. So a promise that *resolves* a promise that rejects will\n itself reject, and a promise that *resolves* a promise that fulfills will\n itself fulfill.\n\n\n Basic Usage:\n ------------\n\n ```js\n let promise = new Promise(function(resolve, reject) {\n // on success\n resolve(value);\n\n // on failure\n reject(reason);\n });\n\n promise.then(function(value) {\n // on fulfillment\n }, function(reason) {\n // on rejection\n });\n ```\n\n Advanced Usage:\n ---------------\n\n Promises shine when abstracting away asynchronous interactions such as\n `XMLHttpRequest`s.\n\n ```js\n function getJSON(url) {\n return new Promise(function(resolve, reject){\n let xhr = new XMLHttpRequest();\n\n xhr.open('GET', url);\n xhr.onreadystatechange = handler;\n xhr.responseType = 'json';\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send();\n\n function handler() {\n if (this.readyState === this.DONE) {\n if (this.status === 200) {\n resolve(this.response);\n } else {\n reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));\n }\n }\n };\n });\n }\n\n getJSON('/posts.json').then(function(json) {\n // on fulfillment\n }, function(reason) {\n // on rejection\n });\n ```\n\n Unlike callbacks, promises are great composable primitives.\n\n ```js\n Promise.all([\n getJSON('/posts'),\n getJSON('/comments')\n ]).then(function(values){\n values[0] // => postsJSON\n values[1] // => commentsJSON\n\n return values;\n });\n ```\n\n @class Promise\n @param {Function} resolver\n Useful for tooling.\n @constructor\n*/\n\nvar Promise$1 = function () {\n function Promise(resolver) {\n this[PROMISE_ID] = nextId();\n this._result = this._state = undefined;\n this._subscribers = [];\n\n if (noop !== resolver) {\n typeof resolver !== 'function' && needsResolver();\n this instanceof Promise ? initializePromise(this, resolver) : needsNew();\n }\n }\n\n /**\n The primary way of interacting with a promise is through its `then` method,\n which registers callbacks to receive either a promise's eventual value or the\n reason why the promise cannot be fulfilled.\n ```js\n findUser().then(function(user){\n // user is available\n }, function(reason){\n // user is unavailable, and you are given the reason why\n });\n ```\n Chaining\n --------\n The return value of `then` is itself a promise. This second, 'downstream'\n promise is resolved with the return value of the first promise's fulfillment\n or rejection handler, or rejected if the handler throws an exception.\n ```js\n findUser().then(function (user) {\n return user.name;\n }, function (reason) {\n return 'default name';\n }).then(function (userName) {\n // If `findUser` fulfilled, `userName` will be the user's name, otherwise it\n // will be `'default name'`\n });\n findUser().then(function (user) {\n throw new Error('Found user, but still unhappy');\n }, function (reason) {\n throw new Error('`findUser` rejected and we're unhappy');\n }).then(function (value) {\n // never reached\n }, function (reason) {\n // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.\n // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.\n });\n ```\n If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.\n ```js\n findUser().then(function (user) {\n throw new PedagogicalException('Upstream error');\n }).then(function (value) {\n // never reached\n }).then(function (value) {\n // never reached\n }, function (reason) {\n // The `PedgagocialException` is propagated all the way down to here\n });\n ```\n Assimilation\n ------------\n Sometimes the value you want to propagate to a downstream promise can only be\n retrieved asynchronously. This can be achieved by returning a promise in the\n fulfillment or rejection handler. The downstream promise will then be pending\n until the returned promise is settled. This is called *assimilation*.\n ```js\n findUser().then(function (user) {\n return findCommentsByAuthor(user);\n }).then(function (comments) {\n // The user's comments are now available\n });\n ```\n If the assimliated promise rejects, then the downstream promise will also reject.\n ```js\n findUser().then(function (user) {\n return findCommentsByAuthor(user);\n }).then(function (comments) {\n // If `findCommentsByAuthor` fulfills, we'll have the value here\n }, function (reason) {\n // If `findCommentsByAuthor` rejects, we'll have the reason here\n });\n ```\n Simple Example\n --------------\n Synchronous Example\n ```javascript\n let result;\n try {\n result = findResult();\n // success\n } catch(reason) {\n // failure\n }\n ```\n Errback Example\n ```js\n findResult(function(result, err){\n if (err) {\n // failure\n } else {\n // success\n }\n });\n ```\n Promise Example;\n ```javascript\n findResult().then(function(result){\n // success\n }, function(reason){\n // failure\n });\n ```\n Advanced Example\n --------------\n Synchronous Example\n ```javascript\n let author, books;\n try {\n author = findAuthor();\n books = findBooksByAuthor(author);\n // success\n } catch(reason) {\n // failure\n }\n ```\n Errback Example\n ```js\n function foundBooks(books) {\n }\n function failure(reason) {\n }\n findAuthor(function(author, err){\n if (err) {\n failure(err);\n // failure\n } else {\n try {\n findBoooksByAuthor(author, function(books, err) {\n if (err) {\n failure(err);\n } else {\n try {\n foundBooks(books);\n } catch(reason) {\n failure(reason);\n }\n }\n });\n } catch(error) {\n failure(err);\n }\n // success\n }\n });\n ```\n Promise Example;\n ```javascript\n findAuthor().\n then(findBooksByAuthor).\n then(function(books){\n // found books\n }).catch(function(reason){\n // something went wrong\n });\n ```\n @method then\n @param {Function} onFulfilled\n @param {Function} onRejected\n Useful for tooling.\n @return {Promise}\n */\n\n /**\n `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same\n as the catch block of a try/catch statement.\n ```js\n function findAuthor(){\n throw new Error('couldn't find that author');\n }\n // synchronous\n try {\n findAuthor();\n } catch(reason) {\n // something went wrong\n }\n // async with promises\n findAuthor().catch(function(reason){\n // something went wrong\n });\n ```\n @method catch\n @param {Function} onRejection\n Useful for tooling.\n @return {Promise}\n */\n\n\n Promise.prototype.catch = function _catch(onRejection) {\n return this.then(null, onRejection);\n };\n\n /**\n `finally` will be invoked regardless of the promise's fate just as native\n try/catch/finally behaves\n \n Synchronous example:\n \n ```js\n findAuthor() {\n if (Math.random() > 0.5) {\n throw new Error();\n }\n return new Author();\n }\n \n try {\n return findAuthor(); // succeed or fail\n } catch(error) {\n return findOtherAuther();\n } finally {\n // always runs\n // doesn't affect the return value\n }\n ```\n \n Asynchronous example:\n \n ```js\n findAuthor().catch(function(reason){\n return findOtherAuther();\n }).finally(function(){\n // author was either found, or not\n });\n ```\n \n @method finally\n @param {Function} callback\n @return {Promise}\n */\n\n\n Promise.prototype.finally = function _finally(callback) {\n var promise = this;\n var constructor = promise.constructor;\n\n if (isFunction(callback)) {\n return promise.then(function (value) {\n return constructor.resolve(callback()).then(function () {\n return value;\n });\n }, function (reason) {\n return constructor.resolve(callback()).then(function () {\n throw reason;\n });\n });\n }\n\n return promise.then(callback, callback);\n };\n\n return Promise;\n}();\n\nPromise$1.prototype.then = then;\nPromise$1.all = all;\nPromise$1.race = race;\nPromise$1.resolve = resolve$1;\nPromise$1.reject = reject$1;\nPromise$1._setScheduler = setScheduler;\nPromise$1._setAsap = setAsap;\nPromise$1._asap = asap;\n\n/*global self*/\nfunction polyfill() {\n var local = void 0;\n\n if (typeof global !== 'undefined') {\n local = global;\n } else if (typeof self !== 'undefined') {\n local = self;\n } else {\n try {\n local = Function('return this')();\n } catch (e) {\n throw new Error('polyfill failed because global object is unavailable in this environment');\n }\n }\n\n var P = local.Promise;\n\n if (P) {\n var promiseToString = null;\n try {\n promiseToString = Object.prototype.toString.call(P.resolve());\n } catch (e) {\n // silently ignored\n }\n\n if (promiseToString === '[object Promise]' && !P.cast) {\n return;\n }\n }\n\n local.Promise = Promise$1;\n}\n\n// Strange compat..\nPromise$1.polyfill = polyfill;\nPromise$1.Promise = Promise$1;\n\nreturn Promise$1;\n\n})));\n\n\n\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport LoggingControl from '../utils/logging-control.js';\nimport Polyfill from '../utils/polyfill.js';\nimport TransmuxingController from './transmuxing-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\n\n/* post message to worker:\n data: {\n cmd: string\n param: any\n }\n\n receive message from worker:\n data: {\n msg: string,\n data: any\n }\n */\n\nlet TransmuxingWorker = function (self) {\n\n let TAG = 'TransmuxingWorker';\n let controller = null;\n let logcatListener = onLogcatCallback.bind(this);\n\n Polyfill.install();\n\n self.addEventListener('message', function (e) {\n switch (e.data.cmd) {\n case 'init':\n controller = new TransmuxingController(e.data.param[0], e.data.param[1]);\n controller.on(TransmuxingEvents.IO_ERROR, onIOError.bind(this));\n controller.on(TransmuxingEvents.DEMUX_ERROR, onDemuxError.bind(this));\n controller.on(TransmuxingEvents.INIT_SEGMENT, onInitSegment.bind(this));\n controller.on(TransmuxingEvents.MEDIA_SEGMENT, onMediaSegment.bind(this));\n controller.on(TransmuxingEvents.LOADING_COMPLETE, onLoadingComplete.bind(this));\n controller.on(TransmuxingEvents.RECOVERED_EARLY_EOF, onRecoveredEarlyEof.bind(this));\n controller.on(TransmuxingEvents.MEDIA_INFO, onMediaInfo.bind(this));\n controller.on(TransmuxingEvents.METADATA_ARRIVED, onMetaDataArrived.bind(this));\n controller.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, onScriptDataArrived.bind(this));\n controller.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, onTimedID3MetadataArrived.bind(this));\n controller.on(TransmuxingEvents.SCTE35_METADATA_ARRIVED, onSCTE35MetadataArrived.bind(this));\n controller.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, onPESPrivateDataDescriptor.bind(this));\n controller.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, onPESPrivateDataArrived.bind(this));\n controller.on(TransmuxingEvents.STATISTICS_INFO, onStatisticsInfo.bind(this));\n controller.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, onRecommendSeekpoint.bind(this));\n break;\n case 'destroy':\n if (controller) {\n controller.destroy();\n controller = null;\n }\n self.postMessage({msg: 'destroyed'});\n break;\n case 'start':\n controller.start();\n break;\n case 'stop':\n controller.stop();\n break;\n case 'seek':\n controller.seek(e.data.param);\n break;\n case 'pause':\n controller.pause();\n break;\n case 'resume':\n controller.resume();\n break;\n case 'logging_config': {\n let config = e.data.param;\n LoggingControl.applyConfig(config);\n\n if (config.enableCallback === true) {\n LoggingControl.addLogListener(logcatListener);\n } else {\n LoggingControl.removeLogListener(logcatListener);\n }\n break;\n }\n }\n });\n\n function onInitSegment(type, initSegment) {\n let obj = {\n msg: TransmuxingEvents.INIT_SEGMENT,\n data: {\n type: type,\n data: initSegment\n }\n };\n self.postMessage(obj, [initSegment.data]); // data: ArrayBuffer\n }\n\n function onMediaSegment(type, mediaSegment) {\n let obj = {\n msg: TransmuxingEvents.MEDIA_SEGMENT,\n data: {\n type: type,\n data: mediaSegment\n }\n };\n self.postMessage(obj, [mediaSegment.data]); // data: ArrayBuffer\n }\n\n function onLoadingComplete() {\n let obj = {\n msg: TransmuxingEvents.LOADING_COMPLETE\n };\n self.postMessage(obj);\n }\n\n function onRecoveredEarlyEof() {\n let obj = {\n msg: TransmuxingEvents.RECOVERED_EARLY_EOF\n };\n self.postMessage(obj);\n }\n\n function onMediaInfo(mediaInfo) {\n let obj = {\n msg: TransmuxingEvents.MEDIA_INFO,\n data: mediaInfo\n };\n self.postMessage(obj);\n }\n\n function onMetaDataArrived(metadata) {\n let obj = {\n msg: TransmuxingEvents.METADATA_ARRIVED,\n data: metadata\n };\n self.postMessage(obj);\n }\n\n function onScriptDataArrived(data) {\n let obj = {\n msg: TransmuxingEvents.SCRIPTDATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onTimedID3MetadataArrived (data) {\n let obj = {\n msg: TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onSCTE35MetadataArrived (data) {\n let obj = {\n msg: TransmuxingEvents.SCTE35_METADATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onPESPrivateDataDescriptor(data) {\n let obj = {\n msg: TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onPESPrivateDataArrived(data) {\n let obj = {\n msg: TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onStatisticsInfo(statInfo) {\n let obj = {\n msg: TransmuxingEvents.STATISTICS_INFO,\n data: statInfo\n };\n self.postMessage(obj);\n }\n\n function onIOError(type, info) {\n self.postMessage({\n msg: TransmuxingEvents.IO_ERROR,\n data: {\n type: type,\n info: info\n }\n });\n }\n\n function onDemuxError(type, info) {\n self.postMessage({\n msg: TransmuxingEvents.DEMUX_ERROR,\n data: {\n type: type,\n info: info\n }\n });\n }\n\n function onRecommendSeekpoint(milliseconds) {\n self.postMessage({\n msg: TransmuxingEvents.RECOMMEND_SEEKPOINT,\n data: milliseconds\n });\n }\n\n function onLogcatCallback(type, str) {\n self.postMessage({\n msg: 'logcat_callback',\n data: {\n type: type,\n logcat: str\n }\n });\n }\n\n};\n\nexport default TransmuxingWorker;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const defaultConfig = {\n enableWorker: false,\n enableStashBuffer: true,\n stashInitialSize: undefined,\n\n isLive: false,\n\n liveBufferLatencyChasing: false,\n liveBufferLatencyMaxLatency: 1.5,\n liveBufferLatencyMinRemain: 0.5,\n\n lazyLoad: true,\n lazyLoadMaxDuration: 3 * 60,\n lazyLoadRecoverDuration: 30,\n deferLoadAfterSourceOpen: true,\n\n // autoCleanupSourceBuffer: default as false, leave unspecified\n autoCleanupMaxBackwardDuration: 3 * 60,\n autoCleanupMinBackwardDuration: 2 * 60,\n\n statisticsInfoReportInterval: 600,\n\n fixAudioTimestampGap: true,\n\n accurateSeek: false,\n seekType: 'range', // [range, param, custom]\n seekParamStart: 'bstart',\n seekParamEnd: 'bend',\n rangeLoadZeroStart: false,\n customSeekHandler: undefined,\n reuseRedirectedURL: false,\n // referrerPolicy: leave as unspecified\n\n headers: undefined,\n customLoader: undefined\n};\n\nexport function createDefaultConfig() {\n return Object.assign({}, defaultConfig);\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport IOController from '../io/io-controller.js';\nimport {createDefaultConfig} from '../config.js';\n\nclass Features {\n\n static supportMSEH264Playback() {\n return window.MediaSource &&\n window.MediaSource.isTypeSupported('video/mp4; codecs=\"avc1.42E01E,mp4a.40.2\"');\n }\n\n static supportNetworkStreamIO() {\n let ioctl = new IOController({}, createDefaultConfig());\n let loaderType = ioctl.loaderType;\n ioctl.destroy();\n return loaderType == 'fetch-stream-loader' || loaderType == 'xhr-moz-chunked-loader';\n }\n\n static getNetworkLoaderTypeName() {\n let ioctl = new IOController({}, createDefaultConfig());\n let loaderType = ioctl.loaderType;\n ioctl.destroy();\n return loaderType;\n }\n\n static supportNativeMediaPlayback(mimeType) {\n if (Features.videoElement == undefined) {\n Features.videoElement = window.document.createElement('video');\n }\n let canPlay = Features.videoElement.canPlayType(mimeType);\n return canPlay === 'probably' || canPlay == 'maybe';\n }\n\n static getFeatureList() {\n let features = {\n msePlayback: false,\n mseLivePlayback: false,\n networkStreamIO: false,\n networkLoaderName: '',\n nativeMP4H264Playback: false,\n nativeWebmVP8Playback: false,\n nativeWebmVP9Playback: false\n };\n\n features.msePlayback = Features.supportMSEH264Playback();\n features.networkStreamIO = Features.supportNetworkStreamIO();\n features.networkLoaderName = Features.getNetworkLoaderTypeName();\n features.mseLivePlayback = features.msePlayback && features.networkStreamIO;\n features.nativeMP4H264Playback = Features.supportNativeMediaPlayback('video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"');\n features.nativeWebmVP8Playback = Features.supportNativeMediaPlayback('video/webm; codecs=\"vp8.0, vorbis\"');\n features.nativeWebmVP9Playback = Features.supportNativeMediaPlayback('video/webm; codecs=\"vp9\"');\n\n return features;\n }\n\n}\n\nexport default Features;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PlayerEvents = {\n ERROR: 'error',\n LOADING_COMPLETE: 'loading_complete',\n RECOVERED_EARLY_EOF: 'recovered_early_eof',\n MEDIA_INFO: 'media_info',\n METADATA_ARRIVED: 'metadata_arrived',\n SCRIPTDATA_ARRIVED: 'scriptdata_arrived',\n TIMED_ID3_METADATA_ARRIVED: 'timed_id3_metadata_arrived',\n SCTE35_METADATA_ARRIVED: 'scte35_metadata_arrived',\n PES_PRIVATE_DATA_DESCRIPTOR: 'pes_private_data_descriptor',\n PES_PRIVATE_DATA_ARRIVED: 'pes_private_data_arrived',\n STATISTICS_INFO: 'statistics_info'\n};\n\nexport default PlayerEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport work from 'webworkify-webpack';\nimport Log from '../utils/logger.js';\nimport LoggingControl from '../utils/logging-control.js';\nimport TransmuxingController from './transmuxing-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\nimport TransmuxingWorker from './transmuxing-worker.js';\nimport MediaInfo from './media-info.js';\n\nclass Transmuxer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'Transmuxer';\n this._emitter = new EventEmitter();\n\n if (config.enableWorker && typeof (Worker) !== 'undefined') {\n try {\n this._worker = work(require.resolve('./transmuxing-worker'));\n this._workerDestroying = false;\n this._worker.addEventListener('message', this._onWorkerMessage.bind(this));\n this._worker.postMessage({cmd: 'init', param: [mediaDataSource, config]});\n this.e = {\n onLoggingConfigChanged: this._onLoggingConfigChanged.bind(this)\n };\n LoggingControl.registerListener(this.e.onLoggingConfigChanged);\n this._worker.postMessage({cmd: 'logging_config', param: LoggingControl.getConfig()});\n } catch (error) {\n Log.e(this.TAG, 'Error while initialize transmuxing worker, fallback to inline transmuxing');\n this._worker = null;\n this._controller = new TransmuxingController(mediaDataSource, config);\n }\n } else {\n this._controller = new TransmuxingController(mediaDataSource, config);\n }\n\n if (this._controller) {\n let ctl = this._controller;\n ctl.on(TransmuxingEvents.IO_ERROR, this._onIOError.bind(this));\n ctl.on(TransmuxingEvents.DEMUX_ERROR, this._onDemuxError.bind(this));\n ctl.on(TransmuxingEvents.INIT_SEGMENT, this._onInitSegment.bind(this));\n ctl.on(TransmuxingEvents.MEDIA_SEGMENT, this._onMediaSegment.bind(this));\n ctl.on(TransmuxingEvents.LOADING_COMPLETE, this._onLoadingComplete.bind(this));\n ctl.on(TransmuxingEvents.RECOVERED_EARLY_EOF, this._onRecoveredEarlyEof.bind(this));\n ctl.on(TransmuxingEvents.MEDIA_INFO, this._onMediaInfo.bind(this));\n ctl.on(TransmuxingEvents.METADATA_ARRIVED, this._onMetaDataArrived.bind(this));\n ctl.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, this._onScriptDataArrived.bind(this));\n ctl.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, this._onTimedID3MetadataArrived.bind(this));\n ctl.on(TransmuxingEvents.SCTE35_METADATA_ARRIVED, this._onSCTE35MetadataArrived.bind(this));\n ctl.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, this._onPESPrivateDataDescriptor.bind(this));\n ctl.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, this._onPESPrivateDataArrived.bind(this));\n ctl.on(TransmuxingEvents.STATISTICS_INFO, this._onStatisticsInfo.bind(this));\n ctl.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, this._onRecommendSeekpoint.bind(this));\n }\n }\n\n destroy() {\n if (this._worker) {\n if (!this._workerDestroying) {\n this._workerDestroying = true;\n this._worker.postMessage({cmd: 'destroy'});\n LoggingControl.removeListener(this.e.onLoggingConfigChanged);\n this.e = null;\n }\n } else {\n this._controller.destroy();\n this._controller = null;\n }\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n hasWorker() {\n return this._worker != null;\n }\n\n open() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'start'});\n } else {\n this._controller.start();\n }\n }\n\n close() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'stop'});\n } else {\n this._controller.stop();\n }\n }\n\n seek(milliseconds) {\n if (this._worker) {\n this._worker.postMessage({cmd: 'seek', param: milliseconds});\n } else {\n this._controller.seek(milliseconds);\n }\n }\n\n pause() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'pause'});\n } else {\n this._controller.pause();\n }\n }\n\n resume() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'resume'});\n } else {\n this._controller.resume();\n }\n }\n\n _onInitSegment(type, initSegment) {\n // do async invoke\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.INIT_SEGMENT, type, initSegment);\n });\n }\n\n _onMediaSegment(type, mediaSegment) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.MEDIA_SEGMENT, type, mediaSegment);\n });\n }\n\n _onLoadingComplete() {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.LOADING_COMPLETE);\n });\n }\n\n _onRecoveredEarlyEof() {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.RECOVERED_EARLY_EOF);\n });\n }\n\n _onMediaInfo(mediaInfo) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.MEDIA_INFO, mediaInfo);\n });\n }\n\n _onMetaDataArrived(metadata) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.METADATA_ARRIVED, metadata);\n });\n }\n\n _onScriptDataArrived(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.SCRIPTDATA_ARRIVED, data);\n });\n }\n\n _onTimedID3MetadataArrived (data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, data);\n })\n }\n\n _onSCTE35MetadataArrived (data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.SCTE35_METADATA_ARRIVED, data);\n })\n }\n\n _onPESPrivateDataDescriptor(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, data);\n });\n }\n\n _onPESPrivateDataArrived(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, data);\n });\n }\n\n _onStatisticsInfo(statisticsInfo) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.STATISTICS_INFO, statisticsInfo);\n });\n }\n\n _onIOError(type, info) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.IO_ERROR, type, info);\n });\n }\n\n _onDemuxError(type, info) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, type, info);\n });\n }\n\n _onRecommendSeekpoint(milliseconds) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.RECOMMEND_SEEKPOINT, milliseconds);\n });\n }\n\n _onLoggingConfigChanged(config) {\n if (this._worker) {\n this._worker.postMessage({cmd: 'logging_config', param: config});\n }\n }\n\n _onWorkerMessage(e) {\n let message = e.data;\n let data = message.data;\n\n if (message.msg === 'destroyed' || this._workerDestroying) {\n this._workerDestroying = false;\n this._worker.terminate();\n this._worker = null;\n return;\n }\n\n switch (message.msg) {\n case TransmuxingEvents.INIT_SEGMENT:\n case TransmuxingEvents.MEDIA_SEGMENT:\n this._emitter.emit(message.msg, data.type, data.data);\n break;\n case TransmuxingEvents.LOADING_COMPLETE:\n case TransmuxingEvents.RECOVERED_EARLY_EOF:\n this._emitter.emit(message.msg);\n break;\n case TransmuxingEvents.MEDIA_INFO:\n Object.setPrototypeOf(data, MediaInfo.prototype);\n this._emitter.emit(message.msg, data);\n break;\n case TransmuxingEvents.METADATA_ARRIVED:\n case TransmuxingEvents.SCRIPTDATA_ARRIVED:\n case TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED:\n case TransmuxingEvents.SCTE35_METADATA_ARRIVED:\n case TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR:\n case TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED:\n case TransmuxingEvents.STATISTICS_INFO:\n this._emitter.emit(message.msg, data);\n break;\n case TransmuxingEvents.IO_ERROR:\n case TransmuxingEvents.DEMUX_ERROR:\n this._emitter.emit(message.msg, data.type, data.info);\n break;\n case TransmuxingEvents.RECOMMEND_SEEKPOINT:\n this._emitter.emit(message.msg, data);\n break;\n case 'logcat_callback':\n Log.emitter.emit('log', data.type, data.logcat);\n break;\n default:\n break;\n }\n }\n\n}\n\nexport default Transmuxer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst MSEEvents = {\n ERROR: 'error',\n SOURCE_OPEN: 'source_open',\n UPDATE_END: 'update_end',\n BUFFER_FULL: 'buffer_full'\n};\n\nexport default MSEEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport MSEEvents from './mse-events.js';\nimport {SampleInfo, IDRSampleList} from './media-segment-info.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\n// Media Source Extensions controller\nclass MSEController {\n\n constructor(config) {\n this.TAG = 'MSEController';\n\n this._config = config;\n this._emitter = new EventEmitter();\n\n if (this._config.isLive && this._config.autoCleanupSourceBuffer == undefined) {\n // For live stream, do auto cleanup by default\n this._config.autoCleanupSourceBuffer = true;\n }\n\n this.e = {\n onSourceOpen: this._onSourceOpen.bind(this),\n onSourceEnded: this._onSourceEnded.bind(this),\n onSourceClose: this._onSourceClose.bind(this),\n onSourceBufferError: this._onSourceBufferError.bind(this),\n onSourceBufferUpdateEnd: this._onSourceBufferUpdateEnd.bind(this)\n };\n\n this._mediaSource = null;\n this._mediaSourceObjectURL = null;\n this._mediaElement = null;\n\n this._isBufferFull = false;\n this._hasPendingEos = false;\n\n this._requireSetMediaDuration = false;\n this._pendingMediaDuration = 0;\n\n this._pendingSourceBufferInit = [];\n this._mimeTypes = {\n video: null,\n audio: null\n };\n this._sourceBuffers = {\n video: null,\n audio: null\n };\n this._lastInitSegments = {\n video: null,\n audio: null\n };\n this._pendingSegments = {\n video: [],\n audio: []\n };\n this._pendingRemoveRanges = {\n video: [],\n audio: []\n };\n this._idrList = new IDRSampleList();\n }\n\n destroy() {\n if (this._mediaElement || this._mediaSource) {\n this.detachMediaElement();\n }\n this.e = null;\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n if (this._mediaSource) {\n throw new IllegalStateException('MediaSource has been attached to an HTMLMediaElement!');\n }\n let ms = this._mediaSource = new window.MediaSource();\n ms.addEventListener('sourceopen', this.e.onSourceOpen);\n ms.addEventListener('sourceended', this.e.onSourceEnded);\n ms.addEventListener('sourceclose', this.e.onSourceClose);\n\n this._mediaElement = mediaElement;\n this._mediaSourceObjectURL = window.URL.createObjectURL(this._mediaSource);\n mediaElement.src = this._mediaSourceObjectURL;\n }\n\n detachMediaElement() {\n if (this._mediaSource) {\n let ms = this._mediaSource;\n for (let type in this._sourceBuffers) {\n // pending segments should be discard\n let ps = this._pendingSegments[type];\n ps.splice(0, ps.length);\n this._pendingSegments[type] = null;\n this._pendingRemoveRanges[type] = null;\n this._lastInitSegments[type] = null;\n\n // remove all sourcebuffers\n let sb = this._sourceBuffers[type];\n if (sb) {\n if (ms.readyState !== 'closed') {\n // ms edge can throw an error: Unexpected call to method or property access\n try {\n ms.removeSourceBuffer(sb);\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n sb.removeEventListener('error', this.e.onSourceBufferError);\n sb.removeEventListener('updateend', this.e.onSourceBufferUpdateEnd);\n }\n this._mimeTypes[type] = null;\n this._sourceBuffers[type] = null;\n }\n }\n if (ms.readyState === 'open') {\n try {\n ms.endOfStream();\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n }\n ms.removeEventListener('sourceopen', this.e.onSourceOpen);\n ms.removeEventListener('sourceended', this.e.onSourceEnded);\n ms.removeEventListener('sourceclose', this.e.onSourceClose);\n this._pendingSourceBufferInit = [];\n this._isBufferFull = false;\n this._idrList.clear();\n this._mediaSource = null;\n }\n\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n this._mediaElement = null;\n }\n if (this._mediaSourceObjectURL) {\n window.URL.revokeObjectURL(this._mediaSourceObjectURL);\n this._mediaSourceObjectURL = null;\n }\n }\n\n appendInitSegment(initSegment, deferred) {\n if (!this._mediaSource || this._mediaSource.readyState !== 'open') {\n // sourcebuffer creation requires mediaSource.readyState === 'open'\n // so we defer the sourcebuffer creation, until sourceopen event triggered\n this._pendingSourceBufferInit.push(initSegment);\n // make sure that this InitSegment is in the front of pending segments queue\n this._pendingSegments[initSegment.type].push(initSegment);\n return;\n }\n\n let is = initSegment;\n let mimeType = `${is.container}`;\n if (is.codec && is.codec.length > 0) {\n mimeType += `;codecs=${is.codec}`;\n }\n\n let firstInitSegment = false;\n\n Log.v(this.TAG, 'Received Initialization Segment, mimeType: ' + mimeType);\n this._lastInitSegments[is.type] = is;\n\n if (mimeType !== this._mimeTypes[is.type]) {\n if (!this._mimeTypes[is.type]) { // empty, first chance create sourcebuffer\n firstInitSegment = true;\n try {\n let sb = this._sourceBuffers[is.type] = this._mediaSource.addSourceBuffer(mimeType);\n sb.addEventListener('error', this.e.onSourceBufferError);\n sb.addEventListener('updateend', this.e.onSourceBufferUpdateEnd);\n } catch (error) {\n Log.e(this.TAG, error.message);\n this._emitter.emit(MSEEvents.ERROR, {code: error.code, msg: error.message});\n return;\n }\n } else {\n Log.v(this.TAG, `Notice: ${is.type} mimeType changed, origin: ${this._mimeTypes[is.type]}, target: ${mimeType}`);\n }\n this._mimeTypes[is.type] = mimeType;\n }\n\n if (!deferred) {\n // deferred means this InitSegment has been pushed to pendingSegments queue\n this._pendingSegments[is.type].push(is);\n }\n if (!firstInitSegment) { // append immediately only if init segment in subsequence\n if (this._sourceBuffers[is.type] && !this._sourceBuffers[is.type].updating) {\n this._doAppendSegments();\n }\n }\n if (Browser.safari && is.container === 'audio/mpeg' && is.mediaDuration > 0) {\n // 'audio/mpeg' track under Safari may cause MediaElement's duration to be NaN\n // Manually correct MediaSource.duration to make progress bar seekable, and report right duration\n this._requireSetMediaDuration = true;\n this._pendingMediaDuration = is.mediaDuration / 1000; // in seconds\n this._updateMediaSourceDuration();\n }\n }\n\n appendMediaSegment(mediaSegment) {\n let ms = mediaSegment;\n this._pendingSegments[ms.type].push(ms);\n\n if (this._config.autoCleanupSourceBuffer && this._needCleanupSourceBuffer()) {\n this._doCleanupSourceBuffer();\n }\n\n let sb = this._sourceBuffers[ms.type];\n if (sb && !sb.updating && !this._hasPendingRemoveRanges()) {\n this._doAppendSegments();\n }\n }\n\n seek(seconds) {\n // remove all appended buffers\n for (let type in this._sourceBuffers) {\n if (!this._sourceBuffers[type]) {\n continue;\n }\n\n // abort current buffer append algorithm\n let sb = this._sourceBuffers[type];\n if (this._mediaSource.readyState === 'open') {\n try {\n // If range removal algorithm is running, InvalidStateError will be throwed\n // Ignore it.\n sb.abort();\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n }\n\n // IDRList should be clear\n this._idrList.clear();\n\n // pending segments should be discard\n let ps = this._pendingSegments[type];\n ps.splice(0, ps.length);\n\n if (this._mediaSource.readyState === 'closed') {\n // Parent MediaSource object has been detached from HTMLMediaElement\n continue;\n }\n\n // record ranges to be remove from SourceBuffer\n for (let i = 0; i < sb.buffered.length; i++) {\n let start = sb.buffered.start(i);\n let end = sb.buffered.end(i);\n this._pendingRemoveRanges[type].push({start, end});\n }\n\n // if sb is not updating, let's remove ranges now!\n if (!sb.updating) {\n this._doRemoveRanges();\n }\n\n // Safari 10 may get InvalidStateError in the later appendBuffer() after SourceBuffer.remove() call\n // Internal parser's state may be invalid at this time. Re-append last InitSegment to workaround.\n // Related issue: https://bugs.webkit.org/show_bug.cgi?id=159230\n if (Browser.safari) {\n let lastInitSegment = this._lastInitSegments[type];\n if (lastInitSegment) {\n this._pendingSegments[type].push(lastInitSegment);\n if (!sb.updating) {\n this._doAppendSegments();\n }\n }\n }\n }\n }\n\n endOfStream() {\n let ms = this._mediaSource;\n let sb = this._sourceBuffers;\n if (!ms || ms.readyState !== 'open') {\n if (ms && ms.readyState === 'closed' && this._hasPendingSegments()) {\n // If MediaSource hasn't turned into open state, and there're pending segments\n // Mark pending endOfStream, defer call until all pending segments appended complete\n this._hasPendingEos = true;\n }\n return;\n }\n if (sb.video && sb.video.updating || sb.audio && sb.audio.updating) {\n // If any sourcebuffer is updating, defer endOfStream operation\n // See _onSourceBufferUpdateEnd()\n this._hasPendingEos = true;\n } else {\n this._hasPendingEos = false;\n // Notify media data loading complete\n // This is helpful for correcting total duration to match last media segment\n // Otherwise MediaElement's ended event may not be triggered\n ms.endOfStream();\n }\n }\n\n getNearestKeyframe(dts) {\n return this._idrList.getLastSyncPointBeforeDts(dts);\n }\n\n _needCleanupSourceBuffer() {\n if (!this._config.autoCleanupSourceBuffer) {\n return false;\n }\n\n let currentTime = this._mediaElement.currentTime;\n\n for (let type in this._sourceBuffers) {\n let sb = this._sourceBuffers[type];\n if (sb) {\n let buffered = sb.buffered;\n if (buffered.length >= 1) {\n if (currentTime - buffered.start(0) >= this._config.autoCleanupMaxBackwardDuration) {\n return true;\n }\n }\n }\n }\n\n return false;\n }\n\n _doCleanupSourceBuffer() {\n let currentTime = this._mediaElement.currentTime;\n\n for (let type in this._sourceBuffers) {\n let sb = this._sourceBuffers[type];\n if (sb) {\n let buffered = sb.buffered;\n let doRemove = false;\n\n for (let i = 0; i < buffered.length; i++) {\n let start = buffered.start(i);\n let end = buffered.end(i);\n\n if (start <= currentTime && currentTime < end + 3) { // padding 3 seconds\n if (currentTime - start >= this._config.autoCleanupMaxBackwardDuration) {\n doRemove = true;\n let removeEnd = currentTime - this._config.autoCleanupMinBackwardDuration;\n this._pendingRemoveRanges[type].push({start: start, end: removeEnd});\n }\n } else if (end < currentTime) {\n doRemove = true;\n this._pendingRemoveRanges[type].push({start: start, end: end});\n }\n }\n\n if (doRemove && !sb.updating) {\n this._doRemoveRanges();\n }\n }\n }\n }\n\n _updateMediaSourceDuration() {\n let sb = this._sourceBuffers;\n if (this._mediaElement.readyState === 0 || this._mediaSource.readyState !== 'open') {\n return;\n }\n if ((sb.video && sb.video.updating) || (sb.audio && sb.audio.updating)) {\n return;\n }\n\n let current = this._mediaSource.duration;\n let target = this._pendingMediaDuration;\n\n if (target > 0 && (isNaN(current) || target > current)) {\n Log.v(this.TAG, `Update MediaSource duration from ${current} to ${target}`);\n this._mediaSource.duration = target;\n }\n\n this._requireSetMediaDuration = false;\n this._pendingMediaDuration = 0;\n }\n\n _doRemoveRanges() {\n for (let type in this._pendingRemoveRanges) {\n if (!this._sourceBuffers[type] || this._sourceBuffers[type].updating) {\n continue;\n }\n let sb = this._sourceBuffers[type];\n let ranges = this._pendingRemoveRanges[type];\n while (ranges.length && !sb.updating) {\n let range = ranges.shift();\n sb.remove(range.start, range.end);\n }\n }\n }\n\n _doAppendSegments() {\n let pendingSegments = this._pendingSegments;\n\n for (let type in pendingSegments) {\n if (!this._sourceBuffers[type] || this._sourceBuffers[type].updating) {\n continue;\n }\n\n if (pendingSegments[type].length > 0) {\n let segment = pendingSegments[type].shift();\n\n if (segment.timestampOffset) {\n // For MPEG audio stream in MSE, if unbuffered-seeking occurred\n // We need explicitly set timestampOffset to the desired point in timeline for mpeg SourceBuffer.\n let currentOffset = this._sourceBuffers[type].timestampOffset;\n let targetOffset = segment.timestampOffset / 1000; // in seconds\n\n let delta = Math.abs(currentOffset - targetOffset);\n if (delta > 0.1) { // If time delta > 100ms\n Log.v(this.TAG, `Update MPEG audio timestampOffset from ${currentOffset} to ${targetOffset}`);\n this._sourceBuffers[type].timestampOffset = targetOffset;\n }\n delete segment.timestampOffset;\n }\n\n if (!segment.data || segment.data.byteLength === 0) {\n // Ignore empty buffer\n continue;\n }\n\n try {\n this._sourceBuffers[type].appendBuffer(segment.data);\n this._isBufferFull = false;\n if (type === 'video' && segment.hasOwnProperty('info')) {\n this._idrList.appendArray(segment.info.syncPoints);\n }\n } catch (error) {\n this._pendingSegments[type].unshift(segment);\n if (error.code === 22) { // QuotaExceededError\n /* Notice that FireFox may not throw QuotaExceededError if SourceBuffer is full\n * Currently we can only do lazy-load to avoid SourceBuffer become scattered.\n * SourceBuffer eviction policy may be changed in future version of FireFox.\n *\n * Related issues:\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1279885\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1280023\n */\n\n // report buffer full, abort network IO\n if (!this._isBufferFull) {\n this._emitter.emit(MSEEvents.BUFFER_FULL);\n }\n this._isBufferFull = true;\n } else {\n Log.e(this.TAG, error.message);\n this._emitter.emit(MSEEvents.ERROR, {code: error.code, msg: error.message});\n }\n }\n }\n }\n }\n\n _onSourceOpen() {\n Log.v(this.TAG, 'MediaSource onSourceOpen');\n this._mediaSource.removeEventListener('sourceopen', this.e.onSourceOpen);\n // deferred sourcebuffer creation / initialization\n if (this._pendingSourceBufferInit.length > 0) {\n let pendings = this._pendingSourceBufferInit;\n while (pendings.length) {\n let segment = pendings.shift();\n this.appendInitSegment(segment, true);\n }\n }\n // there may be some pending media segments, append them\n if (this._hasPendingSegments()) {\n this._doAppendSegments();\n }\n this._emitter.emit(MSEEvents.SOURCE_OPEN);\n }\n\n _onSourceEnded() {\n // fired on endOfStream\n Log.v(this.TAG, 'MediaSource onSourceEnded');\n }\n\n _onSourceClose() {\n // fired on detaching from media element\n Log.v(this.TAG, 'MediaSource onSourceClose');\n if (this._mediaSource && this.e != null) {\n this._mediaSource.removeEventListener('sourceopen', this.e.onSourceOpen);\n this._mediaSource.removeEventListener('sourceended', this.e.onSourceEnded);\n this._mediaSource.removeEventListener('sourceclose', this.e.onSourceClose);\n }\n }\n\n _hasPendingSegments() {\n let ps = this._pendingSegments;\n return ps.video.length > 0 || ps.audio.length > 0;\n }\n\n _hasPendingRemoveRanges() {\n let prr = this._pendingRemoveRanges;\n return prr.video.length > 0 || prr.audio.length > 0;\n }\n\n _onSourceBufferUpdateEnd() {\n if (this._requireSetMediaDuration) {\n this._updateMediaSourceDuration();\n } else if (this._hasPendingRemoveRanges()) {\n this._doRemoveRanges();\n } else if (this._hasPendingSegments()) {\n this._doAppendSegments();\n } else if (this._hasPendingEos) {\n this.endOfStream();\n }\n this._emitter.emit(MSEEvents.UPDATE_END);\n }\n\n _onSourceBufferError(e) {\n Log.e(this.TAG, `SourceBuffer Error: ${e}`);\n // this error might not always be fatal, just ignore it\n }\n\n}\n\nexport default MSEController;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {LoaderErrors} from '../io/loader.js';\nimport DemuxErrors from '../demux/demux-errors.js';\n\nexport const ErrorTypes = {\n NETWORK_ERROR: 'NetworkError',\n MEDIA_ERROR: 'MediaError',\n OTHER_ERROR: 'OtherError'\n};\n\nexport const ErrorDetails = {\n NETWORK_EXCEPTION: LoaderErrors.EXCEPTION,\n NETWORK_STATUS_CODE_INVALID: LoaderErrors.HTTP_STATUS_CODE_INVALID,\n NETWORK_TIMEOUT: LoaderErrors.CONNECTING_TIMEOUT,\n NETWORK_UNRECOVERABLE_EARLY_EOF: LoaderErrors.UNRECOVERABLE_EARLY_EOF,\n\n MEDIA_MSE_ERROR: 'MediaMSEError',\n\n MEDIA_FORMAT_ERROR: DemuxErrors.FORMAT_ERROR,\n MEDIA_FORMAT_UNSUPPORTED: DemuxErrors.FORMAT_UNSUPPORTED,\n MEDIA_CODEC_UNSUPPORTED: DemuxErrors.CODEC_UNSUPPORTED\n};","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport PlayerEvents from './player-events.js';\nimport Transmuxer from '../core/transmuxer.js';\nimport TransmuxingEvents from '../core/transmuxing-events.js';\nimport MSEController from '../core/mse-controller.js';\nimport MSEEvents from '../core/mse-events.js';\nimport {ErrorTypes, ErrorDetails} from './player-errors.js';\nimport {createDefaultConfig} from '../config.js';\nimport {InvalidArgumentException, IllegalStateException} from '../utils/exception.js';\n\nclass MSEPlayer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'MSEPlayer';\n this._type = 'MSEPlayer';\n this._emitter = new EventEmitter();\n\n this._config = createDefaultConfig();\n if (typeof config === 'object') {\n Object.assign(this._config, config);\n }\n\n let typeLowerCase = mediaDataSource.type.toLowerCase();\n if (typeLowerCase !== 'mse'\n && typeLowerCase !== 'mpegts'\n && typeLowerCase !== 'm2ts'\n && typeLowerCase !== 'flv') {\n throw new InvalidArgumentException('MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!');\n }\n\n if (mediaDataSource.isLive === true) {\n this._config.isLive = true;\n }\n\n this.e = {\n onvLoadedMetadata: this._onvLoadedMetadata.bind(this),\n onvSeeking: this._onvSeeking.bind(this),\n onvCanPlay: this._onvCanPlay.bind(this),\n onvStalled: this._onvStalled.bind(this),\n onvProgress: this._onvProgress.bind(this)\n };\n\n if (self.performance && self.performance.now) {\n this._now = self.performance.now.bind(self.performance);\n } else {\n this._now = Date.now;\n }\n\n this._pendingSeekTime = null; // in seconds\n this._requestSetTime = false;\n this._seekpointRecord = null;\n this._progressChecker = null;\n\n this._mediaDataSource = mediaDataSource;\n this._mediaElement = null;\n this._msectl = null;\n this._transmuxer = null;\n\n this._mseSourceOpened = false;\n this._hasPendingLoad = false;\n this._receivedCanPlay = false;\n\n this._mediaInfo = null;\n this._statisticsInfo = null;\n\n let chromeNeedIDRFix = (Browser.chrome &&\n (Browser.version.major < 50 ||\n (Browser.version.major === 50 && Browser.version.build < 2661)));\n this._alwaysSeekKeyframe = (chromeNeedIDRFix || Browser.msedge || Browser.msie) ? true : false;\n\n if (this._alwaysSeekKeyframe) {\n this._config.accurateSeek = false;\n }\n }\n\n destroy() {\n if (this._progressChecker != null) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n }\n if (this._transmuxer) {\n this.unload();\n }\n if (this._mediaElement) {\n this.detachMediaElement();\n }\n this.e = null;\n this._mediaDataSource = null;\n\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n if (event === PlayerEvents.MEDIA_INFO) {\n if (this._mediaInfo != null) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n });\n }\n } else if (event === PlayerEvents.STATISTICS_INFO) {\n if (this._statisticsInfo != null) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n });\n }\n }\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n this._mediaElement = mediaElement;\n mediaElement.addEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n mediaElement.addEventListener('seeking', this.e.onvSeeking);\n mediaElement.addEventListener('canplay', this.e.onvCanPlay);\n mediaElement.addEventListener('stalled', this.e.onvStalled);\n mediaElement.addEventListener('progress', this.e.onvProgress);\n\n this._msectl = new MSEController(this._config);\n\n this._msectl.on(MSEEvents.UPDATE_END, this._onmseUpdateEnd.bind(this));\n this._msectl.on(MSEEvents.BUFFER_FULL, this._onmseBufferFull.bind(this));\n this._msectl.on(MSEEvents.SOURCE_OPEN, () => {\n this._mseSourceOpened = true;\n if (this._hasPendingLoad) {\n this._hasPendingLoad = false;\n this.load();\n }\n });\n this._msectl.on(MSEEvents.ERROR, (info) => {\n this._emitter.emit(PlayerEvents.ERROR,\n ErrorTypes.MEDIA_ERROR,\n ErrorDetails.MEDIA_MSE_ERROR,\n info\n );\n });\n\n this._msectl.attachMediaElement(mediaElement);\n\n if (this._pendingSeekTime != null) {\n try {\n mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n } catch (e) {\n // IE11 may throw InvalidStateError if readyState === 0\n // We can defer set currentTime operation after loadedmetadata\n }\n }\n }\n\n detachMediaElement() {\n if (this._mediaElement) {\n this._msectl.detachMediaElement();\n this._mediaElement.removeEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n this._mediaElement.removeEventListener('seeking', this.e.onvSeeking);\n this._mediaElement.removeEventListener('canplay', this.e.onvCanPlay);\n this._mediaElement.removeEventListener('stalled', this.e.onvStalled);\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n this._mediaElement = null;\n }\n if (this._msectl) {\n this._msectl.destroy();\n this._msectl = null;\n }\n }\n\n load() {\n if (!this._mediaElement) {\n throw new IllegalStateException('HTMLMediaElement must be attached before load()!');\n }\n if (this._transmuxer) {\n throw new IllegalStateException('MSEPlayer.load() has been called, please call unload() first!');\n }\n if (this._hasPendingLoad) {\n return;\n }\n\n if (this._config.deferLoadAfterSourceOpen && this._mseSourceOpened === false) {\n this._hasPendingLoad = true;\n return;\n }\n\n if (this._mediaElement.readyState > 0) {\n this._requestSetTime = true;\n // IE11 may throw InvalidStateError if readyState === 0\n this._mediaElement.currentTime = 0;\n }\n\n this._transmuxer = new Transmuxer(this._mediaDataSource, this._config);\n\n this._transmuxer.on(TransmuxingEvents.INIT_SEGMENT, (type, is) => {\n this._msectl.appendInitSegment(is);\n });\n this._transmuxer.on(TransmuxingEvents.MEDIA_SEGMENT, (type, ms) => {\n this._msectl.appendMediaSegment(ms);\n\n // lazyLoad check\n if (this._config.lazyLoad && !this._config.isLive) {\n let currentTime = this._mediaElement.currentTime;\n if (ms.info.endDts >= (currentTime + this._config.lazyLoadMaxDuration) * 1000) {\n if (this._progressChecker == null) {\n Log.v(this.TAG, 'Maximum buffering duration exceeded, suspend transmuxing task');\n this._suspendTransmuxer();\n }\n }\n }\n });\n this._transmuxer.on(TransmuxingEvents.LOADING_COMPLETE, () => {\n this._msectl.endOfStream();\n this._emitter.emit(PlayerEvents.LOADING_COMPLETE);\n });\n this._transmuxer.on(TransmuxingEvents.RECOVERED_EARLY_EOF, () => {\n this._emitter.emit(PlayerEvents.RECOVERED_EARLY_EOF);\n });\n this._transmuxer.on(TransmuxingEvents.IO_ERROR, (detail, info) => {\n this._emitter.emit(PlayerEvents.ERROR, ErrorTypes.NETWORK_ERROR, detail, info);\n });\n this._transmuxer.on(TransmuxingEvents.DEMUX_ERROR, (detail, info) => {\n this._emitter.emit(PlayerEvents.ERROR, ErrorTypes.MEDIA_ERROR, detail, {code: -1, msg: info});\n });\n this._transmuxer.on(TransmuxingEvents.MEDIA_INFO, (mediaInfo) => {\n this._mediaInfo = mediaInfo;\n this._emitter.emit(PlayerEvents.MEDIA_INFO, Object.assign({}, mediaInfo));\n });\n this._transmuxer.on(TransmuxingEvents.METADATA_ARRIVED, (metadata) => {\n this._emitter.emit(PlayerEvents.METADATA_ARRIVED, metadata);\n });\n this._transmuxer.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, (data) => {\n this._emitter.emit(PlayerEvents.SCRIPTDATA_ARRIVED, data);\n });\n this._transmuxer.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, (timed_id3_metadata) => {\n this._emitter.emit(PlayerEvents.TIMED_ID3_METADATA_ARRIVED, timed_id3_metadata);\n });\n this._transmuxer.on(TransmuxingEvents.SCTE35_METADATA_ARRIVED, (scte35_metadata) => {\n this._emitter.emit(PlayerEvents.SCTE35_METADATA_ARRIVED, scte35_metadata);\n });\n this._transmuxer.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, (descriptor) => {\n this._emitter.emit(PlayerEvents.PES_PRIVATE_DATA_DESCRIPTOR, descriptor);\n });\n this._transmuxer.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, (private_data) => {\n this._emitter.emit(PlayerEvents.PES_PRIVATE_DATA_ARRIVED, private_data);\n });\n this._transmuxer.on(TransmuxingEvents.STATISTICS_INFO, (statInfo) => {\n this._statisticsInfo = this._fillStatisticsInfo(statInfo);\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, Object.assign({}, this._statisticsInfo));\n });\n this._transmuxer.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, (milliseconds) => {\n if (this._mediaElement && !this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = milliseconds / 1000;\n }\n });\n\n this._transmuxer.open();\n }\n\n unload() {\n if (this._mediaElement) {\n this._mediaElement.pause();\n }\n if (this._msectl) {\n this._msectl.seek(0);\n }\n if (this._transmuxer) {\n this._transmuxer.close();\n this._transmuxer.destroy();\n this._transmuxer = null;\n }\n }\n\n play() {\n return this._mediaElement.play();\n }\n\n pause() {\n this._mediaElement.pause();\n }\n\n get type() {\n return this._type;\n }\n\n get buffered() {\n return this._mediaElement.buffered;\n }\n\n get duration() {\n return this._mediaElement.duration;\n }\n\n get volume() {\n return this._mediaElement.volume;\n }\n\n set volume(value) {\n this._mediaElement.volume = value;\n }\n\n get muted() {\n return this._mediaElement.muted;\n }\n\n set muted(muted) {\n this._mediaElement.muted = muted;\n }\n\n get currentTime() {\n if (this._mediaElement) {\n return this._mediaElement.currentTime;\n }\n return 0;\n }\n\n set currentTime(seconds) {\n if (this._mediaElement) {\n this._internalSeek(seconds);\n } else {\n this._pendingSeekTime = seconds;\n }\n }\n\n get mediaInfo() {\n return Object.assign({}, this._mediaInfo);\n }\n\n get statisticsInfo() {\n if (this._statisticsInfo == null) {\n this._statisticsInfo = {};\n }\n this._statisticsInfo = this._fillStatisticsInfo(this._statisticsInfo);\n return Object.assign({}, this._statisticsInfo);\n }\n\n _fillStatisticsInfo(statInfo) {\n statInfo.playerType = this._type;\n\n if (!(this._mediaElement instanceof HTMLVideoElement)) {\n return statInfo;\n }\n\n let hasQualityInfo = true;\n let decoded = 0;\n let dropped = 0;\n\n if (this._mediaElement.getVideoPlaybackQuality) {\n let quality = this._mediaElement.getVideoPlaybackQuality();\n decoded = quality.totalVideoFrames;\n dropped = quality.droppedVideoFrames;\n } else if (this._mediaElement.webkitDecodedFrameCount != undefined) {\n decoded = this._mediaElement.webkitDecodedFrameCount;\n dropped = this._mediaElement.webkitDroppedFrameCount;\n } else {\n hasQualityInfo = false;\n }\n\n if (hasQualityInfo) {\n statInfo.decodedFrames = decoded;\n statInfo.droppedFrames = dropped;\n }\n\n return statInfo;\n }\n\n _onmseUpdateEnd() {\n let buffered = this._mediaElement.buffered;\n let currentTime = this._mediaElement.currentTime;\n\n if (this._config.isLive\n && this._config.liveBufferLatencyChasing\n && buffered.length > 0\n && !this._mediaElement.paused) {\n let buffered_end = buffered.end(buffered.length - 1);\n if (buffered_end > this._config.liveBufferLatencyMaxLatency) {\n // Ensure there's enough buffered data\n if (buffered_end - currentTime > this._config.liveBufferLatencyMaxLatency) {\n // if remained data duration has larger than config.liveBufferLatencyMaxLatency\n let target_time = buffered_end - this._config.liveBufferLatencyMinRemain;\n this.currentTime = target_time;\n }\n }\n }\n\n if (!this._config.lazyLoad || this._config.isLive) {\n return;\n }\n\n let currentRangeStart = 0;\n let currentRangeEnd = 0;\n\n for (let i = 0; i < buffered.length; i++) {\n let start = buffered.start(i);\n let end = buffered.end(i);\n if (start <= currentTime && currentTime < end) {\n currentRangeStart = start;\n currentRangeEnd = end;\n break;\n }\n }\n\n if (currentRangeEnd >= currentTime + this._config.lazyLoadMaxDuration && this._progressChecker == null) {\n Log.v(this.TAG, 'Maximum buffering duration exceeded, suspend transmuxing task');\n this._suspendTransmuxer();\n }\n }\n\n _onmseBufferFull() {\n Log.v(this.TAG, 'MSE SourceBuffer is full, suspend transmuxing task');\n if (this._progressChecker == null) {\n this._suspendTransmuxer();\n }\n }\n\n _suspendTransmuxer() {\n if (this._transmuxer) {\n this._transmuxer.pause();\n\n if (this._progressChecker == null) {\n this._progressChecker = window.setInterval(this._checkProgressAndResume.bind(this), 1000);\n }\n }\n }\n\n _checkProgressAndResume() {\n let currentTime = this._mediaElement.currentTime;\n let buffered = this._mediaElement.buffered;\n\n let needResume = false;\n\n for (let i = 0; i < buffered.length; i++) {\n let from = buffered.start(i);\n let to = buffered.end(i);\n if (currentTime >= from && currentTime < to) {\n if (currentTime >= to - this._config.lazyLoadRecoverDuration) {\n needResume = true;\n }\n break;\n }\n }\n\n if (needResume) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n if (needResume) {\n Log.v(this.TAG, 'Continue loading from paused position');\n this._transmuxer.resume();\n }\n }\n }\n\n _isTimepointBuffered(seconds) {\n let buffered = this._mediaElement.buffered;\n\n for (let i = 0; i < buffered.length; i++) {\n let from = buffered.start(i);\n let to = buffered.end(i);\n if (seconds >= from && seconds < to) {\n return true;\n }\n }\n return false;\n }\n\n _internalSeek(seconds) {\n let directSeek = this._isTimepointBuffered(seconds);\n\n let directSeekBegin = false;\n let directSeekBeginTime = 0;\n\n if (seconds < 1.0 && this._mediaElement.buffered.length > 0) {\n let videoBeginTime = this._mediaElement.buffered.start(0);\n if ((videoBeginTime < 1.0 && seconds < videoBeginTime) || Browser.safari) {\n directSeekBegin = true;\n // also workaround for Safari: Seek to 0 may cause video stuck, use 0.1 to avoid\n directSeekBeginTime = Browser.safari ? 0.1 : videoBeginTime;\n }\n }\n\n if (directSeekBegin) { // seek to video begin, set currentTime directly if beginPTS buffered\n this._requestSetTime = true;\n this._mediaElement.currentTime = directSeekBeginTime;\n } else if (directSeek) { // buffered position\n if (!this._alwaysSeekKeyframe) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = seconds;\n } else {\n let idr = this._msectl.getNearestKeyframe(Math.floor(seconds * 1000));\n this._requestSetTime = true;\n if (idr != null) {\n this._mediaElement.currentTime = idr.dts / 1000;\n } else {\n this._mediaElement.currentTime = seconds;\n }\n }\n if (this._progressChecker != null) {\n this._checkProgressAndResume();\n }\n } else {\n if (this._progressChecker != null) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n }\n this._msectl.seek(seconds);\n this._transmuxer.seek(Math.floor(seconds * 1000)); // in milliseconds\n // no need to set mediaElement.currentTime if non-accurateSeek,\n // just wait for the recommend_seekpoint callback\n if (this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = seconds;\n }\n }\n }\n\n _checkAndApplyUnbufferedSeekpoint() {\n if (this._seekpointRecord) {\n if (this._seekpointRecord.recordTime <= this._now() - 100) {\n let target = this._mediaElement.currentTime;\n this._seekpointRecord = null;\n if (!this._isTimepointBuffered(target)) {\n if (this._progressChecker != null) {\n window.clearTimeout(this._progressChecker);\n this._progressChecker = null;\n }\n // .currentTime is consists with .buffered timestamp\n // Chrome/Edge use DTS, while FireFox/Safari use PTS\n this._msectl.seek(target);\n this._transmuxer.seek(Math.floor(target * 1000));\n // set currentTime if accurateSeek, or wait for recommend_seekpoint callback\n if (this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = target;\n }\n }\n } else {\n window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50);\n }\n }\n }\n\n _checkAndResumeStuckPlayback(stalled) {\n let media = this._mediaElement;\n if (stalled || !this._receivedCanPlay || media.readyState < 2) { // HAVE_CURRENT_DATA\n let buffered = media.buffered;\n if (buffered.length > 0 && media.currentTime < buffered.start(0)) {\n Log.w(this.TAG, `Playback seems stuck at ${media.currentTime}, seek to ${buffered.start(0)}`);\n this._requestSetTime = true;\n this._mediaElement.currentTime = buffered.start(0);\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n }\n } else {\n // Playback didn't stuck, remove progress event listener\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n }\n }\n\n _onvLoadedMetadata(e) {\n if (this._pendingSeekTime != null) {\n this._mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n }\n }\n\n _onvSeeking(e) { // handle seeking request from browser's progress bar\n let target = this._mediaElement.currentTime;\n let buffered = this._mediaElement.buffered;\n\n if (this._requestSetTime) {\n this._requestSetTime = false;\n return;\n }\n\n if (target < 1.0 && buffered.length > 0) {\n // seek to video begin, set currentTime directly if beginPTS buffered\n let videoBeginTime = buffered.start(0);\n if ((videoBeginTime < 1.0 && target < videoBeginTime) || Browser.safari) {\n this._requestSetTime = true;\n // also workaround for Safari: Seek to 0 may cause video stuck, use 0.1 to avoid\n this._mediaElement.currentTime = Browser.safari ? 0.1 : videoBeginTime;\n return;\n }\n }\n\n if (this._isTimepointBuffered(target)) {\n if (this._alwaysSeekKeyframe) {\n let idr = this._msectl.getNearestKeyframe(Math.floor(target * 1000));\n if (idr != null) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = idr.dts / 1000;\n }\n }\n if (this._progressChecker != null) {\n this._checkProgressAndResume();\n }\n return;\n }\n\n this._seekpointRecord = {\n seekPoint: target,\n recordTime: this._now()\n };\n window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50);\n }\n\n _onvCanPlay(e) {\n this._receivedCanPlay = true;\n this._mediaElement.removeEventListener('canplay', this.e.onvCanPlay);\n }\n\n _onvStalled(e) {\n this._checkAndResumeStuckPlayback(true);\n }\n\n _onvProgress(e) {\n this._checkAndResumeStuckPlayback();\n }\n\n}\n\nexport default MSEPlayer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport PlayerEvents from './player-events.js';\nimport {createDefaultConfig} from '../config.js';\nimport {InvalidArgumentException, IllegalStateException} from '../utils/exception.js';\n\n// Player wrapper for browser's native player (HTMLVideoElement) without MediaSource src. \nclass NativePlayer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'NativePlayer';\n this._type = 'NativePlayer';\n this._emitter = new EventEmitter();\n\n this._config = createDefaultConfig();\n if (typeof config === 'object') {\n Object.assign(this._config, config);\n }\n\n let typeLowerCase = mediaDataSource.type.toLowerCase();\n\n if (typeLowerCase === 'mse'\n || typeLowerCase === 'mpegts'\n || typeLowerCase === 'm2ts'\n || typeLowerCase === 'flv') {\n throw new InvalidArgumentException('NativePlayer does\\'t support mse/mpegts/m2ts/flv MediaDataSource input!');\n }\n if (mediaDataSource.hasOwnProperty('segments')) {\n throw new InvalidArgumentException(`NativePlayer(${mediaDataSource.type}) doesn't support multipart playback!`);\n }\n\n this.e = {\n onvLoadedMetadata: this._onvLoadedMetadata.bind(this)\n };\n\n this._pendingSeekTime = null;\n this._statisticsReporter = null;\n\n this._mediaDataSource = mediaDataSource;\n this._mediaElement = null;\n }\n\n destroy() {\n if (this._mediaElement) {\n this.unload();\n this.detachMediaElement();\n }\n this.e = null;\n this._mediaDataSource = null;\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n if (event === PlayerEvents.MEDIA_INFO) {\n if (this._mediaElement != null && this._mediaElement.readyState !== 0) { // HAVE_NOTHING\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n });\n }\n } else if (event === PlayerEvents.STATISTICS_INFO) {\n if (this._mediaElement != null && this._mediaElement.readyState !== 0) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n });\n }\n }\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n this._mediaElement = mediaElement;\n mediaElement.addEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n\n if (this._pendingSeekTime != null) {\n try {\n mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n } catch (e) {\n // IE11 may throw InvalidStateError if readyState === 0\n // Defer set currentTime operation after loadedmetadata\n }\n }\n }\n\n detachMediaElement() {\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n this._mediaElement.removeEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n this._mediaElement = null;\n }\n if (this._statisticsReporter != null) {\n window.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n load() {\n if (!this._mediaElement) {\n throw new IllegalStateException('HTMLMediaElement must be attached before load()!');\n }\n this._mediaElement.src = this._mediaDataSource.url;\n\n if (this._mediaElement.readyState > 0) {\n this._mediaElement.currentTime = 0;\n }\n\n this._mediaElement.preload = 'auto';\n this._mediaElement.load();\n this._statisticsReporter = window.setInterval(\n this._reportStatisticsInfo.bind(this),\n this._config.statisticsInfoReportInterval);\n }\n\n unload() {\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n }\n if (this._statisticsReporter != null) {\n window.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n play() {\n return this._mediaElement.play();\n }\n\n pause() {\n this._mediaElement.pause();\n }\n\n get type() {\n return this._type;\n }\n\n get buffered() {\n return this._mediaElement.buffered;\n }\n\n get duration() {\n return this._mediaElement.duration;\n }\n\n get volume() {\n return this._mediaElement.volume;\n }\n\n set volume(value) {\n this._mediaElement.volume = value;\n }\n\n get muted() {\n return this._mediaElement.muted;\n }\n\n set muted(muted) {\n this._mediaElement.muted = muted;\n }\n\n get currentTime() {\n if (this._mediaElement) {\n return this._mediaElement.currentTime;\n }\n return 0;\n }\n\n set currentTime(seconds) {\n if (this._mediaElement) {\n this._mediaElement.currentTime = seconds;\n } else {\n this._pendingSeekTime = seconds;\n }\n }\n\n get mediaInfo() {\n let mediaPrefix = (this._mediaElement instanceof HTMLAudioElement) ? 'audio/' : 'video/';\n let info = {\n mimeType: mediaPrefix + this._mediaDataSource.type\n };\n if (this._mediaElement) {\n info.duration = Math.floor(this._mediaElement.duration * 1000);\n if (this._mediaElement instanceof HTMLVideoElement) {\n info.width = this._mediaElement.videoWidth;\n info.height = this._mediaElement.videoHeight;\n }\n }\n return info;\n }\n\n get statisticsInfo() {\n let info = {\n playerType: this._type,\n url: this._mediaDataSource.url\n };\n\n if (!(this._mediaElement instanceof HTMLVideoElement)) {\n return info;\n }\n\n let hasQualityInfo = true;\n let decoded = 0;\n let dropped = 0;\n\n if (this._mediaElement.getVideoPlaybackQuality) {\n let quality = this._mediaElement.getVideoPlaybackQuality();\n decoded = quality.totalVideoFrames;\n dropped = quality.droppedVideoFrames;\n } else if (this._mediaElement.webkitDecodedFrameCount != undefined) {\n decoded = this._mediaElement.webkitDecodedFrameCount;\n dropped = this._mediaElement.webkitDroppedFrameCount;\n } else {\n hasQualityInfo = false;\n }\n\n if (hasQualityInfo) {\n info.decodedFrames = decoded;\n info.droppedFrames = dropped;\n }\n \n return info;\n }\n\n _onvLoadedMetadata(e) {\n if (this._pendingSeekTime != null) {\n this._mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n }\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n }\n\n _reportStatisticsInfo() {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n }\n\n}\n\nexport default NativePlayer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Polyfill from './utils/polyfill.js';\nimport Features from './core/features.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './io/loader.js';\nimport MSEPlayer from './player/mse-player.js';\nimport NativePlayer from './player/native-player.js';\nimport PlayerEvents from './player/player-events.js';\nimport {ErrorTypes, ErrorDetails} from './player/player-errors.js';\nimport LoggingControl from './utils/logging-control.js';\nimport {InvalidArgumentException} from './utils/exception.js';\n\n// here are all the interfaces\n\n// install polyfills\nPolyfill.install();\n\n\n// factory method\nfunction createPlayer(mediaDataSource, optionalConfig) {\n let mds = mediaDataSource;\n if (mds == null || typeof mds !== 'object') {\n throw new InvalidArgumentException('MediaDataSource must be an javascript object!');\n }\n\n if (!mds.hasOwnProperty('type')) {\n throw new InvalidArgumentException('MediaDataSource must has type field to indicate video file type!');\n }\n\n switch (mds.type) {\n case 'mse':\n case 'mpegts':\n case 'm2ts':\n case 'flv':\n return new MSEPlayer(mds, optionalConfig);\n default:\n return new NativePlayer(mds, optionalConfig);\n }\n}\n\n\n// feature detection\nfunction isSupported() {\n return Features.supportMSEH264Playback();\n}\n\nfunction getFeatureList() {\n return Features.getFeatureList();\n}\n\n\n// interfaces\nlet mpegts = {};\n\nmpegts.createPlayer = createPlayer;\nmpegts.isSupported = isSupported;\nmpegts.getFeatureList = getFeatureList;\n\nmpegts.BaseLoader = BaseLoader;\nmpegts.LoaderStatus = LoaderStatus;\nmpegts.LoaderErrors = LoaderErrors;\n\nmpegts.Events = PlayerEvents;\nmpegts.ErrorTypes = ErrorTypes;\nmpegts.ErrorDetails = ErrorDetails;\n\nmpegts.MSEPlayer = MSEPlayer;\nmpegts.NativePlayer = NativePlayer;\nmpegts.LoggingControl = LoggingControl;\n\nObject.defineProperty(mpegts, 'version', {\n enumerable: true,\n get: function () {\n // replaced by webpack.DefinePlugin\n return __VERSION__;\n }\n});\n\nexport default mpegts;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/trunk/research/players/srs_player.html b/trunk/research/players/srs_player.html index 959475b6cd..599fecd04a 100755 --- a/trunk/research/players/srs_player.html +++ b/trunk/research/players/srs_player.html @@ -99,7 +99,7 @@ - + diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index b3c8fafb10..3bb9d3d2fe 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 0 +#define VERSION_REVISION 1 #endif