mirror of
https://github.com/encounter/rust-ffmpeg-zmwangx.git
synced 2026-07-10 21:18:40 -07:00
fix: make sure everything that can be AV_NOPTS_VALUE is an Option<T>
This commit is contained in:
@@ -147,13 +147,16 @@ impl Packet {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn duration(&self) -> i64 {
|
||||
self.0.duration as i64
|
||||
pub fn duration(&self) -> Option<i64> {
|
||||
match self.0.duration as i64 {
|
||||
AV_NOPTS_VALUE => None,
|
||||
value => Some(value),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_duration(&mut self, value: i64) {
|
||||
self.0.duration = value;
|
||||
pub fn set_duration(&mut self, value: Option<i64>) {
|
||||
self.0.duration = value.unwrap_or(AV_NOPTS_VALUE);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -38,9 +38,34 @@ impl Parameters {
|
||||
unsafe { media::Type::from((*self.as_ptr()).codec_type) }
|
||||
}
|
||||
|
||||
pub fn set_medium(&mut self, value: media::Type) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).codec_type = value.into();
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Id {
|
||||
unsafe { Id::from((*self.as_ptr()).codec_id) }
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, value: Id) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).codec_id = value.into();
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
pub fn tag(&self) -> u32 {
|
||||
unsafe { (*self.as_ptr()).codec_tag }
|
||||
}
|
||||
|
||||
pub fn set_tag(&mut self, value: u32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).codec_tag = value;
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Parameters {
|
||||
|
||||
@@ -79,8 +79,13 @@ impl Context {
|
||||
unsafe { (*self.as_ptr()).bit_rate }
|
||||
}
|
||||
|
||||
pub fn duration(&self) -> i64 {
|
||||
unsafe { (*self.as_ptr()).duration }
|
||||
pub fn duration(&self) -> Option<i64> {
|
||||
unsafe {
|
||||
match (*self.as_ptr()).duration {
|
||||
AV_NOPTS_VALUE => None,
|
||||
value => Some(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -54,12 +54,22 @@ impl<'a> Stream<'a> {
|
||||
unsafe { Rational::from((*self.as_ptr()).time_base) }
|
||||
}
|
||||
|
||||
pub fn start_time(&self) -> i64 {
|
||||
unsafe { (*self.as_ptr()).start_time }
|
||||
pub fn start_time(&self) -> Option<i64> {
|
||||
unsafe {
|
||||
match (*self.as_ptr()).start_time {
|
||||
AV_NOPTS_VALUE => None,
|
||||
value => Some(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn duration(&self) -> i64 {
|
||||
unsafe { (*self.as_ptr()).duration }
|
||||
pub fn duration(&self) -> Option<i64> {
|
||||
unsafe {
|
||||
match (*self.as_ptr()).duration {
|
||||
AV_NOPTS_VALUE => None,
|
||||
value => Some(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn frames(&self) -> i64 {
|
||||
|
||||
Reference in New Issue
Block a user