[vlc-devel] [PATCH 3/6] video_output: handle the dynamic change of video-stereo-mode
Steve Lhomme
robux4 at ycbcr.xyz
Mon Aug 13 16:44:43 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 | 7 +++++++
include/vlc_vout_wrapper.h | 1 +
src/video_output/control.h | 1 +
src/video_output/display.c | 28 ++++++++++++++++++++++++++++
src/video_output/video_output.c | 14 ++++++++++++++
src/video_output/vout_internal.h | 1 +
src/video_output/vout_intf.c | 13 +++++++++++++
7 files changed, 65 insertions(+)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 86eb1bced0..e3ebc6ad4c 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;
/**
@@ -156,6 +159,10 @@ enum {
/* Ask the module to acknowledge/refuse VR/360° viewing direction after
* being requested externally */
VOUT_DISPLAY_CHANGE_VIEWPOINT, /* const vout_display_cfg_t *p_cfg */
+
+ /* Ask the module to acknowledge/refuse a new Stereoscopic 3D mode after
+ * being requested externally */
+ VOUT_DISPLAY_CHANGE_STEREO_MODE, /* const vout_display_cfg_t *p_cfg */
};
/**
diff --git a/include/vlc_vout_wrapper.h b/include/vlc_vout_wrapper.h
index a394bd4d70..e0a6ab0d1f 100644
--- a/include/vlc_vout_wrapper.h
+++ b/include/vlc_vout_wrapper.h
@@ -92,6 +92,7 @@ void vout_SetDisplayAspect(vout_display_t *, unsigned num, unsigned den);
void vout_SetDisplayCrop(vout_display_t *, unsigned num, unsigned den,
unsigned left, unsigned top, int right, int bottom);
void vout_SetDisplayViewpoint(vout_display_t *, const vlc_viewpoint_t *);
+void vout_SetDisplayStereo(vout_display_t *, vlc_stereoscopic_mode_t);
#endif /* VLC_VOUT_WRAPPER_H */
diff --git a/src/video_output/control.h b/src/video_output/control.h
index 181e02082d..777fa94282 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -64,6 +64,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 b0c0fdbb3e..fe08ffc5bd 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -352,6 +352,9 @@ typedef struct {
unsigned den;
} crop;
+ bool ch_stereo_mode;
+ vlc_stereoscopic_mode_t stereo_mode;
+
/* */
video_format_t source;
/* filters to convert the vout source to fmt, NULL means no conversion
@@ -753,6 +756,18 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
if (fit_window)
VoutDisplayFitWindow(vd, false);
+ if (osys->ch_stereo_mode) {
+ vout_display_cfg_t cfg = osys->cfg;
+
+ cfg.stereo_mode = osys->stereo_mode;
+
+ if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_STEREO_MODE, &cfg)) {
+ msg_Err(vd, "Failed to change multiview");
+ osys->stereo_mode = osys->cfg.stereo_mode;
+ }
+ osys->cfg.stereo_mode = osys->stereo_mode;
+ osys->ch_stereo_mode = false;
+ }
if (allow_reset_pictures
&& atomic_exchange(&osys->reset_pictures, false)) {
@@ -947,6 +962,17 @@ 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;
+
+ if (osys->stereo_mode != mode) {
+ osys->stereo_mode = mode;
+
+ osys->ch_stereo_mode = true;
+ }
+}
+
static vout_display_t *DisplayNew(vout_thread_t *vout,
const video_format_t *source,
const vout_display_state_t *state,
@@ -999,6 +1025,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 bd6fef592e..1b48ee43f5 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -598,6 +598,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)
{
@@ -629,6 +634,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;
@@ -1474,6 +1480,11 @@ static void ThreadExecuteViewpoint(vout_thread_t *vout,
vout_SetDisplayViewpoint(vout->p->display.vd, p_viewpoint);
}
+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);
@@ -1757,6 +1768,9 @@ static int ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
case VOUT_CONTROL_VIEWPOINT:
ThreadExecuteViewpoint(vout, &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 1c61629886..a0212aa3b8 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -207,6 +207,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 4e67d3d493..c600621ab5 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.
@@ -204,6 +206,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 );
@@ -529,6 +533,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 )
{
--
2.17.0
More information about the vlc-devel
mailing list