Using DirectShow to play media files in Visual Studio .NET 2003 (1)

zhaozj2021-02-16  62

DirectShow is a development package provided by Microsoft's streaming of streaming on the Windows platform, which is posted with the DirectX development package. DirectShow provides powerful support for multimedia capture and playback. Using DirectShow we can easily capture data from the acquisition card that supports the WDM drive model, and performs the corresponding post-processing or even stored in the file. It is widely supported in various media formats, including ASF, MPEG, AVI, DV, MP3, WAVE, etc., making the playback of multimedia data becomes light. In addition, DirectShow also integrates the technology of DirectX, such as DirectDraw, DirectSound, which directly supports DVD playback, nonlinear editing of video, and exchanges with the data camera. What is more worth mentioning is that DirectShow provides an open development environment, we can customize your components according to your needs. (lead)

getting Started

DirectShow uses a model called Filter Graph to manage the processing of the entire data stream. Participate in the various functional modules of the data stream processing, and each Filter is connected in a certain order in the Filter Graph, and completes some relative Independent features, such as Filter can complete some of the following features: L Read files LEAR DETATISTICS LEAR DIRE LEAR DETC LEAR DESCRODUCTION LEs MPEG-1 Decoding Filter It is MPEG encoded stream data, and its output is a decoded stream data. DirectShow is why different Filter is connected to complete specific features, we call these Filter's connection Filter Graph, as shown below, is a Filter Graph, which is played AVI:

Figure A Play AVI file Graph Filter chart on the map, each module represents different filters, media file files, read the AVI file from the hard disk, AVI separation FILTER separates files into audio streams and video streams, AVI decoding Filter pairs The stream is decoded and sent to the VIDEO performance FILTER, which is displayed by the latter on the display, and the default DirectSound device outputs the audio stream with DirectSound. Our applications do not need to manage this in this data stream, providing a Advanced component called the Filter Graph Manager in DirectShow. In our application, you only need to call its API, such as Run, STOP, etc. If you want to make further control over the data flow, you can access these Filter directly through the COM interface. Filter Graph Manager also provides another feature: the application can control how Filter Graph generates via manager. DirectShow application

In a broad sense, all DirectShow applications must complete three things, as shown below:

Figure B 1. Generate an instance of the Filter Graph Manager. 2. By using the Filter Grapth instance to generate Filter Graph, which Filter should consist of Filter Graph regarding our application needs. 3. Control by calling the Filter Graph Manager and the response Filter GRAPH and data stream from the Filter Graph's message. DirectShow is COM-based, Filter Graph Manager and Filter are COM objects, you should have a basic understanding of COM before starting to start. Let's start doing a simple DirectShow application, in which we implemented such a function: Open a media file and play it. Setting the environment Before using DirectShow, you must install DirectX's SDK, DirectX SDK can be downloaded on Microsoft's website. Currently, DirectX is 9.0. This article will perform entry-level applications for DirectShow applications. After installing DirectX SDK correctly, we must set the header file and library file of the DirectX SDK to make it within the Visual Studio search path. For Visual Studio .NET 2003, you can set up: Menu → Tools → Options → Item → VC Directory, add D: / DXSDK / INCLUDE in the included file, add D: / DXSDK / LIB (my SDK) in the library file The installation path is d: / dxsdk:

head File

file name

description

Dshow.h

All DirectShow applications must contain

Library file

file name

description

Strmiids.lib

Export Class ID (CLSID) and Interface Identifier (IID) in this library file, all DirectShow applications must contain this file.

Quartz.lib

The function amgeTerRortext is exported in this library file. If you call this function in your program, you must include this library file.

Start engineering

Open Visual Studio .NET 2003, File → New → Project

1. Generate an MFC-based application, name PlayWnd.

2. Select the application type based on the dialog box, click Finish.

转载请注明原文地址:https://www.9cbs.com/read-21870.html

New Post(0)