Tizen 2.1 base
[profile/ivi/gst-openmax0.10.git] / omx / gstomx_base_filter.h
1 /*
2  * Copyright (C) 2007-2009 Nokia Corporation.
3  *
4  * Author: Felipe Contreras <felipe.contreras@nokia.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation
9  * version 2.1 of the License.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef GSTOMX_BASE_FILTER_H
23 #define GSTOMX_BASE_FILTER_H
24
25 #include <gst/gst.h>
26 #include <gst/base/gstadapter.h>
27 #include "gstomx_util.h"
28 #include <async_queue.h>
29
30 G_BEGIN_DECLS
31 #define GST_OMX_BASE_FILTER_TYPE (gst_omx_base_filter_get_type ())
32 #define GST_OMX_BASE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_OMX_BASE_FILTER_TYPE, GstOmxBaseFilter))
33 #define GST_OMX_BASE_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_OMX_BASE_FILTER_TYPE, GstOmxBaseFilterClass))
34 #define GST_OMX_BASE_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_OMX_BASE_FILTER_TYPE, GstOmxBaseFilterClass))
35 typedef struct GstOmxBaseFilter GstOmxBaseFilter;
36 typedef struct GstOmxBaseFilterClass GstOmxBaseFilterClass;
37 typedef void (*GstOmxBaseFilterCb) (GstOmxBaseFilter * self);
38 typedef gboolean (*GstOmxBaseFilterEventCb) (GstPad * pad, GstEvent * event);
39
40
41 /* using common scmn_imgb format */
42 #define SCMN_IMGB_MAX_PLANE         (4) /* max channel count */
43
44 /* image buffer definition
45     +------------------------------------------+ ---
46     |                                          |  ^
47     |     a[], p[]                             |  |
48     |     +---------------------------+ ---    |  |
49     |     |                           |  ^     |  |
50     |     |<---------- w[] ---------->|  |     |  |
51     |     |                           |  |     |  |
52     |     |                           |        |
53     |     |                           |  h[]   |  e[]
54     |     |                           |        |
55     |     |                           |  |     |  |
56     |     |                           |  |     |  |
57     |     |                           |  v     |  |
58     |     +---------------------------+ ---    |  |
59     |                                          |  v
60     +------------------------------------------+ ---
61
62     |<----------------- s[] ------------------>|
63 */
64
65 typedef struct
66 {
67     int      w[SCMN_IMGB_MAX_PLANE];    /* width of each image plane */
68     int      h[SCMN_IMGB_MAX_PLANE];    /* height of each image plane */
69     int      s[SCMN_IMGB_MAX_PLANE];    /* stride of each image plane */
70     int      e[SCMN_IMGB_MAX_PLANE];    /* elevation of each image plane */
71     void   * a[SCMN_IMGB_MAX_PLANE];    /* user space address of each image plane */
72     void   * p[SCMN_IMGB_MAX_PLANE];    /* physical address of each image plane, if needs */
73     int      cs;    /* color space type of image */
74     int      x;    /* left postion, if needs */
75     int      y;    /* top position, if needs */
76     int      __dummy2;    /* to align memory */
77     int      data[16];    /* arbitrary data */
78
79     /* dmabuf fd */
80     int fd[SCMN_IMGB_MAX_PLANE];
81
82     /* flag for buffer share */
83     int buf_share_method;
84 } SCMN_IMGB;
85
86 /* MODIFICATION: Add extended_color_format */
87 typedef enum _EXT_OMX_COLOR_FORMATTYPE {
88     OMX_EXT_COLOR_FormatNV12TPhysicalAddress = 0x7F000001, /**< Reserved region for introducing Vendor Extensions */
89     OMX_EXT_COLOR_FormatNV12LPhysicalAddress = 0x7F000002,
90     OMX_EXT_COLOR_FormatNV12Tiled = 0x7FC00002,
91     OMX_EXT_COLOR_FormatNV12TFdValue = 0x7F000012,
92     OMX_EXT_COLOR_FormatNV12LFdValue = 0x7F000013
93 }EXT_OMX_COLOR_FORMATTYPE;
94
95 typedef enum GstOmxReturn
96 {
97     GSTOMX_RETURN_OK,
98     GSTOMX_RETURN_SKIP,
99     GSTOMX_RETURN_ERROR
100 }GstOmxReturn;
101
102 typedef enum GstOmxChangeState
103 {
104     GstOmx_ToLoaded,
105     GstOmx_LodedToIdle,
106     GstOmx_IdleToExcuting
107 }GstOmxChangeState;
108
109 struct GstOmxBaseFilter
110 {
111   GstElement element;
112
113   GstPad *sinkpad;
114   GstPad *srcpad;
115
116   GOmxCore *gomx;
117   GOmxPort *in_port;
118   GOmxPort *out_port;
119
120   gboolean use_timestamps;   /** @todo remove; timestamps should always be used */
121   gboolean ready;
122   GMutex *ready_lock;
123
124   GstOmxBaseFilterCb omx_setup;
125   GstOmxBaseFilterEventCb pad_event;
126   GstFlowReturn last_pad_push_return;
127   GstBuffer *codec_data;
128
129   /* MODIFICATION: state-tuning */
130   gboolean use_state_tuning;
131
132   GstAdapter *adapter;  /* adapter */
133   guint adapter_size;
134 };
135
136 struct GstOmxBaseFilterClass
137 {
138   GstElementClass parent_class;
139
140   GstOmxReturn (*process_input_buf)(GstOmxBaseFilter *omx_base_filter, GstBuffer **buf);
141   GstOmxReturn (*process_output_buf)(GstOmxBaseFilter *omx_base_filter, GstBuffer **buf, OMX_BUFFERHEADERTYPE *omx_buffer);
142   void (*process_output_caps)(GstOmxBaseFilter *omx_base_filter, OMX_BUFFERHEADERTYPE *omx_buffer);
143
144 };
145
146 GType gst_omx_base_filter_get_type (void);
147
148 G_END_DECLS
149 #endif /* GSTOMX_BASE_FILTER_H */