Exemple #1
0
 private void MainForm_ResizeMove(object sender, EventArgs e)
 {
     if (windowlessCtrl != null)
     {
         int hr = windowlessCtrl.SetVideoPosition(null, DsRect.FromRectangle(this.ClientRectangle));
     }
 }
    private void SetSize()
    {
        var srcRect = new DsRect();
        var dstRect = new DsRect(ClientRectangle);
        int arWidth, arHeight;

        _windowlessControl.GetNativeVideoSize(out srcRect.right, out srcRect.bottom, out arWidth, out arHeight);
        _windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
        _windowlessControl.SetVideoPosition(srcRect, dstRect);
    }
Exemple #3
0
 /// <summary>
 /// Handler of Resize and Move events of HostingControl.
 /// </summary>
 private void HostingControl_ResizeMove
 (
     object sender,
     EventArgs e
 )
 {
     if (_bGraphIsBuilt)
     {
         WindowlessCtrl.SetVideoPosition(null, DsRect.FromRectangle(_DisplayPanel.ClientRectangle));
     }
     return;
 }
        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;
        }
Exemple #5
0
 private void MainForm_ResizeMove(object sender, EventArgs e)
 {
     try
     {
         if (windowlessCtrl != null)
         {
             FilterState fs;// wait for pause to complete
             mediaControl.GetState(2000, out fs);
             //      if (fs == FilterState.Running)
             {
                 int hr = windowlessCtrl.SetVideoPosition(null, DsRect.FromRectangle(this.m_ParentPanel.ClientRectangle));
             }
         }
     }
     catch (Exception ex)
     {
         m_Log.Log("sourceVideoFile MainForm_ResizeMove: ex: " + ex.Message, ErrorLog.LOG_TYPE.FATAL);
     }
 }
Exemple #6
0
 public override void SetVideoPosition(GDI.RECT rcSrc, GDI.RECT rcDest)
 {
     _pVMRWindowlessControl9.SetVideoPosition(/*ref rcSrc*/ IntPtr.Zero, ref rcDest);
 }
Exemple #7
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);
        }