Commit b6689cb8 authored by Thomas Guillem's avatar Thomas Guillem

test: input: move libvlc initialisation in a common helper

parent 2c2eb4d0
......@@ -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)\"
......
/*****************************************************************************
* 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;
}
/*****************************************************************************
* 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);
......@@ -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();
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment