diff options
Diffstat (limited to 'common/recipes-multimedia/gstreamer/gstreamer-vaapi/gstvideoencoder.h')
-rw-r--r-- | common/recipes-multimedia/gstreamer/gstreamer-vaapi/gstvideoencoder.h | 308 |
1 files changed, 308 insertions, 0 deletions
diff --git a/common/recipes-multimedia/gstreamer/gstreamer-vaapi/gstvideoencoder.h b/common/recipes-multimedia/gstreamer/gstreamer-vaapi/gstvideoencoder.h new file mode 100644 index 00000000..9ae3516e --- /dev/null +++ b/common/recipes-multimedia/gstreamer/gstreamer-vaapi/gstvideoencoder.h | |||
@@ -0,0 +1,308 @@ | |||
1 | /* GStreamer | ||
2 | * Copyright (C) 2008 David Schleef <ds@schleef.org> | ||
3 | * Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>. | ||
4 | * Copyright (C) 2011 Nokia Corporation. All rights reserved. | ||
5 | * Contact: Stefan Kost <stefan.kost@nokia.com> | ||
6 | * Copyright (C) 2012 Collabora Ltd. | ||
7 | * Author : Edward Hervey <edward@collabora.com> | ||
8 | * | ||
9 | * This library is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Library General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * This library is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Library General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Library General Public | ||
20 | * License along with this library; if not, write to the | ||
21 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
22 | * Boston, MA 02111-1307, USA. | ||
23 | */ | ||
24 | |||
25 | #ifndef _GST_VIDEO_ENCODER_H_ | ||
26 | #define _GST_VIDEO_ENCODER_H_ | ||
27 | |||
28 | #include <gst/video/gstvideoutils.h> | ||
29 | |||
30 | G_BEGIN_DECLS | ||
31 | |||
32 | #define GST_TYPE_VIDEO_ENCODER \ | ||
33 | (gst_video_encoder_get_type()) | ||
34 | #define GST_VIDEO_ENCODER(obj) \ | ||
35 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_ENCODER,GstVideoEncoder)) | ||
36 | #define GST_VIDEO_ENCODER_CLASS(klass) \ | ||
37 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_ENCODER,GstVideoEncoderClass)) | ||
38 | #define GST_VIDEO_ENCODER_GET_CLASS(obj) \ | ||
39 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VIDEO_ENCODER,GstVideoEncoderClass)) | ||
40 | #define GST_IS_VIDEO_ENCODER(obj) \ | ||
41 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_ENCODER)) | ||
42 | #define GST_IS_VIDEO_ENCODER_CLASS(obj) \ | ||
43 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_ENCODER)) | ||
44 | #define GST_VIDEO_ENCODER_CAST(enc) ((GstVideoEncoder*)enc) | ||
45 | |||
46 | /** | ||
47 | * GST_VIDEO_ENCODER_SINK_NAME: | ||
48 | * | ||
49 | * The name of the templates for the sink pad. | ||
50 | * | ||
51 | * Since: 0.10.37 | ||
52 | */ | ||
53 | #define GST_VIDEO_ENCODER_SINK_NAME "sink" | ||
54 | /** | ||
55 | * GST_VIDEO_ENCODER_SRC_NAME: | ||
56 | * | ||
57 | * The name of the templates for the source pad. | ||
58 | * | ||
59 | * Since: 0.10.37 | ||
60 | */ | ||
61 | #define GST_VIDEO_ENCODER_SRC_NAME "src" | ||
62 | |||
63 | /** | ||
64 | * GST_VIDEO_ENCODER_FLOW_DROPPED: | ||
65 | * | ||
66 | * Returned when the event/buffer should be dropped. | ||
67 | * | ||
68 | * Since: 0.10.37 | ||
69 | */ | ||
70 | #define GST_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1 | ||
71 | |||
72 | /** | ||
73 | * GST_VIDEO_ENCODER_SRC_PAD: | ||
74 | * @obj: a #GstVideoEncoder | ||
75 | * | ||
76 | * Gives the pointer to the source #GstPad object of the element. | ||
77 | * | ||
78 | * Since: 0.10.37 | ||
79 | */ | ||
80 | #define GST_VIDEO_ENCODER_SRC_PAD(obj) (((GstVideoEncoder *) (obj))->srcpad) | ||
81 | |||
82 | /** | ||
83 | * GST_VIDEO_ENCODER_SINK_PAD: | ||
84 | * @obj: a #GstVideoEncoder | ||
85 | * | ||
86 | * Gives the pointer to the sink #GstPad object of the element. | ||
87 | * | ||
88 | * Since: 0.10.37 | ||
89 | */ | ||
90 | #define GST_VIDEO_ENCODER_SINK_PAD(obj) (((GstVideoEncoder *) (obj))->sinkpad) | ||
91 | |||
92 | /** | ||
93 | * GST_VIDEO_ENCODER_FLOW_NEED_DATA: | ||
94 | * | ||
95 | * Returned while parsing to indicate more data is needed. | ||
96 | * | ||
97 | * Since: 0.10.37 | ||
98 | **/ | ||
99 | #define GST_VIDEO_ENCODER_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS | ||
100 | |||
101 | /** | ||
102 | * GST_VIDEO_ENCODER_FLOW_DROPPED: | ||
103 | * | ||
104 | * Returned when the event/buffer should be dropped. | ||
105 | * | ||
106 | * Since: 0.10.37 | ||
107 | */ | ||
108 | #define GST_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1 | ||
109 | |||
110 | /** | ||
111 | * GST_VIDEO_ENCODER_INPUT_SEGMENT: | ||
112 | * @obj: base parse instance | ||
113 | * | ||
114 | * Gives the segment of the element. | ||
115 | * | ||
116 | * Since: 0.10.37 | ||
117 | */ | ||
118 | #define GST_VIDEO_ENCODER_INPUT_SEGMENT(obj) (GST_VIDEO_ENCODER_CAST (obj)->input_segment) | ||
119 | |||
120 | /** | ||
121 | * GST_VIDEO_ENCODER_OUTPUT_SEGMENT: | ||
122 | * @obj: base parse instance | ||
123 | * | ||
124 | * Gives the segment of the element. | ||
125 | * | ||
126 | * Since: 0.10.37 | ||
127 | */ | ||
128 | #define GST_VIDEO_ENCODER_OUTPUT_SEGMENT(obj) (GST_VIDEO_ENCODER_CAST (obj)->output_segment) | ||
129 | |||
130 | /** | ||
131 | * GST_VIDEO_ENCODER_STREAM_LOCK: | ||
132 | * @encoder: video encoder instance | ||
133 | * | ||
134 | * Obtain a lock to protect the encoder function from concurrent access. | ||
135 | * | ||
136 | * Since: 0.10.37 | ||
137 | */ | ||
138 | #define GST_VIDEO_ENCODER_STREAM_LOCK(encoder) g_static_rec_mutex_lock (&GST_VIDEO_ENCODER (encoder)->stream_lock) | ||
139 | |||
140 | /** | ||
141 | * GST_VIDEO_ENCODER_STREAM_UNLOCK: | ||
142 | * @encoder: video encoder instance | ||
143 | * | ||
144 | * Release the lock that protects the encoder function from concurrent access. | ||
145 | * | ||
146 | * Since: 0.10.37 | ||
147 | */ | ||
148 | #define GST_VIDEO_ENCODER_STREAM_UNLOCK(encoder) g_static_rec_mutex_unlock (&GST_VIDEO_ENCODER (encoder)->stream_lock) | ||
149 | |||
150 | typedef struct _GstVideoEncoder GstVideoEncoder; | ||
151 | typedef struct _GstVideoEncoderPrivate GstVideoEncoderPrivate; | ||
152 | typedef struct _GstVideoEncoderClass GstVideoEncoderClass; | ||
153 | |||
154 | /** | ||
155 | * GstVideoEncoder: | ||
156 | * | ||
157 | * The opaque #GstVideoEncoder data structure. | ||
158 | * | ||
159 | * Since: 0.10.37 | ||
160 | */ | ||
161 | struct _GstVideoEncoder | ||
162 | { | ||
163 | /*< private >*/ | ||
164 | GstElement element; | ||
165 | |||
166 | /*< protected >*/ | ||
167 | GstPad *sinkpad; | ||
168 | GstPad *srcpad; | ||
169 | |||
170 | /* protects all data processing, i.e. is locked | ||
171 | * in the chain function, finish_frame and when | ||
172 | * processing serialized events */ | ||
173 | GStaticRecMutex stream_lock; | ||
174 | |||
175 | /* MT-protected (with STREAM_LOCK) */ | ||
176 | GstSegment input_segment; | ||
177 | GstSegment output_segment; | ||
178 | |||
179 | GstVideoEncoderPrivate *priv; | ||
180 | |||
181 | /*< private >*/ | ||
182 | gpointer _gst_reserved[GST_PADDING_LARGE]; | ||
183 | }; | ||
184 | |||
185 | /** | ||
186 | * GstVideoEncoderClass: | ||
187 | * @open: Optional. | ||
188 | * Called when the element changes to GST_STATE_READY. | ||
189 | * Allows opening external resources. Since: 0.10.37. | ||
190 | * @close: Optional. | ||
191 | * Called when the element changes to GST_STATE_NULL. | ||
192 | * Allows closing external resources. Since: 0.10.37. | ||
193 | * @start: Optional. | ||
194 | * Called when the element starts processing. | ||
195 | * Allows opening external resources. | ||
196 | * @stop: Optional. | ||
197 | * Called when the element stops processing. | ||
198 | * Allows closing external resources. | ||
199 | * @set_format: Optional. | ||
200 | * Notifies subclass of incoming data format. | ||
201 | * GstVideoCodecState fields have already been | ||
202 | * set according to provided caps. | ||
203 | * @handle_frame: Provides input frame to subclass. | ||
204 | * @reset: Optional. | ||
205 | * Allows subclass (encoder) to perform post-seek semantics reset. | ||
206 | * @finish: Optional. | ||
207 | * Called to request subclass to dispatch any pending remaining | ||
208 | * data (e.g. at EOS). | ||
209 | * @pre_push: Optional. | ||
210 | * Allows subclass to push frame downstream in whatever | ||
211 | * shape or form it deems appropriate. If not provided, | ||
212 | * provided encoded frame data is simply pushed downstream. | ||
213 | * @getcaps: Optional. | ||
214 | * Allows for a custom sink getcaps implementation (e.g. | ||
215 | * for multichannel input specification). If not implemented, | ||
216 | * default returns gst_video_encoder_proxy_getcaps | ||
217 | * applied to sink template caps. | ||
218 | * @sink_event: Optional. | ||
219 | * Event handler on the sink pad. This function should return | ||
220 | * TRUE if the event was handled and should be discarded | ||
221 | * (i.e. not unref'ed). | ||
222 | * @src_event: Optional. | ||
223 | * Event handler on the source pad. This function should return | ||
224 | * TRUE if the event was handled and should be discarded | ||
225 | * (i.e. not unref'ed). | ||
226 | * | ||
227 | * Subclasses can override any of the available virtual methods or not, as | ||
228 | * needed. At minimum @handle_frame needs to be overridden, and @set_format | ||
229 | * and @get_caps are likely needed as well. | ||
230 | * | ||
231 | * Since: 0.10.37 | ||
232 | */ | ||
233 | struct _GstVideoEncoderClass | ||
234 | { | ||
235 | /*< private >*/ | ||
236 | GstElementClass element_class; | ||
237 | |||
238 | /*< public >*/ | ||
239 | /* virtual methods for subclasses */ | ||
240 | gboolean (*open) (GstVideoEncoder *encoder); | ||
241 | |||
242 | gboolean (*close) (GstVideoEncoder *encoder); | ||
243 | |||
244 | gboolean (*start) (GstVideoEncoder *encoder); | ||
245 | |||
246 | gboolean (*stop) (GstVideoEncoder *encoder); | ||
247 | |||
248 | gboolean (*set_format) (GstVideoEncoder *encoder, | ||
249 | GstVideoCodecState *state); | ||
250 | |||
251 | GstFlowReturn (*handle_frame) (GstVideoEncoder *encoder, | ||
252 | GstVideoCodecFrame *frame); | ||
253 | |||
254 | gboolean (*reset) (GstVideoEncoder *encoder, | ||
255 | gboolean hard); | ||
256 | |||
257 | GstFlowReturn (*finish) (GstVideoEncoder *encoder); | ||
258 | |||
259 | GstFlowReturn (*pre_push) (GstVideoEncoder *encoder, | ||
260 | GstVideoCodecFrame *frame); | ||
261 | |||
262 | GstCaps * (*getcaps) (GstVideoEncoder *enc); | ||
263 | |||
264 | gboolean (*sink_event) (GstVideoEncoder *encoder, | ||
265 | GstEvent *event); | ||
266 | |||
267 | gboolean (*src_event) (GstVideoEncoder *encoder, | ||
268 | GstEvent *event); | ||
269 | |||
270 | /*< private >*/ | ||
271 | gpointer _gst_reserved[GST_PADDING_LARGE]; | ||
272 | }; | ||
273 | |||
274 | GType gst_video_encoder_get_type (void); | ||
275 | |||
276 | GstVideoCodecState* gst_video_encoder_get_output_state (GstVideoEncoder *encoder); | ||
277 | |||
278 | GstVideoCodecState* gst_video_encoder_set_output_state (GstVideoEncoder * encoder, | ||
279 | GstCaps * caps, | ||
280 | GstVideoCodecState * reference); | ||
281 | |||
282 | GstVideoCodecFrame* gst_video_encoder_get_frame (GstVideoEncoder *encoder, | ||
283 | int frame_number); | ||
284 | GstVideoCodecFrame* gst_video_encoder_get_oldest_frame (GstVideoEncoder *encoder); | ||
285 | |||
286 | GList * gst_video_encoder_get_frames (GstVideoEncoder *encoder); | ||
287 | |||
288 | GstFlowReturn gst_video_encoder_finish_frame (GstVideoEncoder *encoder, | ||
289 | GstVideoCodecFrame *frame); | ||
290 | |||
291 | GstCaps * gst_video_encoder_proxy_getcaps (GstVideoEncoder * enc, | ||
292 | GstCaps * caps); | ||
293 | void gst_video_encoder_set_discont (GstVideoEncoder *encoder); | ||
294 | gboolean gst_video_encoder_get_discont (GstVideoEncoder *encoder); | ||
295 | |||
296 | void gst_video_encoder_set_latency (GstVideoEncoder *encoder, | ||
297 | GstClockTime min_latency, | ||
298 | GstClockTime max_latency); | ||
299 | void gst_video_encoder_get_latency (GstVideoEncoder *encoder, | ||
300 | GstClockTime *min_latency, | ||
301 | GstClockTime *max_latency); | ||
302 | |||
303 | void gst_video_encoder_set_headers (GstVideoEncoder *encoder, | ||
304 | GList *headers); | ||
305 | G_END_DECLS | ||
306 | |||
307 | #endif | ||
308 | |||