mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-01 12:02:27 +00:00
basetextoverlay: Improve further the negotiation function
* Only send the caps event once if the query had support for the overlay composition meta. * Only do the allocation query if it is supported through caps. * Send overlay_caps before doing allocation query rather then normal caps https://bugzilla.gnome.org/show_bug.cgi?id=751157
This commit is contained in:
parent
c549523e7b
commit
f9e6d38bf9
1 changed files with 35 additions and 33 deletions
|
@ -760,7 +760,6 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay, GstCaps * caps)
|
|||
f = gst_caps_get_features (overlay_caps, 0);
|
||||
gst_caps_features_add (f,
|
||||
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
|
||||
ret = gst_pad_set_caps (overlay->srcpad, caps);
|
||||
|
||||
/* Then check if downstream accept overlay composition in caps */
|
||||
caps_has_meta = gst_pad_peer_query_accept_caps (overlay->srcpad,
|
||||
|
@ -769,35 +768,43 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay, GstCaps * caps)
|
|||
GST_DEBUG ("caps have overlay meta %d", caps_has_meta);
|
||||
}
|
||||
|
||||
/* First check if the allocation meta has compositon */
|
||||
query = gst_query_new_allocation (overlay_caps, FALSE);
|
||||
if (upstream_has_meta || caps_has_meta) {
|
||||
/* Send caps immediatly, it's needed by GstBaseTransform to get a reply
|
||||
* from allocation query */
|
||||
ret = gst_pad_set_caps (overlay->srcpad, overlay_caps);
|
||||
|
||||
if (!gst_pad_peer_query (overlay->srcpad, query)) {
|
||||
/* no problem, we use the query defaults */
|
||||
GST_DEBUG_OBJECT (overlay, "ALLOCATION query failed");
|
||||
/* First check if the allocation meta has compositon */
|
||||
query = gst_query_new_allocation (overlay_caps, FALSE);
|
||||
|
||||
/* In case we were flushing, mark reconfigure and fail this method,
|
||||
* will make it retry */
|
||||
if (overlay->video_flushing)
|
||||
ret = FALSE;
|
||||
}
|
||||
if (!gst_pad_peer_query (overlay->srcpad, query)) {
|
||||
/* no problem, we use the query defaults */
|
||||
GST_DEBUG_OBJECT (overlay, "ALLOCATION query failed");
|
||||
|
||||
alloc_has_meta = gst_query_find_allocation_meta (query,
|
||||
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, &alloc_index);
|
||||
/* In case we were flushing, mark reconfigure and fail this method,
|
||||
* will make it retry */
|
||||
if (overlay->video_flushing)
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG ("sink alloc has overlay meta %d", alloc_has_meta);
|
||||
alloc_has_meta = gst_query_find_allocation_meta (query,
|
||||
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, &alloc_index);
|
||||
|
||||
if (alloc_has_meta) {
|
||||
const GstStructure *params;
|
||||
GST_DEBUG ("sink alloc has overlay meta %d", alloc_has_meta);
|
||||
|
||||
gst_query_parse_nth_allocation_meta (query, alloc_index, ¶ms);
|
||||
if (params) {
|
||||
if (gst_structure_get (params, "width", G_TYPE_UINT, &width,
|
||||
"height", G_TYPE_UINT, &height, NULL)) {
|
||||
GST_DEBUG ("received window size: %dx%d", width, height);
|
||||
g_assert (width != 0 && height != 0);
|
||||
if (alloc_has_meta) {
|
||||
const GstStructure *params;
|
||||
|
||||
gst_query_parse_nth_allocation_meta (query, alloc_index, ¶ms);
|
||||
if (params) {
|
||||
if (gst_structure_get (params, "width", G_TYPE_UINT, &width,
|
||||
"height", G_TYPE_UINT, &height, NULL)) {
|
||||
GST_DEBUG ("received window size: %dx%d", width, height);
|
||||
g_assert (width != 0 && height != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gst_query_unref (query);
|
||||
}
|
||||
|
||||
/* Update render size if needed */
|
||||
|
@ -805,8 +812,6 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay, GstCaps * caps)
|
|||
overlay->window_height = height;
|
||||
gst_base_text_overlay_update_render_size (overlay);
|
||||
|
||||
gst_query_unref (query);
|
||||
|
||||
/* For backward compatbility, we will prefer bliting if downstream
|
||||
* allocation does not support the meta. In other case we will prefer
|
||||
* attaching, and will fail the negotiation in the unlikely case we are
|
||||
|
@ -827,24 +832,21 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay, GstCaps * caps)
|
|||
|
||||
/* If we attach, then pick the overlay caps */
|
||||
if (attach) {
|
||||
gst_caps_unref (caps);
|
||||
caps = overlay_caps;
|
||||
} else {
|
||||
gst_caps_unref (overlay_caps);
|
||||
}
|
||||
|
||||
/* If negotiation worked, set the caps and remember to attach */
|
||||
if (ret) {
|
||||
GST_DEBUG_OBJECT (overlay, "Using caps %" GST_PTR_FORMAT, overlay_caps);
|
||||
/* Caps where already sent */
|
||||
} else if (ret) {
|
||||
GST_DEBUG_OBJECT (overlay, "Using caps %" GST_PTR_FORMAT, caps);
|
||||
overlay->attach_compo_to_buffer = attach;
|
||||
ret = gst_pad_set_caps (overlay->srcpad, caps);
|
||||
}
|
||||
|
||||
overlay->attach_compo_to_buffer = attach;
|
||||
|
||||
if (!ret) {
|
||||
GST_DEBUG_OBJECT (overlay, "negotiation failed, schedule reconfigure");
|
||||
gst_pad_mark_reconfigure (overlay->srcpad);
|
||||
}
|
||||
|
||||
gst_caps_unref (overlay_caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue