Drop excessive threading that over-complicates synchronisation.
[profile/ivi/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapidecoder.h
1 /*
2  *  gstvaapidecoder.h - VA decoder abstraction
3  *
4  *  gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program 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
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
19  */
20
21 #ifndef GST_VAAPI_DECODER_H
22 #define GST_VAAPI_DECODER_H
23
24 #include <gst/gstbuffer.h>
25 #include <gst/vaapi/gstvaapicontext.h>
26 #include <gst/vaapi/gstvaapisurfaceproxy.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_VAAPI_TYPE_DECODER \
31     (gst_vaapi_decoder_get_type())
32
33 #define GST_VAAPI_DECODER(obj)                          \
34     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
35                                 GST_VAAPI_TYPE_DECODER, \
36                                 GstVaapiDecoder))
37
38 #define GST_VAAPI_DECODER_CLASS(klass)                  \
39     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
40                              GST_VAAPI_TYPE_DECODER,    \
41                              GstVaapiDecoderClass))
42
43 #define GST_VAAPI_IS_DECODER(obj) \
44     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DECODER))
45
46 #define GST_VAAPI_IS_DECODER_CLASS(klass) \
47     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DECODER))
48
49 #define GST_VAAPI_DECODER_GET_CLASS(obj)                \
50     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
51                                GST_VAAPI_TYPE_DECODER,  \
52                                GstVaapiDecoderClass))
53
54 typedef enum _GstVaapiDecoderStatus             GstVaapiDecoderStatus;
55 typedef struct _GstVaapiDecoder                 GstVaapiDecoder;
56 typedef struct _GstVaapiDecoderPrivate          GstVaapiDecoderPrivate;
57 typedef struct _GstVaapiDecoderClass            GstVaapiDecoderClass;
58
59 /**
60  * GstVaapiDecoderStatus:
61  * @GST_VAAPI_DECODER_STATUS_SUCCESS: Success.
62  * @GST_VAAPI_DECODER_STATUS_TIMEOUT: Timeout. Try again later.
63  * @GST_VAAPI_DECODER_STATUS_END_OF_STREAM: End-Of-Stream.
64  * @GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED: No memory left.
65  * @GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED: Decoder initialization failure.
66  * @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC: Unsupported codec.
67  * @GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA: Not enough input data to decode.
68  * @GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE: Invalid surface.
69  * @GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN: Unknown error.
70  *
71  * Decoder status for gst_vaapi_decoder_get_surface().
72  */
73 enum _GstVaapiDecoderStatus {
74     GST_VAAPI_DECODER_STATUS_SUCCESS = 0,
75     GST_VAAPI_DECODER_STATUS_TIMEOUT,
76     GST_VAAPI_DECODER_STATUS_END_OF_STREAM,
77     GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED,
78     GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED,
79     GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC,
80     GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA,
81     GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE,
82     GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN
83 };
84
85 /**
86  * GstVaapiDecoder:
87  *
88  * A VA decoder base instance.
89  */
90 struct _GstVaapiDecoder {
91     /*< private >*/
92     GObject parent_instance;
93
94     GstVaapiDecoderPrivate *priv;
95 };
96
97 /**
98  * GstVaapiDecoderClass:
99  * @decode: decode one frame.
100  *
101  * A VA decoder base class.
102  */
103 struct _GstVaapiDecoderClass {
104     /*< private >*/
105     GObjectClass parent_class;
106
107     GstVaapiDecoderStatus (*decode)(GstVaapiDecoder *decoder, GstBuffer *buffer);
108 };
109
110 GType
111 gst_vaapi_decoder_get_type(void);
112
113 void
114 gst_vaapi_decoder_get_frame_rate(
115     GstVaapiDecoder *decoder,
116     guint           *num,
117     guint           *den
118 );
119
120 void
121 gst_vaapi_decoder_set_frame_rate(
122     GstVaapiDecoder *decoder,
123     guint            num,
124     guint            den
125 );
126
127 gboolean
128 gst_vaapi_decoder_start(GstVaapiDecoder *decoder);
129
130 gboolean
131 gst_vaapi_decoder_pause(GstVaapiDecoder *decoder);
132
133 gboolean
134 gst_vaapi_decoder_stop(GstVaapiDecoder *decoder);
135
136 gboolean
137 gst_vaapi_decoder_put_buffer_data(
138     GstVaapiDecoder *decoder,
139     const guchar    *buf,
140     guint            buf_size
141 );
142
143 gboolean
144 gst_vaapi_decoder_put_buffer_data_copy(
145     GstVaapiDecoder *decoder,
146     const guchar    *buf,
147     guint            buf_size
148 );
149
150 gboolean
151 gst_vaapi_decoder_put_buffer(GstVaapiDecoder *decoder, GstBuffer *buf);
152
153 GstVaapiSurfaceProxy *
154 gst_vaapi_decoder_get_surface(
155     GstVaapiDecoder       *decoder,
156     GstVaapiDecoderStatus *pstatus
157 );
158
159 G_END_DECLS
160
161 #endif /* GST_VAAPI_DECODER_H */