guint16 seqnum;
TimerType type;
GstClockTime pts;
- GstClockTime timeout;
} TimerData;
#define GST_RTP_JITTER_BUFFER_GET_PRIVATE(o) \
return timestamp;
}
-static GstClockTime
-get_sync_time (GstRtpJitterBuffer * jitterbuffer, GstClockTime timestamp)
-{
- GstClockTime result;
- GstRtpJitterBufferPrivate *priv;
-
- priv = jitterbuffer->priv;
-
- result = timestamp + GST_ELEMENT_CAST (jitterbuffer)->base_time;
- /* add latency, this includes our own latency and the peer latency. */
- result += priv->latency_ns;
- result += priv->peer_latency;
-
- return result;
-}
-
#define GST_FLOW_WAIT GST_FLOW_CUSTOM_SUCCESS
static TimerData *
guint16 seqnum, GstClockTime pts)
{
TimerData *timer;
- GstClockTime out_time;
-
- out_time = apply_offset (jitterbuffer, pts);
GST_DEBUG_OBJECT (jitterbuffer,
"set timer for seqnum %d to %" GST_TIME_FORMAT, seqnum,
- GST_TIME_ARGS (out_time));
+ GST_TIME_ARGS (pts));
/* find the seqnum timer */
timer = find_timer (jitterbuffer, type, seqnum, NULL);
- timer->timeout = out_time;
timer->pts = pts;
return GST_FLOW_WAIT;
GstClockTimeDiff total_duration;
GstClockTime out_time_diff;
- out_time_diff = apply_offset (jitterbuffer, timer->pts) - timer->timeout;
+ out_time_diff = apply_offset (jitterbuffer, timer->pts) - timer->pts;
total_duration = MIN (out_time_diff, clock_jitter);
if (duration > 0)
/* update our expected next packet */
priv->last_popped_seqnum = timer->seqnum;
- priv->last_out_time = timer->timeout;
+ priv->last_out_time = apply_offset (jitterbuffer, timer->pts);
priv->last_out_pts = timer->pts;
priv->next_seqnum = (timer->seqnum + lost_packets) & 0xffff;
/* remove timer now */
TimerData *test = &g_array_index (priv->timers, TimerData, i);
/* find the smallest timeout */
- if (timer == NULL || test->timeout == -1 || test->timeout < timer->timeout)
+ if (timer == NULL || test->pts == -1 || test->pts < timer->pts)
timer = test;
}
if (timer) {
GstClockReturn ret;
GstClockTimeDiff clock_jitter;
+ /* no timestamp, timeout immeditately */
+ if (timer->pts == -1)
+ goto do_timeout;
+
GST_OBJECT_LOCK (jitterbuffer);
clock = GST_ELEMENT_CLOCK (jitterbuffer);
if (!clock) {
}
/* prepare for sync against clock */
- sync_time = get_sync_time (jitterbuffer, timer->timeout);
+ sync_time = timer->pts + GST_ELEMENT_CAST (jitterbuffer)->base_time;
+ /* add latency of peer to get input time */
+ sync_time += priv->peer_latency;
+
+ /* add our latency and offset to get output times. */
+ sync_time = apply_offset (jitterbuffer, sync_time);
+ sync_time += priv->latency_ns;
GST_DEBUG_OBJECT (jitterbuffer, "sync to timestamp %" GST_TIME_FORMAT
" with sync time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (timer->timeout), GST_TIME_ARGS (sync_time));
+ GST_TIME_ARGS (timer->pts), GST_TIME_ARGS (sync_time));
/* create an entry for the clock */
id = priv->clock_id = gst_clock_new_single_shot_id (clock, sync_time);