gstreamer/tests/check/elements/videotestsrc.c

394 lines
12 KiB
C
Raw Normal View History

/* GStreamer
*
* unit test for videotestsrc
*
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
* Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_VALGRIND
# include <valgrind/valgrind.h>
#endif
#include <unistd.h>
#include <gst/check/gstcheck.h>
/* For ease of programming we use globals to keep refs for our floating
* src and sink pads we create; otherwise we always have to do get_pad,
* get_peer, and then remove references in every test function */
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static... Original commit message from CVS: * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type): * ext/alsa/gstalsasink.c: (set_hwparams): * ext/alsa/gstalsasrc.c: (set_hwparams): * ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri): * ext/ogg/gstoggmux.h: * ext/ogg/gstogmparse.c: * gst-libs/gst/audio/audio.c: * gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc): * gst-libs/gst/pbutils/missing-plugins.c: (gst_missing_uri_sink_message_new), (gst_missing_element_message_new), (gst_missing_decoder_message_new), (gst_missing_encoder_message_new): * gst-libs/gst/rtp/gstbasertppayload.c: * gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_bye_get_reason): * gst/audioconvert/gstaudioconvert.c: * gst/audioresample/gstaudioresample.c: * gst/ffmpegcolorspace/imgconvert.c: * gst/playback/test.c: (gen_video_element), (gen_audio_element): * gst/typefind/gsttypefindfunctions.c: * gst/videoscale/vs_4tap.c: * gst/videoscale/vs_4tap.h: * sys/v4l/gstv4lelement.c: * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps): * sys/v4l/v4l_calls.c: * sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init), (gst_v4lsrc_try_capture): * sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls), (gst_ximagesink_ximage_new): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls), (gst_xvimagesink_xvimage_new): * tests/check/elements/audioconvert.c: * tests/check/elements/audioresample.c: (fail_unless_perfect_stream): * tests/check/elements/audiotestsrc.c: (setup_audiotestsrc): * tests/check/elements/decodebin.c: * tests/check/elements/gdpdepay.c: (setup_gdpdepay), (setup_gdpdepay_streamheader): * tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST), (setup_gdppay_streamheader): * tests/check/elements/gnomevfssink.c: (setup_gnomevfssink): * tests/check/elements/multifdsink.c: (setup_multifdsink): * tests/check/elements/textoverlay.c: * tests/check/elements/videorate.c: (setup_videorate): * tests/check/elements/videotestsrc.c: (setup_videotestsrc): * tests/check/elements/volume.c: (setup_volume): * tests/check/elements/vorbisdec.c: (setup_vorbisdec): * tests/check/elements/vorbistag.c: * tests/check/generic/clock-selection.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/libs/cddabasesrc.c: * tests/check/libs/video.c: * tests/check/pipelines/gio.c: * tests/check/pipelines/oggmux.c: * tests/check/pipelines/simple-launch-lines.c: (simple_launch_lines_suite): * tests/check/pipelines/streamheader.c: * tests/check/pipelines/theoraenc.c: * tests/check/pipelines/vorbisdec.c: * tests/check/pipelines/vorbisenc.c: * tests/examples/seek/scrubby.c: * tests/examples/seek/seek.c: (query_positions_elems), (query_positions_pads): * tests/icles/stress-xoverlay.c: (myclock): Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static, using NULL instead of 0 for pointers and using "foo (void)" instead of "foo ()" for declarations. * win32/common/libgstrtp.def: Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
static GstPad *mysinkpad;
#define CAPS_TEMPLATE_STRING \
2011-09-29 11:46:36 +00:00
"video/x-raw, " \
2011-06-16 11:41:25 +00:00
"format = (string) UYVY, " \
"width = (int) [ 1, MAX ], " \
"height = (int) [ 1, MAX ], " \
"framerate = (fraction) [ 0/1, MAX ]"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CAPS_TEMPLATE_STRING)
);
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static... Original commit message from CVS: * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type): * ext/alsa/gstalsasink.c: (set_hwparams): * ext/alsa/gstalsasrc.c: (set_hwparams): * ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri): * ext/ogg/gstoggmux.h: * ext/ogg/gstogmparse.c: * gst-libs/gst/audio/audio.c: * gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc): * gst-libs/gst/pbutils/missing-plugins.c: (gst_missing_uri_sink_message_new), (gst_missing_element_message_new), (gst_missing_decoder_message_new), (gst_missing_encoder_message_new): * gst-libs/gst/rtp/gstbasertppayload.c: * gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_bye_get_reason): * gst/audioconvert/gstaudioconvert.c: * gst/audioresample/gstaudioresample.c: * gst/ffmpegcolorspace/imgconvert.c: * gst/playback/test.c: (gen_video_element), (gen_audio_element): * gst/typefind/gsttypefindfunctions.c: * gst/videoscale/vs_4tap.c: * gst/videoscale/vs_4tap.h: * sys/v4l/gstv4lelement.c: * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps): * sys/v4l/v4l_calls.c: * sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init), (gst_v4lsrc_try_capture): * sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls), (gst_ximagesink_ximage_new): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls), (gst_xvimagesink_xvimage_new): * tests/check/elements/audioconvert.c: * tests/check/elements/audioresample.c: (fail_unless_perfect_stream): * tests/check/elements/audiotestsrc.c: (setup_audiotestsrc): * tests/check/elements/decodebin.c: * tests/check/elements/gdpdepay.c: (setup_gdpdepay), (setup_gdpdepay_streamheader): * tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST), (setup_gdppay_streamheader): * tests/check/elements/gnomevfssink.c: (setup_gnomevfssink): * tests/check/elements/multifdsink.c: (setup_multifdsink): * tests/check/elements/textoverlay.c: * tests/check/elements/videorate.c: (setup_videorate): * tests/check/elements/videotestsrc.c: (setup_videotestsrc): * tests/check/elements/volume.c: (setup_volume): * tests/check/elements/vorbisdec.c: (setup_vorbisdec): * tests/check/elements/vorbistag.c: * tests/check/generic/clock-selection.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/libs/cddabasesrc.c: * tests/check/libs/video.c: * tests/check/pipelines/gio.c: * tests/check/pipelines/oggmux.c: * tests/check/pipelines/simple-launch-lines.c: (simple_launch_lines_suite): * tests/check/pipelines/streamheader.c: * tests/check/pipelines/theoraenc.c: * tests/check/pipelines/vorbisdec.c: * tests/check/pipelines/vorbisenc.c: * tests/examples/seek/scrubby.c: * tests/examples/seek/seek.c: (query_positions_elems), (query_positions_pads): * tests/icles/stress-xoverlay.c: (myclock): Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static, using NULL instead of 0 for pointers and using "foo (void)" instead of "foo ()" for declarations. * win32/common/libgstrtp.def: Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
static GstElement *
setup_videotestsrc (void)
{
GstElement *videotestsrc;
GST_DEBUG ("setup_videotestsrc");
videotestsrc = gst_check_setup_element ("videotestsrc");
2012-01-04 15:41:53 +00:00
mysinkpad = gst_check_setup_sink_pad (videotestsrc, &sinktemplate);
gst_pad_set_active (mysinkpad, TRUE);
return videotestsrc;
}
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static... Original commit message from CVS: * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type): * ext/alsa/gstalsasink.c: (set_hwparams): * ext/alsa/gstalsasrc.c: (set_hwparams): * ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri): * ext/ogg/gstoggmux.h: * ext/ogg/gstogmparse.c: * gst-libs/gst/audio/audio.c: * gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc): * gst-libs/gst/pbutils/missing-plugins.c: (gst_missing_uri_sink_message_new), (gst_missing_element_message_new), (gst_missing_decoder_message_new), (gst_missing_encoder_message_new): * gst-libs/gst/rtp/gstbasertppayload.c: * gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_bye_get_reason): * gst/audioconvert/gstaudioconvert.c: * gst/audioresample/gstaudioresample.c: * gst/ffmpegcolorspace/imgconvert.c: * gst/playback/test.c: (gen_video_element), (gen_audio_element): * gst/typefind/gsttypefindfunctions.c: * gst/videoscale/vs_4tap.c: * gst/videoscale/vs_4tap.h: * sys/v4l/gstv4lelement.c: * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps): * sys/v4l/v4l_calls.c: * sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init), (gst_v4lsrc_try_capture): * sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls), (gst_ximagesink_ximage_new): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls), (gst_xvimagesink_xvimage_new): * tests/check/elements/audioconvert.c: * tests/check/elements/audioresample.c: (fail_unless_perfect_stream): * tests/check/elements/audiotestsrc.c: (setup_audiotestsrc): * tests/check/elements/decodebin.c: * tests/check/elements/gdpdepay.c: (setup_gdpdepay), (setup_gdpdepay_streamheader): * tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST), (setup_gdppay_streamheader): * tests/check/elements/gnomevfssink.c: (setup_gnomevfssink): * tests/check/elements/multifdsink.c: (setup_multifdsink): * tests/check/elements/textoverlay.c: * tests/check/elements/videorate.c: (setup_videorate): * tests/check/elements/videotestsrc.c: (setup_videotestsrc): * tests/check/elements/volume.c: (setup_volume): * tests/check/elements/vorbisdec.c: (setup_vorbisdec): * tests/check/elements/vorbistag.c: * tests/check/generic/clock-selection.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/libs/cddabasesrc.c: * tests/check/libs/video.c: * tests/check/pipelines/gio.c: * tests/check/pipelines/oggmux.c: * tests/check/pipelines/simple-launch-lines.c: (simple_launch_lines_suite): * tests/check/pipelines/streamheader.c: * tests/check/pipelines/theoraenc.c: * tests/check/pipelines/vorbisdec.c: * tests/check/pipelines/vorbisenc.c: * tests/examples/seek/scrubby.c: * tests/examples/seek/seek.c: (query_positions_elems), (query_positions_pads): * tests/icles/stress-xoverlay.c: (myclock): Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static, using NULL instead of 0 for pointers and using "foo (void)" instead of "foo ()" for declarations. * win32/common/libgstrtp.def: Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
static void
cleanup_videotestsrc (GstElement * videotestsrc)
{
GST_DEBUG ("cleanup_videotestsrc");
gst_check_drop_buffers ();
gst_pad_set_active (mysinkpad, FALSE);
gst_check_teardown_sink_pad (videotestsrc);
gst_check_teardown_element (videotestsrc);
}
GST_START_TEST (test_all_patterns)
{
GstElement *videotestsrc;
GObjectClass *oclass;
GParamSpec *property;
GEnumValue *values;
guint j = 0;
videotestsrc = setup_videotestsrc ();
oclass = G_OBJECT_GET_CLASS (videotestsrc);
property = g_object_class_find_property (oclass, "pattern");
fail_unless (G_IS_PARAM_SPEC_ENUM (property));
values = G_ENUM_CLASS (g_type_class_ref (property->value_type))->values;
while (values[j].value_name) {
GST_DEBUG_OBJECT (videotestsrc, "testing pattern %s", values[j].value_name);
g_object_set (videotestsrc, "pattern", j, NULL);
fail_unless (gst_element_set_state (videotestsrc,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
2012-09-12 10:54:07 +00:00
g_mutex_lock (&check_mutex);
while (g_list_length (buffers) < 10) {
GST_DEBUG_OBJECT (videotestsrc, "Waiting for more buffers");
2012-09-12 10:54:07 +00:00
g_cond_wait (&check_cond, &check_mutex);
}
2012-09-12 10:54:07 +00:00
g_mutex_unlock (&check_mutex);
gst_element_set_state (videotestsrc, GST_STATE_READY);
gst_check_drop_buffers ();
++j;
}
/* cleanup */
cleanup_videotestsrc (videotestsrc);
}
GST_END_TEST;
static guint32
right_shift_colour (guint32 mask, guint32 pixel)
{
if (mask == 0)
return 0;
pixel = pixel & mask;
while ((mask & 0x01) == 0) {
mask = mask >> 1;
pixel = pixel >> 1;
}
return pixel;
}
static guint8
fix_expected_colour (guint32 col_mask, guint8 col_expected)
{
guint32 mask;
gint last = g_bit_nth_msf (col_mask, -1);
gint first = g_bit_nth_lsf (col_mask, -1);
mask = 1 << (last - first + 1);
mask -= 1;
g_assert (col_expected == 0x00 || col_expected == 0xff);
/* this only works because we only check for all-bits-set or no-bits-set */
return col_expected & mask;
}
static void
check_rgb_buf (const guint8 * pixels, guint32 r_mask, guint32 g_mask,
guint32 b_mask, guint32 a_mask, guint8 r_expected, guint8 g_expected,
2012-01-04 15:41:53 +00:00
guint8 b_expected, guint bpp, guint depth)
{
guint32 pixel, red, green, blue, alpha;
switch (bpp) {
2012-01-04 15:41:53 +00:00
case 32:
pixel = GST_READ_UINT32_BE (pixels);
break;
2012-01-04 15:41:53 +00:00
case 24:
pixel = (GST_READ_UINT8 (pixels) << 16) |
(GST_READ_UINT8 (pixels + 1) << 8) |
(GST_READ_UINT8 (pixels + 2) << 0);
break;
2012-01-04 15:41:53 +00:00
case 16:
if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
pixel = GST_READ_UINT16_LE (pixels);
else
pixel = GST_READ_UINT16_BE (pixels);
break;
default:
g_return_if_reached ();
}
red = right_shift_colour (r_mask, pixel);
green = right_shift_colour (g_mask, pixel);
blue = right_shift_colour (b_mask, pixel);
alpha = right_shift_colour (a_mask, pixel);
/* can't enable this by default, valgrind will complain about accessing
* uninitialised memory for the depth=24,bpp=32 formats ... */
/* GST_LOG ("pixels: 0x%02x 0x%02x 0x%02x 0x%02x => pixel = 0x%08x",
pixels[0], (guint) pixels[1], pixels[2], pixels[3], pixel); */
/* fix up the mask (for rgb15/16) */
if (bpp == 16) {
r_expected = fix_expected_colour (r_mask, r_expected);
g_expected = fix_expected_colour (g_mask, g_expected);
b_expected = fix_expected_colour (b_mask, b_expected);
}
fail_unless (red == r_expected, "RED: expected 0x%02x, found 0x%02x",
r_expected, red);
fail_unless (green == g_expected, "GREEN: expected 0x%02x, found 0x%02x",
g_expected, green);
fail_unless (blue == b_expected, "BLUE: expected 0x%02x, found 0x%02x",
b_expected, blue);
fail_unless (a_mask == 0 || alpha != 0); /* better than nothing */
}
static void
got_buf_cb (GstElement * sink, GstBuffer * new_buf, GstPad * pad,
2012-02-03 11:53:49 +00:00
GstSample ** p_old_sample)
{
2012-02-03 11:53:49 +00:00
GstCaps *caps;
caps = gst_pad_get_current_caps (pad);
if (*p_old_sample)
gst_sample_unref (*p_old_sample);
*p_old_sample = gst_sample_new (new_buf, caps, NULL, NULL);
2012-03-30 14:56:45 +00:00
gst_caps_unref (caps);
}
/* tests the positioning of pixels within the various RGB pixel layouts */
GST_START_TEST (test_rgb_formats)
{
const struct
{
const gchar *pattern_name;
gint pattern_enum;
guint8 r_expected;
guint8 g_expected;
guint8 b_expected;
} test_patterns[] = {
{
"white", 3, 0xff, 0xff, 0xff}, {
"red", 4, 0xff, 0x00, 0x00}, {
"green", 5, 0x00, 0xff, 0x00}, {
"blue", 6, 0x00, 0x00, 0xff}, {
"black", 2, 0x00, 0x00, 0x00}
};
const struct
{
const gchar *nick;
guint bpp, depth;
guint32 red_mask, green_mask, blue_mask, alpha_mask;
} rgb_formats[] = {
{
"RGBA", 32, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff}, {
"ARGB", 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, {
"BGRA", 32, 32, 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff}, {
"ABGR", 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}, {
"RGBx", 32, 24, 0xff000000, 0x00ff0000, 0x0000ff00, 0x00000000}, {
"xRGB", 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000}, {
"BGRx", 32, 24, 0x0000ff00, 0x00ff0000, 0xff000000, 0x00000000}, {
"xBGR", 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000}, {
2012-01-04 15:41:53 +00:00
"RGB", 24, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000}, {
"BGR", 24, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000}, {
"RGB16", 16, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000}, {
"RGB15", 16, 15, 0x00007c00, 0x000003e0, 0x0000001f, 0x0000000}
};
GstElement *pipeline, *src, *filter, *sink;
GstCaps *template_caps;
2012-02-03 11:53:49 +00:00
GstSample *sample = NULL;
GstPad *srcpad;
gint p, i, e;
/* test check function */
fail_unless (right_shift_colour (0x00ff0000, 0x11223344) == 0x22);
pipeline = gst_pipeline_new ("pipeline");
src = gst_check_setup_element ("videotestsrc");
filter = gst_check_setup_element ("capsfilter");
sink = gst_check_setup_element ("fakesink");
gst_bin_add_many (GST_BIN (pipeline), src, filter, sink, NULL);
fail_unless (gst_element_link (src, filter));
fail_unless (gst_element_link (filter, sink));
Don't use bad gst_element_get_pad(). Original commit message from CVS: * ext/ogg/gstoggdemux.c: (gst_ogg_pad_typefind): * gst/playback/decodetest.c: (new_decoded_pad_cb): * gst/playback/gstdecodebin.c: (gst_decode_bin_init), (try_to_link_1), (elem_is_dynamic), (close_link), (type_found), (cleanup_decodebin): * gst/playback/gstdecodebin2.c: (gst_decode_bin_init), (connect_element), (gst_decode_group_control_demuxer_pad): * gst/playback/gstplaybasebin.c: (queue_remove_probe), (queue_out_of_data), (gen_preroll_element), (preroll_unlinked), (mute_group_type): * gst/playback/gstplaybin.c: (gst_play_bin_vis_blocked), (gst_play_bin_set_property), (handoff), (gen_video_element), (gen_text_element), (gen_audio_element), (gen_vis_element), (remove_sinks), (add_sink), (setup_sinks): * gst/playback/gstplaybin2.c: (pad_added_cb), (no_more_pads_cb): * gst/playback/gstplaysink.c: (gst_play_sink_get_video_sink), (gst_play_sink_get_audio_sink), (gst_play_sink_vis_unblocked), (gst_play_sink_vis_blocked), (gst_play_sink_set_vis_plugin), (gst_play_sink_get_vis_plugin), (gst_play_sink_set_mute), (gen_video_chain), (gen_text_chain), (gen_audio_chain), (gen_vis_chain), (gst_play_sink_reconfigure), (gst_play_sink_set_font_desc), (gst_play_sink_get_font_desc), (gst_play_sink_request_pad): * gst/playback/gsturidecodebin.c: (type_found), (setup_source): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (cb_newpad): * gst/playback/test6.c: (new_decoded_pad_cb): * tests/check/elements/audioconvert.c: (GST_START_TEST): * tests/check/elements/audiorate.c: (test_injector_chain), (do_perfect_stream_test): * tests/check/elements/ffmpegcolorspace.c: (GST_START_TEST): * tests/check/elements/gdpdepay.c: (GST_START_TEST): * tests/check/elements/gnomevfssink.c: * tests/check/elements/textoverlay.c: (notgst_check_setup_src_pad2), (notgst_check_teardown_src_pad2): * tests/check/elements/videotestsrc.c: (GST_START_TEST): * tests/check/libs/cddabasesrc.c: (GST_START_TEST): * tests/check/pipelines/oggmux.c: (test_pipeline): * tests/check/pipelines/streamheader.c: (GST_START_TEST): * tests/check/pipelines/theoraenc.c: (GST_START_TEST): * tests/check/pipelines/vorbisenc.c: (GST_START_TEST): * tests/examples/seek/scrubby.c: (make_wav_pipeline): * tests/examples/seek/seek.c: (make_mod_pipeline), (make_dv_pipeline), (make_wav_pipeline), (make_flac_pipeline), (make_sid_pipeline), (make_parse_pipeline), (make_vorbis_pipeline), (make_theora_pipeline), (make_vorbis_theora_pipeline), (make_avi_msmpeg4v3_mp3_pipeline), (make_mp3_pipeline), (make_avi_pipeline), (make_mpeg_pipeline), (make_mpegnt_pipeline), (update_fill), (msg_buffering): Don't use bad gst_element_get_pad().
2008-05-21 16:36:50 +00:00
srcpad = gst_element_get_static_pad (src, "src");
template_caps = gst_pad_get_pad_template_caps (srcpad);
g_object_set (sink, "signal-handoffs", TRUE, NULL);
2012-02-03 11:53:49 +00:00
g_signal_connect (sink, "preroll-handoff", G_CALLBACK (got_buf_cb), &sample);
GST_LOG ("videotestsrc src template caps: %" GST_PTR_FORMAT, template_caps);
for (i = 0; i < G_N_ELEMENTS (rgb_formats); ++i) {
for (e = 0; e < 2; ++e) {
GstCaps *caps;
2012-01-04 15:41:53 +00:00
caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, rgb_formats[i].nick,
"width", G_TYPE_INT, 16, "height", G_TYPE_INT, 16,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL);
if (gst_caps_is_subset (caps, template_caps)) {
/* caps are supported, let's run some tests then ... */
for (p = 0; p < G_N_ELEMENTS (test_patterns); ++p) {
GstStateChangeReturn state_ret;
2012-01-20 15:11:54 +00:00
GstMapInfo map;
g_object_set (src, "pattern", test_patterns[p].pattern_enum, NULL);
2012-01-04 15:41:53 +00:00
GST_INFO ("%5s %u/%u %08x %08x %08x %08x, pattern=%s",
rgb_formats[i].nick, rgb_formats[i].bpp, rgb_formats[i].depth,
rgb_formats[i].red_mask, rgb_formats[i].green_mask,
2012-01-04 15:41:53 +00:00
rgb_formats[i].blue_mask, rgb_formats[i].alpha_mask,
test_patterns[p].pattern_name);
/* now get videotestsrc to produce a buffer with the given caps */
g_object_set (filter, "caps", caps, NULL);
state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
fail_unless (state_ret != GST_STATE_CHANGE_FAILURE,
"pipeline _set_state() to PAUSED failed");
state_ret = gst_element_get_state (pipeline, NULL, NULL, -1);
fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS,
"pipeline failed going to PAUSED state");
state_ret = gst_element_set_state (pipeline, GST_STATE_NULL);
fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS);
2012-02-03 11:53:49 +00:00
fail_unless (sample != NULL);
/* check buffer caps */
{
2012-02-03 11:53:49 +00:00
GstBuffer *buf;
GstStructure *s;
2012-01-04 15:41:53 +00:00
GstCaps *caps;
const gchar *format;
2012-02-03 11:53:49 +00:00
buf = gst_sample_get_buffer (sample);
fail_unless (buf != NULL);
caps = gst_sample_get_caps (sample);
2012-01-04 15:41:53 +00:00
fail_unless (caps != NULL);
2012-01-04 15:41:53 +00:00
s = gst_caps_get_structure (caps, 0);
format = gst_structure_get_string (s, "format");
fail_unless (g_str_equal (format, rgb_formats[i].nick));
2012-02-03 11:53:49 +00:00
/* now check the first pixel */
gst_buffer_map (buf, &map, GST_MAP_READ);
check_rgb_buf (map.data, rgb_formats[i].red_mask,
rgb_formats[i].green_mask, rgb_formats[i].blue_mask,
rgb_formats[i].alpha_mask, test_patterns[p].r_expected,
test_patterns[p].g_expected, test_patterns[p].b_expected,
rgb_formats[i].bpp, rgb_formats[i].depth);
gst_buffer_unmap (buf, &map);
gst_sample_unref (sample);
sample = NULL;
}
}
} else {
GST_INFO ("videotestsrc doesn't support format %" GST_PTR_FORMAT, caps);
}
gst_caps_unref (caps);
}
}
gst_caps_unref (template_caps);
2012-01-04 15:41:53 +00:00
gst_object_unref (srcpad);
gst_object_unref (pipeline);
}
GST_END_TEST;
/* FIXME: add tests for YUV formats */
static Suite *
videotestsrc_suite (void)
{
Suite *s = suite_create ("videotestsrc");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
#ifdef HAVE_VALGRIND
if (RUNNING_ON_VALGRIND) {
/* test_rgb_formats takes a bit longer, so increase timeout */
tcase_set_timeout (tc_chain, 5 * 60);
}
#endif
tcase_add_test (tc_chain, test_all_patterns);
tcase_add_test (tc_chain, test_rgb_formats);
return s;
}
GST_CHECK_MAIN (videotestsrc);