codec/encoder/video: add open_with() constructor

This commit is contained in:
meh 2015-10-26 20:26:21 +01:00
parent 7626f722aa
commit 6bb6a806ed

View File

@ -37,6 +37,21 @@ impl Video {
} }
} }
#[inline]
pub fn open_with(mut self, options: Dictionary) -> Result<Encoder, Error> {
unsafe {
let mut opts = options.disown();
let res = avcodec_open2(self.as_mut_ptr(), ptr::null(), &mut opts);
Dictionary::own(opts);
match res {
0 => Ok(Encoder(self)),
e => Err(Error::from(e))
}
}
}
#[inline] #[inline]
pub fn open_as_with<E: traits::Encoder>(mut self, codec: E, options: Dictionary) -> Result<Encoder, Error> { pub fn open_as_with<E: traits::Encoder>(mut self, codec: E, options: Dictionary) -> Result<Encoder, Error> {
unsafe { unsafe {