input: add a new type input_control_param_t to extend control
[vlc.git] / src / input / input_internal.h
blob540e1003bdedc6bb1c22da1c092a05bd729b7e4f
1 /*****************************************************************************
2 * input_internal.h: Internal input structures
3 *****************************************************************************
4 * Copyright (C) 1998-2006 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
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.
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.
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 *****************************************************************************/
24 #ifndef LIBVLC_INPUT_INTERNAL_H
25 #define LIBVLC_INPUT_INTERNAL_H 1
27 #include <stddef.h>
28 #include <stdatomic.h>
30 #include <vlc_access.h>
31 #include <vlc_demux.h>
32 #include <vlc_input.h>
33 #include <vlc_viewpoint.h>
34 #include <libvlc.h>
35 #include "input_interface.h"
36 #include "misc/interrupt.h"
38 struct input_stats;
40 /*****************************************************************************
41 * Private input fields
42 *****************************************************************************/
44 #define INPUT_CONTROL_FIFO_SIZE 100
46 /* input_source_t: gathers all information per input source */
47 typedef struct
49 struct vlc_common_members obj;
51 demux_t *p_demux; /**< Demux object (most downstream) */
53 /* Title infos for that input */
54 bool b_title_demux; /* Titles/Seekpoints provided by demux */
55 int i_title;
56 input_title_t **title;
58 int i_title_offset;
59 int i_seekpoint_offset;
61 int i_title_start;
62 int i_title_end;
63 int i_seekpoint_start;
64 int i_seekpoint_end;
66 /* Properties */
67 bool b_can_pause;
68 bool b_can_pace_control;
69 bool b_can_rate_control;
70 bool b_can_stream_record;
71 bool b_rescale_ts;
72 double f_fps;
74 /* */
75 vlc_tick_t i_pts_delay;
77 bool b_eof; /* eof of demuxer */
79 } input_source_t;
81 typedef union
83 vlc_value_t val;
84 vlc_viewpoint_t viewpoint;
85 } input_control_param_t;
87 typedef struct
89 int i_type;
90 input_control_param_t param;
91 } input_control_t;
93 /** Private input fields */
94 typedef struct input_thread_private_t
96 struct input_thread_t input;
98 /* Global properties */
99 bool b_preparsing;
100 bool b_can_pause;
101 bool b_can_rate_control;
102 bool b_can_pace_control;
104 /* Current state */
105 int i_state;
106 bool is_running;
107 bool is_stopped;
108 bool b_recording;
109 int i_rate;
111 /* Playtime configuration and state */
112 vlc_tick_t i_start; /* :start-time,0 by default */
113 vlc_tick_t i_stop; /* :stop-time, 0 if none */
114 vlc_tick_t i_time; /* Current time */
115 bool b_fast_seek;/* :input-fast-seek */
117 /* Output */
118 bool b_out_pace_control; /* XXX Move it ot es_sout ? */
119 sout_instance_t *p_sout; /* Idem ? */
120 es_out_t *p_es_out;
121 es_out_t *p_es_out_display;
122 vlc_viewpoint_t viewpoint;
123 bool viewpoint_changed;
124 vlc_renderer_item_t *p_renderer;
126 /* Title infos FIXME multi-input (not easy) ? */
127 int i_title;
128 const input_title_t **title;
130 int i_title_offset;
131 int i_seekpoint_offset;
133 /* User bookmarks FIXME won't be easy with multiples input */
134 seekpoint_t bookmark;
135 int i_bookmark;
136 seekpoint_t **pp_bookmark;
138 /* Input attachment */
139 int i_attachment;
140 input_attachment_t **attachment;
141 const demux_t **attachment_demux;
143 /* Main input properties */
145 /* Input item */
146 input_item_t *p_item;
148 /* Main source */
149 input_source_t *master;
150 /* Slave sources (subs, and others) */
151 int i_slave;
152 input_source_t **slave;
154 /* Resources */
155 input_resource_t *p_resource;
156 input_resource_t *p_resource_private;
158 /* Stats counters */
159 struct input_stats *stats;
161 /* Buffer of pending actions */
162 vlc_mutex_t lock_control;
163 vlc_cond_t wait_control;
164 int i_control;
165 input_control_t control[INPUT_CONTROL_FIFO_SIZE];
167 vlc_thread_t thread;
168 vlc_interrupt_t interrupt;
169 } input_thread_private_t;
171 static inline input_thread_private_t *input_priv(input_thread_t *input)
173 return container_of(input, input_thread_private_t, input);
176 /***************************************************************************
177 * Internal control helpers
178 ***************************************************************************/
179 enum input_control_e
181 INPUT_CONTROL_SET_STATE,
183 INPUT_CONTROL_SET_RATE,
185 INPUT_CONTROL_SET_POSITION,
187 INPUT_CONTROL_SET_TIME,
189 INPUT_CONTROL_SET_PROGRAM,
191 INPUT_CONTROL_SET_TITLE,
192 INPUT_CONTROL_SET_TITLE_NEXT,
193 INPUT_CONTROL_SET_TITLE_PREV,
195 INPUT_CONTROL_SET_SEEKPOINT,
196 INPUT_CONTROL_SET_SEEKPOINT_NEXT,
197 INPUT_CONTROL_SET_SEEKPOINT_PREV,
199 INPUT_CONTROL_SET_BOOKMARK,
201 INPUT_CONTROL_NAV_ACTIVATE, // NOTE: INPUT_CONTROL_NAV_* values must be
202 INPUT_CONTROL_NAV_UP, // contiguous and in the same order as
203 INPUT_CONTROL_NAV_DOWN, // INPUT_NAV_* and DEMUX_NAV_*.
204 INPUT_CONTROL_NAV_LEFT,
205 INPUT_CONTROL_NAV_RIGHT,
206 INPUT_CONTROL_NAV_POPUP,
207 INPUT_CONTROL_NAV_MENU,
209 INPUT_CONTROL_SET_ES,
210 INPUT_CONTROL_RESTART_ES,
212 INPUT_CONTROL_SET_VIEWPOINT, // new absolute viewpoint
213 INPUT_CONTROL_SET_INITIAL_VIEWPOINT, // set initial viewpoint (generally from video)
214 INPUT_CONTROL_UPDATE_VIEWPOINT, // update viewpoint relative to current
216 INPUT_CONTROL_SET_AUDIO_DELAY,
217 INPUT_CONTROL_SET_SPU_DELAY,
219 INPUT_CONTROL_ADD_SLAVE,
221 INPUT_CONTROL_SET_RECORD_STATE,
223 INPUT_CONTROL_SET_FRAME_NEXT,
225 INPUT_CONTROL_SET_RENDERER,
228 /* Internal helpers */
230 void input_ControlPush( input_thread_t *, int, input_control_param_t * );
232 /* XXX for string value you have to allocate it before calling
233 * input_ControlPushHelper
235 static inline void input_ControlPushHelper( input_thread_t *p_input, int i_type, vlc_value_t *val )
237 if( val != NULL )
239 input_control_param_t param = { .val = *val };
240 input_ControlPush( p_input, i_type, &param );
242 else
244 input_ControlPush( p_input, i_type, NULL );
248 bool input_Stopped( input_thread_t * );
250 /* Bound pts_delay */
251 #define INPUT_PTS_DELAY_MAX (CLOCK_FREQ*60)
253 /**********************************************************************
254 * Item metadata
255 **********************************************************************/
256 /* input_ExtractAttachmentAndCacheArt:
257 * Be careful: p_item lock will be taken! */
258 void input_ExtractAttachmentAndCacheArt( input_thread_t *, const char *name );
260 /***************************************************************************
261 * Internal prototypes
262 ***************************************************************************/
264 /* var.c */
265 void input_ControlVarInit ( input_thread_t * );
266 void input_ControlVarStop( input_thread_t * );
267 void input_ControlVarNavigation( input_thread_t * );
268 void input_ControlVarTitle( input_thread_t *, int i_title );
270 void input_ConfigVarInit ( input_thread_t * );
272 /* Subtitles */
273 int subtitles_Detect( input_thread_t *, char *, const char *, input_item_slave_t ***, int * );
274 int subtitles_Filter( const char *);
276 /* meta.c */
277 void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
278 const vlc_meta_t *p_meta );
280 /* item.c */
281 void input_item_node_PostAndDelete( input_item_node_t *p_node );
283 /* stats.c */
284 typedef struct input_rate_t
286 vlc_mutex_t lock;
287 uintmax_t updates;
288 uintmax_t value;
289 struct
291 uintmax_t value;
292 vlc_tick_t date;
293 } samples[2];
294 } input_rate_t;
296 struct input_stats {
297 input_rate_t input_bitrate;
298 input_rate_t demux_bitrate;
299 atomic_uintmax_t demux_corrupted;
300 atomic_uintmax_t demux_discontinuity;
301 atomic_uintmax_t decoded_audio;
302 atomic_uintmax_t decoded_video;
303 atomic_uintmax_t played_abuffers;
304 atomic_uintmax_t lost_abuffers;
305 atomic_uintmax_t displayed_pictures;
306 atomic_uintmax_t lost_pictures;
309 struct input_stats *input_stats_Create(void);
310 void input_stats_Destroy(struct input_stats *);
311 void input_rate_Add(input_rate_t *, uintmax_t);
312 void input_stats_Compute(struct input_stats *, input_stats_t*);
314 #endif