This article walks through a simple C++ program designed to demonstrate how to request a filter to display its property page. It is based on the MPegProp function code in the MPegProp.cpp file, which you can find in the MPegProp sample in the Samples\ds\player directory.
This code displays the property page of the MPEG video decoder. This filter has a property page that enables you to play MPEG files in color or monochrome. You can see this filter's property page by opening the Filter Graph Editor, choosing the Insert Filters command from the Graph menu, selecting MPEG Video Decoder from the DirectShow Filters list, and clicking the Insert Filters button. After you've inserted the filter, right-click anywhere on it to display its property page.
See these related sections if you want to play back media files or specify the video playback window:
Perform the following steps to control the MPEG video decoder's property page in C/C++. You don't necessarily have to perform the steps in the order presented.
#include <windows.h> #include <mmsystem.h> #include <streams.h> #include "playfile.h"
#define WM_GRAPHNOTIFY WM_USER+13 #define HELPER_RELEASE(x) { if (x) x->Release(); x = NULL; }
HWND ghApp; HINSTANCE ghInst; HRESULT hr; LONG evCode; LONG evParam1; LONG evParam2;
The ghApp variable is the handle of window to notify when the graph signals an event. The ghInst variable is the HINSTANCE of the window. The evCode variable will hold the event code, and the evParam1 and evParam2 variables will hold the event parameters.
IGraphBuilder *pigb = NULL; IMediaControl *pimc = NULL; IMediaEventEx *pimex = NULL; IVideoWindow *pivw = NULL; IFilterGraph *pifg = NULL; IBaseFilter *pifPP = NULL; ISpecifyPropertyPages *pispp = NULL;
void MpegProp (LPSTR szFile) {
WCHAR wFile[MAX_PATH]; MultiByteToWideChar( CP_ACP, 0, szFile, -1, wFile, MAX_PATH );
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pigb);
pigb->QueryInterface(IID_IMediaControl, (void **)&pimc); pigb->QueryInterface(IID_IMediaEventEx, (void **)&pimex); pigb->QueryInterface(IID_IVideoWindow, (void **)&pivw);
hr = pigb->RenderFile(wFile, NULL);
pimex->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0);
The window specified by ghApp will handle messages in response to all events from the graph. If an event occurs, DirectShow posts a WM_GRAPHNOTIFY message to the window.
pigb->QueryInterface(IID_IFilterGraph, (void **)&pifg);
hr = pifg->FindFilterByName(L"MPEG Video Codec", &pifPP);
pif->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pispp);
CAUUID caGUID;
pispp->GetPages(&caGUID);
HELPER_RELEASE(pispp);
OleCreatePropertyFrame(NULL, 0, 0, L"Filter", // Caption for the dialog box 1, // Number of filters (IUnknown **)&pifPP, // Pointer to the filter whose property // Pages are being displayed. This can // be an array of pointers if more than // one filter's property pages are to // be displayed. Note that only // properties common to all the filters // can be displayed on the same modal // dialog. caGUID.cElems, // Number of property pages caGUID.pElems, // Pointer to property page CLSIDs 0, 0, NULL);
HELPER_RELEASE(pifPP);
The MPegProp sample uses the same WndMainProc callback function to handle the filter graph messages, the same GetClipFileName function to get the movie to be played, and the same the WinMain function to create the window as the Playfile sample. These are all generic windows functions.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.