[vlc-devel] commit: libvlc: Test preparsing. (Pierre d'Herbemont )
git version control
git at videolan.org
Mon Feb 22 12:02:52 CET 2010
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Mon Feb 22 12:02:09 2010 +0100| [2fc112a1b4c6725d642163e70c91707c4f2ca85f] | committer: Pierre d'Herbemont
libvlc: Test preparsing.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2fc112a1b4c6725d642163e70c91707c4f2ca85f
---
test/Makefile.am | 6 ++++
test/libvlc/media.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.am b/test/Makefile.am
index ac1bc69..4088a98 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -15,6 +15,7 @@ extra_check_verbose__0 = $(extra_check_verbose_0)
check_PROGRAMS = \
test_libvlc_core \
test_libvlc_events \
+ test_libvlc_media \
test_libvlc_media_list \
test_libvlc_media_player \
test_src_misc_variables \
@@ -60,6 +61,11 @@ test_libvlc_events_LDADD = $(top_builddir)/src/libvlc.la
test_libvlc_events_CFLAGS = $(CFLAGS_tests)
test_libvlc_events_LDFLAGS = $(LDFLAGS_tests)
+test_libvlc_media_SOURCES = libvlc/media.c
+test_libvlc_media_LDADD = $(top_builddir)/src/libvlc.la
+test_libvlc_media_CFLAGS = $(CFLAGS_tests)
+test_libvlc_media_LDFLAGS = $(LDFLAGS_tests)
+
test_libvlc_media_list_player_SOURCES = libvlc/media_list_player.c
test_libvlc_media_list_player_LDADD = $(top_builddir)/src/libvlc.la
test_libvlc_media_list_player_CFLAGS = $(CFLAGS_tests)
diff --git a/test/libvlc/media.c b/test/libvlc/media.c
new file mode 100644
index 0000000..03efe26
--- /dev/null
+++ b/test/libvlc/media.c
@@ -0,0 +1,75 @@
+/*
+ * media_player.c - libvlc smoke test
+ *
+ * $Id$
+ */
+
+/**********************************************************************
+ * Copyright (C) 2007 Rémi Denis-Courmont. *
+ * This program is free software; you can redistribute and/or modify *
+ * it under the terms of the GNU General Public License as published *
+ * by the Free Software Foundation; version 2 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, you can get it from: *
+ * http://www.gnu.org/copyleft/gpl.html *
+ **********************************************************************/
+
+#include "test.h"
+
+static void preparsed_changed(const libvlc_event_t *event, void *user_data)
+{
+ (void)event;
+
+ int *received = user_data;
+ *received = true;
+}
+
+static void test_media_preparsed(const char** argv, int argc)
+{
+ const char * file = test_default_sample;
+
+ log ("Testing set_media\n");
+
+ libvlc_instance_t *vlc = libvlc_new (argc, argv);
+ assert (vlc != NULL);
+
+ libvlc_media_t *media = libvlc_media_new_path (vlc, file);
+ assert (media != NULL);
+
+ int received = false;
+
+ // Force preparsing. FIXME - Expose a better API for that.
+ libvlc_media_es_t *es;
+ int num = libvlc_media_get_es(media, &es);
+ free(es);
+
+ libvlc_event_manager_t *em = libvlc_media_event_manager (media);
+ libvlc_event_attach (em, libvlc_MediaPreparsedChanged, preparsed_changed, &received);
+
+ // Wait to see if we properly receive preparsed.
+ while (!received);
+
+ // We are good, now check Elementary Stream info.
+ num = libvlc_media_get_es(media, &es);
+ assert(num > 0);
+ free(es);
+
+ libvlc_media_release (media);
+ libvlc_release (vlc);
+}
+
+int main (void)
+{
+ test_init();
+
+ test_media_preparsed (test_defaults_args, test_defaults_nargs);
+
+ return 0;
+}
More information about the vlc-devel
mailing list