DirectShow Learning (1)

Source: Internet
Author: User
1 , DirectX What isDirectX (dx for short) is a set of Windows-based multimedia application program interfaces (APIS. In development, dx is divided into two parts: one is the Runtime Library, the program compiled by DX must have the support of the Runtime Library, and the other is the development library, that is to say, the SDK is required in compiling DX programs. DirectX is a graphical application interface (API). In short, DirectX is an auxiliary software and an acceleration software that improves system performance. It was created and developed by Microsoft. It is not hard to understand his meaning. Direct means direct, and X means many things. Together, direct means a group of things that share common things. Microsoft defines it as "Hardware Device independence ". DirectX is a graphic and media acceleration interface developed by Microsoft. Only after it is installed can software in the system directly use hardware acceleration resources (high-speed access to hardware ), at present, the highest version of the software is 9.0c. in the Windows operating system architecture, there is an abstraction layer between the kernel and the hardware, which specifically shields and abstracts the hardware, therefore, you are no longer allowed to directly access the hardware. After doing so, the anti-destructive and anti-interference performance of the operating system is greatly improved. However, the hardware operation efficiency has been greatly reduced, and many new hardware features cannot be directly used, this is clearly an obstacle to the development of multimedia and games. DirectX is an excellent Application Programming Interface (APIS) provided by Microsoft. It is used to contact applications and hardware, it plays a key role in developing multimedia applications and computer games on the Windows platform. DirectX components include: DirectDraw, directsound, directplay, direct3d, directinput, directsetup, and Autoplay.
In short, DirectX has two main advantages: providing software developers with hardware independence and providing policies for hardware development. To get the latest version, install DirectX in the system from the latest Microsoft platform SDK. You can find the Platform SDK on the http://www.microsoft.com/msdn msmsdn. By default, Microsoft platform SDK is installed in the/mssdk directory under the root directory of the default drive. The DirectX header file is installed in the/mssdk/include directory, and the Lib file is installed in the/mssdk/lib directory. The Platform SDK contains some excellent DirectX examples and documents. The DirectX documents released earlier are very rough and some are incorrect. The current version has greatly corrected this problem. You 'd better familiarize yourself with these documents. Fortunately, you don't have to process all DirectX functions at once. DirectX is a set of components that can be used separately. In fact, different parts of DirectX are unrelated to each other in programming. They only share the same design style and goals: making windows game programming easier. Is there anything special about the program using the DirectX component? No. Programs using DirectX components are Win32-based programs that use common Win32 API sets and can access all available operating system tools. In fact, DirectX can be used for both GUI programs and console programs. You can use the Petzold-style SDK to program the development program, or use the basic class library, such as MFC. In general, the only requirement is that most DirectX components require hwnd in the program, so there must be at least one window. 2 , DirectX 1, 9.0 All members of the family DirectX graphics: Integrates the previous DirectDraw and direct3d technologies. DirectDraw is mainly responsible for 2D acceleration to directly operate the graphics card memory and system memory. direct3d mainly provides 3D graphics hardware interface, which is the basis for developing 3D DirectX games. Directinput: Mainly supports input services (including the mouse, keyboard, and game pole), and supports output devices. Directplay: Mainly provides communication and organization functions for multiplayer online games. Directsetup: Provides the API function for automatic installation of DirectX components. Directmusic: Mainly supports the synthesis and playback of MIDI music. Directsound: Mainly provides functions such as audio capture, playback, sound processing, hardware acceleration, and direct Device Access. DirectShow: Provides a complete solution for high-performance multimedia applications, such as playback of media files in various formats and audio/video collection on Windows. DirectX Media objects: DirectShow filter simplifies the model and provides more convenient stream data processing solutions. 3 , DirectX FunctionThe DirectX software development kit is a programming interface provided by Microsoft for developing high-performance graphics, sound, input, output, and online games on the Windows operating platform. It provides hardware device independence. 4 , DirectShow Origin and introductionDirectShow is developed from DirectX Media in directx6.0. It integrates the technologies of other members of the DirectX family, such as DirectDraw and directsound. DirectX Media objects is separated from DirectShow of directx8.1 and has become another efficient stream data processing solution. Microsoft DirectShow is a media stream structure based on Microsoft Windows. It supports various formats, including advanced stream mode (ASF), motion image Expert Group (mPEG), audio and video staggered (AVI), audio dynamic compression layer 3 (mp3) and WAV audio files. It supports the capture of Windows Driver mode (WDM) devices, as well as the video of early widows devices. DirectShow integrates other DirectX technologies. When video and audio hardware acceleration is available, it can be automatically detected and used, and also supports systems without hardware acceleration. DirectShow media replay, format conversion, and capturing tasks become simple. At the same time, it provides access to the bottom layer control structure for applications that require custom solutions. You can also create your own DirectShow component to support new formats or custom effects. Applications that use DirectShow include DVD players, video editing applications, Avi-to-ASF converters, MP3 players, and digital video capturing applications. DirectShow is based on the Component Object Model (COM. To create a DirectShow application, you must understand the COM Client programming. For most applications, you do not need to implement your own COM object. DirectShow provides the required components. (If you want to write your own component extension DirectShow, it must be implemented as a COM Object .)   5 , Program development kit SelectionThe download links on the mirosoft DirectX homepage are as follows: what are their differences: l DirectX 9.0 SDK Update-(April 2005) l DirectX 9.0 SDK Update-(April 2005) symbol filesl DirectX 9.0c redistributable for software developers-(release L 2005) l DirectX 9.0c end-user runtime ready l DirectX 9.0 SDK Update-(release L 2005) -dxsdkl DirectX 9.0 SDK Update-(CMDL 2005) symbol files-symbol file used for debugging l DirectX 9.0c redistributable for software developers-(CMDL 2005) -Part of the DX that can be released along with your program l DirectX 9.0c end-user runtime-installed by common users 6 , How DirectX Associated VC Medium?To compile the DirectX program, we must have a DirectX SDK library file, which can be obtained from Microsoft or this site and then associated through VC settings. The following describes the installation methods in vc6 and vs. net. Vc6 (English version): Select Tools-> options from the menu, open the Options dialog box, select the ctions tab, select the include files item, and add the folder path directory of the DirectX header file to it. Similarly, add the folder path directory of the DirectX header file to the library files item. Vs. net (Chinese version): Select "tools-> options" from the menu, open the Options dialog box, open the projects tab, and select "files included" and "library files" respectively to add the corresponding paths. Note: during compilation, VC selects database files in the order of arrangement. If there are two databases with the same name, VC will prioritize the files in the previous database. The DirectShow application must connect to at least the library files strmiids. lib and quartz. Lib. The former defines the standard CLSID and IID of sirectshow, and the latter defines the export function amgeterrortext (if this function is not used in the application, you can also not connect to this library ). DirectShow applications should all contain dshow. H files, but they are often replaced by streams. H files. If streams. H is included, the general library files also need to be connected to strmbasd. Lib, UUID. Lib, and winmm. Lib. 7 , DirectShow Development Environment Configuration(1) Use the VC Wizard to generate a specific project, such as Win32 dynamic-link; (2) include the header file streams. h; (3) select project | Settings | C/C ++ from the VC menu. In the displayed dialog box, select code generation, then select _ stdcall in calling convention; (4) use the multi-threaded Language Runtime Library, that is, select project | Settings | C/C ++ in the VC menu, in the displayed dialog box, select code generation in category. In use run-time library, select debug multithreaded for debug and multithreaded for release. (5) configure the necessary link library file, that is, select project | Settings | link from the VC menu, and select general from the category in the pop-up dialog box, then enter the following code in the object/library modules: debug version strmbasd. lib, msvcrtd. lib, winmm. lib release version strmbase. lib, msvcrt. lib, winmm. lib and select ignore all default libraries. DirectShow SDK recommends that the DirectShow application connect to the strmiids. lib and quartz. Lib files at least. The former defines the standard CLSID and IID of DirectShow, and the latter defines the export function amgeterrortext (if this function is not used in the application, you can also not connect to this library ). If the program contains the header file streams. H, the general library file also needs to connect strmbasd. Lib, UUID. Lib, winmm. Lib. (6) configure the include and Lib directories of the DirectX SDK to the system directory of the VC, and put them in the standard VC directory before the compiler can get the source file of the latest version. Select Tools | options | directories. In the show directories for dialog box that appears, select include files. The configuration is as follows (assume that the DirectX SDK is installed in the D:/dxsdk directory, and the VC is installed in 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 In show directories for, select library files. The configuration is as follows: 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) because the DirectShow application is a COM Client Program, coinitialize () is called before any COM function is called () (or coinitializeex) function to initialize the com Library (usually when the application is started Called once). When the com library is used, the couninitialize () function is called for reverse initialization (usually called once before the application exits ). 8 , VC Compile DX Program appears " External symbols that cannot be parsed " Why?This error often occurs when a beginner wants to compile the DirectX program. It is mainly because the DX library file is not referenced in the project, after we set the dx sdk path to VC, it does not mean that we have already set the dx sdk. In our DX project, we also need to perform corresponding settings, add the required library file (DirectX SDK Library) to our project. There are two ways to set this library file. One is to add it in the compilation options of your project, you can also add (recommended) code ). Command Line: # pragma comment (Lib, "XXX. lib"). This is the pre-compiled command of VC and can be added to the Code. For example: # pragma comment (Lib, "ddraw. lib") indicates adding the ddraw. Lib Library to the Project for compilation. Note: This command line does not require a plus sign (";"). 9 , DirectShow SDK Base Class LibraryIn the DirectShow SDK base class library, in addition to the filter and pin classes, there are many tool classes. With the support of these classes, it is easier to develop the filter component or DirectShow application. These classes mainly include cpullpin, coutputqueue, csourceseeking, cenumpins, cenummedietypes, cmemallocator, cmediasample, cbasereferenceclock, cmediatype, and cbaseproperypage. 10 , DirectShow Of Com Programming BasicsDirectX adopts the com standard, while DirectShow is a completely com-based application system. The DirectShow application is actually a client program of COM components, but it is only a "use" problem of COM components. These questions include how to create a COM component, how to obtain the solution on the component object, how to call the interface method, and how to manage the component object (that is, you need to be familiar with the reference counting mechanism of COM. For filter developers, more com knowledge is required. Because the filter itself is a COM component, developing the filter involves the "Implementation" of the COM component. Com itself is only a specification, rather than implementation. However, when C ++ is used for implementation, the COM component is a C ++ class, and the interfaces are pure virtual classes. The COM specification specifies that any component or interface must be inherited from the iunknown interface. Each component must implement a class factory that corresponds to the branch ), the class factory is also a COM component that implements the iclassfactory interface. In the createinstance interface function of iclassfactory, a corresponding COM component class object instance can be generated using the new operation. COM has three types of components: In-process components, local process components, and Remote components. A filter is generally an in-process component that provides services in the form of DLL. Each COM component uses a guid for unique identification. When creating a COM component, you always call cogetclassobject through the guid to obtain the class factory for creating this component object. Then, call the interface method iclassfactory: createinstance of the class factory to create the guid-marked component object. Five functions required for a typical self-registered COM component DLL are as follows: l dllmain: DLL entry function (DirectShow implements dllentrypoint); L dllgetclassobject: used to obtain class factory pointers; l dllcanunloadnow: This function is called when the system is idle to determine whether the DLL can be uninstalled; l dllregisterserver: register the COM component to the registry; l dllunregisterserver: delete registration information for COM components in the registry.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.