Documentation ¶
Index ¶
Constants ¶
const ( ErrStreamFalse = StreamError(C.OP_FALSE) ErrStreamEOF = StreamError(C.OP_EOF) ErrStreamHole = StreamError(C.OP_HOLE) ErrStreamRead = StreamError(C.OP_EREAD) ErrStreamFault = StreamError(C.OP_EFAULT) ErrStreamImpl = StreamError(C.OP_EIMPL) ErrStreamInval = StreamError(C.OP_EINVAL) ErrStreamNotFormat = StreamError(C.OP_ENOTFORMAT) ErrStreamBadHeader = StreamError(C.OP_EBADHEADER) ErrStreamVersion = StreamError(C.OP_EVERSION) ErrStreamNotAudio = StreamError(C.OP_ENOTAUDIO) ErrStreamBadPacked = StreamError(C.OP_EBADPACKET) ErrStreamBadLink = StreamError(C.OP_EBADLINK) ErrStreamNoSeek = StreamError(C.OP_ENOSEEK) ErrStreamBadTimestamp = StreamError(C.OP_EBADTIMESTAMP) )
Libopusfile errors. The names are copied verbatim from the libopusfile library.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream wraps a io.Reader in a decoding layer. It provides an API similar to io.Reader, but it provides raw PCM data instead of the encoded Opus data.
This is not the same as directly decoding the bytes on the io.Reader; opus streams are Ogg Opus audio streams, which package raw Opus data.
This wraps libopusfile. For more information, see the api docs on xiph.org:
https://www.opus-codec.org/docs/opusfile_api-0.7/index.html
func (*Stream) Init ¶
Init initializes a stream with an io.Reader to fetch opus encoded data from on demand. Errors from the reader are all transformed to an EOF, any actual error information is lost. The same happens when a read returns successfully, but with zero bytes.
func (*Stream) Read ¶
Read a chunk of raw opus data from the stream and decode it. Returns the number of decoded samples per channel. This means that a dual channel (stereo) feed will have twice as many samples as the value returned.
Read may successfully read less bytes than requested, but it will never read exactly zero bytes successfully if a non-zero buffer is supplied.
The number of channels in the output data must be known in advance. It is possible to extract this information from the stream itself, but I'm not motivated to do that. Feel free to send a pull request.
type StreamError ¶
type StreamError int
StreamError represents an error from libopusfile.
func (StreamError) Error ¶
func (i StreamError) Error() string