Windowed Mode Video Rendering

Source: Internet
Author: User

If you need to render with windowed mode, you need the following steps:

    1. Querying the Ivideowindow interface (QueryInterface)
    2. Set parent window (Put_owner)
    3. Setting the window mode (put_windowstyle)
    4. Setting the window position (setwindowposition)
    5. Handling Wm_move Messages

Process explanatory code, shorthand, no return value to judge

HRESULT hr=CoInitialize (NULL); Igraphbuilder*Pgraphbuilder; HR=cocreateinstance (Clsid_filtergraph,null,clsctx_inproc_server,iid_igraphbuilder, (void* *) &Pgraphbuilder); Pgraphbuilder->renderfile (L"D:\\direct_show\\extras\\directshow\\samples\\media\\video\\ruby.avi",0); Ivideowindow*pvideowin=NULL; HR=pgraphbuilder->queryinterface (Iid_ivideowindow, (void* *) &Pvideowin); HR=pvideowin->Put_owner ((Oahwnd) m_hwnd); HR=pvideowin->put_windowstyle (Ws_child |ws_clipsiblings);    Rect rect; GetClientRect (&rect); HR=pvideowin->setwindowposition (0,0, Rect.right,rect.bottom); IMediaControl*Pcontrol; Imediaevent*pevent; HR=pgraphbuilder->queryinterface (Iid_imediacontrol, (void* *) &Pcontrol); HR=pgraphbuilder->queryinterface (Iid_imediaevent, (void* *) &pevent); Pcontrol-Run (); LongEvcode=0; HR=pevent->waitforcompletion (infinite,&Evcode); Pcontrol-Release (); Pevent-Release (); Pgraphbuilder-Release (); CoUninitialize ();
 Case wm_move:    pvidwin-notifyownermessage ((oahwnd) hWnd, MSG, WParam, lParam);     break;

Cleanup work:

Pcontrol->Stop (); Pvidwin-put_visible (oafalse);p vidwin->put_owner (NULL);  

It is important to note that:

The call to the RenderFile function must precede the Put_owner function, or the return value of the Put_owner function is s_nointerface.

In this example, there is no shadow to add any filter, neither the source filter nor the render filter, just one sentence of RenderFile (). Yes, RenderFile () did all the things.
First Igraphbuilder::renderfile () calls Igraphbuilder::addsourcefilter () to add a source Filter to the graph. Igraphbuilder::addsourcefilter () intelligently selects a source Filter for a matching file based on the file name extension or the file first-class information.
Then Igraphbuilder::renderfile () calls Igraphbuilder::render () to complete the rest of the graph generation. Igraphbuilder::render () starts looking for each filter that matches this pin from the output pin of source filter to join the link until a Render filter is found. When the entire link is complete, it also represents graph generation, and you can call Pcontrol->run () to run graph.
Although Ivideowindow is exposed by the filter Graph Manager, the Ivideowindow setting property is for the render filter. RenderFile is not connected in graph until RenderFile is executed, so Ivideowindow's settings are not valid. (http://blog.csdn.net/bwmwm/article/details/4562709)

Windowed Mode Video Rendering

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.