Direct show 开发时注意的一些问题

来源:互联网 发布:好看的男装 知乎 编辑:程序博客网 时间:2024/05/07 15:31

由于对今后图形图象,包括音频部分的开发有很大的影响,特总结下.现在状态为环境搭建.
======================================================================

今天真是混帐,花费了4,5个小时安装DirectShow。//图形图象管理,音频设置.STREAMS.H文件.

先是下载,ms要正版的windows才能下载,郁闷;找了n久终于找到可以下载的链接

http://hotdl.com/dl/showfile.php?id=640&category=52

另外,DirectX9.0c已经将DShow分离出去了,下载时请选DirectX9.0b或者一下

再是配置DirectShow的VC开发环境
---------------------------
DirectShow开发环境
关键词: 环境配置                                          
http://mercredi.bokee.com/3057881.html
1,使用VC向导生成一个具体项目,如Win32 Dynamic-Link;

2,包含头文件streams.h;

3,在VC的菜单中选择Project|Settings|C/C++,在弹出的对话框中的Category中选择Code generation,然后在Calling convention中选择_stdcall;

4,使用多线程语言运行时库,即在VC的菜单中选择Project|Settings|C/C++,在弹出的对话框中的Category中选择Code generation,然后在Use run-time library中,Debug版选择Debug Multithreaded,Release版选择Multithreaded。

5,配置必要的链接库文件,即在VC的菜单中选择Project|Settings|Link,在弹出的对话框中的Category中选择General,然后在Object/library modules中输入如下代码:

    Debug版本   strmbasd.lib, msvcrtd.lib, winmm.lib

    Release版本 strmbase.lib, msvcrt.lib, winmm.lib

并且选中Ignore all default libraries。

DirectShow SDK建议,DirectShow应用程序应该至少连接库文件strmiids.lib和quartz.lib。前者定义了DirectShow标准的CLSID和IID,后者定义了导出函数AMGetErrorText(如果应用程序中没有使用到这个函数,也可以不连接这个库)。如果程序里包含了头文件streams.h,则一般库文件还要连接strmbasd.lib、uuid.lib、winmm.lib。

6,将DirectX SDK的Include和Lib目录配置到VC的系统目录中去,并且放在标准的VC目录之前,以保证编译器能够拿到最新版本的源文件。选择Tools|Options|Directories,在弹出的对话框中的Show directories for中选择Include files,配置如下(假设DirectX SDK安装在D:/DXSDK目录下,VC安装在C:/Program Files下):

    D:/DXSDK/Include

    D:/DXSDK/SAMPLES/C++/DIRECTSHOW/BASECLASSES

    D:/DXSDK/SAMPLES/C++/COMMON/INCLUDE

    C:/Program Files/Microsoft Visual Studio/VC98/INCLUDE

    C:/Program Files/Microsoft Visual Studio/VC98/MFC/INCLUDE

    C:/Program Files/Microsoft Visual Studio/VC98/ATL/INCLUDE

再在Show directories for中选择Library files,配置如下:

    D:/DXSDK/Lib

    D:/DXSDK/SAMPLES/C++/DIRECTSHOW/BASECLASSES/DEBUG

    D:/DXSDK/SAMPLES/C++/DIRECTSHOW/BASECLASSES/RELEASE

    C:/PROGRAM FILES/MICROSOFT SDK/LIB

    C:/Program Files/Microsoft Visual Studio/VC98/LIB

    C:/Program Files/Microsoft Visual Studio/VC98/MFC/LIB

7,因为DirectShow应用程序是一种COM客户程序,因此在调用任何COM函数之前调用CoInitialize()(或CoInitializeEx)函数进行COM库的初始化(一般是在应用程序启动的时候调用一次),在结束COM库使用时调用CoUninitialize()函数进行反初始化(一般是在应用程序退出前调用一次)。
----------------------------
配置时的问题【一定要注意】
1。include和lib的路径前后顺序一定要“非常严格按照上面顺序排列”,否则
  1.1 DXSDK/Include和VC98/INCLUDE有头文件名是重名的,例如control.h,strmif.h。所以要优先选择DXSDK的文件声明。
  2.1 DXSDK/Lib和VC98/LIB对 DWORD_PTR 这个数据类型的声明顺序出现编译上连接的歧异!!!!

2。BASECLASSES/DEBUG和BASECLASSES/RELEASE目录和目录里面是内容是没有的,如果你在应用程序中使用了BASECLASSES里面的class,function,filter,interface,就要先用VC编译baseclasses.dsw,编译时请分别选定DEBUG和RELEASE,因为baseclasses.dsw有4个版本,而且默认下都不是DEBUG和RELEASE。编译后生成两个重要文件:strmbasd.lib(Debug),STRMBASE.lib(Release),在以后将用到。


          2006-05-27 03:43:05

===============================================================================================

VS2005下的DirectShow配置
VS2005下的DirectShow配置

安装Dx9SDK

由于2005Feburary以后的SDK是dx9.0c,都去掉了DirectShow了,我下的dx9.0b的SDK。
编译其下的例子 /Samples/C++/DirectShow/BaseClasses 分别获得debug版和Release 版的库的strmbasd.lib ( release 版 STRMBASE.lib )。
这一步在vs2005以前版本都能过,但2005编译比以前版本更严格了。从microsoft论坛上摘抄一些相关讨论:

The VC2005 compiler is stricter about enforcing some things in the C++ standard.
You can set the compiler to be less strict. (I don't know the setting off the top of my header), or modify the base classes. See:
http://blogs.msdn.com/mikewasson/archive/2005/05/23/421116.aspx

Try this:
If you have a VS2005 Solution with the Direct Show Base classes:
Open Configuration Properties,  Open C/C++,  Open Language
Set the property "Force Conformance In For Loop Scope" to "No"
If you are going to use the PSDK+nmake, copy the win32.mak file to the BaseClasses folder. (best to copy it to your own folder)
Use the Win2000 environment, I had problems with XP.
Edit your local win32.mak "-GS" (turn off security checks) as part of the common flags macro and also find the flag to turn off the loop conformance.  I modified the code so it was not needed for my build. I think the flag is "-Zc:forScope-".

 Yes or what I did and kept documented a while ago:

1. CtlUtil.h:

class

2. OutputQ.cpp:

HRESULT COutputQueue::ReceiveMultiple (

3. WinUtil.cpp:

HRESULT CImagePalette::MakeIdentityPalette(PALETTEENTRY *pEntry,INT iColours, LPSTR szDevice) {
...

   UINT Count ;
   for ( Count = 0;Count < Result;Count++) {

4. wxdebug.cpp:

BOOL WINAPI DbgCheckModuleLevel(DWORD Type,DWORD Level)
...

        static DWORD g_dwLastRefresh = 0;
        DWORD dwTime = timeGetTime();

按照以上修改baseclasses源码后编译通过。

编译DirectShow应用程序,全局设置如下:

选择菜单项tool、options、directories,在弹出的对话框中的show directories for中选择include files,添加配置如下(假设directx sdk安装在D:/dxsdk目录下):

D:/dxsdk/include

D:/dxsdk/samples/c++/directshow/baseclasses

D:/dxsdk/samples/c++/common/include

再在show directories for中选择 library files,添加配置如下:

D:/dxsdk/lib

D:/dxsdk/samples/c++/directshow/baseclasses/debug

D:/dxsdk/samples/c++/directshow/baseclassed/release

   ...
   LONG iDone ;
   for (iDone = 0 ;
COARefTime : public CRefTime {
   ...
   private
:
      COARefTime & operator=(LONG);
// YD: added COARefTime &
} ;

Some DirectShow Samples Break in Visual Studio 2005

[Note: This post applies to the Platform SDK for Windows Server 2003 SP1 and Server 2003 R2. These issues were fixed in the Windows SDK for Vista.]  

Some of the DirectShow samples break if you install Visual Studio 2005 Beta 2. Most of the errors that I found fall into three categories:

  • C4430: Missing type specifier. To conform with C++, undeclared types do not default to int. All types must be declared. Fix: Declare the type, or suppress the warning with the "/wd4430" flag.
  • C4996: ' xxxx' was declared deprecated. You may be including an older version of strsafe.h from the DirectX SDK or the Platform SDK. You should include the version installed with Visual Studio. (But it's probably harmless to ignore this warning.) 
  • C2065: 'xxx': undeclared identifier. To conform with C++, the scope of a variable declared inside a "for" loop is restricted to the loop. Fixes: (a) Move the declaration outside the for loop. (b) Redeclare the variable in multiple scopes, if you don't need it to persist outside the loop. (c) Set the /Zc:forScope flag. (You can find this under Project, Properties, Configuration Properties, C/C++, Language, Force Conformance In For Loop Scope. Set to "No".)

Here are the specific fixes that I made. Warning: I have not thoroughly tested these, and I only tried them under the "Windows XP 32-bit Debug" environment in Platform SDK. You should use your own judgment before making any of these fixes.

  • BaseClasses/ctlutil.h (278)  
        (LONG) operator=(LONG);
  • BaseClasses/wxdebug.cpp (564)
        static DWORD g_dwLastRefresh = 0;
  • BaseClasses/winutil.cpp (2092)
       UINT Count;
       for (Count = 0;Count < Result;Count++) {
  •  BaseClasses/outputq.cpp (635)
       long iDone = 0;
       for (iDone = 0;
  • Capture/AmCap/amcap.cpp (691)
        for(int i = 0; i < NUMELMS(gcap.rgpmAudioMenu); i++)
  • Capture/AmCap/amcap (2795)
        for(int i = 0; i < NUMELMS(gcap.rgpmAudioMenu); i++)
  • DMODemo/dsutil.cpp (686)
        DWORD i = 0;
        for( i=0; i<m_dwNumBuffers; i++ )
  • dmoimpl.h (622)   [In the Platform SDK headers]
        for (DWORD dw = 0; dw < NUMBEROFOUTPUTS; dw++) {
  • DMO/GargleDMO/MedParamBase/param.cpp (91)
        for (DWORD dwIndex = 0; dwIndex < cParams; dwIndex++)
  • DMO/GargleDMO/MedParamBase/param.cpp (309)
        CCurveItem *pCurve = NULL;
        for (pCurve = pCurveHead;
  • DMO/GargleDMO/gargle.cpp (145)
        for (DWORD i = 0; i < cOutputStreams && SUCCEEDED(hr); ++i)
  • Filters/Dump/dump.cpp (426)
        for (int Loop = 0;Loop < (DataLength % BYTES_PER_LINE);Loop++)
  • Filters/Gargle/gargle.cpp (212)
        static int m_nInstanceCount; // total instances
  • Filters/RGBFilters/RateSource/ratesource.cpp (382)
        for( int y = 0 ; y < DEFAULT_HEIGHT ; y++ )
  • Filters/RGBFilters/RateSource/ratesource.cpp (387)
        for( int y = 0 ; y < DEFAULT_WIDTH ; y++ )
  • VMR/VMRXclBasic and VMR/Ticker: LNK1181: cannot open input file 'dxguid.lib'. This was an error in the makefile. Change to read:
        DXLIB="$(DXSDK_DIR)/Lib/x86"  (currently says "x32")
  • VMR/VMRXcl and VMR/VMRMulti: C1083: Cannot open include file: 'd3dxmath.h': No such file or directory. This is an old DX header that is no longer included in DX or in Visual Studio. Unfortunately the only fix is to download an older version of the DirectX SDK.
  • VMR9/MultiVMR9/GamePlayer/character.cpp (383)
        DWORD i = 0;
        for (i = 0; i < pMeshContainer->NumInfl; ++i)
  • VMR9/MultiVMR9/DLL/MixerControl.h (28)
        static const DWORD MultiVMR9Mixer_DefaultFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1;
  • VMR9/VMRAllocator: error LNK2019: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" (etc).  Add this to the makefile:
        LINK32_LIBS = /
        comsuppw.lib /
        shell32.lib /