Commit 3b75df1e authored by Laurent Aimar's avatar Laurent Aimar

Fixed rtsp broadcast streaming(sdp=rtsp://) and a potential double free.

parent 638023d7
...@@ -286,8 +286,8 @@ static int RtspCallbackId( httpd_callback_sys_t *, httpd_client_t *, ...@@ -286,8 +286,8 @@ static int RtspCallbackId( httpd_callback_sys_t *, httpd_client_t *,
httpd_message_t *, httpd_message_t * ); httpd_message_t *, httpd_message_t * );
static rtsp_client_t *RtspClientNew( sout_stream_t *, char *psz_session ); static rtsp_client_t *RtspClientNew( sout_stream_t *, const char *psz_session );
static rtsp_client_t *RtspClientGet( sout_stream_t *, char *psz_session ); static rtsp_client_t *RtspClientGet( sout_stream_t *, const char *psz_session );
static void RtspClientDel( sout_stream_t *, rtsp_client_t * ); static void RtspClientDel( sout_stream_t *, rtsp_client_t * );
/***************************************************************************** /*****************************************************************************
...@@ -899,7 +899,7 @@ static char *SDPGenerate( const sout_stream_t *p_stream, ...@@ -899,7 +899,7 @@ static char *SDPGenerate( const sout_stream_t *p_stream,
} }
if( b_rtsp ) if( b_rtsp )
{ {
p += sprintf( p, "a=control:trackID=%d\r\n", i ); p += sprintf( p, "a=control:/trackID=%d\r\n", i );
} }
} }
if( p_sys->p_mux ) if( p_sys->p_mux )
...@@ -1564,11 +1564,11 @@ static int HttpCallback( httpd_file_sys_t *p_args, ...@@ -1564,11 +1564,11 @@ static int HttpCallback( httpd_file_sys_t *p_args,
/**************************************************************************** /****************************************************************************
* RTSP: * RTSP:
****************************************************************************/ ****************************************************************************/
static rtsp_client_t *RtspClientNew( sout_stream_t *p_stream, char *psz_session ) static rtsp_client_t *RtspClientNew( sout_stream_t *p_stream, const char *psz_session )
{ {
rtsp_client_t *rtsp = malloc( sizeof( rtsp_client_t )); rtsp_client_t *rtsp = malloc( sizeof( rtsp_client_t ));
rtsp->psz_session = psz_session; rtsp->psz_session = strdup( psz_session );
rtsp->i_last = 0; rtsp->i_last = 0;
rtsp->b_playing = VLC_FALSE; rtsp->b_playing = VLC_FALSE;
rtsp->i_id = 0; rtsp->i_id = 0;
...@@ -1580,7 +1580,7 @@ static rtsp_client_t *RtspClientNew( sout_stream_t *p_stream, char *psz_session ...@@ -1580,7 +1580,7 @@ static rtsp_client_t *RtspClientNew( sout_stream_t *p_stream, char *psz_session
return rtsp; return rtsp;
} }
static rtsp_client_t *RtspClientGet( sout_stream_t *p_stream, char *psz_session ) static rtsp_client_t *RtspClientGet( sout_stream_t *p_stream, const char *psz_session )
{ {
int i; int i;
...@@ -1649,8 +1649,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args, ...@@ -1649,8 +1649,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
sout_stream_t *p_stream = (sout_stream_t*)p_args; sout_stream_t *p_stream = (sout_stream_t*)p_args;
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
char *psz_destination = p_sys->psz_destination; char *psz_destination = p_sys->psz_destination;
char *psz_session = NULL; const char *psz_session = NULL;
char *psz_cseq = NULL; const char *psz_cseq = NULL;
int i_cseq = 0; int i_cseq = 0;
if( answer == NULL || query == NULL ) if( answer == NULL || query == NULL )
...@@ -1672,7 +1672,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args, ...@@ -1672,7 +1672,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
answer->i_status = 200; answer->i_status = 200;
answer->psz_status = strdup( "OK" ); answer->psz_status = strdup( "OK" );
httpd_MsgAdd( answer, "Content-type", "%s", "application/sdp" ); httpd_MsgAdd( answer, "Content-type", "%s", "application/sdp" );
httpd_MsgAdd( answer, "Content-Base", "%s/", p_sys->psz_rtsp_control ); httpd_MsgAdd( answer, "Content-Base", "%s", p_sys->psz_rtsp_control );
answer->p_body = (uint8_t *)psz_sdp; answer->p_body = (uint8_t *)psz_sdp;
answer->i_body = strlen( psz_sdp ); answer->i_body = strlen( psz_sdp );
break; break;
...@@ -1773,9 +1773,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args, ...@@ -1773,9 +1773,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" ); httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session ) if( psz_session )
{
httpd_MsgAdd( answer, "Session", "%s;timeout=5", psz_session ); httpd_MsgAdd( answer, "Session", "%s;timeout=5", psz_session );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1786,17 +1784,20 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1786,17 +1784,20 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
sout_stream_id_t *id = (sout_stream_id_t*)p_args; sout_stream_id_t *id = (sout_stream_id_t*)p_args;
sout_stream_t *p_stream = id->p_stream; sout_stream_t *p_stream = id->p_stream;
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
char *psz_session = NULL; char psz_session_init[100];
char *psz_cseq = NULL; const char *psz_session = NULL;
const char *psz_cseq = NULL;
int i_cseq = 0; int i_cseq = 0;
if( answer == NULL || query == NULL ) if( answer == NULL || query == NULL )
{
return VLC_SUCCESS; return VLC_SUCCESS;
}
//fprintf( stderr, "RtspCallback query: type=%d\n", query->i_type ); //fprintf( stderr, "RtspCallback query: type=%d\n", query->i_type );
/* */
snprintf( psz_session_init, sizeof(psz_session_init), "%d", rand() );
/* */
answer->i_proto = HTTPD_PROTO_RTSP; answer->i_proto = HTTPD_PROTO_RTSP;
answer->i_version= query->i_version; answer->i_version= query->i_version;
answer->i_type = HTTPD_MSG_ANSWER; answer->i_type = HTTPD_MSG_ANSWER;
...@@ -1805,7 +1806,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1805,7 +1806,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
{ {
case HTTPD_MSG_SETUP: case HTTPD_MSG_SETUP:
{ {
char *psz_transport = httpd_MsgGet( query, "Transport" ); const char *psz_transport = httpd_MsgGet( query, "Transport" );
//fprintf( stderr, "HTTPD_MSG_SETUP: transport=%s\n", psz_transport ); //fprintf( stderr, "HTTPD_MSG_SETUP: transport=%s\n", psz_transport );
...@@ -1816,12 +1817,11 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1816,12 +1817,11 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
answer->psz_status = strdup( "OK" ); answer->psz_status = strdup( "OK" );
answer->i_body = 0; answer->i_body = 0;
answer->p_body = NULL; answer->p_body = NULL;
psz_session = httpd_MsgGet( query, "Session" ); psz_session = httpd_MsgGet( query, "Session" );
if( !psz_session ) if( !psz_session )
{ psz_session = psz_session_init;
psz_session = malloc( 100 );
sprintf( psz_session, "%d", rand() );
}
httpd_MsgAdd( answer, "Transport", httpd_MsgAdd( answer, "Transport",
"RTP/AVP/UDP;destination=%s;port=%d-%d;ttl=%d", "RTP/AVP/UDP;destination=%s;port=%d-%d;ttl=%d",
id->psz_destination, id->i_port,id->i_port+1, id->psz_destination, id->i_port,id->i_port+1,
...@@ -1850,10 +1850,8 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1850,10 +1850,8 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
psz_session = httpd_MsgGet( query, "Session" ); psz_session = httpd_MsgGet( query, "Session" );
if( !psz_session ) if( !psz_session )
{ {
psz_session = malloc( 100 ); psz_session = psz_session_init;
sprintf( psz_session, "%d", rand() ); rtsp = RtspClientNew( p_stream, psz_session_init );
rtsp = RtspClientNew( p_stream, psz_session );
} }
else else
{ {
...@@ -1925,9 +1923,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1925,9 +1923,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" ); httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session ) if( psz_session )
{
httpd_MsgAdd( answer, "Session", "%s"/*;timeout=5*/, psz_session ); httpd_MsgAdd( answer, "Session", "%s"/*;timeout=5*/, psz_session );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
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