{"version":3,"sources":["webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/IcecastMetadataQueue.js","webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/IcecastMetadataReader.js","webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/IcecastReadableStream.js","webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/MetadataParser/DualMetadataParser.js","webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/MetadataParser/IcyMetadataParser.js","webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/MetadataParser/MetadataParser.js","webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/MetadataParser/OggMetadataParser.js","webpack://IcecastMetadataPlayer/./node_modules/icecast-metadata-js/src/MetadataParser/Stats.js","webpack://IcecastMetadataPlayer/webpack/bootstrap","webpack://IcecastMetadataPlayer/webpack/runtime/compat get default export","webpack://IcecastMetadataPlayer/webpack/runtime/define property getters","webpack://IcecastMetadataPlayer/webpack/runtime/hasOwnProperty shorthand","webpack://IcecastMetadataPlayer/./src/EventTargetPolyfill.js","webpack://IcecastMetadataPlayer/./src/players/Player.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/utilities.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/globals.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/HeaderCache.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/Parser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/Frame.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/Header.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/mpeg/MPEGHeader.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/mpeg/MPEGFrame.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/mpeg/MPEGParser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/aac/AACHeader.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/aac/AACFrame.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/aac/AACParser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/ogg/OggPageHeader.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/ogg/OggPage.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/flac/FLACHeader.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/flac/FLACFrame.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/flac/FLACParser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/opus/OpusHeader.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/opus/OpusFrame.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/opus/OpusParser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/vorbis/VorbisFrame.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/vorbis/VorbisHeader.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/vorbis/VorbisParser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/codecs/ogg/OggParser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/src/CodecParser.js","webpack://IcecastMetadataPlayer/./node_modules/codec-parser/index.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/containers/ContainerElement.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/containers/isobmff/Box.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/containers/isobmff/ESTag.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/containers/isobmff/ISOBMFFContainer.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/utilities.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/containers/webm/EBML.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/containers/webm/WEBMContainer.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/src/MSEAudioWrapper.js","webpack://IcecastMetadataPlayer/./node_modules/mse-audio-wrapper/index.js","webpack://IcecastMetadataPlayer/./src/players/MediaSourcePlayer.js","webpack://IcecastMetadataPlayer/./src/players/HTML5Player.js","webpack://IcecastMetadataPlayer/./src/IcecastMetadataPlayer.js"],"names":["noOp","module","exports","icyBr","onMetadataUpdate","onMetadataEnqueue","this","_icyBr","_onMetadataUpdate","_onMetadataEnqueue","_isInitialMetadata","_metadataQueue","map","_timeoutId","rest","metadata","stats","timestampOffset","timestamp","_enqueueMetadata","getTimeByBytes","currentStreamPosition","bytesRead","forEach","i","clearTimeout","metadataPayload","push","_dequeueMetadata","setTimeout","shift","MetadataParser","IcyMetadataParser","OggMetadataParser","DualMetadataParser","metadataTypes","hasIcy","includes","hasOgg","_metadataParser","string","parseIcyMetadata","icyMetaInt","chunk","iterator","readAll","asyncIterator","asyncReadAll","IcecastMetadataReader","IcecastReadableStream","response","onStream","icecast","_readableStream","ReadableStream","controller","parseInt","headers","get","async","value","enqueue","stream","body","close","_icecast","readableStream","reader","getReader","Symbol","next","read","params","_oggMetadataParser","_icyMetadataParser","oggValue","icyDetectionTimeout","super","_icyMetaInt","_icyDetectionTimeout","_generator","_icyParser","_hasIcyMetadata","_remainingData","_getStream","_getMetadataLength","_getMetadata","Infinity","metadataString","metadataRegex","metadataElement","match","RegExp","_logError","METADATA_SEARCH","startTime","Date","now","metaInt","_buffer","_concatBuffers","_readData","detectMetadata","length","_stats","currentStreamBytesRemaining","_sendStream","_getNextValue","addMetadataLengthBytes","currentMetadataBytesRemaining","addMetadataBytes","_sendMetadata","_decoder","decode","Decoder","TextDecoder","Stats","_currentPosition","Uint8Array","_onStream","_onMetadata","onMetadata","_onError","onError","_enableLogging","enableLogging","_onStreamPromise","Promise","resolve","_onMetadataPromise","_passThroughParser","buf1","buf2","result","set","messages","console","warn","reduce","acc","message","addStreamBytes","streamPayload","minLength","subarray","addBytes","data","addCurrentBytesRemaining","_oggParser","_hasOggPage","codecMatcher","_identifyCodec","offset","DataView","from","buffer","getUint32","matchString","bytes","String","fromCharCode","syncBytes","_totalBytesRead","_currentBytesRemaining","baseOggPage","oggPageSegments","octet","_matchBytes","regex","_readVorbisComment","vendorStringLength","_getUint32","vendorString","commentListLength","comments","commentLength","comment","delimiter","indexOf","key","toUpperCase","val","VENDOR_STRING","_streamBytesRead","_metadataLengthBytesRead","_metadataBytesRead","_currentStreamBytesRemaining","_currentMetadataBytesRemaining","totalBytesRead","streamBytesRead","metadataLengthBytesRead","metadataBytesRead","currentBytesRemaining","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__","n","getter","__esModule","d","a","definition","o","Object","defineProperty","enumerable","obj","prop","prototype","hasOwnProperty","call","EventTargetPolyfill","_listeners","type","listener","some","item","options","hasEventListener","index","findIndex","splice","evt","filter","once","removeEventListener","Player","_audioElement","audioElement","_endpoint","endpoint","_hasIcy","_icecastMetadataQueue","icecastMetadataQueue","_fireEvent","fireEvent","_state","state","_events","events","abortController","res","fetch","method","signal","ok","error","Error","status","url","name","addMetadata","metadataTimestamp","currentTime","logError","crc8Table","Int32Array","reverseTable","reverse","BitReader","_data","_pos","position","bits","byte","Math","floor","bit","isParsedStore","WeakMap","headerStore","frameStore","HeaderCache","onCodecUpdate","_onCodecUpdate","reset","_isEnabled","_headerCache","Map","_codecUpdateData","header","_currentHeader","codecUpdateFields","Parser","remainingData","frame","Frame","_maxHeaderLength","fixedLengthFrameSync","sync","syncFrame","frames","nextFrame","enable","syncResult","samples","duration","sampleRate","frameNumber","undefined","totalBytesOut","totalSamples","totalDuration","Header","isParsed","bitDepth","channels","bitrateMatrix","0","layer12ModeExtensions","description","framePadding","modeExtensions","v1","bitrateIndex","v2","mpegVersions","layers","sampleRates","protection","emphasis","channelModes","MPEGHeader","headerCache","getKey","cachedHeader","getHeader","mpegVersionBits","layerBits","protectionBit","mpegVersion","layer","bitrateBits","sampleRateBits","paddingBit","privateBit","bitrate","isPrivate","frameLength","channelModeBits","modeExtensionBits","copyrightBit","originalBit","emphasisBits","channelMode","modeExtension","isCopyrighted","isOriginal","setHeader","MPEGFrame","MPEGParser","onCodec","codec","profile","AACHeader","assign","profileBits","of","getUint16","homeBit","copyrightIdBit","copyrightIdStartBit","isHome","copyrightId","copyrightIdStart","frameLengthBits","bufferFullnessBits","bufferFullness","numberAACFrames","audioSpecificConfig","setUint16","AACFrame","AACParser","OggPageHeader","view","streamStructureVersion","zeros","continuePacketBit","firstPageBit","lastPageBit","isContinuedPacket","isFirstPage","isLastPage","absoluteGranulePosition","getBigInt64","streamSerialNumber","getInt32","pageSequenceNumber","pageChecksum","pageSegmentTableLength","pageSegmentTable","pageSegmentBytes","segmentLength","segmentByte","OggPage","oggPage","pageStore","segments","segment","blockingStrategy","blockSize","channelAssignments","FLACHeader","mask","idx","blockingStrategyBits","blockSizeBits","channelAssignmentBits","bitDepthBits","channelAssignment","decodedUtf8","decodeUTF8Int","sampleNumber","crc","buf","crc8","FLACFrame","flacHeader","FLACParser","channelMappingFamilies","OpusHeader","preSkip","inputSampleRate","outputGain","getInt16","channelMappingFamily","streamCount","coupledStreamCount","channelMappingTable","configTable","mode","bandwidth","frameSize","OpusFrame","packet","config","code","frameCount","isVbr","Boolean","hasOpusPadding","opusHeader","getPacket","OpusParser","_identificationHeader","VorbisFrame","blockSizes","VorbisHeader","version","bitrateMaximum","bitrateNominal","bitrateMinimum","blocksize1","blocksize0","vorbisComments","vorbisSetup","VorbisParser","_mode","count","_prevBlockSize","_currBlockSize","_parseSetupHeader","_getSamples","blockFlag","prevMask","setup","bitReader","modeBits","mapping","log2","OggParser","_onCodec","_codec","_parser","oggPages","fixedLengthFrame","getCodec","flatMap","parseFrames","mimeType","_inputMimeType","_codecParser","_frameNumber","_totalBytesOut","_totalSamples","_frames","_codecData","_sendReceiveData","_parseFrames","codecData","buffers","concatBuffers","ContainerElement","contents","children","_name","_contents","_children","char","charCodeAt","number","setFloat64","setBigUint64","BigInt","setUint32","setInt16","array","Array","isArray","flatten","_buildContents","element","_buildLength","object","Box","_lengthBytes","stringToByteArray","_length","ESTag","tagNumber","tags","every","getLength","tag","addChild","ISOBMFFContainer","getMp4a","getOpus","getFlaC","esdsCodec","streamDescriptorTag","addTag","getCodecBox","xiphLacing","lacing","l","EBML","isUnknownLength","_isUnknownLength","getUint64","isNaN","_contentLength","getUintVariable","id","WEBMContainer","_codecId","_getCodecSpecificTrack","round","_timestampScale","getFloat64","offsetSamples","PREFERRED_CONTAINER","preferredContainer","MIN_FRAMES","minFramesPerSegment","MAX_FRAMES","maxFramesPerSegment","MIN_FRAMES_LENGTH","minBytesPerSegment","MAX_SAMPLES_PER_SEGMENT","_onMimeType","onMimeType","_container","_getContainer","_mimeType","groups","_groupFrames","_sentInitialSegment","getInitializationSegment","frameGroup","getMediaSegment","currentGroup","pop","MediaSourcePlayer","_createMediaSource","MediaSource","_mediaSource","sourceBuffers","max","buffered","end","sourceBufferPromise","_getMimeType","then","_createSourceBuffer","STREAM","_appendSourceBuffer","_mseAudioWrapper","fragment","inputMimeType","isTypeSupported","args","CODEC_UPDATE","ERROR","_mediaSourcePromise","_sourceBufferRemoved","addSourceBuffer","src","URL","createObjectURL","addEventListener","appendBuffer","_waitForSourceBuffer","BUFFER_INTERVAL","remove","HTML5Player","_frame","_audioLoaded","_offset","crossOrigin","preload","removeAttribute","load","audioPromise","reject","audioLoaded","performance","fetchStream","EventClass","EventTarget","p","STOPPING","STOPPED","RETRYING","PLAY","LOAD","STREAM_START","STREAM_END","METADATA","METADATA_ENQUEUE","STOP","RETRY","RETRY_TIMEOUT","WARN","retryDelayRate","retryDelayMin","retryDelayMax","retryTimeout","icecastReadableStream","player","playerParams","playerResetPromise","onAudioPause","onAudioPlay","onAudioCanPlay","onAudioError","resetPlayback","retryAttempt","retryTimeoutId","onAudioWaiting","fallbackToHTML5","playResponse","attachAudioElement","shouldRetry","IcecastMetadataPlayer","Audio","onPlay","onLoad","onStreamStart","onStreamEnd","onStop","onRetry","onRetryTimeout","onWarn","pause","purgeMetadataQueue","play","stop","e","1","2","3","4","5","target","bind","isSupported","metadataQueue","dispatchEvent","CustomEvent","audio","AbortController","tryFetching","finally","catch","abort","delay","min","random","audioWaiting","getOnMetadata","getOnStream","startReading","event","detail"],"mappings":";;;;;;;;;;;;;;;;;;;+CAiBA,MAAMA,EAAO,OA4GbC,EAAOC,QA1GP,MAwBE,aAAY,MAAEC,EAAK,iBAAEC,EAAmBJ,EAAI,kBAAEK,EAAoBL,IAChEM,KAAKC,EAASJ,EACdG,KAAKE,EAAoBJ,EACzBE,KAAKG,EAAqBJ,EAC1BC,KAAKI,GAAqB,EAC1BJ,KAAKK,EAAiB,GAOxB,oBACE,OAAOL,KAAKK,EAAeC,KAAI,EAAG,EAAAC,KAAeC,KAAWA,IAS9D,aAAY,SAAEC,EAAQ,MAAEC,GAASC,EAAiBC,EAAY,GAM5DZ,KAAKa,EACHJ,EACAE,EACAC,EAAYZ,KAAKc,eAAeJ,EAAMK,wBAS1C,eAAeC,GACb,OAAOhB,KAAKC,EAASe,GAA2B,IAAdhB,KAAKC,GAAgB,EAMzD,qBACED,KAAKK,EAAeY,SAASC,GAAMC,aAAaD,EAAEX,KAClDP,KAAKK,EAAiB,GAGxB,EAAiBI,EAAUE,EAAiBC,GAC1C,MAAMQ,EAAkB,CACtBX,WACAE,kBACAC,aAGFZ,KAAKK,EAAegB,KAAKD,GACzBpB,KAAKG,EAAmBM,EAAUE,EAAiBC,GAE/CZ,KAAKI,GACPJ,KAAKsB,IACLtB,KAAKI,GAAqB,GAE1BgB,EAAgBb,EAAagB,YAAW,KACtCvB,KAAKsB,MAC4B,KAA/BX,EAAkBC,IAI1B,IACE,MAAM,SACJH,EAAQ,gBACRE,EAAe,UACfC,GACEZ,KAAKK,EAAemB,QACxBxB,KAAKE,EAAkBO,EA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B,IAAI,IAAJ,CAA0B7Y,EAAK,CAClEzH,WAAYof,GAAEnjB,IAAIpD,MAAM0nB,IAAQmD,gBAChChoB,SAAU0jB,GAAEnjB,IAAIpD,MAAM0nB,IAAQoD,YAAYlc,GAC1CvH,QAAS,IAAIqd,IAAS1kB,KAAKsO,IAAW8Y,MAAS1C,GAC/C7iB,cAAe0kB,GAAEnjB,IAAIpD,MAAM6B,IAC3BO,WAAYmkB,GAAEnjB,IAAIpD,MAAMoC,IACxBkC,oBAAqBiiB,GAAEnjB,IAAIpD,MAAMsE,YAG7BiiB,GAAEnjB,IAAIpD,MAAMynB,IAAuBsD,eAG3C,CAACzc,IAAW0c,KAAUtG,GACpB1kB,KAAKiqB,cAAc,IAAIC,YAAYc,EAAO,CAAEC,OAAQvG,KACpD6B,GAAEnjB,IAAIpD,MAAM0O,IAAQsc,MAAUtG,GAGhC,CAAC2D,MACCroB,KAAKsO,IACHsW,GACA,8FACA,6CAGF2B,GAAEnjB,IAAIpD,MAAM0nB,IAAU,IAAIlC,GAAYe,GAAEnjB,IAAIpD,MAAM2nB,KAClDpB,GAAEnjB,IAAIpD,MAAM4nB,IAAoB1D,MAAK,IAAMlkB,KAAKqpB,Y","file":"icecast-metadata-player-1.1.1.min.js","sourcesContent":["/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst noOp = () => {};\n\nclass IcecastMetadataQueue {\n  /**\n   * @description Schedules updates up to the millisecond for Icecast Metadata from the response body of an Icecast stream mountpoint\n   * @description The accuracy of metadata updates is a direct relationship of the icyMetaInt\n   * @param {Object} IcecastMetadataQueue constructor parameter\n   * @param {number} [IcecastMetadataQueue.icyBr] Bitrate of audio stream used to increase accuracy when to updating metadata\n   * @param {onMetadataUpdate} [IcecastMetadataQueue.onMetadataUpdate] Callback executed when metadata is scheduled to update\n   * @param {onMetadataEnqueue} [IcecastMetadataQueue.onMetadataEnqueue] Callback executed when metadata is enqueued\n   *\n   * @callback onMetadataUpdate\n   * @param {Object} metadata Object containing all metadata received.\n   * @param {string} [metadata.StreamTitle] Title of the metadata update.\n   * @param {string} [metadata.StreamUrl] Url (usually album art) of the metadata update.\n   * @param {number} timestampOffset Total time buffered when the metadata was added\n   * @param {number} timestamp Current time of the audio player when the metadata was added\n   *\n   * @callback onMetadataEnqueue\n   * @param {Object} metadata Object containing all metadata received.\n   * @param {string} [metadata.StreamTitle] Title of the metadata update.\n   * @param {string} [metadata.StreamUrl] Url (usually album art) of the metadata update.\n   * @param {number} timestampOffset Total time buffered when the metadata was added\n   * @param {number} timestamp Current time of the audio player when the metadata was added\n   *\n   */\n  constructor({ icyBr, onMetadataUpdate = noOp, onMetadataEnqueue = noOp }) {\n    this._icyBr = icyBr;\n    this._onMetadataUpdate = onMetadataUpdate;\n    this._onMetadataEnqueue = onMetadataEnqueue;\n    this._isInitialMetadata = true;\n    this._metadataQueue = [];\n  }\n\n  /**\n   * @description Returns the metadata queued for updates\n   * @type {{metadata: string, time: number}[]} Queued metadata\n   */\n  get metadataQueue() {\n    return this._metadataQueue.map(({ _timeoutId, ...rest }) => rest);\n  }\n\n  /**\n   *\n   * @param {object} metadata Metadata object returned from IcecastMetadataReader\n   * @param {number} timestampOffset Total buffered audio in seconds\n   * @param {number} [timestamp] Current time in the audio player\n   */\n  addMetadata({ metadata, stats }, timestampOffset, timestamp = 0) {\n    /**\n     * Metadata time is derived from the total number of stream bytes read\n     * since the latest buffer input. The buffer offset should be the total\n     * seconds of audio in the player buffer when the metadata was read.\n     */\n    this._enqueueMetadata(\n      metadata,\n      timestampOffset,\n      timestamp + this.getTimeByBytes(stats.currentStreamPosition)\n    );\n  }\n\n  /**\n   * @description Calculates audio stream length based on bitrate\n   * @param {number} bytesRead Number of bytes\n   * @type {number} Seconds\n   */\n  getTimeByBytes(bytesRead) {\n    return this._icyBr ? bytesRead / (this._icyBr * 125) : 0;\n  }\n\n  /**\n   * @description Clears all metadata updates and empties the queue\n   */\n  purgeMetadataQueue() {\n    this._metadataQueue.forEach((i) => clearTimeout(i._timeoutId));\n    this._metadataQueue = [];\n  }\n\n  _enqueueMetadata(metadata, timestampOffset, timestamp) {\n    const metadataPayload = {\n      metadata,\n      timestampOffset,\n      timestamp,\n    };\n\n    this._metadataQueue.push(metadataPayload);\n    this._onMetadataEnqueue(metadata, timestampOffset, timestamp);\n\n    if (this._isInitialMetadata) {\n      this._dequeueMetadata();\n      this._isInitialMetadata = false;\n    } else {\n      metadataPayload._timeoutId = setTimeout(() => {\n        this._dequeueMetadata();\n      }, (timestampOffset - timestamp) * 1000); // trigger timeout relative to play position\n    }\n  }\n\n  _dequeueMetadata() {\n    const {\n      metadata,\n      timestampOffset,\n      timestamp,\n    } = this._metadataQueue.shift();\n    this._onMetadataUpdate(metadata, timestampOffset, timestamp);\n  }\n}\n\nmodule.exports = IcecastMetadataQueue;\n","/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst MetadataParser = require(\"./MetadataParser/MetadataParser\");\nconst IcyMetadataParser = require(\"./MetadataParser/IcyMetadataParser\");\nconst OggMetadataParser = require(\"./MetadataParser/OggMetadataParser\");\nconst DualMetadataParser = require(\"./MetadataParser/DualMetadataParser\");\n\nclass IcecastMetadataReader {\n  /**\n   * @description Splits Icecast raw response into stream bytes and metadata key / value pairs.\n   * @param {number} IcecastMetadataReader.icyMetaInt Interval in bytes of metadata updates returned by the Icecast server\n   * @param {number} IcecastMetadataReader.icyDetectionTimeout Duration in milliseconds to search for metadata if icyMetaInt isn't passed in\n   * @param {Array} IcecastMetadataReader.metadataTypes Types of metadata to capture: \"icy\" and/or \"ogg\"\n   *\n   * @callback onMetadata\n   * @param {object} value Object containing Metadata and Statistics\n   * @param {object} metadata Object containing the metadata received.\n   * @param {string} [metadata.StreamTitle] (ICY) Title of the metadata update.\n   * @param {string} [metadata.StreamUrl] (ICY) Url (usually album art) of the metadata update.\n   * @param {string} [metadata.TITLE] (OGG) Url Title of the metadata update.\n   * @param {object} stats Object containing statistics on how many bytes were read and the current read position.\n   *\n   * @callback onStream\n   * @param {object} value Object containing Stream data and Statistics\n   * @param {Uint8Array} stream Object containing the stream buffer.\n   * @param {object} stats Object containing statistics on how many bytes were read and the current read position.\n   */\n  constructor({ metadataTypes = [\"icy\"], ...rest } = {}) {\n    const hasIcy = metadataTypes.includes(\"icy\");\n    const hasOgg = metadataTypes.includes(\"ogg\");\n\n    if (hasIcy && hasOgg) this._metadataParser = new DualMetadataParser(rest);\n    else if (hasOgg) this._metadataParser = new OggMetadataParser(rest);\n    else if (hasIcy) this._metadataParser = new IcyMetadataParser(rest);\n    else this._metadataParser = new MetadataParser(rest);\n  }\n\n  /**\n   * @description Parses an ICY metadata string into key value pairs.\n   * @param {string} metadataString ICY formatted metadata string. (i.e. \"StreamTitle='A Title';\")\n   * @returns {object} Parsed metadata key value pairs. (i.e. {StreamTitle: \"A Title\"})\n   */\n  static parseIcyMetadata(string) {\n    return IcyMetadataParser.parseIcyMetadata(string);\n  }\n\n  /**\n   * @description Gets the ICY metadata interval for this instance.\n   * @returns {number} ICY metadata interval in bytes.\n   */\n  get icyMetaInt() {\n    return this._metadataParser.icyMetaInt;\n  }\n\n  /**\n   * @description Returns an iterator that yields stream or metadata.\n   * @param {Uint8Array} chunk Next chunk of data to read\n   * @returns {Iterator} Iterator that operates over a raw icecast response.\n   * @yields {object} Object containing stream or metadata.\n   */\n  *iterator(chunk) {\n    yield* this._metadataParser.iterator(chunk);\n  }\n\n  /**\n   * @description Reads all data in the passed in chunk and calls the onStream and onMetadata callbacks.\n   * @param {Uint8Array} chunk Next chunk of data to read\n   */\n  readAll(chunk) {\n    this._metadataParser.readAll(chunk);\n  }\n\n  /**\n   * @description Returns an async iterator that yields stream or metadata and awaits the onStream and onMetadata callbacks.\n   * @param {Uint8Array} chunk Next chunk of data to read\n   * @returns {IterableIterator} Iterator that operates over a raw icecast response.\n   * @yields {object} Object containing stream or metadata.\n   */\n  async *asyncIterator(chunk) {\n    return yield* this._metadataParser.asyncIterator(chunk);\n  }\n\n  /**\n   * @description Reads all data in the chunk and awaits the onStream and onMetadata callbacks.\n   * @param {Uint8Array} chunk Next chunk of data to read\n   */\n  async asyncReadAll(chunk) {\n    return this._metadataParser.asyncReadAll(chunk);\n  }\n}\n\nmodule.exports = IcecastMetadataReader;\n","/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst IcecastMetadataReader = require(\"./IcecastMetadataReader\");\n\nconst noOp = () => {};\n\n/**\n * @description Browser ReadableStream wrapper for IcecastMetadataReader\n */\nclass IcecastReadableStream {\n  /**\n   * @param {ReadableStream} response ReadableStream for raw Icecast response data\n   * @param {object} options Configuration options for IcecastMetadataReader\n   * @see IcecastMetadataReader for information on the options parameter\n   */\n  constructor(response, { icyMetaInt, onStream = noOp, ...rest }) {\n    let icecast;\n\n    this._readableStream = new ReadableStream({\n      async start(controller) {\n        icecast = new IcecastMetadataReader({\n          ...rest,\n          icyMetaInt:\n            parseInt(response.headers.get(\"Icy-MetaInt\")) || icyMetaInt,\n          onStream: async (value) => {\n            controller.enqueue(value.stream);\n            return onStream(value);\n          },\n        });\n\n        for await (const chunk of IcecastReadableStream.asyncIterator(\n          response.body\n        )) {\n          await icecast.asyncReadAll(chunk);\n        }\n\n        controller.close();\n      },\n    });\n\n    this._icecast = icecast;\n  }\n\n  /**\n   * @returns Icecast Metadata Interval if it is present on this stream\n   */\n  get icyMetaInt() {\n    return this._icecast.icyMetaInt;\n  }\n\n  /**\n   * @returns The ReadableStream instance\n   */\n  get readableStream() {\n    return this._readableStream;\n  }\n\n  /**\n   * @description Starts reading from the response and processing stream and metadata.\n   */\n  async startReading() {\n    for await (const i of IcecastReadableStream.asyncIterator(\n      this._readableStream\n    )) {\n    }\n  }\n\n  /**\n   * @description Wraps a ReadableStream as an Async Iterator.\n   * @param {ReadableStream} readableStream ReadableStream to convert to AsyncIterator\n   * @returns {Symbol.asyncIterator} Async Iterator that wraps the ReadableStream\n   */\n  static asyncIterator(readableStream) {\n    const reader = readableStream.getReader();\n    return {\n      [Symbol.asyncIterator]: () => ({\n        next: () => reader.read(),\n      }),\n    };\n  }\n}\n\nmodule.exports = IcecastReadableStream;\n","/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst IcyMetadataParser = require(\"./IcyMetadataParser\");\nconst OggMetadataParser = require(\"./OggMetadataParser\");\n\n/**\n * @description Parses ICY and OGG metadata from an Icecast stream\n * @protected\n * @see IcecastMetadataReader\n */\n\nclass DualMetadataParser {\n  constructor(params) {\n    const { onStream, ...rest } = params;\n    this._oggMetadataParser = new OggMetadataParser(params);\n    this._icyMetadataParser = new IcyMetadataParser(rest);\n  }\n\n  get icyMetaInt() {\n    return this._icyMetadataParser.icyMetaInt;\n  }\n\n  *iterator(chunk) {\n    for (const value of this._icyMetadataParser.iterator(chunk)) {\n      if (value.stream) {\n        yield* this._oggMetadataParser.iterator(value.stream);\n      } else {\n        yield value;\n      }\n    }\n  }\n\n  readAll(chunk) {\n    for (const value of this._icyMetadataParser.iterator(chunk)) {\n      if (value.stream) {\n        this._oggMetadataParser.readAll(value.stream);\n      }\n    }\n  }\n\n  async *asyncIterator(chunk) {\n    for await (const value of this._icyMetadataParser.asyncIterator(chunk)) {\n      if (value.stream) {\n        for await (const oggValue of this._oggMetadataParser.asyncIterator(\n          value.stream\n        )) {\n          yield oggValue;\n        }\n      } else {\n        yield value;\n      }\n    }\n  }\n\n  async asyncReadAll(chunk) {\n    for await (const value of this._icyMetadataParser.iterator(chunk)) {\n      if (value.stream) {\n        await this._oggMetadataParser.asyncReadAll(value.stream);\n      }\n    }\n  }\n}\n\nmodule.exports = DualMetadataParser;\n","/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst MetadataParser = require(\"./MetadataParser\");\n\n/**\n * @description Parses ICY metadata from an Icecast stream\n * @protected\n * @see IcecastMetadataReader\n */\n\nclass IcyMetadataParser extends MetadataParser {\n  constructor({ icyMetaInt, icyDetectionTimeout = 2000, ...rest }) {\n    super(rest);\n\n    this._icyMetaInt = icyMetaInt;\n    this._icyDetectionTimeout = icyDetectionTimeout;\n\n    this._generator = this._icyParser();\n    this._generator.next();\n  }\n\n  *_icyParser() {\n    if (yield* this._hasIcyMetadata()) {\n      do {\n        this._remainingData = this._icyMetaInt;\n        yield* this._getStream();\n        yield* this._getMetadataLength();\n        if (this._remainingData) yield* this._getMetadata();\n      } while (true);\n    }\n\n    this._remainingData = Infinity;\n    yield* this._getStream();\n  }\n\n  static parseIcyMetadata(metadataString) {\n    /**\n     * Metadata is a string of key='value' pairs delimited by a semicolon.\n     * The string is a fixed length and any unused bytes at the end are 0x00.\n     * i.e. \"StreamTitle='The Stream Title';StreamUrl='https://example.com';\\0\\0\\0\\0\\0\\0\"\n     */\n\n    const metadataRegex = /(?<key>[^\\0]+?)='(?<val>[^\\0]*?)(;$|';|'$|$)/;\n    const metadata = {};\n\n    // [{key: \"StreamTitle\", val: \"The Stream Title\"}, {key: \"StreamUrl\", val: \"https://example.com\"}]\n    for (const metadataElement of metadataString.match(\n      new RegExp(metadataRegex, \"g\")\n    ) || []) {\n      const match = metadataElement.match(metadataRegex);\n      if (match) metadata[match[\"groups\"][\"key\"]] = match[\"groups\"][\"val\"];\n    }\n\n    // {StreamTitle: \"The Stream Title\", StreamUrl: \"https://example.com\"}\n    return metadata;\n  }\n\n  get icyMetaInt() {\n    return this._icyMetaInt;\n  }\n\n  *_hasIcyMetadata() {\n    if (this._icyMetaInt > 0) return true;\n    if (!this._icyDetectionTimeout) return false;\n\n    this._logError(\n      \"Passed in Icy-MetaInt is invalid. Attempting to detect ICY Metadata.\",\n      \"See https://github.com/eshaz/icecast-metadata-js for information on how to properly request ICY Metadata.\"\n    );\n\n    // prettier-ignore\n    const METADATA_SEARCH = [null,83,116,114,101,97,109,84,105,116,108,101,61]; // StreamTitle=\n    const startTime = Date.now();\n    let metaInt = 0;\n\n    while (startTime + this._icyDetectionTimeout > Date.now()) {\n      this._buffer = MetadataParser._concatBuffers(\n        this._buffer,\n        yield* this._readData()\n      );\n\n      // search for metadata\n      detectMetadata: while (\n        metaInt <\n        this._buffer.length - METADATA_SEARCH.length\n      ) {\n        for (let i = 1; i < METADATA_SEARCH.length; i++) {\n          if (this._buffer[i + metaInt] !== METADATA_SEARCH[i]) {\n            metaInt++;\n            continue detectMetadata;\n          }\n        }\n\n        // found metadata\n        // prettier-ignore\n        this._logError(`Found ICY Metadata! Setting Icy-MetaInt to ${metaInt}.`);\n        this._icyMetaInt = metaInt;\n\n        return true;\n      }\n    }\n\n    // prettier-ignore\n    this._logError(\n      \"ICY Metadata not detected, but continuing anyway. Audio errors will occur if there is ICY metadata.\",\n      `Searched ${this._buffer.length} bytes for ${(Date.now() - startTime) / 1000} seconds.`,\n      \"Try increasing the `icyDetectionTimeout` value if ICY metadata is present in the stream.\"\n    );\n    return false;\n  }\n\n  *_getStream() {\n    this._stats.currentStreamBytesRemaining = this._remainingData;\n\n    while (this._remainingData) {\n      yield* this._sendStream(yield* super._getNextValue());\n    }\n  }\n\n  *_getMetadataLength() {\n    this._remainingData = 1;\n\n    do {\n      this._remainingData = (yield* this._getNextValue())[0] * 16;\n    } while (this._remainingData === 1);\n\n    this._stats.addMetadataLengthBytes(1);\n  }\n\n  *_getMetadata() {\n    this._stats.currentMetadataBytesRemaining = this._remainingData;\n\n    const metadata = yield* this._getNextValue(this._remainingData);\n    this._stats.addMetadataBytes(metadata.length);\n\n    yield* this._sendMetadata(\n      IcyMetadataParser.parseIcyMetadata(this._decoder.decode(metadata))\n    );\n  }\n}\n\nmodule.exports = IcyMetadataParser;\n","/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst Decoder = require(\"util\").TextDecoder || TextDecoder;\nconst Stats = require(\"./Stats\");\n\nconst noOp = () => {};\n\n/**\n * @description Passthrough parser\n * @protected\n * @see IcecastMetadataReader\n */\n\nclass MetadataParser {\n  constructor(params) {\n    this._remainingData = 0;\n    this._currentPosition = 0;\n    this._buffer = new Uint8Array(0);\n    this._stats = new Stats();\n    this._decoder = new Decoder(\"utf-8\");\n\n    this._onStream = params.onStream || noOp;\n    this._onMetadata = params.onMetadata || noOp;\n    this._onError = params.onError || noOp;\n    this._enableLogging = params.enableLogging || false;\n\n    this._onStreamPromise = Promise.resolve();\n    this._onMetadataPromise = Promise.resolve();\n    this._generator = this._passThroughParser();\n    this._generator.next();\n  }\n\n  *_passThroughParser() {\n    this._remainingData = Infinity;\n    while (true) {\n      yield* this._sendStream(yield* this._getNextValue());\n    }\n  }\n\n  static _concatBuffers(buf1, buf2) {\n    const result = new Uint8Array(buf1.length + buf2.length);\n    result.set(buf1);\n    result.set(buf2, buf1.length);\n    return result;\n  }\n\n  *iterator(chunk) {\n    for (\n      let i = this._generator.next(chunk);\n      i.value;\n      i = this._generator.next()\n    ) {\n      yield i.value;\n    }\n  }\n\n  readAll(chunk) {\n    for (\n      let i = this._generator.next(chunk);\n      i.value;\n      i = this._generator.next()\n    ) {}\n  }\n\n  async *asyncIterator(chunk) {\n    for (\n      let i = this._generator.next(chunk);\n      i.value;\n      i = this._generator.next()\n    ) {\n      await this._onStreamPromise;\n      await this._onMetadataPromise;\n      yield i.value;\n    }\n  }\n\n  async asyncReadAll(chunk) {\n    for (\n      let i = this._generator.next(chunk);\n      i.value;\n      i = this._generator.next()\n    ) {\n      await this._onStreamPromise;\n      await this._onMetadataPromise;\n    }\n  }\n\n  _logError(...messages) {\n    if (this._enableLogging) {\n      console.warn(\n        \"icecast-metadata-js\",\n        messages.reduce((acc, message) => acc + \"\\n  \" + message, \"\")\n      );\n    }\n    this._onError(...messages);\n  }\n\n  *_sendStream(stream) {\n    this._stats.addStreamBytes(stream.length);\n\n    const streamPayload = { stream, stats: this._stats.stats };\n\n    this._onStreamPromise = this._onStream(streamPayload);\n    yield streamPayload;\n  }\n\n  *_sendMetadata(metadata) {\n    const metadataPayload = {\n      metadata,\n      stats: this._stats.stats,\n    };\n\n    this._onMetadataPromise = this._onMetadata(metadataPayload);\n    yield metadataPayload;\n  }\n\n  *_getNextValue(minLength = 0) {\n    if (this._currentPosition === this._buffer.length) {\n      this._buffer = yield* this._readData();\n      this._currentPosition = 0;\n    }\n\n    while (this._buffer.length - this._currentPosition < minLength) {\n      this._buffer = MetadataParser._concatBuffers(\n        this._buffer,\n        yield* this._readData()\n      );\n    }\n\n    const value = this._buffer.subarray(\n      this._currentPosition,\n      (minLength || this._remainingData) + this._currentPosition\n    );\n\n    this._stats.addBytes(value.length);\n    this._remainingData =\n      value.length < this._remainingData\n        ? this._remainingData - value.length\n        : 0;\n\n    this._currentPosition += value.length;\n\n    return value;\n  }\n\n  *_readData() {\n    let data;\n\n    do {\n      data = yield; // if out of data, accept new data in the .next() call\n    } while (!data || data.length === 0);\n\n    this._stats.addCurrentBytesRemaining(data.length);\n    return data;\n  }\n}\n\nmodule.exports = MetadataParser;\n","/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst MetadataParser = require(\"./MetadataParser\");\n\n/**\n * @description Parses OGG metadata from an Icecast stream\n * @protected\n * @see IcecastMetadataReader\n */\nclass OggMetadataParser extends MetadataParser {\n  constructor(params) {\n    super(params);\n\n    this._generator = this._oggParser();\n    this._generator.next();\n  }\n\n  *_oggParser() {\n    if (yield* this._hasOggPage()) {\n      const codecMatcher = yield* this._identifyCodec();\n      if (codecMatcher) {\n        while (yield* this._hasOggPage()) {\n          yield* this._getMetadata(codecMatcher);\n          yield* this._getStream();\n        }\n      }\n    }\n\n    this._remainingData = Infinity;\n    yield* this._getStream();\n  }\n\n  _getUint32(data, offset = 0) {\n    return new DataView(\n      Uint8Array.from([...data.subarray(offset, offset + 4)]).buffer\n    ).getUint32(0, true);\n  }\n\n  _matchBytes(matchString, bytes) {\n    return String.fromCharCode(...bytes).match(matchString);\n  }\n\n  *_hasOggPage() {\n    // Bytes (1-4 of 28)\n    // Frame sync (must equal OggS): `AAAAAAAA|AAAAAAAA|AAAAAAAA|AAAAAAAA`:\n    // Byte (6 of 28)\n    // * `00000...`: All zeros\n    let syncBytes = [];\n    while (syncBytes.length <= 65307) {\n      // max ogg page size\n      const bytes = yield* super._getNextValue(5); // Sync with OGG page without sending stream data\n      if (\n        bytes[0] === 0x4f &&\n        bytes[1] === 0x67 &&\n        bytes[2] === 0x67 &&\n        bytes[3] === 0x53 &&\n        !(bytes[5] & 0b11111000)\n      ) {\n        this._currentPosition -= 5;\n        this._remainingData += 5;\n        this._stats._totalBytesRead -= 5;\n        this._stats._currentBytesRemaining += 5;\n        break;\n      }\n      syncBytes.push(bytes[0]);\n\n      this._currentPosition -= 4;\n      this._stats._totalBytesRead -= 4;\n      this._stats._currentBytesRemaining += 4;\n    }\n\n    if (syncBytes.length) yield* this._sendStream(Uint8Array.from(syncBytes));\n\n    if (syncBytes.length > 65307) {\n      this._logError(\n        \"This stream is not an OGG stream. No OGG metadata will be returned.\",\n        \"See https://github.com/eshaz/icecast-metadata-js for information on OGG metadata.\"\n      );\n      return false;\n    }\n\n    const baseOggPage = yield* this._getNextValue(27);\n    // Byte (27 of 28)\n    // * `JJJJJJJJ`: Number of page segments in the segment table\n    const oggPageSegments = yield* this._getNextValue(baseOggPage[26]);\n\n    this._remainingData = oggPageSegments.reduce(\n      (acc, octet) => acc + octet,\n      0\n    );\n    return true;\n  }\n\n  *_identifyCodec() {\n    const data = yield* this._getNextValue(8);\n\n    yield* this._getStream();\n\n    if (this._matchBytes(/\\x7fFLAC/, data.subarray(0, 5))) {\n      return { regex: /^[\\x84|\\x04]/, length: 4 };\n    } else if (this._matchBytes(/OpusHead/, data.subarray(0, 8))) {\n      return { regex: /OpusTags/, length: 8 };\n    } else if (this._matchBytes(/\\x01vorbis/, data.subarray(0, 7))) {\n      return { regex: /\\x03vorbis/, length: 7 };\n    }\n  }\n\n  *_getMetadata({ regex, length }) {\n    if (this._matchBytes(regex, yield* this._getNextValue(length))) {\n      yield* this._sendMetadata(yield* this._readVorbisComment());\n    }\n  }\n\n  *_getStream() {\n    while (this._remainingData) {\n      yield* this._getNextValue();\n    }\n  }\n\n  *_getNextValue(length) {\n    const value = yield* super._getNextValue(length);\n\n    yield* this._sendStream(value);\n    return value;\n  }\n\n  *_readData() {\n    const data = yield* super._readData();\n    this._stats.currentStreamBytesRemaining = data.length;\n    return data;\n  }\n\n  *_readVorbisComment() {\n    /*\n    1) [vendor_length] = read an unsigned integer of 32 bits\n    2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets\n    3) [user_comment_list_length] = read an unsigned integer of 32 bits\n    4) iterate [user_comment_list_length] times {\n       5) [length] = read an unsigned integer of 32 bits\n       6) this iteration's user comment = read a UTF-8 vector as [length] octets\n    }\n    7) [framing_bit] = read a single bit as boolean\n    8) if ( [framing_bit] unset or end of packet ) then ERROR\n    9) done.\n    */\n    const vendorStringLength = this._getUint32(yield* this._getNextValue(4));\n    this._stats.addMetadataBytes(4);\n\n    const vendorString = this._decoder.decode(\n      yield* this._getNextValue(vendorStringLength)\n    );\n    this._stats.addMetadataBytes(vendorStringLength);\n\n    const commentListLength = this._getUint32(yield* this._getNextValue(4));\n    this._stats.addMetadataBytes(4);\n\n    const comments = [];\n    for (let i = 0; i < commentListLength; i++) {\n      const commentLength = yield* this._getNextValue(4);\n      this._stats.addMetadataBytes(4);\n\n      comments.push(yield* this._getNextValue(this._getUint32(commentLength)));\n      this._stats.addMetadataBytes(comments[comments.length - 1].length);\n    }\n\n    this._stats.currentMetadataBytesRemaining = 0;\n\n    return comments.reduce(\n      (metadata, comment) => {\n        const delimiter = comment.indexOf(0x3d);\n        // prettier-ignore\n        const key = String.fromCharCode(...comment.subarray(0, delimiter)).toUpperCase();\n        const val = this._decoder.decode(comment.subarray(delimiter + 1));\n\n        metadata[key] = metadata[key] ? `${metadata[key]}; ${val}` : val;\n        return metadata;\n      },\n      { VENDOR_STRING: vendorString }\n    );\n  }\n}\n\nmodule.exports = OggMetadataParser;\n","/* Copyright 2020 Ethan Halsall\n    This file is part of icecast-metadata-js.\n\n    icecast-metadata-js free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    icecast-metadata-js distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nclass Stats {\n  constructor() {\n    this._totalBytesRead = 0;\n    this._streamBytesRead = 0;\n    this._metadataLengthBytesRead = 0;\n    this._metadataBytesRead = 0;\n\n    this._currentBytesRemaining = 0;\n    this._currentStreamBytesRemaining = 0;\n    this._currentMetadataBytesRemaining = 0;\n  }\n\n  get stats() {\n    return {\n      totalBytesRead: this._totalBytesRead,\n      streamBytesRead: this._streamBytesRead,\n      metadataLengthBytesRead: this._metadataLengthBytesRead,\n      metadataBytesRead: this._metadataBytesRead,\n      currentBytesRemaining: this._currentBytesRemaining,\n      currentStreamBytesRemaining: this._currentStreamBytesRemaining,\n      currentMetadataBytesRemaining: this._currentMetadataBytesRemaining,\n    };\n  }\n\n  set currentStreamBytesRemaining(bytes) {\n    this._currentStreamBytesRemaining += bytes;\n  }\n\n  set currentMetadataBytesRemaining(bytes) {\n    this._currentMetadataBytesRemaining = bytes;\n  }\n\n  addBytes(bytes) {\n    this._totalBytesRead += bytes;\n    this._currentBytesRemaining -= bytes;\n  }\n\n  addStreamBytes(bytes) {\n    this._streamBytesRead += bytes;\n    this._currentStreamBytesRemaining -= bytes;\n  }\n\n  addMetadataLengthBytes(bytes) {\n    this._metadataLengthBytesRead += bytes;\n  }\n\n  addMetadataBytes(bytes) {\n    this._metadataBytesRead += bytes;\n    this._currentMetadataBytesRemaining -= bytes;\n  }\n\n  addCurrentBytesRemaining(bytes) {\n    this._currentBytesRemaining += bytes;\n  }\n}\n\nmodule.exports = Stats;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// support for Safari 13\n// https://stackoverflow.com/a/58209729/14911733\n\nexport default class EventTargetPolyfill {\n  constructor() {\n    this._listeners = [];\n  }\n\n  hasEventListener(type, listener) {\n    return this._listeners.some(\n      (item) => item.type === type && item.listener === listener\n    );\n  }\n\n  addEventListener(type, listener, options = {}) {\n    if (!this.hasEventListener(type, listener)) {\n      this._listeners.push({ type, listener, options });\n    }\n    // console.log(`${this}-listeners:`,this._listeners);\n    return this;\n  }\n\n  removeEventListener(type, listener) {\n    const index = this._listeners.findIndex(\n      (item) => item.type === type && item.listener === listener\n    );\n    if (index >= 0) this._listeners.splice(index, 1);\n    return this;\n  }\n\n  removeEventListeners() {\n    this._listeners = [];\n    return this;\n  }\n\n  dispatchEvent(evt) {\n    this._listeners\n      .filter((item) => item.type === evt.type)\n      .forEach((item) => {\n        const {\n          type,\n          listener,\n          options: { once },\n        } = item;\n        listener.call(this, evt);\n        if (once === true) this.removeEventListener(type, listener);\n      });\n    return this;\n  }\n}\n","export default class Player {\n  constructor(options) {\n    this._icecast = options.icecast;\n    this._audioElement = options.audioElement;\n    this._endpoint = options.endpoint;\n    this._hasIcy = options.hasIcy;\n    this._enableLogging = options.enableLogging;\n    this._icecastMetadataQueue = options.icecastMetadataQueue;\n    this._fireEvent = options.fireEvent;\n    this._state = options.state;\n    this._events = options.events;\n  }\n\n  async fetchStream(abortController) {\n    const res = await fetch(this._endpoint, {\n      method: \"GET\",\n      headers: this._hasIcy ? { \"Icy-MetaData\": 1 } : {},\n      signal: abortController.signal,\n    });\n\n    if (!res.ok) {\n      const error = new Error(`${res.status} received from ${res.url}`);\n      error.name = \"HTTP Response Error\";\n      throw error;\n    }\n\n    return res;\n  }\n\n  getOnMetadata() {\n    return (value) => {\n      this._icecastMetadataQueue.addMetadata(\n        value,\n        this.metadataTimestamp,\n        this._audioElement.currentTime\n      );\n    };\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst logError = (...messages) => {\n  console.error(\n    \"codec-parser\",\n    messages.reduce((acc, message) => acc + \"\\n  \" + message, \"\")\n  );\n};\n\n// https://pycrc.org/\n\n// prettier-ignore\nconst crc8Table = new Int32Array([\n  0x00,0x07,0x0e,0x09,0x1c,0x1b,0x12,0x15,0x38,0x3f,0x36,0x31,0x24,0x23,0x2a,0x2d,\n  0x70,0x77,0x7e,0x79,0x6c,0x6b,0x62,0x65,0x48,0x4f,0x46,0x41,0x54,0x53,0x5a,0x5d,\n  0xe0,0xe7,0xee,0xe9,0xfc,0xfb,0xf2,0xf5,0xd8,0xdf,0xd6,0xd1,0xc4,0xc3,0xca,0xcd,\n  0x90,0x97,0x9e,0x99,0x8c,0x8b,0x82,0x85,0xa8,0xaf,0xa6,0xa1,0xb4,0xb3,0xba,0xbd,\n  0xc7,0xc0,0xc9,0xce,0xdb,0xdc,0xd5,0xd2,0xff,0xf8,0xf1,0xf6,0xe3,0xe4,0xed,0xea,\n  0xb7,0xb0,0xb9,0xbe,0xab,0xac,0xa5,0xa2,0x8f,0x88,0x81,0x86,0x93,0x94,0x9d,0x9a,\n  0x27,0x20,0x29,0x2e,0x3b,0x3c,0x35,0x32,0x1f,0x18,0x11,0x16,0x03,0x04,0x0d,0x0a,\n  0x57,0x50,0x59,0x5e,0x4b,0x4c,0x45,0x42,0x6f,0x68,0x61,0x66,0x73,0x74,0x7d,0x7a,\n  0x89,0x8e,0x87,0x80,0x95,0x92,0x9b,0x9c,0xb1,0xb6,0xbf,0xb8,0xad,0xaa,0xa3,0xa4,\n  0xf9,0xfe,0xf7,0xf0,0xe5,0xe2,0xeb,0xec,0xc1,0xc6,0xcf,0xc8,0xdd,0xda,0xd3,0xd4,\n  0x69,0x6e,0x67,0x60,0x75,0x72,0x7b,0x7c,0x51,0x56,0x5f,0x58,0x4d,0x4a,0x43,0x44,\n  0x19,0x1e,0x17,0x10,0x05,0x02,0x0b,0x0c,0x21,0x26,0x2f,0x28,0x3d,0x3a,0x33,0x34,\n  0x4e,0x49,0x40,0x47,0x52,0x55,0x5c,0x5b,0x76,0x71,0x78,0x7f,0x6a,0x6d,0x64,0x63,\n  0x3e,0x39,0x30,0x37,0x22,0x25,0x2c,0x2b,0x06,0x01,0x08,0x0f,0x1a,0x1d,0x14,0x13,\n  0xae,0xa9,0xa0,0xa7,0xb2,0xb5,0xbc,0xbb,0x96,0x91,0x98,0x9f,0x8a,0x8d,0x84,0x83,\n  0xde,0xd9,0xd0,0xd7,0xc2,0xc5,0xcc,0xcb,0xe6,0xe1,0xe8,0xef,0xfa,0xfd,0xf4,0xf3\n]);\n\nconst crc8 = (buf) => {\n  let crc;\n\n  for (const byte of buf) {\n    crc = crc8Table[(crc ^ byte) & 0xff] & 0xff;\n  }\n\n  return crc;\n};\n\nconst concatBuffers = (...buffers) => {\n  const buffer = new Uint8Array(\n    buffers.reduce((acc, buf) => acc + buf.length, 0)\n  );\n\n  buffers.reduce((offset, buf) => {\n    buffer.set(buf, offset);\n    return offset + buf.length;\n  }, 0);\n\n  return buffer;\n};\n\n// prettier-ignore\nconst reverseTable = [0x0,0x8,0x4,0xc,0x2,0xa,0x6,0xe,0x1,0x9,0x5,0xd,0x3,0xb,0x7,0xf];\nconst reverse = (val) =>\n  (reverseTable[val & 0b1111] << 4) | reverseTable[val >> 4];\n\nclass BitReader {\n  constructor(data) {\n    this._data = data;\n    this._pos = data.length * 8;\n  }\n\n  set position(position) {\n    this._pos = position;\n  }\n\n  get position() {\n    return this._pos;\n  }\n\n  read(bits) {\n    const byte = Math.floor(this._pos / 8);\n    const bit = this._pos % 8;\n    this._pos -= bits;\n\n    const window =\n      (reverse(this._data[byte - 1]) << 8) + reverse(this._data[byte]);\n\n    return (window >> (7 - bit)) & 0xff;\n  }\n}\n\nexport { crc8, reverse, logError, concatBuffers, BitReader };\n","export const isParsedStore = new WeakMap();\nexport const headerStore = new WeakMap();\nexport const frameStore = new WeakMap();\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nexport default class HeaderCache {\n  constructor(onCodecUpdate) {\n    this._onCodecUpdate = onCodecUpdate;\n    this.reset();\n  }\n\n  static getKey(bytes) {\n    return String.fromCharCode(...bytes);\n  }\n\n  enable() {\n    this._isEnabled = true;\n  }\n\n  reset() {\n    this._headerCache = new Map();\n    this._codecUpdateData = new WeakMap();\n    this._isEnabled = false;\n  }\n\n  getHeader(key) {\n    const header = this._headerCache.get(key);\n\n    if (header) {\n      if (key !== this._currentHeader) {\n        this._currentHeader = key;\n        this._onCodecUpdate({ ...this._codecUpdateData.get(header) });\n      }\n    }\n\n    return header;\n  }\n\n  setHeader(key, header, codecUpdateFields) {\n    if (this._isEnabled) {\n      if (key !== this._currentHeader) {\n        this._currentHeader = key;\n        this._onCodecUpdate({ ...codecUpdateFields });\n      }\n\n      this._headerCache.set(key, header);\n      this._codecUpdateData.set(header, codecUpdateFields);\n    }\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { isParsedStore, frameStore } from \"../globals\";\nimport HeaderCache from \"./HeaderCache\";\n\n/**\n * @abstract\n * @description Abstract class containing methods for parsing codec frames\n */\nexport default class Parser {\n  constructor(onCodecUpdate) {\n    this._headerCache = new HeaderCache(onCodecUpdate);\n  }\n\n  syncFrame(data, remainingData = 0) {\n    let frame = new this.Frame(data.subarray(remainingData), this._headerCache);\n\n    while (\n      !frame.header &&\n      remainingData + this._maxHeaderLength < data.length\n    ) {\n      remainingData += frameStore.get(frame).length || 1;\n      frame = new this.Frame(data.subarray(remainingData), this._headerCache);\n    }\n\n    return { frame, remainingData };\n  }\n\n  /**\n   * @description Searches without as much sync logic for more resilient framing\n   * @param {Uint8Array} data Codec data that should contain a sequence of known length frames.\n   * @returns {object} Object containing the actual offset and frame. Frame is undefined if no valid header was found\n   */\n  fixedLengthFrame(data) {\n    return this.fixedLengthFrameSync(data, false);\n  }\n\n  /**\n   * @description Searches for Frames within bytes containing a sequence of known codec frames.\n   * @param {Uint8Array} data Codec data that should contain a sequence of known length frames.\n   * @returns {object} Object containing the actual offset and frame. Frame is undefined if no valid header was found\n   */\n  fixedLengthFrameSync(data, sync = true) {\n    // initial sync\n    let { frame, remainingData } = this.syncFrame(data);\n    let frames = [];\n\n    while (\n      isParsedStore.get(frame.header) && // was there enough data to parse the header\n      frameStore.get(frame).length + remainingData + this._maxHeaderLength <\n        data.length // is there enough data left to form a frame and check the next frame\n    ) {\n      // check if there is a valid frame immediately after this frame\n      const nextFrame = new this.Frame(\n        data.subarray(frameStore.get(frame).length + remainingData),\n        this._headerCache\n      );\n\n      if (nextFrame.header || !sync) {\n        // start caching when synced\n        this._headerCache.enable();\n        // there is a next frame, so the current frame is valid\n        frames.push(frame);\n        remainingData += frameStore.get(frame).length;\n        frame = nextFrame;\n\n        if (!isParsedStore.get(frame.header)) break; // out of data\n      } else {\n        // frame is invalid and must re-sync and clear cache\n        this._headerCache.reset();\n        remainingData++; // increment to invalidate the invalid frame\n        const syncResult = this.syncFrame(data, remainingData);\n        remainingData += syncResult.remainingData;\n        frame = syncResult.frame;\n      }\n    }\n\n    return {\n      frames,\n      remainingData,\n    };\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { frameStore } from \"../globals\";\n\nexport default class Frame {\n  constructor(header, data, samples) {\n    this.data = data || [];\n    this.header = header;\n    this.samples = samples;\n    this.duration =\n      header && samples && (this.samples / this.header.sampleRate) * 1000;\n    this.frameNumber = undefined;\n    this.totalBytesOut = undefined;\n    this.totalSamples = undefined;\n    this.totalDuration = undefined;\n\n    frameStore.set(this, { length: this.data.length });\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { headerStore, isParsedStore } from \"../globals\";\n\nexport default class Header {\n  /**\n   * @private\n   */\n  constructor(header, isParsed) {\n    headerStore.set(this, header);\n    isParsedStore.set(this, isParsed);\n\n    this.bitDepth = header.bitDepth;\n    this.channels = header.channels;\n    this.sampleRate = header.sampleRate;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Header from \"../Header\";\nimport HeaderCache from \"../HeaderCache\";\n\n// http://www.mp3-tech.org/programmer/frame_header.html\n\nconst bitrateMatrix = {\n  // bits | V1,L1 | V1,L2 | V1,L3 | V2,L1 | V2, L2 & L3\n  0b00000000: [\"free\", \"free\", \"free\", \"free\", \"free\"],\n  0b00010000: [32, 32, 32, 32, 8],\n  0b00100000: [64, 48, 40, 48, 16],\n  0b00110000: [96, 56, 48, 56, 24],\n  0b01000000: [128, 64, 56, 64, 32],\n  0b01010000: [160, 80, 64, 80, 40],\n  0b01100000: [192, 96, 80, 96, 48],\n  0b01110000: [224, 112, 96, 112, 56],\n  0b10000000: [256, 128, 112, 128, 64],\n  0b10010000: [288, 160, 128, 144, 80],\n  0b10100000: [320, 192, 160, 160, 96],\n  0b10110000: [352, 224, 192, 176, 112],\n  0b11000000: [384, 256, 224, 192, 128],\n  0b11010000: [416, 320, 256, 224, 144],\n  0b11100000: [448, 384, 320, 256, 160],\n  0b11110000: [\"bad\", \"bad\", \"bad\", \"bad\", \"bad\"],\n};\n\nconst v1Layer1 = 0;\nconst v1Layer2 = 1;\nconst v1Layer3 = 2;\nconst v2Layer1 = 3;\nconst v2Layer23 = 4;\n\nconst layer12ModeExtensions = {\n  0b00000000: \"bands 4 to 31\",\n  0b00010000: \"bands 8 to 31\",\n  0b00100000: \"bands 12 to 31\",\n  0b00110000: \"bands 16 to 31\",\n};\n\nconst layer3ModeExtensions = {\n  0b00000000: \"Intensity stereo off, MS stereo off\",\n  0b00010000: \"Intensity stereo on, MS stereo off\",\n  0b00100000: \"Intensity stereo off, MS stereo on\",\n  0b00110000: \"Intensity stereo on, MS stereo on\",\n};\n\nconst layers = {\n  0b00000000: { description: \"reserved\" },\n  0b00000010: {\n    description: \"Layer III\",\n    framePadding: 1,\n    modeExtensions: layer3ModeExtensions,\n    v1: {\n      bitrateIndex: v1Layer3,\n      samples: 1152,\n    },\n    v2: {\n      bitrateIndex: v2Layer23,\n      samples: 576,\n    },\n  },\n  0b00000100: {\n    description: \"Layer II\",\n    framePadding: 1,\n    modeExtensions: layer12ModeExtensions,\n    samples: 1152,\n    v1: {\n      bitrateIndex: v1Layer2,\n    },\n    v2: {\n      bitrateIndex: v2Layer23,\n    },\n  },\n  0b00000110: {\n    description: \"Layer I\",\n    framePadding: 4,\n    modeExtensions: layer12ModeExtensions,\n    samples: 384,\n    v1: {\n      bitrateIndex: v1Layer1,\n    },\n    v2: {\n      bitrateIndex: v2Layer1,\n    },\n  },\n};\n\nconst mpegVersions = {\n  0b00000000: {\n    description: \"MPEG Version 2.5 (later extension of MPEG 2)\",\n    layers: \"v2\",\n    sampleRates: {\n      0b00000000: 11025,\n      0b00000100: 12000,\n      0b00001000: 8000,\n      0b00001100: \"reserved\",\n    },\n  },\n  0b00001000: { description: \"reserved\" },\n  0b00010000: {\n    description: \"MPEG Version 2 (ISO/IEC 13818-3)\",\n    layers: \"v2\",\n    sampleRates: {\n      0b00000000: 22050,\n      0b00000100: 24000,\n      0b00001000: 16000,\n      0b00001100: \"reserved\",\n    },\n  },\n  0b00011000: {\n    description: \"MPEG Version 1 (ISO/IEC 11172-3)\",\n    layers: \"v1\",\n    sampleRates: {\n      0b00000000: 44100,\n      0b00000100: 48000,\n      0b00001000: 32000,\n      0b00001100: \"reserved\",\n    },\n  },\n};\n\nconst protection = {\n  0b00000000: \"16bit CRC\",\n  0b00000001: \"none\",\n};\n\nconst emphasis = {\n  0b00000000: \"none\",\n  0b00000001: \"50/15 ms\",\n  0b00000010: \"reserved\",\n  0b00000011: \"CCIT J.17\",\n};\n\nconst channelModes = {\n  0b00000000: { channels: 2, description: \"Stereo\" },\n  0b01000000: { channels: 2, description: \"Joint stereo\" },\n  0b10000000: { channels: 2, description: \"Dual channel\" },\n  0b11000000: { channels: 1, description: \"Single channel (Mono)\" },\n};\n\nexport default class MPEGHeader extends Header {\n  static getHeader(data, headerCache) {\n    const header = {};\n    // Must be at least four bytes.\n    if (data.length < 4) return new MPEGHeader(header, false);\n\n    // Check header cache\n    const key = HeaderCache.getKey(data.subarray(0, 4));\n    const cachedHeader = headerCache.getHeader(key);\n    if (cachedHeader) return new MPEGHeader(cachedHeader, true);\n\n    // Frame sync (all bits must be set): `11111111|111`:\n    if (data[0] !== 0xff || data[1] < 0xe0) return null;\n\n    // Byte (2 of 4)\n    // * `111BBCCD`\n    // * `...BB...`: MPEG Audio version ID\n    // * `.....CC.`: Layer description\n    // * `.......D`: Protection bit (0 - Protected by CRC (16bit CRC follows header), 1 = Not protected)\n    const mpegVersionBits = data[1] & 0b00011000;\n    const layerBits = data[1] & 0b00000110;\n    const protectionBit = data[1] & 0b00000001;\n\n    header.length = 4;\n\n    // Mpeg version (1, 2, 2.5)\n    const mpegVersion = mpegVersions[mpegVersionBits];\n    if (mpegVersion.description === \"reserved\") return null;\n\n    // Layer (I, II, III)\n    if (layers[layerBits].description === \"reserved\") return null;\n    const layer = {\n      ...layers[layerBits],\n      ...layers[layerBits][mpegVersion.layers],\n    };\n\n    header.mpegVersion = mpegVersion.description;\n    header.layer = layer.description;\n    header.samples = layer.samples;\n    header.protection = protection[protectionBit];\n\n    // Byte (3 of 4)\n    // * `EEEEFFGH`\n    // * `EEEE....`: Bitrate index. 1111 is invalid, everything else is accepted\n    // * `....FF..`: Sample rate\n    // * `......G.`: Padding bit, 0=frame not padded, 1=frame padded\n    // * `.......H`: Private bit.\n    const bitrateBits = data[2] & 0b11110000;\n    const sampleRateBits = data[2] & 0b00001100;\n    const paddingBit = data[2] & 0b00000010;\n    const privateBit = data[2] & 0b00000001;\n\n    header.bitrate = bitrateMatrix[bitrateBits][layer.bitrateIndex];\n    if (header.bitrate === \"bad\") return null;\n\n    header.sampleRate = mpegVersion.sampleRates[sampleRateBits];\n    if (header.sampleRate === \"reserved\") return null;\n\n    header.framePadding = paddingBit >> 1 && layer.framePadding;\n    header.isPrivate = !!privateBit;\n\n    header.frameLength = Math.floor(\n      (125 * header.bitrate * header.samples) / header.sampleRate +\n        header.framePadding\n    );\n    if (!header.frameLength) return null;\n\n    // Byte (4 of 4)\n    // * `IIJJKLMM`\n    // * `II......`: Channel mode\n    // * `..JJ....`: Mode extension (only if joint stereo)\n    // * `....K...`: Copyright\n    // * `.....L..`: Original\n    // * `......MM`: Emphasis\n    const channelModeBits = data[3] & 0b11000000;\n    const modeExtensionBits = data[3] & 0b00110000;\n    const copyrightBit = data[3] & 0b00001000;\n    const originalBit = data[3] & 0b00000100;\n    const emphasisBits = data[3] & 0b00000011;\n\n    header.channelMode = channelModes[channelModeBits].description;\n    header.channels = channelModes[channelModeBits].channels;\n    header.modeExtension = layer.modeExtensions[modeExtensionBits];\n    header.isCopyrighted = !!(copyrightBit >> 3);\n    header.isOriginal = !!(originalBit >> 2);\n\n    header.emphasis = emphasis[emphasisBits];\n    if (header.emphasis === \"reserved\") return null;\n\n    header.bitDepth = 16;\n\n    // set header cache\n    const { length, frameLength, samples, ...codecUpdateFields } = header;\n\n    headerCache.setHeader(key, header, codecUpdateFields);\n    return new MPEGHeader(header, true);\n  }\n\n  /**\n   * @private\n   * Call MPEGHeader.getHeader(Array<Uint8>) to get instance\n   */\n  constructor(header, isParsed) {\n    super(header, isParsed);\n\n    this.bitrate = header.bitrate;\n    this.channelMode = header.channelMode;\n    this.emphasis = header.emphasis;\n    this.framePadding = header.framePadding;\n    this.isCopyrighted = header.isCopyrighted;\n    this.isOriginal = header.isOriginal;\n    this.isPrivate = header.isPrivate;\n    this.layer = header.layer;\n    this.modeExtension = header.modeExtension;\n    this.mpegVersion = header.mpegVersion;\n    this.protection = header.protection;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { headerStore } from \"../../globals\";\nimport Frame from \"../Frame\";\nimport MPEGHeader from \"./MPEGHeader\";\n\nexport default class MPEGFrame extends Frame {\n  constructor(data, headerCache) {\n    const header = MPEGHeader.getHeader(data, headerCache);\n\n    super(\n      header,\n      header && data.subarray(0, headerStore.get(header).frameLength),\n      header && headerStore.get(header).samples\n    );\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Parser from \"../Parser\";\nimport MPEGFrame from \"./MPEGFrame\";\n\nexport default class MPEGParser extends Parser {\n  constructor(onCodecUpdate, onCodec) {\n    super(onCodecUpdate);\n    this.Frame = MPEGFrame;\n    this._maxHeaderLength = 4;\n\n    onCodec(this.codec);\n  }\n\n  get codec() {\n    return \"mpeg\";\n  }\n\n  parseFrames(data) {\n    return this.fixedLengthFrameSync(data);\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\n/*\nhttps://wiki.multimedia.cx/index.php/ADTS\n\nAAAAAAAA AAAABCCD EEFFFFGH HHIJKLMM MMMMMMMM MMMOOOOO OOOOOOPP (QQQQQQQQ QQQQQQQQ)\n\nAACHeader consists of 7 or 9 bytes (without or with CRC).\nLetter \tLength (bits) \tDescription\nA \t12 \tsyncword 0xFFF, all bits must be 1\nB \t1 \tMPEG Version: 0 for MPEG-4, 1 for MPEG-2\nC \t2 \tLayer: always 0\nD \t1 \tprotection absent, Warning, set to 1 if there is no CRC and 0 if there is CRC\nE \t2 \tprofile, the MPEG-4 Audio Object Type minus 1\nF \t4 \tMPEG-4 Sampling Frequency Index (15 is forbidden)\nG \t1 \tprivate bit, guaranteed never to be used by MPEG, set to 0 when encoding, ignore when decoding\nH \t3 \tMPEG-4 Channel Configuration (in the case of 0, the channel configuration is sent via an inband PCE)\nI \t1 \toriginality, set to 0 when encoding, ignore when decoding\nJ \t1 \thome, set to 0 when encoding, ignore when decoding\nK \t1 \tcopyrighted id bit, the next bit of a centrally registered copyright identifier, set to 0 when encoding, ignore when decoding\nL \t1 \tcopyright id start, signals that this frame's copyright id bit is the first bit of the copyright id, set to 0 when encoding, ignore when decoding\nM \t13 \tframe length, this value must include 7 or 9 bytes of header length: FrameLength = (ProtectionAbsent == 1 ? 7 : 9) + size(AACFrame)\nO \t11 \tBuffer fullness // 0x7FF for VBR\nP \t2 \tNumber of AAC frames (RDBs) in ADTS frame minus 1, for maximum compatibility always use 1 AAC frame per ADTS frame\nQ \t16 \tCRC if protection absent is 0 \n*/\n\nimport { headerStore } from \"../../globals\";\n\nimport Header from \"../Header\";\nimport HeaderCache from \"../HeaderCache\";\n\nconst mpegVersion = {\n  0b00000000: \"MPEG-4\",\n  0b00001000: \"MPEG-2\",\n};\n\nconst layer = {\n  0b00000000: \"valid\",\n  0b00000010: \"bad\",\n  0b00000100: \"bad\",\n  0b00000110: \"bad\",\n};\n\nconst protection = {\n  0b00000000: \"16bit CRC\",\n  0b00000001: \"none\",\n};\n\nconst profile = {\n  0b00000000: \"AAC Main\",\n  0b01000000: \"AAC LC (Low Complexity)\",\n  0b10000000: \"AAC SSR (Scalable Sample Rate)\",\n  0b11000000: \"AAC LTP (Long Term Prediction)\",\n};\n\nconst sampleRates = {\n  0b00000000: 96000,\n  0b00000100: 88200,\n  0b00001000: 64000,\n  0b00001100: 48000,\n  0b00010000: 44100,\n  0b00010100: 32000,\n  0b00011000: 24000,\n  0b00011100: 22050,\n  0b00100000: 16000,\n  0b00100100: 12000,\n  0b00101000: 11025,\n  0b00101100: 8000,\n  0b00110000: 7350,\n  0b00110100: \"reserved\",\n  0b00111000: \"reserved\",\n  0b00111100: \"frequency is written explicitly\",\n};\n\nconst channelMode = {\n  0b000000000: { channels: 0, description: \"Defined in AOT Specific Config\" },\n  0b001000000: { channels: 1, description: \"front-center\" },\n  0b010000000: { channels: 2, description: \"front-left, front-right\" },\n  0b011000000: {\n    channels: 3,\n    description: \"front-center, front-left, front-right\",\n  },\n  0b100000000: {\n    channels: 4,\n    description: \"front-center, front-left, front-right, back-center\",\n  },\n  0b101000000: {\n    channels: 5,\n    description: \"front-center, front-left, front-right, back-left, back-right\",\n  },\n  0b110000000: {\n    channels: 6,\n    description:\n      \"front-center, front-left, front-right, back-left, back-right, LFE-channel\",\n  },\n  0b111000000: {\n    channels: 8,\n    description:\n      \"front-center, front-left, front-right, side-left, side-right, back-left, back-right, LFE-channel\",\n  },\n};\n\nexport default class AACHeader extends Header {\n  static getHeader(data, headerCache) {\n    const header = {};\n\n    // Must be at least seven bytes. Out of data\n    if (data.length < 7) return new AACHeader(header, false);\n\n    // Check header cache\n    const key = HeaderCache.getKey([\n      data[0],\n      data[1],\n      data[2],\n      data[3] & 111111100, // frame length varies so don't cache it\n    ]);\n    const cachedHeader = headerCache.getHeader(key);\n\n    if (!cachedHeader) {\n      // Frame sync (all bits must be set): `11111111|1111`:\n      if (data[0] !== 0xff || data[1] < 0xf0) return null;\n\n      // Byte (2 of 7)\n      // * `1111BCCD`\n      // * `....B...`: MPEG Version: 0 for MPEG-4, 1 for MPEG-2\n      // * `.....CC.`: Layer: always 0\n      // * `.......D`: protection absent, Warning, set to 1 if there is no CRC and 0 if there is CRC\n      const mpegVersionBits = data[1] & 0b00001000;\n      const layerBits = data[1] & 0b00000110;\n      const protectionBit = data[1] & 0b00000001;\n\n      header.mpegVersion = mpegVersion[mpegVersionBits];\n\n      header.layer = layer[layerBits];\n      if (header.layer === \"bad\") return null;\n\n      header.protection = protection[protectionBit];\n      header.length = protectionBit ? 7 : 9;\n\n      // Byte (3 of 7)\n      // * `EEFFFFGH`\n      // * `EE......`: profile, the MPEG-4 Audio Object Type minus 1\n      // * `..FFFF..`: MPEG-4 Sampling Frequency Index (15 is forbidden)\n      // * `......G.`: private bit, guaranteed never to be used by MPEG, set to 0 when encoding, ignore when decoding\n      header.profileBits = data[2] & 0b11000000;\n      header.sampleRateBits = data[2] & 0b00111100;\n      const privateBit = data[2] & 0b00000010;\n\n      header.profile = profile[header.profileBits];\n\n      header.sampleRate = sampleRates[header.sampleRateBits];\n      if (header.sampleRate === \"reserved\") return null;\n\n      header.isPrivate = !!(privateBit >> 1);\n\n      // Byte (3,4 of 7)\n      // * `.......H|HH......`: MPEG-4 Channel Configuration (in the case of 0, the channel configuration is sent via an inband PCE)\n      header.channelModeBits =\n        new DataView(Uint8Array.of(data[2], data[3]).buffer).getUint16() &\n        0b111000000;\n      header.channelMode = channelMode[header.channelModeBits].description;\n      header.channels = channelMode[header.channelModeBits].channels;\n\n      // Byte (4 of 7)\n      // * `HHIJKLMM`\n      // * `..I.....`: originality, set to 0 when encoding, ignore when decoding\n      // * `...J....`: home, set to 0 when encoding, ignore when decoding\n      // * `....K...`: copyrighted id bit, the next bit of a centrally registered copyright identifier, set to 0 when encoding, ignore when decoding\n      // * `.....L..`: copyright id start, signals that this frame's copyright id bit is the first bit of the copyright id, set to 0 when encoding, ignore when decoding\n      const originalBit = data[3] & 0b00100000;\n      const homeBit = data[3] & 0b00001000;\n      const copyrightIdBit = data[3] & 0b00001000;\n      const copyrightIdStartBit = data[3] & 0b00000100;\n\n      header.isOriginal = !!(originalBit >> 5);\n      header.isHome = !!(homeBit >> 4);\n      header.copyrightId = !!(copyrightIdBit >> 3);\n      header.copyrightIdStart = !!(copyrightIdStartBit >> 2);\n      header.bitDepth = 16;\n    } else {\n      Object.assign(header, cachedHeader);\n    }\n\n    // Byte (4,5,6 of 7)\n    // * `.......MM|MMMMMMMM|MMM.....`: frame length, this value must include 7 or 9 bytes of header length: FrameLength = (ProtectionAbsent == 1 ? 7 : 9) + size(AACFrame)\n    const frameLengthBits =\n      new DataView(\n        Uint8Array.of(0x00, data[3], data[4], data[5]).buffer\n      ).getUint32() & 0x3ffe0;\n    header.frameLength = frameLengthBits >> 5;\n    if (!header.frameLength) return null;\n\n    // Byte (6,7 of 7)\n    // * `...OOOOO|OOOOOO..`: Buffer fullness\n    const bufferFullnessBits =\n      new DataView(Uint8Array.of(data[5], data[6]).buffer).getUint16() & 0x1ffc;\n    header.bufferFullness =\n      bufferFullnessBits === 0x1ffc ? \"VBR\" : bufferFullnessBits >> 2;\n\n    // Byte (7 of 7)\n    // * `......PP` Number of AAC frames (RDBs) in ADTS frame minus 1, for maximum compatibility always use 1 AAC frame per ADTS frame\n    header.numberAACFrames = data[6] & 0b00000011;\n    header.samples = 1024;\n\n    if (!cachedHeader) {\n      const {\n        length,\n        channelModeBits,\n        profileBits,\n        sampleRateBits,\n        frameLength,\n        bufferFullness,\n        numberAACFrames,\n        samples,\n        ...codecUpdateFields\n      } = header;\n      headerCache.setHeader(key, header, codecUpdateFields);\n    }\n    return new AACHeader(header, true);\n  }\n\n  /**\n   * @private\n   * Call AACHeader.getHeader(Array<Uint8>) to get instance\n   */\n  constructor(header, isParsed) {\n    super(header, isParsed);\n\n    this.copyrightId = header.copyrightId;\n    this.copyrightIdStart = header.copyrightIdStart;\n    this.channelMode = header.channelMode;\n    this.bufferFullness = header.bufferFullness;\n    this.isHome = header.isHome;\n    this.isOriginal = header.isOriginal;\n    this.isPrivate = header.isPrivate;\n    this.layer = header.layer;\n    this.mpegVersion = header.mpegVersion;\n    this.numberAACFrames = header.numberAACFrames;\n    this.profile = header.profile;\n    this.protection = header.protection;\n  }\n\n  get audioSpecificConfig() {\n    // Audio Specific Configuration\n    // * `000EEFFF|F0HHH000`:\n    // * `000EE...|........`: Object Type (profileBit + 1)\n    // * `.....FFF|F.......`: Sample Rate\n    // * `........|.0HHH...`: Channel Configuration\n    // * `........|.....0..`: Frame Length (1024)\n    // * `........|......0.`: does not depend on core coder\n    // * `........|.......0`: Not Extension\n    const header = headerStore.get(this);\n\n    const audioSpecificConfig =\n      ((header.profileBits + 0x40) << 5) |\n      (header.sampleRateBits << 5) |\n      (header.channelModeBits >> 3);\n\n    const bytes = new Uint8Array(2);\n    new DataView(bytes.buffer).setUint16(0, audioSpecificConfig, false);\n    return bytes;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { headerStore, frameStore } from \"../../globals\";\nimport Frame from \"../Frame\";\nimport AACHeader from \"./AACHeader\";\n\nexport default class AACFrame extends Frame {\n  constructor(data, headerCache) {\n    const header = AACHeader.getHeader(data, headerCache);\n\n    super(\n      header,\n      header &&\n        data.subarray(\n          headerStore.get(header).length,\n          headerStore.get(header).frameLength\n        ),\n      header && headerStore.get(header).samples\n    );\n\n    frameStore.get(this).length = header && headerStore.get(header).frameLength;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Parser from \"../Parser\";\nimport AACFrame from \"./AACFrame\";\n\nexport default class AACParser extends Parser {\n  constructor(onCodecUpdate, onCodec) {\n    super(onCodecUpdate);\n    this.Frame = AACFrame;\n    this._maxHeaderLength = 9;\n\n    onCodec(this.codec);\n  }\n\n  get codec() {\n    return \"aac\";\n  }\n\n  parseFrames(data) {\n    return this.fixedLengthFrameSync(data);\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\n/*\nhttps://xiph.org/ogg/doc/framing.html\n\nAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA BBBBBBBB 00000CDE\n\n(LSB)                                                             (MSB)\nFFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF\nGGGGGGGG GGGGGGGG GGGGGGGG GGGGGGGG\nHHHHHHHH HHHHHHHH HHHHHHHH HHHHHHHH\nIIIIIIII IIIIIIII IIIIIIII IIIIIIII\n\nJJJJJJJJ\nLLLLLLLL...\n\nOgg Page Header\nLetter \tLength (bits) \tDescription\nA \t32 \t0x4f676753, \"OggS\"\nB \t8 \tstream_structure_version\nC \t1 \t(0 no, 1 yes) continued packet\nD \t1 \t(0 no, 1 yes) first page of logical bitstream (bos)\nE \t1 \t(0 no, 1 yes) last page of logical bitstream (eos)\n\nF \t64 \tabsolute granule position\n        Sample Count??\nG   32  stream serial number\nH   32  page sequence no\nI   32  page checksum\nJ   8   Number of page segments in the segment table\nL   n   Segment table (n=page_segments+26).\n        Segment table values sum to the total length of the packet.\n        Last value is always < 0xFF. Last lacing value will be 0x00 if evenly divisible by 0xFF.\n        \n*/\n\nconst OggS = 0x4f676753;\n\nimport { headerStore, isParsedStore } from \"../../globals\";\n\nexport default class OggPageHeader {\n  static getHeader(data) {\n    const header = {};\n\n    // Must be at least 28 bytes.\n    if (data.length < 28) return new OggPageHeader(header, false);\n\n    const view = new DataView(Uint8Array.of(...data.subarray(0, 28)).buffer);\n\n    // Bytes (1-4 of 28)\n    // Frame sync (must equal OggS): `AAAAAAAA|AAAAAAAA|AAAAAAAA|AAAAAAAA`:\n    if (view.getUint32(0) !== OggS) {\n      return null;\n    }\n\n    // Byte (5 of 28)\n    // * `BBBBBBBB`: stream_structure_version\n    header.streamStructureVersion = data[4];\n\n    // Byte (6 of 28)\n    // * `00000CDE`\n    // * `00000...`: All zeros\n    // * `.....C..`: (0 no, 1 yes) continued packet\n    // * `......D.`: (0 no, 1 yes) first page of logical bitstream (bos)\n    // * `.......E`: (0 no, 1 yes) last page of logical bitstream (eos)\n    const zeros = data[5] & 0b11111000;\n    const continuePacketBit = data[5] & 0b00000100;\n    const firstPageBit = data[5] & 0b00000010;\n    const lastPageBit = data[5] & 0b00000001;\n\n    if (zeros) return null;\n    header.isContinuedPacket = !!(continuePacketBit >> 2);\n    header.isFirstPage = !!(firstPageBit >> 1);\n    header.isLastPage = !!lastPageBit;\n\n    // Byte (7-14 of 28)\n    // * `FFFFFFFF|FFFFFFFF|FFFFFFFF|FFFFFFFF|FFFFFFFF|FFFFFFFF|FFFFFFFF|FFFFFFFF`\n    // * Absolute Granule Position\n\n    /**\n     * @todo Safari does not support getBigInt64, but it also doesn't support Ogg\n     */\n    try {\n      header.absoluteGranulePosition = view.getBigInt64(6, true);\n    } catch {}\n\n    // Byte (15-18 of 28)\n    // * `GGGGGGGG|GGGGGGGG|GGGGGGGG|GGGGGGGG`\n    // * Stream Serial Number\n    header.streamSerialNumber = view.getInt32(14, true);\n\n    // Byte (19-22 of 28)\n    // * `HHHHHHHH|HHHHHHHH|HHHHHHHH|HHHHHHHH`\n    // * Page Sequence Number\n    header.pageSequenceNumber = view.getInt32(18, true);\n\n    // Byte (23-26 of 28)\n    // * `IIIIIIII|IIIIIIII|IIIIIIII|IIIIIIII`\n    // * Page Checksum\n    header.pageChecksum = view.getInt32(22, true);\n\n    // Byte (27 of 28)\n    // * `JJJJJJJJ`: Number of page segments in the segment table\n    const pageSegmentTableLength = data[26];\n    header.length = pageSegmentTableLength + 27;\n\n    if (header.length > data.length) return new OggPageHeader(header, false); // out of data\n\n    header.frameLength = 0;\n    header.pageSegmentTable = [];\n    header.pageSegmentBytes = data.subarray(27, header.length);\n\n    let segmentLength = 0;\n\n    for (const segmentByte of header.pageSegmentBytes) {\n      header.frameLength += segmentByte;\n      segmentLength += segmentByte;\n\n      if (segmentByte !== 0xff) {\n        header.pageSegmentTable.push(segmentLength);\n        segmentLength = 0;\n      }\n    }\n\n    return new OggPageHeader(header, true);\n  }\n\n  /**\n   * @private\n   * Call OggPageHeader.getHeader(Array<Uint8>) to get instance\n   */\n  constructor(header, isParsed) {\n    headerStore.set(this, header);\n    isParsedStore.set(this, isParsed);\n\n    this.absoluteGranulePosition = header.absoluteGranulePosition;\n    this.isContinuedPacket = header.isContinuedPacket;\n    this.isFirstPage = header.isFirstPage;\n    this.isLastPage = header.isLastPage;\n    this.pageSegmentTable = header.pageSegmentTable;\n    this.pageSequenceNumber = header.pageSequenceNumber;\n    this.pageChecksum = header.pageChecksum;\n    this.streamSerialNumber = header.streamSerialNumber;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { headerStore, isParsedStore } from \"../../globals\";\nimport Frame from \"../Frame\";\nimport OggPageHeader from \"./OggPageHeader\";\n\nexport default class OggPage extends Frame {\n  constructor(data) {\n    const oggPage = OggPageHeader.getHeader(data);\n    const pageStore = headerStore.get(oggPage);\n\n    super(\n      oggPage,\n      oggPage\n        ? data.subarray(\n            pageStore.length,\n            pageStore.length + pageStore.frameLength\n          )\n        : []\n    );\n\n    if (isParsedStore.get(oggPage)) {\n      let offset = pageStore.length;\n\n      this.segments = oggPage.pageSegmentTable.map((segmentLength) => {\n        const segment = data.subarray(offset, offset + segmentLength);\n        offset += segmentLength;\n        return segment;\n      });\n      this.length = pageStore.length + pageStore.frameLength;\n    }\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\n/*\nhttps://xiph.org/ogg/doc/framing.html\n\nAAAAAAAA AAAAAABC DDDDEEEE FFFFGGGH \n(IIIIIIII...)\n(JJJJJJJJ|JJJJJJJJ)\n(KKKKKKKK|KKKKKKKK)\nLLLLLLLLL\n\nFLAC Frame Header\nLetter \tLength (bits) \tDescription\nA \t13 \t11111111|11111\nB   1   Reserved 0 - mandatory, 1 - reserved\nC \t1 \tBlocking strategy, 0 - fixed, 1 - variable\nD \t4   Block size in inter-channel samples\nE \t4 \tSample rate\nF   4   Channel assignment\nG   3   Sample size in bits\nH   1   Reserved 0 - mandatory, 1 - reserved\nI   ?   if(variable blocksize)\n           <8-56>:\"UTF-8\" coded sample number (decoded number is 36 bits) [4]\n        else\n           <8-48>:\"UTF-8\" coded frame number (decoded number is 31 bits) [4]\nJ   ?   if(blocksize bits == 011x)\n            8/16 bit (blocksize-1)\nK   ?   if(sample rate bits == 11xx)\n            8/16 bit sample rate\nL   8   CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) of everything before the crc, including the sync code\n        \n*/\n\nimport { crc8 } from \"../../utilities\";\nimport Header from \"../Header\";\nimport HeaderCache from \"../HeaderCache\";\n\nconst blockingStrategy = {\n  0b00000000: \"Fixed\",\n  0b00000001: \"Variable\",\n};\n\nconst blockSize = {\n  0b00000000: \"reserved\",\n  0b00010000: 192,\n  0b00100000: 576,\n  0b00110000: 1152,\n  0b01000000: 2304,\n  0b01010000: 4608,\n  0b01100000: \"8-bit (blocksize-1) end of header\",\n  0b01110000: \"16-bit (blocksize-1) end of header\",\n  0b10000000: 256,\n  0b10010000: 512,\n  0b10100000: 1024,\n  0b10110000: 2048,\n  0b11000000: 4096,\n  0b11010000: 8192,\n  0b11100000: 16384,\n  0b11110000: 32768,\n};\n\nconst sampleRate = {\n  0b00000000: \"invalid\", // (unsupported) get from STREAMINFO metadata block\n  0b00000001: 88200,\n  0b00000010: 176400,\n  0b00000011: 192000,\n  0b00000100: 8000,\n  0b00000101: 16000,\n  0b00000110: 22050,\n  0b00000111: 24000,\n  0b00001000: 32000,\n  0b00001001: 44100,\n  0b00001010: 48000,\n  0b00001011: 96000,\n  0b00001100: \"get 8 bit sample rate (in kHz) from end of header\",\n  0b00001101: \"get 16 bit sample rate (in Hz) from end of header\",\n  0b00001110: \"get 16 bit sample rate (in tens of Hz) from end of header\",\n  0b00001111: \"invalid\",\n};\n\n/* prettier-ignore */\nconst channelAssignments = {\n  0b00000000: {channels: 1, description: \"mono\"},\n  0b00010000: {channels: 2, description: \"left, right\"},\n  0b00100000: {channels: 3, description: \"left, right, center\"},\n  0b00110000: {channels: 4, description: \"front left, front right, back left, back right\"},\n  0b01000000: {channels: 5, description: \"front left, front right, front center, back/surround left, back/surround right\"},\n  0b01010000: {channels: 6, description: \"front left, front right, front center, LFE, back/surround left, back/surround right\"},\n  0b01100000: {channels: 7, description: \"front left, front right, front center, LFE, back center, side left, side right\"},\n  0b01110000: {channels: 8, description: \"front left, front right, front center, LFE, back left, back right, side left, side right\"},\n  0b10000000: {channels: 2, description: \"left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel\"},\n  0b10010000: {channels: 2, description: \"right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel\"},\n  0b10100000: {channels: 2, description: \"mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel\"},\n  0b10110000: \"reserved\",\n  0b11000000: \"reserved\",\n  0b11010000: \"reserved\",\n  0b11100000: \"reserved\",\n  0b11110000: \"reserved\",\n}\n\nconst bitDepth = {\n  0b00000000: \"get from STREAMINFO metadata block\",\n  0b00000010: 8,\n  0b00000100: 12,\n  0b00000110: \"reserved\",\n  0b00001000: 16,\n  0b00001010: 20,\n  0b00001100: 24,\n  0b00001110: \"reserved\",\n};\n\nexport default class FLACHeader extends Header {\n  static decodeUTF8Int(data) {\n    if (data[0] < 0x80) return { value: data[0], next: 1 };\n\n    if (data === 0xff) return null; // invalid\n\n    let next = 2,\n      mask = 0xe0,\n      value;\n\n    // determine length of utf-8 character\n    while ((data[0] & mask) !== ((mask << 1) & 0xff) && next < 7) {\n      next++;\n      mask |= mask >> 1;\n    }\n\n    if (next === 7) return null; // invalid\n\n    const offset = (next - 1) * 6;\n\n    // set value for the remaining bits in the length character\n    value = data[0] & ((mask ^ 0xff) << offset);\n\n    // set the remaining values\n    for (let idx = 1; idx < next; idx++) {\n      value |= (data[idx] & 0x3f) << (offset - 6 * idx);\n    }\n\n    return { value, next };\n  }\n\n  static getHeader(data, headerCache) {\n    const header = {};\n\n    // Must be at least 6 bytes.\n    if (data.length < 6) return new FLACHeader(header, false);\n\n    // Check header cache\n    const key = HeaderCache.getKey(data.subarray(0, 4));\n    const cachedHeader = headerCache.getHeader(key);\n\n    if (!cachedHeader) {\n      // Bytes (1-2 of 6)\n      // * `11111111|111110..`: Frame sync\n      // * `........|......0.`: Reserved 0 - mandatory, 1 - reserved\n      if (data[0] !== 0xff || !(data[1] === 0xf8 || data[1] === 0xf9)) {\n        return null;\n      }\n\n      header.length = 2;\n\n      // Byte (2 of 6)\n      // * `.......C`: Blocking strategy, 0 - fixed, 1 - variable\n      header.blockingStrategyBits = data[1] & 0b00000001;\n      header.blockingStrategy = blockingStrategy[header.blockingStrategyBits];\n\n      // Byte (3 of 6)\n      // * `DDDD....`: Block size in inter-channel samples\n      // * `....EEEE`: Sample rate\n      header.length++;\n      const blockSizeBits = data[2] & 0b11110000;\n      const sampleRateBits = data[2] & 0b00001111;\n\n      header.blockSize = blockSize[blockSizeBits];\n      if (header.blockSize === \"reserved\") return null;\n\n      header.sampleRate = sampleRate[sampleRateBits];\n      if (header.sampleRate === \"invalid\") return null;\n\n      // Byte (4 of 6)\n      // * `FFFF....`: Channel assignment\n      // * `....GGG.`: Sample size in bits\n      // * `.......H`: Reserved 0 - mandatory, 1 - reserved\n      header.length++;\n      if (data[3] & 0b00000001) return null;\n      const channelAssignmentBits = data[3] & 0b11110000;\n      const bitDepthBits = data[3] & 0b00001110;\n\n      const channelAssignment = channelAssignments[channelAssignmentBits];\n      if (channelAssignment === \"reserved\") return null;\n\n      header.channels = channelAssignment.channels;\n      header.channelMode = channelAssignment.description;\n\n      header.bitDepth = bitDepth[bitDepthBits];\n      if (header.bitDepth === \"reserved\") return null;\n    } else {\n      Object.assign(header, cachedHeader);\n    }\n\n    // Byte (5...)\n    // * `IIIIIIII|...`: VBR block size ? sample number : frame number\n    header.length = 5;\n\n    // check if there is enough data to parse UTF8\n    if (data.length < header.length + 8) return new FLACHeader(header, false);\n    const decodedUtf8 = FLACHeader.decodeUTF8Int(data.subarray(4));\n    if (!decodedUtf8) return null;\n\n    if (header.blockingStrategyBits) {\n      header.sampleNumber = decodedUtf8.value;\n    } else {\n      header.frameNumber = decodedUtf8.value;\n    }\n\n    header.length += decodedUtf8.next;\n\n    // Byte (...)\n    // * `JJJJJJJJ|(JJJJJJJJ)`: Blocksize (8/16bit custom value)\n    if (typeof header.blockSize === \"string\") {\n      if (blockSizeBits === 0b01100000) {\n        // 8 bit\n        if (data.length < header.length) return new FLACHeader(header, false); // out of data\n        header.blockSize = data[header.length - 1] - 1;\n        header.length += 1;\n      } else if (blockSizeBits === 0b01110000) {\n        // 16 bit\n        if (data.length <= header.length) return new FLACHeader(header, false); // out of data\n        header.blockSize =\n          (data[header.length - 1] << 8) + data[header.length] - 1;\n        header.length += 2;\n      }\n    }\n\n    header.samples = header.blockSize;\n\n    // Byte (...)\n    // * `KKKKKKKK|(KKKKKKKK)`: Sample rate (8/16bit custom value)\n    if (typeof header.sampleRate === \"string\") {\n      if (sampleRateBits === 0b00001100) {\n        // 8 bit\n        if (data.length < header.length) return new FLACHeader(header, false); // out of data\n        header.sampleRate = data[header.length - 1] - 1;\n        header.length += 1;\n      } else if (sampleRateBits === 0b00001101) {\n        // 16 bit\n        if (data.length <= header.length) return new FLACHeader(header, false); // out of data\n        header.sampleRate =\n          (data[header.length - 1] << 8) + data[header.length] - 1;\n        header.length += 2;\n      } else if (sampleRateBits === 0b00001110) {\n        // 16 bit\n        if (data.length <= header.length) return new FLACHeader(header, false); // out of data\n        header.sampleRate =\n          (data[header.length - 1] << 8) + data[header.length] - 1;\n        header.length += 2;\n      }\n    }\n\n    // Byte (...)\n    // * `LLLLLLLL`: CRC-8\n    if (data.length < header.length) return new FLACHeader(header, false); // out of data\n\n    header.crc = data[header.length - 1];\n    if (header.crc !== crc8(data.subarray(0, header.length - 1))) {\n      return null;\n    }\n\n    if (!cachedHeader) {\n      const {\n        blockingStrategyBits,\n        frameNumber,\n        sampleNumber,\n        samples,\n        crc,\n        length,\n        ...codecUpdateFields\n      } = header;\n      headerCache.setHeader(key, header, codecUpdateFields);\n    }\n    return header;\n  }\n\n  /**\n   * @private\n   * Call FLACHeader.getHeader(Array<Uint8>) to get instance\n   */\n  constructor(header, isParsed) {\n    super(header, isParsed);\n\n    this.channelMode = header.channelMode;\n    this.blockingStrategy = header.blockingStrategy;\n    this.blockSize = header.blockSize;\n    this.frameNumber = header.frameNumber;\n    this.sampleNumber = header.sampleNumber;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { headerStore } from \"../../globals\";\nimport Frame from \"../Frame\";\nimport FLACHeader from \"./FLACHeader\";\n\nexport default class FLACFrame extends Frame {\n  constructor(data, header) {\n    const flacHeader = new FLACHeader(header, true);\n\n    super(flacHeader, data, flacHeader && headerStore.get(flacHeader).samples);\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Parser from \"../Parser\";\nimport FLACFrame from \"./FLACFrame\";\nimport FLACHeader from \"./FLACHeader\";\n\nexport default class FLACParser extends Parser {\n  constructor(onCodecUpdate, onCodec) {\n    super(onCodecUpdate);\n    this.Frame = FLACFrame;\n\n    onCodec(this.codec);\n  }\n\n  get codec() {\n    return \"flac\";\n  }\n\n  parseFrames(oggPage) {\n    if (oggPage.header.pageSequenceNumber === 0) {\n      // Identification header\n      this._headerCache.enable();\n\n      return { frames: [], remainingData: 0 };\n    }\n\n    if (oggPage.header.pageSequenceNumber === 1) {\n      // Vorbis comments\n      return { frames: [], remainingData: 0 };\n    }\n\n    return {\n      frames: oggPage.segments\n        .filter((segment) => segment[0] === 0xff) // filter out padding and other metadata frames\n        .map(\n          (segment) =>\n            new FLACFrame(\n              segment,\n              FLACHeader.getHeader(segment, this._headerCache)\n            )\n        ),\n      remainingData: 0,\n    };\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\n/*\nhttps://tools.ietf.org/html/rfc7845.html\n 0                   1                   2                   3\n 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|      'O'      |      'p'      |      'u'      |      's'      |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|      'H'      |      'e'      |      'a'      |      'd'      |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|  Version = 1  | Channel Count |           Pre-skip            |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|                     Input Sample Rate (Hz)                    |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n|   Output Gain (Q7.8 in dB)    | Mapping Family|               |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               :\n|                                                               |\n:               Optional Channel Mapping Table...               :\n|                                                               |\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\nLetter \tLength (bits) \tDescription\nA  64  Magic Signature - OpusHead\nB  8   Version number - 00000001\nC  8   Output channel count (unsigned)\nD  16  Pre-skip (unsigned, little endian)\nE  32  Sample rate (unsigned, little endian)\nF  16  Output Gain (signed, little endian)\nG  8   Channel Mapping family (unsigned)\n\n// if(channel mapping !== 0)\nH  8   Stream count (unsigned)\nI  8   Coupled Stream Count (unsigned)\nJ  8*C Channel Mapping\n*/\n\nimport Header from \"../Header\";\nimport HeaderCache from \"../HeaderCache\";\n\n/* prettier-ignore */\nconst channelMappingFamilies = {\n  0b00000000: [\n    \"monophonic (mono)\",\n    \"stereo (left, right)\"\n  ],\n  0b00000001: [\n    \"monophonic (mono)\",\n    \"stereo (left, right)\",\n    \"linear surround (left, center, right)\",\n    \"quadraphonic (front left, front right, rear left, rear right)\",\n    \"5.0 surround (front left, front center, front right, rear left, rear right)\",\n    \"5.1 surround (front left, front center, front right, rear left, rear right, LFE)\",\n    \"6.1 surround (front left, front center, front right, side left, side right, rear center, LFE)\",\n    \"7.1 surround (front left, front center, front right, side left, side right, rear left, rear right, LFE)\",\n  ]\n};\n\nexport default class OpusHeader extends Header {\n  static getHeader(data, headerCache) {\n    const header = {};\n    // Must be at least 19 bytes.\n    if (data.length < 19) return new OpusHeader(header, false);\n\n    // Check header cache\n    const key = HeaderCache.getKey(data.subarray(0, 19));\n    const cachedHeader = headerCache.getHeader(key);\n\n    if (!cachedHeader) {\n      // Bytes (1-8 of 19): OpusHead - Magic Signature\n      if (\n        data[0] !== 0x4f ||\n        data[1] !== 0x70 ||\n        data[2] !== 0x75 ||\n        data[3] !== 0x73 ||\n        data[4] !== 0x48 ||\n        data[5] !== 0x65 ||\n        data[6] !== 0x61 ||\n        data[7] !== 0x64\n      ) {\n        return null;\n      }\n\n      // Byte (9 of 19)\n      // * `00000001`: Version number\n      if (data[8] !== 1) return null;\n\n      const view = new DataView(Uint8Array.of(...data.subarray(0, 19)).buffer);\n      header.bitDepth = 16;\n\n      header.length = 19;\n\n      // Byte (10 of 19)\n      // * `CCCCCCCC`: Channel Count\n      header.channels = data[9];\n\n      // Byte (11-12 of 19)\n      // * `DDDDDDDD|DDDDDDDD`: Pre skip\n      header.preSkip = view.getUint16(10, true);\n\n      // Byte (13-16 of 19)\n      // * `EEEEEEEE|EEEEEEEE|EEEEEEEE|EEEEEEEE`: Sample Rate\n      header.inputSampleRate = view.getUint32(12, true);\n      // Opus is always decoded at 48kHz\n      header.sampleRate = 48000;\n\n      // Byte (17-18 of 19)\n      // * `FFFFFFFF|FFFFFFFF`: Output Gain\n      header.outputGain = view.getInt16(16, true);\n\n      // Byte (19 of 19)\n      // * `GGGGGGGG`: Channel Mapping Family\n      header.channelMappingFamily = data[18];\n      if (!header.channelMappingFamily in channelMappingFamilies) return null;\n\n      header.channelMode =\n        channelMappingFamilies[header.channelMappingFamily][\n          header.channels - 1\n        ];\n      if (!header.channelMode) return null;\n    } else {\n      Object.assign(header, cachedHeader);\n    }\n\n    if (header.channelMappingFamily !== 0) {\n      header.length += 2 + header.channels;\n      if (data.length < header.length) return new OpusHeader(header, false); // out of data\n\n      // * `HHHHHHHH`: Stream count\n      header.streamCount = data[19];\n\n      // * `IIIIIIII`: Coupled Stream count\n      header.coupledStreamCount = data[20];\n\n      // * `JJJJJJJJ|...` Channel Mapping table\n      header.channelMappingTable = data.subarray(21, header.channels + 21);\n    }\n\n    header.data = Uint8Array.of(...data.subarray(0, header.length));\n\n    if (!cachedHeader) {\n      // set header cache\n      const {\n        length,\n        data,\n        channelMappingFamily,\n        ...codecUpdateFields\n      } = header;\n\n      headerCache.setHeader(key, header, codecUpdateFields);\n    }\n\n    return new OpusHeader(header, true);\n  }\n\n  /**\n   * @private\n   * Call OpusHeader.getHeader(Array<Uint8>) to get instance\n   */\n  constructor(header, isParsed) {\n    super(header, isParsed);\n\n    this.data = header.data;\n    this.channelMappingFamily = header.channelMappingFamily;\n    this.channelMode = header.channelMode;\n    this.coupledStreamCount = header.coupledStreamCount;\n    this.preSkip = header.preSkip;\n    this.outputGain = header.outputGain;\n    this.inputSampleRate = header.inputSampleRate;\n    this.streamCount = header.streamCount;\n    this.channelMappingTable = header.channelMappingTable;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Frame from \"../Frame\";\nimport OpusHeader from \"./OpusHeader\";\n\n//  0 1 2 3 4 5 6 7\n// +-+-+-+-+-+-+-+-+\n// | config  |s| c |\n// +-+-+-+-+-+-+-+-+\nconst configTable = {\n  0b00000000: { mode: \"SILK-only\", bandwidth: \"NB\", frameSize: 10 },\n  0b00001000: { mode: \"SILK-only\", bandwidth: \"NB\", frameSize: 20 },\n  0b00010000: { mode: \"SILK-only\", bandwidth: \"NB\", frameSize: 40 },\n  0b00011000: { mode: \"SILK-only\", bandwidth: \"NB\", frameSize: 60 },\n  0b00100000: { mode: \"SILK-only\", bandwidth: \"MB\", frameSize: 10 },\n  0b00101000: { mode: \"SILK-only\", bandwidth: \"MB\", frameSize: 20 },\n  0b00110000: { mode: \"SILK-only\", bandwidth: \"MB\", frameSize: 40 },\n  0b00111000: { mode: \"SILK-only\", bandwidth: \"MB\", frameSize: 60 },\n  0b01000000: { mode: \"SILK-only\", bandwidth: \"WB\", frameSize: 10 },\n  0b01001000: { mode: \"SILK-only\", bandwidth: \"WB\", frameSize: 20 },\n  0b01010000: { mode: \"SILK-only\", bandwidth: \"WB\", frameSize: 40 },\n  0b01011000: { mode: \"SILK-only\", bandwidth: \"WB\", frameSize: 60 },\n  0b01100000: { mode: \"Hybrid\", bandwidth: \"SWB\", frameSize: 10 },\n  0b01101000: { mode: \"Hybrid\", bandwidth: \"SWB\", frameSize: 20 },\n  0b01110000: { mode: \"Hybrid\", bandwidth: \"FB\", frameSize: 10 },\n  0b01111000: { mode: \"Hybrid\", bandwidth: \"FB\", frameSize: 20 },\n  0b10000000: { mode: \"CELT-only\", bandwidth: \"NB\", frameSize: 2.5 },\n  0b10001000: { mode: \"CELT-only\", bandwidth: \"NB\", frameSize: 5 },\n  0b10010000: { mode: \"CELT-only\", bandwidth: \"NB\", frameSize: 10 },\n  0b10011000: { mode: \"CELT-only\", bandwidth: \"NB\", frameSize: 20 },\n  0b10100000: { mode: \"CELT-only\", bandwidth: \"WB\", frameSize: 2.5 },\n  0b10101000: { mode: \"CELT-only\", bandwidth: \"WB\", frameSize: 5 },\n  0b10110000: { mode: \"CELT-only\", bandwidth: \"WB\", frameSize: 10 },\n  0b10111000: { mode: \"CELT-only\", bandwidth: \"WB\", frameSize: 20 },\n  0b11000000: { mode: \"CELT-only\", bandwidth: \"SWB\", frameSize: 2.5 },\n  0b11001000: { mode: \"CELT-only\", bandwidth: \"SWB\", frameSize: 5 },\n  0b11010000: { mode: \"CELT-only\", bandwidth: \"SWB\", frameSize: 10 },\n  0b11011000: { mode: \"CELT-only\", bandwidth: \"SWB\", frameSize: 20 },\n  0b11100000: { mode: \"CELT-only\", bandwidth: \"FB\", frameSize: 2.5 },\n  0b11101000: { mode: \"CELT-only\", bandwidth: \"FB\", frameSize: 5 },\n  0b11110000: { mode: \"CELT-only\", bandwidth: \"FB\", frameSize: 10 },\n  0b11111000: { mode: \"CELT-only\", bandwidth: \"FB\", frameSize: 20 },\n};\n\nexport default class OpusFrame extends Frame {\n  static getPacket(data) {\n    const packet = {\n      config: configTable[0b11111000 & data[0]],\n      channels: 0b00000100 & data[0] ? 2 : 1,\n      // 0: 1 frame in the packet\n      // 1: 2 frames in the packet, each with equal compressed size\n      // 2: 2 frames in the packet, with different compressed sizes\n      // 3: an arbitrary number of frames in the packet\n      code: 0b00000011 & data[0],\n    };\n\n    // https://tools.ietf.org/html/rfc6716#appendix-B\n    switch (packet.code) {\n      case 0:\n        packet.frameCount = 1;\n        return packet;\n      case 1:\n        packet.frameCount = 2;\n        return packet;\n      case 2:\n        packet.frameCount = 2;\n        return packet;\n      case 3:\n        packet.isVbr = Boolean(0b10000000 & data[1]);\n        packet.hasOpusPadding = Boolean(0b01000000 & data[1]);\n        packet.frameCount = 0b00111111 & data[1];\n        return packet;\n    }\n  }\n\n  constructor(data, header) {\n    let opusHeader = new OpusHeader(header, true);\n    const packet = OpusFrame.getPacket(data);\n\n    super(\n      opusHeader,\n      data,\n      opusHeader &&\n        ((packet.config.frameSize * packet.frameCount) / 1000) *\n          opusHeader.sampleRate\n    );\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Parser from \"../Parser\";\nimport OpusFrame from \"./OpusFrame\";\nimport OpusHeader from \"./OpusHeader\";\n\nexport default class OpusParser extends Parser {\n  constructor(onCodecUpdate, onCodec) {\n    super(onCodecUpdate);\n    this.Frame = OpusFrame;\n    this._identificationHeader = null;\n    this._maxHeaderLength = 26;\n\n    onCodec(this.codec);\n  }\n\n  get codec() {\n    return \"opus\";\n  }\n\n  parseFrames(oggPage) {\n    if (oggPage.header.pageSequenceNumber === 0) {\n      this._headerCache.enable();\n\n      this._identificationHeader = OpusHeader.getHeader(\n        oggPage.data,\n        this._headerCache\n      );\n      return { frames: [], remainingData: 0 };\n    }\n\n    if (oggPage.header.pageSequenceNumber === 1) {\n      // OpusTags\n      return { frames: [], remainingData: 0 };\n    }\n\n    return {\n      frames: oggPage.segments.map(\n        (segment) => new OpusFrame(segment, this._identificationHeader)\n      ),\n      remainingData: 0,\n    };\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Frame from \"../Frame\";\n\nexport default class VorbisFrame extends Frame {\n  constructor(data, header, samples) {\n    super(header, data, samples);\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\n/*\n\n1  1) [packet_type] : 8 bit value\n2  2) 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73: the characters ’v’,’o’,’r’,’b’,’i’,’s’ as six octets\n\nLetter bits Description\nA      8    Packet type\nB      48   Magic signature (vorbis)\nC      32   Version number\nD      8    Channels\nE      32   Sample rate\nF      32   Bitrate Maximum (signed)\nG      32   Bitrate Nominal (signed)\nH      32   Bitrate Minimum (signed)\nI      4    blocksize 1\nJ      4    blocksize 0\nK      1    Framing flag\n*/\n\nimport Header from \"../Header\";\nimport HeaderCache from \"../HeaderCache\";\n\n/* prettier-ignore */\nconst blockSizes = {\n  0b0110: 64,\n  0b0111: 128,\n  0b1000: 256,\n  0b1001: 512,\n  0b1010: 1024,\n  0b1011: 2048,\n  0b1100: 4096,\n  0b1101: 8192\n};\n\nexport default class VorbisHeader extends Header {\n  static getHeader(data, headerCache) {\n    const header = { length: 30 };\n\n    // Must be at least 30 bytes.\n    if (data.length < 30) return new VorbisHeader(header, false);\n\n    // Check header cache\n    const key = HeaderCache.getKey(data.subarray(0, 30));\n    const cachedHeader = headerCache.getHeader(key);\n    if (cachedHeader) return new VorbisHeader(cachedHeader, true);\n\n    // Bytes (1-7 of 30): /01vorbis - Magic Signature\n    if (\n      data[0] !== 0x01 || // identification header packet type\n      data[1] !== 0x76 || // v\n      data[2] !== 0x6f || // o\n      data[3] !== 0x72 || // r\n      data[4] !== 0x62 || // b\n      data[5] !== 0x69 || // i\n      data[6] !== 0x73 //    s\n    ) {\n      return null;\n    }\n\n    header.data = Uint8Array.of(...data.subarray(0, 30));\n    const view = new DataView(header.data.buffer);\n\n    // Byte (8-11 of 30)\n    // * `CCCCCCCC|CCCCCCCC|CCCCCCCC|CCCCCCCC`: Version number\n    header.version = view.getUint32(7, true);\n    if (header.version !== 0) return null;\n\n    // Byte (12 of 30)\n    // * `DDDDDDDD`: Channel Count\n    header.channels = data[11];\n\n    // Byte (13-16 of 30)\n    // * `EEEEEEEE|EEEEEEEE|EEEEEEEE|EEEEEEEE`: Sample Rate\n    header.sampleRate = view.getUint32(12, true);\n\n    // Byte (17-20 of 30)\n    // * `FFFFFFFF|FFFFFFFF|FFFFFFFF|FFFFFFFF`: Bitrate Maximum\n    header.bitrateMaximum = view.getInt32(16, true);\n\n    // Byte (21-24 of 30)\n    // * `GGGGGGGG|GGGGGGGG|GGGGGGGG|GGGGGGGG`: Bitrate Nominal\n    header.bitrateNominal = view.getInt32(20, true);\n\n    // Byte (25-28 of 30)\n    // * `HHHHHHHH|HHHHHHHH|HHHHHHHH|HHHHHHHH`: Bitrate Minimum\n    header.bitrateMinimum = view.getInt32(24, true);\n\n    // Byte (29 of 30)\n    // * `IIII....` Blocksize 1\n    // * `....JJJJ` Blocksize 0\n    header.blocksize1 = blockSizes[(data[28] & 0b11110000) >> 4];\n    header.blocksize0 = blockSizes[data[28] & 0b00001111];\n\n    // Byte (29 of 30)\n    // * `00000001` Framing bit\n    if (data[29 !== 0x01]) return null;\n\n    header.bitDepth = 32;\n\n    {\n      // set header cache\n      const { length, data, version, ...codecUpdateFields } = header;\n      headerCache.setHeader(key, header, codecUpdateFields);\n    }\n\n    return new VorbisHeader(header, true);\n  }\n\n  /**\n   * @private\n   * Call VorbisHeader.getHeader(Array<Uint8>) to get instance\n   */\n  constructor(header, isParsed) {\n    super(header, isParsed);\n\n    this.bitrateMaximum = header.bitrateMaximum;\n    this.bitrateMinimum = header.bitrateMinimum;\n    this.bitrateNominal = header.bitrateNominal;\n    this.blocksize0 = header.blocksize0;\n    this.blocksize1 = header.blocksize1;\n    this.data = header.data;\n    this.vorbisComments = undefined; // set during ogg parsing\n    this.vorbisSetup = undefined; // set during ogg parsing\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { BitReader, reverse, logError } from \"../../utilities\";\nimport Parser from \"../Parser\";\nimport VorbisFrame from \"./VorbisFrame\";\nimport VorbisHeader from \"./VorbisHeader\";\n\nexport default class VorbisParser extends Parser {\n  constructor(onCodecUpdate, onCodec) {\n    super(onCodecUpdate);\n    this.Frame = VorbisFrame;\n    this._maxHeaderLength = 29;\n\n    onCodec(this.codec);\n\n    this._identificationHeader = null;\n\n    this._mode = {\n      count: 0,\n    };\n    this._prevBlockSize = 0;\n    this._currBlockSize = 0;\n  }\n\n  get codec() {\n    return \"vorbis\";\n  }\n\n  parseFrames(oggPage) {\n    if (oggPage.header.pageSequenceNumber === 0) {\n      this._headerCache.enable();\n\n      this._identificationHeader = VorbisHeader.getHeader(\n        oggPage.data,\n        this._headerCache\n      );\n\n      return { frames: [], remainingData: 0 };\n    }\n\n    if (oggPage.header.pageSequenceNumber === 1) {\n      // gather WEBM CodecPrivate data\n      this._identificationHeader.vorbisComments = oggPage.segments[0];\n      this._identificationHeader.vorbisSetup = oggPage.segments[1];\n\n      this._mode = this._parseSetupHeader(oggPage.segments[1]);\n\n      return { frames: [], remainingData: 0 };\n    }\n\n    return {\n      frames: oggPage.segments.map(\n        (segment) =>\n          new VorbisFrame(\n            segment,\n            this._identificationHeader,\n            this._getSamples(segment)\n          )\n      ),\n      remainingData: 0,\n    };\n  }\n\n  _getSamples(segment) {\n    const byte = segment[0] >> 1;\n\n    const blockFlag = this._mode[byte & this._mode.mask];\n\n    // is this a large window\n    if (blockFlag) {\n      this._prevBlockSize =\n        byte & this._mode.prevMask\n          ? this._identificationHeader.blocksize1\n          : this._identificationHeader.blocksize0;\n    }\n\n    this._currBlockSize = blockFlag\n      ? this._identificationHeader.blocksize1\n      : this._identificationHeader.blocksize0;\n\n    const samples = (this._prevBlockSize + this._currBlockSize) >> 2;\n    this._prevBlockSize = this._currBlockSize;\n\n    return samples;\n  }\n\n  // https://gitlab.xiph.org/xiph/liboggz/-/blob/master/src/liboggz/oggz_auto.c\n  // https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/vorbis_parser.c\n  /*\n   * This is the format of the mode data at the end of the packet for all\n   * Vorbis Version 1 :\n   *\n   * [ 6:number_of_modes ]\n   * [ 1:size | 16:window_type(0) | 16:transform_type(0) | 8:mapping ]\n   * [ 1:size | 16:window_type(0) | 16:transform_type(0) | 8:mapping ]\n   * [ 1:size | 16:window_type(0) | 16:transform_type(0) | 8:mapping ]\n   * [ 1:framing(1) ]\n   *\n   * e.g.:\n   *\n   * MsB         LsB\n   *              <-\n   * 0 0 0 0 0 1 0 0\n   * 0 0 1 0 0 0 0 0\n   * 0 0 1 0 0 0 0 0\n   * 0 0 1|0 0 0 0 0\n   * 0 0 0 0|0|0 0 0\n   * 0 0 0 0 0 0 0 0\n   * 0 0 0 0|0 0 0 0\n   * 0 0 0 0 0 0 0 0\n   * 0 0 0 0|0 0 0 0\n   * 0 0 0|1|0 0 0 0 |\n   * 0 0 0 0 0 0 0 0 V\n   * 0 0 0|0 0 0 0 0\n   * 0 0 0 0 0 0 0 0\n   * 0 0 1|0 0 0 0 0\n   *\n   * The simplest way to approach this is to start at the end\n   * and read backwards to determine the mode configuration.\n   *\n   * liboggz and ffmpeg both use this method.\n   */\n  _parseSetupHeader(setup) {\n    const bitReader = new BitReader(setup);\n\n    let mode = {\n      count: 0,\n    };\n\n    // sync with the framing bit\n    while ((bitReader.read(1) & 0x01) !== 1) {}\n\n    let modeBits;\n    // search in reverse to parse out the mode entries\n    // limit mode count to 63 so previous block flag will be in first packet byte\n    while (mode.count < 64 && bitReader.position > 0) {\n      const mapping = reverse(bitReader.read(8));\n      if (mapping in mode) {\n        logError(\n          \"received duplicate mode mapping, failed to parse vorbis modes\"\n        );\n        throw new Error(\"Failed to read Vorbis stream\");\n      }\n\n      // 16 bits transform type, 16 bits window type, all values must be zero\n      let i = 0;\n      while (bitReader.read(8) === 0x00 && i++ < 3) {} // a non-zero value may indicate the end of the mode entries, or a read error\n\n      if (i === 4) {\n        // transform type and window type were all zeros\n        modeBits = bitReader.read(7); // modeBits may need to be used in the next iteration if this is the last mode entry\n        mode[mapping] = modeBits & 0x01; // read and store mode -> block flag mapping\n        bitReader.position += 6; // go back 6 bits so next iteration starts right after the block flag\n        mode.count++;\n      } else {\n        // transform type and window type were not all zeros\n        // check for mode count using previous iteration modeBits\n        if (((reverse(modeBits) & 0b01111110) >> 1) + 1 !== mode.count) {\n          logError(\n            \"mode count did not match actual modes, failed to parse vorbis modes\"\n          );\n          throw new Error(\"Failed to read Vorbis stream\");\n        }\n\n        break;\n      }\n    }\n\n    // mode mask to read the mode from the first byte in the vorbis frame\n    mode.mask = (1 << Math.log2(mode.count)) - 1;\n    // previous window flag is the next bit after the mode mask\n    mode.prevMask = (mode.mask | 0x1) + 1;\n\n    return mode;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport Parser from \"../Parser\";\nimport OggPage from \"./OggPage\";\n\nimport FLACParser from \"../flac/FLACParser\";\nimport OpusParser from \"../opus/OpusParser\";\nimport VorbisParser from \"../vorbis/VorbisParser\";\n\nexport default class OggParser extends Parser {\n  constructor(onCodecUpdate, onCodec) {\n    super();\n    this._onCodecUpdate = onCodecUpdate;\n    this._onCodec = onCodec;\n    this.Frame = OggPage;\n    this._maxHeaderLength = 283;\n    this._codec = null;\n  }\n\n  get codec() {\n    return this._codec || \"\";\n  }\n\n  _matchBytes(matchString, bytes) {\n    return String.fromCharCode(...bytes).match(matchString);\n  }\n\n  getCodec({ data }) {\n    if (this._matchBytes(/\\x7fFLAC/, data.subarray(0, 5))) {\n      this._parser = new FLACParser(this._onCodecUpdate, this._onCodec);\n      return \"flac\";\n    } else if (this._matchBytes(/OpusHead/, data.subarray(0, 8))) {\n      this._parser = new OpusParser(this._onCodecUpdate, this._onCodec);\n      return \"opus\";\n    } else if (this._matchBytes(/\\x01vorbis/, data.subarray(0, 7))) {\n      this._parser = new VorbisParser(this._onCodecUpdate, this._onCodec);\n      return \"vorbis\";\n    }\n  }\n\n  parseFrames(data) {\n    const oggPages = this.fixedLengthFrame(data);\n\n    if (!oggPages.frames.length) {\n      return {\n        frames: [],\n        remainingData: oggPages.remainingData,\n      };\n    }\n\n    if (!this._codec) {\n      this._codec = this.getCodec(oggPages.frames[0]);\n      if (!this._codec) {\n        return {\n          frames: [],\n          remainingData: oggPages.remainingData,\n        };\n      }\n    }\n\n    return {\n      frames: oggPages.frames.flatMap(\n        (oggPage) => this._parser.parseFrames(oggPage).frames\n      ),\n      remainingData: oggPages.remainingData,\n    };\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of codec-parser.\n    \n    codec-parser is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    codec-parser is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { concatBuffers } from \"./utilities\";\nimport MPEGParser from \"./codecs/mpeg/MPEGParser\";\nimport AACParser from \"./codecs/aac/AACParser\";\nimport OggParser from \"./codecs/ogg/OggParser\";\n\nconst noOp = () => {};\n\nexport default class CodecParser {\n  constructor(mimeType, { onCodecUpdate, onCodec } = {}) {\n    this._inputMimeType = mimeType;\n    this._onCodecUpdate = onCodecUpdate || noOp;\n    this._onCodec = onCodec || noOp;\n\n    if (this._inputMimeType.match(/aac/)) {\n      this._codecParser = new AACParser(this._onCodecUpdate, this._onCodec);\n    } else if (this._inputMimeType.match(/mpeg/)) {\n      this._codecParser = new MPEGParser(this._onCodecUpdate, this._onCodec);\n    } else if (this._inputMimeType.match(/ogg/)) {\n      this._codecParser = new OggParser(this._onCodecUpdate, this._onCodec);\n    } else {\n      throw new Error(`Unsupported Codec ${mimeType}`);\n    }\n\n    this._frameNumber = 0;\n    this._totalBytesOut = 0;\n    this._totalSamples = 0;\n\n    this._frames = [];\n    this._codecData = new Uint8Array(0);\n\n    this._generator = this._generator();\n    this._generator.next();\n  }\n\n  /**\n   * @public\n   * @returns The detected codec\n   */\n  get codec() {\n    return this._codecParser.codec;\n  }\n\n  /**\n   * @public\n   * @description Returns an iterator for the passed in codec data.\n   * @param {Uint8Array} chunk Next chunk of codec data to read\n   * @returns {IterableIterator} Iterator that operates over the codec data.\n   * @yields {Uint8Array} Codec Frames\n   */\n  *iterator(chunk) {\n    for (\n      let i = this._generator.next(chunk);\n      i.value;\n      i = this._generator.next()\n    ) {\n      yield i.value;\n    }\n  }\n\n  *_generator() {\n    let frames = [];\n    // start parsing out frames\n    while (true) {\n      yield* this._sendReceiveData(frames);\n      frames = this._parseFrames();\n    }\n  }\n\n  /**\n   * @private\n   */\n  *_sendReceiveData(frames) {\n    for (const frame of frames) {\n      yield frame;\n    }\n\n    let codecData;\n\n    do {\n      codecData = yield;\n    } while (!codecData);\n\n    this._codecData = concatBuffers(this._codecData, codecData);\n  }\n\n  /**\n   * @private\n   */\n  _parseFrames() {\n    const { frames, remainingData } = this._codecParser.parseFrames(\n      this._codecData\n    );\n\n    this._codecData = this._codecData.subarray(remainingData);\n\n    return frames.map((frame) => {\n      frame.frameNumber = this._frameNumber++;\n      frame.totalBytesOut = this._totalBytesOut;\n      frame.totalSamples = this._totalSamples;\n      frame.totalDuration =\n        (this._totalSamples / frame.header.sampleRate) * 1000;\n\n      this._totalBytesOut += frame.data.length;\n      this._totalSamples += frame.samples;\n\n      return frame;\n    });\n  }\n}\n","import CodecParser from \"./src/CodecParser\";\n\nexport default CodecParser;\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nexport default class ContainerElement {\n  /**\n   * @abstract\n   * @description Container Object structure Abstract Class\n   * @param {any} name Name of the object\n   * @param {Array<Uint8>} [contents] Array of arrays or typed arrays, or a single number or typed array\n   * @param {Array<ContainerElement>} [objects] Array of objects to insert into this object\n   */\n  constructor({ name, contents = [], children = [] }) {\n    this._name = name;\n    this._contents = contents;\n    this._children = children;\n  }\n\n  /**\n   * @description Converts a string to a byte array\n   * @param {string} name String to convert\n   * @returns {Uint8Array}\n   */\n  static stringToByteArray(name) {\n    return [...name].map((char) => char.charCodeAt(0));\n  }\n\n  /**\n   * @description Converts a JavaScript number to Uint32\n   * @param {number} number Number to convert\n   * @returns {Uint32}\n   */\n  static getFloat64(number) {\n    const bytes = new Uint8Array(8);\n    new DataView(bytes.buffer).setFloat64(0, number);\n    return bytes;\n  }\n\n  /**\n   * @description Converts a JavaScript number to Uint32\n   * @param {number} number Number to convert\n   * @returns {Uint32}\n   */\n  static getUint64(number) {\n    const bytes = new Uint8Array(8);\n    new DataView(bytes.buffer).setBigUint64(0, BigInt(number));\n    return bytes;\n  }\n\n  /**\n   * @description Converts a JavaScript number to Uint32\n   * @param {number} number Number to convert\n   * @returns {Uint32}\n   */\n  static getUint32(number) {\n    const bytes = new Uint8Array(4);\n    new DataView(bytes.buffer).setUint32(0, number);\n    return bytes;\n  }\n\n  /**\n   * @description Converts a JavaScript number to Uint16\n   * @param {number} number Number to convert\n   * @returns {Uint32}\n   */\n  static getUint16(number) {\n    const bytes = new Uint8Array(2);\n    new DataView(bytes.buffer).setUint16(0, number);\n    return bytes;\n  }\n\n  /**\n   * @description Converts a JavaScript number to Int16\n   * @param {number} number Number to convert\n   * @returns {Uint32}\n   */\n  static getInt16(number) {\n    const bytes = new Uint8Array(2);\n    new DataView(bytes.buffer).setInt16(0, number);\n    return bytes;\n  }\n\n  static *flatten(array) {\n    for (const item of array) {\n      if (Array.isArray(item)) {\n        yield* ContainerElement.flatten(item);\n      } else {\n        yield item;\n      }\n    }\n  }\n\n  /**\n   * @returns {Uint8Array} Contents of this container element\n   */\n  get contents() {\n    const buffer = new Uint8Array(this.length);\n    const contents = this._buildContents();\n\n    let offset = 0;\n\n    for (const element of ContainerElement.flatten(contents)) {\n      if (typeof element !== \"object\") {\n        buffer[offset] = element;\n        offset++;\n      } else {\n        buffer.set(element, offset);\n        offset += element.length;\n      }\n    }\n\n    return buffer;\n  }\n\n  /**\n   * @returns {number} Length of this container element\n   */\n  get length() {\n    return this._buildLength();\n  }\n\n  _buildContents() {\n    return [\n      this._contents,\n      ...this._children.map((obj) => obj._buildContents()),\n    ];\n  }\n\n  _buildLength() {\n    let length;\n\n    if (Array.isArray(this._contents)) {\n      length = this._contents.reduce(\n        (acc, val) => acc + (val.length === undefined ? 1 : val.length),\n        0\n      );\n    } else {\n      length = this._contents.length === undefined ? 1 : this._contents.length;\n    }\n\n    return length + this._children.reduce((acc, obj) => acc + obj.length, 0);\n  }\n\n  addChild(object) {\n    this._children.push(object);\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport ContainerElement from \"../ContainerElement\";\n\nexport default class Box extends ContainerElement {\n  /**\n   * @description ISO/IEC 14496-12 Part 12 ISO Base Media File Format Box\n   * @param {string} name Name of the box (i.e. 'moov', 'moof', 'traf')\n   * @param {object} params Object containing contents or child boxes\n   * @param {Array<Uint8>} [params.contents] Array of bytes to insert into this box\n   * @param {Array<Box>} [params.children] Array of child boxes to insert into this box\n   */\n  constructor(name, { contents, children } = {}) {\n    super({ name, contents, children });\n  }\n\n  _buildContents() {\n    return [\n      ...this._lengthBytes,\n      ...ContainerElement.stringToByteArray(this._name),\n      ...super._buildContents(),\n    ];\n  }\n\n  _buildLength() {\n    if (!this._length) {\n      // length bytes + name length + content length\n      this._length = 4 + this._name.length + super._buildLength();\n      this._lengthBytes = ContainerElement.getUint32(this._length);\n    }\n\n    return this._length;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport ContainerElement from \"../ContainerElement\";\n\nexport default class ESTag extends ContainerElement {\n  constructor(tagNumber, { contents, tags } = {}) {\n    super({ name: tagNumber, contents, children: tags });\n  }\n\n  static getLength(length) {\n    const bytes = ContainerElement.getUint32(length);\n\n    bytes.every((byte, i, array) => {\n      if (byte === 0x00) {\n        array[i] = 0x80;\n        return true;\n      }\n      return false;\n    });\n\n    return bytes;\n  }\n\n  /**\n   * @returns {Uint8Array} Contents of this stream descriptor tag\n   */\n  _buildContents() {\n    return [this._name, ...this._lengthBytes, ...super._buildContents()];\n  }\n\n  _buildLength() {\n    if (!this._length) {\n      const length = super._buildLength();\n      this._lengthBytes = ESTag.getLength(length);\n      this._length = 1 + length + this._lengthBytes.length;\n    }\n\n    return this._length;\n  }\n\n  addTag(tag) {\n    this.addChild(tag);\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport ContainerElement from \"../ContainerElement\";\nimport Box from \"./Box\";\nimport ESTag from \"./ESTag\";\n\n/**\n * @description Fragmented ISO Base Media File Format Builder is a class to\n * wrap codec frames in a MP4 container for streaming MP3 / AAC compatibility in Firefox.\n */\nexport default class ISOBMFFContainer {\n  constructor(codec) {\n    this._codec = codec;\n  }\n\n  getCodecBox(header) {\n    /**\n     * @description Codec mapping for `esds` box\n     * https://stackoverflow.com/questions/3987850/mp4-atom-how-to-discriminate-the-audio-codec-is-it-aac-or-mp3\n     * https://web.archive.org/web/20180312163039/http://mp4ra.org/object.html\n     * 0x40 - MPEG-4 Audio\n     * 0x6b - MPEG-1 Audio (MPEG-1 Layers 1, 2, and 3)\n     * 0x69 - MPEG-2 Backward Compatible Audio (MPEG-2 Layers 1, 2, and 3)\n     * 0x67 - MPEG-2 AAC LC\n     */\n    switch (this._codec) {\n      case \"mp3\":\n        return this.getMp4a(header, 0x6b);\n      case \"mp4a.40.2\":\n        return this.getMp4a(header, 0x40);\n      case \"opus\":\n        return this.getOpus(header);\n      case \"flac\":\n        return this.getFlaC(header);\n    }\n  }\n\n  getOpus(header) {\n    // https://opus-codec.org/docs/opus_in_isobmff.html\n    return new Box(\"Opus\", {\n      /* prettier-ignore */\n      contents: [\n        0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n        0x00,0x01, // data reference index\n        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n        0x00,header.channels, // channel count\n        0x00,header.bitDepth, // PCM bitrate (16bit)\n        0x00,0x00, // predefined\n        0x00,0x00, // reserved\n        Box.getUint16(header.sampleRate),0x00,0x00, // sample rate 16.16 fixed-point\n      ],\n      children: [\n        new Box(\"dOps\", {\n          /* prettier-ignore */\n          contents: [0x00, // version\n            header.channels, // output channel count\n            Box.getUint16(header.preSkip), // pre skip\n            Box.getUint32(header.inputSampleRate),// input sample rate\n            Box.getInt16(header.outputGain), // output gain\n            header.channelMappingFamily, // channel mapping family int(8)\n            (header.channelMappingFamily !== 0 ? [\n              header.streamCount,\n              header.coupledStreamCount,\n              header.channelMappingTable // channel mapping table\n            ] : [])\n          ],\n        }),\n      ],\n    });\n  }\n\n  getFlaC(header) {\n    // https://github.com/xiph/flac/blob/master/doc/isoflac.txt\n    return new Box(\"fLaC\", {\n      /* prettier-ignore */\n      contents: [\n        0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n        0x00,0x01, // data reference index\n        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n        0x00,header.channels, // channel count\n        0x00,header.bitDepth, // PCM bitrate (16bit)\n        0x00,0x00, // predefined\n        0x00,0x00, // reserved\n        Box.getUint16(header.sampleRate),0x00,0x00, // sample rate 16.16 fixed-point\n        /*\n        When the bitstream's native sample rate is greater\n        than the maximum expressible value of 65535 Hz,\n        the samplerate field shall hold the greatest\n        expressible regular division of that rate. I.e.\n        the samplerate field shall hold 48000.0 for\n        native sample rates of 96 and 192 kHz. In the\n        case of unusual sample rates which do not have\n        an expressible regular division, the maximum value\n        of 65535.0 Hz should be used.\n        */\n      ],\n      children: [\n        new Box(\"dfLa\", {\n          /* prettier-ignore */\n          contents: [0x00, // version\n            0x00,0x00,0x00, // flags\n            // * `A........` Last metadata block flag\n            // * `.BBBBBBBB` BlockType\n            0x80, // last metadata block, stream info\n            0x00,0x00,0x22, // Length\n            Box.getUint16(header.blockSize), // maximum block size\n            Box.getUint16(header.blockSize), // minimum block size\n            0x00,0x00,0x00, // maximum frame size\n            0x00,0x00,0x00, // minimum frame size\n            Box.getUint32((header.sampleRate << 12) | (header.channels << 8) | ((header.bitDepth - 1) << 4)), // 20bits sample rate, 3bits channels, 5bits bitDepth - 1\n            0x00,0x00,0x00,0x00, // total samples\n            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 // md5 of stream\n          ],\n        }),\n      ],\n    });\n  }\n\n  getMp4a(header, esdsCodec) {\n    const streamDescriptorTag = new ESTag(4, {\n      /* prettier-ignore */\n      contents: [\n        esdsCodec,\n        0x15, // stream type(6bits)=5 audio, flags(2bits)=1\n        0x00,0x00,0x00, // 24bit buffer size\n        0x00,0x00,0x00,0x00, // max bitrate\n        0x00,0x00,0x00,0x00, // avg bitrate\n      ],\n    });\n\n    // mp4a.40.2\n    if (esdsCodec === 0x40) {\n      streamDescriptorTag.addTag(\n        new ESTag(5, {\n          contents: header.audioSpecificConfig,\n        })\n      );\n    }\n\n    return new Box(\"mp4a\", {\n      /* prettier-ignore */\n      contents: [0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n        0x00,0x01, // data reference index\n        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n        0x00,header.channels, // channel count\n        0x00,0x10, // PCM bitrate (16bit)\n        0x00,0x00, // Compression ID\n        0x00,0x00, // Packet size\n        Box.getUint16(header.sampleRate),0x00,0x00], // sample rate unsigned floating point\n      children: [\n        new Box(\"esds\", {\n          contents: [0x00, 0x00, 0x00, 0x00],\n          children: [\n            new ESTag(3, {\n              contents: [\n                0x00,\n                0x01, // ES_ID = 1\n                0x00, // flags etc = 0\n              ],\n              tags: [\n                streamDescriptorTag,\n                new ESTag(6, {\n                  contents: 0x02,\n                }),\n              ],\n            }),\n          ],\n        }),\n      ],\n    });\n  }\n\n  /**\n   * @param {Header} header Codec frame\n   * @returns {Uint8Array} Filetype and Movie Box information for the codec\n   */\n  getInitializationSegment({ header, samples }) {\n    return new ContainerElement({\n      children: [\n        new Box(\"ftyp\", {\n          /* prettier-ignore */\n          contents: [Box.stringToByteArray(\"iso5\"), // major brand\n            0x00,0x00,0x02,0x00, // minor version\n            Box.stringToByteArray(\"iso6mp41\")], // compatible brands\n        }),\n        new Box(\"moov\", {\n          children: [\n            new Box(\"mvhd\", {\n              /* prettier-ignore */\n              contents: [0x00, // version\n                0x00,0x00,0x00, // flags\n                0x00,0x00,0x00,0x00, // creation time\n                0x00,0x00,0x00,0x00, // modification time\n                0x00,0x00,0x03,0xe8, // timescale\n                0x00,0x00,0x00,0x00, // duration\n                0x00,0x01,0x00,0x00, // rate\n                0x01,0x00, // volume\n                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n                0x00,0x01,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, // a b u (matrix structure)\n                0x00,0x00,0x00,0x00, 0x00,0x01,0x00,0x00, 0x00,0x00,0x00,0x00, // c d v\n                0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x40,0x00,0x00,0x00, // x y w\n                0x00,0x00,0x00,0x00, // preview time\n                0x00,0x00,0x00,0x00, // preview duration\n                0x00,0x00,0x00,0x00, // poster time\n                0x00,0x00,0x00,0x00, // selection time\n                0x00,0x00,0x00,0x00, // selection duration\n                0x00,0x00,0x00,0x00, // current time\n                0x00,0x00,0x00,0x02], // next track\n            }),\n            new Box(\"trak\", {\n              children: [\n                new Box(\"tkhd\", {\n                  /* prettier-ignore */\n                  contents: [0x00, // version\n                    0x00,0x00,0x03, // flags (0x01 - track enabled, 0x02 - track in movie, 0x04 - track in preview, 0x08 - track in poster)\n                    0x00,0x00,0x00,0x00, // creation time\n                    0x00,0x00,0x00,0x00, // modification time\n                    0x00,0x00,0x00,0x01, // track id\n                    0x00,0x00,0x00,0x00, // reserved\n                    0x00,0x00,0x00,0x00, // duration\n                    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // reserved\n                    0x00,0x00, // layer\n                    0x00,0x01, // alternate group\n                    0x01,0x00, // volume\n                    0x00,0x00, // reserved\n                    0x00,0x01,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, // a b u (matrix structure)\n                    0x00,0x00,0x00,0x00, 0x00,0x01,0x00,0x00, 0x00,0x00,0x00,0x00, // c d v \n                    0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x40,0x00,0x00,0x00, // x y w\n                    0x00,0x00,0x00,0x00, // track width\n                    0x00,0x00,0x00,0x00], // track height\n                }),\n                new Box(\"mdia\", {\n                  children: [\n                    new Box(\"mdhd\", {\n                      /* prettier-ignore */\n                      contents: [0x00, // version\n                        0x00,0x00,0x00, // flags\n                        0x00,0x00,0x00,0x00, // creation time (in seconds since midnight, January 1, 1904)\n                        0x00,0x00,0x00,0x00, // modification time\n                        Box.getUint32(header.sampleRate), // time scale\n                        0x00,0x00,0x00,0x00, // duration\n                        0x55,0xc4, // language\n                        0x00,0x00], // quality\n                    }),\n                    new Box(\"hdlr\", {\n                      /* prettier-ignore */\n                      contents: [0x00, // version\n                        0x00,0x00,0x00, // flags\n                        Box.stringToByteArray('mhlr'), // component type (mhlr, dhlr)\n                        Box.stringToByteArray('soun'), // component subtype (vide' for video data, 'soun' for sound data or ‘subt’ for subtitles)\n                        0x00,0x00,0x00,0x00, // component manufacturer\n                        0x00,0x00,0x00,0x00, // component flags\n                        0x00,0x00,0x00,0x00, // component flags mask\n                        0x00], // String that specifies the name of the component, terminated by a null character\n                    }),\n                    new Box(\"minf\", {\n                      children: [\n                        new Box(\"stbl\", {\n                          children: [\n                            new Box(\"stsd\", {\n                              // Sample description atom\n                              /* prettier-ignore */\n                              contents: [0x00, // version\n                                0x00,0x00,0x00, // flags\n                                0x00,0x00,0x00,0x01], // entry count\n                              children: [this.getCodecBox(header)],\n                            }),\n                            new Box(\"stts\", {\n                              // Time-to-sample atom\n                              /* prettier-ignore */\n                              contents: [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],\n                            }),\n                            new Box(\"stsc\", {\n                              // Sample-to-chunk atom\n                              /* prettier-ignore */\n                              contents: [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],\n                            }),\n                            new Box(\"stsz\", {\n                              // Sample Size atom\n                              /* prettier-ignore */\n                              contents: [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\n                                0x00,0x00,0x00,0x00],\n                            }),\n                            new Box(\"stco\", {\n                              // Chunk Offset atom\n                              /* prettier-ignore */\n                              contents: [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],\n                            }),\n                          ],\n                        }),\n                      ],\n                    }),\n                  ],\n                }),\n              ],\n            }),\n            new Box(\"mvex\", {\n              children: [\n                new Box(\"trex\", {\n                  /* prettier-ignore */\n                  contents: [0x00,0x00,0x00,0x00, // flags\n                    0x00,0x00,0x00,0x01, // track id\n                    0x00,0x00,0x00,0x01, // default_sample_description_index\n                    Box.getUint32(samples), // default_sample_duration\n                    0x00,0x00,0x00,0x00, // default_sample_size;\n                    0x00,0x00,0x00,0x00], // default_sample_flags;\n                }),\n              ],\n            }),\n          ],\n        }),\n      ],\n    }).contents;\n  }\n\n  /**\n   * @description Wraps codec frames into a Movie Fragment\n   * @param {Array<Frame>} frames Frames to contain in this Movie Fragment\n   * @returns {Uint8Array} Movie Fragment containing the frames\n   */\n  getMediaSegment(frames) {\n    return new ContainerElement({\n      children: [\n        new Box(\"moof\", {\n          children: [\n            new Box(\"mfhd\", {\n              /* prettier-ignore */\n              contents: [0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00], // sequence number\n            }),\n            new Box(\"traf\", {\n              children: [\n                new Box(\"tfhd\", {\n                  /* prettier-ignore */\n                  contents: [0x00, // version\n                    0b00000010,0x00,0b00000000, // flags\n                    // * `AB|00000000|00CDE0FG`\n                    // * `A.|........|........` default-base-is-moof\n                    // * `.B|........|........` duration-is-empty\n                    // * `..|........|..C.....` default-sample-flags-present\n                    // * `..|........|...D....` default-sample-size-present\n                    // * `..|........|....E...` default-sample-duration-present\n                    // * `..|........|......F.` sample-description-index-present\n                    // * `..|........|.......G` base-data-offset-present\n                    0x00,0x00,0x00,0x01], // track id\n                }),\n                new Box(\"tfdt\", {\n                  /* prettier-ignore */\n                  contents: [0x00, // version\n                    0x00,0x00,0x00, // flags\n                    0x00,0x00,0x00,0x00], // base media decode time\n                }),\n                new Box(\"trun\", {\n                  /* prettier-ignore */\n                  contents: [0x00, // version\n                    0x00,0b0000010,0b00000001, // flags\n                    // * `ABCD|00000E0F`\n                    // * `A...|........` sample‐composition‐time‐offsets‐present\n                    // * `.B..|........` sample‐flags‐present\n                    // * `..C.|........` sample‐size‐present\n                    // * `...D|........` sample‐duration‐present\n                    // * `....|.....E..` first‐sample‐flags‐present\n                    // * `....|.......G` data-offset-present\n                    Box.getUint32(frames.length), // number of samples\n                    Box.getUint32(92 + frames.length * 4), // data offset\n                    ...frames.map(({data}) => Box.getUint32(data.length))], // samples size per frame\n                }),\n              ],\n            }),\n          ],\n        }),\n        new Box(\"mdat\", {\n          contents: frames.map(({ data }) => data),\n        }),\n      ],\n    }).contents;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nconst xiphLacing = (...buffers) =>\n  buffers.flatMap((buffer) => {\n    const lacing = [];\n    for (let l = buffer.length; l >= 0; l -= 255) {\n      lacing.push(l >= 255 ? 255 : l);\n    }\n    return lacing;\n  });\n\nconst logError = (...messages) => {\n  console.error(\n    \"mse-audio-wrapper\",\n    messages.reduce((acc, message) => acc + \"\\n  \" + message, \"\")\n  );\n};\n\nexport { logError, xiphLacing };\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport { logError } from \"../../utilities\";\nimport ContainerElement from \"../ContainerElement\";\n\nexport default class EBML extends ContainerElement {\n  /**\n   * @description Extensible Binary Meta Language element\n   * @param {name} name ID of the EBML element\n   * @param {object} params Object containing contents or children\n   * @param {boolean} [isUnknownLength] Set to true to use the unknown length constant for EBML\n   * @param {Array<Uint8>} [params.contents] Array of bytes to insert into this box\n   * @param {Array<Box>} [params.children] Array of children to insert into this box\n   */\n  constructor(name, { contents, children, isUnknownLength = false } = {}) {\n    super({ name, contents, children });\n\n    this._isUnknownLength = isUnknownLength;\n  }\n\n  /**\n   * @description Converts a JavaScript number into a variable length EBML integer\n   * @param {number} number Number to convert\n   */\n  static getUintVariable(number) {\n    let buffer;\n\n    if (number < 0x7f) {\n      buffer = [0b10000000 | number];\n    } else if (number < 0x3fff) {\n      buffer = ContainerElement.getUint16(number);\n      buffer[0] |= 0b01000000;\n    } else if (number < 0x1fffff) {\n      buffer = ContainerElement.getUint32(number).subarray(1);\n      buffer[0] |= 0b00100000;\n    } else if (number < 0xfffffff) {\n      buffer = ContainerElement.getUint32(number);\n      buffer[0] |= 0b00010000;\n    } else if (number < 0x7ffffffff) {\n      buffer = ContainerElement.getUint64(number).subarray(3);\n      buffer[0] |= 0b00001000;\n    } else if (number < 0x3ffffffffff) {\n      buffer = ContainerElement.getUint64(number).subarray(2);\n      buffer[0] |= 0b00000100;\n    } else if (number < 0x1ffffffffffff) {\n      buffer = ContainerElement.getUint64(number).subarray(1);\n      buffer[0] |= 0b00000010;\n    } else if (number < 0xffffffffffffff) {\n      buffer = ContainerElement.getUint64(number);\n      buffer[0] |= 0b00000001;\n    } else if (typeof number !== \"number\" || isNaN(number)) {\n      logError(\n        `EBML Variable integer must be a number, instead received ${number}`\n      );\n      throw new Error(\"mse-audio-wrapper: Unable to encode WEBM\");\n    }\n\n    return buffer;\n  }\n\n  _buildContents() {\n    return [...this._name, ...this._lengthBytes, ...super._buildContents()];\n  }\n\n  _buildLength() {\n    if (!this._length) {\n      this._contentLength = super._buildLength();\n      this._lengthBytes = this._isUnknownLength\n        ? [0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff] // unknown length constant\n        : EBML.getUintVariable(this._contentLength);\n      this._length =\n        this._name.length + this._lengthBytes.length + this._contentLength;\n    }\n\n    return this._length;\n  }\n}\n\n// https://tools.ietf.org/id/draft-lhomme-cellar-matroska-00.html\nexport const id = {\n  AlphaMode: [0x53, 0xc0],\n  AspectRatioType: [0x54, 0xb3],\n  AttachedFile: [0x61, 0xa7],\n  AttachmentLink: [0x74, 0x46],\n  Attachments: [0x19, 0x41, 0xa4, 0x69],\n  Audio: [0xe1],\n  BitDepth: [0x62, 0x64],\n  BitsPerChannel: [0x55, 0xb2],\n  Block: [0xa1],\n  BlockAddID: [0xee],\n  BlockAdditional: [0xa5],\n  BlockAdditions: [0x75, 0xa1],\n  BlockDuration: [0x9b],\n  BlockGroup: [0xa0],\n  BlockMore: [0xa6],\n  CbSubsamplingHorz: [0x55, 0xb5],\n  CbSubsamplingVert: [0x55, 0xb6],\n  Channels: [0x9f],\n  ChapCountry: [0x43, 0x7e],\n  ChapLanguage: [0x43, 0x7c],\n  ChapProcess: [0x69, 0x44],\n  ChapProcessCodecID: [0x69, 0x55],\n  ChapProcessCommand: [0x69, 0x11],\n  ChapProcessData: [0x69, 0x33],\n  ChapProcessPrivate: [0x45, 0x0d],\n  ChapProcessTime: [0x69, 0x22],\n  ChapString: [0x85],\n  ChapterAtom: [0xb6],\n  ChapterDisplay: [0x80],\n  ChapterFlagEnabled: [0x45, 0x98],\n  ChapterFlagHidden: [0x98],\n  ChapterPhysicalEquiv: [0x63, 0xc3],\n  Chapters: [0x10, 0x43, 0xa7, 0x70],\n  ChapterSegmentEditionUID: [0x6e, 0xbc],\n  ChapterSegmentUID: [0x6e, 0x67],\n  ChapterStringUID: [0x56, 0x54],\n  ChapterTimeEnd: [0x92],\n  ChapterTimeStart: [0x91],\n  ChapterTrack: [0x8f],\n  ChapterTrackNumber: [0x89],\n  ChapterTranslate: [0x69, 0x24],\n  ChapterTranslateCodec: [0x69, 0xbf],\n  ChapterTranslateEditionUID: [0x69, 0xfc],\n  ChapterTranslateID: [0x69, 0xa5],\n  ChapterUID: [0x73, 0xc4],\n  ChromaSitingHorz: [0x55, 0xb7],\n  ChromaSitingVert: [0x55, 0xb8],\n  ChromaSubsamplingHorz: [0x55, 0xb3],\n  ChromaSubsamplingVert: [0x55, 0xb4],\n  Cluster: [0x1f, 0x43, 0xb6, 0x75],\n  CodecDecodeAll: [0xaa],\n  CodecDelay: [0x56, 0xaa],\n  CodecID: [0x86],\n  CodecName: [0x25, 0x86, 0x88],\n  CodecPrivate: [0x63, 0xa2],\n  CodecState: [0xa4],\n  Colour: [0x55, 0xb0],\n  ColourSpace: [0x2e, 0xb5, 0x24],\n  ContentCompAlgo: [0x42, 0x54],\n  ContentCompression: [0x50, 0x34],\n  ContentCompSettings: [0x42, 0x55],\n  ContentEncAlgo: [0x47, 0xe1],\n  ContentEncKeyID: [0x47, 0xe2],\n  ContentEncoding: [0x62, 0x40],\n  ContentEncodingOrder: [0x50, 0x31],\n  ContentEncodings: [0x6d, 0x80],\n  ContentEncodingScope: [0x50, 0x32],\n  ContentEncodingType: [0x50, 0x33],\n  ContentEncryption: [0x50, 0x35],\n  ContentSigAlgo: [0x47, 0xe5],\n  ContentSigHashAlgo: [0x47, 0xe6],\n  ContentSigKeyID: [0x47, 0xe4],\n  ContentSignature: [0x47, 0xe3],\n  CRC32: [0xbf],\n  CueBlockNumber: [0x53, 0x78],\n  CueClusterPosition: [0xf1],\n  CueCodecState: [0xea],\n  CueDuration: [0xb2],\n  CuePoint: [0xbb],\n  CueReference: [0xdb],\n  CueRefTime: [0x96],\n  CueRelativePosition: [0xf0],\n  Cues: [0x1c, 0x53, 0xbb, 0x6b],\n  CueTime: [0xb3],\n  CueTrack: [0xf7],\n  CueTrackPositions: [0xb7],\n  DateUTC: [0x44, 0x61],\n  DefaultDecodedFieldDuration: [0x23, 0x4e, 0x7a],\n  DefaultDuration: [0x23, 0xe3, 0x83],\n  DiscardPadding: [0x75, 0xa2],\n  DisplayHeight: [0x54, 0xba],\n  DisplayUnit: [0x54, 0xb2],\n  DisplayWidth: [0x54, 0xb0],\n  DocType: [0x42, 0x82],\n  DocTypeReadVersion: [0x42, 0x85],\n  DocTypeVersion: [0x42, 0x87],\n  Duration: [0x44, 0x89],\n  EBML: [0x1a, 0x45, 0xdf, 0xa3],\n  EBMLMaxIDLength: [0x42, 0xf2],\n  EBMLMaxSizeLength: [0x42, 0xf3],\n  EBMLReadVersion: [0x42, 0xf7],\n  EBMLVersion: [0x42, 0x86],\n  EditionEntry: [0x45, 0xb9],\n  EditionFlagDefault: [0x45, 0xdb],\n  EditionFlagHidden: [0x45, 0xbd],\n  EditionFlagOrdered: [0x45, 0xdd],\n  EditionUID: [0x45, 0xbc],\n  FieldOrder: [0x9d],\n  FileData: [0x46, 0x5c],\n  FileDescription: [0x46, 0x7e],\n  FileMimeType: [0x46, 0x60],\n  FileName: [0x46, 0x6e],\n  FileUID: [0x46, 0xae],\n  FlagDefault: [0x88],\n  FlagEnabled: [0xb9],\n  FlagForced: [0x55, 0xaa],\n  FlagInterlaced: [0x9a],\n  FlagLacing: [0x9c],\n  Info: [0x15, 0x49, 0xa9, 0x66],\n  LaceNumber: [0xcc],\n  Language: [0x22, 0xb5, 0x9c],\n  LuminanceMax: [0x55, 0xd9],\n  LuminanceMin: [0x55, 0xda],\n  MasteringMetadata: [0x55, 0xd0],\n  MatrixCoefficients: [0x55, 0xb1],\n  MaxBlockAdditionID: [0x55, 0xee],\n  MaxCache: [0x6d, 0xf8],\n  MaxCLL: [0x55, 0xbc],\n  MaxFALL: [0x55, 0xbd],\n  MinCache: [0x6d, 0xe7],\n  MuxingApp: [0x4d, 0x80],\n  Name: [0x53, 0x6e],\n  NextFilename: [0x3e, 0x83, 0xbb],\n  NextUID: [0x3e, 0xb9, 0x23],\n  OutputSamplingFrequency: [0x78, 0xb5],\n  PixelCropBottom: [0x54, 0xaa],\n  PixelCropLeft: [0x54, 0xcc],\n  PixelCropRight: [0x54, 0xdd],\n  PixelCropTop: [0x54, 0xbb],\n  PixelHeight: [0xba],\n  PixelWidth: [0xb0],\n  Position: [0xa7],\n  PrevFilename: [0x3c, 0x83, 0xab],\n  PrevSize: [0xab],\n  PrevUID: [0x3c, 0xb9, 0x23],\n  Primaries: [0x55, 0xbb],\n  PrimaryBChromaticityX: [0x55, 0xd5],\n  PrimaryBChromaticityY: [0x55, 0xd6],\n  PrimaryGChromaticityX: [0x55, 0xd3],\n  PrimaryGChromaticityY: [0x55, 0xd4],\n  PrimaryRChromaticityX: [0x55, 0xd1],\n  PrimaryRChromaticityY: [0x55, 0xd2],\n  Range: [0x55, 0xb9],\n  ReferenceBlock: [0xfb],\n  ReferencePriority: [0xfa],\n  SamplingFrequency: [0xb5],\n  Seek: [0x4d, 0xbb],\n  SeekHead: [0x11, 0x4d, 0x9b, 0x74],\n  SeekID: [0x53, 0xab],\n  SeekPosition: [0x53, 0xac],\n  SeekPreRoll: [0x56, 0xbb],\n  Segment: [0x18, 0x53, 0x80, 0x67],\n  SegmentFamily: [0x44, 0x44],\n  SegmentFilename: [0x73, 0x84],\n  SegmentUID: [0x73, 0xa4],\n  SilentTrackNumber: [0x58, 0xd7],\n  SilentTracks: [0x58, 0x54],\n  SimpleBlock: [0xa3],\n  SimpleTag: [0x67, 0xc8],\n  Slices: [0x8e],\n  StereoMode: [0x53, 0xb8],\n  Tag: [0x73, 0x73],\n  TagAttachmentUID: [0x63, 0xc6],\n  TagBinary: [0x44, 0x85],\n  TagChapterUID: [0x63, 0xc4],\n  TagDefault: [0x44, 0x84],\n  TagEditionUID: [0x63, 0xc9],\n  TagLanguage: [0x44, 0x7a],\n  TagName: [0x45, 0xa3],\n  Tags: [0x12, 0x54, 0xc3, 0x67],\n  TagString: [0x44, 0x87],\n  TagTrackUID: [0x63, 0xc5],\n  Targets: [0x63, 0xc0],\n  TargetType: [0x63, 0xca],\n  TargetTypeValue: [0x68, 0xca],\n  Timestamp: [0xe7],\n  TimestampScale: [0x2a, 0xd7, 0xb1],\n  TimeSlice: [0xe8],\n  Title: [0x7b, 0xa9],\n  TrackCombinePlanes: [0xe3],\n  TrackEntry: [0xae],\n  TrackJoinBlocks: [0xe9],\n  TrackJoinUID: [0xed],\n  TrackNumber: [0xd7],\n  TrackOperation: [0xe2],\n  TrackOverlay: [0x6f, 0xab],\n  TrackPlane: [0xe4],\n  TrackPlaneType: [0xe6],\n  TrackPlaneUID: [0xe5],\n  Tracks: [0x16, 0x54, 0xae, 0x6b],\n  TrackTranslate: [0x66, 0x24],\n  TrackTranslateCodec: [0x66, 0xbf],\n  TrackTranslateEditionUID: [0x66, 0xfc],\n  TrackTranslateTrackID: [0x66, 0xa5],\n  TrackType: [0x83],\n  TrackUID: [0x73, 0xc5],\n  TransferCharacteristics: [0x55, 0xba],\n  Video: [0xe0],\n  Void: [0xec],\n  WhitePointChromaticityX: [0x55, 0xd7],\n  WhitePointChromaticityY: [0x55, 0xd8],\n  WritingApp: [0x57, 0x41],\n};\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport ContainerElement from \"../ContainerElement\";\nimport EBML, { id } from \"./EBML\";\nimport { xiphLacing } from \"../../utilities\";\n\nexport default class WEBMContainer {\n  constructor(codec) {\n    switch (codec) {\n      case \"opus\": {\n        this._codecId = \"A_OPUS\";\n        this._getCodecSpecificTrack = (header) => [\n          new EBML(id.CodecDelay, {\n            contents: EBML.getUint32(\n              Math.round(header.preSkip * this._timestampScale)\n            ),\n          }), // OPUS codec delay\n          new EBML(id.SeekPreRoll, {\n            contents: EBML.getUint32(Math.round(3840 * this._timestampScale)),\n          }), // OPUS seek preroll 80ms\n          new EBML(id.CodecPrivate, { contents: header.data }), // OpusHead bytes\n        ];\n        break;\n      }\n      case \"vorbis\": {\n        this._codecId = \"A_VORBIS\";\n        this._getCodecSpecificTrack = (header) => [\n          new EBML(id.CodecPrivate, {\n            contents: [\n              0x02, // number of packets\n              xiphLacing(header.data, header.vorbisComments),\n              header.data,\n              header.vorbisComments,\n              header.vorbisSetup,\n            ],\n          }),\n        ];\n        break;\n      }\n    }\n  }\n\n  getInitializationSegment({ header }) {\n    this._timestampScale = 1000000000 / header.sampleRate;\n\n    return new ContainerElement({\n      children: [\n        new EBML(id.EBML, {\n          children: [\n            new EBML(id.EBMLVersion, { contents: 1 }),\n            new EBML(id.EBMLReadVersion, { contents: 1 }),\n            new EBML(id.EBMLMaxIDLength, { contents: 4 }),\n            new EBML(id.EBMLMaxSizeLength, { contents: 8 }),\n            new EBML(id.DocType, { contents: EBML.stringToByteArray(\"webm\") }),\n            new EBML(id.DocTypeVersion, { contents: 4 }),\n            new EBML(id.DocTypeReadVersion, { contents: 2 }),\n          ],\n        }),\n        new EBML(id.Segment, {\n          isUnknownLength: true,\n          children: [\n            new EBML(id.Info, {\n              children: [\n                new EBML(id.TimestampScale, {\n                  contents: EBML.getUint32(\n                    Math.floor(this._timestampScale) // Base timestamps on sample rate vs. milliseconds https://www.matroska.org/technical/notes.html#timestamps\n                  ),\n                }),\n                new EBML(id.MuxingApp, {\n                  contents: EBML.stringToByteArray(\"mse-audio-wrapper\"),\n                }),\n                new EBML(id.WritingApp, {\n                  contents: EBML.stringToByteArray(\"mse-audio-wrapper\"),\n                }),\n              ],\n            }),\n            new EBML(id.Tracks, {\n              children: [\n                new EBML(id.TrackEntry, {\n                  children: [\n                    new EBML(id.TrackNumber, { contents: 0x01 }),\n                    new EBML(id.TrackUID, { contents: 0x01 }),\n                    new EBML(id.FlagLacing, { contents: 0x00 }),\n                    new EBML(id.CodecID, {\n                      contents: EBML.stringToByteArray(this._codecId),\n                    }),\n                    new EBML(id.TrackType, { contents: 0x02 }), // audio\n                    new EBML(id.Audio, {\n                      children: [\n                        new EBML(id.Channels, { contents: header.channels }),\n                        new EBML(id.SamplingFrequency, {\n                          contents: EBML.getFloat64(header.sampleRate),\n                        }),\n                        new EBML(id.BitDepth, { contents: header.bitDepth }),\n                      ],\n                    }),\n                    ...this._getCodecSpecificTrack(header),\n                  ],\n                }),\n              ],\n            }),\n          ],\n        }),\n      ],\n    }).contents;\n  }\n\n  getMediaSegment(frames) {\n    const offsetSamples = frames[0].totalSamples;\n\n    return new EBML(id.Cluster, {\n      children: [\n        new EBML(id.Timestamp, {\n          contents: EBML.getUintVariable(offsetSamples), // Absolute timecode of the cluster\n        }),\n        ...frames.map(\n          ({ data, totalSamples }) =>\n            new EBML(id.SimpleBlock, {\n              contents: [\n                0x81, // track number\n                EBML.getInt16(totalSamples - offsetSamples), // timestamp relative to cluster Int16\n                0x80, // No lacing\n                data, // ogg page contents\n              ],\n            })\n        ),\n      ],\n    }).contents;\n  }\n}\n","/* Copyright 2020-2021 Ethan Halsall\n    \n    This file is part of mse-audio-wrapper.\n    \n    mse-audio-wrapper is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    mse-audio-wrapper is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>\n*/\n\nimport CodecParser from \"codec-parser\";\n\nimport ISOBMFFContainer from \"./containers/isobmff/ISOBMFFContainer\";\nimport WEBMContainer from \"./containers/webm/WEBMContainer\";\n\nconst noOp = () => {};\n\nexport default class MSEAudioWrapper {\n  /**\n   * @description Wraps audio data into media source API compatible containers\n   * @param {string} mimeType Mimetype of the audio data to wrap\n   * @param {object} options.preferredContainer Preferred audio container to output if multiple containers are available\n   * @param {number} options.minBytesPerSegment Minimum number of bytes to process before returning a media segment\n   * @param {number} options.minFramesPerSegment Minimum number of frames to process before returning a media segment\n   * @param {number} options.minBytesPerSegment Minimum number of bytes to process before returning a media segment\n   */\n  constructor(mimeType, options = {}) {\n    this._inputMimeType = mimeType;\n\n    this.PREFERRED_CONTAINER = options.preferredContainer || \"webm\";\n    this.MIN_FRAMES = options.minFramesPerSegment || 4;\n    this.MAX_FRAMES = options.maxFramesPerSegment || 50;\n    this.MIN_FRAMES_LENGTH = options.minBytesPerSegment || 1022;\n    this.MAX_SAMPLES_PER_SEGMENT = Infinity;\n\n    this._onMimeType = options.onMimeType || noOp;\n\n    this._frames = [];\n    this._codecParser = new CodecParser(mimeType, {\n      onCodec: (codec) => {\n        this._container = this._getContainer(codec);\n        this._onMimeType(this._mimeType);\n      },\n      onCodecUpdate: options.onCodecUpdate,\n    });\n  }\n\n  /**\n   * @public\n   * @returns The mimetype being returned from MSEAudioWrapper\n   */\n  get mimeType() {\n    return this._mimeType;\n  }\n\n  /**\n   * @public\n   * @returns The mimetype of the incoming audio data\n   */\n  get inputMimeType() {\n    return this._inputMimeType;\n  }\n\n  /**\n   * @public\n   * @description Returns an iterator for the passed in codec data.\n   * @param {Uint8Array} chunk Next chunk of codec data to read\n   * @returns {Iterator} Iterator that operates over the codec data.\n   * @yields {Uint8Array} Movie Fragments containing codec frames\n   */\n  *iterator(chunk) {\n    this._frames.push(...this._codecParser.iterator(chunk));\n\n    if (this._frames.length) {\n      const groups = this._groupFrames();\n\n      if (groups.length) {\n        if (!this._sentInitialSegment) {\n          this._sentInitialSegment = true;\n\n          yield this._container.getInitializationSegment(groups[0][0]);\n        }\n        for (const frameGroup of groups) {\n          yield this._container.getMediaSegment(frameGroup);\n        }\n      }\n    }\n  }\n\n  /**\n   * @private\n   */\n  _groupFrames() {\n    const groups = [[]];\n    let currentGroup = groups[0];\n    let samples = 0;\n\n    for (const frame of this._frames) {\n      if (\n        currentGroup.length === this.MAX_FRAMES ||\n        samples >= this.MAX_SAMPLES_PER_SEGMENT\n      ) {\n        samples = 0;\n        groups.push((currentGroup = [])); // create new group\n      }\n\n      currentGroup.push(frame);\n      samples += frame.samples;\n    }\n\n    // store remaining frames\n    this._frames =\n      currentGroup.length < this.MIN_FRAMES ||\n      currentGroup.reduce((acc, frame) => acc + frame.data.length, 0) <\n        this.MIN_FRAMES_LENGTH\n        ? groups.pop()\n        : [];\n\n    return groups;\n  }\n\n  /**\n   * @private\n   */\n  _getContainer(codec) {\n    switch (codec) {\n      case \"mpeg\":\n        this._mimeType = 'audio/mp4;codecs=\"mp3\"';\n        return new ISOBMFFContainer(\"mp3\");\n      case \"aac\":\n        this._mimeType = 'audio/mp4;codecs=\"mp4a.40.2\"';\n        return new ISOBMFFContainer(\"mp4a.40.2\");\n      case \"flac\":\n        this._mimeType = 'audio/mp4;codecs=\"flac\"';\n        return new ISOBMFFContainer(\"flac\");\n      case \"vorbis\":\n        this._mimeType = 'audio/webm;codecs=\"vorbis\"';\n\n        this.MAX_SAMPLES_PER_SEGMENT = 32767;\n        return new WEBMContainer(\"vorbis\");\n      case \"opus\":\n        if (this.PREFERRED_CONTAINER === \"webm\") {\n          this._mimeType = 'audio/webm;codecs=\"opus\"';\n\n          this.MAX_SAMPLES_PER_SEGMENT = 32767;\n          return new WEBMContainer(\"opus\");\n        }\n        this._mimeType = 'audio/mp4;codecs=\"opus\"';\n        return new ISOBMFFContainer(\"opus\");\n    }\n  }\n}\n","import MSEAudioWrapper from \"./src/MSEAudioWrapper\";\n\nexport default MSEAudioWrapper;\n","import Player from \"./Player\";\nimport MSEAudioWrapper from \"mse-audio-wrapper\";\n\nconst BUFFER = 10; // seconds of audio to store in SourceBuffer\nconst BUFFER_INTERVAL = 10; // seconds before removing from SourceBuffer\n\nexport default class MediaSourcePlayer extends Player {\n  constructor(options) {\n    super(options);\n\n    this._createMediaSource();\n  }\n\n  static isSupported() {\n    try {\n      new MediaSource();\n    } catch {\n      return false;\n    }\n\n    return true;\n  }\n\n  async reset() {\n    await this._createMediaSource();\n  }\n\n  get metadataTimestamp() {\n    return (\n      (this._mediaSource &&\n        this._mediaSource.sourceBuffers.length &&\n        Math.max(\n          // work-around for WEBM reporting a negative timestampOffset\n          this._mediaSource.sourceBuffers[0].timestampOffset,\n          this._mediaSource.sourceBuffers[0].buffered.length\n            ? this._mediaSource.sourceBuffers[0].buffered.end(0)\n            : 0\n        )) ||\n      0\n    );\n  }\n\n  getOnStream(res) {\n    const sourceBufferPromise = this._getMimeType(\n      res.headers.get(\"content-type\")\n    ).then((mimeType) => this._createSourceBuffer(mimeType));\n\n    const onStream = async ({ stream }) => {\n      this._fireEvent(this._events.STREAM, stream);\n      await sourceBufferPromise;\n      await this._appendSourceBuffer(stream);\n    };\n\n    return this._mseAudioWrapper\n      ? async ({ stream }) => {\n          for await (const fragment of this._mseAudioWrapper.iterator(stream)) {\n            await onStream({ stream: fragment });\n          }\n        }\n      : onStream;\n  }\n\n  async _getMimeType(inputMimeType) {\n    if (MediaSource.isTypeSupported(inputMimeType)) {\n      return inputMimeType;\n    } else {\n      const mimeType = await new Promise((onMimeType) => {\n        this._mseAudioWrapper = new MSEAudioWrapper(inputMimeType, {\n          onCodecUpdate: (...args) =>\n            this._fireEvent(this._events.CODEC_UPDATE, ...args),\n          onMimeType,\n        });\n      });\n\n      if (!MediaSource.isTypeSupported(mimeType)) {\n        this._fireEvent(\n          this._events.ERROR,\n          `Media Source Extensions API in your browser does not support ${inputMimeType} or ${mimeType}`,\n          \"See: https://caniuse.com/mediasource and https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API\"\n        );\n        const error = new Error(`Unsupported Media Source Codec ${mimeType}`);\n        error.name = \"CodecError\";\n        throw error;\n      }\n\n      return mimeType;\n    }\n  }\n\n  async _createSourceBuffer(mimeType) {\n    await this._mediaSourcePromise;\n\n    this._sourceBufferRemoved = 0;\n    this._mediaSource.addSourceBuffer(mimeType).mode = \"sequence\";\n  }\n\n  async _createMediaSource() {\n    this._mediaSource = new MediaSource();\n\n    this._audioElement.src = URL.createObjectURL(this._mediaSource);\n    this._mediaSourcePromise = new Promise((resolve) => {\n      this._mediaSource.addEventListener(\"sourceopen\", resolve, {\n        once: true,\n      });\n    });\n    return this._mediaSourcePromise;\n  }\n\n  async _waitForSourceBuffer() {\n    return new Promise((resolve) => {\n      this._mediaSource.sourceBuffers[0].addEventListener(\n        \"updateend\",\n        resolve,\n        {\n          once: true,\n        }\n      );\n    });\n  }\n\n  async _appendSourceBuffer(chunk) {\n    if (this._state() !== \"stopping\") {\n      this._mediaSource.sourceBuffers[0].appendBuffer(chunk);\n      await this._waitForSourceBuffer();\n\n      if (\n        this._audioElement.currentTime > BUFFER &&\n        this._sourceBufferRemoved + BUFFER_INTERVAL * 1000 < Date.now()\n      ) {\n        this._sourceBufferRemoved = Date.now();\n        this._mediaSource.sourceBuffers[0].remove(\n          0,\n          this._audioElement.currentTime - BUFFER\n        );\n        await this._waitForSourceBuffer();\n      }\n    }\n  }\n}\n","import Player from \"./Player\";\nimport CodecParser from \"codec-parser\";\n\nexport default class HTML5Player extends Player {\n  constructor(options) {\n    super(options);\n\n    this._frame = null;\n    this._audioLoaded = 0;\n    this._offset = 0;\n\n    this._audioElement.crossOrigin = \"anonymous\";\n    this._audioElement.preload = \"none\";\n    this._audioElement.src = this._endpoint;\n  }\n\n  async reset() {\n    if (this._state() !== \"playing\") {\n      this._frame = null;\n      this._audioLoaded = 0;\n      this._offset = 0;\n      this._audioElement.removeAttribute(\"src\");\n      this._audioElement.load();\n      this._audioElement.src = this._endpoint;\n    }\n  }\n\n  async fetchStream(abortController) {\n    const audioPromise = new Promise((resolve, reject) => {\n      this._icecast.addEventListener(\"stopping\", resolve, { once: true }); // short circuit when user has stopped the stream\n      this._audioElement.addEventListener(\"playing\", resolve, { once: true });\n      this._audioElement.addEventListener(\"error\", reject, { once: true });\n    });\n\n    this._audioElement.src = this._endpoint;\n    this._audioElement.load();\n\n    return audioPromise.then(async () => {\n      const audioLoaded = performance.now();\n\n      const res = await super.fetchStream(abortController);\n      this._offset = performance.now() - audioLoaded;\n\n      return res;\n    });\n  }\n\n  get metadataTimestamp() {\n    return this._frame ? (this._frame.totalDuration + this._offset) / 1000 : 0;\n  }\n\n  getOnStream(res) {\n    this._codecParser = new CodecParser(res.headers.get(\"content-type\"), {\n      onCodecUpdate: (...args) =>\n        this._fireEvent(this._events.CODEC_UPDATE, ...args),\n    });\n\n    return ({ stream }) => {\n      this._fireEvent(this._events.STREAM, stream);\n\n      for (const frame of this._codecParser.iterator(stream)) {\n        this._frame = frame;\n      }\n    };\n  }\n}\n","/**\n * @license\n * @see https://github.com/eshaz/icecast-metadata-js\n * @copyright 2021 Ethan Halsall\n *  This file is part of icecast-metadata-player.\n *\n *  icecast-metadata-player free software: you can redistribute it and/or modify\n *  it under the terms of the GNU Lesser General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  icecast-metadata-player distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU Lesser General Public License for more details.\n *\n *  You should have received a copy of the GNU Lesser General Public License\n *  along with this program.  If not, see <https://www.gnu.org/licenses/>\n */\n\nimport EventTargetPolyfill from \"./EventTargetPolyfill\";\nimport {\n  IcecastReadableStream,\n  IcecastMetadataQueue,\n} from \"icecast-metadata-js\";\nimport MediaSourcePlayer from \"./players/MediaSourcePlayer\";\nimport HTML5Player from \"./players/HTML5Player\";\n\nlet EventClass;\n\ntry {\n  new EventTarget();\n  EventClass = EventTarget;\n} catch {\n  EventClass = EventTargetPolyfill;\n}\n\nconst noOp = () => {};\nconst p = new WeakMap();\n\n// State\nconst LOADING = \"loading\";\nconst PLAYING = \"playing\";\nconst STOPPING = \"stopping\";\nconst STOPPED = \"stopped\";\nconst RETRYING = \"retrying\";\n\n// Events\nconst PLAY = \"play\";\nconst LOAD = \"load\";\nconst STREAM_START = \"streamstart\";\nconst STREAM = \"stream\";\nconst STREAM_END = \"streamend\";\nconst METADATA = \"metadata\";\nconst METADATA_ENQUEUE = \"metadataenqueue\";\nconst CODEC_UPDATE = \"codecupdate\";\nconst STOP = \"stop\";\nconst RETRY = \"retry\";\nconst RETRY_TIMEOUT = \"retrytimeout\";\nconst WARN = \"warn\";\nconst ERROR = \"error\";\n\n// options\nconst metadataTypes = Symbol();\nconst audioElement = Symbol();\nconst icyMetaInt = Symbol();\nconst icyDetectionTimeout = Symbol();\nconst enableLogging = Symbol();\nconst endpoint = Symbol();\n\nconst retryDelayRate = Symbol();\nconst retryDelayMin = Symbol();\nconst retryDelayMax = Symbol();\nconst retryTimeout = Symbol();\n\n// variables\nconst hasIcy = Symbol();\nconst icecastReadableStream = Symbol();\nconst icecastMetadataQueue = Symbol();\nconst abortController = Symbol();\nconst player = Symbol();\nconst playerParams = Symbol();\nconst playerResetPromise = Symbol();\nconst events = Symbol();\nconst state = Symbol();\nconst onAudioPause = Symbol();\nconst onAudioPlay = Symbol();\nconst onAudioCanPlay = Symbol();\nconst onAudioError = Symbol();\nconst resetPlayback = Symbol();\nconst retryAttempt = Symbol();\nconst retryTimeoutId = Symbol();\nconst onAudioWaiting = Symbol();\n\n// private methods\nconst fireEvent = Symbol();\nconst fallbackToHTML5 = Symbol();\n\nconst playResponse = Symbol();\nconst attachAudioElement = Symbol();\nconst shouldRetry = Symbol();\n\nexport default class IcecastMetadataPlayer extends EventClass {\n  /**\n   * @constructor\n   * @param {string} endpoint Endpoint of the Icecast compatible stream\n   * @param {object} options Options object\n   * @param {HTMLAudioElement} options.audioElement Audio element to play the stream\n   * @param {Array} options.metadataTypes Array of metadata types to parse\n   * @param {number} options.icyMetaInt ICY metadata interval\n   * @param {number} options.icyDetectionTimeout ICY metadata detection timeout\n   *\n   * @callback options.onMetadata Called with metadata when synchronized with the audio\n   * @callback options.onMetadataEnqueue Called with metadata when discovered on the response\n   * @callback options.onError Called with message(s) when a fallback or error condition is met\n   * @callback options.onWarn Called with message(s) when a warning condition is met\n   * @callback options.onPlay Called when the audio element begins playing\n   * @callback options.onLoad Called when stream request is started\n   * @callback options.onStreamStart Called when stream requests begins to return data\n   * @callback options.onStream Called when stream data is sent to the audio element\n   * @callback options.onStreamEnd Called when the stream request completes\n   * @callback options.onStop Called when the stream is completely stopped and all cleanup operations are complete\n   * @callback options.onRetry Called when a connection retry is attempted\n   * @callback options.onRetryTimeout Called when when connections attempts have timed out\n   * @callback options.onCodecUpdate Called when the audio codec information has changed\n   */\n  constructor(url, options = {}) {\n    super();\n\n    p.set(this, {});\n    p.get(this)[endpoint] = url;\n\n    // options\n    p.get(this)[audioElement] = options.audioElement || new Audio();\n    p.get(this)[icyMetaInt] = options.icyMetaInt;\n    p.get(this)[icyDetectionTimeout] = options.icyDetectionTimeout;\n    p.get(this)[metadataTypes] = options.metadataTypes || [\"icy\"];\n    p.get(this)[hasIcy] = p.get(this)[metadataTypes].includes(\"icy\");\n    p.get(this)[enableLogging] = options.enableLogging || false;\n    p.get(this)[retryDelayRate] = (options.retryDelayRate || 0.1) + 1;\n    p.get(this)[retryDelayMin] = (options.retryDelayMin || 0.5) * 1000;\n    p.get(this)[retryDelayMax] = (options.retryDelayMax || 2) * 1000;\n    p.get(this)[retryTimeout] = (options.retryTimeout || 30) * 1000;\n\n    // callbacks\n    p.get(this)[events] = {\n      [PLAY]: options.onPlay || noOp,\n      [LOAD]: options.onLoad || noOp,\n      [STREAM_START]: options.onStreamStart || noOp,\n      [STREAM]: options.onStream || noOp,\n      [STREAM_END]: options.onStreamEnd || noOp,\n      [METADATA]: options.onMetadata || noOp,\n      [METADATA_ENQUEUE]: options.onMetadataEnqueue || noOp,\n      [CODEC_UPDATE]: options.onCodecUpdate || noOp,\n      [STOP]: options.onStop || noOp,\n      [RETRY]: options.onRetry || noOp,\n      [RETRY_TIMEOUT]: options.onRetryTimeout || noOp,\n      [WARN]: (...messages) => {\n        if (p.get(this)[enableLogging]) {\n          console.warn(\n            \"icecast-metadata-js\",\n            messages.reduce((acc, message) => acc + \"\\n  \" + message, \"\")\n          );\n        }\n        if (options.onWarn) options.onWarn(...messages);\n      },\n      [ERROR]: (...messages) => {\n        if (p.get(this)[enableLogging]) {\n          console.error(\n            \"icecast-metadata-js\",\n            messages.reduce((acc, message) => acc + \"\\n  \" + message, \"\")\n          );\n        }\n        if (options.onError) options.onError(...messages);\n      },\n    };\n\n    p.get(this)[icecastMetadataQueue] = new IcecastMetadataQueue({\n      onMetadataUpdate: (...args) => this[fireEvent](METADATA, ...args),\n      onMetadataEnqueue: (...args) =>\n        this[fireEvent](METADATA_ENQUEUE, ...args),\n    });\n\n    p.get(this)[resetPlayback] = () => {\n      clearTimeout(p.get(this)[retryTimeoutId]);\n      this.removeEventListener(STREAM_START, p.get(this)[resetPlayback]);\n      p.get(this)[audioElement].removeEventListener(\n        \"waiting\",\n        p.get(this)[onAudioWaiting]\n      );\n\n      p.get(this)[audioElement].pause();\n      p.get(this)[icecastMetadataQueue].purgeMetadataQueue();\n      p.get(this)[playerResetPromise] = p.get(this)[player].reset();\n    };\n\n    // audio element event handlers\n    p.get(this)[onAudioPlay] = () => {\n      this.play();\n    };\n    p.get(this)[onAudioPause] = () => {\n      this.stop();\n    };\n    p.get(this)[onAudioCanPlay] = () => {\n      p.get(this)[audioElement].play();\n      this[state] = PLAYING;\n      this[fireEvent](PLAY);\n    };\n    p.get(this)[onAudioError] = (e) => {\n      const errors = {\n        1: \"MEDIA_ERR_ABORTED The fetching of the associated resource was aborted by the user's request.\",\n        2: \"MEDIA_ERR_NETWORK Some kind of network error occurred which prevented the media from being successfully fetched, despite having previously been available.\",\n        3: \"MEDIA_ERR_DECODE Despite having previously been determined to be usable, an error occurred while trying to decode the media resource, resulting in an error.\",\n        4: \"MEDIA_ERR_SRC_NOT_SUPPORTED The associated resource or media provider object (such as a MediaStream) has been found to be unsuitable.\",\n        5: \"MEDIA_ERR_ENCRYPTED\",\n      };\n      this[fireEvent](\n        ERROR,\n        \"The audio element encountered an error\",\n        errors[e.target.error.code] || `Code: ${e.target.error.code}`,\n        `Message: ${e.target.error.message}`\n      );\n\n      if (this.state !== RETRYING) {\n        this.stop();\n      } else {\n        p.get(this)[resetPlayback]();\n      }\n    };\n\n    this[attachAudioElement]();\n    this[state] = STOPPED;\n\n    p.get(this)[playerParams] = {\n      icecast: this,\n      endpoint: p.get(this)[endpoint],\n      hasIcy: p.get(this)[hasIcy],\n      audioElement: p.get(this)[audioElement],\n      enableLogging: p.get(this)[enableLogging],\n      icecastMetadataQueue: p.get(this)[icecastMetadataQueue],\n      fireEvent: this[fireEvent].bind(this),\n      state: () => this.state,\n      events: {\n        STREAM: STREAM,\n        CODEC_UPDATE: CODEC_UPDATE,\n        ERROR: ERROR,\n      },\n    };\n\n    if (MediaSourcePlayer.isSupported()) {\n      p.get(this)[player] = new MediaSourcePlayer(p.get(this)[playerParams]);\n    } else {\n      p.get(this)[player] = new HTML5Player(p.get(this)[playerParams]);\n\n      this[fireEvent](\n        WARN,\n        `Media Source Extensions API in your browser is not supported. Using two requests, one for audio, and another for metadata.`,\n        \"See: https://caniuse.com/mediasource and https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API\"\n      );\n    }\n\n    p.get(this)[icecastReadableStream] = {}; // prevents getters from erroring when in a fallback state\n  }\n\n  /**\n   * @returns {HTMLAudioElement} The audio element associated with this instance\n   */\n  get audioElement() {\n    return p.get(this)[audioElement];\n  }\n\n  /**\n   * @returns {number} The ICY metadata interval in number of bytes for this instance\n   */\n  get icyMetaInt() {\n    return p.get(this)[icecastReadableStream].icyMetaInt;\n  }\n\n  /**\n   * @returns {Array<Metadata>} Array of enqueued metadata objects in FILO order\n   */\n  get metadataQueue() {\n    return p.get(this)[icecastMetadataQueue].metadataQueue;\n  }\n\n  /**\n   * @returns {string} The current state (\"loading\", \"playing\", \"stopping\", \"stopped\", \"retrying\")\n   */\n  get state() {\n    return p.get(this)[state];\n  }\n\n  set [state](_state) {\n    this.dispatchEvent(new CustomEvent(_state));\n    p.get(this)[state] = _state;\n  }\n\n  [attachAudioElement]() {\n    // audio events\n    const audio = p.get(this)[audioElement];\n    audio.addEventListener(\"pause\", p.get(this)[onAudioPause]);\n    audio.addEventListener(\"play\", p.get(this)[onAudioPlay]);\n    audio.addEventListener(\"canplay\", p.get(this)[onAudioCanPlay]);\n    audio.addEventListener(\"error\", p.get(this)[onAudioError]);\n  }\n\n  /**\n   * @description Remove event listeners from the audio element and this instance\n   */\n  detachAudioElement() {\n    const audio = p.get(this)[audioElement];\n    audio.removeEventListener(\"pause\", p.get(this)[onAudioPause]);\n    audio.removeEventListener(\"play\", p.get(this)[onAudioPlay]);\n    audio.removeEventListener(\"canplay\", p.get(this)[onAudioCanPlay]);\n    audio.removeEventListener(\"error\", p.get(this)[onAudioError]);\n  }\n\n  /**\n   * @description Plays the Icecast stream\n   * @async Resolves when the audio element is playing\n   */\n  async play() {\n    if (this.state === STOPPED) {\n      p.get(this)[abortController] = new AbortController();\n      this[state] = LOADING;\n      this[fireEvent](LOAD);\n\n      let error;\n\n      const tryFetching = () =>\n        p\n          .get(this)\n          [player].fetchStream(p.get(this)[abortController])\n          .then(async (res) => {\n            this[fireEvent](STREAM_START);\n\n            return this[playResponse](res).finally(() => {\n              this[fireEvent](STREAM_END);\n            });\n          })\n          .catch(async (e) => {\n            if (e.name !== \"AbortError\") {\n              if (await this[shouldRetry](e)) {\n                this[fireEvent](RETRY);\n                return tryFetching();\n              }\n\n              p.get(this)[abortController].abort(); // stop fetch if is wasn't aborted\n\n              if (\n                p.get(this)[state] !== STOPPING &&\n                p.get(this)[state] !== STOPPED\n              ) {\n                this[fireEvent](ERROR, e);\n                error = e;\n              }\n            }\n          });\n\n      tryFetching().finally(() => {\n        p.get(this)[resetPlayback]();\n\n        if (error && !error.message.match(/network|fetch|offline/))\n          this[fallbackToHTML5]();\n\n        this[fireEvent](STOP);\n        this[state] = STOPPED;\n      });\n\n      await new Promise((resolve) => {\n        this.addEventListener(\"play\", resolve, { once: true });\n      });\n    }\n  }\n\n  /**\n   * @description Stops playing the Icecast stream\n   * @async Resolves the icecast stream has stopped\n   */\n  async stop() {\n    if (this.state !== STOPPED && this.state !== STOPPING) {\n      this[state] = STOPPING;\n      p.get(this)[abortController].abort();\n\n      await new Promise((resolve) => {\n        this.addEventListener(\"stop\", resolve, { once: true });\n      });\n    }\n  }\n\n  async [shouldRetry](error) {\n    if (p.get(this)[retryTimeout] === 0) return false;\n\n    if (p.get(this)[state] === RETRYING) {\n      // wait for retry interval\n      await new Promise((resolve) => {\n        this.addEventListener(STOPPING, resolve, { once: true });\n\n        const delay = Math.min(\n          p.get(this)[retryDelayMin] *\n            p.get(this)[retryDelayRate] ** p.get(this)[retryAttempt]++,\n          p.get(this)[retryDelayMax]\n        ); // exponential backoff\n\n        setTimeout(() => {\n          this.removeEventListener(STOPPING, resolve);\n          resolve();\n        }, delay + delay * 0.3 * Math.random()); // jitter\n      });\n\n      // ensure the retry hasn't been cancelled while waiting\n      return p.get(this)[state] === RETRYING;\n    }\n\n    if (\n      p.get(this)[state] !== STOPPING &&\n      p.get(this)[state] !== STOPPED &&\n      (error.message.match(/network|fetch|offline|Error in body stream/i) ||\n        error.name === \"HTTP Response Error\")\n    ) {\n      this[fireEvent](ERROR, error);\n      this[state] = RETRYING;\n      this.addEventListener(STREAM_START, p.get(this)[resetPlayback], {\n        once: true,\n      });\n\n      if (p.get(this)[hasIcy]) {\n        this[fireEvent](\n          WARN,\n          \"This stream was requested with ICY metadata.\",\n          'If there is a CORS preflight failure, try removing \"icy\" from the metadataTypes option.',\n          \"See https://github.com/eshaz/icecast-metadata-js#cors for more details.\"\n        );\n      }\n\n      const audioWaiting = new Promise((resolve) => {\n        p.get(this)[onAudioWaiting] = resolve;\n        p.get(this)[audioElement].addEventListener(\n          \"waiting\",\n          p.get(this)[onAudioWaiting],\n          {\n            once: true,\n          }\n        );\n      });\n\n      // wait for whichever is longer, audio element waiting or retry timeout\n      p.get(this)[retryTimeoutId] = setTimeout(() => {\n        audioWaiting.then(() => {\n          if (p.get(this)[state] === RETRYING) {\n            this[fireEvent](RETRY_TIMEOUT);\n            this.stop();\n          }\n        });\n      }, p.get(this)[retryTimeout]);\n\n      p.get(this)[retryAttempt] = 0;\n      return true;\n    }\n\n    return false;\n  }\n\n  async [playResponse](res) {\n    p.get(this)[icecastReadableStream] = new IcecastReadableStream(res, {\n      onMetadata: p.get(this)[player].getOnMetadata(),\n      onStream: p.get(this)[player].getOnStream(res),\n      onError: (...args) => this[fireEvent](WARN, ...args),\n      metadataTypes: p.get(this)[metadataTypes],\n      icyMetaInt: p.get(this)[icyMetaInt],\n      icyDetectionTimeout: p.get(this)[icyDetectionTimeout],\n    });\n\n    await p.get(this)[icecastReadableStream].startReading();\n  }\n\n  [fireEvent](event, ...args) {\n    this.dispatchEvent(new CustomEvent(event, { detail: args }));\n    p.get(this)[events][event](...args);\n  }\n\n  [fallbackToHTML5]() {\n    this[fireEvent](\n      ERROR,\n      \"Falling back to HTML5 audio by using two requests: one for audio, and another for metadata.\",\n      \"See the console for details on the error.\"\n    );\n\n    p.get(this)[player] = new HTML5Player(p.get(this)[playerParams]);\n    p.get(this)[playerResetPromise].then(() => this.play());\n  }\n}\n"],"sourceRoot":""}