/// <summary> /// Creates a video capture/output format. /// </summary> /// <param name="device">The parental Video4Linux device.</param> /// <param name="type">The buffer type the format belongs to.</param> internal V4LOverlayFormat(V4LDevice device, v4l2_buf_type type) { this.device = device; format = new v4l2_format(); format.type = type; }
internal V4LVideoFormat(V4LDevice device, v4l2_buf_type type) { this.device = device; format = new v4l2_format(); format.type = type; getFormat(); }
/// <summary> /// Stops the streaming I/O. /// </summary> public void StopStreaming() { // nothing to do here if we use read/write to capture if (captureMethod == CaptureMethod.ReadWrite) { return; } // destroy the buffers buffers = new List <Analog.Buffer>(); v4l2_buf_type type = v4l2_buf_type.VideoCapture; if (ioControl.StreamingOff(ref type) < 0) { throw new Exception("VIDIOC_STREAMOFF"); } }
private unsafe byte[] ProcessCaptureData() { fixed(V4l2FrameBuffer *buffers = &ApplyFrameBuffers()[0]) { // Start data stream v4l2_buf_type type = v4l2_buf_type.V4L2_BUF_TYPE_VIDEO_CAPTURE; Interop.ioctl(_deviceFileDescriptor, (int)VideoSettings.VIDIOC_STREAMON, new IntPtr(&type)); byte[] dataBuffer = GetFrameData(buffers); // Close data stream Interop.ioctl(_deviceFileDescriptor, (int)VideoSettings.VIDIOC_STREAMOFF, new IntPtr(&type)); UnmappingFrameBuffers(buffers); return(dataBuffer); } }
public override unsafe void CaptureContinuous(CancellationToken token) { _capturing = true; fixed(V4l2FrameBuffer *buffers = &ApplyFrameBuffers()[0]) { // Start data stream v4l2_buf_type type = v4l2_buf_type.V4L2_BUF_TYPE_VIDEO_CAPTURE; Interop.ioctl(_deviceFileDescriptor, V4l2Request.VIDIOC_STREAMON, new IntPtr(&type)); while (!token.IsCancellationRequested) { NewImageBufferReady?.Invoke(this, GetFrameDataPooled(buffers)); } // Close data stream Interop.ioctl(_deviceFileDescriptor, V4l2Request.VIDIOC_STREAMOFF, new IntPtr(&type)); UnmappingFrameBuffers(buffers); } _capturing = false; }
/// <summary> /// Starts the streaming I/O. /// </summary> public void StartStreaming() { // nothing to do here if we use read/write to capture if (captureMethod == CaptureMethod.ReadWrite) { return; } // request the streaming buffers if necessary if (buffers == null || buffers.Count != bufferCount) { requestBuffers(); } // make sure that all buffers are in the incoming queue enqueueAllBuffers(); v4l2_buf_type type = v4l2_buf_type.VideoCapture; if (ioControl.StreamingOn(ref type) < 0) { throw new Exception("VIDIOC_STREAMON"); } }
/// <summary> /// Calls VIDIOC_STREAMOFF. /// </summary> public int StreamingOff(ref v4l2_buf_type type) { return ioctl(deviceHandle, v4l2_operation.StreamingOff, ref type); }
ioctl(int device, v4l2_operation request, ref v4l2_buf_type argp);
private static extern int ioctl(int device, v4l2_operation request, ref v4l2_buf_type argp);
/// <summary> /// Calls VIDIOC_STREAMOFF. /// </summary> public int StreamingOff(ref v4l2_buf_type type) { return(ioctl(deviceHandle, v4l2_operation.StreamingOff, ref type)); }