2010-03-25 17:28:49 +00:00
|
|
|
/*
|
|
|
|
* gstvaapidisplay_glx.c - VA/GLX display abstraction
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-11-22 05:37:12 +00:00
|
|
|
* Copyright (C) 2011-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2010-03-25 17:28:49 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +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-25 17:28:49 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-03-25 17:28:49 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-05-03 07:07:27 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-03-25 17:28:49 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +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-25 17:28:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gstvaapidisplay_glx
|
|
|
|
* @short_description: VA/GLX display abstraction
|
|
|
|
*/
|
|
|
|
|
2012-01-30 17:12:59 +00:00
|
|
|
#include "sysdeps.h"
|
2010-03-30 13:01:34 +00:00
|
|
|
#include "gstvaapicompat.h"
|
2010-03-25 17:28:49 +00:00
|
|
|
#include "gstvaapiutils.h"
|
2010-04-01 13:41:24 +00:00
|
|
|
#include "gstvaapiutils_glx.h"
|
2010-04-01 09:47:59 +00:00
|
|
|
#include "gstvaapidisplay_priv.h"
|
2010-04-01 13:41:24 +00:00
|
|
|
#include "gstvaapidisplay_x11_priv.h"
|
|
|
|
#include "gstvaapidisplay_glx.h"
|
|
|
|
#include "gstvaapidisplay_glx_priv.h"
|
2014-12-10 17:12:24 +00:00
|
|
|
#include "gstvaapiwindow_glx.h"
|
2014-12-04 13:36:35 +00:00
|
|
|
#include "gstvaapitexture_glx.h"
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
#define DEBUG_VAAPI_DISPLAY 1
|
2010-03-25 17:28:49 +00:00
|
|
|
#include "gstvaapidebug.h"
|
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
G_DEFINE_TYPE (GstVaapiDisplayGLX, gst_vaapi_display_glx,
|
|
|
|
GST_TYPE_VAAPI_DISPLAY_X11);
|
|
|
|
|
2014-12-10 17:12:24 +00:00
|
|
|
static GstVaapiWindow *
|
|
|
|
gst_vaapi_display_glx_create_window (GstVaapiDisplay * display, GstVaapiID id,
|
|
|
|
guint width, guint height)
|
|
|
|
{
|
|
|
|
return id != GST_VAAPI_ID_INVALID ?
|
|
|
|
gst_vaapi_window_glx_new_with_xid (display, id) :
|
|
|
|
gst_vaapi_window_glx_new (display, width, height);
|
|
|
|
}
|
|
|
|
|
2016-09-22 07:34:38 +00:00
|
|
|
static void
|
|
|
|
ensure_texture_map (GstVaapiDisplayGLX * display)
|
|
|
|
{
|
|
|
|
if (!display->texture_map)
|
|
|
|
display->texture_map = gst_vaapi_texture_map_new ();
|
|
|
|
}
|
|
|
|
|
2014-12-04 13:36:35 +00:00
|
|
|
static GstVaapiTexture *
|
|
|
|
gst_vaapi_display_glx_create_texture (GstVaapiDisplay * display, GstVaapiID id,
|
|
|
|
guint target, guint format, guint width, guint height)
|
|
|
|
{
|
2016-09-22 07:34:38 +00:00
|
|
|
GstVaapiTexture *texture;
|
|
|
|
GstVaapiDisplayGLX *dpy = GST_VAAPI_DISPLAY_GLX (display);
|
|
|
|
|
|
|
|
if (id == GST_VAAPI_ID_INVALID)
|
|
|
|
return gst_vaapi_texture_glx_new (display, target, format, width, height);
|
|
|
|
|
|
|
|
ensure_texture_map (dpy);
|
|
|
|
if (!(texture = gst_vaapi_texture_map_lookup (dpy->texture_map, id))) {
|
|
|
|
if ((texture =
|
|
|
|
gst_vaapi_texture_glx_new_wrapped (display, id, target, format))) {
|
|
|
|
gst_vaapi_texture_map_add (dpy->texture_map, texture, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstVaapiTextureMap *
|
|
|
|
gst_vaapi_display_glx_get_texture_map (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
return GST_VAAPI_DISPLAY_GLX (display)->texture_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-13 03:53:17 +00:00
|
|
|
gst_vaapi_display_glx_finalize (GObject * object)
|
2016-09-22 07:34:38 +00:00
|
|
|
{
|
2016-10-13 03:53:17 +00:00
|
|
|
GstVaapiDisplayGLX *dpy = GST_VAAPI_DISPLAY_GLX (object);
|
2016-09-22 07:34:38 +00:00
|
|
|
|
|
|
|
if (dpy->texture_map)
|
|
|
|
gst_object_unref (dpy->texture_map);
|
2016-10-13 03:53:17 +00:00
|
|
|
G_OBJECT_CLASS (gst_vaapi_display_glx_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapi_display_glx_init (GstVaapiDisplayGLX * display)
|
|
|
|
{
|
2014-12-04 13:36:35 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 17:28:49 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_glx_class_init (GstVaapiDisplayGLXClass * klass)
|
2010-03-25 17:28:49 +00:00
|
|
|
{
|
2016-10-13 03:53:17 +00:00
|
|
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
object_class->finalize = gst_vaapi_display_glx_finalize;
|
2014-12-10 17:02:55 +00:00
|
|
|
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_GLX;
|
2014-12-10 17:12:24 +00:00
|
|
|
dpy_class->create_window = gst_vaapi_display_glx_create_window;
|
2014-12-04 13:36:35 +00:00
|
|
|
dpy_class->create_texture = gst_vaapi_display_glx_create_texture;
|
2016-09-22 07:34:38 +00:00
|
|
|
dpy_class->get_texture_map = gst_vaapi_display_glx_get_texture_map;
|
2010-03-25 17:28:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_glx_new:
|
|
|
|
* @display_name: the X11 display name
|
|
|
|
*
|
|
|
|
* Opens an X11 #Display using @display_name and returns a newly
|
|
|
|
* allocated #GstVaapiDisplay object. The X11 display will be cloed
|
|
|
|
* when the reference count of the object reaches zero.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_glx_new (const gchar * display_name)
|
2010-03-25 17:28:49 +00:00
|
|
|
{
|
2018-06-01 03:36:51 +00:00
|
|
|
GstVaapiDisplay *display;
|
|
|
|
|
|
|
|
display = g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL);
|
|
|
|
return gst_vaapi_display_config (display,
|
2013-12-20 12:27:07 +00:00
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
|
2010-03-25 17:28:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_glx_new_with_display:
|
|
|
|
* @x11_display: an X11 #Display
|
|
|
|
*
|
|
|
|
* Creates a #GstVaapiDisplay based on the X11 @x11_display
|
|
|
|
* display. The caller still owns the display and must call
|
|
|
|
* XCloseDisplay() when all #GstVaapiDisplay references are
|
|
|
|
* released. Doing so too early can yield undefined behaviour.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_glx_new_with_display (Display * x11_display)
|
2010-03-25 17:28:49 +00:00
|
|
|
{
|
2018-06-01 03:36:51 +00:00
|
|
|
GstVaapiDisplay *display;
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (x11_display != NULL, NULL);
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2018-06-01 03:36:51 +00:00
|
|
|
display = g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL);
|
|
|
|
return gst_vaapi_display_config (display,
|
2013-12-20 12:27:07 +00:00
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
|
2010-03-25 17:28:49 +00:00
|
|
|
}
|