Commit 8bb74ef5 authored by Felix Paul Kühne's avatar Felix Paul Kühne

libvlc: expand media player API to retrieve information about all available...

libvlc: expand media player API to retrieve information about all available titles of the currently playing media item
parent 650f0597
...@@ -119,6 +119,8 @@ libVLC: ...@@ -119,6 +119,8 @@ libVLC:
* Add libvlc_audio_output_device_get to get the currently selected audio output device * Add libvlc_audio_output_device_get to get the currently selected audio output device
identifier (if there is one available) identifier (if there is one available)
* Add libvlc_media_get_type to get the type of the media * Add libvlc_media_get_type to get the type of the media
* Add libvlc_media_player_get_full_title_descriptions to get full title info of the media
* Deprecate libvlc_video_get_title_description
Logging Logging
* Support for the SystemD Journal * Support for the SystemD Journal
......
/***************************************************************************** /*****************************************************************************
* libvlc_media_player.h: libvlc_media_player external API * libvlc_media_player.h: libvlc_media_player external API
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2010 VLC authors and VideoLAN * Copyright (C) 1998-2015 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
...@@ -60,6 +60,18 @@ typedef struct libvlc_track_description_t ...@@ -60,6 +60,18 @@ typedef struct libvlc_track_description_t
} libvlc_track_description_t; } libvlc_track_description_t;
/**
* Description for titles. It contains name (description string),
* duration in milliseconds if known,
* and information if it was recognized as a menu by the demuxer.
*/
typedef struct libvlc_title_description_t
{
int64_t i_duration;
char *psz_name;
bool b_menu;
} libvlc_title_description_t;
/** /**
* Description for audio output. It contains * Description for audio output. It contains
* name, description and pointer to next record. * name, description and pointer to next record.
...@@ -1127,9 +1139,36 @@ LIBVLC_API int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi, int64_t ...@@ -1127,9 +1139,36 @@ LIBVLC_API int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi, int64_t
* \return list containing description of available titles. * \return list containing description of available titles.
* It must be freed with libvlc_track_description_list_release() * It must be freed with libvlc_track_description_list_release()
*/ */
LIBVLC_API libvlc_track_description_t * LIBVLC_DEPRECATED LIBVLC_API libvlc_track_description_t *
libvlc_video_get_title_description( libvlc_media_player_t *p_mi ); libvlc_video_get_title_description( libvlc_media_player_t *p_mi );
/**
* Get the full description of available titles
*
* \version LibVLC 3.0.0 and later.
*
* \param p_mi the media player
* \param address to store an allocated array of title descriptions
* descriptions (must be freed with libvlc_title_descriptions_release()
* by the caller) [OUT]
*
* \return the number of titles (-1 on error)
*/
LIBVLC_API int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t *p_mi,
libvlc_title_description_t ***titles );
/**
* Release a title description
*
* \version LibVLC 3.0.0 and later
*
* \param title description array to release
* \param number of title descriptions to release
*/
LIBVLC_API
void libvlc_title_descriptions_release( libvlc_title_description_t **p_titles,
unsigned i_count );
/** /**
* Get the description of available chapters for specific title. * Get the description of available chapters for specific title.
* *
......
/***************************************************************************** /*****************************************************************************
* vlc_input.h: Core input structures * vlc_input.h: Core input structures
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2006 VLC authors and VideoLAN * Copyright (C) 1999-2015 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -92,7 +92,6 @@ typedef struct input_title_t ...@@ -92,7 +92,6 @@ typedef struct input_title_t
/* Title seekpoint */ /* Title seekpoint */
int i_seekpoint; int i_seekpoint;
seekpoint_t **seekpoint; seekpoint_t **seekpoint;
} input_title_t; } input_title_t;
static inline input_title_t *vlc_input_title_New(void) static inline input_title_t *vlc_input_title_New(void)
...@@ -454,6 +453,7 @@ enum input_query_e ...@@ -454,6 +453,7 @@ enum input_query_e
/* titles */ /* titles */
INPUT_GET_TITLE_INFO, /* arg1=input_title_t** arg2= int * res=can fail */ INPUT_GET_TITLE_INFO, /* arg1=input_title_t** arg2= int * res=can fail */
INPUT_GET_FULL_TITLE_INFO, /* arg1=input_title_t*** arg2= int * res=can fail */
/* Attachments */ /* Attachments */
INPUT_GET_ATTACHMENTS, /* arg1=input_attachment_t***, arg2=int* res=can fail */ INPUT_GET_ATTACHMENTS, /* arg1=input_attachment_t***, arg2=int* res=can fail */
......
...@@ -149,6 +149,7 @@ libvlc_media_player_get_chapter ...@@ -149,6 +149,7 @@ libvlc_media_player_get_chapter
libvlc_media_player_get_chapter_count libvlc_media_player_get_chapter_count
libvlc_media_player_get_chapter_count_for_title libvlc_media_player_get_chapter_count_for_title
libvlc_media_player_get_fps libvlc_media_player_get_fps
libvlc_media_player_get_full_title_descriptions
libvlc_media_player_get_hwnd libvlc_media_player_get_hwnd
libvlc_media_player_get_length libvlc_media_player_get_length
libvlc_media_player_get_media libvlc_media_player_get_media
...@@ -204,6 +205,7 @@ libvlc_set_fullscreen ...@@ -204,6 +205,7 @@ libvlc_set_fullscreen
libvlc_set_log_verbosity libvlc_set_log_verbosity
libvlc_set_user_agent libvlc_set_user_agent
libvlc_set_app_id libvlc_set_app_id
libvlc_title_descriptions_release
libvlc_toggle_fullscreen libvlc_toggle_fullscreen
libvlc_toggle_teletext libvlc_toggle_teletext
libvlc_track_description_release libvlc_track_description_release
......
/***************************************************************************** /*****************************************************************************
* media_player.c: Libvlc API Media Instance management functions * media_player.c: Libvlc API Media Instance management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2005-2011 VLC authors and VideoLAN * Copyright (C) 2005-2015 VLC authors and VideoLAN
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* *
...@@ -1330,6 +1330,84 @@ int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi ) ...@@ -1330,6 +1330,84 @@ int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi )
return i_ret == VLC_SUCCESS ? val.i_int : -1; return i_ret == VLC_SUCCESS ? val.i_int : -1;
} }
int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t *p_mi,
libvlc_title_description_t *** pp_titles )
{
assert( p_mi );
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
if( !p_input_thread )
return -1;
input_title_t **p_input_title = NULL;
int *i_titles = 0;
/* fetch data */
int ret = input_Control(p_input_thread, INPUT_GET_FULL_TITLE_INFO, &p_input_title, &i_titles);
vlc_object_release( p_input_thread );
if( ret != VLC_SUCCESS || p_input_title == NULL)
{
return -1;
}
if (i_titles == 0)
{
return 0;
}
const int ci_title_count = (const int)i_titles;
*pp_titles = calloc( ci_title_count, sizeof(**pp_titles) );
if( !*pp_titles )
{
return -1;
}
/* fill array */
for( int i = 0; i < ci_title_count; i++)
{
libvlc_title_description_t *p_title = calloc( 1, sizeof(*p_title) );
if( unlikely(p_title == NULL) )
{
libvlc_title_descriptions_release( *pp_titles, ci_title_count );
free( p_title );
return -1;
}
(*pp_titles)[i] = p_title;
/* we want to return milliseconds to match the rest of the API */
p_title->i_duration = p_input_title[i]->i_length / 1000;
p_title->b_menu = p_input_title[i]->b_menu;
if( p_input_title[i]->psz_name )
{
p_title->psz_name = strdup( p_input_title[i]->psz_name );
}
else
{
p_title->psz_name = NULL;
}
vlc_input_title_Delete( p_input_title[i] );
}
return ci_title_count;
}
void libvlc_title_descriptions_release( libvlc_title_description_t **p_titles,
unsigned i_count )
{
for (unsigned i = 0; i < i_count; i++ )
{
if ( !p_titles[i] )
continue;
free( p_titles[i]->psz_name );
free( p_titles[i] );
}
free( p_titles );
}
void libvlc_media_player_next_chapter( libvlc_media_player_t *p_mi ) void libvlc_media_player_next_chapter( libvlc_media_player_t *p_mi )
{ {
input_thread_t *p_input_thread; input_thread_t *p_input_thread;
......
/***************************************************************************** /*****************************************************************************
* control.c * control.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VLC authors and VideoLAN * Copyright (C) 1999-2015 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Gildas Bazin <gbazin@videolan.org> * Authors: Gildas Bazin <gbazin@videolan.org>
...@@ -358,6 +358,39 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -358,6 +358,39 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
} }
} }
case INPUT_GET_FULL_TITLE_INFO:
{
input_title_t ***array = (input_title_t ***)va_arg( args, input_title_t *** );
int *count = (int *) va_arg( args, int * );
vlc_mutex_lock( &p_input->p->p_item->lock );
const int i_titles = p_input->p->i_title;
*count = i_titles;
if( i_titles == 0 )
{
vlc_mutex_unlock( &p_input->p->p_item->lock );
return VLC_EGENERIC;
}
*array = calloc( i_titles, sizeof(**array) );
if (!array )
{
vlc_mutex_unlock( &p_input->p->p_item->lock );
return VLC_ENOMEM;
}
for( int i = 0; i < i_titles; i++ )
{
(*array)[i] = vlc_input_title_Duplicate( p_input->p->title[i] );
}
vlc_mutex_unlock( &p_input->p->p_item->lock );
return VLC_SUCCESS;
}
case INPUT_GET_VIDEO_FPS: case INPUT_GET_VIDEO_FPS:
pf = (double*)va_arg( args, double * ); pf = (double*)va_arg( args, double * );
......
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