httpd_host_t *host;
httpd_url_t *url;
char *psz_path;
- const char *track_fmt;
unsigned track_id;
unsigned port;
if( rtsp->psz_path == NULL )
goto error;
- assert( strlen( rtsp->psz_path ) > 0 );
- if( rtsp->psz_path[strlen( rtsp->psz_path ) - 1] == '/' )
- rtsp->track_fmt = "%strackID=%u";
- else
- rtsp->track_fmt = "%s/trackID=%u";
-
msg_Dbg( p_stream, "RTSP stream: host %s port %d at %s",
url->psz_host, rtsp->port, rtsp->psz_path );
void RtspUnsetup( rtsp_stream_t *rtsp )
{
- while( rtsp->sessionc > 0 )
- RtspClientDel( rtsp, rtsp->sessionv[0] );
-
if( rtsp->url )
httpd_UrlDelete( rtsp->url );
+ while( rtsp->sessionc > 0 )
+ RtspClientDel( rtsp, rtsp->sessionv[0] );
+
if( rtsp->host )
httpd_HostDelete( rtsp->host );
};
+char *RtspAppendTrackPath( rtsp_stream_id_t *id, const char *base )
+{
+ const char *sep = strlen( base ) > 0 && base[strlen( base ) - 1] == '/' ?
+ "" : "/";
+ char *url;
+
+ if( asprintf( &url, "%s%strackID=%u", base, sep, id->track_id ) == -1 )
+ url = NULL;
+ return url;
+}
+
+
rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
uint32_t ssrc,
/* Multicast stuff - TODO: cleanup */
const char *dst, int ttl,
unsigned loport, unsigned hiport )
{
- char urlbuf[sizeof( "/trackID=123" ) + strlen( rtsp->psz_path )];
+ char *urlbuf;
rtsp_stream_id_t *id = malloc( sizeof( *id ) );
httpd_url_t *url;
id->hiport = hiport;
}
- snprintf( urlbuf, sizeof( urlbuf ), rtsp->track_fmt, rtsp->psz_path,
- id->track_id );
+ urlbuf = RtspAppendTrackPath( id, rtsp->psz_path );
+ if( urlbuf == NULL )
+ {
+ free( id );
+ return NULL;
+ }
+
msg_Dbg( rtsp->owner, "RTSP: adding %s", urlbuf );
url = id->url = httpd_UrlNewUnique( rtsp->host, urlbuf, NULL, NULL, NULL );
+ free( urlbuf );
if( url == NULL )
{
void RtspDelId( rtsp_stream_t *rtsp, rtsp_stream_id_t *id )
{
+ httpd_UrlDelete( id->url );
+
vlc_mutex_lock( &rtsp->lock );
for( int i = 0; i < rtsp->sessionc; i++ )
{
if( ses->trackv[j].id == id )
{
rtsp_strack_t *tr = ses->trackv + j;
- net_Close( tr->fd );
+ rtp_del_sink( tr->id->sout_id, tr->fd );
REMOVE_ELEM( ses->trackv, ses->trackc, j );
}
}
}
vlc_mutex_unlock( &rtsp->lock );
- httpd_UrlDelete( id->url );
free( id );
}
ses = RtspClientGet( rtsp, psz_session );
if( ses != NULL )
{
+ /* The "trackID" part must match what is done in
+ * RtspAppendTrackPath() */
/* FIXME: we really need to limit the number of tracks... */
char info[ses->trackc * ( strlen( control )
+ sizeof("url=/trackID=123;seq=65535;"
}
else
seq = rtp_get_seq( tr->id->sout_id );
+ char *url = RtspAppendTrackPath( tr->id, control );
infolen += sprintf( info + infolen,
- "url=%s/trackID=%u;seq=%u;rtptime=%u, ",
- control, tr->id->track_id, seq,
+ "url=%s;seq=%u;rtptime=%u, ",
+ url != NULL ? url : "", seq,
rtp_compute_ts( tr->id->sout_id, ts ) );
+ free( url );
}
}
if( infolen > 0 )