From 4dfaa373846e79f1bc34b50426c1584b948c0eb6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 1 Sep 2018 13:04:45 +0200 Subject: demux, stream: readd cache-speed in some other form it's more like an input speed rather than a cache speed, but who cares. --- player/command.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'player') diff --git a/player/command.c b/player/command.c index 30629eae54..4d0fbefc34 100644 --- a/player/command.c +++ b/player/command.c @@ -1559,6 +1559,26 @@ static int mp_property_playback_abort(void *ctx, struct m_property *prop, return m_property_flag_ro(action, arg, !mpctx->playing || mpctx->stop_play); } +static int mp_property_cache_speed(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; + + uint64_t val = s.bytes_per_second; + + if (action == M_PROPERTY_PRINT) { + *(char **)arg = talloc_strdup_append(format_file_size(val), "/s"); + return M_PROPERTY_OK; + } + return m_property_int64_ro(action, arg, val); +} + static int mp_property_demuxer_cache_duration(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3771,6 +3791,7 @@ static const struct m_property mp_properties_base[] = { {"eof-reached", mp_property_eof_reached}, {"seeking", mp_property_seeking}, {"playback-abort", mp_property_playback_abort}, + {"cache-speed", mp_property_cache_speed}, {"demuxer-cache-duration", mp_property_demuxer_cache_duration}, {"demuxer-cache-time", mp_property_demuxer_cache_time}, {"demuxer-cache-idle", mp_property_demuxer_cache_idle}, -- cgit v1.2.3