omxvideoenc: drain encoder on ALLOCATION and DRAIN queries
[platform/upstream/gstreamer.git] / omx / gstomxbufferpool.h
1 /*
2  * Copyright 2014 Advanced Micro Devices, Inc.
3  *   Author: Christian König <christian.koenig@amd.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation
8  * version 2.1 of the License.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
18  *
19  */
20
21 #ifndef __GST_OMX_BUFFER_POOL_H__
22 #define __GST_OMX_BUFFER_POOL_H__
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <gst/gst.h>
29 #include <gst/video/gstvideometa.h>
30 #include <gst/video/gstvideopool.h>
31
32 #include "gstomx.h"
33 #include "gstomxallocator.h"
34
35 G_BEGIN_DECLS
36
37 #define GST_TYPE_OMX_BUFFER_POOL \
38   (gst_omx_buffer_pool_get_type())
39 #define GST_OMX_BUFFER_POOL(obj) \
40   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_BUFFER_POOL,GstOMXBufferPool))
41 #define GST_IS_OMX_BUFFER_POOL(obj) \
42   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_BUFFER_POOL))
43
44 typedef struct _GstOMXBufferPool GstOMXBufferPool;
45 typedef struct _GstOMXBufferPoolClass GstOMXBufferPoolClass;
46
47 typedef enum {
48   GST_OMX_BUFFER_MODE_SYSTEM_MEMORY,
49   GST_OMX_BUFFER_MODE_DMABUF,
50 } GstOMXBufferMode;
51
52 struct _GstOMXBufferPool
53 {
54   GstVideoBufferPool parent;
55
56   GstElement *element;
57
58   GstCaps *caps;
59   gboolean add_videometa;
60   gboolean need_copy;
61   GstVideoInfo video_info;
62
63   /* Owned by element, element has to stop this pool before
64    * it destroys component or port */
65   GstOMXComponent *component;
66   GstOMXPort *port;
67
68   /* For handling OpenMAX allocated memory */
69   GstOMXAllocator *allocator;
70
71   /* Set from outside this pool */
72   /* TRUE if the pool is not used anymore */
73   gboolean deactivated;
74
75   /* For populating the pool from another one */
76   GstBufferPool *other_pool;
77   GPtrArray *buffers;
78
79   /* Used during acquire for output ports to
80    * specify which buffer has to be retrieved
81    * and during alloc, which buffer has to be
82    * wrapped
83    */
84   gint current_buffer_index;
85
86   /* The type of buffers produced by the decoder */
87   GstOMXBufferMode output_mode;
88 };
89
90 struct _GstOMXBufferPoolClass
91 {
92   GstVideoBufferPoolClass parent_class;
93 };
94
95 GType gst_omx_buffer_pool_get_type (void);
96
97 GstBufferPool *gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component, GstOMXPort * port, GstOMXBufferMode output_mode);
98
99 G_END_DECLS
100
101 #endif /* __GST_OMX_BUFFER_POOL_H__ */