00001 /***************************************************************************** 00002 * vlc_vout_display.h: vout_display_t definitions 00003 ***************************************************************************** 00004 * Copyright (C) 2009 Laurent Aimar 00005 * $Id: d99cf7eea9c1079754a3a47ea1df8ecd8e8d6163 $ 00006 * 00007 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org> 00008 * 00009 * This program is free software; you can redistribute it and/or modify it 00010 * under the terms of the GNU Lesser General Public License as published by 00011 * the Free Software Foundation; either version 2.1 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public License 00020 * along with this program; if not, write to the Free Software Foundation, 00021 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00022 *****************************************************************************/ 00023 00024 #ifndef VLC_VOUT_DISPLAY_H 00025 #define VLC_VOUT_DISPLAY_H 1 00026 00027 /** 00028 * \file 00029 * This file defines vout display structures and functions in vlc 00030 */ 00031 00032 #include <vlc_es.h> 00033 #include <vlc_picture.h> 00034 #include <vlc_picture_pool.h> 00035 #include <vlc_subpicture.h> 00036 #include <vlc_keys.h> 00037 #include <vlc_mouse.h> 00038 #include <vlc_vout_window.h> 00039 00040 /* XXX 00041 * Do NOT use video_format_t::i_aspect but i_sar_num/den everywhere. i_aspect 00042 * will be removed as soon as possible. 00043 * 00044 */ 00045 typedef struct vout_display_t vout_display_t; 00046 typedef struct vout_display_sys_t vout_display_sys_t; 00047 typedef struct vout_display_owner_t vout_display_owner_t; 00048 typedef struct vout_display_owner_sys_t vout_display_owner_sys_t; 00049 00050 /** 00051 * Possible alignments for vout_display. 00052 */ 00053 typedef enum 00054 { 00055 VOUT_DISPLAY_ALIGN_CENTER, 00056 /* */ 00057 VOUT_DISPLAY_ALIGN_LEFT, 00058 VOUT_DISPLAY_ALIGN_RIGHT, 00059 /* */ 00060 VOUT_DISPLAY_ALIGN_TOP, 00061 VOUT_DISPLAY_ALIGN_BOTTOM, 00062 } vout_display_align_t; 00063 00064 /** 00065 * Window management state. 00066 */ 00067 enum { 00068 VOUT_WINDOW_STATE_NORMAL=0, 00069 VOUT_WINDOW_STATE_ABOVE=1, 00070 VOUT_WINDOW_STATE_BELOW=2, 00071 VOUT_WINDOW_STACK_MASK=3, 00072 }; 00073 00074 /** 00075 * Initial/Current configuration for a vout_display_t 00076 */ 00077 typedef struct { 00078 bool is_fullscreen; /* Is the display fullscreen */ 00079 00080 /* Display properties */ 00081 struct { 00082 /* Window title (may be NULL) */ 00083 const char *title; 00084 00085 /* Display size */ 00086 unsigned width; 00087 unsigned height; 00088 00089 /* Display SAR */ 00090 struct { 00091 unsigned num; 00092 unsigned den; 00093 } sar; 00094 } display; 00095 00096 /* Alignment of the picture inside the display */ 00097 struct { 00098 int horizontal; 00099 int vertical; 00100 } align; 00101 00102 /* Do we fill up the display with the video */ 00103 bool is_display_filled; 00104 00105 /* Zoom to use 00106 * It will be applied to the whole display if b_display_filled is set, otherwise 00107 * only on the video source */ 00108 struct { 00109 int num; 00110 int den; 00111 } zoom; 00112 00113 } vout_display_cfg_t; 00114 00115 /** 00116 * Information from a vout_display_t to configure 00117 * the core behaviour. 00118 * 00119 * By default they are all false or NULL. 00120 * 00121 */ 00122 typedef struct { 00123 bool is_slow; /* The picture memory has slow read/write */ 00124 bool has_double_click; /* Is double-click generated */ 00125 bool has_hide_mouse; /* Is mouse automatically hidden */ 00126 bool has_pictures_invalid; /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */ 00127 bool has_event_thread; /* Will events (key at least) be emitted using an independent thread */ 00128 const vlc_fourcc_t *subpicture_chromas; /* List of supported chromas for subpicture rendering. */ 00129 } vout_display_info_t; 00130 00131 /** 00132 * Control query for vout_display_t 00133 */ 00134 enum { 00135 /* Hide the mouse. It will be sent when 00136 * vout_display_t::info.b_hide_mouse is false */ 00137 VOUT_DISPLAY_HIDE_MOUSE, 00138 00139 /* Ask to reset the internal buffers after a VOUT_DISPLAY_EVENT_PICTURES_INVALID 00140 * request. 00141 */ 00142 VOUT_DISPLAY_RESET_PICTURES, 00143 00144 /* Ask the module to acknowledge/refuse the fullscreen state change after 00145 * being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */ 00146 VOUT_DISPLAY_CHANGE_FULLSCREEN, /* const vout_display_cfg_t *p_cfg */ 00147 00148 /* Ask the module to acknowledge/refuse the window management state change 00149 * after being requested externally or by VOUT_DISPLAY_WINDOW_STATE */ 00150 VOUT_DISPLAY_CHANGE_WINDOW_STATE, /* unsigned state */ 00151 00152 /* Ask the module to acknowledge/refuse the display size change requested 00153 * (externally or by VOUT_DISPLAY_EVENT_DISPLAY_SIZE) */ 00154 VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, /* const vout_display_cfg_t *p_cfg, int is_forced */ 00155 00156 /* Ask the module to acknowledge/refuse fill display state change after 00157 * being requested externally */ 00158 VOUT_DISPLAY_CHANGE_DISPLAY_FILLED, /* const vout_display_cfg_t *p_cfg */ 00159 00160 /* Ask the module to acknowledge/refuse zoom change after being requested 00161 * externally */ 00162 VOUT_DISPLAY_CHANGE_ZOOM, /* const vout_display_cfg_t *p_cfg */ 00163 00164 /* Ask the module to acknowledge/refuse source aspect ratio after being 00165 * requested externally */ 00166 VOUT_DISPLAY_CHANGE_SOURCE_ASPECT, /* const video_format_t *p_source */ 00167 00168 /* Ask the module to acknowledge/refuse source crop change after being 00169 * requested externally. 00170 * The cropping requested is stored by video_format_t::i_x/y_offset and 00171 * video_format_t::i_visible_width/height */ 00172 VOUT_DISPLAY_CHANGE_SOURCE_CROP, /* const video_format_t *p_source */ 00173 00174 /* Ask an opengl interface if available. */ 00175 VOUT_DISPLAY_GET_OPENGL, /* vlc_gl_t ** */ 00176 }; 00177 00178 /** 00179 * Event from vout_display_t 00180 * 00181 * Events modifiying the state may be sent multiple times. 00182 * Only the transition will be retained and acted upon. 00183 */ 00184 enum { 00185 /* TODO: 00186 * ZOOM ? DISPLAY_FILLED ? ON_TOP ? 00187 */ 00188 /* */ 00189 VOUT_DISPLAY_EVENT_PICTURES_INVALID, /* The buffer are now invalid and need to be changed */ 00190 00191 VOUT_DISPLAY_EVENT_FULLSCREEN, 00192 VOUT_DISPLAY_EVENT_WINDOW_STATE, 00193 00194 VOUT_DISPLAY_EVENT_DISPLAY_SIZE, /* The display size need to change : int i_width, int i_height, bool is_fullscreen */ 00195 00196 /* */ 00197 VOUT_DISPLAY_EVENT_CLOSE, 00198 VOUT_DISPLAY_EVENT_KEY, 00199 00200 /* Full mouse state. 00201 * You can use it OR use the other mouse events. The core will do 00202 * the conversion. 00203 */ 00204 VOUT_DISPLAY_EVENT_MOUSE_STATE, 00205 00206 /* Mouse event */ 00207 VOUT_DISPLAY_EVENT_MOUSE_MOVED, 00208 VOUT_DISPLAY_EVENT_MOUSE_PRESSED, 00209 VOUT_DISPLAY_EVENT_MOUSE_RELEASED, 00210 VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK, 00211 }; 00212 00213 /** 00214 * Vout owner structures 00215 */ 00216 struct vout_display_owner_t { 00217 /* Private place holder for the vout_display_t creator 00218 */ 00219 vout_display_owner_sys_t *sys; 00220 00221 /* Event coming from the module 00222 * 00223 * This function is set prior to the module instantiation and must not 00224 * be overwritten nor used directly (use the vout_display_SendEvent* 00225 * wrapper. 00226 * 00227 * You can send it at any time i.e. from any vout_display_t functions or 00228 * from another thread. 00229 * Be careful, it does not ensure correct serialization if it is used 00230 * from multiple threads. 00231 */ 00232 void (*event)(vout_display_t *, int, va_list); 00233 00234 /* Window management 00235 * 00236 * These functions are set prior to the module instantiation and must not 00237 * be overwritten nor used directly (use the vout_display_*Window 00238 * wrapper */ 00239 vout_window_t *(*window_new)(vout_display_t *, const vout_window_cfg_t *); 00240 void (*window_del)(vout_display_t *, vout_window_t *); 00241 }; 00242 00243 struct vout_display_t { 00244 VLC_COMMON_MEMBERS 00245 00246 /* Module */ 00247 module_t *module; 00248 00249 /* Initial and current configuration. 00250 * You cannot modify it directly, you must use the appropriate events. 00251 * 00252 * It reflects the current values, i.e. after the event has been accepted 00253 * and applied/configured if needed. 00254 */ 00255 const vout_display_cfg_t *cfg; 00256 00257 /* video source format. 00258 * 00259 * Cropping is not requested while in the open function. 00260 * You cannot change it. 00261 */ 00262 video_format_t source; 00263 00264 /* picture_t format. 00265 * 00266 * You can only change it inside the module open function to 00267 * match what you want, and when a VOUT_DISPLAY_RESET_PICTURES control 00268 * request is made and succeeds. 00269 * 00270 * By default, it is equal to ::source except for the aspect ratio 00271 * which is undefined(0) and is ignored. 00272 */ 00273 video_format_t fmt; 00274 00275 /* Information 00276 * 00277 * You can only set them in the open function. 00278 */ 00279 vout_display_info_t info; 00280 00281 /* Return a pointer over the current picture_pool_t* (mandatory). 00282 * 00283 * For performance reasons, it is best to provide at least count 00284 * pictures but it is not mandatory. 00285 * You can return NULL when you cannot/do not want to allocate 00286 * pictures. 00287 * The vout display module keeps the ownership of the pool and can 00288 * destroy it only when closing or on invalid pictures control. 00289 */ 00290 picture_pool_t *(*pool)(vout_display_t *, unsigned count); 00291 00292 /* Prepare a picture and an optional subpicture for display (optional). 00293 * 00294 * It is called before the next pf_display call to provide as much 00295 * time as possible to prepare the given picture and the subpicture 00296 * for display. 00297 * You are guaranted that pf_display will always be called and using 00298 * the exact same picture_t and subpicture_t. 00299 * You cannot change the pixel content of the picture_t or of the 00300 * subpicture_t. 00301 */ 00302 void (*prepare)(vout_display_t *, picture_t *, subpicture_t *); 00303 00304 /* Display a picture and an optional subpicture (mandatory). 00305 * 00306 * The picture and the optional subpicture must be displayed as soon as 00307 * possible. 00308 * You cannot change the pixel content of the picture_t or of the 00309 * subpicture_t. 00310 * 00311 * This function gives away the ownership of the picture and of the 00312 * subpicture, so you must release them as soon as possible. 00313 */ 00314 void (*display)(vout_display_t *, picture_t *, subpicture_t *); 00315 00316 /* Control on the module (mandatory) */ 00317 int (*control)(vout_display_t *, int, va_list); 00318 00319 /* Manage pending event (optional) */ 00320 void (*manage)(vout_display_t *); 00321 00322 /* Private place holder for the vout_display_t module (optional) 00323 * 00324 * A module is free to use it as it wishes. 00325 */ 00326 vout_display_sys_t *sys; 00327 00328 /* Reserved for the vout_display_t owner. 00329 * 00330 * It must not be overwritten nor used directly by a module. 00331 */ 00332 vout_display_owner_t owner; 00333 }; 00334 00335 static inline void vout_display_SendEvent(vout_display_t *vd, int query, ...) 00336 { 00337 va_list args; 00338 va_start(args, query); 00339 vd->owner.event(vd, query, args); 00340 va_end(args); 00341 } 00342 00343 static inline void vout_display_SendEventDisplaySize(vout_display_t *vd, int width, int height, bool is_fullscreen) 00344 { 00345 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_DISPLAY_SIZE, width, height, is_fullscreen); 00346 } 00347 static inline void vout_display_SendEventPicturesInvalid(vout_display_t *vd) 00348 { 00349 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_PICTURES_INVALID); 00350 } 00351 static inline void vout_display_SendEventClose(vout_display_t *vd) 00352 { 00353 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_CLOSE); 00354 } 00355 static inline void vout_display_SendEventKey(vout_display_t *vd, int key) 00356 { 00357 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_KEY, key); 00358 } 00359 static inline void vout_display_SendEventFullscreen(vout_display_t *vd, bool is_fullscreen) 00360 { 00361 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_FULLSCREEN, is_fullscreen); 00362 } 00363 static inline void vout_display_SendWindowState(vout_display_t *vd, unsigned state) 00364 { 00365 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_WINDOW_STATE, state); 00366 } 00367 /* The mouse position (State and Moved event) must be expressed against vout_display_t::source unit */ 00368 static inline void vout_display_SendEventMouseState(vout_display_t *vd, int x, int y, int button_mask) 00369 { 00370 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_STATE, x, y, button_mask); 00371 } 00372 static inline void vout_display_SendEventMouseMoved(vout_display_t *vd, int x, int y) 00373 { 00374 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_MOVED, x, y); 00375 } 00376 static inline void vout_display_SendEventMousePressed(vout_display_t *vd, int button) 00377 { 00378 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_PRESSED, button); 00379 } 00380 static inline void vout_display_SendEventMouseReleased(vout_display_t *vd, int button) 00381 { 00382 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_RELEASED, button); 00383 } 00384 static inline void vout_display_SendEventMouseDoubleClick(vout_display_t *vd) 00385 { 00386 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK); 00387 } 00388 00389 /** 00390 * Asks for a new window with the given configuration as hint. 00391 * 00392 * b_standalone/i_x/i_y may be overwritten by the core 00393 */ 00394 static inline vout_window_t *vout_display_NewWindow(vout_display_t *vd, const vout_window_cfg_t *cfg) 00395 { 00396 return vd->owner.window_new(vd, cfg); 00397 } 00398 /** 00399 * Deletes a window created by vout_display_NewWindow if window is non NULL 00400 * or any unused windows otherwise. 00401 */ 00402 static inline void vout_display_DeleteWindow(vout_display_t *vd, 00403 vout_window_t *window) 00404 { 00405 vd->owner.window_del(vd, window); 00406 } 00407 00408 /** 00409 * Computes the default display size given the source and 00410 * the display configuration. 00411 * 00412 * This asssumes that the picture is already cropped. 00413 */ 00414 VLC_API void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height, const video_format_t *source, const vout_display_cfg_t *); 00415 00416 00417 /** 00418 * Structure used to store the result of a vout_display_PlacePicture. 00419 */ 00420 typedef struct { 00421 int x; 00422 int y; 00423 unsigned width; 00424 unsigned height; 00425 } vout_display_place_t; 00426 00427 /** 00428 * Computes how to place a picture inside the display to respect 00429 * the given parameters. 00430 * This assumes that cropping is done by an external mean. 00431 * 00432 * \param p_place Place inside the window (window pixel unit) 00433 * \param p_source Video source format 00434 * \param p_cfg Display configuration 00435 * \param b_clip If true, prevent the video to go outside the display (break zoom). 00436 */ 00437 VLC_API void vout_display_PlacePicture(vout_display_place_t *place, const video_format_t *source, const vout_display_cfg_t *cfg, bool do_clipping); 00438 00439 #endif /* VLC_VOUT_DISPLAY_H */ 00440
1.7.1