From: David Schleef Date: Fri, 2 Jan 2004 10:04:34 +0000 (+0000) Subject: Add fixate function and test for bad caps X-Git-Tag: BEFORE_INDENT~443 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5cb4c96e71ec993bd3b3985ba8b12ad66d57d1f9;p=platform%2Fupstream%2Fgst-plugins-base.git Add fixate function and test for bad caps Original commit message from CVS: Add fixate function and test for bad caps --- diff --git a/ChangeLog b/ChangeLog index b796638..a6090f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-01-02 David Schleef + + * sys/xvimage/xvimagesink.c: (gst_xvimagesink_fixate), + (gst_xvimagesink_sinkconnect), (gst_xvimagesink_init): + Add fixate function and a check for bad formats. + 2004-01-01 David Schleef Negotiation fixes: diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 62b7b3a..fc41d39 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -604,6 +604,32 @@ gst_xvimagesink_xcontext_clear (GstXvImageSink *xvimagesink) /* Element stuff */ +static GstCaps * +gst_xvimagesink_fixate (GstPad *pad, const GstCaps *caps, gpointer ignore) +{ + GstStructure *structure; + GstCaps *newcaps; + + if (gst_caps_get_size (caps) > 1) return NULL; + + newcaps = gst_caps_copy (caps); + structure = gst_caps_get_structure (newcaps, 0); + + if (gst_caps_structure_fixate_field_nearest_int (structure, "width", 320)) { + return newcaps; + } + if (gst_caps_structure_fixate_field_nearest_int (structure, "height", 240)) { + return newcaps; + } + if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate", + 30.0)) { + return newcaps; + } + + gst_caps_free (newcaps); + return NULL; +} + static gint gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink *xvimagesink, GstCaps *caps) @@ -677,11 +703,15 @@ gst_xvimagesink_sinkconnect (GstPad *pad, const GstCaps *caps) ret &= gst_structure_get_double (structure, "framerate", &xvimagesink->framerate); if (!ret) return GST_PAD_LINK_REFUSED; + xvimagesink->xcontext->im_format = 0; if (!gst_structure_get_fourcc (structure, "format", &xvimagesink->xcontext->im_format)) { xvimagesink->xcontext->im_format = gst_xvimagesink_get_fourcc_from_caps ( xvimagesink, gst_caps_copy(caps)); } + if (xvimagesink->xcontext->im_format == 0) { + return GST_PAD_LINK_REFUSED; + } xvimagesink->pixel_width = 1; gst_structure_get_int (structure, "pixel_width", &xvimagesink->pixel_width); @@ -1084,6 +1114,8 @@ gst_xvimagesink_init (GstXvImageSink *xvimagesink) gst_xvimagesink_sinkconnect); gst_pad_set_getcaps_function (GST_VIDEOSINK_PAD (xvimagesink), gst_xvimagesink_getcaps); + gst_pad_set_fixate_function (GST_VIDEOSINK_PAD (xvimagesink), + gst_xvimagesink_fixate); xvimagesink->xcontext = NULL; xvimagesink->xwindow = NULL;