mirror of
https://code.videolan.org/videolan/vlc
synced 2024-08-27 04:21:53 +02:00
libvlc: Export libvlc_media_parse() and libvlc_media_parse_async().
Else there is no way to properly trigger meta preparsing from libvlc.
This commit is contained in:
parent
a78bada169
commit
8119b3280c
@ -278,6 +278,16 @@ VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t *p_md );
|
||||
/**
|
||||
* Read the meta of the media.
|
||||
*
|
||||
* If the media has not yet been parsed this will return NULL.
|
||||
*
|
||||
* This methods automatically calls libvlc_media_parse_async(), so after calling
|
||||
* it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous
|
||||
* version ensure that you call libvlc_media_parse() before get_meta().
|
||||
*
|
||||
* \see libvlc_media_parse
|
||||
* \see libvlc_media_parse_async
|
||||
* \see libvlc_MediaMetaChanged
|
||||
*
|
||||
* \param p_md the media descriptor
|
||||
* \param e_meta the meta to read
|
||||
* \return the media's meta
|
||||
@ -367,6 +377,41 @@ VLC_PUBLIC_API libvlc_event_manager_t *
|
||||
VLC_PUBLIC_API libvlc_time_t
|
||||
libvlc_media_get_duration( libvlc_media_t * p_md );
|
||||
|
||||
/**
|
||||
* Parse a media.
|
||||
*
|
||||
* This fetches (local) meta data and tracks information.
|
||||
* The method is synchronous.
|
||||
*
|
||||
* \see libvlc_media_parse_async
|
||||
* \see libvlc_media_get_meta
|
||||
* \see libvlc_media_get_es
|
||||
*
|
||||
* \param media media descriptor object
|
||||
*/
|
||||
VLC_PUBLIC_API void
|
||||
libvlc_media_parse(libvlc_media_t *media);
|
||||
|
||||
/**
|
||||
* Parse a media.
|
||||
*
|
||||
* This fetches (local) meta data and tracks information.
|
||||
* The method is the asynchronous of libvlc_media_parse_async().
|
||||
*
|
||||
* To track when this is over you can listen to libvlc_MediaPreparsedChanged
|
||||
* event. However if the media was already preparsed you will not receive this
|
||||
* event.
|
||||
*
|
||||
* \see libvlc_media_parse
|
||||
* \see libvlc_MediaPreparsedChanged
|
||||
* \see libvlc_media_get_meta
|
||||
* \see libvlc_media_get_es
|
||||
*
|
||||
* \param media media descriptor object
|
||||
*/
|
||||
VLC_PUBLIC_API void
|
||||
libvlc_media_parse_async(libvlc_media_t *media);
|
||||
|
||||
/**
|
||||
* Get preparsed status for media descriptor object.
|
||||
*
|
||||
|
@ -158,19 +158,26 @@ static void input_item_duration_changed( const vlc_event_t *p_event,
|
||||
/**************************************************************************
|
||||
* input_item_preparsed_changed (Private) (vlc event Callback)
|
||||
**************************************************************************/
|
||||
static void input_item_preparsed_changed( const vlc_event_t *p_event,
|
||||
void * user_data )
|
||||
static void input_item_preparsed_changed(const vlc_event_t *p_event,
|
||||
void * user_data)
|
||||
{
|
||||
libvlc_media_t * p_md = user_data;
|
||||
libvlc_media_t *media = user_data;
|
||||
libvlc_event_t event;
|
||||
|
||||
/* Eventually notify libvlc_media_parse() */
|
||||
vlc_mutex_lock(&media->parsed_lock);
|
||||
media->is_parsed = true;
|
||||
vlc_cond_broadcast(&media->parsed_cond);
|
||||
vlc_mutex_unlock(&media->parsed_lock);
|
||||
|
||||
|
||||
/* Construct the event */
|
||||
event.type = libvlc_MediaPreparsedChanged;
|
||||
event.u.media_preparsed_changed.new_status =
|
||||
p_event->u.input_item_preparsed_changed.new_status;
|
||||
|
||||
/* Send the event */
|
||||
libvlc_event_send( p_md->p_event_manager, &event );
|
||||
libvlc_event_send(media->p_event_manager, &event);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
@ -225,12 +232,12 @@ static void uninstall_input_item_observer( libvlc_media_t *p_md )
|
||||
static void preparse_if_needed( libvlc_media_t *p_md )
|
||||
{
|
||||
/* XXX: need some locking here */
|
||||
if (!p_md->b_preparsed)
|
||||
if (!p_md->has_asked_preparse)
|
||||
{
|
||||
playlist_PreparseEnqueue(
|
||||
libvlc_priv (p_md->p_libvlc_instance->p_libvlc_int)->p_playlist,
|
||||
p_md->p_input_item );
|
||||
p_md->b_preparsed = true;
|
||||
p_md->has_asked_preparse = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,6 +269,9 @@ libvlc_media_t * libvlc_media_new_from_input_item(
|
||||
p_md->p_input_item = p_input_item;
|
||||
p_md->i_refcount = 1;
|
||||
|
||||
vlc_cond_init(&p_md->parsed_cond);
|
||||
vlc_mutex_init(&p_md->parsed_lock);
|
||||
|
||||
p_md->state = libvlc_NothingSpecial;
|
||||
|
||||
/* A media descriptor can be a playlist. When you open a playlist
|
||||
@ -607,6 +617,29 @@ libvlc_media_get_duration( libvlc_media_t * p_md )
|
||||
return from_mtime(input_item_GetDuration( p_md->p_input_item ));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Parse the media.
|
||||
**************************************************************************/
|
||||
void
|
||||
libvlc_media_parse(libvlc_media_t *media)
|
||||
{
|
||||
preparse_if_needed(media);
|
||||
|
||||
vlc_mutex_lock(&media->parsed_lock);
|
||||
while (!media->is_parsed)
|
||||
vlc_cond_wait(&media->parsed_cond, &media->parsed_lock);
|
||||
vlc_mutex_unlock(&media->parsed_lock);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Parse the media.
|
||||
**************************************************************************/
|
||||
void
|
||||
libvlc_media_parse_async(libvlc_media_t *media)
|
||||
{
|
||||
preparse_if_needed(media);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Get preparsed status for media object.
|
||||
**************************************************************************/
|
||||
|
@ -34,13 +34,18 @@
|
||||
struct libvlc_media_t
|
||||
{
|
||||
libvlc_event_manager_t * p_event_manager;
|
||||
int b_preparsed;
|
||||
input_item_t *p_input_item;
|
||||
int i_refcount;
|
||||
libvlc_instance_t *p_libvlc_instance;
|
||||
libvlc_state_t state;
|
||||
VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t*) p_subitems; /* A media descriptor can have Sub items. This is the only dependancy we really have on media_list */
|
||||
void *p_user_data;
|
||||
|
||||
vlc_cond_t parsed_cond;
|
||||
vlc_mutex_t parsed_lock;
|
||||
|
||||
bool is_parsed;
|
||||
bool has_asked_preparse;
|
||||
bool has_asked_art;
|
||||
};
|
||||
|
||||
|
@ -102,6 +102,8 @@ libvlc_media_new_location
|
||||
libvlc_media_new_path
|
||||
libvlc_media_new_as_node
|
||||
libvlc_media_new_from_input_item
|
||||
libvlc_media_parse
|
||||
libvlc_media_parse_async
|
||||
libvlc_media_player_can_pause
|
||||
libvlc_media_player_next_frame
|
||||
libvlc_media_player_event_manager
|
||||
|
Loading…
Reference in New Issue
Block a user