Microsoft DirectX 8.1 (C++)

Querying for Seeking Capabilities

Microsoft® DirectShow® supports seeking through the IMediaSeeking interface. The filter graph manager exposes this interface, but the seeking functionality is always implemented by filters.

Some data cannot be seeked. For example, you cannot seek a live video stream from a camera. If a stream is seekable, however, there are various types of seeking it might support. These include:

The IMediaSeeking interface defines a set of flags, AM_SEEKING_SEEKING_CAPABILITIES, that describe the possible seeking capabilities. To retrieve the stream's capabilities, call the IMediaSeeking::GetCapabilities method. The method returns a bitwise combination of flags. The application can test them using the & (bitwise AND) operator. For example, the following code checks whether the graph can seek to an arbitrary position:

DWORD dwCap = 0;
HRESULT hr = pSeek->GetCapabilities(&dwCap);
if (AM_SEEKING_CanSeekAbsolute & dwCap)
{
    // Graph can seek to absolute positions.
}

An alternate method is IMediaSeeking::CheckCapabilities, which tests a subset of the seeking capabilities. The caller passes a bitwise combination of flags, as follows:

// Set flags for the capabilities you want to check.
DWORD dwCaps = AM_SEEKING_CanSeekAbsolute | 
               AM_SEEKING_CanSeekForwards |
               AM_SEEKING_CanSeekBackwards;

HRESULT hr = pMediaSeeking->CheckCapabilities(&dwCaps);

If the stream supports all of the indicated capabilities, the return value is S_OK. If it supports none of them, the method returns an error code. If the stream supports a subset of them, the return value is S_FALSE. When the method returns, the input parameter contains a bitwise combination of the supported capabilities, from the original set that was passed in. You can test the result as follows:

if (hr == S_FALSE) // Some requested capabilities are not supported.
{
    if (dwCaps & AM_SEEKING_CanSeekAbsolute)
        // This capability is supported.
        ...
}