GValue * value, GParamSpec * pspec);
static gboolean gst_adder_setcaps (GstPad * pad, GstCaps * caps);
-static gboolean gst_adder_query (GstPad * pad, GstQuery ** query);
+static gboolean gst_adder_query (GstPad * pad, GstQuery * query);
static gboolean gst_adder_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_adder_sink_event (GstPad * pad, GstEvent * event);
* if we have filtercaps set, use those to constrain the target caps.
*/
static GstCaps *
-gst_adder_sink_getcaps (GstPad * pad)
+gst_adder_sink_getcaps (GstPad * pad, GstCaps * filter)
{
GstAdder *adder;
GstCaps *result, *peercaps, *sinkcaps, *filter_caps;
GST_OBJECT_LOCK (adder);
/* take filter */
- if ((filter_caps = adder->filter_caps))
- gst_caps_ref (filter_caps);
+ if ((filter_caps = adder->filter_caps)) {
+ if (filter)
+ filter_caps =
+ gst_caps_intersect_full (filter, filter_caps,
+ GST_CAPS_INTERSECT_FIRST);
+ else
+ gst_caps_ref (filter_caps);
+ } else {
+ filter_caps = gst_caps_ref (filter);
+ }
GST_OBJECT_UNLOCK (adder);
+ if (filter_caps && gst_caps_is_empty (filter_caps)) {
+ GST_WARNING_OBJECT (pad, "Empty filter caps");
+ return filter_caps;
+ }
+
/* get the downstream possible caps */
- peercaps = gst_pad_peer_get_caps (adder->srcpad);
+ peercaps = gst_pad_peer_get_caps (adder->srcpad, filter_caps);
/* get the allowed caps on this sinkpad */
sinkcaps = gst_pad_get_current_caps (pad);
if (sinkcaps == NULL) {
- sinkcaps = (GstCaps *) gst_pad_get_pad_template_caps (pad);
- if (sinkcaps)
- gst_caps_ref (sinkcaps);
- else
+ sinkcaps = gst_pad_get_pad_template_caps (pad);
+ if (!sinkcaps)
sinkcaps = gst_caps_new_any ();
}
if (peercaps) {
- /* restrict with filter-caps if any */
- if (filter_caps) {
- GST_DEBUG_OBJECT (adder, "filtering peer caps");
- result = gst_caps_intersect (peercaps, filter_caps);
- gst_caps_unref (peercaps);
- peercaps = result;
- }
/* if the peer has caps, intersect */
GST_DEBUG_OBJECT (adder, "intersecting peer and template caps");
- result = gst_caps_intersect (peercaps, sinkcaps);
+ result =
+ gst_caps_intersect_full (peercaps, sinkcaps, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (peercaps);
gst_caps_unref (sinkcaps);
} else {
/* restrict with filter-caps if any */
if (filter_caps) {
GST_DEBUG_OBJECT (adder, "no peer caps, using filtered sinkcaps");
- result = gst_caps_intersect (sinkcaps, filter_caps);
+ result =
+ gst_caps_intersect_full (filter_caps, sinkcaps,
+ GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (sinkcaps);
} else {
GST_DEBUG_OBJECT (adder, "no peer caps, using sinkcaps");
* cases work at least somewhat.
*/
static gboolean
-gst_adder_query_duration (GstAdder * adder, GstQuery ** query)
+gst_adder_query_duration (GstAdder * adder, GstQuery * query)
{
gint64 max;
gboolean res;
GValue item = { 0, };
/* parse format */
- gst_query_parse_duration (*query, &format, NULL);
+ gst_query_parse_duration (query, &format, NULL);
max = -1;
res = TRUE;
/* and store the max */
GST_DEBUG_OBJECT (adder, "Total duration in format %s: %"
GST_TIME_FORMAT, gst_format_get_name (format), GST_TIME_ARGS (max));
- gst_query_set_duration (*query, format, max);
+ gst_query_set_duration (query, format, max);
}
return res;
}
static gboolean
-gst_adder_query_latency (GstAdder * adder, GstQuery ** query)
+gst_adder_query_latency (GstAdder * adder, GstQuery * query)
{
GstClockTime min, max;
gboolean live;
peerquery = gst_query_new_latency ();
/* Ask peer for latency */
- res &= gst_pad_peer_query (pad, &peerquery);
+ res &= gst_pad_peer_query (pad, peerquery);
/* take max from all valid return values */
if (res) {
GST_DEBUG_OBJECT (adder, "Calculated total latency: live %s, min %"
GST_TIME_FORMAT ", max %" GST_TIME_FORMAT,
(live ? "yes" : "no"), GST_TIME_ARGS (min), GST_TIME_ARGS (max));
- gst_query_set_latency (*query, live, min, max);
+ gst_query_set_latency (query, live, min, max);
}
return res;
}
static gboolean
-gst_adder_query (GstPad * pad, GstQuery ** query)
+gst_adder_query (GstPad * pad, GstQuery * query)
{
GstAdder *adder = GST_ADDER (gst_pad_get_parent (pad));
gboolean res = FALSE;
- switch (GST_QUERY_TYPE (*query)) {
+ switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
{
GstFormat format;
- gst_query_parse_position (*query, &format, NULL);
+ gst_query_parse_position (query, &format, NULL);
switch (format) {
case GST_FORMAT_TIME:
/* FIXME, bring to stream time, might be tricky */
- gst_query_set_position (*query, format, adder->segment.position);
+ gst_query_set_position (query, format, adder->segment.position);
res = TRUE;
break;
case GST_FORMAT_DEFAULT:
- gst_query_set_position (*query, format, adder->offset);
+ gst_query_set_position (query, format, adder->offset);
res = TRUE;
break;
default:
adder = GST_ADDER (element);
/* increment pad counter */
+#if GLIB_CHECK_VERSION(2,29,5)
+ padcount = g_atomic_int_add (&adder->padcount, 1);
+#else
padcount = g_atomic_int_exchange_and_add (&adder->padcount, 1);
+#endif
name = g_strdup_printf ("sink%d", padcount);
newpad = gst_pad_new_from_template (templ, name);