ximagesink: Update for negotiation related API changes

This commit is contained in:
Sebastian Dröge 2011-05-11 17:39:52 +02:00
parent 219b610fdd
commit 6ed5013733

View file

@ -974,7 +974,7 @@ gst_ximagesink_xcontext_clear (GstXImageSink * ximagesink)
/* Element stuff */ /* Element stuff */
static GstCaps * static GstCaps *
gst_ximagesink_getcaps (GstBaseSink * bsink) gst_ximagesink_getcaps (GstBaseSink * bsink, GstCaps * filter)
{ {
GstXImageSink *ximagesink; GstXImageSink *ximagesink;
GstCaps *caps; GstCaps *caps;
@ -984,23 +984,48 @@ gst_ximagesink_getcaps (GstBaseSink * bsink)
g_mutex_lock (ximagesink->x_lock); g_mutex_lock (ximagesink->x_lock);
if (ximagesink->xcontext) { if (ximagesink->xcontext) {
GstCaps *caps;
caps = gst_caps_ref (ximagesink->xcontext->caps);
if (filter) {
GstCaps *intersection;
intersection =
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (caps);
caps = intersection;
}
if (ximagesink->xwindow && ximagesink->xwindow->width) { if (ximagesink->xwindow && ximagesink->xwindow->width) {
GstStructure *s0, *s1; GstStructure *s0, *s1;
caps = gst_caps_copy (ximagesink->xcontext->caps); caps = gst_caps_make_writable (caps);
s1 = gst_structure_copy (gst_caps_get_structure (caps, 0)); /* There can only be a single structure because the xcontext
* caps only have a single structure */
s0 = gst_caps_get_structure (caps, 0); s0 = gst_caps_get_structure (caps, 0);
s1 = gst_structure_copy (gst_caps_get_structure (caps, 0));
gst_structure_set (s0, "width", G_TYPE_INT, ximagesink->xwindow->width, gst_structure_set (s0, "width", G_TYPE_INT, ximagesink->xwindow->width,
"height", G_TYPE_INT, ximagesink->xwindow->height, NULL); "height", G_TYPE_INT, ximagesink->xwindow->height, NULL);
gst_caps_append_structure (caps, s1); gst_caps_append_structure (caps, s1);
g_mutex_unlock (ximagesink->x_lock);
return caps; /* This will not change the order but will remove the
} else { * fixed width/height caps again if not possible
caps = gst_caps_ref (ximagesink->xcontext->caps); * upstream */
g_mutex_unlock (ximagesink->x_lock); if (filter) {
return caps; GstCaps *intersection;
intersection =
gst_caps_intersect_full (caps, filter, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (caps);
caps = intersection;
}
} }
g_mutex_unlock (ximagesink->x_lock);
return caps;
} }
g_mutex_unlock (ximagesink->x_lock); g_mutex_unlock (ximagesink->x_lock);
@ -1021,6 +1046,15 @@ gst_ximagesink_getcaps (GstBaseSink * bsink)
} }
} }
if (filter) {
GstCaps *intersection;
intersection =
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (caps);
caps = intersection;
}
return caps; return caps;
} }