Commit 685ca388 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Hide sout ID from RTSP code

parent 4ad888b9
...@@ -166,6 +166,40 @@ static int SapSetup( sout_stream_t *p_stream ); ...@@ -166,6 +166,40 @@ static int SapSetup( sout_stream_t *p_stream );
static int FileSetup( 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 * );
struct sout_stream_id_t
{
sout_stream_t *p_stream;
/* rtp field */
uint8_t i_payload_type;
uint16_t i_sequence;
uint32_t i_timestamp_start;
uint8_t ssrc[4];
/* for sdp */
int i_clock_rate;
char *psz_rtpmap;
char *psz_fmtp;
int i_port;
int i_cat;
int i_bitrate;
/* Packetizer specific fields */
pf_rtp_packetizer_t pf_packetize;
int i_mtu;
/* for sending the packets */
sout_access_out_t *p_access;
vlc_mutex_t lock_sink;
int i_sink;
sout_access_out_t **sink;
rtsp_stream_id_t *rtsp_id;
/* */
sout_input_t *p_input;
};
/***************************************************************************** /*****************************************************************************
* Open: * Open:
*****************************************************************************/ *****************************************************************************/
...@@ -805,7 +839,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -805,7 +839,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->p_access = NULL; id->p_access = NULL;
id->p_input = p_input; id->p_input = p_input;
id->pf_packetize= NULL; id->pf_packetize= NULL;
id->p_rtsp_url = NULL; id->rtsp_id = NULL;
id->i_port = 0; id->i_port = 0;
return id; return id;
} }
...@@ -871,8 +905,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -871,8 +905,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->p_input = NULL; id->p_input = NULL;
id->psz_rtpmap = NULL; id->psz_rtpmap = NULL;
id->psz_fmtp = NULL; id->psz_fmtp = NULL;
id->i_port = i_port; id->i_port = i_port;
id->p_rtsp_url = NULL; id->rtsp_id = NULL;
vlc_mutex_init( p_stream, &id->lock_sink ); vlc_mutex_init( p_stream, &id->lock_sink );
id->i_sink = 0; id->i_sink = 0;
...@@ -1103,7 +1137,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1103,7 +1137,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
msg_Dbg( p_stream, "maximum RTP packet size: %d bytes", id->i_mtu ); msg_Dbg( p_stream, "maximum RTP packet size: %d bytes", id->i_mtu );
if( p_sys->p_rtsp_url ) if( p_sys->p_rtsp_url )
RtspAddId( p_stream, id ); id->rtsp_id = RtspAddId( p_stream, id, id->i_port, id->i_port + 1 );
/* Update p_sys context */ /* Update p_sys context */
vlc_mutex_lock( &p_sys->lock_es ); vlc_mutex_lock( &p_sys->lock_es );
...@@ -1161,8 +1195,8 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -1161,8 +1195,8 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
{ {
sout_MuxDeleteStream( p_sys->p_mux, id->p_input ); sout_MuxDeleteStream( p_sys->p_mux, id->p_input );
} }
if( id->p_rtsp_url ) if( id->rtsp_id )
RtspDelId( p_stream, id ); RtspDelId( p_stream, id->rtsp_id );
vlc_mutex_destroy( &id->lock_sink ); vlc_mutex_destroy( &id->lock_sink );
free( id->sink ); free( id->sink );
...@@ -1438,6 +1472,7 @@ int rtp_add_sink( sout_stream_id_t *id, sout_access_out_t *access ) ...@@ -1438,6 +1472,7 @@ int rtp_add_sink( sout_stream_id_t *id, sout_access_out_t *access )
vlc_mutex_lock( &id->lock_sink ); vlc_mutex_lock( &id->lock_sink );
TAB_APPEND( id->i_sink, id->sink, access ); TAB_APPEND( id->i_sink, id->sink, access );
vlc_mutex_unlock( &id->lock_sink ); vlc_mutex_unlock( &id->lock_sink );
return VLC_SUCCESS;
} }
void rtp_del_sink( sout_stream_id_t *id, sout_access_out_t *access ) void rtp_del_sink( sout_stream_id_t *id, sout_access_out_t *access )
......
...@@ -22,12 +22,16 @@ ...@@ -22,12 +22,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
/*ypedef struct rtsp_stream_t rtsp_stream_t;*/
typedef struct rtsp_stream_id_t rtsp_stream_id_t;
typedef struct rtsp_client_t rtsp_client_t; typedef struct rtsp_client_t rtsp_client_t;
int RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url ); int RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url );
void RtspUnsetup( sout_stream_t *p_stream ); void RtspUnsetup( sout_stream_t *p_stream );
int RtspAddId( sout_stream_t *p_stream, sout_stream_id_t *id );
void RtspDelId( sout_stream_t *p_stream, sout_stream_id_t *id ); rtsp_stream_id_t *RtspAddId( sout_stream_t *p_stream, sout_stream_id_t *sid,
unsigned loport, unsigned hiport );
void RtspDelId( sout_stream_t *p_stream, rtsp_stream_id_t * );
char *SDPGenerate( const sout_stream_t *p_stream, char *SDPGenerate( const sout_stream_t *p_stream,
const char *psz_destination, vlc_bool_t b_rtsp ); const char *psz_destination, vlc_bool_t b_rtsp );
...@@ -38,41 +42,6 @@ void rtp_del_sink( sout_stream_id_t *id, sout_access_out_t *access ); ...@@ -38,41 +42,6 @@ void rtp_del_sink( sout_stream_id_t *id, sout_access_out_t *access );
typedef int (*pf_rtp_packetizer_t)( sout_stream_t *, sout_stream_id_t *, typedef int (*pf_rtp_packetizer_t)( sout_stream_t *, sout_stream_id_t *,
block_t * ); block_t * );
struct sout_stream_id_t
{
sout_stream_t *p_stream;
/* rtp field */
uint8_t i_payload_type;
uint16_t i_sequence;
uint32_t i_timestamp_start;
uint8_t ssrc[4];
/* for sdp */
int i_clock_rate;
char *psz_rtpmap;
char *psz_fmtp;
int i_port;
int i_cat;
int i_bitrate;
/* Packetizer specific fields */
pf_rtp_packetizer_t pf_packetize;
int i_mtu;
/* for sending the packets */
sout_access_out_t *p_access;
vlc_mutex_t lock_sink;
int i_sink;
sout_access_out_t **sink;
/* */
sout_input_t *p_input;
/* RTSP url control */
httpd_url_t *p_rtsp_url;
};
struct sout_stream_sys_t struct sout_stream_sys_t
{ {
/* sdp */ /* sdp */
......
...@@ -103,31 +103,55 @@ void RtspUnsetup( sout_stream_t *p_stream ) ...@@ -103,31 +103,55 @@ void RtspUnsetup( sout_stream_t *p_stream )
} }
int RtspAddId( sout_stream_t *p_stream, sout_stream_id_t *id ) struct rtsp_stream_id_t
{
sout_stream_t *sout_stream;
sout_stream_id_t *sout_id;
httpd_url_t *url;
unsigned loport, hiport;
};
rtsp_stream_id_t *RtspAddId( sout_stream_t *p_stream, sout_stream_id_t *sid,
unsigned loport, unsigned hiport )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
char psz_urlc[strlen( p_sys->psz_rtsp_control ) + 1 + 10]; char psz_urlc[strlen( p_sys->psz_rtsp_control ) + 1 + 10];
rtsp_stream_id_t *id = malloc( sizeof( *id ) );
httpd_url_t *url;
if( id == NULL )
return NULL;
id->sout_stream = p_stream;
id->sout_id = sid;
id->loport = loport;
id->hiport = loport;
sprintf( psz_urlc, "%s/trackID=%d", p_sys->psz_rtsp_path, p_sys->i_es ); sprintf( psz_urlc, "%s/trackID=%d", p_sys->psz_rtsp_path, p_sys->i_es );
msg_Dbg( p_stream, "rtsp: adding %s\n", psz_urlc ); msg_Dbg( p_stream, "RTSP: adding %s\n", psz_urlc );
id->p_rtsp_url = httpd_UrlNewUnique( p_sys->p_rtsp_host, psz_urlc, NULL, NULL, NULL ); url = id->url =
httpd_UrlNewUnique( p_sys->p_rtsp_host, psz_urlc, NULL, NULL, NULL );
if( id->p_rtsp_url ) if( url == NULL )
{ {
httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_DESCRIBE, RtspCallbackId, (void*)id ); free( id );
httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_SETUP, RtspCallbackId, (void*)id ); return NULL;
httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_PLAY, RtspCallbackId, (void*)id );
httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_PAUSE, RtspCallbackId, (void*)id );
httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_TEARDOWN, RtspCallbackId, (void*)id );
} }
return VLC_SUCCESS; httpd_UrlCatch( url, HTTPD_MSG_DESCRIBE, RtspCallbackId, (void *)id );
httpd_UrlCatch( url, HTTPD_MSG_SETUP, RtspCallbackId, (void *)id );
httpd_UrlCatch( url, HTTPD_MSG_PLAY, RtspCallbackId, (void *)id );
httpd_UrlCatch( url, HTTPD_MSG_PAUSE, RtspCallbackId, (void *)id );
httpd_UrlCatch( url, HTTPD_MSG_TEARDOWN, RtspCallbackId, (void *)id );
return id;
} }
void RtspDelId( sout_stream_t *p_stream, sout_stream_id_t *id ) void RtspDelId( sout_stream_t *p_stream, rtsp_stream_id_t *id )
{ {
httpd_UrlDelete( id->p_rtsp_url ); httpd_UrlDelete( id->url );
free( id );
} }
...@@ -348,12 +372,13 @@ static inline const char *parameter_next( const char *str ) ...@@ -348,12 +372,13 @@ static inline const char *parameter_next( const char *str )
/** Non-aggregate RTSP callback */ /** Non-aggregate RTSP callback */
/*static*/ int RtspCallbackId( httpd_callback_sys_t *p_args, static int RtspCallbackId( httpd_callback_sys_t *p_args,
httpd_client_t *cl, httpd_client_t *cl,
httpd_message_t *answer, httpd_message_t *query ) httpd_message_t *answer, httpd_message_t *query )
{ {
sout_stream_id_t *id = (sout_stream_id_t*)p_args; rtsp_stream_id_t *id = (rtsp_stream_id_t*)p_args;
sout_stream_t *p_stream = id->p_stream; sout_stream_t *p_stream = id->sout_stream;
sout_stream_id_t *sid = id->sout_id;
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
char psz_session_init[21]; char psz_session_init[21];
const char *psz_session; const char *psz_session;
...@@ -464,9 +489,10 @@ static inline const char *parameter_next( const char *str ) ...@@ -464,9 +489,10 @@ static inline const char *parameter_next( const char *str )
answer->i_status = 200; answer->i_status = 200;
httpd_MsgAdd( answer, "Transport", httpd_MsgAdd( answer, "Transport",
"RTP/AVP/UDP;destination=%s;port=%d-%d;" "RTP/AVP/UDP;destination=%s;port=%u-%u;"
"ttl=%d;mode=play", "ttl=%d;mode=play",
p_sys->psz_destination, id->i_port, id->i_port+1, p_sys->psz_destination, id->loport,
id->hiport,
( p_sys->i_ttl > 0 ) ? p_sys->i_ttl : 1 ); ( p_sys->i_ttl > 0 ) ? p_sys->i_ttl : 1 );
} }
else else
...@@ -476,7 +502,7 @@ static inline const char *parameter_next( const char *str ) ...@@ -476,7 +502,7 @@ static inline const char *parameter_next( const char *str )
sout_access_out_t *p_access; sout_access_out_t *p_access;
rtsp_client_t *rtsp = NULL; rtsp_client_t *rtsp = NULL;
if( ( hiport - loport ) > 1 ) if( ( hiport - loport ) != ( id->hiport - id->loport ) )
continue; continue;
if( psz_session == NULL ) if( psz_session == NULL )
...@@ -523,7 +549,7 @@ static inline const char *parameter_next( const char *str ) ...@@ -523,7 +549,7 @@ static inline const char *parameter_next( const char *str )
break; break;
} }
TAB_APPEND( rtsp->i_id, rtsp->id, id ); TAB_APPEND( rtsp->i_id, rtsp->id, sid );
TAB_APPEND( rtsp->i_access, rtsp->access, p_access ); TAB_APPEND( rtsp->i_access, rtsp->access, p_access );
char *src = var_GetNonEmptyString (p_access, "src-addr"); char *src = var_GetNonEmptyString (p_access, "src-addr");
......
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