MediaInfo源代码分析 2:API函数
本文主要分析MediaInfo的API函数。它的API函数位于MediaInfo.h文件中的一个叫做MediaInfo的类中。
该类如下所示,部分重要的方法已经加上了注释:
//MediaInfo类
class MEDIAINFO_EXP MediaInfo
{
public :
//Constructor/Destructor
MediaInfo ();
~MediaInfo ();
//File
/// Open a file and collect information about it (technical information and tags)
/// @brief Open a file
/// @param File_Name Full name of file to open
/// @retval 0 File not opened
/// @retval 1 File opened
//打开文件
size_t Open (const String &File_Name);
/// Open a Buffer (Begin and end of the stream) and collect information about it (technical information and tags)
/// @brief Open a buffer
/// @param Begin First bytes of the buffer
/// @param Begin_Size Size of Begin
/// @param End Last bytes of the buffer
/// @param End_Size Size of End
/// @param File_Size Total size of the file
/// @retval 0 File not opened
/// @retval 1 File opened
//打开一段内存!
size_t Open (const ZenLib::int8u* Begin, size_t Begin_Size, const ZenLib::int8u* End=NULL, size_t End_Size=0, ZenLib::int64u File_Size=0);
/// Open a stream and collect information about it (technical information and tags)
/// @brief Open a stream (Init)
/// @param File_Size Estimated file size
/// @param File_Offset Offset of the file (if we don't have the beginning of the file)
/// @retval 0 File not opened
/// @retval 1 File opened
//打开一个流和收集的关于它的信息
size_t Open_Buffer_Init (ZenLib::int64u File_Size=(ZenLib::int64u)-1, ZenLib::int64u File_Offset=0);
/// Open a stream and collect information about it (technical information and tags)
/// @brief Open a stream (Continue)
/// @param Buffer pointer to the stream
/// @param Buffer_Size Count of bytes to read
/// @return a bitfield \n
/// bit 0: Is Accepted (format is known)
/// bit 1: Is Filled (main data is collected)
/// bit 2: Is Updated (some data have beed updated, example: duration for a real time MPEG-TS stream)
/// bit 3: Is Finalized (No more data is needed, will not use further data)
/// bit 4-15: Reserved
/// bit 16-31: User defined
//打开一个流和收集的关于它的信息
size_t Open_Buffer_Continue (const ZenLib::int8u* Buffer, size_t Buffer_Size);
/// Open a stream and collect information about it (technical information and tags)
/// @brief Open a stream (Get the needed file Offset)
/// @return the needed offset of the file \n
/// File size if no more bytes are needed
ZenLib::int64u Open_Buffer_Continue_GoTo_Get ();
/// Open a stream and collect information about it (technical information and tags)
/// @brief Open a stream (Finalize)
/// @retval 0 failed
/// @retval 1 succeed
//打开一个流和收集的关于它的信息
size_t Open_Buffer_Finalize ();
/// If Open() is used in "PerPacket" mode, parse only one packet and return
/// @brief Read one packet (if "PerPacket" mode is set)
/// @return a bitfield \n
/// bit 0: A packet was read
size_t Open_NextPacket ();
/// (NOT IMPLEMENTED YET) Save the file opened before with Open() (modifications of tags)
/// @brief (NOT IMPLEMENTED YET) Save the file
/// @retval 0 failed
/// @retval 1 suceed
size_t Save ();
/// Close a file opened before with Open() (without saving)
/// @brief Close a file
/// @warning without have saved before, modifications are lost
void Close (); //General information
/// Get all details about a file in one string
/// @brief Get all details about a file
/// @param Reserved Reserved, do not use
/// @pre You can change default presentation with Inform_Set()
/// @return Text with information about the file
//返回文件信息
String Inform (size_t Reserved=0); //Get
/// Get a piece of information about a file (parameter is an integer)
/// @brief Get a piece of information about a file (parameter is an integer)
/// @param StreamKind Kind of stream (general, video, audio...)
/// @param StreamNumber Stream number in Kind of stream (first, second...)
/// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...)
/// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...)
/// @return a string about information you search \n
/// an empty string if there is a problem
//获取一部分文件的信息(参数是一个整数)
String Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text);
/// Get a piece of information about a file (parameter is a string)
/// @brief Get a piece of information about a file (parameter is a string)
/// @param StreamKind Kind of stream (general, video, audio...)
/// @param StreamNumber Stream number in Kind of stream (first, second...)
/// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n
/// See MediaInfo::Option("Info_Parameters") to have the full list
/// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...)
/// @param SearchKind Where to look for the parameter
/// @return a string about information you search \n
/// an empty string if there is a problem
//获取一部分文件的信息(参数是一个字符串)
String Get (stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name); //Set
/// (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an integer)
/// @brief (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an int)
/// @warning Not yet implemented, do not use it
/// @param ToSet Piece of information
/// @param StreamKind Kind of stream (general, video, audio...)
/// @param StreamNumber Stream number in Kind of stream (first, second...)
/// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...)
/// @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
/// @retval >0 succeed
/// @retval 0 failed
size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=String());
/// (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is a string)
/// @warning Not yet implemented, do not use it
/// @brief (NOT IMPLEMENTED YET) Set information about a file (parameter is a string)
/// @param ToSet Piece of information
/// @param StreamKind Kind of stream (general, video, audio...)
/// @param StreamNumber Stream number in Kind of stream (first, second...)
/// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format
/// @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
/// @retval >0 succeed
/// @retval 0 failed
size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=String()); //Output_Buffered
/// Output the written size when "File_Duplicate" option is used.
/// @brief Output the written size when "File_Duplicate" option is used.
/// @param Value The unique name of the duplicated stream (begin with "memory://")
/// @return The size of the used buffer
size_t Output_Buffer_Get (const String &Value);
/// Output the written size when "File_Duplicate" option is used.
/// @brief Output the written size when "File_Duplicate" option is used.
/// @param Pos The order of calling
/// @return The size of the used buffer
size_t Output_Buffer_Get (size_t Pos); //Info
/// Configure or get information about MediaInfoLib
/// @param Option The name of option
/// @param Value The value of option
/// @return Depend of the option: by default "" (nothing) means No, other means Yes
/// @post Known options are: \n
/// * (NOT IMPLEMENTED YET) "BlockMethod": Configure when Open Method must return (default or not command not understood: "1") \n
/// "0": Immediatly \n
/// "1": After geting local information \n
/// "2": When user interaction is needed, or whan Internet information is get
/// * "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
/// * "Complete_Get": return the state of "Complete" \n
/// * "Language": Configure language (default language, and this object); Value is Description of language (format: "Column1;Colum2\n...) \n
/// Column 1: Unique name ("Bytes", "Title") \n
/// Column 2: translation ("Octets", "Titre") \n
/// * "Language_Get": Get the language file in memory
/// * "Language_Update": Configure language of this object only (for optimisation); Value is Description of language (format: "Column1;Colum2\n...) \n
/// Column 1: Unique name ("Bytes", "Title") \n
/// Column 2: translation ("Octets", "Titre") \n
/// * "Inform": Configure custom text, See MediaInfoLib::Inform() function; Description of views (format: "Column1;Colum2...) \n
/// Column 1: code (11 lines: "General", "Video", "Audio", "Text", "Other", "Begin", "End", "Page_Begin", "Page_Middle", "Page_End") \n
/// Column 2: The text to show (exemple: "Audio: %FileName% is at %BitRate/String%") \n
/// * "ParseUnknownExtensions": Configure if MediaInfo parse files with unknown extension\n
/// * "ParseUnknownExtensions_Get": Get if MediaInfo parse files with unknown extension\n
/// * "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
/// 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
/// Column 2: "" (nothing) not keeping, other for keeping
/// * (NOT IMPLEMENTED YET) "TagSeparator": Configure the separator if there are multiple same tags (" | " by default)\n
/// * (NOT IMPLEMENTED YET) "TagSeparator_Get": return the state of "TagSeparator" \n
/// * (NOT IMPLEMENTED YET) "Internet": Authorize Internet connection (Yes by default)
/// * (NOT IMPLEMENTED YET) "Internet_Title_Get": When State=5000, give all possible titles for this file (one per line) \n
/// Form: Author TagSeparator Title TagSeparator Year\n...
/// * (NOT IMPLEMENTED YET) "Internet_Title_Set": Set the Good title (same as given by Internet_Title_Get) \n
/// Form: Author TagSeparator Title TagSeparator Year
/// * "Info_Parameters": Information about what are known unique names for parameters \n
/// * "Info_Parameters_CSV": Information about what are known unique names for parameters, in CSV format \n
/// * "Info_Codecs": Information about which codec is known \n
/// * "Info_Version": Information about the version of MediaInfoLib
/// * "Info_Url": Information about where to find the last version
//配置
String Option (const String &Option, const String &Value=String());
/// Configure or get information about MediaInfoLib
/// @param Option The name of option
/// @param Value The value of option
/// @return Depend of the option: by default "" (nothing) means No, other means Yes
/// @post Known options are: See MediaInfo::Option()
static String Option_Static (const String &Option, const String &Value=String());
/// @brief (NOT IMPLEMENTED YET) Get the state of the library
/// @retval <1000 No information is available for the file yet
/// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet
/// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n
/// Warning: even there is only one possible, user interaction (or the software) is needed
/// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet
/// @retval <10000 Done
size_t State_Get ();
/// @brief Count of streams of a stream kind (StreamNumber not filled), or count of piece of information in this stream
/// @param StreamKind Kind of stream (general, video, audio...)
/// @param StreamNumber Stream number in this kind of stream (first, second...)
/// @return The count of fields for this stream kind / stream number if stream number is provided, else the count of streams for this stream kind
size_t Count_Get (stream_t StreamKind, size_t StreamNumber=(size_t)-1); private :
MediaInfo_Internal* Internal; //Constructor
MediaInfo (const MediaInfo&); // Prevent copy-construction
MediaInfo& operator=(const MediaInfo&); // Prevent assignment
};
由代码可见,MediaInfo实际上不仅仅可以读取一个特定路径的文件【Open (const String &File_Name);】
,而且可以读取一块内存中的数据【Open (const ZenLib::int8u* Begin, size_t Begin_Size, const ZenLib::int8u* End=NULL, size_t End_Size=0, ZenLib::int64u File_Size=0)】(这个函数目前还没有使用过)。
如果想要获取完整的信息,可以使用【Inform (size_t Reserved=0)】,并且使用【Option (const String &Option, const String &Value=String())】进行配置。
如果只想获得特定的信息,可以使用【Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text)】。
具体使用方法参见http://blog.csdn.net/leixiaohua1020/article/details/11902195。
MediaInfo源代码分析 2:API函数的更多相关文章
- MediaInfo源代码分析 3:Open()函数
我们来看一下MediaInfo中的Open()函数的内部调用过程 首先open函数封装了MediaInfo_Internal类中的open()函数 //打开文件 size_t MediaInfo::O ...
- MediaInfo源代码分析 4:Inform()函数
我们来看一下MediaInfo中的Inform()函数的内部调用过程 首先Inform()函数封装了MediaInfo_Internal类中的Inform()函数 //返回文件信息 String Me ...
- MediaInfo源代码分析 1:整体结构
MediaInfo 用来分析视频和音频文件的编码和内容信息,是一款是自由软件 (免费使用.免费获得源代码).之前编程的时候,都是直接调用它提供的Dll,这次突然来了兴趣,想研究一下它内部究竟是怎么实现 ...
- 1.2. chromium源代码分析 - chromiumframe - 入口函数
ChromiumFrame的入口函数在main.cpp中,打开main.cpp.中包含3个类和_tWinMain函数._tWinMain就是我们要找的入口函数.我做了部分注释: int APIENTR ...
- javascript 引擎Rhino源代码分析 浅析 实例函数对象及this
http://blog.csdn.net/liantian_wu/article/details/49797481
- 【API】恶意样本分析手册——API函数篇
学编程又有材料了 http://blog.nsfocus.net/malware-sample-analysis-api/
- Media Player Classic - HC 源代码分析 6:MediaInfo选项卡 (CPPageFileMediaInfo)
===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...
- Zepto源代码分析之二~三个API
因为时间关系:本次仅仅对这三个API($.camelCase.$.contains.$.each)方法进行分析 第一个方法变量转驼峰:$.camelCase('hello-world-welcome' ...
- Media Player Classic - HC 源代码分析 2:核心类 (CMainFrame)(1)
===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...
随机推荐
- (转载)DBGridEh导出Excel等格式文件
DBGridEh导出Excel等格式文件 uses DBGridEhImpExp; {--------------------------------------------------------- ...
- C# 拷贝数组的几种方式
突然学到了,所以就放到博客上来共享一下,权当是学习日记吧. 首先说明一下,数组是引用类型的,所以注意不要在复制时复制了地址而没有复制数值哦! 其实在复制数组的时候,一定要用new在堆中开辟一块新的空间 ...
- Oracle死锁只会回滚跟死锁有关的那条SQL,而不会回滚整个事务
数据库检测到死锁后,只会回滚跟死锁有关的某条语句,而不会回滚整个事务. 创建测试环境:SQL> create table test1(id int,name char(1)); 表已创建. SQ ...
- Spring实战——无需一行xml配置实现自动化注入
已经想不起来上一次买技术相关的书是什么时候了,一直以来都习惯性的下载一份电子档看看.显然,如果不是基于强烈的需求或强大的动力鞭策下,大部分的书籍也都只是蜻蜓点水,浮光掠影. 就像有位同事说的一样,有些 ...
- sql server 表空间
在SqlServer2005中,建表时是默认把所有的表都保存在PRIMARY默认表空间中的.当数据库中表很多,并且数据量很大时,会导致数据库性能严重下降,有必要将一些大的表放到不同的表空间中去.主要的 ...
- win7系统cocos2dx 3.4 绑定自定义类到Lua
Cocos2d-x 3.0开始使用bindings-generator来生成c++类的lua绑定.bindings-generator基于tolua++,通过配置tools/tolua中的ini文件以 ...
- KVC - 键值编码
[基本概念] 1.键值编码是一个用于间接访问对象属性的机制,使用该机制不需要调用存取方法和变量实例就可访问对象属性. 2.键值编码方法在OC非正式协议(类目)NSKeyValueCoding中被声明, ...
- 定位 - CoreLocation - 打印位置信息
1. 导入框架 <CoreLocation.framework>, 引入头文件 import <CoreLocation/CoreLocation.h>; 2. 创建管理者对象 ...
- 从小白进阶ubuntu高手的必经之路—命令
精选的十二个ubuntu下的命令,熟记于心,则能甩掉ubuntu小白标签,高手的伟岸形象焕然生发.一.管理员权限绝大部分情况下,命令的行为须要被赋予管理员权限才能执行.命令 sudo 作用:赋予当前命 ...
- JDK神坑:JAVA中Calendar的月份Month少1
很多朋友在使初次使用Calendar时,会发现月份莫名其妙对不上,显示的结果总是比预期中小1个月,检查好几遍也没发现程序有错,于是开始抓狂.其实这个时候,只要去看JDK就会明白问题所在.JDK告诉我们 ...