Main Page   Namespace List   Compound List   File List   Compound Members   File Members  

MediaInfo.h

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

Generated on Mon Jul 31 00:08:10 2006 for MediaInfoLib by doxygen1.3-rc3