home *** CD-ROM | disk | FTP | other *** search
- //==========================================================================;
- //
- // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
- // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
- // PURPOSE.
- //
- // Copyright (c) 1992 - 1996 Microsoft Corporation. All Rights Reserved.
- //
- //--------------------------------------------------------------------------;
-
- // Base class for simple transform filters such as video decompressors
-
- #include <streams.h>
- #include <measure.h>
-
-
- // =================================================================
- // Implements the CTransformFilter class
- // =================================================================
-
- CTransformFilter::CTransformFilter(TCHAR *pName,
- LPUNKNOWN pUnk,
- CLSID clsid,
- HRESULT *phr) :
- CBaseFilter(pName,pUnk,&m_csFilter, clsid,phr),
- m_pInput(NULL),
- m_pOutput(NULL),
- m_bEOSDelivered(FALSE),
- m_bQualityChanged(FALSE),
- m_bSampleSkipped(FALSE)
- {
- ASSERT(phr);
- #ifdef PERF
- RegisterPerfId();
- #endif // PERF
- }
-
-
- // destructor
-
- CTransformFilter::~CTransformFilter()
- {
- // Delete the pins
-
- if (m_pInput) {
- delete m_pInput;
- m_pInput = NULL;
- }
-
- if (m_pOutput) {
- delete m_pOutput;
- m_pOutput = NULL;
- }
- }
-
-
- // Transform place holder - should never be called
- HRESULT CTransformFilter::Transform(IMediaSample * pIn, IMediaSample *pOut)
- {
- UNREFERENCED_PARAMETER(pIn);
- UNREFERENCED_PARAMETER(pOut);
- DbgBreak("CTransformFilter::Transform() should never be called");
- return E_UNEXPECTED;
- }
-
-
- // return the number of pins we provide
-
- int CTransformFilter::GetPinCount()
- {
- return 2;
- }
-
-
- // return a non-addrefed CBasePin * for the user to addref if he holds onto it
- // for longer than his pointer to us. We create the pins dynamically when they
- // are asked for rather than in the constructor. This is because we want to
- // give the derived class an oppportunity to return different pin objects
-
- // We return the objects as and when they are needed. If either of these fails
- // then we return NULL, the assumption being that the caller will realise the
- // whole deal is off and destroy us - which in turn will delete everything.
-
- CBasePin *
- CTransformFilter::GetPin(int n)
- {
- HRESULT hr = S_OK;
-
- // Create an input pin if necessary
-
- if (n == 0 && m_pInput == NULL) {
-
- m_pInput = new CTransformInputPin(NAME("Transform input pin"),
- this, // Owner filter
- &hr, // Result code
- L"XForm In"); // Pin name
-
- // a failed return code should delete the object
-
- if (FAILED(hr) || m_pInput == NULL) {
- delete m_pInput;
- m_pInput = NULL;
- }
- }
-
- // Or alternatively create an output pin
-
- if (n == 1 && m_pOutput == NULL) {
-
- m_pOutput = (CTransformOutputPin *)
- new CTransformOutputPin(NAME("Transform output pin"),
- this, // Owner filter
- &hr, // Result code
- L"XForm Out"); // Pin name
-
- // a failed return code should delete the object
-
- if (FAILED(hr) || m_pOutput == NULL) {
- delete m_pOutput;
- m_pOutput = NULL;
- }
- }
-
- // Return the appropriate pin
-
- if (n == 0) {
- return m_pInput;
- }
- return m_pOutput;
- }
-
-
- //
- // FindPin
- //
- // If Id is In or Out then return the IPin* for that pin
- // creating the pin if need be. Otherwise return NULL with an error.
-
- STDMETHODIMP CTransformFilter::FindPin(LPCWSTR Id, IPin **ppPin)
- {
- CheckPointer(ppPin,E_POINTER);
- ValidateReadWritePtr(ppPin,sizeof(IPin *));
-
- if (0==lstrcmpW(Id,L"In")) {
- *ppPin = GetPin(0);
- } else if (0==lstrcmpW(Id,L"Out")) {
- *ppPin = GetPin(1);
- } else {
- *ppPin = NULL;
- return VFW_E_NOT_FOUND;
- }
-
- HRESULT hr = NOERROR;
- // AddRef() returned pointer - but GetPin could fail if memory is low.
- if (*ppPin) {
- (*ppPin)->AddRef();
- } else {
- hr = E_OUTOFMEMORY; // probably. There's no pin anyway.
- }
- return hr;
- }
-
-
- // override these two functions if you want to inform something
- // about entry to or exit from streaming state.
-
- HRESULT
- CTransformFilter::StartStreaming()
- {
- return NOERROR;
- }
-
-
- HRESULT
- CTransformFilter::StopStreaming()
- {
- return NOERROR;
- }
-
-
- // override this to grab extra interfaces on connection
-
- HRESULT
- CTransformFilter::CheckConnect(PIN_DIRECTION dir,IPin *pPin)
- {
- UNREFERENCED_PARAMETER(dir);
- UNREFERENCED_PARAMETER(pPin);
- return NOERROR;
- }
-
-
- // place holder to allow derived classes to release any extra interfaces
-
- HRESULT
- CTransformFilter::BreakConnect(PIN_DIRECTION dir)
- {
- UNREFERENCED_PARAMETER(dir);
- return NOERROR;
- }
-
-
- // Let derived classes know about connection completion
-
- HRESULT
- CTransformFilter::CompleteConnect(PIN_DIRECTION direction,IPin *pReceivePin)
- {
- UNREFERENCED_PARAMETER(direction);
- UNREFERENCED_PARAMETER(pReceivePin);
- return NOERROR;
- }
-
-
- // override this to know when the media type is really set
-
- HRESULT
- CTransformFilter::SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt)
- {
- UNREFERENCED_PARAMETER(direction);
- UNREFERENCED_PARAMETER(pmt);
- return NOERROR;
- }
-
-
- // override this to customize the transform process
-
- HRESULT
- CTransformFilter::Receive(IMediaSample *pSample)
- {
- HRESULT hr;
- ASSERT(pSample);
- IMediaSample * pOutSample;
-
- // If no output to deliver to then no point sending us data
-
- ASSERT (m_pOutput != NULL) ;
-
- // default - times are the same
-
- CRefTime tStart, tStop;
- REFERENCE_TIME * pStart = NULL;
- REFERENCE_TIME * pStop = NULL;
- if (NOERROR == pSample->GetTime((REFERENCE_TIME*)&tStart, (REFERENCE_TIME*)&tStop)) {
- pStart = (REFERENCE_TIME*)&tStart;
- pStop = (REFERENCE_TIME*)&tStop;
- }
-
- // this may block for an indeterminate amount of time
- hr = m_pOutput->GetDeliveryBuffer( &pOutSample
- , pStart
- , pStop
- , m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0
- );
- if (FAILED(hr)) {
- return hr;
- }
-
- ASSERT(pOutSample);
- pOutSample->SetTime(pStart, pStop);
- pOutSample->SetSyncPoint(pSample->IsSyncPoint() == S_OK);
- pOutSample->SetDiscontinuity(m_bSampleSkipped ||
- pSample->IsDiscontinuity() == S_OK);
- m_bSampleSkipped = FALSE;
-
- // Copy the media times
-
- LONGLONG MediaStart, MediaEnd;
- if (pSample->GetMediaTime(&MediaStart,&MediaEnd) == NOERROR) {
- pOutSample->SetMediaTime(&MediaStart,&MediaEnd);
- }
-
- // Start timing the transform (if PERF is defined)
- MSR_START(m_idTransform);
-
- // have the derived class transform the data
-
- hr = Transform(pSample, pOutSample);
-
- // Stop the clock and log it (if PERF is defined)
- MSR_STOP(m_idTransform);
-
- if (FAILED(hr)) {
- DbgLog((LOG_TRACE,1,TEXT("Error from transform")));
- } else {
- // the Transform() function can return S_FALSE to indicate that the
- // sample should not be delivered; we only deliver the sample if it's
- // really S_OK (same as NOERROR, of course.)
- if (hr == NOERROR) {
- hr = m_pOutput->Deliver(pOutSample);
- } else {
- // S_FALSE returned from Transform is a PRIVATE agreement
- // We should return NOERROR from Receive() in this cause because returning S_FALSE
- // from Receive() means that this is the end of the stream and no more data should
- // be sent.
- if (S_FALSE == hr) {
- m_bSampleSkipped = TRUE;
- if (!m_bQualityChanged) {
- NotifyEvent(EC_QUALITY_CHANGE,0,0);
- m_bQualityChanged = TRUE;
- }
- hr = NOERROR;
- }
- }
- }
-
- // release the output buffer. If the connected pin still needs it,
- // it will have addrefed it itself.
- pOutSample->Release();
-
- return hr;
- }
-
-
- // Return S_FALSE to mean "pass the note on upstream"
- // Return NOERROR (Same as S_OK)
- // to mean "I've done something about it, don't pass it on"
- HRESULT CTransformFilter::AlterQuality(Quality q)
- {
- UNREFERENCED_PARAMETER(q);
- return S_FALSE;
- }
-
-
- // EndOfStream received. Default behaviour is to deliver straight
- // downstream, since we have no queued data. If you overrode Receive
- // and have queue data, then you need to handle this and deliver EOS after
- // all queued data is sent
- HRESULT
- CTransformFilter::EndOfStream(void)
- {
- HRESULT hr = NOERROR;
- if (m_pOutput != NULL) {
- hr = m_pOutput->DeliverEndOfStream();
- }
-
- return hr;
- }
-
-
- // enter flush state. Receives already blocked
- // must override this if you have queued data or a worker thread
- HRESULT
- CTransformFilter::BeginFlush(void)
- {
- HRESULT hr = NOERROR;
- if (m_pOutput != NULL) {
- // block receives -- done by caller (CBaseInputPin::BeginFlush)
-
- // discard queued data -- we have no queued data
-
- // free anyone blocked on receive - not possible in this filter
-
- // call downstream
- hr = m_pOutput->DeliverBeginFlush();
- }
- return hr;
- }
-
-
- // leave flush state. must override this if you have queued data
- // or a worker thread
- HRESULT
- CTransformFilter::EndFlush(void)
- {
- // sync with pushing thread -- we have no worker thread
-
- // ensure no more data to go downstream -- we have no queued data
-
- // call EndFlush on downstream pins
- ASSERT (m_pOutput != NULL);
- return m_pOutput->DeliverEndFlush();
-
- // caller (the input pin's method) will unblock Receives
- }
-
-
- // override these so that the derived filter can catch them
-
- STDMETHODIMP
- CTransformFilter::Stop()
- {
- CAutoLock lck1(&m_csFilter);
- if (m_State == State_Stopped) {
- return NOERROR;
- }
-
- // Succeed the Stop if we are not completely connected
-
- if (m_pInput == NULL || m_pInput->IsConnected() == FALSE ||
- m_pOutput == NULL || m_pOutput->IsConnected() == FALSE) {
- m_State = State_Stopped;
- m_bEOSDelivered = FALSE;
- return NOERROR;
- }
-
- ASSERT(m_pInput);
- ASSERT(m_pOutput);
-
- // decommit the input pin before locking or we can deadlock
- m_pInput->Inactive();
-
- // synchronize with Receive calls
-
- CAutoLock lck2(&m_csReceive);
- m_pOutput->Inactive();
-
- // allow a class derived from CTransformFilter
- // to know about starting and stopping streaming
-
- HRESULT hr = StopStreaming();
- if (SUCCEEDED(hr)) {
- // complete the state transition
- m_State = State_Stopped;
- m_bEOSDelivered = FALSE;
- }
- return hr;
- }
-
-
- STDMETHODIMP
- CTransformFilter::Pause()
- {
- CAutoLock lck(&m_csFilter);
- HRESULT hr = NOERROR;
-
- if (m_State == State_Paused) {
- // (This space left deliberately blank)
- }
-
- // If we have no input pin or it isn't yet connected then when we are
- // asked to pause we deliver an end of stream to the downstream filter.
- // This makes sure that it doesn't sit there forever waiting for
- // samples which we cannot ever deliver without an input connection.
-
- else if (m_pInput == NULL || m_pInput->IsConnected() == FALSE) {
- if (m_pOutput && m_bEOSDelivered == FALSE) {
- m_pOutput->DeliverEndOfStream();
- m_bEOSDelivered = TRUE;
- }
- m_State = State_Paused;
- }
-
- // We may have an input connection but no output connection
-
- else if (m_pOutput == NULL || m_pOutput->IsConnected() == FALSE) {
- m_State = State_Paused;
- }
-
- else {
- if (m_State == State_Stopped) {
- // allow a class derived from CTransformFilter
- // to know about starting and stopping streaming
- hr = StartStreaming();
- }
- if (SUCCEEDED(hr)) {
- hr = CBaseFilter::Pause();
- }
- }
-
- m_bSampleSkipped = FALSE;
- m_bQualityChanged = FALSE;
- return hr;
- }
-
- HRESULT
- CTransformFilter::NewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate)
- {
- if (m_pOutput != NULL) {
- return m_pOutput->DeliverNewSegment(tStart, tStop, dRate);
- }
- return S_OK;
- }
-
- // Check streaming status
- HRESULT
- CTransformInputPin::CheckStreaming()
- {
- if (m_pTransformFilter->m_pOutput == NULL) {
- return VFW_E_NOT_CONNECTED;
- }
- if (!m_pTransformFilter->m_pOutput->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- } else {
- return CBaseInputPin::CheckStreaming();
- }
- }
-
-
- // =================================================================
- // Implements the CTransformInputPin class
- // =================================================================
-
-
- // constructor
-
- CTransformInputPin::CTransformInputPin(
- TCHAR *pObjectName,
- CTransformFilter *pTransformFilter,
- HRESULT * phr,
- LPCWSTR pName)
- : CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName)
- {
- DbgLog((LOG_TRACE,2,TEXT("CTransformInputPin::CTransformInputPin")));
- m_pTransformFilter = pTransformFilter;
- }
-
-
- // provides derived filter a chance to grab extra interfaces
-
- HRESULT
- CTransformInputPin::CheckConnect(IPin *pPin)
- {
- HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_INPUT,pPin);
- if (FAILED(hr)) {
- return hr;
- }
- return CBaseInputPin::CheckConnect(pPin);
- }
-
-
- // provides derived filter a chance to release it's extra interfaces
-
- HRESULT
- CTransformInputPin::BreakConnect()
- {
- // Can't disconnect unless stopped
- ASSERT(IsStopped());
- m_pTransformFilter->BreakConnect(PINDIR_INPUT);
- return CBaseInputPin::BreakConnect();
- }
-
-
- // Let derived class know when the input pin is connected
-
- HRESULT
- CTransformInputPin::CompleteConnect(IPin *pReceivePin)
- {
- HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_INPUT,pReceivePin);
- if (FAILED(hr)) {
- return hr;
- }
- return CBaseInputPin::CompleteConnect(pReceivePin);
- }
-
-
- // check that we can support a given media type
-
- HRESULT
- CTransformInputPin::CheckMediaType(const CMediaType* pmt)
- {
- // Check the input type
-
- HRESULT hr = m_pTransformFilter->CheckInputType(pmt);
- if (S_OK != hr) {
- return hr;
- }
-
- // if the output pin is still connected, then we have
- // to check the transform not just the input format
-
- if ((m_pTransformFilter->m_pOutput != NULL) &&
- (m_pTransformFilter->m_pOutput->IsConnected())) {
- return m_pTransformFilter->CheckTransform(
- pmt,
- &m_pTransformFilter->m_pOutput->CurrentMediaType());
- } else {
- return hr;
- }
- }
-
-
- // set the media type for this connection
-
- HRESULT
- CTransformInputPin::SetMediaType(const CMediaType* mtIn)
- {
- // Set the base class media type (should always succeed)
- HRESULT hr = CBasePin::SetMediaType(mtIn);
- ASSERT(SUCCEEDED(hr));
-
- // check the transform can be done (should always succeed)
- ASSERT(SUCCEEDED(m_pTransformFilter->CheckInputType(mtIn)));
-
- m_pTransformFilter->SetMediaType(PINDIR_INPUT,mtIn);
- return NOERROR;
- }
-
-
- // =================================================================
- // Implements IMemInputPin interface
- // =================================================================
-
-
- // provide EndOfStream that passes straight downstream
- // (there is no queued data)
- STDMETHODIMP
- CTransformInputPin::EndOfStream(void)
- {
- CAutoLock lck(&m_pTransformFilter->m_csReceive);
- HRESULT hr = CheckStreaming();
- if (S_OK == hr) {
- hr = m_pTransformFilter->EndOfStream();
- }
- return hr;
- }
-
-
- // enter flushing state. Call default handler to block Receives, then
- // pass to overridable method in filter
- STDMETHODIMP
- CTransformInputPin::BeginFlush(void)
- {
- CAutoLock lck(m_pLock);
- // Are we actually doing anything?
- if (!IsConnected() ||
- m_pTransformFilter->m_pOutput == NULL ||
- !m_pTransformFilter->m_pOutput->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- }
- HRESULT hr = CBaseInputPin::BeginFlush();
- if (FAILED(hr)) {
- return hr;
- }
-
- return m_pTransformFilter->BeginFlush();
- }
-
-
- // leave flushing state.
- // Pass to overridable method in filter, then call base class
- // to unblock receives (finally)
- STDMETHODIMP
- CTransformInputPin::EndFlush(void)
- {
- CAutoLock lck(&m_pTransformFilter->m_csFilter);
- // Are we actually doing anything?
- if (!IsConnected() ||
- m_pTransformFilter->m_pOutput == NULL ||
- !m_pTransformFilter->m_pOutput->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- }
-
- HRESULT hr = m_pTransformFilter->EndFlush();
- if (FAILED(hr)) {
- return hr;
- }
-
- return CBaseInputPin::EndFlush();
- }
-
-
- // here's the next block of data from the stream.
- // AddRef it yourself if you need to hold it beyond the end
- // of this call.
-
- HRESULT
- CTransformInputPin::Receive(IMediaSample * pSample)
- {
- CAutoLock lck(&m_pTransformFilter->m_csReceive);
- ASSERT(pSample);
-
- HRESULT hr;
-
- // check all is well with the base class
- hr = CBaseInputPin::Receive(pSample);
- if (S_OK == hr) {
- hr = m_pTransformFilter->Receive(pSample);
- }
-
- return hr;
- }
-
-
- // Pass on the Quality notification q to
- // a. Our QualityControl sink (if we have one) or else
- // b. to our upstream filter
- // and if that doesn't work, throw it away with a bad return code
- HRESULT
- CTransformInputPin::PassNotify(Quality q)
- {
- // We pass the message on, which means that we find the quality sink
- // for our input pin and send it there
-
- DbgLog((LOG_TRACE,3,TEXT("Passing Quality notification through transform")));
- if (m_pQSink!=NULL) {
- return m_pQSink->Notify(m_pTransformFilter, q);
- } else {
- // no sink set, so pass it upstream
- HRESULT hr;
- IQualityControl * pIQC;
-
- hr = VFW_E_NOT_FOUND; // default
- if (m_Connected) {
- m_Connected->QueryInterface(IID_IQualityControl, (void**)&pIQC);
-
- if (pIQC!=NULL) {
- hr = pIQC->Notify(m_pTransformFilter, q);
- pIQC->Release();
- }
- }
- return hr;
- }
-
- } // PassNotify
-
-
- // override to pass downstream
- STDMETHODIMP
- CTransformInputPin::NewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate)
- {
- // Save the values in the pin
- CBasePin::NewSegment(tStart, tStop, dRate);
- return m_pTransformFilter->NewSegment(tStart, tStop, dRate);
- }
-
-
-
-
- // =================================================================
- // Implements the CTransformOutputPin class
- // =================================================================
-
-
- // constructor
-
- CTransformOutputPin::CTransformOutputPin(
- TCHAR *pObjectName,
- CTransformFilter *pTransformFilter,
- HRESULT * phr,
- LPCWSTR pPinName)
- : CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName),
- m_pPosition(NULL)
- {
- DbgLog((LOG_TRACE,2,TEXT("CTransformOutputPin::CTransformOutputPin")));
- m_pTransformFilter = pTransformFilter;
-
- }
-
-
- // destructor
-
- CTransformOutputPin::~CTransformOutputPin()
- {
- DbgLog((LOG_TRACE,2,TEXT("CTransformOutputPin::~CTransformOutputPin")));
-
- if (m_pPosition) {
- delete m_pPosition;
- }
- }
-
-
-
- // overriden to expose IMediaPosition and IMediaSelection control interfaces
-
- STDMETHODIMP
- CTransformOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
- {
- CheckPointer(ppv,E_POINTER);
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- *ppv = NULL;
-
- if (riid == IID_IMediaPosition || riid == IID_IMediaSelection) {
-
- // we should have an input pin by now
-
- if (m_pTransformFilter->m_pInput == NULL) {
- return E_UNEXPECTED;
- }
-
- if (m_pPosition == NULL) {
-
- HRESULT hr = S_OK;
- m_pPosition = new CPosPassThru(NAME("xform CPosPassThru"),
- GetOwner(),
- &hr,
- (IPin *)m_pTransformFilter->m_pInput);
- if (m_pPosition == NULL) {
- return E_OUTOFMEMORY;
- }
-
- if (FAILED(hr)) {
- delete m_pPosition;
- m_pPosition = NULL;
- return hr;
- }
- }
- return m_pPosition->NonDelegatingQueryInterface(riid, ppv);
- } else {
- return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
- }
- }
-
-
- // provides derived filter a chance to grab extra interfaces
-
- HRESULT
- CTransformOutputPin::CheckConnect(IPin *pPin)
- {
- // we should have an input connection first
-
- if ((m_pTransformFilter->m_pInput == NULL) ||
- (m_pTransformFilter->m_pInput->IsConnected() == FALSE)) {
- return E_UNEXPECTED;
- }
-
- HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_OUTPUT,pPin);
- if (FAILED(hr)) {
- return hr;
- }
- return CBaseOutputPin::CheckConnect(pPin);
- }
-
-
- // provides derived filter a chance to release it's extra interfaces
-
- HRESULT
- CTransformOutputPin::BreakConnect()
- {
- // Can't disconnect unless stopped
- ASSERT(IsStopped());
- m_pTransformFilter->BreakConnect(PINDIR_OUTPUT);
- return CBaseOutputPin::BreakConnect();
- }
-
-
- // Let derived class know when the output pin is connected
-
- HRESULT
- CTransformOutputPin::CompleteConnect(IPin *pReceivePin)
- {
- HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_OUTPUT,pReceivePin);
- if (FAILED(hr)) {
- return hr;
- }
- return CBaseOutputPin::CompleteConnect(pReceivePin);
- }
-
-
- // check a given transform - must have selected input type first
-
- HRESULT
- CTransformOutputPin::CheckMediaType(const CMediaType* pmtOut)
- {
- // must have selected input first
- if ((m_pTransformFilter->m_pInput == NULL) ||
- (m_pTransformFilter->m_pInput->IsConnected() == FALSE)) {
- return E_INVALIDARG;
- }
-
- return m_pTransformFilter->CheckTransform(
- &m_pTransformFilter->m_pInput->CurrentMediaType(),
- pmtOut);
- }
-
-
- // called after we have agreed a media type to actually set it in which case
- // we run the CheckTransform function to get the output format type again
-
- HRESULT
- CTransformOutputPin::SetMediaType(const CMediaType* pmtOut)
- {
- HRESULT hr = NOERROR;
- if (m_pTransformFilter->m_pInput==NULL) {
- return E_UNEXPECTED;
- }
- ASSERT(m_pTransformFilter->m_pInput->CurrentMediaType().IsValid());
-
- // Set the base class media type (should always succeed)
- hr = CBasePin::SetMediaType(pmtOut);
- ASSERT(SUCCEEDED(hr));
-
- // Check this transform can be done (should always succeed)
- ASSERT(SUCCEEDED(m_pTransformFilter->CheckTransform(
- &m_pTransformFilter->m_pInput->CurrentMediaType(),pmtOut)));
-
- m_pTransformFilter->SetMediaType(PINDIR_OUTPUT,pmtOut);
- return NOERROR;
- }
-
-
- // pass the buffer size decision through to the main transform class
-
- HRESULT
- CTransformOutputPin::DecideBufferSize(
- IMemAllocator * pAllocator,
- ALLOCATOR_PROPERTIES* pProp)
- {
- return m_pTransformFilter->DecideBufferSize(pAllocator, pProp);
- }
-
-
-
- // return a specific media type indexed by iPosition
-
- HRESULT
- CTransformOutputPin::GetMediaType(
- int iPosition,
- CMediaType *pMediaType)
- {
- CAutoLock lock(&m_pTransformFilter->m_csFilter);
- if (m_pTransformFilter->m_pInput == NULL) {
- return E_UNEXPECTED;
- }
-
- // We don't have any media types if our input is not connected
-
- if (m_pTransformFilter->m_pInput->IsConnected()) {
- return m_pTransformFilter->GetMediaType(iPosition,pMediaType);
- } else {
- return VFW_S_NO_MORE_ITEMS;
- }
- }
-
-
- // Override this if you can do something constructive to act on the
- // quality message. Consider passing it upstream as well
-
- // Pass the quality mesage on upstream.
-
- STDMETHODIMP
- CTransformOutputPin::Notify(IFilter * pSender, Quality q)
- {
- CheckPointer(pSender,E_POINTER);
- ValidateReadPtr(pSender,sizeof(IFilter));
-
- // First see if we want to handle this ourselves
- HRESULT hr = m_pTransformFilter->AlterQuality(q);
- if (hr!=S_FALSE) {
- return hr; // either S_OK or a failure
- }
-
- // S_FALSE means we pass the message on.
- // Find the quality sink for our input pin and send it there
-
- CAutoLock lock(&m_pTransformFilter->m_csFilter);
- if (m_pTransformFilter->m_pInput == NULL){
- return E_FAIL;
- }
-
- return m_pTransformFilter->m_pInput->PassNotify(q);
-
- } // Notify
-
-
- // the following removes a very large number of level 4 warnings from the microsoft
- // compiler output, which are not useful at all in this case.
- #pragma warning(disable:4514)
-