To Identify Output Numbers
[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
To identify the output numbers for a loaded file, perform the following steps. These procedures are identical for both the asynchronous reader and the synchronous reader. Where interface names vary, the synchronous reader methods are listed in parentheses after the methods of the asynchronous reader.
- Create a reader object and load a file for reading. For more information, see To Create a Reader and Open a File (or To Create a Synchronous Reader and Open a File).
- Retrieve the total number of outputs for the file by calling IWMReader::GetOutputCount (or IWMSyncReader::GetOutputCount).
- Loop through the outputs one at a time, performing the following steps for each:
- Retrieve the IWMOutputMediaProps interface for the current output with a call to IWMReader::GetOutputProps (or IWMSyncReader::GetOutputProps).
- Retrieve the WM_MEDIA_TYPE structure for the output by making two calls to IWMMediaProps::GetMediaType. Make the first call to get the size of the structure, then allocate memory for it and pass a pointer to the allocated memory on the second call. Alternatively, you can call IWMMediaProps::GetType, which delivers the major type without requiring you to allocate memory for the WM_MEDIA_TYPE structure. You can skip outputs of the wrong major type.
- Retrieve the major media type and media subtype from the WM_MEDIA_TYPE structure. These values are stored in data members majortype and subtype respectively.
- Check the value of WM_MEDIA_TYPE.formattype. This specifies the type of structure contained in the buffer at WM_MEDIA_TYPE.pbFormat. For more information about format types, see Media Types.
- Allocate memory to hold the structure of the type identified in the previous step. Copy the structure to your allocated memory. For audio and video, this structure gives you essential information about how the data should be rendered.
The synchronous reader also provides methods to retrieve associations between output numbers and stream numbers. For more information, see To Find Stream Numbers and Output Numbers.
Related topics