VLC  3.0.15
event.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * event.h: vout event
3  *****************************************************************************
4  * Copyright (C) 2009 Laurent Aimar
5  * $Id: ac40ef3405f3d16db46a6907d1bf3ccbaca4ac4a $
6  *
7  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #include <vlc_common.h>
25 #include <math.h>
26 
27 #include "vout_control.h"
28 
29 /* TODO/FIXME
30  *
31  * It should be converted to something like input_thread_t:
32  * one intf-event can be grabbed by a callback, all others
33  * variable only var_Change
34  *
35  * Maybe a intf-mouse can be used too (don't like it).
36  *
37  * (Some case may infinite loop otherwise here)
38  */
39 
40 static inline void vout_SendEventClose(vout_thread_t *vout)
41 {
42 #warning FIXME: implement video close event
43  /* FIXME: this code is disabled as it breaks the non-playlist cases */
44  //playlist_Stop(pl_Get(vout));
45  (void) vout;
46 }
47 static inline void vout_SendEventKey(vout_thread_t *vout, int key)
48 {
49  var_SetInteger(vout->obj.libvlc, "key-pressed", key);
50 }
51 static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y)
52 {
53  var_SetCoords(vout, "mouse-moved", x, y);
54 }
55 static inline void vout_SendEventViewpointMoved(vout_thread_t *vout,
56  const vlc_viewpoint_t *p_viewpoint)
57 {
58  var_SetAddress(vout, "viewpoint-moved", (void *) p_viewpoint);
59  /* This variable can only be read from callbacks */
60  var_Change(vout, "viewpoint-moved", VLC_VAR_SETVALUE,
61  &(vlc_value_t) { .p_address = NULL }, NULL);
62 }
63 static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button)
64 {
65  int key = KEY_UNSET;
66  var_OrInteger(vout, "mouse-button-down", 1 << button);
67 
68  switch (button)
69  {
70  case MOUSE_BUTTON_LEFT:
71  {
72  /* FIXME? */
73  int x, y;
74  var_GetCoords(vout, "mouse-moved", &x, &y);
75  var_SetCoords(vout, "mouse-clicked", x, y);
76  var_SetBool(vout->obj.libvlc, "intf-popupmenu", false);
77  return;
78  }
80  var_ToggleBool(vout->obj.libvlc, "intf-toggle-fscontrol");
81  return;
82  case MOUSE_BUTTON_RIGHT:
83 #if !defined(_WIN32)
84  var_SetBool(vout->obj.libvlc, "intf-popupmenu", true);
85 #endif
86  return;
87  case MOUSE_BUTTON_WHEEL_UP: key = KEY_MOUSEWHEELUP; break;
91  }
92  vout_SendEventKey(vout, key);
93 }
94 static inline void vout_SendEventMouseReleased(vout_thread_t *vout, int button)
95 {
96  var_NAndInteger(vout, "mouse-button-down", 1 << button);
97 #if defined(_WIN32)
98  switch (button)
99  {
100  case MOUSE_BUTTON_RIGHT:
101  var_SetBool(vout->obj.libvlc, "intf-popupmenu", true);
102  return;
103  }
104 #endif
105 }
106 static inline void vout_SendEventMouseDoubleClick(vout_thread_t *vout)
107 {
108  //vout_ControlSetFullscreen(vout, !var_GetBool(vout, "fullscreen"));
109  var_ToggleBool(vout, "fullscreen");
110 }
111 static inline void vout_SendEventViewpointChangeable(vout_thread_t *vout,
112  bool b_can_change)
113 {
114  var_SetBool(vout, "viewpoint-changeable", b_can_change);
115 }
116 
117 #if 0
118 static inline void vout_SendEventSnapshot(vout_thread_t *vout, const char *filename)
119 {
120  /* signal creation of a new snapshot file */
121  var_SetString(vout->obj.libvlc, "snapshot-file", filename);
122 }
123 
124 #warning "FIXME clean up postproc event"
125 
126 extern void vout_InstallDeprecatedPostProcessing(vout_thread_t *);
127 extern void vout_UninstallDeprecatedPostProcessing(vout_thread_t *);
128 
129 static inline void vout_SendEventPostProcessing(vout_thread_t *vout, bool is_available)
130 {
131  if (is_available)
132  vout_InstallDeprecatedPostProcessing(vout);
133  else
134  vout_UninstallDeprecatedPostProcessing(vout);
135 }
136 
137 static inline void vout_SendEventFilters(vout_thread_t *vout)
138 {
139  vout_filter_t **filter;
140  int filter_count;
141 
142  vout_ControlGetFilters(vout, &filter, &filter_count);
143 
144  char *list = strdup("");
145  for (int i = 0; i < filter_count; i++) {
146  char *psz;
147 
148  if (asprintf(&psz, "%s%s%s",
149  list, i > 0 ? ":" : "", filter[i]->name) < 0) {
150  free(list);
151  list = NULL;
152  break;
153  }
154  free(list);
155  list = psz;
156  }
157 
158  if (list) {
159  vlc_value_t val;
160  val.psz_string = list;
161  var_Change(vout, "video-filter", VLC_VAR_SETVALUE, &val, NULL);
162  free(list);
163  }
164 
165  for (int i = 0; i < filter_count; i++)
166  vout_filter_Delete(filter[i]);
167  free(filter);
168 }
169 #endif
vout_SendEventMouseMoved
static void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y)
Definition: event.h:50
VLC_VAR_SETVALUE
#define VLC_VAR_SETVALUE
Set the value of this variable without triggering any callbacks.
Definition: vlc_variables.h:87
var_OrInteger
#define var_OrInteger(a, b, c)
Definition: vlc_variables.h:404
var_SetAddress
#define var_SetAddress(o, n, p)
Definition: vlc_variables.h:260
var_SetBool
#define var_SetBool(a, b, c)
Definition: vlc_variables.h:257
vlc_common.h
vout_SendEventMouseDoubleClick
static void vout_SendEventMouseDoubleClick(vout_thread_t *vout)
Definition: event.h:105
KEY_UNSET
#define KEY_UNSET
Definition: vlc_actions.h:47
vout_SendEventViewpointChangeable
static void vout_SendEventViewpointChangeable(vout_thread_t *vout, bool b_can_change)
Definition: event.h:110
MOUSE_BUTTON_CENTER
Definition: vlc_mouse.h:53
vout_filter_t
Definition: video_output.c:719
vlc_common_members::libvlc
libvlc_int_t * libvlc
LibVLC instance.
Definition: vlc_common.h:441
var_ToggleBool
#define var_ToggleBool(a, b)
Definition: vlc_variables.h:589
var_SetCoords
#define var_SetCoords(o, n, x, y)
Definition: vlc_variables.h:211
vlc_viewpoint_t
Viewpoints.
Definition: vlc_viewpoint.h:44
asprintf
int asprintf(char **, const char *,...)
vout_SendEventMousePressed
static void vout_SendEventMousePressed(vout_thread_t *vout, int button)
Definition: event.h:62
vout_SendEventViewpointMoved
static void vout_SendEventViewpointMoved(vout_thread_t *vout, const vlc_viewpoint_t *p_viewpoint)
Definition: event.h:54
vout_SendEventMouseReleased
static void vout_SendEventMouseReleased(vout_thread_t *vout, int button)
Definition: event.h:93
vlc_value_t::psz_string
char * psz_string
Definition: vlc_common.h:330
var_SetInteger
#define var_SetInteger(a, b, c)
Definition: vlc_variables.h:256
MOUSE_BUTTON_WHEEL_LEFT
Definition: vlc_mouse.h:57
KEY_MOUSEWHEELLEFT
#define KEY_MOUSEWHEELLEFT
Definition: vlc_actions.h:114
KEY_MOUSEWHEELDOWN
#define KEY_MOUSEWHEELDOWN
Definition: vlc_actions.h:113
MOUSE_BUTTON_RIGHT
Definition: vlc_mouse.h:54
var_NAndInteger
#define var_NAndInteger(a, b, c)
Definition: vlc_variables.h:415
MOUSE_BUTTON_LEFT
Definition: vlc_mouse.h:52
strdup
char * strdup(const char *)
vout_thread_t::obj
struct vlc_common_members obj
Definition: vlc_vout.h:71
list
module_config_t ** list
Definition: core.c:460
name
const char name[16]
Definition: httpd.c:1249
MOUSE_BUTTON_WHEEL_RIGHT
Definition: vlc_mouse.h:58
vout_SendEventClose
static void vout_SendEventClose(vout_thread_t *vout)
Definition: event.h:39
var_SetString
#define var_SetString(a, b, c)
Definition: vlc_variables.h:259
KEY_MOUSEWHEELUP
#define KEY_MOUSEWHEELUP
Definition: vlc_actions.h:112
KEY_MOUSEWHEELRIGHT
#define KEY_MOUSEWHEELRIGHT
Definition: vlc_actions.h:115
vout_control.h
MOUSE_BUTTON_WHEEL_DOWN
Definition: vlc_mouse.h:56
vout_thread_t
Video output thread descriptor.
Definition: vlc_vout.h:70
MOUSE_BUTTON_WHEEL_UP
Definition: vlc_mouse.h:55
var_GetCoords
#define var_GetCoords(o, n, x, y)
Definition: vlc_variables.h:309
vlc_value_t
VLC value structure.
Definition: vlc_common.h:325
vout_SendEventKey
static void vout_SendEventKey(vout_thread_t *vout, int key)
Definition: event.h:46
var_Change
#define var_Change(a, b, c, d, e)
Definition: vlc_variables.h:127