Commit 74e7bd24 authored by Shaleen Jain's avatar Shaleen Jain Committed by Thomas Guillem

test: input: test demux controls

This a partial merge of the work done by Shaleen during GSOC 2017. See
https://code.videolan.org/GSoC2017/shalzz/vlc.gitSigned-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent b90ec7d3
......@@ -40,6 +40,7 @@ void vlc_run_args_init(struct vlc_run_args *args)
args->verbose = 9;
args->name = getenv("VLC_TARGET");
args->test_demux_controls = getenv_atoi("VLC_DEMUX_CONTROLS");
}
libvlc_instance_t *libvlc_create(const struct vlc_run_args *args)
......
......@@ -34,6 +34,9 @@ struct vlc_run_args
/* vlc verbose level */
unsigned verbose;
/* true to test demux controls */
bool test_demux_controls;
};
void vlc_run_args_init(struct vlc_run_args *args);
......
......@@ -38,6 +38,8 @@
#include <vlc_access.h>
#include <vlc_block.h>
#include <vlc_demux.h>
#include <vlc_input.h>
#include <vlc_meta.h>
#include <vlc_es_out.h>
#include <vlc_url.h>
#include "../lib/libvlc_internal.h"
......@@ -189,6 +191,46 @@ static es_out_t *test_es_out_create(vlc_object_t *parent)
return out;
}
static unsigned demux_test_and_clear_flags(demux_t *demux, unsigned flags)
{
unsigned update;
if (demux_Control(demux, DEMUX_TEST_AND_CLEAR_FLAGS, &update) == VLC_SUCCESS)
return update;
unsigned ret = demux->info.i_update & flags;
demux->info.i_update &= ~flags;
return ret;
}
static void demux_get_title_list(demux_t *demux)
{
int title;
int title_offset;
int seekpoint_offset;
input_title_t **title_list;
if (demux_Control(demux, DEMUX_GET_TITLE_INFO, &title_list, &title,
&title_offset, &seekpoint_offset) == VLC_SUCCESS)
{
for (int i = 0; i < title; i++)
vlc_input_title_Delete(title_list[i]);
}
}
static void demux_get_meta(demux_t *demux)
{
vlc_meta_t *p_meta = vlc_meta_New();
if (unlikely(p_meta == NULL) )
return;
input_attachment_t **attachment;
int i_attachment;
demux_Control(demux, DEMUX_GET_META, p_meta);
demux_Control(demux, DEMUX_GET_ATTACHMENTS, &attachment, &i_attachment);
vlc_meta_Delete(p_meta);
}
static int demux_process_stream(const struct vlc_run_args *args, stream_t *s)
{
const char *name = args->name;
......@@ -215,7 +257,28 @@ static int demux_process_stream(const struct vlc_run_args *args, stream_t *s)
int val;
while ((val = demux_Demux(demux)) == VLC_DEMUXER_SUCCESS)
i++;
{
if (args->test_demux_controls)
{
if (demux_test_and_clear_flags(demux, INPUT_UPDATE_TITLE_LIST))
demux_get_title_list(demux);
if (demux_test_and_clear_flags(demux, INPUT_UPDATE_META))
demux_get_meta(demux);
int seekpoint = 0;
double position = 0.0;
mtime_t time = 0;
mtime_t length = 0;
/* Call controls for increased code coverage */
demux_Control(demux, DEMUX_GET_SEEKPOINT, &seekpoint);
demux_Control(demux, DEMUX_GET_POSITION, &position);
demux_Control(demux, DEMUX_GET_TIME, &time);
demux_Control(demux, DEMUX_GET_LENGTH, &length);
}
i++;
}
demux_Delete(demux);
es_out_Delete(out);
......
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