This is an abstract base class that provides support for the IMediaFilter interface. The CBaseMediaFilter class handles State_Stopped, State_Paused, and State_Running state transitions. Typically, this class is used for plug-in distributors rather than filters with pins. Derive your filter classes from the CBaseFilter class (or base classes derived from this) instead of from this class.
All member functions in this class that return HRESULT and accept a pointer as a parameter return E_POINTER when passed a null pointer.
Protected Data Members
Name | Description |
m_pClock | Pointer to a reference clock used for synchronization. The reference count of the clock object must be incremented using AddRef. Pass NULL if no reference clock is available. |
m_State | Current state of the filter, which can be State_Stopped, State_Paused, or State_Running. |
m_tStart | Offset from the stream time to the reference time. |
m_clsid | Class identifier (CLSID) used for serialization using IPersist. |
Member Functions
Name | Description |
CBaseMediaFilter | Constructs a CBaseMediaFilter object. |
IsActive | Determines if the filter is currently active (running or paused) or stopped. |
Overridable Member Functions
Name | Description |
StreamTime | Returns the current stream time. |
Implemented IPersist Methods
Name | Description |
GetClassID | Returns the class identifier of this filter. |
Implemented IMediaFilter Methods
Name | Description |
GetState | Retrieves the current state of the filter. |
GetSyncSource | Retrieves the current reference clock in use by this filter. |
Pause | Instructs the filter to transition to the new (paused) state. |
Run | Instructs the filter to transition to the new (running) state. |
SetSyncSource | Informs the filter of the reference clock with which it should synchronize activity. |
Stop | Instructs the filter to transition to the new (stopped) state. |
Implemented INonDelegatingUnknown Methods
Name | Description |
NonDelegatingQueryInterface | Passes out references to interfaces supported by CBaseFilter. Override this to pass out pointers to interfaces supported in a derived filter class. |
Constructs a CBaseMediaFilter object.
CBaseMediaFilter(
TCHAR *pName,
LPUNKNOWN pUnk,
CCritSec *pLock,
REFCLSID clsid
);
No return value.
Fills the pClsID parameter with the class identifier of this filter (from m_clsid).
HRESULT GetClassID(
CLSID *pClsID
);
Returns an HRESULT value.
Retrieves the current state of the filter.
HRESULT GetState(
DWORD dwMilliSecsTimeout,
FILTER_STATE * State
);
Returns S_OK.
This member function implements the IMediaFilter::GetState method. It returns the value of the m_State data member.
Filters should derive their filters from CBaseFilter and not from CBaseMediaFilter, so filters will not likely use this member function. Use CBaseFilter::GetState instead.
Retrieves the current reference clock in use by this filter.
HRESULT GetSyncSource(
IReferenceClock ** pClock
);
Returns an HRESULT value
This member function implements the IMediaFilter::GetSyncSource method. It returns the value of m_pClock after adding a reference to it. Be sure to release the interface by calling the IUnknown::Release method when finished with the pointer.
Filters should derive their filters from CBaseFilter and not from CBaseMediaFilter, so filters will not likely use this member function. Use CBaseFilter::GetSyncSource instead.
Determines if the filter is currently active (running or paused) or stopped.
BOOL IsActive(void);
Returns TRUE if the filter is paused or running, or FALSE if it is stopped.
Retrieves an interface and increments the reference count.
HRESULT NonDelegatingQueryInterface(
REFIID riid,
void ** ppv
);
Returns a pointer to the interface.
This member function implements the INonDelegatingUnknown::NonDelegatingQueryInterface method and passes out references to the IMediaFilter, IPersist, and IUnknown interfaces. Override this class to return other interfaces on the object in the derived class.
Transitions the filter to State_Paused state if it is not in this state already.
HRESULT Pause (void);
Returns an HRESULT return value (S_OK by default).
This member function implements the IMediaFilter::Pause method. It sets the value of m_State to State_Paused.
Note that filters should derive their filters from CBaseFilter and not from CBaseMediaFilter, so this member function will not likely be used by filters. Use CBaseFilter::Pause instead.
Transitions the filter to State_Running state if it is not in this state already.
HRESULT Run (
REFERENCE_TIME tStart
);
Returns an HRESULT value.
If the filter is in State_Stopped state, the CBaseMediaFilter::Pause member function is called first to transition the filter to State_Paused state, which has the effect of activating any of the filter's connected pins. If any pin returns a failure return code from its CBasePin::Active member function, the function fails and the state is not changed. If this member function succeeds, the filter's m_State member variable is set to State_Running. This member function holds the filter's lock.
Filters should derive their filters from CBaseFilter and not from CBaseMediaFilter, so filters will not likely use this member function. Use CBaseFilter::Run instead.
Identifies the reference clock to which the filter should synchronize activity.
HRESULT SetSyncSource(
IReferenceClock * pClock
);
Returns an HRESULT value.
This member function implements the IMediaFilter::SetSyncSource method. It sets the m_pClock data member to the pClock parameter and increments the reference count on the IReferenceClock interface passed in.
This member function is most important to rendering filters and might not apply to other filters.
Filters should derive their filters from CBaseFilter and not from CBaseMediaFilter, so filters will not likely use this member function. Use CBaseFilter::SetSyncSource instead.
Transitions the filter to State_Stopped state if it is not in this state already.
HRESULT Stop(void);
Returns an HRESULT value.
This member function implements the IMediaFilter::Stop method. It sets the m_State member variable to State_Stopped.
Note that filters should derive their filters from CBaseFilter and not from CBaseMediaFilter, so this member function will not likely be used by filters. Use CBaseFilter::Stop instead.
Retrieves the current stream time.
virtual HRESULT StreamTime(
CRefTime& rtStream
);
Returns an HRESULT value, which can include the following values.
Value | Meaning |
E_FAIL | Unable to get time from clock. |
S_OK | Stream time returned in the rtStream parameter. |
VFW_E_NO_CLOCK | No reference clock is available. |
Current stream time is the reference clock time minus the stream time offset. All samples with time stamps less than or equal to this time should have been presented.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.