summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-30 14:26:54 +0100
committerwm4 <wm4@nowhere>2017-10-30 15:28:59 +0100
commit2d958dbf2bd918391f3b3f48fe131d3eb783463a (patch)
tree5bc3d3c0888afe734c8f6913bf691095aa5dc7c5 /player
parentd6ebb2df47fa2827aecdcf236a234cd2fe74fe2c (diff)
downloadmpv-2d958dbf2bd918391f3b3f48fe131d3eb783463a.tar.bz2
mpv-2d958dbf2bd918391f3b3f48fe131d3eb783463a.tar.xz
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.
Diffstat (limited to 'player')
-rw-r--r--player/command.c15
1 files changed, 8 insertions, 7 deletions
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);