diff --git a/src/codec/context.rs b/src/codec/context.rs index 41dcae7..58448b3 100644 --- a/src/codec/context.rs +++ b/src/codec/context.rs @@ -125,13 +125,13 @@ impl Context { Parameters::from(self) } - pub fn time_base(&self) -> Rational { - unsafe { Rational::from((*self.as_ptr()).time_base) } + pub fn time_base(&self) -> Option { + unsafe { Rational::from((*self.as_ptr()).time_base).non_zero() } } - pub fn set_time_base>(&mut self, value: R) { + pub fn set_time_base>(&mut self, value: Option) { unsafe { - (*self.as_mut_ptr()).time_base = value.into().into(); + (*self.as_mut_ptr()).time_base = value.map(Into::into).unwrap_or(Rational::ZERO).into(); } } diff --git a/src/format/chapter/chapter.rs b/src/format/chapter/chapter.rs index d5f7d56..00f19cd 100644 --- a/src/format/chapter/chapter.rs +++ b/src/format/chapter/chapter.rs @@ -26,8 +26,8 @@ impl<'a> Chapter<'a> { unsafe { (*self.as_ptr()).id } } - pub fn time_base(&self) -> Rational { - unsafe { Rational::from((*self.as_ptr()).time_base) } + pub fn time_base(&self) -> Option { + unsafe { Rational::from((*self.as_ptr()).time_base).non_zero() } } pub fn start(&self) -> i64 { diff --git a/src/format/stream/stream.rs b/src/format/stream/stream.rs index 60bbd5f..b4f9114 100644 --- a/src/format/stream/stream.rs +++ b/src/format/stream/stream.rs @@ -53,8 +53,8 @@ impl<'a> Stream<'a> { unsafe { (*self.as_ptr()).index as usize } } - pub fn time_base(&self) -> Rational { - unsafe { Rational::from((*self.as_ptr()).time_base) } + pub fn time_base(&self) -> Option { + unsafe { Rational::from((*self.as_ptr()).time_base).non_zero() } } pub fn start_time(&self) -> Option { diff --git a/src/format/stream/stream_mut.rs b/src/format/stream/stream_mut.rs index 077cf64..902df39 100644 --- a/src/format/stream/stream_mut.rs +++ b/src/format/stream/stream_mut.rs @@ -26,9 +26,9 @@ impl<'a> StreamMut<'a> { } impl<'a> StreamMut<'a> { - pub fn set_time_base>(&mut self, value: R) { + pub fn set_time_base>(&mut self, value: Option) { unsafe { - (*self.as_mut_ptr()).time_base = value.into().into(); + (*self.as_mut_ptr()).time_base = value.map(Into::into).unwrap_or(Rational::ZERO).into(); } }