// // 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 CParserFilter::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; }
static HRESULT ConnectFilters(IGraphBuilder *graph, IBaseFilter *lhs, IBaseFilter *rhs) { HRESULT hr = S_OK; IPin *out = 0; IPin *in = 0; hr = GetPin(lhs, PINDIR_OUTPUT, &out); if (FAILED(hr)) return hr; hr = GetPin(rhs, PINDIR_INPUT, &in); if (FAILED(hr)) { out->Release(); return hr; } hr = graph->Connect(out, in); in->Release(); out->Release(); return hr; }
//----------------------------------------------------------------------------- // ConnectFilters // Connects two filters by finding a pin on the upstream filter with the specified // major format type, e.g. For connecting an audio pin to a downstream filter HRESULT CDSUtils::ConnectFilters(IGraphBuilder* pGraph, IBaseFilter* pUpstream, IBaseFilter* pDownstream, const GUID* pFormat) { HRESULT hr = S_OK; if (pUpstream && pDownstream && pFormat) { // find the upstream output pin with the specified format CComPtr<IPin> pIPinOutput = NULL; hr = GetPin(pUpstream, pFormat, PINDIR_OUTPUT, &pIPinOutput); if (SUCCEEDED(hr)) { // get the downstream input pin CComPtr<IPin> pIPinInput = NULL; hr = GetPin(pDownstream, pFormat, PINDIR_INPUT, &pIPinInput); if (SUCCEEDED(hr)) { // connect the pins hr = pGraph->Connect(pIPinOutput, pIPinInput); } } } else { hr = E_INVALIDARG; } return hr; }
void bmp (void) { uprintf("Command Excepted\r"); switch (ExtractNum(3)) { case 0:itoa(GetPin('B',4),dumb,10);break; case 1:itoa(GetPin('B',5),dumb,10);break; } uprintf(dumb); uprintf("\r"); }
STDMETHODIMP CDynamicSource::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName) { CAutoLock lock(&m_cStateLock); HRESULT hr; int nCurrentPin; CDynamicSourceStream* pOutputPin; // The filter is joining the filter graph. if(NULL != pGraph) { IGraphConfig* pGraphConfig = NULL; hr = pGraph->QueryInterface(IID_IGraphConfig, (void**)&pGraphConfig); if(FAILED(hr)) { return hr; } hr = CBaseFilter::JoinFilterGraph(pGraph, pName); if(FAILED(hr)) { pGraphConfig->Release(); return hr; } for(nCurrentPin = 0; nCurrentPin < GetPinCount(); nCurrentPin++) { pOutputPin = (CDynamicSourceStream*) GetPin(nCurrentPin); pOutputPin->SetConfigInfo(pGraphConfig, m_evFilterStoppingEvent); } pGraphConfig->Release(); } else { hr = CBaseFilter::JoinFilterGraph(pGraph, pName); if(FAILED(hr)) { return hr; } for(nCurrentPin = 0; nCurrentPin < GetPinCount(); nCurrentPin++) { pOutputPin = (CDynamicSourceStream*)GetPin(nCurrentPin); pOutputPin->SetConfigInfo(NULL, NULL); } } return S_OK; }
STDMETHODIMP CDynamicSource::Stop(void) { m_evFilterStoppingEvent.Set(); HRESULT hr = CBaseFilter::Stop(); // The following code ensures that a pins thread will be destroyed even // if the pin is disconnected when CBaseFilter::Stop() is called. int nCurrentPin; CDynamicSourceStream* pOutputPin; { // This code holds the pin state lock because it // does not want the number of pins to change // while it executes. CAutoLock alPinStateLock(&m_csPinStateLock); for(nCurrentPin = 0; nCurrentPin < GetPinCount(); nCurrentPin++) { pOutputPin = (CDynamicSourceStream*)GetPin(nCurrentPin); if(pOutputPin->ThreadExists()) { pOutputPin->DestroySourceThread(); } } } if(FAILED(hr)) { return hr; } return NOERROR; }
STDMETHODIMP BaseFilter::FindPin(LPCWSTR aId, IPin** aPin) { if (!aPin) return E_POINTER; *aPin = NULL; CriticalSectionAutoEnter monitor(mLock); int numPins = GetPinCount(); for (int i = 0; i < numPins; i++) { BasePin* pin = GetPin(i); if (NULL == pin) { assert(pin != NULL); return VFW_E_NOT_FOUND; } if (!pin->Name().compare(aId)) { // Found a pin with a matching name, AddRef() and return it. *aPin = pin; NS_IF_ADDREF(pin); return S_OK; } } return VFW_E_NOT_FOUND; }
// Moves the filter into the paused state. If the graph is stopped, notify all // the connected pins that they're active. STDMETHODIMP BaseFilter::Pause() { CriticalSectionAutoEnter monitor(mLock); if (mState == State_Stopped) { int numPins = GetPinCount(); for (int i = 0; i < numPins; i++) { BasePin* pin = GetPin(i); if (NULL == pin) { break; } if (pin->IsConnected()) { HRESULT hr = pin->Active(); if (FAILED(hr)) { return hr; } } } } mState = State_Paused; return S_OK; }
// Stop deactivates any active, connected pins on this filter. STDMETHODIMP BaseFilter::Stop() { CriticalSectionAutoEnter monitor(mLock); HRESULT retval = S_OK; if (mState == State_Stopped) return S_OK; int numPins = GetPinCount(); for (int i = 0; i < numPins; i++) { BasePin* pin = GetPin(i); if (NULL == pin) { continue; } if (pin->IsConnected()) { HRESULT hr = pin->Inactive(); if (FAILED(hr) && SUCCEEDED(retval)) { retval = hr; } } } mState = State_Stopped; return retval; }
static HRESULT ConnectTwoFilters(IGraphBuilder *pGraph, IBaseFilter *pFirst, IBaseFilter *pSecond) { IPin *pOut = NULL, *pIn = NULL; HRESULT hr = GetPin(pFirst, PINDIR_OUTPUT, &pOut); if (FAILED(hr)) return hr; hr = GetPin(pSecond, PINDIR_INPUT, &pIn); if (FAILED(hr)) { pOut->Release(); return E_FAIL; } hr = pGraph->Connect(pOut, pIn); pIn->Release(); pOut->Release(); return hr; }
HRESULT STDMETHODCALLTYPE XnVideoSource::SetMode( IPin *pPin, long Mode ) { XN_METHOD_START; XN_METHOD_CHECK_POINTER(pPin); HRESULT hr = S_OK; // we have only 1 pin, make sure this is it XnVideoStream* pVideoStream = dynamic_cast<XnVideoStream*>(GetPin(0)); if (pPin != static_cast<IPin*>(pVideoStream)) { XN_METHOD_RETURN(E_FAIL); } xnLogVerbose(XN_MASK_FILTER, "Setting flip mode to %d", Mode); hr = pVideoStream->SetMirror(Mode & VideoControlFlag_FlipHorizontal); if (FAILED(hr)) XN_METHOD_RETURN(hr); hr = pVideoStream->SetVerticalFlip(Mode & VideoControlFlag_FlipVertical); if (FAILED(hr)) XN_METHOD_RETURN(hr); XN_METHOD_RETURN(S_OK); }
//----------------------------------------------------------------------------- // FindPinInterface // Attempt to locate the interface on the pin with the specified format or on the first pin if no // format is provided. HRESULT CDSUtils::FindPinInterface(IBaseFilter* pFilter, const GUID* pFormat, PIN_DIRECTION PinDir, const IID& riid, void** ppvInterface) { HRESULT hr = S_OK; if (pFilter && ppvInterface) { CComPtr<IPin> pIPin = NULL; if (pFormat) { hr = GetPin(pFilter, pFormat, PinDir, &pIPin); } else { CComPtr<IEnumPins> pIEnumPins = NULL; hr = pFilter->EnumPins(&pIEnumPins); if (SUCCEEDED(hr)) { hr = pIEnumPins->Next(1, &pIPin, NULL); } } if (SUCCEEDED(hr)) { hr = pIPin->QueryInterface(riid, ppvInterface); } } else { hr = E_INVALIDARG; } return hr; }
// Function name : CVMR9Graph::RenderGraph // Description : render the graph // Return type : BOOL BOOL CVMR9Graph::RenderGraph() { HRESULT hr; if (m_pFilterGraph2 == NULL) { ReportError("Could not render the graph because it is not fully constructed", E_FAIL); return FALSE; } for (int i=0; i<10; i++) { IBaseFilter* pBaseFilter = m_srcFilterArray[i]; if (pBaseFilter != NULL) { IPin* pPin; while ((pPin = GetPin(pBaseFilter, PINDIR_OUTPUT)) != NULL) { hr = m_pFilterGraph2->RenderEx(pPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL); if (FAILED(hr)) { ReportError("Unable to render the pin", hr); return FALSE; } } } } return TRUE; }
HRESULT CAnalyzerWriterFilter::GetMediaPositionInterface(REFIID riid, __deref_out void **ppv) { CAutoLock cObjectCreationLock(&m_ObjectCreationLock); if (m_pPosition) { return m_pPosition->NonDelegatingQueryInterface(riid,ppv); } CBasePin *pPin = GetPin(0); if (NULL == pPin) { return E_OUTOFMEMORY; } HRESULT hr = NOERROR; // Create implementation of this dynamically since sometimes we may // never try and do a seek. The helper object implements a position // control interface (IMediaPosition) which in fact simply takes the // calls normally from the filter graph and passes them upstream m_pPosition = new CAnalyzerPosPassThru(NAME("Renderer CPosPassThru"), CBaseFilter::GetOwner(), (HRESULT *) &hr, pPin, m_analyzer); if (m_pPosition == NULL) { return E_OUTOFMEMORY; } if (FAILED(hr)) { delete m_pPosition; m_pPosition = NULL; return E_NOINTERFACE; } return GetMediaPositionInterface(riid,ppv); }
CTextOutFilter::CTextOutFilter(LPUNKNOWN pUnk,HRESULT *phr) : CBaseRenderer(CLSID_TextRender, NAME("Text Display Filter\0"), pUnk, phr), m_TextWindow(NAME("Text properties\0"),GetOwner(),phr,&m_InterfaceLock,this) { m_TextWindow.SetControlWindowPin( GetPin(0) ); } // (Constructor)
//----------------------------------------------------------------------------- // RenderFilter // Renders the named output pin of the filter, or the first unconnected output if // no name is provided HRESULT CDSUtils::RenderFilter(IGraphBuilder* pGraph, IBaseFilter* pUpstream, wchar_t* pUpstreamPinName) { HRESULT hr = S_OK; if (pUpstream) { CComPtr<IPin> pIPinOutput = NULL; if (pUpstreamPinName) { hr = GetPin(pUpstream, pUpstreamPinName, &pIPinOutput); } else { hr = GetUnconnectedPin(pUpstream, PINDIR_OUTPUT, &pIPinOutput); } if (SUCCEEDED(hr)) { hr = pGraph->Render(pIPinOutput); } } else { hr = E_INVALIDARG; } return hr; }
bool ChannelPinMapper::TogglePin(int pinIdx, int chIdx) { bool on = GetPin(pinIdx, chIdx); on = !on; SetPin(pinIdx, chIdx, on); return on; }
void OggDemuxFilter::notifyPinConnected() { LOG(logDEBUG) << __FUNCTIONW__; if (!m_streamMapper->allStreamsReady()) { return; } if (m_seekTable) { return; } m_seekTable = new CustomOggChainGranuleSeekTable(); int outputPinCount = GetPinCount(); for (int i = 1; i < outputPinCount; i++) { OggDemuxOutputPin* pin = static_cast<OggDemuxOutputPin*>(GetPin(i)); LOG(logDEBUG) << L"Adding decoder interface to seek table, serial no: " << pin->getSerialNo(); m_seekTable->addStream(pin->getSerialNo(), pin->getDecoderInterface()); } #ifndef WINCE LOG(logDEBUG) << __FUNCTIONW__ << L" Building seek table..."; CComPtr<IAsyncReader> reader = m_inputPin.GetReader(); static_cast<CustomOggChainGranuleSeekTable*>(m_seekTable)->buildTable(reader); LOG(logDEBUG) << __FUNCTIONW__ << L" Built."; #endif }
CDXFilter::CDXFilter( IUnknown * pOuter, HRESULT * phr, BOOL ModifiesData ) : CTransInPlaceFilter( TEXT("DXFilter"), (IUnknown*) pOuter, CLSID_DXFilter, phr #if !defined(_WIN32_WCE) ,(BOOL)ModifiesData #endif ) , m_callback( NULL ) { // this is used to override the input pin with our own m_pInput = (CTransInPlaceInputPin*) new CDXFilterInPin( this, phr ); if( !m_pInput ) { if (phr) *phr = E_OUTOFMEMORY; } // Ensure that the output pin gets created. This is necessary because our // SetDeliveryBuffer() method assumes that the input/output pins are created, but // the output pin isn't created until GetPin() is called. The // CTransInPlaceFilter::GetPin() method will create the output pin, since we // have not already created one. IPin *pOutput = GetPin(1); // The pointer is not AddRef'ed by GetPin(), so don't release it }
HRESULT STDMETHODCALLTYPE XnVideoSource::GetMaxAvailableFrameRate( IPin *pPin, long iIndex, SIZE Dimensions, __out LONGLONG *MaxAvailableFrameRate ) { XN_METHOD_START; XN_METHOD_CHECK_POINTER(pPin); XN_METHOD_CHECK_POINTER(MaxAvailableFrameRate); HRESULT hr = S_OK; // we have only 1 pin, make sure this is it XnVideoStream* pVideoStream = dynamic_cast<XnVideoStream*>(GetPin(0)); if (pPin != static_cast<IPin*>(pVideoStream)) { XN_METHOD_RETURN(E_FAIL); } AM_MEDIA_TYPE* pMediaType; VIDEO_STREAM_CONFIG_CAPS vscc; hr = pVideoStream->GetStreamCaps(iIndex, &pMediaType, (BYTE*)&vscc); if (FAILED(hr)) XN_METHOD_RETURN(hr); CoTaskMemFree(pMediaType); if (Dimensions.cx != vscc.MaxOutputSize.cx || Dimensions.cy != vscc.MaxOutputSize.cy) XN_METHOD_RETURN(E_FAIL); *MaxAvailableFrameRate = vscc.MaxFrameInterval; XN_METHOD_RETURN(S_OK); }
HRESULT STDMETHODCALLTYPE XnVideoSource::GetMode( IPin *pPin, __out long *Mode ) { XN_METHOD_START; XN_METHOD_CHECK_POINTER(pPin); XN_METHOD_CHECK_POINTER(Mode); HRESULT hr = S_OK; // we have only 1 pin, make sure this is it XnVideoStream* pVideoStream = dynamic_cast<XnVideoStream*>(GetPin(0)); if (pPin != static_cast<IPin*>(pVideoStream)) { XN_METHOD_RETURN(E_FAIL); } *Mode = 0; if (pVideoStream->GetMirror()) *Mode |= VideoControlFlag_FlipHorizontal; if (pVideoStream->GetVerticalFlip()) *Mode |= VideoControlFlag_FlipVertical; XN_METHOD_RETURN(S_OK); }
void PinView::Update () { PinGraphic* pin = GetPin(); Graphic* pingr = pin; IncurDamage(pin); *pingr = *GetPinComp()->GetGraphic(); IncurDamage(pin); EraseHandles(); }
//----------------------------------------------------------------------------- // ConnectFiltersNamedPin // Connects two filters using the pin names, if no name is supplied the first // unconnected pin is used HRESULT CDSUtils::ConnectFilters(IGraphBuilder* pGraph, IBaseFilter* pUpstream, wchar_t* pUpstreamPinName, IBaseFilter* pDownstream, wchar_t* pDownstreamPinName) { HRESULT hr = S_OK; if (pUpstream && pDownstream) { // get the upstream output pin CComPtr<IPin> pIPinOutput = NULL; if (pUpstreamPinName) { hr = GetPin(pUpstream, pUpstreamPinName, &pIPinOutput); } else { hr = GetUnconnectedPin(pUpstream, PINDIR_OUTPUT, &pIPinOutput); } if (SUCCEEDED(hr)) { // get the downstream input pin CComPtr<IPin> pIPinInput = NULL; if (pDownstreamPinName) { hr = GetPin(pDownstream, pDownstreamPinName, &pIPinInput); } else { hr = GetUnconnectedPin(pDownstream, PINDIR_INPUT, &pIPinInput); } if (SUCCEEDED(hr)) { // connect the pins hr = pGraph->Connect(pIPinOutput, pIPinInput); } } } else { hr = E_INVALIDARG; } return hr; }
// Handler to respond to pin interrupts static void EncoderHandler(void *data) { tEncoder *enc = data; // Determine actual value of pins // and normalize inputs for lookup in a table int input = (GetPin(enc->pinA) ? 0x1 : 0x0) | (GetPin(enc->pinB) ? 0x2 : 0x0); // Add the value in the FSM to the current tick count // (or substract if invert is set) if (enc->invert) { enc->ticks -= enc->decoder->value[input]; } else { enc->ticks += enc->decoder->value[input]; } // Setup the next state of the mealy machine enc->decoder = &DecoderFSM[input]; }
void CCaptureDevice::SetCaptureBufferSize(void) { IPin * pCapturePin = GetPin(); if (pCapturePin) { DWORD dwBytesPerSec = 0; AM_MEDIA_TYPE * pmt = {0}; IAMStreamConfig * pCfg = NULL; HRESULT hr = pCapturePin->QueryInterface(IID_IAMStreamConfig, (void **)&pCfg); if ( hr==S_OK ) { hr = pCfg->GetFormat(&pmt); if ( hr==S_OK ) { WAVEFORMATEX *pWF = (WAVEFORMATEX *) pmt->pbFormat; dwBytesPerSec = pWF->nAvgBytesPerSec; pWF->nChannels = 1; pWF->wBitsPerSample = 8; pWF->nSamplesPerSec = 11025; pWF->nAvgBytesPerSec = pWF->nSamplesPerSec * pWF->nChannels * pWF->wBitsPerSample / 8; pWF->nBlockAlign = 1; /* info.cbSize = sizeof(WAVEFORMATEX); info.wFormatTag = 1; info.nChannels = 2; info.nSamplesPerSec = 44100; //info.nSamplesPerSec = 22050; 11025 info.wBitsPerSample = 16; info.nAvgBytesPerSec = info.nSamplesPerSec * info.nChannels * info.wBitsPerSample / 8; info.nBlockAlign = 4; */ pCfg->SetFormat( pmt ); DeleteMediaType(pmt); } pCfg->Release(); } /* if (dwBytesPerSec) { IAMBufferNegotiation * pNeg = NULL; hr = pCapturePin->QueryInterface(IID_IAMBufferNegotiation, (void **)&pNeg); if (SUCCEEDED(hr)) { ALLOCATOR_PROPERTIES AllocProp; AllocProp.cbAlign = -1; // -1 means no preference. AllocProp.cbBuffer = dwBytesPerSec * dwLatencyInMilliseconds / 1000; AllocProp.cbPrefix = -1; AllocProp.cBuffers = -1; hr = pNeg->SuggestAllocatorProperties(&AllocProp); pNeg->Release(); } }*/ } }
VideoCapture::VideoCapture(HWND hWnd) { CoInitialize(NULL); // HRESULT hr; InitVideoFilters(); IPin *pPin = GetPin(m_pBaseFilter, PINDIR_OUTPUT); ShowFilterProperty(pPin); StartRender(hWnd); }
HRESULT CMPEGFilter::GetMediaPositionInterface(REFIID riid, void **ppv) { CAutoLock cObjectCreationLock(&m_ObjectCreationLock); if (m_pPosition) { return m_pPosition->NonDelegatingQueryInterface(riid,ppv); } HRESULT hr = NOERROR; // Create implementation of this dynamically since sometimes we may // never try and do a seek. The helper object implements a position // control interface (IMediaPosition) which in fact simply takes the // calls normally from the filter graph and passes them upstream /* m_pPosition = new CRendererPosPassThru(NAME("Renderer CPosPassThru"), CBaseFilter::GetOwner(), (HRESULT *) &hr, GetPin(0));*/ m_pPosition = new CMPEGSeeking(NAME("Renderer CPosPassThru"), CBaseFilter::GetOwner(), (HRESULT *) &hr, GetPin(0), GetPin(1), m_pMPEGObj); if (m_pPosition == NULL) { return E_OUTOFMEMORY; } if (FAILED(hr)) { delete m_pPosition; m_pPosition = NULL; return E_NOINTERFACE; } m_pPosition->AddRef(); *ppv = m_pPosition; return S_OK; }
void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment ) { wxCHECK_RET( (aSegment) && (aSegment->Type() == SCH_LINE_T), wxT( "Invalid object pointer." ) ); for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( item->GetFlags() & CANDIDATE ) continue; if( item->Type() == SCH_JUNCTION_T ) { SCH_JUNCTION* junction = (SCH_JUNCTION*) item; if( aSegment->IsEndPoint( junction->GetPosition() ) ) item->SetFlags( CANDIDATE ); continue; } if( item->Type() != SCH_LINE_T ) continue; SCH_LINE* segment = (SCH_LINE*) item; if( aSegment->IsEndPoint( segment->GetStartPoint() ) && !GetPin( segment->GetStartPoint(), NULL, true ) ) { item->SetFlags( CANDIDATE ); MarkConnections( segment ); } if( aSegment->IsEndPoint( segment->GetEndPoint() ) && !GetPin( segment->GetEndPoint(), NULL, true ) ) { item->SetFlags( CANDIDATE ); MarkConnections( segment ); } } }
// // If the format changes, we need to reconnect // void CSynthFilter::ReconnectWithNewFormat(void) { // The caller must hold the state lock because this // function calls IsConnected(). ASSERT(CritCheckIn(pStateLock())); // The synth filter's only has one pin. The pin is an output pin. CDynamicSourceStream* pOutputPin = (CDynamicSourceStream*)GetPin(0); if( pOutputPin->IsConnected() ) { pOutputPin->OutputPinNeedsToBeReconnected(); } }
//---------------------------------------------------------------------------- //! @brief 現在接続されているピンの数を取得する //! @return 接続数 //---------------------------------------------------------------------------- ULONG CDemuxSource::GetNumberOfConnection() { ULONG result = 0; int cPins = GetPinCount(); for( int c = 0; c < cPins; c++ ) { CBaseOutputPin *pPin = reinterpret_cast<CBaseOutputPin*>(GetPin(c)); if( pPin->IsConnected() ) { ++result; } } return result; }