|
Packit |
971217 |
/* GStreamer
|
|
Packit |
971217 |
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* simple_launch_lines.c: Unit test for simple pipelines
|
|
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 |
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/check/gstcheck.h>
|
|
Packit |
971217 |
#include <gst/audio/audio-format.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifndef GST_DISABLE_PARSE
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static GstElement *
|
|
Packit |
971217 |
setup_pipeline (const gchar * pipe_descr)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstElement *pipeline;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_LOG ("pipeline: %s", pipe_descr);
|
|
Packit |
971217 |
pipeline = gst_parse_launch (pipe_descr, NULL);
|
|
Packit |
971217 |
g_return_val_if_fail (GST_IS_PIPELINE (pipeline), NULL);
|
|
Packit |
971217 |
return pipeline;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/*
|
|
Packit |
971217 |
* run_pipeline:
|
|
Packit |
971217 |
* @pipe: the pipeline to run
|
|
Packit |
971217 |
* @desc: the description for use in messages
|
|
Packit |
971217 |
* @events: is a mask of expected events
|
|
Packit |
971217 |
* @tevent: is the expected terminal event.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* the poll call will time out after half a second.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
run_pipeline (GstElement * pipe, const gchar * descr,
|
|
Packit |
971217 |
GstMessageType events, GstMessageType tevent)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstBus *bus;
|
|
Packit |
971217 |
GstMessage *message;
|
|
Packit |
971217 |
GstMessageType revent;
|
|
Packit |
971217 |
GstStateChangeReturn ret;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_assert (pipe);
|
|
Packit |
971217 |
bus = gst_element_get_bus (pipe);
|
|
Packit |
971217 |
g_assert (bus);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
fail_if (gst_element_set_state (pipe, GST_STATE_PLAYING) ==
|
|
Packit |
971217 |
GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to playing", descr);
|
|
Packit |
971217 |
ret = gst_element_get_state (pipe, NULL, NULL, 10 * GST_SECOND);
|
|
Packit |
971217 |
if (ret == GST_STATE_CHANGE_ASYNC) {
|
|
Packit |
971217 |
g_critical ("Pipeline '%s' failed to go to PLAYING fast enough", descr);
|
|
Packit |
971217 |
goto done;
|
|
Packit |
971217 |
} else if (ret != GST_STATE_CHANGE_SUCCESS) {
|
|
Packit |
971217 |
g_critical ("Pipeline '%s' failed to go into PLAYING state", descr);
|
|
Packit |
971217 |
goto done;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
while (1) {
|
|
Packit |
971217 |
message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 2);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* always have to pop the message before getting back into poll */
|
|
Packit |
971217 |
if (message) {
|
|
Packit |
971217 |
revent = GST_MESSAGE_TYPE (message);
|
|
Packit |
971217 |
gst_message_unref (message);
|
|
Packit |
971217 |
} else {
|
|
Packit |
971217 |
revent = GST_MESSAGE_UNKNOWN;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (revent == tevent) {
|
|
Packit |
971217 |
break;
|
|
Packit |
971217 |
} else if (revent == GST_MESSAGE_UNKNOWN) {
|
|
Packit |
971217 |
g_critical ("Unexpected timeout in gst_bus_poll, looking for %d: %s",
|
|
Packit |
971217 |
tevent, descr);
|
|
Packit |
971217 |
break;
|
|
Packit |
971217 |
} else if (revent & events) {
|
|
Packit |
971217 |
continue;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
g_critical
|
|
Packit |
971217 |
("Unexpected message received of type %d, '%s', looking for %d: %s",
|
|
Packit |
971217 |
revent, gst_message_type_get_name (revent), tevent, descr);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
done:
|
|
Packit |
971217 |
fail_if (gst_element_set_state (pipe, GST_STATE_NULL) ==
|
|
Packit |
971217 |
GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to NULL", descr);
|
|
Packit |
971217 |
gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE);
|
|
Packit |
971217 |
gst_object_unref (pipe);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_bus_set_flushing (bus, TRUE);
|
|
Packit |
971217 |
gst_object_unref (bus);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_START_TEST (test_element_negotiation)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
const gchar *s;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Ensures that filtering buffers with unknown caps down to fixed-caps
|
|
Packit |
971217 |
* will apply those caps to the buffers.
|
|
Packit |
971217 |
* see http://bugzilla.gnome.org/show_bug.cgi?id=315126 */
|
|
Packit |
971217 |
s = "fakesrc num-buffers=2 ! "
|
|
Packit |
971217 |
"audio/x-raw,format=" GST_AUDIO_NE (S16) ",rate=22050,channels=1 "
|
|
Packit |
971217 |
"! audioconvert "
|
|
Packit |
971217 |
"! audio/x-raw,format=" GST_AUDIO_NE (S16) ",rate=22050,channels=1 "
|
|
Packit |
971217 |
"! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifdef HAVE_LIBVISUAL
|
|
Packit |
971217 |
s = "audiotestsrc num-buffers=30 ! tee name=t ! alsasink t. ! audioconvert ! "
|
|
Packit |
971217 |
"libvisual_lv_scope ! videoconvert ! xvimagesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_END_TEST;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_START_TEST (test_basetransform_based)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
/* Each of these tests is to check whether various basetransform based
|
|
Packit |
971217 |
* elements can select output caps when not allowed to do passthrough
|
|
Packit |
971217 |
* and going to a generic sink such as fakesink or filesink */
|
|
Packit |
971217 |
const gchar *s;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Check that videoscale can pick a height given only a width */
|
|
Packit |
971217 |
s = "videotestsrc num-buffers=2 ! "
|
|
Packit |
971217 |
"video/x-raw,format=(string)I420,width=320,height=240 ! "
|
|
Packit |
971217 |
"videoscale ! video/x-raw,width=640 ! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Test that videoconvert can pick an output format that isn't
|
|
Packit |
971217 |
* passthrough without completely specified output caps */
|
|
Packit |
971217 |
s = "videotestsrc num-buffers=2 ! "
|
|
Packit |
971217 |
"video/x-raw,format=(string)I420,width=320,height=240 ! "
|
|
Packit |
971217 |
"videoconvert ! video/x-raw,format=(string)RGB ! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Check that audioresample can pick a samplerate to use from a
|
|
Packit |
971217 |
* range that doesn't include the input */
|
|
Packit |
971217 |
s = "audiotestsrc num-buffers=2 ! "
|
|
Packit |
971217 |
"audio/x-raw,format=" GST_AUDIO_NE (S16) ",rate=8000 ! "
|
|
Packit |
971217 |
"audioresample ! audio/x-raw,rate=[16000,48000] ! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Check that audioconvert can pick a depth to use, given a width */
|
|
Packit |
971217 |
s = "audiotestsrc num-buffers=30 ! audio/x-raw,format=" GST_AUDIO_NE (S16)
|
|
Packit |
971217 |
" ! audioconvert ! " "audio/x-raw,format=" GST_AUDIO_NE (S32)
|
|
Packit |
971217 |
" ! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Check that videoscale doesn't claim to be able to transform input in
|
|
Packit |
971217 |
* formats it can't handle for a given scaling method; videoconvert
|
|
Packit |
971217 |
* should then make sure a format that can be handled is chosen (4-tap
|
|
Packit |
971217 |
* scaling is not implemented for RGB and packed yuv currently) */
|
|
Packit |
971217 |
s = "videotestsrc num-buffers=2 ! video/x-raw,format=(string)ARGB64 ! "
|
|
Packit |
971217 |
"videoconvert ! videoscale method=4-tap ! videoconvert ! "
|
|
Packit |
971217 |
"video/x-raw,format=(string)RGB, width=32,height=32,framerate=(fraction)30/1,"
|
|
Packit |
971217 |
"pixel-aspect-ratio=(fraction)1/1 ! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
s = "videotestsrc num-buffers=2 ! video/x-raw,format=(string)AYUV,"
|
|
Packit |
971217 |
"width=64,height=64 ! videoconvert ! videoscale method=4-tap ! "
|
|
Packit |
971217 |
"videoconvert ! video/x-raw,format=(string)AYUV,width=32,"
|
|
Packit |
971217 |
"height=32 ! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
/* make sure nothing funny happens in passthrough mode (we don't check that
|
|
Packit |
971217 |
* passthrough mode is chosen though) */
|
|
Packit |
971217 |
s = "videotestsrc num-buffers=2 ! video/x-raw,format=(string)I420,"
|
|
Packit |
971217 |
"width=64,height=64 ! videoconvert ! videoscale method=4-tap ! "
|
|
Packit |
971217 |
"videoconvert ! video/x-raw,format=(string)I420,width=32,"
|
|
Packit |
971217 |
"height=32 ! fakesink";
|
|
Packit |
971217 |
run_pipeline (setup_pipeline (s), s,
|
|
Packit |
971217 |
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
|
|
Packit |
971217 |
GST_MESSAGE_UNKNOWN);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_END_TEST;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#endif /* #ifndef GST_DISABLE_PARSE */
|
|
Packit |
971217 |
static Suite *
|
|
Packit |
971217 |
simple_launch_lines_suite (void)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
Suite *s = suite_create ("Pipelines");
|
|
Packit |
971217 |
TCase *tc_chain = tcase_create ("linear");
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* time out after 60s, not the default 3 */
|
|
Packit |
971217 |
tcase_set_timeout (tc_chain, 60);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
suite_add_tcase (s, tc_chain);
|
|
Packit |
971217 |
#ifndef GST_DISABLE_PARSE
|
|
Packit |
971217 |
tcase_add_test (tc_chain, test_element_negotiation);
|
|
Packit |
971217 |
tcase_add_test (tc_chain, test_basetransform_based);
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
return s;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_CHECK_MAIN (simple_launch_lines);
|