1 /*****************************************************************************
2 * input_internal.h: Internal input structures
3 *****************************************************************************
4 * Copyright (C) 1998-2006 VLC authors and VideoLAN
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
28 #include <stdatomic.h>
30 #include <vlc_access.h>
31 #include <vlc_demux.h>
32 #include <vlc_input.h>
33 #include <vlc_viewpoint.h>
35 #include "input_interface.h"
36 #include "misc/interrupt.h"
40 /*****************************************************************************
41 * Private input fields
42 *****************************************************************************/
44 #define INPUT_CONTROL_FIFO_SIZE 100
46 /* input_source_t: gathers all information per input source */
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 */
56 input_title_t
**title
;
59 int i_seekpoint_offset
;
63 int i_seekpoint_start
;
68 bool b_can_pace_control
;
69 bool b_can_rate_control
;
70 bool b_can_stream_record
;
75 vlc_tick_t i_pts_delay
;
77 bool b_eof
; /* eof of demuxer */
84 vlc_viewpoint_t viewpoint
;
85 } input_control_param_t
;
90 input_control_param_t param
;
93 /** Private input fields */
94 typedef struct input_thread_private_t
96 struct input_thread_t input
;
98 /* Global properties */
101 bool b_can_rate_control
;
102 bool b_can_pace_control
;
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 */
118 bool b_out_pace_control
; /* XXX Move it ot es_sout ? */
119 sout_instance_t
*p_sout
; /* Idem ? */
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) ? */
128 const input_title_t
**title
;
131 int i_seekpoint_offset
;
133 /* User bookmarks FIXME won't be easy with multiples input */
134 seekpoint_t bookmark
;
136 seekpoint_t
**pp_bookmark
;
138 /* Input attachment */
140 input_attachment_t
**attachment
;
141 const demux_t
**attachment_demux
;
143 /* Main input properties */
146 input_item_t
*p_item
;
149 input_source_t
*master
;
150 /* Slave sources (subs, and others) */
152 input_source_t
**slave
;
155 input_resource_t
*p_resource
;
156 input_resource_t
*p_resource_private
;
159 struct input_stats
*stats
;
161 /* Buffer of pending actions */
162 vlc_mutex_t lock_control
;
163 vlc_cond_t wait_control
;
165 input_control_t control
[INPUT_CONTROL_FIFO_SIZE
];
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 ***************************************************************************/
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
)
239 input_control_param_t param
= { .val
= *val
};
240 input_ControlPush( p_input
, i_type
, ¶m
);
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 /**********************************************************************
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 ***************************************************************************/
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
* );
273 int subtitles_Detect( input_thread_t
*, char *, const char *, input_item_slave_t
***, int * );
274 int subtitles_Filter( const char *);
277 void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t
*p_dst
,
278 const vlc_meta_t
*p_meta
);
281 void input_item_node_PostAndDelete( input_item_node_t
*p_node
);
284 typedef struct input_rate_t
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
*);