1(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.EBML = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ 2"use strict"; 3Object.defineProperty(exports, "__esModule", { value: true }); 4var tools_1 = require("./tools"); 5var int64_buffer_1 = require("int64-buffer"); 6var tools = require("./tools"); 7var schema = require("matroska/lib/schema"); 8var byEbmlID = schema.byEbmlID; 9// https://www.matroska.org/technical/specs/index.html 10var State; 11(function (State) { 12 State[State["STATE_TAG"] = 1] = "STATE_TAG"; 13 State[State["STATE_SIZE"] = 2] = "STATE_SIZE"; 14 State[State["STATE_CONTENT"] = 3] = "STATE_CONTENT"; 15})(State || (State = {})); 16var EBMLDecoder = /** @class */ (function () { 17 function EBMLDecoder() { 18 this._buffer = new tools_1.Buffer(0); 19 this._tag_stack = []; 20 this._state = State.STATE_TAG; 21 this._cursor = 0; 22 this._total = 0; 23 this._schema = byEbmlID; 24 this._result = []; 25 } 26 EBMLDecoder.prototype.decode = function (chunk) { 27 this.readChunk(chunk); 28 var diff = this._result; 29 this._result = []; 30 return diff; 31 }; 32 EBMLDecoder.prototype.readChunk = function (chunk) { 33 // èªã¿ããã®(èªããªãã£ã) this._buffer 㨠æ°ãã chunk ãåããã¦èªã¿ç´ã 34 this._buffer = tools.concat([this._buffer, new tools_1.Buffer(chunk)]); 35 while (this._cursor < this._buffer.length) { 36 // console.log(this._cursor, this._total, this._tag_stack); 37 if (this._state === State.STATE_TAG && !this.readTag()) { 38 break; 39 } 40 if (this._state === State.STATE_SIZE && !this.readSize()) { 41 break; 42 } 43 if (this._state === State.STATE_CONTENT && !this.readContent()) { 44 break; 45 } 46 } 47 }; 48 EBMLDecoder.prototype.getSchemaInfo = function (tagNum) { 49 return this._schema[tagNum] || { 50 name: "unknown", 51 level: -1, 52 type: "unknown", 53 description: "unknown" 54 }; 55 }; 56 /** 57 * vint ããã parsing tag 58 * @return - return false when waiting for more data 59 */ 60 EBMLDecoder.prototype.readTag = function () { 61 // tag.length ã buffer ã®å¤ã«ãã 62 if (this._cursor >= this._buffer.length) { 63 return false; 64 } 65 // read ebml id vint without first byte 66 var tag = tools_1.readVint(this._buffer, this._cursor); 67 // tag ãèªããªãã£ã 68 if (tag == null) { 69 return false; 70 } 71 // >>>>>>>>> 72 // tag èå¥å 73 //const tagStr = this._buffer.toString("hex", this._cursor, this._cursor + tag.length); 74 //const tagNum = parseInt(tagStr, 16); 75 // ä¸ã¨ç価 76 var buf = this._buffer.slice(this._cursor, this._cursor + tag.length); 77 var tagNum = buf.reduce(function (o, v, i, arr) { return o + v * Math.pow(16, 2 * (arr.length - 1 - i)); }, 0); 78 var schema = this.getSchemaInfo(tagNum); 79 var tagObj = { 80 EBML_ID: tagNum.toString(16), 81 schema: schema, 82 type: schema.type, 83 name: schema.name, 84 level: schema.level, 85 tagStart: this._total, 86 tagEnd: this._total + tag.length, 87 sizeStart: this._total + tag.length, 88 sizeEnd: null, 89 dataStart: null, 90 dataEnd: null, 91 dataSize: null, 92 data: null 93 }; 94 // | tag: vint | size: vint | data: Buffer(size) | 95 this._tag_stack.push(tagObj); 96 // <<<<<<<< 97 // ãã¤ã³ã¿ãé²ãã 98 this._cursor += tag.length; 99 this._total += tag.length; 100 // èªã¿è¾¼ã¿ç¶æ 夿´ 101 this._state = State.STATE_SIZE; 102 return true; 103 }; 104 /** 105 * vint ãããç¾å¨ã®ã¿ã°ã®å 容ã®å¤§ãããèªã¿è¾¼ã 106 * @return - return false when waiting for more data 107 */ 108 EBMLDecoder.prototype.readSize = function () { 109 // tag.length ã buffer ã®å¤ã«ãã 110 if (this._cursor >= this._buffer.length) { 111 return false;
112 } 113 // read ebml datasize vint without first byte 114 var size = tools_1.readVint(this._buffer, this._cursor); 115 // ã¾ã èªããªã 116 if (size == null) { 117 return false; 118 } 119 // >>>>>>>>> 120 // current tag ã® data size æ±ºå® 121 var tagObj = this._tag_stack[this._tag_stack.length - 1]; 122 tagObj.sizeEnd = tagObj.sizeStart + size.length; 123 tagObj.dataStart = tagObj.sizeEnd; 124 tagObj.dataSize = size.value; 125 if (size.value === -1) { 126 // unknown size 127 tagObj.dataEnd = -1; 128 if (tagObj.type === "m") { 129 tagObj.unknownSize = true; 130 } 131 } 132 else { 133 tagObj.dataEnd = tagObj.sizeEnd + size.value; 134 } 135 // <<<<<<<< 136 // ãã¤ã³ã¿ãé²ãã 137 this._cursor += size.length; 138 this._total += size.length; 139 this._state = State.STATE_CONTENT; 140 return true; 141 }; 142 /** 143 * ãã¼ã¿èªã¿è¾¼ã¿ 144 */ 145 EBMLDecoder.prototype.readContent = function () { 146 var tagObj = this._tag_stack[this._tag_stack.length - 1]; 147 // master element ã¯åè¦ç´ ãæã¤ã®ã§çãã¼ã¿ã¯ãªã 148 if (tagObj.type === 'm') { 149 // console.log('content should be tags'); 150 tagObj.isEnd = false; 151 this._result.push(tagObj); 152 this._state = State.STATE_TAG; 153 // ãã® Mastert Element ã¯ç©ºè¦ç´ ã 154 if (tagObj.dataSize === 0) { 155 // å³åº§ã«çµäºã¿ã°ã追å 156 var elm = Object.assign({}, tagObj, { isEnd: true }); 157 this._result.push(elm); 158 this._tag_stack.pop(); // ã¹ã¿ãã¯ãããã®ã¿ã°ãæ¨ã¦ã 159 } 160 return true; 161 } 162 // waiting for more data 163 if (this._buffer.length < this._cursor + tagObj.dataSize) { 164 return false; 165 } 166 // ã¿ã°ã®ä¸èº«ã®çãã¼ã¿ 167 var data = this._buffer.slice(this._cursor, this._cursor + tagObj.dataSize); 168 // èªã¿çµãã£ããããã¡ãæ¨ã¦ã¦èªã¿è¾¼ãã§ããé¨åã®ãããã¡ã®ã¿æ®ã 169 this._buffer = this._buffer.slice(this._cursor + tagObj.dataSize); 170 tagObj.data = data; 171 // >>>>>>>>> 172 switch (tagObj.type) { 173 //case "m": break; 174 // Master-Element - contains other EBML sub-elements of the next lower level 175 case "u": 176 tagObj.value = data.readUIntBE(0, data.length); 177 break; 178 // Unsigned Integer - Big-endian, any size from 1 to 8 octets 179 case "i": 180 tagObj.value = data.readIntBE(0, data.length); 181 break; 182 // Signed Integer - Big-endian, any size from 1 to 8 octets 183 case "f": 184 tagObj.value = tagObj.dataSize === 4 ? data.readFloatBE(0) : 185 tagObj.dataSize === 8 ? data.readDoubleBE(0) : 186 (console.warn("cannot read " + tagObj.dataSize + " octets float. failback to 0"), 0); 187 break; 188 // Float - Big-endian, defined for 4 and 8 octets (32, 64 bits) 189 case "s": 190 tagObj.value = data.toString("ascii"); 191 break; // ascii 192 // Printable ASCII (0x20 to 0x7E), zero-padded when needed 193 case "8": 194 tagObj.value = data.toString("utf8"); 195 break; 196 // Unicode string, zero padded when needed (RFC 2279) 197 case "b": 198 tagObj.value = data; 199 break; 200 // Binary - not interpreted by the parser 201 case "d": 202 tagObj.value = tools_1.convertEBMLDateToJSDate(new int64_buffer_1.Int64BE(data).toNumber()); 203 break; 204 // nano second; Date.UTC(2001,1,1,0,0,0,0) === 980985600000 205 // Date - signed 8 octets integer in nanoseconds with 0 indicating 206 // the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC) 207 } 208 if (tagObj.value === null) { 209 throw new Error("unknown tag type:" + tagObj.type); 210 } 211 this._result.push(tagObj); 212 // <<<<<<<< 213 // ãã¤ã³ã¿ãé²ãã 214 this._total += tagObj.dataSize; 215 // ã¿ã°å¾ ã¡ã¢ã¼ãã«å¤æ´ 216 this._state = State.STATE_TAG; 217 this._cursor = 0; 218 this._tag_stack.pop(); // remove the object from the stack 219 while (this._tag_stack.length > 0) { 220 var topEle = this._tag_stack[this._tag_stack.length - 1]; 221 // 親ãä¸å®é·ãµã¤ãºãªã®ã§éãã¿ã°ã¯æå¾ ã§ããªã 222 if (topEle.dataEnd < 0) { 223 this._tag_stack.pop(); // 親ã¿ã°ãæ¨ã¦ã 224 return true; 225 } 226 // éãã¿ã°ã®æ¥ãã¹ãå ´æã¾ã§æ¥ããã©ãã 227 if (this._total < topEle.dataEnd) { 228 break; 229 } 230 // éãã¿ã°ãæ¿å ¥ãã¹ãã¿ã¤ãã³ã°ãæ¥ã 231 if (topEle.type !== "m") { 232 throw new Error("parent element is not master element"); 233 } 234 var elm = Object.assign({}, topEle, { isEnd: true }); 235 this._result.push(elm); 236 this._tag_stack.pop(); 237 } 238 return true; 239 }; 240 return EBMLDecoder; 241}()); 242exports.default = EBMLDecoder; 243 244},{"./tools":5,"int64-buffer":15,"matroska/lib/schema":17}],2:[function(require,module,exports){ 245"use strict"; 246Object.defineProperty(exports, "__esModule", { value: true }); 247var tools = require("./tools"); 248var tools_1 = require("./tools"); 249var schema = require("matroska/lib/schema"); 250var byEbmlID = schema.byEbmlID; 251var EBMLEncoder = /** @class */ (function () { 252 function EBMLEncoder() { 253 this._schema = byEbmlID; 254 this._buffers = []; 255 this._stack = []; 256 } 257 EBMLEncoder.prototype.encode = function (elms) { 258 var _this = this; 259 return tools.concat(elms.reduce(function (lst, elm) { 260 return lst.concat(_this.encodeChunk(elm)); 261 }, [])).buffer; 262 }; 263 EBMLEncoder.prototype.encodeChunk = function (elm) { 264 if (elm.type === "m") { 265 if (!elm.isEnd) { 266 this.startTag(elm); 267 } 268 else { 269 this.endTag(elm); 270 } 271 } 272 else { 273 this.writeTag(elm); 274 } 275 return this.flush(); 276 }; 277 EBMLEncoder.prototype.flush = function () { 278 var ret = this._buffers; 279 this._buffers = []; 280 return ret; 281 }; 282 EBMLEncoder.prototype.getSchemaInfo = function (tagName) { 283 var tagNums = Object.keys(this._schema).map(Number); 284 for (var i = 0; i < tagNums.length; i++) { 285 var tagNum = tagNums[i]; 286 if (this._schema[tagNum].name === tagName) { 287 return new tools_1.Buffer(tagNum.toString(16), 'hex'); 288 } 289 } 290 return null; 291 }; 292 EBMLEncoder.prototype.writeTag = function (elm) { 293 var tagName = elm.name;
294 var tagId = this.getSchemaInfo(tagName); 295 var tagData = elm.data; 296 if (tagId == null) { 297 throw new Error('No schema entry found for ' + tagName); 298 } 299 var data = tools.encodeTag(tagId, tagData); 300 /** 301 * 親è¦ç´ ãéãã¿ã°ãã(isEnd)ãªãéãã¿ã°ãæ¥ãã¾ã§å¾ ã¤(children queã«å ¥ã) 302 */ 303 if (this._stack.length > 0) { 304 var last = this._stack[this._stack.length - 1]; 305 last.children.push({ 306 tagId: tagId, 307 elm: elm, 308 children: [], 309 data: data 310 }); 311 return; 312 } 313 this._buffers = this._buffers.concat(data); 314 return; 315 }; 316 EBMLEncoder.prototype.startTag = function (elm) { 317 var tagName = elm.name; 318 var tagId = this.getSchemaInfo(tagName); 319 if (tagId == null) { 320 throw new Error('No schema entry found for ' + tagName); 321 } 322 /** 323 * éãã¿ã°ä¸å®é·ã®å ´åã¯ã¹ã¿ãã¯ã«ç©ã¾ãã«å³æãããã¡ã«æ¸ãè¾¼ã 324 */ 325 if (elm.unknownSize) { 326 var data = tools.encodeTag(tagId, new tools_1.Buffer(0), elm.unknownSize); 327 this._buffers = this._buffers.concat(data); 328 return; 329 } 330 var tag = { 331 tagId: tagId, 332 elm: elm, 333 children: [], 334 data: null 335 }; 336 if (this._stack.length > 0) { 337 this._stack[this._stack.length - 1].children.push(tag); 338 } 339 this._stack.push(tag); 340 }; 341 EBMLEncoder.prototype.endTag = function (elm) { 342 var tagName = elm.name; 343 var tag = this._stack.pop(); 344 if (tag == null) { 345 throw new Error("EBML structure is broken"); 346 } 347 if (tag.elm.name !== elm.name) { 348 throw new Error("EBML structure is broken"); 349 } 350 var childTagDataBuffers = tag.children.reduce(function (lst, child) { 351 if (child.data === null) { 352 throw new Error("EBML structure is broken"); 353 } 354 return lst.concat(child.data); 355 }, []); 356 var childTagDataBuffer = tools.concat(childTagDataBuffers); 357 if (tag.elm.type === "m") { 358 tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer, tag.elm.unknownSize); 359 } 360 else { 361 tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer); 362 } 363 if (this._stack.length < 1) { 364 this._buffers = this._buffers.concat(tag.data); 365 } 366 }; 367 return EBMLEncoder; 368}()); 369exports.default = EBMLEncoder; 370 371},{"./tools":5,"matroska/lib/schema":17}],3:[function(require,module,exports){ 372"use strict"; 373var __extends = (this && this.__extends) || (function () { 374 var extendStatics = Object.setPrototypeOf || 375 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 376 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 377 return function (d, b) { 378 extendStatics(d, b); 379 function __() { this.constructor = d; } 380 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 381 }; 382})(); 383Object.defineProperty(exports, "__esModule", { value: true }); 384var events_1 = require("events"); 385var tools = require("./tools"); 386/** 387 * This is an informal code for reference. 388 * EBMLReader is a class for getting information to enable seeking Webm recorded by MediaRecorder. 389 * So please do not use for regular WebM files. 390 */ 391var EBMLReader = /** @class */ (function (_super) { 392 __extends(EBMLReader, _super); 393 function EBMLReader() { 394 var _this = _super.call(this) || this; 395 _this.logGroup = ""; 396 _this.hasLoggingStarted = false; 397 _this.metadataloaded = false; 398 _this.chunks = []; 399 _this.stack = []; 400 _this.segmentOffset = 0; 401 _this.last2SimpleBlockVideoTrackTimecode = [0, 0]; 402 _this.last2SimpleBlockAudioTrackTimecode = [0, 0]; 403 _this.lastClusterTimecode = 0; 404 _this.lastClusterPosition = 0; 405 _this.timecodeScale = 1000000; // webm default TimecodeScale is 1ms 406 _this.metadataSize = 0; 407 _this.metadatas = []; 408 _this.cues = [];
409 _this.firstVideoBlockRead = false; 410 _this.firstAudioBlockRead = false; 411 _this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null }; 412 _this.trackTypes = []; 413 _this.trackDefaultDuration = []; 414 _this.trackCodecDelay = []; 415 _this.trackInfo = { type: "nothing" }; 416 _this.ended = false; 417 _this.logging = false; 418 _this.use_duration_every_simpleblock = false; 419 _this.use_webp = false; 420 _this.use_segment_info = true; 421 _this.drop_default_duration = true; 422 return _this; 423 } 424 /** 425 * emit final state. 426 */ 427 EBMLReader.prototype.stop = function () { 428 this.ended = true; 429 this.emit_segment_info(); 430 // clean up any unclosed Master Elements at the end of the stream. 431 while (this.stack.length) { 432 this.stack.pop(); 433 if (this.logging) { 434 console.groupEnd(); 435 } 436 } 437 // close main group if set, logging is enabled, and has actually logged anything. 438 if (this.logging && this.hasLoggingStarted && this.logGroup) { 439 console.groupEnd(); 440 } 441 }; 442 /** 443 * emit chunk info 444 */ 445 EBMLReader.prototype.emit_segment_info = function () { 446 var data = this.chunks; 447 this.chunks = []; 448 if (!this.metadataloaded) { 449 this.metadataloaded = true; 450 this.metadatas = data; 451 var videoTrackNum = this.trackTypes.indexOf(1); // find first video track 452 var audioTrackNum = this.trackTypes.indexOf(2); // find first audio track 453 this.trackInfo = videoTrackNum >= 0 && audioTrackNum >= 0 ? { type: "both", trackNumber: videoTrackNum } 454 : videoTrackNum >= 0 ? { type: "video", trackNumber: videoTrackNum } 455 : audioTrackNum >= 0 ? { type: "audio", trackNumber: audioTrackNum } 456 : { type: "nothing" }; 457 if (!this.use_segment_info) { 458 return; 459 } 460 this.emit("metadata", { data: data, metadataSize: this.metadataSize }); 461 } 462 else { 463 if (!this.use_segment_info) { 464 return; 465 } 466 var timecode = this.lastClusterTimecode; 467 var duration = this.duration; 468 var timecodeScale = this.timecodeScale; 469 this.emit("cluster", { timecode: timecode, data: data }); 470 this.emit("duration", { timecodeScale: timecodeScale, duration: duration }); 471 } 472 }; 473 EBMLReader.prototype.read = function (elm) { 474 var _this = this; 475 var drop = false; 476 if (this.ended) { 477 // reader is finished 478 return; 479 } 480 if (elm.type === "m") { 481 // éãã¿ã°ã®èªåæ¿å ¥ 482 if (elm.isEnd) { 483 this.stack.pop(); 484 } 485 else { 486 var parent_1 = this.stack[this.stack.length - 1]; 487 if (parent_1 != null && parent_1.level >= elm.level) { 488 // éãã¿ã°ãªãã§ã¬ãã«ãä¸ãã£ããéãã¿ã°ãæ¿å ¥ 489 this.stack.pop(); 490 // From http://w3c.github.io/media-source/webm-byte-stream-format.html#webm-media-segments 491 // This fixes logging for webm streams with Cluster of unknown length and no Cluster closing elements. 492 if (this.logging) { 493 console.groupEnd(); 494 } 495 parent_1.dataEnd = elm.dataEnd; 496 parent_1.dataSize = elm.dataEnd - parent_1.dataStart; 497 parent_1.unknownSize = false; 498 var o = Object.assign({}, parent_1, { name: parent_1.name, type: parent_1.type, isEnd: true }); 499 this.chunks.push(o); 500 } 501 this.stack.push(elm); 502 } 503 } 504 if (elm.type === "m" && elm.name == "Segment") { 505 if (this.segmentOffset != 0) { 506 console.warn("Multiple segments detected!"); 507 } 508 this.segmentOffset = elm.dataStart;
509 this.emit("segment_offset", this.segmentOffset); 510 } 511 else if (elm.type === "b" && elm.name === "SimpleBlock") { 512 var _a = tools.ebmlBlock(elm.data), timecode = _a.timecode, trackNumber = _a.trackNumber, frames_1 = _a.frames; 513 if (this.trackTypes[trackNumber] === 1) { // trackType === 1 => video track 514 if (!this.firstVideoBlockRead) { 515 this.firstVideoBlockRead = true; 516 if (this.trackInfo.type === "both" || this.trackInfo.type === "video") { 517 var CueTime = this.lastClusterTimecode + timecode; 518 this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); 519 this.emit("cue_info", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode }); 520 this.emit("cue", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); 521 } 522 } 523 this.last2SimpleBlockVideoTrackTimecode = [this.last2SimpleBlockVideoTrackTimecode[1], timecode]; 524 } 525 else if (this.trackTypes[trackNumber] === 2) { // trackType === 2 => audio track 526 if (!this.firstAudioBlockRead) { 527 this.firstAudioBlockRead = true; 528 if (this.trackInfo.type === "audio") { 529 var CueTime = this.lastClusterTimecode + timecode; 530 this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); 531 this.emit("cue_info", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode }); 532 this.emit("cue", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); 533 } 534 } 535 this.last2SimpleBlockAudioTrackTimecode = [this.last2SimpleBlockAudioTrackTimecode[1], timecode]; 536 } 537 if (this.use_duration_every_simpleblock) { 538 this.emit("duration", { timecodeScale: this.timecodeScale, duration: this.duration }); 539 } 540 if (this.use_webp) { 541 frames_1.forEach(function (frame) { 542 var startcode = frame.slice(3, 6).toString("hex"); 543 if (startcode !== "9d012a") { 544 return; 545 } 546 ; // VP8 ã®å ´å 547 var webpBuf = tools.VP8BitStreamToRiffWebPBuffer(frame); 548 var webp = new Blob([webpBuf], { type: "image/webp" }); 549 var currentTime = _this.duration; 550 _this.emit("webp", { currentTime: currentTime, webp: webp }); 551 }); 552 } 553 } 554 else if (elm.type === "m" && elm.name === "Cluster" && elm.isEnd === false) { 555 this.firstVideoBlockRead = false; 556 this.firstAudioBlockRead = false; 557 this.emit_segment_info(); 558 this.emit("cluster_ptr", elm.tagStart); 559 this.lastClusterPosition = elm.tagStart; 560 } 561 else if (elm.type === "u" && elm.name === "Timecode") { 562 this.lastClusterTimecode = elm.value; 563 } 564 else if (elm.type === "u" && elm.name === "TimecodeScale") { 565 this.timecodeScale = elm.value; 566 } 567 else if (elm.type === "m" && elm.name === "TrackEntry") { 568 if (elm.isEnd) { 569 this.trackTypes[this.currentTrack.TrackNumber] = this.currentTrack.TrackType; 570 this.trackDefaultDuration[this.currentTrack.TrackNumber] = this.currentTrack.DefaultDuration; 571 this.trackCodecDelay[this.currentTrack.TrackNumber] = this.currentTrack.CodecDelay; 572 } 573 else { 574 this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null }; 575 } 576 } 577 else if (elm.type === "u" && elm.name === "TrackType") { 578 this.currentTrack.TrackType = elm.value; 579 } 580 else if (elm.type === "u" && elm.name === "TrackNumber") { 581 this.currentTrack.TrackNumber = elm.value; 582 } 583 else if (elm.type === "u" && elm.name === "CodecDelay") { 584 this.currentTrack.CodecDelay = elm.value; 585 } 586 else if (elm.type === "u" && elm.name === "DefaultDuration") {
587 // media source api 㯠DefaultDuration ãè¨ç®ããã¨ãã°ãã 588 // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22 589 // chrome 58 ã§ã¯ãããåé¿ããããã« DefaultDuration è¦ç´ ãæãåã£ãã 590 // chrome 58 以åã§ããã®ã¿ã°ãæãåããã¨ã§åé¿ã§ãã 591 if (this.drop_default_duration) { 592 console.warn("DefaultDuration detected!, remove it"); 593 drop = true; 594 } 595 else { 596 this.currentTrack.DefaultDuration = elm.value; 597 } 598 } 599 else if (elm.name === "unknown") { 600 console.warn(elm); 601 } 602 if (!this.metadataloaded && elm.dataEnd > 0) { 603 this.metadataSize = elm.dataEnd; 604 } 605 if (!drop) { 606 this.chunks.push(elm); 607 } 608 if (this.logging) { 609 this.put(elm); 610 } 611 }; 612 Object.defineProperty(EBMLReader.prototype, "duration", { 613 /** 614 * DefaultDuration ãå®ç¾©ããã¦ããå ´åã¯æå¾ã®ãã¬ã¼ã ã®durationãèæ ®ãã 615 * åä½ timecodeScale 616 * 617 * !!! if you need duration with seconds !!! 618 * ```js 619 * const nanosec = reader.duration * reader.timecodeScale; 620 * const sec = nanosec / 1000 / 1000 / 1000; 621 * ``` 622 */ 623 get: function () { 624 if (this.trackInfo.type === "nothing") { 625 console.warn("no video, no audio track"); 626 return 0; 627 } 628 // defaultDuration 㯠çã® nano sec 629 var defaultDuration = 0; 630 // nanoseconds 631 var codecDelay = 0; 632 var lastTimecode = 0; 633 var _defaultDuration = this.trackDefaultDuration[this.trackInfo.trackNumber]; 634 if (typeof _defaultDuration === "number") { 635 defaultDuration = _defaultDuration; 636 } 637 else { 638 // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22 639 // default duration ããªãã¨ãã«ä½¿ã delta 640 if (this.trackInfo.type === "both") { 641 if (this.last2SimpleBlockAudioTrackTimecode[1] > this.last2SimpleBlockVideoTrackTimecode[1]) { 642 // audio diff 643 defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale; 644 // audio delay 645 var delay = this.trackCodecDelay[this.trackTypes.indexOf(2)]; // 2 => audio 646 if (typeof delay === "number") { 647 codecDelay = delay; 648 } 649 // audio timecode 650 lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1]; 651 } 652 else { 653 // video diff 654 defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale; 655 // video delay 656 var delay = this.trackCodecDelay[this.trackTypes.indexOf(1)]; // 1 => video 657 if (typeof delay === "number") { 658 codecDelay = delay; 659 } 660 // video timecode 661 lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1]; 662 } 663 } 664 else if (this.trackInfo.type === "video") { 665 defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale; 666 var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 2 => audio 667 if (typeof delay === "number") { 668 codecDelay = delay; 669 } 670 lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1]; 671 } 672 else if (this.trackInfo.type === "audio") { 673 defaultDuration = (this.last2SimpleBlockAudioTrackTimeco
673de[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale; 674 var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 1 => video 675 if (typeof delay === "number") { 676 codecDelay = delay; 677 } 678 lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1]; 679 } // else { not reached } 680 } 681 // convert to timecodescale 682 var duration_nanosec = ((this.lastClusterTimecode + lastTimecode) * this.timecodeScale) + defaultDuration - codecDelay; 683 var duration = duration_nanosec / this.timecodeScale; 684 return Math.floor(duration); 685 }, 686 enumerable: true, 687 configurable: true 688 }); 689 EBMLReader.prototype.addListener = function (event, listener) { 690 return _super.prototype.addListener.call(this, event, listener); 691 }; 692 EBMLReader.prototype.put = function (elm) { 693 if (!this.hasLoggingStarted) { 694 this.hasLoggingStarted = true; 695 if (this.logging && this.logGroup) { 696 console.groupCollapsed(this.logGroup); 697 } 698 } 699 if (elm.type === "m") { 700 if (elm.isEnd) { 701 console.groupEnd(); 702 } 703 else { 704 console.group(elm.name + ":" + elm.tagStart); 705 } 706 } 707 else if (elm.type === "b") { 708 // for debug 709 //if(elm.name === "SimpleBlock"){ 710 //const o = EBML.tools.ebmlBlock(elm.value); 711 //console.log(elm.name, elm.type, o.trackNumber, o.timecode); 712 //}else{ 713 console.log(elm.name, elm.type); 714 //} 715 } 716 else { 717 console.log(elm.name, elm.tagStart, elm.type, elm.value); 718 } 719 }; 720 return EBMLReader; 721}(events_1.EventEmitter)); 722exports.default = EBMLReader; 723; 724; 725; 726; 727 728},{"./tools":5,"events":13}],4:[function(require,module,exports){ 729"use strict"; 730Object.defineProperty(exports, "__esModule", { value: true }); 731var EBMLDecoder_1 = require("./EBMLDecoder"); 732exports.Decoder = EBMLDecoder_1.default; 733var EBMLEncoder_1 = require("./EBMLEncoder"); 734exports.Encoder = EBMLEncoder_1.default; 735var EBMLReader_1 = require("./EBMLReader"); 736exports.Reader = EBMLReader_1.default; 737var tools = require("./tools"); 738exports.tools = tools; 739var version = require("../package.json").version; 740exports.version = version; 741 742},{"../package.json":18,"./EBMLDecoder":1,"./EBMLEncoder":2,"./EBMLReader":3,"./tools":5}],5:[function(require,module,exports){ 743"use strict"; 744Object.defineProperty(exports, "__esModule", { value: true }); 745/// <reference types="node"/> 746var int64_buffer_1 = require("int64-buffer"); 747var EBMLEncoder_1 = require("./EBMLEncoder"); 748var _Buffer = require("buffer/"); 749var _tools = require("ebml/lib/ebml/tools"); 750var _block = require("ebml-block"); 751exports.Buffer = _Buffer.Buffer; 752exports.readVint = _tools.readVint; 753exports.writeVint = _tools.writeVint; 754exports.ebmlBlock = _block; 755function readBlock(buf) { 756 return exports.ebmlBlock(new exports.Buffer(buf)); 757} 758exports.readBlock = readBlock; 759/** 760 * @param end - if end === false then length is unknown 761 */ 762function encodeTag(tagId, tagData, unknownSize) { 763 if (unknownSize === void 0) { unknownSize = false; } 764 return concat([ 765 tagId, 766 unknownSize ? 767 new exports.Buffer('01ffffffffffffff', 'hex') : 768 exports.writeVint(tagData.length), 769 tagData 770 ]); 771} 772exports.encodeTag = encodeTag; 773/** 774 * @return - SimpleBlock to WebP Filter 775 */ 776function WebPFrameFilter(elms) { 777 return WebPBlockFilter(elms).reduce(function (lst, elm) { 778 var o = exports.ebmlBlock(elm.data); 779 return o.frames.reduce(function (lst, frame) { 780 // https://developers.Blob.com/speed/webp/docs/riff_container 781 var webpBuf = VP8BitStreamToRiffWebPBuffer(frame); 782 var webp = new Blob([webpBuf], { type: "image/webp" }); 783 return lst.concat(webp); 784 }, lst); 785 }, []); 786} 787exports.WebPFrameFilter = WebPFrameFilter; 788/**
789 * WebP ãã¡ã¤ã«ã«ã§ãã SimpleBlock ã® ãã¹ãã£ã«ã¿ 790 */ 791function WebPBlockFilter(elms) { 792 return elms.reduce(function (lst, elm) { 793 if (elm.type !== "b") { 794 return lst; 795 } 796 if (elm.name !== "SimpleBlock") { 797 return lst; 798 } 799 var o = exports.ebmlBlock(elm.data); 800 var hasWebP = o.frames.some(function (frame) { 801 // https://tools.ietf.org/html/rfc6386#section-19.1 802 var startcode = frame.slice(3, 6).toString("hex"); 803 return startcode === "9d012a"; 804 }); 805 if (!hasWebP) { 806 return lst; 807 } 808 return lst.concat(elm); 809 }, []); 810} 811exports.WebPBlockFilter = WebPBlockFilter; 812/** 813 * @param frame - VP8 BitStream ã®ãã¡ startcode ãã㤠frame 814 * @return - WebP ãã¡ã¤ã«ã® ArrayBuffer 815 */ 816function VP8BitStreamToRiffWebPBuffer(frame) { 817 var VP8Chunk = createRIFFChunk("VP8 ", frame); 818 var WebPChunk = concat([ 819 new exports.Buffer("WEBP", "ascii"), 820 VP8Chunk 821 ]); 822 return createRIFFChunk("RIFF", WebPChunk); 823} 824exports.VP8BitStreamToRiffWebPBuffer = VP8BitStreamToRiffWebPBuffer; 825/** 826 * RIFF ãã¼ã¿ãã£ã³ã¯ãä½ã 827 */ 828function createRIFFChunk(FourCC, chunk) { 829 var chunkSize = new exports.Buffer(4); 830 chunkSize.writeUInt32LE(chunk.byteLength, 0); 831 return concat([ 832 new exports.Buffer(FourCC.substr(0, 4), "ascii"), 833 chunkSize, 834 chunk, 835 new exports.Buffer(chunk.byteLength % 2 === 0 ? 0 : 1) // padding 836 ]); 837} 838exports.createRIFFChunk = createRIFFChunk; 839/* Original Metadata 840 841 m 0 EBML 842 u 1 EBMLVersion 1 843 u 1 EBMLReadVersion 1 844 u 1 EBMLMaxIDLength 4 845 u 1 EBMLMaxSizeLength 8 846 s 1 DocType webm 847 u 1 DocTypeVersion 4 848 u 1 DocTypeReadVersion 2 849 m 0 Segment 850 m 1 Info segmentContentStartPos, all CueClusterPositions provided in info.cues will be relative to here and will need adjusted 851 u 2 TimecodeScale 1000000 852 8 2 MuxingApp Chrome 853 8 2 WritingApp Chrome 854 m 1 Tracks tracksStartPos 855 m 2 TrackEntry 856 u 3 TrackNumber 1 857 u 3 TrackUID 31790271978391090 858 u 3 TrackType 2 859 s 3 CodecID A_OPUS 860 b 3 CodecPrivate <Buffer 19> 861 m 3 Audio 862 f 4 SamplingFrequency 48000 863 u 4 Channels 1 864 m 2 TrackEntry 865 u 3 TrackNumber 2 866 u 3 TrackUID 24051277436254136 867 u 3 TrackType 1 868 s 3 CodecID V_VP8 869 m 3 Video 870 u 4 PixelWidth 1024 871 u 4 PixelHeight 576 872 m 1 Cluster clusterStartPos 873 u 2 Timecode 0 874 b 2 SimpleBlock track:2 timecode:0 keyframe:true invisible:false discardable:false lacing:1 875*/ 876/* Desired Metadata 877 878 m 0 EBML 879 u 1 EBMLVersion 1 880 u 1 EBMLReadVersion 1 881 u 1 EBMLMaxIDLength 4 882 u 1 EBMLMaxSizeLength 8 883 s 1 DocType webm 884 u 1 DocTypeVersion 4 885 u 1 DocTypeReadVersion 2 886 m 0 Segment 887 m 1 SeekHead -> This is SeekPosition 0, so all SeekPositions can be calculated as (bytePos - segmentContentStartPos), which is 44 in this case 888 m 2 Seek 889 b 3 SeekID -> Buffer([0x15, 0x49, 0xA9, 0x66]) Info 890 u 3 SeekPosition -> infoStartPos = 891 m 2 Seek 892 b 3 SeekID -> Buffer([0x16, 0x54, 0xAE, 0x6B]) Tracks 893 u 3 SeekPosition { tracksStartPos } 894 m 2 Seek 895 b 3 SeekID -> Buffer([0x1C, 0x53, 0xBB, 0x6B]) Cues 896 u 3 SeekPosition { cuesStartPos } 897 m 1 Info 898 f 2 Duration 32480 -> overwrite, or insert if it doesn't exist 899 u 2 TimecodeScale 1000000 900 8 2 MuxingApp Chrome 901 8 2 WritingApp Chrome 902 m 1 Tracks 903 m 2 TrackEntry 904 u 3 TrackNumber 1 905 u 3 TrackUID 31790271978391090 906 u 3 TrackType 2 907 s 3 CodecID A_OPUS 908 b 3 CodecPrivate <Buffer 19> 909 m 3 Audio 910 f 4 SamplingFrequency 48000 911 u 4 Channels 1 912 m 2 TrackEntry 913 u 3 TrackNumber 2 914 u 3 TrackUID 24051277436254136 915 u 3 TrackType 1 916 s 3 CodecID V_VP8 917 m 3 Video 918 u 4 PixelWidth 1024 919 u 4 PixelHeight 576 920 m 1 Cues -> cuesStartPos 921 m 2 CuePoint 922 u 3 CueTime 0 923 m 3 CueTrackPositions 924 u 4 CueTrack 1 925 u 4 CueClusterPosition 3911 926 m 2 CuePoint 927 u 3 CueTime 600 928 m 3 CueTrackPositions 929 u 4 CueTrack 1 930 u 4 CueClusterPosition 3911 931 m 1 Cluster
932 u 2 Timecode 0 933 b 2 SimpleBlock track:2 timecode:0 keyframe:true invisible:false discardable:false lacing:1 934*/ 935/** 936 * convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues 937 * @param originalMetadata - orginal metadata (everything before the clusters start) from media recorder 938 * @param duration - Duration (TimecodeScale) 939 * @param cues - cue points for clusters 940 */ 941function makeMetadataSeekable(originalMetadata, duration, cuesInfo) { 942 // extract the header, we can reuse this as-is 943 var header = extractElement("EBML", originalMetadata); 944 var headerSize = encodedSizeOfEbml(header); 945 //console.error("Header size: " + headerSize); 946 //printElementIds(header); 947 // After the header comes the Segment open tag, which in this implementation is always 12 bytes (4 byte id, 8 byte 'unknown length') 948 // After that the segment content starts. All SeekPositions and CueClusterPosition must be relative to segmentContentStartPos 949 var segmentContentStartPos = headerSize + 12; 950 //console.error("segmentContentStartPos: " + segmentContentStartPos); 951 // find the original metadata size, and adjust it for header size and Segment start element so we can keep all positions relative to segmentContentStartPos 952 var originalMetadataSize = originalMetadata[originalMetadata.length - 1].dataEnd - segmentContentStartPos; 953 //console.error("Original Metadata size: " + originalMetadataSize); 954 //printElementIds(originalMetadata); 955 // extract the segment info, remove the potentially existing Duration element, and add our own one. 956 var info = extractElement("Info", originalMetadata); 957 removeElement("Duration", info); 958 info.splice(1, 0, { name: "Duration", type: "f", data: createFloatBuffer(duration, 8) }); 959 var infoSize = encodedSizeOfEbml(info); 960 //console.error("Info size: " + infoSize); 961 //printElementIds(info); 962 // extract the track info, we can re-use this as is 963 var tracks = extractElement("Tracks", originalMetadata); 964 var tracksSize = encodedSizeOfEbml(tracks); 965 //console.error("Tracks size: " + tracksSize); 966 //printElementIds(tracks); 967 var seekHeadSize = 47; // Initial best guess, but could be slightly larger if the Cues element is huge. 968 var seekHead = []; 969 var cuesSize = 5 + cuesInfo.length * 15; // very rough initial approximation, depends a lot on file size and number of CuePoints 970 var cues = []; 971 var lastSizeDifference = -1; // 972 // The size of SeekHead and Cues elements depends on how many bytes the offsets values can be encoded in. 973 // The actual offsets in CueClusterPosition depend on the final size of the SeekHead and Cues elements 974 // We need to iteratively converge to a stable solution. 975 var maxIterations = 10; 976 var _loop_1 = function (i) { 977 // SeekHead starts at 0 978 var infoStart = seekHeadSize; // Info comes directly after SeekHead 979 var tracksStart = infoStart + infoSize; // Tracks comes directly after Info 980 var cuesStart = tracksStart + tracksSize; // Cues starts directly after 981 var newMetadataSize = cuesStart + cuesSize; // total size of metadata 982 // This is the offset all CueClusterPositions should be adjusted by due to the metadata size changing. 983 var sizeDifference = newMetadataSize - originalMetadataSize; 984 // console.error(`infoStart: ${infoStart}, infoSize: ${infoSize}`); 985 // console.error(`tracksStart: ${tracksStart}, tracksSize: ${tracksSize}`); 986 // console.error(`cuesStart: ${cuesStart}, cuesSize: ${cuesSize}`); 987 // console.error(`originalMetadataSize: ${originalMetadataSize}, newMetadataSize: ${newMetadataSize}, sizeDifference: ${sizeDifference}`); 988 // create the SeekHead element 989 seekHead = []; 990 seekHead.push({ name: "SeekHead", type: "m", isEnd: false }); 991 seekHead.push({ name: "Seek", type: "m", isEnd: false }); 992 seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); // Info 993 seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(infoStart) }); 994 seekHead.push({ name: "Seek", type: "m", isEnd: true }); 995 seekHead.push({ name: "Seek", type: "m", isEnd: false }); 996 seekHead.push({ name: "SeekID", type: "b", data: new exp
996orts.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); // Tracks 997 seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tracksStart) }); 998 seekHead.push({ name: "Seek", type: "m", isEnd: true }); 999 seekHead.push({ name: "Seek", type: "m", isEnd: false }); 1000 seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); // Cues 1001 seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(cuesStart) }); 1002 seekHead.push({ name: "Seek", type: "m", isEnd: true }); 1003 seekHead.push({ name: "SeekHead", type: "m", isEnd: true }); 1004 seekHeadSize = encodedSizeOfEbml(seekHead); 1005 //console.error("SeekHead size: " + seekHeadSize); 1006 //printElementIds(seekHead); 1007 // create the Cues element 1008 cues = []; 1009 cues.push({ name: "Cues", type: "m", isEnd: false }); 1010 cuesInfo.forEach(function (_a) { 1011 var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime; 1012 cues.push({ name: "CuePoint", type: "m", isEnd: false }); 1013 cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) }); 1014 cues.push({ name: "CueTrackPositions", type: "m", isEnd: false }); 1015 cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) }); 1016 //console.error(`CueClusterPosition: ${CueClusterPosition}, Corrected to: ${CueClusterPosition - segmentContentStartPos} , offset by ${sizeDifference} to become ${(CueClusterPosition - segmentContentStartPos) + sizeDifference - segmentContentStartPos}`); 1017 // EBMLReader returns CueClusterPosition with absolute byte offsets. The Cues section expects them as offsets from the first level 1 element of the Segment, so we need to adjust it. 1018 CueClusterPosition -= segmentContentStartPos; 1019 // We also need to adjust to take into account the change in metadata size from when EBMLReader read the original metadata. 1020 CueClusterPosition += sizeDifference; 1021 cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition) }); 1022 cues.push({ name: "CueTrackPositions", type: "m", isEnd: true }); 1023 cues.push({ name: "CuePoint", type: "m", isEnd: true }); 1024 }); 1025 cues.push({ name: "Cues", type: "m", isEnd: true }); 1026 cuesSize = encodedSizeOfEbml(cues); 1027 //console.error("Cues size: " + cuesSize); 1028 //console.error("Cue count: " + cuesInfo.length); 1029 //printElementIds(cues); 1030 // If the new MetadataSize is not the same as the previous iteration, we need to run once more. 1031 if (lastSizeDifference !== sizeDifference) { 1032 lastSizeDifference = sizeDifference; 1033 if (i === maxIterations - 1) { 1034 throw new Error("Failed to converge to a stable metadata size"); 1035 } 1036 } 1037 else { 1038 return "break"; 1039 } 1040 }; 1041 for (var i = 0; i < maxIterations; i++) { 1042 var state_1 = _loop_1(i); 1043 if (state_1 === "break") 1044 break; 1045 } 1046 var finalMetadata = [].concat.apply([], [ 1047 header, 1048 { name: "Segment", type: "m", isEnd: false, unknownSize: true }, 1049 seekHead, 1050 info, 1051 tracks, 1052 cues 1053 ]); 1054 var result = new EBMLEncoder_1.default().encode(finalMetadata); 1055 //printElementIds(finalMetadata); 1056 //console.error(`Final metadata buffer size: ${result.byteLength}`); 1057 //console.error(`Final metadata buffer size without header and segment: ${result.byteLength-segmentContentStartPos}`); 1058 return result; 1059} 1060exports.makeMetadataSeekable = makeMetadataSeekable; 1061/** 1062 * print all element id names in a list 1063 1064 * @param metadata - array of EBML elements to print 1065 * 1066export function printElementIds(metadata: EBML.EBMLElementBuffer[]) { 1067 1068 let result: EBML.EBMLElementBuffer[] = []; 1069 let start: number = -1; 1070 1071 for (let i = 0; i < metadata.length; i++) { 1072 console.error("\t id: " + metadata[i].name); 1073 } 1074} 1075*/ 1076/** 1077 * remove all occurances of an EBML element from an array of elements 1078 * If it's a MasterElement you will also remove the content. (everything between start and end) 1079 * @param idName - name of the EBML Element to remove. 1080 * @param metadata - array of EBML elements to search 1081 */ 1082function removeElement(idName, metadata) { 1083 var result = []; 1084 var start = -1; 1085 for (var i = 0; i < metadata.length; i++) { 1086 var element = metadata[i]; 1087 if (element.name === idName) { 1088 // if it's a Master element, extract the start and end element, and everything in between 1089 if (element.type === "m") { 1090 if (!element.isEnd) { 1091 start = i; 1092 } 1093 else { 1094 // we've reached the end, extract the whole thing 1095 if (start == -1) 1096 throw new Error("Detected " + idName + " closing element before finding the start"); 1097 metadata.splice(start, i - start + 1); 1098 return; 1099 } 1100 } 1101 else { 1102 // not a Master element, so we've found what we're looking for. 1103 metadata.splice(i, 1); 1104 return; 1105 } 1106 } 1107 } 1108} 1109exports.removeElement = removeElement; 1110/** 1111 * extract the first occurance of an EBML tag from a flattened array of EBML data. 1112 * If it's a MasterElement you will also get the content. (everything between start and end) 1113 * @param idName - name of the EBML Element to extract. 1114 * @param metadata - array of EBML elements to search 1115 */ 1116function extractElement(idName, metadata) { 1117 var result = []; 1118 var start = -1; 1119 for (var i = 0; i < metadata.length; i++) { 1120 var element = metadata[i]; 1121 if (element.name === idName) { 1122 // if it's a Master element, extract the start and end element, and everything in between 1123 if (element.type === "m") { 1124 if (!element.isEnd) { 1125 start = i; 1126 } 1127 else { 1128 // we've reached the end, extract the whole thing 1129 if (start == -1) 1130 throw new Error("Detected " + idName + " closing element before finding the start"); 1131 result = metadata.slice(start, i + 1); 1132 break; 1133 } 1134 } 1135 else { 1136 // not a Master element, so we've found what we're looking for. 1137 result.push(metadata[i]); 1138 break; 1139 } 1140 } 1141 } 1142 return result; 1143} 1144exports.extractElement = extractElement; 1145/** 1146 * @deprecated 1147 * metadata ã«å¯¾ã㦠duration 㨠seekhead ã追å ãã metadata ãè¿ã 1148 * @param metadata - 夿´åã® webm ã«ããã ãã¡ã¤ã«å é ãã æåã® Cluster è¦ç´ ã¾ã§ã® è¦ç´ 1149 * @param duration - Duration (TimecodeScale)
1150 * @param cues - cue points for clusters 1151 * @deprecated @param clusterPtrs - 夿´åã® webm ã«ããã SeekHead ã«è¿½å ãã Cluster è¦ç´ ã¸ã® start pointer 1152 * @deprecated @param cueInfos - please use cues. 1153 */ 1154function putRefinedMetaData(metadata, info) { 1155 if (Array.isArray(info.cueInfos) && !Array.isArray(info.cues)) { 1156 console.warn("putRefinedMetaData: info.cueInfos property is deprecated. please use info.cues"); 1157 info.cues = info.cueInfos; 1158 } 1159 var ebml = []; 1160 var payload = []; 1161 for (var i_1 = 0; i_1 < metadata.length; i_1++) { 1162 var elm = metadata[i_1]; 1163 if (elm.type === "m" && elm.name === "Segment") { 1164 ebml = metadata.slice(0, i_1); 1165 payload = metadata.slice(i_1); 1166 if (elm.unknownSize) { 1167 payload.shift(); // remove segment tag 1168 break; 1169 } 1170 throw new Error("this metadata is not streaming webm file"); 1171 } 1172 } 1173 // *0 *4 *5 *36 *40 *48=segmentOffset *185=originalPayloadOffsetEnd 1174 // | | | | | | | 1175 // [EBML][size]....[Segment][size][Info][size][Duration][size]...[Cluster] 1176 // | | |^inf | | 1177 // | +segmentSiz(12)+ | 1178 // +-ebmlSize(36)--+ | +-payloadSize(137)-------------+offsetEndDiff+ 1179 // | | +-newPayloadSize(??)-------------------------+ 1180 // | | | | 1181 // [Segment][size][Info][size][Duration][size]....[size][value][Cluster] 1182 // ^ | 1183 // | *??=newPayloadOffsetEnd 1184 // inf 1185 if (!(payload[payload.length - 1].dataEnd > 0)) { 1186 throw new Error("metadata dataEnd has wrong number"); 1187 } 1188 var originalPayloadOffsetEnd = payload[payload.length - 1].dataEnd; // = first cluster ptr 1189 var ebmlSize = ebml[ebml.length - 1].dataEnd; // = first segment ptr 1190 var refinedEBMLSize = new EBMLEncoder_1.default().encode(ebml).byteLength; 1191 var offsetDiff = refinedEBMLSize - ebmlSize; 1192 var payloadSize = originalPayloadOffsetEnd - payload[0].tagStart; 1193 var segmentSize = payload[0].tagStart - ebmlSize; 1194 var segmentOffset = payload[0].tagStart;
1195 var segmentTagBuf = new exports.Buffer([0x18, 0x53, 0x80, 0x67]); // Segment 1196 var segmentSizeBuf = new exports.Buffer('01ffffffffffffff', 'hex'); // Segmentã®æå¾ã®ä½ç½®ã¯ç¡æ°ã® Cluster ä¾åãªã®ã§ã writeVint(newPayloadSize).byteLength ã§ã¯ãªãã infinity. 1197 var _segmentSize = segmentTagBuf.byteLength + segmentSizeBuf.byteLength; // == segmentSize 1198 var newPayloadSize = payloadSize; 1199 // We need the size to be stable between two refinements in order for our offsets to be correct 1200 // Bound the number of possible refinements so we can't go infinate if something goes wrong 1201 var i; 1202 for (i = 1; i < 20; i++) { 1203 var newPayloadOffsetEnd = ebmlSize + _segmentSize + newPayloadSize; 1204 var offsetEndDiff = newPayloadOffsetEnd - originalPayloadOffsetEnd; 1205 var sizeDiff = offsetDiff + offsetEndDiff; 1206 var refined = refineMetadata(payload, sizeDiff, info); 1207 var newNewRefinedSize = new EBMLEncoder_1.default().encode(refined).byteLength; // 䏿¦ seekhead ãä½ã£ã¦èªèº«ã®ãµã¤ãºã調ã¹ã 1208 if (newNewRefinedSize === newPayloadSize) { 1209 // Size is stable 1210 return new EBMLEncoder_1.default().encode([].concat(ebml, [{ type: "m", name: "Segment", isEnd: false, unknownSize: true }], refined)); 1211 } 1212 newPayloadSize = newNewRefinedSize; 1213 } 1214 throw new Error("unable to refine metadata, stable size could not be found in " + i + " iterations!"); 1215} 1216exports.putRefinedMetaData = putRefinedMetaData; 1217// Given a list of EBMLElementBuffers, returns their encoded size in bytes 1218function encodedSizeOfEbml(refinedMetaData) { 1219 var encorder = new EBMLEncoder_1.default(); 1220 return refinedMetaData.reduce(function (lst, elm) { return lst.concat(encorder.encode([elm])); }, []).reduce(function (o, buf) { return o + buf.byteLength; }, 0); 1221} 1222function refineMetadata(mesetadata, sizeDiff, info) { 1223 var duration = info.duration, clusterPtrs = info.clusterPtrs, cues = info.cues; 1224 var _metadata = mesetadata.slice(0); 1225 if (typeof duration === "number") { 1226 // duration ã追å ãã 1227 var overwrited_1 = false; 1228 _metadata.forEach(function (elm) { 1229 if (elm.type === "f" && elm.name === "Duration") { 1230 overwrited_1 = true; 1231 elm.data = createFloatBuffer(duration, 8); 1232 } 1233 }); 1234 if (!overwrited_1) { 1235 insertTag(_metadata, "Info", [{ name: "Duration", type: "f", data: createFloatBuffer(duration, 8) }]); 1236 } 1237 } 1238 if (Array.isArray(cues)) { 1239 insertTag(_metadata, "Cues", create_cue(cues, sizeDiff)); 1240 } 1241 var seekhead_children = []; 1242 if (Array.isArray(clusterPtrs)) { 1243 console.warn("append cluster pointers to seekhead is deprecated. please use cues"); 1244 seekhead_children = create_seek_from_clusters(clusterPtrs, sizeDiff); 1245 } 1246 // remove seek info 1247 /* 1248 _metadata = _metadata.filter((elm)=> !( 1249 elm.name === "Seek" || 1250 elm.name === "SeekID" || 1251 elm.name === "SeekPosition") ); 1252 */ 1253 // working on progress 1254 //seekhead_children = seekhead_children.concat(create_seekhead(_metadata)); 1255 insertTag(_metadata, "SeekHead", seekhead_children, true); 1256 return _metadata; 1257} 1258function create_seekhead(metadata, sizeDiff) { 1259 var seeks = []; 1260 ["Info", "Tracks", "Cues"].forEach(function (tagName) { 1261 var tagStarts = metadata.filter(function (elm) { return elm.type === "m" && elm.name === tagName && elm.isEnd === false; }).map(function (elm) { return elm["tagStart"]; }); 1262 var tagStart = tagStarts[0]; 1263 if (typeof tagStart !== "number") { 1264 return; 1265 } 1266 seeks.push({ name: "Seek", type: "m", isEnd: false }); 1267 switch (tagName) { 1268 case "Info": 1269 seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); 1270 break; 1271 case "Tracks": 1272 seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); 1273 break; 1274 case "Cues": 1275 seeks.push({ name: "SeekID", type: "b", data: new exp
1275orts.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); 1276 break; 1277 } 1278 seeks.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tagStart + sizeDiff) }); 1279 seeks.push({ name: "Seek", type: "m", isEnd: true }); 1280 }); 1281 return seeks; 1282} 1283function create_seek_from_clusters(clusterPtrs, sizeDiff) { 1284 var seeks = []; 1285 clusterPtrs.forEach(function (start) { 1286 seeks.push({ name: "Seek", type: "m", isEnd: false }); 1287 // [0x1F, 0x43, 0xB6, 0x75] ã§ Cluster æ 1288 seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1F, 0x43, 0xB6, 0x75]) }); 1289 seeks.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(start + sizeDiff) }); 1290 seeks.push({ name: "Seek", type: "m", isEnd: true }); 1291 }); 1292 return seeks; 1293} 1294function create_cue(cueInfos, sizeDiff) { 1295 var cues = []; 1296 cueInfos.forEach(function (_a) { 1297 var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime; 1298 cues.push({ name: "CuePoint", type: "m", isEnd: false }); 1299 cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) }); 1300 cues.push({ name: "CueTrackPositions", type: "m", isEnd: false }); 1301 cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) }); // video track 1302 cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition + sizeDiff) }); 1303 cues.push({ name: "CueTrackPositions", type: "m", isEnd: true }); 1304 cues.push({ name: "CuePoint", type: "m", isEnd: true }); 1305 }); 1306 return cues; 1307} 1308function insertTag(_metadata, tagName, children, insertHead) { 1309 if (insertHead === void 0) { insertHead = false; } 1310 // find the tagname from _metadata 1311 var idx = -1; 1312 for (var i = 0; i < _metadata.length; i++) { 1313 var elm = _metadata[i]; 1314 if (elm.type === "m" && elm.name === tagName && elm.isEnd === false) { 1315 idx = i; 1316 break; 1317 } 1318 } 1319 if (idx >= 0) { 1320 // insert [<CuePoint />] to <Cues /> 1321 Array.prototype.splice.apply(_metadata, [idx + 1, 0].concat(children)); 1322 } 1323 else if (insertHead) { 1324 [].concat([{ name: tagName, type: "m", isEnd: false }], children, [{ name: tagName, type: "m", isEnd: true }]).reverse().forEach(function (elm) { _metadata.unshift(elm); }); 1325 } 1326 else { 1327 // metadata æ«å°¾ã« <Cues /> ã追å 1328 // insert <Cues /> 1329 _metadata.push({ name: tagName, type: "m", isEnd: false }); 1330 children.forEach(function (elm) { _metadata.push(elm); }); 1331 _metadata.push({ name: tagName, type: "m", isEnd: true }); 1332 } 1333} 1334// alter Buffer.concat - https://github.com/feross/buffer/issues/154 1335function concat(list) { 1336 //return Buffer.concat.apply(Buffer, list); 1337 var i = 0; 1338 var length = 0; 1339 for (; i < list.length; ++i) { 1340 length += list[i].length; 1341 } 1342 var buffer = exports.Buffer.allocUnsafe(length); 1343 var pos = 0; 1344 for (i = 0; i < list.length; ++i) { 1345 var buf = list[i]; 1346 buf.copy(buffer, pos); 1347 pos += buf.length; 1348 } 1349 return buffer; 1350} 1351exports.concat = concat; 1352function encodeValueToBuffer(elm) { 1353 var data = new exports.Buffer(0); 1354 if (elm.type === "m") { 1355 return elm; 1356 } 1357 switch (elm.type) { 1358 case "u": 1359 data = createUIntBuffer(elm.value); 1360 break; 1361 case "i": 1362 data = createIntBuffer(elm.value); 1363 break; 1364 case "f": 1365 data = createFloatBuffer(elm.value); 1366 break; 1367 case "s": 1368 data = new exports.Buffer(elm.value, 'ascii'); 1369 break; 1370 case "8": 1371 data = new exports.Buffer(elm.value, 'utf8'); 1372 break; 1373 case "b": 1374 data = elm.value; 1375 break; 1376 case "d": 1377 data = new int64_buffer_1.Int64BE(elm.value.getTime().toString()).toBuffer(); 1378 break; 1379 } 1380 return Object.assign({}, elm, { data: data }); 1381} 1382exports.encodeValueToBuffer = encodeValueToBuffer; 1383function createUIntBuffer(value) { 1384 // Big-endian, any size from 1 to 8 1385 // but js number is float64, so max 6 bit octets 1386 var bytes = 1; 1387 for (; value >= Math.pow(2, 8 * bytes); bytes++) { } 1388 if (bytes >= 7) { 1389 console.warn("7bit or more bigger uint not supported."); 1390 return new int64_buffer_1.Uint64BE(value).toBuffer(); 1391 }
1392 var data = new exports.Buffer(bytes); 1393 data.writeUIntBE(value, 0, bytes); 1394 return data; 1395} 1396exports.createUIntBuffer = createUIntBuffer; 1397function createIntBuffer(value) { 1398 // Big-endian, any size from 1 to 8 octets 1399 // but js number is float64, so max 6 bit 1400 var bytes = 1; 1401 for (; value >= Math.pow(2, 8 * bytes); bytes++) { } 1402 if (bytes >= 7) { 1403 console.warn("7bit or more bigger uint not supported."); 1404 return new int64_buffer_1.Int64BE(value).toBuffer(); 1405 } 1406 var data = new exports.Buffer(bytes); 1407 data.writeIntBE(value, 0, bytes); 1408 return data; 1409} 1410exports.createIntBuffer = createIntBuffer; 1411function createFloatBuffer(value, bytes) { 1412 if (bytes === void 0) { bytes = 8; } 1413 // Big-endian, defined for 4 and 8 octets (32, 64 bits) 1414 // js number is float64 so 8 bytes. 1415 if (bytes === 8) { 1416 // 64bit 1417 var data = new exports.Buffer(8); 1418 data.writeDoubleBE(value, 0); 1419 return data; 1420 } 1421 else if (bytes === 4) { 1422 // 32bit 1423 var data = new exports.Buffer(4); 1424 data.writeFloatBE(value, 0); 1425 return data; 1426 } 1427 else { 1428 throw new Error("float type bits must 4bytes or 8bytes"); 1429 } 1430} 1431exports.createFloatBuffer = createFloatBuffer; 1432function convertEBMLDateToJSDate(int64str) { 1433 if (int64str instanceof Date) { 1434 return int64str; 1435 } 1436 return new Date(new Date("2001-01-01T00:00:00.000Z").getTime() + (Number(int64str) / 1000 / 1000)); 1437} 1438exports.convertEBMLDateToJSDate = convertEBMLDateToJSDate; 1439 1440},{"./EBMLEncoder":2,"buffer/":8,"ebml-block":9,"ebml/lib/ebml/tools":12,"int64-buffer":15}],6:[function(require,module,exports){ 1441'use strict' 1442 1443exports.byteLength = byteLength 1444exports.toByteArray = toByteArray 1445exports.fromByteArray = fromByteArray 1446 1447var lookup = [] 1448var revLookup = [] 1449var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array 1450 1451var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' 1452for (var i = 0, len = code.length; i < len; ++i) { 1453 lookup[i] = code[i] 1454 revLookup[code.charCodeAt(i)] = i 1455} 1456 1457// Support decoding URL-safe base64 strings, as Node.js does. 1458// See: https://en.wikipedia.org/wiki/Base64#URL_applications 1459revLookup['-'.charCodeAt(0)] = 62 1460revLookup['_'.charCodeAt(0)] = 63 1461 1462function getLens (b64) { 1463 var len = b64.length 1464 1465 if (len % 4 > 0) { 1466 throw new Error('Invalid string. Length must be a multiple of 4') 1467 } 1468 1469 // Trim off extra bytes after placeholder bytes are found 1470 // See: https://github.com/beatgammit/base64-js/issues/42 1471 var validLen = b64.indexOf('=') 1472 if (validLen === -1) validLen = len 1473 1474 var placeHoldersLen = validLen === len 1475 ? 0 1476 : 4 - (validLen % 4) 1477 1478 return [validLen, placeHoldersLen] 1479} 1480 1481// base64 is 4/3 + up to two characters of the original data 1482function byteLength (b64) { 1483 var lens = getLens(b64) 1484 var validLen = lens[0] 1485 var placeHoldersLen = lens[1] 1486 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen 1487} 1488 1489function _byteLength (b64, validLen, placeHoldersLen) { 1490 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen 1491} 1492 1493function toByteArray (b64) { 1494 var tmp 1495 var lens = getLens(b64) 1496 var validLen = lens[0] 1497 var placeHoldersLen = lens[1] 1498 1499 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) 1500 1501 var curByte = 0 1502 1503 // if there are placeholders, only get up to the last complete 4 chars 1504 var len = placeHoldersLen > 0 1505 ? validLen - 4 1506 : validLen 1507 1508 for (var i = 0; i < len; i += 4) { 1509 tmp = 1510 (revLookup[b64.charCodeAt(i)] << 18) | 1511 (revLookup[b64.charCodeAt(i + 1)] << 12) | 1512 (revLookup[b64.charCodeAt(i + 2)] << 6) | 1513 revLookup[b64.charCodeAt(i + 3)] 1514 arr[curByte++] = (tmp >> 16) & 0xFF 1515 arr[curByte++] = (tmp >> 8) & 0xFF 1516 arr[curByte++] = tmp & 0xFF 1517 } 1518 1519 if (placeHoldersLen === 2) { 1520 tmp = 1521 (revLookup[b64.charCodeAt(i)] << 2) | 1522 (revLookup[b64.charCodeAt(i + 1)] >> 4) 1523 arr[curByte++] = tmp & 0xFF 1524 } 1525 1526 if (placeHoldersLen === 1) { 1527 tmp = 1528 (revLookup[b64.charCodeAt(i)] << 10) | 1529 (revLookup[b64.charCodeAt(i + 1)] << 4) | 1530 (revLookup[b64.charCodeAt(i + 2)] >> 2) 1531 arr[curByte++] = (tmp >> 8) & 0xFF 1532 arr[curByte++] = tmp & 0xFF 1533 } 1534 1535 return arr 1536} 1537 1538function tripletToBase64 (num) { 1539 return lookup[num >> 18 & 0x3F] + 1540 lookup[num >> 12 & 0x3F] + 1541 lookup[num >> 6 & 0x3F] + 1542 lookup[num & 0x3F] 1543} 1544 1545function encodeChunk (uint8, start, end) { 1546 var tmp 1547 var output = [] 1548 for (var i = start; i < end; i += 3) { 1549 tmp = 1550 ((uint8[i] << 16) & 0xFF0000) + 1551 ((uint8[i + 1] << 8) & 0xFF00) + 1552 (uint8[i + 2] & 0xFF) 1553 output.push(tripletToBase64(tmp)) 1554 } 1555 return output.join('') 1556} 1557 1558function fromByteArray (uint8) { 1559 var tmp 1560 var len = uint8.length 1561 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes 1562 var parts = [] 1563 var maxChunkLength = 16383 // must be multiple of 3 1564 1565 // go through the array every three bytes, we'll deal with trailing stuff later 1566 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { 1567 parts.push(encodeChunk( 1568 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) 1569 )) 1570 } 1571 1572 // pad the end with zeros, but make sure to not forget the extra bytes 1573 if (extraBytes === 1) { 1574 tmp = uint8[len - 1] 1575 parts.push( 1576 lookup[tmp >> 2] + 1577 lookup[(tmp << 4) & 0x3F] + 1578 '==' 1579 ) 1580 } else if (extraBytes === 2) { 1581 tmp = (uint8[len - 2] << 8) + uint8[len - 1] 1582 parts.push( 1583 lookup[tmp >> 10] + 1584 lookup[(tmp >> 4) & 0x3F] + 1585 lookup[(tmp << 2) & 0x3F] + 1586 '=' 1587 ) 1588 } 1589 1590 return parts.join('') 1591} 1592 1593},{}],7
vendor: 48,818 bytes, lines 1593-3386
1593:[function(require,module,exports){ 1594(function (global){ 1595/*! 1596 * The buffer module from node.js, for the browser. 1597 * 1598 * @author Feross Aboukhadijeh <[email protected]> <http://feross.org> 1599 * @license MIT 1600 */ 1601/* eslint-disable no-proto */ 1602 1603'use strict' 1604 1605var base64 = require('base64-js') 1606var ieee754 = require('ieee754') 1607var isArray = require('isarray') 1608 1609exports.Buffer = Buffer 1610exports.SlowBuffer = SlowBuffer 1611exports.INSPECT_MAX_BYTES = 50 1612 1613/** 1614 * If `Buffer.TYPED_ARRAY_SUPPORT`: 1615 * === true Use Uint8Array implementation (fastest) 1616 * === false Use Object implementation (most compatible, even IE6) 1617 * 1618 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 1619 * Opera 11.6+, iOS 4.2+. 1620 * 1621 * Due to various browser bugs, sometimes the Object implementation will be used even 1622 * when the browser supports typed arrays. 1623 * 1624 * Note: 1625 * 1626 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, 1627 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. 1628 * 1629 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. 1630 * 1631 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of 1632 * incorrect length in some situations. 1633 1634 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they 1635 * get the Object implementation, which is slower but behaves correctly. 1636 */ 1637Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined 1638 ? global.TYPED_ARRAY_SUPPORT 1639 : typedArraySupport() 1640 1641/* 1642 * Export kMaxLength after typed array support is determined. 1643 */ 1644exports.kMaxLength = kMaxLength() 1645 1646function typedArraySupport () { 1647 try { 1648 var arr = new Uint8Array(1) 1649 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} 1650 return arr.foo() === 42 && // typed array instances can be augmented 1651 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` 1652 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` 1653 } catch (e) { 1654 return false 1655 } 1656} 1657 1658function kMaxLength () { 1659 return Buffer.TYPED_ARRAY_SUPPORT 1660 ? 0x7fffffff 1661 : 0x3fffffff 1662} 1663 1664function createBuffer (that, length) { 1665 if (kMaxLength() < length) { 1666 throw new RangeError('Invalid typed array length') 1667 } 1668 if (Buffer.TYPED_ARRAY_SUPPORT) { 1669 // Return an augmented `Uint8Array` instance, for best performance 1670 that = new Uint8Array(length) 1671 that.__proto__ = Buffer.prototype 1672 } else { 1673 // Fallback: Return an object instance of the Buffer class 1674 if (that === null) { 1675 that = new Buffer(length) 1676 } 1677 that.length = length 1678 } 1679 1680 return that 1681} 1682 1683/** 1684 * The Buffer constructor returns instances of `Uint8Array` that have their 1685 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of 1686 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods 1687 * and the `Uint8Array` methods. Square bracket notation works as expected -- it 1688 * returns a single octet. 1689 * 1690 * The `Uint8Array` prototype remains unmodified. 1691 */ 1692 1693function Buffer (arg, encodingOrOffset, length) { 1694 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { 1695 return new Buffer(arg, encodingOrOffset, length) 1696 } 1697 1698 // Common case. 1699 if (typeof arg === 'number') { 1700 if (typeof encodingOrOffset === 'string') { 1701 throw new Error( 1702 'If encoding is specified then the first argument must be a string' 1703 ) 1704 } 1705 return allocUnsafe(this, arg) 1706 } 1707 return from(this, arg, encodingOrOffset, length) 1708} 1709 1710Buffer.poolSize = 8192 // not used by this implementation 1711 1712// TODO: Legacy, not needed anymore. Remove in next major version. 1713Buffer._augment = function (arr) { 1714 arr.__proto__ = Buffer.prototype 1715 return arr 1716} 1717 1718function from (that, value, encodingOrOffset, length) { 1719 if (typeof value === 'number') { 1720 throw new TypeError('"value" argument must not be a number') 1721 } 1722 1723 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { 1724 return fromArrayBuffer(that, value, encodingOrOffset, length) 1725 } 1726 1727 if (typeof value === 'string') { 1728 return fromString(that, value, encodingOrOffset) 1729 } 1730 1731 return fromObject(that, value) 1732} 1733 1734/** 1735 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError 1736 * if value is a number. 1737 * Buffer.from(str[, encoding]) 1738 * Buffer.from(array) 1739 * Buffer.from(buffer) 1740 * Buffer.from(arrayBuffer[, byteOffset[, length]]) 1741 **/ 1742Buffer.from = function (value, encodingOrOffset, length) { 1743 return from(null, value, encodingOrOffset, length) 1744} 1745 1746if (Buffer.TYPED_ARRAY_SUPPORT) { 1747 Buffer.prototype.__proto__ = Uint8Array.prototype 1748 Buffer.__proto__ = Uint8Array 1749 if (typeof Symbol !== 'undefined' && Symbol.species && 1750 Buffer[Symbol.species] === Buffer) { 1751 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 1752 Object.defineProperty(Buffer, Symbol.species, { 1753 value: null, 1754 configurable: true 1755 }) 1756 } 1757} 1758 1759function assertSize (size) { 1760 if (typeof size !== 'number') { 1761 throw new TypeError('"size" argument must be a number') 1762 } else if (size < 0) { 1763 throw new RangeError('"size" argument must not be negative') 1764 } 1765} 1766 1767function alloc (that, size, fill, encoding) { 1768 assertSize(size) 1769 if (size <= 0) { 1770 return createBuffer(that, size) 1771 } 1772 if (fill !== undefined) { 1773 // Only pay attention to encoding if it's a string. This 1774 // prevents accidentally sending in a number that would 1775 // be interpretted as a start offset. 1776 return typeof encoding === 'string' 1777 ? createBuffer(that, size).fill(fill, encoding) 1778 : createBuffer(that, size).fill(fill) 1779 } 1780 return createBuffer(that, size) 1781} 1782 1783/** 1784 * Creates a new filled Buffer instance. 1785 * alloc(size[, fill[, encoding]]) 1786 **/ 1787Buffer.alloc = function (size, fill, encoding) { 1788 return alloc(null, size, fill, encoding) 1789} 1790 1791function allocUnsafe (that, size) { 1792 assertSize(size) 1793 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) 1794 if (!Buffer.TYPED_ARRAY_SUPPORT) { 1795 for (var i = 0; i < size; ++i) { 1796 that[i] = 0 1797 } 1798 } 1799 return that 1800} 1801 1802/** 1803 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. 1804 * */ 1805Buffer.allocUnsafe = function (size) { 1806 return allocUnsafe(null, size) 1807} 1808/** 1809 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. 1810 */ 1811Buffer.allocUnsafeSlow = function (size) { 1812 return allocUnsafe(null, size) 1813} 1814 1815function fromString (that, string, encoding) { 1816 if (typeof encoding !== 'string' || encoding === '') { 1817 encoding = 'utf8' 1818 } 1819 1820 if (!Buffer.isEncoding(encoding)) { 1821 throw new TypeError('"encoding" must be a valid string encoding') 1822 } 1823 1824 var length = byteLength(string, encoding) | 0 1825 that = createBuffer(that, length) 1826 1827 var actual = that.write(string, encoding) 1828 1829 if (actual !== length) { 1830 // Writing a hex string, for example, that contains invalid characters will 1831 // cause everything after the first invalid character to be ignored. (e.g. 1832 // 'abxxcd' will be treated as 'ab') 1833 that = that.slice(0, actual) 1834 } 1835 1836 return that 1837} 1838 1839function fromArrayLike (that, array) { 1840 var length = array.length < 0 ? 0 : checked(array.length) | 0 1841 that = createBuffer(that, length) 1842 for (var i = 0; i < length; i += 1) { 1843 that[i] = array[i] & 255 1844 } 1845 return that 1846} 1847 1848function fromArrayBuffer (that, array, byteOffset, length) { 1849 array.byteLength // this throws if `array` is not a valid ArrayBuffer 1850 1851 if (byteOffset < 0 || array.byteLength < byteOffset) { 1852 throw new RangeError('\'offset\' is out of bounds') 1853 } 1854 1855 if (array.byteLength < byteOffset + (length || 0)) { 1856 throw new RangeError('\'length\' is out of bounds') 1857 } 1858 1859 if (byteOffset === undefined && length === undefined) { 1860 array = new Uint8Array(array) 1861 } else if (length === undefined) { 1862 array = new Uint8Array(array, byteOffset) 1863 } else { 1864 array = new Uint8Array(array, byteOffset, length) 1865 } 1866 1867 if (Buffer.TYPED_ARRAY_SUPPORT) { 1868 // Return an augmented `Uint8Array` instance, for best performance 1869 that = array 1870 that.__proto__ = Buffer.prototype 1871 } else { 1872 // Fallback: Return an object instance of the Buffer class 1873 that = fromArrayLike(that, array) 1874 } 1875 return that 1876} 1877 1878function fromObject (that, obj) { 1879 if (Buffer.isBuffer(obj)) { 1880 var len = checked(obj.length) | 0 1881 that = createBuffer(that, len) 1882 1883 if (that.length === 0) { 1884 return that 1885 } 1886 1887 obj.copy(that, 0, 0, len) 1888 return that 1889 } 1890 1891 if (obj) { 1892 if ((typeof ArrayBuffer !== 'undefined' && 1893 obj.buffer instanceof ArrayBuffer) || 'length' in obj) { 1894 if (typeof obj.length !== 'number' || isnan(obj.length)) { 1895 return createBuffer(that, 0) 1896 } 1897 return fromArrayLike(that, obj) 1898 } 1899 1900 if (obj.type === 'Buffer' && isArray(obj.data)) { 1901 return fromArrayLike(that, obj.data) 1902 } 1903 } 1904 1905 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') 1906} 1907 1908function checked (length) { 1909 // Note: cannot use `length < kMaxLength()` here because that fails when 1910 // length is NaN (which is otherwise coerced to zero.) 1911 if (length >= kMaxLength()) { 1912 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 1913 'size: 0x' + kMaxLength().toString(16) + ' bytes') 1914 } 1915 return length | 0 1916} 1917 1918function SlowBuffer (length) { 1919 if (+length != length) { // eslint-disable-line eqeqeq 1920 length = 0 1921 } 1922 return Buffer.alloc(+length) 1923} 1924 1925Buffer.isBuffer = function isBuffer (b) { 1926 return !!(b != null && b._isBuffer) 1927} 1928 1929Buffer.compare = function compare (a, b) { 1930 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { 1931 throw new TypeError('Arguments must be Buffers') 1932 } 1933 1934 if (a === b) return 0 1935 1936 var x = a.length 1937 var y = b.length 1938 1939 for (var i = 0, len = Math.min(x, y); i < len; ++i) { 1940 if (a[i] !== b[i]) { 1941 x = a[i] 1942 y = b[i] 1943 break 1944 } 1945 } 1946 1947 if (x < y) return -1 1948 if (y < x) return 1 1949 return 0 1950} 1951 1952Buffer.isEncoding = function isEncoding (encoding) { 1953 switch (String(encoding).toLowerCase()) { 1954 case 'hex': 1955 case 'utf8': 1956 case 'utf-8': 1957 case 'ascii': 1958 case 'latin1': 1959 case 'binary': 1960 case 'base64': 1961 case 'ucs2': 1962 case 'ucs-2': 1963 case 'utf16le': 1964 case 'utf-16le': 1965 return true 1966 default: 1967 return false 1968 } 1969} 1970 1971Buffer.concat = function concat (list, length) { 1972 if (!isArray(list)) { 1973 throw new TypeError('"list" argument must be an Array of Buffers') 1974 } 1975 1976 if (list.length === 0) { 1977 return Buffer.alloc(0) 1978 } 1979 1980 var i 1981 if (length === undefined) { 1982 length = 0 1983 for (i = 0; i < list.length; ++i) { 1984 length += list[i].length 1985 } 1986 } 1987 1988 var buffer = Buffer.allocUnsafe(length) 1989 var pos = 0 1990 for (i = 0; i < list.length; ++i) { 1991 var buf = list[i] 1992 if (!Buffer.isBuffer(buf)) { 1993 throw new TypeError('"list" argument must be an Array of Buffers') 1994 } 1995 buf.copy(buffer, pos) 1996 pos += buf.length 1997 } 1998 return buffer 1999} 2000 2001function byteLength (string, encoding) { 2002 if (Buffer.isBuffer(string)) { 2003 return string.length 2004 } 2005 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && 2006 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { 2007 return string.byteLength 2008 } 2009 if (typeof string !== 'string') { 2010 string = '' + string 2011 } 2012 2013 var len = string.length 2014 if (len === 0) return 0 2015 2016 // Use a for loop to avoid recursion 2017 var loweredCase = false 2018 for (;;) { 2019 switch (encoding) { 2020 case 'ascii': 2021 case 'latin1': 2022 case 'binary': 2023 return len 2024 case 'utf8': 2025 case 'utf-8': 2026 case undefined: 2027 return utf8ToBytes(string).length 2028 case 'ucs2': 2029 case 'ucs-2': 2030 case 'utf16le': 2031 case 'utf-16le': 2032 return len * 2 2033 case 'hex': 2034 return len >>> 1 2035 case 'base64': 2036 return base64ToBytes(string).length 2037 default: 2038 if (loweredCase) return utf8ToBytes(string).length // assume utf8 2039 encoding = ('' + encoding).toLowerCase() 2040 loweredCase = true 2041 } 2042 } 2043} 2044Buffer.byteLength = byteLength 2045 2046function slowToString (encoding, start, end) { 2047 var loweredCase = false 2048 2049 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only 2050 // property of a typed array. 2051 2052 // This behaves neither like String nor Uint8Array in that we set start/end 2053 // to their upper/lower bounds if the value passed is out of range. 2054 // undefined is handled specially as per ECMA-262 6th Edition, 2055 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. 2056 if (start === undefined || start < 0) { 2057 start = 0 2058 } 2059 // Return early if start > this.length. Done here to prevent potential uint32 2060 // coercion fail below. 2061 if (start > this.length) { 2062 return '' 2063 } 2064 2065 if (end === undefined || end > this.length) { 2066 end = this.length 2067 } 2068 2069 if (end <= 0) { 2070 return '' 2071 } 2072 2073 // Force coersion to uint32. This will also coerce falsey/NaN values to 0. 2074 end >>>= 0 2075 start >>>= 0 2076 2077 if (end <= start) { 2078 return '' 2079 } 2080 2081 if (!encoding) encoding = 'utf8' 2082 2083 while (true) { 2084 switch (encoding) { 2085 case 'hex': 2086 return hexSlice(this, start, end) 2087 2088 case 'utf8': 2089 case 'utf-8': 2090 return utf8Slice(this, start, end) 2091 2092 case 'ascii': 2093 return asciiSlice(this, start, end) 2094 2095 case 'latin1': 2096 case 'binary': 2097 return latin1Slice(this, start, end) 2098 2099 case 'base64': 2100 return base64Slice(this, start, end) 2101 2102 case 'ucs2': 2103 case 'ucs-2': 2104 case 'utf16le': 2105 case 'utf-16le': 2106 return utf16leSlice(this, start, end) 2107 2108 default: 2109 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 2110 encoding = (encoding + '').toLowerCase() 2111 loweredCase = true 2112 } 2113 } 2114} 2115 2116// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect 2117// Buffer instances. 2118Buffer.prototype._isBuffer = true 2119 2120function swap (b, n, m) { 2121 var i = b[n] 2122 b[n] = b[m] 2123 b[m] = i 2124} 2125 2126Buffer.prototype.swap16 = function swap16 () { 2127 var len = this.length 2128 if (len % 2 !== 0) { 2129 throw new RangeError('Buffer size must be a multiple of 16-bits') 2130 } 2131 for (var i = 0; i < len; i += 2) { 2132 swap(this, i, i + 1) 2133 } 2134 return this 2135} 2136 2137Buffer.prototype.swap32 = function swap32 () { 2138 var len = this.length 2139 if (len % 4 !== 0) { 2140 throw new RangeError('Buffer size must be a multiple of 32-bits') 2141 } 2142 for (var i = 0; i < len; i += 4) { 2143 swap(this, i, i + 3) 2144 swap(this, i + 1, i + 2) 2145 } 2146 return this 2147} 2148 2149Buffer.prototype.swap64 = function swap64 () { 2150 var len = this.length 2151 if (len % 8 !== 0) { 2152 throw new RangeError('Buffer size must be a multiple of 64-bits') 2153 } 2154 for (var i = 0; i < len; i += 8) { 2155 swap(this, i, i + 7) 2156 swap(this, i + 1, i + 6) 2157 swap(this, i + 2, i + 5) 2158 swap(this, i + 3, i + 4) 2159 } 2160 return this 2161} 2162 2163Buffer.prototype.toString = function toString () { 2164 var length = this.length | 0 2165 if (length === 0) return '' 2166 if (arguments.length === 0) return utf8Slice(this, 0, length) 2167 return slowToString.apply(this, arguments) 2168} 2169 2170Buffer.prototype.equals = function equals (b) { 2171 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') 2172 if (this === b) return true 2173 return Buffer.compare(this, b) === 0 2174} 2175 2176Buffer.prototype.inspect = function inspect () { 2177 var str = '' 2178 var max = exports.INSPECT_MAX_BYTES 2179 if (this.length > 0) { 2180 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') 2181 if (this.length > max) str += ' ... ' 2182 } 2183 return '<Buffer ' + str + '>' 2184} 2185 2186Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { 2187 if (!Buffer.isBuffer(target)) { 2188 throw new TypeError('Argument must be a Buffer') 2189 } 2190 2191 if (start === undefined) { 2192 start = 0 2193 } 2194 if (end === undefined) { 2195 end = target ? target.length : 0 2196 } 2197 if (thisStart === undefined) { 2198 thisStart = 0 2199 } 2200 if (thisEnd === undefined) { 2201 thisEnd = this.length 2202 } 2203 2204 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { 2205 throw new RangeError('out of range index') 2206 } 2207 2208 if (thisStart >= thisEnd && start >= end) { 2209 return 0 2210 } 2211 if (thisStart >= thisEnd) { 2212 return -1 2213 } 2214 if (start >= end) { 2215 return 1 2216 } 2217 2218 start >>>= 0 2219 end >>>= 0 2220 thisStart >>>= 0 2221 thisEnd >>>= 0 2222 2223 if (this === target) return 0 2224 2225 var x = thisEnd - thisStart 2226 var y = end - start 2227 var len = Math.min(x, y) 2228 2229 var thisCopy = this.slice(thisStart, thisEnd) 2230 var targetCopy = target.slice(start, end) 2231 2232 for (var i = 0; i < len; ++i) { 2233 if (thisCopy[i] !== targetCopy[i]) { 2234 x = thisCopy[i] 2235 y = targetCopy[i] 2236 break 2237 } 2238 } 2239 2240 if (x < y) return -1 2241 if (y < x) return 1 2242 return 0 2243} 2244 2245// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, 2246// OR the last index of `val` in `buffer` at offset <= `byteOffset`. 2247// 2248// Arguments: 2249// - buffer - a Buffer to search 2250// - val - a string, Buffer, or number 2251// - byteOffset - an index into `buffer`; will be clamped to an int32 2252// - encoding - an optional encoding, relevant is val is a string 2253// - dir - true for indexOf, false for lastIndexOf 2254function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { 2255 // Empty buffer means no match 2256 if (buffer.length === 0) return -1 2257 2258 // Normalize byteOffset 2259 if (typeof byteOffset === 'string') { 2260 encoding = byteOffset 2261 byteOffset = 0 2262 } else if (byteOffset > 0x7fffffff) { 2263 byteOffset = 0x7fffffff 2264 } else if (byteOffset < -0x80000000) { 2265 byteOffset = -0x80000000 2266 } 2267 byteOffset = +byteOffset // Coerce to Number. 2268 if (isNaN(byteOffset)) { 2269 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer 2270 byteOffset = dir ? 0 : (buffer.length - 1) 2271 } 2272 2273 // Normalize byteOffset: negative offsets start from the end of the buffer 2274 if (byteOffset < 0) byteOffset = buffer.length + byteOffset 2275 if (byteOffset >= buffer.length) { 2276 if (dir) return -1 2277 else byteOffset = buffer.length - 1 2278 } else if (byteOffset < 0) { 2279 if (dir) byteOffset = 0 2280 else return -1 2281 } 2282 2283 // Normalize val 2284 if (typeof val === 'string') { 2285 val = Buffer.from(val, encoding) 2286 } 2287 2288 // Finally, search either indexOf (if dir is true) or lastIndexOf 2289 if (Buffer.isBuffer(val)) { 2290 // Special case: looking for empty string/buffer always fails 2291 if (val.length === 0) { 2292 return -1 2293 } 2294 return arrayIndexOf(buffer, val, byteOffset, encoding, dir) 2295 } else if (typeof val === 'number') { 2296 val = val & 0xFF // Search for a byte value [0-255] 2297 if (Buffer.TYPED_ARRAY_SUPPORT && 2298 typeof Uint8Array.prototype.indexOf === 'function') { 2299 if (dir) { 2300 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) 2301 } else { 2302 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) 2303 } 2304 } 2305 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) 2306 } 2307 2308 throw new TypeError('val must be string, number or Buffer') 2309} 2310 2311function arrayIndexOf (arr, val, byteOffset, encoding, dir) { 2312 var indexSize = 1 2313 var arrLength = arr.length 2314 var valLength = val.length 2315 2316 if (encoding !== undefined) { 2317 encoding = String(encoding).toLowerCase() 2318 if (encoding === 'ucs2' || encoding === 'ucs-2' || 2319 encoding === 'utf16le' || encoding === 'utf-16le') { 2320 if (arr.length < 2 || val.length < 2) { 2321 return -1 2322 } 2323 indexSize = 2 2324 arrLength /= 2 2325 valLength /= 2 2326 byteOffset /= 2 2327 } 2328 } 2329 2330 function read (buf, i) { 2331 if (indexSize === 1) { 2332 return buf[i] 2333 } else { 2334 return buf.readUInt16BE(i * indexSize) 2335 } 2336 } 2337 2338 var i 2339 if (dir) { 2340 var foundIndex = -1 2341 for (i = byteOffset; i < arrLength; i++) { 2342 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { 2343 if (foundIndex === -1) foundIndex = i 2344 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize 2345 } else { 2346 if (foundIndex !== -1) i -= i - foundIndex 2347 foundIndex = -1 2348 } 2349 } 2350 } else { 2351 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength 2352 for (i = byteOffset; i >= 0; i--) { 2353 var found = true 2354 for (var j = 0; j < valLength; j++) { 2355 if (read(arr, i + j) !== read(val, j)) { 2356 found = false 2357 break 2358 } 2359 } 2360 if (found) return i 2361 } 2362 } 2363 2364 return -1 2365} 2366 2367Buffer.prototype.includes = function includes (val, byteOffset, encoding) { 2368 return this.indexOf(val, byteOffset, encoding) !== -1 2369} 2370 2371Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { 2372 return bidirectionalIndexOf(this, val, byteOffset, encoding, true) 2373} 2374 2375Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { 2376 return bidirectionalIndexOf(this, val, byteOffset, encoding, false) 2377} 2378 2379function hexWrite (buf, string, offset, length) { 2380 offset = Number(offset) || 0 2381 var remaining = buf.length - offset 2382 if (!length) { 2383 length = remaining 2384 } else { 2385 length = Number(length) 2386 if (length > remaining) { 2387 length = remaining 2388 } 2389 } 2390 2391 // must be an even number of digits 2392 var strLen = string.length 2393 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') 2394 2395 if (length > strLen / 2) { 2396 length = strLen / 2 2397 } 2398 for (var i = 0; i < length; ++i) { 2399 var parsed = parseInt(string.substr(i * 2, 2), 16) 2400 if (isNaN(parsed)) return i 2401 buf[offset + i] = parsed 2402 } 2403 return i 2404} 2405 2406function utf8Write (buf, string, offset, length) { 2407 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) 2408} 2409 2410function asciiWrite (buf, string, offset, length) { 2411 return blitBuffer(asciiToBytes(string), buf, offset, length) 2412} 2413 2414function latin1Write (buf, string, offset, length) { 2415 return asciiWrite(buf, string, offset, length) 2416} 2417 2418function base64Write (buf, string, offset, length) { 2419 return blitBuffer(base64ToBytes(string), buf, offset, length) 2420} 2421 2422function ucs2Write (buf, string, offset, length) { 2423 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) 2424} 2425 2426Buffer.prototype.write = function write (string, offset, length, encoding) { 2427 // Buffer#write(string) 2428 if (offset === undefined) { 2429 encoding = 'utf8' 2430 length = this.length 2431 offset = 0 2432 // Buffer#write(string, encoding) 2433 } else if (length === undefined && typeof offset === 'string') { 2434 encoding = offset 2435 length = this.length 2436 offset = 0 2437 // Buffer#write(string, offset[, length][, encoding]) 2438 } else if (isFinite(offset)) { 2439 offset = offset | 0 2440 if (isFinite(length)) { 2441 length = length | 0 2442 if (encoding === undefined) encoding = 'utf8' 2443 } else { 2444 encoding = length 2445 length = undefined 2446 } 2447 // legacy write(string, encoding, offset, length) - remove in v0.13 2448 } else { 2449 throw new Error( 2450 'Buffer.write(string, encoding, offset[, length]) is no longer supported' 2451 ) 2452 } 2453 2454 var remaining = this.length - offset 2455 if (length === undefined || length > remaining) length = remaining 2456 2457 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { 2458 throw new RangeError('Attempt to write outside buffer bounds') 2459 } 2460 2461 if (!encoding) encoding = 'utf8' 2462 2463 var loweredCase = false 2464 for (;;) { 2465 switch (encoding) { 2466 case 'hex': 2467 return hexWrite(this, string, offset, length) 2468 2469 case 'utf8': 2470 case 'utf-8': 2471 return utf8Write(this, string, offset, length) 2472 2473 case 'ascii': 2474 return asciiWrite(this, string, offset, length) 2475 2476 case 'latin1': 2477 case 'binary': 2478 return latin1Write(this, string, offset, length) 2479 2480 case 'base64': 2481 // Warning: maxLength not taken into account in base64Write 2482 return base64Write(this, string, offset, length) 2483 2484 case 'ucs2': 2485 case 'ucs-2': 2486 case 'utf16le': 2487 case 'utf-16le': 2488 return ucs2Write(this, string, offset, length) 2489 2490 default: 2491 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 2492 encoding = ('' + encoding).toLowerCase() 2493 loweredCase = true 2494 } 2495 } 2496} 2497 2498Buffer.prototype.toJSON = function toJSON () { 2499 return { 2500 type: 'Buffer', 2501 data: Array.prototype.slice.call(this._arr || this, 0) 2502 } 2503} 2504 2505function base64Slice (buf, start, end) { 2506 if (start === 0 && end === buf.length) { 2507 return base64.fromByteArray(buf) 2508 } else { 2509 return base64.fromByteArray(buf.slice(start, end)) 2510 } 2511} 2512 2513function utf8Slice (buf, start, end) { 2514 end = Math.min(buf.length, end) 2515 var res = [] 2516 2517 var i = start 2518 while (i < end) { 2519 var firstByte = buf[i] 2520 var codePoint = null 2521 var bytesPerSequence = (firstByte > 0xEF) ? 4 2522 : (firstByte > 0xDF) ? 3 2523 : (firstByte > 0xBF) ? 2 2524 : 1 2525 2526 if (i + bytesPerSequence <= end) { 2527 var secondByte, thirdByte, fourthByte, tempCodePoint 2528 2529 switch (bytesPerSequence) { 2530 case 1: 2531 if (firstByte < 0x80) { 2532 codePoint = firstByte 2533 } 2534 break 2535 case 2: 2536 secondByte = buf[i + 1] 2537 if ((secondByte & 0xC0) === 0x80) { 2538 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) 2539 if (tempCodePoint > 0x7F) { 2540 codePoint = tempCodePoint 2541 } 2542 } 2543 break 2544 case 3: 2545 secondByte = buf[i + 1] 2546 thirdByte = buf[i + 2] 2547 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 2548 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) 2549 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 2550 codePoint = tempCodePoint 2551 } 2552 } 2553 break 2554 case 4: 2555 secondByte = buf[i + 1] 2556 thirdByte = buf[i + 2] 2557 fourthByte = buf[i + 3] 2558 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 2559 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) 2560 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 2561 codePoint = tempCodePoint 2562 } 2563 } 2564 } 2565 } 2566 2567 if (codePoint === null) { 2568 // we did not generate a valid codePoint so insert a 2569 // replacement char (U+FFFD) and advance only 1 byte 2570 codePoint = 0xFFFD 2571 bytesPerSequence = 1 2572 } else if (codePoint > 0xFFFF) { 2573 // encode to utf16 (surrogate pair dance) 2574 codePoint -= 0x10000 2575 res.push(codePoint >>> 10 & 0x3FF | 0xD800) 2576 codePoint = 0xDC00 | codePoint & 0x3FF 2577 } 2578 2579 res.push(codePoint) 2580 i += bytesPerSequence 2581 } 2582 2583 return decodeCodePointsArray(res) 2584} 2585 2586// Based on http://stackoverflow.com/a/22747272/680742, the browser with 2587// the lowest limit is Chrome, with 0x10000 args. 2588// We go 1 magnitude less, for safety 2589var MAX_ARGUMENTS_LENGTH = 0x1000 2590 2591function decodeCodePointsArray (codePoints) { 2592 var len = codePoints.length 2593 if (len <= MAX_ARGUMENTS_LENGTH) { 2594 return String.fromCharCode.apply(String, codePoints) // avoid extra slice() 2595 } 2596 2597 // Decode in chunks to avoid "call stack size exceeded". 2598 var res = '' 2599 var i = 0 2600 while (i < len) { 2601 res += String.fromCharCode.apply( 2602 String, 2603 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) 2604 ) 2605 } 2606 return res 2607} 2608 2609function asciiSlice (buf, start, end) { 2610 var ret = '' 2611 end = Math.min(buf.length, end) 2612 2613 for (var i = start; i < end; ++i) { 2614 ret += String.fromCharCode(buf[i] & 0x7F) 2615 } 2616 return ret 2617} 2618 2619function latin1Slice (buf, start, end) { 2620 var ret = '' 2621 end = Math.min(buf.length, end) 2622 2623 for (var i = start; i < end; ++i) { 2624 ret += String.fromCharCode(buf[i]) 2625 } 2626 return ret 2627} 2628 2629function hexSlice (buf, start, end) { 2630 var len = buf.length 2631 2632 if (!start || start < 0) start = 0 2633 if (!end || end < 0 || end > len) end = len 2634 2635 var out = '' 2636 for (var i = start; i < end; ++i) { 2637 out += toHex(buf[i]) 2638 } 2639 return out 2640} 2641 2642function utf16leSlice (buf, start, end) { 2643 var bytes = buf.slice(start, end) 2644 var res = '' 2645 for (var i = 0; i < bytes.length; i += 2) { 2646 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) 2647 } 2648 return res 2649} 2650 2651Buffer.prototype.slice = function slice (start, end) { 2652 var len = this.length 2653 start = ~~start 2654 end = end === undefined ? len : ~~end 2655 2656 if (start < 0) { 2657 start += len 2658 if (start < 0) start = 0 2659 } else if (start > len) { 2660 start = len 2661 } 2662 2663 if (end < 0) { 2664 end += len 2665 if (end < 0) end = 0 2666 } else if (end > len) { 2667 end = len 2668 } 2669 2670 if (end < start) end = start 2671 2672 var newBuf 2673 if (Buffer.TYPED_ARRAY_SUPPORT) { 2674 newBuf = this.subarray(start, end) 2675 newBuf.__proto__ = Buffer.prototype 2676 } else { 2677 var sliceLen = end - start 2678 newBuf = new Buffer(sliceLen, undefined) 2679 for (var i = 0; i < sliceLen; ++i) { 2680 newBuf[i] = this[i + start] 2681 } 2682 } 2683 2684 return newBuf 2685} 2686 2687/* 2688 * Need to make sure that buffer isn't trying to write out of bounds. 2689 */ 2690function checkOffset (offset, ext, length) { 2691 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') 2692 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') 2693} 2694 2695Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { 2696 offset = offset | 0 2697 byteLength = byteLength | 0 2698 if (!noAssert) checkOffset(offset, byteLength, this.length) 2699 2700 var val = this[offset] 2701 var mul = 1 2702 var i = 0 2703 while (++i < byteLength && (mul *= 0x100)) { 2704 val += this[offset + i] * mul 2705 } 2706 2707 return val 2708} 2709 2710Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { 2711 offset = offset | 0 2712 byteLength = byteLength | 0 2713 if (!noAssert) { 2714 checkOffset(offset, byteLength, this.length) 2715 } 2716 2717 var val = this[offset + --byteLength] 2718 var mul = 1 2719 while (byteLength > 0 && (mul *= 0x100)) { 2720 val += this[offset + --byteLength] * mul 2721 } 2722 2723 return val 2724} 2725 2726Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { 2727 if (!noAssert) checkOffset(offset, 1, this.length) 2728 return this[offset] 2729} 2730 2731Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { 2732 if (!noAssert) checkOffset(offset, 2, this.length) 2733 return this[offset] | (this[offset + 1] << 8) 2734} 2735 2736Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { 2737 if (!noAssert) checkOffset(offset, 2, this.length) 2738 return (this[offset] << 8) | this[offset + 1] 2739} 2740 2741Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { 2742 if (!noAssert) checkOffset(offset, 4, this.length) 2743 2744 return ((this[offset]) | 2745 (this[offset + 1] << 8) | 2746 (this[offset + 2] << 16)) + 2747 (this[offset + 3] * 0x1000000) 2748} 2749 2750Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { 2751 if (!noAssert) checkOffset(offset, 4, this.length) 2752 2753 return (this[offset] * 0x1000000) + 2754 ((this[offset + 1] << 16) | 2755 (this[offset + 2] << 8) | 2756 this[offset + 3]) 2757} 2758 2759Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { 2760 offset = offset | 0 2761 byteLength = byteLength | 0 2762 if (!noAssert) checkOffset(offset, byteLength, this.length) 2763 2764 var val = this[offset] 2765 var mul = 1 2766 var i = 0 2767 while (++i < byteLength && (mul *= 0x100)) { 2768 val += this[offset + i] * mul 2769 } 2770 mul *= 0x80 2771 2772 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 2773 2774 return val 2775} 2776 2777Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { 2778 offset = offset | 0 2779 byteLength = byteLength | 0 2780 if (!noAssert) checkOffset(offset, byteLength, this.length) 2781 2782 var i = byteLength 2783 var mul = 1 2784 var val = this[offset + --i] 2785 while (i > 0 && (mul *= 0x100)) { 2786 val += this[offset + --i] * mul 2787 } 2788 mul *= 0x80 2789 2790 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 2791 2792 return val 2793} 2794 2795Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { 2796 if (!noAssert) checkOffset(offset, 1, this.length) 2797 if (!(this[offset] & 0x80)) return (this[offset]) 2798 return ((0xff - this[offset] + 1) * -1) 2799} 2800 2801Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { 2802 if (!noAssert) checkOffset(offset, 2, this.length) 2803 var val = this[offset] | (this[offset + 1] << 8) 2804 return (val & 0x8000) ? val | 0xFFFF0000 : val 2805} 2806 2807Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { 2808 if (!noAssert) checkOffset(offset, 2, this.length) 2809 var val = this[offset + 1] | (this[offset] << 8) 2810 return (val & 0x8000) ? val | 0xFFFF0000 : val 2811} 2812 2813Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { 2814 if (!noAssert) checkOffset(offset, 4, this.length) 2815 2816 return (this[offset]) | 2817 (this[offset + 1] << 8) | 2818 (this[offset + 2] << 16) | 2819 (this[offset + 3] << 24) 2820} 2821 2822Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { 2823 if (!noAssert) checkOffset(offset, 4, this.length) 2824 2825 return (this[offset] << 24) | 2826 (this[offset + 1] << 16) | 2827 (this[offset + 2] << 8) | 2828 (this[offset + 3]) 2829} 2830 2831Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { 2832 if (!noAssert) checkOffset(offset, 4, this.length) 2833 return ieee754.read(this, offset, true, 23, 4) 2834} 2835 2836Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { 2837 if (!noAssert) checkOffset(offset, 4, this.length) 2838 return ieee754.read(this, offset, false, 23, 4) 2839} 2840 2841Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { 2842 if (!noAssert) checkOffset(offset, 8, this.length) 2843 return ieee754.read(this, offset, true, 52, 8) 2844} 2845 2846Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { 2847 if (!noAssert) checkOffset(offset, 8, this.length) 2848 return ieee754.read(this, offset, false, 52, 8) 2849} 2850 2851function checkInt (buf, value, offset, ext, max, min) { 2852 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') 2853 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') 2854 if (offset + ext > buf.length) throw new RangeError('Index out of range') 2855} 2856 2857Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { 2858 value = +value 2859 offset = offset | 0 2860 byteLength = byteLength | 0 2861 if (!noAssert) { 2862 var maxBytes = Math.pow(2, 8 * byteLength) - 1 2863 checkInt(this, value, offset, byteLength, maxBytes, 0) 2864 } 2865 2866 var mul = 1 2867 var i = 0 2868 this[offset] = value & 0xFF 2869 while (++i < byteLength && (mul *= 0x100)) { 2870 this[offset + i] = (value / mul) & 0xFF 2871 } 2872 2873 return offset + byteLength 2874} 2875 2876Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { 2877 value = +value 2878 offset = offset | 0 2879 byteLength = byteLength | 0 2880 if (!noAssert) { 2881 var maxBytes = Math.pow(2, 8 * byteLength) - 1 2882 checkInt(this, value, offset, byteLength, maxBytes, 0) 2883 } 2884 2885 var i = byteLength - 1 2886 var mul = 1 2887 this[offset + i] = value & 0xFF 2888 while (--i >= 0 && (mul *= 0x100)) { 2889 this[offset + i] = (value / mul) & 0xFF 2890 } 2891 2892 return offset + byteLength 2893} 2894 2895Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { 2896 value = +value 2897 offset = offset | 0 2898 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) 2899 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 2900 this[offset] = (value & 0xff) 2901 return offset + 1 2902} 2903 2904function objectWriteUInt16 (buf, value, offset, littleEndian) { 2905 if (value < 0) value = 0xffff + value + 1 2906 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { 2907 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> 2908 (littleEndian ? i : 1 - i) * 8 2909 } 2910} 2911 2912Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { 2913 value = +value 2914 offset = offset | 0 2915 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 2916 if (Buffer.TYPED_ARRAY_SUPPORT) { 2917 this[offset] = (value & 0xff) 2918 this[offset + 1] = (value >>> 8) 2919 } else { 2920 objectWriteUInt16(this, value, offset, true) 2921 } 2922 return offset + 2 2923} 2924 2925Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { 2926 value = +value 2927 offset = offset | 0 2928 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 2929 if (Buffer.TYPED_ARRAY_SUPPORT) { 2930 this[offset] = (value >>> 8) 2931 this[offset + 1] = (value & 0xff) 2932 } else { 2933 objectWriteUInt16(this, value, offset, false) 2934 } 2935 return offset + 2 2936} 2937 2938function objectWriteUInt32 (buf, value, offset, littleEndian) { 2939 if (value < 0) value = 0xffffffff + value + 1 2940 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { 2941 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff 2942 } 2943} 2944 2945Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { 2946 value = +value 2947 offset = offset | 0 2948 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 2949 if (Buffer.TYPED_ARRAY_SUPPORT) { 2950 this[offset + 3] = (value >>> 24) 2951 this[offset + 2] = (value >>> 16) 2952 this[offset + 1] = (value >>> 8) 2953 this[offset] = (value & 0xff) 2954 } else { 2955 objectWriteUInt32(this, value, offset, true) 2956 } 2957 return offset + 4 2958} 2959 2960Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { 2961 value = +value 2962 offset = offset | 0 2963 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 2964 if (Buffer.TYPED_ARRAY_SUPPORT) { 2965 this[offset] = (value >>> 24) 2966 this[offset + 1] = (value >>> 16) 2967 this[offset + 2] = (value >>> 8) 2968 this[offset + 3] = (value & 0xff) 2969 } else { 2970 objectWriteUInt32(this, value, offset, false) 2971 } 2972 return offset + 4 2973} 2974 2975Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { 2976 value = +value 2977 offset = offset | 0 2978 if (!noAssert) { 2979 var limit = Math.pow(2, 8 * byteLength - 1) 2980 2981 checkInt(this, value, offset, byteLength, limit - 1, -limit) 2982 } 2983 2984 var i = 0 2985 var mul = 1 2986 var sub = 0 2987 this[offset] = value & 0xFF 2988 while (++i < byteLength && (mul *= 0x100)) { 2989 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { 2990 sub = 1 2991 } 2992 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 2993 } 2994 2995 return offset + byteLength 2996} 2997 2998Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { 2999 value = +value 3000 offset = offset | 0 3001 if (!noAssert) { 3002 var limit = Math.pow(2, 8 * byteLength - 1) 3003 3004 checkInt(this, value, offset, byteLength, limit - 1, -limit) 3005 } 3006 3007 var i = byteLength - 1 3008 var mul = 1 3009 var sub = 0 3010 this[offset + i] = value & 0xFF 3011 while (--i >= 0 && (mul *= 0x100)) { 3012 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { 3013 sub = 1 3014 } 3015 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 3016 } 3017 3018 return offset + byteLength 3019} 3020 3021Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { 3022 value = +value 3023 offset = offset | 0 3024 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) 3025 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 3026 if (value < 0) value = 0xff + value + 1 3027 this[offset] = (value & 0xff) 3028 return offset + 1 3029} 3030 3031Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { 3032 value = +value 3033 offset = offset | 0 3034 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 3035 if (Buffer.TYPED_ARRAY_SUPPORT) { 3036 this[offset] = (value & 0xff) 3037 this[offset + 1] = (value >>> 8) 3038 } else { 3039 objectWriteUInt16(this, value, offset, true) 3040 } 3041 return offset + 2 3042} 3043 3044Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { 3045 value = +value 3046 offset = offset | 0 3047 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 3048 if (Buffer.TYPED_ARRAY_SUPPORT) { 3049 this[offset] = (value >>> 8) 3050 this[offset + 1] = (value & 0xff) 3051 } else { 3052 objectWriteUInt16(this, value, offset, false) 3053 } 3054 return offset + 2 3055} 3056 3057Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { 3058 value = +value 3059 offset = offset | 0 3060 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 3061 if (Buffer.TYPED_ARRAY_SUPPORT) { 3062 this[offset] = (value & 0xff) 3063 this[offset + 1] = (value >>> 8) 3064 this[offset + 2] = (value >>> 16) 3065 this[offset + 3] = (value >>> 24) 3066 } else { 3067 objectWriteUInt32(this, value, offset, true) 3068 } 3069 return offset + 4 3070} 3071 3072Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { 3073 value = +value 3074 offset = offset | 0 3075 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 3076 if (value < 0) value = 0xffffffff + value + 1 3077 if (Buffer.TYPED_ARRAY_SUPPORT) { 3078 this[offset] = (value >>> 24) 3079 this[offset + 1] = (value >>> 16) 3080 this[offset + 2] = (value >>> 8) 3081 this[offset + 3] = (value & 0xff) 3082 } else { 3083 objectWriteUInt32(this, value, offset, false) 3084 } 3085 return offset + 4 3086} 3087 3088function checkIEEE754 (buf, value, offset, ext, max, min) { 3089 if (offset + ext > buf.length) throw new RangeError('Index out of range') 3090 if (offset < 0) throw new RangeError('Index out of range') 3091} 3092 3093function writeFloat (buf, value, offset, littleEndian, noAssert) { 3094 if (!noAssert) { 3095 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) 3096 } 3097 ieee754.write(buf, value, offset, littleEndian, 23, 4) 3098 return offset + 4 3099} 3100 3101Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { 3102 return writeFloat(this, value, offset, true, noAssert) 3103} 3104 3105Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { 3106 return writeFloat(this, value, offset, false, noAssert) 3107} 3108 3109function writeDouble (buf, value, offset, littleEndian, noAssert) { 3110 if (!noAssert) { 3111 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) 3112 } 3113 ieee754.write(buf, value, offset, littleEndian, 52, 8) 3114 return offset + 8 3115} 3116 3117Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { 3118 return writeDouble(this, value, offset, true, noAssert) 3119} 3120 3121Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { 3122 return writeDouble(this, value, offset, false, noAssert) 3123} 3124 3125// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 3126Buffer.prototype.copy = function copy (target, targetStart, start, end) { 3127 if (!start) start = 0 3128 if (!end && end !== 0) end = this.length 3129 if (targetStart >= target.length) targetStart = target.length 3130 if (!targetStart) targetStart = 0 3131 if (end > 0 && end < start) end = start 3132 3133 // Copy 0 bytes; we're done 3134 if (end === start) return 0 3135 if (target.length === 0 || this.length === 0) return 0 3136 3137 // Fatal error conditions 3138 if (targetStart < 0) { 3139 throw new RangeError('targetStart out of bounds') 3140 } 3141 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') 3142 if (end < 0) throw new RangeError('sourceEnd out of bounds') 3143 3144 // Are we oob? 3145 if (end > this.length) end = this.length 3146 if (target.length - targetStart < end - start) { 3147 end = target.length - targetStart + start 3148 } 3149 3150 var len = end - start 3151 var i 3152 3153 if (this === target && start < targetStart && targetStart < end) { 3154 // descending copy from end 3155 for (i = len - 1; i >= 0; --i) { 3156 target[i + targetStart] = this[i + start] 3157 } 3158 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { 3159 // ascending copy from start 3160 for (i = 0; i < len; ++i) { 3161 target[i + targetStart] = this[i + start] 3162 } 3163 } else { 3164 Uint8Array.prototype.set.call( 3165 target, 3166 this.subarray(start, start + len), 3167 targetStart 3168 ) 3169 } 3170 3171 return len 3172} 3173 3174// Usage: 3175// buffer.fill(number[, offset[, end]]) 3176// buffer.fill(buffer[, offset[, end]]) 3177// buffer.fill(string[, offset[, end]][, encoding]) 3178Buffer.prototype.fill = function fill (val, start, end, encoding) { 3179 // Handle string cases: 3180 if (typeof val === 'string') { 3181 if (typeof start === 'string') { 3182 encoding = start 3183 start = 0 3184 end = this.length 3185 } else if (typeof end === 'string') { 3186 encoding = end 3187 end = this.length 3188 } 3189 if (val.length === 1) { 3190 var code = val.charCodeAt(0) 3191 if (code < 256) { 3192 val = code 3193 } 3194 } 3195 if (encoding !== undefined && typeof encoding !== 'string') { 3196 throw new TypeError('encoding must be a string') 3197 } 3198 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { 3199 throw new TypeError('Unknown encoding: ' + encoding) 3200 } 3201 } else if (typeof val === 'number') { 3202 val = val & 255 3203 } 3204 3205 // Invalid ranges are not set to a default, so can range check early. 3206 if (start < 0 || this.length < start || this.length < end) { 3207 throw new RangeError('Out of range index') 3208 } 3209 3210 if (end <= start) { 3211 return this 3212 } 3213 3214 start = start >>> 0 3215 end = end === undefined ? this.length : end >>> 0 3216 3217 if (!val) val = 0 3218 3219 var i 3220 if (typeof val === 'number') { 3221 for (i = start; i < end; ++i) { 3222 this[i] = val 3223 } 3224 } else { 3225 var bytes = Buffer.isBuffer(val) 3226 ? val 3227 : utf8ToBytes(new Buffer(val, encoding).toString()) 3228 var len = bytes.length 3229 for (i = 0; i < end - start; ++i) { 3230 this[i + start] = bytes[i % len] 3231 } 3232 } 3233 3234 return this 3235} 3236 3237// HELPER FUNCTIONS 3238// ================ 3239 3240var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g 3241 3242function base64clean (str) { 3243 // Node strips out invalid characters like \n and \t from the string, base64-js does not 3244 str = stringtrim(str).replace(INVALID_BASE64_RE, '') 3245 // Node converts strings with length < 2 to '' 3246 if (str.length < 2) return '' 3247 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 3248 while (str.length % 4 !== 0) { 3249 str = str + '=' 3250 } 3251 return str 3252} 3253 3254function stringtrim (str) { 3255 if (str.trim) return str.trim() 3256 return str.replace(/^\s+|\s+$/g, '') 3257} 3258 3259function toHex (n) { 3260 if (n < 16) return '0' + n.toString(16) 3261 return n.toString(16) 3262} 3263 3264function utf8ToBytes (string, units) { 3265 units = units || Infinity 3266 var codePoint 3267 var length = string.length 3268 var leadSurrogate = null 3269 var bytes = [] 3270 3271 for (var i = 0; i < length; ++i) { 3272 codePoint = string.charCodeAt(i) 3273 3274 // is surrogate component 3275 if (codePoint > 0xD7FF && codePoint < 0xE000) { 3276 // last char was a lead 3277 if (!leadSurrogate) { 3278 // no lead yet 3279 if (codePoint > 0xDBFF) { 3280 // unexpected trail 3281 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 3282 continue 3283 } else if (i + 1 === length) { 3284 // unpaired lead 3285 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 3286 continue 3287 } 3288 3289 // valid lead 3290 leadSurrogate = codePoint 3291 3292 continue 3293 } 3294 3295 // 2 leads in a row 3296 if (codePoint < 0xDC00) { 3297 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 3298 leadSurrogate = codePoint 3299 continue 3300 } 3301 3302 // valid surrogate pair 3303 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 3304 } else if (leadSurrogate) { 3305 // valid bmp char, but last char was a lead 3306 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 3307 } 3308 3309 leadSurrogate = null 3310 3311 // encode utf8 3312 if (codePoint < 0x80) { 3313 if ((units -= 1) < 0) break 3314 bytes.push(codePoint) 3315 } else if (codePoint < 0x800) { 3316 if ((units -= 2) < 0) break 3317 bytes.push( 3318 codePoint >> 0x6 | 0xC0, 3319 codePoint & 0x3F | 0x80 3320 ) 3321 } else if (codePoint < 0x10000) { 3322 if ((units -= 3) < 0) break 3323 bytes.push( 3324 codePoint >> 0xC | 0xE0, 3325 codePoint >> 0x6 & 0x3F | 0x80, 3326 codePoint & 0x3F | 0x80 3327 ) 3328 } else if (codePoint < 0x110000) { 3329 if ((units -= 4) < 0) break 3330 bytes.push( 3331 codePoint >> 0x12 | 0xF0, 3332 codePoint >> 0xC & 0x3F | 0x80, 3333 codePoint >> 0x6 & 0x3F | 0x80, 3334 codePoint & 0x3F | 0x80 3335 ) 3336 } else { 3337 throw new Error('Invalid code point') 3338 } 3339 } 3340 3341 return bytes 3342} 3343 3344function asciiToBytes (str) { 3345 var byteArray = [] 3346 for (var i = 0; i < str.length; ++i) { 3347 // Node's code seems to be doing this and not & 0x7F.. 3348 byteArray.push(str.charCodeAt(i) & 0xFF) 3349 } 3350 return byteArray 3351} 3352 3353function utf16leToBytes (str, units) { 3354 var c, hi, lo 3355 var byteArray = [] 3356 for (var i = 0; i < str.length; ++i) { 3357 if ((units -= 2) < 0) break 3358 3359 c = str.charCodeAt(i) 3360 hi = c >> 8 3361 lo = c % 256 3362 byteArray.push(lo) 3363 byteArray.push(hi) 3364 } 3365 3366 return byteArray 3367} 3368 3369function base64ToBytes (str) { 3370 return base64.toByteArray(base64clean(str)) 3371} 3372 3373function blitBuffer (src, dst, offset, length) { 3374 for (var i = 0; i < length; ++i) { 3375 if ((i + offset >= dst.length) || (i >= src.length)) break 3376 dst[i + offset] = src[i] 3377 } 3378 return i 3379} 3380 3381function isnan (val) { 3382 return val !== val // eslint-disable-line no-self-compare 3383} 3384 3385}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 3386},{"base64-js":
33866,"ieee754":14,"isarray":16}],8:[function(require,module,exports
vendor: 48,766 bytes, lines 3386-5165
3386){ 3387/*! 3388 * The buffer module from node.js, for the browser. 3389 * 3390 * @author Feross Aboukhadijeh <https://feross.org> 3391 * @license MIT 3392 */ 3393/* eslint-disable no-proto */ 3394 3395'use strict' 3396 3397var base64 = require('base64-js') 3398var ieee754 = require('ieee754') 3399 3400exports.Buffer = Buffer 3401exports.SlowBuffer = SlowBuffer 3402exports.INSPECT_MAX_BYTES = 50 3403 3404var K_MAX_LENGTH = 0x7fffffff 3405exports.kMaxLength = K_MAX_LENGTH 3406 3407/** 3408 * If `Buffer.TYPED_ARRAY_SUPPORT`: 3409 * === true Use Uint8Array implementation (fastest) 3410 * === false Print warning and recommend using `buffer` v4.x which has an Object 3411 * implementation (most compatible, even IE6) 3412 * 3413 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 3414 * Opera 11.6+, iOS 4.2+. 3415 * 3416 * We report that the browser does not support typed arrays if the are not subclassable 3417 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` 3418 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support 3419 * for __proto__ and has a buggy typed array implementation. 3420 */ 3421Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() 3422 3423if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && 3424 typeof console.error === 'function') { 3425 console.error( 3426 'This browser lacks typed array (Uint8Array) support which is required by ' + 3427 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' 3428 ) 3429} 3430 3431function typedArraySupport () { 3432 // Can typed array instances can be augmented? 3433 try { 3434 var arr = new Uint8Array(1) 3435 arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } 3436 return arr.foo() === 42 3437 } catch (e) { 3438 return false 3439 } 3440} 3441 3442Object.defineProperty(Buffer.prototype, 'parent', { 3443 enumerable: true, 3444 get: function () { 3445 if (!Buffer.isBuffer(this)) return undefined 3446 return this.buffer 3447 } 3448}) 3449 3450Object.defineProperty(Buffer.prototype, 'offset', { 3451 enumerable: true, 3452 get: function () { 3453 if (!Buffer.isBuffer(this)) return undefined 3454 return this.byteOffset 3455 } 3456}) 3457 3458function createBuffer (length) { 3459 if (length > K_MAX_LENGTH) { 3460 throw new RangeError('The value "' + length + '" is invalid for option "size"') 3461 } 3462 // Return an augmented `Uint8Array` instance 3463 var buf = new Uint8Array(length) 3464 buf.__proto__ = Buffer.prototype 3465 return buf 3466} 3467 3468/** 3469 * The Buffer constructor returns instances of `Uint8Array` that have their 3470 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of 3471 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods 3472 * and the `Uint8Array` methods. Square bracket notation works as expected -- it 3473 * returns a single octet. 3474 * 3475 * The `Uint8Array` prototype remains unmodified. 3476 */ 3477 3478function Buffer (arg, encodingOrOffset, length) { 3479 // Common case. 3480 if (typeof arg === 'number') { 3481 if (typeof encodingOrOffset === 'string') { 3482 throw new TypeError( 3483 'The "string" argument must be of type string. Received type number' 3484 ) 3485 } 3486 return allocUnsafe(arg) 3487 } 3488 return from(arg, encodingOrOffset, length) 3489} 3490 3491// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 3492if (typeof Symbol !== 'undefined' && Symbol.species != null && 3493 Buffer[Symbol.species] === Buffer) { 3494 Object.defineProperty(Buffer, Symbol.species, { 3495 value: null, 3496 configurable: true, 3497 enumerable: false, 3498 writable: false 3499 }) 3500} 3501 3502Buffer.poolSize = 8192 // not used by this implementation 3503 3504function from (value, encodingOrOffset, length) { 3505 if (typeof value === 'string') { 3506 return fromString(value, encodingOrOffset) 3507 } 3508 3509 if (ArrayBuffer.isView(value)) { 3510 return fromArrayLike(value) 3511 } 3512 3513 if (value == null) { 3514 throw TypeError( 3515 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 3516 'or Array-like Object. Received type ' + (typeof value) 3517 ) 3518 } 3519 3520 if (isInstance(value, ArrayBuffer) || 3521 (value && isInstance(value.buffer, ArrayBuffer))) { 3522 return fromArrayBuffer(value, encodingOrOffset, length) 3523 } 3524 3525 if (typeof value === 'number') { 3526 throw new TypeError( 3527 'The "value" argument must not be of type number. Received type number' 3528 ) 3529 } 3530 3531 var valueOf = value.valueOf && value.valueOf() 3532 if (valueOf != null && valueOf !== value) { 3533 return Buffer.from(valueOf, encodingOrOffset, length) 3534 } 3535 3536 var b = fromObject(value) 3537 if (b) return b 3538 3539 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && 3540 typeof value[Symbol.toPrimitive] === 'function') { 3541 return Buffer.from( 3542 value[Symbol.toPrimitive]('string'), encodingOrOffset, length 3543 ) 3544 } 3545 3546 throw new TypeError( 3547 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 3548 'or Array-like Object. Received type ' + (typeof value) 3549 ) 3550} 3551 3552/** 3553 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError 3554 * if value is a number. 3555 * Buffer.from(str[, encoding]) 3556 * Buffer.from(array) 3557 * Buffer.from(buffer) 3558 * Buffer.from(arrayBuffer[, byteOffset[, length]]) 3559 **/ 3560Buffer.from = function (value, encodingOrOffset, length) { 3561 return from(value, encodingOrOffset, length) 3562} 3563 3564// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: 3565// https://github.com/feross/buffer/pull/148 3566Buffer.prototype.__proto__ = Uint8Array.prototype 3567Buffer.__proto__ = Uint8Array 3568 3569function assertSize (size) { 3570 if (typeof size !== 'number') { 3571 throw new TypeError('"size" argument must be of type number') 3572 } else if (size < 0) { 3573 throw new RangeError('The value "' + size + '" is invalid for option "size"') 3574 } 3575} 3576 3577function alloc (size, fill, encoding) { 3578 assertSize(size) 3579 if (size <= 0) { 3580 return createBuffer(size) 3581 } 3582 if (fill !== undefined) { 3583 // Only pay attention to encoding if it's a string. This 3584 // prevents accidentally sending in a number that would 3585 // be interpretted as a start offset. 3586 return typeof encoding === 'string' 3587 ? createBuffer(size).fill(fill, encoding) 3588 : createBuffer(size).fill(fill) 3589 } 3590 return createBuffer(size) 3591} 3592 3593/** 3594 * Creates a new filled Buffer instance. 3595 * alloc(size[, fill[, encoding]]) 3596 **/ 3597Buffer.alloc = function (size, fill, encoding) { 3598 return alloc(size, fill, encoding) 3599} 3600 3601function allocUnsafe (size) { 3602 assertSize(size) 3603 return createBuffer(size < 0 ? 0 : checked(size) | 0) 3604} 3605 3606/** 3607 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. 3608 * */ 3609Buffer.allocUnsafe = function (size) { 3610 return allocUnsafe(size) 3611} 3612/** 3613 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. 3614 */ 3615Buffer.allocUnsafeSlow = function (size) { 3616 return allocUnsafe(size) 3617} 3618 3619function fromString (string, encoding) { 3620 if (typeof encoding !== 'string' || encoding === '') { 3621 encoding = 'utf8' 3622 } 3623 3624 if (!Buffer.isEncoding(encoding)) { 3625 throw new TypeError('Unknown encoding: ' + encoding) 3626 } 3627 3628 var length = byteLength(string, encoding) | 0 3629 var buf = createBuffer(length) 3630 3631 var actual = buf.write(string, encoding) 3632 3633 if (actual !== length) { 3634 // Writing a hex string, for example, that contains invalid characters will 3635 // cause everything after the first invalid character to be ignored. (e.g. 3636 // 'abxxcd' will be treated as 'ab') 3637 buf = buf.slice(0, actual) 3638 } 3639 3640 return buf 3641} 3642 3643function fromArrayLike (array) { 3644 var length = array.length < 0 ? 0 : checked(array.length) | 0 3645 var buf = createBuffer(length) 3646 for (var i = 0; i < length; i += 1) { 3647 buf[i] = array[i] & 255 3648 } 3649 return buf 3650} 3651 3652function fromArrayBuffer (array, byteOffset, length) { 3653 if (byteOffset < 0 || array.byteLength < byteOffset) { 3654 throw new RangeError('"offset" is outside of buffer bounds') 3655 } 3656 3657 if (array.byteLength < byteOffset + (length || 0)) { 3658 throw new RangeError('"length" is outside of buffer bounds') 3659 } 3660 3661 var buf 3662 if (byteOffset === undefined && length === undefined) { 3663 buf = new Uint8Array(array) 3664 } else if (length === undefined) { 3665 buf = new Uint8Array(array, byteOffset) 3666 } else { 3667 buf = new Uint8Array(array, byteOffset, length) 3668 } 3669 3670 // Return an augmented `Uint8Array` instance 3671 buf.__proto__ = Buffer.prototype 3672 return buf 3673} 3674 3675function fromObject (obj) { 3676 if (Buffer.isBuffer(obj)) { 3677 var len = checked(obj.length) | 0 3678 var buf = createBuffer(len) 3679 3680 if (buf.length === 0) { 3681 return buf 3682 } 3683 3684 obj.copy(buf, 0, 0, len) 3685 return buf 3686 } 3687 3688 if (obj.length !== undefined) { 3689 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { 3690 return createBuffer(0) 3691 } 3692 return fromArrayLike(obj) 3693 } 3694 3695 if (obj.type === 'Buffer' && Array.isArray(obj.data)) { 3696 return fromArrayLike(obj.data) 3697 } 3698} 3699 3700function checked (length) { 3701 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when 3702 // length is NaN (which is otherwise coerced to zero.) 3703 if (length >= K_MAX_LENGTH) { 3704 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 3705 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') 3706 } 3707 return length | 0 3708} 3709 3710function SlowBuffer (length) { 3711 if (+length != length) { // eslint-disable-line eqeqeq 3712 length = 0 3713 } 3714 return Buffer.alloc(+length) 3715} 3716 3717Buffer.isBuffer = function isBuffer (b) { 3718 return b != null && b._isBuffer === true && 3719 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false 3720} 3721 3722Buffer.compare = function compare (a, b) { 3723 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) 3724 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) 3725 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { 3726 throw new TypeError( 3727 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' 3728 ) 3729 } 3730 3731 if (a === b) return 0 3732 3733 var x = a.length 3734 var y = b.length 3735 3736 for (var i = 0, len = Math.min(x, y); i < len; ++i) { 3737 if (a[i] !== b[i]) { 3738 x = a[i] 3739 y = b[i] 3740 break 3741 } 3742 } 3743 3744 if (x < y) return -1 3745 if (y < x) return 1 3746 return 0 3747} 3748 3749Buffer.isEncoding = function isEncoding (encoding) { 3750 switch (String(encoding).toLowerCase()) { 3751 case 'hex': 3752 case 'utf8': 3753 case 'utf-8': 3754 case 'ascii': 3755 case 'latin1': 3756 case 'binary': 3757 case 'base64': 3758 case 'ucs2': 3759 case 'ucs-2': 3760 case 'utf16le': 3761 case 'utf-16le': 3762 return true 3763 default: 3764 return false 3765 } 3766} 3767 3768Buffer.concat = function concat (list, length) { 3769 if (!Array.isArray(list)) { 3770 throw new TypeError('"list" argument must be an Array of Buffers') 3771 } 3772 3773 if (list.length === 0) { 3774 return Buffer.alloc(0) 3775 } 3776 3777 var i 3778 if (length === undefined) { 3779 length = 0 3780 for (i = 0; i < list.length; ++i) { 3781 length += list[i].length 3782 } 3783 } 3784 3785 var buffer = Buffer.allocUnsafe(length) 3786 var pos = 0 3787 for (i = 0; i < list.length; ++i) { 3788 var buf = list[i] 3789 if (isInstance(buf, Uint8Array)) { 3790 buf = Buffer.from(buf) 3791 } 3792 if (!Buffer.isBuffer(buf)) { 3793 throw new TypeError('"list" argument must be an Array of Buffers') 3794 } 3795 buf.copy(buffer, pos) 3796 pos += buf.length 3797 } 3798 return buffer 3799} 3800 3801function byteLength (string, encoding) { 3802 if (Buffer.isBuffer(string)) { 3803 return string.length 3804 } 3805 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { 3806 return string.byteLength 3807 } 3808 if (typeof string !== 'string') { 3809 throw new TypeError( 3810 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + 3811 'Received type ' + typeof string 3812 ) 3813 } 3814 3815 var len = string.length 3816 var mustMatch = (arguments.length > 2 && arguments[2] === true) 3817 if (!mustMatch && len === 0) return 0 3818 3819 // Use a for loop to avoid recursion 3820 var loweredCase = false 3821 for (;;) { 3822 switch (encoding) { 3823 case 'ascii': 3824 case 'latin1': 3825 case 'binary': 3826 return len 3827 case 'utf8': 3828 case 'utf-8': 3829 return utf8ToBytes(string).length 3830 case 'ucs2': 3831 case 'ucs-2': 3832 case 'utf16le': 3833 case 'utf-16le': 3834 return len * 2 3835 case 'hex': 3836 return len >>> 1 3837 case 'base64': 3838 return base64ToBytes(string).length 3839 default: 3840 if (loweredCase) { 3841 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 3842 } 3843 encoding = ('' + encoding).toLowerCase() 3844 loweredCase = true 3845 } 3846 } 3847} 3848Buffer.byteLength = byteLength 3849 3850function slowToString (encoding, start, end) { 3851 var loweredCase = false 3852 3853 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only 3854 // property of a typed array. 3855 3856 // This behaves neither like String nor Uint8Array in that we set start/end 3857 // to their upper/lower bounds if the value passed is out of range. 3858 // undefined is handled specially as per ECMA-262 6th Edition, 3859 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. 3860 if (start === undefined || start < 0) { 3861 start = 0 3862 } 3863 // Return early if start > this.length. Done here to prevent potential uint32 3864 // coercion fail below. 3865 if (start > this.length) { 3866 return '' 3867 } 3868 3869 if (end === undefined || end > this.length) { 3870 end = this.length 3871 } 3872 3873 if (end <= 0) { 3874 return '' 3875 } 3876 3877 // Force coersion to uint32. This will also coerce falsey/NaN values to 0. 3878 end >>>= 0 3879 start >>>= 0 3880 3881 if (end <= start) { 3882 return '' 3883 } 3884 3885 if (!encoding) encoding = 'utf8' 3886 3887 while (true) { 3888 switch (encoding) { 3889 case 'hex': 3890 return hexSlice(this, start, end) 3891 3892 case 'utf8': 3893 case 'utf-8': 3894 return utf8Slice(this, start, end) 3895 3896 case 'ascii': 3897 return asciiSlice(this, start, end) 3898 3899 case 'latin1': 3900 case 'binary': 3901 return latin1Slice(this, start, end) 3902 3903 case 'base64': 3904 return base64Slice(this, start, end) 3905 3906 case 'ucs2': 3907 case 'ucs-2': 3908 case 'utf16le': 3909 case 'utf-16le': 3910 return utf16leSlice(this, start, end) 3911 3912 default: 3913 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 3914 encoding = (encoding + '').toLowerCase() 3915 loweredCase = true 3916 } 3917 } 3918} 3919 3920// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) 3921// to detect a Buffer instance. It's not possible to use `instanceof Buffer` 3922// reliably in a browserify context because there could be multiple different 3923// copies of the 'buffer' package in use. This method works even for Buffer 3924// instances that were created from another copy of the `buffer` package. 3925// See: https://github.com/feross/buffer/issues/154 3926Buffer.prototype._isBuffer = true 3927 3928function swap (b, n, m) { 3929 var i = b[n] 3930 b[n] = b[m] 3931 b[m] = i 3932} 3933 3934Buffer.prototype.swap16 = function swap16 () { 3935 var len = this.length 3936 if (len % 2 !== 0) { 3937 throw new RangeError('Buffer size must be a multiple of 16-bits') 3938 } 3939 for (var i = 0; i < len; i += 2) { 3940 swap(this, i, i + 1) 3941 } 3942 return this 3943} 3944 3945Buffer.prototype.swap32 = function swap32 () { 3946 var len = this.length 3947 if (len % 4 !== 0) { 3948 throw new RangeError('Buffer size must be a multiple of 32-bits') 3949 } 3950 for (var i = 0; i < len; i += 4) { 3951 swap(this, i, i + 3) 3952 swap(this, i + 1, i + 2) 3953 } 3954 return this 3955} 3956 3957Buffer.prototype.swap64 = function swap64 () { 3958 var len = this.length 3959 if (len % 8 !== 0) { 3960 throw new RangeError('Buffer size must be a multiple of 64-bits') 3961 } 3962 for (var i = 0; i < len; i += 8) { 3963 swap(this, i, i + 7) 3964 swap(this, i + 1, i + 6) 3965 swap(this, i + 2, i + 5) 3966 swap(this, i + 3, i + 4) 3967 } 3968 return this 3969} 3970 3971Buffer.prototype.toString = function toString () { 3972 var length = this.length 3973 if (length === 0) return '' 3974 if (arguments.length === 0) return utf8Slice(this, 0, length) 3975 return slowToString.apply(this, arguments) 3976} 3977 3978Buffer.prototype.toLocaleString = Buffer.prototype.toString 3979 3980Buffer.prototype.equals = function equals (b) { 3981 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') 3982 if (this === b) return true 3983 return Buffer.compare(this, b) === 0 3984} 3985 3986Buffer.prototype.inspect = function inspect () { 3987 var str = '' 3988 var max = exports.INSPECT_MAX_BYTES 3989 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() 3990 if (this.length > max) str += ' ... ' 3991 return '<Buffer ' + str + '>' 3992} 3993 3994Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { 3995 if (isInstance(target, Uint8Array)) { 3996 target = Buffer.from(target, target.offset, target.byteLength) 3997 } 3998 if (!Buffer.isBuffer(target)) { 3999 throw new TypeError( 4000 'The "target" argument must be one of type Buffer or Uint8Array. ' + 4001 'Received type ' + (typeof target) 4002 ) 4003 } 4004 4005 if (start === undefined) { 4006 start = 0 4007 } 4008 if (end === undefined) { 4009 end = target ? target.length : 0 4010 } 4011 if (thisStart === undefined) { 4012 thisStart = 0 4013 } 4014 if (thisEnd === undefined) { 4015 thisEnd = this.length 4016 } 4017 4018 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { 4019 throw new RangeError('out of range index') 4020 } 4021 4022 if (thisStart >= thisEnd && start >= end) { 4023 return 0 4024 } 4025 if (thisStart >= thisEnd) { 4026 return -1 4027 } 4028 if (start >= end) { 4029 return 1 4030 } 4031 4032 start >>>= 0 4033 end >>>= 0 4034 thisStart >>>= 0 4035 thisEnd >>>= 0 4036 4037 if (this === target) return 0 4038 4039 var x = thisEnd - thisStart 4040 var y = end - start 4041 var len = Math.min(x, y) 4042 4043 var thisCopy = this.slice(thisStart, thisEnd) 4044 var targetCopy = target.slice(start, end) 4045 4046 for (var i = 0; i < len; ++i) { 4047 if (thisCopy[i] !== targetCopy[i]) { 4048 x = thisCopy[i] 4049 y = targetCopy[i] 4050 break 4051 } 4052 } 4053 4054 if (x < y) return -1 4055 if (y < x) return 1 4056 return 0 4057} 4058 4059// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, 4060// OR the last index of `val` in `buffer` at offset <= `byteOffset`. 4061// 4062// Arguments: 4063// - buffer - a Buffer to search 4064// - val - a string, Buffer, or number 4065// - byteOffset - an index into `buffer`; will be clamped to an int32 4066// - encoding - an optional encoding, relevant is val is a string 4067// - dir - true for indexOf, false for lastIndexOf 4068function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { 4069 // Empty buffer means no match 4070 if (buffer.length === 0) return -1 4071 4072 // Normalize byteOffset 4073 if (typeof byteOffset === 'string') { 4074 encoding = byteOffset 4075 byteOffset = 0 4076 } else if (byteOffset > 0x7fffffff) { 4077 byteOffset = 0x7fffffff 4078 } else if (byteOffset < -0x80000000) { 4079 byteOffset = -0x80000000 4080 } 4081 byteOffset = +byteOffset // Coerce to Number. 4082 if (numberIsNaN(byteOffset)) { 4083 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer 4084 byteOffset = dir ? 0 : (buffer.length - 1) 4085 } 4086 4087 // Normalize byteOffset: negative offsets start from the end of the buffer 4088 if (byteOffset < 0) byteOffset = buffer.length + byteOffset 4089 if (byteOffset >= buffer.length) { 4090 if (dir) return -1 4091 else byteOffset = buffer.length - 1 4092 } else if (byteOffset < 0) { 4093 if (dir) byteOffset = 0 4094 else return -1 4095 } 4096 4097 // Normalize val 4098 if (typeof val === 'string') { 4099 val = Buffer.from(val, encoding) 4100 } 4101 4102 // Finally, search either indexOf (if dir is true) or lastIndexOf 4103 if (Buffer.isBuffer(val)) { 4104 // Special case: looking for empty string/buffer always fails 4105 if (val.length === 0) { 4106 return -1 4107 } 4108 return arrayIndexOf(buffer, val, byteOffset, encoding, dir) 4109 } else if (typeof val === 'number') { 4110 val = val & 0xFF // Search for a byte value [0-255] 4111 if (typeof Uint8Array.prototype.indexOf === 'function') { 4112 if (dir) { 4113 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) 4114 } else { 4115 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) 4116 } 4117 } 4118 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) 4119 } 4120 4121 throw new TypeError('val must be string, number or Buffer') 4122} 4123 4124function arrayIndexOf (arr, val, byteOffset, encoding, dir) { 4125 var indexSize = 1 4126 var arrLength = arr.length 4127 var valLength = val.length 4128 4129 if (encoding !== undefined) { 4130 encoding = String(encoding).toLowerCase() 4131 if (encoding === 'ucs2' || encoding === 'ucs-2' || 4132 encoding === 'utf16le' || encoding === 'utf-16le') { 4133 if (arr.length < 2 || val.length < 2) { 4134 return -1 4135 } 4136 indexSize = 2 4137 arrLength /= 2 4138 valLength /= 2 4139 byteOffset /= 2 4140 } 4141 } 4142 4143 function read (buf, i) { 4144 if (indexSize === 1) { 4145 return buf[i] 4146 } else { 4147 return buf.readUInt16BE(i * indexSize) 4148 } 4149 } 4150 4151 var i 4152 if (dir) { 4153 var foundIndex = -1 4154 for (i = byteOffset; i < arrLength; i++) { 4155 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { 4156 if (foundIndex === -1) foundIndex = i 4157 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize 4158 } else { 4159 if (foundIndex !== -1) i -= i - foundIndex 4160 foundIndex = -1 4161 } 4162 } 4163 } else { 4164 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength 4165 for (i = byteOffset; i >= 0; i--) { 4166 var found = true 4167 for (var j = 0; j < valLength; j++) { 4168 if (read(arr, i + j) !== read(val, j)) { 4169 found = false 4170 break 4171 } 4172 } 4173 if (found) return i 4174 } 4175 } 4176 4177 return -1 4178} 4179 4180Buffer.prototype.includes = function includes (val, byteOffset, encoding) { 4181 return this.indexOf(val, byteOffset, encoding) !== -1 4182} 4183 4184Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { 4185 return bidirectionalIndexOf(this, val, byteOffset, encoding, true) 4186} 4187 4188Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { 4189 return bidirectionalIndexOf(this, val, byteOffset, encoding, false) 4190} 4191 4192function hexWrite (buf, string, offset, length) { 4193 offset = Number(offset) || 0 4194 var remaining = buf.length - offset 4195 if (!length) { 4196 length = remaining 4197 } else { 4198 length = Number(length) 4199 if (length > remaining) { 4200 length = remaining 4201 } 4202 } 4203 4204 var strLen = string.length 4205 4206 if (length > strLen / 2) { 4207 length = strLen / 2 4208 } 4209 for (var i = 0; i < length; ++i) { 4210 var parsed = parseInt(string.substr(i * 2, 2), 16) 4211 if (numberIsNaN(parsed)) return i 4212 buf[offset + i] = parsed 4213 } 4214 return i 4215} 4216 4217function utf8Write (buf, string, offset, length) { 4218 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) 4219} 4220 4221function asciiWrite (buf, string, offset, length) { 4222 return blitBuffer(asciiToBytes(string), buf, offset, length) 4223} 4224 4225function latin1Write (buf, string, offset, length) { 4226 return asciiWrite(buf, string, offset, length) 4227} 4228 4229function base64Write (buf, string, offset, length) { 4230 return blitBuffer(base64ToBytes(string), buf, offset, length) 4231} 4232 4233function ucs2Write (buf, string, offset, length) { 4234 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) 4235} 4236 4237Buffer.prototype.write = function write (string, offset, length, encoding) { 4238 // Buffer#write(string) 4239 if (offset === undefined) { 4240 encoding = 'utf8' 4241 length = this.length 4242 offset = 0 4243 // Buffer#write(string, encoding) 4244 } else if (length === undefined && typeof offset === 'string') { 4245 encoding = offset 4246 length = this.length 4247 offset = 0 4248 // Buffer#write(string, offset[, length][, encoding]) 4249 } else if (isFinite(offset)) { 4250 offset = offset >>> 0 4251 if (isFinite(length)) { 4252 length = length >>> 0 4253 if (encoding === undefined) encoding = 'utf8' 4254 } else { 4255 encoding = length 4256 length = undefined 4257 } 4258 } else { 4259 throw new Error( 4260 'Buffer.write(string, encoding, offset[, length]) is no longer supported' 4261 ) 4262 } 4263 4264 var remaining = this.length - offset 4265 if (length === undefined || length > remaining) length = remaining 4266 4267 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { 4268 throw new RangeError('Attempt to write outside buffer bounds') 4269 } 4270 4271 if (!encoding) encoding = 'utf8' 4272 4273 var loweredCase = false 4274 for (;;) { 4275 switch (encoding) { 4276 case 'hex': 4277 return hexWrite(this, string, offset, length) 4278 4279 case 'utf8': 4280 case 'utf-8': 4281 return utf8Write(this, string, offset, length) 4282 4283 case 'ascii': 4284 return asciiWrite(this, string, offset, length) 4285 4286 case 'latin1': 4287 case 'binary': 4288 return latin1Write(this, string, offset, length) 4289 4290 case 'base64': 4291 // Warning: maxLength not taken into account in base64Write 4292 return base64Write(this, string, offset, length) 4293 4294 case 'ucs2': 4295 case 'ucs-2': 4296 case 'utf16le': 4297 case 'utf-16le': 4298 return ucs2Write(this, string, offset, length) 4299 4300 default: 4301 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 4302 encoding = ('' + encoding).toLowerCase() 4303 loweredCase = true 4304 } 4305 } 4306} 4307 4308Buffer.prototype.toJSON = function toJSON () { 4309 return { 4310 type: 'Buffer', 4311 data: Array.prototype.slice.call(this._arr || this, 0) 4312 } 4313} 4314 4315function base64Slice (buf, start, end) { 4316 if (start === 0 && end === buf.length) { 4317 return base64.fromByteArray(buf) 4318 } else { 4319 return base64.fromByteArray(buf.slice(start, end)) 4320 } 4321} 4322 4323function utf8Slice (buf, start, end) { 4324 end = Math.min(buf.length, end) 4325 var res = [] 4326 4327 var i = start 4328 while (i < end) { 4329 var firstByte = buf[i] 4330 var codePoint = null 4331 var bytesPerSequence = (firstByte > 0xEF) ? 4 4332 : (firstByte > 0xDF) ? 3 4333 : (firstByte > 0xBF) ? 2 4334 : 1 4335 4336 if (i + bytesPerSequence <= end) { 4337 var secondByte, thirdByte, fourthByte, tempCodePoint 4338 4339 switch (bytesPerSequence) { 4340 case 1: 4341 if (firstByte < 0x80) { 4342 codePoint = firstByte 4343 } 4344 break 4345 case 2: 4346 secondByte = buf[i + 1] 4347 if ((secondByte & 0xC0) === 0x80) { 4348 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) 4349 if (tempCodePoint > 0x7F) { 4350 codePoint = tempCodePoint 4351 } 4352 } 4353 break 4354 case 3: 4355 secondByte = buf[i + 1] 4356 thirdByte = buf[i + 2] 4357 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 4358 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) 4359 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 4360 codePoint = tempCodePoint 4361 } 4362 } 4363 break 4364 case 4: 4365 secondByte = buf[i + 1] 4366 thirdByte = buf[i + 2] 4367 fourthByte = buf[i + 3] 4368 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 4369 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) 4370 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 4371 codePoint = tempCodePoint 4372 } 4373 } 4374 } 4375 } 4376 4377 if (codePoint === null) { 4378 // we did not generate a valid codePoint so insert a 4379 // replacement char (U+FFFD) and advance only 1 byte 4380 codePoint = 0xFFFD 4381 bytesPerSequence = 1 4382 } else if (codePoint > 0xFFFF) { 4383 // encode to utf16 (surrogate pair dance) 4384 codePoint -= 0x10000 4385 res.push(codePoint >>> 10 & 0x3FF | 0xD800) 4386 codePoint = 0xDC00 | codePoint & 0x3FF 4387 } 4388 4389 res.push(codePoint) 4390 i += bytesPerSequence 4391 } 4392 4393 return decodeCodePointsArray(res) 4394} 4395 4396// Based on http://stackoverflow.com/a/22747272/680742, the browser with 4397// the lowest limit is Chrome, with 0x10000 args. 4398// We go 1 magnitude less, for safety 4399var MAX_ARGUMENTS_LENGTH = 0x1000 4400 4401function decodeCodePointsArray (codePoints) { 4402 var len = codePoints.length 4403 if (len <= MAX_ARGUMENTS_LENGTH) { 4404 return String.fromCharCode.apply(String, codePoints) // avoid extra slice() 4405 } 4406 4407 // Decode in chunks to avoid "call stack size exceeded". 4408 var res = '' 4409 var i = 0 4410 while (i < len) { 4411 res += String.fromCharCode.apply( 4412 String, 4413 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) 4414 ) 4415 } 4416 return res 4417} 4418 4419function asciiSlice (buf, start, end) { 4420 var ret = '' 4421 end = Math.min(buf.length, end) 4422 4423 for (var i = start; i < end; ++i) { 4424 ret += String.fromCharCode(buf[i] & 0x7F) 4425 } 4426 return ret 4427} 4428 4429function latin1Slice (buf, start, end) { 4430 var ret = '' 4431 end = Math.min(buf.length, end) 4432 4433 for (var i = start; i < end; ++i) { 4434 ret += String.fromCharCode(buf[i]) 4435 } 4436 return ret 4437} 4438 4439function hexSlice (buf, start, end) { 4440 var len = buf.length 4441 4442 if (!start || start < 0) start = 0 4443 if (!end || end < 0 || end > len) end = len 4444 4445 var out = '' 4446 for (var i = start; i < end; ++i) { 4447 out += toHex(buf[i]) 4448 } 4449 return out 4450} 4451 4452function utf16leSlice (buf, start, end) { 4453 var bytes = buf.slice(start, end) 4454 var res = '' 4455 for (var i = 0; i < bytes.length; i += 2) { 4456 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) 4457 } 4458 return res 4459} 4460 4461Buffer.prototype.slice = function slice (start, end) { 4462 var len = this.length 4463 start = ~~start 4464 end = end === undefined ? len : ~~end 4465 4466 if (start < 0) { 4467 start += len 4468 if (start < 0) start = 0 4469 } else if (start > len) { 4470 start = len 4471 } 4472 4473 if (end < 0) { 4474 end += len 4475 if (end < 0) end = 0 4476 } else if (end > len) { 4477 end = len 4478 } 4479 4480 if (end < start) end = start 4481 4482 var newBuf = this.subarray(start, end) 4483 // Return an augmented `Uint8Array` instance 4484 newBuf.__proto__ = Buffer.prototype 4485 return newBuf 4486} 4487 4488/* 4489 * Need to make sure that buffer isn't trying to write out of bounds. 4490 */ 4491function checkOffset (offset, ext, length) { 4492 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') 4493 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') 4494} 4495 4496Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { 4497 offset = offset >>> 0 4498 byteLength = byteLength >>> 0 4499 if (!noAssert) checkOffset(offset, byteLength, this.length) 4500 4501 var val = this[offset] 4502 var mul = 1 4503 var i = 0 4504 while (++i < byteLength && (mul *= 0x100)) { 4505 val += this[offset + i] * mul 4506 } 4507 4508 return val 4509} 4510 4511Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { 4512 offset = offset >>> 0 4513 byteLength = byteLength >>> 0 4514 if (!noAssert) { 4515 checkOffset(offset, byteLength, this.length) 4516 } 4517 4518 var val = this[offset + --byteLength] 4519 var mul = 1 4520 while (byteLength > 0 && (mul *= 0x100)) { 4521 val += this[offset + --byteLength] * mul 4522 } 4523 4524 return val 4525} 4526 4527Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { 4528 offset = offset >>> 0 4529 if (!noAssert) checkOffset(offset, 1, this.length) 4530 return this[offset] 4531} 4532 4533Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { 4534 offset = offset >>> 0 4535 if (!noAssert) checkOffset(offset, 2, this.length) 4536 return this[offset] | (this[offset + 1] << 8) 4537} 4538 4539Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { 4540 offset = offset >>> 0 4541 if (!noAssert) checkOffset(offset, 2, this.length) 4542 return (this[offset] << 8) | this[offset + 1] 4543} 4544 4545Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { 4546 offset = offset >>> 0 4547 if (!noAssert) checkOffset(offset, 4, this.length) 4548 4549 return ((this[offset]) | 4550 (this[offset + 1] << 8) | 4551 (this[offset + 2] << 16)) + 4552 (this[offset + 3] * 0x1000000) 4553} 4554 4555Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { 4556 offset = offset >>> 0 4557 if (!noAssert) checkOffset(offset, 4, this.length) 4558 4559 return (this[offset] * 0x1000000) + 4560 ((this[offset + 1] << 16) | 4561 (this[offset + 2] << 8) | 4562 this[offset + 3]) 4563} 4564 4565Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { 4566 offset = offset >>> 0 4567 byteLength = byteLength >>> 0 4568 if (!noAssert) checkOffset(offset, byteLength, this.length) 4569 4570 var val = this[offset] 4571 var mul = 1 4572 var i = 0 4573 while (++i < byteLength && (mul *= 0x100)) { 4574 val += this[offset + i] * mul 4575 } 4576 mul *= 0x80 4577 4578 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 4579 4580 return val 4581} 4582 4583Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { 4584 offset = offset >>> 0 4585 byteLength = byteLength >>> 0 4586 if (!noAssert) checkOffset(offset, byteLength, this.length) 4587 4588 var i = byteLength 4589 var mul = 1 4590 var val = this[offset + --i] 4591 while (i > 0 && (mul *= 0x100)) { 4592 val += this[offset + --i] * mul 4593 } 4594 mul *= 0x80 4595 4596 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 4597 4598 return val 4599} 4600 4601Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { 4602 offset = offset >>> 0 4603 if (!noAssert) checkOffset(offset, 1, this.length) 4604 if (!(this[offset] & 0x80)) return (this[offset]) 4605 return ((0xff - this[offset] + 1) * -1) 4606} 4607 4608Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { 4609 offset = offset >>> 0 4610 if (!noAssert) checkOffset(offset, 2, this.length) 4611 var val = this[offset] | (this[offset + 1] << 8) 4612 return (val & 0x8000) ? val | 0xFFFF0000 : val 4613} 4614 4615Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { 4616 offset = offset >>> 0 4617 if (!noAssert) checkOffset(offset, 2, this.length) 4618 var val = this[offset + 1] | (this[offset] << 8) 4619 return (val & 0x8000) ? val | 0xFFFF0000 : val 4620} 4621 4622Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { 4623 offset = offset >>> 0 4624 if (!noAssert) checkOffset(offset, 4, this.length) 4625 4626 return (this[offset]) | 4627 (this[offset + 1] << 8) | 4628 (this[offset + 2] << 16) | 4629 (this[offset + 3] << 24) 4630} 4631 4632Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { 4633 offset = offset >>> 0 4634 if (!noAssert) checkOffset(offset, 4, this.length) 4635 4636 return (this[offset] << 24) | 4637 (this[offset + 1] << 16) | 4638 (this[offset + 2] << 8) | 4639 (this[offset + 3]) 4640} 4641 4642Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { 4643 offset = offset >>> 0 4644 if (!noAssert) checkOffset(offset, 4, this.length) 4645 return ieee754.read(this, offset, true, 23, 4) 4646} 4647 4648Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { 4649 offset = offset >>> 0 4650 if (!noAssert) checkOffset(offset, 4, this.length) 4651 return ieee754.read(this, offset, false, 23, 4) 4652} 4653 4654Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { 4655 offset = offset >>> 0 4656 if (!noAssert) checkOffset(offset, 8, this.length) 4657 return ieee754.read(this, offset, true, 52, 8) 4658} 4659 4660Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { 4661 offset = offset >>> 0 4662 if (!noAssert) checkOffset(offset, 8, this.length) 4663 return ieee754.read(this, offset, false, 52, 8) 4664} 4665 4666function checkInt (buf, value, offset, ext, max, min) { 4667 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') 4668 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') 4669 if (offset + ext > buf.length) throw new RangeError('Index out of range') 4670} 4671 4672Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { 4673 value = +value 4674 offset = offset >>> 0 4675 byteLength = byteLength >>> 0 4676 if (!noAssert) { 4677 var maxBytes = Math.pow(2, 8 * byteLength) - 1 4678 checkInt(this, value, offset, byteLength, maxBytes, 0) 4679 } 4680 4681 var mul = 1 4682 var i = 0 4683 this[offset] = value & 0xFF 4684 while (++i < byteLength && (mul *= 0x100)) { 4685 this[offset + i] = (value / mul) & 0xFF 4686 } 4687 4688 return offset + byteLength 4689} 4690 4691Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { 4692 value = +value 4693 offset = offset >>> 0 4694 byteLength = byteLength >>> 0 4695 if (!noAssert) { 4696 var maxBytes = Math.pow(2, 8 * byteLength) - 1 4697 checkInt(this, value, offset, byteLength, maxBytes, 0) 4698 } 4699 4700 var i = byteLength - 1 4701 var mul = 1 4702 this[offset + i] = value & 0xFF 4703 while (--i >= 0 && (mul *= 0x100)) { 4704 this[offset + i] = (value / mul) & 0xFF 4705 } 4706 4707 return offset + byteLength 4708} 4709 4710Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { 4711 value = +value 4712 offset = offset >>> 0 4713 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) 4714 this[offset] = (value & 0xff) 4715 return offset + 1 4716} 4717 4718Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { 4719 value = +value 4720 offset = offset >>> 0 4721 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 4722 this[offset] = (value & 0xff) 4723 this[offset + 1] = (value >>> 8) 4724 return offset + 2 4725} 4726 4727Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { 4728 value = +value 4729 offset = offset >>> 0 4730 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 4731 this[offset] = (value >>> 8) 4732 this[offset + 1] = (value & 0xff) 4733 return offset + 2 4734} 4735 4736Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { 4737 value = +value 4738 offset = offset >>> 0 4739 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 4740 this[offset + 3] = (value >>> 24) 4741 this[offset + 2] = (value >>> 16) 4742 this[offset + 1] = (value >>> 8) 4743 this[offset] = (value & 0xff) 4744 return offset + 4 4745} 4746 4747Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { 4748 value = +value 4749 offset = offset >>> 0 4750 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 4751 this[offset] = (value >>> 24) 4752 this[offset + 1] = (value >>> 16) 4753 this[offset + 2] = (value >>> 8) 4754 this[offset + 3] = (value & 0xff) 4755 return offset + 4 4756} 4757 4758Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { 4759 value = +value 4760 offset = offset >>> 0 4761 if (!noAssert) { 4762 var limit = Math.pow(2, (8 * byteLength) - 1) 4763 4764 checkInt(this, value, offset, byteLength, limit - 1, -limit) 4765 } 4766 4767 var i = 0 4768 var mul = 1 4769 var sub = 0 4770 this[offset] = value & 0xFF 4771 while (++i < byteLength && (mul *= 0x100)) { 4772 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { 4773 sub = 1 4774 } 4775 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 4776 } 4777 4778 return offset + byteLength 4779} 4780 4781Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { 4782 value = +value 4783 offset = offset >>> 0 4784 if (!noAssert) { 4785 var limit = Math.pow(2, (8 * byteLength) - 1) 4786 4787 checkInt(this, value, offset, byteLength, limit - 1, -limit) 4788 } 4789 4790 var i = byteLength - 1 4791 var mul = 1 4792 var sub = 0 4793 this[offset + i] = value & 0xFF 4794 while (--i >= 0 && (mul *= 0x100)) { 4795 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { 4796 sub = 1 4797 } 4798 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 4799 } 4800 4801 return offset + byteLength 4802} 4803 4804Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { 4805 value = +value 4806 offset = offset >>> 0 4807 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) 4808 if (value < 0) value = 0xff + value + 1 4809 this[offset] = (value & 0xff) 4810 return offset + 1 4811} 4812 4813Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { 4814 value = +value 4815 offset = offset >>> 0 4816 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 4817 this[offset] = (value & 0xff) 4818 this[offset + 1] = (value >>> 8) 4819 return offset + 2 4820} 4821 4822Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { 4823 value = +value 4824 offset = offset >>> 0 4825 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 4826 this[offset] = (value >>> 8) 4827 this[offset + 1] = (value & 0xff) 4828 return offset + 2 4829} 4830 4831Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { 4832 value = +value 4833 offset = offset >>> 0 4834 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 4835 this[offset] = (value & 0xff) 4836 this[offset + 1] = (value >>> 8) 4837 this[offset + 2] = (value >>> 16) 4838 this[offset + 3] = (value >>> 24) 4839 return offset + 4 4840} 4841 4842Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { 4843 value = +value 4844 offset = offset >>> 0 4845 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 4846 if (value < 0) value = 0xffffffff + value + 1 4847 this[offset] = (value >>> 24) 4848 this[offset + 1] = (value >>> 16) 4849 this[offset + 2] = (value >>> 8) 4850 this[offset + 3] = (value & 0xff) 4851 return offset + 4 4852} 4853 4854function checkIEEE754 (buf, value, offset, ext, max, min) { 4855 if (offset + ext > buf.length) throw new RangeError('Index out of range') 4856 if (offset < 0) throw new RangeError('Index out of range') 4857} 4858 4859function writeFloat (buf, value, offset, littleEndian, noAssert) { 4860 value = +value 4861 offset = offset >>> 0 4862 if (!noAssert) { 4863 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) 4864 } 4865 ieee754.write(buf, value, offset, littleEndian, 23, 4) 4866 return offset + 4 4867} 4868 4869Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { 4870 return writeFloat(this, value, offset, true, noAssert) 4871} 4872 4873Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { 4874 return writeFloat(this, value, offset, false, noAssert) 4875} 4876 4877function writeDouble (buf, value, offset, littleEndian, noAssert) { 4878 value = +value 4879 offset = offset >>> 0 4880 if (!noAssert) { 4881 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) 4882 } 4883 ieee754.write(buf, value, offset, littleEndian, 52, 8) 4884 return offset + 8 4885} 4886 4887Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { 4888 return writeDouble(this, value, offset, true, noAssert) 4889} 4890 4891Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { 4892 return writeDouble(this, value, offset, false, noAssert) 4893} 4894 4895// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 4896Buffer.prototype.copy = function copy (target, targetStart, start, end) { 4897 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') 4898 if (!start) start = 0 4899 if (!end && end !== 0) end = this.length 4900 if (targetStart >= target.length) targetStart = target.length 4901 if (!targetStart) targetStart = 0 4902 if (end > 0 && end < start) end = start 4903 4904 // Copy 0 bytes; we're done 4905 if (end === start) return 0 4906 if (target.length === 0 || this.length === 0) return 0 4907 4908 // Fatal error conditions 4909 if (targetStart < 0) { 4910 throw new RangeError('targetStart out of bounds') 4911 } 4912 if (start < 0 || start >= this.length) throw new RangeError('Index out of range') 4913 if (end < 0) throw new RangeError('sourceEnd out of bounds') 4914 4915 // Are we oob? 4916 if (end > this.length) end = this.length 4917 if (target.length - targetStart < end - start) { 4918 end = target.length - targetStart + start 4919 } 4920 4921 var len = end - start 4922 4923 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { 4924 // Use built-in when available, missing from IE11 4925 this.copyWithin(targetStart, start, end) 4926 } else if (this === target && start < targetStart && targetStart < end) { 4927 // descending copy from end 4928 for (var i = len - 1; i >= 0; --i) { 4929 target[i + targetStart] = this[i + start] 4930 } 4931 } else { 4932 Uint8Array.prototype.set.call( 4933 target, 4934 this.subarray(start, end), 4935 targetStart 4936 ) 4937 } 4938 4939 return len 4940} 4941 4942// Usage: 4943// buffer.fill(number[, offset[, end]]) 4944// buffer.fill(buffer[, offset[, end]]) 4945// buffer.fill(string[, offset[, end]][, encoding]) 4946Buffer.prototype.fill = function fill (val, start, end, encoding) { 4947 // Handle string cases: 4948 if (typeof val === 'string') { 4949 if (typeof start === 'string') { 4950 encoding = start 4951 start = 0 4952 end = this.length 4953 } else if (typeof end === 'string') { 4954 encoding = end 4955 end = this.length 4956 } 4957 if (encoding !== undefined && typeof encoding !== 'string') { 4958 throw new TypeError('encoding must be a string') 4959 } 4960 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { 4961 throw new TypeError('Unknown encoding: ' + encoding) 4962 } 4963 if (val.length === 1) { 4964 var code = val.charCodeAt(0) 4965 if ((encoding === 'utf8' && code < 128) || 4966 encoding === 'latin1') { 4967 // Fast path: If `val` fits into a single byte, use that numeric value. 4968 val = code 4969 } 4970 } 4971 } else if (typeof val === 'number') { 4972 val = val & 255 4973 } 4974 4975 // Invalid ranges are not set to a default, so can range check early. 4976 if (start < 0 || this.length < start || this.length < end) { 4977 throw new RangeError('Out of range index') 4978 } 4979 4980 if (end <= start) { 4981 return this 4982 } 4983 4984 start = start >>> 0 4985 end = end === undefined ? this.length : end >>> 0 4986 4987 if (!val) val = 0 4988 4989 var i 4990 if (typeof val === 'number') { 4991 for (i = start; i < end; ++i) { 4992 this[i] = val 4993 } 4994 } else { 4995 var bytes = Buffer.isBuffer(val) 4996 ? val 4997 : Buffer.from(val, encoding) 4998 var len = bytes.length 4999 if (len === 0) { 5000 throw new TypeError('The value "' + val + 5001 '" is invalid for argument "value"') 5002 } 5003 for (i = 0; i < end - start; ++i) { 5004 this[i + start] = bytes[i % len] 5005 } 5006 } 5007 5008 return this 5009} 5010 5011// HELPER FUNCTIONS 5012// ================ 5013 5014var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g 5015 5016function base64clean (str) { 5017 // Node takes equal signs as end of the Base64 encoding 5018 str = str.split('=')[0] 5019 // Node strips out invalid characters like \n and \t from the string, base64-js does not 5020 str = str.trim().replace(INVALID_BASE64_RE, '') 5021 // Node converts strings with length < 2 to '' 5022 if (str.length < 2) return '' 5023 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 5024 while (str.length % 4 !== 0) { 5025 str = str + '=' 5026 } 5027 return str 5028} 5029 5030function toHex (n) { 5031 if (n < 16) return '0' + n.toString(16) 5032 return n.toString(16) 5033} 5034 5035function utf8ToBytes (string, units) { 5036 units = units || Infinity 5037 var codePoint 5038 var length = string.length 5039 var leadSurrogate = null 5040 var bytes = [] 5041 5042 for (var i = 0; i < length; ++i) { 5043 codePoint = string.charCodeAt(i) 5044 5045 // is surrogate component 5046 if (codePoint > 0xD7FF && codePoint < 0xE000) { 5047 // last char was a lead 5048 if (!leadSurrogate) { 5049 // no lead yet 5050 if (codePoint > 0xDBFF) { 5051 // unexpected trail 5052 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 5053 continue 5054 } else if (i + 1 === length) { 5055 // unpaired lead 5056 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 5057 continue 5058 } 5059 5060 // valid lead 5061 leadSurrogate = codePoint 5062 5063 continue 5064 } 5065 5066 // 2 leads in a row 5067 if (codePoint < 0xDC00) { 5068 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 5069 leadSurrogate = codePoint 5070 continue 5071 } 5072 5073 // valid surrogate pair 5074 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 5075 } else if (leadSurrogate) { 5076 // valid bmp char, but last char was a lead 5077 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 5078 } 5079 5080 leadSurrogate = null 5081 5082 // encode utf8 5083 if (codePoint < 0x80) { 5084 if ((units -= 1) < 0) break 5085 bytes.push(codePoint) 5086 } else if (codePoint < 0x800) { 5087 if ((units -= 2) < 0) break 5088 bytes.push( 5089 codePoint >> 0x6 | 0xC0, 5090 codePoint & 0x3F | 0x80 5091 ) 5092 } else if (codePoint < 0x10000) { 5093 if ((units -= 3) < 0) break 5094 bytes.push( 5095 codePoint >> 0xC | 0xE0, 5096 codePoint >> 0x6 & 0x3F | 0x80, 5097 codePoint & 0x3F | 0x80 5098 ) 5099 } else if (codePoint < 0x110000) { 5100 if ((units -= 4) < 0) break 5101 bytes.push( 5102 codePoint >> 0x12 | 0xF0, 5103 codePoint >> 0xC & 0x3F | 0x80, 5104 codePoint >> 0x6 & 0x3F | 0x80, 5105 codePoint & 0x3F | 0x80 5106 ) 5107 } else { 5108 throw new Error('Invalid code point') 5109 } 5110 } 5111 5112 return bytes 5113} 5114 5115function asciiToBytes (str) { 5116 var byteArray = [] 5117 for (var i = 0; i < str.length; ++i) { 5118 // Node's code seems to be doing this and not & 0x7F.. 5119 byteArray.push(str.charCodeAt(i) & 0xFF) 5120 } 5121 return byteArray 5122} 5123 5124function utf16leToBytes (str, units) { 5125 var c, hi, lo 5126 var byteArray = [] 5127 for (var i = 0; i < str.length; ++i) { 5128 if ((units -= 2) < 0) break 5129 5130 c = str.charCodeAt(i) 5131 hi = c >> 8 5132 lo = c % 256 5133 byteArray.push(lo) 5134 byteArray.push(hi) 5135 } 5136 5137 return byteArray 5138} 5139 5140function base64ToBytes (str) { 5141 return base64.toByteArray(base64clean(str)) 5142} 5143 5144function blitBuffer (src, dst, offset, length) { 5145 for (var i = 0; i < length; ++i) { 5146 if ((i + offset >= dst.length) || (i >= src.length)) break 5147 dst[i + offset] = src[i] 5148 } 5149 return i 5150} 5151 5152// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass 5153// the `instanceof` check but they should be treated as of that type. 5154// See: https://github.com/feross/buffer/issues/166 5155function isInstance (obj, type) { 5156 return obj instanceof type || 5157 (obj != null && obj.constructor != null && obj.constructor.name != null && 5158 obj.constructor.name === type.name) 5159} 5160function numberIsNaN (obj) { 5161 // For IE11 support 5162 return obj !== obj // eslint-disable-line no-self-compare 5163} 5164 5165}
5165,{"base64-js":6,"ieee754":14}],9:[function(require,module,exports){ 5166var BufferReader = require('./lib/buffer-reader') 5167 5168var XIPH_LACING = 1 5169var EBML_LACING = 3 5170var FIXED_SIZE_LACING = 2 5171 5172module.exports = function (buffer) { 5173 var block = {} 5174 var reader = new BufferReader(buffer) 5175 5176 block.trackNumber = reader.nextUIntV() 5177 block.timecode = reader.nextInt16BE() 5178 5179 var flags = reader.nextUInt8() 5180 5181 block.invisible = !!(flags & 0x8) 5182 5183 // only valid for SimpleBlock 5184 block.keyframe = !!(flags & 0x80) 5185 block.discardable = !!(flags & 0x1) 5186 5187 var lacing = (flags & 0x6) >> 1 5188 5189 block.frames = readLacedData(reader, lacing) 5190 5191 return block 5192} 5193 5194function readLacedData (reader, lacing) { 5195 if (!lacing) return [reader.nextBuffer()] 5196 5197 var i, frameSize 5198 var frames = [] 5199 var framesNum = reader.nextUInt8() + 1 // number of frames 5200 5201 if (lacing === FIXED_SIZE_LACING) { 5202 // remaining data should be divisible by the number of frames 5203 if (reader.length % framesNum !== 0) throw new Error('Fixed-Size Lacing Error') 5204 5205 frameSize = reader.length / framesNum 5206 for (i = 0; i < framesNum; i++) { 5207 frames.push(reader.nextBuffer(frameSize)) 5208 } 5209 return frames 5210 } 5211 5212 var frameSizes = [] 5213 5214 if (lacing === XIPH_LACING) { 5215 for (i = 0; i < framesNum - 1; i++) { 5216 var val 5217 frameSize = 0 5218 do { 5219 val = reader.nextUInt8() 5220 frameSize += val 5221 } while (val === 0xff) 5222 frameSizes.push(frameSize) 5223 } 5224 } else if (lacing === EBML_LACING) { 5225 // first frame 5226 frameSize = reader.nextUIntV() 5227 frameSizes.push(frameSize) 5228 5229 // middle frames 5230 for (i = 1; i < framesNum - 1; i++) { 5231 frameSize += reader.nextIntV() 5232 frameSizes.push(frameSize) 5233 } 5234 } 5235 5236 for (i = 0; i < framesNum - 1; i++) { 5237 frames.push(reader.nextBuffer(frameSizes[i])) 5238 } 5239 5240 // last frame (remaining buffer) 5241 frames.push(reader.nextBuffer()) 5242 5243 return frames 5244} 5245 5246},{"./lib/buffer-reader":10}],10:[function(require,module,exports){ 5247var vint = require('./vint') 5248 5249function BufferReader (buffer) { 5250 this.buffer = buffer 5251 this.offset = 0 5252} 5253 5254// a super limited subset of the node buffer API 5255BufferReader.prototype.nextInt16BE = function () { 5256 var value = this.buffer.readInt16BE(this.offset) 5257 this.offset += 2 5258 return value 5259} 5260 5261BufferReader.prototype.nextUInt8 = function () { 5262 var value = this.buffer.readUInt8(this.offset) 5263 this.offset += 1 5264 return value 5265} 5266 5267// EBML variable sized integers 5268BufferReader.prototype.nextUIntV = function () { 5269 var v = vint(this.buffer, this.offset) 5270 this.offset += v.length 5271 return v.value 5272} 5273 5274BufferReader.prototype.nextIntV = function () { 5275 var v = vint(this.buffer, this.offset, true) 5276 this.offset += v.length 5277 return v.value 5278} 5279 5280// buffer slice 5281BufferReader.prototype.nextBuffer = function (length) { 5282 var buffer = length 5283 ? this.buffer.slice(this.offset, this.offset + length) 5284 : this.buffer.slice(this.offset) 5285 this.offset += length || this.length 5286 return buffer 5287} 5288 5289// remaining bytes to read 5290Object.defineProperty(BufferReader.prototype, 'length', { 5291 get: function () { return this.buffer.length - this.offset } 5292}) 5293 5294module.exports = BufferReader 5295 5296},{"./vint":11}],11:[function(require,module,exports){ 5297// https://github.com/themasch/node-ebml/blob/master/lib/ebml/tools.js 5298module.exports = function (buffer, start, signed) { 5299 start = start || 0 5300 for (var length = 1; length <= 8; length++) { 5301 if (buffer[start] >= Math.pow(2, 8 - length)) { 5302 break 5303 } 5304 } 5305 if (length > 8) { 5306 throw new Error('Unrepresentable length: ' + length + ' ' + 5307 buffer.toString('hex', start, start + length)) 5308 } 5309 if (start + length > buffer.length) { 5310 return null 5311 } 5312 var i 5313 var value = buffer[start] & (1 << (8 - length)) - 1 5314 for (i = 1; i < length; i++) { 5315 if (i === 7) { 5316 if (value >= Math.pow(2, 53 - 8) && buffer[start + 7] > 0) { 5317 return { 5318 length: length, 5319 value: -1 5320 } 5321 } 5322 } 5323 value *= Math.pow(2, 8) 5324 value += buffer[start + i] 5325 } 5326 if (signed) { 5327 value -= Math.pow(2, length * 7 - 1) - 1 5328 } 5329 return { 5330 length: length, 5331 value: value 5332 } 5333} 5334 5335},{}],12:[function(require,module,exports){ 5336(function (Buffer){ 5337var tools = { 5338 readVint: function(buffer, start) { 5339 start = start || 0; 5340 for (var length = 1; length <= 8; length++) { 5341 if (buffer[start] >= Math.pow(2, 8 - length)) { 5342 break; 5343 } 5344 } 5345 if (length > 8) { 5346 throw new Error("Unrepresentable length: " + length + " " + 5347 buffer.toString('hex', start, start + length)); 5348 } 5349 if (start + length > buffer.length) { 5350 return null; 5351 } 5352 var value = buffer[start] & (1 << (8 - length)) - 1; 5353 for (var i = 1; i < length; i++) { 5354 if (i === 7) { 5355 if (value >= Math.pow(2, 53 - 8) && buffer[start + 7] > 0) { 5356 return { 5357 length: length, 5358 value: -1 5359 }; 5360 } 5361 } 5362 value *= Math.pow(2, 8); 5363 value += buffer[start + i]; 5364 } 5365 return { 5366 length: length, 5367 value: value 5368 }; 5369 }, 5370 5371 writeVint: function(value) { 5372 if (value < 0 || value > Math.pow(2, 53)) { 5373 throw new Error("Unrepresentable value: " + value); 5374 } 5375 for (var length = 1; length <= 8; length++) { 5376 if (value < Math.pow(2, 7 * length) - 1) { 5377 break; 5378 } 5379 } 5380 var buffer = new Buffer(length); 5381 for (var i = 1; i <= length; i++) { 5382 var b = value & 0xFF; 5383 buffer[length - i] = b; 5384 value -= b; 5385 value /= Math.pow(2, 8); 5386 } 5387 buffer[0] = buffer[0] | (1 << (8 - length)); 5388 return buffer; 5389 } 5390}; 5391 5392module.exports = tools; 5393 5394}).call(this,require("buffer").Buffer) 5395},{"buffer":7}],13:[function(require,module,exports){ 5396// Copyright Joyent, Inc. and other Node contributors. 5397// 5398// Permission is hereby granted, free of charge, to any person obtaining a 5399// copy of this software and associated documentation files (the 5400// "Software"), to deal in the Software without restriction, including 5401// without limitation the rights to use, copy, modify, merge, publish, 5402// distribute, sublicense, and/or sell copies of the Software, and to permit 5403// persons to whom the Software is furnished to do so, subject to the 5404// following conditions: 5405// 5406// The above copyright notice and this permission notice shall be included 5407// in all copies or substantial portions of the Software. 5408// 5409// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 5410// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 5411// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 5412// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 5413// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 5414// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 5415// USE OR OTHER DEALINGS IN THE SOFTWARE. 5416 5417function EventEmitter() { 5418 this._events = this._events || {}; 5419 this._maxListeners = this._maxListeners || undefined; 5420} 5421module.exports = EventEmitter; 5422 5423// Backwards-compat with node 0.10.x 5424EventEmitter.EventEmitter = EventEmitter; 5425 5426EventEmitter.prototype._events = undefined; 5427EventEmitter.prototype._maxListeners = undefined; 5428 5429// By default EventEmitters will print a warning if more than 10 listeners are 5430// added to it. This is a useful default which helps finding memory leaks. 5431EventEmitter.defaultMaxListeners = 10; 5432 5433// Obviously not all Emitters should be limited to 10. This function allows 5434// that to be increased. Set to zero for unlimited. 5435EventEmitter.prototype.setMaxListeners = function(n) { 5436 if (!isNumber(n) || n < 0 || isNaN(n)) 5437 throw TypeError('n must be a positive number'); 5438 this._maxListeners = n; 5439 return this; 5440}; 5441 5442EventEmitter.prototype.emit = function(type) { 5443 var er, handler, len, args, i, listeners; 5444 5445 if (!this._events) 5446 this._events = {}; 5447 5448 // If there is no 'error' event listener then throw. 5449 if (type === 'error') { 5450 if (!this._events.error || 5451 (isObject(this._events.error) && !this._events.error.length)) { 5452 er = arguments[1]; 5453 if (er instanceof Error) { 5454 throw er; // Unhandled 'error' event 5455 } else { 5456 // At least give some kind of context to the user 5457 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); 5458 err.context = er; 5459 throw err; 5460 } 5461 } 5462 } 5463 5464 handler = this._events[type]; 5465 5466 if (isUndefined(handler)) 5467 return false;
vendor: 5,674 bytes, lines 5468-5699
5468 5469 if (isFunction(handler)) { 5470 switch (arguments.length) { 5471 // fast cases 5472 case 1: 5473 handler.call(this); 5474 break; 5475 case 2: 5476 handler.call(this, arguments[1]); 5477 break; 5478 case 3: 5479 handler.call(this, arguments[1], arguments[2]); 5480 break; 5481 // slower 5482 default: 5483 args = Array.prototype.slice.call(arguments, 1); 5484 handler.apply(this, args); 5485 } 5486 } else if (isObject(handler)) { 5487 args = Array.prototype.slice.call(arguments, 1); 5488 listeners = handler.slice(); 5489 len = listeners.length; 5490 for (i = 0; i < len; i++) 5491 listeners[i].apply(this, args); 5492 } 5493 5494 return true; 5495}; 5496 5497EventEmitter.prototype.addListener = function(type, listener) { 5498 var m; 5499 5500 if (!isFunction(listener)) 5501 throw TypeError('listener must be a function'); 5502 5503 if (!this._events) 5504 this._events = {}; 5505 5506 // To avoid recursion in the case that type === "newListener"! Before 5507 // adding it to the listeners, first emit "newListener". 5508 if (this._events.newListener) 5509 this.emit('newListener', type, 5510 isFunction(listener.listener) ? 5511 listener.listener : listener); 5512 5513 if (!this._events[type]) 5514 // Optimize the case of one listener. Don't need the extra array object. 5515 this._events[type] = listener; 5516 else if (isObject(this._events[type])) 5517 // If we've already got an array, just append. 5518 this._events[type].push(listener); 5519 else 5520 // Adding the second element, need to change to array. 5521 this._events[type] = [this._events[type], listener]; 5522 5523 // Check for listener leak 5524 if (isObject(this._events[type]) && !this._events[type].warned) { 5525 if (!isUndefined(this._maxListeners)) { 5526 m = this._maxListeners; 5527 } else { 5528 m = EventEmitter.defaultMaxListeners; 5529 } 5530 5531 if (m && m > 0 && this._events[type].length > m) { 5532 this._events[type].warned = true; 5533 console.error('(node) warning: possible EventEmitter memory ' + 5534 'leak detected. %d listeners added. ' + 5535 'Use emitter.setMaxListeners() to increase limit.', 5536 this._events[type].length); 5537 if (typeof console.trace === 'function') { 5538 // not supported in IE 10 5539 console.trace(); 5540 } 5541 } 5542 } 5543 5544 return this; 5545}; 5546 5547EventEmitter.prototype.on = EventEmitter.prototype.addListener; 5548 5549EventEmitter.prototype.once = function(type, listener) { 5550 if (!isFunction(listener)) 5551 throw TypeError('listener must be a function'); 5552 5553 var fired = false; 5554 5555 function g() { 5556 this.removeListener(type, g); 5557 5558 if (!fired) { 5559 fired = true; 5560 listener.apply(this, arguments); 5561 } 5562 } 5563 5564 g.listener = listener; 5565 this.on(type, g); 5566 5567 return this; 5568}; 5569 5570// emits a 'removeListener' event iff the listener was removed 5571EventEmitter.prototype.removeListener = function(type, listener) { 5572 var list, position, length, i; 5573 5574 if (!isFunction(listener)) 5575 throw TypeError('listener must be a function'); 5576 5577 if (!this._events || !this._events[type]) 5578 return this; 5579 5580 list = this._events[type]; 5581 length = list.length; 5582 position = -1; 5583 5584 if (list === listener || 5585 (isFunction(list.listener) && list.listener === listener)) { 5586 delete this._events[type]; 5587 if (this._events.removeListener) 5588 this.emit('removeListener', type, listener); 5589 5590 } else if (isObject(list)) { 5591 for (i = length; i-- > 0;) { 5592 if (list[i] === listener || 5593 (list[i].listener && list[i].listener === listener)) { 5594 position = i; 5595 break; 5596 } 5597 } 5598 5599 if (position < 0) 5600 return this; 5601 5602 if (list.length === 1) { 5603 list.length = 0; 5604 delete this._events[type]; 5605 } else { 5606 list.splice(position, 1); 5607 } 5608 5609 if (this._events.removeListener) 5610 this.emit('removeListener', type, listener); 5611 } 5612 5613 return this; 5614}; 5615 5616EventEmitter.prototype.removeAllListeners = function(type) { 5617 var key, listeners; 5618 5619 if (!this._events) 5620 return this; 5621 5622 // not listening for removeListener, no need to emit 5623 if (!this._events.removeListener) { 5624 if (arguments.length === 0) 5625 this._events = {}; 5626 else if (this._events[type]) 5627 delete this._events[type]; 5628 return this; 5629 } 5630 5631 // emit removeListener for all listeners on all events 5632 if (arguments.length === 0) { 5633 for (key in this._events) { 5634 if (key === 'removeListener') continue; 5635 this.removeAllListeners(key); 5636 } 5637 this.removeAllListeners('removeListener'); 5638 this._events = {}; 5639 return this; 5640 } 5641 5642 listeners = this._events[type]; 5643 5644 if (isFunction(listeners)) { 5645 this.removeListener(type, listeners); 5646 } else if (listeners) { 5647 // LIFO order 5648 while (listeners.length) 5649 this.removeListener(type, listeners[listeners.length - 1]); 5650 } 5651 delete this._events[type]; 5652 5653 return this; 5654}; 5655 5656EventEmitter.prototype.listeners = function(type) { 5657 var ret; 5658 if (!this._events || !this._events[type]) 5659 ret = []; 5660 else if (isFunction(this._events[type])) 5661 ret = [this._events[type]]; 5662 else 5663 ret = this._events[type].slice(); 5664 return ret; 5665}; 5666 5667EventEmitter.prototype.listenerCount = function(type) { 5668 if (this._events) { 5669 var evlistener = this._events[type]; 5670 5671 if (isFunction(evlistener)) 5672 return 1; 5673 else if (evlistener) 5674 return evlistener.length; 5675 } 5676 return 0; 5677}; 5678 5679EventEmitter.listenerCount = function(emitter, type) { 5680 return emitter.listenerCount(type); 5681}; 5682 5683function isFunction(arg) { 5684 return typeof arg === 'function'; 5685} 5686 5687function isNumber(arg) { 5688 return typeof arg === 'number'; 5689} 5690 5691function isObject(arg) { 5692 return typeof arg === 'object' && arg !== null; 5693} 5694 5695function isUndefined(arg) { 5696 return arg === void 0; 5697} 5698 5699},{}],14:[function(require,module,exports){
5700exports.read = function (buffer, offset, isLE, mLen, nBytes) { 5701 var e, m 5702 var eLen = (nBytes * 8) - mLen - 1 5703 var eMax = (1 << eLen) - 1 5704 var eBias = eMax >> 1 5705 var nBits = -7 5706 var i = isLE ? (nBytes - 1) : 0 5707 var d = isLE ? -1 : 1 5708 var s = buffer[offset + i] 5709 5710 i += d 5711 5712 e = s & ((1 << (-nBits)) - 1) 5713 s >>= (-nBits) 5714 nBits += eLen 5715 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} 5716 5717 m = e & ((1 << (-nBits)) - 1) 5718 e >>= (-nBits) 5719 nBits += mLen 5720 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} 5721 5722 if (e === 0) { 5723 e = 1 - eBias 5724 } else if (e === eMax) { 5725 return m ? NaN : ((s ? -1 : 1) * Infinity) 5726 } else { 5727 m = m + Math.pow(2, mLen) 5728 e = e - eBias 5729 } 5730 return (s ? -1 : 1) * m * Math.pow(2, e - mLen) 5731} 5732 5733exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { 5734 var e, m, c 5735 var eLen = (nBytes * 8) - mLen - 1 5736 var eMax = (1 << eLen) - 1 5737 var eBias = eMax >> 1 5738 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) 5739 var i = isLE ? 0 : (nBytes - 1) 5740 var d = isLE ? 1 : -1 5741 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 5742 5743 value = Math.abs(value) 5744 5745 if (isNaN(value) || value === Infinity) { 5746 m = isNaN(value) ? 1 : 0 5747 e = eMax 5748 } else { 5749 e = Math.floor(Math.log(value) / Math.LN2) 5750 if (value * (c = Math.pow(2, -e)) < 1) { 5751 e-- 5752 c *= 2 5753 } 5754 if (e + eBias >= 1) { 5755 value += rt / c 5756 } else { 5757 value += rt * Math.pow(2, 1 - eBias) 5758 } 5759 if (value * c >= 2) { 5760 e++ 5761 c /= 2 5762 } 5763 5764 if (e + eBias >= eMax) { 5765 m = 0 5766 e = eMax 5767 } else if (e + eBias >= 1) { 5768 m = ((value * c) - 1) * Math.pow(2, mLen) 5769 e = e + eBias 5770 } else { 5771 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) 5772 e = 0 5773 } 5774 } 5775 5776 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} 5777 5778 e = (e << mLen) | m 5779 eLen += mLen 5780 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} 5781 5782 buffer[offset + i - d] |= s * 128 5783} 5784 5785},{}],15:[function(require,module,exports){ 5786(function (Buffer){ 5787// int64-buffer.js 5788 5789/*jshint -W018 */ // Confusing use of '!'. 5790/*jshint -W030 */ // Expected an assignment or function call and instead saw an expression. 5791/*jshint -W093 */ // Did you mean to return a conditional instead of an assignment? 5792 5793var Uint64BE, Int64BE, Uint64LE, Int64LE; 5794 5795!function(exports) { 5796 // constants 5797 5798 var UNDEFINED = "undefined"; 5799 var BUFFER = (UNDEFINED !== typeof Buffer) && Buffer; 5800 var UINT8ARRAY = (UNDEFINED !== typeof Uint8Array) && Uint8Array; 5801 var ARRAYBUFFER = (UNDEFINED !== typeof ArrayBuffer) && ArrayBuffer; 5802 var ZERO = [0, 0, 0, 0, 0, 0, 0, 0]; 5803 var isArray = Array.isArray || _isArray; 5804 var BIT32 = 4294967296; 5805 var BIT24 = 16777216; 5806 5807 // storage class 5808 5809 var storage; // Array; 5810 5811 // generate classes 5812 5813 Uint64BE = factory("Uint64BE", true, true); 5814 Int64BE = factory("Int64BE", true, false); 5815 Uint64LE = factory("Uint64LE", false, true); 5816 Int64LE = factory("Int64LE", false, false); 5817 5818 // class factory 5819 5820 function factory(name, bigendian, unsigned) { 5821 var posH = bigendian ? 0 : 4; 5822 var posL = bigendian ? 4 : 0; 5823 var pos0 = bigendian ? 0 : 3; 5824 var pos1 = bigendian ? 1 : 2; 5825 var pos2 = bigendian ? 2 : 1; 5826 var pos3 = bigendian ? 3 : 0; 5827 var fromPositive = bigendian ? fromPositiveBE : fromPositiveLE; 5828 var fromNegative = bigendian ? fromNegativeBE : fromNegativeLE; 5829 var proto = Int64.prototype; 5830 var isName = "is" + name; 5831 var _isInt64 = "_" + isName; 5832 5833 // properties 5834 proto.buffer = void 0; 5835 proto.offset = 0; 5836 proto[_isInt64] = true; 5837 5838 // methods 5839 proto.toNumber = toNumber; 5840 proto.toString = toString; 5841 proto.toJSON = toNumber; 5842 proto.toArray = toArray; 5843 5844 // add .toBuffer() method only when Buffer available 5845 if (BUFFER) proto.toBuffer = toBuffer; 5846 5847 // add .toArrayBuffer() method only when Uint8Array available 5848 if (UINT8ARRAY) proto.toArrayBuffer = toArrayBuffer; 5849 5850 // isUint64BE, isInt64BE 5851 Int64[isName] = isInt64; 5852 5853 // CommonJS 5854 exports[name] = Int64; 5855 5856 return Int64; 5857 5858 // constructor 5859 function Int64(buffer, offset, value, raddix) { 5860 if (!(this instanceof Int64)) return new Int64(buffer, offset, value, raddix); 5861 return init(this, buffer, offset, value, raddix); 5862 } 5863 5864 // isUint64BE, isInt64BE 5865 function isInt64(b) { 5866 return !!(b && b[_isInt64]); 5867 } 5868 5869 // initializer 5870 function init(that, buffer, offset, value, raddix) { 5871 if (UINT8ARRAY && ARRAYBUFFER) { 5872 if (buffer instanceof ARRAYBUFFER) buffer = new UINT8ARRAY(buffer); 5873 if (value instanceof ARRAYBUFFER) value = new UINT8ARRAY(value); 5874 } 5875 5876 // Int64BE() style 5877 if (!buffer && !offset && !value && !storage) { 5878 // shortcut to initialize with zero 5879 that.buffer = newArray(ZERO, 0); 5880 return; 5881 } 5882 5883 // Int64BE(value, raddix) style 5884 if (!isValidBuffer(buffer, offset)) { 5885 var _storage = storage || Array; 5886 raddix = offset; 5887 value = buffer; 5888 offset = 0; 5889 buffer = new _storage(8); 5890 } 5891 5892 that.buffer = buffer; 5893 that.offset = offset |= 0; 5894 5895 // Int64BE(buffer, offset) style 5896 if (UNDEFINED === typeof value) return; 5897 5898 // Int64BE(buffer, offset, value, raddix) style 5899 if ("string" === typeof value) { 5900 fromString(buffer, offset, value, raddix || 10); 5901 } else if (isValidBuffer(value, raddix)) { 5902 fromArray(buffer, offset, value, raddix); 5903 } else if ("number" === typeof raddix) { 5904 writeInt32(buffer, offset + posH, value); // high 5905 writeInt32(buffer, offset + posL, raddix); // low 5906 } else if (value > 0) { 5907 fromPositive(buffer, offset, value); // positive 5908 } else if (value < 0) { 5909 fromNegative(buffer, offset, value); // negative 5910 } else { 5911 fromArray(buffer, offset, ZERO, 0); // zero, NaN and others 5912 } 5913 } 5914 5915 function fromString(buffer, offset, str, raddix) { 5916 var pos = 0; 5917 var len = str.length; 5918 var high = 0; 5919 var low = 0; 5920 if (str[0] === "-") pos++; 5921 var sign = pos; 5922 while (pos < len) { 5923 var chr = parseInt(str[pos++], raddix); 5924 if (!(chr >= 0)) break; // NaN 5925 low = low * raddix + chr; 5926 high = high * raddix + Math.floor(low / BIT32); 5927 low %= BIT32; 5928 } 5929 if (sign) { 5930 high = ~high; 5931 if (low) { 5932 low = BIT32 - low; 5933 } else { 5934 high++; 5935 } 5936 } 5937 writeInt32(buffer, offset + posH, high); 5938 writeInt32(buffer, offset + posL, low); 5939 } 5940 5941 function toNumber() { 5942 var buffer = this.buffer; 5943 var offset = this.offset; 5944 var high = readInt32(buffer, offset + posH); 5945 var low = readInt32(buffer, offset + posL); 5946 if (!unsigned) high |= 0; // a trick to get signed 5947 return high ? (high * BIT32 + low) : low; 5948 } 5949 5950 function toString(radix) { 5951 var buffer = this.buffer; 5952 var offset = this.offset; 5953 var high = readInt32(buffer, offset + posH); 5954 var low = readInt32(buffer, offset + posL); 5955 var str = ""; 5956 var sign = !unsigned && (high & 0x80000000); 5957 if (sign) { 5958 high = ~high; 5959 low = BIT32 - low; 5960 } 5961 radix = radix || 10; 5962 while (1) { 5963 var mod = (high % radix) * BIT32 + low; 5964 high = Math.floor(high / radix); 5965 low = Math.floor(mod / radix); 5966 str = (mod % radix).toString(radix) + str; 5967 if (!high && !low) break; 5968 } 5969 if (sign) { 5970 str = "-" + str; 5971 } 5972 return str; 5973 } 5974 5975 function writeInt32(buffer, offset, value) { 5976 buffer[offset + pos3] = value & 255; 5977 value = value >> 8; 5978 buffer[offset + pos2] = value & 255; 5979 value = value >> 8; 5980 buffer[offset + pos1] = value & 255; 5981 value = value >> 8; 5982 buffer[offset + pos0] = value & 255; 5983 } 5984 5985 function readInt32(buffer, offset) { 5986 return (buffer[offset + pos0] * BIT24) + 5987 (buffer[offset + pos1] << 16) + 5988 (buffer[offset + pos2] << 8) + 5989 buffer[offset + pos3]; 5990 } 5991 } 5992 5993 function toArray(raw) { 5994 var buffer = this.buffer; 5995 var offset = this.offset; 5996 storage = null; // Array 5997 if (raw !== false && offset === 0 && buffer.length === 8 && isArray(buffer)) return buffer; 5998 return newArray(buffer, offset); 5999 } 6000 6001 function toBuffer(raw) { 6002 var buffer = this.buffer; 6003 var offset = this.offset; 6004 storage = BUFFER; 6005 if (raw !== false && offset === 0 && buffer.length === 8 && Buffer.isBuffer(buffer)) return buffer; 6006 var dest = new BUFFER(8); 6007 fromArray(dest, 0, buffer, offset); 6008 return dest; 6009 } 6010 6011 function toArrayBuffer(raw) { 6012 var buffer = this.buffer; 6013 var offset = this.offset; 6014 var arrbuf = buffer.buffer; 6015 storage = UINT8ARRAY; 6016 if (raw !== false && offset === 0 && (arrbuf instanceof ARRAYBUFFER) && arrbuf.byteLength === 8) return arrbuf; 6017 var dest = new UINT8ARRAY(8); 6018 fromArray(dest, 0, buffer, offset); 6019 return dest.buffer; 6020 } 6021 6022 function isValidBuffer(buffer, offset) { 6023 var len = buffer && buffer.length; 6024 offset |= 0; 6025 return len && (offset + 8 <= len) && ("string" !== typeof buffer[offset]); 6026 } 6027 6028 function fromArray(destbuf, destoff, srcbuf, srcoff) { 6029 destoff |= 0; 6030 srcoff |= 0; 6031 for (var i = 0; i < 8; i++) { 6032 destbuf[destoff++] = srcbuf[srcoff++] & 255; 6033 } 6034 } 6035 6036 function newArray(buffer, offset) { 6037 return Array.prototype.slice.call(buffer, offset, offset + 8); 6038 } 6039 6040 function fromPositiveBE(buffer, offset, value) { 6041 var pos = offset + 8; 6042 while (pos > offset) { 6043 buffer[--pos] = value & 255; 6044 value /= 256; 6045 } 6046 } 6047 6048 function fromNegativeBE(buffer, offset, value) { 6049 var pos = offset + 8; 6050 value++; 6051 while (pos > offset) { 6052 buffer[--pos] = ((-value) & 255) ^ 255; 6053 value /= 256; 6054 } 6055 } 6056 6057 function fromPositiveLE(buffer, offset, value) { 6058 var end = offset + 8; 6059 while (offset < end) { 6060 buffer[offset++] = value & 255; 6061 value /= 256; 6062 } 6063 } 6064 6065 function fromNegativeLE(buffer, offset, value) { 6066 var end = offset + 8; 6067 value++; 6068 while (offset < end) { 6069 buffer[offset++] = ((-value) & 255) ^ 255; 6070 value /= 256; 6071 } 6072 } 6073 6074 // https://github.com/retrofox/is-array 6075 function _isArray(val) { 6076 return !!val && "[object Array]" == Object.prototype.toString.call(val); 6077 } 6078 6079}(typeof exports === 'object' && typeof exports.nodeName !== 'string' ? exports : (this || {})); 6080 6081}).call(this,require("buffer").Buffer) 6082},{"buffer":7}],16:[function(require,module,exports){ 6083var toString = {}.toString; 6084 6085module.exports = Array.isArray || function (arr) { 6086 return toString.call(arr) == '[object Array]'; 6087}; 6088 6089},{}],17:[function(require,module,exports){ 6090/*jslint node: true, vars: true, nomen: true */ 6091'use strict'; 6092 6093var byEbmlID = { 6094 0x80: { 6095 name: "ChapterDisplay", 6096 level: 4, 6097 type: "m", 6098 multiple: true, 6099 minver: 1, 6100 webm: true,
6101 description: "Contains all possible strings to use for the chapter display." 6102 }, 6103 0x83: { 6104 name: "TrackType", 6105 level: 3, 6106 type: "u", 6107 mandatory: true, 6108 minver: 1, 6109 range: "1-254", 6110 description: "A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control)." 6111 }, 6112 0x85: { 6113 name: "ChapString", 6114 cppname: "ChapterString", 6115 level: 5, 6116 type: "8", 6117 mandatory: true, 6118 minver: 1, 6119 webm: true, 6120 description: "Contains the string to use as the chapter atom." 6121 }, 6122 0x86: { 6123 name: "CodecID", 6124 level: 3, 6125 type: "s", 6126 mandatory: true, 6127 minver: 1, 6128 description: "An ID corresponding to the codec, see the codec page for more info." 6129 }, 6130 0x88: { 6131 name: "FlagDefault", 6132 cppname: "TrackFlagDefault", 6133 level: 3, 6134 type: "u", 6135 mandatory: true, 6136 minver: 1, 6137 "default": 1, 6138 range: "0-1", 6139 description: "Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)" 6140 }, 6141 0x89: { 6142 name: "ChapterTrackNumber", 6143 level: 5, 6144 type: "u", 6145 mandatory: true, 6146 multiple: true, 6147 minver: 1, 6148 webm: false, 6149 range: "not 0", 6150 description: "UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks." 6151 }, 6152 0x91: { 6153 name: "ChapterTimeStart", 6154 level: 4, 6155 type: "u", 6156 mandatory: true, 6157 minver: 1, 6158 webm: true, 6159 description: "Timestamp of the start of Chapter (not scaled)." 6160 }, 6161 0x92: { 6162 name: "ChapterTimeEnd", 6163 level: 4, 6164 type: "u", 6165 minver: 1, 6166 webm: false, 6167 description: "Timestamp of the end of Chapter (timestamp excluded, not scaled)." 6168 }, 6169 0x96: { 6170 name: "CueRefTime", 6171 level: 5, 6172 type: "u", 6173 mandatory: true, 6174 minver: 2, 6175 webm: false, 6176 description: "Timestamp of the referenced Block." 6177 }, 6178 0x97: { 6179 name: "CueRefCluster", 6180 level: 5, 6181 type: "u", 6182 mandatory: true, 6183 webm: false, 6184 description: "The Position of the Cluster containing the referenced Block." 6185 }, 6186 0x98: { 6187 name: "ChapterFlagHidden", 6188 level: 4, 6189 type: "u", 6190 mandatory: true, 6191 minver: 1, 6192 webm: false, 6193 "default": 0, 6194 range: "0-1", 6195 description: "If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)" 6196 }, 6197 0x4254: { 6198 name: "ContentCompAlgo", 6199 level: 6, 6200 type: "u", 6201 mandatory: true, 6202 minver: 1, 6203 webm: false, 6204 "default": 0, 6205 // "br": [ "", "", "", "" ], 6206 // "del": [ "1 - bzlib,", "2 - lzo1x" ], 6207 description: "The compression algorithm used. Algorithms that have been specified so far are: 0 - zlib, 3 - Header Stripping" 6208 }, 6209 0x4255: { 6210 name: "ContentCompSettings", 6211 level: 6, 6212 type: "b", 6213 minver: 1, 6214 webm: false, 6215 description: "Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track." 6216 }, 6217 0x4282: { 6218 name: "DocType", 6219 level: 1, 6220 type: "s", 6221 mandatory: true, 6222 "default": "matroska", 6223 minver: 1, 6224 description: "A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files." 6225 }, 6226 0x4285: { 6227 name: "DocTypeReadVersion", 6228 level: 1, 6229 type: "u", 6230 mandatory: true, 6231 "default": 1, 6232 minver: 1, 6233 description: "The minimum DocType version an interpreter has to support to read this file." 6234 }, 6235 0x4286: { 6236 name: "EBMLVersion", 6237 level: 1, 6238 type: "u", 6239 mandatory: true, 6240 "default": 1, 6241 minver: 1, 6242 description: "The version of EBML parser used to create the file." 6243 }, 6244 0x4287: { 6245 name: "DocTypeVersion", 6246 level: 1, 6247 type: "u", 6248 mandatory: true, 6249 "default": 1, 6250 minver: 1, 6251 description: "The version of DocType interpreter used to create the file." 6252 }, 6253 0x4444: { 6254 name: "SegmentFamily", 6255 level: 2, 6256 type: "b", 6257 multiple: true, 6258 minver: 1, 6259 webm: false, 6260 bytesize: 16, 6261 description: "A randomly generated unique ID that all segments related to each other must use (128 bits)." 6262 }, 6263 0x4461: { 6264 name: "DateUTC", 6265 level: 2, 6266 type: "d", 6267 minver: 1,
6268 description: "Date of the origin of timestamp (value 0), i.e. production date." 6269 }, 6270 0x4484: { 6271 name: "TagDefault", 6272 level: 4, 6273 type: "u", 6274 mandatory: true, 6275 minver: 1, 6276 webm: false, 6277 "default": 1, 6278 range: "0-1", 6279 description: "Indication to know if this is the default/original language to use for the given tag. (1 bit)" 6280 }, 6281 0x4485: { 6282 name: "TagBinary", 6283 level: 4, 6284 type: "b", 6285 minver: 1, 6286 webm: false, 6287 description: "The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString." 6288 }, 6289 0x4487: { 6290 name: "TagString", 6291 level: 4, 6292 type: "8", 6293 minver: 1, 6294 webm: false, 6295 description: "The value of the Element." 6296 }, 6297 0x4489: { 6298 name: "Duration", 6299 level: 2, 6300 type: "f", 6301 minver: 1, 6302 range: "> 0", 6303 description: "Duration of the segment (based on TimecodeScale)." 6304 }, 6305 0x4598: { 6306 name: "ChapterFlagEnabled", 6307 level: 4, 6308 type: "u", 6309 mandatory: true, 6310 minver: 1, 6311 webm: false, 6312 "default": 1, 6313 range: "0-1", 6314 description: "Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter (see flag notes). (1 bit)" 6315 }, 6316 0x4660: { 6317 name: "FileMimeType", 6318 level: 3, 6319 type: "s", 6320 mandatory: true, 6321 minver: 1, 6322 webm: false, 6323 description: "MIME type of the file." 6324 }, 6325 0x4661: { 6326 name: "FileUsedStartTime", 6327 level: 3, 6328 type: "u", 6329 divx: true, 6330 description: "DivX font extension" 6331 }, 6332 0x4662: { 6333 name: "FileUsedEndTime", 6334 level: 3, 6335 type: "u", 6336 divx: true, 6337 description: "DivX font extension" 6338 }, 6339 0x4675: { 6340 name: "FileReferral", 6341 level: 3, 6342 type: "b", 6343 webm: false, 6344 description: "A binary value that a track/codec can refer to when the attachment is needed." 6345 }, 6346 0x5031: { 6347 name: "ContentEncodingOrder", 6348 level: 5, 6349 type: "u", 6350 mandatory: true, 6351 minver: 1, 6352 webm: false, 6353 "default": 0, 6354 description: "Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment." 6355 }, 6356 0x5032: { 6357 name: "ContentEncodingScope", 6358 level: 5, 6359 type: "u", 6360 mandatory: true, 6361 minver: 1, 6362 webm: false, 6363 "default": 1, 6364 range: "not 0", 6365 // "br": [ "", "", "" ], 6366 description: "A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values: 1 - all frame contents, 2 - the track's private data, 4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)" 6367 }, 6368 0x5033: { 6369 name: "ContentEncodingType", 6370 level: 5, 6371 type: "u", 6372 mandatory: true, 6373 minver: 1, 6374 webm: false, 6375 "default": 0, 6376 // "br": [ "", "" ], 6377 description: "A value describing what kind of transformation has been done. Possible values: 0 - compression, 1 - encryption" 6378 }, 6379 0x5034: { 6380 name: "ContentCompression", 6381 level: 5, 6382 type: "m", 6383 minver: 1, 6384 webm: false, 6385 description: "Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking." 6386 }, 6387 0x5035: { 6388 name: "ContentEncryption", 6389 level: 5, 6390 type: "m", 6391 minver: 1, 6392 webm: false, 6393 description: "Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise." 6394 }, 6395 0x5378: { 6396 name: "CueBlockNumber", 6397 level: 4, 6398 type: "u", 6399 minver: 1, 6400 "default": 1, 6401 range: "not 0", 6402 description: "Number of the Block in the specified Cluster." 6403 }, 6404 0x5654: { 6405 name: "ChapterStringUID", 6406 level: 4, 6407 type: "8", 6408 mandatory: false, 6409 minver: 3, 6410 webm: true, 6411 description: "A unique string ID to identify the Chapter. Use for WebVTT cue identifier storage." 6412 }, 6413 0x5741: { 6414 name: "WritingApp", 6415 level: 2, 6416 type: "8", 6417 mandatory: true, 6418 minver: 1, 6419 description: "Writing application (\"mkvmerge-0.3.3\")." 6420 }, 6421 0x5854: { 6422 name: "SilentTracks", 6423 cppname: "ClusterSilentTracks", 6424 level: 2, 6425 type: "m", 6426 minver: 1, 6427 webm: false, 6428 description: "The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use." 6429 }, 6430 0x6240: { 6431 name: "ContentEncoding", 6432 level: 4, 6433 type: "m", 6434 mandatory: true, 6435 multiple: true, 6436 minver: 1, 6437 webm: false, 6438 description: "Settings for one content encoding like compression or encryption." 6439 }, 6440 0x6264: { 6441 name: "BitDepth",
6442 cppname: "AudioBitDepth", 6443 level: 4, 6444 type: "u", 6445 minver: 1, 6446 range: "not 0", 6447 description: "Bits per sample, mostly used for PCM." 6448 }, 6449 0x6532: { 6450 name: "SignedElement", 6451 level: 3, 6452 type: "b", 6453 multiple: true, 6454 webm: false, 6455 description: "An element ID whose data will be used to compute the signature." 6456 }, 6457 0x6624: { 6458 name: "TrackTranslate", 6459 level: 3, 6460 type: "m", 6461 multiple: true, 6462 minver: 1, 6463 webm: false, 6464 description: "The track identification for the given Chapter Codec." 6465 }, 6466 0x6911: { 6467 name: "ChapProcessCommand", 6468 cppname: "ChapterProcessCommand", 6469 level: 5, 6470 type: "m", 6471 multiple: true, 6472 minver: 1, 6473 webm: false, 6474 description: "Contains all the commands associated to the Atom." 6475 }, 6476 0x6922: { 6477 name: "ChapProcessTime", 6478 cppname: "ChapterProcessTime", 6479 level: 6, 6480 type: "u", 6481 mandatory: true, 6482 minver: 1, 6483 webm: false, 6484 description: "Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter)." 6485 }, 6486 0x6924: { 6487 name: "ChapterTranslate", 6488 level: 2, 6489 type: "m", 6490 multiple: true, 6491 minver: 1, 6492 webm: false, 6493 description: "A tuple of corresponding ID used by chapter codecs to represent this segment." 6494 }, 6495 0x6933: { 6496 name: "ChapProcessData", 6497 cppname: "ChapterProcessData", 6498 level: 6, 6499 type: "b", 6500 mandatory: true, 6501 minver: 1, 6502 webm: false, 6503 description: "Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands." 6504 }, 6505 0x6944: { 6506 name: "ChapProcess", 6507 cppname: "ChapterProcess", 6508 level: 4, 6509 type: "m", 6510 multiple: true, 6511 minver: 1, 6512 webm: false, 6513 description: "Contains all the commands associated to the Atom." 6514 }, 6515 0x6955: { 6516 name: "ChapProcessCodecID", 6517 cppname: "ChapterProcessCodecID", 6518 level: 5, 6519 type: "u", 6520 mandatory: true, 6521 minver: 1, 6522 webm: false, 6523 "default": 0, 6524 description: "Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later." 6525 }, 6526 0x7373: { 6527 name: "Tag", 6528 level: 2, 6529 type: "m", 6530 mandatory: true, 6531 multiple: true, 6532 minver: 1, 6533 webm: false, 6534 description: "Element containing elements specific to Tracks/Chapters." 6535 }, 6536 0x7384: { 6537 name: "SegmentFilename", 6538 level: 2, 6539 type: "8", 6540 minver: 1, 6541 webm: false, 6542 description: "A filename corresponding to this segment." 6543 }, 6544 0x7446: { 6545 name: "AttachmentLink", 6546 cppname: "TrackAttachmentLink", 6547 level: 3, 6548 type: "u", 6549 minver: 1, 6550 webm: false, 6551 range: "not 0", 6552 description: "The UID of an attachment that is used by this codec." 6553 }, 6554 0x258688: { 6555 name: "CodecName", 6556 level: 3, 6557 type: "8", 6558 minver: 1, 6559 description: "A human-readable string specifying the codec." 6560 }, 6561 0x18538067: { 6562 name: "Segment", 6563 level: "0", 6564 type: "m", 6565 mandatory: true, 6566 multiple: true, 6567 minver: 1, 6568 description: "This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment." 6569 }, 6570 0x447a: { 6571 name: "TagLanguage", 6572 level: 4, 6573 type: "s", 6574 mandatory: true, 6575 minver: 1, 6576 webm: false, 6577 "default": "und", 6578 description: "Specifies the language of the tag specified, in the Matroska languages form." 6579 }, 6580 0x45a3: { 6581 name: "TagName", 6582 level: 4, 6583 type: "8", 6584 mandatory: true, 6585 minver: 1, 6586 webm: false, 6587 description: "The name of the Tag that is going to be stored." 6588 }, 6589 0x67c8: { 6590 name: "SimpleTag", 6591 cppname: "TagSimple", 6592 level: 3, 6593 "recursive": "1", 6594 type: "m", 6595 mandatory: true, 6596 multiple: true, 6597 minver: 1, 6598 webm: false, 6599 description: "Contains general information about the target." 6600 }, 6601 0x63c6: { 6602 name: "TagAttachmentUID", 6603 level: 4, 6604 type: "u", 6605 multiple: true, 6606 minver: 1, 6607 webm: false, 6608 "default": 0, 6609 description: "A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment." 6610 }, 6611 0x63c4: { 6612 name: "TagChapterUID", 6613 level: 4, 6614 type: "u", 6615 multiple: true, 6616 minver: 1, 6617 webm: false, 6618 "default": 0, 6619 description: "A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment." 6620 }, 6621 0x63c9: { 6622 name: "TagEditionUID", 6623 level: 4, 6624 type: "u", 6625 multiple: true, 6626 minver: 1, 6627 webm: false, 6628 "default": 0, 6629 description: "A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment." 6630 }, 6631 0x63c5: { 6632 name: "TagTrackUID", 6633 level: 4, 6634 type: "u", 6635 multiple: true, 6636 minver: 1, 6637 webm: false, 6638 "default": 0, 6639 description: "A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment." 6640 }, 6641 0x63ca: { 6642 name: "TargetType", 6643 cppname: "TagTargetType", 6644 level: 4, 6645 type: "s", 6646 minver: 1, 6647 webm: false, 6648 "strong": "informational", 6649 description: "An string that can be used to display the logical level of the target like \"ALBUM\", \"TRACK\", \"MOVIE\", \"CHAPTER\", etc (see TargetType)." 6650 }, 6651 0x68ca: { 6652 name: "TargetTypeValue", 6653 cppname: "TagTargetTypeValue", 6654 level: 4, 6655 type: "u", 6656 minver: 1, 6657 webm: false, 6658 "default": 50, 6659 description: "A number to indicate the logical level of the target (see TargetType)." 6660 }, 6661 0x63c0: { 6662 name: "Targets", 6663 cppname: "TagTargets", 6664 level: 3, 6665 type: "m", 6666 mandatory: true, 6667 minver: 1, 6668 webm: false, 6669 description: "Contain all UIDs where the specified meta data a
6669pply. It is empty to describe everything in the segment." 6670 }, 6671 0x1254c367: { 6672 name: "Tags", 6673 level: 1, 6674 type: "m", 6675 multiple: true, 6676 minver: 1, 6677 webm: false, 6678 description: "Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here." 6679 }, 6680 0x450d: { 6681 name: "ChapProcessPrivate", 6682 cppname: "ChapterProcessPrivate", 6683 level: 5, 6684 type: "b", 6685 minver: 1, 6686 webm: false, 6687 description: "Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the \"DVD level\" equivalent." 6688 }, 6689 0x437e: { 6690 name: "ChapCountry", 6691 cppname: "ChapterCountry", 6692 level: 5, 6693 type: "s", 6694 multiple: true, 6695 minver: 1, 6696 webm: false, 6697 description: "The countries corresponding to the string, same 2 octets as in Internet domains." 6698 }, 6699 0x437c: { 6700 name: "ChapLanguage", 6701 cppname: "ChapterLanguage", 6702 level: 5, 6703 type: "s", 6704 mandatory: true, 6705 multiple: true, 6706 minver: 1, 6707 webm: true, 6708 "default": "eng", 6709 description: "The languages corresponding to the string, in the bibliographic ISO-639-2 form." 6710 }, 6711 0x8f: { 6712 name: "ChapterTrack", 6713 level: 4, 6714 type: "m", 6715 minver: 1, 6716 webm: false, 6717 description: "List of tracks on which the chapter applies. If this element is not present, all tracks apply" 6718 }, 6719 0x63c3: { 6720 name: "ChapterPhysicalEquiv", 6721 level: 4, 6722 type: "u", 6723 minver: 1, 6724 webm: false, 6725 description: "Specify the physical equivalent of this ChapterAtom like \"DVD\" (60) or \"SIDE\" (50), see complete list of values." 6726 }, 6727 0x6ebc: { 6728 name: "ChapterSegmentEditionUID", 6729 level: 4, 6730 type: "u", 6731 minver: 1, 6732 webm: false, 6733 range: "not 0", 6734 description: "The EditionUID to play from the segment linked in ChapterSegmentUID." 6735 }, 6736 0x6e67: { 6737 name: "ChapterSegmentUID", 6738 level: 4, 6739 type: "b", 6740 minver: 1, 6741 webm: false, 6742 range: ">0", 6743 bytesize: 16, 6744 description: "A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used." 6745 }, 6746 0x73c4: { 6747 name: "ChapterUID", 6748 level: 4, 6749 type: "u", 6750 mandatory: true, 6751 minver: 1, 6752 webm: true, 6753 range: "not 0", 6754 description: "A unique ID to identify the Chapter." 6755 }, 6756 0xb6: { 6757 name: "ChapterAtom", 6758 level: 3, 6759 "recursive": "1", 6760 type: "m", 6761 mandatory: true, 6762 multiple: true, 6763 minver: 1, 6764 webm: true, 6765 description: "Contains the atom information to use as the chapter atom (apply to all tracks)." 6766 }, 6767 0x45dd: { 6768 name: "EditionFlagOrdered", 6769 level: 3, 6770 type: "u", 6771 minver: 1, 6772 webm: false, 6773 "default": 0, 6774 range: "0-1", 6775 description: "Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)" 6776 }, 6777 0x45db: { 6778 name: "EditionFlagDefault", 6779 level: 3, 6780 type: "u", 6781 mandatory: true, 6782 minver: 1, 6783 webm: false, 6784 "default": 0, 6785 range: "0-1", 6786 description: "If a flag is set (1) the edition should be used as the default one. (1 bit)" 6787 }, 6788 0x45bd: { 6789 name: "EditionFlagHidden", 6790 level: 3, 6791 type: "u", 6792 mandatory: true, 6793 minver: 1, 6794 webm: false, 6795 "default": 0, 6796 range: "0-1", 6797 description: "If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)" 6798 }, 6799 0x45bc: { 6800 name: "EditionUID", 6801 level: 3, 6802 type: "u", 6803 minver: 1, 6804 webm: false, 6805 range: "not 0", 6806 description: "A unique ID to identify the edition. It's useful for tagging an edition." 6807 }, 6808 0x45b9: { 6809 name: "EditionEntry", 6810 level: 2, 6811 type: "m", 6812 mandatory: true, 6813 multiple: true, 6814 minver: 1, 6815 webm: true, 6816 description: "Contains all information about a segment edition." 6817 }, 6818 0x1043a770: { 6819 name: "Chapters", 6820 level: 1, 6821 type: "m", 6822 minver: 1, 6823 webm: true, 6824 description: "A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation." 6825 }, 6826 0x46ae: { 6827 name: "FileUID", 6828 level: 3, 6829 type: "u", 6830 mandatory: true, 6831 minver: 1, 6832 webm: false, 6833 range: "not 0", 6834 description: "Unique ID representing the file, as random as possible." 6835 }, 6836 0x465c: { 6837 name: "FileData", 6838 level: 3, 6839 type: "b", 6840 mandatory: true, 6841 minver: 1, 6842 webm: false, 6843 description: "The data of the file." 6844 }, 6845 0x466e: { 6846 name: "FileName", 6847 level: 3, 6848 type: "8", 6849 mandatory: true, 6850 minver: 1, 6851 webm: false, 6852 description: "Filename of the attached file." 6853 }, 6854 0x467e: { 6855 name: "FileDescription", 6856 level: 3, 6857 type: "8", 6858 minver: 1, 6859 webm: false, 6860 description: "A human-friendly name for the attached file." 6861 }, 6862 0x61a7: { 6863 name: "AttachedFile", 6864 level: 2, 6865 type: "m", 6866 mandatory: true, 6867 multiple: true, 6868 minver: 1, 6869 webm: false, 6870 description: "An attached file." 6871 }, 6872 0x1941a469: { 6873 name: "Attachments", 6874 level: 1, 6875 type: "m", 6876 minver: 1, 6877 webm: false, 6878 description: "Contain attached files." 6879 }, 6880 0xeb: { 6881 name: "CueRefCodecState", 6882 level: 5, 6883 type: "u", 6884 webm: false, 6885 "default": 0, 6886 description: "The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry." 6887 }, 6888 0x535f: { 6889 name: "CueRefNumber", 6890 level: 5, 6891 type: "u", 6892 webm: false, 6893 "default": 1, 6894 range: "not 0", 6895 description: "Number of the referenced Block of Track X in the specified Cluster." 6896 }, 6897 0xdb: { 6898 name: "CueReference", 6899 level: 4, 6900 type: "m", 6901 multiple: true, 6902 minver: 2, 6903 webm: false,
6904 description: "The Clusters containing the required referenced Blocks." 6905 }, 6906 0xea: { 6907 name: "CueCodecState", 6908 level: 4, 6909 type: "u", 6910 minver: 2, 6911 webm: false, 6912 "default": 0, 6913 description: "The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry." 6914 }, 6915 0xb2: { 6916 name: "CueDuration", 6917 level: 4, 6918 type: "u", 6919 mandatory: false, 6920 minver: 4, 6921 webm: false, 6922 description: "The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues." 6923 }, 6924 0xf0: { 6925 name: "CueRelativePosition", 6926 level: 4, 6927 type: "u", 6928 mandatory: false, 6929 minver: 4, 6930 webm: false, 6931 description: "The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.", 6932 position: "clusterRelative" 6933 }, 6934 0xf1: { 6935 name: "CueClusterPosition", 6936 level: 4, 6937 type: "u", 6938 mandatory: true, 6939 minver: 1, 6940 description: "The position of the Cluster containing the required Block.", 6941 position: "segment", 6942 }, 6943 0xf7: { 6944 name: "CueTrack", 6945 level: 4, 6946 type: "u", 6947 mandatory: true, 6948 minver: 1, 6949 range: "not 0", 6950 description: "The track for which a position is given." 6951 }, 6952 0xb7: { 6953 name: "CueTrackPositions", 6954 level: 3, 6955 type: "m", 6956 mandatory: true, 6957 multiple: true, 6958 minver: 1, 6959 description: "Contain positions for different tracks corresponding to the timestamp." 6960 }, 6961 0xb3: { 6962 name: "CueTime", 6963 level: 3, 6964 type: "u", 6965 mandatory: true, 6966 minver: 1, 6967 description: "Absolute timestamp according to the segment time base." 6968 }, 6969 0xbb: { 6970 name: "CuePoint", 6971 level: 2, 6972 type: "m", 6973 mandatory: true, 6974 multiple: true, 6975 minver: 1, 6976 description: "Contains all information relative to a seek point in the segment." 6977 }, 6978 0x1c53bb6b: { 6979 name: "Cues", 6980 level: 1, 6981 type: "m", 6982 minver: 1, 6983 description: "A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non \"live\" streams." 6984 }, 6985 0x47e6: { 6986 name: "ContentSigHashAlgo", 6987 level: 6, 6988 type: "u", 6989 minver: 1, 6990 webm: false, 6991 "default": 0, 6992 // "br": [ "", "" ], 6993 description: "The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - SHA1-160 2 - MD5" 6994 }, 6995 0x47e5: { 6996 name: "ContentSigAlgo", 6997 level: 6, 6998 type: "u", 6999 minver: 1, 7000 webm: false, 7001 "default": 0, 7002 // "br": "", 7003 description: "The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - RSA" 7004 }, 7005 0x47e4: { 7006 name: "ContentSigKeyID", 7007 level: 6, 7008 type: "b", 7009 minver: 1, 7010 webm: false, 7011 description: "This is the ID of the private key the data was signed with." 7012 }, 7013 0x47e3: { 7014 name: "ContentSignature", 7015 level: 6, 7016 type: "b", 7017 minver: 1, 7018 webm: false, 7019 description: "A cryptographic signature of the contents." 7020 }, 7021 0x47e2: { 7022 name: "ContentEncKeyID", 7023 level: 6, 7024 type: "b", 7025 minver: 1, 7026 webm: false, 7027 description: "For public key algorithms this is the ID of the public key the the data was encrypted with." 7028 }, 7029 0x47e1: { 7030 name: "ContentEncAlgo", 7031 level: 6, 7032 type: "u", 7033 minver: 1, 7034 webm: false, 7035 "default": 0, 7036 // "br": "", 7037 description: "The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: 1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES" 7038 }, 7039 0x6d80: { 7040 name: "ContentEncodings", 7041 level: 3, 7042 type: "m", 7043 minver: 1, 7044 webm: false, 7045 description: "Settings for several content encoding mechanisms like compression or encryption." 7046 }, 7047 0xc4: { 7048 name: "TrickMasterTrackSegmentUID", 7049 level: 3, 7050 type: "b", 7051 divx: true, 7052 bytesize: 16, 7053 description: "DivX trick track extenstions" 7054 }, 7055 0xc7: { 7056 name: "TrickMasterTrackUID", 7057 level: 3, 7058 type: "u", 7059 divx: true, 7060 description: "DivX trick track extenstions" 7061 }, 7062 0xc6: { 7063 name: "TrickTrackFlag", 7064 level: 3, 7065 type: "u", 7066 divx: true, 7067 "default": 0, 7068 description: "DivX trick track extenstions" 7069 }, 7070 0xc1: { 7071 name: "TrickTrackSegmentUID", 7072 level: 3, 7073 type: "b", 7074 divx: true, 7075 bytesize: 16, 7076 description: "DivX trick track extenstions" 7077 }, 7078 0xc0: { 7079 name: "TrickTrackUID", 7080 level: 3, 7081 type: "u", 7082 divx: true, 7083 description: "DivX trick track extenstions" 7084 }, 7085 0xed: { 7086 name: "TrackJoinUID", 7087 level: 5, 7088 type: "u", 7089 mandatory: true, 7090 multiple: true, 7091 minver: 3, 7092 webm: false, 7093 range: "not 0", 7094 description: "The trackUID number of a track whose blocks are used to create this virtual track." 7095 }, 7096 0xe9: { 7097 name: "TrackJoinBlocks", 7098 level: 4, 7099 type: "m", 7100 minver: 3, 7101 webm: false, 7102 description: "Contains the list of all tracks whose Blocks need to be combined to create this virtual track" 7103 }, 7104 0xe6: { 7105 name: "TrackPlaneType", 7106 level: 6, 7107 type: "u", 7108 mandatory: true, 7109 minver: 3, 7110 webm: false, 7111 description: "The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background)." 7112 }, 7113 0xe5: { 7114 name: "TrackPlaneUID", 7115 level: 6, 7116 type: "u", 7117 mandatory: true, 7118 minver: 3, 7119 webm: false, 7120 range: "not 0", 7121 description: "The trackUID number of the track representing the plane." 7122 }, 7123 0xe4: { 7124 name: "TrackPlane", 7125 level: 5, 7126 type: "m", 7127 mandatory: true, 7128 multiple: true, 7129 minver: 3, 7130 webm: false, 7131 description: "Contains a video plane track that need to be combined to create this 3D track" 7132 }, 7133 0xe3: { 7134 name: "TrackCombinePlanes", 7135 level: 4, 7136 type: "m", 7137 minver: 3, 7138 webm: false, 7139 description: "Contains the list of all video plane tracks that need to be combined to create this 3D track" 7140 }, 7141 0xe2: { 7142 name: "TrackOperation", 7143 level: 3, 7144 type: "m", 7145 minver: 3, 7146 webm: false, 7147 description: "Operation that needs to be applied on tracks to create this virtual track. For more details look at the Specification Notes on the subject." 7148 }, 7149 0x7d7b: { 7150 name: "ChannelPositions", 7151 cppname: "AudioPosition", 7152 level: 4, 7153 type: "b", 7154 webm: false, 7155 description: "Table of horizontal angles for each successive channel, see appendix." 7156 }, 7157 0x9f: { 7158 name: "Channels", 7159 cppname: "AudioChannels", 7160 level: 4, 7161 type: "u", 7162 mandatory: true, 7163 minver: 1, 7164 "default": 1, 7165 range: "not 0", 7166 description: "Numbers of channels in the track." 7167 }, 7168 0x78b5: { 7169 name: "OutputSamplingFrequency", 7170 cppname: "AudioOutputSamplingFreq", 7171 level: 4, 7172 type: "f", 7173 minver: 1, 7174 "default": "Sampling Frequency", 7175 range: "> 0", 7176 description: "Real output sampling frequency in Hz (used for SBR techniques)." 7177 }, 7178 0xb5: { 7179 name: "SamplingFrequency", 7180 cppname: "AudioSamplingFreq", 7181 level: 4, 7182 type: "f", 7183 mandatory: true, 7184 minver: 1, 7185 "default": 8000.0, 7186 range: "> 0", 7187 description: "Sampling frequency in Hz." 7188 }, 7189 0xe1: { 7190 name: "Audio", 7191 cppname: "TrackAudio", 7192 level: 3, 7193 type: "m", 7194 minver: 1, 7195 description: "Audio settings." 7196 }, 7197 0x2383e3: { 7198 name: "FrameRate", 7199 cppname: "VideoFrameRate", 7200 level: 4, 7201 type: "f", 7202 range: "> 0", 7203 "strong": "Informational", 7204 description: "Number of frames per second. only." 7205 }, 7206 0x2fb523: { 7207 name: "GammaValue", 7208 cppname: "VideoGamma", 7209 level: 4, 7210 type: "f", 7211 webm: false, 7212 range: "> 0", 7213 description: "Gamma Value." 7214 }, 7215 0x2eb524: { 7216 name: "ColourSpace", 7217 cppname: "VideoColourSpace", 7218 level: 4, 7219 type: "b", 7220 minver: 1, 7221 webm: false, 7222 bytesize: 4, 7223 description: "Same value as in AVI (32 bits)." 7224 }, 7225 0x54b3: { 7226 name: "AspectRatioType", 7227 cppname: "VideoAspectRatio", 7228 level: 4, 7229 type: "u", 7230 minver: 1, 7231 "default": 0, 7232 description: "Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed)." 7233 }, 7234 0x54b2: { 7235 name: "DisplayUnit", 7236 cppname: "VideoDisplayUnit", 7237 level: 4, 7238 type: "u", 7239 minver: 1, 7240 "default": 0, 7241 description: "How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio)." 7242 }, 7243 0x54ba: { 7244 name: "DisplayHeight", 7245 cppname: "VideoDisplayHeight", 7246 level: 4, 7247 type: "u", 7248 minver: 1, 7249 "default": "PixelHeight", 7250 range: "not 0", 7251 description: "Height of the video frames to display. The default value is only valid when DisplayUnit is 0." 7252 }, 7253 0x54b0: { 7254 name: "DisplayWidth", 7255 cppname: "VideoDisplayWidth", 7256 level: 4, 7257 type: "u", 7258 minver: 1, 7259 "default": "PixelWidth", 7260 range: "not 0", 7261 description: "Width of the video frames to display. The default value is only valid when DisplayUnit is 0." 7262 }, 7263 0x54dd: { 7264 name: "PixelCropRight", 7265 cppname: "VideoPixelCropRight", 7266 level: 4, 7267 type: "u", 7268 minver: 1, 7269 "default": 0, 7270 description: "The number of video pixels to remove on the right of the image." 7271 }, 7272 0x54cc: { 7273 name: "PixelCropLeft", 7274 cppname: "VideoPixelCropLeft", 7275 level: 4, 7276 type: "u", 7277 minver: 1, 7278 "default": 0, 7279 description: "The number of video pixels to remove on the left of the image." 7280 }, 7281 0x54bb: { 7282 name: "PixelCropTop", 7283 cppname: "VideoPixelCropTop", 7284 level: 4, 7285 type: "u", 7286 minver: 1, 7287 "default": 0, 7288 description: "The number of video pixels to remove at the top of the image." 7289 }, 7290 0x54aa: { 7291 name: "PixelCropBottom", 7292 cppname: "VideoPixelCropBottom", 7293 level: 4, 7294 type: "u", 7295 minver: 1, 7296 "default": 0, 7297 description: "The number of video pixels to remove at the bottom of the image (for HDTV content)." 7298 }, 7299 0xba: { 7300 name: "PixelHeight", 7301 cppname: "VideoPixelHeight", 7302 level: 4, 7303 type: "u", 7304 mandatory: true, 7305 minver: 1, 7306 range: "not 0", 7307 description: "Height of the encoded video frames in pixels." 7308 }, 7309 0xb0: { 7310 name: "PixelWidth", 7311 cppname: "VideoPixelWidth", 7312 level: 4, 7313 type: "u", 7314 mandatory: true, 7315 minver: 1, 7316 range: "not 0", 7317 description: "Width of the encoded video frames in pixels." 7318 }, 7319 0x53b9: { 7320 name: "OldStereoMode", 7321 level: 4, 7322 type: "u", 7323 "maxver": "0", 7324 webm: false, 7325 divx: false, 7326 description: "DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes)." 7327 }, 7328 0x53c0: { 7329 name: "AlphaMode", 7330 cppname: "VideoAlphaMode", 7331 level: 4, 7332 type: "u", 7333 minver: 3, 7334 webm: true, 7335 "default": 0, 7336 description: "Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data." 7337 }, 7338 0x53b8: { 7339 name: "StereoMode", 7340 cppname: "VideoStereoMode", 7341 level: 4, 7342 type: "u", 7343 minver: 3, 7344 webm: true, 7345 "default": 0, 7346 description: "Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on 3D support in the Specification Notes." 7347 }, 7348 0x9a: { 7349 name: "FlagInterlaced",
7350 cppname: "VideoFlagInterlaced", 7351 level: 4, 7352 type: "u", 7353 mandatory: true, 7354 minver: 2, 7355 webm: true, 7356 "default": 0, 7357 range: "0-1", 7358 description: "Set if the video is interlaced. (1 bit)" 7359 }, 7360 0xe0: { 7361 name: "Video", 7362 cppname: "TrackVideo", 7363 level: 3, 7364 type: "m", 7365 minver: 1, 7366 description: "Video settings." 7367 }, 7368 0x66a5: { 7369 name: "TrackTranslateTrackID", 7370 level: 4, 7371 type: "b", 7372 mandatory: true, 7373 minver: 1, 7374 webm: false, 7375 description: "The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used." 7376 }, 7377 0x66bf: { 7378 name: "TrackTranslateCodec", 7379 level: 4, 7380 type: "u", 7381 mandatory: true, 7382 minver: 1, 7383 webm: false, 7384 description: "The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)." 7385 }, 7386 0x66fc: { 7387 name: "TrackTranslateEditionUID", 7388 level: 4, 7389 type: "u", 7390 multiple: true, 7391 minver: 1, 7392 webm: false, 7393 description: "Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment." 7394 }, 7395 0x56bb: { 7396 name: "SeekPreRoll", 7397 level: 3, 7398 type: "u", 7399 mandatory: true, 7400 multiple: false, 7401 "default": 0, 7402 minver: 4, 7403 webm: true, 7404 description: "After a discontinuity, SeekPreRoll is the duration in nanoseconds of the data the decoder must decode before the decoded data is valid." 7405 }, 7406 0x56aa: { 7407 name: "CodecDelay", 7408 level: 3, 7409 type: "u", 7410 multiple: false, 7411 "default": 0, 7412 minver: 4, 7413 webm: true, 7414 description: "CodecDelay is The codec-built-in delay in nanoseconds. This value must be subtracted from each block timestamp in order to get the actual timestamp. The value should be small so the muxing of tracks with the same actual timestamp are in the same Cluster." 7415 }, 7416 0x6fab: { 7417 name: "TrackOverlay", 7418 level: 3, 7419 type: "u", 7420 multiple: true, 7421 minver: 1, 7422 webm: false, 7423 description: "Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc." 7424 }, 7425 0xaa: { 7426 name: "CodecDecodeAll", 7427 level: 3, 7428 type: "u", 7429 mandatory: true, 7430 minver: 2, 7431 webm: false, 7432 "default": 1, 7433 range: "0-1", 7434 description: "The codec can decode potentially damaged data (1 bit)." 7435 }, 7436 0x26b240: { 7437 name: "CodecDownloadURL", 7438 level: 3, 7439 type: "s", 7440 multiple: true, 7441 webm: false, 7442 description: "A URL to download about the codec used." 7443 }, 7444 0x3b4040: { 7445 name: "CodecInfoURL", 7446 level: 3, 7447 type: "s", 7448 multiple: true, 7449 webm: false, 7450 description: "A URL to find information about the codec used." 7451 }, 7452 0x3a9697: { 7453 name: "CodecSettings", 7454 level: 3, 7455 type: "8", 7456 webm: false, 7457 description: "A string describing the encoding setting used." 7458 }, 7459 0x63a2: { 7460 name: "CodecPrivate", 7461 level: 3, 7462 type: "b", 7463 minver: 1, 7464 description: "Private data only known to the codec." 7465 }, 7466 0x22b59c: { 7467 name: "Language", 7468 cppname: "TrackLanguage", 7469 level: 3, 7470 type: "s", 7471 minver: 1, 7472 "default": "eng", 7473 description: "Specifies the language of the track in the Matroska languages form." 7474 }, 7475 0x536e: { 7476 name: "Name", 7477 cppname: "TrackName", 7478 level: 3, 7479 type: "8", 7480 minver: 1, 7481 description: "A human-readable track name." 7482 }, 7483 0x55ee: { 7484 name: "MaxBlockAdditionID", 7485 level: 3, 7486 type: "u", 7487 mandatory: true, 7488 minver: 1, 7489 webm: false, 7490 "default": 0, 7491 description: "The maximum value of BlockAdditions for this track." 7492 }, 7493 0x537f: { 7494 name: "TrackOffset", 7495 level: 3, 7496 type: "i", 7497 webm: false, 7498 "default": 0, 7499 description: "A value to add to the Block's Timestamp. This can be used to adjust the playback offset of a track." 7500 }, 7501 0x23314f: { 7502 name: "TrackTimecodeScale", 7503 level: 3, 7504 type: "f", 7505 mandatory: true, 7506 minver: 1, 7507 "maxver": "3", 7508 webm: false, 7509 "default": 1.0, 7510 range: "> 0", 7511 description: "DEPRECATED, DO NOT USE. The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs)." 7512 }, 7513 0x234e7a: { 7514 name: "DefaultDecodedFieldDuration", 7515 cppname: "TrackDefaultDecodedFieldDuration", 7516 level: 3, 7517 type: "u", 7518 minver: 4, 7519 range: "not 0", 7520 description: "The period in nanoseconds (not scaled by TimcodeScale)\nbetween two successive fields at the output of the decoding process (see the notes)" 7521 }, 7522 0x23e383: { 7523 name: "DefaultDuration", 7524 cppname: "TrackDefaultDuration", 7525 level: 3, 7526 type: "u", 7527 minver: 1, 7528 range: "not 0", 7529 description: "Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block)." 7530 }, 7531 0x6df8: { 7532 name: "MaxCache", 7533 cppname: "TrackMaxCache", 7534 level: 3, 7535 type: "u", 7536 minver: 1, 7537 webm: false, 7538 description: "The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed." 7539 }, 7540 0x6de7: { 7541 name: "MinCache", 7542 cppname: "TrackMinCache", 7543 level: 3, 7544 type: "u", 7545 mandatory: true, 7546 minver: 1, 7547 webm: false, 7548 "default": 0, 7549 description: "The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used." 7550 }, 7551 0x9c: { 7552 name: "FlagLacing", 7553 cppname: "TrackFlagLacing", 7554 level: 3, 7555 type: "u", 7556 mandatory: true, 7557 minver: 1, 7558 "default": 1, 7559 range: "0-1", 7560 description: "Set if the track may contain blocks using lacing. (1 bit)" 7561 }, 7562 0x55aa: { 7563 name: "FlagForced", 7564 cppname: "TrackFlagForced", 7565 level: 3, 7566 type: "u", 7567 mandatory: true, 7568 minver: 1, 7569 "default": 0, 7570 range: "0-1", 7571 description: "Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit)" 7572 }, 7573 0xb9: { 7574 name: "FlagEnabled", 7575 cppname: "TrackFlagEnabled", 7576 level: 3, 7577 type: "u", 7578 mandatory: true, 7579 minver: 2, 7580 webm: true, 7581 "default": 1, 7582 range: "0-1", 7583 description: "Set if the track is usable. (1 bit)" 7584 }, 7585 0x73c5: { 7586 name: "TrackUID", 7587 level: 3, 7588 type: "u", 7589 mandatory: true, 7590 minver: 1, 7591 range: "not 0", 7592 description: "A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file." 7593 }, 7594 0xd7: { 7595 name: "TrackNumber", 7596 level: 3, 7597 type: "u", 7598 mandatory: true, 7599 minver: 1, 7600 range: "not 0", 7601 description: "The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number)." 7602 }, 7603 0xae: { 7604 name: "TrackEntry", 7605 level: 2, 7606 type: "m", 7607 mandatory: true, 7608 multiple: true, 7609 minver: 1, 7610 description: "Describes a track with all elements." 7611 },
7612 0x1654ae6b: { 7613 name: "Tracks", 7614 level: 1, 7615 type: "m", 7616 multiple: true, 7617 minver: 1, 7618 description: "A top-level block of information with many tracks described." 7619 }, 7620 0xaf: { 7621 name: "EncryptedBlock", 7622 level: 2, 7623 type: "b", 7624 multiple: true, 7625 webm: false, 7626 description: "Similar to EncryptedBlock Structure)" 7627 }, 7628 0xca: { 7629 name: "ReferenceTimeCode", 7630 level: 4, 7631 type: "u", 7632 multiple: false, 7633 mandatory: true, 7634 minver: 0, 7635 webm: false, 7636 divx: true, 7637 description: "DivX trick track extenstions" 7638 }, 7639 0xc9: { 7640 name: "ReferenceOffset", 7641 level: 4, 7642 type: "u", 7643 multiple: false, 7644 mandatory: true, 7645 minver: 0, 7646 webm: false, 7647 divx: true, 7648 description: "DivX trick track extenstions" 7649 }, 7650 0xc8: { 7651 name: "ReferenceFrame", 7652 level: 3, 7653 type: "m", 7654 multiple: false, 7655 minver: 0, 7656 webm: false, 7657 divx: true, 7658 description: "DivX trick track extenstions" 7659 }, 7660 0xcf: { 7661 name: "SliceDuration", 7662 level: 5, 7663 type: "u", 7664 "default": 0, 7665 description: "The (scaled) duration to apply to the element." 7666 }, 7667 0xce: { 7668 name: "Delay", 7669 cppname: "SliceDelay", 7670 level: 5, 7671 type: "u", 7672 "default": 0, 7673 description: "The (scaled) delay to apply to the element." 7674 }, 7675 0xcb: { 7676 name: "BlockAdditionID", 7677 cppname: "SliceBlockAddID", 7678 level: 5, 7679 type: "u", 7680 "default": 0, 7681 description: "The ID of the BlockAdditional element (0 is the main Block)." 7682 }, 7683 0xcd: { 7684 name: "FrameNumber", 7685 cppname: "SliceFrameNumber", 7686 level: 5, 7687 type: "u", 7688 "default": 0, 7689 description: "The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame)." 7690 }, 7691 0xcc: { 7692 name: "LaceNumber", 7693 cppname: "SliceLaceNumber", 7694 level: 5, 7695 type: "u", 7696 minver: 1, 7697 "default": 0, 7698 divx: false, 7699 description: "The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback." 7700 }, 7701 0xe8: { 7702 name: "TimeSlice", 7703 level: 4, 7704 type: "m", 7705 multiple: true, 7706 minver: 1, 7707 divx: false, 7708 description: "Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback." 7709 }, 7710 0x8e: { 7711 name: "Slices", 7712 level: 3, 7713 type: "m", 7714 minver: 1, 7715 divx: false, 7716 description: "Contains slices description." 7717 }, 7718 0x75a2: { 7719 name: "DiscardPadding", 7720 level: 3, 7721 type: "i", 7722 minver: 4, 7723 webm: true, 7724 description: "Duration in nanoseconds of the silent data added to the Block (padding at the end of the Block for positive value, at the beginning of the Block for negative value). The duration of DiscardPadding is not calculated in the duration of the TrackEntry and should be discarded during playback." 7725 }, 7726 0xa4: { 7727 name: "CodecState", 7728 level: 3, 7729 type: "b", 7730 minver: 2, 7731 webm: false, 7732 description: "The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry." 7733 }, 7734 0xfd: { 7735 name: "ReferenceVirtual", 7736 level: 3, 7737 type: "i", 7738 webm: false, 7739 description: "Relative position of the data that should be in position of the virtual block." 7740 }, 7741 0xfb: { 7742 name: "ReferenceBlock", 7743 level: 3, 7744 type: "i", 7745 multiple: true, 7746 minver: 1, 7747 description: "Timestamp of another frame used as a reference (ie: B or P frame). The timestamp is relative to the block it's attached to." 7748 }, 7749 0xfa: { 7750 name: "ReferencePriority", 7751 cppname: "FlagReferenced", 7752 level: 3, 7753 type: "u", 7754 mandatory: true, 7755 minver: 1, 7756 webm: false, 7757 "default": 0, 7758 description: "This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced." 7759 }, 7760 0x9b: { 7761 name: "BlockDuration", 7762 level: 3, 7763 type: "u", 7764 minver: 1, 7765 "default": "TrackDuration", 7766 description: "The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timestamp of this Block and the timestamp of the next Block in \"display\" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe." 7767 }, 7768 0xa5: { 7769 name: "BlockAdditional", 7770 level: 5, 7771 type: "b", 7772 mandatory: true, 7773 minver: 1, 7774 webm: false, 7775 description: "Interpreted by the codec as it wishes (using the BlockAddID)." 7776 }, 7777 0xee: { 7778 name: "BlockAddID", 7779 level: 5, 7780 type: "u", 7781 mandatory: true, 7782 minver: 1, 7783 webm: false, 7784 "default": 1, 7785 range: "not 0", 7786 description: "An ID to identify the BlockAdditional level." 7787 }, 7788 0xa6: { 7789 name: "BlockMore", 7790 level: 4, 7791 type: "m", 7792 mandatory: true, 7793 multiple: true, 7794 minver: 1, 7795 webm: false, 7796 description: "Contain the BlockAdditional and some parameters." 7797 }, 7798 0x75a1: { 7799 name: "BlockAdditions", 7800 level: 3, 7801 type: "m", 7802 minver: 1, 7803 webm: false, 7804 description: "Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data." 7805 }, 7806 0xa2: { 7807 name: "BlockVirtual", 7808 level: 3, 7809 type: "b", 7810 webm: false, 7811 description: "A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual)" 7812 }, 7813 0xa1: { 7814 name: "Block", 7815 level: 3, 7816 type: "b", 7817 mandatory: true, 7818 minver: 1, 7819 description: "Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)" 7820 }, 7821 0xa0: { 7822 name: "BlockGroup", 7823 level: 2, 7824 type: "m", 7825 multiple: true, 7826 minver: 1, 7827 description: "Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock." 7828 }, 7829 0xa3: { 7830 name: "SimpleBlock", 7831 level: 2, 7832 type: "b", 7833 multiple: true, 7834 minver: 2, 7835 webm: true, 7836 divx: true, 7837 description: "Similar to SimpleBlock Structure" 7838 }, 7839 0xab: { 7840 name: "PrevSize", 7841 cppname: "ClusterPrevSize", 7842 level: 2, 7843 type: "u", 7844 minver: 1, 7845 description: "Size of the previous Cluster, in octets. Can be useful for backward playing.", 7846 position: "prevCluster" 7847 }, 7848 0xa7: { 7849 name: "Position", 7850 cppname: "ClusterPosition", 7851 level: 2, 7852 type: "u", 7853 minver: 1, 7854 webm: false, 7855 description: "The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.", 7856 position: "segment" 7857 }, 7858 0x58d7: { 7859 name: "SilentTrackNumber", 7860 cppname: "ClusterSilentTrackNumber", 7861 level: 3, 7862 type: "u", 7863 multiple: true, 7864 minver: 1, 7865 webm: false, 7866 description: "One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster." 7867 }, 7868 0xe7: { 7869 name: "Timecode", 7870 cppname: "ClusterTimecode", 7871 level: 2, 7872 type: "u", 7873 mandatory: true, 7874 minver: 1, 7875 description: "Absolute timestamp of the cluster (based on TimecodeScale)." 7876 }, 7877 0x1f43b675: { 7878 name: "Cluster", 7879 level: 1, 7880 type: "m", 7881 multiple: true, 7882 minver: 1, 7883 description: "The lower level element containing the (monolithic) Block structure." 7884 }, 7885 0x4d80: { 7886 name: "MuxingApp", 7887 level: 2, 7888 type: "8", 7889 mandatory: true, 7890 minver: 1, 7891 description: "Muxing application or library (\"libmatroska-0.4.3\")." 7892 }, 7893 0x7ba9: { 7894 name: "Title", 7895 level: 2, 7896 type: "8", 7897 minver: 1, 7898 webm: false, 7899 description: "General name of the segment." 7900 }, 7901 0x2ad7b2: { 7902 name: "TimecodeScaleDenominator", 7903 level: 2, 7904 type: "u", 7905 mandatory: true, 7906 minver: 4, 7907 "default": "1000000000", 7908 description: "Timestamp scale numerator, see TimecodeScale." 7909 }, 7910 0x2ad7b1: { 7911 name: "TimecodeScale", 7912 level: 2, 7913 type: "u", 7914 mandatory: true, 7915 minver: 1, 7916 "default": "1000000", 7917 description: "Timestamp scale in nanoseconds (1.000.000 means all timestamps in the segment are expressed in milliseconds)." 7918 }, 7919 0x69a5: { 7920 name: "ChapterTranslateID", 7921 level: 3, 7922 type: "b", 7923 mandatory: true, 7924 minver: 1, 7925 webm: false, 7926 description: "The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used." 7927 }, 7928 0x69bf: { 7929 name: "ChapterTranslateCodec", 7930 level: 3, 7931 type: "u", 7932 mandatory: true, 7933 minver: 1, 7934 webm: false, 7935 description: "The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)." 7936 }, 7937 0x69fc: { 7938 name: "ChapterTranslateEditionUID", 7939 level: 3, 7940 type: "u", 7941 multiple: true, 7942 minver: 1, 7943 webm: false, 7944 description: "Specify an edition UID on which this correspondance applies. When not specified, it means for all editions foun
7944d in the segment." 7945 }, 7946 0x3e83bb: { 7947 name: "NextFilename", 7948 level: 2, 7949 type: "8", 7950 minver: 1, 7951 webm: false, 7952 description: "An escaped filename corresponding to the next segment." 7953 }, 7954 0x3eb923: { 7955 name: "NextUID", 7956 level: 2, 7957 type: "b", 7958 minver: 1, 7959 webm: false, 7960 bytesize: 16, 7961 description: "A unique ID to identify the next chained segment (128 bits)." 7962 }, 7963 0x3c83ab: { 7964 name: "PrevFilename", 7965 level: 2, 7966 type: "8", 7967 minver: 1, 7968 webm: false, 7969 description: "An escaped filename corresponding to the previous segment." 7970 }, 7971 0x3cb923: { 7972 name: "PrevUID", 7973 level: 2, 7974 type: "b", 7975 minver: 1, 7976 webm: false, 7977 bytesize: 16, 7978 description: "A unique ID to identify the previous chained segment (128 bits)." 7979 }, 7980 0x73a4: { 7981 name: "SegmentUID", 7982 level: 2, 7983 type: "b", 7984 minver: 1, 7985 webm: false, 7986 range: "not 0", 7987 bytesize: 16, 7988 description: "A randomly generated unique ID to identify the current segment between many others (128 bits)." 7989 }, 7990 0x1549a966: { 7991 name: "Info", 7992 level: 1, 7993 type: "m", 7994 mandatory: true, 7995 multiple: true, 7996 minver: 1, 7997 description: "Contains miscellaneous general information and statistics on the file." 7998 }, 7999 0x53ac: { 8000 name: "SeekPosition", 8001 level: 3, 8002 type: "u", 8003 mandatory: true, 8004 minver: 1, 8005 description: "The position of the element in the segment in octets (0 = first level 1 element).", 8006 position: "segment" 8007 }, 8008 0x53ab: { 8009 name: "SeekID", 8010 level: 3, 8011 type: "b", 8012 mandatory: true, 8013 minver: 1, 8014 description: "The binary ID corresponding to the element name.", 8015 type2: "ebmlID" 8016 }, 8017 0x4dbb: { 8018 name: "Seek", 8019 cppname: "SeekPoint", 8020 level: 2, 8021 type: "m", 8022 mandatory: true, 8023 multiple: true, 8024 minver: 1, 8025 description: "Contains a single seek entry to an EBML element." 8026 }, 8027 0x114d9b74: { 8028 name: "SeekHead", 8029 cppname: "SeekHeader", 8030 level: 1, 8031 type: "m", 8032 multiple: true, 8033 minver: 1, 8034 description: "Contains the position of other level 1 elements." 8035 }, 8036 0x7e7b: { 8037 name: "SignatureElementList", 8038 level: 2, 8039 type: "m", 8040 multiple: true, 8041 webm: false, 8042 i: "Cluster|Block|BlockAdditional", 8043 description: "A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: means that the BlockAdditional of all Blocks in all Clusters is used for encryption." 8044 }, 8045 0x7e5b: { 8046 name: "SignatureElements", 8047 level: 1, 8048 type: "m", 8049 webm: false, 8050 description: "Contains elements that will be used to compute the signature." 8051 }, 8052 0x7eb5: { 8053 name: "Signature", 8054 level: 1, 8055 type: "b", 8056 webm: false, 8057 description: "The signature of the data (until a new." 8058 }, 8059 0x7ea5: { 8060 name: "SignaturePublicKey", 8061 level: 1, 8062 type: "b", 8063 webm: false, 8064 description: "The public key to use with the algorithm (in the case of a PKI-based signature)." 8065 }, 8066 0x7e9a: { 8067 name: "SignatureHash", 8068 level: 1, 8069 type: "u", 8070 webm: false, 8071 description: "Hash algorithm used (1=SHA1-160, 2=MD5)." 8072 }, 8073 0x7e8a: { 8074 name: "SignatureAlgo", 8075 level: 1, 8076 type: "u", 8077 webm: false, 8078 description: "Signature algorithm used (1=RSA, 2=elliptic)." 8079 }, 8080 0x1b538667: { 8081 name: "SignatureSlot", 8082 level: -1, 8083 type: "m", 8084 multiple: true, 8085 webm: false, 8086 description: "Contain signature of some (coming) elements in the stream." 8087 }, 8088 0xbf: { 8089 name: "CRC-32", 8090 level: -1, 8091 type: "b", 8092 minver: 1, 8093 webm: false, 8094 description: "The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian", 8095 crc: true 8096 }, 8097 0xec: { 8098 name: "Void", 8099 level: -1, 8100 type: "b", 8101 minver: 1, 8102 description: "Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use." 8103 }, 8104 0x42f3: { 8105 name: "EBMLMaxSizeLength", 8106 level: 1, 8107 type: "u", 8108 mandatory: true, 8109 "default": 8, 8110 minver: 1, 8111 description: "The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invali
8111d." 8112 }, 8113 0x42f2: { 8114 name: "EBMLMaxIDLength", 8115 level: 1, 8116 type: "u", 8117 mandatory: true, 8118 "default": 4, 8119 minver: 1, 8120 description: "The maximum length of the IDs you'll find in this file (4 or less in Matroska)." 8121 }, 8122 0x42f7: { 8123 name: "EBMLReadVersion", 8124 level: 1, 8125 type: "u", 8126 mandatory: true, 8127 "default": 1, 8128 minver: 1, 8129 description: "The minimum EBML version a parser has to support to read this file." 8130 }, 8131 0x1a45dfa3: { 8132 name: "EBML", 8133 level: "0", 8134 type: "m", 8135 mandatory: true, 8136 multiple: true, 8137 minver: 1, 8138 description: "Set the EBML characteristics of the data to follow. Each EBML document has to start with this." 8139 } 8140}; 8141 8142var byName = {}; 8143 8144var schema = { 8145 byEbmlID: byEbmlID, 8146 byName: byName 8147} 8148 8149for ( var ebmlID in byEbmlID) { 8150 var desc = byEbmlID[ebmlID]; 8151 byName[desc.name.replace('-', '_')] = parseInt(ebmlID, 10); 8152} 8153 8154module.exports = schema; 8155 8156},{}],18:[function(require,module,exports){ 8157module.exports={ 8158 "name": "ts-ebml", 8159 "version": "2.0.2", 8160 "description": "ebml decoder and encoder", 8161 "scripts": { 8162 "setup": "npm install -g http-server;", 8163 "init": "npm run update; npm run mkdir; npm run build", 8164 "update": "npm run reset; npm update", 8165 "reset": "rm -rf node_modules", 8166 "mkdir": "mkdir lib dist 2>/dev/null", 8167 "clean": "rm -rf lib/* dist/* test/*.js; mkdir -p dist", 8168 "build": "npm run clean && tsc -p .; npm run browserify", 8169 "start": "http-server . -s & tsc -w -p .& watchify lib/example_seekable.js -o test/example_seekable.js", 8170 "stop": "killall -- node */tsc -w -p", 8171 "browserify": "browserify lib/index.js --standalone EBML -o dist/EBML.js", 8172 "watchify": "watchify lib/index.js --standalone EBML -o dist/EBMl.js -v", 8173 "test": "tsc; espower lib/test.js > lib/test.tmp; mv -f lib/test.tmp lib/test.js; browserify lib/test.js -o test/test.js", 8174 "example": "tsc; browserify lib/example_seekable.js -o test/example_seekable.js", 8175 "examples": "tsc; for file in `find lib -name 'example_*.js' -type f -printf '%f\\n'`; do browserify lib/$file -o test/$file; done", 8176 "examples_bsd": "tsc; for file in `find lib -name 'example_*.js' -type f -print`; do browserify lib/$(basename $file) -o test/$(basename $file); done", 8177 "check": "tsc -w --noEmit -p ./", 8178 "lint": "tslint -c ./tslint.json --project ./tsconfig.json --type-check", 8179 "doc": "typedoc --mode modules --out doc --disableOutputCheck" 8180 }, 8181 "repository": { 8182 "type": "git", 8183 "url": "git+https://github.com/legokichi/ts-ebml.git" 8184 }, 8185 "keywords": [ 8186 "ebml", 8187 "webm", 8188 "mkv", 8189 "matrosika", 8190 "webp" 8191 ], 8192 "author": "legokichi duckscallion", 8193 "license": "MIT", 8194 "bugs": { 8195 "url": "https://github.com/legokichi/ts-ebml/issues" 8196 }, 8197 "homepage": "https://github.com/legokichi/ts-ebml#readme", 8198 "dependencies": { 8199 "buffer": "^5.0.7", 8200 "commander": "^2.11.0", 8201 "ebml": "^2.2.1", 8202 "ebml-block": "^1.1.0", 8203 "events": "^1.1.1", 8204 "int64-buffer": "^0.1.9", 8205 "matroska": "^2.2.3" 8206 }, 8207 "devDependencies": { 8208 "@types/commander": "^2.9.1", 8209 "@types/qunit": "^2.0.31", 8210 "browserify": "^13.1.0", 8211 "empower": "^1.2.3", 8212 "espower-cli": "^1.1.0", 8213 "power-assert": "^1.4.4", 8214 "power-assert-formatter": "^1.4.1", 8215 "qunit-tap": "^1.5.1", 8216 "qunitjs": "^2.4.0", 8217 "tslint": "^3.15.1", 8218 "typedoc": "^0.5.3", 8219 "typescript": "^2.4.2", 8220 "watchify": "^3.7.0" 8221 }, 8222 "bin": "./lib/cli.js", 8223 "main": "./lib/index.js", 8224 "typings": "./lib/index.d.ts" 8225} 8226 8227},{}]},{},[4])(4) 8228});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.