From 0390f0d765545dcf4669b1e9592a133b223f6a8a Mon Sep 17 00:00:00 2001 From: Andoni Morales Date: Thu, 29 Jul 2010 16:08:03 +0200 Subject: [PATCH] dshowvideosrc: don't make a range if min==max Fixes bug #625138 --- sys/dshowsrcwrapper/gstdshow.cpp | 36 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/sys/dshowsrcwrapper/gstdshow.cpp b/sys/dshowsrcwrapper/gstdshow.cpp index b916dccf63..b2d577b71d 100644 --- a/sys/dshowsrcwrapper/gstdshow.cpp +++ b/sys/dshowsrcwrapper/gstdshow.cpp @@ -417,6 +417,9 @@ gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar * name, { GstCaps *video_caps = NULL; GstStructure *video_structure = NULL; + gint min_w, max_w; + gint min_h, max_h; + gint min_fr, max_fr; /* raw video format */ switch (video_format) { @@ -462,14 +465,31 @@ gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar * name, /* "The IAMStreamConfig::SetFormat method will set the frame rate to the closest */ /* value that the filter supports" as it said in the VIDEO_STREAM_CONFIG_CAPS dshwo doc */ - gst_structure_set (video_structure, - "width", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cx, - pin_mediatype->vscc.MaxOutputSize.cx, "height", GST_TYPE_INT_RANGE, - pin_mediatype->vscc.MinOutputSize.cy, - pin_mediatype->vscc.MaxOutputSize.cy, "framerate", - GST_TYPE_FRACTION_RANGE, - (gint) (10000000 / pin_mediatype->vscc.MaxFrameInterval), 1, - (gint) (10000000 / pin_mediatype->vscc.MinFrameInterval), 1, NULL); + min_w = pin_mediatype->vscc.MinOutputSize.cx; + max_w = pin_mediatype->vscc.MaxOutputSize.cx; + min_h = pin_mediatype->vscc.MinOutputSize.cy; + max_h = pin_mediatype->vscc.MaxOutputSize.cy; + min_fr = (gint) (10000000 / pin_mediatype->vscc.MaxFrameInterval); + max_fr = (gint)(10000000 / pin_mediatype->vscc.MinFrameInterval); + + if (min_w == max_w) + gst_structure_set (video_structure, "width", G_TYPE_INT, min_w, NULL); + else + gst_structure_set (video_structure, + "width", GST_TYPE_INT_RANGE, min_w, max_w, NULL); + + if (min_h == max_h) + gst_structure_set (video_structure, "height", G_TYPE_INT, min_h, NULL); + else + gst_structure_set (video_structure, + "height", GST_TYPE_INT_RANGE, min_h, max_h, NULL); + + if (min_fr == max_fr) + gst_structure_set (video_structure, "framerate", + GST_TYPE_FRACTION, min_fr, 1, NULL); + else + gst_structure_set (video_structure, "framerate", + GST_TYPE_FRACTION_RANGE, min_fr, 1, max_fr, 1, NULL); return video_caps; }