ffmpreg 0.1.2

An experimental general-purpose multimedia toolkit.
Documentation
use crate::container::WavFormat;
use crate::core::{Decoder, Frame, Packet};
use std::io::Result;

pub struct PcmDecoder {
	format: WavFormat,
}

impl PcmDecoder {
	pub fn new(format: WavFormat) -> Self {
		Self { format }
	}
}

impl Decoder for PcmDecoder {
	fn decode(&mut self, packet: Packet) -> Result<Option<Frame>> {
		let nb_samples = packet.size() / self.format.bytes_per_frame();

		let frame = Frame::new(
			packet.data,
			packet.timebase,
			self.format.sample_rate,
			self.format.channels,
			nb_samples,
		)
		.with_pts(packet.pts);

		Ok(Some(frame))
	}

	fn flush(&mut self) -> Result<Option<Frame>> {
		Ok(None)
	}
}