Axis Decoder DMO Samples - Version 1.0

These code samples were created in order to show how to use Axis video and audio decoders in a non-DirectShow application. All five Axis decoders (H.264/MPEG-4/MJPEG/AAC/G7.xx) are so called DirectX Media Objects (DMO). DMO provides interfaces for simple data transformations and can be used outside the DirectShow graph. However, the DMO Wrapper Filter enables DMOs to also be used in an DirectShow graph.

Disclaimer

We highly recommend considering using the AXIS Media Control or the AXIS Media Parser SDKs. These software developer kits are tested by Axis Communications and full support is offered on the intended usage.

This documentation requires knowledge on how to program with COM interfaces. Axis Communications offers only limited support when using the DMO decoders directly and is reluctant to advice on generic programming questions.

IMPORTANT NOTICES!
Axis Communications AB (“Axis”) makes no warranties, representations or undertakings about any of the content in this document and the provided code (including, without limitation, any as to the quality, accuracy, completeness or fitness for any particular purpose of such content). Axis provides no guarantee that any of the examples will work for any particular application. Axis shall not be held liable for any damage inflicted to any device as a result of the examples or instructions contained in the sample code. Axis reserves the right to make changes to these samples without prior notice.

DirectShow is a trademark of Microsoft Corporation.

Sample description

The solution contains two similar examples - one written in C++ and the other written in C# using the .Net framework. The samples are console applications that take a media recording as input and decodes the contained media streams one or several times. For these examples we use media files (.bin) created with the AXIS Media Parser SDK ('MediaParser' sample). Four test files are included with mixed payloads (see the MediaFiles directory).

Code outline

The sample programs can be outlined in 6 steps:

  1. Initialize source. In this step we need to find out the specific properties of the streams we need to decode, e.g. compression type, frame rate and sample rate, and create an AM_MEDIA_TYPE structure (which is equivalent to the DMO_MEDIA_TYPE structure) for each stream. For example if your source is a RTP stream you might work out this information from the SDP-data. In these examples we open a file stream from an AMP-bin file and parse the media types of all contained streams. All code that relates to the source type used in these examples has been incorporated in the AMPFileSource class. 
  2. Create DMO decoder. We now create instances of the appropriate decoder types and retrieve the IMediaObject interface.
  3. Set input type. Using the media types from step one we can now setup the input of our decoders using IMediaObject::SetInputType. For more information on the supported media types the IMediaObject::GetInputType function could be used or refer to the Axis DirectShow Guide.
  4. Set output type. We retrieve the preferred output type based on the configured input from the decoders by calling IMediaObject::GetOutputType. Then set the retrieved output type by calling IMediaObject::SetOutputType.
  5. Create input and output buffers. These examples provide two basic implementations of IMediaBuffer (the C++ version can be found at MSDN). We now create two buffers for each decoder based on the requirements specified by the decoder (IMediaBuffer::GetInputSizeInfo and IMediaBuffer::GetOutputSizeInfo).
  6. Run decoding loop (simplified)
    1. Get one media sample and meta info from source.
    2. Copy data to input buffer.
    3. Send input buffer and meta info to decoder (IMediaBuffer::ProcessInput).
    4. Call IMediaBuffer::ProcessOutput with the output buffer the get the result.

Remarks