Index Topic Contents | |||
Previous Topic: CBaseList Class Next Topic: CBaseObject Class |
CBaseMediaFilter Class
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_clsid Class identifier (CLSID) used for serialization using IPersist. 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. 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. CBaseMediaFilter Class
CBaseMediaFilter::CBaseMediaFilterConstructs a CBaseMediaFilter object.
CBaseMediaFilter(
TCHAR *pName,
LPUNKNOWN pUnk,
CCritSec *pLock,
REFCLSID clsid
);Parameters
- pName
- Name of the CBaseMediaFilter class.
- pUnk
- IUnknown interface of the delegating object.
- pLock
- Pointer to the object that maintains the lock.
- clsid
- Class identifier used to serialize this filter.
Return Values
No return value.
CBaseMediaFilter Class
CBaseMediaFilter::GetClassIDFills the pClsID parameter with the class identifier of this filter (from m_clsid).
HRESULT GetClassID(
CLSID *pClsID
);Parameters
- pClsID
- Pointer to the class identifier to be filled out.
Return Values
Returns an HRESULT value.
CBaseMediaFilter Class
CBaseMediaFilter::GetStateRetrieves the current state of the filter.
HRESULT GetState(
DWORD dwMilliSecsTimeout,
FILTER_STATE * State
);Parameters
- dwMilliSecsTimeout
- Duration of the time-out, in milliseconds.
- State
- Returned state of the filter.
Return Values
Returns S_OK.
Remarks
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.
CBaseMediaFilter Class
CBaseMediaFilter::GetSyncSourceRetrieves the current reference clock in use by this filter.
HRESULT GetSyncSource(
IReferenceClock ** pClock
);Parameters
- pClock
- Pointer to a reference clock; will be set to the IReferenceClock interface.
Return Values
Returns an HRESULT value
Remarks
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.
CBaseMediaFilter Class
CBaseMediaFilter::IsActiveDetermines if the filter is currently active (running or paused) or stopped.
BOOL IsActive(void);
Return Values
Returns TRUE if the filter is paused or running, or FALSE if it is stopped.
CBaseMediaFilter Class
CBaseMediaFilter::NonDelegatingQueryInterfaceRetrieves an interface and increments the reference count.
HRESULT NonDelegatingQueryInterface(
REFIID riid,
void ** ppv
);Parameters
- riid
- Reference identifier.
- ppv
- Pointer to the interface.
Return Values
Returns E_POINTER if ppv is invalid. Returns NOERROR if the query is successful or E_NOINTERFACE if it is not.
Remarks
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.
CBaseMediaFilter Class
CBaseMediaFilter::PauseTransitions the filter to State_Paused state if it is not in this state already.
HRESULT Pause (void);
Return Values
Returns an HRESULT return value (S_OK by default).
Remarks
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.
CBaseMediaFilter Class
CBaseMediaFilter::RunTransitions the filter to State_Running state if it is not in this state already.
HRESULT Run (
REFERENCE_TIME tStart
);Parameters
- tStart
- Reference time value corresponding to stream time 0.
Return Values
Returns an HRESULT value.
Remarks
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.
CBaseMediaFilter Class
CBaseMediaFilter::SetSyncSourceIdentifies the reference clock to which the filter should synchronize activity.
HRESULT SetSyncSource(
IReferenceClock * pClock
);Parameters
- pClock
- Pointer to the IReferenceClock interface.
Return Values
Returns an HRESULT value.
Remarks
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.
CBaseMediaFilter Class
CBaseMediaFilter::StopTransitions the filter to State_Stopped state if it is not in this state already.
HRESULT Stop(void);
Return Values
Returns an HRESULT value.
Remarks
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.
CBaseMediaFilter Class
CBaseMediaFilter::StreamTimeRetrieves the current stream time.
virtual HRESULT StreamTime(
CRefTime& rtStream
);Parameters
- rtStream
- Current stream time.
Return Values
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. Remarks
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.
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.