/*****************************************************************************
* live.cpp : live.com support.
*****************************************************************************
- * Copyright (C) 2003-2004 VideoLAN
+ * Copyright (C) 2003-2004 VideoLAN (Centrale Réseaux) and its contributors
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
#include <vlc/vlc.h>
#include <vlc/input.h>
+#include "network.h"
#include <iostream>
struct demux_sys_t
{
char *p_sdp; /* XXX mallocated */
+ char *psz_path; /* URL-encoded path */
MediaSession *ms;
TaskScheduler *scheduler;
mtime_t i_start;
/* */
+ vlc_bool_t b_multicast; /* true if one of the tracks is multicasted */
vlc_bool_t b_no_data; /* true if we never receive any data */
int i_no_data_ti; /* consecutive number of TaskInterrupt */
{
/* See if it looks like a SDP
v, o, s fields are mandatory and in this order */
- if( stream_Peek( p_demux->s, &p_peek, 7 ) < 7 )
- {
- msg_Err( p_demux, "cannot peek" );
- return VLC_EGENERIC;
- }
+ if( stream_Peek( p_demux->s, &p_peek, 7 ) < 7 ) return VLC_EGENERIC;
+
if( strncmp( (char*)p_peek, "v=0\r\n", 5 ) &&
strncmp( (char*)p_peek, "v=0\n", 4 ) &&
( p_peek[0] < 'a' || p_peek[0] > 'z' || p_peek[1] != '=' ) )
{
- msg_Warn( p_demux, "SDP module discarded" );
return VLC_EGENERIC;
}
}
p_sys->p_out_asf = NULL;
p_sys->b_no_data = VLC_TRUE;
p_sys->i_no_data_ti = 0;
+ p_sys->b_multicast = VLC_FALSE;
+ p_sys->psz_path = p_demux->psz_path;
if( ( p_sys->scheduler = BasicTaskScheduler::createNew() ) == NULL )
goto error;
}
+ if( strcasecmp( p_demux->psz_access, "sdp" ) &&
+ vlc_UrlIsNotEncoded( p_sys->psz_path ) )
+ {
+ p_sys->psz_path = vlc_UrlEncode( p_sys->psz_path );
+ if( p_sys->psz_path == NULL )
+ goto error;
+ }
+
if( p_demux->s == NULL && !strcasecmp( p_demux->psz_access, "rtsp" ) )
{
char *psz_url;
p_sys->env->getResultMsg() );
goto error;
}
- psz_url = (char*)malloc( strlen( p_demux->psz_path ) + 8 );
- sprintf( psz_url, "rtsp://%s", p_demux->psz_path );
+ psz_url = (char*)malloc( strlen( p_sys->psz_path ) + 8 );
+ sprintf( psz_url, "rtsp://%s", p_sys->psz_path );
psz_options = p_sys->rtsp->sendOptionsCmd( psz_url );
if( psz_options )
}
else if( p_demux->s == NULL && !strcasecmp( p_demux->psz_access, "sdp" ) )
{
- p_sys->p_sdp = strdup( p_demux->psz_path );
+ p_sys->p_sdp = strdup( p_sys->psz_path );
}
else
{
p_sys->rtsp->setupMediaSubsession( *sub, False,
b_rtsp_tcp ? True : False );
}
+ if( !p_sys->b_multicast )
+ {
+ /* Check, because we need diff. rollover behaviour for multicast */
+ p_sys->b_multicast = IsMulticastAddress( sub->connectionEndpointAddress() );
+ }
}
}
{
free( p_sys->p_sdp );
}
+ if( ( p_sys->psz_path != NULL )
+ && ( p_sys->psz_path != p_demux->psz_path ) )
+ free( p_sys->psz_path );
+
free( p_sys );
return VLC_EGENERIC;
}
if( p_sys->env ) RECLAIM_ENV(p_sys->env);
if( p_sys->scheduler ) delete p_sys->scheduler;
if( p_sys->p_sdp ) free( p_sys->p_sdp );
+ if( p_sys->psz_path != p_demux->psz_path )
+ free( p_sys->psz_path );
free( p_sys );
}
}
}
- if( p_sys->b_no_data && p_sys->i_no_data_ti > 3 )
+ if( p_sys->b_multicast && p_sys->b_no_data && p_sys->i_no_data_ti > 120 )
+ {
+ /* FIXME Make this configurable
+ msg_Err( p_demux, "no multicast data received in 36s, aborting" );
+ return 0;
+ */
+ }
+ else if( !p_sys->b_multicast && p_sys->b_no_data && p_sys->i_no_data_ti > 34 )
{
vlc_bool_t b_rtsp_tcp = var_GetBool( p_demux, "rtsp-tcp" );
if( !b_rtsp_tcp && p_sys->rtsp && p_sys->ms )
{
- msg_Warn( p_demux, "no data received in 900ms. Switching to TCP" );
+ msg_Warn( p_demux, "no data received in 10s. Switching to TCP" );
if( RollOverTcp( p_demux ) )
{
msg_Err( p_demux, "TCP rollover failed, aborting" );
}
var_SetBool( p_demux, "rtsp-tcp", VLC_TRUE );
}
- else if( p_sys->i_no_data_ti > 10 )
+ else if( p_sys->i_no_data_ti > 34 )
{
- msg_Err( p_demux, "no data received in 3s, aborting" );
+ msg_Err( p_demux, "no data received in 10s, aborting" );
return 0;
}
}
- else if( p_sys->i_no_data_ti > 10 )
+ else if( !p_sys->b_multicast && p_sys->b_no_data&& p_sys->i_no_data_ti > 34 )
{
/* EOF ? */
- msg_Warn( p_demux, "no data received in 3s, eof ?" );
+ msg_Warn( p_demux, "no data received in 10s, eof ?" );
return 0;
}
return VLC_EGENERIC;
}
- asprintf( &psz_url, "rtsp://%s", p_demux->psz_path );
+ asprintf( &psz_url, "rtsp://%s", p_sys->psz_path );
if( ( psz_options = p_sys->rtsp->sendOptionsCmd( psz_url ) ) )
delete [] psz_options;