00001 // MediaInfoList - A list of MediaInfo 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 // MediaInfoList 00021 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00022 // 00023 // Give information about a lot of media files 00024 // 00025 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00026 // 00027 // 2004-1O-O8, Zen@MediaArea.net 00028 // Added OldValue in Write option 00029 // Added TagSeparator_Set 00030 // 00031 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00032 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00033 00034 //--------------------------------------------------------------------------- 00035 #ifndef MediaInfoListH 00036 #define MediaInfoListH 00037 //--------------------------------------------------------------------------- 00038 00039 //--------------------------------------------------------------------------- 00040 #if defined(__BORLANDC__) 00041 #pragma warn -8058 //Borland doesn't like initialization of data in pre-compiled header 00042 #endif 00043 #include "MediaInfo/MediaInfo.h" 00044 #include <vector> 00045 //--------------------------------------------------------------------------- 00046 00047 namespace MediaInfoLib 00048 { 00049 //--------------------------------------------------------------------------- 00050 /// @brief File opening options 00051 enum fileoptions_t 00052 { 00053 FileOption_Nothing, 00054 FileOption_Recursive, ///< Browse folders recursively 00055 FileOption_Close, ///< Close all files before open 00056 FileOption_Max 00057 }; 00058 //--------------------------------------------------------------------------- 00059 00060 00061 //*************************************************************************** 00062 /// @brief MediaInfoList 00063 /// @version 0.7 00064 //*************************************************************************** 00065 00066 class MediaInfoList 00067 { 00068 public : 00069 //Class 00070 /// @brief Constructor 00071 /// @param Count_Init optimization information : How many files do you plan to handle? 00072 MediaInfoList (unsigned int Count_Init=64); 00073 00074 //Files 00075 /// Open one or more files and collect information about them (technical information and tags) 00076 /// @brief Open files 00077 /// @param File Full name of file(s) to open \n 00078 /// or Full name of folder(s) to open \n 00079 /// (if multiple names, names must be separated by "|") 00080 /// @param Options : FileOption_Recursive = Recursive mode for folders \n 00081 /// FileOption_Close = Close all already opened files before 00082 /// @retval Number of files successfuly added 00083 int Open (const MediaInfo_String &File, const fileoptions_t Options=FileOption_Nothing); 00084 /// Open a stream (Begin and end of the stream) and collect information about it (technical information and tags) 00085 /// @brief Open a stream 00086 /// @param Begin First bytes of the stream 00087 /// @param Begin_Size Size of Begin 00088 /// @param End Last bytes of the stream 00089 /// @param End_Size Size of End 00090 /// @retval 0 File not opened 00091 /// @retval 1 File opened 00092 int Open (const unsigned char* Begin, size_t Begin_Size, const unsigned char* End=NULL, size_t End_Size=NULL); 00093 /// Save the file opened before with Open() (modifications of tags) 00094 /// @brief Save the file 00095 /// @param FilePos File position \n 00096 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00097 /// @retval 0 failed 00098 /// @retval 1 suceed 00099 int Save (unsigned int FilePos); 00100 /// Save all files opened before with Open() (modifications of tags) 00101 /// @brief Save all files 00102 /// @retval Count of files saved 00103 int Save_All (); 00104 /// Close the file opened before with Open() (without saving) 00105 /// @brief Close the file 00106 /// @warning without have saved before, modifications are lost 00107 /// @remarks All positions of files upper than FilePos are shifted 00108 /// @retval >=0 number of files saved 00109 void Close (unsigned int FilePos); 00110 /// Close all files files opened before with Open() (without saving) 00111 /// @brief Close all file 00112 /// @warning without have saved before, modifications are lost 00113 void Close_All (); 00114 00115 /// Get all details about a file in one string 00116 /// @brief Get all details about a file 00117 /// @param FilePos File position \n 00118 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00119 /// @pre You can change default presentation with Inform_Set() 00120 MediaInfo_String Inform (unsigned int FilePos, informoptions_t Options=InformOption_Nothing); 00121 /// Get all details about all file in one string 00122 /// @brief Get all details about all file 00123 /// @param Separator Separator string between files descriptions 00124 /// @pre You can change default presentation with Inform_Set() 00125 MediaInfo_String Inform_All (informoptions_t Options=InformOption_Nothing); 00126 00127 //Get 00128 /// Get a piece of information about a file (parameter is an integer) 00129 /// @brief Get a piece of information about a file (parameter is an integer) 00130 /// @param FilePos File position \n 00131 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00132 /// @param StreamKind Kind of stream (general, video, audio...) 00133 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00134 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00135 /// @param KindOfInfo Kind of information you want about the parameter (the text, the measure, the help...) 00136 /// @return a string about information you search \n 00137 /// an empty string if there is a problem 00138 MediaInfo_String Get (unsigned int FilePos, stream_t StreamKind, unsigned int StreamNumber, unsigned int Parameter, info_t KindOfInfo=Info_Text); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name, text, measure, options, name (language), measure (language), info, how to 00139 /// Get a piece of information about a file (parameter is a string) 00140 /// @brief Get a piece of information about a file (parameter is a string) 00141 /// @param FilePos File position \n 00142 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00143 /// @param StreamKind Kind of stream (general, video, audio...) 00144 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00145 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n 00146 /// See Info_Parameters() to have the full list 00147 /// @param KindOfInfo Kind of information you want about the parameter (the text, the measure, the help...) 00148 /// @param KindOfSearch Where to look for the parameter 00149 /// @return a string about information you search \n 00150 /// an empty string if there is a problem 00151 MediaInfo_String Get (unsigned int FilePos, stream_t StreamKind, unsigned int StreamNumber, const MediaInfo_String &Parameter, info_t KindOfInfo=Info_Text, info_t KindOfSearch=Info_Name); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name text measure options name(language) measure(language) information how to, KindOfSearch=which Kind Of information Parameter must be searched? 00152 00153 //Set 00154 /// Set a piece of information about a file (parameter is an int) 00155 /// @brief Set a piece of information about a file (parameter is an int) 00156 /// @param FilePos File position \n 00157 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00158 /// @param StreamKind Kind of stream (general, video, audio...) 00159 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00160 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00161 /// @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 00162 /// @retval >=0 suceed 00163 /// @retval <0 failed 00164 int Set (const MediaInfo_String &ToSet, unsigned int FilePos, stream_t StreamKind, unsigned int StreamNumber, unsigned int Parameter, const MediaInfo_String &OldValue=_T("")); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name, text, measure, options name(language) measure(language) information how to 00165 /// @brief Get information about a file (parameter is a string) 00166 /// @param FilePos File position \n 00167 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00168 /// @param StreamKind Kind of stream (general, video, audio...) 00169 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00170 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n 00171 /// See Info_Parameters() to have the full list 00172 /// @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 00173 /// @retval >=0 suceed 00174 /// @retval <0 failed 00175 int Set (const MediaInfo_String &ToSet, unsigned int FilePos, stream_t StreamKind, unsigned int StreamNumber, const MediaInfo_String &Parameter, const MediaInfo_String &OldValue=_T("")); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name text measure options name (language) measure (language) information how to, KindOfSearch=which Kind Of information Parameter must be searched? 00176 00177 //Info 00178 /// Configure or get information about MediaInfoLib 00179 /// @param Option The name of option 00180 /// @param Value The value of option 00181 /// @return Depend of the option : by default "" (nothing) means No, other means Yes 00182 /// @post Known options are : \n 00183 /// * (NOT IMPLEMENTED YET) "BlockMethod" : Configure when Open Method must return (default or not command not understood : "1") \n 00184 /// "0" : Immediatly \n 00185 /// "1" : After geting local information \n 00186 /// "2" : When user interaction is needed, or whan Internet information is get 00187 /// * "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 00188 /// * "Complete_Get" : return the state of "Complete" \n 00189 /// * "Language" : Configure language (default language, and this object); Value is Description of language (format : "Column1;Colum2\n...) \n 00190 /// Column 1 : Unique name ("Bytes", "Title") \n 00191 /// Column 2 : translation ("Octets", "Titre") \n 00192 /// * "Language_Update" : Configure language of this object only (for optimisation); Value is Description of language (format : "Column1;Colum2\n...) \n 00193 /// Column 1 : Unique name ("Bytes", "Title") \n 00194 /// Column 2 : translation ("Octets", "Titre") \n 00195 /// * "Inform" : Configure custom text, See MediaInfoLib::Inform() function; Description of views (format : "Column1;Colum2...) \n 00196 /// Column 1 : code (11 lines : "General", "Video", "Audio", "Text", "Chapters", "Images", "Begin", "End", "Page_Begin", "Page_Middle", "Page_End") \n 00197 /// Column 2 : The text to show (exemple : "Audio : %FileName% is at %BitRate_String%") \n 00198 /// * "Inform_Get" : Get custom text\n 00199 /// * (NOT IMPLEMENTED YET) "TagSeparator" : Configure the separator if there are multiple same tags (" | " by default)\n 00200 /// * (NOT IMPLEMENTED YET) "TagSeparator_Get" : return the state of "TagSeparator" \n 00201 /// * (NOT IMPLEMENTED YET) "Internet" : Authorize Internet connection (Yes by default) 00202 /// * (NOT IMPLEMENTED YET) "Internet_Title_Get" : When State=5000, give all possible titles for this file (one per line) \n 00203 /// Form : Author TagSeparator Title TagSeparator Year\n... 00204 /// * (NOT IMPLEMENTED YET) "Internet_Title_Set" : Set the Good title (same as given by Internet_Title_Get) \n 00205 /// Form : Author TagSeparator Title TagSeparator Year 00206 /// * "Info_Parameters" : Information about what are known unique names for parameters \n 00207 /// * "Info_Parameters_CSV" : Information about what are known unique names for parameters, in CSV format \n 00208 /// * "Info_Capacities" : Information about which parameters per format are supported \n 00209 /// * "Info_Codecs" : Information about which codec is known \n 00210 /// * "Info_Version" : Information about the version of MediaInfoLib 00211 MediaInfo_String Option (const MediaInfo_String &Option, const MediaInfo_String &Value=MediaInfo_String(_T(""))); 00212 static MediaInfo_String Option_Static (const MediaInfo_String &Option, const MediaInfo_String &Value=MediaInfo_String(_T(""))); 00213 /// @brief (NOT IMPLEMENTED YET) Get the state of the library 00214 /// @retval <1000 No information is available for the file yet 00215 /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet 00216 /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n 00217 /// Warning : even there is only one possible, user interaction (or the software) is needed 00218 /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet 00219 /// @retval <10000 Done 00220 int State_Get (); 00221 /// @brief Count of streams, or count of piece of information in this stream 00222 /// @param FilePos File position \n 00223 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00224 /// @param StreamKind Kind of stream (general, video, audio...) 00225 /// @param StreamNumber Stream number in this kind of stream (first, second...) 00226 int Count_Get (unsigned int FilePos, stream_t StreamKind, unsigned int StreamNumber=-1); 00227 /// @brief Get the count of opened files 00228 /// @return Count of files opened 00229 int Count_Get (); 00230 00231 private : 00232 std::vector <MediaInfo*> Info; 00233 WxThread* Thread; 00234 int BlockMethod; //Open() return : 0=immedialtly, 1=after local info, 2=when user interaction is needed 00235 00236 }; 00237 00238 } //NameSpace 00239 #endif