CBaseInputPin is an abstract base class derived from CBasePin that adds support for IMemInputPin in addition to the IPin interface support provided by CBasePin. Its IMemInputPin::GetAllocator method returns a CMemAllocator object. Derive your input pin 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_pAllocator | Pointer to the default memory allocator. |
m_bFlushing | In the state of flushing; if TRUE, all IMemInputPin::Receive methods are returned with S_FALSE. |
m_bReadOnly | If TRUE, indicates that the allocator being used contains samples that are read-only. |
Member Functions
Name | Description |
CBaseInputPin | Constructs a CBaseInputPin object. |
IsReadOnly | Checks the m_bReadOnly data member and returns its value. |
IsFlushing | Checks the m_bFlushing data member and returns its value. |
Overridable Member Functions
Name | Description |
CheckStreaming | Verifies conditions for continuing with a streaming operation. |
Inactive | Switches the pin to an inactive state. |
Implemented IPin Methods
Name | Description |
BeginFlush | Informs the pin to begin a flush operation. |
Disconnect | Releases the stored allocator. |
EndFlush | Informs the pin to end a flush operation. |
Implemented IMemInputPin Methods
Name | Description |
GetAllocator | Returns the allocator interface that this input pin would like the output pin to use. |
GetAllocatorRequirements | Indicates an optional method to use if the filter has specific alignment or prefix requirements but could use an upstream allocator. |
NotifyAllocator | Tells the input pin which allocator the output pin is actually going to use. |
Receive | Returns the next block of data from the stream. (Override this method to process a sample being passed in.) |
ReceiveCanBlock | Determines if sending an IMemInputPin::Receive method might block. |
ReceiveMultiple | Returns the next block of data from the stream. (Override this method to process samples being passed in.) |
Implemented INonDelegatingUnknown Methods
Name | Description |
NonDelegatingQueryInterface | Retrieves an interface from the subobject, not the aggregated object. |
Implemented IQualityControl Methods
Name | Description |
Notify | Notifies the recipient that a quality-control change is requested. (Override on the output pin only. This implementation returns NOERROR.) |
Informs the pin to begin a flush operation.
HRESULT BeginFlush(void);
Returns an HRESULT value.
This member function implements the IPin::BeginFlush method. When this method is called, the pin is entering flush state. You must override this method in your derived class, but you should call this base class first in your implementation, because it sets m_bFlushing so that no more IMemInputPin::Receive calls will succeed.
The overriding member function should then carry out the following steps.
IPin::BeginFlush is not logically part of the media stream and can be optimized in the sense that if a pin has passed no data downstream before this method is called, there is no need to pass this notification on.
An example of an overriding implementation of this member function can be found in the CTransformInputPin::BeginFlush member function, which uses the CBaseOutputPin::DeliverBeginFlush member function to perform the last step.
Constructs a CBaseInputPin object.
CBaseInputPin::CBaseInputPin(
TCHAR *pObjectName,
CBaseFilter *pFilter,
CCritSec *pLock,
HRESULT *phr,
LPCWSTR pPinName
);
No return value.
Verifies conditions for continuing with a streaming operation.
virtual HRESULT CheckStreaming( );
Returns one of the following HRESULT values, depending on the state.
Value | Meaning |
S_FALSE | Currently in flushing state. |
S_OK | Receive or EndOfStream operations can safely proceed. |
VFW_E_RUNTIME_ERROR | Run-time error occurred while processing a previous sample. |
VFW_E_WRONG_STATE | Filter is in the State_Stopped state. |
Conditions checked in this member function include whether the filter is connected, if it is in an active state, if it is not currently flushing data, and if it has not just issued a run-time error. If all these conditions pass, it returns S_OK.
You can override this member function to add restrictions defined by your derived class. The overriding member function should call this base class implementation to check for conditions here as well.
This function member should be called from any override of the CBaseInputPin::Receive or CBasePin::EndOfStream member function (or they should do some equivalent check).
Releases the stored allocator.
HRESULT Disconnect( );
Returns an HRESULT value.
This member function overrides the CBasePin::Disconnect member function. It calls CBasePin::Disconnect first, and then releases the allocator held by m_pAllocator.
Informs the pin to end a flush operation and notifies the pin that it can start accepting data again.
HRESULT EndFlush(void);
Returns an HRESULT value.
This member function implements the IPin::EndFlush method. When this method is called, the pin is beginning to end a flush operation. Your derived class must override this member function, but should call this member function at the end of your implementation to clear m_bFlushing so that IMemInputPin::Receive calls will succeed.
Before calling this base class implementation, your overriding member function should perform the following steps.
IPin::EndFlush is not logically part of the media stream. It can be optimized in the sense that if a pin has passed no data downstream before this method is called, there is no need to pass this notification on.
An example of an overriding implementation of this member function can be found in the CTransformInputPin::EndFlush member function, which uses the CBaseOutputPin::DeliverEndFlush member function to perform the last step.
Retrieves the allocator interface that this input pin identifies as the interface for the output pin to use.
HRESULT GetAllocator(
IMemAllocator ** ppAllocator
);
Default implementation returns either E_OUTOFMEMORY, if an allocator cannot be created, or NOERROR upon success.
This member function implements the IMemInputPin::GetAllocator method, which is called by the connected output pin to retrieve an allocator to use for transporting media samples. By default, this member function creates a CMemAllocator object and obtains the IMemAllocator interface, to which it adds a reference count for the pin when assigning it to the m_pAllocator data member, and adds another reference count before passing it back to the output pin.
Override this member function if your filter has another allocator, such as one from a downstream pin, or a specialized allocator to offer the connected output pin.
Optional member function to use if the filter has specific alignment or prefix requirements but could use an upstream allocator.
HRESULT GetAllocatorRequirements(
ALLOCATOR_PROPERTIES * pProps
);
Returns an HRESULT value. Returns E_NOTIMPL by default.
Override this member function if you have specific alignment or prefix requirements but could use an upstream allocator.
Releases the allocator's memory.
HRESULT Inactive(void);
Returns an HRESULT value.
This member function is called through IMediaFilter, which is responsible for locking the object first.
Checks the m_bFlushing data member and returns its value.
BOOL IsFlushing(void);
Returns TRUE if the input pin is flushing data; otherwise, returns FALSE.
Checks the m_bReadOnly data member and returns its value.
BOOL IsReadOnly(void);
Returns TRUE if the allocator has read-only samples; otherwise, returns FALSE.
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 IMemInputPin and IUnknown interfaces. Override this class to return other interfaces on the object in the derived class.
Notifies the recipient that a quality change is requested.
HRESULT Notify(
IBaseFilter * pSelf,
Quality q
);
Returns NOERROR by default.
The IQualityControl::Notify method is usually implemented on the output pin, because quality-control messages are passed upstream, and not on the input pin.
Notifies the input pin as to which allocator the output pin is actually going to use.
HRESULT NotifyAllocator(
IMemAllocator * pAllocator,
BOOL bReadOnly
);
Default implementation returns NOERROR.
This member function implements the IMemInputPin::NotifyAllocator method, which is called by the connected output pin to inform the input pin of the chosen allocator for the memory transport. Override this member function if your filter cares about this information. By default, this sets the m_pAllocator data member to the allocator interface passed in after adding a reference count to that interface.
Retrieves the next block of data from the stream.
HRESULT Receive(
IMediaSample * pSample
);
Returns an HRESULT value.
This member function implements the IMemInputPin::Receive method. It first checks that it can process the sample by calling CBaseInputPin::CheckStreaming; if that member function does not return S_OK, Receive returns immediately with the value returned by CBaseInputPin::CheckStreaming.
This base class member function checks to see if the format has changed with this media sample; if so, it checks that the filter will accept it, generating a run-time error if not. If a run-time error is raised, the m_bRunTimeError data member is set so that no more samples will be accepted.
The overriding member function does something with the passed-in sample, such as calling a member function to transform it or pass it downstream.
This is a blocking synchronous call. Typically no blocking occurs, but if a filter cannot process the sample immediately, it can use the calling application's thread to wait until it can.
Call the IUnknown::AddRef method if you must hold the returned data block beyond the completion of the IMemInputPin::Receive method. If you call AddRef, be sure to call IUnknown::Release when done with it.
Determines if the implementation of the IMemInputPin::Receive method might block on the connected output pin.
HRESULT ReceiveCanBlock(void);
Returns an HRESULT value, which can include one of the following values.
Value | Meaning |
S_FALSE | Input pin will not block on a Receive method. |
S_OK | Input pin might block on a Receive method. |
This member function implements the IMemInputPin::ReceiveCanBlock method. The base class implementation calls the IMemInputPin::ReceiveCanBlock method on the input pin connected to each of the filter's output pins.
This member function is useful because an output pin from a filter might require notification if its thread might be blocked when it calls the Receive method on the connected input pin. For example, a source filter might prefer to keep reading and buffering data rather than be blocked, and might choose to start another thread to wait on the blocking Receive method. See the COutputQueue base class for queuing samples to input pins that potentially block.
Retrieves the next block of data from the stream. This method behaves much like the IMemInputPin::Receive method, but it works with multiple samples. Override this function if you can usefully process samples in batches.
HRESULT ReceiveMultiple(
IMediaSample ** pSamples,
long nSamples,
long * nSamplesProcessed
);
Returns an HRESULT value.
This member function implements the IMemInputPin::ReceiveMultiple method. It is implemented to call the CBaseInputPin::Receive member function in a loop for nSamples number of iterations.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.