#[allow(dead_code)]
-pub struct NAStream<'a> {
+pub struct NAStream {
media_type: StreamType,
id: u32,
- info: Rc<NACodecInfo<'a>>,
+ info: Rc<NACodecInfo>,
}
-impl<'a> NAStream<'a> {
- pub fn new(mt: StreamType, id: u32, info: NACodecInfo<'a>) -> Self {
+impl NAStream {
+ pub fn new(mt: StreamType, id: u32, info: NACodecInfo) -> Self {
NAStream { media_type: mt, id: id, info: Rc::new(info) }
}
pub fn get_id(&self) -> u32 { self.id }
- pub fn get_info(&self) -> Rc<NACodecInfo<'a>> { self.info.clone() }
+ pub fn get_info(&self) -> Rc<NACodecInfo> { self.info.clone() }
}
-impl<'a> fmt::Display for NAStream<'a> {
+impl fmt::Display for NAStream {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}#{})", self.media_type, self.id)
}
}
#[allow(dead_code)]
-pub struct NAPacket<'a> {
- stream: Rc<NAStream<'a>>,
+pub struct NAPacket {
+ stream: Rc<NAStream>,
pts: Option<u64>,
dts: Option<u64>,
duration: Option<u64>,
// options: HashMap<String, NAValue<'a>>,
}
-impl<'a> NAPacket<'a> {
- pub fn new(str: Rc<NAStream<'a>>, pts: Option<u64>, dts: Option<u64>, dur: Option<u64>, kf: bool, vec: Vec<u8>) -> Self {
+impl NAPacket {
+ pub fn new(str: Rc<NAStream>, pts: Option<u64>, dts: Option<u64>, dur: Option<u64>, kf: bool, vec: Vec<u8>) -> Self {
// let mut vec: Vec<u8> = Vec::new();
// vec.resize(size, 0);
NAPacket { stream: str, pts: pts, dts: dts, duration: dur, keyframe: kf, buffer: Rc::new(vec) }
}
- pub fn get_stream(&self) -> Rc<NAStream<'a>> { self.stream.clone() }
+ pub fn get_stream(&self) -> Rc<NAStream> { self.stream.clone() }
pub fn get_pts(&self) -> Option<u64> { self.pts }
pub fn get_buffer(&self) -> Rc<Vec<u8>> { self.buffer.clone() }
}
-impl<'a> fmt::Display for NAPacket<'a> {
+impl fmt::Display for NAPacket {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut foo = format!("[pkt for {} size {}", self.stream, self.buffer.len());
if let Some(pts) = self.pts { foo = format!("{} pts {}", foo, pts); }
fn seek(&mut self, time: u64) -> DemuxerResult<()>;
}
-pub trait NAPacketReader<'a> {
- fn read_packet(&mut self, str: Rc<NAStream<'a>>, pts: Option<u64>, dts: Option<u64>, dur: Option<u64>, keyframe: bool, size: usize) -> DemuxerResult<NAPacket>;
+pub trait NAPacketReader {
+ fn read_packet(&mut self, str: Rc<NAStream>, pts: Option<u64>, dts: Option<u64>, dur: Option<u64>, keyframe: bool, size: usize) -> DemuxerResult<NAPacket>;
fn fill_packet(&mut self, pkt: &mut NAPacket) -> DemuxerResult<()>;
}
-impl<'a> NAPacketReader<'a> for ByteReader<'a> {
- fn read_packet(&mut self, str: Rc<NAStream<'a>>, pts: Option<u64>, dts: Option<u64>, dur: Option<u64>, kf: bool, size: usize) -> DemuxerResult<NAPacket> {
+impl<'a> NAPacketReader for ByteReader<'a> {
+ fn read_packet(&mut self, str: Rc<NAStream>, pts: Option<u64>, dts: Option<u64>, dur: Option<u64>, kf: bool, size: usize) -> DemuxerResult<NAPacket> {
let mut buf: Vec<u8> = Vec::with_capacity(size);
if buf.capacity() < size { return Err(DemuxerError::MemoryError); }
buf.resize(size, 0);
use std::collections::HashMap;
+use std::rc::Rc;
#[allow(dead_code)]
+#[derive(Copy,Clone)]
pub struct NASoniton {
bits: u8,
is_be: bool,
pub const SND_S16_FORMAT: NASoniton = NASoniton { bits: 16, is_be: false, packed: false, planar: false, float: false };
#[allow(dead_code)]
+#[derive(Clone,Copy)]
pub struct NAAudioInfo {
sample_rate: u32,
channels: u8,
}
}
-#[derive(Debug)]
+#[derive(Debug,Clone,Copy)]
pub enum ColorModel {
RGB,
YUV,
}
#[allow(dead_code)]
+#[derive(Clone,Copy)]
pub struct NAPixelChromaton {
h_ss: u8,
v_ss: u8,
}
#[allow(dead_code)]
+#[derive(Clone,Copy)]
pub struct NAPixelFormaton {
model: ColorModel,
components: u8,
#[allow(dead_code)]
+#[derive(Clone,Copy)]
pub struct NAVideoInfo {
width: u32,
height: u32,
}
}
+#[derive(Clone,Copy)]
pub enum NACodecTypeInfo {
None,
Audio(NAAudioInfo),
}
#[allow(dead_code)]
-pub struct NACodecInfo<'a> {
+#[derive(Clone)]
+pub struct NACodecInfo {
properties: NACodecTypeInfo,
- extradata: Option<&'a[u8]>,
+ extradata: Option<Rc<Vec<u8>>>,
}
-impl<'a> NACodecInfo<'a> {
- pub fn new(p: NACodecTypeInfo, edata: Option<&'a[u8]>) -> Self {
- NACodecInfo { properties: p, extradata: edata }
+impl NACodecInfo {
+ pub fn new(p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
+ let extradata = match edata {
+ None => None,
+ Some(vec) => Some(Rc::new(vec)),
+ };
+ NACodecInfo { properties: p, extradata: extradata }
+ }
+ pub fn get_properties(&self) -> NACodecTypeInfo { self.properties }
+ pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> {
+ if let Some(ref vec) = self.extradata { return Some(vec.clone()); }
+ None
}
}
dts: Option<u64>,
duration: Option<u64>,
buffer: &'a mut NABuffer<'a>,
- info: &'a NACodecInfo<'a>,
+ info: &'a NACodecInfo,
options: HashMap<String, NAValue<'a>>,
}
#[allow(dead_code)]
pub struct NACodecContext<'a> {
- info: &'a NACodecInfo<'a>,
+ info: &'a NACodecInfo,
}