Microsoft DirectX 9.0

Using DMOs in DirectShow

Applications based on DirectShow can use DMOs in a filter graph, through the DMO Wrapper filter. This filter aggregates a DMO and handles all the details of using the DMO, such as passing data to and from the DMO, allocating IMediaBuffer objects, and so forth.

Because the DMO is aggregated by the filter, the application can query the filter for any COM interfaces that the DMO exposes. However, the application should let the filter handle all streaming operations on the DMO. For example, do not set media types, process any buffers, flush the DMO, lock the DMO, enable or disable quality control, or set video optimizations.

If you know the class identifier (CLSID) of a specific DMO that you want to use, you can initialize the DMO Wrapper filter with that DMO, as follows:

  1. Call CoCreateInstance to create the DMO Wrapper filter.
  2. Query the DMO Wrapper filter for the IDMOWrapperFilter interface.
  3. Call the IDMOWrapperFilter::Init method. Specify the CLSID of the DMO and the GUID of the DMO's category. For a list of DMO categories, see DMO GUIDs.

The following code shows these steps:

// Create the DMO Wrapper filter.
IBaseFilter *pFilter;
HRESULT hr = CoCreateInstance(CLSID_DMOWrapperFilter, NULL, 

if (SUCCEEDED(hr)) 
    // Query for IDMOWrapperFilter.
    IDMOWrapperFilter *pDmoWrapper;
    hr = pFilter->QueryInterface(IID_IDMOWrapperFilter, 

    if (SUCCEEDED(hr)) 
        // Initialize the filter.
        hr = pDmoWrapper->Init(CLSID_MyDMO, DMOCATEGORY_VIDEO_EFFECT); 

        if (SUCCEEDED(hr)) 
            // Add the filter to the graph.
            hr = pGraph->AddFilter(pFilter, L"My DMO");

The DMOEnum function enumerates DMOs in the registry. This function uses a different set of category GUIDs from the ones used for DirectShow filters.

Using the System Device Enumerator with DMOs

Instead of creating a DMO directly, you can use the System Device Enumerator, which can enumerate any DMO category that is supported by the DMOEnum method. The System Device Enumerator also includes DMOs when it enumerates certain DirectShow filter categories. The following table shows the mapping between DMO categories and DirectShow categories.

DMO Category DirectShow Equivalent

The System Device Enumerator returns a list of moniker objects. If the moniker represents a DMO, the IMoniker::BindToObject method automatically creates the DMO Wrapper filter and initializes it with that DMO. Thus, the fact that a DMO is involved is transparent to the application. For more information on using the System Device Enumerator, see the topic "Using the System Device Enumerator" in the DirectShow documentation.


There are some limitations when using DMOs in DirectShow: