CMediaSample.SetMediaTime 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 SetMediaTime method sets the media times for this sample. This method implements the IMediaSample::SetMediaTime method.

Syntax

HRESULT SetMediaTime(
   LONGLONG *pStart,
   LONGLONG *pEnd
);

Parameters

pStart

Pointer to the media start time, or NULL.

pEnd

Pointer to the media stop time, or NULL.

Return value

Returns S_OK.

Remarks

The media stop time must be greater than the media start time. Use NULL to invalidate the media times.

The pEnd parameter specifies an absolute media time, but the CMediaSample::m_MediaEnd member variable is calculated as an offset from pStart. In other words, m_MediaEnd = *pTimeEnd *pTimeStart.

For information about media times, 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