none
Component WPF to render streaming

    Question

  • Hi

    I make a graph by GraphEdit to view a stream make by a device, and I use GraphEditPlusper to obtain corrispondent C# code. I want to know if is possible view the stream (the stream is renderized from ip address) on a WPF form, This using obtained code

    In BuilsGraph method I have the following code:

     ICaptureGraphBuilder2 pBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
                hr = pBuilder.SetFiltergraph(pGraph);
                checkHR(hr, "Can't SetFiltergrapgh");
    
    
    
                //Guid CLSID_VideoSolutionSource = new Guid("{" + m_LiveStreamId + "}");
                Guid CLSID_VideoSolutionSource = new Guid("{17ADDE6C-ED6E-4867-8133-9198CCC7F740}");// VVSSourceFilter.ax            
                Guid CLSID_VideoSolutionsDecoderFilter = new Guid("{7C71B31D-3F3F-4477-A4FF-BAB16D5B8C68}");// VVSDecoderFilter.ax
                Guid CLSID_EnhanceVideoRenderr = new Guid("{FA10746C-9B63-4B6C-BC49-FC300EA5F256}");// evr.dll
    
                // add Video Solution Source
                IBaseFilter pVideoSolutionSource = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_VideoSolutionSource));
                hr = pGraph.AddFilter(pVideoSolutionSource, "Video Solution Source");
                checkHR(hr, "Can't add Video Solution Source to Graph");
    
                
                // set source filename 
                IFileSourceFilter pVideoSolutionSource_src = pVideoSolutionSource as IFileSourceFilter;
                
                if (pVideoSolutionSource_src == null)
                    checkHR(unchecked((int)0x80004002), "Can't get IFileSourceFilter");
                hr = pVideoSolutionSource_src.Load(srcFile1, null);
                checkHR(hr, "Can't load file");
    
                //add Video Solution Decoder Filter
                IBaseFilter pVideoSolutionDecoderFilter = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_VideoSolutionsDecoderFilter));
                hr = pGraph.AddFilter(pVideoSolutionDecoderFilter, "Video Solution Decoder Filter");
                checkHR(hr, "Can't add Video Solution Decoder Filter to Graph");            
    
                // connect Video Solution Source and Video Solutions Decoder Filter
                hr = pGraph.ConnectDirect(GetPin(pVideoSolutionSource, "Live Video"), GetPin(pVideoSolutionDecoderFilter, "XForm In"), null);
                checkHR(hr, "Can't connect Video Solution Source and Video Solution Decoder Filter");
    
                //add Enhanced Video Render
                IBaseFilter pEnhancedVideoRender = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_EnhanceVideoRenderr));
                hr = pGraph.AddFilter(pEnhancedVideoRender, "Enhanced Video Render");
                checkHR(hr, "Can't add Enhanced Video Render to graph");
    
                //connect Video Solution Decoder Filter and Enhanced Video Render
                hr = pGraph.ConnectDirect(GetPin(pVideoSolutionDecoderFilter, "XForm Out"), GetPin(pEnhancedVideoRender, "EVR Input0"), null);
                checkHR(hr, "Can't connect Video Solution Decoder Filter and Enhanced Video Renderer");

    In the costructor:

    IGraphBuilder graph = (IGraphBuilder)new FilterGraph();
                    Console.WriteLine("Building graph...");
                    BuilsGraph(graph, @"Video Solution Source Filter: ");
                    Console.WriteLine("Running...");
                    IMediaControl mediaControl = (IMediaControl)graph;
                    IMediaEvent mediaEvent = (IMediaEvent)graph;
                    int hr = mediaControl.Run();
                    checkHR(hr, "Can't run the graph");
                    bool stop = false;
    
                    while (!stop)
                    {
                        System.Threading.Thread.Sleep(500);
                        Console.WriteLine(".");
                        EventCode ev;
                        IntPtr p1, p2;
    
                        //System.Windows.Forms.Application.DoEvents();
                        while (mediaEvent.GetEvent(out ev, out p1, out p2, 0) == 0)
                        {
                            if (ev == EventCode.Complete || ev == EventCode.UserAbort)
                            {
                                Console.WriteLine("Done!");
                                stop = true;
                            }
                            else
                                if (ev == EventCode.ErrorAbort)
                                {
                                    Console.WriteLine("An error occurred: HRESULT={0:X}", p1);
                                    mediaControl.Stop();
                                    stop = true;
                                }
                            mediaEvent.FreeEventParams(ev, p1, p2);
                        }
                    }
    Thank's

    Valentina Tavanti



    • Moved by Annabella Luo Tuesday, May 22, 2012 6:19 AM (From:Windows Presentation Foundation (WPF))
    • Edited by Vale820_1 Tuesday, June 12, 2012 2:51 PM
    Friday, May 18, 2012 12:19 PM

All replies

  • Hi Vale820_1,

    Thank you for your post. But here is English Forum that member can't understand you if you don't ask question in English. So I'm moving your thread. You can open a new thread in English to ask this question, sorry for any inconvenience.

    Thank you for your understanding and support.

    Have a nice day.


    Annabella Luo[MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, May 22, 2012 6:18 AM