mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
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.
This commit is contained in:
parent
5592bdd459
commit
a221e91936
2 changed files with 45 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2007-08-23 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2007-08-22 Wim Taymans <wim.taymans@gmail.com>
|
2007-08-22 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_do_seek),
|
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_do_seek),
|
||||||
|
|
|
@ -91,6 +91,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <gst/sdp/gstsdpmessage.h>
|
#include <gst/sdp/gstsdpmessage.h>
|
||||||
#include <gst/rtsp/gstrtsprange.h>
|
#include <gst/rtsp/gstrtsprange.h>
|
||||||
|
@ -3983,6 +3986,36 @@ gst_rtspsrc_parse_rtpinfo (GstRTSPSrc * src, gchar * rtpinfo)
|
||||||
return TRUE;
|
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
|
static gboolean
|
||||||
gst_rtspsrc_play (GstRTSPSrc * src)
|
gst_rtspsrc_play (GstRTSPSrc * src)
|
||||||
{
|
{
|
||||||
|
@ -4013,7 +4046,7 @@ gst_rtspsrc_play (GstRTSPSrc * src)
|
||||||
hval = g_strdup_printf ("npt=0-");
|
hval = g_strdup_printf ("npt=0-");
|
||||||
else
|
else
|
||||||
hval =
|
hval =
|
||||||
g_strdup_printf ("npt=%f-",
|
gst_rtspsrc_dup_printf ("npt=%f-",
|
||||||
((gdouble) src->segment.last_stop) / GST_SECOND);
|
((gdouble) src->segment.last_stop) / GST_SECOND);
|
||||||
|
|
||||||
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_RANGE, hval);
|
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) {
|
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);
|
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SPEED, hval);
|
||||||
g_free (hval);
|
g_free (hval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->segment.applied_rate != 1.0) {
|
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);
|
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SCALE, hval);
|
||||||
g_free (hval);
|
g_free (hval);
|
||||||
}
|
}
|
||||||
|
@ -4050,7 +4083,7 @@ gst_rtspsrc_play (GstRTSPSrc * src)
|
||||||
0) == GST_RTSP_OK) {
|
0) == GST_RTSP_OK) {
|
||||||
gfloat fval;
|
gfloat fval;
|
||||||
|
|
||||||
if (sscanf (hval, "%f", &fval) > 0)
|
if (gst_rtspsrc_get_float (hval, &fval) > 0)
|
||||||
src->segment.rate = fval;
|
src->segment.rate = fval;
|
||||||
} else {
|
} else {
|
||||||
src->segment.rate = 1.0;
|
src->segment.rate = 1.0;
|
||||||
|
@ -4062,7 +4095,7 @@ gst_rtspsrc_play (GstRTSPSrc * src)
|
||||||
0) == GST_RTSP_OK) {
|
0) == GST_RTSP_OK) {
|
||||||
gfloat fval;
|
gfloat fval;
|
||||||
|
|
||||||
if (sscanf (hval, "%f", &fval) > 0)
|
if (gst_rtspsrc_get_float (hval, &fval) > 0)
|
||||||
src->segment.applied_rate = fval;
|
src->segment.applied_rate = fval;
|
||||||
} else {
|
} else {
|
||||||
src->segment.applied_rate = 1.0;
|
src->segment.applied_rate = 1.0;
|
||||||
|
|
Loading…
Reference in a new issue