@libmedia/avplayer 0.11.3 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/19.avplayer.js +1 -1
- package/dist/esm/195.avplayer.js +1 -0
- package/dist/esm/367.avplayer.js +1 -1
- package/dist/esm/400.avplayer.js +1 -1
- package/dist/esm/421.avplayer.js +1 -1
- package/dist/esm/430.avplayer.js +1 -1
- package/dist/esm/464.avplayer.js +1 -1
- package/dist/esm/566.avplayer.js +1 -1
- package/dist/esm/60.avplayer.js +1 -1
- package/dist/esm/690.avplayer.js +1 -1
- package/dist/esm/799.avplayer.js +1 -1
- package/dist/esm/801.avplayer.js +1 -1
- package/dist/esm/81.avplayer.js +1 -1
- package/dist/esm/814.avplayer.js +1 -1
- package/dist/esm/82.avplayer.js +1 -1
- package/dist/esm/852.avplayer.js +1 -1
- package/dist/esm/902.avplayer.js +1 -1
- package/dist/esm/913.avplayer.js +1 -1
- package/dist/esm/945.avplayer.js +1 -1
- package/dist/esm/949.avplayer.js +1 -1
- package/dist/esm/953.avplayer.js +1 -1
- package/dist/esm/avplayer.js +1 -1
- package/dist/types/AVPlayer.d.ts +39 -21
- package/dist/types/Controller.d.ts +3 -2
- package/dist/types/JitterBufferController.d.ts +2 -1
- package/dist/types/StatsController.d.ts +1 -1
- package/dist/types/mse/MSEPipeline.d.ts +10 -9
- package/dist/types/struct.d.ts +5 -5
- package/dist/types/subtitle/AssRender.d.ts +1 -1
- package/dist/types/subtitle/SubtitleRender.d.ts +4 -4
- package/dist/types/type.d.ts +2 -2
- package/dist/umd/19.avplayer.js +1 -1
- package/dist/umd/195.avplayer.js +1 -0
- package/dist/umd/367.avplayer.js +1 -1
- package/dist/umd/400.avplayer.js +1 -1
- package/dist/umd/421.avplayer.js +1 -1
- package/dist/umd/430.avplayer.js +1 -1
- package/dist/umd/464.avplayer.js +1 -1
- package/dist/umd/566.avplayer.js +1 -1
- package/dist/umd/60.avplayer.js +1 -1
- package/dist/umd/690.avplayer.js +1 -1
- package/dist/umd/799.avplayer.js +1 -1
- package/dist/umd/801.avplayer.js +1 -1
- package/dist/umd/81.avplayer.js +1 -1
- package/dist/umd/814.avplayer.js +1 -1
- package/dist/umd/82.avplayer.js +1 -1
- package/dist/umd/852.avplayer.js +1 -1
- package/dist/umd/902.avplayer.js +1 -1
- package/dist/umd/913.avplayer.js +1 -1
- package/dist/umd/945.avplayer.js +1 -1
- package/dist/umd/949.avplayer.js +1 -1
- package/dist/umd/953.avplayer.js +1 -1
- package/dist/umd/avplayer.js +1 -1
- package/package.json +12 -12
- package/dist/esm/733.avplayer.js +0 -1
- package/dist/umd/733.avplayer.js +0 -1
package/dist/types/AVPlayer.d.ts
CHANGED
|
@@ -2,31 +2,34 @@ import { AVCodecID, AVMediaType } from "@libmedia/avutil/codec";
|
|
|
2
2
|
import IOPipeline from "@libmedia/avpipeline/IOPipeline";
|
|
3
3
|
import DemuxPipeline from "@libmedia/avpipeline/DemuxPipeline";
|
|
4
4
|
import AudioDecodePipeline from "@libmedia/avpipeline/AudioDecodePipeline";
|
|
5
|
-
import { Thread } from "@libmedia/cheap/thread/thread";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import type { Thread } from "@libmedia/cheap/thread/thread";
|
|
6
|
+
import type { EmitterOptions } from "@libmedia/common/event/Emitter";
|
|
7
|
+
import Emitter from "@libmedia/common/event/Emitter";
|
|
8
|
+
import type { WebAssemblyResource } from "@libmedia/cheap/webassembly/compiler";
|
|
9
|
+
import compile from "@libmedia/cheap/webassembly/compiler";
|
|
8
10
|
import AudioRenderPipeline from "@libmedia/avpipeline/AudioRenderPipeline";
|
|
9
11
|
import VideoRenderPipeline from "@libmedia/avpipeline/VideoRenderPipeline";
|
|
10
12
|
import { RenderMode } from "@libmedia/avrender/image/ImageRender";
|
|
11
|
-
import { ControllerObserver } from "./Controller";
|
|
13
|
+
import type { ControllerObserver } from "./Controller";
|
|
12
14
|
import * as eventType from "./eventType";
|
|
13
15
|
import Stats from "@libmedia/avpipeline/struct/stats";
|
|
14
16
|
import MSEPipeline from "./mse/MSEPipeline";
|
|
15
|
-
import { AVStreamInterface } from "@libmedia/avutil/AVStream";
|
|
16
|
-
import { AVFormatContextInterface } from "@libmedia/avformat/AVFormatContext";
|
|
17
|
-
import { Data, Fn } from "@libmedia/common/types/type";
|
|
18
|
-
import { playerEventChanged, playerEventChanging, playerEventError, playerEventNoParam, playerEventProgress, playerEventSubtitleDelayChange, playerEventTime, playerEventVolumeChange } from "./type";
|
|
17
|
+
import type { AVStreamInterface } from "@libmedia/avutil/AVStream";
|
|
18
|
+
import type { AVFormatContextInterface } from "@libmedia/avformat/AVFormatContext";
|
|
19
|
+
import type { Data, Fn } from "@libmedia/common/types/type";
|
|
20
|
+
import type { playerEventChanged, playerEventChanging, playerEventError, playerEventNoParam, playerEventProgress, playerEventSubtitleDelayChange, playerEventTime, playerEventVolumeChange } from "./type";
|
|
19
21
|
import FetchIOLoader from "@libmedia/avnetwork/ioLoader/FetchIOLoader";
|
|
20
22
|
import FileIOLoader from "@libmedia/avnetwork/ioLoader/FileIOLoader";
|
|
21
23
|
import CustomIOLoader from "@libmedia/avnetwork/ioLoader/CustomIOLoader";
|
|
22
24
|
import IODemuxPipelineProxy from "./worker/IODemuxPipelineProxy";
|
|
23
25
|
import AudioPipelineProxy from "./worker/AudioPipelineProxy";
|
|
24
26
|
import MSEPipelineProxy from "./worker/MSEPipelineProxy";
|
|
25
|
-
import
|
|
27
|
+
import type { WebSocketOptions } from "@libmedia/avnetwork/ioLoader/WebSocketIOLoader";
|
|
28
|
+
import WebSocketIOLoader from "@libmedia/avnetwork/ioLoader/WebSocketIOLoader";
|
|
26
29
|
import SocketIOLoader from "@libmedia/avnetwork/ioLoader/SocketIOLoader";
|
|
27
30
|
import WebTransportIOLoader from "@libmedia/avnetwork/ioLoader/WebTransportIOLoader";
|
|
28
31
|
import { DRMType } from "./drm/drm";
|
|
29
|
-
import { IOLoaderOptions } from "@libmedia/avnetwork/ioLoader/IOLoader";
|
|
32
|
+
import type { IOLoaderOptions } from "@libmedia/avnetwork/ioLoader/IOLoader";
|
|
30
33
|
export interface ExternalSubtitle {
|
|
31
34
|
/**
|
|
32
35
|
* 字幕源,支持 url 和 文件
|
|
@@ -393,6 +396,8 @@ export default class AVPlayer extends Emitter implements ControllerObserver {
|
|
|
393
396
|
private lastSelectedInnerSubtitleStreamIndex;
|
|
394
397
|
private subtitleRender;
|
|
395
398
|
private externalSubtitleTasks;
|
|
399
|
+
private changingStreamPending;
|
|
400
|
+
private handleChangingStreamPendingTimer;
|
|
396
401
|
constructor(options: AVPlayerOptions);
|
|
397
402
|
/**
|
|
398
403
|
* 当前播放时间戳(毫秒)
|
|
@@ -402,6 +407,10 @@ export default class AVPlayer extends Emitter implements ControllerObserver {
|
|
|
402
407
|
* @hidden
|
|
403
408
|
*/
|
|
404
409
|
private isCodecIdSupported;
|
|
410
|
+
/**
|
|
411
|
+
* @hidden
|
|
412
|
+
*/
|
|
413
|
+
private isAttachmentPicture;
|
|
405
414
|
/**
|
|
406
415
|
* @hidden
|
|
407
416
|
*/
|
|
@@ -410,6 +419,7 @@ export default class AVPlayer extends Emitter implements ControllerObserver {
|
|
|
410
419
|
private createCanvas;
|
|
411
420
|
private createVideo;
|
|
412
421
|
private createAudio;
|
|
422
|
+
private handleChangingStreamPending;
|
|
413
423
|
private handleTimeupdate;
|
|
414
424
|
private replayTo;
|
|
415
425
|
private handleEnded;
|
|
@@ -425,7 +435,12 @@ export default class AVPlayer extends Emitter implements ControllerObserver {
|
|
|
425
435
|
* @returns
|
|
426
436
|
*/
|
|
427
437
|
isDash(): boolean;
|
|
428
|
-
|
|
438
|
+
/**
|
|
439
|
+
* 获取最小开始时间
|
|
440
|
+
*
|
|
441
|
+
* @returns
|
|
442
|
+
*/
|
|
443
|
+
getMinStartPTS(): int64 | 0n;
|
|
429
444
|
private getResource;
|
|
430
445
|
private createSubtitleRender;
|
|
431
446
|
/**
|
|
@@ -474,8 +489,8 @@ export default class AVPlayer extends Emitter implements ControllerObserver {
|
|
|
474
489
|
*/
|
|
475
490
|
mediaType: string;
|
|
476
491
|
codecparProxy: import("@libmedia/avutil/struct/avcodecparameters").default;
|
|
477
|
-
index:
|
|
478
|
-
id:
|
|
492
|
+
index: int32;
|
|
493
|
+
id: int32;
|
|
479
494
|
codecpar: pointer<import("@libmedia/avutil/struct/avcodecparameters").default>;
|
|
480
495
|
nbFrames: int64;
|
|
481
496
|
metadata: Data;
|
|
@@ -483,25 +498,26 @@ export default class AVPlayer extends Emitter implements ControllerObserver {
|
|
|
483
498
|
startTime: int64;
|
|
484
499
|
disposition: int32;
|
|
485
500
|
timeBase: import("@libmedia/avutil/struct/rational").Rational;
|
|
501
|
+
attachedPic: pointer<import("@libmedia/avutil/struct/avpacket").default>;
|
|
486
502
|
}[];
|
|
487
503
|
/**
|
|
488
504
|
* 获取当前选择播放的视频流 id
|
|
489
505
|
*
|
|
490
506
|
* @returns
|
|
491
507
|
*/
|
|
492
|
-
getSelectedVideoStreamId():
|
|
508
|
+
getSelectedVideoStreamId(): -1 | int32;
|
|
493
509
|
/**
|
|
494
510
|
* 获取当前选择播放的音频流 id
|
|
495
511
|
*
|
|
496
512
|
* @returns
|
|
497
513
|
*/
|
|
498
|
-
getSelectedAudioStreamId():
|
|
514
|
+
getSelectedAudioStreamId(): -1 | int32;
|
|
499
515
|
/**
|
|
500
516
|
* 获取当前选择播放的字幕流 id
|
|
501
517
|
*
|
|
502
518
|
* @returns
|
|
503
519
|
*/
|
|
504
|
-
getSelectedSubtitleStreamId():
|
|
520
|
+
getSelectedSubtitleStreamId(): -1 | int32;
|
|
505
521
|
/**
|
|
506
522
|
* 获取章节信息
|
|
507
523
|
*
|
|
@@ -705,21 +721,23 @@ export default class AVPlayer extends Emitter implements ControllerObserver {
|
|
|
705
721
|
/**
|
|
706
722
|
* 设置播放视频轨道
|
|
707
723
|
*
|
|
708
|
-
* @param id 流 id,dash 传 getVideoList 列表中的 index
|
|
724
|
+
* @param id 流 id,dash 和 hls 传 getVideoList 列表中的 index
|
|
725
|
+
* @param smooth 平滑切换(hls 和 dash 使用,切换下一个加载的切片)
|
|
709
726
|
* @returns
|
|
710
727
|
*/
|
|
711
|
-
selectVideo(id: number): Promise<void>;
|
|
728
|
+
selectVideo(id: number, smooth?: boolean): Promise<void>;
|
|
712
729
|
/**
|
|
713
730
|
* 设置播放音频轨道
|
|
714
731
|
*
|
|
715
|
-
* @param id 流 id,dash 传 getAudioList 列表中的 index
|
|
732
|
+
* @param id 流 id,dash 和 hls 传 getAudioList 列表中的 index
|
|
733
|
+
* @param smooth 平滑切换(hls 和 dash 使用,切换下一个加载的切片)
|
|
716
734
|
* @returns
|
|
717
735
|
*/
|
|
718
|
-
selectAudio(id: number): Promise<void>;
|
|
736
|
+
selectAudio(id: number, smooth?: boolean): Promise<void>;
|
|
719
737
|
/**
|
|
720
738
|
* 设置播放字幕轨道
|
|
721
739
|
*
|
|
722
|
-
* @param id 流 id,dash 传 getSubtitleList 列表中的 index
|
|
740
|
+
* @param id 流 id,dash 和 hls 传 getSubtitleList 列表中的 index
|
|
723
741
|
* @returns
|
|
724
742
|
*/
|
|
725
743
|
selectSubtitle(id: number): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AVCodecID
|
|
2
|
-
import {
|
|
1
|
+
import type { AVCodecID } from "@libmedia/avutil/codec";
|
|
2
|
+
import { AVMediaType } from "@libmedia/avutil/codec";
|
|
3
|
+
import type { WebAssemblyResource } from "@libmedia/cheap/webassembly/compiler";
|
|
3
4
|
export interface ControllerObserver {
|
|
4
5
|
onVideoEnded: () => void;
|
|
5
6
|
onAudioEnded: () => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { JitterBuffer } from "@libmedia/avpipeline/struct/stats";
|
|
2
|
+
import type Stats from "@libmedia/avpipeline/struct/stats";
|
|
2
3
|
export interface ControllerObserver {
|
|
3
4
|
onSetPlayRate: (rate: number) => void;
|
|
4
5
|
onCroppingBuffer: (max: int32) => void;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { AVOFormatContext } from "@libmedia/avformat/AVFormatContext";
|
|
2
|
-
import
|
|
1
|
+
import type { AVOFormatContext } from "@libmedia/avformat/AVFormatContext";
|
|
2
|
+
import type { TaskOptions } from "@libmedia/avpipeline/Pipeline";
|
|
3
|
+
import Pipeline from "@libmedia/avpipeline/Pipeline";
|
|
3
4
|
import IPCPort from "@libmedia/common/network/IPCPort";
|
|
4
|
-
import OFormat from "@libmedia/avformat/formats/OFormat";
|
|
5
|
+
import type OFormat from "@libmedia/avformat/formats/OFormat";
|
|
5
6
|
import IOWriter from "@libmedia/common/io/IOWriterSync";
|
|
6
7
|
import AVCodecParameters from "@libmedia/avutil/struct/avcodecparameters";
|
|
7
|
-
import { Rational } from "@libmedia/avutil/struct/rational";
|
|
8
|
+
import type { Rational } from "@libmedia/avutil/struct/rational";
|
|
8
9
|
import LoopTask from "@libmedia/common/timer/LoopTask";
|
|
9
10
|
import Track from "@libmedia/avrender/track/Track";
|
|
10
|
-
import { AVPacketPool, AVPacketRef } from "@libmedia/avutil/struct/avpacket";
|
|
11
|
-
import List from "@libmedia/cheap/std/collection/List";
|
|
12
|
-
import { Mutex } from "@libmedia/cheap/thread/mutex";
|
|
11
|
+
import type { AVPacketPool, AVPacketRef } from "@libmedia/avutil/struct/avpacket";
|
|
12
|
+
import type List from "@libmedia/cheap/std/collection/List";
|
|
13
|
+
import type { Mutex } from "@libmedia/cheap/thread/mutex";
|
|
13
14
|
import SeekableWriteBuffer from "@libmedia/common/io/SeekableWriteBuffer";
|
|
14
|
-
import { AVCodecParametersSerialize } from "@libmedia/avutil/util/serialize";
|
|
15
|
+
import type { AVCodecParametersSerialize } from "@libmedia/avutil/util/serialize";
|
|
15
16
|
import WorkerTimer from "@libmedia/common/timer/WorkerTimer";
|
|
16
|
-
import { Data } from "@libmedia/common/types/type";
|
|
17
|
+
import type { Data } from "@libmedia/common/types/type";
|
|
17
18
|
export interface MSETaskOptions extends TaskOptions {
|
|
18
19
|
isLive: boolean;
|
|
19
20
|
avpacketList: pointer<List<pointer<AVPacketRef>>>;
|
package/dist/types/struct.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Stats from "@libmedia/avpipeline/struct/stats";
|
|
2
|
-
import { AVFrameRef } from "@libmedia/avutil/struct/avframe";
|
|
3
|
-
import { AVPacketRef } from "@libmedia/avutil/struct/avpacket";
|
|
4
|
-
import List from "@libmedia/cheap/std/collection/List";
|
|
5
|
-
import { Mutex } from "@libmedia/cheap/thread/mutex";
|
|
1
|
+
import type Stats from "@libmedia/avpipeline/struct/stats";
|
|
2
|
+
import type { AVFrameRef } from "@libmedia/avutil/struct/avframe";
|
|
3
|
+
import type { AVPacketRef } from "@libmedia/avutil/struct/avpacket";
|
|
4
|
+
import type List from "@libmedia/cheap/std/collection/List";
|
|
5
|
+
import type { Mutex } from "@libmedia/cheap/thread/mutex";
|
|
6
6
|
export declare class AVPlayerGlobalData {
|
|
7
7
|
avpacketList: List<pointer<AVPacketRef>>;
|
|
8
8
|
avframeList: List<pointer<AVFrameRef>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AVPacketRef } from "@libmedia/avutil/struct/avpacket";
|
|
2
|
-
import AVCodecParameters from "@libmedia/avutil/struct/avcodecparameters";
|
|
3
|
-
import List from "@libmedia/cheap/std/collection/List";
|
|
4
|
-
import { Mutex } from "@libmedia/cheap/thread/mutex";
|
|
1
|
+
import type { AVPacketRef } from "@libmedia/avutil/struct/avpacket";
|
|
2
|
+
import type AVCodecParameters from "@libmedia/avutil/struct/avcodecparameters";
|
|
3
|
+
import type List from "@libmedia/cheap/std/collection/List";
|
|
4
|
+
import type { Mutex } from "@libmedia/cheap/thread/mutex";
|
|
5
5
|
export interface SubtitleRenderOptions {
|
|
6
6
|
delay?: int64;
|
|
7
7
|
getCurrentTime: () => int64;
|
package/dist/types/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AVPlayerProgress } from "./AVPlayer";
|
|
2
|
-
import { AVMediaType } from "@libmedia/avutil/codec";
|
|
1
|
+
import type { AVPlayerProgress } from "./AVPlayer";
|
|
2
|
+
import type { AVMediaType } from "@libmedia/avutil/codec";
|
|
3
3
|
export declare function playerEventNoParam(): void;
|
|
4
4
|
export declare function playerEventTime(pts: int64): void;
|
|
5
5
|
export declare function playerEventChanging(type: AVMediaType, newStreamId: int32, oldStreamId: int32): void;
|
package/dist/umd/19.avplayer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[19],{89984:(t,i,e)=>{e.d(i,{A:()=>r});var s=e(9655);class r{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},82019:(t,i,e)=>{e.r(i),e.d(i,{default:()=>y});var s=e(9655),r=e(16566),n=e(36311),a=e(29e3),h=e(20163),o=e(26137),d=e(81429),g=e(20086),l=e(64310),p=e(89984),u=e(41321),c=e(1140),f=e(37142),m=e(40919),b=e(81895),w=e(89378),I=e(59258),k=e(69663),S=e(3027),B=e(76384);const v="src/avformat/formats/IOggFormat.ts";class y extends p.A{constructor(){super(),(0,s.A)(this,"type",4),(0,s.A)(this,"headerPagesPayload",void 0),(0,s.A)(this,"page",void 0),(0,s.A)(this,"curSegIndex",void 0),(0,s.A)(this,"curSegStart",void 0),(0,s.A)(this,"segCount",void 0),(0,s.A)(this,"segIndex",void 0),(0,s.A)(this,"currentPts",void 0),(0,s.A)(this,"firstPos",void 0),(0,s.A)(this,"firstGranulePosition",void 0),(0,s.A)(this,"paddingPayload",void 0),this.page=new a.B,this.headerPagesPayload=[]}init(t){t.ioReader&&t.ioReader.setEndian(!1),t.ioReader&&t.ioReader.setEndian(!1),this.curSegIndex=-1,this.curSegStart=0,this.currentPts=BigInt(0),this.segCount=0,this.segIndex=0,this.firstGranulePosition=BigInt(0)}async estimateTotalBlock(t){let i=BigInt(0);const e=t.ioReader.getPos(),s=this.currentPts,r=await t.ioReader.fileSize();for(await t.ioReader.seek(B.T9(r-BigInt(195072),BigInt(0))),await this.syncPage(t);;)try{this.page.reset(),await this.page.read(t.ioReader),i=this.page.granulePosition}catch(t){break}return await t.ioReader.seek(e),this.currentPts=s,i}async getNextSegment(t){if(this.curSegIndex<0){this.page.granulePosition>BigInt(0)&&(this.currentPts=this.page.granulePosition),this.page.reset(),await this.page.read(t.ioReader),this.curSegIndex=0,this.curSegStart=0,this.segIndex=-1,this.segCount=0;for(let t=0;t<this.page.segmentTable.length;t++)255!==this.page.segmentTable[t]&&this.segCount++;this.segCount||(this.segCount=1)}let i=0;for(;this.curSegIndex<this.page.segmentTable.length;){const t=this.page.segmentTable[this.curSegIndex++];if(i+=t,255!==t)break}const e=this.curSegStart;return this.curSegStart+=i,this.segIndex++,this.curSegIndex===this.page.segmentTable.length&&(this.curSegIndex=-1),this.page.payload.subarray(e,e+i)}addComment(t,i){t.vendorString&&(i.metadata.vendor=t.vendorString),(0,d.ol)(t.comments.list,i.metadata)}async createStream(t,i){if(i.length<8)return 0;let e=new m.A(i.length,!1);e.appendBuffer(i);const s=e.peekString(8);if("OpusHead"===s){const s=new o.q;s.read(e);const r=t.createStream();r.codecpar.codecType=1,r.codecpar.codecId=86076,r.codecpar.sampleRate=s.sampleRate,r.codecpar.chLayout.nbChannels=s.channels,r.timeBase.den=r.codecpar.sampleRate,r.timeBase.num=1,r.codecpar.extradata=(0,c.sY)(i.length),r.codecpar.extradataSize=i.length,r.codecpar.initialPadding=s.preSkip,(0,u.lW)(r.codecpar.extradata,i.length,i);const n=new o.o;i=await this.getNextSegment(t),e=new m.A(i.length,!1),e.appendBuffer(i),n.read(e),this.headerPagesPayload=[s,n],r.privData={serialNumber:this.page.serialNumber},this.addComment(n,r),r.duration=await this.estimateTotalBlock(t)}else if("vorbis"===s.slice(1,7)){const s=[i],r=new d.mS;r.read(e);const n=new d.GM;i=await this.getNextSegment(t),e=new m.A(i.length,!1),e.appendBuffer(i),n.read(e),s.push(i),this.headerPagesPayload=[r,n];const a=t.createStream();a.codecpar.codecType=1,a.codecpar.codecId=86021,a.codecpar.sampleRate=r.sampleRate,a.codecpar.chLayout.nbChannels=r.channels,a.timeBase.den=a.codecpar.sampleRate,a.timeBase.num=1,a.privData={serialNumber:this.page.serialNumber},this.addComment(n,a),s.push(await this.getNextSegment(t));const h=s.reduce(((t,i)=>t+2+i.length),0),o=(0,c.sY)(h),g=new b.A(h,!0,new S.A(o,h));s.forEach((t=>{g.writeUint16(t.length),g.writeBuffer(t)})),a.codecpar.extradata=o,a.codecpar.extradataSize=h,a.duration=await this.estimateTotalBlock(t)}else if("FLAC"===s.slice(1,5)){e.setEndian(!0),e.skip(1),e.skip(4),e.skip(1),e.skip(1),e.readUint16(),e.skip(4);const s=e.readUint8(),r=e.readUint24();if(0!==s)return g.LR;{const s=t.createStream();s.codecpar.codecType=1,s.codecpar.codecId=86028;const n=(0,c.sY)(r);e.peekBuffer(r,(0,u.s3)(n,r)),e.skip(10);const h=e.readUint24();s.codecpar.sampleRate=h>>4,s.codecpar.chLayout.nbChannels=1+((15&h)>>>1),s.timeBase.den=s.codecpar.sampleRate,s.timeBase.num=1,s.privData={serialNumber:this.page.serialNumber},s.codecpar.extradata=n,s.codecpar.extradataSize=r;const o=new a.h;i=await this.getNextSegment(t),e=new m.A(i.length-4,!1),e.appendBuffer(i.subarray(4)),o.read(e),s.duration=await this.estimateTotalBlock(t),this.addComment(o,s),this.headerPagesPayload=[o]}}else{if("Speex"!==s.slice(0,5))return 0;{const s=t.createStream();s.codecpar.codecType=1,s.codecpar.codecId=86051;const r=(0,c.sY)(i.length);(0,u.lW)(r,i.length,i),s.codecpar.extradata=r,s.codecpar.extradataSize=i.length,e.seek(BigInt(36)),s.codecpar.sampleRate=e.readUint32(),e.seek(BigInt(48)),s.codecpar.chLayout.nbChannels=e.readUint32(),s.timeBase.den=s.codecpar.sampleRate,s.timeBase.num=1,s.privData={serialNumber:this.page.serialNumber};const n=new a.h;i=await this.getNextSegment(t),e=new m.A(i.length,!1),e.appendBuffer(i),n.read(e),s.duration=await this.estimateTotalBlock(t),this.addComment(n,s),this.headerPagesPayload=[n]}}return 1}async readHeader(t){try{if("OggS"!==await t.ioReader.peekString(4))return h.z3("the file format is not oggs",v,386),g.LR;for(;;){let i=this.paddingPayload||await this.getNextSegment(t);this.paddingPayload&&(this.paddingPayload=null);const e=await this.createStream(t,i);if(e<0)return e;if(!e){this.paddingPayload=i;break}}return this.firstPos=this.paddingPayload?this.page.pos:t.ioReader.getPos(),0}catch(i){return h.z3(i.message,v,408),t.ioReader.error}}async readAVPacket(t,i){n.M[17](i+56,t.ioReader.getPos());try{const e=this.paddingPayload||await this.getNextSegment(t);this.paddingPayload&&(this.paddingPayload=null);let s=this.currentPts+(this.page.granulePosition-this.currentPts)/BigInt(Math.floor(this.segCount))*BigInt(Math.floor(this.segIndex));n.M[17](i+16,s),n.M[17](i+8,s),this.firstGranulePosition||(this.firstGranulePosition=this.page.granulePosition);const a=t.streams.find((t=>t.privData&&t.privData.serialNumber===this.page.serialNumber));if(!a)return await this.createStream(t,e),this.readAVPacket(t,i);n.M[15](i+32,a.index),n.M[15](i+76,a.timeBase.den),n.M[15](i+72,a.timeBase.num),1===a.codecpar.codecType&&n.M[15](i+36,1|r.f[15](i+36));const h=[e];for(;this.curSegIndex<0;)try{if(!(1&(await t.ioReader.peekBuffer(6))[5]))break;h.push(await this.getNextSegment(t))}catch(t){break}const o=(0,l.A)(Uint8Array,h),d=o.length,g=(0,c.sY)(d);return(0,u.lW)(g,d,o),(0,f.NX)(i,g,d),0}catch(i){return-1048576!==t.ioReader.error&&-1048572!==t.ioReader.error?(h.z3(`read packet error, ${i}`,v,479),g.LR):t.ioReader.error}}async syncPage(t){let i=w.Dh,e=BigInt(0);for(;;)try{if("OggS"===await t.ioReader.peekString(4)){i=t.ioReader.getPos(),this.page.reset(),await this.page.read(t.ioReader),e=this.page.granulePosition;let s=0;for(;3!==s&&"OggS"===await t.ioReader.peekString(4);)s++,this.page.reset(),await this.page.read(t.ioReader);if(3===s)break}await t.ioReader.skip(1)}catch(t){break}if(i!==w.Dh){for(await t.ioReader.seek(i);1&(await t.ioReader.peekBuffer(6))[5];)this.page.reset(),await this.page.read(t.ioReader),e=this.page.granulePosition;this.currentPts=e-this.firstGranulePosition,this.curSegIndex=-1}}async seek(t,i,e,s){const r=t.ioReader.getPos();if(2&s){const i=await t.ioReader.fileSize();return i<=BigInt(0)?BigInt(g.E$):(e<BigInt(0)?e=BigInt(0):e>i&&(e=i),await t.ioReader.seek(e),4&s||await this.syncPage(t),r)}return(0,k.k)(e,i.timeBase,w.i0)<BigInt(1e4)?(h.Yz(`seek pts is earlier then 10s, seek to first packet pos(${this.firstPos}) directly`,v,571),await t.ioReader.seek(this.firstPos),this.currentPts=BigInt(0),r):(0,I.A)(t,i,e,this.firstPos,this.readAVPacket.bind(this),this.syncPage.bind(this))}getAnalyzeStreamsCount(){return 1}}},29e3:(t,i,e)=>{e.d(i,{B:()=>h,h:()=>o});var s=e(9655),r=e(89378),n=e(19372);class a{constructor(){(0,s.A)(this,"list",void 0),this.list=[]}read(t,i){for(let e=0;e<i;e++){const i=t.readUint32();this.list.push(t.readString(i))}}write(t){for(let i=0;i<this.list.length;i++){const e=n.encode(this.list[i]);t.writeUint32(e.length),t.writeBuffer(e)}}addComment(t){this.list.push(t)}}class h{constructor(){(0,s.A)(this,"capturePattern",void 0),(0,s.A)(this,"streamStructureVersion",void 0),(0,s.A)(this,"headerTypeFlag",void 0),(0,s.A)(this,"granulePosition",void 0),(0,s.A)(this,"serialNumber",void 0),(0,s.A)(this,"pageSequenceNumber",void 0),(0,s.A)(this,"crcCheckSum",void 0),(0,s.A)(this,"numberPageSegments",void 0),(0,s.A)(this,"segmentTable",void 0),(0,s.A)(this,"payload",void 0),(0,s.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(t){this.pos=t.getPos(),await this.readPageHeader(t);const i=this.segmentTable.reduce(((t,i)=>t+i),0);i&&(this.payload=await t.readBuffer(i))}async readPageHeader(t){if(this.capturePattern=await t.readString(4),this.streamStructureVersion=await t.readUint8(),this.headerTypeFlag=await t.readUint8(),this.granulePosition=await t.readUint64(),this.serialNumber=await t.readUint32(),this.pageSequenceNumber=await t.readUint32(),this.crcCheckSum=await t.readUint32(),this.numberPageSegments=await t.readUint8(),this.numberPageSegments)for(let i=0;i<this.numberPageSegments;i++){const i=await t.readUint8();this.segmentTable.push(i)}}write(t){if(this.pos=t.getPos(),t.writeString(this.capturePattern),t.writeUint8(this.streamStructureVersion),t.writeUint8(this.headerTypeFlag),t.writeUint64(this.granulePosition),t.writeUint32(this.serialNumber),t.writeUint32(this.pageSequenceNumber),t.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const i=this.payload.length%255;t.writeUint8(this.numberPageSegments);for(let i=0;i<this.numberPageSegments-1;i++)t.writeUint8(255);t.writeUint8(i),t.writeBuffer(this.payload)}else t.writeUint8(0)}}class o{constructor(){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"vendorStringLength",void 0),(0,s.A)(this,"vendorString",void 0),(0,s.A)(this,"userCommentListLength",void 0),(0,s.A)(this,"comments",void 0),this.vendorString="v0.11.0-3-g28452ba8",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new a}read(t){this.vendorStringLength=t.readUint32(),this.vendorString=t.readString(this.vendorStringLength),this.userCommentListLength=t.readUint32(),this.userCommentListLength&&this.comments.read(t,this.userCommentListLength)}write(t){const i=n.encode(this.vendorString);t.writeUint32(i.length),t.writeBuffer(i),t.writeUint32(this.comments.list.length),this.comments.write(t)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},26137:(t,i,e)=>{e.d(i,{o:()=>h,q:()=>a});var s=e(9655),r=e(29e3);class n{constructor(){(0,s.A)(this,"streamCount",void 0),(0,s.A)(this,"coupledStreamCount",void 0),(0,s.A)(this,"mapping",void 0),this.streamCount=1,this.coupledStreamCount=0,this.mapping=new Uint8Array(1)}read(t){this.streamCount=t.readUint8(),this.coupledStreamCount=t.readUint8(),this.mapping=t.readBuffer(this.streamCount+this.coupledStreamCount)}write(t){t.writeUint8(this.streamCount),t.writeUint8(this.coupledStreamCount),t.writeBuffer(this.mapping)}}class a{constructor(){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"channels",void 0),(0,s.A)(this,"preSkip",void 0),(0,s.A)(this,"sampleRate",void 0),(0,s.A)(this,"outputGain",void 0),(0,s.A)(this,"channelMappingFamily",void 0),(0,s.A)(this,"channelMappingTable",void 0),this.signature="OpusHead",this.version=1,this.channels=1,this.preSkip=0,this.sampleRate=48e3,this.outputGain=0,this.channelMappingFamily=0,this.channelMappingTable=new n}read(t){this.signature=t.readString(8),this.version=t.readUint8(),this.channels=t.readUint8(),this.preSkip=t.readUint16(),this.sampleRate=t.readUint32(),this.outputGain=t.readInt16(),this.channelMappingFamily=t.readUint8(),0!==this.channelMappingFamily&&this.channelMappingTable.read(t)}write(t){t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.channels),t.writeUint16(this.preSkip),t.writeUint32(this.sampleRate),t.writeInt16(this.outputGain),t.writeUint8(this.channelMappingFamily),0!==this.channelMappingFamily&&this.channelMappingTable.write(t)}setCodec(t){this.sampleRate=t.sampleRate,this.channels=t.chLayout.nbChannels,this.channelMappingFamily=t.format}}class h extends r.h{constructor(){super(),this.signature="OpusTags"}read(t){this.signature=t.readString(8),super.read(t)}write(t){t.writeString(this.signature),super.write(t)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},81429:(t,i,e)=>{e.d(i,{GM:()=>o,mS:()=>h,ol:()=>a});var s=e(9655),r=e(29e3);e(99868),e(21472);const n={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 a(t,i){t&&t.forEach((t=>{const e=t.split("=");if(2===e.length){const t=e[0].trim().toLowerCase(),s=e[1].trim();n[t]?i[n[t]]=s:i[t.toLowerCase()]=s}}))}class h{constructor(t="vorbis"){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"channels",void 0),(0,s.A)(this,"sampleRate",void 0),(0,s.A)(this,"bitrateMaximum",void 0),(0,s.A)(this,"bitrateNominal",void 0),(0,s.A)(this,"bitrateMinimum",void 0),(0,s.A)(this,"blocksize0",void 0),(0,s.A)(this,"blocksize1",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,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(t){this.packetType=t.readUint8(),this.signature=t.readString(6),this.version=t.readUint32(),this.channels=t.readUint8(),this.sampleRate=t.readInt32(),this.bitrateMaximum=t.readInt32(),this.bitrateNominal=t.readInt32(),this.bitrateMinimum=t.readInt32();const i=255&t.readUint8();this.blocksize0=Math.pow(2,i>>>4),this.blocksize1=Math.pow(2,15&i),this.framingFlag=t.readUint8()}write(t){t.writeUint8(1),t.writeString(this.signature),t.writeUint32(this.version),t.writeUint8(this.channels),t.writeInt32(this.sampleRate),t.writeInt32(this.bitrateMaximum),t.writeInt32(this.bitrateNominal),t.writeInt32(this.bitrateMinimum),t.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),t.writeUint8(1)}setCodec(t){this.sampleRate=t.sampleRate,this.channels=t.chLayout.nbChannels}}class o extends r.h{constructor(t="vorbis"){super(),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,this.packetType=1,this.framingFlag=1}read(t){this.packetType=t.readUint8(),this.signature=t.readString(6),super.read(t),"vorbis"===this.signature&&(this.framingFlag=t.readUint8())}write(t){t.writeUint8(this.packetType),t.writeString(this.signature),super.write(t),"vorbis"===this.signature&&t.writeUint8(this.framingFlag)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},45372:(t,i,e)=>{e.d(i,{d:()=>a});var s=e(31126),r=e(69663),n=e(89378);function a(t,i,e){let a=BigInt(0);return s.__(t,(t=>{a+=t.codecpar.bitrate*(0,r.k)(i,e,n.i0)/BigInt(8e3)})),a}},59258:(t,i,e)=>{e.d(i,{A:()=>l});var s=e(16566),r=(e(51308),e(89378)),n=e(69663),a=e(45372),h=e(37142),o=e(20086),d=e(20163);const g="src/avformat/function/seekInBytes.ts";async function l(t,i,e,l,p,u){const c=t.ioReader.getPos(),f=await t.ioReader.fileSize();let m=r.Dh,b=e;i.startTime!==r.Dh?b-=i.startTime:b-=i.firstDTS;const w=(0,n.k)(e,i.timeBase,r.i0);if(w<BigInt(1e4))return d.Yz(`seek pts is earlier then 10s, seek to first packet pos(${l}) directly`,g,63),await t.ioReader.seek(l),c;let I=(0,a.d)(t.streams,b,i.timeBase);const k=f-(0,a.d)(t.streams,BigInt(1e4),r.i0),S=(0,a.d)(t.streams,BigInt(1e4),r.i0);if(I>k&&(I=k),I<l)return await t.ioReader.seek(l),c;const B=(0,h._5)();let v=f,y=BigInt(0);t:for(;v-y<S&&(I=y),await t.ioReader.seek(I),await u(t),!(8&t.ioReader.flags);){let e=await p(t,B),a=s.f[17](B+56);if(!(e>=0)){m=r.Dh;break}{const o=(0,n.Mr)(s.f[17](B+8),B+72,r.i0);let l=o-w;if(d.Yz(`try to seek to pos: ${I}, got packet pts: ${s.f[17](B+8)}(${o}ms), diff: ${l}ms`,g,100),l<=BigInt(0)&&-l<BigInt(1e4)||v-y<S){const o=[a];for(;l<=0;){if(s.f[15](B+32)===i.index&&1&s.f[15](B+36)&&o.push(a),(0,h.Up)(B),e=await p(t,B),e<0){if(-1048576===e)break;if(-1048575===e)continue;m=r.Dh;break t}a=s.f[17](B+56),l=(0,n.Mr)(s.f[17](B+8),B+72,r.i0)-w}m=o.pop();break}l>BigInt(0)?(v=I,I=y+v>>BigInt(1)):(y=I,I=y+v>>BigInt(1))}if(8&t.ioReader.flags)break}return(0,h.Qe)(B),m!==r.Dh?(d.Yz(`finally seek to pos ${m}`,g,155),await t.ioReader.seek(m),await u(t),c):(await t.ioReader.seek(c),8&t.ioReader.flags?BigInt(o.LT):BigInt(o.E$))}},40919:(t,i,e)=>{e.d(i,{A:()=>h});var s=e(9655),r=e(20163),n=e(19372);const a="src/common/io/IOReaderSync.ts";class h{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}readUint8(){this.remainingLength()<1&&this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}peekUint8(){return this.remainingLength()<1&&this.flush(1),this.data.getUint8(this.pointer)}readUint16(){this.remainingLength()<2&&this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}peekUint16(){return this.remainingLength()<2&&this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}readUint24(){this.remainingLength()<3&&this.flush(3);const t=this.readUint16(),i=this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}peekUint24(){this.remainingLength()<3&&this.flush(3);const t=this.pointer,i=this.pos,e=this.readUint16(),s=this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}readUint32(){this.remainingLength()<4&&this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}peekUint32(){return this.remainingLength()<4&&this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}readUint64(){this.remainingLength()<8&&this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}peekUint64(){return this.remainingLength()<8&&this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}readInt8(){this.remainingLength()<1&&this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}peekInt8(){return this.remainingLength()<1&&this.flush(1),this.data.getInt8(this.pointer)}readInt16(){this.remainingLength()<2&&this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}peekInt16(){return this.remainingLength()<2&&this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}readInt24(){const t=this.readUint24();return 8388608&t?t-16777216:t}peekInt24(){const t=this.peekUint24();return 8388608&t?t-16777216:t}readInt32(){this.remainingLength()<4&&this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}peekInt32(){return this.remainingLength()<4&&this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}readInt64(){this.remainingLength()<8&&this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}peekInt64(){return this.remainingLength()<8&&this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}readFloat(){this.remainingLength()<4&&this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}peekFloat(){return this.remainingLength()<4&&this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}readDouble(){this.remainingLength()<8&&this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}peekDouble(){return this.remainingLength()<8&&this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}readHex(t=1){let i="";for(let e=0;e<t;e++){const t=this.readUint8().toString(16);i+=1===t.length?"0"+t:t}return i}peekHex(t=1){t>this.size&&(this.error=-1048574,r.h2("peekHex, length too large",a,412)),this.remainingLength()<t&&this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=this.readUint8().toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}readBuffer(t,i){if(!t)return new Uint8Array(0);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;){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}peekBuffer(t,i){return t?(t>this.size&&(this.error=-1048574,r.h2("peekBuffer, length too large",a,505)),this.remainingLength()<t&&this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i):new Uint8Array(0)}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{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}readString(t=1){const i=this.readBuffer(t);return n.decode(i)}peekString(t=1){const i=this.peekBuffer(t);return n.decode(i)}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+=this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=this.readString(this.remainingLength()),this.flush()}let i=this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=this.peekUint8(),10===i&&this.pointer++)),t}peekLine(){this.remainingLength()<this.size&&this.flush();let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,r.h2("peekLine, out of buffer",a,656)),t}getPointer(){return this.pointer}getPos(){return this.pos}skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}flush(t=0){if(this.onFlush||(this.error=-1048574,r.h2("IOReader error, flush failed because of no flush callback",a,720)),!(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=this.onFlush(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=this.onFlush(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}}seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<=this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,r.h2("IOReader error, seek failed because of no seek callback",a,790)),this.pointer=this.endPointer=0,this.pos=t;const s=this.onSeek(t);0!==s&&(this.error=s,r.h2("IOReader error, seek failed",a,799)),e&&this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,r.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",a,838)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}isBigEndian(){return!this.littleEndian}fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return r.R8("IOReader error, fileSize failed because of no onSize callback",a,880),BigInt(0);try{this.fileSize_=this.onSize()}catch(t){r.R8(`IOReader error, call fileSize failed: ${t}`,a,887),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){this.flush();const e=Math.min(this.endPointer-this.pointer,i);t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else 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();t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;this.onFlush(this.buffer.subarray(0))>0;){const i=this.remainingLength();t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}}},81895:(t,i,e)=>{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}}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[19],{89984:(t,i,e)=>{e.d(i,{A:()=>r});var s=e(9655);class r{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},82019:(t,i,e)=>{e.r(i),e.d(i,{default:()=>y});var s=e(9655),r=e(16566),n=e(36311),a=e(29e3),h=e(20163),o=e(26137),d=e(81429),g=e(20086),l=e(64310),p=e(89984),u=e(41321),c=e(1140),f=e(37142),m=e(40919),b=e(81895),w=e(89378),I=e(59258),k=e(69663),S=e(3027),B=e(76384);const v="src/avformat/formats/IOggFormat.ts";class y extends p.A{constructor(){super(),(0,s.A)(this,"type",4),(0,s.A)(this,"headerPagesPayload",void 0),(0,s.A)(this,"page",void 0),(0,s.A)(this,"curSegIndex",void 0),(0,s.A)(this,"curSegStart",void 0),(0,s.A)(this,"segCount",void 0),(0,s.A)(this,"segIndex",void 0),(0,s.A)(this,"currentPts",void 0),(0,s.A)(this,"firstPos",void 0),(0,s.A)(this,"firstGranulePosition",void 0),(0,s.A)(this,"paddingPayload",void 0),this.page=new a.B,this.headerPagesPayload=[]}init(t){t.ioReader&&t.ioReader.setEndian(!1),t.ioReader&&t.ioReader.setEndian(!1),this.curSegIndex=-1,this.curSegStart=0,this.currentPts=BigInt(0),this.segCount=0,this.segIndex=0,this.firstGranulePosition=BigInt(0)}async estimateTotalBlock(t){let i=BigInt(0);const e=t.ioReader.getPos(),s=this.currentPts,r=await t.ioReader.fileSize();for(await t.ioReader.seek(B.T9(r-BigInt(195072),BigInt(0))),await this.syncPage(t);;)try{this.page.reset(),await this.page.read(t.ioReader),i=this.page.granulePosition}catch(t){break}return await t.ioReader.seek(e),this.currentPts=s,i}async getNextSegment(t){if(this.curSegIndex<0){this.page.granulePosition>BigInt(0)&&(this.currentPts=this.page.granulePosition),this.page.reset(),await this.page.read(t.ioReader),this.curSegIndex=0,this.curSegStart=0,this.segIndex=-1,this.segCount=0;for(let t=0;t<this.page.segmentTable.length;t++)255!==this.page.segmentTable[t]&&this.segCount++;this.segCount||(this.segCount=1)}let i=0;for(;this.curSegIndex<this.page.segmentTable.length;){const t=this.page.segmentTable[this.curSegIndex++];if(i+=t,255!==t)break}const e=this.curSegStart;return this.curSegStart+=i,this.segIndex++,this.curSegIndex===this.page.segmentTable.length&&(this.curSegIndex=-1),this.page.payload.subarray(e,e+i)}addComment(t,i){t.vendorString&&(i.metadata.vendor=t.vendorString),(0,d.ol)(t.comments.list,i.metadata)}async createStream(t,i){if(i.length<8)return 0;let e=new m.A(i.length,!1);e.appendBuffer(i);const s=e.peekString(8);if("OpusHead"===s){const s=new o.q;s.read(e);const r=t.createStream();r.codecpar.codecType=1,r.codecpar.codecId=86076,r.codecpar.sampleRate=s.sampleRate,r.codecpar.chLayout.nbChannels=s.channels,r.timeBase.den=r.codecpar.sampleRate,r.timeBase.num=1,r.codecpar.extradata=(0,c.sY)(i.length),r.codecpar.extradataSize=i.length,r.codecpar.initialPadding=s.preSkip,(0,u.lW)(r.codecpar.extradata,i.length,i);const n=new o.o;i=await this.getNextSegment(t),e=new m.A(i.length,!1),e.appendBuffer(i),n.read(e),this.headerPagesPayload=[s,n],r.privData={serialNumber:this.page.serialNumber},this.addComment(n,r),r.duration=await this.estimateTotalBlock(t)}else if("vorbis"===s.slice(1,7)){const s=[i],r=new d.mS;r.read(e);const n=new d.GM;i=await this.getNextSegment(t),e=new m.A(i.length,!1),e.appendBuffer(i),n.read(e),s.push(i),this.headerPagesPayload=[r,n];const a=t.createStream();a.codecpar.codecType=1,a.codecpar.codecId=86021,a.codecpar.sampleRate=r.sampleRate,a.codecpar.chLayout.nbChannels=r.channels,a.timeBase.den=a.codecpar.sampleRate,a.timeBase.num=1,a.privData={serialNumber:this.page.serialNumber},this.addComment(n,a),s.push(await this.getNextSegment(t));const h=s.reduce(((t,i)=>t+2+i.length),0),o=(0,c.sY)(h),g=new b.A(h,!0,new S.A(o,h));s.forEach((t=>{g.writeUint16(t.length),g.writeBuffer(t)})),a.codecpar.extradata=o,a.codecpar.extradataSize=h,a.duration=await this.estimateTotalBlock(t)}else if("FLAC"===s.slice(1,5)){e.setEndian(!0),e.skip(1),e.skip(4),e.skip(1),e.skip(1),e.readUint16(),e.skip(4);const s=e.readUint8(),r=e.readUint24();if(0!==s)return g.LR;{const s=t.createStream();s.codecpar.codecType=1,s.codecpar.codecId=86028;const n=(0,c.sY)(r);e.peekBuffer(r,(0,u.s3)(n,r)),e.skip(10);const h=e.readUint24();s.codecpar.sampleRate=h>>4,s.codecpar.chLayout.nbChannels=1+((15&h)>>>1),s.timeBase.den=s.codecpar.sampleRate,s.timeBase.num=1,s.privData={serialNumber:this.page.serialNumber},s.codecpar.extradata=n,s.codecpar.extradataSize=r;const o=new a.h;i=await this.getNextSegment(t),e=new m.A(i.length-4,!1),e.appendBuffer(i.subarray(4)),o.read(e),s.duration=await this.estimateTotalBlock(t),this.addComment(o,s),this.headerPagesPayload=[o]}}else{if("Speex"!==s.slice(0,5))return 0;{const s=t.createStream();s.codecpar.codecType=1,s.codecpar.codecId=86051;const r=(0,c.sY)(i.length);(0,u.lW)(r,i.length,i),s.codecpar.extradata=r,s.codecpar.extradataSize=i.length,e.seek(BigInt(36)),s.codecpar.sampleRate=e.readUint32(),e.seek(BigInt(48)),s.codecpar.chLayout.nbChannels=e.readUint32(),s.timeBase.den=s.codecpar.sampleRate,s.timeBase.num=1,s.privData={serialNumber:this.page.serialNumber};const n=new a.h;i=await this.getNextSegment(t),e=new m.A(i.length,!1),e.appendBuffer(i),n.read(e),s.duration=await this.estimateTotalBlock(t),this.addComment(n,s),this.headerPagesPayload=[n]}}return 1}async readHeader(t){try{if("OggS"!==await t.ioReader.peekString(4))return h.z3("the file format is not oggs",v,388),g.LR;for(;;){let i=this.paddingPayload||await this.getNextSegment(t);this.paddingPayload&&(this.paddingPayload=null);const e=await this.createStream(t,i);if(e<0)return e;if(!e){this.paddingPayload=i;break}}return this.firstPos=this.paddingPayload?this.page.pos:t.ioReader.getPos(),0}catch(i){return h.z3(i.message,v,410),t.ioReader.error}}async readAVPacket(t,i){n.M[17](i+56,t.ioReader.getPos());try{const e=this.paddingPayload||await this.getNextSegment(t);this.paddingPayload&&(this.paddingPayload=null);let s=this.currentPts+(this.page.granulePosition-this.currentPts)/BigInt(Math.floor(this.segCount))*BigInt(Math.floor(this.segIndex));n.M[17](i+16,s),n.M[17](i+8,s),this.firstGranulePosition||(this.firstGranulePosition=this.page.granulePosition);const a=t.streams.find((t=>t.privData&&t.privData.serialNumber===this.page.serialNumber));if(!a)return await this.createStream(t,e),this.readAVPacket(t,i);n.M[15](i+32,a.index),n.M[15](i+76,a.timeBase.den),n.M[15](i+72,a.timeBase.num),1===a.codecpar.codecType&&n.M[15](i+36,1|r.f[15](i+36));const h=[e];for(;this.curSegIndex<0;)try{if(!(1&(await t.ioReader.peekBuffer(6))[5]))break;h.push(await this.getNextSegment(t))}catch(t){break}const o=(0,l.A)(Uint8Array,h),d=o.length,g=(0,c.sY)(d);return(0,u.lW)(g,d,o),(0,f.NX)(i,g,d),0}catch(i){return-1048576!==t.ioReader.error&&-1048572!==t.ioReader.error?(h.z3(`read packet error, ${i}`,v,481),g.LR):t.ioReader.error}}async syncPage(t){let i=w.Dh,e=BigInt(0);for(;;)try{if("OggS"===await t.ioReader.peekString(4)){i=t.ioReader.getPos(),this.page.reset(),await this.page.read(t.ioReader),e=this.page.granulePosition;let s=0;for(;3!==s&&"OggS"===await t.ioReader.peekString(4);)s++,this.page.reset(),await this.page.read(t.ioReader);if(3===s)break}await t.ioReader.skip(1)}catch(t){break}if(i!==w.Dh){for(await t.ioReader.seek(i);1&(await t.ioReader.peekBuffer(6))[5];)this.page.reset(),await this.page.read(t.ioReader),e=this.page.granulePosition;this.currentPts=e-this.firstGranulePosition,this.curSegIndex=-1}}async seek(t,i,e,s){const r=t.ioReader.getPos();if(2&s){const i=await t.ioReader.fileSize();return i<=BigInt(0)?BigInt(g.E$):(e<BigInt(0)?e=BigInt(0):e>i&&(e=i),await t.ioReader.seek(e),4&s||await this.syncPage(t),r)}return(0,k.k)(e,i.timeBase,w.i0)<BigInt(1e4)?(h.Yz(`seek pts is earlier then 10s, seek to first packet pos(${this.firstPos}) directly`,v,573),await t.ioReader.seek(this.firstPos),this.currentPts=BigInt(0),r):(0,I.A)(t,i,e,this.firstPos,this.readAVPacket.bind(this),this.syncPage.bind(this))}getAnalyzeStreamsCount(){return 1}}},29e3:(t,i,e)=>{e.d(i,{B:()=>h,h:()=>o});var s=e(9655),r=e(89378),n=e(19372);class a{constructor(){(0,s.A)(this,"list",void 0),this.list=[]}read(t,i){for(let e=0;e<i;e++){const i=t.readUint32();this.list.push(t.readString(i))}}write(t){for(let i=0;i<this.list.length;i++){const e=n.encode(this.list[i]);t.writeUint32(e.length),t.writeBuffer(e)}}addComment(t){this.list.push(t)}}class h{constructor(){(0,s.A)(this,"capturePattern",void 0),(0,s.A)(this,"streamStructureVersion",void 0),(0,s.A)(this,"headerTypeFlag",void 0),(0,s.A)(this,"granulePosition",void 0),(0,s.A)(this,"serialNumber",void 0),(0,s.A)(this,"pageSequenceNumber",void 0),(0,s.A)(this,"crcCheckSum",void 0),(0,s.A)(this,"numberPageSegments",void 0),(0,s.A)(this,"segmentTable",void 0),(0,s.A)(this,"payload",void 0),(0,s.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(t){this.pos=t.getPos(),await this.readPageHeader(t);const i=this.segmentTable.reduce(((t,i)=>t+i),0);i&&(this.payload=await t.readBuffer(i))}async readPageHeader(t){if(this.capturePattern=await t.readString(4),this.streamStructureVersion=await t.readUint8(),this.headerTypeFlag=await t.readUint8(),this.granulePosition=await t.readUint64(),this.serialNumber=await t.readUint32(),this.pageSequenceNumber=await t.readUint32(),this.crcCheckSum=await t.readUint32(),this.numberPageSegments=await t.readUint8(),this.numberPageSegments)for(let i=0;i<this.numberPageSegments;i++){const i=await t.readUint8();this.segmentTable.push(i)}}write(t){if(this.pos=t.getPos(),t.writeString(this.capturePattern),t.writeUint8(this.streamStructureVersion),t.writeUint8(this.headerTypeFlag),t.writeUint64(this.granulePosition),t.writeUint32(this.serialNumber),t.writeUint32(this.pageSequenceNumber),t.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const i=this.payload.length%255;t.writeUint8(this.numberPageSegments);for(let i=0;i<this.numberPageSegments-1;i++)t.writeUint8(255);t.writeUint8(i),t.writeBuffer(this.payload)}else t.writeUint8(0)}}class o{constructor(){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"vendorStringLength",void 0),(0,s.A)(this,"vendorString",void 0),(0,s.A)(this,"userCommentListLength",void 0),(0,s.A)(this,"comments",void 0),this.vendorString="libmedia-v0.12.0",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new a}read(t){this.vendorStringLength=t.readUint32(),this.vendorString=t.readString(this.vendorStringLength),this.userCommentListLength=t.readUint32(),this.userCommentListLength&&this.comments.read(t,this.userCommentListLength)}write(t){const i=n.encode(this.vendorString);t.writeUint32(i.length),t.writeBuffer(i),t.writeUint32(this.comments.list.length),this.comments.write(t)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},26137:(t,i,e)=>{e.d(i,{o:()=>h,q:()=>a});var s=e(9655),r=e(29e3);class n{constructor(){(0,s.A)(this,"streamCount",void 0),(0,s.A)(this,"coupledStreamCount",void 0),(0,s.A)(this,"mapping",void 0),this.streamCount=1,this.coupledStreamCount=0,this.mapping=new Uint8Array(1)}read(t){this.streamCount=t.readUint8(),this.coupledStreamCount=t.readUint8(),this.mapping=t.readBuffer(this.streamCount+this.coupledStreamCount)}write(t){t.writeUint8(this.streamCount),t.writeUint8(this.coupledStreamCount),t.writeBuffer(this.mapping)}}class a{constructor(){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"channels",void 0),(0,s.A)(this,"preSkip",void 0),(0,s.A)(this,"sampleRate",void 0),(0,s.A)(this,"outputGain",void 0),(0,s.A)(this,"channelMappingFamily",void 0),(0,s.A)(this,"channelMappingTable",void 0),this.signature="OpusHead",this.version=1,this.channels=1,this.preSkip=0,this.sampleRate=48e3,this.outputGain=0,this.channelMappingFamily=0,this.channelMappingTable=new n}read(t){this.signature=t.readString(8),this.version=t.readUint8(),this.channels=t.readUint8(),this.preSkip=t.readUint16(),this.sampleRate=t.readUint32(),this.outputGain=t.readInt16(),this.channelMappingFamily=t.readUint8(),0!==this.channelMappingFamily&&this.channelMappingTable.read(t)}write(t){t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.channels),t.writeUint16(this.preSkip),t.writeUint32(this.sampleRate),t.writeInt16(this.outputGain),t.writeUint8(this.channelMappingFamily),0!==this.channelMappingFamily&&this.channelMappingTable.write(t)}setCodec(t){this.sampleRate=t.sampleRate,this.channels=t.chLayout.nbChannels,this.channelMappingFamily=t.format}}class h extends r.h{constructor(){super(),this.signature="OpusTags"}read(t){this.signature=t.readString(8),super.read(t)}write(t){t.writeString(this.signature),super.write(t)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},81429:(t,i,e)=>{e.d(i,{GM:()=>o,mS:()=>h,ol:()=>a});var s=e(9655),r=e(29e3);e(99868),e(21472);const n={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 a(t,i){t&&t.forEach((t=>{const e=t.split("=");if(2===e.length){const t=e[0].trim().toLowerCase(),s=e[1].trim();n[t]?i[n[t]]=s:i[t.toLowerCase()]=s}}))}class h{constructor(t="vorbis"){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"channels",void 0),(0,s.A)(this,"sampleRate",void 0),(0,s.A)(this,"bitrateMaximum",void 0),(0,s.A)(this,"bitrateNominal",void 0),(0,s.A)(this,"bitrateMinimum",void 0),(0,s.A)(this,"blocksize0",void 0),(0,s.A)(this,"blocksize1",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,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(t){this.packetType=t.readUint8(),this.signature=t.readString(6),this.version=t.readUint32(),this.channels=t.readUint8(),this.sampleRate=t.readInt32(),this.bitrateMaximum=t.readInt32(),this.bitrateNominal=t.readInt32(),this.bitrateMinimum=t.readInt32();const i=255&t.readUint8();this.blocksize0=Math.pow(2,i>>>4),this.blocksize1=Math.pow(2,15&i),this.framingFlag=t.readUint8()}write(t){t.writeUint8(1),t.writeString(this.signature),t.writeUint32(this.version),t.writeUint8(this.channels),t.writeInt32(this.sampleRate),t.writeInt32(this.bitrateMaximum),t.writeInt32(this.bitrateNominal),t.writeInt32(this.bitrateMinimum),t.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),t.writeUint8(1)}setCodec(t){this.sampleRate=t.sampleRate,this.channels=t.chLayout.nbChannels}}class o extends r.h{constructor(t="vorbis"){super(),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,this.packetType=1,this.framingFlag=1}read(t){this.packetType=t.readUint8(),this.signature=t.readString(6),super.read(t),"vorbis"===this.signature&&(this.framingFlag=t.readUint8())}write(t){t.writeUint8(this.packetType),t.writeString(this.signature),super.write(t),"vorbis"===this.signature&&t.writeUint8(this.framingFlag)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},45372:(t,i,e)=>{e.d(i,{d:()=>a});var s=e(31126),r=e(69663),n=e(89378);function a(t,i,e){let a=BigInt(0);return s.__(t,(t=>{a+=t.codecpar.bitrate*(0,r.k)(i,e,n.i0)/BigInt(8e3)})),a}},59258:(t,i,e)=>{e.d(i,{A:()=>l});var s=e(16566),r=(e(51308),e(89378)),n=e(69663),a=e(45372),h=e(37142),o=e(20086),d=e(20163);const g="src/avformat/function/seekInBytes.ts";async function l(t,i,e,l,p,u){const c=t.ioReader.getPos(),f=await t.ioReader.fileSize();let m=r.Dh,b=e;i.startTime!==r.Dh?b-=i.startTime:b-=i.firstDTS;const w=(0,n.k)(e,i.timeBase,r.i0);if(w<BigInt(1e4))return d.Yz(`seek pts is earlier then 10s, seek to first packet pos(${l}) directly`,g,64),await t.ioReader.seek(l),c;let I=(0,a.d)(t.streams,b,i.timeBase);const k=f-(0,a.d)(t.streams,BigInt(1e4),r.i0),S=(0,a.d)(t.streams,BigInt(1e4),r.i0);if(I>k&&(I=k),I<l)return await t.ioReader.seek(l),c;const B=(0,h._5)();let v=f,y=BigInt(0);t:for(;v-y<S&&(I=y),await t.ioReader.seek(I),await u(t),!(8&t.ioReader.flags);){let e=await p(t,B),a=s.f[17](B+56);if(!(e>=0)){m=r.Dh;break}{const o=(0,n.Mr)(s.f[17](B+8),B+72,r.i0);let l=o-w;if(d.Yz(`try to seek to pos: ${I}, got packet pts: ${s.f[17](B+8)}(${o}ms), diff: ${l}ms`,g,101),l<=BigInt(0)&&-l<BigInt(1e4)||v-y<S){const o=[a];for(;l<=0;){if(s.f[15](B+32)===i.index&&1&s.f[15](B+36)&&o.push(a),(0,h.Up)(B),e=await p(t,B),e<0){if(-1048576===e)break;if(-1048575===e)continue;m=r.Dh;break t}a=s.f[17](B+56),l=(0,n.Mr)(s.f[17](B+8),B+72,r.i0)-w}m=o.pop();break}l>BigInt(0)?(v=I,I=y+v>>BigInt(1)):(y=I,I=y+v>>BigInt(1))}if(8&t.ioReader.flags)break}return(0,h.Qe)(B),m!==r.Dh?(d.Yz(`finally seek to pos ${m}`,g,156),await t.ioReader.seek(m),await u(t),c):(await t.ioReader.seek(c),8&t.ioReader.flags?BigInt(o.LT):BigInt(o.E$))}},40919:(t,i,e)=>{e.d(i,{A:()=>h});var s=e(9655),r=e(20163),n=e(19372);const a="src/common/io/IOReaderSync.ts";class h{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}readUint8(){this.remainingLength()<1&&this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}peekUint8(){return this.remainingLength()<1&&this.flush(1),this.data.getUint8(this.pointer)}readUint16(){this.remainingLength()<2&&this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}peekUint16(){return this.remainingLength()<2&&this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}readUint24(){this.remainingLength()<3&&this.flush(3);const t=this.readUint16(),i=this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}peekUint24(){this.remainingLength()<3&&this.flush(3);const t=this.pointer,i=this.pos,e=this.readUint16(),s=this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}readUint32(){this.remainingLength()<4&&this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}peekUint32(){return this.remainingLength()<4&&this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}readUint64(){this.remainingLength()<8&&this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}peekUint64(){return this.remainingLength()<8&&this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}readInt8(){this.remainingLength()<1&&this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}peekInt8(){return this.remainingLength()<1&&this.flush(1),this.data.getInt8(this.pointer)}readInt16(){this.remainingLength()<2&&this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}peekInt16(){return this.remainingLength()<2&&this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}readInt24(){const t=this.readUint24();return 8388608&t?t-16777216:t}peekInt24(){const t=this.peekUint24();return 8388608&t?t-16777216:t}readInt32(){this.remainingLength()<4&&this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}peekInt32(){return this.remainingLength()<4&&this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}readInt64(){this.remainingLength()<8&&this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}peekInt64(){return this.remainingLength()<8&&this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}readFloat(){this.remainingLength()<4&&this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}peekFloat(){return this.remainingLength()<4&&this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}readDouble(){this.remainingLength()<8&&this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}peekDouble(){return this.remainingLength()<8&&this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}readHex(t=1){let i="";for(let e=0;e<t;e++){const t=this.readUint8().toString(16);i+=1===t.length?"0"+t:t}return i}peekHex(t=1){t>this.size&&(this.error=-1048574,r.h2("peekHex, length too large",a,412)),this.remainingLength()<t&&this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=this.readUint8().toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}readBuffer(t,i){if(!t)return new Uint8Array(0);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;){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}peekBuffer(t,i){return t?(t>this.size&&(this.error=-1048574,r.h2("peekBuffer, length too large",a,505)),this.remainingLength()<t&&this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i):new Uint8Array(0)}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{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}readString(t=1){const i=this.readBuffer(t);return n.decode(i)}peekString(t=1){const i=this.peekBuffer(t);return n.decode(i)}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+=this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=this.readString(this.remainingLength()),this.flush()}let i=this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=this.peekUint8(),10===i&&this.pointer++)),t}peekLine(){this.remainingLength()<this.size&&this.flush();let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,r.h2("peekLine, out of buffer",a,656)),t}getPointer(){return this.pointer}getPos(){return this.pos}skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}flush(t=0){if(this.onFlush||(this.error=-1048574,r.h2("IOReader error, flush failed because of no flush callback",a,720)),!(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=this.onFlush(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=this.onFlush(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}}seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<=this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,r.h2("IOReader error, seek failed because of no seek callback",a,790)),this.pointer=this.endPointer=0,this.pos=t;const s=this.onSeek(t);0!==s&&(this.error=s,r.h2("IOReader error, seek failed",a,799)),e&&this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,r.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",a,838)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}isBigEndian(){return!this.littleEndian}fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return r.R8("IOReader error, fileSize failed because of no onSize callback",a,880),BigInt(0);try{this.fileSize_=this.onSize()}catch(t){r.R8(`IOReader error, call fileSize failed: ${t}`,a,887),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){this.flush();const e=Math.min(this.endPointer-this.pointer,i);t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else 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();t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;this.onFlush(this.buffer.subarray(0))>0;){const i=this.remainingLength();t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}}},81895:(t,i,e)=>{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}}}}]);
|