From 056293a24427c19ba2970512398cccbddcce051e Mon Sep 17 00:00:00 2001 From: lummax Date: Wed, 9 Sep 2015 19:19:45 +0200 Subject: [PATCH] filter/graph: add `dump()` method --- src/filter/graph.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/filter/graph.rs b/src/filter/graph.rs index 8005843..cf754c9 100644 --- a/src/filter/graph.rs +++ b/src/filter/graph.rs @@ -1,5 +1,6 @@ use std::ptr; -use std::ffi::CString; +use std::ffi::{CString, CStr}; +use std::str::from_utf8_unchecked; use ffi::*; use libc::c_int; @@ -76,6 +77,18 @@ impl Graph { } } + pub fn dump(&self) -> String { + unsafe { + let ptr = avfilter_graph_dump(self.as_ptr(), ptr::null()); + let cstr = from_utf8_unchecked(CStr::from_ptr((ptr)).to_bytes()); + let string = cstr.to_owned(); + + av_free(ptr as *mut _); + + string + } + } + pub fn input(&mut self, name: &str, pad: usize) -> Result { Parser::new(self).input(name, pad) }