aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2017-05-14 18:00:54 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2017-05-14 18:00:54 +0200
commit83e603fadb920a29f16a1ef2cedb9be4048dab5a (patch)
treeceba2438205de06a84d12d7acfe41d86b4a509c6 /src
parent653e5afd9cc1047d60f3faed8f772cb82d26368d (diff)
downloadnihav-83e603fadb920a29f16a1ef2cedb9be4048dab5a.tar.gz
print more info for streams
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/mod.rs6
-rw-r--r--src/frame.rs25
2 files changed, 28 insertions, 3 deletions
diff --git a/src/demuxers/mod.rs b/src/demuxers/mod.rs
index 14aac93..fac5c82 100644
--- a/src/demuxers/mod.rs
+++ b/src/demuxers/mod.rs
@@ -13,6 +13,7 @@ pub enum StreamType {
Audio,
Subtitles,
Data,
+ None,
}
impl fmt::Display for StreamType {
@@ -22,6 +23,7 @@ impl fmt::Display for StreamType {
StreamType::Audio => write!(f, "Audio"),
StreamType::Subtitles => write!(f, "Subtitles"),
StreamType::Data => write!(f, "Data"),
+ StreamType::None => write!(f, "-"),
}
}
}
@@ -48,7 +50,7 @@ impl NAStream {
impl fmt::Display for NAStream {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "({}#{})", self.media_type, self.id)
+ write!(f, "({}#{} - {})", self.media_type, self.id, self.info.get_properties())
}
}
@@ -117,7 +119,6 @@ impl<'a> NAPacketReader for ByteReader<'a> {
buf.resize(size, 0);
let res = self.read_buf(buf.as_mut_slice());
if let Err(_) = res { return Err(DemuxerError::IOError); }
- if res.unwrap() < buf.len() { return Err(DemuxerError::IOError); }
let pkt = NAPacket::new(str, pts, dts, dur, kf, buf);
Ok(pkt)
}
@@ -126,7 +127,6 @@ impl<'a> NAPacketReader for ByteReader<'a> {
let mut buf = Rc::make_mut(&mut refbuf);
let res = self.read_buf(buf.as_mut_slice());
if let Err(_) = res { return Err(DemuxerError::IOError); }
- if res.unwrap() < buf.len() { return Err(DemuxerError::IOError); }
Ok(())
}
}
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,