Tizen 2.0 Release
[framework/multimedia/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapibaseencoder.h
1 /*
2  *  gstvaapibaseencoder.h - VA-API base encoder
3  *
4  *  Copyright (C) 2011 Intel Corporation
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 License
8  *  as published by the Free Software Foundation; either version 2.1
9  *  of the License, or (at your option) any later version.
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
18  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  *  Boston, MA 02110-1301 USA
20  */
21
22 #ifndef GST_VAAPI_BASE_ENCODER_H
23 #define GST_VAAPI_BASE_ENCODER_H
24
25 #include "gst/vaapi/gstvaapiencoder.h"
26 #include "gst/vaapi/gstvaapivideobuffer.h"
27
28 G_BEGIN_DECLS
29
30 typedef struct _GstVaapiBaseEncoder              GstVaapiBaseEncoder;
31 typedef struct _GstVaapiBaseEncoderPrivate       GstVaapiBaseEncoderPrivate;
32 typedef struct _GstVaapiBaseEncoderClass         GstVaapiBaseEncoderClass;
33
34 #define GST_TYPE_VAAPI_BASE_ENCODER \
35     (gst_vaapi_base_encoder_get_type())
36
37 #define GST_IS_VAAPI_BASE_ENCODER(obj) \
38     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_BASE_ENCODER))
39
40 #define GST_IS_VAAPI_BASE_ENCODER_CLASS(klass) \
41     (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPI_BASE_ENCODER))
42
43 #define GST_VAAPI_BASE_ENCODER_GET_CLASS(obj)                  \
44     (G_TYPE_INSTANCE_GET_CLASS ((obj),                         \
45                                 GST_TYPE_VAAPI_BASE_ENCODER,   \
46                                 GstVaapiBaseEncoderClass))
47
48 #define GST_VAAPI_BASE_ENCODER(obj)                            \
49 (G_TYPE_CHECK_INSTANCE_CAST ((obj),                            \
50                              GST_TYPE_VAAPI_BASE_ENCODER,      \
51                              GstVaapiBaseEncoder))
52
53 #define GST_VAAPI_BASE_ENCODER_CLASS(klass)                    \
54     (G_TYPE_CHECK_CLASS_CAST ((klass),                         \
55                               GST_TYPE_VAAPI_BASE_ENCODER,     \
56                               GstVaapiBaseEncoderClass))
57
58 #define GST_VAAPI_BASE_ENCODER_GET_PRIVATE(obj)                \
59     (G_TYPE_INSTANCE_GET_PRIVATE((obj),                        \
60                                  GST_TYPE_VAAPI_BASE_ENCODER,  \
61                                  GstVaapiBaseEncoderPrivate))
62
63 /* return: if true, continue; else, stop*/
64 typedef gboolean
65   (*GstVaapiBaseEncoderNotifyStatus)(
66        GstVaapiBaseEncoder* encoder,
67        EncoderStatus status,
68        void* userdata);
69
70 struct _GstVaapiBaseEncoder {
71   GstVaapiEncoder parent;
72
73   GstVaapiBaseEncoderPrivate *priv;
74 };
75
76 struct _GstVaapiBaseEncoderClass {
77   GstVaapiEncoderClass parent_class;
78
79   /* in <open> function*/
80   gboolean (*validate_attributes)   (GstVaapiBaseEncoder* encoder);
81   gboolean (*pre_alloc_resource)    (GstVaapiBaseEncoder *encoder,
82                                      GstVaapiContext* context);
83
84   /* in <close> function */
85   gboolean (*release_resource)      (GstVaapiBaseEncoder* encoder);
86
87   /* in <encode> function */
88   EncoderStatus (*prepare_next_input_buffer)(GstVaapiBaseEncoder* encoder,
89                                              GstBuffer *display_buf,
90                                              gboolean need_flush,
91                                              GstBuffer **out_buf);
92
93   EncoderStatus (*render_frame)     (GstVaapiBaseEncoder *encoder,
94                                      GstVaapiSurface *surface,
95                                      guint frame_index,
96                                      VABufferID coded_buf,
97                                      gboolean *is_key);
98
99   void (*encode_frame_failed)       (GstVaapiBaseEncoder *encoder,
100                                      GstVaapiVideoBuffer* buffer);
101
102   void (*notify_buffer)             (GstVaapiBaseEncoder *encoder,
103                                      guint8 *buf, guint32 size);
104
105   GstBuffer *(*wrap_buffer)         (GstVaapiBaseEncoder *encoder,
106                                      GstBuffer *buf);
107 };
108
109 GType
110 gst_vaapi_base_encoder_get_type(void);
111
112 void
113 gst_vaapi_base_encoder_set_frame_notify(
114     GstVaapiBaseEncoder *encoder,
115     gboolean flag
116 );
117
118 gboolean
119 gst_vaapi_base_encoder_set_va_profile(
120     GstVaapiBaseEncoder *encoder,
121     guint profile
122 );
123 void
124 gst_vaapi_base_encoder_set_input_format(
125     GstVaapiBaseEncoder* encoder,
126     guint32 format
127 );
128
129 gboolean
130 gst_vaapi_base_encoder_set_notify_status(
131     GstVaapiBaseEncoder *encoder,
132     GstVaapiBaseEncoderNotifyStatus func,
133     gpointer             user_data
134 );
135
136 void
137 gst_vaapi_base_encoder_set_buffer_sharing(
138     GstVaapiBaseEncoder *encoder,
139     gboolean is_buffer_sharing
140 );
141
142 G_END_DECLS
143
144 #endif /* GST_VAAPI_BASE_ENCODER_H */