Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
// 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;
}
Ejemplo n.º 5
0
// 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;
}
Ejemplo n.º 6
0
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
}
Ejemplo n.º 7
0
CBasePin* CStreamSwitcherFilter::GetPin(int n)
{
	CAutoLock cAutoLock(&m_csPins);

	if(n < 0 || n >= GetPinCount()) return NULL;
	else if(n == 0) return m_pOutput;
	else return m_pInputs.GetAt(m_pInputs.FindIndex(n-1));
}
Ejemplo n.º 8
0
CBasePin *
CAsyncReader::GetPin(int n)
{
    if ((GetPinCount() > 0) && (n == 0)) {
    	return &m_OutputPin;
    } else {
    	return NULL;
    }
}
Ejemplo n.º 9
0
//----------------------------------------------------------------------------
//! @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;
}
Ejemplo n.º 10
0
//----------------------------------------------------------------------------
//! @brief	  	新たに再生が開始されたことをダウンストリームへ通知する
//! @param		tStart : 開始時間
//! @param		tStop : 停止時間
//! @param		dRate : 再生レート
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CDemuxSource::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
	int cPins = GetPinCount();
	for( int c = 0; c < cPins; c++ )
	{
		CBaseOutputPin *pPin = reinterpret_cast<CBaseOutputPin*>(GetPin(c));
		if( pPin->IsConnected() ) {
			HRESULT hr = pPin->DeliverNewSegment(tStart,tStop,dRate);
			if (FAILED(hr)) {
				return hr;
			}
		}
	}
	return S_OK;
}
Ejemplo n.º 11
0
//----------------------------------------------------------------------------
//! @brief	  	フラッシュ処理の開始をダウンストリームへ要求する
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CDemuxSource::DeliverBeginFlush(void)
{
	int cPins = GetPinCount();
	for( int c = 0; c < cPins; c++ )
	{
		CBaseOutputPin *pPin = reinterpret_cast<CBaseOutputPin*>(GetPin(c));
		if( pPin->IsConnected() ) {
			HRESULT hr = pPin->DeliverBeginFlush();
			if (FAILED(hr)) {
				return hr;
			}
		}
	}
	return S_OK;
}
Ejemplo n.º 12
0
STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) 
{
	if(GetPinCount() > 0)
		return VFW_E_ALREADY_CONNECTED;

	HRESULT hr = S_OK;
	if(!(new CFLICStream(pszFileName, this, &hr)))
		return E_OUTOFMEMORY;

	if(FAILED(hr))
		return hr;

	m_fn = pszFileName;

	return S_OK;
}
Ejemplo n.º 13
0
STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
	if (GetPinCount() > 0) {
		return VFW_E_ALREADY_CONNECTED;
	}

	HRESULT hr = S_OK;
	if (!(DNew CSubtitleStream(pszFileName, this, &hr))) {
		return E_OUTOFMEMORY;
	}

	if (FAILED(hr)) {
		return hr;
	}

	m_fn = pszFileName;

	return S_OK;
}
Ejemplo n.º 14
0
// Moves the filter into a running state. aStartTime is the offset to be added
// to the samples' stream time in order for the samples to appear in stream time.
STDMETHODIMP
BaseFilter::Run(REFERENCE_TIME aStartTime)
{
  CriticalSectionAutoEnter monitor(mLock);

  mStartTime = aStartTime;

  if (mState == State_Running) {
    return S_OK;
  }

  // First pause the filter if it's stopped.
  if (mState == State_Stopped) {
    HRESULT hr = Pause();
    if (FAILED(hr)) {
      return hr;
    }
  }

  // Start all connected pins.
  int numPins = GetPinCount();
  for (int i = 0; i < numPins; i++) {

    BasePin* pin = GetPin(i);
    assert(pin != NULL);
    if (!pin) {
      continue;
    }

    if (pin->IsConnected()) {
      HRESULT hr = pin->Run(aStartTime);
      if (FAILED(hr)) {
        return hr;
      }
    }
  }

  mState = State_Running;
  return S_OK;
}
Ejemplo n.º 15
0
XnVideoSource::~XnVideoSource()
{
    xnLogVerbose(XN_MASK_FILTER, "Destroying filter...");

    if (m_pVideoProcAmp != NULL)
    {
        delete m_pVideoProcAmp;
    }

    if (m_pCameraControl != NULL)
    {
        delete m_pCameraControl;
    }

    for (int i = 0; i < GetPinCount(); ++i)
    {
        delete GetPin(i);
    }

    m_image.Release();
    m_context.Release();
}
Ejemplo n.º 16
0
//----------------------------------------------------------------------------
//! @brief	  	保持しているピンをすべて削除する
//! @return		エラーコード
//----------------------------------------------------------------------------
void CDemuxSource::ClearPins()
{
	while( GetPinCount() > 0 )
		delete GetPin(GetPinCount()-1);
}
Ejemplo n.º 17
0
void ChipPackage::Draw(wxDC& dc, const wxSize& sz, const wxString& chipModel)
{
    // set some GUI objects common to all packages-drawing code
    dc.SetPen(*wxBLACK_PEN);

    switch (Type)
    {
    case PDIP:
    case SOIC:
    case SSOP:
        {
            // some drawing constants:

            // in these package types, pins are organized in two columns:
            const unsigned int PinPerSide = GetPinCount()/2;
            if ((GetPinCount()%2) != 0)
            {
                wxLogWarning(_("Invalid odd pin count: %d"), GetPinCount());
                return;
            }

            // choose reasonable package width&height to
            // - make best use of the available space
            // - avoid drawing package excessively big
            const unsigned int BoxW = sz.GetWidth()/3;
            const unsigned int BoxH = (unsigned int)((double)sz.GetHeight()*0.8);
            const unsigned int BoxX = (sz.GetWidth()-BoxW)/2;
            const unsigned int BoxY = (sz.GetHeight()-BoxH)/2;
            const unsigned int R = BoxW/6;
            
            if (int(BoxW/8) == 0)
                return;     // this happens for very small package sizes;
                            // the check avoids an assertion failure from wxFont ctor later

            // draw the PIC package box
            dc.DrawRectangle(BoxX, BoxY, BoxW, BoxH);
            dc.DrawArc(sz.GetWidth()/2-R, BoxY + 1,
                       sz.GetWidth()/2+R, BoxY + 1,
                       sz.GetWidth()/2, BoxY + 1);


            dc.SetFont(wxFont(wxSize(0, BoxW/8), wxFONTFAMILY_DEFAULT,
                              wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
            const wxSize& nameSz = dc.GetTextExtent(chipModel);
            dc.DrawRotatedText(chipModel,
                               (sz.GetWidth() + nameSz.GetHeight())/2,
                               (sz.GetHeight() - nameSz.GetWidth())/2,
                               -90);

            // draw the pins
            DrawPins(dc, wxPoint(BoxX, BoxY), BoxH, 0, PinPerSide, 
                     0, wxLEFT);
            DrawPins(dc, wxPoint(BoxX+BoxW, BoxY), BoxH, PinPerSide, GetPinCount(), 
                     DRAWPIN_INVERTED_ORDER, wxRIGHT);
        }
        break;

    case MQFP:
    case TQFP:
    case PLCC:
	case QFN:
        {
            // some drawing constants:

            // in these package types, pins are organized in two columns:
            const unsigned int PinPerSide = GetPinCount()/4;
            if ((GetPinCount()%4) != 0)
            {
                wxLogWarning(_("Invalid pin count: %d"), GetPinCount());
                return;
            }

            // choose reasonable package width&height to
            // - make best use of the available space
            // - avoid drawing package excessively big
            const unsigned int BoxL = max(sz.GetWidth()/2,80);
            const unsigned int BoxX = (sz.GetWidth()-BoxL)/2;
            const unsigned int BoxY = (sz.GetHeight()-BoxL)/2;
            const unsigned int R = BoxL/10;
            
            if (int(BoxL/10) == 0)
                return;     // this happens for very small package sizes;
                            // the check avoids an assertion failure from wxFont ctor later

            // draw the PIC package box
            dc.DrawRectangle(BoxX, BoxY, BoxL, BoxL);
            dc.DrawCircle(BoxX+int(R*1.3), BoxY+int(R*1.3), R/2);

            // draw the name of the PIC model in the centre of the box
            dc.SetFont(wxFont(wxSize(0, BoxL/10), wxFONTFAMILY_DEFAULT,
                              wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
			const wxSize& nameSz = dc.GetTextExtent(chipModel);
            dc.DrawText(chipModel,
                        (sz.GetWidth() - nameSz.GetWidth())/2,
                        (sz.GetHeight() - nameSz.GetHeight())/2);

            // draw the pins
            DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, 0, PinPerSide, 
                     DRAWPIN_NUMBERS_INSIDE_PINS, wxLEFT);
            DrawPins(dc, wxPoint(BoxX, BoxY+BoxL), BoxL, PinPerSide, PinPerSide*2, 
                     DRAWPIN_NUMBERS_INSIDE_PINS, wxBOTTOM);
            DrawPins(dc, wxPoint(BoxX+BoxL, BoxY), BoxL, PinPerSide*2, PinPerSide*3, 
                     DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxRIGHT);
            DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, PinPerSide*3, PinPerSide*4, 
                     DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxTOP);
        }
        break;

    default:
        break;
    }
}