CMediaSample.GetTime 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 GetTime method retrieves the stream times at which this sample should begin and finish. This method implements the IMediaSample::GetTime method.

Syntax

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

Parameters

pTimeStart

Pointer to a variable that receives the beginning stream time, in 100-nanosecond units.

pTimeEnd

Pointer to a variable that receives the ending stream time, in 100-nanosecond units. If the sample has no stop time, the value is set to the start time plus one.

Return value

Returns one of the HRESULT values shown in the following table.

Return code Description
S_OK
Success.
VFW_S_NO_STOP_TIME
Sample has a valid start time, but no stop time.
VFW_E_SAMPLE_TIME_NOT_SET
Sample does not have valid time stamps.

Remarks

The CMediaSample::m_Start and CMediaSample::m_End member variables specify the time stamps. The CMediaSample::m_dwFlags member variable 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