Blame sys/xvimage/xvcontext.h

Packit 971217
/* GStreamer
Packit 971217
 * Copyright (C) <2005> Julien Moutte <julien@moutte.net>
Packit 971217
 *
Packit 971217
 * This library is free software; you can redistribute it and/or
Packit 971217
 * modify it under the terms of the GNU Library General Public
Packit 971217
 * License as published by the Free Software Foundation; either
Packit 971217
 * version 2 of the License, or (at your option) any later version.
Packit 971217
 *
Packit 971217
 * This library is distributed in the hope that it will be useful,
Packit 971217
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 971217
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 971217
 * Library General Public License for more details.
Packit 971217
 *
Packit 971217
 * You should have received a copy of the GNU Library General Public
Packit 971217
 * License along with this library; if not, write to the
Packit 971217
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit 971217
 * Boston, MA 02110-1301, USA.
Packit 971217
 */
Packit 971217
Packit 971217
#ifndef __GST_XVCONTEXT_H__
Packit 971217
#define __GST_XVCONTEXT_H__
Packit 971217
Packit 971217
#ifdef HAVE_XSHM
Packit 971217
#include <sys/types.h>
Packit 971217
#include <sys/ipc.h>
Packit 971217
#include <sys/shm.h>
Packit 971217
#endif /* HAVE_XSHM */
Packit 971217
Packit 971217
#include <X11/Xlib.h>
Packit 971217
#include <X11/Xutil.h>
Packit 971217
Packit 971217
#ifdef HAVE_XSHM
Packit 971217
#include <X11/extensions/XShm.h>
Packit 971217
#endif /* HAVE_XSHM */
Packit 971217
Packit 971217
#include <X11/extensions/Xv.h>
Packit 971217
#include <X11/extensions/Xvlib.h>
Packit 971217
Packit 971217
#include <string.h>
Packit 971217
#include <math.h>
Packit 971217
#include <stdlib.h>
Packit 971217
Packit 971217
#include <gst/video/video.h>
Packit 971217
Packit 971217
G_BEGIN_DECLS
Packit 971217
Packit 971217
typedef struct _GstXvContextConfig GstXvContextConfig;
Packit 971217
typedef struct _GstXvImageFormat GstXvImageFormat;
Packit 971217
typedef struct _GstXvContext GstXvContext;
Packit 971217
Packit 971217
/**
Packit 971217
 * GstXvContextConfig:
Packit 971217
 *
Packit 971217
 * current configuration of the context
Packit 971217
 */
Packit 971217
struct _GstXvContextConfig
Packit 971217
{
Packit 971217
  gchar *display_name;
Packit 971217
  guint  adaptor_nr;
Packit 971217
Packit 971217
  /* port attributes */
Packit 971217
  gboolean autopaint_colorkey;
Packit 971217
  gint colorkey;
Packit 971217
Packit 971217
  gboolean double_buffer;
Packit 971217
Packit 971217
  gint brightness;
Packit 971217
  gint contrast;
Packit 971217
  gint hue;
Packit 971217
  gint saturation;
Packit 971217
  gboolean cb_changed;
Packit 971217
};
Packit 971217
Packit 971217
/**
Packit 971217
 * GstXvImageFormat:
Packit 971217
 * @format: the image format
Packit 971217
 * @caps: generated #GstCaps for this image format
Packit 971217
 *
Packit 971217
 * Structure storing image format to #GstCaps association.
Packit 971217
 */
Packit 971217
struct _GstXvImageFormat
Packit 971217
{
Packit 971217
  gint format;
Packit 971217
  GstVideoFormat vformat;
Packit 971217
  GstCaps *caps;
Packit 971217
};
Packit 971217
Packit 971217
#define GST_TYPE_XVCONTEXT      (gst_xvcontext_get_type())
Packit 971217
#define GST_IS_XVCONTEXT(obj)   (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_XVCONTEXT))
Packit 971217
#define GST_XVCONTEXT_CAST(obj) ((GstXvContext *)obj)
Packit 971217
#define GST_XVCONTEXT(obj)      (GST_XVCONTEXT_CAST(obj))
Packit 971217
Packit 971217
/*
Packit 971217
 * GstXvContext:
Packit 971217
 * @disp: the X11 Display of this context
Packit 971217
 * @screen: the default Screen of Display @disp
Packit 971217
 * @screen_num: the Screen number of @screen
Packit 971217
 * @visual: the default Visual of Screen @screen
Packit 971217
 * @root: the root Window of Display @disp
Packit 971217
 * @white: the value of a white pixel on Screen @screen
Packit 971217
 * @black: the value of a black pixel on Screen @screen
Packit 971217
 * @depth: the color depth of Display @disp
Packit 971217
 * @bpp: the number of bits per pixel on Display @disp
Packit 971217
 * @endianness: the endianness of image bytes on Display @disp
Packit 971217
 * @width: the width in pixels of Display @disp
Packit 971217
 * @height: the height in pixels of Display @disp
Packit 971217
 * @widthmm: the width in millimeters of Display @disp
Packit 971217
 * @heightmm: the height in millimeters of Display @disp
Packit 971217
 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
Packit 971217
 * @heightmm ratio
Packit 971217
 * @use_xshm: used to known wether of not XShm extension is usable or not even
Packit 971217
 * if the Extension is present
Packit 971217
 * @xv_port_id: the XVideo port ID
Packit 971217
 * @im_format: used to store at least a valid format for XShm calls checks
Packit 971217
 * @formats_list: list of supported image formats on @xv_port_id
Packit 971217
 * @channels_list: list of #GstColorBalanceChannels
Packit 971217
 * @caps: the #GstCaps that Display @disp can accept
Packit 971217
 *
Packit 971217
 * Structure used to store various informations collected/calculated for a
Packit 971217
 * Display.
Packit 971217
 */
Packit 971217
struct _GstXvContext
Packit 971217
{
Packit 971217
  GstMiniObject parent;
Packit 971217
Packit 971217
  GMutex lock;
Packit 971217
Packit 971217
  Display *disp;
Packit 971217
Packit 971217
  Screen *screen;
Packit 971217
  gint screen_num;
Packit 971217
Packit 971217
  Visual *visual;
Packit 971217
Packit 971217
  Window root;
Packit 971217
Packit 971217
  gulong white, black;
Packit 971217
Packit 971217
  gint depth;
Packit 971217
  gint bpp;
Packit 971217
  gint endianness;
Packit 971217
Packit 971217
  gint width, height;
Packit 971217
  gint widthmm, heightmm;
Packit 971217
  GValue *par;                  /* calculated pixel aspect ratio */
Packit 971217
Packit 971217
  gboolean use_xshm;
Packit 971217
Packit 971217
  XvPortID xv_port_id;
Packit 971217
  guint nb_adaptors;
Packit 971217
  gchar **adaptors;
Packit 971217
  guint adaptor_nr;
Packit 971217
  gint im_format;
Packit 971217
Packit 971217
  /* port features */
Packit 971217
  gboolean have_autopaint_colorkey;
Packit 971217
  gboolean have_colorkey;
Packit 971217
  gboolean have_double_buffer;
Packit 971217
  gboolean have_iturbt709;
Packit 971217
Packit 971217
  GList *formats_list;
Packit 971217
Packit 971217
  GList *channels_list;
Packit 971217
Packit 971217
  GstCaps *caps;
Packit 971217
Packit 971217
  /* Optimisation storage for buffer_alloc return */
Packit 971217
  GstCaps *last_caps;
Packit 971217
  gint last_format;
Packit 971217
  gint last_width;
Packit 971217
  gint last_height;
Packit 971217
};
Packit 971217
Packit 971217
GType gst_xvcontext_get_type (void);
Packit 971217
Packit 971217
void            gst_xvcontext_config_clear (GstXvContextConfig *config);
Packit 971217
Packit 971217
GstXvContext *  gst_xvcontext_new          (GstXvContextConfig *config, GError **error);
Packit 971217
Packit 971217
/* refcounting */
Packit 971217
static inline GstXvContext *
Packit 971217
gst_xvcontext_ref (GstXvContext * xvcontext)
Packit 971217
{
Packit 971217
  return GST_XVCONTEXT_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
Packit 971217
      xvcontext)));
Packit 971217
}
Packit 971217
Packit 971217
static inline void
Packit 971217
gst_xvcontext_unref (GstXvContext * xvcontext)
Packit 971217
{
Packit 971217
  gst_mini_object_unref (GST_MINI_OBJECT_CAST (xvcontext));
Packit 971217
}
Packit 971217
Packit 971217
gint            gst_xvcontext_get_format_from_info      (GstXvContext * xvcontext,
Packit 971217
                                                         GstVideoInfo * info);
Packit 971217
Packit 971217
Packit 971217
void            gst_xvcontext_set_synchronous           (GstXvContext * xvcontext,
Packit 971217
                                                         gboolean synchronous);
Packit 971217
void            gst_xvcontext_update_colorbalance       (GstXvContext * xvcontext,
Packit 971217
                                                         GstXvContextConfig * config);
Packit 971217
void            gst_xvcontext_set_colorimetry           (GstXvContext * xvcontext,
Packit 971217
                                                         GstVideoColorimetry *colorimetry);
Packit 971217
Packit 971217
Packit 971217
typedef struct _GstXWindow GstXWindow;
Packit 971217
Packit 971217
/*
Packit 971217
 * GstXWindow:
Packit 971217
 * @win: the Window ID of this X11 window
Packit 971217
 * @width: the width in pixels of Window @win
Packit 971217
 * @height: the height in pixels of Window @win
Packit 971217
 * @internal: used to remember if Window @win was created internally or passed
Packit 971217
 * through the #GstVideoOverlay interface
Packit 971217
 * @gc: the Graphical Context of Window @win
Packit 971217
 *
Packit 971217
 * Structure used to store informations about a Window.
Packit 971217
 */
Packit 971217
struct _GstXWindow
Packit 971217
{
Packit 971217
  GstXvContext *context;
Packit 971217
Packit 971217
  Window win;
Packit 971217
  gint width, height;
Packit 971217
  gboolean have_render_rect;
Packit 971217
  GstVideoRectangle render_rect;
Packit 971217
  gboolean internal;
Packit 971217
  GC gc;
Packit 971217
};
Packit 971217
Packit 971217
G_END_DECLS
Packit 971217
Packit 971217
GstXWindow *   gst_xvcontext_create_xwindow     (GstXvContext * context,
Packit 971217
                                                 gint width, gint height);
Packit 971217
GstXWindow *   gst_xvcontext_create_xwindow_from_xid (GstXvContext * context, XID xid);
Packit 971217
Packit 971217
void           gst_xwindow_destroy              (GstXWindow * window);
Packit 971217
Packit 971217
void           gst_xwindow_set_event_handling   (GstXWindow * window, gboolean handle_events);
Packit 971217
void           gst_xwindow_set_title            (GstXWindow * window, const gchar * title);
Packit 971217
Packit 971217
void           gst_xwindow_update_geometry      (GstXWindow * window);
Packit 971217
void           gst_xwindow_clear                (GstXWindow * window);
Packit 971217
Packit 971217
void           gst_xwindow_set_render_rectangle (GstXWindow * window,
Packit 971217
                                                 gint x, gint y, gint width, gint height);
Packit 971217
Packit 971217
Packit 971217
Packit 971217
#endif /* __GST_XVCONTEXT_H__ */