00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _VLC__INPUT_H
00027 #define _VLC__INPUT_H 1
00028
00029
00030
00031
00032 struct info_t
00033 {
00034 char *psz_name;
00035 char *psz_value;
00036 };
00037
00038 struct info_category_t
00039 {
00040 char *psz_name;
00041 int i_infos;
00042 struct info_t **pp_infos;
00043 };
00044
00045 struct input_item_t
00046 {
00047 char *psz_name;
00048 char *psz_uri;
00050 int i_options;
00051 char **ppsz_options;
00053 mtime_t i_duration;
00056 int i_id;
00057 uint8_t i_type;
00059 int i_categories;
00060 info_category_t **pp_categories;
00062 int i_es;
00063 es_format_t **es;
00065 vlc_bool_t b_fixed_name;
00067 vlc_mutex_t lock;
00068 };
00069
00070 #define ITEM_TYPE_UNKNOWN 0
00071 #define ITEM_TYPE_AFILE 1
00072 #define ITEM_TYPE_VFILE 2
00073 #define ITEM_TYPE_DIRECTORY 3
00074 #define ITEM_TYPE_DISC 4
00075 #define ITEM_TYPE_CDDA 5
00076 #define ITEM_TYPE_CARD 6
00077 #define ITEM_TYPE_NET 7
00078 #define ITEM_TYPE_PLAYLIST 8
00079 #define ITEM_TYPE_NODE 9
00080
00081 static inline void vlc_input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
00082 {
00083 memset( p_i, 0, sizeof(input_item_t) );
00084 p_i->i_options = 0;
00085 p_i->i_es = 0;
00086 p_i->i_categories = 0 ;
00087 p_i->psz_name = 0;
00088 p_i->psz_uri = 0;
00089 p_i->ppsz_options = 0;
00090 p_i->pp_categories = 0;
00091 p_i->es = 0;
00092 p_i->i_type = ITEM_TYPE_UNKNOWN;
00093 p_i->b_fixed_name = VLC_TRUE;
00094 vlc_mutex_init( p_o, &p_i->lock );
00095 }
00096
00097 static inline void vlc_input_item_CopyOptions( input_item_t *p_parent,
00098 input_item_t *p_child )
00099 {
00100 int i;
00101 for( i = 0 ; i< p_parent->i_options; i++ )
00102 {
00103 char *psz_option= strdup( p_parent->ppsz_options[i] );
00104 p_child->i_options++;
00105 p_child->ppsz_options = (char **)realloc( p_child->ppsz_options,
00106 p_child->i_options *
00107 sizeof( char * ) );
00108 p_child->ppsz_options[p_child->i_options-1] = psz_option;
00109 }
00110 }
00111
00112 static inline void vlc_input_item_Clean( input_item_t *p_i )
00113 {
00114 if( p_i->psz_name ) free( p_i->psz_name );
00115 if( p_i->psz_uri ) free( p_i->psz_uri );
00116 p_i->psz_name = 0;
00117 p_i->psz_uri = 0;
00118
00119 while( p_i->i_options )
00120 {
00121 p_i->i_options--;
00122 if( p_i->ppsz_options[p_i->i_options] )
00123 free( p_i->ppsz_options[p_i->i_options] );
00124 if( !p_i->i_options ) free( p_i->ppsz_options );
00125 }
00126
00127 while( p_i->i_es )
00128 {
00129 p_i->i_es--;
00130 es_format_Clean( p_i->es[p_i->i_es] );
00131 if( !p_i->i_es ) free( p_i->es );
00132 }
00133
00134 while( p_i->i_categories )
00135 {
00136 info_category_t *p_category =
00137 p_i->pp_categories[--(p_i->i_categories)];
00138
00139 while( p_category->i_infos )
00140 {
00141 p_category->i_infos--;
00142
00143 if( p_category->pp_infos[p_category->i_infos]->psz_name )
00144 free( p_category->pp_infos[p_category->i_infos]->psz_name);
00145 if( p_category->pp_infos[p_category->i_infos]->psz_value )
00146 free( p_category->pp_infos[p_category->i_infos]->psz_value );
00147 free( p_category->pp_infos[p_category->i_infos] );
00148
00149 if( !p_category->i_infos ) free( p_category->pp_infos );
00150 }
00151
00152 if( p_category->psz_name ) free( p_category->psz_name );
00153 free( p_category );
00154
00155 if( !p_i->i_categories ) free( p_i->pp_categories );
00156 }
00157
00158 vlc_mutex_destroy( &p_i->lock );
00159 }
00160
00161 VLC_EXPORT( char *, vlc_input_item_GetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
00162 VLC_EXPORT(int, vlc_input_item_AddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) );
00163
00164
00165
00166
00167 struct seekpoint_t
00168 {
00169 int64_t i_byte_offset;
00170 int64_t i_time_offset;
00171 char *psz_name;
00172 int i_level;
00173 };
00174
00175 static inline seekpoint_t *vlc_seekpoint_New( void )
00176 {
00177 seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
00178 point->i_byte_offset =
00179 point->i_time_offset = -1;
00180 point->i_level = 0;
00181 point->psz_name = NULL;
00182 return point;
00183 }
00184
00185 static inline void vlc_seekpoint_Delete( seekpoint_t *point )
00186 {
00187 if( !point ) return;
00188 if( point->psz_name ) free( point->psz_name );
00189 free( point );
00190 }
00191
00192 static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src )
00193 {
00194 seekpoint_t *point = vlc_seekpoint_New();
00195 if( src->psz_name ) point->psz_name = strdup( src->psz_name );
00196 point->i_time_offset = src->i_time_offset;
00197 point->i_byte_offset = src->i_byte_offset;
00198 return point;
00199 }
00200
00201
00202
00203
00204 typedef struct
00205 {
00206 char *psz_name;
00207
00208 vlc_bool_t b_menu;
00209
00210 int64_t i_length;
00211 int64_t i_size;
00212
00213
00214 int i_seekpoint;
00215 seekpoint_t **seekpoint;
00216
00217 } input_title_t;
00218
00219 static inline input_title_t *vlc_input_title_New( )
00220 {
00221 input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) );
00222
00223 t->psz_name = NULL;
00224 t->b_menu = VLC_FALSE;
00225 t->i_length = 0;
00226 t->i_size = 0;
00227 t->i_seekpoint = 0;
00228 t->seekpoint = NULL;
00229
00230 return t;
00231 }
00232
00233 static inline void vlc_input_title_Delete( input_title_t *t )
00234 {
00235 int i;
00236 if( t == NULL )
00237 return;
00238
00239 if( t->psz_name ) free( t->psz_name );
00240 for( i = 0; i < t->i_seekpoint; i++ )
00241 {
00242 if( t->seekpoint[i]->psz_name ) free( t->seekpoint[i]->psz_name );
00243 free( t->seekpoint[i] );
00244 }
00245 if( t->seekpoint ) free( t->seekpoint );
00246 free( t );
00247 }
00248
00249 static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
00250 {
00251 input_title_t *dup = vlc_input_title_New( );
00252 int i;
00253
00254 if( t->psz_name ) dup->psz_name = strdup( t->psz_name );
00255 dup->b_menu = t->b_menu;
00256 dup->i_length = t->i_length;
00257 dup->i_size = t->i_size;
00258 dup->i_seekpoint = t->i_seekpoint;
00259 if( t->i_seekpoint > 0 )
00260 {
00261 dup->seekpoint = (seekpoint_t**)calloc( t->i_seekpoint,
00262 sizeof(seekpoint_t*) );
00263
00264 for( i = 0; i < t->i_seekpoint; i++ )
00265 {
00266 dup->seekpoint[i] = vlc_seekpoint_Duplicate( t->seekpoint[i] );
00267 }
00268 }
00269
00270 return dup;
00271 }
00272
00273
00274
00275
00276
00277
00278 enum input_state_e
00279 {
00280 INIT_S,
00281 PLAYING_S,
00282 PAUSE_S,
00283 END_S
00284 };
00285
00286
00287
00288
00289
00290 #define INPUT_RATE_DEFAULT 1000
00291 #define INPUT_RATE_MIN 125
00292 #define INPUT_RATE_MAX 8000
00293
00294
00295 typedef struct
00296 {
00297
00298 input_item_t *p_item;
00299
00300
00301 access_t *p_access;
00302 stream_t *p_stream;
00303 demux_t *p_demux;
00304
00305
00306 vlc_bool_t b_title_demux;
00307 int i_title;
00308 input_title_t **title;
00309
00310 int i_title_offset;
00311 int i_seekpoint_offset;
00312
00313 int i_title_start;
00314 int i_title_end;
00315 int i_seekpoint_start;
00316 int i_seekpoint_end;
00317
00318
00319 vlc_bool_t b_can_pace_control;
00320 vlc_bool_t b_can_pause;
00321 vlc_bool_t b_eof;
00322
00323
00324 int i_cr_average;
00325
00326 } input_source_t;
00327
00328
00329 #define INPUT_UPDATE_NONE 0x0000
00330 #define INPUT_UPDATE_SIZE 0x0001
00331 #define INPUT_UPDATE_TITLE 0x0010
00332 #define INPUT_UPDATE_SEEKPOINT 0x0020
00333 #define INPUT_UPDATE_META 0x0040
00334
00335
00336 #define INPUT_CONTROL_FIFO_SIZE 100
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349 struct input_thread_t
00350 {
00351 VLC_COMMON_MEMBERS
00352
00353
00354 vlc_bool_t b_eof;
00355 vlc_bool_t b_can_pace_control;
00356 vlc_bool_t b_can_pause;
00357
00358
00359 int i_state;
00360 int i_rate;
00361
00362
00363 int64_t i_start;
00364 int64_t i_time;
00365 int64_t i_stop;
00366
00367
00368 int i_title;
00369 input_title_t **title;
00370
00371 int i_title_offset;
00372 int i_seekpoint_offset;
00373
00374
00375 int i_bookmark;
00376 seekpoint_t **bookmark;
00377
00378
00379 vlc_meta_t *p_meta;
00380
00381
00382 es_out_t *p_es_out;
00383 sout_instance_t *p_sout;
00384 vlc_bool_t b_out_pace_control;
00385
00386
00387 int64_t i_pts_delay;
00388
00389
00390 input_source_t input;
00391
00392
00393 int i_slave;
00394 input_source_t **slave;
00395
00396
00397 vlc_mutex_t lock_control;
00398 int i_control;
00399 struct
00400 {
00401
00402 int i_type;
00403 vlc_value_t val;
00404 } control[INPUT_CONTROL_FIFO_SIZE];
00405 };
00406
00407
00408
00409
00410 #define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
00411 VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
00412 #define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b)
00413 VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) );
00414 VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
00415 VLC_EXPORT( void, input_DestroyThread, ( input_thread_t * ) );
00416
00417 enum input_query_e
00418 {
00419
00420 INPUT_GET_POSITION,
00421 INPUT_SET_POSITION,
00422
00423
00424 INPUT_GET_LENGTH,
00425
00426
00427 INPUT_GET_TIME,
00428 INPUT_SET_TIME,
00429
00430
00431 INPUT_GET_RATE,
00432 INPUT_SET_RATE,
00433
00434
00435 INPUT_GET_STATE,
00436 INPUT_SET_STATE,
00437
00438
00439 INPUT_GET_AUDIO_DELAY,
00440 INPUT_SET_AUDIO_DELAY,
00441 INPUT_GET_SPU_DELAY,
00442 INPUT_SET_SPU_DELAY,
00443
00444
00445 INPUT_ADD_INFO,
00446 INPUT_GET_INFO,
00447 INPUT_DEL_INFO,
00448 INPUT_SET_NAME,
00449
00450
00451 INPUT_ADD_OPTION,
00452
00453
00454 INPUT_GET_BYTE_POSITION,
00455 INPUT_SET_BYTE_SIZE,
00456
00457
00458 INPUT_GET_BOOKMARKS,
00459 INPUT_CLEAR_BOOKMARKS,
00460 INPUT_ADD_BOOKMARK,
00461 INPUT_CHANGE_BOOKMARK,
00462 INPUT_DEL_BOOKMARK,
00463 INPUT_SET_BOOKMARK,
00464
00465
00466 INPUT_ADD_SLAVE
00467 };
00468
00469 VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
00470 VLC_EXPORT( int, input_Control, ( input_thread_t *, int i_query, ... ) );
00471
00472 VLC_EXPORT( decoder_t *, input_DecoderNew, ( input_thread_t *, es_format_t *, vlc_bool_t b_force_decoder ) );
00473 VLC_EXPORT( void, input_DecoderDelete, ( decoder_t * ) );
00474 VLC_EXPORT( void, input_DecoderDecode,( decoder_t *, block_t * ) );
00475
00476 #endif