]> git.sesse.net Git - vlc/blob - include/vlc_vout.h
Removed picture_heap_t rgb informations.
[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 };
60
61 /*****************************************************************************
62  * Prototypes
63  *****************************************************************************/
64
65 /**
66  * \defgroup video_output Video Output
67  * This module describes the programming interface for video output threads.
68  * It includes functions allowing to open a new thread, send pictures to a
69  * thread, and destroy a previously opened video output thread.
70  * @{
71  */
72
73 /**
74  * Video ouput thread private structure
75  */
76 typedef struct vout_thread_sys_t vout_thread_sys_t;
77
78 /**
79  * Video output thread descriptor
80  *
81  * Any independent video output device, such as an X11 window or a GGI device,
82  * is represented by a video output thread, and described using the following
83  * structure.
84  */
85 struct vout_thread_t
86 {
87     VLC_COMMON_MEMBERS
88
89     /** \name Thread properties and locks */
90     /**@{*/
91     vlc_mutex_t         picture_lock;                 /**< picture heap lock */
92     vlc_mutex_t         change_lock;                 /**< thread change lock */
93     /**@}*/
94
95     /** \name Current display properties */
96     /**@{*/
97     uint16_t            i_changes;          /**< changes made to the thread.
98                                                       \see \ref vout_changes */
99     unsigned            b_fullscreen:1;       /**< toogle fullscreen display */
100     unsigned            b_on_top:1; /**< stay always on top of other windows */
101
102     /**@}*/
103
104     /** \name Video heap and translation tables */
105     /**@{*/
106     picture_heap_t      render;                       /**< rendered pictures */
107     picture_heap_t      output;                          /**< direct buffers */
108
109     video_format_t      fmt_render;      /* render format (from the decoder) */
110     video_format_t      fmt_in;            /* input (modified render) format */
111     video_format_t      fmt_out;     /* output format (for the video output) */
112     /**@}*/
113
114     /* Picture heap */
115     picture_t           p_picture[2*VOUT_MAX_PICTURES+1];      /**< pictures */
116
117     /* Private vout_thread data */
118     vout_thread_sys_t *p;
119 };
120
121 #define I_OUTPUTPICTURES p_vout->output.i_pictures
122 #define PP_OUTPUTPICTURE p_vout->output.pp_picture
123 #define I_RENDERPICTURES p_vout->render.i_pictures
124 #define PP_RENDERPICTURE p_vout->render.pp_picture
125
126 /** \defgroup vout_changes Flags for changes
127  * These flags are set in the vout_thread_t::i_changes field when another
128  * thread changed a variable
129  * @{
130  */
131 /** b_autoscale changed */
132 #define VOUT_SCALE_CHANGE       0x0008
133 /** b_on_top changed */
134 #define VOUT_ON_TOP_CHANGE      0x0010
135 /** b_fullscreen changed */
136 #define VOUT_FULLSCREEN_CHANGE  0x0040
137 /** i_zoom changed */
138 #define VOUT_ZOOM_CHANGE        0x0080
139 /** cropping parameters changed */
140 #define VOUT_CROP_CHANGE        0x1000
141 /** aspect ratio changed */
142 #define VOUT_ASPECT_CHANGE      0x2000
143 /** change/recreate picture buffers */
144 #define VOUT_PICTURE_BUFFERS_CHANGE 0x4000
145 /**@}*/
146
147 /* Alignment flags */
148 #define VOUT_ALIGN_LEFT         0x0001
149 #define VOUT_ALIGN_RIGHT        0x0002
150 #define VOUT_ALIGN_HMASK        0x0003
151 #define VOUT_ALIGN_TOP          0x0004
152 #define VOUT_ALIGN_BOTTOM       0x0008
153 #define VOUT_ALIGN_VMASK        0x000C
154
155 /* scaling factor (applied to i_zoom in vout_thread_t) */
156 #define ZOOM_FP_FACTOR          1000
157
158 /*****************************************************************************
159  * Prototypes
160  *****************************************************************************/
161
162 /**
163  * This function will
164  *  - returns a suitable vout (if requested by a non NULL p_fmt)
165  *  - recycles an old vout (if given) by either destroying it or by saving it
166  *  for latter usage.
167  *
168  * The purpose of this function is to avoid unnecessary creation/destruction of
169  * vout (and to allow optional vout reusing).
170  *
171  * You can call vout_Request on a vout created by vout_Create or by a previous
172  * call to vout_Request.
173  * You can release the returned value either by vout_Request or vout_Close()
174  * followed by a vlc_object_release() or shorter vout_CloseAndRelease()
175  *
176  * \param p_this a vlc object
177  * \param p_vout a vout candidate
178  * \param p_fmt the video format requested or NULL
179  * \return a vout if p_fmt is non NULL and the request is successfull, NULL
180  * otherwise
181  */
182 VLC_EXPORT( vout_thread_t *, vout_Request, ( vlc_object_t *p_this, vout_thread_t *p_vout, video_format_t *p_fmt ) );
183 #define vout_Request(a,b,c) vout_Request(VLC_OBJECT(a),b,c)
184
185 /**
186  * This function will create a suitable vout for a given p_fmt. It will never
187  * reuse an already existing unused vout.
188  *
189  * You have to call either vout_Close or vout_Request on the returned value
190  * \param p_this a vlc object to which the returned vout will be attached
191  * \param p_fmt the video format requested
192  * \return a vout if the request is successfull, NULL otherwise
193  */
194 VLC_EXPORT( vout_thread_t *, vout_Create, ( vlc_object_t *p_this, video_format_t *p_fmt ) );
195 #define vout_Create(a,b) vout_Create(VLC_OBJECT(a),b)
196
197 /**
198  * This function will close a vout created by vout_Create or vout_Request.
199  * The associated vout module is closed.
200  * Note: It is not released yet, you'll have to call vlc_object_release()
201  * or use the convenient vout_CloseAndRelease().
202  *
203  * \param p_vout the vout to close
204  */
205 VLC_EXPORT( void,            vout_Close,        ( vout_thread_t *p_vout ) );
206
207 /**
208  * This function will close a vout created by vout_Create
209  * and then release it.
210  *
211  * \param p_vout the vout to close and release
212  */
213 static inline void vout_CloseAndRelease( vout_thread_t *p_vout )
214 {
215     vout_Close( p_vout );
216     vlc_object_release( p_vout );
217 }
218
219 /**
220  * This function will handle a snapshot request.
221  *
222  * pp_image, pp_picture and p_fmt can be NULL otherwise they will be
223  * set with returned value in case of success.
224  *
225  * pp_image will hold an encoded picture in psz_format format.
226  *
227  * i_timeout specifies the time the function will wait for a snapshot to be
228  * available.
229  *
230  */
231 VLC_EXPORT( int, vout_GetSnapshot, ( vout_thread_t *p_vout,
232                                      block_t **pp_image, picture_t **pp_picture,
233                                      video_format_t *p_fmt,
234                                      const char *psz_format, mtime_t i_timeout ) );
235
236 /* */
237 VLC_EXPORT( picture_t *,     vout_CreatePicture,  ( vout_thread_t *, bool, bool, unsigned int ) );
238 VLC_EXPORT( void,            vout_DestroyPicture, ( vout_thread_t *, picture_t * ) );
239 VLC_EXPORT( void,            vout_DisplayPicture, ( vout_thread_t *, picture_t * ) );
240 VLC_EXPORT( void,            vout_LinkPicture,    ( vout_thread_t *, picture_t * ) );
241 VLC_EXPORT( void,            vout_UnlinkPicture,  ( vout_thread_t *, picture_t * ) );
242
243 /**
244  * Return the spu_t object associated to a vout_thread_t.
245  *
246  * The return object is valid only as long as the vout is. You must not
247  * release the spu_t object returned.
248  * It cannot return NULL so no need to check.
249  */
250 VLC_EXPORT( spu_t *, vout_GetSpu, ( vout_thread_t * ) );
251
252 VLC_EXPORT( void, vout_EnableFilter, ( vout_thread_t *, const char *,bool , bool  ) );
253
254 /**@}*/
255
256 #endif /* _VLC_VIDEO_H */