Directshow video window-less browsing

Source: Internet
Author: User

HRESULT CVideoSource: AddWindowLessRender (HWND hwndApp, RECT win_rect) // Window to hold the video.
{

HRESULT hr = NULL;
CRect rcSrc, rcDest;
Hr = CoCreateInstance (CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **) & m_pVideoRender );
If (hr! = S_ OK) return hr;
// Create the VMR.

// Add the VMR to the filter graph.
Hr = m_pGrapher-> AddFilter (m_pVideoRender, L "Video Mixing Renderer ");
If (FAILED (hr ))
{
M_pVideoRender-> Release ();
Return hr;
}
// Set the rendering mode.
Long lWidth, lHeight, lARWidth, lARHeight;
Hr = m_pVideoRender-> QueryInterface (IID_IVMRFilterConfig, (void **) & m_pFilterConfig );
If (FAILED (hr ))
{
M_pVideoRender-> Release ();
Return hr;
}
 
Hr = m_pFilterConfig-> SetRenderingMode (VMRMode_Windowless );//
If (FAILED (hr ))
{
M_pVideoRender-> Release ();
Return hr;
}
 
// Set the window.
Hr = m_pVideoRender-> QueryInterface (IID_IVMRWindowlessControl, (void **) & m_pWindowsLessControl );
If (FAILED (hr ))
{
M_pVideoRender-> Release ();
Return hr;
}
If (m_bSetVedioFormat) // when you adjust the video, set the format
{
Hr = UpdateVideoCapConfig ();
M_bSetVedioFormat = false; // The video format is adjusted to the original position.
}
// RenderStream ();
IPin * pPin2;
Hr = m_pBuilder-> FindPin (m_pSmartTee, PINDIR_OUTPUT, 0, 0, TRUE, 1, & pPin2 );
Hr = m_pBuilder-> RenderStream (0, 0, pPin2, 0, m_pVideoRender );
// Hr = m_pBuilder-> RenderStream (0, 0, m_pSmartTee, 0, m_pVideoRender );
 

// Hr = m_pBuilder-> RenderStream (
// & PIN_CATEGORY_PREVIEW, // & PIN_CATEGORY_CAPTURE, // Pin category
// & MEDIATYPE_Video, // Media type
// M_pSmartTee, // m_pVideoCap, // Capture filter
// NULL, // m_pVidCompress, // Compression filter (optional)
// M_pVideoRender // Multiplexer or renderer filter
//);
Hr = m_pWindowsLessControl-> SetVideoClippingWindow (hwndApp );
Hr = m_pWindowsLessControl-> GetNativeVideoSize (& lWidth, & lHeight, NULL, NULL );
If (FAILED (hr ))
{
M_pVideoRender-> Release ();
Return hr;
}
// Set the source rectangle.
SetRect (& rcSrc, 0, 0, lWidth, lHeight );
 
// Get the window client area.
GetClientRect (hwndApp, & rcDest );
// Set the destination rectangle.
SetRect (& rcDest, 10, 10, win_rect.right, win_rect.bottom );
// SetRect (& rcDest, 0, 0, rcDest. right, rcDest. bottom );

Hr = m_pWindowsLessControl-> SetVideoPosition (& rcSrc, & rcDest );
// Make sure we process events while we're re previewing!
Hr = m_pGrapher-> QueryInterface (IID_IMediaEventEx, (void **) & m_pMediaEventEx );
If (hr = NOERROR)
{
M_pMediaEventEx-> setpolicywindow (OAHWND) hwndApp, wm_fg1_y, 0 );
}
Return hr;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.