aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2012-08-19 13:52:52 +0000
committerLRN <lrn1986@gmail.com>2012-08-19 13:52:52 +0000
commit498bb9af50644ab65b12909a1a7074cc38f95701 (patch)
tree350628bbfe0761adfdcae6ad7fcf2fed3441989c
parent98605a3ce9ea7c4e00c88833e28eefec5e811dd7 (diff)
downloadlibextractor-498bb9af50644ab65b12909a1a7074cc38f95701.tar.gz
libextractor-498bb9af50644ab65b12909a1a7074cc38f95701.zip
gstreamer test: asf
-rw-r--r--src/plugins/Makefile.am7
-rw-r--r--src/plugins/test_gstreamer.c302
-rw-r--r--src/plugins/testdata/30_and_33.asfbin0 -> 67846 bytes
3 files changed, 307 insertions, 2 deletions
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index a7e62b8..b03e307 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -553,6 +553,13 @@ test_wav_SOURCES = \
553test_wav_LDADD = \ 553test_wav_LDADD = \
554 $(top_builddir)/src/plugins/libtest.la 554 $(top_builddir)/src/plugins/libtest.la
555 555
556test_gstreamer_SOURCES = \
557 test_gstreamer.c
558test_gstreamer_LDADD = \
559 $(top_builddir)/src/plugins/libtest.la \
560 $(GSTREAMER_LIBS) $(GSTREAMER_PBUTILS_LIBS)
561test_gstreamer_CFLAGS = \
562 $(GSTREAMER_CFLAGS) $(GSTREAMER_PBUTILS_CFLAGS)
556 563
557libextractor_xm_la_SOURCES = \ 564libextractor_xm_la_SOURCES = \
558 xm_extractor.c 565 xm_extractor.c
diff --git a/src/plugins/test_gstreamer.c b/src/plugins/test_gstreamer.c
index 1952187..58cfbf8 100644
--- a/src/plugins/test_gstreamer.c
+++ b/src/plugins/test_gstreamer.c
@@ -25,6 +25,92 @@
25#include "platform.h" 25#include "platform.h"
26#include "test_lib.h" 26#include "test_lib.h"
27 27
28#include <glib.h>
29#include <gst/gst.h>
30#include <gst/pbutils/pbutils.h>
31
32/* This is a miniaturized version of gst-discoverer, its only purpose is
33 * to detect missing plugins situations and skip a test in such cases.
34 */
35GstDiscovererResult
36discoverer_main (GstDiscoverer *dc, char *filename)
37{
38 GError *err = NULL;
39 GDir *dir;
40 gchar *uri, *path;
41 GstDiscovererInfo *info;
42
43 GstDiscovererResult result;
44
45 if (!gst_uri_is_valid (filename)) {
46 if (!g_path_is_absolute (filename)) {
47 gchar *cur_dir;
48
49 cur_dir = g_get_current_dir ();
50 path = g_build_filename (cur_dir, filename, NULL);
51 g_free (cur_dir);
52 } else {
53 path = g_strdup (filename);
54 }
55
56 uri = g_filename_to_uri (path, NULL, &err);
57 g_free (path);
58 path = NULL;
59
60 if (err) {
61 g_warning ("Couldn't convert filename %s to URI: %s\n", filename, err->message);
62 g_error_free (err);
63 return;
64 }
65 } else {
66 uri = g_strdup (filename);
67 }
68
69 info = gst_discoverer_discover_uri (dc, uri, &err);
70
71 result = gst_discoverer_info_get_result (info);
72
73 switch (result) {
74 case GST_DISCOVERER_OK:
75 {
76 break;
77 }
78 case GST_DISCOVERER_URI_INVALID:
79 {
80 g_print ("URI %s is not valid\n", uri);
81 break;
82 }
83 case GST_DISCOVERER_ERROR:
84 {
85 g_print ("An error was encountered while discovering the file %s\n", filename);
86 g_print (" %s\n", err->message);
87 break;
88 }
89 case GST_DISCOVERER_TIMEOUT:
90 {
91 g_print ("Analyzing URI %s timed out\n", uri);
92 break;
93 }
94 case GST_DISCOVERER_BUSY:
95 {
96 g_print ("Discoverer was busy\n");
97 break;
98 }
99 case GST_DISCOVERER_MISSING_PLUGINS:
100 {
101 g_print ("Will skip %s: missing plugins\n", filename);
102 break;
103 }
104 }
105
106 if (err)
107 g_error_free (err);
108 gst_discoverer_info_unref (info);
109
110 g_free (uri);
111
112 return result;
113}
28 114
29/** 115/**
30 * Main function for the GStreamer testcase. 116 * Main function for the GStreamer testcase.
@@ -36,8 +122,220 @@
36int 122int
37main (int argc, char *argv[]) 123main (int argc, char *argv[])
38{ 124{
39 /* FIXME: implement a test */ 125 GError *err = NULL;
40 return 0; 126 gint timeout = 10;
127 GstDiscoverer *dc;
128
129 int result = 0;
130 GstDiscovererResult pre_test;
131
132 gst_init (&argc, &argv);
133
134 dc = gst_discoverer_new (timeout * GST_SECOND, &err);
135 if (G_UNLIKELY (dc == NULL)) {
136 g_print ("Error initializing: %s\n", err->message);
137 exit (1);
138 }
139 if (err)
140 g_error_free (err);
141
142 pre_test = discoverer_main (dc, "testdata/30_and_33.asf");
143 if (pre_test != GST_DISCOVERER_MISSING_PLUGINS)
144 {
145 struct SolutionData thirty_and_thirtythree_sol[] =
146 {
147 {
148 EXTRACTOR_METATYPE_DURATION,
149 EXTRACTOR_METAFORMAT_UTF8,
150 "text/plain",
151 "0:00:05.061000000",
152 strlen ("0:00:05.061000000") + 1,
153 0
154 },
155 {
156 EXTRACTOR_METATYPE_TRACK_NUMBER,
157 EXTRACTOR_METAFORMAT_UTF8,
158 "text/plain",
159 "21",
160 strlen ("21") + 1,
161 0
162 },
163 {
164 EXTRACTOR_METATYPE_ALBUM,
165 EXTRACTOR_METAFORMAT_UTF8,
166 "text/plain",
167 "Zee Album",
168 strlen ("Zee Album") + 1,
169 0
170 },
171 {
172 EXTRACTOR_METATYPE_CREATION_TIME,
173 EXTRACTOR_METAFORMAT_UTF8,
174 "text/plain",
175 "9999",
176 strlen ("9999") + 1,
177 0
178 },
179 /* Suggest a fix to gst devs; "performed by" and "contributors" should
180 * be separate.
181 */
182 {
183 EXTRACTOR_METATYPE_ARTIST,
184 EXTRACTOR_METAFORMAT_UTF8,
185 "text/plain",
186 "All performed by Nobody, This Artist Contributed",
187 strlen ("All performed by Nobody, This Artist Contributed") + 1,
188 0
189 },
190 {
191 EXTRACTOR_METATYPE_TITLE,
192 EXTRACTOR_METAFORMAT_UTF8,
193 "text/plain",
194 "Some title",
195 strlen ("Some title") + 1,
196 0
197 },
198 /* Suggest a fix to gst devs; should be a comment, not description */
199 {
200 EXTRACTOR_METATYPE_DESCRIPTION,
201 EXTRACTOR_METAFORMAT_UTF8,
202 "text/plain",
203 "A witty comment",
204 strlen ("A witty comment") + 1,
205 0
206 },
207 {
208 EXTRACTOR_METATYPE_CONTAINER_FORMAT,
209 EXTRACTOR_METAFORMAT_UTF8,
210 "text/plain",
211 "ASF",
212 strlen ("ASF") + 1,
213 0
214 },
215 {
216 EXTRACTOR_METATYPE_AUDIO_CODEC,
217 EXTRACTOR_METAFORMAT_UTF8,
218 "text/plain",
219 "WMA Version 8",
220 strlen ("WMA Version 8") + 1,
221 0
222 },
223 {
224 EXTRACTOR_METATYPE_LANGUAGE,
225 EXTRACTOR_METAFORMAT_UTF8,
226 "text/plain",
227 "en",
228 strlen ("en") + 1,
229 0
230 },
231 {
232 EXTRACTOR_METATYPE_MIMETYPE,
233 EXTRACTOR_METAFORMAT_UTF8,
234 "text/plain",
235 "video/x-ms-asf",
236 strlen ("video/x-ms-asf") + 1,
237 0
238 },
239 {
240 EXTRACTOR_METATYPE_MIMETYPE,
241 EXTRACTOR_METAFORMAT_UTF8,
242 "text/plain",
243 "audio/x-wma",
244 strlen ("audio/x-wma") + 1,
245 0
246 },
247 {
248 EXTRACTOR_METATYPE_UNKNOWN,
249 EXTRACTOR_METAFORMAT_UTF8,
250 "text/plain",
251 "wmaversion=2",
252 strlen ("wmaversion=2") + 1,
253 0
254 },
255 {
256 EXTRACTOR_METATYPE_UNKNOWN,
257 EXTRACTOR_METAFORMAT_UTF8,
258 "text/plain",
259 "bitrate=96024",
260 strlen ("bitrate=96024") + 1,
261 0
262 },
263 {
264 EXTRACTOR_METATYPE_UNKNOWN,
265 EXTRACTOR_METAFORMAT_UTF8,
266 "text/plain",
267 "depth=16",
268 strlen ("depth=16") + 1,
269 0
270 },
271 {
272 EXTRACTOR_METATYPE_UNKNOWN,
273 EXTRACTOR_METAFORMAT_UTF8,
274 "text/plain",
275 "rate=44100",
276 strlen ("rate=44100") + 1,
277 0
278 },
279 {
280 EXTRACTOR_METATYPE_UNKNOWN,
281 EXTRACTOR_METAFORMAT_UTF8,
282 "text/plain",
283 "channels=2",
284 strlen ("channels=2") + 1,
285 0
286 },
287 {
288 EXTRACTOR_METATYPE_UNKNOWN,
289 EXTRACTOR_METAFORMAT_UTF8,
290 "text/plain",
291 "block_align=4459",
292 strlen ("block_align=4459") + 1,
293 0
294 },
295 {
296 EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
297 EXTRACTOR_METAFORMAT_UTF8,
298 "text/plain",
299 "en",
300 strlen ("en") + 1,
301 0
302 },
303 {
304 EXTRACTOR_METATYPE_CHANNELS,
305 EXTRACTOR_METAFORMAT_UTF8,
306 "text/plain",
307 "2",
308 strlen ("2") + 1,
309 0
310 },
311 {
312 EXTRACTOR_METATYPE_SAMPLE_RATE,
313 EXTRACTOR_METAFORMAT_UTF8,
314 "text/plain",
315 "44100",
316 strlen ("44100") + 1,
317 0
318 },
319 {
320 EXTRACTOR_METATYPE_AUDIO_DEPTH,
321 EXTRACTOR_METAFORMAT_UTF8,
322 "text/plain",
323 "16",
324 strlen ("16") + 1,
325 0
326 },
327 { 0, 0, NULL, NULL, 0, -1 }
328 };
329 struct ProblemSet ps[] =
330 {
331 { "testdata/30_and_33.asf",
332 thirty_and_thirtythree_sol },
333 { NULL, NULL }
334 };
335 result += (0 == ET_main ("gstreamer", ps) ? 0 : 1);
336 }
337 g_object_unref (dc);
338 return result;
41} 339}
42 340
43/* end of test_gstreamer.c */ 341/* end of test_gstreamer.c */
diff --git a/src/plugins/testdata/30_and_33.asf b/src/plugins/testdata/30_and_33.asf
new file mode 100644
index 0000000..536dc11
--- /dev/null
+++ b/src/plugins/testdata/30_and_33.asf
Binary files differ