]> git.sesse.net Git - vlc/commitdiff
probe: helpers for services discovery
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 19 Dec 2009 23:51:38 +0000 (01:51 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 21 Dec 2009 19:42:36 +0000 (21:42 +0200)
include/vlc_services_discovery.h
src/libvlccore.sym
src/playlist/services_discovery.c

index f6eaa0e77a11f49c57c2ac3e1a0d34e0c40fbf01..7094defa2b1966fbae665f286658e5c47e3868d0 100644 (file)
 #ifndef VLC_SERVICES_DISCOVERY_H_
 #define VLC_SERVICES_DISCOVERY_H_
 
+#include <vlc_input.h>
+#include <vlc_events.h>
+#include <vlc_probe.h>
+
 /**
  * \file
  * This file functions and structures for service discovery in vlc
@@ -37,9 +41,6 @@ extern "C" {
  * @{
  */
 
-#include <vlc_input.h>
-#include <vlc_events.h>
-
 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
 }
index fb1480a3ed7e0589b622ef863606910776f00039..5b895e41d30f2192ac6c5d69005dd39290410043 100644 (file)
@@ -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
index 35547c87bd387c42f68edbf7d43f3a8e6c2f2316..355dffb7f1483b9d7d60c697bbc0e50147a6e537 100644 (file)
 #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.
  */