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>
This commit is contained in:
Sreerenj Balachandran 2012-09-03 14:00:25 +03:00 committed by Gwenole Beauchesne
parent 13ca9f382c
commit 38d84d968e
13 changed files with 228 additions and 55 deletions

View file

@ -32,11 +32,8 @@ endif
libgstvaapi_source_c = \ libgstvaapi_source_c = \
gstvaapi.c \ gstvaapi.c \
gstvaapidecode.c \ gstvaapidecode.c \
gstvaapidownload.c \
gstvaapipluginutil.c \ gstvaapipluginutil.c \
gstvaapipostproc.c \
gstvaapisink.c \ gstvaapisink.c \
gstvaapiupload.c \
gstvaapiuploader.c \ gstvaapiuploader.c \
gstvaapivideobuffer.c \ gstvaapivideobuffer.c \
gstvaapivideometa.c \ gstvaapivideometa.c \
@ -44,11 +41,8 @@ libgstvaapi_source_c = \
libgstvaapi_source_h = \ libgstvaapi_source_h = \
gstvaapidecode.h \ gstvaapidecode.h \
gstvaapidownload.h \
gstvaapipluginutil.h \ gstvaapipluginutil.h \
gstvaapipostproc.h \
gstvaapisink.h \ gstvaapisink.h \
gstvaapiupload.h \
gstvaapiuploader.h \ gstvaapiuploader.h \
gstvaapivideobuffer.h \ gstvaapivideobuffer.h \
gstvaapivideometa.h \ gstvaapivideometa.h \

View file

@ -32,18 +32,22 @@
static gboolean static gboolean
plugin_init (GstPlugin *plugin) plugin_init (GstPlugin *plugin)
{ {
#if !GST_CHECK_VERSION(1,0,0)
gst_element_register(plugin, "vaapidownload", gst_element_register(plugin, "vaapidownload",
GST_RANK_SECONDARY, GST_RANK_SECONDARY,
GST_TYPE_VAAPIDOWNLOAD); GST_TYPE_VAAPIDOWNLOAD);
gst_element_register(plugin, "vaapiupload", gst_element_register(plugin, "vaapiupload",
GST_RANK_PRIMARY, GST_RANK_PRIMARY,
GST_TYPE_VAAPIUPLOAD); GST_TYPE_VAAPIUPLOAD);
#endif
gst_element_register(plugin, "vaapidecode", gst_element_register(plugin, "vaapidecode",
GST_RANK_PRIMARY, GST_RANK_PRIMARY,
GST_TYPE_VAAPIDECODE); GST_TYPE_VAAPIDECODE);
#if !GST_CHECK_VERSION(1,0,0)
gst_element_register(plugin, "vaapipostproc", gst_element_register(plugin, "vaapipostproc",
GST_RANK_PRIMARY, GST_RANK_PRIMARY,
GST_TYPE_VAAPIPOSTPROC); GST_TYPE_VAAPIPOSTPROC);
#endif
gst_element_register(plugin, "vaapisink", gst_element_register(plugin, "vaapisink",
GST_RANK_PRIMARY, GST_RANK_PRIMARY,
GST_TYPE_VAAPISINK); GST_TYPE_VAAPISINK);
@ -52,7 +56,7 @@ plugin_init (GstPlugin *plugin)
GST_PLUGIN_DEFINE( GST_PLUGIN_DEFINE(
GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MAJOR, GST_VERSION_MINOR,
"vaapi", vaapi,
"VA-API based elements", "VA-API based elements",
plugin_init, plugin_init,
PACKAGE_VERSION, PACKAGE_VERSION,

View file

@ -80,6 +80,7 @@ static GstStaticPadTemplate gst_vaapidecode_src_factory =
GST_STATIC_CAPS(gst_vaapidecode_src_caps_str)); GST_STATIC_CAPS(gst_vaapidecode_src_caps_str));
/* GstImplementsInterface interface */ /* GstImplementsInterface interface */
#if !GST_CHECK_VERSION(1,0,0)
static gboolean static gboolean
gst_vaapidecode_implements_interface_supported( gst_vaapidecode_implements_interface_supported(
GstImplementsInterface *iface, GstImplementsInterface *iface,
@ -94,6 +95,7 @@ gst_vaapidecode_implements_iface_init(GstImplementsInterfaceClass *iface)
{ {
iface->supported = gst_vaapidecode_implements_interface_supported; iface->supported = gst_vaapidecode_implements_interface_supported;
} }
#endif
/* GstVideoContext interface */ /* GstVideoContext interface */
static void static void
@ -115,8 +117,10 @@ G_DEFINE_TYPE_WITH_CODE(
GstVaapiDecode, GstVaapiDecode,
gst_vaapidecode, gst_vaapidecode,
GST_TYPE_VIDEO_DECODER, GST_TYPE_VIDEO_DECODER,
#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE, G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapidecode_implements_iface_init); gst_vaapidecode_implements_iface_init);
#endif
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT, G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init)) gst_video_context_interface_init))
@ -233,7 +237,7 @@ error_decode_timeout:
{ {
GST_WARNING("decode timeout. Decoder required a VA surface but none " GST_WARNING("decode timeout. Decoder required a VA surface but none "
"got available within one second"); "got available within one second");
return GST_FLOW_UNEXPECTED; return GST_FLOW_EOS;
} }
error_decode: error_decode:
{ {
@ -245,7 +249,7 @@ error_decode:
ret = GST_FLOW_NOT_SUPPORTED; ret = GST_FLOW_NOT_SUPPORTED;
break; break;
default: default:
ret = GST_FLOW_UNEXPECTED; ret = GST_FLOW_EOS;
break; break;
} }
gst_video_decoder_drop_frame(vdec, frame); gst_video_decoder_drop_frame(vdec, frame);
@ -301,13 +305,13 @@ error_create_buffer:
GST_VAAPI_ID_ARGS(surface_id)); GST_VAAPI_ID_ARGS(surface_id));
gst_video_decoder_drop_frame(vdec, out_frame); gst_video_decoder_drop_frame(vdec, out_frame);
gst_video_codec_frame_unref(out_frame); gst_video_codec_frame_unref(out_frame);
return GST_FLOW_UNEXPECTED; return GST_FLOW_EOS;
} }
error_commit_buffer: error_commit_buffer:
{ {
GST_DEBUG("video sink rejected the video buffer (error %d)", ret); GST_DEBUG("video sink rejected the video buffer (error %d)", ret);
gst_video_codec_frame_unref(out_frame); 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: error_flush:
{ {
GST_ERROR("failed to flush decoder (status %d)", status); 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; break;
default: default:
GST_ERROR("parse error %d", status); GST_ERROR("parse error %d", status);
ret = GST_FLOW_UNEXPECTED; ret = GST_FLOW_EOS;
break; break;
} }
return ret; return ret;
@ -571,12 +575,10 @@ gst_vaapidecode_class_init(GstVaapiDecodeClass *klass)
/* sink pad */ /* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapidecode_sink_factory); pad_template = gst_static_pad_template_get(&gst_vaapidecode_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
/* src pad */ /* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapidecode_src_factory); pad_template = gst_static_pad_template_get(&gst_vaapidecode_src_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
} }
static gboolean static gboolean
@ -615,7 +617,8 @@ gst_vaapidecode_ensure_allowed_caps(GstVaapiDecode *decode)
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL 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); gst_caps_unref(decode_caps);
@ -652,7 +655,7 @@ gst_vaapidecode_get_caps(GstPad *pad)
} }
static gboolean 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)); GstVaapiDecode *decode = GST_VAAPIDECODE (gst_pad_get_parent_element (pad));
gboolean res; gboolean res;
@ -661,9 +664,9 @@ gst_vaapidecode_query (GstPad *pad, GstQuery *query) {
if (gst_vaapi_reply_to_query (query, decode->display)) if (gst_vaapi_reply_to_query (query, decode->display))
res = TRUE; res = TRUE;
else if (GST_PAD_IS_SINK(pad)) else if (GST_PAD_IS_SINK(pad))
res = decode->sinkpad_query(decode->sinkpad, query); res = decode->sinkpad_query(decode->sinkpad, parent, query);
else else
res = decode->srcpad_query(decode->srcpad, query); res = decode->srcpad_query(decode->srcpad, parent, query);
g_object_unref (decode); g_object_unref (decode);
return res; return res;
@ -690,7 +693,9 @@ gst_vaapidecode_init(GstVaapiDecode *decode)
decode->sinkpad = GST_VIDEO_DECODER_SINK_PAD(vdec); decode->sinkpad = GST_VIDEO_DECODER_SINK_PAD(vdec);
decode->sinkpad_query = GST_PAD_QUERYFUNC(decode->sinkpad); decode->sinkpad_query = GST_PAD_QUERYFUNC(decode->sinkpad);
gst_pad_set_query_function(decode->sinkpad, gst_vaapidecode_query); 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); gst_pad_set_getcaps_function(decode->sinkpad, gst_vaapidecode_get_caps);
#endif
/* Pad through which data goes out of the element */ /* Pad through which data goes out of the element */
decode->srcpad = GST_VIDEO_DECODER_SRC_PAD(vdec); decode->srcpad = GST_VIDEO_DECODER_SRC_PAD(vdec);

View file

@ -237,12 +237,10 @@ gst_vaapidownload_class_init(GstVaapiDownloadClass *klass)
/* sink pad */ /* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapidownload_sink_factory); pad_template = gst_static_pad_template_get(&gst_vaapidownload_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
/* src pad */ /* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapidownload_src_factory); pad_template = gst_static_pad_template_get(&gst_vaapidownload_src_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
} }
static void static void

View file

@ -335,9 +335,18 @@ gst_vaapi_append_surface_caps(GstCaps *out_caps, GstCaps *in_caps)
gboolean gboolean
gst_vaapi_apply_composition(GstVaapiSurface *surface, GstBuffer *buffer) 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 = GstVideoOverlayComposition * const composition =
gst_video_buffer_get_overlay_composition(buffer); gst_video_buffer_get_overlay_composition(buffer);
#endif
if (!composition) if (!composition)
return TRUE; return TRUE;
return gst_vaapi_surface_set_subpictures_from_composition(surface, return gst_vaapi_surface_set_subpictures_from_composition(surface,

View file

@ -651,12 +651,10 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
/* sink pad */ /* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapipostproc_sink_factory); pad_template = gst_static_pad_template_get(&gst_vaapipostproc_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
/* src pad */ /* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapipostproc_src_factory); pad_template = gst_static_pad_template_get(&gst_vaapipostproc_src_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
/** /**
* GstVaapiPostproc:deinterlace-mode: * GstVaapiPostproc:deinterlace-mode:

View file

@ -51,7 +51,21 @@
#endif #endif
/* Supported interfaces */ /* 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 "gstvaapisink.h"
#include "gstvaapipluginutil.h" #include "gstvaapipluginutil.h"
@ -65,9 +79,11 @@ GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapisink);
/* Default template */ /* Default template */
static const char gst_vaapisink_sink_caps_str[] = static const char gst_vaapisink_sink_caps_str[] =
#if !GST_CHECK_VERSION(1,0,0)
"video/x-raw-yuv, " "video/x-raw-yuv, "
"width = (int) [ 1, MAX ], " "width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]; " "height = (int) [ 1, MAX ]; "
#endif
GST_VAAPI_SURFACE_CAPS; GST_VAAPI_SURFACE_CAPS;
static GstStaticPadTemplate gst_vaapisink_sink_factory = static GstStaticPadTemplate gst_vaapisink_sink_factory =
@ -78,6 +94,7 @@ static GstStaticPadTemplate gst_vaapisink_sink_factory =
GST_STATIC_CAPS(gst_vaapisink_sink_caps_str)); GST_STATIC_CAPS(gst_vaapisink_sink_caps_str));
/* GstImplementsInterface interface */ /* GstImplementsInterface interface */
#if !GST_CHECK_VERSION(1,0,0)
static gboolean static gboolean
gst_vaapisink_implements_interface_supported( gst_vaapisink_implements_interface_supported(
GstImplementsInterface *iface, GstImplementsInterface *iface,
@ -85,7 +102,7 @@ gst_vaapisink_implements_interface_supported(
) )
{ {
return (type == GST_TYPE_VIDEO_CONTEXT || return (type == GST_TYPE_VIDEO_CONTEXT ||
type == GST_TYPE_X_OVERLAY); type == GST_TYPE_VIDEO_OVERLAY);
} }
static void static void
@ -93,6 +110,7 @@ gst_vaapisink_implements_iface_init(GstImplementsInterfaceClass *iface)
{ {
iface->supported = gst_vaapisink_implements_interface_supported; iface->supported = gst_vaapisink_implements_interface_supported;
} }
#endif
/* GstVideoContext interface */ /* GstVideoContext interface */
static void static void
@ -110,18 +128,20 @@ gst_vaapisink_video_context_iface_init(GstVideoContextInterface *iface)
} }
static void static void
gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface); gst_vaapisink_video_overlay_iface_init(GstVideoOverlayInterface *iface);
G_DEFINE_TYPE_WITH_CODE( G_DEFINE_TYPE_WITH_CODE(
GstVaapiSink, GstVaapiSink,
gst_vaapisink, gst_vaapisink,
GST_TYPE_VIDEO_SINK, GST_TYPE_VIDEO_SINK,
#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE, G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapisink_implements_iface_init); gst_vaapisink_implements_iface_init);
#endif
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT, G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_vaapisink_video_context_iface_init); gst_vaapisink_video_context_iface_init);
G_IMPLEMENT_INTERFACE(GST_TYPE_X_OVERLAY, G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_OVERLAY,
gst_vaapisink_xoverlay_iface_init)) gst_vaapisink_video_overlay_iface_init))
enum { enum {
PROP_0, PROP_0,
@ -136,7 +156,7 @@ enum {
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY #define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
#define DEFAULT_ROTATION GST_VAAPI_ROTATION_0 #define DEFAULT_ROTATION GST_VAAPI_ROTATION_0
/* GstXOverlay interface */ /* GstVideoOverlay interface */
#if USE_X11 #if USE_X11
static gboolean static gboolean
@ -147,7 +167,7 @@ static GstFlowReturn
gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer); gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer);
static void 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); GstVaapiSink * const sink = GST_VAAPISINK(overlay);
@ -170,8 +190,8 @@ gst_vaapisink_xoverlay_set_window_handle(GstXOverlay *overlay, guintptr window)
} }
static void static void
gst_vaapisink_xoverlay_set_render_rectangle( gst_vaapisink_video_overlay_set_render_rectangle(
GstXOverlay *overlay, GstVideoOverlay *overlay,
gint x, gint x,
gint y, gint y,
gint width, gint width,
@ -192,12 +212,19 @@ gst_vaapisink_xoverlay_set_render_rectangle(
} }
static void static void
gst_vaapisink_xoverlay_expose(GstXOverlay *overlay) gst_vaapisink_video_overlay_expose(GstVideoOverlay *overlay)
{ {
GstBaseSink * const base_sink = GST_BASE_SINK(overlay); GstBaseSink * const base_sink = GST_BASE_SINK(overlay);
GstBuffer *buffer; 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); buffer = gst_base_sink_get_last_buffer(base_sink);
#endif
if (buffer) { if (buffer) {
gst_vaapisink_show_frame(base_sink, buffer); gst_vaapisink_show_frame(base_sink, buffer);
gst_buffer_unref(buffer); gst_buffer_unref(buffer);
@ -205,11 +232,11 @@ gst_vaapisink_xoverlay_expose(GstXOverlay *overlay)
} }
static void 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_window_handle = gst_vaapisink_video_overlay_set_window_handle;
iface->set_render_rectangle = gst_vaapisink_xoverlay_set_render_rectangle; iface->set_render_rectangle = gst_vaapisink_video_overlay_set_render_rectangle;
iface->expose = gst_vaapisink_xoverlay_expose; iface->expose = gst_vaapisink_video_overlay_expose;
} }
static void static void
@ -443,16 +470,16 @@ gst_vaapisink_ensure_window(GstVaapiSink *sink, guint width, guint height)
#if USE_GLX #if USE_GLX
case GST_VAAPI_DISPLAY_TYPE_GLX: case GST_VAAPI_DISPLAY_TYPE_GLX:
sink->window = gst_vaapi_window_glx_new(display, width, height); sink->window = gst_vaapi_window_glx_new(display, width, height);
goto notify_xoverlay_interface; goto notify_video_overlay_interface;
#endif #endif
#if USE_X11 #if USE_X11
case GST_VAAPI_DISPLAY_TYPE_X11: case GST_VAAPI_DISPLAY_TYPE_X11:
sink->window = gst_vaapi_window_x11_new(display, width, height); sink->window = gst_vaapi_window_x11_new(display, width, height);
notify_xoverlay_interface: notify_video_overlay_interface:
if (!sink->window) if (!sink->window)
break; break;
gst_x_overlay_got_window_handle( gst_video_overlay_got_window_handle(
GST_X_OVERLAY(sink), GST_VIDEO_OVERLAY(sink),
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window)) gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window))
); );
break; break;
@ -589,7 +616,7 @@ gst_vaapisink_stop(GstBaseSink *base_sink)
} }
static GstCaps * 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); GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
GstCaps *out_caps, *yuv_caps; GstCaps *out_caps, *yuv_caps;
@ -642,7 +669,7 @@ gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
} }
else { else {
gst_vaapi_display_lock(sink->display); 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); gst_vaapi_display_unlock(sink->display);
if (sink->window) if (sink->window)
return TRUE; return TRUE;
@ -840,24 +867,30 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
gboolean success; gboolean success;
meta = gst_buffer_get_vaapi_video_meta(src_buffer); 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) if (meta)
buffer = gst_buffer_ref(src_buffer); buffer = gst_buffer_ref(src_buffer);
else if (sink->use_video_raw) { else if (sink->use_video_raw) {
buffer = gst_vaapi_uploader_get_buffer(sink->uploader); buffer = gst_vaapi_uploader_get_buffer(sink->uploader);
if (!buffer) if (!buffer)
return GST_FLOW_UNEXPECTED; return GST_FLOW_EOS;
meta = gst_buffer_get_vaapi_video_meta(buffer); meta = gst_buffer_get_vaapi_video_meta(buffer);
if (!meta) if (!meta)
goto error; goto error;
} }
else else
return GST_FLOW_UNEXPECTED; return GST_FLOW_EOS;
if (sink->use_video_raw && if (sink->use_video_raw &&
!gst_vaapi_uploader_process(sink->uploader, src_buffer, buffer)) { !gst_vaapi_uploader_process(sink->uploader, src_buffer, buffer)) {
GST_WARNING("failed to process raw YUV buffer"); GST_WARNING("failed to process raw YUV buffer");
goto error; goto error;
} }
#endif
if (sink->display != gst_vaapi_video_meta_get_display(meta)) { if (sink->display != gst_vaapi_video_meta_get_display(meta)) {
g_clear_object(&sink->display); g_clear_object(&sink->display);
@ -918,9 +951,10 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
error: error:
gst_buffer_unref(buffer); gst_buffer_unref(buffer);
return GST_FLOW_UNEXPECTED; return GST_FLOW_EOS;
} }
#if !GST_CHECK_VERSION(1,0,0)
static GstFlowReturn static GstFlowReturn
gst_vaapisink_buffer_alloc( gst_vaapisink_buffer_alloc(
GstBaseSink *base_sink, GstBaseSink *base_sink,
@ -961,6 +995,7 @@ gst_vaapisink_buffer_alloc(
*pbuf = buf; *pbuf = buf;
return GST_FLOW_OK; return GST_FLOW_OK;
} }
#endif
static gboolean static gboolean
gst_vaapisink_query(GstBaseSink *base_sink, GstQuery *query) 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->preroll = gst_vaapisink_show_frame;
basesink_class->render = gst_vaapisink_show_frame; basesink_class->render = gst_vaapisink_show_frame;
basesink_class->query = gst_vaapisink_query; basesink_class->query = gst_vaapisink_query;
#if !GST_CHECK_VERSION(1,0,0)
basesink_class->buffer_alloc = gst_vaapisink_buffer_alloc; basesink_class->buffer_alloc = gst_vaapisink_buffer_alloc;
#endif
gst_element_class_set_static_metadata(element_class, gst_element_class_set_static_metadata(element_class,
"VA-API sink", "VA-API sink",
@ -1079,7 +1116,6 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
pad_template = gst_static_pad_template_get(&gst_vaapisink_sink_factory); pad_template = gst_static_pad_template_get(&gst_vaapisink_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
g_object_class_install_property g_object_class_install_property
(object_class, (object_class,

View file

@ -215,12 +215,10 @@ gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
/* sink pad */ /* sink pad */
pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory); pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
/* src pad */ /* src pad */
pad_template = gst_static_pad_template_get(&gst_vaapiupload_src_factory); pad_template = gst_static_pad_template_get(&gst_vaapiupload_src_factory);
gst_element_class_add_pad_template(element_class, pad_template); gst_element_class_add_pad_template(element_class, pad_template);
gst_object_unref(pad_template);
} }
static void static void

View file

@ -449,10 +449,12 @@ gst_vaapi_uploader_get_buffer(GstVaapiUploader *uploader)
goto error; goto error;
} }
#if 0
GST_BUFFER_DATA(buffer) = gst_vaapi_image_get_plane(image, 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_SIZE(buffer) = gst_vaapi_image_get_data_size(image);
gst_buffer_set_caps(buffer, priv->image_caps); gst_buffer_set_caps(buffer, priv->image_caps);
#endif
return buffer; return buffer;
error: error:

View file

@ -26,12 +26,20 @@
*/ */
#include "gst/vaapi/sysdeps.h" #include "gst/vaapi/sysdeps.h"
#include <gst/video/gstsurfacebuffer.h>
#include "gstvaapivideobuffer.h" #include "gstvaapivideobuffer.h"
#if USE_GLX #if USE_GLX
# include "gstvaapivideoconverter_glx.h" # include "gstvaapivideoconverter_glx.h"
#endif #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 \ #define GST_VAAPI_TYPE_VIDEO_BUFFER \
(gst_vaapi_video_buffer_get_type()) (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 static GFunc
get_surface_converter(GstVaapiDisplay *display) get_surface_converter(GstVaapiDisplay *display)
{ {
@ -145,7 +160,7 @@ new_vbuffer(GstVaapiVideoMeta *meta)
gst_vaapi_video_meta_set_surface_converter(meta, gst_vaapi_video_meta_set_surface_converter(meta,
get_surface_converter(gst_vaapi_video_meta_get_display(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) if (buffer)
gst_buffer_set_vaapi_video_meta(buffer, meta); gst_buffer_set_vaapi_video_meta(buffer, meta);
gst_vaapi_video_meta_unref(meta); gst_vaapi_video_meta_unref(meta);

View file

@ -27,8 +27,13 @@
#include "gstvaapipluginutil.h" #include "gstvaapipluginutil.h"
#include "gstvaapivideometa.h" #include "gstvaapivideometa.h"
#if GST_CHECK_VERSION(1,0,0)
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
GstBuffer *);
#else
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *, typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
GstSurfaceBuffer *); GstSurfaceBuffer *);
#endif
static void static void
gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface); gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface);

View file

@ -30,9 +30,6 @@
#include <gst/vaapi/gstvaapisurfacepool.h> #include <gst/vaapi/gstvaapisurfacepool.h>
#include "gstvaapivideometa.h" #include "gstvaapivideometa.h"
#define GST_VAAPI_TYPE_VIDEO_META \
(gst_vaapi_video_meta_get_type())
#define GST_VAAPI_VIDEO_META(obj) \ #define GST_VAAPI_VIDEO_META(obj) \
((GstVaapiVideoMeta *)(obj)) ((GstVaapiVideoMeta *)(obj))
@ -100,6 +97,8 @@ gst_vaapi_video_meta_destroy_surface(GstVaapiVideoMeta *meta)
g_clear_object(&meta->surface_pool); 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 static GType
gst_vaapi_video_meta_get_type(void) gst_vaapi_video_meta_get_type(void)
{ {
@ -114,6 +113,7 @@ gst_vaapi_video_meta_get_type(void)
} }
return (GType)g_type; return (GType)g_type;
} }
#endif
static void static void
gst_vaapi_video_meta_finalize(GstVaapiVideoMeta *meta) 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; 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() #define GST_VAAPI_VIDEO_META_QUARK gst_vaapi_video_meta_quark_get()
static GQuark static GQuark
gst_vaapi_video_meta_quark_get(void) 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, gst_structure_id_new(GST_VAAPI_VIDEO_META_QUARK,
META_QUARK, GST_VAAPI_TYPE_VIDEO_META, meta, NULL)); META_QUARK, GST_VAAPI_TYPE_VIDEO_META, meta, NULL));
} }
#endif

View file

@ -33,6 +33,15 @@ G_BEGIN_DECLS
typedef struct _GstVaapiVideoMeta GstVaapiVideoMeta; 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 G_GNUC_INTERNAL
GstVaapiVideoMeta * GstVaapiVideoMeta *
gst_vaapi_video_meta_new(GstVaapiDisplay *display); gst_vaapi_video_meta_new(GstVaapiDisplay *display);