@libmedia/avplayer 0.11.3 → 0.12.0
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.
- package/dist/esm/19.avplayer.js +1 -1
- package/dist/esm/195.avplayer.js +1 -0
- package/dist/esm/367.avplayer.js +1 -1
- package/dist/esm/400.avplayer.js +1 -1
- package/dist/esm/421.avplayer.js +1 -1
- package/dist/esm/430.avplayer.js +1 -1
- package/dist/esm/464.avplayer.js +1 -1
- package/dist/esm/566.avplayer.js +1 -1
- package/dist/esm/60.avplayer.js +1 -1
- package/dist/esm/690.avplayer.js +1 -1
- package/dist/esm/799.avplayer.js +1 -1
- package/dist/esm/801.avplayer.js +1 -1
- package/dist/esm/81.avplayer.js +1 -1
- package/dist/esm/814.avplayer.js +1 -1
- package/dist/esm/82.avplayer.js +1 -1
- package/dist/esm/852.avplayer.js +1 -1
- package/dist/esm/902.avplayer.js +1 -1
- package/dist/esm/913.avplayer.js +1 -1
- package/dist/esm/945.avplayer.js +1 -1
- package/dist/esm/949.avplayer.js +1 -1
- package/dist/esm/953.avplayer.js +1 -1
- package/dist/esm/avplayer.js +1 -1
- package/dist/types/AVPlayer.d.ts +39 -21
- package/dist/types/Controller.d.ts +3 -2
- package/dist/types/JitterBufferController.d.ts +2 -1
- package/dist/types/StatsController.d.ts +1 -1
- package/dist/types/mse/MSEPipeline.d.ts +10 -9
- package/dist/types/struct.d.ts +5 -5
- package/dist/types/subtitle/AssRender.d.ts +1 -1
- package/dist/types/subtitle/SubtitleRender.d.ts +4 -4
- package/dist/types/type.d.ts +2 -2
- package/dist/umd/19.avplayer.js +1 -1
- package/dist/umd/195.avplayer.js +1 -0
- package/dist/umd/367.avplayer.js +1 -1
- package/dist/umd/400.avplayer.js +1 -1
- package/dist/umd/421.avplayer.js +1 -1
- package/dist/umd/430.avplayer.js +1 -1
- package/dist/umd/464.avplayer.js +1 -1
- package/dist/umd/566.avplayer.js +1 -1
- package/dist/umd/60.avplayer.js +1 -1
- package/dist/umd/690.avplayer.js +1 -1
- package/dist/umd/799.avplayer.js +1 -1
- package/dist/umd/801.avplayer.js +1 -1
- package/dist/umd/81.avplayer.js +1 -1
- package/dist/umd/814.avplayer.js +1 -1
- package/dist/umd/82.avplayer.js +1 -1
- package/dist/umd/852.avplayer.js +1 -1
- package/dist/umd/902.avplayer.js +1 -1
- package/dist/umd/913.avplayer.js +1 -1
- package/dist/umd/945.avplayer.js +1 -1
- package/dist/umd/949.avplayer.js +1 -1
- package/dist/umd/953.avplayer.js +1 -1
- package/dist/umd/avplayer.js +1 -1
- package/package.json +12 -12
- package/dist/esm/733.avplayer.js +0 -1
- package/dist/umd/733.avplayer.js +0 -1
package/dist/umd/690.avplayer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[690],{5114:(t,i,e)=>{"use strict";e.d(i,{A:()=>r});var s=e(9655);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)}}},63278:(t,i,e)=>{"use strict";e.d(i,{A:()=>u});var s=e(9655),r=e(81895),n=e(64310),a=e(20163),h=e(68944),o=e(20086),f=e(41177);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)}}},71619:(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}},68944:(t,i,e)=>{"use strict";e.d(i,{M5:()=>n}),e(71619),e(69663),e(89378),e(92324);var s=e(68483);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)}},92324:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(20163);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}},27690:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>b});var s=e(9655),r=e(33096),n=e(65160),a=e(90946),h=e(95779),o=e(17848),f=e(73416),u=e(10446),l=e(81895),d=e(5114),p=e(63278),c=e(48162),w=e(41177),g=e(21472);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}}},72231:(t,i,e)=>{"use strict";e.d(i,{u:()=>r});var s=e(9655);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)}}},95779:(t,i,e)=>{"use strict";e.d(i,{A:()=>U});var s=e(9655),r=e(33793),n=e.n(r),a=e(55906),h=e.n(a),o=e(72231),f=e(5332),u=e(80155),l=e(87590),d=e(28495),p=e(41177),c=e(61272),w=e(48162),g=e(20163),b=e(31126),y=e(68483),m=e(56719),k=e(22080);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}}},28495:(t,i,e)=>{"use strict";e.d(i,{iD:()=>s});const s=1024},61272:(t,i,e)=>{"use strict";e.d(i,{U:()=>o,w:()=>f});var s=e(72231),r=e(64310),n=e(20163);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}},89378:(t,i,e)=>{"use strict";e.d(i,{Dh:()=>r,FQ:()=>d,H3:()=>o,KR:()=>u,N_:()=>n,SF:()=>a,WT:()=>f,f7:()=>g,go:()=>p,i0:()=>l,qs:()=>h,vh:()=>c,zg:()=>w});var s=e(51308);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=BigInt(0x8000000000000000),w=65535,g=4294967295;BigInt(0x10000000000000000)},51308:(t,i,e)=>{"use strict";e.d(i,{P:()=>u});var s,r,n=e(9655),a=e(33793),h=e.n(a),o=e(67312),f=e(7490);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)},41177:(t,i,e)=>{"use strict";e.d(i,{$x:()=>h,bD:()=>o});var s=e(68483),r=e(31126),n=e(99868);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)}},5332:(t,i,e)=>{"use strict";function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},69663:(t,i,e)=>{"use strict";e.d(i,{FP:()=>o,Mr:()=>h,iU:()=>l,j2:()=>u,k:()=>a,lb:()=>f});var s=e(16566),r=e(89378),n=e(17583);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)}},22080:(t,i,e)=>{"use strict";e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(9655),r=e(55906),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]()}},97023:(t,i,e)=>{"use strict";e(68483),e(31126)},17848:(t,i,e)=>{"use strict";e.d(i,{A:()=>u});var s=e(9655),r=e(55906),n=e.n(r),a=e(20163),h=e(19372),o=e(56719);const f="src/common/io/IOReader.ts";class u{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),(0,s.A)(this,"flushResolve",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,a.h2("peekHex, length too large",f,416)),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,a.h2("peekBuffer, length too large",f,501)),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 h.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return h.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,a.h2("peekLine, out of buffer",f,659)),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){return new(n())((async i=>{for(this.flushResolve=i;;){const e=await this.onFlush(t);if(-1048575!==e){this.flushResolve=null,i(e);break}await new o.A(0)}}))}async flush(t=0){if(this.onFlush||(this.error=-1048574,a.h2("IOReader error, flush failed because of no flush callback",f,738)),!(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,a.h2("IOReader error, seek failed because of no seek callback",f,809)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,a.h2("IOReader error, seek failed",f,818)),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,a.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",f,856)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}isBigEndian(){return!this.littleEndian}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return a.R8("IOReader error, fileSize failed because of no onSize callback",f,898),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){a.R8(`IOReader error, call fileSize failed: ${t}`,f,905),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)}}}abort(){this.error=-1048572,this.flushResolve&&(this.flushResolve(-1048572),this.flushResolve=null)}}},73416:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(9655),r=e(19372);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}}},81895:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(9655),r=e(19372);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}}},17583:(t,i,e)=>{"use strict";function s(t,i){for(;0!==i;)[t,i]=[i,t%i];return t}e.d(i,{A:()=>s})},10446:(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(38035),e(68483),e(97023),e(31126),e(99868);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)}},6431:(t,i,e)=>{var s=e(54446),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},38035:(t,i,e)=>{t.exports=e(6431)}}]);
|
|
1
|
+
(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[690],{5114:(t,i,e)=>{"use strict";e.d(i,{A:()=>r});var s=e(9655);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)}}},63278:(t,i,e)=>{"use strict";e.d(i,{A:()=>u});var s=e(9655),r=e(81895),n=e(64310),a=e(20163),h=e(68944),o=e(20086),f=e(41177);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)}}},71619:(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}},68944:(t,i,e)=>{"use strict";e.d(i,{M5:()=>n}),e(71619),e(69663),e(89378),e(92324);var s=e(68483);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)}},92324:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(20163);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}},27690:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>b});var s=e(9655),r=e(33096),n=e(65160),a=e(90946),h=e(95779),o=e(17848),f=e(73416),u=e(10446),l=e(81895),d=e(5114),p=e(63278),c=e(48162),w=e(41177),g=e(21472);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}}},72231:(t,i,e)=>{"use strict";e.d(i,{u:()=>r});var s=e(9655);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)}}},95779:(t,i,e)=>{"use strict";e.d(i,{A:()=>U});var s=e(9655),r=e(33793),n=e.n(r),a=e(55906),h=e.n(a),o=e(72231),f=e(5332),u=e(80155),l=e(87590),d=e(28495),p=e(41177),c=e(61272),w=e(48162),g=e(20163),b=e(31126),y=e(68483),m=e(56719),k=e(22080);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}}},28495:(t,i,e)=>{"use strict";e.d(i,{iD:()=>s});const s=1024},61272:(t,i,e)=>{"use strict";e.d(i,{U:()=>o,w:()=>f});var s=e(72231),r=e(64310),n=e(20163);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}},89378:(t,i,e)=>{"use strict";e.d(i,{Dh:()=>r,FQ:()=>d,H3:()=>o,KR:()=>u,N_:()=>n,SF:()=>a,WT:()=>f,f7:()=>g,go:()=>p,i0:()=>l,pu:()=>b,qs:()=>h,vh:()=>c,zg:()=>w});var s=e(51308);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=BigInt(0x8000000000000000),w=65535,g=4294967295,b=(BigInt(0x10000000000000000),8)},51308:(t,i,e)=>{"use strict";e.d(i,{P:()=>u});var s,r,n=e(9655),a=e(33793),h=e.n(a),o=e(67312),f=e(7490);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)},41177:(t,i,e)=>{"use strict";e.d(i,{$x:()=>h,bD:()=>o});var s=e(68483),r=e(31126),n=e(99868);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)}},5332:(t,i,e)=>{"use strict";function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},69663:(t,i,e)=>{"use strict";e.d(i,{FP:()=>o,Mr:()=>h,iU:()=>l,j2:()=>u,k:()=>a,lb:()=>f});var s=e(16566),r=e(89378),n=e(17583);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)}},22080:(t,i,e)=>{"use strict";e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(9655),r=e(55906),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]()}},97023:(t,i,e)=>{"use strict";e(68483),e(31126)},17848:(t,i,e)=>{"use strict";e.d(i,{A:()=>u});var s=e(9655),r=e(55906),n=e.n(r),a=e(20163),h=e(19372),o=e(56719);const f="src/common/io/IOReader.ts";class u{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),(0,s.A)(this,"flushResolve",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,a.h2("peekHex, length too large",f,416)),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,a.h2("peekBuffer, length too large",f,501)),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 h.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return h.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,a.h2("peekLine, out of buffer",f,659)),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){return new(n())((async i=>{for(this.flushResolve=i;;){const e=await this.onFlush(t);if(-1048575!==e){this.flushResolve=null,i(e);break}await new o.A(0)}}))}async flush(t=0){if(this.onFlush||(this.error=-1048574,a.h2("IOReader error, flush failed because of no flush callback",f,738)),!(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,a.h2("IOReader error, seek failed because of no seek callback",f,809)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,a.h2("IOReader error, seek failed",f,818)),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,a.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",f,856)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}isBigEndian(){return!this.littleEndian}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return a.R8("IOReader error, fileSize failed because of no onSize callback",f,898),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){a.R8(`IOReader error, call fileSize failed: ${t}`,f,905),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)}}}abort(){this.error=-1048572,this.flushResolve&&(this.flushResolve(-1048572),this.flushResolve=null)}}},73416:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(9655),r=e(19372);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}}},81895:(t,i,e)=>{"use strict";e.d(i,{A:()=>n});var s=e(9655),r=e(19372);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}}},17583:(t,i,e)=>{"use strict";function s(t,i){for(;0!==i;)[t,i]=[i,t%i];return t}e.d(i,{A:()=>s})},10446:(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(38035),e(68483),e(97023),e(31126),e(99868);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)}},6431:(t,i,e)=>{var s=e(54446),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},38035:(t,i,e)=>{t.exports=e(6431)}}]);
|
package/dist/umd/799.avplayer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[799],{57533:(e,t,a)=>{a.d(t,{A:()=>o});var r=a(9655),i=a(16566),s=(a(66219),a(1140)),n=a(15191);class o{constructor(){(0,r.A)(this,"inCodecpar",void 0),(0,r.A)(this,"inTimeBase",void 0),(0,r.A)(this,"outCodecpar",void 0)}init(e,t){return this.inCodecpar=(0,s.Gy)(168),(0,n.Yi)(this.inCodecpar,e),this.inTimeBase={den:i.f[15](t+4),num:i.f[15](t)},0}destroy(){this.inCodecpar&&((0,n.dn)(this.inCodecpar),this.inCodecpar=0)}}},31245:(e,t,a)=>{a.d(t,{A:()=>w});var r=a(9655),i=a(16566),s=a(36311),n=a(66219),o=a(17641),c=a(57533),d=a(41321),f=a(20163),l=a(20086),h=a(89378),p=a(35497),m=a(69663),u=a(1140),g=a(37142),R=a(31531),k=a(68483);class w extends c.A{constructor(...e){super(...e),(0,r.A)(this,"bitReader",void 0),(0,r.A)(this,"streamMuxConfig",void 0),(0,r.A)(this,"caches",void 0),(0,r.A)(this,"refSampleDuration",void 0)}init(e,t){return super.init(e,t),this.caches=[],this.refSampleDuration=BigInt(0),this.bitReader=new R.A,this.streamMuxConfig={profile:h.N_,sampleRate:h.N_,channels:h.N_},0}sendAVPacket(e){const t=(0,d.s3)(i.f[20](e+24),i.f[15](e+28));this.bitReader.appendBuffer(t);let a=i.f[17](e+16)!==h.Dh?i.f[17](e+16):i.f[17](e+8);for(;this.bitReader.remainingLength()>=20;){const t=this.bitReader.getPointer(),r=p.f7(null,this.bitReader);if(k.ai(r)){let e=!1;for(;this.bitReader.remainingLength()>=20;){if(695===this.bitReader.peekU(11)){e=!0;break}this.bitReader.readU1()}if(e)continue;return f.z3("AACLATMParser parse failed","src/avformat/bsf/aac/LATM2RawFilter.ts",107),this.bitReader.reset(),l.LR}if(r.framePayloadLength>=this.bitReader.remainingLength()){this.bitReader.skipPadding(),this.bitReader.setPointer(t);break}r.useSameStreamMux||(this.streamMuxConfig.profile=r.profile,this.streamMuxConfig.sampleRate=r.sampleRate,this.streamMuxConfig.channels=r.channels);const c=r.framePayloadLength,g=new Uint8Array(c);for(let e=0;e<c;e++)g[e]=this.bitReader.readU(8);const R={dts:a,buffer:g,extradata:null,pos:i.f[17](e+56)};if(i.f[15](this.inCodecpar+48)!==this.streamMuxConfig.profile||i.f[15](this.inCodecpar+136)!==this.streamMuxConfig.sampleRate||i.f[15](this.inCodecpar+116)!==this.streamMuxConfig.channels){this.refSampleDuration=(0,m.k)(BigInt(Math.floor(1024/this.streamMuxConfig.sampleRate*h.SF)),h.KR,this.inTimeBase),s.M[15](this.inCodecpar+48,this.streamMuxConfig.profile),s.M[15](this.inCodecpar+136,this.streamMuxConfig.sampleRate),s.M[15](this.inCodecpar+116,this.streamMuxConfig.channels);const e=(0,p.Ij)((0,o.A)(this.inCodecpar,n.A));i.f[20](this.inCodecpar+12)&&(0,u.Eb)(i.f[20](this.inCodecpar+12)),s.M[20](this.inCodecpar+12,(0,u.sY)(e.length)),(0,d.lW)(i.f[20](this.inCodecpar+12),e.length,e),s.M[15](this.inCodecpar+16,e.length),R.extradata=e}this.caches.push(R),a+=this.refSampleDuration,this.bitReader.skipPadding()}return 0}receiveAVPacket(e){if(this.caches.length){(0,g.Up)(e);const t=this.caches.shift(),a=(0,u.sY)(t.buffer.length);if((0,d.lW)(a,t.buffer.length,t.buffer),(0,g.NX)(e,a,t.buffer.length),s.M[17](e+16,t.dts),s.M[17](e+8,t.dts),s.M[17](e+56,t.pos),s.M[15](e+36,1|i.f[15](e+36)),s.M[17](e+48,this.refSampleDuration),t.extradata){const a=(0,u.sY)(t.extradata.length);(0,d.lW)(a,t.extradata.length,t.extradata),(0,g.Ow)(e,1,a,t.extradata.length)}return 0}return l.LT}reset(){return this.bitReader.reset(),this.caches.length=0,0}}},60799:(e,t,a)=>{a.r(t),a.d(t,{default:()=>b});var r=a(9655),i=a(67312),s=a(16566),n=a(36311),o=a(20163),c=a(20086),d=a(89984),f=a(41321),l=a(1140),h=a(37142),p=a(69663),m=a(89378),u=a(31126),g=a(35497),R=a(68483),k=a(31245),w=a(29887);const T="src/avformat/formats/IAacFormat.ts",B=1024;class b extends d.A{constructor(){super(),(0,r.A)(this,"type",15),(0,r.A)(this,"frameType",void 0),(0,r.A)(this,"fileSize",void 0),(0,r.A)(this,"currentPts",void 0),(0,r.A)(this,"latmFilter",void 0),(0,r.A)(this,"encodeSampleRate",void 0)}init(e){this.currentPts=BigInt(0)}async destroy(e){this.latmFilter&&(this.latmFilter.destroy(),this.latmFilter=null)}async estimateTotalBlock(e){let t=0;const a=e.ioReader.getPos();for(;;)try{const a=await e.ioReader.peekBuffer(7),r=(3&a[3])<<11|a[4]<<3|(224&a[5])>>>5;t+=1+(3&a[6]),await e.ioReader.skip(r)}catch(e){break}return await e.ioReader.seek(a),t}async parseTransportStreamTimestamp(e){if("ID3"===await e.ioReader.peekString(3)){await e.ioReader.skip(3);const t={version:await e.ioReader.readUint8(),revision:await e.ioReader.readUint8(),flags:await e.ioReader.readUint8()},a={},r=(127&await e.ioReader.readUint8())<<21|(127&await e.ioReader.readUint8())<<14|(127&await e.ioReader.readUint8())<<7|127&await e.ioReader.readUint8();if(await w.q(e.ioReader,r,t,a),R.o(a["com.apple.streaming.transportStreamTimestamp"]))return a["com.apple.streaming.transportStreamTimestamp"]}}async readHeader(e){let t;2&e.ioReader.flags&&(t=await this.parseTransportStreamTimestamp(e));const a=await e.ioReader.peekBuffer(4);if(this.fileSize=await e.ioReader.fileSize(),65===a[0]&&68===a[1]&&73===a[2]&&70===a[3]){const t=e.createStream();t.codecpar.codecId=86018,t.codecpar.codecType=1,this.frameType=0,t.duration=this.fileSize,t.timeBase.den=16384,t.timeBase.num=1}else if(255!==a[0]||240&~a[1]){if(86!==a[0]||224&~a[1])return c.LR;{this.frameType=2;const t=e.createStream();t.codecpar.codecId=86018,t.codecpar.codecType=1;const a=(0,g.f7)(await e.ioReader.peekBuffer(20));if(R.ai(a))return c.LR;t.codecpar.profile=a.profile,t.codecpar.sampleRate=a.sampleRate,t.codecpar.chLayout.nbChannels=a.channels;const r=(0,g.Ij)(t.codecpar);t.codecpar.extradata=(0,l.sY)(r.length),(0,f.lW)(t.codecpar.extradata,r.length,r),t.codecpar.extradataSize=r.length,t.duration=this.fileSize,t.timeBase.den=16384,t.timeBase.num=1,this.latmFilter=new k.A,this.latmFilter.init(t.codecpar[i.o9],t.timeBase[i.o9])}}else{this.frameType=1;const a=e.createStream();a.codecpar.codecId=86018,a.codecpar.codecType=1;const r=(0,g.Bq)(await e.ioReader.peekBuffer(20));if(R.ai(r))return c.LR;this.encodeSampleRate=r.sampleRate,a.codecpar.profile=r.profile,a.codecpar.sampleRate=r.sampleRate,a.codecpar.chLayout.nbChannels=r.channels;const i=(0,g.Ij)(a.codecpar);a.codecpar.extradata=(0,l.sY)(i.length),(0,f.lW)(a.codecpar.extradata,i.length,i),a.codecpar.extradataSize=i.length,a.timeBase.den=a.codecpar.sampleRate,a.timeBase.num=1,2&e.ioReader.flags?R.o(t)&&(this.currentPts=(0,p.k)(t,{num:1,den:9e4},a.timeBase)):a.duration=(0,p.k)(BigInt(Math.floor(1024*await this.estimateTotalBlock(e)/this.encodeSampleRate*m.SF)),m.KR,a.timeBase)}return 0}async readAVPacket(e,t){const a=e.streams.find((e=>e.codecpar.codecType=1));try{if(2&e.ioReader.flags){let t=await this.parseTransportStreamTimestamp(e);R.o(t)&&(this.currentPts=(0,p.k)(t,{num:1,den:9e4},a.timeBase))}const r=e.ioReader.getPos();let i;if(0===this.frameType){i=await e.ioReader.readBuffer(Math.min(B,Number(BigInt.asIntN(32,this.fileSize-r))));const a=(0,l.sY)(i.length);(0,f.lW)(a,i.length,i),(0,h.NX)(t,a,i.length),n.M[17](t+48,BigInt(B)),n.M[17](t+56,r)}else if(1===this.frameType){const s=await e.ioReader.readBuffer(7),o=1&s[1],c=(3&s[3])<<11|s[4]<<3|(224&s[5])>>>5,d=3&s[6];let u=1===o?7:9,g=c-u;9===u&&await e.ioReader.skip(2);const R=(0,p.k)(BigInt(Math.floor(1024*(d+1)/this.encodeSampleRate*m.SF)),m.KR,a.timeBase);n.M[17](t+48,R),i=await e.ioReader.readBuffer(g);const k=(0,l.sY)(i.length);(0,f.lW)(k,i.length,i),(0,h.NX)(t,k,i.length),n.M[17](t+56,r)}else if(2===this.frameType){if(r===this.fileSize)return-1048576;for(;;){let a=this.latmFilter.receiveAVPacket(t);if(a!==c.LT){if(a<0)return a;n.M[17](t+48,BigInt(0|s.f[15](t+28))),n.M[17](t+56,this.currentPts);break}{if(e.ioReader.getPos()===this.fileSize)return-1048576;i=await e.ioReader.readBuffer(Math.min(B,Number(BigInt.asIntN(32,this.fileSize-r))));const a=(0,l.sY)(i.length);(0,f.lW)(a,i.length,i),(0,h.NX)(t,a,i.length),this.latmFilter.sendAVPacket(t)}}}return n.M[15](t+32,a.index),n.M[15](t+76,a.timeBase.den),n.M[15](t+72,a.timeBase.num),n.M[17](t+16,this.currentPts),n.M[17](t+8,this.currentPts),n.M[15](t+36,1|s.f[15](t+36)),this.currentPts+=s.f[17](t+48),0}catch(t){return-1048576!==e.ioReader.error&&-1048572!==e.ioReader.error?(o.z3(`read packet error, ${t}`,T,337),c.LR):e.ioReader.error}}async syncFrame(e){if(0===this.frameType)return;let t=m.Dh;const a=1===this.frameType?4095:695,r=1===this.frameType?4:5;for(;;)try{let i=0;for(t=e.ioReader.getPos();3!==i&&await e.ioReader.peekUint16()>>>r===a;){const t=1===this.frameType?(0,g.Bq)(await e.ioReader.peekBuffer(9)):(0,g.f7)(await e.ioReader.peekBuffer(20));if(R.ai(t))break;i++,await e.ioReader.skip(t.headerLength+t.framePayloadLength)}if(3===i)break;await e.ioReader.skip(1)}catch(e){break}t!==m.Dh&&await e.ioReader.seek(t)}async seek(e,t,a,r){if(16&r&&2&e.ioReader.flags){const r=(0,p.k)(a,t.timeBase,m.i0);return await e.ioReader.seek(r,!0),this.currentPts=a,BigInt(0)}if(1===this.frameType){const i=e.ioReader.getPos();if(2&r){const s=await e.ioReader.fileSize();return s<=BigInt(0)?BigInt(c.E$):(a<BigInt(0)?a=BigInt(0):a>s&&(a=s),await e.ioReader.seek(a),4&r||(await this.syncFrame(e),t.duration&&this.fileSize&&(this.currentPts=a/this.fileSize*t.duration)),i)}if(t&&t.sampleIndexes.length){let r=u.El(t.sampleIndexes,(e=>e.pts>a?-1:1));if(r>0&&(0,p.k)(a-t.sampleIndexes[r-1].pts,t.timeBase,m.i0)<BigInt(5e3))return o.Yz(`seek in sampleIndexes, found index: ${r}, pts: ${t.sampleIndexes[r-1].pts}, pos: ${t.sampleIndexes[r-1].pos}`,T,443),await e.ioReader.seek(t.sampleIndexes[r-1].pos),this.currentPts=a,i}if(o.Yz("not found any keyframe index, try to seek in bytes",T,450),!t.duration)return BigInt(c.E$);{await e.ioReader.seek(BigInt(0));let r=BigInt(0);for(;;)try{if(r>=a)return this.currentPts=r,i;const s=await e.ioReader.peekBuffer(7),n=(3&s[3])<<11|s[4]<<3|(224&s[5])>>>5,o=3&s[6];r+=(0,p.k)(BigInt(Math.floor(1024*(o+1)/this.encodeSampleRate*m.SF)),m.KR,t.timeBase),await e.ioReader.skip(n)}catch(e){return BigInt(c.E$)}}}else if(0===this.frameType||2===this.frameType){this.latmFilter&&this.latmFilter.reset();const t=e.ioReader.getPos();return a<BigInt(0)?a=BigInt(0):a>this.fileSize&&(a=this.fileSize),await e.ioReader.seek(a),this.currentPts=a,2!==this.frameType||4&r||await this.syncFrame(e),t}return BigInt(c.E$)}getAnalyzeStreamsCount(){return 1}}},89984:(e,t,a)=>{a.d(t,{A:()=>i});var r=a(9655);class i{constructor(){(0,r.A)(this,"type",-1),(0,r.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},29887:(e,t,a)=>{a.d(t,{q:()=>o});var r=a(20163),i=a(19372);const s="src/avformat/formats/mp3/id3v2.ts";function n(e,t){let a="utf-8";return 0===e?a="iso-8859-1":1===e?a="utf-16":2===e&&(a="utf-16be"),new TextDecoder(a).decode(t)}async function o(e,t,a,o){const c=2!==a.version,d=c?10:6;let f=e.getPos()+BigInt(0|t);async function l(){await e.seek(f)}if(c&&64&a.flags){let i=await async function(e,t){let a=0;for(;t--;)a=(a<<7)+(127&await e.readUint8());return a}(e,4);if(4===a.version&&(i-=4),i<0)return r.z3("invalid extended header length",s,88),await l();if(await e.skip(i),(t-=i+4)<0)return r.z3("extended header too long",s,94),await e.seek(f),await l()}for(;t>d;){let a,f;if(c){if(a=await e.readString(4),f=await e.readUint32(),!f){r.z3("invalid frame size",s,108);break}await e.readUint16()}else a=await e.readString(3),f=await e.readUint24();if("APIC"===a)o.poster=await e.readBuffer(f);else if("USLT"===a){const t=await e.readUint8(),a=await e.readString(3),r=await e.readBuffer(f-4);o.lyrics=`${a} ${n(t,r)}`}else if("COMM"===a||"COM"===a){const t=await e.readUint8(),a=await e.readString(3),r=await e.readBuffer(f-4);o.comment=`${a} ${n(t,r)}`}else if("PRIV"===a){const t=e.getPos(),a=[];for(;;){const t=await e.readUint8();if(0===t)break;a.push(t)}const r=i.decode(new Uint8Array(a));let s;s="com.apple.streaming.transportStreamTimestamp"===r?await e.readUint64():await e.readBuffer(f-Number(e.getPos()-t)),o[r]=s}else{let t;switch(t="T"===a[0]?n(await e.readUint8(),await e.readBuffer(f-1)):await e.readBuffer(f),a){case"TIT2":case"TT2":o.title=t;break;case"TPE1":case"TP1":o.artist=t;break;case"TPE2":case"TP2":o.albumArtist=t;break;case"TPOS":o.disc=t;break;case"TCOP":o.copyright=t;break;case"TALB":case"TAL":o.album=t;break;case"TRCK":case"TRK":o.track=t;break;case"TYER":case"TDRL":case"TDRC":o.date=t;break;case"COMM":case"COM":o.comment=t;break;case"TCON":case"TCO":o.genre=t;break;case"TSSE":case"TEN":o.encoder=t;break;case"TCOM":o.composer=t;break;case"TENC":o.vendor=t;break;case"TLAN":o.language=t;break;case"TPE3":case"TP3":o.performer=t;break;case"TPUB":o.publisher=t;break;case"TCMP":case"TCP":o.compilation=t;break;case"TDEN":o.creationTime=t;break;case"TSOA":o.albumSort=t;break;case"TSOP":o.artistSort=t;break;case"TSOT":o.titleSort=t;break;case"TIT1":o.grouping=t;break;default:o[a]=t}}t-=f+d}4==a.version&&16&a.flags&&(f+=BigInt(10)),await e.seek(f)}},35497:(e,t,a)=>{a.d(t,{Bq:()=>l,Ij:()=>f,XC:()=>d,f7:()=>h,uF:()=>s});var r=a(89378),i=a(31531);const s={1:"Main",2:"LC",3:"SSR",4:"LTP",5:"HE",6:"SCALABLE",29:"HEv2",23:"LD",39:"ELD"},n={96e3:0,88200:1,64e3:2,48e3:3,44100:4,32e3:5,24e3:6,22050:7,16e3:8,12e3:9,11025:10,8e3:11,7350:12},o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,r.N_,r.N_,r.N_],c=[r.N_,1,2,3,4,5,6,7];function d(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t){const{profile:a,sampleRate:i,channels:s}=function(e){let t=r.N_,a=r.N_,i=r.N_;return e.length>=2&&(t=e[0]>>3&31,a=o[(7&e[0])<<1|e[1]>>7],i=c[e[1]>>3&15]),{profile:t,sampleRate:a,channels:i}}(t);e.codecpar.profile=a,e.codecpar.sampleRate=i,e.codecpar.chLayout.nbChannels=s,e.codecpar.frameSize=5===a?2048:1024,e.codecpar.format=8}}function f(e){const t=n[e.sampleRate],a=e.chLayout.nbChannels,i=e.profile===r.N_?2:e.profile,s=new Uint8Array(2);return s[0]=(31&i)<<3|(14&t)>>1,s[1]=(1&t)<<7|(15&a)<<3,s}function l(e){if(e.length<7)return-1;const t=e[0]<<4|e[1]>>4;if(4095!==t)return-1;const a=1&e[1],r=(192&e[2])>>>6,i=(60&e[2])>>>2,s=(1&e[2])<<2|(192&e[3])>>>6,n=(3&e[3])<<11|e[4]<<3|(224&e[5])>>>5,d=3&e[6];let f=1===a?7:9,l=n-f;return{syncWord:t,profile:r+1,sampleRate:o[i],channels:c[s],aacFrameLength:n,numberOfRawDataBlocksInFrame:d,headerLength:f,framePayloadLength:l}}function h(e,t){function a(){const e=t.readU(2);let a=0;for(let r=0;r<=e;r++)a<<=8,a|=t.readU(8);return a}t||(t=new i.A).appendBuffer(e);const r=t.getPointer(),s={syncWord:0,profile:0,sampleRate:0,channels:0,useSameStreamMux:!1,headerLength:0,framePayloadLength:0,muxLengthBytes:0},n=t.readU(11);if(695!==n)return-1;s.syncWord=n,s.muxLengthBytes=t.readU(13);const d=1===t.readU1();if(s.useSameStreamMux=d,!d){const e=1===t.readU1();if(e&&1===t.readU1())return-1;if(e&&a(),1!==t.readU1())return-1;if(0!==t.readU(6))return-1;if(0!==t.readU(4))return-1;if(0!==t.readU(3))return-1;let r=e?a():0;const i=t.readU(5);r-=5;const n=t.readU(4);r-=4;const d=t.readU(4);if(r-=4,t.readU(3),r-=3,r>0&&t.readU(r),0!==t.readU(3))return-1;if(t.readU(8),1===t.readU1())if(e)a();else{let e=0;for(;;){e<<=8;const a=1===t.readU1();if(e+=t.readU(8),!a)break}}1===t.readU1()&&t.readU(8),s.profile=i+1,s.sampleRate=o[n],s.channels=c[d]}let f=0;for(;;){const e=t.readU(8);if(f+=e,255!==e)break}return s.framePayloadLength=f,s.headerLength=t.getPointer()-r+(8===t.getBitLeft()?0:1),s}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[799],{57533:(e,t,i)=>{i.d(t,{A:()=>o});var a=i(9655),r=i(16566),s=(i(66219),i(1140)),n=i(15191);class o{constructor(){(0,a.A)(this,"inCodecpar",void 0),(0,a.A)(this,"inTimeBase",void 0),(0,a.A)(this,"outCodecpar",void 0)}init(e,t){return this.inCodecpar=(0,s.Gy)(168),(0,n.Yi)(this.inCodecpar,e),this.inTimeBase={den:r.f[15](t+4),num:r.f[15](t)},0}destroy(){this.inCodecpar&&((0,n.dn)(this.inCodecpar),this.inCodecpar=0)}}},31245:(e,t,i)=>{i.d(t,{A:()=>B});var a=i(9655),r=i(16566),s=i(36311),n=i(66219),o=i(17641),h=i(57533),c=i(41321),d=i(20163),f=i(20086),l=i(89378),p=i(35497),u=i(69663),m=i(1140),g=i(37142),w=i(31531),b=i(68483);class B extends h.A{constructor(...e){super(...e),(0,a.A)(this,"bitReader",void 0),(0,a.A)(this,"streamMuxConfig",void 0),(0,a.A)(this,"caches",void 0),(0,a.A)(this,"refSampleDuration",void 0)}init(e,t){return super.init(e,t),this.caches=[],this.refSampleDuration=BigInt(0),this.bitReader=new w.A,this.streamMuxConfig={profile:l.N_,sampleRate:l.N_,channels:l.N_},0}sendAVPacket(e){const t=(0,c.s3)(r.f[20](e+24),r.f[15](e+28));this.bitReader.appendBuffer(t);let i=r.f[17](e+16)!==l.Dh?r.f[17](e+16):r.f[17](e+8);for(;this.bitReader.remainingLength()>=20;){const t=this.bitReader.getPointer(),a=p.f7(null,this.bitReader);if(b.ai(a)){let e=!1;for(;this.bitReader.remainingLength()>=20;){if(695===this.bitReader.peekU(11)){e=!0;break}this.bitReader.readU1()}if(e)continue;return d.z3("AACLATMParser parse failed","src/avformat/bsf/aac/LATM2RawFilter.ts",108),this.bitReader.reset(),f.LR}if(a.framePayloadLength>=this.bitReader.remainingLength()){this.bitReader.skipPadding(),this.bitReader.setPointer(t);break}a.useSameStreamMux||(this.streamMuxConfig.profile=a.profile,this.streamMuxConfig.sampleRate=a.sampleRate,this.streamMuxConfig.channels=a.channels);const h=a.framePayloadLength,g=new Uint8Array(h);for(let e=0;e<h;e++)g[e]=this.bitReader.readU(8);const w={dts:i,buffer:g,extradata:null,pos:r.f[17](e+56)};if(r.f[15](this.inCodecpar+48)!==this.streamMuxConfig.profile||r.f[15](this.inCodecpar+136)!==this.streamMuxConfig.sampleRate||r.f[15](this.inCodecpar+116)!==this.streamMuxConfig.channels){this.refSampleDuration=(0,u.k)(BigInt(Math.floor(1024/this.streamMuxConfig.sampleRate*l.SF)),l.KR,this.inTimeBase),s.M[15](this.inCodecpar+48,this.streamMuxConfig.profile),s.M[15](this.inCodecpar+136,this.streamMuxConfig.sampleRate),s.M[15](this.inCodecpar+116,this.streamMuxConfig.channels);const e=(0,p.Ij)((0,o.A)(this.inCodecpar,n.A));r.f[20](this.inCodecpar+12)&&(0,m.Eb)(r.f[20](this.inCodecpar+12)),s.M[20](this.inCodecpar+12,(0,m.sY)(e.length)),(0,c.lW)(r.f[20](this.inCodecpar+12),e.length,e),s.M[15](this.inCodecpar+16,e.length),w.extradata=e}this.caches.push(w),i+=this.refSampleDuration,this.bitReader.skipPadding()}return 0}receiveAVPacket(e){if(this.caches.length){(0,g.Up)(e);const t=this.caches.shift(),i=(0,m.sY)(t.buffer.length);if((0,c.lW)(i,t.buffer.length,t.buffer),(0,g.NX)(e,i,t.buffer.length),s.M[17](e+16,t.dts),s.M[17](e+8,t.dts),s.M[17](e+56,t.pos),s.M[15](e+36,1|r.f[15](e+36)),s.M[17](e+48,this.refSampleDuration),t.extradata){const i=(0,m.sY)(t.extradata.length);(0,c.lW)(i,t.extradata.length,t.extradata),(0,g.Ow)(e,1,i,t.extradata.length)}return 0}return f.LT}reset(){return this.bitReader.reset(),this.caches.length=0,0}}},60799:(e,t,i)=>{i.r(t),i.d(t,{default:()=>I});var a=i(9655),r=i(67312),s=i(16566),n=i(36311),o=i(20163),h=i(20086),c=i(89984),d=i(41321),f=i(1140),l=i(37142),p=i(69663),u=i(89378),m=i(31126),g=i(35497),w=i(68483),b=i(31245),B=i(29887);const R="src/avformat/formats/IAacFormat.ts",k=1024;class I extends c.A{constructor(){super(),(0,a.A)(this,"type",15),(0,a.A)(this,"frameType",void 0),(0,a.A)(this,"fileSize",void 0),(0,a.A)(this,"currentPts",void 0),(0,a.A)(this,"latmFilter",void 0),(0,a.A)(this,"encodeSampleRate",void 0)}init(e){this.currentPts=BigInt(0)}async destroy(e){this.latmFilter&&(this.latmFilter.destroy(),this.latmFilter=null)}async estimateTotalBlock(e){let t=0;const i=e.ioReader.getPos();for(;;)try{const i=await e.ioReader.peekBuffer(7),a=(3&i[3])<<11|i[4]<<3|(224&i[5])>>>5;t+=1+(3&i[6]),await e.ioReader.skip(a)}catch(e){break}return await e.ioReader.seek(i),t}async parseTransportStreamTimestamp(e){if("ID3"===await e.ioReader.peekString(3)){await e.ioReader.skip(3);const t={version:await e.ioReader.readUint8(),revision:await e.ioReader.readUint8(),flags:await e.ioReader.readUint8()},i={},a=(127&await e.ioReader.readUint8())<<21|(127&await e.ioReader.readUint8())<<14|(127&await e.ioReader.readUint8())<<7|127&await e.ioReader.readUint8();if(await B.qg(e.ioReader,a,t,i),w.o(i["com.apple.streaming.transportStreamTimestamp"]))return i["com.apple.streaming.transportStreamTimestamp"]}}async readHeader(e){let t;2&e.ioReader.flags&&(t=await this.parseTransportStreamTimestamp(e));const i=await e.ioReader.peekBuffer(4);if(this.fileSize=await e.ioReader.fileSize(),65===i[0]&&68===i[1]&&73===i[2]&&70===i[3]){const t=e.createStream();t.codecpar.codecId=86018,t.codecpar.codecType=1,this.frameType=0,t.duration=this.fileSize,t.timeBase.den=16384,t.timeBase.num=1}else if(255!==i[0]||240&~i[1]){if(86!==i[0]||224&~i[1])return h.LR;{this.frameType=2;const t=e.createStream();t.codecpar.codecId=86018,t.codecpar.codecType=1;const i=(0,g.f7)(await e.ioReader.peekBuffer(20));if(w.ai(i))return h.LR;t.codecpar.profile=i.profile,t.codecpar.sampleRate=i.sampleRate,t.codecpar.chLayout.nbChannels=i.channels;const a=(0,g.Ij)(t.codecpar);t.codecpar.extradata=(0,f.sY)(a.length),(0,d.lW)(t.codecpar.extradata,a.length,a),t.codecpar.extradataSize=a.length,t.duration=this.fileSize,t.timeBase.den=16384,t.timeBase.num=1,this.latmFilter=new b.A,this.latmFilter.init(t.codecpar[r.o9],t.timeBase[r.o9])}}else{this.frameType=1;const i=e.createStream();i.codecpar.codecId=86018,i.codecpar.codecType=1;const a=(0,g.Bq)(await e.ioReader.peekBuffer(20));if(w.ai(a))return h.LR;this.encodeSampleRate=a.sampleRate,i.codecpar.profile=a.profile,i.codecpar.sampleRate=a.sampleRate,i.codecpar.chLayout.nbChannels=a.channels;const r=(0,g.Ij)(i.codecpar);i.codecpar.extradata=(0,f.sY)(r.length),(0,d.lW)(i.codecpar.extradata,r.length,r),i.codecpar.extradataSize=r.length,i.timeBase.den=i.codecpar.sampleRate,i.timeBase.num=1,2&e.ioReader.flags?w.o(t)&&(this.currentPts=(0,p.k)(t,{num:1,den:9e4},i.timeBase)):i.duration=(0,p.k)(BigInt(Math.floor(1024*await this.estimateTotalBlock(e)/this.encodeSampleRate*u.SF)),u.KR,i.timeBase)}return 0}async readAVPacket(e,t){const i=e.streams.find((e=>e.codecpar.codecType=1));try{if(2&e.ioReader.flags){let t=await this.parseTransportStreamTimestamp(e);w.o(t)&&(this.currentPts=(0,p.k)(t,{num:1,den:9e4},i.timeBase))}const a=e.ioReader.getPos();let r;if(0===this.frameType){r=await e.ioReader.readBuffer(Math.min(k,Number(BigInt.asIntN(32,this.fileSize-a))));const i=(0,f.sY)(r.length);(0,d.lW)(i,r.length,r),(0,l.NX)(t,i,r.length),n.M[17](t+48,BigInt(k)),n.M[17](t+56,a)}else if(1===this.frameType){const s=await e.ioReader.readBuffer(7),o=1&s[1],h=(3&s[3])<<11|s[4]<<3|(224&s[5])>>>5,c=3&s[6];let m=1===o?7:9,g=h-m;9===m&&await e.ioReader.skip(2);const w=(0,p.k)(BigInt(Math.floor(1024*(c+1)/this.encodeSampleRate*u.SF)),u.KR,i.timeBase);n.M[17](t+48,w),r=await e.ioReader.readBuffer(g);const b=(0,f.sY)(r.length);(0,d.lW)(b,r.length,r),(0,l.NX)(t,b,r.length),n.M[17](t+56,a)}else if(2===this.frameType){if(a===this.fileSize)return-1048576;for(;;){let i=this.latmFilter.receiveAVPacket(t);if(i!==h.LT){if(i<0)return i;n.M[17](t+48,BigInt(0|s.f[15](t+28))),n.M[17](t+56,this.currentPts);break}{if(e.ioReader.getPos()===this.fileSize)return-1048576;r=await e.ioReader.readBuffer(Math.min(k,Number(BigInt.asIntN(32,this.fileSize-a))));const i=(0,f.sY)(r.length);(0,d.lW)(i,r.length,r),(0,l.NX)(t,i,r.length),this.latmFilter.sendAVPacket(t)}}}return n.M[15](t+32,i.index),n.M[15](t+76,i.timeBase.den),n.M[15](t+72,i.timeBase.num),n.M[17](t+16,this.currentPts),n.M[17](t+8,this.currentPts),n.M[15](t+36,1|s.f[15](t+36)),this.currentPts+=s.f[17](t+48),0}catch(t){return-1048576!==e.ioReader.error&&-1048572!==e.ioReader.error?(o.z3(`read packet error, ${t}`,R,338),h.LR):e.ioReader.error}}async syncFrame(e){if(0===this.frameType)return;let t=u.Dh;const i=1===this.frameType?4095:695,a=1===this.frameType?4:5;for(;;)try{let r=0;for(t=e.ioReader.getPos();3!==r&&await e.ioReader.peekUint16()>>>a===i;){const t=1===this.frameType?(0,g.Bq)(await e.ioReader.peekBuffer(9)):(0,g.f7)(await e.ioReader.peekBuffer(20));if(w.ai(t))break;r++,await e.ioReader.skip(t.headerLength+t.framePayloadLength)}if(3===r)break;await e.ioReader.skip(1)}catch(e){break}t!==u.Dh&&await e.ioReader.seek(t)}async seek(e,t,i,a){if(16&a&&2&e.ioReader.flags){const a=(0,p.k)(i,t.timeBase,u.i0);return await e.ioReader.seek(a,!0),this.currentPts=i,BigInt(0)}if(1===this.frameType){const r=e.ioReader.getPos();if(2&a){const s=await e.ioReader.fileSize();return s<=BigInt(0)?BigInt(h.E$):(i<BigInt(0)?i=BigInt(0):i>s&&(i=s),await e.ioReader.seek(i),4&a||(await this.syncFrame(e),t.duration&&this.fileSize&&(this.currentPts=i/this.fileSize*t.duration)),r)}if(t&&t.sampleIndexes.length){let a=m.El(t.sampleIndexes,(e=>e.pts>i?-1:1));if(a>0&&(0,p.k)(i-t.sampleIndexes[a-1].pts,t.timeBase,u.i0)<BigInt(5e3))return o.Yz(`seek in sampleIndexes, found index: ${a}, pts: ${t.sampleIndexes[a-1].pts}, pos: ${t.sampleIndexes[a-1].pos}`,R,444),await e.ioReader.seek(t.sampleIndexes[a-1].pos),this.currentPts=i,r}if(o.Yz("not found any keyframe index, try to seek in bytes",R,451),!t.duration)return BigInt(h.E$);{await e.ioReader.seek(BigInt(0));let a=BigInt(0);for(;;)try{if(a>=i)return this.currentPts=a,r;const s=await e.ioReader.peekBuffer(7),n=(3&s[3])<<11|s[4]<<3|(224&s[5])>>>5,o=3&s[6];a+=(0,p.k)(BigInt(Math.floor(1024*(o+1)/this.encodeSampleRate*u.SF)),u.KR,t.timeBase),await e.ioReader.skip(n)}catch(e){return BigInt(h.E$)}}}else if(0===this.frameType||2===this.frameType){this.latmFilter&&this.latmFilter.reset();const t=e.ioReader.getPos();return i<BigInt(0)?i=BigInt(0):i>this.fileSize&&(i=this.fileSize),await e.ioReader.seek(i),this.currentPts=i,2!==this.frameType||4&a||await this.syncFrame(e),t}return BigInt(h.E$)}getAnalyzeStreamsCount(){return 1}}},89984:(e,t,i)=>{i.d(t,{A:()=>r});var a=i(9655);class r{constructor(){(0,a.A)(this,"type",-1),(0,a.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},29887:(e,t,i)=>{i.d(t,{In:()=>p,fz:()=>u,hm:()=>B,qg:()=>b});var a=i(16566),r=i(36311),s=i(20163),n=i(19372),o=(i(81895),i(48162)),h=i(37142),c=i(1140),d=i(41321),f=i(31126);i(99868);const l="src/avformat/formats/mp3/id3v2.ts",p={JPG:7,PNG:61,"image/gif":97,"image/jpeg":7,"image/jpg":7,"image/png":61,"image/tiff":96,"image/bmp":78,"image/webp":171},u=["Other","32x32 pixels 'file icon'","Other file icon","Cover (front)","Cover (back)","Leaflet page","Media (e.g. label side of CD)","Lead artist/lead performer/soloist","Artist/performer","Conductor","Band/Orchestra","Composer","Lyricist/text writer","Recording Location","During recording","During performance","Movie/video screen capture","A bright coloured fish","Illustration","Band/artist logotype","Publisher/Studio logotype"];function m(e,t){let i="utf-8";return 0===e?i="iso-8859-1":1===e?i="utf-16":2===e&&(i="utf-16be"),new TextDecoder(i).decode(t)}function g(e){return(127&e)+((32512&e)>>1)+((8323072&e)>>2)+((2130706432&e)>>3)}async function w(e,t){await e.seek(t);const i=await e.readString(4);return/^[A-Z0-9]+$/.test(i)}async function b(e,t,i,a){const r=2!==i.version,o=r?10:6;let h=e.getPos()+BigInt(0|t);async function c(){await e.skip(Number(BigInt.asIntN(32,h-e.getPos())))}if(r&&64&i.flags){let a=await async function(e,t){let i=0;for(;t--;)i=(i<<7)+(127&await e.readUint8());return i}(e,4);if(4===i.version&&(a-=4),a<0)return s.z3("invalid extended header length",l,149),await c();if(await e.skip(a),(t-=a+4)<0)return s.z3("extended header too long",l,155),await c()}for(;t>o;){let h,c;if(r){if(h=await e.readString(4),c=await e.readUint32(),!c){s.z3("invalid frame size",l,168);break}if(4===i.version&&c>127)if(c<t){await e.flush();const t=e.getPos();if(!(1&e.flags||6+c<e.remainingLength()))break;if(await w(e,t+BigInt(2)+BigInt(g(c))))c=g(c);else if(!await w(e,t+BigInt(2)+BigInt(c)))break;await e.seek(t)}else c=g(c);await e.readUint16()}else h=await e.readString(3),c=await e.readUint24();if("APIC"===h)a.apic||(a.apic=[]),a.apic.push(await e.readBuffer(c));else if("USLT"===h){const t=await e.readUint8(),i=await e.readString(3),r=await e.readBuffer(c-4);a.lyrics=`${i} ${m(t,r)}`}else if("COMM"===h||"COM"===h){const t=await e.readUint8(),i=await e.readString(3),r=await e.readBuffer(c-4);a.comment=`${i} ${m(t,r)}`}else if("PRIV"===h){const t=e.getPos(),i=[];for(;;){const t=await e.readUint8();if(0===t)break;i.push(t)}const r=n.decode(new Uint8Array(i));let s;s="com.apple.streaming.transportStreamTimestamp"===r?await e.readUint64():await e.readBuffer(c-Number(e.getPos()-t)),a[r]=s}else{let t;switch(t="T"===h[0]?m(await e.readUint8(),await e.readBuffer(c-1)):await e.readBuffer(c),h){case"TIT2":case"TT2":a.title=t;break;case"TPE1":case"TP1":a.artist=t;break;case"TPE2":case"TP2":a.albumArtist=t;break;case"TPOS":a.disc=t;break;case"TCOP":a.copyright=t;break;case"TALB":case"TAL":a.album=t;break;case"TRCK":case"TRK":a.track=t;break;case"TYER":case"TDRL":case"TDRC":a.date=t;break;case"COMM":case"COM":a.comment=t;break;case"TCON":case"TCO":a.genre=t;break;case"TSSE":case"TEN":a.encoder=t;break;case"TCOM":a.composer=t;break;case"TENC":a.vendor=t;break;case"TLAN":a.language=t;break;case"TPE3":case"TP3":a.performer=t;break;case"TPUB":a.publisher=t;break;case"TCMP":case"TCP":a.compilation=t;break;case"TDEN":a.creationTime=t;break;case"TSOA":a.albumSort=t;break;case"TSOP":a.artistSort=t;break;case"TSOT":a.titleSort=t;break;case"TIT1":a.grouping=t;break;default:a[h]=t}}t-=c+o}4==i.version&&16&i.flags&&(h+=BigInt(10)),await e.skip(Number(BigInt.asIntN(32,h-e.getPos())))}function B(e,t,i){const s=2!==i.version;t.forEach((t=>{const i=new o.A(t),n=i.readUint8();let l;function g(){let e=Number(i.getPos());for(;e<t.length&&t[e];)e++;return e}if(s?(l=i.readString(g()-Number(i.getPos())),i.skip(1)):l=i.readString(3),!p[l])return;const w=i.readUint8();let b;const B=g()-Number(i.getPos());B&&(b=m(n,i.readBuffer(B))),i.skip(1);const R=e.createStream();R.codecpar.codecId=p[l],R.codecpar.codecType=0,R.disposition|=1024,R.attachedPic=(0,h._5)(),r.M[15](R.attachedPic+32,R.index);const k=i.remainingSize(),I=(0,c.sY)(k),y=i.readBuffer(k);(0,d.lW)(I,k,y),y.length>=8&&f.FB(y.subarray(0,8),new Uint8Array([137,80,78,71,13,10,26,10]))&&(R.codecpar.codecId=61),(0,h.NX)(R.attachedPic,I,k),r.M[15](R.attachedPic+36,1|a.f[15](R.attachedPic+36)),R.metadata.comment=u[w],b&&(R.metadata.title=b)}))}},35497:(e,t,i)=>{i.d(t,{Bq:()=>f,Ij:()=>d,XC:()=>c,f7:()=>l,uF:()=>s});var a=i(89378),r=i(31531);const s={1:"Main",2:"LC",3:"SSR",4:"LTP",5:"HE",6:"SCALABLE",29:"HEv2",23:"LD",39:"ELD"},n={96e3:0,88200:1,64e3:2,48e3:3,44100:4,32e3:5,24e3:6,22050:7,16e3:8,12e3:9,11025:10,8e3:11,7350:12},o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,a.N_,a.N_,a.N_],h=[a.N_,1,2,3,4,5,6,7];function c(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t){const{profile:i,sampleRate:r,channels:s}=function(e){let t=a.N_,i=a.N_,r=a.N_;return e.length>=2&&(t=e[0]>>3&31,i=o[(7&e[0])<<1|e[1]>>7],r=h[e[1]>>3&15]),{profile:t,sampleRate:i,channels:r}}(t);e.codecpar.profile=i,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=s,e.codecpar.frameSize=5===i?2048:1024,e.codecpar.format=8}}function d(e){const t=n[e.sampleRate],i=e.chLayout.nbChannels,r=e.profile===a.N_?2:e.profile,s=new Uint8Array(2);return s[0]=(31&r)<<3|(14&t)>>1,s[1]=(1&t)<<7|(15&i)<<3,s}function f(e){if(e.length<7)return-1;const t=e[0]<<4|e[1]>>4;if(4095!==t)return-1;const i=1&e[1],a=(192&e[2])>>>6,r=(60&e[2])>>>2,s=(1&e[2])<<2|(192&e[3])>>>6,n=(3&e[3])<<11|e[4]<<3|(224&e[5])>>>5,c=3&e[6];let d=1===i?7:9,f=n-d;return{syncWord:t,profile:a+1,sampleRate:o[r],channels:h[s],aacFrameLength:n,numberOfRawDataBlocksInFrame:c,headerLength:d,framePayloadLength:f}}function l(e,t){function i(){const e=t.readU(2);let i=0;for(let a=0;a<=e;a++)i<<=8,i|=t.readU(8);return i}t||(t=new r.A).appendBuffer(e);const a=t.getPointer(),s={syncWord:0,profile:0,sampleRate:0,channels:0,useSameStreamMux:!1,headerLength:0,framePayloadLength:0,muxLengthBytes:0},n=t.readU(11);if(695!==n)return-1;s.syncWord=n,s.muxLengthBytes=t.readU(13);const c=1===t.readU1();if(s.useSameStreamMux=c,!c){const e=1===t.readU1();if(e&&1===t.readU1())return-1;if(e&&i(),1!==t.readU1())return-1;if(0!==t.readU(6))return-1;if(0!==t.readU(4))return-1;if(0!==t.readU(3))return-1;let a=e?i():0;const r=t.readU(5);a-=5;const n=t.readU(4);a-=4;const c=t.readU(4);if(a-=4,t.readU(3),a-=3,a>0&&t.readU(a),0!==t.readU(3))return-1;if(t.readU(8),1===t.readU1())if(e)i();else{let e=0;for(;;){e<<=8;const i=1===t.readU1();if(e+=t.readU(8),!i)break}}1===t.readU1()&&t.readU(8),s.profile=r+1,s.sampleRate=o[n],s.channels=h[c]}let d=0;for(;;){const e=t.readU(8);if(d+=e,255!==e)break}return s.framePayloadLength=d,s.headerLength=t.getPointer()-a+(8===t.getBitLeft()?0:1),s}},81895:(e,t,i)=>{i.d(t,{A:()=>s});var a=i(9655),r=i(19372);class s{constructor(e=1048576,t=!0,i){if((0,a.A)(this,"data",void 0),(0,a.A)(this,"buffer",void 0),(0,a.A)(this,"pointer",void 0),(0,a.A)(this,"pos",void 0),(0,a.A)(this,"size",void 0),(0,a.A)(this,"littleEndian",void 0),(0,a.A)(this,"error",void 0),(0,a.A)(this,"onFlush",void 0),(0,a.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=e,this.littleEndian=!t,this.error=0,i&&i.view)this.size=i.length,this.buffer=i,this.data=i.view;else if(i&&!i.byteOffset)this.size=i.length,this.buffer=i,this.data=new DataView(this.buffer.buffer);else{if(i)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(e){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,e),this.pointer++,this.pos++}writeUint16(e){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,e,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(e){this.remainingLength()<3&&this.flush();const t=(16711680&e)>>16,i=(65280&e)>>8,a=255&e;this.littleEndian?(this.writeUint8(a),this.writeUint8(i),this.writeUint8(t)):(this.writeUint8(t),this.writeUint8(i),this.writeUint8(a))}writeUint32(e){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,e,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(e){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,e,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(e){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,e),this.pointer++,this.pos++}writeInt16(e){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,e,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt24(e){this.writeUint24(e<0?e+16777216:e)}writeInt32(e){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,e,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(e){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,e,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(e){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,e,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(e){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,e,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(e){if(!e.length)return;let t=e.length;if(this.remainingLength()<t){let i=0;for(;t>0;){this.flush();const a=Math.min(this.size,t);this.buffer.set(e.subarray(i,i+a),this.pointer),this.pointer+=a,this.pos+=BigInt(a),i+=a,t-=a}}else this.buffer.set(e,this.pointer),this.pointer+=t,this.pos+=BigInt(t)}writeString(e){const t=r.encode(e);return this.writeBuffer(t),t.length}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const e=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==e)throw this.error=e,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(e){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),e);if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}seek(e){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const t=this.onSeek(e);if(0!==t)throw this.error=t,Error("IOWriter error, seek failed");this.pos=e}seekInline(e){const t=this.pointer;this.pointer=Math.max(0,Math.min(this.size,e)),this.pos+=BigInt(this.pointer-t)}skip(e){const t=this.pointer;this.pointer=Math.min(this.size,this.pointer+e),this.pos+=BigInt(this.pointer-t)}back(e){const t=this.pointer;this.pointer=Math.max(0,this.pointer-e),this.pos+=BigInt(this.pointer-t)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(e){this.littleEndian=!e}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}}}]);
|
package/dist/umd/801.avplayer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[801],{89984:(t,e,i)=>{i.d(e,{A:()=>s});var n=i(9655);class s{constructor(){(0,n.A)(this,"type",-1),(0,n.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},95801:(t,e,i)=>{i.r(e),i.d(e,{default:()=>l});var n=i(9655),s=i(36311),r=i(20163),u=i(20086),h=i(89984),a=i(41321),c=i(1140),o=i(37142),d=i(31126),
|
|
1
|
+
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[801],{89984:(t,e,i)=>{i.d(e,{A:()=>s});var n=i(9655);class s{constructor(){(0,n.A)(this,"type",-1),(0,n.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},95801:(t,e,i)=>{i.r(e),i.d(e,{default:()=>l});var n=i(9655),s=i(36311),r=i(20163),u=i(20086),h=i(89984),a=i(41321),c=i(1140),o=i(37142),d=i(31126),g=i(19372),f=i(7782);class l extends h.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(),h=r.shift().split(/--?>/);const a=(0,f.t)(h[0]),c=(0,f.t)(h[1]);if(c<=a)continue;const o=r.join("\n").trim();if(!o)continue;e.nbFrames++,e.duration=c;const g={identifier:u,context:o,startTs:a,endTs:c,pos:s};a>=i?(this.queue.push(g),i=a):d._(this.queue,g,(t=>t.startTs<g.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=g.encode(n.identifier),i=(0,c.sY)(t.length);(0,a.lW)(i,t.length,t),(0,o.Ow)(e,16,i,t.length)}const r=g.encode(n.context),h=(0,c.sY)(r.length);return(0,a.lW)(h,r.length,r),(0,o.NX)(e,h,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}}},7782:(t,e,i)=>{function n(t){if(!t)return-BigInt(1);let e=(t=t.trim()).split(":"),i=BigInt(0);if(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),e.length){let t=e[0].trim().length,n=BigInt(+e.shift().trim());1===t?n*=BigInt(100):2===t&&(n*=BigInt(10)),i+=n}return i}function s(t){if(!t)return-BigInt(1);let e=(t=t.trim()).split(":"),i=BigInt(0);if(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),e.length){let t=e[0].trim().length,n=BigInt(+e.shift().trim());1===t?n*=BigInt(100):2===t&&(n*=BigInt(10)),i+=n}return i}i.d(e,{j:()=>n,t:()=>s})}}]);
|
package/dist/umd/81.avplayer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[81],{50081:(e,t,i)=>{i.r(t),i.d(t,{default:()=>S});var s=i(9655),n=i(33793),a=i.n(n),o=i(55906),d=i.n(o),r=i(56719),l=i(72277),u=i(99868),m=i(20163),h=i(92518),c=i(33267),g=i(80155),f=i(20086);const p="src/avnetwork/ioLoader/DashIOLoader.ts";class S extends l.A{constructor(...e){super(...e),(0,s.A)(this,"info",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),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"signal",void 0)}createResource(e){return{type:e,fetchedMap:new(a()),fetchedHistoryListMax:100,fetchedHistoryList:[],loader:null,segmentIndex:0,currentUri:"",selectedIndex:0,segments:[],initSegmentPadding:"",initedSegment:"",sleep:null,lastPendingSegmentFetchTs:0,lastPendingSegmentDuration:0}}addHistory(e,t,i){e.fetchedMap.clear(),e.fetchedHistoryList.length=0;for(let s=0;s<i;s++)e.fetchedMap.set(t[s].url,!0),e.fetchedHistoryList.push(t[s].url);for(;e.fetchedHistoryList.length>=e.fetchedHistoryListMax;)e.fetchedMap.delete(e.fetchedHistoryList.shift())}async fetchMediaPlayList(e){var t,i,s;if(!e){if(this.fetchMediaPlayListPromise)return;this.fetchMediaPlayListPromise=new(d())((t=>{e=t}))}const n={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};null!==(t=this.info.httpOptions)&&void 0!==t&&t.headers&&u.__(this.info.httpOptions.headers,((e,t)=>{n.headers[t]=e})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(n.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(n.referrerPolicy=this.info.httpOptions.referrerPolicy);try{var a;"function"==typeof AbortController&&(this.signal=new AbortController);const t=await fetch(this.info.url,{...n,signal:null===(a=this.signal)||void 0===a?void 0:a.signal});this.signal=null;const i=await t.text();this.mediaPlayList=(0,h.A)(i,this.info.url),this.minBuffer=this.mediaPlayList.minBufferTime,"vod"===this.mediaPlayList.type?this.options.isLive=!1:this.options.isLive=!0;const s=(e,t,i)=>{let s=0,n=0;for(let e=t.length-2;e>=0;e--)if(!0!==t[e].pending&&(n+=t[e].segmentDuration,n>=i)){s=e;break}e.lastPendingSegmentFetchTs=this.mediaPlayList.maxSegmentDuration,e.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration,e.fetchedHistoryListMax=Math.max(e.fetchedHistoryListMax,t.length+1),this.addHistory(e,t,s)};if(this.mediaPlayList.mediaList.audio.length){if(this.options.preferAudioCodec||this.options.preferAudioLang){let e=!1,t=!1,i=this.mediaPlayList.mediaList.audio.some((e=>e.codecs&&e.codecs.indexOf(this.options.preferAudioCodec)>=0));this.mediaPlayList.mediaList.audio.forEach(((s,n)=>{this.options.preferAudioCodec&&i&&s.codecs&&-1===s.codecs.indexOf(this.options.preferAudioCodec)||(e||(this.audioResource.selectedIndex=n,e=!0),s.lang&&this.options.preferAudioLang&&s.lang.indexOf(this.options.preferAudioLang)>=0&&!t&&(this.audioResource.selectedIndex=n,s.lang===this.options.preferAudioLang&&(t=!0)))}))}const e=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];e.file?this.audioResource.segments=[{url:e.file}]:this.options.isLive&&this.audioResource.initedSegment===e.initSegment?(this.audioResource.segments=e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration}))),this.audioResource.lastPendingSegmentFetchTs=this.mediaPlayList.timestamp,this.audioResource.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration):(this.options.isLive&&s(this.audioResource,e.mediaSegments,this.minBuffer),this.audioResource.segments=[{url:e.initSegment}].concat(e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.audioResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.video.length){if(this.options.preferResolution||this.options.preferVideoCodec){let e=1,t=1;if(this.options.preferResolution){const i=this.options.preferResolution.split("*");e=+i[0]||1,t=+i[1]||1}let i=!1,s=1/0,n=this.mediaPlayList.mediaList.video.some((e=>e.codecs&&e.codecs.indexOf(this.options.preferVideoCodec)>=0));this.mediaPlayList.mediaList.video.forEach(((a,o)=>{if(!(this.options.preferVideoCodec&&n&&a.codecs&&-1===a.codecs.indexOf(this.options.preferVideoCodec))&&(i||(this.videoResource.selectedIndex=o,i=!0),a.width&&a.height&&this.options.preferResolution)){const i=1===e?1:a.width,n=1===t?1:a.height;Math.abs(i*n-e*t)<s&&(s=Math.abs(i*n-e*t),this.videoResource.selectedIndex=o)}}))}const e=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];e.file?this.videoResource.segments=[{url:e.file}]:this.options.isLive&&this.videoResource.initedSegment===e.initSegment?(this.videoResource.segments=e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration}))),this.videoResource.lastPendingSegmentFetchTs=this.mediaPlayList.maxSegmentDuration,this.videoResource.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration):(this.options.isLive&&s(this.videoResource,e.mediaSegments,this.minBuffer),this.videoResource.segments=[{url:e.initSegment}].concat(e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.videoResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.subtitle.length){if(this.options.preferSubtitleCodec||this.options.preferSubtitleLang){let e=!1,t=!1,i=this.mediaPlayList.mediaList.subtitle.some((e=>e.codecs&&e.codecs.indexOf(this.options.preferSubtitleCodec)>=0));this.mediaPlayList.mediaList.subtitle.forEach(((s,n)=>{this.options.preferSubtitleCodec&&i&&s.codecs&&-1===s.codecs.indexOf(this.options.preferSubtitleCodec)||(e||(this.subtitleResource.selectedIndex=n,e=!0),s.lang&&this.options.preferSubtitleLang&&s.lang.indexOf(this.options.preferSubtitleLang)>=0&&!t&&(this.subtitleResource.selectedIndex=n,s.lang===this.options.preferSubtitleLang&&(t=!0)))}))}const e=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];e.file?this.subtitleResource.segments=[{url:e.file}]:this.options.isLive&&this.subtitleResource.initedSegment===e.initSegment?(this.subtitleResource.segments=e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration}))),this.subtitleResource.lastPendingSegmentFetchTs=this.mediaPlayList.maxSegmentDuration,this.subtitleResource.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration):(this.options.isLive&&s(this.subtitleResource,e.mediaSegments,this.minBuffer),this.subtitleResource.segments=[{url:e.initSegment}].concat(e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.subtitleResource.initedSegment=e.initSegment)}return e(),this.fetchMediaPlayListPromise=null,this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.aborted)return this.status=3,void e();if(this.retryCount<this.options.retryCount)return this.retryCount++,m.z3(`failed fetch mpd file ${t}, retry(${this.retryCount}/3)`,p,397),await new r.A(2===this.status?this.options.retryInterval:5),this.fetchMediaPlayList(e);this.status=3,e(),m.h2(`DashLoader: exception, fetch slice error, error: ${t.message}`,p,405)}}async open(e){return 2===this.status?0:0!==this.status?f.lh:(this.info=e,this.videoResource=this.createResource(0),this.audioResource=this.createResource(1),this.subtitleResource=this.createResource(3),this.status=1,this.retryCount=0,this.aborted=!1,await this.fetchMediaPlayList(),0)}async readResource(e,t){let i=0;if(t.loader){if(i=await t.loader.read(e),-1048576!==i||this.aborted)return i;if(this.options.isLive)t.fetchedMap.set(t.currentUri,!0),t.fetchedHistoryList.length===t.fetchedHistoryListMax&&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.url)));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&&(t.sleep=new r.A(i),await t.sleep,t.sleep=null,this.aborted))return-1048576;if(this.fetchMediaPlayListPromise){if(await this.fetchMediaPlayListPromise,3===this.status||this.aborted)return-1048576}else if(await this.fetchMediaPlayList(),this.aborted)return-1048576;return this.readResource(e,t)}if(t.currentUri=i[0].url,this.options.isLive&&i[0].pending){if(t.lastPendingSegmentFetchTs){const e=t.lastPendingSegmentDuration-((0,g.A)()-t.lastPendingSegmentFetchTs)/1e3;if(e>0&&(t.sleep=new r.A(e),await t.sleep,t.sleep=null,this.aborted))return-1048576}t.lastPendingSegmentFetchTs=(0,g.A)(),t.lastPendingSegmentDuration=i[0].duration||this.mediaPlayList.maxSegmentDuration}return t.loader=new c.A(u.X$({},this.options,{disableSegment:!0,loop:!1})),await t.loader.open(u.X$({},this.info,{url:t.currentUri}),{from:0,to:-1}),t.loader.read(e)}return t.loader=new c.A(u.X$({},this.options,{disableSegment:!0,loop:!1})),t.initSegmentPadding?(await t.loader.open(u.X$({},this.info,{url:t.initSegmentPadding}),{from:0,to:-1}),t.initSegmentPadding=null,t.segmentIndex--):await t.loader.open(u.X$({},this.info,{url:t.segments[t.segmentIndex].url}),{from:0,to:-1}),t.loader.read(e)}async read(e,t){return 1===t.mediaType?this.readResource(e,this.audioResource):0===t.mediaType?this.readResource(e,this.videoResource):3===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 n=1===t.type?this.mediaPlayList.mediaList.audio:0===t.type?this.mediaPlayList.mediaList.video:this.mediaPlayList.mediaList.subtitle,a=n[t.selectedIndex].mediaSegments;if(null!=a&&a.length){e=-1;for(let t=0;t<a.length;t++)if(s>=1e3*a[t].start&&s<1e3*a[t].end){e=t;break}-1===e&&(e=a.length-1)}t.segmentIndex=e+(n[t.selectedIndex].initSegment?1:0);let o="";0===t.type?o=this.mediaPlayList.mediaList.video[t.selectedIndex].initSegment:1===t.type?o=this.mediaPlayList.mediaList.audio[t.selectedIndex].initSegment:3===t.type&&(o=this.mediaPlayList.mediaList.subtitle[t.selectedIndex].initSegment),o&&o===i&&(t.initSegmentPadding=o)}}async seek(e,t){return 1===t.mediaType&&this.audioResource.loader&&await this.seekResource(e,this.audioResource),0===t.mediaType&&this.videoResource.loader&&await this.seekResource(e,this.videoResource),3===t.mediaType&&this.subtitleResource.loader&&await this.seekResource(e,this.subtitleResource),4===this.status&&(this.status=2),this.aborted=!1,0}async size(){return BigInt(0)}abortSleep(){this.aborted=!0,this.videoResource.loader&&this.videoResource.loader.abortSleep(),this.videoResource.sleep&&(this.videoResource.sleep.stop(),this.videoResource.sleep=null),this.audioResource.loader&&this.audioResource.loader.abortSleep(),this.audioResource.sleep&&(this.audioResource.sleep.stop(),this.audioResource.sleep=null),this.subtitleResource.loader&&this.subtitleResource.loader.abortSleep(),this.subtitleResource.sleep&&(this.subtitleResource.sleep.stop(),this.subtitleResource.sleep=null)}async abort(){this.abortSleep(),this.signal&&this.signal.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,codec:e.codecs,bandwidth:e.bandwidth}))),selectedIndex:this.videoResource.selectedIndex}:{list:[],selectedIndex:0}}getAudioList(){return this.hasAudio()?{list:this.mediaPlayList.mediaList.audio.map((e=>({lang:e.lang,codec:e.codecs,bandwidth:e.bandwidth}))),selectedIndex:this.audioResource.selectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.hasSubtitle()?{list:this.mediaPlayList.mediaList.subtitle.map((e=>({lang:e.lang,codec: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];if(t.file)this.videoResource.segments=[{url:t.file}];else{if(this.options.isLive){let e=this.videoResource.segmentIndex;this.videoResource.segments.find(((t,i)=>{if(t.url===this.videoResource.currentUri)return e=i,!0})),this.addHistory(this.videoResource,t.mediaSegments,e+1)}this.videoResource.segments=[{url:t.initSegment}].concat(t.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),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];if(t.file)this.audioResource.segments=[{url:t.file}];else{if(this.options.isLive){let e=this.audioResource.segmentIndex;this.audioResource.segments.find(((t,i)=>{if(t.url===this.audioResource.currentUri)return e=i,!0})),this.addHistory(this.audioResource,t.mediaSegments,e+1)}this.audioResource.segments=[{url:t.initSegment}].concat(t.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),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];if(t.file)this.subtitleResource.segments=[{url:t.file}];else{if(this.options.isLive){let e=this.subtitleResource.segmentIndex;this.subtitleResource.segments.find(((t,i)=>{if(t.url===this.subtitleResource.currentUri)return e=i,!0})),this.addHistory(this.subtitleResource,t.mediaSegments,e+1)}this.subtitleResource.segments=[{url:t.initSegment}].concat(t.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.subtitleResource.initSegmentPadding=t.initSegment}}}getCurrentProtection(e){return 1===e?this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex].protection:0===e?this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex].protection:void 0}getMinBuffer(){return this.minBuffer}}},92518:(e,t,i)=>{i.d(t,{A:()=>R});var s=i(25116),n=i.n(s),a=i(6235),o=i.n(a),d=i(28800),r=i(68483),l=i(99868),u=i(97487),m=i(80155);function h(e){const t=e.match(/^PT?(?:(\d+)Y)?(?:(\d+)D)?(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?$/);if(!t)throw new Error("Invalid DASH PT duration: "+e);const[,i,s,a,d,r]=t;return 3600*n()(i||"0")*24*365+3600*n()(s||"0")*24+3600*n()(a||"0")+60*n()(d||"0")+o()(r||"0")}function c(e,t){const i=(0,u.A)(e);return i.length>=t?i:"0".repeat(t-i.length)+i}function g(e){if(!e)return 0;if(e.indexOf("/")>-1){const t=e.split("/");return o()(t[0])/o()(t[1])}return o()(e)}function f(e){e=e.replaceAll("-","");const t=[];for(let i=0;i<e.length;i+=2)t.push(+`0x${e.substring(i,i+2)}`);return new Uint8Array(t)}function p(e){let t={};return e.forEach((e=>{const i={};if(l.__(e,((e,t)=>{i[t.toLocaleLowerCase()]=e})),i["cenc:default_kid"]&&(t.kid=f(i["cenc:default_kid"]),t.scheme=i.value),i.schemeiduri){const e=i.schemeiduri.split(":");3===e.length&&"urn"===e[0]&&"uuid"===e[1]&&(t.systemId=f(e[2]))}i["clearkey:laurl"]&&(t.url=i["clearkey:laurl"].value),i["dashif:laurl"]&&(t.url=i["dashif:laurl"].value)})),t}function S(e,t){return/^https?:\/\//.test(t)?t:e+t}function L(e,t,i){const s={mediaList:{audio:[],video:[],subtitle:[]},type:"live",isEnd:!1,duration:0,minBufferTime:0,maxSegmentDuration:0,minimumUpdatePeriod:0,timeShiftBufferDepth:0,timestamp:(0,m.A)()},a=[];"static"===e.type&&(s.type="vod",s.isEnd=!0),e.minBufferTime&&(s.minBufferTime=h(e.minBufferTime)),e.maxSegmentDuration&&(s.maxSegmentDuration=h(e.maxSegmentDuration)),e.minimumUpdatePeriod&&(s.minimumUpdatePeriod=Math.min(h(e.minimumUpdatePeriod),30*Math.max(s.maxSegmentDuration,2))),e.availabilityStartTime&&(s.availabilityStartTime=new Date(e.availabilityStartTime).getTime()),e.timeShiftBufferDepth&&(s.timeShiftBufferDepth=h(e.timeShiftBufferDepth)),e.mediaPresentationDuration&&(s.duration=h(e.mediaPresentationDuration));let d="";return e.BaseURL&&(d=r.YO(e.BaseURL)?e.BaseURL[0].value:r.Yj(e.BaseURL)?e.BaseURL:e.BaseURL.value),null!=t&&t.duration&&(s.duration=h(t.duration)),t.BaseURL&&(d=S(d,r.Yj(t.BaseURL)?t.BaseURL:t.BaseURL.value)),(r.YO(t.AdaptationSet)?t.AdaptationSet:[t.AdaptationSet]).forEach(((e,t)=>{let l,h="",f="",L="",R=0,b=0,y=0,v=0,P=0,x="1:1",w="1",A=0,T=d,I="und";e.BaseURL&&(T=S(T,r.Yj(e.BaseURL)?e.BaseURL:e.BaseURL.value)),e.lang&&(I=e.lang),e.mimeType||e.contentType?(h=e.mimeType,f=e.contentType,"video/mp4"===h||"video"===f?(L=e.codecs,R=o()(e.width),b=o()(e.height),e.maxWidth&&(y=o()(e.maxWidth)),e.maxHeight&&(v=o()(e.maxHeight)),e.frameRate&&(P=g(e.frameRate)),x=e.sar,w=e.startWithSAP,A=o()(e.bandwidth)):"audio/mp4"!==h&&"audio"!==f||(L=e.codecs,w=e.startWithSAP,A=o()(e.bandwidth))):(e.maxWidth&&(y=o()(e.maxWidth)),e.maxHeight&&(v=o()(e.maxHeight)),e.frameRate&&(P=g(e.frameRate))),e.ContentProtection&&(l=p(e.ContentProtection)),(r.YO(e.Representation)?e.Representation:[e.Representation]).forEach(((t,d)=>{a.indexOf(t.id)>-1&&(t.id=(n()(a[a.length-1])+1).toString()),a.push(t.id);let g="";const D=[];let B=0,U=s.duration,M=S(i.slice(0,i.lastIndexOf("/")+1),T);if(t.mimeType&&(h=t.mimeType),"video/mp4"===h||"video"===f?(t.codecs&&(L=t.codecs),t.width&&(R=o()(t.width)),t.height&&(b=o()(t.height)),t.maxWidth&&(y=o()(t.maxWidth)),t.maxHeight&&(v=o()(t.maxHeight)),t.frameRate&&(P=o()(t.frameRate)),t.sar&&(x=t.sar),t.startWithSAP&&(w=t.startWithSAP),t.bandwidth&&(A=o()(t.bandwidth))):(t.codecs&&(L=t.codecs),t.startWithSAP&&(w=t.startWithSAP),t.bandwidth&&(A=o()(t.bandwidth))),t.BaseURL&&(M=S(M,r.Yj(t.BaseURL)?t.BaseURL:t.BaseURL.value)),t.ContentProtection&&(l=p(t.ContentProtection)),t.SegmentBase)"video/mp4"===h||"video"===f?s.mediaList.video.push({id:t.id,file:M,mimeType:h,codecs:L,width:R,height:b,maxWidth:y,maxHeight:v,frameRate:P,sar:x,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l}):"audio/mp4"===h||"audio"===f?s.mediaList.audio.push({id:t.id,file:M,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:I}):"application/mp4"!==h&&"text"!==f||s.mediaList.subtitle.push({id:t.id,file:M,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:I});else{let i;if(e.SegmentTemplate&&(i=r.YO(e.SegmentTemplate)?e.SegmentTemplate[0]:e.SegmentTemplate),t.SegmentTemplate&&(i=r.YO(t.SegmentTemplate)?t.SegmentTemplate[0]:t.SegmentTemplate),i){let e=i.startNumber?n()(i.startNumber):1;if(g=i.initialization,B=o()(i.timescale||"1"),i.duration&&!i.SegmentTimeline){U=o()(i.duration);let a=U/B,d=e+Math.ceil((s.duration||a)/a)-1,l=d;if("live"===s.type&&(r.ai(s.availabilityStartTime)||i.presentationTimeOffset)){const t=((s.timestamp||(0,m.A)())-s.availabilityStartTime)/1e3-(i.presentationTimeOffset?n()(i.presentationTimeOffset):0);d=e+Math.floor(t/a),s.timeShiftBufferDepth&&(e=d-Math.ceil(s.timeShiftBufferDepth/a)+1),l=d,("false"===i.availabilityTimeComplete||s.minimumUpdatePeriod>2*s.minBufferTime)&&(d+=Math.ceil(s.minimumUpdatePeriod/a))}for(let n=e;n<=d;n++){const o=a*(n-e);let r=a*(n-e+1);n===d&&s.duration&&(a=s.duration-a*(d-e),r=s.duration),D.push({idx:n,start:o,end:r,url:M+i.media.replace(/\$RepresentationID\$/g,t.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?c(n,+i):(0,u.A)(n))),segmentDuration:a,pending:n>l})}}else if(i.SegmentTimeline&&i.SegmentTimeline.S){const s=r.YO(i.SegmentTimeline.S)?i.SegmentTimeline.S:[i.SegmentTimeline.S];let a=0,d=e;for(let e=0;e<s.length;e++){let r=o()(s[e].d);s[e].t&&(a=o()(s[e].t));let l=1;s[e].r&&(l=n()(s[e].r),-1===l&&U?l=Math.ceil(U*B/r):l+=1);for(let e=0;e<l;e++)D.push({idx:d,start:a/B,end:(a+r)/B,url:M+i.media.replace(/\$RepresentationID\$/g,t.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?c(d,+i):(0,u.A)(d))).replace(/\$Time\$/g,(0,u.A)(a)),segmentDuration:r/B}),d++,a+=r}}}else if(t.SegmentList){const e=r.YO(t.SegmentList.SegmentURL)?t.SegmentList.SegmentURL:[t.SegmentList.SegmentURL];let i=0,s=o()(t.SegmentList.duration);for(let t=0;t<e.length;t++)D.push({idx:t,start:i/B,end:(i+s)/B,url:M+e[t].media,segmentDuration:s/B}),i+=s}"video/mp4"===h||"video"===f?s.mediaList.video.push({id:t.id,baseURL:M,initSegment:M+g.replace(/\$RepresentationID\$/g,t.id).replace(/\$Bandwidth\$/g,(0,u.A)(A)),mediaSegments:D,mimeType:h,codecs:L,width:R,height:b,maxWidth:y,maxHeight:v,frameRate:P,sar:x,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l}):"audio/mp4"===h||"audio"===f?s.mediaList.audio.push({id:t.id,baseURL:M,initSegment:M+g.replace(/\$RepresentationID\$/g,t.id).replace(/\$Bandwidth\$/g,(0,u.A)(A)),mediaSegments:D,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:I}):"application/mp4"!==h&&"text"!==f||s.mediaList.subtitle.push({id:t.id,baseURL:M,initSegment:M+g.replace(/\$RepresentationID\$/g,t.id).replace(/\$Bandwidth\$/g,(0,u.A)(A)),mediaSegments:D,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:I})}}))})),["video","audio"].forEach((e=>{s.mediaList[e].sort(((e,t)=>e.bandwidth-t.bandwidth))})),s}function R(e,t){const i=(s=e,s?(0,d.A)(s,{aloneValueName:"value"}):null).MPD;var s;if("dynamic"===i.type){const e=r.YO(i.Period)?i.Period[i.Period.length-1]:i.Period;return L(i,e,t)}{const e=(r.YO(i.Period)?i.Period:[i.Period]).map((e=>L(i,e,t))),s=e[0];for(let t=1;t<e.length;t++)s.duration+=e[t].duration,e[t].mediaList.video.forEach((e=>{const t=s.mediaList.video.find((t=>e.initSegment&&e.initSegment===t.initSegment||e.id===t.id));var i,n;t?(null!==(i=t.mediaSegments)&&void 0!==i&&i.length&&null!==(n=e.mediaSegments)&&void 0!==n&&n.length&&e.mediaSegments.forEach((e=>{e.start+=t.mediaSegments[t.mediaSegments.length-1].end,e.end+=t.mediaSegments[t.mediaSegments.length-1].end})),t.mediaSegments=(t.mediaSegments||[]).concat(e.mediaSegments||[])):s.mediaList.video.push(e)})),e[t].mediaList.audio.forEach((e=>{const t=s.mediaList.audio.find((t=>e.initSegment&&e.initSegment===t.initSegment||e.id===t.id));var i,n;t?(null!==(i=t.mediaSegments)&&void 0!==i&&i.length&&null!==(n=e.mediaSegments)&&void 0!==n&&n.length&&e.mediaSegments.forEach((e=>{e.start+=t.mediaSegments[t.mediaSegments.length-1].end,e.end+=t.mediaSegments[t.mediaSegments.length-1].end})),t.mediaSegments=(t.mediaSegments||[]).concat(e.mediaSegments||[])):s.mediaList.audio.push(e)})),e[t].mediaList.subtitle.forEach((e=>{const t=s.mediaList.subtitle.find((t=>e.initSegment&&e.initSegment===t.initSegment||e.id===t.id));var i,n;t?(null!==(i=t.mediaSegments)&&void 0!==i&&i.length&&null!==(n=e.mediaSegments)&&void 0!==n&&n.length&&e.mediaSegments.forEach((e=>{e.start+=t.mediaSegments[t.mediaSegments.length-1].end,e.end+=t.mediaSegments[t.mediaSegments.length-1].end})),t.mediaSegments=(t.mediaSegments||[]).concat(e.mediaSegments||[])):s.mediaList.subtitle.push(e)}));return i.mediaPresentationDuration&&(s.duration=h(i.mediaPresentationDuration)),s}}},28800:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(16513),n=i.n(s),a=i(31126);const o={aloneValueName:"_@attribute"},d=[" ","/",'"',"'","<",">"];function r(e,t=o){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 a=i[i.length-1];a&&(e!==t.aloneValueName||null==a.obj[t.aloneValueName]?null==a.obj[e]?a.obj[e]=s:n()(a.obj[e])?a.obj[e].push(s):a.obj[e]=[a.obj[e],s]:a.obj[t.aloneValueName]=[a.obj[t.aloneValueName],{tagName:e,...s}])}function l(t){for(;s<e.length;){if(e[s]===t)return!0;s++}return!1}function u(){m();let t="";for(;s<e.length&&!a.zy(d,e[s]);)t+=e[s],s++;return t}function m(){for(;s<e.length&&/\s|\r|\n/.test(e[s]);)s++}const h=/\s/,c=/'/,g=/"/;function f(){if(s>=e.length)return!0;m();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(){m();let t="";for(;s<e.length&&"<"!==e[s];)t+=e[s],s++;return t}function S(){for(;"<"===e[s];){const t=s;if(s++,m(),"/"!==e[s]){s=t;break}if(s++,u()===i[i.length-1].tag){if(i.length>1){const e=i.pop();r(e.tag,e.obj)}l(">"),s++,m()}else i.pop(),l(">"),s++,m()}}return function n(){if(s>=e.length)return;let a=s;if(m(),"<"!==e[s])return s=a,r(t.aloneValueName,p()),S(),n();let o=l("<");if(!o)return;a=s,s++;const d=u();if(i.push({obj:{},tag:d,start:a}),function(){for(;m(),">"!==e[s]&&"/"!==e[s];){let e=u();if(!e)break;"="===e[e.length-1]?e=e.substring(0,e.length-1):(l("="),s++),r(e,f())}}(),m(),"/"===e[s]){if(s++,i.length>1){const e=i.pop();r(e.tag,e.obj)}return l(">"),s++,S(),n()}o=l(">"),o&&(s++,m(),"<"!==e[s]&&(r(t.aloneValueName,p()),m()),S(),n())}(),{[i[0].tag]:i[0].obj}}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[81],{50081:(e,t,i)=>{i.r(t),i.d(t,{default:()=>S});var s=i(9655),n=i(33793),a=i.n(n),o=i(55906),d=i.n(o),r=i(56719),l=i(72277),u=i(99868),m=i(20163),h=i(92518),c=i(33267),g=i(80155),f=i(20086);const p="src/avnetwork/ioLoader/DashIOLoader.ts";class S extends l.A{constructor(...e){super(...e),(0,s.A)(this,"info",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),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"signal",void 0)}createResource(e){return{type:e,fetchedMap:new(a()),fetchedHistoryListMax:100,fetchedHistoryList:[],loader:null,segmentIndex:0,currentUri:"",selectedIndex:0,segments:[],initSegmentPadding:"",initedSegment:"",sleep:null,lastPendingSegmentFetchTs:0,lastPendingSegmentDuration:0}}addHistory(e,t,i){e.fetchedMap.clear(),e.fetchedHistoryList.length=0;for(let s=0;s<i;s++)e.fetchedMap.set(t[s].url,!0),e.fetchedHistoryList.push(t[s].url);for(;e.fetchedHistoryList.length>=e.fetchedHistoryListMax;)e.fetchedMap.delete(e.fetchedHistoryList.shift())}async fetchMediaPlayList(e){var t,i,s;if(!e){if(this.fetchMediaPlayListPromise)return;this.fetchMediaPlayListPromise=new(d())((t=>{e=t}))}const n={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};null!==(t=this.info.httpOptions)&&void 0!==t&&t.headers&&u.__(this.info.httpOptions.headers,((e,t)=>{n.headers[t]=e})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(n.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(n.referrerPolicy=this.info.httpOptions.referrerPolicy);try{var a;"function"==typeof AbortController&&(this.signal=new AbortController);const t=await fetch(this.info.url,{...n,signal:null===(a=this.signal)||void 0===a?void 0:a.signal});this.signal=null;const i=await t.text();this.mediaPlayList=(0,h.A)(i,this.info.url),this.minBuffer=this.mediaPlayList.minBufferTime,"vod"===this.mediaPlayList.type?this.options.isLive=!1:this.options.isLive=!0;const s=(e,t,i)=>{let s=0,n=0;for(let e=t.length-2;e>=0;e--)if(!0!==t[e].pending&&(n+=t[e].segmentDuration,n>=i)){s=e;break}e.lastPendingSegmentFetchTs=this.mediaPlayList.maxSegmentDuration,e.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration,e.fetchedHistoryListMax=Math.max(e.fetchedHistoryListMax,t.length+1),this.addHistory(e,t,s)};if(this.mediaPlayList.mediaList.audio.length){if(this.options.preferAudioCodec||this.options.preferAudioLang){let e=!1,t=!1,i=this.mediaPlayList.mediaList.audio.some((e=>e.codecs&&e.codecs.indexOf(this.options.preferAudioCodec)>=0));this.mediaPlayList.mediaList.audio.forEach(((s,n)=>{this.options.preferAudioCodec&&i&&s.codecs&&-1===s.codecs.indexOf(this.options.preferAudioCodec)||(e||(this.audioResource.selectedIndex=n,e=!0),s.lang&&this.options.preferAudioLang&&s.lang.indexOf(this.options.preferAudioLang)>=0&&!t&&(this.audioResource.selectedIndex=n,s.lang===this.options.preferAudioLang&&(t=!0)))}))}const e=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];e.file?this.audioResource.segments=[{url:e.file}]:this.options.isLive&&this.audioResource.initedSegment===e.initSegment?(this.audioResource.segments=e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration}))),this.audioResource.lastPendingSegmentFetchTs=this.mediaPlayList.timestamp,this.audioResource.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration):(this.options.isLive&&s(this.audioResource,e.mediaSegments,this.minBuffer),this.audioResource.segments=[{url:e.initSegment}].concat(e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.audioResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.video.length){if(this.options.preferResolution||this.options.preferVideoCodec){let e=1,t=1;if(this.options.preferResolution){const i=this.options.preferResolution.split("*");e=+i[0]||1,t=+i[1]||1}let i=!1,s=1/0,n=this.mediaPlayList.mediaList.video.some((e=>e.codecs&&e.codecs.indexOf(this.options.preferVideoCodec)>=0));this.mediaPlayList.mediaList.video.forEach(((a,o)=>{if(!(this.options.preferVideoCodec&&n&&a.codecs&&-1===a.codecs.indexOf(this.options.preferVideoCodec))&&(i||(this.videoResource.selectedIndex=o,i=!0),a.width&&a.height&&this.options.preferResolution)){const i=1===e?1:a.width,n=1===t?1:a.height;Math.abs(i*n-e*t)<s&&(s=Math.abs(i*n-e*t),this.videoResource.selectedIndex=o)}}))}const e=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];e.file?this.videoResource.segments=[{url:e.file}]:this.options.isLive&&this.videoResource.initedSegment===e.initSegment?(this.videoResource.segments=e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration}))),this.videoResource.lastPendingSegmentFetchTs=this.mediaPlayList.maxSegmentDuration,this.videoResource.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration):(this.options.isLive&&s(this.videoResource,e.mediaSegments,this.minBuffer),this.videoResource.segments=[{url:e.initSegment}].concat(e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.videoResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.subtitle.length){if(this.options.preferSubtitleCodec||this.options.preferSubtitleLang){let e=!1,t=!1,i=this.mediaPlayList.mediaList.subtitle.some((e=>e.codecs&&e.codecs.indexOf(this.options.preferSubtitleCodec)>=0));this.mediaPlayList.mediaList.subtitle.forEach(((s,n)=>{this.options.preferSubtitleCodec&&i&&s.codecs&&-1===s.codecs.indexOf(this.options.preferSubtitleCodec)||(e||(this.subtitleResource.selectedIndex=n,e=!0),s.lang&&this.options.preferSubtitleLang&&s.lang.indexOf(this.options.preferSubtitleLang)>=0&&!t&&(this.subtitleResource.selectedIndex=n,s.lang===this.options.preferSubtitleLang&&(t=!0)))}))}const e=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];e.file?this.subtitleResource.segments=[{url:e.file}]:this.options.isLive&&this.subtitleResource.initedSegment===e.initSegment?(this.subtitleResource.segments=e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration}))),this.subtitleResource.lastPendingSegmentFetchTs=this.mediaPlayList.maxSegmentDuration,this.subtitleResource.lastPendingSegmentDuration=this.mediaPlayList.maxSegmentDuration):(this.options.isLive&&s(this.subtitleResource,e.mediaSegments,this.minBuffer),this.subtitleResource.segments=[{url:e.initSegment}].concat(e.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.subtitleResource.initedSegment=e.initSegment)}return e(),this.fetchMediaPlayListPromise=null,this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.aborted)return this.status=3,void e();if(this.retryCount<this.options.retryCount)return this.retryCount++,m.z3(`failed fetch mpd file ${t}, retry(${this.retryCount}/3)`,p,400),await new r.A(2===this.status?this.options.retryInterval:5),this.fetchMediaPlayList(e);this.status=3,e(),m.h2(`DashLoader: exception, fetch slice error, error: ${t.message}`,p,408)}}async open(e){return 2===this.status?0:0!==this.status?f.lh:(this.info=e,this.videoResource=this.createResource(0),this.audioResource=this.createResource(1),this.subtitleResource=this.createResource(3),this.status=1,this.retryCount=0,this.aborted=!1,await this.fetchMediaPlayList(),0)}async readResource(e,t){let i=0;if(t.loader){if(i=await t.loader.read(e),-1048576!==i||this.aborted)return i;if(this.options.isLive)t.fetchedMap.set(t.currentUri,!0),t.fetchedHistoryList.length===t.fetchedHistoryListMax&&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.url)));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&&(t.sleep=new r.A(i),await t.sleep,t.sleep=null,this.aborted))return-1048576;if(this.fetchMediaPlayListPromise){if(await this.fetchMediaPlayListPromise,3===this.status||this.aborted)return-1048576}else if(await this.fetchMediaPlayList(),this.aborted)return-1048576;return this.readResource(e,t)}if(t.currentUri=i[0].url,this.options.isLive&&i[0].pending){if(t.lastPendingSegmentFetchTs){const e=t.lastPendingSegmentDuration-((0,g.A)()-t.lastPendingSegmentFetchTs)/1e3;if(e>0&&(t.sleep=new r.A(e),await t.sleep,t.sleep=null,this.aborted))return-1048576}t.lastPendingSegmentFetchTs=(0,g.A)(),t.lastPendingSegmentDuration=i[0].duration||this.mediaPlayList.maxSegmentDuration}return t.loader=new c.A(u.X$({},this.options,{disableSegment:!0,loop:!1,enableBandwidthReader:0===t.type})),await t.loader.open(u.X$({},this.info,{url:t.currentUri}),{from:0,to:-1}),t.loader.read(e)}return t.loader=new c.A(u.X$({},this.options,{disableSegment:!0,loop:!1,enableBandwidthReader:0===t.type})),t.initSegmentPadding?(await t.loader.open(u.X$({},this.info,{url:t.initSegmentPadding}),{from:0,to:-1}),t.initSegmentPadding=null,t.segmentIndex--):await t.loader.open(u.X$({},this.info,{url:t.segments[t.segmentIndex].url}),{from:0,to:-1}),t.loader.read(e)}async read(e,t){return 1===t.mediaType?this.readResource(e,this.audioResource):0===t.mediaType?this.readResource(e,this.videoResource):3===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 n=1===t.type?this.mediaPlayList.mediaList.audio:0===t.type?this.mediaPlayList.mediaList.video:this.mediaPlayList.mediaList.subtitle,a=n[t.selectedIndex].mediaSegments;if(null!=a&&a.length){e=-1;for(let t=0;t<a.length;t++)if(s>=1e3*a[t].start&&s<1e3*a[t].end){e=t;break}-1===e&&(e=a.length-1)}t.segmentIndex=e+(n[t.selectedIndex].initSegment?1:0);let o="";0===t.type?o=this.mediaPlayList.mediaList.video[t.selectedIndex].initSegment:1===t.type?o=this.mediaPlayList.mediaList.audio[t.selectedIndex].initSegment:3===t.type&&(o=this.mediaPlayList.mediaList.subtitle[t.selectedIndex].initSegment),o&&o===i&&(t.initSegmentPadding=o)}}async seek(e,t){return 1===t.mediaType&&this.audioResource.loader&&await this.seekResource(e,this.audioResource),0===t.mediaType&&this.videoResource.loader&&await this.seekResource(e,this.videoResource),3===t.mediaType&&this.subtitleResource.loader&&await this.seekResource(e,this.subtitleResource),4===this.status&&(this.status=2),this.aborted=!1,0}async size(){return BigInt(0)}abortSleep(){this.aborted=!0,this.videoResource.loader&&this.videoResource.loader.abortSleep(),this.videoResource.sleep&&(this.videoResource.sleep.stop(),this.videoResource.sleep=null),this.audioResource.loader&&this.audioResource.loader.abortSleep(),this.audioResource.sleep&&(this.audioResource.sleep.stop(),this.audioResource.sleep=null),this.subtitleResource.loader&&this.subtitleResource.loader.abortSleep(),this.subtitleResource.sleep&&(this.subtitleResource.sleep.stop(),this.subtitleResource.sleep=null)}async abort(){this.abortSleep(),this.signal&&this.signal.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,codec:e.codecs,bandwidth:e.bandwidth}))),selectedIndex:this.videoResource.selectedIndex}:{list:[],selectedIndex:0}}getAudioList(){return this.hasAudio()?{list:this.mediaPlayList.mediaList.audio.map((e=>({lang:e.lang,codec:e.codecs,bandwidth:e.bandwidth}))),selectedIndex:this.audioResource.selectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.hasSubtitle()?{list:this.mediaPlayList.mediaList.subtitle.map((e=>({lang:e.lang,codec: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];if(t.file)this.videoResource.segments=[{url:t.file}];else{if(this.options.isLive){let e=this.videoResource.segmentIndex;this.videoResource.segments.find(((t,i)=>{if(t.url===this.videoResource.currentUri)return e=i,!0})),this.addHistory(this.videoResource,t.mediaSegments,e+1)}this.videoResource.segments=[{url:t.initSegment}].concat(t.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.videoResource.initSegmentPadding=t.initSegment}if(t.mediaSegments&&this.videoResource.segmentIndex-(t.initSegment?1:0)<t.mediaSegments.length-1)return t.mediaSegments[this.videoResource.segmentIndex+(t.initSegment?0:1)].start}return-1}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];if(t.file)this.audioResource.segments=[{url:t.file}];else{if(this.options.isLive){let e=this.audioResource.segmentIndex;this.audioResource.segments.find(((t,i)=>{if(t.url===this.audioResource.currentUri)return e=i,!0})),this.addHistory(this.audioResource,t.mediaSegments,e+1)}this.audioResource.segments=[{url:t.initSegment}].concat(t.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.audioResource.initSegmentPadding=t.initSegment}if(t.mediaSegments&&this.audioResource.segmentIndex-(t.initSegment?1:0)<t.mediaSegments.length-1)return t.mediaSegments[this.audioResource.segmentIndex+(t.initSegment?0:1)].start}return-1}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];if(t.file)this.subtitleResource.segments=[{url:t.file}];else{if(this.options.isLive){let e=this.subtitleResource.segmentIndex;this.subtitleResource.segments.find(((t,i)=>{if(t.url===this.subtitleResource.currentUri)return e=i,!0})),this.addHistory(this.subtitleResource,t.mediaSegments,e+1)}this.subtitleResource.segments=[{url:t.initSegment}].concat(t.mediaSegments.map((e=>({url:e.url,pending:e.pending,duration:e.segmentDuration})))),this.subtitleResource.initSegmentPadding=t.initSegment}if(t.mediaSegments&&this.subtitleResource.segmentIndex-(t.initSegment?1:0)<t.mediaSegments.length-1)return t.mediaSegments[this.subtitleResource.segmentIndex+(t.initSegment?0:1)].start}return-1}getCurrentProtection(e){return 1===e?this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex].protection:0===e?this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex].protection:void 0}getMinBuffer(){return this.minBuffer}}},92518:(e,t,i)=>{i.d(t,{A:()=>R});var s=i(25116),n=i.n(s),a=i(6235),o=i.n(a),d=i(28800),r=i(68483),l=i(99868),u=i(97487),m=i(80155);function h(e){const t=e.match(/^PT?(?:(\d+)Y)?(?:(\d+)D)?(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?$/);if(!t)throw new Error("Invalid DASH PT duration: "+e);const[,i,s,a,d,r]=t;return 3600*n()(i||"0")*24*365+3600*n()(s||"0")*24+3600*n()(a||"0")+60*n()(d||"0")+o()(r||"0")}function c(e,t){const i=(0,u.A)(e);return i.length>=t?i:"0".repeat(t-i.length)+i}function g(e){if(!e)return 0;if(e.indexOf("/")>-1){const t=e.split("/");return o()(t[0])/o()(t[1])}return o()(e)}function f(e){e=e.replaceAll("-","");const t=[];for(let i=0;i<e.length;i+=2)t.push(+`0x${e.substring(i,i+2)}`);return new Uint8Array(t)}function p(e){let t={};return e.forEach((e=>{const i={};if(l.__(e,((e,t)=>{i[t.toLocaleLowerCase()]=e})),i["cenc:default_kid"]&&(t.kid=f(i["cenc:default_kid"]),t.scheme=i.value),i.schemeiduri){const e=i.schemeiduri.split(":");3===e.length&&"urn"===e[0]&&"uuid"===e[1]&&(t.systemId=f(e[2]))}i["clearkey:laurl"]&&(t.url=i["clearkey:laurl"].value),i["dashif:laurl"]&&(t.url=i["dashif:laurl"].value)})),t}function S(e,t){return/^https?:\/\//.test(t)?t:e+t}function L(e,t,i){const s={mediaList:{audio:[],video:[],subtitle:[]},type:"live",isEnd:!1,duration:0,minBufferTime:0,maxSegmentDuration:0,minimumUpdatePeriod:0,timeShiftBufferDepth:0,timestamp:(0,m.A)()},a=[];"static"===e.type&&(s.type="vod",s.isEnd=!0),e.minBufferTime&&(s.minBufferTime=h(e.minBufferTime)),e.maxSegmentDuration&&(s.maxSegmentDuration=h(e.maxSegmentDuration)),e.minimumUpdatePeriod&&(s.minimumUpdatePeriod=Math.min(h(e.minimumUpdatePeriod),30*Math.max(s.maxSegmentDuration,2))),e.availabilityStartTime&&(s.availabilityStartTime=new Date(e.availabilityStartTime).getTime()),e.timeShiftBufferDepth&&(s.timeShiftBufferDepth=h(e.timeShiftBufferDepth)),e.mediaPresentationDuration&&(s.duration=h(e.mediaPresentationDuration));let d="";return e.BaseURL&&(d=r.YO(e.BaseURL)?e.BaseURL[0].value:r.Yj(e.BaseURL)?e.BaseURL:e.BaseURL.value),null!=t&&t.duration&&(s.duration=h(t.duration)),t.BaseURL&&(d=S(d,r.Yj(t.BaseURL)?t.BaseURL:t.BaseURL.value)),(r.YO(t.AdaptationSet)?t.AdaptationSet:[t.AdaptationSet]).forEach(((e,t)=>{let l,h="",f="",L="",R=0,b=0,y=0,v=0,P=0,x="1:1",w="1",A=0,I=d,T="und";e.BaseURL&&(I=S(I,r.Yj(e.BaseURL)?e.BaseURL:e.BaseURL.value)),e.lang&&(T=e.lang),e.mimeType||e.contentType?(h=e.mimeType,f=e.contentType,"video/mp4"===h||"video"===f?(L=e.codecs,R=o()(e.width),b=o()(e.height),e.maxWidth&&(y=o()(e.maxWidth)),e.maxHeight&&(v=o()(e.maxHeight)),e.frameRate&&(P=g(e.frameRate)),x=e.sar,w=e.startWithSAP,A=o()(e.bandwidth)):"audio/mp4"!==h&&"audio"!==f||(L=e.codecs,w=e.startWithSAP,A=o()(e.bandwidth))):(e.maxWidth&&(y=o()(e.maxWidth)),e.maxHeight&&(v=o()(e.maxHeight)),e.frameRate&&(P=g(e.frameRate))),e.ContentProtection&&(l=p(e.ContentProtection)),(r.YO(e.Representation)?e.Representation:[e.Representation]).forEach(((t,d)=>{a.indexOf(t.id)>-1&&(t.id=(n()(a[a.length-1])+1).toString()),a.push(t.id);let g="";const D=[];let B=0,U=s.duration,M=S(i.slice(0,i.lastIndexOf("/")+1),I);if(t.mimeType&&(h=t.mimeType),"video/mp4"===h||"video"===f?(t.codecs&&(L=t.codecs),t.width&&(R=o()(t.width)),t.height&&(b=o()(t.height)),t.maxWidth&&(y=o()(t.maxWidth)),t.maxHeight&&(v=o()(t.maxHeight)),t.frameRate&&(P=o()(t.frameRate)),t.sar&&(x=t.sar),t.startWithSAP&&(w=t.startWithSAP),t.bandwidth&&(A=o()(t.bandwidth))):(t.codecs&&(L=t.codecs),t.startWithSAP&&(w=t.startWithSAP),t.bandwidth&&(A=o()(t.bandwidth))),t.BaseURL&&(M=S(M,r.Yj(t.BaseURL)?t.BaseURL:t.BaseURL.value)),t.ContentProtection&&(l=p(t.ContentProtection)),t.SegmentBase)"video/mp4"===h||"video"===f?s.mediaList.video.push({id:t.id,file:M,mimeType:h,codecs:L,width:R,height:b,maxWidth:y,maxHeight:v,frameRate:P,sar:x,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l}):"audio/mp4"===h||"audio"===f?s.mediaList.audio.push({id:t.id,file:M,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:T}):"application/mp4"!==h&&"text"!==f||s.mediaList.subtitle.push({id:t.id,file:M,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:T});else{let i;if(e.SegmentTemplate&&(i=r.YO(e.SegmentTemplate)?e.SegmentTemplate[0]:e.SegmentTemplate),t.SegmentTemplate&&(i=r.YO(t.SegmentTemplate)?t.SegmentTemplate[0]:t.SegmentTemplate),i){let e=i.startNumber?n()(i.startNumber):1;if(g=i.initialization,B=o()(i.timescale||"1"),i.duration&&!i.SegmentTimeline){U=o()(i.duration);let a=U/B,d=e+Math.ceil((s.duration||a)/a)-1,l=d;if("live"===s.type&&(r.ai(s.availabilityStartTime)||i.presentationTimeOffset)){const t=((s.timestamp||(0,m.A)())-s.availabilityStartTime)/1e3-(i.presentationTimeOffset?n()(i.presentationTimeOffset):0);d=e+Math.floor(t/a),s.timeShiftBufferDepth&&(e=d-Math.ceil(s.timeShiftBufferDepth/a)+1),l=d,("false"===i.availabilityTimeComplete||s.minimumUpdatePeriod>2*s.minBufferTime)&&(d+=Math.ceil(s.minimumUpdatePeriod/a))}for(let n=e;n<=d;n++){const o=a*(n-e);let r=a*(n-e+1);n===d&&s.duration&&(a=s.duration-a*(d-e),r=s.duration),D.push({idx:n,start:o,end:r,url:M+i.media.replace(/\$RepresentationID\$/g,t.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?c(n,+i):(0,u.A)(n))),segmentDuration:a,pending:n>l})}}else if(i.SegmentTimeline&&i.SegmentTimeline.S){const s=r.YO(i.SegmentTimeline.S)?i.SegmentTimeline.S:[i.SegmentTimeline.S];let a=0,d=e;for(let e=0;e<s.length;e++){let r=o()(s[e].d);s[e].t&&(a=o()(s[e].t));let l=1;s[e].r&&(l=n()(s[e].r),-1===l&&U?l=Math.ceil(U*B/r):l+=1);for(let e=0;e<l;e++)D.push({idx:d,start:a/B,end:(a+r)/B,url:M+i.media.replace(/\$RepresentationID\$/g,t.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?c(d,+i):(0,u.A)(d))).replace(/\$Time\$/g,(0,u.A)(a)),segmentDuration:r/B}),d++,a+=r}}}else if(t.SegmentList){const e=r.YO(t.SegmentList.SegmentURL)?t.SegmentList.SegmentURL:[t.SegmentList.SegmentURL];let i=0,s=o()(t.SegmentList.duration);for(let t=0;t<e.length;t++)D.push({idx:t,start:i/B,end:(i+s)/B,url:M+e[t].media,segmentDuration:s/B}),i+=s}"video/mp4"===h||"video"===f?s.mediaList.video.push({id:t.id,baseURL:M,initSegment:M+g.replace(/\$RepresentationID\$/g,t.id).replace(/\$Bandwidth\$/g,(0,u.A)(A)),mediaSegments:D,mimeType:h,codecs:L,width:R,height:b,maxWidth:y,maxHeight:v,frameRate:P,sar:x,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l}):"audio/mp4"===h||"audio"===f?s.mediaList.audio.push({id:t.id,baseURL:M,initSegment:M+g.replace(/\$RepresentationID\$/g,t.id).replace(/\$Bandwidth\$/g,(0,u.A)(A)),mediaSegments:D,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:T}):"application/mp4"!==h&&"text"!==f||s.mediaList.subtitle.push({id:t.id,baseURL:M,initSegment:M+g.replace(/\$RepresentationID\$/g,t.id).replace(/\$Bandwidth\$/g,(0,u.A)(A)),mediaSegments:D,mimeType:h,codecs:L,startWithSAP:"1"===w,bandwidth:A,timescale:B,duration:U,protection:l,lang:T})}}))})),["video","audio"].forEach((e=>{s.mediaList[e].sort(((e,t)=>e.bandwidth-t.bandwidth))})),s}function R(e,t){const i=(s=e,s?(0,d.A)(s,{aloneValueName:"value"}):null).MPD;var s;if("dynamic"===i.type){const e=r.YO(i.Period)?i.Period[i.Period.length-1]:i.Period;return L(i,e,t)}{const e=(r.YO(i.Period)?i.Period:[i.Period]).map((e=>L(i,e,t))),s=e[0];for(let t=1;t<e.length;t++)s.duration+=e[t].duration,e[t].mediaList.video.forEach((e=>{const t=s.mediaList.video.find((t=>e.initSegment&&e.initSegment===t.initSegment||e.id===t.id));var i,n;t?(null!==(i=t.mediaSegments)&&void 0!==i&&i.length&&null!==(n=e.mediaSegments)&&void 0!==n&&n.length&&e.mediaSegments.forEach((e=>{e.start+=t.mediaSegments[t.mediaSegments.length-1].end,e.end+=t.mediaSegments[t.mediaSegments.length-1].end})),t.mediaSegments=(t.mediaSegments||[]).concat(e.mediaSegments||[])):s.mediaList.video.push(e)})),e[t].mediaList.audio.forEach((e=>{const t=s.mediaList.audio.find((t=>e.initSegment&&e.initSegment===t.initSegment||e.id===t.id));var i,n;t?(null!==(i=t.mediaSegments)&&void 0!==i&&i.length&&null!==(n=e.mediaSegments)&&void 0!==n&&n.length&&e.mediaSegments.forEach((e=>{e.start+=t.mediaSegments[t.mediaSegments.length-1].end,e.end+=t.mediaSegments[t.mediaSegments.length-1].end})),t.mediaSegments=(t.mediaSegments||[]).concat(e.mediaSegments||[])):s.mediaList.audio.push(e)})),e[t].mediaList.subtitle.forEach((e=>{const t=s.mediaList.subtitle.find((t=>e.initSegment&&e.initSegment===t.initSegment||e.id===t.id));var i,n;t?(null!==(i=t.mediaSegments)&&void 0!==i&&i.length&&null!==(n=e.mediaSegments)&&void 0!==n&&n.length&&e.mediaSegments.forEach((e=>{e.start+=t.mediaSegments[t.mediaSegments.length-1].end,e.end+=t.mediaSegments[t.mediaSegments.length-1].end})),t.mediaSegments=(t.mediaSegments||[]).concat(e.mediaSegments||[])):s.mediaList.subtitle.push(e)}));return i.mediaPresentationDuration&&(s.duration=h(i.mediaPresentationDuration)),s}}},28800:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(16513),n=i.n(s),a=i(31126);const o={aloneValueName:"_@attribute"},d=[" ","/",'"',"'","<",">"];function r(e,t=o){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 a=i[i.length-1];a&&(e!==t.aloneValueName||null==a.obj[t.aloneValueName]?null==a.obj[e]?a.obj[e]=s:n()(a.obj[e])?a.obj[e].push(s):a.obj[e]=[a.obj[e],s]:a.obj[t.aloneValueName]=[a.obj[t.aloneValueName],{tagName:e,...s}])}function l(t){for(;s<e.length;){if(e[s]===t)return!0;s++}return!1}function u(){m();let t="";for(;s<e.length&&!a.zy(d,e[s]);)t+=e[s],s++;return t}function m(){for(;s<e.length&&/\s|\r|\n/.test(e[s]);)s++}const h=/\s/,c=/'/,g=/"/;function f(){if(s>=e.length)return!0;m();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(){m();let t="";for(;s<e.length&&"<"!==e[s];)t+=e[s],s++;return t}function S(){for(;"<"===e[s];){const t=s;if(s++,m(),"/"!==e[s]){s=t;break}if(s++,u()===i[i.length-1].tag){if(i.length>1){const e=i.pop();r(e.tag,e.obj)}l(">"),s++,m()}else i.pop(),l(">"),s++,m()}}return function n(){if(s>=e.length)return;let a=s;if(m(),"<"!==e[s])return s=a,r(t.aloneValueName,p()),S(),n();let o=l("<");if(!o)return;a=s,s++;const d=u();if(i.push({obj:{},tag:d,start:a}),function(){for(;m(),">"!==e[s]&&"/"!==e[s];){let e=u();if(!e)break;"="===e[e.length-1]?e=e.substring(0,e.length-1):(l("="),s++),r(e,f())}}(),m(),"/"===e[s]){if(s++,i.length>1){const e=i.pop();r(e.tag,e.obj)}return l(">"),s++,S(),n()}o=l(">"),o&&(s++,m(),"<"!==e[s]&&(r(t.aloneValueName,p()),m()),S(),n())}(),{[i[0].tag]:i[0].obj}}}}]);
|
package/dist/umd/814.avplayer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[814],{38037:(e,t,a)=>{a.d(t,{A:()=>b});var i=a(9655),s=a(16566),n=a(36311),r=a(66219),o=a(17641),h=a(57533),c=a(41321),d=a(20163),l=a(20086),f=a(89378),p=a(35497),u=a(69663),g=a(1140),m=a(37142),A=a(68483),I=a(64310);class b extends h.A{constructor(...e){super(...e),(0,i.A)(this,"streamMuxConfig",void 0),(0,i.A)(this,"caches",void 0),(0,i.A)(this,"pendingItem",void 0)}init(e,t){return super.init(e,t),this.caches=[],this.streamMuxConfig={profile:f.N_,sampleRate:f.N_,channels:f.N_},0}sendAVPacket(e){let t=0,a=s.f[17](e+16)!==f.Dh?s.f[17](e+16):s.f[17](e+8),i=(0,c.s3)(s.f[20](e+24),s.f[15](e+28)).slice();for(this.pendingItem&&(this.pendingItem.buffer=(0,I.A)(Uint8Array,[this.pendingItem.buffer,i.subarray(0,this.pendingItem.miss)]),i=i.subarray(this.pendingItem.miss),this.caches.push(this.pendingItem),this.pendingItem=null);t<i.length;){const h=p.Bq(i.subarray(t));if(A.ai(h)){let e=t+1;for(;e<i.length-1;e++)if(4095==(i[e]<<4|i[e+1]>>4)){t=e;break}if(e<i.length-1)continue;return d.z3("AACADTSParser parse failed","src/avformat/bsf/aac/ADTS2RawFilter.ts",108),l.LR}const m={dts:a,buffer:null,extradata:null,duration:f.N_,pos:s.f[17](e+56)};m.buffer=i.subarray(t+h.headerLength,t+h.headerLength+h.framePayloadLength),this.streamMuxConfig.profile=h.profile,this.streamMuxConfig.sampleRate=h.sampleRate,this.streamMuxConfig.channels=h.channels;const I=s.f[15](this.inCodecpar+48)!==this.streamMuxConfig.profile||s.f[15](this.inCodecpar+136)!==this.streamMuxConfig.sampleRate||s.f[15](this.inCodecpar+116)!==this.streamMuxConfig.channels,b=(0,u.k)(BigInt(Math.floor(1024*(h.numberOfRawDataBlocksInFrame+1)/this.streamMuxConfig.sampleRate*f.SF)),f.KR,this.inTimeBase);if(m.duration=Number(b),I){n.M[15](this.inCodecpar+48,this.streamMuxConfig.profile),n.M[15](this.inCodecpar+136,this.streamMuxConfig.sampleRate),n.M[15](this.inCodecpar+116,this.streamMuxConfig.channels);const e=(0,p.Ij)((0,o.A)(this.inCodecpar,r.A));s.f[20](this.inCodecpar+12)&&(0,g.Eb)(s.f[20](this.inCodecpar+12)),n.M[20](this.inCodecpar+12,(0,g.sY)(e.length)),(0,c.lW)(s.f[20](this.inCodecpar+12),e.length,e),n.M[15](this.inCodecpar+16,e.length),m.extradata=e}m.buffer.length<h.framePayloadLength?this.pendingItem={...m,miss:h.framePayloadLength-m.buffer.length}:this.caches.push(m),t+=h.aacFrameLength,a+=b}return 0}receiveAVPacket(e){if(this.caches.length){(0,m.Up)(e);const t=this.caches.shift(),a=(0,g.sY)(t.buffer.length);if((0,c.lW)(a,t.buffer.length,t.buffer),(0,m.NX)(e,a,t.buffer.length),n.M[17](e+16,t.dts),n.M[17](e+8,t.dts),n.M[17](e+56,t.pos),n.M[17](e+48,BigInt(Math.floor(t.duration))),n.M[15](e+36,1|s.f[15](e+36)),t.extradata){const a=(0,g.sY)(t.extradata.length);(0,c.lW)(a,t.extradata.length,t.extradata),(0,m.Ow)(e,1,a,t.extradata.length)}return 0}return l.LT}reset(){return this.pendingItem=null,this.caches.length=0,0}}},89984:(e,t,a)=>{a.d(t,{A:()=>s});var i=a(9655);class s{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},88441:(e,t,a)=>{a.d(t,{A:()=>o});var i=a(89378),s=a(20163),n=a(20086);const r="src/avformat/formats/mpegts/function/parsePES.ts";function o(e){const t=e.data,a=t[3],o=t[4]<<8|t[5];let h=0,c=0,d=0;if(188!==a&&190!==a&&191!==a&&240!==a&&241!==a&&255!==a&&242!==a&&248!==a){let a=i.Dh,l=i.Dh;for(;;){if(6+c>=t.length)return n.LR;if(d=t[6+c],255!==d)break;c++}if(64==(192&d)&&(c+=2,d=t[6+c]),32==(224&d))h+=5,a=a=BigInt(Math.floor(536870912*(14&t[6+c])+4194304*(255&t[7+c])+16384*(254&t[8+c])+128*(255&t[9+c])+(254&t[10+c])/2)),16&d?(l=BigInt(Math.floor(536870912*(14&t[11+c])+4194304*(255&t[12+c])+16384*(254&t[13+c])+128*(255&t[14+c])+(254&t[15+c])/2)),h+=5):l=a;else if(128==(192&d)){const e=(192&t[7+c])>>>6;h=3+t[8+c],2!==e&&3!==e||(a=BigInt(Math.floor(536870912*(14&t[9+c])+4194304*(255&t[10+c])+16384*(254&t[11+c])+128*(255&t[12+c])+(254&t[13+c])/2)),l=3===e?BigInt(Math.floor(536870912*(14&t[14+c])+4194304*(255&t[15+c])+16384*(254&t[16+c])+128*(255&t[17+c])+(254&t[18+c])/2)):a)}else{if(15!==d)return s.z3("invalid data",r,122),n.LR;h=1}e.dts=l,e.pts=a;const f=6+c+h;let p=0;if(0!==o){if(o<c+h)return s.z3("Malformed PES: PES_packet_length < 3 + PES_header_data_length",r,134),n.LR;p=o-(c+h),f+(t.byteLength-f)!=o+6&&(s.R8("PES packet size mismatch",r,139),e.flags|=2)}else p=t.byteLength-f;e.payload=t.subarray(f,f+p)}else if((188===a||191===a||240===a||241===a||255===a||242===a||248===a)&&6===e.streamId){const a=6;let i=0;i=0!==o?o:t.byteLength-a,e.payload=t.subarray(a,a+i)}return 0}},84216:(e,t,a)=>{a.d(t,{Cd:()=>d,I4:()=>f,am:()=>h,kJ:()=>l,pi:()=>c,xf:()=>p});var i=a(9655),s=a(33793),n=a.n(s),r=a(89378);class o{constructor(){(0,i.A)(this,"discontinuityIndicator",0),(0,i.A)(this,"randomAccessIndicator",0),(0,i.A)(this,"elementaryStreamPriorityIndicator",0),(0,i.A)(this,"pcrFlag",0),(0,i.A)(this,"opcrFlag",0),(0,i.A)(this,"splicingPointFlag",0),(0,i.A)(this,"transportPrivateDataFlag",0),(0,i.A)(this,"adaptationFieldExtensionFlag",0),(0,i.A)(this,"pcr",BigInt(0)),(0,i.A)(this,"opcr",BigInt(0)),(0,i.A)(this,"spliceCountDown",0),(0,i.A)(this,"transportPrivateData",null),(0,i.A)(this,"extension",null)}}class h{constructor(){(0,i.A)(this,"pos",r.Dh),(0,i.A)(this,"payloadUnitStartIndicator",0),(0,i.A)(this,"transportPriority",0),(0,i.A)(this,"pid",r.N_),(0,i.A)(this,"adaptationFieldControl",0),(0,i.A)(this,"continuityCounter",0),(0,i.A)(this,"transportScramblingControl",0),(0,i.A)(this,"adaptationFieldInfo",new o),(0,i.A)(this,"payload",null)}}class c{constructor(){(0,i.A)(this,"slices",[]),(0,i.A)(this,"totalLength",0),(0,i.A)(this,"expectedLength",r.N_),(0,i.A)(this,"randomAccessIndicator",0),(0,i.A)(this,"pid",r.N_),(0,i.A)(this,"streamType",0),(0,i.A)(this,"pos",r.Dh)}}class d{constructor(){(0,i.A)(this,"versionNumber",0),(0,i.A)(this,"networkPid",r.N_),(0,i.A)(this,"program2PmtPid",new(n()))}}class l{constructor(){(0,i.A)(this,"tag",void 0),(0,i.A)(this,"buffer",void 0)}}class f{constructor(){(0,i.A)(this,"versionNumber",0),(0,i.A)(this,"programNumber",0),(0,i.A)(this,"pcrPid",0),(0,i.A)(this,"pid2StreamType",new(n())),(0,i.A)(this,"pid2ESDescriptor",new(n()))}}class p{constructor(){(0,i.A)(this,"pid",r.N_),(0,i.A)(this,"streamType",0),(0,i.A)(this,"streamId",r.N_),(0,i.A)(this,"dts",r.Dh),(0,i.A)(this,"pts",r.Dh),(0,i.A)(this,"pos",r.Dh),(0,i.A)(this,"payload",null),(0,i.A)(this,"data",null),(0,i.A)(this,"randomAccessIndicator",0),(0,i.A)(this,"flags",void 0)}}},45372:(e,t,a)=>{a.d(t,{d:()=>r});var i=a(31126),s=a(69663),n=a(89378);function r(e,t,a){let r=BigInt(0);return i.__(e,(e=>{r+=e.codecpar.bitrate*(0,s.k)(t,a,n.i0)/BigInt(8e3)})),r}},59258:(e,t,a)=>{a.d(t,{A:()=>l});var i=a(16566),s=(a(51308),a(89378)),n=a(69663),r=a(45372),o=a(37142),h=a(20086),c=a(20163);const d="src/avformat/function/seekInBytes.ts";async function l(e,t,a,l,f,p){const u=e.ioReader.getPos(),g=await e.ioReader.fileSize();let m=s.Dh,A=a;t.startTime!==s.Dh?A-=t.startTime:A-=t.firstDTS;const I=(0,n.k)(a,t.timeBase,s.i0);if(I<BigInt(1e4))return c.Yz(`seek pts is earlier then 10s, seek to first packet pos(${l}) directly`,d,63),await e.ioReader.seek(l),u;let b=(0,r.d)(e.streams,A,t.timeBase);const y=g-(0,r.d)(e.streams,BigInt(1e4),s.i0),k=(0,r.d)(e.streams,BigInt(1e4),s.i0);if(b>y&&(b=y),b<l)return await e.ioReader.seek(l),u;const C=(0,o._5)();let x=g,R=BigInt(0);e:for(;x-R<k&&(b=R),await e.ioReader.seek(b),await p(e),!(8&e.ioReader.flags);){let a=await f(e,C),r=i.f[17](C+56);if(!(a>=0)){m=s.Dh;break}{const h=(0,n.Mr)(i.f[17](C+8),C+72,s.i0);let l=h-I;if(c.Yz(`try to seek to pos: ${b}, got packet pts: ${i.f[17](C+8)}(${h}ms), diff: ${l}ms`,d,100),l<=BigInt(0)&&-l<BigInt(1e4)||x-R<k){const h=[r];for(;l<=0;){if(i.f[15](C+32)===t.index&&1&i.f[15](C+36)&&h.push(r),(0,o.Up)(C),a=await f(e,C),a<0){if(-1048576===a)break;if(-1048575===a)continue;m=s.Dh;break e}r=i.f[17](C+56),l=(0,n.Mr)(i.f[17](C+8),C+72,s.i0)-I}m=h.pop();break}l>BigInt(0)?(x=b,b=R+x>>BigInt(1)):(R=b,b=R+x>>BigInt(1))}if(8&e.ioReader.flags)break}return(0,o.Qe)(C),m!==s.Dh?(c.Yz(`finally seek to pos ${m}`,d,155),await e.ioReader.seek(m),await p(e),u):(await e.ioReader.seek(u),8&e.ioReader.flags?BigInt(h.LT):BigInt(h.E$))}},30807:(e,t,a)=>{a.d(t,{R:()=>c,u:()=>h});var i=a(31531),s=a(816);const n=[1,2,2,2,2,3,3,4,4,5,6,6,6,7,8,8],r=[0,8e3,16e3,32e3,0,0,11025,22050,44100,0,0,12e3,24e3,48e3,96e3,192e3],o=[32e3,56e3,64e3,96e3,112e3,128e3,192e3,224e3,256e3,32e4,384e3,448e3,512e3,576e3,64e4,768e3,96e4,1024e3,1152e3,128e4,1344e3,1408e3,1411200,1472e3,1536e3,192e4,2048e3,3072e3,384e4,0,0,0],h=32;function c(e){const t=new i.A(e.length);t.appendBuffer(e);const a={syncWord:0,frameType:0,deficitSamples:0,crcFlag:0,sampleBlock:0,frameSize:0,channelIndex:0,sampleRateIndex:0,bitrateIndex:0,channels:0,sampleRate:0,bitrate:0};return a.syncWord=t.readU(32),2147385345!==a.syncWord&&4269736320!==a.syncWord?-1:(a.frameType=t.readU1(),a.deficitSamples=t.readU(5)+1,a.crcFlag=t.readU1(),a.sampleBlock=t.readU(7)+1,a.frameSize=(0,s.A)(t.readU(14)+1,4),a.channelIndex=t.readU(6),a.sampleRateIndex=t.readU(4),a.bitrateIndex=t.readU(5),a.channels=n[a.channelIndex],a.sampleRate=r[a.sampleRateIndex],a.bitrate=o[a.bitrateIndex],a)}},77735:(e,t,a)=>{a.d(t,{Ij:()=>c,XC:()=>h,kt:()=>o});var i=a(48162),s=a(87590),n=a(69663);const r=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960];function o(e){let t=0,a=0,i=0;if(e.length<1)return 0;switch(t=e[0],a=r[t>>3],3&t){case 0:i=1;break;case 1:case 2:i=2;break;case 3:if(e.length<2)return 0;i=63&e[1]}return i*a}function h(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=19){const a=new i.A(t,!1);a.skip(9),e.codecpar.chLayout.nbChannels=a.readUint8(),e.codecpar.initialPadding=a.readUint16(),e.codecpar.sampleRate=a.readUint32(),e.codecpar.seekPreroll=Number((0,n.k)(BigInt(80),{den:1e3,num:1},{den:48e3,num:1}))}}function c(e){const t=new Uint8Array(19),a=new s.A(t,!1);return a.writeString("OpusHead"),a.writeUint8(1),a.writeUint8(e.chLayout.nbChannels),a.writeUint16(e.initialPadding),a.writeUint32(e.sampleRate),t}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[814],{38037:(e,t,a)=>{a.d(t,{A:()=>b});var i=a(9655),s=a(16566),n=a(36311),r=a(66219),o=a(17641),h=a(57533),c=a(41321),d=a(20163),l=a(20086),f=a(89378),p=a(35497),u=a(69663),g=a(1140),m=a(37142),A=a(68483),I=a(64310);class b extends h.A{constructor(...e){super(...e),(0,i.A)(this,"streamMuxConfig",void 0),(0,i.A)(this,"caches",void 0),(0,i.A)(this,"pendingItem",void 0)}init(e,t){return super.init(e,t),this.caches=[],this.streamMuxConfig={profile:f.N_,sampleRate:f.N_,channels:f.N_},0}sendAVPacket(e){let t=0,a=s.f[17](e+16)!==f.Dh?s.f[17](e+16):s.f[17](e+8),i=(0,c.s3)(s.f[20](e+24),s.f[15](e+28)).slice();for(this.pendingItem&&(this.pendingItem.buffer=(0,I.A)(Uint8Array,[this.pendingItem.buffer,i.subarray(0,this.pendingItem.miss)]),i=i.subarray(this.pendingItem.miss),this.caches.push(this.pendingItem),this.pendingItem=null);t<i.length;){const h=p.Bq(i.subarray(t));if(A.ai(h)){let e=t+1;for(;e<i.length-1;e++)if(4095==(i[e]<<4|i[e+1]>>4)){t=e;break}if(e<i.length-1)continue;return d.z3("AACADTSParser parse failed","src/avformat/bsf/aac/ADTS2RawFilter.ts",109),l.LR}const m={dts:a,buffer:null,extradata:null,duration:f.N_,pos:s.f[17](e+56)};m.buffer=i.subarray(t+h.headerLength,t+h.headerLength+h.framePayloadLength),this.streamMuxConfig.profile=h.profile,this.streamMuxConfig.sampleRate=h.sampleRate,this.streamMuxConfig.channels=h.channels;const I=s.f[15](this.inCodecpar+48)!==this.streamMuxConfig.profile||s.f[15](this.inCodecpar+136)!==this.streamMuxConfig.sampleRate||s.f[15](this.inCodecpar+116)!==this.streamMuxConfig.channels,b=(0,u.k)(BigInt(Math.floor(1024*(h.numberOfRawDataBlocksInFrame+1)/this.streamMuxConfig.sampleRate*f.SF)),f.KR,this.inTimeBase);if(m.duration=Number(b),I){n.M[15](this.inCodecpar+48,this.streamMuxConfig.profile),n.M[15](this.inCodecpar+136,this.streamMuxConfig.sampleRate),n.M[15](this.inCodecpar+116,this.streamMuxConfig.channels);const e=(0,p.Ij)((0,o.A)(this.inCodecpar,r.A));s.f[20](this.inCodecpar+12)&&(0,g.Eb)(s.f[20](this.inCodecpar+12)),n.M[20](this.inCodecpar+12,(0,g.sY)(e.length)),(0,c.lW)(s.f[20](this.inCodecpar+12),e.length,e),n.M[15](this.inCodecpar+16,e.length),m.extradata=e}m.buffer.length<h.framePayloadLength?this.pendingItem={...m,miss:h.framePayloadLength-m.buffer.length}:this.caches.push(m),t+=h.aacFrameLength,a+=b}return 0}receiveAVPacket(e){if(this.caches.length){(0,m.Up)(e);const t=this.caches.shift(),a=(0,g.sY)(t.buffer.length);if((0,c.lW)(a,t.buffer.length,t.buffer),(0,m.NX)(e,a,t.buffer.length),n.M[17](e+16,t.dts),n.M[17](e+8,t.dts),n.M[17](e+56,t.pos),n.M[17](e+48,BigInt(Math.floor(t.duration))),n.M[15](e+36,1|s.f[15](e+36)),t.extradata){const a=(0,g.sY)(t.extradata.length);(0,c.lW)(a,t.extradata.length,t.extradata),(0,m.Ow)(e,1,a,t.extradata.length)}return 0}return l.LT}reset(){return this.pendingItem=null,this.caches.length=0,0}}},89984:(e,t,a)=>{a.d(t,{A:()=>s});var i=a(9655);class s{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},88441:(e,t,a)=>{a.d(t,{A:()=>o});var i=a(89378),s=a(20163),n=a(20086);const r="src/avformat/formats/mpegts/function/parsePES.ts";function o(e){const t=e.data,a=t[3],o=t[4]<<8|t[5];let h=0,c=0,d=0;if(188!==a&&190!==a&&191!==a&&240!==a&&241!==a&&255!==a&&242!==a&&248!==a){let a=i.Dh,l=i.Dh;for(;;){if(6+c>=t.length)return n.LR;if(d=t[6+c],255!==d)break;c++}if(64==(192&d)&&(c+=2,d=t[6+c]),32==(224&d))h+=5,a=a=BigInt(Math.floor(536870912*(14&t[6+c])+4194304*(255&t[7+c])+16384*(254&t[8+c])+128*(255&t[9+c])+(254&t[10+c])/2)),16&d?(l=BigInt(Math.floor(536870912*(14&t[11+c])+4194304*(255&t[12+c])+16384*(254&t[13+c])+128*(255&t[14+c])+(254&t[15+c])/2)),h+=5):l=a;else if(128==(192&d)){const e=(192&t[7+c])>>>6;h=3+t[8+c],2!==e&&3!==e||(a=BigInt(Math.floor(536870912*(14&t[9+c])+4194304*(255&t[10+c])+16384*(254&t[11+c])+128*(255&t[12+c])+(254&t[13+c])/2)),l=3===e?BigInt(Math.floor(536870912*(14&t[14+c])+4194304*(255&t[15+c])+16384*(254&t[16+c])+128*(255&t[17+c])+(254&t[18+c])/2)):a)}else{if(15!==d)return s.z3("invalid data",r,122),n.LR;h=1}e.dts=l,e.pts=a;const f=6+c+h;let p=0;if(0!==o){if(o<c+h)return s.z3("Malformed PES: PES_packet_length < 3 + PES_header_data_length",r,134),n.LR;p=o-(c+h),f+(t.byteLength-f)!=o+6&&(s.R8("PES packet size mismatch",r,139),e.flags|=2)}else p=t.byteLength-f;e.payload=t.subarray(f,f+p)}else if((188===a||191===a||240===a||241===a||255===a||242===a||248===a)&&6===e.streamId){const a=6;let i=0;i=0!==o?o:t.byteLength-a,e.payload=t.subarray(a,a+i)}return 0}},84216:(e,t,a)=>{a.d(t,{Cd:()=>d,I4:()=>f,am:()=>h,kJ:()=>l,pi:()=>c,xf:()=>p});var i=a(9655),s=a(33793),n=a.n(s),r=a(89378);class o{constructor(){(0,i.A)(this,"discontinuityIndicator",0),(0,i.A)(this,"randomAccessIndicator",0),(0,i.A)(this,"elementaryStreamPriorityIndicator",0),(0,i.A)(this,"pcrFlag",0),(0,i.A)(this,"opcrFlag",0),(0,i.A)(this,"splicingPointFlag",0),(0,i.A)(this,"transportPrivateDataFlag",0),(0,i.A)(this,"adaptationFieldExtensionFlag",0),(0,i.A)(this,"pcr",BigInt(0)),(0,i.A)(this,"opcr",BigInt(0)),(0,i.A)(this,"spliceCountDown",0),(0,i.A)(this,"transportPrivateData",null),(0,i.A)(this,"extension",null)}}class h{constructor(){(0,i.A)(this,"pos",r.Dh),(0,i.A)(this,"payloadUnitStartIndicator",0),(0,i.A)(this,"transportPriority",0),(0,i.A)(this,"pid",r.N_),(0,i.A)(this,"adaptationFieldControl",0),(0,i.A)(this,"continuityCounter",0),(0,i.A)(this,"transportScramblingControl",0),(0,i.A)(this,"adaptationFieldInfo",new o),(0,i.A)(this,"payload",null)}}class c{constructor(){(0,i.A)(this,"slices",[]),(0,i.A)(this,"totalLength",0),(0,i.A)(this,"expectedLength",r.N_),(0,i.A)(this,"randomAccessIndicator",0),(0,i.A)(this,"pid",r.N_),(0,i.A)(this,"streamType",0),(0,i.A)(this,"pos",r.Dh)}}class d{constructor(){(0,i.A)(this,"versionNumber",0),(0,i.A)(this,"networkPid",r.N_),(0,i.A)(this,"program2PmtPid",new(n()))}}class l{constructor(){(0,i.A)(this,"tag",void 0),(0,i.A)(this,"buffer",void 0)}}class f{constructor(){(0,i.A)(this,"versionNumber",0),(0,i.A)(this,"programNumber",0),(0,i.A)(this,"pcrPid",0),(0,i.A)(this,"pid2StreamType",new(n())),(0,i.A)(this,"pid2ESDescriptor",new(n()))}}class p{constructor(){(0,i.A)(this,"pid",r.N_),(0,i.A)(this,"streamType",0),(0,i.A)(this,"streamId",r.N_),(0,i.A)(this,"dts",r.Dh),(0,i.A)(this,"pts",r.Dh),(0,i.A)(this,"pos",r.Dh),(0,i.A)(this,"payload",null),(0,i.A)(this,"data",null),(0,i.A)(this,"randomAccessIndicator",0),(0,i.A)(this,"flags",void 0)}}},45372:(e,t,a)=>{a.d(t,{d:()=>r});var i=a(31126),s=a(69663),n=a(89378);function r(e,t,a){let r=BigInt(0);return i.__(e,(e=>{r+=e.codecpar.bitrate*(0,s.k)(t,a,n.i0)/BigInt(8e3)})),r}},59258:(e,t,a)=>{a.d(t,{A:()=>l});var i=a(16566),s=(a(51308),a(89378)),n=a(69663),r=a(45372),o=a(37142),h=a(20086),c=a(20163);const d="src/avformat/function/seekInBytes.ts";async function l(e,t,a,l,f,p){const u=e.ioReader.getPos(),g=await e.ioReader.fileSize();let m=s.Dh,A=a;t.startTime!==s.Dh?A-=t.startTime:A-=t.firstDTS;const I=(0,n.k)(a,t.timeBase,s.i0);if(I<BigInt(1e4))return c.Yz(`seek pts is earlier then 10s, seek to first packet pos(${l}) directly`,d,64),await e.ioReader.seek(l),u;let b=(0,r.d)(e.streams,A,t.timeBase);const y=g-(0,r.d)(e.streams,BigInt(1e4),s.i0),k=(0,r.d)(e.streams,BigInt(1e4),s.i0);if(b>y&&(b=y),b<l)return await e.ioReader.seek(l),u;const C=(0,o._5)();let x=g,R=BigInt(0);e:for(;x-R<k&&(b=R),await e.ioReader.seek(b),await p(e),!(8&e.ioReader.flags);){let a=await f(e,C),r=i.f[17](C+56);if(!(a>=0)){m=s.Dh;break}{const h=(0,n.Mr)(i.f[17](C+8),C+72,s.i0);let l=h-I;if(c.Yz(`try to seek to pos: ${b}, got packet pts: ${i.f[17](C+8)}(${h}ms), diff: ${l}ms`,d,101),l<=BigInt(0)&&-l<BigInt(1e4)||x-R<k){const h=[r];for(;l<=0;){if(i.f[15](C+32)===t.index&&1&i.f[15](C+36)&&h.push(r),(0,o.Up)(C),a=await f(e,C),a<0){if(-1048576===a)break;if(-1048575===a)continue;m=s.Dh;break e}r=i.f[17](C+56),l=(0,n.Mr)(i.f[17](C+8),C+72,s.i0)-I}m=h.pop();break}l>BigInt(0)?(x=b,b=R+x>>BigInt(1)):(R=b,b=R+x>>BigInt(1))}if(8&e.ioReader.flags)break}return(0,o.Qe)(C),m!==s.Dh?(c.Yz(`finally seek to pos ${m}`,d,156),await e.ioReader.seek(m),await p(e),u):(await e.ioReader.seek(u),8&e.ioReader.flags?BigInt(h.LT):BigInt(h.E$))}},30807:(e,t,a)=>{a.d(t,{R:()=>c,u:()=>h});var i=a(31531),s=a(816);const n=[1,2,2,2,2,3,3,4,4,5,6,6,6,7,8,8],r=[0,8e3,16e3,32e3,0,0,11025,22050,44100,0,0,12e3,24e3,48e3,96e3,192e3],o=[32e3,56e3,64e3,96e3,112e3,128e3,192e3,224e3,256e3,32e4,384e3,448e3,512e3,576e3,64e4,768e3,96e4,1024e3,1152e3,128e4,1344e3,1408e3,1411200,1472e3,1536e3,192e4,2048e3,3072e3,384e4,0,0,0],h=32;function c(e){const t=new i.A(e.length);t.appendBuffer(e);const a={syncWord:0,frameType:0,deficitSamples:0,crcFlag:0,sampleBlock:0,frameSize:0,channelIndex:0,sampleRateIndex:0,bitrateIndex:0,channels:0,sampleRate:0,bitrate:0};return a.syncWord=t.readU(32),2147385345!==a.syncWord&&4269736320!==a.syncWord?-1:(a.frameType=t.readU1(),a.deficitSamples=t.readU(5)+1,a.crcFlag=t.readU1(),a.sampleBlock=t.readU(7)+1,a.frameSize=(0,s.A)(t.readU(14)+1,4),a.channelIndex=t.readU(6),a.sampleRateIndex=t.readU(4),a.bitrateIndex=t.readU(5),a.channels=n[a.channelIndex],a.sampleRate=r[a.sampleRateIndex],a.bitrate=o[a.bitrateIndex],a)}},77735:(e,t,a)=>{a.d(t,{Ij:()=>c,XC:()=>h,kt:()=>o});var i=a(48162),s=a(87590),n=a(69663);const r=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960];function o(e){let t=0,a=0,i=0;if(e.length<1)return 0;switch(t=e[0],a=r[t>>3],3&t){case 0:i=1;break;case 1:case 2:i=2;break;case 3:if(e.length<2)return 0;i=63&e[1]}return i*a}function h(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=19){const a=new i.A(t,!1);a.skip(9),e.codecpar.chLayout.nbChannels=a.readUint8(),e.codecpar.initialPadding=a.readUint16(),e.codecpar.sampleRate=a.readUint32(),e.codecpar.seekPreroll=Number((0,n.k)(BigInt(80),{den:1e3,num:1},{den:48e3,num:1}))}}function c(e){const t=new Uint8Array(19),a=new s.A(t,!1);return a.writeString("OpusHead"),a.writeUint8(1),a.writeUint8(e.chLayout.nbChannels),a.writeUint16(e.initialPadding),a.writeUint32(e.sampleRate),t}}}]);
|