Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-07-17 07:50:16 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-07-17 07:50:16 +0300
commit4b00567df1534ae18d7ffc63c0d48319164901d7 (patch)
tree06a4cdf71b6c3478c00fa227c1a55dd870a98c70 /webtorrent.min.js
parentdd370795f29478728cef97c7d1830e0634cb7038 (diff)
build
Diffstat (limited to 'webtorrent.min.js')
-rw-r--r--webtorrent.min.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index d54a82c..5415fcb 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -10,4 +10,4 @@ inherits:225,"readable-stream/duplex.js":200,"readable-stream/passthrough.js":20
"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a","m4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},{}],228:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],229:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{dup:39,wrappy:228}],230:[function(e,t,r){var i=e("once");var n=e("end-of-stream");var a=e("fs");var s=function(){};var o=function(e){return typeof e==="function"};var f=function(e){return(e instanceof(a.ReadStream||s)||e instanceof(a.WriteStream||s))&&o(e.close)};var l=function(e){return e.setHeader&&o(e.abort)};var u=function(e,t,r,a){a=i(a);var s=false;e.on("close",function(){s=true});n(e,{readable:t,writable:r},function(e){if(e)return a(e);s=true;a()});var u=false;return function(t){if(s)return;if(u)return;u=true;if(f(e))return e.close();if(l(e))return e.abort();if(o(e.destroy))return e.destroy();a(t||new Error("stream was destroyed"))}};var c=function(e){e()};var p=function(e,t){return e.pipe(t)};var d=function(){var e=Array.prototype.slice.call(arguments);var t=o(e[e.length-1]||s)&&e.pop()||s;if(Array.isArray(e[0]))e=e[0];if(e.length<2)throw new Error("pump requires two streams per minimum");var r;var i=e.map(function(n,a){var s=a<e.length-1;var o=a>0;return u(n,s,o,function(e){if(!r)r=e;if(e)i.forEach(c);if(s)return;i.forEach(c);t(r)})});return e.reduce(p)};t.exports=d},{"end-of-stream":223,fs:167,once:229}],231:[function(e,t,r){t.exports=function(e,t){var r=true;var i=t.indexOf("=");if(-1==i)return-2;var n=t.slice(i+1).split(",").map(function(t){var t=t.split("-"),i=parseInt(t[0],10),n=parseInt(t[1],10);if(isNaN(i)){i=e-n;n=e-1}else if(isNaN(n)){n=e-1}if(n>e-1)n=e-1;if(isNaN(i)||isNaN(n)||i>n||i<0)r=false;return{start:i,end:n}});n.type=t.slice(0,i);return r?n:-1}},{}],232:[function(e,t,r){arguments[4][78][0].apply(r,arguments)},{dup:78,rusha:233}],233:[function(e,t,r){arguments[4][79][0].apply(r,arguments)},{dup:79}],234:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],235:[function(e,t,r){arguments[4][83][0].apply(r,arguments)},{dup:83}],236:[function(e,t,r){var i=function(e,t,r){this._byteOffset=t||0;if(e instanceof ArrayBuffer){this.buffer=e}else if(typeof e=="object"){this.dataView=e;if(t){this._byteOffset+=t}}else{this.buffer=new ArrayBuffer(e||0)}this.position=0;this.endianness=r==null?i.LITTLE_ENDIAN:r};t.exports=i;i.prototype={};i.prototype.save=function(e){var t=new Blob([this.buffer]);var r=window.webkitURL||window.URL;if(r&&r.createObjectURL){var i=r.createObjectURL(t);var n=document.createElement("a");n.setAttribute("href",i);n.setAttribute("download",e);n.click();r.revokeObjectURL(i)}else{throw"DataStream.save: Can't create object URL."}};i.BIG_ENDIAN=false;i.LITTLE_ENDIAN=true;i.prototype._dynamicSize=true;Object.defineProperty(i.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){if(!e){this._trimAlloc()}this._dynamicSize=e}});i.prototype._byteLength=0;Object.defineProperty(i.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}});Object.defineProperty(i.prototype,"buffer",{get:function(){this._trimAlloc();return this._buffer},set:function(e){this._buffer=e;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._buffer.byteLength}});Object.defineProperty(i.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._buffer.byteLength}});Object.defineProperty(i.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset;this._buffer=e.buffer;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._byteOffset+e.byteLength}});i.prototype._realloc=function(e){if(!this._dynamicSize){return}var t=this._byteOffset+this.position+e;var r=this._buffer.byteLength;if(t<=r){if(t>this._byteLength){this._byteLength=t}return}if(r<1){r=1}while(t>r){r*=2}var i=new ArrayBuffer(r);var n=new Uint8Array(this._buffer);var a=new Uint8Array(i,0,n.length);a.set(n);this.buffer=i;this._byteLength=t};i.prototype._trimAlloc=function(){if(this._byteLength==this._buffer.byteLength){return}var e=new ArrayBuffer(this._byteLength);var t=new Uint8Array(e);var r=new Uint8Array(this._buffer,0,t.length);t.set(r);this.buffer=e};i.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e);var r=new Uint8Array(t);var i=new Uint8Array(this._buffer,e,r.length);r.set(i);this.buffer=t;this.position-=e};i.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t};i.prototype.isEof=function(){return this.position>=this._byteLength};i.prototype.mapInt32Array=function(e,t){this._realloc(e*4);var r=new Int32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.mapInt16Array=function(e,t){this._realloc(e*2);var r=new Int16Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*2;return r};i.prototype.mapInt8Array=function(e){this._realloc(e*1);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);this.position+=e*1;return t};i.prototype.mapUint32Array=function(e,t){this._realloc(e*4);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.mapUint16Array=function(e,t){this._realloc(e*2);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*2;return r};i.prototype.mapUint8Array=function(e){this._realloc(e*1);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);this.position+=e*1;return t};i.prototype.mapFloat64Array=function(e,t){this._realloc(e*8);var r=new Float64Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*8;return r};i.prototype.mapFloat32Array=function(e,t){this._realloc(e*4);var r=new Float32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.readInt32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Int32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readInt16Array=function(e,t){e=e==null?this.byteLength-this.position/2:e;var r=new Int16Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readInt8Array=function(e){e=e==null?this.byteLength-this.position:e;var t=new Int8Array(e);i.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT);this.position+=t.byteLength;return t};i.prototype.readUint32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Uint32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readUint16Array=function(e,t){e=e==null?this.byteLength-this.position/2:e;var r=new Uint16Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readUint8Array=function(e){e=e==null?this.byteLength-this.position:e;var t=new Uint8Array(e);i.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT);this.position+=t.byteLength;return t};i.prototype.readFloat64Array=function(e,t){e=e==null?this.byteLength-this.position/8:e;var r=new Float64Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readFloat32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Float32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.writeInt32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeInt32(e[r],t)}}};i.prototype.writeInt16Array=function(e,t){this._realloc(e.length*2);if(e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt16Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeInt16(e[r],t)}}};i.prototype.writeInt8Array=function(e){this._realloc(e.length*1);if(e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt8Array(e.length)}else{for(var t=0;t<e.length;t++){this.writeInt8(e[t])}}};i.prototype.writeUint32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeUint32(e[r],t)}}};i.prototype.writeUint16Array=function(e,t){this._realloc(e.length*2);if(e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint16Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeUint16(e[r],t)}}};i.prototype.writeUint8Array=function(e){this._realloc(e.length*1);if(e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint8Array(e.length)}else{for(var t=0;t<e.length;t++){this.writeUint8(e[t])}}};i.prototype.writeFloat64Array=function(e,t){this._realloc(e.length*8);if(e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapFloat64Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeFloat64(e[r],t)}}};i.prototype.writeFloat32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapFloat32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeFloat32(e[r],t)}}};i.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,e==null?this.endianness:e);this.position+=2;return t};i.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);this.position+=1;return e};i.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,e==null?this.endianness:e);this.position+=2;return t};i.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);this.position+=1;return e};i.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,e==null?this.endianness:e);this.position+=8;return t};i.prototype.writeInt32=function(e,t){this._realloc(4);this._dataView.setInt32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeInt16=function(e,t){this._realloc(2);this._dataView.setInt16(this.position,e,t==null?this.endianness:t);this.position+=2};i.prototype.writeInt8=function(e){this._realloc(1);this._dataView.setInt8(this.position,e);this.position+=1};i.prototype.writeUint32=function(e,t){this._realloc(4);this._dataView.setUint32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeUint16=function(e,t){this._realloc(2);this._dataView.setUint16(this.position,e,t==null?this.endianness:t);this.position+=2};i.prototype.writeUint8=function(e){this._realloc(1);this._dataView.setUint8(this.position,e);this.position+=1};i.prototype.writeFloat32=function(e,t){this._realloc(4);this._dataView.setFloat32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeFloat64=function(e,t){this._realloc(8);this._dataView.setFloat64(this.position,e,t==null?this.endianness:t);this.position+=8};i.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0;i.memcpy=function(e,t,r,i,n){var a=new Uint8Array(e,t,n);var s=new Uint8Array(r,i,n);a.set(s)};i.arrayToNative=function(e,t){if(t==this.endianness){return e}else{return this.flipArrayEndianness(e)}};i.nativeToEndian=function(e,t){if(this.endianness==t){return e}else{return this.flipArrayEndianness(e)}};i.flipArrayEndianness=function(e){var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);for(var r=0;r<e.byteLength;r+=e.BYTES_PER_ELEMENT){for(var i=r+e.BYTES_PER_ELEMENT-1,n=r;i>n;i--,n++){var a=t[n];t[n]=t[i];t[i]=a}}return e};i.prototype.failurePosition=0;i.prototype.readStruct=function(e){var t={},r,i,n;var a=this.position;for(var s=0;s<e.length;s+=2){r=e[s+1];i=this.readType(r,t);if(i==null){if(this.failurePosition===0){this.failurePosition=this.position}this.position=a;return null}t[e[s]]=i}return t};i.prototype.readUCS2String=function(e,t){return String.fromCharCode.apply(null,this.readUint16Array(e,t))};i.prototype.writeUCS2String=function(e,t,r){if(r==null){r=e.length}for(var i=0;i<e.length&&i<r;i++){this.writeUint16(e.charCodeAt(i),t)}for(;i<r;i++){this.writeUint16(0)}};i.prototype.readString=function(e,t){if(t==null||t=="ASCII"){return String.fromCharCode.apply(null,this.mapUint8Array(e==null?this.byteLength-this.position:e))}else{return new TextDecoder(t).decode(this.mapUint8Array(e))}};i.prototype.writeString=function(e,t,r){var i=0;if(t==null||t=="ASCII"){if(r!=null){var n=Math.min(e.length,r);for(i=0;i<n;i++){this.writeUint8(e.charCodeAt(i))}for(;i<r;i++){this.writeUint8(0)}}else{for(i=0;i<e.length;i++){this.writeUint8(e.charCodeAt(i))}}}else{this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,r)))}};i.prototype.readCString=function(e){var t=this.byteLength-this.position;var r=new Uint8Array(this._buffer,this._byteOffset+this.position);var i=t;if(e!=null){i=Math.min(e,t)}for(var n=0;n<i&&r[n]!==0;n++);var a=String.fromCharCode.apply(null,this.mapUint8Array(n));if(e!=null){this.position+=i-n}else if(n!=t){this.position+=1}return a};i.prototype.writeCString=function(e,t){var r=0;if(t!=null){var i=Math.min(e.length,t);for(r=0;r<i;r++){this.writeUint8(e.charCodeAt(r))}for(;r<t;r++){this.writeUint8(0)}}else{for(r=0;r<e.length;r++){this.writeUint8(e.charCodeAt(r))}this.writeUint8(0)}};i.prototype.readType=function(e,t){if(typeof e=="function"){return e(this,t)}else if(typeof e=="object"&&!(e instanceof Array)){return e.get(this,t)}else if(e instanceof Array&&e.length!=3){return this.readStruct(e,t)}var r=null;var n=null;var a="ASCII";var s=this.position;var o;var f;var l;if(typeof e=="string"&&/:/.test(e)){o=e.split(":");e=o[0];n=parseInt(o[1])}if(typeof e=="string"&&/,/.test(e)){o=e.split(",");e=o[0];a=parseInt(o[1])}switch(e){case"uint8":r=this.readUint8();break;case"int8":r=this.readInt8();break;case"uint16":r=this.readUint16(this.endianness);break;case"int16":r=this.readInt16(this.endianness);break;case"uint32":r=this.readUint32(this.endianness);break;case"int32":r=this.readInt32(this.endianness);break;case"float32":r=this.readFloat32(this.endianness);break;case"float64":r=this.readFloat64(this.endianness);break;case"uint16be":r=this.readUint16(i.BIG_ENDIAN);break;case"int16be":r=this.readInt16(i.BIG_ENDIAN);break;case"uint32be":r=this.readUint32(i.BIG_ENDIAN);break;case"int32be":r=this.readInt32(i.BIG_ENDIAN);break;case"float32be":r=this.readFloat32(i.BIG_ENDIAN);break;case"float64be":r=this.readFloat64(i.BIG_ENDIAN);break;case"uint16le":r=this.readUint16(i.LITTLE_ENDIAN);break;case"int16le":r=this.readInt16(i.LITTLE_ENDIAN);break;case"uint32le":r=this.readUint32(i.LITTLE_ENDIAN);
break;case"int32le":r=this.readInt32(i.LITTLE_ENDIAN);break;case"float32le":r=this.readFloat32(i.LITTLE_ENDIAN);break;case"float64le":r=this.readFloat64(i.LITTLE_ENDIAN);break;case"cstring":r=this.readCString(n);break;case"string":r=this.readString(n,a);break;case"u16string":r=this.readUCS2String(n,this.endianness);break;case"u16stringle":r=this.readUCS2String(n,i.LITTLE_ENDIAN);break;case"u16stringbe":r=this.readUCS2String(n,i.BIG_ENDIAN);break;default:if(e.length==3){var u=e[1];var c=e[2];var p=0;if(typeof c=="function"){p=c(t,this,e)}else if(typeof c=="string"&&t[c]!=null){p=parseInt(t[c])}else{p=parseInt(c)}if(typeof u=="string"){var d=u.replace(/(le|be)$/,"");var h=null;if(/le$/.test(u)){h=i.LITTLE_ENDIAN}else if(/be$/.test(u)){h=i.BIG_ENDIAN}if(c=="*"){p=null}switch(d){case"uint8":r=this.readUint8Array(p);break;case"uint16":r=this.readUint16Array(p,h);break;case"uint32":r=this.readUint32Array(p,h);break;case"int8":r=this.readInt8Array(p);break;case"int16":r=this.readInt16Array(p,h);break;case"int32":r=this.readInt32Array(p,h);break;case"float32":r=this.readFloat32Array(p,h);break;case"float64":r=this.readFloat64Array(p,h);break;case"cstring":case"utf16string":case"string":if(p==null){r=[];while(!this.isEof()){l=this.readType(u,t);if(l==null)break;r.push(l)}}else{r=new Array(p);for(f=0;f<p;f++){r[f]=this.readType(u,t)}}break}}else{if(c=="*"){r=[];var m=this.buffer;while(true){var v=this.position;try{var g=this.readType(u,t);if(g==null){this.position=v;break}r.push(g)}catch(_){this.position=v;break}}}else{r=new Array(p);for(f=0;f<p;f++){l=this.readType(u,t);if(l==null)return null;r[f]=l}}}break}}if(n!=null){this.position=s+n}return r};i.prototype.writeStruct=function(e,t){for(var r=0;r<e.length;r+=2){var i=e[r+1];this.writeType(i,t[e[r]],t)}};i.prototype.writeType=function(e,t,r){var n;if(typeof e=="function"){return e(this,t)}else if(typeof e=="object"&&!(e instanceof Array)){return e.set(this,t,r)}var a=null;var s="ASCII";var o=this.position;if(typeof e=="string"&&/:/.test(e)){n=e.split(":");e=n[0];a=parseInt(n[1])}if(typeof e=="string"&&/,/.test(e)){n=e.split(",");e=n[0];s=parseInt(n[1])}switch(e){case"uint8":this.writeUint8(t);break;case"int8":this.writeInt8(t);break;case"uint16":this.writeUint16(t,this.endianness);break;case"int16":this.writeInt16(t,this.endianness);break;case"uint32":this.writeUint32(t,this.endianness);break;case"int32":this.writeInt32(t,this.endianness);break;case"float32":this.writeFloat32(t,this.endianness);break;case"float64":this.writeFloat64(t,this.endianness);break;case"uint16be":this.writeUint16(t,i.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,i.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,i.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,i.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,i.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,i.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,i.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,i.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,i.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,i.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,i.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,i.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,a);break;case"string":this.writeString(t,s,a);break;case"u16string":this.writeUCS2String(t,this.endianness,a);break;case"u16stringle":this.writeUCS2String(t,i.LITTLE_ENDIAN,a);break;case"u16stringbe":this.writeUCS2String(t,i.BIG_ENDIAN,a);break;default:if(e.length==3){var f=e[1];for(var l=0;l<t.length;l++){this.writeType(f,t[l])}break}else{this.writeStruct(e,t);break}}if(a!=null){this.position=o;this._realloc(a);this.position=o+a}};var n=Math.pow(2,32);r.MAX_SIZE=n;i.prototype.readUint64=function(){return this.readUint32()*n+this.readUint32()};i.prototype.writeUint64=function(e){var t=Math.floor(e/n);this.writeUint32(t);this.writeUint32(e&4294967295)};i.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()};i.prototype.writeUint24=function(e){this.writeUint8((e&16711680)>>16);this.writeUint8((e&65280)>>8);this.writeUint8(e&255)};i.prototype.adjustUint32=function(e,t){var r=this.position;this.seek(e);this.writeUint32(t);this.seek(r)}},{}],237:[function(e,t,r){var n=e("./DataStream");var a=e("./descriptor");var s=e("./log");var o={ERR_NOT_ENOUGH_DATA:0,OK:1,boxCodes:["mdat","avcC","hvcC","ftyp","payl","vmhd","smhd","hmhd","dref","elst"],fullBoxCodes:["mvhd","tkhd","mdhd","hdlr","smhd","hmhd","nhmd","url ","urn ","ctts","cslg","stco","co64","stsc","stss","stsz","stz2","stts","stsh","mehd","trex","mfhd","tfhd","trun","tfdt","esds","subs","txtC"],containerBoxCodes:[["moov",["trak"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl"],["mvex",["trex"]],["moof",["traf"]],["traf",["trun"]],["vttc"],["tref"]],sampleEntryCodes:[{prefix:"Visual",types:["mp4v","avc1","avc2","avc3","avc4","avcp","drac","encv","mjp2","mvc1","mvc2","resv","s263","svc1","vc-1","hvc1","hev1"]},{prefix:"Audio",types:["mp4a","ac-3","alac","dra1","dtsc","dtse",,"dtsh","dtsl","ec-3","enca","g719","g726","m4ae","mlpa","raw ","samr","sawb","sawp","sevc","sqcp","ssmv","twos"]},{prefix:"Hint",types:["fdp ","m2ts","pm2t","prtp","rm2t","rrtp","rsrp","rtp ","sm2t","srtp"]},{prefix:"Metadata",types:["metx","mett","urim"]},{prefix:"Subtitle",types:["stpp","wvtt","sbtt","tx3g","stxt"]}],trackReferenceTypes:["scal"],initialize:function(){var e,t;var r;o.FullBox.prototype=new o.Box;o.ContainerBox.prototype=new o.Box;o.stsdBox.prototype=new o.FullBox;o.SampleEntry.prototype=new o.FullBox;o.TrackReferenceTypeBox.prototype=new o.Box;r=o.boxCodes.length;for(e=0;e<r;e++){o[o.boxCodes[e]+"Box"]=function(e){return function(t){o.Box.call(this,o.boxCodes[e],t)}}(e);o[o.boxCodes[e]+"Box"].prototype=new o.Box}r=o.fullBoxCodes.length;for(e=0;e<r;e++){o[o.fullBoxCodes[e]+"Box"]=function(e){return function(t){o.FullBox.call(this,o.fullBoxCodes[e],t)}}(e);o[o.fullBoxCodes[e]+"Box"].prototype=new o.FullBox}r=o.containerBoxCodes.length;for(e=0;e<r;e++){o[o.containerBoxCodes[e][0]+"Box"]=function(e,t){return function(r){o.ContainerBox.call(this,o.containerBoxCodes[e][0],r);if(t){this.subBoxNames=t;var i=t.length;for(var n=0;n<i;n++){this[t[n]+"s"]=[]}}}}(e,o.containerBoxCodes[e][1]);o[o.containerBoxCodes[e][0]+"Box"].prototype=new o.ContainerBox}r=o.sampleEntryCodes.length;for(t=0;t<r;t++){var i=o.sampleEntryCodes[t].prefix;var n=o.sampleEntryCodes[t].types;var a=n.length;o[i+"SampleEntry"]=function(e,t){o.SampleEntry.call(this,e,t)};o[i+"SampleEntry"].prototype=new o.SampleEntry;for(e=0;e<a;e++){o[n[e]+"Box"]=function(e,t){return function(r){o[o.sampleEntryCodes[e].prefix+"SampleEntry"].call(this,o.sampleEntryCodes[e].types[t],r)}}(t,e);o[n[e]+"Box"].prototype=new o[i+"SampleEntry"]}}r=o.trackReferenceTypes.length;for(e=0;e<r;e++){o[o.trackReferenceTypes[e]+"Box"]=function(e){return function(t){o.TrackReferenceTypeBox.call(this,o.trackReferenceTypes[e],t)}}(e);o[o.trackReferenceTypes[e]+"Box"].prototype=new o.Box}},Box:function(e,t){this.type=e;this.size=t},FullBox:function(e,t){o.Box.call(this,e,t);this.flags=0;this.version=0},ContainerBox:function(e,t){o.Box.call(this,e,t);this.boxes=[]},SampleEntry:function(e,t){o.Box.call(this,e,t);this.boxes=[]},TrackReferenceTypeBox:function(e,t){o.Box.call(this,e,t);this.track_ids=[]},stsdBox:function(e){o.FullBox.call(this,"stsd",e);this.entries=[]},parseOneBox:function(e,t){var r;var i=e.position;var n=0;if(e.byteLength-e.position<8){s.d("BoxParser","Not enough data in stream to parse the type and size of the box");return{code:o.ERR_NOT_ENOUGH_DATA}}var a=e.readUint32();var f=e.readString(4);s.d("BoxParser","Found box of type "+f+" and size "+a+" at position "+i+" in the current buffer ("+(e.buffer.fileStart+i)+" in the file)");n=8;if(a==1){if(e.byteLength-e.position<8){e.seek(i);s.w("BoxParser",'Not enough data in stream to parse the extended size of the "'+f+'" box');return{code:o.ERR_NOT_ENOUGH_DATA}}a=e.readUint64();n+=8}else if(a===0){throw"Unlimited box size not supported"}if(i+a>e.byteLength){e.seek(i);s.w("BoxParser",'Not enough data in stream to parse the entire "'+f+'" box');return{code:o.ERR_NOT_ENOUGH_DATA,type:f,size:a,hdr_size:n}}if(o[f+"Box"]){r=new o[f+"Box"](a-n)}else{if(t){r=new o.SampleEntry(f,a-n)}else{r=new o.Box(f,a-n)}}r.hdr_size=n;r.start=i;r.fileStart=i+e.buffer.fileStart;r.parse(e);e.seek(i+a);return{code:o.OK,box:r,size:a}}};t.exports=o;o.initialize();o.Box.prototype.parse=function(e){if(this.type!="mdat"){this.data=e.readUint8Array(this.size)}else{e.seek(this.start+this.size+this.hdr_size)}};o.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8();this.flags=e.readUint24();this.size-=4};o.ContainerBox.prototype.parse=function(e){var t;var r;var i;i=e.position;while(e.position<i+this.size){t=o.parseOneBox(e);r=t.box;this.boxes.push(r);if(this.subBoxNames&&this.subBoxNames.indexOf(r.type)!=-1){this[this.subBoxNames+"s"].push(r)}else{this[r.type]=r}}};o.SampleEntry.prototype.isVideo=function(){return false};o.SampleEntry.prototype.isAudio=function(){return false};o.SampleEntry.prototype.isSubtitle=function(){return false};o.SampleEntry.prototype.isMetadata=function(){return false};o.SampleEntry.prototype.isHint=function(){return false};o.SampleEntry.prototype.getCodec=function(){return this.type};o.SampleEntry.prototype.getWidth=function(){return""};o.SampleEntry.prototype.getHeight=function(){return""};o.SampleEntry.prototype.getChannelCount=function(){return""};o.SampleEntry.prototype.getSampleRate=function(){return""};o.SampleEntry.prototype.getSampleSize=function(){return""};o.SampleEntry.prototype.parseHeader=function(e){this.start=e.position;e.readUint8Array(6);this.data_reference_index=e.readUint16()};o.SampleEntry.prototype.parse=function(e){this.parseHeader(e);e.seek(this.start+this.size)};o.SampleEntry.prototype.parseFooter=function(e){var t;var r;while(e.position<this.start+this.size){t=o.parseOneBox(e,false);r=t.box;this.boxes.push(r);this[r.type]=r}};o.VisualSampleEntry.prototype.parse=function(e){this.parseHeader(e);e.readUint16();e.readUint16();e.readUint32Array(3);this.width=e.readUint16();this.height=e.readUint16();this.horizresolution=e.readUint32();this.vertresolution=e.readUint32();e.readUint32();this.frame_count=e.readUint16();this.compressorname=e.readString(32);this.depth=e.readUint16();e.readUint16();this.parseFooter(e)};o.VisualSampleEntry.prototype.isVideo=function(){return true};o.VisualSampleEntry.prototype.getWidth=function(){return this.width};o.VisualSampleEntry.prototype.getHeight=function(){return this.height};o.AudioSampleEntry.prototype.parse=function(e){this.parseHeader(e);e.readUint32Array(2);this.channel_count=e.readUint16();this.samplesize=e.readUint16();e.readUint16();e.readUint16();this.samplerate=e.readUint32()/(1<<16);this.parseFooter(e)};o.AudioSampleEntry.prototype.isAudio=function(){return true};o.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count};o.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate};o.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize};o.SubtitleSampleEntry.prototype.parse=function(e){this.parseHeader(e);this.parseFooter(e)};o.SubtitleSampleEntry.prototype.isSubtitle=function(){return true};o.MetadataSampleEntry.prototype.parse=function(e){this.parseHeader(e);this.parseFooter(e)};o.MetadataSampleEntry.prototype.isMetadata=function(){return true};o.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint8Array(this.size)};o.metxBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.namespace=e.readCString();this.schema_location=e.readCString();this.parseFooter(e)};o.mettBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.sbttBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.stxtBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.stppBox.prototype.parse=function(e){this.parseHeader(e);this.namespace=e.readCString();this.schema_location=e.readCString();this.auxiliary_mime_types=e.readCString();this.parseFooter(e)};o.tx3gBox.prototype.parse=function(e){this.parseHeader(e);this.displayFlags=e.readUint32();this.horizontal_justification=e.readInt8();this.vertical_justification=e.readInt8();this.bg_color_rgba=e.readUint8Array(4);this.box_record=e.readInt16Array(4);this.style_record=e.readUint8Array(12);this.parseFooter(e)};o.ftypBox.prototype.parse=function(e){this.major_brand=e.readString(4);this.minor_version=e.readUint32();this.size-=8;this.compatible_brands=[];var t=0;while(this.size>=4){this.compatible_brands[t]=e.readString(4);this.size-=4;t++}};o.mvhdBox.prototype.parse=function(e){this.flags=0;this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.timescale=e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.timescale=e.readUint32();this.duration=e.readUint32()}this.rate=e.readUint32();this.volume=e.readUint16()>>8;e.readUint16();e.readUint32Array(2);this.matrix=e.readUint32Array(9);e.readUint32Array(6);this.next_track_id=e.readUint32()};o.TKHD_FLAG_ENABLED=1;o.TKHD_FLAG_IN_MOVIE=2;o.TKHD_FLAG_IN_PREVIEW=4;o.tkhdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.track_id=e.readUint32();e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.track_id=e.readUint32();e.readUint32();this.duration=e.readUint32()}e.readUint32Array(2);this.layer=e.readInt16();this.alternate_group=e.readInt16();this.volume=e.readInt16()>>8;e.readUint16();this.matrix=e.readInt32Array(9);this.width=e.readUint32();this.height=e.readUint32()};o.mdhdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.timescale=e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.timescale=e.readUint32();this.duration=e.readUint32()}this.language=e.readUint16();var t=[];t[0]=this.language>>10&31;t[1]=this.language>>5&31;t[2]=this.language&31;this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96);e.readUint16()};o.hdlrBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version===0){e.readUint32();this.handler=e.readString(4);e.readUint32Array(3);this.name=e.readCString()}else{this.data=e.readUint8Array(size)}};o.stsdBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);r=e.readUint32();for(i=1;i<=r;i++){t=o.parseOneBox(e,true);this.entries.push(t.box)}};o.avcCBox.prototype.parse=function(e){var t;var r;var i;this.configurationVersion=e.readUint8();this.AVCProfileIndication=e.readUint8();this.profile_compatibility=e.readUint8();this.AVCLevelIndication=e.readUint8();this.lengthSizeMinusOne=e.readUint8()&3;r=e.readUint8()&31;this.size-=6;this.SPS=new Array(r);for(t=0;t<r;t++){i=e.readUint16();this.SPS[t]=e.readUint8Array(i);this.size-=2+i}r=e.readUint8();this.size--;this.PPS=new Array(r);for(t=0;t<r;t++){i=e.readUint16();this.PPS[t]=e.readUint8Array(i);this.size-=2+i}if(this.size>0){this.ext=e.readUint8Array(this.size)}};o.hvcCBox.prototype.parse=function(e){var t;var r;var i;var n;this.configurationVersion=e.readUint8();n=e.readUint8();this.general_profile_space=n>>6;this.general_tier_flag=(n&32)>>5;this.general_profile_idc=n&31;this.general_profile_compatibility=e.readUint32();this.general_constraint_indicator=e.readUint8Array(6);this.general_level_idc=e.readUint8();this.min_spatial_segmentation_idc=e.readUint16()&4095;this.parallelismType=e.readUint8()&3;this.chromaFormat=e.readUint8()&3;this.bitDepthLumaMinus8=e.readUint8()&7;this.bitDepthChromaMinus8=e.readUint8()&7;this.avgFrameRate=e.readUint16();n=e.readUint8();this.constantFrameRate=n>>6;this.numTemporalLayers=(n&13)>>3;this.temporalIdNested=(n&4)>>2;this.lengthSizeMinusOne=n&3;this.nalu_arrays=[];numOfArrays=e.readUint8();for(t=0;t<numOfArrays;t++){var a=[];this.nalu_arrays.push(a);n=e.readUint8();a.completeness=(n&128)>>7;a.nalu_type=n&63;numNalus=e.readUint16();for(j=0;j<numNalus;j++){var s={};a.push(s);i=e.readUint16();s.data=e.readUint8Array(i)}}};function f(e,t){var r=Number(e).toString(16);t=typeof t==="undefined"||t===null?t=2:t;while(r.length<t){r="0"+r}return r}o.avc1Box.prototype.getCodec=function(){var e=o.SampleEntry.prototype.getCodec.call(this);if(this.avcC){return e+"."+f(this.avcC.AVCProfileIndication)+""+f(this.avcC.profile_compatibility)+""+f(this.avcC.AVCLevelIndication)}else{return e}};o.hvc1Box.prototype.getCodec=function(){var e;var t=o.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){t+=".";switch(this.hvcC.general_profile_space){case 0:t+="";break;case 1:t+="A";break;case 2:t+="B";break;case 3:t+="C";break}t+=this.hvcC.general_profile_idc;t+=".";var r=this.hvcC.general_profile_compatibility;var i=0;for(e=0;e<32;e++){i|=r&1;if(e==31)break;i<<=1;r>>=1}t+=f(i,0);t+=".";if(this.hvcC.general_tier_flag===0){t+="L"}else{t+="H"}t+=this.hvcC.general_level_idc;var n=false;var a="";for(e=5;e>=0;e--){if(this.hvcC.general_constraint_indicator[e]||n){a="."+f(this.hvcC.general_constraint_indicator[e],0)+a;n=true}}t+=a}return t};o.mp4aBox.prototype.getCodec=function(){var e=o.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI();var r=this.esds.esd.getAudioConfig();return e+"."+f(t)+(r?"."+r:"")}else{return e}};o.esdsBox.prototype.parse=function(e){this.parseFullHeader(e);this.data=e.readUint8Array(this.size);this.size=0;var t=new a;this.esd=t.parseOneDescriptor(new n(this.data.buffer,0,n.BIG_ENDIAN))};o.txtCBox.prototype.parse=function(e){this.parseFullHeader(e);this.config=e.readCString()};o.cttsBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.sample_counts=[];this.sample_offsets=[];if(this.version===0){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_offsets.push(e.readInt32())}}else if(this.version==1){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_offsets.push(e.readInt32())}}else{this.data=e.readUint8Array(this.size-4)}};o.cttsBox.prototype.unpack=function(e){var t,r,i;i=0;for(t=0;t<this.sample_counts.length;t++){for(r=0;r<this.sample_counts[t];r++){e[i].pts=e[i].dts+this.sample_offsets[t];i++}}};o.cslgBox.prototype.parse=function(e){var t;this.parseFullHeader(e);if(this.version===0){this.compositionToDTSShift=e.readInt32();this.leastDecodeToDisplayDelta=e.readInt32();this.greatestDecodeToDisplayDelta=e.readInt32();this.compositionStartTime=e.readInt32();this.compositionEndTime=e.readInt32()}else{this.data=e.readUint8Array(this.size-4)}};o.sttsBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.sample_counts=[];this.sample_deltas=[];if(this.version===0){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_deltas.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.sttsBox.prototype.unpack=function(e){var t,r,i;i=0;for(t=0;t<this.sample_counts.length;t++){for(r=0;r<this.sample_counts[t];r++){if(i===0){e[i].dts=0}else{e[i].dts=e[i-1].dts+this.sample_deltas[t]}i++}}};o.stssBox.prototype.parse=function(e){var t;this.parseFullHeader(e);t=e.readUint32();if(this.version===0){this.sample_numbers=e.readUint32Array(t)}else{this.data=e.readUint8Array(this.size-4)}};o.stshBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.shadowed_sample_numbers=[];this.sync_sample_numbers=[];if(this.version===0){for(r=0;r<t;r++){this.shadowed_sample_numbers.push(e.readUint32());this.sync_sample_numbers.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.stcoBox.prototype.parse=function(e){var t;this.parseFullHeader(e);t=e.readUint32();if(this.version===0){this.chunk_offsets=e.readUint32Array(t)}else{this.data=e.readUint8Array(this.size-4)}};o.stcoBox.prototype.unpack=function(e){var t;for(t=0;t<this.chunk_offsets.length;t++){e[t].offset=this.chunk_offsets[t]}};o.co64Box.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.chunk_offsets=[];if(this.version===0){for(r=0;r<t;r++){this.chunk_offsets.push(e.readUint64())}}else{this.data=e.readUint8Array(this.size-4)}};o.stscBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.first_chunk=[];this.samples_per_chunk=[];this.sample_description_index=[];if(this.version===0){for(r=0;r<t;r++){this.first_chunk.push(e.readUint32());this.samples_per_chunk.push(e.readUint32());this.sample_description_index.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.stscBox.prototype.unpack=function(e){var t,r,i,n,a;n=0;a=0;for(t=0;t<this.first_chunk.length;t++){for(r=0;r<(t+1<this.first_chunk.length?this.first_chunk[t+1]:Infinity);r++){a++;for(i=0;i<this.samples_per_chunk[t];i++){if(e[n]){e[n].description_index=this.sample_description_index[t];e[n].chunk_index=a}else{return}n++}}}};o.stszBox.prototype.parse=function(e){var t;var r;var i;this.parseFullHeader(e);this.sample_sizes=[];if(this.version===0){r=e.readUint32();i=e.readUint32();if(r===0){this.sample_sizes=e.readUint32Array(i)}else{this.sample_sizes=[];for(t=0;t<i;t++){this.sample_sizes[t]=r}}}else{this.data=e.readUint8Array(this.size)}};o.stszBox.prototype.unpack=function(e){var t;for(t=0;t<this.sample_sizes.length;t++){e[t].size=this.sample_sizes[t]}};o.mehdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.fragment_duration=e.readUint64()}else{this.fragment_duration=e.readUint32()}};o.trexBox.prototype.parse=function(e){this.parseFullHeader(e);this.track_id=e.readUint32();this.default_sample_description_index=e.readUint32();this.default_sample_duration=e.readUint32();this.default_sample_size=e.readUint32();this.default_sample_flags=e.readUint32()};o.mfhdBox.prototype.parse=function(e){this.parseFullHeader(e);this.sequence_number=e.readUint32()};o.TFHD_FLAG_BASE_DATA_OFFSET=1;o.TFHD_FLAG_SAMPLE_DESC=2;o.TFHD_FLAG_SAMPLE_DUR=8;o.TFHD_FLAG_SAMPLE_SIZE=16;o.TFHD_FLAG_SAMPLE_FLAGS=32;o.TFHD_FLAG_DUR_EMPTY=65536;o.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072;o.tfhdBox.prototype.parse=function(e){var t=0;this.parseFullHeader(e);this.track_id=e.readUint32();if(this.size>t&&this.flags&o.TFHD_FLAG_BASE_DATA_OFFSET){this.base_data_offset=e.readUint64();t+=8}else{this.base_data_offset=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_DESC){this.default_sample_description_index=e.readUint32();t+=4}else{this.default_sample_description_index=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_DUR){this.default_sample_duration=e.readUint32();t+=4}else{this.default_sample_duration=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_SIZE){this.default_sample_size=e.readUint32();t+=4}else{this.default_sample_size=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){this.default_sample_flags=e.readUint32();t+=4}else{this.default_sample_flags=0}};o.TRUN_FLAGS_DATA_OFFSET=1;o.TRUN_FLAGS_FIRST_FLAG=4;o.TRUN_FLAGS_DURATION=256;o.TRUN_FLAGS_SIZE=512;o.TRUN_FLAGS_FLAGS=1024;o.TRUN_FLAGS_CTS_OFFSET=2048;o.trunBox.prototype.parse=function(e){var t=0;this.parseFullHeader(e);this.sample_count=e.readUint32();t+=4;if(this.size>t&&this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.data_offset=e.readInt32();t+=4}else{this.data_offset=0}if(this.size>t&&this.flags&o.TRUN_FLAGS_FIRST_FLAG){this.first_sample_flags=e.readUint32();t+=4}else{this.first_sample_flags=0}this.sample_duration=[];this.sample_size=[];this.sample_flags=[];this.sample_composition_time_offset=[];if(this.size>t){for(var r=0;r<this.sample_count;r++){if(this.flags&o.TRUN_FLAGS_DURATION){this.sample_duration[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_SIZE){this.sample_size[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_FLAGS){this.sample_flags[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){if(this.version===0){this.sample_composition_time_offset[r]=e.readUint32()}else{this.sample_composition_time_offset[r]=e.readInt32()}}}}};o.tfdtBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.baseMediaDecodeTime=e.readUint64()}else{this.baseMediaDecodeTime=e.readUint32()}};o.paylBox.prototype.parse=function(e){this.text=e.readString(this.size)};o.subsBox.prototype.parse=function(e){var t,r;var i;var n;this.parseFullHeader(e);i=e.readUint32();this.samples=[];for(t=0;t<i;t++){var a={};this.samples[t]=a;a.sample_delta=e.readUint32();a.subsamples=[];n=e.readUint16();if(n>0){for(r=0;r<n;r++){var s={};a.subsamples.push(s);if(this.version==1){s.size=e.readUint32()}else{s.size=e.readUint16()}s.priority=e.readUint8();s.discardable=e.readUint8();s.reserved=e.readUint32()}}}};o.Box.prototype.writeHeader=function(e,t){this.size+=8;if(this.size>n.MAX_SIZE){this.size+=8}s.d("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.position+(t||""));if(this.size>n.MAX_SIZE){e.writeUint32(1)}else{this.sizePosition=e.position;e.writeUint32(this.size)}e.writeString(this.type,null,4);if(this.size>n.MAX_SIZE){e.writeUint64(this.size)}};o.FullBox.prototype.writeHeader=function(e){this.size+=4;o.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags);e.writeUint8(this.version);e.writeUint24(this.flags)};o.Box.prototype.write=function(e){if(this.type==="mdat"){if(this.data){this.size=this.data.length;this.writeHeader(e);e.writeUint8Array(this.data)}}else{this.size=this.data.length;this.writeHeader(e);e.writeUint8Array(this.data)}};o.ContainerBox.prototype.write=function(e){this.size=0;this.writeHeader(e);for(var t=0;t<this.boxes.length;t++){if(this.boxes[t]){this.boxes[t].write(e);this.size+=this.boxes[t].size}}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.TrackReferenceTypeBox.prototype.write=function(e){this.size=this.track_ids.length*4;this.writeHeader(e);e.writeUint32Array(this.track_ids)};o.ftypBox.prototype.write=function(e){this.size=8+4*this.compatible_brands.length;this.writeHeader(e);e.writeString(this.major_brand,null,4);e.writeUint32(this.minor_version);for(var t=0;t<this.compatible_brands.length;t++){e.writeString(this.compatible_brands[t],null,4)}};o.mvhdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=23*4+2*2;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.timescale);e.writeUint32(this.duration);e.writeUint32(this.rate);e.writeUint16(this.volume<<8);e.writeUint16(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32Array(this.matrix);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(this.next_track_id)};o.tkhdBox.prototype.write=function(e){this.version=0;this.size=4*18+2*4;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.track_id);e.writeUint32(0);e.writeUint32(this.duration);e.writeUint32(0);e.writeUint32(0);e.writeInt16(this.layer);e.writeInt16(this.alternate_group);e.writeInt16(this.volume<<8);e.writeUint16(0);e.writeInt32Array(this.matrix);e.writeUint32(this.width);e.writeUint32(this.height)};o.mdhdBox.prototype.write=function(e){this.size=4*4+2*2;this.flags=0;this.version=0;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.timescale);e.writeUint32(this.duration);e.writeUint16(this.language);e.writeUint16(0)};o.hdlrBox.prototype.write=function(e){this.size=5*4+this.name.length+1;this.version=0;this.flags=0;this.writeHeader(e);e.writeUint32(0);e.writeString(this.handler,null,4);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeCString(this.name)};o.stsdBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=0;this.writeHeader(e);e.writeUint32(this.entries.length);this.size+=4;for(t=0;t<this.entries.length;t++){this.entries[t].write(e);this.size+=this.entries[t].size}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.SampleEntry.prototype.writeHeader=function(e){this.size=8;o.Box.prototype.writeHeader.call(this,e);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint16(this.data_reference_index)};o.SampleEntry.prototype.writeFooter=function(e){for(var t=0;t<this.boxes.length;t++){this.boxes[t].write(e);this.size+=this.boxes[t].size}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.SampleEntry.prototype.write=function(e){this.writeHeader(e);this.writeFooter(e)};o.VisualSampleEntry.prototype.write=function(e){this.writeHeader(e);this.size+=2*7+6*4+32;e.writeUint16(0);e.writeUint16(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint16(this.width-this.width%2);e.writeUint16(this.height-this.height%2);e.writeUint32(this.horizresolution);e.writeUint32(this.vertresolution);e.writeUint32(0);e.writeUint16(this.frame_count);e.writeString(this.compressorname,null,32);e.writeUint16(this.depth);e.writeInt16(-1);this.writeFooter(e)};o.AudioSampleEntry.prototype.write=function(e){this.writeHeader(e);this.size+=2*4+3*4;e.writeUint32(0);e.writeUint32(0);e.writeUint16(this.channel_count);e.writeUint16(this.samplesize);e.writeUint16(0);e.writeUint16(0);e.writeUint32(this.samplerate<<16);this.writeFooter(e)};o.avcCBox.prototype.write=function(e){var t;this.size=7;for(t=0;t<this.SPS.length;t++){this.size+=2+this.SPS[t].length}for(t=0;t<this.PPS.length;t++){this.size+=2+this.PPS[t].length}if(this.ext){this.size+=this.ext.length}this.writeHeader(e);e.writeUint8(this.configurationVersion);e.writeUint8(this.AVCProfileIndication);e.writeUint8(this.profile_compatibility);e.writeUint8(this.AVCLevelIndication);e.writeUint8(this.lengthSizeMinusOne+(63<<2));e.writeUint8(this.SPS.length+(7<<5));for(t=0;t<this.SPS.length;t++){e.writeUint16(this.SPS[t].length);e.writeUint8Array(this.SPS[t])}e.writeUint8(this.PPS.length);for(t=0;t<this.PPS.length;t++){e.writeUint16(this.PPS[t].length);e.writeUint8Array(this.PPS[t])}if(this.ext){e.writeUint8Array(this.ext)}};o.cttsBox.prototype.write=function(e){var t;this.version=1;this.flags=0;this.size=4+8*this.sample_counts.length;this.writeHeader(e);e.writeUint32(this.sample_counts.length);for(t=0;t<this.sample_counts.length;t++){e.writeUint32(this.sample_counts[t]);e.writeInt32(this.sample_offsets[t])}};o.cslgBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4*5;this.writeHeader(e);e.writeInt32(this.compositionToDTSShift);e.writeInt32(this.leastDecodeToDisplayDelta);e.writeInt32(this.greatestDecodeToDisplayDelta);e.writeInt32(this.compositionStartTime);e.writeInt32(this.compositionEndTime)};o.sttsBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.sample_counts.length;this.writeHeader(e);e.writeUint32(this.sample_counts.length);for(t=0;t<this.sample_counts.length;t++){e.writeUint32(this.sample_counts[t]);e.writeUint32(this.sample_deltas[t])}};o.stssBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4+4*this.sample_numbers.length;this.writeHeader(e);e.writeUint32(this.sample_numbers.length);e.writeUint32Array(this.sample_numbers)};o.stshBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.shadowed_sample_numbers.length;this.writeHeader(e);e.writeUint32(this.shadowed_sample_numbers.length);for(t=0;t<this.shadowed_sample_numbers.length;t++){e.writeUint32(this.shadowed_sample_numbers[t]);e.writeUint32(this.sync_sample_numbers[t])}};o.stcoBox.prototype.write=function(e){
this.version=0;this.flags=0;this.size=4+4*this.chunk_offsets.length;this.writeHeader(e);e.writeUint32(this.chunk_offsets.length);e.writeUint32Array(this.chunk_offsets)};o.co64Box.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.chunk_offsets.length;this.writeHeader(e);e.writeUint32(this.chunk_offsets.length);for(t=0;t<this.chunk_offsets.length;t++){e.writeUint64(this.chunk_offsets[t])}};o.stscBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+12*this.first_chunk.length;this.writeHeader(e);e.writeUint32(this.first_chunk.length);for(t=0;t<this.first_chunk.length;t++){e.writeUint32(this.first_chunk[t]);e.writeUint32(this.samples_per_chunk[t]);e.writeUint32(this.sample_description_index[t])}};o.stszBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=8+12*this.sample_sizes.length;this.writeHeader(e);e.writeUint32(0);e.writeUint32(this.sample_sizes.length);e.writeUint32Array(this.sample_sizes)};o.mehdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);e.writeUint32(this.fragment_duration)};o.trexBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4*5;this.writeHeader(e);e.writeUint32(this.track_id);e.writeUint32(this.default_sample_description_index);e.writeUint32(this.default_sample_duration);e.writeUint32(this.default_sample_size);e.writeUint32(this.default_sample_flags)};o.mfhdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);e.writeUint32(this.sequence_number)};o.tfhdBox.prototype.write=function(e){this.version=0;this.size=4;if(this.flags&o.TFHD_FLAG_BASE_OFFSET){this.size+=8}if(this.flags&o.TFHD_FLAG_SAMPLE_DESC){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_DUR){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_SIZE){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){this.size+=4}this.writeHeader(e);e.writeUint32(this.track_id);if(this.flags&o.TFHD_FLAG_BASE_OFFSET){e.writeUint64(this.base_data_offset)}if(this.flags&o.TFHD_FLAG_SAMPLE_DESC){e.writeUint32(this.default_sample_description_index)}if(this.flags&o.TFHD_FLAG_SAMPLE_DUR){e.writeUint32(this.default_sample_duration)}if(this.flags&o.TFHD_FLAG_SAMPLE_SIZE){e.writeUint32(this.default_sample_size)}if(this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){e.writeUint32(this.default_sample_flags)}};o.trunBox.prototype.write=function(e){this.version=0;this.size=4;if(this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.size+=4}if(this.flags&o.TRUN_FLAGS_FIRST_FLAG){this.size+=4}if(this.flags&o.TRUN_FLAGS_DURATION){this.size+=4*this.sample_duration.length}if(this.flags&o.TRUN_FLAGS_SIZE){this.size+=4*this.sample_size.length}if(this.flags&o.TRUN_FLAGS_FLAGS){this.size+=4*this.sample_flags.length}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){this.size+=4*this.sample_composition_time_offset.length}this.writeHeader(e);e.writeUint32(this.sample_count);if(this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.data_offset_position=e.position;e.writeInt32(this.data_offset)}if(this.flags&o.TRUN_FLAGS_FIRST_FLAG){e.writeUint32(this.first_sample_flags)}for(var t=0;t<this.sample_count;t++){if(this.flags&o.TRUN_FLAGS_DURATION){e.writeUint32(this.sample_duration[t])}if(this.flags&o.TRUN_FLAGS_SIZE){e.writeUint32(this.sample_size[t])}if(this.flags&o.TRUN_FLAGS_FLAGS){e.writeUint32(this.sample_flags[t])}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){if(this.version===0){e.writeUint32(this.sample_composition_time_offset[t])}else{e.writeInt32(this.sample_composition_time_offset[t])}}}};o.tfdtBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);if(this.version==1){e.writeUint64(this.baseMediaDecodeTime)}else{e.writeUint32(this.baseMediaDecodeTime)}}},{"./DataStream":236,"./descriptor":238,"./log":240}],238:[function(e,t,r){var i=e("./log");var n=function(){var e=3;var t=4;var r=5;var n=6;var a=[];a[e]="ES_Descriptor";a[t]="DecoderConfigDescriptor";a[r]="DecoderSpecificInfo";a[n]="SLConfigDescriptor";var s=this;var o={};this.parseOneDescriptor=function(e){var t=0;var r=0;var n;var s;var f;n=e.readUint8();t++;f=e.readUint8();t++;while(f&128){r=(f&127)<<7;f=e.readUint8();t++}r+=f&127;i.d("MPEG4DescriptorParser","Found "+(a[n]|"Descriptor "+n)+", size "+r+" at position "+e.position);if(a[n]){s=new o[a[n]](r)}else{s=new o.Descriptor(r)}s.parse(e);return s};o.Descriptor=function(e,t){this.tag=e;this.size=t;this.descs=[]};o.Descriptor.prototype.parse=function(e){this.data=e.readUint8Array(this.size)};o.Descriptor.prototype.findDescriptor=function(e){for(var t=0;t<this.descs.length;t++){if(this.descs[t].tag==e){return this.descs[t]}}return null};o.Descriptor.prototype.parseRemainingDescriptors=function(e){var t=e.position;while(e.position<t+this.size){var r=s.parseOneDescriptor(e);this.descs.push(r)}};o.ES_Descriptor=function(t){o.Descriptor.call(this,e,t)};o.ES_Descriptor.prototype=new o.Descriptor;o.ES_Descriptor.prototype.parse=function(e){this.ES_ID=e.readUint16();this.flags=e.readUint8();this.size-=3;if(this.flags&128){this.dependsOn_ES_ID=e.readUint16();this.size-=2}else{this.dependsOn_ES_ID=0}if(this.flags&64){var t=e.readUint8();this.URL=e.readString(t);this.size-=t+1}else{this.URL=null}if(this.flags&32){this.OCR_ES_ID=e.readUint16();this.size-=2}else{this.OCR_ES_ID=0}this.parseRemainingDescriptors(e)};o.ES_Descriptor.prototype.getOTI=function(e){var r=this.findDescriptor(t);if(r){return r.oti}else{return 0}};o.ES_Descriptor.prototype.getAudioConfig=function(e){var i=this.findDescriptor(t);if(!i)return null;var n=i.findDescriptor(r);if(n&&n.data){return(n.data[0]&248)>>3}else{return null}};o.DecoderConfigDescriptor=function(e){o.Descriptor.call(this,t,e)};o.DecoderConfigDescriptor.prototype=new o.Descriptor;o.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8();this.streamType=e.readUint8();this.bufferSize=e.readUint24();this.maxBitrate=e.readUint32();this.avgBitrate=e.readUint32();this.size-=13;this.parseRemainingDescriptors(e)};o.DecoderSpecificInfo=function(e){o.Descriptor.call(this,r,e)};o.DecoderSpecificInfo.prototype=new o.Descriptor;o.SLConfigDescriptor=function(e){o.Descriptor.call(this,n,e)};o.SLConfigDescriptor.prototype=new o.Descriptor;return this};t.exports=n},{"./log":240}],239:[function(e,t,r){var i=e("./box");var n=e("./DataStream");var a=e("./log");var s=function(e){this.stream=e;this.boxes=[];this.mdats=[];this.moofs=[];this.isProgressive=false;this.lastMoofIndex=0;this.lastBoxStartPosition=0;this.parsingMdat=null;this.moovStartFound=false;this.samplesDataSize=0;this.nextParsePosition=0};t.exports=s;s.prototype.mergeNextBuffer=function(){var e;if(this.stream.bufferIndex+1<this.stream.nextBuffers.length){e=this.stream.nextBuffers[this.stream.bufferIndex+1];if(e.fileStart===this.stream.buffer.fileStart+this.stream.buffer.byteLength){var t=this.stream.buffer.byteLength;var r=this.stream.buffer.usedBytes;var i=this.stream.buffer.fileStart;this.stream.nextBuffers[this.stream.bufferIndex]=ArrayBuffer.concat(this.stream.buffer,e);this.stream.buffer=this.stream.nextBuffers[this.stream.bufferIndex];this.stream.nextBuffers.splice(this.stream.bufferIndex+1,1);this.stream.buffer.usedBytes=r;this.stream.buffer.fileStart=i;a.d("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.stream.buffer.byteLength+")");return true}else{return false}}else{return false}};s.prototype.parse=function(){var e;var t;var r;a.d("ISOFile","Starting parsing with buffer #"+this.stream.bufferIndex+" (fileStart: "+this.stream.buffer.fileStart+" - Length: "+this.stream.buffer.byteLength+") from position "+this.lastBoxStartPosition+" ("+(this.stream.buffer.fileStart+this.lastBoxStartPosition)+" in the file)");this.stream.seek(this.lastBoxStartPosition);while(true){if(this.parsingMdat!==null){r=this.parsingMdat;e=this.reposition(false,r.fileStart+r.hdr_size+r.size);if(e){a.d("ISOFile","Found 'mdat' end in buffer #"+this.stream.bufferIndex);this.parsingMdat=null;continue}else{this.nextParsePosition=this.findEndContiguousBuf(this.stream.bufferIndex);return}}else{this.lastBoxStartPosition=this.stream.position;t=i.parseOneBox(this.stream);if(t.code===i.ERR_NOT_ENOUGH_DATA){if(t.type==="mdat"){r=new i[t.type+"Box"](t.size-t.hdr_size);this.parsingMdat=r;this.mdats.push(r);r.fileStart=this.stream.buffer.fileStart+this.stream.position;r.hdr_size=t.hdr_size;this.stream.buffer.usedBytes+=t.hdr_size;e=this.reposition(false,r.fileStart+r.hdr_size+r.size);if(e){this.parsingMdat=null;continue}else{if(!this.moovStartFound){this.nextParsePosition=r.fileStart+r.size+r.hdr_size}else{this.nextParsePosition=this.findEndContiguousBuf(this.stream.bufferIndex)}return}}else{if(t.type==="moov"){this.moovStartFound=true;if(this.mdats.length===0){this.isProgressive=true}}else if(t.type==="free"){e=this.reposition(false,this.stream.buffer.fileStart+this.stream.position+t.size);if(e){continue}else{this.nextParsePosition=this.stream.buffer.fileStart+this.stream.position+t.size;return}}merged=this.mergeNextBuffer();if(merged){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength;continue}else{if(!t.type){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength}else{if(this.moovStartFound){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength}else{this.nextParsePosition=this.stream.buffer.fileStart+this.stream.position+t.size}}return}}}else{r=t.box;this.boxes.push(r);switch(r.type){case"mdat":this.mdats.push(r);r.fileStart=this.stream.buffer.fileStart+r.start;break;case"moof":this.moofs.push(r);break;case"moov":this.moovStartFound=true;if(this.mdats.length===0){this.isProgressive=true}default:if(this[r.type]!==undefined){a.w("ISOFile","Duplicate Box of type: "+r.type+", overriding previous occurrence")}this[r.type]=r;break}if(r.type==="mdat"){this.stream.buffer.usedBytes+=r.hdr_size}else{this.stream.buffer.usedBytes+=t.size}}}}};s.prototype.reposition=function(e,t){var r;r=this.findPosition(e,t);if(r!==-1){this.stream.buffer=this.stream.nextBuffers[r];this.stream.bufferIndex=r;this.stream.position=t-this.stream.buffer.fileStart;a.d("ISOFile","Repositioning parser at buffer position: "+this.stream.position);return true}else{return false}};s.prototype.findPosition=function(e,t){var r;var i=null;var n=-1;if(e===true){r=0}else{r=this.stream.bufferIndex}while(r<this.stream.nextBuffers.length){i=this.stream.nextBuffers[r];if(i.fileStart<=t){n=r}else{break}r++}if(n!==-1){i=this.stream.nextBuffers[n];if(i.fileStart+i.byteLength>=t){a.d("ISOFile","Found position in existing buffer #"+n);return n}else{return-1}}else{return-1}};s.prototype.findEndContiguousBuf=function(e){var t;var r;var i;r=this.stream.nextBuffers[e];if(this.stream.nextBuffers.length>e+1){for(t=e+1;t<this.stream.nextBuffers.length;t++){i=this.stream.nextBuffers[t];if(i.fileStart===r.fileStart+r.byteLength){r=i}else{break}}}return r.fileStart+r.byteLength};s.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++){this.boxes[t].write(e)}};s.prototype.writeInitializationSegment=function(e){var t;var r;var n;var s;var o;a.d("ISOFile","Generating initialization segment");this.ftyp.write(e);if(this.moov.mvex){this.initial_duration=this.moov.mvex.mehd.fragment_duration;r=-1;for(t=0;t<this.moov.boxes.length;t++){o=this.moov.boxes[t];if(o===this.moov.mvex){r=t}}if(r>-1){this.moov.boxes.splice(r,1)}this.moov.mvex=null}this.moov.mvex=new i.mvexBox;this.moov.boxes.push(this.moov.mvex);this.moov.mvex.mehd=new i.mehdBox;this.moov.mvex.boxes.push(this.moov.mvex.mehd);this.moov.mvex.mehd.fragment_duration=this.initial_duration;for(t=0;t<this.moov.traks.length;t++){if(this.moov.traks[t].ignore)continue;s=new i.trexBox;this.moov.mvex.boxes.push(s);s.track_id=this.moov.traks[t].tkhd.track_id;s.default_sample_description_index=1;s.default_sample_duration=this.moov.traks[t].samples.length>0?this.moov.traks[t].samples[0].duration:0;s.default_sample_size=0;s.default_sample_flags=1<<16}this.moov.write(e)};s.prototype.resetTables=function(){var e;var t,r,i,n,a,s,o,f;this.initial_duration=this.moov.mvhd.duration;this.moov.mvhd.duration=0;for(e=0;e<this.moov.traks.length;e++){t=this.moov.traks[e];t.tkhd.duration=0;t.mdia.mdhd.duration=0;r=t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64;r.chunk_offsets=[];i=t.mdia.minf.stbl.stsc;i.first_chunk=[];i.samples_per_chunk=[];i.sample_description_index=[];n=t.mdia.minf.stbl.stsz;n.sample_sizes=[];a=t.mdia.minf.stbl.stts;a.sample_counts=[];a.sample_deltas=[];s=t.mdia.minf.stbl.ctts;if(s){s.sample_counts=[];s.sample_offsets=[]}o=t.mdia.minf.stbl.stss;if(o){o.sample_numbers=new Uint32Array(0)}f=t.mdia.minf.stbl.sdtp;var l=t.mdia.minf.stbl.boxes.indexOf(f);if(l!=-1)t.mdia.minf.stbl.boxes[l]=null}};s.prototype.buildSampleLists=function(){var e,t,r;var i,n,a,s,o,f,l,u,c;var p,d,h,m,v;var g,_,y,b,w,x;this.originalMvex=this.moov.mvex;for(e=0;e<this.moov.traks.length;e++){i=this.moov.traks[e];i.samples=[];n=i.mdia.minf.stbl.stco||i.mdia.minf.stbl.co64;a=i.mdia.minf.stbl.stsc;s=i.mdia.minf.stbl.stsz;o=i.mdia.minf.stbl.stts;f=i.mdia.minf.stbl.ctts;l=i.mdia.minf.stbl.stss;u=i.mdia.minf.stbl.stsd;c=i.mdia.minf.stbl.subs;g=-1;_=-1;y=-1;b=-1;w=0;subs_entry_index=0;last_subs_sample_index=0;for(t=0;t<s.sample_sizes.length;t++){var k={};k.number=t;k.track_id=i.tkhd.track_id;k.timescale=i.mdia.mdhd.timescale;i.samples[t]=k;k.size=s.sample_sizes[t];if(t===0){d=1;p=0;k.chunk_index=d;k.chunk_run_index=p;v=a.samples_per_chunk[p];m=0;if(p+1<a.first_chunk.length){h=a.first_chunk[p+1]-1}else{h=Infinity}}else{if(t<v){k.chunk_index=d;k.chunk_run_index=p}else{d++;k.chunk_index=d;m=0;if(d<=h){}else{p++;if(p+1<a.first_chunk.length){h=a.first_chunk[p+1]-1}else{h=Infinity}}k.chunk_run_index=p;v+=a.samples_per_chunk[p]}}k.description=u.entries[a.sample_description_index[k.chunk_run_index]-1];k.offset=n.chunk_offsets[k.chunk_index-1]+m;m+=k.size;if(t>g){_++;if(g<0){g=0}g+=o.sample_counts[_]}if(t>0){i.samples[t-1].duration=o.sample_deltas[_];k.dts=i.samples[t-1].dts+i.samples[t-1].duration}else{k.dts=0}if(f){if(t>y){b++;y+=f.sample_counts[b]}k.cts=i.samples[t].dts+f.sample_offsets[b]}else{k.cts=k.dts}if(l){if(t==l.sample_numbers[w]-1){k.is_rap=true;w++}else{k.is_rap=false}}else{k.is_rap=true}if(c){if(c.samples[subs_entry_index].sample_delta+last_subs_sample_index==t){k.subsamples=c.samples[subs_entry_index].subsamples;last_subs_sample_index+=c.samples[subs_entry_index].sample_delta}}}if(t>0)i.samples[t-1].duration=i.mdia.mdhd.duration-i.samples[t-1].dts}};s.prototype.updateSampleLists=function(){var e,t,r;var n,a,s,o;var f;var l,u,c,p,d;var h;while(this.lastMoofIndex<this.moofs.length){l=this.moofs[this.lastMoofIndex];this.lastMoofIndex++;if(l.type=="moof"){u=l;for(e=0;e<u.trafs.length;e++){c=u.trafs[e];p=this.getTrackById(c.tfhd.track_id);d=this.getTrexById(c.tfhd.track_id);if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_DESC){n=c.tfhd.default_sample_description_index}else{n=d.default_sample_description_index}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_DUR){a=c.tfhd.default_sample_duration}else{a=d.default_sample_duration}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_SIZE){s=c.tfhd.default_sample_size}else{s=d.default_sample_size}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_FLAGS){o=c.tfhd.default_sample_flags}else{o=d.default_sample_flags}for(t=0;t<c.truns.length;t++){var m=c.truns[t];for(r=0;r<m.sample_count;r++){h={};c.first_sample_index=p.samples.length;p.samples.push(h);h.track_id=p.tkhd.track_id;h.timescale=p.mdia.mdhd.timescale;h.description=p.mdia.minf.stbl.stsd.entries[n-1];h.size=s;if(m.flags&i.TRUN_FLAGS_SIZE){h.size=m.sample_size[r]}h.duration=a;if(m.flags&i.TRUN_FLAGS_DURATION){h.duration=m.sample_duration[r]}if(p.first_traf_merged||r>0){h.dts=p.samples[p.samples.length-2].dts+p.samples[p.samples.length-2].duration}else{if(c.tfdt){h.dts=c.tfdt.baseMediaDecodeTime}else{h.dts=0}p.first_traf_merged=true}h.cts=h.dts;if(m.flags&i.TRUN_FLAGS_CTS_OFFSET){h.cts=h.dts+m.sample_composition_time_offset[r]}sample_flags=o;if(m.flags&i.TRUN_FLAGS_FLAGS){sample_flags=m.sample_flags[r]}else if(r===0&&m.flags&i.TRUN_FLAGS_FIRST_FLAG){sample_flags=m.first_sample_flags}h.is_rap=sample_flags>>16&1?false:true;var v=c.tfhd.flags&i.TFHD_FLAG_BASE_DATA_OFFSET?true:false;var g=c.tfhd.flags&i.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?true:false;var _=m.flags&i.TRUN_FLAGS_DATA_OFFSET?true:false;var y=0;if(!v){if(!g){if(t===0){y=u.fileStart}else{y=f}}else{y=u.fileStart}}else{y=c.tfhd.base_data_offset}if(t===0&&r===0){if(_){h.offset=y+m.data_offset}else{h.offset=y}}else{h.offset=f}f=h.offset+h.size}}if(c.subs){var b=c.first_sample_index;for(t=0;t<c.subs.samples.length;t++){b+=c.subs.samples[t].sample_delta;h=p.samples[b-1];h.subsamples=c.subs.samples[t].subsamples}}}}}};s.prototype.getCodecs=function(){var e;var t="";for(e=0;e<this.moov.traks.length;e++){var r=this.moov.traks[e];if(e>0){t+=","}t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t};s.prototype.getTrexById=function(e){var t;if(!this.originalMvex)return null;for(t=0;t<this.originalMvex.trexs.length;t++){var r=this.originalMvex.trexs[t];if(r.track_id==e)return r}return null};s.prototype.getTrackById=function(e){for(var t=0;t<this.moov.traks.length;t++){var r=this.moov.traks[t];if(r.tkhd.track_id==e)return r}return null};s.prototype.getSample=function(e,t){var r;var i;var s=e.samples[t];if(!this.moov){return null}if(!s.data){s.data=new Uint8Array(s.size);s.alreadyRead=0;this.samplesDataSize+=s.size;a.d("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+s.size+" (total: "+this.samplesDataSize+")")}else if(s.alreadyRead==s.size){return s}for(i=0;i<this.stream.nextBuffers.length;i++){r=this.stream.nextBuffers[i];if(s.offset+s.alreadyRead>=r.fileStart&&s.offset+s.alreadyRead<r.fileStart+r.byteLength){var o=r.byteLength-(s.offset+s.alreadyRead-r.fileStart);if(s.size-s.alreadyRead<=o){a.d("ISOFile","Getting sample #"+t+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-r.fileStart)+" size: "+(s.size-s.alreadyRead)+")");n.memcpy(s.data.buffer,s.alreadyRead,r,s.offset+s.alreadyRead-r.fileStart,s.size-s.alreadyRead);s.alreadyRead=s.size;r.usedBytes+=s.size-s.alreadyRead;if(r.usedBytes===r.byteLength){this.stream.nextBuffers.splice(i,1);i--}return s}else{a.d("ISOFile","Getting sample data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-r.fileStart)+" size: "+o+")");n.memcpy(s.data.buffer,s.alreadyRead,r,s.offset+s.alreadyRead-r.fileStart,o);s.alreadyRead+=o;r.usedBytes+=o;if(r.usedBytes===r.byteLength){this.stream.nextBuffers.splice(i,1);i--}}}}return null};s.prototype.releaseSample=function(e,t){var r=e.samples[t];r.data=null;this.samplesDataSize-=r.size;return r.size}},{"./DataStream":236,"./box":237,"./log":240}],240:[function(e,t,r){var i=function(){var e=new Date;var t=4;var r=3;var n=2;var a=1;var s=t;var o={setLogLevel:function(e){if(e==this.d)s=a;else if(e==this.i)s=n;else if(e==this.w)s=r;else if(e==this.e)s=t;else s=t},d:function(t,r){if(a>=s){console.debug("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)}},i:function(t,r){if(n>=s){console.info("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)}},w:function(t,n){if(r>=s){console.warn("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",n)}},e:function(r,n){if(t>=s){console.error("["+i.getDurationString(new Date-e,1e3)+"]","["+r+"]",n)}}};return o}();t.exports=i;i.getDurationString=function(e,t){function r(e,t){var r=""+e;var i=r.split(".");while(i[0].length<t){i[0]="0"+i[0]}return i.join(".")}var i=t||1;var n=e/i;var a=Math.floor(n/3600);n-=a*3600;var s=Math.floor(n/60);n-=s*60;var o=n*1e3;n=Math.floor(n);o-=n*1e3;o=Math.floor(o);return""+a+":"+r(s,2)+":"+r(n,2)+"."+r(o,3)};i.printRanges=function(e){var t=e.length;if(t>0){var r="";for(var n=0;n<t;n++){if(n>0)r+=",";r+="["+i.getDurationString(e.start(n))+","+i.getDurationString(e.end(n))+"]"}return r}else{return"(empty)"}}},{}],241:[function(e,t,r){var n=e("./box");var a=e("./DataStream");var s=e("./isofile");var o=e("./log");var f=function(){this.inputStream=null;this.nextBuffers=[];this.inputIsoFile=null;this.onMoovStart=null;this.moovStartSent=false;this.onReady=null;this.readySent=false;this.onSegment=null;this.onSamples=null;this.onError=null;this.sampleListBuilt=false;this.fragmentedTracks=[];this.extractedTracks=[];this.isFragmentationStarted=false;this.nextMoofNumber=0};t.exports=f;f.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n);n.id=e;n.user=t;n.trak=i;i.nextSample=0;n.segmentStream=null;n.nb_samples=1e3;n.rapAlignement=true;if(r){if(r.nbSamples)n.nb_samples=r.nbSamples;if(r.rapAlignement)n.rapAlignement=r.rapAlignement}}};f.prototype.unsetSegmentOptions=function(e){var t=-1;for(var r=0;r<this.fragmentedTracks.length;r++){var i=this.fragmentedTracks[r];if(i.id==e){t=r}}if(t>-1){this.fragmentedTracks.splice(t,1)}};f.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n);n.id=e;n.user=t;n.trak=i;i.nextSample=0;n.nb_samples=1e3;n.samples=[];if(r){if(r.nbSamples)n.nb_samples=r.nbSamples}}};f.prototype.unsetExtractionOptions=function(e){var t=-1;for(var r=0;r<this.extractedTracks.length;r++){var i=this.extractedTracks[r];if(i.id==e){t=r}}if(t>-1){this.extractedTracks.splice(t,1)}};f.prototype.createSingleSampleMoof=function(e){var t=new n.moofBox;var r=new n.mfhdBox;r.sequence_number=this.nextMoofNumber;this.nextMoofNumber++;t.boxes.push(r);var i=new n.trafBox;t.boxes.push(i);var a=new n.tfhdBox;i.boxes.push(a);a.track_id=e.track_id;a.flags=n.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new n.tfdtBox;i.boxes.push(s);s.baseMediaDecodeTime=e.dts;var o=new n.trunBox;i.boxes.push(o);t.trun=o;o.flags=n.TRUN_FLAGS_DATA_OFFSET|n.TRUN_FLAGS_DURATION|n.TRUN_FLAGS_SIZE|n.TRUN_FLAGS_FLAGS|n.TRUN_FLAGS_CTS_OFFSET;o.data_offset=0;o.first_sample_flags=0;o.sample_count=1;o.sample_duration=[];o.sample_duration[0]=e.duration;o.sample_size=[];o.sample_size[0]=e.size;o.sample_flags=[];o.sample_flags[0]=0;o.sample_composition_time_offset=[];o.sample_composition_time_offset[0]=e.cts-e.dts;return t};f.prototype.createFragment=function(e,t,r,i){var s=this.inputIsoFile.getTrackById(t);var f=this.inputIsoFile.getSample(s,r);if(f==null){if(this.nextSeekPosition){this.nextSeekPosition=Math.min(s.samples[r].offset,this.nextSeekPosition)}else{this.nextSeekPosition=s.samples[r].offset}return null}var l=i||new a;l.endianness=a.BIG_ENDIAN;var u=this.createSingleSampleMoof(f);u.write(l);u.trun.data_offset=u.size+8;o.d("BoxWriter","Adjusting data_offset with new value "+u.trun.data_offset);l.adjustUint32(u.trun.data_offset_position,u.trun.data_offset);var c=new n.mdatBox;c.data=f.data;c.write(l);return l};ArrayBuffer.concat=function(e,t){o.d("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var r=new Uint8Array(e.byteLength+t.byteLength);r.set(new Uint8Array(e),0);r.set(new Uint8Array(t),e.byteLength);return r.buffer};f.prototype.reduceBuffer=function(e,t,r){var i;i=new Uint8Array(r);i.set(new Uint8Array(e,t,r));i.buffer.fileStart=e.fileStart+t;i.buffer.usedBytes=0;return i.buffer};f.prototype.insertBuffer=function(e){var t=true;for(var r=0;r<this.nextBuffers.length;r++){var i=this.nextBuffers[r];if(e.fileStart<=i.fileStart){if(e.fileStart===i.fileStart){if(e.byteLength>i.byteLength){this.nextBuffers.splice(r,1);r--;continue}else{o.w("MP4Box","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}}else{if(e.fileStart+e.byteLength<=i.fileStart){}else{e=this.reduceBuffer(e,0,i.fileStart-e.fileStart)}o.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")");this.nextBuffers.splice(r,0,e);if(r===0&&this.inputStream!==null){this.inputStream.buffer=e}}t=false;break}else if(e.fileStart<i.fileStart+i.byteLength){var n=i.fileStart+i.byteLength-e.fileStart;var a=e.byteLength-n;if(a>0){e=this.reduceBuffer(e,n,a)}else{t=false;break}}}if(t){o.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")");this.nextBuffers.push(e);if(r===0&&this.inputStream!==null){this.inputStream.buffer=e}}};f.prototype.processSamples=function(){var e;var t;if(this.isFragmentationStarted&&this.onSegment!==null){for(e=0;e<this.fragmentedTracks.length;e++){var r=this.fragmentedTracks[e];t=r.trak;while(t.nextSample<t.samples.length){o.d("MP4Box","Creating media fragment on track #"+r.id+" for sample "+t.nextSample);var i=this.createFragment(this.inputIsoFile,r.id,t.nextSample,r.segmentStream);if(i){r.segmentStream=i;t.nextSample++}else{break}if(t.nextSample%r.nb_samples===0||t.nextSample>=t.samples.length){o.i("MP4Box","Sending fragmented data on track #"+r.id+" for samples ["+(t.nextSample-r.nb_samples)+","+(t.nextSample-1)+"]");if(this.onSegment){this.onSegment(r.id,r.user,r.segmentStream.buffer,t.nextSample)}r.segmentStream=null;if(r!==this.fragmentedTracks[e]){break}}}}}if(this.onSamples!==null){for(e=0;e<this.extractedTracks.length;e++){var n=this.extractedTracks[e];t=n.trak;while(t.nextSample<t.samples.length){o.d("MP4Box","Exporting on track #"+n.id+" sample #"+t.nextSample);var a=this.inputIsoFile.getSample(t,t.nextSample);if(a){t.nextSample++;n.samples.push(a)}else{return}if(t.nextSample%n.nb_samples===0||t.nextSample>=t.samples.length){o.d("MP4Box","Sending samples on track #"+n.id+" for sample "+t.nextSample);if(this.onSamples){this.onSamples(n.id,n.user,n.samples)}n.samples=[];if(n!==this.extractedTracks[e]){break}}}}}};f.prototype.appendBuffer=function(e){var t;var r;if(e===null||e===undefined){throw"Buffer must be defined and non empty"}if(e.fileStart===undefined){throw"Buffer must have a fileStart property"}if(e.byteLength===0){o.w("MP4Box","Ignoring empty buffer (fileStart: "+e.fileStart+")");return}e.usedBytes=0;this.insertBuffer(e);if(!this.inputStream){if(this.nextBuffers.length>0){r=this.nextBuffers[0];if(r.fileStart===0){this.inputStream=new a(r,0,a.BIG_ENDIAN);this.inputStream.nextBuffers=this.nextBuffers;this.inputStream.bufferIndex=0}else{o.w("MP4Box","The first buffer should have a fileStart of 0");return}}else{o.w("MP4Box","No buffer to start parsing from");return}}if(!this.inputIsoFile){this.inputIsoFile=new s(this.inputStream)}this.inputIsoFile.parse();if(this.inputIsoFile.moovStartFound&&!this.moovStartSent){this.moovStartSent=true;if(this.onMoovStart)this.onMoovStart()}if(this.inputIsoFile.moov){if(!this.sampleListBuilt){this.inputIsoFile.buildSampleLists();this.sampleListBuilt=true}this.inputIsoFile.updateSampleLists();if(this.onReady&&!this.readySent){var i=this.getInfo();this.readySent=true;this.onReady(i)}this.processSamples();if(this.nextSeekPosition){t=this.nextSeekPosition;this.nextSeekPosition=undefined}else{t=this.inputIsoFile.nextParsePosition}var n=this.inputIsoFile.findPosition(true,t);if(n!==-1){t=this.inputIsoFile.findEndContiguousBuf(n)}o.i("MP4Box","Next buffer to fetch should have a fileStart position of "+t);return t}else{if(this.inputIsoFile!==null){return this.inputIsoFile.nextParsePosition}else{return 0}}};f.prototype.getInfo=function(){var e={};var t;var r;var n;var a=new Date(4,0,1,0,0,0,0).getTime();e.duration=this.inputIsoFile.moov.mvhd.duration;e.timescale=this.inputIsoFile.moov.mvhd.timescale;e.isFragmented=this.inputIsoFile.moov.mvex!=null;if(e.isFragmented&&this.inputIsoFile.moov.mvex.mehd){e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration}else{e.fragment_duration=0}e.isProgressive=this.inputIsoFile.isProgressive;e.hasIOD=this.inputIsoFile.moov.iods!=null;e.brands=[];e.brands.push(this.inputIsoFile.ftyp.major_brand);e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);e.created=new Date(a+this.inputIsoFile.moov.mvhd.creation_time*1e3);e.modified=new Date(a+this.inputIsoFile.moov.mvhd.modification_time*1e3);e.tracks=[];e.audioTracks=[];e.videoTracks=[];e.subtitleTracks=[];e.metadataTracks=[];e.hintTracks=[];e.otherTracks=[];for(i=0;i<this.inputIsoFile.moov.traks.length;i++){t=this.inputIsoFile.moov.traks[i];n=t.mdia.minf.stbl.stsd.entries[0];r={};e.tracks.push(r);r.id=t.tkhd.track_id;r.references=[];if(t.tref){for(j=0;j<t.tref.boxes.length;j++){ref={};r.references.push(ref);ref.type=t.tref.boxes[j].type;ref.track_ids=t.tref.boxes[j].track_ids}}r.created=new Date(a+t.tkhd.creation_time*1e3);r.modified=new Date(a+t.tkhd.modification_time*1e3);r.movie_duration=t.tkhd.duration;r.layer=t.tkhd.layer;r.alternate_group=t.tkhd.alternate_group;r.volume=t.tkhd.volume;r.matrix=t.tkhd.matrix;r.track_width=t.tkhd.width/(1<<16);r.track_height=t.tkhd.height/(1<<16);r.timescale=t.mdia.mdhd.timescale;r.duration=t.mdia.mdhd.duration;r.codec=n.getCodec();r.language=t.mdia.mdhd.languageString;r.nb_samples=t.samples.length;r.size=0;for(j=0;j<r.nb_samples;j++){r.size+=t.samples[j].size}r.bitrate=r.size*8*r.timescale/r.duration;if(n.isAudio()){e.audioTracks.push(r);r.audio={};r.audio.sample_rate=n.getSampleRate();r.audio.channel_count=n.getChannelCount();r.audio.sample_size=n.getSampleSize()}else if(n.isVideo()){e.videoTracks.push(r);r.video={};r.video.width=n.getWidth();r.video.height=n.getHeight()}else if(n.isSubtitle()){e.subtitleTracks.push(r)}else if(n.isHint()){e.hintTracks.push(r)}else if(n.isMetadata()){e.metadataTracks.push(r)}else{e.otherTracks.push(r)}}return e};f.prototype.getInitializationSegment=function(){var e=new a;e.endianness=a.BIG_ENDIAN;this.inputIsoFile.writeInitializationSegment(e);return e.buffer};f.prototype.writeFile=function(){var e=new a;e.endianness=a.BIG_ENDIAN;this.inputIsoFile.write(e);return e.buffer};f.prototype.initializeSegmentation=function(){var e;var t;var r;var i;var n;if(this.onSegment===null){o.w("MP4Box","No segmentation callback set!")}if(!this.isFragmentationStarted){this.isFragmentationStarted=true;this.nextMoofNumber=0;this.inputIsoFile.resetTables()}i=[];for(e=0;e<this.fragmentedTracks.length;e++){for(t=0;t<this.inputIsoFile.moov.boxes.length;t++){r=this.inputIsoFile.moov.boxes[t];if(r&&r.type==="trak"){this.inputIsoFile.moov.boxes[t].ignore=true;this.inputIsoFile.moov.boxes[t]=null}}n=this.inputIsoFile.getTrackById(this.fragmentedTracks[e].id);delete n.ignore;for(t=0;t<this.inputIsoFile.moov.boxes.length;t++){r=this.inputIsoFile.moov.boxes[t];if(r==null){this.inputIsoFile.moov.boxes[t]=n;break}}seg={};seg.id=n.tkhd.track_id;seg.user=this.fragmentedTracks[e].user;seg.buffer=this.getInitializationSegment();i.push(seg)}return i};f.prototype.releaseUsedSamples=function(e,t){var r=0;var i=this.inputIsoFile.getTrackById(e);if(!i.lastValidSample)i.lastValidSample=0;for(var n=i.lastValidSample;n<t;n++){r+=this.inputIsoFile.releaseSample(i,n)}o.d("MP4Box","Track #"+e+" released samples up to "+t+" (total size: "+r+", remaining: "+this.inputIsoFile.samplesDataSize+")");i.lastValidSample=t};f.prototype.flush=function(){o.i("MP4Box","Flushing remaining samples");this.inputIsoFile.updateSampleLists();this.processSamples()};f.prototype.seekTrack=function(e,t,r){var i;var n;var a=Infinity;var s=0;var f=Infinity;var l=0;var u=0;var c;for(i=0;i<r.samples.length;i++){n=r.samples[i];if(i===0){f=n.offset;u=0;c=n.timescale}else if(n.cts>e*n.timescale){f=r.samples[i-1].offset;u=i-1;break}if(t&&n.is_rap){a=n.offset;s=n.cts;l=i}}if(t){r.nextSample=l;o.i("MP4Box","Seeking to RAP sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(s,c)+" and offset: "+a);return{offset:a,time:s/c}}else{r.nextSample=u;o.i("MP4Box","Seeking to non-RAP sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(e)+" and offset: "+a);return{offset:f,time:e}}};f.prototype.seek=function(e,t){var r=this.inputIsoFile.moov;var i;var n;var a;var s={offset:Infinity,time:Infinity};if(!this.inputIsoFile.moov){throw"Cannot seek: moov not received!"}else{for(a=0;a<r.traks.length;a++){i=r.traks[a];n=this.seekTrack(e,t,i);if(n.offset<s.offset){s.offset=n.offset}if(n.time<s.time){s.time=n.time}}if(s.offset===Infinity){s={offset:this.inputIsoFile.nextParsePosition,time:0}}else{var f=this.inputIsoFile.findPosition(true,s.offset);if(f!==-1){s.offset=this.inputIsoFile.findEndContiguousBuf(f);
-}}o.i("MP4Box","Seeking at time "+o.getDurationString(s.time,1)+" needs a buffer with a fileStart position of "+s.offset);return s}}},{"./DataStream":236,"./box":237,"./isofile":239,"./log":240}],242:[function(e,t,r){var i=e("debug")();var n=e("mp4box");var a=1e7;var s=1e6;var o=5e3;t.exports=function(e,t,r){r=r||{};var l=r.debugTrack||-1;var u=[];t.addEventListener("waiting",function(){if(d){b(t.currentTime)}});var c=new MediaSource;c.addEventListener("sourceopen",function(){y(0)});t.src=window.URL.createObjectURL(c);var p=new n;p.onError=function(e){i("MP4Box error: %s",e.message);if(_){_()}if(c.readyState==="open"){c.endOfStream("decode")}};var d=false;var h=0;var m={};p.onReady=function(e){i("MP4 info: %o",e);e.tracks.forEach(function(e){var t;if(e.video){t="video/mp4"}else if(e.audio){t="audio/mp4"}else{return}t+='; codecs="'+e.codec+'"';if(MediaSource.isTypeSupported(t)){var r=c.addSourceBuffer(t);var i={buffer:r,arrayBuffers:[],meta:e,ended:false};r.addEventListener("updateend",x.bind(null,i));p.setSegmentOptions(e.id,null,{nbSamples:e.video?1:100});m[e.id]=i}});if(Object.keys(m).length===0){c.endOfStream("decode");return}var t=p.initializeSegmentation();t.forEach(function(e){w(m[e.id],e.buffer);if(e.id===l){f("init-track-"+l+".mp4",[e.buffer]);u.push(e.buffer)}});d=true};p.onSegment=function(e,t,r,i){var n=m[e];w(n,r,i===n.meta.nb_samples);if(e===l&&u){u.push(r);if(i>1e3){f("track-"+l+".mp4",u);u=null}}};var v;var g=null;var _=null;function y(t){if(t===e.length){p.flush();return}if(g&&t===v){return}if(g){g.destroy();_()}v=t;var r={start:v,end:e.length-1};g=e.createReadStream(r);function n(e){g.pause();if(h<=a){k()}var t=e.toArrayBuffer();t.fileStart=v;v+=t.byteLength;var r;try{r=p.appendBuffer(t)}catch(n){i("MP4Box threw exception: %s",n.message);if(c.readyState==="open"){c.endOfStream("decode")}g.destroy();_();return}y(r)}g.on("data",n);function s(){_();y(v)}g.on("end",s);function o(e){i("Stream error: %s",e.message);if(c.readyState==="open"){c.endOfStream("network")}}g.on("error",o);_=function(){g.removeListener("data",n);g.removeListener("end",s);g.removeListener("error",o);g=null;_=null}}function b(e){var t=p.seek(e,true);i("Seeking to time: %d",e);i("Seeked file offset: %d",t.offset);y(t.offset);k()}function w(e,t,r){h+=t.byteLength;e.arrayBuffers.push({buffer:t,ended:r||false});x(e)}function x(e){if(e.buffer.updating||e.arrayBuffers.length===0)return;var t=e.arrayBuffers.shift();var r=false;try{e.buffer.appendBuffer(t.buffer);e.ended=t.ended;r=true}catch(n){i("SourceBuffer error: %s",n.message);e.arrayBuffers.unshift(t);setTimeout(function(){x(e)},o)}if(r){h-=t.buffer.byteLength;if(h<=s){k()}S()}}function k(){setTimeout(function(){if(g){if(g.isPaused?g.isPaused():!g._readableState.flowing){g.resume()}}})}function S(){if(c.readyState!=="open"){return}var e=Object.keys(m).every(function(e){var t=m[e];return t.ended&&!t.buffer.updating});if(e&&c.readyState==="open"){c.endOfStream()}}};function f(e,t){var r=new Blob(t);var i=URL.createObjectURL(r);var n=document.createElement("a");n.setAttribute("href",i);n.setAttribute("download",e);n.click()}},{debug:216,mp4box:241}],243:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{dup:14}],244:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.53.1",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./lib/server":false,"bittorrent-dht/client":false,"load-ip-set":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","block-stream2":"^1.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0",dezalgo:"^1.0.1","end-of-stream":"^1.0.0",hat:"0.0.3",inherits:"^2.0.1",inquirer:"^0.8.0","load-ip-set":"^1.0.3",mime:"^1.2.11",minimist:"^1.1.0",mkdirp:"^0.5.0",moment:"^2.8.3",multistream:"^1.4.2","network-address":"^1.0.0",once:"^1.3.1","parse-torrent":"^5.1.0","pretty-bytes":"^2.0.1",pump:"^1.0.0","random-access-file":"^0.3.1","range-parser":"^1.0.2","re-emitter":"^1.0.0",rimraf:"^2.2.5","run-parallel":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1",videostream:"^1.1.4","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^5.0.0",brfs:"^1.2.0",browserify:"^10.0.0",finalhandler:"^0.3.6","run-auto":"^1.0.0","serve-static":"^1.9.3","simple-get":"^1.0.0",standard:"^4.0.1",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}],245:[function(e,t,r){(function(r,i,n){t.exports=k;var a=e("create-torrent");var s=e("debug")("webtorrent");var o=e("bittorrent-dht/client");var f=e("events").EventEmitter;var l=e("xtend");var u=e("hat");var c=e("inherits");var p=e("load-ip-set");var d=e("run-parallel");var h=e("parse-torrent");var m=e("speedometer");var v=e("zero-fill");var g=e("path");var _=e("./lib/fs-storage");var y=e("./lib/storage");var b=e("./lib/torrent");c(k,f);var w=e("./package.json").version;var x=w.match(/([0-9]+)/g).slice(0,2).map(v(2)).join("");function k(e){var t=this;if(!(t instanceof k))return new k(e);if(!e)e={};f.call(t);if(!s.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||i.WRTC;t.torrents=[];t.downloadSpeed=m();t.uploadSpeed=m();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof _==="function"?_:y;t.peerId=e.peerId===undefined?new n("-WW"+x+"-"+u(48),"utf8"):typeof e.peerId==="string"?new n(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new n(u(160),"hex"):typeof e.nodeId==="string"?new n(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof o==="function"){t.dht=new o(l({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}s("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof p==="function"){p(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e)return t.error("failed to load blocklist: "+e.message);t.blocked=r;a()})}else r.nextTick(a);function a(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(k.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var r=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/r}});k.prototype.get=function(e){var t=this;if(e instanceof b)return e;var r;try{r=h(e)}catch(i){return null}if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var n=0,a=t.torrents.length;n<a;n++){var s=t.torrents[n];if(s.infoHash===r.infoHash)return s}return null};k.prototype.add=k.prototype.download=function(e,t,i){var n=this;if(n.destroyed)throw new Error("client is destroyed");s("add");if(typeof t==="function"){i=t;t={}}if(!t)t={};if(!t.storage)t.storage=n.storage;t.client=n;var a=n.get(e);function o(){s("on torrent");if(typeof i==="function")i(a)}if(a){if(a.ready)r.nextTick(o);else a.on("ready",o)}else{a=new b(e,t);n.torrents.push(a);a.on("error",function(e){n.emit("error",e,a);n.remove(a)});a.on("listening",function(e){n.emit("listening",e,a)});a.on("ready",function(){o();n.emit("torrent",a)})}return a};k.prototype.seed=function(e,t,r){var i=this;if(i.destroyed)throw new Error("client is destroyed");s("seed");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.noVerify=true;t.createdBy="WebTorrent/"+w;if(typeof e==="string"&&!t.path)t.path=g.dirname(e);var n;var o=i.add(undefined,t,function(e){var t=[function(t){e.storage.load(n,t)}];if(i.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return i.emit("error",t);f();i.emit("seed",e)})});a.parseInput(e,t,function(r,s){if(r)return i.emit("error",r);n=s.map(function(e){return e.getStream});a(e,t,function(e,t){if(e)return i.emit("error",e);if(i.destroyed)return;var r=i.get(t);if(r){o.destroy();f();return}else{o._onTorrentId(t)}})});function f(){s("on seed");if(typeof r==="function")r(o)}return o};k.prototype.remove=function(e,t){var r=this;var i=r.get(e);if(!i)throw new Error("No torrent with id "+e);s("remove");r.torrents.splice(r.torrents.indexOf(i),1);i.destroy(t)};k.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};k.prototype.destroy=function(e){var t=this;t.destroyed=true;s("destroy");var r=t.torrents.map(function(e){return function(r){t.remove(e,r)}});if(t.dht){r.push(function(e){t.dht.destroy(e)})}d(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/fs-storage":169,"./lib/storage":153,"./lib/torrent":154,"./package.json":244,_process:195,"bittorrent-dht/client":169,buffer:183,"create-torrent":46,debug:216,events:187,hat:224,inherits:225,"load-ip-set":169,"parse-torrent":95,path:194,"run-parallel":101,speedometer:234,xtend:243,"zero-fill":246}],246:[function(e,t,r){t.exports=function i(e,t,r){if(t===undefined){return function(t,r){return i(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}]},{},[245])(245)});
+}}o.i("MP4Box","Seeking at time "+o.getDurationString(s.time,1)+" needs a buffer with a fileStart position of "+s.offset);return s}}},{"./DataStream":236,"./box":237,"./isofile":239,"./log":240}],242:[function(e,t,r){var i=e("debug")();var n=e("mp4box");var a=1e7;var s=1e6;var o=5e3;t.exports=function(e,t,r){r=r||{};var l=r.debugTrack||-1;var u=[];t.addEventListener("waiting",function(){if(d){b(t.currentTime)}});var c=new MediaSource;c.addEventListener("sourceopen",function(){y(0)});t.src=window.URL.createObjectURL(c);var p=new n;p.onError=function(e){i("MP4Box error: %s",e.message);if(_){_()}if(c.readyState==="open"){c.endOfStream("decode")}};var d=false;var h=0;var m={};p.onReady=function(e){i("MP4 info: %o",e);e.tracks.forEach(function(e){var t;if(e.video){t="video/mp4"}else if(e.audio){t="audio/mp4"}else{return}t+='; codecs="'+e.codec+'"';if(MediaSource.isTypeSupported(t)){var r=c.addSourceBuffer(t);var i={buffer:r,arrayBuffers:[],meta:e,ended:false};r.addEventListener("updateend",x.bind(null,i));p.setSegmentOptions(e.id,null,{nbSamples:e.video?1:100});m[e.id]=i}});if(Object.keys(m).length===0){c.endOfStream("decode");return}var t=p.initializeSegmentation();t.forEach(function(e){w(m[e.id],e.buffer);if(e.id===l){f("init-track-"+l+".mp4",[e.buffer]);u.push(e.buffer)}});d=true};p.onSegment=function(e,t,r,i){var n=m[e];w(n,r,i===n.meta.nb_samples);if(e===l&&u){u.push(r);if(i>1e3){f("track-"+l+".mp4",u);u=null}}};var v;var g=null;var _=null;function y(t){if(t===e.length){p.flush();return}if(g&&t===v){return}if(g){g.destroy();_()}v=t;var r={start:v,end:e.length-1};g=e.createReadStream(r);function n(e){g.pause();if(h<=a){k()}var t=e.toArrayBuffer();t.fileStart=v;v+=t.byteLength;var r;try{r=p.appendBuffer(t)}catch(n){i("MP4Box threw exception: %s",n.message);if(c.readyState==="open"){c.endOfStream("decode")}g.destroy();_();return}y(r)}g.on("data",n);function s(){_();y(v)}g.on("end",s);function o(e){i("Stream error: %s",e.message);if(c.readyState==="open"){c.endOfStream("network")}}g.on("error",o);_=function(){g.removeListener("data",n);g.removeListener("end",s);g.removeListener("error",o);g=null;_=null}}function b(e){var t=p.seek(e,true);i("Seeking to time: %d",e);i("Seeked file offset: %d",t.offset);y(t.offset);k()}function w(e,t,r){h+=t.byteLength;e.arrayBuffers.push({buffer:t,ended:r||false});x(e)}function x(e){if(e.buffer.updating||e.arrayBuffers.length===0)return;var t=e.arrayBuffers.shift();var r=false;try{e.buffer.appendBuffer(t.buffer);e.ended=t.ended;r=true}catch(n){i("SourceBuffer error: %s",n.message);e.arrayBuffers.unshift(t);setTimeout(function(){x(e)},o)}if(r){h-=t.buffer.byteLength;if(h<=s){k()}S()}}function k(){setTimeout(function(){if(g){if(g.isPaused?g.isPaused():!g._readableState.flowing){g.resume()}}})}function S(){if(c.readyState!=="open"){return}var e=Object.keys(m).every(function(e){var t=m[e];return t.ended&&!t.buffer.updating});if(e&&c.readyState==="open"){c.endOfStream()}}};function f(e,t){var r=new Blob(t);var i=URL.createObjectURL(r);var n=document.createElement("a");n.setAttribute("href",i);n.setAttribute("download",e);n.click()}},{debug:216,mp4box:241}],243:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{dup:14}],244:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.53.2",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./lib/server":false,"bittorrent-dht/client":false,"load-ip-set":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","block-stream2":"^1.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0",dezalgo:"^1.0.1","end-of-stream":"^1.0.0",hat:"0.0.3",inherits:"^2.0.1",inquirer:"^0.8.0","load-ip-set":"^1.0.3",mime:"^1.2.11",minimist:"^1.1.0",mkdirp:"^0.5.0",moment:"^2.8.3",multistream:"^1.4.2","network-address":"^1.0.0",once:"^1.3.1","parse-torrent":"^5.1.0","pretty-bytes":"^2.0.1",pump:"^1.0.0","random-access-file":"^0.3.1","range-parser":"^1.0.2","re-emitter":"^1.0.0",rimraf:"^2.2.5","run-parallel":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1",videostream:"^1.1.4","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^5.0.0",brfs:"^1.2.0",browserify:"^10.0.0",finalhandler:"^0.3.6","run-auto":"^1.0.0","serve-static":"^1.9.3","simple-get":"^1.0.0",standard:"^4.0.1",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}],245:[function(e,t,r){(function(r,i,n){t.exports=k;var a=e("create-torrent");var s=e("debug")("webtorrent");var o=e("bittorrent-dht/client");var f=e("events").EventEmitter;var l=e("xtend");var u=e("hat");var c=e("inherits");var p=e("load-ip-set");var d=e("run-parallel");var h=e("parse-torrent");var m=e("speedometer");var v=e("zero-fill");var g=e("path");var _=e("./lib/fs-storage");var y=e("./lib/storage");var b=e("./lib/torrent");c(k,f);var w=e("./package.json").version;var x=w.match(/([0-9]+)/g).slice(0,2).map(v(2)).join("");function k(e){var t=this;if(!(t instanceof k))return new k(e);if(!e)e={};f.call(t);if(!s.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||i.WRTC;t.torrents=[];t.downloadSpeed=m();t.uploadSpeed=m();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof _==="function"?_:y;t.peerId=e.peerId===undefined?new n("-WW"+x+"-"+u(48),"utf8"):typeof e.peerId==="string"?new n(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new n(u(160),"hex"):typeof e.nodeId==="string"?new n(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof o==="function"){t.dht=new o(l({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}s("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof p==="function"){p(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e)return t.error("failed to load blocklist: "+e.message);t.blocked=r;a()})}else r.nextTick(a);function a(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(k.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var r=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/r}});k.prototype.get=function(e){var t=this;if(e instanceof b)return e;var r;try{r=h(e)}catch(i){return null}if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var n=0,a=t.torrents.length;n<a;n++){var s=t.torrents[n];if(s.infoHash===r.infoHash)return s}return null};k.prototype.add=k.prototype.download=function(e,t,i){var n=this;if(n.destroyed)throw new Error("client is destroyed");s("add");if(typeof t==="function"){i=t;t={}}if(!t)t={};if(!t.storage)t.storage=n.storage;t.client=n;var a=n.get(e);function o(){s("on torrent");if(typeof i==="function")i(a)}if(a){if(a.ready)r.nextTick(o);else a.on("ready",o)}else{a=new b(e,t);n.torrents.push(a);a.on("error",function(e){n.emit("error",e,a);n.remove(a)});a.on("listening",function(e){n.emit("listening",e,a)});a.on("ready",function(){o();n.emit("torrent",a)})}return a};k.prototype.seed=function(e,t,r){var i=this;if(i.destroyed)throw new Error("client is destroyed");s("seed");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.noVerify=true;t.createdBy="WebTorrent/"+w;if(typeof e==="string"&&!t.path)t.path=g.dirname(e);var n;var o=i.add(undefined,t,function(e){var t=[function(t){e.storage.load(n,t)}];if(i.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return i.emit("error",t);f();i.emit("seed",e)})});a.parseInput(e,t,function(r,s){if(r)return i.emit("error",r);n=s.map(function(e){return e.getStream});a(e,t,function(e,t){if(e)return i.emit("error",e);if(i.destroyed)return;var r=i.get(t);if(r){o.destroy();f();return}else{o._onTorrentId(t)}})});function f(){s("on seed");if(typeof r==="function")r(o)}return o};k.prototype.remove=function(e,t){var r=this;var i=r.get(e);if(!i)throw new Error("No torrent with id "+e);s("remove");r.torrents.splice(r.torrents.indexOf(i),1);i.destroy(t)};k.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};k.prototype.destroy=function(e){var t=this;t.destroyed=true;s("destroy");var r=t.torrents.map(function(e){return function(r){t.remove(e,r)}});if(t.dht){r.push(function(e){t.dht.destroy(e)})}d(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/fs-storage":169,"./lib/storage":153,"./lib/torrent":154,"./package.json":244,_process:195,"bittorrent-dht/client":169,buffer:183,"create-torrent":46,debug:216,events:187,hat:224,inherits:225,"load-ip-set":169,"parse-torrent":95,path:194,"run-parallel":101,speedometer:234,xtend:243,"zero-fill":246}],246:[function(e,t,r){t.exports=function i(e,t,r){if(t===undefined){return function(t,r){return i(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}]},{},[245])(245)});