videoaggregator: Move needs_alpha pad field to the private struct

And also trigger renegotiation if the value has changed.

https://bugzilla.gnome.org/show_bug.cgi?id=795836
This commit is contained in:
Sebastian Dröge 2018-05-05 16:14:14 +02:00
parent 83192bce84
commit 0680c3e47d
3 changed files with 36 additions and 6 deletions

View file

@ -72,6 +72,10 @@ struct _GstVideoAggregatorPadPrivate
guint zorder; guint zorder;
gboolean repeat_after_eos; gboolean repeat_after_eos;
/* Subclasses can force an alpha channel in the (input thus output)
* colorspace format */
gboolean needs_alpha;
/* Converter, if NULL no conversion is done */ /* Converter, if NULL no conversion is done */
GstVideoConverter *convert; GstVideoConverter *convert;
@ -435,6 +439,32 @@ gst_video_aggregator_pad_get_prepared_frame (GstVideoAggregatorPad * pad)
return pad->priv->prepared_frame.buffer ? &pad->priv->prepared_frame : NULL; return pad->priv->prepared_frame.buffer ? &pad->priv->prepared_frame : NULL;
} }
/**
* gst_video_aggregator_pad_set_needs_alpha:
* @pad: a #GstVideoAggregatorPad
* @needs_alpha: %TRUE if this pad requires alpha output
*
* Allows selecting that this pad requires an output format with alpha
*
* Returns: (transfer none): The currently prepared video frame
*/
void
gst_video_aggregator_pad_set_needs_alpha (GstVideoAggregatorPad * pad,
gboolean needs_alpha)
{
g_return_if_fail (GST_IS_VIDEO_AGGREGATOR_PAD (pad));
if (needs_alpha != pad->priv->needs_alpha) {
GstAggregator *agg =
GST_AGGREGATOR (gst_object_get_parent (GST_OBJECT (pad)));
pad->priv->needs_alpha = needs_alpha;
if (agg) {
gst_pad_mark_reconfigure (GST_AGGREGATOR_SRC_PAD (agg));
gst_object_unref (agg);
}
}
}
/************************************** /**************************************
* GstVideoAggregator implementation * * GstVideoAggregator implementation *
**************************************/ **************************************/
@ -562,7 +592,7 @@ gst_video_aggregator_find_best_format (GstVideoAggregator * vagg,
GINT_TO_POINTER (format_number)); GINT_TO_POINTER (format_number));
/* If that pad is the first with alpha, set it as the new best format */ /* If that pad is the first with alpha, set it as the new best format */
if (!need_alpha && (pad->needs_alpha if (!need_alpha && (pad->priv->needs_alpha
&& (!GST_VIDEO_FORMAT_INFO_HAS_ALPHA (pad->info.finfo)))) { && (!GST_VIDEO_FORMAT_INFO_HAS_ALPHA (pad->info.finfo)))) {
need_alpha = TRUE; need_alpha = TRUE;
/* Just fallback to ARGB in case we require alpha but the input pad /* Just fallback to ARGB in case we require alpha but the input pad

View file

@ -71,10 +71,6 @@ struct _GstVideoAggregatorPad
/* read-only, with OBJECT_LOCK */ /* read-only, with OBJECT_LOCK */
GstVideoInfo info; GstVideoInfo info;
/* Subclasses can force an alpha channel in the (input thus output)
* colorspace format */
gboolean needs_alpha;
/* < private > */ /* < private > */
GstVideoAggregatorPadPrivate *priv; GstVideoAggregatorPadPrivate *priv;
@ -122,6 +118,9 @@ GstBuffer * gst_video_aggregator_pad_get_current_buffer (GstVideoAggregatorPad *
GST_VIDEO_BAD_API GST_VIDEO_BAD_API
GstVideoFrame * gst_video_aggregator_pad_get_prepared_frame (GstVideoAggregatorPad *pad); GstVideoFrame * gst_video_aggregator_pad_get_prepared_frame (GstVideoAggregatorPad *pad);
GST_VIDEO_BAD_API
void gst_video_aggregator_pad_set_needs_alpha (GstVideoAggregatorPad *pad, gboolean needs_alpha);
#define GST_TYPE_VIDEO_AGGREGATOR (gst_video_aggregator_get_type()) #define GST_TYPE_VIDEO_AGGREGATOR (gst_video_aggregator_get_type())
#define GST_VIDEO_AGGREGATOR(obj) \ #define GST_VIDEO_AGGREGATOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR, GstVideoAggregator)) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR, GstVideoAggregator))

View file

@ -198,7 +198,8 @@ gst_compositor_pad_set_property (GObject * object, guint prop_id,
break; break;
case PROP_PAD_CROSSFADE_RATIO: case PROP_PAD_CROSSFADE_RATIO:
pad->crossfade = g_value_get_double (value); pad->crossfade = g_value_get_double (value);
GST_VIDEO_AGGREGATOR_PAD (pad)->needs_alpha = pad->crossfade >= 0.0f; gst_video_aggregator_pad_set_needs_alpha (GST_VIDEO_AGGREGATOR_PAD (pad),
pad->crossfade >= 0.0f);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);