mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
test-onvif-client: perform accurate seeks
See https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/336 Also, modify how we compute the position: position queries in PAUSED mode fail to account for the newly-prerolled frame, leading to frame skips when performing seeks in that state. Instead, compute the current position from the last sample.
This commit is contained in:
parent
16bc937ed9
commit
513c0fcb95
1 changed files with 27 additions and 3 deletions
|
@ -156,6 +156,27 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstClockTime
|
||||||
|
get_current_position (Context * ctx, gboolean reverse)
|
||||||
|
{
|
||||||
|
GstSample *sample;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstClockTime ret;
|
||||||
|
|
||||||
|
g_object_get (ctx->sink, "last-sample", &sample, NULL);
|
||||||
|
|
||||||
|
buffer = gst_sample_get_buffer (sample);
|
||||||
|
|
||||||
|
ret = GST_BUFFER_PTS (buffer);
|
||||||
|
|
||||||
|
if (reverse && GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer)))
|
||||||
|
ret += GST_BUFFER_DURATION (buffer);
|
||||||
|
|
||||||
|
gst_sample_unref (sample);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static GstEvent *
|
static GstEvent *
|
||||||
translate_seek_parameters (Context * ctx, SeekParameters * seek_params)
|
translate_seek_parameters (Context * ctx, SeekParameters * seek_params)
|
||||||
{
|
{
|
||||||
|
@ -188,19 +209,22 @@ translate_seek_parameters (Context * ctx, SeekParameters * seek_params)
|
||||||
stop_type = GST_SEEK_TYPE_SET;
|
stop_type = GST_SEEK_TYPE_SET;
|
||||||
|
|
||||||
if (!ctx->new_range) {
|
if (!ctx->new_range) {
|
||||||
|
GstClockTime current_position =
|
||||||
|
get_current_position (ctx, seek_params->reverse);
|
||||||
gst_element_query_position (ctx->pipe, GST_FORMAT_TIME, &cur_pos);
|
gst_element_query_position (ctx->pipe, GST_FORMAT_TIME, &cur_pos);
|
||||||
|
|
||||||
if (seek_params->reverse) {
|
if (seek_params->reverse) {
|
||||||
stop_type = GST_SEEK_TYPE_SET;
|
stop_type = GST_SEEK_TYPE_SET;
|
||||||
stop = cur_pos;
|
stop = current_position;
|
||||||
} else {
|
} else {
|
||||||
start_type = GST_SEEK_TYPE_SET;
|
start_type = GST_SEEK_TYPE_SET;
|
||||||
start = cur_pos;
|
start = current_position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->new_range = FALSE;
|
ctx->new_range = FALSE;
|
||||||
|
|
||||||
flags = GST_SEEK_FLAG_FLUSH;
|
flags = GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE;
|
||||||
|
|
||||||
split = g_strsplit (seek_params->frames, "/", 2);
|
split = g_strsplit (seek_params->frames, "/", 2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue