代码改变世界

xbmc-12.0稳定版代码初探 (2) —— XBMC_HOME

2013-01-31 14:04  Scott Guthrie Liu  阅读(347)  评论(0编辑  收藏  举报

XBMC工程在debug时要设置XBMC_HOME的环境

用于指定ffmpeg的Dll文件位置,语言等等

xbmc/filesystem/SpecialProtocol.cpp 定义了一些如: CSpecialProtocol::SetXBMCPath();的函数

xbmc\Application.cpp  InitDirectoriesWin32(); -> CUtil::GetHomePath(xbmcPath);

在Util.h看到static void GetHomePath(CStdString& strPath, const CStdString& strTarget = "XBMC_HOME");

直接编译完的debug的exe是不能单独运行的 可以在Application.cpp Line 1134行设置如: xbmcPath = "D:\\xbmc\\xbmc-12.0";  //CUtil::GetHomePath(xbmcPath);

在程序中路径都被重新映射到被设置的目录,安装时另有一个参数

special://xbmc/ is mapped to: D:\xbmc\xbmc-12.0
special://xbmcbin/ is mapped to: D:\xbmc\xbmc-12.0

DllPaths_win32.h是对这些的定义, 如:

/* ffmpeg */
#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-53.dll"
#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-53.dll"
#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-51.dll"

如:对应 DECLARE_DLL_WRAPPER(DllAvFormat, DLL_PATH_LIBAVFORMAT)

实际执行代码为 public: DllAvFormat () : DllDynamic( "special://xbmcbin/system/players/dvdplayer/avformat-53.dll" ) {}
初始化:

DllDynamic::DllDynamic(const CStdString& strDllName)
{
m_strDllName=strDllName;
m_dll=NULL;
m_DelayUnload=true;
}

dll延迟加载到, FFmpegVideoDecoder初始化时才创建

FFmpegVideoDecoder::FFmpegVideoDecoder()
{
m_pFormatCtx = 0;
m_pCodecCtx = 0;
m_pCodec = 0;
m_pFrame = 0;
m_pFrameRGB = 0;

m_dllAvFormat = new DllAvFormat();
m_dllAvCodec = new DllAvCodec();
m_dllAvUtil = new DllAvUtil();
m_dllSwScale = new DllSwScale();
}

使用库中的函数前, 经过if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllAvFormat.Load())判断是否加载

这个基本是xbmc使用ffmpeg的动态库过程