mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
adder: use the collect_pads_query func
We were setting the query-func on the sink-pad, which got overwritten when adding the new pad to collect pads. Instead register our query-func with the collect pads object. This fixes filter caps. Add a test for it.
This commit is contained in:
parent
abfa8678ec
commit
cff9fccc69
2 changed files with 60 additions and 11 deletions
|
@ -112,8 +112,8 @@ static gboolean gst_adder_setcaps (GstAdder * adder, GstPad * pad,
|
|||
GstCaps * caps);
|
||||
static gboolean gst_adder_src_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query);
|
||||
static gboolean gst_adder_sink_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query);
|
||||
static gboolean gst_adder_sink_query (GstCollectPads * pads,
|
||||
GstCollectData * pad, GstQuery * query, gpointer user_data);
|
||||
static gboolean gst_adder_src_event (GstPad * pad, GstObject * parent,
|
||||
GstEvent * event);
|
||||
static gboolean gst_adder_sink_event (GstCollectPads * pads,
|
||||
|
@ -218,7 +218,8 @@ gst_adder_sink_getcaps (GstPad * pad, GstCaps * filter)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_adder_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
gst_adder_sink_query (GstCollectPads * pads, GstCollectData * pad,
|
||||
GstQuery * query, gpointer user_data)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
|
@ -228,16 +229,17 @@ gst_adder_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_adder_sink_getcaps (pad, filter);
|
||||
caps = gst_adder_sink_getcaps (pad->pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, parent, query);
|
||||
res = gst_collect_pads_query_default (pads, pad, query, FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -868,11 +870,6 @@ gst_adder_class_init (GstAdderClass * klass)
|
|||
gobject_class->get_property = gst_adder_get_property;
|
||||
gobject_class->dispose = gst_adder_dispose;
|
||||
|
||||
/**
|
||||
* GstAdder:caps:
|
||||
*
|
||||
* Since: 0.10.24
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_FILTER_CAPS,
|
||||
g_param_spec_boxed ("caps", "Target caps",
|
||||
"Set target format for mixing (NULL means ANY). "
|
||||
|
@ -926,6 +923,8 @@ gst_adder_init (GstAdder * adder)
|
|||
GST_DEBUG_FUNCPTR (gst_adder_do_clip), adder);
|
||||
gst_collect_pads_set_event_function (adder->collect,
|
||||
GST_DEBUG_FUNCPTR (gst_adder_sink_event), adder);
|
||||
gst_collect_pads_set_query_function (adder->collect,
|
||||
GST_DEBUG_FUNCPTR (gst_adder_sink_query), adder);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1024,7 +1023,6 @@ gst_adder_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
|||
GST_DEBUG_OBJECT (adder, "request new pad %s", name);
|
||||
g_free (name);
|
||||
|
||||
gst_pad_set_query_function (newpad, GST_DEBUG_FUNCPTR (gst_adder_sink_query));
|
||||
gst_collect_pads_add_pad (adder->collect, newpad, sizeof (GstCollectData),
|
||||
NULL, TRUE);
|
||||
|
||||
|
|
|
@ -76,6 +76,56 @@ GST_START_TEST (test_caps)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
/* check that caps set on the property are honoured */
|
||||
GST_START_TEST (test_filter_caps)
|
||||
{
|
||||
GstElement *pipeline, *src, *adder, *sink;
|
||||
GstStateChangeReturn state_res;
|
||||
GstCaps *filter_caps, *caps;
|
||||
GstPad *pad;
|
||||
|
||||
filter_caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, "F32LE",
|
||||
"layout", G_TYPE_STRING, "interleaved",
|
||||
"rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1, NULL);
|
||||
|
||||
/* build pipeline */
|
||||
pipeline = gst_pipeline_new ("pipeline");
|
||||
|
||||
src = gst_element_factory_make ("audiotestsrc", NULL);
|
||||
g_object_set (src, "wave", 4, NULL); /* silence */
|
||||
adder = gst_element_factory_make ("adder", NULL);
|
||||
g_object_set (adder, "caps", filter_caps, NULL);
|
||||
sink = gst_element_factory_make ("fakesink", "sink");
|
||||
gst_bin_add_many (GST_BIN (pipeline), src, adder, sink, NULL);
|
||||
|
||||
fail_unless (gst_element_link_many (src, adder, sink, NULL));
|
||||
|
||||
/* prepare playing */
|
||||
state_res = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||
fail_unless_equals_int (state_res, GST_STATE_CHANGE_ASYNC);
|
||||
|
||||
/* wait for preroll */
|
||||
state_res = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
||||
fail_unless_equals_int (state_res, GST_STATE_CHANGE_SUCCESS);
|
||||
|
||||
/* check caps on fakesink */
|
||||
pad = gst_element_get_static_pad (sink, "sink");
|
||||
caps = gst_pad_get_current_caps (pad);
|
||||
fail_unless (caps != NULL);
|
||||
GST_INFO_OBJECT (pipeline, "received caps: %" GST_PTR_FORMAT, caps);
|
||||
fail_unless (gst_caps_is_equal_fixed (caps, filter_caps));
|
||||
gst_caps_unref (caps);
|
||||
gst_object_unref (pad);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
|
||||
gst_caps_unref (filter_caps);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static void
|
||||
message_received (GstBus * bus, GstMessage * message, GstPipeline * bin)
|
||||
{
|
||||
|
@ -1028,6 +1078,7 @@ adder_suite (void)
|
|||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_caps);
|
||||
tcase_add_test (tc_chain, test_filter_caps);
|
||||
tcase_add_test (tc_chain, test_event);
|
||||
tcase_add_test (tc_chain, test_play_twice);
|
||||
tcase_add_test (tc_chain, test_play_twice_then_add_and_play_again);
|
||||
|
|
Loading…
Reference in a new issue