public void Start(SamplesAvailableDelegate callback) { int v4l2_r; Console.WriteLine("Start"); Samplerate = _sampleRate; // set sampling rate NativeMethods.v4l2_requestbuffers req = new NativeMethods.v4l2_requestbuffers(); req.count = 10; // nbuffers to driver req.type = V4L2_BUF_TYPE_SDR_CAPTURE; req.memory = V4L2_MEMORY_MMAP; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req); Console.WriteLine("CMD64_VIDIOC_REQBUFS v4l2_ioctl r = {0} req.count = {1}", v4l2_r, req.count); // v4l2_mmap buffers mmap_start = new IntPtr [req.count]; mmap_length = new UInt32 [req.count]; // mmap = new Mmap [req.count]; for (n_buffers = 0; n_buffers < req.count; n_buffers++) { buf.type = V4L2_BUF_TYPE_SDR_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = n_buffers; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf); // mmap[n_buffers].length = buf.length; // mmap[n_buffers].start = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); mmap_length[n_buffers] = buf.length; //mmap_start[n_buffers] = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); mmap_start[n_buffers] = NativeMethods.mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); Console.WriteLine("CMD64_VIDIOC_QUERYBUF v4l2_ioctl r = {0} mmap_start[n_buffers] = {1}", v4l2_r, mmap_start[n_buffers]); } //Exchange a buffer with the driver for (uint i = 0; i < n_buffers; i++) { //CLEAR(buf); buf.type = V4L2_BUF_TYPE_SDR_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = i; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf); Console.WriteLine("CMD64_VIDIOC_QBUF v4l2_ioctl r = {0} buf.index = {1}", v4l2_r, buf.index); } // start streaming int type = V4L2_BUF_TYPE_SDR_CAPTURE; int *ptr = &type; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr); Console.WriteLine("CMD64_VIDIOC_STREAMON v4l2_ioctl r = {0}", v4l2_r); _callback = callback; // set device parameters here streaming = true; _sampleThread = new Thread(ReceiveData); _sampleThread.Start(); }
public void Start(SamplesAvailableDelegate callback) { int v4l2_r; Console.WriteLine("Start"); Samplerate = _sampleRate; // set sampling rate NativeMethods.v4l2_requestbuffers req = new NativeMethods.v4l2_requestbuffers(); req.count = 10; // nbuffers to driver req.type = V4L2_BUF_TYPE_SDR_CAPTURE; req.memory = V4L2_MEMORY_MMAP; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req); Console.WriteLine("CMD64_VIDIOC_REQBUFS v4l2_ioctl r = {0} req.count = {1}", v4l2_r, req.count); // v4l2_mmap buffers mmap_start = new IntPtr [req.count]; mmap_length = new UInt32 [req.count]; // mmap = new Mmap [req.count]; for (n_buffers = 0; n_buffers < req.count; n_buffers++) { buf.type = V4L2_BUF_TYPE_SDR_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = n_buffers; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf); // mmap[n_buffers].length = buf.length; // mmap[n_buffers].start = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); mmap_length[n_buffers] = buf.length; //mmap_start[n_buffers] = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); mmap_start[n_buffers] = NativeMethods.mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); Console.WriteLine("CMD64_VIDIOC_QUERYBUF v4l2_ioctl r = {0} mmap_start[n_buffers] = {1}", v4l2_r, mmap_start[n_buffers]); } //Exchange a buffer with the driver for (uint i = 0; i < n_buffers; i++) { //CLEAR(buf); buf.type = V4L2_BUF_TYPE_SDR_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = i; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf); Console.WriteLine("CMD64_VIDIOC_QBUF v4l2_ioctl r = {0} buf.index = {1}", v4l2_r, buf.index); } // start streaming int type = V4L2_BUF_TYPE_SDR_CAPTURE; int *ptr = & type; //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr); v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr); Console.WriteLine("CMD64_VIDIOC_STREAMON v4l2_ioctl r = {0}", v4l2_r); _callback = callback; // set device parameters here streaming = true; _sampleThread = new Thread(ReceiveData); _sampleThread.Start(); }