gstvaapidisplay_glx.c 3.44 KB
Newer Older
gb's avatar
gb committed
1 2 3
/*
 *  gstvaapidisplay_glx.c - VA/GLX display abstraction
 *
4
 *  Copyright (C) 2010-2011 Splitted-Desktop Systems
gb's avatar
gb committed
5
 *
6 7 8 9
 *  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.
gb's avatar
gb committed
10
 *
11
 *  This library is distributed in the hope that it will be useful,
gb's avatar
gb committed
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
gb's avatar
gb committed
15
 *
16 17 18 19
 *  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
gb's avatar
gb committed
20 21 22 23 24 25 26 27
 */

/**
 * SECTION:gstvaapidisplay_glx
 * @short_description: VA/GLX display abstraction
 */

#include "config.h"
28
#include "gstvaapicompat.h"
gb's avatar
gb committed
29
#include "gstvaapiutils.h"
30
#include "gstvaapiutils_glx.h"
31
#include "gstvaapidisplay_priv.h"
32 33 34
#include "gstvaapidisplay_x11_priv.h"
#include "gstvaapidisplay_glx.h"
#include "gstvaapidisplay_glx_priv.h"
gb's avatar
gb committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48

#define DEBUG 1
#include "gstvaapidebug.h"

G_DEFINE_TYPE(GstVaapiDisplayGLX,
              gst_vaapi_display_glx,
              GST_VAAPI_TYPE_DISPLAY_X11);

static void
gst_vaapi_display_glx_finalize(GObject *object)
{
    G_OBJECT_CLASS(gst_vaapi_display_glx_parent_class)->finalize(object);
}

49 50 51 52 53
static gboolean
gst_vaapi_display_glx_get_display_info(
    GstVaapiDisplay     *display,
    GstVaapiDisplayInfo *info
)
gb's avatar
gb committed
54
{
55 56 57 58 59 60 61
    GstVaapiDisplayClass * const dpy_class =
        GST_VAAPI_DISPLAY_CLASS(gst_vaapi_display_glx_parent_class);

    info->va_display = vaGetDisplayGLX(GST_VAAPI_DISPLAY_XDISPLAY(display));
    if (!info->va_display)
        return FALSE;
    return dpy_class->get_display(display, info);
gb's avatar
gb committed
62 63 64 65 66 67 68 69 70
}

static void
gst_vaapi_display_glx_class_init(GstVaapiDisplayGLXClass *klass)
{
    GObjectClass * const object_class = G_OBJECT_CLASS(klass);
    GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);

    object_class->finalize      = gst_vaapi_display_glx_finalize;
71
    dpy_class->get_display      = gst_vaapi_display_glx_get_display_info;
gb's avatar
gb committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
}

static void
gst_vaapi_display_glx_init(GstVaapiDisplayGLX *display)
{
}

/**
 * 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 *
gst_vaapi_display_glx_new(const gchar *display_name)
{
    return g_object_new(GST_VAAPI_TYPE_DISPLAY_GLX,
                        "display-name", display_name,
                        NULL);
}

/**
 * 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 *
gst_vaapi_display_glx_new_with_display(Display *x11_display)
{
    return g_object_new(GST_VAAPI_TYPE_DISPLAY_GLX,
                        "x11-display", x11_display,
                        NULL);
}