[vlc-devel] commit: rtp sout: implement rtptime parameter (Pierre Ynard )
git version control
git at videolan.org
Sun Dec 6 16:51:45 CET 2009
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Dec 6 16:50:43 2009 +0100| [ce7a4746ad10d451e5e2807be44181df9456d6f0] | committer: Pierre Ynard
rtp sout: implement rtptime parameter
This adds support for the rtptime parameter in the RTP-Info RTSP header.
It is needed by RealPlayer, otherwise it will start playing the stream
or not depending on the time of the day.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce7a4746ad10d451e5e2807be44181df9456d6f0
---
modules/stream_out/rtp.c | 11 +++++++++++
modules/stream_out/rtp.h | 1 +
modules/stream_out/rtsp.c | 11 ++++++++---
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 837270b..f7f80ed 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -301,6 +301,7 @@ struct sout_stream_id_t
sout_stream_t *p_stream;
/* rtp field */
+ uint32_t i_timestamp;
uint16_t i_sequence;
uint8_t i_payload_type;
uint8_t ssrc[4];
@@ -909,6 +910,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->p_stream = p_stream;
+ id->i_timestamp = 0; /* It will be filled when the first packet is sent */
+
/* Look for free dymanic payload type */
id->i_payload_type = 96;
while (p_sys->payload_bitmap & (1 << (id->i_payload_type - 96)))
@@ -1662,6 +1665,13 @@ uint16_t rtp_get_seq( const sout_stream_id_t *id )
return id->i_sequence;
}
+uint32_t rtp_get_ts( const sout_stream_id_t *id )
+{
+ /* ... and this will return the value for the last packet.
+ * Lame, but close enough. */
+ return id->i_timestamp;
+}
+
/* FIXME: this is pretty bad - if we remove and then insert an ES
* the number will get unsynched from inside RTSP */
unsigned rtp_get_num( const sout_stream_id_t *id )
@@ -1698,6 +1708,7 @@ void rtp_packetize_common( sout_stream_id_t *id, block_t *out,
memcpy( out->p_buffer + 8, id->ssrc, 4 );
out->i_buffer = 12;
+ id->i_timestamp = i_timestamp;
id->i_sequence++;
}
diff --git a/modules/stream_out/rtp.h b/modules/stream_out/rtp.h
index aec9dde..1f9841c 100644
--- a/modules/stream_out/rtp.h
+++ b/modules/stream_out/rtp.h
@@ -39,6 +39,7 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url );
int rtp_add_sink( sout_stream_id_t *id, int fd, bool rtcp_mux );
void rtp_del_sink( sout_stream_id_t *id, int fd );
uint16_t rtp_get_seq( const sout_stream_id_t *id );
+uint32_t rtp_get_ts( const sout_stream_id_t *id );
unsigned rtp_get_num( const sout_stream_id_t *id );
/* RTP packetization */
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index 523a1d4..2e29e15 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -635,7 +635,8 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
{
/* FIXME: we really need to limit the number of tracks... */
char info[ses->trackc * ( strlen( control )
- + sizeof("url=/trackID=123;seq=65535, ") ) + 1];
+ + sizeof("url=/trackID=123;seq=65535;"
+ "rtptime=4294967295, ") ) + 1];
size_t infolen = 0;
for( int i = 0; i < ses->trackc; i++ )
@@ -648,11 +649,15 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
tr->playing = true;
rtp_add_sink( tr->id, tr->fd, false );
}
+ /* This is racy, as the first packets may have
+ * already been sent before we fetch this info:
+ * these extra packets might confuse the client. */
infolen += sprintf( info + infolen,
- "url=%s/trackID=%u;seq=%u, ",
+ "url=%s/trackID=%u;seq=%u;rtptime=%u, ",
control,
rtp_get_num( tr->id ),
- rtp_get_seq( tr->id ) );
+ rtp_get_seq( tr->id ),
+ rtp_get_ts( tr->id ) );
}
}
if( infolen > 0 )
More information about the vlc-devel
mailing list