3 * unit test for vorbisdec
5 * Copyright (C) 2007 Thomas Vander Stichele <thomas at apestaart dot org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #include <gst/check/gstcheck.h>
24 #include <gst/check/gstbufferstraw.h>
26 #ifndef GST_DISABLE_PARSE
28 static GMainLoop *loop;
29 static gint messages = 0;
32 element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
36 s = gst_structure_to_string (gst_message_get_structure (message));
37 GST_DEBUG ("Received message: %s", s);
44 eos_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
46 GST_DEBUG ("Received eos");
47 g_main_loop_quit (loop);
50 GST_START_TEST (test_timestamps)
57 /* allowing some tolerance permits audiodecoder to come up with
58 * perfect timestamps rather than sticking to upstream ts */
59 pipe_str = g_strdup_printf ("audiotestsrc num-buffers=100"
60 " ! audio/x-raw-int,rate=44100 ! audioconvert ! vorbisenc "
61 " ! vorbisdec tolerance=10000000 "
62 " ! identity check-imperfect-timestamp=TRUE ! fakesink");
64 pipeline = gst_parse_launch (pipe_str, &error);
65 fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
66 error ? error->message : "(invalid error)");
69 bus = gst_element_get_bus (pipeline);
70 fail_if (bus == NULL);
71 gst_bus_add_signal_watch (bus);
72 g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
74 g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
76 gst_element_set_state (pipeline, GST_STATE_PLAYING);
78 /* run until we receive EOS */
79 loop = g_main_loop_new (NULL, FALSE);
81 g_main_loop_run (loop);
83 gst_element_set_state (pipeline, GST_STATE_NULL);
85 fail_if (messages > 0, "Received imperfect timestamp messages");
86 gst_object_unref (pipeline);
90 #endif /* #ifndef GST_DISABLE_PARSE */
93 vorbisenc_suite (void)
95 Suite *s = suite_create ("vorbisenc");
96 TCase *tc_chain = tcase_create ("general");
98 suite_add_tcase (s, tc_chain);
99 #ifndef GST_DISABLE_PARSE
100 tcase_add_test (tc_chain, test_timestamps);
107 main (int argc, char **argv)
111 Suite *s = vorbisenc_suite ();
112 SRunner *sr = srunner_create (s);
114 gst_check_init (&argc, &argv);
116 srunner_run_all (sr, CK_NORMAL);
117 nf = srunner_ntests_failed (sr);