+ * use timestamp unless it is undefined, NaN or Infinity + *
+ */ - return { - audioTrack: track, - avcTrack: Object(_dummy_demuxed_track__WEBPACK_IMPORTED_MODULE_2__["dummyTrack"])(), - id3Track: id3Track, - textTrack: Object(_dummy_demuxed_track__WEBPACK_IMPORTED_MODULE_2__["dummyTrack"])() - }; - }; + var initPTSFn = function initPTSFn(timestamp, timeOffset) { + return Object(_home_runner_work_CiderHls_js_CiderHls_js_src_polyfills_number__WEBPACK_IMPORTED_MODULE_0__["isFiniteNumber"])(timestamp) ? timestamp * 90 : timeOffset * 90000; + }; + /* harmony default export */ __webpack_exports__["default"] = BaseAudioDemuxer; - _proto.demuxSampleAes = function demuxSampleAes(data, keyData, timeOffset) { - return Promise.reject(new Error("[" + this + "] This demuxer does not support Sample-AES decryption")); - }; + /***/ + }, - _proto.flush = function flush(timeOffset) { - // Parse cache in case of remaining frames. - var cachedData = this.cachedData; - - if (cachedData) { - this.cachedData = null; - this.demux(cachedData, 0); - } - - this.frameIndex = 0; - return { - audioTrack: this._audioTrack, - avcTrack: Object(_dummy_demuxed_track__WEBPACK_IMPORTED_MODULE_2__["dummyTrack"])(), - id3Track: this._id3Track, - textTrack: Object(_dummy_demuxed_track__WEBPACK_IMPORTED_MODULE_2__["dummyTrack"])() - }; - }; - - _proto.destroy = function destroy() {}; - - return BaseAudioDemuxer; -}(); -/** - * Initialize PTS - *- * use timestamp unless it is undefined, NaN or Infinity - *
- */ - - -var initPTSFn = function initPTSFn(timestamp, timeOffset) { - return Object(_home_runner_work_CiderHls_js_CiderHls_js_src_polyfills_number__WEBPACK_IMPORTED_MODULE_0__["isFiniteNumber"])(timestamp) ? timestamp * 90 : timeOffset * 90000; -}; -/* harmony default export */ __webpack_exports__["default"] = (BaseAudioDemuxer); - -/***/ }), - -/***/ "./src/demux/chunk-cache.ts": -/*!**********************************!*\ + /***/ "./src/demux/chunk-cache.ts": + /*!**********************************!*\ !*** ./src/demux/chunk-cache.ts ***! \**********************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /*! exports provided: default */ + /***/ function (module, __webpack_exports__, __webpack_require__) { + "use strict"; + __webpack_require__.r(__webpack_exports__); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function () { + return ChunkCache; + }); + var ChunkCache = /*#__PURE__*/ (function () { + function ChunkCache() { + this.chunks = []; + this.dataLength = 0; + } -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ChunkCache; }); -var ChunkCache = /*#__PURE__*/function () { - function ChunkCache() { - this.chunks = []; - this.dataLength = 0; - } + var _proto = ChunkCache.prototype; - var _proto = ChunkCache.prototype; + _proto.push = function push(chunk) { + this.chunks.push(chunk); + this.dataLength += chunk.length; + }; - _proto.push = function push(chunk) { - this.chunks.push(chunk); - this.dataLength += chunk.length; - }; + _proto.flush = function flush() { + var chunks = this.chunks, + dataLength = this.dataLength; + var result; - _proto.flush = function flush() { - var chunks = this.chunks, - dataLength = this.dataLength; - var result; + if (!chunks.length) { + return new Uint8Array(0); + } else if (chunks.length === 1) { + result = chunks[0]; + } else { + result = concatUint8Arrays(chunks, dataLength); + } - if (!chunks.length) { - return new Uint8Array(0); - } else if (chunks.length === 1) { - result = chunks[0]; - } else { - result = concatUint8Arrays(chunks, dataLength); - } + this.reset(); + return result; + }; - this.reset(); - return result; - }; + _proto.reset = function reset() { + this.chunks.length = 0; + this.dataLength = 0; + }; - _proto.reset = function reset() { - this.chunks.length = 0; - this.dataLength = 0; - }; + return ChunkCache; + })(); - return ChunkCache; -}(); + function concatUint8Arrays(chunks, dataLength) { + var result = new Uint8Array(dataLength); + var offset = 0; + for (var i = 0; i < chunks.length; i++) { + var chunk = chunks[i]; + result.set(chunk, offset); + offset += chunk.length; + } + return result; + } -function concatUint8Arrays(chunks, dataLength) { - var result = new Uint8Array(dataLength); - var offset = 0; + /***/ + }, - for (var i = 0; i < chunks.length; i++) { - var chunk = chunks[i]; - result.set(chunk, offset); - offset += chunk.length; - } - - return result; -} - -/***/ }), - -/***/ "./src/demux/dummy-demuxed-track.ts": -/*!******************************************!*\ + /***/ "./src/demux/dummy-demuxed-track.ts": + /*!******************************************!*\ !*** ./src/demux/dummy-demuxed-track.ts ***! \******************************************/ -/*! exports provided: dummyTrack */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /*! exports provided: dummyTrack */ + /***/ function (module, __webpack_exports__, __webpack_require__) { + "use strict"; + __webpack_require__.r(__webpack_exports__); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dummyTrack", function () { + return dummyTrack; + }); + function dummyTrack() { + return { + type: "", + id: -1, + pid: -1, + inputTimeScale: 90000, + sequenceNumber: -1, + samples: [], + dropped: 0, + }; + } -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dummyTrack", function() { return dummyTrack; }); -function dummyTrack() { - return { - type: '', - id: -1, - pid: -1, - inputTimeScale: 90000, - sequenceNumber: -1, - samples: [], - dropped: 0 - }; -} + /***/ + }, -/***/ }), - -/***/ "./src/demux/exp-golomb.ts": -/*!*********************************!*\ + /***/ "./src/demux/exp-golomb.ts": + /*!*********************************!*\ !*** ./src/demux/exp-golomb.ts ***! \*********************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _utils_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/logger */ "./src/utils/logger.ts"); -/** - * Parser for exponential Golomb codes, a variable-bitwidth number encoding scheme used by h264. - */ - - -var ExpGolomb = /*#__PURE__*/function () { - function ExpGolomb(data) { - this.data = void 0; - this.bytesAvailable = void 0; - this.word = void 0; - this.bitsAvailable = void 0; - this.data = data; // the number of bytes left to examine in this.data - - this.bytesAvailable = data.byteLength; // the current word being examined - - this.word = 0; // :uint - // the number of bits left to examine in the current word - - this.bitsAvailable = 0; // :uint - } // ():void - - - var _proto = ExpGolomb.prototype; - - _proto.loadWord = function loadWord() { - var data = this.data; - var bytesAvailable = this.bytesAvailable; - var position = data.byteLength - bytesAvailable; - var workingBytes = new Uint8Array(4); - var availableBytes = Math.min(4, bytesAvailable); - - if (availableBytes === 0) { - throw new Error('no bytes available'); - } - - workingBytes.set(data.subarray(position, position + availableBytes)); - this.word = new DataView(workingBytes.buffer).getUint32(0); // track the amount of this.data that has been processed - - this.bitsAvailable = availableBytes * 8; - this.bytesAvailable -= availableBytes; - } // (count:int):void - ; - - _proto.skipBits = function skipBits(count) { - var skipBytes; // :int - - if (this.bitsAvailable > count) { - this.word <<= count; - this.bitsAvailable -= count; - } else { - count -= this.bitsAvailable; - skipBytes = count >> 3; - count -= skipBytes >> 3; - this.bytesAvailable -= skipBytes; - this.loadWord(); - this.word <<= count; - this.bitsAvailable -= count; - } - } // (size:int):uint - ; - - _proto.readBits = function readBits(size) { - var bits = Math.min(this.bitsAvailable, size); // :uint - - var valu = this.word >>> 32 - bits; // :uint - - if (size > 32) { - _utils_logger__WEBPACK_IMPORTED_MODULE_0__["logger"].error('Cannot read more than 32 bits at a time'); - } - - this.bitsAvailable -= bits; - - if (this.bitsAvailable > 0) { - this.word <<= bits; - } else if (this.bytesAvailable > 0) { - this.loadWord(); - } - - bits = size - bits; - - if (bits > 0 && this.bitsAvailable) { - return valu << bits | this.readBits(bits); - } else { - return valu; - } - } // ():uint - ; - - _proto.skipLZ = function skipLZ() { - var leadingZeroCount; // :uint - - for (leadingZeroCount = 0; leadingZeroCount < this.bitsAvailable; ++leadingZeroCount) { - if ((this.word & 0x80000000 >>> leadingZeroCount) !== 0) { - // the first bit of working word is 1 - this.word <<= leadingZeroCount; - this.bitsAvailable -= leadingZeroCount; - return leadingZeroCount; - } - } // we exhausted word and still have not found a 1 - - - this.loadWord(); - return leadingZeroCount + this.skipLZ(); - } // ():void - ; - - _proto.skipUEG = function skipUEG() { - this.skipBits(1 + this.skipLZ()); - } // ():void - ; - - _proto.skipEG = function skipEG() { - this.skipBits(1 + this.skipLZ()); - } // ():uint - ; - - _proto.readUEG = function readUEG() { - var clz = this.skipLZ(); // :uint - - return this.readBits(clz + 1) - 1; - } // ():int - ; - - _proto.readEG = function readEG() { - var valu = this.readUEG(); // :int - - if (0x01 & valu) { - // the number is odd if the low order bit is set - return 1 + valu >>> 1; // add 1 to make it even, and divide by 2 - } else { - return -1 * (valu >>> 1); // divide by two then make it negative - } - } // Some convenience functions - // :Boolean - ; - - _proto.readBoolean = function readBoolean() { - return this.readBits(1) === 1; - } // ():int - ; - - _proto.readUByte = function readUByte() { - return this.readBits(8); - } // ():int - ; - - _proto.readUShort = function readUShort() { - return this.readBits(16); - } // ():int - ; - - _proto.readUInt = function readUInt() { - return this.readBits(32); - } - /** - * Advance the ExpGolomb decoder past a scaling list. The scaling - * list is optionally transmitted as part of a sequence parameter - * set and is not relevant to transmuxing. - * @param count the number of entries in this scaling list - * @see Recommendation ITU-T H.264, Section 7.3.2.1.1.1 - */ - ; - - _proto.skipScalingList = function skipScalingList(count) { - var lastScale = 8; - var nextScale = 8; - var deltaScale; - - for (var j = 0; j < count; j++) { - if (nextScale !== 0) { - deltaScale = this.readEG(); - nextScale = (lastScale + deltaScale + 256) % 256; - } - - lastScale = nextScale === 0 ? lastScale : nextScale; - } - } - /** - * Read a sequence parameter set and return some interesting video - * properties. A sequence parameter set is the H264 metadata that - * describes the properties of upcoming video frames. - * @param data {Uint8Array} the bytes of a sequence parameter set - * @return {object} an object with configuration parsed from the - * sequence parameter set, including the dimensions of the - * associated video frames. - */ - ; - - _proto.readSPS = function readSPS() { - var frameCropLeftOffset = 0; - var frameCropRightOffset = 0; - var frameCropTopOffset = 0; - var frameCropBottomOffset = 0; - var numRefFramesInPicOrderCntCycle; - var scalingListCount; - var i; - var readUByte = this.readUByte.bind(this); - var readBits = this.readBits.bind(this); - var readUEG = this.readUEG.bind(this); - var readBoolean = this.readBoolean.bind(this); - var skipBits = this.skipBits.bind(this); - var skipEG = this.skipEG.bind(this); - var skipUEG = this.skipUEG.bind(this); - var skipScalingList = this.skipScalingList.bind(this); - readUByte(); - var profileIdc = readUByte(); // profile_idc - - readBits(5); // profileCompat constraint_set[0-4]_flag, u(5) - - skipBits(3); // reserved_zero_3bits u(3), - - readUByte(); // level_idc u(8) - - skipUEG(); // seq_parameter_set_id - // some profiles have more optional data we don't need - - if (profileIdc === 100 || profileIdc === 110 || profileIdc === 122 || profileIdc === 244 || profileIdc === 44 || profileIdc === 83 || profileIdc === 86 || profileIdc === 118 || profileIdc === 128) { - var chromaFormatIdc = readUEG(); - - if (chromaFormatIdc === 3) { - skipBits(1); - } // separate_colour_plane_flag - - - skipUEG(); // bit_depth_luma_minus8 - - skipUEG(); // bit_depth_chroma_minus8 - - skipBits(1); // qpprime_y_zero_transform_bypass_flag - - if (readBoolean()) { - // seq_scaling_matrix_present_flag - scalingListCount = chromaFormatIdc !== 3 ? 8 : 12; - - for (i = 0; i < scalingListCount; i++) { - if (readBoolean()) { - // seq_scaling_list_present_flag[ i ] - if (i < 6) { - skipScalingList(16); - } else { - skipScalingList(64); - } - } - } - } - } - - skipUEG(); // log2_max_frame_num_minus4 - - var picOrderCntType = readUEG(); - - if (picOrderCntType === 0) { - readUEG(); // log2_max_pic_order_cnt_lsb_minus4 - } else if (picOrderCntType === 1) { - skipBits(1); // delta_pic_order_always_zero_flag - - skipEG(); // offset_for_non_ref_pic - - skipEG(); // offset_for_top_to_bottom_field - - numRefFramesInPicOrderCntCycle = readUEG(); - - for (i = 0; i < numRefFramesInPicOrderCntCycle; i++) { - skipEG(); - } // offset_for_ref_frame[ i ] - - } - - skipUEG(); // max_num_ref_frames - - skipBits(1); // gaps_in_frame_num_value_allowed_flag - - var picWidthInMbsMinus1 = readUEG(); - var picHeightInMapUnitsMinus1 = readUEG(); - var frameMbsOnlyFlag = readBits(1); - - if (frameMbsOnlyFlag === 0) { - skipBits(1); - } // mb_adaptive_frame_field_flag - - - skipBits(1); // direct_8x8_inference_flag - - if (readBoolean()) { - // frame_cropping_flag - frameCropLeftOffset = readUEG(); - frameCropRightOffset = readUEG(); - frameCropTopOffset = readUEG(); - frameCropBottomOffset = readUEG(); - } + /*! exports provided: default */ + /***/ function (module, __webpack_exports__, __webpack_require__) { + "use strict"; + __webpack_require__.r(__webpack_exports__); + /* harmony import */ var _utils_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/logger */ "./src/utils/logger.ts"); + /** + * Parser for exponential Golomb codes, a variable-bitwidth number encoding scheme used by h264. + */ + + var ExpGolomb = /*#__PURE__*/ (function () { + function ExpGolomb(data) { + this.data = void 0; + this.bytesAvailable = void 0; + this.word = void 0; + this.bitsAvailable = void 0; + this.data = data; // the number of bytes left to examine in this.data + + this.bytesAvailable = data.byteLength; // the current word being examined + + this.word = 0; // :uint + // the number of bits left to examine in the current word + + this.bitsAvailable = 0; // :uint + } // ():void + + var _proto = ExpGolomb.prototype; + + _proto.loadWord = function loadWord() { + var data = this.data; + var bytesAvailable = this.bytesAvailable; + var position = data.byteLength - bytesAvailable; + var workingBytes = new Uint8Array(4); + var availableBytes = Math.min(4, bytesAvailable); + + if (availableBytes === 0) { + throw new Error("no bytes available"); + } + + workingBytes.set(data.subarray(position, position + availableBytes)); + this.word = new DataView(workingBytes.buffer).getUint32(0); // track the amount of this.data that has been processed + + this.bitsAvailable = availableBytes * 8; + this.bytesAvailable -= availableBytes; + }; // (count:int):void + + _proto.skipBits = function skipBits(count) { + var skipBytes; // :int + + if (this.bitsAvailable > count) { + this.word <<= count; + this.bitsAvailable -= count; + } else { + count -= this.bitsAvailable; + skipBytes = count >> 3; + count -= skipBytes >> 3; + this.bytesAvailable -= skipBytes; + this.loadWord(); + this.word <<= count; + this.bitsAvailable -= count; + } + }; // (size:int):uint + + _proto.readBits = function readBits(size) { + var bits = Math.min(this.bitsAvailable, size); // :uint + + var valu = this.word >>> (32 - bits); // :uint + + if (size > 32) { + _utils_logger__WEBPACK_IMPORTED_MODULE_0__["logger"].error("Cannot read more than 32 bits at a time"); + } + + this.bitsAvailable -= bits; + + if (this.bitsAvailable > 0) { + this.word <<= bits; + } else if (this.bytesAvailable > 0) { + this.loadWord(); + } + + bits = size - bits; + + if (bits > 0 && this.bitsAvailable) { + return (valu << bits) | this.readBits(bits); + } else { + return valu; + } + }; // ():uint + + _proto.skipLZ = function skipLZ() { + var leadingZeroCount; // :uint + + for (leadingZeroCount = 0; leadingZeroCount < this.bitsAvailable; ++leadingZeroCount) { + if ((this.word & (0x80000000 >>> leadingZeroCount)) !== 0) { + // the first bit of working word is 1 + this.word <<= leadingZeroCount; + this.bitsAvailable -= leadingZeroCount; + return leadingZeroCount; + } + } // we exhausted word and still have not found a 1 + + this.loadWord(); + return leadingZeroCount + this.skipLZ(); + }; // ():void + + _proto.skipUEG = function skipUEG() { + this.skipBits(1 + this.skipLZ()); + }; // ():void + + _proto.skipEG = function skipEG() { + this.skipBits(1 + this.skipLZ()); + }; // ():uint + + _proto.readUEG = function readUEG() { + var clz = this.skipLZ(); // :uint + + return this.readBits(clz + 1) - 1; + }; // ():int + + _proto.readEG = function readEG() { + var valu = this.readUEG(); // :int + + if (0x01 & valu) { + // the number is odd if the low order bit is set + return (1 + valu) >>> 1; // add 1 to make it even, and divide by 2 + } else { + return -1 * (valu >>> 1); // divide by two then make it negative + } + }; // Some convenience functions + // :Boolean + + _proto.readBoolean = function readBoolean() { + return this.readBits(1) === 1; + }; // ():int + + _proto.readUByte = function readUByte() { + return this.readBits(8); + }; // ():int + + _proto.readUShort = function readUShort() { + return this.readBits(16); + }; // ():int + + _proto.readUInt = function readUInt() { + return this.readBits(32); + }; + /** + * Advance the ExpGolomb decoder past a scaling list. The scaling + * list is optionally transmitted as part of a sequence parameter + * set and is not relevant to transmuxing. + * @param count the number of entries in this scaling list + * @see Recommendation ITU-T H.264, Section 7.3.2.1.1.1 + */ + + _proto.skipScalingList = function skipScalingList(count) { + var lastScale = 8; + var nextScale = 8; + var deltaScale; + + for (var j = 0; j < count; j++) { + if (nextScale !== 0) { + deltaScale = this.readEG(); + nextScale = (lastScale + deltaScale + 256) % 256; + } + + lastScale = nextScale === 0 ? lastScale : nextScale; + } + }; + /** + * Read a sequence parameter set and return some interesting video + * properties. A sequence parameter set is the H264 metadata that + * describes the properties of upcoming video frames. + * @param data {Uint8Array} the bytes of a sequence parameter set + * @return {object} an object with configuration parsed from the + * sequence parameter set, including the dimensions of the + * associated video frames. + */ + + _proto.readSPS = function readSPS() { + var frameCropLeftOffset = 0; + var frameCropRightOffset = 0; + var frameCropTopOffset = 0; + var frameCropBottomOffset = 0; + var numRefFramesInPicOrderCntCycle; + var scalingListCount; + var i; + var readUByte = this.readUByte.bind(this); + var readBits = this.readBits.bind(this); + var readUEG = this.readUEG.bind(this); + var readBoolean = this.readBoolean.bind(this); + var skipBits = this.skipBits.bind(this); + var skipEG = this.skipEG.bind(this); + var skipUEG = this.skipUEG.bind(this); + var skipScalingList = this.skipScalingList.bind(this); + readUByte(); + var profileIdc = readUByte(); // profile_idc + + readBits(5); // profileCompat constraint_set[0-4]_flag, u(5) + + skipBits(3); // reserved_zero_3bits u(3), + + readUByte(); // level_idc u(8) + + skipUEG(); // seq_parameter_set_id + // some profiles have more optional data we don't need + + if (profileIdc === 100 || profileIdc === 110 || profileIdc === 122 || profileIdc === 244 || profileIdc === 44 || profileIdc === 83 || profileIdc === 86 || profileIdc === 118 || profileIdc === 128) { + var chromaFormatIdc = readUEG(); + + if (chromaFormatIdc === 3) { + skipBits(1); + } // separate_colour_plane_flag + + skipUEG(); // bit_depth_luma_minus8 + + skipUEG(); // bit_depth_chroma_minus8 + + skipBits(1); // qpprime_y_zero_transform_bypass_flag + + if (readBoolean()) { + // seq_scaling_matrix_present_flag + scalingListCount = chromaFormatIdc !== 3 ? 8 : 12; + + for (i = 0; i < scalingListCount; i++) { + if (readBoolean()) { + // seq_scaling_list_present_flag[ i ] + if (i < 6) { + skipScalingList(16); + } else { + skipScalingList(64); + } + } + } + } + } + + skipUEG(); // log2_max_frame_num_minus4 + + var picOrderCntType = readUEG(); + + if (picOrderCntType === 0) { + readUEG(); // log2_max_pic_order_cnt_lsb_minus4 + } else if (picOrderCntType === 1) { + skipBits(1); // delta_pic_order_always_zero_flag + + skipEG(); // offset_for_non_ref_pic + + skipEG(); // offset_for_top_to_bottom_field + + numRefFramesInPicOrderCntCycle = readUEG(); + + for (i = 0; i < numRefFramesInPicOrderCntCycle; i++) { + skipEG(); + } // offset_for_ref_frame[ i ] + } + + skipUEG(); // max_num_ref_frames + + skipBits(1); // gaps_in_frame_num_value_allowed_flag + + var picWidthInMbsMinus1 = readUEG(); + var picHeightInMapUnitsMinus1 = readUEG(); + var frameMbsOnlyFlag = readBits(1); + + if (frameMbsOnlyFlag === 0) { + skipBits(1); + } // mb_adaptive_frame_field_flag + + skipBits(1); // direct_8x8_inference_flag + + if (readBoolean()) { + // frame_cropping_flag + frameCropLeftOffset = readUEG(); + frameCropRightOffset = readUEG(); + frameCropTopOffset = readUEG(); + frameCropBottomOffset = readUEG(); + } - var pixelRatio = [1, 1]; + var pixelRatio = [1, 1]; - if (readBoolean()) { - // vui_parameters_present_flag - if (readBoolean()) { - // aspect_ratio_info_present_flag - var aspectRatioIdc = readUByte(); + if (readBoolean()) { + // vui_parameters_present_flag + if (readBoolean()) { + // aspect_ratio_info_present_flag + var aspectRatioIdc = readUByte(); - switch (aspectRatioIdc) { - case 1: - pixelRatio = [1, 1]; - break; + switch (aspectRatioIdc) { + case 1: + pixelRatio = [1, 1]; + break; - case 2: - pixelRatio = [12, 11]; - break; + case 2: + pixelRatio = [12, 11]; + break; - case 3: - pixelRatio = [10, 11]; - break; + case 3: + pixelRatio = [10, 11]; + break; - case 4: - pixelRatio = [16, 11]; - break; + case 4: + pixelRatio = [16, 11]; + break; - case 5: - pixelRatio = [40, 33]; - break; + case 5: + pixelRatio = [40, 33]; + break; - case 6: - pixelRatio = [24, 11]; - break; + case 6: + pixelRatio = [24, 11]; + break; - case 7: - pixelRatio = [20, 11]; - break; + case 7: + pixelRatio = [20, 11]; + break; - case 8: - pixelRatio = [32, 11]; - break; + case 8: + pixelRatio = [32, 11]; + break; - case 9: - pixelRatio = [80, 33]; - break; + case 9: + pixelRatio = [80, 33]; + break; - case 10: - pixelRatio = [18, 11]; - break; + case 10: + pixelRatio = [18, 11]; + break; - case 11: - pixelRatio = [15, 11]; - break; + case 11: + pixelRatio = [15, 11]; + break; - case 12: - pixelRatio = [64, 33]; - break; + case 12: + pixelRatio = [64, 33]; + break; - case 13: - pixelRatio = [160, 99]; - break; + case 13: + pixelRatio = [160, 99]; + break; - case 14: - pixelRatio = [4, 3]; - break; + case 14: + pixelRatio = [4, 3]; + break; - case 15: - pixelRatio = [3, 2]; - break; + case 15: + pixelRatio = [3, 2]; + break; - case 16: - pixelRatio = [2, 1]; - break; + case 16: + pixelRatio = [2, 1]; + break; - case 255: - { - pixelRatio = [readUByte() << 8 | readUByte(), readUByte() << 8 | readUByte()]; - break; - } - } - } - } + case 255: { + pixelRatio = [(readUByte() << 8) | readUByte(), (readUByte() << 8) | readUByte()]; + break; + } + } + } + } - return { - width: Math.ceil((picWidthInMbsMinus1 + 1) * 16 - frameCropLeftOffset * 2 - frameCropRightOffset * 2), - height: (2 - frameMbsOnlyFlag) * (picHeightInMapUnitsMinus1 + 1) * 16 - (frameMbsOnlyFlag ? 2 : 4) * (frameCropTopOffset + frameCropBottomOffset), - pixelRatio: pixelRatio - }; - }; + return { + width: Math.ceil((picWidthInMbsMinus1 + 1) * 16 - frameCropLeftOffset * 2 - frameCropRightOffset * 2), + height: (2 - frameMbsOnlyFlag) * (picHeightInMapUnitsMinus1 + 1) * 16 - (frameMbsOnlyFlag ? 2 : 4) * (frameCropTopOffset + frameCropBottomOffset), + pixelRatio: pixelRatio, + }; + }; + + _proto.readSliceType = function readSliceType() { + // skip NALu type + this.readUByte(); // discard first_mb_in_slice + + this.readUEG(); // return slice_type + + return this.readUEG(); + }; - _proto.readSliceType = function readSliceType() { - // skip NALu type - this.readUByte(); // discard first_mb_in_slice - - this.readUEG(); // return slice_type - - return this.readUEG(); - }; + return ExpGolomb; + })(); - return ExpGolomb; -}(); + /* harmony default export */ __webpack_exports__["default"] = ExpGolomb; -/* harmony default export */ __webpack_exports__["default"] = (ExpGolomb); - -/***/ }), + /***/ + }, -/***/ "./src/demux/id3.ts": -/*!**************************!*\ + /***/ "./src/demux/id3.ts": + /*!**************************!*\ !*** ./src/demux/id3.ts ***! \**************************/ -/*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */ + /***/ function (module, __webpack_exports__, __webpack_require__) { + "use strict"; + __webpack_require__.r(__webpack_exports__); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeader", function () { + return isHeader; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isFooter", function () { + return isFooter; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getID3Data", function () { + return getID3Data; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "canParse", function () { + return canParse; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTimeStamp", function () { + return getTimeStamp; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isTimeStampFrame", function () { + return isTimeStampFrame; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getID3Frames", function () { + return getID3Frames; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodeFrame", function () { + return decodeFrame; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "utf8ArrayToStr", function () { + return utf8ArrayToStr; + }); + /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "testables", function () { + return testables; + }); + // breaking up those two types in order to clarify what is happening in the decoding path. -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeader", function() { return isHeader; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isFooter", function() { return isFooter; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getID3Data", function() { return getID3Data; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "canParse", function() { return canParse; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTimeStamp", function() { return getTimeStamp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isTimeStampFrame", function() { return isTimeStampFrame; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getID3Frames", function() { return getID3Frames; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodeFrame", function() { return decodeFrame; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "utf8ArrayToStr", function() { return utf8ArrayToStr; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "testables", function() { return testables; }); -// breaking up those two types in order to clarify what is happening in the decoding path. + /** + * Returns true if an ID3 header can be found at offset in data + * @param {Uint8Array} data - The data to search in + * @param {number} offset - The offset at which to start searching + * @return {boolean} - True if an ID3 header is found + */ + var isHeader = function isHeader(data, offset) { + /* + * http://id3.org/id3v2.3.0 + * [0] = 'I' + * [1] = 'D' + * [2] = '3' + * [3,4] = {Version} + * [5] = {Flags} + * [6-9] = {ID3 Size} + * + * An ID3v2 tag can be detected with the following pattern: + * $49 44 33 yy yy xx zz zz zz zz + * Where yy is less than $FF, xx is the 'flags' byte and zz is less than $80 + */ + if (offset + 10 <= data.length) { + // look for 'ID3' identifier + if (data[offset] === 0x49 && data[offset + 1] === 0x44 && data[offset + 2] === 0x33) { + // check version is within range + if (data[offset + 3] < 0xff && data[offset + 4] < 0xff) { + // check size is within range + if (data[offset + 6] < 0x80 && data[offset + 7] < 0x80 && data[offset + 8] < 0x80 && data[offset + 9] < 0x80) { + return true; + } + } + } + } -/** - * Returns true if an ID3 header can be found at offset in data - * @param {Uint8Array} data - The data to search in - * @param {number} offset - The offset at which to start searching - * @return {boolean} - True if an ID3 header is found - */ -var isHeader = function isHeader(data, offset) { - /* - * http://id3.org/id3v2.3.0 - * [0] = 'I' - * [1] = 'D' - * [2] = '3' - * [3,4] = {Version} - * [5] = {Flags} - * [6-9] = {ID3 Size} - * - * An ID3v2 tag can be detected with the following pattern: - * $49 44 33 yy yy xx zz zz zz zz - * Where yy is less than $FF, xx is the 'flags' byte and zz is less than $80 - */ - if (offset + 10 <= data.length) { - // look for 'ID3' identifier - if (data[offset] === 0x49 && data[offset + 1] === 0x44 && data[offset + 2] === 0x33) { - // check version is within range - if (data[offset + 3] < 0xff && data[offset + 4] < 0xff) { - // check size is within range - if (data[offset + 6] < 0x80 && data[offset + 7] < 0x80 && data[offset + 8] < 0x80 && data[offset + 9] < 0x80) { - return true; - } - } - } - } + return false; + }; + /** + * Returns true if an ID3 footer can be found at offset in data + * @param {Uint8Array} data - The data to search in + * @param {number} offset - The offset at which to start searching + * @return {boolean} - True if an ID3 footer is found + */ - return false; -}; -/** - * Returns true if an ID3 footer can be found at offset in data - * @param {Uint8Array} data - The data to search in - * @param {number} offset - The offset at which to start searching - * @return {boolean} - True if an ID3 footer is found - */ + var isFooter = function isFooter(data, offset) { + /* + * The footer is a copy of the header, but with a different identifier + */ + if (offset + 10 <= data.length) { + // look for '3DI' identifier + if (data[offset] === 0x33 && data[offset + 1] === 0x44 && data[offset + 2] === 0x49) { + // check version is within range + if (data[offset + 3] < 0xff && data[offset + 4] < 0xff) { + // check size is within range + if (data[offset + 6] < 0x80 && data[offset + 7] < 0x80 && data[offset + 8] < 0x80 && data[offset + 9] < 0x80) { + return true; + } + } + } + } -var isFooter = function isFooter(data, offset) { - /* - * The footer is a copy of the header, but with a different identifier - */ - if (offset + 10 <= data.length) { - // look for '3DI' identifier - if (data[offset] === 0x33 && data[offset + 1] === 0x44 && data[offset + 2] === 0x49) { - // check version is within range - if (data[offset + 3] < 0xff && data[offset + 4] < 0xff) { - // check size is within range - if (data[offset + 6] < 0x80 && data[offset + 7] < 0x80 && data[offset + 8] < 0x80 && data[offset + 9] < 0x80) { - return true; - } - } - } - } + return false; + }; + /** + * Returns any adjacent ID3 tags found in data starting at offset, as one block of data + * @param {Uint8Array} data - The data to search in + * @param {number} offset - The offset at which to start searching + * @return {Uint8Array | undefined} - The block of data containing any ID3 tags found + * or *undefined* if no header is found at the starting offset + */ - return false; -}; -/** - * Returns any adjacent ID3 tags found in data starting at offset, as one block of data - * @param {Uint8Array} data - The data to search in - * @param {number} offset - The offset at which to start searching - * @return {Uint8Array | undefined} - The block of data containing any ID3 tags found - * or *undefined* if no header is found at the starting offset - */ + var getID3Data = function getID3Data(data, offset) { + var front = offset; + var length = 0; -var getID3Data = function getID3Data(data, offset) { - var front = offset; - var length = 0; + while (isHeader(data, offset)) { + // ID3 header is 10 bytes + length += 10; + var size = readSize(data, offset + 6); + length += size; - while (isHeader(data, offset)) { - // ID3 header is 10 bytes - length += 10; - var size = readSize(data, offset + 6); - length += size; + if (isFooter(data, offset + 10)) { + // ID3 footer is 10 bytes + length += 10; + } - if (isFooter(data, offset + 10)) { - // ID3 footer is 10 bytes - length += 10; - } + offset += length; + } - offset += length; - } + if (length > 0) { + return data.subarray(front, front + length); + } - if (length > 0) { - return data.subarray(front, front + length); - } + return undefined; + }; - return undefined; -}; + var readSize = function readSize(data, offset) { + var size = 0; + size = (data[offset] & 0x7f) << 21; + size |= (data[offset + 1] & 0x7f) << 14; + size |= (data[offset + 2] & 0x7f) << 7; + size |= data[offset + 3] & 0x7f; + return size; + }; -var readSize = function readSize(data, offset) { - var size = 0; - size = (data[offset] & 0x7f) << 21; - size |= (data[offset + 1] & 0x7f) << 14; - size |= (data[offset + 2] & 0x7f) << 7; - size |= data[offset + 3] & 0x7f; - return size; -}; + var canParse = function canParse(data, offset) { + return isHeader(data, offset) && readSize(data, offset + 6) + 10 <= data.length - offset; + }; + /** + * Searches for the Elementary Stream timestamp found in the ID3 data chunk + * @param {Uint8Array} data - Block of data containing one or more ID3 tags + * @return {number | undefined} - The timestamp + */ -var canParse = function canParse(data, offset) { - return isHeader(data, offset) && readSize(data, offset + 6) + 10 <= data.length - offset; -}; -/** - * Searches for the Elementary Stream timestamp found in the ID3 data chunk - * @param {Uint8Array} data - Block of data containing one or more ID3 tags - * @return {number | undefined} - The timestamp - */ + var getTimeStamp = function getTimeStamp(data) { + var frames = getID3Frames(data); -var getTimeStamp = function getTimeStamp(data) { - var frames = getID3Frames(data); + for (var i = 0; i < frames.length; i++) { + var frame = frames[i]; - for (var i = 0; i < frames.length; i++) { - var frame = frames[i]; + if (isTimeStampFrame(frame)) { + return readTimeStamp(frame); + } + } - if (isTimeStampFrame(frame)) { - return readTimeStamp(frame); - } - } + return undefined; + }; + /** + * Returns true if the ID3 frame is an Elementary Stream timestamp frame + * @param {ID3 frame} frame + */ - return undefined; -}; -/** - * Returns true if the ID3 frame is an Elementary Stream timestamp frame - * @param {ID3 frame} frame - */ + var isTimeStampFrame = function isTimeStampFrame(frame) { + return frame && frame.key === "PRIV" && frame.info === "com.apple.streaming.transportStreamTimestamp"; + }; -var isTimeStampFrame = function isTimeStampFrame(frame) { - return frame && frame.key === 'PRIV' && frame.info === 'com.apple.streaming.transportStreamTimestamp'; -}; - -var getFrameData = function getFrameData(data) { - /* + var getFrameData = function getFrameData(data) { + /* Frame ID $xx xx xx xx (four characters) Size $xx xx xx xx Flags $xx xx */ - var type = String.fromCharCode(data[0], data[1], data[2], data[3]); - var size = readSize(data, 4); // skip frame id, size, and flags + var type = String.fromCharCode(data[0], data[1], data[2], data[3]); + var size = readSize(data, 4); // skip frame id, size, and flags - var offset = 10; - return { - type: type, - size: size, - data: data.subarray(offset, offset + size) - }; -}; -/** - * Returns an array of ID3 frames found in all the ID3 tags in the id3Data - * @param {Uint8Array} id3Data - The ID3 data containing one or more ID3 tags - * @return {ID3.Frame[]} - Array of ID3 frame objects - */ + var offset = 10; + return { + type: type, + size: size, + data: data.subarray(offset, offset + size), + }; + }; + /** + * Returns an array of ID3 frames found in all the ID3 tags in the id3Data + * @param {Uint8Array} id3Data - The ID3 data containing one or more ID3 tags + * @return {ID3.Frame[]} - Array of ID3 frame objects + */ + var getID3Frames = function getID3Frames(id3Data) { + var offset = 0; + var frames = []; -var getID3Frames = function getID3Frames(id3Data) { - var offset = 0; - var frames = []; + while (isHeader(id3Data, offset)) { + var size = readSize(id3Data, offset + 6); // skip past ID3 header - while (isHeader(id3Data, offset)) { - var size = readSize(id3Data, offset + 6); // skip past ID3 header + offset += 10; + var end = offset + size; // loop through frames in the ID3 tag - offset += 10; - var end = offset + size; // loop through frames in the ID3 tag + while (offset + 8 < end) { + var frameData = getFrameData(id3Data.subarray(offset)); + var frame = decodeFrame(frameData); - while (offset + 8 < end) { - var frameData = getFrameData(id3Data.subarray(offset)); - var frame = decodeFrame(frameData); + if (frame) { + frames.push(frame); + } // skip frame header and frame data - if (frame) { - frames.push(frame); - } // skip frame header and frame data + offset += frameData.size + 10; + } + if (isFooter(id3Data, offset)) { + offset += 10; + } + } - offset += frameData.size + 10; - } + return frames; + }; + var decodeFrame = function decodeFrame(frame) { + if (frame.type === "PRIV") { + return decodePrivFrame(frame); + } else if (frame.type[0] === "W") { + return decodeURLFrame(frame); + } - if (isFooter(id3Data, offset)) { - offset += 10; - } - } + return decodeTextFrame(frame); + }; - return frames; -}; -var decodeFrame = function decodeFrame(frame) { - if (frame.type === 'PRIV') { - return decodePrivFrame(frame); - } else if (frame.type[0] === 'W') { - return decodeURLFrame(frame); - } - - return decodeTextFrame(frame); -}; - -var decodePrivFrame = function decodePrivFrame(frame) { - /* + var decodePrivFrame = function decodePrivFrame(frame) { + /* Format: