mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
imagefreeze: simplify caps selection
The downstream caps query with a filter alraedy gives us the possible intersection so there is no need to check it again with downstream if it is supported. Just try to set it directly.
This commit is contained in:
parent
3aa0dd8629
commit
4ac0a49308
1 changed files with 10 additions and 12 deletions
|
@ -204,8 +204,8 @@ gst_image_freeze_sink_setcaps (GstImageFreeze * self, GstCaps * caps)
|
|||
caps = othercaps;
|
||||
othercaps = NULL;
|
||||
|
||||
/* 4. For every candidate check if it's accepted downstream
|
||||
* and fixate framerate to nearest 25/1 */
|
||||
/* 4. For every candidate try to use it downstream with framerate as
|
||||
* near as possible to 25/1 */
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
GstCaps *candidate = gst_caps_new_empty ();
|
||||
|
@ -214,28 +214,26 @@ gst_image_freeze_sink_setcaps (GstImageFreeze * self, GstCaps * caps)
|
|||
gst_caps_append_structure (candidate, s);
|
||||
if (gst_structure_has_field_typed (s, "framerate", GST_TYPE_FRACTION) ||
|
||||
gst_structure_fixate_field_nearest_fraction (s, "framerate", 25, 1)) {
|
||||
if (gst_pad_peer_query_accept_caps (self->srcpad, candidate)) {
|
||||
gst_structure_get_fraction (s, "framerate", &fps_n, &fps_d);
|
||||
if (fps_d != 0) {
|
||||
gst_structure_get_fraction (s, "framerate", &fps_n, &fps_d);
|
||||
if (fps_d != 0) {
|
||||
if (gst_pad_set_caps (self->srcpad, candidate)) {
|
||||
g_mutex_lock (&self->lock);
|
||||
self->fps_n = fps_n;
|
||||
self->fps_d = fps_d;
|
||||
g_mutex_unlock (&self->lock);
|
||||
GST_DEBUG_OBJECT (pad, "Setting caps %" GST_PTR_FORMAT, candidate);
|
||||
gst_pad_set_caps (self->srcpad, candidate);
|
||||
gst_caps_unref (candidate);
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
} else {
|
||||
GST_WARNING_OBJECT (pad, "Invalid caps with framerate %d/%d", fps_n,
|
||||
fps_d);
|
||||
gst_caps_unref (candidate);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING_OBJECT (pad, "Invalid caps with framerate %d/%d", fps_n,
|
||||
fps_d);
|
||||
}
|
||||
}
|
||||
gst_caps_unref (candidate);
|
||||
}
|
||||
|
||||
done:
|
||||
if (!ret)
|
||||
GST_ERROR_OBJECT (pad, "No usable caps found");
|
||||
|
||||
|
|
Loading…
Reference in a new issue