@libmedia/avplayer 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[543],{58121:(t,i,e)=>{e.d(i,{A:()=>r});var s=e(134);class r{constructor(){(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"dataOffset",void 0),(0,s.A)(this,"hasVideo",void 0),(0,s.A)(this,"hasAudio",void 0),this.signature="FLV",this.version=1,this.flags=0,this.dataOffset=9,this.hasAudio=!1,this.hasVideo=!1}async read(t){this.signature=await t.readString(3),this.version=await t.readUint8(),this.flags=await t.readUint8(),this.dataOffset=await t.readUint32(),this.hasAudio=!!(4&this.flags),this.hasVideo=!!(1&this.flags)}write(t){this.flags=0,this.hasAudio&&(this.flags|=4),this.hasVideo&&(this.flags|=1),t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.flags),t.writeUint32(this.dataOffset)}}},68243:(t,i,e)=>{e.d(i,{A:()=>u});var s=e(134),r=e(35336),n=e(92647),a=e(4624),h=e(94889),o=e(9705),f=e(73040);class u{constructor(){(0,s.A)(this,"onMetaData",void 0),this.onMetaData={canSeekToEnd:!1}}async read(t,i){const e=t.getPos(),s=e+BigInt(Math.floor(i)),r=await(0,f.$x)(t,s),n=await(0,f.$x)(t,s);this[r]=n,s>t.getPos()&&await t.skip(Number(BigInt.asIntN(32,s-t.getPos())));const h=Number(t.getPos()-e),u=await t.readUint32();return h+11!==u?(a.R8(`script size not match, size: ${h+11}, previousTagSize: ${u}`,"src/avformat/formats/flv/FlvScriptTag.ts",63),o.LR):0}computeSize(){const t=[],i=new r.A;return i.onFlush=i=>(t.push(i.slice()),0),(0,f.bD)(i,"onMetaData"),(0,f.bD)(i,this.onMetaData),i.flush(),(0,n.A)(Uint8Array,t).length}write(t){if(this.onMetaData){const i=[],e=new r.A;e.onFlush=t=>(i.push(t.slice()),0),(0,f.bD)(e,"onMetaData"),(0,f.bD)(e,this.onMetaData),e.flush();const s=(0,n.A)(Uint8Array,i);h.M5(t,18,BigInt(0),void 0,s)}}dts2Position(t){if(this.canSeek()){let i=-1;const e=this.onMetaData.keyframes.times,s=this.onMetaData.keyframes.filepositions;let r;for(r=0;r<e.length;r++){if(e[r]===t){i=r;break}if(e[r]>t){i=Math.max(r-1,0);break}}return r&&r===e.length&&(i=e.length-1),{pos:s[i],dts:e[i]}}return{pos:-1,dts:-1}}position2DTS(t){if(this.canSeek()){let e=-1;const s=this.onMetaData.keyframes.times,r=this.onMetaData.keyframes.filepositions;let n=0;for(n=0;n<r.length;n++)if(r[n]>t){e=n;break}var i;return n===r.length?null!==(i=this.onMetaData.duration)&&void 0!==i?i:s[s.length-1]:s[e]}return-1}canSeek(){return!!(this.onMetaData.keyframes&&this.onMetaData.keyframes.filepositions&&this.onMetaData.keyframes.filepositions.length)}}},35028:(t,i,e)=>{e.d(i,{FJ:()=>s,U5:()=>r});const s={10:86018,2:86017,11:86051,1:69645,4:86049,5:86049,6:86049,7:65543,8:65542},r={7:27,12:173,9:12,2:4,3:86,4:92,5:106,6:131}},94889:(t,i,e)=>{e.d(i,{M5:()=>n}),e(35028),e(44328),e(77231),e(65977);var s=e(67672);function r(t,i,e){const s=t.getPos(),r=t.getPointer(),n=s-BigInt(Math.floor(r));i<s&&i>=n?(t.seekInline(r+Number(i-s)),t.writeUint24(e),t.seekInline(r)):(t.seek(i),t.writeUint24(e),t.seek(s))}function n(t,i,e,n,a,h){t.flush(),t.writeUint8(i);const o=t.getPos();t.writeUint24(0),t.writeUint24(Number(e&BigInt(16777215))),t.writeUint8(Number(e>>BigInt(24)&BigInt(255))),t.writeUint24(0);const f=t.getPos();n&&n(t),s.Pc(a)?(a(t),r(t,o,Number(t.getPos()-f))):a&&(r(t,o,a.length+Number(t.getPos()-f)),t.writeBuffer(a));const u=Number(t.getPos()-o)+1;h&&h(u),t.writeUint32(u)}},65977:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(4624);const r="src/avformat/function/mktag.ts";function n(t){4!==t.length&&s.R8(`tag length is not 4, tag: ${t}`,r,30);let i=0;for(let e=0;e<4;e++)i=i<<8|t.charCodeAt(e);return i}},67543:(t,i,e)=>{e.r(i),e.d(i,{default:()=>b});var s=e(134),r=e(36773),n=e(14619),a=e(42383),h=e(82058),o=e(24175),f=e(34531),u=e(8507),l=e(35336),d=e(58121),p=e(68243),c=e(31865),w=e(73040),g=e(34677);class b extends r.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"socket",void 0),(0,s.A)(this,"session",void 0),(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"flvWriter",void 0),(0,s.A)(this,"flvHeader",void 0),(0,s.A)(this,"packetQueue",void 0),(0,s.A)(this,"flvHeaderWrote",void 0),(0,s.A)(this,"hasMetadata",void 0),(0,s.A)(this,"bufferReader",void 0)}writeFlvData(t){this.flvWriter.writeUint8(t.type),this.flvWriter.writeUint24(t.payload.length),this.flvWriter.writeUint24(t.timestamp),this.flvWriter.writeUint8(t.timestamp>>24),this.flvWriter.writeUint24(0),this.flvWriter.writeBuffer(t.payload),this.flvWriter.writeUint32(t.payload.length+11),this.flvWriter.flush()}async handleRtmpPacket(t){if(this.flvHeaderWrote)this.writeFlvData(t);else{if(this.packetQueue.push(t),8===t.type)this.flvHeader.hasAudio=!0;else if(9===t.type)this.flvHeader.hasVideo=!0;else if(18===t.type&&(this.bufferReader?this.bufferReader.resetBuffer(t.payload):this.bufferReader=new c.A(t.payload),"onMetaData"===await w.$x(this.bufferReader,BigInt(t.payload.length)))){this.hasMetadata=!0;const i=await w.$x(this.bufferReader,BigInt(t.payload.length));this.flvHeader.hasAudio=(0,g.A)(i.audiocodecid),this.flvHeader.hasVideo=(0,g.A)(i.videocodecid)}if(this.packetQueue.length>10||this.hasMetadata){if(this.flvHeader.write(this.flvWriter),this.flvWriter.writeUint32(0),!this.hasMetadata&&this.session.getDuration()){const t=new p.A;t.onMetaData={duration:this.session.getDuration()},t.write(this.flvWriter)}this.packetQueue.forEach((t=>{this.writeFlvData(t)})),this.packetQueue.length=0,this.flvHeaderWrote=!0}}}async send(t){return this.socket?(await this.socket.send(t),0):-1048574}async open(t){this.info=t,this.status=1,3===t.subProtocol?(this.socket=new a.A(this.options),await this.socket.open({url:t.url,webtransportOptions:t.webtransportOptions})):(this.socket=new n.A(this.options),await this.socket.open({url:t.url})),this.ioReader=new o.A,this.ioReader.onFlush=async t=>this.socket.read(t),this.ioReader.onSeek=async t=>this.socket.seek(t),this.ioReader.onSize=async()=>this.socket.size(),this.ioWriter=new f.A,this.ioWriter.onFlush=async t=>this.socket.write(t),this.ioWriter.onSeek=async t=>this.socket.seek(t),this.flvWriter=new l.A,this.flvWriter.onFlush=t=>(this.readQueue.push(t.slice()),this.consume&&this.consume(),0),this.flvHeader=new d.A,this.packetQueue=[],this.flvHeaderWrote=!1,this.hasMetadata=!1,this.session=new h.A(this.ioReader,this.ioWriter,{isLive:this.options.isLive,isPull:!0}),this.session.onMediaPacket=async(t,i)=>this.handleRtmpPacket(t),this.session.onError=()=>{this.status=3,this.consume&&this.consume()},await this.session.handshake();const i=u.qg(this.info.uri),e=i.pathname.split("/");await this.session.connect(e[1],`rtmp://${i.host}${i.port?":"+i.port:""}/${e[1]}`);const s=e.slice(2);return this.session.play((s.length>1?s.join("/"):s[0])||""),0}async seek(t){return await this.session.seek(Number(t)),0}async size(){return BigInt(0)}async stop(){this.socket&&(await this.socket.stop(),this.socket=null),this.status=4}}},46084:(t,i,e)=>{e.d(i,{u:()=>r});var s=e(134);class r{constructor(t,i,e,r){(0,s.A)(this,"channelId",void 0),(0,s.A)(this,"type",void 0),(0,s.A)(this,"timestamp",void 0),(0,s.A)(this,"tsField",0),(0,s.A)(this,"extra",0),(0,s.A)(this,"payload",void 0),this.channelId=t,this.type=i,this.timestamp=e,this.payload=r instanceof Uint8Array?r:new Uint8Array(r)}}},82058:(t,i,e)=>{e.d(i,{A:()=>U});var s=e(134),r=e(80662),n=e.n(r),a=e(54001),h=e.n(a),o=e(46084),f=e(90519),u=e(86932),l=e(729),d=e(68680),p=e(73040),c=e(98951),w=e(31865),g=e(4624),b=e(72739),y=e(67672),m=e(13724),k=e(83229);const v="src/avprotocol/rtmp/RtmpSession.ts";class U{constructor(t,i,e){(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"prevReadPacket",void 0),(0,s.A)(this,"prevWritePacket",void 0),(0,s.A)(this,"inChunkSize",void 0),(0,s.A)(this,"outChunkSize",void 0),(0,s.A)(this,"seq",void 0),(0,s.A)(this,"bufferWriter",void 0),(0,s.A)(this,"bufferReader",void 0),(0,s.A)(this,"requestMap",void 0),(0,s.A)(this,"state",void 0),(0,s.A)(this,"maxSentUnacked",void 0),(0,s.A)(this,"receiveReportSize",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"options",void 0),(0,s.A)(this,"streamIdMap",void 0),(0,s.A)(this,"sendAsync",void 0),(0,s.A)(this,"onMediaPacket",void 0),(0,s.A)(this,"onError",void 0),this.ioReader=t,this.ioWriter=i,this.options=e,this.prevReadPacket=new(n()),this.prevWritePacket=new(n()),this.requestMap=new(n()),this.streamIdMap=new(n()),this.inChunkSize=128,this.outChunkSize=128,this.seq=0,this.maxSentUnacked=25e5,this.receiveReportSize=1048576,this.sendAsync=new k.an,this.bufferWriter=new l.A(new Uint8Array(1)),this.bufferReader=new w.A(new Uint8Array(1)),this.state=0}async handshake(){const t=(0,u.A)();await this.ioWriter.writeUint8(3),await this.ioWriter.writeUint32(0),await this.ioWriter.writeUint32(0);const i=new Uint8Array(1528);f.y(i),await this.ioWriter.writeBuffer(i),await this.ioWriter.flush(),await this.ioReader.readUint8();const e=await this.ioReader.readUint32();await this.ioReader.skip(4);const s=await this.ioReader.readBuffer(1528);await this.ioWriter.writeUint32(e),await this.ioWriter.writeUint32((0,u.A)()-t),await this.ioWriter.writeBuffer(s),await this.ioWriter.flush(),await this.ioReader.skip(1536),this.readRtmpPacket()}async sendPacket(t){await(0,k.s2)(this.sendAsync),await(0,c.U)(this.ioWriter,this.outChunkSize,t,this.prevWritePacket.get(t.channelId)),this.prevWritePacket.set(t.channelId,t),(0,k.Tl)(this.sendAsync)}async readPacket(){const t=await(0,c.w)(this.ioReader,this.inChunkSize,this.prevReadPacket);return this.prevReadPacket.set(t.channelId,t),t}handleChunkSize(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.inChunkSize=this.bufferReader.readUint32())}handleUserControl(t){t.payload.length>=2&&(this.bufferReader.resetBuffer(t.payload),6===this.bufferReader.readUint16()&&this.sendPong(t,this.bufferReader.readUint32()))}handleSetPeerBW(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.maxSentUnacked=this.bufferReader.readUint32(),g.Yz(`Max sent, unacked = ${this.maxSentUnacked}`,v,205))}handleWindowSizeACK(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.receiveReportSize=this.bufferReader.readUint32(),g.Yz(`Window acknowledgement size = ${this.receiveReportSize}`,v,212),this.receiveReportSize>>=1)}async handleInvoke(t){this.bufferReader.resetBuffer(t.payload);const i=BigInt(t.payload.length),e=await p.$x(this.bufferReader,i),s=await p.$x(this.bufferReader,i);if("_result"===e||"_error"===e){if(this.requestMap.has(s)){const t=await p.$x(this.bufferReader,i),r=await p.$x(this.bufferReader,i);"_result"===e?this.requestMap.get(s).resolve({options:t,info:r}):this.requestMap.get(s).reject({options:t,info:r}),this.requestMap.delete(s)}}else if("onStatus"===e){const t=await p.$x(this.bufferReader,i);let e=await p.$x(this.bufferReader,i);if("error"===e.level)g.z3(`Server error: ${e.description}, ${e.code}`,v,248),this.requestMap.has(s)?(this.requestMap.get(s).reject({options:t,info:e}),this.requestMap.delete(s)):this.onError&&this.onError();else{switch(e.code){case"NetStream.Play.Start":case"NetStream.Seek.Notify":this.state=3;break;case"NetStream.Play.Stop":case"NetStream.Play.UnpublishNotify":this.state=8;break;case"NetStream.Publish.Start":this.state=5}this.requestMap.has(s)&&(this.requestMap.get(s).resolve({options:t,info:e}),this.requestMap.delete(s))}}else"onBWDone"===e&&await this.sendCheckBW()}async handleNotify(t){this.bufferReader.resetBuffer(t.payload),"@setDataFrame"===await p.$x(this.bufferReader,BigInt(t.payload.length))&&(t.payload=t.payload.subarray(Number(this.bufferReader.getPos()))),t.payload.length&&this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}async readRtmpPacket(){for(;;)try{const t=await this.readPacket();switch(t.type){case 3:default:break;case 1:this.handleChunkSize(t);break;case 4:this.handleUserControl(t);break;case 6:this.handleSetPeerBW(t);break;case 5:this.handleWindowSizeACK(t);break;case 20:await this.handleInvoke(t);break;case 18:await this.handleNotify(t);break;case 22:case 8:case 9:this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}}catch(t){break}}async sendPong(t,i){if(t.payload.length<6)return void g.R8(`Too short ping packet (${t.payload.length})`,v,348);const e=new o.u(2,4,t.timestamp+1,6);this.bufferWriter.resetBuffer(e.payload),this.bufferWriter.writeUint16(7),this.bufferWriter.writeUint32(i),this.sendPacket(e)}async sendWindowAckSize(){const t=new o.u(2,5,0,4);this.bufferWriter.resetBuffer(t.payload),this.bufferWriter.writeUint32(this.maxSentUnacked),await this.sendPacket(t)}async sendBufferTime(t){const i=new o.u(2,4,1,10);this.bufferWriter.resetBuffer(i.payload),this.bufferWriter.writeUint16(3),this.bufferWriter.writeUint32(t),this.bufferWriter.writeUint32(this.options.clientBufferTime||3e3),await this.sendPacket(i)}async sendFCSubscribe(t){const i=new o.u(3,20,0,27+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCSubscribe"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendFCPublish(t){const i=new o.u(3,20,0,25+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCPublish"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendReleaseStream(t){const i=new o.u(3,20,0,29+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"releaseStream"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendCheckBW(){const t=new o.u(3,20,0,21);this.bufferWriter.resetBuffer(t.payload),p.bD(this.bufferWriter,"_checkbw"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),await this.sendPacket(t)}async request(t,i){const e=new o.u(3,20,0,4096+d.iD);return this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,++this.seq),b.__(i,(t=>{p.bD(this.bufferWriter,t)})),e.payload=e.payload.subarray(0,this.bufferWriter.getPos()),new(h())(((t,i)=>{this.requestMap.set(this.seq,{resolve:t,reject:i}),this.sendPacket(e)}))}async connect(t,i){await this.request("connect",[{app:t,fourCcList:["hvc1","av01","vp09"],flashVer:"LNX 9,0,124,2",tcUrl:i,fpad:0,capabilities:15,audioCodecs:4071,videoCodecs:252,videoFunction:1}]),this.options.isPull&&await this.sendWindowAckSize()}async createStream(){return(await this.request("createStream",[null])).info}async play(t){const i=await this.createStream();if(this.streamIdMap.set(i,t),!this.options.isLive){const i=await h().race([this.request("getStreamLength",[null,t]),new m.A(1)]);y.ai(i)||(this.duration=i.info)}await this.sendFCSubscribe(t),this.request("play",[null,t,-1,-1,!0]),await this.sendBufferTime(i)}async publish(t){await this.sendReleaseStream(t),await this.sendFCPublish(t);const i=await this.createStream();this.streamIdMap.set(i,t),await this.request("publish",[null,t,"live"])}async sendStreamPacket(t,i){let e=0;this.streamIdMap.forEach(((t,s)=>{t===i&&(e=s)})),t.extra=e,await this.sendPacket(t)}async seek(t){const i=new o.u(3,20,0,26);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"seek"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async pause(t,i){const e=new o.u(3,20,0,29);this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,"pause"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,i),await this.sendPacket(e)}getDuration(){return this.duration}}},68680:(t,i,e)=>{e.d(i,{iD:()=>s});const s=1024},98951:(t,i,e)=>{e.d(i,{U:()=>o,w:()=>f});var s=e(46084),r=e(92647),n=e(4624);const a="src/avprotocol/rtmp/util.ts";async function h(t,i,e){if(i<64)await t.writeUint8(i|e<<6);else if(i<320)await t.writeUint8(e<<6),await t.writeUint8(i-64);else{await t.writeUint8(1|e<<6);const s=i-64;await t.writeUint8(255&s),await t.writeUint8(s>>>8)}}async function o(t,i,e,s){const r=s&&s.extra===e.extra&&e.timestamp>=s.timestamp;let n=e.timestamp;r&&(n-=s.timestamp),e.tsField=n>16777215?16777215:n;let a=0;r&&(e.type===s.type&&e.payload.length===s.payload.length?(a=2,e.tsField===s.tsField&&(a=3)):a=1),await h(t,e.channelId,a),3!==a&&(await t.writeUint24(e.tsField),2!==a&&(await t.writeUint24(e.payload.length),await t.writeUint8(e.type),0===a&&(await t.writeUint8(e.extra),await t.writeUint8(e.extra>>8),await t.writeUint8(e.extra>>16),await t.writeUint8(e.extra>>24)))),16777215===e.tsField&&await t.writeUint32(n);let o=0;for(;o<e.payload.length;){const s=Math.min(i,e.payload.length-o);await t.writeBuffer(e.payload.subarray(o,o+s)),o+=s,o<e.payload.length&&(await h(t,e.channelId,3),16777215===e.tsField&&await t.writeUint32(n))}await t.flush()}async function f(t,i,e){const h=[],o=await t.readUint8();let f=63&o;f<2&&(f=0===await t.readUint8()?await t.readUint8()+64:64+(await t.readUint8()|await t.readUint8()<<8));const u=o>>>6,l=e.get(f);let d=l?l.payload.length:0,p=l?l.type:0,c=l?l.extra:0,w=0,g=0;if(3===u?w=l.tsField:(w=await t.readUint24(),2!==u&&(d=await t.readUint24(),p=await t.readUint8(),0===u&&(c=await t.readUint8(),c|=await t.readUint8()<<8,c|=await t.readUint8()<<16,c|=await t.readUint8()<<24))),g=16777215===w?await t.readUint32():w,0!==u&&(l?g+=l.timestamp:n.R8(`got invalid message fmt, channel id ${f} can not find prev message with fmt ${u}`,a,171)),d<i)h.push(await t.readBuffer(d));else{let e=d;for(;e;){const s=Math.min(i,e);if(h.push(await t.readBuffer(s)),e-=s,e){const i=63&await t.readUint8();i<2&&await t.skip(i+1),16777215===w&&await t.skip(4)}}}const b=new s.u(f,p,g,(0,r.A)(Uint8Array,h));return b.tsField=w,b.extra=c,b}},77231:(t,i,e)=>{e.d(i,{Dh:()=>r,FQ:()=>d,H3:()=>o,KR:()=>u,N_:()=>n,SF:()=>a,WT:()=>f,f7:()=>w,go:()=>p,i0:()=>l,qs:()=>h,zg:()=>c});var s=e(9599);const r=-BigInt(1),n=-1,a=1e6,h=1e3,o=1e9,f=BigInt(2208988800)*BigInt(1e6),u=new s.P({den:a,num:1}),l=new s.P({den:h,num:1}),d=new s.P({den:o,num:1}),p=(new s.P({den:1,num:1}),2147483647),c=65535,w=4294967295},9599:(t,i,e)=>{e.d(i,{P:()=>u});var s,r,n=e(134),a=e(80662),h=e.n(a),o=e(61499),f=e(12085);class u{constructor(t){(0,n.A)(this,"num",1),(0,n.A)(this,"den",1),t&&(this.den=t.den,this.num=t.num)}}s=u.prototype,(r=new(h())).set("num",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),r.set("den",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,f.A)(s,o.Og,!0),(0,f.A)(s,o.dc,4),(0,f.A)(s,o.g7,8),(0,f.A)(s,o.JY,r)},73040:(t,i,e)=>{e.d(i,{$x:()=>h,bD:()=>o});var s=e(67672),r=e(72739),n=e(95335);async function a(t,i){return{key:await t.readString(await t.readUint16()),value:await h(t,i)}}async function h(t,i){let e;switch(await t.readUint8()){case 0:e=await t.readDouble();break;case 1:e=!!await t.readUint8();break;case 2:e=await t.readString(await t.readUint16());break;case 3:for(e={};t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 8:for(e={},await t.skip(4);t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 9:case 5:e=null;break;case 10:e=[];const s=await t.readUint32();for(let r=0;r<s;r++)e.push(await h(t,i));break;case 11:const r=await t.readDouble(),n=await t.readInt16();e=new Date(r+60*n*1e3);break;case 12:e=await t.readString(await t.readUint32())}return e}function o(t,i){s.ai(i)?(t.writeUint8(0),t.writeDouble(i)):s.o(i)?(t.writeUint8(0),t.writeDouble(Number(i))):s.zM(i)?(t.writeUint8(1),t.writeUint8(i?1:0)):s.Yj(i)?i.length>=65536?(t.writeUint8(12),t.writeUint32(i.length),t.writeString(i)):(t.writeUint8(2),t.writeUint16(i.length),t.writeString(i)):s.YO(i)?(t.writeUint8(10),t.writeUint32(i.length),r.__(i,(i=>{o(t,i)}))):s.Ik(i)?(t.writeUint8(3),n.__(i,((i,e)=>{t.writeUint16(e.length),t.writeString(e),o(t,i)})),t.writeUint24(9)):i instanceof Date?(t.writeUint8(11),t.writeDouble(i.getTime()),t.writeInt16(0)):null==i&&t.writeUint8(5)}},90519:(t,i,e)=>{function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},44328:(t,i,e)=>{e.d(i,{FP:()=>o,Mr:()=>h,iU:()=>l,j2:()=>u,k:()=>a,lb:()=>f});var s=e(63939),r=e(77231),n=e(31658);function a(t,i,e){return t*BigInt(i.num)*BigInt(e.den)/(BigInt(i.den)*BigInt(e.num))}function h(t,i,e){return t*BigInt(s.f[15](i))*BigInt(e.den)/(BigInt(s.f[15](i+4))*BigInt(e.num))}function o(t,i,e){return t*BigInt(i.num)*BigInt(s.f[15](e+4))/(BigInt(i.den)*BigInt(s.f[15](e)))}function f(t){return t.num/t.den}function u(t,i){if(isNaN(19))return{den:0,num:0};if(Math.abs(t)>r.go+3)return{den:0,num:t<0?-1:1};const e=t>1?{den:Math.floor(i/t+.5),num:i}:{den:i,num:Math.floor(t*i+.5)};return l(e),e}function l(t){const i=(0,n.A)(t.num,t.den);i<=1||(t.den/=i,t.num/=i)}},83229:(t,i,e)=>{e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(134),r=e(54001),n=e.n(r);class a{constructor(){(0,s.A)(this,"list",[])}}async function h(t){return new(n())((i=>{t.list.push(i),1===t.list.length&&i()}))}function o(t){t.list.shift(),t.list.length&&t.list[0]()}},6498:(t,i,e)=>{e(67672),e(72739)},24175:(t,i,e)=>{e.d(i,{A:()=>o});var s=e(134),r=e(4624),n=e(50011),a=e(13724);const h="src/common/io/IOReader.ts";class o{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async readUint8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}async peekUint8(){return this.remainingLength()<1&&await this.flush(1),this.data.getUint8(this.pointer)}async readUint16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekUint16(){return this.remainingLength()<2&&await this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}async readUint24(){this.remainingLength()<3&&await this.flush(3);const t=await this.readUint16(),i=await this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}async peekUint24(){this.remainingLength()<3&&await this.flush(3);const t=this.pointer,i=this.pos,e=await this.readUint16(),s=await this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}async readUint32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekUint32(){return this.remainingLength()<4&&await this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}async readUint64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekUint64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}async readInt8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}async peekInt8(){return this.remainingLength()<1&&await this.flush(1),this.data.getInt8(this.pointer)}async readInt16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekInt16(){return this.remainingLength()<2&&await this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}async readInt24(){const t=await this.readUint24();return 8388608&t?t-16777216:t}async peekInt24(){const t=await this.peekUint24();return 8388608&t?t-16777216:t}async readInt32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekInt32(){return this.remainingLength()<4&&await this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}async readInt64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekInt64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}async readFloat(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekFloat(){return this.remainingLength()<4&&await this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}async readDouble(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekDouble(){return this.remainingLength()<8&&await this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}async readHex(t=1){let i="";for(let e=0;e<t;e++){const t=(await this.readUint8()).toString(16);i+=1===t.length?"0"+t:t}return i}async peekHex(t=1){t>this.size&&(this.error=-1048574,r.h2("peekHex, length too large",h,414)),this.remainingLength()<t&&await this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=(await this.readUint8()).toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}async readBuffer(t,i){if(i||(i=new Uint8Array(t)),this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){await this.flush();const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}}else i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t);return i}async peekBuffer(t,i){return t>this.size&&(this.error=-1048574,r.h2("peekBuffer, length too large",h,499)),this.remainingLength()<t&&await this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i}async readToBuffer(t,i){if(this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){try{await this.flush()}catch(t){if(-1048576===this.error&&e)return e;throw t}const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}return e}return i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t),t}async readString(t=1){const i=await this.readBuffer(t);return n.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return n.decode(i)}async readLine(){let t="";for(;;){let i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){e!==this.pointer&&(t+=await this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=await this.readString(this.remainingLength()),await this.flush()}let i=await this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=await this.peekUint8(),10===i&&this.pointer++)),t}async peekLine(){if(this.remainingLength()<this.size)try{await this.flush()}catch(t){if(-1048576!==this.error)throw t}let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=await this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,r.h2("peekLine, out of buffer",h,657)),t}getPointer(){return this.pointer}getPos(){return this.pos}async skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,await this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}async flush_(t){for(;;){const i=await this.onFlush(t);if(-1048575!==i)return i;await new a.A(0)}}async flush(t=0){if(this.onFlush||(this.error=-1048574,r.h2("IOReader error, flush failed because of no flush callback",h,731)),!(this.size-this.remainingLength()<=0)){if(t=Math.min(t,this.size),this.pointer<this.endPointer?(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0,t)for(;this.remainingLength()<t;){const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}else{const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}this.error=0}}async seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,r.h2("IOReader error, seek failed because of no seek callback",h,802)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,r.h2("IOReader error, seek failed",h,811)),e&&await this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,r.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",h,849)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return r.R8("IOReader error, fileSize failed because of no onSize callback",h,882),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){r.R8(`IOReader error, call fileSize failed: ${t}`,h,889),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}async pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){await this.flush();const e=Math.min(this.remainingLength(),i);await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i);else{if(this.remainingLength()>0){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;await this.flush_(this.buffer.subarray(0))>0;){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}}},34531:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async writeUint8(t){this.remainingLength()<1&&await this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}async writeUint16(t){this.remainingLength()<2&&await this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeUint24(t){this.remainingLength()<3&&await this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(await this.writeUint8(s),await this.writeUint8(e),await this.writeUint8(i)):(await this.writeUint8(i),await this.writeUint8(e),await this.writeUint8(s))}async writeUint32(t){this.remainingLength()<4&&await this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeUint64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeInt8(t){this.remainingLength()<1&&await this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}async writeInt16(t){this.remainingLength()<2&&await this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeInt24(t){await this.writeUint24(t<0?t+16777216:t)}async writeInt32(t){this.remainingLength()<4&&await this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeInt64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeFloat(t){this.remainingLength()<4&&await this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeDouble(t){this.remainingLength()<8&&await this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}async writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){await this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}async writeString(t){const i=r.encode(t);return await this.writeBuffer(i),i.length}async flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=await this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}async flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=await this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}async seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");await this.flush();const i=await this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},35336:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(t){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}writeUint16(t){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(t){this.remainingLength()<3&&this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(this.writeUint8(s),this.writeUint8(e),this.writeUint8(i)):(this.writeUint8(i),this.writeUint8(e),this.writeUint8(s))}writeUint32(t){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(t){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(t){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}writeInt16(t){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt24(t){this.writeUint24(t<0?t+16777216:t)}writeInt32(t){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(t){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(t){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(t){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}writeString(t){const i=r.encode(t);return this.writeBuffer(i),i.length}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const i=this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},31658:(t,i,e)=>{function s(t,i){for(;0!==i;)[t,i]=[i,t%i];return t}e.d(i,{A:()=>s})},8507:(t,i,e)=>{function s(t){const i=t,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let r="";s.test(t)&&(t=t.replace(s,((t,i,e)=>(r=e,`://${i||""}a.b`))));const n={},a=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let h=14;for(;h--;){var o;n[e[h]]=null!==(o=a[h])&&void 0!==o?o:""}return r&&(n.host=r,n.source=i,n.authority=r+(n.port?":"+n.port:"")),{protocol:n.protocol,file:n.file,host:n.host,port:n.port,user:n.user,password:n.password,origin:`${n.protocol}://${n.authority}`,pathname:n.path,search:`?${n.query}`,hash:n.anchor?`#${n.anchor}`:""}}e.d(i,{ll:()=>l,qg:()=>s}),e(73146),e(67672),e(6498),e(72739),e(95335);const r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a=/^(?=([^\/?#]*))\1([^]*)$/,h=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function o(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function f(t){const i=h.exec(t);return i?{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}:null}function u(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")}function l(t,i,e){if(e=e||{},t=t.trim(),!(i=i.trim())){if(!e.alwaysNormalize)return t;let i=f(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=u(i.path),o(i)}let s=f(i);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return e.alwaysNormalize?(s.path=u(s.path),o(s)):i;let r=f(t);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){let t=a.exec(r.path);r.netLoc=t[1],r.path=t[2]}r.netLoc&&!r.path&&(r.path="/");const n={scheme:r.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(n.netLoc=r.netLoc,"/"!==s.path[0]))if(s.path){let t=r.path,i=t.substring(0,t.lastIndexOf("/")+1)+s.path;n.path=u(i)}else n.path=r.path,s.params||(n.params=r.params,s.query||(n.query=r.query));return null===n.path&&(n.path=e.alwaysNormalize?u(s.path):s.path),o(n)}},85079:(t,i,e)=>{var s=e(46438),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},73146:(t,i,e)=>{t.exports=e(85079)}}]);
1
+ (self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[543],{58121:(t,i,e)=>{"use strict";e.d(i,{A:()=>r});var s=e(134);class r{constructor(){(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"dataOffset",void 0),(0,s.A)(this,"hasVideo",void 0),(0,s.A)(this,"hasAudio",void 0),this.signature="FLV",this.version=1,this.flags=0,this.dataOffset=9,this.hasAudio=!1,this.hasVideo=!1}async read(t){this.signature=await t.readString(3),this.version=await t.readUint8(),this.flags=await t.readUint8(),this.dataOffset=await t.readUint32(),this.hasAudio=!!(4&this.flags),this.hasVideo=!!(1&this.flags)}write(t){this.flags=0,this.hasAudio&&(this.flags|=4),this.hasVideo&&(this.flags|=1),t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.flags),t.writeUint32(this.dataOffset)}}},68243:(t,i,e)=>{"use strict";e.d(i,{A:()=>u});var s=e(134),r=e(35336),n=e(92647),a=e(4624),h=e(94889),o=e(9705),f=e(73040);class u{constructor(){(0,s.A)(this,"onMetaData",void 0),this.onMetaData={canSeekToEnd:!1}}async read(t,i){const e=t.getPos(),s=e+BigInt(Math.floor(i)),r=await(0,f.$x)(t,s),n=await(0,f.$x)(t,s);this[r]=n,s>t.getPos()&&await t.skip(Number(BigInt.asIntN(32,s-t.getPos())));const h=Number(t.getPos()-e),u=await t.readUint32();return h+11!==u?(a.R8(`script size not match, size: ${h+11}, previousTagSize: ${u}`,"src/avformat/formats/flv/FlvScriptTag.ts",63),o.LR):0}computeSize(){const t=[],i=new r.A;return i.onFlush=i=>(t.push(i.slice()),0),(0,f.bD)(i,"onMetaData"),(0,f.bD)(i,this.onMetaData),i.flush(),(0,n.A)(Uint8Array,t).length}write(t){if(this.onMetaData){const i=[],e=new r.A;e.onFlush=t=>(i.push(t.slice()),0),(0,f.bD)(e,"onMetaData"),(0,f.bD)(e,this.onMetaData),e.flush();const s=(0,n.A)(Uint8Array,i);h.M5(t,18,BigInt(0),void 0,s)}}dts2Position(t){if(this.canSeek()){let i=-1;const e=this.onMetaData.keyframes.times,s=this.onMetaData.keyframes.filepositions;let r;for(r=0;r<e.length;r++){if(e[r]===t){i=r;break}if(e[r]>t){i=Math.max(r-1,0);break}}return r&&r===e.length&&(i=e.length-1),{pos:s[i],dts:e[i]}}return{pos:-1,dts:-1}}position2DTS(t){if(this.canSeek()){let e=-1;const s=this.onMetaData.keyframes.times,r=this.onMetaData.keyframes.filepositions;let n=0;for(n=0;n<r.length;n++)if(r[n]>t){e=n;break}var i;return n===r.length?null!==(i=this.onMetaData.duration)&&void 0!==i?i:s[s.length-1]:s[e]}return-1}canSeek(){return!!(this.onMetaData.keyframes&&this.onMetaData.keyframes.filepositions&&this.onMetaData.keyframes.filepositions.length)}}},35028:(t,i,e)=>{"use strict";e.d(i,{FJ:()=>s,U5:()=>r});const s={10:86018,2:86017,11:86051,1:69645,4:86049,5:86049,6:86049,7:65543,8:65542},r={7:27,12:173,9:12,2:4,3:86,4:92,5:106,6:131}},94889:(t,i,e)=>{"use strict";e.d(i,{M5:()=>n}),e(35028),e(44328),e(77231),e(65977);var s=e(67672);function r(t,i,e){const s=t.getPos(),r=t.getPointer(),n=s-BigInt(Math.floor(r));i<s&&i>=n?(t.seekInline(r+Number(i-s)),t.writeUint24(e),t.seekInline(r)):(t.seek(i),t.writeUint24(e),t.seek(s))}function n(t,i,e,n,a,h){t.flush(),t.writeUint8(i);const o=t.getPos();t.writeUint24(0),t.writeUint24(Number(e&BigInt(16777215))),t.writeUint8(Number(e>>BigInt(24)&BigInt(255))),t.writeUint24(0);const f=t.getPos();n&&n(t),s.Pc(a)?(a(t),r(t,o,Number(t.getPos()-f))):a&&(r(t,o,a.length+Number(t.getPos()-f)),t.writeBuffer(a));const u=Number(t.getPos()-o)+1;h&&h(u),t.writeUint32(u)}},65977:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(4624);const r="src/avformat/function/mktag.ts";function n(t){4!==t.length&&s.R8(`tag length is not 4, tag: ${t}`,r,30);let i=0;for(let e=0;e<4;e++)i=i<<8|t.charCodeAt(e);return i}},67543:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>b});var s=e(134),r=e(36773),n=e(14619),a=e(42383),h=e(82058),o=e(24175),f=e(34531),u=e(8507),l=e(35336),d=e(58121),p=e(68243),c=e(31865),w=e(73040),g=e(34677);class b extends r.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"socket",void 0),(0,s.A)(this,"session",void 0),(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"flvWriter",void 0),(0,s.A)(this,"flvHeader",void 0),(0,s.A)(this,"packetQueue",void 0),(0,s.A)(this,"flvHeaderWrote",void 0),(0,s.A)(this,"hasMetadata",void 0),(0,s.A)(this,"bufferReader",void 0)}writeFlvData(t){this.flvWriter.writeUint8(t.type),this.flvWriter.writeUint24(t.payload.length),this.flvWriter.writeUint24(t.timestamp),this.flvWriter.writeUint8(t.timestamp>>24),this.flvWriter.writeUint24(0),this.flvWriter.writeBuffer(t.payload),this.flvWriter.writeUint32(t.payload.length+11),this.flvWriter.flush()}async handleRtmpPacket(t){if(this.flvHeaderWrote)this.writeFlvData(t);else{if(this.packetQueue.push(t),8===t.type)this.flvHeader.hasAudio=!0;else if(9===t.type)this.flvHeader.hasVideo=!0;else if(18===t.type&&(this.bufferReader?this.bufferReader.resetBuffer(t.payload):this.bufferReader=new c.A(t.payload),"onMetaData"===await w.$x(this.bufferReader,BigInt(t.payload.length)))){this.hasMetadata=!0;const i=await w.$x(this.bufferReader,BigInt(t.payload.length));this.flvHeader.hasAudio=(0,g.A)(i.audiocodecid),this.flvHeader.hasVideo=(0,g.A)(i.videocodecid)}if(this.packetQueue.length>10||this.hasMetadata){if(this.flvHeader.write(this.flvWriter),this.flvWriter.writeUint32(0),!this.hasMetadata&&this.session.getDuration()){const t=new p.A;t.onMetaData={duration:this.session.getDuration()},t.write(this.flvWriter)}this.packetQueue.forEach((t=>{this.writeFlvData(t)})),this.packetQueue.length=0,this.flvHeaderWrote=!0}}}async send(t){return this.socket?(await this.socket.send(t),0):-1048574}async open(t){this.info=t,this.status=1,3===t.subProtocol?(this.socket=new a.A(this.options),await this.socket.open({url:t.url,webtransportOptions:t.webtransportOptions})):(this.socket=new n.A(this.options),await this.socket.open({url:t.url})),this.ioReader=new o.A,this.ioReader.onFlush=async t=>this.socket.read(t),this.ioReader.onSeek=async t=>this.socket.seek(t),this.ioReader.onSize=async()=>this.socket.size(),this.ioWriter=new f.A,this.ioWriter.onFlush=async t=>this.socket.write(t),this.ioWriter.onSeek=async t=>this.socket.seek(t),this.flvWriter=new l.A,this.flvWriter.onFlush=t=>(this.readQueue.push(t.slice()),this.consume&&this.consume(),0),this.flvHeader=new d.A,this.packetQueue=[],this.flvHeaderWrote=!1,this.hasMetadata=!1,this.session=new h.A(this.ioReader,this.ioWriter,{isLive:this.options.isLive,isPull:!0}),this.session.onMediaPacket=async(t,i)=>this.handleRtmpPacket(t),this.session.onError=()=>{this.status=3,this.consume&&this.consume()},await this.session.handshake();const i=u.qg(this.info.uri),e=i.pathname.split("/");await this.session.connect(e[1],`rtmp://${i.host}${i.port?":"+i.port:""}/${e[1]}`);const s=e.slice(2);return this.session.play((s.length>1?s.join("/"):s[0])||""),0}async seek(t){return await this.session.seek(Number(t)),0}async size(){return BigInt(0)}async stop(){this.socket&&(await this.socket.stop(),this.socket=null),this.status=4}}},46084:(t,i,e)=>{"use strict";e.d(i,{u:()=>r});var s=e(134);class r{constructor(t,i,e,r){(0,s.A)(this,"channelId",void 0),(0,s.A)(this,"type",void 0),(0,s.A)(this,"timestamp",void 0),(0,s.A)(this,"tsField",0),(0,s.A)(this,"extra",0),(0,s.A)(this,"payload",void 0),this.channelId=t,this.type=i,this.timestamp=e,this.payload=r instanceof Uint8Array?r:new Uint8Array(r)}}},82058:(t,i,e)=>{"use strict";e.d(i,{A:()=>U});var s=e(134),r=e(80662),n=e.n(r),a=e(54001),h=e.n(a),o=e(46084),f=e(90519),u=e(86932),l=e(729),d=e(68680),p=e(73040),c=e(98951),w=e(31865),g=e(4624),b=e(72739),y=e(67672),m=e(13724),k=e(83229);const v="src/avprotocol/rtmp/RtmpSession.ts";class U{constructor(t,i,e){(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"prevReadPacket",void 0),(0,s.A)(this,"prevWritePacket",void 0),(0,s.A)(this,"inChunkSize",void 0),(0,s.A)(this,"outChunkSize",void 0),(0,s.A)(this,"seq",void 0),(0,s.A)(this,"bufferWriter",void 0),(0,s.A)(this,"bufferReader",void 0),(0,s.A)(this,"requestMap",void 0),(0,s.A)(this,"state",void 0),(0,s.A)(this,"maxSentUnacked",void 0),(0,s.A)(this,"receiveReportSize",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"options",void 0),(0,s.A)(this,"streamIdMap",void 0),(0,s.A)(this,"sendAsync",void 0),(0,s.A)(this,"onMediaPacket",void 0),(0,s.A)(this,"onError",void 0),this.ioReader=t,this.ioWriter=i,this.options=e,this.prevReadPacket=new(n()),this.prevWritePacket=new(n()),this.requestMap=new(n()),this.streamIdMap=new(n()),this.inChunkSize=128,this.outChunkSize=128,this.seq=0,this.maxSentUnacked=25e5,this.receiveReportSize=1048576,this.sendAsync=new k.an,this.bufferWriter=new l.A(new Uint8Array(1)),this.bufferReader=new w.A(new Uint8Array(1)),this.state=0}async handshake(){const t=(0,u.A)();await this.ioWriter.writeUint8(3),await this.ioWriter.writeUint32(0),await this.ioWriter.writeUint32(0);const i=new Uint8Array(1528);f.y(i),await this.ioWriter.writeBuffer(i),await this.ioWriter.flush(),await this.ioReader.readUint8();const e=await this.ioReader.readUint32();await this.ioReader.skip(4);const s=await this.ioReader.readBuffer(1528);await this.ioWriter.writeUint32(e),await this.ioWriter.writeUint32((0,u.A)()-t),await this.ioWriter.writeBuffer(s),await this.ioWriter.flush(),await this.ioReader.skip(1536),this.readRtmpPacket()}async sendPacket(t){await(0,k.s2)(this.sendAsync),await(0,c.U)(this.ioWriter,this.outChunkSize,t,this.prevWritePacket.get(t.channelId)),this.prevWritePacket.set(t.channelId,t),(0,k.Tl)(this.sendAsync)}async readPacket(){const t=await(0,c.w)(this.ioReader,this.inChunkSize,this.prevReadPacket);return this.prevReadPacket.set(t.channelId,t),t}handleChunkSize(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.inChunkSize=this.bufferReader.readUint32())}handleUserControl(t){t.payload.length>=2&&(this.bufferReader.resetBuffer(t.payload),6===this.bufferReader.readUint16()&&this.sendPong(t,this.bufferReader.readUint32()))}handleSetPeerBW(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.maxSentUnacked=this.bufferReader.readUint32(),g.Yz(`Max sent, unacked = ${this.maxSentUnacked}`,v,205))}handleWindowSizeACK(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.receiveReportSize=this.bufferReader.readUint32(),g.Yz(`Window acknowledgement size = ${this.receiveReportSize}`,v,212),this.receiveReportSize>>=1)}async handleInvoke(t){this.bufferReader.resetBuffer(t.payload);const i=BigInt(t.payload.length),e=await p.$x(this.bufferReader,i),s=await p.$x(this.bufferReader,i);if("_result"===e||"_error"===e){if(this.requestMap.has(s)){const t=await p.$x(this.bufferReader,i),r=await p.$x(this.bufferReader,i);"_result"===e?this.requestMap.get(s).resolve({options:t,info:r}):this.requestMap.get(s).reject({options:t,info:r}),this.requestMap.delete(s)}}else if("onStatus"===e){const t=await p.$x(this.bufferReader,i);let e=await p.$x(this.bufferReader,i);if("error"===e.level)g.z3(`Server error: ${e.description}, ${e.code}`,v,248),this.requestMap.has(s)?(this.requestMap.get(s).reject({options:t,info:e}),this.requestMap.delete(s)):this.onError&&this.onError();else{switch(e.code){case"NetStream.Play.Start":case"NetStream.Seek.Notify":this.state=3;break;case"NetStream.Play.Stop":case"NetStream.Play.UnpublishNotify":this.state=8;break;case"NetStream.Publish.Start":this.state=5}this.requestMap.has(s)&&(this.requestMap.get(s).resolve({options:t,info:e}),this.requestMap.delete(s))}}else"onBWDone"===e&&await this.sendCheckBW()}async handleNotify(t){this.bufferReader.resetBuffer(t.payload),"@setDataFrame"===await p.$x(this.bufferReader,BigInt(t.payload.length))&&(t.payload=t.payload.subarray(Number(this.bufferReader.getPos()))),t.payload.length&&this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}async readRtmpPacket(){for(;;)try{const t=await this.readPacket();switch(t.type){case 3:default:break;case 1:this.handleChunkSize(t);break;case 4:this.handleUserControl(t);break;case 6:this.handleSetPeerBW(t);break;case 5:this.handleWindowSizeACK(t);break;case 20:await this.handleInvoke(t);break;case 18:await this.handleNotify(t);break;case 22:case 8:case 9:this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}}catch(t){break}}async sendPong(t,i){if(t.payload.length<6)return void g.R8(`Too short ping packet (${t.payload.length})`,v,348);const e=new o.u(2,4,t.timestamp+1,6);this.bufferWriter.resetBuffer(e.payload),this.bufferWriter.writeUint16(7),this.bufferWriter.writeUint32(i),this.sendPacket(e)}async sendWindowAckSize(){const t=new o.u(2,5,0,4);this.bufferWriter.resetBuffer(t.payload),this.bufferWriter.writeUint32(this.maxSentUnacked),await this.sendPacket(t)}async sendBufferTime(t){const i=new o.u(2,4,1,10);this.bufferWriter.resetBuffer(i.payload),this.bufferWriter.writeUint16(3),this.bufferWriter.writeUint32(t),this.bufferWriter.writeUint32(this.options.clientBufferTime||3e3),await this.sendPacket(i)}async sendFCSubscribe(t){const i=new o.u(3,20,0,27+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCSubscribe"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendFCPublish(t){const i=new o.u(3,20,0,25+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCPublish"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendReleaseStream(t){const i=new o.u(3,20,0,29+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"releaseStream"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendCheckBW(){const t=new o.u(3,20,0,21);this.bufferWriter.resetBuffer(t.payload),p.bD(this.bufferWriter,"_checkbw"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),await this.sendPacket(t)}async request(t,i){const e=new o.u(3,20,0,4096+d.iD);return this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,++this.seq),b.__(i,(t=>{p.bD(this.bufferWriter,t)})),e.payload=e.payload.subarray(0,this.bufferWriter.getPos()),new(h())(((t,i)=>{this.requestMap.set(this.seq,{resolve:t,reject:i}),this.sendPacket(e)}))}async connect(t,i){await this.request("connect",[{app:t,fourCcList:["hvc1","av01","vp09"],flashVer:"LNX 9,0,124,2",tcUrl:i,fpad:0,capabilities:15,audioCodecs:4071,videoCodecs:252,videoFunction:1}]),this.options.isPull&&await this.sendWindowAckSize()}async createStream(){return(await this.request("createStream",[null])).info}async play(t){const i=await this.createStream();if(this.streamIdMap.set(i,t),!this.options.isLive){const i=await h().race([this.request("getStreamLength",[null,t]),new m.A(1)]);y.ai(i)||(this.duration=i.info)}await this.sendFCSubscribe(t),this.request("play",[null,t,-1,-1,!0]),await this.sendBufferTime(i)}async publish(t){await this.sendReleaseStream(t),await this.sendFCPublish(t);const i=await this.createStream();this.streamIdMap.set(i,t),await this.request("publish",[null,t,"live"])}async sendStreamPacket(t,i){let e=0;this.streamIdMap.forEach(((t,s)=>{t===i&&(e=s)})),t.extra=e,await this.sendPacket(t)}async seek(t){const i=new o.u(3,20,0,26);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"seek"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async pause(t,i){const e=new o.u(3,20,0,29);this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,"pause"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,i),await this.sendPacket(e)}getDuration(){return this.duration}}},68680:(t,i,e)=>{"use strict";e.d(i,{iD:()=>s});const s=1024},98951:(t,i,e)=>{"use strict";e.d(i,{U:()=>o,w:()=>f});var s=e(46084),r=e(92647),n=e(4624);const a="src/avprotocol/rtmp/util.ts";async function h(t,i,e){if(i<64)await t.writeUint8(i|e<<6);else if(i<320)await t.writeUint8(e<<6),await t.writeUint8(i-64);else{await t.writeUint8(1|e<<6);const s=i-64;await t.writeUint8(255&s),await t.writeUint8(s>>>8)}}async function o(t,i,e,s){const r=s&&s.extra===e.extra&&e.timestamp>=s.timestamp;let n=e.timestamp;r&&(n-=s.timestamp),e.tsField=n>16777215?16777215:n;let a=0;r&&(e.type===s.type&&e.payload.length===s.payload.length?(a=2,e.tsField===s.tsField&&(a=3)):a=1),await h(t,e.channelId,a),3!==a&&(await t.writeUint24(e.tsField),2!==a&&(await t.writeUint24(e.payload.length),await t.writeUint8(e.type),0===a&&(await t.writeUint8(e.extra),await t.writeUint8(e.extra>>8),await t.writeUint8(e.extra>>16),await t.writeUint8(e.extra>>24)))),16777215===e.tsField&&await t.writeUint32(n);let o=0;for(;o<e.payload.length;){const s=Math.min(i,e.payload.length-o);await t.writeBuffer(e.payload.subarray(o,o+s)),o+=s,o<e.payload.length&&(await h(t,e.channelId,3),16777215===e.tsField&&await t.writeUint32(n))}await t.flush()}async function f(t,i,e){const h=[],o=await t.readUint8();let f=63&o;f<2&&(f=0===await t.readUint8()?await t.readUint8()+64:64+(await t.readUint8()|await t.readUint8()<<8));const u=o>>>6,l=e.get(f);let d=l?l.payload.length:0,p=l?l.type:0,c=l?l.extra:0,w=0,g=0;if(3===u?w=l.tsField:(w=await t.readUint24(),2!==u&&(d=await t.readUint24(),p=await t.readUint8(),0===u&&(c=await t.readUint8(),c|=await t.readUint8()<<8,c|=await t.readUint8()<<16,c|=await t.readUint8()<<24))),g=16777215===w?await t.readUint32():w,0!==u&&(l?g+=l.timestamp:n.R8(`got invalid message fmt, channel id ${f} can not find prev message with fmt ${u}`,a,171)),d<i)h.push(await t.readBuffer(d));else{let e=d;for(;e;){const s=Math.min(i,e);if(h.push(await t.readBuffer(s)),e-=s,e){const i=63&await t.readUint8();i<2&&await t.skip(i+1),16777215===w&&await t.skip(4)}}}const b=new s.u(f,p,g,(0,r.A)(Uint8Array,h));return b.tsField=w,b.extra=c,b}},77231:(t,i,e)=>{"use strict";e.d(i,{Dh:()=>r,FQ:()=>d,H3:()=>o,KR:()=>u,N_:()=>n,SF:()=>a,WT:()=>f,f7:()=>w,go:()=>p,i0:()=>l,qs:()=>h,zg:()=>c});var s=e(9599);const r=-BigInt(1),n=-1,a=1e6,h=1e3,o=1e9,f=BigInt(2208988800)*BigInt(1e6),u=new s.P({den:a,num:1}),l=new s.P({den:h,num:1}),d=new s.P({den:o,num:1}),p=(new s.P({den:1,num:1}),2147483647),c=65535,w=4294967295},9599:(t,i,e)=>{"use strict";e.d(i,{P:()=>u});var s,r,n=e(134),a=e(80662),h=e.n(a),o=e(61499),f=e(12085);class u{constructor(t){(0,n.A)(this,"num",1),(0,n.A)(this,"den",1),t&&(this.den=t.den,this.num=t.num)}}s=u.prototype,(r=new(h())).set("num",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),r.set("den",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,f.A)(s,o.Og,!0),(0,f.A)(s,o.dc,4),(0,f.A)(s,o.g7,8),(0,f.A)(s,o.JY,r)},73040:(t,i,e)=>{"use strict";e.d(i,{$x:()=>h,bD:()=>o});var s=e(67672),r=e(72739),n=e(95335);async function a(t,i){return{key:await t.readString(await t.readUint16()),value:await h(t,i)}}async function h(t,i){let e;switch(await t.readUint8()){case 0:e=await t.readDouble();break;case 1:e=!!await t.readUint8();break;case 2:e=await t.readString(await t.readUint16());break;case 3:for(e={};t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 8:for(e={},await t.skip(4);t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 9:case 5:e=null;break;case 10:e=[];const s=await t.readUint32();for(let r=0;r<s;r++)e.push(await h(t,i));break;case 11:const r=await t.readDouble(),n=await t.readInt16();e=new Date(r+60*n*1e3);break;case 12:e=await t.readString(await t.readUint32())}return e}function o(t,i){s.ai(i)?(t.writeUint8(0),t.writeDouble(i)):s.o(i)?(t.writeUint8(0),t.writeDouble(Number(i))):s.zM(i)?(t.writeUint8(1),t.writeUint8(i?1:0)):s.Yj(i)?i.length>=65536?(t.writeUint8(12),t.writeUint32(i.length),t.writeString(i)):(t.writeUint8(2),t.writeUint16(i.length),t.writeString(i)):s.YO(i)?(t.writeUint8(10),t.writeUint32(i.length),r.__(i,(i=>{o(t,i)}))):s.Ik(i)?(t.writeUint8(3),n.__(i,((i,e)=>{t.writeUint16(e.length),t.writeString(e),o(t,i)})),t.writeUint24(9)):i instanceof Date?(t.writeUint8(11),t.writeDouble(i.getTime()),t.writeInt16(0)):null==i&&t.writeUint8(5)}},90519:(t,i,e)=>{"use strict";function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},44328:(t,i,e)=>{"use strict";e.d(i,{FP:()=>o,Mr:()=>h,iU:()=>l,j2:()=>u,k:()=>a,lb:()=>f});var s=e(63939),r=e(77231),n=e(31658);function a(t,i,e){return t*BigInt(i.num)*BigInt(e.den)/(BigInt(i.den)*BigInt(e.num))}function h(t,i,e){return t*BigInt(s.f[15](i))*BigInt(e.den)/(BigInt(s.f[15](i+4))*BigInt(e.num))}function o(t,i,e){return t*BigInt(i.num)*BigInt(s.f[15](e+4))/(BigInt(i.den)*BigInt(s.f[15](e)))}function f(t){return t.num/t.den}function u(t,i){if(isNaN(19))return{den:0,num:0};if(Math.abs(t)>r.go+3)return{den:0,num:t<0?-1:1};const e=t>1?{den:Math.floor(i/t+.5),num:i}:{den:i,num:Math.floor(t*i+.5)};return l(e),e}function l(t){const i=(0,n.A)(t.num,t.den);i<=1||(t.den/=i,t.num/=i)}},83229:(t,i,e)=>{"use strict";e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(134),r=e(54001),n=e.n(r);class a{constructor(){(0,s.A)(this,"list",[])}}async function h(t){return new(n())((i=>{t.list.push(i),1===t.list.length&&i()}))}function o(t){t.list.shift(),t.list.length&&t.list[0]()}},6498:(t,i,e)=>{"use strict";e(67672),e(72739)},24175:(t,i,e)=>{"use strict";e.d(i,{A:()=>o});var s=e(134),r=e(4624),n=e(50011),a=e(13724);const h="src/common/io/IOReader.ts";class o{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async readUint8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}async peekUint8(){return this.remainingLength()<1&&await this.flush(1),this.data.getUint8(this.pointer)}async readUint16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekUint16(){return this.remainingLength()<2&&await this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}async readUint24(){this.remainingLength()<3&&await this.flush(3);const t=await this.readUint16(),i=await this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}async peekUint24(){this.remainingLength()<3&&await this.flush(3);const t=this.pointer,i=this.pos,e=await this.readUint16(),s=await this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}async readUint32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekUint32(){return this.remainingLength()<4&&await this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}async readUint64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekUint64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}async readInt8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}async peekInt8(){return this.remainingLength()<1&&await this.flush(1),this.data.getInt8(this.pointer)}async readInt16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekInt16(){return this.remainingLength()<2&&await this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}async readInt24(){const t=await this.readUint24();return 8388608&t?t-16777216:t}async peekInt24(){const t=await this.peekUint24();return 8388608&t?t-16777216:t}async readInt32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekInt32(){return this.remainingLength()<4&&await this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}async readInt64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekInt64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}async readFloat(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekFloat(){return this.remainingLength()<4&&await this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}async readDouble(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekDouble(){return this.remainingLength()<8&&await this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}async readHex(t=1){let i="";for(let e=0;e<t;e++){const t=(await this.readUint8()).toString(16);i+=1===t.length?"0"+t:t}return i}async peekHex(t=1){t>this.size&&(this.error=-1048574,r.h2("peekHex, length too large",h,414)),this.remainingLength()<t&&await this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=(await this.readUint8()).toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}async readBuffer(t,i){if(i||(i=new Uint8Array(t)),this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){await this.flush();const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}}else i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t);return i}async peekBuffer(t,i){return t>this.size&&(this.error=-1048574,r.h2("peekBuffer, length too large",h,499)),this.remainingLength()<t&&await this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i}async readToBuffer(t,i){if(this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){try{await this.flush()}catch(t){if(-1048576===this.error&&e)return e;throw t}const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}return e}return i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t),t}async readString(t=1){const i=await this.readBuffer(t);return n.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return n.decode(i)}async readLine(){let t="";for(;;){let i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){e!==this.pointer&&(t+=await this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=await this.readString(this.remainingLength()),await this.flush()}let i=await this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=await this.peekUint8(),10===i&&this.pointer++)),t}async peekLine(){if(this.remainingLength()<this.size)try{await this.flush()}catch(t){if(-1048576!==this.error)throw t}let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=await this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,r.h2("peekLine, out of buffer",h,657)),t}getPointer(){return this.pointer}getPos(){return this.pos}async skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,await this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}async flush_(t){for(;;){const i=await this.onFlush(t);if(-1048575!==i)return i;await new a.A(0)}}async flush(t=0){if(this.onFlush||(this.error=-1048574,r.h2("IOReader error, flush failed because of no flush callback",h,731)),!(this.size-this.remainingLength()<=0)){if(t=Math.min(t,this.size),this.pointer<this.endPointer?(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0,t)for(;this.remainingLength()<t;){const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}else{const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}this.error=0}}async seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,r.h2("IOReader error, seek failed because of no seek callback",h,802)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,r.h2("IOReader error, seek failed",h,811)),e&&await this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,r.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",h,849)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return r.R8("IOReader error, fileSize failed because of no onSize callback",h,882),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){r.R8(`IOReader error, call fileSize failed: ${t}`,h,889),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}async pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){await this.flush();const e=Math.min(this.remainingLength(),i);await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i);else{if(this.remainingLength()>0){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;await this.flush_(this.buffer.subarray(0))>0;){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}}},34531:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async writeUint8(t){this.remainingLength()<1&&await this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}async writeUint16(t){this.remainingLength()<2&&await this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeUint24(t){this.remainingLength()<3&&await this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(await this.writeUint8(s),await this.writeUint8(e),await this.writeUint8(i)):(await this.writeUint8(i),await this.writeUint8(e),await this.writeUint8(s))}async writeUint32(t){this.remainingLength()<4&&await this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeUint64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeInt8(t){this.remainingLength()<1&&await this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}async writeInt16(t){this.remainingLength()<2&&await this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeInt24(t){await this.writeUint24(t<0?t+16777216:t)}async writeInt32(t){this.remainingLength()<4&&await this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeInt64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeFloat(t){this.remainingLength()<4&&await this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeDouble(t){this.remainingLength()<8&&await this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}async writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){await this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}async writeString(t){const i=r.encode(t);return await this.writeBuffer(i),i.length}async flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=await this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}async flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=await this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}async seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");await this.flush();const i=await this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},35336:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(t){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}writeUint16(t){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(t){this.remainingLength()<3&&this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(this.writeUint8(s),this.writeUint8(e),this.writeUint8(i)):(this.writeUint8(i),this.writeUint8(e),this.writeUint8(s))}writeUint32(t){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(t){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(t){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}writeInt16(t){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt24(t){this.writeUint24(t<0?t+16777216:t)}writeInt32(t){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(t){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(t){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(t){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}writeString(t){const i=r.encode(t);return this.writeBuffer(i),i.length}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const i=this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},31658:(t,i,e)=>{"use strict";function s(t,i){for(;0!==i;)[t,i]=[i,t%i];return t}e.d(i,{A:()=>s})},8507:(t,i,e)=>{"use strict";function s(t){const i=t,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let r="";s.test(t)&&(t=t.replace(s,((t,i,e)=>(r=e,`://${i||""}a.b`))));const n={},a=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let h=14;for(;h--;){var o;n[e[h]]=null!==(o=a[h])&&void 0!==o?o:""}return r&&(n.host=r,n.source=i,n.authority=r+(n.port?":"+n.port:"")),{protocol:n.protocol,file:n.file,host:n.host,port:n.port,user:n.user,password:n.password,origin:`${n.protocol}://${n.authority}`,pathname:n.path,search:`?${n.query}`,hash:n.anchor?`#${n.anchor}`:""}}e.d(i,{ll:()=>l,qg:()=>s}),e(73146),e(67672),e(6498),e(72739),e(95335);const r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a=/^(?=([^\/?#]*))\1([^]*)$/,h=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function o(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function f(t){const i=h.exec(t);return i?{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}:null}function u(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")}function l(t,i,e){if(e=e||{},t=t.trim(),!(i=i.trim())){if(!e.alwaysNormalize)return t;let i=f(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=u(i.path),o(i)}let s=f(i);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return e.alwaysNormalize?(s.path=u(s.path),o(s)):i;let r=f(t);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){let t=a.exec(r.path);r.netLoc=t[1],r.path=t[2]}r.netLoc&&!r.path&&(r.path="/");const n={scheme:r.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(n.netLoc=r.netLoc,"/"!==s.path[0]))if(s.path){let t=r.path,i=t.substring(0,t.lastIndexOf("/")+1)+s.path;n.path=u(i)}else n.path=r.path,s.params||(n.params=r.params,s.query||(n.query=r.query));return null===n.path&&(n.path=e.alwaysNormalize?u(s.path):s.path),o(n)}},85079:(t,i,e)=>{var s=e(46438),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},73146:(t,i,e)=>{t.exports=e(85079)}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[576],{41576:(e,t,i)=>{i.r(t),i.d(t,{default:()=>L});var s=i(134),a=i(80662),n=i.n(a),d=i(54001),o=i.n(d),r=i(13724),l=i(82800),m=i(95335),u=i(4624),h=i(78417),c=i(77580),g=i(86932),f=i(9705);const p="src/avnetwork/ioLoader/DashIOLoader.ts";class L extends l.A{constructor(...e){super(...e),(0,s.A)(this,"info",void 0),(0,s.A)(this,"range",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"fetchMediaPlayListPromise",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"audioResource",void 0),(0,s.A)(this,"videoResource",void 0),(0,s.A)(this,"subtitleResource",void 0)}createResource(e){return{type:e,fetchedMap:new(n()),fetchedHistoryList:[],loader:null,segmentIndex:0,currentUri:"",selectedIndex:0,segments:[],initSegmentPadding:"",initedSegment:""}}async fetchMediaPlayList(e){var t,i,s;if(!e){if(this.fetchMediaPlayListPromise)return;this.fetchMediaPlayListPromise=new(o())((t=>{e=t}))}const a={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};null!==(t=this.info.httpOptions)&&void 0!==t&&t.headers&&m.__(this.info.httpOptions.headers,((e,t)=>{a.headers[t]=e})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(a.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(a.referrerPolicy=this.info.httpOptions.referrerPolicy);try{const t=await fetch(this.info.url,a),i=await t.text();if(this.mediaPlayList=(0,h.A)(i,this.info.url),this.minBuffer=this.mediaPlayList.minBufferTime,this.options.isLive){var n,d;const t=this.mediaPlayList.minBufferTime/this.mediaPlayList.maxSegmentDuration,i=Math.max(this.mediaPlayList.mediaList.audio&&(null===(n=this.mediaPlayList.mediaList.audio[0])||void 0===n?void 0:n.mediaSegments.length)||0,this.mediaPlayList.mediaList.video&&(null===(d=this.mediaPlayList.mediaList.video[0])||void 0===d?void 0:d.mediaSegments.length)||0);if(i<t)return await new r.A((t-i)*this.mediaPlayList.maxSegmentDuration),u.R8(`wait for min buffer time, buffer: ${i*this.mediaPlayList.maxSegmentDuration}, need: ${t*this.mediaPlayList.maxSegmentDuration}`,p,136),this.fetchMediaPlayList(e)}if("vod"===this.mediaPlayList.type?this.options.isLive=!1:this.options.isLive=!0,this.mediaPlayList.mediaList.audio.length){const e=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];e.file?this.audioResource.segments=[e.file]:this.options.isLive&&this.audioResource.initedSegment===e.initSegment?this.audioResource.segments=e.mediaSegments.map((e=>e.url)):(this.audioResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.audioResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.video.length){const e=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];e.file?this.videoResource.segments=[e.file]:this.options.isLive&&this.videoResource.initedSegment===e.initSegment?this.videoResource.segments=e.mediaSegments.map((e=>e.url)):(this.videoResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.videoResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.subtitle.length){const e=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];e.file?this.subtitleResource.segments=[e.file]:this.options.isLive&&this.subtitleResource.initedSegment===e.initSegment?this.subtitleResource.segments=e.mediaSegments.map((e=>e.url)):(this.subtitleResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.subtitleResource.initedSegment=e.initSegment)}return e(),this.fetchMediaPlayListPromise=null,this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,u.z3(`failed fetch mpd file, retry(${this.retryCount}/3)`,p,208),await new r.A(2===this.status?this.options.retryInterval:5),this.fetchMediaPlayList(e);this.status=3,e(),u.h2(`DashLoader: exception, fetch slice error, error: ${t.message}`,p,216)}}async open(e,t){return 0!==this.status?f.lh:(this.info=e,this.range=t,this.range.to||(this.range.to=-1),this.range.from=Math.max(this.range.from,0),this.videoResource=this.createResource("video"),this.audioResource=this.createResource("audio"),this.subtitleResource=this.createResource("subtitle"),this.status=1,this.retryCount=0,await this.fetchMediaPlayList(),0)}async readResource(e,t){let i=0;if(t.loader){if(i=await t.loader.read(e),-1048576!==i)return i;if(this.options.isLive)t.fetchedMap.set(t.currentUri,!0),10===t.fetchedHistoryList.length&&t.fetchedMap.delete(t.fetchedHistoryList.shift()),t.fetchedHistoryList.push(t.currentUri);else if(t.segmentIndex++,t.segmentIndex>=t.segments.length)return-1048576;t.loader=null}if(this.options.isLive){const i=t.segments.filter((e=>!t.fetchedMap.get(e)));if(!i.length){if(this.mediaPlayList.isEnd)return-1048576;const i=(this.mediaPlayList.duration||this.mediaPlayList.minimumUpdatePeriod)-((0,g.A)()-this.mediaPlayList.timestamp)/1e3;if(i>0&&await new r.A(Math.max(i,2)),this.fetchMediaPlayListPromise){if(await this.fetchMediaPlayListPromise,3===this.status)return-1048576}else await this.fetchMediaPlayList();return this.readResource(e,t)}return t.currentUri=i[0],t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),await t.loader.open(m.X$({},this.info,{url:t.currentUri}),{from:0,to:-1}),t.loader.read(e)}return t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),t.initSegmentPadding?(await t.loader.open(m.X$({},this.info,{url:t.initSegmentPadding}),{from:0,to:-1}),t.initSegmentPadding=null,t.segmentIndex--):await t.loader.open(m.X$({},this.info,{url:t.segments[t.segmentIndex]}),{from:0,to:-1}),t.loader.read(e)}async read(e,t){return"audio"===t.mediaType?this.readResource(e,this.audioResource):"video"===t.mediaType?this.readResource(e,this.videoResource):"subtitle"===t.mediaType?this.readResource(e,this.subtitleResource):f.UY}async seekResource(e,t){let i="";t.loader&&(i=t.loader.getUrl(),await t.loader.abort(),t.loader=null);let s=Number(BigInt.asIntN(32,e));if(t.segments){let e=0;const a="audio"===t.type?this.mediaPlayList.mediaList.audio:"video"===t.type?this.mediaPlayList.mediaList.video:this.mediaPlayList.mediaList.subtitle,n=a[t.selectedIndex].mediaSegments;if(null!=n&&n.length)for(let t=0;t<n.length;t++)if(s>=1e3*n[t].start&&s<1e3*n[t].end){e=t;break}t.segmentIndex=e+(a[t.selectedIndex].initSegment?1:0);let d="";"video"===t.type?d=this.mediaPlayList.mediaList.video[t.selectedIndex].initSegment:"audio"===t.type?d=this.mediaPlayList.mediaList.audio[t.selectedIndex].initSegment:"subtitle"===t.type&&(d=this.mediaPlayList.mediaList.subtitle[t.selectedIndex].initSegment),d&&d===i&&(t.initSegmentPadding=d)}}async seek(e,t){return"audio"===t.mediaType&&this.audioResource.loader&&await this.seekResource(e,this.audioResource),"video"===t.mediaType&&this.videoResource.loader&&await this.seekResource(e,this.videoResource),"subtitle"===t.mediaType&&this.subtitleResource.loader&&await this.seekResource(e,this.subtitleResource),4===this.status&&(this.status=2),0}async size(){return BigInt(0)}async abort(){this.videoResource.loader&&(await this.videoResource.loader.abort(),this.videoResource.loader=null),this.audioResource.loader&&(await this.audioResource.loader.abort(),this.audioResource.loader=null),this.subtitleResource.loader&&(await this.subtitleResource.loader.abort(),this.subtitleResource.loader=null)}async stop(){await this.abort(),this.status=0}getDuration(){return this.mediaPlayList.duration}hasVideo(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.video.length)>0}hasAudio(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.audio.length)>0}hasSubtitle(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.subtitle.length)>0}getVideoList(){return this.hasVideo()?{list:this.mediaPlayList.mediaList.video.map((e=>({width:e.width,height:e.height,frameRate:e.frameRate,codecs:e.codecs}))),selectedIndex:this.videoResource.selectedIndex}:{list:[],selectedIndex:0}}getAudioList(){return this.hasAudio()?{list:this.mediaPlayList.mediaList.audio.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.audioResource.selectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.hasSubtitle()?{list:this.mediaPlayList.mediaList.subtitle.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.subtitleResource.selectedIndex}:{list:[],selectedIndex:0}}selectVideo(e){if(e!==this.videoResource.selectedIndex&&this.hasVideo()&&e>=0&&e<this.mediaPlayList.mediaList.video.length){this.videoResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];t.file?this.videoResource.segments=[t.file]:(this.videoResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.videoResource.initSegmentPadding=t.initSegment)}}selectAudio(e){if(e!==this.audioResource.selectedIndex&&this.hasAudio()&&e>=0&&e<this.mediaPlayList.mediaList.audio.length){this.audioResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];t.file?this.audioResource.segments=[t.file]:(this.audioResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.audioResource.initSegmentPadding=t.initSegment)}}selectSubtitle(e){if(e!==this.subtitleResource.selectedIndex&&this.hasSubtitle()&&e>=0&&e<this.mediaPlayList.mediaList.subtitle.length){this.subtitleResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];t.file?this.subtitleResource.segments=[t.file]:(this.subtitleResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.subtitleResource.initSegmentPadding=t.initSegment)}}getMinBuffer(){return this.minBuffer}}},78417:(e,t,i)=>{i.d(t,{A:()=>g});var s=i(88032),a=i.n(s),n=i(29967),d=i.n(n),o=i(79331),r=i(67672),l=i(62100),m=i(86932);function u(e){let t=0,i=0,s=0;return(e=e.slice(e.indexOf("PT")+2)).indexOf("H")>-1&&e.indexOf("M")>-1&&e.indexOf("S")>-1?(t=a()(e.slice(0,e.indexOf("H"))),i=a()(e.slice(e.indexOf("H")+1,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")>0&&e.indexOf("S")>-1?(i=a()(e.slice(0,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")<0&&e.indexOf("S")>-1&&(s=a()(e.slice(0,e.indexOf("S")))),3600*t+60*i+s}function h(e,t){return(Array(t).join("0")+e).slice(-t)}function c(e){if(!e)return 0;if(e.indexOf("/")>-1){const t=e.split("/");return a()(t[0])/a()(t[1])}return a()(e)}function g(e,t){const i={source:e,mediaList:{audio:[],video:[],subtitle:[]},type:"live",isEnd:!1,duration:0,minBufferTime:0,maxSegmentDuration:0,minimumUpdatePeriod:0,timestamp:(0,m.A)()},s=[],n=(g=e,g?(0,o.A)(g,{aloneValueName:"value"}):null).MPD;var g;"static"===n.type&&(i.type="vod",i.isEnd=!0),n.minBufferTime&&(i.minBufferTime=u(n.minBufferTime)),n.maxSegmentDuration&&(i.maxSegmentDuration=u(n.maxSegmentDuration)),n.minimumUpdatePeriod&&(i.minimumUpdatePeriod=u(n.minimumUpdatePeriod)),n.mediaPresentationDuration&&(i.duration=u(n.mediaPresentationDuration));let f="";n.BaseURL&&(f=r.Yj(n.BaseURL)?n.BaseURL:n.BaseURL.value);const p=r.YO(n.Period)?n.Period[0]:n.Period;return!i.duration&&p&&p.duration&&(i.duration=u(p.duration)),(r.YO(p.AdaptationSet)?p.AdaptationSet:[p.AdaptationSet]).forEach(((e,n)=>{let o="video/mp4",m="video",u="avc1.64001E",g=640,p=360,L=640,S=360,y=25,R="1:1",P="1",v=588633,b=f,x="und";e.BaseURL&&(b+=e.BaseURL),e.lang&&(x=e.lang),e.mimeType||e.contentType?(o=e.mimeType,m=e.contentType,"video/mp4"===o||"video"===m?(u=e.codecs,g=a()(e.width),p=a()(e.height),e.maxWidth&&(L=a()(e.maxWidth)),e.maxHeight&&(S=a()(e.maxHeight)),e.frameRate&&(y=c(e.frameRate)),R=e.sar,P=e.startWithSAP,v=a()(e.bandwidth)):"audio/mp4"!==o&&"audio"!==m||(u=e.codecs,P=e.startWithSAP,v=a()(e.bandwidth))):(e.maxWidth&&(L=a()(e.maxWidth)),e.maxHeight&&(S=a()(e.maxHeight)),e.frameRate&&(y=c(e.frameRate))),(r.YO(e.Representation)?e.Representation:[e.Representation]).forEach(((n,c)=>{s.indexOf(n.id)>-1&&(n.id=(d()(s[s.length-1])+1).toString()),s.push(n.id);let f="";const w=[];let A=0,I=0,T=t.slice(0,t.lastIndexOf("/")+1)+b;n.mimeType&&(o=n.mimeType),"video/mp4"===o||"video"===m?(n.codecs&&(u=n.codecs),n.width&&(g=a()(n.width)),n.height&&(p=a()(n.height)),n.maxWidth&&(L=a()(n.maxWidth)),n.maxHeight&&(S=a()(n.maxHeight)),n.frameRate&&(y=a()(n.frameRate)),n.sar&&(R=n.sar),n.startWithSAP&&(P=n.startWithSAP),n.bandwidth&&(v=a()(n.bandwidth))):(n.codecs&&(u=n.codecs),n.startWithSAP&&(P=n.startWithSAP),n.bandwidth&&(v=a()(n.bandwidth))),n.BaseURL&&(T+=r.Yj(n.BaseURL)?n.BaseURL:n.BaseURL.value);let O=!1;if((e.ContentProtection||n.ContentProtection)&&(O=!0),n.SegmentBase)"video/mp4"===o||"video"===m?i.mediaList.video.push({id:n.id,file:T,mimeType:o,codecs:u,width:g,height:p,maxWidth:L,maxHeight:S,frameRate:y,sar:R,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O}):"audio/mp4"===o||"audio"===m?i.mediaList.audio.push({id:n.id,file:T,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x}):"application/mp4"!==o&&"text"!==m||i.mediaList.subtitle.push({id:n.id,file:T,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x});else{let t;if(e.SegmentTemplate&&(t=r.YO(e.SegmentTemplate)?e.SegmentTemplate[0]:e.SegmentTemplate),n.SegmentTemplate&&(t=r.YO(n.SegmentTemplate)?n.SegmentTemplate[0]:n.SegmentTemplate),t){const e=d()(t.startNumber);if(f=t.initialization,A=a()(t.timescale||"1"),t.duration&&!t.SegmentTimeline){I=a()(t.duration);let s=I/A;const d=e+Math.ceil((i.duration||s)/s)-1;for(let a=e;a<=d;a++){const o=s*(a-e);let r=s*(a-e+1);a===d&&(s=i.duration-s*(d-e),r=i.duration),w.push({idx:a,start:o,end:r,url:T+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(a,+i):(0,l.A)(a))),segmentDuration:s})}}else if(t.SegmentTimeline&&t.SegmentTimeline.S){const i=r.YO(t.SegmentTimeline.S)?t.SegmentTimeline.S:[t.SegmentTimeline.S];let s=0,o=e;for(let e=0;e<i.length;e++){let r=a()(i[e].d);i[e].t&&(s=a()(i[0].t));let m=1;i[e].r&&(m=d()(i[e].r)+1);for(let e=0;e<m;e++)w.push({idx:o,start:s/A,end:(s+r)/A,url:T+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(o,+i):(0,l.A)(o))).replace(/\$Time\$/g,(0,l.A)(s)),segmentDuration:r/A}),o++,s+=r}}}else if(n.SegmentList){const e=r.YO(n.SegmentList.SegmentURL)?n.SegmentList.SegmentURL:[n.SegmentList.SegmentURL];let t=0,i=a()(n.SegmentList.duration);for(let s=0;s<e.length;s++)w.push({idx:s,start:t/A,end:(t+i)/A,url:T+e[s].media,segmentDuration:i/A}),t+=i}"video/mp4"===o||"video"===m?i.mediaList.video.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,width:g,height:p,maxWidth:L,maxHeight:S,frameRate:y,sar:R,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O}):"audio/mp4"===o||"audio"===m?i.mediaList.audio.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x}):"application/mp4"!==o&&"text"!==m||i.mediaList.subtitle.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x})}}))})),["video","audio"].forEach((e=>{i.mediaList[e].sort(((e,t)=>e.bandwidth-t.bandwidth))})),i}},79331:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(68632),a=i.n(s),n=i(72739);const d={aloneValueName:"_@attribute"},o=[" ","/",'"',"'","<",">"];function r(e,t=d){e=(e=(e=(e=e.replace(/<!--[\s\S]*?-->/g,"")).replace(/[\n\t\r]/g,"")).replace(/>[ \t]+</g,"><")).replace(/<\?[^>]*\?>/g,"");const i=[];let s=0;function r(e,s){const n=i[i.length-1];n&&(e===t.aloneValueName||null==n.obj[t.aloneValueName]?null==n.obj[e]?n.obj[e]=s:a()(n.obj[e])?n.obj[e].push(s):n.obj[e]=[n.obj[e],s]:n.obj[t.aloneValueName]=[n.obj[t.aloneValueName],{tagName:e,...s}])}function l(t){for(;s<e.length;){if(e[s]===t)return!0;s++}return!1}function m(){u();let t="";for(;s<e.length&&!n.zy(o,e[s]);)t+=e[s],s++;return t}function u(){for(;s<e.length&&/\s|\r|\n/.test(e[s]);)s++}const h=/\s/,c=/'/,g=/"/;function f(){if(s>=e.length)return!0;u();let t=h;'"'!==e[s]&&"'"!=e[s]||(t='"'===e[s]?g:c,s++);let i="";for(;s<e.length;){if(t.test(e[s])){s++;break}i+=e[s],s++}return i}function p(){u();let t="";for(;s<e.length&&"<"!==e[s];)t+=e[s],s++;return t}function L(){for(;"<"===e[s];){const t=s;if(s++,u(),"/"!==e[s]){s=t;break}if(s++,m()===i[i.length-1].tag){if(i.length>1){const e=i.pop();r(e.tag,e.obj)}l(">"),s++,u()}else i.pop(),l(">"),s++,u()}}return function a(){if(s>=e.length)return;let n=s;if(u(),"<"!==e[s])return s=n,r(t.aloneValueName,p()),L(),a();let d=l("<");if(!d)return;n=s,s++;const o=m();if(i.push({obj:{},tag:o,start:n}),function(){for(;u(),">"!==e[s]&&"/"!==e[s];){let e=m();if(!e)break;"="===e[e.length-1]?e=e.substring(0,e.length-1):(l("="),s++),r(e,f())}}(),u(),"/"===e[s]){if(s++,i.length>1){const e=i.pop();r(e.tag,e.obj)}return l(">"),s++,L(),a()}d=l(">"),d&&(s++,u(),"<"!==e[s]&&(r(t.aloneValueName,p()),u()),L(),a())}(),{[i[0].tag]:i[0].obj}}}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[576],{41576:(e,t,i)=>{i.r(t),i.d(t,{default:()=>L});var s=i(134),a=i(80662),n=i.n(a),d=i(54001),o=i.n(d),r=i(13724),l=i(82800),m=i(95335),u=i(4624),h=i(78417),c=i(77580),g=i(86932),f=i(9705);const p="src/avnetwork/ioLoader/DashIOLoader.ts";class L extends l.A{constructor(...e){super(...e),(0,s.A)(this,"info",void 0),(0,s.A)(this,"range",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"fetchMediaPlayListPromise",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"audioResource",void 0),(0,s.A)(this,"videoResource",void 0),(0,s.A)(this,"subtitleResource",void 0)}createResource(e){return{type:e,fetchedMap:new(n()),fetchedHistoryList:[],loader:null,segmentIndex:0,currentUri:"",selectedIndex:0,segments:[],initSegmentPadding:"",initedSegment:""}}async fetchMediaPlayList(e){var t,i,s;if(!e){if(this.fetchMediaPlayListPromise)return;this.fetchMediaPlayListPromise=new(o())((t=>{e=t}))}const a={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};null!==(t=this.info.httpOptions)&&void 0!==t&&t.headers&&m.__(this.info.httpOptions.headers,((e,t)=>{a.headers[t]=e})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(a.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(a.referrerPolicy=this.info.httpOptions.referrerPolicy);try{const t=await fetch(this.info.url,a),i=await t.text();if(this.mediaPlayList=(0,h.A)(i,this.info.url),this.minBuffer=this.mediaPlayList.minBufferTime,this.options.isLive){var n,d;const t=this.mediaPlayList.minBufferTime/this.mediaPlayList.maxSegmentDuration,i=Math.max(this.mediaPlayList.mediaList.audio&&(null===(n=this.mediaPlayList.mediaList.audio[0])||void 0===n?void 0:n.mediaSegments.length)||0,this.mediaPlayList.mediaList.video&&(null===(d=this.mediaPlayList.mediaList.video[0])||void 0===d?void 0:d.mediaSegments.length)||0);if(i<t)return await new r.A((t-i)*this.mediaPlayList.maxSegmentDuration),u.R8(`wait for min buffer time, buffer: ${i*this.mediaPlayList.maxSegmentDuration}, need: ${t*this.mediaPlayList.maxSegmentDuration}`,p,136),this.fetchMediaPlayList(e)}if("vod"===this.mediaPlayList.type?this.options.isLive=!1:this.options.isLive=!0,this.mediaPlayList.mediaList.audio.length){const e=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];e.file?this.audioResource.segments=[e.file]:this.options.isLive&&this.audioResource.initedSegment===e.initSegment?this.audioResource.segments=e.mediaSegments.map((e=>e.url)):(this.audioResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.audioResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.video.length){const e=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];e.file?this.videoResource.segments=[e.file]:this.options.isLive&&this.videoResource.initedSegment===e.initSegment?this.videoResource.segments=e.mediaSegments.map((e=>e.url)):(this.videoResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.videoResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.subtitle.length){const e=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];e.file?this.subtitleResource.segments=[e.file]:this.options.isLive&&this.subtitleResource.initedSegment===e.initSegment?this.subtitleResource.segments=e.mediaSegments.map((e=>e.url)):(this.subtitleResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.subtitleResource.initedSegment=e.initSegment)}return e(),this.fetchMediaPlayListPromise=null,this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,u.z3(`failed fetch mpd file, retry(${this.retryCount}/3)`,p,208),await new r.A(2===this.status?this.options.retryInterval:5),this.fetchMediaPlayList(e);this.status=3,e(),u.h2(`DashLoader: exception, fetch slice error, error: ${t.message}`,p,216)}}async open(e,t){return 0!==this.status?f.lh:(this.info=e,this.range=t,this.range.to||(this.range.to=-1),this.range.from=Math.max(this.range.from,0),this.videoResource=this.createResource("video"),this.audioResource=this.createResource("audio"),this.subtitleResource=this.createResource("subtitle"),this.status=1,this.retryCount=0,await this.fetchMediaPlayList(),0)}async readResource(e,t){let i=0;if(t.loader){if(i=await t.loader.read(e),-1048576!==i)return i;if(this.options.isLive)t.fetchedMap.set(t.currentUri,!0),10===t.fetchedHistoryList.length&&t.fetchedMap.delete(t.fetchedHistoryList.shift()),t.fetchedHistoryList.push(t.currentUri);else if(t.segmentIndex++,t.segmentIndex>=t.segments.length)return-1048576;t.loader=null}if(this.options.isLive){const i=t.segments.filter((e=>!t.fetchedMap.get(e)));if(!i.length){if(this.mediaPlayList.isEnd)return-1048576;const i=(this.mediaPlayList.duration||this.mediaPlayList.minimumUpdatePeriod)-((0,g.A)()-this.mediaPlayList.timestamp)/1e3;if(i>0&&await new r.A(Math.max(i,2)),this.fetchMediaPlayListPromise){if(await this.fetchMediaPlayListPromise,3===this.status)return-1048576}else await this.fetchMediaPlayList();return this.readResource(e,t)}return t.currentUri=i[0],t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),await t.loader.open(m.X$({},this.info,{url:t.currentUri}),{from:0,to:-1}),t.loader.read(e)}return t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),t.initSegmentPadding?(await t.loader.open(m.X$({},this.info,{url:t.initSegmentPadding}),{from:0,to:-1}),t.initSegmentPadding=null,t.segmentIndex--):await t.loader.open(m.X$({},this.info,{url:t.segments[t.segmentIndex]}),{from:0,to:-1}),t.loader.read(e)}async read(e,t){return"audio"===t.mediaType?this.readResource(e,this.audioResource):"video"===t.mediaType?this.readResource(e,this.videoResource):"subtitle"===t.mediaType?this.readResource(e,this.subtitleResource):f.UY}async seekResource(e,t){let i="";t.loader&&(i=t.loader.getUrl(),await t.loader.abort(),t.loader=null);let s=Number(BigInt.asIntN(32,e));if(t.segments){let e=0;const a="audio"===t.type?this.mediaPlayList.mediaList.audio:"video"===t.type?this.mediaPlayList.mediaList.video:this.mediaPlayList.mediaList.subtitle,n=a[t.selectedIndex].mediaSegments;if(null!=n&&n.length)for(let t=0;t<n.length;t++)if(s>=1e3*n[t].start&&s<1e3*n[t].end){e=t;break}t.segmentIndex=e+(a[t.selectedIndex].initSegment?1:0);let d="";"video"===t.type?d=this.mediaPlayList.mediaList.video[t.selectedIndex].initSegment:"audio"===t.type?d=this.mediaPlayList.mediaList.audio[t.selectedIndex].initSegment:"subtitle"===t.type&&(d=this.mediaPlayList.mediaList.subtitle[t.selectedIndex].initSegment),d&&d===i&&(t.initSegmentPadding=d)}}async seek(e,t){return"audio"===t.mediaType&&this.audioResource.loader&&await this.seekResource(e,this.audioResource),"video"===t.mediaType&&this.videoResource.loader&&await this.seekResource(e,this.videoResource),"subtitle"===t.mediaType&&this.subtitleResource.loader&&await this.seekResource(e,this.subtitleResource),4===this.status&&(this.status=2),0}async size(){return BigInt(0)}async abort(){this.videoResource.loader&&(await this.videoResource.loader.abort(),this.videoResource.loader=null),this.audioResource.loader&&(await this.audioResource.loader.abort(),this.audioResource.loader=null),this.subtitleResource.loader&&(await this.subtitleResource.loader.abort(),this.subtitleResource.loader=null)}async stop(){await this.abort(),this.status=0}getDuration(){return this.mediaPlayList.duration}hasVideo(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.video.length)>0}hasAudio(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.audio.length)>0}hasSubtitle(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.subtitle.length)>0}getVideoList(){return this.hasVideo()?{list:this.mediaPlayList.mediaList.video.map((e=>({width:e.width,height:e.height,frameRate:e.frameRate,codecs:e.codecs}))),selectedIndex:this.videoResource.selectedIndex}:{list:[],selectedIndex:0}}getAudioList(){return this.hasAudio()?{list:this.mediaPlayList.mediaList.audio.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.audioResource.selectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.hasSubtitle()?{list:this.mediaPlayList.mediaList.subtitle.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.subtitleResource.selectedIndex}:{list:[],selectedIndex:0}}selectVideo(e){if(e!==this.videoResource.selectedIndex&&this.hasVideo()&&e>=0&&e<this.mediaPlayList.mediaList.video.length){this.videoResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];t.file?this.videoResource.segments=[t.file]:(this.videoResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.videoResource.initSegmentPadding=t.initSegment)}}selectAudio(e){if(e!==this.audioResource.selectedIndex&&this.hasAudio()&&e>=0&&e<this.mediaPlayList.mediaList.audio.length){this.audioResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];t.file?this.audioResource.segments=[t.file]:(this.audioResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.audioResource.initSegmentPadding=t.initSegment)}}selectSubtitle(e){if(e!==this.subtitleResource.selectedIndex&&this.hasSubtitle()&&e>=0&&e<this.mediaPlayList.mediaList.subtitle.length){this.subtitleResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];t.file?this.subtitleResource.segments=[t.file]:(this.subtitleResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.subtitleResource.initSegmentPadding=t.initSegment)}}getMinBuffer(){return this.minBuffer}}},78417:(e,t,i)=>{i.d(t,{A:()=>g});var s=i(88032),a=i.n(s),n=i(29967),d=i.n(n),o=i(79331),r=i(67672),l=i(62100),m=i(86932);function u(e){let t=0,i=0,s=0;return(e=e.slice(e.indexOf("PT")+2)).indexOf("H")>-1&&e.indexOf("M")>-1&&e.indexOf("S")>-1?(t=a()(e.slice(0,e.indexOf("H"))),i=a()(e.slice(e.indexOf("H")+1,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")>0&&e.indexOf("S")>-1?(i=a()(e.slice(0,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")<0&&e.indexOf("S")>-1&&(s=a()(e.slice(0,e.indexOf("S")))),3600*t+60*i+s}function h(e,t){return(Array(t).join("0")+e).slice(-t)}function c(e){if(!e)return 0;if(e.indexOf("/")>-1){const t=e.split("/");return a()(t[0])/a()(t[1])}return a()(e)}function g(e,t){const i={source:e,mediaList:{audio:[],video:[],subtitle:[]},type:"live",isEnd:!1,duration:0,minBufferTime:0,maxSegmentDuration:0,minimumUpdatePeriod:0,timestamp:(0,m.A)()},s=[],n=(g=e,g?(0,o.A)(g,{aloneValueName:"value"}):null).MPD;var g;"static"===n.type&&(i.type="vod",i.isEnd=!0),n.minBufferTime&&(i.minBufferTime=u(n.minBufferTime)),n.maxSegmentDuration&&(i.maxSegmentDuration=u(n.maxSegmentDuration)),n.minimumUpdatePeriod&&(i.minimumUpdatePeriod=u(n.minimumUpdatePeriod)),n.mediaPresentationDuration&&(i.duration=u(n.mediaPresentationDuration));let f="";n.BaseURL&&(f=r.Yj(n.BaseURL)?n.BaseURL:n.BaseURL.value);const p=r.YO(n.Period)?n.Period[0]:n.Period;return!i.duration&&p&&p.duration&&(i.duration=u(p.duration)),(r.YO(p.AdaptationSet)?p.AdaptationSet:[p.AdaptationSet]).forEach(((e,n)=>{let o="video/mp4",m="video",u="avc1.64001E",g=640,p=360,L=640,y=360,S=25,R="1:1",P="1",v=588633,b=f,x="und";e.BaseURL&&(b+=e.BaseURL),e.lang&&(x=e.lang),e.mimeType||e.contentType?(o=e.mimeType,m=e.contentType,"video/mp4"===o||"video"===m?(u=e.codecs,g=a()(e.width),p=a()(e.height),e.maxWidth&&(L=a()(e.maxWidth)),e.maxHeight&&(y=a()(e.maxHeight)),e.frameRate&&(S=c(e.frameRate)),R=e.sar,P=e.startWithSAP,v=a()(e.bandwidth)):"audio/mp4"!==o&&"audio"!==m||(u=e.codecs,P=e.startWithSAP,v=a()(e.bandwidth))):(e.maxWidth&&(L=a()(e.maxWidth)),e.maxHeight&&(y=a()(e.maxHeight)),e.frameRate&&(S=c(e.frameRate))),(r.YO(e.Representation)?e.Representation:[e.Representation]).forEach(((n,c)=>{s.indexOf(n.id)>-1&&(n.id=(d()(s[s.length-1])+1).toString()),s.push(n.id);let f="";const w=[];let A=0,I=0,T=t.slice(0,t.lastIndexOf("/")+1)+b;n.mimeType&&(o=n.mimeType),"video/mp4"===o||"video"===m?(n.codecs&&(u=n.codecs),n.width&&(g=a()(n.width)),n.height&&(p=a()(n.height)),n.maxWidth&&(L=a()(n.maxWidth)),n.maxHeight&&(y=a()(n.maxHeight)),n.frameRate&&(S=a()(n.frameRate)),n.sar&&(R=n.sar),n.startWithSAP&&(P=n.startWithSAP),n.bandwidth&&(v=a()(n.bandwidth))):(n.codecs&&(u=n.codecs),n.startWithSAP&&(P=n.startWithSAP),n.bandwidth&&(v=a()(n.bandwidth))),n.BaseURL&&(T+=r.Yj(n.BaseURL)?n.BaseURL:n.BaseURL.value);let O=!1;if((e.ContentProtection||n.ContentProtection)&&(O=!0),n.SegmentBase)"video/mp4"===o||"video"===m?i.mediaList.video.push({id:n.id,file:T,mimeType:o,codecs:u,width:g,height:p,maxWidth:L,maxHeight:y,frameRate:S,sar:R,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O}):"audio/mp4"===o||"audio"===m?i.mediaList.audio.push({id:n.id,file:T,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x}):"application/mp4"!==o&&"text"!==m||i.mediaList.subtitle.push({id:n.id,file:T,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x});else{let t;if(e.SegmentTemplate&&(t=r.YO(e.SegmentTemplate)?e.SegmentTemplate[0]:e.SegmentTemplate),n.SegmentTemplate&&(t=r.YO(n.SegmentTemplate)?n.SegmentTemplate[0]:n.SegmentTemplate),t){const e=d()(t.startNumber);if(f=t.initialization,A=a()(t.timescale||"1"),t.duration&&!t.SegmentTimeline){I=a()(t.duration);let s=I/A;const d=e+Math.ceil((i.duration||s)/s)-1;for(let a=e;a<=d;a++){const o=s*(a-e);let r=s*(a-e+1);a===d&&(s=i.duration-s*(d-e),r=i.duration),w.push({idx:a,start:o,end:r,url:T+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(a,+i):(0,l.A)(a))),segmentDuration:s})}}else if(t.SegmentTimeline&&t.SegmentTimeline.S){const i=r.YO(t.SegmentTimeline.S)?t.SegmentTimeline.S:[t.SegmentTimeline.S];let s=0,o=e;for(let e=0;e<i.length;e++){let r=a()(i[e].d);i[e].t&&(s=a()(i[0].t));let m=1;i[e].r&&(m=d()(i[e].r)+1);for(let e=0;e<m;e++)w.push({idx:o,start:s/A,end:(s+r)/A,url:T+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(o,+i):(0,l.A)(o))).replace(/\$Time\$/g,(0,l.A)(s)),segmentDuration:r/A}),o++,s+=r}}}else if(n.SegmentList){const e=r.YO(n.SegmentList.SegmentURL)?n.SegmentList.SegmentURL:[n.SegmentList.SegmentURL];let t=0,i=a()(n.SegmentList.duration);for(let s=0;s<e.length;s++)w.push({idx:s,start:t/A,end:(t+i)/A,url:T+e[s].media,segmentDuration:i/A}),t+=i}"video/mp4"===o||"video"===m?i.mediaList.video.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,width:g,height:p,maxWidth:L,maxHeight:y,frameRate:S,sar:R,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O}):"audio/mp4"===o||"audio"===m?i.mediaList.audio.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x}):"application/mp4"!==o&&"text"!==m||i.mediaList.subtitle.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x})}}))})),["video","audio"].forEach((e=>{i.mediaList[e].sort(((e,t)=>e.bandwidth-t.bandwidth))})),i}},79331:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(68632),a=i.n(s),n=i(72739);const d={aloneValueName:"_@attribute"},o=[" ","/",'"',"'","<",">"];function r(e,t=d){e=(e=(e=(e=e.replace(/<!--[\s\S]*?-->/g,"")).replace(/[\n\t\r]/g,"")).replace(/>[ \t]+</g,"><")).replace(/<\?[^>]*\?>/g,"");const i=[];let s=0;function r(e,s){const n=i[i.length-1];n&&(e===t.aloneValueName||null==n.obj[t.aloneValueName]?null==n.obj[e]?n.obj[e]=s:a()(n.obj[e])?n.obj[e].push(s):n.obj[e]=[n.obj[e],s]:n.obj[t.aloneValueName]=[n.obj[t.aloneValueName],{tagName:e,...s}])}function l(t){for(;s<e.length;){if(e[s]===t)return!0;s++}return!1}function m(){u();let t="";for(;s<e.length&&!n.zy(o,e[s]);)t+=e[s],s++;return t}function u(){for(;s<e.length&&/\s|\r|\n/.test(e[s]);)s++}const h=/\s/,c=/'/,g=/"/;function f(){if(s>=e.length)return!0;u();let t=h;'"'!==e[s]&&"'"!=e[s]||(t='"'===e[s]?g:c,s++);let i="";for(;s<e.length;){if(t.test(e[s])){s++;break}i+=e[s],s++}return i}function p(){u();let t="";for(;s<e.length&&"<"!==e[s];)t+=e[s],s++;return t}function L(){for(;"<"===e[s];){const t=s;if(s++,u(),"/"!==e[s]){s=t;break}if(s++,m()===i[i.length-1].tag){if(i.length>1){const e=i.pop();r(e.tag,e.obj)}l(">"),s++,u()}else i.pop(),l(">"),s++,u()}}return function a(){if(s>=e.length)return;let n=s;if(u(),"<"!==e[s])return s=n,r(t.aloneValueName,p()),L(),a();let d=l("<");if(!d)return;n=s,s++;const o=m();if(i.push({obj:{},tag:o,start:n}),function(){for(;u(),">"!==e[s]&&"/"!==e[s];){let e=m();if(!e)break;"="===e[e.length-1]?e=e.substring(0,e.length-1):(l("="),s++),r(e,f())}}(),u(),"/"===e[s]){if(s++,i.length>1){const e=i.pop();r(e.tag,e.obj)}return l(">"),s++,L(),a()}d=l(">"),d&&(s++,u(),"<"!==e[s]&&(r(t.aloneValueName,p()),u()),L(),a())}(),{[i[0].tag]:i[0].obj}}}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[611],{85947:(t,e,i)=>{i.d(e,{A:()=>s});var n=i(134);class s{constructor(){(0,n.A)(this,"type",-1),(0,n.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},85611:(t,e,i)=>{i.r(e),i.d(e,{default:()=>m});var n=i(134),s=i(50932),r=i(4624),a=i(9705),o=i(85947),h=i(14686),u=i(37837),d=i(71517),c=i(72739),f=i(50011),l=i(54825);const g="src/avformat/formats/IWebVttFormat.ts";class m extends o.A{constructor(){super(),(0,n.A)(this,"type",18),(0,n.A)(this,"queue",void 0),(0,n.A)(this,"index",void 0)}init(t){this.queue=[]}async readChunk(t){let e="";const i=t.ioReader.getPos();for(;;){const i=await t.ioReader.readLine();if(""===i)break;e+=i+"\n"}return{chunk:e.trim(),pos:i}}async readHeader(t){const e=await t.ioReader.peekBuffer(3);if(239===e[0]&&187===e[1]&&191===e[2]&&await t.ioReader.skip(3),"WEBVTT"!==await t.ioReader.peekString(6))return r.z3("the file format is not vtt",g,90),a.LR;const i=t.createStream();i.codecpar.codecId=94226,i.codecpar.codecType=3,i.timeBase.den=1e3,i.timeBase.num=1;const n=await t.ioReader.readLine();n.indexOf("-")>0&&(i.metadata.title=n.split("-").pop().trim()),this.index=0;const s=[];let o=BigInt(0);try{for(;;){const{chunk:e,pos:n}=await this.readChunk(t);if(""===e||/^NOTE/.test(e))continue;/^STYLE/.test(e)&&s.push({style:e.replace(/STYLE[\s|\n]?/,""),pos:n});const r=e.split("\n");let a,h;-1===r[0].indexOf("--\x3e")&&(a=r.shift().trim());let u=r.shift().split("--\x3e");const d=(0,l.j)(u.shift());u=u.shift().trim().split(" ");const f=(0,l.j)(u.shift());if(f<=d)continue;u=u.filter((t=>""!==t)),u.length&&(h=u.join(" "));const g=r.join("\n").trim();if(!g)continue;i.nbFrames++,i.duration=f;const m={identifier:a,options:h,context:g,startTs:d,endTs:f,pos:n};d>=o?(this.queue.push(m),o=d):c._(this.queue,m,(t=>t.startTs<m.startTs?1:-1))}}catch(t){return i.metadata.styles=s,0}}async readAVPacket(t,e){if(!this.queue.length)return a.LR;if(this.index>=this.queue.length)return-1048576;const i=t.streams.find((t=>3===t.codecpar.codecType)),n=this.queue[this.index++];if(s.M[15](e+32,i.index),s.M[15](e+76,i.timeBase.den),s.M[15](e+72,i.timeBase.num),s.M[17](e+16,n.startTs),s.M[17](e+8,n.startTs),s.M[17](e+48,n.endTs-n.startTs),n.identifier){const t=f.encode(n.identifier),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,16,i,t.length)}if(n.options){const t=f.encode(n.options),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,17,i,t.length)}const r=f.encode(n.context),o=(0,u.sY)(r.length);return(0,h.lW)(o,r.length,r),(0,d.NX)(e,o,r.length),0}async seek(t,e,i,n){if(2&n)return BigInt(a.E$);if(i<=BigInt(0))return this.index=0,BigInt(0);const s=c.El(this.queue,(t=>t.startTs>i?-1:1));if(s>=0){for(r.Yz(`seek in cues, found index: ${s}, pts: ${this.queue[s].startTs}, pos: ${this.queue[s].pos}`,g,257),this.index=Math.max(s-1,0);this.index>0&&(this.queue[this.index-1].startTs===this.queue[this.index].startTs||this.queue[this.index-1].endTs>i);)this.index--;return BigInt(0)}return BigInt(a.LR)}getAnalyzeStreamsCount(){return 1}}},54825:(t,e,i)=>{function n(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}function s(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}i.d(e,{j:()=>n,t:()=>s})}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[611],{85947:(t,e,i)=>{i.d(e,{A:()=>n});var s=i(134);class n{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},85611:(t,e,i)=>{i.r(e),i.d(e,{default:()=>p});var s=i(134),n=i(50932),r=i(4624),a=i(9705),o=i(85947),h=i(14686),u=i(37837),c=i(71517),d=i(72739),f=i(50011),l=i(54825);const g="src/avformat/formats/IWebVttFormat.ts";class p extends o.A{constructor(){super(),(0,s.A)(this,"type",18),(0,s.A)(this,"queue",void 0),(0,s.A)(this,"index",void 0)}init(t){this.queue=[]}async readChunk(t){let e="";const i=t.ioReader.getPos();for(;;){const i=await t.ioReader.readLine();if(""===i)break;e+=i+"\n"}return{chunk:e.trim(),pos:i}}async readHeader(t){const e=await t.ioReader.peekBuffer(3);if(239===e[0]&&187===e[1]&&191===e[2]&&await t.ioReader.skip(3),"WEBVTT"!==await t.ioReader.peekString(6))return r.z3("the file format is not vtt",g,90),a.LR;const i=t.createStream();i.codecpar.codecId=94226,i.codecpar.codecType=3,i.timeBase.den=1e3,i.timeBase.num=1;const s=await t.ioReader.readLine();s.indexOf("-")>0&&(i.metadata.title=s.split("-").pop().trim()),this.index=0;const n=[];let o=BigInt(0);try{for(;;){const{chunk:e,pos:s}=await this.readChunk(t);if(""===e||/^NOTE/.test(e))continue;/^STYLE/.test(e)&&n.push({style:e.replace(/STYLE[\s|\n]?/,""),pos:s});const r=e.split("\n");let a,h;-1===r[0].indexOf("--\x3e")&&(a=r.shift().trim());let u=r.shift().split("--\x3e");const c=(0,l.j)(u.shift());u=u.shift().trim().split(" ");const f=(0,l.j)(u.shift());if(f<=c)continue;u=u.filter((t=>""!==t)),u.length&&(h=u.join(" "));const g=r.join("\n").trim();if(!g)continue;i.nbFrames++,i.duration=f;const p={identifier:a,options:h,context:g,startTs:c,endTs:f,pos:s};c>=o?(this.queue.push(p),o=c):d._(this.queue,p,(t=>t.startTs<p.startTs?1:-1))}}catch(t){return i.metadata.styles=n,0}}async readAVPacket(t,e){if(!this.queue.length)return a.LR;if(this.index>=this.queue.length)return-1048576;const i=t.streams.find((t=>3===t.codecpar.codecType)),s=this.queue[this.index++];if(n.M[15](e+32,i.index),n.M[15](e+76,i.timeBase.den),n.M[15](e+72,i.timeBase.num),n.M[17](e+16,s.startTs),n.M[17](e+8,s.startTs),n.M[17](e+48,s.endTs-s.startTs),s.identifier){const t=f.encode(s.identifier),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,c.Ow)(e,16,i,t.length)}if(s.options){const t=f.encode(s.options),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,c.Ow)(e,17,i,t.length)}const r=f.encode(s.context),o=(0,u.sY)(r.length);return(0,h.lW)(o,r.length,r),(0,c.NX)(e,o,r.length),0}async seek(t,e,i,s){if(2&s)return BigInt(a.E$);if(i<=BigInt(0))return this.index=0,BigInt(0);const n=d.El(this.queue,(t=>t.startTs>i?-1:1));if(n>=0){for(r.Yz(`seek in cues, found index: ${n}, pts: ${this.queue[n].startTs}, pos: ${this.queue[n].pos}`,g,257),this.index=Math.max(n-1,0);this.index>0&&(this.queue[this.index-1].startTs===this.queue[this.index].startTs||this.queue[this.index-1].endTs>i);)this.index--;return BigInt(0)}return BigInt(a.LR)}getAnalyzeStreamsCount(){return 1}}},54825:(t,e,i)=>{function s(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}function n(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}i.d(e,{j:()=>s,t:()=>n})}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[634],{85947:(e,t,r)=>{r.d(t,{A:()=>i});var a=r(134);class i{constructor(){(0,a.A)(this,"type",-1),(0,a.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},16634:(e,t,r)=>{r.r(t),r.d(t,{IVFHeader:()=>f,default:()=>A});var a=r(134),i=r(63939),d=r(50932),o=r(4624),s=r(9705),h=r(85947),n=r(14686),c=r(37837),m=r(71517),u=r(77231);const R="src/avformat/formats/IIvfFormat.ts",w={VP80:139,VP90:167};class f{constructor(){(0,a.A)(this,"version",void 0),(0,a.A)(this,"length",void 0),(0,a.A)(this,"codec",void 0),(0,a.A)(this,"width",void 0),(0,a.A)(this,"height",void 0),(0,a.A)(this,"denominator",void 0),(0,a.A)(this,"numerator",void 0),(0,a.A)(this,"framesCount",void 0),this.version=0,this.length=32,this.codec="VP80",this.width=0,this.height=0,this.framesCount=0,this.denominator=1,this.numerator=0}}class A extends h.A{constructor(){super(),(0,a.A)(this,"type",5),(0,a.A)(this,"header",void 0),this.header=new f}init(e){e.ioReader&&e.ioReader.setEndian(!1)}async readHeader(e){try{if("DKIF"!==await e.ioReader.readString(4))return o.z3("the file format is not ivf",R,104),s.LR;this.header.version=await e.ioReader.readUint16(),await e.ioReader.skip(2),this.header.codec=await e.ioReader.readString(4),this.header.width=await e.ioReader.readUint16(),this.header.height=await e.ioReader.readUint16(),this.header.denominator=await e.ioReader.readUint32(),this.header.numerator=await e.ioReader.readUint32(),this.header.framesCount=await e.ioReader.readUint32(),await e.ioReader.skip(4);const t=e.createStream();return t.codecpar.codecType=0,t.codecpar.codecId=w[this.header.codec],t.timeBase.den=this.header.denominator,t.timeBase.num=this.header.numerator,t.codecpar.width=this.header.width,t.codecpar.height=this.header.height,t.nbFrames=BigInt(Math.floor(this.header.framesCount)),this.onStreamAdd&&this.onStreamAdd(t),0}catch(t){return o.z3(t.message,R,136),e.ioReader.error}}async readAVPacket(e,t){try{const r=e.getStreamByMediaType(0);if(!r)return s.LR;{const a=e.ioReader.getPos(),o=await e.ioReader.readUint32(),s=await e.ioReader.readUint64(),h=(0,c.sY)(o);(0,m.NX)(t,h,o),await e.ioReader.readBuffer(o,(0,n.JW)(h,o)),d.M[17](t+56,a),d.M[17](t+8,s),d.M[17](t+16,s),d.M[15](t+76,this.header.denominator),d.M[15](t+72,this.header.numerator),d.M[15](t+32,r.index),r.startTime===u.Dh&&(r.startTime=i.f[17](t+8)||i.f[17](t+16))}return 0}catch(t){return-1048576!==e.ioReader.error?(o.z3(`read packet error, ${t}`,R,173),s.LR):e.ioReader.error}}async seek(e,t,r,a){return BigInt(s.E$)}getAnalyzeStreamsCount(){return 1}}}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[634],{85947:(e,t,r)=>{r.d(t,{A:()=>i});var a=r(134);class i{constructor(){(0,a.A)(this,"type",-1),(0,a.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},16634:(e,t,r)=>{r.r(t),r.d(t,{IVFHeader:()=>A,default:()=>f});var a=r(134),i=r(63939),d=r(50932),o=r(4624),s=r(9705),h=r(85947),n=r(14686),c=r(37837),m=r(71517),u=r(77231);const R="src/avformat/formats/IIvfFormat.ts",w={VP80:139,VP90:167};class A{constructor(){(0,a.A)(this,"version",void 0),(0,a.A)(this,"length",void 0),(0,a.A)(this,"codec",void 0),(0,a.A)(this,"width",void 0),(0,a.A)(this,"height",void 0),(0,a.A)(this,"denominator",void 0),(0,a.A)(this,"numerator",void 0),(0,a.A)(this,"framesCount",void 0),this.version=0,this.length=32,this.codec="VP80",this.width=0,this.height=0,this.framesCount=0,this.denominator=1,this.numerator=0}}class f extends h.A{constructor(){super(),(0,a.A)(this,"type",5),(0,a.A)(this,"header",void 0),this.header=new A}init(e){e.ioReader&&e.ioReader.setEndian(!1)}async readHeader(e){try{if("DKIF"!==await e.ioReader.readString(4))return o.z3("the file format is not ivf",R,104),s.LR;this.header.version=await e.ioReader.readUint16(),await e.ioReader.skip(2),this.header.codec=await e.ioReader.readString(4),this.header.width=await e.ioReader.readUint16(),this.header.height=await e.ioReader.readUint16(),this.header.denominator=await e.ioReader.readUint32(),this.header.numerator=await e.ioReader.readUint32(),this.header.framesCount=await e.ioReader.readUint32(),await e.ioReader.skip(4);const t=e.createStream();return t.codecpar.codecType=0,t.codecpar.codecId=w[this.header.codec],t.timeBase.den=this.header.denominator,t.timeBase.num=this.header.numerator,t.codecpar.width=this.header.width,t.codecpar.height=this.header.height,t.nbFrames=BigInt(Math.floor(this.header.framesCount)),this.onStreamAdd&&this.onStreamAdd(t),0}catch(t){return o.z3(t.message,R,136),e.ioReader.error}}async readAVPacket(e,t){try{const r=e.getStreamByMediaType(0);if(!r)return s.LR;{const a=e.ioReader.getPos(),o=await e.ioReader.readUint32(),s=await e.ioReader.readUint64(),h=(0,c.sY)(o);(0,m.NX)(t,h,o),await e.ioReader.readBuffer(o,(0,n.JW)(h,o)),d.M[17](t+56,a),d.M[17](t+8,s),d.M[17](t+16,s),d.M[15](t+76,this.header.denominator),d.M[15](t+72,this.header.numerator),d.M[15](t+32,r.index),r.startTime===u.Dh&&(r.startTime=i.f[17](t+8)||i.f[17](t+16))}return 0}catch(t){return-1048576!==e.ioReader.error?(o.z3(`read packet error, ${t}`,R,173),s.LR):e.ioReader.error}}async seek(e,t,r,a){return BigInt(s.E$)}getAnalyzeStreamsCount(){return 1}}}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[70],{85947:(t,e,i)=>{i.d(e,{A:()=>s});var n=i(134);class s{constructor(){(0,n.A)(this,"type",-1),(0,n.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},78070:(t,e,i)=>{i.r(e),i.d(e,{default:()=>l});var n=i(134),s=i(50932),r=i(4624),u=i(9705),a=i(85947),h=i(14686),c=i(37837),d=i(71517),o=i(72739),f=i(50011),g=i(54825);class l extends a.A{constructor(){super(),(0,n.A)(this,"type",19),(0,n.A)(this,"queue",void 0),(0,n.A)(this,"index",void 0)}init(t){this.queue=[]}async readChunk(t){let e="";const i=t.ioReader.getPos();for(;;){const i=await t.ioReader.readLine();if(""===i)break;e+=i+"\n"}return{chunk:e.trim(),pos:i}}async readHeader(t){const e=t.createStream();e.codecpar.codecId=94225,e.codecpar.codecType=3,e.timeBase.den=1e3,e.timeBase.num=1,this.index=0;let i=BigInt(0);try{for(;;){const{chunk:n,pos:s}=await this.readChunk(t);if(""===n)continue;const r=n.split("\n");let u=r.shift().trim(),a=r.shift().split(/--?>/);const h=(0,g.t)(a[0]),c=(0,g.t)(a[1]);if(c<=h)continue;const d=r.join("\n").trim();if(!d)continue;e.nbFrames++,e.duration=c;const f={identifier:u,context:d,startTs:h,endTs:c,pos:s};h>=i?(this.queue.push(f),i=h):o._(this.queue,f,(t=>t.startTs<f.startTs?1:-1))}}catch(t){return 0}}async readAVPacket(t,e){if(!this.queue.length)return u.LR;if(this.index>=this.queue.length)return-1048576;const i=t.streams.find((t=>3===t.codecpar.codecType)),n=this.queue[this.index++];if(s.M[15](e+32,i.index),s.M[15](e+76,i.timeBase.den),s.M[15](e+72,i.timeBase.num),s.M[17](e+16,n.startTs),s.M[17](e+8,n.startTs),s.M[17](e+48,n.endTs-n.startTs),n.identifier){const t=f.encode(n.identifier),i=(0,c.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,16,i,t.length)}const r=f.encode(n.context),a=(0,c.sY)(r.length);return(0,h.lW)(a,r.length,r),(0,d.NX)(e,a,r.length),0}async seek(t,e,i,n){if(2&n)return BigInt(u.E$);if(i<=BigInt(0))return this.index=0,BigInt(0);const s=o.El(this.queue,(t=>t.startTs>i?-1:1));if(s>=0){for(r.Yz(`seek in cues, found index: ${s}, pts: ${this.queue[s].startTs}, pos: ${this.queue[s].pos}`,"src/avformat/formats/ISubRipFormat.ts",201),this.index=Math.max(s-1,0);this.index>0&&(this.queue[this.index-1].startTs===this.queue[this.index].startTs||this.queue[this.index-1].endTs>i);)this.index--;return BigInt(0)}return BigInt(u.LR)}getAnalyzeStreamsCount(){return 1}}},54825:(t,e,i)=>{function n(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}function s(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}i.d(e,{j:()=>n,t:()=>s})}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[70],{85947:(t,e,i)=>{i.d(e,{A:()=>s});var n=i(134);class s{constructor(){(0,n.A)(this,"type",-1),(0,n.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},78070:(t,e,i)=>{i.r(e),i.d(e,{default:()=>l});var n=i(134),s=i(50932),r=i(4624),u=i(9705),a=i(85947),h=i(14686),c=i(37837),o=i(71517),d=i(72739),f=i(50011),g=i(54825);class l extends a.A{constructor(){super(),(0,n.A)(this,"type",19),(0,n.A)(this,"queue",void 0),(0,n.A)(this,"index",void 0)}init(t){this.queue=[]}async readChunk(t){let e="";const i=t.ioReader.getPos();for(;;){const i=await t.ioReader.readLine();if(""===i)break;e+=i+"\n"}return{chunk:e.trim(),pos:i}}async readHeader(t){const e=t.createStream();e.codecpar.codecId=94225,e.codecpar.codecType=3,e.timeBase.den=1e3,e.timeBase.num=1,this.index=0;let i=BigInt(0);try{for(;;){const{chunk:n,pos:s}=await this.readChunk(t);if(""===n)continue;const r=n.split("\n");let u=r.shift().trim(),a=r.shift().split(/--?>/);const h=(0,g.t)(a[0]),c=(0,g.t)(a[1]);if(c<=h)continue;const o=r.join("\n").trim();if(!o)continue;e.nbFrames++,e.duration=c;const f={identifier:u,context:o,startTs:h,endTs:c,pos:s};h>=i?(this.queue.push(f),i=h):d._(this.queue,f,(t=>t.startTs<f.startTs?1:-1))}}catch(t){return 0}}async readAVPacket(t,e){if(!this.queue.length)return u.LR;if(this.index>=this.queue.length)return-1048576;const i=t.streams.find((t=>3===t.codecpar.codecType)),n=this.queue[this.index++];if(s.M[15](e+32,i.index),s.M[15](e+76,i.timeBase.den),s.M[15](e+72,i.timeBase.num),s.M[17](e+16,n.startTs),s.M[17](e+8,n.startTs),s.M[17](e+48,n.endTs-n.startTs),n.identifier){const t=f.encode(n.identifier),i=(0,c.sY)(t.length);(0,h.lW)(i,t.length,t),(0,o.Ow)(e,16,i,t.length)}const r=f.encode(n.context),a=(0,c.sY)(r.length);return(0,h.lW)(a,r.length,r),(0,o.NX)(e,a,r.length),0}async seek(t,e,i,n){if(2&n)return BigInt(u.E$);if(i<=BigInt(0))return this.index=0,BigInt(0);const s=d.El(this.queue,(t=>t.startTs>i?-1:1));if(s>=0){for(r.Yz(`seek in cues, found index: ${s}, pts: ${this.queue[s].startTs}, pos: ${this.queue[s].pos}`,"src/avformat/formats/ISubRipFormat.ts",201),this.index=Math.max(s-1,0);this.index>0&&(this.queue[this.index-1].startTs===this.queue[this.index].startTs||this.queue[this.index-1].endTs>i);)this.index--;return BigInt(0)}return BigInt(u.LR)}getAnalyzeStreamsCount(){return 1}}},54825:(t,e,i)=>{function n(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}function s(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),i+=BigInt(+e.shift().trim())*BigInt(1e3),i+=BigInt(+e.shift().trim()),i}i.d(e,{j:()=>n,t:()=>s})}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[791],{85947:(e,a,t)=>{t.d(a,{A:()=>s});var r=t(134);class s{constructor(){(0,r.A)(this,"type",-1),(0,r.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},3791:(e,a,t)=>{t.r(a),t.d(a,{default:()=>l});var r=t(134),s=t(61499),i=t(50932),c=t(4624),n=t(9705),o=t(85947),d=t(14686),A=t(37837),u=t(71517),f=t(35531),M=t(95644);const h="src/avformat/formats/IWavFormat.ts";class l extends o.A{constructor(){super(),(0,r.A)(this,"type",16),(0,r.A)(this,"dataSize",void 0),(0,r.A)(this,"sampleCount",void 0),(0,r.A)(this,"pcmStartPos",void 0),(0,r.A)(this,"currentPts",void 0)}init(e){e.ioReader.setEndian(!1)}async readHeader(e){const a=await e.ioReader.readString(4);switch(a){case"RIFF":case"RF64":case"BW64":break;case"RIFX":e.ioReader.setEndian(!0);break;default:return c.z3("the file format is not wav",h,73),n.LR}await e.ioReader.skip(4);const t=await e.ioReader.readString(4);if("WAVE"!==t)return c.z3(`invalid start code ${t} in RIFF header`,h,83),n.LR;if("RF64"===a||"BW64"===a){if("ds64"!==await e.ioReader.readString(4))return n.LR;const a=await e.ioReader.readUint32();if(a<24)return n.LR;if(await e.ioReader.skip(8),this.dataSize=await e.ioReader.readUint64(),this.sampleCount=await e.ioReader.readUint64(),this.dataSize<0||this.sampleCount<0)return c.z3("negative data_size and/or sample_count in ds64",h,103),n.LR;await e.ioReader.skip(a-24)}const r=e.createStream(),i=await e.ioReader.fileSize();for(;e.ioReader.getPos()<i;){const a=await e.ioReader.readString(4),t=await e.ioReader.readUint32();if("fmt "===a){let a=await(0,f.y)(e.ioReader,r.codecpar[s.o9],t);if(a<0)return a}else if("data"===a){if(this.pcmStartPos=e.ioReader.getPos(),this.dataSize||(this.dataSize=BigInt(Math.floor(t))),this.pcmStartPos+this.dataSize===i)break;await e.ioReader.seek(this.pcmStartPos+this.dataSize)}else{if(this.pcmStartPos+this.dataSize===i)break;await e.ioReader.seek(e.ioReader.getPos()+BigInt(Math.floor(t)))}}return this.sampleCount||(this.sampleCount=(this.dataSize<<BigInt(3))/BigInt(r.codecpar.chLayout.nbChannels*(0,M.MZ)(r.codecpar.codecId))),r.timeBase.den=r.codecpar.sampleRate,r.timeBase.num=1,this.sampleCount&&(r.duration=this.sampleCount),this.currentPts=BigInt(0),await e.ioReader.seek(this.pcmStartPos),0}async readAVPacket(e,a){const t=e.streams.find((e=>e.codecpar.codecType=1));try{const r=1024*t.codecpar.chLayout.nbChannels*(0,M.MZ)(t.codecpar.codecId)>>>3,s=(0,A.sY)(r);return(0,u.NX)(a,s,r),i.M[17](a+16,this.currentPts),i.M[17](a+8,this.currentPts),i.M[17](a+56,e.ioReader.getPos()),await e.ioReader.readBuffer(r,(0,d.JW)(s,r)),i.M[15](a+32,t.index),i.M[15](a+76,t.timeBase.den),i.M[15](a+72,t.timeBase.num),this.currentPts+=BigInt(1024),0}catch(a){return-1048576!==e.ioReader.error?(c.z3(`read packet error, ${a}`,h,191),n.LR):e.ioReader.error}}async seek(e,a,t,r){const s=e.ioReader.getPos();if(2&r){const i=await e.ioReader.fileSize();return i<=BigInt(0)?BigInt(n.E$):(t<BigInt(0)?t=BigInt(0):t>i&&(t=i),await e.ioReader.seek(t),4&r||(this.currentPts=(t-this.pcmStartPos<<BigInt(3))/BigInt(a.codecpar.chLayout.nbChannels*(0,M.MZ)(a.codecpar.codecId))),s)}{const r=this.pcmStartPos+(t*BigInt(a.codecpar.chLayout.nbChannels*(0,M.MZ)(a.codecpar.codecId))>>BigInt(3));return await e.ioReader.seek(r),this.currentPts=t,s}}getAnalyzeStreamsCount(){return 1}}},35531:(e,a,t)=>{t.d(a,{y:()=>M});var r=t(63939),s=t(50932),i=t(4624),c=t(9705),n=t(53260),o=t(95644),d=t(37837),A=t(14686),u=t(39381);const f="src/avformat/formats/riff/iriff.ts";async function M(e,a,t){if(t<14)return i.z3("wav format size < 14",f,36),c.LR;s.M[15](a,1);const M=await e.readUint16();let h=await e.readUint16();const l=await e.readUint32();let R=8*await e.readUint32();const m=await e.readUint16();if(s.M[15](a+136,l),s.M[15](a+140,m),14===t?s.M[15](a+40,8):s.M[15](a+40,await e.readUint16()),65534===M?s.M[8](a+8,0):(s.M[8](a+8,M),s.M[15](a+4,function(e,a){let t=n.g[e];return t?(65541===t?t=(0,o.uU)(a,!1,!1,-2):65557===t&&(t=(0,o.uU)(a,!0,!1,0)),69633===t&&8===a&&(t=69676),t):0}(M,r.f[15](a+40)))),t>=18&&357!==M){let i=await e.readUint16();t-=18,i=Math.min(t,i),i>=22&&65534===M&&(await e.skip(22),i-=22,t-=22),i>0&&(s.M[20](a+12,(0,d.sY)(i)),s.M[15](a+16,i),await e.readBuffer(i,(0,A.JW)(r.f[20](a+12),i)),t-=i),t>0&&await e.skip(t)}else if(357===M&&t>=32){t-=4,s.M[20](a+12,(0,d.sY)(t)),s.M[15](a+16,t),await e.readBuffer(t,(0,A.JW)(r.f[20](a+12),t));const i=u.E3(r.f[20](a+12)+4);if(s.M[15](a+136,u.Y0(r.f[20](a+12)+12)),h=0,R=0,t<8+20*i)return c.LR;for(let e=0;e<i;e++)h+=r.f[2](r.f[20](a+12)+(8+20*e+17))}return s.M[17](a+32,BigInt(R)),r.f[15](a+136)<0?(i.z3(`Invalid sample rate: ${r.f[15](a+136)}`,f,116),c.LR):(86065===r.f[15](a+4)&&(h=0,s.M[15](a+136,0)),69643==r.f[15](a+4)&&r.f[15](a+136)&&s.M[15](a+40,Number(BigInt.asIntN(32,r.f[17](a+32)))/r.f[15](a+136)),h!=r.f[15](a+116)&&(s.M[15](a+112,0),s.M[15](a+116,h)),0)}},53260:(e,a,t)=>{t.d(a,{g:()=>s,n:()=>i});var r=t(79682);const s={1:65541,2:69638,3:65557,6:65543,7:65542,10:86052,16:69664,17:69633,23:69664,32:69646,34:86037,49:86046,50:86046,56:73728,66:86068,69:69643,20:69643,64:69643,97:69635,98:69634,100:69643,105:69633,117:86079,131:86069,255:86018,273:86068,5632:86018,5634:86065,8192:86019},i={[(0,r.A)("H264")]:27,[(0,r.A)("h264")]:27,[(0,r.A)("X264")]:27,[(0,r.A)("x264")]:27,[(0,r.A)("avc1")]:27,[(0,r.A)("DAVC")]:27,[(0,r.A)("SMV2")]:27,[(0,r.A)("VSSH")]:27,[(0,r.A)("Q264")]:27,[(0,r.A)("V264")]:27,[(0,r.A)("GAVC")]:27,[(0,r.A)("UMSV")]:27,[(0,r.A)("tshd")]:27,[(0,r.A)("INMC")]:27,[(0,r.A)("FMP4")]:12,[(0,r.A)("DIVX")]:12,[(0,r.A)("DX50")]:12,[(0,r.A)("XVID")]:12,[(0,r.A)("MP4S")]:12,[(0,r.A)("M4S2")]:12,[(0,r.A)("DIVX")]:12,4:12,[(0,r.A)("ZMP4")]:12,[(0,r.A)("DIV1")]:12,[(0,r.A)("BLZ0")]:12,[(0,r.A)("mp4v")]:12,[(0,r.A)("UMP4")]:12,[(0,r.A)("WV1F")]:12,[(0,r.A)("SEDG")]:12,[(0,r.A)("RMP4")]:12,[(0,r.A)("3IV2")]:12,[(0,r.A)("WAWV")]:12,[(0,r.A)("FFDS")]:12,[(0,r.A)("FVFW")]:12,[(0,r.A)("DCOD")]:12,[(0,r.A)("MVXM")]:12,[(0,r.A)("PM4V")]:12,[(0,r.A)("SMP4")]:12,[(0,r.A)("DXGM")]:12,[(0,r.A)("VIDM")]:12,[(0,r.A)("M4T3")]:12,[(0,r.A)("GEOX")]:12,[(0,r.A)("G264")]:12,[(0,r.A)("HDX4")]:12,[(0,r.A)("DM4V")]:12,[(0,r.A)("DMK2")]:12,[(0,r.A)("DYM4")]:12,[(0,r.A)("DIGI")]:12,[(0,r.A)("EPHV")]:12,[(0,r.A)("EM4A")]:12,[(0,r.A)("M4CC")]:12,[(0,r.A)("SN40")]:12,[(0,r.A)("VSPX")]:12,[(0,r.A)("ULDX")]:12,[(0,r.A)("GEOV")]:12,[(0,r.A)("SIPP")]:12,[(0,r.A)("SM4V")]:12,[(0,r.A)("XVIX")]:12,[(0,r.A)("DreX")]:12,[(0,r.A)("QMP4")]:12,[(0,r.A)("PLV1")]:12,[(0,r.A)("GLV4")]:12,[(0,r.A)("GMP4")]:12,[(0,r.A)("MNM4")]:12,[(0,r.A)("GTM4")]:12,[(0,r.A)("MPG4")]:14,[(0,r.A)("MP41")]:14,[(0,r.A)("MP42")]:15,[(0,r.A)("DIV2")]:15,[(0,r.A)("MP43")]:16,[(0,r.A)("DIV3")]:16,[(0,r.A)("MPG3")]:16,[(0,r.A)("DIV5")]:16,[(0,r.A)("DIV6")]:16,[(0,r.A)("DIV4")]:16,[(0,r.A)("DVX3")]:16,[(0,r.A)("AP41")]:16,[(0,r.A)("COL1")]:16,[(0,r.A)("COL0")]:16,[(0,r.A)("VP80")]:139,[(0,r.A)("VP90")]:167}},79682:(e,a,t)=>{t.d(a,{A:()=>i});var r=t(4624);const s="src/avformat/function/mktagle.ts";function i(e){4!==e.length&&r.R8(`tag length is not 4, tag: ${e}`,s,30);let a=0;for(let t=3;t>=0;t--)a=a<<8|e.charCodeAt(t);return a}},95644:(e,a,t)=>{function r(e,a,t,r){if(e<=0||e>64)return 0;if(a)switch(e){case 32:return t?65556:65557;case 64:return t?65558:65559;default:return 0}else if(e+=7,r&1<<(e>>>=3)-1)switch(e){case 1:return 65540;case 2:return t?65537:65536;case 3:return t?65549:65548;case 4:return t?65545:65544;case 8:return t?65568:65567;default:return 0}else switch(e){case 1:return 65541;case 2:return t?65539:65538;case 3:return t?65551:65550;case 4:return t?65547:65546;default:return 0}}function s(e){switch(e){case 69649:return 2;case 69648:return 3;case 69647:case 69633:case 69632:case 69645:case 69638:return 4;default:return function(e){switch(e){case 86070:case 86071:case 69674:case 69644:case 69678:case 69651:case 69661:case 69677:case 69655:case 69664:case 69636:case 69675:case 69660:case 69646:case 69670:return 4;case 86089:case 86090:case 86091:case 86092:case 65543:case 65542:case 65571:case 65540:case 65563:case 65572:case 65541:case 81924:case 81926:return 8;case 65537:case 65566:case 65536:case 65554:case 65539:case 65538:return 16;case 65552:case 65549:case 65548:case 65564:case 65551:case 65550:return 24;case 65545:case 65544:case 65565:case 65547:case 65546:case 65556:case 65557:case 65570:case 65569:return 32;case 65558:case 65559:case 65568:case 65567:return 64;default:return 0}}(e)}}t.d(a,{MZ:()=>s,uU:()=>r})}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[791],{85947:(e,a,t)=>{t.d(a,{A:()=>s});var r=t(134);class s{constructor(){(0,r.A)(this,"type",-1),(0,r.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},3791:(e,a,t)=>{t.r(a),t.d(a,{default:()=>l});var r=t(134),s=t(61499),i=t(50932),c=t(4624),n=t(9705),o=t(85947),d=t(14686),A=t(37837),u=t(71517),f=t(35531),M=t(95644);const h="src/avformat/formats/IWavFormat.ts";class l extends o.A{constructor(){super(),(0,r.A)(this,"type",16),(0,r.A)(this,"dataSize",void 0),(0,r.A)(this,"sampleCount",void 0),(0,r.A)(this,"pcmStartPos",void 0),(0,r.A)(this,"currentPts",void 0)}init(e){e.ioReader.setEndian(!1)}async readHeader(e){const a=await e.ioReader.readString(4);switch(a){case"RIFF":case"RF64":case"BW64":break;case"RIFX":e.ioReader.setEndian(!0);break;default:return c.z3("the file format is not wav",h,73),n.LR}await e.ioReader.skip(4);const t=await e.ioReader.readString(4);if("WAVE"!==t)return c.z3(`invalid start code ${t} in RIFF header`,h,83),n.LR;if("RF64"===a||"BW64"===a){if("ds64"!==await e.ioReader.readString(4))return n.LR;const a=await e.ioReader.readUint32();if(a<24)return n.LR;if(await e.ioReader.skip(8),this.dataSize=await e.ioReader.readUint64(),this.sampleCount=await e.ioReader.readUint64(),this.dataSize<0||this.sampleCount<0)return c.z3("negative data_size and/or sample_count in ds64",h,103),n.LR;await e.ioReader.skip(a-24)}const r=e.createStream(),i=await e.ioReader.fileSize();for(;e.ioReader.getPos()<i;){const a=await e.ioReader.readString(4),t=await e.ioReader.readUint32();if("fmt "===a){let a=await(0,f.y)(e.ioReader,r.codecpar[s.o9],t);if(a<0)return a}else if("data"===a){if(this.pcmStartPos=e.ioReader.getPos(),this.dataSize||(this.dataSize=BigInt(Math.floor(t))),this.pcmStartPos+this.dataSize===i)break;await e.ioReader.seek(this.pcmStartPos+this.dataSize)}else{if(this.pcmStartPos+this.dataSize===i)break;await e.ioReader.seek(e.ioReader.getPos()+BigInt(Math.floor(t)))}}return this.sampleCount||(this.sampleCount=(this.dataSize<<BigInt(3))/BigInt(r.codecpar.chLayout.nbChannels*(0,M.MZ)(r.codecpar.codecId))),r.timeBase.den=r.codecpar.sampleRate,r.timeBase.num=1,this.sampleCount&&(r.duration=this.sampleCount),this.currentPts=BigInt(0),await e.ioReader.seek(this.pcmStartPos),0}async readAVPacket(e,a){const t=e.streams.find((e=>e.codecpar.codecType=1));try{const r=1024*t.codecpar.chLayout.nbChannels*(0,M.MZ)(t.codecpar.codecId)>>>3,s=(0,A.sY)(r);return(0,u.NX)(a,s,r),i.M[17](a+16,this.currentPts),i.M[17](a+8,this.currentPts),i.M[17](a+56,e.ioReader.getPos()),await e.ioReader.readBuffer(r,(0,d.JW)(s,r)),i.M[15](a+32,t.index),i.M[15](a+76,t.timeBase.den),i.M[15](a+72,t.timeBase.num),this.currentPts+=BigInt(1024),0}catch(a){return-1048576!==e.ioReader.error?(c.z3(`read packet error, ${a}`,h,191),n.LR):e.ioReader.error}}async seek(e,a,t,r){const s=e.ioReader.getPos();if(2&r){const i=await e.ioReader.fileSize();return i<=BigInt(0)?BigInt(n.E$):(t<BigInt(0)?t=BigInt(0):t>i&&(t=i),await e.ioReader.seek(t),4&r||(this.currentPts=(t-this.pcmStartPos<<BigInt(3))/BigInt(a.codecpar.chLayout.nbChannels*(0,M.MZ)(a.codecpar.codecId))),s)}{const r=this.pcmStartPos+(t*BigInt(a.codecpar.chLayout.nbChannels*(0,M.MZ)(a.codecpar.codecId))>>BigInt(3));return await e.ioReader.seek(r),this.currentPts=t,s}}getAnalyzeStreamsCount(){return 1}}},35531:(e,a,t)=>{t.d(a,{y:()=>M});var r=t(63939),s=t(50932),i=t(4624),c=t(9705),n=t(53260),o=t(95644),d=t(37837),A=t(14686),u=t(39381);const f="src/avformat/formats/riff/iriff.ts";async function M(e,a,t){if(t<14)return i.z3("wav format size < 14",f,36),c.LR;s.M[15](a,1);const M=await e.readUint16();let h=await e.readUint16();const l=await e.readUint32();let R=8*await e.readUint32();const P=await e.readUint16();if(s.M[15](a+136,l),s.M[15](a+140,P),14===t?s.M[15](a+40,8):s.M[15](a+40,await e.readUint16()),65534===M?s.M[8](a+8,0):(s.M[8](a+8,M),s.M[15](a+4,function(e,a){let t=n.g[e];return t?(65541===t?t=(0,o.uU)(a,!1,!1,-2):65557===t&&(t=(0,o.uU)(a,!0,!1,0)),69633===t&&8===a&&(t=69676),t):0}(M,r.f[15](a+40)))),t>=18&&357!==M){let i=await e.readUint16();t-=18,i=Math.min(t,i),i>=22&&65534===M&&(await e.skip(22),i-=22,t-=22),i>0&&(s.M[20](a+12,(0,d.sY)(i)),s.M[15](a+16,i),await e.readBuffer(i,(0,A.JW)(r.f[20](a+12),i)),t-=i),t>0&&await e.skip(t)}else if(357===M&&t>=32){t-=4,s.M[20](a+12,(0,d.sY)(t)),s.M[15](a+16,t),await e.readBuffer(t,(0,A.JW)(r.f[20](a+12),t));const i=u.E3(r.f[20](a+12)+4);if(s.M[15](a+136,u.Y0(r.f[20](a+12)+12)),h=0,R=0,t<8+20*i)return c.LR;for(let e=0;e<i;e++)h+=r.f[2](r.f[20](a+12)+(8+20*e+17))}return s.M[17](a+32,BigInt(R)),r.f[15](a+136)<0?(i.z3(`Invalid sample rate: ${r.f[15](a+136)}`,f,116),c.LR):(86065===r.f[15](a+4)&&(h=0,s.M[15](a+136,0)),69643==r.f[15](a+4)&&r.f[15](a+136)&&s.M[15](a+40,Number(BigInt.asIntN(32,r.f[17](a+32)))/r.f[15](a+136)),h!=r.f[15](a+116)&&(s.M[15](a+112,0),s.M[15](a+116,h)),0)}},53260:(e,a,t)=>{t.d(a,{g:()=>s,n:()=>i});var r=t(79682);const s={1:65541,2:69638,3:65557,6:65543,7:65542,10:86052,16:69664,17:69633,23:69664,32:69646,34:86037,49:86046,50:86046,56:73728,66:86068,69:69643,20:69643,64:69643,97:69635,98:69634,100:69643,105:69633,117:86079,131:86069,255:86018,273:86068,5632:86018,5634:86065,8192:86019},i={[(0,r.A)("H264")]:27,[(0,r.A)("h264")]:27,[(0,r.A)("X264")]:27,[(0,r.A)("x264")]:27,[(0,r.A)("avc1")]:27,[(0,r.A)("DAVC")]:27,[(0,r.A)("SMV2")]:27,[(0,r.A)("VSSH")]:27,[(0,r.A)("Q264")]:27,[(0,r.A)("V264")]:27,[(0,r.A)("GAVC")]:27,[(0,r.A)("UMSV")]:27,[(0,r.A)("tshd")]:27,[(0,r.A)("INMC")]:27,[(0,r.A)("FMP4")]:12,[(0,r.A)("DIVX")]:12,[(0,r.A)("DX50")]:12,[(0,r.A)("XVID")]:12,[(0,r.A)("MP4S")]:12,[(0,r.A)("M4S2")]:12,[(0,r.A)("DIVX")]:12,4:12,[(0,r.A)("ZMP4")]:12,[(0,r.A)("DIV1")]:12,[(0,r.A)("BLZ0")]:12,[(0,r.A)("mp4v")]:12,[(0,r.A)("UMP4")]:12,[(0,r.A)("WV1F")]:12,[(0,r.A)("SEDG")]:12,[(0,r.A)("RMP4")]:12,[(0,r.A)("3IV2")]:12,[(0,r.A)("WAWV")]:12,[(0,r.A)("FFDS")]:12,[(0,r.A)("FVFW")]:12,[(0,r.A)("DCOD")]:12,[(0,r.A)("MVXM")]:12,[(0,r.A)("PM4V")]:12,[(0,r.A)("SMP4")]:12,[(0,r.A)("DXGM")]:12,[(0,r.A)("VIDM")]:12,[(0,r.A)("M4T3")]:12,[(0,r.A)("GEOX")]:12,[(0,r.A)("G264")]:12,[(0,r.A)("HDX4")]:12,[(0,r.A)("DM4V")]:12,[(0,r.A)("DMK2")]:12,[(0,r.A)("DYM4")]:12,[(0,r.A)("DIGI")]:12,[(0,r.A)("EPHV")]:12,[(0,r.A)("EM4A")]:12,[(0,r.A)("M4CC")]:12,[(0,r.A)("SN40")]:12,[(0,r.A)("VSPX")]:12,[(0,r.A)("ULDX")]:12,[(0,r.A)("GEOV")]:12,[(0,r.A)("SIPP")]:12,[(0,r.A)("SM4V")]:12,[(0,r.A)("XVIX")]:12,[(0,r.A)("DreX")]:12,[(0,r.A)("QMP4")]:12,[(0,r.A)("PLV1")]:12,[(0,r.A)("GLV4")]:12,[(0,r.A)("GMP4")]:12,[(0,r.A)("MNM4")]:12,[(0,r.A)("GTM4")]:12,[(0,r.A)("MPG4")]:14,[(0,r.A)("MP41")]:14,[(0,r.A)("MP42")]:15,[(0,r.A)("DIV2")]:15,[(0,r.A)("MP43")]:16,[(0,r.A)("DIV3")]:16,[(0,r.A)("MPG3")]:16,[(0,r.A)("DIV5")]:16,[(0,r.A)("DIV6")]:16,[(0,r.A)("DIV4")]:16,[(0,r.A)("DVX3")]:16,[(0,r.A)("AP41")]:16,[(0,r.A)("COL1")]:16,[(0,r.A)("COL0")]:16,[(0,r.A)("VP80")]:139,[(0,r.A)("VP90")]:167}},79682:(e,a,t)=>{t.d(a,{A:()=>i});var r=t(4624);const s="src/avformat/function/mktagle.ts";function i(e){4!==e.length&&r.R8(`tag length is not 4, tag: ${e}`,s,30);let a=0;for(let t=3;t>=0;t--)a=a<<8|e.charCodeAt(t);return a}},95644:(e,a,t)=>{function r(e,a,t,r){if(e<=0||e>64)return 0;if(a)switch(e){case 32:return t?65556:65557;case 64:return t?65558:65559;default:return 0}else if(e+=7,r&1<<(e>>>=3)-1)switch(e){case 1:return 65540;case 2:return t?65537:65536;case 3:return t?65549:65548;case 4:return t?65545:65544;case 8:return t?65568:65567;default:return 0}else switch(e){case 1:return 65541;case 2:return t?65539:65538;case 3:return t?65551:65550;case 4:return t?65547:65546;default:return 0}}function s(e){switch(e){case 69649:return 2;case 69648:return 3;case 69647:case 69633:case 69632:case 69645:case 69638:return 4;default:return function(e){switch(e){case 86070:case 86071:case 69674:case 69644:case 69678:case 69651:case 69661:case 69677:case 69655:case 69664:case 69636:case 69675:case 69660:case 69646:case 69670:return 4;case 86089:case 86090:case 86091:case 86092:case 65543:case 65542:case 65571:case 65540:case 65563:case 65572:case 65541:case 81924:case 81926:return 8;case 65537:case 65566:case 65536:case 65554:case 65539:case 65538:return 16;case 65552:case 65549:case 65548:case 65564:case 65551:case 65550:return 24;case 65545:case 65544:case 65565:case 65547:case 65546:case 65556:case 65557:case 65570:case 65569:return 32;case 65558:case 65559:case 65568:case 65567:return 64;default:return 0}}(e)}}t.d(a,{MZ:()=>s,uU:()=>r})}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[808],{85947:(t,e,s)=>{s.d(e,{A:()=>h});var i=s(134);class h{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},95808:(t,e,s)=>{s.r(e),s.d(e,{default:()=>m});var i=s(134),h=s(63939),r=s(50932),a=s(9705),n=s(85947),u=s(14686),o=s(37837),d=s(71517),c=s(95335),p=s(92647),l=s(59166),f=s(77231),b=s(37246),g=s(23991),y=s(37805);const A={framerate:{num:30,den:1}};class m extends n.A{constructor(t={}){super(),(0,i.A)(this,"type",12),(0,i.A)(this,"options",void 0),(0,i.A)(this,"currentDts",void 0),(0,i.A)(this,"currentPts",void 0),(0,i.A)(this,"step",void 0),(0,i.A)(this,"slices",void 0),(0,i.A)(this,"naluPos",void 0),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"bitReader",void 0),(0,i.A)(this,"sliceType",void 0),(0,i.A)(this,"naluType",void 0),(0,i.A)(this,"poc",void 0),(0,i.A)(this,"pocTid0",void 0),(0,i.A)(this,"sps",void 0),(0,i.A)(this,"naluReader",void 0),this.options=c.X$({},A,t)}init(t){t.ioReader&&t.ioReader.setEndian(!1),this.slices=[],this.queue=[],this.bitReader=new b.A(500),this.naluReader=new y.A}async destroy(t){if(this.queue.length){for(let t=0;t<this.queue.length;t++)(0,d.Qe)(this.queue[t].avpacket);this.queue.length=0}}isFrameNalu(t){return(t[1===t[2]?4:5]>>>3&31)<12}async readNaluFrame(t){let e=!1;const s=this.slices;for(this.slices=[],s.length&&(e=this.isFrameNalu(s[0]));;){const i=await this.naluReader.read(t.ioReader);if(!i)return s;const h=i[1===i[2]?4:5]>>>3&31;if(this.isFrameNalu(i))if(e){if(i[1===i[2]?5:6]>>>7)return this.slices.push(i),s;s.push(i)}else s.push(i),e=!0;else{if(e&&(20===h||19===h||15===h||14===h||16===h||12===h||13===h))return this.slices.push(i),s;s.push(i)}}}async readHeader(t){const e=t.createStream();for(e.codecpar.codecType=0,e.codecpar.codecId=196,e.timeBase.den=f.SF,e.timeBase.num=1,e.codecpar.bitFormat=2,this.currentDts=BigInt(0),this.currentPts=BigInt(0),this.naluPos=BigInt(0),this.poc=0,this.pocTid0=0,this.step=BigInt(Math.floor(f.SF/this.options.framerate.num*this.options.framerate.den));;){const s=await this.readNaluFrame(t);if(!s.length)return-1048576;const i=(0,p.A)(Uint8Array,s),a=l.sL(i);if(a){e.codecpar.extradata=(0,o.sY)(a.length),(0,u.lW)(e.codecpar.extradata,a.length,a),e.codecpar.extradataSize=a.length,l.XC(e,a);const n=s.find((t=>15==(t[1===t[2]?4:5]>>>3&31)));this.sps=l.wf(n);const c=(0,d._5)(),p=(0,o.sY)(i.length);(0,u.lW)(p,i.length,i),(0,d.NX)(c,p,i.length),r.M[17](c+56,this.naluPos),this.naluPos+=BigInt(Math.floor(i.length)),r.M[17](c+16,this.currentDts),this.currentDts+=this.step,r.M[17](c+8,this.currentPts),this.currentPts+=this.step,r.M[15](c+32,e.index),r.M[15](c+36,1|h.f[15](c+36)),r.M[15](c+72,e.timeBase.num),r.M[15](c+76,e.timeBase.den),r.M[15](c+80,2),t.interval.packetBuffer.push(c);break}this.naluPos+=BigInt(Math.floor(i.length))}return 0}computePoc(t,e,s,i){this.bitReader.reset(),this.bitReader.appendBuffer(s.subarray(0,500)),i&&this.bitReader.readU1();const h=this.bitReader.readU1(),r=this.bitReader.readU1();let a=0;h&&(a=this.bitReader.readU1()),this.bitReader.readU1()&&this.bitReader.readU1(),g.xb(this.bitReader);const n=this.bitReader.readU(this.sps.sps_log2_max_pic_order_cnt_lsb_minus4+4);a&&g.xb(this.bitReader);for(let t=0;t<8*this.sps.sps_num_extra_ph_bytes;t++)this.sps.sps_extra_ph_bit_present_flag[t]&&this.bitReader.readU1();let u=0,o=0;this.sps.sps_poc_msb_cycle_flag&&(o=this.bitReader.readU1(),o&&(u=this.bitReader.readU(this.sps.sps_poc_msb_cycle_len_minus1+1)));const d=1<<this.sps.sps_log2_max_pic_order_cnt_lsb_minus4+4;let c=0;if(8===t||7===t)c=o?u*d:0;else{const t=this.pocTid0,e=t&d-1,s=t-e;c=o?u*d:n<e&&e-n>=d/2?s+d:n>e&&n-e>d/2?s-d:s}this.poc=c+n,0!=e||r||2===t||3===t||(this.pocTid0=this.poc)}async readAVPacket_(t,e){const s=t.getStreamByMediaType(0),i=await this.readNaluFrame(t);if(!i.length)return-1048576;this.sliceType=-1;let a=!1,n=!0;i.forEach((t=>{const e=1===t[2]?t[4]:t[5],s=e>>>3&31,i=(7&e)-1;15===s&&(this.sps=l.wf(t)),8!==s&&7!==s||(a=!0),19===s&&this.computePoc(s,i,t.subarray(1===t[2]?5:6),!1),s<14&&n&&(n=!1,this.naluType=s,t[1===t[2]?5:6]>>>7&&this.computePoc(s,i,t.subarray(1===t[2]?5:6),!0))}));const c=(0,p.A)(Uint8Array,i),f=(0,o.sY)(c.length);return(0,u.lW)(f,c.length,c),(0,d.NX)(e,f,c.length),r.M[17](e+56,this.naluPos),this.naluPos+=BigInt(Math.floor(c.length)),r.M[17](e+16,this.currentDts),this.currentDts+=this.step,r.M[15](e+32,s.index),r.M[15](e+72,s.timeBase.num),r.M[15](e+76,s.timeBase.den),r.M[15](e+80,2),a&&r.M[15](e+36,1|h.f[15](e+36)),0}async readAVPacket(t,e){let s=this.queue.length;const i=()=>{this.queue.length>1&&this.queue.sort(((t,e)=>t.poc-e.poc>0?1:-1));for(let t=0;t<this.queue.length;t++)r.M[17](this.queue[t].avpacket+8,this.currentPts),this.currentPts+=this.step;this.queue.length>1&&this.queue.sort(((t,e)=>h.f[17](t.avpacket+16)-h.f[17](e.avpacket+16)>BigInt(0)?1:-1)),this.queue.length&&((0,d.rN)(e,this.queue[0].avpacket),(0,d.Qe)(this.queue[0].avpacket));for(let e=1;e<this.queue.length;e++)t.interval.packetBuffer.push(this.queue[e].avpacket);this.queue.length=0};for(;;){const e=(0,d._5)();let r=await this.readAVPacket_(t,e);if(r<0)return(0,d.Qe)(e),this.queue.length?(i(),0):r;if(1&h.f[15](e+36)||9===this.naluType||1===this.sliceType||2===this.sliceType){if(1===s||(9===this.naluType||1&h.f[15](e+36))&&this.queue.length)return i(),this.queue.push({avpacket:e,poc:this.poc}),0;this.queue.push({avpacket:e,poc:this.poc}),s++}else this.queue.push({avpacket:e,poc:this.poc})}}async seek(t,e,s,i){return BigInt(a.E$)}getAnalyzeStreamsCount(){return 1}}},37805:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(134),h=s(60264),r=s(92647);class a{constructor(){(0,i.A)(this,"buffer",void 0),(0,i.A)(this,"pos",void 0),(0,i.A)(this,"end",void 0),(0,i.A)(this,"ended",void 0),this.buffer=new Uint8Array(102400),this.pos=0,this.end=0,this.ended=!1}async read(t){if(this.ended&&this.pos>=this.end)return;const e=[];if(this.pos<this.end-4){let t=h.Ky(this.buffer.subarray(this.pos,this.end-4),3);if(t.offset>-1){const e=this.buffer.slice(this.pos,this.pos+t.offset);return this.pos+=t.offset,e}e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}for(;;){if(!this.ended&&this.end<this.buffer.length)try{const e=await t.readToBuffer(this.buffer.length-this.end,this.buffer.subarray(this.end));this.end+=e}catch(t){if(this.ended=!0,this.pos>=this.end)return e.length?(0,r.A)(Uint8Array,e):null}let s=h.Ky(this.buffer.subarray(this.pos,this.end-4),e.length?0:3);if(s.offset>-1)return e.push(this.buffer.slice(this.pos,this.pos+s.offset)),this.pos+=s.offset,(0,r.A)(Uint8Array,e);if(this.ended)return e.push(this.buffer.slice(this.pos,this.end)),this.pos=this.end=0,(0,r.A)(Uint8Array,e);e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}}reset(){this.pos=0,this.end=0,this.ended=!1}}}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[808],{85947:(t,e,s)=>{s.d(e,{A:()=>h});var i=s(134);class h{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},95808:(t,e,s)=>{s.r(e),s.d(e,{default:()=>m});var i=s(134),h=s(63939),r=s(50932),a=s(9705),n=s(85947),u=s(14686),o=s(37837),c=s(71517),d=s(95335),p=s(92647),l=s(59166),f=s(77231),b=s(37246),g=s(23991),y=s(37805);const A={framerate:{num:30,den:1}};class m extends n.A{constructor(t={}){super(),(0,i.A)(this,"type",12),(0,i.A)(this,"options",void 0),(0,i.A)(this,"currentDts",void 0),(0,i.A)(this,"currentPts",void 0),(0,i.A)(this,"step",void 0),(0,i.A)(this,"slices",void 0),(0,i.A)(this,"naluPos",void 0),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"bitReader",void 0),(0,i.A)(this,"sliceType",void 0),(0,i.A)(this,"naluType",void 0),(0,i.A)(this,"poc",void 0),(0,i.A)(this,"pocTid0",void 0),(0,i.A)(this,"sps",void 0),(0,i.A)(this,"naluReader",void 0),this.options=d.X$({},A,t)}init(t){t.ioReader&&t.ioReader.setEndian(!1),this.slices=[],this.queue=[],this.bitReader=new b.A(500),this.naluReader=new y.A}async destroy(t){if(this.queue.length){for(let t=0;t<this.queue.length;t++)(0,c.Qe)(this.queue[t].avpacket);this.queue.length=0}}isFrameNalu(t){return(t[1===t[2]?4:5]>>>3&31)<12}async readNaluFrame(t){let e=!1;const s=this.slices;for(this.slices=[],s.length&&(e=this.isFrameNalu(s[0]));;){const i=await this.naluReader.read(t.ioReader);if(!i)return s;const h=i[1===i[2]?4:5]>>>3&31;if(this.isFrameNalu(i))if(e){if(i[1===i[2]?5:6]>>>7)return this.slices.push(i),s;s.push(i)}else s.push(i),e=!0;else{if(e&&(20===h||19===h||15===h||14===h||16===h||12===h||13===h))return this.slices.push(i),s;s.push(i)}}}async readHeader(t){const e=t.createStream();for(e.codecpar.codecType=0,e.codecpar.codecId=196,e.timeBase.den=f.SF,e.timeBase.num=1,e.codecpar.bitFormat=2,this.currentDts=BigInt(0),this.currentPts=BigInt(0),this.naluPos=BigInt(0),this.poc=0,this.pocTid0=0,this.step=BigInt(Math.floor(f.SF/this.options.framerate.num*this.options.framerate.den));;){const s=await this.readNaluFrame(t);if(!s.length)return-1048576;const i=(0,p.A)(Uint8Array,s),a=l.sL(i);if(a){e.codecpar.extradata=(0,o.sY)(a.length),(0,u.lW)(e.codecpar.extradata,a.length,a),e.codecpar.extradataSize=a.length,l.XC(e,a);const n=s.find((t=>15==(t[1===t[2]?4:5]>>>3&31)));this.sps=l.wf(n);const d=(0,c._5)(),p=(0,o.sY)(i.length);(0,u.lW)(p,i.length,i),(0,c.NX)(d,p,i.length),r.M[17](d+56,this.naluPos),this.naluPos+=BigInt(Math.floor(i.length)),r.M[17](d+16,this.currentDts),this.currentDts+=this.step,r.M[17](d+8,this.currentPts),this.currentPts+=this.step,r.M[15](d+32,e.index),r.M[15](d+36,1|h.f[15](d+36)),r.M[15](d+72,e.timeBase.num),r.M[15](d+76,e.timeBase.den),r.M[15](d+80,2),t.interval.packetBuffer.push(d);break}this.naluPos+=BigInt(Math.floor(i.length))}return 0}computePoc(t,e,s,i){this.bitReader.reset(),this.bitReader.appendBuffer(s.subarray(0,500)),i&&this.bitReader.readU1();const h=this.bitReader.readU1(),r=this.bitReader.readU1();let a=0;h&&(a=this.bitReader.readU1()),this.bitReader.readU1()&&this.bitReader.readU1(),g.xb(this.bitReader);const n=this.bitReader.readU(this.sps.sps_log2_max_pic_order_cnt_lsb_minus4+4);a&&g.xb(this.bitReader);for(let t=0;t<8*this.sps.sps_num_extra_ph_bytes;t++)this.sps.sps_extra_ph_bit_present_flag[t]&&this.bitReader.readU1();let u=0,o=0;this.sps.sps_poc_msb_cycle_flag&&(o=this.bitReader.readU1(),o&&(u=this.bitReader.readU(this.sps.sps_poc_msb_cycle_len_minus1+1)));const c=1<<this.sps.sps_log2_max_pic_order_cnt_lsb_minus4+4;let d=0;if(8===t||7===t)d=o?u*c:0;else{const t=this.pocTid0,e=t&c-1,s=t-e;d=o?u*c:n<e&&e-n>=c/2?s+c:n>e&&n-e>c/2?s-c:s}this.poc=d+n,0!=e||r||2===t||3===t||(this.pocTid0=this.poc)}async readAVPacket_(t,e){const s=t.getStreamByMediaType(0),i=await this.readNaluFrame(t);if(!i.length)return-1048576;this.sliceType=-1;let a=!1,n=!0;i.forEach((t=>{const e=1===t[2]?t[4]:t[5],s=e>>>3&31,i=(7&e)-1;15===s&&(this.sps=l.wf(t)),8!==s&&7!==s||(a=!0),19===s&&this.computePoc(s,i,t.subarray(1===t[2]?5:6),!1),s<14&&n&&(n=!1,this.naluType=s,t[1===t[2]?5:6]>>>7&&this.computePoc(s,i,t.subarray(1===t[2]?5:6),!0))}));const d=(0,p.A)(Uint8Array,i),f=(0,o.sY)(d.length);return(0,u.lW)(f,d.length,d),(0,c.NX)(e,f,d.length),r.M[17](e+56,this.naluPos),this.naluPos+=BigInt(Math.floor(d.length)),r.M[17](e+16,this.currentDts),this.currentDts+=this.step,r.M[15](e+32,s.index),r.M[15](e+72,s.timeBase.num),r.M[15](e+76,s.timeBase.den),r.M[15](e+80,2),a&&r.M[15](e+36,1|h.f[15](e+36)),0}async readAVPacket(t,e){let s=this.queue.length;const i=()=>{this.queue.length>1&&this.queue.sort(((t,e)=>t.poc-e.poc>0?1:-1));for(let t=0;t<this.queue.length;t++)r.M[17](this.queue[t].avpacket+8,this.currentPts),this.currentPts+=this.step;this.queue.length>1&&this.queue.sort(((t,e)=>h.f[17](t.avpacket+16)-h.f[17](e.avpacket+16)>BigInt(0)?1:-1)),this.queue.length&&((0,c.rN)(e,this.queue[0].avpacket),(0,c.Qe)(this.queue[0].avpacket));for(let e=1;e<this.queue.length;e++)t.interval.packetBuffer.push(this.queue[e].avpacket);this.queue.length=0};for(;;){const e=(0,c._5)();let r=await this.readAVPacket_(t,e);if(r<0)return(0,c.Qe)(e),this.queue.length?(i(),0):r;if(1&h.f[15](e+36)||9===this.naluType||1===this.sliceType||2===this.sliceType){if(1===s||(9===this.naluType||1&h.f[15](e+36))&&this.queue.length)return i(),this.queue.push({avpacket:e,poc:this.poc}),0;this.queue.push({avpacket:e,poc:this.poc}),s++}else this.queue.push({avpacket:e,poc:this.poc})}}async seek(t,e,s,i){return BigInt(a.E$)}getAnalyzeStreamsCount(){return 1}}},37805:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(134),h=s(60264),r=s(92647);class a{constructor(){(0,i.A)(this,"buffer",void 0),(0,i.A)(this,"pos",void 0),(0,i.A)(this,"end",void 0),(0,i.A)(this,"ended",void 0),this.buffer=new Uint8Array(102400),this.pos=0,this.end=0,this.ended=!1}async read(t){if(this.ended&&this.pos>=this.end)return;const e=[];if(this.pos<this.end-4){let t=h.Ky(this.buffer.subarray(this.pos,this.end-4),3);if(t.offset>-1){const e=this.buffer.slice(this.pos,this.pos+t.offset);return this.pos+=t.offset,e}e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}for(;;){if(!this.ended&&this.end<this.buffer.length)try{const e=await t.readToBuffer(this.buffer.length-this.end,this.buffer.subarray(this.end));this.end+=e}catch(t){if(this.ended=!0,this.pos>=this.end)return e.length?(0,r.A)(Uint8Array,e):null}let s=h.Ky(this.buffer.subarray(this.pos,this.end-4),e.length?0:3);if(s.offset>-1)return e.push(this.buffer.slice(this.pos,this.pos+s.offset)),this.pos+=s.offset,(0,r.A)(Uint8Array,e);if(this.ended)return e.push(this.buffer.slice(this.pos,this.end)),this.pos=this.end=0,(0,r.A)(Uint8Array,e);e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}}reset(){this.pos=0,this.end=0,this.ended=!1}}}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[839],{85947:(e,a,t)=>{t.d(a,{A:()=>r});var i=t(134);class r{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},6839:(e,a,t)=>{t.r(a),t.d(a,{default:()=>S});var i=t(134),r=t(14686),s=t(61499),o=t(63939),n=t(50932),d=(t(9599),t(4624)),c=t(85947),f=t(37837),m=t(71517),p=t(77231),g=t(50011),l=t(64093),h=t(44328),u=t(31608),R=t(43607),w=t(72739),x=t(19028),k=t(75294),I=t(9705);const B="src/avformat/formats/IMp3Format.ts";class S extends c.A{constructor(){super(),(0,i.A)(this,"type",14),(0,i.A)(this,"context",void 0)}init(e){e.ioReader&&e.ioReader.setEndian(!0),this.context={firstFramePos:p.Dh,isVBR:!1,hasID3v1:!1,id3v2:{version:p.N_,revision:p.N_,flags:p.N_},fileSize:BigInt(0)}}async readHeader(e){const a=e.createStream();a.codecpar.codecId=86017,a.codecpar.codecType=1,a.startTime=BigInt(0),a.firstDTS=BigInt(0);const t={frameHeader:new k.Vz,nbFrame:BigInt(0),tocIndexes:[],nextDTS:BigInt(0),frameLength:0};a.privData=t;const i=a.metadata={},s=await e.ioReader.fileSize();if(1&e.ioReader.flags&&s>u.c1&&(await e.ioReader.seek(s-BigInt(u.c1)),"TAG"===await e.ioReader.readString(3))){let a=await e.ioReader.readBuffer(30);i.title=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(30),i.artist=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(30),i.album=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(4),i.date=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(30),i.comment=g.decode(a).replace(/\s/g,""),0===a[28]&&0!==a[29]&&(i.track=a[29]+""),i.genre=await e.ioReader.readUint8(),this.context.hasID3v1=!0}if(await e.ioReader.seek(BigInt(0)),"ID3"===await e.ioReader.peekString(3)){await e.ioReader.skip(3),this.context.id3v2.version=await e.ioReader.readUint8(),this.context.id3v2.revision=await e.ioReader.readUint8(),this.context.id3v2.flags=await e.ioReader.readUint8();const a=(127&await e.ioReader.readUint8())<<21|(127&await e.ioReader.readUint8())<<14|(127&await e.ioReader.readUint8())<<7|127&await e.ioReader.readUint8();await x.q(e.ioReader,a,this.context.id3v2,i)}for(this.context.firstFramePos=e.ioReader.getPos();65504&~await e.ioReader.peekUint16();)await e.ioReader.skip(1);this.context.firstFramePos!==e.ioReader.getPos()&&(d.R8(`skipping ${e.ioReader.getPos()-this.context.firstFramePos} bytes of junk at ${this.context.firstFramePos}`,B,171),this.context.firstFramePos=e.ioReader.getPos()),a.codecpar.extradataSize=4,a.codecpar.extradata=(0,f.sY)(a.codecpar.extradataSize),await e.ioReader.peekBuffer(a.codecpar.extradataSize,(0,r.JW)(a.codecpar.extradata,a.codecpar.extradataSize)),k.qg(t.frameHeader,await e.ioReader.readUint32()),a.codecpar.profile=l.Au(t.frameHeader.layer),a.codecpar.frameSize=l.hG(t.frameHeader.version,t.frameHeader.layer),a.codecpar.sampleRate=l.Y2(t.frameHeader.version,t.frameHeader.samplingFrequency),a.timeBase.num=1,a.timeBase.den=a.codecpar.sampleRate;const o=3===t.frameHeader.mode?1:2;a.codecpar.chLayout.nbChannels=o;const n=BigInt(Math.floor(l.oz(t.frameHeader.version,t.frameHeader.layer,t.frameHeader.bitrateIndex))),c=k.CM(t.frameHeader,a.codecpar.sampleRate),m=e.ioReader.getPos();await e.ioReader.skip([[0,9,17],[0,0,0],[0,9,17],[0,17,32]][t.frameHeader.version][a.codecpar.chLayout.nbChannels]);const p=await e.ioReader.readString(4);if("Xing"===p||"Info"===p){this.context.isVBR=!0;const r=await e.ioReader.readUint32();1&r&&(t.nbFrame=BigInt(Math.floor(await e.ioReader.readUint32()))),2&r&&(this.context.fileSize=BigInt(Math.floor(await e.ioReader.readUint32())));const o=s>=m?s-m:BigInt(0);if(o&&this.context.fileSize){const e=R.jk(o,this.context.fileSize),a=R.T9(o,this.context.fileSize)-e;o>this.context.fileSize&&a>e>>BigInt(4)?(t.nbFrame=BigInt(0),d.R8("invalid concatenated file detected - using bitrate for duration",B,224)):a>e>>BigInt(4)&&d.R8("filesize and duration do not match (growing file?)",B,227)}if(a.duration=t.nbFrame*BigInt(0|a.codecpar.frameSize),4&r)for(let i=0;i<u.W8;i++){const r=await e.ioReader.readUint8(),s=this.context.fileSize*BigInt(Math.floor(r))/BigInt(256),o={dts:a.duration/BigInt(u.W8)*BigInt(Math.floor(i)),pos:s};t.tocIndexes.push(o)}8&r&&await e.ioReader.skip(4),i.encoder=await e.ioReader.readString(9),this.context.firstFramePos+=BigInt(Math.floor(c))}else await e.ioReader.seek(m),"VBRI"===await e.ioReader.readString(4)?(1===await e.ioReader.readUint16()&&(await e.ioReader.skip(4),this.context.fileSize=BigInt(Math.floor(await e.ioReader.readUint32())),t.nbFrame=BigInt(Math.floor(await e.ioReader.readUint32())),a.duration=t.nbFrame*BigInt(0|a.codecpar.frameSize)),this.context.firstFramePos+=BigInt(Math.floor(c))):(this.context.isVBR=!1,a.codecpar.bitrate=n*BigInt(1e3),t.nbFrame=(s-this.context.firstFramePos-BigInt(u.c1))/BigInt(Math.floor(c)),a.duration=t.nbFrame*BigInt(0|a.codecpar.frameSize),t.frameLength=c,this.context.fileSize=s);for(await e.ioReader.seek(this.context.firstFramePos);65504&~await e.ioReader.peekUint16();)await e.ioReader.skip(1);if(this.context.firstFramePos!==e.ioReader.getPos()&&(d.R8(`skipping ${e.ioReader.getPos()-this.context.firstFramePos} bytes of junk at ${this.context.firstFramePos}`,B,287),this.context.firstFramePos=e.ioReader.getPos()),t.tocIndexes.length)for(let e=0;e<u.W8;e++)t.tocIndexes[e].pos+=this.context.firstFramePos;return 0}async readAVPacket(e,a){const t=e.getStreamByMediaType(1),i=t.privData,c=e.ioReader.getPos();if(this.context.hasID3v1&&c>=this.context.fileSize-BigInt(u.c1))return-1048576;try{k.qg(i.frameHeader,await e.ioReader.peekUint32());let d=this.context.isVBR?k.CM(i.frameHeader,t.codecpar.sampleRate):i.frameLength;n.M[15](a+28,d),n.M[17](a+56,c),n.M[15](a+32,t.index),(0,r.Mr)(a+72,t.timeBase[s.o9],8),n.M[17](a+48,BigInt(0|t.codecpar.frameSize)),n.M[17](a+16,i.nextDTS),n.M[17](a+8,i.nextDTS),n.M[15](a+36,1|o.f[15](a+36)),i.nextDTS+=BigInt(0|t.codecpar.frameSize);const p=(0,f.sY)(d);return(0,m.NX)(a,p,d),await e.ioReader.readBuffer(d,(0,r.JW)(p,d)),0}catch(a){return-1048576!==e.ioReader.error&&d.z3(a.message,B,334),e.ioReader.error}}async syncToFrame(e){let a=p.Dh;const t=e.getStreamByMediaType(1),i=t.privData;for(;;)try{if(!(65504&~await e.ioReader.peekUint16())){a=e.ioReader.getPos(),k.qg(i.frameHeader,await e.ioReader.peekUint32());let r=this.context.isVBR?k.CM(i.frameHeader,t.codecpar.sampleRate):i.frameLength;if(r>512e3){await e.ioReader.skip(1);continue}await e.ioReader.skip(r);let s=0;for(;s<=3&&!(65504&~await e.ioReader.peekUint16());){k.qg(i.frameHeader,await e.ioReader.peekUint32());let a=this.context.isVBR?k.CM(i.frameHeader,t.codecpar.sampleRate):i.frameLength;await e.ioReader.skip(a),s++}if(!(s<3))break;await e.ioReader.seek(a+BigInt(1)),a=p.Dh}await e.ioReader.skip(1)}catch(e){break}a!==p.Dh&&await e.ioReader.seek(a)}async seek(e,a,t,i){const r=e.ioReader.getPos(),s=a.privData;if(2&i){const o=await e.ioReader.fileSize();return o<=BigInt(0)?BigInt(I.E$):(t<BigInt(0)?t=BigInt(0):t>o&&(t=o),await e.ioReader.seek(t),4&i||(await this.syncToFrame(e),a.duration&&o&&(s.nextDTS=t/o*a.duration)),r)}if(a.sampleIndexes.length){let i=w.El(a.sampleIndexes,(e=>e.pts>t?-1:1));if(i>0&&(0,h.k)(t-a.sampleIndexes[i-1].pts,a.timeBase,p.i0)<BigInt(1e4))return d.Yz(`seek in sampleIndexes, found index: ${i}, pts: ${a.sampleIndexes[i-1].pts}, pos: ${a.sampleIndexes[i-1].pos}`,B,442),await e.ioReader.seek(a.sampleIndexes[i-1].pos),s.nextDTS=a.sampleIndexes[i-1].dts,r}if(t===BigInt(0))return await e.ioReader.seek(this.context.firstFramePos),r;if(this.context.isVBR)if(s.tocIndexes.length){const i=s.tocIndexes[Number(BigInt.asIntN(32,t/(a.duration/BigInt(u.W8))))];if(i)d.Yz(`seek in xing toc indexes, pts: ${i.dts}, pos: ${i.pos}`,B,458),await e.ioReader.seek(i.pos),s.nextDTS=i.dts;else{d.Yz("not found any keyframe index, try to seek in bytes",B,463);const i=k.CM(s.frameHeader,a.codecpar.sampleRate),r=t/BigInt(0|a.codecpar.frameSize),o=r*BigInt(Math.floor(i))+this.context.firstFramePos;s.nextDTS=r*BigInt(0|a.codecpar.frameSize),await e.ioReader.seek(o)}}else{d.Yz("not found any keyframe index, try to seek in bytes",B,472);const i=k.CM(s.frameHeader,a.codecpar.sampleRate),r=t/BigInt(0|a.codecpar.frameSize),o=r*BigInt(Math.floor(i))+this.context.firstFramePos;s.nextDTS=r*BigInt(0|a.codecpar.frameSize),await e.ioReader.seek(o)}else{const i=t/BigInt(0|a.codecpar.frameSize),r=i*BigInt(0|s.frameLength)+this.context.firstFramePos;s.nextDTS=i*BigInt(0|a.codecpar.frameSize),await e.ioReader.seek(r)}return await this.syncToFrame(e),r}getAnalyzeStreamsCount(){return 1}}},75294:(e,a,t)=>{t.d(a,{CM:()=>n,Vz:()=>s,qg:()=>o});var i=t(134),r=t(64093);class s{constructor(){(0,i.A)(this,"version",void 0),(0,i.A)(this,"layer",void 0),(0,i.A)(this,"protection",void 0),(0,i.A)(this,"bitrateIndex",void 0),(0,i.A)(this,"samplingFrequency",void 0),(0,i.A)(this,"padding",void 0),(0,i.A)(this,"private",void 0),(0,i.A)(this,"mode",void 0),(0,i.A)(this,"modeExtension",void 0),(0,i.A)(this,"copyright",void 0),(0,i.A)(this,"original",void 0),(0,i.A)(this,"emphasis",void 0)}}function o(e,a){e.version=a>>19&3,e.layer=a>>17&3,e.protection=a>>16&1,e.bitrateIndex=a>>12&15,e.samplingFrequency=a>>10&3,e.padding=a>>9&1,e.mode=a>>6&3,e.modeExtension=a>>4&3,e.copyright=a>>3&1,e.original=a>>2&1,e.emphasis=3&a}function n(e,a){let t=r.oz(e.version,e.layer,e.bitrateIndex);switch(e.layer){case 1:default:t=144e3*t/(a<<(3===e.version?0:1))>>>0,t+=e.padding;break;case 2:t=144e3*t/a>>>0,t+=e.padding;break;case 3:t=12e3*t/a>>>0,t=4*(t+e.padding)}return t}},19028:(e,a,t)=>{t.d(a,{q:()=>o});var i=t(4624);t(50011);const r="src/avformat/formats/mp3/id3v2.ts";function s(e,a){let t="utf-8";return 0===e?t="iso-8859-1":1===e?t="utf-16":2===e&&(t="utf-16be"),new TextDecoder(t).decode(a)}async function o(e,a,t,o){const n=2!==t.version,d=n?10:6;let c=e.getPos()+BigInt(0|a);async function f(){await e.seek(c)}if(n&&64&t.flags){let s=await async function(e,a){let t=0;for(;a--;)t=(t<<7)+(127&await e.readUint8());return t}(e,4);if(4===t.version&&(s-=4),s<0)return i.z3("invalid extended header length",r,88),await f();if(await e.skip(s),(a-=s+4)<0)return i.z3("extended header too long",r,94),await e.seek(c),await f()}for(;a>d;){let t,c;if(n){if(t=await e.readString(4),c=await e.readUint32(),!c){i.z3("invalid frame size",r,108);break}await e.readUint16()}else t=await e.readString(3),c=await e.readUint24();if("APIC"===t)o.poster=await e.readBuffer(c);else if("USLT"===t){const a=await e.readUint8(),t=await e.readString(3),i=await e.readBuffer(c-4);o.lyrics=`${t} ${s(a,i)}`}else if("COMM"===t||"COM"===t){const a=await e.readUint8(),t=await e.readString(3),i=await e.readBuffer(c-4);o.comment=`${t} ${s(a,i)}`}else{let a;switch(a="T"===t[0]?s(await e.readUint8(),await e.readBuffer(c-1)):await e.readBuffer(c),t){case"TIT2":case"TT2":o.title=a;break;case"TPE1":case"TP1":o.artist=a;break;case"TPE2":case"TP2":o.albumArtist=a;break;case"TPOS":o.disc=a;break;case"TCOP":o.copyright=a;break;case"TALB":case"TAL":o.album=a;break;case"TRCK":case"TRK":o.track=a;break;case"TYER":case"TDRL":case"TDRC":o.date=a;break;case"COMM":case"COM":o.comment=a;break;case"TCON":case"TCO":o.genre=a;break;case"TSSE":case"TEN":o.encoder=a;break;case"TCOM":o.composer=a;break;case"TENC":o.vendor=a;break;case"TLAN":o.language=a;break;case"TPE3":case"TP3":o.performer=a;break;case"TPUB":o.publisher=a;break;case"TCMP":case"TCP":o.compilation=a;break;case"TDEN":o.creationTime=a;break;case"TSOA":o.albumSort=a;break;case"TSOP":o.artistSort=a;break;case"TSOT":o.titleSort=a;break;case"TIT1":o.grouping=a;break;default:o[t]=a}}a-=c+d}4==t.version&&16&t.flags&&(c+=BigInt(10)),await e.seek(c)}},31608:(e,a,t)=>{t.d(a,{W8:()=>i,c1:()=>r});const i=100,r=128},64093:(e,a,t)=>{t.d(a,{Au:()=>w,He:()=>x,XC:()=>k,Y2:()=>h,hG:()=>u,oz:()=>R});var i=t(77231);const r=[44100,48e3,32e3,0],s=[22050,24e3,16e3,0],o=[11025,12e3,8e3,0],n=[0,1152,1152,384],d=[0,576,1152,384],c=[0,576,1152,384],f=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],m=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],p=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],g=[0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],l=[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1];function h(e,a){switch(e){case 0:return o[a];case 2:return s[a];case 3:return r[a]}return i.N_}function u(e,a){switch(e){case 0:return c[a];case 2:return d[a];case 3:return n[a]}return i.N_}function R(e,a,t){switch(a){case 1:switch(e){case 0:case 2:return l[t];case 3:return p[t]}break;case 2:switch(e){case 0:case 2:return l[t];case 3:return m[t]}case 3:switch(e){case 0:case 2:return g[t];case 3:return f[t]}}return i.N_}function w(e){switch(e){case 1:return 34;case 2:return 33;case 3:return 32}return i.N_}const x={32:"Layer1",33:"Layer2",34:"Layer3"};function k(e,a){if(a&&a.length>=4){const t=a[1]>>>3&3,i=(6&a[1])>>1,r=(12&a[2])>>>2,s=3&~(a[3]>>>6)?2:1,o=w(i),n=h(t,r);e.codecpar.profile=o,e.codecpar.sampleRate=n,e.codecpar.chLayout.nbChannels=s}}}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[839],{85947:(e,a,t)=>{t.d(a,{A:()=>r});var i=t(134);class r{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},6839:(e,a,t)=>{t.r(a),t.d(a,{default:()=>S});var i=t(134),r=t(14686),s=t(61499),o=t(63939),n=t(50932),d=(t(9599),t(4624)),c=t(85947),f=t(37837),m=t(71517),p=t(77231),g=t(50011),l=t(64093),h=t(44328),u=t(31608),R=t(43607),w=t(72739),x=t(19028),k=t(75294),I=t(9705);const B="src/avformat/formats/IMp3Format.ts";class S extends c.A{constructor(){super(),(0,i.A)(this,"type",14),(0,i.A)(this,"context",void 0)}init(e){e.ioReader&&e.ioReader.setEndian(!0),this.context={firstFramePos:p.Dh,isVBR:!1,hasID3v1:!1,id3v2:{version:p.N_,revision:p.N_,flags:p.N_},fileSize:BigInt(0)}}async readHeader(e){const a=e.createStream();a.codecpar.codecId=86017,a.codecpar.codecType=1,a.startTime=BigInt(0),a.firstDTS=BigInt(0);const t={frameHeader:new k.Vz,nbFrame:BigInt(0),tocIndexes:[],nextDTS:BigInt(0),frameLength:0};a.privData=t;const i=a.metadata={},s=await e.ioReader.fileSize();if(1&e.ioReader.flags&&s>u.c1&&(await e.ioReader.seek(s-BigInt(u.c1)),"TAG"===await e.ioReader.readString(3))){let a=await e.ioReader.readBuffer(30);i.title=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(30),i.artist=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(30),i.album=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(4),i.date=g.decode(a).replace(/\s/g,""),a=await e.ioReader.readBuffer(30),i.comment=g.decode(a).replace(/\s/g,""),0===a[28]&&0!==a[29]&&(i.track=a[29]+""),i.genre=await e.ioReader.readUint8(),this.context.hasID3v1=!0}if(await e.ioReader.seek(BigInt(0)),"ID3"===await e.ioReader.peekString(3)){await e.ioReader.skip(3),this.context.id3v2.version=await e.ioReader.readUint8(),this.context.id3v2.revision=await e.ioReader.readUint8(),this.context.id3v2.flags=await e.ioReader.readUint8();const a=(127&await e.ioReader.readUint8())<<21|(127&await e.ioReader.readUint8())<<14|(127&await e.ioReader.readUint8())<<7|127&await e.ioReader.readUint8();await x.q(e.ioReader,a,this.context.id3v2,i)}for(this.context.firstFramePos=e.ioReader.getPos();65504&~await e.ioReader.peekUint16();)await e.ioReader.skip(1);this.context.firstFramePos!==e.ioReader.getPos()&&(d.R8(`skipping ${e.ioReader.getPos()-this.context.firstFramePos} bytes of junk at ${this.context.firstFramePos}`,B,171),this.context.firstFramePos=e.ioReader.getPos()),a.codecpar.extradataSize=4,a.codecpar.extradata=(0,f.sY)(a.codecpar.extradataSize),await e.ioReader.peekBuffer(a.codecpar.extradataSize,(0,r.JW)(a.codecpar.extradata,a.codecpar.extradataSize)),k.qg(t.frameHeader,await e.ioReader.readUint32()),a.codecpar.profile=l.Au(t.frameHeader.layer),a.codecpar.frameSize=l.hG(t.frameHeader.version,t.frameHeader.layer),a.codecpar.sampleRate=l.Y2(t.frameHeader.version,t.frameHeader.samplingFrequency),a.timeBase.num=1,a.timeBase.den=a.codecpar.sampleRate;const o=3===t.frameHeader.mode?1:2;a.codecpar.chLayout.nbChannels=o;const n=BigInt(Math.floor(l.oz(t.frameHeader.version,t.frameHeader.layer,t.frameHeader.bitrateIndex))),c=k.CM(t.frameHeader,a.codecpar.sampleRate),m=e.ioReader.getPos();await e.ioReader.skip([[0,9,17],[0,0,0],[0,9,17],[0,17,32]][t.frameHeader.version][a.codecpar.chLayout.nbChannels]);const p=await e.ioReader.readString(4);if("Xing"===p||"Info"===p){this.context.isVBR=!0;const r=await e.ioReader.readUint32();1&r&&(t.nbFrame=BigInt(Math.floor(await e.ioReader.readUint32()))),2&r&&(this.context.fileSize=BigInt(Math.floor(await e.ioReader.readUint32())));const o=s>=m?s-m:BigInt(0);if(o&&this.context.fileSize){const e=R.jk(o,this.context.fileSize),a=R.T9(o,this.context.fileSize)-e;o>this.context.fileSize&&a>e>>BigInt(4)?(t.nbFrame=BigInt(0),d.R8("invalid concatenated file detected - using bitrate for duration",B,224)):a>e>>BigInt(4)&&d.R8("filesize and duration do not match (growing file?)",B,227)}if(a.duration=t.nbFrame*BigInt(0|a.codecpar.frameSize),4&r)for(let i=0;i<u.W8;i++){const r=await e.ioReader.readUint8(),s=this.context.fileSize*BigInt(Math.floor(r))/BigInt(256),o={dts:a.duration/BigInt(u.W8)*BigInt(Math.floor(i)),pos:s};t.tocIndexes.push(o)}8&r&&await e.ioReader.skip(4),i.encoder=await e.ioReader.readString(9),this.context.firstFramePos+=BigInt(Math.floor(c))}else await e.ioReader.seek(m),"VBRI"===await e.ioReader.readString(4)?(1===await e.ioReader.readUint16()&&(await e.ioReader.skip(4),this.context.fileSize=BigInt(Math.floor(await e.ioReader.readUint32())),t.nbFrame=BigInt(Math.floor(await e.ioReader.readUint32())),a.duration=t.nbFrame*BigInt(0|a.codecpar.frameSize)),this.context.firstFramePos+=BigInt(Math.floor(c))):(this.context.isVBR=!1,a.codecpar.bitrate=n*BigInt(1e3),t.nbFrame=(s-this.context.firstFramePos-BigInt(u.c1))/BigInt(Math.floor(c)),a.duration=t.nbFrame*BigInt(0|a.codecpar.frameSize),t.frameLength=c,this.context.fileSize=s);for(await e.ioReader.seek(this.context.firstFramePos);65504&~await e.ioReader.peekUint16();)await e.ioReader.skip(1);if(this.context.firstFramePos!==e.ioReader.getPos()&&(d.R8(`skipping ${e.ioReader.getPos()-this.context.firstFramePos} bytes of junk at ${this.context.firstFramePos}`,B,287),this.context.firstFramePos=e.ioReader.getPos()),t.tocIndexes.length)for(let e=0;e<u.W8;e++)t.tocIndexes[e].pos+=this.context.firstFramePos;return 0}async readAVPacket(e,a){const t=e.getStreamByMediaType(1),i=t.privData,c=e.ioReader.getPos();if(this.context.hasID3v1&&c>=this.context.fileSize-BigInt(u.c1))return-1048576;try{k.qg(i.frameHeader,await e.ioReader.peekUint32());let d=this.context.isVBR?k.CM(i.frameHeader,t.codecpar.sampleRate):i.frameLength;n.M[15](a+28,d),n.M[17](a+56,c),n.M[15](a+32,t.index),(0,r.Mr)(a+72,t.timeBase[s.o9],8),n.M[17](a+48,BigInt(0|t.codecpar.frameSize)),n.M[17](a+16,i.nextDTS),n.M[17](a+8,i.nextDTS),n.M[15](a+36,1|o.f[15](a+36)),i.nextDTS+=BigInt(0|t.codecpar.frameSize);const p=(0,f.sY)(d);return(0,m.NX)(a,p,d),await e.ioReader.readBuffer(d,(0,r.JW)(p,d)),0}catch(a){return-1048576!==e.ioReader.error&&d.z3(a.message,B,334),e.ioReader.error}}async syncToFrame(e){let a=p.Dh;const t=e.getStreamByMediaType(1),i=t.privData;for(;;)try{if(!(65504&~await e.ioReader.peekUint16())){a=e.ioReader.getPos(),k.qg(i.frameHeader,await e.ioReader.peekUint32());let r=this.context.isVBR?k.CM(i.frameHeader,t.codecpar.sampleRate):i.frameLength;if(r>512e3){await e.ioReader.skip(1);continue}await e.ioReader.skip(r);let s=0;for(;s<=3&&!(65504&~await e.ioReader.peekUint16());){k.qg(i.frameHeader,await e.ioReader.peekUint32());let a=this.context.isVBR?k.CM(i.frameHeader,t.codecpar.sampleRate):i.frameLength;await e.ioReader.skip(a),s++}if(!(s<3))break;await e.ioReader.seek(a+BigInt(1)),a=p.Dh}await e.ioReader.skip(1)}catch(e){break}a!==p.Dh&&await e.ioReader.seek(a)}async seek(e,a,t,i){const r=e.ioReader.getPos(),s=a.privData;if(2&i){const o=await e.ioReader.fileSize();return o<=BigInt(0)?BigInt(I.E$):(t<BigInt(0)?t=BigInt(0):t>o&&(t=o),await e.ioReader.seek(t),4&i||(await this.syncToFrame(e),a.duration&&o&&(s.nextDTS=t/o*a.duration)),r)}if(a.sampleIndexes.length){let i=w.El(a.sampleIndexes,(e=>e.pts>t?-1:1));if(i>0&&(0,h.k)(t-a.sampleIndexes[i-1].pts,a.timeBase,p.i0)<BigInt(1e4))return d.Yz(`seek in sampleIndexes, found index: ${i}, pts: ${a.sampleIndexes[i-1].pts}, pos: ${a.sampleIndexes[i-1].pos}`,B,442),await e.ioReader.seek(a.sampleIndexes[i-1].pos),s.nextDTS=a.sampleIndexes[i-1].dts,r}if(t===BigInt(0))return await e.ioReader.seek(this.context.firstFramePos),r;if(this.context.isVBR)if(s.tocIndexes.length){const i=s.tocIndexes[Number(BigInt.asIntN(32,t/(a.duration/BigInt(u.W8))))];if(i)d.Yz(`seek in xing toc indexes, pts: ${i.dts}, pos: ${i.pos}`,B,458),await e.ioReader.seek(i.pos),s.nextDTS=i.dts;else{d.Yz("not found any keyframe index, try to seek in bytes",B,463);const i=k.CM(s.frameHeader,a.codecpar.sampleRate),r=t/BigInt(0|a.codecpar.frameSize),o=r*BigInt(Math.floor(i))+this.context.firstFramePos;s.nextDTS=r*BigInt(0|a.codecpar.frameSize),await e.ioReader.seek(o)}}else{d.Yz("not found any keyframe index, try to seek in bytes",B,472);const i=k.CM(s.frameHeader,a.codecpar.sampleRate),r=t/BigInt(0|a.codecpar.frameSize),o=r*BigInt(Math.floor(i))+this.context.firstFramePos;s.nextDTS=r*BigInt(0|a.codecpar.frameSize),await e.ioReader.seek(o)}else{const i=t/BigInt(0|a.codecpar.frameSize),r=i*BigInt(0|s.frameLength)+this.context.firstFramePos;s.nextDTS=i*BigInt(0|a.codecpar.frameSize),await e.ioReader.seek(r)}return await this.syncToFrame(e),r}getAnalyzeStreamsCount(){return 1}}},75294:(e,a,t)=>{t.d(a,{CM:()=>n,Vz:()=>s,qg:()=>o});var i=t(134),r=t(64093);class s{constructor(){(0,i.A)(this,"version",void 0),(0,i.A)(this,"layer",void 0),(0,i.A)(this,"protection",void 0),(0,i.A)(this,"bitrateIndex",void 0),(0,i.A)(this,"samplingFrequency",void 0),(0,i.A)(this,"padding",void 0),(0,i.A)(this,"private",void 0),(0,i.A)(this,"mode",void 0),(0,i.A)(this,"modeExtension",void 0),(0,i.A)(this,"copyright",void 0),(0,i.A)(this,"original",void 0),(0,i.A)(this,"emphasis",void 0)}}function o(e,a){e.version=a>>19&3,e.layer=a>>17&3,e.protection=a>>16&1,e.bitrateIndex=a>>12&15,e.samplingFrequency=a>>10&3,e.padding=a>>9&1,e.mode=a>>6&3,e.modeExtension=a>>4&3,e.copyright=a>>3&1,e.original=a>>2&1,e.emphasis=3&a}function n(e,a){let t=r.oz(e.version,e.layer,e.bitrateIndex);switch(e.layer){case 1:default:t=144e3*t/(a<<(3===e.version?0:1))>>>0,t+=e.padding;break;case 2:t=144e3*t/a>>>0,t+=e.padding;break;case 3:t=12e3*t/a>>>0,t=4*(t+e.padding)}return t}},19028:(e,a,t)=>{t.d(a,{q:()=>o});var i=t(4624);t(50011);const r="src/avformat/formats/mp3/id3v2.ts";function s(e,a){let t="utf-8";return 0===e?t="iso-8859-1":1===e?t="utf-16":2===e&&(t="utf-16be"),new TextDecoder(t).decode(a)}async function o(e,a,t,o){const n=2!==t.version,d=n?10:6;let c=e.getPos()+BigInt(0|a);async function f(){await e.seek(c)}if(n&&64&t.flags){let s=await async function(e,a){let t=0;for(;a--;)t=(t<<7)+(127&await e.readUint8());return t}(e,4);if(4===t.version&&(s-=4),s<0)return i.z3("invalid extended header length",r,88),await f();if(await e.skip(s),(a-=s+4)<0)return i.z3("extended header too long",r,94),await e.seek(c),await f()}for(;a>d;){let t,c;if(n){if(t=await e.readString(4),c=await e.readUint32(),!c){i.z3("invalid frame size",r,108);break}await e.readUint16()}else t=await e.readString(3),c=await e.readUint24();if("APIC"===t)o.poster=await e.readBuffer(c);else if("USLT"===t){const a=await e.readUint8(),t=await e.readString(3),i=await e.readBuffer(c-4);o.lyrics=`${t} ${s(a,i)}`}else if("COMM"===t||"COM"===t){const a=await e.readUint8(),t=await e.readString(3),i=await e.readBuffer(c-4);o.comment=`${t} ${s(a,i)}`}else{let a;switch(a="T"===t[0]?s(await e.readUint8(),await e.readBuffer(c-1)):await e.readBuffer(c),t){case"TIT2":case"TT2":o.title=a;break;case"TPE1":case"TP1":o.artist=a;break;case"TPE2":case"TP2":o.albumArtist=a;break;case"TPOS":o.disc=a;break;case"TCOP":o.copyright=a;break;case"TALB":case"TAL":o.album=a;break;case"TRCK":case"TRK":o.track=a;break;case"TYER":case"TDRL":case"TDRC":o.date=a;break;case"COMM":case"COM":o.comment=a;break;case"TCON":case"TCO":o.genre=a;break;case"TSSE":case"TEN":o.encoder=a;break;case"TCOM":o.composer=a;break;case"TENC":o.vendor=a;break;case"TLAN":o.language=a;break;case"TPE3":case"TP3":o.performer=a;break;case"TPUB":o.publisher=a;break;case"TCMP":case"TCP":o.compilation=a;break;case"TDEN":o.creationTime=a;break;case"TSOA":o.albumSort=a;break;case"TSOP":o.artistSort=a;break;case"TSOT":o.titleSort=a;break;case"TIT1":o.grouping=a;break;default:o[t]=a}}a-=c+d}4==t.version&&16&t.flags&&(c+=BigInt(10)),await e.seek(c)}},31608:(e,a,t)=>{t.d(a,{W8:()=>i,c1:()=>r});const i=100,r=128},64093:(e,a,t)=>{t.d(a,{Au:()=>w,He:()=>x,XC:()=>k,Y2:()=>h,hG:()=>u,oz:()=>R});var i=t(77231);const r=[44100,48e3,32e3,0],s=[22050,24e3,16e3,0],o=[11025,12e3,8e3,0],n=[0,1152,1152,384],d=[0,576,1152,384],c=[0,576,1152,384],f=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],m=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],p=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],g=[0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],l=[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1];function h(e,a){switch(e){case 0:return o[a];case 2:return s[a];case 3:return r[a]}return i.N_}function u(e,a){switch(e){case 0:return c[a];case 2:return d[a];case 3:return n[a]}return i.N_}function R(e,a,t){switch(a){case 1:switch(e){case 0:case 2:return l[t];case 3:return p[t]}break;case 2:switch(e){case 0:case 2:return l[t];case 3:return m[t]}case 3:switch(e){case 0:case 2:return g[t];case 3:return f[t]}}return i.N_}function w(e){switch(e){case 1:return 34;case 2:return 33;case 3:return 32}return i.N_}const x={32:"Layer1",33:"Layer2",34:"Layer3"};function k(e,a){if(a&&a.length>=4){const t=a[1]>>>3&3,i=(6&a[1])>>1,r=(12&a[2])>>>2,s=3&~(a[3]>>>6)?2:1,o=w(i),n=h(t,r);e.codecpar.profile=o,e.codecpar.sampleRate=n,e.codecpar.chLayout.nbChannels=s}}}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[854],{85947:(t,e,n)=>{n.d(e,{A:()=>r});var i=n(134);class r{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},98854:(t,e,n)=>{n.r(e),n.d(e,{default:()=>m});var i=n(134),r=n(73146),a=n.n(r),o=n(50932),s=n(4624),u=n(9705),c=n(85947),d=n(14686),l=n(37837),h=n(71517),g=n(72739),f=n(50011),p=n(38115);class m extends c.A{constructor(){super(),(0,i.A)(this,"type",21),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"index",void 0)}init(t){this.queue=[]}async readHeader(t){const e=t.createStream();e.codecpar.codecId=94232,e.codecpar.codecType=3,e.timeBase.den=1e3,e.timeBase.num=1;let n="";if(1&t.ioReader.flags){const e=await t.ioReader.fileSize();n=await t.ioReader.readString(Number(BigInt.asIntN(32,e)))}else try{n+=await t.ioReader.readLine()+"\n"}catch(t){}if(f){const t=p.q(n);if(this.queue=t.queue,t.head){const n=a()(t.head),i=f.encode(n);e.codecpar.extradata=(0,l.sY)(i.length),(0,d.lW)(e.codecpar.extradata,i.length,i),e.codecpar.extradataSize=i.length}}return this.index=0,0}async readAVPacket(t,e){if(!this.queue.length)return u.LR;if(this.index>=this.queue.length)return-1048576;const n=t.streams.find((t=>3===t.codecpar.codecType)),i=this.queue[this.index++];o.M[15](e+32,n.index),o.M[15](e+76,n.timeBase.den),o.M[15](e+72,n.timeBase.num),o.M[17](e+16,i.pts),o.M[17](e+8,i.pts),o.M[17](e+48,i.duration);const r=f.encode(i.context),a=(0,l.sY)(r.length);return(0,d.lW)(a,r.length,r),(0,h.NX)(e,a,r.length),0}async seek(t,e,n,i){if(2&i)return BigInt(u.E$);if(n<=BigInt(0))return this.index=0,BigInt(0);const r=g.El(this.queue,(t=>t.pts>n?-1:1));if(r>=0){for(s.Yz(`seek in cues, found index: ${r}, pts: ${this.queue[r].pts}`,"src/avformat/formats/ITtmlFormat.ts",143),this.index=Math.max(r-1,0);this.index>0&&(this.queue[this.index-1].pts===this.queue[this.index].pts||this.queue[this.index-1].pts+this.queue[this.index-1].duration>n);)this.index--;return BigInt(0)}return BigInt(u.LR)}getAnalyzeStreamsCount(){return 1}}},38115:(t,e,n)=>{n.d(e,{q:()=>s});var i=n(79331),r=n(67672),a=n(72739),o=n(54825);function s(t){const e=(0,i.A)(t,{aloneValueName:"context"});if(!e.tt)return{queue:[],head:{}};const n=[];function s(t){let e="";return a.__(t,(t=>{r.Yj(t)?e+=t:t.context?e+=`<${t.tagName}>${t.context}</${t.tagName}>`:e+=`<${t.tagName}/>`})),e}function u(t,e,i){var a;const u=(0,o.j)(e||t.begin);let c=t.context||"",d=t.region||"Default";r.YO(c)&&(c=s(c)),null!==(a=t.span)&&void 0!==a&&a.context&&(t.span.region&&(d=t.span.region),r.Yj(t.span.context)?c+=t.span.context:c+=s(t.span.context)),n.push({context:c,pts:u,region:d,duration:t.dur?(0,o.j)(t.dur):(0,o.j)(i||t.end)-u})}function c(t,e,n){r.YO(t)?a.__(t,(t=>{u(t,e,n)})):u(t,e,n)}return e.tt.body&&e.tt.body.div&&(r.YO(e.tt.body.div)?a.__(e.tt.body.div,(t=>{t.p&&c(t.p,t.begin,t.end)})):e.tt.body.div.p&&c(e.tt.body.div.p,e.tt.body.div.begin,e.tt.body.end)),{queue:n,head:e.tt.head||{}}}},54825:(t,e,n)=>{function i(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),n=BigInt(0);return 3===e.length&&(n+=BigInt(+e.shift().trim())*BigInt(36e5)),n+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),n+=BigInt(+e.shift().trim())*BigInt(1e3),n+=BigInt(+e.shift().trim()),n}function r(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),n=BigInt(0);return 3===e.length&&(n+=BigInt(+e.shift().trim())*BigInt(36e5)),n+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),n+=BigInt(+e.shift().trim())*BigInt(1e3),n+=BigInt(+e.shift().trim()),n}n.d(e,{j:()=>i,t:()=>r})},79331:(t,e,n)=>{n.d(e,{A:()=>u});var i=n(68632),r=n.n(i),a=n(72739);const o={aloneValueName:"_@attribute"},s=[" ","/",'"',"'","<",">"];function u(t,e=o){t=(t=(t=(t=t.replace(/<!--[\s\S]*?-->/g,"")).replace(/[\n\t\r]/g,"")).replace(/>[ \t]+</g,"><")).replace(/<\?[^>]*\?>/g,"");const n=[];let i=0;function u(t,i){const a=n[n.length-1];a&&(t===e.aloneValueName||null==a.obj[e.aloneValueName]?null==a.obj[t]?a.obj[t]=i:r()(a.obj[t])?a.obj[t].push(i):a.obj[t]=[a.obj[t],i]:a.obj[e.aloneValueName]=[a.obj[e.aloneValueName],{tagName:t,...i}])}function c(e){for(;i<t.length;){if(t[i]===e)return!0;i++}return!1}function d(){l();let e="";for(;i<t.length&&!a.zy(s,t[i]);)e+=t[i],i++;return e}function l(){for(;i<t.length&&/\s|\r|\n/.test(t[i]);)i++}const h=/\s/,g=/'/,f=/"/;function p(){if(i>=t.length)return!0;l();let e=h;'"'!==t[i]&&"'"!=t[i]||(e='"'===t[i]?f:g,i++);let n="";for(;i<t.length;){if(e.test(t[i])){i++;break}n+=t[i],i++}return n}function m(){l();let e="";for(;i<t.length&&"<"!==t[i];)e+=t[i],i++;return e}function b(){for(;"<"===t[i];){const e=i;if(i++,l(),"/"!==t[i]){i=e;break}if(i++,d()===n[n.length-1].tag){if(n.length>1){const t=n.pop();u(t.tag,t.obj)}c(">"),i++,l()}else n.pop(),c(">"),i++,l()}}return function r(){if(i>=t.length)return;let a=i;if(l(),"<"!==t[i])return i=a,u(e.aloneValueName,m()),b(),r();let o=c("<");if(!o)return;a=i,i++;const s=d();if(n.push({obj:{},tag:s,start:a}),function(){for(;l(),">"!==t[i]&&"/"!==t[i];){let t=d();if(!t)break;"="===t[t.length-1]?t=t.substring(0,t.length-1):(c("="),i++),u(t,p())}}(),l(),"/"===t[i]){if(i++,n.length>1){const t=n.pop();u(t.tag,t.obj)}return c(">"),i++,b(),r()}o=c(">"),o&&(i++,l(),"<"!==t[i]&&(u(e.aloneValueName,m()),l()),b(),r())}(),{[n[0].tag]:n[0].obj}}}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[854],{85947:(t,e,n)=>{n.d(e,{A:()=>r});var i=n(134);class r{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},98854:(t,e,n)=>{n.r(e),n.d(e,{default:()=>m});var i=n(134),r=n(73146),a=n.n(r),s=n(50932),o=n(4624),u=n(9705),c=n(85947),d=n(14686),l=n(37837),h=n(71517),g=n(72739),f=n(50011),p=n(74762);class m extends c.A{constructor(){super(),(0,i.A)(this,"type",21),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"index",void 0)}init(t){this.queue=[]}async readHeader(t){const e=t.createStream();e.codecpar.codecId=94232,e.codecpar.codecType=3,e.timeBase.den=1e3,e.timeBase.num=1;let n="";if(1&t.ioReader.flags){const e=await t.ioReader.fileSize();n=await t.ioReader.readString(Number(BigInt.asIntN(32,e)))}else try{n+=await t.ioReader.readLine()+"\n"}catch(t){}if(f){const t=p.q(n);if(this.queue=t.queue,t.head){const n=a()(t.head),i=f.encode(n);e.codecpar.extradata=(0,l.sY)(i.length),(0,d.lW)(e.codecpar.extradata,i.length,i),e.codecpar.extradataSize=i.length}}return this.index=0,0}async readAVPacket(t,e){if(!this.queue.length)return u.LR;if(this.index>=this.queue.length)return-1048576;const n=t.streams.find((t=>3===t.codecpar.codecType)),i=this.queue[this.index++];s.M[15](e+32,n.index),s.M[15](e+76,n.timeBase.den),s.M[15](e+72,n.timeBase.num),s.M[17](e+16,i.pts),s.M[17](e+8,i.pts),s.M[17](e+48,i.duration);const r=f.encode(i.context),a=(0,l.sY)(r.length);return(0,d.lW)(a,r.length,r),(0,h.NX)(e,a,r.length),0}async seek(t,e,n,i){if(2&i)return BigInt(u.E$);if(n<=BigInt(0))return this.index=0,BigInt(0);const r=g.El(this.queue,(t=>t.pts>n?-1:1));if(r>=0){for(o.Yz(`seek in cues, found index: ${r}, pts: ${this.queue[r].pts}`,"src/avformat/formats/ITtmlFormat.ts",143),this.index=Math.max(r-1,0);this.index>0&&(this.queue[this.index-1].pts===this.queue[this.index].pts||this.queue[this.index-1].pts+this.queue[this.index-1].duration>n);)this.index--;return BigInt(0)}return BigInt(u.LR)}getAnalyzeStreamsCount(){return 1}}},74762:(t,e,n)=>{n.d(e,{q:()=>o});var i=n(79331),r=n(67672),a=n(72739),s=n(54825);function o(t){const e=(0,i.A)(t,{aloneValueName:"context"});if(!e.tt)return{queue:[],head:{}};const n=[];function o(t){let e="";return a.__(t,(t=>{r.Yj(t)?e+=t:t.context?e+=`<${t.tagName}>${t.context}</${t.tagName}>`:e+=`<${t.tagName}/>`})),e}function u(t,e,i){var a;const u=(0,s.j)(e||t.begin);let c=t.context||"",d=t.region||"Default";r.YO(c)&&(c=o(c)),null!==(a=t.span)&&void 0!==a&&a.context&&(t.span.region&&(d=t.span.region),r.Yj(t.span.context)?c+=t.span.context:c+=o(t.span.context)),n.push({context:c,pts:u,region:d,duration:t.dur?(0,s.j)(t.dur):(0,s.j)(i||t.end)-u})}function c(t,e,n){r.YO(t)?a.__(t,(t=>{u(t,e,n)})):u(t,e,n)}return e.tt.body&&e.tt.body.div&&(r.YO(e.tt.body.div)?a.__(e.tt.body.div,(t=>{t.p&&c(t.p,t.begin,t.end)})):e.tt.body.div.p&&c(e.tt.body.div.p,e.tt.body.div.begin,e.tt.body.end)),{queue:n,head:e.tt.head||{}}}},54825:(t,e,n)=>{function i(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),n=BigInt(0);return 3===e.length&&(n+=BigInt(+e.shift().trim())*BigInt(36e5)),n+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),n+=BigInt(+e.shift().trim())*BigInt(1e3),n+=BigInt(+e.shift().trim()),n}function r(t){if(!(t=t.trim()))return-BigInt(1);let e=t.split(":"),n=BigInt(0);return 3===e.length&&(n+=BigInt(+e.shift().trim())*BigInt(36e5)),n+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),n+=BigInt(+e.shift().trim())*BigInt(1e3),n+=BigInt(+e.shift().trim()),n}n.d(e,{j:()=>i,t:()=>r})},79331:(t,e,n)=>{n.d(e,{A:()=>u});var i=n(68632),r=n.n(i),a=n(72739);const s={aloneValueName:"_@attribute"},o=[" ","/",'"',"'","<",">"];function u(t,e=s){t=(t=(t=(t=t.replace(/<!--[\s\S]*?-->/g,"")).replace(/[\n\t\r]/g,"")).replace(/>[ \t]+</g,"><")).replace(/<\?[^>]*\?>/g,"");const n=[];let i=0;function u(t,i){const a=n[n.length-1];a&&(t===e.aloneValueName||null==a.obj[e.aloneValueName]?null==a.obj[t]?a.obj[t]=i:r()(a.obj[t])?a.obj[t].push(i):a.obj[t]=[a.obj[t],i]:a.obj[e.aloneValueName]=[a.obj[e.aloneValueName],{tagName:t,...i}])}function c(e){for(;i<t.length;){if(t[i]===e)return!0;i++}return!1}function d(){l();let e="";for(;i<t.length&&!a.zy(o,t[i]);)e+=t[i],i++;return e}function l(){for(;i<t.length&&/\s|\r|\n/.test(t[i]);)i++}const h=/\s/,g=/'/,f=/"/;function p(){if(i>=t.length)return!0;l();let e=h;'"'!==t[i]&&"'"!=t[i]||(e='"'===t[i]?f:g,i++);let n="";for(;i<t.length;){if(e.test(t[i])){i++;break}n+=t[i],i++}return n}function m(){l();let e="";for(;i<t.length&&"<"!==t[i];)e+=t[i],i++;return e}function b(){for(;"<"===t[i];){const e=i;if(i++,l(),"/"!==t[i]){i=e;break}if(i++,d()===n[n.length-1].tag){if(n.length>1){const t=n.pop();u(t.tag,t.obj)}c(">"),i++,l()}else n.pop(),c(">"),i++,l()}}return function r(){if(i>=t.length)return;let a=i;if(l(),"<"!==t[i])return i=a,u(e.aloneValueName,m()),b(),r();let s=c("<");if(!s)return;a=i,i++;const o=d();if(n.push({obj:{},tag:o,start:a}),function(){for(;l(),">"!==t[i]&&"/"!==t[i];){let t=d();if(!t)break;"="===t[t.length-1]?t=t.substring(0,t.length-1):(c("="),i++),u(t,p())}}(),l(),"/"===t[i]){if(i++,n.length>1){const t=n.pop();u(t.tag,t.obj)}return c(">"),i++,b(),r()}s=c(">"),s&&(i++,l(),"<"!==t[i]&&(u(e.aloneValueName,m()),l()),b(),r())}(),{[n[0].tag]:n[0].obj}}}}]);