Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vlc_input.h

00001 /*****************************************************************************
00002  * vlc_input.h:
00003  *****************************************************************************
00004  * Copyright (C) 1999-2004 the VideoLAN team
00005  * $Id: input_ext-intf.h 7954 2004-06-07 22:19:12Z fenrir $
00006  *
00007  * Authors: Christophe Massiot <[email protected]>
00008  *          Laurent Aimar <[email protected]>
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., 59 Temple Place - Suite 330, Boston, MA  02111, 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 /*****************************************************************************
00030  * input_item_t: Describes an input and is used to spawn input_thread_t objects
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  * Seek point: (generalisation of chapters)
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  * Title:
00203  *****************************************************************************/
00204 typedef struct
00205 {
00206     char        *psz_name;
00207 
00208     vlc_bool_t  b_menu;      /* Is it a menu or a normal entry */
00209 
00210     int64_t     i_length;   /* Length(microsecond) if known, else 0 */
00211     int64_t     i_size;     /* Size (bytes) if known, else 0 */
00212 
00213     /* Title seekpoint */
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  * input defines/constants.
00275  *****************************************************************************/
00276 
00277 /* "state" value */
00278 enum input_state_e
00279 {
00280     INIT_S,
00281     PLAYING_S,
00282     PAUSE_S,
00283     END_S
00284 };
00285 
00286 /* "rate" default, min/max
00287  * A rate below 1000 plays the movie faster,
00288  * A rate above 1000 plays the movie slower.
00289  */
00290 #define INPUT_RATE_DEFAULT  1000
00291 #define INPUT_RATE_MIN       125            /* Up to 8/1 */
00292 #define INPUT_RATE_MAX      8000            /* Up to 1/8 */
00293 
00294 /* input_source_t: gathers all information per input source */
00295 typedef struct
00296 {
00297     /* Input item description */
00298     input_item_t *p_item;
00299 
00300     /* Access/Stream/Demux plugins */
00301     access_t *p_access;
00302     stream_t *p_stream;
00303     demux_t  *p_demux;
00304 
00305     /* Title infos for that input */
00306     vlc_bool_t   b_title_demux; /* Titles/Seekpoints provided by 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     /* Properties */
00319     vlc_bool_t b_can_pace_control;
00320     vlc_bool_t b_can_pause;
00321     vlc_bool_t b_eof;   /* eof of demuxer */
00322 
00323     /* Clock average variation */
00324     int     i_cr_average;
00325 
00326 } input_source_t;
00327 
00328 /* i_update field of access_t/demux_t */
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 /* Input control XXX: internal */
00336 #define INPUT_CONTROL_FIFO_SIZE    100
00337 
00338 /*****************************************************************************
00339  * input_thread_t
00340  *****************************************************************************
00341  * XXX: this strucrures is *PRIVATE* so nobody can touch it out of src/input.
00342  * I plan to move it to src/input/input_internal.h anyway
00343  *
00344  * XXX: look at src/input/input.c:input_CreateThread for accessible variables
00345  *      YOU CANNOT HAVE ACCESS TO THE CONTENT OF input_thread_t except
00346  *      p_input->input.p_item (and it's only temporary).
00347  * XXX: move the docs somewhere (better than src/input )
00348  *****************************************************************************/
00349 struct input_thread_t
00350 {
00351     VLC_COMMON_MEMBERS
00352 
00353      /* Global properties */
00354     vlc_bool_t  b_eof;
00355     vlc_bool_t  b_can_pace_control;
00356     vlc_bool_t  b_can_pause;
00357 
00358     /* Global state */
00359     int         i_state;
00360     int         i_rate;
00361 
00362     /* */
00363     int64_t     i_start;    /* :start-time,0 by default */
00364     int64_t     i_time;     /* Current time */
00365     int64_t     i_stop;     /* :stop-time, 0 if none */
00366 
00367     /* Title infos FIXME multi-input (not easy) ? */
00368     int          i_title;
00369     input_title_t **title;
00370 
00371     int i_title_offset;
00372     int i_seekpoint_offset;
00373 
00374     /* User bookmarks FIXME won't be easy with multiples input */
00375     int         i_bookmark;
00376     seekpoint_t **bookmark;
00377 
00378     /* Global meta datas FIXME move to input_item_t ? */
00379     vlc_meta_t  *p_meta;
00380 
00381     /* Output */
00382     es_out_t    *p_es_out;
00383     sout_instance_t *p_sout;            /* XXX Move it to es_out ? */
00384     vlc_bool_t      b_out_pace_control; /*     idem ? */
00385 
00386     /* Internal caching common for all inputs */
00387     int64_t i_pts_delay;
00388 
00389     /* Main input properties */
00390     input_source_t input;
00391 
00392     /* Slave demuxers (subs, and others) */
00393     int            i_slave;
00394     input_source_t **slave;
00395 
00396     /* Buffer of pending actions */
00397     vlc_mutex_t lock_control;
00398     int i_control;
00399     struct
00400     {
00401         /* XXX: val isn't duplicated so it won't works with string */
00402         int         i_type;
00403         vlc_value_t val;
00404     } control[INPUT_CONTROL_FIFO_SIZE];
00405 };
00406 
00407 /*****************************************************************************
00408  * Prototypes
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     /* input variable "position" */
00420     INPUT_GET_POSITION,         /* arg1= double *       res=    */
00421     INPUT_SET_POSITION,         /* arg1= double         res=can fail    */
00422 
00423     /* input variable "length" */
00424     INPUT_GET_LENGTH,           /* arg1= int64_t *      res=can fail    */
00425 
00426     /* input variable "time" */
00427     INPUT_GET_TIME,             /* arg1= int64_t *      res=    */
00428     INPUT_SET_TIME,             /* arg1= int64_t        res=can fail    */
00429 
00430     /* input variable "rate" (1 is DEFAULT_RATE) */
00431     INPUT_GET_RATE,             /* arg1= int *          res=    */
00432     INPUT_SET_RATE,             /* arg1= int            res=can fail    */
00433 
00434     /* input variable "state" */
00435     INPUT_GET_STATE,            /* arg1= int *          res=    */
00436     INPUT_SET_STATE,            /* arg1= int            res=can fail    */
00437 
00438     /* input variable "audio-delay" and "sub-delay" */
00439     INPUT_GET_AUDIO_DELAY,      /* arg1 = int* res=can fail */
00440     INPUT_SET_AUDIO_DELAY,      /* arg1 = int  res=can fail */
00441     INPUT_GET_SPU_DELAY,        /* arg1 = int* res=can fail */
00442     INPUT_SET_SPU_DELAY,        /* arg1 = int  res=can fail */
00443 
00444     /* Meta datas */
00445     INPUT_ADD_INFO,   /* arg1= char* arg2= char* arg3=...     res=can fail */
00446     INPUT_GET_INFO,   /* arg1= char* arg2= char* arg3= char** res=can fail */
00447     INPUT_DEL_INFO,   /* arg1= char* arg2= char*              res=can fail */
00448     INPUT_SET_NAME,   /* arg1= char* res=can fail    */
00449 
00450     /* Input config options */
00451     INPUT_ADD_OPTION,      /* arg1= char * arg2= char *  res=can fail*/
00452 
00453     /* Input properties */
00454     INPUT_GET_BYTE_POSITION,     /* arg1= int64_t *       res=    */
00455     INPUT_SET_BYTE_SIZE,         /* arg1= int64_t *       res=    */
00456 
00457     /* bookmarks */
00458     INPUT_GET_BOOKMARKS,   /* arg1= seekpoint_t *** arg2= int * res=can fail */
00459     INPUT_CLEAR_BOOKMARKS, /* res=can fail */
00460     INPUT_ADD_BOOKMARK,    /* arg1= seekpoint_t *  res=can fail   */
00461     INPUT_CHANGE_BOOKMARK, /* arg1= seekpoint_t * arg2= int * res=can fail   */
00462     INPUT_DEL_BOOKMARK,    /* arg1= seekpoint_t *  res=can fail   */
00463     INPUT_SET_BOOKMARK,    /* arg1= int  res=can fail    */
00464 
00465     /* On the fly input slave */
00466     INPUT_ADD_SLAVE        /* arg1= char * */
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

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2