00001 // MediaInfo - All information about media files 00002 // Copyright (C) 2002-2004 Jerome Martinez, Zen@MediaArea.net 00003 // 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 // 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 // 00018 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00019 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00020 // 00021 // Give information about a lot of media files 00022 // 00023 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00024 // 00025 // 2004-12-16, Zen@MediaArea.net 00026 // Added Open (with a buffer) 00027 // 00028 // 2004-1O-O8, Zen@MediaArea.net 00029 // Added OldValue in Write option 00030 // Added Option method, and deleted deprecated methods 00031 // 00032 // 2004-09-24, Zen@MediaArea.net 00033 // All is now in the MediaInfoLib namespace 00034 // Friend relationship for recursivity in MediaInfo 00035 // 00036 // 2004-09-21, Zen@MediaArea.net 00037 // Open a stream (Binary form, rather than opening a file) 00038 // 00039 // 2003-??-??, Zen@MediaArea.net 00040 // Add Inform Options 00041 // 00042 // 2003-??-??, Zen@MediaArea.net 00043 // Namespace, use of MediaInfo_String, Doxygen comments 00044 // 00045 // 2003-??-??, Zen@MediaArea.net 00046 // DLL 00047 // 00048 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00049 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00050 00051 //--------------------------------------------------------------------------- 00052 /// \mainpage MediaInfoLib Index Page 00053 /// 00054 /// \section Interfaces 00055 /// 00056 /// There is 3 access methods 00057 /// 00058 /// \subsection MediaInfo MediaInfo class (MediaInfoLib::MediaInfo) 00059 /// Simplest interface : one file only \n 00060 /// MediaInfoLib::MediaInfo::Open to analyse file \n 00061 /// MediaInfoLib::MediaInfo::Inform to have a summary \n 00062 /// MediaInfoLib::MediaInfo::Get to retreive one piece of information \n 00063 /// 00064 /// \subsection MediaInfoList List class (MediaInfoLib::MediaInfoList) 00065 /// To manage a list of files \n 00066 /// MediaInfoLib::MediaInfoList::Open to analyse file \n 00067 /// MediaInfoLib::MediaInfoList::Inform to have a summary \n 00068 /// MediaInfoLib::MediaInfoList::Get to retreive one piece of information \n 00069 /// MediaInfoLib::MediaInfoList::Close to close one file \n 00070 /// 00071 /// \subsection C C Interface (MediaInfo_*) 00072 /// For compatibility and DLL interface \n 00073 /// This is a C interface for the List class \n 00074 /// Note : Don't forget to include the MediaInfoDLL.Def file in your project! \n 00075 /// MediaInfoDLL::MediaInfo_Open to analyse file \n 00076 /// MediaInfoDLL::MediaInfo_Inform to have a summary \n 00077 /// MediaInfoDLL::MediaInfo_Get to retreive one piece of information \n 00078 /// MediaInfoDLL::MediaInfo_Close to free memory \n 00079 /// 00080 //--------------------------------------------------------------------------- 00081 00082 //--------------------------------------------------------------------------- 00083 #ifndef MediaInfoH 00084 #define MediaInfoH 00085 //--------------------------------------------------------------------------- 00086 00087 //--------------------------------------------------------------------------- 00088 #include <string> 00089 //--------------------------------------------------------------------------- 00090 00091 namespace MediaInfoLib 00092 { 00093 00094 //--------------------------------------------------------------------------- 00095 //Char types 00096 #undef _T 00097 #define _T(__x) __T(__x) 00098 #if defined(UNICODE) || defined (_UNICODE) 00099 typedef wchar_t Char; 00100 #undef __T 00101 #define __T(__x) L ## __x 00102 #else 00103 typedef char Char; 00104 #undef __T 00105 #define __T(__x) __x 00106 #endif 00107 typedef std::basic_string<Char, std::char_traits<Char>, std::allocator<Char> > MediaInfo_String; 00108 //--------------------------------------------------------------------------- 00109 00110 class File__Base; 00111 class Internet__Base; 00112 class WxThread; 00113 00114 //--------------------------------------------------------------------------- 00115 /// @brief Kinds of Stream 00116 enum stream_t 00117 { 00118 Stream_General, ///< StreamKind = General 00119 Stream_Video, ///< StreamKind = Video 00120 Stream_Audio, ///< StreamKind = Audio 00121 Stream_Text, ///< StreamKind = Text 00122 Stream_Chapters, ///< StreamKind = Chapters 00123 Stream_Image, ///< StreamKind = Image 00124 Stream_Max 00125 }; 00126 00127 /// @brief Kind of information 00128 enum info_t 00129 { 00130 Info_Name, ///< InfoKind = Unique name of parameter 00131 Info_Text, ///< InfoKind = Value of parameter 00132 Info_Measure, ///< InfoKind = Unique name of measure unit of parameter 00133 Info_Options, ///< InfoKind = See infooptions_t 00134 Info_Name_Text, ///< InfoKind = Translated name of parameter 00135 Info_Measure_Text, ///< InfoKind = Translated name of measure unit 00136 Info_Info, ///< InfoKind = More information about the parameter 00137 Info_HowTo, ///< InfoKind = Information : how data is found 00138 Info_Max 00139 }; 00140 00141 /// Get(...)[infooptions_t] return a string like "YNYN..." \n 00142 /// Use this enum to know at what correspond the Y (Yes) or N (No) 00143 /// If Get(...)[0]==Y, then : 00144 /// @brief Option if InfoKind = Info_Options 00145 enum infooptions_t 00146 { 00147 InfoOption_ShowInInform, ///< Show this parameter in Inform() 00148 InfoOption_Support, ///< Hhow this parameter is supported, could be N (No), R (Read only), W (Read/Write), space (Non applicable) 00149 InfoOption_ShowInSupported, ///< Internal use only (info : Must be showed in Info_Capacities() ) 00150 InfoOption_TypeOfValue, ///< Value return by a standard Get() can be : T (Text), I (Integer, warning up to 64 bits), F (Float), D (Date), B (Binary datas coded Base64) (Numbers are in Base 10) 00151 InfoOption_Max 00152 }; 00153 00154 /// @brief Option for Inform 00155 enum informoptions_t 00156 { 00157 InformOption_Nothing, ///< No options 00158 InformOption_Custom, ///< Use information given by Inform_Set 00159 InformOption_HTML, ///< Output is in HTML Format 00160 InformOption_Max 00161 }; 00162 00163 //--------------------------------------------------------------------------- 00164 00165 //*************************************************************************** 00166 /// @brief MediaInfo 00167 /// @version 0.7 00168 //*************************************************************************** 00169 00170 class MediaInfo 00171 { 00172 public : 00173 //Constructor/Destructor 00174 MediaInfo (); 00175 ~MediaInfo (); 00176 //File 00177 /// Open a file and collect information about it (technical information and tags) 00178 /// @brief Open a file 00179 /// @param File Full name of file to open 00180 /// @retval 0 File not opened 00181 /// @retval 1 File opened 00182 int Open (const MediaInfo_String &File); 00183 /// Open a stream (Begin and end of the stream) and collect information about it (technical information and tags) 00184 /// @brief Open a stream 00185 /// @param Begin First bytes of the stream 00186 /// @param Begin_Size Size of Begin 00187 /// @param End Last bytes of the stream 00188 /// @param End_Size Size of End 00189 /// @retval 0 File not opened 00190 /// @retval 1 File opened 00191 int Open (const unsigned char* Begin, size_t Begin_Size, const unsigned char* End=NULL, size_t End_Size=NULL); 00192 /// Save the file opened before with Open() (modifications of tags) 00193 /// @brief Save the file 00194 /// @retval 0 failed 00195 /// @retval 1 suceed 00196 int Save (); 00197 /// Close a file opened before with Open() (without saving) 00198 /// @brief Close a file 00199 /// @warning without have saved before, modifications are lost 00200 void Close (); 00201 00202 //General information 00203 /// Get all details about a file in one string 00204 /// @brief Get all details about a file 00205 /// @pre You can change default presentation with Inform_Set() 00206 MediaInfo_String Inform (informoptions_t Options=InformOption_Nothing); 00207 00208 //Get 00209 /// Get a piece of information about a file (parameter is an integer) 00210 /// @brief Get a piece of information about a file (parameter is an integer) 00211 /// @param StreamKind Kind of stream (general, video, audio...) 00212 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00213 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00214 /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) 00215 /// @return a string about information you search \n 00216 /// an empty string if there is a problem 00217 MediaInfo_String Get (stream_t StreamKind, int StreamNumber, int Parameter, info_t InfoKind=Info_Text); 00218 /// Get a piece of information about a file (parameter is a string) 00219 /// @brief Get a piece of information about a file (parameter is a string) 00220 /// @param StreamKind Kind of stream (general, video, audio...) 00221 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00222 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n 00223 /// See Info_Parameters() to have the full list 00224 /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) 00225 /// @param SearchKind Where to look for the parameter 00226 /// @return a string about information you search \n 00227 /// an empty string if there is a problem 00228 MediaInfo_String Get (stream_t StreamKind, int StreamNumber, const MediaInfo_String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name); 00229 00230 //Set 00231 /// Set a piece of information about a file (parameter is an integer) 00232 /// @brief Set a piece of information about a file (parameter is an int) 00233 /// @param StreamKind Kind of stream (general, video, audio...) 00234 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00235 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00236 /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled : tag is added \n if OldValue is filled and ToSet is filled : tag is replaced \n if OldValue is filled and ToSet is empty : tag is deleted 00237 /// @retval >=0 suceed 00238 /// @retval <0 failed 00239 int Set (const MediaInfo_String &ToSet, stream_t StreamKind, int StreamNumber, int Parameter, const MediaInfo_String &OldValue=_T("")); 00240 /// Set a piece of information about a file (parameter is a string) 00241 /// @brief Set information about a file (parameter is a string) 00242 /// @param StreamKind Kind of stream (general, video, audio...) 00243 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00244 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format 00245 /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled : tag is added \n if OldValue is filled and ToSet is filled : tag is replaced \n if OldValue is filled and ToSet is empty : tag is deleted 00246 /// @retval >=0 suceed 00247 /// @retval <0 failed 00248 int Set (const MediaInfo_String &ToSet, stream_t StreamKind, int StreamNumber, const MediaInfo_String &Parameter, const MediaInfo_String &OldValue=_T("")); 00249 00250 //Info 00251 /// Configure or get information about MediaInfoLib 00252 /// @param Option The name of option 00253 /// @param Value The value of option 00254 /// @return Depend of the option : by default "" (nothing) means No, other means Yes 00255 /// @post Known options are : \n 00256 /// * (NOT IMPLEMENTED YET) "BlockMethod" : Configure when Open Method must return (default or not command not understood : "1") \n 00257 /// "0" : Immediatly \n 00258 /// "1" : After geting local information \n 00259 /// "2" : When user interaction is needed, or whan Internet information is get 00260 /// * "Complete" : For debug, configure if MediaInfoLib::Inform() show all information (doesn't care of InfoOption_NoShow tag) : shows all information if true, shows only useful for user information if false (No by default)\n 00261 /// * "Complete_Get" : return the state of "Complete" \n 00262 /// * "Language" : Configure language (default language, and this object); Value is Description of language (format : "Column1;Colum2\n...) \n 00263 /// Column 1 : Unique name ("Bytes", "Title") \n 00264 /// Column 2 : translation ("Octets", "Titre") \n 00265 /// * "Language_Get" : Get the language file in memory 00266 /// * "Language_Update" : Configure language of this object only (for optimisation); Value is Description of language (format : "Column1;Colum2\n...) \n 00267 /// Column 1 : Unique name ("Bytes", "Title") \n 00268 /// Column 2 : translation ("Octets", "Titre") \n 00269 /// * "Inform" : Configure custom text, See MediaInfoLib::Inform() function; Description of views (format : "Column1;Colum2...) \n 00270 /// Column 1 : code (11 lines : "General", "Video", "Audio", "Text", "Chapters", "Images", "Begin", "End", "Page_Begin", "Page_Middle", "Page_End") \n 00271 /// Column 2 : The text to show (exemple : "Audio : %FileName% is at %BitRate_String%") \n 00272 /// * "Inform_Get" : Get custom text\n 00273 /// * (NOT IMPLEMENTED YET) "TagSeparator" : Configure the separator if there are multiple same tags (" | " by default)\n 00274 /// * (NOT IMPLEMENTED YET) "TagSeparator_Get" : return the state of "TagSeparator" \n 00275 /// * (NOT IMPLEMENTED YET) "Internet" : Authorize Internet connection (Yes by default) 00276 /// * (NOT IMPLEMENTED YET) "Internet_Title_Get" : When State=5000, give all possible titles for this file (one per line) \n 00277 /// Form : Author TagSeparator Title TagSeparator Year\n... 00278 /// * (NOT IMPLEMENTED YET) "Internet_Title_Set" : Set the Good title (same as given by Internet_Title_Get) \n 00279 /// Form : Author TagSeparator Title TagSeparator Year 00280 /// * "Info_Parameters" : Information about what are known unique names for parameters \n 00281 /// * "Info_Parameters_CSV" : Information about what are known unique names for parameters, in CSV format \n 00282 /// * "Info_Capacities" : Information about which parameters per format are supported \n 00283 /// * "Info_Codecs" : Information about which codec is known \n 00284 /// * "Info_Version" : Information about the version of MediaInfoLib 00285 MediaInfo_String Option (const MediaInfo_String &Option, const MediaInfo_String &Value=_T("")); 00286 static MediaInfo_String Option_Static (const MediaInfo_String &Option, const MediaInfo_String &Value=_T("")); 00287 /// @brief (NOT IMPLEMENTED YET) Get the state of the library 00288 /// @retval <1000 No information is available for the file yet 00289 /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet 00290 /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n 00291 /// Warning : even there is only one possible, user interaction (or the software) is needed 00292 /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet 00293 /// @retval <10000 Done 00294 int State_Get (); 00295 /// @brief Count of streams of a stream kind (StreamNumber not filled), or count of piece of information in this stream 00296 /// @param StreamKind Kind of stream (general, video, audio...) 00297 /// @param StreamNumber Stream number in this kind of stream (first, second...) 00298 int Count_Get (stream_t StreamKind, int StreamNumber=-1); 00299 00300 private : 00301 //Theses classes need access to internal structure for optimization. There is recursivity with theses formats 00302 friend class File_Cdxa; 00303 00304 WxThread* Thread; 00305 int BlockMethod; //Open() return : 0=immedialtly, 1=after local info, 2=when user interaction is needed 00306 File__Base* Info; 00307 Internet__Base* Internet; 00308 }; 00309 00310 } //NameSpace 00311 #endif