[vlc-commits] test: input: test demux controls

Shaleen Jain git at videolan.org
Sat Nov 11 15:46:55 CET 2017


vlc | branch: master | Shaleen Jain <shaleen.jain95 at gmail.com> | Fri Oct 13 12:38:13 2017 +0200| [74e7bd240d5b239d0eeb3b67a7511b8b83cb6694] | committer: 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.git

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 test/src/input/common.c    |  1 +
 test/src/input/common.h    |  3 +++
 test/src/input/demux-run.c | 65 +++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/test/src/input/common.c b/test/src/input/common.c
index 81539ce60c..75112bd36d 100644
--- a/test/src/input/common.c
+++ b/test/src/input/common.c
@@ -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)
diff --git a/test/src/input/common.h b/test/src/input/common.h
index ef81a3ff9b..96f4253814 100644
--- a/test/src/input/common.h
+++ b/test/src/input/common.h
@@ -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);
diff --git a/test/src/input/demux-run.c b/test/src/input/demux-run.c
index f748302346..7474ae081e 100644
--- a/test/src/input/demux-run.c
+++ b/test/src/input/demux-run.c
@@ -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);



More information about the vlc-commits mailing list