Commit 816aefe8 authored by Lukas Durfina's avatar Lukas Durfina Committed by Jean-Baptiste Kempf

libvlc: description and count of tracks, titles, chapters and subtitles

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 94757879
......@@ -721,6 +721,13 @@ VLC_PUBLIC_API int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi,
*/
VLC_PUBLIC_API int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e );
/**
* Release (free) libvlc_track_description_t
*
* \param p_track_description the structure to release
*/
VLC_PUBLIC_API void libvlc_track_description_release( libvlc_track_description_t *p_track_description );
/** \defgroup libvlc_video libvlc_video
* \ingroup libvlc_media_player
* LibVLC Video handling
......@@ -798,6 +805,25 @@ VLC_PUBLIC_API void libvlc_video_set_aspect_ratio( libvlc_media_player_t *, char
*/
VLC_PUBLIC_API int libvlc_video_get_spu( libvlc_media_player_t *, libvlc_exception_t * );
/**
* Get the number of available video subtitles.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the number of available video subtitles
*/
VLC_PUBLIC_API int libvlc_video_get_spu_count( libvlc_media_player_t *, libvlc_exception_t * );
/**
* Get the description of available video subtitles.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return list containing description of available video subtitles
*/
VLC_PUBLIC_API libvlc_track_description_t *
libvlc_video_get_spu_description( libvlc_media_player_t *, libvlc_exception_t * );
/**
* Set new video subtitle.
*
......@@ -817,6 +843,27 @@ VLC_PUBLIC_API void libvlc_video_set_spu( libvlc_media_player_t *, int , libvlc_
*/
VLC_PUBLIC_API int libvlc_video_set_subtitle_file( libvlc_media_player_t *, char *, libvlc_exception_t * );
/**
* Get the description of available titles.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return list containing description of available titles
*/
VLC_PUBLIC_API libvlc_track_description_t *
libvlc_video_get_title_description( libvlc_media_player_t *, libvlc_exception_t * );
/**
* Get the description of available chapters for specific title.
*
* \param p_mediaplayer the media player
* \param i_title selected title
* \param p_e an initialized exception pointer
* \return list containing description of available chapter for title i_title
*/
VLC_PUBLIC_API libvlc_track_description_t *
libvlc_video_get_chapter_description( libvlc_media_player_t *, int, libvlc_exception_t * );
/**
* Get current crop filter geometry.
*
......@@ -861,6 +908,43 @@ VLC_PUBLIC_API int libvlc_video_get_teletext( libvlc_media_player_t *, libvlc_ex
*/
VLC_PUBLIC_API void libvlc_video_set_teletext( libvlc_media_player_t *, int, libvlc_exception_t * );
/**
* Get number of available video tracks.
*
* \param p_mi media player
* \param p_e an initialized exception
* \return the number of available video tracks (int)
*/
VLC_PUBLIC_API int libvlc_video_get_track_count( libvlc_media_player_t *, libvlc_exception_t * );
/**
* Get the description of available video tracks.
*
* \param p_mi media player
* \param p_e an initialized exception
* \return list with description of available video tracks
*/
VLC_PUBLIC_API libvlc_track_description_t *
libvlc_video_get_track_description( libvlc_media_player_t *, libvlc_exception_t * );
/**
* Get current video track.
*
* \param p_mi media player
* \param p_e an initialized exception pointer
* \return the video track (int)
*/
VLC_PUBLIC_API int libvlc_video_get_track( libvlc_media_player_t *, libvlc_exception_t * );
/**
* Set video track.
*
* \param p_mi media player
* \param i_track the track (int)
* \param p_e an initialized exception pointer
*/
VLC_PUBLIC_API void libvlc_video_set_track( libvlc_media_player_t *, int, libvlc_exception_t * );
/**
* Take a snapshot of the current video window.
*
......
......@@ -209,6 +209,30 @@ typedef struct libvlc_playlist_item_t
/**@} */
/*****************************************************************************
* Media Player
*****************************************************************************/
/** \defgroup libvlc_media_player libvlc_media_player
* \ingroup libvlc
* LibVLC Media Player, object that let you play a media
* in a libvlc_drawable_t
* @{
*/
/**
* Description for video, audio tracks and subtitles. It contains
* id, name (description string) and pointer to next record.
*/
typedef struct libvlc_track_description_t
{
int i_id;
char *psz_name;
struct libvlc_track_description_t *p_next;
} libvlc_track_description_t;
/**@} */
/*****************************************************************************
* Video
......@@ -218,7 +242,7 @@ typedef struct libvlc_playlist_item_t
* LibVLC Video handling
* @{
*/
/**
* Downcast to this general type as placeholder for a platform specific one, such as:
* Drawable on X11,
......
......@@ -120,7 +120,7 @@ void libvlc_audio_set_volume( libvlc_instance_t *p_instance, int i_volume,
/*****************************************************************************
* libvlc_audio_get_track_count : Get the number of available audio tracks
*****************************************************************************/
int libvlc_audio_get_track_count( libvlc_media_player_t *p_mi,
int libvlc_audio_get_track_count( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
......@@ -134,6 +134,16 @@ int libvlc_audio_get_track_count( libvlc_media_player_t *p_mi,
return val_list.p_list->i_count;
}
/*****************************************************************************
* libvlc_audio_get_track_description : Get the description of available audio tracks
*****************************************************************************/
libvlc_track_description_t *
libvlc_audio_get_track_description( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
return libvlc_get_track_description( p_mi, "audio-es", p_e);
}
/*****************************************************************************
* libvlc_audio_get_track : Get the current audio track
*****************************************************************************/
......
......@@ -91,7 +91,7 @@ struct libvlc_media_list_t
libvlc_media_t * p_md; /* The media from which the
* mlist comes, if any. */
vlc_array_t items;
/* Other way to see that media list */
/* Used in flat_media_list.c */
libvlc_media_list_t * p_flat_mlist;
......@@ -126,7 +126,7 @@ struct libvlc_media_list_view_t
libvlc_instance_t * p_libvlc_instance;
int i_refcount;
vlc_mutex_t object_lock;
libvlc_media_list_t * p_mlist;
struct libvlc_media_list_view_private_t * p_this_view_data;
......@@ -153,7 +153,7 @@ struct libvlc_media_player_t
libvlc_media_t * p_md; /* current media descriptor */
libvlc_event_manager_t * p_event_manager;
libvlc_drawable_t drawable;
bool b_own_its_input_thread;
};
......@@ -339,6 +339,12 @@ void libvlc_event_send(
libvlc_event_manager_t * p_em,
libvlc_event_t * p_event );
/* Media player - audio, video */
libvlc_track_description_t * libvlc_get_track_description(
libvlc_media_player_t *p_mi,
const char *psz_variable,
libvlc_exception_t *p_e );
/* Exception shorcuts */
......
......@@ -1117,6 +1117,78 @@ int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi,
return val.b_bool;
}
/* internal function, used by audio, video */
libvlc_track_description_t *
libvlc_get_track_description( libvlc_media_player_t *p_mi,
const char *psz_variable,
libvlc_exception_t *p_e )
{
input_thread_t *p_input = libvlc_get_input_thread( p_mi, p_e );
if( !p_input )
return NULL;
vlc_value_t val_list, text_list;
var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list);
if( val_list.p_list->i_count <= 0 ) /* no tracks */
return NULL;
libvlc_track_description_t *p_track_description, *p_actual, *p_previous;
p_track_description = ( libvlc_track_description_t * )
malloc( sizeof( libvlc_track_description_t ) );
if ( !p_track_description )
{
var_Change( p_input, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list);
vlc_object_release( p_input );
libvlc_exception_raise( p_e, "no enough memory" );
return NULL;
}
p_actual = p_track_description;
p_previous = NULL;
for( int i = 0; i < val_list.p_list->i_count; i++ )
{
if( !p_actual )
{
p_actual = ( libvlc_track_description_t * )
malloc( sizeof( libvlc_track_description_t ) );
if ( !p_actual )
{
libvlc_track_description_release( p_track_description );
var_Change( p_input, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list);
vlc_object_release( p_input );
libvlc_exception_raise( p_e, "no enough memory" );
return NULL;
}
}
p_actual->i_id = val_list.p_list->p_values[i].i_int;
p_actual->psz_name = strdup( text_list.p_list->p_values[i].psz_string );
p_actual->p_next = NULL;
if( p_previous )
p_previous->p_next = p_actual;
p_previous = p_actual;
p_actual = NULL;
}
var_Change( p_input, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list);
vlc_object_release( p_input );
return p_track_description;
}
void libvlc_track_description_release( libvlc_track_description_t *p_track_description )
{
libvlc_track_description_t *p_actual, *p_before;
p_actual = p_track_description;
while ( p_actual )
{
free( p_actual->psz_name );
p_before = p_actual;
p_actual = p_before->p_next;
free( p_before );
}
}
int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
......
......@@ -383,6 +383,27 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi,
return i_spu;
}
int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
vlc_value_t val_list;
if( !p_input_thread )
return -1;
var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
vlc_object_release( p_input_thread );
return val_list.p_list->i_count;
}
libvlc_track_description_t *
libvlc_video_get_spu_description( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
return libvlc_get_track_description( p_mi, "spu-es", p_e);
}
void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu,
libvlc_exception_t *p_e )
{
......@@ -426,6 +447,23 @@ int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi,
return b_ret;
}
libvlc_track_description_t *
libvlc_video_get_title_description( libvlc_media_player_t *p_mi,
libvlc_exception_t * p_e )
{
return libvlc_get_track_description( p_mi, "title", p_e);
}
libvlc_track_description_t *
libvlc_video_get_chapter_description( libvlc_media_player_t *p_mi,
int i_title,
libvlc_exception_t *p_e )
{
char psz_title[12];
sprintf( psz_title, "title %2i", i_title );
return libvlc_get_track_description( p_mi, psz_title, p_e);
}
char *libvlc_video_get_crop_geometry( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
......@@ -559,6 +597,90 @@ void libvlc_toggle_teletext( libvlc_media_player_t *p_mi,
vlc_object_release( p_input_thread );
}
int libvlc_video_get_track_count( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
vlc_value_t val_list;
if( !p_input_thread )
return -1;
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
vlc_object_release( p_input_thread );
return val_list.p_list->i_count;
}
libvlc_track_description_t *
libvlc_video_get_track_description( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
return libvlc_get_track_description( p_mi, "video-es", p_e);
}
int libvlc_video_get_track( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
vlc_value_t val_list;
vlc_value_t val;
int i_track = -1;
int i_ret = -1;
int i;
if( !p_input_thread )
return -1;
i_ret = var_Get( p_input_thread, "video-es", &val );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e, "Getting Video track information failed" );
vlc_object_release( p_input_thread );
return i_ret;
}
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ )
{
vlc_value_t track_val = val_list.p_list->p_values[i];
if( track_val.i_int == val.i_int )
{
i_track = i;
break;
}
}
vlc_object_release( p_input_thread );
return i_track;
}
void libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
vlc_value_t val_list;
int i_ret = -1;
int i;
if( !p_input_thread )
return;
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ )
{
vlc_value_t val = val_list.p_list->p_values[i];
if( i_track == val.i_int )
{
i_ret = var_Set( p_input_thread, "audio-es", val );
if( i_ret < 0 )
libvlc_exception_raise( p_e, "Setting video track failed" );
vlc_object_release( p_input_thread );
return;
}
}
libvlc_exception_raise( p_e, "Video track out of range" );
vlc_object_release( p_input_thread );
}
int libvlc_video_destroy( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
{
......
......@@ -3,6 +3,7 @@ libvlc_audio_get_channel
libvlc_audio_get_mute
libvlc_audio_get_track
libvlc_audio_get_track_count
libvlc_audio_get_track_description
libvlc_audio_get_volume
libvlc_audio_set_channel
libvlc_audio_set_mute
......@@ -169,13 +170,21 @@ libvlc_set_fullscreen
libvlc_set_log_verbosity
libvlc_toggle_fullscreen
libvlc_toggle_teletext
libvlc_track_description_release
libvlc_video_destroy
libvlc_video_get_aspect_ratio
libvlc_video_get_chapter_description
libvlc_video_get_crop_geometry
libvlc_video_get_height
libvlc_video_get_parent
libvlc_video_get_spu
libvlc_video_get_spu_count
libvlc_video_get_spu_description
libvlc_video_get_teletext
libvlc_video_get_title_description
libvlc_video_get_track
libvlc_video_get_track_count
libvlc_video_get_track_description
libvlc_video_get_width
libvlc_video_redraw_rectangle
libvlc_video_reparent
......@@ -187,6 +196,7 @@ libvlc_video_set_size
libvlc_video_set_spu
libvlc_video_set_subtitle_file
libvlc_video_set_teletext
libvlc_video_set_track
libvlc_video_set_viewport
libvlc_video_take_snapshot
libvlc_vlm_add_broadcast
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment