[vlc-commits] test: input: move libvlc initialisation in a common helper

Thomas Guillem git at videolan.org
Sat Nov 11 15:46:52 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Oct 13 13:16:54 2017 +0200| [b6689cb891aab22d49818a41c930f764a37f8980] | committer: Thomas Guillem

test: input: move libvlc initialisation in a common helper

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

 test/Makefile.am           |  3 ++-
 test/src/input/common.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
 test/src/input/common.h    | 29 +++++++++++++++++++++++++++++
 test/src/input/demux-run.c | 26 --------------------------
 test/src/input/demux-run.h |  1 +
 5 files changed, 74 insertions(+), 27 deletions(-)

diff --git a/test/Makefile.am b/test/Makefile.am
index 1d2f30a3b7..afb18d2913 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -138,7 +138,8 @@ FORCE:
 
 .PHONY: FORCE
 
-libvlc_demux_run_la_SOURCES = src/input/demux-run.c src/input/demux-run.h
+libvlc_demux_run_la_SOURCES = src/input/demux-run.c src/input/demux-run.h \
+	src/input/common.c src/input/common.h
 libvlc_demux_run_la_CPPFLAGS = $(AM_CPPFLAGS) \
 	-DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\" \
 	-DTOP_SRCDIR=\"$$(cd "$(top_srcdir)"; pwd)\"
diff --git a/test/src/input/common.c b/test/src/input/common.c
new file mode 100644
index 0000000000..4f9d3d0aaa
--- /dev/null
+++ b/test/src/input/common.c
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * common.c
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ *
+ * 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 "../lib/libvlc_internal.h"
+
+#include "common.h"
+
+libvlc_instance_t *libvlc_create(void)
+{
+#ifdef TOP_BUILDDIR
+# ifndef HAVE_STATIC_MODULES
+    setenv("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1);
+# endif
+    setenv("VLC_DATA_PATH", TOP_SRCDIR"/share", 1);
+#endif
+
+    libvlc_instance_t *vlc = libvlc_new(0, NULL);
+    if (vlc == NULL)
+        fprintf(stderr, "Error: cannot initialize LibVLC.\n");
+    return vlc;
+}
diff --git a/test/src/input/common.h b/test/src/input/common.h
new file mode 100644
index 0000000000..79e3378a4a
--- /dev/null
+++ b/test/src/input/common.h
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * common.h
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ *
+ * 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.
+ *****************************************************************************/
+
+#include <vlc/vlc.h>
+
+#if 0
+#define debug(...) printf(__VA_ARGS__)
+#else
+#define debug(...) (void)0
+#endif
+
+libvlc_instance_t *libvlc_create(void);
diff --git a/test/src/input/demux-run.c b/test/src/input/demux-run.c
index 70f6cc3eec..3b9f1fdb97 100644
--- a/test/src/input/demux-run.c
+++ b/test/src/input/demux-run.c
@@ -46,12 +46,6 @@
 
 #include "demux-run.h"
 
-#if 0
-#define debug(...) printf(__VA_ARGS__)
-#else
-#define debug(...) (void)0
-#endif
-
 struct test_es_out_t
 {
     struct es_out_t out;
@@ -230,26 +224,6 @@ static int demux_process_stream(const char *name, stream_t *s)
     return val == VLC_DEMUXER_EOF ? 0 : -1;
 }
 
-static libvlc_instance_t *libvlc_create(void)
-{
-    const char *argv[] = {
-        NULL
-    };
-    unsigned argc = (sizeof (argv) / sizeof (*argv)) - 1;
-
-#ifdef TOP_BUILDDIR
-# ifndef HAVE_STATIC_MODULES
-    setenv("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1);
-# endif
-    setenv("VLC_DATA_PATH", TOP_SRCDIR"/share", 1);
-#endif
-
-    libvlc_instance_t *vlc = libvlc_new(argc, argv);
-    if (vlc == NULL)
-        fprintf(stderr, "Error: cannot initialize LibVLC.\n");
-    return vlc;
-}
-
 int vlc_demux_process_url(const char *demux, const char *url)
 {
     libvlc_instance_t *vlc = libvlc_create();
diff --git a/test/src/input/demux-run.h b/test/src/input/demux-run.h
index e4c10f4f07..b9b8bac4d4 100644
--- a/test/src/input/demux-run.h
+++ b/test/src/input/demux-run.h
@@ -24,6 +24,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#include "common.h"
 
 int vlc_demux_process_url(const char *demux, const char *url);
 int vlc_demux_process_path(const char *demux, const char *path);



More information about the vlc-commits mailing list