[−][src]Trait adts_reader::AdtsConsumer
Trait to be implemented by types that wish to consume the ADTS data produced by AdtsParser
.
Example
use adts_reader::*; struct MyConsumer { } impl AdtsConsumer for MyConsumer { fn new_config(&mut self, mpeg_version: MpegVersion, protection: ProtectionIndicator, aot: AudioObjectType, freq: SamplingFrequency, private_bit: u8, channels: ChannelConfiguration, originality: Originality, home: u8) { println!("Configuration {:?} {:?} {:?}", aot, freq, channels); } fn payload(&mut self, buffer_fullness: u16, number_of_blocks: u8, buf: &[u8]) { println!(" - frame of {} bytes", buf.len()); } fn error(&mut self, err: AdtsParseError) { println!(" - oops: {:?}", err); } } let consumer = MyConsumer { }; let parser = AdtsParser::new(consumer);
Required methods
fn new_config(
&mut self,
mpeg_version: MpegVersion,
protection: ProtectionIndicator,
aot: AudioObjectType,
freq: SamplingFrequency,
private_bit: u8,
channels: ChannelConfiguration,
originality: Originality,
home: u8
)
&mut self,
mpeg_version: MpegVersion,
protection: ProtectionIndicator,
aot: AudioObjectType,
freq: SamplingFrequency,
private_bit: u8,
channels: ChannelConfiguration,
originality: Originality,
home: u8
)
Called when a new configuration is found within the ADTS bitstream
An ADTS bitstream should have the same configuration throughout, so this would usually just be called once at the beginning of the stream. The audio configuration header values do however appear in every frame (so that the bitstream format can support seeking, not that this implementation helps there) and so it would be possible for a malformed bitstream to signal a configuration change part way through.
fn payload(&mut self, buffer_fullness: u16, number_of_blocks: u8, buf: &[u8])
called with the ADTS frame payload, and frame-specific header values
fn error(&mut self, err: AdtsParseError)
called if AdtsParser encounters an error in the ADTS bitstream.