2005-08-25 15:44:58 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
2009-01-23 11:46:28 +00:00
|
|
|
* unit test for legacyresample
|
2005-08-25 15:44:58 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
|
2006-06-16 15:43:23 +00:00
|
|
|
* Copyright (C) <2006> Tim-Philipp Müller <tim at centricular net>
|
2005-08-25 15:44:58 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2012-02-07 11:14:05 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
/* 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:02 +00:00
|
|
|
static GstPad *mysrcpad, *mysinkpad;
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
#define RESAMPLE_CAPS_TEMPLATE_STRING \
|
2012-02-07 11:14:05 +00:00
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) " GST_AUDIO_NE (S16) ", " \
|
2005-12-06 19:42:02 +00:00
|
|
|
"channels = (int) [ 1, MAX ], " \
|
2012-02-07 11:14:05 +00:00
|
|
|
"rate = (int) [ 1, MAX ]"
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (RESAMPLE_CAPS_TEMPLATE_STRING)
|
|
|
|
);
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (RESAMPLE_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:02 +00:00
|
|
|
static GstElement *
|
2009-01-23 11:46:28 +00:00
|
|
|
setup_legacyresample (int channels, int inrate, int outrate)
|
2005-08-25 15:44:58 +00:00
|
|
|
{
|
2009-01-23 11:46:28 +00:00
|
|
|
GstElement *legacyresample;
|
2005-08-25 15:44:58 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
GST_DEBUG ("setup_legacyresample");
|
|
|
|
legacyresample = gst_check_setup_element ("legacyresample");
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2005-08-25 16:19:39 +00:00
|
|
|
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
|
2005-08-25 15:44:58 +00:00
|
|
|
"rate", G_TYPE_INT, inrate, NULL);
|
|
|
|
fail_unless (gst_caps_is_fixed (caps));
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2006-06-16 15:17:44 +00:00
|
|
|
GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to paused");
|
|
|
|
|
2011-11-24 20:42:39 +00:00
|
|
|
mysrcpad = gst_check_setup_src_pad (legacyresample, &srctemplate);
|
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
2005-08-25 15:44:58 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2005-08-25 16:19:39 +00:00
|
|
|
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
|
2005-08-25 15:44:58 +00:00
|
|
|
"rate", G_TYPE_INT, outrate, NULL);
|
|
|
|
fail_unless (gst_caps_is_fixed (caps));
|
|
|
|
|
2011-11-24 20:42:39 +00:00
|
|
|
mysinkpad = gst_check_setup_sink_pad (legacyresample, &sinktemplate);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
2005-08-25 15:44:58 +00:00
|
|
|
/* this installs a getcaps func that will always return the caps we set
|
|
|
|
* later */
|
2011-11-24 20:42:39 +00:00
|
|
|
fail_unless (gst_pad_set_caps (mysinkpad, caps));
|
2005-08-25 15:44:58 +00:00
|
|
|
gst_pad_use_fixed_caps (mysinkpad);
|
2009-03-06 19:02:21 +00:00
|
|
|
gst_caps_unref (caps);
|
2008-09-01 16:05:45 +00:00
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
return legacyresample;
|
2005-08-25 15:44:58 +00:00
|
|
|
}
|
|
|
|
|
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:02 +00:00
|
|
|
static void
|
2009-01-23 11:46:28 +00:00
|
|
|
cleanup_legacyresample (GstElement * legacyresample)
|
2005-08-25 15:44:58 +00:00
|
|
|
{
|
2009-01-23 11:46:28 +00:00
|
|
|
GST_DEBUG ("cleanup_legacyresample");
|
2005-08-25 15:44:58 +00:00
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2006-06-16 15:17:44 +00:00
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to NULL");
|
|
|
|
|
2006-12-21 08:12:26 +00:00
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
2009-01-23 11:46:28 +00:00
|
|
|
gst_check_teardown_src_pad (legacyresample);
|
|
|
|
gst_check_teardown_sink_pad (legacyresample);
|
|
|
|
gst_check_teardown_element (legacyresample);
|
2005-08-25 15:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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:02 +00:00
|
|
|
fail_unless_perfect_stream (void)
|
2005-08-25 15:44:58 +00:00
|
|
|
{
|
|
|
|
guint64 timestamp = 0L, duration = 0L;
|
|
|
|
guint64 offset = 0L, offset_end = 0L;
|
|
|
|
|
|
|
|
GList *l;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
|
|
|
for (l = buffers; l; l = l->next) {
|
|
|
|
buffer = GST_BUFFER (l->data);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
GST_DEBUG ("buffer timestamp %" G_GUINT64_FORMAT ", duration %"
|
2008-09-01 16:05:45 +00:00
|
|
|
G_GUINT64_FORMAT " offset %" G_GUINT64_FORMAT " offset_end %"
|
|
|
|
G_GUINT64_FORMAT,
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer),
|
|
|
|
GST_BUFFER_DURATION (buffer),
|
|
|
|
GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET_END (buffer));
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
fail_unless_equals_uint64 (timestamp, GST_BUFFER_TIMESTAMP (buffer));
|
|
|
|
fail_unless_equals_uint64 (offset, GST_BUFFER_OFFSET (buffer));
|
|
|
|
duration = GST_BUFFER_DURATION (buffer);
|
|
|
|
offset_end = GST_BUFFER_OFFSET_END (buffer);
|
|
|
|
|
|
|
|
timestamp += duration;
|
|
|
|
offset = offset_end;
|
2005-08-25 16:19:39 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2005-08-25 15:44:58 +00:00
|
|
|
}
|
2005-08-25 16:19:39 +00:00
|
|
|
g_list_free (buffers);
|
|
|
|
buffers = NULL;
|
2005-08-25 15:44:58 +00:00
|
|
|
}
|
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
/* this tests that the output is a perfect stream if the input is */
|
2005-08-25 15:44:58 +00:00
|
|
|
static void
|
|
|
|
test_perfect_stream_instance (int inrate, int outrate, int samples,
|
|
|
|
int numbuffers)
|
|
|
|
{
|
2009-01-23 11:46:28 +00:00
|
|
|
GstElement *legacyresample;
|
2005-08-25 15:44:58 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
2008-09-01 16:05:45 +00:00
|
|
|
guint64 offset = 0;
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
int i, j;
|
|
|
|
gint16 *p;
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
legacyresample = setup_legacyresample (2, inrate, outrate);
|
2012-02-07 11:14:05 +00:00
|
|
|
caps = gst_pad_get_current_caps (mysrcpad);
|
2005-08-25 15:44:58 +00:00
|
|
|
fail_unless (gst_caps_is_fixed (caps));
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2005-09-02 15:43:14 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
for (j = 1; j <= numbuffers; ++j) {
|
2012-02-07 11:14:05 +00:00
|
|
|
GstMapInfo map;
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (samples * 4);
|
|
|
|
GST_BUFFER_DURATION (inbuffer) = samples * GST_SECOND / inrate;
|
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = GST_BUFFER_DURATION (inbuffer) * (j - 1);
|
2008-09-01 16:05:45 +00:00
|
|
|
GST_BUFFER_OFFSET (inbuffer) = offset;
|
|
|
|
offset += samples;
|
|
|
|
GST_BUFFER_OFFSET_END (inbuffer) = offset;
|
2005-08-25 15:44:58 +00:00
|
|
|
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
|
|
|
p = (gint16 *) map.data;
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
/* create a 16 bit signed ramp */
|
|
|
|
for (i = 0; i < samples; ++i) {
|
|
|
|
*p = -32767 + i * (65535 / samples);
|
|
|
|
++p;
|
|
|
|
*p = -32767 + i * (65535 / samples);
|
|
|
|
++p;
|
|
|
|
}
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_buffer_unmap (inbuffer, &map);
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
2005-08-25 16:19:39 +00:00
|
|
|
fail_unless_equals_int (g_list_length (buffers), j);
|
2005-08-25 15:44:58 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
/* FIXME: we should make legacyresample handle eos by flushing out the last
|
2005-08-25 15:44:58 +00:00
|
|
|
* samples, which will give us one more, small, buffer */
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
|
|
|
|
|
|
|
fail_unless_perfect_stream ();
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
gst_caps_unref (caps);
|
2009-01-23 11:46:28 +00:00
|
|
|
cleanup_legacyresample (legacyresample);
|
2005-08-25 15:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* make sure that outgoing buffers are contiguous in timestamp/duration and
|
|
|
|
* offset/offsetend
|
|
|
|
*/
|
|
|
|
GST_START_TEST (test_perfect_stream)
|
|
|
|
{
|
2005-08-25 16:19:39 +00:00
|
|
|
/* integral scalings */
|
|
|
|
test_perfect_stream_instance (48000, 24000, 500, 20);
|
|
|
|
test_perfect_stream_instance (48000, 12000, 500, 20);
|
|
|
|
test_perfect_stream_instance (12000, 24000, 500, 20);
|
|
|
|
test_perfect_stream_instance (12000, 48000, 500, 20);
|
|
|
|
|
|
|
|
/* non-integral scalings */
|
|
|
|
test_perfect_stream_instance (44100, 8000, 500, 20);
|
|
|
|
test_perfect_stream_instance (8000, 44100, 500, 20);
|
|
|
|
|
|
|
|
/* wacky scalings */
|
|
|
|
test_perfect_stream_instance (12345, 54321, 500, 20);
|
|
|
|
test_perfect_stream_instance (101, 99, 500, 20);
|
2005-08-25 15:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
/* this tests that the output is a correct discontinuous stream
|
|
|
|
* if the input is; ie input drops in time come out the same way */
|
|
|
|
static void
|
|
|
|
test_discont_stream_instance (int inrate, int outrate, int samples,
|
|
|
|
int numbuffers)
|
|
|
|
{
|
2009-01-23 11:46:28 +00:00
|
|
|
GstElement *legacyresample;
|
2007-03-14 17:16:30 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstClockTime ints;
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
gint16 *p;
|
|
|
|
|
2008-09-01 16:05:45 +00:00
|
|
|
GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
|
|
|
|
inrate, outrate, samples, numbuffers);
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
legacyresample = setup_legacyresample (2, inrate, outrate);
|
2012-02-07 11:14:05 +00:00
|
|
|
caps = gst_pad_get_current_caps (mysrcpad);
|
2007-03-14 17:16:30 +00:00
|
|
|
fail_unless (gst_caps_is_fixed (caps));
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2007-03-14 17:16:30 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
for (j = 1; j <= numbuffers; ++j) {
|
2012-02-07 11:14:05 +00:00
|
|
|
GstMapInfo map;
|
2007-03-14 17:16:30 +00:00
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (samples * 4);
|
|
|
|
GST_BUFFER_DURATION (inbuffer) = samples * GST_SECOND / inrate;
|
|
|
|
/* "drop" half the buffers */
|
|
|
|
ints = GST_BUFFER_DURATION (inbuffer) * 2 * (j - 1);
|
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = ints;
|
|
|
|
GST_BUFFER_OFFSET (inbuffer) = (j - 1) * 2 * samples;
|
|
|
|
GST_BUFFER_OFFSET_END (inbuffer) = j * 2 * samples + samples;
|
|
|
|
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
|
|
|
p = (gint16 *) map.data;
|
2007-03-14 17:16:30 +00:00
|
|
|
|
|
|
|
/* create a 16 bit signed ramp */
|
|
|
|
for (i = 0; i < samples; ++i) {
|
|
|
|
*p = -32767 + i * (65535 / samples);
|
|
|
|
++p;
|
|
|
|
*p = -32767 + i * (65535 / samples);
|
|
|
|
++p;
|
|
|
|
}
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_buffer_unmap (inbuffer, &map);
|
2007-03-14 17:16:30 +00:00
|
|
|
|
2008-09-01 16:05:45 +00:00
|
|
|
GST_DEBUG ("Sending Buffer time:%" G_GUINT64_FORMAT " duration:%"
|
|
|
|
G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
|
|
|
|
G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (inbuffer),
|
|
|
|
GST_BUFFER_DURATION (inbuffer), GST_BUFFER_IS_DISCONT (inbuffer),
|
|
|
|
GST_BUFFER_OFFSET (inbuffer), GST_BUFFER_OFFSET_END (inbuffer));
|
2007-03-14 17:16:30 +00:00
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
|
|
|
|
/* check if the timestamp of the pushed buffer matches the incoming one */
|
|
|
|
outbuffer = g_list_nth_data (buffers, g_list_length (buffers) - 1);
|
|
|
|
fail_if (outbuffer == NULL);
|
|
|
|
fail_unless_equals_uint64 (ints, GST_BUFFER_TIMESTAMP (outbuffer));
|
2008-09-01 16:05:45 +00:00
|
|
|
GST_DEBUG ("Got Buffer time:%" G_GUINT64_FORMAT " duration:%"
|
|
|
|
G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
|
|
|
|
G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (outbuffer),
|
|
|
|
GST_BUFFER_DURATION (outbuffer), GST_BUFFER_IS_DISCONT (outbuffer),
|
|
|
|
GST_BUFFER_OFFSET (outbuffer), GST_BUFFER_OFFSET_END (outbuffer));
|
2007-03-14 17:16:30 +00:00
|
|
|
if (j > 1) {
|
|
|
|
fail_unless (GST_BUFFER_IS_DISCONT (outbuffer),
|
2008-09-01 16:05:45 +00:00
|
|
|
"expected discont for buffer #%d", j);
|
2007-03-14 17:16:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
gst_caps_unref (caps);
|
2009-01-23 11:46:28 +00:00
|
|
|
cleanup_legacyresample (legacyresample);
|
2007-03-14 17:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_discont_stream)
|
|
|
|
{
|
|
|
|
/* integral scalings */
|
|
|
|
test_discont_stream_instance (48000, 24000, 500, 20);
|
|
|
|
test_discont_stream_instance (48000, 12000, 500, 20);
|
|
|
|
test_discont_stream_instance (12000, 24000, 500, 20);
|
|
|
|
test_discont_stream_instance (12000, 48000, 500, 20);
|
|
|
|
|
|
|
|
/* non-integral scalings */
|
|
|
|
test_discont_stream_instance (44100, 8000, 500, 20);
|
|
|
|
test_discont_stream_instance (8000, 44100, 500, 20);
|
|
|
|
|
|
|
|
/* wacky scalings */
|
|
|
|
test_discont_stream_instance (12345, 54321, 500, 20);
|
|
|
|
test_discont_stream_instance (101, 99, 500, 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-16 15:43:23 +00:00
|
|
|
GST_START_TEST (test_reuse)
|
|
|
|
{
|
2009-01-23 11:46:28 +00:00
|
|
|
GstElement *legacyresample;
|
2006-06-16 15:43:23 +00:00
|
|
|
GstEvent *newseg;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstCaps *caps;
|
2012-02-07 11:14:05 +00:00
|
|
|
GstSegment seg;
|
2006-06-16 15:43:23 +00:00
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
legacyresample = setup_legacyresample (1, 9343, 48000);
|
2012-02-07 11:14:05 +00:00
|
|
|
caps = gst_pad_get_current_caps (mysrcpad);
|
2006-06-16 15:43:23 +00:00
|
|
|
fail_unless (gst_caps_is_fixed (caps));
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2006-06-16 15:43:23 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_segment_init (&seg, GST_FORMAT_TIME);
|
|
|
|
newseg = gst_event_new_segment (&seg);
|
2006-06-16 15:43:23 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_buffer_memset (inbuffer, 0, 0, -1);
|
2006-06-16 15:43:23 +00:00
|
|
|
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
|
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
|
|
|
GST_BUFFER_OFFSET (inbuffer) = 0;
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
|
|
|
|
/* now reset and try again ... */
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2006-06-16 15:43:23 +00:00
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to NULL");
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2006-06-16 15:43:23 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_segment_init (&seg, GST_FORMAT_TIME);
|
|
|
|
newseg = gst_event_new_segment (&seg);
|
2006-06-16 15:43:23 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_buffer_memset (inbuffer, 0, 0, -1);
|
2006-06-16 15:43:23 +00:00
|
|
|
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
|
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
|
|
|
GST_BUFFER_OFFSET (inbuffer) = 0;
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
|
|
|
|
/* ... it also ends up being collected on the global buffer list. If we
|
2009-01-23 11:46:28 +00:00
|
|
|
* now have more than 2 buffers, then legacyresample probably didn't clean
|
2006-06-16 15:43:23 +00:00
|
|
|
* up its internal buffer properly and tried to push the remaining samples
|
|
|
|
* when it got the second NEWSEGMENT event */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 2);
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
cleanup_legacyresample (legacyresample);
|
2006-06-16 15:43:23 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-04-21 13:54:39 +00:00
|
|
|
GST_START_TEST (test_shutdown)
|
|
|
|
{
|
|
|
|
GstElement *pipeline, *src, *cf1, *ar, *cf2, *sink;
|
|
|
|
GstCaps *caps;
|
|
|
|
guint i;
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
/* create pipeline, force legacyresample to actually resample */
|
2007-04-21 13:54:39 +00:00
|
|
|
pipeline = gst_pipeline_new (NULL);
|
|
|
|
|
|
|
|
src = gst_check_setup_element ("audiotestsrc");
|
|
|
|
cf1 = gst_check_setup_element ("capsfilter");
|
2008-11-27 16:58:31 +00:00
|
|
|
ar = gst_check_setup_element ("legacyresample");
|
2007-04-21 13:54:39 +00:00
|
|
|
cf2 = gst_check_setup_element ("capsfilter");
|
|
|
|
g_object_set (cf2, "name", "capsfilter2", NULL);
|
|
|
|
sink = gst_check_setup_element ("fakesink");
|
|
|
|
|
|
|
|
caps =
|
|
|
|
gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, 11025, NULL);
|
|
|
|
g_object_set (cf1, "caps", caps, NULL);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
caps =
|
|
|
|
gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, 48000, NULL);
|
|
|
|
g_object_set (cf2, "caps", caps, NULL);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
/* don't want to sync against the clock, the more throughput the better */
|
|
|
|
g_object_set (src, "is-live", FALSE, NULL);
|
|
|
|
g_object_set (sink, "sync", FALSE, NULL);
|
|
|
|
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, cf1, ar, cf2, sink, NULL);
|
|
|
|
fail_if (!gst_element_link_many (src, cf1, ar, cf2, sink, NULL));
|
|
|
|
|
|
|
|
/* now, wait until pipeline is running and then shut it down again; repeat */
|
|
|
|
for (i = 0; i < 20; ++i) {
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
|
|
gst_element_get_state (pipeline, NULL, NULL, -1);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
g_usleep (100);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
}
|
|
|
|
|
2008-05-08 06:20:42 +00:00
|
|
|
GST_END_TEST;
|
|
|
|
|
2012-02-07 11:14:05 +00:00
|
|
|
#if 0
|
2008-05-08 06:20:42 +00:00
|
|
|
static GstFlowReturn
|
2008-05-13 10:59:49 +00:00
|
|
|
live_switch_alloc_only_48000 (GstPad * pad, guint64 offset,
|
|
|
|
guint size, GstCaps * caps, GstBuffer ** buf)
|
2008-05-08 06:20:42 +00:00
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
gint rate;
|
2008-05-13 10:59:49 +00:00
|
|
|
gint channels;
|
|
|
|
GstCaps *desired;
|
2008-05-08 06:20:42 +00:00
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
fail_unless (gst_structure_get_int (structure, "rate", &rate));
|
2008-05-13 10:59:49 +00:00
|
|
|
fail_unless (gst_structure_get_int (structure, "channels", &channels));
|
2008-05-08 06:20:42 +00:00
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
if (rate < 48000)
|
2008-05-08 06:20:42 +00:00
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
desired = gst_caps_copy (caps);
|
|
|
|
gst_caps_set_simple (desired, "rate", G_TYPE_INT, 48000, NULL);
|
|
|
|
|
|
|
|
*buf = gst_buffer_new_and_alloc (channels * 48000);
|
|
|
|
gst_buffer_set_caps (*buf, desired);
|
|
|
|
gst_caps_unref (desired);
|
|
|
|
|
2008-05-08 06:20:42 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
static GstCaps *
|
|
|
|
live_switch_get_sink_caps (GstPad * pad)
|
2008-05-08 06:20:42 +00:00
|
|
|
{
|
2008-05-13 10:59:49 +00:00
|
|
|
GstCaps *result;
|
2008-05-08 06:20:42 +00:00
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
result = gst_caps_copy (GST_PAD_CAPS (pad));
|
2008-05-08 06:20:42 +00:00
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
gst_caps_set_simple (result,
|
|
|
|
"rate", GST_TYPE_INT_RANGE, 48000, G_MAXINT, NULL);
|
2008-05-08 06:20:42 +00:00
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
2008-05-08 06:20:42 +00:00
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
static void
|
|
|
|
live_switch_push (int rate, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstCaps *desired;
|
|
|
|
GList *l;
|
2008-05-08 06:20:42 +00:00
|
|
|
|
2008-05-13 10:59:49 +00:00
|
|
|
desired = gst_caps_copy (caps);
|
|
|
|
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
|
2008-05-08 06:20:42 +00:00
|
|
|
|
|
|
|
fail_unless (gst_pad_alloc_buffer_and_set_caps (mysrcpad,
|
2008-05-13 10:59:49 +00:00
|
|
|
GST_BUFFER_OFFSET_NONE, rate * 4, desired, &inbuffer) == GST_FLOW_OK);
|
|
|
|
|
|
|
|
/* When the basetransform hits the non-configured case it always
|
|
|
|
* returns a buffer with exactly the same caps as we requested so the actual
|
|
|
|
* renegotiation (if needed) will be done in the _chain*/
|
|
|
|
fail_unless (inbuffer != NULL);
|
|
|
|
fail_unless (gst_caps_is_equal (desired, GST_BUFFER_CAPS (inbuffer)));
|
2008-05-08 06:20:42 +00:00
|
|
|
|
2012-02-07 11:14:05 +00:00
|
|
|
gst_buffer_memset (inbuffer, 0, 0, -1);
|
2008-05-08 06:20:42 +00:00
|
|
|
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
|
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
|
|
|
GST_BUFFER_OFFSET (inbuffer) = 0;
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
|
|
|
|
for (l = buffers; l; l = l->next) {
|
|
|
|
GstBuffer *buffer = GST_BUFFER (l->data);
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
2008-05-13 10:59:49 +00:00
|
|
|
|
2008-05-08 06:20:42 +00:00
|
|
|
g_list_free (buffers);
|
|
|
|
buffers = NULL;
|
2008-05-13 10:59:49 +00:00
|
|
|
|
|
|
|
gst_caps_unref (desired);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_live_switch)
|
|
|
|
{
|
2009-01-23 11:46:28 +00:00
|
|
|
GstElement *legacyresample;
|
2008-05-13 10:59:49 +00:00
|
|
|
GstEvent *newseg;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
legacyresample = setup_legacyresample (4, 48000, 48000);
|
2008-05-13 10:59:49 +00:00
|
|
|
|
|
|
|
/* Let the sinkpad act like something that can only handle things of
|
|
|
|
* rate 48000- and can only allocate buffers for that rate, but if someone
|
|
|
|
* tries to get a buffer with a rate higher then 48000 tries to renegotiate
|
|
|
|
* */
|
|
|
|
gst_pad_set_bufferalloc_function (mysinkpad, live_switch_alloc_only_48000);
|
|
|
|
gst_pad_set_getcaps_function (mysinkpad, live_switch_get_sink_caps);
|
|
|
|
|
|
|
|
caps = gst_pad_get_negotiated_caps (mysrcpad);
|
|
|
|
fail_unless (gst_caps_is_fixed (caps));
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
fail_unless (gst_element_set_state (legacyresample,
|
2008-05-13 10:59:49 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
newseg = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
|
|
|
|
|
|
|
|
/* downstream can provide the requested rate, a buffer alloc will be passed
|
|
|
|
* on */
|
|
|
|
live_switch_push (48000, caps);
|
|
|
|
|
|
|
|
/* Downstream can never accept this rate, buffer alloc isn't passed on */
|
|
|
|
live_switch_push (40000, caps);
|
|
|
|
|
|
|
|
/* Downstream can provide the requested rate but will re-negotiate */
|
|
|
|
live_switch_push (50000, caps);
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
cleanup_legacyresample (legacyresample);
|
2008-05-08 06:20:42 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
2012-02-07 11:14:05 +00:00
|
|
|
GST_END_TEST
|
|
|
|
#endif
|
|
|
|
static Suite *
|
2009-01-23 11:46:28 +00:00
|
|
|
legacyresample_suite (void)
|
2005-08-25 15:44:58 +00:00
|
|
|
{
|
2009-01-23 11:46:28 +00:00
|
|
|
Suite *s = suite_create ("legacyresample");
|
2005-08-25 15:44:58 +00:00
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_test (tc_chain, test_perfect_stream);
|
2007-03-14 17:16:30 +00:00
|
|
|
tcase_add_test (tc_chain, test_discont_stream);
|
2006-06-16 15:43:23 +00:00
|
|
|
tcase_add_test (tc_chain, test_reuse);
|
2007-04-21 13:54:39 +00:00
|
|
|
tcase_add_test (tc_chain, test_shutdown);
|
2012-02-07 11:14:05 +00:00
|
|
|
#if 0
|
2008-05-08 06:20:42 +00:00
|
|
|
tcase_add_test (tc_chain, test_live_switch);
|
2012-02-07 11:14:05 +00:00
|
|
|
#endif
|
2005-08-25 15:44:58 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2009-01-23 11:46:28 +00:00
|
|
|
GST_CHECK_MAIN (legacyresample);
|