Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/codec/decoder/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ impl Decoder {
}
}

pub fn open_with(mut self, options: Dictionary) -> Result<Opened, 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(Opened(self)),
e => Err(Error::from(e)),
}
}
}

pub fn open_as_with<D: traits::Decoder>(
mut self,
codec: D,
Expand Down
14 changes: 14 additions & 0 deletions src/codec/encoder/subtitle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ impl Subtitle {
}
}

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)),
}
}
}

pub fn open_as_with<E: traits::Encoder>(
mut self,
codec: E,
Expand Down