X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Frtsp.c;h=f70abe34c48404716cfa89d89213b1cf9f6b5537;hb=8f055856fa79bfa284f77bcd55e7556977eec769;hp=844890ed05f28272a6b16285c44e208a0c8cde16;hpb=94558b79a949d86ade0184b3262adfedfc91252d;p=vlc diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c index 844890ed05..f70abe34c4 100644 --- a/modules/stream_out/rtsp.c +++ b/modules/stream_out/rtsp.c @@ -52,7 +52,6 @@ struct rtsp_stream_t httpd_host_t *host; httpd_url_t *url; char *psz_path; - const char *track_sep; unsigned track_id; unsigned port; @@ -93,10 +92,6 @@ rtsp_stream_t *RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url ) if( rtsp->psz_path == NULL ) goto error; - assert( strlen( rtsp->psz_path ) > 0 ); - rtsp->track_sep = rtsp->psz_path[strlen( rtsp->psz_path ) - 1] == '/' ? - "" : "/"; - msg_Dbg( p_stream, "RTSP stream: host %s port %d at %s", url->psz_host, rtsp->port, rtsp->psz_path ); @@ -179,13 +174,25 @@ struct rtsp_strack_t }; +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; @@ -205,10 +212,16 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid, id->hiport = hiport; } - snprintf( urlbuf, sizeof( urlbuf ), "%s%strackID=%u", rtsp->psz_path, - rtsp->track_sep, 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 ) { @@ -639,6 +652,8 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *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;" @@ -660,11 +675,12 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id, } else seq = rtp_get_seq( tr->id->sout_id ); + char *url = RtspAppendTrackPath( tr->id, control ); infolen += sprintf( info + infolen, - "url=%s%strackID=%u;seq=%u;rtptime=%u, ", - control, rtsp->track_sep, - 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 )