Merge branch 'master' into vlm-broadcast
commit
ab7c27e8cb
|
@ -8,6 +8,7 @@ keywords = ["libVLC", "bindings"]
|
||||||
repository = "https://github.com/garkimasera/vlc-rs"
|
repository = "https://github.com/garkimasera/vlc-rs"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "vlc"
|
name = "vlc"
|
||||||
|
|
10
src/audio.rs
10
src/audio.rs
|
@ -2,14 +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 sys;
|
use crate::sys;
|
||||||
use ::MediaPlayer;
|
use crate::MediaPlayer;
|
||||||
use ::TrackDescription;
|
use crate::TrackDescription;
|
||||||
use ::tools::from_cstr;
|
use crate::tools::from_cstr;
|
||||||
|
|
||||||
pub trait MediaPlayerAudioEx {
|
pub trait MediaPlayerAudioEx {
|
||||||
fn get_mute(&self) -> Option<bool>;
|
fn get_mute(&self) -> Option<bool>;
|
||||||
fn set_mute(&self, 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<(), ()>;
|
||||||
fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>>;
|
fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>>;
|
||||||
|
|
16
src/core.rs
16
src/core.rs
|
@ -7,10 +7,10 @@ use std::borrow::Cow;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ffi::{CString, CStr};
|
use std::ffi::{CString, CStr};
|
||||||
use std::i32;
|
use std::i32;
|
||||||
use sys;
|
use libc::{c_void, c_char, c_int};
|
||||||
use ::tools::{to_cstr, from_cstr, from_cstr_ref};
|
use crate::sys;
|
||||||
use ::libc::{c_void, c_char, c_int};
|
use crate::tools::{to_cstr, from_cstr, from_cstr_ref};
|
||||||
use ::enums::*;
|
use crate::enums::*;
|
||||||
|
|
||||||
/// Retrieve libvlc version.
|
/// Retrieve libvlc version.
|
||||||
pub fn version() -> String {
|
pub fn version() -> String {
|
||||||
|
@ -132,7 +132,7 @@ impl Instance {
|
||||||
|
|
||||||
/// Set logging callback
|
/// Set logging callback
|
||||||
pub fn set_log<F: Fn(LogLevel, Log, Cow<str>) + Send + 'static>(&self, f: F) {
|
pub fn set_log<F: Fn(LogLevel, Log, Cow<str>) + Send + 'static>(&self, f: F) {
|
||||||
let cb: Box<Box<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, logging_cb, Box::into_raw(cb) as *mut _);
|
||||||
|
@ -160,7 +160,7 @@ 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: sys::va_list) {
|
||||||
|
|
||||||
let f: &Box<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);
|
vsnprintf(buf.as_mut_ptr(), BUF_SIZE, fmt, args);
|
||||||
|
@ -330,7 +330,7 @@ impl<'a> EventManager<'a> {
|
||||||
where F: Fn(Event, VLCObject) + Send + 'static
|
where F: Fn(Event, VLCObject) + Send + 'static
|
||||||
{
|
{
|
||||||
// Explicit type annotation is needed
|
// Explicit type annotation is needed
|
||||||
let callback: Box<Box<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 result = unsafe{
|
let result = unsafe{
|
||||||
|
@ -353,7 +353,7 @@ impl<'a> EventManager<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn event_manager_callback(pe: *const sys::libvlc_event_t, data: *mut c_void) {
|
unsafe extern "C" fn event_manager_callback(pe: *const sys::libvlc_event_t, data: *mut c_void) {
|
||||||
let f: &Box<Fn(Event, VLCObject) + Send + 'static> = ::std::mem::transmute(data);
|
let f: &Box<dyn Fn(Event, VLCObject) + Send + 'static> = ::std::mem::transmute(data);
|
||||||
|
|
||||||
f(conv_event(pe), VLCObject{ ptr: (*pe).p_obj });
|
f(conv_event(pe), VLCObject{ ptr: (*pe).p_obj });
|
||||||
}
|
}
|
||||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -17,12 +17,12 @@ mod video;
|
||||||
mod audio;
|
mod audio;
|
||||||
mod vlm;
|
mod vlm;
|
||||||
|
|
||||||
pub use enums::*;
|
pub use crate::enums::*;
|
||||||
pub use core::*;
|
pub use crate::core::*;
|
||||||
pub use media::*;
|
pub use crate::media::*;
|
||||||
pub use media_player::*;
|
pub use crate::media_player::*;
|
||||||
pub use media_list::*;
|
pub use crate::media_list::*;
|
||||||
pub use media_library::*;
|
pub use crate::media_library::*;
|
||||||
pub use video::*;
|
pub use crate::video::*;
|
||||||
pub use audio::*;
|
pub use crate::audio::*;
|
||||||
pub use vlm::*;
|
pub use crate::vlm::*;
|
||||||
|
|
|
@ -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 sys;
|
use crate::sys;
|
||||||
use ::{Instance, EventManager};
|
use crate::{Instance, EventManager};
|
||||||
use ::enums::{State, Meta, TrackType};
|
use crate::enums::{State, Meta, TrackType};
|
||||||
use ::tools::{to_cstr, from_cstr, path_to_cstr};
|
use crate::tools::{to_cstr, from_cstr, path_to_cstr};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub struct Media {
|
pub struct Media {
|
||||||
|
|
|
@ -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 sys;
|
use crate::sys;
|
||||||
use ::{Instance, MediaList};
|
use crate::{Instance, MediaList};
|
||||||
|
|
||||||
pub struct MediaLibrary {
|
pub struct MediaLibrary {
|
||||||
pub(crate) ptr: *mut sys::libvlc_media_library_t,
|
pub(crate) ptr: *mut sys::libvlc_media_library_t,
|
||||||
|
|
|
@ -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 sys;
|
use crate::sys;
|
||||||
use ::{Instance, Media, EventManager};
|
use crate::{Instance, Media, EventManager};
|
||||||
|
|
||||||
pub struct MediaList {
|
pub struct MediaList {
|
||||||
pub(crate) ptr: *mut sys::libvlc_media_list_t,
|
pub(crate) ptr: *mut sys::libvlc_media_list_t,
|
||||||
|
|
|
@ -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 sys;
|
use crate::sys;
|
||||||
use ::Instance;
|
use crate::Instance;
|
||||||
use ::Media;
|
use crate::Media;
|
||||||
use ::EventManager;
|
use crate::EventManager;
|
||||||
use ::libc::{c_void, c_uint};
|
use libc::{c_void, c_uint};
|
||||||
use ::enums::{State, Position};
|
use crate::enums::{State, Position};
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
|
|
||||||
/// A LibVLC media player plays one media (usually in a custom drawable).
|
/// A LibVLC media player plays one media (usually in a custom drawable).
|
||||||
|
@ -90,10 +90,10 @@ impl MediaPlayer {
|
||||||
pub fn set_callbacks<F>(
|
pub fn set_callbacks<F>(
|
||||||
&self,
|
&self,
|
||||||
play: F,
|
play: F,
|
||||||
pause: Option<Box<Fn(i64) + Send + 'static>>,
|
pause: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||||
resume: Option<Box<Fn(i64) + Send + 'static>>,
|
resume: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||||
flush: Option<Box<Fn(i64) + Send + 'static>>,
|
flush: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||||
drain: Option<Box<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();
|
||||||
|
@ -328,11 +328,11 @@ impl Drop for MediaPlayer {
|
||||||
|
|
||||||
// For audio_set_callbacks
|
// For audio_set_callbacks
|
||||||
struct AudioCallbacksData {
|
struct AudioCallbacksData {
|
||||||
play: Box<Fn(*const c_void, u32, i64) + Send + 'static>,
|
play: Box<dyn Fn(*const c_void, u32, i64) + Send + 'static>,
|
||||||
pause: Option<Box<Fn(i64) + Send + 'static>>,
|
pause: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||||
resume: Option<Box<Fn(i64) + Send + 'static>>,
|
resume: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||||
flush: Option<Box<Fn(i64) + Send + 'static>>,
|
flush: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||||
drain: Option<Box<Fn() + Send + 'static>>,
|
drain: Option<Box<dyn Fn() + Send + 'static>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn audio_cb_play(
|
unsafe extern "C" fn audio_cb_play(
|
||||||
|
|
14
src/sys.rs
14
src/sys.rs
|
@ -38,7 +38,7 @@ pub type libvlc_callback_t = unsafe extern "C" fn(*const libvlc_event_t, *mut c_
|
||||||
pub type va_list = *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 type libvlc_log_cb = unsafe extern "C" fn(*mut c_void, c_int, *const libvlc_log_t, *const c_char, va_list);
|
||||||
|
|
||||||
pub use LogLevel as libvlc_log_level;
|
pub use crate::enums::LogLevel as libvlc_log_level;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
@ -99,13 +99,13 @@ pub unsafe fn libvlc_delay(pts: i64) -> i64 {
|
||||||
// From libvlc_media.h
|
// From libvlc_media.h
|
||||||
pub enum libvlc_media_t {}
|
pub enum libvlc_media_t {}
|
||||||
|
|
||||||
pub use Meta as libvlc_meta_t;
|
pub use crate::enums::Meta as libvlc_meta_t;
|
||||||
pub use State as libvlc_state_t;
|
pub use crate::enums::State as libvlc_state_t;
|
||||||
|
|
||||||
pub const libvlc_media_option_trusted: u32 = 0x2;
|
pub const libvlc_media_option_trusted: u32 = 0x2;
|
||||||
pub const libvlc_media_option_unique: u32 = 0x100;
|
pub const libvlc_media_option_unique: u32 = 0x100;
|
||||||
|
|
||||||
pub use TrackType as libvlc_track_type_t;
|
pub use crate::enums::TrackType as libvlc_track_type_t;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
@ -335,8 +335,8 @@ pub enum libvlc_navigate_mode_t {
|
||||||
libvlc_navigate_right,
|
libvlc_navigate_right,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use Position as libvlc_position_t;
|
pub use crate::enums::Position as libvlc_position_t;
|
||||||
pub use VideoAdjustOption as libvlc_video_adjust_option;
|
pub use crate::enums::VideoAdjustOption as libvlc_video_adjust_option;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
@ -575,7 +575,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
// From libvlc_events.h
|
// From libvlc_events.h
|
||||||
pub use EventType as libvlc_event_e;
|
pub use crate::enums::EventType as libvlc_event_e;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub unsafe fn from_cstr_ref<'a>(p: *const c_char) -> Option<Cow<'a, str>> {
|
||||||
|
|
||||||
// Create CString from &Path
|
// Create CString from &Path
|
||||||
pub fn path_to_cstr(path: &Path) -> Result<CString, NulError> {
|
pub fn path_to_cstr(path: &Path) -> Result<CString, NulError> {
|
||||||
let path = try!(CString::new(path.to_string_lossy().into_owned()));
|
let path = CString::new(path.to_string_lossy().into_owned())?;
|
||||||
|
|
||||||
Ok(path)
|
Ok(path)
|
||||||
}
|
}
|
||||||
|
|
12
src/video.rs
12
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 sys;
|
use crate::sys;
|
||||||
use ::MediaPlayer;
|
use crate::MediaPlayer;
|
||||||
use ::TrackDescription;
|
use crate::TrackDescription;
|
||||||
use ::enums::VideoAdjustOption;
|
use crate::enums::VideoAdjustOption;
|
||||||
use ::tools::{to_cstr, from_cstr};
|
use crate::tools::{to_cstr, from_cstr};
|
||||||
use ::libc::c_void;
|
use libc::c_void;
|
||||||
|
|
||||||
pub trait MediaPlayerVideoEx {
|
pub trait MediaPlayerVideoEx {
|
||||||
fn toggle_fullscreen(&self);
|
fn toggle_fullscreen(&self);
|
||||||
|
|
Loading…
Reference in New Issue