diff --git a/src/codec/context.rs b/src/codec/context.rs index aa91840..50d2e2e 100644 --- a/src/codec/context.rs +++ b/src/codec/context.rs @@ -8,7 +8,7 @@ use super::{threading, Compliance, Debug, Flags, Id, Parameters}; use ffi::*; use libc::c_int; use media; -use {Codec, Error}; +use {Codec, Error, Rational}; pub struct Context { ptr: *mut AVCodecContext, @@ -138,6 +138,31 @@ impl Context { } } } + + pub fn time_base(&self) -> Rational { + unsafe { Rational::from((*self.as_ptr()).time_base) } + } + + pub fn set_time_base>(&mut self, value: R) { + unsafe { + (*self.as_mut_ptr()).time_base = value.into().into(); + } + } + + pub fn frame_rate(&self) -> Rational { + unsafe { Rational::from((*self.as_ptr()).framerate) } + } + + pub fn set_frame_rate>(&mut self, value: Option) { + unsafe { + if let Some(value) = value { + (*self.as_mut_ptr()).framerate = value.into().into(); + } else { + (*self.as_mut_ptr()).framerate.num = 0; + (*self.as_mut_ptr()).framerate.den = 1; + } + } + } } impl Default for Context { diff --git a/src/codec/decoder/decoder.rs b/src/codec/decoder/decoder.rs index 6990ab7..c7f6923 100644 --- a/src/codec/decoder/decoder.rs +++ b/src/codec/decoder/decoder.rs @@ -107,8 +107,14 @@ impl Decoder { } } - pub fn time_base(&self) -> Rational { - unsafe { Rational::from((*self.as_ptr()).time_base) } + pub fn packet_time_base(&self) -> Rational { + unsafe { Rational::from((*self.as_ptr()).pkt_timebase) } + } + + pub fn set_packet_time_base>(&mut self, value: R) { + unsafe { + (*self.as_mut_ptr()).pkt_timebase = value.into().into(); + } } } diff --git a/src/codec/encoder/encoder.rs b/src/codec/encoder/encoder.rs index 3dd507b..ab57202 100644 --- a/src/codec/encoder/encoder.rs +++ b/src/codec/encoder/encoder.rs @@ -116,23 +116,6 @@ impl Encoder { } } } - - pub fn set_time_base>(&mut self, value: R) { - unsafe { - (*self.as_mut_ptr()).time_base = value.into().into(); - } - } - - pub fn set_frame_rate>(&mut self, value: Option) { - unsafe { - if let Some(value) = value { - (*self.as_mut_ptr()).framerate = value.into().into(); - } else { - (*self.as_mut_ptr()).framerate.num = 0; - (*self.as_mut_ptr()).framerate.den = 1; - } - } - } } impl Deref for Encoder {