gstreamer/tests/check/pipelines/streamheader.c

276 lines
7 KiB
C
Raw Normal View History

/* GStreamer
*
* unit test for streamheader handling
*
* Copyright (C) 2007 Thomas Vander Stichele <thomas at apestaart dot org>
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <unistd.h>
2012-01-19 14:32:52 +00:00
#include <gio/gio.h>
#include <gst/check/gstcheck.h>
#include <gst/check/gstbufferstraw.h>
#ifndef GST_DISABLE_PARSE
/* this tests a gdp-serialized tag from audiotestsrc being sent only once
2012-01-19 14:32:52 +00:00
* to clients of multisocketsink */
static int n_tags = 0;
2012-01-04 15:41:53 +00:00
static GstPadProbeReturn
tag_event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
2012-01-04 15:41:53 +00:00
GMainLoop *loop = user_data;
GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG:
{
++n_tags;
fail_if (n_tags > 1, "More than 1 tag received");
break;
}
case GST_EVENT_EOS:
{
g_main_loop_quit (loop);
break;
}
default:
break;
}
2012-01-04 15:41:53 +00:00
return GST_PAD_PROBE_OK;
}
2012-01-19 14:32:52 +00:00
GST_START_TEST (test_multisocketsink_gdp_tag)
{
GstElement *p1, *p2;
GstElement *src, *sink, *depay;
GstPad *pad;
GMainLoop *loop;
int pfd[2];
2012-01-19 14:32:52 +00:00
GSocket *s[2];
loop = g_main_loop_new (NULL, FALSE);
p1 = gst_parse_launch ("audiotestsrc num-buffers=10 ! gdppay"
2012-01-19 14:32:52 +00:00
" ! multisocketsink name=p1sink", NULL);
fail_if (p1 == NULL);
p2 = gst_parse_launch ("fdsrc name=p2src ! gdpdepay name=depay"
" ! fakesink name=p2sink signal-handoffs=True", NULL);
fail_if (p2 == NULL);
fail_if (pipe (pfd) == -1);
2012-01-19 14:32:52 +00:00
s[0] = g_socket_new_from_fd (pfd[0], NULL);
gst_element_set_state (p1, GST_STATE_READY);
sink = gst_bin_get_by_name (GST_BIN (p1), "p1sink");
2012-01-19 14:32:52 +00:00
g_signal_emit_by_name (sink, "add", s[1], NULL);
gst_object_unref (sink);
src = gst_bin_get_by_name (GST_BIN (p2), "p2src");
g_object_set (G_OBJECT (src), "fd", pfd[0], NULL);
gst_object_unref (src);
depay = gst_bin_get_by_name (GST_BIN (p2), "depay");
fail_if (depay == NULL);
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
pad = gst_element_get_static_pad (depay, "src");
fail_unless (pad != NULL, "Could not get pad out of depay");
gst_object_unref (depay);
2012-01-04 15:41:53 +00:00
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
tag_event_probe_cb, loop, NULL);
gst_element_set_state (p1, GST_STATE_PLAYING);
gst_element_set_state (p2, GST_STATE_PLAYING);
g_main_loop_run (loop);
assert_equals_int (n_tags, 1);
gst_element_set_state (p1, GST_STATE_NULL);
gst_object_unref (p1);
gst_element_set_state (p2, GST_STATE_NULL);
gst_object_unref (p2);
}
GST_END_TEST;
#ifdef HAVE_VORBIS
/* this tests gdp-serialized Vorbis header pages being sent only once
2012-01-19 14:32:52 +00:00
* to clients of multisocketsink; the gdp depayloader should deserialize
* exactly three in_caps buffers for the three header packets */
static int n_in_caps = 0;
2012-01-04 15:41:53 +00:00
static GstPadProbeReturn
buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
2012-01-04 15:41:53 +00:00
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
2012-01-20 15:11:54 +00:00
GstMapInfo map;
2011-03-28 13:51:46 +00:00
2012-01-20 15:11:54 +00:00
gst_buffer_map (buffer, &map, GST_MAP_READ);
2011-03-28 13:51:46 +00:00
2012-01-30 16:16:17 +00:00
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER)) {
GstCaps *caps;
GstStructure *s;
const GValue *sh;
GArray *buffers;
GstBuffer *buf;
int i;
gboolean found = FALSE;
n_in_caps++;
2012-01-04 15:41:53 +00:00
caps = gst_pad_get_current_caps (pad);
s = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_has_field (s, "streamheader"));
sh = gst_structure_get_value (s, "streamheader");
buffers = g_value_peek_pointer (sh);
assert_equals_int (buffers->len, 3);
for (i = 0; i < 3; ++i) {
GValue *val;
2012-01-20 15:11:54 +00:00
GstMapInfo map2;
val = &g_array_index (buffers, GValue, i);
buf = g_value_peek_pointer (val);
fail_unless (GST_IS_BUFFER (buf));
2011-03-28 13:51:46 +00:00
2012-01-20 15:11:54 +00:00
gst_buffer_map (buf, &map2, GST_MAP_READ);
if (map2.size == map.size) {
if (memcmp (map2.data, map.data, map.size) == 0) {
found = TRUE;
}
}
2012-01-20 15:11:54 +00:00
gst_buffer_unmap (buf, &map2);
}
2012-01-30 16:16:17 +00:00
fail_unless (found, "Did not find incoming HEADER buffer %p on caps",
buffer);
gst_caps_unref (caps);
}
2012-01-20 15:11:54 +00:00
gst_buffer_unmap (buffer, &map);
return TRUE;
}
2012-01-19 14:32:52 +00:00
GST_START_TEST (test_multisocketsink_gdp_vorbisenc)
{
GstElement *p1, *p2;
GstElement *src, *sink, *depay;
GstPad *pad;
GMainLoop *loop;
int pfd[2];
2012-01-19 14:32:52 +00:00
GSocket *s[2];
loop = g_main_loop_new (NULL, FALSE);
p1 = gst_parse_launch ("audiotestsrc num-buffers=10 ! audioconvert "
2012-01-19 14:32:52 +00:00
" ! vorbisenc ! gdppay ! multisocketsink name=p1sink", NULL);
fail_if (p1 == NULL);
p2 = gst_parse_launch ("fdsrc name=p2src ! gdpdepay name=depay"
" ! fakesink name=p2sink signal-handoffs=True", NULL);
fail_if (p2 == NULL);
fail_if (pipe (pfd) == -1);
2012-01-19 14:32:52 +00:00
s[0] = g_socket_new_from_fd (pfd[0], NULL);
gst_element_set_state (p1, GST_STATE_READY);
sink = gst_bin_get_by_name (GST_BIN (p1), "p1sink");
2012-01-19 14:32:52 +00:00
g_signal_emit_by_name (sink, "add", s[1], NULL);
gst_object_unref (sink);
src = gst_bin_get_by_name (GST_BIN (p2), "p2src");
g_object_set (G_OBJECT (src), "fd", pfd[0], NULL);
gst_object_unref (src);
depay = gst_bin_get_by_name (GST_BIN (p2), "depay");
fail_if (depay == NULL);
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
pad = gst_element_get_static_pad (depay, "src");
fail_unless (pad != NULL, "Could not get pad out of depay");
gst_object_unref (depay);
2012-01-04 15:41:53 +00:00
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
tag_event_probe_cb, loop, NULL);
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer_probe_cb, NULL,
NULL);
gst_element_set_state (p1, GST_STATE_PLAYING);
gst_element_set_state (p2, GST_STATE_PLAYING);
g_main_loop_run (loop);
assert_equals_int (n_in_caps, 3);
gst_element_set_state (p1, GST_STATE_NULL);
gst_object_unref (p1);
gst_element_set_state (p2, GST_STATE_NULL);
gst_object_unref (p2);
}
GST_END_TEST;
#endif /* HAVE_VORBIS */
#endif /* #ifndef GST_DISABLE_PARSE */
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 Suite *
streamheader_suite (void)
{
Suite *s = suite_create ("streamheader");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
#ifndef GST_DISABLE_PARSE
2012-01-19 14:32:52 +00:00
tcase_add_test (tc_chain, test_multisocketsink_gdp_tag);
#ifdef HAVE_VORBIS
2012-01-19 14:32:52 +00:00
tcase_add_test (tc_chain, test_multisocketsink_gdp_vorbisenc);
#endif
#endif
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = streamheader_suite ();
SRunner *sr = srunner_create (s);
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);
srunner_free (sr);
return nf;
}