Microsoft DirectShow.

Slides:



Advertisements
Similar presentations
Programming with OpenGL - Getting started - Hanyang University Han Jae-Hyek.
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Using Macros and Visual Basic for Applications (VBA) with Excel
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Windows 7. Objectives After completing this lesson, you will be able to: oExplain the common functions of an operating system. oIdentify the basic components.
Introduction to DirectX Implementation. Installing DirectX SDK To write and execute DirectX 9.0 programs, you need both : DirectX 9.0 runtime and the.
Using PlayCap. Introduction  Based on: 1. Win32 API 2. DirectShow API 3. GDI+ API  Platform Windows XP  IDE Visual Studio.Net 2003.
Chapter 1- Visual Basic Schneider 1 Chapter 1 An Introduction to Computers and Visual Basic.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
© 2010 IBM Corporation IBM Experience Modeler - Theme Editor Installing Python Image Library Presenter’s Name - Presenter’s Title DD Month Year.
Software Development. Chapter 3 – Your first Windows 8 app.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
©2005 GE Fanuc Automation, Inc. All Rights Reserved PACSystems Training Programmer’s Toolkit.
taskbar Notification area Start To change size of taskbar: RMC- uncheck Lock the taskbar Changing Properties : RMC- Properties.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
OPENCV TUTORIAL OpenCV Windows 7 Microsoft Visual C++ Express 2010.
1 INF160 IS Development Environments AUBG, COS dept Lecture 06 Title: Dev Env: Code::Blocks (Extract from Syllabus) Reference:
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
Multimedia Framework and Libraries
A Tutorial to DirectShow Ruigang Yang August, 2001.
Introduction to Android. Android as a system, is a java based operating system that runs on the Linux kernel. The system is very lightweight and full.
DirectShow.
Presented by : Olivia Lin. Outline Preparation works –What software do I need? Source of sample codes –Online source: Supergeo Developer Network (SGDN)
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
Introduction to Matlab & Data Analysis
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
FLTK Tutorial.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Active-HDL Interfaces Debugging C Code Course 10.
H.323, IP Multicast Conferencing, And TAPI 3.0 Don Ryan Development Lead Windows Networking And Communications Microsoft Corporation.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
Sound DirectMusic & DirectSound. DirectShow Video Formats DirectShow is an open architecture, it can support any format as long as there are filters to.
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Microsoft Office XP Illustrated Introductory, Enhanced Started with Windows 2000 Getting.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
Lesson No: 6 Introduction to Windows XP CHBT-01 Basic Micro process & Computer Operation.
Bit-DSP-MicrocontrollerTMS320F2812 Texas Instruments Incorporated European Customer Training Center University of Applied Sciences Zwickau (FH)
1 Programming Environment and Tools VS.Net 2012 First project MSDN Library.
Microsoft DirectX 8.0 Project Introduction Microsoft COM DirectShow Instruction: Hsiao Kung Wu Students: 賴建利、林廷駿、楊惟仁.
Java Programming, Second Edition Appendix A Working with Java SDK 1.4.
GAM666 – Introduction To Game Programming ● DirectX is implemented as a collection of COM objects ● To use a DirectX program, the user must have the correct.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Compiling and running Java programs with BlueJ. Successfully compiled files program files in BlueJ You can tell from the shade of a program icon in BlueJ.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Open project in Microsoft Visual Studio → build program in “Release” mode.
1NetBeans Tutorial Using the “Properties” menu, name the List “List1” and the button “Button1”. NetBeans Tutorial6.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
1. 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components,
Development Environment Setup
Eclipse.
Chapter 2: The Visual Studio .NET Development Environment
Programming and Debugging
Chapter 2 – Introduction to the Visual Studio .NET IDE
1. Introduction to Visual Basic
Introduction to VB6 Week 1 3/2/2004 PPCC - Introduction to VB6
Microsoft Windows XP Inside Out Second Edition
Mobile Application Development with MeeGo™ - Programming with SDK
Chapter 2 – Introduction to the Visual Studio .NET IDE
Microsoft Windows 7 Basics
Social Media And Global Computing Creating DLLs with Visual Studio
An Introduction to Computers and Visual Basic
AUDACITY Home Home Preparation Step1 Step2 Step3 Step4 Step5 Step6 Step7 Step8 Step9 Step10PreparationStep1Step2Step3Step4Step5Step6Step7Step8Step9Step10.
Presentation transcript:

Microsoft DirectShow

Introduction DirectShow 是 Microsoft 所提供的函式庫

Software Requirements Operation system Windows XP Development tool Microsoft Visual Studio .NET Visual C++ .NET

Install DirectX 9.0 SDK 到網站下載 SDK 安裝程式 執行所下載程式 http://msdn.microsoft.com/downloads/ 點選 DirectX 9.0 Software Development Kit with DirectX 9.0b Runtime 執行所下載程式 透過安裝介面選擇要安裝的目錄 程式將自動安裝 SDK

Preparing for Compilation 設定工作環境 Add include search paths Add linker search paths Add project link libraries

Add include search paths (1) choose Options from the Tools menu

Add include search paths (2) Select Directories tag Double click the left button on the mouse

Add include search paths (3) Select the SDK include search path Type or browse to select the search path

Add include search paths (4) Shift the include search path to the top of the search directories Press this icon

Add linker search paths (1) choose Options from the Tools menu

Add linker search paths (2) Select Directories tag Double click the left button on the mouse

Add linker search paths (3) Select the SDK include search path Type or browse to select the search path

Add linker search paths (4) Shift the include search path to the top of the search directories Press this icon

Add project link libraries (1) choose settings from the Project menu

Add project link libraries (2) Select the link tag type the name of the project link library

DirectShow Example

Filter DirectShow 中處理 media stream 的基本元件 根據功能,可分成三類 Source filter Transform filter Renderer filter

Filter Graph 將 source filter, transform filter, and Renderer filter 串接起來而形成的圖

Source Filter 從 data source 獲取資料,並將資料傳送到 filter graph 中 資料源可以是攝影機、網際網路、磁片檔等

Transform Filter 獲取、處理和傳送媒體資料 Examples Splitter transform filter Video decoder Audio decoder

Renderer Filter 在硬體上表現媒體資料,如顯示卡和音效卡,或者是任何可以接受媒體資料的地方,如磁片。 Example Video renderer filter Audio renderer filter。

Filter Graph Manager 掌管 Filter Graph 中 filters 的連接 控制 media stream 在 filter 之間的流動

Filter Graph Manager (cont.) 程式開發人員可透過 API 函數對media stream 控制 Examples Run: 啟動 media stream 在 Filter graph 中的流動 Pause:暫停 media stream 的播放 Stop:停止播放 media stream

DirectShow 工具示範 Graph Editor

Programming DirectShow Applications Play a File Building a Filter Graph

Preliminary DirectShow COM Based on Component Object Model(COM) Interface 1 COM object Interface 2 Interface n

Coding Flowchart Running some applications Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Running some applications Releasing the COM interfaces Releasing the COM facilities

Example .…..……Some executions………… Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications Object name CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… Interface name pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example .…..……Some executions………… Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM Interface name IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example .…..……Some executions………… Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example .…..……Some executions………… Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example .…..……Some executions………… Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example .…..……Some executions………… Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Example .…..……Some executions………… Initializing the COM facilities Creating an Instance of a COM Object Querying Interfaces in the COM Object Releasing the COM interfaces Releasing the COM facilities Running some applications CoInitialize (NULL) //Initializes COM IGraphBuilder *pGraphBuilder = NULL; // Pointer to created object HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder); IMediaControl *pMediaControl = NULL; // Store pointer to interface hr = pGraphBuilder->QueryInterface(IID_MediaControl, (void**)&pMediaControl); .…..……Some executions………… pMediaControl->Release(); // Release the object pMediaControl = NULL; // And set it to NULL pGraphBuilder->Release(); // Release the object pGraphBuilder = NULL; // And set it to NULL CoUninitialize(); // Releases COM

Some interfaces IGraphBuilder IMediaControl IMediaEvent provides methods that enable an application to build a filter graph methods: AddSourceFilter, Connect, RenderFile, etc. IMediaControl provides methods for controlling the flow of data through the filter graph methods: Run, Pause, Stop, etc. IMediaEvent contains methods for retrieving event notifications methods: GetEvent, WaitForCompletion, etc.

Query Interfaces in the COM object 1. Play a File #include <dshow.h> void main(void) { IGraphBuilder *pGraph; IMediaControl *pMediaControl; //Handles media streaming in the filter graph IMediaEvent *pEvent; //Handles filter graph events Create the COM object CoInitialize(NULL); // Create the filter graph manager and query for interfaces. CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); Query Interfaces in the COM object pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl); pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

Release the Interfaces 1. Play a File // Build the graph. IMPORTANT: Change string to a file on your system. pGraph->RenderFile(L"C:\\Example.avi", NULL); // Run the graph. pMediaControl->Run(); // Wait for completion. long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); Running …. Release the Interfaces // Clean up. pMediaControl->Release(); pEvent->Release(); pGraph->Release(); CoUninitialize(); } Release the COM

1. Play a File pGraph->RenderFile(L"C:\\Example.avi", NULL); // Build the graph. //IMPORTANT: Change string to a file on your system. pGraph->RenderFile(L"C:\\Example.avi", NULL); // Run the graph. pMediaControl->Run(); // Wait for completion. long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); // Clean up. pMediaControl->Release(); pEvent->Release(); pGraph->Release(); CoUninitialize(); }

2. Building a Filter Graph InputFileFilter DSoundRenderer

2. Building a Filter Graph #include <dshow.h> int main(int argc, char* argv[]) { IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; //Handles media streaming in the filter graph IMediaEvent *pEvent = NULL; //Handles filter graph events IBaseFilter *pInputFileFilter = NULL; IBaseFilter *pDSoundRenderer = NULL; IPin *pFileOut = NULL, *pWAVIn = NULL; // Initialize the COM library. HRESULT hr = CoInitialize(NULL); hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); // Now get the media control interface... hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); // And the media event interface. hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent); hr = pGraph->AddSourceFilter(L“C:\\test.mpg", L“Source File", &pInputFileFilter);

2. Building a Filter Graph #include <dshow.h> int main(int argc, char* argv[]) { IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; //Handles media streaming in the filter graph IMediaEvent *pEvent = NULL; //Handles filter graph events IBaseFilter *pInputFileFilter = NULL; IBaseFilter *pDSoundRenderer = NULL; IPin *pFileOut = NULL, *pWAVIn = NULL;); hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); // Now get the media control interface... hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); // And the media event interface. hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent); FilterGraph InputFileFilter DSoundRenderer hr = pGraph->AddSourceFilter(L“C:\\test.mpg", L“Source File", &pInputFileFilter);

2. Building a Filter Graph #include <dshow.h> int main(int argc, char* argv[]) { IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; //Handles media streaming in the filter graph IMediaEvent *pEvent = NULL; //Handles filter graph events IBaseFilter *pInputFileFilter = NULL; IBaseFilter *pDSoundRenderer = NULL; IPin *pFileOut = NULL, *pWAVIn = NULL; // Initialize the COM library. HRESULT hr = CoInitialize(NULL); hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); // Now get the media control interface... hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); // And the media event interface. hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent); hr = pGraph->AddSourceFilter(L“C:\\test.mpg", L“Source File", &pInputFileFilter);

2. Building a Filter Graph #include <dshow.h> int main(int argc, char* argv[]) { IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; //Handles media streaming in the filter graph IMediaEvent *pEvent = NULL; //Handles filter graph events IBaseFilter *pInputFileFilter = NULL; IBaseFilter *pDSoundRenderer = NULL; IPin *pFileOut = NULL, *pWAVIn = NULL; // Initialize the COM library. HRESULT hr = CoInitialize(NULL); FilterGraph InputFileFilter File name hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); // Now get the media control interface... hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); // And the media event interface. hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent); hr = pGraph->AddSourceFilter(L“C:\\test.mpg", L“Source File", &pInputFileFilter); Filter name

2. Building a Filter Graph hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pDSoundRenderer); // And add the filter to the filter graph // using the member function AddFilter. hr = pGraph->AddFilter(pDSoundRenderer, L"Audio Renderer"); // Obtain the output pin of the source filter. // The local function GetPin does this. pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT); // Obtain the input pin of the WAV renderer. pWAVIn = GetPin(pDSoundRenderer, PINDIR_INPUT); hr = pGraph->Connect(pFileOut, pWAVIn); hr = pControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); hr = pControl->Stop();

2. Building a Filter Graph hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pDSoundRenderer); // And add the filter to the filter graph // using the member function AddFilter. hr = pGraph->AddFilter(pDSoundRenderer, L"Audio Renderer"); Object name // Obtain the output pin of the source filter. // The local function GetPin does this. pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT); // Obtain the input pin of the WAV renderer. pWAVIn = GetPin(pDSoundRenderer, PINDIR_INPUT); Filter name FilterGraph hr = pGraph->Connect(pFileOut, pWAVIn); hr = pControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); hr = pControl->Stop(); InputFileFilter DSoundRenderer

2. Building a Filter Graph hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pDSoundRenderer); // And add the filter to the filter graph // using the member function AddFilter. hr = pGraph->AddFilter(pDSoundRenderer, L"Audio Renderer"); // Obtain the output pin of the source filter. // The local function GetPin does this. pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT); // Obtain the input pin of the WAV renderer. pWAVIn = GetPin(pDSoundRenderer, PINDIR_INPUT); hr = pGraph->Connect(pFileOut, pWAVIn); hr = pControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); hr = pControl->Stop();

2. Building a Filter Graph hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pDSoundRenderer); // And add the filter to the filter graph // using the member function AddFilter. hr = pGraph->AddFilter(pDSoundRenderer, L"Audio Renderer"); // Obtain the output pin of the source filter. // The local function GetPin does this. pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT); // Obtain the input pin of the WAV renderer. pWAVIn = GetPin(pDSoundRenderer, PINDIR_INPUT); FilterGraph hr = pGraph->Connect(pFileOut, pWAVIn); hr = pControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); hr = pControl->Stop(); InputFileFilter DSoundRenderer

2. Building a Filter Graph hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pDSoundRenderer); // And add the filter to the filter graph // using the member function AddFilter. hr = pGraph->AddFilter(pDSoundRenderer, L"Audio Renderer"); // Obtain the output pin of the source filter. // The local function GetPin does this. pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT); // Obtain the input pin of the WAV renderer. pWAVIn = GetPin(pDSoundRenderer, PINDIR_INPUT); hr = pGraph->Connect(pFileOut, pWAVIn); hr = pControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); hr = pControl->Stop();

2. Building a Filter Graph hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pDSoundRenderer); // And add the filter to the filter graph // using the member function AddFilter. hr = pGraph->AddFilter(pDSoundRenderer, L"Audio Renderer"); FilterGraph InputFileFilter DSoundRenderer // Obtain the output pin of the source filter. // The local function GetPin does this. pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT); // Obtain the input pin of the WAV renderer. pWAVIn = GetPin(pDSoundRenderer, PINDIR_INPUT); hr = pGraph->Connect(pFileOut, pWAVIn); hr = pControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); hr = pControl->Stop();

2. Building a Filter Graph hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pDSoundRenderer); // And add the filter to the filter graph // using the member function AddFilter. hr = pGraph->AddFilter(pDSoundRenderer, L"Audio Renderer"); // Obtain the output pin of the source filter. // The local function GetPin does this. pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT); // Obtain the input pin of the WAV renderer. pWAVIn = GetPin(pDSoundRenderer, PINDIR_INPUT); hr = pGraph->Connect(pFileOut, pWAVIn); hr = pControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); hr = pControl->Stop();

2. Building a Filter Graph // Now release everything we instantiated-- // that is, if it got instantiated. pFileOut->Release(); pWAVIn->Release(); pInputFileFilter->Release(); pDSoundRenderer->Release(); pControl->Release(); pEvent->Release(); pGraph->Release(); CoUninitialize(); return 0; }

上機實驗流程

下載程式 Play a File Building a Filter Graph 所需之video檔 http://nn.csie.nctu.edu.tw/course/MM2004/codes/DSRender.zip Building a Filter Graph http://nn.csie.nctu.edu.tw/course/MM2004/codes/DSBuild.zip 所需之video檔 http://nn.csie.nctu.edu.tw/course/MM2004/codes/ TEST.MPG

將程式載入 visual studio 中 解下載的檔案解壓縮 開啟 Visual Studio

將程式載入 visual studio 中 choose Open Workspace from the Files menu

將程式載入 visual studio 中 找尋剛才解壓縮時所產生的目錄並開啟 位於目錄內的 workspace

建立執行檔 choose Build xxx.exe from the Build menu

執行程式 choose Execute xxx.exe from the Build menu