home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 October / maximum-cd-2009-10.iso / DiscContents / vlc-1.0.0-win32.exe / sdk / include / vlc / plugins / vlc_input_item.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-07-06  |  10.7 KB  |  254 lines

  1. /*****************************************************************************
  2.  * vlc_input_item.h: Core input item
  3.  *****************************************************************************
  4.  * Copyright (C) 1999-2009 the VideoLAN team
  5.  * $Id$
  6.  *
  7.  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  8.  *          Laurent Aimar <fenrir@via.ecp.fr>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23.  *****************************************************************************/
  24.  
  25. #ifndef VLC__INPUT_ITEM_H
  26. #define VLC__INPUT_ITEM_H 1
  27.  
  28. /**
  29.  * \file
  30.  * This file defines functions, structures and enums for input items in vlc
  31.  */
  32.  
  33. #include <vlc_meta.h>
  34.  
  35. #include <string.h>
  36.  
  37. /*****************************************************************************
  38.  * input_item_t: Describes an input and is used to spawn input_thread_t objects
  39.  *****************************************************************************/
  40. struct info_t
  41. {
  42.     char *psz_name;            /**< Name of this info */
  43.     char *psz_value;           /**< Value of the info */
  44. };
  45.  
  46. struct info_category_t
  47. {
  48.     char   *psz_name;      /**< Name of this category */
  49.     int    i_infos;        /**< Number of infos in the category */
  50.     struct info_t **pp_infos;     /**< Pointer to an array of infos */
  51. };
  52.  
  53. struct input_item_t
  54. {
  55.     VLC_GC_MEMBERS
  56.     int        i_id;                 /**< Identifier of the item */
  57.  
  58.     char       *psz_name;            /**< text describing this item */
  59.     char       *psz_uri;             /**< mrl of this item */
  60.     bool       b_fixed_name;        /**< Can the interface change the name ?*/
  61.  
  62.     int        i_options;            /**< Number of input options */
  63.     char       **ppsz_options;       /**< Array of input options */
  64.     uint8_t    *optflagv;            /**< Some flags of input options */
  65.     unsigned   optflagc;
  66.  
  67.     mtime_t    i_duration;           /**< Duration in milliseconds*/
  68.  
  69.     uint8_t    i_type;               /**< Type (file, disc, ... see input_item_type_e) */
  70.     bool b_prefers_tree;             /**< Do we prefer being displayed as tree*/
  71.  
  72.     int        i_categories;         /**< Number of info categories */
  73.     info_category_t **pp_categories; /**< Pointer to the first info category */
  74.  
  75.     int         i_es;                /**< Number of es format descriptions */
  76.     es_format_t **es;                /**< Es formats */
  77.  
  78.     input_stats_t *p_stats;          /**< Statistics */
  79.     int           i_nb_played;       /**< Number of times played */
  80.  
  81.     bool          b_error_when_reading;       /**< Error When Reading */
  82.  
  83.     vlc_meta_t *p_meta;
  84.  
  85.     vlc_event_manager_t event_manager;
  86.  
  87.     vlc_mutex_t lock;                 /**< Lock for the item */
  88. };
  89.  
  90. enum input_item_type_e
  91. {
  92.     ITEM_TYPE_UNKNOWN,
  93.     ITEM_TYPE_FILE,
  94.     ITEM_TYPE_DIRECTORY,
  95.     ITEM_TYPE_DISC,
  96.     ITEM_TYPE_CDDA,
  97.     ITEM_TYPE_CARD,
  98.     ITEM_TYPE_NET,
  99.     ITEM_TYPE_PLAYLIST,
  100.     ITEM_TYPE_NODE,
  101.  
  102.     /* This one is not a real type but the number of input_item types. */
  103.     ITEM_TYPE_NUMBER
  104. };
  105.  
  106. VLC_EXPORT( void, input_item_CopyOptions, ( input_item_t *p_parent, input_item_t *p_child ) );
  107. VLC_EXPORT( void, input_item_SetName, ( input_item_t *p_item, const char *psz_name ) );
  108.  
  109. /* This won't hold the item, but can tell to interested third parties
  110.  * Like the playlist, that there is a new sub item. With this design
  111.  * It is not the input item's responsability to keep all the ref of
  112.  * the input item children. */
  113. VLC_EXPORT( void, input_item_AddSubItem, ( input_item_t *p_parent, input_item_t *p_child ) );
  114.  
  115.  
  116. /**
  117.  * Option flags
  118.  */
  119. enum input_item_option_e
  120. {
  121.     /* Allow VLC to trust the given option.
  122.      * By default options are untrusted */
  123.     VLC_INPUT_OPTION_TRUSTED = 0x2,
  124.  
  125.     /* Change the value associated to an option if already present, otherwise
  126.      * add the option */
  127.     VLC_INPUT_OPTION_UNIQUE  = 0x100,
  128. };
  129.  
  130. /**
  131.  * This function allows to add an option to an existing input_item_t.
  132.  */
  133. VLC_EXPORT( int,  input_item_AddOption, (input_item_t *, const char *, unsigned i_flags ) );
  134.  
  135. /* */
  136. VLC_EXPORT( bool, input_item_HasErrorWhenReading, ( input_item_t * ) );
  137. VLC_EXPORT( void, input_item_SetMeta, ( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val ));
  138. VLC_EXPORT( bool, input_item_MetaMatch, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) );
  139. VLC_EXPORT( char *, input_item_GetMeta, ( input_item_t *p_i, vlc_meta_type_t meta_type ) );
  140. VLC_EXPORT( char *, input_item_GetName, ( input_item_t * p_i ) );
  141. VLC_EXPORT( char *, input_item_GetTitleFbName, ( input_item_t * p_i ) );
  142. VLC_EXPORT( char *, input_item_GetURI, ( input_item_t * p_i ) );
  143. VLC_EXPORT( void,   input_item_SetURI, ( input_item_t * p_i, const char *psz_uri ));
  144. VLC_EXPORT(mtime_t, input_item_GetDuration, ( input_item_t * p_i ) );
  145. VLC_EXPORT( void,   input_item_SetDuration, ( input_item_t * p_i, mtime_t i_duration ));
  146. VLC_EXPORT( bool,   input_item_IsPreparsed, ( input_item_t *p_i ));
  147. VLC_EXPORT( bool,   input_item_IsArtFetched, ( input_item_t *p_i ));
  148.  
  149.  
  150. #define input_item_SetTitle( item, b )       input_item_SetMeta( item, vlc_meta_Title, b )
  151. #define input_item_SetArtist( item, b )      input_item_SetMeta( item, vlc_meta_Artist, b )
  152. #define input_item_SetGenre( item, b )       input_item_SetMeta( item, vlc_meta_Genre, b )
  153. #define input_item_SetCopyright( item, b )   input_item_SetMeta( item, vlc_meta_Copyright, b )
  154. #define input_item_SetAlbum( item, b )       input_item_SetMeta( item, vlc_meta_Album, b )
  155. #define input_item_SetTrackNum( item, b )    input_item_SetMeta( item, vlc_meta_TrackNumber, b )
  156. #define input_item_SetDescription( item, b ) input_item_SetMeta( item, vlc_meta_Description, b )
  157. #define input_item_SetRating( item, b )      input_item_SetMeta( item, vlc_meta_Rating, b )
  158. #define input_item_SetDate( item, b )        input_item_SetMeta( item, vlc_meta_Date, b )
  159. #define input_item_SetSetting( item, b )     input_item_SetMeta( item, vlc_meta_Setting, b )
  160. #define input_item_SetURL( item, b )         input_item_SetMeta( item, vlc_meta_URL, b )
  161. #define input_item_SetLanguage( item, b )    input_item_SetMeta( item, vlc_meta_Language, b )
  162. #define input_item_SetNowPlaying( item, b )  input_item_SetMeta( item, vlc_meta_NowPlaying, b )
  163. #define input_item_SetPublisher( item, b )   input_item_SetMeta( item, vlc_meta_Publisher, b )
  164. #define input_item_SetEncodedBy( item, b )   input_item_SetMeta( item, vlc_meta_EncodedBy, b )
  165. #define input_item_SetArtURL( item, b )      input_item_SetMeta( item, vlc_meta_ArtworkURL, b )
  166. #define input_item_SetTrackID( item, b )     input_item_SetMeta( item, vlc_meta_TrackID, b )
  167.  
  168. #define input_item_GetTitle( item )          input_item_GetMeta( item, vlc_meta_Title )
  169. #define input_item_GetArtist( item )         input_item_GetMeta( item, vlc_meta_Artist )
  170. #define input_item_GetGenre( item )          input_item_GetMeta( item, vlc_meta_Genre )
  171. #define input_item_GetCopyright( item )      input_item_GetMeta( item, vlc_meta_Copyright )
  172. #define input_item_GetAlbum( item )          input_item_GetMeta( item, vlc_meta_Album )
  173. #define input_item_GetTrackNum( item )       input_item_GetMeta( item, vlc_meta_TrackNumber )
  174. #define input_item_GetDescription( item )    input_item_GetMeta( item, vlc_meta_Description )
  175. #define input_item_GetRating( item )         input_item_GetMeta( item, vlc_meta_Rating )
  176. #define input_item_GetDate( item )           input_item_GetMeta( item, vlc_meta_Date )
  177. #define input_item_GetGetting( item )        input_item_GetMeta( item, vlc_meta_Getting )
  178. #define input_item_GetURL( item )            input_item_GetMeta( item, vlc_meta_URL )
  179. #define input_item_GetLanguage( item )       input_item_GetMeta( item, vlc_meta_Language )
  180. #define input_item_GetNowPlaying( item )     input_item_GetMeta( item, vlc_meta_NowPlaying )
  181. #define input_item_GetPublisher( item )      input_item_GetMeta( item, vlc_meta_Publisher )
  182. #define input_item_GetEncodedBy( item )      input_item_GetMeta( item, vlc_meta_EncodedBy )
  183. #define input_item_GetArtURL( item )         input_item_GetMeta( item, vlc_meta_ArtworkURL )
  184. #define input_item_GetTrackID( item )        input_item_GetMeta( item, vlc_meta_TrackID )
  185. #define input_item_GetSetting( item )        input_item_GetMeta( item, vlc_meta_Setting )
  186.  
  187. VLC_EXPORT( char *, input_item_GetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
  188. 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 ) );
  189. VLC_EXPORT( int, input_item_DelInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name ) );
  190.  
  191. /**
  192.  * This function creates a new input_item_t with the provided informations.
  193.  *
  194.  * XXX You may also use input_item_New or input_item_NewExt as they need
  195.  * less arguments.
  196.  */
  197. 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 ) );
  198.  
  199. /**
  200.  * This function creates a new input_item_t with the provided informations.
  201.  *
  202.  * Provided for convenience.
  203.  */
  204. #define input_item_NewExt(a,b,c,d,e,f,g) __input_item_NewExt( VLC_OBJECT(a),b,c,d,e,f,g)
  205. 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 ) );
  206.  
  207. /**
  208.  * This function creates a new input_item_t with the provided informations.
  209.  *
  210.  * Provided for convenience.
  211.  */
  212. #define input_item_New( a,b,c ) input_item_NewExt( a, b, c, 0, NULL, 0, -1 )
  213.  
  214. /******************
  215.  * Input stats
  216.  ******************/
  217. struct input_stats_t
  218. {
  219.     vlc_mutex_t         lock;
  220.  
  221.     /* Input */
  222.     int i_read_packets;
  223.     int i_read_bytes;
  224.     float f_input_bitrate;
  225.     float f_average_input_bitrate;
  226.  
  227.     /* Demux */
  228.     int i_demux_read_packets;
  229.     int i_demux_read_bytes;
  230.     float f_demux_bitrate;
  231.     float f_average_demux_bitrate;
  232.     int i_demux_corrupted;
  233.     int i_demux_discontinuity;
  234.  
  235.     /* Decoders */
  236.     int i_decoded_audio;
  237.     int i_decoded_video;
  238.  
  239.     /* Vout */
  240.     int i_displayed_pictures;
  241.     int i_lost_pictures;
  242.  
  243.     /* Sout */
  244.     int i_sent_packets;
  245.     int i_sent_bytes;
  246.     float f_send_bitrate;
  247.  
  248.     /* Aout */
  249.     int i_played_abuffers;
  250.     int i_lost_abuffers;
  251. };
  252.  
  253. #endif
  254.