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_id; /**< Identifier of the item */
57 uint8_t i_type; /**< Type (file, disc, ...) */
59 int i_categories; /**< Number of info categories */
60 info_category_t **pp_categories; /**< Pointer to the first info category */
62 int i_es; /**< Number of es format descriptions */
63 es_format_t **es; /**< Pointer to an array of es formats */
65 vlc_mutex_t lock; /**< Item cannot be changed without this lock */
68 #define ITEM_TYPE_UNKNOWN 0
69 #define ITEM_TYPE_FILE 1
70 #define ITEM_TYPE_DIRECTORY 2
71 #define ITEM_TYPE_DISC 3
72 #define ITEM_TYPE_CARD 4
73 #define ITEM_TYPE_NET 5
74 #define ITEM_TYPE_PLAYLIST 6
76 static inline void vlc_input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
78 memset( p_i, 0, sizeof(input_item_t) );
81 p_i->i_categories = 0 ;
84 p_i->ppsz_options = 0;
85 p_i->pp_categories = 0;
87 p_i->i_type = ITEM_TYPE_UNKNOWN;
88 vlc_mutex_init( p_o, &p_i->lock );
91 static inline void vlc_input_item_Clean( input_item_t *p_i )
93 if( p_i->psz_name ) free( p_i->psz_name );
94 if( p_i->psz_uri ) free( p_i->psz_uri );
98 while( p_i->i_options )
101 if( p_i->ppsz_options[p_i->i_options] )
102 free( p_i->ppsz_options[p_i->i_options] );
103 if( !p_i->i_options ) free( p_i->ppsz_options );
109 es_format_Clean( p_i->es[p_i->i_es] );
110 if( !p_i->i_es ) free( p_i->es );
113 while( p_i->i_categories )
115 info_category_t *p_category =
116 p_i->pp_categories[--(p_i->i_categories)];
118 while( p_category->i_infos )
120 p_category->i_infos--;
122 if( p_category->pp_infos[p_category->i_infos]->psz_name )
123 free( p_category->pp_infos[p_category->i_infos]->psz_name);
124 if( p_category->pp_infos[p_category->i_infos]->psz_value )
125 free( p_category->pp_infos[p_category->i_infos]->psz_value );
126 free( p_category->pp_infos[p_category->i_infos] );
128 if( !p_category->i_infos ) free( p_category->pp_infos );
131 if( p_category->psz_name ) free( p_category->psz_name );
134 if( !p_i->i_categories ) free( p_i->pp_categories );
137 vlc_mutex_destroy( &p_i->lock );
140 /*****************************************************************************
141 * Seek point: (generalisation of chapters)
142 *****************************************************************************/
145 int64_t i_byte_offset;
146 int64_t i_time_offset;
150 static inline seekpoint_t *vlc_seekpoint_New( void )
152 seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
153 point->i_byte_offset =
154 point->i_time_offset = 0;
155 point->psz_name = NULL;
159 static inline void vlc_seekpoint_Delete( seekpoint_t *point )
162 if( point->psz_name ) free( point->psz_name );
166 static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src )
168 seekpoint_t *point = vlc_seekpoint_New();
169 if( src->psz_name ) point->psz_name = strdup( src->psz_name );
170 point->i_time_offset = src->i_time_offset;
171 point->i_byte_offset = src->i_byte_offset;
175 /*****************************************************************************
177 *****************************************************************************/
182 vlc_bool_t b_menu; /* Is it a menu or a normal entry */
184 int64_t i_length; /* Length(microsecond) if known, else 0 */
185 int64_t i_size; /* Size (bytes) if known, else 0 */
187 /* Title seekpoint */
189 seekpoint_t **seekpoint;
193 static inline input_title_t *vlc_input_title_New( )
195 input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) );
198 t->b_menu = VLC_FALSE;
207 static inline void vlc_input_title_Delete( input_title_t *t )
213 if( t->psz_name ) free( t->psz_name );
214 for( i = 0; i < t->i_seekpoint; i++ )
216 if( t->seekpoint[i]->psz_name ) free( t->seekpoint[i]->psz_name );
217 free( t->seekpoint[i] );
219 if( t->seekpoint ) free( t->seekpoint );
223 static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
225 input_title_t *dup = vlc_input_title_New( );
228 if( t->psz_name ) dup->psz_name = strdup( t->psz_name );
229 dup->b_menu = t->b_menu;
230 dup->i_length = t->i_length;
231 dup->i_size = t->i_size;
232 dup->i_seekpoint = t->i_seekpoint;
233 if( t->i_seekpoint > 0 )
235 dup->seekpoint = (seekpoint_t**)calloc( t->i_seekpoint,
236 sizeof(seekpoint_t*) );
238 for( i = 0; i < t->i_seekpoint; i++ )
240 dup->seekpoint[i] = vlc_seekpoint_Duplicate( t->seekpoint[i] );
247 /*****************************************************************************
248 * input defines/constants.
249 *****************************************************************************/
260 /* "rate" default, min/max */
261 #define INPUT_RATE_DEFAULT 1000
262 #define INPUT_RATE_MIN 125 /* Up to 8/1 */
263 #define INPUT_RATE_MAX 8000 /* Up to 1/8 */
265 /* input_source_t: gathers all information per input source */
268 /* Input item description */
269 input_item_t *p_item;
271 /* Access/Stream/Demux plugins */
276 /* Title infos for that input */
277 vlc_bool_t b_title_demux; /* Titles/Seekpoints provided by demux */
279 input_title_t **title;
282 int i_seekpoint_offset;
286 int i_seekpoint_start;
290 vlc_bool_t b_can_pace_control;
291 vlc_bool_t b_can_pause;
292 vlc_bool_t b_eof; /* eof of demuxer */
294 /* Clock average variation */
299 /* i_update field of access_t/demux_t */
300 #define INPUT_UPDATE_NONE 0x0000
301 #define INPUT_UPDATE_SIZE 0x0001
302 #define INPUT_UPDATE_TITLE 0x0010
303 #define INPUT_UPDATE_SEEKPOINT 0x0020
304 #define INPUT_UPDATE_META 0x0040
306 /* Input control XXX: internal */
307 #define INPUT_CONTROL_FIFO_SIZE 100
309 /*****************************************************************************
311 *****************************************************************************
312 * XXX: this strucrures is *PRIVATE* so nobody can touch it out of src/input.
313 * I plan to move it to src/input/input_internal.h anyway
315 * XXX: look at src/input/input.c:input_CreateThread for accessible variables
316 * YOU CANNOT HAVE ACCESS TO THE CONTENT OF input_thread_t except
317 * p_input->input.p_item (and it's only temporary).
318 * XXX: move the docs somewhere (better than src/input )
319 *****************************************************************************/
320 struct input_thread_t
324 /* Global properties */
326 vlc_bool_t b_can_pace_control;
327 vlc_bool_t b_can_pause;
334 int64_t i_start; /* :start-time,0 by default */
335 int64_t i_time; /* Current time */
336 int64_t i_stop; /* :stop-time, 0 if none */
338 /* Title infos FIXME multi-input (not easy) ? */
340 input_title_t **title;
343 int i_seekpoint_offset;
345 /* User bookmarks FIXME won't be easy with multiples input */
347 seekpoint_t **bookmark;
351 sout_instance_t *p_sout; /* XXX Move it to es_out ? */
352 vlc_bool_t b_out_pace_control; /* idem ? */
354 /* Internal caching common for all inputs */
357 /* Main input properties */
358 input_source_t input;
360 /* Slave demuxers (subs, and others) */
362 input_source_t **slave;
364 /* Buffer of pending actions */
365 vlc_mutex_t lock_control;
369 /* XXX: val isn't duplicated so it won't works with string */
372 } control[INPUT_CONTROL_FIFO_SIZE];
375 /*****************************************************************************
377 *****************************************************************************/
378 #define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
379 VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
380 VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
381 VLC_EXPORT( void, input_DestroyThread, ( input_thread_t * ) );
385 /* input variable "position" */
386 INPUT_GET_POSITION, /* arg1= double * res= */
387 INPUT_SET_POSITION, /* arg1= double res=can fail */
389 /* input variable "length" */
390 INPUT_GET_LENGTH, /* arg1= int64_t * res=can fail */
392 /* input variable "time" */
393 INPUT_GET_TIME, /* arg1= int64_t * res= */
394 INPUT_SET_TIME, /* arg1= int64_t res=can fail */
396 /* input variable "rate" (1 is DEFAULT_RATE) */
397 INPUT_GET_RATE, /* arg1= int * res= */
398 INPUT_SET_RATE, /* arg1= int res=can fail */
400 /* input variable "state" */
401 INPUT_GET_STATE, /* arg1= int * res= */
402 INPUT_SET_STATE, /* arg1= int res=can fail */
404 /* input variable "audio-delay" and "spu-delay" */
405 INPUT_GET_AUDIO_DELAY, /* arg1 = int* res=can fail */
406 INPUT_SET_AUDIO_DELAY, /* arg1 = int res=can fail */
407 INPUT_GET_SPU_DELAY, /* arg1 = int* res=can fail */
408 INPUT_SET_SPU_DELAY, /* arg1 = int res=can fail */
411 INPUT_ADD_INFO, /* arg1= char * arg2= char * arg3=... res=can fail */
412 INPUT_GET_INFO, /* arg1= char * arg2= char * arg3= char ** res=can fail*/
413 INPUT_SET_NAME, /* arg1= char * res=can fail */
415 /* Input config options */
416 INPUT_ADD_OPTION, /* arg1= char * arg2= char * res=can fail*/
418 /* Input properties */
419 INPUT_GET_BYTE_POSITION, /* arg1= int64_t * res= */
420 INPUT_SET_BYTE_SIZE, /* arg1= int64_t * res= */
423 INPUT_GET_BOOKMARKS, /* arg1= seekpoint_t *** arg2= int * res=can fail */
424 INPUT_CLEAR_BOOKMARKS, /* res=can fail */
425 INPUT_ADD_BOOKMARK, /* arg1= seekpoint_t * res=can fail */
426 INPUT_CHANGE_BOOKMARK, /* arg1= seekpoint_t * arg2= int * res=can fail */
427 INPUT_DEL_BOOKMARK, /* arg1= seekpoint_t * res=can fail */
428 INPUT_SET_BOOKMARK, /* arg1= int res=can fail */
431 VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
432 VLC_EXPORT( int, input_Control, ( input_thread_t *, int i_query, ... ) );
434 VLC_EXPORT( decoder_t *, input_DecoderNew, ( input_thread_t *, es_format_t *, vlc_bool_t b_force_decoder ) );
435 VLC_EXPORT( void, input_DecoderDelete, ( decoder_t * ) );
436 VLC_EXPORT( void, input_DecoderDecode,( decoder_t *, block_t * ) );