Commit e1b39c52 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Partially fix parsing of npt=

parent 7c14959c
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
#include <vlc_strings.h> #include <vlc_strings.h>
#include <errno.h> #include <errno.h>
#ifndef WIN32
# include <locale.h>
#endif
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -919,6 +922,29 @@ static void RtspClientDel( vod_media_t *p_media, rtsp_client_t *p_rtsp ) ...@@ -919,6 +922,29 @@ static void RtspClientDel( vod_media_t *p_media, rtsp_client_t *p_rtsp )
free( p_rtsp ); free( p_rtsp );
} }
static float ParseNPT (const char *str)
{
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t oldloc = uselocale (loc);
unsigned hour, min;
float sec;
if (sscanf (str, "%u:%u:%f", &hour, &min, &sec) == 3)
sec += ((hour * 60) + min) * 60;
else
if (sscanf (str, "%f", &sec) != 1)
sec = 0.;
if (loc != (locale_t)0)
{
uselocale (oldloc);
freelocale (loc);
}
return sec;
}
static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
httpd_message_t *answer, const httpd_message_t *query ) httpd_message_t *answer, const httpd_message_t *query )
{ {
...@@ -1090,19 +1116,11 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -1090,19 +1116,11 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
psz_position = strstr( psz_position, "npt=" ); psz_position = strstr( psz_position, "npt=" );
if( psz_position && !psz_scale ) if( psz_position && !psz_scale )
{ {
double f_pos; double f_pos = ParseNPT (psz_position + 4);
char *end;
msg_Dbg( p_vod, "seeking request: %s", psz_position ); msg_Dbg( p_vod, "seeking request: %s", psz_position );
psz_position += 4;
/* FIXME: npt= is not necessarily formatted as a float */
f_pos = us_strtod( psz_position, &end );
if( end > psz_position )
{
f_pos /= ((double)(p_media->i_length))/1000 /1000 / 100; f_pos /= ((double)(p_media->i_length))/1000 /1000 / 100;
CommandPush( p_vod, RTSP_CMD_TYPE_SEEK, p_media, CommandPush( p_vod, RTSP_CMD_TYPE_SEEK, p_media,
psz_session, f_pos, NULL ); psz_session, f_pos, NULL );
}
break; break;
} }
if( psz_scale ) if( psz_scale )
...@@ -1423,21 +1441,12 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -1423,21 +1441,12 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl,
if( psz_position ) psz_position = strstr( psz_position, "npt=" ); if( psz_position ) psz_position = strstr( psz_position, "npt=" );
if( psz_position ) if( psz_position )
{ {
double f_pos; double f_pos = ParseNPT (psz_position + 4);
char *end;
msg_Dbg( p_vod, "seeking request: %s", psz_position ); msg_Dbg( p_vod, "seeking request: %s", psz_position );
psz_position += 4;
/* FIXME: npt= is not necessarily formatted as a float */
f_pos = us_strtod( psz_position, &end );
if( end > psz_position )
{
f_pos /= ((double)(p_media->i_length))/1000 /1000 / 100; f_pos /= ((double)(p_media->i_length))/1000 /1000 / 100;
CommandPush( p_vod, RTSP_CMD_TYPE_SEEK, p_media, CommandPush( p_vod, RTSP_CMD_TYPE_SEEK, p_media,
psz_session, f_pos, NULL ); psz_session, f_pos, NULL );
} }
}
if( !psz_playnow ) if( !psz_playnow )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment