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 const char * psz_value;
00049
00050 if( !p_meta )
00051 return;
00052
00053 if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_GAIN")) ||
00054 (psz_value = vlc_meta_GetExtra(p_meta, "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 = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_PEAK" )) ||
00060 (psz_value = vlc_meta_GetExtra(p_meta, "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 = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_GAIN" )) ||
00066 (psz_value = vlc_meta_GetExtra(p_meta, "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 = vlc_meta_GetExtra(p_meta, "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( const 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( const 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_error;
00271 bool b_eof;
00272 bool b_preparsing;
00273 bool b_dead;
00274
00275
00276
00277 input_thread_private_t *p;
00278 };
00279
00280
00281
00282
00283
00284 #define INPUT_RECORD_PREFIX "vlc-record-%Y-%m-%d-%Hh%Mm%Ss-$ N-$ p"
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
00335 typedef enum input_state_e
00336 {
00337 INIT_S = 0,
00338 OPENING_S,
00339 PLAYING_S,
00340 PAUSE_S,
00341 END_S,
00342 ERROR_S,
00343 } input_state_e;
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 #define INPUT_RATE_DEFAULT 1000
00362
00363
00364
00365 #define INPUT_RATE_MIN 32
00366
00367
00368
00369 #define INPUT_RATE_MAX 32000
00370
00371
00372
00373
00374
00375
00376
00377 typedef enum input_event_type_e
00378 {
00379
00380 INPUT_EVENT_STATE,
00381
00382 INPUT_EVENT_DEAD,
00383
00384 INPUT_EVENT_ABORT,
00385
00386
00387 INPUT_EVENT_RATE,
00388
00389
00390 INPUT_EVENT_POSITION,
00391
00392
00393 INPUT_EVENT_LENGTH,
00394
00395
00396
00397 INPUT_EVENT_TITLE,
00398
00399 INPUT_EVENT_CHAPTER,
00400
00401
00402
00403 INPUT_EVENT_PROGRAM,
00404
00405 INPUT_EVENT_ES,
00406
00407 INPUT_EVENT_TELETEXT,
00408
00409
00410 INPUT_EVENT_RECORD,
00411
00412
00413 INPUT_EVENT_ITEM_META,
00414
00415 INPUT_EVENT_ITEM_INFO,
00416
00417 INPUT_EVENT_ITEM_NAME,
00418
00419 INPUT_EVENT_ITEM_EPG,
00420
00421
00422 INPUT_EVENT_STATISTICS,
00423
00424 INPUT_EVENT_SIGNAL,
00425
00426
00427 INPUT_EVENT_AUDIO_DELAY,
00428
00429 INPUT_EVENT_SUBTITLE_DELAY,
00430
00431
00432 INPUT_EVENT_BOOKMARK,
00433
00434
00435 INPUT_EVENT_CACHE,
00436
00437
00438 INPUT_EVENT_AOUT,
00439
00440 INPUT_EVENT_VOUT,
00441
00442 } input_event_type_e;
00443
00444
00445
00446
00447 enum input_query_e
00448 {
00449
00450 INPUT_GET_POSITION,
00451 INPUT_SET_POSITION,
00452
00453
00454 INPUT_GET_LENGTH,
00455
00456
00457 INPUT_GET_TIME,
00458 INPUT_SET_TIME,
00459
00460
00461 INPUT_GET_RATE,
00462 INPUT_SET_RATE,
00463
00464
00465 INPUT_GET_STATE,
00466 INPUT_SET_STATE,
00467
00468
00469 INPUT_GET_AUDIO_DELAY,
00470 INPUT_SET_AUDIO_DELAY,
00471 INPUT_GET_SPU_DELAY,
00472 INPUT_SET_SPU_DELAY,
00473
00474
00475 INPUT_ADD_INFO,
00476 INPUT_REPLACE_INFOS,
00477 INPUT_MERGE_INFOS,
00478 INPUT_GET_INFO,
00479 INPUT_DEL_INFO,
00480 INPUT_SET_NAME,
00481
00482
00483 INPUT_ADD_OPTION,
00484
00485
00486 INPUT_GET_VIDEO_FPS,
00487
00488
00489 INPUT_GET_BOOKMARK,
00490 INPUT_GET_BOOKMARKS,
00491 INPUT_CLEAR_BOOKMARKS,
00492 INPUT_ADD_BOOKMARK,
00493 INPUT_CHANGE_BOOKMARK,
00494 INPUT_DEL_BOOKMARK,
00495 INPUT_SET_BOOKMARK,
00496
00497
00498 INPUT_GET_ATTACHMENTS,
00499 INPUT_GET_ATTACHMENT,
00500
00501
00502 INPUT_ADD_SLAVE,
00503 INPUT_ADD_SUBTITLE,
00504
00505
00506 INPUT_SET_RECORD_STATE,
00507 INPUT_GET_RECORD_STATE,
00508
00509
00510 INPUT_RESTART_ES,
00511
00512
00513
00514 INPUT_GET_AOUT,
00515 INPUT_GET_VOUTS,
00516 INPUT_GET_ES_OBJECTS,
00517
00518
00519 INPUT_GET_PCR_SYSTEM,
00520 INPUT_MODIFY_PCR_SYSTEM,
00521 };
00522
00523
00524
00525
00526
00527
00528
00529 VLC_EXPORT( input_thread_t *, input_Create, ( vlc_object_t *p_parent, input_item_t *, const char *psz_log, input_resource_t * ) LIBVLC_USED );
00530 #define input_Create(a,b,c,d) input_Create(VLC_OBJECT(a),b,c,d)
00531
00532 VLC_EXPORT( input_thread_t *, input_CreateAndStart, ( vlc_object_t *p_parent, input_item_t *, const char *psz_log ) LIBVLC_USED );
00533 #define input_CreateAndStart(a,b,c) input_CreateAndStart(VLC_OBJECT(a),b,c)
00534
00535 VLC_EXPORT( int, input_Start, ( input_thread_t * ) );
00536
00537 VLC_EXPORT( void, input_Stop, ( input_thread_t *, bool b_abort ) );
00538
00539 VLC_EXPORT( int, input_Read, ( vlc_object_t *, input_item_t * ) );
00540 #define input_Read(a,b) input_Read(VLC_OBJECT(a),b)
00541
00542 VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
00543
00544 VLC_EXPORT( int, input_Control, ( input_thread_t *, int i_query, ... ) );
00545
00546
00547
00548
00549
00550
00551
00552 VLC_EXPORT( input_item_t*, input_GetItem, ( input_thread_t * ) LIBVLC_USED );
00553
00554
00555
00556
00557
00558 static inline input_state_e input_GetState( input_thread_t * p_input )
00559 {
00560 input_state_e state = INIT_S;
00561 input_Control( p_input, INPUT_GET_STATE, &state );
00562 return state;
00563 }
00564
00565
00566
00567
00568 static inline int input_AddSubtitle( input_thread_t *p_input, const char *psz_url, bool b_check_extension )
00569 {
00570 return input_Control( p_input, INPUT_ADD_SUBTITLE, psz_url, b_check_extension );
00571 }
00572
00573
00574
00575
00576
00577
00578
00579
00580 static inline vout_thread_t *input_GetVout( input_thread_t *p_input )
00581 {
00582 vout_thread_t **pp_vout, *p_vout;
00583 size_t i_vout;
00584
00585 if( input_Control( p_input, INPUT_GET_VOUTS, &pp_vout, &i_vout ) )
00586 return NULL;
00587
00588 for( size_t i = 1; i < i_vout; i++ )
00589 vlc_object_release( (vlc_object_t *)(pp_vout[i]) );
00590
00591 p_vout = (i_vout >= 1) ? pp_vout[0] : NULL;
00592 free( pp_vout );
00593 return p_vout;
00594 }
00595
00596
00597
00598
00599
00600
00601
00602 static inline aout_instance_t *input_GetAout( input_thread_t *p_input )
00603 {
00604 aout_instance_t *p_aout;
00605 return input_Control( p_input, INPUT_GET_AOUT, &p_aout ) ? NULL : p_aout;
00606 }
00607
00608
00609
00610
00611
00612
00613
00614 static inline int input_GetEsObjects( input_thread_t *p_input, int i_id,
00615 vlc_object_t **pp_decoder,
00616 vout_thread_t **pp_vout, aout_instance_t **pp_aout )
00617 {
00618 return input_Control( p_input, INPUT_GET_ES_OBJECTS, i_id,
00619 pp_decoder, pp_vout, pp_aout );
00620 }
00621
00622
00623
00624
00625 static inline int input_GetPcrSystem( input_thread_t *p_input, mtime_t *pi_system, mtime_t *pi_delay )
00626 {
00627 return input_Control( p_input, INPUT_GET_PCR_SYSTEM, pi_system, pi_delay );
00628 }
00629
00630
00631
00632 static inline int input_ModifyPcrSystem( input_thread_t *p_input, bool b_absolute, mtime_t i_system )
00633 {
00634 return input_Control( p_input, INPUT_MODIFY_PCR_SYSTEM, b_absolute, i_system );
00635 }
00636
00637
00638 typedef struct input_clock_t input_clock_t;
00639 VLC_EXPORT( decoder_t *, input_DecoderNew, ( input_thread_t *, es_format_t *, input_clock_t *, sout_instance_t * ) LIBVLC_USED );
00640 VLC_EXPORT( void, input_DecoderDelete, ( decoder_t * ) );
00641 VLC_EXPORT( void, input_DecoderDecode,( decoder_t *, block_t *, bool b_do_pace ) );
00642
00643
00644
00645
00646
00647
00648
00649
00650 VLC_EXPORT( void, input_SplitMRL, ( const char **ppsz_access, const char **ppsz_demux, char **ppsz_path, char *psz_dup ) );
00651
00652
00653
00654
00655 VLC_EXPORT( char *, input_CreateFilename, ( vlc_object_t *, const char *psz_path, const char *psz_prefix, const char *psz_extension ) LIBVLC_USED );
00656
00657
00658
00659
00660
00661
00662
00663 VLC_EXPORT( input_resource_t *, input_resource_New, ( vlc_object_t * ) LIBVLC_USED );
00664
00665
00666
00667
00668 VLC_EXPORT(void, input_resource_Release, ( input_resource_t * ) );
00669
00670
00671
00672
00673 VLC_EXPORT(void, input_resource_TerminateVout, ( input_resource_t * ) );
00674
00675
00676
00677
00678 VLC_EXPORT( void, input_resource_Terminate, ( input_resource_t * ) );
00679
00680 #endif