From b9e4fb952dbfc3b0b021fb3a838c4ab0328808cf Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 24 Mar 2017 15:31:01 +0100 Subject: command: add a property to signal whether networking is used Requested. The property semantics are a bit muddy due to lack of effort. Anticipated use is different display of cache status, so it should not matter anyway. --- DOCS/man/input.rst | 8 ++++++++ player/command.c | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 67c5e81b7d..e14a69c770 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1224,6 +1224,14 @@ 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-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 + be used for other types of untrusted streams, could be wrong in certain + cases, and its definition might be changing. Also, external files (like + separate audio files or streams) do not influence the value of this + property (currently). + ``paused-for-cache`` Returns ``yes`` when playback is paused because of waiting for the cache. diff --git a/player/command.c b/player/command.c index ae01796f31..c490f9db61 100644 --- a/player/command.c +++ b/player/command.c @@ -1742,6 +1742,17 @@ static int mp_property_cache_buffering(void *ctx, struct m_property *prop, return m_property_int_ro(action, arg, state); } +static int mp_property_demuxer_is_network(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + if (!mpctx->demuxer) + return M_PROPERTY_UNAVAILABLE; + + return m_property_flag_ro(action, arg, mpctx->demuxer->is_network); +} + + static int mp_property_clock(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3906,6 +3917,7 @@ static const struct m_property mp_properties_base[] = { {"demuxer-cache-idle", mp_property_demuxer_cache_idle}, {"cache-buffering-state", mp_property_cache_buffering}, {"paused-for-cache", mp_property_paused_for_cache}, + {"demuxer-via-network", mp_property_demuxer_is_network}, {"clock", mp_property_clock}, {"seekable", mp_property_seekable}, {"partially-seekable", mp_property_partially_seekable}, -- cgit v1.2.3