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 ~MediaInfoList (); 00074 00075 //Files 00076 /// Open one or more files and collect information about them (technical information and tags) 00077 /// @brief Open files 00078 /// @param File Full name of file(s) to open \n 00079 /// or Full name of folder(s) to open \n 00080 /// (if multiple names, names must be separated by "|") 00081 /// @param Options : FileOption_Recursive = Recursive mode for folders \n 00082 /// FileOption_Close = Close all already opened files before 00083 /// @retval Number of files successfuly added 00084 int Open (const MediaInfo_String &File, const fileoptions_t Options=FileOption_Nothing); 00085 /// Open a stream (Begin and end of the stream) and collect information about it (technical information and tags) 00086 /// @brief Open a stream 00087 /// @param Begin First bytes of the stream 00088 /// @param Begin_Size Size of Begin 00089 /// @param End Last bytes of the stream 00090 /// @param End_Size Size of End 00091 /// @retval 0 File not opened 00092 /// @retval 1 File opened 00093 int Open (const unsigned char* Begin, size_t Begin_Size, const unsigned char* End=NULL, size_t End_Size=NULL); 00094 /// Save the file opened before with Open() (modifications of tags) 00095 /// @brief Save the file 00096 /// @param FilePos File position \n 00097 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00098 /// @retval 0 failed 00099 /// @retval 1 suceed 00100 int Save (unsigned int FilePos); 00101 /// Save all files opened before with Open() (modifications of tags) 00102 /// @brief Save all files 00103 /// @retval Count of files saved 00104 //int Save_All (); 00105 /// Close the file opened before with Open() (without saving) 00106 /// @brief Close the file 00107 /// @warning without have saved before, modifications are lost 00108 /// @remarks All positions of files upper than FilePos are shifted 00109 /// @retval >=0 number of files saved 00110 void Close (unsigned int FilePos); 00111 00112 /// Get all details about a file in one string 00113 /// @brief Get all details about a file 00114 /// @param FilePos File position \n 00115 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00116 /// @pre You can change default presentation with Inform_Set() 00117 MediaInfo_String Inform (unsigned int FilePos=(unsigned int)-1, size_t Reserved=0); 00118 00119 //Get 00120 /// Get a piece of information about a file (parameter is an integer) 00121 /// @brief Get a piece of information about a file (parameter is an integer) 00122 /// @param FilePos File position \n 00123 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00124 /// @param StreamKind Kind of stream (general, video, audio...) 00125 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00126 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00127 /// @param KindOfInfo Kind of information you want about the parameter (the text, the measure, the help...) 00128 /// @return a string about information you search \n 00129 /// an empty string if there is a problem 00130 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 00131 /// Get a piece of information about a file (parameter is a string) 00132 /// @brief Get a piece of information about a file (parameter is a string) 00133 /// @param FilePos File position \n 00134 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00135 /// @param StreamKind Kind of stream (general, video, audio...) 00136 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00137 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n 00138 /// See Info_Parameters() to have the full list 00139 /// @param KindOfInfo Kind of information you want about the parameter (the text, the measure, the help...) 00140 /// @param KindOfSearch Where to look for the parameter 00141 /// @return a string about information you search \n 00142 /// an empty string if there is a problem 00143 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? 00144 00145 //Set 00146 /// Set a piece of information about a file (parameter is an int) 00147 /// @brief Set a piece of information about a file (parameter is an int) 00148 /// @param FilePos File position \n 00149 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00150 /// @param StreamKind Kind of stream (general, video, audio...) 00151 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00152 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) 00153 /// @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 00154 /// @retval >=0 suceed 00155 /// @retval <0 failed 00156 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 00157 /// @brief Get information about a file (parameter is a string) 00158 /// @param FilePos File position \n 00159 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00160 /// @param StreamKind Kind of stream (general, video, audio...) 00161 /// @param StreamNumber Stream number in Kind of stream (first, second...) 00162 /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n 00163 /// See Info_Parameters() to have the full list 00164 /// @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 00165 /// @retval >=0 suceed 00166 /// @retval <0 failed 00167 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? 00168 00169 //Info 00170 /// Configure or get information about MediaInfoLib 00171 /// @param Option The name of option 00172 /// @param Value The value of option 00173 /// @return Depend of the option : by default "" (nothing) means No, other means Yes 00174 /// @post Known options are : See MediaInfo::Option() 00175 MediaInfo_String Option (const MediaInfo_String &Option, const MediaInfo_String &Value=MediaInfo_String(_T(""))); 00176 static MediaInfo_String Option_Static (const MediaInfo_String &Option, const MediaInfo_String &Value=MediaInfo_String(_T(""))); 00177 /// @brief (NOT IMPLEMENTED YET) Get the state of the library 00178 /// @retval <1000 No information is available for the file yet 00179 /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet 00180 /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n 00181 /// Warning : even there is only one possible, user interaction (or the software) is needed 00182 /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet 00183 /// @retval <10000 Done 00184 int State_Get (); 00185 /// @brief Count of streams, or count of piece of information in this stream 00186 /// @param FilePos File position \n 00187 /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") ) 00188 /// @param StreamKind Kind of stream (general, video, audio...) 00189 /// @param StreamNumber Stream number in this kind of stream (first, second...) 00190 int Count_Get (unsigned int FilePos, stream_t StreamKind, unsigned int StreamNumber=-1); 00191 /// @brief Get the count of opened files 00192 /// @return Count of files opened 00193 int Count_Get (); 00194 00195 private : 00196 std::vector<MediaInfo> Info; 00197 WxThread* Thread; 00198 int BlockMethod; //Open() return : 0=immedialtly, 1=after local info, 2=when user interaction is needed 00199 00200 }; 00201 00202 } //NameSpace 00203 #endif