pr-player 0.1.9 → 0.2.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.
@@ -1,5 +1,4 @@
1
1
  import { RenderWorker } from './render/RenderWorker';
2
- import { Shader } from './render/type';
3
2
  interface On {
4
3
  demuxer: {
5
4
  info?: (_info: any) => void;
@@ -18,6 +17,7 @@ interface On {
18
17
  }
19
18
  interface PrPlayerOption {
20
19
  debug?: boolean;
20
+ frameTrack?: boolean;
21
21
  }
22
22
  export declare class PrPlayer {
23
23
  private option;
@@ -28,9 +28,7 @@ export declare class PrPlayer {
28
28
  private decoderWorker;
29
29
  private audioPlayer;
30
30
  private renderWorker;
31
- private renderBaseTime;
32
31
  private stream;
33
- private canvas;
34
32
  on: On;
35
33
  private cutRenders;
36
34
  trackGenerator: MediaStreamTrackGenerator;
@@ -48,22 +46,41 @@ export declare class PrPlayer {
48
46
  * 停止
49
47
  */
50
48
  stop: () => Promise<void>;
51
- getCanvas: () => HTMLCanvasElement | undefined;
49
+ /**
50
+ * 获取媒体流
51
+ */
52
52
  getStream: () => MediaStream | undefined;
53
- setPause: (pause: boolean) => void;
54
53
  /**
55
- * 设置渲染模式
54
+ * 设置暂停
55
+ * @param pause: boolean
56
56
  */
57
- setShader: (shader: Shader[]) => void;
57
+ setPause: (pause: boolean) => void;
58
58
  /**
59
59
  * 是否静音 默认为true
60
60
  * @param state?: boolean
61
61
  */
62
62
  setMute: (state?: boolean) => void | undefined;
63
+ /**
64
+ * 是否开启追帧
65
+ * @param frameTrack?: boolean
66
+ */
67
+ setFrameTrack: (frameTrack: boolean) => void;
63
68
  /**
64
69
  * 是否已准备好
65
70
  */
66
71
  isReady: () => Promise<unknown>;
72
+ /**
73
+ * 初始化解复器
74
+ */
75
+ private initDemuxer;
76
+ /**
77
+ * 初始化解码器
78
+ */
79
+ private initDecoder;
80
+ /**
81
+ * 初始化渲染器
82
+ */
83
+ private initRender;
67
84
  cut: {
68
85
  /**
69
86
  * 创建剪切
@@ -76,33 +93,22 @@ export declare class PrPlayer {
76
93
  }) => {
77
94
  worker: RenderWorker;
78
95
  stream: MediaStream;
79
- canvas: HTMLCanvasElement;
80
96
  destroy: Function;
81
97
  };
82
- getCanvas: (key: string) => HTMLCanvasElement | undefined;
98
+ /**
99
+ * 获取媒体流
100
+ */
83
101
  getStream: (key: string) => MediaStream | undefined;
84
- setPause: (key: string, pause: boolean) => void;
85
102
  /**
86
- * 设置渲染模式
103
+ * 设置暂停
104
+ * @param pause: boolean
87
105
  */
88
- setShader: (key: string, shader: Shader[]) => void;
106
+ setPause: (key: string, pause: boolean) => void;
89
107
  /**
90
108
  * 移除剪切
91
109
  */
92
110
  remove: (key: string) => void;
93
111
  };
94
- /**
95
- * 初始化解复器
96
- */
97
- private initDemuxer;
98
- /**
99
- * 初始化解码器
100
- */
101
- private initDecoder;
102
- /**
103
- * 初始化渲染器
104
- */
105
- private initRender;
106
112
  private flv;
107
113
  private hls;
108
114
  }
@@ -5,17 +5,38 @@ export declare class Decoder {
5
5
  private videoDecoderConfig?;
6
6
  private videoDecoder?;
7
7
  private hasKeyFrame;
8
+ private baseTime;
9
+ private pendingChunks;
10
+ private isProcessing;
11
+ private decodeTimer;
12
+ private frameTrack;
13
+ private minFrameTrackCacheNum;
14
+ private decodingSpeed;
15
+ private decodingSpeedRatio;
16
+ private maxDecodingSpeedRatio;
17
+ private nextRenderTime?;
8
18
  on: On;
9
19
  constructor();
20
+ init: (option: {
21
+ decodingSpeed: number;
22
+ frameTrack?: boolean;
23
+ minFrameTrackCacheNum?: number;
24
+ }) => void;
25
+ setFrameTrack: (frameTrack: boolean) => void;
26
+ private initDecodeInterval;
27
+ private decode;
28
+ private decodeAudio;
29
+ private decodeVideo;
30
+ destroy: () => void;
10
31
  audio: {
11
32
  init: (config: AudioDecoderConfig) => void;
12
- decode: (init: EncodedAudioChunkInit) => void;
33
+ push: (init: EncodedAudioChunkInit) => void;
13
34
  flush: () => void;
14
35
  destroy: () => void;
15
36
  };
16
37
  video: {
17
38
  init: (config: VideoDecoderConfig) => void;
18
- decode: (init: EncodedVideoChunkInit) => void;
39
+ push: (init: EncodedVideoChunkInit) => void;
19
40
  flush: () => void;
20
41
  destroy: () => void;
21
42
  };
@@ -3,15 +3,21 @@ export declare class DecoderWorker {
3
3
  worker: Worker;
4
4
  on: On;
5
5
  constructor();
6
+ init: (option: {
7
+ decodingSpeed: number;
8
+ frameTrack?: boolean;
9
+ minFrameTrackCacheNum?: number;
10
+ }) => void;
11
+ setFrameTrack: (frameTrack: boolean) => void;
6
12
  audio: {
7
13
  init: (config: AudioDecoderConfig) => void;
8
- decode: (init: EncodedAudioChunkInit) => void;
14
+ push: (init: EncodedAudioChunkInit) => void;
9
15
  flush: () => void;
10
16
  destroy: () => void;
11
17
  };
12
18
  video: {
13
19
  init: (config: VideoDecoderConfig) => void;
14
- decode: (init: EncodedVideoChunkInit) => void;
20
+ push: (init: EncodedVideoChunkInit) => void;
15
21
  flush: () => void;
16
22
  destroy: () => void;
17
23
  };
@@ -11,3 +11,13 @@ export interface On {
11
11
  error?: (_e: DOMException) => void;
12
12
  };
13
13
  }
14
+ interface PendingAudioChunk {
15
+ type: 'audio';
16
+ init: EncodedAudioChunkInit;
17
+ }
18
+ interface PendingVideoChunk {
19
+ type: 'video';
20
+ init: EncodedAudioChunkInit;
21
+ }
22
+ export type PendingChunk = PendingAudioChunk | PendingVideoChunk;
23
+ export {};
@@ -1,4 +1,4 @@
1
- import { Cacher, Chunk } from '../cacher/Cacher';
1
+ import { Cacher, Chunk } from './Cacher';
2
2
  export type Pattern = 'hls' | 'dash' | 'rtmp' | 'flv';
3
3
  export interface AudioConfig {
4
4
  kind: 'audio';
@@ -1,4 +1,4 @@
1
- import { Chunk } from '../cacher/Cacher';
1
+ import { Chunk } from './Cacher';
2
2
  import { AudioConfig, VideoConfig } from './Demuxer';
3
3
  export interface On {
4
4
  debug?: (_debug: any) => void;
@@ -1,4 +1,4 @@
1
- import { Chunk } from '../cacher/Cacher';
1
+ import { Chunk } from './Cacher';
2
2
  import { AudioConfig, VideoConfig } from './Demuxer';
3
3
  export interface Pat {
4
4
  header: {