GDCL Home About GDCL DirectShow WinNt & WDM
GDCL Home / Technology / DirectShow / Media Types

DirectShow Media Types

The DirectShow filter graph manager builds a graph of filters by connecting the input pin of a filter to the output pin of another filter. During the connection process, the two filters negotiate what type of data they are going to exchange and in what format.

This type information is described in a Media Type structure. This contains three unique identifiers (GUIDs) and a block of format data:

  • the major type id defines the overall type of the data. Examples are video or audio.
  • the sub-type id defines the specific format to be supplied: examples are RGB-8 or RGB-565 for video.
  • the format type id defines the contents of the block of format data. This field identifies the type-specific structure that has been used. This will be a structure such as WaveFormatEx for audio or VideoInfo for video.
  • the format block contains finer details of the format in a structure defined by the format type id. The VideoInfo (or VideoInfo2) structure used for video data contains a bitmapinfoheader structure defining the image format together with source and target rectangles and other information.

Many video formats are defined by 32-bit FOURCCs. DirectShow uses standard COM 128-bit GUIDs for its ids, but has allocated a range of GUIDs for mapping FOURCCs as {XXXXXXXX-0000-0010-8000-00AA00389B71}. See fourcc.h in the DirectShow SDK.

Media Type Negotiation

A pin lists its preferred media types in order via its EnumMediaTypes method. When a connection attempt is made, one pin (called on its IPin::Connect method by the filter graph manager) will control the connection process. It will enumerate its own and the receiving pin's preferred media types, and will try to make a connection on a specific media type using IPin::ReceiveConnection. The code for this is in the DirectShow class library: see CBasePin::Connect.

The types listed by a pin's EnumMediaTypes method are its preferred types. It may accept connections on other types, and in fact it may refuse a connection on one of its preferred types if needed resources are not present.

Type Changes

The type defined during the connection process can be changed dynamically by attaching a MediaType structure to a buffer. This can be done by the source, indicating that the data starting with this buffer is in a new format. It can also be done by a renderer to indicate a switch in format of the output buffer: this is done when the video renderer is supplying DirectDraw surfaces to indicate a change in surface. Note that in both cases, the pin's QueryAccept method should be called to check that the new media type will be accepted.

 DirectShow

An overview of the DirectShow filter architecture
The filter graph manager and plug-in distributors
How the filtergraph manager builds graphs
Media types
Data transports
A technical Q & A for developers