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 <stdatomic.h>
28 
29 #include <vlc_picture_fifo.h>
30 #include <vlc_picture_pool.h>
31 #include <vlc_vout_display.h>
32 #include "vout_wrapper.h"
33 #include "statistic.h"
34 #include "chrono.h"
35 #include "../clock/clock.h"
36 #include "../input/input_internal.h"
37 
38 /* It should be high enough to absorbe jitter due to difficult picture(s)
39  * to decode but not too high as memory is not that cheap.
40  *
41  * It can be made lower at compilation time if needed, but performance
42  * may be degraded.
43  */
44 #define VOUT_MAX_PICTURES (20)
45 
46 /**
47  * Vout configuration
48  */
49 typedef struct {
51  const video_format_t *fmt; // for the initial window dimensions
53 
54 typedef struct {
59  void *mouse_opaque;
61 #include "control.h"
62 
63 struct vout_snapshot;
64 
67 };
68 
69 /* */
71 {
72  bool dummy;
73 
74  /* Splitter module if used */
76 
78  float rate;
80 
81  /* */
82  video_format_t original; /* Original format ie coming from the decoder */
83  struct {
84  struct {
85  unsigned num;
86  unsigned den;
87  } dar;
88  struct {
89  enum vout_crop_mode mode;
90  union {
91  struct {
92  unsigned num;
93  unsigned den;
94  } ratio;
95  struct {
96  unsigned x;
97  unsigned y;
98  unsigned width;
99  unsigned height;
100  } window;
101  struct {
102  unsigned left;
103  unsigned right;
104  unsigned top;
105  unsigned bottom;
106  } border;
107  };
108  } crop;
109  } source;
110 
111  /* Snapshot interface */
113 
114  /* Statistics */
116 
117  /* Subpicture unit */
122 
123  /* Thread & synchronization */
126 
127  struct {
131  picture_t *decoded; // decoded picture before passed through chain_static
134  } displayed;
135 
136  struct {
138  vlc_tick_t timestamp;
139  } step;
140 
141  struct {
142  bool is_on;
143  vlc_tick_t date;
144  } pause;
145 
146  /* OSD title configuration */
147  struct {
148  bool show;
149  int timeout;
150  int position;
151  } title;
152 
153  struct {
154  bool is_interlaced;
155  vlc_tick_t date;
156  } interlacing;
157 
158  /* */
160 
161  /* Video filter2 chain */
162  struct {
168  bool has_deint;
169  } filter;
170 
171  /* */
175 
176  /* Video output window */
180 
181  /* Video output display */
185 
189  vout_chrono_t render; /**< picture render time estimator */
190 
191  atomic_uintptr_t refs;
192 };
193 
194 /**
195  * Creates a video output.
196  */
198 
200 
201 /**
202  * Setup the vout for the given configuration and get an associated decoder device.
203  *
204  * \param cfg the video configuration requested.
205  * \return pointer to a decoder device reference to use with the vout or NULL
206  */
208 
209 /**
210  * Returns a suitable vout or release the given one.
211  *
212  * If cfg->fmt is non NULL and valid, a vout will be returned, reusing cfg->vout
213  * is possible, otherwise it returns NULL.
214  * If cfg->vout is not used, it will be closed and released.
215  *
216  * You can release the returned value either by vout_Request() or vout_Close().
217  *
218  * \param cfg the video configuration requested.
219  * \param input used to get attachments for spu filters
220  * \param vctx pointer to the video context to use with the vout or NULL
221  * \retval 0 on success
222  * \retval -1 on error
223  */
225 
226 /**
227  * Disables a vout.
228  *
229  * This disables a vout, but keeps it for later reuse.
230  */
231 void vout_Stop(vout_thread_t *);
232 
233 /**
234  * Stop the display plugin, but keep its window plugin for later reuse.
235  */
237 
238 /**
239  * Destroys a vout.
240  *
241  * This function closes and releases a vout created by vout_Create().
242  *
243  * \param p_vout the vout to close
244  */
245 void vout_Close( vout_thread_t *p_vout );
246 
247 /**
248  * Set the new source format for a started vout
249  *
250  * \retval 0 on success
251  * \retval -1 on error, the vout needs to be restarted to handle the format
252  */
253 int vout_ChangeSource( vout_thread_t *p_vout, const video_format_t *fmt );
254 
255 /* TODO to move them to vlc_vout.h */
256 void vout_ChangeFullscreen(vout_thread_t *, const char *id);
258 void vout_ChangeWindowState(vout_thread_t *, unsigned state);
259 void vout_ChangeDisplaySize(vout_thread_t *, unsigned width, unsigned height);
260 void vout_ChangeDisplayFilled(vout_thread_t *, bool is_filled);
261 void vout_ChangeZoom(vout_thread_t *, unsigned num, unsigned den);
262 void vout_ChangeDisplayAspectRatio(vout_thread_t *, unsigned num, unsigned den);
263 void vout_ChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
264 void vout_ChangeCropWindow(vout_thread_t *, int x, int y, int width, int height);
265 void vout_ChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
266 void vout_ControlChangeFilters(vout_thread_t *, const char *);
267 void vout_ControlChangeSubSources(vout_thread_t *, const char *);
268 void vout_ControlChangeSubFilters(vout_thread_t *, const char *);
271 
272 /* */
274 void vout_IntfInit( vout_thread_t * );
277 
278 /* */
282 
283 /* */
285  vlc_clock_t *clock,
286  enum vlc_vout_order *out_order );
288 void spu_Attach( spu_t *, input_thread_t *input );
289 void spu_Detach( spu_t * );
290 void spu_SetClockDelay(spu_t *spu, size_t channel_id, vlc_tick_t delay);
291 void spu_SetClockRate(spu_t *spu, size_t channel_id, float rate);
294 
295 /**
296  * This function will (un)pause the display of pictures.
297  * It is thread safe
298  */
299 void vout_ChangePause( vout_thread_t *, bool b_paused, vlc_tick_t i_date );
300 
301 /**
302  * This function will change the rate of the vout
303  * It is thread safe
304  */
305 void vout_ChangeRate( vout_thread_t *, float rate );
306 
307 /**
308  * This function will change the delay of the vout
309  * It is thread safe
310  */
311 void vout_ChangeDelay( vout_thread_t *, vlc_tick_t delay );
312 
313 /**
314  * This function will change the rate of the spu channel
315  * It is thread safe
316  */
317 void vout_ChangeSpuRate( vout_thread_t *, size_t channel_id, float rate );
318 /**
319  * This function will change the delay of the spu channel
320  * It is thread safe
321  */
322 void vout_ChangeSpuDelay( vout_thread_t *, size_t channel_id, vlc_tick_t delay );
323 
324 
325 /**
326  * Updates the pointing device state.
327  */
328 void vout_MouseState(vout_thread_t *, const vlc_mouse_t *);
329 
330 /**
331  * This function will return and reset internal statistics.
332  */
333 void vout_GetResetStatistic( vout_thread_t *p_vout, unsigned *pi_displayed,
334  unsigned *pi_lost );
335 
336 /**
337  * This function will force to display the next picture while paused
338  */
339 void vout_NextPicture( vout_thread_t *p_vout, vlc_tick_t *pi_duration );
340 
341 /**
342  * This function will ask the display of the input title
343  */
344 void vout_DisplayTitle( vout_thread_t *p_vout, const char *psz_title );
345 
346 /**
347  * This function will return true if no more pictures are to be displayed.
348  */
349 bool vout_IsEmpty( vout_thread_t *p_vout );
350 
352 
353 #endif
spu_t * spu
Definition: vout_internal.h:119
void vout_StopDisplay(vout_thread_t *)
Stop the display plugin, but keep its window plugin for later reuse.
Definition: video_output.c:1732
vlc_tick_t delay
Definition: vout_internal.h:79
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:2000
vout_control_t control
Definition: vout_internal.h:125
vlc_decoder_device * dec_device
Definition: vout_internal.h:179
vout_thread_t * vout_Create(vlc_object_t *obj)
Creates a video output.
Definition: video_output.c:1855
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:168
void spu_SetClockDelay(spu_t *spu, size_t channel_id, vlc_tick_t delay)
Definition: vout_subpictures.c:1764
vlc_tick_t timestamp
Definition: vout_internal.h:129
Definition: statistic.h:30
Video picture.
Definition: vlc_picture.h:126
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:1430
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:1418
vout_thread_t * vout
Definition: vout_internal.h:50
vlc_blender_t * spu_blend
Definition: vout_internal.h:121
atomic_uintptr_t refs
Definition: vout_internal.h:191
bool window_enabled
Definition: vout_internal.h:177
picture_t * next
Definition: vout_internal.h:133
pthread_mutex_t vlc_mutex_t
Mutex.
Definition: vlc_threads.h:278
unsigned num
Definition: vout_internal.h:85
vout_display_t * display
Definition: vout_internal.h:183
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:526
Definition: picture_fifo.c:39
char * splitter_name
Definition: vout_internal.h:75
vout_thread_t * vout_CreateDummy(vlc_object_t *obj)
Definition: video_output.c:1844
void vout_IntfInit(vout_thread_t *)
Definition: vout_intf.c:289
unsigned left
Definition: vout_internal.h:102
struct vout_snapshot * snapshot
Definition: vout_internal.h:112
vlc_mouse_event mouse_event
Definition: vout_internal.h:173
void vout_ChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom)
Definition: video_output.c:558
void vout_ControlChangeFilters(vout_thread_t *, const char *)
Definition: video_output.c:591
vlc_mutex_t lock
Definition: vout_internal.h:163
Definition: vlc_subpicture.h:85
Vout configuration.
Definition: vout_internal.h:49
vlc_mutex_t spu_lock
Definition: vout_internal.h:118
Definition: vout_internal.h:66
void spu_SetHighlight(spu_t *, const vlc_spu_highlight_t *)
Definition: vout_subpictures.c:2135
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:620
picture_t * current
Definition: vout_internal.h:132
void spu_ChangeChannelOrderMargin(spu_t *, enum vlc_vout_order, int)
Definition: vout_subpictures.c:2115
unsigned bottom
Definition: vout_internal.h:105
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:1395
video_format_t original
Definition: vout_internal.h:82
bool is_on
Definition: vout_internal.h:142
struct filter_chain_t * chain_interactive
Definition: vout_internal.h:167
void vout_Close(vout_thread_t *p_vout)
Destroys a vout.
Definition: video_output.c:1769
picture_pool_t * private_pool
Definition: vout_internal.h:186
vout_chrono_t render
picture render time estimator
Definition: vout_internal.h:189
unsigned right
Definition: vout_internal.h:103
unsigned x
Definition: vout_internal.h:96
picture_pool_t * display_pool
Definition: vout_internal.h:187
vlc_mutex_t display_lock
Definition: vout_internal.h:184
video_format_t format
Definition: vout_internal.h:165
const video_format_t * fmt
Definition: vout_internal.h:51
void vout_ControlChangeSubSources(vout_thread_t *, const char *)
Definition: video_output.c:598
char * configuration
Definition: vout_internal.h:164
Definition: decoder_helpers.c:231
vlc_fourcc_t spu_blend_chroma
Definition: vout_internal.h:120
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
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:1449
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:483
Viewpoints.
Definition: vlc_viewpoint.h:41
Thread handle.
Definition: vlc_threads.h:263
ssize_t spu_RegisterChannelInternal(spu_t *, vlc_clock_t *, enum vlc_vout_order *)
Definition: vout_subpictures.c:2010
void * mouse_opaque
Definition: vout_internal.h:174
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:1441
void vout_ChangeCropRatio(vout_thread_t *, unsigned num, unsigned den)
Definition: video_output.c:503
Video output thread descriptor.
Definition: vlc_vout.h:60
picture_fifo_t * decoder_fifo
Definition: vout_internal.h:188
video format description
Definition: vlc_es.h:349
Definition: vout_internal.h:66
void vout_ChangeSpuChannelMargin(vout_thread_t *, enum vlc_vout_order order, int)
Definition: video_output.c:612
bool is_interlaced
Definition: vout_internal.h:130
Decoder context struct.
Definition: vlc_codec.h:555
vlc_decoder_device * vout_GetDevice(const vout_device_configuration_t *cfg)
Setup the vout for the given configuration and get an associated decoder device.
Definition: video_output.c:2060
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:1327
vlc_mutex_t window_lock
Definition: vout_internal.h:178
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:418
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:97
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:124
Definition: vout_internal.h:66
Main structure representing an input thread.
Definition: input_internal.h:47
void vout_IntfReinit(vout_thread_t *)
Definition: vout_intf.c:310
Subpicture unit descriptor.
Definition: vlc_spu.h:47
Definition: vout_internal.h:66
unsigned top
Definition: vout_internal.h:104
void vout_ControlChangeSubFilters(vout_thread_t *, const char *)
Definition: video_output.c:605
unsigned height
Definition: vout_internal.h:99
bool is_late_dropped
Definition: vout_internal.h:159
vlc_mouse_event mouse_event
Definition: vout_internal.h:58
vlc_clock_t * clock
Definition: vout_internal.h:77
Structure describing a filter.
Definition: vlc_filter.h:68
unsigned den
Definition: vout_internal.h:86
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:172
void spu_Attach(spu_t *, input_thread_t *input)
Attach the SPU to an input.
Definition: vout_subpictures.c:1736
vout_crop_mode
Definition: vout_internal.h:65
void vout_ChangeDisplayFilled(vout_thread_t *, bool is_filled)
Definition: video_output.c:432
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:449
vout_thread_t * vout
Definition: vout_internal.h:55
bool show
Definition: vout_internal.h:148
void vout_ChangeWindowState(vout_thread_t *, unsigned state)
Definition: video_output.c:410
vout_statistic_t statistic
Definition: vout_internal.h:115
Initial/Current configuration for a vout_display_t.
Definition: vlc_vout_display.h:68
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:182
vlc_tick_t date
Definition: vout_internal.h:128
float rate
Definition: vout_internal.h:78
Definition: vout_internal.h:70
void vout_CloseWrapper(vout_thread_t *, vout_display_t *vd)
Definition: vout_wrapper.c:132
const video_format_t * fmt
Definition: vout_internal.h:57
void spu_SetClockRate(spu_t *spu, size_t channel_id, float rate)
Definition: vout_subpictures.c:1776
void spu_Detach(spu_t *)
Detach the SPU from its attached input.
Definition: vout_subpictures.c:1756
VLC object common members.
Definition: vlc_objects.h:43
int position
Definition: vout_internal.h:150
void vout_Stop(vout_thread_t *)
Disables a vout.
Definition: video_output.c:1758
vlc_tick_t last
Definition: vout_internal.h:137
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:1943
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:219
unsigned width
Definition: vout_internal.h:98
struct filter_chain_t * chain_static
Definition: vout_internal.h:166
Definition: chrono.h:28
bool dummy
Definition: vout_internal.h:72
#define VLC_USED
Definition: fourcc_gen.c:32
picture_t * decoded
Definition: vout_internal.h:131
Definition: snapshot.c:43
void * mouse_opaque
Definition: vout_internal.h:59
vlc_clock_t * clock
Definition: vout_internal.h:56
Definition: vout_internal.h:54
int timeout
Definition: vout_internal.h:149
Definition: control.h:60