GST_TIME_FORMAT, GST_TIME_ARGS (*timestamp));
}
- if (GST_CLOCK_TIME_IS_VALID (self->paused_start_time)) {
+ if (GST_CLOCK_TIME_IS_VALID (self->paused_start_time) &&
+ GST_CLOCK_TIME_IS_VALID (self->playing_base_time)) {
+ /* add the time since we were last playing. */
+ *timestamp += self->paused_start_time + self->playing_base_time;
+ } else {
/* only valid whil we're in PAUSED and most likely without a set clock,
* we update based on our internal clock */
*timestamp += gst_clock_get_internal_time (self->output->clock);
- } else {
- /* add the time since we were last playing. */
- *timestamp += self->playing_start_time;
}
GST_LOG_OBJECT (self, "Output timestamp %" GST_TIME_FORMAT
" using paused start at %" GST_TIME_FORMAT " playing start at %"
GST_TIME_FORMAT, GST_TIME_ARGS (*timestamp),
GST_TIME_ARGS (self->paused_start_time),
- GST_TIME_ARGS (self->playing_start_time));
+ GST_TIME_ARGS (self->playing_base_time));
}
static GstFlowReturn
GST_STATE_CHANGE_FAILURE)
ret = GST_STATE_CHANGE_FAILURE;
break;
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+ self->playing_exit_time = gst_clock_get_internal_time (self->output->clock);
+ break;
default:
break;
}
GstDecklinkVideoSink *self = GST_DECKLINK_VIDEO_SINK_CAST (element);
if (new_state == GST_STATE_PLAYING) {
- self->paused_start_time = GST_CLOCK_TIME_NONE;
- self->playing_start_time =
- gst_clock_get_internal_time (self->output->clock);
- GST_DEBUG_OBJECT (self,
- "playing entered, new playing start time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (self->playing_start_time));
+ self->playing_base_time = gst_clock_get_internal_time (self->output->clock) - self->playing_exit_time;
+ GST_DEBUG_OBJECT (self, "playing entered paused start time %"
+ GST_TIME_FORMAT "playing base time %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (self->paused_start_time),
+ GST_TIME_ARGS (self->playing_base_time));
}
if (new_state == GST_STATE_PAUSED) {
/* all in internal time of the decklink clock */
/* really an internal base time */
- GstClockTime playing_start_time; /* time that we entered playing */
+ GstClockTime playing_base_time; /* time that we entered playing */
/* really an internal start time */
GstClockTime paused_start_time; /* time we entered paused, used to track how long we are in paused while the clock is running */
+ GstClockTime playing_exit_time; /* time that we exit playing */
GstDecklinkOutput *output;