mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-07 15:02:40 +00:00
imagefreeze: fix query and _getcaps handling
This commit is contained in:
parent
9041a588f9
commit
ff616b1173
1 changed files with 41 additions and 31 deletions
|
@ -248,11 +248,26 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove framerate in writable @caps */
|
||||||
|
static void
|
||||||
|
gst_image_freeze_remove_fps (GstImageFreeze * self, GstCaps * caps)
|
||||||
|
{
|
||||||
|
gint i, n;
|
||||||
|
|
||||||
|
n = gst_caps_get_size (caps);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
GstStructure *s = gst_caps_get_structure (caps, i);
|
||||||
|
|
||||||
|
gst_structure_remove_field (s, "framerate");
|
||||||
|
gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT,
|
||||||
|
1, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
|
gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
|
||||||
{
|
{
|
||||||
GstCaps *ret, *tmp;
|
GstCaps *ret, *tmp, *templ;
|
||||||
guint i, n;
|
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
|
|
||||||
pad = self->sinkpad;
|
pad = self->sinkpad;
|
||||||
|
@ -263,22 +278,24 @@ gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
filter = gst_caps_copy (filter);
|
||||||
|
gst_image_freeze_remove_fps (self, filter);
|
||||||
|
}
|
||||||
|
templ = gst_pad_get_pad_template_caps (pad);
|
||||||
tmp = gst_pad_peer_query_caps (self->srcpad, filter);
|
tmp = gst_pad_peer_query_caps (self->srcpad, filter);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ret = gst_caps_intersect (tmp, gst_pad_get_pad_template_caps (pad));
|
GST_LOG_OBJECT (self, "peer caps %" GST_PTR_FORMAT, tmp);
|
||||||
|
ret = gst_caps_intersect (tmp, templ);
|
||||||
gst_caps_unref (tmp);
|
gst_caps_unref (tmp);
|
||||||
} else {
|
} else {
|
||||||
ret = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
GST_LOG_OBJECT (self, "going to copy");
|
||||||
|
ret = gst_caps_copy (templ);
|
||||||
}
|
}
|
||||||
|
gst_caps_unref (templ);
|
||||||
|
|
||||||
n = gst_caps_get_size (ret);
|
ret = gst_caps_make_writable (ret);
|
||||||
for (i = 0; i < n; i++) {
|
gst_image_freeze_remove_fps (self, ret);
|
||||||
GstStructure *s = gst_caps_get_structure (ret, i);
|
|
||||||
|
|
||||||
gst_structure_remove_field (s, "framerate");
|
|
||||||
gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT,
|
|
||||||
1, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
GST_LOG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, ret);
|
GST_LOG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, ret);
|
||||||
|
@ -291,15 +308,10 @@ gst_image_freeze_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
|
GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GstPad *peer = gst_pad_get_peer (self->srcpad);
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (pad, "Handling query of type '%s'",
|
GST_LOG_OBJECT (pad, "Handling query of type '%s'",
|
||||||
gst_query_type_get_name (GST_QUERY_TYPE (query)));
|
gst_query_type_get_name (GST_QUERY_TYPE (query)));
|
||||||
|
|
||||||
if (!peer) {
|
|
||||||
GST_INFO_OBJECT (pad, "No peer yet, dropping query");
|
|
||||||
ret = FALSE;
|
|
||||||
} else {
|
|
||||||
switch (GST_QUERY_TYPE (query)) {
|
switch (GST_QUERY_TYPE (query)) {
|
||||||
case GST_QUERY_CAPS:
|
case GST_QUERY_CAPS:
|
||||||
{
|
{
|
||||||
|
@ -313,9 +325,7 @@ gst_image_freeze_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ret = gst_pad_query_default (peer, parent, query);
|
ret = gst_pad_query_default (pad, parent, query);
|
||||||
}
|
|
||||||
gst_object_unref (peer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue