@predy-js/render-interface 0.3.3-beta.2 → 0.3.3-beta.20

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.2
5
+ * Version: v0.3.3-beta.20
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -4,6 +4,7 @@ import type { GPUCapability } from '../GPUCapability';
4
4
  import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
5
5
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
6
6
  import type { PredyVideoDecoder, PredyVideoDecoderConstructor } from './VideoDecoder';
7
+ import type { ResourcePlatform } from './ResourceInternal';
7
8
  export interface PredyRequestOptions {
8
9
  url: string;
9
10
  disableCache?: boolean;
@@ -32,10 +33,16 @@ export declare enum PredyTextEncoding {
32
33
  }
33
34
  export declare enum PredyVideoCodec {
34
35
  h264 = "avc1",
35
- h265 = "hev1"
36
+ h265 = "hev1",
37
+ av1 = "av1"
36
38
  }
37
39
  export interface PredyNativeInternal {
38
40
  webpDisabled?: boolean;
41
+ /**
42
+ * 是否支持获取gles3,但如果获取es3失败,会降级到es2
43
+ */
44
+ supportGLES3?: boolean;
45
+ platform: ResourcePlatform;
39
46
  createImageBitmap(data: TypedArray | string, //图片文件的数据
40
47
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
41
48
  getDefaultGPUCapability(): GPUCapability;
@@ -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,13 +1,4 @@
1
- import type { VideoCodec } 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
- }
1
+ import type { VideoFrameFormat } from '@predy-js/specification';
11
2
  export interface PredyVideoDecoderFrameData {
12
3
  width: number;
13
4
  height: number;
@@ -30,8 +21,8 @@ export interface PredyVideoDecoderMetadata {
30
21
  width: number;
31
22
  height: number;
32
23
  duration: number;
33
- frames: PredyVideoDecoderFrame[];
34
- format: VideoCodec;
24
+ frameCount: number;
25
+ format: VideoFrameFormat;
35
26
  frameBufferSize: number;
36
27
  }
37
28
  /**
@@ -39,6 +30,7 @@ export interface PredyVideoDecoderMetadata {
39
30
  */
40
31
  export interface PredyVideoDecoderConstructor {
41
32
  name: string;
33
+ prefetchOnly?: boolean;
42
34
  }
43
35
  export type PredyVideoDecoderLoadedCallback = (error?: Error, metadata?: PredyVideoDecoderMetadata) => void;
44
36
  export type PredyVideoDecoderSeekFrameCallback = (error?: Error, frame?: PredyVideoDecoderFrameData) => void;
@@ -46,6 +38,11 @@ export interface PredyVideoDecoder {
46
38
  readonly name: string;
47
39
  readonly status: PredyVideoDecoderStatus;
48
40
  readonly metadata?: PredyVideoDecoderMetadata;
41
+ /**
42
+ * 只做资源请求,不进行视频解码,
43
+ * 这种情况下,seekFrame永远返回error(prefetch only)
44
+ */
45
+ readonly prefetchOnly: boolean;
49
46
  /**
50
47
  * 是否要跳播/回播,如果不需要的话,Decoder可以自行释放已经播放的帧
51
48
  */
@@ -54,12 +51,12 @@ export interface PredyVideoDecoder {
54
51
  /**
55
52
  * 加载视频,解析视频的metadata,设置frame数组,
56
53
  * 此函数只能调用一次,如果需要解析其他的视频,需要重新创建对象
57
- * @param buffer 视频数据
54
+ * @param url 视频地址
58
55
  * @param callback 解析回调
59
56
  */
60
- loadVideo(buffer: Uint8Array | string, callback: PredyVideoDecoderLoadedCallback): void;
57
+ loadVideo(url: string, callback: PredyVideoDecoderLoadedCallback): void;
61
58
  /**
62
- * 解析视频的下一帧,获得图像数据。
59
+ * 解析视频的下一帧,获得图像数据。如果调用的时候正在解析,callback直接返回error
63
60
  * @param frameIndex frame的index
64
61
  * @param data 图像数据buffer,数据将被写入到此Buffer中,如果buffer尺寸不对,解析会失败
65
62
  * @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.2",
3
+ "version": "0.3.3-beta.20",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -4,6 +4,7 @@ import type { GPUCapability } from '../GPUCapability';
4
4
  import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
5
5
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
6
6
  import type { PredyVideoDecoder, PredyVideoDecoderConstructor } from './VideoDecoder';
7
+ import type { ResourcePlatform } from './ResourceInternal';
7
8
 
8
9
  export interface PredyRequestOptions {
9
10
  url: string,
@@ -46,11 +47,19 @@ export enum PredyTextEncoding {
46
47
  export enum PredyVideoCodec {
47
48
  h264 = 'avc1',
48
49
  h265 = 'hev1',
50
+ av1 = 'av1'
49
51
  }
50
52
 
51
53
  export interface PredyNativeInternal {
52
54
  webpDisabled?: boolean,
53
55
 
56
+ /**
57
+ * 是否支持获取gles3,但如果获取es3失败,会降级到es2
58
+ */
59
+ supportGLES3?: boolean,
60
+
61
+ platform: ResourcePlatform,
62
+
54
63
  createImageBitmap(data: TypedArray | string, //图片文件的数据
55
64
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void,
56
65
 
@@ -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,14 +1,4 @@
1
- import type { VideoCodec } from '@predy-js/specification';
2
-
3
- /**
4
- * video原始数据的切片,原始数据不暴露到js,只能通过decoder解析
5
- * 只暴露当前的切片时间和是否是keyframe
6
- */
7
- export interface PredyVideoDecoderFrame {
8
- time: number,
9
- key?: boolean,
10
- idx: number,
11
- }
1
+ import type { VideoFrameFormat } from '@predy-js/specification';
12
2
 
13
3
  export interface PredyVideoDecoderFrameData {
14
4
  width: number,
@@ -34,8 +24,8 @@ export interface PredyVideoDecoderMetadata {
34
24
  width: number,
35
25
  height: number,
36
26
  duration: number,
37
- frames: PredyVideoDecoderFrame[],
38
- format: VideoCodec,
27
+ frameCount: number,
28
+ format: VideoFrameFormat,
39
29
  frameBufferSize: number, // 每帧的buffer大小
40
30
  }
41
31
 
@@ -44,6 +34,7 @@ export interface PredyVideoDecoderMetadata {
44
34
  */
45
35
  export interface PredyVideoDecoderConstructor {
46
36
  name: string,
37
+ prefetchOnly?: boolean,
47
38
  }
48
39
 
49
40
  export type PredyVideoDecoderLoadedCallback = (error?: Error, metadata?: PredyVideoDecoderMetadata) => void;
@@ -53,6 +44,12 @@ export interface PredyVideoDecoder {
53
44
  readonly name: string,
54
45
  readonly status: PredyVideoDecoderStatus,
55
46
  readonly metadata?: PredyVideoDecoderMetadata,
47
+
48
+ /**
49
+ * 只做资源请求,不进行视频解码,
50
+ * 这种情况下,seekFrame永远返回error(prefetch only)
51
+ */
52
+ readonly prefetchOnly: boolean,
56
53
  /**
57
54
  * 是否要跳播/回播,如果不需要的话,Decoder可以自行释放已经播放的帧
58
55
  */
@@ -62,13 +59,13 @@ export interface PredyVideoDecoder {
62
59
  /**
63
60
  * 加载视频,解析视频的metadata,设置frame数组,
64
61
  * 此函数只能调用一次,如果需要解析其他的视频,需要重新创建对象
65
- * @param buffer 视频数据
62
+ * @param url 视频地址
66
63
  * @param callback 解析回调
67
64
  */
68
- loadVideo(buffer: Uint8Array | string, callback: PredyVideoDecoderLoadedCallback): void,
65
+ loadVideo(url: string, callback: PredyVideoDecoderLoadedCallback): void,
69
66
 
70
67
  /**
71
- * 解析视频的下一帧,获得图像数据。
68
+ * 解析视频的下一帧,获得图像数据。如果调用的时候正在解析,callback直接返回error
72
69
  * @param frameIndex frame的index
73
70
  * @param data 图像数据buffer,数据将被写入到此Buffer中,如果buffer尺寸不对,解析会失败
74
71
  * @param callback 图像数据回调