diff options
author | wm4 <wm4@nowhere> | 2017-10-21 21:13:53 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-10-21 21:13:53 +0200 |
commit | 60df01512cf88d51b6334c95dab72de734f136fd (patch) | |
tree | b3fffa31fad74494d49d2fd33284e9ae3af75fd1 | |
parent | 633077814ed32a6dd5d09be79688df0e1062b91b (diff) | |
download | mpv-60df01512cf88d51b6334c95dab72de734f136fd.tar.bz2 mpv-60df01512cf88d51b6334c95dab72de734f136fd.tar.xz |
command: read the diff if you want to know
-rw-r--r-- | DOCS/man/input.rst | 16 | ||||
-rw-r--r-- | demux/demux.c | 1 | ||||
-rw-r--r-- | demux/demux.h | 2 | ||||
-rw-r--r-- | options/m_property.h | 2 | ||||
-rw-r--r-- | player/command.c | 36 |
5 files changed, 56 insertions, 1 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 39a50e52e0..2f0cd74c94 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1258,6 +1258,22 @@ Property list Returns ``yes`` if the demuxer is idle, which means the demuxer cache is filled to the requested amount, and is currently not reading more data. +``demuxer-cache-state`` + Various undocumented things. Some fields are documented: + + ``demuxer-cache-state/seekable-start``, ``demuxer-cache-state/seekable-end`` + Seekable range within demuxer cache. Unavailable if not possible. + + When querying the property with the client API using ``MPV_FORMAT_NODE``, + or with Lua ``mp.get_property_native``, this will return a mpv_node with + the following contents: + + :: + + MPV_FORMAT_NODE_ARRAY + "seekable-start" MPV_FORMAT_DOUBLE + "seekable-end" MPV_FORMAT_DOUBLE + ``demuxer-via-network`` Returns ``yes`` if the stream demuxed via the main demuxer is most likely played via network. What constitutes "network" is not always clear, might diff --git a/demux/demux.c b/demux/demux.c index 015a3a6e2a..2ebed5a3e7 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1931,6 +1931,7 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg) struct demux_ctrl_reader_state *r = arg; *r = (struct demux_ctrl_reader_state){ .eof = in->last_eof, + .seekable = in->seekable_cache, .ts_start = MP_NOPTS_VALUE, .ts_min = MP_NOPTS_VALUE, .ts_max = MP_NOPTS_VALUE, diff --git a/demux/demux.h b/demux/demux.h index 24a08ecff4..9c9824658b 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -41,7 +41,7 @@ enum demux_ctrl { }; struct demux_ctrl_reader_state { - bool eof, underrun, idle; + bool eof, underrun, idle, seekable; double ts_duration; double ts_reader; // approx. timerstamp of decoder position double ts_start; // approx. timestamp for the earliest packet buffered diff --git a/options/m_property.h b/options/m_property.h index 35d704ad97..d71ec033aa 100644 --- a/options/m_property.h +++ b/options/m_property.h @@ -200,6 +200,8 @@ struct m_sub_property { .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)} #define SUB_PROP_FLAG(f) \ .type = {.type = CONF_TYPE_FLAG}, .value = {.flag = (f)} +#define SUB_PROP_PTS(f) \ + .type = {.type = &m_option_type_time}, .value = {.double_ = (f)} int m_property_read_sub(const struct m_sub_property *props, int action, void *arg); diff --git a/player/command.c b/player/command.c index 3b20ec8f3d..a6ffe3256e 100644 --- a/player/command.c +++ b/player/command.c @@ -1716,6 +1716,41 @@ static int mp_property_demuxer_cache_idle(void *ctx, struct m_property *prop, return m_property_flag_ro(action, arg, s.idle); } +static int mp_property_demuxer_cache_state(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + if (!mpctx->demuxer) + return M_PROPERTY_UNAVAILABLE; + + struct demux_ctrl_reader_state s; + if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1) + return M_PROPERTY_UNAVAILABLE; + + bool seek_ok = s.ts_min != MP_NOPTS_VALUE && + s.ts_max != MP_NOPTS_VALUE && + s.seekable; + + struct m_sub_property props[] = { + {"seekable-start", SUB_PROP_PTS(s.ts_min), + .unavailable = !seek_ok}, + {"seekable-end", SUB_PROP_PTS(s.ts_max), + .unavailable = !seek_ok}, + {"cache-start", SUB_PROP_PTS(s.ts_start), + .unavailable = s.ts_start == MP_NOPTS_VALUE}, + {"cache-end", SUB_PROP_PTS(s.ts_max), + .unavailable = s.ts_max == MP_NOPTS_VALUE}, + {"reader-pts", SUB_PROP_PTS(s.ts_reader), + .unavailable = s.ts_reader == MP_NOPTS_VALUE}, + {"eof", SUB_PROP_FLAG(s.eof)}, + {"underrun", SUB_PROP_FLAG(s.underrun)}, + {"idle", SUB_PROP_FLAG(s.idle)}, + {0} + }; + + return m_property_read_sub(props, action, arg); +} + static int mp_property_demuxer_start_time(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3937,6 +3972,7 @@ static const struct m_property mp_properties_base[] = { {"demuxer-cache-time", mp_property_demuxer_cache_time}, {"demuxer-cache-idle", mp_property_demuxer_cache_idle}, {"demuxer-start-time", mp_property_demuxer_start_time}, + {"demuxer-cache-state", mp_property_demuxer_cache_state}, {"cache-buffering-state", mp_property_cache_buffering}, {"paused-for-cache", mp_property_paused_for_cache}, {"demuxer-via-network", mp_property_demuxer_is_network}, |