rtsp-media: Don't seek for PLAY if the position will not change

https://bugzilla.gnome.org/show_bug.cgi?id=745704
This commit is contained in:
Sebastian Dröge 2015-03-09 13:00:25 +01:00
parent 93bdbb6acd
commit b58af93d83

View file

@ -1855,6 +1855,7 @@ gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
GstClockTime start, stop; GstClockTime start, stop;
GstSeekType start_type, stop_type; GstSeekType start_type, stop_type;
GstQuery *query; GstQuery *query;
gint64 current_position;
klass = GST_RTSP_MEDIA_GET_CLASS (media); klass = GST_RTSP_MEDIA_GET_CLASS (media);
@ -1899,6 +1900,12 @@ gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
GST_INFO ("current %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT, GST_INFO ("current %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT,
GST_TIME_ARGS (priv->range_start), GST_TIME_ARGS (priv->range_stop)); GST_TIME_ARGS (priv->range_start), GST_TIME_ARGS (priv->range_stop));
current_position = -1;
if (klass->query_position)
klass->query_position (media, &current_position);
GST_INFO ("current media position %" GST_TIME_FORMAT,
GST_TIME_ARGS (current_position));
if (start != GST_CLOCK_TIME_NONE) if (start != GST_CLOCK_TIME_NONE)
start_type = GST_SEEK_TYPE_SET; start_type = GST_SEEK_TYPE_SET;
@ -1913,10 +1920,6 @@ gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
GST_INFO ("seeking to %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT, GST_INFO ("seeking to %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT,
GST_TIME_ARGS (start), GST_TIME_ARGS (stop)); GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_PREPARING);
if (priv->blocked)
media_streams_set_blocked (media, TRUE);
/* depends on the current playing state of the pipeline. We might need to /* depends on the current playing state of the pipeline. We might need to
* queue this until we get EOS. */ * queue this until we get EOS. */
flags = GST_SEEK_FLAG_FLUSH; flags = GST_SEEK_FLAG_FLUSH;
@ -1925,18 +1928,12 @@ gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
* but since we're doing a flushing seek, let us query the current position * but since we're doing a flushing seek, let us query the current position
* so we end up at exactly the same position after the seek. */ * so we end up at exactly the same position after the seek. */
if (range->min.type == GST_RTSP_TIME_END) { /* Yepp, that's right! */ if (range->min.type == GST_RTSP_TIME_END) { /* Yepp, that's right! */
gint64 position; if (current_position == -1) {
gboolean ret = FALSE; GST_WARNING ("current position unknown");
if (klass->query_position)
ret = klass->query_position (media, &position);
if (!ret) {
GST_WARNING ("position query failed");
} else { } else {
GST_DEBUG ("doing accurate seek to %" GST_TIME_FORMAT, GST_DEBUG ("doing accurate seek to %" GST_TIME_FORMAT,
GST_TIME_ARGS (position)); GST_TIME_ARGS (current_position));
start = position; start = current_position;
start_type = GST_SEEK_TYPE_SET; start_type = GST_SEEK_TYPE_SET;
flags |= GST_SEEK_FLAG_ACCURATE; flags |= GST_SEEK_FLAG_ACCURATE;
} }
@ -1946,23 +1943,32 @@ gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
flags |= GST_SEEK_FLAG_KEY_UNIT; flags |= GST_SEEK_FLAG_KEY_UNIT;
} }
/* FIXME, we only do forwards playback, no trick modes yet */ if (start == current_position && stop_type == GST_SEEK_TYPE_NONE) {
res = gst_element_seek (priv->pipeline, 1.0, GST_FORMAT_TIME, GST_DEBUG ("not seeking because no position change");
flags, start_type, start, stop_type, stop); res = TRUE;
} else {
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_PREPARING);
if (priv->blocked)
media_streams_set_blocked (media, TRUE);
/* and block for the seek to complete */ /* FIXME, we only do forwards playback, no trick modes yet */
GST_INFO ("done seeking %d", res); res = gst_element_seek (priv->pipeline, 1.0, GST_FORMAT_TIME,
if (!res) flags, start_type, start, stop_type, stop);
goto seek_failed;
g_rec_mutex_unlock (&priv->state_lock); /* and block for the seek to complete */
GST_INFO ("done seeking %d", res);
if (!res)
goto seek_failed;
/* wait until pipeline is prerolled again, this will also collect stats */ g_rec_mutex_unlock (&priv->state_lock);
if (!wait_preroll (media))
goto preroll_failed;
g_rec_mutex_lock (&priv->state_lock); /* wait until pipeline is prerolled again, this will also collect stats */
GST_INFO ("prerolled again"); if (!wait_preroll (media))
goto preroll_failed;
g_rec_mutex_lock (&priv->state_lock);
GST_INFO ("prerolled again");
}
} else { } else {
GST_INFO ("no seek needed"); GST_INFO ("no seek needed");
res = TRUE; res = TRUE;