1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 1999-2004 VideoLAN
5 * $Id: input_ext-intf.h 7954 2004-06-07 22:19:12Z fenrir $
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * Laurent Aimar <fenrir@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
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 General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /* __ is need because conflict with <vlc/input.h> */
27 #define _VLC__INPUT_H 1
29 /*****************************************************************************
30 * input_item_t: Describes an input and is used to spawn input_thread_t objects.
31 *****************************************************************************/
34 char *psz_name; /**< Name of this info */
35 char *psz_value; /**< Value of the info */
38 struct info_category_t
40 char *psz_name; /**< Name of this category */
41 int i_infos; /**< Number of infos in the category */
42 struct info_t **pp_infos; /**< Pointer to an array of infos */
47 char *psz_name; /**< text describing this item */
48 char *psz_uri; /**< mrl of this item */
50 int i_options; /**< Number of input options */
51 char **ppsz_options; /**< Array of input options */
53 mtime_t i_duration; /**< A hint about the duration of this
54 * item, in milliseconds*/
56 int i_categories; /**< Number of info categories */
57 info_category_t **pp_categories; /**< Pointer to the first info category */
59 vlc_mutex_t lock; /**< Item cannot be changed without this lock */
63 /*****************************************************************************
64 * Seek point: (generalisation of chapters)
65 *****************************************************************************/
68 int64_t i_byte_offset;
69 int64_t i_time_offset;
73 static inline seekpoint_t *vlc_seekpoint_New( void )
75 seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
76 point->i_byte_offset =
77 point->i_time_offset = 0;
78 point->psz_name = NULL;
82 static inline void vlc_seekpoint_Delete( seekpoint_t *point )
85 if( point->psz_name ) free( point->psz_name );
89 static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src )
91 seekpoint_t *point = vlc_seekpoint_New();
92 if( src->psz_name ) point->psz_name = strdup( src->psz_name );
93 point->i_time_offset = src->i_time_offset;
94 point->i_byte_offset = src->i_byte_offset;
98 /*****************************************************************************
100 *****************************************************************************/
105 vlc_bool_t b_menu; /* Is it a menu or a normal entry */
107 int64_t i_length; /* Length(microsecond) if known, else 0 */
108 int64_t i_size; /* Size (bytes) if known, else 0 */
110 /* Title seekpoint */
112 seekpoint_t **seekpoint;
116 static inline input_title_t *vlc_input_title_New( )
118 input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) );
121 t->b_menu = VLC_FALSE;
129 static inline void vlc_input_title_Delete( input_title_t *t )
135 if( t->psz_name ) free( t->psz_name );
136 for( i = 0; i < t->i_seekpoint; i++ )
138 if( t->seekpoint[i]->psz_name ) free( t->seekpoint[i]->psz_name );
139 free( t->seekpoint[i] );
141 if( t->seekpoint ) free( t->seekpoint );
145 static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
147 input_title_t *dup = vlc_input_title_New( );
150 if( t->psz_name ) dup->psz_name = strdup( t->psz_name );
151 dup->b_menu = t->b_menu;
152 dup->i_length = t->i_length;
153 dup->i_size = t->i_size;
154 dup->i_seekpoint = t->i_seekpoint;
155 if( t->i_seekpoint > 0 )
157 dup->seekpoint = (seekpoint_t**)calloc( t->i_seekpoint,
158 sizeof(seekpoint_t*) );
160 for( i = 0; i < t->i_seekpoint; i++ )
162 dup->seekpoint[i] = vlc_seekpoint_Duplicate( t->seekpoint[i] );
170 /*****************************************************************************
171 * input defines/constants.
172 *****************************************************************************/
183 /* "rate" default, min/max */
184 #define INPUT_RATE_DEFAULT 1000
185 #define INPUT_RATE_MIN 125 /* Up to 8/1 */
186 #define INPUT_RATE_MAX 8000 /* Up to 1/8 */
188 /* input_source_t: gathers all informations per input source */
191 /* Input item description */
192 input_item_t *p_item;
194 /* Access/Stream/Demux plugins */
199 /* Title infos for that input */
200 vlc_bool_t b_title_demux; /* Titles/Seekpoints provided by demux */
202 input_title_t **title;
205 vlc_bool_t b_can_pace_control;
206 vlc_bool_t b_can_pause;
207 vlc_bool_t b_eof; /* eof of demuxer */
209 /* Clock average variation */
214 /* i_update field of access_t/demux_t */
215 #define INPUT_UPDATE_NONE 0x0000
216 #define INPUT_UPDATE_SIZE 0x0001
217 #define INPUT_UPDATE_TITLE 0x0010
218 #define INPUT_UPDATE_SEEKPOINT 0x0020
220 /* Input control XXX: internal */
221 #define INPUT_CONTROL_FIFO_SIZE 100
223 /*****************************************************************************
225 *****************************************************************************
226 * XXX: this strucrures is *PRIVATE* so nobody can touch it out of src/input.
227 * I plan to move it to src/input/input_internal.h anyway
229 * XXX: look at src/input/input.c:input_CreateThread for accessible variables
230 * YOU CANNOT HAVE ACCESS TO THE CONTENT OF input_thread_t except
231 * p_input->input.p_item (and it's only temporary).
232 * XXX: move the docs somewhere (better than src/input )
233 *****************************************************************************/
234 struct input_thread_t
238 /* Global properties */
240 vlc_bool_t b_can_pace_control;
241 vlc_bool_t b_can_pause;
248 int64_t i_start; /* :start-time,0 by default */
249 int64_t i_time; /* Current time */
250 int64_t i_stop; /* :stop-time, 0 if none */
252 /* Title infos FIXME multi-input (not easy) ? */
254 input_title_t **title;
256 /* User bookmarks FIXME won't be easy with multiples input */
258 seekpoint_t **bookmark;
262 sout_instance_t *p_sout; /* XXX Move it to es_out ? */
263 vlc_bool_t b_out_pace_control; /* idem ? */
265 /* Internal caching common for all inputs */
268 /* Main input properties */
269 input_source_t input;
271 /* Slave demuxers (subs, and others) */
273 input_source_t **slave;
275 /* Buffer of pending actions */
276 vlc_mutex_t lock_control;
280 /* XXX: val isn't duplicated so it won't works with string */
283 } control[INPUT_CONTROL_FIFO_SIZE];
286 /*****************************************************************************
288 *****************************************************************************/
289 #define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
290 VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
291 VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
292 VLC_EXPORT( void, input_DestroyThread, ( input_thread_t * ) );
296 /* input variable "position" */
297 INPUT_GET_POSITION, /* arg1= double * res= */
298 INPUT_SET_POSITION, /* arg1= double res=can fail */
300 /* input variable "length" */
301 INPUT_GET_LENGTH, /* arg1= int64_t * res=can fail */
303 /* input variable "time" */
304 INPUT_GET_TIME, /* arg1= int64_t * res= */
305 INPUT_SET_TIME, /* arg1= int64_t res=can fail */
307 /* input variable "rate" (1 is DEFAULT_RATE) */
308 INPUT_GET_RATE, /* arg1= int * res= */
309 INPUT_SET_RATE, /* arg1= int res=can fail */
311 /* input variable "state" */
312 INPUT_GET_STATE, /* arg1= int * res= */
313 INPUT_SET_STATE, /* arg1= int res=can fail */
315 /* input variable "audio-delay" and "spu-delay" */
316 INPUT_GET_AUDIO_DELAY, /* arg1 = int* res=can fail */
317 INPUT_SET_AUDIO_DELAY, /* arg1 = int res=can fail */
318 INPUT_GET_SPU_DELAY, /* arg1 = int* res=can fail */
319 INPUT_SET_SPU_DELAY, /* arg1 = int res=can fail */
322 INPUT_ADD_INFO, /* arg1= char * arg2= char * arg3=... res=can fail */
323 INPUT_GET_INFO, /* arg1= char * arg2= char * arg3= char ** res=can fail*/
325 INPUT_SET_NAME, /* arg1= char * res=can fail */
327 /* XXX: all next query aren't working for now */
329 INPUT_GET_BOOKMARKS, /* arg1= seekpoint_t *** arg2= int * res=can fail */
330 INPUT_CLEAR_BOOKMARKS, /* res=can fail */
331 INPUT_ADD_BOOKMARK, /* arg1= seekpoint_t * res=can fail */
332 INPUT_CHANGE_BOOKMARK, /* arg1= seekpoint_t * arg2= int * res=can fail */
333 INPUT_DEL_BOOKMARK, /* arg1= seekpoint_t * res=can fail */
334 INPUT_SET_BOOKMARK, /* arg1= int res=can fail */
337 VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
338 VLC_EXPORT( int, input_Control, ( input_thread_t *, int i_query, ... ) );
341 VLC_EXPORT( decoder_t *, input_DecoderNew, ( input_thread_t *, es_format_t *, vlc_bool_t b_force_decoder ) );
342 VLC_EXPORT( void, input_DecoderDelete, ( decoder_t * ) );
343 VLC_EXPORT( void, input_DecoderDecode,( decoder_t *, block_t * ) );