CMediaSample.SetTime method

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The SetTime method sets the stream times when this sample should begin and finish. This method implements the IMediaSample::SetTime method.

Syntax

HRESULT SetTime(
   REFERENCE_TIME *pTimeStart,
   REFERENCE_TIME *pTimeEnd
);

Parameters

pTimeStart

Pointer to the stream time at which the sample begins, in 100-nanosecond units, or NULL.

pTimeEnd

Pointer to the stream time at which the sample ends, in 100-nanosecond units, or NULL.

Return value

Returns S_OK.

Remarks

This method sets the CMediaSample::m_Start and CMediaSample::m_End member variables, which specify the time stamps. It also updates the CMediaSample::m_dwFlags member variable, which specifies whether the time stamps are valid.

For information about time stamps, see Time and Clocks in DirectShow.

Requirements

Requirement Value
Header
Amfilter.h (include Streams.h)
Library
Strmbase.lib (retail builds);
Strmbasd.lib (debug builds)

See also

CMediaSample Class