注:此前已经写了一系列分析MediaInfo源代码的文章,列表如下:
===================
我们来看一下MediaInfo中的Inform()函数的内部调用过程
首先Inform()函数封装了MediaInfo_Internal类中的Inform()函数
//返回文件信息String MediaInfo::Inform(size_t){ //封装了一层 return Internal->Inform();}查看一下MediaInfo_Internal类中的Inform()函数的源代码:
// 获取信息Ztring MediaInfo_Internal::Inform(){ CS.Enter(); if (Info && Info->Status[File__Analyze::IsUpdated]) Info->Open_Buffer_Update(); CS.Leave(); if (MediaInfoLib::Config.Inform_Get()==__T("MPEG-7")) return Export_Mpeg7().Transform(*this); if (MediaInfoLib::Config.Inform_Get()==__T("PBCore") || MediaInfoLib::Config.Inform_Get()==__T("PBCore_1.2")) return Export_PBCore().Transform(*this); if (MediaInfoLib::Config.Inform_Get()==__T("reVTMD")) return __T("reVTMD is disabled due to its non-free licensing."); //return Export_reVTMD().Transform(*this); //获取相应的信息 if (!( MediaInfoLib::Config.Inform_Get(__T("General")).empty() && MediaInfoLib::Config.Inform_Get(__T("Video")).empty() && MediaInfoLib::Config.Inform_Get(__T("Audio")).empty() && MediaInfoLib::Config.Inform_Get(__T("Text")).empty() && MediaInfoLib::Config.Inform_Get(__T("Chapters")).empty() && MediaInfoLib::Config.Inform_Get(__T("Image")).empty() && MediaInfoLib::Config.Inform_Get(__T("Menu")).empty() )) { //获取各种信息 //Retour即为返回的字符串 Ztring Retour; Retour+=MediaInfoLib::Config.Inform_Get(__T("File_Begin")); Retour+=MediaInfoLib::Config.Inform_Get(__T("General_Begin")); Retour+=Inform(Stream_General, 0, false); Retour+=MediaInfoLib::Config.Inform_Get(__T("General_End")); if (Count_Get(Stream_Video)) Retour+=MediaInfoLib::Config.Inform_Get(__T("Video_Begin")); for (size_t I1=0; I1函数比较复杂,从代码中我们可以看出,Inform()的实质还是使用Get()一个一个取出所有的属性值。\n\n\n \n\n"); if (XML) Retour+=__T(" \n"); for (size_t StreamKind=(size_t)Stream_General; StreamKind \n\n "); //输出为XML if (XML) Retour+=__T("
当指定输出为XML或者是HTML的时候,在输出的字符串上加上相应的标签(例如,输出为HTML的时候,字符串每一行上加上“</tr><tr>”,首尾加上“<table></table>”)
具体每一块代码的含义已经写在注释中了。