diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-03-06 19:44:02 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-03-21 20:38:09 +0200 |
commit | 43d1dd3dad735fe8c81ee31b2dc574460a0f4c29 (patch) | |
tree | d0e4a4857ef06ecc90e96b5bfe32456f4654508e /ext/dash/gstmpdparser.c | |
parent | ffa63c593302fb83f05c60f102528efe1110b90b (diff) | |
download | gstreamer-plugins-bad-43d1dd3dad735fe8c81ee31b2dc574460a0f4c29.tar.gz |
mpdparser: Refactor to get rid of one level of indentation in seeking code
Also go out of the segment searching loop once segment->start > ts.
We're not going to find any earlier segment anymore.
Diffstat (limited to 'ext/dash/gstmpdparser.c')
-rw-r--r-- | ext/dash/gstmpdparser.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index baf5dbc83..734959dcd 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -4765,62 +4765,61 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, gint index = 0; gint repeat_index = 0; GstMediaSegment *selectedChunk = NULL; - gboolean in_segment; g_return_val_if_fail (stream != NULL, 0); if (stream->segments) { for (index = 0; index < stream->segments->len; index++) { + gboolean in_segment = FALSE; GstMediaSegment *segment = g_ptr_array_index (stream->segments, index); + GstClockTime end_time; GST_DEBUG ("Looking at fragment sequence chunk %d / %d", index, stream->segments->len); - in_segment = FALSE; - if (segment->start <= ts) { - GstClockTime end_time; - if (segment->repeat >= 0) { - end_time = segment->start + (segment->repeat + 1) * segment->duration; - } else { - end_time = - gst_mpdparser_get_segment_end_time (client, stream->segments, - segment, index); - } + if (segment->start > ts) + break; - /* avoid downloading another fragment just for 1ns in reverse mode */ - if (forward) - in_segment = ts < end_time; - else - in_segment = ts <= end_time; + if (segment->repeat >= 0) { + end_time = segment->start + (segment->repeat + 1) * segment->duration; + } else { + end_time = + gst_mpdparser_get_segment_end_time (client, stream->segments, + segment, index); + } + + /* avoid downloading another fragment just for 1ns in reverse mode */ + if (forward) + in_segment = ts < end_time; + else + in_segment = ts <= end_time; - if (in_segment) { - selectedChunk = segment; - repeat_index = (ts - segment->start) / segment->duration; + if (in_segment) { + selectedChunk = segment; + repeat_index = (ts - segment->start) / segment->duration; - /* At the end of a segment in reverse mode, start from the previous fragment */ - if (!forward && repeat_index > 0 - && ((ts - segment->start) % segment->duration == 0)) - repeat_index--; + /* At the end of a segment in reverse mode, start from the previous fragment */ + if (!forward && repeat_index > 0 + && ((ts - segment->start) % segment->duration == 0)) + repeat_index--; - if ((flags & GST_SEEK_FLAG_SNAP_NEAREST) == - GST_SEEK_FLAG_SNAP_NEAREST) { - /* FIXME implement this */ - } else if ((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) || - (!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) { + if ((flags & GST_SEEK_FLAG_SNAP_NEAREST) == GST_SEEK_FLAG_SNAP_NEAREST) { + /* FIXME implement this */ + } else if ((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) || + (!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) { - if (repeat_index + 1 < segment->repeat) { - repeat_index++; + if (repeat_index + 1 < segment->repeat) { + repeat_index++; + } else { + repeat_index = 0; + if (index + 1 >= stream->segments->len) { + selectedChunk = NULL; } else { - repeat_index = 0; - if (index + 1 >= stream->segments->len) { - selectedChunk = NULL; - } else { - selectedChunk = g_ptr_array_index (stream->segments, ++index); - } + selectedChunk = g_ptr_array_index (stream->segments, ++index); } } - break; } + break; } } |