From 2d958dbf2bd918391f3b3f48fe131d3eb783463a Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 30 Oct 2017 14:26:54 +0100 Subject: demux: refactor to export seek ranges Even though only 1 seek range is supported at the time. Other than preparation for possibly future features, the main gain is actually that we finally separate the reporting for the buffering, and the seek ranges. These can be subtly different, so it's good to have a clear separation. This commit also fixes that the ts_reader wasn't rebased to the start time, which could make the player show "???" for buffered cache amount in some .ts files and others (especially at the end, when ts_reader could become higher than ts_max). It also fixes writing the cache-end field in the demuxer-cache-state property: it checked ts_start against NOPTS, which makes no sense. ts_start was never used (except for the bug mentioned above), so get rid of it completely. This also makes it convenient to move the segment check for last_ts to the demux_add_packet() function. --- player/command.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index 5a75681bd1..c95f7e6054 100644 --- a/player/command.c +++ b/player/command.c @@ -1696,10 +1696,10 @@ static int mp_property_demuxer_cache_time(void *ctx, struct m_property *prop, if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1) return M_PROPERTY_UNAVAILABLE; - if (s.ts_max == MP_NOPTS_VALUE) + if (s.ts_end == MP_NOPTS_VALUE) return M_PROPERTY_UNAVAILABLE; - return m_property_double_ro(action, arg, s.ts_max); + return m_property_double_ro(action, arg, s.ts_end); } static int mp_property_demuxer_cache_idle(void *ctx, struct m_property *prop, @@ -1739,14 +1739,15 @@ static int mp_property_demuxer_cache_state(void *ctx, struct m_property *prop, struct mpv_node *ranges = node_map_add(r, "seekable-ranges", MPV_FORMAT_NODE_ARRAY); - if (s.ts_min != MP_NOPTS_VALUE && s.ts_max != MP_NOPTS_VALUE && s.seekable) { + for (int n = 0; n < s.num_seek_ranges; n++) { + struct demux_seek_range *range = &s.seek_ranges[n]; struct mpv_node *sub = node_array_add(ranges, MPV_FORMAT_NODE_MAP); - node_map_add_double(sub, "start", s.ts_min); - node_map_add_double(sub, "end", s.ts_max); + node_map_add_double(sub, "start", range->start); + node_map_add_double(sub, "end", range->end); } - if (s.ts_start != MP_NOPTS_VALUE) - node_map_add_double(r, "cache-end", s.ts_max); + if (s.ts_end != MP_NOPTS_VALUE) + node_map_add_double(r, "cache-end", s.ts_end); if (s.ts_reader != MP_NOPTS_VALUE) node_map_add_double(r, "reader-pts", s.ts_reader); -- cgit v1.2.3