Commit 561d5ca2 authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

Export services_discovery_RemoveAll

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 170a67b5
......@@ -127,6 +127,7 @@ typedef enum vlc_event_type_t {
/* Service Discovery event */
vlc_ServicesDiscoveryItemAdded,
vlc_ServicesDiscoveryItemRemoved,
vlc_ServicesDiscoveryItemRemoveAll,
vlc_ServicesDiscoveryStarted,
vlc_ServicesDiscoveryEnded
} vlc_event_type_t;
......
......@@ -157,6 +157,7 @@ VLC_API vlc_event_manager_t * services_discovery_EventManager( services_discover
* for more options, directly set the (meta) data on the input item */
VLC_API void services_discovery_AddItem( services_discovery_t * p_this, input_item_t * p_item, const char * psz_category );
VLC_API void services_discovery_RemoveItem( services_discovery_t * p_this, input_item_t * p_item );
VLC_API void services_discovery_RemoveAll( services_discovery_t * p_sd );
/* SD probing */
......
......@@ -128,6 +128,22 @@ static void services_discovery_item_removed( const vlc_event_t * p_event,
libvlc_media_list_unlock( p_mdis->p_mlist );
}
/**************************************************************************
* services_discovery_removeall (Private) (VLC event callback)
**************************************************************************/
static void services_discovery_removeall( const vlc_event_t * p_event,
void * user_data )
{
libvlc_media_discoverer_t * p_mdis = user_data;
libvlc_media_list_lock( p_mdis->p_mlist );
for( int i = 0; i < libvlc_media_list_count( p_mdis->p_mlist ); i++ )
{
_libvlc_media_list_remove_index( p_mdis->p_mlist, i );
}
libvlc_media_list_unlock( p_mdis->p_mlist );
}
/**************************************************************************
* services_discovery_started (Private) (VLC event callback)
**************************************************************************/
......@@ -226,6 +242,10 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
vlc_ServicesDiscoveryEnded,
services_discovery_ended,
p_mdis );
vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ),
vlc_ServicesDiscoveryItemRemoveAll,
services_discovery_removeall,
p_mdis );
/* Here we go */
if( !vlc_sd_Start( p_mdis->p_sd ) )
......@@ -265,6 +285,10 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
vlc_ServicesDiscoveryEnded,
services_discovery_ended,
p_mdis );
vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
vlc_ServicesDiscoveryItemRemoveAll,
services_discovery_removeall,
p_mdis );
libvlc_media_list_release( p_mdis->p_mlist );
......
......@@ -381,6 +381,7 @@ secstotimestr
services_discovery_AddItem
services_discovery_EventManager
services_discovery_GetLocalizedName
services_discovery_RemoveAll
services_discovery_RemoveItem
sout_AccessOutControl
sout_AccessOutDelete
......
......@@ -120,6 +120,7 @@ services_discovery_t *vlc_sd_Create( vlc_object_t *p_super,
vlc_event_manager_init( em, p_sd );
vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryItemAdded);
vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryItemRemoved);
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);
......@@ -207,6 +208,18 @@ services_discovery_EventManager ( services_discovery_t * p_sd )
return &p_sd->event_manager;
}
/*******************************************************************//**
* Remove all items from the Service Discovery listing
***********************************************************************/
void
services_discovery_RemoveAll ( services_discovery_t * p_sd )
{
vlc_event_t event;
event.type = vlc_ServicesDiscoveryItemRemoveAll;
vlc_event_send( &p_sd->event_manager, &event );
}
/*******************************************************************//**
* Add an item to the Service Discovery listing
***********************************************************************/
......@@ -306,6 +319,17 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d
PL_UNLOCK;
}
/* A request to remove all ideas from SD */
static void playlist_sd_item_removeall( const vlc_event_t * p_event, void * user_data )
{
playlist_item_t* p_sd_node = user_data;
if( p_sd_node == NULL ) return;
playlist_t* p_playlist = p_sd_node->p_playlist;
PL_LOCK;
playlist_NodeEmpty( p_playlist, p_sd_node, true );
PL_UNLOCK;
}
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
const char *psz_name )
{
......@@ -355,6 +379,9 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
vlc_event_attach( em, vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed, p_node );
vlc_event_attach( em, vlc_ServicesDiscoveryItemRemoveAll,
playlist_sd_item_removeall, p_node );
if( !vlc_sd_Start( p_sd ) )
{
vlc_sd_Destroy( p_sd );
......
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