![]() |
![]() |
![]() |
![]() |
||
DirectShow Media TypesThe 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:
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 NegotiationA 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 ChangesThe 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
|