我们来看一下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<Count_Get(Stream_Video); I1++)
{
Retour+=Inform(Stream_Video, I1, false);
if (I1!=Count_Get(Stream_Video)-1)
Retour+=MediaInfoLib::Config.Inform_Get(__T("Video_Middle"));
}
if (Count_Get(Stream_Video))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Video_End"));
if (Count_Get(Stream_Audio))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Audio_Begin"));
for (size_t I1=0; I1<Count_Get(Stream_Audio); I1++)
{
Retour+=Inform(Stream_Audio, I1, false);
if (I1!=Count_Get(Stream_Audio)-1)
Retour+=MediaInfoLib::Config.Inform_Get(__T("Audio_Middle"));
}
if (Count_Get(Stream_Audio))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Audio_End"));
if (Count_Get(Stream_Text))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Text_Begin"));
for (size_t I1=0; I1<Count_Get(Stream_Text); I1++)
{
Retour+=Inform(Stream_Text, I1, false);
if (I1!=Count_Get(Stream_Text)-1)
Retour+=MediaInfoLib::Config.Inform_Get(__T("Text_Middle"));
}
if (Count_Get(Stream_Text))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Text_End"));
if (Count_Get(Stream_Other))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Chapters_Begin"));
for (size_t I1=0; I1<Count_Get(Stream_Other); I1++)
{
Retour+=Inform(Stream_Other, I1, false);
if (I1!=Count_Get(Stream_Other)-1)
Retour+=MediaInfoLib::Config.Inform_Get(__T("Chapters_Middle"));
}
if (Count_Get(Stream_Other))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Chapters_End"));
if (Count_Get(Stream_Image))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Image_Begin"));
for (size_t I1=0; I1<Count_Get(Stream_Image); I1++)
{
Retour+=Inform(Stream_Image, I1, false);
if (I1!=Count_Get(Stream_Image)-1)
Retour+=MediaInfoLib::Config.Inform_Get(__T("Image_Middle"));
}
if (Count_Get(Stream_Image))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Image_End"));
if (Count_Get(Stream_Menu))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Menu_Begin"));
for (size_t I1=0; I1<Count_Get(Stream_Menu); I1++)
{
Retour+=Inform(Stream_Menu, I1, false);
if (I1!=Count_Get(Stream_Menu)-1)
Retour+=MediaInfoLib::Config.Inform_Get(__T("Menu_Middle"));
}
if (Count_Get(Stream_Menu))
Retour+=MediaInfoLib::Config.Inform_Get(__T("Menu_End"));
Retour+=MediaInfoLib::Config.Inform_Get(__T("File_End"));
//可以在此加入视频质量检测----------------------------------------- //字符串替换?各种换行符统统改为“\n”-----------------------------
Retour.FindAndReplace(__T("\\r\\n"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\\r"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\\n"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\n"), MediaInfoLib::Config.LineSeparator_Get(), 0, Ztring_Recursive); //Special characters
Retour.FindAndReplace(__T("|SC1|"), __T("\\"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC2|"), __T("["), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC3|"), __T("]"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC4|"), __T(","), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC5|"), __T(";"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC6|"), __T("("), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC7|"), __T(")"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC8|"), __T(")"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC9|"), __T("),"), 0, Ztring_Recursive); return Retour;
} //Informations
Ztring Retour;
bool HTML=false;
bool XML=false;
bool CSV=false;
//获取配置信息(输出格式)
if (MediaInfoLib::Config.Inform_Get()==__T("HTML"))
HTML=true;
if (MediaInfoLib::Config.Inform_Get()==__T("XML"))
XML=true;
if (MediaInfoLib::Config.Inform_Get()==__T("CSV"))
CSV=true; if (HTML) Retour+=__T("<html>\n\n<head>\n<META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head>\n<body>\n");
if (XML) Retour+=__T("<File>\n"); for (size_t StreamKind=(size_t)Stream_General; StreamKind<Stream_Max; StreamKind++)
{
//Pour chaque type de flux
for (size_t StreamPos=0; StreamPos<(size_t)Count_Get((stream_t)StreamKind); StreamPos++)
{
//Pour chaque stream
//输出为HTML
if (HTML) Retour+=__T("<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"2\" style=\"border:1px solid Navy\">\n<tr>\n <td width=\"150\"><h2>");
//输出为XML
if (XML) Retour+=__T("<track type=\"");
Ztring A=Get((stream_t)StreamKind, StreamPos, __T("StreamKind/String"));
Ztring B=Get((stream_t)StreamKind, StreamPos, __T("StreamKindPos"));
if (!XML && !B.empty())
{
if (CSV)
A+=__T(",");
else
A+=MediaInfoLib::Config.Language_Get(__T(" Config_Text_NumberTag"));
A+=B;
}
Retour+=A;
if (XML)
{
Retour+=__T("\"");
if (!B.empty())
{
Retour+=__T(" streamid=\"");
Retour+=B;
Retour+=__T("\"");
}
}
//输出为HTML
if (HTML) Retour+=__T("</h2></td>\n </tr>");
//输出为XML
if (XML) Retour+=__T(">");
Retour+=MediaInfoLib::Config.LineSeparator_Get();
Retour+=Inform((stream_t)StreamKind, StreamPos, false);
Retour.FindAndReplace(__T("\\"), __T("|SC1|"), 0, Ztring_Recursive);
if (HTML) Retour+=__T("</table>\n<br />");
if (XML) Retour+=__T("</track>\n");
Retour+=MediaInfoLib::Config.LineSeparator_Get();
}
}
//输出为HTML
if (HTML) Retour+=__T("\n</body>\n</html>\n");
//输出为XML
if (XML) Retour+=__T("</File>\n");
//字符串替换?
Retour.FindAndReplace(__T("\\r\\n"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\\r"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\\n"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("\n"), MediaInfoLib::Config.LineSeparator_Get(), 0, Ztring_Recursive); //Special characters
Retour.FindAndReplace(__T("|SC1|"), __T("\\"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC2|"), __T("["), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC3|"), __T("]"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC4|"), __T(","), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC5|"), __T(";"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC6|"), __T("("), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC7|"), __T(")"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC8|"), __T(")"), 0, Ztring_Recursive);
Retour.FindAndReplace(__T("|SC9|"), __T("),"), 0, Ztring_Recursive);
return Retour;
}

函数比较复杂,从代码中我们可以看出,Inform()的实质还是使用Get()一个一个取出所有的属性值。

当指定输出为XML或者是HTML的时候,在输出的字符串上加上相应的标签(例如,输出为HTML的时候,字符串每一行上加上“</tr><tr>”,首尾加上“<table></table>”)

具体每一块代码的含义已经写在注释中了。

MediaInfo源代码分析 4:Inform()函数的更多相关文章

  1. MediaInfo源代码分析 2:API函数

    本文主要分析MediaInfo的API函数.它的API函数位于MediaInfo.h文件中的一个叫做MediaInfo的类中. 该类如下所示,部分重要的方法已经加上了注释: //MediaInfo类 ...

  2. MediaInfo源代码分析 3:Open()函数

    我们来看一下MediaInfo中的Open()函数的内部调用过程 首先open函数封装了MediaInfo_Internal类中的open()函数 //打开文件 size_t MediaInfo::O ...

  3. MediaInfo源代码分析 1:整体结构

    MediaInfo 用来分析视频和音频文件的编码和内容信息,是一款是自由软件 (免费使用.免费获得源代码).之前编程的时候,都是直接调用它提供的Dll,这次突然来了兴趣,想研究一下它内部究竟是怎么实现 ...

  4. 1.2. chromium源代码分析 - chromiumframe - 入口函数

    ChromiumFrame的入口函数在main.cpp中,打开main.cpp.中包含3个类和_tWinMain函数._tWinMain就是我们要找的入口函数.我做了部分注释: int APIENTR ...

  5. javascript 引擎Rhino源代码分析 浅析 实例函数对象及this

    http://blog.csdn.net/liantian_wu/article/details/49797481

  6. Media Player Classic - HC 源代码分析 6:MediaInfo选项卡 (CPPageFileMediaInfo)

    ===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...

  7. Media Player Classic - HC 源代码分析 7:详细信息选项卡(CPPageFileInfoDetails)

    ===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...

  8. Media Player Classic - HC 源代码分析 5:关于对话框 (CAboutDlg)

    ===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...

  9. Media Player Classic - HC 源代码分析 4:核心类 (CMainFrame)(3)

    ===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...

随机推荐

  1. Lambda表达式, 可以让我们的代码更优雅.

    在C#中, 适当地使用Lambda表达式, 可以让我们的代码更优雅. 通过lambda表达式, 我们可以很方便地创建一个delegate: 下面两个语句是等价的 Code highlighting p ...

  2. mvc验证码

    public string CreateValidateCode(int length) { int[] randMembers = new int[length]; int[] validateNu ...

  3. java环境变量设置方法

    1.安装JDK,安装过程中可以自定义安装目录等信息,例如我们选择安装目录为D:\java\jdk1.5.0_08:    2.安装完成后,右击“我的电脑”,点击“属性”:         3.选择“高 ...

  4. 各大Oj平台介绍[转]

    1.题库与网站资源题库-在线提交系统(Online Judge)简介   下面是几个比较大的在线提交系统(OnlineJudge)里面有大量历年的竞赛题目,注册一个ID,然后用自己熟悉的语言(一般有P ...

  5. 如何用OS X的Xcode写C语言程序

    声明:以下内容非本人原创,转载于别处.拿出来只是分享给FY们,不喜勿喷!原创地址http://blog.yorkxin.org/posts/2009/03/15/fundamental-c-with- ...

  6. nutch getOutLinks 外链的处理

    转载自: http://blog.csdn.net/witsmakemen/article/details/8067530 通过跟踪发现,Fetcher获得网页解析链接没有问题,获得了网页中所有的链接 ...

  7. bzoj 1414: [ZJOI2009]对称的正方形 manacher算法+單調隊列

    1414: [ZJOI2009]对称的正方形 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 331  Solved: 149[Submit][Stat ...

  8. Contest20140705 testC DP

    testC 输入文件: testC.in 输出文件testC.out 时限1000ms 问题描述: ,⋯,an. ,a2,a3,⋯,an) ,⋯,alm. ,al2,al3,⋯,alm) 现要求G=g ...

  9. [UOJ 74] 【UR #6】破解密码

    题目链接:UOJ - 74 题目分析 题目中,将字符串 S 的第一个字符移到末尾,其他字符向前移动一个位置,f(S) 就从 Hi 变成了 Hi+1. 我们分析一下这个过程:假设第一个字符为 c, (H ...

  10. 【 POJ - 1204 Word Puzzles】(Trie+爆搜|AC自动机)

    Word Puzzles Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 10782 Accepted: 4076 Special ...