Microsoft DirectX 8.0 |
Base class that implements the IMediaFilter interface. Use this class for plug-in distributors or other objects that need to support IMediaFilter without supporting the IBaseFilter interface. Do not use this class for filters. Instead, use the CBaseFilter class, or a base class derived from CBaseFilter.
Declaration: Amfilter.h
Protected Member Variables | |
---|---|
m_State | Current state of the object. |
m_pClock | Pointer to the object's reference clock. |
m_tStart | Reference time that corresponds to stream time 0. |
m_clsid | Class identifier (CLSID) of the object. |
m_pLock | Pointer to a critical section. |
Public Methods | |
CBaseMediaFilter | Constructor method. |
~CBaseMediaFilter | Destructor method. Virtual. |
StreamTime | Retrieves the current stream time. Virtual. |
IsActive | Determines whether the object is active (running or paused). |
IPersist Methods | |
GetClassID | Retrieves the class identifier. |
IMediaFilter Methods | |
GetState | Retrieves the object's state (running, stopped, or paused). |
SetSyncSource | Sets a reference clock for the object. |
GetSyncSource | Retrieves the reference clock that the object is using. |
Stop | Stops the object. |
Pause | Pauses the object. |
Run | Runs the object. |
Current state of the object.
Syntax
FILTER_STATE m_State;
Pointer to the object's reference clock.
Syntax
IReferenceClock *m_pClock;
Reference time that corresponds to stream time 0.
Syntax
CRefTime m_tStart;
Class identifier (CLSID) of the object.
Syntax
CLSID m_clsid;
Pointer to a critical section.
Syntax
CCritSec *m_pLock;
Remarks
The critical section is held during state transitions (Run, Pause, Stop), when accessing the reference clock (SetSyncSource, GetSyncSource), and in the IsActive method.
Constructor method.
Syntax
CBaseMediaFilter( const TCHAR *pName, LPUNKNOWN pUnk, CCritSec *pLock, REFCLSID clsid );
Parameters
- pName
- Pointer to a string containing the name of the object.
- pUnk
- Pointer to the owner of this object. If the object is aggregated, pass a pointer to the aggregating object's IUnknown interface. Otherwise, set this parameter to NULL.
- pLock
- Pointer to a CCritSec lock, used to serialize state changes.
- clsid
- Class identifier of the object.
Remarks
If another object contains or aggregates the CBaseMediaFilter object, the CCritSec lock might be external to the CBaseMediaFilter object. In that case, pass a pointer to the lock in pLock.
Otherwise, you can:
- Derive a class that inherits both CBaseMediaFilter and CCritSec. For pLock, pass the this pointer.
- Derive a class that inherits CBaseMediaFilter and contains a CCritSec member variable. For pLock, pass the address of that variable.
Destructor method.
Syntax
CBaseMediaFilter(void);
Remarks
Always stop the object before destroying it.
Retrieves the class identifier. Implements the IPersist::GetClassID method.
Syntax
HRESULT GetClassID( CLSID *pClsID );
Parameters
- pClsID
- Pointer to a variable that receives the class identifier.
Return Value
Returns S_OK or E_POINTER.
Retrieves the object's state (running, stopped, or paused). Implements the IMediaFilter::GetState method.
Syntax
HRESULT GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State );
Parameters
- dwMilliSecsTimeout
- Time-out interval, in milliseconds.
- State
- Pointer to a variable that receives a member of the FILTER_STATE enumerated type, indicating the object's state.
Return Value
Returns S_OK or E_POINTER.
Remarks
In the base class, all state transitions are synchronous and the dwMilliSecsTimeout parameter is ignored. If a derived class performs asynchronous state transitions, it should override this method to wait during state transitions, with a time-out of dwMilliSecsTimeout milliseconds.
Retrieves the reference clock that the object is using. Implements the IMediaFilter::GetSyncSource method.
Syntax
HRESULT GetSyncSource( IReferenceClock **pClock );
Parameters
- pClock
- Address of a variable that receives a pointer to the clock's IReferenceClock interface.
Return Value
Returns S_OK or E_POINTER.
Remarks
If the object is not using a reference clock, *pClock is set to NULL. When the method returns, if *pClock is non-NULL, the IReferenceClock interface has an outstanding reference count. Be sure to release it when you are done.
Determines whether the object is active (running or paused).
Syntax
BOOL IsActive(void);
Return Value
Returns TRUE if the object is paused or running, or FALSE if it is stopped.
Pauses the object. Implements the IMediaFilter::Pause method.
Syntax
HRESULT Pause(void);
Return Value
Returns S_OK.
Remarks
In the base class, this method sets the m_State member variable to State_Paused but does nothing else.
Runs the object. Implements the IMediaFilter::Run method.
Syntax
HRESULT Run( REFERENCE_TIME tStart );
Parameters
- tStart
- Reference time corresponding to stream time 0.
Return Value
Returns S_OK.
Remarks
If the object is stopped, this method pauses the object by calling the CBaseMediaFilter::Pause method. It then sets the m_State member variable to State_Running.
Stream time is calculated as the current reference time minus tStart. A media sample with a time stamp of zero should be rendered at time tStart.
Sets a reference clock for the object. Implements the IMediaFilter::SetSyncSource method.
Syntax
HRESULT SetSyncSource( IReferenceClock *pClock );
Parameters
- pClock
- Pointer to the clock's IReferenceClock interface, or NULL.
Return Value
Returns S_OK.
Stops the object. Implements the IMediaFilter::Stop method.
Syntax
HRESULT Stop(void);
Return Value
Returns S_OK.
Remarks
In the base class, this method sets the m_State member variable to State_Stopped but does nothing else.
Retrieves the current stream time.
Syntax
virtual HRESULT StreamTime( CRefTime& rtStream );
Parameters
- rtStream
- Reference to a CRefTime object that receives the current stream time.
Return Value
Returns an HRESULT value. Possible values include those listed in the following table.
S_OK Success. VFW_E_NO_CLOCK No reference clock is available.
Remarks
Stream time is defined as the current reference time (as given by the reference clock) minus the start time (specified by m_tStart). A media sample's time stamp specifies the stream time when it should be rendered. If a sample with a time stamp less than the current stream time has not yet been rendered, it is late.