Example #1
0
/******************************Public*Routine******************************\
* AddVideoMixingRendererToFG
*
\**************************************************************************/
HRESULT
CMpegMovie::AddVideoMixingRendererToFG()
{
	if ( m_Vw ) {

		return FALSE;

	}	else {


    IBaseFilter* pBF = NULL;
    HRESULT hRes = CoCreateInstance(CLSID_VideoMixingRenderer,
        NULL,
        CLSCTX_INPROC,
        IID_IBaseFilter,
        (LPVOID *)&pBF);


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

        if(SUCCEEDED(hRes))
        {
				hRes = SetRenderingMode(pBF, VMRMode_Renderless);
				
				hRes = pBF->QueryInterface(IID_IVMRSurfaceAllocatorNotify,
							(LPVOID *)&m_San);

				hRes = CreateDefaultAllocatorPresenter();
				hRes = m_San->AdviseSurfaceAllocator(MY_USER_ID, this);

        }
    }

    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;

	}
}
Example #2
0
//-------------------------------------------------------------------------
//  InitializeEnvironment
//  creates default allocator-presenter and sets D3D environment
//-------------------------------------------------------------------------
HRESULT CMultiSAP::InitializeEnvironment()
{
    HRESULT hr;
//    m_hMonitor = MonitorFromWindow(m_hwndApp, MONITOR_DEFAULTTOPRIMARY);

    hr = CreateDefaultAllocatorPresenter();
    if (hr != S_OK)
        return hr;

    BITMAPINFOHEADER  bi =
    {
        sizeof(BITMAPINFOHEADER), // biSize
            640,                      // biWidth
            480,                      // biHeight
            1,                        // biPlanes
            0,                        // biBitCount
            BI_RGB,                   // biCompression
            0,                        // biSizeImage,
            0,                        // biXpelsPerMeter
            0,                        // biYPelsPerMeter
            0,                        // biClrUsed
            0                         // biClrImportant
    };
    VMRALLOCATIONINFO ai =
    {
        AMAP_3D_TARGET,             // dwFlags
        &bi,                        // lpHdr
        NULL,                       // lpPicFmt
        {4, 3},                     // szAspectRatio
        1,                          // dwMinBuffers
        1,                          // dwMaxBuffers
        0,                          // dwInterlaceFlags
        {640, 480}                  // szNativeSize
    };

    DWORD dwBuffers = 0;
    LPDIRECTDRAWSURFACE7 lpDDSurf;
    hr = m_pAlloc->AllocateSurface(0, &ai, &dwBuffers, &lpDDSurf);
    if (hr != DD_OK)
        return hr;

    DDSURFACEDESC2 ddsd = {sizeof(DDSURFACEDESC2)};
    hr = lpDDSurf->GetSurfaceDesc(&ddsd);
    if (hr != DD_OK) {
        return hr;
    }

    //
    // Overlay surfaces have these flags set, we need to remove
    // these flags prior to calling GetAttachedSurface
    //
    ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_FRONTBUFFER | DDSCAPS_VISIBLE);

    hr = lpDDSurf->GetAttachedSurface(&ddsd.ddsCaps, &m_lpBackBuffer);


    m_lpBackBuffer->GetDDInterface((LPVOID *)&m_lpDDObj);

    //
    // get the h/w caps for this device
    //
    INITDDSTRUCT(m_ddHWCaps);
    m_lpDDObj->GetCaps(&m_ddHWCaps, NULL);

    //
    // Create the device. The device is created off of our back buffer, which
    // becomes the render target for the newly created device. Note that the
    // z-buffer must be created BEFORE the device
    //
    m_pD3DHelper = new CD3DHelper(m_lpBackBuffer, &hr);
    if(m_pD3DHelper == NULL || hr != DD_OK)
    {
        if(m_pD3DHelper == NULL)
        {
            hr = E_OUTOFMEMORY;
        }
        delete m_pD3DHelper;
    }

    SetRect(&m_rcDst, 0, 0, 640, 480);

#ifdef SPARKLE
    m_pSparkle = new CSparkle(m_lpDDObj);
    if (m_pSparkle)
        m_pSparkle->InitializeSparkle();
#endif

    return hr;
}