[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23307 - in Extractor/src/plugins: . testdata
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23307 - in Extractor/src/plugins: . testdata |
Date: |
Sun, 19 Aug 2012 15:52:52 +0200 |
Author: LRN
Date: 2012-08-19 15:52:52 +0200 (Sun, 19 Aug 2012)
New Revision: 23307
Added:
Extractor/src/plugins/testdata/30_and_33.asf
Modified:
Extractor/src/plugins/Makefile.am
Extractor/src/plugins/test_gstreamer.c
Log:
gstreamer test: asf
Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am 2012-08-18 22:34:11 UTC (rev 23306)
+++ Extractor/src/plugins/Makefile.am 2012-08-19 13:52:52 UTC (rev 23307)
@@ -553,6 +553,13 @@
test_wav_LDADD = \
$(top_builddir)/src/plugins/libtest.la
+test_gstreamer_SOURCES = \
+ test_gstreamer.c
+test_gstreamer_LDADD = \
+ $(top_builddir)/src/plugins/libtest.la \
+ $(GSTREAMER_LIBS) $(GSTREAMER_PBUTILS_LIBS)
+test_gstreamer_CFLAGS = \
+ $(GSTREAMER_CFLAGS) $(GSTREAMER_PBUTILS_CFLAGS)
libextractor_xm_la_SOURCES = \
xm_extractor.c
Modified: Extractor/src/plugins/test_gstreamer.c
===================================================================
--- Extractor/src/plugins/test_gstreamer.c 2012-08-18 22:34:11 UTC (rev
23306)
+++ Extractor/src/plugins/test_gstreamer.c 2012-08-19 13:52:52 UTC (rev
23307)
@@ -25,7 +25,93 @@
#include "platform.h"
#include "test_lib.h"
+#include <glib.h>
+#include <gst/gst.h>
+#include <gst/pbutils/pbutils.h>
+/* This is a miniaturized version of gst-discoverer, its only purpose is
+ * to detect missing plugins situations and skip a test in such cases.
+ */
+GstDiscovererResult
+discoverer_main (GstDiscoverer *dc, char *filename)
+{
+ GError *err = NULL;
+ GDir *dir;
+ gchar *uri, *path;
+ GstDiscovererInfo *info;
+
+ GstDiscovererResult result;
+
+ if (!gst_uri_is_valid (filename)) {
+ if (!g_path_is_absolute (filename)) {
+ gchar *cur_dir;
+
+ cur_dir = g_get_current_dir ();
+ path = g_build_filename (cur_dir, filename, NULL);
+ g_free (cur_dir);
+ } else {
+ path = g_strdup (filename);
+ }
+
+ uri = g_filename_to_uri (path, NULL, &err);
+ g_free (path);
+ path = NULL;
+
+ if (err) {
+ g_warning ("Couldn't convert filename %s to URI: %s\n", filename,
err->message);
+ g_error_free (err);
+ return;
+ }
+ } else {
+ uri = g_strdup (filename);
+ }
+
+ info = gst_discoverer_discover_uri (dc, uri, &err);
+
+ result = gst_discoverer_info_get_result (info);
+
+ switch (result) {
+ case GST_DISCOVERER_OK:
+ {
+ break;
+ }
+ case GST_DISCOVERER_URI_INVALID:
+ {
+ g_print ("URI %s is not valid\n", uri);
+ break;
+ }
+ case GST_DISCOVERER_ERROR:
+ {
+ g_print ("An error was encountered while discovering the file %s\n",
filename);
+ g_print (" %s\n", err->message);
+ break;
+ }
+ case GST_DISCOVERER_TIMEOUT:
+ {
+ g_print ("Analyzing URI %s timed out\n", uri);
+ break;
+ }
+ case GST_DISCOVERER_BUSY:
+ {
+ g_print ("Discoverer was busy\n");
+ break;
+ }
+ case GST_DISCOVERER_MISSING_PLUGINS:
+ {
+ g_print ("Will skip %s: missing plugins\n", filename);
+ break;
+ }
+ }
+
+ if (err)
+ g_error_free (err);
+ gst_discoverer_info_unref (info);
+
+ g_free (uri);
+
+ return result;
+}
+
/**
* Main function for the GStreamer testcase.
*
@@ -36,8 +122,220 @@
int
main (int argc, char *argv[])
{
- /* FIXME: implement a test */
- return 0;
+ GError *err = NULL;
+ gint timeout = 10;
+ GstDiscoverer *dc;
+
+ int result = 0;
+ GstDiscovererResult pre_test;
+
+ gst_init (&argc, &argv);
+
+ dc = gst_discoverer_new (timeout * GST_SECOND, &err);
+ if (G_UNLIKELY (dc == NULL)) {
+ g_print ("Error initializing: %s\n", err->message);
+ exit (1);
+ }
+ if (err)
+ g_error_free (err);
+
+ pre_test = discoverer_main (dc, "testdata/30_and_33.asf");
+ if (pre_test != GST_DISCOVERER_MISSING_PLUGINS)
+ {
+ struct SolutionData thirty_and_thirtythree_sol[] =
+ {
+ {
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:05.061000000",
+ strlen ("0:00:05.061000000") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TRACK_NUMBER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "21",
+ strlen ("21") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Zee Album",
+ strlen ("Zee Album") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_TIME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "9999",
+ strlen ("9999") + 1,
+ 0
+ },
+ /* Suggest a fix to gst devs; "performed by" and "contributors" should
+ * be separate.
+ */
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "All performed by Nobody, This Artist Contributed",
+ strlen ("All performed by Nobody, This Artist Contributed") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Some title",
+ strlen ("Some title") + 1,
+ 0
+ },
+ /* Suggest a fix to gst devs; should be a comment, not description */
+ {
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "A witty comment",
+ strlen ("A witty comment") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTAINER_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ASF",
+ strlen ("ASF") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "WMA Version 8",
+ strlen ("WMA Version 8") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "en",
+ strlen ("en") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-ms-asf",
+ strlen ("video/x-ms-asf") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-wma",
+ strlen ("audio/x-wma") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "wmaversion=2",
+ strlen ("wmaversion=2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "bitrate=96024",
+ strlen ("bitrate=96024") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "depth=16",
+ strlen ("depth=16") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "rate=44100",
+ strlen ("rate=44100") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "channels=2",
+ strlen ("channels=2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "block_align=4459",
+ strlen ("block_align=4459") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "en",
+ strlen ("en") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CHANNELS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2",
+ strlen ("2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SAMPLE_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "44100",
+ strlen ("44100") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_DEPTH,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "16",
+ strlen ("16") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] =
+ {
+ { "testdata/30_and_33.asf",
+ thirty_and_thirtythree_sol },
+ { NULL, NULL }
+ };
+ result += (0 == ET_main ("gstreamer", ps) ? 0 : 1);
+ }
+ g_object_unref (dc);
+ return result;
}
/* end of test_gstreamer.c */
Added: Extractor/src/plugins/testdata/30_and_33.asf
===================================================================
--- Extractor/src/plugins/testdata/30_and_33.asf
(rev 0)
+++ Extractor/src/plugins/testdata/30_and_33.asf 2012-08-19 13:52:52 UTC
(rev 23307)
@@ -0,0 +1,176 @@
+0&�u�f��� � b�lH �ܫ�G���� � Seh �*� ߬K���q�Ba
���
+}� /� u + � � Fy ��_.���� �
Ser �ӫ����� � Se D �FC|���K�)9>�A\�. r u
e n - U S ]��&�E�G�_eR� ���ů[wH�g��D�L�z 4 D e v i c e C o n f o r m a n c e T e m p l a t e L 1
I s V B R ˥�r�2C���iR[ZX w + w + k ��"