diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index a423f15bf2..99c8a3893b 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1450,6 +1450,13 @@ Property list buffering amount, while the seek ranges represent the buffered data that can actually be used for cached seeking. + ``bof-cached`` indicates whether the seek range with the lowest timestamp + points to the beginning of the stream (BOF). This implies you cannot seek + before this position at all. ``eof-cached`` indicates whether the seek range + with the highest timestamp points to the end of the stream (EOF). If both + ``bof-cached`` and ``eof-cached`` are set to ``yes``, the entire stream is + cached. + ``fw-bytes`` is the number of bytes of packets buffered in the range starting from the current decoding position. @@ -1464,6 +1471,8 @@ Property list MPV_FORMAT_NODE_MAP "start" MPV_FORMAT_DOUBLE "end" MPV_FORMAT_DOUBLE + "bof-cached" MPV_FORMAT_FLAG + "eof-cached" MPV_FORMAT_FLAG "fw-bytes" MPV_FORMAT_INT64 Other fields (might be changed or removed in the future): diff --git a/demux/demux.c b/demux/demux.c index b033fd504a..ff62c4e95f 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -3227,6 +3227,8 @@ void demux_get_reader_state(struct demuxer *demuxer, struct demux_reader_state * .start = MP_ADD_PTS(range->seek_start, in->ts_offset), .end = MP_ADD_PTS(range->seek_end, in->ts_offset), }; + r->bof_cached |= range->is_bof; + r->eof_cached |= range->is_eof; } } diff --git a/demux/demux.h b/demux/demux.h index 526c03713e..085fa26cff 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -38,6 +38,7 @@ struct demux_seek_range { struct demux_reader_state { bool eof, underrun, idle; + bool bof_cached, eof_cached; double ts_duration; double ts_reader; // approx. timerstamp of decoder position double ts_end; // approx. timestamp of end of buffered range diff --git a/player/command.c b/player/command.c index 4aae5e21b8..dce975dca7 100644 --- a/player/command.c +++ b/player/command.c @@ -1502,6 +1502,9 @@ static int mp_property_demuxer_cache_state(void *ctx, struct m_property *prop, struct mpv_node *r = (struct mpv_node *)arg; node_init(r, MPV_FORMAT_NODE_MAP, NULL); + node_map_add_flag(r, "bof-cached", s.bof_cached); + node_map_add_flag(r, "eof-cached", s.eof_cached); + struct mpv_node *ranges = node_map_add(r, "seekable-ranges", MPV_FORMAT_NODE_ARRAY); for (int n = 0; n < s.num_seek_ranges; n++) {