2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * parse1.c: Test common pipelines (need various plugins)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* variables used by the TEST_* macros */
27 static guint iterations;
28 static GstElement *cur = NULL;
29 static GError *error = NULL;
30 static char *audio_file = NULL;
31 static char *video_file = NULL;
33 /* variables needed for checking */
35 #define TEST_CHECK_FAIL(condition) G_STMT_START{ \
37 g_print ("TEST %2d line %3d OK\n", test, __LINE__); \
39 g_print ("TEST %2d line %3d FAILED : %s\n", test, __LINE__, #condition); \
43 #ifdef G_HAVE_ISO_VARARGS
44 #define TEST_START(...) G_STMT_START{ \
45 gchar *pipeline = g_strdup_printf (__VA_ARGS__); \
46 g_print ("TEST %2d line %3d START : %s\n", ++test, __LINE__, pipeline); \
47 cur = gst_parse_launch (pipeline, &error); \
48 if (error == NULL) { \
49 g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
51 g_print ("TEST %2d line %3d FAILED : %s\n", test, __LINE__, error->message); \
52 g_error_free (error); \
57 #elif defined(G_HAVE_GNUC_VARARGS)
58 #define TEST_START(pipe...) G_STMT_START{ \
59 gchar *pipeline = g_strdup_printf ( ## pipe ); \
60 g_print ("TEST %2d line %3d START : %s\n", ++test, __LINE__, pipeline); \
61 cur = gst_parse_launch (pipeline, &error); \
62 if (error == NULL) { \
63 g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
65 g_print ("TEST %2d line %3d FAILED : %s\n", test, __LINE__, error->message); \
66 g_error_free (error); \
72 #error Please fix this macro here
73 #define TEST_START(pipe...) G_STMT_START{ \
74 gchar *pipeline = g_strdup_printf (__VA_ARGS__); \
75 g_print ("TEST %2d line %3d START : %s\n", ++test, __LINE__, pipeline); \
76 cur = gst_parse_launch (pipeline, &error); \
77 if (error == NULL) { \
78 g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
80 g_print ("TEST %2d line %3d FAILED : %s\n", test, __LINE__, error->message); \
81 g_error_free (error); \
87 #define TEST_OK G_STMT_START{ \
88 gst_object_unref (cur); \
90 g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
92 #define TEST_RUN(iters) G_STMT_START{ \
94 g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
95 if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
96 g_print ("TEST %2d line %3d FAILED : pipeline could not be set to state PLAYING\n", test, __LINE__); \
100 while (gst_bin_iterate (GST_BIN (cur)) && it != 0) { \
104 if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
105 g_print ("TEST %2d line %3d FAILED : pipeline could not be reset to state NULL\n", test, __LINE__); \
108 g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \
110 #define TEST_FINISH G_STMT_START{ \
112 g_print("To run this test there are things required that you do not have. (see above)\n"); \
113 g_print("Please correct the above mentioned problem if you want to run this test.\n"); \
114 g_print("Currently the following tests will be ignored.\n"); \
118 #define TEST_REQUIRE(condition, error) G_STMT_START{ \
120 g_print ("REQUIRE line %3d OK\n", __LINE__); \
122 g_print ("REQUIRE line %3d EXIT : %s\n", __LINE__, (error)); \
126 #define TEST_REQUIRE_ELEMENT(element_name) G_STMT_START{ \
127 GstElement *element = gst_element_factory_make ((element_name), NULL); \
129 g_print ("REQUIRE line %3d OK\n", __LINE__); \
130 gst_object_unref (element); \
132 g_print ("REQUIRE line %3d EXIT : No element of type \"%s\" available. Exiting.\n", __LINE__, (element_name)); \
137 #define PIPELINE1 "filesrc blocksize =8192 location=%s ! mad ! osssink"
138 #define PIPELINE2 "filesrc location=%s ! mpegdemux ! mpeg2dec ! xvimagesink"
139 #define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvimagesink } demux.audio_00 ! mad ! osssink"
140 #define PIPELINE4 "pipeline. ( { filesrc location=%s ! spider name=spider ! { queue ! volume ! ( tee name=tee ! { queue ! ( goom ) ! colorspace ! ( xvimagesink ) } tee. ! { queue ! ( osssink ) } ) } spider. ! { queue ! colorspace ( xvimagesink ) } } )"
141 #define PIPELINE5 "pipeline. ( { filesrc location=%s ! spider name=spider ! ( tee name=tee ! { queue ! spider ! ( goom ) ! colorspace ! ( xvimagesink ) } tee. ! { queue ! volume ! ( osssink ) } ) spider. ! { queue! colorspace ( xvimagesink ) } } )"
143 /* FIXME: Should this run, too?
144 #define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvimagesink } demux.audio_%%02d ! mad ! osssink"
148 main (gint argc, gchar * argv[])
150 gst_init (&argc, &argv);
157 * - default playback pipeline
158 * - unsigned parameters
160 audio_file = g_build_filename (g_get_home_dir (), "music.mp3", NULL);
161 TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS),
162 "The following tests requires a valid mp3 file music.mp3 in your home directory.");
163 TEST_REQUIRE_ELEMENT ("mad");
164 TEST_REQUIRE_ELEMENT ("osssink");
165 TEST_START (PIPELINE1, audio_file);
171 * - default video playback pipeline (without audio)
174 video_file = g_build_filename (g_get_home_dir (), "video.mpeg", NULL);
175 TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS),
176 "The following tests requires a valid mpeg file video.mpeg in your home directory.");
177 TEST_REQUIRE_ELEMENT ("mpegdemux");
178 TEST_REQUIRE_ELEMENT ("mpeg2dec");
179 TEST_REQUIRE_ELEMENT ("xvimagesink");
180 TEST_START (PIPELINE2, video_file);
186 * - default video playback pipeline (with audio)
187 * - more SOMETIMES pads
189 TEST_START (PIPELINE3, video_file);
195 * - default new gst-player pipeline
197 TEST_START (PIPELINE4, video_file);
203 * - default old gst-player pipeline
205 TEST_START (PIPELINE5, video_file);