Files
im_webapp/umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js
T

7358 lines
233 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(self["webpackChunktinode_webapp"] = self["webpackChunktinode_webapp"] || []).push([["vendors-node_modules_webm-duration-fix_lib_index_js"],{
/***/ "./node_modules/base64-js/index.js":
/*!*****************************************!*\
!*** ./node_modules/base64-js/index.js ***!
\*****************************************/
/***/ (function(__unused_webpack_module, exports) {
"use strict";
exports.byteLength = byteLength
exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for (var i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i]
revLookup[code.charCodeAt(i)] = i
}
// Support decoding URL-safe base64 strings, as Node.js does.
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
revLookup['-'.charCodeAt(0)] = 62
revLookup['_'.charCodeAt(0)] = 63
function getLens (b64) {
var len = b64.length
if (len % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
// Trim off extra bytes after placeholder bytes are found
// See: https://github.com/beatgammit/base64-js/issues/42
var validLen = b64.indexOf('=')
if (validLen === -1) validLen = len
var placeHoldersLen = validLen === len
? 0
: 4 - (validLen % 4)
return [validLen, placeHoldersLen]
}
// base64 is 4/3 + up to two characters of the original data
function byteLength (b64) {
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
}
function _byteLength (b64, validLen, placeHoldersLen) {
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
}
function toByteArray (b64) {
var tmp
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
var curByte = 0
// if there are placeholders, only get up to the last complete 4 chars
var len = placeHoldersLen > 0
? validLen - 4
: validLen
var i
for (i = 0; i < len; i += 4) {
tmp =
(revLookup[b64.charCodeAt(i)] << 18) |
(revLookup[b64.charCodeAt(i + 1)] << 12) |
(revLookup[b64.charCodeAt(i + 2)] << 6) |
revLookup[b64.charCodeAt(i + 3)]
arr[curByte++] = (tmp >> 16) & 0xFF
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
}
if (placeHoldersLen === 2) {
tmp =
(revLookup[b64.charCodeAt(i)] << 2) |
(revLookup[b64.charCodeAt(i + 1)] >> 4)
arr[curByte++] = tmp & 0xFF
}
if (placeHoldersLen === 1) {
tmp =
(revLookup[b64.charCodeAt(i)] << 10) |
(revLookup[b64.charCodeAt(i + 1)] << 4) |
(revLookup[b64.charCodeAt(i + 2)] >> 2)
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
}
return arr
}
function tripletToBase64 (num) {
return lookup[num >> 18 & 0x3F] +
lookup[num >> 12 & 0x3F] +
lookup[num >> 6 & 0x3F] +
lookup[num & 0x3F]
}
function encodeChunk (uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
tmp =
((uint8[i] << 16) & 0xFF0000) +
((uint8[i + 1] << 8) & 0xFF00) +
(uint8[i + 2] & 0xFF)
output.push(tripletToBase64(tmp))
}
return output.join('')
}
function fromByteArray (uint8) {
var tmp
var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var parts = []
var maxChunkLength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
}
// pad the end with zeros, but make sure to not forget the extra bytes
if (extraBytes === 1) {
tmp = uint8[len - 1]
parts.push(
lookup[tmp >> 2] +
lookup[(tmp << 4) & 0x3F] +
'=='
)
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
parts.push(
lookup[tmp >> 10] +
lookup[(tmp >> 4) & 0x3F] +
lookup[(tmp << 2) & 0x3F] +
'='
)
}
return parts.join('')
}
/***/ }),
/***/ "./node_modules/buffer/index.js":
/*!**************************************!*\
!*** ./node_modules/buffer/index.js ***!
\**************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
/* eslint-disable no-proto */
const base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
const ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
const customInspectSymbol =
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
: null
exports.Buffer = Buffer
exports.SlowBuffer = SlowBuffer
exports.INSPECT_MAX_BYTES = 50
const K_MAX_LENGTH = 0x7fffffff
exports.kMaxLength = K_MAX_LENGTH
/**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
* === false Print warning and recommend using `buffer` v4.x which has an Object
* implementation (most compatible, even IE6)
*
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
* Opera 11.6+, iOS 4.2+.
*
* We report that the browser does not support typed arrays if the are not subclassable
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
* for __proto__ and has a buggy typed array implementation.
*/
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
typeof console.error === 'function') {
console.error(
'This browser lacks typed array (Uint8Array) support which is required by ' +
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
)
}
function typedArraySupport () {
// Can typed array instances can be augmented?
try {
const arr = new Uint8Array(1)
const proto = { foo: function () { return 42 } }
Object.setPrototypeOf(proto, Uint8Array.prototype)
Object.setPrototypeOf(arr, proto)
return arr.foo() === 42
} catch (e) {
return false
}
}
Object.defineProperty(Buffer.prototype, 'parent', {
enumerable: true,
get: function () {
if (!Buffer.isBuffer(this)) return undefined
return this.buffer
}
})
Object.defineProperty(Buffer.prototype, 'offset', {
enumerable: true,
get: function () {
if (!Buffer.isBuffer(this)) return undefined
return this.byteOffset
}
})
function createBuffer (length) {
if (length > K_MAX_LENGTH) {
throw new RangeError('The value "' + length + '" is invalid for option "size"')
}
// Return an augmented `Uint8Array` instance
const buf = new Uint8Array(length)
Object.setPrototypeOf(buf, Buffer.prototype)
return buf
}
/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/
function Buffer (arg, encodingOrOffset, length) {
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new TypeError(
'The "string" argument must be of type string. Received type number'
)
}
return allocUnsafe(arg)
}
return from(arg, encodingOrOffset, length)
}
Buffer.poolSize = 8192 // not used by this implementation
function from (value, encodingOrOffset, length) {
if (typeof value === 'string') {
return fromString(value, encodingOrOffset)
}
if (ArrayBuffer.isView(value)) {
return fromArrayView(value)
}
if (value == null) {
throw new TypeError(
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
'or Array-like Object. Received type ' + (typeof value)
)
}
if (isInstance(value, ArrayBuffer) ||
(value && isInstance(value.buffer, ArrayBuffer))) {
return fromArrayBuffer(value, encodingOrOffset, length)
}
if (typeof SharedArrayBuffer !== 'undefined' &&
(isInstance(value, SharedArrayBuffer) ||
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
return fromArrayBuffer(value, encodingOrOffset, length)
}
if (typeof value === 'number') {
throw new TypeError(
'The "value" argument must not be of type number. Received type number'
)
}
const valueOf = value.valueOf && value.valueOf()
if (valueOf != null && valueOf !== value) {
return Buffer.from(valueOf, encodingOrOffset, length)
}
const b = fromObject(value)
if (b) return b
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
typeof value[Symbol.toPrimitive] === 'function') {
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
}
throw new TypeError(
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
'or Array-like Object. Received type ' + (typeof value)
)
}
/**
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
* if value is a number.
* Buffer.from(str[, encoding])
* Buffer.from(array)
* Buffer.from(buffer)
* Buffer.from(arrayBuffer[, byteOffset[, length]])
**/
Buffer.from = function (value, encodingOrOffset, length) {
return from(value, encodingOrOffset, length)
}
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
// https://github.com/feross/buffer/pull/148
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
Object.setPrototypeOf(Buffer, Uint8Array)
function assertSize (size) {
if (typeof size !== 'number') {
throw new TypeError('"size" argument must be of type number')
} else if (size < 0) {
throw new RangeError('The value "' + size + '" is invalid for option "size"')
}
}
function alloc (size, fill, encoding) {
assertSize(size)
if (size <= 0) {
return createBuffer(size)
}
if (fill !== undefined) {
// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpreted as a start offset.
return typeof encoding === 'string'
? createBuffer(size).fill(fill, encoding)
: createBuffer(size).fill(fill)
}
return createBuffer(size)
}
/**
* Creates a new filled Buffer instance.
* alloc(size[, fill[, encoding]])
**/
Buffer.alloc = function (size, fill, encoding) {
return alloc(size, fill, encoding)
}
function allocUnsafe (size) {
assertSize(size)
return createBuffer(size < 0 ? 0 : checked(size) | 0)
}
/**
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
* */
Buffer.allocUnsafe = function (size) {
return allocUnsafe(size)
}
/**
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
*/
Buffer.allocUnsafeSlow = function (size) {
return allocUnsafe(size)
}
function fromString (string, encoding) {
if (typeof encoding !== 'string' || encoding === '') {
encoding = 'utf8'
}
if (!Buffer.isEncoding(encoding)) {
throw new TypeError('Unknown encoding: ' + encoding)
}
const length = byteLength(string, encoding) | 0
let buf = createBuffer(length)
const actual = buf.write(string, encoding)
if (actual !== length) {
// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
buf = buf.slice(0, actual)
}
return buf
}
function fromArrayLike (array) {
const length = array.length < 0 ? 0 : checked(array.length) | 0
const buf = createBuffer(length)
for (let i = 0; i < length; i += 1) {
buf[i] = array[i] & 255
}
return buf
}
function fromArrayView (arrayView) {
if (isInstance(arrayView, Uint8Array)) {
const copy = new Uint8Array(arrayView)
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
}
return fromArrayLike(arrayView)
}
function fromArrayBuffer (array, byteOffset, length) {
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('"offset" is outside of buffer bounds')
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('"length" is outside of buffer bounds')
}
let buf
if (byteOffset === undefined && length === undefined) {
buf = new Uint8Array(array)
} else if (length === undefined) {
buf = new Uint8Array(array, byteOffset)
} else {
buf = new Uint8Array(array, byteOffset, length)
}
// Return an augmented `Uint8Array` instance
Object.setPrototypeOf(buf, Buffer.prototype)
return buf
}
function fromObject (obj) {
if (Buffer.isBuffer(obj)) {
const len = checked(obj.length) | 0
const buf = createBuffer(len)
if (buf.length === 0) {
return buf
}
obj.copy(buf, 0, 0, len)
return buf
}
if (obj.length !== undefined) {
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
return createBuffer(0)
}
return fromArrayLike(obj)
}
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
return fromArrayLike(obj.data)
}
}
function checked (length) {
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= K_MAX_LENGTH) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
}
return length | 0
}
function SlowBuffer (length) {
if (+length != length) { // eslint-disable-line eqeqeq
length = 0
}
return Buffer.alloc(+length)
}
Buffer.isBuffer = function isBuffer (b) {
return b != null && b._isBuffer === true &&
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
}
Buffer.compare = function compare (a, b) {
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
throw new TypeError(
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
)
}
if (a === b) return 0
let x = a.length
let y = b.length
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
if (a[i] !== b[i]) {
x = a[i]
y = b[i]
break
}
}
if (x < y) return -1
if (y < x) return 1
return 0
}
Buffer.isEncoding = function isEncoding (encoding) {
switch (String(encoding).toLowerCase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'latin1':
case 'binary':
case 'base64':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return true
default:
return false
}
}
Buffer.concat = function concat (list, length) {
if (!Array.isArray(list)) {
throw new TypeError('"list" argument must be an Array of Buffers')
}
if (list.length === 0) {
return Buffer.alloc(0)
}
let i
if (length === undefined) {
length = 0
for (i = 0; i < list.length; ++i) {
length += list[i].length
}
}
const buffer = Buffer.allocUnsafe(length)
let pos = 0
for (i = 0; i < list.length; ++i) {
let buf = list[i]
if (isInstance(buf, Uint8Array)) {
if (pos + buf.length > buffer.length) {
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
buf.copy(buffer, pos)
} else {
Uint8Array.prototype.set.call(
buffer,
buf,
pos
)
}
} else if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers')
} else {
buf.copy(buffer, pos)
}
pos += buf.length
}
return buffer
}
function byteLength (string, encoding) {
if (Buffer.isBuffer(string)) {
return string.length
}
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
return string.byteLength
}
if (typeof string !== 'string') {
throw new TypeError(
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
'Received type ' + typeof string
)
}
const len = string.length
const mustMatch = (arguments.length > 2 && arguments[2] === true)
if (!mustMatch && len === 0) return 0
// Use a for loop to avoid recursion
let loweredCase = false
for (;;) {
switch (encoding) {
case 'ascii':
case 'latin1':
case 'binary':
return len
case 'utf8':
case 'utf-8':
return utf8ToBytes(string).length
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return len * 2
case 'hex':
return len >>> 1
case 'base64':
return base64ToBytes(string).length
default:
if (loweredCase) {
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
}
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
Buffer.byteLength = byteLength
function slowToString (encoding, start, end) {
let loweredCase = false
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if (start === undefined || start < 0) {
start = 0
}
// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if (start > this.length) {
return ''
}
if (end === undefined || end > this.length) {
end = this.length
}
if (end <= 0) {
return ''
}
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
end >>>= 0
start >>>= 0
if (end <= start) {
return ''
}
if (!encoding) encoding = 'utf8'
while (true) {
switch (encoding) {
case 'hex':
return hexSlice(this, start, end)
case 'utf8':
case 'utf-8':
return utf8Slice(this, start, end)
case 'ascii':
return asciiSlice(this, start, end)
case 'latin1':
case 'binary':
return latin1Slice(this, start, end)
case 'base64':
return base64Slice(this, start, end)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return utf16leSlice(this, start, end)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = (encoding + '').toLowerCase()
loweredCase = true
}
}
}
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
// reliably in a browserify context because there could be multiple different
// copies of the 'buffer' package in use. This method works even for Buffer
// instances that were created from another copy of the `buffer` package.
// See: https://github.com/feross/buffer/issues/154
Buffer.prototype._isBuffer = true
function swap (b, n, m) {
const i = b[n]
b[n] = b[m]
b[m] = i
}
Buffer.prototype.swap16 = function swap16 () {
const len = this.length
if (len % 2 !== 0) {
throw new RangeError('Buffer size must be a multiple of 16-bits')
}
for (let i = 0; i < len; i += 2) {
swap(this, i, i + 1)
}
return this
}
Buffer.prototype.swap32 = function swap32 () {
const len = this.length
if (len % 4 !== 0) {
throw new RangeError('Buffer size must be a multiple of 32-bits')
}
for (let i = 0; i < len; i += 4) {
swap(this, i, i + 3)
swap(this, i + 1, i + 2)
}
return this
}
Buffer.prototype.swap64 = function swap64 () {
const len = this.length
if (len % 8 !== 0) {
throw new RangeError('Buffer size must be a multiple of 64-bits')
}
for (let i = 0; i < len; i += 8) {
swap(this, i, i + 7)
swap(this, i + 1, i + 6)
swap(this, i + 2, i + 5)
swap(this, i + 3, i + 4)
}
return this
}
Buffer.prototype.toString = function toString () {
const length = this.length
if (length === 0) return ''
if (arguments.length === 0) return utf8Slice(this, 0, length)
return slowToString.apply(this, arguments)
}
Buffer.prototype.toLocaleString = Buffer.prototype.toString
Buffer.prototype.equals = function equals (b) {
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
if (this === b) return true
return Buffer.compare(this, b) === 0
}
Buffer.prototype.inspect = function inspect () {
let str = ''
const max = exports.INSPECT_MAX_BYTES
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
if (this.length > max) str += ' ... '
return '<Buffer ' + str + '>'
}
if (customInspectSymbol) {
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
}
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
if (isInstance(target, Uint8Array)) {
target = Buffer.from(target, target.offset, target.byteLength)
}
if (!Buffer.isBuffer(target)) {
throw new TypeError(
'The "target" argument must be one of type Buffer or Uint8Array. ' +
'Received type ' + (typeof target)
)
}
if (start === undefined) {
start = 0
}
if (end === undefined) {
end = target ? target.length : 0
}
if (thisStart === undefined) {
thisStart = 0
}
if (thisEnd === undefined) {
thisEnd = this.length
}
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
throw new RangeError('out of range index')
}
if (thisStart >= thisEnd && start >= end) {
return 0
}
if (thisStart >= thisEnd) {
return -1
}
if (start >= end) {
return 1
}
start >>>= 0
end >>>= 0
thisStart >>>= 0
thisEnd >>>= 0
if (this === target) return 0
let x = thisEnd - thisStart
let y = end - start
const len = Math.min(x, y)
const thisCopy = this.slice(thisStart, thisEnd)
const targetCopy = target.slice(start, end)
for (let i = 0; i < len; ++i) {
if (thisCopy[i] !== targetCopy[i]) {
x = thisCopy[i]
y = targetCopy[i]
break
}
}
if (x < y) return -1
if (y < x) return 1
return 0
}
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
//
// Arguments:
// - buffer - a Buffer to search
// - val - a string, Buffer, or number
// - byteOffset - an index into `buffer`; will be clamped to an int32
// - encoding - an optional encoding, relevant is val is a string
// - dir - true for indexOf, false for lastIndexOf
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
// Empty buffer means no match
if (buffer.length === 0) return -1
// Normalize byteOffset
if (typeof byteOffset === 'string') {
encoding = byteOffset
byteOffset = 0
} else if (byteOffset > 0x7fffffff) {
byteOffset = 0x7fffffff
} else if (byteOffset < -0x80000000) {
byteOffset = -0x80000000
}
byteOffset = +byteOffset // Coerce to Number.
if (numberIsNaN(byteOffset)) {
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
byteOffset = dir ? 0 : (buffer.length - 1)
}
// Normalize byteOffset: negative offsets start from the end of the buffer
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
if (byteOffset >= buffer.length) {
if (dir) return -1
else byteOffset = buffer.length - 1
} else if (byteOffset < 0) {
if (dir) byteOffset = 0
else return -1
}
// Normalize val
if (typeof val === 'string') {
val = Buffer.from(val, encoding)
}
// Finally, search either indexOf (if dir is true) or lastIndexOf
if (Buffer.isBuffer(val)) {
// Special case: looking for empty string/buffer always fails
if (val.length === 0) {
return -1
}
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
} else if (typeof val === 'number') {
val = val & 0xFF // Search for a byte value [0-255]
if (typeof Uint8Array.prototype.indexOf === 'function') {
if (dir) {
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
} else {
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
}
}
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
}
throw new TypeError('val must be string, number or Buffer')
}
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
let indexSize = 1
let arrLength = arr.length
let valLength = val.length
if (encoding !== undefined) {
encoding = String(encoding).toLowerCase()
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
encoding === 'utf16le' || encoding === 'utf-16le') {
if (arr.length < 2 || val.length < 2) {
return -1
}
indexSize = 2
arrLength /= 2
valLength /= 2
byteOffset /= 2
}
}
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
let i
if (dir) {
let foundIndex = -1
for (i = byteOffset; i < arrLength; i++) {
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
} else {
if (foundIndex !== -1) i -= i - foundIndex
foundIndex = -1
}
}
} else {
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
for (i = byteOffset; i >= 0; i--) {
let found = true
for (let j = 0; j < valLength; j++) {
if (read(arr, i + j) !== read(val, j)) {
found = false
break
}
}
if (found) return i
}
}
return -1
}
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
return this.indexOf(val, byteOffset, encoding) !== -1
}
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
}
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
}
function hexWrite (buf, string, offset, length) {
offset = Number(offset) || 0
const remaining = buf.length - offset
if (!length) {
length = remaining
} else {
length = Number(length)
if (length > remaining) {
length = remaining
}
}
const strLen = string.length
if (length > strLen / 2) {
length = strLen / 2
}
let i
for (i = 0; i < length; ++i) {
const parsed = parseInt(string.substr(i * 2, 2), 16)
if (numberIsNaN(parsed)) return i
buf[offset + i] = parsed
}
return i
}
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
function asciiWrite (buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length)
}
function base64Write (buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length)
}
function ucs2Write (buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
}
Buffer.prototype.write = function write (string, offset, length, encoding) {
// Buffer#write(string)
if (offset === undefined) {
encoding = 'utf8'
length = this.length
offset = 0
// Buffer#write(string, encoding)
} else if (length === undefined && typeof offset === 'string') {
encoding = offset
length = this.length
offset = 0
// Buffer#write(string, offset[, length][, encoding])
} else if (isFinite(offset)) {
offset = offset >>> 0
if (isFinite(length)) {
length = length >>> 0
if (encoding === undefined) encoding = 'utf8'
} else {
encoding = length
length = undefined
}
} else {
throw new Error(
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
)
}
const remaining = this.length - offset
if (length === undefined || length > remaining) length = remaining
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
throw new RangeError('Attempt to write outside buffer bounds')
}
if (!encoding) encoding = 'utf8'
let loweredCase = false
for (;;) {
switch (encoding) {
case 'hex':
return hexWrite(this, string, offset, length)
case 'utf8':
case 'utf-8':
return utf8Write(this, string, offset, length)
case 'ascii':
case 'latin1':
case 'binary':
return asciiWrite(this, string, offset, length)
case 'base64':
// Warning: maxLength not taken into account in base64Write
return base64Write(this, string, offset, length)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return ucs2Write(this, string, offset, length)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
Buffer.prototype.toJSON = function toJSON () {
return {
type: 'Buffer',
data: Array.prototype.slice.call(this._arr || this, 0)
}
}
function base64Slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf)
} else {
return base64.fromByteArray(buf.slice(start, end))
}
}
function utf8Slice (buf, start, end) {
end = Math.min(buf.length, end)
const res = []
let i = start
while (i < end) {
const firstByte = buf[i]
let codePoint = null
let bytesPerSequence = (firstByte > 0xEF)
? 4
: (firstByte > 0xDF)
? 3
: (firstByte > 0xBF)
? 2
: 1
if (i + bytesPerSequence <= end) {
let secondByte, thirdByte, fourthByte, tempCodePoint
switch (bytesPerSequence) {
case 1:
if (firstByte < 0x80) {
codePoint = firstByte
}
break
case 2:
secondByte = buf[i + 1]
if ((secondByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
if (tempCodePoint > 0x7F) {
codePoint = tempCodePoint
}
}
break
case 3:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
codePoint = tempCodePoint
}
}
break
case 4:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
fourthByte = buf[i + 3]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
codePoint = tempCodePoint
}
}
}
}
if (codePoint === null) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if (codePoint > 0xFFFF) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
codePoint = 0xDC00 | codePoint & 0x3FF
}
res.push(codePoint)
i += bytesPerSequence
}
return decodeCodePointsArray(res)
}
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is Chrome, with 0x10000 args.
// We go 1 magnitude less, for safety
const MAX_ARGUMENTS_LENGTH = 0x1000
function decodeCodePointsArray (codePoints) {
const len = codePoints.length
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
}
// Decode in chunks to avoid "call stack size exceeded".
let res = ''
let i = 0
while (i < len) {
res += String.fromCharCode.apply(
String,
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
)
}
return res
}
function asciiSlice (buf, start, end) {
let ret = ''
end = Math.min(buf.length, end)
for (let i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i] & 0x7F)
}
return ret
}
function latin1Slice (buf, start, end) {
let ret = ''
end = Math.min(buf.length, end)
for (let i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i])
}
return ret
}
function hexSlice (buf, start, end) {
const len = buf.length
if (!start || start < 0) start = 0
if (!end || end < 0 || end > len) end = len
let out = ''
for (let i = start; i < end; ++i) {
out += hexSliceLookupTable[buf[i]]
}
return out
}
function utf16leSlice (buf, start, end) {
const bytes = buf.slice(start, end)
let res = ''
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
for (let i = 0; i < bytes.length - 1; i += 2) {
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
}
return res
}
Buffer.prototype.slice = function slice (start, end) {
const len = this.length
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len
if (start < 0) start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0) end = 0
} else if (end > len) {
end = len
}
if (end < start) end = start
const newBuf = this.subarray(start, end)
// Return an augmented `Uint8Array` instance
Object.setPrototypeOf(newBuf, Buffer.prototype)
return newBuf
}
/*
* Need to make sure that buffer isn't trying to write out of bounds.
*/
function checkOffset (offset, ext, length) {
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
}
Buffer.prototype.readUintLE =
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
offset = offset >>> 0
byteLength = byteLength >>> 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
let val = this[offset]
let mul = 1
let i = 0
while (++i < byteLength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
return val
}
Buffer.prototype.readUintBE =
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
offset = offset >>> 0
byteLength = byteLength >>> 0
if (!noAssert) {
checkOffset(offset, byteLength, this.length)
}
let val = this[offset + --byteLength]
let mul = 1
while (byteLength > 0 && (mul *= 0x100)) {
val += this[offset + --byteLength] * mul
}
return val
}
Buffer.prototype.readUint8 =
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 1, this.length)
return this[offset]
}
Buffer.prototype.readUint16LE =
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 2, this.length)
return this[offset] | (this[offset + 1] << 8)
}
Buffer.prototype.readUint16BE =
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 2, this.length)
return (this[offset] << 8) | this[offset + 1]
}
Buffer.prototype.readUint32LE =
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 4, this.length)
return ((this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16)) +
(this[offset + 3] * 0x1000000)
}
Buffer.prototype.readUint32BE =
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset] * 0x1000000) +
((this[offset + 1] << 16) |
(this[offset + 2] << 8) |
this[offset + 3])
}
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
offset = offset >>> 0
validateNumber(offset, 'offset')
const first = this[offset]
const last = this[offset + 7]
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8)
}
const lo = first +
this[++offset] * 2 ** 8 +
this[++offset] * 2 ** 16 +
this[++offset] * 2 ** 24
const hi = this[++offset] +
this[++offset] * 2 ** 8 +
this[++offset] * 2 ** 16 +
last * 2 ** 24
return BigInt(lo) + (BigInt(hi) << BigInt(32))
})
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
offset = offset >>> 0
validateNumber(offset, 'offset')
const first = this[offset]
const last = this[offset + 7]
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8)
}
const hi = first * 2 ** 24 +
this[++offset] * 2 ** 16 +
this[++offset] * 2 ** 8 +
this[++offset]
const lo = this[++offset] * 2 ** 24 +
this[++offset] * 2 ** 16 +
this[++offset] * 2 ** 8 +
last
return (BigInt(hi) << BigInt(32)) + BigInt(lo)
})
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
offset = offset >>> 0
byteLength = byteLength >>> 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
let val = this[offset]
let mul = 1
let i = 0
while (++i < byteLength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
mul *= 0x80
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
return val
}
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
offset = offset >>> 0
byteLength = byteLength >>> 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
let i = byteLength
let mul = 1
let val = this[offset + --i]
while (i > 0 && (mul *= 0x100)) {
val += this[offset + --i] * mul
}
mul *= 0x80
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
return val
}
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 1, this.length)
if (!(this[offset] & 0x80)) return (this[offset])
return ((0xff - this[offset] + 1) * -1)
}
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 2, this.length)
const val = this[offset] | (this[offset + 1] << 8)
return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 2, this.length)
const val = this[offset + 1] | (this[offset] << 8)
return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16) |
(this[offset + 3] << 24)
}
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset] << 24) |
(this[offset + 1] << 16) |
(this[offset + 2] << 8) |
(this[offset + 3])
}
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
offset = offset >>> 0
validateNumber(offset, 'offset')
const first = this[offset]
const last = this[offset + 7]
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8)
}
const val = this[offset + 4] +
this[offset + 5] * 2 ** 8 +
this[offset + 6] * 2 ** 16 +
(last << 24) // Overflow
return (BigInt(val) << BigInt(32)) +
BigInt(first +
this[++offset] * 2 ** 8 +
this[++offset] * 2 ** 16 +
this[++offset] * 2 ** 24)
})
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
offset = offset >>> 0
validateNumber(offset, 'offset')
const first = this[offset]
const last = this[offset + 7]
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8)
}
const val = (first << 24) + // Overflow
this[++offset] * 2 ** 16 +
this[++offset] * 2 ** 8 +
this[++offset]
return (BigInt(val) << BigInt(32)) +
BigInt(this[++offset] * 2 ** 24 +
this[++offset] * 2 ** 16 +
this[++offset] * 2 ** 8 +
last)
})
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 4, this.length)
return ieee754.read(this, offset, true, 23, 4)
}
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 4, this.length)
return ieee754.read(this, offset, false, 23, 4)
}
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 8, this.length)
return ieee754.read(this, offset, true, 52, 8)
}
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
offset = offset >>> 0
if (!noAssert) checkOffset(offset, 8, this.length)
return ieee754.read(this, offset, false, 52, 8)
}
function checkInt (buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
if (offset + ext > buf.length) throw new RangeError('Index out of range')
}
Buffer.prototype.writeUintLE =
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
value = +value
offset = offset >>> 0
byteLength = byteLength >>> 0
if (!noAssert) {
const maxBytes = Math.pow(2, 8 * byteLength) - 1
checkInt(this, value, offset, byteLength, maxBytes, 0)
}
let mul = 1
let i = 0
this[offset] = value & 0xFF
while (++i < byteLength && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeUintBE =
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
value = +value
offset = offset >>> 0
byteLength = byteLength >>> 0
if (!noAssert) {
const maxBytes = Math.pow(2, 8 * byteLength) - 1
checkInt(this, value, offset, byteLength, maxBytes, 0)
}
let i = byteLength - 1
let mul = 1
this[offset + i] = value & 0xFF
while (--i >= 0 && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeUint8 =
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
this[offset] = (value & 0xff)
return offset + 1
}
Buffer.prototype.writeUint16LE =
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
return offset + 2
}
Buffer.prototype.writeUint16BE =
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
return offset + 2
}
Buffer.prototype.writeUint32LE =
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
this[offset + 3] = (value >>> 24)
this[offset + 2] = (value >>> 16)
this[offset + 1] = (value >>> 8)
this[offset] = (value & 0xff)
return offset + 4
}
Buffer.prototype.writeUint32BE =
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
return offset + 4
}
function wrtBigUInt64LE (buf, value, offset, min, max) {
checkIntBI(value, min, max, buf, offset, 7)
let lo = Number(value & BigInt(0xffffffff))
buf[offset++] = lo
lo = lo >> 8
buf[offset++] = lo
lo = lo >> 8
buf[offset++] = lo
lo = lo >> 8
buf[offset++] = lo
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
buf[offset++] = hi
hi = hi >> 8
buf[offset++] = hi
hi = hi >> 8
buf[offset++] = hi
hi = hi >> 8
buf[offset++] = hi
return offset
}
function wrtBigUInt64BE (buf, value, offset, min, max) {
checkIntBI(value, min, max, buf, offset, 7)
let lo = Number(value & BigInt(0xffffffff))
buf[offset + 7] = lo
lo = lo >> 8
buf[offset + 6] = lo
lo = lo >> 8
buf[offset + 5] = lo
lo = lo >> 8
buf[offset + 4] = lo
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
buf[offset + 3] = hi
hi = hi >> 8
buf[offset + 2] = hi
hi = hi >> 8
buf[offset + 1] = hi
hi = hi >> 8
buf[offset] = hi
return offset + 8
}
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
})
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
})
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) {
const limit = Math.pow(2, (8 * byteLength) - 1)
checkInt(this, value, offset, byteLength, limit - 1, -limit)
}
let i = 0
let mul = 1
let sub = 0
this[offset] = value & 0xFF
while (++i < byteLength && (mul *= 0x100)) {
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
sub = 1
}
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) {
const limit = Math.pow(2, (8 * byteLength) - 1)
checkInt(this, value, offset, byteLength, limit - 1, -limit)
}
let i = byteLength - 1
let mul = 1
let sub = 0
this[offset + i] = value & 0xFF
while (--i >= 0 && (mul *= 0x100)) {
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
sub = 1
}
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
if (value < 0) value = 0xff + value + 1
this[offset] = (value & 0xff)
return offset + 1
}
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
return offset + 2
}
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
return offset + 2
}
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
this[offset + 2] = (value >>> 16)
this[offset + 3] = (value >>> 24)
return offset + 4
}
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
if (value < 0) value = 0xffffffff + value + 1
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
return offset + 4
}
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
})
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
})
function checkIEEE754 (buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new RangeError('Index out of range')
if (offset < 0) throw new RangeError('Index out of range')
}
function writeFloat (buf, value, offset, littleEndian, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) {
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
}
ieee754.write(buf, value, offset, littleEndian, 23, 4)
return offset + 4
}
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
return writeFloat(this, value, offset, true, noAssert)
}
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
return writeFloat(this, value, offset, false, noAssert)
}
function writeDouble (buf, value, offset, littleEndian, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) {
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
}
ieee754.write(buf, value, offset, littleEndian, 52, 8)
return offset + 8
}
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
return writeDouble(this, value, offset, true, noAssert)
}
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
return writeDouble(this, value, offset, false, noAssert)
}
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
if (!start) start = 0
if (!end && end !== 0) end = this.length
if (targetStart >= target.length) targetStart = target.length
if (!targetStart) targetStart = 0
if (end > 0 && end < start) end = start
// Copy 0 bytes; we're done
if (end === start) return 0
if (target.length === 0 || this.length === 0) return 0
// Fatal error conditions
if (targetStart < 0) {
throw new RangeError('targetStart out of bounds')
}
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
if (end < 0) throw new RangeError('sourceEnd out of bounds')
// Are we oob?
if (end > this.length) end = this.length
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start
}
const len = end - start
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
// Use built-in when available, missing from IE11
this.copyWithin(targetStart, start, end)
} else {
Uint8Array.prototype.set.call(
target,
this.subarray(start, end),
targetStart
)
}
return len
}
// Usage:
// buffer.fill(number[, offset[, end]])
// buffer.fill(buffer[, offset[, end]])
// buffer.fill(string[, offset[, end]][, encoding])
Buffer.prototype.fill = function fill (val, start, end, encoding) {
// Handle string cases:
if (typeof val === 'string') {
if (typeof start === 'string') {
encoding = start
start = 0
end = this.length
} else if (typeof end === 'string') {
encoding = end
end = this.length
}
if (encoding !== undefined && typeof encoding !== 'string') {
throw new TypeError('encoding must be a string')
}
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
throw new TypeError('Unknown encoding: ' + encoding)
}
if (val.length === 1) {
const code = val.charCodeAt(0)
if ((encoding === 'utf8' && code < 128) ||
encoding === 'latin1') {
// Fast path: If `val` fits into a single byte, use that numeric value.
val = code
}
}
} else if (typeof val === 'number') {
val = val & 255
} else if (typeof val === 'boolean') {
val = Number(val)
}
// Invalid ranges are not set to a default, so can range check early.
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError('Out of range index')
}
if (end <= start) {
return this
}
start = start >>> 0
end = end === undefined ? this.length : end >>> 0
if (!val) val = 0
let i
if (typeof val === 'number') {
for (i = start; i < end; ++i) {
this[i] = val
}
} else {
const bytes = Buffer.isBuffer(val)
? val
: Buffer.from(val, encoding)
const len = bytes.length
if (len === 0) {
throw new TypeError('The value "' + val +
'" is invalid for argument "value"')
}
for (i = 0; i < end - start; ++i) {
this[i + start] = bytes[i % len]
}
}
return this
}
// CUSTOM ERRORS
// =============
// Simplified versions from Node, changed for Buffer-only usage
const errors = {}
function E (sym, getMessage, Base) {
errors[sym] = class NodeError extends Base {
constructor () {
super()
Object.defineProperty(this, 'message', {
value: getMessage.apply(this, arguments),
writable: true,
configurable: true
})
// Add the error code to the name to include it in the stack trace.
this.name = `${this.name} [${sym}]`
// Access the stack to generate the error message including the error code
// from the name.
this.stack // eslint-disable-line no-unused-expressions
// Reset the name to the actual name.
delete this.name
}
get code () {
return sym
}
set code (value) {
Object.defineProperty(this, 'code', {
configurable: true,
enumerable: true,
value,
writable: true
})
}
toString () {
return `${this.name} [${sym}]: ${this.message}`
}
}
}
E('ERR_BUFFER_OUT_OF_BOUNDS',
function (name) {
if (name) {
return `${name} is outside of buffer bounds`
}
return 'Attempt to access memory outside buffer bounds'
}, RangeError)
E('ERR_INVALID_ARG_TYPE',
function (name, actual) {
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
}, TypeError)
E('ERR_OUT_OF_RANGE',
function (str, range, input) {
let msg = `The value of "${str}" is out of range.`
let received = input
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
received = addNumericalSeparator(String(input))
} else if (typeof input === 'bigint') {
received = String(input)
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
received = addNumericalSeparator(received)
}
received += 'n'
}
msg += ` It must be ${range}. Received ${received}`
return msg
}, RangeError)
function addNumericalSeparator (val) {
let res = ''
let i = val.length
const start = val[0] === '-' ? 1 : 0
for (; i >= start + 4; i -= 3) {
res = `_${val.slice(i - 3, i)}${res}`
}
return `${val.slice(0, i)}${res}`
}
// CHECK FUNCTIONS
// ===============
function checkBounds (buf, offset, byteLength) {
validateNumber(offset, 'offset')
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
boundsError(offset, buf.length - (byteLength + 1))
}
}
function checkIntBI (value, min, max, buf, offset, byteLength) {
if (value > max || value < min) {
const n = typeof min === 'bigint' ? 'n' : ''
let range
if (byteLength > 3) {
if (min === 0 || min === BigInt(0)) {
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`
} else {
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
`${(byteLength + 1) * 8 - 1}${n}`
}
} else {
range = `>= ${min}${n} and <= ${max}${n}`
}
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
}
checkBounds(buf, offset, byteLength)
}
function validateNumber (value, name) {
if (typeof value !== 'number') {
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
}
}
function boundsError (value, length, type) {
if (Math.floor(value) !== value) {
validateNumber(value, type)
throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
}
if (length < 0) {
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
}
throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
`>= ${type ? 1 : 0} and <= ${length}`,
value)
}
// HELPER FUNCTIONS
// ================
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
function base64clean (str) {
// Node takes equal signs as end of the Base64 encoding
str = str.split('=')[0]
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = str.trim().replace(INVALID_BASE64_RE, '')
// Node converts strings with length < 2 to ''
if (str.length < 2) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while (str.length % 4 !== 0) {
str = str + '='
}
return str
}
function utf8ToBytes (string, units) {
units = units || Infinity
let codePoint
const length = string.length
let leadSurrogate = null
const bytes = []
for (let i = 0; i < length; ++i) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
function asciiToBytes (str) {
const byteArray = []
for (let i = 0; i < str.length; ++i) {
// Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i) & 0xFF)
}
return byteArray
}
function utf16leToBytes (str, units) {
let c, hi, lo
const byteArray = []
for (let i = 0; i < str.length; ++i) {
if ((units -= 2) < 0) break
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
function base64ToBytes (str) {
return base64.toByteArray(base64clean(str))
}
function blitBuffer (src, dst, offset, length) {
let i
for (i = 0; i < length; ++i) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
// the `instanceof` check but they should be treated as of that type.
// See: https://github.com/feross/buffer/issues/166
function isInstance (obj, type) {
return obj instanceof type ||
(obj != null && obj.constructor != null && obj.constructor.name != null &&
obj.constructor.name === type.name)
}
function numberIsNaN (obj) {
// For IE11 support
return obj !== obj // eslint-disable-line no-self-compare
}
// Create lookup table for `toString('hex')`
// See: https://github.com/feross/buffer/issues/219
const hexSliceLookupTable = (function () {
const alphabet = '0123456789abcdef'
const table = new Array(256)
for (let i = 0; i < 16; ++i) {
const i16 = i * 16
for (let j = 0; j < 16; ++j) {
table[i16 + j] = alphabet[i] + alphabet[j]
}
}
return table
})()
// Return not function with Error if BigInt not supported
function defineBigIntMethod (fn) {
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
}
function BufferBigIntNotDefined () {
throw new Error('BigInt not supported')
}
/***/ }),
/***/ "./node_modules/ebml-block/index.js":
/*!******************************************!*\
!*** ./node_modules/ebml-block/index.js ***!
\******************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var BufferReader = __webpack_require__(/*! ./lib/buffer-reader */ "./node_modules/ebml-block/lib/buffer-reader.js")
var XIPH_LACING = 1
var EBML_LACING = 3
var FIXED_SIZE_LACING = 2
module.exports = function (buffer) {
var block = {}
var reader = new BufferReader(buffer)
block.trackNumber = reader.nextUIntV()
block.timecode = reader.nextInt16BE()
var flags = reader.nextUInt8()
block.invisible = !!(flags & 0x8)
// only valid for SimpleBlock
block.keyframe = !!(flags & 0x80)
block.discardable = !!(flags & 0x1)
var lacing = (flags & 0x6) >> 1
block.frames = readLacedData(reader, lacing)
return block
}
function readLacedData (reader, lacing) {
if (!lacing) return [reader.nextBuffer()]
var i, frameSize
var frames = []
var framesNum = reader.nextUInt8() + 1 // number of frames
if (lacing === FIXED_SIZE_LACING) {
// remaining data should be divisible by the number of frames
if (reader.length % framesNum !== 0) throw new Error('Fixed-Size Lacing Error')
frameSize = reader.length / framesNum
for (i = 0; i < framesNum; i++) {
frames.push(reader.nextBuffer(frameSize))
}
return frames
}
var frameSizes = []
if (lacing === XIPH_LACING) {
for (i = 0; i < framesNum - 1; i++) {
var val
frameSize = 0
do {
val = reader.nextUInt8()
frameSize += val
} while (val === 0xff)
frameSizes.push(frameSize)
}
} else if (lacing === EBML_LACING) {
// first frame
frameSize = reader.nextUIntV()
frameSizes.push(frameSize)
// middle frames
for (i = 1; i < framesNum - 1; i++) {
frameSize += reader.nextIntV()
frameSizes.push(frameSize)
}
}
for (i = 0; i < framesNum - 1; i++) {
frames.push(reader.nextBuffer(frameSizes[i]))
}
// last frame (remaining buffer)
frames.push(reader.nextBuffer())
return frames
}
/***/ }),
/***/ "./node_modules/ebml-block/lib/buffer-reader.js":
/*!******************************************************!*\
!*** ./node_modules/ebml-block/lib/buffer-reader.js ***!
\******************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var vint = __webpack_require__(/*! ./vint */ "./node_modules/ebml-block/lib/vint.js")
function BufferReader (buffer) {
this.buffer = buffer
this.offset = 0
}
// a super limited subset of the node buffer API
BufferReader.prototype.nextInt16BE = function () {
var value = this.buffer.readInt16BE(this.offset)
this.offset += 2
return value
}
BufferReader.prototype.nextUInt8 = function () {
var value = this.buffer.readUInt8(this.offset)
this.offset += 1
return value
}
// EBML variable sized integers
BufferReader.prototype.nextUIntV = function () {
var v = vint(this.buffer, this.offset)
this.offset += v.length
return v.value
}
BufferReader.prototype.nextIntV = function () {
var v = vint(this.buffer, this.offset, true)
this.offset += v.length
return v.value
}
// buffer slice
BufferReader.prototype.nextBuffer = function (length) {
var buffer = length
? this.buffer.slice(this.offset, this.offset + length)
: this.buffer.slice(this.offset)
this.offset += length || this.length
return buffer
}
// remaining bytes to read
Object.defineProperty(BufferReader.prototype, 'length', {
get: function () { return this.buffer.length - this.offset }
})
module.exports = BufferReader
/***/ }),
/***/ "./node_modules/ebml-block/lib/vint.js":
/*!*********************************************!*\
!*** ./node_modules/ebml-block/lib/vint.js ***!
\*********************************************/
/***/ (function(module) {
// https://github.com/themasch/node-ebml/blob/master/lib/ebml/tools.js
module.exports = function (buffer, start, signed) {
start = start || 0
for (var length = 1; length <= 8; length++) {
if (buffer[start] >= Math.pow(2, 8 - length)) {
break
}
}
if (length > 8) {
throw new Error('Unrepresentable length: ' + length + ' ' +
buffer.toString('hex', start, start + length))
}
if (start + length > buffer.length) {
return null
}
var i
var value = buffer[start] & (1 << (8 - length)) - 1
for (i = 1; i < length; i++) {
if (i === 7) {
if (value >= Math.pow(2, 53 - 8) && buffer[start + 7] > 0) {
return {
length: length,
value: -1
}
}
}
value *= Math.pow(2, 8)
value += buffer[start + i]
}
if (signed) {
value -= Math.pow(2, length * 7 - 1) - 1
}
return {
length: length,
value: value
}
}
/***/ }),
/***/ "./node_modules/events/events.js":
/*!***************************************!*\
!*** ./node_modules/events/events.js ***!
\***************************************/
/***/ (function(module) {
"use strict";
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var R = typeof Reflect === 'object' ? Reflect : null
var ReflectApply = R && typeof R.apply === 'function'
? R.apply
: function ReflectApply(target, receiver, args) {
return Function.prototype.apply.call(target, receiver, args);
}
var ReflectOwnKeys
if (R && typeof R.ownKeys === 'function') {
ReflectOwnKeys = R.ownKeys
} else if (Object.getOwnPropertySymbols) {
ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target)
.concat(Object.getOwnPropertySymbols(target));
};
} else {
ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target);
};
}
function ProcessEmitWarning(warning) {
if (console && console.warn) console.warn(warning);
}
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
return value !== value;
}
function EventEmitter() {
EventEmitter.init.call(this);
}
module.exports = EventEmitter;
module.exports.once = once;
// Backwards-compat with node 0.10.x
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._eventsCount = 0;
EventEmitter.prototype._maxListeners = undefined;
// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
var defaultMaxListeners = 10;
function checkListener(listener) {
if (typeof listener !== 'function') {
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
}
}
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
enumerable: true,
get: function() {
return defaultMaxListeners;
},
set: function(arg) {
if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
}
defaultMaxListeners = arg;
}
});
EventEmitter.init = function() {
if (this._events === undefined ||
this._events === Object.getPrototypeOf(this)._events) {
this._events = Object.create(null);
this._eventsCount = 0;
}
this._maxListeners = this._maxListeners || undefined;
};
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
}
this._maxListeners = n;
return this;
};
function _getMaxListeners(that) {
if (that._maxListeners === undefined)
return EventEmitter.defaultMaxListeners;
return that._maxListeners;
}
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
return _getMaxListeners(this);
};
EventEmitter.prototype.emit = function emit(type) {
var args = [];
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
var doError = (type === 'error');
var events = this._events;
if (events !== undefined)
doError = (doError && events.error === undefined);
else if (!doError)
return false;
// If there is no 'error' event listener then throw.
if (doError) {
var er;
if (args.length > 0)
er = args[0];
if (er instanceof Error) {
// Note: The comments on the `throw` lines are intentional, they show
// up in Node's output if this results in an unhandled exception.
throw er; // Unhandled 'error' event
}
// At least give some kind of context to the user
var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
err.context = er;
throw err; // Unhandled 'error' event
}
var handler = events[type];
if (handler === undefined)
return false;
if (typeof handler === 'function') {
ReflectApply(handler, this, args);
} else {
var len = handler.length;
var listeners = arrayClone(handler, len);
for (var i = 0; i < len; ++i)
ReflectApply(listeners[i], this, args);
}
return true;
};
function _addListener(target, type, listener, prepend) {
var m;
var events;
var existing;
checkListener(listener);
events = target._events;
if (events === undefined) {
events = target._events = Object.create(null);
target._eventsCount = 0;
} else {
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (events.newListener !== undefined) {
target.emit('newListener', type,
listener.listener ? listener.listener : listener);
// Re-assign `events` because a newListener handler could have caused the
// this._events to be assigned to a new object
events = target._events;
}
existing = events[type];
}
if (existing === undefined) {
// Optimize the case of one listener. Don't need the extra array object.
existing = events[type] = listener;
++target._eventsCount;
} else {
if (typeof existing === 'function') {
// Adding the second element, need to change to array.
existing = events[type] =
prepend ? [listener, existing] : [existing, listener];
// If we've already got an array, just append.
} else if (prepend) {
existing.unshift(listener);
} else {
existing.push(listener);
}
// Check for listener leak
m = _getMaxListeners(target);
if (m > 0 && existing.length > m && !existing.warned) {
existing.warned = true;
// No error code for this since it is a Warning
// eslint-disable-next-line no-restricted-syntax
var w = new Error('Possible EventEmitter memory leak detected. ' +
existing.length + ' ' + String(type) + ' listeners ' +
'added. Use emitter.setMaxListeners() to ' +
'increase limit');
w.name = 'MaxListenersExceededWarning';
w.emitter = target;
w.type = type;
w.count = existing.length;
ProcessEmitWarning(w);
}
}
return target;
}
EventEmitter.prototype.addListener = function addListener(type, listener) {
return _addListener(this, type, listener, false);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.prependListener =
function prependListener(type, listener) {
return _addListener(this, type, listener, true);
};
function onceWrapper() {
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
if (arguments.length === 0)
return this.listener.call(this.target);
return this.listener.apply(this.target, arguments);
}
}
function _onceWrap(target, type, listener) {
var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
var wrapped = onceWrapper.bind(state);
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
EventEmitter.prototype.once = function once(type, listener) {
checkListener(listener);
this.on(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.prependOnceListener =
function prependOnceListener(type, listener) {
checkListener(listener);
this.prependListener(type, _onceWrap(this, type, listener));
return this;
};
// Emits a 'removeListener' event if and only if the listener was removed.
EventEmitter.prototype.removeListener =
function removeListener(type, listener) {
var list, events, position, i, originalListener;
checkListener(listener);
events = this._events;
if (events === undefined)
return this;
list = events[type];
if (list === undefined)
return this;
if (list === listener || list.listener === listener) {
if (--this._eventsCount === 0)
this._events = Object.create(null);
else {
delete events[type];
if (events.removeListener)
this.emit('removeListener', type, list.listener || listener);
}
} else if (typeof list !== 'function') {
position = -1;
for (i = list.length - 1; i >= 0; i--) {
if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
break;
}
}
if (position < 0)
return this;
if (position === 0)
list.shift();
else {
spliceOne(list, position);
}
if (list.length === 1)
events[type] = list[0];
if (events.removeListener !== undefined)
this.emit('removeListener', type, originalListener || listener);
}
return this;
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.removeAllListeners =
function removeAllListeners(type) {
var listeners, events, i;
events = this._events;
if (events === undefined)
return this;
// not listening for removeListener, no need to emit
if (events.removeListener === undefined) {
if (arguments.length === 0) {
this._events = Object.create(null);
this._eventsCount = 0;
} else if (events[type] !== undefined) {
if (--this._eventsCount === 0)
this._events = Object.create(null);
else
delete events[type];
}
return this;
}
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
var keys = Object.keys(events);
var key;
for (i = 0; i < keys.length; ++i) {
key = keys[i];
if (key === 'removeListener') continue;
this.removeAllListeners(key);
}
this.removeAllListeners('removeListener');
this._events = Object.create(null);
this._eventsCount = 0;
return this;
}
listeners = events[type];
if (typeof listeners === 'function') {
this.removeListener(type, listeners);
} else if (listeners !== undefined) {
// LIFO order
for (i = listeners.length - 1; i >= 0; i--) {
this.removeListener(type, listeners[i]);
}
}
return this;
};
function _listeners(target, type, unwrap) {
var events = target._events;
if (events === undefined)
return [];
var evlistener = events[type];
if (evlistener === undefined)
return [];
if (typeof evlistener === 'function')
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
return unwrap ?
unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
}
EventEmitter.prototype.listeners = function listeners(type) {
return _listeners(this, type, true);
};
EventEmitter.prototype.rawListeners = function rawListeners(type) {
return _listeners(this, type, false);
};
EventEmitter.listenerCount = function(emitter, type) {
if (typeof emitter.listenerCount === 'function') {
return emitter.listenerCount(type);
} else {
return listenerCount.call(emitter, type);
}
};
EventEmitter.prototype.listenerCount = listenerCount;
function listenerCount(type) {
var events = this._events;
if (events !== undefined) {
var evlistener = events[type];
if (typeof evlistener === 'function') {
return 1;
} else if (evlistener !== undefined) {
return evlistener.length;
}
}
return 0;
}
EventEmitter.prototype.eventNames = function eventNames() {
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
};
function arrayClone(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i)
copy[i] = arr[i];
return copy;
}
function spliceOne(list, index) {
for (; index + 1 < list.length; index++)
list[index] = list[index + 1];
list.pop();
}
function unwrapListeners(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < ret.length; ++i) {
ret[i] = arr[i].listener || arr[i];
}
return ret;
}
function once(emitter, name) {
return new Promise(function (resolve, reject) {
function errorListener(err) {
emitter.removeListener(name, resolver);
reject(err);
}
function resolver() {
if (typeof emitter.removeListener === 'function') {
emitter.removeListener('error', errorListener);
}
resolve([].slice.call(arguments));
};
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
if (name !== 'error') {
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
}
});
}
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
if (typeof emitter.on === 'function') {
eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
}
}
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
if (typeof emitter.on === 'function') {
if (flags.once) {
emitter.once(name, listener);
} else {
emitter.on(name, listener);
}
} else if (typeof emitter.addEventListener === 'function') {
// EventTarget does not have `error` event semantics like Node
// EventEmitters, we do not listen for `error` events here.
emitter.addEventListener(name, function wrapListener(arg) {
// IE does not have builtin `{ once: true }` support so we
// have to do it manually.
if (flags.once) {
emitter.removeEventListener(name, wrapListener);
}
listener(arg);
});
} else {
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
}
}
/***/ }),
/***/ "./node_modules/ieee754/index.js":
/*!***************************************!*\
!*** ./node_modules/ieee754/index.js ***!
\***************************************/
/***/ (function(__unused_webpack_module, exports) {
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
var e, m
var eLen = (nBytes * 8) - mLen - 1
var eMax = (1 << eLen) - 1
var eBias = eMax >> 1
var nBits = -7
var i = isLE ? (nBytes - 1) : 0
var d = isLE ? -1 : 1
var s = buffer[offset + i]
i += d
e = s & ((1 << (-nBits)) - 1)
s >>= (-nBits)
nBits += eLen
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
m = e & ((1 << (-nBits)) - 1)
e >>= (-nBits)
nBits += mLen
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
if (e === 0) {
e = 1 - eBias
} else if (e === eMax) {
return m ? NaN : ((s ? -1 : 1) * Infinity)
} else {
m = m + Math.pow(2, mLen)
e = e - eBias
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
}
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c
var eLen = (nBytes * 8) - mLen - 1
var eMax = (1 << eLen) - 1
var eBias = eMax >> 1
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
var i = isLE ? 0 : (nBytes - 1)
var d = isLE ? 1 : -1
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
value = Math.abs(value)
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0
e = eMax
} else {
e = Math.floor(Math.log(value) / Math.LN2)
if (value * (c = Math.pow(2, -e)) < 1) {
e--
c *= 2
}
if (e + eBias >= 1) {
value += rt / c
} else {
value += rt * Math.pow(2, 1 - eBias)
}
if (value * c >= 2) {
e++
c /= 2
}
if (e + eBias >= eMax) {
m = 0
e = eMax
} else if (e + eBias >= 1) {
m = ((value * c) - 1) * Math.pow(2, mLen)
e = e + eBias
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
e = 0
}
}
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
e = (e << mLen) | m
eLen += mLen
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
buffer[offset + i - d] |= s * 128
}
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/EBML.js":
/*!*********************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/EBML.js ***!
\*********************************************************/
/***/ (function(__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/EBMLDecoder.js":
/*!****************************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/EBMLDecoder.js ***!
\****************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
var int64_buffer_1 = __webpack_require__(/*! int64-buffer */ "./node_modules/int64-buffer/int64-buffer.js");
var tools_1 = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js");
var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js");
var ebmlID_1 = __webpack_require__(/*! ./ebmlID */ "./node_modules/webm-duration-fix/lib/ebml/ebmlID.js");
var State;
(function (State) {
State[State["STATE_TAG"] = 1] = "STATE_TAG";
State[State["STATE_SIZE"] = 2] = "STATE_SIZE";
State[State["STATE_CONTENT"] = 3] = "STATE_CONTENT";
})(State || (State = {}));
var EBMLDecoder = /** @class */ (function () {
function EBMLDecoder() {
this._buffer = new tools_1.Buffer(0);
this._tag_stack = [];
this._state = State.STATE_TAG;
this._cursor = 0;
this._total = 0;
this._schema = ebmlID_1.byEbmlID;
this._result = [];
}
EBMLDecoder.prototype.decode = function (chunk) {
this.readChunk(chunk);
var diff = this._result;
this._result = [];
return diff;
};
EBMLDecoder.prototype.readChunk = function (chunk) {
// 読みかけの(読めなかった) this._buffer と 新しい chunk を合わせて読み直す
this._buffer = tools.concat([this._buffer, new tools_1.Buffer(chunk)]);
while (this._cursor < this._buffer.length) {
// console.log(this._cursor, this._total, this._tag_stack);
if (this._state === State.STATE_TAG && !this.readTag()) {
break;
}
if (this._state === State.STATE_SIZE && !this.readSize()) {
break;
}
if (this._state === State.STATE_CONTENT && !this.readContent()) {
break;
}
}
};
EBMLDecoder.prototype.getSchemaInfo = function (tagNum) {
return this._schema[tagNum] || {
name: "unknown",
level: -1,
type: "unknown",
description: "unknown"
};
};
/**
* vint された parsing tag
* @return - return false when waiting for more data
*/
EBMLDecoder.prototype.readTag = function () {
// tag.length が buffer の外にある
if (this._cursor >= this._buffer.length) {
return false;
}
// read ebml id vint without first byte
var tag = (0, tools_1.readVint)(this._buffer, this._cursor);
// tag が読めなかった
if (tag == null) {
return false;
}
// >>>>>>>>>
// tag 識別子
//const tagStr = this._buffer.toString("hex", this._cursor, this._cursor + tag.length);
//const tagNum = parseInt(tagStr, 16);
// 上と等価
var buf = this._buffer.slice(this._cursor, this._cursor + tag.length);
var tagNum = buf.reduce(function (o, v, i, arr) { return o + v * Math.pow(16, 2 * (arr.length - 1 - i)); }, 0);
var schema = this.getSchemaInfo(tagNum);
var tagObj = {
EBML_ID: tagNum.toString(16),
schema: schema,
type: schema.type,
name: schema.name,
level: schema.level,
tagStart: this._total,
tagEnd: this._total + tag.length,
sizeStart: this._total + tag.length,
sizeEnd: null,
dataStart: null,
dataEnd: null,
dataSize: null,
data: null
};
// | tag: vint | size: vint | data: Buffer(size) |
this._tag_stack.push(tagObj);
// <<<<<<<<
// ポインタを進める
this._cursor += tag.length;
this._total += tag.length;
// 読み込み状態変更
this._state = State.STATE_SIZE;
return true;
};
/**
* vint された現在のタグの内容の大きさを読み込む
* @return - return false when waiting for more data
*/
EBMLDecoder.prototype.readSize = function () {
// tag.length が buffer の外にある
if (this._cursor >= this._buffer.length) {
return false;
}
// read ebml datasize vint without first byte
var size = (0, tools_1.readVint)(this._buffer, this._cursor);
// まだ読めない
if (size == null) {
return false;
}
// >>>>>>>>>
// current tag の data size 決定
var tagObj = this._tag_stack[this._tag_stack.length - 1];
tagObj.sizeEnd = tagObj.sizeStart + size.length;
tagObj.dataStart = tagObj.sizeEnd;
tagObj.dataSize = size.value;
if (size.value === -1) {
// unknown size
tagObj.dataEnd = -1;
if (tagObj.type === "m") {
tagObj.unknownSize = true;
}
}
else {
tagObj.dataEnd = tagObj.sizeEnd + size.value;
}
// <<<<<<<<
// ポインタを進める
this._cursor += size.length;
this._total += size.length;
this._state = State.STATE_CONTENT;
return true;
};
/**
* データ読み込み
*/
EBMLDecoder.prototype.readContent = function () {
var tagObj = this._tag_stack[this._tag_stack.length - 1];
// master element は子要素を持つので生データはない
if (tagObj.type === 'm') {
// console.log('content should be tags');
tagObj.isEnd = false;
this._result.push(tagObj);
this._state = State.STATE_TAG;
// この Mastert Element は空要素か
if (tagObj.dataSize === 0) {
// 即座に終了タグを追加
var elm = Object.assign({}, tagObj, { isEnd: true });
this._result.push(elm);
this._tag_stack.pop(); // スタックからこのタグを捨てる
}
return true;
}
// waiting for more data
if (this._buffer.length < this._cursor + tagObj.dataSize) {
return false;
}
// タグの中身の生データ
var data = this._buffer.slice(this._cursor, this._cursor + tagObj.dataSize);
// 読み終わったバッファを捨てて読み込んでいる部分のバッファのみ残す
this._buffer = this._buffer.slice(this._cursor + tagObj.dataSize);
tagObj.data = data;
// >>>>>>>>>
switch (tagObj.type) {
//case "m": break;
// Master-Element - contains other EBML sub-elements of the next lower level
case "u":
tagObj.value = data.readUIntBE(0, data.length);
break;
// Unsigned Integer - Big-endian, any size from 1 to 8 octets
case "i":
tagObj.value = data.readIntBE(0, data.length);
break;
// Signed Integer - Big-endian, any size from 1 to 8 octets
case "f":
tagObj.value = tagObj.dataSize === 4 ? data.readFloatBE(0) :
tagObj.dataSize === 8 ? data.readDoubleBE(0) :
(console.warn("cannot read ".concat(tagObj.dataSize, " octets float. failback to 0")), 0);
break;
// Float - Big-endian, defined for 4 and 8 octets (32, 64 bits)
case "s":
tagObj.value = data.toString("ascii");
break; // ascii
// Printable ASCII (0x20 to 0x7E), zero-padded when needed
case "8":
tagObj.value = data.toString("utf8");
break;
// Unicode string, zero padded when needed (RFC 2279)
case "b":
tagObj.value = data;
break;
// Binary - not interpreted by the parser
case "d":
tagObj.value = (0, tools_1.convertEBMLDateToJSDate)(new int64_buffer_1.Int64BE(data).toNumber());
break;
// nano second; Date.UTC(2001,1,1,0,0,0,0) === 980985600000
// Date - signed 8 octets integer in nanoseconds with 0 indicating
// the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC)
}
if (tagObj.value === null) {
throw new Error("unknown tag type:" + tagObj.type);
}
this._result.push(tagObj);
// <<<<<<<<
// ポインタを進める
this._total += tagObj.dataSize;
// タグ待ちモードに変更
this._state = State.STATE_TAG;
this._cursor = 0;
this._tag_stack.pop(); // remove the object from the stack
while (this._tag_stack.length > 0) {
var topEle = this._tag_stack[this._tag_stack.length - 1];
// 親が不定長サイズなので閉じタグは期待できない
if (topEle.dataEnd < 0) {
this._tag_stack.pop(); // 親タグを捨てる
return true;
}
// 閉じタグの来るべき場所まで来たかどうか
if (this._total < topEle.dataEnd) {
break;
}
// 閉じタグを挿入すべきタイミングが来た
if (topEle.type !== "m") {
throw new Error("parent element is not master element");
}
var elm = Object.assign({}, topEle, { isEnd: true });
this._result.push(elm);
this._tag_stack.pop();
}
return true;
};
return EBMLDecoder;
}());
exports["default"] = EBMLDecoder;
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js":
/*!****************************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js ***!
\****************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js");
var tools_1 = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js");
var ebmlID_1 = __webpack_require__(/*! ./ebmlID */ "./node_modules/webm-duration-fix/lib/ebml/ebmlID.js");
var EBMLEncoder = /** @class */ (function () {
function EBMLEncoder() {
this._schema = ebmlID_1.byEbmlID;
this._buffers = [];
this._stack = [];
}
EBMLEncoder.prototype.encode = function (elms) {
var _this = this;
return tools.concat(elms.reduce(function (lst, elm) {
return lst.concat(_this.encodeChunk(elm));
}, [])).buffer;
};
EBMLEncoder.prototype.encodeChunk = function (elm) {
if (elm.type === "m") {
if (!elm.isEnd) {
this.startTag(elm);
}
else {
this.endTag(elm);
}
}
else {
// ensure that we are working with an internal `Buffer` instance
elm.data = tools_1.Buffer.from(elm.data);
this.writeTag(elm);
}
return this.flush();
};
EBMLEncoder.prototype.flush = function () {
var ret = this._buffers;
this._buffers = [];
return ret;
};
EBMLEncoder.prototype.getSchemaInfo = function (tagName) {
var tagNums = Object.keys(this._schema).map(Number);
for (var i = 0; i < tagNums.length; i++) {
var tagNum = tagNums[i];
if (this._schema[tagNum].name === tagName) {
return new tools_1.Buffer(tagNum.toString(16), 'hex');
}
}
return null;
};
EBMLEncoder.prototype.writeTag = function (elm) {
var tagName = elm.name;
var tagId = this.getSchemaInfo(tagName);
var tagData = elm.data;
if (tagId == null) {
throw new Error('No schema entry found for ' + tagName);
}
var data = tools.encodeTag(tagId, tagData);
/**
* 親要素が閉じタグあり(isEnd)なら閉じタグが来るまで待つ(children queに入る)
*/
if (this._stack.length > 0) {
var last = this._stack[this._stack.length - 1];
last.children.push({
tagId: tagId,
elm: elm,
children: [],
data: data
});
return;
}
this._buffers = this._buffers.concat(data);
return;
};
EBMLEncoder.prototype.startTag = function (elm) {
var tagName = elm.name;
var tagId = this.getSchemaInfo(tagName);
if (tagId == null) {
throw new Error('No schema entry found for ' + tagName);
}
/**
* 閉じタグ不定長の場合はスタックに積まずに即時バッファに書き込む
*/
if (elm.unknownSize) {
var data = tools.encodeTag(tagId, new tools_1.Buffer(0), elm.unknownSize);
this._buffers = this._buffers.concat(data);
return;
}
var tag = {
tagId: tagId,
elm: elm,
children: [],
data: null
};
if (this._stack.length > 0) {
this._stack[this._stack.length - 1].children.push(tag);
}
this._stack.push(tag);
};
EBMLEncoder.prototype.endTag = function (elm) {
var tagName = elm.name;
var tag = this._stack.pop();
if (tag == null) {
throw new Error("EBML structure is broken");
}
if (tag.elm.name !== elm.name) {
throw new Error("EBML structure is broken");
}
var childTagDataBuffers = tag.children.reduce(function (lst, child) {
if (child.data === null) {
throw new Error("EBML structure is broken");
}
return lst.concat(child.data);
}, []);
var childTagDataBuffer = tools.concat(childTagDataBuffers);
if (tag.elm.type === "m") {
tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer, tag.elm.unknownSize);
}
else {
tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer);
}
if (this._stack.length < 1) {
this._buffers = this._buffers.concat(tag.data);
}
};
return EBMLEncoder;
}());
exports["default"] = EBMLEncoder;
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/EBMLReader.js":
/*!***************************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/EBMLReader.js ***!
\***************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", ({ value: true }));
var events_1 = __webpack_require__(/*! events */ "./node_modules/events/events.js");
var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js");
/**
* This is an informal code for reference.
* EBMLReader is a class for getting information to enable seeking Webm recorded by MediaRecorder.
* So please do not use for regular WebM files.
*/
var EBMLReader = /** @class */ (function (_super) {
__extends(EBMLReader, _super);
function EBMLReader() {
var _this = _super.call(this) || this;
_this.logGroup = "";
_this.hasLoggingStarted = false;
_this.metadataloaded = false;
_this.chunks = [];
_this.stack = [];
_this.segmentOffset = 0;
_this.last2SimpleBlockVideoTrackTimecode = [0, 0];
_this.last2SimpleBlockAudioTrackTimecode = [0, 0];
_this.lastClusterTimecode = 0;
_this.lastClusterPosition = 0;
_this.timecodeScale = 1000000; // webm default TimecodeScale is 1ms
_this.metadataSize = 0;
_this.metadatas = [];
_this.cues = [];
_this.firstVideoBlockRead = false;
_this.firstAudioBlockRead = false;
_this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null };
_this.trackTypes = [];
_this.trackDefaultDuration = [];
_this.trackCodecDelay = [];
_this.trackInfo = { type: "nothing" };
_this.ended = false;
_this.logging = false;
_this.use_duration_every_simpleblock = false;
_this.use_webp = false;
_this.use_segment_info = true;
_this.drop_default_duration = true;
return _this;
}
/**
* emit final state.
*/
EBMLReader.prototype.stop = function () {
this.ended = true;
this.emit_segment_info();
// clean up any unclosed Master Elements at the end of the stream.
while (this.stack.length) {
this.stack.pop();
if (this.logging) {
console.groupEnd();
}
}
// close main group if set, logging is enabled, and has actually logged anything.
if (this.logging && this.hasLoggingStarted && this.logGroup) {
console.groupEnd();
}
};
/**
* emit chunk info
*/
EBMLReader.prototype.emit_segment_info = function () {
var data = this.chunks;
this.chunks = [];
if (!this.metadataloaded) {
this.metadataloaded = true;
this.metadatas = data;
var videoTrackNum = this.trackTypes.indexOf(1); // find first video track
var audioTrackNum = this.trackTypes.indexOf(2); // find first audio track
this.trackInfo = videoTrackNum >= 0 && audioTrackNum >= 0 ? { type: "both", trackNumber: videoTrackNum }
: videoTrackNum >= 0 ? { type: "video", trackNumber: videoTrackNum }
: audioTrackNum >= 0 ? { type: "audio", trackNumber: audioTrackNum }
: { type: "nothing" };
if (!this.use_segment_info) {
return;
}
this.emit("metadata", { data: data, metadataSize: this.metadataSize });
}
else {
if (!this.use_segment_info) {
return;
}
var timecode = this.lastClusterTimecode;
var duration = this.duration;
var timecodeScale = this.timecodeScale;
this.emit("cluster", { timecode: timecode, data: data });
this.emit("duration", { timecodeScale: timecodeScale, duration: duration });
}
};
EBMLReader.prototype.read = function (elm) {
var _this = this;
var drop = false;
if (this.ended) {
// reader is finished
return;
}
if (elm.type === "m") {
// 閉じタグの自動挿入
if (elm.isEnd) {
this.stack.pop();
}
else {
var parent_1 = this.stack[this.stack.length - 1];
if (parent_1 != null && parent_1.level >= elm.level) {
// 閉じタグなしでレベルが下がったら閉じタグを挿入
this.stack.pop();
// From http://w3c.github.io/media-source/webm-byte-stream-format.html#webm-media-segments
// This fixes logging for webm streams with Cluster of unknown length and no Cluster closing elements.
if (this.logging) {
console.groupEnd();
}
parent_1.dataEnd = elm.dataEnd;
parent_1.dataSize = elm.dataEnd - parent_1.dataStart;
parent_1.unknownSize = false;
var o = Object.assign({}, parent_1, { name: parent_1.name, type: parent_1.type, isEnd: true });
this.chunks.push(o);
}
this.stack.push(elm);
}
}
if (elm.type === "m" && elm.name == "Segment") {
if (this.segmentOffset != 0) {
console.warn("Multiple segments detected!");
}
this.segmentOffset = elm.dataStart;
this.emit("segment_offset", this.segmentOffset);
}
else if (elm.type === "b" && elm.name === "SimpleBlock") {
var _a = tools.ebmlBlock(elm.data), timecode = _a.timecode, trackNumber = _a.trackNumber, frames_1 = _a.frames;
if (this.trackTypes[trackNumber] === 1) { // trackType === 1 => video track
if (!this.firstVideoBlockRead) {
this.firstVideoBlockRead = true;
if (this.trackInfo.type === "both" || this.trackInfo.type === "video") {
var CueTime = this.lastClusterTimecode + timecode;
this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });
this.emit("cue_info", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode });
this.emit("cue", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });
}
}
this.last2SimpleBlockVideoTrackTimecode = [this.last2SimpleBlockVideoTrackTimecode[1], timecode];
}
else if (this.trackTypes[trackNumber] === 2) { // trackType === 2 => audio track
if (!this.firstAudioBlockRead) {
this.firstAudioBlockRead = true;
if (this.trackInfo.type === "audio") {
var CueTime = this.lastClusterTimecode + timecode;
this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });
this.emit("cue_info", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode });
this.emit("cue", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });
}
}
this.last2SimpleBlockAudioTrackTimecode = [this.last2SimpleBlockAudioTrackTimecode[1], timecode];
}
if (this.use_duration_every_simpleblock) {
this.emit("duration", { timecodeScale: this.timecodeScale, duration: this.duration });
}
if (this.use_webp) {
frames_1.forEach(function (frame) {
var startcode = frame.slice(3, 6).toString("hex");
if (startcode !== "9d012a") {
return;
}
; // VP8 の場合
var webpBuf = tools.VP8BitStreamToRiffWebPBuffer(frame);
var webp = new Blob([webpBuf], { type: "image/webp" });
var currentTime = _this.duration;
_this.emit("webp", { currentTime: currentTime, webp: webp });
});
}
}
else if (elm.type === "m" && elm.name === "Cluster" && elm.isEnd === false) {
this.firstVideoBlockRead = false;
this.firstAudioBlockRead = false;
this.emit_segment_info();
this.emit("cluster_ptr", elm.tagStart);
this.lastClusterPosition = elm.tagStart;
}
else if (elm.type === "u" && elm.name === "Timecode") {
this.lastClusterTimecode = elm.value;
}
else if (elm.type === "u" && elm.name === "TimecodeScale") {
this.timecodeScale = elm.value;
}
else if (elm.type === "m" && elm.name === "TrackEntry") {
if (elm.isEnd) {
this.trackTypes[this.currentTrack.TrackNumber] = this.currentTrack.TrackType;
this.trackDefaultDuration[this.currentTrack.TrackNumber] = this.currentTrack.DefaultDuration;
this.trackCodecDelay[this.currentTrack.TrackNumber] = this.currentTrack.CodecDelay;
}
else {
this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null };
}
}
else if (elm.type === "u" && elm.name === "TrackType") {
this.currentTrack.TrackType = elm.value;
}
else if (elm.type === "u" && elm.name === "TrackNumber") {
this.currentTrack.TrackNumber = elm.value;
}
else if (elm.type === "u" && elm.name === "CodecDelay") {
this.currentTrack.CodecDelay = elm.value;
}
else if (elm.type === "u" && elm.name === "DefaultDuration") {
// media source api は DefaultDuration を計算するとバグる。
// https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22
// chrome 58 ではこれを回避するために DefaultDuration 要素を抜き取った。
// chrome 58 以前でもこのタグを抜き取ることで回避できる
if (this.drop_default_duration) {
console.warn("DefaultDuration detected!, remove it");
drop = true;
}
else {
this.currentTrack.DefaultDuration = elm.value;
}
}
else if (elm.name === "unknown") {
console.warn(elm);
}
if (!this.metadataloaded && elm.dataEnd > 0) {
this.metadataSize = elm.dataEnd;
}
if (!drop) {
this.chunks.push(elm);
}
if (this.logging) {
this.put(elm);
}
};
Object.defineProperty(EBMLReader.prototype, "duration", {
/**
* DefaultDuration が定義されている場合は最後のフレームのdurationも考慮する
* 単位 timecodeScale
*
* !!! if you need duration with seconds !!!
* ```js
* const nanosec = reader.duration * reader.timecodeScale;
* const sec = nanosec / 1000 / 1000 / 1000;
* ```
*/
get: function () {
if (this.trackInfo.type === "nothing") {
console.warn("no video, no audio track");
return 0;
}
// defaultDuration は 生の nano sec
var defaultDuration = 0;
// nanoseconds
var codecDelay = 0;
var lastTimecode = 0;
var _defaultDuration = this.trackDefaultDuration[this.trackInfo.trackNumber];
if (typeof _defaultDuration === "number") {
defaultDuration = _defaultDuration;
}
else {
// https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22
// default duration がないときに使う delta
if (this.trackInfo.type === "both") {
if (this.last2SimpleBlockAudioTrackTimecode[1] > this.last2SimpleBlockVideoTrackTimecode[1]) {
// audio diff
defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale;
// audio delay
var delay = this.trackCodecDelay[this.trackTypes.indexOf(2)]; // 2 => audio
if (typeof delay === "number") {
codecDelay = delay;
}
// audio timecode
lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1];
}
else {
// video diff
defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale;
// video delay
var delay = this.trackCodecDelay[this.trackTypes.indexOf(1)]; // 1 => video
if (typeof delay === "number") {
codecDelay = delay;
}
// video timecode
lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1];
}
}
else if (this.trackInfo.type === "video") {
defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale;
var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 2 => audio
if (typeof delay === "number") {
codecDelay = delay;
}
lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1];
}
else if (this.trackInfo.type === "audio") {
defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale;
var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 1 => video
if (typeof delay === "number") {
codecDelay = delay;
}
lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1];
} // else { not reached }
}
// convert to timecodescale
var duration_nanosec = ((this.lastClusterTimecode + lastTimecode) * this.timecodeScale) + defaultDuration - codecDelay;
var duration = duration_nanosec / this.timecodeScale;
return Math.floor(duration);
},
enumerable: false,
configurable: true
});
EBMLReader.prototype.addListener = function (event, listener) {
return _super.prototype.addListener.call(this, event, listener);
};
EBMLReader.prototype.put = function (elm) {
if (!this.hasLoggingStarted) {
this.hasLoggingStarted = true;
if (this.logging && this.logGroup) {
console.groupCollapsed(this.logGroup);
}
}
if (elm.type === "m") {
if (elm.isEnd) {
console.groupEnd();
}
else {
console.group(elm.name + ":" + elm.tagStart);
}
}
else if (elm.type === "b") {
// for debug
//if(elm.name === "SimpleBlock"){
//const o = EBML.tools.ebmlBlock(elm.value);
//console.log(elm.name, elm.type, o.trackNumber, o.timecode);
//}else{
console.log(elm.name, elm.type);
//}
}
else {
console.log(elm.name, elm.tagStart, elm.type, elm.value);
}
};
return EBMLReader;
}(events_1.EventEmitter));
exports["default"] = EBMLReader;
;
;
;
;
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/ebmlID.js":
/*!***********************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/ebmlID.js ***!
\***********************************************************/
/***/ (function(__unused_webpack_module, exports) {
"use strict";
// source: https://www.matroska.org/technical/elements.html
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.byEbmlID = void 0;
exports.byEbmlID = {
0x80: {
name: "ChapterDisplay",
level: 4,
type: "m",
multiple: true,
minver: 1,
webm: true,
description: "Contains all possible strings to use for the chapter display."
},
0x83: {
name: "TrackType",
level: 3,
type: "u",
mandatory: true,
minver: 1,
range: "1-254",
description: "A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control)."
},
0x85: {
name: "ChapString",
cppname: "ChapterString",
level: 5,
type: "8",
mandatory: true,
minver: 1,
webm: true,
description: "Contains the string to use as the chapter atom."
},
0x86: {
name: "CodecID",
level: 3,
type: "s",
mandatory: true,
minver: 1,
description: "An ID corresponding to the codec, see the codec page for more info."
},
0x88: {
name: "FlagDefault",
cppname: "TrackFlagDefault",
level: 3,
type: "u",
mandatory: true,
minver: 1,
"default": 1,
range: "0-1",
description: "Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)"
},
0x89: {
name: "ChapterTrackNumber",
level: 5,
type: "u",
mandatory: true,
multiple: true,
minver: 1,
webm: false,
range: "not 0",
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."
},
0x91: {
name: "ChapterTimeStart",
level: 4,
type: "u",
mandatory: true,
minver: 1,
webm: true,
description: "Timestamp of the start of Chapter (not scaled)."
},
0x92: {
name: "ChapterTimeEnd",
level: 4,
type: "u",
minver: 1,
webm: false,
description: "Timestamp of the end of Chapter (timestamp excluded, not scaled)."
},
0x96: {
name: "CueRefTime",
level: 5,
type: "u",
mandatory: true,
minver: 2,
webm: false,
description: "Timestamp of the referenced Block."
},
0x97: {
name: "CueRefCluster",
level: 5,
type: "u",
mandatory: true,
webm: false,
description: "The Position of the Cluster containing the referenced Block."
},
0x98: {
name: "ChapterFlagHidden",
level: 4,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
range: "0-1",
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)"
},
0x4254: {
name: "ContentCompAlgo",
level: 6,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
// "br": [ "", "", "", "" ],
// "del": [ "1 - bzlib,", "2 - lzo1x" ],
description: "The compression algorithm used. Algorithms that have been specified so far are: 0 - zlib, 3 - Header Stripping"
},
0x4255: {
name: "ContentCompSettings",
level: 6,
type: "b",
minver: 1,
webm: false,
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."
},
0x4282: {
name: "DocType",
level: 1,
type: "s",
mandatory: true,
"default": "matroska",
minver: 1,
description: "A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files."
},
0x4285: {
name: "DocTypeReadVersion",
level: 1,
type: "u",
mandatory: true,
"default": 1,
minver: 1,
description: "The minimum DocType version an interpreter has to support to read this file."
},
0x4286: {
name: "EBMLVersion",
level: 1,
type: "u",
mandatory: true,
"default": 1,
minver: 1,
description: "The version of EBML parser used to create the file."
},
0x4287: {
name: "DocTypeVersion",
level: 1,
type: "u",
mandatory: true,
"default": 1,
minver: 1,
description: "The version of DocType interpreter used to create the file."
},
0x4444: {
name: "SegmentFamily",
level: 2,
type: "b",
multiple: true,
minver: 1,
webm: false,
bytesize: 16,
description: "A randomly generated unique ID that all segments related to each other must use (128 bits)."
},
0x4461: {
name: "DateUTC",
level: 2,
type: "d",
minver: 1,
description: "Date of the origin of timestamp (value 0), i.e. production date."
},
0x4484: {
name: "TagDefault",
level: 4,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 1,
range: "0-1",
description: "Indication to know if this is the default/original language to use for the given tag. (1 bit)"
},
0x4485: {
name: "TagBinary",
level: 4,
type: "b",
minver: 1,
webm: false,
description: "The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString."
},
0x4487: {
name: "TagString",
level: 4,
type: "8",
minver: 1,
webm: false,
description: "The value of the Element."
},
0x4489: {
name: "Duration",
level: 2,
type: "f",
minver: 1,
range: "> 0",
description: "Duration of the segment (based on TimecodeScale)."
},
0x4598: {
name: "ChapterFlagEnabled",
level: 4,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 1,
range: "0-1",
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)"
},
0x4660: {
name: "FileMimeType",
level: 3,
type: "s",
mandatory: true,
minver: 1,
webm: false,
description: "MIME type of the file."
},
0x4661: {
name: "FileUsedStartTime",
level: 3,
type: "u",
divx: true,
description: "DivX font extension"
},
0x4662: {
name: "FileUsedEndTime",
level: 3,
type: "u",
divx: true,
description: "DivX font extension"
},
0x4675: {
name: "FileReferral",
level: 3,
type: "b",
webm: false,
description: "A binary value that a track/codec can refer to when the attachment is needed."
},
0x5031: {
name: "ContentEncodingOrder",
level: 5,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x5032: {
name: "ContentEncodingScope",
level: 5,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 1,
range: "not 0",
// "br": [ "", "", "" ],
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)"
},
0x5033: {
name: "ContentEncodingType",
level: 5,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
// "br": [ "", "" ],
description: "A value describing what kind of transformation has been done. Possible values: 0 - compression, 1 - encryption"
},
0x5034: {
name: "ContentCompression",
level: 5,
type: "m",
minver: 1,
webm: false,
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."
},
0x5035: {
name: "ContentEncryption",
level: 5,
type: "m",
minver: 1,
webm: false,
description: "Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise."
},
0x5378: {
name: "CueBlockNumber",
level: 4,
type: "u",
minver: 1,
"default": 1,
range: "not 0",
description: "Number of the Block in the specified Cluster."
},
0x5654: {
name: "ChapterStringUID",
level: 4,
type: "8",
mandatory: false,
minver: 3,
webm: true,
description: "A unique string ID to identify the Chapter. Use for WebVTT cue identifier storage."
},
0x5741: {
name: "WritingApp",
level: 2,
type: "8",
mandatory: true,
minver: 1,
description: "Writing application (\"mkvmerge-0.3.3\")."
},
0x5854: {
name: "SilentTracks",
cppname: "ClusterSilentTracks",
level: 2,
type: "m",
minver: 1,
webm: false,
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."
},
0x6240: {
name: "ContentEncoding",
level: 4,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
webm: false,
description: "Settings for one content encoding like compression or encryption."
},
0x6264: {
name: "BitDepth",
cppname: "AudioBitDepth",
level: 4,
type: "u",
minver: 1,
range: "not 0",
description: "Bits per sample, mostly used for PCM."
},
0x6532: {
name: "SignedElement",
level: 3,
type: "b",
multiple: true,
webm: false,
description: "An element ID whose data will be used to compute the signature."
},
0x6624: {
name: "TrackTranslate",
level: 3,
type: "m",
multiple: true,
minver: 1,
webm: false,
description: "The track identification for the given Chapter Codec."
},
0x6911: {
name: "ChapProcessCommand",
cppname: "ChapterProcessCommand",
level: 5,
type: "m",
multiple: true,
minver: 1,
webm: false,
description: "Contains all the commands associated to the Atom."
},
0x6922: {
name: "ChapProcessTime",
cppname: "ChapterProcessTime",
level: 6,
type: "u",
mandatory: true,
minver: 1,
webm: false,
description: "Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter)."
},
0x6924: {
name: "ChapterTranslate",
level: 2,
type: "m",
multiple: true,
minver: 1,
webm: false,
description: "A tuple of corresponding ID used by chapter codecs to represent this segment."
},
0x6933: {
name: "ChapProcessData",
cppname: "ChapterProcessData",
level: 6,
type: "b",
mandatory: true,
minver: 1,
webm: false,
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."
},
0x6944: {
name: "ChapProcess",
cppname: "ChapterProcess",
level: 4,
type: "m",
multiple: true,
minver: 1,
webm: false,
description: "Contains all the commands associated to the Atom."
},
0x6955: {
name: "ChapProcessCodecID",
cppname: "ChapterProcessCodecID",
level: 5,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x7373: {
name: "Tag",
level: 2,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
webm: false,
description: "Element containing elements specific to Tracks/Chapters."
},
0x7384: {
name: "SegmentFilename",
level: 2,
type: "8",
minver: 1,
webm: false,
description: "A filename corresponding to this segment."
},
0x7446: {
name: "AttachmentLink",
cppname: "TrackAttachmentLink",
level: 3,
type: "u",
minver: 1,
webm: false,
range: "not 0",
description: "The UID of an attachment that is used by this codec."
},
0x258688: {
name: "CodecName",
level: 3,
type: "8",
minver: 1,
description: "A human-readable string specifying the codec."
},
0x18538067: {
name: "Segment",
level: "0",
type: "m",
mandatory: true,
multiple: true,
minver: 1,
description: "This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment."
},
0x447a: {
name: "TagLanguage",
level: 4,
type: "s",
mandatory: true,
minver: 1,
webm: false,
"default": "und",
description: "Specifies the language of the tag specified, in the Matroska languages form."
},
0x45a3: {
name: "TagName",
level: 4,
type: "8",
mandatory: true,
minver: 1,
webm: false,
description: "The name of the Tag that is going to be stored."
},
0x67c8: {
name: "SimpleTag",
cppname: "TagSimple",
level: 3,
"recursive": "1",
type: "m",
mandatory: true,
multiple: true,
minver: 1,
webm: false,
description: "Contains general information about the target."
},
0x63c6: {
name: "TagAttachmentUID",
level: 4,
type: "u",
multiple: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x63c4: {
name: "TagChapterUID",
level: 4,
type: "u",
multiple: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x63c9: {
name: "TagEditionUID",
level: 4,
type: "u",
multiple: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x63c5: {
name: "TagTrackUID",
level: 4,
type: "u",
multiple: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x63ca: {
name: "TargetType",
cppname: "TagTargetType",
level: 4,
type: "s",
minver: 1,
webm: false,
"strong": "informational",
description: "An string that can be used to display the logical level of the target like \"ALBUM\", \"TRACK\", \"MOVIE\", \"CHAPTER\", etc (see TargetType)."
},
0x68ca: {
name: "TargetTypeValue",
cppname: "TagTargetTypeValue",
level: 4,
type: "u",
minver: 1,
webm: false,
"default": 50,
description: "A number to indicate the logical level of the target (see TargetType)."
},
0x63c0: {
name: "Targets",
cppname: "TagTargets",
level: 3,
type: "m",
mandatory: true,
minver: 1,
webm: false,
description: "Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment."
},
0x1254c367: {
name: "Tags",
level: 1,
type: "m",
multiple: true,
minver: 1,
webm: false,
description: "Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here."
},
0x450d: {
name: "ChapProcessPrivate",
cppname: "ChapterProcessPrivate",
level: 5,
type: "b",
minver: 1,
webm: false,
description: "Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the \"DVD level\" equivalent."
},
0x437e: {
name: "ChapCountry",
cppname: "ChapterCountry",
level: 5,
type: "s",
multiple: true,
minver: 1,
webm: false,
description: "The countries corresponding to the string, same 2 octets as in Internet domains."
},
0x437c: {
name: "ChapLanguage",
cppname: "ChapterLanguage",
level: 5,
type: "s",
mandatory: true,
multiple: true,
minver: 1,
webm: true,
"default": "eng",
description: "The languages corresponding to the string, in the bibliographic ISO-639-2 form."
},
0x8f: {
name: "ChapterTrack",
level: 4,
type: "m",
minver: 1,
webm: false,
description: "List of tracks on which the chapter applies. If this element is not present, all tracks apply"
},
0x63c3: {
name: "ChapterPhysicalEquiv",
level: 4,
type: "u",
minver: 1,
webm: false,
description: "Specify the physical equivalent of this ChapterAtom like \"DVD\" (60) or \"SIDE\" (50), see complete list of values."
},
0x6ebc: {
name: "ChapterSegmentEditionUID",
level: 4,
type: "u",
minver: 1,
webm: false,
range: "not 0",
description: "The EditionUID to play from the segment linked in ChapterSegmentUID."
},
0x6e67: {
name: "ChapterSegmentUID",
level: 4,
type: "b",
minver: 1,
webm: false,
range: ">0",
bytesize: 16,
description: "A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used."
},
0x73c4: {
name: "ChapterUID",
level: 4,
type: "u",
mandatory: true,
minver: 1,
webm: true,
range: "not 0",
description: "A unique ID to identify the Chapter."
},
0xb6: {
name: "ChapterAtom",
level: 3,
"recursive": "1",
type: "m",
mandatory: true,
multiple: true,
minver: 1,
webm: true,
description: "Contains the atom information to use as the chapter atom (apply to all tracks)."
},
0x45dd: {
name: "EditionFlagOrdered",
level: 3,
type: "u",
minver: 1,
webm: false,
"default": 0,
range: "0-1",
description: "Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)"
},
0x45db: {
name: "EditionFlagDefault",
level: 3,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
range: "0-1",
description: "If a flag is set (1) the edition should be used as the default one. (1 bit)"
},
0x45bd: {
name: "EditionFlagHidden",
level: 3,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
range: "0-1",
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)"
},
0x45bc: {
name: "EditionUID",
level: 3,
type: "u",
minver: 1,
webm: false,
range: "not 0",
description: "A unique ID to identify the edition. It's useful for tagging an edition."
},
0x45b9: {
name: "EditionEntry",
level: 2,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
webm: true,
description: "Contains all information about a segment edition."
},
0x1043a770: {
name: "Chapters",
level: 1,
type: "m",
minver: 1,
webm: true,
description: "A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation."
},
0x46ae: {
name: "FileUID",
level: 3,
type: "u",
mandatory: true,
minver: 1,
webm: false,
range: "not 0",
description: "Unique ID representing the file, as random as possible."
},
0x465c: {
name: "FileData",
level: 3,
type: "b",
mandatory: true,
minver: 1,
webm: false,
description: "The data of the file."
},
0x466e: {
name: "FileName",
level: 3,
type: "8",
mandatory: true,
minver: 1,
webm: false,
description: "Filename of the attached file."
},
0x467e: {
name: "FileDescription",
level: 3,
type: "8",
minver: 1,
webm: false,
description: "A human-friendly name for the attached file."
},
0x61a7: {
name: "AttachedFile",
level: 2,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
webm: false,
description: "An attached file."
},
0x1941a469: {
name: "Attachments",
level: 1,
type: "m",
minver: 1,
webm: false,
description: "Contain attached files."
},
0xeb: {
name: "CueRefCodecState",
level: 5,
type: "u",
webm: false,
"default": 0,
description: "The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry."
},
0x535f: {
name: "CueRefNumber",
level: 5,
type: "u",
webm: false,
"default": 1,
range: "not 0",
description: "Number of the referenced Block of Track X in the specified Cluster."
},
0xdb: {
name: "CueReference",
level: 4,
type: "m",
multiple: true,
minver: 2,
webm: false,
description: "The Clusters containing the required referenced Blocks."
},
0xea: {
name: "CueCodecState",
level: 4,
type: "u",
minver: 2,
webm: false,
"default": 0,
description: "The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry."
},
0xb2: {
name: "CueDuration",
level: 4,
type: "u",
mandatory: false,
minver: 4,
webm: false,
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."
},
0xf0: {
name: "CueRelativePosition",
level: 4,
type: "u",
mandatory: false,
minver: 4,
webm: false,
description: "The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.",
position: "clusterRelative"
},
0xf1: {
name: "CueClusterPosition",
level: 4,
type: "u",
mandatory: true,
minver: 1,
description: "The position of the Cluster containing the required Block.",
position: "segment",
},
0xf7: {
name: "CueTrack",
level: 4,
type: "u",
mandatory: true,
minver: 1,
range: "not 0",
description: "The track for which a position is given."
},
0xb7: {
name: "CueTrackPositions",
level: 3,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
description: "Contain positions for different tracks corresponding to the timestamp."
},
0xb3: {
name: "CueTime",
level: 3,
type: "u",
mandatory: true,
minver: 1,
description: "Absolute timestamp according to the segment time base."
},
0xbb: {
name: "CuePoint",
level: 2,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
description: "Contains all information relative to a seek point in the segment."
},
0x1c53bb6b: {
name: "Cues",
level: 1,
type: "m",
minver: 1,
description: "A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non \"live\" streams."
},
0x47e6: {
name: "ContentSigHashAlgo",
level: 6,
type: "u",
minver: 1,
webm: false,
"default": 0,
// "br": [ "", "" ],
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"
},
0x47e5: {
name: "ContentSigAlgo",
level: 6,
type: "u",
minver: 1,
webm: false,
"default": 0,
// "br": "",
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"
},
0x47e4: {
name: "ContentSigKeyID",
level: 6,
type: "b",
minver: 1,
webm: false,
description: "This is the ID of the private key the data was signed with."
},
0x47e3: {
name: "ContentSignature",
level: 6,
type: "b",
minver: 1,
webm: false,
description: "A cryptographic signature of the contents."
},
0x47e2: {
name: "ContentEncKeyID",
level: 6,
type: "b",
minver: 1,
webm: false,
description: "For public key algorithms this is the ID of the public key the the data was encrypted with."
},
0x47e1: {
name: "ContentEncAlgo",
level: 6,
type: "u",
minver: 1,
webm: false,
"default": 0,
// "br": "",
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"
},
0x6d80: {
name: "ContentEncodings",
level: 3,
type: "m",
minver: 1,
webm: false,
description: "Settings for several content encoding mechanisms like compression or encryption."
},
0xc4: {
name: "TrickMasterTrackSegmentUID",
level: 3,
type: "b",
divx: true,
bytesize: 16,
description: "DivX trick track extenstions"
},
0xc7: {
name: "TrickMasterTrackUID",
level: 3,
type: "u",
divx: true,
description: "DivX trick track extenstions"
},
0xc6: {
name: "TrickTrackFlag",
level: 3,
type: "u",
divx: true,
"default": 0,
description: "DivX trick track extenstions"
},
0xc1: {
name: "TrickTrackSegmentUID",
level: 3,
type: "b",
divx: true,
bytesize: 16,
description: "DivX trick track extenstions"
},
0xc0: {
name: "TrickTrackUID",
level: 3,
type: "u",
divx: true,
description: "DivX trick track extenstions"
},
0xed: {
name: "TrackJoinUID",
level: 5,
type: "u",
mandatory: true,
multiple: true,
minver: 3,
webm: false,
range: "not 0",
description: "The trackUID number of a track whose blocks are used to create this virtual track."
},
0xe9: {
name: "TrackJoinBlocks",
level: 4,
type: "m",
minver: 3,
webm: false,
description: "Contains the list of all tracks whose Blocks need to be combined to create this virtual track"
},
0xe6: {
name: "TrackPlaneType",
level: 6,
type: "u",
mandatory: true,
minver: 3,
webm: false,
description: "The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background)."
},
0xe5: {
name: "TrackPlaneUID",
level: 6,
type: "u",
mandatory: true,
minver: 3,
webm: false,
range: "not 0",
description: "The trackUID number of the track representing the plane."
},
0xe4: {
name: "TrackPlane",
level: 5,
type: "m",
mandatory: true,
multiple: true,
minver: 3,
webm: false,
description: "Contains a video plane track that need to be combined to create this 3D track"
},
0xe3: {
name: "TrackCombinePlanes",
level: 4,
type: "m",
minver: 3,
webm: false,
description: "Contains the list of all video plane tracks that need to be combined to create this 3D track"
},
0xe2: {
name: "TrackOperation",
level: 3,
type: "m",
minver: 3,
webm: false,
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."
},
0x7d7b: {
name: "ChannelPositions",
cppname: "AudioPosition",
level: 4,
type: "b",
webm: false,
description: "Table of horizontal angles for each successive channel, see appendix."
},
0x9f: {
name: "Channels",
cppname: "AudioChannels",
level: 4,
type: "u",
mandatory: true,
minver: 1,
"default": 1,
range: "not 0",
description: "Numbers of channels in the track."
},
0x78b5: {
name: "OutputSamplingFrequency",
cppname: "AudioOutputSamplingFreq",
level: 4,
type: "f",
minver: 1,
"default": "Sampling Frequency",
range: "> 0",
description: "Real output sampling frequency in Hz (used for SBR techniques)."
},
0xb5: {
name: "SamplingFrequency",
cppname: "AudioSamplingFreq",
level: 4,
type: "f",
mandatory: true,
minver: 1,
"default": 8000.0,
range: "> 0",
description: "Sampling frequency in Hz."
},
0xe1: {
name: "Audio",
cppname: "TrackAudio",
level: 3,
type: "m",
minver: 1,
description: "Audio settings."
},
0x2383e3: {
name: "FrameRate",
cppname: "VideoFrameRate",
level: 4,
type: "f",
range: "> 0",
"strong": "Informational",
description: "Number of frames per second. only."
},
0x2fb523: {
name: "GammaValue",
cppname: "VideoGamma",
level: 4,
type: "f",
webm: false,
range: "> 0",
description: "Gamma Value."
},
0x2eb524: {
name: "ColourSpace",
cppname: "VideoColourSpace",
level: 4,
type: "b",
minver: 1,
webm: false,
bytesize: 4,
description: "Same value as in AVI (32 bits)."
},
0x54b3: {
name: "AspectRatioType",
cppname: "VideoAspectRatio",
level: 4,
type: "u",
minver: 1,
"default": 0,
description: "Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed)."
},
0x54b2: {
name: "DisplayUnit",
cppname: "VideoDisplayUnit",
level: 4,
type: "u",
minver: 1,
"default": 0,
description: "How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio)."
},
0x54ba: {
name: "DisplayHeight",
cppname: "VideoDisplayHeight",
level: 4,
type: "u",
minver: 1,
"default": "PixelHeight",
range: "not 0",
description: "Height of the video frames to display. The default value is only valid when DisplayUnit is 0."
},
0x54b0: {
name: "DisplayWidth",
cppname: "VideoDisplayWidth",
level: 4,
type: "u",
minver: 1,
"default": "PixelWidth",
range: "not 0",
description: "Width of the video frames to display. The default value is only valid when DisplayUnit is 0."
},
0x54dd: {
name: "PixelCropRight",
cppname: "VideoPixelCropRight",
level: 4,
type: "u",
minver: 1,
"default": 0,
description: "The number of video pixels to remove on the right of the image."
},
0x54cc: {
name: "PixelCropLeft",
cppname: "VideoPixelCropLeft",
level: 4,
type: "u",
minver: 1,
"default": 0,
description: "The number of video pixels to remove on the left of the image."
},
0x54bb: {
name: "PixelCropTop",
cppname: "VideoPixelCropTop",
level: 4,
type: "u",
minver: 1,
"default": 0,
description: "The number of video pixels to remove at the top of the image."
},
0x54aa: {
name: "PixelCropBottom",
cppname: "VideoPixelCropBottom",
level: 4,
type: "u",
minver: 1,
"default": 0,
description: "The number of video pixels to remove at the bottom of the image (for HDTV content)."
},
0xba: {
name: "PixelHeight",
cppname: "VideoPixelHeight",
level: 4,
type: "u",
mandatory: true,
minver: 1,
range: "not 0",
description: "Height of the encoded video frames in pixels."
},
0xb0: {
name: "PixelWidth",
cppname: "VideoPixelWidth",
level: 4,
type: "u",
mandatory: true,
minver: 1,
range: "not 0",
description: "Width of the encoded video frames in pixels."
},
0x53b9: {
name: "OldStereoMode",
level: 4,
type: "u",
"maxver": "0",
webm: false,
divx: false,
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)."
},
0x53c0: {
name: "AlphaMode",
cppname: "VideoAlphaMode",
level: 4,
type: "u",
minver: 3,
webm: true,
"default": 0,
description: "Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data."
},
0x53b8: {
name: "StereoMode",
cppname: "VideoStereoMode",
level: 4,
type: "u",
minver: 3,
webm: true,
"default": 0,
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."
},
0x9a: {
name: "FlagInterlaced",
cppname: "VideoFlagInterlaced",
level: 4,
type: "u",
mandatory: true,
minver: 2,
webm: true,
"default": 0,
range: "0-1",
description: "Set if the video is interlaced. (1 bit)"
},
0xe0: {
name: "Video",
cppname: "TrackVideo",
level: 3,
type: "m",
minver: 1,
description: "Video settings."
},
0x66a5: {
name: "TrackTranslateTrackID",
level: 4,
type: "b",
mandatory: true,
minver: 1,
webm: false,
description: "The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used."
},
0x66bf: {
name: "TrackTranslateCodec",
level: 4,
type: "u",
mandatory: true,
minver: 1,
webm: false,
description: "The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)."
},
0x66fc: {
name: "TrackTranslateEditionUID",
level: 4,
type: "u",
multiple: true,
minver: 1,
webm: false,
description: "Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment."
},
0x56bb: {
name: "SeekPreRoll",
level: 3,
type: "u",
mandatory: true,
multiple: false,
"default": 0,
minver: 4,
webm: true,
description: "After a discontinuity, SeekPreRoll is the duration in nanoseconds of the data the decoder must decode before the decoded data is valid."
},
0x56aa: {
name: "CodecDelay",
level: 3,
type: "u",
multiple: false,
"default": 0,
minver: 4,
webm: true,
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."
},
0x6fab: {
name: "TrackOverlay",
level: 3,
type: "u",
multiple: true,
minver: 1,
webm: false,
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."
},
0xaa: {
name: "CodecDecodeAll",
level: 3,
type: "u",
mandatory: true,
minver: 2,
webm: false,
"default": 1,
range: "0-1",
description: "The codec can decode potentially damaged data (1 bit)."
},
0x26b240: {
name: "CodecDownloadURL",
level: 3,
type: "s",
multiple: true,
webm: false,
description: "A URL to download about the codec used."
},
0x3b4040: {
name: "CodecInfoURL",
level: 3,
type: "s",
multiple: true,
webm: false,
description: "A URL to find information about the codec used."
},
0x3a9697: {
name: "CodecSettings",
level: 3,
type: "8",
webm: false,
description: "A string describing the encoding setting used."
},
0x63a2: {
name: "CodecPrivate",
level: 3,
type: "b",
minver: 1,
description: "Private data only known to the codec."
},
0x22b59c: {
name: "Language",
cppname: "TrackLanguage",
level: 3,
type: "s",
minver: 1,
"default": "eng",
description: "Specifies the language of the track in the Matroska languages form."
},
0x536e: {
name: "Name",
cppname: "TrackName",
level: 3,
type: "8",
minver: 1,
description: "A human-readable track name."
},
0x55ee: {
name: "MaxBlockAdditionID",
level: 3,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
description: "The maximum value of BlockAdditions for this track."
},
0x537f: {
name: "TrackOffset",
level: 3,
type: "i",
webm: false,
"default": 0,
description: "A value to add to the Block's Timestamp. This can be used to adjust the playback offset of a track."
},
0x23314f: {
name: "TrackTimecodeScale",
level: 3,
type: "f",
mandatory: true,
minver: 1,
"maxver": "3",
webm: false,
"default": 1.0,
range: "> 0",
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)."
},
0x234e7a: {
name: "DefaultDecodedFieldDuration",
cppname: "TrackDefaultDecodedFieldDuration",
level: 3,
type: "u",
minver: 4,
range: "not 0",
description: "The period in nanoseconds (not scaled by TimcodeScale)\nbetween two successive fields at the output of the decoding process (see the notes)"
},
0x23e383: {
name: "DefaultDuration",
cppname: "TrackDefaultDuration",
level: 3,
type: "u",
minver: 1,
range: "not 0",
description: "Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block)."
},
0x6df8: {
name: "MaxCache",
cppname: "TrackMaxCache",
level: 3,
type: "u",
minver: 1,
webm: false,
description: "The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed."
},
0x6de7: {
name: "MinCache",
cppname: "TrackMinCache",
level: 3,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x9c: {
name: "FlagLacing",
cppname: "TrackFlagLacing",
level: 3,
type: "u",
mandatory: true,
minver: 1,
"default": 1,
range: "0-1",
description: "Set if the track may contain blocks using lacing. (1 bit)"
},
0x55aa: {
name: "FlagForced",
cppname: "TrackFlagForced",
level: 3,
type: "u",
mandatory: true,
minver: 1,
"default": 0,
range: "0-1",
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)"
},
0xb9: {
name: "FlagEnabled",
cppname: "TrackFlagEnabled",
level: 3,
type: "u",
mandatory: true,
minver: 2,
webm: true,
"default": 1,
range: "0-1",
description: "Set if the track is usable. (1 bit)"
},
0x73c5: {
name: "TrackUID",
level: 3,
type: "u",
mandatory: true,
minver: 1,
range: "not 0",
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."
},
0xd7: {
name: "TrackNumber",
level: 3,
type: "u",
mandatory: true,
minver: 1,
range: "not 0",
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)."
},
0xae: {
name: "TrackEntry",
level: 2,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
description: "Describes a track with all elements."
},
0x1654ae6b: {
name: "Tracks",
level: 1,
type: "m",
multiple: true,
minver: 1,
description: "A top-level block of information with many tracks described."
},
0xaf: {
name: "EncryptedBlock",
level: 2,
type: "b",
multiple: true,
webm: false,
description: "Similar to EncryptedBlock Structure)"
},
0xca: {
name: "ReferenceTimeCode",
level: 4,
type: "u",
multiple: false,
mandatory: true,
minver: 0,
webm: false,
divx: true,
description: "DivX trick track extenstions"
},
0xc9: {
name: "ReferenceOffset",
level: 4,
type: "u",
multiple: false,
mandatory: true,
minver: 0,
webm: false,
divx: true,
description: "DivX trick track extenstions"
},
0xc8: {
name: "ReferenceFrame",
level: 3,
type: "m",
multiple: false,
minver: 0,
webm: false,
divx: true,
description: "DivX trick track extenstions"
},
0xcf: {
name: "SliceDuration",
level: 5,
type: "u",
"default": 0,
description: "The (scaled) duration to apply to the element."
},
0xce: {
name: "Delay",
cppname: "SliceDelay",
level: 5,
type: "u",
"default": 0,
description: "The (scaled) delay to apply to the element."
},
0xcb: {
name: "BlockAdditionID",
cppname: "SliceBlockAddID",
level: 5,
type: "u",
"default": 0,
description: "The ID of the BlockAdditional element (0 is the main Block)."
},
0xcd: {
name: "FrameNumber",
cppname: "SliceFrameNumber",
level: 5,
type: "u",
"default": 0,
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)."
},
0xcc: {
name: "LaceNumber",
cppname: "SliceLaceNumber",
level: 5,
type: "u",
minver: 1,
"default": 0,
divx: false,
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."
},
0xe8: {
name: "TimeSlice",
level: 4,
type: "m",
multiple: true,
minver: 1,
divx: false,
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."
},
0x8e: {
name: "Slices",
level: 3,
type: "m",
minver: 1,
divx: false,
description: "Contains slices description."
},
0x75a2: {
name: "DiscardPadding",
level: 3,
type: "i",
minver: 4,
webm: true,
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."
},
0xa4: {
name: "CodecState",
level: 3,
type: "b",
minver: 2,
webm: false,
description: "The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry."
},
0xfd: {
name: "ReferenceVirtual",
level: 3,
type: "i",
webm: false,
description: "Relative position of the data that should be in position of the virtual block."
},
0xfb: {
name: "ReferenceBlock",
level: 3,
type: "i",
multiple: true,
minver: 1,
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."
},
0xfa: {
name: "ReferencePriority",
cppname: "FlagReferenced",
level: 3,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 0,
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."
},
0x9b: {
name: "BlockDuration",
level: 3,
type: "u",
minver: 1,
"default": "TrackDuration",
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."
},
0xa5: {
name: "BlockAdditional",
level: 5,
type: "b",
mandatory: true,
minver: 1,
webm: false,
description: "Interpreted by the codec as it wishes (using the BlockAddID)."
},
0xee: {
name: "BlockAddID",
level: 5,
type: "u",
mandatory: true,
minver: 1,
webm: false,
"default": 1,
range: "not 0",
description: "An ID to identify the BlockAdditional level."
},
0xa6: {
name: "BlockMore",
level: 4,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
webm: false,
description: "Contain the BlockAdditional and some parameters."
},
0x75a1: {
name: "BlockAdditions",
level: 3,
type: "m",
minver: 1,
webm: false,
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."
},
0xa2: {
name: "BlockVirtual",
level: 3,
type: "b",
webm: false,
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)"
},
0xa1: {
name: "Block",
level: 3,
type: "b",
mandatory: true,
minver: 1,
description: "Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)"
},
0xa0: {
name: "BlockGroup",
level: 2,
type: "m",
multiple: true,
minver: 1,
description: "Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock."
},
0xa3: {
name: "SimpleBlock",
level: 2,
type: "b",
multiple: true,
minver: 2,
webm: true,
divx: true,
description: "Similar to SimpleBlock Structure"
},
0xab: {
name: "PrevSize",
cppname: "ClusterPrevSize",
level: 2,
type: "u",
minver: 1,
description: "Size of the previous Cluster, in octets. Can be useful for backward playing.",
position: "prevCluster"
},
0xa7: {
name: "Position",
cppname: "ClusterPosition",
level: 2,
type: "u",
minver: 1,
webm: false,
description: "The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.",
position: "segment"
},
0x58d7: {
name: "SilentTrackNumber",
cppname: "ClusterSilentTrackNumber",
level: 3,
type: "u",
multiple: true,
minver: 1,
webm: false,
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."
},
0xe7: {
name: "Timecode",
cppname: "ClusterTimecode",
level: 2,
type: "u",
mandatory: true,
minver: 1,
description: "Absolute timestamp of the cluster (based on TimecodeScale)."
},
0x1f43b675: {
name: "Cluster",
level: 1,
type: "m",
multiple: true,
minver: 1,
description: "The lower level element containing the (monolithic) Block structure."
},
0x4d80: {
name: "MuxingApp",
level: 2,
type: "8",
mandatory: true,
minver: 1,
description: "Muxing application or library (\"libmatroska-0.4.3\")."
},
0x7ba9: {
name: "Title",
level: 2,
type: "8",
minver: 1,
webm: false,
description: "General name of the segment."
},
0x2ad7b2: {
name: "TimecodeScaleDenominator",
level: 2,
type: "u",
mandatory: true,
minver: 4,
"default": "1000000000",
description: "Timestamp scale numerator, see TimecodeScale."
},
0x2ad7b1: {
name: "TimecodeScale",
level: 2,
type: "u",
mandatory: true,
minver: 1,
"default": "1000000",
description: "Timestamp scale in nanoseconds (1.000.000 means all timestamps in the segment are expressed in milliseconds)."
},
0x69a5: {
name: "ChapterTranslateID",
level: 3,
type: "b",
mandatory: true,
minver: 1,
webm: false,
description: "The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used."
},
0x69bf: {
name: "ChapterTranslateCodec",
level: 3,
type: "u",
mandatory: true,
minver: 1,
webm: false,
description: "The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)."
},
0x69fc: {
name: "ChapterTranslateEditionUID",
level: 3,
type: "u",
multiple: true,
minver: 1,
webm: false,
description: "Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment."
},
0x3e83bb: {
name: "NextFilename",
level: 2,
type: "8",
minver: 1,
webm: false,
description: "An escaped filename corresponding to the next segment."
},
0x3eb923: {
name: "NextUID",
level: 2,
type: "b",
minver: 1,
webm: false,
bytesize: 16,
description: "A unique ID to identify the next chained segment (128 bits)."
},
0x3c83ab: {
name: "PrevFilename",
level: 2,
type: "8",
minver: 1,
webm: false,
description: "An escaped filename corresponding to the previous segment."
},
0x3cb923: {
name: "PrevUID",
level: 2,
type: "b",
minver: 1,
webm: false,
bytesize: 16,
description: "A unique ID to identify the previous chained segment (128 bits)."
},
0x73a4: {
name: "SegmentUID",
level: 2,
type: "b",
minver: 1,
webm: false,
range: "not 0",
bytesize: 16,
description: "A randomly generated unique ID to identify the current segment between many others (128 bits)."
},
0x1549a966: {
name: "Info",
level: 1,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
description: "Contains miscellaneous general information and statistics on the file."
},
0x53ac: {
name: "SeekPosition",
level: 3,
type: "u",
mandatory: true,
minver: 1,
description: "The position of the element in the segment in octets (0 = first level 1 element).",
position: "segment"
},
0x53ab: {
name: "SeekID",
level: 3,
type: "b",
mandatory: true,
minver: 1,
description: "The binary ID corresponding to the element name.",
type2: "ebmlID"
},
0x4dbb: {
name: "Seek",
cppname: "SeekPoint",
level: 2,
type: "m",
mandatory: true,
multiple: true,
minver: 1,
description: "Contains a single seek entry to an EBML element."
},
0x114d9b74: {
name: "SeekHead",
cppname: "SeekHeader",
level: 1,
type: "m",
multiple: true,
minver: 1,
description: "Contains the position of other level 1 elements."
},
0x7e7b: {
name: "SignatureElementList",
level: 2,
type: "m",
multiple: true,
webm: false,
i: "Cluster|Block|BlockAdditional",
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."
},
0x7e5b: {
name: "SignatureElements",
level: 1,
type: "m",
webm: false,
description: "Contains elements that will be used to compute the signature."
},
0x7eb5: {
name: "Signature",
level: 1,
type: "b",
webm: false,
description: "The signature of the data (until a new."
},
0x7ea5: {
name: "SignaturePublicKey",
level: 1,
type: "b",
webm: false,
description: "The public key to use with the algorithm (in the case of a PKI-based signature)."
},
0x7e9a: {
name: "SignatureHash",
level: 1,
type: "u",
webm: false,
description: "Hash algorithm used (1=SHA1-160, 2=MD5)."
},
0x7e8a: {
name: "SignatureAlgo",
level: 1,
type: "u",
webm: false,
description: "Signature algorithm used (1=RSA, 2=elliptic)."
},
0x1b538667: {
name: "SignatureSlot",
level: -1,
type: "m",
multiple: true,
webm: false,
description: "Contain signature of some (coming) elements in the stream."
},
0xbf: {
name: "CRC-32",
level: -1,
type: "b",
minver: 1,
webm: false,
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",
crc: true
},
0xec: {
name: "Void",
level: -1,
type: "b",
minver: 1,
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."
},
0x42f3: {
name: "EBMLMaxSizeLength",
level: 1,
type: "u",
mandatory: true,
"default": 8,
minver: 1,
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 invalid."
},
0x42f2: {
name: "EBMLMaxIDLength",
level: 1,
type: "u",
mandatory: true,
"default": 4,
minver: 1,
description: "The maximum length of the IDs you'll find in this file (4 or less in Matroska)."
},
0x42f7: {
name: "EBMLReadVersion",
level: 1,
type: "u",
mandatory: true,
"default": 1,
minver: 1,
description: "The minimum EBML version a parser has to support to read this file."
},
0x1a45dfa3: {
name: "EBML",
level: "0",
type: "m",
mandatory: true,
multiple: true,
minver: 1,
description: "Set the EBML characteristics of the data to follow. Each EBML document has to start with this."
},
0x55b0: {
name: "Colour",
level: "4",
type: "m",
mandatory: true,
multiple: true,
description: "Settings describing the colour format."
},
0x55b1: {
name: "MatrixCoefficients",
level: "5",
type: "u",
mandatory: true,
multiple: true,
description: "The Matrix Coefficients of the video used to derive luma and chroma values from red, green, and blue color primaries. For clarity, the value and meanings for MatrixCoefficients are adopted from Table 4 of ISO/IEC 23001-8:2016 or ITU-T H.273."
},
0x55b9: {
name: "Range",
level: "5",
type: "u",
mandatory: true,
multiple: true,
description: "Clipping of the color ranges."
},
0x55ba: {
name: "TransferCharacteristics",
level: "5",
type: "u",
mandatory: true,
multiple: true,
description: "The transfer characteristics of the video."
},
0x55bb: {
name: "Primaries",
level: "5",
type: "u",
mandatory: true,
multiple: true,
description: "The colour primaries of the video. For clarity, the value and meanings for Primaries are adopted from Table 2 of ISO/IEC 23091-4 or ITU-T H.273."
},
};
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/index.js":
/*!**********************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/index.js ***!
\**********************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tools = exports.Reader = exports.Encoder = exports.Decoder = void 0;
__exportStar(__webpack_require__(/*! ./EBML */ "./node_modules/webm-duration-fix/lib/ebml/EBML.js"), exports);
var EBMLDecoder_1 = __webpack_require__(/*! ./EBMLDecoder */ "./node_modules/webm-duration-fix/lib/ebml/EBMLDecoder.js");
exports.Decoder = EBMLDecoder_1.default;
var EBMLEncoder_1 = __webpack_require__(/*! ./EBMLEncoder */ "./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js");
exports.Encoder = EBMLEncoder_1.default;
var EBMLReader_1 = __webpack_require__(/*! ./EBMLReader */ "./node_modules/webm-duration-fix/lib/ebml/EBMLReader.js");
exports.Reader = EBMLReader_1.default;
var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js");
exports.tools = tools;
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/tools-ebml.js":
/*!***************************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/tools-ebml.js ***!
\***************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
var tools_1 = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js");
var Tools = /** @class */ (function () {
function Tools() {
}
/**
* read variable length integer per
* https://www.matroska.org/technical/specs/index.html#EBML_ex
* @static
* @param {Buffer} buffer containing input
* @param {Number} [start=0] position in buffer
* @returns {{length: Number, value: number}} value / length object
*/
Tools.readVint = function (buffer, start) {
if (start === void 0) { start = 0; }
var length = 8 - Math.floor(Math.log2(buffer[start]));
if (length > 8) {
var number = Tools.readHexString(buffer, start, start + length);
throw new Error("Unrepresentable length: ".concat(length, " ").concat(number));
}
if (start + length > buffer.length) {
return null;
}
var value = buffer[start] & ((1 << (8 - length)) - 1);
for (var i = 1; i < length; i += 1) {
if (i === 7) {
if (value >= Math.pow(2, 8) && buffer[start + 7] > 0) {
return { length: length, value: -1 };
}
}
value *= Math.pow(2, 8);
value += buffer[start + i];
}
return { length: length, value: value };
};
/**
* write variable length integer
* @static
* @param {Number} value to store into buffer
* @returns {Buffer} containing the value
*/
Tools.writeVint = function (value) {
if (value < 0 || value > Math.pow(2, 53)) {
throw new Error("Unrepresentable value: ".concat(value));
}
var length = 1;
for (length = 1; length <= 8; length += 1) {
if (value < Math.pow(2, (7 * length)) - 1) {
break;
}
}
var buffer = tools_1.Buffer.alloc(length);
var val = value;
for (var i = 1; i <= length; i += 1) {
var b = val & 0xff;
buffer[length - i] = b;
val -= b;
val /= Math.pow(2, 8);
}
buffer[0] |= 1 << (8 - length);
return buffer;
};
/**
* *
* concatenate two arrays of bytes
* @static
* @param {Buffer} a1 First array
* @param {Buffer} a2 Second array
* @returns {Buffer} concatenated arrays
*/
Tools.concatenate = function (a1, a2) {
// both null or undefined
if (!a1 && !a2) {
return tools_1.Buffer.from([]);
}
if (!a1 || a1.byteLength === 0) {
return a2;
}
if (!a2 || a2.byteLength === 0) {
return a1;
}
return tools_1.Buffer.from(__spreadArray(__spreadArray([], a1, true), a2, true));
};
/**
* get a hex text string from Buff[start,end)
* @param {Buffer} buff from which to read the string
* @param {Number} [start=0] starting point (default 0)
* @param {Number} [end=buff.byteLength] ending point (default the whole buffer)
* @returns {string} the hex string
*/
Tools.readHexString = function (buff, start, end) {
if (start === void 0) { start = 0; }
if (end === void 0) { end = buff.byteLength; }
return Array.from(buff.slice(start, end))
.map(function (q) { return Number(q).toString(16); })
.reduce(function (acc, current) { return "".concat(acc).concat(current.padStart(2, '0')); }, '');
};
/**
* tries to read out a UTF-8 encoded string
* @param {Buffer} buff the buffer to attempt to read from
* @return {string|null} the decoded text, or null if unable to
*/
Tools.readUtf8 = function (buff) {
try {
return tools_1.Buffer.from(buff).toString('utf8');
}
catch (exception) {
return null;
}
};
/**
* get an unsigned number from a buffer
* @param {Buffer} buff from which to read variable-length unsigned number
* @returns {number|string} result (in hex for lengths > 6)
*/
Tools.readUnsigned = function (buff) {
var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);
switch (buff.byteLength) {
case 1:
return b.getUint8(0);
case 2:
return b.getUint16(0);
case 4:
return b.getUint32(0);
default:
break;
}
if (buff.byteLength <= 6) {
return buff.reduce(function (acc, current) { return acc * 256 + current; }, 0);
}
return Tools.readHexString(buff, 0, buff.byteLength);
};
/**
* get an signed number from a buffer
* @static
* @param {Buffer} buff from which to read variable-length signed number
* @returns {number} result
*/
Tools.readSigned = function (buff) {
var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);
switch (buff.byteLength) {
case 1:
return b.getInt8(0);
case 2:
return b.getInt16(0);
case 4:
return b.getInt32(0);
default:
return NaN;
}
};
/**
* get an floating-point number from a buffer
* @static
* @param {Buffer} buff from which to read variable-length floating-point number
* @returns {number} result
*/
Tools.readFloat = function (buff) {
var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);
switch (buff.byteLength) {
case 4:
return b.getFloat32(0);
case 8:
return b.getFloat64(0);
default:
return NaN;
}
};
/**
* get a date from a buffer
* @static
* @param {Buffer} buff from which to read the date
* @return {Date} result
*/
Tools.readDate = function (buff) {
var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);
switch (buff.byteLength) {
case 1:
return new Date(b.getUint8(0));
case 2:
return new Date(b.getUint16(0));
case 4:
return new Date(b.getUint32(0));
case 8:
return new Date(Number.parseInt(Tools.readHexString(buff), 16));
default:
return new Date(0);
}
};
/**
* Reads the data from a tag
* @static
* @param {TagData} tagObj The tag object to be read
* @param {Buffer} data Data to be transformed
* @return {Tag} result
*/
Tools.readDataFromTag = function (tagObj, data) {
var type = tagObj.type, name = tagObj.name;
var track = tagObj.track;
var discardable = tagObj.discardable || false;
var keyframe = tagObj.keyframe || false;
var payload = null;
var value;
switch (type) {
case 'u':
value = Tools.readUnsigned(data);
break;
case 'f':
value = Tools.readFloat(data);
break;
case 'i':
value = Tools.readSigned(data);
break;
case 's':
value = String.fromCharCode.apply(String, data);
break;
case '8':
value = Tools.readUtf8(data);
break;
case 'd':
value = Tools.readDate(data);
break;
default:
break;
}
if (name === 'SimpleBlock' || name === 'Block') {
var p = 0;
var _a = Tools.readVint(data, p), length_1 = _a.length, trak = _a.value;
p += length_1;
track = trak;
value = Tools.readSigned(data.subarray(p, p + 2));
p += 2;
if (name === 'SimpleBlock') {
keyframe = Boolean(data[length_1 + 2] & 0x80);
discardable = Boolean(data[length_1 + 2] & 0x01);
}
p += 1;
payload = data.subarray(p);
}
return __assign(__assign({}, tagObj), { data: data, discardable: discardable, keyframe: keyframe, payload: payload, track: track, value: value });
};
return Tools;
}());
exports["default"] = Tools;
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/ebml/tools.js":
/*!**********************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/ebml/tools.js ***!
\**********************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.convertEBMLDateToJSDate = exports.createFloatBuffer = exports.createIntBuffer = exports.createUIntBuffer = exports.encodeValueToBuffer = exports.concat = exports.putRefinedMetaData = exports.extractElement = exports.removeElement = exports.makeMetadataSeekable = exports.createRIFFChunk = exports.VP8BitStreamToRiffWebPBuffer = exports.WebPBlockFilter = exports.encodeTag = exports.readBlock = exports.ebmlBlock = exports.writeVint = exports.readVint = exports.Buffer = void 0;
/// <reference types="node"/>
var int64_buffer_1 = __webpack_require__(/*! int64-buffer */ "./node_modules/int64-buffer/int64-buffer.js");
var EBMLEncoder_1 = __webpack_require__(/*! ./EBMLEncoder */ "./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js");
var _Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js");
var tools_ebml_1 = __webpack_require__(/*! ./tools-ebml */ "./node_modules/webm-duration-fix/lib/ebml/tools-ebml.js");
var _block = __webpack_require__(/*! ebml-block */ "./node_modules/ebml-block/index.js");
exports.Buffer = _Buffer.Buffer;
exports.readVint = tools_ebml_1.default.readVint;
exports.writeVint = tools_ebml_1.default.writeVint;
exports.ebmlBlock = _block;
function readBlock(buf) {
return (0, exports.ebmlBlock)(new exports.Buffer(buf));
}
exports.readBlock = readBlock;
/**
* @param end - if end === false then length is unknown
*/
function encodeTag(tagId, tagData, unknownSize) {
if (unknownSize === void 0) { unknownSize = false; }
return concat([
tagId,
unknownSize ?
new exports.Buffer('01ffffffffffffff', 'hex') :
(0, exports.writeVint)(tagData.length),
tagData
]);
}
exports.encodeTag = encodeTag;
/**
* WebP ファイルにできる SimpleBlock の パスフィルタ
*/
function WebPBlockFilter(elms) {
return elms.reduce(function (lst, elm) {
if (elm.type !== "b") {
return lst;
}
if (elm.name !== "SimpleBlock") {
return lst;
}
var o = (0, exports.ebmlBlock)(elm.data);
var hasWebP = o.frames.some(function (frame) {
// https://tools.ietf.org/html/rfc6386#section-19.1
var startcode = frame.slice(3, 6).toString("hex");
return startcode === "9d012a";
});
if (!hasWebP) {
return lst;
}
return lst.concat(elm);
}, []);
}
exports.WebPBlockFilter = WebPBlockFilter;
/**
* @param frame - VP8 BitStream のうち startcode をもつ frame
* @return - WebP ファイルの ArrayBuffer
*/
function VP8BitStreamToRiffWebPBuffer(frame) {
var VP8Chunk = createRIFFChunk("VP8 ", frame);
var WebPChunk = concat([
new exports.Buffer("WEBP", "ascii"),
VP8Chunk
]);
return createRIFFChunk("RIFF", WebPChunk);
}
exports.VP8BitStreamToRiffWebPBuffer = VP8BitStreamToRiffWebPBuffer;
/**
* RIFF データチャンクを作る
*/
function createRIFFChunk(FourCC, chunk) {
var chunkSize = new exports.Buffer(4);
chunkSize.writeUInt32LE(chunk.byteLength, 0);
return concat([
new exports.Buffer(FourCC.substr(0, 4), "ascii"),
chunkSize,
chunk,
new exports.Buffer(chunk.byteLength % 2 === 0 ? 0 : 1) // padding
]);
}
exports.createRIFFChunk = createRIFFChunk;
/* Original Metadata
m 0 EBML
u 1 EBMLVersion 1
u 1 EBMLReadVersion 1
u 1 EBMLMaxIDLength 4
u 1 EBMLMaxSizeLength 8
s 1 DocType webm
u 1 DocTypeVersion 4
u 1 DocTypeReadVersion 2
m 0 Segment
m 1 Info segmentContentStartPos, all CueClusterPositions provided in info.cues will be relative to here and will need adjusted
u 2 TimecodeScale 1000000
8 2 MuxingApp Chrome
8 2 WritingApp Chrome
m 1 Tracks tracksStartPos
m 2 TrackEntry
u 3 TrackNumber 1
u 3 TrackUID 31790271978391090
u 3 TrackType 2
s 3 CodecID A_OPUS
b 3 CodecPrivate <Buffer 19>
m 3 Audio
f 4 SamplingFrequency 48000
u 4 Channels 1
m 2 TrackEntry
u 3 TrackNumber 2
u 3 TrackUID 24051277436254136
u 3 TrackType 1
s 3 CodecID V_VP8
m 3 Video
u 4 PixelWidth 1024
u 4 PixelHeight 576
m 1 Cluster clusterStartPos
u 2 Timecode 0
b 2 SimpleBlock track:2 timecode:0 keyframe:true invisible:false discardable:false lacing:1
*/
/* Desired Metadata
m 0 EBML
u 1 EBMLVersion 1
u 1 EBMLReadVersion 1
u 1 EBMLMaxIDLength 4
u 1 EBMLMaxSizeLength 8
s 1 DocType webm
u 1 DocTypeVersion 4
u 1 DocTypeReadVersion 2
m 0 Segment
m 1 SeekHead -> This is SeekPosition 0, so all SeekPositions can be calculated as (bytePos - segmentContentStartPos), which is 44 in this case
m 2 Seek
b 3 SeekID -> Buffer([0x15, 0x49, 0xA9, 0x66]) Info
u 3 SeekPosition -> infoStartPos =
m 2 Seek
b 3 SeekID -> Buffer([0x16, 0x54, 0xAE, 0x6B]) Tracks
u 3 SeekPosition { tracksStartPos }
m 2 Seek
b 3 SeekID -> Buffer([0x1C, 0x53, 0xBB, 0x6B]) Cues
u 3 SeekPosition { cuesStartPos }
m 1 Info
f 2 Duration 32480 -> overwrite, or insert if it doesn't exist
u 2 TimecodeScale 1000000
8 2 MuxingApp Chrome
8 2 WritingApp Chrome
m 1 Tracks
m 2 TrackEntry
u 3 TrackNumber 1
u 3 TrackUID 31790271978391090
u 3 TrackType 2
s 3 CodecID A_OPUS
b 3 CodecPrivate <Buffer 19>
m 3 Audio
f 4 SamplingFrequency 48000
u 4 Channels 1
m 2 TrackEntry
u 3 TrackNumber 2
u 3 TrackUID 24051277436254136
u 3 TrackType 1
s 3 CodecID V_VP8
m 3 Video
u 4 PixelWidth 1024
u 4 PixelHeight 576
m 1 Cues -> cuesStartPos
m 2 CuePoint
u 3 CueTime 0
m 3 CueTrackPositions
u 4 CueTrack 1
u 4 CueClusterPosition 3911
m 2 CuePoint
u 3 CueTime 600
m 3 CueTrackPositions
u 4 CueTrack 1
u 4 CueClusterPosition 3911
m 1 Cluster
u 2 Timecode 0
b 2 SimpleBlock track:2 timecode:0 keyframe:true invisible:false discardable:false lacing:1
*/
/**
* convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues
* @param originalMetadata - orginal metadata (everything before the clusters start) from media recorder
* @param duration - Duration (TimecodeScale)
* @param cues - cue points for clusters
*/
function makeMetadataSeekable(originalMetadata, duration, cuesInfo) {
// extract the header, we can reuse this as-is
var header = extractElement("EBML", originalMetadata);
var headerSize = encodedSizeOfEbml(header);
//console.error("Header size: " + headerSize);
//printElementIds(header);
// After the header comes the Segment open tag, which in this implementation is always 12 bytes (4 byte id, 8 byte 'unknown length')
// After that the segment content starts. All SeekPositions and CueClusterPosition must be relative to segmentContentStartPos
var segmentContentStartPos = headerSize + 12;
//console.error("segmentContentStartPos: " + segmentContentStartPos);
// find the original metadata size, and adjust it for header size and Segment start element so we can keep all positions relative to segmentContentStartPos
var originalMetadataSize = originalMetadata[originalMetadata.length - 1].dataEnd - segmentContentStartPos;
//console.error("Original Metadata size: " + originalMetadataSize);
//printElementIds(originalMetadata);
// extract the segment info, remove the potentially existing Duration element, and add our own one.
var info = extractElement("Info", originalMetadata);
removeElement("Duration", info);
info.splice(1, 0, { name: "Duration", type: "f", data: createFloatBuffer(duration, 8) });
var infoSize = encodedSizeOfEbml(info);
//console.error("Info size: " + infoSize);
//printElementIds(info);
// extract the track info, we can re-use this as is
var tracks = extractElement("Tracks", originalMetadata);
var tracksSize = encodedSizeOfEbml(tracks);
//console.error("Tracks size: " + tracksSize);
//printElementIds(tracks);
var seekHeadSize = 47; // Initial best guess, but could be slightly larger if the Cues element is huge.
var seekHead = [];
var cuesSize = 5 + cuesInfo.length * 15; // very rough initial approximation, depends a lot on file size and number of CuePoints
var cues = [];
var lastSizeDifference = -1; //
// The size of SeekHead and Cues elements depends on how many bytes the offsets values can be encoded in.
// The actual offsets in CueClusterPosition depend on the final size of the SeekHead and Cues elements
// We need to iteratively converge to a stable solution.
var maxIterations = 10;
var _loop_1 = function (i) {
// SeekHead starts at 0
var infoStart = seekHeadSize; // Info comes directly after SeekHead
var tracksStart = infoStart + infoSize; // Tracks comes directly after Info
var cuesStart = tracksStart + tracksSize; // Cues starts directly after
var newMetadataSize = cuesStart + cuesSize; // total size of metadata
// This is the offset all CueClusterPositions should be adjusted by due to the metadata size changing.
var sizeDifference = newMetadataSize - originalMetadataSize;
// console.error(`infoStart: ${infoStart}, infoSize: ${infoSize}`);
// console.error(`tracksStart: ${tracksStart}, tracksSize: ${tracksSize}`);
// console.error(`cuesStart: ${cuesStart}, cuesSize: ${cuesSize}`);
// console.error(`originalMetadataSize: ${originalMetadataSize}, newMetadataSize: ${newMetadataSize}, sizeDifference: ${sizeDifference}`);
// create the SeekHead element
seekHead = [];
seekHead.push({ name: "SeekHead", type: "m", isEnd: false });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); // Info
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(infoStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); // Tracks
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tracksStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); // Cues
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(cuesStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "SeekHead", type: "m", isEnd: true });
seekHeadSize = encodedSizeOfEbml(seekHead);
//console.error("SeekHead size: " + seekHeadSize);
//printElementIds(seekHead);
// create the Cues element
cues = [];
cues.push({ name: "Cues", type: "m", isEnd: false });
cuesInfo.forEach(function (_a) {
var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;
cues.push({ name: "CuePoint", type: "m", isEnd: false });
cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: false });
cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) });
//console.error(`CueClusterPosition: ${CueClusterPosition}, Corrected to: ${CueClusterPosition - segmentContentStartPos} , offset by ${sizeDifference} to become ${(CueClusterPosition - segmentContentStartPos) + sizeDifference - segmentContentStartPos}`);
// 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.
CueClusterPosition -= segmentContentStartPos;
// We also need to adjust to take into account the change in metadata size from when EBMLReader read the original metadata.
CueClusterPosition += sizeDifference;
cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: true });
cues.push({ name: "CuePoint", type: "m", isEnd: true });
});
cues.push({ name: "Cues", type: "m", isEnd: true });
cuesSize = encodedSizeOfEbml(cues);
//console.error("Cues size: " + cuesSize);
//console.error("Cue count: " + cuesInfo.length);
//printElementIds(cues);
// If the new MetadataSize is not the same as the previous iteration, we need to run once more.
if (lastSizeDifference !== sizeDifference) {
lastSizeDifference = sizeDifference;
if (i === maxIterations - 1) {
throw new Error("Failed to converge to a stable metadata size");
}
}
else {
return "break";
}
};
for (var i = 0; i < maxIterations; i++) {
var state_1 = _loop_1(i);
if (state_1 === "break")
break;
}
var finalMetadata = [].concat.apply([], [
header,
{ name: "Segment", type: "m", isEnd: false, unknownSize: true },
seekHead,
info,
tracks,
cues
]);
var result = new EBMLEncoder_1.default().encode(finalMetadata);
//printElementIds(finalMetadata);
//console.error(`Final metadata buffer size: ${result.byteLength}`);
//console.error(`Final metadata buffer size without header and segment: ${result.byteLength-segmentContentStartPos}`);
return result;
}
exports.makeMetadataSeekable = makeMetadataSeekable;
/**
* print all element id names in a list
* @param metadata - array of EBML elements to print
*
export function printElementIds(metadata: EBML.EBMLElementBuffer[]) {
let result: EBML.EBMLElementBuffer[] = [];
let start: number = -1;
for (let i = 0; i < metadata.length; i++) {
console.error("\t id: " + metadata[i].name);
}
}
*/
/**
* remove all occurances of an EBML element from an array of elements
* If it's a MasterElement you will also remove the content. (everything between start and end)
* @param idName - name of the EBML Element to remove.
* @param metadata - array of EBML elements to search
*/
function removeElement(idName, metadata) {
var result = [];
var start = -1;
for (var i = 0; i < metadata.length; i++) {
var element = metadata[i];
if (element.name === idName) {
// if it's a Master element, extract the start and end element, and everything in between
if (element.type === "m") {
if (!element.isEnd) {
start = i;
}
else {
// we've reached the end, extract the whole thing
if (start == -1)
throw new Error("Detected ".concat(idName, " closing element before finding the start"));
metadata.splice(start, i - start + 1);
return;
}
}
else {
// not a Master element, so we've found what we're looking for.
metadata.splice(i, 1);
return;
}
}
}
}
exports.removeElement = removeElement;
/**
* extract the first occurance of an EBML tag from a flattened array of EBML data.
* If it's a MasterElement you will also get the content. (everything between start and end)
* @param idName - name of the EBML Element to extract.
* @param metadata - array of EBML elements to search
*/
function extractElement(idName, metadata) {
var result = [];
var start = -1;
for (var i = 0; i < metadata.length; i++) {
var element = metadata[i];
if (element.name === idName) {
// if it's a Master element, extract the start and end element, and everything in between
if (element.type === "m") {
if (!element.isEnd) {
start = i;
}
else {
// we've reached the end, extract the whole thing
if (start == -1)
throw new Error("Detected ".concat(idName, " closing element before finding the start"));
result = metadata.slice(start, i + 1);
break;
}
}
else {
// not a Master element, so we've found what we're looking for.
result.push(metadata[i]);
break;
}
}
}
return result;
}
exports.extractElement = extractElement;
/**
* @deprecated
* metadata に対して duration と seekhead を追加した metadata を返す
* @param metadata - 変更前の webm における ファイル先頭から 最初の Cluster 要素までの 要素
* @param duration - Duration (TimecodeScale)
* @param cues - cue points for clusters
* @deprecated @param clusterPtrs - 変更前の webm における SeekHead に追加する Cluster 要素 への start pointer
* @deprecated @param cueInfos - please use cues.
*/
function putRefinedMetaData(metadata, info) {
if (Array.isArray(info.cueInfos) && !Array.isArray(info.cues)) {
console.warn("putRefinedMetaData: info.cueInfos property is deprecated. please use info.cues");
info.cues = info.cueInfos;
}
var ebml = [];
var payload = [];
for (var i_1 = 0; i_1 < metadata.length; i_1++) {
var elm = metadata[i_1];
if (elm.type === "m" && elm.name === "Segment") {
ebml = metadata.slice(0, i_1);
payload = metadata.slice(i_1);
if (elm.unknownSize) {
payload.shift(); // remove segment tag
break;
}
throw new Error("this metadata is not streaming webm file");
}
}
// *0 *4 *5 *36 *40 *48=segmentOffset *185=originalPayloadOffsetEnd
// | | | | | | |
// [EBML][size]....[Segment][size][Info][size][Duration][size]...[Cluster]
// | | |^inf | |
// | +segmentSiz(12)+ |
// +-ebmlSize(36)--+ | +-payloadSize(137)-------------+offsetEndDiff+
// | | +-newPayloadSize(??)-------------------------+
// | | | |
// [Segment][size][Info][size][Duration][size]....[size][value][Cluster]
// ^ |
// | *??=newPayloadOffsetEnd
// inf
if (!(payload[payload.length - 1].dataEnd > 0)) {
throw new Error("metadata dataEnd has wrong number");
}
var originalPayloadOffsetEnd = payload[payload.length - 1].dataEnd; // = first cluster ptr
var ebmlSize = ebml[ebml.length - 1].dataEnd; // = first segment ptr
var refinedEBMLSize = new EBMLEncoder_1.default().encode(ebml).byteLength;
var offsetDiff = refinedEBMLSize - ebmlSize;
var payloadSize = originalPayloadOffsetEnd - payload[0].tagStart;
var segmentSize = payload[0].tagStart - ebmlSize;
var segmentOffset = payload[0].tagStart;
var segmentTagBuf = new exports.Buffer([0x18, 0x53, 0x80, 0x67]); // Segment
var segmentSizeBuf = new exports.Buffer('01ffffffffffffff', 'hex'); // Segmentの最後の位置は無数の Cluster 依存なので。 writeVint(newPayloadSize).byteLength ではなく、 infinity.
var _segmentSize = segmentTagBuf.byteLength + segmentSizeBuf.byteLength; // == segmentSize
var newPayloadSize = payloadSize;
// We need the size to be stable between two refinements in order for our offsets to be correct
// Bound the number of possible refinements so we can't go infinate if something goes wrong
var i;
for (i = 1; i < 20; i++) {
var newPayloadOffsetEnd = ebmlSize + _segmentSize + newPayloadSize;
var offsetEndDiff = newPayloadOffsetEnd - originalPayloadOffsetEnd;
var sizeDiff = offsetDiff + offsetEndDiff;
var refined = refineMetadata(payload, sizeDiff, info);
var newNewRefinedSize = new EBMLEncoder_1.default().encode(refined).byteLength; // 一旦 seekhead を作って自身のサイズを調べる
if (newNewRefinedSize === newPayloadSize) {
// Size is stable
return new EBMLEncoder_1.default().encode([].concat(ebml, [{ type: "m", name: "Segment", isEnd: false, unknownSize: true }], refined));
}
newPayloadSize = newNewRefinedSize;
}
throw new Error("unable to refine metadata, stable size could not be found in " + i + " iterations!");
}
exports.putRefinedMetaData = putRefinedMetaData;
// Given a list of EBMLElementBuffers, returns their encoded size in bytes
function encodedSizeOfEbml(refinedMetaData) {
var encorder = new EBMLEncoder_1.default();
return refinedMetaData.reduce(function (lst, elm) { return lst.concat(encorder.encode([elm])); }, []).reduce(function (o, buf) { return o + buf.byteLength; }, 0);
}
function refineMetadata(mesetadata, sizeDiff, info) {
var duration = info.duration, clusterPtrs = info.clusterPtrs, cues = info.cues;
var _metadata = mesetadata.slice(0);
if (typeof duration === "number") {
// duration を追加する
var overwrited_1 = false;
_metadata.forEach(function (elm) {
if (elm.type === "f" && elm.name === "Duration") {
overwrited_1 = true;
elm.data = createFloatBuffer(duration, 8);
}
});
if (!overwrited_1) {
insertTag(_metadata, "Info", [{ name: "Duration", type: "f", data: createFloatBuffer(duration, 8) }]);
}
}
if (Array.isArray(cues)) {
insertTag(_metadata, "Cues", create_cue(cues, sizeDiff));
}
var seekhead_children = [];
if (Array.isArray(clusterPtrs)) {
console.warn("append cluster pointers to seekhead is deprecated. please use cues");
seekhead_children = create_seek_from_clusters(clusterPtrs, sizeDiff);
}
// remove seek info
/*
_metadata = _metadata.filter((elm)=> !(
elm.name === "Seek" ||
elm.name === "SeekID" ||
elm.name === "SeekPosition") );
*/
// working on progress
//seekhead_children = seekhead_children.concat(create_seekhead(_metadata));
insertTag(_metadata, "SeekHead", seekhead_children, true);
return _metadata;
}
function create_seekhead(metadata, sizeDiff) {
var seeks = [];
["Info", "Tracks", "Cues"].forEach(function (tagName) {
var tagStarts = metadata.filter(function (elm) { return elm.type === "m" && elm.name === tagName && elm.isEnd === false; }).map(function (elm) { return elm["tagStart"]; });
var tagStart = tagStarts[0];
if (typeof tagStart !== "number") {
return;
}
seeks.push({ name: "Seek", type: "m", isEnd: false });
switch (tagName) {
case "Info":
seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) });
break;
case "Tracks":
seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) });
break;
case "Cues":
seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) });
break;
}
seeks.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tagStart + sizeDiff) });
seeks.push({ name: "Seek", type: "m", isEnd: true });
});
return seeks;
}
function create_seek_from_clusters(clusterPtrs, sizeDiff) {
var seeks = [];
clusterPtrs.forEach(function (start) {
seeks.push({ name: "Seek", type: "m", isEnd: false });
// [0x1F, 0x43, 0xB6, 0x75] で Cluster 意
seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1F, 0x43, 0xB6, 0x75]) });
seeks.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(start + sizeDiff) });
seeks.push({ name: "Seek", type: "m", isEnd: true });
});
return seeks;
}
function create_cue(cueInfos, sizeDiff) {
var cues = [];
cueInfos.forEach(function (_a) {
var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;
cues.push({ name: "CuePoint", type: "m", isEnd: false });
cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: false });
cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) }); // video track
cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition + sizeDiff) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: true });
cues.push({ name: "CuePoint", type: "m", isEnd: true });
});
return cues;
}
function insertTag(_metadata, tagName, children, insertHead) {
if (insertHead === void 0) { insertHead = false; }
// find the tagname from _metadata
var idx = -1;
for (var i = 0; i < _metadata.length; i++) {
var elm = _metadata[i];
if (elm.type === "m" && elm.name === tagName && elm.isEnd === false) {
idx = i;
break;
}
}
if (idx >= 0) {
// insert [<CuePoint />] to <Cues />
Array.prototype.splice.apply(_metadata, [idx + 1, 0].concat(children));
}
else if (insertHead) {
[].concat([{ name: tagName, type: "m", isEnd: false }], children, [{ name: tagName, type: "m", isEnd: true }]).reverse().forEach(function (elm) { _metadata.unshift(elm); });
}
else {
// metadata 末尾に <Cues /> を追加
// insert <Cues />
_metadata.push({ name: tagName, type: "m", isEnd: false });
children.forEach(function (elm) { _metadata.push(elm); });
_metadata.push({ name: tagName, type: "m", isEnd: true });
}
}
function concat(list) {
return exports.Buffer.concat(list);
}
exports.concat = concat;
function encodeValueToBuffer(elm) {
var data = new exports.Buffer(0);
if (elm.type === "m") {
return elm;
}
switch (elm.type) {
case "u":
data = createUIntBuffer(elm.value);
break;
case "i":
data = createIntBuffer(elm.value);
break;
case "f":
data = createFloatBuffer(elm.value);
break;
case "s":
data = new exports.Buffer(elm.value, 'ascii');
break;
case "8":
data = new exports.Buffer(elm.value, 'utf8');
break;
case "b":
data = elm.value;
break;
case "d":
data = new int64_buffer_1.Int64BE(elm.value.getTime().toString()).toBuffer();
break;
}
return Object.assign({}, elm, { data: data });
}
exports.encodeValueToBuffer = encodeValueToBuffer;
function createUIntBuffer(value) {
// Big-endian, any size from 1 to 8
// but js number is float64, so max 6 bit octets
var bytes = 1;
for (; value >= Math.pow(2, 8 * bytes); bytes++) { }
if (bytes >= 7) {
console.warn("7bit or more bigger uint not supported.");
return new int64_buffer_1.Uint64BE(value).toBuffer();
}
var data = new exports.Buffer(bytes);
data.writeUIntBE(value, 0, bytes);
return data;
}
exports.createUIntBuffer = createUIntBuffer;
function createIntBuffer(value) {
// Big-endian, any size from 1 to 8 octets
// but js number is float64, so max 6 bit
var bytes = 1;
for (; value >= Math.pow(2, 8 * bytes); bytes++) { }
if (bytes >= 7) {
console.warn("7bit or more bigger uint not supported.");
return new int64_buffer_1.Int64BE(value).toBuffer();
}
var data = new exports.Buffer(bytes);
data.writeIntBE(value, 0, bytes);
return data;
}
exports.createIntBuffer = createIntBuffer;
function createFloatBuffer(value, bytes) {
if (bytes === void 0) { bytes = 8; }
// Big-endian, defined for 4 and 8 octets (32, 64 bits)
// js number is float64 so 8 bytes.
if (bytes === 8) {
// 64bit
var data = new exports.Buffer(8);
data.writeDoubleBE(value, 0);
return data;
}
else if (bytes === 4) {
// 32bit
var data = new exports.Buffer(4);
data.writeFloatBE(value, 0);
return data;
}
else {
throw new Error("float type bits must 4bytes or 8bytes");
}
}
exports.createFloatBuffer = createFloatBuffer;
function convertEBMLDateToJSDate(int64str) {
if (int64str instanceof Date) {
return int64str;
}
return new Date(new Date("2001-01-01T00:00:00.000Z").getTime() + (Number(int64str) / 1000 / 1000));
}
exports.convertEBMLDateToJSDate = convertEBMLDateToJSDate;
/***/ }),
/***/ "./node_modules/webm-duration-fix/lib/index.js":
/*!*****************************************************!*\
!*** ./node_modules/webm-duration-fix/lib/index.js ***!
\*****************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
var ebml_1 = __webpack_require__(/*! ./ebml */ "./node_modules/webm-duration-fix/lib/ebml/index.js");
/**
* based on ts-ebml and support large file,optimize memory usage during repair
*
* @param blob the blob you need to fix
* @returns the blob that has been fixed
*
*/
function fixWebmDuration(blob) {
return __awaiter(this, void 0, void 0, function () {
var decoder, reader, readstream, readerBlob, _a, done, value, elms, refinedMetadataBuf, refinedMetadataBlob, firstPartBlobWithoutMetadata, finalBlob;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!blob) {
throw Error('call to fixWebmDuration requires a blob');
}
decoder = new ebml_1.Decoder();
reader = new ebml_1.Reader();
readstream = blob.stream();
readerBlob = readstream.getReader();
_b.label = 1;
case 1:
if (false) // removed by dead control flow
{}
return [4 /*yield*/, readerBlob.read()];
case 2:
_a = _b.sent(), done = _a.done, value = _a.value;
if (done) {
reader.stop();
return [3 /*break*/, 3];
}
elms = decoder.decode(value);
// As browser upgrade webm meta attributes are gradually added,
// so filter unknown type to bypass this issue.
elms = elms === null || elms === void 0 ? void 0 : elms.filter(function (elm) { return elm.type !== 'unknown'; });
elms.forEach(function (elm) {
reader.read(elm);
});
value = null;
return [3 /*break*/, 1];
case 3:
refinedMetadataBuf = ebml_1.tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);
refinedMetadataBlob = new Blob([refinedMetadataBuf], { type: blob.type });
firstPartBlobWithoutMetadata = blob.slice(reader.metadataSize);
finalBlob = new Blob([refinedMetadataBlob, firstPartBlobWithoutMetadata], { type: blob.type });
return [2 /*return*/, finalBlob];
}
});
});
}
exports["default"] = fixWebmDuration;
/***/ }),
/***/ "./node_modules/int64-buffer/int64-buffer.js":
/*!***************************************************!*\
!*** ./node_modules/int64-buffer/int64-buffer.js ***!
\***************************************************/
/***/ (function(__unused_webpack_module, exports) {
// int64-buffer.js
/*jshint -W018 */ // Confusing use of '!'.
/*jshint -W030 */ // Expected an assignment or function call and instead saw an expression.
/*jshint -W093 */ // Did you mean to return a conditional instead of an assignment?
var Uint64BE, Int64BE, Uint64LE, Int64LE;
!function(exports) {
// constants
var UNDEFINED = "undefined";
var BUFFER = (UNDEFINED !== typeof Buffer) && Buffer;
var UINT8ARRAY = (UNDEFINED !== typeof Uint8Array) && Uint8Array;
var ARRAYBUFFER = (UNDEFINED !== typeof ArrayBuffer) && ArrayBuffer;
var ZERO = [0, 0, 0, 0, 0, 0, 0, 0];
var isArray = Array.isArray || _isArray;
var BIT32 = 4294967296;
var BIT24 = 16777216;
// storage class
var storage; // Array;
// generate classes
Uint64BE = factory("Uint64BE", true, true);
Int64BE = factory("Int64BE", true, false);
Uint64LE = factory("Uint64LE", false, true);
Int64LE = factory("Int64LE", false, false);
// class factory
function factory(name, bigendian, unsigned) {
var posH = bigendian ? 0 : 4;
var posL = bigendian ? 4 : 0;
var pos0 = bigendian ? 0 : 3;
var pos1 = bigendian ? 1 : 2;
var pos2 = bigendian ? 2 : 1;
var pos3 = bigendian ? 3 : 0;
var fromPositive = bigendian ? fromPositiveBE : fromPositiveLE;
var fromNegative = bigendian ? fromNegativeBE : fromNegativeLE;
var proto = Int64.prototype;
var isName = "is" + name;
var _isInt64 = "_" + isName;
// properties
proto.buffer = void 0;
proto.offset = 0;
proto[_isInt64] = true;
// methods
proto.toNumber = toNumber;
proto.toString = toString;
proto.toJSON = toNumber;
proto.toArray = toArray;
// add .toBuffer() method only when Buffer available
if (BUFFER) proto.toBuffer = toBuffer;
// add .toArrayBuffer() method only when Uint8Array available
if (UINT8ARRAY) proto.toArrayBuffer = toArrayBuffer;
// isUint64BE, isInt64BE
Int64[isName] = isInt64;
// CommonJS
exports[name] = Int64;
return Int64;
// constructor
function Int64(buffer, offset, value, raddix) {
if (!(this instanceof Int64)) return new Int64(buffer, offset, value, raddix);
return init(this, buffer, offset, value, raddix);
}
// isUint64BE, isInt64BE
function isInt64(b) {
return !!(b && b[_isInt64]);
}
// initializer
function init(that, buffer, offset, value, raddix) {
if (UINT8ARRAY && ARRAYBUFFER) {
if (buffer instanceof ARRAYBUFFER) buffer = new UINT8ARRAY(buffer);
if (value instanceof ARRAYBUFFER) value = new UINT8ARRAY(value);
}
// Int64BE() style
if (!buffer && !offset && !value && !storage) {
// shortcut to initialize with zero
that.buffer = newArray(ZERO, 0);
return;
}
// Int64BE(value, raddix) style
if (!isValidBuffer(buffer, offset)) {
var _storage = storage || Array;
raddix = offset;
value = buffer;
offset = 0;
buffer = (storage === BUFFER) ? BUFFER.alloc(8) : new _storage(8);
}
that.buffer = buffer;
that.offset = offset |= 0;
// Int64BE(buffer, offset) style
if (UNDEFINED === typeof value) return;
// Int64BE(buffer, offset, value, raddix) style
if ("string" === typeof value) {
fromString(buffer, offset, value, raddix || 10);
} else if (isValidBuffer(value, raddix)) {
fromArray(buffer, offset, value, raddix);
} else if ("number" === typeof raddix) {
writeInt32(buffer, offset + posH, value); // high
writeInt32(buffer, offset + posL, raddix); // low
} else if (value > 0) {
fromPositive(buffer, offset, value); // positive
} else if (value < 0) {
fromNegative(buffer, offset, value); // negative
} else {
fromArray(buffer, offset, ZERO, 0); // zero, NaN and others
}
}
function fromString(buffer, offset, str, raddix) {
var pos = 0;
var len = str.length;
var high = 0;
var low = 0;
if (str[0] === "-") pos++;
var sign = pos;
while (pos < len) {
var chr = parseInt(str[pos++], raddix);
if (!(chr >= 0)) break; // NaN
low = low * raddix + chr;
high = high * raddix + Math.floor(low / BIT32);
low %= BIT32;
}
if (sign) {
high = ~high;
if (low) {
low = BIT32 - low;
} else {
high++;
}
}
writeInt32(buffer, offset + posH, high);
writeInt32(buffer, offset + posL, low);
}
function toNumber() {
var buffer = this.buffer;
var offset = this.offset;
var high = readInt32(buffer, offset + posH);
var low = readInt32(buffer, offset + posL);
if (!unsigned) high |= 0; // a trick to get signed
return high ? (high * BIT32 + low) : low;
}
function toString(radix) {
var buffer = this.buffer;
var offset = this.offset;
var high = readInt32(buffer, offset + posH);
var low = readInt32(buffer, offset + posL);
var str = "";
var sign = !unsigned && (high & 0x80000000);
if (sign) {
high = ~high;
low = BIT32 - low;
}
radix = radix || 10;
while (1) {
var mod = (high % radix) * BIT32 + low;
high = Math.floor(high / radix);
low = Math.floor(mod / radix);
str = (mod % radix).toString(radix) + str;
if (!high && !low) break;
}
if (sign) {
str = "-" + str;
}
return str;
}
function writeInt32(buffer, offset, value) {
buffer[offset + pos3] = value & 255;
value = value >> 8;
buffer[offset + pos2] = value & 255;
value = value >> 8;
buffer[offset + pos1] = value & 255;
value = value >> 8;
buffer[offset + pos0] = value & 255;
}
function readInt32(buffer, offset) {
return (buffer[offset + pos0] * BIT24) +
(buffer[offset + pos1] << 16) +
(buffer[offset + pos2] << 8) +
buffer[offset + pos3];
}
}
function toArray(raw) {
var buffer = this.buffer;
var offset = this.offset;
storage = null; // Array
if (raw !== false && isArray(buffer)) {
return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8);
}
return newArray(buffer, offset);
}
function toBuffer(raw) {
var buffer = this.buffer;
var offset = this.offset;
storage = BUFFER;
if (raw !== false && BUFFER.isBuffer(buffer)) {
return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8);
}
// Buffer.from(arraybuffer) available since Node v4.5.0
// https://nodejs.org/en/blog/release/v4.5.0/
return BUFFER.from(toArrayBuffer.call(this, raw));
}
function toArrayBuffer(raw) {
var buffer = this.buffer;
var offset = this.offset;
var arrbuf = buffer.buffer;
storage = UINT8ARRAY;
// arrbuf.slice() ignores buffer.offset until Node v8.0.0
if (raw !== false && !buffer.offset && (arrbuf instanceof ARRAYBUFFER)) {
return (arrbuf.byteLength === 8) ? arrbuf : arrbuf.slice(offset, offset + 8);
}
var dest = new UINT8ARRAY(8);
fromArray(dest, 0, buffer, offset);
return dest.buffer;
}
function isValidBuffer(buffer, offset) {
var len = buffer && buffer.length;
offset |= 0;
return len && (offset + 8 <= len) && ("string" !== typeof buffer[offset]);
}
function fromArray(destbuf, destoff, srcbuf, srcoff) {
destoff |= 0;
srcoff |= 0;
for (var i = 0; i < 8; i++) {
destbuf[destoff++] = srcbuf[srcoff++] & 255;
}
}
function newArray(buffer, offset) {
return Array.prototype.slice.call(buffer, offset, offset + 8);
}
function fromPositiveBE(buffer, offset, value) {
var pos = offset + 8;
while (pos > offset) {
buffer[--pos] = value & 255;
value /= 256;
}
}
function fromNegativeBE(buffer, offset, value) {
var pos = offset + 8;
value++;
while (pos > offset) {
buffer[--pos] = ((-value) & 255) ^ 255;
value /= 256;
}
}
function fromPositiveLE(buffer, offset, value) {
var end = offset + 8;
while (offset < end) {
buffer[offset++] = value & 255;
value /= 256;
}
}
function fromNegativeLE(buffer, offset, value) {
var end = offset + 8;
value++;
while (offset < end) {
buffer[offset++] = ((-value) & 255) ^ 255;
value /= 256;
}
}
// https://github.com/retrofox/is-array
function _isArray(val) {
return !!val && "[object Array]" == Object.prototype.toString.call(val);
}
}( true && typeof exports.nodeName !== 'string' ? exports : (this || {}));
/***/ })
}]);
//# sourceMappingURL=vendors-node_modules_webm-duration-fix_lib_index_js.dev.js.map