From ba026e24e2eff821e518b195bc01b8a5095afb8b Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Mon, 19 Aug 2024 23:00:04 +0530 Subject: [PATCH] fix: issue with ts_forced_program default value --- src/rust/lib_ccxr/src/common/options.rs | 22 ++++++++++++++++++++-- src/rust/src/common.rs | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/rust/lib_ccxr/src/common/options.rs b/src/rust/lib_ccxr/src/common/options.rs index 330f692d6..dabe0019c 100644 --- a/src/rust/lib_ccxr/src/common/options.rs +++ b/src/rust/lib_ccxr/src/common/options.rs @@ -157,7 +157,7 @@ pub enum DtvccServiceCharset { } #[allow(dead_code)] -#[derive(Default, Debug, Clone)] +#[derive(Debug, Clone)] pub struct DemuxerConfig { /// Regular TS or M2TS pub m2ts: bool, @@ -175,13 +175,31 @@ pub struct DemuxerConfig { /// If 1, never mess with the selected PID pub ts_forced_cappid: bool, /// Specific program to process in TS files, if a forced program is given - pub ts_forced_program: Option, + pub ts_forced_program: Option, /// User WANTED stream type (i.e. use the stream that has this type) pub ts_datastreamtype: StreamType, /// User selected (forced) stream type pub ts_forced_streamtype: StreamType, } +impl Default for DemuxerConfig { + fn default() -> Self { + Self { + m2ts: false, + auto_stream: StreamMode::default(), + codec: SelectCodec::Some(super::Codec::Any), + nocodec: SelectCodec::None, + ts_autoprogram: false, + ts_allprogram: false, + ts_cappids: Vec::new(), + ts_forced_cappid: false, + ts_forced_program: None, + ts_datastreamtype: StreamType::default(), + ts_forced_streamtype: StreamType::default(), + } + } +} + impl Default for EncoderConfig { fn default() -> Self { Self { diff --git a/src/rust/src/common.rs b/src/rust/src/common.rs index 608761696..adbc6b481 100644 --- a/src/rust/src/common.rs +++ b/src/rust/src/common.rs @@ -486,7 +486,7 @@ impl CType for DemuxerConfig { ts_cappids: self.ts_cappids.to_ctype(), nb_ts_cappid: self.ts_cappids.len() as _, ts_forced_cappid: self.ts_forced_cappid as _, - ts_forced_program: self.ts_forced_program.unwrap_or_default() as _, + ts_forced_program: self.ts_forced_program.unwrap_or(-1) as _, ts_forced_program_selected: self.ts_forced_program.is_some() as _, ts_datastreamtype: self.ts_datastreamtype.to_ctype() as _, ts_forced_streamtype: self.ts_forced_streamtype.to_ctype() as _,