-
Notifications
You must be signed in to change notification settings - Fork 147
Decoder Class Reference
The AV.Decoder
class is a class abstraction that subclasses and extends audio decoding for various codecs (e.g. MP3, AAC, FLAC, etc.,). Decoders receive data from the AV.Demuxer and implement the readChunk
method to decode the audio data into Linear PCM. This is passed to the audio hardware for playback (or any other output destination).
When you implement your own decoders, remember to call AV.Decoder.register(id, YourDecoder)
to register your decoder with the framework.
A AV.Stream object containing the audio data.
A AV.Bitstream object containing the audio data.
A boolean that keeps track of whether the decoder has been sent the final buffer from the AV.Demuxer yet.
This method is optional and is called when a 'cookie' event is emitted by the AV.Demuxer. The cookie is passed as an AV.Buffer object.
readChunk
is required, and is called by the framework whenever decoding is necessary. readChunk
is responsible for decoding the audio data found in the stream
or bitstream
and emitting data events containing the decoded audio data as a Typed Array.
If not enough data is available in the stream at the time readChunk
is called, schedule it to be called later by registering readChunk
for the 'available' event once in the future, e.g. this.once('available', this.readChunk)
.
If there is an error in the decoding process, emit an error
event to stop the whole decoding process entirely.
You should emit the data
event whenever you have decoded some number of samples of Linear PCM audio data. You should include the data as a Typed Array.
This event is emitted by the AV.Decoder
class whenever new data is available from the AV.Demuxer.
You should emit the error
event whenever there is an error in the decoder. Emitting this event will halt the rest of the decoding process.
All AV.Decoder
subclasses should be registered with the AV.Decoder
class using this class method. You can register your decoder for multiple ids if you know that different containers use different FOURCCs for the codec, for example.
Finds a registered decoder using the 4 (or less) character FOURCC code the decoder registered itself as.