diff options
author | Minh Ngo <nlminhtl@gmail.com> | 2013-10-19 15:33:02 +0300 |
---|---|---|
committer | Minh Ngo <nlminhtl@gmail.com> | 2013-10-19 15:36:49 +0300 |
commit | 5b24f86c1c2d64e99da1535c05139a1266dcbcc1 (patch) | |
tree | 9a451066448849b57b738f61a8a027609523c297 /avmedia | |
parent | 16eda8aa564101645908b11d42a63761f751aae6 (diff) |
avmedia/vlc: setting a correct video/audio track
Change-Id: I935e64f9df74193aba17d00cfe7f37ad3f4f9077
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/vlc/wrapper/Player.cxx | 36 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/Types.hxx | 11 |
2 files changed, 42 insertions, 5 deletions
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx index d8608d804053..cd572675c615 100644 --- a/avmedia/source/vlc/wrapper/Player.cxx +++ b/avmedia/source/vlc/wrapper/Player.cxx @@ -12,7 +12,7 @@ #include "Player.hxx" #include "Media.hxx" #include "SymbolLoader.hxx" - #include "Common.hxx" +#include "Common.hxx" struct libvlc_media_t; @@ -52,6 +52,12 @@ namespace int ( *libvlc_video_get_size ) ( libvlc_media_player_t *p_mi, unsigned num, unsigned *px, unsigned *py ); int ( *libvlc_video_get_track_count ) ( libvlc_media_player_t *p_mi ); + int ( *libvlc_video_set_track ) ( libvlc_media_player_t *p_mi, int i_track ); + libvlc_track_description_t* ( *libvlc_video_get_track_description ) ( libvlc_media_player_t *p_mi ); + + int ( *libvlc_audio_get_track ) ( libvlc_media_player_t *p_mi ); + libvlc_track_description_t * ( *libvlc_audio_get_track_description ) (libvlc_media_player_t *p_mi ); + int ( *libvlc_audio_set_track ) (libvlc_media_player_t *p_mi, int i_track); } namespace avmedia @@ -90,7 +96,12 @@ namespace wrapper SYM_MAP( libvlc_media_player_retain ), SYM_MAP( libvlc_video_set_scale ), SYM_MAP( libvlc_video_get_size ), - SYM_MAP( libvlc_video_get_track_count ) + SYM_MAP( libvlc_video_get_track_count ), + SYM_MAP( libvlc_video_set_track ), + SYM_MAP( libvlc_video_get_track_description ), + SYM_MAP( libvlc_audio_get_track ), + SYM_MAP( libvlc_audio_get_track_description ), + SYM_MAP( libvlc_audio_set_track ) }; return InitApiMap( VLC_PLAYER_API ); @@ -121,7 +132,26 @@ namespace wrapper bool Player::play() { - return libvlc_media_player_play( mPlayer ) == 0; + const bool status = ( libvlc_media_player_play( mPlayer ) == 0 ); + if ( libvlc_video_get_track_count( mPlayer ) > 0 ) + { + const libvlc_track_description_t *description = libvlc_video_get_track_description( mPlayer ); + + for ( ; description->p_next != NULL; description = description->p_next ); + + libvlc_video_set_track( mPlayer, description->i_id ); + } + + if ( libvlc_audio_get_track( mPlayer ) > 0 ) + { + const libvlc_track_description_t *description = libvlc_audio_get_track_description( mPlayer ); + + for ( ; description->p_next != NULL; description = description->p_next ); + + libvlc_audio_set_track( mPlayer, description->i_id ); + } + + return status; } void Player::pause() diff --git a/avmedia/source/vlc/wrapper/Types.hxx b/avmedia/source/vlc/wrapper/Types.hxx index 624ef13df413..06a0674c06da 100644 --- a/avmedia/source/vlc/wrapper/Types.hxx +++ b/avmedia/source/vlc/wrapper/Types.hxx @@ -23,7 +23,7 @@ typedef void ( *libvlc_callback_t ) ( const struct libvlc_event_t *, void * ); #define libvlc_MediaPlayerEndReached 0x109 // event structure pieces we use -typedef struct libvlc_event_t +struct libvlc_event_t { int type; // event type void *p_obj; // object emitting that event @@ -35,7 +35,14 @@ typedef struct libvlc_event_t const char *dummy2; } padding; } u; -} libvlc_event_t; +}; + +struct libvlc_track_description_t +{ + int i_id; + char *psz_name; + libvlc_track_description_t *p_next; +}; } |