@@ -136,22 +136,34 @@ type Media interface {
136
136
137
137
// Return parameters if a the stream should be decoded
138
138
// and either resampled or resized. Return nil if you
139
- // don't want to resample or resize the stream.
139
+ // want to ignore the stream, or pass identical stream
140
+ // parameters (stream.Parameters()) if you want to copy
141
+ // the stream without any changes.
140
142
type DecoderMapFunc func (Stream ) (Parameters , error )
141
143
142
- // Decoder represents a decoder for a media stream.
144
+ // Stream represents a audio, video, subtitle or data stream
145
+ // within a media file
146
+ type Stream interface {
147
+ // Return AUDIO, VIDEO, SUBTITLE or DATA
148
+ Type () MediaType
149
+
150
+ // Return the stream parameters
151
+ Parameters () Parameters
152
+ }
153
+
154
+ // Decoder represents a demuliplexer and decoder for a media stream.
155
+ // You can call either Demux or Decode to process the media stream,
156
+ // but not both.
143
157
type Decoder interface {
144
158
// Demultiplex media into packets. Pass a packet to a decoder function.
145
159
// Stop when the context is cancelled or the end of the media stream is
146
160
// reached.
147
161
Demux (context.Context , DecoderFunc ) error
148
162
149
- /*
150
- // Return a decode function, which can rescale or
151
- // resample a frame and then call a frame processing
152
- // function for encoding and multiplexing.
153
- Decode(FrameFunc) DecoderFunc
154
- */
163
+ // Decode media into frames, and resample or resize the frame.
164
+ // Stop when the context is cancelled or the end of the media stream is
165
+ // reached.
166
+ Decode (context.Context , FrameFunc ) error
155
167
}
156
168
157
169
// Parameters represents a set of parameters for encoding
@@ -173,6 +185,9 @@ type AudioParameters interface {
173
185
174
186
// Return the sample rate (Hz)
175
187
SampleRate () int
188
+
189
+ // TODO:
190
+ // Planar, number of planes, bits and bytes per sample
176
191
}
177
192
178
193
// Video parameters for encoding or decoding video data.
@@ -188,31 +203,29 @@ type VideoParameters interface {
188
203
189
204
// Return the frame rate (fps)
190
205
FrameRate () int
206
+
207
+ // TODO:
208
+ // Planar, number of planes, names of the planes, bits and bytes per pixel
191
209
}
192
210
193
- // DecoderFunc is a function that decodes a packet
211
+ // DecoderFunc is a function that decodes a packet. Return
212
+ // io.EOF if you want to stop processing the packets early.
194
213
type DecoderFunc func (Packet ) error
195
214
196
215
// FrameFunc is a function that processes a frame of audio
197
- // or video data.
216
+ // or video data. Return io.EOF if you want to stop
217
+ // processing the frames early.
198
218
type FrameFunc func (Frame ) error
199
219
200
220
// Packet represents a packet of demultiplexed data.
201
221
// Currently this is quite opaque!
202
222
type Packet interface {}
203
223
204
- // Stream represents a audio, video, subtitle or data stream
205
- // within a media file
206
- type Stream interface {
207
- // Return AUDIO, VIDEO, SUBTITLE or DATA
208
- Type () MediaType
209
-
210
- // Return the stream parameters
211
- Parameters () Parameters
212
- }
213
-
214
224
// Frame represents a frame of audio or picture data.
225
+ // Currently this is quite opaque - should allow access to
226
+ // the audio sample data, or the individual pixel data!
215
227
type Frame interface {}
216
228
217
229
// Metadata represents a metadata entry for a media stream.
230
+ // Currently this is quite opaque!
218
231
type Metadata interface {}
0 commit comments