Add get_track_description

merge-requests/7/merge
T. Okubo 2015-12-19 11:23:20 +09:00
parent 76bd1a2340
commit 48d22b29f7
3 changed files with 42 additions and 0 deletions

View File

@ -4,12 +4,15 @@
use ffi;
use ::MediaPlayer;
use ::TrackDescription;
use ::tools::from_cstr;
pub trait MediaPlayerAudioEx {
fn get_mute(&self) -> Option<bool>;
fn set_mute(&self, bool);
fn get_volume(&self) -> i32;
fn set_volume(&self, volume: i32) -> Result<(), ()>;
fn get_audio_track_description(&self) -> Option<Vec<TrackDescription>>;
}
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(()) }
}
}
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)
}
}
}

View File

@ -355,3 +355,9 @@ unsafe extern "C" fn audio_cb_drain(data: *mut c_void) {
(data.drain.as_ref().unwrap())();
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct TrackDescription {
pub id: i32,
pub name: Option<String>,
}

View File

@ -4,6 +4,7 @@
use ffi;
use ::MediaPlayer;
use ::TrackDescription;
use ::enums::VideoAdjustOption;
use ::tools::{to_cstr, from_cstr};
use ::libc::c_void;
@ -22,6 +23,7 @@ pub trait MediaPlayerVideoEx {
fn set_scale(&self, factor: f32);
fn get_aspect_ratio(&self) -> Option<String>;
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 set_adjust_int(&self, option: VideoAdjustOption, value: i32);
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 {
unsafe{ ffi::libvlc_video_get_adjust_int(self.ptr, option as u32) }
}