2010-03-05 17:11:52 +00:00
|
|
|
/*
|
|
|
|
* gstvaapisink.c - VA-API video sink
|
|
|
|
*
|
2011-06-14 11:52:56 +00:00
|
|
|
* gstreamer-vaapi (C) 2010-2011 Splitted-Desktop Systems
|
2011-12-07 18:09:55 +00:00
|
|
|
* Copyright (C) 2011 Intel Corporation
|
2010-03-05 17:11:52 +00:00
|
|
|
*
|
2011-10-18 07:06:52 +00:00
|
|
|
* 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.
|
2010-03-05 17:11:52 +00:00
|
|
|
*
|
2011-10-18 07:06:52 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-03-05 17:11:52 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-10-18 07:06:52 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-03-05 17:11:52 +00:00
|
|
|
*
|
2011-10-18 07:06:52 +00:00
|
|
|
* 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
|
2010-03-05 17:11:52 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-23 15:22:47 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstvaapisink
|
|
|
|
* @short_description: A VA-API based videosink
|
|
|
|
*
|
|
|
|
* vaapisink renders video frames to a drawable (X #Window) on a local
|
|
|
|
* display using the Video Acceleration (VA) API. The element will
|
|
|
|
* create its own internal window and render into it.
|
|
|
|
*/
|
|
|
|
|
2010-03-05 17:11:52 +00:00
|
|
|
#include "config.h"
|
2010-03-12 23:53:48 +00:00
|
|
|
#include <gst/gst.h>
|
2011-12-07 18:04:09 +00:00
|
|
|
#include <gst/gstutils_version.h>
|
2011-11-04 20:50:15 +00:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
#include <gst/video/videocontext.h>
|
2010-03-15 17:09:12 +00:00
|
|
|
#include <gst/vaapi/gstvaapivideobuffer.h>
|
2010-03-16 09:03:10 +00:00
|
|
|
#include <gst/vaapi/gstvaapivideosink.h>
|
2010-03-12 23:53:48 +00:00
|
|
|
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
2010-03-15 17:09:12 +00:00
|
|
|
#include <gst/vaapi/gstvaapiwindow_x11.h>
|
2010-03-29 15:03:30 +00:00
|
|
|
#if USE_VAAPISINK_GLX
|
2010-03-29 14:13:26 +00:00
|
|
|
#include <gst/vaapi/gstvaapidisplay_glx.h>
|
|
|
|
#include <gst/vaapi/gstvaapiwindow_glx.h>
|
|
|
|
#endif
|
2010-03-05 17:11:52 +00:00
|
|
|
|
2010-05-12 11:43:50 +00:00
|
|
|
/* Supported interfaces */
|
|
|
|
#include <gst/interfaces/xoverlay.h>
|
|
|
|
|
2011-11-04 20:50:15 +00:00
|
|
|
#include "gstvaapisink.h"
|
|
|
|
#include "gstvaapipluginutil.h"
|
|
|
|
|
2011-12-07 18:04:09 +00:00
|
|
|
#define HAVE_GST_XOVERLAY_SET_WINDOW_HANDLE \
|
|
|
|
GST_PLUGINS_BASE_CHECK_VERSION(0,10,31)
|
|
|
|
|
2012-01-09 09:37:30 +00:00
|
|
|
#define HAVE_GST_XOVERLAY_SET_RENDER_RECTANGLE \
|
|
|
|
GST_PLUGINS_BASE_CHECK_VERSION(0,10,29)
|
|
|
|
|
2010-03-12 23:53:48 +00:00
|
|
|
#define GST_PLUGIN_NAME "vaapisink"
|
|
|
|
#define GST_PLUGIN_DESC "A VA-API based videosink"
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapisink);
|
|
|
|
#define GST_CAT_DEFAULT gst_debug_vaapisink
|
|
|
|
|
2010-03-05 17:11:52 +00:00
|
|
|
/* ElementFactory information */
|
|
|
|
static const GstElementDetails gst_vaapisink_details =
|
|
|
|
GST_ELEMENT_DETAILS(
|
2010-05-10 09:32:47 +00:00
|
|
|
"VA-API sink",
|
2010-03-05 17:11:52 +00:00
|
|
|
"Sink/Video",
|
2010-05-10 09:32:47 +00:00
|
|
|
GST_PLUGIN_DESC,
|
2011-10-19 12:43:56 +00:00
|
|
|
"Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
|
2010-03-05 17:11:52 +00:00
|
|
|
|
|
|
|
/* Default template */
|
|
|
|
static GstStaticPadTemplate gst_vaapisink_sink_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE(
|
|
|
|
"sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2010-05-07 06:35:31 +00:00
|
|
|
GST_STATIC_CAPS(GST_VAAPI_SURFACE_CAPS));
|
2010-03-05 17:11:52 +00:00
|
|
|
|
2010-03-12 23:53:48 +00:00
|
|
|
static void gst_vaapisink_iface_init(GType type);
|
|
|
|
|
|
|
|
GST_BOILERPLATE_FULL(
|
|
|
|
GstVaapiSink,
|
|
|
|
gst_vaapisink,
|
|
|
|
GstVideoSink,
|
|
|
|
GST_TYPE_VIDEO_SINK,
|
|
|
|
gst_vaapisink_iface_init);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
|
2010-03-29 14:13:26 +00:00
|
|
|
PROP_USE_GLX,
|
2010-03-26 11:30:54 +00:00
|
|
|
PROP_FULLSCREEN,
|
2010-03-29 15:59:44 +00:00
|
|
|
PROP_SYNCHRONOUS,
|
|
|
|
PROP_USE_REFLECTION
|
2010-03-12 23:53:48 +00:00
|
|
|
};
|
|
|
|
|
2010-05-12 11:43:50 +00:00
|
|
|
/* GstImplementsInterface interface */
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_vaapisink_implements_interface_supported(
|
|
|
|
GstImplementsInterface *iface,
|
|
|
|
GType type
|
|
|
|
)
|
|
|
|
{
|
2011-11-04 20:50:15 +00:00
|
|
|
return (type == GST_TYPE_VIDEO_CONTEXT ||
|
2010-05-12 11:43:50 +00:00
|
|
|
type == GST_TYPE_X_OVERLAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapisink_implements_iface_init(GstImplementsInterfaceClass *iface)
|
|
|
|
{
|
|
|
|
iface->supported = gst_vaapisink_implements_interface_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GstVaapiVideoSink interface */
|
|
|
|
|
2011-11-04 20:50:15 +00:00
|
|
|
static void
|
|
|
|
gst_vaapisink_set_video_context(GstVideoContext *context, const gchar *type,
|
|
|
|
const GValue *value)
|
2010-03-12 23:53:48 +00:00
|
|
|
{
|
2011-11-04 20:50:15 +00:00
|
|
|
GstVaapiSink *sink = GST_VAAPISINK (context);
|
|
|
|
gst_vaapi_set_display (type, value, &sink->display);
|
2010-03-12 23:53:48 +00:00
|
|
|
}
|
|
|
|
|
2010-05-12 09:34:37 +00:00
|
|
|
static void
|
2011-11-04 20:50:15 +00:00
|
|
|
gst_vaapisink_video_context_iface_init(GstVideoContextInterface *iface)
|
2010-03-12 23:53:48 +00:00
|
|
|
{
|
2011-11-04 20:50:15 +00:00
|
|
|
iface->set_context = gst_vaapisink_set_video_context;
|
2010-03-12 23:53:48 +00:00
|
|
|
}
|
|
|
|
|
2010-05-12 11:43:50 +00:00
|
|
|
/* GstXOverlay interface */
|
|
|
|
|
2010-05-12 19:35:45 +00:00
|
|
|
static gboolean
|
2011-07-28 08:14:49 +00:00
|
|
|
gst_vaapisink_ensure_window_xid(GstVaapiSink *sink, guintptr window_id);
|
2010-05-12 19:35:45 +00:00
|
|
|
|
2010-05-12 11:43:50 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer);
|
|
|
|
|
2011-12-07 18:04:09 +00:00
|
|
|
static inline void
|
|
|
|
_gst_vaapisink_xoverlay_set_xid(GstXOverlay *overlay, guintptr window_id)
|
2010-05-12 11:43:50 +00:00
|
|
|
{
|
|
|
|
GstVaapiSink * const sink = GST_VAAPISINK(overlay);
|
|
|
|
|
2010-05-17 08:28:28 +00:00
|
|
|
/* Disable GLX rendering when vaapisink is using a foreign X
|
|
|
|
window. It's pretty much useless */
|
|
|
|
sink->use_glx = FALSE;
|
|
|
|
|
2010-05-18 11:22:54 +00:00
|
|
|
sink->foreign_window = TRUE;
|
2011-07-28 08:14:49 +00:00
|
|
|
gst_vaapisink_ensure_window_xid(sink, window_id);
|
2010-05-12 11:43:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-07 18:04:09 +00:00
|
|
|
#if HAVE_GST_XOVERLAY_SET_WINDOW_HANDLE
|
|
|
|
static void
|
|
|
|
gst_vaapisink_xoverlay_set_window_handle(GstXOverlay *overlay, guintptr window_id)
|
|
|
|
{
|
|
|
|
_gst_vaapisink_xoverlay_set_xid(overlay, window_id);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void
|
|
|
|
gst_vaapisink_xoverlay_set_xid(GstXOverlay *overlay, XID xid)
|
|
|
|
{
|
|
|
|
_gst_vaapisink_xoverlay_set_xid(overlay, xid);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-01-09 09:37:30 +00:00
|
|
|
#if HAVE_GST_XOVERLAY_SET_RENDER_RECTANGLE
|
|
|
|
static void
|
|
|
|
gst_vaapisink_xoverlay_set_render_rectangle(
|
|
|
|
GstXOverlay *overlay,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height
|
|
|
|
)
|
|
|
|
{
|
|
|
|
GstVaapiSink * const sink = GST_VAAPISINK(overlay);
|
|
|
|
GstVaapiRectangle * const display_rect = &sink->display_rect;
|
|
|
|
|
|
|
|
display_rect->x = x;
|
|
|
|
display_rect->y = y;
|
|
|
|
display_rect->width = width;
|
|
|
|
display_rect->height = height;
|
|
|
|
|
|
|
|
GST_DEBUG("render rect (%d,%d):%ux%u",
|
|
|
|
display_rect->x, display_rect->y,
|
|
|
|
display_rect->width, display_rect->height);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-12 11:43:50 +00:00
|
|
|
static void
|
|
|
|
gst_vaapisink_xoverlay_expose(GstXOverlay *overlay)
|
|
|
|
{
|
|
|
|
GstBaseSink * const base_sink = GST_BASE_SINK(overlay);
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
|
|
|
buffer = gst_base_sink_get_last_buffer(base_sink);
|
|
|
|
if (buffer) {
|
|
|
|
gst_vaapisink_show_frame(base_sink, buffer);
|
|
|
|
gst_buffer_unref(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface)
|
|
|
|
{
|
2011-12-07 18:04:09 +00:00
|
|
|
#if HAVE_GST_XOVERLAY_SET_WINDOW_HANDLE
|
2012-01-09 09:37:30 +00:00
|
|
|
iface->set_window_handle = gst_vaapisink_xoverlay_set_window_handle;
|
2011-12-07 18:04:09 +00:00
|
|
|
#else
|
2012-01-09 09:37:30 +00:00
|
|
|
iface->set_xwindow_id = gst_vaapisink_xoverlay_set_xid;
|
|
|
|
#endif
|
|
|
|
#if HAVE_GST_XOVERLAY_SET_RENDER_RECTANGLE
|
|
|
|
iface->set_render_rectangle = gst_vaapisink_xoverlay_set_render_rectangle;
|
2011-12-07 18:04:09 +00:00
|
|
|
#endif
|
2012-01-09 09:37:30 +00:00
|
|
|
iface->expose = gst_vaapisink_xoverlay_expose;
|
2010-05-12 11:43:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-12 09:34:37 +00:00
|
|
|
static void
|
|
|
|
gst_vaapisink_iface_init(GType type)
|
2010-03-12 23:53:48 +00:00
|
|
|
{
|
|
|
|
const GType g_define_type_id = type;
|
|
|
|
|
2010-05-12 11:43:50 +00:00
|
|
|
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
|
|
|
|
gst_vaapisink_implements_iface_init);
|
2011-11-04 20:50:15 +00:00
|
|
|
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
|
|
|
|
gst_vaapisink_video_context_iface_init);
|
2010-05-12 11:43:50 +00:00
|
|
|
G_IMPLEMENT_INTERFACE(GST_TYPE_X_OVERLAY,
|
|
|
|
gst_vaapisink_xoverlay_iface_init);
|
2010-03-12 23:53:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapisink_destroy(GstVaapiSink *sink)
|
|
|
|
{
|
|
|
|
if (sink->display) {
|
|
|
|
g_object_unref(sink->display);
|
|
|
|
sink->display = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-17 08:55:51 +00:00
|
|
|
/* Checks whether a ConfigureNotify event is in the queue */
|
|
|
|
typedef struct _ConfigureNotifyEventPendingArgs ConfigureNotifyEventPendingArgs;
|
|
|
|
struct _ConfigureNotifyEventPendingArgs {
|
|
|
|
Window window;
|
|
|
|
guint width;
|
|
|
|
guint height;
|
|
|
|
gboolean match;
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
configure_notify_event_pending_cb(Display *dpy, XEvent *xev, XPointer arg)
|
|
|
|
{
|
|
|
|
ConfigureNotifyEventPendingArgs * const args =
|
|
|
|
(ConfigureNotifyEventPendingArgs *)arg;
|
|
|
|
|
|
|
|
if (xev->type == ConfigureNotify &&
|
|
|
|
xev->xconfigure.window == args->window &&
|
|
|
|
xev->xconfigure.width == args->width &&
|
|
|
|
xev->xconfigure.height == args->height)
|
|
|
|
args->match = TRUE;
|
|
|
|
|
|
|
|
/* XXX: this is a hack to traverse the whole queue because we
|
|
|
|
can't use XPeekIfEvent() since it could block */
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
configure_notify_event_pending(
|
|
|
|
GstVaapiSink *sink,
|
|
|
|
Window window,
|
|
|
|
guint width,
|
|
|
|
guint height
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ConfigureNotifyEventPendingArgs args;
|
|
|
|
XEvent xev;
|
|
|
|
|
|
|
|
args.window = window;
|
|
|
|
args.width = width;
|
|
|
|
args.height = height;
|
|
|
|
args.match = FALSE;
|
|
|
|
|
|
|
|
/* XXX: don't use XPeekIfEvent() because it might block */
|
|
|
|
XCheckIfEvent(
|
|
|
|
gst_vaapi_display_x11_get_display(GST_VAAPI_DISPLAY_X11(sink->display)),
|
|
|
|
&xev,
|
|
|
|
configure_notify_event_pending_cb, (XPointer)&args
|
|
|
|
);
|
|
|
|
return args.match;
|
|
|
|
}
|
|
|
|
|
2010-05-12 19:40:30 +00:00
|
|
|
static gboolean
|
|
|
|
gst_vaapisink_ensure_render_rect(GstVaapiSink *sink, guint width, guint height)
|
|
|
|
{
|
|
|
|
GstVaapiRectangle * const display_rect = &sink->display_rect;
|
|
|
|
guint num, den, display_par_n, display_par_d;
|
|
|
|
gboolean success;
|
|
|
|
|
2010-05-15 04:25:32 +00:00
|
|
|
GST_DEBUG("ensure render rect within %ux%u bounds", width, height);
|
|
|
|
|
2010-05-12 19:40:30 +00:00
|
|
|
gst_vaapi_display_get_pixel_aspect_ratio(
|
|
|
|
sink->display,
|
|
|
|
&display_par_n, &display_par_d
|
|
|
|
);
|
2010-05-13 04:27:44 +00:00
|
|
|
GST_DEBUG("display pixel-aspect-ratio %d/%d",
|
|
|
|
display_par_n, display_par_d);
|
2010-05-12 19:40:30 +00:00
|
|
|
|
|
|
|
success = gst_video_calculate_display_ratio(
|
|
|
|
&num, &den,
|
|
|
|
sink->video_width, sink->video_height,
|
|
|
|
sink->video_par_n, sink->video_par_d,
|
|
|
|
display_par_n, display_par_d
|
|
|
|
);
|
|
|
|
if (!success)
|
|
|
|
return FALSE;
|
2010-05-15 04:25:32 +00:00
|
|
|
GST_DEBUG("video size %dx%d, calculated ratio %d/%d",
|
2010-05-12 19:40:30 +00:00
|
|
|
sink->video_width, sink->video_height, num, den);
|
|
|
|
|
2012-01-09 15:51:35 +00:00
|
|
|
display_rect->width = gst_util_uint64_scale_int(height, num, den);
|
|
|
|
if (display_rect->width <= width) {
|
|
|
|
GST_DEBUG("keeping window height");
|
|
|
|
display_rect->height = height;
|
2010-05-12 19:40:30 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-01-09 15:51:35 +00:00
|
|
|
GST_DEBUG("keeping window width");
|
|
|
|
display_rect->width = width;
|
|
|
|
display_rect->height =
|
|
|
|
gst_util_uint64_scale_int(width, den, num);
|
2010-05-12 19:40:30 +00:00
|
|
|
}
|
2012-01-09 15:51:35 +00:00
|
|
|
GST_DEBUG("scaling video to %ux%u", display_rect->width, display_rect->height);
|
2010-05-12 19:40:30 +00:00
|
|
|
|
2012-01-09 15:51:35 +00:00
|
|
|
g_assert(display_rect->width <= width);
|
|
|
|
g_assert(display_rect->height <= height);
|
|
|
|
|
|
|
|
display_rect->x = (width - display_rect->width) / 2;
|
|
|
|
display_rect->y = (height - display_rect->height) / 2;
|
2010-05-15 04:25:32 +00:00
|
|
|
|
|
|
|
GST_DEBUG("render rect (%d,%d):%ux%u",
|
|
|
|
display_rect->x, display_rect->y,
|
|
|
|
display_rect->width, display_rect->height);
|
2010-05-12 19:40:30 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-03-29 14:13:26 +00:00
|
|
|
static inline gboolean
|
|
|
|
gst_vaapisink_ensure_window(GstVaapiSink *sink, guint width, guint height)
|
|
|
|
{
|
|
|
|
GstVaapiDisplay * const display = sink->display;
|
|
|
|
|
|
|
|
if (!sink->window) {
|
2010-03-29 15:03:30 +00:00
|
|
|
#if USE_VAAPISINK_GLX
|
2010-03-29 14:13:26 +00:00
|
|
|
if (sink->use_glx)
|
|
|
|
sink->window = gst_vaapi_window_glx_new(display, width, height);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
sink->window = gst_vaapi_window_x11_new(display, width, height);
|
2010-05-12 11:43:50 +00:00
|
|
|
if (sink->window)
|
|
|
|
gst_x_overlay_got_xwindow_id(
|
|
|
|
GST_X_OVERLAY(sink),
|
|
|
|
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window))
|
|
|
|
);
|
2010-03-29 14:13:26 +00:00
|
|
|
}
|
|
|
|
return sink->window != NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-12 19:35:45 +00:00
|
|
|
static gboolean
|
2011-07-28 08:14:49 +00:00
|
|
|
gst_vaapisink_ensure_window_xid(GstVaapiSink *sink, guintptr window_id)
|
2010-03-15 17:09:12 +00:00
|
|
|
{
|
2010-05-13 04:22:31 +00:00
|
|
|
Window rootwin;
|
|
|
|
unsigned int width, height, border_width, depth;
|
|
|
|
int x, y;
|
2011-07-28 08:14:49 +00:00
|
|
|
XID xid = window_id;
|
2010-05-12 19:35:45 +00:00
|
|
|
|
2011-11-04 20:50:15 +00:00
|
|
|
if (!gst_vaapi_ensure_display(sink, &sink->display))
|
2010-05-12 19:35:45 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gst_vaapi_display_lock(sink->display);
|
2010-05-13 04:22:31 +00:00
|
|
|
XGetGeometry(
|
2010-05-12 19:35:45 +00:00
|
|
|
gst_vaapi_display_x11_get_display(GST_VAAPI_DISPLAY_X11(sink->display)),
|
|
|
|
xid,
|
2010-05-13 04:22:31 +00:00
|
|
|
&rootwin,
|
|
|
|
&x, &y, &width, &height, &border_width, &depth
|
2010-05-12 19:35:45 +00:00
|
|
|
);
|
|
|
|
gst_vaapi_display_unlock(sink->display);
|
|
|
|
|
2010-05-17 08:55:51 +00:00
|
|
|
if ((width != sink->window_width || height != sink->window_height) &&
|
|
|
|
!configure_notify_event_pending(sink, xid, width, height)) {
|
2010-05-13 04:22:31 +00:00
|
|
|
if (!gst_vaapisink_ensure_render_rect(sink, width, height))
|
2010-05-12 19:40:30 +00:00
|
|
|
return FALSE;
|
2010-05-13 04:22:31 +00:00
|
|
|
sink->window_width = width;
|
|
|
|
sink->window_height = height;
|
2010-05-12 19:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sink->window &&
|
|
|
|
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window)) == xid)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (sink->window) {
|
|
|
|
g_object_unref(sink->window);
|
|
|
|
sink->window = NULL;
|
|
|
|
}
|
|
|
|
|
2010-03-29 15:03:30 +00:00
|
|
|
#if USE_VAAPISINK_GLX
|
2010-05-12 19:35:45 +00:00
|
|
|
if (sink->use_glx)
|
|
|
|
sink->window = gst_vaapi_window_glx_new_with_xid(sink->display, xid);
|
|
|
|
else
|
2010-03-29 14:13:26 +00:00
|
|
|
#endif
|
2010-05-12 19:35:45 +00:00
|
|
|
sink->window = gst_vaapi_window_x11_new_with_xid(sink->display, xid);
|
|
|
|
return sink->window != NULL;
|
2010-03-15 17:09:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_vaapisink_start(GstBaseSink *base_sink)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_vaapisink_stop(GstBaseSink *base_sink)
|
|
|
|
{
|
|
|
|
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
|
|
|
|
|
|
|
|
if (sink->window) {
|
|
|
|
g_object_unref(sink->window);
|
|
|
|
sink->window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sink->display) {
|
|
|
|
g_object_unref(sink->display);
|
|
|
|
sink->display = NULL;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-12 12:58:53 +00:00
|
|
|
static gboolean
|
|
|
|
gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
|
|
|
|
{
|
|
|
|
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
|
|
|
|
GstStructure * const structure = gst_caps_get_structure(caps, 0);
|
2012-01-09 10:23:39 +00:00
|
|
|
guint win_width, win_height;
|
2010-05-12 12:58:53 +00:00
|
|
|
gint video_width, video_height, video_par_n = 1, video_par_d = 1;
|
|
|
|
|
|
|
|
if (!structure)
|
|
|
|
return FALSE;
|
|
|
|
if (!gst_structure_get_int(structure, "width", &video_width))
|
|
|
|
return FALSE;
|
|
|
|
if (!gst_structure_get_int(structure, "height", &video_height))
|
|
|
|
return FALSE;
|
|
|
|
sink->video_width = video_width;
|
|
|
|
sink->video_height = video_height;
|
|
|
|
|
|
|
|
gst_video_parse_caps_pixel_aspect_ratio(caps, &video_par_n, &video_par_d);
|
|
|
|
sink->video_par_n = video_par_n;
|
|
|
|
sink->video_par_d = video_par_d;
|
2010-05-13 04:27:44 +00:00
|
|
|
GST_DEBUG("video pixel-aspect-ratio %d/%d", video_par_n, video_par_d);
|
2010-05-12 12:58:53 +00:00
|
|
|
|
2011-11-04 20:50:15 +00:00
|
|
|
if (!gst_vaapi_ensure_display(sink, &sink->display))
|
|
|
|
return FALSE;
|
|
|
|
|
2012-01-09 10:23:39 +00:00
|
|
|
if (sink->fullscreen)
|
|
|
|
gst_vaapi_display_get_size(sink->display, &win_width, &win_height);
|
2010-03-22 12:03:26 +00:00
|
|
|
else {
|
2012-01-09 10:23:39 +00:00
|
|
|
win_width = video_width;
|
|
|
|
win_height = video_height;
|
2010-03-22 12:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-03-17 07:20:19 +00:00
|
|
|
if (sink->window)
|
2010-03-22 10:03:24 +00:00
|
|
|
gst_vaapi_window_set_size(sink->window, win_width, win_height);
|
2010-03-17 07:20:19 +00:00
|
|
|
else {
|
2010-05-12 12:58:53 +00:00
|
|
|
gst_vaapi_display_lock(sink->display);
|
|
|
|
gst_x_overlay_prepare_xwindow_id(GST_X_OVERLAY(sink));
|
|
|
|
gst_vaapi_display_unlock(sink->display);
|
|
|
|
if (sink->window)
|
|
|
|
return TRUE;
|
2010-03-29 14:13:26 +00:00
|
|
|
if (!gst_vaapisink_ensure_window(sink, win_width, win_height))
|
2010-03-17 07:20:19 +00:00
|
|
|
return FALSE;
|
2010-03-22 12:03:26 +00:00
|
|
|
gst_vaapi_window_set_fullscreen(sink->window, sink->fullscreen);
|
2010-03-17 07:20:19 +00:00
|
|
|
gst_vaapi_window_show(sink->window);
|
2012-01-09 10:23:39 +00:00
|
|
|
gst_vaapi_window_get_size(sink->window, &win_width, &win_height);
|
2010-03-17 07:20:19 +00:00
|
|
|
}
|
2010-03-29 16:17:38 +00:00
|
|
|
sink->window_width = win_width;
|
|
|
|
sink->window_height = win_height;
|
2012-01-09 10:23:39 +00:00
|
|
|
GST_DEBUG("window size %ux%u", win_width, win_height);
|
|
|
|
|
|
|
|
return gst_vaapisink_ensure_render_rect(sink, win_width, win_height);
|
2010-03-17 07:20:19 +00:00
|
|
|
}
|
|
|
|
|
2010-03-29 15:59:44 +00:00
|
|
|
#if USE_VAAPISINK_GLX
|
|
|
|
static void
|
|
|
|
render_background(GstVaapiSink *sink)
|
|
|
|
{
|
|
|
|
/* Original code from Mirco Muller (MacSlow):
|
|
|
|
<http://cgit.freedesktop.org/~macslow/gl-gst-player/> */
|
|
|
|
GLfloat fStartX = 0.0f;
|
|
|
|
GLfloat fStartY = 0.0f;
|
2010-03-29 16:17:38 +00:00
|
|
|
GLfloat fWidth = (GLfloat)sink->window_width;
|
|
|
|
GLfloat fHeight = (GLfloat)sink->window_height;
|
2010-03-29 15:59:44 +00:00
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
{
|
|
|
|
/* top third, darker grey to white */
|
|
|
|
glColor3f(0.85f, 0.85f, 0.85f);
|
|
|
|
glVertex3f(fStartX, fStartY, 0.0f);
|
|
|
|
glColor3f(0.85f, 0.85f, 0.85f);
|
|
|
|
glVertex3f(fStartX + fWidth, fStartY, 0.0f);
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
glVertex3f(fStartX + fWidth, fStartY + fHeight / 3.0f, 0.0f);
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
glVertex3f(fStartX, fStartY + fHeight / 3.0f, 0.0f);
|
|
|
|
|
|
|
|
/* middle third, just plain white */
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
glVertex3f(fStartX, fStartY + fHeight / 3.0f, 0.0f);
|
|
|
|
glVertex3f(fStartX + fWidth, fStartY + fHeight / 3.0f, 0.0f);
|
|
|
|
glVertex3f(fStartX + fWidth, fStartY + 2.0f * fHeight / 3.0f, 0.0f);
|
|
|
|
glVertex3f(fStartX, fStartY + 2.0f * fHeight / 3.0f, 0.0f);
|
|
|
|
|
|
|
|
/* bottom third, white to lighter grey */
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
glVertex3f(fStartX, fStartY + 2.0f * fHeight / 3.0f, 0.0f);
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
glVertex3f(fStartX + fWidth, fStartY + 2.0f * fHeight / 3.0f, 0.0f);
|
|
|
|
glColor3f(0.62f, 0.66f, 0.69f);
|
|
|
|
glVertex3f(fStartX + fWidth, fStartY + fHeight, 0.0f);
|
|
|
|
glColor3f(0.62f, 0.66f, 0.69f);
|
|
|
|
glVertex3f(fStartX, fStartY + fHeight, 0.0f);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
render_frame(GstVaapiSink *sink)
|
|
|
|
{
|
2010-03-29 16:24:37 +00:00
|
|
|
const guint x1 = sink->display_rect.x;
|
|
|
|
const guint x2 = sink->display_rect.x + sink->display_rect.width;
|
|
|
|
const guint y1 = sink->display_rect.y;
|
|
|
|
const guint y2 = sink->display_rect.y + sink->display_rect.height;
|
2010-03-29 15:59:44 +00:00
|
|
|
|
|
|
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
{
|
2010-03-29 16:24:37 +00:00
|
|
|
glTexCoord2f(0.0f, 0.0f); glVertex2i(x1, y1);
|
|
|
|
glTexCoord2f(0.0f, 1.0f); glVertex2i(x1, y2);
|
|
|
|
glTexCoord2f(1.0f, 1.0f); glVertex2i(x2, y2);
|
|
|
|
glTexCoord2f(1.0f, 0.0f); glVertex2i(x2, y1);
|
2010-03-29 15:59:44 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
render_reflection(GstVaapiSink *sink)
|
|
|
|
{
|
2010-03-29 16:24:37 +00:00
|
|
|
const guint x1 = sink->display_rect.x;
|
|
|
|
const guint x2 = sink->display_rect.x + sink->display_rect.width;
|
|
|
|
const guint y1 = sink->display_rect.y;
|
|
|
|
const guint rh = sink->display_rect.height / 5;
|
|
|
|
GLfloat ry = 1.0f - (GLfloat)rh / (GLfloat)sink->display_rect.height;
|
2010-03-29 15:59:44 +00:00
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
{
|
|
|
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
2010-03-29 16:24:37 +00:00
|
|
|
glTexCoord2f(0.0f, 1.0f); glVertex2i(x1, y1);
|
|
|
|
glTexCoord2f(1.0f, 1.0f); glVertex2i(x2, y1);
|
2010-03-29 15:59:44 +00:00
|
|
|
|
|
|
|
glColor4f(1.0f, 1.0f, 1.0f, 0.0f);
|
2010-03-29 16:24:37 +00:00
|
|
|
glTexCoord2f(1.0f, ry); glVertex2i(x2, y1 + rh);
|
|
|
|
glTexCoord2f(0.0f, ry); glVertex2i(x1, y1 + rh);
|
2010-03-29 15:59:44 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2010-05-17 08:24:42 +00:00
|
|
|
gst_vaapisink_show_frame_glx(
|
|
|
|
GstVaapiSink *sink,
|
|
|
|
GstVaapiSurface *surface,
|
|
|
|
guint flags
|
|
|
|
)
|
2010-03-29 15:59:44 +00:00
|
|
|
{
|
|
|
|
GstVaapiWindowGLX * const window = GST_VAAPI_WINDOW_GLX(sink->window);
|
|
|
|
GLenum target;
|
|
|
|
GLuint texture;
|
|
|
|
|
2010-05-17 08:24:42 +00:00
|
|
|
gst_vaapi_window_glx_make_current(window);
|
|
|
|
if (!sink->texture) {
|
|
|
|
sink->texture = gst_vaapi_texture_new(
|
|
|
|
sink->display,
|
|
|
|
GL_TEXTURE_2D,
|
|
|
|
GL_BGRA,
|
|
|
|
sink->video_width,
|
|
|
|
sink->video_height
|
|
|
|
);
|
|
|
|
if (!sink->texture)
|
|
|
|
goto error_create_texture;
|
|
|
|
}
|
|
|
|
if (!gst_vaapi_texture_put_surface(sink->texture, surface, flags))
|
|
|
|
goto error_transfer_surface;
|
2010-03-29 15:59:44 +00:00
|
|
|
|
|
|
|
target = gst_vaapi_texture_get_target(sink->texture);
|
|
|
|
texture = gst_vaapi_texture_get_id(sink->texture);
|
|
|
|
if (target != GL_TEXTURE_2D || !texture)
|
|
|
|
return FALSE;
|
|
|
|
|
2010-07-01 13:19:29 +00:00
|
|
|
if (sink->use_reflection)
|
|
|
|
render_background(sink);
|
2010-03-29 15:59:44 +00:00
|
|
|
|
|
|
|
glEnable(target);
|
|
|
|
glBindTexture(target, texture);
|
|
|
|
{
|
2010-05-17 08:24:42 +00:00
|
|
|
if (sink->use_reflection) {
|
|
|
|
glPushMatrix();
|
|
|
|
glRotatef(20.0f, 0.0f, 1.0f, 0.0f);
|
|
|
|
glTranslatef(50.0f, 0.0f, 0.0f);
|
|
|
|
}
|
2010-03-29 15:59:44 +00:00
|
|
|
render_frame(sink);
|
2010-05-17 08:24:42 +00:00
|
|
|
if (sink->use_reflection) {
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(0.0, (GLfloat)sink->display_rect.height + 5.0f, 0.0f);
|
|
|
|
render_reflection(sink);
|
|
|
|
glPopMatrix();
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
2010-03-29 15:59:44 +00:00
|
|
|
}
|
|
|
|
glBindTexture(target, 0);
|
|
|
|
glDisable(target);
|
2010-05-17 08:24:42 +00:00
|
|
|
gst_vaapi_window_glx_swap_buffers(window);
|
2010-03-29 15:59:44 +00:00
|
|
|
return TRUE;
|
2010-05-17 08:24:42 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
error_create_texture:
|
|
|
|
{
|
|
|
|
GST_DEBUG("could not create VA/GLX texture");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
error_transfer_surface:
|
|
|
|
{
|
|
|
|
GST_DEBUG("could not transfer VA surface to texture");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-03-29 15:59:44 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-17 08:24:42 +00:00
|
|
|
static inline gboolean
|
|
|
|
gst_vaapisink_show_frame_x11(
|
|
|
|
GstVaapiSink *sink,
|
|
|
|
GstVaapiSurface *surface,
|
|
|
|
guint flags
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (!gst_vaapi_window_put_surface(sink->window, surface,
|
2011-11-23 19:45:46 +00:00
|
|
|
NULL, &sink->display_rect, flags)) {
|
2010-05-17 08:24:42 +00:00
|
|
|
GST_DEBUG("could not render VA surface");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-03-15 17:09:12 +00:00
|
|
|
static GstFlowReturn
|
2010-03-17 07:20:19 +00:00
|
|
|
gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer)
|
2010-03-15 17:09:12 +00:00
|
|
|
{
|
2010-03-17 07:20:19 +00:00
|
|
|
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
|
2010-03-15 17:09:12 +00:00
|
|
|
GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
|
|
|
|
GstVaapiSurface *surface;
|
2010-03-17 07:20:19 +00:00
|
|
|
guint flags;
|
2010-05-17 08:24:42 +00:00
|
|
|
gboolean success;
|
2011-11-23 19:45:46 +00:00
|
|
|
GstVideoOverlayComposition * const composition =
|
|
|
|
gst_video_buffer_get_overlay_composition(buffer);
|
2010-03-17 07:20:19 +00:00
|
|
|
|
2011-11-04 20:50:15 +00:00
|
|
|
if (sink->display != gst_vaapi_video_buffer_get_display (vbuffer)) {
|
|
|
|
if (sink->display)
|
|
|
|
g_object_unref (sink->display);
|
|
|
|
sink->display = g_object_ref (gst_vaapi_video_buffer_get_display (vbuffer));
|
|
|
|
}
|
|
|
|
|
2010-03-17 07:20:19 +00:00
|
|
|
if (!sink->window)
|
|
|
|
return GST_FLOW_UNEXPECTED;
|
2010-03-15 17:09:12 +00:00
|
|
|
|
|
|
|
surface = gst_vaapi_video_buffer_get_surface(vbuffer);
|
|
|
|
if (!surface)
|
|
|
|
return GST_FLOW_UNEXPECTED;
|
|
|
|
|
2010-05-13 09:38:47 +00:00
|
|
|
GST_DEBUG("render surface %" GST_VAAPI_ID_FORMAT,
|
|
|
|
GST_VAAPI_ID_ARGS(gst_vaapi_surface_get_id(surface)));
|
|
|
|
|
2010-03-15 17:09:12 +00:00
|
|
|
flags = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
|
|
|
|
|
2011-12-14 13:40:37 +00:00
|
|
|
if (!gst_vaapi_surface_set_subpictures_from_composition(surface,
|
|
|
|
composition, TRUE))
|
2011-11-23 19:45:46 +00:00
|
|
|
GST_WARNING("could not update subtitles");
|
|
|
|
|
2010-03-29 15:03:30 +00:00
|
|
|
#if USE_VAAPISINK_GLX
|
2010-05-17 08:24:42 +00:00
|
|
|
if (sink->use_glx)
|
|
|
|
success = gst_vaapisink_show_frame_glx(sink, surface, flags);
|
|
|
|
else
|
2010-03-29 14:13:26 +00:00
|
|
|
#endif
|
2010-05-17 08:24:42 +00:00
|
|
|
success = gst_vaapisink_show_frame_x11(sink, surface, flags);
|
|
|
|
return success ? GST_FLOW_OK : GST_FLOW_UNEXPECTED;
|
2010-03-15 17:09:12 +00:00
|
|
|
}
|
|
|
|
|
2011-11-04 20:50:15 +00:00
|
|
|
static gboolean
|
|
|
|
gst_vaapisink_query(GstBaseSink *base_sink, GstQuery *query)
|
|
|
|
{
|
|
|
|
GstVaapiSink *sink = GST_VAAPISINK(base_sink);
|
|
|
|
GST_DEBUG ("sharing display %p", sink->display);
|
|
|
|
return gst_vaapi_reply_to_query (query, sink->display);
|
|
|
|
}
|
|
|
|
|
2010-03-12 23:53:48 +00:00
|
|
|
static void
|
|
|
|
gst_vaapisink_finalize(GObject *object)
|
|
|
|
{
|
|
|
|
gst_vaapisink_destroy(GST_VAAPISINK(object));
|
|
|
|
|
|
|
|
G_OBJECT_CLASS(parent_class)->finalize(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapisink_set_property(
|
|
|
|
GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec
|
|
|
|
)
|
|
|
|
{
|
|
|
|
GstVaapiSink * const sink = GST_VAAPISINK(object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-03-29 14:13:26 +00:00
|
|
|
case PROP_USE_GLX:
|
|
|
|
sink->use_glx = g_value_get_boolean(value);
|
|
|
|
break;
|
2010-03-22 12:03:26 +00:00
|
|
|
case PROP_FULLSCREEN:
|
|
|
|
sink->fullscreen = g_value_get_boolean(value);
|
|
|
|
break;
|
2010-03-26 11:30:54 +00:00
|
|
|
case PROP_SYNCHRONOUS:
|
|
|
|
sink->synchronous = g_value_get_boolean(value);
|
|
|
|
break;
|
2010-03-29 15:59:44 +00:00
|
|
|
case PROP_USE_REFLECTION:
|
|
|
|
sink->use_reflection = g_value_get_boolean(value);
|
|
|
|
break;
|
2010-03-12 23:53:48 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapisink_get_property(
|
|
|
|
GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec
|
|
|
|
)
|
|
|
|
{
|
|
|
|
GstVaapiSink * const sink = GST_VAAPISINK(object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-03-29 14:13:26 +00:00
|
|
|
case PROP_USE_GLX:
|
|
|
|
g_value_set_boolean(value, sink->use_glx);
|
|
|
|
break;
|
2010-03-22 12:03:26 +00:00
|
|
|
case PROP_FULLSCREEN:
|
|
|
|
g_value_set_boolean(value, sink->fullscreen);
|
|
|
|
break;
|
2010-03-26 11:30:54 +00:00
|
|
|
case PROP_SYNCHRONOUS:
|
|
|
|
g_value_set_boolean(value, sink->synchronous);
|
|
|
|
break;
|
2010-03-29 15:59:44 +00:00
|
|
|
case PROP_USE_REFLECTION:
|
|
|
|
g_value_set_boolean(value, sink->use_reflection);
|
|
|
|
break;
|
2010-03-12 23:53:48 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-03-05 17:11:52 +00:00
|
|
|
|
2010-05-12 09:34:37 +00:00
|
|
|
static void
|
|
|
|
gst_vaapisink_base_init(gpointer klass)
|
2010-03-05 17:11:52 +00:00
|
|
|
{
|
|
|
|
GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
|
|
|
|
|
|
|
|
gst_element_class_set_details(element_class, &gst_vaapisink_details);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template(
|
|
|
|
element_class,
|
|
|
|
gst_static_pad_template_get(&gst_vaapisink_sink_factory)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-05-12 09:34:37 +00:00
|
|
|
static void
|
|
|
|
gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
2010-03-05 17:11:52 +00:00
|
|
|
{
|
2010-04-29 21:59:14 +00:00
|
|
|
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
|
|
|
GstBaseSinkClass * const basesink_class = GST_BASE_SINK_CLASS(klass);
|
|
|
|
|
2011-09-14 19:12:41 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT(gst_debug_vaapisink,
|
|
|
|
GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
|
|
|
|
|
2010-04-29 21:59:14 +00:00
|
|
|
object_class->finalize = gst_vaapisink_finalize;
|
|
|
|
object_class->set_property = gst_vaapisink_set_property;
|
|
|
|
object_class->get_property = gst_vaapisink_get_property;
|
|
|
|
|
|
|
|
basesink_class->start = gst_vaapisink_start;
|
|
|
|
basesink_class->stop = gst_vaapisink_stop;
|
|
|
|
basesink_class->set_caps = gst_vaapisink_set_caps;
|
|
|
|
basesink_class->preroll = gst_vaapisink_show_frame;
|
|
|
|
basesink_class->render = gst_vaapisink_show_frame;
|
2011-11-04 20:50:15 +00:00
|
|
|
basesink_class->query = gst_vaapisink_query;
|
2010-03-15 17:09:12 +00:00
|
|
|
|
2010-03-29 15:03:30 +00:00
|
|
|
#if USE_VAAPISINK_GLX
|
2010-03-29 14:13:26 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class,
|
|
|
|
PROP_USE_GLX,
|
|
|
|
g_param_spec_boolean("use-glx",
|
|
|
|
"GLX rendering",
|
|
|
|
"Enables GLX rendering",
|
2010-03-29 15:03:30 +00:00
|
|
|
TRUE,
|
2010-03-29 14:13:26 +00:00
|
|
|
G_PARAM_READWRITE));
|
2010-03-29 15:59:44 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(object_class,
|
|
|
|
PROP_USE_REFLECTION,
|
|
|
|
g_param_spec_boolean("use-reflection",
|
|
|
|
"Reflection effect",
|
|
|
|
"Enables OpenGL reflection effect",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE));
|
2010-03-29 14:13:26 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-22 12:03:26 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class,
|
|
|
|
PROP_FULLSCREEN,
|
|
|
|
g_param_spec_boolean("fullscreen",
|
|
|
|
"Fullscreen",
|
|
|
|
"Requests window in fullscreen state",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE));
|
2010-03-26 11:30:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiSink:synchronous:
|
|
|
|
*
|
|
|
|
* When enabled, runs the X display in synchronous mode. Note that
|
|
|
|
* this is used only for debugging.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property
|
|
|
|
(object_class,
|
|
|
|
PROP_SYNCHRONOUS,
|
|
|
|
g_param_spec_boolean("synchronous",
|
|
|
|
"Synchronous mode",
|
|
|
|
"Toggles X display synchronous mode",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE));
|
2010-03-05 17:11:52 +00:00
|
|
|
}
|
|
|
|
|
2010-05-12 09:34:37 +00:00
|
|
|
static void
|
|
|
|
gst_vaapisink_init(GstVaapiSink *sink, GstVaapiSinkClass *klass)
|
2010-03-05 17:11:52 +00:00
|
|
|
{
|
2010-03-29 15:59:44 +00:00
|
|
|
sink->display = NULL;
|
|
|
|
sink->window = NULL;
|
2010-03-29 16:17:38 +00:00
|
|
|
sink->window_width = 0;
|
|
|
|
sink->window_height = 0;
|
2010-03-29 15:59:44 +00:00
|
|
|
sink->texture = NULL;
|
|
|
|
sink->video_width = 0;
|
|
|
|
sink->video_height = 0;
|
2010-05-12 12:58:53 +00:00
|
|
|
sink->video_par_n = 1;
|
|
|
|
sink->video_par_d = 1;
|
2010-05-18 11:22:54 +00:00
|
|
|
sink->foreign_window = FALSE;
|
2010-03-29 15:59:44 +00:00
|
|
|
sink->fullscreen = FALSE;
|
|
|
|
sink->synchronous = FALSE;
|
|
|
|
sink->use_glx = USE_VAAPISINK_GLX;
|
|
|
|
sink->use_reflection = FALSE;
|
2010-03-12 23:53:48 +00:00
|
|
|
}
|