예제 #1
0
        protected override void CloseInterfaces()
        {
            _pVMRFilterConfig9      = null;
            _pVMRWindowlessControl9 = null; // they will be released when pBaseFilter is released

            base.CloseInterfaces();         // release bBaseFilter
        }
예제 #2
0
파일: MainForm.cs 프로젝트: d3x0r/xperdex
        private void ConfigureVMR9InWindowlessMode()
        {
            int hr = 0;

            IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)vmr9;

            // Not really needed for VMR9 but don't forget calling it with VMR7
            hr = filterConfig.SetNumberOfStreams(1);
            DsError.ThrowExceptionForHR(hr);

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

            windowlessCtrl = (IVMRWindowlessControl9)vmr9;

            // Set "Parent" window
            hr = windowlessCtrl.SetVideoClippingWindow(this.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);
        }
예제 #3
0
        private void ConfigureVMR9InWindowlessMode()
        {
            int hr = 0;
            IVMRFilterConfig9 filterConfig = this.videoRenderer as IVMRFilterConfig9;

            // Configure VMR-9 in Windowsless mode
            hr = filterConfig.SetRenderingMode(VMR9Mode.Windowless);
            DsError.ThrowExceptionForHR(hr);

            // With 1 input stream
            hr = filterConfig.SetNumberOfStreams(1);
            DsError.ThrowExceptionForHR(hr);

            IVMRWindowlessControl9 windowlessControl = this.videoRenderer as IVMRWindowlessControl9;

            // The main form is hosting the VMR-9
            hr = windowlessControl.SetVideoClippingWindow(this.hostingControl.Handle);
            DsError.ThrowExceptionForHR(hr);

            // Keep the aspect-ratio OK
            hr = windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
            DsError.ThrowExceptionForHR(hr);

            // Init the VMR-9 with default size values
            ResizeMoveHandler(null, null);

            // Add Windows Messages handlers
            AddHandlers();
        }
        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);

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

            surfaceAllocatorNotify = (IVMRSurfaceAllocatorNotify9)vmr9;

            // Advise to VMR9 of our custom Allocator / Presenter
            hr = surfaceAllocatorNotify.AdviseSurfaceAllocator(cookie, this);
            DsError.ThrowExceptionForHR(hr);

            // Advise our custom Allocator / Presenter of the VMR9
            hr = this.AdviseNotify(surfaceAllocatorNotify);
            DsError.ThrowExceptionForHR(hr);

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

            hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null);
            DsError.ThrowExceptionForHR(hr);
        }
예제 #5
0
파일: MainForm.cs 프로젝트: d3x0r/xperdex
        public void InitVMR9(string filename)
        {
            int hr = 0;

            // Create a DirectShow FilterGraph
            graphBuilder = (IFilterGraph2) new FilterGraph();

            // Add it in ROT for debug purpose
            rot = new DsROTEntry(graphBuilder);

            // Add a notification handler (see WndProc)
            hr = (graphBuilder as IMediaEventEx).SetNotifyWindow(this.Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);

            // Create a VMR9 object
            vmr9 = (IBaseFilter) new VideoMixingRenderer9();

            IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)vmr9;

            // We want the Renderless mode!
            hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless);
            DsError.ThrowExceptionForHR(hr);

            // One stream is enough for this sample
            hr = filterConfig.SetNumberOfStreams(1);
            DsError.ThrowExceptionForHR(hr);

            // Create the Allocator / Presenter object
            allocator = new Allocator(device);

            IVMRSurfaceAllocatorNotify9 vmrSurfAllocNotify = (IVMRSurfaceAllocatorNotify9)vmr9;

            // Notify the VMR9 filter about our allocator
            hr = vmrSurfAllocNotify.AdviseSurfaceAllocator(IntPtr.Zero, allocator);
            DsError.ThrowExceptionForHR(hr);

            // Notify our allocator about the VMR9 filter
            hr = allocator.AdviseNotify(vmrSurfAllocNotify);
            DsError.ThrowExceptionForHR(hr);

            IVMRMixerControl9 mixerControl = (IVMRMixerControl9)vmr9;

            // Select the mixer mode : YUV or RGB
            hr = mixerControl.SetMixingPrefs(VMR9MixerPrefs.RenderTargetYUV | VMR9MixerPrefs.NoDecimation | VMR9MixerPrefs.ARAdjustXorY | VMR9MixerPrefs.BiLinearFiltering);
            //hr = mixerControl.SetMixingPrefs(VMR9MixerPrefs.RenderTargetRGB | VMR9MixerPrefs.NoDecimation | VMR9MixerPrefs.ARAdjustXorY | VMR9MixerPrefs.BiLinearFiltering);
            DsError.ThrowExceptionForHR(hr);

            // Add the filter to the graph
            hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
            DsError.ThrowExceptionForHR(hr);

            // Render the file
            hr = graphBuilder.RenderFile(filename, null);
            DsError.ThrowExceptionForHR(hr);

            // Run the graph
            hr = (graphBuilder as IMediaControl).Run();
            DsError.ThrowExceptionForHR(hr);
        }
예제 #6
0
        public void VideoWindowSnapshot(IVMRFilterConfig9 renderer)
        {
            if (null == VmrRenderer)
            {
                return;
            }

            IVMRWindowlessControl9 ctrl = (IVMRWindowlessControl9)renderer;
            IntPtr imgptr = IntPtr.Zero;
            Bitmap bmp    = null;

            try
            {
                ctrl.GetCurrentImage(out imgptr);
                if (IntPtr.Zero != imgptr)
                {
                    BitmapInfoHeader header = new BitmapInfoHeader();
                    Marshal.PtrToStructure(imgptr, header);
                    //stride formula comes from MSDN
                    //https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader
                    var stride = ((((header.Width * header.BitCount) + 31) & ~31) >> 3);

                    //暫時假定輸出圖像是純DIB沒有Color Mask等額外資訊
                    bmp = new Bitmap(header.Width, header.Height, stride,
                                     PixelFormat.Format32bppArgb, imgptr + header.Size);
                    //注意這邊撈出的CurrentImage,是上下顛倒狀態(沿著X軸鏡射)
                    //要把它再鏡射回來才能存檔
                    bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);

                    SaveFileDialog dlg = new SaveFileDialog();
                    dlg.Filter           = "Bitmap File (*.bmp)|*.bmp";
                    dlg.InitialDirectory = BinPath;
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        bmp.Save(dlg.FileName, ImageFormat.Jpeg);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to save snapshot bmp file : " + ex.Message);
            }
            finally
            {
                if (bmp != null)
                {
                    bmp.Dispose();
                }
                if (IntPtr.Zero != imgptr)
                {
                    Marshal.FreeCoTaskMem(imgptr);
                }
            }
        }
        public void DoTests()
        {
            int hr = 0;
            IVMRFilterConfig9 vmrConfig = null;

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

                // VMR9 need to be placed in Windowless mode before connecting it to the rest of the graph
                vmrConfig = this.vmr9Filter as IVMRFilterConfig9;
                hr        = vmrConfig.SetRenderingMode(VMR9Mode.Windowless);
                Marshal.ThrowExceptionForHR(hr);

                this.vmrWndConfig = this.vmr9Filter as IVMRWindowlessControl9;

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

                // Connect source filter with the VMR9
                ConnectGraph(ref this.graphBuilder, ref this.sourceFilter, ref this.vmr9Filter);

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

                this.isPlaying = true;
                TestVideoPosition();

                Thread.Sleep(2000);
                TestGetCurrentImage();

                Thread.Sleep(2000);
                TestDisplayModeChanged();
                TestGetNativeVideoSize();
                TestRepaintVideo();
            }
            finally
            {
                if (this.mediaControl != null)
                {
                    this.mediaControl.Stop();
                }
                Marshal.ReleaseComObject(this.vmr9Filter);
                Marshal.ReleaseComObject(this.sourceFilter);
                Marshal.ReleaseComObject(this.graphBuilder);
            }
        }
예제 #8
0
        void PreviewInit()
        {
            m_dvdNav  = (IBaseFilter) new DVDNavigator();
            m_dvdCtrl = m_dvdNav as IDvdControl2;
            int hr = m_dvdCtrl.SetDVDDirectory(Disk.VIDEO_TS);

            DsError.ThrowExceptionForHR(hr);

            m_dvdInfo = m_dvdCtrl as IDvdInfo2;

            m_filterGraph = (IGraphBuilder) new FilterGraph();
            hr            = m_filterGraph.AddFilter(m_dvdNav, "DVD Navigator");
            DsError.ThrowExceptionForHR(hr);

            m_renderer = (IBaseFilter) new VideoMixingRenderer9();
            IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)m_renderer;

            hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless);
            DsError.ThrowExceptionForHR(hr);

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

            hr = m_filterGraph.AddFilter(m_renderer, "Video Mix 9");
            DsError.ThrowExceptionForHR(hr);

            IPin videoPin;

            hr = m_dvdNav.FindPin("Video", out videoPin);
            DsError.ThrowExceptionForHR(hr);

            IPin audioPin;

            hr = m_dvdNav.FindPin("AC3", out audioPin);
            DsError.ThrowExceptionForHR(hr);

            //hr = m_filterGraph.Render(videoPin);
            //DsError.ThrowExceptionForHR(hr);
            //hr = m_filterGraph.Render(audioPin);
            //DsError.ThrowExceptionForHR(hr);

            //IMediaControl mediaCtrl = (IMediaControl)m_filterGraph;

            //hr = mediaCtrl.Run();
            //DsError.ThrowExceptionForHR(hr);

            //hr = m_dvdCtrl.SetOption(DvdOptionFlag.EnableNonblockingAPIs, true);
            //DsError.ThrowExceptionForHR(hr);
            //m_dvdCtrl.SetOption(DvdOptionFlag.ResetOnStop, true);
        }
예제 #9
0
        private void ConfigureVMRInWindowlessMode()
        {
            IVMRFilterConfig9 vMRenderer = (IVMRFilterConfig9)this.DX.VMRenderer;

            DsError.ThrowExceptionForHR(vMRenderer.SetNumberOfStreams(1));
            DsError.ThrowExceptionForHR(vMRenderer.SetRenderingMode(VMR9Mode.Windowless));
            this.DX.WindowlessCtrl = (IVMRWindowlessControl9)this.DX.VMRenderer;
            if (this._HostingControl != null)
            {
                DsError.ThrowExceptionForHR(this.DX.WindowlessCtrl.SetVideoClippingWindow(this._HostingControl.Handle));
            }
            DsError.ThrowExceptionForHR(this.DX.WindowlessCtrl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox));
            this.AddHandlers();
            this.HostingControl_ResizeMove(null, null);
        }
예제 #10
0
        protected override void Initialize(IGraphBuilder pGraphBuilder, IntPtr hMediaWindow)
        {
            if (_initialized)
            {
                base.Initialize(pGraphBuilder, hMediaWindow);
            }
            else
            {
                IVMRFilterConfig9 pVMRFilterConfig9 = (IVMRFilterConfig9)BaseFilter; // will be released when pBaseFilter is released
                pVMRFilterConfig9.SetNumberOfStreams(NUMBER_OF_STREAMS);

                IVMRAspectRatioControl9 pVMRAspectRatioControl9 = (IVMRAspectRatioControl9)BaseFilter;
                pVMRAspectRatioControl9.SetAspectRatioMode(VMR9AspectRatioMode.VMR9ARMode_None);

                _initialized = true;
            }
        }
예제 #11
0
        private void SetupRenderWindow(IVMRFilterConfig9 renderer, Control target)
        {
            IVMRFilterConfig9 config = renderer;

            // Not really needed for VMR9 but don't forget calling it with VMR7
            config.SetNumberOfStreams(1);
            // Change VMR9 mode to Windowless
            config.SetRenderingMode(VMR9Mode.Windowless);
            IVMRWindowlessControl9 winless_ctrl = (IVMRWindowlessControl9)renderer;

            // Set "Parent" window
            winless_ctrl.SetVideoClippingWindow(target.Handle);
            // Set Aspect-Ratio
            winless_ctrl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
            winless_ctrl.SetVideoPosition(null, DsRect.FromRectangle(target.ClientRectangle));
            winless_ctrl = null;
        }
예제 #12
0
        protected override void Initialize(IGraphBuilder pGraphBuilder, IntPtr hMediaWindow)
        {
            // QUERY the VMR9 interfaces
            try
            {
                _pVMRFilterConfig9 = (IVMRFilterConfig9)BaseFilter;
                _pVMRFilterConfig9.SetRenderingMode(VMR9Mode.VMR9Mode_Windowless);
                _pVMRFilterConfig9.SetNumberOfStreams(NUMBER_OF_STREAMS);
                _pVMRWindowlessControl9 = (IVMRWindowlessControl9)BaseFilter;
                _pVMRWindowlessControl9.SetVideoClippingWindow(hMediaWindow);

                _pVMRWindowlessControl9.SetAspectRatioMode(VMR9AspectRatioMode.VMR9ARMode_None);
            }
            catch (Exception e)
            {
                throw new FilterGraphBuilderException(GraphBuilderError.ConfigureVMR9, e);
            }
        }
예제 #13
0
        public void DoTests()
        {
            try
            {
                BuildGraph(testFile, out this.graphBuilder, out this.vmr9Filter);
                this.vmrConfig = this.vmr9Filter as IVMRFilterConfig9;

                TestNumberOfStreams();
                TestRenderingMode();
                TestRenderingPrefs();
                TestSetImageCompositor();
            }
            finally
            {
                Marshal.ReleaseComObject(this.vmr9Filter);
                Marshal.ReleaseComObject(this.graphBuilder);
            }
        }
예제 #14
0
        private void StartGraph()
        {
            int hr = 0;

            CloseGraph();

            string path = GetMoviePath();

            if (path == string.Empty)
            {
                return;
            }

            try
            {
                graph  = (IGraphBuilder) new FilterGraph();
                filter = (IBaseFilter) new VideoMixingRenderer9();

                IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)filter;

                hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless);
                DsError.ThrowExceptionForHR(hr);

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

                SetAllocatorPresenter();

                hr = graph.AddFilter(filter, "Video Mixing Renderer 9");
                DsError.ThrowExceptionForHR(hr);

                hr = graph.RenderFile(path, null);
                DsError.ThrowExceptionForHR(hr);

                mediaControl = (IMediaControl)graph;

                hr = mediaControl.Run();
                DsError.ThrowExceptionForHR(hr);
            }
            catch
            {
            }
        }
예제 #15
0
        /// <summary>
        /// Adds VMR9 (renderer) filter to the filter graph.
        /// </summary>
        private void AddFilter_Renderer()
        {
            VMRenderer = (IBaseFilter) new VideoMixingRenderer9();

            IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)VMRenderer;

            // Not really needed for vmr but don't forget calling it with VMR7
            int hr = filterConfig.SetNumberOfStreams(1);

            DsError.ThrowExceptionForHR(hr);

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

            // video renderer
            WindowlessCtrl = (IVMRWindowlessControl9)VMRenderer;

            // set clipping window
            hr = WindowlessCtrl.SetVideoClippingWindow(_DisplayPanel.Handle);
            DsError.ThrowExceptionForHR(hr);

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

            // Add delegates for Windowless operations
            _DisplayPanel.Paint  += new PaintEventHandler(HostingControl_Paint);                          // for WM_PAINT
            _DisplayPanel.Resize += new EventHandler(HostingControl_ResizeMove);                          // for WM_SIZE
            _DisplayPanel.Move   += new EventHandler(HostingControl_ResizeMove);                          // for WM_MOVE
            SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged); // for WM_DISPLAYCHANGE
            _bHandlersAdded = true;

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

            hr = FilterGraph.AddFilter(VMRenderer, "Video Mixing Renderer 9");
            DsError.ThrowExceptionForHR(hr);
        }
        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);
        }
예제 #17
0
파일: MainForm.cs 프로젝트: d3x0r/xperdex
        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);
        }
예제 #18
0
        private void ConfigureVMR9InWindowlessMode()
        {
            int hr = 0;

            IVMRFilterConfig9 _filterConfig = (IVMRFilterConfig9)_vmr9Filter;

            // Not really needed for VMR9 but don't forget calling it with VMR7
            hr = _filterConfig.SetNumberOfStreams(1);
            DsError.ThrowExceptionForHR(hr);

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

            windowlessCtrl = (IVMRWindowlessControl9)_vmr9Filter;

            // Set "Parent" window
            hr = windowlessCtrl.SetVideoClippingWindow(this.panVideoWin.Handle);
            DsError.ThrowExceptionForHR(hr);

            // Set Aspect-Ratio
            hr = windowlessCtrl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
            DsError.ThrowExceptionForHR(hr);
        }
예제 #19
0
파일: AVPlayer.cs 프로젝트: DeSciL/Ogama
    private void LoadMovieInWindow(string filename)
    {
      int hr = 0;

      if (filename == string.Empty)
        return;

      this.graphBuilder = (IGraphBuilder)new FilterGraph();
      this.captureGraphBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
      this.vmr9 = new VideoMixingRenderer9();
      this.vmrConfig = this.vmr9 as IVMRFilterConfig9;

      // Attach the filter graph to the capture graph
      hr = this.captureGraphBuilder.SetFiltergraph(this.graphBuilder);
      DsError.ThrowExceptionForHR(hr);

      hr = this.graphBuilder.AddFilter(vmr9 as IBaseFilter, "VideoMixingRenderer9");
      DsError.ThrowExceptionForHR(hr);

      hr = this.vmrConfig.SetRenderingMode(VMR9Mode.Windowless);
      DsError.ThrowExceptionForHR(hr);
      this.windowLessControl = this.vmr9 as IVMRWindowlessControl9;
      this.windowLessControl.SetVideoClippingWindow(this.Handle);
      this.windowLessControl.SetVideoPosition(null, new DsRect(0, 0, this.ClientSize.Width, this.ClientSize.Height));

      IBaseFilter fileSourceFilter;
      hr = this.graphBuilder.AddSourceFilter(filename, "WebCamSource", out fileSourceFilter);
      DsError.ThrowExceptionForHR(hr);

      hr = this.captureGraphBuilder.RenderStream(null, null, fileSourceFilter, null, vmr9 as IBaseFilter);
      DsError.ThrowExceptionForHR(hr);

      //// Have the graph builder construct its the appropriate graph automatically
      //hr = this.graphBuilder.RenderFile(filename, null);
      //DsError.ThrowExceptionForHR(hr);

      // QueryInterface for DirectShow interfaces
      this.mediaControl = (IMediaControl)this.graphBuilder;
      //this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
      this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
      //this.mediaPosition = (IMediaPosition)this.graphBuilder;

      // Query for video interfaces, which may not be relevant for audio files
      ////this.videoWindow = this.graphBuilder as IVideoWindow;
      this.basicVideo = this.graphBuilder as IBasicVideo;

      // Query for audio interfaces, which may not be relevant for video-only files
      this.basicAudio = this.graphBuilder as IBasicAudio;

      // Is this an audio-only file (no video component)?
      CheckVisibility();

      //// Have the graph signal event via window callbacks for performance
      //hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero);
      //DsError.ThrowExceptionForHR(hr);

      if (!this.isAudioOnly)
      {
        this.windowLessControl = this.vmr9 as IVMRWindowlessControl9;
        this.windowLessControl.SetVideoClippingWindow(this.Handle);
        this.windowLessControl.SetVideoPosition(null, new DsRect(0, 0, this.ClientSize.Width, this.ClientSize.Height));

        //hr = InitVideoWindow();
        //DsError.ThrowExceptionForHR(hr);

        GetFrameStepInterface();
      }

      // Complete window initialization
      //this.isFullScreen = false;
      this.currentPlaybackRate = 1.0;
      //UpdateToolTip();

#if DEBUG
      rot = new DsROTEntry(this.graphBuilder);
#endif
    }
예제 #20
0
        void initGraph(Rectangle rect, IntPtr hwnd)
        {
            log.writeLog("Init Graph");
            pGB           = (IGraphBuilder) new FilterGraph();
            pVmr          = (IBaseFilter) new VideoMixingRenderer9();
            compressVideo = CreateFilter(FilterCategory.VideoCompressorCategory, lstCompressor[3]);
            pGB.AddFilter(pVmr, "Video");
            pGB.AddFilter(captureVideo, "VideoCapture");
            //pGB.AddFilter(compressVideo, "Encoder");

            pConfig = (IVMRFilterConfig9)pVmr;
            pConfig.SetRenderingMode(VMR9Mode.Windowless);
            pWC = (IVMRWindowlessControl9)pVmr;

            pWC.SetVideoPosition(null, DsRect.FromRectangle(rect));
            pWC.SetVideoClippingWindow(hwnd);

            pMix = (IVMRMixerControl9)pVmr;
            pMs  = (IMediaSeeking)pGB;
            pMC  = (IMediaControl)pGB;

            ICaptureGraphBuilder2 cc = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            cc.SetFiltergraph(pGB);
            pGB.AddFilter(devices[0], "Camera-1");
            if (devices[1] != null)
            {
                pGB.AddFilter(devices[1], "Camera-2");
            }
            pGB.AddFilter(audioCapture, "Audio Capture");

            Rectangle win = rect;
            float     _w  = win.Width;
            float     _H  = win.Height;

            NormalizedRect _0rect = new NormalizedRect();

            _0rect.top    = win.Top;
            _0rect.left   = win.Left;
            _0rect.right  = (win.Left + win.Width / 2) / _w;
            _0rect.bottom = (win.Bottom / _H);

            NormalizedRect _1rect = new NormalizedRect();

            _1rect.top    = win.Top;
            _1rect.left   = (win.Left + win.Width / 2) / _w;;
            _1rect.right  = win.Right / _w;
            _1rect.bottom = win.Bottom / _H;

            pMix.SetOutputRect(0, _0rect);
            pMix.SetOutputRect(1, _1rect);

            int             hr   = 0;
            IFileSinkFilter sink = null;

            log.writeLog("SetOutputFileName create");
            hr = cc.SetOutputFileName(MediaSubType.Avi, "VideoCaptured.avi", out captureVideo, out sink);
            DsError.ThrowExceptionForHR(hr);
            log.writeLog("SetOutputFileName success");
            log.writeLog("Start create cam-1 to preview");
            hr = cc.RenderStream(PinCategory.Preview, MediaType.Video, devices[0], null, pVmr);
            DsError.ThrowExceptionForHR(hr);
            log.writeLog("Start cam-1 to preview success");
            if (devices[1] != null)
            {
                log.writeLog("Start create cam-2 to preview");
                hr = cc.RenderStream(PinCategory.Preview, MediaType.Video, devices[1], null, pVmr);
                DsError.ThrowExceptionForHR(hr);
                log.writeLog("Create cam-2 to preview success");
            }
            log.writeLog("Start capture video from cam-1");
            hr = cc.RenderStream(PinCategory.Capture, MediaType.Video, devices[0], null, captureVideo);
            DsError.ThrowExceptionForHR(hr);
            log.writeLog("success create capture from cam-1");
            log.writeLog("Start capture audio");
            hr = cc.RenderStream(PinCategory.Capture, MediaType.Audio, audioCapture, null, captureVideo);
            DsError.ThrowExceptionForHR(hr);
            log.writeLog("Success to capture audio");

            Marshal.ReleaseComObject(cc);
        }
예제 #21
0
        protected override HRESULT OnInitInterfaces()
        {
            m_Renderer             = new VMR9Renderer();
            m_Renderer.FilterGraph = m_GraphBuilder;
            IVMRFilterConfig9 _config = (IVMRFilterConfig9)m_Renderer.QueryInterface(typeof(IVMRFilterConfig9).GUID);
            HRESULT           hr;

            if (_config != null)
            {
                hr = (HRESULT)_config.SetRenderingMode(VMR9Mode.Renderless);
                hr.Assert();
                hr = (HRESULT)_config.SetNumberOfStreams(2);
                hr.Assert();
            }

            m_mixerControl = (IVMRMixerControl9)m_Renderer.QueryInterface(typeof(IVMRMixerControl9).GUID);

            m_mixerControl.SetBackgroundClr((int)0xbf7f2f);

            VMR9MixerPrefs mixerPrefs;

            m_mixerControl.GetMixingPrefs(out mixerPrefs);
            m_mixerControl.SetMixingPrefs(mixerPrefs);

            IVMRSurfaceAllocatorNotify9 _notify = (IVMRSurfaceAllocatorNotify9)m_Renderer.QueryInterface(typeof(IVMRSurfaceAllocatorNotify9).GUID);

            if (_notify != null)
            {
                hr = (HRESULT)_notify.AdviseSurfaceAllocator(new IntPtr(g_ciUsedID), this);
                hr.Assert();
                hr = (HRESULT)this.AdviseNotify(_notify);
                hr.Assert();
            }

            DSVideoCaptureCategory captureCategory = new DSVideoCaptureCategory();
            List <DSFilter>        capFilters      = new List <DSFilter>();

            foreach (var captureDevice in captureCategory.Objects)
            {
                if (captureDevice.DevicePath == m_leftEyeDevicePath)
                {
                    capFilters.Add(captureDevice.Filter);
                    break;
                }
            }

            foreach (var captureDevice in captureCategory.Objects)
            {
                if (captureDevice.DevicePath == m_rightEyeDevicePath)
                {
                    capFilters.Add(captureDevice.Filter);
                    break;
                }
            }

            if (capFilters.Count < 2)
            {
                MessageBox.Show("Not enough capture devices found (" + capFilters.Count.ToString() + " device(s))");
                throw new Exception();
            }


            for (int i = 0; i < 2; i++)
            {
                if (capFilters[i] == null)
                {
                    return(E_FAIL);
                }

                DSPin capturePin = null;

                foreach (var outputPin in capFilters[i].Output)
                {
                    if (outputPin.Name == "Capture")
                    {
                        capturePin = outputPin;
                        break;
                    }
                }

                AMMediaType mjpgMediaType = null;

                int maxPixels = -1;
                foreach (var mediaType in capturePin.MediaTypes)
                {
                    VideoInfoHeader videoInfo = new VideoInfoHeader();
                    videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader));

                    // pick the highest res mode...
                    if ((videoInfo.BmiHeader.Width * videoInfo.BmiHeader.Height) > maxPixels)
                    {
                        maxPixels     = videoInfo.BmiHeader.Width * videoInfo.BmiHeader.Height;
                        mjpgMediaType = mediaType;
                        //break;
                    }
                }

                capFilters[i].OutputPin.Format = mjpgMediaType;

                capFilters[i].FilterGraph = m_GraphBuilder;
                capFilters[i].Connect(m_Renderer);
            }


            VMR9NormalizedRect r1 = new VMR9NormalizedRect(0, 0, 0.5f, 1f);
            VMR9NormalizedRect r2 = new VMR9NormalizedRect(0.5f, 0f, 1f, 1f);

            int rt0 = m_mixerControl.SetOutputRect(0, ref r1);
            int rt1 = m_mixerControl.SetOutputRect(1, ref r2);

            hr = base.OnInitInterfaces();

            return(hr);
        }
예제 #22
0
        /// <summary> build the capture graph for grabber. </summary>
        bool SetupGraph()
        {
            int  hr;
            IPin pin1, pin2;

            try
            {
                hr = capGraph.SetFiltergraph(graphBuilder);
                if (hr < 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                if (atiTVCardFound)
                {
                    SetupVideoCrossbar();
                    AddFilter(atiCrossbar, "ATI Crossbar");
                    AddFilter(capFilter, "Analog Capture Device");
                    AddFilter(wmVideoDecoder, "AVI Decompressor");
                    AddFilter(stretchVideo, "Stretch Video");
                    AddFilter(colorConverter, "Color Space Converter");
                }
                else if (videoSource.Equals("File"))
                {
                    graphBuilder.AddSourceFilter(filePath, "WM ASF Reader", out capFilter);
                    AddFilter(modFrameRate, "Modify Frame Rate");
                    AddFilter(stretchVideo, "Stretch Video");
                    AddFilter(colorConverter, "Color Space Converter");
                }
                else
                {
                    int state;
                    if (capFilter.GetState(100, out state) == 0)
                    {
                        AddFilter(capFilter, "Capture Filter");
                    }
                }

                AddFilter(sampleGrabber, "Sample Grabber"); // make sure samples grabbed have 32 bits per pixel to work with Ge Force 7900

                AddFilter(baseGrabFlt, "Vector Grabber");
                AddFilter(motionVector, "Motion Flow Vector Filter");

                if (videoPreview)
                {
                    AddFilter(teeSplitter, "Smart Tee Splitter");
                    AddFilter(colorConverter, "Color Space Converter");
                    AddFilter(videoRenderer, "Video Renderer");
                }

#if false // Attempt to use VMR9 abandoned for now
                IVMRFilterConfig9 vmrConfig = videoRenderer as IVMRFilterConfig9;
                hr = vmrConfig.SetRenderingMode(VMR9Mode.Renderless);
                if (hr < 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
                IVMRSurfaceAllocatorNotify9 vmrAllocNotify = videoRenderer as IVMRSurfaceAllocatorNotify9;
                vmrAllocNotify.AdviseSurfaceAllocator(userID, vmrAllocator);
                vmrAllocator.AdviseNotify(vmrAllocNotify);
#endif

                // connect the pins
                if (videoSource.Equals("File"))
                {
                    ConnectPins(capFilter, "Raw Video 1", modFrameRate, "In");
                    ConnectPins(modFrameRate, "Out", stretchVideo, "In");
                    //ConnectPins(wmVideoDecoder, "out0", stretchVideo, "In");
                    ConnectPins(stretchVideo, "Out", colorConverter, "In");
                    ConnectPins(colorConverter, "Out", sampleGrabber, "In");
                }
                else
                {
                    if (atiTVCardFound)
                    {
                        ConnectPins(atiCrossbar, "0: Video Decoder Out", capFilter, "0");
                        ConnectPins(capFilter, "2", wmVideoDecoder, "In");
                        ConnectPins(wmVideoDecoder, "Out", stretchVideo, "In");
                        ConnectPins(stretchVideo, "Out", colorConverter, "In");
                        ConnectPins(colorConverter, "Out", sampleGrabber, "In");
                    }
                    else // webcam case
                    {
                        //ConnectPins(capFilter, "CapturePin", stretchVideo, "In");
                        ConnectPins(capFilter, "CapturePin", sampleGrabber, "In");
                    }
                }


                if (videoPreview)
                {
                    ConnectPins(sampleGrabber, "Out", teeSplitter, "Input");
                    //ConnectPins(teeSplitter, "0", videoRenderer, "In");
                    ConnectPins(teeSplitter, "Preview", colorConverter, "In");
                    ConnectPins(colorConverter, "Out", videoRenderer, "VMR Input0");
                    ConnectPins(teeSplitter, "Capture", motionVector, "In");
                }
                else
                {
                    ConnectPins(sampleGrabber, "Out", motionVector, "In");
                }
                ConnectPins(motionVector, "Out", baseGrabFlt, "In");

                // check that all filters are accounted for
                // there must be a total of 7 filters if source is "File"
                IEnumFilters enumFilters;
                graphBuilder.EnumFilters(out enumFilters);
                enumFilters.Reset();
                IBaseFilter[] filters = new IBaseFilter[1];
                int           count   = 0;
                int           total   = 0;
                while (0 == (hr = enumFilters.Next(1, filters, out count)))
                {
                    FilterInfo info = new FilterInfo();
                    hr = filters[0].QueryFilterInfo(info);
                    if (hr < 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    LogInfo(LogGroups.Console, info.achName);
                    IPin[]    pins = new IPin[1];
                    IEnumPins enumPins;
                    filters[0].EnumPins(out enumPins);
                    while (0 == (hr = enumPins.Next(1, pins, out count)))
                    {
                        IPin pin;
                        hr = pins[0].ConnectedTo(out pin);
                        if (pin != null)
                        {
                            string pinID;
                            hr = pin.QueryId(out pinID);
                            LogInfo(LogGroups.Console, pinID);
                        }
                    }
                    Marshal.ReleaseComObject(filters[0]);
                    total++;
                }
                Marshal.ReleaseComObject(enumFilters);

                SetupVideoGrabber();

                SetupVectorGrabber();

                return(true);
            }
            catch (Exception ee)
            {
                LogInfo(LogGroups.Console, "Could not setup graph\r\n" + ee.Message);
                return(false);
            }
        }
예제 #23
0
        /// <summary> create the used COM components and get the interfaces. </summary>
        protected virtual bool GetDVDInterfaces(string path)
        {
            int hr;
            //Type	            comtype = null;
            object comobj = null;

            _freeNavigator = true;
            _dvdInfo       = null;
            _dvdCtrl       = null;
            bool   useAC3Filter    = false;
            string dvdNavigator    = "";
            string aspectRatioMode = "";
            string displayMode     = "";

            _videoPref = DvdPreferredDisplayMode.DisplayContentDefault;
            using (MediaPortal.Profile.Settings xmlreader = new MPSettings())
            {
                dvdNavigator    = xmlreader.GetValueAsString("dvdplayer", "navigator", "DVD Navigator");
                aspectRatioMode = xmlreader.GetValueAsString("dvdplayer", "armode", "").ToLower();

                dvdNavigator = "dslibdvdnav";

                if (aspectRatioMode == "crop")
                {
                    arMode = AspectRatioMode.Crop;
                }
                if (aspectRatioMode == "letterbox")
                {
                    arMode = AspectRatioMode.LetterBox;
                }
                if (aspectRatioMode == "stretch")
                {
                    arMode = AspectRatioMode.Stretched;
                }
                //if ( aspectRatioMode == "stretch" ) arMode = AspectRatioMode.zoom14to9;
                if (aspectRatioMode == "follow stream")
                {
                    arMode = AspectRatioMode.StretchedAsPrimary;
                }
                useAC3Filter = xmlreader.GetValueAsBool("dvdplayer", "ac3", false);
                displayMode  = xmlreader.GetValueAsString("dvdplayer", "displaymode", "").ToLower();
                if (displayMode == "default")
                {
                    _videoPref = DvdPreferredDisplayMode.DisplayContentDefault;
                }
                if (displayMode == "16:9")
                {
                    _videoPref = DvdPreferredDisplayMode.Display16x9;
                }
                if (displayMode == "4:3 pan scan")
                {
                    _videoPref = DvdPreferredDisplayMode.Display4x3PanScanPreferred;
                }
                if (displayMode == "4:3 letterbox")
                {
                    _videoPref = DvdPreferredDisplayMode.Display4x3LetterBoxPreferred;
                }
            }
            try
            {
                _dvdGraph = (IDvdGraphBuilder) new DvdGraphBuilder();

                hr = _dvdGraph.GetFiltergraph(out _graphBuilder);
                if (hr < 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
                _rotEntry = new DsROTEntry((IFilterGraph)_graphBuilder);

                _vmr9Filter = (IBaseFilter) new VideoMixingRenderer9();
                IVMRFilterConfig9 config = _vmr9Filter as IVMRFilterConfig9;
                hr             = config.SetNumberOfStreams(1);
                hr             = config.SetRenderingMode(VMR9Mode.Windowless);
                windowlessCtrl = (IVMRWindowlessControl9)_vmr9Filter;
                windowlessCtrl.SetVideoClippingWindow(this.panVideoWin.Handle);


                //                config.SetRenderingPrefs(VMR9RenderPrefs.

                _graphBuilder.AddFilter(_vmr9Filter, "Video Mixing Renderer 9");

                //               _vmr7 = new VMR7Util();
                //               _vmr7.AddVMR7(_graphBuilder);

                try
                {
                    _dvdbasefilter = DirectShowUtil.AddFilterToGraph(_graphBuilder, dvdNavigator);
                    if (_dvdbasefilter != null)
                    {
                        IDvdControl2 cntl = (IDvdControl2)_dvdbasefilter;
                        if (cntl != null)
                        {
                            _dvdInfo = (IDvdInfo2)cntl;
                            _dvdCtrl = (IDvdControl2)cntl;
                            if (path != null)
                            {
                                if (path.Length != 0)
                                {
                                    cntl.SetDVDDirectory(path);
                                }
                            }
                            _dvdCtrl.SetOption(DvdOptionFlag.HMSFTimeCodeEvents, true); // use new HMSF timecode format
                            _dvdCtrl.SetOption(DvdOptionFlag.ResetOnStop, false);

                            AddPreferedCodecs(_graphBuilder);
                            DirectShowUtil.RenderOutputPins(_graphBuilder, _dvdbasefilter);


//                            _videoWin = _graphBuilder as IVideoWindow;
                            _freeNavigator = false;
                        }

                        //DirectShowUtil.ReleaseComObject( _dvdbasefilter); _dvdbasefilter = null;
                    }
                }
                catch (Exception ex)
                {
                    string strEx = ex.Message;
                }

                Guid riid;

                if (_dvdInfo == null)
                {
                    riid = typeof(IDvdInfo2).GUID;
                    hr   = _dvdGraph.GetDvdInterface(riid, out comobj);
                    if (hr < 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    _dvdInfo = (IDvdInfo2)comobj;
                    comobj   = null;
                }

                if (_dvdCtrl == null)
                {
                    riid = typeof(IDvdControl2).GUID;
                    hr   = _dvdGraph.GetDvdInterface(riid, out comobj);
                    if (hr < 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    _dvdCtrl = (IDvdControl2)comobj;
                    comobj   = null;
                }

                _mediaCtrl  = (IMediaControl)_graphBuilder;
                _mediaEvt   = (IMediaEventEx)_graphBuilder;
                _basicAudio = _graphBuilder as IBasicAudio;
                _mediaPos   = (IMediaPosition)_graphBuilder;
                _mediaSeek  = (IMediaSeeking)_graphBuilder;
                _mediaStep  = (IVideoFrameStep)_graphBuilder;
                _basicVideo = _graphBuilder as IBasicVideo2;
                _videoWin   = _graphBuilder as IVideoWindow;

                // disable Closed Captions!
                IBaseFilter baseFilter;
                _graphBuilder.FindFilterByName("Line 21 Decoder", out baseFilter);
                if (baseFilter == null)
                {
                    _graphBuilder.FindFilterByName("Line21 Decoder", out baseFilter);
                }
                if (baseFilter != null)
                {
                    _line21Decoder = (IAMLine21Decoder)baseFilter;
                    if (_line21Decoder != null)
                    {
                        AMLine21CCState state = AMLine21CCState.Off;
                        hr = _line21Decoder.SetServiceState(state);
                        if (hr == 0)
                        {
                            logger.Info("DVDPlayer:Closed Captions disabled");
                        }
                        else
                        {
                            logger.Info("DVDPlayer:failed 2 disable Closed Captions");
                        }
                    }
                }

                /*
                 *      // get video window
                 *      if (_videoWin==null)
                 *      {
                 *        riid = typeof( IVideoWindow ).GUID;
                 *        hr = _dvdGraph.GetDvdInterface( ref riid, out comobj );
                 *        if( hr < 0 )
                 *          Marshal.ThrowExceptionForHR( hr );
                 *        _videoWin = (IVideoWindow) comobj; comobj = null;
                 *      }
                 */
                // GetFrameStepInterface();

                DirectShowUtil.SetARMode(_graphBuilder, arMode);
                DirectShowUtil.EnableDeInterlace(_graphBuilder);
                //m_ovMgr = new OVTOOLLib.OvMgrClass();
                //m_ovMgr.SetGraph(_graphBuilder);

                return(true);
            }
            catch (Exception)
            {
                //MessageBox.Show( this, "Could not get interfaces\r\n" + ee.Message, "DVDPlayer.NET", MessageBoxButtons.OK, MessageBoxIcon.Stop );
                CloseDVDInterfaces();
                return(false);
            }
            finally
            {
                if (comobj != null)
                {
                    DirectShowUtil.ReleaseComObject(comobj);
                }
                comobj = null;
            }
        }
예제 #24
0
        private void LoadMovieInWindow(string filename)
        {
            int hr = 0;

            if (filename == string.Empty)
            {
                return;
            }

            this.graphBuilder        = (IGraphBuilder) new FilterGraph();
            this.captureGraphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
            this.vmr9      = new VideoMixingRenderer9();
            this.vmrConfig = this.vmr9 as IVMRFilterConfig9;

            // Attach the filter graph to the capture graph
            hr = this.captureGraphBuilder.SetFiltergraph(this.graphBuilder);
            DsError.ThrowExceptionForHR(hr);

            hr = this.graphBuilder.AddFilter(vmr9 as IBaseFilter, "VideoMixingRenderer9");
            DsError.ThrowExceptionForHR(hr);

            hr = this.vmrConfig.SetRenderingMode(VMR9Mode.Windowless);
            DsError.ThrowExceptionForHR(hr);
            this.windowLessControl = this.vmr9 as IVMRWindowlessControl9;
            this.windowLessControl.SetVideoClippingWindow(this.Handle);
            this.windowLessControl.SetVideoPosition(null, new DsRect(0, 0, this.ClientSize.Width, this.ClientSize.Height));

            IBaseFilter fileSourceFilter;

            hr = this.graphBuilder.AddSourceFilter(filename, "WebCamSource", out fileSourceFilter);
            DsError.ThrowExceptionForHR(hr);

            hr = this.captureGraphBuilder.RenderStream(null, null, fileSourceFilter, null, vmr9 as IBaseFilter);
            DsError.ThrowExceptionForHR(hr);

            //// Have the graph builder construct its the appropriate graph automatically
            //hr = this.graphBuilder.RenderFile(filename, null);
            //DsError.ThrowExceptionForHR(hr);

            // QueryInterface for DirectShow interfaces
            this.mediaControl = (IMediaControl)this.graphBuilder;
            //this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
            this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
            //this.mediaPosition = (IMediaPosition)this.graphBuilder;

            // Query for video interfaces, which may not be relevant for audio files
            ////this.videoWindow = this.graphBuilder as IVideoWindow;
            this.basicVideo = this.graphBuilder as IBasicVideo;

            // Query for audio interfaces, which may not be relevant for video-only files
            this.basicAudio = this.graphBuilder as IBasicAudio;

            // Is this an audio-only file (no video component)?
            CheckVisibility();

            //// Have the graph signal event via window callbacks for performance
            //hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero);
            //DsError.ThrowExceptionForHR(hr);

            if (!this.isAudioOnly)
            {
                this.windowLessControl = this.vmr9 as IVMRWindowlessControl9;
                this.windowLessControl.SetVideoClippingWindow(this.Handle);
                this.windowLessControl.SetVideoPosition(null, new DsRect(0, 0, this.ClientSize.Width, this.ClientSize.Height));

                //hr = InitVideoWindow();
                //DsError.ThrowExceptionForHR(hr);

                GetFrameStepInterface();
            }

            // Complete window initialization
            //this.isFullScreen = false;
            this.currentPlaybackRate = 1.0;
            //UpdateToolTip();

#if DEBUG
            rot = new DsROTEntry(this.graphBuilder);
#endif
        }