summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-06-05 16:19:30 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-06-05 16:19:30 +0000
commit9dac555993a020be7ac6253e36caf47b72e0ed16 (patch)
tree77db47e17e4b9b9ce0e4c489d86a595ab1b98b96
parentd4bb17ab7a5ac581356ce85c3caa269db06889b0 (diff)
gst-libs/gst/rtp/gstbasertpdepayload.c: Handle timestamp wraparound.
Original commit message from CVS: * gst-libs/gst/rtp/gstbasertpdepayload.c: (gst_base_rtp_depayload_setcaps), (gst_base_rtp_depayload_set_gst_timestamp), (gst_base_rtp_depayload_change_state): Handle timestamp wraparound.
-rw-r--r--ChangeLog8
-rw-r--r--gst-libs/gst/rtp/gstbasertpdepayload.c37
2 files changed, 40 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 04a30590..da7cdaa4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2007-06-05 Wim Taymans <wim@fluendo.com>
+ * gst-libs/gst/rtp/gstbasertpdepayload.c:
+ (gst_base_rtp_depayload_setcaps),
+ (gst_base_rtp_depayload_set_gst_timestamp),
+ (gst_base_rtp_depayload_change_state):
+ Handle timestamp wraparound.
+
+2007-06-05 Wim Taymans <wim@fluendo.com>
+
* gst/playback/gsturidecodebin.c: (no_more_pads_full),
(new_decoded_pad), (remove_pads), (make_decoder), (setup_source),
(gst_uri_decode_bin_change_state):
diff --git a/gst-libs/gst/rtp/gstbasertpdepayload.c b/gst-libs/gst/rtp/gstbasertpdepayload.c
index 9073d6bb..cf8e4faa 100644
--- a/gst-libs/gst/rtp/gstbasertpdepayload.c
+++ b/gst-libs/gst/rtp/gstbasertpdepayload.c
@@ -45,6 +45,9 @@ struct _GstBaseRTPDepayloadPrivate
GstClockTime npt_stop;
gdouble play_speed;
gdouble play_scale;
+
+ GstClockTime ts_wraparound;
+ GstClockTime prev_timestamp;
};
/* Filter signals and args */
@@ -223,6 +226,8 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
else
priv->play_scale = 1.0;
+ priv->prev_timestamp = -1;
+
if (bclass->set_caps)
res = bclass->set_caps (filter, caps);
else
@@ -476,8 +481,9 @@ static void
gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter,
guint32 timestamp, GstBuffer * buf)
{
- GstClockTime ts, adjusted;
+ GstClockTime ts, adjusted, exttimestamp;
GstBaseRTPDepayloadPrivate *priv;
+ guint64 diff;
priv = filter->priv;
@@ -485,14 +491,34 @@ gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter,
if (priv->clock_base == -1)
priv->clock_base = timestamp;
- /* FIXME, timestamp wraparound */
+ if (priv->prev_timestamp == -1) {
+ priv->prev_timestamp = timestamp;
+ priv->ts_wraparound = 0;
+ }
+
+ /* check for timestamp wraparound */
+ exttimestamp = timestamp + priv->ts_wraparound;
+
+ if (exttimestamp < priv->prev_timestamp)
+ diff = priv->prev_timestamp - exttimestamp;
+ else
+ diff = exttimestamp - priv->prev_timestamp;
+
+ if (diff > G_MAXINT32) {
+ /* timestamp went backwards more than allowed, we wrap around and get
+ * updated extended timestamp. */
+ priv->ts_wraparound += (1LL << 32);
+ exttimestamp = timestamp + priv->ts_wraparound;
+ }
+ priv->prev_timestamp = exttimestamp;
/* rtp timestamps are based on the clock_rate
* gst timesamps are in nanoseconds */
- ts = gst_util_uint64_scale_int (timestamp, GST_SECOND, filter->clock_rate);
+ ts = gst_util_uint64_scale_int (exttimestamp, GST_SECOND, filter->clock_rate);
- GST_DEBUG_OBJECT (filter, "ts : timestamp : %u, clockrate : %u",
- timestamp, filter->clock_rate);
+ GST_DEBUG_OBJECT (filter,
+ "timestamp: %u, wrap %" G_GUINT64_FORMAT ", clockrate : %u", timestamp,
+ priv->ts_wraparound, filter->clock_rate);
/* add delay to timestamp */
adjusted = ts + (filter->queue_delay * GST_MSECOND);
@@ -668,6 +694,7 @@ gst_base_rtp_depayload_change_state (GstElement * element,
/* clock_rate needs to be overwritten by child */
filter->clock_rate = 0;
filter->priv->clock_base = -1;
+ filter->priv->ts_wraparound = 0;
filter->need_newsegment = TRUE;
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING: