Ejemplo n.º 1
0
        /// <summary>
        /// Get all the resolutions supported by the specified pixel format.
        /// </summary>
        /// <param name="format">Pixel format.</param>
        /// <returns>Supported resolution.</returns>
        public override IEnumerable <(uint Width, uint Height)> GetPixelFormatResolutions(PixelFormat format)
        {
            Initialize();

            v4l2_frmsizeenum size = new v4l2_frmsizeenum()
            {
                index        = 0,
                pixel_format = format
            };

            List <(uint Width, uint Height)> result = new List <(uint Width, uint Height)>();

            while (V4l2Struct(VideoSettings.VIDIOC_ENUM_FRAMESIZES, ref size) != -1)
            {
                result.Add((size.discrete.width, size.discrete.height));
                size.index++;
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get all the resolutions supported by the specified pixel format.
        /// </summary>
        /// <param name="format">Pixel format.</param>
        /// <returns>Supported resolution.</returns>
        public override IEnumerable <Resolution> GetPixelFormatResolutions(PixelFormat format)
        {
            Initialize();

            v4l2_frmsizeenum size = new v4l2_frmsizeenum()
            {
                index        = 0,
                pixel_format = format
            };

            List <Resolution> result = new List <Resolution>();

            while (V4l2Struct(V4l2Request.VIDIOC_ENUM_FRAMESIZES, ref size) != -1)
            {
                Resolution resolution;
                switch (size.type)
                {
                case v4l2_frmsizetypes.V4L2_FRMSIZE_TYPE_DISCRETE:
                    resolution = new Resolution
                    {
                        Type       = ResolutionType.Discrete,
                        MinHeight  = size.discrete.height,
                        MaxHeight  = size.discrete.height,
                        StepHeight = 0,
                        MinWidth   = size.discrete.width,
                        MaxWidth   = size.discrete.width,
                        StepWidth  = 0,
                    };
                    break;

                case v4l2_frmsizetypes.V4L2_FRMSIZE_TYPE_CONTINUOUS:
                    resolution = new Resolution
                    {
                        Type       = ResolutionType.Continuous,
                        MinHeight  = size.stepwise.min_height,
                        MaxHeight  = size.stepwise.max_height,
                        StepHeight = 1,
                        MinWidth   = size.stepwise.min_width,
                        MaxWidth   = size.stepwise.max_width,
                        StepWidth  = 1,
                    };
                    break;

                case v4l2_frmsizetypes.V4L2_FRMSIZE_TYPE_STEPWISE:
                    resolution = new Resolution
                    {
                        Type       = ResolutionType.Stepwise,
                        MinHeight  = size.stepwise.min_height,
                        MaxHeight  = size.stepwise.max_height,
                        StepHeight = size.stepwise.step_height,
                        MinWidth   = size.stepwise.min_width,
                        MaxWidth   = size.stepwise.max_width,
                        StepWidth  = size.stepwise.step_width,
                    };
                    break;

                default:
                    resolution = new Resolution
                    {
                        Type       = ResolutionType.Discrete,
                        MinHeight  = 0,
                        MaxHeight  = 0,
                        StepHeight = 0,
                        MinWidth   = 0,
                        MaxWidth   = 0,
                        StepWidth  = 0,
                    };
                    break;
                }

                result.Add(resolution);
                size.index++;
            }

            return(result);
        }