summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-04 16:55:26 +0200
committerwm4 <wm4@nowhere>2016-05-04 16:55:26 +0200
commit833375f88d0392cac49b30ee3a4704fbab58e814 (patch)
tree225c7d03869f633524d80c0eba3ecd698c1c1d63 /player/command.c
parent86b5f1463c9084d83fbfb60bcd15bdb67795bb25 (diff)
downloadmpv-833375f88d0392cac49b30ee3a4704fbab58e814.tar.bz2
mpv-833375f88d0392cac49b30ee3a4704fbab58e814.tar.xz
command: change some hwdec properties
Introduce hwdec-current and hwdec-interop properties. Deprecate hwdec-detected, which never made a lot of sense, and which is replaced by the new properties. hwdec-active also becomes useless, as hwdec-current is a superset, so it's deprecated too (for now).
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index e6a3258741..c6391cc224 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2166,6 +2166,51 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop,
return mp_property_generic_option(mpctx, prop, action, arg);
}
+static int mp_property_hwdec_current(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ struct track *track = mpctx->current_track[0][STREAM_VIDEO];
+ struct dec_video *vd = track ? track->d_video : NULL;
+
+ if (!vd)
+ return M_PROPERTY_UNAVAILABLE;
+
+ switch (action) {
+ case M_PROPERTY_GET_TYPE: {
+ // Abuse another hwdec option to resolve the value names
+ struct m_property dummy = {.name = "hwdec"};
+ return mp_property_generic_option(mpctx, &dummy, action, arg);
+ }
+ case M_PROPERTY_GET: {
+ int current = HWDEC_NONE;
+ video_vd_control(vd, VDCTRL_GET_HWDEC, &current);
+ if (current == HWDEC_AUTO)
+ current = HWDEC_NONE;
+ *(int *)arg = current;
+ return M_PROPERTY_OK;
+ }
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
+static int mp_property_hwdec_interop(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ if (!mpctx->video_out)
+ return M_PROPERTY_UNAVAILABLE;
+
+ struct mp_hwdec_info *hwdec_info = NULL;
+ vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &hwdec_info);
+ struct mp_hwdec_ctx *hwctx = hwdec_info ? hwdec_info->hwctx : NULL;
+ const char *name = hwctx ? hwctx->driver_name : NULL;
+ if (!name && hwctx && hwctx->type != HWDEC_NONE && hwctx->type != HWDEC_AUTO)
+ name = m_opt_choice_str(mp_hwdec_names, hwctx->type);
+
+ return m_property_strdup_ro(action, arg, name);
+}
+
static int mp_property_hwdec_active(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3696,6 +3741,8 @@ static const struct m_property mp_properties[] = {
{"program", mp_property_program},
{"hwdec", mp_property_hwdec},
{"hwdec-active", mp_property_hwdec_active},
+ {"hwdec-current", mp_property_hwdec_current},
+ {"hwdec-interop", mp_property_hwdec_interop},
{"hwdec-detected", mp_property_detected_hwdec},
{"estimated-frame-count", mp_property_frame_count},