2009-08-04 07:14:20 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
* 2006 Edgard Lima <edgard.lima@indt.org.br>
|
|
|
|
* 2009 Texas Instruments, Inc - http://www.ti.com/
|
|
|
|
*
|
2010-01-18 12:55:38 +00:00
|
|
|
* gstv4l2bufferpool.h V4L2 buffer pool class
|
2009-08-04 07:14:20 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-08-04 07:14:20 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-13 14:33:58 +00:00
|
|
|
#ifndef __GST_V4L2_BUFFER_POOL_H__
|
|
|
|
#define __GST_V4L2_BUFFER_POOL_H__
|
2009-08-04 07:14:20 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2011-07-13 14:33:58 +00:00
|
|
|
|
|
|
|
typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
|
|
|
|
typedef struct _GstV4l2BufferPoolClass GstV4l2BufferPoolClass;
|
2011-10-31 01:24:04 +00:00
|
|
|
typedef struct _GstV4l2Meta GstV4l2Meta;
|
2011-07-13 14:33:58 +00:00
|
|
|
|
|
|
|
#include "gstv4l2object.h"
|
2009-08-04 07:14:20 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_EXTERN (v4l2buffer_debug);
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
2011-08-04 11:50:01 +00:00
|
|
|
#define GST_TYPE_V4L2_BUFFER_POOL (gst_v4l2_buffer_pool_get_type())
|
|
|
|
#define GST_IS_V4L2_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_BUFFER_POOL))
|
|
|
|
#define GST_V4L2_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_BUFFER_POOL, GstV4l2BufferPool))
|
|
|
|
#define GST_V4L2_BUFFER_POOL_CAST(obj) ((GstV4l2BufferPool*)(obj))
|
2009-08-04 07:14:20 +00:00
|
|
|
|
|
|
|
struct _GstV4l2BufferPool
|
|
|
|
{
|
2011-07-15 09:27:18 +00:00
|
|
|
GstBufferPool parent;
|
2009-08-04 07:14:20 +00:00
|
|
|
|
2011-07-15 12:07:11 +00:00
|
|
|
GstV4l2Object *obj; /* the v4l2 object */
|
2011-07-15 09:27:18 +00:00
|
|
|
gint video_fd; /* a dup(2) of the v4l2object's video_fd */
|
2009-08-04 07:14:20 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
GstAllocator *allocator;
|
2012-03-15 12:36:17 +00:00
|
|
|
GstAllocationParams params;
|
2011-07-18 16:54:49 +00:00
|
|
|
guint size;
|
2011-07-27 11:41:28 +00:00
|
|
|
gboolean add_videometa;
|
2013-05-02 07:41:01 +00:00
|
|
|
gboolean can_alloc; /* if extra buffers can be allocated */
|
2011-07-15 09:27:18 +00:00
|
|
|
|
2012-04-23 16:01:31 +00:00
|
|
|
guint num_buffers; /* number of buffers we use */
|
2011-07-25 13:47:05 +00:00
|
|
|
guint num_allocated; /* number of buffers allocated by the driver */
|
|
|
|
guint num_queued; /* number of buffers queued in the driver */
|
2012-04-23 16:01:31 +00:00
|
|
|
guint copy_threshold; /* when our pool runs lower, start handing out copies */
|
2011-07-15 09:27:18 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
gboolean streaming;
|
|
|
|
|
2011-02-24 12:51:32 +00:00
|
|
|
GstBuffer **buffers;
|
2009-08-04 07:14:20 +00:00
|
|
|
};
|
|
|
|
|
2011-07-11 10:04:57 +00:00
|
|
|
struct _GstV4l2BufferPoolClass
|
|
|
|
{
|
2011-07-15 09:27:18 +00:00
|
|
|
GstBufferPoolClass parent_class;
|
2011-07-11 10:04:57 +00:00
|
|
|
};
|
|
|
|
|
2011-10-31 01:24:04 +00:00
|
|
|
struct _GstV4l2Meta {
|
2011-02-25 15:29:38 +00:00
|
|
|
GstMeta meta;
|
2009-08-04 07:14:20 +00:00
|
|
|
|
2013-11-19 17:16:27 +00:00
|
|
|
/* number of v4l2 planes
|
|
|
|
* In MPLANE and non MPLANE case it can be one so
|
|
|
|
* it contains all yuv planes
|
|
|
|
* In MPLANE mode it can be one per yuv plane.
|
|
|
|
* For example, 2 for NV12 and 3 for I420
|
|
|
|
*
|
|
|
|
* In non MPLANE mode it's always equal to 1
|
|
|
|
* In MPLANE mode it's equivalent to vbuffer.length
|
|
|
|
*/
|
|
|
|
guint n_planes;
|
|
|
|
|
2013-11-13 12:05:40 +00:00
|
|
|
/* only useful in GST_V4L2_IO_MMAP case.
|
|
|
|
* it contains address at which the mapping
|
|
|
|
* was placed for each v4l2 plane */
|
|
|
|
gpointer mem[GST_VIDEO_MAX_PLANES];
|
2013-11-19 17:16:27 +00:00
|
|
|
|
2013-11-13 12:05:40 +00:00
|
|
|
/* plane info for multi-planar buffers */
|
|
|
|
struct v4l2_plane vplanes[GST_VIDEO_MAX_PLANES];
|
2013-11-19 17:16:27 +00:00
|
|
|
|
2013-11-13 12:05:40 +00:00
|
|
|
/* video buffer info */
|
2009-08-04 07:14:20 +00:00
|
|
|
struct v4l2_buffer vbuffer;
|
|
|
|
};
|
|
|
|
|
2012-02-29 16:26:01 +00:00
|
|
|
GType gst_v4l2_meta_api_get_type (void);
|
2011-10-31 01:24:04 +00:00
|
|
|
const GstMetaInfo * gst_v4l2_meta_get_info (void);
|
2012-02-29 16:26:01 +00:00
|
|
|
#define GST_V4L2_META_GET(buf) ((GstV4l2Meta *)gst_buffer_get_meta(buf,gst_v4l2_meta_api_get_type()))
|
2011-10-31 01:24:04 +00:00
|
|
|
#define GST_V4L2_META_ADD(buf) ((GstV4l2Meta *)gst_buffer_add_meta(buf,gst_v4l2_meta_get_info(),NULL))
|
2011-02-25 15:29:38 +00:00
|
|
|
|
2011-07-15 09:27:18 +00:00
|
|
|
GType gst_v4l2_buffer_pool_get_type (void);
|
2011-07-14 14:12:15 +00:00
|
|
|
|
2011-08-04 11:50:01 +00:00
|
|
|
GstBufferPool * gst_v4l2_buffer_pool_new (GstV4l2Object *obj, GstCaps *caps);
|
2011-07-14 14:12:15 +00:00
|
|
|
|
2011-07-27 14:46:46 +00:00
|
|
|
GstFlowReturn gst_v4l2_buffer_pool_process (GstV4l2BufferPool * bpool, GstBuffer * buf);
|
2009-08-04 07:14:20 +00:00
|
|
|
|
2013-12-18 18:37:23 +00:00
|
|
|
gboolean gst_v4l2_buffer_pool_flush (GstV4l2BufferPool * pool);
|
|
|
|
|
2010-01-18 12:57:42 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
2011-07-13 14:33:58 +00:00
|
|
|
#endif /*__GST_V4L2_BUFFER_POOL_H__ */
|