"http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
"if empty, the http_proxy environment variable will be tried." )
+#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") );
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 );
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' )
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)" );
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)" );
}
/* 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;
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 )
{
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 );
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;
}
}
/* We'll wait 0.5 second if nothing happens */
timeout = 500;
+ 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;
{
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;
{
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
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;
}