Commit af0e55a0 authored by Thomas Guillem's avatar Thomas Guillem

libvlc: add libvlc_MediaParsedStatus event

This event is always sent after libvlc_media_parse_with_options is successfuly
called.
parent 01d3be26
......@@ -53,6 +53,7 @@ enum libvlc_event_e {
libvlc_MediaFreed,
libvlc_MediaStateChanged,
libvlc_MediaSubItemTreeAdded,
libvlc_MediaParsedStatus,
libvlc_MediaPlayerMediaChanged=0x100,
libvlc_MediaPlayerNothingSpecial,
......@@ -154,6 +155,10 @@ typedef struct libvlc_event_t
{
libvlc_media_t * item;
} media_subitemtree_added;
struct
{
int new_status;
} media_parsed_status;
/* media instance */
struct
......
......@@ -275,6 +275,19 @@ typedef enum libvlc_media_parse_flag_t
libvlc_media_do_interact = 0x08,
} libvlc_media_parse_flag_t;
/**
* Parse status used sent by libvlc_media_parse_with_options()
*
* \see libvlc_media_parse_with_options
*/
typedef enum libvlc_media_parsed_status_t
{
libvlc_media_parse_init,
libvlc_media_parse_skipped,
libvlc_media_parse_failed,
libvlc_media_parse_done,
} libvlc_media_parsed_status_t;
/**
* Callback prototype to open a custom bitstream input media.
*
......@@ -665,15 +678,15 @@ libvlc_media_parse_async( libvlc_media_t *p_md );
* This fetches (local or network) art, meta data and/or tracks information.
* This method is the extended version of libvlc_media_parse_async().
*
* To track when this is over you can listen to libvlc_MediaParsedChanged
* event. However if this functions returns an error, you will not receive this
* event.
* To track when this is over you can listen to libvlc_MediaParsedStatus
* event. However if this functions returns an error, you will not receive any
* events.
*
* It uses a flag to specify parse options (see libvlc_media_parse_flag_t). All
* these flags can be combined. By default, media is parsed if it's a local
* file.
*
* \see libvlc_MediaParsedChanged
* \see libvlc_MediaParsedStatus
* \see libvlc_media_get_meta
* \see libvlc_media_tracks_get
* \see libvlc_media_parse_flag_t
......
......@@ -257,6 +257,26 @@ static void input_item_preparse_ended( const vlc_event_t * p_event,
VLC_UNUSED( p_event );
libvlc_media_t * p_md = user_data;
libvlc_media_list_t *p_subitems = media_get_subitems( p_md, false );
libvlc_event_t event;
event.type = libvlc_MediaParsedStatus;
vlc_mutex_lock(&p_md->parsed_lock);
switch (p_event->u.input_item_preparse_ended.new_status)
{
case ITEM_PREPARSE_SKIPPED:
p_md->parsed_status = libvlc_media_parse_skipped;
p_md->has_asked_preparse = false;
break;
case ITEM_PREPARSE_FAILED:
p_md->parsed_status = libvlc_media_parse_failed;
break;
case ITEM_PREPARSE_DONE:
p_md->parsed_status = libvlc_media_parse_done;
break;
}
event.u.media_parsed_status.new_status = p_md->parsed_status;
vlc_mutex_unlock(&p_md->parsed_lock);
if( p_subitems != NULL )
{
......@@ -270,6 +290,8 @@ static void input_item_preparse_ended( const vlc_event_t * p_event,
* libvlc_MediaParsedChanged was sent with a true status. Therefore, send
* this event if it was not previously sent */
send_preparsed_event(p_md);
libvlc_event_send(p_md->p_event_manager, &event);
}
/**************************************************************************
......
......@@ -45,6 +45,7 @@ struct libvlc_media_t
vlc_mutex_t parsed_lock;
vlc_mutex_t subitems_lock;
int parsed_status;
bool is_parsed;
bool has_asked_preparse;
};
......
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