Merge branch '4-clippy_fmt' into 'master'
Draft: Resolve "Fix clippy warnings" Closes #4 See merge request videolan/vlc-rs!7merge-requests/7/merge
						commit
						42c20da5df
					
				| 
						 | 
					@ -12,4 +12,5 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Generated by Cargo
 | 
					# Generated by Cargo
 | 
				
			||||||
/target/
 | 
					/target/
 | 
				
			||||||
 | 
					/libvlc-sys/target
 | 
				
			||||||
Cargo.lock
 | 
					Cargo.lock
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,9 @@ version = "0.3.0"
 | 
				
			||||||
authors = ["T. Okubo <t.okubo.rx78+github@gmail.com>"]
 | 
					authors = ["T. Okubo <t.okubo.rx78+github@gmail.com>"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
description = "Rust bindings for libVLC media framework."
 | 
					description = "Rust bindings for libVLC media framework."
 | 
				
			||||||
keywords = ["libVLC", "bindings"]
 | 
					keywords = ["libVLC", "bindings", "multimedia"]
 | 
				
			||||||
 | 
					categories = ["external-ffi-bindings", "multimedia"]
 | 
				
			||||||
 | 
					documentation = "https://docs.rs/vlc-rs"
 | 
				
			||||||
repository = "https://code.videolan.org/videolan/vlc-rs"
 | 
					repository = "https://code.videolan.org/videolan/vlc-rs"
 | 
				
			||||||
homepage = "https://code.videolan.org/videolan/vlc-rs"
 | 
					homepage = "https://code.videolan.org/videolan/vlc-rs"
 | 
				
			||||||
license = "MIT"
 | 
					license = "MIT"
 | 
				
			||||||
| 
						 | 
					@ -17,6 +19,7 @@ crate-type = ["rlib"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dependencies]
 | 
					[dependencies]
 | 
				
			||||||
libc = "0.2"
 | 
					libc = "0.2"
 | 
				
			||||||
 | 
					libvlc-sys = "0.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[target.'cfg(target_os = "windows")'.build-dependencies]
 | 
					[target.'cfg(target_os = "windows")'.build-dependencies]
 | 
				
			||||||
vswhom = "0.1.0"
 | 
					vswhom = "0.1.0"
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,3 @@
 | 
				
			||||||
 | 
					 | 
				
			||||||
// This file is an example for vlc-rs, licensed under CC0.
 | 
					// This file is an example for vlc-rs, licensed under CC0.
 | 
				
			||||||
// https://creativecommons.org/publicdomain/zero/1.0/deed
 | 
					// https://creativecommons.org/publicdomain/zero/1.0/deed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +5,7 @@ extern crate vlc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use std::sync::mpsc::channel;
 | 
					use std::sync::mpsc::channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use vlc::{Instance, Media, MediaPlayer, Event, EventType, State};
 | 
					use vlc::{Event, EventType, Instance, Media, MediaPlayer, State};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn main() {
 | 
					fn main() {
 | 
				
			||||||
    let args: Vec<String> = std::env::args().collect();
 | 
					    let args: Vec<String> = std::env::args().collect();
 | 
				
			||||||
| 
						 | 
					@ -26,16 +25,14 @@ fn main() {
 | 
				
			||||||
    let (tx, rx) = channel::<()>();
 | 
					    let (tx, rx) = channel::<()>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let em = md.event_manager();
 | 
					    let em = md.event_manager();
 | 
				
			||||||
    let _ = em.attach(EventType::MediaStateChanged, move |e, _| {
 | 
					    let _ = em.attach(EventType::MediaStateChanged, move |e, _| match e {
 | 
				
			||||||
        match e {
 | 
					 | 
				
			||||||
        Event::MediaStateChanged(s) => {
 | 
					        Event::MediaStateChanged(s) => {
 | 
				
			||||||
            println!("State : {:?}", s);
 | 
					            println!("State : {:?}", s);
 | 
				
			||||||
            if s == State::Ended || s == State::Error {
 | 
					            if s == State::Ended || s == State::Error {
 | 
				
			||||||
                tx.send(()).unwrap();
 | 
					                tx.send(()).unwrap();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            _ => (),
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        _ => (),
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mdp.set_media(&md);
 | 
					    mdp.set_media(&md);
 | 
				
			||||||
| 
						 | 
					@ -46,5 +43,3 @@ fn main() {
 | 
				
			||||||
    // Wait for end state
 | 
					    // Wait for end state
 | 
				
			||||||
    rx.recv().unwrap();
 | 
					    rx.recv().unwrap();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,3 @@
 | 
				
			||||||
 | 
					 | 
				
			||||||
// This file is an example for vlc-rs, licensed under CC0.
 | 
					// This file is an example for vlc-rs, licensed under CC0.
 | 
				
			||||||
// https://creativecommons.org/publicdomain/zero/1.0/deed
 | 
					// https://creativecommons.org/publicdomain/zero/1.0/deed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					[package]
 | 
				
			||||||
 | 
					name = "libvlc-sys"
 | 
				
			||||||
 | 
					version = "0.2.0"
 | 
				
			||||||
 | 
					authors = ["T. Okubo <t.okubo.rx78+devel@gmail.com>"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					description = "libVLC C API"
 | 
				
			||||||
 | 
					keywords = ["libVLC", "bindings"]
 | 
				
			||||||
 | 
					categories = ["external-ffi-bindings", "multimedia"]
 | 
				
			||||||
 | 
					documentation = "https://docs.rs/vlc-rs"
 | 
				
			||||||
 | 
					repository = "https://code.videolan.org/videolan/vlc-rs"
 | 
				
			||||||
 | 
					homepage = "https://code.videolan.org/videolan/vlc-rs"
 | 
				
			||||||
 | 
					license = "MIT"
 | 
				
			||||||
 | 
					edition = "2018"
 | 
				
			||||||
 | 
					build = "build.rs"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[lib]
 | 
				
			||||||
 | 
					name = "vlc_sys"
 | 
				
			||||||
 | 
					crate-type = ["rlib"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[dependencies]
 | 
				
			||||||
 | 
					libc = "0.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[build-dependencies]
 | 
				
			||||||
 | 
					bindgen = "0.59"
 | 
				
			||||||
 | 
					pkg-config = "0.3"
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					use bindgen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use std::env;
 | 
				
			||||||
 | 
					use std::path::PathBuf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn main() {
 | 
				
			||||||
 | 
					    println!("cargo:rerun-if-changed=wrapper.h");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let mut bindings = bindgen::Builder::default()
 | 
				
			||||||
 | 
					        .header("wrapper.h")
 | 
				
			||||||
 | 
					        // For no_std
 | 
				
			||||||
 | 
					        .use_core()
 | 
				
			||||||
 | 
					        // Use libc
 | 
				
			||||||
 | 
					        .ctypes_prefix("libc")
 | 
				
			||||||
 | 
					        // Whitelist
 | 
				
			||||||
 | 
					        .whitelist_type(".*vlc.*")
 | 
				
			||||||
 | 
					        .whitelist_function(".*vlc.*")
 | 
				
			||||||
 | 
					        .whitelist_var(".*vlc.*")
 | 
				
			||||||
 | 
					        .whitelist_function("vsnprintf")
 | 
				
			||||||
 | 
					        .parse_callbacks(Box::new(bindgen::CargoCallbacks));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Set header include paths
 | 
				
			||||||
 | 
					    let pkg_config_library = pkg_config::Config::new().probe("libvlc").unwrap();
 | 
				
			||||||
 | 
					    for include_path in &pkg_config_library.include_paths {
 | 
				
			||||||
 | 
					        bindings = bindings.clang_arg(format!("-I{}", include_path.display()));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let bindings = bindings.generate().expect("Unable to generate bindings");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
 | 
				
			||||||
 | 
					    bindings
 | 
				
			||||||
 | 
					        .write_to_file(out_path.join("bindings.rs"))
 | 
				
			||||||
 | 
					        .expect("Couldn't write bindings!");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,6 @@
 | 
				
			||||||
 | 
					#![allow(non_upper_case_globals)]
 | 
				
			||||||
 | 
					#![allow(non_camel_case_types)]
 | 
				
			||||||
 | 
					#![allow(non_snake_case)]
 | 
				
			||||||
 | 
					#![no_std]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					#include <vlc/vlc.h>
 | 
				
			||||||
							
								
								
									
										26
									
								
								src/audio.rs
								
								
								
								
							
							
						
						
									
										26
									
								
								src/audio.rs
								
								
								
								
							| 
						 | 
					@ -2,16 +2,17 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::sys;
 | 
					use crate::tools::from_cstr;
 | 
				
			||||||
 | 
					use crate::InternalError;
 | 
				
			||||||
use crate::MediaPlayer;
 | 
					use crate::MediaPlayer;
 | 
				
			||||||
use crate::TrackDescription;
 | 
					use crate::TrackDescription;
 | 
				
			||||||
use crate::tools::from_cstr;
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub trait MediaPlayerAudioEx {
 | 
					pub trait MediaPlayerAudioEx {
 | 
				
			||||||
    fn get_mute(&self) -> Option<bool>;
 | 
					    fn get_mute(&self) -> Option<bool>;
 | 
				
			||||||
    fn set_mute(&self, muted: bool);
 | 
					    fn set_mute(&self, muted: bool);
 | 
				
			||||||
    fn get_volume(&self) -> i32;
 | 
					    fn get_volume(&self) -> i32;
 | 
				
			||||||
    fn set_volume(&self, volume: i32) -> Result<(), ()>;
 | 
					    fn set_volume(&self, volume: i32) -> Result<(), InternalError>;
 | 
				
			||||||
    fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>>;
 | 
					    fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,25 +36,34 @@ impl MediaPlayerAudioEx for MediaPlayer {
 | 
				
			||||||
    fn get_volume(&self) -> i32 {
 | 
					    fn get_volume(&self) -> i32 {
 | 
				
			||||||
        unsafe { sys::libvlc_audio_get_volume(self.ptr) }
 | 
					        unsafe { sys::libvlc_audio_get_volume(self.ptr) }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_volume(&self, volume: i32) -> Result<(), ()> {
 | 
					    fn set_volume(&self, volume: i32) -> Result<(), InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            if sys::libvlc_audio_set_volume(self.ptr, volume) == 0 { Ok(()) }else{ Err(()) }
 | 
					            if sys::libvlc_audio_set_volume(self.ptr, volume) == 0 {
 | 
				
			||||||
 | 
					                Ok(())
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Err(InternalError)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>> {
 | 
					    fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p0 = sys::libvlc_audio_get_track_description(self.ptr);
 | 
					            let p0 = sys::libvlc_audio_get_track_description(self.ptr);
 | 
				
			||||||
            if p0.is_null() { return None; }
 | 
					            if p0.is_null() {
 | 
				
			||||||
 | 
					                return None;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            let mut td = Vec::new();
 | 
					            let mut td = Vec::new();
 | 
				
			||||||
            let mut p = p0;
 | 
					            let mut p = p0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            while !(*p).p_next.is_null() {
 | 
					            while !(*p).p_next.is_null() {
 | 
				
			||||||
                td.push(TrackDescription{ id: (*p).i_id, name: from_cstr((*p).psz_name) });
 | 
					                td.push(TrackDescription {
 | 
				
			||||||
 | 
					                    id: (*p).i_id,
 | 
				
			||||||
 | 
					                    name: from_cstr((*p).psz_name),
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
                p = (*p).p_next;
 | 
					                p = (*p).p_next;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            sys::libvlc_track_description_list_release(p0);
 | 
					            sys::libvlc_track_description_list_release(p0);
 | 
				
			||||||
            Some(td)
 | 
					            Some(td)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										431
									
								
								src/core.rs
								
								
								
								
							
							
						
						
									
										431
									
								
								src/core.rs
								
								
								
								
							| 
						 | 
					@ -2,33 +2,49 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use std::ptr;
 | 
					 | 
				
			||||||
use std::borrow::Cow;
 | 
					 | 
				
			||||||
use std::marker::PhantomData;
 | 
					 | 
				
			||||||
use std::ffi::{CString, CStr};
 | 
					 | 
				
			||||||
use std::i32;
 | 
					 | 
				
			||||||
use libc::{c_void, c_char, c_int};
 | 
					 | 
				
			||||||
use crate::sys;
 | 
					 | 
				
			||||||
use crate::tools::{to_cstr, from_cstr, from_cstr_ref};
 | 
					 | 
				
			||||||
use crate::enums::*;
 | 
					use crate::enums::*;
 | 
				
			||||||
 | 
					use crate::tools::{from_cstr, from_cstr_ref, to_cstr};
 | 
				
			||||||
 | 
					use libc::{c_char, c_int, c_void};
 | 
				
			||||||
 | 
					use std::borrow::Cow;
 | 
				
			||||||
 | 
					use std::convert::TryInto;
 | 
				
			||||||
 | 
					use std::ffi::CString;
 | 
				
			||||||
 | 
					use std::fmt;
 | 
				
			||||||
 | 
					use std::i32;
 | 
				
			||||||
 | 
					use std::marker::PhantomData;
 | 
				
			||||||
 | 
					use std::ptr;
 | 
				
			||||||
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[derive(Debug)]
 | 
				
			||||||
 | 
					pub struct InternalError;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl fmt::Display for InternalError {
 | 
				
			||||||
 | 
					    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 | 
				
			||||||
 | 
					        write!(f, "libvlc internal error")
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl std::error::Error for InternalError {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Retrieve libvlc version.
 | 
					/// Retrieve libvlc version.
 | 
				
			||||||
pub fn version() -> String {
 | 
					pub fn version() -> String {
 | 
				
			||||||
    unsafe {
 | 
					    unsafe {
 | 
				
			||||||
        from_cstr_ref(sys::libvlc_get_version()).unwrap().into_owned()
 | 
					        from_cstr_ref(sys::libvlc_get_version())
 | 
				
			||||||
 | 
					            .unwrap()
 | 
				
			||||||
 | 
					            .into_owned()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Retrieve libvlc compiler version.
 | 
					/// Retrieve libvlc compiler version.
 | 
				
			||||||
pub fn compiler() -> String {
 | 
					pub fn compiler() -> String {
 | 
				
			||||||
    unsafe {
 | 
					    unsafe {
 | 
				
			||||||
        from_cstr_ref(sys::libvlc_get_compiler()).unwrap().into_owned()
 | 
					        from_cstr_ref(sys::libvlc_get_compiler())
 | 
				
			||||||
 | 
					            .unwrap()
 | 
				
			||||||
 | 
					            .into_owned()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct Instance {
 | 
					pub struct Instance {
 | 
				
			||||||
    pub(crate) ptr: *mut sys::libvlc_instance_t,
 | 
					    pub(crate) ptr: *mut sys::libvlc_instance_t,
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsafe impl Send for Instance {}
 | 
					unsafe impl Send for Instance {}
 | 
				
			||||||
| 
						 | 
					@ -37,18 +53,19 @@ impl Instance {
 | 
				
			||||||
    /// Create and initialize a libvlc instance with specified args.
 | 
					    /// Create and initialize a libvlc instance with specified args.
 | 
				
			||||||
    /// Note: args.len() has to be less or equal to i32::MAX
 | 
					    /// Note: args.len() has to be less or equal to i32::MAX
 | 
				
			||||||
    /// Note: libvlc discourages using arguments as these are not guaranteed to be stable between different versions of libvlc
 | 
					    /// Note: libvlc discourages using arguments as these are not guaranteed to be stable between different versions of libvlc
 | 
				
			||||||
    pub fn with_args(args: Option<Vec<String>>) -> Option<Instance> {
 | 
					    pub fn with_args(args: Option<Vec<String>>) -> Result<Instance, InternalError> {
 | 
				
			||||||
        let args_c_ptr: Vec<*const c_char>;
 | 
					        let args_c_ptr: Vec<*const c_char>;
 | 
				
			||||||
        let args_c: Vec<CString>;
 | 
					        let args_c: Vec<CString>;
 | 
				
			||||||
        if let Some(argv) = args {
 | 
					        if let Some(argv) = args {
 | 
				
			||||||
            args_c = argv.into_iter()
 | 
					            args_c = argv
 | 
				
			||||||
                .map(|x| CString::new(x).expect("Error: Unexpected null byte")).collect();
 | 
					                .into_iter()
 | 
				
			||||||
 | 
					                .map(|x| CString::new(x).expect("Error: Unexpected null byte"))
 | 
				
			||||||
 | 
					                .collect();
 | 
				
			||||||
            args_c_ptr = args_c.iter().map(|x| x.as_ptr()).collect();
 | 
					            args_c_ptr = args_c.iter().map(|x| x.as_ptr()).collect();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            args_c_ptr = Vec::new();
 | 
					            args_c_ptr = Vec::new();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = if args_c_ptr.is_empty() {
 | 
					            let p = if args_c_ptr.is_empty() {
 | 
				
			||||||
                sys::libvlc_new(0, ptr::null())
 | 
					                sys::libvlc_new(0, ptr::null())
 | 
				
			||||||
| 
						 | 
					@ -57,36 +74,36 @@ impl Instance {
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if p.is_null() {
 | 
					            if p.is_null() {
 | 
				
			||||||
                return None;
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Ok(Instance { ptr: p })
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					 | 
				
			||||||
            Some(Instance{ptr: p})
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Create and initialize a libvlc instance.
 | 
					    /// Create and initialize a libvlc instance.
 | 
				
			||||||
    pub fn new() -> Option<Instance> {
 | 
					    pub fn new() -> Result<Instance, InternalError> {
 | 
				
			||||||
        Instance::with_args(None)
 | 
					        Instance::with_args(None)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Try to start a user interface for the libvlc instance.
 | 
					    /// Try to start a user interface for the libvlc instance.
 | 
				
			||||||
    pub fn add_intf(&self, name: &str) -> Result<(), ()> {
 | 
					    pub fn add_intf(&self, name: &str) -> Result<(), InternalError> {
 | 
				
			||||||
        let cstr = to_cstr(name);
 | 
					        let cstr = to_cstr(name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let result = unsafe{
 | 
					        let result = unsafe { sys::libvlc_add_intf(self.ptr, cstr.as_ptr()) };
 | 
				
			||||||
            sys::libvlc_add_intf(self.ptr, cstr.as_ptr())
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if result == 0 { Ok(()) }
 | 
					        if result == 0 {
 | 
				
			||||||
        else { Err(()) }
 | 
					            Ok(())
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Sets the application name.
 | 
					    /// Sets the application name.
 | 
				
			||||||
    /// LibVLC passes this as the user agent string when a protocol requires it.
 | 
					    /// LibVLC passes this as the user agent string when a protocol requires it.
 | 
				
			||||||
    pub fn set_user_agent(&self, name: &str, http: &str) {
 | 
					    pub fn set_user_agent(&self, name: &str, http: &str) {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            sys::libvlc_set_user_agent(
 | 
					            sys::libvlc_set_user_agent(self.ptr, to_cstr(name).as_ptr(), to_cstr(http).as_ptr());
 | 
				
			||||||
                self.ptr, to_cstr(name).as_ptr(), to_cstr(http).as_ptr());
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,25 +116,35 @@ impl Instance {
 | 
				
			||||||
    pub fn set_app_id(&self, id: &str, version: &str, icon: &str) {
 | 
					    pub fn set_app_id(&self, id: &str, version: &str, icon: &str) {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            sys::libvlc_set_app_id(
 | 
					            sys::libvlc_set_app_id(
 | 
				
			||||||
                self.ptr, to_cstr(id).as_ptr(), to_cstr(version).as_ptr(), to_cstr(icon).as_ptr());
 | 
					                self.ptr,
 | 
				
			||||||
 | 
					                to_cstr(id).as_ptr(),
 | 
				
			||||||
 | 
					                to_cstr(version).as_ptr(),
 | 
				
			||||||
 | 
					                to_cstr(icon).as_ptr(),
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns a list of audio filters that are available.
 | 
					    /// Returns a list of audio filters that are available.
 | 
				
			||||||
    pub fn audio_filter_list_get(&self) -> Option<ModuleDescriptionList> {
 | 
					    pub fn audio_filter_list_get(&self) -> Result<ModuleDescriptionList, InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_audio_filter_list_get(self.ptr);
 | 
					            let p = sys::libvlc_audio_filter_list_get(self.ptr);
 | 
				
			||||||
            if p.is_null() { None }
 | 
					            if p.is_null() {
 | 
				
			||||||
            else { Some(ModuleDescriptionList{ptr: p}) }
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Ok(ModuleDescriptionList { ptr: p })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns a list of video filters that are available.
 | 
					    /// Returns a list of video filters that are available.
 | 
				
			||||||
    pub fn video_filter_list_get(&self) -> Option<ModuleDescriptionList> {
 | 
					    pub fn video_filter_list_get(&self) -> Result<ModuleDescriptionList, InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_video_filter_list_get(self.ptr);
 | 
					            let p = sys::libvlc_video_filter_list_get(self.ptr);
 | 
				
			||||||
            if p.is_null() { None }
 | 
					            if p.is_null() {
 | 
				
			||||||
            else { Some(ModuleDescriptionList{ptr: p}) }
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Ok(ModuleDescriptionList { ptr: p })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,7 +153,10 @@ impl Instance {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_vlm_get_event_manager(self.ptr);
 | 
					            let p = sys::libvlc_vlm_get_event_manager(self.ptr);
 | 
				
			||||||
            assert!(!p.is_null());
 | 
					            assert!(!p.is_null());
 | 
				
			||||||
            EventManager{ptr: p, _phantomdata: ::std::marker::PhantomData}
 | 
					            EventManager {
 | 
				
			||||||
 | 
					                ptr: p,
 | 
				
			||||||
 | 
					                _phantomdata: ::std::marker::PhantomData,
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,7 +165,7 @@ impl Instance {
 | 
				
			||||||
        let cb: Box<Box<dyn Fn(LogLevel, Log, Cow<str>) + Send + 'static>> = Box::new(Box::new(f));
 | 
					        let cb: Box<Box<dyn Fn(LogLevel, Log, Cow<str>) + Send + 'static>> = Box::new(Box::new(f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            sys::libvlc_log_set(self.ptr, logging_cb, Box::into_raw(cb) as *mut _);
 | 
					            sys::libvlc_log_set(self.ptr, Some(logging_cb), Box::into_raw(cb) as *mut _);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -153,19 +183,24 @@ impl Drop for Instance {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    fn vsnprintf(s: *mut c_char, n: usize, fmt: *const c_char, arg: sys::va_list);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
const BUF_SIZE: usize = 1024; // Write log message to the buffer by vsnprintf.
 | 
					const BUF_SIZE: usize = 1024; // Write log message to the buffer by vsnprintf.
 | 
				
			||||||
unsafe extern "C" fn logging_cb(
 | 
					unsafe extern "C" fn logging_cb(
 | 
				
			||||||
    data: *mut c_void, level: c_int, ctx: *const sys::libvlc_log_t, fmt: *const c_char, args: sys::va_list) {
 | 
					    data: *mut c_void,
 | 
				
			||||||
 | 
					    level: c_int,
 | 
				
			||||||
 | 
					    ctx: *const sys::libvlc_log_t,
 | 
				
			||||||
 | 
					    fmt: *const c_char,
 | 
				
			||||||
 | 
					    args: *mut sys::__va_list_tag,
 | 
				
			||||||
 | 
					) {
 | 
				
			||||||
    let f: &Box<dyn Fn(LogLevel, Log, Cow<str>) + Send + 'static> = ::std::mem::transmute(data);
 | 
					    let f: &Box<dyn Fn(LogLevel, Log, Cow<str>) + Send + 'static> = ::std::mem::transmute(data);
 | 
				
			||||||
    let mut buf: [c_char; BUF_SIZE] = [0; BUF_SIZE];
 | 
					    let mut buf: [c_char; BUF_SIZE] = [0; BUF_SIZE];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    vsnprintf(buf.as_mut_ptr(), BUF_SIZE, fmt, args);
 | 
					    sys::vsnprintf(buf.as_mut_ptr(), BUF_SIZE.try_into().unwrap(), fmt, args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    f(::std::mem::transmute(level), Log{ptr: ctx}, from_cstr_ref(buf.as_ptr()).unwrap());
 | 
					    f(
 | 
				
			||||||
 | 
					        (level as u32).into(),
 | 
				
			||||||
 | 
					        Log { ptr: ctx },
 | 
				
			||||||
 | 
					        from_cstr_ref(buf.as_ptr()).unwrap(),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// List of module description.
 | 
					/// List of module description.
 | 
				
			||||||
| 
						 | 
					@ -191,7 +226,10 @@ impl<'a> IntoIterator for &'a ModuleDescriptionList {
 | 
				
			||||||
    type IntoIter = ModuleDescriptionListIter<'a>;
 | 
					    type IntoIter = ModuleDescriptionListIter<'a>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn into_iter(self) -> Self::IntoIter {
 | 
					    fn into_iter(self) -> Self::IntoIter {
 | 
				
			||||||
        ModuleDescriptionListIter{ptr: self.ptr, _phantomdata: PhantomData}
 | 
					        ModuleDescriptionListIter {
 | 
				
			||||||
 | 
					            ptr: self.ptr,
 | 
				
			||||||
 | 
					            _phantomdata: PhantomData,
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -317,7 +355,7 @@ pub enum Event {
 | 
				
			||||||
    VlmMediaInstanceStatusPlaying(Option<String>, Option<String>),
 | 
					    VlmMediaInstanceStatusPlaying(Option<String>, Option<String>),
 | 
				
			||||||
    VlmMediaInstanceStatusPause(Option<String>, Option<String>),
 | 
					    VlmMediaInstanceStatusPause(Option<String>, Option<String>),
 | 
				
			||||||
    VlmMediaInstanceStatusEnd(Option<String>, Option<String>),
 | 
					    VlmMediaInstanceStatusEnd(Option<String>, Option<String>),
 | 
				
			||||||
    VlmMediaInstanceStatusError(Option<String>, Option<String>)
 | 
					    VlmMediaInstanceStatusError(Option<String>, Option<String>),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct EventManager<'a> {
 | 
					pub struct EventManager<'a> {
 | 
				
			||||||
| 
						 | 
					@ -326,23 +364,44 @@ pub struct EventManager<'a> {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<'a> EventManager<'a> {
 | 
					impl<'a> EventManager<'a> {
 | 
				
			||||||
    pub fn attach<F>(&self, event_type: EventType, callback: F) -> Result<(), ()>
 | 
					    pub fn detach(&self, event_type: EventType, registered_callback: *mut c_void) {
 | 
				
			||||||
        where F: Fn(Event, VLCObject) + Send + 'static
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_event_detach(
 | 
				
			||||||
 | 
					                self.ptr,
 | 
				
			||||||
 | 
					                event_type as i32,
 | 
				
			||||||
 | 
					                Some(event_manager_callback),
 | 
				
			||||||
 | 
					                registered_callback
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub fn attach<F>(
 | 
				
			||||||
 | 
					        &self,
 | 
				
			||||||
 | 
					        event_type: EventType,
 | 
				
			||||||
 | 
					        callback: F,
 | 
				
			||||||
 | 
					    ) -> Result<*mut c_void, InternalError>
 | 
				
			||||||
 | 
					    where
 | 
				
			||||||
 | 
					        F: Fn(Event, VLCObject) + Send + 'static,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // Explicit type annotation is needed
 | 
					        // Explicit type annotation is needed
 | 
				
			||||||
        let callback: Box<Box<dyn Fn(Event, VLCObject) + Send + 'static>> =
 | 
					        let callback: Box<Box<dyn Fn(Event, VLCObject) + Send + 'static>> =
 | 
				
			||||||
            Box::new(Box::new(callback));
 | 
					            Box::new(Box::new(callback));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let raw = Box::into_raw(callback) as *mut c_void;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let result = unsafe {
 | 
					        let result = unsafe {
 | 
				
			||||||
            sys::libvlc_event_attach(
 | 
					            sys::libvlc_event_attach(
 | 
				
			||||||
                self.ptr, event_type as i32, event_manager_callback,
 | 
					                self.ptr,
 | 
				
			||||||
                Box::into_raw(callback) as *mut c_void)
 | 
					                event_type as i32,
 | 
				
			||||||
 | 
					                Some(event_manager_callback),
 | 
				
			||||||
 | 
					                raw,
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if result == 0 {
 | 
					        if result == 0 {
 | 
				
			||||||
            Ok(())
 | 
					            Ok(raw)
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Err(())
 | 
					            Err(InternalError)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -360,195 +419,128 @@ unsafe extern "C" fn event_manager_callback(pe: *const sys::libvlc_event_t, data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Convert c-style libvlc_event_t to Event
 | 
					// Convert c-style libvlc_event_t to Event
 | 
				
			||||||
fn conv_event(pe: *const sys::libvlc_event_t) -> Event {
 | 
					fn conv_event(pe: *const sys::libvlc_event_t) -> Event {
 | 
				
			||||||
    let event_type: EventType = unsafe{ ::std::mem::transmute((*pe)._type) };
 | 
					    let event_type: EventType = (unsafe { (*pe).type_ } as u32).into();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    match event_type {
 | 
					    match event_type {
 | 
				
			||||||
        EventType::MediaMetaChanged => {
 | 
					        EventType::MediaMetaChanged => unsafe {
 | 
				
			||||||
            unsafe{
 | 
					            Event::MediaMetaChanged((*pe).u.media_meta_changed.meta_type.into())
 | 
				
			||||||
                Event::MediaMetaChanged((*pe).u.media_meta_changed.meta_type)
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaSubItemAdded => {
 | 
					        EventType::MediaSubItemAdded => Event::MediaSubItemAdded,
 | 
				
			||||||
            Event::MediaSubItemAdded
 | 
					        EventType::MediaDurationChanged => unsafe {
 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaDurationChanged => {
 | 
					 | 
				
			||||||
            unsafe{
 | 
					 | 
				
			||||||
            Event::MediaDurationChanged((*pe).u.media_duration_changed.new_duration)
 | 
					            Event::MediaDurationChanged((*pe).u.media_duration_changed.new_duration)
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaParsedChanged => {
 | 
					        EventType::MediaParsedChanged => unsafe {
 | 
				
			||||||
            unsafe{
 | 
					 | 
				
			||||||
            Event::MediaParsedChanged((*pe).u.media_parsed_changed.new_status)
 | 
					            Event::MediaParsedChanged((*pe).u.media_parsed_changed.new_status)
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaFreed => {
 | 
					        EventType::MediaFreed => Event::MediaFreed,
 | 
				
			||||||
            Event::MediaFreed
 | 
					        EventType::MediaStateChanged => unsafe {
 | 
				
			||||||
 | 
					            let new_state: sys::libvlc_state_t =
 | 
				
			||||||
 | 
					                (*pe).u.media_state_changed.new_state.try_into().unwrap();
 | 
				
			||||||
 | 
					            Event::MediaStateChanged(new_state.into())
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaStateChanged => {
 | 
					        EventType::MediaSubItemTreeAdded => Event::MediaSubItemTreeAdded,
 | 
				
			||||||
            unsafe{
 | 
					        EventType::MediaPlayerMediaChanged => Event::MediaPlayerMediaChanged,
 | 
				
			||||||
                Event::MediaStateChanged((*pe).u.media_state_changed.new_state)
 | 
					        EventType::MediaPlayerNothingSpecial => Event::MediaPlayerNothingSpecial,
 | 
				
			||||||
            }
 | 
					        EventType::MediaPlayerOpening => Event::MediaPlayerOpening,
 | 
				
			||||||
        },
 | 
					        EventType::MediaPlayerBuffering => unsafe {
 | 
				
			||||||
        EventType::MediaSubItemTreeAdded => {
 | 
					 | 
				
			||||||
            Event::MediaSubItemTreeAdded
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerMediaChanged => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerMediaChanged
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerNothingSpecial => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerNothingSpecial
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerOpening => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerOpening
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerBuffering => {
 | 
					 | 
				
			||||||
            unsafe{
 | 
					 | 
				
			||||||
            Event::MediaPlayerBuffering((*pe).u.media_player_buffering.new_cache)
 | 
					            Event::MediaPlayerBuffering((*pe).u.media_player_buffering.new_cache)
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerPlaying => {
 | 
					        EventType::MediaPlayerPlaying => Event::MediaPlayerPlaying,
 | 
				
			||||||
            Event::MediaPlayerPlaying
 | 
					        EventType::MediaPlayerPaused => Event::MediaPlayerPaused,
 | 
				
			||||||
        },
 | 
					        EventType::MediaPlayerStopped => Event::MediaPlayerStopped,
 | 
				
			||||||
        EventType::MediaPlayerPaused => {
 | 
					        EventType::MediaPlayerForward => Event::MediaPlayerForward,
 | 
				
			||||||
            Event::MediaPlayerPaused
 | 
					        EventType::MediaPlayerBackward => Event::MediaPlayerBackward,
 | 
				
			||||||
        },
 | 
					        EventType::MediaPlayerEndReached => Event::MediaPlayerEndReached,
 | 
				
			||||||
        EventType::MediaPlayerStopped => {
 | 
					        EventType::MediaPlayerEncounteredError => Event::MediaPlayerEncounteredError,
 | 
				
			||||||
            Event::MediaPlayerStopped
 | 
					        EventType::MediaPlayerTimeChanged => Event::MediaPlayerTimeChanged,
 | 
				
			||||||
        },
 | 
					        EventType::MediaPlayerPositionChanged => unsafe {
 | 
				
			||||||
        EventType::MediaPlayerForward => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerForward
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerBackward => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerBackward
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerEndReached => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerEndReached
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerEncounteredError => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerEncounteredError
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerTimeChanged => {
 | 
					 | 
				
			||||||
            Event::MediaPlayerTimeChanged
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaPlayerPositionChanged => {
 | 
					 | 
				
			||||||
            unsafe{
 | 
					 | 
				
			||||||
            Event::MediaPlayerPositionChanged((*pe).u.media_player_position_changed.new_position)
 | 
					            Event::MediaPlayerPositionChanged((*pe).u.media_player_position_changed.new_position)
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerSeekableChanged => {
 | 
					        EventType::MediaPlayerSeekableChanged => Event::MediaPlayerSeekableChanged,
 | 
				
			||||||
            Event::MediaPlayerSeekableChanged
 | 
					        EventType::MediaPlayerPausableChanged => Event::MediaPlayerPausableChanged,
 | 
				
			||||||
 | 
					        EventType::MediaPlayerTitleChanged => Event::MediaPlayerTitleChanged,
 | 
				
			||||||
 | 
					        EventType::MediaPlayerSnapshotTaken => Event::MediaPlayerSnapshotTaken,
 | 
				
			||||||
 | 
					        EventType::MediaPlayerLengthChanged => Event::MediaPlayerLengthChanged,
 | 
				
			||||||
 | 
					        EventType::MediaPlayerVout => Event::MediaPlayerVout,
 | 
				
			||||||
 | 
					        EventType::MediaPlayerScrambledChanged => Event::MediaPlayerScrambledChanged,
 | 
				
			||||||
 | 
					        EventType::MediaListItemAdded => Event::MediaListItemAdded,
 | 
				
			||||||
 | 
					        EventType::MediaListWillAddItem => Event::MediaListWillAddItem,
 | 
				
			||||||
 | 
					        EventType::MediaListItemDeleted => Event::MediaListItemDeleted,
 | 
				
			||||||
 | 
					        EventType::MediaListWillDeleteItem => Event::MediaListWillDeleteItem,
 | 
				
			||||||
 | 
					        EventType::MediaListViewItemAdded => Event::MediaListViewItemAdded,
 | 
				
			||||||
 | 
					        EventType::MediaListViewWillAddItem => Event::MediaListViewWillAddItem,
 | 
				
			||||||
 | 
					        EventType::MediaListViewItemDeleted => Event::MediaListViewItemDeleted,
 | 
				
			||||||
 | 
					        EventType::MediaListViewWillDeleteItem => Event::MediaListViewWillDeleteItem,
 | 
				
			||||||
 | 
					        EventType::MediaListPlayerPlayed => Event::MediaListPlayerPlayed,
 | 
				
			||||||
 | 
					        EventType::MediaListPlayerNextItemSet => Event::MediaListPlayerNextItemSet,
 | 
				
			||||||
 | 
					        EventType::MediaListPlayerStopped => Event::MediaListPlayerStopped,
 | 
				
			||||||
 | 
					        EventType::MediaDiscovererStarted => Event::MediaDiscovererStarted,
 | 
				
			||||||
 | 
					        EventType::MediaDiscovererEnded => Event::MediaDiscovererEnded,
 | 
				
			||||||
 | 
					        EventType::VlmMediaAdded => unsafe {
 | 
				
			||||||
 | 
					            Event::VlmMediaAdded(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerPausableChanged => {
 | 
					        EventType::VlmMediaRemoved => unsafe {
 | 
				
			||||||
            Event::MediaPlayerPausableChanged
 | 
					            Event::VlmMediaRemoved(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerTitleChanged => {
 | 
					        EventType::VlmMediaChanged => unsafe {
 | 
				
			||||||
            Event::MediaPlayerTitleChanged
 | 
					            Event::VlmMediaChanged(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerSnapshotTaken => {
 | 
					        EventType::VlmMediaInstanceStarted => unsafe {
 | 
				
			||||||
            Event::MediaPlayerSnapshotTaken
 | 
					            Event::VlmMediaInstanceStarted(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerLengthChanged => {
 | 
					        EventType::VlmMediaInstanceStopped => unsafe {
 | 
				
			||||||
            Event::MediaPlayerLengthChanged
 | 
					            Event::VlmMediaInstanceStopped(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerVout => {
 | 
					        EventType::VlmMediaInstanceStatusInit => unsafe {
 | 
				
			||||||
            Event::MediaPlayerVout
 | 
					            Event::VlmMediaInstanceStatusInit(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaPlayerScrambledChanged => {
 | 
					        EventType::VlmMediaInstanceStatusOpening => unsafe {
 | 
				
			||||||
            Event::MediaPlayerScrambledChanged
 | 
					            Event::VlmMediaInstanceStatusOpening(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaListItemAdded => {
 | 
					        EventType::VlmMediaInstanceStatusPlaying => unsafe {
 | 
				
			||||||
            Event::MediaListItemAdded
 | 
					            Event::VlmMediaInstanceStatusPlaying(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaListWillAddItem => {
 | 
					        EventType::VlmMediaInstanceStatusPause => unsafe {
 | 
				
			||||||
            Event::MediaListWillAddItem
 | 
					            Event::VlmMediaInstanceStatusPause(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaListItemDeleted => {
 | 
					        EventType::VlmMediaInstanceStatusEnd => unsafe {
 | 
				
			||||||
            Event::MediaListItemDeleted
 | 
					            Event::VlmMediaInstanceStatusEnd(
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        EventType::MediaListWillDeleteItem => {
 | 
					        EventType::VlmMediaInstanceStatusError => unsafe {
 | 
				
			||||||
            Event::MediaListWillDeleteItem
 | 
					            Event::VlmMediaInstanceStatusError(
 | 
				
			||||||
        },
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_instance_name),
 | 
				
			||||||
        EventType::MediaListViewItemAdded => {
 | 
					                from_cstr((*pe).u.vlm_media_event.psz_media_name),
 | 
				
			||||||
            Event::MediaListViewItemAdded
 | 
					            )
 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaListViewWillAddItem => {
 | 
					 | 
				
			||||||
            Event::MediaListViewWillAddItem
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaListViewItemDeleted => {
 | 
					 | 
				
			||||||
            Event::MediaListViewItemDeleted
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaListViewWillDeleteItem => {
 | 
					 | 
				
			||||||
            Event::MediaListViewWillDeleteItem
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaListPlayerPlayed => {
 | 
					 | 
				
			||||||
            Event::MediaListPlayerPlayed
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaListPlayerNextItemSet => {
 | 
					 | 
				
			||||||
            Event::MediaListPlayerNextItemSet
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaListPlayerStopped => {
 | 
					 | 
				
			||||||
            Event::MediaListPlayerStopped
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaDiscovererStarted => {
 | 
					 | 
				
			||||||
            Event::MediaDiscovererStarted
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::MediaDiscovererEnded => {
 | 
					 | 
				
			||||||
            Event::MediaDiscovererEnded
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaAdded => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaAdded(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaRemoved => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaRemoved(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaChanged => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaChanged(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStarted => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStarted(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStopped => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStopped(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStatusInit => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStatusInit(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStatusOpening => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStatusOpening(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStatusPlaying => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStatusPlaying(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStatusPause => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStatusPause(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStatusEnd => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStatusEnd(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        EventType::VlmMediaInstanceStatusError => {
 | 
					 | 
				
			||||||
            unsafe {
 | 
					 | 
				
			||||||
                Event::VlmMediaInstanceStatusError(from_cstr((*pe).u.vlm_media_event.psz_instance_name), from_cstr((*pe).u.vlm_media_event.psz_media_name))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -565,7 +557,7 @@ impl VLCObject {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct Log {
 | 
					pub struct Log {
 | 
				
			||||||
    pub(crate) ptr: *const sys::libvlc_log_t
 | 
					    pub(crate) ptr: *const sys::libvlc_log_t,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Log {
 | 
					impl Log {
 | 
				
			||||||
| 
						 | 
					@ -574,4 +566,3 @@ impl Log {
 | 
				
			||||||
        self.ptr
 | 
					        self.ptr
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										297
									
								
								src/enums.rs
								
								
								
								
							
							
						
						
									
										297
									
								
								src/enums.rs
								
								
								
								
							| 
						 | 
					@ -2,158 +2,171 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[repr(C)]
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					macro_rules! define_enum {
 | 
				
			||||||
 | 
					    ($enum_name:ident, $original_type:ident; $($value:ident = $c_value:ident,)*) => {
 | 
				
			||||||
        #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
					        #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
				
			||||||
pub enum LogLevel {
 | 
					 | 
				
			||||||
    Debug = 0,
 | 
					 | 
				
			||||||
    Notice = 2,
 | 
					 | 
				
			||||||
    Warning = 3,
 | 
					 | 
				
			||||||
    Error = 4,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        #[repr(C)]
 | 
					        #[repr(C)]
 | 
				
			||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
					        pub enum $enum_name {
 | 
				
			||||||
pub enum Meta {
 | 
					            $(
 | 
				
			||||||
    Title,
 | 
					                $value = sys::$c_value as isize,
 | 
				
			||||||
    Artist,
 | 
					            )*
 | 
				
			||||||
    Genre,
 | 
					 | 
				
			||||||
    Copyright,
 | 
					 | 
				
			||||||
    Album,
 | 
					 | 
				
			||||||
    TrackNumber,
 | 
					 | 
				
			||||||
    Description,
 | 
					 | 
				
			||||||
    Rating,
 | 
					 | 
				
			||||||
    Date,
 | 
					 | 
				
			||||||
    Setting,
 | 
					 | 
				
			||||||
    URL,
 | 
					 | 
				
			||||||
    Language,
 | 
					 | 
				
			||||||
    NowPlaying,
 | 
					 | 
				
			||||||
    Publisher,
 | 
					 | 
				
			||||||
    EncodedBy,
 | 
					 | 
				
			||||||
    ArtworkURL,
 | 
					 | 
				
			||||||
    TrackID,
 | 
					 | 
				
			||||||
    TrackTotal,
 | 
					 | 
				
			||||||
    Director,
 | 
					 | 
				
			||||||
    Season,
 | 
					 | 
				
			||||||
    Episode,
 | 
					 | 
				
			||||||
    ShowName,
 | 
					 | 
				
			||||||
    Actors
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[repr(C)]
 | 
					        impl From<sys::$original_type> for $enum_name {
 | 
				
			||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
					            fn from(a: sys::$original_type) -> Self {
 | 
				
			||||||
pub enum State {
 | 
					                match a {
 | 
				
			||||||
    NothingSpecial = 0,
 | 
					                    $(
 | 
				
			||||||
    Opening,
 | 
					                        sys::$c_value => Self::$value,
 | 
				
			||||||
    Buffering,
 | 
					                    )*
 | 
				
			||||||
    Playing,
 | 
					                    _ => unreachable!(),
 | 
				
			||||||
    Paused,
 | 
					                }
 | 
				
			||||||
    Stopped,
 | 
					            }
 | 
				
			||||||
    Ended,
 | 
					        }
 | 
				
			||||||
    Error
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[repr(C)]
 | 
					define_enum!(
 | 
				
			||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
					    LogLevel, libvlc_log_level;
 | 
				
			||||||
pub enum TrackType {
 | 
					    Debug = libvlc_log_level_LIBVLC_DEBUG,
 | 
				
			||||||
    Unknown = -1,
 | 
					    Dotice = libvlc_log_level_LIBVLC_NOTICE,
 | 
				
			||||||
    Audio   = 0,
 | 
					    Warning = libvlc_log_level_LIBVLC_WARNING,
 | 
				
			||||||
    Video   = 1,
 | 
					    Error = libvlc_log_level_LIBVLC_ERROR,
 | 
				
			||||||
    Text    = 2
 | 
					);
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[repr(C)]
 | 
					define_enum!(
 | 
				
			||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
					    Meta, libvlc_meta_t;
 | 
				
			||||||
pub enum Position {
 | 
					    Title = libvlc_meta_t_libvlc_meta_Title,
 | 
				
			||||||
    Disable = -1,
 | 
					    Artist = libvlc_meta_t_libvlc_meta_Artist,
 | 
				
			||||||
    Center,
 | 
					    Genre = libvlc_meta_t_libvlc_meta_Genre,
 | 
				
			||||||
    Left,
 | 
					    Copyright = libvlc_meta_t_libvlc_meta_Copyright,
 | 
				
			||||||
    Right,
 | 
					    Album = libvlc_meta_t_libvlc_meta_Album,
 | 
				
			||||||
    Top,
 | 
					    TrackNumber = libvlc_meta_t_libvlc_meta_TrackNumber,
 | 
				
			||||||
    TopLeft,
 | 
					    Description = libvlc_meta_t_libvlc_meta_Description,
 | 
				
			||||||
    TopRight,
 | 
					    Rating = libvlc_meta_t_libvlc_meta_Rating,
 | 
				
			||||||
    Bottom,
 | 
					    Date = libvlc_meta_t_libvlc_meta_Date,
 | 
				
			||||||
    BottomLeft,
 | 
					    Setting = libvlc_meta_t_libvlc_meta_Setting,
 | 
				
			||||||
    BottomRight,
 | 
					    URL = libvlc_meta_t_libvlc_meta_URL,
 | 
				
			||||||
}
 | 
					    Language = libvlc_meta_t_libvlc_meta_Language,
 | 
				
			||||||
 | 
					    NowPlaying = libvlc_meta_t_libvlc_meta_NowPlaying,
 | 
				
			||||||
 | 
					    Publisher = libvlc_meta_t_libvlc_meta_Publisher,
 | 
				
			||||||
 | 
					    EncodedBy = libvlc_meta_t_libvlc_meta_EncodedBy,
 | 
				
			||||||
 | 
					    ArtworkURL = libvlc_meta_t_libvlc_meta_ArtworkURL,
 | 
				
			||||||
 | 
					    TrackID = libvlc_meta_t_libvlc_meta_TrackID,
 | 
				
			||||||
 | 
					    TrackTotal = libvlc_meta_t_libvlc_meta_TrackTotal,
 | 
				
			||||||
 | 
					    Director = libvlc_meta_t_libvlc_meta_Director,
 | 
				
			||||||
 | 
					    Season = libvlc_meta_t_libvlc_meta_Season,
 | 
				
			||||||
 | 
					    Episode = libvlc_meta_t_libvlc_meta_Episode,
 | 
				
			||||||
 | 
					    ShowName = libvlc_meta_t_libvlc_meta_ShowName,
 | 
				
			||||||
 | 
					    Actors = libvlc_meta_t_libvlc_meta_Actors,
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[repr(C)]
 | 
					define_enum!(
 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					    State, libvlc_state_t;
 | 
				
			||||||
pub enum VideoAdjustOption {
 | 
					    NothingSpecial = libvlc_state_t_libvlc_NothingSpecial,
 | 
				
			||||||
    Enable = 0,
 | 
					    Opening = libvlc_state_t_libvlc_Opening,
 | 
				
			||||||
    Contrast,
 | 
					    Buffering = libvlc_state_t_libvlc_Buffering,
 | 
				
			||||||
    Brightness,
 | 
					    Playing = libvlc_state_t_libvlc_Playing,
 | 
				
			||||||
    Hue,
 | 
					    Paused = libvlc_state_t_libvlc_Paused,
 | 
				
			||||||
    Saturation,
 | 
					    Stopped = libvlc_state_t_libvlc_Stopped,
 | 
				
			||||||
    Gamma
 | 
					    Ended = libvlc_state_t_libvlc_Ended,
 | 
				
			||||||
}
 | 
					    Error = libvlc_state_t_libvlc_Error,
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// #[repr(C)]
 | 
					define_enum!(
 | 
				
			||||||
// #[derive(Clone, Copy, PartialEq, Eq, Debug)]
 | 
					    TrackType, libvlc_track_type_t;
 | 
				
			||||||
// pub enum ParseFlag {
 | 
					    Unknown = libvlc_track_type_t_libvlc_track_unknown,
 | 
				
			||||||
//     ParseLocal,
 | 
					    Audio = libvlc_track_type_t_libvlc_track_audio,
 | 
				
			||||||
//     ParseNetwork,
 | 
					    Video = libvlc_track_type_t_libvlc_track_video,
 | 
				
			||||||
//     FetchLocal,
 | 
					    Text = libvlc_track_type_t_libvlc_track_text,
 | 
				
			||||||
//     FetchNetwork,
 | 
					);
 | 
				
			||||||
// }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[repr(C)]
 | 
					define_enum!(
 | 
				
			||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
					    Position, libvlc_position_t;
 | 
				
			||||||
pub enum EventType {
 | 
					    Disable = libvlc_position_t_libvlc_position_disable,
 | 
				
			||||||
    MediaMetaChanged = 0,
 | 
					    Center = libvlc_position_t_libvlc_position_center,
 | 
				
			||||||
    MediaSubItemAdded,
 | 
					    Left = libvlc_position_t_libvlc_position_left,
 | 
				
			||||||
    MediaDurationChanged,
 | 
					    Right = libvlc_position_t_libvlc_position_right,
 | 
				
			||||||
    MediaParsedChanged,
 | 
					    Top = libvlc_position_t_libvlc_position_top,
 | 
				
			||||||
    MediaFreed,
 | 
					    TopLeft = libvlc_position_t_libvlc_position_top_left,
 | 
				
			||||||
    MediaStateChanged,
 | 
					    TopRight = libvlc_position_t_libvlc_position_top_right,
 | 
				
			||||||
    MediaSubItemTreeAdded,
 | 
					    Bottom = libvlc_position_t_libvlc_position_bottom,
 | 
				
			||||||
 | 
					    BottomLeft = libvlc_position_t_libvlc_position_bottom_left,
 | 
				
			||||||
 | 
					    BottomRight = libvlc_position_t_libvlc_position_bottom_right,
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MediaPlayerMediaChanged = 0x100,
 | 
					define_enum!(
 | 
				
			||||||
    MediaPlayerNothingSpecial,
 | 
					    VideoAdjustOption, libvlc_video_adjust_option_t;
 | 
				
			||||||
    MediaPlayerOpening,
 | 
					    Enable = libvlc_video_adjust_option_t_libvlc_adjust_Enable,
 | 
				
			||||||
    MediaPlayerBuffering,
 | 
					    Contrast = libvlc_video_adjust_option_t_libvlc_adjust_Contrast,
 | 
				
			||||||
    MediaPlayerPlaying,
 | 
					    Brightness = libvlc_video_adjust_option_t_libvlc_adjust_Brightness,
 | 
				
			||||||
    MediaPlayerPaused,
 | 
					    Hue = libvlc_video_adjust_option_t_libvlc_adjust_Hue,
 | 
				
			||||||
    MediaPlayerStopped,
 | 
					    Saturation = libvlc_video_adjust_option_t_libvlc_adjust_Saturation,
 | 
				
			||||||
    MediaPlayerForward,
 | 
					    Gamma = libvlc_video_adjust_option_t_libvlc_adjust_Gamma,
 | 
				
			||||||
    MediaPlayerBackward,
 | 
					);
 | 
				
			||||||
    MediaPlayerEndReached,
 | 
					 | 
				
			||||||
    MediaPlayerEncounteredError,
 | 
					 | 
				
			||||||
    MediaPlayerTimeChanged,
 | 
					 | 
				
			||||||
    MediaPlayerPositionChanged,
 | 
					 | 
				
			||||||
    MediaPlayerSeekableChanged,
 | 
					 | 
				
			||||||
    MediaPlayerPausableChanged,
 | 
					 | 
				
			||||||
    MediaPlayerTitleChanged,
 | 
					 | 
				
			||||||
    MediaPlayerSnapshotTaken,
 | 
					 | 
				
			||||||
    MediaPlayerLengthChanged,
 | 
					 | 
				
			||||||
    MediaPlayerVout,
 | 
					 | 
				
			||||||
    MediaPlayerScrambledChanged,
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MediaListItemAdded = 0x200,
 | 
					// libvlc 3.0
 | 
				
			||||||
    MediaListWillAddItem,
 | 
					// define_enum!(
 | 
				
			||||||
    MediaListItemDeleted,
 | 
					//     ParseFlag, libvlc_media_parse_flag_t;
 | 
				
			||||||
    MediaListWillDeleteItem,
 | 
					//     DoInteract = libvlc_media_parse_flag_t_libvlc_media_do_interact,
 | 
				
			||||||
 | 
					//     FetchLocal = libvlc_media_parse_flag_t_libvlc_media_fetch_local,
 | 
				
			||||||
 | 
					//     FetchNetwork = libvlc_media_parse_flag_t_libvlc_media_fetch_network,
 | 
				
			||||||
 | 
					//     ParseLocal = libvlc_media_parse_flag_t_libvlc_media_parse_local,
 | 
				
			||||||
 | 
					//     ParseNetwork = libvlc_media_parse_flag_t_libvlc_media_parse_network,
 | 
				
			||||||
 | 
					// );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MediaListViewItemAdded = 0x300,
 | 
					define_enum!(
 | 
				
			||||||
    MediaListViewWillAddItem,
 | 
					    EventType, libvlc_event_e;
 | 
				
			||||||
    MediaListViewItemDeleted,
 | 
					    MediaMetaChanged = libvlc_event_e_libvlc_MediaMetaChanged,
 | 
				
			||||||
    MediaListViewWillDeleteItem,
 | 
					    MediaSubItemAdded = libvlc_event_e_libvlc_MediaSubItemAdded,
 | 
				
			||||||
 | 
					    MediaDurationChanged = libvlc_event_e_libvlc_MediaDurationChanged,
 | 
				
			||||||
    MediaListPlayerPlayed = 0x400,
 | 
					    MediaParsedChanged = libvlc_event_e_libvlc_MediaParsedChanged,
 | 
				
			||||||
    MediaListPlayerNextItemSet,
 | 
					    MediaFreed = libvlc_event_e_libvlc_MediaFreed,
 | 
				
			||||||
    MediaListPlayerStopped,
 | 
					    MediaStateChanged = libvlc_event_e_libvlc_MediaStateChanged,
 | 
				
			||||||
 | 
					    MediaSubItemTreeAdded = libvlc_event_e_libvlc_MediaSubItemTreeAdded,
 | 
				
			||||||
    MediaDiscovererStarted = 0x500,
 | 
					    MediaPlayerMediaChanged = libvlc_event_e_libvlc_MediaPlayerMediaChanged,
 | 
				
			||||||
    MediaDiscovererEnded,
 | 
					    MediaPlayerNothingSpecial = libvlc_event_e_libvlc_MediaPlayerNothingSpecial,
 | 
				
			||||||
 | 
					    MediaPlayerOpening = libvlc_event_e_libvlc_MediaPlayerOpening,
 | 
				
			||||||
    VlmMediaAdded = 0x600,
 | 
					    MediaPlayerBuffering = libvlc_event_e_libvlc_MediaPlayerBuffering,
 | 
				
			||||||
    VlmMediaRemoved,
 | 
					    MediaPlayerPlaying = libvlc_event_e_libvlc_MediaPlayerPlaying,
 | 
				
			||||||
    VlmMediaChanged,
 | 
					    MediaPlayerPaused = libvlc_event_e_libvlc_MediaPlayerPaused,
 | 
				
			||||||
    VlmMediaInstanceStarted,
 | 
					    MediaPlayerStopped = libvlc_event_e_libvlc_MediaPlayerStopped,
 | 
				
			||||||
    VlmMediaInstanceStopped,
 | 
					    MediaPlayerForward = libvlc_event_e_libvlc_MediaPlayerForward,
 | 
				
			||||||
    VlmMediaInstanceStatusInit,
 | 
					    MediaPlayerBackward = libvlc_event_e_libvlc_MediaPlayerBackward,
 | 
				
			||||||
    VlmMediaInstanceStatusOpening,
 | 
					    MediaPlayerEndReached = libvlc_event_e_libvlc_MediaPlayerEndReached,
 | 
				
			||||||
    VlmMediaInstanceStatusPlaying,
 | 
					    MediaPlayerEncounteredError = libvlc_event_e_libvlc_MediaPlayerEncounteredError,
 | 
				
			||||||
    VlmMediaInstanceStatusPause,
 | 
					    MediaPlayerTimeChanged = libvlc_event_e_libvlc_MediaPlayerTimeChanged,
 | 
				
			||||||
    VlmMediaInstanceStatusEnd,
 | 
					    MediaPlayerPositionChanged = libvlc_event_e_libvlc_MediaPlayerPositionChanged,
 | 
				
			||||||
    VlmMediaInstanceStatusError
 | 
					    MediaPlayerSeekableChanged = libvlc_event_e_libvlc_MediaPlayerSeekableChanged,
 | 
				
			||||||
}
 | 
					    MediaPlayerPausableChanged = libvlc_event_e_libvlc_MediaPlayerPausableChanged,
 | 
				
			||||||
 | 
					    MediaPlayerTitleChanged = libvlc_event_e_libvlc_MediaPlayerTitleChanged,
 | 
				
			||||||
 | 
					    MediaPlayerSnapshotTaken = libvlc_event_e_libvlc_MediaPlayerSnapshotTaken,
 | 
				
			||||||
 | 
					    MediaPlayerLengthChanged = libvlc_event_e_libvlc_MediaPlayerLengthChanged,
 | 
				
			||||||
 | 
					    MediaPlayerVout = libvlc_event_e_libvlc_MediaPlayerVout,
 | 
				
			||||||
 | 
					    MediaPlayerScrambledChanged = libvlc_event_e_libvlc_MediaPlayerScrambledChanged,
 | 
				
			||||||
 | 
					    MediaListItemAdded = libvlc_event_e_libvlc_MediaListItemAdded,
 | 
				
			||||||
 | 
					    MediaListWillAddItem = libvlc_event_e_libvlc_MediaListWillAddItem,
 | 
				
			||||||
 | 
					    MediaListItemDeleted = libvlc_event_e_libvlc_MediaListItemDeleted,
 | 
				
			||||||
 | 
					    MediaListWillDeleteItem = libvlc_event_e_libvlc_MediaListWillDeleteItem,
 | 
				
			||||||
 | 
					    MediaListViewItemAdded = libvlc_event_e_libvlc_MediaListViewItemAdded,
 | 
				
			||||||
 | 
					    MediaListViewWillAddItem = libvlc_event_e_libvlc_MediaListViewWillAddItem,
 | 
				
			||||||
 | 
					    MediaListViewItemDeleted = libvlc_event_e_libvlc_MediaListViewItemDeleted,
 | 
				
			||||||
 | 
					    MediaListViewWillDeleteItem = libvlc_event_e_libvlc_MediaListViewWillDeleteItem,
 | 
				
			||||||
 | 
					    MediaListPlayerPlayed = libvlc_event_e_libvlc_MediaListPlayerPlayed,
 | 
				
			||||||
 | 
					    MediaListPlayerNextItemSet = libvlc_event_e_libvlc_MediaListPlayerNextItemSet,
 | 
				
			||||||
 | 
					    MediaListPlayerStopped = libvlc_event_e_libvlc_MediaListPlayerStopped,
 | 
				
			||||||
 | 
					    MediaDiscovererStarted = libvlc_event_e_libvlc_MediaDiscovererStarted,
 | 
				
			||||||
 | 
					    MediaDiscovererEnded = libvlc_event_e_libvlc_MediaDiscovererEnded,
 | 
				
			||||||
 | 
					    VlmMediaAdded = libvlc_event_e_libvlc_VlmMediaAdded,
 | 
				
			||||||
 | 
					    VlmMediaRemoved = libvlc_event_e_libvlc_VlmMediaRemoved,
 | 
				
			||||||
 | 
					    VlmMediaChanged = libvlc_event_e_libvlc_VlmMediaChanged,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStarted = libvlc_event_e_libvlc_VlmMediaInstanceStarted,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStopped = libvlc_event_e_libvlc_VlmMediaInstanceStopped,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStatusInit = libvlc_event_e_libvlc_VlmMediaInstanceStatusInit,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStatusOpening = libvlc_event_e_libvlc_VlmMediaInstanceStatusOpening,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStatusPlaying = libvlc_event_e_libvlc_VlmMediaInstanceStatusPlaying,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStatusPause = libvlc_event_e_libvlc_VlmMediaInstanceStatusPause,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStatusEnd = libvlc_event_e_libvlc_VlmMediaInstanceStatusEnd,
 | 
				
			||||||
 | 
					    VlmMediaInstanceStatusError = libvlc_event_e_libvlc_VlmMediaInstanceStatusError,
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										32
									
								
								src/lib.rs
								
								
								
								
							
							
						
						
									
										32
									
								
								src/lib.rs
								
								
								
								
							| 
						 | 
					@ -4,25 +4,23 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern crate libc;
 | 
					extern crate libc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub mod sys;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
mod tools;
 | 
					 | 
				
			||||||
mod core;
 | 
					 | 
				
			||||||
mod media;
 | 
					 | 
				
			||||||
mod media_player;
 | 
					 | 
				
			||||||
mod media_list;
 | 
					 | 
				
			||||||
mod media_library;
 | 
					 | 
				
			||||||
mod enums;
 | 
					 | 
				
			||||||
mod video;
 | 
					 | 
				
			||||||
mod audio;
 | 
					mod audio;
 | 
				
			||||||
 | 
					mod core;
 | 
				
			||||||
 | 
					mod enums;
 | 
				
			||||||
 | 
					mod media;
 | 
				
			||||||
 | 
					mod media_library;
 | 
				
			||||||
 | 
					mod media_list;
 | 
				
			||||||
 | 
					mod media_player;
 | 
				
			||||||
 | 
					mod tools;
 | 
				
			||||||
 | 
					mod video;
 | 
				
			||||||
mod vlm;
 | 
					mod vlm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub use crate::enums::*;
 | 
					 | 
				
			||||||
pub use crate::core::*;
 | 
					 | 
				
			||||||
pub use crate::media::*;
 | 
					 | 
				
			||||||
pub use crate::media_player::*;
 | 
					 | 
				
			||||||
pub use crate::media_list::*;
 | 
					 | 
				
			||||||
pub use crate::media_library::*;
 | 
					 | 
				
			||||||
pub use crate::video::*;
 | 
					 | 
				
			||||||
pub use crate::audio::*;
 | 
					pub use crate::audio::*;
 | 
				
			||||||
 | 
					pub use crate::core::*;
 | 
				
			||||||
 | 
					pub use crate::enums::*;
 | 
				
			||||||
 | 
					pub use crate::media::*;
 | 
				
			||||||
 | 
					pub use crate::media_library::*;
 | 
				
			||||||
 | 
					pub use crate::media_list::*;
 | 
				
			||||||
 | 
					pub use crate::media_player::*;
 | 
				
			||||||
 | 
					pub use crate::video::*;
 | 
				
			||||||
pub use crate::vlm::*;
 | 
					pub use crate::vlm::*;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										64
									
								
								src/media.rs
								
								
								
								
							
							
						
						
									
										64
									
								
								src/media.rs
								
								
								
								
							| 
						 | 
					@ -2,11 +2,11 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::sys;
 | 
					use crate::enums::{Meta, State, TrackType};
 | 
				
			||||||
use crate::{Instance, EventManager};
 | 
					use crate::tools::{from_cstr, path_to_cstr, to_cstr};
 | 
				
			||||||
use crate::enums::{State, Meta, TrackType};
 | 
					use crate::{EventManager, Instance};
 | 
				
			||||||
use crate::tools::{to_cstr, from_cstr, path_to_cstr};
 | 
					 | 
				
			||||||
use std::path::Path;
 | 
					use std::path::Path;
 | 
				
			||||||
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct Media {
 | 
					pub struct Media {
 | 
				
			||||||
    pub(crate) ptr: *mut sys::libvlc_media_t,
 | 
					    pub(crate) ptr: *mut sys::libvlc_media_t,
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,9 @@ impl Media {
 | 
				
			||||||
    pub fn new_path<T: AsRef<Path>>(instance: &Instance, path: T) -> Option<Media> {
 | 
					    pub fn new_path<T: AsRef<Path>>(instance: &Instance, path: T) -> Option<Media> {
 | 
				
			||||||
        let cstr = match path_to_cstr(path.as_ref()) {
 | 
					        let cstr = match path_to_cstr(path.as_ref()) {
 | 
				
			||||||
            Ok(s) => s,
 | 
					            Ok(s) => s,
 | 
				
			||||||
            Err(_) => { return None; },
 | 
					            Err(_) => {
 | 
				
			||||||
 | 
					                return None;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
| 
						 | 
					@ -70,7 +72,10 @@ impl Media {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_event_manager(self.ptr);
 | 
					            let p = sys::libvlc_media_event_manager(self.ptr);
 | 
				
			||||||
            assert!(!p.is_null());
 | 
					            assert!(!p.is_null());
 | 
				
			||||||
            EventManager{ptr: p, _phantomdata: ::std::marker::PhantomData}
 | 
					            EventManager {
 | 
				
			||||||
 | 
					                ptr: p,
 | 
				
			||||||
 | 
					                _phantomdata: ::std::marker::PhantomData,
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +83,7 @@ impl Media {
 | 
				
			||||||
    /// If the media has not yet been parsed this will return None.
 | 
					    /// If the media has not yet been parsed this will return None.
 | 
				
			||||||
    pub fn get_meta(&self, meta: Meta) -> Option<String> {
 | 
					    pub fn get_meta(&self, meta: Meta) -> Option<String> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p_str = sys::libvlc_media_get_meta(self.ptr, meta);
 | 
					            let p_str = sys::libvlc_media_get_meta(self.ptr, meta as u32);
 | 
				
			||||||
            let s = from_cstr(p_str);
 | 
					            let s = from_cstr(p_str);
 | 
				
			||||||
            sys::libvlc_free(p_str as *mut ::libc::c_void);
 | 
					            sys::libvlc_free(p_str as *mut ::libc::c_void);
 | 
				
			||||||
            s
 | 
					            s
 | 
				
			||||||
| 
						 | 
					@ -95,26 +100,28 @@ impl Media {
 | 
				
			||||||
    /// (This function will not save the meta, call save_meta in order to save the meta)
 | 
					    /// (This function will not save the meta, call save_meta in order to save the meta)
 | 
				
			||||||
    pub fn set_meta(&self, meta: Meta, value: &str) {
 | 
					    pub fn set_meta(&self, meta: Meta, value: &str) {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            sys::libvlc_media_set_meta(self.ptr, meta, to_cstr(value).as_ptr());
 | 
					            sys::libvlc_media_set_meta(self.ptr, meta as u32, to_cstr(value).as_ptr());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Save the meta previously set.
 | 
					    /// Save the meta previously set.
 | 
				
			||||||
    pub fn save_meta(&self) -> bool {
 | 
					    pub fn save_meta(&self) -> bool {
 | 
				
			||||||
        if unsafe{ sys::libvlc_media_save_meta(self.ptr) } == 0 { false }else{ true }
 | 
					        (unsafe { sys::libvlc_media_save_meta(self.ptr) } != 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get current state of media descriptor object.
 | 
					    /// Get current state of media descriptor object.
 | 
				
			||||||
    pub fn state(&self) -> State {
 | 
					    pub fn state(&self) -> State {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_get_state(self.ptr) }
 | 
					        unsafe { sys::libvlc_media_get_state(self.ptr).into() }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get duration (in ms) of media descriptor object item.
 | 
					    /// Get duration (in ms) of media descriptor object item.
 | 
				
			||||||
    pub fn duration(&self) -> Option<i64> {
 | 
					    pub fn duration(&self) -> Option<i64> {
 | 
				
			||||||
        let time = unsafe{
 | 
					        let time = unsafe { sys::libvlc_media_get_duration(self.ptr) };
 | 
				
			||||||
            sys::libvlc_media_get_duration(self.ptr)
 | 
					        if time != -1 {
 | 
				
			||||||
        };
 | 
					            Some(time)
 | 
				
			||||||
        if time != -1 { Some(time) }else{ None }
 | 
					        } else {
 | 
				
			||||||
 | 
					            None
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Parse a media.
 | 
					    /// Parse a media.
 | 
				
			||||||
| 
						 | 
					@ -129,7 +136,7 @@ impl Media {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get Parsed status for media descriptor object.
 | 
					    /// Get Parsed status for media descriptor object.
 | 
				
			||||||
    pub fn is_parsed(&self) -> bool {
 | 
					    pub fn is_parsed(&self) -> bool {
 | 
				
			||||||
        if unsafe{ sys::libvlc_media_is_parsed(self.ptr) } == 0 { false }else{ true }
 | 
					        (unsafe { sys::libvlc_media_is_parsed(self.ptr) } != 0)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn tracks(&self) -> Option<Vec<MediaTrack>> {
 | 
					    pub fn tracks(&self) -> Option<Vec<MediaTrack>> {
 | 
				
			||||||
| 
						 | 
					@ -144,16 +151,17 @@ impl Media {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for i in 0..n {
 | 
					            for i in 0..n {
 | 
				
			||||||
                let p = p_track.offset(i as isize);
 | 
					                let p = p_track.offset(i as isize);
 | 
				
			||||||
                let type_specific_data = match (**p).i_type {
 | 
					                let i_type: TrackType = (**p).i_type.into();
 | 
				
			||||||
 | 
					                let type_specific_data = match i_type {
 | 
				
			||||||
                    TrackType::Audio => {
 | 
					                    TrackType::Audio => {
 | 
				
			||||||
                        let audio = (**p).audio();
 | 
					                        let audio = (**p).__bindgen_anon_1.audio;
 | 
				
			||||||
                        MediaTrackUnion::Audio(AudioTrack {
 | 
					                        MediaTrackUnion::Audio(AudioTrack {
 | 
				
			||||||
                            channels: (*audio).i_channels,
 | 
					                            channels: (*audio).i_channels,
 | 
				
			||||||
                            rate: (*audio).i_rate,
 | 
					                            rate: (*audio).i_rate,
 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
                    },
 | 
					                    }
 | 
				
			||||||
                    TrackType::Video => {
 | 
					                    TrackType::Video => {
 | 
				
			||||||
                        let video = (**p).video();
 | 
					                        let video = (**p).__bindgen_anon_1.video;
 | 
				
			||||||
                        MediaTrackUnion::Video(VideoTrack {
 | 
					                        MediaTrackUnion::Video(VideoTrack {
 | 
				
			||||||
                            height: (*video).i_height,
 | 
					                            height: (*video).i_height,
 | 
				
			||||||
                            width: (*video).i_width,
 | 
					                            width: (*video).i_width,
 | 
				
			||||||
| 
						 | 
					@ -162,26 +170,26 @@ impl Media {
 | 
				
			||||||
                            frame_rate_num: (*video).i_frame_rate_num,
 | 
					                            frame_rate_num: (*video).i_frame_rate_num,
 | 
				
			||||||
                            frame_rate_den: (*video).i_frame_rate_den,
 | 
					                            frame_rate_den: (*video).i_frame_rate_den,
 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
                    },
 | 
					                    }
 | 
				
			||||||
                    TrackType::Text => {
 | 
					                    TrackType::Text => {
 | 
				
			||||||
                        let subtitle = (**p).subtitle();
 | 
					                        let subtitle = (**p).__bindgen_anon_1.subtitle;
 | 
				
			||||||
                        MediaTrackUnion::Subtitle(SubtitleTrack {
 | 
					                        MediaTrackUnion::Subtitle(SubtitleTrack {
 | 
				
			||||||
                            encoding: from_cstr((*subtitle).psz_encoding)
 | 
					                            encoding: from_cstr((*subtitle).psz_encoding),
 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
                    },
 | 
					                    }
 | 
				
			||||||
                    TrackType::Unknown => MediaTrackUnion::None,
 | 
					                    TrackType::Unknown => MediaTrackUnion::None,
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                track.push(MediaTrack {
 | 
					                track.push(MediaTrack {
 | 
				
			||||||
                    codec: (**p).i_codec,
 | 
					                    codec: (**p).i_codec,
 | 
				
			||||||
                    original_fourcc: (**p).i_original_fourcc,
 | 
					                    original_fourcc: (**p).i_original_fourcc,
 | 
				
			||||||
                    id: (**p).i_id,
 | 
					                    id: (**p).i_id,
 | 
				
			||||||
                    track_type:         (**p).i_type,
 | 
					                    track_type: (**p).i_type.into(),
 | 
				
			||||||
                    profile: (**p).i_profile,
 | 
					                    profile: (**p).i_profile,
 | 
				
			||||||
                    level: (**p).i_level,
 | 
					                    level: (**p).i_level,
 | 
				
			||||||
                    bitrate: (**p).i_bitrate,
 | 
					                    bitrate: (**p).i_bitrate,
 | 
				
			||||||
                    language: from_cstr((**p).psz_language),
 | 
					                    language: from_cstr((**p).psz_language),
 | 
				
			||||||
                    description: from_cstr((**p).psz_description),
 | 
					                    description: from_cstr((**p).psz_description),
 | 
				
			||||||
                    type_specific_data: type_specific_data,
 | 
					                    type_specific_data,
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -218,7 +226,10 @@ pub struct MediaTrack {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
 | 
					#[derive(Clone, PartialEq, Eq, Hash, Debug)]
 | 
				
			||||||
pub enum MediaTrackUnion {
 | 
					pub enum MediaTrackUnion {
 | 
				
			||||||
    Audio(AudioTrack), Video(VideoTrack), Subtitle(SubtitleTrack), None,
 | 
					    Audio(AudioTrack),
 | 
				
			||||||
 | 
					    Video(VideoTrack),
 | 
				
			||||||
 | 
					    Subtitle(SubtitleTrack),
 | 
				
			||||||
 | 
					    None,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
					#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 | 
				
			||||||
| 
						 | 
					@ -241,4 +252,3 @@ pub struct VideoTrack {
 | 
				
			||||||
pub struct SubtitleTrack {
 | 
					pub struct SubtitleTrack {
 | 
				
			||||||
    pub encoding: Option<String>,
 | 
					    pub encoding: Option<String>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,8 +2,8 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::sys;
 | 
					use crate::{Instance, InternalError, MediaList};
 | 
				
			||||||
use crate::{Instance, MediaList};
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct MediaLibrary {
 | 
					pub struct MediaLibrary {
 | 
				
			||||||
    pub(crate) ptr: *mut sys::libvlc_media_library_t,
 | 
					    pub(crate) ptr: *mut sys::libvlc_media_library_t,
 | 
				
			||||||
| 
						 | 
					@ -11,17 +11,25 @@ pub struct MediaLibrary {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl MediaLibrary {
 | 
					impl MediaLibrary {
 | 
				
			||||||
    /// Create an new Media Library object.
 | 
					    /// Create an new Media Library object.
 | 
				
			||||||
    pub fn new(instance: &Instance) -> Option<MediaLibrary> {
 | 
					    pub fn new(instance: &Instance) -> Result<MediaLibrary, InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_library_new(instance.ptr);
 | 
					            let p = sys::libvlc_media_library_new(instance.ptr);
 | 
				
			||||||
            if p.is_null() { None }else{ Some(MediaLibrary{ptr: p}) }
 | 
					            if p.is_null() {
 | 
				
			||||||
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Ok(MediaLibrary { ptr: p })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Load media library.
 | 
					    /// Load media library.
 | 
				
			||||||
    pub fn load(&self) -> Result<(), ()> {
 | 
					    pub fn load(&self) -> Result<(), InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            if sys::libvlc_media_library_load(self.ptr) == 0 { Ok(()) }else{ Err(()) }
 | 
					            if sys::libvlc_media_library_load(self.ptr) == 0 {
 | 
				
			||||||
 | 
					                Ok(())
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +37,11 @@ impl MediaLibrary {
 | 
				
			||||||
    pub fn media_list(&self) -> Option<MediaList> {
 | 
					    pub fn media_list(&self) -> Option<MediaList> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_library_media_list(self.ptr);
 | 
					            let p = sys::libvlc_media_library_media_list(self.ptr);
 | 
				
			||||||
            if p.is_null() { None }else{ Some(MediaList{ptr: p}) }
 | 
					            if p.is_null() {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(MediaList { ptr: p })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,8 +2,8 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::sys;
 | 
					use crate::{EventManager, Instance, InternalError, Media};
 | 
				
			||||||
use crate::{Instance, Media, EventManager};
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct MediaList {
 | 
					pub struct MediaList {
 | 
				
			||||||
    pub(crate) ptr: *mut sys::libvlc_media_list_t,
 | 
					    pub(crate) ptr: *mut sys::libvlc_media_list_t,
 | 
				
			||||||
| 
						 | 
					@ -11,17 +11,23 @@ pub struct MediaList {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl MediaList {
 | 
					impl MediaList {
 | 
				
			||||||
    /// Create an empty media list.
 | 
					    /// Create an empty media list.
 | 
				
			||||||
    pub fn new(instance: &Instance) -> Option<MediaList> {
 | 
					    pub fn new(instance: &Instance) -> Result<MediaList, InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_list_new(instance.ptr);
 | 
					            let p = sys::libvlc_media_list_new(instance.ptr);
 | 
				
			||||||
            if p.is_null() { None }else{ Some(MediaList{ptr: p}) }
 | 
					            if p.is_null() {
 | 
				
			||||||
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Ok(MediaList { ptr: p })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Associate media instance with this media list instance.
 | 
					    /// Associate media instance with this media list instance.
 | 
				
			||||||
    /// If another media instance was present it will be released. The libvlc_media_list_lock should NOT be held upon entering this function.
 | 
					    /// If another media instance was present it will be released. The libvlc_media_list_lock should NOT be held upon entering this function.
 | 
				
			||||||
    pub fn set_media(&self, md: &Media) {
 | 
					    pub fn set_media(&self, md: &Media) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_list_set_media(self.ptr, md.ptr); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_list_set_media(self.ptr, md.ptr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get media instance from this media list instance.
 | 
					    /// Get media instance from this media list instance.
 | 
				
			||||||
| 
						 | 
					@ -29,31 +35,48 @@ impl MediaList {
 | 
				
			||||||
    pub fn media(&self) -> Option<Media> {
 | 
					    pub fn media(&self) -> Option<Media> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_list_media(self.ptr);
 | 
					            let p = sys::libvlc_media_list_media(self.ptr);
 | 
				
			||||||
            if p.is_null() { None }else{ Some(Media{ptr: p}) }
 | 
					            if p.is_null() {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(Media { ptr: p })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Add media instance to media list.
 | 
					    /// Add media instance to media list.
 | 
				
			||||||
    /// The MediaList::lock should be held upon entering this function.
 | 
					    /// The MediaList::lock should be held upon entering this function.
 | 
				
			||||||
    pub fn add_media(&self, md: &Media) -> Result<(), ()> {
 | 
					    // TODO: use specific error type since documentation says "-1 if the media list is read-only"
 | 
				
			||||||
 | 
					    pub fn add_media(&self, md: &Media) -> Result<(), InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            if sys::libvlc_media_list_add_media(self.ptr, md.ptr) == 0 { Ok(()) }else{ Err(()) }
 | 
					            if sys::libvlc_media_list_add_media(self.ptr, md.ptr) == 0 {
 | 
				
			||||||
 | 
					                Ok(())
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Insert media instance in media list on a position.
 | 
					    /// Insert media instance in media list on a position.
 | 
				
			||||||
    /// The MediaList::lock should be held upon entering this function.
 | 
					    /// The MediaList::lock should be held upon entering this function.
 | 
				
			||||||
    pub fn insert_media(&self, md: &Media, pos: i32) -> Result<(), ()> {
 | 
					    pub fn insert_media(&self, md: &Media, pos: i32) -> Result<(), InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            if sys::libvlc_media_list_insert_media(self.ptr, md.ptr, pos) == 0 { Ok(()) }else{ Err(()) }
 | 
					            if sys::libvlc_media_list_insert_media(self.ptr, md.ptr, pos) == 0 {
 | 
				
			||||||
 | 
					                Ok(())
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Remove media instance from media list on a position.
 | 
					    /// Remove media instance from media list on a position.
 | 
				
			||||||
    /// The MediaList::lock should be held upon entering this function.
 | 
					    /// The MediaList::lock should be held upon entering this function.
 | 
				
			||||||
    pub fn remove_index(&self, pos: i32) -> Result<(), ()> {
 | 
					    pub fn remove_index(&self, pos: i32) -> Result<(), InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            if sys::libvlc_media_list_remove_index(self.ptr, pos) == 0 { Ok(()) }else{ Err(()) }
 | 
					            if sys::libvlc_media_list_remove_index(self.ptr, pos) == 0 {
 | 
				
			||||||
 | 
					                Ok(())
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Err(InternalError)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +91,11 @@ impl MediaList {
 | 
				
			||||||
    pub fn item_at_index(&self, pos: i32) -> Option<Media> {
 | 
					    pub fn item_at_index(&self, pos: i32) -> Option<Media> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_list_item_at_index(self.ptr, pos);
 | 
					            let p = sys::libvlc_media_list_item_at_index(self.ptr, pos);
 | 
				
			||||||
            if p.is_null() { None }else{ Some(Media{ptr: p}) }
 | 
					            if p.is_null() {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(Media { ptr: p })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,24 +103,32 @@ impl MediaList {
 | 
				
			||||||
    pub fn index_of_item(&self, md: &Media) -> Option<i32> {
 | 
					    pub fn index_of_item(&self, md: &Media) -> Option<i32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let i = sys::libvlc_media_list_index_of_item(self.ptr, md.ptr);
 | 
					            let i = sys::libvlc_media_list_index_of_item(self.ptr, md.ptr);
 | 
				
			||||||
            if i == -1 { None }else{ Some(i) }
 | 
					            if i == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(i)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// This indicates if this media list is read-only from a user point of view.
 | 
					    /// This indicates if this media list is read-only from a user point of view.
 | 
				
			||||||
    pub fn is_readonly(&self) -> bool {
 | 
					    pub fn is_readonly(&self) -> bool {
 | 
				
			||||||
        unsafe{ if sys::libvlc_media_list_is_readonly(self.ptr) == 0 { false }else{ true } }
 | 
					        unsafe { sys::libvlc_media_list_is_readonly(self.ptr) != 0 }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get lock on media list items
 | 
					    /// Get lock on media list items
 | 
				
			||||||
    pub fn lock(&self) {
 | 
					    pub fn lock(&self) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_list_lock(self.ptr); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_list_lock(self.ptr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Release lock on media list items
 | 
					    /// Release lock on media list items
 | 
				
			||||||
    /// The libvlc_media_list_lock should be held upon entering this function.
 | 
					    /// The libvlc_media_list_lock should be held upon entering this function.
 | 
				
			||||||
    pub fn unlock(&self) {
 | 
					    pub fn unlock(&self) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_list_unlock(self.ptr); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_list_unlock(self.ptr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get EventManager from this media list instance.
 | 
					    /// Get EventManager from this media list instance.
 | 
				
			||||||
| 
						 | 
					@ -101,7 +136,10 @@ impl MediaList {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_list_event_manager(self.ptr);
 | 
					            let p = sys::libvlc_media_list_event_manager(self.ptr);
 | 
				
			||||||
            assert!(!p.is_null());
 | 
					            assert!(!p.is_null());
 | 
				
			||||||
            EventManager{ptr: p, _phantomdata: ::std::marker::PhantomData}
 | 
					            EventManager {
 | 
				
			||||||
 | 
					                ptr: p,
 | 
				
			||||||
 | 
					                _phantomdata: ::std::marker::PhantomData,
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,13 +2,14 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::sys;
 | 
					use crate::enums::{Position, State};
 | 
				
			||||||
use crate::Instance;
 | 
					 | 
				
			||||||
use crate::Media;
 | 
					 | 
				
			||||||
use crate::EventManager;
 | 
					use crate::EventManager;
 | 
				
			||||||
use libc::{c_void, c_uint};
 | 
					use crate::Instance;
 | 
				
			||||||
use crate::enums::{State, Position};
 | 
					use crate::InternalError;
 | 
				
			||||||
 | 
					use crate::Media;
 | 
				
			||||||
 | 
					use libc::{c_uint, c_void};
 | 
				
			||||||
use std::mem::transmute;
 | 
					use std::mem::transmute;
 | 
				
			||||||
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// A LibVLC media player plays one media (usually in a custom drawable).
 | 
					/// A LibVLC media player plays one media (usually in a custom drawable).
 | 
				
			||||||
pub struct MediaPlayer {
 | 
					pub struct MediaPlayer {
 | 
				
			||||||
| 
						 | 
					@ -22,13 +23,13 @@ impl MediaPlayer {
 | 
				
			||||||
    pub fn new(instance: &Instance) -> Option<MediaPlayer> {
 | 
					    pub fn new(instance: &Instance) -> Option<MediaPlayer> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_player_new(instance.ptr);
 | 
					            let p = sys::libvlc_media_player_new(instance.ptr);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if p.is_null() {
 | 
					            if p.is_null() {
 | 
				
			||||||
                return None;
 | 
					                None
 | 
				
			||||||
            }
 | 
					            } else {
 | 
				
			||||||
                Some(MediaPlayer { ptr: p })
 | 
					                Some(MediaPlayer { ptr: p })
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the media that will be used by the media_player. If any, previous md will be released.
 | 
					    /// Set the media that will be used by the media_player. If any, previous md will be released.
 | 
				
			||||||
    pub fn set_media(&self, md: &Media) {
 | 
					    pub fn set_media(&self, md: &Media) {
 | 
				
			||||||
| 
						 | 
					@ -50,25 +51,24 @@ impl MediaPlayer {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_media_player_event_manager(self.ptr);
 | 
					            let p = sys::libvlc_media_player_event_manager(self.ptr);
 | 
				
			||||||
            assert!(!p.is_null());
 | 
					            assert!(!p.is_null());
 | 
				
			||||||
            EventManager{ptr: p, _phantomdata: ::std::marker::PhantomData}
 | 
					            EventManager {
 | 
				
			||||||
 | 
					                ptr: p,
 | 
				
			||||||
 | 
					                _phantomdata: ::std::marker::PhantomData,
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// is_playing
 | 
					    /// is_playing
 | 
				
			||||||
    pub fn is_playing(&self) -> bool {
 | 
					    pub fn is_playing(&self) -> bool {
 | 
				
			||||||
        if unsafe{ sys::libvlc_media_player_is_playing(self.ptr) } == 0 {
 | 
					        unsafe { sys::libvlc_media_player_is_playing(self.ptr) != 0 }
 | 
				
			||||||
            false
 | 
					 | 
				
			||||||
        }else{
 | 
					 | 
				
			||||||
            true
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Play
 | 
					    /// Play
 | 
				
			||||||
    pub fn play(&self) -> Result<(), ()> {
 | 
					    pub fn play(&self) -> Result<(), InternalError> {
 | 
				
			||||||
        if unsafe { sys::libvlc_media_player_play(self.ptr) } == 0 {
 | 
					        if unsafe { sys::libvlc_media_player_play(self.ptr) } == 0 {
 | 
				
			||||||
            Ok(())
 | 
					            Ok(())
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Err(())
 | 
					            Err(InternalError)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -93,8 +93,9 @@ impl MediaPlayer {
 | 
				
			||||||
        pause: Option<Box<dyn Fn(i64) + Send + 'static>>,
 | 
					        pause: Option<Box<dyn Fn(i64) + Send + 'static>>,
 | 
				
			||||||
        resume: Option<Box<dyn Fn(i64) + Send + 'static>>,
 | 
					        resume: Option<Box<dyn Fn(i64) + Send + 'static>>,
 | 
				
			||||||
        flush: Option<Box<dyn Fn(i64) + Send + 'static>>,
 | 
					        flush: Option<Box<dyn Fn(i64) + Send + 'static>>,
 | 
				
			||||||
        drain: Option<Box<dyn Fn() + Send + 'static>>)
 | 
					        drain: Option<Box<dyn Fn() + Send + 'static>>,
 | 
				
			||||||
        where F: Fn(*const c_void, u32, i64) + Send + 'static,
 | 
					    ) where
 | 
				
			||||||
 | 
					        F: Fn(*const c_void, u32, i64) + Send + 'static,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        let flag_pause = pause.is_some();
 | 
					        let flag_pause = pause.is_some();
 | 
				
			||||||
        let flag_resume = resume.is_some();
 | 
					        let flag_resume = resume.is_some();
 | 
				
			||||||
| 
						 | 
					@ -102,8 +103,11 @@ impl MediaPlayer {
 | 
				
			||||||
        let flag_drain = drain.is_some();
 | 
					        let flag_drain = drain.is_some();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let data = AudioCallbacksData {
 | 
					        let data = AudioCallbacksData {
 | 
				
			||||||
            play: Box::new(play), pause: pause, resume: resume,
 | 
					            play: Box::new(play),
 | 
				
			||||||
            flush: flush, drain: drain,
 | 
					            pause,
 | 
				
			||||||
 | 
					            resume,
 | 
				
			||||||
 | 
					            flush,
 | 
				
			||||||
 | 
					            drain,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        let data = Box::into_raw(Box::new(data));
 | 
					        let data = Box::into_raw(Box::new(data));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,23 +115,45 @@ impl MediaPlayer {
 | 
				
			||||||
            sys::libvlc_audio_set_callbacks(
 | 
					            sys::libvlc_audio_set_callbacks(
 | 
				
			||||||
                self.ptr,
 | 
					                self.ptr,
 | 
				
			||||||
                Some(audio_cb_play),
 | 
					                Some(audio_cb_play),
 | 
				
			||||||
                if flag_pause {Some(audio_cb_pause)} else {None},
 | 
					                if flag_pause {
 | 
				
			||||||
                if flag_resume {Some(audio_cb_resume)} else {None},
 | 
					                    Some(audio_cb_pause)
 | 
				
			||||||
                if flag_flush {Some(audio_cb_flush)} else {None},
 | 
					                } else {
 | 
				
			||||||
                if flag_drain {Some(audio_cb_drain)} else {None},
 | 
					                    None
 | 
				
			||||||
                data as *mut c_void);
 | 
					                },
 | 
				
			||||||
 | 
					                if flag_resume {
 | 
				
			||||||
 | 
					                    Some(audio_cb_resume)
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    None
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                if flag_flush {
 | 
				
			||||||
 | 
					                    Some(audio_cb_flush)
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    None
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                if flag_drain {
 | 
				
			||||||
 | 
					                    Some(audio_cb_drain)
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    None
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                data as *mut c_void,
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the NSView handler where the media player should render its video output.
 | 
					    /// Set the NSView handler where the media player should render its video output.
 | 
				
			||||||
    pub fn set_nsobject(&self, drawable: *mut c_void) {
 | 
					    pub fn set_nsobject(&self, drawable: *mut c_void) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_set_nsobject(self.ptr, drawable) };
 | 
					        let d = drawable;
 | 
				
			||||||
 | 
					        unsafe { sys::libvlc_media_player_set_nsobject(self.ptr, d) };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get the NSView handler previously set with set_nsobject().
 | 
					    /// Get the NSView handler previously set with set_nsobject().
 | 
				
			||||||
    pub fn get_nsobject(&self) -> Option<*mut c_void> {
 | 
					    pub fn get_nsobject(&self) -> Option<*mut c_void> {
 | 
				
			||||||
        let nso = unsafe { sys::libvlc_media_player_get_nsobject(self.ptr) };
 | 
					        let nso = unsafe { sys::libvlc_media_player_get_nsobject(self.ptr) };
 | 
				
			||||||
        if nso.is_null() { None }else{ Some(nso) }
 | 
					        if nso.is_null() {
 | 
				
			||||||
 | 
					            None
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Some(nso)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set an X Window System drawable where the media player should render its video output.
 | 
					    /// Set an X Window System drawable where the media player should render its video output.
 | 
				
			||||||
| 
						 | 
					@ -138,59 +164,87 @@ impl MediaPlayer {
 | 
				
			||||||
    /// Get the X Window System window identifier previously set with set_xwindow().
 | 
					    /// Get the X Window System window identifier previously set with set_xwindow().
 | 
				
			||||||
    pub fn get_xwindow(&self) -> Option<u32> {
 | 
					    pub fn get_xwindow(&self) -> Option<u32> {
 | 
				
			||||||
        let id = unsafe { sys::libvlc_media_player_get_xwindow(self.ptr) };
 | 
					        let id = unsafe { sys::libvlc_media_player_get_xwindow(self.ptr) };
 | 
				
			||||||
        if id == 0 { None }else{ Some(id) }
 | 
					        if id == 0 {
 | 
				
			||||||
 | 
					            None
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Some(id)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set a Win32/Win64 API window handle (HWND) where the media player should render its video output.
 | 
					    /// Set a Win32/Win64 API window handle (HWND) where the media player should render its video output.
 | 
				
			||||||
    /// If LibVLC was built without Win32/Win64 API output support, then this has no effects.
 | 
					    /// If LibVLC was built without Win32/Win64 API output support, then this has no effects.
 | 
				
			||||||
    pub fn set_hwnd(&self, drawable: *mut c_void) {
 | 
					    pub fn set_hwnd(&self, drawable: *mut c_void) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_set_hwnd(self.ptr, drawable) };
 | 
					        let d = drawable;
 | 
				
			||||||
 | 
					        unsafe { sys::libvlc_media_player_set_hwnd(self.ptr, d) };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get the Windows API window handle (HWND) previously set with set_hwnd().
 | 
					    /// Get the Windows API window handle (HWND) previously set with set_hwnd().
 | 
				
			||||||
    pub fn get_hwnd(&self) -> Option<*mut c_void> {
 | 
					    pub fn get_hwnd(&self) -> Option<*mut c_void> {
 | 
				
			||||||
        let hwnd = unsafe { sys::libvlc_media_player_get_hwnd(self.ptr) };
 | 
					        let hwnd = unsafe { sys::libvlc_media_player_get_hwnd(self.ptr) };
 | 
				
			||||||
        if hwnd.is_null() { None }else{ Some(hwnd) }
 | 
					        if hwnd.is_null() {
 | 
				
			||||||
 | 
					            None
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Some(hwnd)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get the current movie time (in ms).
 | 
					    /// Get the current movie time (in ms).
 | 
				
			||||||
    pub fn get_time(&self) -> Option<i64> {
 | 
					    pub fn get_time(&self) -> Option<i64> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let t = sys::libvlc_media_player_get_time(self.ptr);
 | 
					            let t = sys::libvlc_media_player_get_time(self.ptr);
 | 
				
			||||||
            if t == -1 { None }else{ Some(t) }
 | 
					            if t == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(t)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the movie time (in ms).
 | 
					    /// Set the movie time (in ms).
 | 
				
			||||||
    /// This has no effect if no media is being played. Not all formats and protocols support this.
 | 
					    /// This has no effect if no media is being played. Not all formats and protocols support this.
 | 
				
			||||||
    pub fn set_time(&self, time: i64) {
 | 
					    pub fn set_time(&self, time: i64) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_set_time(self.ptr, time); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_set_time(self.ptr, time);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get movie position as percentage between 0.0 and 1.0.
 | 
					    /// Get movie position as percentage between 0.0 and 1.0.
 | 
				
			||||||
    pub fn get_position(&self) -> Option<f32> {
 | 
					    pub fn get_position(&self) -> Option<f32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let pos = sys::libvlc_media_player_get_position(self.ptr);
 | 
					            let pos = sys::libvlc_media_player_get_position(self.ptr);
 | 
				
			||||||
            if pos == -1f32 { None }else{ Some(pos) }
 | 
					            // if pos == -1f32 { None }else{ Some(pos) }
 | 
				
			||||||
 | 
					            if (pos - -1f32).abs() < f32::EPSILON {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(pos)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set movie position as percentage between 0.0 and 1.0.
 | 
					    /// Set movie position as percentage between 0.0 and 1.0.
 | 
				
			||||||
    /// This has no effect if playback is not enabled. This might not work depending on the underlying input format and protocol.
 | 
					    /// This has no effect if playback is not enabled. This might not work depending on the underlying input format and protocol.
 | 
				
			||||||
    pub fn set_position(&self, pos: f32) {
 | 
					    pub fn set_position(&self, pos: f32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_set_position(self.ptr, pos); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_set_position(self.ptr, pos);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set movie chapter (if applicable).
 | 
					    /// Set movie chapter (if applicable).
 | 
				
			||||||
    pub fn set_chapter(&self, chapter: i32) {
 | 
					    pub fn set_chapter(&self, chapter: i32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_set_chapter(self.ptr, chapter); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_set_chapter(self.ptr, chapter);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get movie chapter.
 | 
					    /// Get movie chapter.
 | 
				
			||||||
    pub fn get_chapter(&self) -> Option<i32> {
 | 
					    pub fn get_chapter(&self) -> Option<i32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let c = sys::libvlc_media_player_get_chapter(self.ptr);
 | 
					            let c = sys::libvlc_media_player_get_chapter(self.ptr);
 | 
				
			||||||
            if c == -1 { None }else{ Some(c) }
 | 
					            if c == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(c)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -198,36 +252,47 @@ impl MediaPlayer {
 | 
				
			||||||
    pub fn chapter_count(&self) -> Option<i32> {
 | 
					    pub fn chapter_count(&self) -> Option<i32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let c = sys::libvlc_media_player_get_chapter_count(self.ptr);
 | 
					            let c = sys::libvlc_media_player_get_chapter_count(self.ptr);
 | 
				
			||||||
            if c == -1 { None }else{ Some(c) }
 | 
					            if c == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(c)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Is the player able to play.
 | 
					    /// Is the player able to play.
 | 
				
			||||||
    pub fn will_play(&self) -> bool {
 | 
					    pub fn will_play(&self) -> bool {
 | 
				
			||||||
        unsafe{
 | 
					        unsafe { sys::libvlc_media_player_will_play(self.ptr) != 0 }
 | 
				
			||||||
            let b = sys::libvlc_media_player_will_play(self.ptr);
 | 
					 | 
				
			||||||
            if b == 0 { false }else{ true }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get title chapter count.
 | 
					    /// Get title chapter count.
 | 
				
			||||||
    pub fn chapter_count_for_title(&self, title: i32) -> Option<i32> {
 | 
					    pub fn chapter_count_for_title(&self, title: i32) -> Option<i32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let c = sys::libvlc_media_player_get_chapter_count_for_title(self.ptr, title);
 | 
					            let c = sys::libvlc_media_player_get_chapter_count_for_title(self.ptr, title);
 | 
				
			||||||
            if c == -1 { None }else{ Some(c) }
 | 
					            if c == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(c)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set movie title.
 | 
					    /// Set movie title.
 | 
				
			||||||
    pub fn set_title(&self, title: i32) {
 | 
					    pub fn set_title(&self, title: i32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_set_title(self.ptr, title); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_set_title(self.ptr, title);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get movie title.
 | 
					    /// Get movie title.
 | 
				
			||||||
    pub fn get_title(&self) -> Option<i32> {
 | 
					    pub fn get_title(&self) -> Option<i32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let t = sys::libvlc_media_player_get_title(self.ptr);
 | 
					            let t = sys::libvlc_media_player_get_title(self.ptr);
 | 
				
			||||||
            if t == -1 { None }else{ Some(t) }
 | 
					            if t == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(t)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -235,18 +300,26 @@ impl MediaPlayer {
 | 
				
			||||||
    pub fn title_count(&self) -> Option<i32> {
 | 
					    pub fn title_count(&self) -> Option<i32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let t = sys::libvlc_media_player_get_title_count(self.ptr);
 | 
					            let t = sys::libvlc_media_player_get_title_count(self.ptr);
 | 
				
			||||||
            if t == -1 { Some(t) } else { None }
 | 
					            if t == -1 {
 | 
				
			||||||
 | 
					                Some(t)
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set previous chapter (if applicable)
 | 
					    /// Set previous chapter (if applicable)
 | 
				
			||||||
    pub fn previous_chapter(&self) {
 | 
					    pub fn previous_chapter(&self) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_previous_chapter(self.ptr); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_previous_chapter(self.ptr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set next chapter (if applicable)
 | 
					    /// Set next chapter (if applicable)
 | 
				
			||||||
    pub fn next_chapter(&self) {
 | 
					    pub fn next_chapter(&self) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_next_chapter(self.ptr); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_next_chapter(self.ptr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get the requested movie play rate.
 | 
					    /// Get the requested movie play rate.
 | 
				
			||||||
| 
						 | 
					@ -255,10 +328,10 @@ impl MediaPlayer {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set movie play rate.
 | 
					    /// Set movie play rate.
 | 
				
			||||||
    pub fn set_rate(&self, rate: f32) -> Result<(),()> {
 | 
					    pub fn set_rate(&self, rate: f32) -> Result<(), InternalError> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            if sys::libvlc_media_player_set_rate(self.ptr, rate) == -1 {
 | 
					            if sys::libvlc_media_player_set_rate(self.ptr, rate) == -1 {
 | 
				
			||||||
                Err(())
 | 
					                Err(InternalError)
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                Ok(())
 | 
					                Ok(())
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -267,7 +340,7 @@ impl MediaPlayer {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Get current movie state.
 | 
					    /// Get current movie state.
 | 
				
			||||||
    pub fn state(&self) -> State {
 | 
					    pub fn state(&self) -> State {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_get_state(self.ptr) }
 | 
					        unsafe { sys::libvlc_media_player_get_state(self.ptr) }.into()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// How many video outputs does this media player have?
 | 
					    /// How many video outputs does this media player have?
 | 
				
			||||||
| 
						 | 
					@ -277,41 +350,38 @@ impl MediaPlayer {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Is this media player seekable?
 | 
					    /// Is this media player seekable?
 | 
				
			||||||
    pub fn is_seekable(&self) -> bool {
 | 
					    pub fn is_seekable(&self) -> bool {
 | 
				
			||||||
        unsafe{
 | 
					        unsafe { sys::libvlc_media_player_is_seekable(self.ptr) != 0 }
 | 
				
			||||||
            let b = sys::libvlc_media_player_is_seekable(self.ptr);
 | 
					 | 
				
			||||||
            if b == 0 { false }else{ true }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Can this media player be paused?
 | 
					    /// Can this media player be paused?
 | 
				
			||||||
    pub fn can_pause(&self) -> bool {
 | 
					    pub fn can_pause(&self) -> bool {
 | 
				
			||||||
        unsafe{
 | 
					        unsafe { sys::libvlc_media_player_can_pause(self.ptr) != 0 }
 | 
				
			||||||
            let b = sys::libvlc_media_player_can_pause(self.ptr);
 | 
					 | 
				
			||||||
            if b == 0 { false }else{ true }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Check if the current program is scrambled.
 | 
					    /// Check if the current program is scrambled.
 | 
				
			||||||
    pub fn program_scrambled(&self) -> bool {
 | 
					    pub fn program_scrambled(&self) -> bool {
 | 
				
			||||||
        unsafe{
 | 
					        unsafe { sys::libvlc_media_player_program_scrambled(self.ptr) != 0 }
 | 
				
			||||||
            let b = sys::libvlc_media_player_program_scrambled(self.ptr);
 | 
					 | 
				
			||||||
            if b == 0 { false }else{ true }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Display the next frame (if supported)
 | 
					    /// Display the next frame (if supported)
 | 
				
			||||||
    pub fn next_frame(&self) {
 | 
					    pub fn next_frame(&self) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_next_frame(self.ptr); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_next_frame(self.ptr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Navigate through DVD Menu.
 | 
					    /// Navigate through DVD Menu.
 | 
				
			||||||
    pub fn navigate(&self, navigate: u32) {
 | 
					    pub fn navigate(&self, navigate: u32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_navigate(self.ptr, navigate); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_navigate(self.ptr, navigate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set if, and how, the video title will be shown when media is played.
 | 
					    /// Set if, and how, the video title will be shown when media is played.
 | 
				
			||||||
    pub fn set_video_title_display(&self, position: Position, timeout: u32) {
 | 
					    pub fn set_video_title_display(&self, position: Position, timeout: u32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_media_player_set_video_title_display(self.ptr, position, timeout); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_media_player_set_video_title_display(self.ptr, position as i32, timeout);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns raw pointer
 | 
					    /// Returns raw pointer
 | 
				
			||||||
| 
						 | 
					@ -336,10 +406,13 @@ struct AudioCallbacksData {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsafe extern "C" fn audio_cb_play(
 | 
					unsafe extern "C" fn audio_cb_play(
 | 
				
			||||||
    data: *mut c_void, samples: *const c_void, count: c_uint, pts: i64) {
 | 
					    data: *mut c_void,
 | 
				
			||||||
 | 
					    samples: *const c_void,
 | 
				
			||||||
 | 
					    count: c_uint,
 | 
				
			||||||
 | 
					    pts: i64,
 | 
				
			||||||
 | 
					) {
 | 
				
			||||||
    let data: &AudioCallbacksData = transmute(data as *mut AudioCallbacksData);
 | 
					    let data: &AudioCallbacksData = transmute(data as *mut AudioCallbacksData);
 | 
				
			||||||
    (data.play)(samples, count, pts);
 | 
					    (data.play)(samples, count, pts);
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsafe extern "C" fn audio_cb_pause(data: *mut c_void, pts: i64) {
 | 
					unsafe extern "C" fn audio_cb_pause(data: *mut c_void, pts: i64) {
 | 
				
			||||||
| 
						 | 
					@ -367,4 +440,3 @@ pub struct TrackDescription {
 | 
				
			||||||
    pub id: i32,
 | 
					    pub id: i32,
 | 
				
			||||||
    pub name: Option<String>,
 | 
					    pub name: Option<String>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										853
									
								
								src/sys.rs
								
								
								
								
							
							
						
						
									
										853
									
								
								src/sys.rs
								
								
								
								
							| 
						 | 
					@ -1,853 +0,0 @@
 | 
				
			||||||
// Copyright (c) 2015 T. Okubo
 | 
					 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#![allow(non_camel_case_types, non_upper_case_globals)]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[link(name = "vlc")]
 | 
					 | 
				
			||||||
extern "C" {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use libc::{c_void, c_int, c_uint, c_char, c_float, uintptr_t, FILE};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub type c_bool = u8;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub type libvlc_event_type_t = c_int;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_structures.h
 | 
					 | 
				
			||||||
pub enum libvlc_instance_t {}
 | 
					 | 
				
			||||||
pub enum libvlc_log_iterator_t {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub type libvlc_time_t = i64;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_log_message_t {
 | 
					 | 
				
			||||||
    pub i_severity: c_int,
 | 
					 | 
				
			||||||
    pub psz_type: *const c_char,
 | 
					 | 
				
			||||||
    pub psz_name: *const c_char,
 | 
					 | 
				
			||||||
    pub psz_header: *const c_char,
 | 
					 | 
				
			||||||
    pub psz_message: *const c_char,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc.h
 | 
					 | 
				
			||||||
pub enum libvlc_event_manager_t {}
 | 
					 | 
				
			||||||
pub enum libvlc_log_t {}
 | 
					 | 
				
			||||||
pub enum vlc_log_t {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub type libvlc_callback_t = unsafe extern "C" fn(*const libvlc_event_t, *mut c_void);
 | 
					 | 
				
			||||||
pub type va_list = *mut c_void;
 | 
					 | 
				
			||||||
pub type libvlc_log_cb = unsafe extern "C" fn(*mut c_void, c_int, *const libvlc_log_t, *const c_char, va_list);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub use crate::enums::LogLevel as libvlc_log_level;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_module_description_t
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    pub psz_name: *const c_char,
 | 
					 | 
				
			||||||
    pub psz_shortname: *const c_char,
 | 
					 | 
				
			||||||
    pub psz_longname: *const c_char,
 | 
					 | 
				
			||||||
    pub psz_help: *const c_char,
 | 
					 | 
				
			||||||
    pub p_next: *mut libvlc_module_description_t,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    pub fn libvlc_errmsg() -> *const c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_clearerr();
 | 
					 | 
				
			||||||
    pub fn libvlc_new(argc: c_int, argv: *const *const c_char) -> *mut libvlc_instance_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_release(p_instance: *mut libvlc_instance_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_retain(p_instance: *mut libvlc_instance_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_add_intf(p_instance: *mut libvlc_instance_t, name: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_set_exit_handler(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t,
 | 
					 | 
				
			||||||
        cb: extern "C" fn(*mut c_void), opaque: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_wait(p_instance: *mut libvlc_instance_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_set_user_agent(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, name: *const c_char, http: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_set_app_id(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, id: *const c_char, version: *const c_char,
 | 
					 | 
				
			||||||
        icon: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_get_version() -> *const c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_get_compiler() -> *const c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_get_changeset() -> *const c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_free(ptr: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_event_attach(
 | 
					 | 
				
			||||||
        p_event_manager: *mut libvlc_event_manager_t, i_event_type: libvlc_event_type_t,
 | 
					 | 
				
			||||||
        f_callback: libvlc_callback_t, user_data: *mut c_void) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_event_type_name(event_type: libvlc_event_type_t) -> *const c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_log_get_context(
 | 
					 | 
				
			||||||
        ctx: *const libvlc_log_t, module: *const *const c_char, file: *const *const c_char,
 | 
					 | 
				
			||||||
        line: *mut c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_log_get_object(
 | 
					 | 
				
			||||||
        ctx: *const libvlc_log_t, name: *const *const c_char,
 | 
					 | 
				
			||||||
        header: *const *const c_char, id: *mut uintptr_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_log_unset(_: *mut libvlc_instance_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_log_set(instance: *mut libvlc_instance_t, cb: libvlc_log_cb, data: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_log_set_file(_: *mut libvlc_instance_t, stream: *mut FILE);
 | 
					 | 
				
			||||||
    pub fn libvlc_module_description_list_release(p_list: *mut libvlc_module_description_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_filter_list_get(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t) -> *mut libvlc_module_description_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_filter_list_get(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t) -> *mut libvlc_module_description_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_clock() -> i64;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub unsafe fn libvlc_delay(pts: i64) -> i64 {
 | 
					 | 
				
			||||||
    pts - libvlc_clock()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_media.h
 | 
					 | 
				
			||||||
pub enum libvlc_media_t {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub use crate::enums::Meta as libvlc_meta_t;
 | 
					 | 
				
			||||||
pub use crate::enums::State as libvlc_state_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub const libvlc_media_option_trusted: u32 = 0x2;
 | 
					 | 
				
			||||||
pub const libvlc_media_option_unique: u32 = 0x100;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub use crate::enums::TrackType as libvlc_track_type_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_media_stats_t {
 | 
					 | 
				
			||||||
    /* Input */
 | 
					 | 
				
			||||||
    pub i_read_bytes: c_int,
 | 
					 | 
				
			||||||
    pub f_input_bitrate: c_float,
 | 
					 | 
				
			||||||
    /* Demux */
 | 
					 | 
				
			||||||
    pub i_demux_read_bytes: c_int,
 | 
					 | 
				
			||||||
    pub f_demux_bitrate: c_float,
 | 
					 | 
				
			||||||
    pub i_demux_corrupted: c_int,
 | 
					 | 
				
			||||||
    pub i_demux_discontinuity: c_int,
 | 
					 | 
				
			||||||
    /* Decoders */
 | 
					 | 
				
			||||||
    pub i_decoded_video: c_int,
 | 
					 | 
				
			||||||
    pub i_decoded_audio: c_int,
 | 
					 | 
				
			||||||
    /* Video Output */
 | 
					 | 
				
			||||||
    pub i_displayed_pictures: c_int,
 | 
					 | 
				
			||||||
    pub i_lost_pictures: c_int,
 | 
					 | 
				
			||||||
    /* Audio output */
 | 
					 | 
				
			||||||
    pub i_played_abuffers: c_int,
 | 
					 | 
				
			||||||
    pub i_lost_abuffers: c_int,
 | 
					 | 
				
			||||||
    /* Stream output */
 | 
					 | 
				
			||||||
    pub i_sent_packets: c_int,
 | 
					 | 
				
			||||||
    pub i_sent_bytes: c_int,
 | 
					 | 
				
			||||||
    pub f_send_bitrate: c_float,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_media_track_info_t {
 | 
					 | 
				
			||||||
    /* Codec fourcc */
 | 
					 | 
				
			||||||
    pub i_codec: u32,
 | 
					 | 
				
			||||||
    pub i_id: c_int,
 | 
					 | 
				
			||||||
    pub i_type: libvlc_track_type_t,
 | 
					 | 
				
			||||||
    /* Codec specific */
 | 
					 | 
				
			||||||
    pub i_profile: c_int,
 | 
					 | 
				
			||||||
    pub i_level: c_int,
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    pub u: libvlc_media_track_info_t_types::u,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub mod libvlc_media_track_info_t_types {
 | 
					 | 
				
			||||||
    use libc::c_uint;
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub union u {
 | 
					 | 
				
			||||||
        pub audio: audio,
 | 
					 | 
				
			||||||
        pub video: video,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct audio {
 | 
					 | 
				
			||||||
        pub i_channels: c_uint,
 | 
					 | 
				
			||||||
        pub i_rate: c_uint,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct video {
 | 
					 | 
				
			||||||
        pub i_height: c_uint,
 | 
					 | 
				
			||||||
        pub i_width: c_uint,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_audio_track_t
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    pub i_channels: c_uint,
 | 
					 | 
				
			||||||
    pub i_rate: c_uint,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
pub struct libvlc_video_track_t
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    pub i_height: c_uint,
 | 
					 | 
				
			||||||
    pub i_width: c_uint,
 | 
					 | 
				
			||||||
    pub i_sar_num: c_uint,
 | 
					 | 
				
			||||||
    pub i_sar_den: c_uint,
 | 
					 | 
				
			||||||
    pub i_frame_rate_num: c_uint,
 | 
					 | 
				
			||||||
    pub i_frame_rate_den: c_uint,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_subtitle_track_t {
 | 
					 | 
				
			||||||
    pub psz_encoding: *const c_char,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_media_track_t {
 | 
					 | 
				
			||||||
    pub i_codec: u32,
 | 
					 | 
				
			||||||
    pub i_original_fourcc: u32,
 | 
					 | 
				
			||||||
    pub i_id: c_int,
 | 
					 | 
				
			||||||
    pub i_type: libvlc_track_type_t,
 | 
					 | 
				
			||||||
    pub i_profile: c_int,
 | 
					 | 
				
			||||||
    pub i_level: c_int,
 | 
					 | 
				
			||||||
    pub u: libvlc_media_track_t_types::u,
 | 
					 | 
				
			||||||
    pub i_bitrate: c_uint,
 | 
					 | 
				
			||||||
    pub psz_language: *mut c_char,
 | 
					 | 
				
			||||||
    pub psz_description: *mut c_char,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub mod libvlc_media_track_t_types {
 | 
					 | 
				
			||||||
    use super::*;
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub union u {
 | 
					 | 
				
			||||||
        pub audio: *mut libvlc_audio_track_t,
 | 
					 | 
				
			||||||
        pub video: *mut libvlc_video_track_t,
 | 
					 | 
				
			||||||
        pub subtitle: *mut libvlc_subtitle_track_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl libvlc_media_track_t {
 | 
					 | 
				
			||||||
    pub unsafe fn audio(&self) -> *mut libvlc_audio_track_t {
 | 
					 | 
				
			||||||
        self.u.audio
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    pub unsafe fn video(&self) -> *mut libvlc_video_track_t {
 | 
					 | 
				
			||||||
        self.u.video
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    pub unsafe fn subtitle(&self) -> *mut libvlc_subtitle_track_t {
 | 
					 | 
				
			||||||
        self.u.subtitle
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    pub fn libvlc_media_new_location(p_instance: *mut libvlc_instance_t, psz_mrl: *const c_char)
 | 
					 | 
				
			||||||
                                     -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_new_path(p_instance: *mut libvlc_instance_t, path: *const c_char)
 | 
					 | 
				
			||||||
                                 -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_new_fd(p_instance: *mut libvlc_instance_t, fd: c_int)
 | 
					 | 
				
			||||||
                               -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_as_node(p_instance: *mut libvlc_instance_t, psz_name: *const c_char)
 | 
					 | 
				
			||||||
                                -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_add_option(p_md: *mut libvlc_media_t, psz_options: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_add_option_flag(
 | 
					 | 
				
			||||||
        p_md: *mut libvlc_media_t, psz_options: *const c_char, i_flags: c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_retain(p_md: *mut libvlc_media_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_release(p_md: *mut libvlc_media_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_get_mrl(p_md: *mut libvlc_media_t) -> *mut c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_duplicate(p_md: *mut libvlc_media_t) -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_get_meta(p_md: *mut libvlc_media_t, e_meta: libvlc_meta_t) -> *mut c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_set_meta(p_md: *mut libvlc_media_t, e_meta: libvlc_meta_t,
 | 
					 | 
				
			||||||
                                 psz_value: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_save_meta(p_md: *mut libvlc_media_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_get_state(p_md: *mut libvlc_media_t) -> libvlc_state_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_get_stats(p_md: *mut libvlc_media_t, p_stats: *mut libvlc_media_stats_t)
 | 
					 | 
				
			||||||
                                  -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_subitems(p_md: *mut libvlc_media_t)
 | 
					 | 
				
			||||||
                                 -> *mut libvlc_media_list_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_event_manager(p_md: *mut libvlc_media_t)
 | 
					 | 
				
			||||||
                                      -> *mut libvlc_event_manager_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_get_duration(p_md: *mut libvlc_media_t)
 | 
					 | 
				
			||||||
                                     -> libvlc_time_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_parse(p_md: *mut libvlc_media_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_parse_async(p_md: *mut libvlc_media_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_is_parsed(p_md: *mut libvlc_media_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_set_user_data(p_md: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
                                      p_new_user_data: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_get_user_data(p_md: *mut libvlc_media_t) -> *mut c_void;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_tracks_get(p_md: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
                                   tracks: *mut *mut *mut libvlc_media_track_t) -> c_uint;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_tracks_release(p_tracks: *mut *mut libvlc_media_track_t, i_count: c_uint);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_media_player.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub enum libvlc_media_player_t {}
 | 
					 | 
				
			||||||
pub enum libvlc_equalizer_t {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					 | 
				
			||||||
pub struct libvlc_track_description_t {
 | 
					 | 
				
			||||||
    pub i_id: c_int,
 | 
					 | 
				
			||||||
    pub psz_name: *mut c_char,
 | 
					 | 
				
			||||||
    pub p_next: *mut libvlc_track_description_t,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_audio_output_t {
 | 
					 | 
				
			||||||
    pub psz_name: *mut c_char,
 | 
					 | 
				
			||||||
    pub psz_description: *mut c_char,
 | 
					 | 
				
			||||||
    pub p_next: *mut libvlc_audio_output_t,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_audio_output_device_t {
 | 
					 | 
				
			||||||
    pub p_next: *mut libvlc_audio_output_device_t,
 | 
					 | 
				
			||||||
    pub psz_device: *mut c_char,
 | 
					 | 
				
			||||||
    pub psz_description: *mut c_char,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					 | 
				
			||||||
pub struct libvlc_rectangle_t {
 | 
					 | 
				
			||||||
    pub top: c_int, pub left: c_int, pub bottom: c_int, pub right: c_int,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					 | 
				
			||||||
pub enum libvlc_video_marquee_option_t {
 | 
					 | 
				
			||||||
    libvlc_marquee_Enable = 0,
 | 
					 | 
				
			||||||
    libvlc_marquee_Text,
 | 
					 | 
				
			||||||
    libvlc_marquee_Color,
 | 
					 | 
				
			||||||
    libvlc_marquee_Opacity,
 | 
					 | 
				
			||||||
    libvlc_marquee_Position,
 | 
					 | 
				
			||||||
    libvlc_marquee_Refresh,
 | 
					 | 
				
			||||||
    libvlc_marquee_Size,
 | 
					 | 
				
			||||||
    libvlc_marquee_Timeout,
 | 
					 | 
				
			||||||
    libvlc_marquee_X,
 | 
					 | 
				
			||||||
    libvlc_marquee_Y,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					 | 
				
			||||||
pub enum libvlc_navigate_mode_t {
 | 
					 | 
				
			||||||
    libvlc_navigate_activate = 0,
 | 
					 | 
				
			||||||
    libvlc_navigate_up,
 | 
					 | 
				
			||||||
    libvlc_navigate_down,
 | 
					 | 
				
			||||||
    libvlc_navigate_left,
 | 
					 | 
				
			||||||
    libvlc_navigate_right,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub use crate::enums::Position as libvlc_position_t;
 | 
					 | 
				
			||||||
pub use crate::enums::VideoAdjustOption as libvlc_video_adjust_option;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					 | 
				
			||||||
pub enum libvlc_video_logo_option_t {
 | 
					 | 
				
			||||||
    libvlc_logo_enable,
 | 
					 | 
				
			||||||
    libvlc_logo_file,
 | 
					 | 
				
			||||||
    libvlc_logo_x,
 | 
					 | 
				
			||||||
    libvlc_logo_y,
 | 
					 | 
				
			||||||
    libvlc_logo_delay,
 | 
					 | 
				
			||||||
    libvlc_logo_repeat,
 | 
					 | 
				
			||||||
    libvlc_logo_opacity,
 | 
					 | 
				
			||||||
    libvlc_logo_position
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					 | 
				
			||||||
pub enum libvlc_audio_output_device_types_t {
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_Error  = -1,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_Mono   =  1,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_Stereo =  2,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_2F2R   =  4,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_3F2R   =  5,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_5_1    =  6,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_6_1    =  7,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_7_1    =  8,
 | 
					 | 
				
			||||||
    libvlc_AudioOutputDevice_SPDIF  = 10
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy, Debug)]
 | 
					 | 
				
			||||||
pub enum libvlc_audio_output_channel_t {
 | 
					 | 
				
			||||||
    libvlc_AudioChannel_Error   = -1,
 | 
					 | 
				
			||||||
    libvlc_AudioChannel_Stereo  =  1,
 | 
					 | 
				
			||||||
    libvlc_AudioChannel_RStereo =  2,
 | 
					 | 
				
			||||||
    libvlc_AudioChannel_Left    =  3,
 | 
					 | 
				
			||||||
    libvlc_AudioChannel_Right   =  4,
 | 
					 | 
				
			||||||
    libvlc_AudioChannel_Dolbys  =  5
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub type libvlc_video_lock_cb = Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> *mut c_void>;
 | 
					 | 
				
			||||||
pub type libvlc_video_unlock_cb = Option<unsafe extern "C" fn(
 | 
					 | 
				
			||||||
    *mut c_void, *mut c_void, *const *mut c_void)>;
 | 
					 | 
				
			||||||
pub type libvlc_video_display_cb = Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>;
 | 
					 | 
				
			||||||
pub type libvlc_video_format_cb = Option<unsafe extern "C" fn(
 | 
					 | 
				
			||||||
    *mut *mut c_void, *mut c_char, *mut c_uint, *mut c_uint, *mut c_uint, *mut c_uint)>;
 | 
					 | 
				
			||||||
pub type libvlc_video_cleanup_cb = Option<unsafe extern "C" fn(*mut c_void)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_play_cb = Option<unsafe extern "C" fn(*mut c_void, *const c_void, c_uint, i64)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_pause_cb = Option<unsafe extern "C" fn(*mut c_void, i64)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_resume_cb = Option<unsafe extern "C" fn(*mut c_void, i64)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_flush_cb = Option<unsafe extern "C" fn(*mut c_void, i64)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_drain_cb = Option<unsafe extern "C" fn(*mut c_void)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_set_volume_cb = Option<unsafe extern "C" fn(*mut c_void, c_float, c_bool)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_setup_cb = Option<unsafe extern "C" fn(
 | 
					 | 
				
			||||||
    *mut *mut c_void, *mut c_char, *mut c_uint, *mut c_uint)>;
 | 
					 | 
				
			||||||
pub type libvlc_audio_cleanup_cb = Option<unsafe extern "C" fn(*mut c_void)>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_new(p_libvlc_instance: *mut libvlc_instance_t)
 | 
					 | 
				
			||||||
                                   -> *mut libvlc_media_player_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_new_from_media(p_md: *mut libvlc_media_t)
 | 
					 | 
				
			||||||
                                              -> *mut libvlc_media_player_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_release(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_retain(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_media(p_mi: *mut libvlc_media_player_t,
 | 
					 | 
				
			||||||
                                         p_md: *mut libvlc_media_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_media(p_mi: *mut libvlc_media_player_t) -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_event_manager(p_mi: *mut libvlc_media_player_t)
 | 
					 | 
				
			||||||
                                             -> *mut libvlc_event_manager_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_is_playing(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_play(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_pause(mp: *mut libvlc_media_player_t, do_pause: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_pause(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_stop(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_callbacks(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, lock: libvlc_video_lock_cb,
 | 
					 | 
				
			||||||
        unlock: libvlc_video_unlock_cb, display: libvlc_video_display_cb,
 | 
					 | 
				
			||||||
        opaque: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_format(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, chroma: *const c_char, width: c_uint, height: c_uint,
 | 
					 | 
				
			||||||
        pitch: c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_format_callbacks(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, setup: libvlc_video_format_cb,
 | 
					 | 
				
			||||||
        cleanup: libvlc_video_cleanup_cb);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_nsobject(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, drawable: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_nsobject(p_mi: *mut libvlc_media_player_t) -> *mut c_void;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_xwindow(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, drawable: u32);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_xwindow(p_mi: *mut libvlc_media_player_t) -> u32;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_hwnd(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, drawable: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_hwnd(p_mi: *mut libvlc_media_player_t) -> *mut c_void;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_callbacks(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, play: libvlc_audio_play_cb, pause: libvlc_audio_pause_cb,
 | 
					 | 
				
			||||||
        resume: libvlc_audio_resume_cb, flush: libvlc_audio_flush_cb,
 | 
					 | 
				
			||||||
        drain: libvlc_audio_drain_cb, opaque: *mut c_void);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_volume_callback(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, set_volume: libvlc_audio_set_volume_cb);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_format_callbacks(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, setup: libvlc_audio_setup_cb,
 | 
					 | 
				
			||||||
        cleanup: libvlc_audio_cleanup_cb);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_format(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, format: *const c_char, rate: c_uint, channels: c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_length(p_mi: *mut libvlc_media_player_t) -> libvlc_time_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_time(p_mi: *mut libvlc_media_player_t) -> libvlc_time_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_time(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, i_time: libvlc_time_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_position(p_mi: *mut libvlc_media_player_t) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_position(p_mi: *mut libvlc_media_player_t, f_pos: c_float);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_chapter(p_mi: *mut libvlc_media_player_t, i_chapter: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_chapter(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_chapter_count(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_will_play(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_title(p_mi: *mut libvlc_media_player_t, i_title: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_chapter_count_for_title(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, i_title: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_title(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_title_count(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_previous_chapter(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_next_chapter(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_rate(p_mi: *mut libvlc_media_player_t) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_rate(p_mi: *mut libvlc_media_player_t, rate: c_float) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_state(p_mi: *mut libvlc_media_player_t) -> libvlc_state_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_get_fps(p_mi: *mut libvlc_media_player_t) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_has_vout(p_mi: *mut libvlc_media_player_t) -> c_uint;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_is_seekable(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_can_pause(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_program_scrambled(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_next_frame(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_navigate(p_mi: *mut libvlc_media_player_t, navigate: c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_video_title_display(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, position: libvlc_position_t, timeout: c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_track_description_list_release(p_track_description: *mut libvlc_track_description_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_toggle_fullscreen(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_set_fullscreen(p_mi: *mut libvlc_media_player_t, b_fullscreen: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_get_fullscreen(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_key_input(p_mi: *mut libvlc_media_player_t, on: c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_mouse_input(p_mi: *mut libvlc_media_player_t, on: c_uint);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_size(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, num: c_uint, px: *mut c_uint, py: *mut c_uint) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_cursor(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, num: c_uint, px: *mut c_int, py: *mut c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_scale(p_mi: *mut libvlc_media_player_t) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_scale(p_mi: *mut libvlc_media_player_t, f_factor: c_float);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_aspect_ratio(p_mi: *mut libvlc_media_player_t) -> *mut c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_aspect_ratio(p_mi: *mut libvlc_media_player_t, psz_aspect: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_spu(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_spu_count(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_spu_description(p_mi: *mut libvlc_media_player_t)
 | 
					 | 
				
			||||||
     -> *mut libvlc_track_description_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_spu(p_mi: *mut libvlc_media_player_t, i_spu: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_subtitle_file(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, psz_subtitle: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_spu_delay(p_mi: *mut libvlc_media_player_t) -> i64;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_spu_delay(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, i_delay: i64) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_title_description(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t) -> *mut libvlc_track_description_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_chapter_description(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, i_title: c_int) -> *mut libvlc_track_description_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_crop_geometry(p_mi: *mut libvlc_media_player_t) -> *mut c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_crop_geometry(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, psz_geometry: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_teletext(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_teletext(p_mi: *mut libvlc_media_player_t, i_page: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_toggle_teletext(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_track_count(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_track_description(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t) -> *mut libvlc_track_description_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_track(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_track(p_mi: *mut libvlc_media_player_t, i_track: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_take_snapshot(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, num: c_uint, psz_filepath: *const c_char,
 | 
					 | 
				
			||||||
        i_width: c_uint, i_height: c_uint) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_deinterlace(p_mi: *mut libvlc_media_player_t, psz_mode: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_marquee_int(p_mi: *mut libvlc_media_player_t, option: c_uint) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_marquee_string(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint) -> *mut c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_marquee_int(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint, i_val: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_marquee_string(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint, psz_text: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_logo_int(p_mi: *mut libvlc_media_player_t, option: c_uint) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_logo_int(p_mi: *mut libvlc_media_player_t, option: c_uint, value: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_logo_string(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint, psz_value: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_adjust_int(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_adjust_int(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint, value: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_video_get_adjust_float(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_video_set_adjust_float(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, option: c_uint, value: c_float);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_output_list_get(p_instance: *mut libvlc_instance_t)
 | 
					 | 
				
			||||||
     -> *mut libvlc_audio_output_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_output_list_release(p_list: *mut libvlc_audio_output_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_output_set(p_mi: *mut libvlc_media_player_t, psz_name: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_output_device_enum(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t) -> *mut libvlc_audio_output_device_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_output_device_list_get(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, aout: *const c_char) -> *mut libvlc_audio_output_device_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_output_device_list_release(p_list: *mut libvlc_audio_output_device_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_output_device_set(
 | 
					 | 
				
			||||||
        mp: *mut libvlc_media_player_t, module: *const c_char, device_id: *const c_char);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_toggle_mute(p_mi: *mut libvlc_media_player_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_get_mute(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_mute(p_mi: *mut libvlc_media_player_t, status: c_int);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_get_volume(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_volume(p_mi: *mut libvlc_media_player_t, i_volume: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_get_track_count(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_get_track_description(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t) -> *mut libvlc_track_description_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_get_track(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_track(p_mi: *mut libvlc_media_player_t, i_track: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_get_channel(p_mi: *mut libvlc_media_player_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_channel(p_mi: *mut libvlc_media_player_t, channel: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_get_delay(p_mi: *mut libvlc_media_player_t) -> i64;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_set_delay(p_mi: *mut libvlc_media_player_t, i_delay: i64) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_get_preset_count() -> c_uint;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_get_preset_name(u_index: c_uint) -> *const c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_get_band_count() -> c_uint;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_get_band_frequency(u_index: c_uint) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_new() -> *mut libvlc_equalizer_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_new_from_preset(u_index: c_uint) -> *mut libvlc_equalizer_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_release(p_equalizer: *mut libvlc_equalizer_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_set_preamp(
 | 
					 | 
				
			||||||
        p_equalizer: *mut libvlc_equalizer_t, f_preamp: c_float) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_get_preamp(p_equalizer: *mut libvlc_equalizer_t) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_set_amp_at_index(
 | 
					 | 
				
			||||||
        p_equalizer: *mut libvlc_equalizer_t, f_amp: c_float, u_band: c_uint) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_audio_equalizer_get_amp_at_index(
 | 
					 | 
				
			||||||
        p_equalizer: *mut libvlc_equalizer_t, u_band: c_uint) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_player_set_equalizer(
 | 
					 | 
				
			||||||
        p_mi: *mut libvlc_media_player_t, p_equalizer: *mut libvlc_equalizer_t) -> c_int;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_events.h
 | 
					 | 
				
			||||||
pub use crate::enums::EventType as libvlc_event_e;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[repr(C)]
 | 
					 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
pub struct libvlc_event_t {
 | 
					 | 
				
			||||||
    pub _type: c_int,
 | 
					 | 
				
			||||||
    pub p_obj: *mut c_void,
 | 
					 | 
				
			||||||
    pub u: libvlc_event_t_types::u,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub mod libvlc_event_t_types {
 | 
					 | 
				
			||||||
    use super::*;
 | 
					 | 
				
			||||||
    use libc::{c_int, c_char, c_float};
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub union u {
 | 
					 | 
				
			||||||
        pub media_meta_changed: media_meta_changed,
 | 
					 | 
				
			||||||
        pub media_subitem_added: media_subitem_added,
 | 
					 | 
				
			||||||
        pub media_duration_changed: media_duration_changed,
 | 
					 | 
				
			||||||
        pub media_parsed_changed: media_parsed_changed,
 | 
					 | 
				
			||||||
        pub media_freed: media_freed,
 | 
					 | 
				
			||||||
        pub media_state_changed: media_state_changed,
 | 
					 | 
				
			||||||
        pub media_subitemtree_added: media_subitemtree_added,
 | 
					 | 
				
			||||||
        pub media_player_buffering: media_player_buffering,
 | 
					 | 
				
			||||||
        pub media_player_position_changed: media_player_position_changed,
 | 
					 | 
				
			||||||
        pub media_player_time_changed: media_player_time_changed,
 | 
					 | 
				
			||||||
        pub media_player_title_changed: media_player_title_changed,
 | 
					 | 
				
			||||||
        pub media_player_seekable_changed: media_player_seekable_changed,
 | 
					 | 
				
			||||||
        pub media_player_pausable_changed: media_player_pausable_changed,
 | 
					 | 
				
			||||||
        pub media_player_scrambled_changed: media_player_scrambled_changed,
 | 
					 | 
				
			||||||
        pub media_player_vout: media_player_vout,
 | 
					 | 
				
			||||||
        pub media_list_item_added: media_list_item_added,
 | 
					 | 
				
			||||||
        pub media_list_will_add_item: media_list_will_add_item,
 | 
					 | 
				
			||||||
        pub media_list_item_deleted: media_list_item_deleted,
 | 
					 | 
				
			||||||
        pub media_list_will_delete_item: media_list_will_delete_item,
 | 
					 | 
				
			||||||
        pub media_list_player_next_item_set: media_list_player_next_item_set,
 | 
					 | 
				
			||||||
        pub media_player_snapshot_taken: media_player_snapshot_taken,
 | 
					 | 
				
			||||||
        pub media_player_length_changed: media_player_length_changed,
 | 
					 | 
				
			||||||
        pub vlm_media_event: vlm_media_event,
 | 
					 | 
				
			||||||
        pub media_player_media_changed: media_player_media_changed,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_meta_changed {
 | 
					 | 
				
			||||||
        pub meta_type: libvlc_meta_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_subitem_added {
 | 
					 | 
				
			||||||
        pub new_child: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_duration_changed {
 | 
					 | 
				
			||||||
        pub new_duration: i64,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_parsed_changed {
 | 
					 | 
				
			||||||
        pub new_status: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_freed {
 | 
					 | 
				
			||||||
        pub md: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_state_changed {
 | 
					 | 
				
			||||||
        pub new_state: libvlc_state_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_subitemtree_added {
 | 
					 | 
				
			||||||
        pub item: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_buffering {
 | 
					 | 
				
			||||||
        pub new_cache: c_float,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_position_changed {
 | 
					 | 
				
			||||||
        pub new_position: c_float,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_time_changed {
 | 
					 | 
				
			||||||
        pub new_time: libvlc_time_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_title_changed {
 | 
					 | 
				
			||||||
        pub new_titie: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_seekable_changed {
 | 
					 | 
				
			||||||
        pub new_seekable: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_pausable_changed {
 | 
					 | 
				
			||||||
        pub new_pausable: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_scrambled_changed {
 | 
					 | 
				
			||||||
        pub new_scrambled: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_vout {
 | 
					 | 
				
			||||||
        pub new_count: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_list_item_added {
 | 
					 | 
				
			||||||
        pub item: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
        pub index: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_list_will_add_item {
 | 
					 | 
				
			||||||
        pub item: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
        pub index: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_list_item_deleted {
 | 
					 | 
				
			||||||
        pub item: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
        pub index: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_list_will_delete_item {
 | 
					 | 
				
			||||||
        pub item: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
        pub index: c_int,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_list_player_next_item_set {
 | 
					 | 
				
			||||||
        pub item: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_snapshot_taken {
 | 
					 | 
				
			||||||
        pub psz_filename: *mut c_char,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_length_changed {
 | 
					 | 
				
			||||||
        pub new_length: libvlc_time_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct vlm_media_event {
 | 
					 | 
				
			||||||
        pub psz_media_name: *mut c_char,
 | 
					 | 
				
			||||||
        pub psz_instance_name: *mut c_char,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #[repr(C)]
 | 
					 | 
				
			||||||
    #[derive(Clone, Copy)]
 | 
					 | 
				
			||||||
    pub struct media_player_media_changed {
 | 
					 | 
				
			||||||
        pub new_media: *mut libvlc_media_t,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_media_list.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub enum libvlc_media_list_t {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_new(p_instance: *mut libvlc_instance_t) -> *mut libvlc_media_list_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_release(p_ml: *mut libvlc_media_list_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_retain(p_ml: *mut libvlc_media_list_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_set_media(p_ml: *mut libvlc_media_list_t, p_md: *mut libvlc_media_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_media(p_ml: *mut libvlc_media_list_t) -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_add_media(
 | 
					 | 
				
			||||||
        p_ml: *mut libvlc_media_list_t, p_md: *mut libvlc_media_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_insert_media(
 | 
					 | 
				
			||||||
        p_ml: *mut libvlc_media_list_t, p_md: *mut libvlc_media_t, i_pos: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_remove_index(p_ml: *mut libvlc_media_list_t, i_pos: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_count(p_ml: *mut libvlc_media_list_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_item_at_index(
 | 
					 | 
				
			||||||
        p_ml: *mut libvlc_media_list_t, i_pos: c_int) -> *mut libvlc_media_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_index_of_item(
 | 
					 | 
				
			||||||
        p_ml: *mut libvlc_media_list_t, p_md: *mut libvlc_media_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_is_readonly(p_ml: *mut libvlc_media_list_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_lock(p_ml: *mut libvlc_media_list_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_unlock(p_ml: *mut libvlc_media_list_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_list_event_manager(
 | 
					 | 
				
			||||||
        p_ml: *mut libvlc_media_list_t) -> *mut libvlc_event_manager_t;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_media_library.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub enum libvlc_media_library_t {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    pub fn libvlc_media_library_new(p_instance: *mut libvlc_instance_t) -> *mut libvlc_media_library_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_library_release(p_mlib: *mut libvlc_media_library_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_library_retain(p_mlib: *mut libvlc_media_library_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_library_load(p_mlib: *mut libvlc_media_library_t) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_library_media_list(
 | 
					 | 
				
			||||||
        p_mlib: *mut libvlc_media_library_t) -> *mut libvlc_media_list_t;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_media_discoverer.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub enum libvlc_media_discoverer_t {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    pub fn libvlc_media_discoverer_new_from_name(
 | 
					 | 
				
			||||||
        p_inst: *mut libvlc_instance_t, psz_name: *const c_char) -> *mut libvlc_media_discoverer_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_discoverer_release(p_mdis: *mut libvlc_media_discoverer_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_media_discoverer_localized_name(
 | 
					 | 
				
			||||||
        p_mdis: *mut libvlc_media_discoverer_t) -> *mut c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_discoverer_media_list(
 | 
					 | 
				
			||||||
        p_mdis: *mut libvlc_media_discoverer_t) -> *mut libvlc_media_list_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_discoverer_event_manager(
 | 
					 | 
				
			||||||
        p_mdis: *mut libvlc_media_discoverer_t) -> *mut libvlc_event_manager_t;
 | 
					 | 
				
			||||||
    pub fn libvlc_media_discoverer_is_running(p_mdis: *mut libvlc_media_discoverer_t) -> c_int;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// From libvlc_vlm.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_release(p_instance: *mut libvlc_instance_t);
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_add_broadcast(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, psz_input: *const c_char,
 | 
					 | 
				
			||||||
        psz_output: *const c_char, i_options: c_int, ppsz_options: *const *const c_char,
 | 
					 | 
				
			||||||
        b_enabled: c_int, b_loop: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_add_vod(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, psz_input: *const c_char,
 | 
					 | 
				
			||||||
        i_options: c_int, ppsz_options: *const *const c_char, b_enabled: c_int,
 | 
					 | 
				
			||||||
        psz_mux: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_del_media(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_set_enabled(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, b_enabled: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_set_output(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, psz_output: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_set_input(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, psz_input: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_add_input(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, psz_input: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_set_loop(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, b_loop: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_set_mux(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, psz_mux: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_change_media(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, psz_input: *const c_char,
 | 
					 | 
				
			||||||
        psz_output: *const c_char, i_options: c_int, ppsz_options: *const *const c_char,
 | 
					 | 
				
			||||||
        b_enabled: c_int, b_loop: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_play_media(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_stop_media(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_pause_media(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_seek_media(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, f_percentage: c_float) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_show_media(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char) -> *const c_char;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_get_media_instance_position(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, i_instance: c_int) -> c_float;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_get_media_instance_time(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, i_instance: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_get_media_instance_length(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, i_instance: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_get_media_instance_rate(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t, psz_name: *const c_char, i_instance: c_int) -> c_int;
 | 
					 | 
				
			||||||
    pub fn libvlc_vlm_get_event_manager(
 | 
					 | 
				
			||||||
        p_instance: *mut libvlc_instance_t) -> *mut libvlc_event_manager_t;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -2,10 +2,10 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use std::ffi::{CString, CStr, NulError};
 | 
					 | 
				
			||||||
use std::path::Path;
 | 
					 | 
				
			||||||
use std::borrow::Cow;
 | 
					 | 
				
			||||||
use libc::c_char;
 | 
					use libc::c_char;
 | 
				
			||||||
 | 
					use std::borrow::Cow;
 | 
				
			||||||
 | 
					use std::ffi::{CStr, CString, NulError};
 | 
				
			||||||
 | 
					use std::path::Path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Convert String to CString.
 | 
					// Convert String to CString.
 | 
				
			||||||
// Panic if the string includes null bytes.
 | 
					// Panic if the string includes null bytes.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										71
									
								
								src/video.rs
								
								
								
								
							
							
						
						
									
										71
									
								
								src/video.rs
								
								
								
								
							| 
						 | 
					@ -2,12 +2,12 @@
 | 
				
			||||||
// This file is part of vlc-rs.
 | 
					// This file is part of vlc-rs.
 | 
				
			||||||
// Licensed under the MIT license, see the LICENSE file.
 | 
					// Licensed under the MIT license, see the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::sys;
 | 
					use crate::enums::VideoAdjustOption;
 | 
				
			||||||
 | 
					use crate::tools::{from_cstr, to_cstr};
 | 
				
			||||||
use crate::MediaPlayer;
 | 
					use crate::MediaPlayer;
 | 
				
			||||||
use crate::TrackDescription;
 | 
					use crate::TrackDescription;
 | 
				
			||||||
use crate::enums::VideoAdjustOption;
 | 
					 | 
				
			||||||
use crate::tools::{to_cstr, from_cstr};
 | 
					 | 
				
			||||||
use libc::c_void;
 | 
					use libc::c_void;
 | 
				
			||||||
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub trait MediaPlayerVideoEx {
 | 
					pub trait MediaPlayerVideoEx {
 | 
				
			||||||
    fn toggle_fullscreen(&self);
 | 
					    fn toggle_fullscreen(&self);
 | 
				
			||||||
| 
						 | 
					@ -32,26 +32,38 @@ pub trait MediaPlayerVideoEx {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl MediaPlayerVideoEx for MediaPlayer {
 | 
					impl MediaPlayerVideoEx for MediaPlayer {
 | 
				
			||||||
    fn toggle_fullscreen(&self) {
 | 
					    fn toggle_fullscreen(&self) {
 | 
				
			||||||
        unsafe{ sys::libvlc_toggle_fullscreen(self.ptr); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_toggle_fullscreen(self.ptr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_fullscreen(&self, fullscreen: bool) {
 | 
					    fn set_fullscreen(&self, fullscreen: bool) {
 | 
				
			||||||
        unsafe{ sys::libvlc_set_fullscreen(self.ptr, if fullscreen { 1 }else{ 0 }); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_set_fullscreen(self.ptr, if fullscreen { 1 } else { 0 });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn get_fullscreen(&self) -> bool {
 | 
					    fn get_fullscreen(&self) -> bool {
 | 
				
			||||||
        unsafe{ if sys::libvlc_get_fullscreen(self.ptr) == 0 { false }else{ true } }
 | 
					        unsafe { sys::libvlc_get_fullscreen(self.ptr) != 0 }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_key_input(&self, on: bool) {
 | 
					    fn set_key_input(&self, on: bool) {
 | 
				
			||||||
        unsafe{ sys::libvlc_video_set_key_input(self.ptr, if on { 1 }else{ 0 }); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_video_set_key_input(self.ptr, if on { 1 } else { 0 });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_mouse_input(&self, on: bool) {
 | 
					    fn set_mouse_input(&self, on: bool) {
 | 
				
			||||||
        unsafe{ sys::libvlc_video_set_mouse_input(self.ptr, if on { 1 }else{ 0 }); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_video_set_mouse_input(self.ptr, if on { 1 } else { 0 });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn get_size(&self, num: u32) -> Option<(u32, u32)> {
 | 
					    fn get_size(&self, num: u32) -> Option<(u32, u32)> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let mut x = 0;
 | 
					            let mut x = 0;
 | 
				
			||||||
            let mut y = 0;
 | 
					            let mut y = 0;
 | 
				
			||||||
            let res = sys::libvlc_video_get_size(self.ptr, num, &mut x, &mut y);
 | 
					            let res = sys::libvlc_video_get_size(self.ptr, num, &mut x, &mut y);
 | 
				
			||||||
            if res == -1 { None }else{ Some((x, y)) }
 | 
					            if res == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some((x, y))
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn get_cursor(&self, num: u32) -> Option<(i32, i32)> {
 | 
					    fn get_cursor(&self, num: u32) -> Option<(i32, i32)> {
 | 
				
			||||||
| 
						 | 
					@ -59,29 +71,43 @@ impl MediaPlayerVideoEx for MediaPlayer {
 | 
				
			||||||
            let mut x = 0;
 | 
					            let mut x = 0;
 | 
				
			||||||
            let mut y = 0;
 | 
					            let mut y = 0;
 | 
				
			||||||
            let res = sys::libvlc_video_get_cursor(self.ptr, num, &mut x, &mut y);
 | 
					            let res = sys::libvlc_video_get_cursor(self.ptr, num, &mut x, &mut y);
 | 
				
			||||||
            if res == -1 { None }else{ Some((x, y)) }
 | 
					            if res == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some((x, y))
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn get_scale(&self) -> f32 {
 | 
					    fn get_scale(&self) -> f32 {
 | 
				
			||||||
        unsafe { sys::libvlc_video_get_scale(self.ptr) }
 | 
					        unsafe { sys::libvlc_video_get_scale(self.ptr) }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_scale(&self, factor: f32) {
 | 
					    fn set_scale(&self, factor: f32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_video_set_scale(self.ptr, factor); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_video_set_scale(self.ptr, factor);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn get_video_track(&self) -> Option<i32> {
 | 
					    fn get_video_track(&self) -> Option<i32> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let track = sys::libvlc_video_get_track(self.ptr);
 | 
					            let track = sys::libvlc_video_get_track(self.ptr);
 | 
				
			||||||
            if track == -1 { None }else{ Some(track) }
 | 
					            if track == -1 {
 | 
				
			||||||
 | 
					                None
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Some(track)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_video_track(&self, track: i32) {
 | 
					    fn set_video_track(&self, track: i32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_video_set_track(self.ptr, track); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_video_set_track(self.ptr, track);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn get_aspect_ratio(&self) -> Option<String> {
 | 
					    fn get_aspect_ratio(&self) -> Option<String> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p = sys::libvlc_video_get_aspect_ratio(self.ptr);
 | 
					            let p = sys::libvlc_video_get_aspect_ratio(self.ptr);
 | 
				
			||||||
            let s = from_cstr(p);
 | 
					            let s = from_cstr(p);
 | 
				
			||||||
            if !p.is_null() { sys::libvlc_free(p as *mut c_void); }
 | 
					            if !p.is_null() {
 | 
				
			||||||
 | 
					                sys::libvlc_free(p as *mut c_void);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            s
 | 
					            s
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -97,12 +123,17 @@ impl MediaPlayerVideoEx for MediaPlayer {
 | 
				
			||||||
    fn get_video_track_description(&self) -> Option<Vec<TrackDescription>> {
 | 
					    fn get_video_track_description(&self) -> Option<Vec<TrackDescription>> {
 | 
				
			||||||
        unsafe {
 | 
					        unsafe {
 | 
				
			||||||
            let p0 = sys::libvlc_video_get_track_description(self.ptr);
 | 
					            let p0 = sys::libvlc_video_get_track_description(self.ptr);
 | 
				
			||||||
            if p0.is_null() { return None; }
 | 
					            if p0.is_null() {
 | 
				
			||||||
 | 
					                return None;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            let mut td = Vec::new();
 | 
					            let mut td = Vec::new();
 | 
				
			||||||
            let mut p = p0;
 | 
					            let mut p = p0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            while !(*p).p_next.is_null() {
 | 
					            while !(*p).p_next.is_null() {
 | 
				
			||||||
                td.push(TrackDescription{ id: (*p).i_id, name: from_cstr((*p).psz_name) });
 | 
					                td.push(TrackDescription {
 | 
				
			||||||
 | 
					                    id: (*p).i_id,
 | 
				
			||||||
 | 
					                    name: from_cstr((*p).psz_name),
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
                p = (*p).p_next;
 | 
					                p = (*p).p_next;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            sys::libvlc_track_description_list_release(p0);
 | 
					            sys::libvlc_track_description_list_release(p0);
 | 
				
			||||||
| 
						 | 
					@ -113,12 +144,16 @@ impl MediaPlayerVideoEx for MediaPlayer {
 | 
				
			||||||
        unsafe { sys::libvlc_video_get_adjust_int(self.ptr, option as u32) }
 | 
					        unsafe { sys::libvlc_video_get_adjust_int(self.ptr, option as u32) }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_adjust_int(&self, option: VideoAdjustOption, value: i32) {
 | 
					    fn set_adjust_int(&self, option: VideoAdjustOption, value: i32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_video_set_adjust_int(self.ptr, option as u32, value); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_video_set_adjust_int(self.ptr, option as u32, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn get_adjust_float(&self, option: VideoAdjustOption) -> f32 {
 | 
					    fn get_adjust_float(&self, option: VideoAdjustOption) -> f32 {
 | 
				
			||||||
        unsafe { sys::libvlc_video_get_adjust_float(self.ptr, option as u32) }
 | 
					        unsafe { sys::libvlc_video_get_adjust_float(self.ptr, option as u32) }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn set_adjust_float(&self, option: VideoAdjustOption, value: f32) {
 | 
					    fn set_adjust_float(&self, option: VideoAdjustOption, value: f32) {
 | 
				
			||||||
        unsafe{ sys::libvlc_video_set_adjust_float(self.ptr, option as u32, value); }
 | 
					        unsafe {
 | 
				
			||||||
 | 
					            sys::libvlc_video_set_adjust_float(self.ptr, option as u32, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										243
									
								
								src/vlm.rs
								
								
								
								
							
							
						
						
									
										243
									
								
								src/vlm.rs
								
								
								
								
							| 
						 | 
					@ -2,33 +2,57 @@ use std::ffi::CString;
 | 
				
			||||||
use std::os::raw::c_char;
 | 
					use std::os::raw::c_char;
 | 
				
			||||||
use std::ptr;
 | 
					use std::ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::{Instance, sys};
 | 
					 | 
				
			||||||
use crate::tools::{from_cstr, to_cstr};
 | 
					use crate::tools::{from_cstr, to_cstr};
 | 
				
			||||||
 | 
					use crate::{Instance, InternalError};
 | 
				
			||||||
 | 
					use vlc_sys as sys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub trait Vlm {
 | 
					pub trait Vlm {
 | 
				
			||||||
    fn add_broadcast(&self, name: &str, input: &str, output: &str, options: Option<Vec<String>>, enabled: bool, loop_broadcast: bool, ) -> Result<(), ()>;
 | 
					    fn add_broadcast(
 | 
				
			||||||
 | 
					        &self,
 | 
				
			||||||
 | 
					        name: &str,
 | 
				
			||||||
 | 
					        input: &str,
 | 
				
			||||||
 | 
					        output: &str,
 | 
				
			||||||
 | 
					        options: Option<Vec<String>>,
 | 
				
			||||||
 | 
					        enabled: bool,
 | 
				
			||||||
 | 
					        loop_broadcast: bool,
 | 
				
			||||||
 | 
					    ) -> Result<(), InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn add_vod(&self, name: &str, input: &str, mux: &str, options: Option<Vec<String>>, enabled: bool) -> Result<(), ()>;
 | 
					    fn add_vod(
 | 
				
			||||||
 | 
					        &self,
 | 
				
			||||||
 | 
					        name: &str,
 | 
				
			||||||
 | 
					        input: &str,
 | 
				
			||||||
 | 
					        mux: &str,
 | 
				
			||||||
 | 
					        options: Option<Vec<String>>,
 | 
				
			||||||
 | 
					        enabled: bool,
 | 
				
			||||||
 | 
					    ) -> Result<(), InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn play_media(&self, name: &str) -> Result<(), ()>;
 | 
					    fn play_media(&self, name: &str) -> Result<(), InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn pause_media(&self, name: &str) -> Result<(), ()>;
 | 
					    fn pause_media(&self, name: &str) -> Result<(), InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn stop_media(&self, name: &str) -> Result<(), ()>;
 | 
					    fn stop_media(&self, name: &str) -> Result<(), InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn get_media_instance_position(&self, name: &str, instance: i32) -> Result<f32, ()>;
 | 
					    fn get_media_instance_position(&self, name: &str, instance: i32) -> Result<f32, InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn get_media_instance_length(&self, name: &str, instance: i32) -> Result<i32, ()>;
 | 
					    fn get_media_instance_length(&self, name: &str, instance: i32) -> Result<i32, InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn get_media_instance_time(&self, name: &str, instance: i32) -> Result<i32, ()>;
 | 
					    fn get_media_instance_time(&self, name: &str, instance: i32) -> Result<i32, InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn get_media_instance_rate(&self, name: &str, instance: i32) -> Result<i32, ()>;
 | 
					    fn get_media_instance_rate(&self, name: &str, instance: i32) -> Result<i32, InternalError>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn show_media(&self, name: &str) -> Result<String, ()>;
 | 
					    fn show_media(&self, name: &str) -> Result<String, InternalError>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Vlm for Instance {
 | 
					impl Vlm for Instance {
 | 
				
			||||||
    fn add_broadcast(&self, name: &str, input: &str, output: &str, options: Option<Vec<String>>, enabled: bool, loop_broadcast: bool, ) -> Result<(), ()> {
 | 
					    fn add_broadcast(
 | 
				
			||||||
 | 
					        &self,
 | 
				
			||||||
 | 
					        name: &str,
 | 
				
			||||||
 | 
					        input: &str,
 | 
				
			||||||
 | 
					        output: &str,
 | 
				
			||||||
 | 
					        options: Option<Vec<String>>,
 | 
				
			||||||
 | 
					        enabled: bool,
 | 
				
			||||||
 | 
					        loop_broadcast: bool,
 | 
				
			||||||
 | 
					    ) -> Result<(), InternalError> {
 | 
				
			||||||
        let name = to_cstr(name);
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
        let input = to_cstr(input);
 | 
					        let input = to_cstr(input);
 | 
				
			||||||
        let output = to_cstr(output);
 | 
					        let output = to_cstr(output);
 | 
				
			||||||
| 
						 | 
					@ -37,23 +61,54 @@ impl Vlm for Instance {
 | 
				
			||||||
        let enabled = if enabled { 1 } else { 0 };
 | 
					        let enabled = if enabled { 1 } else { 0 };
 | 
				
			||||||
        let loop_broadcast = if loop_broadcast { 1 } else { 0 };
 | 
					        let loop_broadcast = if loop_broadcast { 1 } else { 0 };
 | 
				
			||||||
        if let Some(vec) = options {
 | 
					        if let Some(vec) = options {
 | 
				
			||||||
            opts_c = vec.into_iter()
 | 
					            opts_c = vec
 | 
				
			||||||
                .map(|x| CString::new(x).expect("Error: Unexpected null byte")).collect();
 | 
					                .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();
 | 
					            opts_c_ptr = opts_c.iter().map(|x| x.as_ptr()).collect();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            opts_c_ptr = Vec::new();
 | 
					            opts_c_ptr = Vec::new();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let result = unsafe {
 | 
					        let result = unsafe {
 | 
				
			||||||
            if opts_c_ptr.is_empty() {
 | 
					            if opts_c_ptr.is_empty() {
 | 
				
			||||||
                sys::libvlc_vlm_add_broadcast(self.ptr, name.as_ptr(), input.as_ptr(), output.as_ptr(), 0, ptr::null(), enabled, loop_broadcast)
 | 
					                sys::libvlc_vlm_add_broadcast(
 | 
				
			||||||
 | 
					                    self.ptr,
 | 
				
			||||||
 | 
					                    name.as_ptr(),
 | 
				
			||||||
 | 
					                    input.as_ptr(),
 | 
				
			||||||
 | 
					                    output.as_ptr(),
 | 
				
			||||||
 | 
					                    0,
 | 
				
			||||||
 | 
					                    ptr::null(),
 | 
				
			||||||
 | 
					                    enabled,
 | 
				
			||||||
 | 
					                    loop_broadcast,
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                sys::libvlc_vlm_add_broadcast(self.ptr, name.as_ptr(), input.as_ptr(), output.as_ptr(), opts_c_ptr.len() as i32, opts_c_ptr.as_ptr(), enabled, loop_broadcast)
 | 
					                sys::libvlc_vlm_add_broadcast(
 | 
				
			||||||
 | 
					                    self.ptr,
 | 
				
			||||||
 | 
					                    name.as_ptr(),
 | 
				
			||||||
 | 
					                    input.as_ptr(),
 | 
				
			||||||
 | 
					                    output.as_ptr(),
 | 
				
			||||||
 | 
					                    opts_c_ptr.len() as i32,
 | 
				
			||||||
 | 
					                    opts_c_ptr.as_ptr(),
 | 
				
			||||||
 | 
					                    enabled,
 | 
				
			||||||
 | 
					                    loop_broadcast,
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        if result == 0 { Ok(()) } else { Err(()) }
 | 
					        if result == 0 {
 | 
				
			||||||
 | 
					            Ok(())
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn add_vod(&self, name: &str, input: &str, mux: &str, options: Option<Vec<String>>, enabled: bool) -> Result<(), ()> {
 | 
					    fn add_vod(
 | 
				
			||||||
 | 
					        &self,
 | 
				
			||||||
 | 
					        name: &str,
 | 
				
			||||||
 | 
					        input: &str,
 | 
				
			||||||
 | 
					        mux: &str,
 | 
				
			||||||
 | 
					        options: Option<Vec<String>>,
 | 
				
			||||||
 | 
					        enabled: bool,
 | 
				
			||||||
 | 
					    ) -> Result<(), InternalError> {
 | 
				
			||||||
        let name = to_cstr(name);
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
        let input = to_cstr(input);
 | 
					        let input = to_cstr(input);
 | 
				
			||||||
        let mux = to_cstr(mux);
 | 
					        let mux = to_cstr(mux);
 | 
				
			||||||
| 
						 | 
					@ -61,87 +116,127 @@ impl Vlm for Instance {
 | 
				
			||||||
        let opts_c: Vec<CString>;
 | 
					        let opts_c: Vec<CString>;
 | 
				
			||||||
        let enabled = if enabled { 1 } else { 0 };
 | 
					        let enabled = if enabled { 1 } else { 0 };
 | 
				
			||||||
        if let Some(vec) = options {
 | 
					        if let Some(vec) = options {
 | 
				
			||||||
            opts_c = vec.into_iter()
 | 
					            opts_c = vec
 | 
				
			||||||
                .map(|x| CString::new(x).expect("Error: Unexpected null byte")).collect();
 | 
					                .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();
 | 
					            opts_c_ptr = opts_c.iter().map(|x| x.as_ptr()).collect();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            opts_c_ptr = Vec::new();
 | 
					            opts_c_ptr = Vec::new();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let result = unsafe {
 | 
					        let result = unsafe {
 | 
				
			||||||
            if opts_c_ptr.is_empty() {
 | 
					            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())
 | 
					                sys::libvlc_vlm_add_vod(
 | 
				
			||||||
 | 
					                    self.ptr,
 | 
				
			||||||
 | 
					                    name.as_ptr(),
 | 
				
			||||||
 | 
					                    input.as_ptr(),
 | 
				
			||||||
 | 
					                    0,
 | 
				
			||||||
 | 
					                    ptr::null(),
 | 
				
			||||||
 | 
					                    enabled,
 | 
				
			||||||
 | 
					                    mux.as_ptr(),
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
            } else {
 | 
					            } 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())
 | 
					                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(()) }
 | 
					        if result == 0 {
 | 
				
			||||||
 | 
					            Ok(())
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn play_media(&self, name: &str) -> Result<(), ()> {
 | 
					    fn play_media(&self, name: &str) -> Result<(), InternalError> {
 | 
				
			||||||
        let name = to_cstr(name);
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
        let result = unsafe {
 | 
					        let result = unsafe { sys::libvlc_vlm_play_media(self.ptr, name.as_ptr()) };
 | 
				
			||||||
            sys::libvlc_vlm_play_media(self.ptr, name.as_ptr())
 | 
					        if result == 0 {
 | 
				
			||||||
        };
 | 
					            Ok(())
 | 
				
			||||||
        if result == 0 { Ok(()) } else { Err(()) }
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn pause_media(&self, name: &str) -> Result<(), ()> {
 | 
					    fn pause_media(&self, name: &str) -> Result<(), InternalError> {
 | 
				
			||||||
        let name = to_cstr(name);
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
        let result = unsafe {
 | 
					        let result = unsafe { sys::libvlc_vlm_pause_media(self.ptr, name.as_ptr()) };
 | 
				
			||||||
            sys::libvlc_vlm_pause_media(self.ptr, name.as_ptr())
 | 
					        if result == 0 {
 | 
				
			||||||
        };
 | 
					            Ok(())
 | 
				
			||||||
        if result == 0 { Ok(()) } else { Err(()) }
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn stop_media(&self, name: &str) -> Result<(), ()> {
 | 
					    fn stop_media(&self, name: &str) -> Result<(), InternalError> {
 | 
				
			||||||
        let name = to_cstr(name);
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
        let result = unsafe {
 | 
					        let result = unsafe { sys::libvlc_vlm_stop_media(self.ptr, name.as_ptr()) };
 | 
				
			||||||
            sys::libvlc_vlm_stop_media(self.ptr, name.as_ptr())
 | 
					        if result == 0 {
 | 
				
			||||||
        };
 | 
					            Ok(())
 | 
				
			||||||
        if result == 0 { Ok(()) } else { Err(()) }
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn get_media_instance_position(&self, name: &str, instance: i32) -> Result<f32, ()> {
 | 
					    fn get_media_instance_position(&self, name: &str, instance: i32) -> Result<f32, InternalError> {
 | 
				
			||||||
        let name = to_cstr(name);
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
        let result = unsafe {
 | 
					        let result = unsafe {
 | 
				
			||||||
            sys::libvlc_vlm_get_media_instance_position(self.ptr, name.as_ptr(), instance)
 | 
					            sys::libvlc_vlm_get_media_instance_position(self.ptr, name.as_ptr(), instance)
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        if result != -1f32 { Ok(result) } else { Err(()) }
 | 
					        // if result != -1f32 { Ok(result) } else { Err(()) }
 | 
				
			||||||
    }
 | 
					        if (result - -1f32).abs() < f32::EPSILON {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
    fn get_media_instance_length(&self, name: &str, instance: i32) -> Result<i32, ()> {
 | 
					 | 
				
			||||||
        let name = to_cstr(name);
 | 
					 | 
				
			||||||
        let result = unsafe {
 | 
					 | 
				
			||||||
            sys::libvlc_vlm_get_media_instance_length(self.ptr, name.as_ptr(), instance)
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        if result != -1 { Ok(result) } else { Err(()) }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn get_media_instance_time(&self, name: &str, instance: i32) -> Result<i32, ()> {
 | 
					 | 
				
			||||||
        let name = to_cstr(name);
 | 
					 | 
				
			||||||
        let result = unsafe {
 | 
					 | 
				
			||||||
            sys::libvlc_vlm_get_media_instance_time(self.ptr, name.as_ptr(), instance)
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        if result != -1 { Ok(result) } else { Err(()) }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn get_media_instance_rate(&self, name: &str, instance: i32) -> Result<i32, ()> {
 | 
					 | 
				
			||||||
        let name = to_cstr(name);
 | 
					 | 
				
			||||||
        let result = unsafe {
 | 
					 | 
				
			||||||
            sys::libvlc_vlm_get_media_instance_rate(self.ptr, name.as_ptr(), instance)
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        if result != -1 { Ok(result) } else { Err(()) }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn show_media(&self, name: &str) -> Result<String, ()> {
 | 
					 | 
				
			||||||
        let name = to_cstr(name);
 | 
					 | 
				
			||||||
        let result = unsafe {
 | 
					 | 
				
			||||||
            from_cstr(sys::libvlc_vlm_show_media(self.ptr, name.as_ptr()))
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        if let Some(data) = result {
 | 
					 | 
				
			||||||
            Ok(data.to_string())
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Err(())
 | 
					            Ok(result)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn get_media_instance_length(&self, name: &str, instance: i32) -> Result<i32, InternalError> {
 | 
				
			||||||
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
 | 
					        let result =
 | 
				
			||||||
 | 
					            unsafe { sys::libvlc_vlm_get_media_instance_length(self.ptr, name.as_ptr(), instance) };
 | 
				
			||||||
 | 
					        if result != -1 {
 | 
				
			||||||
 | 
					            Ok(result)
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn get_media_instance_time(&self, name: &str, instance: i32) -> Result<i32, InternalError> {
 | 
				
			||||||
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
 | 
					        let result =
 | 
				
			||||||
 | 
					            unsafe { sys::libvlc_vlm_get_media_instance_time(self.ptr, name.as_ptr(), instance) };
 | 
				
			||||||
 | 
					        if result != -1 {
 | 
				
			||||||
 | 
					            Ok(result)
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn get_media_instance_rate(&self, name: &str, instance: i32) -> Result<i32, InternalError> {
 | 
				
			||||||
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
 | 
					        let result =
 | 
				
			||||||
 | 
					            unsafe { sys::libvlc_vlm_get_media_instance_rate(self.ptr, name.as_ptr(), instance) };
 | 
				
			||||||
 | 
					        if result != -1 {
 | 
				
			||||||
 | 
					            Ok(result)
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn show_media(&self, name: &str) -> Result<String, InternalError> {
 | 
				
			||||||
 | 
					        let name = to_cstr(name);
 | 
				
			||||||
 | 
					        let result = unsafe { from_cstr(sys::libvlc_vlm_show_media(self.ptr, name.as_ptr())) };
 | 
				
			||||||
 | 
					        if let Some(data) = result {
 | 
				
			||||||
 | 
					            Ok(data)
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Err(InternalError)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue