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 #ifndef MediaInfoH 00053 #define MediaInfoH 00054 //--------------------------------------------------------------------------- 00055 00056 //--------------------------------------------------------------------------- 00057 #include <string> 00058 #include <MediaInfo/MediaInfo_Config.h> 00059 //--------------------------------------------------------------------------- 00060 00061 namespace MediaInfoLib 00062 { 00063 00064 class File__Base; 00065 class Internet__Base; 00066 class WxThread; 00067 00068 //*************************************************************************** 00069 /// @brief MediaInfo 00070 /// @version 0.7 00071 //*************************************************************************** 00072 00073 class MediaInfo 00074 { 00075 public : 00076 //Constructor/Destructor 00077 MediaInfo (); 00078 ~MediaInfo (); 00079 //File 00080 /// Open a file and collect information about it (technical information and tags) 00081 /// @brief Open a file 00082 /// @param File Full name of file to open 00083 /// @retval 0 File not opened 00084 /// @retval 1 File opened 00085 int Open (const MediaInfo_String &File); 00086 /// Open a stream (Begin and end of the stream) and collect information about it (technical information and tags) 00087 /// @brief Open a stream 00088 /// @param Begin First bytes of the stream 00089 /// @param Begin_Size Size of Begin 00090 /// @param End Last bytes of the stream 00091 /// @param End_Size Size of End 00092 /// @retval 0 File not opened 00093 /// @retval 1 File opened 00094 int Open (const unsigned char* Begin, size_t Begin_Size, const unsigned char* End=NULL, size_t End_Size=(size_t)NULL); 00095 /// Save the file opened before with Open() (modifications of tags) 00096 /// @brief Save the file 00097 /// @retval 0 failed 00098 /// @retval 1 suceed 00099 int Save (); 00100 /// Close a file opened before with Open() (without saving) 00101 /// @brief Close a file 00102 /// @warning without have saved before, modifications are lost 00103 void Close (); 00104 00105 //General information 00106 /// Get all details about a file in one string 00107 /// @brief Get all details about a file 00108 /// @pre You can change default presentation with Inform_Set() 00109 MediaInfo_String Inform (size_t Reserved=0); 00110 00111 //Get 00112 /// Get a piece of information about a file (parameter is an integer) 00113 /// @brief Get a piece of information about a file (parameter is an integer) 00114 /// @param StreamKind Kind of stream (general, video, audio...) 00115 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00116 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00117 /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) 00118 /// @return a string about information you search \n 00119 /// an empty string if there is a problem 00120 MediaInfo_String Get (stream_t StreamKind, int StreamNumber, int Parameter, info_t InfoKind=Info_Text); 00121 /// Get a piece of information about a file (parameter is a string) 00122 /// @brief Get a piece of information about a file (parameter is a string) 00123 /// @param StreamKind Kind of stream (general, video, audio...) 00124 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00125 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n 00126 /// See Info_Parameters() to have the full list 00127 /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) 00128 /// @param SearchKind Where to look for the parameter 00129 /// @return a string about information you search \n 00130 /// an empty string if there is a problem 00131 MediaInfo_String Get (stream_t StreamKind, int StreamNumber, const MediaInfo_String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name); 00132 00133 //Set 00134 /// Set a piece of information about a file (parameter is an integer) 00135 /// @brief Set a piece of information about a file (parameter is an int) 00136 /// @param StreamKind Kind of stream (general, video, audio...) 00137 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00138 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00139 /// @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 00140 /// @retval >=0 suceed 00141 /// @retval <0 failed 00142 int Set (const MediaInfo_String &ToSet, stream_t StreamKind, int StreamNumber, int Parameter, const MediaInfo_String &OldValue=_T("")); 00143 /// Set a piece of information about a file (parameter is a string) 00144 /// @brief Set information about a file (parameter is a string) 00145 /// @param StreamKind Kind of stream (general, video, audio...) 00146 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00147 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format 00148 /// @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 00149 /// @retval >=0 suceed 00150 /// @retval <0 failed 00151 int Set (const MediaInfo_String &ToSet, stream_t StreamKind, int StreamNumber, const MediaInfo_String &Parameter, const MediaInfo_String &OldValue=_T("")); 00152 00153 //Info 00154 /// Configure or get information about MediaInfoLib 00155 /// @param Option The name of option 00156 /// @param Value The value of option 00157 /// @return Depend of the option : by default "" (nothing) means No, other means Yes 00158 /// @post Known options are : \n 00159 /// * (NOT IMPLEMENTED YET) "BlockMethod" : Configure when Open Method must return (default or not command not understood : "1") \n 00160 /// "0" : Immediatly \n 00161 /// "1" : After geting local information \n 00162 /// "2" : When user interaction is needed, or whan Internet information is get 00163 /// * "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 00164 /// * "Complete_Get" : return the state of "Complete" \n 00165 /// * "Language" : Configure language (default language, and this object); Value is Description of language (format : "Column1;Colum2\n...) \n 00166 /// Column 1 : Unique name ("Bytes", "Title") \n 00167 /// Column 2 : translation ("Octets", "Titre") \n 00168 /// * "Language_Get" : Get the language file in memory 00169 /// * "Language_Update" : Configure language of this object only (for optimisation); Value is Description of language (format : "Column1;Colum2\n...) \n 00170 /// Column 1 : Unique name ("Bytes", "Title") \n 00171 /// Column 2 : translation ("Octets", "Titre") \n 00172 /// * "Inform" : Configure custom text, See MediaInfoLib::Inform() function; Description of views (format : "Column1;Colum2...) \n 00173 /// Column 1 : code (11 lines : "General", "Video", "Audio", "Text", "Chapters", "Begin", "End", "Page_Begin", "Page_Middle", "Page_End") \n 00174 /// Column 2 : The text to show (exemple : "Audio : %FileName% is at %BitRate/String%") \n 00175 /// * "ParseUnknownExtensions" : Configure if MediaInfo parse files with unknown extension\n 00176 /// * "ParseUnknownExtensions_Get" : Get if MediaInfo parse files with unknown extension\n 00177 /// * "ShowFiles" : Configure if MediaInfo keep in memory files with specific kind of streams (or no streams); Value is Description of components (format : "Column1;Colum2\n...) \n\n 00178 /// Column 1 : code (available : "Nothing" for unknown format, "VideoAudio" for at least 1 video and 1 audio, "VideoOnly" for video streams only, "AudioOnly", "TextOnly") \n 00179 /// Column 2 : "" (nothing) not keeping, other for keeping 00180 /// * (NOT IMPLEMENTED YET) "TagSeparator" : Configure the separator if there are multiple same tags (" | " by default)\n 00181 /// * (NOT IMPLEMENTED YET) "TagSeparator_Get" : return the state of "TagSeparator" \n 00182 /// * (NOT IMPLEMENTED YET) "Internet" : Authorize Internet connection (Yes by default) 00183 /// * (NOT IMPLEMENTED YET) "Internet_Title_Get" : When State=5000, give all possible titles for this file (one per line) \n 00184 /// Form : Author TagSeparator Title TagSeparator Year\n... 00185 /// * (NOT IMPLEMENTED YET) "Internet_Title_Set" : Set the Good title (same as given by Internet_Title_Get) \n 00186 /// Form : Author TagSeparator Title TagSeparator Year 00187 /// * "Info_Parameters" : Information about what are known unique names for parameters \n 00188 /// * "Info_Parameters_CSV" : Information about what are known unique names for parameters, in CSV format \n 00189 /// * "Info_Capacities" : Information about which parameters per format are supported \n 00190 /// * "Info_Codecs" : Information about which codec is known \n 00191 /// * "Info_Version" : Information about the version of MediaInfoLib 00192 /// * "Info_Url" : Information about where to find the last version 00193 MediaInfo_String Option (const MediaInfo_String &Option, const MediaInfo_String &Value=_T("")); 00194 static MediaInfo_String Option_Static (const MediaInfo_String &Option, const MediaInfo_String &Value=_T("")); 00195 /// @brief (NOT IMPLEMENTED YET) Get the state of the library 00196 /// @retval <1000 No information is available for the file yet 00197 /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet 00198 /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n 00199 /// Warning : even there is only one possible, user interaction (or the software) is needed 00200 /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet 00201 /// @retval <10000 Done 00202 int State_Get (); 00203 /// @brief Count of streams of a stream kind (StreamNumber not filled), or count of piece of information in this stream 00204 /// @param StreamKind Kind of stream (general, video, audio...) 00205 /// @param StreamNumber Stream number in this kind of stream (first, second...) 00206 int Count_Get (stream_t StreamKind, int StreamNumber=-1); 00207 00208 private : 00209 friend class File_Cdxa; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats 00210 friend class File_Mpeg4; //Due to an hack in File_Mpeg4 //TODO : to remove 00211 00212 WxThread* Thread; 00213 int BlockMethod; //Open() return : 0=immedialtly, 1=after local info, 2=when user interaction is needed 00214 File__Base* Info; 00215 Internet__Base* Internet; 00216 MediaInfo_String FileName; 00217 unsigned char* Begin; 00218 size_t Begin_Size; 00219 unsigned char* End; 00220 size_t End_Size; 00221 00222 int InternalMethod; //1=Open file, 2=Open buffer, 3=Supported formats 00223 int ApplyMethod(); 00224 int ListFormats1(); //If one item succeed, return 00225 int ListFormats2(); //Do all items 00226 int File2Buffer(); //Open a file, and fill buffer 00227 }; 00228 00229 } //NameSpace 00230 #endif