Examining and Changing a Filter s Property Pages

Examining and Changing a Filter s Property Pages

The WM ASF Writer created by the call to SetOutputFileName has a wide range of options that control how it uses the Windows Media compression algorithms. A file can be highly compressed, which saves space but sacrifices quality, or it can be relatively expansive, consuming valuable hard disk resources but requiring fewer CPU cycles to process. These values can be set internally (which we ll cover in Chapter 15), or they can be presented to the user in a property page. Many DirectShow filters implement property pages, which are dialog boxes that expose the inner settings of a filter. The ShowFilterPropertyPages function presents the property pages of a filter.

// Show the property pages for a filter. // This is stolen from the DX9 SDK. HRESULT ShowFilterPropertyPages(IBaseFilter *pFilter) { /* Obtain the filter's IBaseFilter interface. (Not shown) */ ISpecifyPropertyPages *pProp; HRESULT hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pProp); if (SUCCEEDED(hr)) { // Get the filter's name and IUnknown pointer. FILTER_INFO FilterInfo; hr = pFilter->QueryFilterInfo(&FilterInfo); IUnknown *pFilterUnk; pFilter->QueryInterface(IID_IUnknown, (void **)&pFilterUnk); // Show the page. CAUUID caGUID; pProp->GetPages(&caGUID); pProp->Release(); OleCreatePropertyFrame( NULL, // Parent window 0, 0, // Reserved FilterInfo.achName, // Caption for the dialog box 1, // # of objects (just the filter) &pFilterUnk, // Array of object pointers. caGUID.cElems, // Number of property pages caGUID.pElems, // Array of property page CLSIDs 0, // Locale identifier 0, NULL // Reserved ); // Clean up. pFilterUnk->Release(); FilterInfo.pGraph->Release(); CoTaskMemFree(caGUID.pElems); } return hr; }

The ShowFilterPropertyPages function exposes the ISpecificPropertyPages interface of the IBaseFilter passed by the caller and then gets the name of the filter. It also creates an interface to an IUnknown object, which exposes all the interfaces of a given object. That information is passed in a call to OleCreatePropertyFrame, which manages the property pages dialog box for user input. When this function is executed, you should see a property page dialog box that looks something like the one shown in Figure 5-1.

figure 5-1 property pages dialog box for the wm asf writer

Figure 5-1. Property pages dialog box for the WM ASF Writer

The operating system handles the details of user input, and when the user closes the dialog box, control returns to the function, which cleans itself up and exits.

Some, but not all, DirectShow filters have a property page associated with them, but it s not a good idea to show the property page to the user. These property pages are designed for testing by the programmer, so they don t meet Microsoft s user interface guidelines or accessibility requirements; they could potentially confuse the user. In this case, however, the property page serves a useful purpose for testing: it allows you to adjust file compression parameters to suit your needs.

It s not necessary to use property pages to change the settings on the WM ASF Writer, and, in fact, you cannot use the filter s default property page to enable the latest Windows Media 9 Series Audio and Video codecs. But there is a set of COM interfaces that allow you to adjust all the features available to the Windows Media encoder and to make your own property page for end users; these interfaces will be covered in detail in Chapter 15.



Programming Microsoft DirectShow for Digital Video and Television
Programming Microsoft DirectShow for Digital Video and Television (Pro-Developer)
ISBN: 0735618216
EAN: 2147483647
Year: 2002
Pages: 108
Authors: Mark D. Pesce

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net