Index Topic Contents | |||
Previous Topic: IMediaFilter Interface Next Topic: IMediaPropertyBag Interface |
IMediaPosition Interface
Applications communicating with the filter graph can call methods on this interface to set or retrieve properties such as the duration of the stream, the start and stop times, the preroll time, the rate, and the current position. The filter graph uses these properties on seekable filters to control the playback of streams within the graph; where there are multiple streams, the filter graph sets them all to play in parallel, beginning at the same position, and will report the duration as being the duration of the longest stream. The REFTIME parameters used in this interface are double value, representing a fractional number of seconds. Internally, filters will store time to an accuracy of 100 nanoseconds.
When to Implement
The filter graph manager exposes the IMediaPosition interface if any of the filters within the graph are seekable (can seek to an arbitrary position in the stream). This normally means a seekable file source filter. Filters, such as a file source filter, will expose IMediaPosition if they can seek their data or if their output pin represents a seekable stream. The renderer filter should also expose this interface. Output pins of transform filters expose this interface to pass the positioning information upstream from the renderer through each intermediate filter to the seekable filter.
Use the CMediaPosition class to help implement this interface on a filter. Use the CPosPassThru base class to implement this interface on output pins of transform filters used to pass media positioning information upstream. This is enabled by default in the pin base classes.
When to Use
Applications can use this interface to set or retrieve media positioning properties. Most commonly, an application will use the methods on this interface to play a media stream for some duration starting at some set position in the stream (for example, 10 seconds from the start).
Methods in Vtable Order
IUnknown methods Description QueryInterface Returns pointers to supported interfaces. AddRef Increments the reference count. Release Decrements the reference count.
IDispatch methods Description GetTypeInfoCount Determines whether there is type information available for this dispinterface. GetTypeInfo Retrieves the type information for this dispinterface if GetTypeInfoCount returned successfully. GetIDsOfNames Converts text names of properties and methods (including arguments) to their corresponding DISPIDs. Invoke Calls a method or accesses a property in this dispinterface if given a DISPID and any other necessary parameters.
IMediaPosition methods Description get_Duration Retrieves the total duration of the media stream. put_CurrentPosition Sets the time that the media stream begins. get_CurrentPosition Retrieves the current position in terms of the total length of the media stream. get_StopTime Retrieves the position within the media stream at which playback should stop. put_StopTime Sets the position within the media stream at which playback should stop. get_PrerollTime Retrieves the time prior to the start position that the filter graph begins any nonrandom access device rolling. put_PrerollTime Sets the time prior to the start position that the filter graph begins any nonrandom access device rolling. put_Rate Sets the playback rate, relative to normal playback of the media stream. get_Rate Retrieves the playback rate, relative to normal playback of the media stream. CanSeekForward Determines if the current position can be moved forward in the media stream. CanSeekBackward Determines if the current position can be moved backward in the media stream. IMediaPosition Interface
IMediaPosition::CanSeekBackwardDetermines if the current position can be moved backward in the media stream.
HRESULT CanSeekBackward(
LONG *pCanSeekBackward
);Parameters
- pCanSeekBackward
- [out] Set to OATRUE if able to seek backward; otherwise set to OAFALSE.
Return Values
Returns an HRESULT value.
IMediaPosition Interface
IMediaPosition::CanSeekForwardDetermines if the current position can be moved forward in the media stream.
HRESULT CanSeekForward(
LONG *pCanSeekForward
);Parameters
- pCanSeekForward
- [out] Set to OATRUE if able to seek forward; otherwise set to OAFALSE.
Return Values
Returns an HRESULT value.
IMediaPosition Interface
IMediaPosition::get_CurrentPositionRetrieves the current position in terms of the total length of the media stream.
HRESULT get_CurrentPosition(
REFTIME* pllTime
);Parameters
- pllTime
- [out] Reference time of the current position.
Return Values
Returns an HRESULT value.
Remarks
This is the position that playback has reached. It is a value between zero and the total duration of the media (that is, it does not take into account the rate and start time). If the filter graph is paused, this is the position at which it will restart.
When the filter graph is stopped or paused, this method returns the position at which playback will recommence. When the filter graph is running, the filter graph manager returns the position according to the reference clock. If an individual filter implements this, it should return the stream time of the sample it is processing (that is, the offset time from the beginning) when paused or running. If you implement this using stream time or the reference clock, remember to adjust the value you return for start position and playback rate so that the value returned is in terms of the media's total duration.
After stopping or pausing, a run command causes playback to begin at the current position. This will be where playback stopped or paused, unless there has been an IMediaPosition::put_CurrentPosition call in the meantime.
IMediaPosition Interface
IMediaPosition::get_DurationRetrieves the total duration of the media stream.
HRESULT get_Duration(
REFTIME* plength
);Parameters
- plength
- [out] Returned length of the media stream.
Return Values
Returns an HRESULT value.
Remarks
The duration assumes normal playback speed, and it is therefore unaffected by the rate.
IMediaPosition Interface
IMediaPosition::get_PrerollTimeRetrieves the time prior to the start position that any nonrandom access device should start rolling.
HRESULT get_PrerollTime(
REFTIME* pllTime
);Parameters
- pllTime
- [out] Returned preroll time as a double pointer value.
Return Values
Returns an HRESULT value.
Remarks
Preroll time is the time prior to the start position at which nonrandom access devices, such as tape players, should start rolling.
IMediaPosition Interface
IMediaPosition::get_RateRetrieves the rate of playback relative to normal playback speed.
HRESULT get_Rate(
double * pdRate
);Parameters
- pdRate
- [out] Returned rate.
Return Values
Returns an HRESULT value.
Remarks
A rate of 1.0 indicates normal playback speed. A rate of 0.5 indicates half speed. A rate of 1.0 indicates normal speed in reverse.
IMediaPosition Interface
IMediaPosition::get_StopTimeRetrieves the time at which the media stream stops.
HRESULT get_StopTime(
REFTIME* pllTime
);Parameters
- pllTime
- [out] Returned stop time as a double pointer value.
Return Values
Returns an HRESULT value.
Remarks
The stop time is a position between zero and the duration of the media at which playback should stop.
The stop position is applied before the rate and therefore is the position at typical playback speed.
IMediaPosition Interface
IMediaPosition::put_CurrentPositionSets the time that the media stream begins.
HRESULT put_CurrentPosition(
REFTIME llTime
);Parameters
- llTime
- [in] Start time expressed as a double value.
Return Values
Returns an HRESULT value.
Remarks
The start time is a position between zero and the duration of the media at which playback should begin when the next run command is issued.
If this method is called when the filter graph manager is running, the filter graph manager will pause the graph, run the method, and then issue a new run command.
If called when the filter graph is paused, this method must flush existing data by using IPin::BeginFlush and IPin::EndFlush before pushing the new data (at the new current position).
Setting the current position when paused or stopped causes playback to resume from the new start position when the run command is issued.
The current position is applied before the rate and therefore is the position at typical playback speed.
IMediaPosition Interface
IMediaPosition::put_PrerollTimeSets the time prior to the start position that any nonrandom access device should start rolling.
HRESULT put_PrerollTime(
REFTIME llTime
);Parameters
- llTime
- [in] Preroll time to be set.
Return Values
Returns an HRESULT value.
Remarks
Preroll time is the time prior to the start position at which nonrandom access devices, such as tape players, should start rolling.
IMediaPosition Interface
IMediaPosition::put_RateSets the rate of playback relative to normal speed.
HRESULT put_Rate(
double dRate
);Parameters
- dRate
- [in] Rate to set.
Return Values
Returns an HRESULT value.
Remarks
This method allows an application to speed up or slow down playback relative to the normal default playback speed. A rate of 1.0 indicates normal playback speed. Specifying 2.0 causes playback at twice the normal rate: a video created for 10 frames per second (fps) will be played back at 20 fps, if resources permit. Audio streams played back at above-normal speed increase the pitch rather than drop samples.
IMediaPosition Interface
IMediaPosition::put_StopTimeSets the time at which the media stream will stop.
HRESULT put_StopTime(
REFTIME llTime
);Parameters
- llTime
- [in] Stop time as a double value.
Return Values
Returns an HRESULT value.
Remarks
The stop time is a position between zero and the duration of the media at which playback should stop.
The stop position is applied before the rate and therefore is the position at typical playback speed.
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.