DirectShow开发环境配置及测试例程(VC6)
2007-08-17 16:16
465 查看
开发环境
SDK:DirectX9.0b (Summer 2003)
Visual C++ 6.0
参考文档:SDK文档
1) DirectShow->Getting Started->Setting Up the Build Environment
2) DirectShow->DirectShow Reference->DirectShow Base Classes->Using the DirectShow Base Classes
3) DirectShow->Getting Started->How To Play a File
测试例子:SDK文档
DirectShow->Getting Started->How To Play a File
配置说明:
1. Tools->Options->Directories
Include - 添加<SDK root>/Include
Lib - 添加<SDK root>/Lib
- 添加<SDK root>/SAMPLES/C++/DirectShow/BASECLASSES/DEBUG // [注1]
2. Build BaseClasses
打开<SDK root>/Samples/C++/DirectShow/BaseClasses/baseclasses.dsp,编译debug得到Strmbasd.lib。 // [注2]
3. Project->Setting->Link
添加Strmbasd.lib
4. 添加头文件
#include <Dshow.h> // 所有DirectShow应用程序必备
#include <Streams.h> // 使用DirectShow基类
源代码如下,代码分析见参考文档3)
#include <Dshow.h>
#include <Streams.h>
#include <stdio.h>
void main(void)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return;
}
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return;
}
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// Build the graph. IMPORTANT: Change this string to a file on your system.
// hr = pGraph->RenderFile(L"C://Example.avi", NULL);
hr = pGraph->RenderFile(L"E://DX90SDK//Samples//Media//chicken.wmv", NULL); // 打开一个媒体文件
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}
注1:该处可根据需要添加不同版本,如RELEASE/Debug_Unicode/Release_Unicode。
注2:debug - strmbasd.lib;release - strmbase.lib;另外还有对应的Unicode版本。
注3:步骤3缺,将导致
error LNK2001: unresolved external symbol _IID_IMediaEvent
error LNK2001: unresolved external symbol _IID_IMediaControl
error LNK2001: unresolved external symbol _CLSID_FilterGraph
error LNK2001: unresolved external symbol _IID_IGraphBuilder
Debug/Howtoplayafile.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
*******************************************************************************
先编译BaseClasses,再在project->settings里面配置C/C++,下拉框选Preprocessor,确认有DEBUG,没有就加上,再配置Link,去掉"../../BASECLASSES/DEBUG_UNICODE/strmbasd.lib",换成你的BaseClasses所在目录,配置Tools->Options目录里面的Directory和Lib,分别加上“DXSDK/Include”,"Samples/c++/Directshow/baseclasses"和“Samples/c++/Directshow/baseclasses/debug”,“Samples/c++/Directshow/baseclasses/release”
"DXSDK/Lib"
SDK:DirectX9.0b (Summer 2003)
Visual C++ 6.0
参考文档:SDK文档
1) DirectShow->Getting Started->Setting Up the Build Environment
2) DirectShow->DirectShow Reference->DirectShow Base Classes->Using the DirectShow Base Classes
3) DirectShow->Getting Started->How To Play a File
测试例子:SDK文档
DirectShow->Getting Started->How To Play a File
配置说明:
1. Tools->Options->Directories
Include - 添加<SDK root>/Include
Lib - 添加<SDK root>/Lib
- 添加<SDK root>/SAMPLES/C++/DirectShow/BASECLASSES/DEBUG // [注1]
2. Build BaseClasses
打开<SDK root>/Samples/C++/DirectShow/BaseClasses/baseclasses.dsp,编译debug得到Strmbasd.lib。 // [注2]
3. Project->Setting->Link
添加Strmbasd.lib
4. 添加头文件
#include <Dshow.h> // 所有DirectShow应用程序必备
#include <Streams.h> // 使用DirectShow基类
源代码如下,代码分析见参考文档3)
#include <Dshow.h>
#include <Streams.h>
#include <stdio.h>
void main(void)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return;
}
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return;
}
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// Build the graph. IMPORTANT: Change this string to a file on your system.
// hr = pGraph->RenderFile(L"C://Example.avi", NULL);
hr = pGraph->RenderFile(L"E://DX90SDK//Samples//Media//chicken.wmv", NULL); // 打开一个媒体文件
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}
注1:该处可根据需要添加不同版本,如RELEASE/Debug_Unicode/Release_Unicode。
注2:debug - strmbasd.lib;release - strmbase.lib;另外还有对应的Unicode版本。
注3:步骤3缺,将导致
error LNK2001: unresolved external symbol _IID_IMediaEvent
error LNK2001: unresolved external symbol _IID_IMediaControl
error LNK2001: unresolved external symbol _CLSID_FilterGraph
error LNK2001: unresolved external symbol _IID_IGraphBuilder
Debug/Howtoplayafile.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
*******************************************************************************
先编译BaseClasses,再在project->settings里面配置C/C++,下拉框选Preprocessor,确认有DEBUG,没有就加上,再配置Link,去掉"../../BASECLASSES/DEBUG_UNICODE/strmbasd.lib",换成你的BaseClasses所在目录,配置Tools->Options目录里面的Directory和Lib,分别加上“DXSDK/Include”,"Samples/c++/Directshow/baseclasses"和“Samples/c++/Directshow/baseclasses/debug”,“Samples/c++/Directshow/baseclasses/release”
"DXSDK/Lib"
相关文章推荐
- VC6 下配置DirectShow SDK开发环境及下载地址
- VC6配置DIRECTSHOW开发环境
- VC6配置DIRECTSHOW开发环境
- Cocos2d-x开发FlappyBird01-环境变量配置和测试案例运行
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- 通过Maven配置测试环境和开发环境连接不同的数据库
- 实现开发环境、测试环境、生产环境配置自动切换
- DirectShow在vs2005中配置directshow开发环境
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- VS2010 配置DirectShow开发环境
- Web开发之tomcat配置及使用(环境变量设置及测试,一个简单的web应用实例)
- GO语言初探(一) 开发环境配置及测试 .
- 关于软件开发环境 jdk,tomcat和maven的配置以及测试
- DirectShow开发环境配置
- DirectShow学习之一在vs2005中配置directshow开发环境
- Java日志框架-logback配置文件多环境日志配置(开发、测试、生产)(原始解决方法)
- 前端开发之配置-移动端真机测试环境的搭建小白教程
- maven: 开发、测试和生产环境使用不同的配置文件例子