2 --- b/gst-libs/gst/video/gstvideoaggregator.c
3 +++ a/gst-libs/gst/video/gstvideoaggregator.c
9 G_DEFINE_TYPE (GstVideoAggregatorPad, gst_videoaggregator_pad,
10 GST_TYPE_AGGREGATOR_PAD);
16 +G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstVideoAggregator, gst_videoaggregator,
17 + GST_TYPE_AGGREGATOR, G_IMPLEMENT_INTERFACE (GST_TYPE_CHILD_PROXY,
18 + gst_videoaggregator_child_proxy_init));
19 -/* Can't use the G_DEFINE_TYPE macros because we need the
20 - * videoaggregator class in the _init to be able to set
21 - * the sink pad non-alpha caps. Using the G_DEFINE_TYPE there
22 - * seems to be no way of getting the real class being initialized */
23 -static void gst_videoaggregator_init (GstVideoAggregator * self,
24 - GstVideoAggregatorClass * klass);
25 -static void gst_videoaggregator_class_init (GstVideoAggregatorClass * klass);
26 -static gpointer gst_videoaggregator_parent_class = NULL;
27 -static gint GstVideoAggregator_private_offset;
29 -_G_DEFINE_TYPE_EXTENDED_CLASS_INIT (GstVideoAggregator, gst_videoaggregator);
31 -G_GNUC_UNUSED static inline gpointer
32 -gst_videoaggregator_get_instance_private (const GstVideoAggregator * self)
34 - return (G_STRUCT_MEMBER_P (self, GstVideoAggregator_private_offset));
38 -gst_videoaggregator_get_type (void)
40 - static volatile gsize g_define_type_id_volatile = 0;
41 - if (g_once_init_enter (&g_define_type_id_volatile)) {
42 - GType g_define_type_id = g_type_register_static_simple (GST_TYPE_AGGREGATOR,
43 - g_intern_static_string ("GstVideoAggregator"),
44 - sizeof (GstVideoAggregatorClass),
45 - (GClassInitFunc) gst_videoaggregator_class_intern_init,
46 - sizeof (GstVideoAggregator),
47 - (GInstanceInitFunc) gst_videoaggregator_init,
48 - (GTypeFlags) G_TYPE_FLAG_ABSTRACT);
50 - G_IMPLEMENT_INTERFACE (GST_TYPE_CHILD_PROXY,
51 - gst_videoaggregator_child_proxy_init);
53 - g_once_init_leave (&g_define_type_id_volatile, g_define_type_id);
55 - return g_define_type_id_volatile;
59 gst_videoaggreagator_find_best_format (GstVideoAggregator * vagg,
65 -gst_videoaggregator_caps_has_alpha (GstCaps * caps)
67 - guint size = gst_caps_get_size (caps);
70 - for (i = 0; i < size; i++) {
71 - GstStructure *s = gst_caps_get_structure (caps, i);
72 - const GValue *formats = gst_structure_get_value (s, "format");
75 - const GstVideoFormatInfo *info;
77 - if (GST_VALUE_HOLDS_LIST (formats)) {
78 - guint list_size = gst_value_list_get_size (formats);
81 - for (index = 0; index < list_size; index++) {
82 - const GValue *list_item = gst_value_list_get_value (formats, index);
84 - gst_video_format_get_info (gst_video_format_from_string
85 - (g_value_get_string (list_item)));
86 - if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (info))
90 - } else if (G_VALUE_HOLDS_STRING (formats)) {
92 - gst_video_format_get_info (gst_video_format_from_string
93 - (g_value_get_string (formats)));
94 - if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (info))
98 - g_assert_not_reached ();
99 - GST_WARNING ("Unexpected type for video 'format' field: %s",
100 - G_VALUE_TYPE_NAME (formats));
111 gst_videoaggregator_pad_sink_getcaps (GstPad * pad, GstVideoAggregator * vagg,
115 + GstCaps *template_caps;
116 - GstCaps *template_caps, *sink_template_caps;
117 GstCaps *returned_caps;
119 + gboolean had_current_caps = TRUE;
121 GstAggregator *agg = GST_AGGREGATOR (vagg);
122 - GstPad *srcpad = GST_PAD (agg->srcpad);
123 - gboolean has_alpha;
125 + template_caps = gst_pad_get_pad_template_caps (GST_PAD (agg->srcpad));
126 - template_caps = gst_pad_get_pad_template_caps (srcpad);
128 + srccaps = gst_pad_get_current_caps (GST_PAD (agg->srcpad));
129 - GST_DEBUG_OBJECT (pad, "Get caps with filter: %" GST_PTR_FORMAT, filter);
131 - srccaps = gst_pad_get_current_caps (srcpad);
132 if (srccaps == NULL) {
133 + had_current_caps = FALSE;
134 + srccaps = template_caps;
135 - srccaps = gst_pad_peer_query_caps (srcpad, template_caps);
136 - GST_DEBUG_OBJECT (pad, "No output caps, using possible formats: %"
137 - GST_PTR_FORMAT, srccaps);
139 - GST_DEBUG_OBJECT (pad, "Using output caps: %" GST_PTR_FORMAT, srccaps);
142 srccaps = gst_caps_make_writable (srccaps);
143 - has_alpha = gst_videoaggregator_caps_has_alpha (srccaps);
145 n = gst_caps_get_size (srccaps);
146 for (i = 0; i < n; i++) {
148 returned_caps = srccaps;
151 + if (had_current_caps)
152 + gst_caps_unref (template_caps);
154 - sink_template_caps = gst_pad_get_pad_template_caps (pad);
156 - GstVideoAggregatorClass *klass = GST_VIDEO_AGGREGATOR_GET_CLASS (vagg);
157 - sink_template_caps = gst_caps_ref (klass->sink_non_alpha_caps);
161 - GstCaps *intersect = gst_caps_intersect (returned_caps, sink_template_caps);
162 - gst_caps_unref (returned_caps);
163 - returned_caps = intersect;
166 - gst_caps_unref (template_caps);
167 - gst_caps_unref (sink_template_caps);
169 - GST_DEBUG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, returned_caps);
171 return returned_caps;
173 @@ -2078,83 +1974,9 @@
174 g_type_class_ref (GST_TYPE_VIDEO_AGGREGATOR_PAD);
177 -static inline GstCaps *
178 -_get_non_alpha_caps_from_template (GstVideoAggregatorClass * klass)
181 - GstCaps *templatecaps;
185 - gst_pad_template_get_caps (gst_element_class_get_pad_template
186 - (GST_ELEMENT_CLASS (klass), "sink_%u"));
188 - size = gst_caps_get_size (templatecaps);
189 - result = gst_caps_new_empty ();
190 - for (i = 0; i < size; i++) {
191 - GstStructure *s = gst_caps_get_structure (templatecaps, i);
192 - const GValue *formats = gst_structure_get_value (s, "format");
193 - GValue new_formats = { 0, };
194 - gboolean has_format = FALSE;
196 - /* FIXME what to do if formats are missing? */
198 - const GstVideoFormatInfo *info;
200 - if (GST_VALUE_HOLDS_LIST (formats)) {
201 - guint list_size = gst_value_list_get_size (formats);
204 - g_value_init (&new_formats, GST_TYPE_LIST);
206 - for (index = 0; index < list_size; index++) {
207 - const GValue *list_item = gst_value_list_get_value (formats, index);
210 - gst_video_format_get_info (gst_video_format_from_string
211 - (g_value_get_string (list_item)));
212 - if (!GST_VIDEO_FORMAT_INFO_HAS_ALPHA (info)) {
214 - gst_value_list_append_value (&new_formats, list_item);
218 - } else if (G_VALUE_HOLDS_STRING (formats)) {
220 - gst_video_format_get_info (gst_video_format_from_string
221 - (g_value_get_string (formats)));
222 - if (!GST_VIDEO_FORMAT_INFO_HAS_ALPHA (info)) {
224 - gst_value_init_and_copy (&new_formats, formats);
228 - g_assert_not_reached ();
229 - GST_WARNING ("Unexpected type for video 'format' field: %s",
230 - G_VALUE_TYPE_NAME (formats));
234 - s = gst_structure_copy (s);
235 - gst_structure_take_value (s, "format", &new_formats);
236 - gst_caps_append_structure (result, s);
242 - gst_caps_unref (templatecaps);
247 -static GMutex sink_caps_mutex;
250 +gst_videoaggregator_init (GstVideoAggregator * vagg)
251 -gst_videoaggregator_init (GstVideoAggregator * vagg,
252 - GstVideoAggregatorClass * klass)
256 G_TYPE_INSTANCE_GET_PRIVATE (vagg, GST_TYPE_VIDEO_AGGREGATOR,
257 GstVideoAggregatorPrivate);
258 @@ -2162,13 +1984,6 @@
259 vagg->priv->current_caps = NULL;
261 g_mutex_init (&vagg->priv->lock);
263 /* initialize variables */
264 - g_mutex_lock (&sink_caps_mutex);
265 - if (klass->sink_non_alpha_caps == NULL) {
266 - klass->sink_non_alpha_caps = _get_non_alpha_caps_from_template (klass);
268 - g_mutex_unlock (&sink_caps_mutex);
270 gst_videoaggregator_reset (vagg);
273 --- b/gst-libs/gst/video/gstvideoaggregator.h
274 +++ a/gst-libs/gst/video/gstvideoaggregator.h
277 gboolean preserve_update_caps_result;
279 - GstCaps *sink_non_alpha_caps;
282 gpointer _gst_reserved[GST_PADDING_LARGE];