Microsoft DirectX 8.1 (C++) |
First, query the DMO for the number of streams it supports and the preferred media types for each stream. To retrieve the number of input streams and output streams, call the IMediaObject::GetStreamCount method.
For each stream, the DMO ranks its preferred media types in order of preference and assigns each type an index, starting from zero. To retrieve a preferred media type for a particular stream, call the IMediaObject::GetInputType method or IMediaObject::GetOutputType method. Specify a stream number and a media-type index. To enumerate all the media types on a stream, use a loop that increments the media-type index until the method returns DMO_E_NO_MORE_ITEMS, as shown in the following pseudo-code:
DWORD cInputs, cOutputs, type = 0
DMO_MEDIA_TYPE mt
pDMO->GetStreamCount(&cInputs, &cOutputs)
for (DWORD i = 0; i < cInputs; i++)
{
while (pDMO->GetInputType(i, type, &mt) != DMO_E_NO_MORE_ITEMS)
{
if ( this media type is one you want )
break
MoFreeMediaType(&mt)
type++
}
}
The GetInputType and GetOutputType methods return a DMO_MEDIA_TYPE structure with the media type. The following structure members are relevant:
The media type might have a NULL format structure, indicated by a value of GUID_NULL for the formattype member. A NULL format indicates that the DMO can accept a range of formats within the specified media type. For example, a stream that requires PCM audio might accept a range of sample rates. Therefore, it returns MEDIATYPE_Audio for the major type, MEDIASUBTYPE_PCMAudio for the subtype, and a NULL format.
The application must call the MoFreeMediaType function to free the pbFormat member.