From a48233cbfedaf42fef6254c6bcc073c1ea4cfee8 Mon Sep 17 00:00:00 2001 From: lummax Date: Mon, 24 Aug 2015 22:50:48 +0200 Subject: [PATCH] format/context: add `new_stream()` method --- src/format/context.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/format/context.rs b/src/format/context.rs index 9559918..ea249bf 100644 --- a/src/format/context.rs +++ b/src/format/context.rs @@ -92,6 +92,19 @@ impl Context { } } + pub fn new_stream(&mut self, codec: &Codec) -> Option { + unsafe { + let ptr = avformat_new_stream(self.as_mut_ptr(), codec.as_ptr()); + + if ptr.is_null() { + None + } + else { + Some(StreamMut::wrap(ptr)) + } + } + } + pub fn metadata(&self) -> Dictionary { unsafe { Dictionary::wrap((*self.as_ptr()).metadata)