[vlc-commits] sd: split generic and playlist code to different modules

Rémi Denis-Courmont git at videolan.org
Sun Nov 20 15:32:15 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 20 16:31:27 2016 +0200| [15bfa0f7ef26a713733f80ce08b98eb7b8f86c0b] | committer: Rémi Denis-Courmont

sd: split generic and playlist code to different modules

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

 po/POTFILES.in                    |   1 -
 src/Makefile.am                   |   1 +
 src/input/services_discovery.c    | 137 ++++++++++++++++++++++++++++++++++++++
 src/playlist/services_discovery.c | 114 +------------------------------
 4 files changed, 139 insertions(+), 114 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 464a571..cfcc12c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -138,7 +138,6 @@ src/playlist/item.c
 src/playlist/loadsave.c
 src/playlist/playlist_internal.h
 src/playlist/search.c
-src/playlist/services_discovery.c
 src/playlist/sort.c
 src/playlist/thread.c
 src/playlist/tree.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c247aa..60f5fac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -253,6 +253,7 @@ libvlccore_la_SOURCES = \
 	input/vlm_event.h \
 	input/resource.h \
 	input/resource.c \
+	input/services_discovery.c \
 	input/stats.c \
 	input/stream.c \
 	input/stream_fifo.c \
diff --git a/src/input/services_discovery.c b/src/input/services_discovery.c
new file mode 100644
index 0000000..c2028f8
--- /dev/null
+++ b/src/input/services_discovery.c
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ * services_discovery.c : Manage playlist services_discovery modules
+ *****************************************************************************
+ * Copyright (C) 1999-2004 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub at videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#include <assert.h>
+
+#include <vlc_common.h>
+#include <vlc_services_discovery.h>
+#include <vlc_probe.h>
+#include <vlc_modules.h>
+#include "../libvlc.h"
+
+typedef struct
+{
+    char *name;
+    char *longname;
+    int category;
+} vlc_sd_probe_t;
+
+int vlc_sd_probe_Add (vlc_probe_t *probe, const char *name,
+                      const char *longname, int category)
+{
+    vlc_sd_probe_t names = { strdup(name), strdup(longname), category };
+
+    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, int **pp_categories)
+{
+    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));
+    int *categories = malloc(sizeof(int) * (count + 1));
+
+    if (unlikely (names == NULL || longnames == NULL || categories == NULL))
+    {
+        free(names);
+        free(longnames);
+        free(categories);
+        free(tab);
+        return NULL;
+    }
+    for( size_t i = 0; i < count; i++ )
+    {
+        names[i] = tab[i].name;
+        longnames[i] = tab[i].longname;
+        categories[i] = tab[i].category;
+    }
+    free (tab);
+    names[count] = longnames[count] = NULL;
+    categories[count] = 0;
+    *pppsz_longnames = longnames;
+    if( pp_categories ) *pp_categories = categories;
+    else free( categories );
+    return names;
+}
+
+/*
+ * Services discovery
+ * Basically you just listen to Service discovery event through the
+ * sd's event manager.
+ * That's how the playlist get's Service Discovery information
+ */
+
+services_discovery_t *vlc_sd_Create(vlc_object_t *parent, const char *cfg,
+    const struct services_discovery_owner_t *restrict owner)
+{
+    services_discovery_t *sd = vlc_custom_create(parent, sizeof (*sd),
+                                                 "services discovery");
+    if (unlikely(sd == NULL))
+        return NULL;
+
+    free(config_ChainCreate(&sd->psz_name, &sd->p_cfg, cfg));
+    sd->description = NULL;
+    sd->owner = *owner;
+
+    sd->p_module = module_need(sd, "services_discovery",
+                               sd->psz_name, true);
+    if (sd->p_module == NULL)
+    {
+        msg_Err(sd, "no suitable services discovery module");
+        vlc_sd_Destroy(sd);
+        sd = NULL;
+    }
+
+    return sd;
+}
+
+void vlc_sd_Destroy(services_discovery_t *sd)
+{
+    if (sd->p_module != NULL)
+        module_unneed(sd, sd->p_module);
+    config_ChainDestroy(sd->p_cfg);
+    free(sd->psz_name);
+    vlc_object_release(sd);
+}
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index f32ffe7..6796a8f 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -26,121 +26,9 @@
 #include <assert.h>
 
 #include <vlc_common.h>
-#include "vlc_playlist.h"
+#include <vlc_playlist.h>
 #include <vlc_services_discovery.h>
-#include <vlc_probe.h>
-#include <vlc_modules.h>
 #include "playlist_internal.h"
-#include "../libvlc.h"
-
-typedef struct
-{
-    char *name;
-    char *longname;
-    int category;
-} vlc_sd_probe_t;
-
-int vlc_sd_probe_Add (vlc_probe_t *probe, const char *name,
-                      const char *longname, int category)
-{
-    vlc_sd_probe_t names = { strdup(name), strdup(longname), category };
-
-    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, int **pp_categories)
-{
-    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));
-    int *categories = malloc(sizeof(int) * (count + 1));
-
-    if (unlikely (names == NULL || longnames == NULL || categories == NULL))
-    {
-        free(names);
-        free(longnames);
-        free(categories);
-        free(tab);
-        return NULL;
-    }
-    for( size_t i = 0; i < count; i++ )
-    {
-        names[i] = tab[i].name;
-        longnames[i] = tab[i].longname;
-        categories[i] = tab[i].category;
-    }
-    free (tab);
-    names[count] = longnames[count] = NULL;
-    categories[count] = 0;
-    *pppsz_longnames = longnames;
-    if( pp_categories ) *pp_categories = categories;
-    else free( categories );
-    return names;
-}
-
-/*
- * Services discovery
- * Basically you just listen to Service discovery event through the
- * sd's event manager.
- * That's how the playlist get's Service Discovery information
- */
-
-services_discovery_t *vlc_sd_Create(vlc_object_t *parent, const char *cfg,
-    const struct services_discovery_owner_t *restrict owner)
-{
-    services_discovery_t *sd = vlc_custom_create(parent, sizeof (*sd),
-                                                 "services discovery");
-    if (unlikely(sd == NULL))
-        return NULL;
-
-    free(config_ChainCreate(&sd->psz_name, &sd->p_cfg, cfg));
-    sd->description = NULL;
-    sd->owner = *owner;
-
-    sd->p_module = module_need(sd, "services_discovery",
-                               sd->psz_name, true);
-    if (sd->p_module == NULL)
-    {
-        msg_Err(sd, "no suitable services discovery module");
-        vlc_sd_Destroy(sd);
-        sd = NULL;
-    }
-
-    return sd;
-}
-
-void vlc_sd_Destroy(services_discovery_t *sd)
-{
-    if (sd->p_module != NULL)
-        module_unneed(sd, sd->p_module);
-    config_ChainDestroy(sd->p_cfg);
-    free(sd->psz_name);
-    vlc_object_release(sd);
-}
-
-/*
- * Playlist - Services discovery bridge
- */
 
 struct vlc_sd_internal_t
 {



More information about the vlc-commits mailing list