1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
|
/*
* gstvaapipluginbase.h - Base GStreamer VA-API Plugin element
*
* Copyright (C) 2010-2011 Splitted-Desktop Systems
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
* Copyright (C) 2011-2013 Intel Corporation
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef GST_VAAPI_PLUGIN_BASE_H
#define GST_VAAPI_PLUGIN_BASE_H
#include <gst/base/gstbasetransform.h>
#include <gst/video/gstvideodecoder.h>
#include <gst/video/gstvideoencoder.h>
#include <gst/video/gstvideosink.h>
#include <gst/vaapi/gstvaapidisplay.h>
G_BEGIN_DECLS
typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
typedef struct _GstVaapiPadPrivate GstVaapiPadPrivate;
#define GST_VAAPI_PLUGIN_BASE(plugin) \
((GstVaapiPluginBase *)(plugin))
#define GST_VAAPI_PLUGIN_BASE_CLASS(plugin) \
((GstVaapiPluginBaseClass *)(plugin))
#define GST_VAAPI_PLUGIN_BASE_GET_CLASS(plugin) \
GST_VAAPI_PLUGIN_BASE_CLASS(GST_ELEMENT_GET_CLASS( \
GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin)))
#define GST_VAAPI_PLUGIN_BASE_PARENT(plugin) \
(&GST_VAAPI_PLUGIN_BASE(plugin)->parent_instance)
#define GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin) \
(&GST_VAAPI_PLUGIN_BASE_CLASS(plugin)->parent_class)
#define GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->element)
#define GST_VAAPI_PLUGIN_BASE_ELEMENT_CLASS(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->element)
#define GST_VAAPI_PLUGIN_BASE_DECODER(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->decoder)
#define GST_VAAPI_PLUGIN_BASE_DECODER_CLASS(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->decoder)
#define GST_VAAPI_PLUGIN_BASE_ENCODER(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->encoder)
#define GST_VAAPI_PLUGIN_BASE_ENCODER_CLASS(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->encoder)
#define GST_VAAPI_PLUGIN_BASE_TRANSFORM(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->transform)
#define GST_VAAPI_PLUGIN_BASE_TRANSFORM_CLASS(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->transform)
#define GST_VAAPI_PLUGIN_BASE_SINK(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->sink)
#define GST_VAAPI_PLUGIN_BASE_SINK_CLASS(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->sink)
#define GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES \
gst_vaapi_plugin_base_init_interfaces(g_define_type_id);
#define GST_VAAPI_PLUGIN_BASE_SINK_PAD(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad)
#define GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->sinkpriv)
#define GST_VAAPI_PLUGIN_BASE_SINK_PAD_CAPS(plugin) \
(GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin)->caps)
#define GST_VAAPI_PLUGIN_BASE_SINK_PAD_INFO(plugin) \
(&GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin)->info)
#define GST_VAAPI_PLUGIN_BASE_SRC_PAD(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->srcpad)
#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->srcpriv)
#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAPS(plugin) \
(GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->caps)
#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_INFO(plugin) \
(&GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->info)
#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAN_DMABUF(plugin) \
(GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->can_dmabuf)
#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_BUFFER_POOL(plugin) \
(GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->buffer_pool)
#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_ALLOCATOR(plugin) \
(GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->allocator)
#define GST_VAAPI_PLUGIN_BASE_OTHER_ALLOCATOR(plugin) \
(GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->other_allocator)
#define GST_VAAPI_PLUGIN_BASE_OTHER_ALLOCATOR_PARAMS(plugin) \
(GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->other_allocator_params)
#define GST_VAAPI_PLUGIN_BASE_COPY_OUTPUT_FRAME(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->copy_output_frame)
#define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->display)
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->display_type)
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_NAME(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->display_name)
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
(gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
(new_display)))
#define GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT(parent_class) \
static void \
gst_vaapi_base_set_context (GstElement * element, GstContext * context) \
{ \
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element); \
\
gst_vaapi_plugin_base_set_context (plugin, context); \
GST_ELEMENT_CLASS (parent_class)->set_context (element, context); \
}
struct _GstVaapiPadPrivate
{
GstCaps *caps;
GstVideoInfo info;
GstBufferPool *buffer_pool;
GstAllocator *allocator;
guint buffer_size;
gboolean caps_is_raw;
gboolean can_dmabuf;
GstAllocator *other_allocator;
GstAllocationParams other_allocator_params;
};
G_GNUC_INTERNAL
GstVaapiPadPrivate *
gst_vaapi_pad_private_new (void);
G_GNUC_INTERNAL
void
gst_vaapi_pad_private_reset (GstVaapiPadPrivate * priv);
G_GNUC_INTERNAL
void
gst_vaapi_pad_private_finalize (GstVaapiPadPrivate * priv);
struct _GstVaapiPluginBase
{
/*< private >*/
union
{
GstElement element;
GstVideoDecoder decoder;
GstVideoEncoder encoder;
GstBaseTransform transform;
GstVideoSink sink;
GstVideoAggregator aggregator;
} parent_instance;
GstDebugCategory *debug_category;
GstPad *sinkpad;
GstPad *srcpad;
GstVaapiPadPrivate *sinkpriv;
GstVaapiPadPrivate *srcpriv;
GstVaapiDisplay *display;
GstVaapiDisplayType display_type;
GstVaapiDisplayType display_type_req;
gchar *display_name;
GstObject *gl_context;
GstObject *gl_display;
GstObject *gl_other_context;
GstCaps *allowed_raw_caps;
gboolean enable_direct_rendering;
gboolean copy_output_frame;
};
struct _GstVaapiPluginBaseClass
{
/*< private >*/
union
{
GstElementClass element;
GstVideoDecoderClass decoder;
GstVideoEncoderClass encoder;
GstBaseTransformClass transform;
GstVideoSinkClass sink;
GstVideoAggregatorClass aggregator;
} parent_class;
gboolean (*has_interface) (GstVaapiPluginBase * plugin, GType type);
void (*display_changed) (GstVaapiPluginBase * plugin);
GstVaapiPadPrivate * (*get_vaapi_pad_private) (GstVaapiPluginBase * plugin, GstPad * pad);
};
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_init_interfaces (GType type);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
GstDebugCategory * debug_category);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_finalize (GstVaapiPluginBase * plugin);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_has_display_type (GstVaapiPluginBase * plugin,
GstVaapiDisplayType display_type_req);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
GstVaapiDisplayType display_type);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
const gchar * display_name);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
GstCaps * outcaps);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_pad_set_caps (GstVaapiPluginBase *plugin,
GstPad * sinkpad, GstCaps * incaps, GstPad * srcpad, GstCaps * outcaps);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
GstQuery * query);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_pad_propose_allocation (GstVaapiPluginBase * plugin,
GstPad * sinkpad, GstQuery * query);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
GstQuery * query);
G_GNUC_INTERNAL
GstFlowReturn
gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
G_GNUC_INTERNAL
GstFlowReturn
gst_vaapi_plugin_base_pad_get_input_buffer (GstVaapiPluginBase * plugin,
GstPad * sinkpad, GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
GstContext * context);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
GstObject * object);
G_GNUC_INTERNAL
GstObject *
gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin);
G_GNUC_INTERNAL
GstCaps *
gst_vaapi_plugin_base_get_allowed_sinkpad_raw_caps (GstVaapiPluginBase * plugin);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_set_srcpad_can_dmabuf (GstVaapiPluginBase * plugin,
GstObject * object);
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_copy_va_buffer (GstVaapiPluginBase * plugin,
GstBuffer * inbuf, GstBuffer * outbuf);
G_END_DECLS
#endif /* GST_VAAPI_PLUGIN_BASE_H */
|