]> git.sesse.net Git - vlc/blob - include/vlc_vout.h
Moved vout_AllocatePicture out of vlc_vout.h
[vlc] / include / vlc_vout.h
1 /*****************************************************************************
2  * vlc_video.h: common video definitions
3  *****************************************************************************
4  * Copyright (C) 1999 - 2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Vincent Seguin <seguin@via.ecp.fr>
8  *          Samuel Hocevar <sam@via.ecp.fr>
9  *          Olivier Aubert <oaubert 47 videolan d07 org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifndef VLC_VOUT_H_
27 #define VLC_VOUT_H_ 1
28
29 /**
30  * \file
31  * This file defines common video output structures and functions in vlc
32  */
33
34 #include <vlc_picture.h>
35 #include <vlc_filter.h>
36 #include <vlc_subpicture.h>
37
38 /**
39  * Video picture heap, either render (to store pictures used
40  * by the decoder) or output (to store pictures displayed by the vout plugin)
41  */
42 struct picture_heap_t
43 {
44     int i_pictures;                                   /**< current heap size */
45
46     /* \name Picture static properties
47      * Those properties are fixed at initialization and should NOT be modified
48      * @{
49      */
50     unsigned int i_width;                                 /**< picture width */
51     unsigned int i_height;                               /**< picture height */
52     vlc_fourcc_t i_chroma;                               /**< picture chroma */
53     unsigned int i_aspect;                                 /**< aspect ratio */
54     /**@}*/
55
56     /* Real pictures */
57     picture_t*      pp_picture[VOUT_MAX_PICTURES];             /**< pictures */
58     int             i_last_used_pic;              /**< last used pic in heap */
59     bool            b_allow_modify_pics;
60
61     /* Stuff used for truecolor RGB planes */
62     uint32_t i_rmask; int i_rrshift, i_lrshift;
63     uint32_t i_gmask; int i_rgshift, i_lgshift;
64     uint32_t i_bmask; int i_rbshift, i_lbshift;
65 };
66
67 /*****************************************************************************
68  * Prototypes
69  *****************************************************************************/
70
71 /**
72  * \defgroup video_output Video Output
73  * This module describes the programming interface for video output threads.
74  * It includes functions allowing to open a new thread, send pictures to a
75  * thread, and destroy a previously opened video output thread.
76  * @{
77  */
78
79 /**
80  * Video ouput thread private structure
81  */
82 typedef struct vout_thread_sys_t vout_thread_sys_t;
83
84 /**
85  * Video output thread descriptor
86  *
87  * Any independent video output device, such as an X11 window or a GGI device,
88  * is represented by a video output thread, and described using the following
89  * structure.
90  */
91 struct vout_thread_t
92 {
93     VLC_COMMON_MEMBERS
94     bool                b_error;
95
96     /** \name Thread properties and locks */
97     /**@{*/
98     vlc_mutex_t         picture_lock;                 /**< picture heap lock */
99     vlc_mutex_t         change_lock;                 /**< thread change lock */
100     vout_sys_t *        p_sys;                     /**< system output method */
101     /**@}*/
102
103     /** \name Current display properties */
104     /**@{*/
105     uint16_t            i_changes;          /**< changes made to the thread.
106                                                       \see \ref vout_changes */
107     unsigned            b_fullscreen:1;       /**< toogle fullscreen display */
108     unsigned            b_autoscale:1;      /**< auto scaling picture or not */
109     unsigned            b_on_top:1; /**< stay always on top of other windows */
110     int                 i_zoom;               /**< scaling factor if no auto */
111     unsigned int        i_window_width;              /**< video window width */
112     unsigned int        i_window_height;            /**< video window height */
113     unsigned int        i_alignment;          /**< video alignment in window */
114
115     /**@}*/
116
117     /** \name Video heap and translation tables */
118     /**@{*/
119     int                 i_heap_size;                          /**< heap size */
120     picture_heap_t      render;                       /**< rendered pictures */
121     picture_heap_t      output;                          /**< direct buffers */
122
123     video_format_t      fmt_render;      /* render format (from the decoder) */
124     video_format_t      fmt_in;            /* input (modified render) format */
125     video_format_t      fmt_out;     /* output format (for the video output) */
126     /**@}*/
127
128     /* Picture heap */
129     picture_t           p_picture[2*VOUT_MAX_PICTURES+1];      /**< pictures */
130
131     /* Subpicture unit */
132     spu_t          *p_spu;
133
134     /* Video output configuration */
135     config_chain_t *p_cfg;
136
137     /* Private vout_thread data */
138     vout_thread_sys_t *p;
139 };
140
141 #define I_OUTPUTPICTURES p_vout->output.i_pictures
142 #define PP_OUTPUTPICTURE p_vout->output.pp_picture
143 #define I_RENDERPICTURES p_vout->render.i_pictures
144 #define PP_RENDERPICTURE p_vout->render.pp_picture
145
146 /** \defgroup vout_changes Flags for changes
147  * These flags are set in the vout_thread_t::i_changes field when another
148  * thread changed a variable
149  * @{
150  */
151 /** b_autoscale changed */
152 #define VOUT_SCALE_CHANGE       0x0008
153 /** b_on_top changed */
154 #define VOUT_ON_TOP_CHANGE      0x0010
155 /** b_fullscreen changed */
156 #define VOUT_FULLSCREEN_CHANGE  0x0040
157 /** i_zoom changed */
158 #define VOUT_ZOOM_CHANGE        0x0080
159 /** cropping parameters changed */
160 #define VOUT_CROP_CHANGE        0x1000
161 /** aspect ratio changed */
162 #define VOUT_ASPECT_CHANGE      0x2000
163 /** change/recreate picture buffers */
164 #define VOUT_PICTURE_BUFFERS_CHANGE 0x4000
165 /**@}*/
166
167 /* Alignment flags */
168 #define VOUT_ALIGN_LEFT         0x0001
169 #define VOUT_ALIGN_RIGHT        0x0002
170 #define VOUT_ALIGN_HMASK        0x0003
171 #define VOUT_ALIGN_TOP          0x0004
172 #define VOUT_ALIGN_BOTTOM       0x0008
173 #define VOUT_ALIGN_VMASK        0x000C
174
175 /* scaling factor (applied to i_zoom in vout_thread_t) */
176 #define ZOOM_FP_FACTOR          1000
177
178 /*****************************************************************************
179  * Prototypes
180  *****************************************************************************/
181
182 /**
183  * This function will
184  *  - returns a suitable vout (if requested by a non NULL p_fmt)
185  *  - recycles an old vout (if given) by either destroying it or by saving it
186  *  for latter usage.
187  *
188  * The purpose of this function is to avoid unnecessary creation/destruction of
189  * vout (and to allow optional vout reusing).
190  *
191  * You can call vout_Request on a vout created by vout_Create or by a previous
192  * call to vout_Request.
193  * You can release the returned value either by vout_Request or vout_Close()
194  * followed by a vlc_object_release() or shorter vout_CloseAndRelease()
195  *
196  * \param p_this a vlc object
197  * \param p_vout a vout candidate
198  * \param p_fmt the video format requested or NULL
199  * \return a vout if p_fmt is non NULL and the request is successfull, NULL
200  * otherwise
201  */
202 VLC_EXPORT( vout_thread_t *, vout_Request, ( vlc_object_t *p_this, vout_thread_t *p_vout, video_format_t *p_fmt ) );
203 #define vout_Request(a,b,c) vout_Request(VLC_OBJECT(a),b,c)
204
205 /**
206  * This function will create a suitable vout for a given p_fmt. It will never
207  * reuse an already existing unused vout.
208  *
209  * You have to call either vout_Close or vout_Request on the returned value
210  * \param p_this a vlc object to which the returned vout will be attached
211  * \param p_fmt the video format requested
212  * \return a vout if the request is successfull, NULL otherwise
213  */
214 VLC_EXPORT( vout_thread_t *, vout_Create, ( vlc_object_t *p_this, video_format_t *p_fmt ) );
215 #define vout_Create(a,b) vout_Create(VLC_OBJECT(a),b)
216
217 /**
218  * This function will close a vout created by vout_Create or vout_Request.
219  * The associated vout module is closed.
220  * Note: It is not released yet, you'll have to call vlc_object_release()
221  * or use the convenient vout_CloseAndRelease().
222  *
223  * \param p_vout the vout to close
224  */
225 VLC_EXPORT( void,            vout_Close,        ( vout_thread_t *p_vout ) );
226
227 /**
228  * This function will close a vout created by vout_Create
229  * and then release it.
230  *
231  * \param p_vout the vout to close and release
232  */
233 static inline void vout_CloseAndRelease( vout_thread_t *p_vout )
234 {
235     vout_Close( p_vout );
236     vlc_object_release( p_vout );
237 }
238
239 /**
240  * This function will handle a snapshot request.
241  *
242  * pp_image, pp_picture and p_fmt can be NULL otherwise they will be
243  * set with returned value in case of success.
244  *
245  * pp_image will hold an encoded picture in psz_format format.
246  *
247  * i_timeout specifies the time the function will wait for a snapshot to be
248  * available.
249  *
250  */
251 VLC_EXPORT( int, vout_GetSnapshot, ( vout_thread_t *p_vout,
252                                      block_t **pp_image, picture_t **pp_picture,
253                                      video_format_t *p_fmt,
254                                      const char *psz_format, mtime_t i_timeout ) );
255
256 /* */
257 VLC_EXPORT( picture_t *,     vout_CreatePicture,  ( vout_thread_t *, bool, bool, unsigned int ) );
258 VLC_EXPORT( void,            vout_DestroyPicture, ( vout_thread_t *, picture_t * ) );
259 VLC_EXPORT( void,            vout_DisplayPicture, ( vout_thread_t *, picture_t * ) );
260 VLC_EXPORT( void,            vout_LinkPicture,    ( vout_thread_t *, picture_t * ) );
261 VLC_EXPORT( void,            vout_UnlinkPicture,  ( vout_thread_t *, picture_t * ) );
262
263 /**
264  * Return the spu_t object associated to a vout_thread_t.
265  *
266  * The return object is valid only as long as the vout is. You must not
267  * release the spu_t object returned.
268  * It cannot return NULL so no need to check.
269  */
270 VLC_EXPORT( spu_t *, vout_GetSpu, ( vout_thread_t * ) );
271
272 VLC_EXPORT( void, vout_EnableFilter, ( vout_thread_t *, const char *,bool , bool  ) );
273
274 /**@}*/
275
276 #endif /* _VLC_VIDEO_H */