From: Kostya Shishkov Date: Sat, 17 Dec 2022 10:45:15 +0000 (+0100) Subject: core/demuxer: add functions for creating demuxers with options X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=534a5b60b896020c2113a29436333e4b1ec83334;p=nihav.git core/demuxer: add functions for creating demuxers with options --- diff --git a/nihav-core/src/demuxers/mod.rs b/nihav-core/src/demuxers/mod.rs index 23f27fb..181f88a 100644 --- a/nihav-core/src/demuxers/mod.rs +++ b/nihav-core/src/demuxers/mod.rs @@ -471,6 +471,16 @@ pub fn create_demuxer<'a>(dmxcr: &dyn DemuxerCreator, br: &'a mut ByteReader<'a> Ok(Demuxer::new(dmx, strmgr, seek_idx)) } +/// Creates demuxer for a provided bytestream with options applied right after its creation. +pub fn create_demuxer_with_options<'a>(dmxcr: &dyn DemuxerCreator, br: &'a mut ByteReader<'a>, opts: &[NAOption]) -> DemuxerResult> { + let mut dmx = dmxcr.new_demuxer(br); + dmx.set_options(opts); + let mut strmgr = StreamManager::new(); + let mut seek_idx = SeekIndex::new(); + dmx.open(&mut strmgr, &mut seek_idx)?; + Ok(Demuxer::new(dmx, strmgr, seek_idx)) +} + /// List of registered demuxers. #[derive(Default)] pub struct RegisteredDemuxers { @@ -637,6 +647,16 @@ pub fn create_raw_demuxer<'a>(dmxcr: &dyn RawDemuxerCreator, br: &'a mut ByteRea Ok(RawDemuxer::new(dmx, strmgr, seek_idx)) } +/// Creates raw data demuxer for a provided bytestream with options applied right after its creation. +pub fn create_raw_demuxer_with_options<'a>(dmxcr: &dyn RawDemuxerCreator, br: &'a mut ByteReader<'a>, opts: &[NAOption]) -> DemuxerResult> { + let mut dmx = dmxcr.new_demuxer(br); + dmx.set_options(opts); + let mut strmgr = StreamManager::new(); + let mut seek_idx = SeekIndex::new(); + dmx.open(&mut strmgr, &mut seek_idx)?; + Ok(RawDemuxer::new(dmx, strmgr, seek_idx)) +} + /// List of registered demuxers. #[derive(Default)] pub struct RegisteredRawDemuxers {