[vlc-devel] [PATCH 3/9] video_output: add an API to select the stereo mode dynamically
Steve Lhomme
robux4 at ycbcr.xyz
Sat Oct 27 08:46:29 CEST 2018
From: "Mohammed (Shaan) Huzaifa Danish" <shaan3 at gmail.com>
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
---
include/vlc_vout_display.h | 3 +++
src/video_output/control.h | 1 +
src/video_output/display.c | 11 +++++++++++
src/video_output/video_output.c | 14 ++++++++++++++
src/video_output/vout_internal.h | 1 +
src/video_output/vout_intf.c | 13 +++++++++++++
src/video_output/vout_wrapper.h | 1 +
7 files changed, 44 insertions(+)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 09f257790c..91ac07b9c0 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -99,6 +99,9 @@ typedef struct {
} zoom;
vlc_viewpoint_t viewpoint;
+
+ /* Stereoscopic/3D mode used by the display */
+ vlc_stereoscopic_mode_t stereo_mode;
} vout_display_cfg_t;
/**
diff --git a/src/video_output/control.h b/src/video_output/control.h
index ddb3b1ad99..7fbde44eb5 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -56,6 +56,7 @@ enum {
VOUT_CONTROL_CROP_RATIO, /* pair */
VOUT_CONTROL_CROP_WINDOW, /* window */
VOUT_CONTROL_VIEWPOINT, /* viewpoint */
+ VOUT_CONTROL_STEREO_MODE, /* integer */
};
typedef struct {
diff --git a/src/video_output/display.c b/src/video_output/display.c
index abe7aeb58a..94487b1748 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -352,6 +352,8 @@ typedef struct {
unsigned den;
} crop;
+ vlc_stereoscopic_mode_t stereo_mode;
+
/* */
video_format_t source;
/* filters to convert the vout source to fmt, NULL means no conversion
@@ -922,6 +924,13 @@ void vout_SetDisplayViewpoint(vout_display_t *vd,
}
}
+void vout_SetDisplayStereo(vout_display_t *vd, vlc_stereoscopic_mode_t mode)
+{
+ vout_display_owner_sys_t *osys = vd->owner.sys;
+
+ osys->stereo_mode = mode;
+}
+
static vout_display_t *DisplayNew(vout_thread_t *vout,
const video_format_t *source,
const vout_display_state_t *state,
@@ -962,6 +971,8 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
osys->sar.num = osys->sar_initial.num ? osys->sar_initial.num : source->i_sar_num;
osys->sar.den = osys->sar_initial.den ? osys->sar_initial.den : source->i_sar_den;
+ osys->stereo_mode = cfg->stereo_mode;
+
vout_display_owner_t owner;
if (owner_ptr)
owner = *owner_ptr;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 5177408a32..0336de353f 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -666,6 +666,11 @@ void vout_ControlChangeViewpoint(vout_thread_t *vout,
vout_control_Push(&vout->p->control, &cmd);
}
+void vout_ControlChangeStereo(vout_thread_t *vout, vlc_stereoscopic_mode_t mode)
+{
+ vout_control_PushInteger(&vout->p->control, VOUT_CONTROL_STEREO_MODE, mode);
+}
+
/* */
static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg)
{
@@ -697,6 +702,7 @@ static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg)
cfg->zoom.den = zoom_den;
cfg->align.vertical = VOUT_DISPLAY_ALIGN_CENTER;
cfg->align.horizontal = VOUT_DISPLAY_ALIGN_CENTER;
+ cfg->stereo_mode = var_GetInteger(vout, "video-stereo-mode");
const int align_mask = var_GetInteger(vout, "align");
if (align_mask & 0x1)
cfg->align.horizontal = VOUT_DISPLAY_ALIGN_LEFT;
@@ -1416,6 +1422,11 @@ static void ThreadTranslateMouseState(vout_thread_t *vout,
vout_SendDisplayEventMouse(vout, &vid_mouse);
}
+static void ThreadChangeStereo(vout_thread_t *vout, vlc_stereoscopic_mode_t mode)
+{
+ vout_SetDisplayStereo(vout->p->display.vd, mode);
+}
+
static int ThreadStart(vout_thread_t *vout, vout_display_state_t *state)
{
vlc_mouse_Init(&vout->p->mouse);
@@ -1677,6 +1688,9 @@ static int ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
case VOUT_CONTROL_VIEWPOINT:
vout_SetDisplayViewpoint(vout->p->display.vd, &cmd.viewpoint);
break;
+ case VOUT_CONTROL_STEREO_MODE:
+ ThreadChangeStereo(vout, cmd.integer);
+ break;
default:
break;
}
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 8fb36a69db..b189f4a8ef 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -208,6 +208,7 @@ void vout_ControlChangeSubSources(vout_thread_t *, const char *);
void vout_ControlChangeSubFilters(vout_thread_t *, const char *);
void vout_ControlChangeSubMargin(vout_thread_t *, int);
void vout_ControlChangeViewpoint( vout_thread_t *, const vlc_viewpoint_t *);
+void vout_ControlChangeStereo(vout_thread_t *vout, vlc_stereoscopic_mode_t mode);
/* */
void vout_IntfInit( vout_thread_t * );
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index a70563bb4e..c65b0fcde4 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -75,6 +75,8 @@ static int SubMarginCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int ViewpointCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static int Stereo3DCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* vout_IntfInit: called during the vout creation to initialise misc things.
@@ -203,6 +205,8 @@ void vout_IntfInit( vout_thread_t *p_vout )
vlc_gettext( p_3D_output_format_values[i].psz_label ) );
}
+ var_AddCallback( p_vout, "video-stereo-mode", Stereo3DCallback, NULL );
+
/* Crop offset vars */
var_Create( p_vout, "crop-left", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_Create( p_vout, "crop-top", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
@@ -528,6 +532,15 @@ static int ZoomCallback( vlc_object_t *obj, char const *name,
return VLC_SUCCESS;
}
+static int Stereo3DCallback( vlc_object_t *obj, char const *name,
+ vlc_value_t prev, vlc_value_t cur, void *data )
+{
+ vout_thread_t *p_vout = (vout_thread_t *)obj;
+ (void) name; (void) prev; (void) data;
+ vout_ControlChangeStereo( p_vout, cur.i_int );
+ return VLC_SUCCESS;
+}
+
static int AboveCallback( vlc_object_t *obj, char const *name,
vlc_value_t prev, vlc_value_t cur, void *data )
{
diff --git a/src/video_output/vout_wrapper.h b/src/video_output/vout_wrapper.h
index fec8a4869f..c5dbb3a20c 100644
--- a/src/video_output/vout_wrapper.h
+++ b/src/video_output/vout_wrapper.h
@@ -93,6 +93,7 @@ void vout_SetDisplayCrop(vout_display_t *,
unsigned left, unsigned top, int right, int bottom);
void vout_SetDisplayCropRatio(vout_display_t *, unsigned num, unsigned den);
void vout_SetDisplayViewpoint(vout_display_t *, const vlc_viewpoint_t *);
+void vout_SetDisplayStereo(vout_display_t *, vlc_stereoscopic_mode_t);
#endif /* LIBVLC_VOUT_WRAPPER_H */
--
2.17.0
More information about the vlc-devel
mailing list