diff options
author | xylosper <darklin20@gmail.com> | 2015-04-21 06:47:13 +0900 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-04-21 13:53:25 +0200 |
commit | dbeb1053962e2eb35d380e6b6a5bc7a3c3d60d76 (patch) | |
tree | 95c8c4d276104d57be7befeb18a50be305d048d0 /player | |
parent | 445527d45cc2dbf274da8f14bb61dbf8c1f64a13 (diff) |
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 <wm4@nowhere>
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 22 |
1 files changed, 21 insertions, 1 deletions
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"), |