-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdts-header.d.ts
More file actions
192 lines (174 loc) · 5.23 KB
/
dts-header.d.ts
File metadata and controls
192 lines (174 loc) · 5.23 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// Import types from standard.d.ts for use in index.d.ts
import type {
VideoDecoderConfig,
VideoEncoderConfig,
AudioEncoderConfig,
AudioDecoderConfig,
VideoFrameBufferInit,
EncodedVideoChunkInit,
EncodedAudioChunkInit,
AudioDataInit,
VideoColorSpaceInit,
ImageDecoderInit,
BufferSource,
AllowSharedBufferSource,
} from './standard'
// Re-export types from standard.d.ts
export {
// Config types
VideoDecoderConfig,
VideoEncoderConfig,
AudioEncoderConfig,
AudioDecoderConfig,
VideoFrameBufferInit,
// Init types (used by constructors)
EncodedVideoChunkInit,
EncodedAudioChunkInit,
AudioDataInit,
VideoColorSpaceInit,
ImageDecoderInit,
// Buffer types
BufferSource,
AllowSharedBufferSource,
} from './standard'
/**
* Interface for Canvas-like objects compatible with VideoFrame constructor.
* Compatible with @napi-rs/canvas Canvas class.
*
* @napi-rs/canvas is an optional peer dependency. If installed, Canvas objects
* can be used as VideoFrame sources. The Canvas pixel data is copied (RGBA format).
*/
export interface CanvasLike {
readonly width: number
readonly height: number
/** Returns raw RGBA pixel data as a Buffer */
data(): Uint8Array
}
// ============================================================================
// Muxer/Demuxer Types
// ============================================================================
/** Demuxer state */
export type DemuxerState = 'unloaded' | 'ready' | 'demuxing' | 'ended' | 'closed'
/** Muxer state */
export type MuxerState = 'configuring' | 'muxing' | 'finalized' | 'closed'
/** Init options for Mp4Demuxer */
export interface Mp4DemuxerInit {
/** Callback for video chunks */
videoOutput?: (chunk: EncodedVideoChunk) => void
/** Callback for audio chunks */
audioOutput?: (chunk: EncodedAudioChunk) => void
/** Error callback (required) */
error: (error: Error) => void
}
/** Init options for WebMDemuxer */
export interface WebMDemuxerInit {
/** Callback for video chunks */
videoOutput?: (chunk: EncodedVideoChunk) => void
/** Callback for audio chunks */
audioOutput?: (chunk: EncodedAudioChunk) => void
/** Error callback (required) */
error: (error: Error) => void
}
/** Init options for MkvDemuxer */
export interface MkvDemuxerInit {
/** Callback for video chunks */
videoOutput?: (chunk: EncodedVideoChunk) => void
/** Callback for audio chunks */
audioOutput?: (chunk: EncodedAudioChunk) => void
/** Error callback (required) */
error: (error: Error) => void
}
/** Video track config for muxer */
export interface MuxerVideoTrackConfig {
/** Codec string */
codec: string
/** Video width */
width: number
/** Video height */
height: number
/** Codec description (e.g., avcC for H.264) */
description?: Uint8Array
}
/** Audio track config for muxer */
export interface MuxerAudioTrackConfig {
/** Codec string */
codec: string
/** Sample rate */
sampleRate: number
/** Number of channels */
numberOfChannels: number
/** Codec description */
description?: Uint8Array
}
/** Init options for Mp4Muxer */
export interface Mp4MuxerInit {
/** Move moov atom to beginning (not compatible with streaming) */
fastStart?: boolean
/** Use fragmented MP4 for streaming */
fragmented?: boolean
/** Enable streaming output mode */
streaming?: { bufferCapacity?: number }
}
/** Init options for WebMMuxer */
export interface WebMMuxerInit {
/** Enable live streaming mode */
live?: boolean
/** Enable streaming output mode */
streaming?: { bufferCapacity?: number }
}
/** Init options for MkvMuxer */
export interface MkvMuxerInit {
/** Enable live streaming mode */
live?: boolean
/** Enable streaming output mode */
streaming?: { bufferCapacity?: number }
}
// ============================================================================
// Async Iterator Types
// ============================================================================
/**
* Chunk yielded by demuxer async iterator.
*
* Contains either a video or audio chunk. Use the `chunkType` property
* to determine which type of chunk is present.
*
* @example
* ```typescript
* for await (const chunk of demuxer) {
* if (chunk.chunkType === 'video') {
* videoDecoder.decode(chunk.videoChunk!)
* } else {
* audioDecoder.decode(chunk.audioChunk!)
* }
* }
* ```
*/
export interface DemuxerChunk {
/** Type of chunk: 'video' or 'audio' */
chunkType: 'video' | 'audio'
/** Video chunk (present when chunkType is 'video') */
videoChunk?: EncodedVideoChunk
/** Audio chunk (present when chunkType is 'audio') */
audioChunk?: EncodedAudioChunk
}
/**
* Adds async iterator support to Mp4Demuxer.
* Declaration merging allows using `for await...of` with the demuxer.
*/
export interface Mp4Demuxer {
[Symbol.asyncIterator](): AsyncGenerator<DemuxerChunk, void, void>
}
/**
* Adds async iterator support to WebMDemuxer.
* Declaration merging allows using `for await...of` with the demuxer.
*/
export interface WebMDemuxer {
[Symbol.asyncIterator](): AsyncGenerator<DemuxerChunk, void, void>
}
/**
* Adds async iterator support to MkvDemuxer.
* Declaration merging allows using `for await...of` with the demuxer.
*/
export interface MkvDemuxer {
[Symbol.asyncIterator](): AsyncGenerator<DemuxerChunk, void, void>
}