summaryrefslogtreecommitdiffstats
path: root/gst/rtsp
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-08-23 16:27:36 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-08-23 16:27:36 +0000
commita221e91936a2e2319931db4ec70c1c4bcf4ef684 (patch)
tree98e5139e083426ab33b2ae8fe4a19aca714fcce7 /gst/rtsp
parent5592bdd4592958b4e0ec231d79b3b9f3c784a4e1 (diff)
gst/rtsp/gstrtspsrc.c: Make sure we generate and parse floating point values in the POSIX locale instead of the curre...
Original commit message from CVS: * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_dup_printf), (gst_rtspsrc_get_float), (gst_rtspsrc_play): Make sure we generate and parse floating point values in the POSIX locale instead of the current locale.
Diffstat (limited to 'gst/rtsp')
-rw-r--r--gst/rtsp/gstrtspsrc.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index 415ecb70..fd6fa342 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -91,6 +91,9 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdarg.h>
#include <gst/sdp/gstsdpmessage.h>
#include <gst/rtsp/gstrtsprange.h>
@@ -3983,6 +3986,36 @@ gst_rtspsrc_parse_rtpinfo (GstRTSPSrc * src, gchar * rtpinfo)
return TRUE;
}
+#define USE_POSIX_LOCALE { \
+ gchar *__old_locale = g_strdup (setlocale (LC_NUMERIC, NULL)); \
+ setlocale (LC_NUMERIC, "POSIX");
+
+#define RESTORE_LOCALE \
+ setlocale (LC_NUMERIC, __old_locale); \
+ g_free (__old_locale);}
+
+static gchar *
+gst_rtspsrc_dup_printf (const gchar * format, ...)
+{
+ gchar *result;
+ va_list varargs;
+
+ USE_POSIX_LOCALE va_start (varargs, format);
+
+ result = g_strdup_vprintf (format, varargs);
+ va_end (varargs);
+ RESTORE_LOCALE return result;
+}
+
+static gint
+gst_rtspsrc_get_float (const char *str, gfloat * val)
+{
+ gint result;
+
+ USE_POSIX_LOCALE result = sscanf (str, "%f", val);
+ RESTORE_LOCALE return result;
+}
+
static gboolean
gst_rtspsrc_play (GstRTSPSrc * src)
{
@@ -4013,7 +4046,7 @@ gst_rtspsrc_play (GstRTSPSrc * src)
hval = g_strdup_printf ("npt=0-");
else
hval =
- g_strdup_printf ("npt=%f-",
+ gst_rtspsrc_dup_printf ("npt=%f-",
((gdouble) src->segment.last_stop) / GST_SECOND);
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_RANGE, hval);
@@ -4022,13 +4055,13 @@ gst_rtspsrc_play (GstRTSPSrc * src)
}
if (src->segment.rate != 1.0) {
- hval = g_strdup_printf ("%f", src->segment.rate);
+ hval = gst_rtspsrc_dup_printf ("%f", src->segment.rate);
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SPEED, hval);
g_free (hval);
}
if (src->segment.applied_rate != 1.0) {
- hval = g_strdup_printf ("%f", src->segment.applied_rate);
+ hval = gst_rtspsrc_dup_printf ("%f", src->segment.applied_rate);
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SCALE, hval);
g_free (hval);
}
@@ -4050,7 +4083,7 @@ gst_rtspsrc_play (GstRTSPSrc * src)
0) == GST_RTSP_OK) {
gfloat fval;
- if (sscanf (hval, "%f", &fval) > 0)
+ if (gst_rtspsrc_get_float (hval, &fval) > 0)
src->segment.rate = fval;
} else {
src->segment.rate = 1.0;
@@ -4062,7 +4095,7 @@ gst_rtspsrc_play (GstRTSPSrc * src)
0) == GST_RTSP_OK) {
gfloat fval;
- if (sscanf (hval, "%f", &fval) > 0)
+ if (gst_rtspsrc_get_float (hval, &fval) > 0)
src->segment.applied_rate = fval;
} else {
src->segment.applied_rate = 1.0;