/// <summary> /// Queries the device for information about each requested buffer. /// </summary> /// <param name="req">Struct with information about the request buffers.</param> private void fetchBuffers(v4l2_requestbuffers req) { for(uint i=0; i < req.count; i++) { v4l2_buffer buffer = new v4l2_buffer(); buffer.index = i; buffer.type = req.type; buffer.memory = req.memory; if(ioControl.QueryBuffer(ref buffer) < 0) throw new Exception("VIDIOC_QUERYBUF"); buffers.Add(new Analog.Buffer(this, buffer)); } }
/// <summary> /// Requests a given number of buffers for mmap data transfer. /// </summary> private void requestBuffers() { v4l2_requestbuffers req = new v4l2_requestbuffers(); req.count = bufferCount; req.type = v4l2_buf_type.VideoCapture; req.memory = v4l2_memory.MemoryMapping; if(ioControl.RequestBuffers(ref req) < 0) throw new Exception("VIDIOC_REQBUFS"); if(req.count < bufferCount) throw new Exception("VIDIOC_REQBUFS [count]"); fetchBuffers(req); }
ioctl(int device, v4l2_operation request, ref v4l2_requestbuffers argp);
/// <summary> /// Calls VIDIOC_REQBUFS. /// </summary> public int RequestBuffers(ref v4l2_requestbuffers req) { return ioctl(deviceHandle, v4l2_operation.RequestBuffers, ref req); }
private static extern int ioctl(int device, v4l2_operation request, ref v4l2_requestbuffers argp);