command: read the diff if you want to know

This commit is contained in:
wm4 2017-10-21 21:13:53 +02:00
parent 633077814e
commit 60df01512c
5 changed files with 56 additions and 1 deletions

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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);

View File

@ -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},