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
00033
00034 #include <vlc_es.h>
00035 #include <vlc_meta.h>
00036 #include <vlc_epg.h>
00037 #include <vlc_events.h>
00038 #include <vlc_input_item.h>
00039
00040 #include <string.h>
00041
00042
00043
00044
00045 static inline void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
00046 const vlc_meta_t *p_meta )
00047 {
00048 char * psz_value;
00049
00050 if( !p_meta )
00051 return;
00052
00053 if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_TRACK_GAIN" )) ||
00054 (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_RADIO" )) )
00055 {
00056 p_dst->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
00057 p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
00058 }
00059 else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_TRACK_PEAK" )) ||
00060 (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_PEAK" )) )
00061 {
00062 p_dst->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
00063 p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
00064 }
00065 else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_ALBUM_GAIN" )) ||
00066 (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_AUDIOPHILE" )) )
00067 {
00068 p_dst->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
00069 p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
00070 }
00071 else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_ALBUM_PEAK" )) )
00072 {
00073 p_dst->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
00074 p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
00075 }
00076 }
00077
00078
00079
00080
00081 struct seekpoint_t
00082 {
00083 int64_t i_byte_offset;
00084 int64_t i_time_offset;
00085 char *psz_name;
00086 int i_level;
00087 };
00088
00089 static inline seekpoint_t *vlc_seekpoint_New( void )
00090 {
00091 seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
00092 point->i_byte_offset =
00093 point->i_time_offset = -1;
00094 point->i_level = 0;
00095 point->psz_name = NULL;
00096 return point;
00097 }
00098
00099 static inline void vlc_seekpoint_Delete( seekpoint_t *point )
00100 {
00101 if( !point ) return;
00102 free( point->psz_name );
00103 free( point );
00104 }
00105
00106 static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src )
00107 {
00108 seekpoint_t *point = vlc_seekpoint_New();
00109 if( src->psz_name ) point->psz_name = strdup( src->psz_name );
00110 point->i_time_offset = src->i_time_offset;
00111 point->i_byte_offset = src->i_byte_offset;
00112 return point;
00113 }
00114
00115
00116
00117
00118 typedef struct
00119 {
00120 char *psz_name;
00121
00122 bool b_menu;
00123
00124 int64_t i_length;
00125 int64_t i_size;
00126
00127
00128 int i_seekpoint;
00129 seekpoint_t **seekpoint;
00130
00131 } input_title_t;
00132
00133 static inline input_title_t *vlc_input_title_New(void)
00134 {
00135 input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) );
00136
00137 t->psz_name = NULL;
00138 t->b_menu = false;
00139 t->i_length = 0;
00140 t->i_size = 0;
00141 t->i_seekpoint = 0;
00142 t->seekpoint = NULL;
00143
00144 return t;
00145 }
00146
00147 static inline void vlc_input_title_Delete( input_title_t *t )
00148 {
00149 int i;
00150 if( t == NULL )
00151 return;
00152
00153 free( t->psz_name );
00154 for( i = 0; i < t->i_seekpoint; i++ )
00155 {
00156 free( t->seekpoint[i]->psz_name );
00157 free( t->seekpoint[i] );
00158 }
00159 free( t->seekpoint );
00160 free( t );
00161 }
00162
00163 static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
00164 {
00165 input_title_t *dup = vlc_input_title_New( );
00166 int i;
00167
00168 if( t->psz_name ) dup->psz_name = strdup( t->psz_name );
00169 dup->b_menu = t->b_menu;
00170 dup->i_length = t->i_length;
00171 dup->i_size = t->i_size;
00172 dup->i_seekpoint = t->i_seekpoint;
00173 if( t->i_seekpoint > 0 )
00174 {
00175 dup->seekpoint = (seekpoint_t**)calloc( t->i_seekpoint,
00176 sizeof(seekpoint_t*) );
00177
00178 for( i = 0; i < t->i_seekpoint; i++ )
00179 {
00180 dup->seekpoint[i] = vlc_seekpoint_Duplicate( t->seekpoint[i] );
00181 }
00182 }
00183
00184 return dup;
00185 }
00186
00187
00188
00189
00190 struct input_attachment_t
00191 {
00192 char *psz_name;
00193 char *psz_mime;
00194 char *psz_description;
00195
00196 int i_data;
00197 void *p_data;
00198 };
00199
00200 static inline input_attachment_t *vlc_input_attachment_New( const char *psz_name,
00201 const char *psz_mime,
00202 const char *psz_description,
00203 const void *p_data,
00204 int i_data )
00205 {
00206 input_attachment_t *a =
00207 (input_attachment_t*)malloc( sizeof(input_attachment_t) );
00208 if( !a )
00209 return NULL;
00210 a->psz_name = strdup( psz_name ? psz_name : "" );
00211 a->psz_mime = strdup( psz_mime ? psz_mime : "" );
00212 a->psz_description = strdup( psz_description ? psz_description : "" );
00213 a->i_data = i_data;
00214 a->p_data = NULL;
00215 if( i_data > 0 )
00216 {
00217 a->p_data = malloc( i_data );
00218 if( a->p_data && p_data )
00219 memcpy( a->p_data, p_data, i_data );
00220 }
00221 return a;
00222 }
00223 static inline input_attachment_t *vlc_input_attachment_Duplicate( const input_attachment_t *a )
00224 {
00225 return vlc_input_attachment_New( a->psz_name, a->psz_mime, a->psz_description,
00226 a->p_data, a->i_data );
00227 }
00228 static inline void vlc_input_attachment_Delete( input_attachment_t *a )
00229 {
00230 if( !a )
00231 return;
00232 free( a->psz_name );
00233 free( a->psz_mime );
00234 free( a->psz_description );
00235 free( a->p_data );
00236 free( a );
00237 }
00238
00239
00240
00241
00242
00243
00244 #define INPUT_UPDATE_NONE 0x0000
00245 #define INPUT_UPDATE_SIZE 0x0001
00246 #define INPUT_UPDATE_TITLE 0x0010
00247 #define INPUT_UPDATE_SEEKPOINT 0x0020
00248 #define INPUT_UPDATE_META 0x0040
00249 #define INPUT_UPDATE_SIGNAL 0x0080
00250
00251
00252
00253
00254 typedef struct input_thread_private_t input_thread_private_t;
00255
00256
00257
00258
00259 typedef struct input_resource_t input_resource_t;
00260
00261
00262
00263
00264
00265
00266 struct input_thread_t
00267 {
00268 VLC_COMMON_MEMBERS;
00269
00270 bool b_eof;
00271 bool b_preparsing;
00272 bool b_dead;
00273
00274
00275
00276 input_thread_private_t *p;
00277 };
00278
00279
00280
00281
00282
00283 #define INPUT_RECORD_PREFIX "vlc-record-%Y-%m-%d-%Hh%Mm%Ss-$ N-$ p"
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 typedef enum input_state_e
00335 {
00336 INIT_S = 0,
00337 OPENING_S,
00338 PLAYING_S,
00339 PAUSE_S,
00340 END_S,
00341 ERROR_S,
00342 } input_state_e;
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 #define INPUT_RATE_DEFAULT 1000
00359
00360
00361
00362 #define INPUT_RATE_MIN 32
00363
00364
00365
00366 #define INPUT_RATE_MAX 32000
00367
00368
00369
00370
00371
00372
00373
00374 typedef enum input_event_type_e
00375 {
00376
00377 INPUT_EVENT_STATE,
00378
00379 INPUT_EVENT_DEAD,
00380
00381 INPUT_EVENT_ABORT,
00382
00383
00384 INPUT_EVENT_RATE,
00385
00386
00387 INPUT_EVENT_POSITION,
00388
00389
00390 INPUT_EVENT_LENGTH,
00391
00392
00393
00394 INPUT_EVENT_TITLE,
00395
00396 INPUT_EVENT_CHAPTER,
00397
00398
00399
00400 INPUT_EVENT_PROGRAM,
00401
00402 INPUT_EVENT_ES,
00403
00404 INPUT_EVENT_TELETEXT,
00405
00406
00407 INPUT_EVENT_RECORD,
00408
00409
00410 INPUT_EVENT_ITEM_META,
00411
00412 INPUT_EVENT_ITEM_INFO,
00413
00414 INPUT_EVENT_ITEM_NAME,
00415
00416
00417 INPUT_EVENT_STATISTICS,
00418
00419 INPUT_EVENT_SIGNAL,
00420
00421
00422 INPUT_EVENT_AUDIO_DELAY,
00423
00424 INPUT_EVENT_SUBTITLE_DELAY,
00425
00426
00427 INPUT_EVENT_BOOKMARK,
00428
00429
00430 INPUT_EVENT_CACHE,
00431
00432
00433 INPUT_EVENT_AOUT,
00434
00435 INPUT_EVENT_VOUT,
00436
00437 } input_event_type_e;
00438
00439
00440
00441
00442 enum input_query_e
00443 {
00444
00445 INPUT_GET_POSITION,
00446 INPUT_SET_POSITION,
00447
00448
00449 INPUT_GET_LENGTH,
00450
00451
00452 INPUT_GET_TIME,
00453 INPUT_SET_TIME,
00454
00455
00456 INPUT_GET_RATE,
00457 INPUT_SET_RATE,
00458
00459
00460 INPUT_GET_STATE,
00461 INPUT_SET_STATE,
00462
00463
00464 INPUT_GET_AUDIO_DELAY,
00465 INPUT_SET_AUDIO_DELAY,
00466 INPUT_GET_SPU_DELAY,
00467 INPUT_SET_SPU_DELAY,
00468
00469
00470 INPUT_ADD_INFO,
00471 INPUT_GET_INFO,
00472 INPUT_DEL_INFO,
00473 INPUT_SET_NAME,
00474
00475
00476 INPUT_ADD_OPTION,
00477
00478
00479 INPUT_GET_VIDEO_FPS,
00480
00481
00482 INPUT_GET_BOOKMARK,
00483 INPUT_GET_BOOKMARKS,
00484 INPUT_CLEAR_BOOKMARKS,
00485 INPUT_ADD_BOOKMARK,
00486 INPUT_CHANGE_BOOKMARK,
00487 INPUT_DEL_BOOKMARK,
00488 INPUT_SET_BOOKMARK,
00489
00490
00491 INPUT_GET_ATTACHMENTS,
00492 INPUT_GET_ATTACHMENT,
00493
00494
00495 INPUT_ADD_SLAVE,
00496 INPUT_ADD_SUBTITLE,
00497
00498
00499 INPUT_SET_RECORD_STATE,
00500 INPUT_GET_RECORD_STATE,
00501
00502
00503 INPUT_RESTART_ES,
00504
00505
00506
00507 INPUT_GET_AOUT,
00508 INPUT_GET_VOUTS,
00509 };
00510
00511
00512
00513
00514
00515
00516
00517 #define input_Create(a,b,c,d) __input_Create(VLC_OBJECT(a),b,c,d)
00518 VLC_EXPORT( input_thread_t *, __input_Create, ( vlc_object_t *p_parent, input_item_t *, const char *psz_log, input_resource_t * ) );
00519
00520 #define input_CreateAndStart(a,b,c) __input_CreateAndStart(VLC_OBJECT(a),b,c)
00521 VLC_EXPORT( input_thread_t *, __input_CreateAndStart, ( vlc_object_t *p_parent, input_item_t *, const char *psz_log ) );
00522
00523 VLC_EXPORT( int, input_Start, ( input_thread_t * ) );
00524
00525 VLC_EXPORT( void, input_Stop, ( input_thread_t *, bool b_abort ) );
00526
00527 #define input_Read(a,b) __input_Read(VLC_OBJECT(a),b)
00528 VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t * ) );
00529
00530 VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
00531
00532 VLC_EXPORT( int, input_Control, ( input_thread_t *, int i_query, ... ) );
00533
00534
00535
00536
00537
00538
00539
00540 VLC_EXPORT( input_item_t*, input_GetItem, ( input_thread_t * ) );
00541
00542
00543
00544
00545
00546 static inline input_state_e input_GetState( input_thread_t * p_input )
00547 {
00548 input_state_e state = INIT_S;
00549 input_Control( p_input, INPUT_GET_STATE, &state );
00550 return state;
00551 }
00552
00553
00554
00555
00556 static inline int input_AddSubtitle( input_thread_t *p_input, const char *psz_url, bool b_check_extension )
00557 {
00558 return input_Control( p_input, INPUT_ADD_SUBTITLE, psz_url, b_check_extension );
00559 }
00560
00561
00562
00563
00564
00565
00566
00567
00568 static inline vout_thread_t *input_GetVout( input_thread_t *p_input )
00569 {
00570 vout_thread_t **pp_vout, *p_vout;
00571 size_t i_vout;
00572
00573 if( input_Control( p_input, INPUT_GET_VOUTS, &pp_vout, &i_vout ) )
00574 return NULL;
00575
00576 for( size_t i = 1; i < i_vout; i++ )
00577 vlc_object_release( (vlc_object_t *)(pp_vout[i]) );
00578
00579 p_vout = (i_vout >= 1) ? pp_vout[0] : NULL;
00580 free( pp_vout );
00581 return p_vout;
00582 }
00583
00584
00585
00586
00587
00588
00589
00590 static inline aout_instance_t *input_GetAout( input_thread_t *p_input )
00591 {
00592 aout_instance_t *p_aout;
00593 return input_Control( p_input, INPUT_GET_AOUT, &p_aout ) ? NULL : p_aout;
00594 }
00595
00596
00597 typedef struct input_clock_t input_clock_t;
00598 VLC_EXPORT( decoder_t *, input_DecoderNew, ( input_thread_t *, es_format_t *, input_clock_t *, sout_instance_t * ) );
00599 VLC_EXPORT( void, input_DecoderDelete, ( decoder_t * ) );
00600 VLC_EXPORT( void, input_DecoderDecode,( decoder_t *, block_t *, bool b_do_pace ) );
00601
00602
00603
00604
00605
00606
00607
00608
00609 VLC_EXPORT( void, input_SplitMRL, ( const char **ppsz_access, const char **ppsz_demux, char **ppsz_path, char *psz_dup ) );
00610
00611
00612
00613
00614 VLC_EXPORT( char *, input_CreateFilename, ( vlc_object_t *, const char *psz_path, const char *psz_prefix, const char *psz_extension ) );
00615
00616
00617
00618
00619
00620
00621
00622
00623 VLC_EXPORT(input_resource_t *, input_DetachResource, ( input_thread_t * ) );
00624
00625
00626
00627
00628 VLC_EXPORT(void, input_resource_Delete, ( input_resource_t * ) );
00629
00630 #endif