|Microsoft DirectX 9.0|
The time stamp defines a media sample's start and finish times, measured in stream time. The time stamp is sometimes called the presentation time. When reading the rest of this article, it is important to remember that not all formats use time stamps in the same way. For example, not all MPEG samples are time stamped. In MPEG filter graphs, the time stamp is not applied to each frame until they are output from the decoder.
When a renderer filter receives a sample, it schedules rendering based on the time stamp. If the sample arrives late, or has no time stamp, the filter renders the sample immediately. Otherwise, the filter waits until the sample's start time before it renders the sample. (It waits for the start time by calling the IReferenceClock::AdviseTime method.)
Source filters and parser filters are responsible for setting the correct time stamps on the samples they process. Use the following guidelines.
To set the time stamp on a sample, call the IMediaSample::SetTime method.
Optionally, the filter can also specify a media time for the sample. In a video stream, media time represents the frame number. In an audio stream, media time represents the sample number in the packet. For example, if each packet contains one second of 44.1 kilohertz (kHz) audio, the first packet has a media start time of zero and a media stop time of 44100. In a seekable stream, the media time is always relative to the start time of the stream. For example, suppose you seek to 2 seconds from the start of a 15-fps video stream. The first media sample after the seek has a time stamp of zero but a media time of 30.
Renderer and mux filters can use the media time to determine whether frames or samples have been dropped, by checking for gaps. However, filters are not required to set the media time. To set the media time on a sample, call the IMediaSample::SetMediaTime method.