gst-libs/gst/rtp/gstbasertpdepayload.c: Be less silly with the segment start, just apply the clock-base to the timest...

Original commit message from CVS:
* gst-libs/gst/rtp/gstbasertpdepayload.c:
(gst_base_rtp_depayload_setcaps),
(gst_base_rtp_depayload_set_gst_timestamp):
Be less silly with the segment start, just apply the clock-base to the
timestamp.
This commit is contained in:
Wim Taymans 2007-08-31 21:07:20 +00:00
parent 827967c8e8
commit 210100078d
2 changed files with 25 additions and 16 deletions

View file

@ -1,3 +1,11 @@
2007-08-31 Wim Taymans <wim.taymans@gmail.com>
* gst-libs/gst/rtp/gstbasertpdepayload.c:
(gst_base_rtp_depayload_setcaps),
(gst_base_rtp_depayload_set_gst_timestamp):
Be less silly with the segment start, just apply the clock-base to the
timestamp.
2007-08-31 Wim Taymans <wim.taymans@gmail.com> 2007-08-31 Wim Taymans <wim.taymans@gmail.com>
* gst-libs/gst/rtp/gstbasertpdepayload.c: * gst-libs/gst/rtp/gstbasertpdepayload.c:

View file

@ -182,6 +182,7 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
gboolean res; gboolean res;
GstStructure *caps_struct; GstStructure *caps_struct;
const GValue *value; const GValue *value;
guint val;
filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad)); filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad));
priv = filter->priv; priv = filter->priv;
@ -193,9 +194,8 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
caps_struct = gst_caps_get_structure (caps, 0); caps_struct = gst_caps_get_structure (caps, 0);
/* get clock base if any, we need this for the newsegment */ /* get clock base if any, we need this for the newsegment */
value = gst_structure_get_value (caps_struct, "clock-base"); if (gst_structure_get_uint (caps_struct, "clock-base", &val))
if (value && G_VALUE_HOLDS_UINT (value)) priv->clock_base = val;
priv->clock_base = g_value_get_uint (value);
else else
priv->clock_base = -1; priv->clock_base = -1;
@ -391,7 +391,7 @@ static void
gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter, gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter,
guint32 timestamp, GstBuffer * buf) guint32 timestamp, GstBuffer * buf)
{ {
GstClockTime ts, adjusted, exttimestamp; GstClockTime ts, exttimestamp;
GstBaseRTPDepayloadPrivate *priv; GstBaseRTPDepayloadPrivate *priv;
priv = filter->priv; priv = filter->priv;
@ -403,6 +403,13 @@ gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter,
/* get extended timestamp */ /* get extended timestamp */
exttimestamp = gst_rtp_buffer_ext_timestamp (&priv->exttimestamp, timestamp); exttimestamp = gst_rtp_buffer_ext_timestamp (&priv->exttimestamp, timestamp);
/* subtract clock-base to get a 0 based timestamp. Make sure we don't go
* negative. */
if (exttimestamp > priv->clock_base)
exttimestamp -= priv->clock_base;
else
exttimestamp = 0;
/* rtp timestamps are based on the clock_rate /* rtp timestamps are based on the clock_rate
* gst timesamps are in nanoseconds */ * gst timesamps are in nanoseconds */
ts = gst_util_uint64_scale_int (exttimestamp, GST_SECOND, filter->clock_rate); ts = gst_util_uint64_scale_int (exttimestamp, GST_SECOND, filter->clock_rate);
@ -411,24 +418,18 @@ gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter,
"timestamp: %u, exttimestamp %" G_GUINT64_FORMAT ", clockrate : %u", "timestamp: %u, exttimestamp %" G_GUINT64_FORMAT ", clockrate : %u",
timestamp, exttimestamp, filter->clock_rate); timestamp, exttimestamp, filter->clock_rate);
/* add delay to timestamp */ GST_DEBUG_OBJECT (filter, "RTP: %u, GST: %" GST_TIME_FORMAT ", ts %"
adjusted = ts + (filter->queue_delay * GST_MSECOND); GST_TIME_FORMAT, timestamp, GST_TIME_ARGS (ts), GST_TIME_ARGS (ts));
GST_DEBUG_OBJECT (filter, "RTP: %u, GST: %" GST_TIME_FORMAT ", adjusted %" GST_BUFFER_TIMESTAMP (buf) = ts;
GST_TIME_FORMAT, timestamp, GST_TIME_ARGS (ts), GST_TIME_ARGS (adjusted));
GST_BUFFER_TIMESTAMP (buf) = adjusted;
/* if this is the first buf send a NEWSEGMENT */ /* if this is the first buf send a NEWSEGMENT */
if (filter->need_newsegment) { if (filter->need_newsegment) {
GstEvent *event; GstEvent *event;
GstClockTime start, stop, position; GstClockTime stop, position;
start = gst_util_uint64_scale_int (priv->clock_base, GST_SECOND,
filter->clock_rate);
if (priv->npt_stop != -1) if (priv->npt_stop != -1)
stop = priv->npt_stop - priv->npt_start + start; stop = priv->npt_stop - priv->npt_start;
else else
stop = -1; stop = -1;
@ -436,7 +437,7 @@ gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter,
event = event =
gst_event_new_new_segment_full (FALSE, priv->play_speed, gst_event_new_new_segment_full (FALSE, priv->play_speed,
priv->play_scale, GST_FORMAT_TIME, start, stop, position); priv->play_scale, GST_FORMAT_TIME, 0, stop, position);
gst_pad_push_event (filter->srcpad, event); gst_pad_push_event (filter->srcpad, event);