diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2022-12-17 11:45:15 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2022-12-17 11:45:15 +0100 |
commit | 534a5b60b896020c2113a29436333e4b1ec83334 (patch) | |
tree | 0fc930964e80ab3a814d1c605a7e6459a1d910b6 | |
parent | de82c8216a0244cc7df9c39bcb392724fc920528 (diff) | |
download | nihav-534a5b60b896020c2113a29436333e4b1ec83334.tar.gz |
core/demuxer: add functions for creating demuxers with options
-rw-r--r-- | nihav-core/src/demuxers/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
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<Demuxer<'a>> { + 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<RawDemuxer<'a>> { + 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 { |