2006-04-26 16:44:20 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for videorate
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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 *mysrcpad, *mysinkpad;
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define VIDEO_CAPS_TEMPLATE_STRING \
|
2011-06-16 11:41:25 +00:00
|
|
|
"video/x-raw"
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
#define VIDEO_CAPS_STRING \
|
2011-06-16 11:41:25 +00:00
|
|
|
"video/x-raw, " \
|
2006-04-26 16:44:20 +00:00
|
|
|
"width = (int) 320, " \
|
|
|
|
"height = (int) 240, " \
|
|
|
|
"framerate = (fraction) 25/1 , " \
|
2011-06-16 11:41:25 +00:00
|
|
|
"format = (string) I420"
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
#define VIDEO_CAPS_NO_FRAMERATE_STRING \
|
2011-06-16 11:41:25 +00:00
|
|
|
"video/x-raw, " \
|
2006-04-26 16:44:20 +00:00
|
|
|
"width = (int) 320, " \
|
|
|
|
"height = (int) 240, " \
|
2011-06-16 11:41:25 +00:00
|
|
|
"format = (string) I420"
|
2006-04-26 16:44:20 +00:00
|
|
|
|
2007-04-12 15:00:03 +00:00
|
|
|
#define VIDEO_CAPS_NEWSIZE_STRING \
|
2011-06-16 11:41:25 +00:00
|
|
|
"video/x-raw, " \
|
2007-04-12 15:00:03 +00:00
|
|
|
"width = (int) 240, " \
|
|
|
|
"height = (int) 120, " \
|
|
|
|
"framerate = (fraction) 25/1 , " \
|
2011-06-16 11:41:25 +00:00
|
|
|
"format = (string) I420"
|
2006-04-26 16:44:20 +00:00
|
|
|
|
2010-02-19 21:24:40 +00:00
|
|
|
#define VIDEO_CAPS_UNUSUAL_FRAMERATE \
|
2011-06-16 11:41:25 +00:00
|
|
|
"video/x-raw, " \
|
2010-02-19 21:24:40 +00:00
|
|
|
"width = (int) 240, " \
|
|
|
|
"height = (int) 120, " \
|
|
|
|
"framerate = (fraction) 999/7 , " \
|
2011-06-16 11:41:25 +00:00
|
|
|
"format = (string) I420, " \
|
2010-03-15 09:41:35 +00:00
|
|
|
"color-matrix=(string)sdtv"
|
2010-02-19 21:24:40 +00:00
|
|
|
|
2006-04-26 16:44:20 +00:00
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (VIDEO_CAPS_TEMPLATE_STRING)
|
|
|
|
);
|
2010-02-19 21:24:40 +00:00
|
|
|
static GstStaticPadTemplate downstreamsinktemplate =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (VIDEO_CAPS_STRING)
|
|
|
|
);
|
2006-04-26 16:44:20 +00:00
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (VIDEO_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 void
|
2010-03-15 21:49:53 +00:00
|
|
|
assert_videorate_stats (GstElement * videorate, const gchar * reason,
|
2006-04-26 16:44:20 +00:00
|
|
|
guint64 xin, guint64 xout, guint64 xdropped, guint64 xduplicated)
|
|
|
|
{
|
|
|
|
guint64 in, out, dropped, duplicated;
|
|
|
|
|
|
|
|
g_object_get (videorate, "in", &in, "out", &out, "drop", &dropped,
|
|
|
|
"duplicate", &duplicated, NULL);
|
|
|
|
#define _assert_equals_uint64(a, b) \
|
|
|
|
G_STMT_START { \
|
|
|
|
guint64 first = a; \
|
|
|
|
guint64 second = b; \
|
|
|
|
fail_unless(first == second, \
|
|
|
|
"%s: '" #a "' (%" G_GUINT64_FORMAT ") is not equal to " \
|
|
|
|
"expected '" #a"' (%" G_GUINT64_FORMAT ")", reason, first, second); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
|
|
|
|
_assert_equals_uint64 (in, xin);
|
|
|
|
_assert_equals_uint64 (out, xout);
|
|
|
|
_assert_equals_uint64 (dropped, xdropped);
|
|
|
|
_assert_equals_uint64 (duplicated, xduplicated);
|
|
|
|
}
|
|
|
|
|
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 *
|
2010-02-19 21:24:40 +00:00
|
|
|
setup_videorate_full (GstStaticPadTemplate * srctemplate,
|
|
|
|
GstStaticPadTemplate * sinktemplate)
|
2006-04-26 16:44:20 +00:00
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
|
|
|
|
GST_DEBUG ("setup_videorate");
|
|
|
|
videorate = gst_check_setup_element ("videorate");
|
2010-02-19 21:24:40 +00:00
|
|
|
mysrcpad = gst_check_setup_src_pad (videorate, srctemplate, NULL);
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (videorate, sinktemplate, NULL);
|
2006-04-26 16:44:20 +00:00
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
|
|
|
return videorate;
|
|
|
|
}
|
|
|
|
|
2010-02-19 21:24:40 +00:00
|
|
|
static GstElement *
|
|
|
|
setup_videorate (void)
|
|
|
|
{
|
|
|
|
return setup_videorate_full (&srctemplate, &sinktemplate);
|
|
|
|
}
|
|
|
|
|
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
|
2006-04-26 16:44:20 +00:00
|
|
|
cleanup_videorate (GstElement * videorate)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("cleanup_videorate");
|
|
|
|
|
|
|
|
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
|
|
|
|
g_list_free (buffers);
|
|
|
|
buffers = NULL;
|
|
|
|
|
|
|
|
gst_element_set_state (videorate, GST_STATE_NULL);
|
|
|
|
gst_element_get_state (videorate, NULL, NULL, GST_CLOCK_TIME_NONE);
|
2006-12-21 08:12:26 +00:00
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
2006-04-26 16:44:20 +00:00
|
|
|
gst_check_teardown_src_pad (videorate);
|
|
|
|
gst_check_teardown_sink_pad (videorate);
|
|
|
|
gst_check_teardown_element (videorate);
|
|
|
|
}
|
|
|
|
|
2011-03-28 12:12:24 +00:00
|
|
|
static void
|
|
|
|
buffer_memset (GstBuffer * buffer, gint val, gsize size)
|
|
|
|
{
|
|
|
|
guint8 *data;
|
|
|
|
|
|
|
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
|
|
|
memset (data, val, size);
|
|
|
|
gst_buffer_unmap (buffer, data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint8
|
|
|
|
buffer_get_byte (GstBuffer * buffer, gint offset)
|
|
|
|
{
|
|
|
|
guint8 res;
|
|
|
|
|
|
|
|
gst_buffer_extract (buffer, offset, &res, 1);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2006-04-26 16:44:20 +00:00
|
|
|
GST_START_TEST (test_one)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
2006-09-20 17:04:57 +00:00
|
|
|
GstBuffer *inbuffer;
|
2006-04-26 16:44:20 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
videorate = setup_videorate ();
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (inbuffer, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (inbuffer, caps);
|
2007-05-03 11:24:00 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2006-04-26 16:44:20 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
GST_START_TEST (test_more)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
GstBuffer *first, *second, *third, *outbuffer;
|
|
|
|
GList *l;
|
|
|
|
GstCaps *caps;
|
2007-03-29 11:24:47 +00:00
|
|
|
GRand *rand;
|
2006-04-28 14:49:22 +00:00
|
|
|
|
|
|
|
videorate = setup_videorate ();
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
assert_videorate_stats (videorate, "creation", 0, 0, 0, 0);
|
|
|
|
|
2007-03-29 11:24:47 +00:00
|
|
|
rand = g_rand_new ();
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
/* first buffer */
|
|
|
|
first = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (first) = 0;
|
2007-03-29 11:24:47 +00:00
|
|
|
/* it shouldn't matter what the offsets are, videorate produces perfect
|
|
|
|
streams */
|
|
|
|
GST_BUFFER_OFFSET (first) = g_rand_int (rand);
|
|
|
|
GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (first, 1, 4);
|
2006-04-28 14:49:22 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (first, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
|
|
|
gst_buffer_ref (first);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, first) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 2);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
|
|
|
assert_videorate_stats (videorate, "first buffer", 1, 0, 0, 0);
|
|
|
|
|
|
|
|
/* second buffer; inbetween second and third output frame's timestamp */
|
|
|
|
second = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (second) = GST_SECOND * 3 / 50;
|
2007-03-29 11:24:47 +00:00
|
|
|
GST_BUFFER_OFFSET (first) = g_rand_int (rand);
|
|
|
|
GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (second, 2, 4);
|
2006-04-28 14:49:22 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (second, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
|
|
|
gst_buffer_ref (second);
|
|
|
|
|
|
|
|
/* pushing gives away one of my references ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 2);
|
|
|
|
|
|
|
|
/* ... and the first one is pushed out, with timestamp 0 */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
assert_videorate_stats (videorate, "second buffer", 2, 1, 0, 0);
|
2011-03-28 15:53:39 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
2006-04-28 14:49:22 +00:00
|
|
|
|
|
|
|
outbuffer = buffers->data;
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (outbuffer), 0);
|
|
|
|
|
|
|
|
/* third buffer */
|
|
|
|
third = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (third) = GST_SECOND * 12 / 50;
|
2007-03-29 11:24:47 +00:00
|
|
|
GST_BUFFER_OFFSET (first) = g_rand_int (rand);
|
|
|
|
GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (third, 3, 4);
|
2006-04-28 14:49:22 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (third, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (third, "third", 1);
|
|
|
|
gst_buffer_ref (third);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (third, "third", 2);
|
|
|
|
|
|
|
|
/* submitting the third buffer has triggered flushing of three more frames */
|
|
|
|
assert_videorate_stats (videorate, "third buffer", 3, 4, 0, 2);
|
|
|
|
|
|
|
|
/* check timestamp and source correctness */
|
|
|
|
l = buffers;
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), 0);
|
2011-03-28 12:12:24 +00:00
|
|
|
fail_unless_equals_int (buffer_get_byte (l->data, 0), 1);
|
2007-03-29 11:24:47 +00:00
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 0);
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 1);
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
l = g_list_next (l);
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), GST_SECOND / 25);
|
2011-03-28 12:12:24 +00:00
|
|
|
fail_unless_equals_int (buffer_get_byte (l->data, 0), 2);
|
2007-03-29 11:24:47 +00:00
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 1);
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 2);
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
l = g_list_next (l);
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data),
|
|
|
|
GST_SECOND * 2 / 25);
|
2011-03-28 12:12:24 +00:00
|
|
|
fail_unless_equals_int (buffer_get_byte (l->data, 0), 2);
|
2007-03-29 11:24:47 +00:00
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 2);
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 3);
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
l = g_list_next (l);
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data),
|
|
|
|
GST_SECOND * 3 / 25);
|
2011-03-28 12:12:24 +00:00
|
|
|
fail_unless_equals_int (buffer_get_byte (l->data, 0), 2);
|
2007-03-29 11:24:47 +00:00
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 3);
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 4);
|
2006-04-28 14:49:22 +00:00
|
|
|
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 4);
|
|
|
|
/* one held by us, three held by each output frame taken from the second */
|
2011-03-28 15:53:39 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
2006-04-28 14:49:22 +00:00
|
|
|
|
|
|
|
/* now send EOS */
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
|
|
|
|
/* submitting eos should flush out two more frames for tick 8 and 10 */
|
|
|
|
/* FIXME: right now it only flushes out one, so out is 5 instead of 6 ! */
|
|
|
|
assert_videorate_stats (videorate, "eos", 3, 5, 0, 2);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 5);
|
|
|
|
|
|
|
|
/* cleanup */
|
2007-03-29 11:24:47 +00:00
|
|
|
g_rand_free (rand);
|
2006-04-28 14:49:22 +00:00
|
|
|
gst_buffer_unref (first);
|
|
|
|
gst_buffer_unref (second);
|
|
|
|
gst_buffer_unref (third);
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-04-26 16:44:20 +00:00
|
|
|
/* frames at 1, 0, 2 -> second one should be ignored */
|
|
|
|
GST_START_TEST (test_wrong_order_from_zero)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
GstBuffer *first, *second, *third, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
videorate = setup_videorate ();
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
assert_videorate_stats (videorate, "start", 0, 0, 0, 0);
|
|
|
|
|
|
|
|
/* first buffer */
|
|
|
|
first = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (first) = GST_SECOND;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (first, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (first, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
|
|
|
gst_buffer_ref (first);
|
|
|
|
|
|
|
|
GST_DEBUG ("pushing first buffer");
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, first) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 2);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
2006-04-28 14:49:22 +00:00
|
|
|
assert_videorate_stats (videorate, "first", 1, 0, 0, 0);
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
/* second buffer */
|
|
|
|
second = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (second) = 0;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (second, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (second, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
|
|
|
gst_buffer_ref (second);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
|
2006-04-28 14:49:22 +00:00
|
|
|
/* ... and it is now dropped because it is too old */
|
2006-04-26 16:44:20 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
/* ... and the first one is still there */
|
|
|
|
assert_videorate_stats (videorate, "second", 2, 0, 1, 0);
|
2006-04-26 16:44:20 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 2);
|
|
|
|
|
|
|
|
/* third buffer */
|
|
|
|
third = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (third, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (third, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (third, "third", 1);
|
|
|
|
gst_buffer_ref (third);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (third, "third", 2);
|
|
|
|
|
|
|
|
/* and now the first one should be pushed once and dupped 24 + 13 times, to
|
|
|
|
* reach the half point between 1 s (first) and 2 s (third) */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 38);
|
2011-03-28 15:53:39 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
2006-04-26 16:44:20 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (third, "third", 2);
|
2006-04-28 14:49:22 +00:00
|
|
|
assert_videorate_stats (videorate, "third", 3, 38, 1, 37);
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
/* verify last buffer */
|
|
|
|
outbuffer = g_list_last (buffers)->data;
|
|
|
|
fail_unless (GST_IS_BUFFER (outbuffer));
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (outbuffer),
|
|
|
|
GST_SECOND * 37 / 25);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
gst_buffer_unref (first);
|
|
|
|
gst_buffer_unref (second);
|
|
|
|
gst_buffer_unref (third);
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* send frames with 0, 1, 2, 0 seconds */
|
|
|
|
GST_START_TEST (test_wrong_order)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
GstBuffer *first, *second, *third, *fourth, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
videorate = setup_videorate ();
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
assert_videorate_stats (videorate, "start", 0, 0, 0, 0);
|
|
|
|
|
|
|
|
/* first buffer */
|
|
|
|
first = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (first) = 0;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (first, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (first, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
|
|
|
gst_buffer_ref (first);
|
|
|
|
|
|
|
|
GST_DEBUG ("pushing first buffer");
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, first) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 2);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
2006-04-28 14:49:22 +00:00
|
|
|
assert_videorate_stats (videorate, "first", 1, 0, 0, 0);
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
/* second buffer */
|
|
|
|
second = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (second) = GST_SECOND;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (second, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (second, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
|
|
|
gst_buffer_ref (second);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 2);
|
|
|
|
/* and it created 13 output buffers as copies of the first frame */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 13);
|
2006-04-28 14:49:22 +00:00
|
|
|
assert_videorate_stats (videorate, "second", 2, 13, 0, 12);
|
2011-03-28 15:53:39 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
/* third buffer */
|
|
|
|
third = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (third, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (third, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (third, "third", 1);
|
|
|
|
gst_buffer_ref (third);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK);
|
|
|
|
/* ... and it is now stuck inside videorate */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (third, "third", 2);
|
|
|
|
|
|
|
|
/* submitting a frame with 2 seconds triggers output of 25 more frames */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 38);
|
2011-03-28 15:53:39 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
2006-04-26 16:44:20 +00:00
|
|
|
/* three frames submitted; two of them output as is, and 36 duplicated */
|
2006-04-28 14:49:22 +00:00
|
|
|
assert_videorate_stats (videorate, "third", 3, 38, 0, 36);
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
/* fourth buffer */
|
|
|
|
fourth = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (fourth) = 0;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (fourth, 0, 4);
|
2006-04-26 16:44:20 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (fourth, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (fourth, "fourth", 1);
|
|
|
|
gst_buffer_ref (fourth);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, fourth) == GST_FLOW_OK);
|
2006-04-28 14:49:22 +00:00
|
|
|
/* ... and it is dropped */
|
2006-04-26 16:44:20 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (fourth, "fourth", 1);
|
|
|
|
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 38);
|
2011-03-28 15:53:39 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
2006-04-28 14:49:22 +00:00
|
|
|
assert_videorate_stats (videorate, "fourth", 4, 38, 1, 36);
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
/* verify last buffer */
|
|
|
|
outbuffer = g_list_last (buffers)->data;
|
|
|
|
fail_unless (GST_IS_BUFFER (outbuffer));
|
|
|
|
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (outbuffer),
|
|
|
|
GST_SECOND * 37 / 25);
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
|
2006-04-26 16:44:20 +00:00
|
|
|
/* cleanup */
|
|
|
|
gst_buffer_unref (first);
|
|
|
|
gst_buffer_unref (second);
|
|
|
|
gst_buffer_unref (third);
|
|
|
|
gst_buffer_unref (fourth);
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-04-28 14:49:22 +00:00
|
|
|
|
|
|
|
/* if no framerate is negotiated, we should not be able to push a buffer */
|
|
|
|
GST_START_TEST (test_no_framerate)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
2006-09-20 17:04:57 +00:00
|
|
|
GstBuffer *inbuffer;
|
2006-04-28 14:49:22 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
videorate = setup_videorate ();
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (inbuffer, 0, 4);
|
2006-04-28 14:49:22 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_NO_FRAMERATE_STRING);
|
|
|
|
gst_buffer_set_caps (inbuffer, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* take a ref so we can later check refcount */
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
|
|
|
|
/* no framerate is negotiated so pushing should fail */
|
|
|
|
fail_if (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
gst_buffer_unref (inbuffer);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-04-12 15:00:03 +00:00
|
|
|
/* This test outputs 2 buffers of same dimensions (320x240), then 1 buffer of
|
|
|
|
* differing dimensions (240x120), and then another buffer of previous
|
|
|
|
* dimensions (320x240) and checks that the 3 buffers output as a result have
|
|
|
|
* correct caps (first 2 with 320x240 and 3rd with 240x120).
|
|
|
|
*/
|
|
|
|
GST_START_TEST (test_changing_size)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
GstBuffer *first;
|
|
|
|
GstBuffer *second;
|
|
|
|
GstBuffer *third;
|
|
|
|
GstBuffer *fourth;
|
|
|
|
GstBuffer *fifth;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
GstEvent *newsegment;
|
|
|
|
GstCaps *caps, *caps_newsize;
|
|
|
|
|
|
|
|
videorate = setup_videorate ();
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
newsegment = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1,
|
|
|
|
0);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, newsegment) == TRUE);
|
|
|
|
|
|
|
|
first = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (first, 0, 4);
|
2007-04-12 15:00:03 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
GST_BUFFER_TIMESTAMP (first) = 0;
|
|
|
|
gst_buffer_set_caps (first, caps);
|
|
|
|
|
|
|
|
GST_DEBUG ("pushing first buffer");
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, first) == GST_FLOW_OK);
|
|
|
|
|
|
|
|
/* second buffer */
|
|
|
|
second = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (second) = GST_SECOND / 25;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (second, 0, 4);
|
2007-04-12 15:00:03 +00:00
|
|
|
gst_buffer_set_caps (second, caps);
|
2006-04-28 14:49:22 +00:00
|
|
|
|
2007-04-12 15:00:03 +00:00
|
|
|
fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
outbuf = buffers->data;
|
|
|
|
/* first buffer should be output here */
|
|
|
|
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps));
|
|
|
|
fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 0);
|
|
|
|
|
|
|
|
/* third buffer with new size */
|
|
|
|
third = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND / 25;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (third, 0, 4);
|
2007-04-12 15:00:03 +00:00
|
|
|
caps_newsize = gst_caps_from_string (VIDEO_CAPS_NEWSIZE_STRING);
|
|
|
|
gst_buffer_set_caps (third, caps_newsize);
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK);
|
|
|
|
/* new caps flushed the internal state, no new output yet */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
outbuf = g_list_last (buffers)->data;
|
|
|
|
/* first buffer should be output here */
|
|
|
|
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps));
|
|
|
|
fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 0);
|
|
|
|
|
|
|
|
/* fourth buffer with original size */
|
|
|
|
fourth = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (fourth) = 3 * GST_SECOND / 25;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (fourth, 0, 4);
|
2007-04-12 15:00:03 +00:00
|
|
|
gst_buffer_set_caps (fourth, caps);
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, fourth) == GST_FLOW_OK);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
|
|
|
|
/* fifth buffer with original size */
|
|
|
|
fifth = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (fifth) = 4 * GST_SECOND / 25;
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (fifth, 0, 4);
|
2007-04-12 15:00:03 +00:00
|
|
|
gst_buffer_set_caps (fifth, caps);
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, fifth) == GST_FLOW_OK);
|
|
|
|
/* all four missing buffers here, dups of fourth buffer */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 4);
|
|
|
|
outbuf = g_list_last (buffers)->data;
|
|
|
|
/* third buffer should be output here */
|
|
|
|
fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 3 * GST_SECOND / 25);
|
|
|
|
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps));
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
gst_caps_unref (caps_newsize);
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2007-04-24 15:00:07 +00:00
|
|
|
|
|
|
|
GST_START_TEST (test_non_ok_flow)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
GstClockTime ts;
|
|
|
|
GstBuffer *buf;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
videorate = setup_videorate ();
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
buf = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
buffer_memset (buf, 0, 4);
|
2007-04-24 15:00:07 +00:00
|
|
|
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
|
|
|
gst_buffer_set_caps (buf, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buf, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* push a few 'normal' buffers */
|
|
|
|
for (ts = 0; ts < 100 * GST_SECOND; ts += GST_SECOND / 33) {
|
|
|
|
GstBuffer *inbuf;
|
|
|
|
|
|
|
|
inbuf = gst_buffer_copy (buf);
|
|
|
|
GST_BUFFER_TIMESTAMP (inbuf) = ts;
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuf), GST_FLOW_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we should have buffers according to the output framerate of 25/1 */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 100 * 25);
|
|
|
|
|
|
|
|
/* now deactivate pad so we get a WRONG_STATE flow return */
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
|
|
|
|
|
|
|
/* push buffer on deactivated pad */
|
2011-03-28 12:12:24 +00:00
|
|
|
fail_unless (gst_buffer_is_writable (buf));
|
2007-04-24 15:00:07 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buf) = ts;
|
|
|
|
|
|
|
|
/* pushing gives away our reference */
|
|
|
|
fail_unless_equals_int (gst_pad_push (mysrcpad, buf), GST_FLOW_WRONG_STATE);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-02-19 21:24:40 +00:00
|
|
|
GST_START_TEST (test_upstream_caps_nego)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
GstPad *videorate_pad;
|
|
|
|
GstCaps *expected_caps;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
videorate = setup_videorate_full (&srctemplate, &downstreamsinktemplate);
|
|
|
|
fail_unless (gst_element_set_state (videorate,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2010-03-10 00:41:13 +00:00
|
|
|
videorate_pad = gst_element_get_static_pad (videorate, "sink");
|
2010-02-19 21:24:40 +00:00
|
|
|
caps = gst_pad_get_caps (videorate_pad);
|
|
|
|
|
|
|
|
/* assemble the expected caps */
|
|
|
|
structure = gst_structure_from_string (VIDEO_CAPS_STRING, NULL);
|
|
|
|
expected_caps = gst_caps_new_empty ();
|
|
|
|
gst_caps_append_structure (expected_caps, structure);
|
|
|
|
structure = gst_structure_copy (structure);
|
|
|
|
gst_structure_set (structure, "framerate", GST_TYPE_FRACTION_RANGE,
|
|
|
|
0, 1, G_MAXINT, 1, NULL);
|
|
|
|
gst_caps_append_structure (expected_caps, structure);
|
|
|
|
|
|
|
|
fail_unless (gst_caps_is_equal (expected_caps, caps));
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
gst_caps_unref (expected_caps);
|
|
|
|
gst_object_unref (videorate_pad);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_videorate (videorate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
GST_START_TEST (test_selected_caps)
|
|
|
|
{
|
|
|
|
GstElement *videorate;
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *msg;
|
|
|
|
|
2010-03-10 00:42:15 +00:00
|
|
|
pipeline = gst_parse_launch ("videotestsrc num-buffers=1"
|
|
|
|
" ! identity ! videorate name=videorate0 ! " VIDEO_CAPS_UNUSUAL_FRAMERATE
|
2010-02-19 21:24:40 +00:00
|
|
|
" ! fakesink", NULL);
|
|
|
|
fail_if (pipeline == NULL);
|
|
|
|
videorate = gst_bin_get_by_name (GST_BIN (pipeline), "videorate0");
|
|
|
|
fail_if (videorate == NULL);
|
|
|
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
|
|
|
|
|
|
fail_if (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
|
|
|
|
GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
|
|
|
|
fail_if (msg == NULL || GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
|
2010-03-16 01:08:48 +00:00
|
|
|
/* make sure upstream nego works right and videotestsrc has selected the
|
|
|
|
* caps we want downstream of videorate */
|
|
|
|
{
|
|
|
|
GstStructure *s;
|
|
|
|
const GValue *val;
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
GstPad *videorate_pad;
|
|
|
|
|
|
|
|
videorate_pad = gst_element_get_static_pad (videorate, "sink");
|
|
|
|
g_object_get (videorate_pad, "caps", &caps, NULL);
|
|
|
|
fail_unless (caps != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("negotiated caps: %" GST_PTR_FORMAT, caps);
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
val = gst_structure_get_value (s, "framerate");
|
|
|
|
fail_unless (val != NULL, "no framerate field in negotiated caps");
|
|
|
|
fail_unless (GST_VALUE_HOLDS_FRACTION (val));
|
|
|
|
fail_unless_equals_int (gst_value_get_fraction_numerator (val), 999);
|
|
|
|
fail_unless_equals_int (gst_value_get_fraction_denominator (val), 7);
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
gst_object_unref (videorate_pad);
|
|
|
|
}
|
2010-02-19 21:24:40 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
gst_object_unref (bus);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
2010-03-16 01:08:48 +00:00
|
|
|
gst_object_unref (videorate);
|
2010-02-19 21:24:40 +00:00
|
|
|
gst_object_unref (pipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-04-24 15:00:07 +00:00
|
|
|
static Suite *
|
2006-04-26 16:44:20 +00:00
|
|
|
videorate_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("videorate");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
2006-04-28 14:49:22 +00:00
|
|
|
tcase_add_test (tc_chain, test_one);
|
|
|
|
tcase_add_test (tc_chain, test_more);
|
2006-04-26 16:44:20 +00:00
|
|
|
tcase_add_test (tc_chain, test_wrong_order_from_zero);
|
|
|
|
tcase_add_test (tc_chain, test_wrong_order);
|
2006-04-28 14:49:22 +00:00
|
|
|
tcase_add_test (tc_chain, test_no_framerate);
|
2007-04-12 15:00:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_changing_size);
|
2007-04-24 15:00:07 +00:00
|
|
|
tcase_add_test (tc_chain, test_non_ok_flow);
|
2010-02-19 21:24:40 +00:00
|
|
|
tcase_add_test (tc_chain, test_upstream_caps_nego);
|
|
|
|
tcase_add_test (tc_chain, test_selected_caps);
|
2006-04-26 16:44:20 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2007-04-24 15:00:07 +00:00
|
|
|
GST_CHECK_MAIN (videorate)
|