/// <summary> /// Creates a buffer to be used with Video4Linux streaming I/O. /// </summary> /// <param name="device">The parental Video4Linux device.</param> /// <param name="buffer">The struct holding the buffer information.</param> internal V4LBuffer(V4LDevice device, v4l2_buffer buffer) { this.device = device; this.buffer = buffer; mapMemory(); }
private void threadTest() { APIv2.v4l2_buffer buf = new APIv2.v4l2_buffer(); buf.type = Buffers[0].Type; buf.memory = Buffers[0].Memory; while (ioControl.DequeueBuffer(ref buf) == 0) { V4LBuffer dbuf = Buffers[(int)buf.index]; // invoke the event if (BufferFilled != null) BufferFilled(this, dbuf); // Re-enqueue the buffer dbuf.Enqueue(); } }
private void fetchBuffers(APIv2.v4l2_requestbuffers req) { for (uint i=0; i<req.count; i++) { APIv2.v4l2_buffer buffer = new APIv2.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 V4LBuffer(this, buffer)); } }
/// <summary> /// Tries to dequeue a buffer and fires the 'BufferFilled' event if the buffer was filled by the driver. /// </summary> private void captureFromBuffers() { v4l2_buffer buf = new v4l2_buffer(); buf.type = Buffers[0].Type; buf.memory = Buffers[0].Memory; while (ioControl.DequeueBuffer(ref buf) == 0) { V4LBuffer dbuf = Buffers[(int)buf.index]; // invoke the event if (BufferFilled != null) BufferFilled(this, dbuf); // re-enqueue the buffer dbuf.Enqueue(); } }
/// <summary> /// Calls VIDIOC_QBUF. /// </summary> public int EnqueueBuffer(ref v4l2_buffer buffer) { return ioctl(deviceHandle, v4l2_operation.EnqueueBuffer, ref buffer); }
private static extern int ioctl(int device, v4l2_operation request, ref v4l2_buffer argp);
/// <summary> /// Calls VIDIOC_QUERYBUF. /// </summary> public int QueryBuffer(ref v4l2_buffer buffer) { return ioctl(deviceHandle, v4l2_operation.QueryBuffer, ref buffer); }