X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=src%2Fframe.rs;h=962198e84df7afba64412a1a179d2bf9c64dc326;hb=83e603fadb920a29f16a1ef2cedb9be4048dab5a;hp=77a5c1730768d3e76dfeede9409779199b46b6bd;hpb=653e5afd9cc1047d60f3faed8f772cb82d26368d;p=nihav.git diff --git a/src/frame.rs b/src/frame.rs index 77a5c17..962198e 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::fmt; use std::rc::Rc; use formats::*; @@ -17,6 +18,12 @@ impl NAAudioInfo { } } +impl fmt::Display for NAAudioInfo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} Hz, {} ch", self.sample_rate, self.channels) + } +} + #[allow(dead_code)] #[derive(Clone,Copy)] pub struct NAVideoInfo { @@ -32,6 +39,12 @@ impl NAVideoInfo { } } +impl fmt::Display for NAVideoInfo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}x{}", self.width, self.height) + } +} + #[derive(Clone,Copy)] pub enum NACodecTypeInfo { None, @@ -39,6 +52,18 @@ pub enum NACodecTypeInfo { Video(NAVideoInfo), } +impl fmt::Display for NACodecTypeInfo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let ret = match *self { + NACodecTypeInfo::None => format!(""), + NACodecTypeInfo::Audio(fmt) => format!("{}", fmt), + NACodecTypeInfo::Video(fmt) => format!("{}", fmt), + }; + write!(f, "{}", ret) + } +} + + #[allow(dead_code)] pub struct NABuffer<'a> { id: u64,