示例#1
0
        public void Open()
        {
            Console.WriteLine("Open");

            //_fd = NativeMethods.v4l2_open(_dev_file, O_RDWR);
            _fd = NativeMethods.open(_dev_file, O_RDWR);
            Console.WriteLine("fd = {0}", _fd);
            if (_fd < 0)
            {
                throw new ApplicationException("Cannot open V4L2 device. Is the device locked somewhere?");
            }

            NativeMethods.v4l2_format fmt = new NativeMethods.v4l2_format();
            fmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
            //fmt.fmt.sdr.pixelformat = V4L2_PIX_FMT_SDR_U8;
            fmt.fmt.sdr.pixelformat = V4L2_SDR_FMT_CU16LE;
            Console.WriteLine("request fmt.pixelformat = {0}", fmt.fmt.sdr.pixelformat);

            //var v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_S_FMT, ref fmt);
            var v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_S_FMT, ref fmt);

            Console.WriteLine("v4l2_ioctl r = {0} sdr.pixelformat = {1}", v4l2_r, fmt.fmt.sdr.pixelformat);

            if (fmt.fmt.sdr.pixelformat != V4L2_SDR_FMT_CU16LE)
            {
                // throw exception?
                Console.WriteLine("Device didn't accept format!");
            }
        }
示例#2
0
        public void Open()
        {
            Console.WriteLine("Open");

            //_fd = NativeMethods.v4l2_open(_dev_file, O_RDWR);
            _fd = NativeMethods.open(_dev_file, O_RDWR);
            Console.WriteLine("fd = {0}", _fd);
            if (_fd < 0)
            {
                throw new ApplicationException("Cannot open V4L2 device. Is the device locked somewhere?");
            }

            NativeMethods.v4l2_format fmt = new NativeMethods.v4l2_format();
            fmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
            //fmt.fmt.sdr.pixelformat = V4L2_PIX_FMT_SDR_U8;
            fmt.fmt.sdr.pixelformat = V4L2_SDR_FMT_CU16LE;
            Console.WriteLine("request fmt.pixelformat = {0}", fmt.fmt.sdr.pixelformat);

            //var v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_S_FMT, ref fmt);
            var v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_S_FMT, ref fmt);
            Console.WriteLine("v4l2_ioctl r = {0} sdr.pixelformat = {1}", v4l2_r, fmt.fmt.sdr.pixelformat);

            if (fmt.fmt.sdr.pixelformat != V4L2_SDR_FMT_CU16LE) {
                // throw exception?
                Console.WriteLine("Device didn't accept format!");
            }
        }