Make more helpers internal, thus reducing .text size further. Add gst_vaapi_display_x...
authorgb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>
Thu, 1 Apr 2010 13:41:24 +0000 (13:41 +0000)
committergb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>
Thu, 1 Apr 2010 13:41:24 +0000 (13:41 +0000)
13 files changed:
docs/reference/libs/libs-sections.txt
gst-libs/gst/vaapi/Makefile.am
gst-libs/gst/vaapi/gstvaapidisplay_glx.c
gst-libs/gst/vaapi/gstvaapidisplay_glx_priv.h [new file with mode: 0644]
gst-libs/gst/vaapi/gstvaapidisplay_priv.h
gst-libs/gst/vaapi/gstvaapidisplay_x11.c
gst-libs/gst/vaapi/gstvaapidisplay_x11.h
gst-libs/gst/vaapi/gstvaapidisplay_x11_priv.h [new file with mode: 0644]
gst-libs/gst/vaapi/gstvaapiobject_priv.h
gst-libs/gst/vaapi/gstvaapitexture.c
gst-libs/gst/vaapi/gstvaapiwindow_glx.c
gst-libs/gst/vaapi/gstvaapiwindow_x11.c
tests/test-windows.c

index 9847492..7a8414d 100644 (file)
@@ -51,10 +51,10 @@ gst_vaapi_video_sink_get_type
 <TITLE>GstVaapiDisplayX11</TITLE>
 GstVaapiDisplayX11
 GstVaapiDisplayX11Class
-GST_VAAPI_DISPLAY_XDISPLAY
 gst_vaapi_display_x11_new
 gst_vaapi_display_x11_new_with_display
 gst_vaapi_display_x11_get_display
+gst_vaapi_display_x11_get_screen
 <SUBSECTION Standard>
 GST_VAAPI_DISPLAY_X11
 GST_VAAPI_IS_DISPLAY_X11
index 3a9295b..6809431 100644 (file)
@@ -70,6 +70,7 @@ libgstvaapi_x11_source_h =                    \
 
 libgstvaapi_x11_source_priv_h =                        \
        gstvaapicompat.h                        \
+       gstvaapidisplay_x11_priv.h              \
        gstvaapiutils.h                         \
        gstvaapiutils_x11.h                     \
        $(NULL)
@@ -91,6 +92,7 @@ libgstvaapi_glx_source_h =                    \
 
 libgstvaapi_glx_source_priv_h =                        \
        gstvaapicompat.h                        \
+       gstvaapidisplay_glx_priv.h              \
        gstvaapiutils.h                         \
        gstvaapiutils_glx.h                     \
        gstvaapiutils_x11.h                     \
index d6d4e46..14cc35b 100644 (file)
 #include "config.h"
 #include "gstvaapicompat.h"
 #include "gstvaapiutils.h"
-#include "gstvaapidisplay_glx.h"
+#include "gstvaapiutils_glx.h"
 #include "gstvaapidisplay_priv.h"
+#include "gstvaapidisplay_x11_priv.h"
+#include "gstvaapidisplay_glx.h"
+#include "gstvaapidisplay_glx_priv.h"
 
 #define DEBUG 1
 #include "gstvaapidebug.h"
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_glx_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_glx_priv.h
new file mode 100644 (file)
index 0000000..d6758b0
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  gstvaapidisplay_glx_priv.h - Internal VA/GLX interface
+ *
+ *  gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+#ifndef GST_VAAPI_DISPLAY_GLX_PRIV_H
+#define GST_VAAPI_DISPLAY_GLX_PRIV_H
+
+#include <gst/vaapi/gstvaapiutils_glx.h>
+#include <gst/vaapi/gstvaapidisplay_glx.h>
+
+G_BEGIN_DECLS
+
+#define GST_VAAPI_DISPLAY_GLX_CAST(display) ((GstVaapiDisplayGLX *)(display))
+
+G_END_DECLS
+
+#endif /* GST_VAAPI_DISPLAY_GLX_PRIV_H */
index 7cc40fd..0f8adbd 100644 (file)
@@ -39,6 +39,7 @@ G_BEGIN_DECLS
  * Macro that evaluates to the #VADisplay of @display.
  * This is an internal macro that does not do any run-time type check.
  */
+#undef  GST_VAAPI_DISPLAY_VADISPLAY
 #define GST_VAAPI_DISPLAY_VADISPLAY(display_) \
     GST_VAAPI_DISPLAY_CAST(display_)->priv->display
 
@@ -48,8 +49,9 @@ G_BEGIN_DECLS
  *
  * Locks @display
  */
+#undef  GST_VAAPI_DISPLAY_LOCK
 #define GST_VAAPI_DISPLAY_LOCK(display) \
-    gst_vaapi_display_lock(display)
+    gst_vaapi_display_lock(GST_VAAPI_DISPLAY_CAST(display))
 
 /**
  * GST_VAAPI_DISPLAY_UNLOCK:
@@ -57,8 +59,9 @@ G_BEGIN_DECLS
  *
  * Unlocks @display
  */
+#undef  GST_VAAPI_DISPLAY_UNLOCK
 #define GST_VAAPI_DISPLAY_UNLOCK(display) \
-    gst_vaapi_display_unlock(display)
+    gst_vaapi_display_unlock(GST_VAAPI_DISPLAY_CAST(display))
 
 /**
  * GstVaapiDisplayPrivate:
index b0f6bdf..f61a863 100644 (file)
@@ -25,8 +25,9 @@
 
 #include "config.h"
 #include "gstvaapiutils.h"
-#include "gstvaapidisplay_x11.h"
 #include "gstvaapidisplay_priv.h"
+#include "gstvaapidisplay_x11.h"
+#include "gstvaapidisplay_x11_priv.h"
 
 #define DEBUG 1
 #include "gstvaapidebug.h"
@@ -35,25 +36,13 @@ G_DEFINE_TYPE(GstVaapiDisplayX11,
               gst_vaapi_display_x11,
               GST_VAAPI_TYPE_DISPLAY);
 
-#define GST_VAAPI_DISPLAY_X11_GET_PRIVATE(obj)                  \
-    (G_TYPE_INSTANCE_GET_PRIVATE((obj),                         \
-                                 GST_VAAPI_TYPE_DISPLAY_X11,   \
-                                 GstVaapiDisplayX11Private))
-
-struct _GstVaapiDisplayX11Private {
-    gchar      *display_name;
-    Display    *x11_display;
-    int         x11_screen;
-    guint       create_display  : 1;
-    guint       synchronous     : 1;
-};
-
 enum {
     PROP_0,
 
     PROP_SYNCHRONOUS,
     PROP_DISPLAY_NAME,
-    PROP_X11_DISPLAY
+    PROP_X11_DISPLAY,
+    PROP_X11_SCREEN
 };
 
 static void
@@ -107,6 +96,9 @@ gst_vaapi_display_x11_set_property(
     case PROP_X11_DISPLAY:
         display->priv->x11_display = g_value_get_pointer(value);
         break;
+    case PROP_X11_SCREEN:
+        display->priv->x11_screen = g_value_get_int(value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -133,6 +125,9 @@ gst_vaapi_display_x11_get_property(
     case PROP_X11_DISPLAY:
         g_value_set_pointer(value, gst_vaapi_display_x11_get_display(display));
         break;
+    case PROP_X11_SCREEN:
+        g_value_set_int(value, gst_vaapi_display_x11_get_screen(display));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -163,15 +158,17 @@ gst_vaapi_display_x11_open_display(GstVaapiDisplay *display)
         GST_VAAPI_DISPLAY_X11(display)->priv;
 
     /* XXX: maintain an X11 display cache */
-    if (!priv->x11_display && priv->create_display)
+    if (priv->create_display) {
         priv->x11_display = XOpenDisplay(priv->display_name);
+        if (!priv->x11_display)
+            return FALSE;
+        priv->x11_screen = DefaultScreen(priv->x11_display);
+    }
     if (!priv->x11_display)
         return FALSE;
 
     if (priv->synchronous)
         XSynchronize(priv->x11_display, True);
-
-    priv->x11_screen = DefaultScreen(priv->x11_display);
     return TRUE;
 }
 
@@ -316,6 +313,21 @@ gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
                               G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
 
     /**
+     * GstVaapiDisplayX11:x11-screen:
+     *
+     * The X11 screen that was created by gst_vaapi_display_x11_new()
+     * or that was bound from gst_vaapi_display_x11_new_with_display().
+     */
+    g_object_class_install_property
+        (object_class,
+         PROP_X11_SCREEN,
+         g_param_spec_int("x11-screen",
+                          "X11 screen",
+                          "X11 screen",
+                          0, G_MAXINT32, 0,
+                          G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+
+    /**
      * GstVaapiDisplayX11:display-name:
      *
      * The X11 display name.
@@ -374,8 +386,11 @@ gst_vaapi_display_x11_new(const gchar *display_name)
 GstVaapiDisplay *
 gst_vaapi_display_x11_new_with_display(Display *x11_display)
 {
+    g_return_val_if_fail(x11_display, NULL);
+
     return g_object_new(GST_VAAPI_TYPE_DISPLAY_X11,
                         "x11-display", x11_display,
+                        "x11-screen",  DefaultScreen(x11_display),
                         NULL);
 }
 
@@ -396,3 +411,21 @@ gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display)
 
     return display->priv->x11_display;
 }
+
+/**
+ * gst_vaapi_display_x11_get_screen:
+ * @display: a #GstVaapiDisplayX11
+ *
+ * Returns the default X11 screen that was created by
+ * gst_vaapi_display_x11_new() or that was bound from
+ * gst_vaapi_display_x11_new_with_display().
+ *
+ * Return value: the X11 #Display attached to @display
+ */
+int
+gst_vaapi_display_x11_get_screen(GstVaapiDisplayX11 *display)
+{
+    g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), -1);
+
+    return display->priv->x11_screen;
+}
index d6c2d15..8a52c57 100644 (file)
@@ -55,15 +55,6 @@ G_BEGIN_DECLS
                                GST_VAAPI_TYPE_DISPLAY_X11,      \
                                GstVaapiDisplayX11Class))
 
-/**
- * GST_VAAPI_DISPLAY_XDISPLAY:
- * @display: a #GstVaapiDisplay
- *
- * Macro that evaluates to the underlying X11 #Display of @display
- */
-#define GST_VAAPI_DISPLAY_XDISPLAY(display) \
-    gst_vaapi_display_x11_get_display(GST_VAAPI_DISPLAY_X11(display))
-
 typedef struct _GstVaapiDisplayX11              GstVaapiDisplayX11;
 typedef struct _GstVaapiDisplayX11Private       GstVaapiDisplayX11Private;
 typedef struct _GstVaapiDisplayX11Class         GstVaapiDisplayX11Class;
@@ -103,6 +94,9 @@ gst_vaapi_display_x11_new_with_display(Display *x11_display);
 Display *
 gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display);
 
+int
+gst_vaapi_display_x11_get_screen(GstVaapiDisplayX11 *display);
+
 G_END_DECLS
 
 #endif /* GST_VAAPI_DISPLAY_X11_H */
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_x11_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_x11_priv.h
new file mode 100644 (file)
index 0000000..9ffb1aa
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *  gstvaapidisplay_x11_priv.h - Internal VA/X11 interface
+ *
+ *  gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+#ifndef GST_VAAPI_DISPLAY_X11_PRIV_H
+#define GST_VAAPI_DISPLAY_X11_PRIV_H
+
+#include <gst/vaapi/gstvaapiutils_x11.h>
+#include <gst/vaapi/gstvaapidisplay_x11.h>
+
+G_BEGIN_DECLS
+
+#define GST_VAAPI_DISPLAY_X11_GET_PRIVATE(obj)                  \
+    (G_TYPE_INSTANCE_GET_PRIVATE((obj),                         \
+                                 GST_VAAPI_TYPE_DISPLAY_X11,   \
+                                 GstVaapiDisplayX11Private))
+
+#define GST_VAAPI_DISPLAY_X11_CAST(display) ((GstVaapiDisplayX11 *)(display))
+
+/**
+ * GST_VAAPI_DISPLAY_XDISPLAY:
+ * @display: a #GstVaapiDisplay
+ *
+ * Macro that evaluates to the underlying X11 #Display of @display
+ */
+#undef  GST_VAAPI_DISPLAY_XDISPLAY
+#define GST_VAAPI_DISPLAY_XDISPLAY(display) \
+    GST_VAAPI_DISPLAY_X11_CAST(display)->priv->x11_display
+
+/**
+ * GST_VAAPI_DISPLAY_XSCREEN:
+ * @display: a #GstVaapiDisplay
+ *
+ * Macro that evaluates to the underlying X11 screen of @display
+ */
+#undef  GST_VAAPI_DISPLAY_XSCREEN
+#define GST_VAAPI_DISPLAY_XSCREEN(display) \
+    GST_VAAPI_DISPLAY_X11_CAST(display)->priv->x11_screen
+
+struct _GstVaapiDisplayX11Private {
+    gchar      *display_name;
+    Display    *x11_display;
+    int         x11_screen;
+    guint       create_display  : 1;
+    guint       synchronous     : 1;
+};
+
+G_END_DECLS
+
+#endif /* GST_VAAPI_DISPLAY_X11_PRIV_H */
index 0a8f75e..1720d62 100644 (file)
@@ -43,11 +43,44 @@ G_BEGIN_DECLS
     GST_VAAPI_OBJECT_CAST(object)->priv->display
 
 /**
+ * GST_VAAPI_OBJECT_ID:
+ * @object: a #GstVaapiObject
+ *
+ * Macro that evaluates to the #GstVaapiID contained in @object.
+ * This is an internal macro that does not do any run-time type checks.
+ */
+#define GST_VAAPI_OBJECT_ID(object) \
+    GST_VAAPI_OBJECT_CAST(object)->priv->id
+
+/**
+ * GST_VAAPI_OBJECT_DISPLAY_X11:
+ * @object: a #GstVaapiObject
+ *
+ * Macro that evaluates to the #GstVaapiDisplayX11 the @object is bound to.
+ * This is an internal macro that does not do any run-time type check
+ * and requires #include "gstvaapidisplay_x11_priv.h"
+ */
+#define GST_VAAPI_OBJECT_DISPLAY_X11(object) \
+    GST_VAAPI_DISPLAY_X11_CAST(GST_VAAPI_OBJECT_DISPLAY(object))
+
+/**
+ * GST_VAAPI_OBJECT_DISPLAY_GLX:
+ * @object: a #GstVaapiObject
+ *
+ * Macro that evaluates to the #GstVaapiDisplayGLX the @object is bound to.
+ * This is an internal macro that does not do any run-time type check
+ * and requires #include "gstvaapidisplay_glx_priv.h".
+ */
+#define GST_VAAPI_OBJECT_DISPLAY_GLX(object) \
+    GST_VAAPI_DISPLAY_GLX_CAST(GST_VAAPI_OBJECT_DISPLAY(object))
+
+/**
  * GST_VAAPI_OBJECT_VADISPLAY:
  * @object: a #GstVaapiObject
  *
  * Macro that evaluates to the #VADisplay of @display.
- * This is an internal macro that does not do any run-time type check.
+ * This is an internal macro that does not do any run-time type check
+ * and requires #include "gstvaapidisplay_priv.h".
  */
 #define GST_VAAPI_OBJECT_VADISPLAY(object) \
     GST_VAAPI_DISPLAY_VADISPLAY(GST_VAAPI_OBJECT_DISPLAY(object))
@@ -57,13 +90,24 @@ G_BEGIN_DECLS
  * @object: a #GstVaapiObject
  *
  * Macro that evaluates to the underlying X11 #Display of @display.
- * This is an internal macro that does not do any run-time type check.
- * Besides, this is only valid within libgstvaapi-x11.
+ * This is an internal macro that does not do any run-time type check
+ * and requires #include "gstvaapidisplay_x11_priv.h".
  */
 #define GST_VAAPI_OBJECT_XDISPLAY(object) \
     GST_VAAPI_DISPLAY_XDISPLAY(GST_VAAPI_OBJECT_DISPLAY(object))
 
 /**
+ * GST_VAAPI_OBJECT_XSCREEN:
+ * @object: a #GstVaapiObject
+ *
+ * Macro that evaluates to the underlying X11 screen of @display.
+ * This is an internal macro that does not do any run-time type check
+ * and requires #include "gstvaapidisplay_x11_priv.h".
+ */
+#define GST_VAAPI_OBJECT_XSCREEN(object) \
+    GST_VAAPI_DISPLAY_XSCREEN(GST_VAAPI_OBJECT_DISPLAY(object))
+
+/**
  * GST_VAAPI_OBJECT_LOCK_DISPLAY:
  * @object: a #GstVaapiObject
  *
@@ -84,16 +128,6 @@ G_BEGIN_DECLS
     GST_VAAPI_DISPLAY_UNLOCK(GST_VAAPI_OBJECT_DISPLAY(object))
 
 /**
- * GST_VAAPI_OBJECT_ID:
- * @object: a #GstVaapiObject
- *
- * Macro that evaluates to the #GstVaapiID contained in @object.
- * This is an internal macro that does not do any run-time type checks.
- */
-#define GST_VAAPI_OBJECT_ID(object) \
-    GST_VAAPI_OBJECT_CAST(object)->priv->id
-
-/**
  * GstVaapiObjectPrivate:
  *
  * VA object base.
index 92f9994..949ef85 100644 (file)
@@ -30,6 +30,7 @@
 #include "gstvaapiutils_glx.h"
 #include "gstvaapidisplay_glx.h"
 #include "gstvaapi_priv.h"
+#include "gstvaapidisplay_x11_priv.h"
 
 #define DEBUG 1
 #include "gstvaapidebug.h"
@@ -165,7 +166,7 @@ gst_vaapi_texture_create(GstVaapiTexture *texture)
     gl_get_current_context(&old_cs);
     priv->gl_context = gl_create_context(
         GST_VAAPI_OBJECT_XDISPLAY(texture),
-        DefaultScreen(GST_VAAPI_OBJECT_XDISPLAY(texture)),
+        GST_VAAPI_OBJECT_XSCREEN(texture),
         &old_cs
     );
     GST_VAAPI_OBJECT_UNLOCK_DISPLAY(texture);
index d050c4f..9ca7b7c 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "gstvaapiwindow_glx.h"
 #include "gstvaapidisplay_x11.h"
+#include "gstvaapidisplay_x11_priv.h"
 #include "gstvaapiutils_x11.h"
 #include "gstvaapiutils_glx.h"
 #include "gstvaapi_priv.h"
@@ -112,7 +113,11 @@ _gst_vaapi_window_glx_create_context(
     parent_cs.context = foreign_context;
 
     GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
-    priv->gl_context = gl_create_context(dpy, DefaultScreen(dpy), &parent_cs);
+    priv->gl_context = gl_create_context(
+        dpy,
+        GST_VAAPI_OBJECT_XSCREEN(window),
+        &parent_cs
+    );
     if (!priv->gl_context) {
         GST_DEBUG("could not create GLX context");
         goto end;
@@ -226,7 +231,7 @@ gst_vaapi_window_glx_create_colormap(GstVaapiWindowGLX *window)
             GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
             x11_trap_errors();
             /* XXX: add a GstVaapiDisplayX11:x11-screen property? */
-            screen     = DefaultScreen(dpy);
+            screen     = GST_VAAPI_OBJECT_XSCREEN(window);
             priv->cmap = XCreateColormap(
                 dpy,
                 RootWindow(dpy, screen),
index f2ffbef..b46f08a 100644 (file)
@@ -29,6 +29,7 @@
 #include "gstvaapicompat.h"
 #include "gstvaapiwindow_x11.h"
 #include "gstvaapidisplay_x11.h"
+#include "gstvaapidisplay_x11_priv.h"
 #include "gstvaapiutils.h"
 #include "gstvaapiutils_x11.h"
 #include "gstvaapi_priv.h"
index d381191..f6ea9d8 100644 (file)
@@ -105,7 +105,7 @@ main(int argc, char *argv[])
     g_print("# Create window with gst_vaapi_window_x11_new_with_xid()\n");
     g_print("#\n");
     {
-        Display * const dpy = GST_VAAPI_DISPLAY_XDISPLAY(display);
+        Display * const dpy = gst_vaapi_display_x11_get_display(GST_VAAPI_DISPLAY_X11(display));
         Window rootwin, win;
         int screen;
         unsigned long white_pixel, black_pixel;