tests: port and enable more unit tests

This commit is contained in:
Wim Taymans 2012-01-04 16:41:53 +01:00
parent 21ed12739e
commit a01fad7024
19 changed files with 635 additions and 825 deletions

View file

@ -128,18 +128,7 @@ check_PROGRAMS = \
libs/xmpwriter \ libs/xmpwriter \
$(cxx_checks) \ $(cxx_checks) \
$(check_orc) \ $(check_orc) \
pipelines/simple-launch-lines 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/streamheader \ pipelines/streamheader \
pipelines/basetime \ pipelines/basetime \
pipelines/capsfilter-renegotiation \ pipelines/capsfilter-renegotiation \
@ -158,14 +147,19 @@ ZERO_11_TO_PORT = \
elements/videoscale \ elements/videoscale \
elements/videotestsrc \ elements/videotestsrc \
elements/volume elements/volume
# FIXME 0.11: these tests don't pass at the moment
ZERO_11_TO_FIX = \
elements/adder \ elements/adder \
$(check_theora) $(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 # these tests don't even pass
noinst_PROGRAMS = $(check_libvisual) $(ZERO_11_TO_FIX) noinst_PROGRAMS = $(check_libvisual)
noinst_HEADERS = \ noinst_HEADERS = \
libs/struct_arm.h \ libs/struct_arm.h \
@ -351,7 +345,11 @@ elements_audioconvert_LDADD = \
$(GST_BASE_LIBS) \ $(GST_BASE_LIBS) \
$(LDADD) $(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_audiorate_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_libvisual_LDADD = $(LDADD) elements_libvisual_LDADD = $(LDADD)
@ -391,7 +389,7 @@ elements_textoverlay_LDADD = $(GST_BASE_LIBS) $(LDADD)
elements_textoverlay_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS) elements_textoverlay_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
elements_volume_LDADD = \ 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_CONTROLLER_LIBS) \
$(GST_BASE_LIBS) \ $(GST_BASE_LIBS) \
$(LDADD) $(LDADD)

View file

@ -38,7 +38,7 @@ setup_appsink (void)
GST_DEBUG ("setup_appsink"); GST_DEBUG ("setup_appsink");
appsink = gst_check_setup_element ("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; return appsink;
} }
@ -88,7 +88,7 @@ GST_START_TEST (test_non_clients)
caps = gst_caps_from_string ("application/x-gst-check"); caps = gst_caps_from_string ("application/x-gst-check");
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
@ -113,7 +113,7 @@ GST_START_TEST (test_handoff_callback)
global_testdata = 0; global_testdata = 0;
testdata = 5; /* Arbitrary value */ 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); 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"); caps = gst_caps_from_string ("application/x-gst-check");
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
/* Pushing a buffer should run our callback */ /* Pushing a buffer should run our callback */
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK); 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"); mycaps = gst_caps_from_string ("application/x-gst-check");
fail_if (mycaps == NULL); fail_if (mycaps == NULL);
len = gst_buffer_list_len (mylist); len = gst_buffer_list_length (mylist);
fail_if (len != 0); fail_if (len != 0);
buffer = gst_buffer_new_and_alloc (sizeof (gint)); buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[0], sizeof (gint)); gst_buffer_fill (buffer, 0, &values[0], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_add (mylist, buffer); gst_buffer_list_add (mylist, buffer);
buffer = gst_buffer_new_and_alloc (sizeof (gint)); buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[1], sizeof (gint)); gst_buffer_fill (buffer, 0, &values[1], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_add (mylist, buffer); gst_buffer_list_add (mylist, buffer);
buffer = gst_buffer_new_and_alloc (sizeof (gint)); buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[2], sizeof (gint)); gst_buffer_fill (buffer, 0, &values[2], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_add (mylist, buffer); gst_buffer_list_add (mylist, buffer);
gst_pad_set_caps (mysrcpad, mycaps);
gst_caps_unref (mycaps);
return mylist; 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 static GstFlowReturn
callback_function_buffer_list (GstAppSink * appsink, gpointer callback_data) callback_function_sample (GstAppSink * appsink, gpointer p_counter)
{
GstBufferList *list;
list = gst_app_sink_pull_buffer_list (appsink);
fail_unless (GST_IS_BUFFER_LIST (list));
check_buffer_list (list);
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);
}
GST_END_TEST;
static GstFlowReturn
callback_function_buffer (GstAppSink * appsink, gpointer p_counter)
{ {
GstSample *sample;
GstBuffer *buf; GstBuffer *buf;
gint *p_int_counter = p_counter; 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)); fail_unless (GST_IS_BUFFER (buf));
/* buffer list has 3 buffers in two groups */ /* buffer list has 3 buffers in two groups */
@ -334,7 +263,7 @@ callback_function_buffer (GstAppSink * appsink, gpointer p_counter)
break; break;
} }
gst_buffer_unref (buf); gst_sample_unref (sample);
*p_int_counter += 1; *p_int_counter += 1;
@ -350,7 +279,7 @@ GST_START_TEST (test_buffer_list_fallback)
sink = setup_appsink (); 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); 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 (); sink = setup_appsink ();
/* C calling convention to the rescue.. */ /* 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); &counter);
g_object_set (sink, "emit-signals", TRUE, NULL); 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_handoff_callback);
tcase_add_test (tc_chain, test_notify0); tcase_add_test (tc_chain, test_notify0);
tcase_add_test (tc_chain, test_notify1); 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);
tcase_add_test (tc_chain, test_buffer_list_fallback_signal); tcase_add_test (tc_chain, test_buffer_list_fallback_signal);

View file

@ -37,7 +37,7 @@ setup_appsrc (void)
GST_DEBUG ("setup_appsrc"); GST_DEBUG ("setup_appsrc");
appsrc = gst_check_setup_element ("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); gst_pad_set_active (mysinkpad, TRUE);
@ -53,62 +53,6 @@ cleanup_appsrc (GstElement * appsrc)
gst_check_teardown_element (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. * 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; GstElement *src;
GstBuffer *buffer; GstBuffer *buffer;
GList *iter;
GstCaps *caps; GstCaps *caps;
src = setup_appsrc (); src = setup_appsrc ();
@ -137,7 +80,6 @@ GST_START_TEST (test_appsrc_non_null_caps)
buffer) == GST_FLOW_OK); buffer) == GST_FLOW_OK);
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src), fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src),
buffer) == GST_FLOW_OK); buffer) == GST_FLOW_OK);
@ -146,7 +88,6 @@ GST_START_TEST (test_appsrc_non_null_caps)
buffer) == GST_FLOW_OK); buffer) == GST_FLOW_OK);
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src), fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src),
buffer) == GST_FLOW_OK); buffer) == GST_FLOW_OK);
@ -157,11 +98,8 @@ GST_START_TEST (test_appsrc_non_null_caps)
/* Check the output caps */ /* Check the output caps */
fail_unless (g_list_length (buffers) == 4); 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); ASSERT_SET_STATE (src, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -177,7 +115,6 @@ appsrc_suite (void)
Suite *s = suite_create ("appsrc"); Suite *s = suite_create ("appsrc");
TCase *tc_chain = tcase_create ("general"); 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); tcase_add_test (tc_chain, test_appsrc_non_null_caps);
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);

View file

@ -23,6 +23,7 @@
#endif #endif
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/audio/audio.h>
/* helper element to insert additional buffers overlapping with previous ones */ /* helper element to insert additional buffers overlapping with previous ones */
static gdouble injector_inject_probability = 0.0; static gdouble injector_inject_probability = 0.0;
@ -64,7 +65,7 @@ test_injector_class_init (TestInjectorClass * klass)
} }
static GstFlowReturn static GstFlowReturn
test_injector_chain (GstPad * pad, GstBuffer * buf) test_injector_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{ {
GstFlowReturn ret; GstFlowReturn ret;
GstPad *srcpad; GstPad *srcpad;
@ -141,29 +142,30 @@ test_injector_init (TestInjector * injector)
pad = gst_pad_new_from_static_template (&sink_template, "sink"); pad = gst_pad_new_from_static_template (&sink_template, "sink");
gst_pad_set_chain_function (pad, test_injector_chain); gst_pad_set_chain_function (pad, test_injector_chain);
gst_pad_set_getcaps_function (pad, gst_pad_proxy_getcaps); GST_PAD_SET_PROXY_CAPS (pad);
gst_pad_set_setcaps_function (pad, gst_pad_proxy_setcaps);
gst_element_add_pad (GST_ELEMENT (injector), pad); gst_element_add_pad (GST_ELEMENT (injector), pad);
pad = gst_pad_new_from_static_template (&src_template, "src"); pad = gst_pad_new_from_static_template (&src_template, "src");
gst_pad_set_getcaps_function (pad, gst_pad_proxy_getcaps); GST_PAD_SET_PROXY_CAPS (pad);
gst_pad_set_setcaps_function (pad, gst_pad_proxy_setcaps);
gst_element_add_pad (GST_ELEMENT (injector), pad); gst_element_add_pad (GST_ELEMENT (injector), pad);
} }
static gboolean static GstPadProbeReturn
probe_cb (GstPad * pad, GstBuffer * buf, gdouble * drop_probability) 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) { if (g_random_double () < *drop_probability) {
GST_LOG ("dropping buffer [t=%" GST_TIME_FORMAT "-%" GST_TIME_FORMAT "], " GST_LOG ("dropping buffer [t=%" GST_TIME_FORMAT "-%" GST_TIME_FORMAT "], "
"offset=%" G_GINT64_FORMAT ", offset_end=%" G_GINT64_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_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf)), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (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 static void
@ -183,6 +185,15 @@ do_perfect_stream_test (guint rate, const gchar * format,
GList *l, *bufs = NULL; GList *l, *bufs = NULL;
GstClockTime next_time = GST_CLOCK_TIME_NONE; GstClockTime next_time = GST_CLOCK_TIME_NONE;
guint64 next_offset = GST_BUFFER_OFFSET_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, caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT,
rate, "format", G_TYPE_STRING, format, NULL); 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 (drop_probability >= 0.0 && drop_probability <= 1.0);
g_assert (inject_probability >= 0.0 && inject_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"); pipe = gst_pipeline_new ("pipeline");
fail_unless (pipe != NULL); 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"); srcpad = gst_element_get_static_pad (injector, "src");
fail_unless (srcpad != NULL); 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); gst_object_unref (srcpad);
audiorate = gst_element_factory_make ("audiorate", "audiorate"); 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), "format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 44100, NULL); "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 44100, NULL);
srcpad = gst_check_setup_src_pad (audiorate, &srctemplate, caps); srcpad = gst_check_setup_src_pad (audiorate, &srctemplate);
sinkpad = gst_check_setup_sink_pad (audiorate, &sinktemplate, caps); sinkpad = gst_check_setup_sink_pad (audiorate, &sinktemplate);
gst_pad_set_active (srcpad, TRUE); gst_pad_set_active (srcpad, TRUE);
gst_pad_set_active (sinkpad, TRUE); gst_pad_set_active (sinkpad, TRUE);
@ -412,14 +423,13 @@ GST_START_TEST (test_large_discont)
"failed to set audiorate playing"); "failed to set audiorate playing");
buf = gst_buffer_new_and_alloc (4); 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_BUFFER_TIMESTAMP (buf) = 0;
gst_pad_push (srcpad, buf); gst_pad_push (srcpad, buf);
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
buf = gst_buffer_new_and_alloc (4); buf = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buf, caps);
GST_BUFFER_TIMESTAMP (buf) = 2 * GST_SECOND; GST_BUFFER_TIMESTAMP (buf) = 2 * GST_SECOND;
gst_pad_push (srcpad, buf); gst_pad_push (srcpad, buf);
/* Now we should have 3 more buffers: the one we injected, plus _two_ filler /* Now we should have 3 more buffers: the one we injected, plus _two_ filler

View file

@ -99,7 +99,7 @@ setup_audioresample (int channels, int inrate, int outrate, int width,
GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS,
"could not set to paused"); "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_pad_set_caps (mysrcpad, caps);
gst_caps_unref (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); gst_structure_set (structure, "depth", G_TYPE_INT, width, NULL);
fail_unless (gst_caps_is_fixed (caps)); 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 /* this installs a getcaps func that will always return the caps we set
* later */ * later */
gst_pad_set_caps (mysinkpad, caps); gst_pad_set_caps (mysinkpad, caps);
@ -189,7 +189,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
gint16 *p, *data; gint16 *p, *data;
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE); 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_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample, fail_unless (gst_element_set_state (audioresample,
@ -205,8 +205,6 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
offset += samples; offset += samples;
GST_BUFFER_OFFSET_END (inbuffer) = offset; GST_BUFFER_OFFSET_END (inbuffer) = offset;
gst_buffer_set_caps (inbuffer, caps);
p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE); p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */ /* create a 16 bit signed ramp */
@ -277,7 +275,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
inrate, outrate, samples, numbuffers); inrate, outrate, samples, numbuffers);
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE); 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_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample, 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 (inbuffer) = (j - 1) * 2 * samples;
GST_BUFFER_OFFSET_END (inbuffer) = j * 2 * samples + 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); p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */ /* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) { for (i = 0; i < samples; ++i) {
@ -362,16 +358,18 @@ GST_START_TEST (test_reuse)
GstBuffer *inbuffer; GstBuffer *inbuffer;
GstCaps *caps; GstCaps *caps;
guint8 *data; guint8 *data;
GstSegment segment;
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE); 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_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample, fail_unless (gst_element_set_state (audioresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "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); fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4); 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_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0; GST_BUFFER_OFFSET (inbuffer) = 0;
gst_buffer_set_caps (inbuffer, caps);
/* pushing gives away my reference ... */ /* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); 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, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "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); fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4); 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_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0; GST_BUFFER_OFFSET (inbuffer) = 0;
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); 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; return GST_FLOW_OK;
} }
#endif
static GstCaps * static GstCaps *
live_switch_get_sink_caps (GstPad * pad) live_switch_get_sink_caps (GstPad * pad)
{ {
GstCaps *result; 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, gst_caps_set_simple (result,
"rate", GST_TYPE_INT_RANGE, 48000, G_MAXINT, NULL); "rate", GST_TYPE_INT_RANGE, 48000, G_MAXINT, NULL);
return result; return result;
} }
#endif
static void static void
live_switch_push (int rate, GstCaps * caps) live_switch_push (int rate, GstCaps * caps)
@ -515,7 +511,6 @@ live_switch_push (int rate, GstCaps * caps)
GstBuffer *inbuffer; GstBuffer *inbuffer;
GstCaps *desired; GstCaps *desired;
GList *l; GList *l;
guint8 *data;
desired = gst_caps_copy (caps); desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL); 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); GST_BUFFER_OFFSET_NONE, rate * 4, desired, &inbuffer) == GST_FLOW_OK);
#endif #endif
inbuffer = gst_buffer_new_and_alloc (rate * 4); inbuffer = gst_buffer_new_and_alloc (rate * 4);
gst_buffer_set_caps (inbuffer, desired); gst_buffer_memset (inbuffer, 0, 0, rate * 4);
/* 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)));
data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
memset (data, 0, rate * 4);
gst_buffer_unmap (inbuffer, data, rate * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND; GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
@ -567,6 +550,7 @@ GST_START_TEST (test_live_switch)
GstElement *audioresample; GstElement *audioresample;
GstEvent *newseg; GstEvent *newseg;
GstCaps *caps; GstCaps *caps;
GstSegment segment;
audioresample = setup_audioresample (4, 48000, 48000, 16, FALSE); audioresample = setup_audioresample (4, 48000, 48000, 16, FALSE);
@ -575,18 +559,19 @@ GST_START_TEST (test_live_switch)
* tries to get a buffer with a rate higher then 48000 tries to renegotiate * 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_bufferalloc_function (mysinkpad, live_switch_alloc_only_48000);
gst_pad_set_getcaps_function (mysinkpad, live_switch_get_sink_caps); //gst_pad_set_getcaps_function (mysinkpad, live_switch_get_sink_caps);
gst_pad_use_fixed_caps (mysrcpad); gst_pad_use_fixed_caps (mysrcpad);
caps = gst_pad_get_negotiated_caps (mysrcpad); caps = gst_pad_get_current_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps)); fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample, fail_unless (gst_element_set_state (audioresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "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); fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
/* downstream can provide the requested rate, a buffer alloc will be passed /* downstream can provide the requested rate, a buffer alloc will be passed
@ -678,23 +663,23 @@ GST_START_TEST (test_pipelines)
for (quality = 0; quality < 11; quality += 5) { for (quality = 0; quality < 11; quality += 5) {
GST_DEBUG ("Checking with quality %d", quality); GST_DEBUG ("Checking with quality %d", quality);
test_pipeline (8, FALSE, 44100, 48000, quality); test_pipeline ("S8", 44100, 48000, quality);
test_pipeline (8, FALSE, 48000, 44100, quality); test_pipeline ("S8", 48000, 44100, quality);
test_pipeline (16, FALSE, 44100, 48000, quality); test_pipeline ("S16", 44100, 48000, quality);
test_pipeline (16, FALSE, 48000, 44100, quality); test_pipeline ("S16", 48000, 44100, quality);
test_pipeline (24, FALSE, 44100, 48000, quality); test_pipeline ("S24", 44100, 48000, quality);
test_pipeline (24, FALSE, 48000, 44100, quality); test_pipeline ("S24", 48000, 44100, quality);
test_pipeline (32, FALSE, 44100, 48000, quality); test_pipeline ("S32", 44100, 48000, quality);
test_pipeline (32, FALSE, 48000, 44100, quality); test_pipeline ("S32", 48000, 44100, quality);
test_pipeline (32, TRUE, 44100, 48000, quality); test_pipeline ("F32", 44100, 48000, quality);
test_pipeline (32, TRUE, 48000, 44100, quality); test_pipeline ("F32", 48000, 44100, quality);
test_pipeline (64, TRUE, 44100, 48000, quality); test_pipeline ("F64", 44100, 48000, quality);
test_pipeline (64, TRUE, 48000, 44100, quality); test_pipeline ("F64", 48000, 44100, quality);
} }
} }
@ -732,8 +717,8 @@ GST_START_TEST (test_preference_passthrough)
fail_unless (src != NULL); fail_unless (src != NULL);
pad = gst_element_get_static_pad (src, "src"); pad = gst_element_get_static_pad (src, "src");
fail_unless (pad != NULL); fail_unless (pad != NULL);
caps = gst_pad_get_negotiated_caps (pad); caps = gst_pad_get_current_caps (pad);
GST_LOG ("negotiated audiotestsrc caps: %" GST_PTR_FORMAT, caps); GST_LOG ("current audiotestsrc caps: %" GST_PTR_FORMAT, caps);
fail_unless (caps != NULL); fail_unless (caps != NULL);
s = gst_caps_get_structure (caps, 0); s = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_get_int (s, "rate", &rate)); fail_unless (gst_structure_get_int (s, "rate", &rate));
@ -959,23 +944,31 @@ static gboolean is_zero_except_##ffttag (const GstFFT##ffttag##Complex *v, int e
} \ } \
return TRUE; \ return TRUE; \
} \ } \
static void compare_ffts_##ffttag (const GstBuffer *inbuffer, const GstBuffer *outbuffer) \ static void compare_ffts_##ffttag (GstBuffer *inbuffer, GstBuffer *outbuffer) \
{ \ { \
int insamples = GST_BUFFER_SIZE (inbuffer) / sizeof(type) & ~1; \ gsize insize, outsize; \
int outsamples = GST_BUFFER_SIZE (outbuffer) / sizeof(type) & ~1; \ gpointer indata, outdata; \
int insamples, outsamples; \
gdouble inspot, outspot; \ gdouble inspot, outspot; \
GstFFT##ffttag *inctx, *outctx; \
GstFFT##ffttag##Complex *in, *out; \
\ \
GstFFT##ffttag *inctx = gst_fft_##ffttag2##_new (insamples, FALSE); \ indata = gst_buffer_map (inbuffer, &insize, NULL, GST_MAP_READ); \
GstFFT##ffttag##Complex *in = g_new (GstFFT##ffttag##Complex, insamples / 2 + 1); \ outdata = gst_buffer_map (outbuffer, &outsize, NULL, GST_MAP_READWRITE); \
GstFFT##ffttag *outctx = gst_fft_##ffttag2##_new (outsamples, FALSE); \
GstFFT##ffttag##Complex *out = g_new (GstFFT##ffttag##Complex, outsamples / 2 + 1); \
\ \
gst_fft_##ffttag2##_window (inctx, (type*)GST_BUFFER_DATA (inbuffer), \ insamples = insize / sizeof(type) & ~1; \
outsamples = outsize / sizeof(type) & ~1; \
inctx = gst_fft_##ffttag2##_new (insamples, FALSE); \
outctx = gst_fft_##ffttag2##_new (outsamples, FALSE); \
in = g_new (GstFFT##ffttag##Complex, insamples / 2 + 1); \
out = g_new (GstFFT##ffttag##Complex, outsamples / 2 + 1); \
\
gst_fft_##ffttag2##_window (inctx, (type*)indata, \
GST_FFT_WINDOW_HAMMING); \ GST_FFT_WINDOW_HAMMING); \
gst_fft_##ffttag2##_fft (inctx, (type*)GST_BUFFER_DATA (inbuffer), in); \ gst_fft_##ffttag2##_fft (inctx, (type*)indata, in); \
gst_fft_##ffttag2##_window (outctx, (type*)GST_BUFFER_DATA (outbuffer), \ gst_fft_##ffttag2##_window (outctx, (type*)outdata, \
GST_FFT_WINDOW_HAMMING); \ GST_FFT_WINDOW_HAMMING); \
gst_fft_##ffttag2##_fft (outctx, (type*)GST_BUFFER_DATA (outbuffer), out); \ gst_fft_##ffttag2##_fft (outctx, (type*)outdata, out); \
\ \
inspot = find_main_frequency_spot_##ffttag (in, insamples / 2 + 1); \ inspot = find_main_frequency_spot_##ffttag (in, insamples / 2 + 1); \
outspot = find_main_frequency_spot_##ffttag (out, outsamples / 2 + 1); \ outspot = find_main_frequency_spot_##ffttag (out, outsamples / 2 + 1); \
@ -984,6 +977,9 @@ static void compare_ffts_##ffttag (const GstBuffer *inbuffer, const GstBuffer *o
fail_unless (is_zero_except_##ffttag (in, insamples / 2 + 1, inspot)); \ fail_unless (is_zero_except_##ffttag (in, insamples / 2 + 1, inspot)); \
fail_unless (is_zero_except_##ffttag (out, outsamples / 2 + 1, outspot)); \ fail_unless (is_zero_except_##ffttag (out, outsamples / 2 + 1, outspot)); \
\ \
gst_buffer_unmap (inbuffer, indata, insize); \
gst_buffer_unmap (outbuffer, outdata, outsize); \
\
gst_fft_##ffttag2##_free (inctx); \ gst_fft_##ffttag2##_free (inctx); \
gst_fft_##ffttag2##_free (outctx); \ gst_fft_##ffttag2##_free (outctx); \
g_free (in); \ g_free (in); \
@ -997,8 +993,9 @@ FFT_HELPERS (gint32, S32, s32, 2147483647.0);
#define FILL_BUFFER(type, desc, value); \ #define FILL_BUFFER(type, desc, value); \
static void init_##type##_##desc (GstBuffer *buffer) \ static void init_##type##_##desc (GstBuffer *buffer) \
{ \ { \
type *ptr = (type *) GST_BUFFER_DATA (buffer); \ gsize size; \
int i, nsamples = GST_BUFFER_SIZE (buffer) / sizeof (type); \ type *ptr = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE); \
int i, nsamples = size / sizeof (type); \
for (i = 0; i < nsamples; ++i) { \ for (i = 0; i < nsamples; ++i) { \
*ptr++ = value; \ *ptr++ = value; \
} \ } \
@ -1019,8 +1016,7 @@ FILL_BUFFER (gint32, sine2, (gint32) (2147483647 * sinf (i * 1.8f)));
static void static void
run_fft_pipeline (int inrate, int outrate, int quality, int width, gboolean fp, run_fft_pipeline (int inrate, int outrate, int quality, int width, gboolean fp,
void (*init) (GstBuffer *), void (*init) (GstBuffer *), void (*compare_ffts) (GstBuffer *, GstBuffer *))
void (*compare_ffts) (const GstBuffer *, const GstBuffer *))
{ {
GstElement *audioresample; GstElement *audioresample;
GstBuffer *inbuffer, *outbuffer; GstBuffer *inbuffer, *outbuffer;
@ -1030,7 +1026,7 @@ run_fft_pipeline (int inrate, int outrate, int quality, int width, gboolean fp,
audioresample = setup_audioresample (1, inrate, outrate, width, fp); audioresample = setup_audioresample (1, inrate, outrate, width, fp);
fail_unless (audioresample != NULL); fail_unless (audioresample != NULL);
g_object_set (audioresample, "quality", quality, NULL); g_object_set (audioresample, "quality", quality, NULL);
caps = gst_pad_get_negotiated_caps (mysrcpad); caps = gst_pad_get_current_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps)); fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample, fail_unless (gst_element_set_state (audioresample,
@ -1040,7 +1036,7 @@ run_fft_pipeline (int inrate, int outrate, int quality, int width, gboolean fp,
inbuffer = gst_buffer_new_and_alloc (nsamples * width / 8); inbuffer = gst_buffer_new_and_alloc (nsamples * width / 8);
GST_BUFFER_DURATION (inbuffer) = GST_FRAMES_TO_CLOCK_TIME (nsamples, inrate); GST_BUFFER_DURATION (inbuffer) = GST_FRAMES_TO_CLOCK_TIME (nsamples, inrate);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_buffer_ref (inbuffer); gst_buffer_ref (inbuffer);
(*init) (inbuffer); (*init) (inbuffer);

View file

@ -23,6 +23,8 @@
#include <unistd.h> #include <unistd.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/audio/audio.h>
#undef GST_CAT_DEFAULT
#include "../../gst/gdp/dataprotocol.c" #include "../../gst/gdp/dataprotocol.c"
/* For ease of programming we use globals to keep refs for our floating /* For ease of programming we use globals to keep refs for our floating
@ -63,8 +65,8 @@ setup_gdpdepay (void)
GST_DEBUG ("setup_gdpdepay"); GST_DEBUG ("setup_gdpdepay");
gdpdepay = gst_check_setup_element ("gdpdepay"); gdpdepay = gst_check_setup_element ("gdpdepay");
mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate, NULL); mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate);
mysinkpad = gst_check_setup_sink_pad (gdpdepay, &sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (gdpdepay, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE); gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE); gst_pad_set_active (mysinkpad, TRUE);
@ -122,10 +124,10 @@ GST_START_TEST (test_audio_per_byte)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "could not set to playing");
caps = gst_pad_get_caps (srcpad); caps = gst_pad_query_caps (srcpad, NULL);
fail_unless (gst_caps_is_any (caps)); fail_unless (gst_caps_is_any (caps));
gst_caps_unref (caps); gst_caps_unref (caps);
fail_if (gst_pad_get_negotiated_caps (srcpad)); fail_if (gst_pad_get_current_caps (srcpad));
/* create caps and buffer packets and push them */ /* create caps and buffer packets and push them */
caps = gst_caps_from_string (AUDIO_CAPS_STRING); caps = gst_caps_from_string (AUDIO_CAPS_STRING);
@ -136,7 +138,7 @@ GST_START_TEST (test_audio_per_byte)
gdpdepay_push_per_byte ("caps payload", payload, gdpdepay_push_per_byte ("caps payload", payload,
gst_dp_header_payload_length (header)); gst_dp_header_payload_length (header));
fail_unless_equals_int (g_list_length (buffers), 0); fail_unless_equals_int (g_list_length (buffers), 0);
caps = gst_pad_get_caps (srcpad); caps = gst_pad_query_caps (srcpad, NULL);
fail_if (gst_caps_is_any (caps)); fail_if (gst_caps_is_any (caps));
gst_caps_unref (caps); gst_caps_unref (caps);
@ -199,10 +201,10 @@ GST_START_TEST (test_audio_in_one_buffer)
"could not set to playing"); "could not set to playing");
/* make sure no caps are set yet */ /* make sure no caps are set yet */
caps = gst_pad_get_caps (srcpad); caps = gst_pad_query_caps (srcpad, NULL);
fail_unless (gst_caps_is_any (caps)); fail_unless (gst_caps_is_any (caps));
gst_caps_unref (caps); gst_caps_unref (caps);
fail_if (gst_pad_get_negotiated_caps (srcpad)); fail_if (gst_pad_get_current_caps (srcpad));
/* create caps and buffer packets and push them as one buffer */ /* create caps and buffer packets and push them as one buffer */
caps = gst_caps_from_string (AUDIO_CAPS_STRING); caps = gst_caps_from_string (AUDIO_CAPS_STRING);
@ -266,8 +268,8 @@ setup_gdpdepay_streamheader (void)
GST_DEBUG ("setup_gdpdepay"); GST_DEBUG ("setup_gdpdepay");
gdpdepay = gst_check_setup_element ("gdpdepay"); gdpdepay = gst_check_setup_element ("gdpdepay");
mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate, NULL); mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate);
myshsinkpad = gst_check_setup_sink_pad (gdpdepay, &shsinktemplate, NULL); myshsinkpad = gst_check_setup_sink_pad (gdpdepay, &shsinktemplate);
gst_pad_set_active (mysrcpad, TRUE); gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (myshsinkpad, TRUE); gst_pad_set_active (myshsinkpad, TRUE);
@ -278,7 +280,7 @@ setup_gdpdepay_streamheader (void)
* have a streamheader set */ * have a streamheader set */
GST_START_TEST (test_streamheader) GST_START_TEST (test_streamheader)
{ {
GstCaps *caps, *padcaps; GstCaps *caps;
GstPad *srcpad; GstPad *srcpad;
GstElement *gdpdepay; GstElement *gdpdepay;
GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer; GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
@ -302,10 +304,10 @@ GST_START_TEST (test_streamheader)
"could not set to playing"); "could not set to playing");
/* make sure no caps are set yet */ /* make sure no caps are set yet */
caps = gst_pad_get_caps (srcpad); caps = gst_pad_query_caps (srcpad, NULL);
fail_unless (gst_caps_is_any (caps)); fail_unless (gst_caps_is_any (caps));
gst_caps_unref (caps); gst_caps_unref (caps);
fail_if (gst_pad_get_negotiated_caps (srcpad)); fail_if (gst_pad_get_current_caps (srcpad));
/* create a streamheader buffer and the caps containing it */ /* create a streamheader buffer and the caps containing it */
caps = gst_caps_from_string ("application/x-gst-test-streamheader"); caps = gst_caps_from_string ("application/x-gst-test-streamheader");
@ -323,8 +325,6 @@ GST_START_TEST (test_streamheader)
gst_structure_set_value (structure, "streamheader", &array); gst_structure_set_value (structure, "streamheader", &array);
g_value_unset (&array); g_value_unset (&array);
gst_buffer_set_caps (buffer, caps);
/* create GDP packets for the caps and the buffer, and put them in one /* create GDP packets for the caps and the buffer, and put them in one
* GDP buffer */ * GDP buffer */
fail_unless (pk->packet_from_caps (caps, 0, &header_len, &caps_header, fail_unless (pk->packet_from_caps (caps, 0, &header_len, &caps_header,
@ -364,17 +364,8 @@ GST_START_TEST (test_streamheader)
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
fail_unless (GST_BUFFER_FLAG_IS_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS)); fail_unless (GST_BUFFER_FLAG_IS_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS));
padcaps = gst_pad_get_negotiated_caps (myshsinkpad);
caps = gst_buffer_get_caps (outbuffer);
fail_if (caps == NULL);
fail_if (padcaps == NULL);
GST_DEBUG ("caps: %" GST_PTR_FORMAT ", padcaps: %" GST_PTR_FORMAT, caps,
padcaps);
fail_unless (gst_caps_is_equal (padcaps, caps));
/* FIXME: get streamheader, compare data with buffer */ /* FIXME: get streamheader, compare data with buffer */
gst_buffer_unref (outbuffer); gst_buffer_unref (outbuffer);
gst_caps_unref (padcaps);
gst_caps_unref (caps); gst_caps_unref (caps);
/* clean up */ /* clean up */

View file

@ -18,10 +18,13 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include "config.h"
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/audio/audio.h>
#undef GST_CAT_DEFAULT
#include "../../gst/gdp/dataprotocol.c" #include "../../gst/gdp/dataprotocol.c"
/* For ease of programming we use globals to keep refs for our floating /* For ease of programming we use globals to keep refs for our floating
@ -63,8 +66,8 @@ setup_gdppay (void)
GST_DEBUG ("setup_gdppay"); GST_DEBUG ("setup_gdppay");
gdppay = gst_check_setup_element ("gdppay"); gdppay = gst_check_setup_element ("gdppay");
mysrcpad = gst_check_setup_src_pad (gdppay, &srctemplate, NULL); mysrcpad = gst_check_setup_src_pad (gdppay, &srctemplate);
mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE); gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE); gst_pad_set_active (mysinkpad, TRUE);
@ -93,6 +96,7 @@ GST_START_TEST (test_audio)
GstCaps *caps; GstCaps *caps;
GstElement *gdppay; GstElement *gdppay;
GstBuffer *inbuffer, *outbuffer; GstBuffer *inbuffer, *outbuffer;
GstSegment segment;
GstEvent *event; GstEvent *event;
gchar *caps_string; gchar *caps_string;
gint length; gint length;
@ -104,8 +108,9 @@ GST_START_TEST (test_audio)
"could not set to playing"); "could not set to playing");
GST_DEBUG ("new segment"); GST_DEBUG ("new segment");
event = gst_segment_init (&segment, GST_FORMAT_TIME);
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0); segment.stop = GST_SECOND;
event = gst_event_new_segment (&segment);
fail_unless (gst_pad_push_event (mysrcpad, event)); fail_unless (gst_pad_push_event (mysrcpad, event));
/* no buffer should be pushed yet, waiting for caps */ /* no buffer should be pushed yet, waiting for caps */
@ -114,7 +119,7 @@ GST_START_TEST (test_audio)
GST_DEBUG ("first buffer"); GST_DEBUG ("first buffer");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
caps = gst_caps_from_string (AUDIO_CAPS_STRING); caps = gst_caps_from_string (AUDIO_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
caps_string = gst_caps_to_string (caps); caps_string = gst_caps_to_string (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -152,7 +157,6 @@ GST_START_TEST (test_audio)
/* second buffer */ /* second buffer */
GST_DEBUG ("second buffer"); GST_DEBUG ("second buffer");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (inbuffer, caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -217,8 +221,8 @@ setup_gdppay_streamheader (void)
GST_DEBUG ("setup_gdppay"); GST_DEBUG ("setup_gdppay");
gdppay = gst_check_setup_element ("gdppay"); gdppay = gst_check_setup_element ("gdppay");
myshsrcpad = gst_check_setup_src_pad (gdppay, &shsrctemplate, NULL); myshsrcpad = gst_check_setup_src_pad (gdppay, &shsrctemplate);
mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate);
gst_pad_set_active (myshsrcpad, TRUE); gst_pad_set_active (myshsrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE); gst_pad_set_active (mysinkpad, TRUE);
@ -233,6 +237,7 @@ GST_START_TEST (test_streamheader)
GstCaps *caps, *sinkcaps; GstCaps *caps, *sinkcaps;
GstElement *gdppay; GstElement *gdppay;
GstBuffer *inbuffer, *outbuffer, *shbuffer; GstBuffer *inbuffer, *outbuffer, *shbuffer;
GstSegment segment;
GstEvent *event; GstEvent *event;
gchar *caps_string; gchar *caps_string;
gint length; gint length;
@ -250,8 +255,9 @@ GST_START_TEST (test_streamheader)
"could not set to playing"); "could not set to playing");
GST_DEBUG ("new segment"); GST_DEBUG ("new segment");
event = gst_segment_init (&segment, GST_FORMAT_TIME);
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0); segment.stop = GST_SECOND;
event = gst_event_new_segment (&segment);
fail_unless (gst_pad_push_event (myshsrcpad, event)); fail_unless (gst_pad_push_event (myshsrcpad, event));
/* no buffer should be pushed yet, still waiting for caps */ /* no buffer should be pushed yet, still waiting for caps */
@ -274,7 +280,7 @@ GST_START_TEST (test_streamheader)
g_value_unset (&array); g_value_unset (&array);
caps_string = gst_caps_to_string (caps); caps_string = gst_caps_to_string (caps);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (myshsrcpad, caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference */ /* pushing gives away my reference */
@ -285,7 +291,7 @@ GST_START_TEST (test_streamheader)
/* our sink pad should now have GDP caps with a streamheader that includes /* our sink pad should now have GDP caps with a streamheader that includes
* GDP wrappings of our streamheader */ * GDP wrappings of our streamheader */
sinkcaps = gst_pad_get_negotiated_caps (mysinkpad); sinkcaps = gst_pad_get_current_caps (mysinkpad);
structure = gst_caps_get_structure (sinkcaps, 0); structure = gst_caps_get_structure (sinkcaps, 0);
fail_unless_equals_string ((gchar *) gst_structure_get_name (structure), fail_unless_equals_string ((gchar *) gst_structure_get_name (structure),
"application/x-gdp"); "application/x-gdp");
@ -326,7 +332,6 @@ GST_START_TEST (test_streamheader)
/* second buffer */ /* second buffer */
GST_DEBUG ("second buffer"); GST_DEBUG ("second buffer");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (inbuffer, caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -427,7 +432,7 @@ GST_START_TEST (test_first_no_new_segment)
GST_DEBUG ("first buffer"); GST_DEBUG ("first buffer");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
caps = gst_caps_from_string (AUDIO_CAPS_STRING); caps = gst_caps_from_string (AUDIO_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -457,6 +462,7 @@ GST_START_TEST (test_crc)
GstCaps *caps; GstCaps *caps;
GstElement *gdppay; GstElement *gdppay;
GstBuffer *inbuffer, *outbuffer; GstBuffer *inbuffer, *outbuffer;
GstSegment segment;
GstEvent *event; GstEvent *event;
gchar *caps_string; gchar *caps_string;
gint length; gint length;
@ -472,8 +478,8 @@ GST_START_TEST (test_crc)
"could not set to playing"); "could not set to playing");
GST_DEBUG ("new segment"); GST_DEBUG ("new segment");
event = gst_segment_init (&segment, GST_FORMAT_TIME);
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0); event = gst_event_new_segment (&segment);
fail_unless (gst_pad_push_event (mysrcpad, event)); fail_unless (gst_pad_push_event (mysrcpad, event));
/* no buffer should be pushed yet, waiting for caps */ /* no buffer should be pushed yet, waiting for caps */
@ -482,7 +488,7 @@ GST_START_TEST (test_crc)
GST_DEBUG ("first buffer"); GST_DEBUG ("first buffer");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
caps = gst_caps_from_string (AUDIO_CAPS_STRING); caps = gst_caps_from_string (AUDIO_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
caps_string = gst_caps_to_string (caps); caps_string = gst_caps_to_string (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

View file

@ -41,7 +41,7 @@ setup_multifdsink (void)
GST_DEBUG ("setup_multifdsink"); GST_DEBUG ("setup_multifdsink");
multifdsink = gst_check_setup_element ("multifdsink"); multifdsink = gst_check_setup_element ("multifdsink");
mysrcpad = gst_check_setup_src_pad (multifdsink, &srctemplate, NULL); mysrcpad = gst_check_setup_src_pad (multifdsink, &srctemplate);
return multifdsink; return multifdsink;
} }
@ -88,7 +88,7 @@ GST_START_TEST (test_no_clients)
caps = gst_caps_from_string ("application/x-gst-check"); caps = gst_caps_from_string ("application/x-gst-check");
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
@ -119,7 +119,7 @@ GST_START_TEST (test_add_client)
caps = gst_caps_from_string ("application/x-gst-check"); caps = gst_caps_from_string ("application/x-gst-check");
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps); GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps); gst_pad_set_caps (mysrcpad, caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 2); ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
gst_buffer_fill (buffer, 0, "dead", 4); gst_buffer_fill (buffer, 0, "dead", 4);
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
@ -207,11 +207,6 @@ gst_multifdsink_create_streamheader (const gchar * data1,
g_value_unset (&array); g_value_unset (&array);
ASSERT_CAPS_REFCOUNT (*caps, "streamheader caps", 1); ASSERT_CAPS_REFCOUNT (*caps, "streamheader caps", 1);
/* set our streamheadery caps on the buffers */
gst_buffer_set_caps (*hbuf1, *caps);
gst_buffer_set_caps (*hbuf2, *caps);
ASSERT_CAPS_REFCOUNT (*caps, "streamheader caps", 3);
/* we want to keep them around for the tests */ /* we want to keep them around for the tests */
gst_buffer_ref (*hbuf1); gst_buffer_ref (*hbuf1);
gst_buffer_ref (*hbuf2); gst_buffer_ref (*hbuf2);
@ -459,6 +454,7 @@ GST_START_TEST (test_burst_client_bytes)
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC); ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
caps = gst_caps_from_string ("application/x-gst-check"); caps = gst_caps_from_string ("application/x-gst-check");
gst_pad_set_caps (mysrcpad, caps);
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps); GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
/* push buffers in, 9 * 16 bytes = 144 bytes */ /* push buffers in, 9 * 16 bytes = 144 bytes */
@ -466,7 +462,6 @@ GST_START_TEST (test_burst_client_bytes)
gchar *data; gchar *data;
buffer = gst_buffer_new_and_alloc (16); buffer = gst_buffer_new_and_alloc (16);
gst_buffer_set_caps (buffer, caps);
/* copy some id */ /* copy some id */
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE); data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
@ -492,7 +487,6 @@ GST_START_TEST (test_burst_client_bytes)
gchar *data; gchar *data;
buffer = gst_buffer_new_and_alloc (16); buffer = gst_buffer_new_and_alloc (16);
gst_buffer_set_caps (buffer, caps);
/* copy some id */ /* copy some id */
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE); data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
@ -575,13 +569,13 @@ GST_START_TEST (test_burst_client_bytes_keyframe)
caps = gst_caps_from_string ("application/x-gst-check"); caps = gst_caps_from_string ("application/x-gst-check");
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps); GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
gst_pad_set_caps (mysrcpad, caps);
/* push buffers in, 9 * 16 bytes = 144 bytes */ /* push buffers in, 9 * 16 bytes = 144 bytes */
for (i = 0; i < 9; i++) { for (i = 0; i < 9; i++) {
gchar *data; gchar *data;
buffer = gst_buffer_new_and_alloc (16); buffer = gst_buffer_new_and_alloc (16);
gst_buffer_set_caps (buffer, caps);
/* mark most buffers as delta */ /* mark most buffers as delta */
if (i != 0 && i != 4 && i != 8) if (i != 0 && i != 4 && i != 8)
@ -611,7 +605,6 @@ GST_START_TEST (test_burst_client_bytes_keyframe)
gchar *data; gchar *data;
buffer = gst_buffer_new_and_alloc (16); buffer = gst_buffer_new_and_alloc (16);
gst_buffer_set_caps (buffer, caps);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT); GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
/* copy some id */ /* copy some id */
@ -691,6 +684,7 @@ GST_START_TEST (test_burst_client_bytes_with_keyframe)
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC); ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
caps = gst_caps_from_string ("application/x-gst-check"); caps = gst_caps_from_string ("application/x-gst-check");
gst_pad_set_caps (mysrcpad, caps);
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps); GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
/* push buffers in, 9 * 16 bytes = 144 bytes */ /* push buffers in, 9 * 16 bytes = 144 bytes */
@ -698,7 +692,6 @@ GST_START_TEST (test_burst_client_bytes_with_keyframe)
gchar *data; gchar *data;
buffer = gst_buffer_new_and_alloc (16); buffer = gst_buffer_new_and_alloc (16);
gst_buffer_set_caps (buffer, caps);
/* mark most buffers as delta */ /* mark most buffers as delta */
if (i != 0 && i != 4 && i != 8) if (i != 0 && i != 4 && i != 8)
@ -728,7 +721,6 @@ GST_START_TEST (test_burst_client_bytes_with_keyframe)
gchar *data; gchar *data;
buffer = gst_buffer_new_and_alloc (16); buffer = gst_buffer_new_and_alloc (16);
gst_buffer_set_caps (buffer, caps);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT); GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
/* copy some id */ /* copy some id */
@ -806,6 +798,7 @@ GST_START_TEST (test_client_next_keyframe)
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC); ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
caps = gst_caps_from_string ("application/x-gst-check"); caps = gst_caps_from_string ("application/x-gst-check");
gst_pad_set_caps (mysrcpad, caps);
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps); GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
/* now add our client */ /* now add our client */
@ -816,7 +809,6 @@ GST_START_TEST (test_client_next_keyframe)
gchar *data; gchar *data;
buffer = gst_buffer_new_and_alloc (16); buffer = gst_buffer_new_and_alloc (16);
gst_buffer_set_caps (buffer, caps);
/* copy some id */ /* copy some id */
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE); data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);

View file

@ -38,8 +38,6 @@ static GType gst_codec_sink_get_type (void);
static GType gst_audio_codec_sink_get_type (void); static GType gst_audio_codec_sink_get_type (void);
static GType gst_video_codec_sink_get_type (void); static GType gst_video_codec_sink_get_type (void);
#undef parent_class
#define parent_class caps_src_parent_class
typedef struct _GstCapsSrc GstCapsSrc; typedef struct _GstCapsSrc GstCapsSrc;
typedef GstPushSrcClass GstCapsSrcClass; typedef GstPushSrcClass GstCapsSrcClass;
@ -53,29 +51,30 @@ struct _GstCapsSrc
}; };
static GstURIType static GstURIType
gst_caps_src_uri_get_type (void) gst_caps_src_uri_get_type (GType type)
{ {
return GST_URI_SRC; return GST_URI_SRC;
} }
static const gchar *const * static const gchar *const *
gst_caps_src_uri_get_protocols (void) gst_caps_src_uri_get_protocols (GType type)
{ {
static const gchar *protocols[] = { "caps", NULL }; static const gchar *protocols[] = { "caps", NULL };
return protocols; return protocols;
} }
static const gchar * static gchar *
gst_caps_src_uri_get_uri (GstURIHandler * handler) gst_caps_src_uri_get_uri (GstURIHandler * handler)
{ {
GstCapsSrc *src = (GstCapsSrc *) handler; GstCapsSrc *src = (GstCapsSrc *) handler;
return src->uri; return g_strdup (src->uri);
} }
static gboolean static gboolean
gst_caps_src_uri_set_uri (GstURIHandler * handler, const gchar * uri) gst_caps_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{ {
GstCapsSrc *src = (GstCapsSrc *) handler; GstCapsSrc *src = (GstCapsSrc *) handler;
@ -103,32 +102,9 @@ gst_caps_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
iface->set_uri = gst_caps_src_uri_set_uri; iface->set_uri = gst_caps_src_uri_set_uri;
} }
static void G_DEFINE_TYPE_WITH_CODE (GstCapsSrc, gst_caps_src, GST_TYPE_PUSH_SRC,
gst_caps_src_init_type (GType type) G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
{ gst_caps_src_uri_handler_init));
static const GInterfaceInfo uri_hdlr_info = {
gst_caps_src_uri_handler_init, NULL, NULL
};
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &uri_hdlr_info);
}
GST_BOILERPLATE_FULL (GstCapsSrc, gst_caps_src, GstPushSrc,
GST_TYPE_PUSH_SRC, gst_caps_src_init_type);
static void
gst_caps_src_base_init (gpointer klass)
{
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_templ));
gst_element_class_set_details_simple (element_class,
"CapsSource", "Source/Generic", "yep", "me");
}
static void static void
gst_caps_src_finalize (GObject * object) gst_caps_src_finalize (GObject * object)
@ -140,7 +116,7 @@ gst_caps_src_finalize (GObject * object)
src->caps = NULL; src->caps = NULL;
g_free (src->uri); g_free (src->uri);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (gst_caps_src_parent_class)->finalize (object);
} }
static GstFlowReturn static GstFlowReturn
@ -150,7 +126,7 @@ gst_caps_src_create (GstPushSrc * psrc, GstBuffer ** p_buf)
GstBuffer *buf; GstBuffer *buf;
if (src->nbuffers >= NBUFFERS) { if (src->nbuffers >= NBUFFERS) {
return GST_FLOW_UNEXPECTED; return GST_FLOW_EOS;
} }
if (!src->caps) { if (!src->caps) {
@ -165,7 +141,6 @@ gst_caps_src_create (GstPushSrc * psrc, GstBuffer ** p_buf)
} }
buf = gst_buffer_new (); buf = gst_buffer_new ();
gst_buffer_set_caps (buf, src->caps);
GST_BUFFER_TIMESTAMP (buf) = GST_BUFFER_TIMESTAMP (buf) =
gst_util_uint64_scale (src->nbuffers, GST_SECOND, 25); gst_util_uint64_scale (src->nbuffers, GST_SECOND, 25);
src->nbuffers++; src->nbuffers++;
@ -178,21 +153,27 @@ static void
gst_caps_src_class_init (GstCapsSrcClass * klass) gst_caps_src_class_init (GstCapsSrcClass * klass)
{ {
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstPushSrcClass *pushsrc_class = (GstPushSrcClass *) klass; GstPushSrcClass *pushsrc_class = (GstPushSrcClass *) klass;
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_templ));
gst_element_class_set_details_simple (element_class,
"CapsSource", "Source/Generic", "yep", "me");
gobject_class->finalize = gst_caps_src_finalize; gobject_class->finalize = gst_caps_src_finalize;
pushsrc_class->create = gst_caps_src_create; pushsrc_class->create = gst_caps_src_create;
} }
static void static void
gst_caps_src_init (GstCapsSrc * src, GstCapsSrcClass * klass) gst_caps_src_init (GstCapsSrc * src)
{ {
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
} }
#undef parent_class
#define parent_class codec_sink_parent_class
typedef struct _GstCodecSink GstCodecSink; typedef struct _GstCodecSink GstCodecSink;
typedef GstBaseSinkClass GstCodecSinkClass; typedef GstBaseSinkClass GstCodecSinkClass;
@ -205,12 +186,7 @@ struct _GstCodecSink
gint n_raw, n_compressed; gint n_raw, n_compressed;
}; };
GST_BOILERPLATE (GstCodecSink, gst_codec_sink, GstBaseSink, GST_TYPE_BASE_SINK); G_DEFINE_TYPE (GstCodecSink, gst_codec_sink, GST_TYPE_BASE_SINK);
static void
gst_codec_sink_base_init (gpointer klass)
{
}
static gboolean static gboolean
gst_codec_sink_start (GstBaseSink * bsink) gst_codec_sink_start (GstBaseSink * bsink)
@ -246,43 +222,16 @@ gst_codec_sink_class_init (GstCodecSinkClass * klass)
} }
static void static void
gst_codec_sink_init (GstCodecSink * sink, GstCodecSinkClass * klass) gst_codec_sink_init (GstCodecSink * sink)
{ {
} }
#undef parent_class
#define parent_class audio_codec_sink_parent_class
typedef GstCodecSink GstAudioCodecSink; typedef GstCodecSink GstAudioCodecSink;
typedef GstCodecSinkClass GstAudioCodecSinkClass; typedef GstCodecSinkClass GstAudioCodecSinkClass;
static void G_DEFINE_TYPE_WITH_CODE (GstAudioCodecSink, gst_audio_codec_sink,
gst_audio_codec_sink_init_type (GType type) gst_codec_sink_get_type (),
{ G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL));
static const GInterfaceInfo svol_iface_info = {
NULL, NULL, NULL
};
g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_iface_info);
}
GST_BOILERPLATE_FULL (GstAudioCodecSink, gst_audio_codec_sink, GstBaseSink,
gst_codec_sink_get_type (), gst_audio_codec_sink_init_type);
static void
gst_audio_codec_sink_base_init (gpointer klass)
{
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw; audio/x-compressed")
);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_templ));
gst_element_class_set_details_simple (element_class,
"AudioCodecSink", "Sink/Audio", "yep", "me");
}
static void static void
gst_audio_codec_sink_set_property (GObject * object, gst_audio_codec_sink_set_property (GObject * object,
@ -341,7 +290,12 @@ static void
gst_audio_codec_sink_class_init (GstAudioCodecSinkClass * klass) gst_audio_codec_sink_class_init (GstAudioCodecSinkClass * klass)
{ {
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass; GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw; audio/x-compressed")
);
gobject_class->set_property = gst_audio_codec_sink_set_property; gobject_class->set_property = gst_audio_codec_sink_set_property;
gobject_class->get_property = gst_audio_codec_sink_get_property; gobject_class->get_property = gst_audio_codec_sink_get_property;
@ -356,40 +310,26 @@ gst_audio_codec_sink_class_init (GstAudioCodecSinkClass * klass)
g_param_spec_boolean ("mute", "Mute", g_param_spec_boolean ("mute", "Mute",
"Mute", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); "Mute", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_templ));
gst_element_class_set_details_simple (element_class,
"AudioCodecSink", "Sink/Audio", "yep", "me");
basesink_class->set_caps = gst_audio_codec_sink_set_caps; basesink_class->set_caps = gst_audio_codec_sink_set_caps;
} }
static void static void
gst_audio_codec_sink_init (GstAudioCodecSink * sink, gst_audio_codec_sink_init (GstAudioCodecSink * sink)
GstAudioCodecSinkClass * klass)
{ {
sink->audio = TRUE; sink->audio = TRUE;
} }
#undef parent_class
#define parent_class video_codec_sink_parent_class
typedef GstCodecSink GstVideoCodecSink; typedef GstCodecSink GstVideoCodecSink;
typedef GstCodecSinkClass GstVideoCodecSinkClass; typedef GstCodecSinkClass GstVideoCodecSinkClass;
GST_BOILERPLATE (GstVideoCodecSink, gst_video_codec_sink, GstBaseSink, G_DEFINE_TYPE (GstVideoCodecSink, gst_video_codec_sink,
gst_codec_sink_get_type ()); gst_codec_sink_get_type ());
static void
gst_video_codec_sink_base_init (gpointer klass)
{
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw; video/x-compressed")
);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_templ));
gst_element_class_set_details_simple (element_class,
"VideoCodecSink", "Sink/Video", "yep", "me");
}
static gboolean static gboolean
gst_video_codec_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) gst_video_codec_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
{ {
@ -415,19 +355,26 @@ static void
gst_video_codec_sink_class_init (GstVideoCodecSinkClass * klass) gst_video_codec_sink_class_init (GstVideoCodecSinkClass * klass)
{ {
GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass; GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw; video/x-compressed")
);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_templ));
gst_element_class_set_details_simple (element_class,
"VideoCodecSink", "Sink/Video", "yep", "me");
basesink_class->set_caps = gst_video_codec_sink_set_caps; basesink_class->set_caps = gst_video_codec_sink_set_caps;
} }
static void static void
gst_video_codec_sink_init (GstVideoCodecSink * sink, gst_video_codec_sink_init (GstVideoCodecSink * sink)
GstVideoCodecSinkClass * klass)
{ {
sink->audio = FALSE; sink->audio = FALSE;
} }
#undef parent_class
#define parent_class codec_demuxer_parent_class
typedef struct _GstCodecDemuxer GstCodecDemuxer; typedef struct _GstCodecDemuxer GstCodecDemuxer;
typedef GstElementClass GstCodecDemuxerClass; typedef GstElementClass GstCodecDemuxerClass;
@ -441,9 +388,6 @@ struct _GstCodecDemuxer
GstEvent *newseg_event; GstEvent *newseg_event;
}; };
GST_BOILERPLATE (GstCodecDemuxer, gst_codec_demuxer, GstElement,
GST_TYPE_ELEMENT);
#define STREAM_TYPES "{ " \ #define STREAM_TYPES "{ " \
"none, " \ "none, " \
"raw-audio, " \ "raw-audio, " \
@ -452,29 +396,19 @@ GST_BOILERPLATE (GstCodecDemuxer, gst_codec_demuxer, GstElement,
"compressed-video " \ "compressed-video " \
"}" "}"
static void static GstStaticPadTemplate cd_sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
gst_codec_demuxer_base_init (gpointer klass) GST_PAD_SINK, GST_PAD_ALWAYS,
{ GST_STATIC_CAPS ("application/x-container,"
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink", " stream0 = (string)" STREAM_TYPES " ,"
GST_PAD_SINK, GST_PAD_ALWAYS, " stream1 = (string)" STREAM_TYPES)
GST_STATIC_CAPS ("application/x-container," );
" stream0 = (string)" STREAM_TYPES " ," static GstStaticPadTemplate cd_src_templ = GST_STATIC_PAD_TEMPLATE ("src_%d",
" stream1 = (string)" STREAM_TYPES) GST_PAD_SRC, GST_PAD_SOMETIMES,
); GST_STATIC_CAPS ("audio/x-raw; audio/x-compressed; "
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src_%d", "video/x-raw; video/x-compressed")
GST_PAD_SRC, GST_PAD_SOMETIMES, );
GST_STATIC_CAPS ("audio/x-raw; audio/x-compressed; "
"video/x-raw; video/x-compressed")
);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, G_DEFINE_TYPE (GstCodecDemuxer, gst_codec_demuxer, GST_TYPE_ELEMENT);
gst_static_pad_template_get (&sink_templ));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_templ));
gst_element_class_set_details_simple (element_class,
"CodecDemuxer", "Codec/Demuxer", "yep", "me");
}
static void static void
gst_codec_demuxer_finalize (GObject * object) gst_codec_demuxer_finalize (GObject * object)
@ -485,35 +419,41 @@ gst_codec_demuxer_finalize (GObject * object)
gst_event_unref (demux->newseg_event); gst_event_unref (demux->newseg_event);
demux->newseg_event = NULL; demux->newseg_event = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (gst_codec_demuxer_parent_class)->finalize (object);
} }
static void static void
gst_codec_demuxer_class_init (GstCodecDemuxerClass * klass) gst_codec_demuxer_class_init (GstCodecDemuxerClass * klass)
{ {
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gobject_class->finalize = gst_codec_demuxer_finalize; gobject_class->finalize = gst_codec_demuxer_finalize;
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&cd_sink_templ));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&cd_src_templ));
gst_element_class_set_details_simple (element_class,
"CodecDemuxer", "Codec/Demuxer", "yep", "me");
} }
static GstFlowReturn static GstFlowReturn
gst_codec_demuxer_chain (GstPad * pad, GstBuffer * buf) gst_codec_demuxer_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{ {
GstCodecDemuxer *demux = (GstCodecDemuxer *) GST_PAD_PARENT (pad); GstCodecDemuxer *demux = (GstCodecDemuxer *) parent;
GstFlowReturn ret0 = GST_FLOW_OK, ret1 = GST_FLOW_OK; GstFlowReturn ret0 = GST_FLOW_OK, ret1 = GST_FLOW_OK;
if (demux->srcpad0) { if (demux->srcpad0) {
GstBuffer *outbuf = gst_buffer_new (); GstBuffer *outbuf = gst_buffer_new ();
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (demux->srcpad0));
ret0 = gst_pad_push (demux->srcpad0, outbuf); ret0 = gst_pad_push (demux->srcpad0, outbuf);
} }
if (demux->srcpad1) { if (demux->srcpad1) {
GstBuffer *outbuf = gst_buffer_new (); GstBuffer *outbuf = gst_buffer_new ();
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (demux->srcpad1));
ret1 = gst_pad_push (demux->srcpad1, outbuf); ret1 = gst_pad_push (demux->srcpad1, outbuf);
} }
gst_buffer_unref (buf); gst_buffer_unref (buf);
@ -526,28 +466,6 @@ gst_codec_demuxer_chain (GstPad * pad, GstBuffer * buf)
return MIN (ret0, ret1); return MIN (ret0, ret1);
} }
static gboolean
gst_codec_demuxer_event (GstPad * pad, GstEvent * event)
{
GstCodecDemuxer *demux = (GstCodecDemuxer *) gst_pad_get_parent (pad);
gboolean ret = TRUE;
/* The single newsegment event is pushed when the pads are created */
if (GST_EVENT_TYPE (event) != GST_EVENT_NEWSEGMENT) {
if (demux->srcpad0)
ret = ret && gst_pad_push_event (demux->srcpad0, gst_event_ref (event));
if (demux->srcpad1)
ret = ret && gst_pad_push_event (demux->srcpad1, gst_event_ref (event));
} else {
gst_event_replace (&demux->newseg_event, event);
}
gst_event_unref (event);
gst_object_unref (demux);
return ret;
}
static void static void
gst_codec_demuxer_setup_pad (GstCodecDemuxer * demux, GstPad ** pad, gst_codec_demuxer_setup_pad (GstCodecDemuxer * demux, GstPad ** pad,
const gchar * streaminfo) const gchar * streaminfo)
@ -578,19 +496,19 @@ gst_codec_demuxer_setup_pad (GstCodecDemuxer * demux, GstPad ** pad,
if (g_str_equal (streaminfo, "raw-video")) { if (g_str_equal (streaminfo, "raw-video")) {
caps = gst_caps_new_simple ("video/x-raw", caps = gst_caps_new_simple ("video/x-raw",
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'), "format", G_TYPE_STRING, "I420",
"width", G_TYPE_INT, 320, "width", G_TYPE_INT, 320,
"height", G_TYPE_INT, 240, "height", G_TYPE_INT, 240,
"framerate", GST_TYPE_FRACTION, 25, 1, "framerate", GST_TYPE_FRACTION, 25, 1,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL); "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
} else if (g_str_equal (streaminfo, "compressed-video")) { } else if (g_str_equal (streaminfo, "compressed-video")) {
caps = gst_caps_new_simple ("video/x-compressed", NULL); caps = gst_caps_new_empty_simple ("video/x-compressed");
} else if (g_str_equal (streaminfo, "raw-audio")) { } else if (g_str_equal (streaminfo, "raw-audio")) {
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S16LE", "format", G_TYPE_STRING, "S16LE",
"rate", G_TYPE_INT, 48000, "channels", G_TYPE_INT, 2, NULL); "rate", G_TYPE_INT, 48000, "channels", G_TYPE_INT, 2, NULL);
} else { } else {
caps = gst_caps_new_simple ("audio/x-compressed", NULL); caps = gst_caps_new_empty_simple ("audio/x-compressed");
} }
gst_pad_set_caps (*pad, caps); gst_pad_set_caps (*pad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -601,9 +519,9 @@ gst_codec_demuxer_setup_pad (GstCodecDemuxer * demux, GstPad ** pad,
} }
static gboolean static gboolean
gst_codec_demuxer_setcaps (GstPad * pad, GstCaps * caps) gst_codec_demuxer_setcaps (GstPad * pad, GstObject * parent, GstCaps * caps)
{ {
GstCodecDemuxer *demux = (GstCodecDemuxer *) gst_pad_get_parent (pad); GstCodecDemuxer *demux = (GstCodecDemuxer *) parent;
GstStructure *s; GstStructure *s;
const gchar *streaminfo; const gchar *streaminfo;
@ -615,19 +533,44 @@ gst_codec_demuxer_setcaps (GstPad * pad, GstCaps * caps)
streaminfo = gst_structure_get_string (s, "stream1"); streaminfo = gst_structure_get_string (s, "stream1");
gst_codec_demuxer_setup_pad (demux, &demux->srcpad1, streaminfo); gst_codec_demuxer_setup_pad (demux, &demux->srcpad1, streaminfo);
gst_object_unref (demux);
return TRUE; return TRUE;
} }
static void static gboolean
gst_codec_demuxer_init (GstCodecDemuxer * demux, GstCodecDemuxerClass * klass) gst_codec_demuxer_event (GstPad * pad, GstObject * parent, GstEvent * event)
{ {
GstPadTemplate *templ; GstCodecDemuxer *demux = (GstCodecDemuxer *) parent;
gboolean ret = TRUE;
templ = gst_element_class_get_pad_template (klass, "sink"); /* The single newsegment event is pushed when the pads are created */
demux->sinkpad = gst_pad_new_from_template (templ, "sink"); switch (GST_EVENT_TYPE (event)) {
gst_pad_set_setcaps_function (demux->sinkpad, case GST_EVENT_CAPS:
GST_DEBUG_FUNCPTR (gst_codec_demuxer_setcaps)); {
GstCaps *caps;
gst_event_parse_caps (event, &caps);
ret = gst_codec_demuxer_setcaps (pad, parent, caps);
break;
}
case GST_EVENT_SEGMENT:
gst_event_replace (&demux->newseg_event, event);
break;
default:
if (demux->srcpad0)
ret = ret && gst_pad_push_event (demux->srcpad0, gst_event_ref (event));
if (demux->srcpad1)
ret = ret && gst_pad_push_event (demux->srcpad1, gst_event_ref (event));
break;
}
gst_event_unref (event);
return ret;
}
static void
gst_codec_demuxer_init (GstCodecDemuxer * demux)
{
demux->sinkpad = gst_pad_new_from_static_template (&cd_sink_templ, "sink");
gst_pad_set_chain_function (demux->sinkpad, gst_pad_set_chain_function (demux->sinkpad,
GST_DEBUG_FUNCPTR (gst_codec_demuxer_chain)); GST_DEBUG_FUNCPTR (gst_codec_demuxer_chain));
gst_pad_set_event_function (demux->sinkpad, gst_pad_set_event_function (demux->sinkpad,

View file

@ -477,7 +477,8 @@ GST_START_TEST (test_source_setup)
GstElement *playbin, *videosink; GstElement *playbin, *videosink;
GstElement *src = NULL; GstElement *src = NULL;
if (!gst_default_registry_check_feature_version ("redvideosrc", 0, 10, 0)) { if (!gst_registry_check_feature_version (gst_registry_get (), "redvideosrc",
0, 10, 0)) {
fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY, fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
gst_red_video_src_get_type ())); gst_red_video_src_get_type ()));
} }
@ -510,27 +511,28 @@ GST_END_TEST;
/*** redvideo:// source ***/ /*** redvideo:// source ***/
static GstURIType static GstURIType
gst_red_video_src_uri_get_type (void) gst_red_video_src_uri_get_type (GType type)
{ {
return GST_URI_SRC; return GST_URI_SRC;
} }
static const gchar *const * static const gchar *const *
gst_red_video_src_uri_get_protocols (void) gst_red_video_src_uri_get_protocols (GType type)
{ {
static const gchar *protocols[] = { "redvideo", NULL }; static const gchar *protocols[] = { "redvideo", NULL };
return protocols; return protocols;
} }
static const gchar * static gchar *
gst_red_video_src_uri_get_uri (GstURIHandler * handler) gst_red_video_src_uri_get_uri (GstURIHandler * handler)
{ {
return "redvideo://"; return g_strdup ("redvideo://");
} }
static gboolean static gboolean
gst_red_video_src_uri_set_uri (GstURIHandler * handler, const gchar * uri) gst_red_video_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{ {
return (uri != NULL && g_str_has_prefix (uri, "redvideo:")); return (uri != NULL && g_str_has_prefix (uri, "redvideo:"));
} }
@ -586,8 +588,8 @@ static GstCaps *
gst_red_video_src_get_caps (GstBaseSrc * src, GstCaps * filter) gst_red_video_src_get_caps (GstBaseSrc * src, GstCaps * filter)
{ {
guint w = 64, h = 64; guint w = 64, h = 64;
return gst_caps_new_simple ("video/x-raw", "format", GST_TYPE_FOURCC, return gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
GST_MAKE_FOURCC ('I', '4', '2', '0'), "width", G_TYPE_INT, w, "height", "I420", "width", G_TYPE_INT, w, "height",
G_TYPE_INT, h, "framerate", GST_TYPE_FRACTION, 1, 1, NULL); G_TYPE_INT, h, "framerate", GST_TYPE_FRACTION, 1, 1, NULL);
} }
@ -619,27 +621,28 @@ gst_red_video_src_init (GstRedVideoSrc * src)
/*** codec:// source ***/ /*** codec:// source ***/
static GstURIType static GstURIType
gst_codec_src_uri_get_type (void) gst_codec_src_uri_get_type (GType type)
{ {
return GST_URI_SRC; return GST_URI_SRC;
} }
static gchar ** static const gchar *const *
gst_codec_src_uri_get_protocols (void) gst_codec_src_uri_get_protocols (GType type)
{ {
static gchar *protocols[] = { (char *) "codec", NULL }; static const gchar *protocols[] = { (char *) "codec", NULL };
return protocols; return protocols;
} }
static const gchar * static gchar *
gst_codec_src_uri_get_uri (GstURIHandler * handler) gst_codec_src_uri_get_uri (GstURIHandler * handler)
{ {
return "codec://"; return g_strdup ("codec://");
} }
static gboolean static gboolean
gst_codec_src_uri_set_uri (GstURIHandler * handler, const gchar * uri) gst_codec_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{ {
return (uri != NULL && g_str_has_prefix (uri, "codec:")); return (uri != NULL && g_str_has_prefix (uri, "codec:"));
} }
@ -692,7 +695,7 @@ gst_codec_src_create (GstPushSrc * src, GstBuffer ** p_buf)
static GstCaps * static GstCaps *
gst_codec_src_get_caps (GstBaseSrc * src, GstCaps * filter) gst_codec_src_get_caps (GstBaseSrc * src, GstCaps * filter)
{ {
return gst_caps_new_simple ("application/x-codec", NULL); return gst_caps_new_empty_simple ("application/x-codec");
} }
static void static void

View file

@ -48,7 +48,7 @@ buffer_from_static_string (const gchar * s)
len = strlen (s); len = strlen (s);
buf = gst_buffer_new (); buf = gst_buffer_new ();
gst_buffer_take_memory (buf, gst_buffer_take_memory (buf, -1,
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
(gpointer) s, NULL, len, 0, len)); (gpointer) s, NULL, len, 0, len));
@ -159,8 +159,8 @@ setup_subparse (void)
{ {
subparse = gst_check_setup_element ("subparse"); subparse = gst_check_setup_element ("subparse");
mysrcpad = gst_check_setup_src_pad (subparse, &srctemplate, NULL); mysrcpad = gst_check_setup_src_pad (subparse, &srctemplate);
mysinkpad = gst_check_setup_sink_pad (subparse, &sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (subparse, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE); gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE); gst_pad_set_active (mysinkpad, TRUE);
@ -192,6 +192,7 @@ static void
test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num) test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num)
{ {
guint n; guint n;
GstCaps *outcaps;
GST_LOG ("srt test: start_idx = %u, num = %u", start_idx, num); GST_LOG ("srt test: start_idx = %u, num = %u", start_idx, num);
@ -208,6 +209,8 @@ test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num)
fail_unless_equals_int (g_list_length (buffers), num); fail_unless_equals_int (g_list_length (buffers), num);
outcaps = gst_pad_get_current_caps (mysinkpad);
for (n = start_idx; n < start_idx + num; ++n) { for (n = start_idx; n < start_idx + num; ++n) {
const GstStructure *buffer_caps_struct; const GstStructure *buffer_caps_struct;
GstBuffer *buf; GstBuffer *buf;
@ -236,11 +239,12 @@ test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num)
} }
gst_buffer_unmap (buf, out, out_size); gst_buffer_unmap (buf, out, out_size);
/* check caps */ /* check caps */
fail_unless (GST_BUFFER_CAPS (buf) != NULL); fail_unless (outcaps != NULL);
buffer_caps_struct = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0); buffer_caps_struct = gst_caps_get_structure (outcaps, 0);
fail_unless_equals_string (gst_structure_get_name (buffer_caps_struct), fail_unless_equals_string (gst_structure_get_name (buffer_caps_struct),
"text/x-pango-markup"); "text/x-pango-markup");
} }
gst_caps_unref (outcaps);
teardown_subparse (); teardown_subparse ();
} }
@ -277,6 +281,7 @@ static void
do_test (SubParseInputChunk * input, guint num, const gchar * media_type) do_test (SubParseInputChunk * input, guint num, const gchar * media_type)
{ {
guint n; guint n;
GstCaps *outcaps;
setup_subparse (); setup_subparse ();
@ -291,6 +296,8 @@ do_test (SubParseInputChunk * input, guint num, const gchar * media_type)
fail_unless_equals_int (g_list_length (buffers), num); fail_unless_equals_int (g_list_length (buffers), num);
outcaps = gst_pad_get_current_caps (mysinkpad);
for (n = 0; n < num; ++n) { for (n = 0; n < num; ++n) {
const GstStructure *buffer_caps_struct; const GstStructure *buffer_caps_struct;
GstBuffer *buf; GstBuffer *buf;
@ -326,11 +333,12 @@ do_test (SubParseInputChunk * input, guint num, const gchar * media_type)
} }
gst_buffer_unmap (buf, out, out_size); gst_buffer_unmap (buf, out, out_size);
/* check caps */ /* check caps */
fail_unless (GST_BUFFER_CAPS (buf) != NULL); fail_unless (outcaps != NULL);
buffer_caps_struct = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0); buffer_caps_struct = gst_caps_get_structure (outcaps, 0);
fail_unless_equals_string (gst_structure_get_name (buffer_caps_struct), fail_unless_equals_string (gst_structure_get_name (buffer_caps_struct),
media_type); media_type);
} }
gst_caps_unref (outcaps);
teardown_subparse (); teardown_subparse ();
} }

View file

@ -139,7 +139,7 @@ setup_textoverlay (gboolean video_only_no_text)
GST_DEBUG ("setup_textoverlay"); GST_DEBUG ("setup_textoverlay");
textoverlay = gst_check_setup_element ("textoverlay"); textoverlay = gst_check_setup_element ("textoverlay");
mysinkpad = gst_check_setup_sink_pad (textoverlay, &sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (textoverlay, &sinktemplate);
myvideosrcpad = myvideosrcpad =
notgst_check_setup_src_pad2 (textoverlay, &video_srctemplate, NULL, notgst_check_setup_src_pad2 (textoverlay, &video_srctemplate, NULL,
"video_sink"); "video_sink");
@ -160,7 +160,7 @@ setup_textoverlay (gboolean video_only_no_text)
} }
static gboolean static gboolean
buffer_is_all_black (GstBuffer * buf) buffer_is_all_black (GstBuffer * buf, GstCaps * caps)
{ {
GstStructure *s; GstStructure *s;
gint x, y, w, h; gint x, y, w, h;
@ -168,8 +168,8 @@ buffer_is_all_black (GstBuffer * buf)
gsize size; gsize size;
fail_unless (buf != NULL); fail_unless (buf != NULL);
fail_unless (GST_BUFFER_CAPS (buf) != NULL); fail_unless (caps != NULL);
s = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0); s = gst_caps_get_structure (caps, 0);
fail_unless (s != NULL); fail_unless (s != NULL);
fail_unless (gst_structure_get_int (s, "width", &w)); fail_unless (gst_structure_get_int (s, "width", &w));
fail_unless (gst_structure_get_int (s, "height", &h)); fail_unless (gst_structure_get_int (s, "height", &h));
@ -190,26 +190,34 @@ buffer_is_all_black (GstBuffer * buf)
return TRUE; return TRUE;
} }
static GstBuffer * static GstCaps *
create_black_buffer (const gchar * caps_string) create_video_caps (const gchar * caps_string)
{ {
GstStructure *s;
GstBuffer *buffer;
GstCaps *caps; GstCaps *caps;
gint w, h, size;
guint8 *data;
fail_unless (caps_string != NULL);
caps = gst_caps_from_string (caps_string); caps = gst_caps_from_string (caps_string);
fail_unless (caps != NULL); fail_unless (caps != NULL);
fail_unless (gst_caps_is_fixed (caps)); fail_unless (gst_caps_is_fixed (caps));
return caps;
}
static GstBuffer *
create_black_buffer (GstCaps * caps)
{
GstStructure *s;
GstBuffer *buffer;
gint w, h, size;
guint8 *data;
fail_unless (caps != NULL);
s = gst_caps_get_structure (caps, 0); s = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_get_int (s, "width", &w)); fail_unless (gst_structure_get_int (s, "width", &w));
fail_unless (gst_structure_get_int (s, "height", &h)); fail_unless (gst_structure_get_int (s, "height", &h));
GST_LOG ("creating buffer (%dx%d)", w, h); GST_LOG ("creating buffer (%dx%d)", w, h);
size = I420_SIZE (w, h); size = I420_SIZE (w, h);
buffer = gst_buffer_new_and_alloc (size); buffer = gst_buffer_new_and_alloc (size);
@ -219,11 +227,8 @@ create_black_buffer (const gchar * caps_string)
memset (data, 0, size); memset (data, 0, size);
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, data, size);
gst_buffer_set_caps (buffer, caps);
gst_caps_unref (caps);
/* double check to make sure it's been created right */ /* double check to make sure it's been created right */
fail_unless (buffer_is_all_black (buffer)); fail_unless (buffer_is_all_black (buffer, caps));
return buffer; return buffer;
} }
@ -232,7 +237,6 @@ static GstBuffer *
create_text_buffer (const gchar * txt, GstClockTime ts, GstClockTime duration) create_text_buffer (const gchar * txt, GstClockTime ts, GstClockTime duration)
{ {
GstBuffer *buffer; GstBuffer *buffer;
GstCaps *caps;
guint txt_len; guint txt_len;
fail_unless (txt != NULL); fail_unless (txt != NULL);
@ -245,10 +249,6 @@ create_text_buffer (const gchar * txt, GstClockTime ts, GstClockTime duration)
GST_BUFFER_TIMESTAMP (buffer) = ts; GST_BUFFER_TIMESTAMP (buffer) = ts;
GST_BUFFER_DURATION (buffer) = duration; GST_BUFFER_DURATION (buffer) = duration;
caps = gst_caps_new_simple ("text/plain", NULL);
gst_buffer_set_caps (buffer, caps);
gst_caps_unref (caps);
return buffer; return buffer;
} }
@ -276,14 +276,20 @@ cleanup_textoverlay (GstElement * textoverlay)
GST_START_TEST (test_video_passthrough) GST_START_TEST (test_video_passthrough)
{ {
GstElement *textoverlay; GstElement *textoverlay;
GstBuffer *inbuffer; GstBuffer *inbuffer, *outbuffer;
GstCaps *incaps, *outcaps;
GstSegment segment;
textoverlay = setup_textoverlay (TRUE); textoverlay = setup_textoverlay (TRUE);
fail_unless (gst_element_set_state (textoverlay, fail_unless (gst_element_set_state (textoverlay,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "could not set to playing");
inbuffer = create_black_buffer (VIDEO_CAPS_STRING); incaps = create_video_caps (VIDEO_CAPS_STRING);
gst_pad_set_caps (myvideosrcpad, incaps);
inbuffer = create_black_buffer (incaps);
gst_caps_unref (incaps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* ========== (1) video buffer without timestamp => should be dropped ==== */ /* ========== (1) video buffer without timestamp => should be dropped ==== */
@ -315,8 +321,11 @@ GST_START_TEST (test_video_passthrough)
/* text pad is not linked, timestamp is in segment, no static text to /* text pad is not linked, timestamp is in segment, no static text to
* render, should have gone through right away without modification */ * render, should have gone through right away without modification */
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_unless (GST_BUFFER_CAST (buffers->data) == inbuffer); outbuffer = GST_BUFFER_CAST (buffers->data);
fail_unless (buffer_is_all_black (inbuffer)); fail_unless (outbuffer == inbuffer);
outcaps = gst_pad_get_current_caps (mysinkpad);
fail_unless (buffer_is_all_black (outbuffer, outcaps));
gst_caps_unref (outcaps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 2); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 2);
/* and clean up */ /* and clean up */
@ -328,9 +337,11 @@ GST_START_TEST (test_video_passthrough)
/* ========== (3) buffer with 0 timestamp and no duration, with the /* ========== (3) buffer with 0 timestamp and no duration, with the
* segment starting from 1sec => should be discarded */ * segment starting from 1sec => should be discarded */
gst_pad_push_event (myvideosrcpad, gst_segment_init (&segment, GST_FORMAT_TIME);
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 1 * GST_SECOND, segment.start = 1 * GST_SECOND;
-1, 0)); segment.stop = -1;
segment.time = 0;
gst_pad_push_event (myvideosrcpad, gst_event_new_segment (&segment));
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_DURATION (inbuffer) = GST_CLOCK_TIME_NONE; GST_BUFFER_DURATION (inbuffer) = GST_CLOCK_TIME_NONE;
@ -349,9 +360,7 @@ GST_START_TEST (test_video_passthrough)
/* ========== (4) buffer with 0 timestamp and small defined duration, with /* ========== (4) buffer with 0 timestamp and small defined duration, with
* segment starting from 1sec => should be discarded */ * segment starting from 1sec => should be discarded */
gst_pad_push_event (myvideosrcpad, gst_pad_push_event (myvideosrcpad, gst_event_new_segment (&segment));
gst_event_new_new_segment (FALSE, 1.0, 1 * GST_FORMAT_TIME, GST_SECOND,
-1, 0));
GST_BUFFER_DURATION (inbuffer) = GST_SECOND / 10; GST_BUFFER_DURATION (inbuffer) = GST_SECOND / 10;
@ -369,9 +378,7 @@ GST_START_TEST (test_video_passthrough)
/* ========== (5) buffer partially overlapping into the segment => should /* ========== (5) buffer partially overlapping into the segment => should
* be pushed through, but with adjusted stamp values */ * be pushed through, but with adjusted stamp values */
gst_pad_push_event (myvideosrcpad, gst_pad_push_event (myvideosrcpad, gst_event_new_segment (&segment));
gst_event_new_new_segment (FALSE, 1.0, 1 * GST_FORMAT_TIME, GST_SECOND,
-1, 0));
GST_BUFFER_TIMESTAMP (inbuffer) = GST_SECOND / 4; GST_BUFFER_TIMESTAMP (inbuffer) = GST_SECOND / 4;
GST_BUFFER_DURATION (inbuffer) = GST_SECOND; GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
@ -386,12 +393,13 @@ GST_START_TEST (test_video_passthrough)
/* should be a new buffer for the stamp fix-up */ /* should be a new buffer for the stamp fix-up */
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_unless (GST_BUFFER_CAST (buffers->data) != inbuffer); outbuffer = GST_BUFFER_CAST (buffers->data);
fail_unless (GST_BUFFER_TIMESTAMP (GST_BUFFER_CAST (buffers->data)) == outcaps = gst_pad_get_current_caps (mysinkpad);
GST_SECOND); fail_unless (outbuffer != inbuffer);
fail_unless (GST_BUFFER_DURATION (GST_BUFFER_CAST (buffers->data)) == fail_unless (GST_BUFFER_TIMESTAMP (outbuffer) == GST_SECOND);
(GST_SECOND / 4)); fail_unless (GST_BUFFER_DURATION (outbuffer) == (GST_SECOND / 4));
fail_unless (buffer_is_all_black (GST_BUFFER_CAST (buffers->data))); fail_unless (buffer_is_all_black (outbuffer, outcaps));
gst_caps_unref (outcaps);
/* and clean up */ /* and clean up */
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (buffers); g_list_free (buffers);
@ -408,7 +416,8 @@ GST_END_TEST;
GST_START_TEST (test_video_render_static_text) GST_START_TEST (test_video_render_static_text)
{ {
GstElement *textoverlay; GstElement *textoverlay;
GstBuffer *inbuffer; GstBuffer *inbuffer, *outbuffer;
GstCaps *incaps, *outcaps;
textoverlay = setup_textoverlay (TRUE); textoverlay = setup_textoverlay (TRUE);
@ -419,7 +428,10 @@ GST_START_TEST (test_video_render_static_text)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "could not set to playing");
inbuffer = create_black_buffer (VIDEO_CAPS_STRING); incaps = create_video_caps (VIDEO_CAPS_STRING);
gst_pad_set_caps (myvideosrcpad, incaps);
inbuffer = create_black_buffer (incaps);
gst_caps_unref (incaps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
@ -435,14 +447,16 @@ GST_START_TEST (test_video_render_static_text)
/* should have been dropped in favour of a new writable buffer */ /* should have been dropped in favour of a new writable buffer */
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_unless (GST_BUFFER_CAST (buffers->data) != inbuffer); outbuffer = GST_BUFFER_CAST (buffers->data);
outcaps = gst_pad_get_current_caps (mysinkpad);
fail_unless (outbuffer != inbuffer);
/* there should be text rendered */ /* there should be text rendered */
fail_unless (buffer_is_all_black (GST_BUFFER_CAST (buffers->data)) == FALSE); fail_unless (buffer_is_all_black (outbuffer, outcaps) == FALSE);
gst_caps_unref (outcaps);
fail_unless (GST_BUFFER_TIMESTAMP (GST_BUFFER_CAST (buffers->data)) == 0); fail_unless (GST_BUFFER_TIMESTAMP (outbuffer) == 0);
fail_unless (GST_BUFFER_DURATION (GST_BUFFER_CAST (buffers->data)) == fail_unless (GST_BUFFER_DURATION (outbuffer) == (GST_SECOND / 10));
(GST_SECOND / 10));
/* and clean up */ /* and clean up */
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
@ -460,14 +474,18 @@ GST_END_TEST;
static gpointer static gpointer
test_video_waits_for_text_send_text_newsegment_thread (gpointer data) test_video_waits_for_text_send_text_newsegment_thread (gpointer data)
{ {
GstSegment segment;
g_usleep (1 * G_USEC_PER_SEC); g_usleep (1 * G_USEC_PER_SEC);
/* send an update newsegment; the video buffer should now be pushed through /* send an update newsegment; the video buffer should now be pushed through
* even though there is no text buffer queued at the moment */ * even though there is no text buffer queued at the moment */
GST_INFO ("Sending newsegment update on text pad"); GST_INFO ("Sending newsegment update on text pad");
gst_pad_push_event (mytextsrcpad, gst_segment_init (&segment, GST_FORMAT_TIME);
gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, segment.base = 35 * GST_SECOND;
35 * GST_SECOND, -1, 35 * GST_SECOND)); segment.start = 35 * GST_SECOND;
segment.time = 35 * GST_SECOND;
gst_pad_push_event (mytextsrcpad, gst_event_new_segment (&segment));
return NULL; return NULL;
} }
@ -489,7 +507,8 @@ test_video_waits_for_text_shutdown_element (gpointer data)
GST_START_TEST (test_video_waits_for_text) GST_START_TEST (test_video_waits_for_text)
{ {
GstElement *textoverlay; GstElement *textoverlay;
GstBuffer *inbuffer, *tbuf; GstBuffer *inbuffer, *outbuffer, *tbuf;
GstCaps *caps, *incaps, *outcaps;
GThread *thread; GThread *thread;
textoverlay = setup_textoverlay (FALSE); textoverlay = setup_textoverlay (FALSE);
@ -498,6 +517,10 @@ GST_START_TEST (test_video_waits_for_text)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "could not set to playing");
caps = gst_caps_new_empty_simple ("text/plain");
gst_pad_set_caps (mytextsrcpad, caps);
gst_caps_unref (caps);
tbuf = create_text_buffer ("XLX", 1 * GST_SECOND, 5 * GST_SECOND); tbuf = create_text_buffer ("XLX", 1 * GST_SECOND, 5 * GST_SECOND);
gst_buffer_ref (tbuf); gst_buffer_ref (tbuf);
ASSERT_BUFFER_REFCOUNT (tbuf, "tbuf", 2); ASSERT_BUFFER_REFCOUNT (tbuf, "tbuf", 2);
@ -509,7 +532,10 @@ GST_START_TEST (test_video_waits_for_text)
* newsegment event that indicates it's not needed any longer */ * newsegment event that indicates it's not needed any longer */
fail_unless_equals_int (g_list_length (buffers), 0); fail_unless_equals_int (g_list_length (buffers), 0);
inbuffer = create_black_buffer (VIDEO_CAPS_STRING); incaps = create_video_caps (VIDEO_CAPS_STRING);
gst_pad_set_caps (myvideosrcpad, incaps);
inbuffer = create_black_buffer (incaps);
gst_caps_unref (incaps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
@ -530,7 +556,10 @@ GST_START_TEST (test_video_waits_for_text)
ASSERT_BUFFER_REFCOUNT (tbuf, "tbuf", 2); ASSERT_BUFFER_REFCOUNT (tbuf, "tbuf", 2);
/* there should be no text rendered */ /* there should be no text rendered */
fail_unless (buffer_is_all_black (GST_BUFFER_CAST (buffers->data))); outbuffer = GST_BUFFER_CAST (buffers->data);
outcaps = gst_pad_get_current_caps (mysinkpad);
fail_unless (buffer_is_all_black (outbuffer, outcaps));
gst_caps_unref (outcaps);
/* now, another video buffer */ /* now, another video buffer */
inbuffer = gst_buffer_make_writable (inbuffer); inbuffer = gst_buffer_make_writable (inbuffer);
@ -549,8 +578,10 @@ GST_START_TEST (test_video_waits_for_text)
ASSERT_BUFFER_REFCOUNT (tbuf, "tbuf", 2); ASSERT_BUFFER_REFCOUNT (tbuf, "tbuf", 2);
/* there should be text rendered */ /* there should be text rendered */
fail_unless (buffer_is_all_black (GST_BUFFER_CAST (buffers->next->data)) == outbuffer = GST_BUFFER_CAST (buffers->next->data);
FALSE); outcaps = gst_pad_get_current_caps (mysinkpad);
fail_unless (buffer_is_all_black (outbuffer, outcaps) == FALSE);
gst_caps_unref (outcaps);
/* a third video buffer */ /* a third video buffer */
inbuffer = gst_buffer_make_writable (inbuffer); inbuffer = gst_buffer_make_writable (inbuffer);
@ -577,8 +608,10 @@ GST_START_TEST (test_video_waits_for_text)
fail_unless_equals_int (g_list_length (buffers), 3); fail_unless_equals_int (g_list_length (buffers), 3);
/* ... and there should not be any text rendered on it */ /* ... and there should not be any text rendered on it */
fail_unless (buffer_is_all_black (GST_BUFFER_CAST (buffers->next-> outbuffer = GST_BUFFER_CAST (buffers->next->next->data);
next->data))); outcaps = gst_pad_get_current_caps (mysinkpad);
fail_unless (buffer_is_all_black (outbuffer, outcaps));
gst_caps_unref (outcaps);
/* a fourth video buffer */ /* a fourth video buffer */
inbuffer = gst_buffer_make_writable (inbuffer); inbuffer = gst_buffer_make_writable (inbuffer);
@ -619,11 +652,15 @@ test_render_continuity_push_video_buffers_thread (gpointer data)
{ {
/* push video buffers at 1fps */ /* push video buffers at 1fps */
guint frame_count = 0; guint frame_count = 0;
GstCaps *vcaps;
vcaps = create_video_caps (VIDEO_CAPS_STRING);
gst_pad_set_caps (myvideosrcpad, vcaps);
do { do {
GstBuffer *vbuf; GstBuffer *vbuf;
vbuf = create_black_buffer (VIDEO_CAPS_STRING); vbuf = create_black_buffer (vcaps);
ASSERT_BUFFER_REFCOUNT (vbuf, "vbuf", 1); ASSERT_BUFFER_REFCOUNT (vbuf, "vbuf", 1);
GST_BUFFER_TIMESTAMP (vbuf) = frame_count * GST_SECOND; GST_BUFFER_TIMESTAMP (vbuf) = frame_count * GST_SECOND;
@ -637,15 +674,17 @@ test_render_continuity_push_video_buffers_thread (gpointer data)
++frame_count; ++frame_count;
} while (frame_count < 15); } while (frame_count < 15);
gst_caps_unref (vcaps);
return NULL; return NULL;
} }
GST_START_TEST (test_render_continuity) GST_START_TEST (test_render_continuity)
{ {
GThread *thread; GThread *thread;
GstElement *textoverlay; GstElement *textoverlay;
GstBuffer *tbuf; GstBuffer *tbuf;
GstCaps *caps, *outcaps;
textoverlay = setup_textoverlay (FALSE); textoverlay = setup_textoverlay (FALSE);
@ -657,6 +696,10 @@ GST_START_TEST (test_render_continuity)
NULL, FALSE, NULL); NULL, FALSE, NULL);
fail_unless (thread != NULL); fail_unless (thread != NULL);
caps = gst_caps_new_empty_simple ("text/plain");
gst_pad_set_caps (mytextsrcpad, caps);
gst_caps_unref (caps);
tbuf = create_text_buffer ("XLX", 2 * GST_SECOND, GST_SECOND); tbuf = create_text_buffer ("XLX", 2 * GST_SECOND, GST_SECOND);
GST_LOG ("pushing text buffer @ %" GST_TIME_FORMAT, GST_LOG ("pushing text buffer @ %" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (tbuf))); GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (tbuf)));
@ -695,39 +738,46 @@ GST_START_TEST (test_render_continuity)
/* we should have 15 buffers each with one second length now */ /* we should have 15 buffers each with one second length now */
fail_unless_equals_int (g_list_length (buffers), 15); fail_unless_equals_int (g_list_length (buffers), 15);
outcaps = gst_pad_get_current_caps (mysinkpad);
/* buffers 0 + 1 should be black */ /* buffers 0 + 1 should be black */
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 0)))); fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 0)),
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 1)))); outcaps));
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 1)),
outcaps));
/* buffers 2 - 4 should have text */ /* buffers 2 - 4 should have text */
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
2))) == FALSE); 2)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
3))) == FALSE); 3)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
4))) == FALSE); 4)), outcaps) == FALSE);
/* buffers 5 + 6 should be black */ /* buffers 5 + 6 should be black */
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 5)))); fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 5)),
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 6)))); outcaps));
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, 6)),
outcaps));
/* buffers 7 - last should have text */ /* buffers 7 - last should have text */
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
7))) == FALSE); 7)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
8))) == FALSE); 8)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
9))) == FALSE); 9)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
10))) == FALSE); 10)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
11))) == FALSE); 11)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
12))) == FALSE); 12)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
13))) == FALSE); 13)), outcaps) == FALSE);
fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers, fail_unless (buffer_is_all_black (GST_BUFFER (g_list_nth_data (buffers,
14))) == FALSE); 14)), outcaps) == FALSE);
gst_caps_unref (outcaps);
/* and clean up */ /* and clean up */
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);

View file

@ -110,8 +110,8 @@ setup_videorate_full (GstStaticPadTemplate * srctemplate,
GST_DEBUG ("setup_videorate"); GST_DEBUG ("setup_videorate");
videorate = gst_check_setup_element ("videorate"); videorate = gst_check_setup_element ("videorate");
mysrcpad = gst_check_setup_src_pad (videorate, srctemplate, NULL); mysrcpad = gst_check_setup_src_pad (videorate, srctemplate);
mysinkpad = gst_check_setup_sink_pad (videorate, sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (videorate, sinktemplate);
gst_pad_set_active (mysrcpad, TRUE); gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE); gst_pad_set_active (mysinkpad, TRUE);
@ -142,16 +142,6 @@ cleanup_videorate (GstElement * videorate)
gst_check_teardown_element (videorate); gst_check_teardown_element (videorate);
} }
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 static guint8
buffer_get_byte (GstBuffer * buffer, gint offset) buffer_get_byte (GstBuffer * buffer, gint offset)
{ {
@ -174,9 +164,9 @@ GST_START_TEST (test_one)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
buffer_memset (inbuffer, 0, 4); gst_buffer_memset (inbuffer, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING); caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -216,9 +206,9 @@ GST_START_TEST (test_more)
streams */ streams */
GST_BUFFER_OFFSET (first) = g_rand_int (rand); GST_BUFFER_OFFSET (first) = g_rand_int (rand);
GST_BUFFER_OFFSET_END (first) = g_rand_int (rand); GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
buffer_memset (first, 1, 4); gst_buffer_memset (first, 0, 1, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING); caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (first, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (first, "first", 1); ASSERT_BUFFER_REFCOUNT (first, "first", 1);
gst_buffer_ref (first); gst_buffer_ref (first);
@ -235,10 +225,7 @@ GST_START_TEST (test_more)
GST_BUFFER_TIMESTAMP (second) = GST_SECOND * 3 / 50; GST_BUFFER_TIMESTAMP (second) = GST_SECOND * 3 / 50;
GST_BUFFER_OFFSET (first) = g_rand_int (rand); GST_BUFFER_OFFSET (first) = g_rand_int (rand);
GST_BUFFER_OFFSET_END (first) = g_rand_int (rand); GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
buffer_memset (second, 2, 4); gst_buffer_memset (second, 0, 2, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (second, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (second, "second", 1); ASSERT_BUFFER_REFCOUNT (second, "second", 1);
gst_buffer_ref (second); gst_buffer_ref (second);
@ -260,10 +247,7 @@ GST_START_TEST (test_more)
GST_BUFFER_TIMESTAMP (third) = GST_SECOND * 12 / 50; GST_BUFFER_TIMESTAMP (third) = GST_SECOND * 12 / 50;
GST_BUFFER_OFFSET (first) = g_rand_int (rand); GST_BUFFER_OFFSET (first) = g_rand_int (rand);
GST_BUFFER_OFFSET_END (first) = g_rand_int (rand); GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
buffer_memset (third, 3, 4); gst_buffer_memset (third, 0, 3, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (third, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (third, "third", 1); ASSERT_BUFFER_REFCOUNT (third, "third", 1);
gst_buffer_ref (third); gst_buffer_ref (third);
@ -340,9 +324,9 @@ GST_START_TEST (test_wrong_order_from_zero)
/* first buffer */ /* first buffer */
first = gst_buffer_new_and_alloc (4); first = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (first) = GST_SECOND; GST_BUFFER_TIMESTAMP (first) = GST_SECOND;
buffer_memset (first, 0, 4); gst_buffer_memset (first, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING); caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (first, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (first, "first", 1); ASSERT_BUFFER_REFCOUNT (first, "first", 1);
gst_buffer_ref (first); gst_buffer_ref (first);
@ -358,10 +342,7 @@ GST_START_TEST (test_wrong_order_from_zero)
/* second buffer */ /* second buffer */
second = gst_buffer_new_and_alloc (4); second = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (second) = 0; GST_BUFFER_TIMESTAMP (second) = 0;
buffer_memset (second, 0, 4); gst_buffer_memset (second, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (second, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (second, "second", 1); ASSERT_BUFFER_REFCOUNT (second, "second", 1);
gst_buffer_ref (second); gst_buffer_ref (second);
@ -378,10 +359,7 @@ GST_START_TEST (test_wrong_order_from_zero)
/* third buffer */ /* third buffer */
third = gst_buffer_new_and_alloc (4); third = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND; GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
buffer_memset (third, 0, 4); gst_buffer_memset (third, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (third, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (third, "third", 1); ASSERT_BUFFER_REFCOUNT (third, "third", 1);
gst_buffer_ref (third); gst_buffer_ref (third);
@ -429,9 +407,9 @@ GST_START_TEST (test_wrong_order)
/* first buffer */ /* first buffer */
first = gst_buffer_new_and_alloc (4); first = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (first) = 0; GST_BUFFER_TIMESTAMP (first) = 0;
buffer_memset (first, 0, 4); gst_buffer_memset (first, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING); caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (first, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (first, "first", 1); ASSERT_BUFFER_REFCOUNT (first, "first", 1);
gst_buffer_ref (first); gst_buffer_ref (first);
@ -447,10 +425,7 @@ GST_START_TEST (test_wrong_order)
/* second buffer */ /* second buffer */
second = gst_buffer_new_and_alloc (4); second = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (second) = GST_SECOND; GST_BUFFER_TIMESTAMP (second) = GST_SECOND;
buffer_memset (second, 0, 4); gst_buffer_memset (second, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (second, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (second, "second", 1); ASSERT_BUFFER_REFCOUNT (second, "second", 1);
gst_buffer_ref (second); gst_buffer_ref (second);
@ -466,10 +441,7 @@ GST_START_TEST (test_wrong_order)
/* third buffer */ /* third buffer */
third = gst_buffer_new_and_alloc (4); third = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND; GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
buffer_memset (third, 0, 4); gst_buffer_memset (third, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (third, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (third, "third", 1); ASSERT_BUFFER_REFCOUNT (third, "third", 1);
gst_buffer_ref (third); gst_buffer_ref (third);
@ -488,10 +460,7 @@ GST_START_TEST (test_wrong_order)
/* fourth buffer */ /* fourth buffer */
fourth = gst_buffer_new_and_alloc (4); fourth = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (fourth) = 0; GST_BUFFER_TIMESTAMP (fourth) = 0;
buffer_memset (fourth, 0, 4); gst_buffer_memset (fourth, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (fourth, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (fourth, "fourth", 1); ASSERT_BUFFER_REFCOUNT (fourth, "fourth", 1);
gst_buffer_ref (fourth); gst_buffer_ref (fourth);
@ -536,9 +505,9 @@ GST_START_TEST (test_no_framerate)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
buffer_memset (inbuffer, 0, 4); gst_buffer_memset (inbuffer, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_NO_FRAMERATE_STRING); caps = gst_caps_from_string (VIDEO_CAPS_NO_FRAMERATE_STRING);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -573,21 +542,22 @@ GST_START_TEST (test_changing_size)
GstBuffer *outbuf; GstBuffer *outbuf;
GstEvent *newsegment; GstEvent *newsegment;
GstCaps *caps, *caps_newsize; GstCaps *caps, *caps_newsize;
GstSegment segment;
videorate = setup_videorate (); videorate = setup_videorate ();
fail_unless (gst_element_set_state (videorate, fail_unless (gst_element_set_state (videorate,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "could not set to playing");
newsegment = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, gst_segment_init (&segment, GST_FORMAT_TIME);
0); newsegment = gst_event_new_segment (&segment);
fail_unless (gst_pad_push_event (mysrcpad, newsegment) == TRUE); fail_unless (gst_pad_push_event (mysrcpad, newsegment) == TRUE);
first = gst_buffer_new_and_alloc (4); first = gst_buffer_new_and_alloc (4);
buffer_memset (first, 0, 4); gst_buffer_memset (first, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING); caps = gst_caps_from_string (VIDEO_CAPS_STRING);
GST_BUFFER_TIMESTAMP (first) = 0; GST_BUFFER_TIMESTAMP (first) = 0;
gst_buffer_set_caps (first, caps); gst_pad_set_caps (mysrcpad, caps);
GST_DEBUG ("pushing first buffer"); GST_DEBUG ("pushing first buffer");
fail_unless (gst_pad_push (mysrcpad, first) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, first) == GST_FLOW_OK);
@ -595,36 +565,34 @@ GST_START_TEST (test_changing_size)
/* second buffer */ /* second buffer */
second = gst_buffer_new_and_alloc (4); second = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (second) = GST_SECOND / 25; GST_BUFFER_TIMESTAMP (second) = GST_SECOND / 25;
buffer_memset (second, 0, 4); gst_buffer_memset (second, 0, 0, 4);
gst_buffer_set_caps (second, caps);
fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
outbuf = buffers->data; outbuf = buffers->data;
/* first buffer should be output here */ /* first buffer should be output here */
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps));
fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 0); fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 0);
/* third buffer with new size */ /* third buffer with new size */
third = gst_buffer_new_and_alloc (4); third = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND / 25; GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND / 25;
buffer_memset (third, 0, 4); gst_buffer_memset (third, 0, 0, 4);
caps_newsize = gst_caps_from_string (VIDEO_CAPS_NEWSIZE_STRING); caps_newsize = gst_caps_from_string (VIDEO_CAPS_NEWSIZE_STRING);
gst_buffer_set_caps (third, caps_newsize); gst_pad_set_caps (mysrcpad, caps_newsize);
fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK);
/* new caps flushed the internal state, no new output yet */ /* new caps flushed the internal state, no new output yet */
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
outbuf = g_list_last (buffers)->data; outbuf = g_list_last (buffers)->data;
/* first buffer should be output here */ /* first buffer should be output here */
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps)); //fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps));
fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 0); fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 0);
/* fourth buffer with original size */ /* fourth buffer with original size */
fourth = gst_buffer_new_and_alloc (4); fourth = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (fourth) = 3 * GST_SECOND / 25; GST_BUFFER_TIMESTAMP (fourth) = 3 * GST_SECOND / 25;
buffer_memset (fourth, 0, 4); gst_buffer_memset (fourth, 0, 0, 4);
gst_buffer_set_caps (fourth, caps); gst_pad_set_caps (mysrcpad, caps);
fail_unless (gst_pad_push (mysrcpad, fourth) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, fourth) == GST_FLOW_OK);
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
@ -632,8 +600,7 @@ GST_START_TEST (test_changing_size)
/* fifth buffer with original size */ /* fifth buffer with original size */
fifth = gst_buffer_new_and_alloc (4); fifth = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (fifth) = 4 * GST_SECOND / 25; GST_BUFFER_TIMESTAMP (fifth) = 4 * GST_SECOND / 25;
buffer_memset (fifth, 0, 4); gst_buffer_memset (fifth, 0, 0, 4);
gst_buffer_set_caps (fifth, caps);
fail_unless (gst_pad_push (mysrcpad, fifth) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, fifth) == GST_FLOW_OK);
/* all four missing buffers here, dups of fourth buffer */ /* all four missing buffers here, dups of fourth buffer */
@ -641,7 +608,7 @@ GST_START_TEST (test_changing_size)
outbuf = g_list_last (buffers)->data; outbuf = g_list_last (buffers)->data;
/* third buffer should be output here */ /* third buffer should be output here */
fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 3 * GST_SECOND / 25); fail_unless (GST_BUFFER_TIMESTAMP (outbuf) == 3 * GST_SECOND / 25);
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps)); //fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (outbuf), caps));
gst_caps_unref (caps); gst_caps_unref (caps);
gst_caps_unref (caps_newsize); gst_caps_unref (caps_newsize);
@ -663,9 +630,9 @@ GST_START_TEST (test_non_ok_flow)
"could not set to playing"); "could not set to playing");
buf = gst_buffer_new_and_alloc (4); buf = gst_buffer_new_and_alloc (4);
buffer_memset (buf, 0, 4); gst_buffer_memset (buf, 0, 0, 4);
caps = gst_caps_from_string (VIDEO_CAPS_STRING); caps = gst_caps_from_string (VIDEO_CAPS_STRING);
gst_buffer_set_caps (buf, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (buf, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (buf, "inbuffer", 1);
@ -712,7 +679,7 @@ GST_START_TEST (test_upstream_caps_nego)
"could not set to playing"); "could not set to playing");
videorate_pad = gst_element_get_static_pad (videorate, "sink"); videorate_pad = gst_element_get_static_pad (videorate, "sink");
caps = gst_pad_get_caps (videorate_pad); caps = gst_pad_query_caps (videorate_pad, NULL);
/* assemble the expected caps */ /* assemble the expected caps */
structure = gst_structure_from_string (VIDEO_CAPS_STRING, NULL); structure = gst_structure_from_string (VIDEO_CAPS_STRING, NULL);
@ -981,14 +948,26 @@ static TestInfo caps_negotiation_tests[] = {
"video/x-raw, framerate=(fraction)[0/1, 20/1]"}, "video/x-raw, framerate=(fraction)[0/1, 20/1]"},
}; };
static GstCaps * static gboolean
_getcaps_function (GstPad * pad) _query_function (GstPad * pad, GstObject * parent, GstQuery * query)
{ {
GstCaps *caps = g_object_get_data (G_OBJECT (pad), "caps"); gboolean res;
fail_unless (caps != NULL); switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CAPS:{
GstCaps *caps = g_object_get_data (G_OBJECT (pad), "caps");
return gst_caps_copy (caps); fail_unless (caps != NULL);
gst_query_set_caps_result (query, caps);
res = TRUE;
break;
}
default:
res = gst_pad_query_default (pad, parent, query);
break;
}
return res;
} }
static void static void
@ -1022,7 +1001,7 @@ check_peer_caps (GstPad * pad, const char *expected, const char *name)
GstCaps *caps; GstCaps *caps;
GstCaps *expected_caps; GstCaps *expected_caps;
caps = gst_pad_peer_get_caps (pad); caps = gst_pad_peer_query_caps (pad, NULL);
fail_unless (caps != NULL); fail_unless (caps != NULL);
expected_caps = gst_caps_from_string (expected); expected_caps = gst_caps_from_string (expected);
@ -1053,8 +1032,8 @@ GST_START_TEST (test_caps_negotiation)
if (test->max_rate != 0) if (test->max_rate != 0)
g_object_set (videorate, "max-rate", test->max_rate, NULL); g_object_set (videorate, "max-rate", test->max_rate, NULL);
gst_pad_set_getcaps_function (mysrcpad, _getcaps_function); gst_pad_set_query_function (mysrcpad, _query_function);
gst_pad_set_getcaps_function (mysinkpad, _getcaps_function); gst_pad_set_query_function (mysinkpad, _query_function);
check_peer_caps (mysrcpad, test->expected_sink_caps, "sink"); check_peer_caps (mysrcpad, test->expected_sink_caps, "sink");
check_peer_caps (mysinkpad, test->expected_src_caps, "src"); check_peer_caps (mysinkpad, test->expected_src_caps, "src");

View file

@ -73,17 +73,16 @@ static gboolean
caps_are_64bpp (const GstCaps * caps) caps_are_64bpp (const GstCaps * caps)
{ {
GstVideoFormat fmt; GstVideoFormat fmt;
GstCaps *fmt_caps; GstStructure *s;
const gchar *format;
/* need fixed caps for _parse_caps */ s = gst_caps_get_structure (caps, 0);
fmt_caps = gst_caps_copy (caps); format = gst_structure_get_string (s, "format");
gst_structure_remove_field (gst_caps_get_structure (fmt_caps, 0), "width"); fail_if (format == NULL);
gst_structure_remove_field (gst_caps_get_structure (fmt_caps, 0), "height");
gst_structure_remove_field (gst_caps_get_structure (fmt_caps, 0), fmt = gst_video_format_from_string (format);
"framerate"); fail_if (fmt == GST_VIDEO_FORMAT_UNKNOWN);
fail_unless (gst_video_format_parse_caps (fmt_caps, &fmt, NULL, NULL));
gst_caps_unref (fmt_caps);
return (fmt == GST_VIDEO_FORMAT_ARGB64 || fmt == GST_VIDEO_FORMAT_AYUV64); return (fmt == GST_VIDEO_FORMAT_ARGB64 || fmt == GST_VIDEO_FORMAT_AYUV64);
} }
@ -573,7 +572,7 @@ G_DEFINE_TYPE (GstTestReverseNegotiationSink,
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB)); GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("xRGB")));
#if 0 #if 0
static GstFlowReturn static GstFlowReturn
@ -617,12 +616,13 @@ gst_test_reverse_negotiation_sink_render (GstBaseSink * bsink,
{ {
GstTestReverseNegotiationSink *sink = GstTestReverseNegotiationSink *sink =
GST_TEST_REVERSE_NEGOTIATION_SINK (bsink); GST_TEST_REVERSE_NEGOTIATION_SINK (bsink);
GstCaps *caps = gst_buffer_get_caps (buffer); GstCaps *caps;
GstVideoFormat fmt; GstVideoInfo info;
gint width, height;
caps = gst_pad_get_current_caps (GST_BASE_SINK_PAD (bsink));
fail_unless (caps != NULL); fail_unless (caps != NULL);
fail_unless (gst_video_format_parse_caps (caps, &fmt, &width, &height)); fail_unless (gst_video_info_from_caps (&info, caps));
sink->nbuffers++; sink->nbuffers++;
@ -631,8 +631,8 @@ gst_test_reverse_negotiation_sink_render (GstBaseSink * bsink,
* the frame sizes * the frame sizes
*/ */
if (sink->nbuffers > 3) { if (sink->nbuffers > 3) {
fail_unless_equals_int (width, 512); fail_unless_equals_int (GST_VIDEO_INFO_WIDTH (&info), 512);
fail_unless_equals_int (height, 128); fail_unless_equals_int (GST_VIDEO_INFO_HEIGHT (&info), 128);
} }
gst_caps_unref (caps); gst_caps_unref (caps);
@ -780,16 +780,16 @@ GST_START_TEST (test_basetransform_negotiation)
g_object_set (src, "num-buffers", 3, NULL); g_object_set (src, "num-buffers", 3, NULL);
caps = gst_caps_new_simple ("video/x-raw", "format", GST_TYPE_FOURCC, caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), "width", G_TYPE_INT, 352, "UYVY", "width", G_TYPE_INT, 352,
"height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1, "height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL); "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
g_object_set (capsfilter1, "caps", caps, NULL); g_object_set (capsfilter1, "caps", caps, NULL);
gst_caps_unref (caps); gst_caps_unref (caps);
/* same caps, just different pixel-aspect-ratio */ /* same caps, just different pixel-aspect-ratio */
caps = gst_caps_new_simple ("video/x-raw", "format", GST_TYPE_FOURCC, caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), "width", G_TYPE_INT, 352, "UYVY", "width", G_TYPE_INT, 352,
"height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1, "height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 12, 11, NULL); "pixel-aspect-ratio", GST_TYPE_FRACTION, 12, 11, NULL);
g_object_set (capsfilter2, "caps", caps, NULL); g_object_set (capsfilter2, "caps", caps, NULL);

View file

@ -59,7 +59,7 @@ setup_videotestsrc (void)
GST_DEBUG ("setup_videotestsrc"); GST_DEBUG ("setup_videotestsrc");
videotestsrc = gst_check_setup_element ("videotestsrc"); videotestsrc = gst_check_setup_element ("videotestsrc");
mysinkpad = gst_check_setup_sink_pad (videotestsrc, &sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (videotestsrc, &sinktemplate);
gst_pad_set_active (mysinkpad, TRUE); gst_pad_set_active (mysinkpad, TRUE);
return videotestsrc; return videotestsrc;
@ -153,37 +153,25 @@ fix_expected_colour (guint32 col_mask, guint8 col_expected)
static void static void
check_rgb_buf (const guint8 * pixels, guint32 r_mask, guint32 g_mask, check_rgb_buf (const guint8 * pixels, guint32 r_mask, guint32 g_mask,
guint32 b_mask, guint32 a_mask, guint8 r_expected, guint8 g_expected, guint32 b_mask, guint32 a_mask, guint8 r_expected, guint8 g_expected,
guint8 b_expected, guint endianness, guint bpp, guint depth) guint8 b_expected, guint bpp, guint depth)
{ {
guint32 pixel, red, green, blue, alpha; guint32 pixel, red, green, blue, alpha;
switch (bpp) { switch (bpp) {
case 32:{ case 32:
if (endianness == G_LITTLE_ENDIAN) pixel = GST_READ_UINT32_BE (pixels);
pixel = GST_READ_UINT32_LE (pixels);
else
pixel = GST_READ_UINT32_BE (pixels);
break; break;
} case 24:
case 24:{ pixel = (GST_READ_UINT8 (pixels) << 16) |
if (endianness == G_BIG_ENDIAN) { (GST_READ_UINT8 (pixels + 1) << 8) |
pixel = (GST_READ_UINT8 (pixels) << 16) | (GST_READ_UINT8 (pixels + 2) << 0);
(GST_READ_UINT8 (pixels + 1) << 8) |
(GST_READ_UINT8 (pixels + 2) << 0);
} else {
pixel = (GST_READ_UINT8 (pixels + 2) << 16) |
(GST_READ_UINT8 (pixels + 1) << 8) |
(GST_READ_UINT8 (pixels + 0) << 0);
}
break; break;
} case 16:
case 16:{ if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
if (endianness == G_LITTLE_ENDIAN)
pixel = GST_READ_UINT16_LE (pixels); pixel = GST_READ_UINT16_LE (pixels);
else else
pixel = GST_READ_UINT16_BE (pixels); pixel = GST_READ_UINT16_BE (pixels);
break; break;
}
default: default:
g_return_if_reached (); g_return_if_reached ();
} }
@ -255,10 +243,10 @@ GST_START_TEST (test_rgb_formats)
"xRGB", 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000}, { "xRGB", 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000}, {
"BGRx", 32, 24, 0x0000ff00, 0x00ff0000, 0xff000000, 0x00000000}, { "BGRx", 32, 24, 0x0000ff00, 0x00ff0000, 0xff000000, 0x00000000}, {
"xBGR", 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000}, { "xBGR", 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000}, {
"RGB ", 24, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000}, { "RGB", 24, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000}, {
"BGR ", 24, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000}, { "BGR", 24, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000}, {
"RGB565", 16, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000}, { "RGB16", 16, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000}, {
"xRGB1555", 16, 15, 0x00007c00, 0x000003e0, 0x0000001f, 0x0000000} "RGB15", 16, 15, 0x00007c00, 0x000003e0, 0x0000001f, 0x0000000}
}; };
GstElement *pipeline, *src, *filter, *sink; GstElement *pipeline, *src, *filter, *sink;
GstCaps *template_caps; GstCaps *template_caps;
@ -281,7 +269,6 @@ GST_START_TEST (test_rgb_formats)
srcpad = gst_element_get_static_pad (src, "src"); srcpad = gst_element_get_static_pad (src, "src");
template_caps = gst_pad_get_pad_template_caps (srcpad); template_caps = gst_pad_get_pad_template_caps (srcpad);
gst_object_unref (srcpad);
g_object_set (sink, "signal-handoffs", TRUE, NULL); g_object_set (sink, "signal-handoffs", TRUE, NULL);
g_signal_connect (sink, "preroll-handoff", G_CALLBACK (got_buf_cb), &buf); g_signal_connect (sink, "preroll-handoff", G_CALLBACK (got_buf_cb), &buf);
@ -290,35 +277,14 @@ GST_START_TEST (test_rgb_formats)
for (i = 0; i < G_N_ELEMENTS (rgb_formats); ++i) { for (i = 0; i < G_N_ELEMENTS (rgb_formats); ++i) {
for (e = 0; e < 2; ++e) { for (e = 0; e < 2; ++e) {
guint endianness;
GstCaps *caps; GstCaps *caps;
if (e == 0) { caps = gst_caps_new_simple ("video/x-raw",
endianness = G_BYTE_ORDER; "format", G_TYPE_STRING, rgb_formats[i].nick,
} else {
endianness =
(G_BYTE_ORDER == G_BIG_ENDIAN) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
}
caps = gst_caps_new_simple ("video/x-raw-rgb",
"bpp", G_TYPE_INT, rgb_formats[i].bpp,
"depth", G_TYPE_INT, rgb_formats[i].depth,
"red_mask", G_TYPE_INT, rgb_formats[i].red_mask,
"green_mask", G_TYPE_INT, rgb_formats[i].green_mask,
"blue_mask", G_TYPE_INT, rgb_formats[i].blue_mask,
"width", G_TYPE_INT, 16, "height", G_TYPE_INT, 16, "width", G_TYPE_INT, 16, "height", G_TYPE_INT, 16,
"endianness", G_TYPE_INT, endianness,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL); "framerate", GST_TYPE_FRACTION, 1, 1, NULL);
fail_unless (rgb_formats[i].alpha_mask == 0 || rgb_formats[i].bpp == 32);
if (rgb_formats[i].alpha_mask != 0) {
gst_structure_set (gst_caps_get_structure (caps, 0),
"alpha_mask", G_TYPE_INT, rgb_formats[i].alpha_mask, NULL);
}
if (gst_caps_is_subset (caps, template_caps)) { if (gst_caps_is_subset (caps, template_caps)) {
/* caps are supported, let's run some tests then ... */ /* caps are supported, let's run some tests then ... */
for (p = 0; p < G_N_ELEMENTS (test_patterns); ++p) { for (p = 0; p < G_N_ELEMENTS (test_patterns); ++p) {
GstStateChangeReturn state_ret; GstStateChangeReturn state_ret;
@ -327,10 +293,10 @@ GST_START_TEST (test_rgb_formats)
g_object_set (src, "pattern", test_patterns[p].pattern_enum, NULL); g_object_set (src, "pattern", test_patterns[p].pattern_enum, NULL);
GST_INFO ("%5s %u/%u %08x %08x %08x %08x %u, pattern=%s", GST_INFO ("%5s %u/%u %08x %08x %08x %08x, pattern=%s",
rgb_formats[i].nick, rgb_formats[i].bpp, rgb_formats[i].depth, rgb_formats[i].nick, rgb_formats[i].bpp, rgb_formats[i].depth,
rgb_formats[i].red_mask, rgb_formats[i].green_mask, rgb_formats[i].red_mask, rgb_formats[i].green_mask,
rgb_formats[i].blue_mask, rgb_formats[i].alpha_mask, endianness, rgb_formats[i].blue_mask, rgb_formats[i].alpha_mask,
test_patterns[p].pattern_name); test_patterns[p].pattern_name);
/* now get videotestsrc to produce a buffer with the given caps */ /* now get videotestsrc to produce a buffer with the given caps */
@ -351,38 +317,24 @@ GST_START_TEST (test_rgb_formats)
/* check buffer caps */ /* check buffer caps */
{ {
GstStructure *s; GstStructure *s;
gint v; GstCaps *caps;
const gchar *format;
fail_unless (GST_BUFFER_CAPS (buf) != NULL); caps = gst_pad_get_current_caps (srcpad);
fail_unless (caps != NULL);
s = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0); s = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_get_int (s, "bpp", &v)); format = gst_structure_get_string (s, "format");
fail_unless_equals_int (v, rgb_formats[i].bpp); fail_unless (g_str_equal (format, rgb_formats[i].nick));
fail_unless (gst_structure_get_int (s, "depth", &v));
fail_unless_equals_int (v, rgb_formats[i].depth);
fail_unless (gst_structure_get_int (s, "red_mask", &v));
fail_unless_equals_int (v, rgb_formats[i].red_mask);
fail_unless (gst_structure_get_int (s, "green_mask", &v));
fail_unless_equals_int (v, rgb_formats[i].green_mask);
fail_unless (gst_structure_get_int (s, "blue_mask", &v));
fail_unless_equals_int (v, rgb_formats[i].blue_mask);
/* there mustn't be an alpha_mask if there's no alpha component */
if (rgb_formats[i].depth == 32) {
fail_unless (gst_structure_get_int (s, "alpha_mask", &v));
fail_unless_equals_int (v, rgb_formats[i].alpha_mask);
} else {
fail_unless (gst_structure_get_value (s, "alpha_mask") == NULL);
}
} }
/* now check the first pixel */ /* now check the first pixel */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
check_rgb_buf (data, rgb_formats[i].red_mask, check_rgb_buf (data, rgb_formats[i].red_mask,
rgb_formats[i].green_mask, rgb_formats[i].blue_mask, rgb_formats[i].green_mask, rgb_formats[i].blue_mask,
rgb_formats[i].alpha_mask, test_patterns[p].r_expected, rgb_formats[i].alpha_mask, test_patterns[p].r_expected,
test_patterns[p].g_expected, test_patterns[p].b_expected, test_patterns[p].g_expected, test_patterns[p].b_expected,
endianness, rgb_formats[i].bpp, rgb_formats[i].depth); rgb_formats[i].bpp, rgb_formats[i].depth);
gst_buffer_unmap (buf, data, size); gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf); gst_buffer_unref (buf);
@ -397,6 +349,7 @@ GST_START_TEST (test_rgb_formats)
} }
} }
gst_caps_unref (template_caps); gst_caps_unref (template_caps);
gst_object_unref (srcpad);
gst_object_unref (pipeline); gst_object_unref (pipeline);
} }

View file

@ -24,7 +24,7 @@
#include <gst/base/gstbasetransform.h> #include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/interfaces/streamvolume.h> #include <gst/audio/streamvolume.h>
#include <gst/controller/gstinterpolationcontrolsource.h> #include <gst/controller/gstinterpolationcontrolsource.h>
/* For ease of programming we use globals to keep refs for our floating /* For ease of programming we use globals to keep refs for our floating
@ -119,8 +119,8 @@ setup_volume (void)
GST_DEBUG ("setup_volume"); GST_DEBUG ("setup_volume");
volume = gst_check_setup_element ("volume"); volume = gst_check_setup_element ("volume");
mysrcpad = gst_check_setup_src_pad (volume, &srctemplate, NULL); mysrcpad = gst_check_setup_src_pad (volume, &srctemplate);
mysinkpad = gst_check_setup_sink_pad (volume, &sinktemplate, NULL); mysinkpad = gst_check_setup_sink_pad (volume, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE); gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE); gst_pad_set_active (mysinkpad, TRUE);
@ -189,7 +189,7 @@ GST_START_TEST (test_unity_s8)
inbuffer = gst_buffer_new_and_alloc (2); inbuffer = gst_buffer_new_and_alloc (2);
gst_buffer_fill (inbuffer, 0, in, 2); gst_buffer_fill (inbuffer, 0, in, 2);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -231,7 +231,7 @@ GST_START_TEST (test_half_s8)
inbuffer = gst_buffer_new_and_alloc (2); inbuffer = gst_buffer_new_and_alloc (2);
gst_buffer_fill (inbuffer, 0, in, 2); gst_buffer_fill (inbuffer, 0, in, 2);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -279,7 +279,7 @@ GST_START_TEST (test_double_s8)
inbuffer = gst_buffer_new_and_alloc (2); inbuffer = gst_buffer_new_and_alloc (2);
gst_buffer_fill (inbuffer, 0, in, 2); gst_buffer_fill (inbuffer, 0, in, 2);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -316,6 +316,7 @@ GST_START_TEST (test_ten_s8)
gint8 in[2] = { 64, -10 }; gint8 in[2] = { 64, -10 };
gint8 out[2] = { 127, -100 }; /* notice the clamped sample */ gint8 out[2] = { 127, -100 }; /* notice the clamped sample */
gint8 *res; gint8 *res;
gsize size;
volume = setup_volume (); volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL); g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@ -324,10 +325,10 @@ GST_START_TEST (test_ten_s8)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (2); inbuffer = gst_buffer_new_and_alloc (2);
memcpy (GST_BUFFER_DATA (inbuffer), in, 2); gst_buffer_fill (inbuffer, 0, in, 2);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 2) == 0); fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 2) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -343,10 +344,11 @@ GST_START_TEST (test_ten_s8)
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer); fail_unless (inbuffer == outbuffer);
res = (gint8 *) GST_BUFFER_DATA (outbuffer); res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0], GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
res[1]); res[1]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 2) == 0); fail_unless (memcmp (res, out, 2) == 0);
gst_buffer_unmap (outbuffer, res, size);
/* cleanup */ /* cleanup */
cleanup_volume (volume); cleanup_volume (volume);
@ -374,7 +376,7 @@ GST_START_TEST (test_mute_s8)
inbuffer = gst_buffer_new_and_alloc (2); inbuffer = gst_buffer_new_and_alloc (2);
gst_buffer_fill (inbuffer, 0, in, 2); gst_buffer_fill (inbuffer, 0, in, 2);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -419,7 +421,7 @@ GST_START_TEST (test_unity_s16)
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_fill (inbuffer, 0, in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -461,7 +463,7 @@ GST_START_TEST (test_half_s16)
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_fill (inbuffer, 0, in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -509,7 +511,7 @@ GST_START_TEST (test_double_s16)
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_fill (inbuffer, 0, in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -546,6 +548,7 @@ GST_START_TEST (test_ten_s16)
gint16 in[2] = { 16384, -10 }; gint16 in[2] = { 16384, -10 };
gint16 out[2] = { 32767, -100 }; /* notice the clamped sample */ gint16 out[2] = { 32767, -100 }; /* notice the clamped sample */
gint16 *res; gint16 *res;
gsize size;
volume = setup_volume (); volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL); g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@ -554,10 +557,10 @@ GST_START_TEST (test_ten_s16)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (inbuffer), in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0); fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -573,10 +576,11 @@ GST_START_TEST (test_ten_s16)
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer); fail_unless (inbuffer == outbuffer);
res = (gint16 *) GST_BUFFER_DATA (outbuffer); res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0], GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
res[1]); res[1]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 4) == 0); fail_unless (memcmp (res, out, 4) == 0);
gst_buffer_unmap (outbuffer, res, size);
/* cleanup */ /* cleanup */
cleanup_volume (volume); cleanup_volume (volume);
@ -605,7 +609,7 @@ GST_START_TEST (test_mute_s16)
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_fill (inbuffer, 0, in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -663,7 +667,7 @@ GST_START_TEST (test_unity_s24)
inbuffer = gst_buffer_new_and_alloc (6); inbuffer = gst_buffer_new_and_alloc (6);
gst_buffer_fill (inbuffer, 0, in, 6); gst_buffer_fill (inbuffer, 0, in, 6);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -715,7 +719,7 @@ GST_START_TEST (test_half_s24)
inbuffer = gst_buffer_new_and_alloc (6); inbuffer = gst_buffer_new_and_alloc (6);
gst_buffer_fill (inbuffer, 0, in, 6); gst_buffer_fill (inbuffer, 0, in, 6);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -772,7 +776,7 @@ GST_START_TEST (test_double_s24)
inbuffer = gst_buffer_new_and_alloc (6); inbuffer = gst_buffer_new_and_alloc (6);
gst_buffer_fill (inbuffer, 0, in, 6); gst_buffer_fill (inbuffer, 0, in, 6);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -815,6 +819,7 @@ GST_START_TEST (test_ten_s24)
guint8 *res; guint8 *res;
gint32 res_32[2]; gint32 res_32[2];
gint32 out_32[2] = { 8388607, -100 }; /* notice the clamped sample */ gint32 out_32[2] = { 8388607, -100 }; /* notice the clamped sample */
gsize size;
write_unaligned_u24 (in, in_32[0]); write_unaligned_u24 (in, in_32[0]);
write_unaligned_u24 (in + 3, in_32[1]); write_unaligned_u24 (in + 3, in_32[1]);
@ -826,10 +831,10 @@ GST_START_TEST (test_ten_s24)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (6); inbuffer = gst_buffer_new_and_alloc (6);
memcpy (GST_BUFFER_DATA (inbuffer), in, 6); gst_buffer_fill (inbuffer, 0, in, 6);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 6) == 0); fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 6) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -845,7 +850,7 @@ GST_START_TEST (test_ten_s24)
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer); fail_unless (inbuffer == outbuffer);
res = GST_BUFFER_DATA (outbuffer); res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
res_32[0] = get_unaligned_i24 (res); res_32[0] = get_unaligned_i24 (res);
res_32[1] = get_unaligned_i24 ((res + 3)); res_32[1] = get_unaligned_i24 ((res + 3));
@ -853,6 +858,7 @@ GST_START_TEST (test_ten_s24)
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1], GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
res_32[0], res_32[1]); res_32[0], res_32[1]);
fail_unless (memcmp (res_32, out_32, 8) == 0); fail_unless (memcmp (res_32, out_32, 8) == 0);
gst_buffer_unmap (outbuffer, res, size);
/* cleanup */ /* cleanup */
cleanup_volume (volume); cleanup_volume (volume);
@ -885,7 +891,7 @@ GST_START_TEST (test_mute_s24)
inbuffer = gst_buffer_new_and_alloc (6); inbuffer = gst_buffer_new_and_alloc (6);
gst_buffer_fill (inbuffer, 0, in, 6); gst_buffer_fill (inbuffer, 0, in, 6);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -935,7 +941,7 @@ GST_START_TEST (test_unity_s32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -977,7 +983,7 @@ GST_START_TEST (test_half_s32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1025,7 +1031,7 @@ GST_START_TEST (test_double_s32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1062,6 +1068,7 @@ GST_START_TEST (test_ten_s32)
gint32 in[2] = { 1073741824, -10 }; gint32 in[2] = { 1073741824, -10 };
gint32 out[2] = { 2147483647, -100 }; /* notice the clamped sample */ gint32 out[2] = { 2147483647, -100 }; /* notice the clamped sample */
gint32 *res; gint32 *res;
gsize size;
volume = setup_volume (); volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL); g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@ -1070,10 +1077,10 @@ GST_START_TEST (test_ten_s32)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
memcpy (GST_BUFFER_DATA (inbuffer), in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0); fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1089,10 +1096,11 @@ GST_START_TEST (test_ten_s32)
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer); fail_unless (inbuffer == outbuffer);
res = (gint32 *) GST_BUFFER_DATA (outbuffer); res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0], GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
res[1]); res[1]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0); fail_unless (memcmp (res, out, 8) == 0);
gst_buffer_unmap (outbuffer, res, size);
/* cleanup */ /* cleanup */
cleanup_volume (volume); cleanup_volume (volume);
@ -1120,7 +1128,7 @@ GST_START_TEST (test_mute_s32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1165,7 +1173,7 @@ GST_START_TEST (test_unity_f32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -1208,7 +1216,7 @@ GST_START_TEST (test_half_f32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1257,7 +1265,7 @@ GST_START_TEST (test_double_f32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1295,6 +1303,7 @@ GST_START_TEST (test_ten_f32)
gfloat in[2] = { 0.75, -0.25 }; gfloat in[2] = { 0.75, -0.25 };
gfloat out[2] = { 7.5, -2.5 }; /* nothing is clamped */ gfloat out[2] = { 7.5, -2.5 }; /* nothing is clamped */
gfloat *res; gfloat *res;
gsize size;
volume = setup_volume (); volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL); g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@ -1303,10 +1312,10 @@ GST_START_TEST (test_ten_f32)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
memcpy (GST_BUFFER_DATA (inbuffer), in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0); fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1322,11 +1331,12 @@ GST_START_TEST (test_ten_f32)
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer); fail_unless (inbuffer == outbuffer);
res = (gfloat *) GST_BUFFER_DATA (outbuffer); res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1], GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
res[0], res[1]); res[0], res[1]);
fail_unless_equals_float (res[0], out[0]); fail_unless_equals_float (res[0], out[0]);
fail_unless_equals_float (res[1], out[1]); fail_unless_equals_float (res[1], out[1]);
gst_buffer_unmap (outbuffer, res, size);
/* cleanup */ /* cleanup */
cleanup_volume (volume); cleanup_volume (volume);
@ -1355,7 +1365,7 @@ GST_START_TEST (test_mute_f32)
inbuffer = gst_buffer_new_and_alloc (8); inbuffer = gst_buffer_new_and_alloc (8);
gst_buffer_fill (inbuffer, 0, in, 8); gst_buffer_fill (inbuffer, 0, in, 8);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1401,7 +1411,7 @@ GST_START_TEST (test_unity_f64)
inbuffer = gst_buffer_new_and_alloc (16); inbuffer = gst_buffer_new_and_alloc (16);
gst_buffer_fill (inbuffer, 0, in, 16); gst_buffer_fill (inbuffer, 0, in, 16);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -1444,7 +1454,7 @@ GST_START_TEST (test_half_f64)
inbuffer = gst_buffer_new_and_alloc (16); inbuffer = gst_buffer_new_and_alloc (16);
gst_buffer_fill (inbuffer, 0, in, 16); gst_buffer_fill (inbuffer, 0, in, 16);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1493,7 +1503,7 @@ GST_START_TEST (test_double_f64)
inbuffer = gst_buffer_new_and_alloc (16); inbuffer = gst_buffer_new_and_alloc (16);
gst_buffer_fill (inbuffer, 0, in, 16); gst_buffer_fill (inbuffer, 0, in, 16);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1531,6 +1541,7 @@ GST_START_TEST (test_ten_f64)
gdouble in[2] = { 0.75, -0.25 }; gdouble in[2] = { 0.75, -0.25 };
gdouble out[2] = { 7.5, -2.5 }; /* nothing is clamped */ gdouble out[2] = { 7.5, -2.5 }; /* nothing is clamped */
gdouble *res; gdouble *res;
gsize size;
volume = setup_volume (); volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL); g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@ -1539,10 +1550,10 @@ GST_START_TEST (test_ten_f64)
"could not set to playing"); "could not set to playing");
inbuffer = gst_buffer_new_and_alloc (16); inbuffer = gst_buffer_new_and_alloc (16);
memcpy (GST_BUFFER_DATA (inbuffer), in, 16); gst_buffer_fill (inbuffer, 0, in, 16);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0); fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1558,11 +1569,12 @@ GST_START_TEST (test_ten_f64)
fail_unless_equals_int (g_list_length (buffers), 1); fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer); fail_unless (inbuffer == outbuffer);
res = (gdouble *) GST_BUFFER_DATA (outbuffer); res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1], GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
res[0], res[1]); res[0], res[1]);
fail_unless_equals_float (res[0], out[0]); fail_unless_equals_float (res[0], out[0]);
fail_unless_equals_float (res[1], out[1]); fail_unless_equals_float (res[1], out[1]);
gst_buffer_unmap (outbuffer, res, size);
/* cleanup */ /* cleanup */
cleanup_volume (volume); cleanup_volume (volume);
@ -1591,7 +1603,7 @@ GST_START_TEST (test_mute_f64)
inbuffer = gst_buffer_new_and_alloc (16); inbuffer = gst_buffer_new_and_alloc (16);
gst_buffer_fill (inbuffer, 0, in, 16); gst_buffer_fill (inbuffer, 0, in, 16);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64); caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be /* FIXME: reffing the inbuffer should make the transformation not be
@ -1639,7 +1651,7 @@ GST_START_TEST (test_wrong_caps)
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_fill (inbuffer, 0, in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
caps = gst_caps_from_string (VOLUME_WRONG_CAPS_STRING); caps = gst_caps_from_string (VOLUME_WRONG_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_ref (inbuffer); gst_buffer_ref (inbuffer);
@ -1685,7 +1697,7 @@ GST_START_TEST (test_passthrough)
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_fill (inbuffer, 0, in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -1712,14 +1724,13 @@ GST_START_TEST (test_controller_usability)
GstInterpolationControlSource *csource; GstInterpolationControlSource *csource;
GstTimedValueControlSource *cs; GstTimedValueControlSource *cs;
GstElement *volume; GstElement *volume;
GValue value = { 0, };
volume = setup_volume (); volume = setup_volume ();
/* this shouldn't crash, whether this mode is implemented or not */ /* this shouldn't crash, whether this mode is implemented or not */
csource = gst_interpolation_control_source_new (); csource = gst_interpolation_control_source_new ();
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
gst_object_set_control_source (volume, "volume", gst_object_set_control_source (GST_OBJECT_CAST (volume), "volume",
GST_CONTROL_SOURCE (csource)); GST_CONTROL_SOURCE (csource));
cs = (GstTimedValueControlSource *) csource; cs = (GstTimedValueControlSource *) csource;
@ -1748,7 +1759,7 @@ GST_START_TEST (test_controller_processing)
csource = gst_interpolation_control_source_new (); csource = gst_interpolation_control_source_new ();
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
gst_object_set_control_source (volume, "volume", gst_object_set_control_source (GST_OBJECT_CAST (volume), "volume",
GST_CONTROL_SOURCE (csource)); GST_CONTROL_SOURCE (csource));
fail_unless (gst_element_set_state (volume, fail_unless (gst_element_set_state (volume,
@ -1758,7 +1769,7 @@ GST_START_TEST (test_controller_processing)
inbuffer = gst_buffer_new_and_alloc (4); inbuffer = gst_buffer_new_and_alloc (4);
gst_buffer_fill (inbuffer, 0, in, 4); gst_buffer_fill (inbuffer, 0, in, 4);
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16); caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
gst_buffer_set_caps (inbuffer, caps); gst_pad_set_caps (mysrcpad, caps);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
gst_caps_unref (caps); gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

View file

@ -41,9 +41,10 @@ break_mainloop (gpointer data)
return FALSE; return FALSE;
} }
static gboolean static GstPadProbeReturn
buffer_probe_cb (GstPad * pad, GstBuffer * buffer) buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{ {
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
GstClockTime new_ts = GST_BUFFER_TIMESTAMP (buffer); GstClockTime new_ts = GST_BUFFER_TIMESTAMP (buffer);
GST_LOG ("ts = %" GST_TIME_FORMAT, GST_TIME_ARGS (new_ts)); GST_LOG ("ts = %" GST_TIME_FORMAT, GST_TIME_ARGS (new_ts));
@ -90,7 +91,8 @@ GST_START_TEST (test_basetime_calculation)
pad = gst_element_get_static_pad (asink, "sink"); pad = gst_element_get_static_pad (asink, "sink");
fail_unless (pad != NULL, "Could not get pad out of sink"); fail_unless (pad != NULL, "Could not get pad out of sink");
gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe_cb), NULL); gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer_probe_cb, NULL,
NULL);
gst_element_set_locked_state (bin, TRUE); gst_element_set_locked_state (bin, TRUE);
/* Run main pipeline first */ /* Run main pipeline first */

View file

@ -34,16 +34,13 @@ int buffer_count = 0;
GstCaps *current_caps = NULL; GstCaps *current_caps = NULL;
int caps_change = 0; int caps_change = 0;
static gboolean static GstPadProbeReturn
buffer_probe (GstPad * pad, GstMiniObject * obj, gpointer data) buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer data)
{ {
GstBuffer *buffer; GstCaps *pad_caps;
GstCaps *buffer_caps;
GstElement *capsfilter = GST_ELEMENT (data); GstElement *capsfilter = GST_ELEMENT (data);
GstCaps *caps = NULL; GstCaps *caps = NULL;
buffer = GST_BUFFER (obj);
/* increment the buffer count and check if it is time to change the caps */ /* increment the buffer count and check if it is time to change the caps */
buffer_count++; buffer_count++;
if (buffer_count == 50) { if (buffer_count == 50) {
@ -62,24 +59,23 @@ buffer_probe (GstPad * pad, GstMiniObject * obj, gpointer data)
g_object_set (capsfilter, "caps", caps, NULL); g_object_set (capsfilter, "caps", caps, NULL);
gst_caps_unref (caps); gst_caps_unref (caps);
} }
/* now check if the pad caps has changed since last check */
/* now check if the buffer caps has changed since last check */ pad_caps = gst_pad_get_current_caps (pad);
buffer_caps = GST_BUFFER_CAPS (buffer); if (current_caps == NULL && pad_caps != NULL) {
if (current_caps == NULL && buffer_caps != NULL) {
/* probably the first caps, this is a change */ /* probably the first caps, this is a change */
current_caps = gst_caps_copy (buffer_caps); current_caps = gst_caps_copy (pad_caps);
caps_change++; caps_change++;
} else if (current_caps != NULL) { } else if (current_caps != NULL) {
if (buffer_caps == NULL) { if (pad_caps == NULL) {
/* caps was set to NULL, we consider this a change */ /* caps was set to NULL, we consider this a change */
gst_caps_unref (current_caps); gst_caps_unref (current_caps);
current_caps = NULL; current_caps = NULL;
caps_change++; caps_change++;
} else { } else {
if (!gst_caps_is_equal (current_caps, buffer_caps)) { if (!gst_caps_is_equal (current_caps, pad_caps)) {
/* a caps change */ /* a caps change */
gst_caps_unref (current_caps); gst_caps_unref (current_caps);
current_caps = gst_caps_copy (buffer_caps); current_caps = gst_caps_copy (pad_caps);
caps_change++; caps_change++;
} }
} }
@ -116,7 +112,8 @@ run_capsfilter_renegotiation (const gchar * launch_line)
g_assert (sink); g_assert (sink);
pad = gst_element_get_static_pad (sink, "sink"); pad = gst_element_get_static_pad (sink, "sink");
gst_pad_add_buffer_probe (pad, (GCallback) buffer_probe, capsfilter); gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer_probe, capsfilter,
NULL);
gst_object_unref (pad); gst_object_unref (pad);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

View file

@ -36,9 +36,12 @@
static int n_tags = 0; static int n_tags = 0;
static gboolean static GstPadProbeReturn
tag_event_probe_cb (GstPad * pad, GstEvent * event, GMainLoop * loop) tag_event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{ {
GMainLoop *loop = user_data;
GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG: case GST_EVENT_TAG:
{ {
@ -55,7 +58,7 @@ tag_event_probe_cb (GstPad * pad, GstEvent * event, GMainLoop * loop)
break; break;
} }
return TRUE; return GST_PAD_PROBE_OK;
} }
GST_START_TEST (test_multifdsink_gdp_tag) GST_START_TEST (test_multifdsink_gdp_tag)
@ -95,7 +98,8 @@ GST_START_TEST (test_multifdsink_gdp_tag)
fail_unless (pad != NULL, "Could not get pad out of depay"); fail_unless (pad != NULL, "Could not get pad out of depay");
gst_object_unref (depay); gst_object_unref (depay);
gst_pad_add_event_probe (pad, G_CALLBACK (tag_event_probe_cb), loop); gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
tag_event_probe_cb, loop, NULL);
gst_element_set_state (p1, GST_STATE_PLAYING); gst_element_set_state (p1, GST_STATE_PLAYING);
gst_element_set_state (p2, GST_STATE_PLAYING); gst_element_set_state (p2, GST_STATE_PLAYING);
@ -119,9 +123,10 @@ GST_END_TEST;
static int n_in_caps = 0; static int n_in_caps = 0;
static gboolean static GstPadProbeReturn
buffer_probe_cb (GstPad * pad, GstBuffer * buffer) buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{ {
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
guint8 *data; guint8 *data;
gsize size; gsize size;
@ -138,14 +143,13 @@ buffer_probe_cb (GstPad * pad, GstBuffer * buffer)
n_in_caps++; n_in_caps++;
caps = gst_buffer_get_caps (buffer); caps = gst_pad_get_current_caps (pad);
s = gst_caps_get_structure (caps, 0); s = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_has_field (s, "streamheader")); fail_unless (gst_structure_has_field (s, "streamheader"));
sh = gst_structure_get_value (s, "streamheader"); sh = gst_structure_get_value (s, "streamheader");
buffers = g_value_peek_pointer (sh); buffers = g_value_peek_pointer (sh);
assert_equals_int (buffers->len, 3); assert_equals_int (buffers->len, 3);
for (i = 0; i < 3; ++i) { for (i = 0; i < 3; ++i) {
GValue *val; GValue *val;
guint8 *data2; guint8 *data2;
@ -210,8 +214,10 @@ GST_START_TEST (test_multifdsink_gdp_vorbisenc)
fail_unless (pad != NULL, "Could not get pad out of depay"); fail_unless (pad != NULL, "Could not get pad out of depay");
gst_object_unref (depay); gst_object_unref (depay);
gst_pad_add_event_probe (pad, G_CALLBACK (tag_event_probe_cb), loop); gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe_cb), NULL); tag_event_probe_cb, loop, NULL);
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer_probe_cb, NULL,
NULL);
gst_element_set_state (p1, GST_STATE_PLAYING); gst_element_set_state (p1, GST_STATE_PLAYING);
gst_element_set_state (p2, GST_STATE_PLAYING); gst_element_set_state (p2, GST_STATE_PLAYING);