Add get_track_description
parent
76bd1a2340
commit
48d22b29f7
19
src/audio.rs
19
src/audio.rs
|
@ -4,12 +4,15 @@
|
||||||
|
|
||||||
use ffi;
|
use ffi;
|
||||||
use ::MediaPlayer;
|
use ::MediaPlayer;
|
||||||
|
use ::TrackDescription;
|
||||||
|
use ::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, 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>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MediaPlayerAudioEx for MediaPlayer {
|
impl MediaPlayerAudioEx for MediaPlayer {
|
||||||
|
@ -37,4 +40,20 @@ impl MediaPlayerAudioEx for MediaPlayer {
|
||||||
if ffi::libvlc_audio_set_volume(self.ptr, volume) == 0 { Ok(()) }else{ Err(()) }
|
if ffi::libvlc_audio_set_volume(self.ptr, volume) == 0 { Ok(()) }else{ Err(()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>> {
|
||||||
|
unsafe{
|
||||||
|
let p0 = ffi::libvlc_audio_get_track_description(self.ptr);
|
||||||
|
if p0.is_null() { return None; }
|
||||||
|
let mut td = Vec::new();
|
||||||
|
let mut p = p0;
|
||||||
|
|
||||||
|
while !(*p).p_next.is_null() {
|
||||||
|
td.push(TrackDescription{ id: (*p).i_id, name: from_cstr((*p).psz_name) });
|
||||||
|
p = (*p).p_next;
|
||||||
|
}
|
||||||
|
ffi::libvlc_track_description_list_release(p0);
|
||||||
|
Some(td)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,3 +355,9 @@ unsafe extern "C" fn audio_cb_drain(data: *mut c_void) {
|
||||||
(data.drain.as_ref().unwrap())();
|
(data.drain.as_ref().unwrap())();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
|
pub struct TrackDescription {
|
||||||
|
pub id: i32,
|
||||||
|
pub name: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
17
src/video.rs
17
src/video.rs
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use ffi;
|
use ffi;
|
||||||
use ::MediaPlayer;
|
use ::MediaPlayer;
|
||||||
|
use ::TrackDescription;
|
||||||
use ::enums::VideoAdjustOption;
|
use ::enums::VideoAdjustOption;
|
||||||
use ::tools::{to_cstr, from_cstr};
|
use ::tools::{to_cstr, from_cstr};
|
||||||
use ::libc::c_void;
|
use ::libc::c_void;
|
||||||
|
@ -22,6 +23,7 @@ pub trait MediaPlayerVideoEx {
|
||||||
fn set_scale(&self, factor: f32);
|
fn set_scale(&self, factor: f32);
|
||||||
fn get_aspect_ratio(&self) -> Option<String>;
|
fn get_aspect_ratio(&self) -> Option<String>;
|
||||||
fn set_aspect_ratio(&self, aspect: Option<&str>);
|
fn set_aspect_ratio(&self, aspect: Option<&str>);
|
||||||
|
fn get_video_track_description(&self) -> Option<Vec<TrackDescription>>;
|
||||||
fn get_adjust_int(&self, option: VideoAdjustOption) -> i32;
|
fn get_adjust_int(&self, option: VideoAdjustOption) -> i32;
|
||||||
fn set_adjust_int(&self, option: VideoAdjustOption, value: i32);
|
fn set_adjust_int(&self, option: VideoAdjustOption, value: i32);
|
||||||
fn get_adjust_float(&self, option: VideoAdjustOption) -> f32;
|
fn get_adjust_float(&self, option: VideoAdjustOption) -> f32;
|
||||||
|
@ -92,6 +94,21 @@ impl MediaPlayerVideoEx for MediaPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn get_video_track_description(&self) -> Option<Vec<TrackDescription>> {
|
||||||
|
unsafe{
|
||||||
|
let p0 = ffi::libvlc_video_get_track_description(self.ptr);
|
||||||
|
if p0.is_null() { return None; }
|
||||||
|
let mut td = Vec::new();
|
||||||
|
let mut p = p0;
|
||||||
|
|
||||||
|
while !(*p).p_next.is_null() {
|
||||||
|
td.push(TrackDescription{ id: (*p).i_id, name: from_cstr((*p).psz_name) });
|
||||||
|
p = (*p).p_next;
|
||||||
|
}
|
||||||
|
ffi::libvlc_track_description_list_release(p0);
|
||||||
|
Some(td)
|
||||||
|
}
|
||||||
|
}
|
||||||
fn get_adjust_int(&self, option: VideoAdjustOption) -> i32 {
|
fn get_adjust_int(&self, option: VideoAdjustOption) -> i32 {
|
||||||
unsafe{ ffi::libvlc_video_get_adjust_int(self.ptr, option as u32) }
|
unsafe{ ffi::libvlc_video_get_adjust_int(self.ptr, option as u32) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue