vlc_input_item.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_input_item.h: Core input item
00003  *****************************************************************************
00004  * Copyright (C) 1999-2009 the VideoLAN team
00005  * $Id: 4136bf1d5353b553ec26d3835931213d43de9ed8 $
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 #ifndef VLC__INPUT_ITEM_H
00026 #define VLC__INPUT_ITEM_H 1
00027 
00028 /**
00029  * \file
00030  * This file defines functions, structures and enums for input items in vlc
00031  */
00032 
00033 #include <vlc_meta.h>
00034 #include <vlc_epg.h>
00035 
00036 #include <string.h>
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 microseconds */
00069 
00070     uint8_t    i_type;               /**< Type (file, disc, ... see input_item_type_e) */
00071     bool b_prefers_tree;             /**< Do we prefer being displayed as tree*/
00072 
00073     int        i_categories;         /**< Number of info categories */
00074     info_category_t **pp_categories; /**< Pointer to the first info category */
00075 
00076     int         i_es;                /**< Number of es format descriptions */
00077     es_format_t **es;                /**< Es formats */
00078 
00079     input_stats_t *p_stats;          /**< Statistics */
00080     int           i_nb_played;       /**< Number of times played */
00081 
00082     bool          b_error_when_reading;       /**< Error When Reading */
00083 
00084     vlc_meta_t *p_meta;
00085 
00086     int         i_epg;               /**< Number of EPG entries */
00087     vlc_epg_t   **pp_epg;            /**< EPG entries */
00088 
00089     vlc_event_manager_t event_manager;
00090 
00091     vlc_mutex_t lock;                 /**< Lock for the item */
00092 };
00093 
00094 enum input_item_type_e
00095 {
00096     ITEM_TYPE_UNKNOWN,
00097     ITEM_TYPE_FILE,
00098     ITEM_TYPE_DIRECTORY,
00099     ITEM_TYPE_DISC,
00100     ITEM_TYPE_CDDA,
00101     ITEM_TYPE_CARD,
00102     ITEM_TYPE_NET,
00103     ITEM_TYPE_PLAYLIST,
00104     ITEM_TYPE_NODE,
00105 
00106     /* This one is not a real type but the number of input_item types. */
00107     ITEM_TYPE_NUMBER
00108 };
00109 
00110 VLC_EXPORT( void, input_item_CopyOptions, ( input_item_t *p_parent, input_item_t *p_child ) );
00111 VLC_EXPORT( void, input_item_SetName, ( input_item_t *p_item, const char *psz_name ) );
00112 
00113 /* This won't hold the item, but can tell to interested third parties
00114  * Like the playlist, that there is a new sub item. With this design
00115  * It is not the input item's responsability to keep all the ref of
00116  * the input item children. */
00117 VLC_EXPORT( void, input_item_AddSubItem, ( input_item_t *p_parent, input_item_t *p_child ) );
00118 
00119 
00120 /**
00121  * Option flags
00122  */
00123 enum input_item_option_e
00124 {
00125     /* Allow VLC to trust the given option.
00126      * By default options are untrusted */
00127     VLC_INPUT_OPTION_TRUSTED = 0x2,
00128 
00129     /* Change the value associated to an option if already present, otherwise
00130      * add the option */
00131     VLC_INPUT_OPTION_UNIQUE  = 0x100,
00132 };
00133 
00134 /**
00135  * This function allows to add an option to an existing input_item_t.
00136  */
00137 VLC_EXPORT( int,  input_item_AddOption, (input_item_t *, const char *, unsigned i_flags ) );
00138 
00139 /* */
00140 VLC_EXPORT( bool, input_item_HasErrorWhenReading, ( input_item_t * ) );
00141 VLC_EXPORT( void, input_item_SetMeta, ( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val ));
00142 VLC_EXPORT( bool, input_item_MetaMatch, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) );
00143 VLC_EXPORT( char *, input_item_GetMeta, ( input_item_t *p_i, vlc_meta_type_t meta_type ) );
00144 VLC_EXPORT( char *, input_item_GetName, ( input_item_t * p_i ) );
00145 VLC_EXPORT( char *, input_item_GetTitleFbName, ( input_item_t * p_i ) );
00146 VLC_EXPORT( char *, input_item_GetURI, ( input_item_t * p_i ) );
00147 VLC_EXPORT( void,   input_item_SetURI, ( input_item_t * p_i, const char *psz_uri ));
00148 VLC_EXPORT(mtime_t, input_item_GetDuration, ( input_item_t * p_i ) );
00149 VLC_EXPORT( void,   input_item_SetDuration, ( input_item_t * p_i, mtime_t i_duration ));
00150 VLC_EXPORT( bool,   input_item_IsPreparsed, ( input_item_t *p_i ));
00151 VLC_EXPORT( bool,   input_item_IsArtFetched, ( input_item_t *p_i ));
00152 
00153 
00154 #define input_item_SetTitle( item, b )       input_item_SetMeta( item, vlc_meta_Title, b )
00155 #define input_item_SetArtist( item, b )      input_item_SetMeta( item, vlc_meta_Artist, b )
00156 #define input_item_SetGenre( item, b )       input_item_SetMeta( item, vlc_meta_Genre, b )
00157 #define input_item_SetCopyright( item, b )   input_item_SetMeta( item, vlc_meta_Copyright, b )
00158 #define input_item_SetAlbum( item, b )       input_item_SetMeta( item, vlc_meta_Album, b )
00159 #define input_item_SetTrackNum( item, b )    input_item_SetMeta( item, vlc_meta_TrackNumber, b )
00160 #define input_item_SetDescription( item, b ) input_item_SetMeta( item, vlc_meta_Description, b )
00161 #define input_item_SetRating( item, b )      input_item_SetMeta( item, vlc_meta_Rating, b )
00162 #define input_item_SetDate( item, b )        input_item_SetMeta( item, vlc_meta_Date, b )
00163 #define input_item_SetSetting( item, b )     input_item_SetMeta( item, vlc_meta_Setting, b )
00164 #define input_item_SetURL( item, b )         input_item_SetMeta( item, vlc_meta_URL, b )
00165 #define input_item_SetLanguage( item, b )    input_item_SetMeta( item, vlc_meta_Language, b )
00166 #define input_item_SetNowPlaying( item, b )  input_item_SetMeta( item, vlc_meta_NowPlaying, b )
00167 #define input_item_SetPublisher( item, b )   input_item_SetMeta( item, vlc_meta_Publisher, b )
00168 #define input_item_SetEncodedBy( item, b )   input_item_SetMeta( item, vlc_meta_EncodedBy, b )
00169 #define input_item_SetArtURL( item, b )      input_item_SetMeta( item, vlc_meta_ArtworkURL, b )
00170 #define input_item_SetTrackID( item, b )     input_item_SetMeta( item, vlc_meta_TrackID, b )
00171 
00172 #define input_item_GetTitle( item )          input_item_GetMeta( item, vlc_meta_Title )
00173 #define input_item_GetArtist( item )         input_item_GetMeta( item, vlc_meta_Artist )
00174 #define input_item_GetGenre( item )          input_item_GetMeta( item, vlc_meta_Genre )
00175 #define input_item_GetCopyright( item )      input_item_GetMeta( item, vlc_meta_Copyright )
00176 #define input_item_GetAlbum( item )          input_item_GetMeta( item, vlc_meta_Album )
00177 #define input_item_GetTrackNum( item )       input_item_GetMeta( item, vlc_meta_TrackNumber )
00178 #define input_item_GetDescription( item )    input_item_GetMeta( item, vlc_meta_Description )
00179 #define input_item_GetRating( item )         input_item_GetMeta( item, vlc_meta_Rating )
00180 #define input_item_GetDate( item )           input_item_GetMeta( item, vlc_meta_Date )
00181 #define input_item_GetGetting( item )        input_item_GetMeta( item, vlc_meta_Getting )
00182 #define input_item_GetURL( item )            input_item_GetMeta( item, vlc_meta_URL )
00183 #define input_item_GetLanguage( item )       input_item_GetMeta( item, vlc_meta_Language )
00184 #define input_item_GetNowPlaying( item )     input_item_GetMeta( item, vlc_meta_NowPlaying )
00185 #define input_item_GetPublisher( item )      input_item_GetMeta( item, vlc_meta_Publisher )
00186 #define input_item_GetEncodedBy( item )      input_item_GetMeta( item, vlc_meta_EncodedBy )
00187 #define input_item_GetArtURL( item )         input_item_GetMeta( item, vlc_meta_ArtworkURL )
00188 #define input_item_GetTrackID( item )        input_item_GetMeta( item, vlc_meta_TrackID )
00189 #define input_item_GetSetting( item )        input_item_GetMeta( item, vlc_meta_Setting )
00190 
00191 VLC_EXPORT( char *, input_item_GetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
00192 VLC_EXPORT( int, input_item_AddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) LIBVLC_FORMAT( 4, 5 ) );
00193 VLC_EXPORT( int, input_item_DelInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name ) );
00194 
00195 /**
00196  * This function creates a new input_item_t with the provided informations.
00197  *
00198  * XXX You may also use input_item_New or input_item_NewExt as they need
00199  * less arguments.
00200  */
00201 VLC_EXPORT( input_item_t *, input_item_NewWithType, ( vlc_object_t *, const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration, int i_type ) );
00202 
00203 /**
00204  * This function creates a new input_item_t with the provided informations.
00205  *
00206  * Provided for convenience.
00207  */
00208 #define input_item_NewExt(a,b,c,d,e,f,g) __input_item_NewExt( VLC_OBJECT(a),b,c,d,e,f,g)
00209 VLC_EXPORT( input_item_t *, __input_item_NewExt, (vlc_object_t *, const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration ) );
00210 
00211 /**
00212  * This function creates a new input_item_t with the provided informations.
00213  *
00214  * Provided for convenience.
00215  */
00216 #define input_item_New( a,b,c ) input_item_NewExt( a, b, c, 0, NULL, 0, -1 )
00217 
00218 /******************
00219  * Input stats
00220  ******************/
00221 struct input_stats_t
00222 {
00223     vlc_mutex_t         lock;
00224 
00225     /* Input */
00226     int i_read_packets;
00227     int i_read_bytes;
00228     float f_input_bitrate;
00229     float f_average_input_bitrate;
00230 
00231     /* Demux */
00232     int i_demux_read_packets;
00233     int i_demux_read_bytes;
00234     float f_demux_bitrate;
00235     float f_average_demux_bitrate;
00236     int i_demux_corrupted;
00237     int i_demux_discontinuity;
00238 
00239     /* Decoders */
00240     int i_decoded_audio;
00241     int i_decoded_video;
00242 
00243     /* Vout */
00244     int i_displayed_pictures;
00245     int i_lost_pictures;
00246 
00247     /* Sout */
00248     int i_sent_packets;
00249     int i_sent_bytes;
00250     float f_send_bitrate;
00251 
00252     /* Aout */
00253     int i_played_abuffers;
00254     int i_lost_abuffers;
00255 };
00256 
00257 #endif

Generated on Sat Nov 21 08:05:14 2009 for VLC by  doxygen 1.5.6