vlc_input.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_input.h: Core input structures
00003  *****************************************************************************
00004  * Copyright (C) 1999-2006 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Christophe Massiot <massiot@via.ecp.fr>
00008  *          Laurent Aimar <fenrir@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 /* __ is need because conflict with <vlc/input.h> */
00026 #ifndef VLC__INPUT_H
00027 #define VLC__INPUT_H 1
00028 
00029 #include <vlc_es.h>
00030 #include <vlc_meta.h>
00031 #include <vlc_epg.h>
00032 #include <vlc_events.h>
00033 
00034 #include <string.h>                                     /* strcasestr() */
00035 
00036 struct vlc_meta_t;
00037 
00038 /*****************************************************************************
00039  * input_item_t: Describes an input and is used to spawn input_thread_t objects
00040  *****************************************************************************/
00041 struct info_t
00042 {
00043     char *psz_name;            /**< Name of this info */
00044     char *psz_value;           /**< Value of the info */
00045 };
00046 
00047 struct info_category_t
00048 {
00049     char   *psz_name;      /**< Name of this category */
00050     int    i_infos;        /**< Number of infos in the category */
00051     struct info_t **pp_infos;     /**< Pointer to an array of infos */
00052 };
00053 
00054 struct input_item_t
00055 {
00056     VLC_GC_MEMBERS
00057     int        i_id;                 /**< Identifier of the item */
00058 
00059     char       *psz_name;            /**< text describing this item */
00060     char       *psz_uri;             /**< mrl of this item */
00061     bool       b_fixed_name;        /**< Can the interface change the name ?*/
00062 
00063     int        i_options;            /**< Number of input options */
00064     char       **ppsz_options;       /**< Array of input options */
00065     uint8_t    *optflagv;            /**< Some flags of input options */
00066     unsigned   optflagc;
00067 
00068     mtime_t    i_duration;           /**< Duration in milliseconds*/
00069 
00070     uint8_t    i_type;               /**< Type (file, disc, ...) */
00071 
00072     int        i_categories;         /**< Number of info categories */
00073     info_category_t **pp_categories; /**< Pointer to the first info category */
00074 
00075     int         i_es;                /**< Number of es format descriptions */
00076     es_format_t **es;                /**< Es formats */
00077 
00078     input_stats_t *p_stats;          /**< Statistics */
00079     int           i_nb_played;       /**< Number of times played */
00080 
00081     bool          b_error_when_reading;       /**< Error When Reading */
00082 
00083     vlc_meta_t *p_meta;
00084 
00085     vlc_event_manager_t event_manager;
00086 
00087     vlc_mutex_t lock;                 /**< Lock for the item */
00088 };
00089 
00090 #define ITEM_TYPE_UNKNOWN       0
00091 #define ITEM_TYPE_FILE          1
00092 #define ITEM_TYPE_DIRECTORY     2
00093 #define ITEM_TYPE_DISC          3
00094 #define ITEM_TYPE_CDDA          4
00095 #define ITEM_TYPE_CARD          5
00096 #define ITEM_TYPE_NET           6
00097 #define ITEM_TYPE_PLAYLIST      7
00098 #define ITEM_TYPE_NODE          8
00099 #define ITEM_TYPE_NUMBER        9
00100 
00101 static inline void input_ItemCopyOptions( input_item_t *p_parent,
00102                                           input_item_t *p_child )
00103 {
00104     int i;
00105     for( i = 0 ; i< p_parent->i_options; i++ )
00106     {
00107         char *psz_option= strdup( p_parent->ppsz_options[i] );
00108         if( !strcmp( psz_option, "meta-file" ) )
00109         {
00110             free( psz_option );
00111             continue;
00112         }
00113         p_child->i_options++;
00114         p_child->ppsz_options = (char **)realloc( p_child->ppsz_options,
00115                                                   p_child->i_options *
00116                                                   sizeof( char * ) );
00117         p_child->ppsz_options[p_child->i_options-1] = psz_option;
00118         p_child->optflagc++;
00119         p_child->optflagv = (uint8_t *)realloc( p_child->optflagv,
00120                                                 p_child->optflagc );
00121         p_child->optflagv[p_child->optflagc - 1] = p_parent->optflagv[i];
00122     }
00123 }
00124 
00125 static inline void input_item_SetName( input_item_t *p_item, const char *psz_name )
00126 {
00127     free( p_item->psz_name );
00128     p_item->psz_name = strdup( psz_name );
00129 }
00130 
00131 /* This won't hold the item, but can tell to interested third parties
00132  * Like the playlist, that there is a new sub item. With this design
00133  * It is not the input item's responsability to keep all the ref of
00134  * the input item children. */
00135 static inline void input_ItemAddSubItem( input_item_t *p_parent,
00136                                          input_item_t *p_child )
00137 {
00138     vlc_event_t event;
00139 
00140     p_parent->i_type = ITEM_TYPE_PLAYLIST;
00141 
00142     /* Notify interested third parties */
00143     event.type = vlc_InputItemSubItemAdded;
00144     event.u.input_item_subitem_added.p_new_child = p_child;
00145     vlc_event_send( &p_parent->event_manager, &event );
00146 }
00147 
00148 /* Flags handled past input_ItemAddOpt() */
00149 #define VLC_INPUT_OPTION_TRUSTED 0x2
00150 
00151 /* Flags handled within input_ItemAddOpt() */
00152 #define VLC_INPUT_OPTION_UNIQUE  0x100
00153 
00154 VLC_EXPORT( int, input_ItemAddOpt, ( input_item_t *, const char *str, unsigned flags ) );
00155 
00156 static inline
00157 int input_ItemAddOption (input_item_t *item, const char *str)
00158 {
00159     return input_ItemAddOpt (item, str, VLC_INPUT_OPTION_TRUSTED);
00160 }
00161 
00162 static inline
00163 int input_ItemHasErrorWhenReading (input_item_t *item)
00164 {
00165     return item->b_error_when_reading;
00166 }
00167 
00168 
00169 VLC_EXPORT( void, input_item_SetMeta, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz_val ));
00170 
00171 static inline bool input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz )
00172 {
00173     vlc_mutex_lock( &p_i->lock );
00174     if( !p_i->p_meta )
00175     {
00176         vlc_mutex_unlock( &p_i->lock );
00177         return false;
00178     }
00179     const char * meta = vlc_meta_Get( p_i->p_meta, meta_type );
00180     bool ret = meta && strcasestr( meta, psz );
00181     vlc_mutex_unlock( &p_i->lock );
00182 
00183     return ret;
00184 }
00185 
00186 static inline char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type )
00187 {
00188     char * psz = NULL;
00189     vlc_mutex_lock( &p_i->lock );
00190 
00191     if( !p_i->p_meta )
00192     {
00193         vlc_mutex_unlock( &p_i->lock );
00194         return NULL;
00195     }
00196 
00197     if( vlc_meta_Get( p_i->p_meta, meta_type ) )
00198         psz = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) );
00199 
00200     vlc_mutex_unlock( &p_i->lock );
00201     return psz;
00202 }
00203 
00204 static inline char * input_item_GetName( input_item_t * p_i )
00205 {
00206     vlc_mutex_lock( &p_i->lock );
00207     char *psz_s = p_i->psz_name ? strdup( p_i->psz_name ) : NULL;
00208     vlc_mutex_unlock( &p_i->lock );
00209     return psz_s;
00210 }
00211 
00212 static inline char * input_item_GetURI( input_item_t * p_i )
00213 {
00214     vlc_mutex_lock( &p_i->lock );
00215     char *psz_s = p_i->psz_uri ? strdup( p_i->psz_uri ) : NULL;
00216     vlc_mutex_unlock( &p_i->lock );
00217     return psz_s;
00218 }
00219 
00220 static inline void input_item_SetURI( input_item_t * p_i, char * psz_uri )
00221 {
00222     vlc_mutex_lock( &p_i->lock );
00223     free( p_i->psz_uri );
00224     p_i->psz_uri = strdup( psz_uri );
00225     vlc_mutex_unlock( &p_i->lock );
00226 }
00227 
00228 static inline mtime_t input_item_GetDuration( input_item_t * p_i )
00229 {
00230     vlc_mutex_lock( &p_i->lock );
00231     mtime_t i_duration = p_i->i_duration;
00232     vlc_mutex_unlock( &p_i->lock );
00233     return i_duration;
00234 }
00235 
00236 static inline void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration )
00237 {
00238     bool send_event = false;
00239 
00240     vlc_mutex_lock( &p_i->lock );
00241     if( p_i->i_duration != i_duration )
00242     {
00243         p_i->i_duration = i_duration;
00244         send_event = true;
00245     }
00246     vlc_mutex_unlock( &p_i->lock );
00247 
00248     if ( send_event == true )
00249     {
00250         vlc_event_t event;
00251         event.type = vlc_InputItemDurationChanged;
00252         event.u.input_item_duration_changed.new_duration = i_duration;
00253         vlc_event_send( &p_i->event_manager, &event );
00254     }
00255 
00256     return;
00257 }
00258 
00259 
00260 static inline bool input_item_IsPreparsed( input_item_t *p_i )
00261 {
00262     return p_i->p_meta ? p_i->p_meta->i_status & ITEM_PREPARSED : false ;
00263 }
00264 
00265 static inline bool input_item_IsArtFetched( input_item_t *p_i )
00266 {
00267     return p_i->p_meta ? p_i->p_meta->i_status & ITEM_ART_FETCHED : false ;
00268 }
00269 
00270 static inline const vlc_meta_t * input_item_GetMetaObject( input_item_t *p_i )
00271 {
00272     if( !p_i->p_meta )
00273         p_i->p_meta = vlc_meta_New();
00274 
00275     return p_i->p_meta;
00276 }
00277 
00278 static inline void input_item_MetaMerge( input_item_t *p_i, const vlc_meta_t * p_new_meta )
00279 {
00280     if( !p_i->p_meta )
00281         p_i->p_meta = vlc_meta_New();
00282 
00283     vlc_meta_Merge( p_i->p_meta, p_new_meta );
00284 }
00285 
00286 #define input_item_SetTitle( item, b )       input_item_SetMeta( item, vlc_meta_Title, b )
00287 #define input_item_SetArtist( item, b )      input_item_SetMeta( item, vlc_meta_Artist, b )
00288 #define input_item_SetGenre( item, b )       input_item_SetMeta( item, vlc_meta_Genre, b )
00289 #define input_item_SetCopyright( item, b )   input_item_SetMeta( item, vlc_meta_Copyright, b )
00290 #define input_item_SetAlbum( item, b )       input_item_SetMeta( item, vlc_meta_Album, b )
00291 #define input_item_SetTrackNum( item, b )    input_item_SetMeta( item, vlc_meta_TrackNumber, b )
00292 #define input_item_SetDescription( item, b ) input_item_SetMeta( item, vlc_meta_Description, b )
00293 #define input_item_SetRating( item, b )      input_item_SetMeta( item, vlc_meta_Rating, b )
00294 #define input_item_SetDate( item, b )        input_item_SetMeta( item, vlc_meta_Date, b )
00295 #define input_item_SetSetting( item, b )     input_item_SetMeta( item, vlc_meta_Setting, b )
00296 #define input_item_SetURL( item, b )         input_item_SetMeta( item, vlc_meta_URL, b )
00297 #define input_item_SetLanguage( item, b )    input_item_SetMeta( item, vlc_meta_Language, b )
00298 #define input_item_SetNowPlaying( item, b )  input_item_SetMeta( item, vlc_meta_NowPlaying, b )
00299 #define input_item_SetPublisher( item, b )   input_item_SetMeta( item, vlc_meta_Publisher, b )
00300 #define input_item_SetEncodedBy( item, b )   input_item_SetMeta( item, vlc_meta_EncodedBy, b )
00301 #define input_item_SetArtURL( item, b )      input_item_SetMeta( item, vlc_meta_ArtworkURL, b )
00302 #define input_item_SetTrackID( item, b )     input_item_SetMeta( item, vlc_meta_TrackID, b )
00303 
00304 #define input_item_GetTitle( item )          input_item_GetMeta( item, vlc_meta_Title )
00305 #define input_item_GetArtist( item )         input_item_GetMeta( item, vlc_meta_Artist )
00306 #define input_item_GetGenre( item )          input_item_GetMeta( item, vlc_meta_Genre )
00307 #define input_item_GetCopyright( item )      input_item_GetMeta( item, vlc_meta_Copyright )
00308 #define input_item_GetAlbum( item )          input_item_GetMeta( item, vlc_meta_Album )
00309 #define input_item_GetTrackNum( item )       input_item_GetMeta( item, vlc_meta_TrackNumber )
00310 #define input_item_GetDescription( item )    input_item_GetMeta( item, vlc_meta_Description )
00311 #define input_item_GetRating( item )         input_item_GetMeta( item, vlc_meta_Rating )
00312 #define input_item_GetDate( item )           input_item_GetMeta( item, vlc_meta_Date )
00313 #define input_item_GetGetting( item )        input_item_GetMeta( item, vlc_meta_Getting )
00314 #define input_item_GetURL( item )            input_item_GetMeta( item, vlc_meta_URL )
00315 #define input_item_GetLanguage( item )       input_item_GetMeta( item, vlc_meta_Language )
00316 #define input_item_GetNowPlaying( item )     input_item_GetMeta( item, vlc_meta_NowPlaying )
00317 #define input_item_GetPublisher( item )      input_item_GetMeta( item, vlc_meta_Publisher )
00318 #define input_item_GetEncodedBy( item )      input_item_GetMeta( item, vlc_meta_EncodedBy )
00319 #define input_item_GetArtURL( item )         input_item_GetMeta( item, vlc_meta_ArtworkURL )
00320 #define input_item_GetTrackID( item )        input_item_GetMeta( item, vlc_meta_TrackID )
00321 #define input_item_GetSetting( item )        input_item_GetMeta( item, vlc_meta_Setting )
00322 
00323 VLC_EXPORT( char *, input_ItemGetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
00324 VLC_EXPORT(int, input_ItemAddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) LIBVLC_FORMAT( 4, 5 ) );
00325 
00326 #define input_ItemNew( a,b,c ) input_ItemNewExt( a, b, c, 0, NULL, -1 )
00327 #define input_ItemNewExt(a,b,c,d,e,f) __input_ItemNewExt( VLC_OBJECT(a),b,c,d,e,f)
00328 VLC_EXPORT( input_item_t *, __input_ItemNewExt, (vlc_object_t *, const char *, const char*, int, const char *const *, mtime_t i_duration )  );
00329 VLC_EXPORT( input_item_t *, input_ItemNewWithType, ( vlc_object_t *, const char *, const char *e, int, const char *const *, mtime_t i_duration, int ) );
00330 
00331 #define input_ItemGetById(a,b) __input_ItemGetById( VLC_OBJECT(a),b )
00332 VLC_EXPORT( input_item_t *, __input_ItemGetById, (vlc_object_t *, int ) );
00333 
00334 /*****************************************************************************
00335  * Meta data helpers
00336  *****************************************************************************/
00337 static inline void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
00338                                                         const vlc_meta_t *p_meta )
00339 {
00340     char * psz_value;
00341 
00342     if( !p_meta )
00343         return;
00344 
00345     if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_TRACK_GAIN" )) ||
00346         (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_RADIO" )) )
00347     {
00348         p_dst->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
00349         p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
00350     }
00351     else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_TRACK_PEAK" )) ||
00352              (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_PEAK" )) )
00353     {
00354         p_dst->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
00355         p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
00356     }
00357     else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_ALBUM_GAIN" )) ||
00358              (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_AUDIOPHILE" )) )
00359     {
00360         p_dst->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
00361         p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
00362     }
00363     else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_ALBUM_PEAK" )) )
00364     {
00365         p_dst->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
00366         p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
00367     }
00368 }
00369 
00370 /*****************************************************************************
00371  * Seek point: (generalisation of chapters)
00372  *****************************************************************************/
00373 struct seekpoint_t
00374 {
00375     int64_t i_byte_offset;
00376     int64_t i_time_offset;
00377     char    *psz_name;
00378     int     i_level;
00379 };
00380 
00381 static inline seekpoint_t *vlc_seekpoint_New( void )
00382 {
00383     seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
00384     point->i_byte_offset =
00385     point->i_time_offset = -1;
00386     point->i_level = 0;
00387     point->psz_name = NULL;
00388     return point;
00389 }
00390 
00391 static inline void vlc_seekpoint_Delete( seekpoint_t *point )
00392 {
00393     if( !point ) return;
00394     free( point->psz_name );
00395     free( point );
00396 }
00397 
00398 static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src )
00399 {
00400     seekpoint_t *point = vlc_seekpoint_New();
00401     if( src->psz_name ) point->psz_name = strdup( src->psz_name );
00402     point->i_time_offset = src->i_time_offset;
00403     point->i_byte_offset = src->i_byte_offset;
00404     return point;
00405 }
00406 
00407 /*****************************************************************************
00408  * Title:
00409  *****************************************************************************/
00410 typedef struct
00411 {
00412     char        *psz_name;
00413 
00414     bool        b_menu;      /* Is it a menu or a normal entry */
00415 
00416     int64_t     i_length;   /* Length(microsecond) if known, else 0 */
00417     int64_t     i_size;     /* Size (bytes) if known, else 0 */
00418 
00419     /* Title seekpoint */
00420     int         i_seekpoint;
00421     seekpoint_t **seekpoint;
00422 
00423 } input_title_t;
00424 
00425 static inline input_title_t *vlc_input_title_New(void)
00426 {
00427     input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) );
00428 
00429     t->psz_name = NULL;
00430     t->b_menu = false;
00431     t->i_length = 0;
00432     t->i_size   = 0;
00433     t->i_seekpoint = 0;
00434     t->seekpoint = NULL;
00435 
00436     return t;
00437 }
00438 
00439 static inline void vlc_input_title_Delete( input_title_t *t )
00440 {
00441     int i;
00442     if( t == NULL )
00443         return;
00444 
00445     free( t->psz_name );
00446     for( i = 0; i < t->i_seekpoint; i++ )
00447     {
00448         free( t->seekpoint[i]->psz_name );
00449         free( t->seekpoint[i] );
00450     }
00451     free( t->seekpoint );
00452     free( t );
00453 }
00454 
00455 static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
00456 {
00457     input_title_t *dup = vlc_input_title_New( );
00458     int i;
00459 
00460     if( t->psz_name ) dup->psz_name = strdup( t->psz_name );
00461     dup->b_menu      = t->b_menu;
00462     dup->i_length    = t->i_length;
00463     dup->i_size      = t->i_size;
00464     dup->i_seekpoint = t->i_seekpoint;
00465     if( t->i_seekpoint > 0 )
00466     {
00467         dup->seekpoint = (seekpoint_t**)calloc( t->i_seekpoint,
00468                                                 sizeof(seekpoint_t*) );
00469 
00470         for( i = 0; i < t->i_seekpoint; i++ )
00471         {
00472             dup->seekpoint[i] = vlc_seekpoint_Duplicate( t->seekpoint[i] );
00473         }
00474     }
00475 
00476     return dup;
00477 }
00478 
00479 /*****************************************************************************
00480  * Attachments
00481  *****************************************************************************/
00482 struct input_attachment_t
00483 {
00484     char *psz_name;
00485     char *psz_mime;
00486     char *psz_description;
00487 
00488     int  i_data;
00489     void *p_data;
00490 };
00491 
00492 static inline input_attachment_t *vlc_input_attachment_New( const char *psz_name,
00493                                                             const char *psz_mime,
00494                                                             const char *psz_description,
00495                                                             const void *p_data,
00496                                                             int i_data )
00497 {
00498     input_attachment_t *a =
00499         (input_attachment_t*)malloc( sizeof(input_attachment_t) );
00500     if( !a )
00501         return NULL;
00502     a->psz_name = strdup( psz_name ? psz_name : "" );
00503     a->psz_mime = strdup( psz_mime ? psz_mime : "" );
00504     a->psz_description = strdup( psz_description ? psz_description : "" );
00505     a->i_data = i_data;
00506     a->p_data = NULL;
00507     if( i_data > 0 )
00508     {
00509         a->p_data = malloc( i_data );
00510         if( a->p_data && p_data )
00511             memcpy( a->p_data, p_data, i_data );
00512     }
00513     return a;
00514 }
00515 static inline input_attachment_t *vlc_input_attachment_Duplicate( const input_attachment_t *a )
00516 {
00517     return vlc_input_attachment_New( a->psz_name, a->psz_mime, a->psz_description,
00518                                      a->p_data, a->i_data );
00519 }
00520 static inline void vlc_input_attachment_Delete( input_attachment_t *a )
00521 {
00522     if( !a )
00523         return;
00524     free( a->psz_name );
00525     free( a->psz_mime );
00526     free( a->psz_description );
00527     free( a->p_data );
00528     free( a );
00529 }
00530 
00531 /*****************************************************************************
00532  * input defines/constants.
00533  *****************************************************************************/
00534 
00535 /* "state" value */
00536 /* NOTE: you need to update ppsz_input_state in the RC interface
00537  * if you modify this list. */
00538 typedef enum input_state_e
00539 {
00540     INIT_S = 0,
00541     OPENING_S,
00542     BUFFERING_S,
00543     PLAYING_S,
00544     PAUSE_S,
00545     STOP_S,
00546     FORWARD_S,
00547     BACKWARD_S,
00548     END_S,
00549     ERROR_S,
00550 } input_state_e;
00551 
00552 /* "rate" default, min/max
00553  * A rate below 1000 plays the movie faster,
00554  * A rate above 1000 plays the movie slower.
00555  */
00556 #define INPUT_RATE_DEFAULT  1000
00557 #define INPUT_RATE_MIN       125            /* Up to 8/1 */
00558 #define INPUT_RATE_MAX     32000            /* Up to 1/32 */
00559 
00560 /* i_update field of access_t/demux_t */
00561 #define INPUT_UPDATE_NONE       0x0000
00562 #define INPUT_UPDATE_SIZE       0x0001
00563 #define INPUT_UPDATE_TITLE      0x0010
00564 #define INPUT_UPDATE_SEEKPOINT  0x0020
00565 #define INPUT_UPDATE_META       0x0040
00566 
00567 /* Input control XXX: internal */
00568 #define INPUT_CONTROL_FIFO_SIZE    100
00569 
00570 /** Get the input item for an input thread */
00571 VLC_EXPORT(input_item_t*, input_GetItem, (input_thread_t*));
00572 
00573 typedef struct input_thread_private_t input_thread_private_t;
00574 
00575 /**
00576  * Main structure representing an input thread. This structure is mostly
00577  * private. The only public fields are READ-ONLY. You must use the helpers
00578  * to modify them
00579  */
00580 struct input_thread_t
00581 {
00582     VLC_COMMON_MEMBERS;
00583 
00584     bool  b_eof;
00585     bool b_preparsing;
00586 
00587     int i_state;
00588     bool b_can_pace_control;
00589     int64_t     i_time;     /* Current time */
00590 
00591     /* Internal caching common to all inputs */
00592     mtime_t i_pts_delay;
00593 
00594     /* All other data is input_thread is PRIVATE. You can't access it
00595      * outside of src/input */
00596     input_thread_private_t *p;
00597 };
00598 
00599 /*****************************************************************************
00600  * Prototypes
00601  *****************************************************************************/
00602 
00603 /* input_CreateThread
00604  * Release the returned input_thread_t using vlc_object_release() */
00605 #define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
00606 VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
00607 
00608 #define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b)
00609 VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) );
00610 
00611 #define input_Read(a,b,c) __input_Read(VLC_OBJECT(a),b, c)
00612 VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t *, bool ) );
00613 VLC_EXPORT( void,             input_StopThread,     ( input_thread_t * ) );
00614 
00615 enum input_query_e
00616 {
00617     /* input variable "position" */
00618     INPUT_GET_POSITION,         /* arg1= double *       res=    */
00619     INPUT_SET_POSITION,         /* arg1= double         res=can fail    */
00620 
00621     /* input variable "length" */
00622     INPUT_GET_LENGTH,           /* arg1= int64_t *      res=can fail    */
00623 
00624     /* input variable "time" */
00625     INPUT_GET_TIME,             /* arg1= int64_t *      res=    */
00626     INPUT_SET_TIME,             /* arg1= int64_t        res=can fail    */
00627 
00628     /* input variable "rate" (1 is DEFAULT_RATE) */
00629     INPUT_GET_RATE,             /* arg1= int *          res=    */
00630     INPUT_SET_RATE,             /* arg1= int            res=can fail    */
00631 
00632     /* input variable "state" */
00633     INPUT_GET_STATE,            /* arg1= int *          res=    */
00634     INPUT_SET_STATE,            /* arg1= int            res=can fail    */
00635 
00636     /* input variable "audio-delay" and "sub-delay" */
00637     INPUT_GET_AUDIO_DELAY,      /* arg1 = int* res=can fail */
00638     INPUT_SET_AUDIO_DELAY,      /* arg1 = int  res=can fail */
00639     INPUT_GET_SPU_DELAY,        /* arg1 = int* res=can fail */
00640     INPUT_SET_SPU_DELAY,        /* arg1 = int  res=can fail */
00641 
00642     /* Meta datas */
00643     INPUT_ADD_INFO,   /* arg1= char* arg2= char* arg3=...     res=can fail */
00644     INPUT_GET_INFO,   /* arg1= char* arg2= char* arg3= char** res=can fail */
00645     INPUT_DEL_INFO,   /* arg1= char* arg2= char*              res=can fail */
00646     INPUT_SET_NAME,   /* arg1= char* res=can fail    */
00647 
00648     /* Input config options */
00649     INPUT_ADD_OPTION,      /* arg1= char * arg2= char *  res=can fail*/
00650 
00651     /* Input properties */
00652     INPUT_GET_BYTE_POSITION,     /* arg1= int64_t *       res=    */
00653     INPUT_SET_BYTE_SIZE,         /* arg1= int64_t *       res=    */
00654     INPUT_GET_VIDEO_FPS,         /* arg1= double *        res=can fail */
00655 
00656     /* bookmarks */
00657     INPUT_GET_BOOKMARKS,   /* arg1= seekpoint_t *** arg2= int * res=can fail */
00658     INPUT_CLEAR_BOOKMARKS, /* res=can fail */
00659     INPUT_ADD_BOOKMARK,    /* arg1= seekpoint_t *  res=can fail   */
00660     INPUT_CHANGE_BOOKMARK, /* arg1= seekpoint_t * arg2= int * res=can fail   */
00661     INPUT_DEL_BOOKMARK,    /* arg1= seekpoint_t *  res=can fail   */
00662     INPUT_SET_BOOKMARK,    /* arg1= int  res=can fail    */
00663 
00664     /* Attachments */
00665     INPUT_GET_ATTACHMENTS, /* arg1=input_attachment_t***, arg2=int*  res=can fail */
00666     INPUT_GET_ATTACHMENT,  /* arg1=input_attachment_t**, arg2=char*  res=can fail */
00667 
00668     /* On the fly input slave */
00669     INPUT_ADD_SLAVE        /* arg1= char * */
00670 };
00671 
00672 VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list  ) );
00673 VLC_EXPORT( int, input_Control,  ( input_thread_t *, int i_query, ...  ) );
00674 
00675 static inline input_state_e input_GetState( input_thread_t * p_input )
00676 {
00677     input_state_e state = INIT_S;
00678     input_Control( p_input, INPUT_GET_STATE, &state );
00679     return state;
00680 }
00681 VLC_EXPORT( decoder_t *, input_DecoderNew, ( input_thread_t *, es_format_t *, bool b_force_decoder ) );
00682 VLC_EXPORT( void, input_DecoderDelete, ( decoder_t * ) );
00683 VLC_EXPORT( void, input_DecoderDecode,( decoder_t *, block_t * ) );
00684 
00685 VLC_EXPORT( bool, input_AddSubtitles, ( input_thread_t *, char *, bool ) );
00686 
00687 VLC_EXPORT( vlc_event_manager_t *, input_get_event_manager, ( input_thread_t * ) );
00688 
00689 #endif

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1