public void BuildGraph()
        {
            int hr = 0;

            graphBuilder = (IFilterGraph2) new FilterGraph();

            rot = new DsROTEntry(graphBuilder);

            vmr9 = (IBaseFilter) new VideoMixingRenderer9();

            IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)vmr9;

            hr = filterConfig.SetNumberOfStreams(2);
            DsError.ThrowExceptionForHR(hr);

            // Set the custom compositor
            hr = filterConfig.SetImageCompositor(this);
            DsError.ThrowExceptionForHR(hr);

            IVMRMixerControl9 mixerControl = (IVMRMixerControl9)vmr9;

            // In COLORREF, colors are coded in ABGR format
            hr = mixerControl.SetBackgroundClr(backgroundColorABGR);
            DsError.ThrowExceptionForHR(hr);

            hr = graphBuilder.AddFilter(vmr9, "VMR9");
            DsError.ThrowExceptionForHR(hr);

            // The 2 VMR pins must be connected...
            hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null);
            DsError.ThrowExceptionForHR(hr);

            hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null);
            DsError.ThrowExceptionForHR(hr);

            hr = (graphBuilder as IMediaControl).Run();
            DsError.ThrowExceptionForHR(hr);
        }
Пример #2
0
        private void ConfigureVMR9InWindowlessMode()
        {
            int hr = 0;

            IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)vmr9;

            // Must be called before calling SetImageCompositor
            hr = filterConfig.SetNumberOfStreams(1);
            DsError.ThrowExceptionForHR(hr);

            // Create an instance of the Compositor
            compositor = new Compositor();

            // Configure the filter with the Compositor
            hr = filterConfig.SetImageCompositor(compositor);
            DsError.ThrowExceptionForHR(hr);

            // Change VMR9 mode to Windowless
            hr = filterConfig.SetRenderingMode(VMR9Mode.Windowless);
            DsError.ThrowExceptionForHR(hr);

            windowlessCtrl = (IVMRWindowlessControl9)vmr9;

            // Set rendering window
            hr = windowlessCtrl.SetVideoClippingWindow(renderingPanel.Handle);
            DsError.ThrowExceptionForHR(hr);

            // Set Aspect-Ratio
            hr = windowlessCtrl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
            DsError.ThrowExceptionForHR(hr);

            // Add delegates for Windowless operations
            AddHandlers();

            // Call the resize handler to configure the output size
            MainForm_ResizeMove(null, null);
        }