Commit bfcaf24f authored by Gildas Bazin's avatar Gildas Bazin

* src/video_output/vout_intf.c: vout_IntfInit() for some interface/control related initializations.

* src/video_output/video_output.c: moved some stuff to vout_IntfInit().
* include/video_output.h: vout_vaControl()/vout_Control() prototypes.
* modules/video_output/x11/xcommon.c: implemented a vout_Control() (only VOUT_SET_ZOOM for now).
* modules/gui/wxwindows/menus.cpp: handle float object vars, added "zoom" to the menus.
parent 73d587a5
...@@ -99,6 +99,7 @@ struct vout_thread_t ...@@ -99,6 +99,7 @@ struct vout_thread_t
int ( *pf_manage ) ( vout_thread_t * ); int ( *pf_manage ) ( vout_thread_t * );
void ( *pf_render ) ( vout_thread_t *, picture_t * ); void ( *pf_render ) ( vout_thread_t *, picture_t * );
void ( *pf_display ) ( vout_thread_t *, picture_t * ); void ( *pf_display ) ( vout_thread_t *, picture_t * );
int ( *pf_control ) ( vout_thread_t *, int, va_list );
/**@}*/ /**@}*/
/** \name Statistics /** \name Statistics
...@@ -218,6 +219,32 @@ picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *, ...@@ -218,6 +219,32 @@ picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *,
VLC_EXPORT( void *, vout_RequestWindow, ( vout_thread_t *, int *, int *, unsigned int *, unsigned int * ) ); VLC_EXPORT( void *, vout_RequestWindow, ( vout_thread_t *, int *, int *, unsigned int *, unsigned int * ) );
VLC_EXPORT( void, vout_ReleaseWindow, ( vout_thread_t *, void * ) ); VLC_EXPORT( void, vout_ReleaseWindow, ( vout_thread_t *, void * ) );
static inline int vout_vaControl( vout_thread_t *p_vout, int i_query,
va_list args )
{
if( p_vout->pf_control )
return p_vout->pf_control( p_vout, i_query, args );
else
return VLC_EGENERIC;
}
static inline int vout_Control( vout_thread_t *p_vout, int i_query, ... )
{
va_list args;
int i_result;
va_start( args, i_query );
i_result = vout_vaControl( p_vout, i_query, args );
va_end( args );
return i_result;
}
enum output_query_e
{
VOUT_SET_ZOOM, /* arg1= double * res= */
VOUT_REPARENT
};
/** /**
* \addtogroup subpicture * \addtogroup subpicture
* @{ * @{
......
...@@ -139,6 +139,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, ...@@ -139,6 +139,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
ppsz_varnames[i] = "fullscreen"; ppsz_varnames[i] = "fullscreen";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "zoom";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "deinterlace"; ppsz_varnames[i] = "deinterlace";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "aspect-ratio"; ppsz_varnames[i] = "aspect-ratio";
...@@ -297,6 +299,8 @@ wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent ) ...@@ -297,6 +299,8 @@ wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent )
ppsz_varnames[i] = "fullscreen"; ppsz_varnames[i] = "fullscreen";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "zoom";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "deinterlace"; ppsz_varnames[i] = "deinterlace";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "aspect-ratio"; ppsz_varnames[i] = "aspect-ratio";
...@@ -523,6 +527,7 @@ void Menu::CreateMenuItem( wxMenu *menu, char *psz_var, ...@@ -523,6 +527,7 @@ void Menu::CreateMenuItem( wxMenu *menu, char *psz_var,
case VLC_VAR_VARIABLE: case VLC_VAR_VARIABLE:
case VLC_VAR_STRING: case VLC_VAR_STRING:
case VLC_VAR_INTEGER: case VLC_VAR_INTEGER:
case VLC_VAR_FLOAT:
break; break;
default: default:
/* Variable doesn't exist or isn't handled */ /* Variable doesn't exist or isn't handled */
...@@ -594,6 +599,7 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object, ...@@ -594,6 +599,7 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
case VLC_VAR_VARIABLE: case VLC_VAR_VARIABLE:
case VLC_VAR_STRING: case VLC_VAR_STRING:
case VLC_VAR_INTEGER: case VLC_VAR_INTEGER:
case VLC_VAR_FLOAT:
break; break;
default: default:
/* Variable doesn't exist or isn't handled */ /* Variable doesn't exist or isn't handled */
...@@ -672,6 +678,29 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object, ...@@ -672,6 +678,29 @@ wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
menu->Check( i_item_id, TRUE ); menu->Check( i_item_id, TRUE );
break; break;
case VLC_VAR_FLOAT:
var_Get( p_object, psz_var, &val );
menuitem =
new wxMenuItemExt( menu, ++i_item_id,
text_list.p_list->p_values[i].psz_string ?
(wxString)wxU(
text_list.p_list->p_values[i].psz_string) :
wxString::Format(wxT("%.2f"),
val_list.p_list->p_values[i].f_float),wxT(""),
i_type & VLC_VAR_ISCOMMAND ?
wxITEM_NORMAL : wxITEM_RADIO,
strdup(psz_var),
p_object->i_object_id,
val_list.p_list->p_values[i], i_type );
menu->Append( menuitem );
if( !(i_type & VLC_VAR_ISCOMMAND) &&
val_list.p_list->p_values[i].f_float == val.f_float )
menu->Check( i_item_id, TRUE );
break;
default: default:
break; break;
} }
......
...@@ -83,6 +83,7 @@ static int InitVideo ( vout_thread_t * ); ...@@ -83,6 +83,7 @@ static int InitVideo ( vout_thread_t * );
static void EndVideo ( vout_thread_t * ); static void EndVideo ( vout_thread_t * );
static void DisplayVideo ( vout_thread_t *, picture_t * ); static void DisplayVideo ( vout_thread_t *, picture_t * );
static int ManageVideo ( vout_thread_t * ); static int ManageVideo ( vout_thread_t * );
static int Control ( vout_thread_t *, int, va_list );
static int InitDisplay ( vout_thread_t * ); static int InitDisplay ( vout_thread_t * );
...@@ -149,6 +150,7 @@ int E_(Activate) ( vlc_object_t *p_this ) ...@@ -149,6 +150,7 @@ int E_(Activate) ( vlc_object_t *p_this )
p_vout->pf_manage = ManageVideo; p_vout->pf_manage = ManageVideo;
p_vout->pf_render = NULL; p_vout->pf_render = NULL;
p_vout->pf_display = DisplayVideo; p_vout->pf_display = DisplayVideo;
p_vout->pf_control = Control;
/* Allocate structure */ /* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
...@@ -2113,6 +2115,32 @@ static void SetPalette( vout_thread_t *p_vout, ...@@ -2113,6 +2115,32 @@ static void SetPalette( vout_thread_t *p_vout,
} }
#endif #endif
/*****************************************************************************
* Control: control facility for the vout
*****************************************************************************/
static int Control( vout_thread_t *p_vout, int i_query, va_list args )
{
double f_arg;
switch( i_query )
{
case VOUT_SET_ZOOM:
f_arg = va_arg( args, double );
/* Update dimensions */
XResizeWindow( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->base_window,
p_vout->render.i_width * f_arg,
p_vout->render.i_height * f_arg );
return VLC_SUCCESS;
default:
msg_Dbg( p_vout, "control query not supported" );
return VLC_EGENERIC;
}
}
/***************************************************************************** /*****************************************************************************
* TestNetWMSupport: tests for Extended Window Manager Hints support * TestNetWMSupport: tests for Extended Window Manager Hints support
*****************************************************************************/ *****************************************************************************/
......
...@@ -57,6 +57,8 @@ static int BinaryLog ( uint32_t ); ...@@ -57,6 +57,8 @@ static int BinaryLog ( uint32_t );
static void MaskToShift ( int *, int *, uint32_t ); static void MaskToShift ( int *, int *, uint32_t );
static void InitWindowSize ( vout_thread_t *, int *, int * ); static void InitWindowSize ( vout_thread_t *, int *, int * );
void vout_IntfInit( vout_thread_t * );
/* Object variables callbacks */ /* Object variables callbacks */
static int FullscreenCallback( vlc_object_t *, char const *, static int FullscreenCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
...@@ -290,6 +292,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, ...@@ -290,6 +292,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
p_vout->render_time = 10; p_vout->render_time = 10;
p_vout->c_fps_samples = 0; p_vout->c_fps_samples = 0;
p_vout->b_filter_change = 0; p_vout->b_filter_change = 0;
p_vout->pf_control = 0;
/* Mouse coordinates */ /* Mouse coordinates */
var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER );
...@@ -310,14 +313,8 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, ...@@ -310,14 +313,8 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
/* Attach the new object now so we can use var inheritance below */ /* Attach the new object now so we can use var inheritance below */
vlc_object_attach( p_vout, p_parent ); vlc_object_attach( p_vout, p_parent );
/* Create a few object variables we'll need later on */ /* Take care of some "interface/control" related initialisations */
var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); vout_IntfInit( p_vout );
var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
p_vout->b_override_aspect = VLC_FALSE; p_vout->b_override_aspect = VLC_FALSE;
......
...@@ -36,6 +36,10 @@ ...@@ -36,6 +36,10 @@
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
/* Object variables callbacks */
static int ZoomCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/***************************************************************************** /*****************************************************************************
* vout_RequestWindow: Create/Get a video window if possible. * vout_RequestWindow: Create/Get a video window if possible.
***************************************************************************** *****************************************************************************
...@@ -100,3 +104,58 @@ void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window ) ...@@ -100,3 +104,58 @@ void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window )
p_intf->pf_release_window( p_intf, p_window ); p_intf->pf_release_window( p_intf, p_window );
vlc_object_release( p_intf ); vlc_object_release( p_intf );
} }
/*****************************************************************************
* vout_IntfInit: called during the vout creation to initialise misc things.
*****************************************************************************/
void vout_IntfInit( vout_thread_t *p_vout )
{
vlc_value_t val, text, old_val;
/* Create a few object variables we'll need later on */
var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_ISCOMMAND |
VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT );
text.psz_string = _("Zoom");
var_Change( p_vout, "zoom", VLC_VAR_SETTEXT, &text, NULL );
var_Get( p_vout, "zoom", &old_val );
if( old_val.f_float == 0.25 ||
old_val.f_float == 0.5 ||
old_val.f_float == 1 ||
old_val.f_float == 2 )
{
var_Change( p_vout, "zoom", VLC_VAR_DELCHOICE, &old_val, NULL );
}
val.f_float = 0.25; text.psz_string = _("1:4 Quater");
var_Change( p_vout, "zoom", VLC_VAR_ADDCHOICE, &val, &text );
val.f_float = 0.5; text.psz_string = _("1:2 Half");
var_Change( p_vout, "zoom", VLC_VAR_ADDCHOICE, &val, &text );
val.f_float = 1; text.psz_string = _("1:1 Original");
var_Change( p_vout, "zoom", VLC_VAR_ADDCHOICE, &val, &text );
val.f_float = 2; text.psz_string = _("2:1 Double");
var_Change( p_vout, "zoom", VLC_VAR_ADDCHOICE, &val, &text );
var_Set( p_vout, "zoom", old_val );
var_AddCallback( p_vout, "zoom", ZoomCallback, NULL );
}
/*****************************************************************************
* Object variables callbacks
*****************************************************************************/
static int ZoomCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
vout_Control( p_vout, VOUT_SET_ZOOM, newval.f_float );
return VLC_SUCCESS;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment