Example #1
0
        private void AddVideoRenderer()
        {
            int hr;

            _videoRender = (IBaseFilter) new VideoMixingRenderer();
            Debug.Assert(_videoRender != null);
            hr = _graphBuilder.AddFilter(_videoRender, "VMR7");
            DsError.ThrowExceptionForHR(hr);

            // Configure the video renderer

            if (_hostControl != null)
            {
                IVMRFilterConfig vmrFilterConfig = (IVMRFilterConfig)_videoRender;
                hr = vmrFilterConfig.SetRenderingMode(VMRMode.Windowless);
                DsError.ThrowExceptionForHR(hr);
                _vmrWindowlessControl = (IVMRWindowlessControl)_videoRender;
                hr = _vmrWindowlessControl.SetAspectRatioMode(VMRAspectRatioMode.LetterBox);
                DsError.ThrowExceptionForHR(hr);
                hr = _vmrWindowlessControl.SetVideoClippingWindow(_hostControl.Handle);
                DsError.ThrowExceptionForHR(hr);
                ResizeMoveHandler(null, null);
                _hostControl.Paint  += new PaintEventHandler(PaintHandler);
                _hostControl.Resize += new EventHandler(ResizeMoveHandler);
                _hostControl.Move   += new EventHandler(ResizeMoveHandler);
            }
            else
            {
                throw new Exception("Host control not specified");
            }
        }
        protected override void Initialize(IGraphBuilder pGraphBuilder, IntPtr hMediaWindow)
        {
            // QUERY the VMR interfaces
            try
            {
                _pVMRFilterConfig = (IVMRFilterConfig)BaseFilter;
                _pVMRFilterConfig.SetRenderingMode(VMRMode.VMRMode_Windowless);
                _pVMRWindowlessControl = (IVMRWindowlessControl)BaseFilter;
                _pVMRWindowlessControl.SetVideoClippingWindow(hMediaWindow);

                _pVMRWindowlessControl.SetAspectRatioMode(VMR_ASPECT_RATIO_MODE.VMR_ARMODE_NONE);
            }
            catch (Exception e)
            {
                throw new FilterGraphBuilderException(GraphBuilderError.ConfigureVMR, e);
            }
        }
Example #3
0
        protected void AddVideoRender()
        {
            int hr;

            _videoRender = (IBaseFilter) new VideoMixingRenderer();
            hr           = _graphBuilder.AddFilter(_videoRender, "VMR");
            DsError.ThrowExceptionForHR(hr);

            // Configure the video renderer

            IVMRFilterConfig vmrFilterConfig = (IVMRFilterConfig)_videoRender;

            hr = vmrFilterConfig.SetRenderingMode(VMRMode.Windowless);
            DsError.ThrowExceptionForHR(hr);
            _windowlessControl = (IVMRWindowlessControl)_videoRender;
            hr = _windowlessControl.SetAspectRatioMode(VMRAspectRatioMode.LetterBox);
            DsError.ThrowExceptionForHR(hr);
            NotifyPropertyChanged("VideoRender");
        }
Example #4
0
        public void BuildGraph()
        {
            int hr = 0;

            graphBuilder = (IFilterGraph2) new FilterGraph();
            rot          = new DsROTEntry(graphBuilder);

            vmr = (IBaseFilter) new VideoMixingRenderer();

            IVMRFilterConfig filterConfig = (IVMRFilterConfig)vmr;

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

            // Put the VMR7 in Renderless mode
            hr = filterConfig.SetRenderingMode(VMRMode.Renderless);
            DsError.ThrowExceptionForHR(hr);

            surfaceAllocatorNotify = (IVMRSurfaceAllocatorNotify)vmr;

            hr = surfaceAllocatorNotify.AdviseSurfaceAllocator(cookie, this);
            DsError.ThrowExceptionForHR(hr);

            defaultAllocatorPresenter = (IVMRSurfaceAllocator)Activator.CreateInstance(Type.GetTypeFromCLSID(VMRClsId.AllocPresenter));

            form = new Form();
            form.Show();

            hr = (defaultAllocatorPresenter as IVMRWindowlessControl).SetVideoClippingWindow(form.Handle);
            DsError.ThrowExceptionForHR(hr);

            hr = this.AdviseNotify(surfaceAllocatorNotify);
            DsError.ThrowExceptionForHR(hr);

            hr = graphBuilder.AddFilter(vmr, "VMR");

            hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null);
            DsError.ThrowExceptionForHR(hr);
        }
Example #5
0
        public void DoTests()
        {
            int hr = 0;
            IVMRFilterConfig vmrConfig = null;
            DsROTEntry       ROT       = null;

            this.Show();

            try
            {
                // Just build the graph with unconnected source filter and VMR7
                BuildGraph(testFile, out this.graphBuilder, out this.sourceFilter, out this.vmr7Filter);

                // VMR7 need to be placed in Windowless mode before connecting it to the rest of the graph
                vmrConfig = this.vmr7Filter as IVMRFilterConfig;
                hr        = vmrConfig.SetRenderingMode(VMRMode.Windowless);
                Marshal.ThrowExceptionForHR(hr);

                this.vmrWndConfig = this.vmr7Filter as IVMRWindowlessControl;

                TestSetVideoClippingWindow();
                TestAspectRatioMode();
                TestBorderColor();
                TestColorKey();
                TestGetMaxIdealVideoSize();
                TestGetMinIdealVideoSize();

                // Connect source filter with the VMR7
                ConnectGraph(ref this.graphBuilder, ref this.sourceFilter, ref this.vmr7Filter);
                ROT = new DsROTEntry(this.graphBuilder);

                // Run the graph to test other methods
                this.mediaControl = this.graphBuilder as IMediaControl;
                hr = this.mediaControl.Run();
                Marshal.ThrowExceptionForHR(hr);

                this.timer          = new System.Windows.Forms.Timer();
                this.timer.Interval = 2000;
                this.timer.Enabled  = true;
                this.timer.Tick    += new EventHandler(DoTestsPart2);
                this.timer.Start();

                this.isPlaying = true;
                TestVideoPosition();

                Application.Run(this);
            }
            finally
            {
                if (ROT != null)
                {
                    ROT.Dispose();
                }
                if (this.mediaControl != null)
                {
                    this.mediaControl.Stop();
                }
                Marshal.ReleaseComObject(this.vmr7Filter);
                Marshal.ReleaseComObject(this.sourceFilter);
                Marshal.ReleaseComObject(this.graphBuilder);
            }
        }