summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-28 17:48:31 +0200
committerwm4 <wm4@nowhere>2014-08-28 17:49:10 +0200
commite47a9bd721d6a6fcc06143aee5432d2a44866efb (patch)
tree5797395da8bf18ecb0f8d15e1251c4d5be012627
parentfb1266c98b409e0ff9a2c6bb2422879132b3922d (diff)
downloadmpv-e47a9bd721d6a6fcc06143aee5432d2a44866efb.tar.bz2
mpv-e47a9bd721d6a6fcc06143aee5432d2a44866efb.tar.xz
command: export demuxer cache info properties
-rw-r--r--DOCS/man/input.rst9
-rw-r--r--player/command.c36
2 files changed, 44 insertions, 1 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index b66326c56b..cde7cd3d23 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -834,6 +834,15 @@ Property list
Returns ``yes`` if the cache is idle, which means the cache is filled as
much as possible, and is currently not reading more data.
+``demuxer-cache-duration``
+ Approximate duration of video buffered in the demuxer, in seconds. The
+ guess is very unreliable, and often the property will not be available
+ at all, even if data is buffered.
+
+``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.
+
``paused-for-cache``
Returns ``yes`` when playback is paused because of waiting for the cache.
diff --git a/player/command.c b/player/command.c
index e624003ce9..95edb88ec2 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1217,6 +1217,37 @@ static int mp_property_cache_idle(void *ctx, struct m_property *prop,
return m_property_flag_ro(action, arg, !!idle);
}
+static int mp_property_demuxer_cache_duration(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;
+
+ if (s.ts_duration < 0)
+ return M_PROPERTY_UNAVAILABLE;
+
+ return m_property_double_ro(action, arg, s.ts_duration);
+}
+
+static int mp_property_demuxer_cache_idle(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;
+
+ return m_property_flag_ro(action, arg, s.idle);
+}
+
static int mp_property_paused_for_cache(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -2762,6 +2793,8 @@ static const struct m_property mp_properties[] = {
{"cache-used", mp_property_cache_used},
{"cache-size", mp_property_cache_size},
{"cache-idle", mp_property_cache_idle},
+ {"demuxer-cache-duration", mp_property_demuxer_cache_duration},
+ {"demuxer-cache-idle", mp_property_demuxer_cache_idle},
{"paused-for-cache", mp_property_paused_for_cache},
{"pts-association-mode", mp_property_generic_option},
{"hr-seek", mp_property_generic_option},
@@ -2897,7 +2930,8 @@ static const char *const *const mp_event_property_change[] = {
E(MPV_EVENT_PLAYBACK_RESTART, "seeking"),
E(MPV_EVENT_METADATA_UPDATE, "metadata"),
E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"),
- E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle"),
+ E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle",
+ "demuxer-cache-duration", "demuxer-cache-idle"),
};
#undef E