format: add _with()
variants to open()
This commit is contained in:
parent
316778ccd9
commit
bde17a8bae
@ -195,6 +195,29 @@ pub fn output<P: AsRef<Path>>(path: &P) -> Result<context::Output, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn output_with<P: AsRef<Path>>(path: &P, options: Dictionary) -> Result<context::Output, Error> {
|
||||
unsafe {
|
||||
let mut ps = ptr::null_mut();
|
||||
let path = from_path(path);
|
||||
let mut opts = options.disown();
|
||||
|
||||
match avformat_alloc_output_context2(&mut ps, ptr::null_mut(), ptr::null(), path.as_ptr()) {
|
||||
0 => {
|
||||
let res = avio_open2(&mut (*ps).pb, path.as_ptr(), AVIO_FLAG_WRITE, ptr::null(), &mut opts,);
|
||||
|
||||
Dictionary::own(opts);
|
||||
|
||||
match res {
|
||||
0 => Ok(context::Output::wrap(ps)),
|
||||
e => Err(Error::from(e))
|
||||
}
|
||||
}
|
||||
|
||||
e => Err(Error::from(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn output_as<P: AsRef<Path>>(path: &P, format: &str) -> Result<context::Output, Error> {
|
||||
unsafe {
|
||||
let mut ps = ptr::null_mut();
|
||||
@ -213,3 +236,27 @@ pub fn output_as<P: AsRef<Path>>(path: &P, format: &str) -> Result<context::Outp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn output_as_with<P: AsRef<Path>>(path: &P, format: &str, options: Dictionary) -> Result<context::Output, Error> {
|
||||
unsafe {
|
||||
let mut ps = ptr::null_mut();
|
||||
let path = from_path(path);
|
||||
let format = CString::new(format).unwrap();
|
||||
let mut opts = options.disown();
|
||||
|
||||
match avformat_alloc_output_context2(&mut ps, ptr::null_mut(), format.as_ptr(), path.as_ptr()) {
|
||||
0 => {
|
||||
let res = avio_open2(&mut (*ps).pb, path.as_ptr(), AVIO_FLAG_WRITE, ptr::null(), &mut opts,);
|
||||
|
||||
Dictionary::own(opts);
|
||||
|
||||
match res {
|
||||
0 => Ok(context::Output::wrap(ps)),
|
||||
e => Err(Error::from(e))
|
||||
}
|
||||
}
|
||||
|
||||
e => Err(Error::from(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user