Commit a01fad70 authored by Wim Taymans's avatar Wim Taymans
Browse files

tests: port and enable more unit tests

parent 21ed1273
......@@ -128,18 +128,7 @@ check_PROGRAMS = \
libs/xmpwriter \
$(cxx_checks) \
$(check_orc) \
pipelines/simple-launch-lines
# TORTURE_TO_FIX = \
# elements/adder
# videoconvert takes too long, so disabled for now
VALGRIND_TO_FIX = \
elements/videoconvert \
libs/video
# FIXME 0.11: these tests don't even build at the moment
ZERO_11_TO_PORT = \
pipelines/simple-launch-lines \
pipelines/streamheader \
pipelines/basetime \
pipelines/capsfilter-renegotiation \
......@@ -158,14 +147,19 @@ ZERO_11_TO_PORT = \
elements/videoscale \
elements/videotestsrc \
elements/volume
# FIXME 0.11: these tests don't pass at the moment
ZERO_11_TO_FIX = \
elements/adder \
$(check_theora)
# TORTURE_TO_FIX = \
# elements/adder
# videoconvert takes too long, so disabled for now
VALGRIND_TO_FIX = \
elements/videoconvert \
libs/video
# these tests don't even pass
noinst_PROGRAMS = $(check_libvisual) $(ZERO_11_TO_FIX)
noinst_PROGRAMS = $(check_libvisual)
noinst_HEADERS = \
libs/struct_arm.h \
......@@ -351,7 +345,11 @@ elements_audioconvert_LDADD = \
$(GST_BASE_LIBS) \
$(LDADD)
elements_audiorate_LDADD = $(LDADD)
elements_audiorate_LDADD = \
$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
$(GST_BASE_LIBS) \
$(LDADD)
elements_audiorate_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_libvisual_LDADD = $(LDADD)
......@@ -391,7 +389,7 @@ elements_textoverlay_LDADD = $(GST_BASE_LIBS) $(LDADD)
elements_textoverlay_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
elements_volume_LDADD = \
$(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
$(GST_CONTROLLER_LIBS) \
$(GST_BASE_LIBS) \
$(LDADD)
......
......@@ -38,7 +38,7 @@ setup_appsink (void)
GST_DEBUG ("setup_appsink");
appsink = gst_check_setup_element ("appsink");
mysrcpad = gst_check_setup_src_pad (appsink, &srctemplate, NULL);
mysrcpad = gst_check_setup_src_pad (appsink, &srctemplate);
return appsink;
}
......@@ -88,7 +88,7 @@ GST_START_TEST (test_non_clients)
caps = gst_caps_from_string ("application/x-gst-check");
buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
......@@ -113,7 +113,7 @@ GST_START_TEST (test_handoff_callback)
global_testdata = 0;
testdata = 5; /* Arbitrary value */
callbacks.new_buffer = callback_function;
callbacks.new_sample = callback_function;
gst_app_sink_set_callbacks (GST_APP_SINK (sink), &callbacks, &testdata, NULL);
......@@ -121,7 +121,7 @@ GST_START_TEST (test_handoff_callback)
caps = gst_caps_from_string ("application/x-gst-check");
buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
/* Pushing a buffer should run our callback */
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
......@@ -212,107 +212,36 @@ create_buffer_list (void)
mycaps = gst_caps_from_string ("application/x-gst-check");
fail_if (mycaps == NULL);
len = gst_buffer_list_len (mylist);
len = gst_buffer_list_length (mylist);
fail_if (len != 0);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[0], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_add (mylist, buffer);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[1], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_add (mylist, buffer);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[2], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_add (mylist, buffer);
return mylist;
}
static void
check_buffer_list (GstBufferList * list)
{
guint len;
GstBuffer *buf;
GstCaps *caps;
fail_unless (list == mylist);
fail_unless (gst_buffer_list_len (list) == 3);
len = gst_buffer_list_len (list);
buf = gst_buffer_list_get (list, 0);
fail_if (buf == NULL);
gst_check_buffer_data (buf, &values[0], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
fail_unless (gst_caps_is_equal (caps, mycaps));
gst_caps_unref (caps);
buf = gst_buffer_list_get (list, 1);
fail_if (buf == NULL);
gst_check_buffer_data (buf, &values[1], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
gst_caps_unref (caps);
buf = gst_buffer_list_get (list, 2);
fail_if (buf == NULL);
gst_check_buffer_data (buf, &values[2], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
gst_caps_unref (caps);
}
static GstFlowReturn
callback_function_buffer_list (GstAppSink * appsink, gpointer callback_data)
{
GstBufferList *list;
list = gst_app_sink_pull_buffer_list (appsink);
fail_unless (GST_IS_BUFFER_LIST (list));
check_buffer_list (list);
gst_pad_set_caps (mysrcpad, mycaps);
gst_caps_unref (mycaps);
gst_buffer_list_unref (list);
return GST_FLOW_OK;
}
GST_START_TEST (test_buffer_list)
{
GstElement *sink;
GstBufferList *list;
GstAppSinkCallbacks callbacks = { NULL };
sink = setup_appsink ();
callbacks.new_buffer_list = callback_function_buffer_list;
gst_app_sink_set_callbacks (GST_APP_SINK (sink), &callbacks, NULL, NULL);
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
list = create_buffer_list ();
fail_unless (gst_pad_push_list (mysrcpad, list) == GST_FLOW_OK);
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
cleanup_appsink (sink);
return mylist;
}
GST_END_TEST;
static GstFlowReturn
callback_function_buffer (GstAppSink * appsink, gpointer p_counter)
callback_function_sample (GstAppSink * appsink, gpointer p_counter)
{
GstSample *sample;
GstBuffer *buf;
gint *p_int_counter = p_counter;
buf = gst_app_sink_pull_buffer (appsink);
sample = gst_app_sink_pull_sample (appsink);
buf = gst_sample_get_buffer (sample);
fail_unless (GST_IS_BUFFER (buf));
/* buffer list has 3 buffers in two groups */
......@@ -334,7 +263,7 @@ callback_function_buffer (GstAppSink * appsink, gpointer p_counter)
break;
}
gst_buffer_unref (buf);
gst_sample_unref (sample);
*p_int_counter += 1;
......@@ -350,7 +279,7 @@ GST_START_TEST (test_buffer_list_fallback)
sink = setup_appsink ();
callbacks.new_buffer = callback_function_buffer;
callbacks.new_sample = callback_function_sample;
gst_app_sink_set_callbacks (GST_APP_SINK (sink), &callbacks, &counter, NULL);
......@@ -376,7 +305,7 @@ GST_START_TEST (test_buffer_list_fallback_signal)
sink = setup_appsink ();
/* C calling convention to the rescue.. */
g_signal_connect (sink, "new-buffer", G_CALLBACK (callback_function_buffer),
g_signal_connect (sink, "new-sample", G_CALLBACK (callback_function_sample),
&counter);
g_object_set (sink, "emit-signals", TRUE, NULL);
......@@ -405,7 +334,6 @@ appsink_suite (void)
tcase_add_test (tc_chain, test_handoff_callback);
tcase_add_test (tc_chain, test_notify0);
tcase_add_test (tc_chain, test_notify1);
tcase_add_test (tc_chain, test_buffer_list);
tcase_add_test (tc_chain, test_buffer_list_fallback);
tcase_add_test (tc_chain, test_buffer_list_fallback_signal);
......
......@@ -37,7 +37,7 @@ setup_appsrc (void)
GST_DEBUG ("setup_appsrc");
appsrc = gst_check_setup_element ("appsrc");
mysinkpad = gst_check_setup_sink_pad (appsrc, &sinktemplate, NULL);
mysinkpad = gst_check_setup_sink_pad (appsrc, &sinktemplate);
gst_pad_set_active (mysinkpad, TRUE);
......@@ -53,62 +53,6 @@ cleanup_appsrc (GstElement * appsrc)
gst_check_teardown_element (appsrc);
}
/*
* Pushes 4 buffers into appsrc and checks the caps on them on the output.
*
* Appsrc is configured with caps=null, so the buffers should have the
* same caps that they were pushed with.
*
* The 4 buffers have NULL, SAMPLE_CAPS, NULL, SAMPLE_CAPS caps,
* respectively.
*/
GST_START_TEST (test_appsrc_null_caps)
{
GstElement *src;
GstBuffer *buffer;
GList *iter;
GstCaps *caps;
src = setup_appsrc ();
g_object_set (src, "caps", NULL, NULL);
caps = gst_caps_from_string (SAMPLE_CAPS);
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
buffer = gst_buffer_new_and_alloc (4);
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src),
buffer) == GST_FLOW_OK);
buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src),
buffer) == GST_FLOW_OK);
fail_unless (gst_app_src_end_of_stream (GST_APP_SRC (src)) == GST_FLOW_OK);
/* Give some time to the appsrc loop to push the buffers */
g_usleep (G_USEC_PER_SEC * 3);
/* Check the output caps */
fail_unless (g_list_length (buffers) == 2);
iter = buffers;
buffer = (GstBuffer *) iter->data;
fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
iter = g_list_next (iter);
buffer = (GstBuffer *) iter->data;
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
ASSERT_SET_STATE (src, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
gst_caps_unref (caps);
cleanup_appsrc (src);
}
GST_END_TEST;
/*
* Pushes 4 buffers into appsrc and checks the caps on them on the output.
*
......@@ -122,7 +66,6 @@ GST_START_TEST (test_appsrc_non_null_caps)
{
GstElement *src;
GstBuffer *buffer;
GList *iter;
GstCaps *caps;
src = setup_appsrc ();
......@@ -137,7 +80,6 @@ GST_START_TEST (test_appsrc_non_null_caps)
buffer) == GST_FLOW_OK);
buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src),
buffer) == GST_FLOW_OK);
......@@ -146,7 +88,6 @@ GST_START_TEST (test_appsrc_non_null_caps)
buffer) == GST_FLOW_OK);
buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src),
buffer) == GST_FLOW_OK);
......@@ -157,11 +98,8 @@ GST_START_TEST (test_appsrc_non_null_caps)
/* Check the output caps */
fail_unless (g_list_length (buffers) == 4);
for (iter = buffers; iter; iter = g_list_next (iter)) {
GstBuffer *buf = (GstBuffer *) iter->data;
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buf), caps));
}
fail_unless (gst_caps_is_equal (gst_pad_get_current_caps (mysinkpad), caps));
ASSERT_SET_STATE (src, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
gst_caps_unref (caps);
......@@ -177,7 +115,6 @@ appsrc_suite (void)
Suite *s = suite_create ("appsrc");
TCase *tc_chain = tcase_create ("general");
tcase_add_test (tc_chain, test_appsrc_null_caps);
tcase_add_test (tc_chain, test_appsrc_non_null_caps);
suite_add_tcase (s, tc_chain);
......
......@@ -23,6 +23,7 @@
#endif
#include <gst/check/gstcheck.h>
#include <gst/audio/audio.h>
/* helper element to insert additional buffers overlapping with previous ones */
static gdouble injector_inject_probability = 0.0;
......@@ -64,7 +65,7 @@ test_injector_class_init (TestInjectorClass * klass)
}
static GstFlowReturn
test_injector_chain (GstPad * pad, GstBuffer * buf)
test_injector_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret;
GstPad *srcpad;
......@@ -141,29 +142,30 @@ test_injector_init (TestInjector * injector)
pad = gst_pad_new_from_static_template (&sink_template, "sink");
gst_pad_set_chain_function (pad, test_injector_chain);
gst_pad_set_getcaps_function (pad, gst_pad_proxy_getcaps);
gst_pad_set_setcaps_function (pad, gst_pad_proxy_setcaps);
GST_PAD_SET_PROXY_CAPS (pad);
gst_element_add_pad (GST_ELEMENT (injector), pad);
pad = gst_pad_new_from_static_template (&src_template, "src");
gst_pad_set_getcaps_function (pad, gst_pad_proxy_getcaps);
gst_pad_set_setcaps_function (pad, gst_pad_proxy_setcaps);
GST_PAD_SET_PROXY_CAPS (pad);
gst_element_add_pad (GST_ELEMENT (injector), pad);
}
static gboolean
probe_cb (GstPad * pad, GstBuffer * buf, gdouble * drop_probability)
static GstPadProbeReturn
probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
GstBuffer *buf = GST_PAD_PROBE_INFO_BUFFER (info);
gdouble *drop_probability = user_data;
if (g_random_double () < *drop_probability) {
GST_LOG ("dropping buffer [t=%" GST_TIME_FORMAT "-%" GST_TIME_FORMAT "], "
"offset=%" G_GINT64_FORMAT ", offset_end=%" G_GINT64_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf));
return FALSE; /* drop buffer */
return GST_PAD_PROBE_DROP; /* drop buffer */
}
return TRUE; /* don't drop buffer */
return GST_PAD_PROBE_OK; /* don't drop buffer */
}
static void
......@@ -183,6 +185,15 @@ do_perfect_stream_test (guint rate, const gchar * format,
GList *l, *bufs = NULL;
GstClockTime next_time = GST_CLOCK_TIME_NONE;
guint64 next_offset = GST_BUFFER_OFFSET_NONE;
GstAudioFormat fmt;
const GstAudioFormatInfo *finfo;
gint width;
fmt = gst_audio_format_from_string (format);
g_assert (format != GST_AUDIO_FORMAT_UNKNOWN);
finfo = gst_audio_format_get_info (fmt);
width = GST_AUDIO_FORMAT_INFO_WIDTH (finfo);
caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT,
rate, "format", G_TYPE_STRING, format, NULL);
......@@ -192,7 +203,6 @@ do_perfect_stream_test (guint rate, const gchar * format,
g_assert (drop_probability >= 0.0 && drop_probability <= 1.0);
g_assert (inject_probability >= 0.0 && inject_probability <= 1.0);
g_assert (width > 0 && (width % 8) == 0);
pipe = gst_pipeline_new ("pipeline");
fail_unless (pipe != NULL);
......@@ -216,7 +226,8 @@ do_perfect_stream_test (guint rate, const gchar * format,
srcpad = gst_element_get_static_pad (injector, "src");
fail_unless (srcpad != NULL);
gst_pad_add_buffer_probe (srcpad, G_CALLBACK (probe_cb), &drop_probability);
gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BUFFER, probe_cb,
&drop_probability, NULL);
gst_object_unref (srcpad);
audiorate = gst_element_factory_make ("audiorate", "audiorate");
......@@ -401,8 +412,8 @@ GST_START_TEST (test_large_discont)
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 44100, NULL);
srcpad = gst_check_setup_src_pad (audiorate, &srctemplate, caps);
sinkpad = gst_check_setup_sink_pad (audiorate, &sinktemplate, caps);
srcpad = gst_check_setup_src_pad (audiorate, &srctemplate);
sinkpad = gst_check_setup_sink_pad (audiorate, &sinktemplate);
gst_pad_set_active (srcpad, TRUE);
gst_pad_set_active (sinkpad, TRUE);
......@@ -412,14 +423,13 @@ GST_START_TEST (test_large_discont)
"failed to set audiorate playing");
buf = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buf, caps);
gst_pad_set_caps (srcpad, caps);
GST_BUFFER_TIMESTAMP (buf) = 0;
gst_pad_push (srcpad, buf);
fail_unless_equals_int (g_list_length (buffers), 1);
buf = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buf, caps);
GST_BUFFER_TIMESTAMP (buf) = 2 * GST_SECOND;
gst_pad_push (srcpad, buf);
/* Now we should have 3 more buffers: the one we injected, plus _two_ filler
......
......@@ -99,7 +99,7 @@ setup_audioresample (int channels, int inrate, int outrate, int width,
GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS,
"could not set to paused");
mysrcpad = gst_check_setup_src_pad (audioresample, &srctemplate, caps);
mysrcpad = gst_check_setup_src_pad (audioresample, &srctemplate);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
......@@ -114,7 +114,7 @@ setup_audioresample (int channels, int inrate, int outrate, int width,
gst_structure_set (structure, "depth", G_TYPE_INT, width, NULL);
fail_unless (gst_caps_is_fixed (caps));
mysinkpad = gst_check_setup_sink_pad (audioresample, &sinktemplate, caps);
mysinkpad = gst_check_setup_sink_pad (audioresample, &sinktemplate);
/* this installs a getcaps func that will always return the caps we set
* later */
gst_pad_set_caps (mysinkpad, caps);
......@@ -189,7 +189,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
gint16 *p, *data;
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
caps = gst_pad_get_current_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample,
......@@ -205,8 +205,6 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
offset += samples;
GST_BUFFER_OFFSET_END (inbuffer) = offset;
gst_buffer_set_caps (inbuffer, caps);
p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */
......@@ -277,7 +275,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
inrate, outrate, samples, numbuffers);
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
caps = gst_pad_get_current_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample,
......@@ -294,8 +292,6 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
GST_BUFFER_OFFSET (inbuffer) = (j - 1) * 2 * samples;
GST_BUFFER_OFFSET_END (inbuffer) = j * 2 * samples + samples;
gst_buffer_set_caps (inbuffer, caps);
p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
......@@ -362,16 +358,18 @@ GST_START_TEST (test_reuse)
GstBuffer *inbuffer;
GstCaps *caps;
guint8 *data;
GstSegment segment;
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
caps = gst_pad_get_current_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample,
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);
gst_segment_init (&segment, GST_FORMAT_TIME);
newseg = gst_event_new_segment (&segment);
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
......@@ -381,7 +379,6 @@ GST_START_TEST (test_reuse)
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
gst_buffer_set_caps (inbuffer, caps);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
......@@ -397,7 +394,7 @@ GST_START_TEST (test_reuse)
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);
newseg = gst_event_new_segment (&segment);
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
......@@ -407,7 +404,6 @@ GST_START_TEST (test_reuse)
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
......@@ -494,20 +490,20 @@ live_switch_alloc_only_48000 (GstPad * pad, guint64 offset,
return GST_FLOW_OK;
}
#endif
static GstCaps *
live_switch_get_sink_caps (GstPad * pad)
{
GstCaps *result;
result = gst_caps_copy (GST_PAD_CAPS (pad));
result = gst_caps_make_writable (gst_pad_get_current_caps (pad));
gst_caps_set_simple (result,
"rate", GST_TYPE_INT_RANGE, 48000, G_MAXINT, NULL);
return result;
}
#endif
static void
live_switch_push (int rate, GstCaps * caps)
......@@ -515,7 +511,6 @@ live_switch_push (int rate, GstCaps * caps)
GstBuffer *inbuffer;
GstCaps *desired;
GList *l;
guint8 *data;
desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
......@@ -526,19 +521,7 @@ live_switch_push (int rate, GstCaps * caps)
GST_BUFFER_OFFSET_NONE, rate * 4, desired, &inbuffer) == GST_FLOW_OK);
#endif
inbuffer = gst_buffer_new_and_alloc (rate * 4);
gst_buffer_set_caps (inbuffer, desired);
/* 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);
GST_DEBUG ("desired: %" GST_PTR_FORMAT ".... got: %" GST_PTR_FORMAT,
desired, GST_BUFFER_CAPS (inbuffer));
fail_unless (gst_caps_is_equal (desired, GST_BUFFER_CAPS (inbuffer)));