Microsoft DirectX 8.0 |
This article describes how to use Microsoft® DirectX® Media Objects (DMOs) in a Microsoft® DirectShow® application. For information about using DMOs outside of DirectShow, see Using DirectX Media Objects.
This article contains the following sections.
The DMO Wrapper filter enables a DirectShow application to use a DMO within a filter graph. This filter wraps the DMO and handles all the details of using the DMO, such as passing data to and from the DMO. Also, the filter aggregates the DMO, so the application can query the filter for any COM interfaces that the DMO exposes.
However, all stream control should occur between the application and the filter (or between the application and the filter graph manager). Do not call any methods on DMO interfaces that might change the state of the DMO. For example, do not set the media type on a stream, process any buffers, flush the DMO, lock the DMO, enable or disable quality control, or set video optimizations. The DMO Wrapper filter handles all streaming for the DMO, and directly calling these methods might cause an error.
There are two ways to add a DMO to a filter graph:
The following sections describe each approach.
Start by creating an instance of the DMO Wrapper filter. Query the DMO Wrapper filter for the IDMOWrapperFilter interface. Then call the IDMOWrapperFilter::Init method. This method takes the CLSID of the DMO and the GUID of the DMO's category.
You can use the DMOEnum function to enumerate DMOs registered on the user's system. DMOs are registered using a different set of category GUIDs from the ones used for DirectShow filters. For a list of DMO categories, see Category GUIDs.
The following code example shows how to use the IDMOWrapperFilter interface.
// IMediaObject // Create the DMO Wrapper filter. IBaseFilter *pFilter; HRESULT hr = CoCreateInstance(CLSID_DMOWrapperFilter, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void **)&pFilter); if (SUCCEEDED(hr)) { IDMOWrapperFilter *pWrap; hr = pFilter->QueryInterface(IID_IDMOWrapperFilter, (void **)&pWrap); if (SUCCEEDED(hr)) { // Initialize the filter. hr = pWrap->Init(CLSID_MyDMO, CLSID_MyDMOCategory); pWrap->Release(); } if (SUCCEEDED(hr)) { // Add the filter to the graph. hr = pGraph->AddFilter(pFilter, L"My DMO"); } pFilter->Release(); }
The system device enumerator includes DMOs when it enumerates certain DirectShow device categories. It maps the following DMO categories to their DirectShow equivalents.
DMO Category | DirectShow Equivalent |
---|---|
DMOCATEGORY_AUDIO_ENCODER | CLSID_AudioCompressorCategory |
DMOCATEGORY_AUDIO_DECODER | CLSID_LegacyAmFilterCategory |
DMOCATEGORY_VIDEO_ENCODER | CLSID_VideoCompressorCategory |
DMOCATEGORY_VIDEO_DECODER | CLSID_LegacyAmFilterCategory |
In addition, you can use the system device enumerator to enumerate any DMO categories, including DMOCATEGORY_AUDIO_EFFECT and DMOCATEGORY_VIDEO_EFFECT. For more information on using the system device enumerator, see Using the System Device Enumerator. The IMoniker::BindToObject method automatically wraps the DMO in the DMO Wrapper filter.