[vlc-commits] commit: sd: remove the pf_search and use a more generic pf_control function . ( Rémi Duraffort )
git at videolan.org
git at videolan.org
Sun Oct 24 04:18:42 CEST 2010
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Oct 24 03:52:12 2010 +0200| [7c5348b695c23258157ec21cdcf69ed6917bf009] | committer: Rémi Duraffort
sd: remove the pf_search and use a more generic pf_control function.
This way we can implement both a search function and a description function.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c5348b695c23258157ec21cdcf69ed6917bf009
---
include/vlc_playlist.h | 2 +-
include/vlc_services_discovery.h | 42 +++++++++++++++++++++++++++++----
modules/misc/lua/services_discovery.c | 26 +++++++++++++++-----
src/libvlccore.sym | 2 +-
src/playlist/services_discovery.c | 7 ++++-
5 files changed, 63 insertions(+), 16 deletions(-)
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 1002886..5ea1089 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -324,7 +324,7 @@ VLC_EXPORT( int, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *))
/** Check whether a given SD is loaded */
VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
/** Query a services discovery */
-VLC_EXPORT( int, playlist_QueryServicesDiscovery, ( playlist_t *, const char *, const char * ) );
+VLC_EXPORT( int, playlist_ServicesDiscoveryControl, ( playlist_t *, const char *, int, ... ) );
diff --git a/include/vlc_services_discovery.h b/include/vlc_services_discovery.h
index 8a00dcb..0b8b329 100644
--- a/include/vlc_services_discovery.h
+++ b/include/vlc_services_discovery.h
@@ -51,11 +51,14 @@ struct services_discovery_t
char *psz_name;
config_chain_t *p_cfg;
- int ( *pf_search ) ( services_discovery_t *, const char * );
+ int ( *pf_control ) ( services_discovery_t *, int, va_list );
services_discovery_sys_t *p_sys;
};
+/**
+ * Service discovery categories
+ */
enum services_discovery_category_e
{
SD_CAT_DEVICES = 1,
@@ -64,6 +67,34 @@ enum services_discovery_category_e
SD_CAT_MYCOMPUTER
};
+/**
+ * Service discovery control commands
+ */
+enum services_discovery_command_e
+{
+ SD_CMD_SEARCH = 1, /**< arg1 = query */
+ SD_CMD_CAPABILITIES /**< arg1 = services_discovery_descriptor_t* */
+};
+
+/**
+ * Service discovery capabilities
+ */
+enum services_discovery_capability_e
+{
+ SD_CAP_SEARCH = 1
+};
+
+/**
+ * Service discovery descriptor
+ */
+typedef struct
+{
+ char *psz_short_desc;
+ char *psz_icon_url;
+ char *psz_url;
+ int i_capabilities;
+} services_discovery_descriptor_t;
+
/***********************************************************************
* Service Discovery
***********************************************************************/
@@ -71,13 +102,14 @@ enum services_discovery_category_e
/**
* Ask for a research in the SD
* @param p_sd: the Service Discovery
- * @param psz_query: the query
+ * @param i_control: the command to issue
+ * @param args: the argument list
* @return VLC_SUCCESS in case of success, the error code overwise
*/
-static inline int vlc_sd_search( services_discovery_t *p_sd, const char *psz_query )
+static inline int vlc_sd_control( services_discovery_t *p_sd, int i_control, va_list args )
{
- if( p_sd->pf_search )
- return p_sd->pf_search( p_sd, psz_query );
+ if( p_sd->pf_control )
+ return p_sd->pf_control( p_sd, i_control, args );
else
return VLC_EGENERIC;
}
diff --git a/modules/misc/lua/services_discovery.c b/modules/misc/lua/services_discovery.c
index 3561b5f..f8c42b5 100644
--- a/modules/misc/lua/services_discovery.c
+++ b/modules/misc/lua/services_discovery.c
@@ -35,7 +35,7 @@
*****************************************************************************/
static void *Run( void * );
static int DoSearch( services_discovery_t *p_sd, const char *psz_query );
-static int Search( services_discovery_t *p_sd, const char *psz_query );
+static int Control( services_discovery_t *p_sd, int i_command, va_list args );
static const char * const ppsz_sd_options[] = { "sd", "longname", NULL };
@@ -88,7 +88,7 @@ int Open_LuaSD( vlc_object_t *p_this )
return VLC_ENOMEM;
}
p_sd->p_sys = p_sys;
- p_sd->pf_search = Search;
+ p_sd->pf_control = Control;
p_sys->psz_filename = vlclua_find_file( p_this, "sd", psz_name );
if( !p_sys->psz_filename )
{
@@ -243,13 +243,25 @@ static void* Run( void *data )
/*****************************************************************************
* Search: search for items according to the given query
****************************************************************************/
-static int Search( services_discovery_t *p_sd, const char *psz_query )
+static int Control( services_discovery_t *p_sd, int i_command, va_list args )
{
services_discovery_sys_t *p_sys = p_sd->p_sys;
- vlc_mutex_lock( &p_sys->lock );
- TAB_APPEND( p_sys->i_query, p_sys->ppsz_query, strdup( psz_query ) );
- vlc_cond_signal( &p_sys->cond );
- vlc_mutex_unlock( &p_sys->lock );
+
+ switch( i_command )
+ {
+ case SD_CMD_SEARCH:
+ {
+ const char *psz_query = va_arg( args, const char * );
+ vlc_mutex_lock( &p_sys->lock );
+ TAB_APPEND( p_sys->i_query, p_sys->ppsz_query, strdup( psz_query ) );
+ vlc_cond_signal( &p_sys->cond );
+ vlc_mutex_unlock( &p_sys->lock );
+ break;
+ }
+
+ case SD_CMD_CAPABILITIES:
+ return VLC_EGENERIC;
+ }
return VLC_SUCCESS;
}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index e238adb..03938fb 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -361,9 +361,9 @@ playlist_NodeDelete
playlist_NodeInsert
playlist_NodeRemoveItem
playlist_PreparseEnqueue
-playlist_QueryServicesDiscovery
playlist_RecursiveNodeSort
playlist_ServicesDiscoveryAdd
+playlist_ServicesDiscoveryControl
playlist_ServicesDiscoveryRemove
playlist_Status
playlist_TreeMove
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index ca5ec49..65e2970 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -440,7 +440,7 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
return found;
}
-int playlist_QueryServicesDiscovery( playlist_t *p_playlist, const char *psz_name, const char *psz_query )
+int playlist_ServicesDiscoveryControl( playlist_t *p_playlist, const char *psz_name, int i_control, ... )
{
playlist_private_t *priv = pl_priv( p_playlist );
int i_ret = VLC_EGENERIC;
@@ -452,7 +452,10 @@ int playlist_QueryServicesDiscovery( playlist_t *p_playlist, const char *psz_nam
vlc_sd_internal_t *sd = priv->pp_sds[i];
if( sd->psz_name && !strcmp( psz_name, sd->psz_name ) )
{
- i_ret = vlc_sd_search( sd->p_sd, psz_query );
+ va_list args;
+ va_start( args, i_control );
+ i_ret = vlc_sd_control( sd->p_sd, i_control, args );
+ va_end( args );
break;
}
}
More information about the vlc-commits
mailing list