From a5499802ab83cd42f016dc5453680b88a5e83bfb Mon Sep 17 00:00:00 2001 From: Raniz Date: Tue, 19 Nov 2019 07:26:29 +0100 Subject: [PATCH] Add method for adding VODs to VLM --- src/core.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/core.rs b/src/core.rs index b04f096..ef8c141 100644 --- a/src/core.rs +++ b/src/core.rs @@ -105,6 +105,31 @@ impl Instance { else { Err(()) } } + pub fn add_vod(&self, name: &str, input: &str, mux: &str, options: Option>, enabled: bool) -> Result<(), ()> { + let name= to_cstr(name); + let input = to_cstr(input); + let mux = to_cstr(mux); + let opts_c_ptr: Vec<*const c_char> ; + let opts_c: Vec; + let enabled = if enabled { 1 } else { 0 }; + if let Some(vec) = options { + opts_c = vec.into_iter() + .map(|x| CString::new(x).expect("Error: Unexpected null byte")).collect(); + opts_c_ptr = opts_c.iter().map(|x| x.as_ptr()).collect(); + } else { + opts_c_ptr = Vec::new(); + } + let result = unsafe { + if opts_c_ptr.is_empty() { + sys::libvlc_vlm_add_vod(self.ptr, name.as_ptr(), input.as_ptr(), 0, ptr::null(), enabled, mux.as_ptr()) + } else { + sys::libvlc_vlm_add_vod(self.ptr, name.as_ptr(), input.as_ptr(), opts_c_ptr.len() as i32, opts_c_ptr.as_ptr(), enabled, mux.as_ptr()) + } + }; + if result == 0 { Ok(()) } + else { Err(()) } + } + pub fn play_media(&self, name: &str) -> Result<(), ()> { let name = to_cstr(name); let result = unsafe {