1159cl/lib/icecast-metadata-player-1.17.3.mediasource.min.js

22 lines
10 KiB
JavaScript
Raw Normal View History

2024-12-06 23:38:18 +00:00
/*!
* Copyright 2021-2023 Ethan Halsall
* https://github.com/eshaz/icecast-metadata-js
*
* This file is part of icecast-metadata-player.
*
* icecast-metadata-player free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* icecast-metadata-player distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
"use strict";(self.webpackChunkIcecastMetadataPlayer=self.webpackChunkIcecastMetadataPlayer||[]).push([[762],{448:(t,e,n)=>{n.r(e),n.d(e,{default:()=>Z});var s=n(317);const i="webm",r="mp3",c="mp4a.40.2",h="flac",o="vorbis",a="opus",w="audio/",d=";codecs=",l=w+"mp4"+d,u=w+i+d,g="mse-audio-wrapper";class m{constructor({name:t,contents:e=[],children:n=[]}){this.t=t,this.i=e,this.h=n}static stringToByteArray(t){return[...t].map((t=>t.charCodeAt(0)))}static getFloat64(t){const e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t),e}static getUint64(t){const e=new Uint8Array(8);return new DataView(e.buffer).setBigUint64(0,BigInt(t)),e}static getUint32(t){const e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t),e}static getUint16(t){const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t),e}static getInt16(t){const e=new Uint8Array(2);return new DataView(e.buffer).setInt16(0,t),e}static*flatten(t){for(const e of t)Array.isArray(e)?yield*m.flatten(e):yield e}get contents(){const t=new Uint8Array(this.length),e=this.o();let n=0;for(const s of m.flatten(e))"object"!=typeof s?(t[n]=s,n++):(t.set(s,n),n+=s.length);return t}get length(){return this.l()}o(){return[this.i,...this.h.map((t=>t.o()))]}l(){let t;return t=Array.isArray(this.i)?this.i.reduce(((t,e)=>t+(void 0===e.length?1:e.length)),0):void 0===this.i.length?1:this.i.length,t+this.h.reduce(((t,e)=>t+e.length),0)}addChild(t){this.h.push(t)}}class f extends m{constructor(t,{contents:e,children:n}={}){super({name:t,contents:e,children:n})}o(){return[...this.u,...m.stringToByteArray(this.t),...super.o()]}l(){return this.m||(this.m=4+this.t.length+super.l(),this.u=m.getUint32(this.m)),this.m}}class p extends m{constructor(t,{contents:e,tags:n}={}){super({name:t,contents:e,children:n})}static getLength(t){const e=m.getUint32(t);return e.every(((t,e,n)=>0===t&&(n[e]=128,!0))),e}o(){return[this.t,...this.u,...super.o()]}l(){if(!this.m){const t=super.l();this.u=p.getLength(t),this.m=1+t+this.u.length}return this.m}addTag(t){this.addChild(t)}}class y{constructor(t){this.p=t}getCodecBox(t){switch(this.p){case r:return this.getMp4a(t,107);case c:return this.getMp4a(t,64);case a:return this.getOpus(t);case h:return this.getFlaC(t)}}getOpus(t){return new f("Opus",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channels,0,t.bitDepth,0,0,0,0,f.getUint16(t.sampleRate),0,0],children:[new f("dOps",{contents:[0,t.channels,f.getUint16(t.preSkip),f.getUint32(t.inputSampleRate),f.getInt16(t.outputGain),t.channelMappingFamily,0!==t.channelMappingFamily?[t.streamCount,t.coupledStreamCount,t.channelMappingTable]:[]]})]})}getFlaC(t){return new f("fLaC",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channels,0,t.bitDepth,0,0,0,0,f.getUint16(t.sampleRate),0,0],children:[new f("dfLa",{contents:[0,0,0,0,...t.streamInfo||[128,0,0,34,f.getUint16(t.blockSize),f.getUint16(t.blockSize),0,0,0,0,0,0,f.getUint32(t.sampleRate<<12|t.channels<<8|t.bitDepth-1<<4),0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]})]})}getMp4a(t,e){const n=new p(4,{contents:[e,21,0,0,0,0,0,0,0,0,0,0,0]});return 64===e&&n.addTag(new p(5,{contents:t.audioSpecificConfig})),new f("mp4a",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channels,0,16,0,0,0,0,f.getUint16(t.sampleRate),0,0],children:[new f("esds",{contents:[0,0,0,0],children:[new p(3,{contents:[0,1,0],tags:[n,new p(6,{contents:2})]})]})]})}getInitializationSegment({header:t,samples:e}){return new m({children:[new f("ftyp",{contents:[f.stringToByteArray("iso5"),0,0,2,0,f.stringToByteArray("iso6mp41")]}),new f("moov",{children:[new f("mvhd",{contents:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2]}),new f("trak",{children:[new f("tkhd",{contents:[0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0]}),new f("mdia",{children:[new f("mdhd",{contents:[0,0,0,0,0,0,0,0,0,0,0,0,f.getUin
//# sourceMappingURL=icecast-metadata-player-1.17.3.mediasource.min.js.map