X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Flive555.cpp;h=38257b40307bde773db808293fe92d39f4fca0a9;hb=f2f15f46eca071e5118bd115fc298cb507872fe4;hp=1842f56708dbbf3b183b92bd8d576c8c2b8cc98f;hpb=96e4e5f43914820bd36c12e8532d5908d678e02d;p=vlc diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp index 1842f56708..38257b4030 100644 --- a/modules/demux/live555.cpp +++ b/modules/demux/live555.cpp @@ -27,11 +27,19 @@ * Preamble *****************************************************************************/ +/* For inttypes.h + * Note: config.h may include inttypes.h, so make sure we define this option + * early enough. */ +#define __STDC_CONSTANT_MACROS 1 + #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include +#include + +#include +#include #include #include @@ -41,6 +49,7 @@ #include #include + #if defined( WIN32 ) # include #endif @@ -80,7 +89,7 @@ static void Close( vlc_object_t * ); "used for the connection.") vlc_module_begin(); - set_description( _("RTP/RTSP/SDP demuxer (using Live555)" ) ); + set_description( N_("RTP/RTSP/SDP demuxer (using Live555)" ) ); set_capability( "demux", 50 ); set_shortname( "RTP/RTSP"); set_callbacks( Open, Close ); @@ -90,7 +99,7 @@ vlc_module_begin(); set_subcategory( SUBCAT_INPUT_DEMUX ); add_submodule(); - set_description( _("RTSP/RTP access and demux") ); + set_description( N_("RTSP/RTP access and demux") ); add_shortcut( "rtsp" ); add_shortcut( "sdp" ); set_capability( "access_demux", 0 ); @@ -101,6 +110,9 @@ vlc_module_begin(); add_integer( "rtp-client-port", -1, NULL, N_("Client port"), N_("Port to use for the RTP source of the session"), true ); + add_bool( "rtsp-mcast", false, NULL, + N_("Force multicast RTP via RTSP"), + N_("Force multicast RTP via RTSP"), true ); add_bool( "rtsp-http", 0, NULL, N_("Tunnel RTSP and RTP over HTTP"), N_("Tunnel RTSP and RTP over HTTP"), true ); @@ -131,15 +143,15 @@ typedef struct es_format_t fmt; es_out_id_t *p_es; - bool b_muxed; - bool b_quicktime; - bool b_asf; + bool b_muxed; + bool b_quicktime; + bool b_asf; stream_t *p_out_muxed; /* for muxed stream */ uint8_t *p_buffer; unsigned int i_buffer; - bool b_rtcp_sync; + bool b_rtcp_sync; char waiting; int64_t i_pts; u_int32_t i_start_seq; @@ -187,8 +199,9 @@ struct demux_sys_t timeout_thread_t *p_timeout; /* the actual thread that makes sure we don't timeout */ /* */ - bool b_multicast; /* true if one of the tracks is multicasted */ - bool b_no_data; /* true if we never receive any data */ + bool b_force_mcast; + bool b_multicast; /* if one of the tracks is multicasted */ + bool b_no_data; /* if we never received any data */ int i_no_data_ti; /* consecutive number of TaskInterrupt */ char event; @@ -270,6 +283,7 @@ static int Open ( vlc_object_t *p_this ) p_sys->b_multicast = false; p_sys->b_real = false; p_sys->psz_path = strdup( p_demux->psz_path ); + p_sys->b_force_mcast = var_CreateGetBool( p_demux, "rtsp-mcast" ); /* parse URL for rtsp://[user:[passwd]@]serverip:port/options */ vlc_UrlParse( &p_sys->url, p_sys->psz_path, 0 ); @@ -383,6 +397,7 @@ error: live_track_t *tk = p_sys->track[i]; if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed ); + es_format_Clean( &tk->fmt ); free( tk->p_buffer ); free( tk ); } @@ -424,6 +439,7 @@ static void Close( vlc_object_t *p_this ) live_track_t *tk = p_sys->track[i]; if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed ); + es_format_Clean( &tk->fmt ); free( tk->p_buffer ); free( tk ); } @@ -457,8 +473,7 @@ static int Connect( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; Authenticator authenticator; - bool b_firstpass = true; - + bool b_firstpass = true; char *psz_user = NULL; char *psz_pwd = NULL; char *psz_url = NULL; @@ -466,27 +481,30 @@ static int Connect( demux_t *p_demux ) char *p_sdp = NULL; int i_http_port = 0; int i_ret = VLC_SUCCESS; + int i_lefttries; - psz_url = (char*)malloc( strlen( p_sys->psz_path ) + 8 ); - if( !psz_url ) return VLC_ENOMEM; - + if( p_sys->url.i_port == 0 ) p_sys->url.i_port = 554; if( p_sys->url.psz_username || p_sys->url.psz_password ) { - sprintf( psz_url, "rtsp://%s%s", p_sys->url.psz_host, - p_sys->url.psz_path ); + int err; + err = asprintf( &psz_url, "rtsp://%s:%d%s", p_sys->url.psz_host, + p_sys->url.i_port, p_sys->url.psz_path ); + if( err == -1 ) return VLC_ENOMEM; psz_user = strdup( p_sys->url.psz_username ); psz_pwd = strdup( p_sys->url.psz_password ); } else { - sprintf( psz_url, "rtsp://%s", p_sys->psz_path ); + int err; + err = asprintf( &psz_url, "rtsp://%s", p_sys->psz_path ); + if( err == -1 ) return VLC_ENOMEM; psz_user = var_CreateGetString( p_demux, "rtsp-user" ); psz_pwd = var_CreateGetString( p_demux, "rtsp-pwd" ); } - int i_lefttries = 3; + i_lefttries = 3; createnew: i_lefttries--; if( p_demux->b_die || p_demux->b_error ) @@ -501,7 +519,7 @@ createnew: i_http_port = var_CreateGetInteger( p_demux, "rtsp-http-port" ); if( ( p_sys->rtsp = RTSPClient::createNew( *p_sys->env, - p_demux->p_libvlc->i_verbose > 1, + var_CreateGetInteger( p_demux, "verbose" ) > 1, "VLC media player", i_http_port ) ) == NULL ) { msg_Err( p_demux, "RTSPClient::createNew failed (%s)", @@ -707,13 +725,18 @@ static int SessionsSetup( demux_t *p_demux ) /* Issue the SETUP */ if( p_sys->rtsp ) { - if( !( p_sys->rtsp->setupMediaSubsession( *sub, False, - b_rtsp_tcp ? True : False ) ) ) + bool tcp = b_rtsp_tcp; + bool mcast = p_sys->b_force_mcast; + if( !p_sys->rtsp->setupMediaSubsession( *sub, False, + tcp ? True : False, + ( mcast && !tcp ) ? True : False ) ) { + tcp = !tcp; /* if we get an unsupported transport error, toggle TCP use and try again */ if( !strstr(p_sys->env->getResultMsg(), "461 Unsupported Transport") - || !( p_sys->rtsp->setupMediaSubsession( *sub, False, - b_rtsp_tcp ? False : True ) ) ) + || !p_sys->rtsp->setupMediaSubsession( *sub, False, + tcp ? False : True, + ( mcast && !tcp ) ? True : False ) ) { msg_Err( p_demux, "SETUP of'%s/%s' failed %s", sub->mediumName(), sub->codecName(), p_sys->env->getResultMsg() ); @@ -976,6 +999,7 @@ static int SessionsSetup( demux_t *p_demux ) { /* BUG ??? */ msg_Err( p_demux, "unusable RTSP track. this should not happen" ); + es_format_Clean( &tk->fmt ); free( tk ); } } @@ -1377,7 +1401,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) case DEMUX_SET_PAUSE_STATE: { - double d_npt = (double) p_sys->i_npt / I64C(1000000); + double d_npt = (double) p_sys->i_npt / INT64_C(1000000); int i; b_bool = (bool)va_arg( args, int ); @@ -1476,6 +1500,7 @@ static int RollOverTcp( demux_t *p_demux ) live_track_t *tk = p_sys->track[i]; if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed ); + es_format_Clean( &tk->fmt ); free( tk->p_buffer ); free( tk ); } @@ -1536,11 +1561,11 @@ static void StreamRead( void *p_private, unsigned int i_size, //msg_Dbg( p_demux, "pts: %d", pts.tv_sec ); - int64_t i_pts = (uint64_t)pts.tv_sec * UI64C(1000000) + + int64_t i_pts = (uint64_t)pts.tv_sec * UINT64_C(1000000) + (uint64_t)pts.tv_usec; /* XXX Beurk beurk beurk Avoid having negative value XXX */ - i_pts &= UI64C(0x00ffffffffffffff); + i_pts &= UINT64_C(0x00ffffffffffffff); if( tk->b_quicktime && tk->p_es == NULL ) { @@ -1841,7 +1866,7 @@ static int ParseASF( demux_t *p_demux ) } /* Parse it to get packet size */ - E_(asf_HeaderParse)( &p_sys->asfh, p_header->p_buffer, p_header->i_buffer ); + asf_HeaderParse( &p_sys->asfh, p_header->p_buffer, p_header->i_buffer ); /* Send it to demuxer */ stream_DemuxSend( p_sys->p_out_asf, p_header );