use nihav_core::demuxers::*;
use nihav_core::muxers::*;
use nihav_registry::detect;
-use nihav_core::io::byteio::ByteReader;
+use nihav_core::io::byteio::ByteIO;
use nihav_allstuff::*;
use crate::null::*;
use crate::imgseq::*;
stream: NAStreamRef,
sm: StreamManager,
packetiser: Box<dyn NAPacketiser + Send>,
- br: &'a mut ByteReader<'a>,
+ br: &'a mut dyn ByteIO,
pts: u64,
}
impl<'a> RawStreamCtx<'a> {
- fn new(stream: NAStreamRef, packetiser: Box<dyn NAPacketiser + Send>, br: &'a mut ByteReader<'a>) -> Self {
+ fn new(stream: NAStreamRef, packetiser: Box<dyn NAPacketiser + Send>, br: &'a mut dyn ByteIO) -> Self {
let mut sm = StreamManager::new();
sm.add_stream_ref(stream.clone());
Self { stream, sm, packetiser, br, pts: 0 }
}
}
-type ReaderBox<'a> = SBBox<Box<dyn ByteIO>, ByteReader<'a>>;
+type ReaderBox = Box<dyn ByteIO>;
pub enum DemuxerObject<'a> {
None,
- Normal(SBBox<ReaderBox<'a>, Demuxer<'a>>),
- Raw(SBBox<ReaderBox<'a>, RawDemuxer<'a>>, Vec<Option<Box<dyn NAPacketiser + Send>>>, bool),
- RawStream(SBBox<ReaderBox<'a>, RawStreamCtx<'a>>),
+ Normal(SBBox<ReaderBox, Demuxer<'a>>),
+ Raw(SBBox<ReaderBox, RawDemuxer<'a>>, Vec<Option<Box<dyn NAPacketiser + Send>>>, bool),
+ RawStream(SBBox<ReaderBox, RawStreamCtx<'a>>),
ImageSequence(ImgSeqDemuxer),
}
impl<'a> DemuxerObject<'a> {
- pub fn create(mut brb: ReaderBox<'a>, reg: &FullRegister, name: &str, ifmt: &Option<String>, is_raw: bool, print_info: bool) -> DemuxerObject<'a> {
- let br = brb.get_object_mut();
+ pub fn create(mut br: ReaderBox, reg: &FullRegister, name: &str, ifmt: &Option<String>, is_raw: bool, print_info: bool) -> DemuxerObject<'a> {
if !is_raw {
let dmx_name = if let Some(ref dname) = ifmt {
dname.as_str()
- } else if let Some((dname, score)) = detect::detect_format(name, br) {
+ } else if let Some((dname, score)) = detect::detect_format(name, &mut *br) {
if print_info {
println!("detected {} with score {:?}", dname, score);
}
if let Some(dmx_fact) = reg.dmx_reg.find_demuxer(dmx_name) {
br.seek(SeekFrom::Start(0)).unwrap();
- let ret = SelfBorrow::try_new(brb, |br_| {
+ let ret = SelfBorrow::try_new(br, |br_| {
unsafe {
- create_demuxer(dmx_fact, br_.as_mut().unwrap().get_object_mut()).ok()
+ create_demuxer(dmx_fact, (*br_).as_mut()).ok()
}
});
if let Some(dmx) = ret {
}
if let Some(rdmx_fact) = reg.rdmx_reg.find_demuxer(dmx_name) {
br.seek(SeekFrom::Start(0)).unwrap();
- let ret = SelfBorrow::try_new(brb, |br_| {
+ let ret = SelfBorrow::try_new(br, |br_| {
unsafe {
- create_raw_demuxer(rdmx_fact, br_.as_mut().unwrap().get_object_mut()).ok()
+ create_raw_demuxer(rdmx_fact, (*br_).as_mut()).ok()
}
});
if let Some(dmx) = ret {
}
}
for rdmx in reg.rdmx_reg.iter() {
- if rdmx.check_format(br) {
+ if rdmx.check_format(&mut *br) {
if print_info {
println!("detected {} as {}", name, rdmx.get_name());
}
br.seek(SeekFrom::Start(0)).unwrap();
- let ret = SelfBorrow::try_new(brb, |br_| {
+ let ret = SelfBorrow::try_new(br, |br_| {
unsafe {
- create_raw_demuxer(*rdmx, br_.as_mut().unwrap().get_object_mut()).ok()
+ create_raw_demuxer(*rdmx, (*br_).as_mut()).ok()
}
});
if let Some(dmx) = ret {
println!("found raw stream of type {} for {}", pname, name);
}
let pcreate = reg.pkt_reg.find_packetiser(pname).unwrap();
- let rctx = SelfBorrow::new(brb, |br_| {
+ let rctx = SelfBorrow::new(br, |br_| {
unsafe {
let mut packetiser = (pcreate)();
packetiser.add_data(&buf[..size]);
let stream = packetiser.parse_stream(0).unwrap();
packetiser.reset();
- RawStreamCtx::new(stream, packetiser, br_.as_mut().unwrap().get_object_mut())
+ RawStreamCtx::new(stream, packetiser, (*br_).as_mut())
}
});
DemuxerObject::RawStream(rctx)
}
}
-pub fn detect_tags(br: &mut ByteReader) -> (bool, u64, Option<u64>) {
+pub fn detect_tags(br: &mut dyn ByteIO) -> (bool, u64, Option<u64>) {
let mut is_raw = false;
let mut start = 0;
let mut end = None;
"--query-demuxer-options" => {
next_arg!(args, arg_idx);
let dname = args[arg_idx].as_str();
- let mut mr = MemoryReader::new_read(&[]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&[]);
if let Some(dmx_creator) = full_reg.dmx_reg.find_demuxer(dname) {
let dmx = dmx_creator.new_demuxer(&mut br);
let opts = dmx.get_supported_options();
next_arg!(args, arg_idx);
let name = args[arg_idx].as_str();
let mut data = [];
- let mut mw = MemoryWriter::new_write(&mut data);
- let mut bw = ByteWriter::new(&mut mw);
+ let mut bw = MemoryWriter::new_write(&mut data);
if let Some(mux_creator) = full_reg.mux_reg.find_muxer(name) {
let mux = mux_creator.new_muxer(&mut bw);
let opts = mux.get_supported_options();
println!("cannot open output file");
return;
}
- let mut fw = FileWriter::new_write(ret.unwrap());
- let mut bw = ByteWriter::new(&mut fw);
+ let mut bw = FileWriter::new_write(ret.unwrap());
let ret = create_muxer(mux_creator, out_sm, &mut bw);
if let Err(err) = ret {
println!("cannot create muxer instance {:?}", err);