From: RĂ©mi Denis-Courmont Date: Sat, 19 Dec 2009 23:51:38 +0000 (+0200) Subject: probe: helpers for services discovery X-Git-Tag: 1.1.0-ff~1818 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ace8442cc7b676b95aac14c6b93985657e020aa6;p=vlc probe: helpers for services discovery --- diff --git a/include/vlc_services_discovery.h b/include/vlc_services_discovery.h index f6eaa0e77a..7094defa2b 100644 --- a/include/vlc_services_discovery.h +++ b/include/vlc_services_discovery.h @@ -24,6 +24,10 @@ #ifndef VLC_SERVICES_DISCOVERY_H_ #define VLC_SERVICES_DISCOVERY_H_ +#include +#include +#include + /** * \file * This file functions and structures for service discovery in vlc @@ -37,9 +41,6 @@ extern "C" { * @{ */ -#include -#include - struct services_discovery_t { VLC_COMMON_MEMBERS @@ -88,6 +89,22 @@ VLC_EXPORT( vlc_event_manager_t *, services_discovery_EventManager, ( services_ VLC_EXPORT( void, services_discovery_AddItem, ( services_discovery_t * p_this, input_item_t * p_item, const char * psz_category ) ); VLC_EXPORT( void, services_discovery_RemoveItem, ( services_discovery_t * p_this, input_item_t * p_item ) ); + +/* SD probing */ + +VLC_EXPORT(int, vlc_sd_probe_Add, (vlc_probe_t *, const char *, const char *)); + +#define VLC_SD_PROBE_SUBMODULE \ + add_submodule() \ + set_capability( "services probe", 100 ) \ + set_callbacks( vlc_sd_probe_Open, NULL ) + +#define VLC_SD_PROBE_HELPER(name, longname) \ +static int vlc_sd_probe_Open (vlc_object_t *obj) \ +{ \ + return vlc_sd_probe_Add ((struct vlc_probe_t *)obj, name, longname); \ +} + /** @} */ # ifdef __cplusplus } diff --git a/src/libvlccore.sym b/src/libvlccore.sym index fb1480a3ed..5b895e41d3 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -537,6 +537,7 @@ vlc_rwlock_wrlock vlc_savecancel vlc_sd_Create vlc_sd_GetNames +vlc_sd_probe_Add vlc_sdp_Start vlc_sd_Start vlc_sd_Stop diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c index 35547c87bd..355dffb7f1 100644 --- a/src/playlist/services_discovery.c +++ b/src/playlist/services_discovery.c @@ -33,14 +33,29 @@ #include "playlist_internal.h" #include "../libvlc.h" -#undef vlc_sd_GetNames - typedef struct { char *name; char *longname; } vlc_sd_probe_t; +int vlc_sd_probe_Add (vlc_probe_t *probe, const char *name, + const char *longname) +{ + vlc_sd_probe_t names = { strdup(name), strdup(longname) }; + + if (unlikely (names.name == NULL || names.longname == NULL + || vlc_probe_add (probe, &names, sizeof (names)))) + { + free (names.name); + free (names.longname); + return VLC_ENOMEM; + } + return VLC_PROBE_CONTINUE; +} + +#undef vlc_sd_GetNames + /** * Gets the list of available services discovery plugins. */