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 #ifndef _T 00096 #define _T(__x) __T(__x) 00097 #endif 00098 #if defined(_UNICODE) 00099 typedef wchar_t Char; 00100 #define __T(__x) L ## __x 00101 #else 00102 typedef char Char; 00103 #define __T(__x) __x 00104 #endif 00105 typedef std::basic_string<Char, std::char_traits<Char>, std::allocator<Char> > MediaInfo_String; 00106 //--------------------------------------------------------------------------- 00107 00108 class File__Base; 00109 class Internet__Base; 00110 class WxThread; 00111 00112 //--------------------------------------------------------------------------- 00113 /// @brief Kinds of Stream 00114 enum stream_t 00115 { 00116 Stream_General, ///< StreamKind = General 00117 Stream_Video, ///< StreamKind = Video 00118 Stream_Audio, ///< StreamKind = Audio 00119 Stream_Text, ///< StreamKind = Text 00120 Stream_Chapters, ///< StreamKind = Chapters 00121 Stream_Image, ///< StreamKind = Image 00122 Stream_Max, 00123 }; 00124 00125 /// @brief Kind of information 00126 enum info_t 00127 { 00128 Info_Name, ///< InfoKind = Unique name of parameter 00129 Info_Text, ///< InfoKind = Value of parameter 00130 Info_Measure, ///< InfoKind = Unique name of measure unit of parameter 00131 Info_Options, ///< InfoKind = See infooptions_t 00132 Info_Name_Text, ///< InfoKind = Translated name of parameter 00133 Info_Measure_Text, ///< InfoKind = Translated name of measure unit 00134 Info_Info, ///< InfoKind = More information about the parameter 00135 Info_HowTo, ///< InfoKind = Information : how data is found 00136 Info_Max 00137 }; 00138 00139 /// Get(...)[infooptions_t] return a string like "YNYN..." \n 00140 /// Use this enum to know at what correspond the Y (Yes) or N (No) 00141 /// If Get(...)[0]==Y, then : 00142 /// @brief Option if InfoKind = Info_Options 00143 enum infooptions_t 00144 { 00145 InfoOption_ShowInInform, ///< Show this parameter in Inform() 00146 InfoOption_Support, ///< Hhow this parameter is supported, could be N (No), R (Read only), W (Read/Write), space (Non applicable) 00147 InfoOption_ShowInSupported, ///< Internal use only (info : Must be showed in Info_Capacities() ) 00148 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) 00149 InfoOption_Max 00150 }; 00151 00152 /// @brief Option for Inform 00153 enum informoptions_t 00154 { 00155 InformOption_Nothing, ///< No options 00156 InformOption_Custom, ///< Use information given by Inform_Set 00157 InformOption_HTML, ///< Output is in HTML Format 00158 InformOption_Max 00159 }; 00160 00161 //--------------------------------------------------------------------------- 00162 00163 //*************************************************************************** 00164 /// @brief MediaInfo 00165 /// @version 0.6 00166 //*************************************************************************** 00167 00168 class MediaInfo 00169 { 00170 public : 00171 //Constructor/Destructor 00172 MediaInfo (); 00173 ~MediaInfo (); 00174 //File 00175 /// Open a file and collect information about it (technical information and tags) 00176 /// @brief Open a file 00177 /// @param File Full name of file to open 00178 /// @retval 0 File not opened 00179 /// @retval 1 File opened 00180 int Open (const MediaInfo_String &File); 00181 /// Open a stream (Begin and end of the stream) and collect information about it (technical information and tags) 00182 /// @brief Open a stream 00183 /// @param Begin First bytes of the stream 00184 /// @param Begin_Size Size of Begin 00185 /// @param End Last bytes of the stream 00186 /// @param End_Size Size of End 00187 /// @retval 0 File not opened 00188 /// @retval 1 File opened 00189 int Open (const unsigned char* Begin, size_t Begin_Size, const unsigned char* End=NULL, size_t End_Size=NULL); 00190 /// Save the file opened before with Open() (modifications of tags) 00191 /// @brief Save the file 00192 /// @retval 0 failed 00193 /// @retval 1 suceed 00194 int Save (); 00195 /// Close a file opened before with Open() (without saving) 00196 /// @brief Close a file 00197 /// @warning without have saved before, modifications are lost 00198 void Close (); 00199 00200 //General information 00201 /// Get all details about a file in one string 00202 /// @brief Get all details about a file 00203 /// @pre You can change default presentation with Inform_Set() 00204 MediaInfo_String Inform (informoptions_t Options=InformOption_Nothing); 00205 00206 //Get 00207 /// Get a piece of information about a file (parameter is an integer) 00208 /// @brief Get a piece of information about a file (parameter is an integer) 00209 /// @param StreamKind Kind of stream (general, video, audio...) 00210 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00211 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00212 /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) 00213 /// @return a string about information you search \n 00214 /// an empty string if there is a problem 00215 MediaInfo_String Get (stream_t StreamKind, int StreamNumber, int Parameter, info_t InfoKind=Info_Text); 00216 /// Get a piece of information about a file (parameter is a string) 00217 /// @brief Get a piece of information about a file (parameter is a string) 00218 /// @param StreamKind Kind of stream (general, video, audio...) 00219 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00220 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n 00221 /// See Info_Parameters() to have the full list 00222 /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) 00223 /// @param SearchKind Where to look for the parameter 00224 /// @return a string about information you search \n 00225 /// an empty string if there is a problem 00226 MediaInfo_String Get (stream_t StreamKind, int StreamNumber, const MediaInfo_String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name); 00227 00228 //Set 00229 /// Set a piece of information about a file (parameter is an integer) 00230 /// @brief Set a piece of information about a file (parameter is an int) 00231 /// @param StreamKind Kind of stream (general, video, audio...) 00232 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00233 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00234 /// @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 00235 /// @retval >=0 suceed 00236 /// @retval <0 failed 00237 int Set (const MediaInfo_String &ToSet, stream_t StreamKind, int StreamNumber, int Parameter, const MediaInfo_String &OldValue=_T("")); 00238 /// Set a piece of information about a file (parameter is a string) 00239 /// @brief Set information about a file (parameter is a string) 00240 /// @param StreamKind Kind of stream (general, video, audio...) 00241 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00242 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format 00243 /// @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 00244 /// @retval >=0 suceed 00245 /// @retval <0 failed 00246 int Set (const MediaInfo_String &ToSet, stream_t StreamKind, int StreamNumber, const MediaInfo_String &Parameter, const MediaInfo_String &OldValue=_T("")); 00247 00248 //Info 00249 /// Configure or get information about MediaInfoLib 00250 /// @param Option The name of option 00251 /// @param Value The value of option 00252 /// @return Depend of the option : by default "" (nothing) means No, other means Yes 00253 /// @post Known options are : \n 00254 /// * (NOT IMPLEMENTED YET) "BlockMethod" : Configure when Open Method must return (default or not command not understood : "1") \n 00255 /// "0" : Immediatly \n 00256 /// "1" : After geting local information \n 00257 /// "2" : When user interaction is needed, or whan Internet information is get 00258 /// * "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 00259 /// * "Complete_Get" : return the state of "Complete" \n 00260 /// * "Language" : Configure language (default language, and this object); Value is Description of language (format : "Column1;Colum2\n...) \n 00261 /// Column 1 : Unique name ("Bytes", "Title") \n 00262 /// Column 2 : translation ("Octets", "Titre") \n 00263 /// * "Language_Get" : Get the language file in memory 00264 /// * "Language_Update" : Configure language of this object only (for optimisation); Value is Description of language (format : "Column1;Colum2\n...) \n 00265 /// Column 1 : Unique name ("Bytes", "Title") \n 00266 /// Column 2 : translation ("Octets", "Titre") \n 00267 /// * "Inform" : Configure custom text, See MediaInfoLib::Inform() function; Description of views (format : "Column1;Colum2...) \n 00268 /// Column 1 : code (11 lines : "General", "Video", "Audio", "Text", "Chapters", "Images", "Begin", "End", "Page_Begin", "Page_Middle", "Page_End") \n 00269 /// Column 2 : The text to show (exemple : "Audio : %FileName% is at %BitRate_String%") \n 00270 /// * "Inform_Get" : Get custom text\n 00271 /// * (NOT IMPLEMENTED YET) "TagSeparator" : Configure the separator if there are multiple same tags (" | " by default)\n 00272 /// * (NOT IMPLEMENTED YET) "TagSeparator_Get" : return the state of "TagSeparator" \n 00273 /// * (NOT IMPLEMENTED YET) "Internet" : Authorize Internet connection (Yes by default) 00274 /// * (NOT IMPLEMENTED YET) "Internet_Title_Get" : When State=5000, give all possible titles for this file (one per line) \n 00275 /// Form : Author TagSeparator Title TagSeparator Year\n... 00276 /// * (NOT IMPLEMENTED YET) "Internet_Title_Set" : Set the Good title (same as given by Internet_Title_Get) \n 00277 /// Form : Author TagSeparator Title TagSeparator Year 00278 /// * "Info_Parameters" : Information about what are known unique names for parameters \n 00279 /// * "Info_Parameters_CSV" : Information about what are known unique names for parameters, in CSV format \n 00280 /// * "Info_Capacities" : Information about which parameters per format are supported \n 00281 /// * "Info_Codecs" : Information about which codec is known \n 00282 /// * "Info_Version" : Information about the version of MediaInfoLib 00283 MediaInfo_String Option (const MediaInfo_String &Option, const MediaInfo_String &Value=MediaInfo_String(_T(""))); 00284 static MediaInfo_String Option_Static (const MediaInfo_String &Option, const MediaInfo_String &Value=MediaInfo_String(_T(""))); 00285 /// @brief (NOT IMPLEMENTED YET) Get the state of the library 00286 /// @retval <1000 No information is available for the file yet 00287 /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet 00288 /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n 00289 /// Warning : even there is only one possible, user interaction (or the software) is needed 00290 /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet 00291 /// @retval <10000 Done 00292 int State_Get (); 00293 /// @brief Count of streams of a stream kind (StreamNumber not filled), or count of piece of information in this stream 00294 /// @param StreamKind Kind of stream (general, video, audio...) 00295 /// @param StreamNumber Stream number in this kind of stream (first, second...) 00296 int Count_Get (stream_t StreamKind, int StreamNumber=-1); 00297 00298 private : 00299 //Theses classes need access to internal structure for optimization. There is recursivity with theses formats 00300 friend class File_Cdxa; 00301 00302 WxThread* Thread; 00303 int BlockMethod; //Open() return : 0=immedialtly, 1=after local info, 2=when user interaction is needed 00304 File__Base* Info; 00305 Internet__Base* Internet; 00306 }; 00307 00308 } //NameSpace 00309 #endif