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 );
static int FileSetup( sout_stream_t *p_stream );
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:
*****************************************************************************/
......@@ -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_input = p_input;
id->pf_packetize= NULL;
id->p_rtsp_url = NULL;
id->rtsp_id = NULL;
id->i_port = 0;
return id;
}
......@@ -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->psz_rtpmap = NULL;
id->psz_fmtp = NULL;
id->i_port = i_port;
id->p_rtsp_url = NULL;
id->i_port = i_port;
id->rtsp_id = NULL;
vlc_mutex_init( p_stream, &id->lock_sink );
id->i_sink = 0;
......@@ -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 );
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 */
vlc_mutex_lock( &p_sys->lock_es );
......@@ -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 );
}
if( id->p_rtsp_url )
RtspDelId( p_stream, id );
if( id->rtsp_id )
RtspDelId( p_stream, id->rtsp_id );
vlc_mutex_destroy( &id->lock_sink );
free( id->sink );
......@@ -1438,6 +1472,7 @@ int rtp_add_sink( sout_stream_id_t *id, sout_access_out_t *access )
vlc_mutex_lock( &id->lock_sink );
TAB_APPEND( id->i_sink, id->sink, access );
vlc_mutex_unlock( &id->lock_sink );
return VLC_SUCCESS;
}
void rtp_del_sink( sout_stream_id_t *id, sout_access_out_t *access )
......
......@@ -22,12 +22,16 @@
* 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;
int RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url );
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,
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 );
typedef int (*pf_rtp_packetizer_t)( sout_stream_t *, sout_stream_id_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
{
/* sdp */
......
......@@ -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;
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 );
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 );
msg_Dbg( p_stream, "RTSP: adding %s\n", psz_urlc );
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 );
httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_SETUP, RtspCallbackId, (void*)id );
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 );
free( id );
return NULL;
}
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 )
/** Non-aggregate RTSP callback */
/*static*/ int RtspCallbackId( httpd_callback_sys_t *p_args,
httpd_client_t *cl,
httpd_message_t *answer, httpd_message_t *query )
static int RtspCallbackId( httpd_callback_sys_t *p_args,
httpd_client_t *cl,
httpd_message_t *answer, httpd_message_t *query )
{
sout_stream_id_t *id = (sout_stream_id_t*)p_args;
sout_stream_t *p_stream = id->p_stream;
rtsp_stream_id_t *id = (rtsp_stream_id_t*)p_args;
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;
char psz_session_init[21];
const char *psz_session;
......@@ -464,9 +489,10 @@ static inline const char *parameter_next( const char *str )
answer->i_status = 200;
httpd_MsgAdd( answer, "Transport",
"RTP/AVP/UDP;destination=%s;port=%d-%d;"
"RTP/AVP/UDP;destination=%s;port=%u-%u;"
"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 );
}
else
......@@ -476,7 +502,7 @@ static inline const char *parameter_next( const char *str )
sout_access_out_t *p_access;
rtsp_client_t *rtsp = NULL;
if( ( hiport - loport ) > 1 )
if( ( hiport - loport ) != ( id->hiport - id->loport ) )
continue;
if( psz_session == NULL )
......@@ -523,7 +549,7 @@ static inline const char *parameter_next( const char *str )
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 );
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