diff options
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c index 2387eb25d8..1b7156bb6c 100644 --- a/player/command.c +++ b/player/command.c @@ -2970,6 +2970,23 @@ static int mp_property_ab_loop(void *ctx, struct m_property *prop, return r; } +static int mp_property_packet_bitrate(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + int type = (intptr_t)prop->priv; + + if (!mpctx->demuxer) + return M_PROPERTY_UNAVAILABLE; + + double r[STREAM_TYPE_COUNT]; + if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_BITRATE_STATS, &r) < 1) + return M_PROPERTY_UNAVAILABLE; + + // r[type] is in bytes/second -> kilobits + return m_property_int64_ro(action, arg, r[type] * 8 / 1000.0 + 0.5); +} + static int mp_property_version(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3301,6 +3318,12 @@ static const struct m_property mp_properties[] = { {"ab-loop-a", mp_property_ab_loop}, {"ab-loop-b", mp_property_ab_loop}, +#define PROPERTY_BITRATE(name, type) \ + {name, mp_property_packet_bitrate, (void *)(intptr_t)type} + PROPERTY_BITRATE("packet-video-bitrate", STREAM_VIDEO), + PROPERTY_BITRATE("packet-audio-bitrate", STREAM_AUDIO), + PROPERTY_BITRATE("packet-sub-bitrate", STREAM_SUB), + #define PROPERTY_TV_COLOR(name, type) \ {name, mp_property_tv_color, (void *)(intptr_t)type} PROPERTY_TV_COLOR("tv-brightness", TV_COLOR_BRIGHTNESS), |