pr-player 0.2.6 → 0.2.7

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/README.md CHANGED
@@ -33,9 +33,6 @@ const player = new PrPlayer({ debug: true })
33
33
  player.on.demuxer.chunk = (chunk) => {
34
34
  console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: chunk`, chunk)
35
35
  }
36
- player.on.demuxer.sei = (sei) => {
37
- console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: sei`, sei)
38
- }
39
36
  }
40
37
 
41
38
  // 如果你只需要解码器相关的能力 可以拿到解码后的所有回调
@@ -46,6 +43,9 @@ const player = new PrPlayer({ debug: true })
46
43
  player.on.decoder.video = (video) => {
47
44
  console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: video`, video)
48
45
  }
46
+ player.on.decoder.sei = (sei) => {
47
+ console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: sei`, sei)
48
+ }
49
49
  }
50
50
 
51
51
  await player.start('https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-720p.flv')
@@ -4,7 +4,6 @@ interface On {
4
4
  info?: (_info: any) => void;
5
5
  config?: (_config: any) => void;
6
6
  chunk?: (_chunk: any) => void;
7
- sei?: (_payload: Uint8Array) => void;
8
7
  };
9
8
  decoder: {
10
9
  audio?: (_audio: {
@@ -15,6 +14,7 @@ interface On {
15
14
  timestamp: number;
16
15
  bitmap: ImageBitmap;
17
16
  }) => void;
17
+ sei?: (_payload: Uint8Array) => void;
18
18
  };
19
19
  error?: (_e: any) => void;
20
20
  }
@@ -1,5 +1,5 @@
1
1
  import { Pattern } from '../type';
2
- import { On } from './type';
2
+ import { On, PendingChunk } from './type';
3
3
  export declare class Decoder {
4
4
  private pattern;
5
5
  private audioDecoderConfig?;
@@ -9,6 +9,7 @@ export declare class Decoder {
9
9
  private hasKeyFrame;
10
10
  private baseTime;
11
11
  private pendingChunks;
12
+ private currentChunk?;
12
13
  private isProcessing;
13
14
  private decodeTimer;
14
15
  private frameTrack;
@@ -20,27 +21,21 @@ export declare class Decoder {
20
21
  private secondVideoChunkTimestamp?;
21
22
  private decodingSpeedRatio;
22
23
  private maxDecodingSpeedRatio;
24
+ private frameStartTime?;
23
25
  private lastRenderTime?;
24
26
  private nextRenderTime?;
25
27
  on: On;
26
28
  constructor();
27
29
  init: (pattern: Pattern) => void;
30
+ initAudio: (config: AudioDecoderConfig) => void;
31
+ initVideo: (config: VideoDecoderConfig) => void;
28
32
  setFrameTrack: (frameTrack: boolean) => void;
33
+ push: (chunk: PendingChunk) => void;
34
+ destroy: () => void;
29
35
  private initDecodeInterval;
30
36
  private decode;
31
37
  private decodeAudio;
32
38
  private decodeVideo;
33
- destroy: () => void;
34
- audio: {
35
- init: (config: AudioDecoderConfig) => void;
36
- push: (init: EncodedAudioChunkInit) => void;
37
- flush: () => void;
38
- destroy: () => void;
39
- };
40
- video: {
41
- init: (config: VideoDecoderConfig) => void;
42
- push: (init: EncodedVideoChunkInit) => void;
43
- flush: () => void;
44
- destroy: () => void;
45
- };
39
+ private audio;
40
+ private video;
46
41
  }
@@ -1,22 +1,13 @@
1
1
  import { Pattern } from '../type';
2
- import { On } from './type';
2
+ import { On, PendingChunk } from './type';
3
3
  export declare class DecoderWorker {
4
4
  worker: Worker;
5
5
  on: On;
6
6
  constructor();
7
7
  init: (pattern: Pattern) => void;
8
+ initAudio: (config: AudioDecoderConfig) => void;
9
+ initVideo: (config: VideoDecoderConfig) => void;
10
+ push: (chunk: PendingChunk) => void;
8
11
  setFrameTrack: (frameTrack: boolean) => void;
9
- audio: {
10
- init: (config: AudioDecoderConfig) => void;
11
- push: (init: EncodedAudioChunkInit) => void;
12
- flush: () => void;
13
- destroy: () => void;
14
- };
15
- video: {
16
- init: (config: VideoDecoderConfig) => void;
17
- push: (init: EncodedVideoChunkInit) => void;
18
- flush: () => void;
19
- destroy: () => void;
20
- };
21
12
  destroy: () => void;
22
13
  }
@@ -13,15 +13,17 @@ export interface On {
13
13
  }) => void;
14
14
  error?: (_e: DOMException) => void;
15
15
  };
16
+ nalus?: (nalus: Uint8Array<ArrayBufferLike>[]) => void;
16
17
  debug?: (_e: any) => void;
17
18
  }
18
19
  interface PendingAudioChunk {
19
- type: 'audio';
20
+ kind: 'audio';
20
21
  init: EncodedAudioChunkInit;
21
22
  }
22
23
  interface PendingVideoChunk {
23
- type: 'video';
24
+ kind: 'video';
24
25
  init: EncodedAudioChunkInit;
26
+ nalus?: Uint8Array<ArrayBufferLike>[];
25
27
  }
26
28
  export type PendingChunk = PendingAudioChunk | PendingVideoChunk;
27
29
  export {};