]> git.sesse.net Git - vlc/blobdiff - src/playlist/services_discovery.c
playlist, Qt: playlist browsing support
[vlc] / src / playlist / services_discovery.c
index 1aa8f64e685ca8dea83bc60b46c6ad57bef16f8a..355dffb7f1483b9d7d60c697bbc0e50147a6e537 100644 (file)
 #include "vlc_playlist.h"
 #include "vlc_events.h"
 #include <vlc_services_discovery.h>
+#include <vlc_probe.h>
 #include "playlist_internal.h"
 #include "../libvlc.h"
 
+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.
+ */
+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,15 +105,6 @@ static void services_discovery_Destructor ( vlc_object_t *p_obj );
  * That's how the playlist get's Service Discovery information
  */
 
-/**
- * Gets the list of available services discovery plugins.
- */
-char **vlc_sd_GetNames( char ***pppsz_longnames )
-{
-    return module_GetModulesNamesForCapability( "services_discovery",
-                                                pppsz_longnames );
-}
-
 /***********************************************************************
  * Create
  ***********************************************************************/