Commit ada036d0 authored by Laurent Aimar's avatar Laurent Aimar

* rtp: sdp can now be exported as a file (sdp=file://filename).

 Initial path by Philippe Van Hecke (philippe DOT vanhecke AT belnet DOT be)
parent ef198559
...@@ -123,6 +123,8 @@ struct sout_stream_sys_t ...@@ -123,6 +123,8 @@ struct sout_stream_sys_t
char *psz_session_name; char *psz_session_name;
/* */
vlc_bool_t b_export_sdp_file;
/* sap */ /* sap */
vlc_bool_t b_export_sap; vlc_bool_t b_export_sap;
session_descriptor_t *p_session; session_descriptor_t *p_session;
...@@ -204,6 +206,7 @@ struct sout_stream_id_t ...@@ -204,6 +206,7 @@ struct sout_stream_id_t
static int AccessOutGrabberWrite( sout_access_out_t *, block_t * ); static int AccessOutGrabberWrite( sout_access_out_t *, block_t * );
static int SapSetup( sout_stream_t *p_stream ); static int SapSetup( sout_stream_t *p_stream );
static int FileSetup( sout_stream_t *p_stream );
static int HttpSetup( sout_stream_t *p_stream, vlc_url_t * ); static int HttpSetup( sout_stream_t *p_stream, vlc_url_t * );
static int RtspSetup( sout_stream_t *p_stream, vlc_url_t * ); static int RtspSetup( sout_stream_t *p_stream, vlc_url_t * );
...@@ -284,6 +287,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -284,6 +287,7 @@ static int Open( vlc_object_t *p_this )
p_sys->psz_sdp = NULL; p_sys->psz_sdp = NULL;
p_sys->b_export_sap = VLC_FALSE; p_sys->b_export_sap = VLC_FALSE;
p_sys->b_export_sdp_file = VLC_FALSE;
p_sys->p_session = NULL; p_sys->p_session = NULL;
p_sys->p_httpd_host = NULL; p_sys->p_httpd_host = NULL;
...@@ -422,7 +426,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -422,7 +426,7 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_stream, "cannot export sdp as http" ); msg_Err( p_stream, "cannot export sdp as http" );
} }
} }
if( url.psz_protocol && !strcasecmp( url.psz_protocol, "rtsp" ) ) else if( url.psz_protocol && !strcasecmp( url.psz_protocol, "rtsp" ) )
{ {
/* FIXME test if destination is multicast or no destination at all FIXME */ /* FIXME test if destination is multicast or no destination at all FIXME */
if( RtspSetup( p_stream, &url ) ) if( RtspSetup( p_stream, &url ) )
...@@ -435,6 +439,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -435,6 +439,10 @@ static int Open( vlc_object_t *p_this )
p_sys->b_export_sap = VLC_TRUE; p_sys->b_export_sap = VLC_TRUE;
SapSetup( p_stream ); SapSetup( p_stream );
} }
else if( url.psz_protocol && !strcasecmp( url.psz_protocol, "file" ) )
{
p_sys->b_export_sdp_file = VLC_TRUE;
}
else else
{ {
msg_Warn( p_stream, "unknow protocol for SDP (%s)", msg_Warn( p_stream, "unknow protocol for SDP (%s)",
...@@ -831,11 +839,9 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -831,11 +839,9 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
fprintf( stderr, "sdp=%s", p_sys->psz_sdp ); fprintf( stderr, "sdp=%s", p_sys->psz_sdp );
/* Update the SAP announce */ /* Update SDP (sap/file) */
if( p_sys->b_export_sap ) if( p_sys->b_export_sap ) SapSetup( p_stream );
{ if( p_sys->b_export_sdp_file ) FileSetup( p_stream );
SapSetup( p_stream );
}
} }
return id; return id;
...@@ -874,11 +880,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -874,11 +880,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
vlc_mutex_destroy( &id->lock_rtsp ); vlc_mutex_destroy( &id->lock_rtsp );
if( id->rtsp_access ) free( id->rtsp_access ); if( id->rtsp_access ) free( id->rtsp_access );
/* Update the SAP announce */ /* Update SDP (sap/file) */
if( p_sys->b_export_sap ) if( p_sys->b_export_sap ) SapSetup( p_stream );
{ if( p_sys->b_export_sdp_file ) FileSetup( p_stream );
SapSetup( p_stream );
}
free( id ); free( id );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -1026,6 +1030,50 @@ static int SapSetup( sout_stream_t *p_stream ) ...@@ -1026,6 +1030,50 @@ static int SapSetup( sout_stream_t *p_stream )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/****************************************************************************
* File:
****************************************************************************/
static int FileSetup( sout_stream_t *p_stream )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
vlc_value_t val;
char *psz;
FILE *f;
var_Get( p_stream, SOUT_CFG_PREFIX "sdp", &val );
if( strncasecmp( val.psz_string, "file:", 5 ) )
{
msg_Err( p_stream, "FileSetup called with invalid sdp option" );
free( val.psz_string );
return VLC_EGENERIC;
}
psz = &val.psz_string[5];
if( psz[0] == '/' && psz[1] == '/' )
psz += 2;
if( *psz == '\0' )
{
msg_Err( p_stream, "FileSetup called with empty sdp option" );
free( val.psz_string );
return VLC_EGENERIC;
}
if( ( f = fopen( psz, "wt" ) ) == NULL )
{
msg_Err( p_stream, "cannot open file '%s' (%s)",
psz, strerror(errno) );
free( val.psz_string );
return VLC_EGENERIC;
}
free( val.psz_string );
fprintf( f, "%s", p_sys->psz_sdp );
fclose( f );
return VLC_SUCCESS;
}
/**************************************************************************** /****************************************************************************
* HTTP: * HTTP:
****************************************************************************/ ****************************************************************************/
......
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