diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2008-04-25 08:15:58 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2008-04-25 08:15:58 +0000 |
commit | 9285e110ccb5b062926557f4ca5e682ea796267e (patch) | |
tree | e39854dc6429e3ada1e7ad54ad98cc6ea9ccc736 | |
parent | af19b9121617cb5be2abf3ac4c3b035343c72da0 (diff) | |
download | gst-plugins-bad-9285e110ccb5b062926557f4ca5e682ea796267e.tar.gz gst-plugins-bad-9285e110ccb5b062926557f4ca5e682ea796267e.tar.bz2 gst-plugins-bad-9285e110ccb5b062926557f4ca5e682ea796267e.zip |
gst/rtpmanager/: Also keep track of the first buffer timestamp together with the first
Original commit message from CVS:
* gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_associate),
(gst_rtp_bin_sync_chain):
* gst/rtpmanager/rtpsession.c: (update_arrival_stats),
(rtp_session_process_sr), (rtp_session_on_timeout):
* gst/rtpmanager/rtpsource.c: (rtp_source_init),
(calculate_jitter):
* gst/rtpmanager/rtpsource.h:
* gst/rtpmanager/rtpstats.h:
Also keep track of the first buffer timestamp together with the first
RTP timestamp as they both are needed to construct the timing of
outgoing packets in the jitterbuffer and are therefore also needed to
manage lip-sync. This fixes lip-sync if the first RTP packets arrive
with a wildly different gap.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | gst/rtpmanager/gstrtpbin.c | 3 | ||||
-rw-r--r-- | gst/rtpmanager/rtpsession.c | 2 | ||||
-rw-r--r-- | gst/rtpmanager/rtpsource.c | 2 | ||||
-rw-r--r-- | gst/rtpmanager/rtpsource.h | 1 | ||||
-rw-r--r-- | gst/rtpmanager/rtpstats.h | 4 |
6 files changed, 27 insertions, 1 deletions
@@ -1,5 +1,21 @@ 2008-04-25 Wim Taymans <wim.taymans@collabora.co.uk> + * gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_associate), + (gst_rtp_bin_sync_chain): + * gst/rtpmanager/rtpsession.c: (update_arrival_stats), + (rtp_session_process_sr), (rtp_session_on_timeout): + * gst/rtpmanager/rtpsource.c: (rtp_source_init), + (calculate_jitter): + * gst/rtpmanager/rtpsource.h: + * gst/rtpmanager/rtpstats.h: + Also keep track of the first buffer timestamp together with the first + RTP timestamp as they both are needed to construct the timing of + outgoing packets in the jitterbuffer and are therefore also needed to + manage lip-sync. This fixes lip-sync if the first RTP packets arrive + with a wildly different gap. + +2008-04-25 Wim Taymans <wim.taymans@collabora.co.uk> + * gst/flv/gstflvdemux.c: (gst_flv_demux_query): Forward unknown queries upstream instead of returning FALSE on them. diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index 76b806bc..8cfd63c4 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -306,6 +306,7 @@ struct _GstRtpBinStream /* for lip-sync */ guint64 clock_base; + guint64 clock_base_time; gint clock_rate; gint64 ts_offset; gint64 prev_ts_offset; @@ -785,6 +786,7 @@ gst_rtp_bin_associate (GstRtpBin * bin, GstRtpBinStream * stream, guint8 len, stream->local_unix = gst_util_uint64_scale_int (stream->local_rtp, GST_SECOND, stream->clock_rate); + stream->local_unix += stream->clock_base_time; /* calculate delta between server and receiver */ stream->unix_delta = stream->last_unix - stream->local_unix; @@ -942,6 +944,7 @@ gst_rtp_bin_sync_chain (GstPad * pad, GstBuffer * buffer) if (type == GST_RTCP_SDES_CNAME) { stream->clock_base = GST_BUFFER_OFFSET (buffer); + stream->clock_base_time = GST_BUFFER_OFFSET_END (buffer); /* associate the stream to CNAME */ gst_rtp_bin_associate (bin, stream, len, data); } diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index 0eaf3e6f..7ddcfe4d 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -1233,6 +1233,7 @@ update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival, /* get time of arrival */ g_get_current_time (¤t); arrival->time = GST_TIMEVAL_TO_TIME (current); + arrival->timestamp = GST_BUFFER_TIMESTAMP (buffer); arrival->ntpnstime = ntpnstime; /* get packet size including header overhead */ @@ -1434,6 +1435,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet, return; GST_BUFFER_OFFSET (packet->buffer) = source->clock_base; + GST_BUFFER_OFFSET_END (packet->buffer) = source->clock_base_time; prevsender = RTP_SOURCE_IS_SENDER (source); diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c index 938a1d56..36def461 100644 --- a/gst/rtpmanager/rtpsource.c +++ b/gst/rtpmanager/rtpsource.c @@ -171,6 +171,7 @@ rtp_source_init (RTPSource * src) src->payload = 0; src->clock_rate = -1; src->clock_base = -1; + src->clock_base_time = -1; src->packets = g_queue_new (); src->seqnum_base = -1; src->last_rtptime = -1; @@ -772,6 +773,7 @@ calculate_jitter (RTPSource * src, GstBuffer * buffer, if (src->clock_base == -1) { GST_DEBUG ("using clock-base of %" G_GUINT32_FORMAT, rtptime); src->clock_base = rtptime; + src->clock_base_time = arrival->timestamp; } /* convert arrival time to RTP timestamp units, truncate to 32 bits, we don't diff --git a/gst/rtpmanager/rtpsource.h b/gst/rtpmanager/rtpsource.h index 1eae0c18..a2ba2d61 100644 --- a/gst/rtpmanager/rtpsource.h +++ b/gst/rtpmanager/rtpsource.h @@ -134,6 +134,7 @@ struct _RTPSource { gint clock_rate; gint32 seqnum_base; gint64 clock_base; + guint64 clock_base_time; GstClockTime bye_time; GstClockTime last_activity; diff --git a/gst/rtpmanager/rtpstats.h b/gst/rtpmanager/rtpstats.h index c0d3a512..f82c9585 100644 --- a/gst/rtpmanager/rtpstats.h +++ b/gst/rtpmanager/rtpstats.h @@ -56,7 +56,8 @@ typedef struct { /** * RTPArrivalStats: - * @time: arrival time of a packet + * @time: arrival time of a packet according to the system clock + * @timestamp: arrival time of a packet as buffer timestamp * @address: address of the sender of the packet * @bytes: bytes of the packet including lowlevel overhead * @payload_len: bytes of the RTP payload @@ -65,6 +66,7 @@ typedef struct { */ typedef struct { GstClockTime time; + GstClockTime timestamp; guint64 ntpnstime; gboolean have_address; GstNetAddress address; |