CSourceSeeking is an abstract class that assists source filters with the implementation of IMediaSeeking interface methods. This class enables a source filter to handle calls that change the start and stop positions in the media stream and the playback rate.
Derive from this class and set the positions. This class supports IMediaSeeking, and calls the pure virtual member functions CSourceSeeking::ChangeStart, CSourceSeeking::ChangeStop, and CSourceSeeking::ChangeRate when CSourceSeeking::SetPositions or CSourceSeeking::SetRate is called, to enable a source filter to handle these commands and start sending new data.
Override the CSourceSeeking::ChangeStart, CSourceSeeking::ChangeStop, and CSourceSeeking::ChangeRate member functions to do something when the properties change.
Protected Data Members
| Name | Description |
| m_dRateSeeking | Playback rate. Set to 1 by default. |
| m_dwSeekingCaps | Seeking capabilities returned in the GetCapabilities function. Can be one or more of the following values: AM_SEEKING_CanSeekForwards, AM_SEEKING_CanSeekBackwards, AM_SEEKING_CanSeekAbsolute, AM_SEEKING_CanGetStopPos, AM_SEEKING_CanGetDuration. Set to all of these by default. |
| m_pLock | Pointer to a CCritSec object for locking. |
| m_rtDuration | Duration of the stream. Set to m_rtStop by default. |
| m_rtStart | Start time. Set to zero by default. |
| m_rtStop | Stop time. Set to the largest positive 64-bit integer possible (9223372036854775807) by default. |
Member Functions
| Name | Description |
| CSourceSeeking | Constructs a CSourceSeeking object. |
Overridable Member Functions
| Name | Description |
| ChangeRate | Override this pure virtual to handle notification of a change of sample rate. |
| ChangeStart | Override this pure virtual to handle notification of a change of start time. |
| ChangeStop | Override this pure virtual to handle notification of a change in stop time. |
Implemented IMediaSeeking Methods
| Name | Description |
| CheckCapabilities | Checks that all requested capabilities are in m_dwSeekingCaps. |
| ConvertTimeFormat | Checks that the time format is TIME_FORMAT_MEDIA_TIME. This is the only format currently available. |
| GetAvailable | Retrieves the range of seeking times. Earliest is zero and latest is the media stream's duration. |
| GetCapabilities | Retrieves the current seeking capabilities in m_dwSeekingCaps. |
| GetCurrentPosition | Not currently implemented. |
| GetDuration | Retrieves the length of time the media stream will play. |
| GetPositions | Retrieves the current start and stop position settings. |
| GetPreroll | Sets the preroll time to zero. |
| GetRate | Retrieves the current playback rate. |
| GetStopPosition | Retrieves the position within the media stream at which playback should stop. |
| GetTimeFormat | Sets the time format to TIME_FORMAT_MEDIA_TIME. This is the only format currently supported. |
| IsFormatSupported | Determines if the requested format is TIME_FORMAT_MEDIA_TIME. This is the only format currently supported. |
| IsUsingTimeFormat | Determines if the requested format is TIME_FORMAT_MEDIA_TIME. This is the only format currently supported. |
| QueryPreferredFormat | Sets the preferred time format to TIME_FORMAT_MEDIA_TIME. This is the only format currently supported. |
| SetPositions | Sets current and stop positions, first checking that the seeking options are valid. |
| SetRate | Sets the playback rate. |
| SetTimeFormat | Checks that the time format is TIME_FORMAT_MEDIA_TIME. This is the only format currently supported. |
Implemented INonDelegatingUnknown Methods
| Name | Description |
| NonDelegatingQueryInterface | Retrieves an interface and increments the reference count on the interface. |
Override this member function to handle notification of a change of sample rate.
virtual HRESULT ChangeRate( ) PURE;
Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:
| Value | Meaning |
| E_FAIL | Failure. |
| E_POINTER | Null pointer argument. |
| E_INVALIDARG | Invalid argument. |
| E_NOTIMPL | Method isn't supported. |
| S_OK or NOERROR | Success. |
This member function is called when a change to the rate has been made by a call to the CSourceSeeking::SetRate function. Override this and change the rate of data sent. Typically, you do this by calling CBaseInputPin::BeginFlush and CBaseInputPin::EndFlush, and then send samples marked with new time stamps, for example, with an implementation NewSegment method.
Override this member function to handle notification of a change of start time.
virtual HRESULT ChangeStart( ) PURE;
Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:
| Value | Meaning |
| E_FAIL | Failure. |
| E_POINTER | Null pointer argument. |
| E_INVALIDARG | Invalid argument. |
| E_NOTIMPL | Method isn't supported. |
| S_OK or NOERROR | Success. |
This member function is called when a new start position has been requested by a call to CSourceSeeking::SetPositions. Override this and change the data sent. Typically, you do this by calling CBaseInputPin::BeginFlush and CBaseInputPin::EndFlush, and then send samples marked with new start time, for example, with an implementation NewSegment method.
Override this member function to handle notification of a change in stop time.
virtual HRESULT ChangeStop( ) PURE;
Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:
| Value | Meaning |
| E_FAIL | Failure. |
| E_POINTER | Null pointer argument. |
| E_INVALIDARG | Invalid argument. |
| E_NOTIMPL | Method isn't supported. |
| S_OK or NOERROR | Success. |
This member function is called when a change to the stop position has been made by a call to CSourceSeeking::SetPositions. Override this and ensure that the correct stop time is being observed. Typically, you do this by calling CBaseInputPin::BeginFlush and CBaseInputPin::EndFlush, and then send samples marked with new stop time, for example, with an implementation NewSegment method.
Checks that all the requested capabilities are among the flags in m_dwSeekingCaps.
HRESULT CheckCapabilities(
DWORD * pCapabilities
);
| AM_SEEKING_CanGetCurrentPos |
| AM_SEEKING_CanGetDuration |
| AM_SEEKING_CanGetStopPos |
| AM_SEEKING_CanPlayBackwards |
| AM_SEEKING_CanSeekAbsolute |
| AM_SEEKING_CanSeekBackwards |
| AM_SEEKING_CanSeekForwards |
Returns E_POINTER if pCapabilities is not a valid pointer, S_OK if all the requested capabilities in pCapabilities are supported, or S_FALSE if they are not.
Checks that the time format is TIME_FORMAT_MEDIA_TIME. This is the only format currently available.
HRESULT ConvertTimeFormat(
LONGLONG * pTarget,
const GUID * pTargetFormat,
LONGLONG Source,
const GUID * pSourceFormat
);
Returns E_POINTER if pTarget is not a valid pointer, or E_INVALIDARG if pTargetFormat and pSourceFormat are not equal to TIME_FORMAT_MEDIA_TIME or NULL; otherwise, returns S_OK.
Constructs a CSourceSeeking object.
CSourceSeeking(
const TCHAR * pName,
LPUNKNOWN pUnk,
HRESULT * phr,
CCritSec * pLock
);
No return value.
Allocate the pName parameter in static memory. This name appears on the debugging terminal upon creation and deletion of the object.
Returns the range of seeking times.
HRESULT GetAvailable(
LONGLONG * pEarliest,
LONGLONG * pLatest
);
Returns S_OK.
Retrieves the seeking capabilities of the media stream.
HRESULT GetCapabilities(
DWORD * pCapabilities
);
| AM_SEEKING_CanGetCurrentPos |
| AM_SEEKING_CanGetDuration |
| AM_SEEKING_CanGetStopPos |
| AM_SEEKING_CanPlayBackwards |
| AM_SEEKING_CanSeekAbsolute |
| AM_SEEKING_CanSeekBackwards |
| AM_SEEKING_CanSeekForwards |
Returns E_POINTER if pCapabilities is invalid; otherwise, returns S_OK.
Not currently implemented.
HRESULT GetCurrentPosition(
LONGLONG* pCurrent
);
Returns E_NOTIMPL.
This function is typically supported only in renderers and not in source filters.
Retrieves the length of time that the media stream will play.
HRESULT GetDuration(
LONGLONG* pDuration
);
Returns E_POINTER if pDuration is invalid; otherwise, returns S_OK.
The duration in m_rtDuration is set to the stop time in m_rtStop. Set the stop time with the CSourceSeeking::SetPositions function.
Retrieves the current and stop position settings.
HRESULT GetPositions(
LONGLONG * pCurrent,
LONGLONG * pStop
);
Returns S_OK.
The start and stop times are set in the CSourceSeeking::SetPositions function.
Sets the preroll time to zero.
HRESULT GetPreroll(
LONGLONG * pPreroll
);
Returns E_POINTER if pPreroll is invalid; otherwise, returns S_OK.
Retrieves the current playback rate.
HRESULT GetRate(
double * pdRate
);
Returns E_POINTER if pdRate is invalid; otherwise, returns S_OK.
Set the rate in the CSourceSeeking::SetRate function.
Retrieves the position within the media stream at which playback should stop.
HRESULT GetStopPosition(
LONGLONG* pStop
);
Returns E_POINTER if pStop is invalid; otherwise, returns S_OK.
Set the stop time in the CSourceSeeking::SetPositions function.
Sets the time format to TIME_FORMAT_MEDIA_TIME, which determines the format of units used during seeking.
HRESULT GetTimeFormat(
const GUID * pFormat
);
Returns E_POINTER if pFormat is invalid; otherwise, returns S_OK.
TIME_FORMAT_MEDIA_TIME is the only time format currently supported.
Determines if the requested format is TIME_FORMAT_MEDIA_TIME.
HRESULT IsFormatSupported(
const GUID * pFormat
);
Returns E_POINTER if pFormat is invalid, S_OK if the format in pFormat is TIME_FORMAT_MEDIA_TIME, or S_FALSE if the format in pFormat is not TIME_FORMAT_MEDIA_TIME.
TIME_FORMAT_MEDIA_TIME is the only time format currently supported. As implemented, this function is the same as CSourceSeeking::IsUsingTimeFormat.
Determines if the requested format is TIME_FORMAT_MEDIA_TIME.
HRESULT IsUsingTimeFormat(
const GUID * pFormat
);
Returns E_POINTER if pFormat is invalid, S_OK if the format in pFormat is TIME_FORMAT_MEDIA_TIME, or S_FALSE if the format in pFormat is not TIME_FORMAT_MEDIA_TIME.
TIME_FORMAT_MEDIA_TIME is the only time format currently supported. As implemented, this method is the same as CSourceSeeking::IsFormatSupported.
Retrieves an interface and increments the reference count on the interface.
HRESULT NonDelegatingQueryInterface(
REFIID riid,
void **ppv
);
Returns E_POINTER if ppv is invalid. Returns NOERROR if the query is successful or E_NOINTERFACE if it is not.
Returns pointers to the IMediaSeeking and IUnknown interfaces by default. Override this method to publish any additional interfaces implemented by the derived class.
This member function implements the INonDelegatingUnknown::NonDelegatingQueryInterface method.
Sets the preferred time format to TIME_FORMAT_MEDIA_TIME.
HRESULT QueryPreferredFormat(
GUID *pFormat
);
Returns E_POINTER if pFormat is invalid; otherwise, returns S_OK.
TIME_FORMAT_MEDIA_TIME is the only time format currently supported.
Sets current and stop positions, first checking that the seeking options are valid.
HRESULT SetPositions(
LONGLONG * pCurrent,
DWORD CurrentFlags,
LONGLONG * pStop,
DWORD StopFlags
);
Returns E_INVALIDARG if CurrentFlags and StopFlags are not one of the values listed, or E_POINTER if pCurrent or pStop is invalid; otherwise, returns the HRESULT returned by calls to the CSourceSeeking::ChangeStart and CSourceSeeking::ChangeStop functions.
You must implement ChangeStart and ChangeStop to use this method.
CSourceSeeking::GetPositions, CSourceSeeking::GetStopPosition, CSourceSeeking::GetDuration
Sets a new playback rate.
HRESULT SetRate(
double dRate
);
Returns the HRESULT value returned by the call to the CSourceSeeking::ChangeRate function.
You must implement ChangeRate to use this method. The m_dRateSeeking data member is set to the new rate. Setting the rate to zero causes an error.
Checks that the requested format is TIME_FORMAT_MEDIA_TIME.
HRESULT SetTimeFormat(
const GUID * pFormat
);
Returns E_POINTER if pFormat is invalid, S_OK if the format in pFormat is TIME_FORMAT_MEDIA_TIME, or E_INVALIDARG if the format in pFormat is not TIME_FORMAT_MEDIA_TIME.
TIME_FORMAT_MEDIA_TIME is the only time format currently supported.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.