@libmedia/avplayer 0.11.2 → 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.
Files changed (118) hide show
  1. package/dist/esm/19.avplayer.js +1 -0
  2. package/dist/esm/195.avplayer.js +1 -0
  3. package/dist/esm/201.avplayer.js +1 -0
  4. package/dist/esm/312.avplayer.js +1 -0
  5. package/dist/esm/337.avplayer.js +1 -0
  6. package/dist/esm/367.avplayer.js +1 -0
  7. package/dist/esm/399.avplayer.js +1 -0
  8. package/dist/esm/400.avplayer.js +1 -0
  9. package/dist/esm/421.avplayer.js +1 -0
  10. package/dist/esm/430.avplayer.js +1 -0
  11. package/dist/esm/464.avplayer.js +1 -0
  12. package/dist/esm/531.avplayer.js +1 -1
  13. package/dist/esm/566.avplayer.js +1 -0
  14. package/dist/esm/60.avplayer.js +1 -0
  15. package/dist/esm/620.avplayer.js +1 -0
  16. package/dist/esm/690.avplayer.js +1 -0
  17. package/dist/esm/799.avplayer.js +1 -0
  18. package/dist/esm/801.avplayer.js +1 -0
  19. package/dist/esm/81.avplayer.js +1 -0
  20. package/dist/esm/814.avplayer.js +1 -0
  21. package/dist/esm/82.avplayer.js +1 -0
  22. package/dist/esm/852.avplayer.js +1 -0
  23. package/dist/esm/902.avplayer.js +1 -0
  24. package/dist/esm/913.avplayer.js +1 -0
  25. package/dist/esm/945.avplayer.js +1 -0
  26. package/dist/esm/949.avplayer.js +1 -0
  27. package/dist/esm/953.avplayer.js +1 -0
  28. package/dist/esm/avplayer.js +1 -1
  29. package/dist/types/AVPlayer.d.ts +39 -21
  30. package/dist/types/Controller.d.ts +3 -2
  31. package/dist/types/JitterBufferController.d.ts +2 -1
  32. package/dist/types/StatsController.d.ts +1 -1
  33. package/dist/types/mse/MSEPipeline.d.ts +10 -9
  34. package/dist/types/struct.d.ts +5 -5
  35. package/dist/types/subtitle/AssRender.d.ts +1 -1
  36. package/dist/types/subtitle/SubtitleRender.d.ts +4 -4
  37. package/dist/types/type.d.ts +2 -2
  38. package/dist/umd/19.avplayer.js +1 -0
  39. package/dist/umd/195.avplayer.js +1 -0
  40. package/dist/umd/201.avplayer.js +1 -0
  41. package/dist/umd/312.avplayer.js +1 -0
  42. package/dist/umd/337.avplayer.js +1 -0
  43. package/dist/umd/367.avplayer.js +1 -0
  44. package/dist/umd/399.avplayer.js +1 -0
  45. package/dist/umd/400.avplayer.js +1 -0
  46. package/dist/umd/421.avplayer.js +1 -0
  47. package/dist/umd/430.avplayer.js +1 -0
  48. package/dist/umd/464.avplayer.js +1 -0
  49. package/dist/umd/531.avplayer.js +1 -1
  50. package/dist/umd/566.avplayer.js +1 -0
  51. package/dist/umd/60.avplayer.js +1 -0
  52. package/dist/umd/620.avplayer.js +1 -0
  53. package/dist/umd/690.avplayer.js +1 -0
  54. package/dist/umd/799.avplayer.js +1 -0
  55. package/dist/umd/801.avplayer.js +1 -0
  56. package/dist/umd/81.avplayer.js +1 -0
  57. package/dist/umd/814.avplayer.js +1 -0
  58. package/dist/umd/82.avplayer.js +1 -0
  59. package/dist/umd/852.avplayer.js +1 -0
  60. package/dist/umd/902.avplayer.js +1 -0
  61. package/dist/umd/913.avplayer.js +1 -0
  62. package/dist/umd/945.avplayer.js +1 -0
  63. package/dist/umd/949.avplayer.js +1 -0
  64. package/dist/umd/953.avplayer.js +1 -0
  65. package/dist/umd/avplayer.js +1 -1
  66. package/package.json +12 -12
  67. package/dist/esm/118.avplayer.js +0 -1
  68. package/dist/esm/171.avplayer.js +0 -1
  69. package/dist/esm/217.avplayer.js +0 -1
  70. package/dist/esm/299.avplayer.js +0 -1
  71. package/dist/esm/331.avplayer.js +0 -1
  72. package/dist/esm/344.avplayer.js +0 -1
  73. package/dist/esm/433.avplayer.js +0 -1
  74. package/dist/esm/453.avplayer.js +0 -1
  75. package/dist/esm/487.avplayer.js +0 -1
  76. package/dist/esm/522.avplayer.js +0 -1
  77. package/dist/esm/527.avplayer.js +0 -1
  78. package/dist/esm/543.avplayer.js +0 -1
  79. package/dist/esm/576.avplayer.js +0 -1
  80. package/dist/esm/611.avplayer.js +0 -1
  81. package/dist/esm/634.avplayer.js +0 -1
  82. package/dist/esm/70.avplayer.js +0 -1
  83. package/dist/esm/791.avplayer.js +0 -1
  84. package/dist/esm/808.avplayer.js +0 -1
  85. package/dist/esm/839.avplayer.js +0 -1
  86. package/dist/esm/854.avplayer.js +0 -1
  87. package/dist/esm/855.avplayer.js +0 -1
  88. package/dist/esm/897.avplayer.js +0 -1
  89. package/dist/esm/904.avplayer.js +0 -1
  90. package/dist/esm/94.avplayer.js +0 -1
  91. package/dist/esm/941.avplayer.js +0 -1
  92. package/dist/esm/969.avplayer.js +0 -1
  93. package/dist/umd/118.avplayer.js +0 -1
  94. package/dist/umd/171.avplayer.js +0 -1
  95. package/dist/umd/217.avplayer.js +0 -1
  96. package/dist/umd/299.avplayer.js +0 -1
  97. package/dist/umd/331.avplayer.js +0 -1
  98. package/dist/umd/344.avplayer.js +0 -1
  99. package/dist/umd/433.avplayer.js +0 -1
  100. package/dist/umd/453.avplayer.js +0 -1
  101. package/dist/umd/487.avplayer.js +0 -1
  102. package/dist/umd/522.avplayer.js +0 -1
  103. package/dist/umd/527.avplayer.js +0 -1
  104. package/dist/umd/543.avplayer.js +0 -1
  105. package/dist/umd/576.avplayer.js +0 -1
  106. package/dist/umd/611.avplayer.js +0 -1
  107. package/dist/umd/634.avplayer.js +0 -1
  108. package/dist/umd/70.avplayer.js +0 -1
  109. package/dist/umd/791.avplayer.js +0 -1
  110. package/dist/umd/808.avplayer.js +0 -1
  111. package/dist/umd/839.avplayer.js +0 -1
  112. package/dist/umd/854.avplayer.js +0 -1
  113. package/dist/umd/855.avplayer.js +0 -1
  114. package/dist/umd/897.avplayer.js +0 -1
  115. package/dist/umd/904.avplayer.js +0 -1
  116. package/dist/umd/94.avplayer.js +0 -1
  117. package/dist/umd/941.avplayer.js +0 -1
  118. package/dist/umd/969.avplayer.js +0 -1
@@ -0,0 +1 @@
1
+ (self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[566],{81534:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(9655);class a{constructor(){(0,s.A)(this,"onFlush",void 0)}}},5866:(t,e,i)=>{"use strict";i.d(e,{A:()=>p});var s=i(9655),a=i(81534),r=i(54893),n=i(10855),o=i(56719),h=i(20163);const l="src/avnetwork/bsp/aes/AESDecryptPipe.ts",d=16;let u=!0;const c=new Uint8Array(d).fill(d);class p extends a.A{constructor(t=0,e=1048576){super(),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"aesSoftDecryptor",void 0),(0,s.A)(this,"aesWebDecryptor",void 0),(0,s.A)(this,"aesTargetDecryptor",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"ended",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"pos",void 0),this.mode=t,this.size=e,this.pointer=0,this.endPointer=0,this.pos=0,this.ended=!1,this.buffer=new Uint8Array(e),this.aesSoftDecryptor=new r.A(t),n.A.isSupport()&&u&&(this.aesWebDecryptor=new n.A(t)),this.aesTargetDecryptor=this.aesWebDecryptor||this.aesSoftDecryptor}remainingLength(){return this.endPointer-this.pointer}async expandKey(t,e){this.key=t,this.iv=e,this.aesWebDecryptor&&await this.aesWebDecryptor.expandKey(t),t.byteLength<=8&&this.aesSoftDecryptor.expandKey(t)}async flush_(t){for(;;){const e=await this.onFlush(t);if(-1048575!==e)return e;await new o.A(0)}}async flush(){if(this.size-this.remainingLength()<=0)return;this.pointer<this.endPointer?this.pointer&&(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0;const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0){if(-1048576===t)return void(this.ended=!0);h.h2(`AESPipe error, flush failed, ret: ${t}`,l,128)}this.endPointer+=t}removePadding(t){const e=t.length,i=e&&new DataView(t.buffer).getUint8(e-1);return i?t.subarray(0,e-i):t}async decryptCBC(t){let e,i=0;this.aesTargetDecryptor!==this.aesWebDecryptor||this.ended||(e=this.buffer.subarray(this.pointer+t,this.pointer+t+d).slice(),this.buffer.set((await this.aesWebDecryptor.encryptPadding(c,this.buffer.subarray(this.pointer+t-d,this.pointer+t))).subarray(0,d),this.pointer+t),i=d);try{const s=this.buffer.subarray(this.pointer,this.pointer+t+i),a=await this.aesTargetDecryptor.decrypt(s,this.iv);return this.iv=s.slice(s.length-d-i,s.length-i).buffer,e&&this.buffer.set(e,this.pointer+t),this.pointer+=t,this.pos+=t,new Uint8Array(a)}catch(i){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,178),e&&this.buffer.set(e,this.pointer+t),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCBC(t);h.h2("aes decrypt failed",l,188)}}getCTRIv(){const t=new Uint8Array(this.iv).slice();let e=Math.floor(this.pos/d);for(let i=15;i>=0&&e>0;i--){const s=t[i]+(255&e);t[i]=255&s,e=(e>>>8)+(s>>8)}return t.buffer}async decryptCTR(t){try{const e=this.buffer.subarray(this.pointer,this.pointer+t),i=await this.aesTargetDecryptor.decrypt(e,this.getCTRIv());return this.pointer+=t,this.pos+=t,new Uint8Array(i)}catch(e){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,214),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCTR(t);h.h2("aes decrypt failed",l,220)}}async read(t){for(;!this.ended&&this.remainingLength()<48;)await this.flush();if(0===this.remainingLength())return-1048576;if(0===this.mode){const e=Math.min(Math.floor((this.remainingLength()-(this.ended?0:32))/d)*d,t.length);let i=await this.decryptCBC(e);return this.ended&&this.aesTargetDecryptor===this.aesSoftDecryptor&&(i=this.removePadding(i)),t.set(i),i.length}{const e=this.ended?this.remainingLength():Math.min(Math.floor(this.remainingLength()/d)*d,t.length);let i=await this.decryptCTR(e);return t.set(i),i.length}}}},4566:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>X});var s=i(9655),a=i(55906),r=i.n(a),n=i(33793),o=i.n(n),h=i(56719),l=i(72277),d=i(99868),u=i(10446),c=i(68141),p=i(33267),m=i(80155),f=i(20163),T=i(5866),E=i(68483),y=i(20086),A=i(10855),g=i(93426);const v="src/avnetwork/ioLoader/HlsIOLoader.ts";function S(t,e="GET"){var i,s,a;const r={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};return null!==(i=t.httpOptions)&&void 0!==i&&i.headers&&d.__(t.httpOptions.headers,((t,e)=>{r.headers[e]=t})),null!==(s=t.httpOptions)&&void 0!==s&&s.credentials&&(r.credentials=t.httpOptions.credentials),null!==(a=t.httpOptions)&&void 0!==a&&a.referrerPolicy&&(r.referrerPolicy=t.httpOptions.referrerPolicy),r}async function I(t,e,i,s){return new(r())(((a,r)=>{let n=0;!async function o(){try{const r=await fetch(t,{...S(e),signal:s}),d=await r.text(),u=(0,c.A)(d);if(i.isLive&&(!u.segments||u.segments.length<2)){var l;let t=5;null!==(l=u.segments)&&void 0!==l&&l.length&&(t=u.segments[0].duration*(2-u.segments.length)),f.R8(`wait for min buffer time, now segments: ${u.segments.length}`,v,94),await new h.A(t),n=0,o()}a(u)}catch(t){if("AbortError"===(null==t?void 0:t.name))return void a(null);if(n<i.retryCount)return n++,f.z3(`failed fetch m3u8 file, retry(${n}/3)`,v,108),await new h.A(i.retryInterval),o();f.z3("HLSLoader: exception, fetch slice error",v,113),r()}}()}))}class b{constructor(t,e,i,a){(0,s.A)(this,"options",void 0),(0,s.A)(this,"info",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"fetchedMap",void 0),(0,s.A)(this,"fetchedHistoryList",void 0),(0,s.A)(this,"mediaListUrl",void 0),(0,s.A)(this,"segmentIndex",void 0),(0,s.A)(this,"currentUri",void 0),(0,s.A)(this,"loader",void 0),(0,s.A)(this,"keyMap",void 0),(0,s.A)(this,"currentIV",void 0),(0,s.A)(this,"currentKey",void 0),(0,s.A)(this,"aesDecryptPipe",void 0),(0,s.A)(this,"initLoaded",void 0),(0,s.A)(this,"isInitLoader",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"pendingBuffer",void 0),(0,s.A)(this,"magicAdded",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"signal",void 0),this.options=t,this.info=e,this.segmentIndex=0,this.fetchedMap=new(o()),this.fetchedHistoryList=[],this.keyMap=new(o()),this.aborted=!1,i&&a&&this.setMediaPlayList(i,a)}setMediaPlayList(t,e){if(this.options.isLive){this.fetchedMap.clear(),this.fetchedHistoryList.length=0,this.segmentIndex=0;const t=e.segments.find((t=>t.uri===this.currentUri));if(t)for(e.segments.forEach(((e,i)=>{e.mediaSequenceNumber===t.mediaSequenceNumber+1?this.segmentIndex=i:e.mediaSequenceNumber<=t.mediaSequenceNumber&&(this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri))}));this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift())}if(this.mediaListUrl=t,this.mediaPlayList=e,this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.initLoaded=!0,this.mediaPlayList.segments.length&&this.mediaPlayList.segments[0].map&&(this.initLoaded=!1),this.mediaPlayList.lowLatencyCompatibility){const t=this.mediaPlayList.lowLatencyCompatibility.partHoldBack||this.mediaPlayList.lowLatencyCompatibility.holdBack||this.minBuffer;let e=0,s=!1,a=0;for(let r=this.mediaPlayList.segments.length-1;r>=0;r--){var i;const n=this.mediaPlayList.segments[r];if(null!==(i=n.parts)&&void 0!==i&&i.length){if(!n.uri)continue;for(let i=n.parts.length-1;i>=0;i--){const o=n.parts[i];if(!o.hint&&(e+=o.duration,o.independent&&(s=!0),e>=t&&s)){a=r;break}}if(e>=t&&s)break}else if(e+=n.duration,s=!0,e>=t&&s){a=r;break}}this.fetchedMap.clear(),this.fetchedHistoryList.length=0;for(let t=0;t<a;t++){const e=this.mediaPlayList.segments[t];this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri)}for(;this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift());this.segmentIndex=a,this.minBuffer=e}}getMediaListUrl(){return this.mediaListUrl}async checkNeedDecrypt(t,e,i){if(!t)return void(this.aesDecryptPipe=null);if("aes-128"!==t.method.toLocaleLowerCase()&&"aes-128-ctr"!==t.method.toLocaleLowerCase()&&("aes-256"!==t.method.toLocaleLowerCase()&&"aes-256-ctr"!==t.method.toLocaleLowerCase()||!A.A.isSupport())){if("mp4"===e.split(".").pop())return void(this.aesDecryptPipe=null);f.h2(`m3u8 ts not support EXT-X-KEY METHOD ${t.method}`,v,286)}const s=t.uri;if(this.keyMap.has(s)?this.currentKey=this.keyMap.get(s):(this.currentKey=await(await fetch((0,u.ll)(this.mediaListUrl,s),S(this.info))).arrayBuffer(),this.keyMap.set(s,this.currentKey)),t.iv)this.currentIV=t.iv.buffer;else{const t=new Uint8Array(16);new DataView(t.buffer).setUint32(12,i,!1),this.currentIV=t.buffer}this.aesDecryptPipe=new T.A(t.method.toLocaleLowerCase().indexOf("ctr")>0?1:0),this.aesDecryptPipe.onFlush=async t=>this.loader.read(t),await this.aesDecryptPipe.expandKey(this.currentKey,this.currentIV)}handleSlice(t,e){const i=this.loader.getUrl().split(".").pop();if("mp3"!==i&&!this.magicAdded&&73===e[0]&&68===e[1]&&51===e[2]){var s;const a=null!==(s=g.HR[i])&&void 0!==s?s:-1;return-1===a?t:(t+6>e.length&&(this.pendingBuffer=e.slice(t-6)),e.set(e.slice(0,t-6),6),e[0]=76,e[1]=73,e[2]=77,e[3]=65,e[4]=a>>>8&255,e[5]=255&a,this.magicAdded=!0,this.pendingBuffer?t:t+6)}return t}async read(t){if(this.pendingBuffer){let e=this.pendingBuffer.length;return t.set(this.pendingBuffer),this.pendingBuffer=null,e}let e=0;if(this.loader){if(e=this.aesDecryptPipe?await this.aesDecryptPipe.read(t):await this.loader.read(t),-1048576!==e||this.aborted)return e;if(this.isInitLoader)this.initLoaded=!0;else if(this.options.isLive)this.fetchedMap.set(this.currentUri,!0),10===this.fetchedHistoryList.length&&this.fetchedMap.delete(this.fetchedHistoryList.shift()),this.fetchedHistoryList.push(this.currentUri),this.segmentIndex++;else if(this.segmentIndex++,this.segmentIndex>=this.mediaPlayList.segments.length)return-1048576;this.loader=null}if(this.options.isLive){var i,s;const e=this.mediaPlayList.segments.filter((t=>t.uri&&!this.fetchedMap.get(t.uri)));if(!e.length){var a;if(this.mediaPlayList.endlist)return-1048576;const e=(this.minBuffer-((0,m.A)()-this.mediaPlayList.timestamp)/1e3)/2;return e>0&&(this.sleep=new h.A(e),await this.sleep,this.sleep=null,this.aborted)?-1048576:("function"==typeof AbortController&&(this.signal=new AbortController),this.mediaPlayList=await I(this.mediaListUrl,this.info,this.options,null===(a=this.signal)||void 0===a?void 0:a.signal),this.signal=null,this.aborted?-1048576:this.read(t))}this.isInitLoader=!(null===(i=e[0].map)||void 0===i||!i.uri||this.initLoaded),this.currentUri=e[0].uri,this.isInitLoader?null!==(s=e[0].map)&&void 0!==s&&s.key&&await this.checkNeedDecrypt(e[0].map.key,e[0].map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e[0].key,this.currentUri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)),this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));const r=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e[0].map.uri:this.currentUri),n={from:0,to:-1},o=this.isInitLoader?e[0].map.byterange:e[0].byterange;o&&(n.from=o.offset,n.to=o.offset+o.length),await this.loader.open(d.X$({},this.info,{url:r}),n);const l=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return l>10?this.handleSlice(l,t):l}{var r,n;this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));let e=this.mediaPlayList.segments[this.segmentIndex];for(;e&&!e.uri;)e=this.mediaPlayList.segments[++this.segmentIndex];this.isInitLoader=!(null===(r=e.map)||void 0===r||!r.uri||this.initLoaded),this.isInitLoader?null!==(n=e.map)&&void 0!==n&&n.key&&await this.checkNeedDecrypt(e.map.key,e.map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e.key,e.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0));const i=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e.map.uri:e.uri),s={from:0,to:-1},a=this.isInitLoader?e.map.byterange:e.byterange;a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(d.X$({},this.info,{url:i}),s);const o=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return o>10?this.handleSlice(o,t):o}}async seek(t,e=0){this.loader&&(await this.loader.abort(),this.loader=null);let i=e,s=Number(t),a=-1;for(let t=0;t<this.mediaPlayList.segments.length;t++)if(E.ai(this.mediaPlayList.segments[t].duration)&&(i+=this.mediaPlayList.segments[t].duration,1e3*i>=s)){a=t;break}return-1===a&&(a=this.mediaPlayList.segments.length-1),this.segmentIndex=a,this.aborted=!1,0}abortSleep(){this.aborted=!0,this.loader&&this.loader.abortSleep(),this.sleep&&(this.sleep.stop(),this.sleep=null)}async abort(){this.abortSleep(),this.signal&&(this.signal.abort(),this.signal=null),this.loader&&(await this.loader.abort(),this.loader=null)}getMinBuffer(){return this.minBuffer}getDuration(){return this.mediaPlayList.duration}getNextFragmentStart(t=0){if(this.segmentIndex>=this.mediaPlayList.segments.length-1)return-1;for(let e=0;e<this.segmentIndex+1;e++){if(!E.ai(this.mediaPlayList.segments[e].duration))return-1;t+=this.mediaPlayList.segments[e].duration}return t}}class X extends l.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"masterPlaylist",void 0),(0,s.A)(this,"mediaPlayListIndex",void 0),(0,s.A)(this,"mainLoader",void 0),(0,s.A)(this,"loaders",void 0),(0,s.A)(this,"audioSelectedIndex",void 0),(0,s.A)(this,"subtitleSelectedIndex",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"start",void 0)}async fetchMasterPlayList(){try{const e=await fetch(this.info.url,S(this.info)),i=await e.text(),s=(0,c.A)(i);if(s.isMasterPlaylist){if(this.masterPlaylist=s,this.options.preferResolution||this.options.preferVideoCodec){let t=1,e=1;if(this.options.preferResolution){const i=this.options.preferResolution.split("*");t=+i[0]||1,e=+i[1]||1}let i=!1,s=1/0,a=this.masterPlaylist.variants.some((t=>t.codecs&&t.codecs.indexOf(this.options.preferVideoCodec)>=0));this.masterPlaylist.variants.forEach(((r,n)=>{if(!(this.options.preferVideoCodec&&a&&r.codecs&&-1===r.codecs.indexOf(this.options.preferVideoCodec))&&(i||(this.mediaPlayListIndex=n,i=!0),r.resolution&&this.options.preferResolution)){const i=1===t?1:r.resolution.width,a=1===e?1:r.resolution.height;Math.abs(i*a-t*e)<s&&(s=Math.abs(i*a-t*e),this.mediaPlayListIndex=n)}}))}const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t){if(t.audio.length&&this.options.preferAudioLang){let e=!1;t.audio.forEach(((t,i)=>{t.language&&t.language.indexOf(this.options.preferAudioLang)>=0&&!e&&(this.audioSelectedIndex=i,t.language===this.options.preferAudioLang&&(e=!0))}))}if(t.subtitles.length&&this.options.preferSubtitleLang){let e=!1;t.subtitles.forEach(((t,i)=>{t.language&&t.language.indexOf(this.options.preferSubtitleLang)>=0&&!e&&(this.subtitleSelectedIndex=i,t.language===this.options.preferSubtitleLang&&(e=!0))}))}}}else{const e=s;if(this.options.isLive&&(!e.segments||e.segments.length<2)){var t;let i=5;return null!==(t=e.segments)&&void 0!==t&&t.length&&(i=e.segments[0].duration*(2-e.segments.length)),f.R8(`wait for min buffer time, now segments: ${e.segments.length}`,v,666),await new h.A(i),this.fetchMasterPlayList()}this.mainLoader=new b(d.X$({enableBandwidthReader:!0},this.options),this.info,this.info.url,e),this.loaders.set(0,this.mainLoader)}return s}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,f.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,v,683),this.sleep=new h.A(3),await this.sleep,this.sleep=null,this.aborted&&f.h2("HLSLoader: exception, fetch abort",v,688),this.fetchMasterPlayList();this.status=3,f.h2("HLSLoader: exception, fetch slice error",v,694)}}buildUrl(t){return/^https?/.test(t)||(t=u.ll(this.info.url,t)),t}async createLoader(){if(this.masterPlaylist){const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t||f.h2("no media playlist",v,710),t.audio.length){const e=this.buildUrl(t.audio[this.audioSelectedIndex].uri);this.loaders.set(1,new b(this.options,this.info,e,await I(e,this.info,this.options)))}if(t.subtitles.length){const e=this.buildUrl(t.subtitles[this.subtitleSelectedIndex].uri);this.loaders.set(3,new b(this.options,this.info,e,await I(e,this.info,this.options)))}const e=this.buildUrl(t.uri);this.mainLoader=new b(d.X$({enableBandwidthReader:!0},this.options),this.info,e,await I(e,this.info,this.options)),this.loaders.set(0,this.mainLoader)}}async open(t){return 2===this.status?0:0!==this.status?y.lh:(this.info=t,this.mediaPlayListIndex=0,this.audioSelectedIndex=0,this.subtitleSelectedIndex=0,this.loaders=new(o()),this.status=1,this.retryCount=0,this.aborted=!1,this.start=0,await this.fetchMasterPlayList(),!this.loaders.size&&this.masterPlaylist&&await this.createLoader(),this.status=2,0)}async read(t,e){if(!e)return y.UY;const i=await this.loaders.get(e.mediaType).read(t);return i<0&&-1048575!==i&&(this.status=-1048576===i?4:3),i}async seek(t,e){return e?(await this.loaders.get(e.mediaType).seek(t,this.start),4===this.status&&(this.status=2),0):y.UY}async size(){return BigInt(0)}async abort(){for(let t of this.loaders)await t[1].abort();this.aborted=!0,this.sleep&&(this.sleep.stop(),this.sleep=null)}async stop(){await this.abort(),this.status=0}getDuration(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:0}hasVideo(){return this.masterPlaylist?this.masterPlaylist.variants.length>0:!!this.mainLoader}hasAudio(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].audio.length>0}hasSubtitle(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.length>0}getVideoList(){var t,e;return{list:null!==(t=null===(e=this.masterPlaylist)||void 0===e?void 0:e.variants.map((t=>{var e,i,s,a,r;return{width:null!==(e=null===(i=t.resolution)||void 0===i?void 0:i.width)&&void 0!==e?e:0,height:null!==(s=null===(a=t.resolution)||void 0===a?void 0:a.height)&&void 0!==s?s:0,frameRate:null!==(r=t.frameRate)&&void 0!==r?r:0,codec:t.codecs,bandwidth:t.bandwidth}})))&&void 0!==t?t:[],selectedIndex:this.mediaPlayListIndex||0}}getAudioList(){return this.masterPlaylist&&this.hasAudio()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].audio.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.audioSelectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.masterPlaylist&&this.hasSubtitle()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.subtitleSelectedIndex}:{list:[],selectedIndex:0}}async selectVideo(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[t];if(e){const i=this.buildUrl(e.uri),s=await I(i,this.info,this.options);if(this.loaders.get(0).setMediaPlayList(i,s),this.mediaPlayListIndex=t,1===e.audio.length&&this.loaders.has(1)&&this.buildUrl(e.audio[0].uri)!==this.loaders.get(1).getMediaListUrl()){const t=this.buildUrl(e.audio[0].uri),i=await I(t,this.info,this.options);this.loaders.get(1).setMediaPlayList(t,i)}if(1===e.subtitles.length&&this.loaders.has(3)&&this.buildUrl(e.subtitles[0].uri)!==this.loaders.get(3).getMediaListUrl()){const t=this.buildUrl(e.subtitles[0].uri),i=await I(t,this.info,this.options);this.loaders.get(3).setMediaPlayList(t,i)}return this.loaders.get(0).getNextFragmentStart(this.start)}}return-1}async selectAudio(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.audio[t]){const i=this.buildUrl(e.audio[t].uri),s=await I(i,this.info,this.options);return this.loaders.get(1).setMediaPlayList(i,s),this.audioSelectedIndex=t,this.loaders.get(1).getNextFragmentStart(this.start)}}return-1}async selectSubtitle(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.subtitles[t]){const i=this.buildUrl(e.subtitles[t].uri),s=await I(i,this.info,this.options);return this.loaders.get(3).setMediaPlayList(i,s),this.subtitleSelectedIndex=t,this.loaders.get(3).getNextFragmentStart(this.start)}}return-1}getMinBuffer(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getMinBuffer())&&void 0!==t?t:0}setStart(t){this.start=t}}},68141:(t,e,i)=>{"use strict";i.d(e,{A:()=>w});var s=i(14265),a=i.n(s),r=i(89730),n=i.n(r),o=i(21955),h=i.n(o),l=i(33793),d=i.n(l),u=i(91325),c=i(41497),p=i(20163);const m="src/avprotocol/m3u8/parser.ts";function f(t){return u.Bq(t,'"')}function T(t){const e=u.gI(t,",");return{duration:u.Ro(e[0]),title:decodeURIComponent(escape(e[1]))}}function E(t){const e=u.gI(t,"@");return{length:u.Ro(e[0]),offset:e[1]?u.Ro(e[1]):-1}}function y(t){const e=u.gI(t,"x");return{width:u.Ro(e[0]),height:u.Ro(e[1])}}function A(t){const e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",i=t.split(",");0===i.length&&p.z3(e,m,103);const s=[];for(const t of i){const[i,a]=u.gI(t,":");i&&a?s.push({format:i,cpcList:a.split("/")}):p.z3(e,m,109)}return s}function g(t){const e=u.m2(t);return 16!==e.length&&p.z3("IV must be a 128-bit unsigned integer",m,120),e}function v(t,e){e.IV&&t.compatibleVersion<2&&(t.compatibleVersion=2),(e.KEYFORMAT||e.KEYFORMATVERSIONS)&&t.compatibleVersion<5&&(t.compatibleVersion=5)}function S(t){const e={};for(const s of u.HG(t)){const[t,a]=u.gI(s,"="),r=f(a);switch(t){case"URI":e[t]=r;break;case"START-DATE":case"END-DATE":e[t]=new Date(r);break;case"IV":e[t]=g(r);break;case"BYTERANGE":e[t]=E(r);break;case"RESOLUTION":e[t]=y(r);break;case"ALLOWED-CPC":e[t]=A(r);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":e[t]="YES"===r;break;case"DURATION":case"PLANNED-DURATION":case"BANDWIDTH":case"AVERAGE-BANDWIDTH":case"FRAME-RATE":case"TIME-OFFSET":case"CAN-SKIP-UNTIL":case"HOLD-BACK":case"PART-HOLD-BACK":case"PART-TARGET":case"BYTERANGE-START":case"BYTERANGE-LENGTH":case"LAST-MSN":case"LAST-PART":case"SKIPPED-SEGMENTS":case"SCORE":case"PROGRAM-ID":e[t]=u.Ro(r);break;default:t.startsWith("SCTE35-")?e[t]=u.m2(r):t.startsWith("X-")?e[t]=(i=a).startsWith('"')?f(i):i.startsWith("0x")||i.startsWith("0X")?u.m2(i):u.Ro(i):("VIDEO-RANGE"===t&&"SDR"!==r&&"HLG"!==r&&"PQ"!==r&&p.h2(`VIDEO-RANGE: unknown value "${r}"`,m,207),e[t]=r)}}var i;return e}function I(t,e,i){const s=function({attributes:t}){return new c.ru({type:t.TYPE,uri:t.URI,groupId:t["GROUP-ID"],language:t.LANGUAGE,assocLanguage:t["ASSOC-LANGUAGE"],name:t.NAME,isDefault:t.DEFAULT,autoselect:t.AUTOSELECT,forced:t.FORCED,instreamId:t["INSTREAM-ID"],characteristics:t.CHARACTERISTICS,channels:t.CHANNELS})}(e),a=t[u.Th(i)],r=function(t,e){let i=!1;for(const s of t){if(s.name===e.name)return"All EXT-X-MEDIA tags in the same Group MUST have different NAME attributes.";s.isDefault&&(i=!0)}return i&&e.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(a,s);r&&p.h2(r,m,316),a.push(s),s.isDefault&&(t.currentRenditions[u.Th(i)]=a.length-1)}function b(t,e,i,s,a){const r=new c.KT({uri:i,bandwidth:e.BANDWIDTH,averageBandwidth:e["AVERAGE-BANDWIDTH"],score:e.SCORE,codecs:e.CODECS,resolution:e.RESOLUTION,frameRate:e["FRAME-RATE"],hdcpLevel:e["HDCP-LEVEL"],allowedCpc:e["ALLOWED-CPC"],videoRange:e["VIDEO-RANGE"],stableVariantId:e["STABLE-VARIANT-ID"],programId:e["PROGRAM-ID"]});for(const i of t)if("EXT-X-MEDIA"===i.name){const t=i.attributes,s=t.TYPE;if(s&&t["GROUP-ID"]||p.h2("EXT-X-MEDIA TYPE attribute is REQUIRED.",m,356),e[s]===t["GROUP-ID"]&&(I(r,i,s),"CLOSED-CAPTIONS"===s))for(const{instreamId:t}of r.closedCaptions)if(t&&t.startsWith("SERVICE")&&a.compatibleVersion<7){a.compatibleVersion=7;break}}return function(t,e,i){for(const s of["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"])"CLOSED-CAPTIONS"===s&&"NONE"===t[s]?(i.isClosedCaptionsNone=!0,e.closedCaptions=[]):t[s]&&!e[u.Th(s)].some((e=>e.groupId===t[s]))&&p.h2(`${s} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${s}.`,m,331)}(e,r,a),r.isIFrameOnly=s,r}function X(t,e){if(t.method!==e.method)return!1;if(t.uri!==e.uri)return!1;if(t.iv){if(!e.iv)return!1;if(t.iv.length!==e.iv.length)return!1;for(let i=0;i<t.iv.length;i++)if(t.iv[i]!==e.iv[i])return!1}else if(e.iv)return!1;return t.format===e.format&&t.formatVersion===e.formatVersion}function N(t,e,i,s,a,r,o){const l=new c.Y4({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});let d=!1,u=!1;for(let e=i;e<=s;e++){const{name:i,value:s,attributes:a}=t[e];if("EXTINF"===i)!n()(s.duration)&&o.compatibleVersion<3&&(o.compatibleVersion=3),Math.round(s.duration)>o.targetDuration&&p.h2("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration",m,518),l.duration=s.duration,l.title=s.title;else if("EXT-X-BYTERANGE"===i)o.compatibleVersion<4&&(o.compatibleVersion=4),l.byterange=s;else if("EXT-X-DISCONTINUITY"===i)l.parts.length>0&&p.h2("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment.",m,531),l.discontinuity=!0;else if("EXT-X-KEY"===i)l.parts.length>0&&p.h2("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment.",m,537),"NONE"!==a.METHOD?(v(o,a),l.key=new c.Uz({method:a.METHOD,uri:a.URI,iv:a.IV,format:a.KEYFORMAT,formatVersion:a.KEYFORMATVERSIONS})):l.key=null;else if("EXT-X-MAP"===i)l.parts.length>0&&p.h2("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment.",m,556),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,l.map=new c.qP({uri:a.URI,byterange:a.BYTERANGE,key:l.key});else if("EXT-X-PROGRAM-DATE-TIME"===i)l.programDateTime=s;else if("EXT-X-DATERANGE"===i){const t={};for(const e of h()(a))(e.startsWith("SCTE35-")||e.startsWith("X-"))&&(t[e]=a[e]);l.dateRange=new c.ad({id:a.ID,classId:a.CLASS,start:a["START-DATE"],end:a["END-DATE"],duration:a.DURATION,plannedDuration:a["PLANNED-DURATION"],endOnNext:a["END-ON-NEXT"],attributes:t})}else if("EXT-X-CUE-OUT"===i)l.markers.push(new c.xC({type:"OUT",duration:a&&a.DURATION||s}));else if("EXT-X-CUE-IN"===i)l.markers.push(new c.xC({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===i||"EXT-X-CUE"===i||"EXT-OATCLS-SCTE35"===i||"EXT-X-ASSET"===i||"EXT-X-SCTE35"===i)l.markers.push(new c.xC({type:"RAW",tagName:i,value:s}));else if("EXT-X-PRELOAD-HINT"!==i||a.TYPE)if("EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE&&u)p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",m,617);else if("EXT-X-PART"!==i&&"EXT-X-PRELOAD-HINT"!==i||a.URI){if("EXT-X-PRELOAD-HINT"===i&&"MAP"===a.TYPE)d&&p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",m,624),d=!0,o.hasMap=!0,l.map=new c.qP({hint:!0,uri:a.URI,byterange:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0}});else if("EXT-X-PART"===i||"EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE){"EXT-X-PART"!==i||a.DURATION||p.h2("EXT-X-PART: DURATION attribute is mandatory",m,636),"EXT-X-PRELOAD-HINT"===i&&(u=!0);const t=new c.nw({hint:"EXT-X-PRELOAD-HINT"===i,uri:a.URI,byterange:"EXT-X-PART"===i?a.BYTERANGE:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0},duration:a.DURATION,independent:a.INDEPENDENT,gap:a.GAP});l.parts.push(t)}}else p.h2("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory",m,620);else p.h2("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory",m,614)}return l}function R(t,e,i,s,a,r,n){const o=new c.Vd({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});for(let e=i;e<=s;e++){const{name:i,attributes:s}=t[e];"EXTINF"===i?p.h2("A prefetch segment must not be advertised with an EXTINF tag.",m,668):"EXT-X-DISCONTINUITY"===i?p.h2("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag.",m,671):"EXT-X-PREFETCH-DISCONTINUITY"===i?o.discontinuity=!0:"EXT-X-KEY"===i?"NONE"!==s.METHOD&&(v(n,s),o.key=new c.Uz({method:s.METHOD,uri:s.URI,iv:s.IV,format:s.KEYFORMAT,formatVersion:s.KEYFORMATVERSIONS})):"EXT-X-MAP"===i&&p.h2("Prefetch segments must not be advertised with an EXT-X-MAP tag.",m,689)}return o}function P(t,e,i,s,a){const{discontinuity:r,key:n,map:o,byterange:h,uri:l}=e;if(r&&(e.discontinuitySequence=i+1),n||(e.key=s),o||(e.map=a),h&&-1===h.offset){const{segments:e}=t;if(e.length>0){const t=e[e.length-1];t.byterange&&t.uri===l?h.offset=t.byterange.offset+t.byterange.length:p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource",m,913)}else p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file",m,917)}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function L(t,e){const[i,s]=function(t){const e=t.indexOf(":");return-1===e?[t.slice(1).trim(),null]:[t.slice(1,e).trim(),t.slice(e+1).trim()]}(t),r=function(t){switch(t){case"EXTM3U":case"EXT-X-VERSION":return"Basic";case"EXTINF":case"EXT-X-BYTERANGE":case"EXT-X-DISCONTINUITY":case"EXT-X-PREFETCH-DISCONTINUITY":case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-PROGRAM-DATE-TIME":case"EXT-X-DATERANGE":case"EXT-X-CUE-OUT":case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT-CONT":case"EXT-X-CUE":case"EXT-OATCLS-SCTE35":case"EXT-X-ASSET":case"EXT-X-SCTE35":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":return"Segment";case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":case"EXT-X-ENDLIST":case"EXT-X-PLAYLIST-TYPE":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PREFETCH":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return"MediaPlaylist";case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":return"MasterPlaylist";case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-START":return"MediaorMasterPlaylist";default:return"Unknown"}}(i);if(function(t,e){if("Segment"===t||"MediaPlaylist"===t)return void 0===e.isMasterPlaylist?void(e.isMasterPlaylist=!1):void(e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",m,1024));if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",m,1034)}}(r,e),"Unknown"===r)return null;"MediaPlaylist"===r&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&p.h2("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist",m,1055),e.hash[i]=!0);const[n,o]=function(t,e){switch(t){case"EXTM3U":case"EXT-X-DISCONTINUITY":case"EXT-X-ENDLIST":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-CUE-IN":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[u.Ro(e),null];case"EXT-X-CUE-OUT":return a()(Number(e))?[null,S(e)]:[u.Ro(e),null];case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-DATERANGE":case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":case"EXT-X-START":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return[null,S(e)];case"EXTINF":return[T(e),null];case"EXT-X-BYTERANGE":return[E(e),null];case"EXT-X-PROGRAM-DATE-TIME":return[new Date(e),null];default:return[e,null]}}(i,s);return{name:i,category:r,value:n,attributes:o}}function D(t,e){let i;return e.isMasterPlaylist?i=function(t,e){const i=new c.ts;let s=!1;for(const[a,{name:r,value:n,attributes:o}]of t.entries())if("EXT-X-VERSION"===r)i.version=n;else if("EXT-X-STREAM-INF"===r){const r=t[a+1];("string"!=typeof r||r.startsWith("#EXT"))&&p.h2("EXT-X-STREAM-INF must be followed by a URI line",m,418);const n=b(t,o,r,!1,e);n&&("number"==typeof n.score&&(s=!0,n.score<0&&p.h2("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.",m,425)),i.variants.push(n))}else if("EXT-X-I-FRAME-STREAM-INF"===r){const s=b(t,o,o.URI,!0,e);s&&i.variants.push(s)}else if("EXT-X-SESSION-DATA"===r){const t=new c.pf({id:o["DATA-ID"],value:o.VALUE,uri:o.URI,language:o.LANGUAGE});i.sessionDataList.some((e=>e.id===t.id&&e.language===t.language))&&p.h2("A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute.",m,445),i.sessionDataList.push(t)}else if("EXT-X-SESSION-KEY"===r){"NONE"===o.METHOD&&p.h2("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE",m,451);const t=new c.Uz({method:o.METHOD,uri:o.URI,iv:o.IV,format:o.KEYFORMAT,formatVersion:o.KEYFORMATVERSIONS});i.sessionKeyList.some((e=>X(e,t)))&&p.h2("A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values.",m,461),v(e,o),i.sessionKeyList.push(t)}else"EXT-X-INDEPENDENT-SEGMENTS"===r?(i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",m,468),i.independentSegments=!0):"EXT-X-START"===r&&(i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",m,474),"number"!=typeof o["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",m,477),i.start={offset:o["TIME-OFFSET"],precise:o.PRECISE||!1});if(s)for(const t of i.variants)"number"!=typeof t.score&&p.h2("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute",m,485);if(e.isClosedCaptionsNone)for(const t of i.variants)t.closedCaptions.length>0&&p.h2("If there is a variant with CLOSED-CAPTIONS attribute of NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE",m,492);return i}(t,e):(i=function(t,e){const i=new c.tk;let s=-1,a=0,r=!1,n=!1,o=0,h=null,l=null,u=!1;for(const[d,f]of t.entries()){const{name:T,value:E,attributes:y,category:A}=f;if("Segment"!==A){if("EXT-X-VERSION"===T)void 0===i.version?i.version=E:p.h2("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.",m,721);else if("EXT-X-TARGETDURATION"===T)i.targetDuration=e.targetDuration=E;else if("EXT-X-MEDIA-SEQUENCE"===T)i.segments.length>0&&p.h2("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",m,729),i.mediaSequenceBase=a=E;else if("EXT-X-DISCONTINUITY-SEQUENCE"===T)i.segments.length>0&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",m,735),r&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag.",m,738),i.discontinuitySequenceBase=o=E;else if("EXT-X-ENDLIST"===T)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===T)i.playlistType=E;else if("EXT-X-I-FRAMES-ONLY"===T)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===T)i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",m,756),i.independentSegments=!0;else if("EXT-X-START"===T)i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",m,762),"number"!=typeof y["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",m,765),i.start={offset:y["TIME-OFFSET"],precise:y.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===T)y["CAN-BLOCK-RELOAD"]||p.h2("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS",m,771),i.lowLatencyCompatibility={canBlockReload:y["CAN-BLOCK-RELOAD"],canSkipUntil:y["CAN-SKIP-UNTIL"],holdBack:y["HOLD-BACK"],partHoldBack:y["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===T)y["PART-TARGET"]||p.h2("EXT-X-PART-INF: PART-TARGET attribute is mandatory",m,782),i.partTargetDuration=y["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===T)y.URI||p.h2("EXT-X-RENDITION-REPORT: URI attribute is mandatory",m,788),0===y.URI.search(/^[a-z]+:/)&&p.h2("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri",m,791),i.renditionReports.push(new c.h4({uri:y.URI,lastMSN:y["LAST-MSN"],lastPart:y["LAST-PART"]}));else if("EXT-X-SKIP"===T)y["SKIPPED-SEGMENTS"]||p.h2("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory",m,801),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=y["SKIPPED-SEGMENTS"],a+=i.skip;else if("EXT-X-PREFETCH"===T){const r=R(t,E,-1===s?d:s,d-1,a++,o,e);r&&(r.discontinuity&&(r.discontinuitySequence++,o=r.discontinuitySequence),r.key?h=r.key:null===r.key?h=void 0:r.key=h,i.prefetchSegments.push(r)),n=!0,s=-1}else if("string"==typeof f){-1===s&&p.h2("A URI line is not preceded by any segment tags",m,841),i.targetDuration||p.h2("The EXT-X-TARGETDURATION tag is REQUIRED",m,844),n&&p.h2("These segments must appear after all complete segments.",m,847);const r=N(t,f,s,d-1,a++,o,e);r&&(null===r.key&&(h=void 0),[o,h,l]=P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)),s=-1}}else-1===s&&(s=d),"EXT-X-DISCONTINUITY"===T&&(r=!0)}if(-1!==s){const r=N(t,"",s,t.length-1,a++,o,e);if(r){var f;null===r.key&&(h=void 0);const{parts:t}=r;!(t.length>0)||i.endlist||null!==(f=t[t.length-1])&&void 0!==f&&f.hint||p.h2("If the Playlist contains EXT-X-PART tags and does not contain an EXT-X-ENDLIST tag, the Playlist must contain an EXT-X-PRELOAD-HINT tag with a TYPE=PART attribute",m,870),P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)}}return function(t){const e=new(d()),i=new(d());let s=!1,a=!1;for(let r=t.length-1;r>=0;r--){const{programDateTime:n,dateRange:o}=t[r];if(n&&(a=!0),o&&o.start){s=!0,o.endOnNext&&(o.end||o.duration)&&p.h2("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.",m,937);const t=o.start.getTime(),a=o.duration||0;o.end&&o.duration&&t+1e3*a!==o.end.getTime()&&p.h2("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION",m,943),o.endOnNext&&(o.end=e.get(o.classId)),e.set(o.classId,o.start);const r=o.end?o.end.getTime():o.start.getTime()+1e3*(o.duration||0),n=i.get(o.classId);if(n){for(const e of n)(e.start<=t&&e.end>t||e.start>=t&&e.start<r)&&p.h2("DATERANGE tags with the same CLASS should not overlap",m,955);n.push({start:t,end:r})}else o.classId&&i.set(o.classId,[{start:t,end:r}])}}s&&!a&&p.h2("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.",m,966)}(i.segments),i.lowLatencyCompatibility&&function({lowLatencyCompatibility:t,targetDuration:e,partTargetDuration:i,segments:s,renditionReports:a},r){const{canSkipUntil:n,holdBack:o,partHoldBack:h}=t;if(n<6*e&&p.h2("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.",m,973),o<3*e&&p.h2("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.",m,977),r){void 0===i&&p.h2("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags",m,981),void 0===h&&p.h2("EXT-X-PART: PART-HOLD-BACK attribute is mandatory",m,984),h<i&&p.h2("PART-HOLD-BACK must be at least PART-TARGET",m,987);for(const[t,{parts:e}]of s.entries())for(const[t,{duration:s}]of e.entries())void 0!==s&&(s>i&&p.h2("PART-TARGET is the maximum duration of any Partial Segment",m,998),t<e.length-1&&s<.85*i&&p.h2("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET",m,1001))}for(const t of a){const e=s[s.length-1];null!==t.lastMSN&&void 0!==t.lastMSN||(t.lastMSN=e.mediaSequenceNumber),(null===t.lastPart||void 0===t.lastPart)&&e.parts.length>0&&(t.lastPart=e.parts.length-1)}}(i,u),i.duration=i.segments.reduce(((t,e)=>"number"==typeof e.duration?t+e.duration:t),0),i}(t,e),!i.isIFrame&&e.hasMap&&e.compatibleVersion<6&&(e.compatibleVersion=6)),e.compatibleVersion>1&&(!i.version||i.version<e.compatibleVersion)&&p.h2(`EXT-X-VERSION needs to be ${e.compatibleVersion} or higher.`,m,1105),i}function w(t){const e={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},i=function(t,e){const i=[];for(const s of t.split("\n")){const t=s.trim();if(t)if(t.startsWith("#")){if(t.startsWith("#EXT")){const s=L(t,e);s&&i.push(s)}}else i.push(t)}return 0!==i.length&&"EXTM3U"===i[0].name||p.h2("The EXTM3U tag MUST be the first line.",m,1087),i}(t,e),s=D(i,e);return s.source=t,s}},41497:(t,e,i)=>{"use strict";i.d(e,{KT:()=>n,Uz:()=>h,Vd:()=>y,Y4:()=>T,ad:()=>d,h4:()=>A,nw:()=>E,pf:()=>o,qP:()=>l,ru:()=>r,tk:()=>f,ts:()=>m,xC:()=>u});var s=i(9655),a=i(80155);class r{constructor({type:t,uri:e,groupId:i,language:a,assocLanguage:r,name:n,isDefault:o,autoselect:h,forced:l,instreamId:d,characteristics:u,channels:c}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"groupId",void 0),(0,s.A)(this,"language",void 0),(0,s.A)(this,"assocLanguage",void 0),(0,s.A)(this,"name",void 0),(0,s.A)(this,"isDefault",void 0),(0,s.A)(this,"autoselect",void 0),(0,s.A)(this,"forced",void 0),(0,s.A)(this,"instreamId",void 0),(0,s.A)(this,"characteristics",void 0),(0,s.A)(this,"channels",void 0),this.type=t,this.uri=e,this.groupId=i,this.language=a,this.assocLanguage=r,this.name=n,this.isDefault=o,this.autoselect=h,this.forced=l,this.instreamId=d,this.characteristics=u,this.channels=c}}class n{constructor({uri:t,isIFrameOnly:e=!1,bandwidth:i,averageBandwidth:a,score:r,codecs:n,resolution:o,frameRate:h,hdcpLevel:l,allowedCpc:d,videoRange:u,stableVariantId:c,programId:p,audio:m=[],video:f=[],subtitles:T=[],closedCaptions:E=[],currentRenditions:y={audio:0,video:0,subtitles:0,closedCaptions:0}}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"isIFrameOnly",void 0),(0,s.A)(this,"bandwidth",void 0),(0,s.A)(this,"averageBandwidth",void 0),(0,s.A)(this,"score",void 0),(0,s.A)(this,"codecs",void 0),(0,s.A)(this,"resolution",void 0),(0,s.A)(this,"frameRate",void 0),(0,s.A)(this,"hdcpLevel",void 0),(0,s.A)(this,"allowedCpc",void 0),(0,s.A)(this,"videoRange",void 0),(0,s.A)(this,"stableVariantId",void 0),(0,s.A)(this,"programId",void 0),(0,s.A)(this,"audio",void 0),(0,s.A)(this,"video",void 0),(0,s.A)(this,"subtitles",void 0),(0,s.A)(this,"closedCaptions",void 0),(0,s.A)(this,"currentRenditions",void 0),this.uri=t,this.isIFrameOnly=e,this.bandwidth=i,this.averageBandwidth=a,this.score=r,this.codecs=n,this.resolution=o,this.frameRate=h,this.hdcpLevel=l,this.allowedCpc=d,this.videoRange=u,this.stableVariantId=c,this.programId=p,this.audio=m,this.video=f,this.subtitles=T,this.closedCaptions=E,this.currentRenditions=y}}class o{constructor({id:t,value:e,uri:i,language:a}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"value",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"language",void 0),this.id=t,this.value=e,this.uri=i,this.language=a}}class h{constructor({method:t,uri:e,iv:i,format:a,formatVersion:r}){(0,s.A)(this,"method",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"format",void 0),(0,s.A)(this,"formatVersion",void 0),this.method=t,this.uri=e,this.iv=i,this.format=a,this.formatVersion=r}}class l{constructor({hint:t=!1,uri:e,mimeType:i,byterange:a,key:r}){(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"key",void 0),this.hint=t,this.uri=e,this.mimeType=i,this.byterange=a,this.key=r}}class d{constructor({id:t,classId:e,start:i,end:a,duration:r,plannedDuration:n,endOnNext:o,attributes:h={}}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"classId",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"end",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"plannedDuration",void 0),(0,s.A)(this,"endOnNext",void 0),(0,s.A)(this,"attributes",void 0),this.id=t,this.classId=e,this.start=i,this.end=a,this.duration=r,this.plannedDuration=n,this.endOnNext=o,this.attributes=h}}class u{constructor({type:t,duration:e,tagName:i,value:a}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"tagName",void 0),(0,s.A)(this,"value",void 0),this.type=t,this.duration=e,this.tagName=i,this.value=a}}class c{constructor(t){(0,s.A)(this,"type",void 0),this.type=t}}class p extends c{constructor({isMasterPlaylist:t,uri:e,version:i,independentSegments:a=!1,start:r,source:n}){super("playlist"),(0,s.A)(this,"isMasterPlaylist",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"independentSegments",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"source",void 0),this.isMasterPlaylist=t,this.uri=e,this.version=i,this.independentSegments=a,this.start=r,this.source=n}}class m extends p{constructor(t={}){super({...t,isMasterPlaylist:!0}),(0,s.A)(this,"variants",void 0),(0,s.A)(this,"currentVariant",void 0),(0,s.A)(this,"sessionDataList",void 0),(0,s.A)(this,"sessionKeyList",void 0);const{variants:e=[],currentVariant:i,sessionDataList:a=[],sessionKeyList:r=[]}=t;this.variants=e,this.currentVariant=i,this.sessionDataList=a,this.sessionKeyList=r}}class f extends p{constructor(t={}){super({...t,isMasterPlaylist:!1}),(0,s.A)(this,"targetDuration",void 0),(0,s.A)(this,"mediaSequenceBase",void 0),(0,s.A)(this,"discontinuitySequenceBase",void 0),(0,s.A)(this,"endlist",void 0),(0,s.A)(this,"playlistType",void 0),(0,s.A)(this,"isIFrame",void 0),(0,s.A)(this,"segments",void 0),(0,s.A)(this,"prefetchSegments",void 0),(0,s.A)(this,"lowLatencyCompatibility",void 0),(0,s.A)(this,"partTargetDuration",void 0),(0,s.A)(this,"renditionReports",void 0),(0,s.A)(this,"skip",void 0),(0,s.A)(this,"hash",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"timestamp",void 0);const{targetDuration:e,mediaSequenceBase:i=0,discontinuitySequenceBase:r=0,endlist:n=!1,playlistType:o,isIFrame:h,segments:l=[],prefetchSegments:d=[],lowLatencyCompatibility:u,partTargetDuration:c,renditionReports:p=[],skip:m=0,hash:f,duration:T=0}=t;this.targetDuration=e,this.mediaSequenceBase=i,this.discontinuitySequenceBase=r,this.endlist=n,this.playlistType=o,this.isIFrame=h,this.segments=l,this.prefetchSegments=d,this.lowLatencyCompatibility=u,this.partTargetDuration=c,this.renditionReports=p,this.skip=m,this.hash=f,this.duration=T,this.timestamp=(0,a.A)()}}class T extends c{constructor({uri:t,mimeType:e,data:i,duration:a,title:r,byterange:n,discontinuity:o,mediaSequenceNumber:h=0,discontinuitySequence:l=0,key:d,map:u,programDateTime:c,dateRange:p,markers:m=[],parts:f=[]}){super("segment"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"data",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"title",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"map",void 0),(0,s.A)(this,"programDateTime",void 0),(0,s.A)(this,"dateRange",void 0),(0,s.A)(this,"markers",void 0),(0,s.A)(this,"parts",void 0),this.uri=t,this.mimeType=e,this.data=i,this.duration=a,this.title=r,this.byterange=n,this.discontinuity=o,this.mediaSequenceNumber=h,this.discontinuitySequence=l,this.key=d,this.map=u,this.programDateTime=c,this.dateRange=p,this.markers=m,this.parts=f}}class E extends c{constructor({hint:t=!1,uri:e,duration:i,independent:a,byterange:r,gap:n}){super("part"),(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"independent",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"gap",void 0),this.hint=t,this.uri=e,this.duration=i,this.independent=a,this.duration=i,this.byterange=r,this.gap=n}}class y extends c{constructor({uri:t,discontinuity:e,mediaSequenceNumber:i=0,discontinuitySequence:a=0,key:r}){super("prefetch"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),this.uri=t,this.discontinuity=e,this.mediaSequenceNumber=i,this.discontinuitySequence=a,this.key=r}}class A{constructor({uri:t,lastMSN:e,lastPart:i}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"lastMSN",void 0),(0,s.A)(this,"lastPart",void 0),this.uri=t,this.lastMSN=e,this.lastPart=i}}},91325:(t,e,i)=>{"use strict";i.d(e,{Bq:()=>c,HG:()=>p,Ro:()=>l,Th:()=>m,gI:()=>u,m2:()=>d});var s=i(46181),a=i.n(s),r=i(27138),n=i.n(r),o=i(14265),h=i.n(o);function l(t,e=10){if("number"==typeof t)return t;const i=10===e?a()(t):n()(t,e);return h()(i)?0:i}function d(t){(t.startsWith("0x")||t.startsWith("0X"))&&(t=t.slice(2));const e=[];for(let i=0;i<t.length;i+=2)e.push(l(t.slice(i,i+2),16));return new Uint8Array(e)}function u(t,e,i=0){let s=-1;for(let a=0,r=0;a<t.length;a++)if(t[a]===e){if(r++===i)return[t.slice(0,a),t.slice(a+1)];s=a}return-1!==s?[t.slice(0,s),t.slice(s+1)]:[t]}function c(t,e=" "){return t?(t=t.trim()," "===e||(t.startsWith(e)&&(t=t.slice(1)),t.endsWith(e)&&(t=t.slice(0,-1))),t):t}function p(t){const e=[];let i=!0,s=0;const a=[];for(let r=0;r<t.length;r++){const n=t[r];i&&","===n?(e.push(t.slice(s,r).trim()),s=r+1):'"'!==n&&"'"!==n||(i?(a.push(n),i=!1):n===a[a.length-1]?(a.pop(),i=!0):a.push(n))}return e.push(t.slice(s).trim()),e}function m(t){const e=[];let i=!1;for(const s of t)"-"!==s&&"_"!==s?i?(e.push(s.toUpperCase()),i=!1):e.push(s.toLowerCase()):i=!0;return e.join("")}},93426:(t,e,i)=>{"use strict";i.d(e,{$$:()=>r,Eh:()=>f,HR:()=>a,IY:()=>g,Ki:()=>A,Ld:()=>l,Mb:()=>E,Sz:()=>u,Xp:()=>h,_R:()=>n,_m:()=>m,d8:()=>T,iW:()=>c,mX:()=>p,n1:()=>o,os:()=>s,qO:()=>d,u6:()=>y});const s={86017:"mp3",86018:"mp4a.40",86021:"vorbis",86028:"flac",86076:"opus",65542:"ulaw",65543:"alaw",86019:"ac-3",86056:"ec-3",86020:"dtsc",65541:"pcm-u8",65540:"pcm-s8",65536:"pcm-s16",65537:"pcm-s16be",65548:"pcm-s24",65549:"pcm-s24be",65544:"pcm-s32",65545:"pcm-s32be",65557:"pcm-f32",65556:"pcm-f32be",65559:"pcm-f64",65558:"pcm-f64be",225:"av01",27:"avc1",173:"hev1",196:"vvc1",139:"vp8",167:"vp09",12:"mp4v"},a={flv:0,mp4:1,m4s:1,mov:1,ts:2,mts:2,m2ts:2,ivf:5,opus:4,oggs:4,ogg:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,mka:8,webm:9,aac:15,flac:17,wav:16,srt:19,vtt:18,ssa:20,ass:20,xml:21,ttml:21,h264:11,264:11,avc:11,h265:12,265:12,hevc:12,h266:13,266:13,vvc:13,mpeg:3,mpg:3,rtsp:6,rtmp:7,avi:10,avif:1,heic:1},r={m3u8:4,m3u:4,mpd:5},n={copy:0,h264:27,h261:3,h263:4,h263i:20,h263p:19,mjpeg:7,wmv1:17,wmv2:18,wmv3:71,avc:27,hevc:173,h265:173,vvc:196,h266:196,av1:225,vp9:167,vp8:139,mpeg4:12,theora:30,mpeg2video:2,rv10:5,rv20:6,rv30:68,rv40:69,png:61,bmp:78,webp:171,tiff:96,gif:97},o={copy:0,aac:86018,ac3:86019,eac3:86056,dts:86020,mp3:86017,opus:86076,flac:86028,speex:86051,vorbis:86021,pcm_alaw:65543,pcm_mulaw:65542,wmav1:86023,wmav2:86024,cook:86036,sipr:86057,ralf:86073,pcm_u8:65541,pcm_s16le:65536,pcm_s24le:65548,pcm_s32le:65544,pcm_s64le:65567,pcm_f32le:65557,pcm_f64le:65559},h={webvtt:94226,subrip:94225,ass:94230,ttml:94232,mov_text:94213,hdmv_pgs:94214,hdmv_text:94231,dvd:94208,dvb:94209,eia_608:94218},l={bin_data:98314},d={yuv420p:0,yuv422p:4,yuv444p:5,yuva420p:33,yuva422p:78,yuva444p:79,yuvj420p:12,yuvj422p:13,yuvj444p:14,yuv420p10le:62,yuv422p10le:64,yuv444p10le:68,yuva420p10le:87,yuva422p10le:89,yuva444p10le:91,yuv420p10be:61,yuv422p10be:63,yuv444p10be:67,yuva420p10be:86,yuva422p10be:88,yuva444p10be:90,rgba:26,rgb24:2,bgr24:3,gray:8},u={u8:0,"u8-planar":5,s16:1,"s16-planar":6,s32:2,"s32-planar":7,s64:10,"s64-planar":11,float:3,"float-planar":8,double:4,"double-planar":9},c={flv:0,isobmff:1,mp4:1,mov:1,ts:2,mpegts:2,mpeg:3,ivf:5,ogg:4,opus:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,matroska:8,mka:8,webm:9,aac:15,flac:17,wav:16,raw_h264:11,raw_h265:12,raw_vvc:13,rtsp:6,rtmp:7,avi:10},p={tv:1,pc:2},m={bt709:1,fcc:4,bt470bg:5,smpte170m:6,smpte240m:7,ycgco:8,gbr:0,bt2020nc:9},f={bt709:1,bt470m:4,bt470bg:5,smpte170m:6,smpte240m:7,smpte428:10,film:8,smpte431:11,smpte432:12,bt2020:9,"jedec-p22":22,ebu3213:22},T={bt709:1,gamma22:4,gamma28:5,smpte170m:6,smpte240m:7,srgb:13,xvycc:11,"bt2020-10":14,"bt2020-12":15,smpte2084:16,"arib-std-b67":18},E={Audio:1,Video:0,Subtitle:3,Attachment:4,Data:2},y={"Tile Grid":3,"Audio Element":1,"Mix Presentation":2},A={default:1,dub:2,original:4,comment:8,lyrics:16,karaoke:32,forced:64,"hearing impaired":128,"visual impaired":256,"clean effects":512,"attached pic":1024,"timed thumbnails":2048,captions:65536,descriptions:131072,metadata:262144,dependent:524288,"still image":1048576,thumbnail:8192},g={mono:4,stereo:3,2.1:11,"3.0":7,"3.0(back)":259,"4.0":263,quad:51,"quad(side)":1539,3.1:15,"5.0":55,"5.0(side)":1543,4.1:271,5.1:63,"5.1(side)":1551,"6.0":1799,"6.0(front)":1731,"3.1.2":20495,hexagonal:311,6.1:1807,"6.1(back)":319,"6.1(front)":1739,"7.0":1591,"7.0(front)":1735,7.1:1599,"7.1(wide)":255,"7.1(wide-side)":1743,"5.1.2":20543,octagonal:1847,cube:184371,"5.1.4":184383,"7.1.2":22079,"7.1.4":185919,"7.2.3":34359825983,"9.1.4":186111,hexadecagonal:6442710839,downmix:1610612736,22.2:2164663779327}},54893:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(9655);class a{constructor(t=0){(0,s.A)(this,"rcon",[0,1,2,4,8,16,32,64,128,27,54]),(0,s.A)(this,"subMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"invSubMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"sBox",new Uint32Array(256)),(0,s.A)(this,"invSBox",new Uint32Array(256)),(0,s.A)(this,"key",new Uint32Array(0)),(0,s.A)(this,"ksRows",0),(0,s.A)(this,"keySize",0),(0,s.A)(this,"keySchedule",void 0),(0,s.A)(this,"invKeySchedule",void 0),this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],a=i[1],r=i[2],n=i[3],o=this.invSubMix,h=o[0],l=o[1],d=o[2],u=o[3],c=new Uint32Array(256);let p=0,m=0,f=0;for(f=0;f<256;f++)c[f]=f<128?f<<1:f<<1^283;for(f=0;f<256;f++){let i=m^m<<1^m<<2^m<<3^m<<4;i=i>>>8^255&i^99,t[p]=i,e[i]=p;const o=c[p],f=c[o],T=c[f];let E=257*c[i]^16843008*i;s[p]=E<<24|E>>>8,a[p]=E<<16|E>>>16,r[p]=E<<8|E>>>24,n[p]=E,E=16843009*T^65537*f^257*o^16843008*p,h[i]=E<<24|E>>>8,l[i]=E<<16|E>>>16,d[i]=E<<8|E>>>24,u[i]=E,p?(p=o^c[c[c[T^o]]],m^=c[c[m]]):p=m=1}}async expandKey(t){const e=this.uint8ArrayToUint32Array_(t);if(this.key){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.key[i],i++;if(t)return}this.key=e;const i=this.keySize=this.key.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);const s=this.ksRows=4*(i+6+1);let a,r;const n=this.keySchedule=new Uint32Array(s),o=this.invKeySchedule=new Uint32Array(s),h=this.sBox,l=this.rcon,d=this.invSubMix,u=d[0],c=d[1],p=d[2],m=d[3];let f,T;for(a=0;a<s;a++)a<i?f=n[a]=e[a]:(T=f,a%i==0?(T=T<<8|T>>>24,T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T],T^=l[a/i|0]<<24):i>6&&a%i==4&&(T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T]),n[a]=f=(n[a-i]^T)>>>0);for(r=0;r<s;r++)a=s-r,T=3&r?n[a]:n[a-4],o[r]=r<4||a<=4?T:u[h[T>>>24]]^c[h[T>>>16&255]]^p[h[T>>>8&255]]^m[h[255&T]],o[r]=o[r]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}async decrypt(t,e){const i=this.keySize+6,s=this.invKeySchedule,a=this.invSBox,r=this.invSubMix,n=r[0],o=r[1],h=r[2],l=r[3],d=this.uint8ArrayToUint32Array_(e);let u=d[0],c=d[1],p=d[2],m=d[3];const f=new Int32Array(t.buffer).subarray(t.byteOffset>>>2,(t.byteOffset>>>2)+(t.length>>>2)),T=new Int32Array(f.length);let E,y,A,g,v,S,I,b,X,N,R,P,L,D;const w=this.networkToHostOrderSwap;let O=0;for(;O<f.length;){for(X=w(f[O]),N=w(f[O+1]),R=w(f[O+2]),P=w(f[O+3]),v=X^s[0],S=P^s[1],I=R^s[2],b=N^s[3],L=4,D=1;D<i;D++)E=n[v>>>24]^o[S>>16&255]^h[I>>8&255]^l[255&b]^s[L],y=n[S>>>24]^o[I>>16&255]^h[b>>8&255]^l[255&v]^s[L+1],A=n[I>>>24]^o[b>>16&255]^h[v>>8&255]^l[255&S]^s[L+2],g=n[b>>>24]^o[v>>16&255]^h[S>>8&255]^l[255&I]^s[L+3],v=E,S=y,I=A,b=g,L+=4;E=a[v>>>24]<<24^a[S>>16&255]<<16^a[I>>8&255]<<8^a[255&b]^s[L],y=a[S>>>24]<<24^a[I>>16&255]<<16^a[b>>8&255]<<8^a[255&v]^s[L+1],A=a[I>>>24]<<24^a[b>>16&255]<<16^a[v>>8&255]<<8^a[255&S]^s[L+2],g=a[b>>>24]<<24^a[v>>16&255]<<16^a[S>>8&255]<<8^a[255&I]^s[L+3],T[O]=w(E^u),T[O+1]=w(g^c),T[O+2]=w(A^p),T[O+3]=w(y^m),u=X,c=N,p=R,m=P,O+=4}return T.buffer}}},10855:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(9655);class a{constructor(t=0){(0,s.A)(this,"subtle",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"keyBuffer",void 0),this.mode=t,this.subtle=crypto.subtle||crypto.webkitSubtle}getSubtleAlgoName(){switch(this.mode){case 0:return"AES-CBC";case 1:return"AES-CTR"}}async expandKey(t){let e=new Uint8Array(t);if(this.keyBuffer){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.keyBuffer[i],i++;if(t)return}this.keyBuffer=e,this.key=await this.subtle.importKey("raw",t,{name:this.getSubtleAlgoName()},!1,["encrypt","decrypt"])}async encryptPadding(t,e){return new Uint8Array(await crypto.subtle.encrypt({name:"AES-CBC",iv:e},this.key,t))}async decrypt(t,e){switch(this.mode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:e},this.key,t);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:e,length:64},this.key,t)}}static isSupport(){return"object"==typeof(crypto.subtle||crypto.webkitSubtle)}}},97023:(t,e,i)=>{"use strict";i(68483),i(31126)},10446:(t,e,i)=>{"use strict";function s(t){const e=t,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let a="";s.test(t)&&(t=t.replace(s,((t,e,i)=>(a=i,`://${e||""}a.b`))));const r={},n=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let o=14;for(;o--;){var h;r[i[o]]=null!==(h=n[o])&&void 0!==h?h:""}return a&&(r.host=a,r.source=e,r.authority=a+(r.port?":"+r.port:"")),{protocol:r.protocol,file:r.file,host:r.host,port:r.port,user:r.user,password:r.password,origin:`${r.protocol}://${r.authority}`,pathname:r.path,search:`?${r.query}`,hash:r.anchor?`#${r.anchor}`:""}}i.d(e,{ll:()=>u,qg:()=>s}),i(38035),i(68483),i(97023),i(31126),i(99868);const a=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function h(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function l(t){const e=o.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null}function d(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(r,"")).length;);return t.split("").reverse().join("")}function u(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;let e=l(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=d(e.path),h(e)}let s=l(e);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=d(s.path),h(s)):e;let a=l(t);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){let t=n.exec(a.path);a.netLoc=t[1],a.path=t[2]}a.netLoc&&!a.path&&(a.path="/");const r={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(r.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){let t=a.path,e=t.substring(0,t.lastIndexOf("/")+1)+s.path;r.path=d(e)}else r.path=a.path,s.params||(r.params=a.params,s.query||(r.query=a.query));return null===r.path&&(r.path=i.alwaysNormalize?d(s.path):s.path),h(r)}},6431:(t,e,i)=>{var s=i(54446),a=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return a.stringify.apply(a,arguments)}},52214:(t,e,i)=>{i(56930),t.exports=i(54446).Number.isInteger},49669:(t,e,i)=>{i(37305),t.exports=i(54446).Number.isNaN},4801:(t,e,i)=>{i(80613),t.exports=i(54446).Number.parseFloat},81646:(t,e,i)=>{i(50338),t.exports=i(54446).Number.parseInt},40738:(t,e,i)=>{var s=i(72441),a=Math.floor;t.exports=function(t){return!s(t)&&isFinite(t)&&a(t)===t}},56930:(t,e,i)=>{var s=i(78255);s(s.S,"Number",{isInteger:i(40738)})},37305:(t,e,i)=>{var s=i(78255);s(s.S,"Number",{isNaN:function(t){return t!=t}})},80613:(t,e,i)=>{var s=i(78255),a=i(50149);s(s.S+s.F*(Number.parseFloat!=a),"Number",{parseFloat:a})},50338:(t,e,i)=>{var s=i(78255),a=i(25634);s(s.S+s.F*(Number.parseInt!=a),"Number",{parseInt:a})},38035:(t,e,i)=>{t.exports=i(6431)},89730:(t,e,i)=>{t.exports=i(52214)},14265:(t,e,i)=>{t.exports=i(49669)},46181:(t,e,i)=>{t.exports=i(4801)},27138:(t,e,i)=>{t.exports=i(81646)}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[60],{89984:(t,e,i)=>{i.d(e,{A:()=>n});var s=i(9655);class n{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},29060:(t,e,i)=>{i.r(e),i.d(e,{default:()=>p});var s=i(9655),n=i(36311),r=i(20163),a=i(20086),o=i(89984),h=i(41321),u=i(1140),d=i(37142),c=i(31126),f=i(19372),l=i(7782),g=i(89378),B=i(69663);const m="src/avformat/formats/IWebVttFormat.ts";class p extends o.A{constructor(){super(),(0,s.A)(this,"type",18),(0,s.A)(this,"queue",void 0),(0,s.A)(this,"index",void 0),(0,s.A)(this,"baseTs",void 0)}init(t){this.queue=[],this.baseTs=BigInt(0)}async readChunk(t){let e="";const i=t.ioReader.getPos();for(;;){const i=await t.ioReader.readLine();if(""===i||"WEBVTT"===i)break;e+=i+"\n"}return{chunk:e.trim(),pos:i}}async readCue(t,e){for(;;){const{chunk:i,pos:s}=await this.readChunk(t);if(""===i||/^NOTE/.test(i)||"WEBVTT"===i)continue;if(/^STYLE/.test(i)){e.push({style:i.replace(/STYLE[\s|\n]?/,""),pos:s});continue}if(/^X-TIMESTAMP-MAP/.test(i)){const t=i.split("=")[1].split(",");let e=BigInt(0),s=BigInt(0);t.forEach((t=>{const i=t.split(":");"LOCAL"===i[0]?(i.shift(),e=(0,l.j)(i.join(":").trim())):"MPEGTS"===i[0]&&(s=BigInt(+i[1])*BigInt(1e3)/BigInt(9e4))})),this.baseTs=s-e;continue}const n=i.split("\n");let r,a;-1===n[0].indexOf("--\x3e")&&(r=n.shift().trim());let o=n.shift().split("--\x3e");const h=(0,l.j)(o.shift())+this.baseTs;o=o.shift().trim().split(" ");const u=(0,l.j)(o.shift())+this.baseTs;if(u<=h)continue;o=o.filter((t=>""!==t)),o.length&&(a=o.join(" "));const d=n.join("\n").trim();if(d)return{identifier:r,options:a,context:d,startTs:h,endTs:u,pos:s}}}async readHeader(t){const e=await t.ioReader.peekBuffer(3);if(239===e[0]&&187===e[1]&&191===e[2]&&await t.ioReader.skip(3),"WEBVTT"!==await t.ioReader.peekString(6))return r.z3("the file format is not vtt",m,169),a.LR;const i=t.createStream();i.codecpar.codecId=94226,i.codecpar.codecType=3,i.timeBase.den=1e3,i.timeBase.num=1;const s=await t.ioReader.readLine();s.indexOf("-")>0&&(i.metadata.title=s.split("-").pop().trim()),this.index=0;const n=[];let o=BigInt(0);try{for(;;){const e=await this.readCue(t,n);if(i.nbFrames++,i.duration=e.endTs,e.startTs>=o?(this.queue.push(e),o=e.startTs):c._(this.queue,e,(t=>t.startTs<e.startTs?1:-1)),2&t.ioReader.flags)break}}catch(t){}return i.metadata.styles=n,0}async readAVPacket(t,e){const i=t.streams.find((t=>3===t.codecpar.codecType));if(2&t.ioReader.flags){if(this.index>=this.queue.length)try{const s=await this.readCue(t,i.metadata.styles);if(this.queue.length){const i=this.queue[this.queue.length-1];if(i.startTs===s.startTs&&i.endTs===s.endTs&&i.context===s.context)return this.readAVPacket(t,e)}this.queue.push(s),i.nbFrames++,i.duration=s.endTs}catch(e){return-1048576!==t.ioReader.error&&-1048572!==t.ioReader.error?(r.z3(`read cue error, ${e}`,m,252),a.LR):t.ioReader.error}}else{if(!this.queue.length)return a.LR;if(this.index>=this.queue.length)return-1048576}const s=this.queue[this.index++];if(n.M[15](e+32,i.index),n.M[15](e+76,i.timeBase.den),n.M[15](e+72,i.timeBase.num),n.M[17](e+16,s.startTs),n.M[17](e+8,s.startTs),n.M[17](e+48,s.endTs-s.startTs),s.identifier){const t=f.encode(s.identifier),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,16,i,t.length)}if(s.options){const t=f.encode(s.options),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,17,i,t.length)}const o=f.encode(s.context),c=(0,u.sY)(o.length);return(0,h.lW)(c,o.length,o),(0,d.NX)(e,c,o.length),0}async seek(t,e,i,s){if(2&s)return BigInt(a.E$);if(16&s&&2&t.ioReader.flags){const s=(0,B.k)(i,e.timeBase,g.i0);return await t.ioReader.seek(s,!0),this.queue.length=0,this.index=0,BigInt(0)}if(i<=BigInt(0))return this.index=0,BigInt(0);const n=c.El(this.queue,(t=>t.startTs>i?-1:1));if(n>=0){for(r.Yz(`seek in cues, found index: ${n}, pts: ${this.queue[n].startTs}, pos: ${this.queue[n].pos}`,m,319),this.index=Math.max(n-1,0);this.index>0&&(this.queue[this.index-1].startTs===this.queue[this.index].startTs||this.queue[this.index-1].endTs>i);)this.index--;return BigInt(0)}return BigInt(a.LR)}getAnalyzeStreamsCount(){return 1}}},7782:(t,e,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,s=BigInt(+e.shift().trim());1===t?s*=BigInt(100):2===t&&(s*=BigInt(10)),i+=s}return 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,s=BigInt(+e.shift().trim());1===t?s*=BigInt(100):2===t&&(s*=BigInt(10)),i+=s}return i}i.d(e,{j:()=>s,t:()=>n})}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[620],{89984:(t,e,s)=>{s.d(e,{A:()=>r});var i=s(9655);class r{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},17620:(t,e,s)=>{s.r(e),s.d(e,{default:()=>y});var i=s(9655),r=s(16566),h=s(36311),n=s(20086),a=s(89984),u=s(41321),o=s(1140),d=s(37142),c=s(99868),f=s(64310),l=s(79240),p=s(89378),b=s(31531),g=s(42350),A=s(68006);const m={framerate:{num:30,den:1}};class y extends a.A{constructor(t={}){super(),(0,i.A)(this,"type",11),(0,i.A)(this,"options",void 0),(0,i.A)(this,"currentDts",void 0),(0,i.A)(this,"currentPts",void 0),(0,i.A)(this,"step",void 0),(0,i.A)(this,"slices",void 0),(0,i.A)(this,"naluPos",void 0),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"bitReader",void 0),(0,i.A)(this,"sliceType",void 0),(0,i.A)(this,"poc",void 0),(0,i.A)(this,"picOrderCntMsb",void 0),(0,i.A)(this,"lastPicOrderCntLsb",void 0),(0,i.A)(this,"frameNumberOffset",void 0),(0,i.A)(this,"prevFrameNumber",void 0),(0,i.A)(this,"sps",void 0),(0,i.A)(this,"naluReader",void 0),this.options=c.X$({},m,t)}init(t){t.ioReader&&t.ioReader.setEndian(!1),this.slices=[],this.queue=[],this.bitReader=new b.A(50),this.naluReader=new A.A}async destroy(t){if(this.queue.length){for(let t=0;t<this.queue.length;t++)(0,d.Qe)(this.queue[t].avpacket);this.queue.length=0}}isFrameNalu(t){const e=31&t[1===t[2]?3:4];return 1===e||5===e||2===e||3===e||4===e}async readNaluFrame(t){let e=!1;const s=this.slices;for(this.slices=[],s.length&&(e=this.isFrameNalu(s[0]));;){const i=await this.naluReader.read(t.ioReader);if(!i)return s;const r=31&i[1===i[2]?3:4];if(this.isFrameNalu(i))if(e){if(this.bitReader.reset(),this.bitReader.appendBuffer(i.subarray(1===i[2]?4:5,10)),0===g.xb(this.bitReader))return this.slices.push(i),s;s.push(i)}else s.push(i),e=!0;else{if(e&&(9===r||7===r||8===r))return this.slices.push(i),s;s.push(i)}}}async readHeader(t){const e=t.createStream();for(e.codecpar.codecType=0,e.codecpar.codecId=27,e.timeBase.den=p.SF,e.timeBase.num=1,e.codecpar.flags|=1,this.currentDts=BigInt(0),this.currentPts=BigInt(0),this.naluPos=BigInt(0),this.poc=BigInt(0),this.picOrderCntMsb=BigInt(0),this.lastPicOrderCntLsb=0,this.frameNumberOffset=BigInt(0),this.prevFrameNumber=0,this.step=BigInt(Math.floor(p.SF/this.options.framerate.num*this.options.framerate.den));;){const s=await this.readNaluFrame(t);if(!s.length)return-1048576;const i=(0,f.A)(Uint8Array,s);let n=l.sL(i);if(n){e.codecpar.extradata=(0,o.sY)(n.length),(0,u.lW)(e.codecpar.extradata,n.length,n),e.codecpar.extradataSize=n.length,l.XC(e,n);const a=s.find((t=>7==(31&t[1===t[2]?3:4])));this.sps=l.wf(a);const c=(0,d._5)(),f=(0,o.sY)(i.length);(0,u.lW)(f,i.length,i),(0,d.NX)(c,f,i.length),h.M[17](c+56,this.naluPos),this.naluPos+=BigInt(Math.floor(i.length)),h.M[17](c+16,this.currentDts),this.currentDts+=this.step,h.M[17](c+8,this.currentPts),this.currentPts+=this.step,h.M[15](c+32,e.index),h.M[15](c+36,1|r.f[15](c+36)),h.M[15](c+72,e.timeBase.num),h.M[15](c+76,e.timeBase.den),h.M[15](c+36,64|r.f[15](c+36)),t.interval.packetBuffer.push(c);break}this.naluPos+=BigInt(Math.floor(i.length))}return 0}async readAVPacket_(t,e){const s=t.getStreamByMediaType(0),i=await this.readNaluFrame(t);if(!i.length)return-1048576;this.sliceType=-1;let n=!1,a=!0;i.forEach((t=>{const e=1===t[2]?t[3]:t[4],s=31&e,i=e>>>5&3;if(7===s&&(this.sps=l.wf(t)),5===s&&(n=!0),(1===s||2===s||3===s||4===s||5===s)&&a){a=!1,this.bitReader.reset(),this.bitReader.appendBuffer(t.subarray(1===t[2]?4:5,50)),g.xb(this.bitReader),this.sliceType=g.xb(this.bitReader),g.xb(this.bitReader);const e=this.bitReader.readU(this.sps.log2MaxFrameNumMinus4+4);let r=0,h=0;if(this.sps.frameMbsOnlyFlag||(r=this.bitReader.readU1()),r&&(h=this.bitReader.readU1()),5===s&&g.xb(this.bitReader),0===this.sps.picOrderCntType){const t=this.bitReader.readU(this.sps.log2MaxPicOrderCntLsbMinus4+4),e=(1<<this.sps.log2MaxPicOrderCntLsbMinus4+4)-1;Math.abs(t-this.lastPicOrderCntLsb)>e>>>1&&(this.picOrderCntMsb+=BigInt(Math.floor(e))),this.poc=this.picOrderCntMsb+BigInt(Math.floor(t)),this.lastPicOrderCntLsb=t}else if(1===this.sps.picOrderCntType){const t=[0,0];if(this.sps.deltaPicOrderAlwaysZeroFlag||(t[0]=g.$x(this.bitReader),h&&(t[1]=g.$x(this.bitReader))),e<this.prevFrameNumber){const t=(1<<this.sps.log2MaxFrameNumMinus4+4)-1;this.frameNumberOffset+=BigInt(Math.floor(t))}let s=this.frameNumberOffset+BigInt(Math.floor(e));0===i&&s>0&&s--,this.poc=BigInt(2)*s+BigInt(0|t[0]),r&&h&&(this.poc+=BigInt(0|t[1])),this.prevFrameNumber=e}else this.poc++}}));const c=(0,f.A)(Uint8Array,i),p=(0,o.sY)(c.length);return(0,u.lW)(p,c.length,c),(0,d.NX)(e,p,c.length),h.M[17](e+56,this.naluPos),this.naluPos+=BigInt(Math.floor(c.length)),h.M[17](e+16,this.currentDts),this.currentDts+=this.step,h.M[15](e+32,s.index),h.M[15](e+72,s.timeBase.num),h.M[15](e+76,s.timeBase.den),h.M[15](e+36,64|r.f[15](e+36)),n&&h.M[15](e+36,1|r.f[15](e+36)),0}async readAVPacket(t,e){let s=this.queue.length;const i=()=>{this.queue.length>1&&this.queue.sort(((t,e)=>t.poc-e.poc>BigInt(0)?1:-1));for(let t=0;t<this.queue.length;t++)h.M[17](this.queue[t].avpacket+8,this.currentPts),this.currentPts+=this.step;this.queue.length>1&&this.queue.sort(((t,e)=>r.f[17](t.avpacket+16)-r.f[17](e.avpacket+16)>BigInt(0)?1:-1)),this.queue.length&&((0,d.rN)(e,this.queue[0].avpacket),(0,d.Qe)(this.queue[0].avpacket));for(let e=1;e<this.queue.length;e++)t.interval.packetBuffer.push(this.queue[e].avpacket);this.queue.length=0};for(;;){const e=(0,d._5)();let h=await this.readAVPacket_(t,e);if(h<0)return(0,d.Qe)(e),this.queue.length?(i(),0):h;if(1&r.f[15](e+36)||0===this.sliceType||2===this.sliceType||5===this.sliceType||7===this.sliceType){if(1===s||1&r.f[15](e+36)&&this.queue.length)return i(),this.queue.push({avpacket:e,poc:this.poc}),0;this.queue.push({avpacket:e,poc:this.poc}),s++}else this.queue.push({avpacket:e,poc:this.poc})}}async seek(t,e,s,i){const r=t.ioReader.getPos();return 2&i?(await t.ioReader.seek(s),r):BigInt(n.E$)}getAnalyzeStreamsCount(){return 1}}},68006:(t,e,s)=>{s.d(e,{A:()=>n});var i=s(9655),r=s(98755),h=s(64310);class n{constructor(){(0,i.A)(this,"buffer",void 0),(0,i.A)(this,"pos",void 0),(0,i.A)(this,"end",void 0),(0,i.A)(this,"ended",void 0),this.buffer=new Uint8Array(102400),this.pos=0,this.end=0,this.ended=!1}async read(t){if(this.ended&&this.pos>=this.end)return;const e=[];if(this.pos<this.end-4){let t=r.Ky(this.buffer.subarray(this.pos,this.end-4),3);if(t.offset>-1){const e=this.buffer.slice(this.pos,this.pos+t.offset);return this.pos+=t.offset,e}e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}for(;;){if(!this.ended&&this.end<this.buffer.length)try{const e=await t.readToBuffer(this.buffer.length-this.end,this.buffer.subarray(this.end));this.end+=e}catch(t){if(this.ended=!0,this.pos>=this.end)return e.length?(0,h.A)(Uint8Array,e):null}let s=r.Ky(this.buffer.subarray(this.pos,this.end-4),e.length?0:3);if(s.offset>-1)return e.push(this.buffer.slice(this.pos,this.pos+s.offset)),this.pos+=s.offset,(0,h.A)(Uint8Array,e);if(this.ended)return e.push(this.buffer.slice(this.pos,this.end)),this.pos=this.end=0,(0,h.A)(Uint8Array,e);e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}}reset(){this.pos=0,this.end=0,this.ended=!1}}}}]);
@@ -0,0 +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,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)}}]);
@@ -0,0 +1 @@
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}}}}]);
@@ -0,0 +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),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})}}]);
@@ -0,0 +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,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}}}}]);
@@ -0,0 +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",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}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[82],{26082:(e,t,i)=>{i.r(t),i.d(t,{default:()=>R});var a=i(9655),r=i(16566),s=i(36311),n=i(20163),o=i(20086),c=i(89984),h=i(41321),d=i(1140),f=i(37142),l=i(46898),m=i(31531),u=i(64310),p=i(89378),g=i(59258),w=i(31126),b=i(69663),B=i(81429),x=i(29887);const I="src/avformat/formats/IFlacFormat.ts",k=1024;class R extends c.A{constructor(){super(),(0,a.A)(this,"type",17),(0,a.A)(this,"context",void 0)}init(e){e.ioReader.setEndian(!0),this.context={streamInfo:{minimumBlockSize:0,maximumBlockSize:0,minimumFrameSize:0,maximumFrameSize:0,sampleRate:0,channels:0,bitPerSample:0,samples:BigInt(0),md5:""},frameInfo:{sampleRate:0,channels:0,bps:0,blocksize:0,chMode:0,frameOrSampleNum:BigInt(0),isVarSize:0},seekPoints:[],cueSheet:{catalogNumber:"",leadInSamples:BigInt(0),compactDisc:!1,tracks:[]},picture:{type:0,mimeType:"",description:"",width:0,height:0,colorDepth:0,indexedColor:0,data:null},cacheBuffer:null,cachePos:BigInt(0),bitReader:new m.A(16),fileSize:BigInt(0),firstFramePos:BigInt(0),isVarSize:-1}}async readHeader(e){if("fLaC"!==await e.ioReader.readString(4))return n.z3("the file format is not flac",I,120),o.LR;this.context.fileSize=await e.ioReader.fileSize();const t=e.createStream();for(t.codecpar.codecType=1,t.codecpar.codecId=86028;;){const i=await e.ioReader.readUint8(),a=await e.ioReader.readUint24(),n=-129&i;if(0===n){t.codecpar.extradata=(0,d.sY)(a),t.codecpar.extradataSize=a,(0,h.lW)(t.codecpar.extradata,a,await e.ioReader.peekBuffer(a)),this.context.streamInfo.minimumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.maximumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.minimumFrameSize=await e.ioReader.readUint24(),this.context.streamInfo.maximumFrameSize=await e.ioReader.readUint24();const i=await e.ioReader.readUint24();t.codecpar.sampleRate=i>>4,t.codecpar.chLayout.nbChannels=1+((15&i)>>>1),this.context.streamInfo.sampleRate=t.codecpar.sampleRate,this.context.streamInfo.channels=t.codecpar.chLayout.nbChannels;const r=await e.ioReader.readUint8();t.codecpar.bitsPerRawSample=1+((1&i)<<4|(240&r)>>>4),this.context.streamInfo.bitPerSample=t.codecpar.bitsPerRawSample;const s=await e.ioReader.readUint32(),n=BigInt(Math.floor(15&r))<<BigInt(32)|BigInt(Math.floor(s));this.context.streamInfo.samples=n,t.timeBase.den=t.codecpar.sampleRate,t.timeBase.num=1,t.duration=n,t.startTime=BigInt(0),this.context.streamInfo.md5=await e.ioReader.readString(16)}else if(2===n){const t=e.createStream();t.codecpar.codecType=2,t.codecpar.codecTag=await e.ioReader.readUint32(),t.codecpar.extradata=(0,d.sY)(a-4),t.codecpar.extradataSize=a-4,await e.ioReader.readBuffer(a-4,(0,h.JW)(t.codecpar.extradata,t.codecpar.extradataSize))}else if(3===n)for(let t=0;t<a/18;t++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint64(),a=await e.ioReader.readUint16();this.context.seekPoints.push({pts:t,pos:i,samples:a})}else if(4===n){e.ioReader.setEndian(!1);const t=await e.ioReader.readUint32(),i=await e.ioReader.readString(t),a=await e.ioReader.readUint32(),r=[];for(let t=0;t<a;t++){const t=await e.ioReader.readUint32();r.push(await e.ioReader.readString(t))}e.metadata.vendor=i,(0,B.ol)(r,e.metadata),e.ioReader.setEndian(!0)}else if(5===n){this.context.cueSheet.catalogNumber=await e.ioReader.readString(128),this.context.cueSheet.leadInSamples=await e.ioReader.readUint64(),this.context.cueSheet.compactDisc=!!(await e.ioReader.readUint8()>>>7),await e.ioReader.skip(258);const t=await e.ioReader.readUint8();for(let i=0;i<t;i++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint8(),a=await e.ioReader.readBuffer(12),r=await e.ioReader.readUint8();await e.ioReader.skip(13);const s=await e.ioReader.readUint8(),n=[];for(let t=0;t<s;t++)n.push({offset:await e.ioReader.readUint64(),point:await e.ioReader.readUint8()}),await e.ioReader.skip(3);this.context.cueSheet.tracks.push({offset:t,number:i,isrc:a,type:r>>>7,preEmphasisFlag:r>>>6&1,points:n})}}else if(6===n){this.context.picture.type=await e.ioReader.readUint32();let t=await e.ioReader.readUint32();this.context.picture.mimeType=await e.ioReader.readString(t),t=await e.ioReader.readUint32(),this.context.picture.description=await e.ioReader.readString(t),this.context.picture.width=await e.ioReader.readUint32(),this.context.picture.height=await e.ioReader.readUint32(),this.context.picture.colorDepth=await e.ioReader.readUint32(),this.context.picture.indexedColor=await e.ioReader.readUint32(),t=await e.ioReader.readUint32(),this.context.picture.data=await e.ioReader.readBuffer(t);let i=x.In[this.context.picture.mimeType]||0;if(i){const t=e.createStream();t.codecpar.codecId=i,this.context.picture.data.length>=8&&w.FB(this.context.picture.data.subarray(0,8),new Uint8Array([137,80,78,71,13,10,26,10]))&&(i=61),t.codecpar.width=this.context.picture.width,t.codecpar.height=this.context.picture.height,t.codecpar.codecType=0,t.disposition|=1024,t.attachedPic=(0,f._5)(),s.M[15](t.attachedPic+32,t.index);const a=(0,d.sY)(this.context.picture.data.length);(0,h.lW)(a,this.context.picture.data.length,this.context.picture.data),(0,f.NX)(t.attachedPic,a,this.context.picture.data.length),s.M[15](t.attachedPic+36,1|r.f[15](t.attachedPic+36)),t.metadata.comment=x.fz[this.context.picture.type],this.context.picture.description&&(t.metadata.title=this.context.picture.description)}}else await e.ioReader.skip(a);if(128&i)break}return this.context.firstFramePos=e.ioReader.getPos(),t.privData=this.context,0}async getNextFrame(e){const t=[];for(;;){if(e.ioReader.getPos()===this.context.fileSize){this.context.cacheBuffer&&(t.push(this.context.cacheBuffer),this.context.cacheBuffer=null);break}this.context.cacheBuffer?this.context.cacheBuffer.length<17&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(k,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])):(this.context.cachePos=e.ioReader.getPos(),this.context.cacheBuffer=await e.ioReader.readBuffer(Math.min(k,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos())))));let i=t.length?0:2;const a=this.context.isVarSize<0?[248,249]:this.context.isVarSize?[249]:[248],r=this.context.cacheBuffer.length-2;for(;i<r;i++)if(255===this.context.cacheBuffer[i]&&w.zy(a,this.context.cacheBuffer[i+1])){i&&(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i),this.context.cachePos+=BigInt(Math.floor(i)));break}if(i===r){e.ioReader.getPos()===this.context.fileSize?(t.push(this.context.cacheBuffer),this.context.cachePos+=BigInt(Math.floor(this.context.cacheBuffer.length)),this.context.cacheBuffer=null):(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cachePos+=BigInt(Math.floor(i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i));continue}this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(k,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16));const s={};if(!((0,l.x)(this.context.bitReader,s,!0)<0||s.frameOrSampleNum-this.context.frameInfo.frameOrSampleNum!==BigInt(0|this.context.frameInfo.blocksize)&&s.frameOrSampleNum!==this.context.frameInfo.frameOrSampleNum+BigInt(1)))break;t.push(this.context.cacheBuffer.subarray(0,2)),this.context.cachePos+=BigInt(2),this.context.cacheBuffer=this.context.cacheBuffer.subarray(2)}return 1===t.length?t[0]:(0,u.A)(Uint8Array,t)}async readAVPacket(e,t){const i=e.streams.find((e=>e.codecpar.codecType=1));try{let a=e.ioReader.getPos();if(a===this.context.fileSize)return-1048576;if(this.context.bitReader.reset(),this.context.cacheBuffer?(a=this.context.cachePos,this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(k,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16))):this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),(0,l.x)(this.context.bitReader,this.context.frameInfo)<0)return o.LR;const n=await this.getNextFrame(e),c=(0,d.sY)(n.length);return(0,h.lW)(c,n.length,n),(0,f.NX)(t,c,n.length),s.M[17](t+56,a),s.M[15](t+32,i.index),s.M[15](t+76,i.timeBase.den),s.M[15](t+72,i.timeBase.num),s.M[15](t+36,1|r.f[15](t+36)),s.M[17](t+48,BigInt(0|this.context.frameInfo.blocksize)),s.M[17](t+16,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),s.M[17](t+8,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),this.context.frameInfo.isVarSize||e.ioReader.getPos()!==this.context.fileSize||(s.M[17](t+16,this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.streamInfo.minimumBlockSize)),s.M[17](t+8,this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.streamInfo.minimumBlockSize))),this.context.isVarSize<0&&(this.context.isVarSize=this.context.frameInfo.isVarSize),0}catch(t){return-1048576!==e.ioReader.error&&-1048572!==e.ioReader.error?(n.z3(`read packet error, ${t}`,I,452),o.LR):e.ioReader.error}}async syncFrame(e){let t=p.Dh;for(;;)try{const i=await e.ioReader.peekUint16();if((65529===i||65528===i)&&(t=e.ioReader.getPos(),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),!(0,l.x)(this.context.bitReader,{},!0)))break;await e.ioReader.skip(1)}catch(e){break}t!==p.Dh&&await e.ioReader.seek(t)}async seek(e,t,i,a){const r=e.ioReader.getPos(),s=t.privData;if(2&a){const t=await e.ioReader.fileSize();return t<=BigInt(0)?BigInt(o.E$):(i<BigInt(0)?i=BigInt(0):i>t&&(i=t),await e.ioReader.seek(i),4&a||await this.syncFrame(e),r)}if(t&&t.sampleIndexes.length){let a=w.El(t.sampleIndexes,(e=>e.pts>i?-1:1));if(a>0&&(0,b.k)(i-t.sampleIndexes[a-1].pts,t.timeBase,p.i0)<BigInt(5e3))return n.Yz(`seek in sampleIndexes, found index: ${a}, pts: ${t.sampleIndexes[a-1].pts}, pos: ${t.sampleIndexes[a-1].pos}`,I,519),await e.ioReader.seek(t.sampleIndexes[a-1].pos),s.cacheBuffer=null,r}if(s.seekPoints.length){let t=0;for(let e=0;e<s.seekPoints.length;e++){if(s.seekPoints[e].pts===i){t=e;break}if(s.seekPoints[e].pts>i){t=Math.max(e-1,0);break}}const a=s.seekPoints[t];return n.Yz(`seek in seekPoints, found index: ${t}, pts: ${a.pts}, pos: ${a.pos+s.firstFramePos}`,I,539),await e.ioReader.seek(a.pos+s.firstFramePos),s.cacheBuffer=null,r}n.Yz("not found any keyframe index, try to seek in bytes",I,545);const c=await(0,g.A)(e,t,i,s.firstFramePos,this.readAVPacket.bind(this),this.syncFrame.bind(this));return c>0&&(s.cacheBuffer=null),c}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){}}},46898:(e,t,i)=>{i.d(t,{x:()=>c});var a=i(20086),r=i(20163),s=i(32982),n=i(95135);const o="src/avformat/formats/flac/iflac.ts";function c(e,t,i=!1){const c=e.getPointer();if(32764!=(32767&e.readU(15)))return!i&&r.z3("invalid sync code",o,57),a.LR;t.isVarSize=e.readU1();const h=e.readU(4),d=e.readU(4);if(t.chMode=e.readU(4),t.chMode<s.jA)t.channels=t.chMode+1,t.chMode=0;else{if(!(t.chMode<s.jA+3))return!i&&r.z3(`invalid channel mode: ${t.chMode}`,o,76),a.LR;t.channels=2,t.chMode-=s.jA-1}const f=e.readU(3);if(3===f)return!i&&r.z3(`invalid sample size code: ${f}`,o,82),a.LR;if(t.bps=s.oe[f],e.readU1())return!i&&r.z3("broken stream, invalid padding",o,88),a.LR;if(t.frameOrSampleNum=function(e){let t=BigInt(Math.floor(e.readU(8))),i=(t&BigInt(128))>>BigInt(1);if((t&BigInt(192))===BigInt(128)||t>=BigInt(254))return-BigInt(1);for(;t&i;){const a=BigInt(Math.floor(e.readU(8)))-BigInt(128);if(a>>BigInt(6))return-BigInt(1);t=(t<<BigInt(6))+a,i<<=BigInt(5)}return t&=(i<<BigInt(1))-BigInt(1),t}(e),t.frameOrSampleNum<0)return!i&&r.z3("sample/frame number invalid",o,95),a.LR;if(0===h)return!i&&r.z3("reserved blocksize code: 0",o,100),a.LR;if(t.blocksize=6===h?e.readU(8)+1:7===h?e.readU(16)+1:s.Xr[h],d<12)t.sampleRate=s.DK[d];else if(12===d)t.sampleRate=1e3*e.readU(8);else if(13===d)t.sampleRate=e.readU(16);else{if(14!==d)return!i&&r.z3(`illegal sample rate code ${d}`,o,126),a.LR;t.sampleRate=10*e.readU(16)}return(0,n.A)(e.getBuffer().subarray(c,e.getPointer()))!==e.readU(8)?(!i&&r.z3("header crc mismatch",o,133),a.LR):0}},29887:(e,t,i)=>{i.d(t,{In:()=>m,fz:()=>u,hm:()=>B,qg:()=>b});var a=i(16566),r=i(36311),s=i(20163),n=i(19372),o=(i(81895),i(48162)),c=i(37142),h=i(1140),d=i(41321),f=i(31126);i(99868);const l="src/avformat/formats/mp3/id3v2.ts",m={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 p(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 c=e.getPos()+BigInt(0|t);async function h(){await e.skip(Number(BigInt.asIntN(32,c-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 h();if(await e.skip(a),(t-=a+4)<0)return s.z3("extended header too long",l,155),await h()}for(;t>o;){let c,h;if(r){if(c=await e.readString(4),h=await e.readUint32(),!h){s.z3("invalid frame size",l,168);break}if(4===i.version&&h>127)if(h<t){await e.flush();const t=e.getPos();if(!(1&e.flags||6+h<e.remainingLength()))break;if(await w(e,t+BigInt(2)+BigInt(g(h))))h=g(h);else if(!await w(e,t+BigInt(2)+BigInt(h)))break;await e.seek(t)}else h=g(h);await e.readUint16()}else c=await e.readString(3),h=await e.readUint24();if("APIC"===c)a.apic||(a.apic=[]),a.apic.push(await e.readBuffer(h));else if("USLT"===c){const t=await e.readUint8(),i=await e.readString(3),r=await e.readBuffer(h-4);a.lyrics=`${i} ${p(t,r)}`}else if("COMM"===c||"COM"===c){const t=await e.readUint8(),i=await e.readString(3),r=await e.readBuffer(h-4);a.comment=`${i} ${p(t,r)}`}else if("PRIV"===c){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(h-Number(e.getPos()-t)),a[r]=s}else{let t;switch(t="T"===c[0]?p(await e.readUint8(),await e.readBuffer(h-1)):await e.readBuffer(h),c){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[c]=t}}t-=h+o}4==i.version&&16&i.flags&&(c+=BigInt(10)),await e.skip(Number(BigInt.asIntN(32,c-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),!m[l])return;const w=i.readUint8();let b;const B=g()-Number(i.getPos());B&&(b=p(n,i.readBuffer(B))),i.skip(1);const x=e.createStream();x.codecpar.codecId=m[l],x.codecpar.codecType=0,x.disposition|=1024,x.attachedPic=(0,c._5)(),r.M[15](x.attachedPic+32,x.index);const I=i.remainingSize(),k=(0,h.sY)(I),R=i.readBuffer(I);(0,d.lW)(k,I,R),R.length>=8&&f.FB(R.subarray(0,8),new Uint8Array([137,80,78,71,13,10,26,10]))&&(x.codecpar.codecId=61),(0,c.NX)(x.attachedPic,k,I),r.M[15](x.attachedPic+36,1|a.f[15](x.attachedPic+36)),x.metadata.comment=u[w],b&&(x.metadata.title=b)}))}},29e3:(e,t,i)=>{i.d(t,{B:()=>o,h:()=>c});var a=i(9655),r=i(89378),s=i(19372);class n{constructor(){(0,a.A)(this,"list",void 0),this.list=[]}read(e,t){for(let i=0;i<t;i++){const t=e.readUint32();this.list.push(e.readString(t))}}write(e){for(let t=0;t<this.list.length;t++){const i=s.encode(this.list[t]);e.writeUint32(i.length),e.writeBuffer(i)}}addComment(e){this.list.push(e)}}class o{constructor(){(0,a.A)(this,"capturePattern",void 0),(0,a.A)(this,"streamStructureVersion",void 0),(0,a.A)(this,"headerTypeFlag",void 0),(0,a.A)(this,"granulePosition",void 0),(0,a.A)(this,"serialNumber",void 0),(0,a.A)(this,"pageSequenceNumber",void 0),(0,a.A)(this,"crcCheckSum",void 0),(0,a.A)(this,"numberPageSegments",void 0),(0,a.A)(this,"segmentTable",void 0),(0,a.A)(this,"payload",void 0),(0,a.A)(this,"pos",void 0),this.reset()}reset(){this.capturePattern="OggS",this.streamStructureVersion=0,this.headerTypeFlag=0,this.granulePosition=r.Dh,this.serialNumber=0,this.pageSequenceNumber=0,this.crcCheckSum=0,this.numberPageSegments=0,this.segmentTable=[],this.pos=BigInt(0)}async read(e){this.pos=e.getPos(),await this.readPageHeader(e);const t=this.segmentTable.reduce(((e,t)=>e+t),0);t&&(this.payload=await e.readBuffer(t))}async readPageHeader(e){if(this.capturePattern=await e.readString(4),this.streamStructureVersion=await e.readUint8(),this.headerTypeFlag=await e.readUint8(),this.granulePosition=await e.readUint64(),this.serialNumber=await e.readUint32(),this.pageSequenceNumber=await e.readUint32(),this.crcCheckSum=await e.readUint32(),this.numberPageSegments=await e.readUint8(),this.numberPageSegments)for(let t=0;t<this.numberPageSegments;t++){const t=await e.readUint8();this.segmentTable.push(t)}}write(e){if(this.pos=e.getPos(),e.writeString(this.capturePattern),e.writeUint8(this.streamStructureVersion),e.writeUint8(this.headerTypeFlag),e.writeUint64(this.granulePosition),e.writeUint32(this.serialNumber),e.writeUint32(this.pageSequenceNumber),e.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const t=this.payload.length%255;e.writeUint8(this.numberPageSegments);for(let t=0;t<this.numberPageSegments-1;t++)e.writeUint8(255);e.writeUint8(t),e.writeBuffer(this.payload)}else e.writeUint8(0)}}class c{constructor(){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"vendorStringLength",void 0),(0,a.A)(this,"vendorString",void 0),(0,a.A)(this,"userCommentListLength",void 0),(0,a.A)(this,"comments",void 0),this.vendorString="libmedia-v0.12.0",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new n}read(e){this.vendorStringLength=e.readUint32(),this.vendorString=e.readString(this.vendorStringLength),this.userCommentListLength=e.readUint32(),this.userCommentListLength&&this.comments.read(e,this.userCommentListLength)}write(e){const t=s.encode(this.vendorString);e.writeUint32(t.length),e.writeBuffer(t),e.writeUint32(this.comments.list.length),this.comments.write(e)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},81429:(e,t,i)=>{i.d(t,{GM:()=>c,mS:()=>o,ol:()=>n});var a=i(9655),r=i(29e3);i(99868),i(21472);const s={album:"album",artist:"artist",description:"description",encoder:"encoder",title:"title",tracknumber:"track",date:"date",genre:"genre",comment:"comment",albumartist:"albumArtist",composer:"composer",performer:"performer",discnumber:"disc",organization:"vendor",copyright:"copyright",license:"license",isrc:"isrc",lyrics:"lyrics",language:"language",label:"vendor",script:"lyrics",encoded_by:"vendor"};function n(e,t){e&&e.forEach((e=>{const i=e.split("=");if(2===i.length){const e=i[0].trim().toLowerCase(),a=i[1].trim();s[e]?t[s[e]]=a:t[e.toLowerCase()]=a}}))}class o{constructor(e="vorbis"){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"version",void 0),(0,a.A)(this,"channels",void 0),(0,a.A)(this,"sampleRate",void 0),(0,a.A)(this,"bitrateMaximum",void 0),(0,a.A)(this,"bitrateNominal",void 0),(0,a.A)(this,"bitrateMinimum",void 0),(0,a.A)(this,"blocksize0",void 0),(0,a.A)(this,"blocksize1",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.version=0,this.channels=1,this.sampleRate=48e3,this.bitrateMaximum=0,this.bitrateNominal=0,this.bitrateMinimum=0,this.blocksize0=2048,this.blocksize1=256}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),this.version=e.readUint32(),this.channels=e.readUint8(),this.sampleRate=e.readInt32(),this.bitrateMaximum=e.readInt32(),this.bitrateNominal=e.readInt32(),this.bitrateMinimum=e.readInt32();const t=255&e.readUint8();this.blocksize0=Math.pow(2,t>>>4),this.blocksize1=Math.pow(2,15&t),this.framingFlag=e.readUint8()}write(e){e.writeUint8(1),e.writeString(this.signature),e.writeUint32(this.version),e.writeUint8(this.channels),e.writeInt32(this.sampleRate),e.writeInt32(this.bitrateMaximum),e.writeInt32(this.bitrateNominal),e.writeInt32(this.bitrateMinimum),e.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),e.writeUint8(1)}setCodec(e){this.sampleRate=e.sampleRate,this.channels=e.chLayout.nbChannels}}class c extends r.h{constructor(e="vorbis"){super(),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.packetType=1,this.framingFlag=1}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),super.read(e),"vorbis"===this.signature&&(this.framingFlag=e.readUint8())}write(e){e.writeUint8(this.packetType),e.writeString(this.signature),super.write(e),"vorbis"===this.signature&&e.writeUint8(this.framingFlag)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},45372:(e,t,i)=>{i.d(t,{d:()=>n});var a=i(31126),r=i(69663),s=i(89378);function n(e,t,i){let n=BigInt(0);return a.__(e,(e=>{n+=e.codecpar.bitrate*(0,r.k)(t,i,s.i0)/BigInt(8e3)})),n}},59258:(e,t,i)=>{i.d(t,{A:()=>f});var a=i(16566),r=(i(51308),i(89378)),s=i(69663),n=i(45372),o=i(37142),c=i(20086),h=i(20163);const d="src/avformat/function/seekInBytes.ts";async function f(e,t,i,f,l,m){const u=e.ioReader.getPos(),p=await e.ioReader.fileSize();let g=r.Dh,w=i;t.startTime!==r.Dh?w-=t.startTime:w-=t.firstDTS;const b=(0,s.k)(i,t.timeBase,r.i0);if(b<BigInt(1e4))return h.Yz(`seek pts is earlier then 10s, seek to first packet pos(${f}) directly`,d,64),await e.ioReader.seek(f),u;let B=(0,n.d)(e.streams,w,t.timeBase);const x=p-(0,n.d)(e.streams,BigInt(1e4),r.i0),I=(0,n.d)(e.streams,BigInt(1e4),r.i0);if(B>x&&(B=x),B<f)return await e.ioReader.seek(f),u;const k=(0,o._5)();let R=p,S=BigInt(0);e:for(;R-S<I&&(B=S),await e.ioReader.seek(B),await m(e),!(8&e.ioReader.flags);){let i=await l(e,k),n=a.f[17](k+56);if(!(i>=0)){g=r.Dh;break}{const c=(0,s.Mr)(a.f[17](k+8),k+72,r.i0);let f=c-b;if(h.Yz(`try to seek to pos: ${B}, got packet pts: ${a.f[17](k+8)}(${c}ms), diff: ${f}ms`,d,101),f<=BigInt(0)&&-f<BigInt(1e4)||R-S<I){const c=[n];for(;f<=0;){if(a.f[15](k+32)===t.index&&1&a.f[15](k+36)&&c.push(n),(0,o.Up)(k),i=await l(e,k),i<0){if(-1048576===i)break;if(-1048575===i)continue;g=r.Dh;break e}n=a.f[17](k+56),f=(0,s.Mr)(a.f[17](k+8),k+72,r.i0)-b}g=c.pop();break}f>BigInt(0)?(R=B,B=S+R>>BigInt(1)):(S=B,B=S+R>>BigInt(1))}if(8&e.ioReader.flags)break}return(0,o.Qe)(k),g!==r.Dh?(h.Yz(`finally seek to pos ${g}`,d,156),await e.ioReader.seek(g),await m(e),u):(await e.ioReader.seek(u),8&e.ioReader.flags?BigInt(c.LT):BigInt(c.E$))}},32982:(e,t,i)=>{i.d(t,{DK:()=>o,XC:()=>h,Xr:()=>c,jA:()=>s,ob:()=>r,oe:()=>n});var a=i(48162);const r=34,s=8,n=[0,8,12,0,16,20,24,32],o=[0,88200,176400,192e3,8e3,16e3,22050,24e3,32e3,44100,48e3,96e3,0,0,0,0],c=[0,192,576,1152,2304,4608,0,0,256,512,1024,2048,4096,8192,16384,32768];function h(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length===r){const{bitsPerRawSample:i,sampleRate:r,channels:s}=function(e){const t=new a.A(e);t.skip(10);const i=t.readUint24();return{sampleRate:i>>4,channels:1+((15&i)>>>1),bitsPerRawSample:1+((1&i)<<4|(240&t.readUint8())>>>4)}}(t);e.codecpar.bitsPerRawSample=i,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=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}}},95135:(e,t,i)=>{function a(e,t=0){for(let i=0;i<e.length;i++){t^=e[i];for(let e=0;e<8;e++)128&t?t=t<<1^7:t<<=1}return 255&t}i.d(t,{A:()=>a})}}]);