VLC  4.0.0-dev
vout_internal.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vout_internal.h : Internal vout definitions
3  *****************************************************************************
4  * Copyright (C) 2008-2018 VLC authors and VideoLAN
5  * Copyright (C) 2008 Laurent Aimar
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 #ifndef LIBVLC_VOUT_INTERNAL_H
25 #define LIBVLC_VOUT_INTERNAL_H 1
26 
27 #include <vlc_atomic.h>
28 #include <vlc_picture_fifo.h>
29 #include <vlc_picture_pool.h>
30 #include <vlc_vout_display.h>
31 #include "vout_wrapper.h"
32 #include "statistic.h"
33 #include "chrono.h"
34 #include "../clock/clock.h"
35 #include "../input/input_internal.h"
36 
37 /* It should be high enough to absorbe jitter due to difficult picture(s)
38  * to decode but not too high as memory is not that cheap.
39  *
40  * It can be made lower at compilation time if needed, but performance
41  * may be degraded.
42  */
43 #define VOUT_MAX_PICTURES (20)
44 
45 /**
46  * Vout configuration
47  */
48 typedef struct {
53  void *mouse_opaque;
55 #include "control.h"
56 
57 struct vout_snapshot;
58 
61 };
62 
63 /* */
65 {
66  bool dummy;
67 
68  /* Splitter module if used */
70 
72  float rate;
74 
75  /* */
76  video_format_t original; /* Original format ie coming from the decoder */
77  struct {
78  struct {
79  unsigned num;
80  unsigned den;
81  } dar;
82  struct {
83  enum vout_crop_mode mode;
84  union {
85  struct {
86  unsigned num;
87  unsigned den;
88  } ratio;
89  struct {
90  unsigned x;
91  unsigned y;
92  unsigned width;
93  unsigned height;
94  } window;
95  struct {
96  unsigned left;
97  unsigned right;
98  unsigned top;
99  unsigned bottom;
100  } border;
101  };
102  } crop;
103  } source;
104 
105  /* Snapshot interface */
107 
108  /* Statistics */
110 
111  /* Subpicture unit */
116 
117  /* Thread & synchronization */
120 
121  struct {
125  picture_t *decoded; // decoded picture before passed through chain_static
128  } displayed;
129 
130  struct {
132  vlc_tick_t timestamp;
133  } step;
134 
135  struct {
136  bool is_on;
137  vlc_tick_t date;
138  } pause;
139 
140  /* OSD title configuration */
141  struct {
142  bool show;
143  int timeout;
144  int position;
145  } title;
146 
147  struct {
148  bool is_interlaced;
149  vlc_tick_t date;
150  } interlacing;
151 
152  /* */
154 
155  /* Video filter2 chain */
156  struct {
163  bool has_deint;
164  } filter;
165 
166  /* */
170 
171  /* Video output window */
173  unsigned window_width; /* protected by display_lock */
174  unsigned window_height; /* protected by display_lock */
177 
178  /* Video output display */
182 
186  vout_chrono_t render; /**< picture render time estimator */
187 
189 };
190 
191 /**
192  * Creates a video output.
193  */
195 
197 
198 /**
199  * Setup the vout for the given configuration and get an associated decoder device.
200  *
201  * \param vout the video configuration requested.
202  * \return pointer to a decoder device reference to use with the vout or NULL
203  */
205 
206 /**
207  * Returns a suitable vout or release the given one.
208  *
209  * If cfg->fmt is non NULL and valid, a vout will be returned, reusing cfg->vout
210  * is possible, otherwise it returns NULL.
211  * If cfg->vout is not used, it will be closed and released.
212  *
213  * You can release the returned value either by vout_Request() or vout_Close().
214  *
215  * \param cfg the video configuration requested.
216  * \param input used to get attachments for spu filters
217  * \param vctx pointer to the video context to use with the vout or NULL
218  * \retval 0 on success
219  * \retval -1 on error
220  */
222 
223 /**
224  * Disables a vout.
225  *
226  * This disables a vout, but keeps it for later reuse.
227  */
228 void vout_Stop(vout_thread_t *);
229 
230 /**
231  * Stop the display plugin, but keep its window plugin for later reuse.
232  */
234 
235 /**
236  * Destroys a vout.
237  *
238  * This function closes and releases a vout created by vout_Create().
239  *
240  * \param p_vout the vout to close
241  */
242 void vout_Close( vout_thread_t *p_vout );
243 
244 /**
245  * Set the new source format for a started vout
246  *
247  * \retval 0 on success
248  * \retval -1 on error, the vout needs to be restarted to handle the format
249  */
250 int vout_ChangeSource( vout_thread_t *p_vout, const video_format_t *fmt );
251 
252 /* TODO to move them to vlc_vout.h */
253 void vout_ChangeFullscreen(vout_thread_t *, const char *id);
255 void vout_ChangeWindowState(vout_thread_t *, unsigned state);
256 void vout_ChangeDisplaySize(vout_thread_t *, unsigned width, unsigned height);
257 void vout_ChangeDisplayFilled(vout_thread_t *, bool is_filled);
258 void vout_ChangeZoom(vout_thread_t *, unsigned num, unsigned den);
259 void vout_ChangeDisplayAspectRatio(vout_thread_t *, unsigned num, unsigned den);
260 void vout_ChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
261 void vout_ChangeCropWindow(vout_thread_t *, int x, int y, int width, int height);
262 void vout_ChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
263 void vout_ControlChangeFilters(vout_thread_t *, const char *);
264 void vout_ControlChangeSubSources(vout_thread_t *, const char *);
265 void vout_ControlChangeSubFilters(vout_thread_t *, const char *);
268 
269 /* */
271 void vout_IntfInit( vout_thread_t * );
274 
275 /* */
279 
280 /* */
282  vlc_clock_t *clock,
283  enum vlc_vout_order *out_order );
285 void spu_Attach( spu_t *, input_thread_t *input );
286 void spu_Detach( spu_t * );
287 void spu_SetClockDelay(spu_t *spu, size_t channel_id, vlc_tick_t delay);
288 void spu_SetClockRate(spu_t *spu, size_t channel_id, float rate);
291 
292 /**
293  * This function will (un)pause the display of pictures.
294  * It is thread safe
295  */
296 void vout_ChangePause( vout_thread_t *, bool b_paused, vlc_tick_t i_date );
297 
298 /**
299  * This function will change the rate of the vout
300  * It is thread safe
301  */
302 void vout_ChangeRate( vout_thread_t *, float rate );
303 
304 /**
305  * This function will change the delay of the vout
306  * It is thread safe
307  */
308 void vout_ChangeDelay( vout_thread_t *, vlc_tick_t delay );
309 
310 /**
311  * This function will change the rate of the spu channel
312  * It is thread safe
313  */
314 void vout_ChangeSpuRate( vout_thread_t *, size_t channel_id, float rate );
315 /**
316  * This function will change the delay of the spu channel
317  * It is thread safe
318  */
319 void vout_ChangeSpuDelay( vout_thread_t *, size_t channel_id, vlc_tick_t delay );
320 
321 
322 /**
323  * Updates the pointing device state.
324  */
325 void vout_MouseState(vout_thread_t *, const vlc_mouse_t *);
326 
327 /**
328  * This function will return and reset internal statistics.
329  */
330 void vout_GetResetStatistic( vout_thread_t *p_vout, unsigned *pi_displayed,
331  unsigned *pi_lost );
332 
333 /**
334  * This function will force to display the next picture while paused
335  */
336 void vout_NextPicture( vout_thread_t *p_vout, vlc_tick_t *pi_duration );
337 
338 /**
339  * This function will ask the display of the input title
340  */
341 void vout_DisplayTitle( vout_thread_t *p_vout, const char *psz_title );
342 
343 /**
344  * This function will return true if no more pictures are to be displayed.
345  */
346 bool vout_IsEmpty( vout_thread_t *p_vout );
347 
349 
350 #endif
spu_t * spu
Definition: vout_internal.h:113
void vout_StopDisplay(vout_thread_t *)
Stop the display plugin, but keep its window plugin for later reuse.
Definition: video_output.c:1782
vlc_tick_t delay
Definition: vout_internal.h:73
int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input_thread_t *input)
Returns a suitable vout or release the given one.
Definition: video_output.c:2029
vout_control_t control
Definition: vout_internal.h:119
vlc_decoder_device * dec_device
Definition: vout_internal.h:176
vout_thread_t * vout_Create(vlc_object_t *obj)
Creates a video output.
Definition: video_output.c:1896
void(* vlc_mouse_event)(const vlc_mouse_t *mouse, void *user_data)
Mouse event callback.
Definition: vlc_mouse.h:62
bool has_deint
Definition: vout_internal.h:163
void spu_SetClockDelay(spu_t *spu, size_t channel_id, vlc_tick_t delay)
Definition: vout_subpictures.c:1756
Definition: vlc_atomic.h:38
vlc_tick_t timestamp
Definition: vout_internal.h:123
Definition: statistic.h:30
Video picture.
Definition: vlc_picture.h:127
void vout_ChangeRate(vout_thread_t *, float rate)
This function will change the rate of the vout It is thread safe.
Definition: video_output.c:1465
void vout_ChangeDelay(vout_thread_t *, vlc_tick_t delay)
This function will change the delay of the vout It is thread safe.
Definition: video_output.c:1453
video_format_t src_fmt
Definition: vout_internal.h:159
vlc_blender_t * spu_blend
Definition: vout_internal.h:115
bool window_enabled
Definition: vout_internal.h:172
picture_t * next
Definition: vout_internal.h:127
unsigned num
Definition: vout_internal.h:79
vout_display_t * display
Definition: vout_internal.h:180
void vout_GetResetStatistic(vout_thread_t *p_vout, unsigned *pi_displayed, unsigned *pi_lost)
This function will return and reset internal statistics.
static thread_local struct @77 state
void vout_ChangeCropWindow(vout_thread_t *, int x, int y, int width, int height)
Definition: video_output.c:531
Definition: picture_fifo.c:39
char * splitter_name
Definition: vout_internal.h:69
vout_thread_t * vout_CreateDummy(vlc_object_t *obj)
Definition: video_output.c:1885
void vout_IntfInit(vout_thread_t *)
Definition: vout_intf.c:289
unsigned left
Definition: vout_internal.h:96
struct vout_snapshot * snapshot
Definition: vout_internal.h:106
vlc_mouse_event mouse_event
Definition: vout_internal.h:168
void vout_ChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom)
Definition: video_output.c:563
void vout_ControlChangeFilters(vout_thread_t *, const char *)
Definition: video_output.c:596
vlc_mutex_t lock
Definition: vout_internal.h:157
Definition: vlc_subpicture.h:85
vlc_mutex_t spu_lock
Definition: vout_internal.h:112
Definition: vout_internal.h:60
void spu_SetHighlight(spu_t *, const vlc_spu_highlight_t *)
Definition: vout_subpictures.c:2127
void vout_IntfDeinit(vlc_object_t *)
Definition: vout_intf.c:322
void vout_ChangeViewpoint(vout_thread_t *, const vlc_viewpoint_t *)
Definition: video_output.c:625
picture_t * current
Definition: vout_internal.h:126
void spu_ChangeChannelOrderMargin(spu_t *, enum vlc_vout_order, int)
Definition: vout_subpictures.c:2107
unsigned bottom
Definition: vout_internal.h:99
vlc_object_t * obj
Definition: filter_chain.c:48
void vout_MouseState(vout_thread_t *, const vlc_mouse_t *)
Updates the pointing device state.
Definition: video_output.c:251
void vout_NextPicture(vout_thread_t *p_vout, vlc_tick_t *pi_duration)
This function will force to display the next picture while paused.
Definition: video_output.c:1430
video_format_t original
Definition: vout_internal.h:76
bool is_on
Definition: vout_internal.h:136
struct filter_chain_t * chain_interactive
Definition: vout_internal.h:162
void vout_Close(vout_thread_t *p_vout)
Destroys a vout.
Definition: video_output.c:1814
picture_pool_t * private_pool
Definition: vout_internal.h:183
vout_chrono_t render
picture render time estimator
Definition: vout_internal.h:186
unsigned right
Definition: vout_internal.h:97
unsigned x
Definition: vout_internal.h:90
picture_pool_t * display_pool
Definition: vout_internal.h:184
vlc_mutex_t display_lock
Definition: vout_internal.h:181
void vout_ControlChangeSubSources(vout_thread_t *, const char *)
Definition: video_output.c:603
char * configuration
Definition: vout_internal.h:158
Definition: decoder_helpers.c:232
vlc_fourcc_t spu_blend_chroma
Definition: vout_internal.h:114
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45
void vout_ChangeFullscreen(vout_thread_t *, const char *id)
Definition: video_output.c:392
vlc_decoder_device * vout_GetDevice(vout_thread_t *vout)
Setup the vout for the given configuration and get an associated decoder device.
Definition: video_output.c:2092
Atomic operations do not require locking, but they are not very powerful.
uint32_t vlc_fourcc_t
Definition: fourcc_gen.c:33
void vout_ChangeSpuRate(vout_thread_t *, size_t channel_id, float rate)
This function will change the rate of the spu channel It is thread safe.
Definition: video_output.c:1484
This file defines picture fifo structures and functions in vlc.
Definition: clock.c:61
void vout_ChangeDisplayAspectRatio(vout_thread_t *, unsigned num, unsigned den)
Definition: video_output.c:488
Viewpoints.
Definition: vlc_viewpoint.h:41
Thread handle.
Definition: vlc_threads.h:208
ssize_t spu_RegisterChannelInternal(spu_t *, vlc_clock_t *, enum vlc_vout_order *)
Definition: vout_subpictures.c:2002
void * mouse_opaque
Definition: vout_internal.h:169
void vout_ChangeSpuDelay(vout_thread_t *, size_t channel_id, vlc_tick_t delay)
This function will change the delay of the spu channel It is thread safe.
Definition: video_output.c:1476
void vout_ChangeCropRatio(vout_thread_t *, unsigned num, unsigned den)
Definition: video_output.c:508
unsigned window_width
Definition: vout_internal.h:173
Video output thread descriptor.
Definition: vlc_vout.h:60
picture_fifo_t * decoder_fifo
Definition: vout_internal.h:185
video format description
Definition: vlc_es.h:349
Definition: vout_internal.h:60
void vout_ChangeSpuChannelMargin(vout_thread_t *, enum vlc_vout_order order, int)
Definition: video_output.c:617
Mutex.
Definition: vlc_threads.h:266
bool is_interlaced
Definition: vout_internal.h:124
Decoder context struct.
Definition: vlc_codec.h:577
Mouse state.
Definition: vlc_mouse.h:45
void vout_ChangePause(vout_thread_t *, bool b_paused, vlc_tick_t i_date)
This function will (un)pause the display of pictures.
Definition: video_output.c:1363
vlc_mutex_t window_lock
Definition: vout_internal.h:175
Video output display modules interface.
ssize_t vout_RegisterSubpictureChannelInternal(vout_thread_t *, vlc_clock_t *clock, enum vlc_vout_order *out_order)
Definition: video_output.c:284
void vout_ChangeDisplaySize(vout_thread_t *, unsigned width, unsigned height)
Definition: video_output.c:419
void vout_CreateVars(vout_thread_t *)
Definition: vout_intf.c:154
void vout_ChangeWindowed(vout_thread_t *)
Definition: video_output.c:400
unsigned y
Definition: vout_internal.h:91
vlc_vout_order
vout or spu_channel order
Definition: vlc_vout.h:78
Definition: picture_pool.c:41
vlc_thread_t thread
Definition: vout_internal.h:118
Definition: vout_internal.h:60
Main structure representing an input thread.
Definition: input_internal.h:48
void vout_IntfReinit(vout_thread_t *)
Definition: vout_intf.c:310
Subpicture unit descriptor.
Definition: vlc_spu.h:47
Definition: vout_internal.h:60
unsigned top
Definition: vout_internal.h:98
void vout_ControlChangeSubFilters(vout_thread_t *, const char *)
Definition: video_output.c:610
unsigned height
Definition: vout_internal.h:93
bool is_late_dropped
Definition: vout_internal.h:153
unsigned window_height
Definition: vout_internal.h:174
vlc_mouse_event mouse_event
Definition: vout_internal.h:52
vlc_clock_t * clock
Definition: vout_internal.h:71
Structure describing a filter.
Definition: vlc_filter.h:72
unsigned den
Definition: vout_internal.h:80
void vout_DisplayTitle(vout_thread_t *p_vout, const char *psz_title)
This function will ask the display of the input title.
Definition: video_output.c:239
vlc_mouse_t mouse
Definition: vout_internal.h:167
void spu_Attach(spu_t *, input_thread_t *input)
Attach the SPU to an input.
Definition: vout_subpictures.c:1728
vout_crop_mode
Definition: vout_internal.h:59
vlc_video_context * src_vctx
Definition: vout_internal.h:160
void vout_ChangeDisplayFilled(vout_thread_t *, bool is_filled)
Definition: video_output.c:437
bool vout_IsEmpty(vout_thread_t *p_vout)
This function will return true if no more pictures are to be displayed.
Definition: video_output.c:226
void vout_ChangeZoom(vout_thread_t *, unsigned num, unsigned den)
Definition: video_output.c:454
vout_thread_t * vout
Definition: vout_internal.h:49
bool show
Definition: vout_internal.h:142
void vout_ChangeWindowState(vout_thread_t *, unsigned state)
Definition: video_output.c:411
vout_statistic_t statistic
Definition: vout_internal.h:109
User configuration for a video output display (vout_display_t)
Definition: vlc_vout_display.h:94
This file defines picture pool structures and functions in vlc.
Definition: filter_chain.c:46
vout_display_cfg_t display_cfg
Definition: vout_internal.h:179
vlc_tick_t date
Definition: vout_internal.h:122
vlc_atomic_rc_t rc
Definition: vout_internal.h:188
float rate
Definition: vout_internal.h:72
Definition: vout_internal.h:64
void vout_CloseWrapper(vout_thread_t *, vout_display_t *vd)
Definition: vout_wrapper.c:132
const video_format_t * fmt
Definition: vout_internal.h:51
void spu_SetClockRate(spu_t *spu, size_t channel_id, float rate)
Definition: vout_subpictures.c:1768
void spu_Detach(spu_t *)
Detach the SPU from its attached input.
Definition: vout_subpictures.c:1748
VLC object common members.
Definition: vlc_objects.h:43
int position
Definition: vout_internal.h:144
void vout_Stop(vout_thread_t *)
Disables a vout.
Definition: video_output.c:1803
vlc_tick_t last
Definition: vout_internal.h:131
int vout_ChangeSource(vout_thread_t *p_vout, const video_format_t *fmt)
Set the new source format for a started vout.
Definition: video_output.c:1982
vout_display_t * vout_OpenWrapper(vout_thread_t *, const char *, const vout_display_cfg_t *, vlc_video_context *)
Definition: vout_wrapper.c:57
void vout_SetSpuHighlight(vout_thread_t *p_vout, const vlc_spu_highlight_t *)
Definition: video_output.c:312
Definition: vlc_vout_display.h:272
unsigned width
Definition: vout_internal.h:92
struct filter_chain_t * chain_static
Definition: vout_internal.h:161
Definition: chrono.h:28
bool dummy
Definition: vout_internal.h:66
#define VLC_USED
Definition: fourcc_gen.c:32
picture_t * decoded
Definition: vout_internal.h:125
Definition: snapshot.c:43
void * mouse_opaque
Definition: vout_internal.h:53
vlc_clock_t * clock
Definition: vout_internal.h:50
Vout configuration.
Definition: vout_internal.h:48
int timeout
Definition: vout_internal.h:143
Definition: control.h:60