다음을 통해 공유


IMediaSeeking::SetPositions

 
Microsoft DirectShow 9.0

IMediaSeeking::SetPositions

The SetPositions method sets the current position and the stop position.

Syntax

  HRESULT SetPositions(
  LONGLONG *pCurrent,
  DWORD dwCurrentFlags,
  LONGLONG *pStop,
  DWORD dwStopFlags
);

Parameters

pCurrent

[in,out] Pointer to a variable that specifies the current position, in units of the current time format.

dwCurrentFlags

[in] Bitwise combination of flags. See Remarks.

pStop

[in,out] Pointer to a variable that specifies the stop time, in units of the current time format.

dwStopFlags

[in] Bitwise combination of flags. See Remarks.

Return Values

Returns an HRESULT value. Possible values include the following.

Return code Description
S_FALSE No position change. (Both flags specify no seeking.)
S_OK Success.
E_INVALIDARG Invalid argument.
E_NOTIMPL Method is not supported.
E_POINTER NULL pointer argument.

Remarks

The dwCurrentFlags and dwStopFlags parameters define the type of seek. The following flags are defined.

Positioning Flags Description
AM_SEEKING_NoPositioning No change in position. (The time parameter can be NULL.)
AM_SEEKING_AbsolutePositioning The specified position is absolute.
AM_SEEKING_RelativePositioning The specified position is relative to the previous value.
AM_SEEKING_IncrementalPositioning The stop position (pStop) is relative to the current position (pCurrent).
Modifier Flags Description
AM_SEEKING_SeekToKeyFrame Seek to the nearest key frame. This might be faster, but less accurate. None of the filters that ship with DirectShow support this flag. Decoders are the most likely type of filter to support it.
AM_SEEKING_ReturnTime Return the equivalent reference times.
AM_SEEKING_Segment Use segment seeking.
AM_SEEKING_NoFlush Do not flush.

For each parameter, use one positioning flag. Optionally, include one or more modifier flags.

If the AM_SEEKING_ReturnTime flag is specified, the method converts the position value to a reference time and returns it in the pCurrent or pStop variable. This flag is useful if you are using another time format, such as frames.

The AM_SEEKING_Segment and AM_SEEKING_NoFlush flags support seamless looping:

  • If the AM_SEEKING_Segment flag is present, the source filter sends an EC_END_OF_SEGMENT event when it reaches the stop position, instead of calling IPin::EndOfStream. The application can wait for this event and then issue another seek command.
  • If the AM_SEEKING_NoFlush flag is present, the graph does not flush data during the seek. Use this flag with AM_SEEKING_Segment.

To perform looping, the graph must report AM_SEEKING_CanDoSegments in the IMediaSeeking::GetCapabilities method. Currently, only the WAVE Parser Filter supports this feature.

The incoming values of pCurrent and pStop are expressed in the current time format. The default time format is REFERENCE_TIME units (100 nanoseconds). To change time formats, use the IMediaSeeking::SetTimeFormat method. If the AM_SEEKING_ReturnTime flag is present, the method converts the outgoing value to REFERENCE_TIME units.

Filter Developers

If you implement this method, you can check whether the caller is requesting a change in the current or stop position, by using the value AM_SEEKING_PositioningBitsMask to mask out the modifier flags. For example:

DWORD dwCurrentPos = dwCurrentFlags & AM_SEEKING_PositioningBitsMask
if (dwCurrentPos == AM_SEEKING_AbsolutePositioning)
{ 
    // Set new position to pCurrent.
    m_rtStart = *pCurrent;
}
else if (dwCurrentPos == AM_SEEKING_RelativePositioning)
{
    // Increment current position by pCurrent.
    m_rtStart += *pCurrent;
}

For more information, see the source code for the CSourceSeeking::SetPositions method in the base class library.

Requirements

Header: Declared in Strmif.h; include Dshow.h.

Library: Use Strmiids.lib.

See Also