@predy-js/render-interface 0.3.3-beta.9 → 0.3.4-beta.1

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