Skip to content

Commit 42f791d

Browse files
committed
Updated interfaces
1 parent af58360 commit 42f791d

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

interfaces.go

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,34 @@ type Media interface {
136136

137137
// Return parameters if a the stream should be decoded
138138
// 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.
140142
type DecoderMapFunc func(Stream) (Parameters, error)
141143

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.
143157
type Decoder interface {
144158
// Demultiplex media into packets. Pass a packet to a decoder function.
145159
// Stop when the context is cancelled or the end of the media stream is
146160
// reached.
147161
Demux(context.Context, DecoderFunc) error
148162

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
155167
}
156168

157169
// Parameters represents a set of parameters for encoding
@@ -173,6 +185,9 @@ type AudioParameters interface {
173185

174186
// Return the sample rate (Hz)
175187
SampleRate() int
188+
189+
// TODO:
190+
// Planar, number of planes, bits and bytes per sample
176191
}
177192

178193
// Video parameters for encoding or decoding video data.
@@ -188,31 +203,29 @@ type VideoParameters interface {
188203

189204
// Return the frame rate (fps)
190205
FrameRate() int
206+
207+
// TODO:
208+
// Planar, number of planes, names of the planes, bits and bytes per pixel
191209
}
192210

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.
194213
type DecoderFunc func(Packet) error
195214

196215
// 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.
198218
type FrameFunc func(Frame) error
199219

200220
// Packet represents a packet of demultiplexed data.
201221
// Currently this is quite opaque!
202222
type Packet interface{}
203223

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-
214224
// 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!
215227
type Frame interface{}
216228

217229
// Metadata represents a metadata entry for a media stream.
230+
// Currently this is quite opaque!
218231
type Metadata interface{}

sys/chromaprint/chromaprint.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package chromaprint
22

3+
import (
4+
"fmt"
5+
"time"
6+
"unsafe"
7+
)
8+
39
////////////////////////////////////////////////////////////////////////////////
410
// CGO
511

@@ -8,11 +14,6 @@ package chromaprint
814
#include <chromaprint.h>
915
*/
1016
import "C"
11-
import (
12-
"fmt"
13-
"time"
14-
"unsafe"
15-
)
1617

1718
////////////////////////////////////////////////////////////////////////////////
1819
// TYPES

0 commit comments

Comments
 (0)