Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (!(obj is VMR9NormalizedRect))
            {
                return(false);
            }

            VMR9NormalizedRect other = (VMR9NormalizedRect)obj;

            return(this == other);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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;
        }