From a082998e48a3b7ad4efd6ab7cac1682c4c842483 Mon Sep 17 00:00:00 2001 From: lummax Date: Wed, 26 Aug 2015 10:11:50 +0200 Subject: [PATCH] format/context: add `write_header{_with}()` methods --- src/format/context.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/format/context.rs b/src/format/context.rs index ea249bf..b9ca0e2 100644 --- a/src/format/context.rs +++ b/src/format/context.rs @@ -58,6 +58,29 @@ impl Context { !self._input } + pub fn write_header(&mut self) -> Result<(), Error> { + unsafe { + match avformat_write_header(self.as_mut_ptr(), ptr::null_mut()) { + 0 => Ok(()), + e => Err(Error::from(e)), + } + } + } + + pub fn write_header_with(&mut self, options: Dictionary) -> Result<(), Error> { + unsafe { + let mut opts = options.take(); + let status = avformat_write_header(self.as_mut_ptr(), &mut opts); + + Dictionary::own(opts); + + match status { + 0 => Ok(()), + e => Err(Error::from(e)), + } + } + } + pub fn stream(&self, index: usize) -> Option { unsafe { if index >= (*self.as_ptr()).nb_streams as usize {