[vlc-devel] commit: vlc_sd_GetNames: use probe ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Dec 21 20:46:03 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Dec 20 01:27:59 2009 +0200| [1cfe42c98fe6b715632a447957a733b5f6d0c36f] | committer: Rémi Denis-Courmont 

vlc_sd_GetNames: use probe

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1cfe42c98fe6b715632a447957a733b5f6d0c36f
---

 src/playlist/services_discovery.c |   51 +++++++++++++++++++++++++++++--------
 1 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index 53a314b..35547c8 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -29,9 +29,49 @@
 #include "vlc_playlist.h"
 #include "vlc_events.h"
 #include <vlc_services_discovery.h>
+#include <vlc_probe.h>
 #include "playlist_internal.h"
 #include "../libvlc.h"
 
+#undef vlc_sd_GetNames
+
+typedef struct
+{
+    char *name;
+    char *longname;
+} vlc_sd_probe_t;
+
+/**
+ * Gets the list of available services discovery plugins.
+ */
+char **vlc_sd_GetNames (vlc_object_t *obj, char ***pppsz_longnames)
+{
+    size_t count;
+    vlc_sd_probe_t *tab = vlc_probe (obj, "services probe", &count);
+
+    if (count == 0)
+    {
+        free (tab);
+        return NULL;
+    }
+
+    char **names = malloc (sizeof(char *) * (count + 1));
+    char **longnames = malloc (sizeof(char *) * (count + 1));
+
+    if (unlikely (names == NULL || longnames == NULL))
+        abort();
+    for( size_t i = 0; i < count; i++ )
+    {
+        names[i] = tab[i].name;
+        longnames[i] = tab[i].longname;
+    }
+    free (tab);
+    names[count] = longnames[count] = NULL;
+    *pppsz_longnames = longnames;
+    return names;
+}
+
+
 struct vlc_sd_internal_t
 {
     /* the playlist items for category and onelevel */
@@ -50,17 +90,6 @@ static void services_discovery_Destructor ( vlc_object_t *p_obj );
  * That's how the playlist get's Service Discovery information
  */
 
-#undef vlc_sd_GetNames
-
-/**
- * Gets the list of available services discovery plugins.
- */
-char **vlc_sd_GetNames( vlc_object_t *obj, char ***pppsz_longnames )
-{
-    return module_GetModulesNamesForCapability( "services_discovery",
-                                                pppsz_longnames );
-}
-
 /***********************************************************************
  * Create
  ***********************************************************************/




More information about the vlc-devel mailing list