aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2022-12-17 11:45:15 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2022-12-17 11:45:15 +0100
commit534a5b60b896020c2113a29436333e4b1ec83334 (patch)
tree0fc930964e80ab3a814d1c605a7e6459a1d910b6
parentde82c8216a0244cc7df9c39bcb392724fc920528 (diff)
downloadnihav-534a5b60b896020c2113a29436333e4b1ec83334.tar.gz
core/demuxer: add functions for creating demuxers with options
-rw-r--r--nihav-core/src/demuxers/mod.rs20
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 {