DirectShow Programming (1) - DirectShow Introduction

xiaoxiao2021-03-06  78

Learning DirectShow for a while, sharing the SDK translated in this study process with everyone, and also hope that experts will point out the mistakes I understand, thank you very much. 1. DirectShow Introduction DirectShow is a streaming media framework on a Windows platform, providing high quality multimedia stream acquisition and playback. It supports a variety of diverse media file formats, including ASF, MPEG, AVI, MP3, and WAV files, and supports collection of multimedia streams using WDM drivers or early VFW drivers. DirectShow integrates other DirectX technology, which can automatically detect and use the available audio and video hardware acceleration, and can also support systems with no hardware acceleration. DirectShow greatly simplifies media playback, format conversion, and acquisition work. But at the same time, it also provides the user-defined solution to provide the underlying flow control framework to enable the user to create a DirectShow component that supports new file formats or other purposes. The following is a typical application written in DirectShow: DVD player, video editing, AVI to ASF converter, MP3 player, and digital video acquisition apps. DirectShow is built on the Component Object Model (COM), so you must have knowledge written by COM client when you write DirectShow applications. For most applications, you don't need to implement your own COM objects, DirectShow provides most of the DirectShow components you need, but if you need to write your own DirectShow components, you also need to have knowledge of COM components. 1.1. DirectShow supported format DirectShow is an open frame, so as long as there is a suitable filter to analyze and decode, it can support any format. DirectShow supports the following file type and compressed format: Note: You need to play with Windows Media Format SDK Support file type: Windows Media? Audio (WMA) * Windows Media? Video (WMV) * ​​Advanced Systems Format (ASF) * Motion Picture Experts Group (MPEG) Audio-Video Interleaved (AVI) QuickTime (version 2 and lower) WAV AIFF AU SND MIDI compression formats: Windows Media Video * ISO MPEG-4 video version 1.0 * Microsoft MPEG-4 version 3 * Sipro Labs ACELP * Windows Media Audio * MPEG Audio Layer-3 (MP3) (Decompression Only) Digital Video (DV) MPEG-1 (Decompression Only) MPEG CINEPAK Microsoft does not provide MPEG2 decoder, some available DirectShow MPEG2 hardware or software decoders are Provided by a third party. 1.2. Frequently Asked Questions (Excerpts) 1.2.1. General Questions * What operating systems are supported by DirectShow? DirectShow supports Windows9x, Windows2000, Windows ME, and Windows XP.

* How much COM knowledge is needed to use DirectShow? Application developers only need basic COM component knowledge: instantiate COM components, call interfaces, and management interfaces. Filter developers need more. * Is there a hardware list (HCL) compatible with DirectShow? No. If hardware is compatible with DirectShow, DirectShow uses them, if there is no compatible hardware, DirectShow uses GDI to draw videos, and use Waveout Series Multimedia API to play audio. * What languages ​​can be used to write DirectShow applications? DirectShow is mainly C / C development design. Visual Basic can only use a small part of it. Script-based DVDs and TV applications can be supported by MS JScript or VB Script. It may also be written in Delphi, but the SDK document does not provide this. * DirectSHOW will be implemented by the hosted code? There is currently no program. DirectX SDK provides limited managed playback feature that uses audio and video recursions, you can use COM Interop DirectShow client applications, but because of performance, it is not recommended to create Filter running on the CLR.

* What kind of compiler does DirectSHOW need? Any compiler that can generate COM objects can be. * The relationship between DirectShow and other components of DirectX DirectShow and DirectX other components are internally contacted. DirectShow uses DirectSound and DirectDraw with hardware support. Video Renderer and Overlay Mixer use DirectDraw 3 and DirectDraw5 surfaces (SURFCES). Video Mixing Renderer 7 (WinXP only) uses the DirectDraw7 surface. Video Mixing Renderer 9 Use the latest (current DirectX9) Direct3D API function. Even if an application contains DirectX other components, you don't have to use the API of other components to write it. Refer to SDK: Texture3D Sample. * DirectShow relationship with ActiveMovie? ActiveMovie is the original name of DirectShow, which is now no longer used, but a part of the API still retains "AM" prefix, such as am_media_type and IamvideoAccelerator. * DIRECTSHOW is limited to multimedia applications? DirectShow The default component is mainly designed for audio and video streams, however, the DirectShow framework has been successfully used in other data streams. * Is the graphedit tool active? Is the graphedit.exe remained? There is no source code, no remained. * DMO can replace DirectShow Filter? In writing encoders, decoders, and effects, DMO is encouraged to replace DirectShow Filter. In other applications, use DirectShow Filter may be appropriate. 1.2.2. Program Writing Questions * How to set the compilation environment, which header files and libraries do you need? Refer to the "Setup Compilation Environment" chapter * Graphedit lists many other files supported by documents, what are they all? Graphedit enumerates all Filter registered as a Filter type in the system, including Filter installed by a third-party application, and other Microsoft technology such as Windows Media or NetMeeting, and some DirectShow Filter is used to do hard coding or hard Decoding the driven housing. Microsoft H.263 Video Codec is used for NetMeeting and is no longer supported by DirectShow. * How do I know how DirectShow has been installed? Calls CoCreateInstance to create a Filter Graph Manager instance, if successful, represents DirectShow has been installed, the following is an example: IGraphBuilder * pGraph; HRESULT hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **) & pGraph);

* If you do not change the version of the Filter through the property settings? Of course, it is an interface provided by FILTER. If not provided, there is no way * DirectShow notifies the application current playback location? Do not provide callbacks to notify the location, you need to use a timer timing call iMediaseEeping :: getCurrentPosition method to get the current playback location. * Which filter runs in which privileged level? Running under Ring 3 privilege level, some stream control drivers (such as audio and video acquisition drivers) are running at RING 0 privilege levels. * Do you need a KERNEL debugger? This is based on specific items. Installing the DirectX Debug Runtime Library means installing debug driver and other core components, so if your application generates a debug break in some of them ( Debug assert, your machine will automatically restart unless you have a Kernal debugger. * DEFINE_GUID How does Macro work? Using the define_guid macro allows you to define the GUID value by containing the same header file without having to use the extern keyword. For example, there are three source files in your project: src1.cpp, src2.cpp, src3.cpp, they all use one of the same GUID values, and this GUID can only define once in your project in order to ensure consistency. At this time, other source files must define external references to use it. With Define_Guid, you can use the same header file in all source files, definition in the header file: GUID:

Define_guid (CLSID_MYOBJECT, 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

In this example, the GUID is 0. In the actual program, use the Guidgen tool to generate a GUID, in one of the source files, including initguid.h before your header, such as:

// src1.cpp #include

#include "myguids.h"

// src2.cpp

#include "myguids.h"

// src3.cpp #include "myguids.h"

On the place where INITGUID.H is not included, the Define_GUID macro creates an external reference to use the GUID value, where the define_guid is redefined with the Define_Guid macro to generate the definition of the GUID.

If you don't add initguid.h anywhere, you will get a link error: "Unresolved External Symbol." If the same GUID contains INITGUID.H, you will get compiled error "Redefinition; Multiple Initialization." To resolve these questions Please confirm that INITGUID.H is only once. Similarly, do not include initguid.h to the pre-compiled head file, because the pre-translated head file is included in each source file.

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

New Post(0)