示例#1
0
文件: BaseGraph.cs 项目: ewin66/media
        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 CloseInterfaces()
        {
            _pVMRFilterConfig      = null;
            _pVMRWindowlessControl = null; // they will be released when pBaseFilter is released

            base.CloseInterfaces();        // release pBaseFilter
        }
示例#3
0
文件: Snapshot.cs 项目: ewin66/media
        /// <summary>
        /// Creates a Snapshot from a windowless control
        /// </summary>
        /// <param name="control">control that is being drawn to by the VMR7</param>
        public Snapshot(IVMRWindowlessControl control)
        {
            int hr;

            hr = control.GetCurrentImage(out _dib);
            DsError.ThrowExceptionForHR(hr);
        }
 public void SetRendererInterfaces(IVMRWindowlessControl VMRWindowlessControl,
                                   IVMRWindowlessControl9 VMRWindowlessControl9,
                                   IMFVideoDisplayControl MFVideoDisplayControl)
 {
     _VMRWindowlessControl  = VMRWindowlessControl;
     _VMRWindowlessControl9 = VMRWindowlessControl9;
     _MFVideoDisplayControl = MFVideoDisplayControl;
 }
        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);
            }
        }
示例#6
0
        /// <summary>
        /// Binds a control to the VMR. This will be the surface the VMR renders onto.
        /// </summary>
        /// <param name="hostControl">control to render on</param>
        /// <seealso cref="M:FutureConcepts.Media.Client.StreamViewer.DSGraph.DetachControl"/>
        public void AttachControl(Control hostControl)
        {
            int hr;

            // Configure the video renderer

            if (hostControl != null)
            {
                _hostControl       = hostControl;
                _windowlessControl = (IVMRWindowlessControl)_videoRender;
                hr = _windowlessControl.SetVideoClippingWindow(hostControl.Handle);
                DsError.ThrowExceptionForHR(hr);
                ResizeMoveHandler(null, null);
                _hostControl.Paint  += new PaintEventHandler(PaintHandler);
                _hostControl.Resize += new EventHandler(ResizeMoveHandler);
                _hostControl.Move   += new EventHandler(ResizeMoveHandler);
                Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(DisplayChangedHandler); // for WM_DISPLAYCHANGE
            }
        }
示例#7
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");
        }
示例#8
0
文件: BaseGraph.cs 项目: ewin66/media
        protected virtual void Dispose(bool disposeManaged)
        {
            GC.SuppressFinalize(this);
            Process currentProc = Process.GetCurrentProcess();

            currentProc.PriorityClass = ProcessPriorityClass.Normal;

            _hostControl.Paint  -= new PaintEventHandler(PaintHandler);
            _hostControl.Resize -= new EventHandler(ResizeMoveHandler);
            _hostControl.Move   -= new EventHandler(ResizeMoveHandler);

            ForceReleaseComObject(_captureFilter);
            _captureFilter = null;
            ForceReleaseComObject(_fileWriter);
            _fileWriter = null;

            ForceReleaseComObject(_mediaControl);
            _mediaControl = null;
            ForceReleaseComObject(_graphBuilder);
            _graphBuilder = null;
            ForceReleaseComObject(_captureGraphBuilder);
            _captureGraphBuilder = null;

            ForceReleaseComObject(_videoRender);
            _videoRender = null;
            ForceReleaseComObject(_audioRender);
            _audioRender = null;
            ForceReleaseComObject(_audioVolumeFilter);
            _audioVolumeFilter          = null;
            _audioVolumeFilterInterface = null;

            ForceReleaseComObject(_vmrWindowlessControl);
            _vmrWindowlessControl = null;

            DsUtils.FreeAMMediaType(_emptyAMMediaType);
        }
示例#9
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);
            }
        }
示例#10
0
 public void SetRendererInterfaces(IVMRWindowlessControl VMRWindowlessControl,
                                   IVMRWindowlessControl9 VMRWindowlessControl9,
                                   IMFVideoDisplayControl MFVideoDisplayControl)
 {
     _manager.SetRunning(true, VMRWindowlessControl, VMRWindowlessControl9, MFVideoDisplayControl);
 }
示例#11
0
 private void ConfigureVMR()
 {
     baseFilter = (IBaseFilter)new VideoMixingRenderer();
     IVMRFilterConfig filterConfig = (IVMRFilterConfig)baseFilter;
     filterConfig.SetNumberOfStreams(1);
     filterConfig.SetRenderingMode(VMRMode.Windowless);
     VMRCtrl = (IVMRWindowlessControl)baseFilter;
     VMRCtrl.SetVideoClippingWindow(winHandle);
     VMRCtrl.SetAspectRatioMode(VMRAspectRatioMode.LetterBox);
     Form1_ResizeMove(null, null);
     graphBuilder.AddFilter(baseFilter, "Video Mixing Renderer");
 }
示例#12
0
        public void CloseInterfaces()
        {
            //mediaEvent = null;
            if (mediaControl != null)
                mediaControl.Stop();

            if (baseFilter != null)
            {
                Marshal.ReleaseComObject(baseFilter);
                baseFilter = null;
            }
            EVRCtrl = null;
            VMRCtrl = null;

            if (dvdGraphBuilder != null)
            {
                Marshal.ReleaseComObject(dvdGraphBuilder);
                dvdGraphBuilder = null;
            }

            if (graphBuilder != null)
            {
                Marshal.ReleaseComObject(graphBuilder);
                graphBuilder = null;
            }
            mediaControl = null;
        }