From d080d1d39afe2b0a4286ab4688df609984996357 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 Mar 2013 21:25:11 +0100 Subject: command: export VO video width/height as properties Add new properties "dwidth" and "dheight", which contain the video size as known by the VO (not necessarily what the VO makes out of them, i.e. without window scaling and panscan). --- core/command.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'core/command.c') diff --git a/core/command.c b/core/command.c index 1d6e0c976d..58079d63f1 100644 --- a/core/command.c +++ b/core/command.c @@ -1143,6 +1143,28 @@ static int mp_property_height(m_option_t *prop, int action, void *arg, return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h); } +static int property_vo_wh(m_option_t *prop, int action, void *arg, + MPContext *mpctx, bool get_w) +{ + struct vo *vo = mpctx->video_out; + if (!mpctx->sh_video && !vo || !vo->hasframe) + return M_PROPERTY_UNAVAILABLE; + return m_property_int_ro(prop, action, arg, + get_w ? vo->aspdat.prew : vo->aspdat.preh); +} + +static int mp_property_dwidth(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + return property_vo_wh(prop, action, arg, mpctx, true); +} + +static int mp_property_dheight(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + return property_vo_wh(prop, action, arg, mpctx, false); +} + /// Video fps (RO) static int mp_property_fps(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -1408,6 +1430,8 @@ static const m_option_t mp_properties[] = { 0, 0, 0, NULL }, { "height", mp_property_height, CONF_TYPE_INT, 0, 0, 0, NULL }, + { "dwidth", mp_property_dwidth, CONF_TYPE_INT }, + { "dheight", mp_property_dheight, CONF_TYPE_INT }, { "fps", mp_property_fps, CONF_TYPE_FLOAT, 0, 0, 0, NULL }, { "aspect", mp_property_aspect, CONF_TYPE_FLOAT, -- cgit v1.2.3