enabling omx decoder
[platform/upstream/gstreamer.git] / omx / gstomxvideodec.h
1 /*
2  * Copyright (C) 2011, Hewlett-Packard Development Company, L.P.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>, Collabora Ltd.
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_VIDEO_DEC_H__
22 #define __GST_OMX_VIDEO_DEC_H__
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <gst/gst.h>
29 #include <gst/video/video.h>
30 #include <gst/video/gstvideodecoder.h>
31
32 #include "gstomx.h"
33
34 #define OMX_VERSION_MAJOR 1
35 #define OMX_VERSION_MINOR 1
36 #define OMX_VERSION_REVISION 2
37 #define OMX_VERSION_STEP 0
38
39 #define OMX_VERSION ((OMX_VERSION_STEP<<24) | (OMX_VERSION_REVISION<<16) | (OMX_VERSION_MINOR<<8) | OMX_VERSION_MAJOR)
40
41 #define OMX_INIT_STRUCTURE(a) \
42     memset(&(a), 0, sizeof(a)); \
43     (a).nSize = sizeof(a); \
44     (a).nVersion.nVersion = OMX_VERSION; \
45     (a).nVersion.s.nVersionMajor = OMX_VERSION_MAJOR; \
46     (a).nVersion.s.nVersionMinor = OMX_VERSION_MINOR; \
47     (a).nVersion.s.nRevision = OMX_VERSION_REVISION; \
48     (a).nVersion.s.nStep = OMX_VERSION_STEP
49
50 G_BEGIN_DECLS
51
52 #define GST_TYPE_OMX_VIDEO_DEC \
53   (gst_omx_video_dec_get_type())
54 #define GST_OMX_VIDEO_DEC(obj) \
55   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_VIDEO_DEC,GstOMXVideoDec))
56 #define GST_OMX_VIDEO_DEC_CLASS(klass) \
57   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_VIDEO_DEC,GstOMXVideoDecClass))
58 #define GST_OMX_VIDEO_DEC_GET_CLASS(obj) \
59   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_VIDEO_DEC,GstOMXVideoDecClass))
60 #define GST_IS_OMX_VIDEO_DEC(obj) \
61   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_VIDEO_DEC))
62 #define GST_IS_OMX_VIDEO_DEC_CLASS(obj) \
63   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VIDEO_DEC))
64
65 typedef struct _GstOMXVideoDec GstOMXVideoDec;
66 typedef struct _GstOMXVideoDecClass GstOMXVideoDecClass;
67
68 struct _GstOMXVideoDec
69 {
70   GstVideoDecoder parent;
71
72   /* < protected > */
73   GstOMXComponent *dec;
74   GstOMXPort *dec_in_port, *dec_out_port;
75   
76   GstBufferPool *in_port_pool, *out_port_pool;
77
78   /* < private > */
79   GstVideoCodecState *input_state;
80   GstBuffer *codec_data;
81   /* TRUE if the component is configured and saw
82    * the first buffer */
83   gboolean started;
84
85   GstClockTime last_upstream_ts;
86
87   /* Draining state */
88   GMutex drain_lock;
89   GCond drain_cond;
90   /* TRUE if EOS buffers shouldn't be forwarded */
91   gboolean draining;
92
93   GstFlowReturn downstream_flow_ret;
94 #ifdef GST_TIZEN_MODIFICATION
95   gint drm_fd;
96   tbm_bufmgr hTBMBufMgr;
97 #endif
98 #ifdef USE_OMX_TARGET_RPI
99   GstOMXComponent *egl_render;
100   GstOMXPort *egl_in_port, *egl_out_port;
101   gboolean eglimage;
102 #endif
103 };
104
105 struct _GstOMXVideoDecClass
106 {
107   GstVideoDecoderClass parent_class;
108
109   GstOMXClassData cdata;
110
111   gboolean (*is_format_change) (GstOMXVideoDec * self, GstOMXPort * port, GstVideoCodecState * state);
112   gboolean (*set_format)       (GstOMXVideoDec * self, GstOMXPort * port, GstVideoCodecState * state);
113   GstFlowReturn (*prepare_frame)   (GstOMXVideoDec * self, GstVideoCodecFrame *frame);
114 };
115
116 GType gst_omx_video_dec_get_type (void);
117
118 G_END_DECLS
119
120 #endif /* __GST_OMX_VIDEO_DEC_H__ */