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 pipe_str = g_strdup_printf ("audiotestsrc num-buffers=100"
58 " ! audio/x-raw-int,rate=44100 ! audioconvert ! vorbisenc ! vorbisdec"
59 " ! identity check-imperfect-timestamp=TRUE ! fakesink");
61 pipeline = gst_parse_launch (pipe_str, &error);
62 fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
63 error ? error->message : "(invalid error)");
66 bus = gst_element_get_bus (pipeline);
67 fail_if (bus == NULL);
68 gst_bus_add_signal_watch (bus);
69 g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
71 g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
73 gst_element_set_state (pipeline, GST_STATE_PLAYING);
75 /* run until we receive EOS */
76 loop = g_main_loop_new (NULL, FALSE);
78 g_main_loop_run (loop);
80 gst_element_set_state (pipeline, GST_STATE_NULL);
82 fail_if (messages > 0, "Received imperfect timestamp messages");
83 gst_object_unref (pipeline);
87 #endif /* #ifndef GST_DISABLE_PARSE */
90 vorbisenc_suite (void)
92 Suite *s = suite_create ("vorbisenc");
93 TCase *tc_chain = tcase_create ("general");
95 suite_add_tcase (s, tc_chain);
96 #ifndef GST_DISABLE_PARSE
97 tcase_add_test (tc_chain, test_timestamps);
104 main (int argc, char **argv)
108 Suite *s = vorbisenc_suite ();
109 SRunner *sr = srunner_create (s);
111 gst_check_init (&argc, &argv);
113 srunner_run_all (sr, CK_NORMAL);
114 nf = srunner_ntests_failed (sr);