Exemple #1
0
HRESULT CStreamSwitcherOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
    CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
    if (!pIn || !pIn->IsConnected()) {
        return E_UNEXPECTED;
    }

    CComPtr<IEnumMediaTypes> pEM;
    if (FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM))) {
        return VFW_S_NO_MORE_ITEMS;
    }

    if (iPosition > 0 && FAILED(pEM->Skip(iPosition))) {
        return VFW_S_NO_MORE_ITEMS;
    }

    AM_MEDIA_TYPE* tmp = nullptr;
    if (S_OK != pEM->Next(1, &tmp, nullptr) || !tmp) {
        return VFW_S_NO_MORE_ITEMS;
    }

    CopyMediaType(pmt, tmp);
    DeleteMediaType(tmp);
    /*
        if (iPosition < 0) return E_INVALIDARG;
        if (iPosition > 0) return VFW_S_NO_MORE_ITEMS;

        CopyMediaType(pmt, &pIn->CurrentMediaType());
    */
    return S_OK;
}
Exemple #2
0
HRESULT CStreamSwitcherOutputPin::CompleteConnect(IPin* pReceivePin)
{
    m_pPinConnection = CComQIPtr<IPinConnection>(pReceivePin);
    HRESULT hr = __super::CompleteConnect(pReceivePin);

    CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
    CMediaType mt;
    if (SUCCEEDED(hr) && pIn && pIn->IsConnected()
            && SUCCEEDED(pIn->GetConnected()->ConnectionMediaType(&mt)) && m_mt != mt) {
        if (pIn->GetConnected()->QueryAccept(&m_mt) == S_OK) {
            hr = m_pFilter->ReconnectPin(pIn->GetConnected(), &m_mt);
        } else {
            hr = VFW_E_TYPE_NOT_ACCEPTED;
        }
    }

    return hr;
}
Exemple #3
0
HRESULT CStreamSwitcherOutputPin::QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt)
{
    HRESULT hr = S_FALSE;

    CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();

    if (pIn && pIn->IsConnected() && (pIn->IsUsingOwnAllocator() || pIn->CurrentMediaType() == *pmt)) {
        if (CComQIPtr<IPin> pPinTo = pIn->GetConnected()) {
            if (S_OK != (hr = pPinTo->QueryAccept(pmt))) {
                return VFW_E_TYPE_NOT_ACCEPTED;
            }
        } else {
            return E_FAIL;
        }
    }

    return hr;
}