-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi.ts
67 lines (56 loc) · 1.17 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/// <reference path="typings/es6-promise.d.ts" />
interface VideoInfo {
width: number;
height: number;
fps_num: number;
fps_den: number;
}
interface EncoderConfig extends VideoInfo {
params: any;
}
interface VideoFrame {
timestamp: number;
width: number;
height: number;
data: ArrayBuffer;
y: Uint8ClampedArray;
u: Uint8ClampedArray;
v: Uint8ClampedArray;
transferable: boolean;
}
enum FrameType {
Key = 1,
IDR = 1,
I = 2,
P = 3,
B = 4,
Unknown = 255
}
interface ReadEventArgs extends VideoFrame {
ended: boolean;
}
interface IReader {
open(args: any): Promise<VideoInfo>;
read(): Promise<ReadEventArgs>;
close(): void;
}
interface IRenderer {
init(info: VideoInfo): void;
draw(frame: VideoFrame): void;
}
interface Packet {
data: ArrayBuffer;
frame_type: FrameType;
}
interface IResult {
status: number,
reason?: string,
}
interface IEncoder {
setup(cfg: EncoderConfig): Promise<Packet>;
encode(frame: VideoFrame): Promise<Packet>;
}
interface IDecoder {
setup(cfg: any, packet: Packet): Promise<any>;
decode(packet: Packet): Promise<VideoFrame>;
}