feat(codec/packet, util/frame): expose time_base fields

This commit is contained in:
tilpner
2023-08-29 16:09:37 +02:00
parent 3d6efeba5e
commit 825e0d4484
2 changed files with 23 additions and 1 deletions
+10
View File
@@ -106,6 +106,16 @@ impl Packet {
self.0.stream_index = index as c_int;
}
#[inline]
pub fn time_base(&self) -> Option<Rational> {
Rational::from(self.0.time_base).non_zero()
}
#[inline]
pub fn set_time_base(&mut self, time_base: Option<impl Into<Rational>>) {
self.0.time_base = time_base.map(Into::into).unwrap_or(Rational::ZERO).into();
}
#[inline]
pub fn pts(&self) -> Option<i64> {
match self.0.pts {
+13 -1
View File
@@ -10,7 +10,7 @@ pub use self::audio::Audio;
pub mod flag;
pub use self::flag::Flags;
use crate::{ffi::*, Dictionary, DictionaryRef, Error};
use crate::{ffi::*, Dictionary, DictionaryRef, Error, Rational};
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct Packet {
@@ -102,6 +102,18 @@ impl Frame {
}
}
#[inline]
pub fn time_base(&self) -> Option<Rational> {
unsafe { Rational::from((*self.as_ptr()).time_base).non_zero() }
}
#[inline]
pub fn set_time_base(&mut self, time_base: Option<impl Into<Rational>>) {
unsafe {
(*self.as_mut_ptr()).time_base = time_base.map(Into::into).unwrap_or(Rational::ZERO).into();
}
}
#[inline]
pub fn pts(&self) -> Option<i64> {
unsafe {