let profile;
let mut nal_buf = Vec::with_capacity(1024);
if edata.len() > 11 && &edata[0..4] == b"avcC" {
- let mut mr = MemoryReader::new_read(edata.as_slice());
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(edata.as_slice());
br.read_skip(4)?;
let version = br.read_byte()?;
self.tb_num = pkt.ts.tb_num;
self.tb_den = pkt.ts.tb_den;
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let mut frame_type = FrameType::I;
let mut nal_buf = Vec::with_capacity(1024);
while br.left() > 0 {
fn decode_h264(name: &str, dname: &str, dmx_reg: &RegisteredDemuxers, opfx: &str) -> DecoderResult<()> {
let dmx_f = dmx_reg.find_demuxer(dname).expect("demuxer exists");
let file = std::fs::File::open(name).expect("file exists");
- let mut fr = FileReader::new_read(file);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(file);
let mut dmx = create_demuxer(dmx_f, &mut br).expect("create demuxer");
let mut vstream_id = 0;
use nihav_core::codecs::*;
use nihav_core::demuxers::*;
use nihav_registry::detect;
-use nihav_core::io::byteio::ByteReader;
+use nihav_core::io::byteio::ByteIO;
use super::allreg::FullRegister;
pub struct RawStreamCtx<'a> {
stream: NAStreamRef,
pkt: Box<dyn NAPacketiser + Send>,
- br: &'a mut ByteReader<'a>,
+ br: &'a mut dyn ByteIO,
pts: u64,
seek: SeekIndex,
}
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 seek = SeekIndex::new();
seek.add_stream(0);
Self { stream, pkt: packetiser, br, pts: 0, seek }
}
impl<'a> DemuxerObject<'a> {
- pub fn create(br: &'a mut ByteReader<'a>, reg: &FullRegister, name: &str, is_raw: bool) -> DemuxerObject<'a> {
+ pub fn create(br: &'a mut dyn ByteIO, reg: &FullRegister, name: &str, is_raw: bool) -> DemuxerObject<'a> {
if !is_raw {
let res = detect::detect_format(name, br);
let (dmx_name, _) = res.unwrap_or(("", detect::DetectionScore::No));
}
}
-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;
use std::time::Duration;
use std::thread;
use sdl2_sys::{SDL_AudioSpec, Uint32};
-use nihav_core::io::byteio::{FileReader, ByteReader};
+use nihav_core::io::byteio::{ByteIO,FileReader};
use nihav_core::frame::*;
use nihav_core::codecs::*;
use nihav_core::demuxers::*;
let file = BufReader::new(file);
let mut fr = FileReader::new_read(file);
- let mut br = ByteReader::new(&mut fr);
- if br.peek_byte().is_err() {
+ if fr.peek_byte().is_err() {
println!("Cannot read {}", name);
return;
}
- let (is_raw, start, end) = detect_tags(&mut br);
+ let (is_raw, start, end) = detect_tags(&mut fr);
- let mut nfr: Box<dyn ByteIO>;
+ let mut br: Box<dyn ByteIO>;
if start != 0 || end.is_some() {
//println!(" limiting range to {:X}-{:X}", start, end.unwrap_or(0));
let file = fr.finish();
- nfr = Box::new(BoundedFileReader::new_read(file, start, end).unwrap());
+ br = Box::new(BoundedFileReader::new_read(file, start, end).unwrap());
} else {
- nfr = Box::new(fr);
+ br = Box::new(fr);
}
- let mut br = ByteReader::new(nfr.as_mut());
- let dmx = DemuxerObject::create(&mut br, &self.full_reg, name, is_raw);
+ let dmx = DemuxerObject::create(br.as_mut(), &self.full_reg, name, is_raw);
if dmx.is_none() {
println!("No demuxer found!");
return;
use nihav_registry::detect;
use nihav_core::frame::*;
-use nihav_core::io::byteio::{FileReader, ByteReader};
+use nihav_core::io::byteio::{ByteIO,FileReader};
use nihav_core::reorder::*;
use nihav_core::codecs::*;
use nihav_core::demuxers::*;
println!("failed to open {}", name);
return window;
};
- let mut fr = FileReader::new_read(&mut file);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let res = detect::detect_format(name, &mut br);
if res.is_none() {
println!("cannot detect format for {}", name);