use nihav_core::io::byteio::*;
#[derive(Clone,Copy,Debug,PartialEq)]
use nihav_core::io::byteio::*;
#[derive(Clone,Copy,Debug,PartialEq)]
impl PCMDecoder {
fn new(mode: PCMMode) -> Self {
PCMDecoder { chmap: NAChannelMap::new(), mode }
impl PCMDecoder {
fn new(mode: PCMMode) -> Self {
PCMDecoder { chmap: NAChannelMap::new(), mode }
fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) -> u64 {
if duration == None {
let size_bits = (data_size as u64) * 8;
fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) -> u64 {
if duration == None {
let size_bits = (data_size as u64) * 8;
impl NADecoder for PCMDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
impl NADecoder for PCMDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
impl NAOptionHandler for PCMDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for PCMDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
macro_rules! write_buffer {
($abuf: expr, $dvec: expr, $write_be: ident, $write_le: ident, $dtype: tt) => {
let info = $abuf.get_info();
macro_rules! write_buffer {
($abuf: expr, $dvec: expr, $write_be: ident, $write_le: ident, $dtype: tt) => {
let info = $abuf.get_info();
impl NAEncoder for PCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
NACodecTypeInfo::None => {
impl NAEncoder for PCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
NACodecTypeInfo::None => {
- let mut ofmt = EncodeParameters::default();
- ofmt.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16P_FORMAT, 0));
- Ok(ofmt)
+ Ok(EncodeParameters {
+ format: NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16P_FORMAT, 0)),
+ ..Default::default()
+ })
NACodecTypeInfo::Video(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Audio(_) => {
let info = NACodecInfo::new("pcm", encinfo.format, None);
NACodecTypeInfo::Video(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Audio(_) => {
let info = NACodecInfo::new("pcm", encinfo.format, None);
- let mut stream = NAStream::new(StreamType::Audio, stream_id, info, encinfo.tb_num, encinfo.tb_den);
+ let mut stream = NAStream::new(StreamType::Audio, stream_id, info, encinfo.tb_num, encinfo.tb_den, 0);
stream.set_num(stream_id as usize);
let stream = stream.into_ref();
self.stream = Some(stream.clone());
stream.set_num(stream_id as usize);
let stream = stream.into_ref();
self.stream = Some(stream.clone());
impl NAOptionHandler for PCMEncoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for PCMEncoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}