]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/v4l2_buffers.h
avdevice/avdevice: Constify avdevice_list_input_sources/output_sinks
[ffmpeg] / libavcodec / v4l2_buffers.h
index e28a4a650d7630f2e5495cf2273b1ed2fe93b857..8dbc7fc104d9d6969bba90c2cd690f6582d48a75 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef AVCODEC_V4L2_BUFFERS_H
 #define AVCODEC_V4L2_BUFFERS_H
 
+#include <stdatomic.h>
 #include <linux/videodev2.h>
 
 #include "avcodec.h"
@@ -41,6 +42,11 @@ typedef struct V4L2Buffer {
     /* each buffer needs to have a reference to its context */
     struct V4L2Context *context;
 
+    /* This object is refcounted per-plane, so we need to keep track
+     * of how many context-refs we are holding. */
+    AVBufferRef *context_ref;
+    atomic_uint context_refcount;
+
     /* keep track of the mmap address and mmap length */
     struct V4L2Plane_info {
         int bytesperline;
@@ -66,7 +72,7 @@ typedef struct V4L2Buffer {
  * @param[in] buf The V4L2Buffer to get the information from
  *
  * @returns 0 in case of success, AVERROR(EINVAL) if the number of planes is incorrect,
- * AVERROR(ENOMEM) if the AVBufferRef cant be created.
+ * AVERROR(ENOMEM) if the AVBufferRef can't be created.
  */
 int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *buf);
 
@@ -77,7 +83,7 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *buf);
  * @param[in] buf The V4L2Buffer to get the information from
  *
  * @returns 0 in case of success, AVERROR(EINVAL) if the number of planes is incorrect,
- * AVERROR(ENOMEM) if the AVBufferRef cant be created.
+ * AVERROR(ENOMEM) if the AVBufferRef can't be created.
  *
  */
 int ff_v4l2_buffer_buf_to_avpkt(AVPacket *pkt, V4L2Buffer *buf);
@@ -100,7 +106,7 @@ int ff_v4l2_buffer_avpkt_to_buf(const AVPacket *pkt, V4L2Buffer *out);
  *
  * @returns 0 in case of success, a negative AVERROR code otherwise
  */
-int ff_v4l2_buffer_avframe_to_buf(const AVFrame *frame, V4L2Bufferout);
+int ff_v4l2_buffer_avframe_to_buf(const AVFrame *frame, V4L2Buffer *out);
 
 /**
  * Initializes a V4L2Buffer