CSourcePosition is an abstract class that assists source filters with the implementation of IMediaPosition methods.
Derive from this class and set the duration and default stop positions. This class supports IMediaPosition, and calls the pure virtual member functions CSourcePosition::ChangeStart, CSourcePosition::ChangeStop, and CSourcePosition::ChangeRate when CSourcePosition::put_CurrentPosition, CSourcePosition::put_StopTime, or CSourcePosition::put_Rate is called, to allow a source filter to handle these commands and start sending new data.
Override the CSourcePosition::ChangeStart, CSourcePosition::ChangeStop, and CSourcePosition::ChangeRate member functions to do something when the properties change.
Protected Data Members
Name | Description |
m_Duration | Duration of the stream. |
m_pLock | Pointer to a CCritSec object for locking. |
m_Rate | Sample rate. |
m_Start | Start time. |
m_Stop | Stop time. |
Member Functions
Name | Description |
CSourcePosition | Constructs a CSourcePosition object. |
Overridable Member Functions
Name | Description |
ChangeRate | Override this pure virtual to handle notification that the rate property has changed. |
ChangeStart | Override this pure virtual to handle notification that the start position property has changed. |
ChangeStop | Override this pure virtual to handle notification that the stop position property has changed. |
Implemented IMediaPosition Methods
Name | Description |
get_Duration | Retrieves the total duration of the media. |
get_PrerollTime | Retrieves the time prior to the start position that the filter graph will start any nonrandom access device rolling. |
put_PrerollTime | Sets the time prior to the start position that the filter graph will start any nonrandom access device rolling. |
get_Rate | Retrieves the playback rate, relative to normal playback of the media. |
put_Rate | Sets the playback rate, relative to normal playback of the media. |
get_CurrentPosition | Retrieves the position within the media at which playback will start. |
put_CurrentPosition | Sets the position within the media at which playback should start. |
get_StopTime | Retrieves the position within the media at which playback should stop. |
put_StopTime | Sets the position within the media at which playback should stop. |
Override this member function to handle notification of a change of sample rate.
virtual HRESULT ChangeRate( ) PURE;
Returns an HRESULT value.
This member function is called when a change to the rate has been made by a call to IMediaPosition::put_Rate. Override this and change the rate of data sent; typically, this will be by a call to CBaseInputPin::BeginFlush and CBaseInputPin::EndFlush, and then sending samples marked with new time stamps.
Override this member function to handle notification of a change of start time.
virtual HRESULT ChangeStart( ) PURE;
Returns an HRESULT value.
This member function is called when a new start position has been requested by a call to IMediaPosition::put_CurrentPosition. Override this and change the data sent; typically, this will be by a call to CBaseInputPin::BeginFlush and CBaseInputPin::EndFlush, and then sending samples marked with new time stamps.
Override this member function to handle notification of a change in stop time.
virtual HRESULT ChangeStop( ) PURE;
Returns an HRESULT value.
This member function is called when a change to the stop position has been made by a call to IMediaPosition::put_StopTime. Override this and ensure that the correct stop time is being observed; typically, this will be a call to CBaseInputPin::BeginFlush and CBaseInputPin::EndFlush, and then resending data.
Constructs a CSourcePosition object.
CSourcePosition(
const TCHAR *pName,
LPUNKNOWN pUnk,
HRESULT * phr,
CCritSec * pCritSec
);
No return value.
Allocate the pName parameter in static memory. This name appears on the debugging terminal upon creation and deletion of the object.
Retrieves the position within the stream at which playback should begin.
HRESULT get_CurrentPosition(
REFTIME* pllTime
);
Returns an HRESULT value.
The start position is applied before the rate and therefore is the position at typical playback speed.
Retrieves the total duration of the media stream.
HRESULT get_Duration(
REFTIME* plength
);
Returns an HRESULT value.
The duration assumes normal playback speed; it is therefore unaffected by the rate.
Retrieves the time prior to the start position that devices should start rolling.
HRESULT get_PrerollTime(
REFTIME* pllTime
);
Returns an HRESULT value.
Preroll time is the time prior to the start position at which nonrandom access devices, such as tape players, should start rolling.
Retrieves the rate of playback relative to normal playback speed.
HRESULT get_Rate(
double * pdRate
);
Returns an HRESULT value.
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.
Retrieves the time at which the media stream stops.
HRESULT get_StopTime(
REFTIME* pllTime
);
Returns an HRESULT value.
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.
Sets the time within the media stream that playback should begin.
HRESULT put_CurrentPosition(
REFTIME llTime
);
Returns an HRESULT value.
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.
Setting the start position when paused causes playback to resume from the new start position when the run command is issued.
The start position is applied before the rate and therefore is the position at typical playback speed.
Sets the time prior to the start position that devices should start rolling.
HRESULT put_PrerollTime(
REFTIME llTime
);
Returns an HRESULT value.
Preroll time is the time prior to the start position at which nonrandom access devices, such as tape players, should start rolling.
Sets the rate of playback relative to normal speed.
HRESULT put_Rate(
double dRate
);
Returns an HRESULT value.
This property 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 frames.
Negative rates indicate reverse play. Not all media will support reverse play.
Sets the time at which the media stream will stop.
HRESULT put_StopTime(
REFTIME llTime
);
Returns an HRESULT value.
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.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.