private void cmbResolution_DropDownClosed(object sender, EventArgs e)
        {
            if (isLoading)
            {
                return;
            }

            if (cmbResolution.SelectedIndex == -1 || lastResolution == cmbResolution.SelectedIndex)
            {
                return;
            }

            lastResolution = cmbResolution.SelectedIndex;

            if (avermediaTools.m_DemoState == DEMOSTATE.DEMO_STATE_PREVIEW)
            {
                avermediaTools.stopStreaming();
            }

            uint nVideoResolution = 0;
            int  nSelIndex        = cmbResolution.SelectedIndex;

            nVideoResolution = (uint)m_VideoResolutionList[nSelIndex];

            VIDEO_RESOLUTION VideoResolution = AVerCapAPI.GetVideoResolutionByIndex(nVideoResolution);

            VideoResolution.dwVersion = 1;
            VideoResolution.bCustom   = 0;
            avermediaTools.ChangeVideoResolution(VideoResolution);

            if (avermediaTools.m_DemoState == DEMOSTATE.DEMO_STATE_PREVIEW)
            {
                avermediaTools.startStreaming(refreshDeviceSettings: false);
            }
        }
        public bool InitFrameRate()
        {
            if (m_bIsRangeFramerate)
            {
                cmbFrameRate.Enabled = false;
                //textBox_FrameRate.IsEnabled = true;
                //button_SetFrameRate.IsEnabled = true;
                uint uFrameRate = 0;
                int  ir         = AVerCapAPI.AVerGetVideoInputFrameRate(avermediaTools.CaptureDeviceHandle, ref uFrameRate);
                if (ir != (int)ERRORCODE.CAP_EC_SUCCESS)
                {
                    return(false);
                }
                //textBox_FrameRate.Text = uFrameRate.ToString();
            }
            else
            {
                cmbFrameRate.Enabled = true;
                cmbFrameRate.Items.Clear();
                uint uNum = 0;
                int  lr   = 0;

                VIDEO_RESOLUTION VideoResolution = avermediaTools.GetActualVideoResolution();
                lr = AVerCapAPI.AVerGetVideoInputFrameRateSupportedEx(avermediaTools.CaptureDeviceHandle, m_uVideoSource, m_uVideoFormat, VideoResolution.dwVideoResolution, null, ref uNum);
                uint[] pdwSupported = new uint[uNum];
                if (lr != (int)ERRORCODE.CAP_EC_SUCCESS)
                {
                    if (lr == (int)ERRORCODE.CAP_EC_NOT_SUPPORTED)
                    {
                        cmbFrameRate.Enabled = false;
                        return(true);
                    }
                    return(false);
                }
                uint dwVideoFrameRate = 0;
                AVerCapAPI.AVerGetVideoInputFrameRate(avermediaTools.CaptureDeviceHandle, ref dwVideoFrameRate);
                lr = AVerCapAPI.AVerGetVideoInputFrameRateSupportedEx(avermediaTools.CaptureDeviceHandle, m_uVideoSource, m_uVideoFormat, VideoResolution.dwVideoResolution, pdwSupported, ref uNum);
                if (lr != (int)ERRORCODE.CAP_EC_SUCCESS)
                {
                    return(false);
                }
                bool bSelected = false;
                for (int i = 0; i < uNum; i++)
                {
                    cmbFrameRate.Items.Add(pdwSupported[i].ToString());
                    if (pdwSupported[i] == dwVideoFrameRate)
                    {
                        cmbFrameRate.SelectedIndex = i;
                        lastFrameRate = cmbFrameRate.SelectedIndex;
                        bSelected     = true;
                    }
                }
                if (!bSelected)
                {
                    cmbFrameRate.SelectedIndex = 0;
                    lastFrameRate = cmbFrameRate.SelectedIndex;
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public LocalStreamer(uint deviceId, IntPtr controlHandle, VIDEOSOURCE videoSource, CAPTURETYPE captureType, uint imageWidth, uint imageHeight, VIDEORESOLUTION resolution, VIDEOFORMAT format = VIDEOFORMAT.VIDEOFORMAT_NTSC)
        {
            DeviceId = deviceId;

            AVerCapAPI.AVerCreateCaptureObjectEx(DeviceId, (uint)captureType, controlHandle, ref _captureObject);

            var videoResolution = new VIDEO_RESOLUTION()
            {
                dwVideoResolution = (uint)resolution,
                dwVersion         = 1
            };

            AVerCapAPI.AVerSetVideoFormat(_captureObject, (uint)format);
            AVerCapAPI.AVerSetVideoSource(_captureObject, (uint)videoSource);
            AVerCapAPI.AVerSetVideoResolutionEx(_captureObject, ref videoResolution);
            AVerCapAPI.AVerSetVideoRenderer(_captureObject, (uint)VIDEORENDERER.VIDEORENDERER_VMR9);
            AVerCapAPI.AVerSetVideoPreviewEnabled(_captureObject, 1);
            AVerCapAPI.AVerSetVideoInputFrameRate(_captureObject, 5900);
            AVerCapAPI.AVerSetVideoOutputFrameRate(_captureObject, 5900);
            AVerCapAPI.AVerSetVideoEnhanceMode(_captureObject, (uint)VIDEOENHANCE.VIDEOENHANCE_NONE);
            AVerCapAPI.AVerSetMaintainAspectRatioEnabled(_captureObject, 1);

            var rectClient = new RECT
            {
                Left   = 0,
                Top    = 0,
                Right  = (int)imageWidth,
                Bottom = (int)imageHeight
            };

            AVerCapAPI.AVerSetVideoWindowPosition(_captureObject, rectClient);
        }
        private void InitVideoResolution()
        {
            m_VideoResolutionList.Clear();
            cmbResolution.Items.Clear();

            AVerCapAPI.AVerGetVideoSource(avermediaTools.CaptureDeviceHandle, ref m_uVideoSource);
            AVerCapAPI.AVerGetVideoFormat(avermediaTools.CaptureDeviceHandle, ref m_uVideoFormat);
            uint SolutionNum = 0;

            AVerCapAPI.AVerGetVideoResolutionSupported(avermediaTools.CaptureDeviceHandle, m_uVideoSource, m_uVideoFormat, null, ref SolutionNum);
            uint[] pdwSupported = new uint[SolutionNum];
            AVerCapAPI.AVerGetVideoResolutionSupported(avermediaTools.CaptureDeviceHandle, m_uVideoSource, m_uVideoFormat, pdwSupported, ref SolutionNum);

            uint             m_uVideoResolution = 0;
            VIDEO_RESOLUTION VideoResolution    = avermediaTools.GetActualVideoResolution();

            m_uVideoResolution = VideoResolution.dwVideoResolution;
            int index = 0;

            foreach (uint i in pdwSupported)
            {
                m_VideoResolutionList.Add(i);

                switch (i)
                {
                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_640X480:
                    cmbResolution.Items.Add("640X480");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_704X576:
                    cmbResolution.Items.Add("704X576");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_720X480:
                    cmbResolution.Items.Add("720X480");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_720X576:
                    cmbResolution.Items.Add("720X576");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1920X1080:
                    cmbResolution.Items.Add("1920X1080");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_160X120:
                    cmbResolution.Items.Add("160X120");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_176X144:
                    cmbResolution.Items.Add("176X144");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_240X176:
                    cmbResolution.Items.Add("240X176");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_240X180:
                    cmbResolution.Items.Add("240X180");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_320X240:
                    cmbResolution.Items.Add("320X240");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_352X240:
                    cmbResolution.Items.Add("352X240");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_352X288:
                    cmbResolution.Items.Add("352X288");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_640X240:
                    cmbResolution.Items.Add("640X240");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_640X288:
                    cmbResolution.Items.Add("640X288");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_720X240:
                    cmbResolution.Items.Add("720X240");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_720X288:
                    cmbResolution.Items.Add("720X288");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_80X60:
                    cmbResolution.Items.Add("80X60  ");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_88X72:
                    cmbResolution.Items.Add("88X72  ");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_128X96:
                    cmbResolution.Items.Add("128X96 ");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_640X576:
                    cmbResolution.Items.Add("640X576");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_180X120:
                    cmbResolution.Items.Add("180X120");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_180X144:
                    cmbResolution.Items.Add("180X144");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_360X240:
                    cmbResolution.Items.Add("360X240");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_360X288:
                    cmbResolution.Items.Add("360X288");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_768X576:
                    cmbResolution.Items.Add("768X576");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_384x288:
                    cmbResolution.Items.Add("384x288");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_192x144:
                    cmbResolution.Items.Add("192x144 ");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1280X720:
                    cmbResolution.Items.Add("1280X720");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1024X768:
                    cmbResolution.Items.Add("1024X768");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1280X800:
                    cmbResolution.Items.Add("1280X800");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1280X1024:
                    cmbResolution.Items.Add("1280X1024");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1440X900:
                    cmbResolution.Items.Add("1440X900");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1600X1200:
                    cmbResolution.Items.Add("1600X1200");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1680X1050:
                    cmbResolution.Items.Add("1680X1050");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_800X600:
                    cmbResolution.Items.Add("800X600");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1280X768:
                    cmbResolution.Items.Add("1280X768");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1360X768:
                    cmbResolution.Items.Add("1360X768");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1152X864:
                    cmbResolution.Items.Add("1152X864");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1280X960:
                    cmbResolution.Items.Add("1280X960");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_702X576:
                    cmbResolution.Items.Add("702X576");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_720X400:
                    cmbResolution.Items.Add("720X400");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1152X900:
                    cmbResolution.Items.Add("1152X900");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1360X1024:
                    cmbResolution.Items.Add("1360X1024");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1366X768:
                    cmbResolution.Items.Add("1366X768");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1400X1050:
                    cmbResolution.Items.Add("1400X1050");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1440X480:
                    cmbResolution.Items.Add("1440X480");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1440X576:
                    cmbResolution.Items.Add("1440X576");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1600X900:
                    cmbResolution.Items.Add("1600X900");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1920X1200:
                    cmbResolution.Items.Add("1920X1200");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1440X1080:
                    cmbResolution.Items.Add("1440X1080");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1600X1024:
                    cmbResolution.Items.Add("1600X1024");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_3840X2160:
                    cmbResolution.Items.Add("3840X2160");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1152X768:
                    cmbResolution.Items.Add("1152X768");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_176X120:
                    cmbResolution.Items.Add("176X120");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_704X480:
                    cmbResolution.Items.Add("704X480");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1792X1344:
                    cmbResolution.Items.Add("1792X1344");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1856X1392:
                    cmbResolution.Items.Add("1856X1392");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_1920X1440:
                    cmbResolution.Items.Add("1920X1440");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_2048X1152:
                    cmbResolution.Items.Add("2048X1152");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_2560X1080:
                    cmbResolution.Items.Add("2560X1080");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_2560X1440:
                    cmbResolution.Items.Add("2560X1440");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_2560X1600:
                    cmbResolution.Items.Add("2560X1600");
                    index = index + 1;
                    break;

                case (uint)VIDEORESOLUTION.VIDEORESOLUTION_4096X2160:
                    cmbResolution.Items.Add("4096X2160");
                    index = index + 1;
                    break;
                }

                if (m_uVideoResolution == i)
                {
                    cmbResolution.SelectedIndex = index - 1;
                    lastResolution = cmbResolution.SelectedIndex;
                }
            }

            string videoWidth  = VideoResolution.dwWidth.ToString();
            string videoHeight = VideoResolution.dwHeight.ToString();

            if (VideoResolution.bCustom == 1)
            {
                cmbResolution.Enabled = false;
            }
            else
            {
                cmbResolution.Enabled = true;
            }
        }