Merge pull request #5 from alexandre-janniaux/change-edition-2018/MR
Update repository to Rust edition 2018merge-requests/7/merge
commit
97898ed074
|
@ -8,6 +8,7 @@ keywords = ["libVLC", "bindings"]
|
|||
repository = "https://github.com/garkimasera/vlc-rs"
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
name = "vlc"
|
||||
|
|
10
src/audio.rs
10
src/audio.rs
|
@ -2,14 +2,14 @@
|
|||
// This file is part of vlc-rs.
|
||||
// Licensed under the MIT license, see the LICENSE file.
|
||||
|
||||
use sys;
|
||||
use ::MediaPlayer;
|
||||
use ::TrackDescription;
|
||||
use ::tools::from_cstr;
|
||||
use crate::sys;
|
||||
use crate::MediaPlayer;
|
||||
use crate::TrackDescription;
|
||||
use crate::tools::from_cstr;
|
||||
|
||||
pub trait MediaPlayerAudioEx {
|
||||
fn get_mute(&self) -> Option<bool>;
|
||||
fn set_mute(&self, bool);
|
||||
fn set_mute(&self, muted: bool);
|
||||
fn get_volume(&self) -> i32;
|
||||
fn set_volume(&self, volume: i32) -> Result<(), ()>;
|
||||
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::ffi::CString;
|
||||
use std::i32;
|
||||
use sys;
|
||||
use ::tools::{to_cstr, from_cstr, from_cstr_ref};
|
||||
use ::libc::{c_void, c_char, c_int};
|
||||
use ::enums::*;
|
||||
use libc::{c_void, c_char, c_int};
|
||||
use crate::sys;
|
||||
use crate::tools::{to_cstr, from_cstr, from_cstr_ref};
|
||||
use crate::enums::*;
|
||||
|
||||
/// Retrieve libvlc version.
|
||||
pub fn version() -> String {
|
||||
|
@ -121,7 +121,7 @@ impl Instance {
|
|||
|
||||
/// Set logging callback
|
||||
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{
|
||||
sys::libvlc_log_set(self.ptr, logging_cb, Box::into_raw(cb) as *mut _);
|
||||
|
@ -149,7 +149,7 @@ const BUF_SIZE: usize = 1024; // Write log message to the buffer by vsnprintf.
|
|||
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) {
|
||||
|
||||
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];
|
||||
|
||||
vsnprintf(buf.as_mut_ptr(), BUF_SIZE, fmt, args);
|
||||
|
@ -319,7 +319,7 @@ impl<'a> EventManager<'a> {
|
|||
where F: Fn(Event, VLCObject) + Send + 'static
|
||||
{
|
||||
// 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));
|
||||
|
||||
let result = unsafe{
|
||||
|
@ -342,7 +342,7 @@ impl<'a> EventManager<'a> {
|
|||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
|
|
16
src/lib.rs
16
src/lib.rs
|
@ -16,11 +16,11 @@ mod enums;
|
|||
mod video;
|
||||
mod audio;
|
||||
|
||||
pub use enums::*;
|
||||
pub use core::*;
|
||||
pub use media::*;
|
||||
pub use media_player::*;
|
||||
pub use media_list::*;
|
||||
pub use media_library::*;
|
||||
pub use video::*;
|
||||
pub use audio::*;
|
||||
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::*;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// This file is part of vlc-rs.
|
||||
// Licensed under the MIT license, see the LICENSE file.
|
||||
|
||||
use sys;
|
||||
use ::{Instance, EventManager};
|
||||
use ::enums::{State, Meta, TrackType};
|
||||
use ::tools::{to_cstr, from_cstr, path_to_cstr};
|
||||
use crate::sys;
|
||||
use crate::{Instance, EventManager};
|
||||
use crate::enums::{State, Meta, TrackType};
|
||||
use crate::tools::{to_cstr, from_cstr, path_to_cstr};
|
||||
use std::path::Path;
|
||||
|
||||
pub struct Media {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// This file is part of vlc-rs.
|
||||
// Licensed under the MIT license, see the LICENSE file.
|
||||
|
||||
use sys;
|
||||
use ::{Instance, MediaList};
|
||||
use crate::sys;
|
||||
use crate::{Instance, MediaList};
|
||||
|
||||
pub struct MediaLibrary {
|
||||
pub(crate) ptr: *mut sys::libvlc_media_library_t,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// This file is part of vlc-rs.
|
||||
// Licensed under the MIT license, see the LICENSE file.
|
||||
|
||||
use sys;
|
||||
use ::{Instance, Media, EventManager};
|
||||
use crate::sys;
|
||||
use crate::{Instance, Media, EventManager};
|
||||
|
||||
pub struct MediaList {
|
||||
pub(crate) ptr: *mut sys::libvlc_media_list_t,
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
// This file is part of vlc-rs.
|
||||
// Licensed under the MIT license, see the LICENSE file.
|
||||
|
||||
use sys;
|
||||
use ::Instance;
|
||||
use ::Media;
|
||||
use ::EventManager;
|
||||
use ::libc::{c_void, c_uint};
|
||||
use ::enums::{State, Position};
|
||||
use crate::sys;
|
||||
use crate::Instance;
|
||||
use crate::Media;
|
||||
use crate::EventManager;
|
||||
use libc::{c_void, c_uint};
|
||||
use crate::enums::{State, Position};
|
||||
use std::mem::transmute;
|
||||
|
||||
/// A LibVLC media player plays one media (usually in a custom drawable).
|
||||
|
@ -88,10 +88,10 @@ impl MediaPlayer {
|
|||
pub fn set_callbacks<F>(
|
||||
&self,
|
||||
play: F,
|
||||
pause: Option<Box<Fn(i64) + Send + 'static>>,
|
||||
resume: Option<Box<Fn(i64) + Send + 'static>>,
|
||||
flush: Option<Box<Fn(i64) + Send + 'static>>,
|
||||
drain: Option<Box<Fn() + Send + 'static>>)
|
||||
pause: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||
resume: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||
flush: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||
drain: Option<Box<dyn Fn() + Send + 'static>>)
|
||||
where F: Fn(*const c_void, u32, i64) + Send + 'static,
|
||||
{
|
||||
let flag_pause = pause.is_some();
|
||||
|
@ -326,11 +326,11 @@ impl Drop for MediaPlayer {
|
|||
|
||||
// For audio_set_callbacks
|
||||
struct AudioCallbacksData {
|
||||
play: Box<Fn(*const c_void, u32, i64) + Send + 'static>,
|
||||
pause: Option<Box<Fn(i64) + Send + 'static>>,
|
||||
resume: Option<Box<Fn(i64) + Send + 'static>>,
|
||||
flush: Option<Box<Fn(i64) + Send + 'static>>,
|
||||
drain: Option<Box<Fn() + Send + 'static>>,
|
||||
play: Box<dyn Fn(*const c_void, u32, i64) + Send + 'static>,
|
||||
pause: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||
resume: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||
flush: Option<Box<dyn Fn(i64) + Send + 'static>>,
|
||||
drain: Option<Box<dyn Fn() + Send + 'static>>,
|
||||
}
|
||||
|
||||
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 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)]
|
||||
#[derive(Clone, Copy)]
|
||||
|
@ -99,13 +99,13 @@ pub unsafe fn libvlc_delay(pts: i64) -> i64 {
|
|||
// From libvlc_media.h
|
||||
pub enum libvlc_media_t {}
|
||||
|
||||
pub use Meta as libvlc_meta_t;
|
||||
pub use State as libvlc_state_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 TrackType as libvlc_track_type_t;
|
||||
pub use crate::enums::TrackType as libvlc_track_type_t;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
|
@ -335,8 +335,8 @@ pub enum libvlc_navigate_mode_t {
|
|||
libvlc_navigate_right,
|
||||
}
|
||||
|
||||
pub use Position as libvlc_position_t;
|
||||
pub use VideoAdjustOption as libvlc_video_adjust_option;
|
||||
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)]
|
||||
|
@ -575,7 +575,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
// From libvlc_events.h
|
||||
pub use EventType as libvlc_event_e;
|
||||
pub use crate::enums::EventType as libvlc_event_e;
|
||||
|
||||
#[repr(C)]
|
||||
#[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
|
||||
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)
|
||||
}
|
||||
|
|
12
src/video.rs
12
src/video.rs
|
@ -2,12 +2,12 @@
|
|||
// This file is part of vlc-rs.
|
||||
// Licensed under the MIT license, see the LICENSE file.
|
||||
|
||||
use sys;
|
||||
use ::MediaPlayer;
|
||||
use ::TrackDescription;
|
||||
use ::enums::VideoAdjustOption;
|
||||
use ::tools::{to_cstr, from_cstr};
|
||||
use ::libc::c_void;
|
||||
use crate::sys;
|
||||
use crate::MediaPlayer;
|
||||
use crate::TrackDescription;
|
||||
use crate::enums::VideoAdjustOption;
|
||||
use crate::tools::{to_cstr, from_cstr};
|
||||
use libc::c_void;
|
||||
|
||||
pub trait MediaPlayerVideoEx {
|
||||
fn toggle_fullscreen(&self);
|
||||
|
|
Loading…
Reference in New Issue