QVisu
Qt-based visualization for smart homes
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vlc_filter.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_filter.h: filter related structures and functions
3  *****************************************************************************
4  * Copyright (C) 1999-2008 VLC authors and VideoLAN
5  * $Id: 320cbac3a4a5b8461ec41eabd77f323bbbc509dd $
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  * Antoine Cellerier <dionoea at videolan dot org>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24 
25 #ifndef VLC_FILTER_H
26 #define VLC_FILTER_H 1
27 
28 #include <vlc_es.h>
29 #include <vlc_picture.h>
30 #include <vlc_subpicture.h>
31 #include <vlc_mouse.h>
32 
38 typedef struct filter_owner_sys_t filter_owner_sys_t;
39 
45 struct filter_t
46 {
47  VLC_COMMON_MEMBERS
48 
49  /* Module properties */
50  module_t * p_module;
51  filter_sys_t * p_sys;
52 
53  /* Input format */
54  es_format_t fmt_in;
55 
56  /* Output format of filter */
57  es_format_t fmt_out;
58  bool b_allow_fmt_out_change;
59 
60  /* Filter configuration */
61  config_chain_t * p_cfg;
62 
63  union
64  {
65  struct
66  {
67  picture_t * (*pf_filter) ( filter_t *, picture_t * );
68  void (*pf_flush)( filter_t * );
69  picture_t * (*pf_buffer_new) ( filter_t * );
70  void (*pf_buffer_del) ( filter_t *, picture_t * );
71  /* Filter mouse state.
72  *
73  * If non-NULL, you must convert from output to input formats:
74  * - If VLC_SUCCESS is returned, the mouse state is propagated.
75  * - Otherwise, the mouse change is not propagated.
76  * If NULL, the mouse state is considered unchanged and will be
77  * propagated.
78  */
79  int (*pf_mouse)( filter_t *, vlc_mouse_t *,
80  const vlc_mouse_t *p_old,
81  const vlc_mouse_t *p_new );
82  } video;
83 #define pf_video_filter u.video.pf_filter
84 #define pf_video_flush u.video.pf_flush
85 #define pf_video_mouse u.video.pf_mouse
86 #define pf_video_buffer_new u.video.pf_buffer_new
87 #define pf_video_buffer_del u.video.pf_buffer_del
88 
89  struct
90  {
91  block_t * (*pf_filter) ( filter_t *, block_t * );
92  } audio;
93 #define pf_audio_filter u.audio.pf_filter
94 
95  struct
96  {
97  void (*pf_blend) ( filter_t *, picture_t *,
98  const picture_t *, int, int, int );
99  } blend;
100 #define pf_video_blend u.blend.pf_blend
101 
102  struct
103  {
104  subpicture_t * (*pf_source) ( filter_t *, mtime_t );
105  subpicture_t * (*pf_buffer_new)( filter_t * );
106  void (*pf_buffer_del)( filter_t *, subpicture_t * );
107  int (*pf_mouse) ( filter_t *,
108  const vlc_mouse_t *p_old,
109  const vlc_mouse_t *p_new,
110  const video_format_t * );
111  } sub;
112 #define pf_sub_source u.sub.pf_source
113 #define pf_sub_buffer_new u.sub.pf_buffer_new
114 #define pf_sub_buffer_del u.sub.pf_buffer_del
115 #define pf_sub_mouse u.sub.pf_mouse
116 
117  struct
118  {
119  subpicture_t * (*pf_filter) ( filter_t *, subpicture_t * );
120  } subf;
121 #define pf_sub_filter u.subf.pf_filter
122 
123  struct
124  {
125  int (*pf_text) ( filter_t *, subpicture_region_t *,
126  subpicture_region_t *,
127  const vlc_fourcc_t * );
128  int (*pf_html) ( filter_t *, subpicture_region_t *,
129  subpicture_region_t *,
130  const vlc_fourcc_t * );
131  } render;
132 #define pf_render_text u.render.pf_text
133 #define pf_render_html u.render.pf_html
134 
135  } u;
136 
137  /* Input attachments
138  * XXX use filter_GetInputAttachments */
139  int (*pf_get_attachments)( filter_t *, input_attachment_t ***, int * );
140 
141  /* Private structure for the owner of the decoder */
142  filter_owner_sys_t *p_owner;
143 };
144 
154 static inline picture_t *filter_NewPicture( filter_t *p_filter )
155 {
156  picture_t *p_picture = p_filter->pf_video_buffer_new( p_filter );
157  if( !p_picture )
158  msg_Warn( p_filter, "can't get output picture" );
159  return p_picture;
160 }
161 
169 static inline void filter_DeletePicture( filter_t *p_filter, picture_t *p_picture )
170 {
171  p_filter->pf_video_buffer_del( p_filter, p_picture );
172 }
173 
177 static inline void filter_FlushPictures( filter_t *p_filter )
178 {
179  if( p_filter->pf_video_flush )
180  p_filter->pf_video_flush( p_filter );
181 }
182 
192 static inline subpicture_t *filter_NewSubpicture( filter_t *p_filter )
193 {
194  subpicture_t *p_subpicture = p_filter->pf_sub_buffer_new( p_filter );
195  if( !p_subpicture )
196  msg_Warn( p_filter, "can't get output subpicture" );
197  return p_subpicture;
198 }
199 
207 static inline void filter_DeleteSubpicture( filter_t *p_filter, subpicture_t *p_subpicture )
208 {
209  p_filter->pf_sub_buffer_del( p_filter, p_subpicture );
210 }
211 
217 static inline int filter_GetInputAttachments( filter_t *p_filter,
218  input_attachment_t ***ppp_attachment,
219  int *pi_attachment )
220 {
221  if( !p_filter->pf_get_attachments )
222  return VLC_EGENERIC;
223  return p_filter->pf_get_attachments( p_filter,
224  ppp_attachment, pi_attachment );
225 }
226 
233 VLC_API filter_t * filter_NewBlend( vlc_object_t *, const video_format_t *p_dst_chroma ) VLC_USED;
234 
239 VLC_API int filter_ConfigureBlend( filter_t *, int i_dst_width, int i_dst_height, const video_format_t *p_src );
240 
246 VLC_API int filter_Blend( filter_t *, picture_t *p_dst, int i_dst_x, int i_dst_y, const picture_t *p_src, int i_alpha );
247 
251 VLC_API void filter_DeleteBlend( filter_t * );
252 
259 #define VIDEO_FILTER_WRAPPER( name ) \
260  static picture_t *name ## _Filter ( filter_t *p_filter, \
261  picture_t *p_pic ) \
262  { \
263  picture_t *p_outpic = filter_NewPicture( p_filter ); \
264  if( p_outpic ) \
265  { \
266  name( p_filter, p_pic, p_outpic ); \
267  picture_CopyProperties( p_outpic, p_pic ); \
268  } \
269  picture_Release( p_pic ); \
270  return p_outpic; \
271  }
272 
280 
292 VLC_API filter_chain_t * filter_chain_New( vlc_object_t *, const char *, bool, int (*)( filter_t *, void * ), void (*)( filter_t * ), void * ) VLC_USED;
293 #define filter_chain_New( a, b, c, d, e, f ) filter_chain_New( VLC_OBJECT( a ), b, c, d, e, f )
294 
301 VLC_API void filter_chain_Delete( filter_chain_t * );
302 
311 VLC_API void filter_chain_Reset( filter_chain_t *, const es_format_t *, const es_format_t * );
312 
323 VLC_API filter_t * filter_chain_AppendFilter( filter_chain_t *, const char *, config_chain_t *, const es_format_t *, const es_format_t * );
324 
332 VLC_API int filter_chain_AppendFromString( filter_chain_t *, const char * );
333 
344 
351 VLC_API int filter_chain_GetLength( filter_chain_t * );
352 
360 
369 
373 VLC_API void filter_chain_VideoFlush( filter_chain_t * );
374 
383 
391 
400 
410 
416 VLC_API int filter_chain_MouseEvent( filter_chain_t *, const vlc_mouse_t *, const video_format_t * );
417 
418 #endif /* _VLC_FILTER_H */
419 
Definition: vlc_input.h:152
VLC_API const es_format_t * filter_chain_GetFmtOut(filter_chain_t *)
VLC_API int filter_ConfigureBlend(filter_t *, int i_dst_width, int i_dst_height, const video_format_t *p_src)
Definition: vlc_picture.h:69
VLC_API int filter_chain_AppendFromString(filter_chain_t *, const char *)
Definition: vlc_subpicture.h:57
Definition: vlc_subpicture.h:136
VLC_API int filter_Blend(filter_t *, picture_t *p_dst, int i_dst_x, int i_dst_y, const picture_t *p_src, int i_alpha)
VLC_API void filter_chain_VideoFlush(filter_chain_t *)
VLC_API block_t * filter_chain_AudioFilter(filter_chain_t *, block_t *)
Definition: vlc_configuration.h:156
VLC_API int filter_chain_DeleteFilter(filter_chain_t *, filter_t *)
VLC_API filter_chain_t * filter_chain_New(vlc_object_t *, const char *, bool, int(*)(filter_t *, void *), void(*)(filter_t *), void *) VLC_USED
VLC_API int filter_chain_GetLength(filter_chain_t *)
Definition: vlc_es.h:323
VLC_API void filter_chain_SubSource(filter_chain_t *, mtime_t)
Definition: vlc_es.h:180
VLC_API void filter_chain_Reset(filter_chain_t *, const es_format_t *, const es_format_t *)
Definition: vlc_mouse.h:45
VLC_API filter_t * filter_chain_AppendFilter(filter_chain_t *, const char *, config_chain_t *, const es_format_t *, const es_format_t *)
VLC_API void filter_DeleteBlend(filter_t *)
int64_t mtime_t
Definition: vlc_common.h:153
#define VLC_EGENERIC
Definition: vlc_common.h:374
Definition: vlc_filter.h:45
uint32_t vlc_fourcc_t
Definition: vlc_common.h:160
VLC_API picture_t * filter_chain_VideoFilter(filter_chain_t *, picture_t *)
VLC_API void filter_chain_Delete(filter_chain_t *)
Definition: vlc_block.h:102
VLC_API subpicture_t * filter_chain_SubFilter(filter_chain_t *, subpicture_t *)
VLC_API filter_t * filter_NewBlend(vlc_object_t *, const video_format_t *p_dst_chroma) VLC_USED
Definition: vlc_objects.h:42
VLC_API int filter_chain_MouseFilter(filter_chain_t *, vlc_mouse_t *, const vlc_mouse_t *)
VLC_API int filter_chain_MouseEvent(filter_chain_t *, const vlc_mouse_t *, const video_format_t *)
struct filter_chain_t filter_chain_t
Definition: vlc_filter.h:279