From dbeb1053962e2eb35d380e6b6a5bc7a3c3d60d76 Mon Sep 17 00:00:00 2001 From: xylosper Date: Tue, 21 Apr 2015 06:47:13 +0900 Subject: command: demuxer-cache-time property Approximate time of video buffered in the demuxer, in seconds. Same as `demuxer-cache-duration` but returns the last timestamp of bufferred data in demuxer. Signed-off-by: wm4 --- DOCS/man/input.rst | 5 +++++ player/command.c | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index e1c3a58421..2d297c0371 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1090,6 +1090,11 @@ Property list guess is very unreliable, and often the property will not be available at all, even if data is buffered. +``demuxer-cache-time`` + Approximate time of video buffered in the demuxer, in seconds. Same as + ``demuxer-cache-duration`` but returns the last timestamp of bufferred + data in demuxer. + ``demuxer-cache-idle`` 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. diff --git a/player/command.c b/player/command.c index d210398946..3556986473 100644 --- a/player/command.c +++ b/player/command.c @@ -1383,6 +1383,24 @@ static int mp_property_demuxer_cache_duration(void *ctx, struct m_property *prop return m_property_double_ro(action, arg, s.ts_duration); } +static int mp_property_demuxer_cache_time(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; + + double ts = s.ts_range[1]; + if (ts == MP_NOPTS_VALUE) + return M_PROPERTY_UNAVAILABLE; + + return m_property_double_ro(action, arg, ts); +} + static int mp_property_demuxer_cache_idle(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3271,6 +3289,7 @@ static const struct m_property mp_properties[] = { {"cache-size", mp_property_cache_size}, {"cache-idle", mp_property_cache_idle}, {"demuxer-cache-duration", mp_property_demuxer_cache_duration}, + {"demuxer-cache-time", mp_property_demuxer_cache_time}, {"demuxer-cache-idle", mp_property_demuxer_cache_idle}, {"cache-buffering-state", mp_property_cache_buffering}, {"paused-for-cache", mp_property_paused_for_cache}, @@ -3463,7 +3482,8 @@ static const char *const *const mp_event_property_change[] = { E(MPV_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"), E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"), E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle", - "demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache"), + "demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache", + "demuxer-cache-time"), E(MP_EVENT_WIN_RESIZE, "window-scale"), E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps"), E(MP_EVENT_AUDIO_DEVICES, "audio-device-list"), -- cgit v1.2.3