@predy-js/render-interface 0.3.3-beta.3 → 0.3.3-beta.31

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/statistic.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.3.3-beta.3
5
+ * Version: v0.3.3-beta.31
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -23,6 +23,7 @@ export declare abstract class TextureInternal implements ResourceInternal {
23
23
  readonly height: number;
24
24
  readonly name: string;
25
25
  readonly options: TextureInternalOptions;
26
+ readonly error?: number;
26
27
  protected constructor(options: TextureInternalConstructOptions);
27
28
  abstract resize(width: number, height: number): boolean;
28
29
  abstract destroy(): void;
@@ -1,18 +1,10 @@
1
1
  import type { VideoFrameFormat } from '@predy-js/specification';
2
- /**
3
- * video原始数据的切片,原始数据不暴露到js,只能通过decoder解析
4
- * 只暴露当前的切片时间和是否是keyframe
5
- */
6
- export interface PredyVideoDecoderFrame {
7
- time: number;
8
- key?: boolean;
9
- idx: number;
10
- }
11
2
  export interface PredyVideoDecoderFrameData {
12
3
  width: number;
13
4
  height: number;
14
5
  data: Uint8Array;
15
6
  idx: number;
7
+ keyframe: boolean;
16
8
  }
17
9
  export declare enum PredyVideoDecoderStatus {
18
10
  init = 0,
@@ -30,7 +22,7 @@ export interface PredyVideoDecoderMetadata {
30
22
  width: number;
31
23
  height: number;
32
24
  duration: number;
33
- frames: PredyVideoDecoderFrame[];
25
+ frameCount: number;
34
26
  format: VideoFrameFormat;
35
27
  frameBufferSize: number;
36
28
  }
@@ -39,6 +31,7 @@ export interface PredyVideoDecoderMetadata {
39
31
  */
40
32
  export interface PredyVideoDecoderConstructor {
41
33
  name: string;
34
+ prefetchOnly?: boolean;
42
35
  }
43
36
  export type PredyVideoDecoderLoadedCallback = (error?: Error, metadata?: PredyVideoDecoderMetadata) => void;
44
37
  export type PredyVideoDecoderSeekFrameCallback = (error?: Error, frame?: PredyVideoDecoderFrameData) => void;
@@ -46,6 +39,11 @@ export interface PredyVideoDecoder {
46
39
  readonly name: string;
47
40
  readonly status: PredyVideoDecoderStatus;
48
41
  readonly metadata?: PredyVideoDecoderMetadata;
42
+ /**
43
+ * 只做资源请求,不进行视频解码,
44
+ * 这种情况下,seekFrame永远返回error(prefetch only)
45
+ */
46
+ readonly prefetchOnly: boolean;
49
47
  /**
50
48
  * 是否要跳播/回播,如果不需要的话,Decoder可以自行释放已经播放的帧
51
49
  */
@@ -59,7 +57,12 @@ export interface PredyVideoDecoder {
59
57
  */
60
58
  loadVideo(url: string, callback: PredyVideoDecoderLoadedCallback): void;
61
59
  /**
62
- * 解析视频的下一帧,获得图像数据。
60
+ * 如果当前正在解析,中断解析,并且之前的callback返回error(abort)
61
+ * 调用后回到frameReady状态
62
+ */
63
+ abortSeeking(): void;
64
+ /**
65
+ * 解析视频的下一帧,获得图像数据。如果调用的时候正在解析,callback直接返回error
63
66
  * @param frameIndex frame的index
64
67
  * @param data 图像数据buffer,数据将被写入到此Buffer中,如果buffer尺寸不对,解析会失败
65
68
  * @param callback 图像数据回调
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.3.3-beta.3",
3
+ "version": "0.3.3-beta.31",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -52,28 +52,21 @@ export enum PredyVideoCodec {
52
52
 
53
53
  export interface PredyNativeInternal {
54
54
  webpDisabled?: boolean,
55
-
56
55
  /**
57
56
  * 是否支持获取gles3,但如果获取es3失败,会降级到es2
58
57
  */
59
58
  supportGLES3?: boolean,
60
-
61
59
  platform: ResourcePlatform,
62
-
63
60
  createImageBitmap(data: TypedArray | string, //图片文件的数据
64
61
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void,
65
-
66
62
  getDefaultGPUCapability(): GPUCapability,
67
-
68
63
  requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void,
69
-
70
64
  /**
71
65
  * decode text from data
72
66
  * @param data
73
67
  * @param encoding 默认utf8
74
68
  */
75
69
  decodeText(data: Uint8Array, encoding?: PredyTextEncoding): string,
76
-
77
70
  /**
78
71
  * 将图片绘制到画布上,同时替换文案,绘制的顺序如下
79
72
  * 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
@@ -82,14 +75,12 @@ export interface PredyNativeInternal {
82
75
  * @param template
83
76
  */
84
77
  renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal,
85
-
86
78
  /**
87
79
  * 异步绘制图片的模板
88
80
  * @param options
89
81
  * @param callback 如果传入callback就是异步绘制,否则会直接返回结果
90
82
  */
91
83
  generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined,
92
-
93
84
  /**
94
85
  * 下载并且执行脚本文件,此方法会缓存https的脚本内容
95
86
  * 对于http的请求(开发环境),每次都重新请求
@@ -97,7 +88,6 @@ export interface PredyNativeInternal {
97
88
  * @param callback
98
89
  */
99
90
  evaluateScriptURL(url: string, callback: (err: Error, result: any) => void): void,
100
-
101
91
  /**
102
92
  * 将float32Array转换为half float,写入Uint16Array中,
103
93
  * 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
@@ -32,6 +32,8 @@ export abstract class TextureInternal implements ResourceInternal {
32
32
 
33
33
  readonly options: TextureInternalOptions;
34
34
 
35
+ readonly error?: number;
36
+
35
37
  protected constructor (options: TextureInternalConstructOptions) {
36
38
  }
37
39
 
@@ -1,20 +1,11 @@
1
1
  import type { VideoFrameFormat } from '@predy-js/specification';
2
2
 
3
- /**
4
- * video原始数据的切片,原始数据不暴露到js,只能通过decoder解析
5
- * 只暴露当前的切片时间和是否是keyframe
6
- */
7
- export interface PredyVideoDecoderFrame {
8
- time: number,
9
- key?: boolean,
10
- idx: number,
11
- }
12
-
13
3
  export interface PredyVideoDecoderFrameData {
14
4
  width: number,
15
5
  height: number,
16
6
  data: Uint8Array,
17
7
  idx: number,
8
+ keyframe: boolean,
18
9
  }
19
10
 
20
11
  export enum PredyVideoDecoderStatus {
@@ -34,7 +25,7 @@ export interface PredyVideoDecoderMetadata {
34
25
  width: number,
35
26
  height: number,
36
27
  duration: number,
37
- frames: PredyVideoDecoderFrame[],
28
+ frameCount: number,
38
29
  format: VideoFrameFormat,
39
30
  frameBufferSize: number, // 每帧的buffer大小
40
31
  }
@@ -44,6 +35,7 @@ export interface PredyVideoDecoderMetadata {
44
35
  */
45
36
  export interface PredyVideoDecoderConstructor {
46
37
  name: string,
38
+ prefetchOnly?: boolean,
47
39
  }
48
40
 
49
41
  export type PredyVideoDecoderLoadedCallback = (error?: Error, metadata?: PredyVideoDecoderMetadata) => void;
@@ -53,6 +45,12 @@ export interface PredyVideoDecoder {
53
45
  readonly name: string,
54
46
  readonly status: PredyVideoDecoderStatus,
55
47
  readonly metadata?: PredyVideoDecoderMetadata,
48
+
49
+ /**
50
+ * 只做资源请求,不进行视频解码,
51
+ * 这种情况下,seekFrame永远返回error(prefetch only)
52
+ */
53
+ readonly prefetchOnly: boolean,
56
54
  /**
57
55
  * 是否要跳播/回播,如果不需要的话,Decoder可以自行释放已经播放的帧
58
56
  */
@@ -68,7 +66,12 @@ export interface PredyVideoDecoder {
68
66
  loadVideo(url: string, callback: PredyVideoDecoderLoadedCallback): void,
69
67
 
70
68
  /**
71
- * 解析视频的下一帧,获得图像数据。
69
+ * 如果当前正在解析,中断解析,并且之前的callback返回error(abort)
70
+ * 调用后回到frameReady状态
71
+ */
72
+ abortSeeking(): void,
73
+ /**
74
+ * 解析视频的下一帧,获得图像数据。如果调用的时候正在解析,callback直接返回error
72
75
  * @param frameIndex frame的index
73
76
  * @param data 图像数据buffer,数据将被写入到此Buffer中,如果buffer尺寸不对,解析会失败
74
77
  * @param callback 图像数据回调