Commit 8f914515 authored by Wim Taymans's avatar Wim Taymans

More seeking fixes.

Keep the udp sources in playing even if we go to paused. unlock the sources when
we shut down.
Add some more debug info.
Only seek when we need to.
Keep track of the position when we go to paused.
parent 525d639c
...@@ -36,6 +36,7 @@ static void gst_rtsp_media_finalize (GObject * obj); ...@@ -36,6 +36,7 @@ static void gst_rtsp_media_finalize (GObject * obj);
static gpointer do_loop (GstRTSPMediaClass *klass); static gpointer do_loop (GstRTSPMediaClass *klass);
static gboolean default_handle_message (GstRTSPMedia *media, GstMessage *message); static gboolean default_handle_message (GstRTSPMedia *media, GstMessage *message);
static void unlock_streams (GstRTSPMedia *media);
G_DEFINE_TYPE (GstRTSPMedia, gst_rtsp_media, G_TYPE_OBJECT); G_DEFINE_TYPE (GstRTSPMedia, gst_rtsp_media, G_TYPE_OBJECT);
...@@ -96,6 +97,7 @@ gst_rtsp_media_finalize (GObject * obj) ...@@ -96,6 +97,7 @@ gst_rtsp_media_finalize (GObject * obj)
g_message ("finalize media %p", media); g_message ("finalize media %p", media);
if (media->pipeline) { if (media->pipeline) {
unlock_streams (media);
gst_element_set_state (media->pipeline, GST_STATE_NULL); gst_element_set_state (media->pipeline, GST_STATE_NULL);
gst_object_unref (media->pipeline); gst_object_unref (media->pipeline);
} }
...@@ -174,13 +176,20 @@ collect_media_stats (GstRTSPMedia *media) ...@@ -174,13 +176,20 @@ collect_media_stats (GstRTSPMedia *media)
else { else {
/* get the position */ /* get the position */
format = GST_FORMAT_TIME; format = GST_FORMAT_TIME;
if (!gst_element_query_position (media->pipeline, &format, &position)) if (!gst_element_query_position (media->pipeline, &format, &position)) {
g_message ("position query failed");
position = 0; position = 0;
}
/* get the duration */ /* get the duration */
format = GST_FORMAT_TIME; format = GST_FORMAT_TIME;
if (!gst_element_query_duration (media->pipeline, &format, &duration)) if (!gst_element_query_duration (media->pipeline, &format, &duration)) {
g_message ("duration query failed");
duration = -1; duration = -1;
}
g_message ("stats: position %"GST_TIME_FORMAT", duration %"GST_TIME_FORMAT,
GST_TIME_ARGS (position), GST_TIME_ARGS (duration));
if (position == -1) { if (position == -1) {
media->range.min.type = GST_RTSP_TIME_NOW; media->range.min.type = GST_RTSP_TIME_NOW;
...@@ -328,8 +337,13 @@ gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range) ...@@ -328,8 +337,13 @@ gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range)
start = -1; start = -1;
break; break;
case GST_RTSP_TIME_SECONDS: case GST_RTSP_TIME_SECONDS:
start = range->min.seconds * GST_SECOND; /* only seek when something changed */
start_type = GST_SEEK_TYPE_SET; if (media->range.min.seconds == range->min.seconds) {
start = -1;
} else {
start = range->min.seconds * GST_SECOND;
start_type = GST_SEEK_TYPE_SET;
}
break; break;
case GST_RTSP_TIME_END: case GST_RTSP_TIME_END:
default: default:
...@@ -337,8 +351,13 @@ gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range) ...@@ -337,8 +351,13 @@ gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range)
} }
switch (range->max.type) { switch (range->max.type) {
case GST_RTSP_TIME_SECONDS: case GST_RTSP_TIME_SECONDS:
stop = range->max.seconds * GST_SECOND; /* only seek when something changed */
stop_type = GST_SEEK_TYPE_SET; if (media->range.max.seconds == range->max.seconds) {
stop = -1;
} else {
stop = range->max.seconds * GST_SECOND;
stop_type = GST_SEEK_TYPE_SET;
}
break; break;
case GST_RTSP_TIME_END: case GST_RTSP_TIME_END:
stop = -1; stop = -1;
...@@ -353,15 +372,13 @@ gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range) ...@@ -353,15 +372,13 @@ gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range)
g_message ("seeking to %"GST_TIME_FORMAT" - %"GST_TIME_FORMAT, g_message ("seeking to %"GST_TIME_FORMAT" - %"GST_TIME_FORMAT,
GST_TIME_ARGS (start), GST_TIME_ARGS (stop)); GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
#if 0
res = gst_element_seek (media->pipeline, 1.0, GST_FORMAT_TIME, res = gst_element_seek (media->pipeline, 1.0, GST_FORMAT_TIME,
flags, start_type, start, stop_type, stop); flags, start_type, start, stop_type, stop);
#endif
res = TRUE;
/* and block for the seek to complete */ /* and block for the seek to complete */
gst_element_get_state (media->pipeline, NULL, NULL, -1);
g_message ("done seeking %d", res); g_message ("done seeking %d", res);
gst_element_get_state (media->pipeline, NULL, NULL, -1);
g_message ("prerolled again");
collect_media_stats (media); collect_media_stats (media);
} }
...@@ -1019,9 +1036,6 @@ gst_rtsp_media_prepare (GstRTSPMedia *media) ...@@ -1019,9 +1036,6 @@ gst_rtsp_media_prepare (GstRTSPMedia *media)
/* collect stats about the media */ /* collect stats about the media */
collect_media_stats (media); collect_media_stats (media);
/* unlock the streams so that they follow the state changes from now on */
unlock_streams (media);
g_message ("object %p is prerolled", media); g_message ("object %p is prerolled", media);
media->prepared = TRUE; media->prepared = TRUE;
...@@ -1075,6 +1089,8 @@ gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state, GArray *transport ...@@ -1075,6 +1089,8 @@ gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state, GArray *transport
switch (state) { switch (state) {
case GST_STATE_NULL: case GST_STATE_NULL:
/* unlock the streams so that they follow the state changes from now on */
unlock_streams (media);
case GST_STATE_PAUSED: case GST_STATE_PAUSED:
/* we're going from PLAYING to READY or NULL, remove */ /* we're going from PLAYING to READY or NULL, remove */
if (media->target_state == GST_STATE_PLAYING) if (media->target_state == GST_STATE_PLAYING)
...@@ -1134,6 +1150,10 @@ gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state, GArray *transport ...@@ -1134,6 +1150,10 @@ gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state, GArray *transport
media->target_state = state; media->target_state = state;
ret = gst_element_set_state (media->pipeline, state); ret = gst_element_set_state (media->pipeline, state);
/* remember where we are */
if (state == GST_STATE_PAUSED)
collect_media_stats (media);
return TRUE; return TRUE;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment