omxvideodec: support interlace-mode=interleaved input
[platform/upstream/gstreamer.git] / omx / gstomxaudiodec.h
1 /*
2  * Copyright (C) 2014, Sebastian Dröge <sebastian@centricular.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation
7  * version 2.1 of the License.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  */
19
20 #ifndef __GST_OMX_AUDIO_DEC_H__
21 #define __GST_OMX_AUDIO_DEC_H__
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include <gst/gst.h>
28 #include <gst/audio/audio.h>
29 #include <gst/audio/gstaudiodecoder.h>
30
31 #include "gstomx.h"
32
33 G_BEGIN_DECLS
34
35 #define GST_TYPE_OMX_AUDIO_DEC \
36   (gst_omx_audio_dec_get_type())
37 #define GST_OMX_AUDIO_DEC(obj) \
38   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AUDIO_DEC,GstOMXAudioDec))
39 #define GST_OMX_AUDIO_DEC_CLASS(klass) \
40   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AUDIO_DEC,GstOMXAudioDecClass))
41 #define GST_OMX_AUDIO_DEC_GET_CLASS(obj) \
42   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AUDIO_DEC,GstOMXAudioDecClass))
43 #define GST_IS_OMX_AUDIO_DEC(obj) \
44   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AUDIO_DEC))
45 #define GST_IS_OMX_AUDIO_DEC_CLASS(obj) \
46   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AUDIO_DEC))
47
48 typedef struct _GstOMXAudioDec GstOMXAudioDec;
49 typedef struct _GstOMXAudioDecClass GstOMXAudioDecClass;
50
51 struct _GstOMXAudioDec
52 {
53   GstAudioDecoder parent;
54
55   /* < protected > */
56   GstOMXComponent *dec;
57   GstOMXPort *dec_in_port, *dec_out_port;
58   
59   GstBufferPool *in_port_pool, *out_port_pool;
60
61   /* < private > */
62   GstAudioInfo info;
63   GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS];
64   gint reorder_map[OMX_AUDIO_MAXCHANNELS];
65   gboolean needs_reorder;
66   GstBuffer *codec_data;
67   /* TRUE if the component is configured and saw
68    * the first buffer */
69   gboolean started;
70
71   GstClockTime last_upstream_ts;
72
73   /* Draining state */
74   GMutex drain_lock;
75   GCond drain_cond;
76   /* TRUE if EOS buffers shouldn't be forwarded */
77   gboolean draining;
78
79   GstAdapter *output_adapter;
80
81   GstFlowReturn downstream_flow_ret;
82 };
83
84 struct _GstOMXAudioDecClass
85 {
86   GstAudioDecoderClass parent_class;
87
88   GstOMXClassData cdata;
89
90   gboolean (*is_format_change) (GstOMXAudioDec * self, GstOMXPort * port, GstCaps * caps);
91   gboolean (*set_format)       (GstOMXAudioDec * self, GstOMXPort * port, GstCaps * caps);
92   gint     (*get_samples_per_frame) (GstOMXAudioDec * self, GstOMXPort * port);
93   gboolean (*get_channel_positions) (GstOMXAudioDec * self, GstOMXPort * port, GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS]);
94 };
95
96 GType gst_omx_audio_dec_get_type (void);
97
98 G_END_DECLS
99
100 #endif /* __GST_OMX_AUDIO_DEC_H__ */