DirectX video playback ------ manual connection, directx ------

Source: Internet
Author: User

DirectX video playback ------ manual connection, directx ------



IGraphBuilder *pigb  = NULL;IMediaControl *pimc  = NULL;IMediaEventEx *pimex = NULL;IVideoWindow  *pivw  = NULL;IMediaSeeking  *pims  = NULL;
ICaptureGraphBuilder2 * g_pCaptureBuilder = NULL;

IBaseFilter * pF = 0; void CTestFilterDlg: OnButton4 () {// TODO: Add your control notification handler code hereCoInitialize (NULL); HRESULThr = CoCreateInstance (CLSID_FilterGraph, NULL, ignore, IID_IGraphBuilder, (void **) & pigb); hr = CoCreateInstance (Region, NULL, CLSCTX_INPROC, region, (void **) & g_pCaptureBuilder); pigb-> QueryInterface (IID_IMedia) Control, (void **) & pimc); pigb-> QueryInterface (IID_IMediaEventEx, (void **) & pimex); pigb-> QueryInterface (IID_IMediaSeeking, (void **) & pims); pigb-> QueryInterface (IID_IVideoWindow, (void **) & pivw); hr = g_pCaptureBuilder-> SetFiltergraph (pigb ); // avi-source /////////////////////////////////// ////////////// // const GUID CLSID_AviSource = {0xCEA8DEFF, 0x0AF7, 0x4DB9, {0x9A, 0x38, 0xFB, 0x3C, 0x3A, 0xE F, 0xC0, 0xDE }}; hr = CoCreateInstance (CLSID_AviSource, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast <void **> (& pF )); hr = pigb-> AddFilter (pF, L "source filter"); IFileSourceFilter * pSF = NULL; hr = pF-> QueryInterface (IID_IFileSourceFilter, (void **) & pSF ); if (SUCCEEDED (hr) {pSF-> Load (L "F: \ FFOutput \ ff640480.avi", NULL); pSF-> Release ();} IPin * pOut_Source = 0; IPin * pPin; if (SUCCEEDED (h R) {IEnumPins * pEnum; // IPin * pPin; hr = pF-> EnumPins (& pEnum); if (SUCCEEDED (hr )) {/* while (pEnum-> Next (1, & pPin, 0) = S_ OK) {PIN_DIRECTION pinDirThis; pPin-> QueryDirection (& pinDirThis ); if (PINDIR_OUTPUT = pinDirThis) {break ;}} */hr = g_pCaptureBuilder-> FindPin (pF, PINDIR_OUTPUT, NULL, NULL, FALSE, 0, & pPin ); pEnum-> Release () ;}} pOut_Source = pPin; if (hr) {MessageBox ("err renderavi! ");} // Ffshow-decoder /////////////////////////////////// //// // IBaseFilter * paviDecoder; // --- 871E-AB91661A4EF7 const GUID CLSID_Decoder = {0x04FE9017, 0xF873, 0x0000e, {0x87, 0x1e, 0xaB, 0x91,0x66, 0x1a, 0x4e, 0xf7 }}; hr = CoCreateInstance (CLSID_Decoder, NULL, CLSCTX_ALL, IID_IBaseFilter, (void **) & paviDecoder); hr = pigb-> AddFilter (paviDecoder, L "ffdshow Video Decoder "); IPin * pIn_aviDecoder = 0; IPin * pOut_aviDecoder = 0; hr = g_pCaptureBuilder-> FindPin (paviDecoder, PINDIR_INPUT, NULL, NULL, FALSE, 0, & pIn_aviDecoder ); hr = g_pCaptureBuilder-> FindPin (paviDecoder, PINDIR_OUTPUT, NULL, NULL, FALSE, 0, & pOut_aviDecoder ); // Render filter //////////////////////////////////// /// IBaseFilter * pRenderFilter; hr = CoCreateInstance (CLSID_VideoRenderer, NULL, CLSCTX_ALL, IID_IBaseFilter, (void **) & pRenderFilter); hr = pigb-> AddFilter (pRenderFilter, L "ffdshow Video Render "); IPin * pIn_Render = 0; hr = g_pCaptureBuilder-> FindPin (pRenderFilter, PINDIR_INPUT, NULL, NULL, FALSE, 0, & pIn_Render ); //// Special filter ///////////////////////////////// /// // IBaseFilter * peffect; // --- 871E-AB91661A4EF7 const GUID CLSID_EFFECT = {0x8b498501, 0x1218, 0x11cf, {0xad, 0xc4, 0x0, 0xa0, 0xd1, 0x0, 0x4, 0x1b }}; hr = CoCreateInstance (CLSID_EFFECT, NULL, CLSCTX_ALL, IID_IBaseFilter, (void **) & peffect); hr = pigb-> AddFilter (peffect, L "Image effect"); IPin * pIn_peffect = 0; IPin * pOut_peffect = 0; hr = g_pCaptureBuilder-> FindPin (peffect, PINDIR_INPUT, NULL, NULL, FALSE, 0, & pIn_peffect); hr = g_pCaptureBuilder-> FindPin (peffect, PINDIR_OUTPUT, NULL, NULL, FALSE, 0, & pOut_peffect); peffect-> Release (); /// Connect to the pin // hr = pigb-> Connect (pOut_Source, pIn_aviDecoder); if (FAILED (hr) {MessageBox ("err17");} hr = pigb-> Connect (pOut_aviDecoder, pIn_peffect); if (FAILED (hr )) {MessageBox ("err18");} hr = pigb-> Connect (pOut_peffect, pIn_Render); if (FAILED (hr) {MessageBox ("err19 ");} ////// display ////////// // HWND m_hwndScreen = m_Screen2.GetSafeHwnd (); RECT rc; hr = pivw-> put_Owner (OAHWND) m_hwndScreen); hr = pivw-> put_WindowStyle (WS_CHILD | WS_CLIPCHILDREN); values (& rc); hr = pivw-> SetWindowPosition (0, 0, (rc. right), (rc. bottom); hr = pivw-> put_Visible (OATRUE); // */hr = pimc-> Run ();}



Directx must be installed to connect to the TV box.

Is the computer connected to a TV? It seems that you want a TV card. You need a vga interface on the TV side to transmit the computer signal.

DirectX 11 download connection

Baidu
 

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.