rtpjpegdepay: fix framerate parsing for locales that use a comma as floating point

atof() converts strings according to the current locale, but the
framerate string will likely always use a dot as floating point
separator, so use g_ascii_strtod() instead (but also canonicalise
the string before, so we can handle both formats as input).
This commit is contained in:
Tim-Philipp Müller 2010-12-29 14:40:05 +00:00
parent b5647685c4
commit fafd0b7bc3

View file

@ -460,15 +460,23 @@ gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
if (media_attr) { if (media_attr) {
GValue src = { 0 }; GValue src = { 0 };
GValue dest = { 0 }; GValue dest = { 0 };
gchar *s;
/* canonicalise floating point string so we can handle framerate strings
* in the form "24.930" or "24,930" irrespective of the current locale */
s = g_strdup (media_attr);
g_strdelimit (s, ",", '.');
/* convert the float to a fraction */ /* convert the float to a fraction */
g_value_init (&src, G_TYPE_DOUBLE); g_value_init (&src, G_TYPE_DOUBLE);
g_value_set_double (&src, atof (media_attr)); g_value_set_double (&src, g_ascii_strtod (s, NULL));
g_value_init (&dest, GST_TYPE_FRACTION); g_value_init (&dest, GST_TYPE_FRACTION);
g_value_transform (&src, &dest); g_value_transform (&src, &dest);
rtpjpegdepay->frate_num = gst_value_get_fraction_numerator (&dest); rtpjpegdepay->frate_num = gst_value_get_fraction_numerator (&dest);
rtpjpegdepay->frate_denom = gst_value_get_fraction_denominator (&dest); rtpjpegdepay->frate_denom = gst_value_get_fraction_denominator (&dest);
g_free (s);
} }
return TRUE; return TRUE;