Microsoft Developer Studio and DirectShow
Getting Started
Make sure you have installed Microsoft’s Visual C++ Developer Studio and the
DirectShow SDK including libraries, samples, and headers.
Set the Microsoft Developer Studio Include and Lib directories properly:
- Bring up the Options dialog box by selecting Options from the Tools menu. Select the Directories tab.
- Add the DirectShow include directories (by default:
DXMEDIA\INCLUDE and DXMEDIA\CLASSES\BASE) to the list.
Select Library files in the Show directories for: combo-box.
Add the DirectShow library path (c:\DXMEDIA\LIB).
Remember to link with
QUARTZ.LIB STRMBASE.LIB and LIBCMT.LIB via the Link tab in the Microsoft Developer Studio Build/Settings dialog box, and check ‘Ignore Default Libraries.’ No further changes are required to build first DirectShow application. Filter developers should follow the steps below to install and customize the AMVCKIT.
Filter Development and Microsoft Visual C++ Developer Studio
The steps below explain how to customize AMVCKIT in preparation for filter development.
Assumptions |
|
- The
DirectShow Software Development Kit has been installed in C:\DXMEDIA. |
The name for our sample filter will be FILTER.
|
Preliminary Setup
- Choose a project name (we’re going to use
FILTER).
Create an empty directory for the project. [C:\FILTER].
Copy the files (excluding this .doc file) into the directory just created [into C:\FILTER].
If you already have a working project which you have developed you can keep your .DEF file and .RC file rather than reverting to those provided in AMVCKIT. However, be sure to read Modifying the .DEF and RC files from the AMVCKIT below and merge any necessary changes into your own files.
Copy the source .CPP and .H files into the project directory, as well as the .RC file and any other miscellaneous source files it requires. Do not copy any make files or compiler intermediate files.
Working with Microsoft Developer Studio
- Run Microsoft Developer Studio and close any open projects.
- Open the [
FILTER] workspace [FILTER.DSW] using Open Workspace… from the File menu.
Add any .CPP files to the project by choosing Files… from the Add to Project… menu option under the Project menu.
Bring up the Settings dialog box by selecting Settings… from the Project menu. Select the Link tab and set the Output file name to [C:\FILTER\FILTER.AX].
Choose Save All from the File menu.
Modifying the .DEF and .RC files from the AMVCKIT
AMVCKIT includes a sample .DEF file and minimal .RC file you can use as a template if your are creating a new filter. If you have an existing project, treat the following steps as a checklist to make sure you have modified your files appropriately. This especially applies if you are modifying one of the samples provided with the DirectShow SDK.
- Follow the steps listed in Appendix A to create your own GUID. Appendix A also provides more information about GUIDs. If you are using code from one of the AMSDK samples, please generate a new GUID.
- Save everything via Save All from the File menu.
The Test
- Rebuild the entire project via Rebuild All from the Build menu. The project should build with zero errors and two warnings when built as Debug, and one warning when built as Release.
- Install the filter by using the REGSVR32 program found in the \MSDEV\BIN directory. From the console window for example, REGSVR32 FILTER.AX. The REGSVR32 program will indicate success or failure via a dialog box.
- Launch GraphEdit from (
C:\DXMEDIA\TOOLS\GRAPHEDT.EXE) and try inserting the [FILTER] filter.
Appendix A - Generating New Globally Unique Identifiers (GUIDs)
In DirectShow, objects are identified by globally unique identifiers (GUIDs). Each filter is identified by a distinct GUID. Likewise, the filter’s property page is identified by a separate and distinct GUID. GUIDGEN is a Windows-based utility designed to generate GUIDs. Adding GUIDGEN to the Developer Studio Tools menu (via Customize) is a great time-saver. GUIDGEN can be found in the \MSDEV\BIN directory. If GUIDGEN.EXE was not installed, simply copy the executable from the Microsoft Developer Studio disc.
- Run GUIDGEN (handy if it's in the Tools menu) and copy the new GUID in the DEFINE_GUID format. Now you have a new GUID on the clipboard, ready to be pasted into your source code
.
Replace the GUID declaration in your source code by pasting in the new GUID.
For the steps below, imagine GUIDGEN created the following GUID:
// {A0290240-8EF6-11cf-8F47-00AA0060D683}
DEFINE_GUID(<<name>>,
0xa0290240, 0x8ef6, 0x11cf, 0x8f, 0x47, 0x0, 0xaa, 0x0, 0x60, 0xd6, 0x83);
Replace the <<name>> in the filter's DEFINE_GUID macro accordingly [CLSID_FILTER].
Copy the alpha-numeric sequence [{A0290240-8EF6-11cf-8F47-00AA0060D683}], from the comment line above into the clipboard.
Save your changes.
Proceed with other modifications in step 3 of Modifying the .DEF and .RC files from the AMVCKIT above.
Appendix B - Details about the AMVCKIT kit.
The following information chronicles how the AMVCKIT project workspace was created in case the developer needs to reconstruct, refine or customize the environment.
- Launch Developer Studio.
- Create a new DLL project workspace named FILTER.
- Modify the project’s Build/Settings…
In the Settings For: portion of the Project Settings dialog, select both the Win32 Debug and Win32 Release entries.
- Set the Microsoft Foundation Classes: setting of the General pane for Not Using MFC.
- In the General category under C/C++, set the compiler at W3 (minimum).
- Add the following Preprocessor Directives (commas between directives):
INC_OLE2, STRICT, WIN32,_MT,_DLL,_X86_=1,WINVER=0x0400
In the C++ Language category, enable exception handling.
In the Code Generation category, set the processor setting to Blend.
In the Code Generation category, set the call convention to __stdcall.
In the Code Generation category, select multithreaded dlls..
In the Precompiled Headers category, disable use of precompiled headers.
In the Object/library module section, start the .lib list with QUARTZ.LIB STRMBASE.LIB LIBCMT.LIB.
Select to ignore default libraries.
Disable the use of program databases under the Customize category.
In the Output category, set the base address to 0x1c400000.
In the Output category, set the entry-point symbol to DllEntryPoint@12.
Back in the left Settings For pane, select the Debug entry.
In the General category under C/C++, enable generation of browse information.
In the Debug category under Link, enable generation of debug information.
Select C7 compatible debug information.
In the Code Generation category, select debug multithreaded dlls..
Under Browse Info, enable generation of browse information.
- Copy the
.DEF and .RC files from the SDK’s BALL sample, naming the files FILTER.DEF and FILTER.RC respectively.
Add FILTER.DEF and FILTER.RCto the project via Insert/Files…
Save the entire environment via File/Save All.