[vlc-devel] Adding Fetching and Idle in SD
Francois Cartegnie
fcvlcdev at free.fr
Sun Jan 20 20:43:29 CET 2013
Hi,
With most of lua SD, end user just sees nothing on activation.
He also can't tell if there's a problem or just no result.
SD state is unknown until first items are added to playlist or unless
you're watching the logs.
I'd like to add Fetching & Idle events to get more info on SD states.
The current problem is:
- SD are private within playlist.
- playlist doesn't emit events. (neither playlist_items)
I don't see how the UI could place a listener for those events.
Do we really need to only work with input at this level ?
Francois
diff --git a/include/vlc_events.h b/include/vlc_events.h
index 9e37f7f..527f4fb 100644
--- a/include/vlc_events.h
+++ b/include/vlc_events.h
@@ -128,8 +128,10 @@ typedef enum vlc_event_type_t {
vlc_ServicesDiscoveryItemAdded,
vlc_ServicesDiscoveryItemRemoved,
vlc_ServicesDiscoveryItemRemoveAll,
- vlc_ServicesDiscoveryStarted,
- vlc_ServicesDiscoveryEnded
+ vlc_ServicesDiscoveryStarted, /* module successfully
loaded/initialized */
+ vlc_ServicesDiscoveryEnded,
+ vlc_ServicesDiscoveryFetching, /* trying to retrieve new data */
+ vlc_ServicesDiscoveryIdle
} vlc_event_type_t;
/* Event definition */
@@ -201,6 +203,10 @@ typedef struct vlc_event_t
{
void * unused;
} services_discovery_ended;
+ struct vlc_services_discovery_fetching_idle
+ {
+ const char * psz_name;
+ } services_discovery_fetching, services_discovery_idle;
} u;
} vlc_event_t;
diff --git a/src/playlist/services_discovery.c
b/src/playlist/services_discovery.c
index e413f9b..1677051 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -123,6 +123,8 @@ services_discovery_t *vlc_sd_Create( vlc_object_t
*p_super,
vlc_event_manager_register_event_type(em,
vlc_ServicesDiscoveryItemRemoveAll);
vlc_event_manager_register_event_type(em,
vlc_ServicesDiscoveryStarted);
vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryEnded);
+ vlc_event_manager_register_event_type(em,
vlc_ServicesDiscoveryFetching);
+ vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryIdle);
vlc_object_set_destructor( p_sd, services_discovery_Destructor );
return p_sd;
@@ -331,6 +333,24 @@ static void playlist_sd_item_removeall( const
vlc_event_t * p_event, void * user
PL_UNLOCK;
}
+/* A SD starts fetching new data */
+static void playlist_sd_fetching( const vlc_event_t * p_event, void *
user_data )
+{
+ const char * psz_name = p_event->u.services_discovery_fetching.psz_name;
+ playlist_item_t * p_sd_node = user_data;
+ playlist_t *p_playlist = p_sd_node->p_playlist;
+ msg_Err( p_playlist, "discovery FETCHING %s", psz_name );
+}
+
+/* A SD waits event or condition to fetch new data */
+static void playlist_sd_idle( const vlc_event_t * p_event, void *
user_data )
+{
+ const char * psz_name = p_event->u.services_discovery_idle.psz_name;
+ playlist_item_t * p_sd_node = user_data;
+ playlist_t *p_playlist = p_sd_node->p_playlist;
+ msg_Err( p_playlist, "discovery IDLE %s", psz_name );
+}
+
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
const char *psz_name )
{
@@ -383,6 +403,12 @@ int playlist_ServicesDiscoveryAdd( playlist_t
*p_playlist,
vlc_event_attach( em, vlc_ServicesDiscoveryItemRemoveAll,
playlist_sd_item_removeall, p_node );
+ vlc_event_attach( em, vlc_ServicesDiscoveryFetching,
+ playlist_sd_fetching, p_node );
+
+ vlc_event_attach( em, vlc_ServicesDiscoveryIdle,
+ playlist_sd_idle, p_node );
+
if( !vlc_sd_Start( p_sd ) )
{
vlc_sd_Destroy( p_sd );
@@ -440,6 +466,16 @@ int playlist_ServicesDiscoveryRemove( playlist_t *
p_playlist,
playlist_sd_item_removed,
p_sds->p_node );
+ vlc_event_detach( services_discovery_EventManager( p_sd ),
+ vlc_ServicesDiscoveryFetching,
+ playlist_sd_fetching,
+ p_sds->p_node );
+
+ vlc_event_detach( services_discovery_EventManager( p_sd ),
+ vlc_ServicesDiscoveryIdle,
+ playlist_sd_idle,
+ p_sds->p_node );
+
/* Remove the sd playlist node if it exists */
PL_LOCK;
playlist_NodeDelete( p_playlist, p_sds->p_node, true, false );
More information about the vlc-devel
mailing list