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>
This commit is contained in:
xylosper 2015-04-21 06:47:13 +09:00 committed by wm4
parent 445527d45c
commit dbeb105396
2 changed files with 26 additions and 1 deletions

View File

@ -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.

View File

@ -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"),