summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>2012-09-03 14:00:25 +0300
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-04-10 14:58:16 +0200
commit38d84d968eb06b876a807f43e41896af27558ed5 (patch)
tree86d52951b1c1799cccc717a71a7a594663009b0b
parent13ca9f382cba888c4248956a76d7179f9f953cb5 (diff)
plugins: initial port to GStreamer 1.0.
Port vaapidecode and vaapisink plugins to GStreamer API >= 1.0. This is rather minimalistic so that to test the basic functionality. Disable vaapiupload, vaapidownload and vaapipostproc plugins. The latter needs polishing wrt. to GStreamer 1.x functionality and the former are totally phased out in favor of GstVaapiVideoMemory map/unmap facilities, which are yet to be implemented. Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
-rw-r--r--gst/vaapi/Makefile.am6
-rw-r--r--gst/vaapi/gstvaapi.c6
-rw-r--r--gst/vaapi/gstvaapidecode.c29
-rw-r--r--gst/vaapi/gstvaapidownload.c2
-rw-r--r--gst/vaapi/gstvaapipluginutil.c11
-rw-r--r--gst/vaapi/gstvaapipostproc.c2
-rw-r--r--gst/vaapi/gstvaapisink.c84
-rw-r--r--gst/vaapi/gstvaapiupload.c2
-rw-r--r--gst/vaapi/gstvaapiuploader.c2
-rw-r--r--gst/vaapi/gstvaapivideobuffer.c19
-rw-r--r--gst/vaapi/gstvaapivideoconverter_glx.c5
-rw-r--r--gst/vaapi/gstvaapivideometa.c106
-rw-r--r--gst/vaapi/gstvaapivideometa.h9
13 files changed, 228 insertions, 55 deletions
diff --git a/gst/vaapi/Makefile.am b/gst/vaapi/Makefile.am
index c5955cb4..e8d66337 100644
--- a/gst/vaapi/Makefile.am
+++ b/gst/vaapi/Makefile.am
@@ -32,11 +32,8 @@ endif
libgstvaapi_source_c = \
gstvaapi.c \
gstvaapidecode.c \
- gstvaapidownload.c \
gstvaapipluginutil.c \
- gstvaapipostproc.c \
gstvaapisink.c \
- gstvaapiupload.c \
gstvaapiuploader.c \
gstvaapivideobuffer.c \
gstvaapivideometa.c \
@@ -44,11 +41,8 @@ libgstvaapi_source_c = \
libgstvaapi_source_h = \
gstvaapidecode.h \
- gstvaapidownload.h \
gstvaapipluginutil.h \
- gstvaapipostproc.h \
gstvaapisink.h \
- gstvaapiupload.h \
gstvaapiuploader.h \
gstvaapivideobuffer.h \
gstvaapivideometa.h \
diff --git a/gst/vaapi/gstvaapi.c b/gst/vaapi/gstvaapi.c
index 5a6462f9..909be71d 100644
--- a/gst/vaapi/gstvaapi.c
+++ b/gst/vaapi/gstvaapi.c
@@ -32,18 +32,22 @@
static gboolean
plugin_init (GstPlugin *plugin)
{
+#if !GST_CHECK_VERSION(1,0,0)
gst_element_register(plugin, "vaapidownload",
GST_RANK_SECONDARY,
GST_TYPE_VAAPIDOWNLOAD);
gst_element_register(plugin, "vaapiupload",
GST_RANK_PRIMARY,
GST_TYPE_VAAPIUPLOAD);
+#endif
gst_element_register(plugin, "vaapidecode",
GST_RANK_PRIMARY,
GST_TYPE_VAAPIDECODE);
+#if !GST_CHECK_VERSION(1,0,0)
gst_element_register(plugin, "vaapipostproc",
GST_RANK_PRIMARY,
GST_TYPE_VAAPIPOSTPROC);
+#endif
gst_element_register(plugin, "vaapisink",
GST_RANK_PRIMARY,
GST_TYPE_VAAPISINK);
@@ -52,7 +56,7 @@ plugin_init (GstPlugin *plugin)
GST_PLUGIN_DEFINE(
GST_VERSION_MAJOR, GST_VERSION_MINOR,
- "vaapi",
+ vaapi,
"VA-API based elements",
plugin_init,
PACKAGE_VERSION,
diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c
index 58c33587..77c437ba 100644
--- a/gst/vaapi/gstvaapidecode.c
+++ b/gst/vaapi/gstvaapidecode.c
@@ -80,6 +80,7 @@ static GstStaticPadTemplate gst_vaapidecode_src_factory =
GST_STATIC_CAPS(gst_vaapidecode_src_caps_str));
/* GstImplementsInterface interface */
+#if !GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapidecode_implements_interface_supported(
GstImplementsInterface *iface,
@@ -94,6 +95,7 @@ gst_vaapidecode_implements_iface_init(GstImplementsInterfaceClass *iface)
{
iface->supported = gst_vaapidecode_implements_interface_supported;
}
+#endif
/* GstVideoContext interface */
static void
@@ -115,8 +117,10 @@ G_DEFINE_TYPE_WITH_CODE(
GstVaapiDecode,
gst_vaapidecode,
GST_TYPE_VIDEO_DECODER,
+#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapidecode_implements_iface_init);
+#endif
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init))
@@ -233,7 +237,7 @@ error_decode_timeout:
{
GST_WARNING("decode timeout. Decoder required a VA surface but none "
"got available within one second");
- return GST_FLOW_UNEXPECTED;
+ return GST_FLOW_EOS;
}
error_decode:
{
@@ -245,7 +249,7 @@ error_decode:
ret = GST_FLOW_NOT_SUPPORTED;
break;
default:
- ret = GST_FLOW_UNEXPECTED;
+ ret = GST_FLOW_EOS;
break;
}
gst_video_decoder_drop_frame(vdec, frame);
@@ -301,13 +305,13 @@ error_create_buffer:
GST_VAAPI_ID_ARGS(surface_id));
gst_video_decoder_drop_frame(vdec, out_frame);
gst_video_codec_frame_unref(out_frame);
- return GST_FLOW_UNEXPECTED;
+ return GST_FLOW_EOS;
}
error_commit_buffer:
{
GST_DEBUG("video sink rejected the video buffer (error %d)", ret);
gst_video_codec_frame_unref(out_frame);
- return GST_FLOW_UNEXPECTED;
+ return GST_FLOW_EOS;
}
}
@@ -337,7 +341,7 @@ gst_vaapidecode_finish(GstVideoDecoder *vdec)
error_flush:
{
GST_ERROR("failed to flush decoder (status %d)", status);
- return GST_FLOW_UNEXPECTED;
+ return GST_FLOW_EOS;
}
}
@@ -535,7 +539,7 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec,
break;
default:
GST_ERROR("parse error %d", status);
- ret = GST_FLOW_UNEXPECTED;
+ ret = GST_FLOW_EOS;
break;
}
return ret;
@@ -571,12 +575,10 @@ gst_vaapidecode_class_init(GstVaapiDecodeClass *klass)
/* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapidecode_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
/* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapidecode_src_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
}
static gboolean
@@ -615,7 +617,8 @@ gst_vaapidecode_ensure_allowed_caps(GstVaapiDecode *decode)
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL
);
- gst_caps_merge_structure(decode->allowed_caps, structure);
+ decode->allowed_caps =
+ gst_caps_merge_structure(decode->allowed_caps, structure);
}
gst_caps_unref(decode_caps);
@@ -652,7 +655,7 @@ gst_vaapidecode_get_caps(GstPad *pad)
}
static gboolean
-gst_vaapidecode_query (GstPad *pad, GstQuery *query) {
+gst_vaapidecode_query (GstPad *pad, GstObject *parent, GstQuery *query) {
GstVaapiDecode *decode = GST_VAAPIDECODE (gst_pad_get_parent_element (pad));
gboolean res;
@@ -661,9 +664,9 @@ gst_vaapidecode_query (GstPad *pad, GstQuery *query) {
if (gst_vaapi_reply_to_query (query, decode->display))
res = TRUE;
else if (GST_PAD_IS_SINK(pad))
- res = decode->sinkpad_query(decode->sinkpad, query);
+ res = decode->sinkpad_query(decode->sinkpad, parent, query);
else
- res = decode->srcpad_query(decode->srcpad, query);
+ res = decode->srcpad_query(decode->srcpad, parent, query);
g_object_unref (decode);
return res;
@@ -690,7 +693,9 @@ gst_vaapidecode_init(GstVaapiDecode *decode)
decode->sinkpad = GST_VIDEO_DECODER_SINK_PAD(vdec);
decode->sinkpad_query = GST_PAD_QUERYFUNC(decode->sinkpad);
gst_pad_set_query_function(decode->sinkpad, gst_vaapidecode_query);
+#if !GST_CHECK_VERSION(1,0,0)
gst_pad_set_getcaps_function(decode->sinkpad, gst_vaapidecode_get_caps);
+#endif
/* Pad through which data goes out of the element */
decode->srcpad = GST_VIDEO_DECODER_SRC_PAD(vdec);
diff --git a/gst/vaapi/gstvaapidownload.c b/gst/vaapi/gstvaapidownload.c
index f90cfa2a..a1222585 100644
--- a/gst/vaapi/gstvaapidownload.c
+++ b/gst/vaapi/gstvaapidownload.c
@@ -237,12 +237,10 @@ gst_vaapidownload_class_init(GstVaapiDownloadClass *klass)
/* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapidownload_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
/* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapidownload_src_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
}
static void
diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c
index b2cc92f1..6364fbb1 100644
--- a/gst/vaapi/gstvaapipluginutil.c
+++ b/gst/vaapi/gstvaapipluginutil.c
@@ -335,9 +335,18 @@ gst_vaapi_append_surface_caps(GstCaps *out_caps, GstCaps *in_caps)
gboolean
gst_vaapi_apply_composition(GstVaapiSurface *surface, GstBuffer *buffer)
{
+#if GST_CHECK_VERSION(1,0,0)
+ GstVideoOverlayCompositionMeta * const cmeta =
+ gst_buffer_get_video_overlay_composition_meta(buffer);
+ GstVideoOverlayComposition *composition;
+
+ if (!cmeta)
+ return TRUE;
+ composition = cmeta->overlay;
+#else
GstVideoOverlayComposition * const composition =
gst_video_buffer_get_overlay_composition(buffer);
-
+#endif
if (!composition)
return TRUE;
return gst_vaapi_surface_set_subpictures_from_composition(surface,
diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c
index bb0d76c1..534017e6 100644
--- a/gst/vaapi/gstvaapipostproc.c
+++ b/gst/vaapi/gstvaapipostproc.c
@@ -651,12 +651,10 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
/* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapipostproc_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
/* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapipostproc_src_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
/**
* GstVaapiPostproc:deinterlace-mode:
diff --git a/gst/vaapi/gstvaapisink.c b/gst/vaapi/gstvaapisink.c
index 1bf8026a..28c61f12 100644
--- a/gst/vaapi/gstvaapisink.c
+++ b/gst/vaapi/gstvaapisink.c
@@ -51,7 +51,21 @@
#endif
/* Supported interfaces */
-#include <gst/interfaces/xoverlay.h>
+#if GST_CHECK_VERSION(1,0,0)
+# include <gst/video/videooverlay.h>
+#else
+# include <gst/interfaces/xoverlay.h>
+
+# define GST_TYPE_VIDEO_OVERLAY GST_TYPE_X_OVERLAY
+# define GST_VIDEO_OVERLAY GST_X_OVERLAY
+# define GstVideoOverlay GstXOverlay
+# define GstVideoOverlayInterface GstXOverlayClass
+
+# define gst_video_overlay_prepare_window_handle(sink) \
+ gst_x_overlay_prepare_xwindow_id(sink)
+# define gst_video_overlay_got_window_handle(sink, window_handle) \
+ gst_x_overlay_got_window_handle(sink, window_handle)
+#endif
#include "gstvaapisink.h"
#include "gstvaapipluginutil.h"
@@ -65,9 +79,11 @@ GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapisink);
/* Default template */
static const char gst_vaapisink_sink_caps_str[] =
+#if !GST_CHECK_VERSION(1,0,0)
"video/x-raw-yuv, "
"width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]; "
+#endif
GST_VAAPI_SURFACE_CAPS;
static GstStaticPadTemplate gst_vaapisink_sink_factory =
@@ -78,6 +94,7 @@ static GstStaticPadTemplate gst_vaapisink_sink_factory =
GST_STATIC_CAPS(gst_vaapisink_sink_caps_str));
/* GstImplementsInterface interface */
+#if !GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapisink_implements_interface_supported(
GstImplementsInterface *iface,
@@ -85,7 +102,7 @@ gst_vaapisink_implements_interface_supported(
)
{
return (type == GST_TYPE_VIDEO_CONTEXT ||
- type == GST_TYPE_X_OVERLAY);
+ type == GST_TYPE_VIDEO_OVERLAY);
}
static void
@@ -93,6 +110,7 @@ gst_vaapisink_implements_iface_init(GstImplementsInterfaceClass *iface)
{
iface->supported = gst_vaapisink_implements_interface_supported;
}
+#endif
/* GstVideoContext interface */
static void
@@ -110,18 +128,20 @@ gst_vaapisink_video_context_iface_init(GstVideoContextInterface *iface)
}
static void
-gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface);
+gst_vaapisink_video_overlay_iface_init(GstVideoOverlayInterface *iface);
G_DEFINE_TYPE_WITH_CODE(
GstVaapiSink,
gst_vaapisink,
GST_TYPE_VIDEO_SINK,
+#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapisink_implements_iface_init);
+#endif
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_vaapisink_video_context_iface_init);
- G_IMPLEMENT_INTERFACE(GST_TYPE_X_OVERLAY,
- gst_vaapisink_xoverlay_iface_init))
+ G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_OVERLAY,
+ gst_vaapisink_video_overlay_iface_init))
enum {
PROP_0,
@@ -136,7 +156,7 @@ enum {
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
#define DEFAULT_ROTATION GST_VAAPI_ROTATION_0
-/* GstXOverlay interface */
+/* GstVideoOverlay interface */
#if USE_X11
static gboolean
@@ -147,7 +167,7 @@ static GstFlowReturn
gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer);
static void
-gst_vaapisink_xoverlay_set_window_handle(GstXOverlay *overlay, guintptr window)
+gst_vaapisink_video_overlay_set_window_handle(GstVideoOverlay *overlay, guintptr window)
{
GstVaapiSink * const sink = GST_VAAPISINK(overlay);
@@ -170,8 +190,8 @@ gst_vaapisink_xoverlay_set_window_handle(GstXOverlay *overlay, guintptr window)
}
static void
-gst_vaapisink_xoverlay_set_render_rectangle(
- GstXOverlay *overlay,
+gst_vaapisink_video_overlay_set_render_rectangle(
+ GstVideoOverlay *overlay,
gint x,
gint y,
gint width,
@@ -192,12 +212,19 @@ gst_vaapisink_xoverlay_set_render_rectangle(
}
static void
-gst_vaapisink_xoverlay_expose(GstXOverlay *overlay)
+gst_vaapisink_video_overlay_expose(GstVideoOverlay *overlay)
{
GstBaseSink * const base_sink = GST_BASE_SINK(overlay);
GstBuffer *buffer;
+#if GST_CHECK_VERSION(1,0,0)
+ GstSample * const sample = gst_base_sink_get_last_sample(base_sink);
+ if (!sample)
+ return;
+ buffer = gst_sample_get_buffer(sample);
+#else
buffer = gst_base_sink_get_last_buffer(base_sink);
+#endif
if (buffer) {
gst_vaapisink_show_frame(base_sink, buffer);
gst_buffer_unref(buffer);
@@ -205,11 +232,11 @@ gst_vaapisink_xoverlay_expose(GstXOverlay *overlay)
}
static void
-gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface)
+gst_vaapisink_video_overlay_iface_init(GstVideoOverlayInterface *iface)
{
- iface->set_window_handle = gst_vaapisink_xoverlay_set_window_handle;
- iface->set_render_rectangle = gst_vaapisink_xoverlay_set_render_rectangle;
- iface->expose = gst_vaapisink_xoverlay_expose;
+ iface->set_window_handle = gst_vaapisink_video_overlay_set_window_handle;
+ iface->set_render_rectangle = gst_vaapisink_video_overlay_set_render_rectangle;
+ iface->expose = gst_vaapisink_video_overlay_expose;
}
static void
@@ -443,16 +470,16 @@ gst_vaapisink_ensure_window(GstVaapiSink *sink, guint width, guint height)
#if USE_GLX
case GST_VAAPI_DISPLAY_TYPE_GLX:
sink->window = gst_vaapi_window_glx_new(display, width, height);
- goto notify_xoverlay_interface;
+ goto notify_video_overlay_interface;
#endif
#if USE_X11
case GST_VAAPI_DISPLAY_TYPE_X11:
sink->window = gst_vaapi_window_x11_new(display, width, height);
- notify_xoverlay_interface:
+ notify_video_overlay_interface:
if (!sink->window)
break;
- gst_x_overlay_got_window_handle(
- GST_X_OVERLAY(sink),
+ gst_video_overlay_got_window_handle(
+ GST_VIDEO_OVERLAY(sink),
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window))
);
break;
@@ -589,7 +616,7 @@ gst_vaapisink_stop(GstBaseSink *base_sink)
}
static GstCaps *
-gst_vaapisink_get_caps(GstBaseSink *base_sink)
+gst_vaapisink_get_caps(GstBaseSink *base_sink, GstCaps *filter)
{
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
GstCaps *out_caps, *yuv_caps;
@@ -642,7 +669,7 @@ gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
}
else {
gst_vaapi_display_lock(sink->display);
- gst_x_overlay_prepare_xwindow_id(GST_X_OVERLAY(sink));
+ gst_video_overlay_prepare_window_handle(GST_VIDEO_OVERLAY(sink));
gst_vaapi_display_unlock(sink->display);
if (sink->window)
return TRUE;
@@ -840,24 +867,30 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
gboolean success;
meta = gst_buffer_get_vaapi_video_meta(src_buffer);
+#if GST_CHECK_VERSION(1,0,0)
+ if (!meta)
+ return GST_FLOW_EOS;
+ buffer = gst_buffer_ref(src_buffer);
+#else
if (meta)
buffer = gst_buffer_ref(src_buffer);
else if (sink->use_video_raw) {
buffer = gst_vaapi_uploader_get_buffer(sink->uploader);
if (!buffer)
- return GST_FLOW_UNEXPECTED;
+ return GST_FLOW_EOS;
meta = gst_buffer_get_vaapi_video_meta(buffer);
if (!meta)
goto error;
}
else
- return GST_FLOW_UNEXPECTED;
+ return GST_FLOW_EOS;
if (sink->use_video_raw &&
!gst_vaapi_uploader_process(sink->uploader, src_buffer, buffer)) {
GST_WARNING("failed to process raw YUV buffer");
goto error;
}
+#endif
if (sink->display != gst_vaapi_video_meta_get_display(meta)) {
g_clear_object(&sink->display);
@@ -918,9 +951,10 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
error:
gst_buffer_unref(buffer);
- return GST_FLOW_UNEXPECTED;
+ return GST_FLOW_EOS;
}
+#if !GST_CHECK_VERSION(1,0,0)
static GstFlowReturn
gst_vaapisink_buffer_alloc(
GstBaseSink *base_sink,
@@ -961,6 +995,7 @@ gst_vaapisink_buffer_alloc(
*pbuf = buf;
return GST_FLOW_OK;
}
+#endif
static gboolean
gst_vaapisink_query(GstBaseSink *base_sink, GstQuery *query)
@@ -1069,7 +1104,9 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
basesink_class->preroll = gst_vaapisink_show_frame;
basesink_class->render = gst_vaapisink_show_frame;
basesink_class->query = gst_vaapisink_query;
+#if !GST_CHECK_VERSION(1,0,0)
basesink_class->buffer_alloc = gst_vaapisink_buffer_alloc;
+#endif
gst_element_class_set_static_metadata(element_class,
"VA-API sink",
@@ -1079,7 +1116,6 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
pad_template = gst_static_pad_template_get(&gst_vaapisink_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
g_object_class_install_property
(object_class,
diff --git a/gst/vaapi/gstvaapiupload.c b/gst/vaapi/gstvaapiupload.c
index ecb0743e..50c8c9ff 100644
--- a/gst/vaapi/gstvaapiupload.c
+++ b/gst/vaapi/gstvaapiupload.c
@@ -215,12 +215,10 @@ gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
/* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
/* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapiupload_src_factory);
gst_element_class_add_pad_template(element_class, pad_template);
- gst_object_unref(pad_template);
}
static void
diff --git a/gst/vaapi/gstvaapiuploader.c b/gst/vaapi/gstvaapiuploader.c
index a0d5ef13..ac7afd74 100644
--- a/gst/vaapi/gstvaapiuploader.c
+++ b/gst/vaapi/gstvaapiuploader.c
@@ -449,10 +449,12 @@ gst_vaapi_uploader_get_buffer(GstVaapiUploader *uploader)
goto error;
}
+#if 0
GST_BUFFER_DATA(buffer) = gst_vaapi_image_get_plane(image, 0);
GST_BUFFER_SIZE(buffer) = gst_vaapi_image_get_data_size(image);
gst_buffer_set_caps(buffer, priv->image_caps);
+#endif
return buffer;
error:
diff --git a/gst/vaapi/gstvaapivideobuffer.c b/gst/vaapi/gstvaapivideobuffer.c
index c6c1a0ac..1ae3f794 100644
--- a/gst/vaapi/gstvaapivideobuffer.c
+++ b/gst/vaapi/gstvaapivideobuffer.c
@@ -26,12 +26,20 @@
*/
#include "gst/vaapi/sysdeps.h"
-#include <gst/video/gstsurfacebuffer.h>
#include "gstvaapivideobuffer.h"
#if USE_GLX
# include "gstvaapivideoconverter_glx.h"
#endif
+#if GST_CHECK_VERSION(1,0,0)
+static inline GstBuffer *
+gst_surface_buffer_new(void)
+{
+ return gst_buffer_new();
+}
+#else
+#include <gst/video/gstsurfacebuffer.h>
+
#define GST_VAAPI_TYPE_VIDEO_BUFFER \
(gst_vaapi_video_buffer_get_type())
@@ -117,6 +125,13 @@ gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer)
{
}
+static inline GstBuffer *
+gst_surface_buffer_new(void)
+{
+ return GST_BUFFER_CAST(gst_mini_object_new(GST_TYPE_SURFACE_BUFFER));
+}
+#endif
+
static GFunc
get_surface_converter(GstVaapiDisplay *display)
{
@@ -145,7 +160,7 @@ new_vbuffer(GstVaapiVideoMeta *meta)
gst_vaapi_video_meta_set_surface_converter(meta,
get_surface_converter(gst_vaapi_video_meta_get_display(meta)));
- buffer = GST_BUFFER_CAST(gst_mini_object_new(GST_TYPE_SURFACE_BUFFER));
+ buffer = gst_surface_buffer_new();
if (buffer)
gst_buffer_set_vaapi_video_meta(buffer, meta);
gst_vaapi_video_meta_unref(meta);
diff --git a/gst/vaapi/gstvaapivideoconverter_glx.c b/gst/vaapi/gstvaapivideoconverter_glx.c
index 323013f3..cfbf163b 100644
--- a/gst/vaapi/gstvaapivideoconverter_glx.c
+++ b/gst/vaapi/gstvaapivideoconverter_glx.c
@@ -27,8 +27,13 @@
#include "gstvaapipluginutil.h"
#include "gstvaapivideometa.h"
+#if GST_CHECK_VERSION(1,0,0)
+typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
+ GstBuffer *);
+#else
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
GstSurfaceBuffer *);
+#endif
static void
gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface);
diff --git a/gst/vaapi/gstvaapivideometa.c b/gst/vaapi/gstvaapivideometa.c
index 2b437009..18d10e85 100644
--- a/gst/vaapi/gstvaapivideometa.c
+++ b/gst/vaapi/gstvaapivideometa.c
@@ -30,9 +30,6 @@
#include <gst/vaapi/gstvaapisurfacepool.h>
#include "gstvaapivideometa.h"
-#define GST_VAAPI_TYPE_VIDEO_META \
- (gst_vaapi_video_meta_get_type())
-
#define GST_VAAPI_VIDEO_META(obj) \
((GstVaapiVideoMeta *)(obj))
@@ -100,6 +97,8 @@ gst_vaapi_video_meta_destroy_surface(GstVaapiVideoMeta *meta)
g_clear_object(&meta->surface_pool);
}
+#if !GST_CHECK_VERSION(1,0,0)
+#define GST_VAAPI_TYPE_VIDEO_META gst_vaapi_video_meta_get_type()
static GType
gst_vaapi_video_meta_get_type(void)
{
@@ -114,6 +113,7 @@ gst_vaapi_video_meta_get_type(void)
}
return (GType)g_type;
}
+#endif
static void
gst_vaapi_video_meta_finalize(GstVaapiVideoMeta *meta)
@@ -649,6 +649,105 @@ gst_vaapi_video_meta_set_render_flags(GstVaapiVideoMeta *meta, guint flags)
meta->render_flags = flags;
}
+#if GST_CHECK_VERSION(1,0,0)
+
+#define GST_VAAPI_VIDEO_META_HOLDER(meta) \
+ ((GstVaapiVideoMetaHolder *)(meta))
+
+typedef struct _GstVaapiVideoMetaHolder GstVaapiVideoMetaHolder;
+struct _GstVaapiVideoMetaHolder {
+ GstMeta base;
+ GstVaapiVideoMeta *meta;
+};
+
+static gboolean
+gst_vaapi_video_meta_holder_init(GstVaapiVideoMetaHolder *meta,
+ gpointer params, GstBuffer *buffer)
+{
+ meta->meta = NULL;
+ return TRUE;
+}
+
+static void
+gst_vaapi_video_meta_holder_free(GstVaapiVideoMetaHolder *meta,
+ GstBuffer *buffer)
+{
+ if (meta->meta)
+ gst_vaapi_video_meta_unref(meta->meta);
+}
+
+static gboolean
+gst_vaapi_video_meta_holder_transform(GstBuffer *dst_buffer, GstMeta *meta,
+ GstBuffer *src_buffer, GQuark type, gpointer data)
+{
+ GstVaapiVideoMetaHolder * const src_meta =
+ GST_VAAPI_VIDEO_META_HOLDER(meta);
+
+ if (GST_META_TRANSFORM_IS_COPY(type)) {
+ gst_buffer_set_vaapi_video_meta(dst_buffer, src_meta->meta);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+GType
+gst_vaapi_video_meta_api_get_type(void)
+{
+ static gsize g_type;
+ static const gchar *tags[] = { "memory", NULL };
+
+ if (g_once_init_enter(&g_type)) {
+ GType type = gst_meta_api_type_register("GstVaapiVideoMetaAPI", tags);
+ g_once_init_leave(&g_type, type);
+ }
+ return g_type;
+}
+
+#define GST_VAAPI_VIDEO_META_INFO gst_vaapi_video_meta_info_get()
+static const GstMetaInfo *
+gst_vaapi_video_meta_info_get(void)
+{
+ static gsize g_meta_info;
+
+ if (g_once_init_enter(&g_meta_info)) {
+ gsize meta_info = GPOINTER_TO_SIZE(gst_meta_register(
+ GST_VAAPI_VIDEO_META_API_TYPE,
+ "GstVaapiVideoMeta", sizeof(GstVaapiVideoMetaHolder),
+ (GstMetaInitFunction)gst_vaapi_video_meta_holder_init,
+ (GstMetaFreeFunction)gst_vaapi_video_meta_holder_free,
+ (GstMetaTransformFunction)gst_vaapi_video_meta_holder_transform));
+ g_once_init_leave(&g_meta_info, meta_info);
+ }
+ return GSIZE_TO_POINTER(g_meta_info);
+}
+
+GstVaapiVideoMeta *
+gst_buffer_get_vaapi_video_meta(GstBuffer *buffer)
+{
+ GstMeta *m;
+
+ g_return_val_if_fail(GST_IS_BUFFER(buffer), NULL);
+
+ m = gst_buffer_get_meta(buffer, GST_VAAPI_VIDEO_META_API_TYPE);
+ if (!m)
+ return NULL;
+ return GST_VAAPI_VIDEO_META_HOLDER(m)->meta;
+}
+
+void
+gst_buffer_set_vaapi_video_meta(GstBuffer *buffer, GstVaapiVideoMeta *meta)
+{
+ GstMeta *m;
+
+ g_return_if_fail(GST_IS_BUFFER(buffer));
+ g_return_if_fail(GST_VAAPI_IS_VIDEO_META(meta));
+
+ m = gst_buffer_add_meta(buffer, GST_VAAPI_VIDEO_META_INFO, NULL);
+ if (m)
+ GST_VAAPI_VIDEO_META_HOLDER(m)->meta = gst_vaapi_video_meta_ref(meta);
+}
+#else
+
#define GST_VAAPI_VIDEO_META_QUARK gst_vaapi_video_meta_quark_get()
static GQuark
gst_vaapi_video_meta_quark_get(void)
@@ -704,3 +803,4 @@ gst_buffer_set_vaapi_video_meta(GstBuffer *buffer, GstVaapiVideoMeta *meta)
gst_structure_id_new(GST_VAAPI_VIDEO_META_QUARK,
META_QUARK, GST_VAAPI_TYPE_VIDEO_META, meta, NULL));
}
+#endif
diff --git a/gst/vaapi/gstvaapivideometa.h b/gst/vaapi/gstvaapivideometa.h
index 47d07e34..2d566497 100644
--- a/gst/vaapi/gstvaapivideometa.h
+++ b/gst/vaapi/gstvaapivideometa.h
@@ -33,6 +33,15 @@ G_BEGIN_DECLS
typedef struct _GstVaapiVideoMeta GstVaapiVideoMeta;
+#if GST_CHECK_VERSION(1,0,0)
+#define GST_VAAPI_VIDEO_META_API_TYPE \
+ gst_vaapi_video_meta_api_get_type()
+
+G_GNUC_INTERNAL
+GType
+gst_vaapi_video_meta_api_get_type(void) G_GNUC_CONST;
+#endif
+
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new(GstVaapiDisplay *display);