mirror of
https://github.com/encounter/rust-ffmpeg.git
synced 2026-07-10 21:18:39 -07:00
feat(codec/packet, util/frame): expose time_base fields
This commit is contained in:
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user