/******************************Public*Routine******************************\
* AddVideoMixingRendererToFG
*
\**************************************************************************/
HRESULT
CMovie::AddVideoMixingRendererToFG()
{
    IBaseFilter* pBF = NULL;
    HRESULT hRes = CoCreateInstance(CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC,
                                    IID_IBaseFilter, (LPVOID *)&pBF);

    if(SUCCEEDED(hRes))
    {
        hRes = m_Fg->AddFilter(pBF, L"Video Mixing Renderer 9");

        if(SUCCEEDED(hRes))
        {
            // Test VMRConfig, VMRMonitorConfig
            IVMRFilterConfig9* pConfig;
            HRESULT hRes2 = pBF->QueryInterface(IID_IVMRFilterConfig9, (LPVOID *)&pConfig);
            if(SUCCEEDED(hRes2))
            {
                hRes2 = pConfig->SetNumberOfStreams(2);
                hRes2 = pConfig->SetRenderingMode(VMR9Mode_Windowless);
                //hRes2 = pConfig->SetRenderingPrefs(RenderPrefs_AllowOverlays);
                pConfig->Release();
            }

            IVMRMonitorConfig9* pMonitorConfig;
            HRESULT hRes3 = pBF->QueryInterface(IID_IVMRMonitorConfig9, (LPVOID *)&pMonitorConfig);
            if(SUCCEEDED(hRes3))
            {
                UINT iCurrentMonitor;
                HRESULT hr4 = pMonitorConfig->GetMonitor(&iCurrentMonitor);
                pMonitorConfig->Release();
            }

            hRes = pBF->QueryInterface(IID_IVMRWindowlessControl9, (LPVOID *)&m_Wc);
        }
    }

    if(pBF)
    {
        pBF->Release();
    }

    if(SUCCEEDED(hRes))
    {
        HRESULT hr = m_Wc->SetVideoClippingWindow(m_hwndApp);
        hr = m_Wc->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX);
    }
    else
    {
        if(m_Wc)
        {
            m_Wc->Release();
            m_Wc = NULL;
        }
    }

    return hRes;
}
Esempio n. 2
0
void	Video::ConfigureVMR9()
{
	HRESULT	hr;

	IVMRFilterConfig9*	pVMRConfig;
	ASSERT( SUCCEEDED( hr = m_pVMR9->QueryInterface( IID_IVMRFilterConfig9, (LPVOID*) &pVMRConfig ) ), "Failed to retrieve VMR9 config!" );
	pVMRConfig->SetRenderingMode( VMR9Mode_Renderless );
	pVMRConfig->SetNumberOfStreams( 1 );
	pVMRConfig->Release();

	ASSERT( SUCCEEDED( hr = m_pVMR9->QueryInterface( IID_IVMRSurfaceAllocatorNotify9, (LPVOID*) &m_pVMRAllocatorNotify ) ), "Failed to retrieve VMR9 surface allocator!" );
	AdviseNotify( m_pVMRAllocatorNotify );
	ASSERT( SUCCEEDED( hr = m_pVMRAllocatorNotify->AdviseSurfaceAllocator( 0x1234, this ) ), "Failed to replace the allocator/renderer for VRM9!" );		// Use our class as interface to allocator/presenter
}