|
Packit |
971217 |
/* GStreamer
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* unit test for vorbisdec
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Copyright (C) 2007 Thomas Vander Stichele <thomas at apestaart dot org>
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
971217 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
971217 |
* License as published by the Free Software Foundation; either
|
|
Packit |
971217 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
971217 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
971217 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
971217 |
* Library General Public License for more details.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
971217 |
* License along with this library; if not, write to the
|
|
Packit |
971217 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
971217 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
971217 |
#include "config.h"
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/check/gstcheck.h>
|
|
Packit |
971217 |
#include <gst/check/gstbufferstraw.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifndef GST_DISABLE_PARSE
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static GMainLoop *loop;
|
|
Packit |
971217 |
static gint messages = 0;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
gchar *s;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
s = gst_structure_to_string (gst_message_get_structure (message));
|
|
Packit |
971217 |
GST_DEBUG ("Received message: %s", s);
|
|
Packit |
971217 |
g_free (s);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
messages++;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
eos_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GST_DEBUG ("Received eos");
|
|
Packit |
971217 |
g_main_loop_quit (loop);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_START_TEST (test_timestamps)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstElement *pipeline;
|
|
Packit |
971217 |
gchar *pipe_str;
|
|
Packit |
971217 |
GstBus *bus;
|
|
Packit |
971217 |
GError *error = NULL;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* allowing some tolerance permits audiodecoder to come up with
|
|
Packit |
971217 |
* perfect timestamps rather than sticking to upstream ts */
|
|
Packit |
971217 |
pipe_str = g_strdup_printf ("audiotestsrc num-buffers=100"
|
|
Packit |
971217 |
" ! audio/x-raw,rate=44100 ! audioconvert ! vorbisenc "
|
|
Packit |
971217 |
" ! vorbisdec tolerance=10000000 "
|
|
Packit |
971217 |
" ! identity check-imperfect-timestamp=TRUE ! fakesink");
|
|
Packit |
971217 |
|
|
Packit |
971217 |
pipeline = gst_parse_launch (pipe_str, &error);
|
|
Packit |
971217 |
fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
|
|
Packit |
971217 |
error ? error->message : "(invalid error)");
|
|
Packit |
971217 |
g_free (pipe_str);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
bus = gst_element_get_bus (pipeline);
|
|
Packit |
971217 |
fail_if (bus == NULL);
|
|
Packit |
971217 |
gst_bus_add_signal_watch (bus);
|
|
Packit |
971217 |
g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
|
|
Packit |
971217 |
NULL);
|
|
Packit |
971217 |
g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* run until we receive EOS */
|
|
Packit |
971217 |
loop = g_main_loop_new (NULL, FALSE);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_main_loop_run (loop);
|
|
Packit |
971217 |
g_main_loop_unref (loop);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_bus_remove_signal_watch (bus);
|
|
Packit |
971217 |
gst_object_unref (bus);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
fail_if (messages > 0, "Received imperfect timestamp messages");
|
|
Packit |
971217 |
gst_object_unref (pipeline);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_END_TEST;
|
|
Packit |
971217 |
#endif /* #ifndef GST_DISABLE_PARSE */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static Suite *
|
|
Packit |
971217 |
vorbisdec_suite (void)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
Suite *s = suite_create ("vorbisdec");
|
|
Packit |
971217 |
TCase *tc_chain = tcase_create ("general");
|
|
Packit |
971217 |
|
|
Packit |
971217 |
suite_add_tcase (s, tc_chain);
|
|
Packit |
971217 |
#ifndef GST_DISABLE_PARSE
|
|
Packit |
971217 |
tcase_add_test (tc_chain, test_timestamps);
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return s;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_CHECK_MAIN (vorbisdec);
|