From: Thomas V. S. <tho...@pd...> - 2004-04-27 15:08:40
|
CVS Root: /home/cvs/gstreamer Module: gst-plugins Changes by: thomasvs Date: Tue Apr 27 2004 08:08:39 PDT Log message: use max width and height for fixation Modified files: . : ChangeLog sys/v4l : gstv4lsrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ChangeLog.diff?r1=1.572&r2=1.573 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/sys/v4l/gstv4lsrc.c.diff?r1=1.63&r2=1.64 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /home/cvs/gstreamer/gst-plugins/ChangeLog,v retrieving revision 1.572 retrieving revision 1.573 diff -u -d -r1.572 -r1.573 --- a/ChangeLog 27 Apr 2004 11:33:52 -0000 1.572 +++ b/ChangeLog 27 Apr 2004 15:08:22 -0000 1.573 @@ -1,6 +1,13 @@ 2004-04-27 Thomas Vander Stichele <thomas at apestaart dot org> * Makefile.am: + * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_init), (gst_v4lsrc_fixate), + (gst_v4lsrc_getcaps), (gst_v4lsrc_buffer_free): + fixate to max width and height of device + +2004-04-27 Thomas Vander Stichele <thomas at apestaart dot org> + * Makefile.am: * sys/v4l/gstv4l.c: * sys/v4l/gstv4lsrc.c: * sys/v4l/v4l_calls.c: Index: gstv4lsrc.c RCS file: /home/cvs/gstreamer/gst-plugins/sys/v4l/gstv4lsrc.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- a/gstv4lsrc.c 27 Apr 2004 11:33:52 -0000 1.63 +++ b/gstv4lsrc.c 27 Apr 2004 15:08:27 -0000 1.64 @@ -86,6 +86,7 @@ /* buffer functions */ static GstPadLinkReturn gst_v4lsrc_srcconnect (GstPad * pad, const GstCaps * caps); +static GstCaps *gst_v4lsrc_fixate (GstPad * pad, const GstCaps * caps); static GstCaps *gst_v4lsrc_getcaps (GstPad * pad); static GstData *gst_v4lsrc_get (GstPad * pad); @@ -214,6 +215,7 @@ gst_pad_set_get_function (v4lsrc->srcpad, gst_v4lsrc_get); gst_pad_set_getcaps_function (v4lsrc->srcpad, gst_v4lsrc_getcaps); + gst_pad_set_fixate_function (v4lsrc->srcpad, gst_v4lsrc_fixate); gst_pad_set_link_function (v4lsrc->srcpad, gst_v4lsrc_srcconnect); gst_pad_set_convert_function (v4lsrc->srcpad, gst_v4lsrc_src_convert); gst_pad_set_formats_function (v4lsrc->srcpad, gst_v4lsrc_get_formats); @@ -575,6 +577,37 @@ return GST_PAD_LINK_OK; } +static GstCaps * +gst_v4lsrc_fixate (GstPad * pad, const GstCaps * caps) +{ + GstStructure *structure; + GstCaps *newcaps; + GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad)); + struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap; + if (gst_caps_get_size (caps) > 1) + return NULL; + if (!vcap) { + GST_DEBUG_OBJECT (v4lsrc, "don't have device caps, cannot fixate"); + } + newcaps = gst_caps_copy (caps); + structure = gst_caps_get_structure (newcaps, 0); + GST_DEBUG_OBJECT (v4lsrc, "device reported w: %d-%d, h: %d-%d", + vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight); + if (gst_caps_structure_fixate_field_nearest_int (structure, "width", + vcap->maxwidth)) { + return newcaps; + if (gst_caps_structure_fixate_field_nearest_int (structure, "height", + vcap->maxheight)) { + gst_caps_free (newcaps); + return NULL; +} static GstCaps * gst_v4lsrc_getcaps (GstPad * pad) @@ -595,10 +628,12 @@ one = gst_v4lsrc_palette_to_caps (GPOINTER_TO_INT (item->data)); if (!one) g_print ("Palette %d gave no caps\n", GPOINTER_TO_INT (item->data)); - gst_caps_set_simple (one, - "width", GST_TYPE_INT_RANGE, vcap->minwidth, vcap->maxwidth, - "height", GST_TYPE_INT_RANGE, vcap->minheight, vcap->maxheight, - "framerate", G_TYPE_DOUBLE, gst_v4lsrc_get_fps (v4lsrc), NULL); + GST_DEBUG_OBJECT (v4lsrc, "Device reports w: %d-%d, h: %d-%d", + vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight); + gst_caps_set_simple (one, "width", GST_TYPE_INT_RANGE, vcap->minwidth, + vcap->maxwidth, "height", GST_TYPE_INT_RANGE, vcap->minheight, + vcap->maxheight, "framerate", G_TYPE_DOUBLE, + gst_v4lsrc_get_fps (v4lsrc), NULL); gst_caps_append (list, one); } |