videojs-contrib-hls.min.js
131.4 KB
/**
* videojs-contrib-hls
* @version 2.0.1
* @copyright 2016 Brightcove, Inc
* @license Apache-2.0
*/
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.videojsContribHls=t()}}(function(){return function t(e,i,n){function r(s,o){if(!i[s]){if(!e[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(a)return a(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var f=i[s]={exports:{}};e[s][0].call(f.exports,function(t){var i=e[s][1][t];return r(i?i:t)},f,f.exports,t,e,i,n)}return i[s].exports}for(var a="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(t,e){return t.start(e)+"-"+t.end(e)},r=function(t,e){var i=t.toString(16);return"00".substring(0,2-i.length)+i+(e%2?" ":"")},a=function(t){return t>=32&&126>t?String.fromCharCode(t):"."},s={hexDump:function(t){for(var e=Array.prototype.slice.call(t),i=16,n="",s=void 0,o=void 0,u=0;u<e.length/i;u++)s=e.slice(u*i,u*i+i).map(r).join(""),o=e.slice(u*i,u*i+i).map(a).join(""),n+=s+" "+o+"\n";return n},tagDump:function(t){return s.hexDump(t.bytes)},textRanges:function(t){var e="",i=void 0;for(i=0;i<t.length;i++)e+=n(t,i)+" ";return e}};i["default"]=s,e.exports=i["default"]},{}],2:[function(t,e,i){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=function(){var t=[[[],[],[],[],[]],[[],[],[],[],[]]],e=t[0],i=t[1],n=e[4],r=i[4],a=void 0,s=void 0,o=void 0,u=[],d=[],f=void 0,l=void 0,c=void 0,h=void 0,p=void 0,g=void 0;for(a=0;256>a;a++)d[(u[a]=a<<1^283*(a>>7))^a]=a;for(s=o=0;!n[s];s^=f||1,o=d[o]||1)for(h=o^o<<1^o<<2^o<<3^o<<4,h=h>>8^255&h^99,n[s]=h,r[h]=s,c=u[l=u[f=u[s]]],g=16843009*c^65537*l^257*f^16843008*s,p=257*u[h]^16843008*h,a=0;4>a;a++)e[a][s]=p=p<<24^p>>>8,i[a][h]=g=g<<24^g>>>8;for(a=0;5>a;a++)e[a]=e[a].slice(0),i[a]=i[a].slice(0);return t},s=null,o=function(){function t(e){n(this,t),s||(s=a()),this._tables=[[s[0][0].slice(),s[0][1].slice(),s[0][2].slice(),s[0][3].slice(),s[0][4].slice()],[s[1][0].slice(),s[1][1].slice(),s[1][2].slice(),s[1][3].slice(),s[1][4].slice()]];var i=void 0,r=void 0,o=void 0,u=void 0,d=void 0,f=this._tables[0][4],l=this._tables[1],c=e.length,h=1;if(4!==c&&6!==c&&8!==c)throw new Error("Invalid aes key size");for(u=e.slice(0),d=[],this._key=[u,d],i=c;4*c+28>i;i++)o=u[i-1],(i%c===0||8===c&&i%c===4)&&(o=f[o>>>24]<<24^f[o>>16&255]<<16^f[o>>8&255]<<8^f[255&o],i%c===0&&(o=o<<8^o>>>24^h<<24,h=h<<1^283*(h>>7))),u[i]=u[i-c]^o;for(r=0;i;r++,i--)o=u[3&r?i:i-4],4>=i||4>r?d[r]=o:d[r]=l[0][f[o>>>24]]^l[1][f[o>>16&255]]^l[2][f[o>>8&255]]^l[3][f[255&o]]}return r(t,[{key:"decrypt",value:function(t,e,i,n,r,a){var s=this._key[1],o=t^s[0],u=n^s[1],d=i^s[2],f=e^s[3],l=void 0,c=void 0,h=void 0,p=s.length/4-2,g=void 0,y=4,m=this._tables[1],b=m[0],v=m[1],_=m[2],w=m[3],T=m[4];for(g=0;p>g;g++)l=b[o>>>24]^v[u>>16&255]^_[d>>8&255]^w[255&f]^s[y],c=b[u>>>24]^v[d>>16&255]^_[f>>8&255]^w[255&o]^s[y+1],h=b[d>>>24]^v[f>>16&255]^_[o>>8&255]^w[255&u]^s[y+2],f=b[f>>>24]^v[o>>16&255]^_[u>>8&255]^w[255&d]^s[y+3],y+=4,o=l,u=c,d=h;for(g=0;4>g;g++)r[(3&-g)+a]=T[o>>>24]<<24^T[u>>16&255]<<16^T[d>>8&255]<<8^T[255&f]^s[y++],l=o,o=u,u=d,d=f,f=l}}]),t}();i["default"]=o,e.exports=i["default"]},{}],3:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},u=t("../stream"),d=n(u),f=function(t){function e(){r(this,e),o(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,d["default"]),this.jobs=[],this.delay=1,this.timeout_=null}return a(e,t),s(e,[{key:"processJob_",value:function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}},{key:"push",value:function(t){this.jobs.push(t),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}]),e}(d["default"]);i["default"]=f,e.exports=i["default"]},{"../stream":13}],4:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=t("./aes"),o=n(s),u=t("./async-stream"),d=n(u),f=t("pkcs7"),l=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},c=function(t,e,i){var n=new Int32Array(t.buffer,t.byteOffset,t.byteLength>>2),r=new o["default"](Array.prototype.slice.call(e)),a=new Uint8Array(t.byteLength),s=new Int32Array(a.buffer),u=void 0,d=void 0,f=void 0,c=void 0,h=void 0,p=void 0,g=void 0,y=void 0,m=void 0;for(u=i[0],d=i[1],f=i[2],c=i[3],m=0;m<n.length;m+=4)h=l(n[m]),p=l(n[m+1]),g=l(n[m+2]),y=l(n[m+3]),r.decrypt(h,p,g,y,s,m),s[m]=l(s[m]^u),s[m+1]=l(s[m+1]^d),s[m+2]=l(s[m+2]^f),s[m+3]=l(s[m+3]^c),u=h,d=p,f=g,c=y;return a};i.decrypt=c;var h=function(){function t(e,i,n,a){r(this,t);var s=t.STEP,o=new Int32Array(e.buffer),u=new Uint8Array(e.byteLength),c=0;for(this.asyncStream_=new d["default"],this.asyncStream_.push(this.decryptChunk_(o.subarray(c,c+s),i,n,u)),c=s;c<o.length;c+=s)n=new Uint32Array([l(o[c-4]),l(o[c-3]),l(o[c-2]),l(o[c-1])]),this.asyncStream_.push(this.decryptChunk_(o.subarray(c,c+s),i,n,u));this.asyncStream_.push(function(){a(null,(0,f.unpad)(u))})}return a(t,[{key:"decryptChunk_",value:function(t,e,i,n){return function(){var r=c(t,e,i);n.set(r,t.byteOffset)}}}]),t}();i.Decrypter=h,h.STEP=32e3,i["default"]={Decrypter:h,decrypt:c}},{"./aes":2,"./async-stream":3,pkcs7:18}],5:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(i,"__esModule",{value:!0});var r=t("./decrypter"),a=t("./async-stream"),s=n(a);i["default"]={decrypt:r.decrypt,Decrypter:r.Decrypter,AsyncStream:s["default"]},e.exports=i["default"]},{"./async-stream":3,"./decrypter":4}],6:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(i,"__esModule",{value:!0});var r=t("./line-stream"),a=n(r),s=t("./parse-stream"),o=n(s),u=t("./parser"),d=n(u);i["default"]={LineStream:a["default"],ParseStream:o["default"],Parser:d["default"]},e.exports=i["default"]},{"./line-stream":7,"./parse-stream":8,"./parser":9}],7:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},u=t("../stream"),d=n(u),f=function(t){function e(){r(this,e),o(Object.getPrototypeOf(e.prototype),"constructor",this).call(this),this.buffer=""}return a(e,t),s(e,[{key:"push",value:function(t){var e=void 0;for(this.buffer+=t,e=this.buffer.indexOf("\n");e>-1;e=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)}}]),e}(d["default"]);i["default"]=f,e.exports=i["default"]},{"../stream":13}],8:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},u=t("../stream"),d=n(u),f=function(){var t="[^=]*",e='"[^"]*"|[^,]*',i="(?:"+t+")=(?:"+e+")";return new RegExp("(?:^|,)("+i+")")},l=function(t){for(var e=t.split(f()),i=e.length,n={},r=void 0;i--;)""!==e[i]&&(r=/([^=]*)=(.*)/.exec(e[i]).slice(1),r[0]=r[0].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^['"](.*)['"]$/g,"$1"),n[r[0]]=r[1]);return n},c=function(t){function e(){r(this,e),o(Object.getPrototypeOf(e.prototype),"constructor",this).call(this)}return a(e,t),s(e,[{key:"push",value:function(t){var e=void 0,i=void 0;if(t=t.replace(/^[\u0000\s]+|[\u0000\s]+$/g,""),0!==t.length){if("#"!==t[0])return void this.trigger("data",{type:"uri",uri:t});if(0!==t.indexOf("#EXT"))return void this.trigger("data",{type:"comment",text:t.slice(1)});if(t=t.replace("\r",""),e=/^#EXTM3U/.exec(t))return void this.trigger("data",{type:"tag",tagType:"m3u"});if(e=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(t))return i={type:"tag",tagType:"inf"},e[1]&&(i.duration=parseFloat(e[1])),e[2]&&(i.title=e[2]),void this.trigger("data",i);if(e=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(t))return i={type:"tag",tagType:"targetduration"},e[1]&&(i.duration=parseInt(e[1],10)),void this.trigger("data",i);if(e=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(t))return i={type:"tag",tagType:"totalduration"},e[1]&&(i.duration=parseInt(e[1],10)),void this.trigger("data",i);if(e=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(t))return i={type:"tag",tagType:"version"},e[1]&&(i.version=parseInt(e[1],10)),void this.trigger("data",i);if(e=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return i={type:"tag",tagType:"media-sequence"},e[1]&&(i.number=parseInt(e[1],10)),void this.trigger("data",i);if(e=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return i={type:"tag",tagType:"discontinuity-sequence"},e[1]&&(i.number=parseInt(e[1],10)),void this.trigger("data",i);if(e=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(t))return i={type:"tag",tagType:"playlist-type"},e[1]&&(i.playlistType=e[1]),void this.trigger("data",i);if(e=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(t))return i={type:"tag",tagType:"byterange"},e[1]&&(i.length=parseInt(e[1],10)),e[2]&&(i.offset=parseInt(e[2],10)),void this.trigger("data",i);if(e=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(t))return i={type:"tag",tagType:"allow-cache"},e[1]&&(i.allowed=!/NO/.test(e[1])),void this.trigger("data",i);if(e=/^#EXT-X-STREAM-INF:?(.*)$/.exec(t)){if(i={type:"tag",tagType:"stream-inf"},e[1]){if(i.attributes=l(e[1]),i.attributes.RESOLUTION){var n=i.attributes.RESOLUTION.split("x"),r={};n[0]&&(r.width=parseInt(n[0],10)),n[1]&&(r.height=parseInt(n[1],10)),i.attributes.RESOLUTION=r}i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes["PROGRAM-ID"]&&(i.attributes["PROGRAM-ID"]=parseInt(i.attributes["PROGRAM-ID"],10))}return void this.trigger("data",i)}return(e=/^#EXT-X-ENDLIST/.exec(t))?void this.trigger("data",{type:"tag",tagType:"endlist"}):(e=/^#EXT-X-DISCONTINUITY/.exec(t))?void this.trigger("data",{type:"tag",tagType:"discontinuity"}):(e=/^#EXT-X-KEY:?(.*)$/.exec(t))?(i={type:"tag",tagType:"key"},e[1]&&(i.attributes=l(e[1]),i.attributes.IV&&("0x"===i.attributes.IV.substring(0,2)&&(i.attributes.IV=i.attributes.IV.substring(2)),i.attributes.IV=i.attributes.IV.match(/.{8}/g),i.attributes.IV[0]=parseInt(i.attributes.IV[0],16),i.attributes.IV[1]=parseInt(i.attributes.IV[1],16),i.attributes.IV[2]=parseInt(i.attributes.IV[2],16),i.attributes.IV[3]=parseInt(i.attributes.IV[3],16),i.attributes.IV=new Uint32Array(i.attributes.IV))),void this.trigger("data",i)):void this.trigger("data",{type:"tag",data:t.slice(4,t.length)})}}}]),e}(d["default"]);i["default"]=c,e.exports=i["default"]},{"../stream":13}],9:[function(t,e,i){(function(n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},d=t("../stream"),f=r(d),l=t("./line-stream"),c=r(l),h=t("./parse-stream"),p=r(h),g="undefined"!=typeof window?window.videojs:"undefined"!=typeof n?n.videojs:null,y=function(t){function e(){a(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this),this.lineStream=new c["default"],this.parseStream=new p["default"],this.lineStream.pipe(this.parseStream);var t=this,i=[],n={},r=void 0,s=function(){};this.manifest={allowCache:!0,discontinuityStarts:[]},this.parseStream.on("data",function(e){({tag:function(){(({"allow-cache":function(){this.manifest.allowCache=e.allowed,"allowed"in e||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange:function a(){var a={};"length"in e&&(n.byterange=a,a.length=e.length,"offset"in e||(this.trigger("info",{message:"defaulting offset to zero"}),e.offset=0)),"offset"in e&&(n.byterange=a,a.offset=e.offset)},endlist:function(){this.manifest.endList=!0},inf:function(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),e.duration>=0&&(n.duration=e.duration),this.manifest.segments=i},key:function(){return e.attributes?"NONE"===e.attributes.METHOD?void(r=null):e.attributes.URI?(e.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),r={method:e.attributes.METHOD||"AES-128",uri:e.attributes.URI},void("undefined"!=typeof e.attributes.IV&&(r.iv=e.attributes.IV))):void this.trigger("warn",{message:"ignoring key declaration without URI"}):void this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){return isFinite(e.number)?void(this.manifest.mediaSequence=e.number):void this.trigger("warn",{message:"ignoring invalid media sequence: "+e.number})},"discontinuity-sequence":function(){return isFinite(e.number)?void(this.manifest.discontinuitySequence=e.number):void this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+e.number})},"playlist-type":function(){return/VOD|EVENT/.test(e.playlistType)?void(this.manifest.playlistType=e.playlistType):void this.trigger("warn",{message:"ignoring unknown playlist type: "+e.playlist})},"stream-inf":function(){return this.manifest.playlists=i,e.attributes?(n.attributes||(n.attributes={}),void(n.attributes=(0,g.mergeOptions)(n.attributes,e.attributes))):void this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},discontinuity:function(){n.discontinuity=!0,this.manifest.discontinuityStarts.push(i.length)},targetduration:function(){return!isFinite(e.duration)||e.duration<0?void this.trigger("warn",{message:"ignoring invalid target duration: "+e.duration}):void(this.manifest.targetDuration=e.duration)},totalduration:function(){return!isFinite(e.duration)||e.duration<0?void this.trigger("warn",{message:"ignoring invalid total duration: "+e.duration}):void(this.manifest.totalDuration=e.duration)}})[e.tagType]||s).call(t)},uri:function(){n.uri=e.uri,i.push(n),!this.manifest.targetDuration||"duration"in n||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),n.duration=this.manifest.targetDuration),r&&(n.key=r),n={}},comment:function(){}})[e.type].call(t)})}return s(e,t),o(e,[{key:"push",value:function(t){this.lineStream.push(t)}},{key:"end",value:function(){this.lineStream.push("\n")}}]),e}(f["default"]);i["default"]=y,e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../stream":13,"./line-stream":7,"./parse-stream":8}],10:[function(t,e,i){(function(n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},d=t("./resolve-url"),f=r(d),l=t("./xhr"),c=r(l),h="undefined"!=typeof window?window.videojs:"undefined"!=typeof n?n.videojs:null,p=t("./stream"),g=r(p),y=t("./m3u8"),m=r(y),b=function(t,e){for(var i=!1,n=(0,h.mergeOptions)(t,{}),r=t.playlists.length,a=void 0;r--;)if(a=n.playlists[r],a.uri===e.uri){if(a.segments&&e.segments&&a.segments.length===e.segments.length&&a.mediaSequence===e.mediaSequence)continue;n.playlists[r]=(0,h.mergeOptions)(a,e),n.playlists[e.uri]=n.playlists[r],a.segments&&(n.playlists[r].segments=v(a.segments,e.segments,e.mediaSequence-a.mediaSequence)),i=!0}return i?n:null},v=function(t,e,i){var n=e.slice(),r=void 0,a=void 0;for(i=i||0,r=Math.min(t.length,e.length+i),a=i;r>a;a++)n[a-i]=(0,h.mergeOptions)(t[a],n[a-i]);return n},_=function(t){function e(t,i){a(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this);var n=this,r=void 0,s=void 0,o=void 0,d=void 0,l=void 0;if(this.trackExpiredTime_=!1,!t)throw new Error("A non-empty playlist URL is required");d=function(t,e,i){n.setBandwidth(o||t),o=null,i&&(n.state=i),n.error={playlist:n.master.playlists[e],status:t.status,message:"HLS playlist request error at URL: "+e,responseText:t.responseText,code:t.status>=500?4:2},n.trigger("error")},l=function(t,e){var i=void 0,r=void 0,a=void 0;n.setBandwidth(o||t),o=null,n.state="HAVE_METADATA",i=new m["default"].Parser,i.push(t.responseText),i.end(),i.manifest.uri=e,a=b(n.master,i.manifest),r=1e3*(i.manifest.targetDuration||10),a?(n.master=a,n.updateMediaPlaylist_(i.manifest)):r/=2,n.media().endList||(window.clearTimeout(s),s=window.setTimeout(function(){n.trigger("mediaupdatetimeout")},r)),n.trigger("loadedplaylist")},n.state="HAVE_NOTHING",this.expired_=0,r=this.dispose,n.dispose=function(){o&&(o.onreadystatechange=null,o.abort(),o=null),window.clearTimeout(s),r.call(this)},n.media=function(t){var e=n.state,r=void 0;if(!t)return n.media_;if("HAVE_NOTHING"===n.state)throw new Error("Cannot switch media playlist from "+n.state);if("string"==typeof t){if(!n.master.playlists[t])throw new Error("Unknown playlist URI: "+t);t=n.master.playlists[t]}if(r=!n.media_||t.uri!==n.media_.uri,n.master.playlists[t.uri].endList)return o&&(o.onreadystatechange=null,o.abort(),o=null),n.state="HAVE_METADATA",n.media_=t,void(r&&n.trigger("mediachange"));if(r){if(n.state="SWITCHING_MEDIA",o){if((0,f["default"])(n.master.uri,t.uri)===o.url)return;o.onreadystatechange=null,o.abort(),o=null}o=(0,c["default"])({uri:(0,f["default"])(n.master.uri,t.uri),withCredentials:i},function(i,r){return i?d(r,t.uri,e):(l(r,t.uri),void("HAVE_MASTER"===e?n.trigger("loadedmetadata"):n.trigger("mediachange")))})}},n.setBandwidth=function(t){n.bandwidth=t.bandwidth},n.on("firstplay",function(){this.trackExpiredTime_=!0}),n.on("mediaupdatetimeout",function(){"HAVE_METADATA"===n.state&&(n.state="HAVE_CURRENT_METADATA",o=(0,c["default"])({uri:(0,f["default"])(n.master.uri,n.media().uri),withCredentials:i},function(t,e){return t?d(e,n.media().uri):void l(e,n.media().uri)}))}),o=(0,c["default"])({uri:t,withCredentials:i},function(e,i){var r=void 0,a=void 0;if(o=null,e)return n.error={status:i.status,message:"HLS playlist request error at URL: "+t,responseText:i.responseText,code:2},n.trigger("error");if(r=new m["default"].Parser,r.push(i.responseText),r.end(),n.state="HAVE_MASTER",r.manifest.uri=t,r.manifest.playlists){for(n.master=r.manifest,a=n.master.playlists.length;a--;)n.master.playlists[n.master.playlists[a].uri]=n.master.playlists[a];return n.trigger("loadedplaylist"),void(o||n.media(r.manifest.playlists[0]))}return n.master={uri:window.location.href,playlists:[{uri:t}]},n.master.playlists[t]=n.master.playlists[0],l(i,t),n.trigger("loadedmetadata")})}return s(e,t),o(e,[{key:"updateMediaPlaylist_",value:function(t){var e=void 0,i=void 0,n=void 0;if(e=this.media_,this.media_=this.master.playlists[t.uri],e&&this.trackExpiredTime_&&t.uri===e.uri){if(t.segments.length){if(void 0!==t.segments[0].start)return void(this.expired_=t.segments[0].start);if(void 0!==t.segments[0].end)return void(this.expired_=t.segments[0].end-t.segments[0].duration)}for(i=t.mediaSequence-e.mediaSequence-1;i>=0;i--)if(n=e.segments[i]){if(void 0!==n.end)return void(this.expired_=n.end);if(void 0!==n.start)return void(this.expired_=n.start+n.duration);this.expired_+=n.duration}else this.expired_+=e.targetDuration||10}}},{key:"getMediaIndexForTime_",value:function(t){var e=void 0,i=void 0,n=t,r=this.media_.segments.length,a=r-1,s=void 0,o=void 0,u=void 0,d=void 0;if(!this.media_)return 0;if(0>t)return 0;for(e=0;r>e;e++)if(i=this.media_.segments[e],i.end){if(i.end>t){d=i.end,o=e;break}u=i.end,s=e+1}if(void 0!==s){for(t-=u,e=s;(o||r)>e;e++)if(i=this.media_.segments[e],t-=i.duration,0>t)return e;return e>=o?s+Math.floor((n-u)/(d-u)*(o-s)):a}if(void 0!==o){for(t=d-t,e=o;e>=0;e--)if(i=this.media_.segments[e],t-=i.duration,0>t)return e;return 0===t?0:-1}if(t-=this.expired_,0>t)return-1;for(e=0;r>e;e++)if(i=this.media_.segments[e],t-=i.duration,0>t)return e;return a}}]),e}(g["default"]);i["default"]=_,e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./m3u8":6,"./resolve-url":12,"./stream":13,"./xhr":14}],11:[function(t,e,i){(function(t){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var e="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,n={UNSAFE_LIVE_SEGMENTS:3},r=function(t,e){var i=0,n=e-t.mediaSequence,r=t.segments[n];if(r){if("undefined"!=typeof r.start)return{result:r.start,precise:!0};if("undefined"!=typeof r.end)return{result:r.end-r.duration,precise:!0}}for(;n--;){if(r=t.segments[n],"undefined"!=typeof r.end)return{result:i+r.end,precise:!0};if(i+=r.duration,"undefined"!=typeof r.start)return{result:i+r.start,precise:!0}}return{result:i,precise:!1}},a=function(t,e){for(var i=0,n=void 0,r=e-t.mediaSequence;r<t.segments.length;r++){if(n=t.segments[r],"undefined"!=typeof n.start)return{result:n.start-i,precise:!0};if(i+=n.duration,"undefined"!=typeof n.end)return{result:n.end-i,precise:!0}}return{result:-1,precise:!1}},s=function(t,e){var i=void 0,n=void 0;return"undefined"==typeof e&&(e=t.mediaSequence+t.segments.length),e<t.mediaSequence?0:(i=r(t,e),i.precise?i.result:(n=a(t,e),n.precise?n.result:i.result))},o=function(t,e,i){if(!t)return 0;if("undefined"==typeof i&&(i=!0),"undefined"==typeof e){if(t.totalDuration)return t.totalDuration;if(!t.endList)return window.Infinity}return s(t,e,i)};i.duration=o;var u=function(t){var i=void 0,r=void 0;return t.segments?t.endList?(0,e.createTimeRange)(0,o(t)):(i=s(t,t.mediaSequence),r=s(t,t.mediaSequence+Math.max(0,t.segments.length-n.UNSAFE_LIVE_SEGMENTS)),(0,e.createTimeRange)(i,r)):(0,e.createTimeRange)()};i.seekable=u,n.duration=o,n.seekable=u,i["default"]=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],12:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(i,"__esModule",{value:!0});var r=t("global/document"),a=n(r),s=function(t,e){var i=a["default"].querySelector("base"),n=a["default"].querySelector("head"),r=a["default"].createElement("a"),s=i,o=void 0,u=void 0;return i?o=i.href:s=n.appendChild(a["default"].createElement("base")),s.href=t,r.href=e,u=r.href,i?i.href=o:n.removeChild(s),u};i["default"]=s,e.exports=i["default"]},{"global/document":16}],13:[function(t,e,i){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=function(){function t(){n(this,t),this.listeners={}}return r(t,[{key:"on",value:function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}},{key:"off",value:function(t,e){var i=void 0;return this.listeners[t]?(i=this.listeners[t].indexOf(e),this.listeners[t].splice(i,1),i>-1):!1}},{key:"trigger",value:function(t){var e=void 0,i=void 0,n=void 0,r=void 0;if(e=this.listeners[t])if(2===arguments.length)for(n=e.length,i=0;n>i;++i)e[i].call(this,arguments[1]);else for(r=Array.prototype.slice.call(arguments,1),n=e.length,i=0;n>i;++i)e[i].apply(this,r)}},{key:"dispose",value:function(){this.listeners={}}},{key:"pipe",value:function(t){this.on("data",function(e){t.push(e)})}}]),t}();i["default"]=a,e.exports=i["default"]},{}],14:[function(t,e,i){(function(t){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,r=function(t,e){t=(0,n.mergeOptions)({timeout:45e3},t);var i=(0,n.xhr)(t,function(t,n){!t&&i.response&&(i.responseTime=(new Date).getTime(),i.roundTripTime=i.responseTime-i.requestTime,i.bytesReceived=i.response.byteLength||i.response.length,i.bandwidth||(i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3))),t||i.timedout?i.timedout=i.timedout||"ETIMEDOUT"===t.code:i.timedout=!1,t||200===n.statusCode||206===n.statusCode||0===n.statusCode||(t=new Error("XHR Failed with a response of: "+(i&&(i.response||i.responseText)))),e(t,i)});return i.requestTime=(new Date).getTime(),i};i["default"]=r,e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(t,e,i){},{}],16:[function(t,e,i){(function(i){var n="undefined"!=typeof i?i:"undefined"!=typeof window?window:{},r=t("min-document");if("undefined"!=typeof document)e.exports=document;else{var a=n["__GLOBAL_DOCUMENT_CACHE@4"];a||(a=n["__GLOBAL_DOCUMENT_CACHE@4"]=r),e.exports=a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"min-document":15}],17:[function(t,e,i){"use strict";var n;e.exports=function(t){var e=n[t.byteLength%16||0],i=new Uint8Array(t.byteLength+e.length);return i.set(t),i.set(e,t.byteLength),i},n=[[16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16],[15,15,15,15,15,15,15,15,15,15,15,15,15,15,15],[14,14,14,14,14,14,14,14,14,14,14,14,14,14],[13,13,13,13,13,13,13,13,13,13,13,13,13],[12,12,12,12,12,12,12,12,12,12,12,12],[11,11,11,11,11,11,11,11,11,11,11],[10,10,10,10,10,10,10,10,10,10],[9,9,9,9,9,9,9,9,9],[8,8,8,8,8,8,8,8],[7,7,7,7,7,7,7],[6,6,6,6,6,6],[5,5,5,5,5],[4,4,4,4],[3,3,3],[2,2],[1]]},{}],18:[function(t,e,i){"use strict";i.pad=t("./pad.js"),i.unpad=t("./unpad.js")},{"./pad.js":17,"./unpad.js":19}],19:[function(t,e,i){"use strict";e.exports=function(t){return t.subarray(0,t.byteLength-t[t.byteLength-1])}},{}],20:[function(t,e,i){(function(t){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(i,"__esModule",{value:!0});var r="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,a=n(r),s=function(t){Object.defineProperties(t.frame,{id:{get:function(){return a["default"].log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get:function(){return a["default"].log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get:function(){return a["default"].log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})},o=function(t,e,i){var n=window.WebKitDataCue||window.VTTCue;e&&e.forEach(function(t){this.inbandTextTrack_.addCue(new n(t.startTime+this.timestampOffset,t.endTime+this.timestampOffset,t.text))},t),i&&i.forEach(function(t){var e=t.cueTime+this.timestampOffset;t.frames.forEach(function(t){var i=new n(e,e,t.value||t.url||t.data||"");i.frame=t,
i.value=t,s(i),this.metadataTrack_.addCue(i)},this)},t)};i["default"]=o,e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],21:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(t,e,i){i.captions&&i.captions.length&&!t.inbandTextTrack_&&(t.inbandTextTrack_=e.player_.addTextTrack("captions","cc1")),i.metadata&&i.metadata.length&&!t.metadataTrack_&&(t.metadataTrack_=e.player_.addTextTrack("metadata","Timed Metadata"),t.metadataTrack_.inBandMetadataTrackDispatchType=i.metadata.dispatchType)};i["default"]=n,e.exports=i["default"]},{}],22:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={TIME_BETWEEN_TICKS:Math.floor(1e3/480),TIME_PER_TICK:Math.floor(1e3/240),BYTES_PER_CHUNK:1024,MIN_CHUNK:1024,MAX_CHUNK:1048576};i["default"]=n,e.exports=i["default"]},{}],23:[function(t,e,i){(function(n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},d="undefined"!=typeof window?window.videojs:"undefined"!=typeof n?n.videojs:null,f=r(d),l=t("./flash-source-buffer"),c=r(l),h=t("./flash-constants"),p=r(h),g=function(t){function e(){var t=this;a(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this),this.sourceBuffers=[],this.readyState="closed",this.on(["sourceopen","webkitsourceopen"],function(e){t.swfObj=document.getElementById(e.swfId),t.player_=(0,f["default"])(t.swfObj.parentNode),t.tech_=t.swfObj.tech,t.readyState="open",t.tech_.on("seeking",function(){for(var e=t.sourceBuffers.length;e--;)t.sourceBuffers[e].abort()}),t.swfObj&&t.swfObj.vjs_load()})}return s(e,t),o(e,[{key:"addSeekableRange_",value:function(){}},{key:"addSourceBuffer",value:function(t){var e=void 0;if(0!==t.indexOf("video/mp2t"))throw new Error("NotSupportedError (Video.js)");return e=new c["default"](this),this.sourceBuffers.push(e),e}},{key:"endOfStream",value:function(t){"network"===t?this.tech_.error(2):"decode"===t&&this.tech_.error(3),"ended"!==this.readyState&&(this.readyState="ended",this.swfObj.vjs_endOfStream())}}]),e}(f["default"].EventTarget);i["default"]=g;try{Object.defineProperty(g.prototype,"duration",{get:function(){return this.swfObj?this.swfObj.vjs_getProperty("duration"):NaN},set:function(t){var e=void 0,i=this.swfObj.vjs_getProperty("duration");if(this.swfObj.vjs_setProperty("duration",t),i>t)for(e=0;e<this.sourceBuffers.length;e++)this.sourceBuffers[e].remove(t,i);return t}})}catch(y){g.prototype.duration=NaN}for(var m in p["default"])g[m]=p["default"][m];e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./flash-constants":22,"./flash-source-buffer":24}],24:[function(t,e,i){(function(n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},d="undefined"!=typeof window?window.videojs:"undefined"!=typeof n?n.videojs:null,f=r(d),l=t("mux.js"),c=r(l),h=t("./remove-cues-from-track"),p=r(h),g=t("./create-text-tracks-if-necessary"),y=r(g),m=t("./add-text-track-data"),b=r(m),v=t("./flash-constants"),_=r(v),w=function(t){window.setTimeout(t,_["default"].TIME_BETWEEN_TICKS)},T=function(t){function e(t){var i=this;a(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this);var n=void 0;this.chunkSize_=_["default"].BYTES_PER_CHUNK,this.buffer_=[],this.bufferSize_=0,this.basePtsOffset_=NaN,this.mediaSource=t,this.updating=!1,this.timestampOffset_=0,this.segmentParser_=new c["default"].flv.Transmuxer,this.segmentParser_.on("data",this.receiveBuffer_.bind(this)),n=window.btoa(String.fromCharCode.apply(null,Array.prototype.slice.call(this.segmentParser_.getFlvHeader()))),this.mediaSource.swfObj.vjs_appendBuffer(n),Object.defineProperty(this,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(t){"number"==typeof t&&t>=0&&(this.timestampOffset_=t,this.segmentParser_=new c["default"].flv.Transmuxer,this.segmentParser_.on("data",this.receiveBuffer_.bind(this)),this.mediaSource.swfObj.vjs_discontinuity(),this.basePtsOffset_=NaN)}}),Object.defineProperty(this,"buffered",{get:function(){return f["default"].createTimeRanges(this.mediaSource.swfObj.vjs_getProperty("buffered"))}}),this.mediaSource.player_.on("seeked",function(){(0,p["default"])(0,1/0,i.metadataTrack_),(0,p["default"])(0,1/0,i.inbandTextTrack_)})}return s(e,t),o(e,[{key:"appendBuffer",value:function(t){var e=this,i=void 0,n=524288,r=0;if(this.updating)throw i=new Error("SourceBuffer.append() cannot be called while an update is in progress"),i.name="InvalidStateError",i.code=11,i;this.updating=!0,this.mediaSource.readyState="open",this.trigger({type:"update"});var a=function s(){e.segmentParser_.push(t.subarray(r,r+n)),r+=n,w(r<t.byteLength?s:e.segmentParser_.flush.bind(e.segmentParser_))};a()}},{key:"abort",value:function(){this.buffer_=[],this.bufferSize_=0,this.mediaSource.swfObj.vjs_abort(),this.updating&&(this.updating=!1,this.trigger({type:"updateend"}))}},{key:"remove",value:function(t,e){(0,p["default"])(t,e,this.metadataTrack_),(0,p["default"])(t,e,this.inbandTextTrack_),this.trigger({type:"update"}),this.trigger({type:"updateend"})}},{key:"receiveBuffer_",value:function(t){var e=this;(0,y["default"])(this,this.mediaSource,t),(0,b["default"])(this,t.captions,t.metadata),w(function(){var i=e.convertTagsToData_(t);0===e.buffer_.length&&w(e.processBuffer_.bind(e)),i&&(e.buffer_.push(i),e.bufferSize_+=i.byteLength)})}},{key:"processBuffer_",value:function(){var t=void 0,e=void 0,i=void 0,n=void 0,r=void 0,a=0,s=0,o=+new Date,u=void 0;if(!this.buffer_.length)return void(this.updating!==!1&&(this.updating=!1,this.trigger({type:"updateend"})));do{for(s++,t=this.buffer_[0].subarray(a,a+this.chunkSize_),t.byteLength<this.chunkSize_||this.buffer_[0].byteLength===a+this.chunkSize_?(a=0,this.buffer_.shift()):a+=this.chunkSize_,this.bufferSize_-=t.byteLength,n="",i=t.byteLength,e=0;i>e;e++)n+=String.fromCharCode(t[e]);r=window.btoa(n),this.mediaSource.swfObj.CallFunction('<invoke name="vjs_appendBuffer"returntype="javascript"><arguments><string>'+r+"</string></arguments></invoke>"),u=new Date-o}while(this.buffer_.length&&u<_["default"].TIME_PER_TICK);this.buffer_.length&&a&&(this.buffer_[0]=this.buffer_[0].subarray(a)),u>=_["default"].TIME_PER_TICK&&(this.chunkSize_=Math.floor(this.chunkSize_*(s/4))),this.chunkSize_=Math.max(_["default"].MIN_CHUNK,Math.min(this.chunkSize_,_["default"].MAX_CHUNK)),0!==this.bufferSize_?w(this.processBuffer_.bind(this)):(this.updating=!1,this.trigger({type:"updateend"}))}},{key:"convertTagsToData_",value:function(t){var e=0,i=this.mediaSource.tech_,n=0,r=void 0,a=void 0,s=void 0,o=[],u=this.getOrderedTags_(t);for(isNaN(this.basePtsOffset_)&&u.length&&(this.basePtsOffset_=u[0].pts),i.buffered().length&&(n=i.buffered().end(0)-this.timestampOffset),n=Math.max(n,i.currentTime()-this.timestampOffset),n*=1e3,n+=this.basePtsOffset_,r=0;r<u.length;r++)u[r].pts>=n&&o.push(u[r]);if(0!==o.length){for(r=0;r<o.length;r++)e+=o[r].bytes.byteLength;for(s=new Uint8Array(e),r=0,a=0;r<o.length;r++)s.set(o[r].bytes,a),a+=o[r].bytes.byteLength;return s}}},{key:"getOrderedTags_",value:function(t){for(var e=t.tags.videoTags,i=t.tags.audioTags,n=void 0,r=[];e.length||i.length;)n=e.length?i.length&&i[0].dts<e[0].dts?i.shift():e.shift():i.shift(),r.push(n.finalize());return r}}]),e}(f["default"].EventTarget);i["default"]=T,e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./add-text-track-data":20,"./create-text-tracks-if-necessary":21,"./flash-constants":22,"./remove-cues-from-track":26,"mux.js":37}],25:[function(t,e,i){(function(n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},d="undefined"!=typeof window?window.videojs:"undefined"!=typeof n?n.videojs:null,f=r(d),l=t("./virtual-source-buffer"),c=r(l),h=function(t){return t.replace(/avc1\.(\d+)\.(\d+)/i,function(t,e,i){var n=("00"+Number(e).toString(16)).slice(-2),r=("00"+Number(i).toString(16)).slice(-2);return"avc1."+n+"00"+r})},p=function(t){function e(){a(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,f["default"].EventTarget);var t=this,i=void 0;this.mediaSource_=new window.MediaSource;for(i in this.mediaSource_)i in e.prototype||"function"!=typeof this.mediaSource_[i]||(this[i]=this.mediaSource_[i].bind(this.mediaSource_));this.duration_=NaN,Object.defineProperty(this,"duration",{get:function(){return t.duration_===1/0?t.duration_:t.mediaSource_.duration},set:function(e){return t.duration_=e,e!==1/0?void(t.mediaSource_.duration=e):void 0}}),Object.defineProperty(this,"seekable",{get:function(){return this.duration_===1/0?f["default"].createTimeRanges([[0,t.mediaSource_.duration]]):t.mediaSource_.seekable}}),Object.defineProperty(this,"readyState",{get:function(){return t.mediaSource_.readyState}}),this.sourceBuffers=[],["sourceopen","sourceclose","sourceended"].forEach(function(t){this.mediaSource_.addEventListener(t,this.trigger.bind(this))},this),this.on("sourceopen",function(e){var i=document.querySelector('[src="'+t.url_+'"]');i&&(t.player_=(0,f["default"])(i.parentNode))}),this.on("sourceclose",function(t){this.sourceBuffers.forEach(function(t){t.transmuxer_&&t.transmuxer_.terminate()}),this.sourceBuffers.length=0})}return s(e,t),o(e,[{key:"addSeekableRange_",value:function(t,e){var i=void 0;if(this.duration!==1/0)throw i=new Error("MediaSource.addSeekableRange() can only be invoked when the duration is Infinity"),i.name="InvalidStateError",i.code=11,i;(e>this.mediaSource_.duration||isNaN(this.mediaSource_.duration))&&(this.mediaSource_.duration=e)}},{key:"addSourceBuffer",value:function(t){var e=void 0,i=void 0,n=void 0,r=void 0,a=/avc1\.[\da-f]+/i,s=/mp4a\.\d+.\d+/i;return/^video\/mp2t/i.test(t)?(i=t.split(";").slice(1).join(";"),i=h(i),n=(i.match(a)||[])[0],r=(i.match(s)||[])[0],n&&n.length||(n="avc1.4d400d"),r&&r.length||(r="mp4a.40.2"),e=new c["default"](this,[n,r]),this.sourceBuffers.push(e),e):(e=this.mediaSource_.addSourceBuffer(t),this.sourceBuffers.push(e),e)}}]),e}(f["default"].EventTarget);i["default"]=p,e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./virtual-source-buffer":29}],26:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(t,e,i){var n=void 0,r=void 0;if(i)for(n=i.cues.length;n--;)r=i.cues[n],r.startTime<=e&&r.endTime>=t&&i.removeCue(r)};i["default"]=n,e.exports=i["default"]},{}],27:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(i,"__esModule",{value:!0});var r=t("mux.js"),a=n(r),s=void 0,o={},u=function(t){t.on("data",function(t){var e=t.data;t.data=e.buffer,postMessage({action:"data",segment:t,byteOffset:e.byteOffset,byteLength:e.byteLength},[t.data])}),t.captionStream&&t.captionStream.on("data",function(t){postMessage({action:"caption",data:t})}),t.on("done",function(t){postMessage({action:"done"})})},d={init:function(t){o=t&&t.options||{},this.defaultInit()},defaultInit:function(){s&&s.dispose(),s=new a["default"].mp4.Transmuxer(o),u(s)},push:function(t){var e=new Uint8Array(t.data,t.byteOffset,t.byteLength);s.push(e)},reset:function(){this.defaultInit()},setTimestampOffset:function(t){var e=t.timestampOffset||0;s.setBaseMediaDecodeTime(Math.round(9e4*e))},flush:function(t){s.flush()}},f=function(t){t.onmessage=function(t){s||"init"===t.data.action||d.defaultInit(),t.data&&t.data.action&&d[t.data.action]&&d[t.data.action](t.data)}};i["default"]=f,e.exports=i["default"]},{"mux.js":37}],28:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(i,"__esModule",{value:!0});var r=t("./flash-media-source"),a=n(r),s=t("./html-media-source"),o=n(s),u=window.videojs,d=0,f={mode:"auto"};u.mediaSources={};var l=function(t,e){var i=u.mediaSources[t];if(!i)throw new Error("Media Source not found (Video.js)");i.trigger({type:"sourceopen",swfId:e})},c=function(){return!!window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},h=function(t){var e=u.mergeOptions(f,t);return this.MediaSource={open:l,supportsNativeMediaSources:c},"html5"===e.mode||"auto"===e.mode&&c()?new o["default"]:new a["default"]};i.MediaSource=h,h.open=l,h.supportsNativeMediaSources=c;var p={createObjectURL:function(t){var e="blob:vjs-media-source/",i=void 0;return t instanceof o["default"]?(i=window.URL.createObjectURL(t.mediaSource_),t.url_=i,i):t instanceof a["default"]?(i=e+d,d++,u.mediaSources[i]=t,i):(i=window.URL.createObjectURL(t),t.url_=i,i)}};i.URL=p,u.MediaSource=h,u.URL=p},{"./flash-media-source":23,"./html-media-source":25}],29:[function(t,e,i){(function(n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},d="undefined"!=typeof window?window.videojs:"undefined"!=typeof n?n.videojs:null,f=r(d),l=t("./create-text-tracks-if-necessary"),c=r(l),h=t("./remove-cues-from-track"),p=r(h),g=t("./add-text-track-data"),y=r(g),m=t("webworkify"),b=r(m),v=t("./transmuxer-worker"),_=r(v),w=function(t,e,i){return function(){return t[e]&&t[e].updating?void 0:t.trigger(i)}},T=function(t){function e(t,i){var n=this;a(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,f["default"].EventTarget),this.timestampOffset_=0,this.pendingBuffers_=[],this.bufferUpdating_=!1,this.mediaSource_=t,this.codecs_=i,this.transmuxer_=(0,b["default"])(_["default"]),this.transmuxer_.postMessage({action:"init",options:{remux:!1}}),this.transmuxer_.onmessage=function(t){return"data"===t.data.action?n.data_(t):"done"===t.data.action?n.done_(t):void 0},Object.defineProperty(this,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(t){"number"==typeof t&&t>=0&&(this.timestampOffset_=t,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:t}))}}),Object.defineProperty(this,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(t){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=t),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=t)}}),Object.defineProperty(this,"updating",{get:function(){return this.bufferUpdating_||this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating}}),Object.defineProperty(this,"buffered",{get:function(){var t=null,e=null,i=0,n=[],r=[];if(!(this.videoBuffer_&&0!==this.videoBuffer_.buffered.length||this.audioBuffer_&&0!==this.audioBuffer_.buffered.length))return f["default"].createTimeRange();if(!this.videoBuffer_)return this.audioBuffer_.buffered;if(!this.audioBuffer_)return this.videoBuffer_.buffered;for(var a=this.videoBuffer_.buffered,s=this.audioBuffer_.buffered,o=a.length;o--;)n.push({time:a.start(o),type:"start"}),n.push({time:a.end(o),type:"end"});for(o=s.length;o--;)n.push({time:s.start(o),type:"start"}),n.push({time:s.end(o),type:"end"});for(n.sort(function(t,e){return t.time-e.time}),o=0;o<n.length;o++)"start"===n[o].type?(i++,2===i&&(t=n[o].time)):"end"===n[o].type&&(i--,1===i&&(e=n[o].time)),null!==t&&null!==e&&(r.push([t,e]),t=null,e=null);return f["default"].createTimeRanges(r)}})}return s(e,t),o(e,[{key:"data_",value:function(t){var e=t.data.segment,i=this.mediaSource_.mediaSource_;e.data=new Uint8Array(e.data,t.data.byteOffset,t.data.byteLength),"video"===e.type?this.videoBuffer_||(this.videoBuffer_=i.addSourceBuffer('video/mp4;codecs="'+this.codecs_[0]+'"'),this.videoBuffer_.addEventListener("updatestart",w(this,"audioBuffer_","updatestart")),this.videoBuffer_.addEventListener("update",w(this,"audioBuffer_","update")),this.videoBuffer_.addEventListener("updateend",w(this,"audioBuffer_","updateend"))):"audio"===e.type?this.audioBuffer_||(this.audioBuffer_=i.addSourceBuffer('audio/mp4;codecs="'+this.codecs_[1]+'"'),this.audioBuffer_.addEventListener("updatestart",w(this,"videoBuffer_","updatestart")),this.audioBuffer_.addEventListener("update",w(this,"videoBuffer_","update")),this.audioBuffer_.addEventListener("updateend",w(this,"videoBuffer_","updateend"))):"combined"===e.type&&(this.videoBuffer_||(this.videoBuffer_=i.addSourceBuffer('video/mp4;codecs="'+this.codecs_.join(",")+'"'),this.videoBuffer_.addEventListener("updatestart",w(this,"videoBuffer_","updatestart")),this.videoBuffer_.addEventListener("update",w(this,"videoBuffer_","update")),this.videoBuffer_.addEventListener("updateend",w(this,"videoBuffer_","updateend")))),(0,c["default"])(this,this.mediaSource_,e),this.pendingBuffers_.push(e)}},{key:"done_",value:function(){this.processPendingSegments_()}},{key:"appendBuffer",value:function(t){this.bufferUpdating_=!0,this.transmuxer_.postMessage({action:"push",data:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength},[t.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"remove",value:function(t,e){this.videoBuffer_&&this.videoBuffer_.remove(t,e),this.audioBuffer_&&this.audioBuffer_.remove(t,e),(0,p["default"])(t,e,this.metadataTrack_),(0,p["default"])(t,e,this.inbandTextTrack_)}},{key:"processPendingSegments_",value:function(){var t={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};t=this.pendingBuffers_.reduce(function(t,e){var i=e.type,n=e.data;return"combined"===i&&(i="video"),t[i].segments.push(n),t[i].bytes+=n.byteLength,e.captions&&(t.captions=t.captions.concat(e.captions)),e.metadata&&(t.metadata=t.metadata.concat(e.metadata)),t},t),(0,y["default"])(this,t.captions,t.metadata),this.concatAndAppendSegments_(t.video,this.videoBuffer_),this.concatAndAppendSegments_(t.audio,this.audioBuffer_),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(t,e){var i=0,n=void 0;t.bytes&&(n=new Uint8Array(t.bytes),t.segments.forEach(function(t){n.set(t,i),i+=t.byteLength}),e.appendBuffer(n))}},{key:"abort",value:function(){this.videoBuffer_&&this.videoBuffer_.abort(),this.audioBuffer_&&this.audioBuffer_.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"reset"}),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}}]),e}(f["default"].EventTarget);i["default"]=T,e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./add-text-track-data":20,"./create-text-tracks-if-necessary":21,"./remove-cues-from-track":26,"./transmuxer-worker":27,webworkify:50}],30:[function(t,e,i){"use strict";var n,r=t("../utils/stream.js");n=function(){var t,e=0;n.prototype.init.call(this),this.setTimestamp=function(t){e=t},this.parseId3TagSize=function(t,e){var i=t[e+6]<<21|t[e+7]<<14|t[e+8]<<7|t[e+9],n=t[e+5],r=(16&n)>>4;return r?i+20:i+10},this.parseAdtsSize=function(t,e){var i=(224&t[e+5])>>5,n=t[e+4]<<3,r=6144&t[e+3];return r|n|i},this.push=function(i){var n,r,a,s=0,o=0;for(void 0!==t&&t.length?(a=t.length,t=new Uint8Array(i.byteLength+a),t.set(t.subarray(0,a)),t.set(i,a)):t=i;t.length-o>=10;)if(t[o]!=="I".charCodeAt(0)||t[o+1]!=="D".charCodeAt(0)||t[o+2]!=="3".charCodeAt(0))if(t[o]&!0&&240===(240&t[o+1])){if(s=this.parseAdtsSize(t,o),s>t.length)break;r={type:"audio",data:t.subarray(o,o+s),pts:e,dts:e},this.trigger("data",r),o+=s}else o++;else{if(s=this.parseId3TagSize(t,o),s>t.length)break;n={type:"timed-metadata",data:t.subarray(o,o+s)},this.trigger("data",n),o+=s}}},n.prototype=new r,e.exports=n},{"../utils/stream.js":49}],31:[function(t,e,i){"use strict";var n,r=t("../utils/stream.js"),a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=function(){var t,e;n.prototype.init.call(this),t=this,this.push=function(t){var i,n,r,s,o,u,d=0,f=0;if("audio"===t.type)for(e?(s=e,e=new Uint8Array(s.byteLength+t.data.byteLength),e.set(s),e.set(t.data,s.byteLength)):e=t.data;d+5<e.length;)if(255===e[d]&&240===(246&e[d+1])){if(n=2*(1&~e[d+1]),i=(3&e[d+3])<<11|e[d+4]<<3|(224&e[d+5])>>5,o=1024*((3&e[d+6])+1),u=9e4*o/a[(60&e[d+2])>>>2],r=d+i,e.byteLength<r)return;if(this.trigger("data",{pts:t.pts+f*u,dts:t.dts+f*u,sampleCount:o,audioobjecttype:(e[d+2]>>>6&3)+1,channelcount:(1&e[d+2])<<3|(192&e[d+3])>>>6,samplerate:a[(60&e[d+2])>>>2],samplingfrequencyindex:(60&e[d+2])>>>2,samplesize:16,data:e.subarray(d+7+n,r)}),e.byteLength===r)return void(e=void 0);f++,e=e.subarray(r)}else d++},this.flush=function(){this.trigger("done")}},n.prototype=new r,e.exports=n},{"../utils/stream.js":49}],32:[function(t,e,i){"use strict";var n,r,a=t("../utils/stream.js"),s=t("../utils/exp-golomb.js");r=function(){var t,e,i=0;r.prototype.init.call(this),this.push=function(n){var r;for(e?(r=new Uint8Array(e.byteLength+n.data.byteLength),r.set(e),r.set(n.data,e.byteLength),e=r):e=n.data;i<e.byteLength-3;i++)if(1===e[i+2]){t=i+5;break}for(;t<e.byteLength;)switch(e[t]){case 0:if(0!==e[t-1]){t+=2;break}if(0!==e[t-2]){t++;break}this.trigger("data",e.subarray(i+3,t-2));do t++;while(1!==e[t]&&t<e.length);i=t-2,t+=3;break;case 1:if(0!==e[t-1]||0!==e[t-2]){t+=3;break}this.trigger("data",e.subarray(i+3,t-2)),i=t-2,t+=3;break;default:t+=3}e=e.subarray(i),t-=i,i=0},this.flush=function(){e&&e.byteLength>3&&this.trigger("data",e.subarray(i+3)),e=null,i=0,this.trigger("done")}},r.prototype=new a,n=function(){var t,e,i,a,o,u,d,f=new r;n.prototype.init.call(this),t=this,this.push=function(t){"video"===t.type&&(e=t.trackId,i=t.pts,a=t.dts,f.push(t))},f.on("data",function(n){var r={trackId:e,pts:i,dts:a,data:n};switch(31&n[0]){case 5:r.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:r.nalUnitType="sei_rbsp",r.escapedRBSP=o(n.subarray(1));break;case 7:r.nalUnitType="seq_parameter_set_rbsp",r.escapedRBSP=o(n.subarray(1)),r.config=u(r.escapedRBSP);break;case 8:r.nalUnitType="pic_parameter_set_rbsp";break;case 9:r.nalUnitType="access_unit_delimiter_rbsp"}t.trigger("data",r)}),f.on("done",function(){t.trigger("done")}),this.flush=function(){f.flush()},d=function(t,e){var i,n,r=8,a=8;for(i=0;t>i;i++)0!==a&&(n=e.readExpGolomb(),a=(r+n+256)%256),r=0===a?r:a},o=function(t){for(var e,i,n=t.byteLength,r=[],a=1;n-2>a;)0===t[a]&&0===t[a+1]&&3===t[a+2]?(r.push(a+2),a+=2):a++;if(0===r.length)return t;e=n-r.length,i=new Uint8Array(e);var s=0;for(a=0;e>a;s++,a++)s===r[0]&&(s++,r.shift()),i[a]=t[s];return i},u=function(t){var e,i,n,r,a,o,u,f,l,c,h,p,g=0,y=0,m=0,b=0;if(e=new s(t),i=e.readUnsignedByte(),r=e.readUnsignedByte(),n=e.readUnsignedByte(),e.skipUnsignedExpGolomb(),(100===i||110===i||122===i||244===i||44===i||83===i||86===i||118===i||128===i||138===i||139===i||134===i)&&(a=e.readUnsignedExpGolomb(),3===a&&e.skipBits(1),e.skipUnsignedExpGolomb(),e.skipUnsignedExpGolomb(),e.skipBits(1),e.readBoolean()))for(h=3!==a?8:12,p=0;h>p;p++)e.readBoolean()&&(6>p?d(16,e):d(64,e));if(e.skipUnsignedExpGolomb(),o=e.readUnsignedExpGolomb(),0===o)e.readUnsignedExpGolomb();else if(1===o)for(e.skipBits(1),e.skipExpGolomb(),e.skipExpGolomb(),u=e.readUnsignedExpGolomb(),p=0;u>p;p++)e.skipExpGolomb();return e.skipUnsignedExpGolomb(),e.skipBits(1),f=e.readUnsignedExpGolomb(),l=e.readUnsignedExpGolomb(),c=e.readBits(1),0===c&&e.skipBits(1),e.skipBits(1),e.readBoolean()&&(g=e.readUnsignedExpGolomb(),y=e.readUnsignedExpGolomb(),m=e.readUnsignedExpGolomb(),b=e.readUnsignedExpGolomb()),{profileIdc:i,levelIdc:n,profileCompatibility:r,width:16*(f+1)-2*g-2*y,height:(2-c)*(l+1)*16-2*m-2*b}}},n.prototype=new a,e.exports={H264Stream:n,NalByteStream:r}},{"../utils/exp-golomb.js":48,"../utils/stream.js":49}],33:[function(t,e,i){e.exports={adts:t("./adts"),h264:t("./h264")}},{"./adts":31,"./h264":32}],34:[function(t,e,i){"use strict";var n;n=function(t,e){var i,r=0,a=16384,s=function(t,e){var i,n=t.position+e;n<t.bytes.byteLength||(i=new Uint8Array(2*n),i.set(t.bytes.subarray(0,t.position),0),t.bytes=i,t.view=new DataView(t.bytes.buffer))},o=n.widthBytes||new Uint8Array("width".length),u=n.heightBytes||new Uint8Array("height".length),d=n.videocodecidBytes||new Uint8Array("videocodecid".length);if(!n.widthBytes){for(i=0;i<"width".length;i++)o[i]="width".charCodeAt(i);for(i=0;i<"height".length;i++)u[i]="height".charCodeAt(i);for(i=0;i<"videocodecid".length;i++)d[i]="videocodecid".charCodeAt(i);n.widthBytes=o,n.heightBytes=u,n.videocodecidBytes=d}switch(this.keyFrame=!1,t){case n.VIDEO_TAG:this.length=16,a*=6;break;case n.AUDIO_TAG:this.length=13,this.keyFrame=!0;break;case n.METADATA_TAG:this.length=29,this.keyFrame=!0;break;default:throw"Error Unknown TagType"}this.bytes=new Uint8Array(a),this.view=new DataView(this.bytes.buffer),this.bytes[0]=t,this.position=this.length,this.keyFrame=e,this.pts=0,this.dts=0,this.writeBytes=function(t,e,i){var n,r=e||0;i=i||t.byteLength,n=r+i,s(this,i),this.bytes.set(t.subarray(r,n),this.position),this.position+=i,this.length=Math.max(this.length,this.position)},this.writeByte=function(t){s(this,1),this.bytes[this.position]=t,this.position++,this.length=Math.max(this.length,this.position)},this.writeShort=function(t){s(this,2),this.view.setUint16(this.position,t),this.position+=2,this.length=Math.max(this.length,this.position)},this.negIndex=function(t){return this.bytes[this.length-t]},this.nalUnitSize=function(){return 0===r?0:this.length-(r+4)},this.startNalUnit=function(){if(r>0)throw new Error("Attempted to create new NAL wihout closing the old one");r=this.length,this.length+=4,this.position=this.length},this.endNalUnit=function(t){var e,i;this.length===r+4?this.length-=4:r>0&&(e=r+4,i=this.length-e,this.position=r,this.view.setUint32(this.position,i),this.position=this.length,t&&t.push(this.bytes.subarray(e,e+i))),r=0},this.writeMetaDataDouble=function(t,e){var i;if(s(this,2+t.length+9),this.view.setUint16(this.position,t.length),this.position+=2,"width"===t)this.bytes.set(o,this.position),this.position+=5;else if("height"===t)this.bytes.set(u,this.position),this.position+=6;else if("videocodecid"===t)this.bytes.set(d,this.position),this.position+=12;else for(i=0;i<t.length;i++)this.bytes[this.position]=t.charCodeAt(i),this.position++;this.position++,this.view.setFloat64(this.position,e),this.position+=8,this.length=Math.max(this.length,this.position),++r},this.writeMetaDataBoolean=function(t,e){var i;for(s(this,2),this.view.setUint16(this.position,t.length),this.position+=2,i=0;i<t.length;i++)s(this,1),this.bytes[this.position]=t.charCodeAt(i),this.position++;s(this,2),this.view.setUint8(this.position,1),this.position++,this.view.setUint8(this.position,e?1:0),this.position++,this.length=Math.max(this.length,this.position),++r},this.finalize=function(){var t,i;switch(this.bytes[0]){case n.VIDEO_TAG:this.bytes[11]=7|(this.keyFrame||e?16:32),this.bytes[12]=e?0:1,t=this.pts-this.dts,this.bytes[13]=(16711680&t)>>>16,this.bytes[14]=(65280&t)>>>8,this.bytes[15]=(255&t)>>>0;break;case n.AUDIO_TAG:this.bytes[11]=175,this.bytes[12]=e?0:1;break;case n.METADATA_TAG:this.position=11,this.view.setUint8(this.position,2),this.position++,this.view.setUint16(this.position,10),this.position+=2,this.bytes.set([111,110,77,101,116,97,68,97,116,97],this.position),this.position+=10,this.bytes[this.position]=8,this.position++,this.view.setUint32(this.position,r),this.position=this.length,this.bytes.set([0,0,9],this.position),this.position+=3,this.length=this.position}return i=this.length-11,this.bytes[1]=(16711680&i)>>>16,this.bytes[2]=(65280&i)>>>8,this.bytes[3]=(255&i)>>>0,this.bytes[4]=(16711680&this.dts)>>>16,this.bytes[5]=(65280&this.dts)>>>8,this.bytes[6]=(255&this.dts)>>>0,this.bytes[7]=(4278190080&this.dts)>>>24,this.bytes[8]=0,this.bytes[9]=0,this.bytes[10]=0,s(this,4),this.view.setUint32(this.length,this.length),this.length+=4,this.position+=4,this.bytes=this.bytes.subarray(0,this.length),this.frameTime=n.frameTime(this.bytes),this}},n.AUDIO_TAG=8,n.VIDEO_TAG=9,n.METADATA_TAG=18,n.isAudioFrame=function(t){return n.AUDIO_TAG===t[0]},n.isVideoFrame=function(t){return n.VIDEO_TAG===t[0]},n.isMetaData=function(t){return n.METADATA_TAG===t[0]},n.isKeyFrame=function(t){return n.isVideoFrame(t)?23===t[11]:n.isAudioFrame(t)?!0:!!n.isMetaData(t);
},n.frameTime=function(t){var e=t[4]<<16;return e|=t[5]<<8,e|=t[6]<<0,e|=t[7]<<24},e.exports=n},{}],35:[function(t,e,i){e.exports={tag:t("./flv-tag"),Transmuxer:t("./transmuxer"),tools:t("../tools/flv-inspector")}},{"../tools/flv-inspector":46,"./flv-tag":34,"./transmuxer":36}],36:[function(t,e,i){"use strict";var n,r,a,s,o,u,d,f=t("../utils/stream.js"),l=t("./flv-tag.js"),c=t("../m2ts/m2ts.js"),h=t("../codecs/adts.js"),p=t("../codecs/h264").H264Stream;o=function(t,e){"number"==typeof e.pts&&(void 0===t.timelineStartInfo.pts?t.timelineStartInfo.pts=e.pts:t.timelineStartInfo.pts=Math.min(t.timelineStartInfo.pts,e.pts)),"number"==typeof e.dts&&(void 0===t.timelineStartInfo.dts?t.timelineStartInfo.dts=e.dts:t.timelineStartInfo.dts=Math.min(t.timelineStartInfo.dts,e.dts))},u=function(t,e){var i=new l(l.METADATA_TAG);return i.dts=e,i.pts=e,i.writeMetaDataDouble("videocodecid",7),i.writeMetaDataDouble("width",t.width),i.writeMetaDataDouble("height",t.height),i},d=function(t,e){var i,n=new l(l.VIDEO_TAG,!0);for(n.dts=e,n.pts=e,n.writeByte(1),n.writeByte(t.profileIdc),n.writeByte(t.profileCompatibility),n.writeByte(t.levelIdc),n.writeByte(255),n.writeByte(225),n.writeShort(t.sps[0].length),n.writeBytes(t.sps[0]),n.writeByte(t.pps.length),i=0;i<t.pps.length;++i)n.writeShort(t.pps[i].length),n.writeBytes(t.pps[i]);return n},a=function(t){var e,i=[];a.prototype.init.call(this),this.push=function(e){o(t,e),t&&void 0===t.channelcount&&(t.audioobjecttype=e.audioobjecttype,t.channelcount=e.channelcount,t.samplerate=e.samplerate,t.samplingfrequencyindex=e.samplingfrequencyindex,t.samplesize=e.samplesize,t.extraData=t.audioobjecttype<<11|t.samplingfrequencyindex<<7|t.channelcount<<3),e.pts=Math.round(e.pts/90),e.dts=Math.round(e.dts/90),i.push(e)},this.flush=function(){var n,r,a,s=[];if(0===i.length)return void this.trigger("done");for(a=-(1/0);i.length;)n=i.shift(),(t.extraData!==e||n.pts-a>=1e3)&&(r=new l(l.METADATA_TAG),r.pts=n.pts,r.dts=n.dts,r.writeMetaDataDouble("audiocodecid",10),r.writeMetaDataBoolean("stereo",2===t.channelcount),r.writeMetaDataDouble("audiosamplerate",t.samplerate),r.writeMetaDataDouble("audiosamplesize",16),s.push(r),e=t.extraData,r=new l(l.AUDIO_TAG,!0),r.pts=n.pts,r.dts=n.dts,r.view.setUint16(r.position,t.extraData),r.position+=2,r.length=Math.max(r.length,r.position),s.push(r),a=n.pts),r=new l(l.AUDIO_TAG),r.pts=n.pts,r.dts=n.dts,r.writeBytes(n.data),s.push(r);e=null,this.trigger("data",{track:t,tags:s}),this.trigger("done")}},a.prototype=new f,r=function(t){var e,i,n=[];r.prototype.init.call(this),this.finishFrame=function(i,n){n&&(e&&t&&t.newMetadata&&(n.keyFrame||0===i.length)&&(i.push(u(e,n.pts)),i.push(d(t,n.pts)),t.newMetadata=!1),n.endNalUnit(),i.push(n))},this.push=function(e){o(t,e),e.pts=Math.round(e.pts/90),e.dts=Math.round(e.dts/90),n.push(e)},this.flush=function(){for(var r,a=[];n.length&&"access_unit_delimiter_rbsp"!==n[0].nalUnitType;)n.shift();if(0===n.length)return void this.trigger("done");for(;n.length;)r=n.shift(),"seq_parameter_set_rbsp"===r.nalUnitType?(t.newMetadata=!0,e=r.config,t.width=e.width,t.height=e.height,t.sps=[r.data],t.profileIdc=e.profileIdc,t.levelIdc=e.levelIdc,t.profileCompatibility=e.profileCompatibility,i.endNalUnit()):"pic_parameter_set_rbsp"===r.nalUnitType?(t.newMetadata=!0,t.pps=[r.data],i.endNalUnit()):"access_unit_delimiter_rbsp"===r.nalUnitType?(i&&this.finishFrame(a,i),i=new l(l.VIDEO_TAG),i.pts=r.pts,i.dts=r.dts):("slice_layer_without_partitioning_rbsp_idr"===r.nalUnitType&&(i.keyFrame=!0),i.endNalUnit()),i.startNalUnit(),i.writeBytes(r.data);i&&this.finishFrame(a,i),this.trigger("data",{track:t,tags:a}),this.trigger("done")}},r.prototype=new f,s=function(t){this.numberOfTracks=0,this.metadataStream=t.metadataStream,this.videoTags=[],this.audioTags=[],this.videoTrack=null,this.audioTrack=null,this.pendingCaptions=[],this.pendingMetadata=[],this.pendingTracks=0,s.prototype.init.call(this),this.push=function(t){return t.text?this.pendingCaptions.push(t):t.frames?this.pendingMetadata.push(t):("video"===t.track.type&&(this.videoTrack=t.track,this.videoTags=t.tags,this.pendingTracks++),void("audio"===t.track.type&&(this.audioTrack=t.track,this.audioTags=t.tags,this.pendingTracks++)))}},s.prototype=new f,s.prototype.flush=function(){var t,e,i,n,r={tags:{},captions:[],metadata:[]};if(!(this.pendingTracks<this.numberOfTracks)){for(this.videoTrack?n=this.videoTrack.timelineStartInfo.pts:this.audioTrack&&(n=this.audioTrack.timelineStartInfo.pts),r.tags.videoTags=this.videoTags,r.tags.audioTags=this.audioTags,i=0;i<this.pendingCaptions.length;i++)e=this.pendingCaptions[i],e.startTime=e.startPts-n,e.startTime/=9e4,e.endTime=e.endPts-n,e.endTime/=9e4,r.captions.push(e);for(i=0;i<this.pendingMetadata.length;i++)t=this.pendingMetadata[i],t.cueTime=t.pts-n,t.cueTime/=9e4,r.metadata.push(t);r.metadata.dispatchType=this.metadataStream.dispatchType,this.videoTrack=null,this.audioTrack=null,this.videoTags=[],this.audioTags=[],this.pendingCaptions.length=0,this.pendingMetadata.length=0,this.pendingTracks=0,this.trigger("data",r),this.trigger("done")}},n=function(t){var e,i,o,u,d,f,g,y,m,b=this;n.prototype.init.call(this),t=t||{},this.metadataStream=new c.MetadataStream,t.metadataStream=this.metadataStream,e=new c.TransportPacketStream,i=new c.TransportParseStream,o=new c.ElementaryStream,u=new h,d=new p,m=new s(t),e.pipe(i).pipe(o),o.pipe(d),o.pipe(u),o.pipe(this.metadataStream).pipe(m),y=new c.CaptionStream,d.pipe(y).pipe(m),o.on("data",function(t){var e,i,n;if("metadata"===t.type){for(e=t.tracks.length;e--;)"video"===t.tracks[e].type?i=t.tracks[e]:"audio"===t.tracks[e].type&&(n=t.tracks[e]);i&&!f&&(m.numberOfTracks++,f=new r(i),d.pipe(f).pipe(m)),n&&!g&&(m.numberOfTracks++,g=new a(n),u.pipe(g).pipe(m))}}),this.push=function(t){e.push(t)},this.flush=function(){e.flush()},m.on("data",function(t){b.trigger("data",t)}),m.on("done",function(){b.trigger("done")}),this.getFlvHeader=function(t,e,i){var n,r,a,s=new Uint8Array(9),o=new DataView(s.buffer);return t=t||0,e=void 0===e?!0:e,i=void 0===i?!0:i,o.setUint8(0,70),o.setUint8(1,76),o.setUint8(2,86),o.setUint8(3,1),o.setUint8(4,(e?4:0)|(i?1:0)),o.setUint32(5,s.byteLength),0>=t?(r=new Uint8Array(s.byteLength+4),r.set(s),r.set([0,0,0,0],s.byteLength),r):(n=new l(l.METADATA_TAG),n.pts=n.dts=0,n.writeMetaDataDouble("duration",t),a=n.finalize().length,r=new Uint8Array(s.byteLength+a),r.set(s),r.set(o.byteLength,a),r)}},n.prototype=new f,e.exports=n},{"../codecs/adts.js":31,"../codecs/h264":32,"../m2ts/m2ts.js":40,"../utils/stream.js":49,"./flv-tag.js":34}],37:[function(t,e,i){"use strict";var n={codecs:t("./codecs"),mp4:t("./mp4"),flv:t("./flv"),mp2t:t("./m2ts")};e.exports=n},{"./codecs":33,"./flv":35,"./m2ts":39,"./mp4":43}],38:[function(t,e,i){"use strict";var n=4,r=128,a=t("../utils/stream"),s=function(t){for(var e=0,i={payloadType:-1,payloadSize:0},a=0,s=0;e<t.byteLength&&t[e]!==r;){for(;255===t[e];)a+=255,e++;for(a+=t[e++];255===t[e];)s+=255,e++;if(s+=t[e++],!i.payload&&a===n){i.payloadType=a,i.payloadSize=s,i.payload=t.subarray(e,e+s);break}e+=s,a=0,s=0}return i},o=function(t){return 181!==t.payload[0]?null:49!==(t.payload[1]<<8|t.payload[2])?null:"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])?null:3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},u=function(t,e){var i,n,r,a,s=[];if(!(64&e[0]))return s;for(n=31&e[0],i=0;n>i;i++)r=3*i,a={type:3&e[r+2],pts:t},4&e[r+2]&&(a.ccData=e[r+3]<<8|e[r+4],s.push(a));return s},d=function(){d.prototype.init.call(this),this.captionPackets_=[],this.field1_=new k,this.field1_.on("data",this.trigger.bind(this,"data")),this.field1_.on("done",this.trigger.bind(this,"done"))};d.prototype=new a,d.prototype.push=function(t){var e,i;"sei_rbsp"===t.nalUnitType&&(e=s(t.escapedRBSP),e.payloadType===n&&(i=o(e),i&&(this.captionPackets_=this.captionPackets_.concat(u(t.pts,i)))))},d.prototype.flush=function(){return this.captionPackets_.length?(this.captionPackets_.sort(function(t,e){return t.pts-e.pts}),this.captionPackets_.forEach(this.field1_.push,this.field1_),this.captionPackets_.length=0,void this.field1_.flush()):void this.field1_.flush()};var f={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608},l=function(t){return null===t?"":(t=f[t]||t,String.fromCharCode(t))},c=0,h=5152,p=5167,g=5157,y=5158,m=5159,b=5165,v=5153,_=5164,w=5166,T=14,S=function(){for(var t=[],e=T+1;e--;)t.push("");return t},k=function(){k.prototype.init.call(this),this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=S(),this.nonDisplayed_=S(),this.lastControlCode_=null,this.push=function(t){if(0===t.type){var e,i,n,r;if(e=32639&t.ccData,e===this.lastControlCode_)return void(this.lastControlCode_=null);switch(4096===(61440&e)?this.lastControlCode_=e:this.lastControlCode_=null,e){case c:break;case h:this.mode_="popOn";break;case p:this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=t.pts;break;case g:this.topRow_=T-1,this.mode_="rollUp";break;case y:this.topRow_=T-2,this.mode_="rollUp";break;case m:this.topRow_=T-3,this.mode_="rollUp";break;case b:this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;break;case v:"popOn"===this.mode_?this.nonDisplayed_[T]=this.nonDisplayed_[T].slice(0,-1):this.displayed_[T]=this.displayed_[T].slice(0,-1);break;case _:this.flushDisplayed(t.pts),this.displayed_=S();break;case w:this.nonDisplayed_=S();break;default:if(n=e>>>8,r=255&e,n>=16&&23>=n&&r>=64&&127>=r&&(16!==n||96>r)&&(n=32,r=null),(17===n||25===n)&&r>=48&&63>=r&&(n=14850474,r=""),16===(240&n))return;this[this.mode_](t.pts,n,r)}}}};k.prototype=new a,k.prototype.flushDisplayed=function(t){var e,i;for(i=0;i<this.displayed_.length;i++)e=this.displayed_[i],e.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:e.trim()})},k.prototype.popOn=function(t,e,i){var n=this.nonDisplayed_[T];n+=l(e),n+=l(i),this.nonDisplayed_[T]=n},k.prototype.rollUp=function(t,e,i){var n=this.displayed_[T];""===n&&(this.flushDisplayed(t),this.startPts_=t),n+=l(e),n+=l(i),this.displayed_[T]=n},k.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.topRow_;T>t;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[T]=""},e.exports={CaptionStream:d,Cea608Stream:k}},{"../utils/stream":49}],39:[function(t,e,i){e.exports=t("./m2ts")},{"./m2ts":40}],40:[function(t,e,i){"use strict";var n,r,a,s=t("../utils/stream.js"),o=t("./caption-stream"),u=t("./stream-types"),s=t("../utils/stream.js"),d=t("./stream-types.js"),f=188,l=71,n=function(){var t=new Uint8Array(f),e=0;n.prototype.init.call(this),this.push=function(i){var n,r=0,a=f;for(e?(n=new Uint8Array(i.byteLength+e),n.set(t.subarray(0,e)),n.set(i,e),e=0):n=i;a<n.byteLength;)n[r]!==l||n[a]!==l?(r++,a++):(this.trigger("data",n.subarray(r,a)),r+=f,a+=f);r<n.byteLength&&(t.set(n.subarray(r),0),e=n.byteLength-r)},this.flush=function(){e===f&&t[0]===l&&(this.trigger("data",t),e=0),this.trigger("done")}};n.prototype=new s,r=function(){var t,e,i,n;r.prototype.init.call(this),n=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,t=function(t,n){var r=0;n.payloadUnitStartIndicator&&(r+=t[r]+1),"pat"===n.type?e(t.subarray(r),n):i(t.subarray(r),n)},e=function(t,e){e.section_number=t[7],e.last_section_number=t[8],n.pmtPid=(31&t[10])<<8|t[11],e.pmtPid=n.pmtPid},i=function(t,e){var i,r,a,s;if(1&t[5]){for(n.programMapTable={},i=(15&t[1])<<8|t[2],r=3+i-4,a=(15&t[10])<<8|t[11],s=12+a;r>s;)n.programMapTable[(31&t[s+1])<<8|t[s+2]]=t[s],s+=((15&t[s+3])<<8|t[s+4])+5;for(e.programMapTable=n.programMapTable;n.packetsWaitingForPmt.length;)n.processPes_.apply(n,n.packetsWaitingForPmt.shift())}},this.push=function(e){var i={},n=4;i.payloadUnitStartIndicator=!!(64&e[1]),i.pid=31&e[1],i.pid<<=8,i.pid|=e[2],(48&e[3])>>>4>1&&(n+=e[n]+1),0===i.pid?(i.type="pat",t(e.subarray(n),i),this.trigger("data",i)):i.pid===this.pmtPid?(i.type="pmt",t(e.subarray(n),i),this.trigger("data",i)):void 0===this.programMapTable?this.packetsWaitingForPmt.push([e,n,i]):this.processPes_(e,n,i)},this.processPes_=function(t,e,i){i.streamType=this.programMapTable[i.pid],i.type="pes",i.data=t.subarray(e),this.trigger("data",i)}},r.prototype=new s,r.STREAM_TYPES={h264:27,adts:15},a=function(){var t,e={data:[],size:0},i={data:[],size:0},n={data:[],size:0},r=function(t,e){var i;e.dataAlignmentIndicator=0!==(4&t[6]),i=t[7],192&i&&(e.pts=(14&t[9])<<27|(255&t[10])<<20|(254&t[11])<<12|(255&t[12])<<5|(254&t[13])>>>3,e.pts*=4,e.pts+=(6&t[13])>>>1,e.dts=e.pts,64&i&&(e.dts=(14&t[14])<<27|(255&t[15])<<20|(254&t[16])<<12|(255&t[17])<<5|(254&t[18])>>>3,e.dts*=4,e.dts+=(6&t[18])>>>1)),e.data=t.subarray(9+t[8])},s=function(e,i){var n,a=new Uint8Array(e.size),s={type:i},o=0;if(e.data.length){for(s.trackId=e.data[0].pid;e.data.length;)n=e.data.shift(),a.set(n.data,o),o+=n.data.byteLength;r(a,s),e.size=0,t.trigger("data",s)}};a.prototype.init.call(this),t=this,this.push=function(r){({pat:function(){},pes:function(){var t,a;switch(r.streamType){case u.H264_STREAM_TYPE:case d.H264_STREAM_TYPE:t=e,a="video";break;case u.ADTS_STREAM_TYPE:t=i,a="audio";break;case u.METADATA_STREAM_TYPE:t=n,a="timed-metadata";break;default:return}r.payloadUnitStartIndicator&&s(t,a),t.data.push(r),t.size+=r.data.byteLength},pmt:function(){var e,i,n={type:"metadata",tracks:[]},a=r.programMapTable;for(e in a)a.hasOwnProperty(e)&&(i={timelineStartInfo:{baseMediaDecodeTime:0}},i.id=+e,a[e]===d.H264_STREAM_TYPE?(i.codec="avc",i.type="video"):a[e]===d.ADTS_STREAM_TYPE&&(i.codec="adts",i.type="audio"),n.tracks.push(i));t.trigger("data",n)}})[r.type]()},this.flush=function(){s(e,"video"),s(i,"audio"),s(n,"timed-metadata"),this.trigger("done")}},a.prototype=new s;var c={PAT_PID:0,MP2T_PACKET_LENGTH:f,TransportPacketStream:n,TransportParseStream:r,ElementaryStream:a,CaptionStream:o.CaptionStream,Cea608Stream:o.Cea608Stream,MetadataStream:t("./metadata-stream")};for(var h in u)u.hasOwnProperty(h)&&(c[h]=u[h]);e.exports=c},{"../utils/stream.js":49,"./caption-stream":38,"./metadata-stream":41,"./stream-types":42,"./stream-types.js":42}],41:[function(t,e,i){"use strict";var n,r=t("../utils/stream"),a=t("./stream-types"),s=function(t,e,i){var n,r="";for(n=e;i>n;n++)r+="%"+("00"+t[n].toString(16)).slice(-2);return r},o=function(t,e,i){return decodeURIComponent(s(t,e,i))},u=function(t,e,i){return unescape(s(t,e,i))},d=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},f={TXXX:function(t){var e;if(3===t.data[0]){for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.value=o(t.data,e+1,t.data.length-1);break}t.data=t.value}},WXXX:function(t){var e;if(3===t.data[0])for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.url=o(t.data,e+1,t.data.length);break}},PRIV:function(t){var e;for(e=0;e<t.data.length;e++)if(0===t.data[e]){t.owner=u(t.data,0,e);break}t.privateData=t.data.subarray(e+1),t.data=t.privateData}};n=function(t){var e,i={debug:!(!t||!t.debug),descriptor:t&&t.descriptor},r=0,s=[],o=0;if(n.prototype.init.call(this),this.dispatchType=a.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(e=0;e<i.descriptor.length;e++)this.dispatchType+=("00"+i.descriptor[e].toString(16)).slice(-2);this.push=function(t){var e,n,a,u,l,c;if("timed-metadata"===t.type){if(t.dataAlignmentIndicator&&(o=0,s.length=0),0===s.length&&(t.data.length<10||t.data[0]!=="I".charCodeAt(0)||t.data[1]!=="D".charCodeAt(0)||t.data[2]!=="3".charCodeAt(0)))return void(i.debug&&console.log("Skipping unrecognized metadata packet"));if(s.push(t),o+=t.data.byteLength,1===s.length&&(r=d(t.data.subarray(6,10)),r+=10),!(r>o)){for(e={data:new Uint8Array(r),frames:[],pts:s[0].pts,dts:s[0].dts},l=0;r>l;)e.data.set(s[0].data.subarray(0,r-l),l),l+=s[0].data.byteLength,o-=s[0].data.byteLength,s.shift();n=10,64&e.data[5]&&(n+=4,n+=d(e.data.subarray(10,14)),r-=d(e.data.subarray(16,20)));do{if(a=d(e.data.subarray(n+4,n+8)),1>a)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(c=String.fromCharCode(e.data[n],e.data[n+1],e.data[n+2],e.data[n+3]),u={id:c,data:e.data.subarray(n+10,n+a+10)},u.key=u.id,f[u.id]&&(f[u.id](u),"com.apple.streaming.transportStreamTimestamp"===u.owner)){var h=u.data,p=(1&h[3])<<30|h[4]<<22|h[5]<<14|h[6]<<6|h[7]>>>2;p*=4,p+=3&h[7],u.timeStamp=p,this.trigger("timestamp",u)}e.frames.push(u),n+=10,n+=a}while(r>n);this.trigger("data",e)}}}},n.prototype=new r,e.exports=n},{"../utils/stream":49,"./stream-types":42}],42:[function(t,e,i){"use strict";e.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],43:[function(t,e,i){e.exports={generator:t("./mp4-generator"),Transmuxer:t("./transmuxer").Transmuxer,AudioSegmentStream:t("./transmuxer").AudioSegmentStream,VideoSegmentStream:t("./transmuxer").VideoSegmentStream,tools:t("../tools/mp4-inspector")}},{"../tools/mp4-inspector":47,"./mp4-generator":44,"./transmuxer":45}],44:[function(t,e,i){"use strict";var n,r,a,s,o,u,d,f,l,c,h,p,g,y,m,b,v,_,w,T,S,k,O,U,A,x,D,P,E,C,L,B,M,I,j,R,N;!function(){var t;U={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]};for(t in U)U.hasOwnProperty(t)&&(U[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);A=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),D=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),x=new Uint8Array([0,0,0,1]),P=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]),E=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]),C={video:P,audio:E},M=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),B=new Uint8Array([0,0,0,0,0,0,0,0]),I=new Uint8Array([0,0,0,0,0,0,0,0]),j=I,R=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),N=I,L=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}(),n=function(t){var e,i,n,r=[],a=0;for(e=1;e<arguments.length;e++)r.push(arguments[e]);for(e=r.length;e--;)a+=r[e].byteLength;for(i=new Uint8Array(a+8),n=new DataView(i.buffer,i.byteOffset,i.byteLength),n.setUint32(0,i.byteLength),i.set(t,4),e=0,a=8;e<r.length;e++)i.set(r[e],a),a+=r[e].byteLength;return i},r=function(){return n(U.dinf,n(U.dref,M))},a=function(t){return n(U.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,t.audioobjecttype<<3|t.samplingfrequencyindex>>>1,t.samplingfrequencyindex<<7|t.channelcount<<3,6,1,2]))},s=function(){return n(U.ftyp,A,x,A,D)},b=function(t){return n(U.hdlr,C[t])},o=function(t){return n(U.mdat,t)},m=function(t){var e=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,t.duration>>>24&255,t.duration>>>16&255,t.duration>>>8&255,255&t.duration,85,196,0,0]);return t.samplerate&&(e[12]=t.samplerate>>>24&255,e[13]=t.samplerate>>>16&255,e[14]=t.samplerate>>>8&255,e[15]=255&t.samplerate),n(U.mdhd,e)},y=function(t){return n(U.mdia,m(t),b(t.type),d(t))},u=function(t){return n(U.mfhd,new Uint8Array([0,0,0,0,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t]))},d=function(t){return n(U.minf,"video"===t.type?n(U.vmhd,L):n(U.smhd,B),r(),_(t))},f=function(t,e){for(var i=[],r=e.length;r--;)i[r]=S(e[r]);return n.apply(null,[U.moof,u(t)].concat(i))},l=function(t){for(var e=t.length,i=[];e--;)i[e]=p(t[e]);return n.apply(null,[U.moov,h(4294967295)].concat(i).concat(c(t)))},c=function(t){for(var e=t.length,i=[];e--;)i[e]=k(t[e]);return n.apply(null,[U.mvex].concat(i))},h=function(t){var e=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n(U.mvhd,e)},v=function(t){var e,i,r=t.samples||[],a=new Uint8Array(4+r.length);for(i=0;i<r.length;i++)e=r[i].flags,a[i+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy;return n(U.sdtp,a)},_=function(t){return n(U.stbl,w(t),n(U.stts,N),n(U.stsc,j),n(U.stsz,R),n(U.stco,I))},function(){var t,e;w=function(i){return n(U.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),"video"===i.type?t(i):e(i))},t=function(t){var e,i=t.sps||[],r=t.pps||[],a=[],s=[];for(e=0;e<i.length;e++)a.push((65280&i[e].byteLength)>>>8),a.push(255&i[e].byteLength),a=a.concat(Array.prototype.slice.call(i[e]));for(e=0;e<r.length;e++)s.push((65280&r[e].byteLength)>>>8),s.push(255&r[e].byteLength),s=s.concat(Array.prototype.slice.call(r[e]));return n(U.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&t.width)>>8,255&t.width,(65280&t.height)>>8,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n(U.avcC,new Uint8Array([1,t.profileIdc,t.profileCompatibility,t.levelIdc,255].concat([i.length]).concat(a).concat([r.length]).concat(s))),n(U.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))},e=function(t){return n(U.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&t.channelcount)>>8,255&t.channelcount,(65280&t.samplesize)>>8,255&t.samplesize,0,0,0,0,(65280&t.samplerate)>>8,255&t.samplerate,0,0]),a(t))}}(),T=function(){return n(U.styp,A,x,A)},g=function(t){var e=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,0,(4278190080&t.duration)>>24,(16711680&t.duration)>>16,(65280&t.duration)>>8,255&t.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&t.width)>>8,255&t.width,0,0,(65280&t.height)>>8,255&t.height,0,0]);return n(U.tkhd,e)},S=function(t){var e,i,r,a,s;return e=n(U.tfhd,new Uint8Array([0,0,0,58,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),i=n(U.tfdt,new Uint8Array([0,0,0,0,t.baseMediaDecodeTime>>>24&255,t.baseMediaDecodeTime>>>16&255,t.baseMediaDecodeTime>>>8&255,255&t.baseMediaDecodeTime])),s=88,"audio"===t.type?(r=O(t,s),n(U.traf,e,i,r)):(a=v(t),r=O(t,a.length+s),n(U.traf,e,i,r,a))},p=function(t){return t.duration=t.duration||4294967295,n(U.trak,g(t),y(t))},k=function(t){var e=new Uint8Array([0,0,0,0,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==t.type&&(e[e.length-1]=0),n(U.trex,e)},function(){var t,e,i;i=function(t,e){var i=0,n=0,r=0,a=0;return t.length&&(void 0!==t[0].duration&&(i=1),void 0!==t[0].size&&(n=2),void 0!==t[0].flags&&(r=4),void 0!==t[0].compositionTimeOffset&&(a=8)),[0,0,i|n|r|a,1,(4278190080&t.length)>>>24,(16711680&t.length)>>>16,(65280&t.length)>>>8,255&t.length,(4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e]},e=function(t,e){var r,a,s,o;for(a=t.samples||[],e+=20+16*a.length,r=i(a,e),o=0;o<a.length;o++)s=a[o],r=r.concat([(4278190080&s.duration)>>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size,s.flags.isLeading<<2|s.flags.dependsOn,s.flags.isDependedOn<<6|s.flags.hasRedundancy<<4|s.flags.paddingValue<<1|s.flags.isNonSyncSample,61440&s.flags.degradationPriority,15&s.flags.degradationPriority,(4278190080&s.compositionTimeOffset)>>>24,(16711680&s.compositionTimeOffset)>>>16,(65280&s.compositionTimeOffset)>>>8,255&s.compositionTimeOffset]);return n(U.trun,new Uint8Array(r))},t=function(t,e){var r,a,s,o;for(a=t.samples||[],e+=20+8*a.length,r=i(a,e),o=0;o<a.length;o++)s=a[o],r=r.concat([(4278190080&s.duration)>>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size]);return n(U.trun,new Uint8Array(r))},O=function(i,n){return"audio"===i.type?t(i,n):e(i,n)}}(),e.exports={ftyp:s,mdat:o,moof:f,moov:l,initSegment:function(t){var e,i=s(),n=l(t);return e=new Uint8Array(i.byteLength+n.byteLength),e.set(i),e.set(n,i.byteLength),e}}},{}],45:[function(t,e,i){"use strict";var n,r,a,s,o,u,d,f,l,c,h=t("../utils/stream.js"),p=t("./mp4-generator.js"),g=t("../m2ts/m2ts.js"),y=t("../codecs/adts.js"),m=t("../codecs/h264").H264Stream,b=t("../aac");o={size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0}},l=function(t,e){var i;if(t.length!==e.length)return!1;for(i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0},c=function(t){var e,i,n=0;for(e=0;e<t.length;e++)i=t[e],n+=i.data.byteLength;return n},r=function(t){var e=[],i=0,n=0;r.prototype.init.call(this),this.push=function(i){u(t,i),t&&(t.audioobjecttype=i.audioobjecttype,t.channelcount=i.channelcount,t.samplerate=i.samplerate,t.samplingfrequencyindex=i.samplingfrequencyindex,t.samplesize=i.samplesize),e.push(i)},this.setEarliestDts=function(e){n=e-t.timelineStartInfo.baseMediaDecodeTime},this.flush=function(){var n,r,a,s;return 0===e.length?void this.trigger("done"):(n=this.trimAdtsFramesByEarliestDts_(e),t.samples=this.generateSampleTable_(n),a=p.mdat(this.concatenateFrameData_(n)),e=[],f(t),r=p.moof(i,[t]),s=new Uint8Array(r.byteLength+a.byteLength),i++,s.set(r),s.set(a,r.byteLength),d(t),this.trigger("data",{track:t,boxes:s}),void this.trigger("done"))},this.trimAdtsFramesByEarliestDts_=function(e){return t.minSegmentDts>=n?e:(t.minSegmentDts=1/0,e.filter(function(e){return e.dts>=n?(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0):!1}))},this.generateSampleTable_=function(t){var e,i,n=[];for(e=0;e<t.length;e++)i=t[e],n.push({size:i.data.byteLength,duration:1024});return n},this.concatenateFrameData_=function(t){var e,i,n=0,r=new Uint8Array(c(t));for(e=0;e<t.length;e++)i=t[e],r.set(i.data,n),n+=i.data.byteLength;return r}},r.prototype=new h,n=function(t){var e,i,r=0,a=[];n.prototype.init.call(this),delete t.minPTS,this.gopCache_=[],this.push=function(n){u(t,n),"seq_parameter_set_rbsp"!==n.nalUnitType||e||(e=n.config,t.width=e.width,t.height=e.height,t.sps=[n.data],t.profileIdc=e.profileIdc,t.levelIdc=e.levelIdc,t.profileCompatibility=e.profileCompatibility),"pic_parameter_set_rbsp"!==n.nalUnitType||i||(i=n.data,t.pps=[n.data]),a.push(n)},this.flush=function(){for(var e,i,n,s,o,d;a.length&&"access_unit_delimiter_rbsp"!==a[0].nalUnitType;)a.shift();return 0===a.length?(this.resetStream_(),void this.trigger("done")):(e=this.groupNalsIntoFrames_(a),n=this.groupFramesIntoGops_(e),n[0][0].keyFrame||(i=this.getGopForFusion_(a[0],t),i?(n.unshift(i),n.byteLength+=i.byteLength,n.nalCount+=i.nalCount,n.pts=i.pts,n.dts=i.dts,n.duration+=i.duration):n=this.extendFirstKeyFrame_(n)),u(t,n),t.samples=this.generateSampleTable_(n),o=p.mdat(this.concatenateNalData_(n)),this.gopCache_.unshift({gop:n.pop(),pps:t.pps,sps:t.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),a=[],f(t),this.trigger("timelineStartInfo",t.timelineStartInfo),s=p.moof(r,[t]),d=new Uint8Array(s.byteLength+o.byteLength),r++,d.set(s),d.set(o,s.byteLength),this.trigger("data",{track:t,boxes:d}),this.resetStream_(),void this.trigger("done"))},this.resetStream_=function(){d(t),e=void 0,i=void 0},this.getGopForFusion_=function(e){var i,n,r,a,s,o=45e3,u=1e4,d=1/0;for(s=0;s<this.gopCache_.length;s++)a=this.gopCache_[s],r=a.gop,t.pps&&l(t.pps[0],a.pps[0])&&t.sps&&l(t.sps[0],a.sps[0])&&(r.dts<t.timelineStartInfo.dts||(i=e.dts-r.dts-r.duration,i>=-u&&o>=i&&(!n||d>i)&&(n=a,d=i)));return n?n.gop:null},this.extendFirstKeyFrame_=function(t){var e;return t[0][0].keyFrame||(e=t.shift(),t.byteLength-=e.byteLength,t.nalCount-=e.nalCount,t[0][0].dts=e.dts,t[0][0].pts=e.pts,t[0][0].duration+=e.duration),t},this.groupNalsIntoFrames_=function(t){var e,i,n=[],r=[];for(n.byteLength=0,e=0;e<t.length;e++)i=t[e],"access_unit_delimiter_rbsp"===i.nalUnitType?(n.length&&(n.duration=i.dts-n.dts,r.push(n)),n=[i],n.byteLength=i.data.byteLength,n.pts=i.pts,n.dts=i.dts):("slice_layer_without_partitioning_rbsp_idr"===i.nalUnitType&&(n.keyFrame=!0),n.duration=i.dts-n.dts,n.byteLength+=i.data.byteLength,n.push(i));return(r.length&&!n.duration||n.duration<=0)&&(n.duration=r[r.length-1].duration),r.push(n),r},this.groupFramesIntoGops_=function(t){var e,i,n=[],r=[];for(n.byteLength=0,n.nalCount=0,n.duration=0,n.pts=t[0].pts,n.dts=t[0].dts,r.byteLength=0,r.nalCount=0,r.duration=0,r.pts=t[0].pts,r.dts=t[0].dts,e=0;e<t.length;e++)i=t[e],i.keyFrame?(n.length&&(r.push(n),r.byteLength+=n.byteLength,r.nalCount+=n.nalCount,r.duration+=n.duration),n=[i],n.nalCount=i.length,n.byteLength=i.byteLength,n.pts=i.pts,n.dts=i.dts,n.duration=i.duration):(n.duration+=i.duration,n.nalCount+=i.length,n.byteLength+=i.byteLength,n.push(i));return r.length&&n.duration<=0&&(n.duration=r[r.length-1].duration),r.byteLength+=n.byteLength,r.nalCount+=n.nalCount,r.duration+=n.duration,r.push(n),r},this.generateSampleTable_=function(t,e){var i,n,r,a,s,u=e||0,d=[];for(i=0;i<t.length;i++)for(a=t[i],n=0;n<a.length;n++)s=a[n],r=Object.create(o),r.dataOffset=u,r.compositionTimeOffset=s.pts-s.dts,r.duration=s.duration,r.size=4*s.length,r.size+=s.byteLength,s.keyFrame&&(r.flags.dependsOn=2),u+=r.size,d.push(r);return d},this.concatenateNalData_=function(t){var e,i,n,r,a,s,o=0,u=t.byteLength,d=t.nalCount,f=u+4*d,l=new Uint8Array(f),c=new DataView(l.buffer);for(e=0;e<t.length;e++)for(r=t[e],i=0;i<r.length;i++)for(a=r[i],n=0;n<a.length;n++)s=a[n],c.setUint32(o,s.data.byteLength),o+=4,l.set(s.data,o),o+=s.data.byteLength;return l}},n.prototype=new h,u=function(t,e){"number"==typeof e.pts&&(void 0===t.timelineStartInfo.pts&&(t.timelineStartInfo.pts=e.pts),void 0===t.minSegmentPts?t.minSegmentPts=e.pts:t.minSegmentPts=Math.min(t.minSegmentPts,e.pts),void 0===t.maxSegmentPts?t.maxSegmentPts=e.pts:t.maxSegmentPts=Math.max(t.maxSegmentPts,e.pts)),"number"==typeof e.dts&&(void 0===t.timelineStartInfo.dts&&(t.timelineStartInfo.dts=e.dts),void 0===t.minSegmentDts?t.minSegmentDts=e.dts:t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),void 0===t.maxSegmentDts?t.maxSegmentDts=e.dts:t.maxSegmentDts=Math.max(t.maxSegmentDts,e.dts))},d=function(t){delete t.minSegmentDts,delete t.maxSegmentDts,delete t.minSegmentPts,delete t.maxSegmentPts},f=function(t){var e,i=9e4,n=t.minSegmentDts-t.timelineStartInfo.dts,r=t.minSegmentPts-t.minSegmentDts;t.baseMediaDecodeTime=t.timelineStartInfo.baseMediaDecodeTime,t.baseMediaDecodeTime+=n,t.baseMediaDecodeTime-=r,t.baseMediaDecodeTime=Math.max(0,t.baseMediaDecodeTime),"audio"===t.type&&(e=t.samplerate/i,t.baseMediaDecodeTime*=e,t.baseMediaDecodeTime=Math.floor(t.baseMediaDecodeTime))},s=function(t){this.numberOfTracks=0,this.metadataStream=t.metadataStream,"undefined"!=typeof t.remux?this.remuxTracks=!!t.remux:this.remuxTracks=!0,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,s.prototype.init.call(this),this.push=function(t){return t.text?this.pendingCaptions.push(t):t.frames?this.pendingMetadata.push(t):(this.pendingTracks.push(t.track),this.pendingBoxes.push(t.boxes),this.pendingBytes+=t.boxes.byteLength,"video"===t.track.type&&(this.videoTrack=t.track),void("audio"===t.track.type&&(this.audioTrack=t.track)))}},s.prototype=new h,s.prototype.flush=function(){var t,e,i,n,r=0,a={captions:[],metadata:[]},s=0;if(!(0===this.pendingTracks.length||this.remuxTracks&&this.pendingTracks.length<this.numberOfTracks)){for(this.videoTrack?s=this.videoTrack.timelineStartInfo.pts:this.audioTrack&&(s=this.audioTrack.timelineStartInfo.pts),1===this.pendingTracks.length?a.type=this.pendingTracks[0].type:a.type="combined",this.emittedTracks+=this.pendingTracks.length,i=p.initSegment(this.pendingTracks),a.data=new Uint8Array(i.byteLength+this.pendingBytes),a.data.set(i),r+=i.byteLength,n=0;n<this.pendingBoxes.length;n++)a.data.set(this.pendingBoxes[n],r),r+=this.pendingBoxes[n].byteLength;for(n=0;n<this.pendingCaptions.length;n++)t=this.pendingCaptions[n],
t.startTime=t.startPts-s,t.startTime/=9e4,t.endTime=t.endPts-s,t.endTime/=9e4,a.captions.push(t);for(n=0;n<this.pendingMetadata.length;n++)e=this.pendingMetadata[n],e.cueTime=e.pts-s,e.cueTime/=9e4,a.metadata.push(e);a.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",a),this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)}},a=function(t){var e,i,o,u,f,l,c,h,p,v,_,w,T,S=this;this.setupAacPipeline=function(){this.metadataStream=new g.MetadataStream,t.metadataStream=this.metadataStream,h=new b,l=new y,w=new s(t),T=h,h.pipe(l),h.pipe(this.metadataStream),this.metadataStream.pipe(w),this.metadataStream.on("timestamp",function(t){h.setTimestamp(t.timestamp)}),this.addAacListener()},this.addAacListener=function(){h.on("data",function(t){if("timed-metadata"===t.type){var e={timelineStartInfo:{baseMediaDecodeTime:0},codec:"adts",type:"audio"};e&&!v&&(w.numberOfTracks++,v=new r(e),l.pipe(v).pipe(w))}})},this.setupTsPipeline=function(){this.metadataStream=new g.MetadataStream,t.metadataStream=this.metadataStream,o=new g.TransportPacketStream,u=new g.TransportParseStream,f=new g.ElementaryStream,l=new y,c=new m,_=new g.CaptionStream,w=new s(t),T=o,o.pipe(u).pipe(f),f.pipe(c),f.pipe(l),f.pipe(this.metadataStream).pipe(w),c.pipe(_).pipe(w),this.addTsListener()},this.addTsListener=function(){f.on("data",function(t){var a;if("metadata"===t.type){for(a=t.tracks.length;a--;)e||"video"!==t.tracks[a].type?i||"audio"!==t.tracks[a].type||(i=t.tracks[a],i.timelineStartInfo.baseMediaDecodeTime=S.baseMediaDecodeTime):(e=t.tracks[a],e.timelineStartInfo.baseMediaDecodeTime=S.baseMediaDecodeTime);e&&!p&&(w.numberOfTracks++,p=new n(e),p.on("timelineStartInfo",function(t){i&&(i.timelineStartInfo=t,v.setEarliestDts(t.dts))}),c.pipe(p).pipe(w)),i&&!v&&(w.numberOfTracks++,v=new r(i),l.pipe(v).pipe(w))}})},a.prototype.init.call(this),t=t||{},this.baseMediaDecodeTime=t.baseMediaDecodeTime||0,void 0===t.aacfile?this.setupTsPipeline():this.setupAacPipeline(),this.setBaseMediaDecodeTime=function(t){this.baseMediaDecodeTime=t,i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,d(i),i.timelineStartInfo.baseMediaDecodeTime=t),e&&(p.gopCache_=[],e.timelineStartInfo.dts=void 0,e.timelineStartInfo.pts=void 0,d(e),e.timelineStartInfo.baseMediaDecodeTime=t)},this.push=function(t){T.push(t)},this.flush=function(){T.flush()},w.on("data",function(t){S.trigger("data",t)}),w.on("done",function(){S.trigger("done")})},a.prototype=new h,e.exports={Transmuxer:a,VideoSegmentStream:n,AudioSegmentStream:r}},{"../aac":30,"../codecs/adts.js":31,"../codecs/h264":32,"../m2ts/m2ts.js":40,"../utils/stream.js":49,"./mp4-generator.js":44}],46:[function(t,e,i){"use strict";var n={8:"audio",9:"video",18:"metadata"},r=function(t){return"0x"+("00"+t.toString(16)).slice(-2).toUpperCase()},a=function(t){for(var e,i=[];t.byteLength>0;){switch(e=0,t.byteLength){default:i.push(r(t[e++]));case 7:i.push(r(t[e++]));case 6:i.push(r(t[e++]));case 5:i.push(r(t[e++]));case 4:i.push(r(t[e++]));case 3:i.push(r(t[e++]));case 2:i.push(r(t[e++]));case 1:i.push(r(t[e++]))}t=t.subarray(e)}return i.join(" ")},s=function(t,e){var i=["AVC Sequence Header","AVC NALU","AVC End-of-Sequence"],n=t[1]&parseInt("01111111",2)<<16|t[2]<<8|t[3];return e=e||{},e.avcPacketType=i[t[0]],e.CompositionTime=t[1]&parseInt("10000000",2)?-n:n,1===t[0]?e.nalUnitTypeRaw=a(t.subarray(4,100)):e.data=a(t.subarray(4)),e},o=function(t,e){var i=["Unknown","Keyframe (for AVC, a seekable frame)","Inter frame (for AVC, a nonseekable frame)","Disposable inter frame (H.263 only)","Generated keyframe (reserved for server use only)","Video info/command frame"],n=t[0]&parseInt("00001111",2);return e=e||{},e.frameType=i[(t[0]&parseInt("11110000",2))>>>4],e.codecID=n,7===n?s(t.subarray(1),e):e},u=function(t,e){var i=["AAC Sequence Header","AAC Raw"];return e=e||{},e.aacPacketType=i[t[0]],e.data=a(t.subarray(1)),e},d=function(t,e){var i=["Linear PCM, platform endian","ADPCM","MP3","Linear PCM, little endian","Nellymoser 16-kHz mono","Nellymoser 8-kHz mono","Nellymoser","G.711 A-law logarithmic PCM","G.711 mu-law logarithmic PCM","reserved","AAC","Speex","MP3 8-Khz","Device-specific sound"],n=["5.5-kHz","11-kHz","22-kHz","44-kHz"],r=(t[0]&parseInt("11110000",2))>>>4;return e=e||{},e.soundFormat=i[r],e.soundRate=n[(t[0]&parseInt("00001100",2))>>>2],e.soundSize=(t[0]&parseInt("00000010",2))>>>1?"16-bit":"8-bit",e.soundType=t[0]&parseInt("00000001",2)?"Stereo":"Mono",10===r?u(t.subarray(1),e):e},f=function(t){return{tagType:n[t[0]],dataSize:t[1]<<16|t[2]<<8|t[3],timestamp:t[7]<<24|t[4]<<16|t[5]<<8|t[6],streamID:t[8]<<16|t[9]<<8|t[10]}},l=function(t){var e=f(t);switch(t[0]){case 8:d(t.subarray(11),e);break;case 9:o(t.subarray(11),e);break;case 18:}return e},c=function(t){var e,i,n=9,r=[];for(n+=4;n<t.byteLength;)e=t[n+1]<<16,e|=t[n+2]<<8,e|=t[n+3],e+=11,i=t.subarray(n,n+e),r.push(l(i)),n+=e+4;return r},h=function(t){return JSON.stringify(t,null,2)};e.exports={inspectTag:l,inspect:c,textify:h}},{}],47:[function(t,e,i){(function(t){"use strict";var i,n,r=function(t){var e="";return e+=String.fromCharCode(t[0]),e+=String.fromCharCode(t[1]),e+=String.fromCharCode(t[2]),e+=String.fromCharCode(t[3])},a=function(t){return new Date(1e3*t-20828448e5)},s=function(t){return{isLeading:(12&t[0])>>>2,dependsOn:3&t[0],isDependedOn:(192&t[1])>>>6,hasRedundancy:(48&t[1])>>>4,paddingValue:(14&t[1])>>>1,isNonSyncSample:1&t[1],degradationPriority:t[2]<<8|t[3]}},o=function(t){var e,i,n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=[];for(e=0;e+4<t.length;e+=i){if(i=n.getUint32(e),e+=4,0>=i)return;switch(31&t[e]){case 1:r.push("slice_layer_without_partitioning_rbsp");break;case 5:r.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:r.push("sei_rbsp");break;case 7:r.push("seq_parameter_set_rbsp");break;case 8:r.push("pic_parameter_set_rbsp");break;case 9:r.push("access_unit_delimiter_rbsp");break;default:r.push(31&t[e])}}return r},u={avc1:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{dataReferenceIndex:e.getUint16(6),width:e.getUint16(24),height:e.getUint16(26),horizresolution:e.getUint16(28)+e.getUint16(30)/16,vertresolution:e.getUint16(32)+e.getUint16(34)/16,frameCount:e.getUint16(40),depth:e.getUint16(74),config:i(t.subarray(78,t.byteLength))}},avcC:function(t){var e,i,n,r,a=new DataView(t.buffer,t.byteOffset,t.byteLength),s={configurationVersion:t[0],avcProfileIndication:t[1],profileCompatibility:t[2],avcLevelIndication:t[3],lengthSizeMinusOne:3&t[4],sps:[],pps:[]},o=31&t[5];for(n=6,r=0;o>r;r++)i=a.getUint16(n),n+=2,s.sps.push(new Uint8Array(t.subarray(n,n+i))),n+=i;for(e=t[n],n++,r=0;e>r;r++)i=a.getUint16(n),n+=2,s.pps.push(new Uint8Array(t.subarray(n,n+i))),n+=i;return s},btrt:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{bufferSizeDB:e.getUint32(0),maxBitrate:e.getUint32(4),avgBitrate:e.getUint32(8)}},esds:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),esId:t[6]<<8|t[7],streamPriority:31&t[8],decoderConfig:{objectProfileIndication:t[11],streamType:t[12]>>>2&63,bufferSize:t[13]<<16|t[14]<<8|t[15],maxBitrate:t[16]<<24|t[17]<<16|t[18]<<8|t[19],avgBitrate:t[20]<<24|t[21]<<16|t[22]<<8|t[23],decoderConfigDescriptor:{tag:t[24],length:t[25],audioObjectType:t[26]>>>3&31,samplingFrequencyIndex:(7&t[26])<<1|t[27]>>>7&1,channelConfiguration:t[27]>>>3&15}}}},ftyp:function(t){for(var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={majorBrand:r(t.subarray(0,4)),minorVersion:e.getUint32(4),compatibleBrands:[]},n=8;n<t.byteLength;)i.compatibleBrands.push(r(t.subarray(n,n+4))),n+=4;return i},dinf:function(t){return{boxes:i(t)}},dref:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),dataReferences:i(t.subarray(8))}},hdlr:function(e){var i=new DataView(e.buffer,e.byteOffset,e.byteLength),n={version:i.getUint8(0),flags:new Uint8Array(e.subarray(1,4)),handlerType:r(e.subarray(8,12)),name:""},a=8;for(a=24;a<e.byteLength;a++){if(0===e[a]){a++;break}n.name+=String.fromCharCode(e[a])}return n.name=decodeURIComponent(t.escape(n.name)),n},mdat:function(t){return{byteLength:t.byteLength,nals:o(t)}},mdhd:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=4,r={version:i.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),language:""};return 1===r.version?(n+=4,r.creationTime=a(i.getUint32(n)),n+=8,r.modificationTime=a(i.getUint32(n)),n+=4,r.timescale=i.getUint32(n),n+=8,r.duration=i.getUint32(n)):(r.creationTime=a(i.getUint32(n)),n+=4,r.modificationTime=a(i.getUint32(n)),n+=4,r.timescale=i.getUint32(n),n+=4,r.duration=i.getUint32(n)),n+=4,e=i.getUint16(n),r.language+=String.fromCharCode((e>>10)+96),r.language+=String.fromCharCode(((960&e)>>5)+96),r.language+=String.fromCharCode((31&e)+96),r},mdia:function(t){return{boxes:i(t)}},mfhd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),sequenceNumber:t[4]<<24|t[5]<<16|t[6]<<8|t[7]}},minf:function(t){return{boxes:i(t)}},mp4a:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),n={dataReferenceIndex:e.getUint16(6),channelcount:e.getUint16(16),samplesize:e.getUint16(18),samplerate:e.getUint16(24)+e.getUint16(26)/65536};return t.byteLength>28&&(n.streamDescriptor=i(t.subarray(28))[0]),n},moof:function(t){return{boxes:i(t)}},moov:function(t){return{boxes:i(t)}},mvex:function(t){return{boxes:i(t)}},mvhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=4,n={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4))};return 1===n.version?(i+=4,n.creationTime=a(e.getUint32(i)),i+=8,n.modificationTime=a(e.getUint32(i)),i+=4,n.timescale=e.getUint32(i),i+=8,n.duration=e.getUint32(i)):(n.creationTime=a(e.getUint32(i)),i+=4,n.modificationTime=a(e.getUint32(i)),i+=4,n.timescale=e.getUint32(i),i+=4,n.duration=e.getUint32(i)),i+=4,n.rate=e.getUint16(i)+e.getUint16(i+2)/16,i+=4,n.volume=e.getUint8(i)+e.getUint8(i+1)/8,i+=2,i+=2,i+=8,n.matrix=new Uint32Array(t.subarray(i,i+36)),i+=36,i+=24,n.nextTrackId=e.getUint32(i),n},pdin:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),rate:e.getUint32(4),initialDelay:e.getUint32(8)}},sdtp:function(t){var e,i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),samples:[]};for(e=4;e<t.byteLength;e++)i.samples.push({dependsOn:(48&t[e])>>4,isDependedOn:(12&t[e])>>2,hasRedundancy:3&t[e]});return i},sidx:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),references:[],referenceId:i.getUint32(4),timescale:i.getUint32(8),earliestPresentationTime:i.getUint32(12),firstOffset:i.getUint32(16)},r=i.getUint16(22);for(e=24;r;e+=12,r--)n.references.push({referenceType:(128&t[e])>>>7,referencedSize:2147483647&i.getUint32(e),subsegmentDuration:i.getUint32(e+4),startsWithSap:!!(128&t[e+8]),sapType:(112&t[e+8])>>>4,sapDeltaTime:268435455&i.getUint32(e+8)});return n},smhd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),balance:t[4]+t[5]/256}},stbl:function(t){return{boxes:i(t)}},stco:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),chunkOffsets:[]},r=i.getUint32(4);for(e=8;r;e+=4,r--)n.chunkOffsets.push(i.getUint32(e));return n},stsc:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=i.getUint32(4),r={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleToChunks:[]};for(e=8;n;e+=12,n--)r.sampleToChunks.push({firstChunk:i.getUint32(e),samplesPerChunk:i.getUint32(e+4),sampleDescriptionIndex:i.getUint32(e+8)});return r},stsd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleDescriptions:i(t.subarray(8))}},stsz:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleSize:i.getUint32(4),entries:[]};for(e=12;e<t.byteLength;e+=4)n.entries.push(i.getUint32(e));return n},stts:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),timeToSamples:[]},r=i.getUint32(4);for(e=8;r;e+=8,r--)n.timeToSamples.push({sampleCount:i.getUint32(e),sampleDelta:i.getUint32(e+4)});return n},styp:function(t){return u.ftyp(t)},tfdt:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),baseMediaDecodeTime:t[4]<<24|t[5]<<16|t[6]<<8|t[7]}},tfhd:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),trackId:i.getUint32(4)},r=1&n.flags[2],a=2&n.flags[2],s=8&n.flags[2],o=16&n.flags[2],u=32&n.flags[2];return e=8,r&&(e+=4,n.baseDataOffset=i.getUint32(12),e+=4),a&&(n.sampleDescriptionIndex=i.getUint32(e),e+=4),s&&(n.defaultSampleDuration=i.getUint32(e),e+=4),o&&(n.defaultSampleSize=i.getUint32(e),e+=4),u&&(n.defaultSampleFlags=i.getUint32(e)),n},tkhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=4,n={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4))};return 1===n.version?(i+=4,n.creationTime=a(e.getUint32(i)),i+=8,n.modificationTime=a(e.getUint32(i)),i+=4,n.trackId=e.getUint32(i),i+=4,i+=8,n.duration=e.getUint32(i)):(n.creationTime=a(e.getUint32(i)),i+=4,n.modificationTime=a(e.getUint32(i)),i+=4,n.trackId=e.getUint32(i),i+=4,i+=4,n.duration=e.getUint32(i)),i+=4,i+=8,n.layer=e.getUint16(i),i+=2,n.alternateGroup=e.getUint16(i),i+=2,n.volume=e.getUint8(i)+e.getUint8(i+1)/8,i+=2,i+=2,n.matrix=new Uint32Array(t.subarray(i,i+36)),i+=36,n.width=e.getUint16(i)+e.getUint16(i+2)/16,i+=4,n.height=e.getUint16(i)+e.getUint16(i+2)/16,n},traf:function(t){return{boxes:i(t)}},trak:function(t){return{boxes:i(t)}},trex:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),trackId:e.getUint32(4),defaultSampleDescriptionIndex:e.getUint32(8),defaultSampleDuration:e.getUint32(12),defaultSampleSize:e.getUint32(16),sampleDependsOn:3&t[20],sampleIsDependedOn:(192&t[21])>>6,sampleHasRedundancy:(48&t[21])>>4,samplePaddingValue:(14&t[21])>>1,sampleIsDifferenceSample:!!(1&t[21]),sampleDegradationPriority:e.getUint16(22)}},trun:function(t){var e,i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),samples:[]},n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=1&i.flags[2],a=4&i.flags[2],o=1&i.flags[1],u=2&i.flags[1],d=4&i.flags[1],f=8&i.flags[1],l=n.getUint32(4),c=8;for(r&&(i.dataOffset=n.getUint32(c),c+=4),a&&l&&(e={flags:s(t.subarray(c,c+4))},c+=4,o&&(e.duration=n.getUint32(c),c+=4),u&&(e.size=n.getUint32(c),c+=4),f&&(e.compositionTimeOffset=n.getUint32(c),c+=4),i.samples.push(e),l--);l--;)e={},o&&(e.duration=n.getUint32(c),c+=4),u&&(e.size=n.getUint32(c),c+=4),d&&(e.flags=s(t.subarray(c,c+4)),c+=4),f&&(e.compositionTimeOffset=n.getUint32(c),c+=4),i.samples.push(e);return i},"url ":function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4))}},vmhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),graphicsmode:e.getUint16(4),opcolor:new Uint16Array([e.getUint16(6),e.getUint16(8),e.getUint16(10)])}}};i=function(t){for(var e,i,n,a,s,o=0,d=[],f=new ArrayBuffer(t.length),l=new Uint8Array(f),c=0;c<t.length;++c)l[c]=t[c];for(e=new DataView(f);o<t.byteLength;)i=e.getUint32(o),n=r(t.subarray(o+4,o+8)),a=i>1?o+i:t.byteLength,s=(u[n]||function(t){return{data:t}})(t.subarray(o+8,a)),s.size=i,s.type=n,d.push(s),o=a;return d},n=function(t,e){var i;return e=e||0,i=new Array(2*e+1).join(" "),t.map(function(t,r){return i+t.type+"\n"+Object.keys(t).filter(function(t){return"type"!==t&&"boxes"!==t}).map(function(e){var n=i+" "+e+": ",r=t[e];if(r instanceof Uint8Array||r instanceof Uint32Array){var a=Array.prototype.slice.call(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)).map(function(t){return" "+("00"+t.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);return a?1===a.length?n+"<"+a.join("").slice(1)+">":n+"<\n"+a.map(function(t){return i+" "+t}).join("\n")+"\n"+i+" >":n+"<>"}return n+JSON.stringify(r,null,2).split("\n").map(function(t,e){return 0===e?t:i+" "+t}).join("\n")}).join("\n")+(t.boxes?"\n"+n(t.boxes,e+1):"")}).join("\n")},e.exports={inspect:i,textify:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],48:[function(t,e,i){"use strict";var n;n=function(t){var e=t.byteLength,i=0,n=0;this.length=function(){return 8*e},this.bitsAvailable=function(){return 8*e+n},this.loadWord=function(){var r=t.byteLength-e,a=new Uint8Array(4),s=Math.min(4,e);if(0===s)throw new Error("no bytes available");a.set(t.subarray(r,r+s)),i=new DataView(a.buffer).getUint32(0),n=8*s,e-=s},this.skipBits=function(t){var r;n>t?(i<<=t,n-=t):(t-=n,r=Math.floor(t/8),t-=8*r,e-=r,this.loadWord(),i<<=t,n-=t)},this.readBits=function(t){var r=Math.min(n,t),a=i>>>32-r;return n-=r,n>0?i<<=r:e>0&&this.loadWord(),r=t-r,r>0?a<<r|this.readBits(r):a},this.skipLeadingZeros=function(){var t;for(t=0;n>t;++t)if(0!==(i&2147483648>>>t))return i<<=t,n-=t,t;return this.loadWord(),t+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var t=this.skipLeadingZeros();return this.readBits(t+1)-1},this.readExpGolomb=function(){var t=this.readUnsignedExpGolomb();return 1&t?1+t>>>1:-1*(t>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()},e.exports=n},{}],49:[function(t,e,i){"use strict";var n=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e].push(i)},this.off=function(e,i){var n;return t[e]?(n=t[e].indexOf(i),t[e].splice(n,1),n>-1):!1},this.trigger=function(e){var i,n,r,a;if(i=t[e])if(2===arguments.length)for(r=i.length,n=0;r>n;++n)i[n].call(this,arguments[1]);else{for(a=[],n=arguments.length,n=1;n<arguments.length;++n)a.push(arguments[n]);for(r=i.length,n=0;r>n;++n)i[n].apply(this,a)}},this.dispose=function(){t={}}}};n.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(){t.flush()}),t},n.prototype.push=function(t){this.trigger("data",t)},n.prototype.flush=function(){this.trigger("done")},e.exports=n},{}],50:[function(t,e,i){var n=arguments[3],r=arguments[4],a=arguments[5],s=JSON.stringify;e.exports=function(t){for(var e,i=Object.keys(a),o=0,u=i.length;u>o;o++){var d=i[o];if(a[d].exports===t){e=d;break}}if(!e){e=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var f={},o=0,u=i.length;u>o;o++){var d=i[o];f[d]=d}r[e]=[Function(["require","module","exports"],"("+t+")(self)"),f]}var l=Math.floor(Math.pow(16,8)*Math.random()).toString(16),c={};c[e]=e,r[l]=[Function(["require"],"require("+s(e)+")(self)"),c];var h="("+n+")({"+Object.keys(r).map(function(t){return s(t)+":["+r[t][0]+","+s(r[t][1])+"]"}).join(",")+"},{},["+s(l)+"])",p=window.URL||window.webkitURL||window.mozURL||window.msURL;return new Worker(p.createObjectURL(new Blob([h],{type:"text/javascript"})))}},{}],51:[function(t,e,i){(function(n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function(t,e,i){for(var n=!0;n;){var r=t,a=e,s=i;n=!1,null===r&&(r=Function.prototype);var o=Object.getOwnPropertyDescriptor(r,a);if(void 0!==o){if("value"in o)return o.value;var u=o.get;if(void 0===u)return;return u.call(s)}var d=Object.getPrototypeOf(r);if(null===d)return;t=d,e=a,i=s,n=!0,o=d=void 0}},d=t("./playlist-loader"),f=r(d),l=t("./playlist"),c=r(l),h=t("./xhr"),p=r(h),g=t("./decrypter"),y=t("./bin-utils"),m=r(y),b=t("videojs-contrib-media-sources"),v=t("./m3u8"),_=r(v),w="undefined"!=typeof window?window.videojs:"undefined"!=typeof n?n.videojs:null,T=r(w),S=t("./resolve-url"),k=r(S),O={PlaylistLoader:f["default"],Playlist:c["default"],Decrypter:g.Decrypter,AsyncStream:g.AsyncStream,decrypt:g.decrypt,utils:m["default"],xhr:p["default"]};O.GOAL_BUFFER_LENGTH=30,O.canPlaySource=function(){return T["default"].log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")},O.findSoleUncommonTimeRangesEnd_=function(t,e){var i=void 0,n=void 0,r=void 0,a=[],s=[],o=function(t){return t[0]<=r&&t[1]>=r};if(t)for(i=0;i<t.length;i++)n=t.start(i),r=t.end(i),s.push([n,r]);if(e)for(i=0;i<e.length;i++)n=e.start(i),r=e.end(i),s.some(o)||a.push(r);return 1!==a.length?null:a[0]},O.supportsNativeHls=function(){var t=document.createElement("video"),e=void 0,i=void 0;return T["default"].getComponent("Html5").isSupported()?(e=t.canPlayType("application/x-mpegURL"),i=t.canPlayType("application/vnd.apple.mpegURL"),/probably|maybe/.test(e)||/probably|maybe/.test(i)):!1}(),O.isSupported=function(){return T["default"].log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")},O.comparePlaylistBandwidth=function(t,e){var i=void 0,n=void 0;return t.attributes&&t.attributes.BANDWIDTH&&(i=t.attributes.BANDWIDTH),i=i||window.Number.MAX_VALUE,e.attributes&&e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n=n||window.Number.MAX_VALUE,i-n},O.comparePlaylistResolution=function(t,e){var i=void 0,n=void 0;return t.attributes&&t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(i=t.attributes.RESOLUTION.width),i=i||window.Number.MAX_VALUE,e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n=n||window.Number.MAX_VALUE,i===n&&t.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?t.attributes.BANDWIDTH-e.attributes.BANDWIDTH:i-n};var U=1.2,A=3e5,x=1/30,D=T["default"].getComponent("Component"),P=500,E=function(t){return t.retries&&t.retries>=2},C=function(t,e){var i=void 0;return t?(i=getComputedStyle(t),i?i[e]:""):""},L=function(t,e,i){if(t){var n=t.segments[e],r=t.segments[e-1];i&&n&&(n.end=i,r?r.end&&(n.duration=n.end-r.end):n.duration=n.end)}},B=function(t,e,i,n){if(!t)return!1;var r=t.segments,a=i===r.length-1,s=n.length&&r[r.length-1].end<=n.end(0);return t.endList&&"open"===e.readyState&&(a||s)},M=function(t){var e={codecCount:0,videoCodec:null,audioProfile:null};return e.codecCount=t.split(",").length,e.codecCount=e.codecCount||2,e.videoCodec=/(^|\s|,)+(avc1)[^ ,]*/i.exec(t),e.videoCodec=e.videoCodec&&e.videoCodec[2],e.audioProfile=/(^|\s|,)+mp4a.\d+\.(\d+)/i.exec(t),e.audioProfile=e.audioProfile&&e.audioProfile[2],e},I=function(t){return function(e){var i=void 0,n=[],r=this.tech_,a=r.buffered();if("undefined"==typeof e&&(e=r.currentTime()),!this.mediaSource||!this.mediaSource.mediaSource_||!this.mediaSource.mediaSource_.sourceBuffers.length)return T["default"].createTimeRanges([]);if(a&&a.length)for(i=0;i<a.length;i++)t(a.start(i),a.end(i),e)&&n.push([a.start(i),a.end(i)]);return T["default"].createTimeRanges(n)}},j=function(t){function e(t,i){var n=this;a(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,t);var r=void 0;t.options_&&t.options_.playerId&&(r=(0,T["default"])(t.options_.playerId),r.hls||Object.defineProperty(r,"hls",{get:function(){return T["default"].log.warn("player.hls is deprecated. Use player.tech.hls instead."),n}})),this.tech_=t,this.source_=i.source,this.mode_=i.mode,this.pendingSegment_=null,this.bandwidth=i.bandwidth||4194304,this.bytesReceived=0,this.loadingState_="none","none"!==this.tech_.preload()&&(this.loadingState_="meta"),this.startCheckingBuffer_(),this.on(this.tech_,"seeking",function(){this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.stopCheckingBuffer_()}),this.on(this.tech_,"play",this.play)}return s(e,t),o(e,[{key:"src",value:function(t){var e=this,i=void 0;t&&(this.mediaSource=new T["default"].MediaSource({mode:this.mode_}),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen.bind(this)),this.options_={},"undefined"!=typeof this.source_.withCredentials?this.options_.withCredentials=this.source_.withCredentials:T["default"].options.hls&&(this.options_.withCredentials=T["default"].options.hls.withCredentials),this.playlists=new O.PlaylistLoader(this.source_.src,this.options_.withCredentials),this.tech_.one("canplay",this.setupFirstPlay.bind(this)),this.playlists.on("loadedmetadata",function(){i=e.playlists.media(),i.endList&&"metadata"!==e.tech_.preload()&&"none"!==e.tech_.preload()&&(e.loadingState_="segments"),e.setupSourceBuffer_(),e.setupFirstPlay(),e.fillBuffer(),e.tech_.trigger("loadedmetadata")}),this.playlists.on("error",function(){e.blacklistCurrentPlaylist_(e.playlists.error)}),this.playlists.on("loadedplaylist",function(){var t=e.playlists.media(),n=void 0;return t?(e.updateDuration(e.playlists.media()),n=e.seekable(),e.duration()===1/0&&0!==n.length&&e.mediaSource.addSeekableRange_(n.start(0),n.end(0)),void(i=t)):void e.playlists.media(e.selectPlaylist())}),this.playlists.on("mediachange",function(){e.tech_.trigger({type:"mediachange",bubbles:!0})}),this.tech_.el()&&this.tech_.src(T["default"].URL.createObjectURL(this.mediaSource)))}},{key:"handleSourceOpen",value:function(){this.sourceBuffer||this.setupSourceBuffer_(),this.tech_.autoplay()&&this.play()}},{key:"excludeIncompatibleVariants_",value:function(t){var e=this.playlists.master,i=2,n=null,r=null,a=void 0;t.attributes&&t.attributes.CODECS&&(a=M(t.attributes.CODECS),n=a.videoCodec,r=a.audioProfile,i=a.codecCount),e.playlists.forEach(function(t){var e={codecCount:2,videoCodec:null,audioProfile:null};t.attributes&&t.attributes.CODECS&&(e=M(t.attributes.CODECS)),e.codecCount!==i&&(t.excludeUntil=1/0),e.videoCodec!==n&&(t.excludeUntil=1/0),("5"===e.audioProfile&&"5"!==r||"5"===r&&"5"!==e.audioProfile)&&(t.excludeUntil=1/0)})}},{key:"setupSourceBuffer_",value:function(){var t=this.playlists.media(),e=void 0;t&&"open"===this.mediaSource.readyState&&(e="video/mp2t",t.attributes&&t.attributes.CODECS&&(e+='; codecs="'+t.attributes.CODECS+'"'),this.sourceBuffer=this.mediaSource.addSourceBuffer(e),this.excludeIncompatibleVariants_(t),this.sourceBuffer.addEventListener("updateend",this.updateEndHandler_.bind(this)))}},{key:"setupFirstPlay",value:function(){var t=void 0,e=this.playlists.media();this.duration()===1/0&&0===this.tech_.played().length&&!this.tech_.paused()&&this.sourceBuffer&&e&&this.tech_.readyState()>=1&&(this.playlists.trigger("firstplay"),t=this.seekable(),t.length&&this.tech_.setCurrentTime(t.end(0)))}},{key:"play",value:function(){return this.loadingState_="segments",this.tech_.ended()&&this.tech_.setCurrentTime(0),0===this.tech_.played().length?this.setupFirstPlay():void(this.duration()===1/0&&this.tech_.currentTime()<this.seekable().start(0)&&this.tech_.setCurrentTime(this.seekable().start(0)))}},{key:"setCurrentTime",value:function(t){var e=this.findBufferedRange_();return this.playlists&&this.playlists.media()&&this.playlists.media().segments?e&&e.length?t:this.pendingSegment_&&this.pendingSegment_.buffered?t:(this.lastSegmentLoaded_=null,this.cancelSegmentXhr(),this.keyXhr_&&(this.keyXhr_.aborted=!0,this.cancelKeyXhr()),void this.fillBuffer(this.playlists.getMediaIndexForTime_(t))):0}},{key:"duration",value:function(){var t=this.playlists;return t?this.mediaSource?this.mediaSource.duration:O.Playlist.duration(t.media()):0}},{key:"seekable",value:function i(){var t=void 0,i=void 0;return this.playlists&&(t=this.playlists.media())?(i=O.Playlist.seekable(t),0===i.length?i:0===i.start(0)?T["default"].createTimeRanges([[this.playlists.expired_,this.playlists.expired_+i.end(0)]]):i):T["default"].createTimeRanges()}},{key:"updateDuration",value:function(t){var e=this,i=this.mediaSource.duration,n=O.Playlist.duration(t),r=this.tech_.buffered(),a=function s(){e.mediaSource.duration=n,e.tech_.trigger("durationchange"),e.mediaSource.removeEventListener("sourceopen",s)};r.length>0&&(n=Math.max(n,r.end(r.length-1))),i!==n&&("open"!==this.mediaSource.readyState?this.mediaSource.addEventListener("sourceopen",a):this.sourceBuffer&&this.sourceBuffer.updating||(this.mediaSource.duration=n,this.tech_.trigger("durationchange")))}},{key:"resetSrc_",value:function(){this.cancelSegmentXhr(),this.cancelKeyXhr(),this.sourceBuffer&&"open"===this.mediaSource.readyState&&this.sourceBuffer.abort()}},{key:"cancelKeyXhr",value:function(){this.keyXhr_&&(this.keyXhr_.onreadystatechange=null,this.keyXhr_.abort(),this.keyXhr_=null)}},{key:"cancelSegmentXhr",value:function(){this.segmentXhr_&&(this.segmentXhr_.onreadystatechange=null,this.segmentXhr_.abort(),this.segmentXhr_=null),this.pendingSegment_=null}},{key:"dispose",value:function(){this.stopCheckingBuffer_(),this.playlists&&this.playlists.dispose(),this.resetSrc_(),u(Object.getPrototypeOf(e.prototype),"dispose",this).call(this)}},{key:"selectPlaylist",value:function(){var t=void 0,e=this.playlists.master.playlists.slice(),i=[],n=+new Date,r=void 0,a=void 0,s=void 0,o=void 0,u=void 0,d=void 0,f=void 0,l=void 0;for(e.sort(O.comparePlaylistBandwidth),e=e.filter(function(t){return"undefined"!=typeof t.excludeUntil?n>=t.excludeUntil:!0}),r=e.length;r--;)a=e[r],a.attributes&&a.attributes.BANDWIDTH&&(t=a.attributes.BANDWIDTH*U,t<this.bandwidth&&(i.push(a),s||(s=a)));for(r=i.length,i.sort(O.comparePlaylistResolution),a=null,f=parseInt(C(this.tech_.el(),"width"),10),l=parseInt(C(this.tech_.el(),"height"),10);r--;)if(a=i[r],a.attributes&&a.attributes.RESOLUTION&&a.attributes.RESOLUTION.width&&a.attributes.RESOLUTION.height){var c=a.attributes.RESOLUTION;if(c.width===f&&c.height===l){o=null,d=a;break}if(c.width<f&&c.height<l)break;(!o||c.width<u.width&&c.height<u.height)&&(o=a,u=o.attributes.RESOLUTION)}return o||d||s||e[0]}},{key:"checkBuffer_",value:function(){this.checkBufferTimeout_&&(window.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null),this.fillBuffer(),this.drainBuffer(),this.checkBufferTimeout_=window.setTimeout(this.checkBuffer_.bind(this),P)}},{key:"startCheckingBuffer_",value:function(){this.checkBuffer_()}},{key:"stopCheckingBuffer_",value:function(){this.checkBufferTimeout_&&(window.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"fillBuffer",value:function(t){var e=this.tech_,i=e.currentTime(),n=0!==this.tech_.buffered().length,r=this.findBufferedRange_(),a=!(r&&r.length),s=0,o=0,u=void 0,d=void 0,f=void 0;if("segments"===this.loadingState_&&e.currentSrc()&&this.playlists&&!this.segmentXhr_&&!this.pendingSegment_&&"HAVE_NOTHING"!==this.playlists.state&&this.playlists.media()&&this.playlists.media().segments&&"SWITCHING_MEDIA"!==this.playlists.state){if("undefined"==typeof t)if(r&&r.length){if(s=r.end(0),t=this.playlists.getMediaIndexForTime_(s),o=Math.max(0,s-i),o>=O.GOAL_BUFFER_LENGTH)return}else t=this.playlists.getMediaIndexForTime_(this.tech_.currentTime());if(u=this.playlists.media().segments[t]){if(this.lastSegmentLoaded_&&this.playlistUriToUrl(this.lastSegmentLoaded_.uri)===this.playlistUriToUrl(u.uri)&&this.lastSegmentLoaded_.byterange===u.byterange)return this.fillBuffer(t+1);d={uri:this.playlistUriToUrl(u.uri),mediaIndex:t,mediaSequence:this.playlists.media().mediaSequence,playlist:this.playlists.media(),currentBufferedEnd:s,bytes:null,encryptedBytes:null,decrypter:null,buffered:null,timestampOffset:null},t>0&&(f=O.Playlist.duration(d.playlist,d.playlist.mediaSequence+t)+this.playlists.expired_),
this.tech_.seeking()&&a?d.playlist.discontinuityStarts.length&&(d.timestampOffset=f):u.discontinuity&&r.length?d.timestampOffset=r.end(0):!n&&this.tech_.currentTime()>.05&&(d.timestampOffset=f),this.loadSegment(d)}}}},{key:"playlistUriToUrl",value:function(t){var e=void 0;return e=this.playlists.media().uri===this.source_.src?(0,k["default"])(this.source_.src,t):(0,k["default"])((0,k["default"])(this.source_.src,this.playlists.media().uri||""),t)}},{key:"byterangeStr_",value:function(t){var e=void 0,i=void 0;return i=t.offset+t.length-1,e=t.offset,"bytes="+e+"-"+i}},{key:"segmentXhrHeaders_",value:function(t){var e={};return"byterange"in t&&(e.Range=this.byterangeStr_(t.byterange)),e}},{key:"setBandwidth",value:function(t){this.segmentXhrTime=t.roundTripTime,this.bandwidth=t.bandwidth,this.bytesReceived+=t.bytesReceived||0,this.tech_.trigger("bandwidthupdate")}},{key:"blacklistCurrentPlaylist_",value:function(t){var e=void 0,i=void 0;return(e=t.playlist||this.playlists.media())?(e.excludeUntil=Date.now()+A,(i=this.selectPlaylist())?(T["default"].log.warn("Problem encountered with the current HLS playlist. Switching to another playlist."),this.playlists.media(i)):(T["default"].log.warn("Problem encountered with the current HLS playlist. No suitable alternatives found."),this.error=t,this.mediaSource.endOfStream("network"))):(this.error=t,this.mediaSource.endOfStream("network"))}},{key:"loadSegment",value:function(t){var e=this,i=t.playlist.segments[t.mediaIndex],n=0,r=this.seekable(),a=this.tech_.currentTime();this.sourceBuffer&&!this.sourceBuffer.updating&&(n=r.length&&r.start(0)>0&&r.start(0)<a?r.start(0):a-60,n>0&&this.sourceBuffer.remove(0,n)),i.key&&this.fetchKey_(i),this.segmentXhr_=O.xhr({uri:t.uri,responseType:"arraybuffer",withCredentials:this.source_.withCredentials,timeout:1.5*i.duration*1e3,headers:this.segmentXhrHeaders_(i)},function(n,r){return e.segmentXhr_&&r===e.segmentXhr_?(e.segmentXhr_=null,r.timedout?(e.bandwidth=1,e.playlists.media(e.selectPlaylist())):!r.aborted&&n?e.blacklistCurrentPlaylist_({status:r.status,message:"HLS segment request error at URL: "+t.uri,code:r.status>=500?4:2}):void(r.response&&(e.lastSegmentLoaded_=i,e.setBandwidth(r),i.key?t.encryptedBytes=new Uint8Array(r.response):t.bytes=new Uint8Array(r.response),e.pendingSegment_=t,e.tech_.trigger("progress"),e.drainBuffer(),e.playlists.media(e.selectPlaylist())))):void 0})}},{key:"drainBuffer",value:function(){var t=void 0,e=void 0,i=void 0,n=void 0,r=void 0,a=void 0,s=void 0;if(this.pendingSegment_&&this.sourceBuffer&&!this.pendingSegment_.buffered&&!this.sourceBuffer.updating){if(t=this.pendingSegment_,e=t.mediaIndex,i=t.playlist,n=t.bytes,r=i.segments[e],r.key&&!n){if(E(r.key))return this.blacklistCurrentPlaylist_({message:"HLS segment key request error.",code:4});if(!r.key.bytes)return;if(t.decrypter)return;return s=r.key.iv||new Uint32Array([0,0,0,e+i.mediaSequence]),a=new O.Decrypter(t.encryptedBytes,r.key.bytes,s,function(e,i){e&&T["default"].log.warn(e),t.bytes=i}),void(t.decrypter=a)}this.pendingSegment_.buffered=this.tech_.buffered(),null!==t.timestampOffset&&(this.sourceBuffer.timestampOffset=t.timestampOffset),this.sourceBuffer.appendBuffer(n)}}},{key:"updateEndHandler_",value:function(){var t=this.pendingSegment_,e=void 0,i=void 0,n=void 0,r=void 0,a=void 0,s=void 0;if(!t)return void(this.pendingSegment_=null);if(t.buffered){if(this.pendingSegment_=null,e=t.playlist,i=t.mediaIndex+(t.mediaSequence-e.mediaSequence),n=this.findBufferedRange_(),s=B(e,this.mediaSource,i,n),t.playlist.uri!==this.playlists.media().uri)return s?this.mediaSource.endOfStream():this.fillBuffer();if(r=this.seekable(),this.tech_.seeking()&&0===n.length&&r.length&&this.tech_.currentTime()<r.start(0)){var o=this.findNextBufferedRange_();o.length&&(T["default"].log("tried seeking to",this.tech_.currentTime(),"but that was too early, retrying at",o.start(0)),this.tech_.setCurrentTime(o.start(0)+x))}return a=O.findSoleUncommonTimeRangesEnd_(t.buffered,this.tech_.buffered()),L(e,i,a),s?this.mediaSource.endOfStream():null!==a||t.buffered.length!==this.tech_.buffered().length?(this.updateDuration(e),void this.fillBuffer()):void this.fillBuffer(i+1)}}},{key:"fetchKey_",value:function(t){var e=this,i=void 0,n=void 0,r=void 0;return!this.keyXhr_&&(n=this.options_,r=function(i){return function(n,r){var a=void 0;return e.keyXhr_=null,n||!r.response||16!==r.response.byteLength?(i.retries=i.retries||0,i.retries++,void(r.aborted||e.fetchKey_(t))):(a=new DataView(r.response),i.bytes=new Uint32Array([a.getUint32(0),a.getUint32(4),a.getUint32(8),a.getUint32(12)]),void e.checkBuffer_())}},i=t.key)?i.bytes||E(i)?void 0:void(this.keyXhr_=O.xhr({uri:this.playlistUriToUrl(i.uri),responseType:"arraybuffer",withCredentials:n.withCredentials},r(i))):void 0}}]),e}(D);i["default"]=j,j.prototype.findBufferedRange_=I(function(t,e,i){return i>=t-x&&e+x>=i}),j.prototype.findNextBufferedRange_=I(function(t,e,i){return t-x>=i});var R=function N(t){return{canHandleSource:function(t){return N.canPlayType(t.type)},handleSource:function(e,i){return"flash"===t&&i.setTimeout(function(){i.trigger("loadstart")},1),i.hls=new j(i,{source:e,mode:t}),i.hls.src(e.src),i.hls},canPlayType:function(t){return N.canPlayType(t)}}};R.canPlayType=function(t){var e=/^application\/(?:x-|vnd\.apple\.)mpegurl/i;return O.supportsNativeHls?!1:e.test(t)},"undefined"!=typeof T["default"].MediaSource&&"undefined"!=typeof T["default"].URL||(T["default"].MediaSource=b.MediaSource,T["default"].URL=b.URL),b.MediaSource.supportsNativeMediaSources()&&T["default"].getComponent("Html5").registerSourceHandler(R("html5")),window.Uint8Array&&T["default"].getComponent("Flash").registerSourceHandler(R("flash")),T["default"].HlsHandler=j,T["default"].HlsSourceHandler=R,T["default"].Hls=O,T["default"].m3u8=_["default"],i["default"]={Hls:O,HlsHandler:j,HlsSourceHandler:R},e.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./bin-utils":1,"./decrypter":5,"./m3u8":6,"./playlist":11,"./playlist-loader":10,"./resolve-url":12,"./xhr":14,"videojs-contrib-media-sources":28}]},{},[51])(51)});