Blame sys/ximage/ximageutil.h

Packit 8ff292
/* GStreamer
Packit 8ff292
 * Copyright (C) <2005> Luca Ognibene <luogni@tin.it>
Packit 8ff292
 *
Packit 8ff292
 * This library is free software; you can redistribute it and/or
Packit 8ff292
 * modify it under the terms of the GNU Library General Public
Packit 8ff292
 * License as published by the Free Software Foundation; either
Packit 8ff292
 * version 2 of the License, or (at your option) any later version.
Packit 8ff292
 *
Packit 8ff292
 * This library is distributed in the hope that it will be useful,
Packit 8ff292
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8ff292
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 8ff292
 * Library General Public License for more details.
Packit 8ff292
 *
Packit 8ff292
 * You should have received a copy of the GNU Library General Public
Packit 8ff292
 * License along with this library; if not, write to the
Packit 8ff292
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit 8ff292
 * Boston, MA 02110-1301, USA.
Packit 8ff292
 */
Packit 8ff292
Packit 8ff292
#ifndef __GST_XIMAGEUTIL_H__
Packit 8ff292
#define __GST_XIMAGEUTIL_H__
Packit 8ff292
Packit 8ff292
#include <gst/gst.h>
Packit 8ff292
Packit 8ff292
#ifdef HAVE_XSHM
Packit 8ff292
#include <sys/types.h>
Packit 8ff292
#include <sys/ipc.h>
Packit 8ff292
#include <sys/shm.h>
Packit 8ff292
#endif /* HAVE_XSHM */
Packit 8ff292
Packit 8ff292
#include <X11/Xlib.h>
Packit 8ff292
#include <X11/Xutil.h>
Packit 8ff292
Packit 8ff292
#ifdef HAVE_XSHM
Packit 8ff292
#include <X11/extensions/XShm.h>
Packit 8ff292
#endif /* HAVE_XSHM */
Packit 8ff292
Packit 8ff292
#include <string.h>
Packit 8ff292
#include <math.h>
Packit 8ff292
Packit 8ff292
G_BEGIN_DECLS
Packit 8ff292
Packit 8ff292
typedef struct _GstXContext GstXContext;
Packit 8ff292
typedef struct _GstXWindow GstXWindow;
Packit 8ff292
typedef struct _GstXImage GstXImage;
Packit 8ff292
typedef struct _GstMetaXImage GstMetaXImage;
Packit 8ff292
Packit 8ff292
/* Global X Context stuff */
Packit 8ff292
/**
Packit 8ff292
 * GstXContext:
Packit 8ff292
 * @disp: the X11 Display of this context
Packit 8ff292
 * @screen: the default Screen of Display @disp
Packit 8ff292
 * @visual: the default Visual of Screen @screen
Packit 8ff292
 * @root: the root Window of Display @disp
Packit 8ff292
 * @white: the value of a white pixel on Screen @screen
Packit 8ff292
 * @black: the value of a black pixel on Screen @screen
Packit 8ff292
 * @depth: the color depth of Display @disp
Packit 8ff292
 * @bpp: the number of bits per pixel on Display @disp
Packit 8ff292
 * @endianness: the endianness of image bytes on Display @disp
Packit 8ff292
 * @width: the width in pixels of Display @disp
Packit 8ff292
 * @height: the height in pixels of Display @disp
Packit 8ff292
 * @widthmm: the width in millimeters of Display @disp
Packit 8ff292
 * @heightmm: the height in millimeters of Display @disp
Packit 8ff292
 * @par_n: the pixel aspect ratio numerator calculated from @width, @widthmm
Packit 8ff292
 * and @height,
Packit 8ff292
 * @par_d: the pixel aspect ratio denumerator calculated from @width, @widthmm
Packit 8ff292
 * and @height,
Packit 8ff292
 * @heightmm ratio
Packit 8ff292
 * @use_xshm: used to known wether of not XShm extension is usable or not even
Packit 8ff292
 * if the Extension is present
Packit 8ff292
 * @caps: the #GstCaps that Display @disp can accept
Packit 8ff292
 *
Packit 8ff292
 * Structure used to store various informations collected/calculated for a
Packit 8ff292
 * Display.
Packit 8ff292
 */
Packit 8ff292
struct _GstXContext {
Packit 8ff292
  Display *disp;
Packit 8ff292
Packit 8ff292
  Screen *screen;
Packit 8ff292
Packit 8ff292
  Visual *visual;
Packit 8ff292
Packit 8ff292
  Window root;
Packit 8ff292
Packit 8ff292
  gulong white, black;
Packit 8ff292
Packit 8ff292
  gint depth;
Packit 8ff292
  gint bpp;
Packit 8ff292
  gint endianness;
Packit 8ff292
Packit 8ff292
  gint width, height;
Packit 8ff292
  gint widthmm, heightmm;
Packit 8ff292
Packit 8ff292
  /* these are the output masks
Packit 8ff292
   * for buffers from ximagesrc
Packit 8ff292
   * and are in big endian */
Packit 8ff292
  guint32 r_mask_output, g_mask_output, b_mask_output;
Packit 8ff292
Packit 8ff292
  guint par_n;                  /* calculated pixel aspect ratio numerator */
Packit 8ff292
  guint par_d;                  /* calculated pixel aspect ratio denumerator */
Packit 8ff292
Packit 8ff292
  gboolean use_xshm;
Packit 8ff292
Packit 8ff292
  GstCaps *caps;
Packit 8ff292
};
Packit 8ff292
Packit 8ff292
/**
Packit 8ff292
 * GstXWindow:
Packit 8ff292
 * @win: the Window ID of this X11 window
Packit 8ff292
 * @width: the width in pixels of Window @win
Packit 8ff292
 * @height: the height in pixels of Window @win
Packit 8ff292
 * @internal: used to remember if Window @win was created internally or passed
Packit 8ff292
 * through the #GstXOverlay interface
Packit 8ff292
 * @gc: the Graphical Context of Window @win
Packit 8ff292
 *
Packit 8ff292
 * Structure used to store informations about a Window.
Packit 8ff292
 */
Packit 8ff292
struct _GstXWindow {
Packit 8ff292
  Window win;
Packit 8ff292
  gint width, height;
Packit 8ff292
  gboolean internal;
Packit 8ff292
  GC gc;
Packit 8ff292
};
Packit 8ff292
Packit 8ff292
gboolean ximageutil_check_xshm_calls (GstXContext * xcontext);
Packit 8ff292
Packit 8ff292
GstXContext *ximageutil_xcontext_get (GstElement *parent, 
Packit 8ff292
    const gchar *display_name);
Packit 8ff292
void ximageutil_xcontext_clear (GstXContext *xcontext);
Packit 8ff292
void ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext);
Packit 8ff292
Packit 8ff292
/* custom ximagesrc buffer, copied from ximagesink */
Packit 8ff292
Packit 8ff292
/* BufferReturnFunc is called when a buffer is finalised */
Packit 8ff292
typedef gboolean (*BufferReturnFunc) (GstElement *parent, GstBuffer *buf);
Packit 8ff292
Packit 8ff292
/**
Packit 8ff292
 * GstMetaXImage:
Packit 8ff292
 * @parent: a reference to the element we belong to
Packit 8ff292
 * @ximage: the XImage of this buffer
Packit 8ff292
 * @width: the width in pixels of XImage @ximage
Packit 8ff292
 * @height: the height in pixels of XImage @ximage
Packit 8ff292
 * @size: the size in bytes of XImage @ximage
Packit 8ff292
 *
Packit 8ff292
 * Extra data attached to buffers containing additional information about an XImage.
Packit 8ff292
 */
Packit 8ff292
struct _GstMetaXImage {
Packit 8ff292
  GstMeta meta;
Packit 8ff292
Packit 8ff292
  /* Reference to the ximagesrc we belong to */
Packit 8ff292
  GstElement *parent;
Packit 8ff292
Packit 8ff292
  XImage *ximage;
Packit 8ff292
Packit 8ff292
#ifdef HAVE_XSHM
Packit 8ff292
  XShmSegmentInfo SHMInfo;
Packit 8ff292
#endif /* HAVE_XSHM */
Packit 8ff292
Packit 8ff292
  gint width, height;
Packit 8ff292
  size_t size;
Packit 8ff292
Packit 8ff292
  BufferReturnFunc return_func;
Packit 8ff292
};
Packit 8ff292
Packit 8ff292
GType gst_meta_ximage_api_get_type (void);
Packit 8ff292
const GstMetaInfo * gst_meta_ximage_get_info (void);
Packit 8ff292
#define GST_META_XIMAGE_GET(buf) ((GstMetaXImage *)gst_buffer_get_meta(buf,gst_meta_ximage_api_get_type()))
Packit 8ff292
#define GST_META_XIMAGE_ADD(buf) ((GstMetaXImage *)gst_buffer_add_meta(buf,gst_meta_ximage_get_info(),NULL))
Packit 8ff292
Packit 8ff292
GstBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext,
Packit 8ff292
  GstElement *parent, int width, int height, BufferReturnFunc return_func);
Packit 8ff292
Packit 8ff292
void gst_ximageutil_ximage_destroy (GstXContext *xcontext, 
Packit 8ff292
  GstBuffer * ximage);
Packit 8ff292
  
Packit 8ff292
/* Call to manually release a buffer */
Packit 8ff292
void gst_ximage_buffer_free (GstBuffer *ximage);
Packit 8ff292
Packit 8ff292
G_END_DECLS 
Packit 8ff292
Packit 8ff292
#endif /* __GST_XIMAGEUTIL_H__ */