Microsoft DirectX 8.1 (C++) |
In the IMediaObjectImpl class, most of the IMediaObject methods are wrappers that call an internal version of the same method. The derived class must implement the internal versions, which have the prefix Internal-. For a list of methods the derived class must implement, see Using the DMO Base Class.
The following remarks give details about some of the implementations.
AllocateStreamingResources
The template keeps a private flag that indicates whether this method has been called. If the method is called when the flag is already TRUE, it returns S_OK without calling the InternalAllocateStreamingResources method. The FreeStreamingResources method resets the flag to FALSE.
DMOLock
This method implements the IMediaObject::Lock method. It calls _DERIVED_::Lock if the parameter is TRUE or _DERIVED_::Unlock if the parameter is FALSE. The derived class must implement these methods.
To avoid name conflicts with ATL, the base class renames the IMediaObject::Lock method to DMOLock. When you build the derived class, define FIX_LOCK_NAME before you include the DMO header file. This directive causes the preprocessor to substitute DMOLock for Lock in the declaration of the IMediaObject interface. Applications can still invoke the method using the name Lock, because the vtable order does not change.
Flush
The template keeps a private flag that indicates the object's flushed state. The Flush method sets the flag to TRUE, and the ProcessInput method resets it to FALSE. If Flush is called when the flag is already TRUE, the method returns S_OK without calling the InternalFlush method.
GetInputSizeInfo, GetOutputSizeInfo
These methods return DMO_E_TYPE_NOT_SET unless all of the non-optional streams have media types. Therefore, in the derived class, the internal methods can assume that all of the non-optional streams have media types.
GetInputStatus
This method calls the InternalAcceptingInput method, which the derived class must implement. The InternalAcceptingInput method returns S_OK if the specified input stream can accept input. Otherwise, it returns S_FALSE.
Unless all of the non-optional streams have media types, the GetInputStatus method returns DMO_E_TYPE_NOT_SET. Therefore, the implementation of InternalAcceptingInput does not have to check for this condition.
ProcessInput
Before this method calls InternalProcessInput, it calls AllocateStreamingResources and InternalAcceptingInput. Therefore, the implementation of InternalProcessInput can assume the following:
ProcessOutput
Before this method calls InternalProcessOutput, it calls AllocateStreamingResources. Therefore, the implementation of InternalProcessOutput can assume that all resources have been allocated.
SetInputType
This method tests, sets, or clears the media type on an input stream. It calls the InternalCheckInputType method, which the derived class must implement. The InternalCheckInputType method returns S_OK if the media type is acceptable, or an error code otherwise. The SetInputType method implements the rest of the functionality.
This method does not allocate any resources. When the DMO switches to a streaming state, it calls the AllocateStreamingResources method. The derived class should use the InternalAllocateStreamingResources method to allocate any resources that it needs, such as memory buffers.
SetOutputType
This method tests, sets, or clears the media type on an output stream. It calls the InternalCheckOutputType method, which the derived class must implement. The InternalCheckOutputType method returns S_OK if the media type is acceptable, or an error code otherwise. The SetOutputType method implements the rest of the functionality.
This method does not allocate any resources. When the DMO switches to a streaming state, it calls the AllocateStreamingResources method. The derived class should use the InternalAllocateStreamingResources method to allocate any resources that it needs, such as memory buffers.