Add fixate function and test for bad caps

Original commit message from CVS:
Add fixate function and test for bad caps
This commit is contained in:
David Schleef 2004-01-02 10:04:34 +00:00
parent 2936894898
commit 5cb4c96e71
2 changed files with 38 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2004-01-02 David Schleef <ds@schleef.org>
* 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 <ds@schleef.org> 2004-01-01 David Schleef <ds@schleef.org>
Negotiation fixes: Negotiation fixes:

View file

@ -604,6 +604,32 @@ gst_xvimagesink_xcontext_clear (GstXvImageSink *xvimagesink)
/* Element stuff */ /* 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 static gint
gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink *xvimagesink, gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink *xvimagesink,
GstCaps *caps) GstCaps *caps)
@ -677,11 +703,15 @@ gst_xvimagesink_sinkconnect (GstPad *pad, const GstCaps *caps)
ret &= gst_structure_get_double (structure, "framerate", &xvimagesink->framerate); ret &= gst_structure_get_double (structure, "framerate", &xvimagesink->framerate);
if (!ret) return GST_PAD_LINK_REFUSED; if (!ret) return GST_PAD_LINK_REFUSED;
xvimagesink->xcontext->im_format = 0;
if (!gst_structure_get_fourcc (structure, "format", if (!gst_structure_get_fourcc (structure, "format",
&xvimagesink->xcontext->im_format)) { &xvimagesink->xcontext->im_format)) {
xvimagesink->xcontext->im_format = gst_xvimagesink_get_fourcc_from_caps ( xvimagesink->xcontext->im_format = gst_xvimagesink_get_fourcc_from_caps (
xvimagesink, gst_caps_copy(caps)); xvimagesink, gst_caps_copy(caps));
} }
if (xvimagesink->xcontext->im_format == 0) {
return GST_PAD_LINK_REFUSED;
}
xvimagesink->pixel_width = 1; xvimagesink->pixel_width = 1;
gst_structure_get_int (structure, "pixel_width", &xvimagesink->pixel_width); gst_structure_get_int (structure, "pixel_width", &xvimagesink->pixel_width);
@ -1084,6 +1114,8 @@ gst_xvimagesink_init (GstXvImageSink *xvimagesink)
gst_xvimagesink_sinkconnect); gst_xvimagesink_sinkconnect);
gst_pad_set_getcaps_function (GST_VIDEOSINK_PAD (xvimagesink), gst_pad_set_getcaps_function (GST_VIDEOSINK_PAD (xvimagesink),
gst_xvimagesink_getcaps); gst_xvimagesink_getcaps);
gst_pad_set_fixate_function (GST_VIDEOSINK_PAD (xvimagesink),
gst_xvimagesink_fixate);
xvimagesink->xcontext = NULL; xvimagesink->xcontext = NULL;
xvimagesink->xwindow = NULL; xvimagesink->xwindow = NULL;