[vlc-devel] commit: Backport of 21f7e7ea477453871b494758c2dec31e0c23287c MMS: close access on network timeout (Jean-Paul Saman )
git version control
git at videolan.org
Mon Mar 31 14:19:26 CEST 2008
vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Mon Mar 31 14:12:29 2008 +0200| [3a71634a6e973d885ce779e8029efb66e672cd2f]
Backport of 21f7e7ea477453871b494758c2dec31e0c23287c MMS: close access on network timeout
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3a71634a6e973d885ce779e8029efb66e672cd2f
---
modules/access/mms/mms.c | 8 ++++++-
modules/access/mms/mmstu.c | 52 +++++++++++++++++++++++++++++++++-----------
modules/access/mms/mmstu.h | 4 ++-
3 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/modules/access/mms/mms.c b/modules/access/mms/mms.c
index d336b57..4405b17 100644
--- a/modules/access/mms/mms.c
+++ b/modules/access/mms/mms.c
@@ -2,7 +2,7 @@
* mms.c: MMS over tcp, udp and http access plug-in
*****************************************************************************
* Copyright (C) 2002-2004 the VideoLAN team
- * $Id$
+ * $Id: d336b57e7c9250cea85f3be6a6b8a20ae03d5db1 $
*
* Authors: Laurent Aimar <fenrir at via.ecp.fr>
*
@@ -57,6 +57,9 @@ static void Close( vlc_object_t * );
#define BITRATE_LONGTEXT N_( \
"Select the stream with the maximum bitrate under that limit." )
+#define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)")
+#define TIMEOUT_LONGTEXT N_("Amount of time (in ms) to wait before aborting network reception of data. Note that there will be 10 retries before completely giving up.")
+
vlc_module_begin();
set_shortname( "MMS" );
set_description( _("Microsoft Media Server (MMS) input") );
@@ -67,6 +70,9 @@ vlc_module_begin();
add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL,
CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
+ add_integer( "mms-timeout", 5000, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
+ VLC_TRUE );
+
add_bool( "mms-all", 0, NULL, ALL_TEXT, ALL_LONGTEXT, VLC_TRUE );
add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
VLC_FALSE );
diff --git a/modules/access/mms/mmstu.c b/modules/access/mms/mmstu.c
index 457ab56..f9691c3 100644
--- a/modules/access/mms/mmstu.c
+++ b/modules/access/mms/mmstu.c
@@ -2,7 +2,7 @@
* mms.c: MMS access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 the VideoLAN team
- * $Id$
+ * $Id: 457ab56a8dc457127802daa10a4b0fcc77f1f801 $
*
* Authors: Laurent Aimar <fenrir at via.ecp.fr>
*
@@ -125,8 +125,11 @@ int E_(MMSTUOpen)( access_t *p_access )
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
+ if( !p_sys ) return VLC_ENOMEM;
memset( p_sys, 0, sizeof( access_sys_t ) );
+ p_sys->i_timeout = var_CreateGetInteger( p_access, "mms-timeout" );
+
/* *** Parse URL and get server addr/port and path *** */
vlc_UrlParse( &p_sys->url, p_access->psz_path, 0 );
if( p_sys->url.psz_host == NULL || *p_sys->url.psz_host == '\0' )
@@ -357,7 +360,12 @@ static int Seek( access_t * p_access, int64_t i_pos )
while( !p_access->b_die )
{
- mms_HeaderMediaRead( p_access, MMS_PACKET_CMD );
+ if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 )
+ {
+ p_access->info.b_eof = VLC_TRUE;
+ return VLC_EGENERIC;
+ }
+
if( p_sys->i_command == 0x1e )
{
msg_Dbg( p_access, "received 0x1e (seek)" );
@@ -367,7 +375,11 @@ static int Seek( access_t * p_access, int64_t i_pos )
while( !p_access->b_die )
{
- mms_HeaderMediaRead( p_access, MMS_PACKET_CMD );
+ if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 )
+ {
+ p_access->info.b_eof = VLC_TRUE;
+ return VLC_EGENERIC;
+ }
if( p_sys->i_command == 0x05 )
{
msg_Dbg( p_access, "received 0x05 (seek)" );
@@ -376,7 +388,12 @@ static int Seek( access_t * p_access, int64_t i_pos )
}
/* get a packet */
- mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA );
+ if( mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ) < 0 )
+ {
+ p_access->info.b_eof = VLC_TRUE;
+ return VLC_EGENERIC;
+ }
+
msg_Dbg( p_access, "Streaming restarted" );
p_sys->i_media_used += i_offset;
@@ -398,7 +415,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
i_data = 0;
/* *** now send data if needed *** */
- while( i_data < (size_t)i_len )
+ while( i_data < i_len )
{
if( p_access->info.i_pos < p_sys->i_header )
{
@@ -515,7 +532,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto )
p_sys->i_buffer_udp = 0;
p_sys->p_cmd = NULL;
p_sys->i_cmd = 0;
- p_access->info.b_eof = 0;
+ p_access->info.b_eof = VLC_FALSE;
/* *** send command 1 : connection request *** */
var_buffer_initwrite( &buffer, 0 );
@@ -862,14 +879,15 @@ static int MMSStart( access_t *p_access, uint32_t i_packet )
msg_Err( p_access,
"unknown answer (0x%x instead of 0x05)",
p_sys->i_command );
- return( -1 );
+ return -1;
}
else
{
/* get a packet */
- mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA );
+ if( mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ) < 0 )
+ return -1;
msg_Dbg( p_access, "streaming started" );
- return( 0 );
+ return 0;
}
}
@@ -1046,6 +1064,12 @@ static int NetFillBuffer( access_t *p_access )
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
+ if( i_try * timeout > p_sys->i_timeout )
+ {
+ msg_Err(p_access, "no data received");
+ return -1;
+ }
+
if( i_try > 3 && (p_sys->i_buffer_tcp > 0 || p_sys->i_buffer_udp > 0) )
{
return -1;
@@ -1462,17 +1486,18 @@ static int mms_CommandRead( access_t *p_access, int i_command1,
{
case 0x03:
msg_Warn( p_access, "socket closed by server" );
- p_access->info.b_eof = 1;
+ p_access->info.b_eof = VLC_TRUE;
return VLC_EGENERIC;
case 0x1e:
msg_Warn( p_access, "end of media stream" );
- p_access->info.b_eof = 1;
+ p_access->info.b_eof = VLC_TRUE;
return VLC_EGENERIC;
default:
break;
}
}
}
+ p_access->info.b_eof = VLC_TRUE;
msg_Warn( p_access, "failed to receive command (aborting)" );
return VLC_EGENERIC;
@@ -1509,11 +1534,11 @@ static int mms_HeaderMediaRead( access_t *p_access, int i_type )
{
case 0x03:
msg_Warn( p_access, "socket closed by server" );
- p_access->info.b_eof = 1;
+ p_access->info.b_eof = VLC_TRUE;
return -1;
case 0x1e:
msg_Warn( p_access, "end of media stream" );
- p_access->info.b_eof = 1;
+ p_access->info.b_eof = VLC_TRUE;
return -1;
case 0x20:
/* XXX not too dificult to be done EXCEPT that we
@@ -1531,6 +1556,7 @@ static int mms_HeaderMediaRead( access_t *p_access, int i_type )
msg_Err( p_access, "cannot receive %s (aborting)",
( i_type == MMS_PACKET_HEADER ) ? "header" : "media data" );
+ p_access->info.b_eof = VLC_TRUE;
return -1;
}
diff --git a/modules/access/mms/mmstu.h b/modules/access/mms/mmstu.h
index bf84207..b265127 100644
--- a/modules/access/mms/mmstu.h
+++ b/modules/access/mms/mmstu.h
@@ -2,7 +2,7 @@
* mms.h: MMS access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 the VideoLAN team
- * $Id$
+ * $Id: bf842072474e9e733d468a0a17d2cf4b626ddf77 $
*
* Authors: Laurent Aimar <fenrir at via.ecp.fr>
*
@@ -43,6 +43,8 @@ struct access_sys_t
asf_header_t asfh;
+ unsigned i_timeout;
+
/* */
uint8_t buffer_tcp[MMS_BUFFER_SIZE];
int i_buffer_tcp;
More information about the vlc-devel
mailing list