From 0c0067a1b01d44017cdffe1be559ee8af1e68f32 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Mon, 20 Feb 2006 21:19:59 +0000 Subject: Port ximagesrc to 0.10 (Closes #304795) Original commit message from CVS: * configure.ac: * sys/Makefile.am: * sys/ximagesrc/Makefile.am: * sys/ximagesrc/ximagesrc.c: (gst_ximagesrc_return_buf), (gst_ximagesrc_open_display), (gst_ximagesrc_start), (gst_ximagesrc_stop), (gst_ximagesrc_unlock), (gst_ximagesrc_recalc), (composite_pixel), (gst_ximagesrc_ximage_get), (gst_ximagesrc_create), (gst_ximagesrc_set_property), (gst_ximagesrc_get_property), (gst_ximagesrc_clear_bufpool), (gst_ximagesrc_base_init), (gst_ximagesrc_dispose), (gst_ximagesrc_finalize), (gst_ximagesrc_get_caps), (gst_ximagesrc_set_caps), (gst_ximagesrc_fixate), (gst_ximagesrc_class_init), (gst_ximagesrc_init), (plugin_init): * sys/ximagesrc/ximagesrc.h: * sys/ximagesrc/ximageutil.c: (ximageutil_handle_xerror), (ximageutil_check_xshm_calls), (ximageutil_xcontext_get), (ximageutil_xcontext_clear), (ximageutil_calculate_pixel_aspect_ratio), (gst_ximagesrc_buffer_finalize), (gst_ximage_buffer_free), (gst_ximagesrc_buffer_init), (gst_ximagesrc_buffer_class_init), (gst_ximagesrc_buffer_get_type), (gst_ximageutil_ximage_new), (gst_ximageutil_ximage_destroy): * sys/ximagesrc/ximageutil.h: Port ximagesrc to 0.10 (Closes #304795) --- sys/ximagesrc/ximageutil.h | 174 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 sys/ximagesrc/ximageutil.h (limited to 'sys/ximagesrc/ximageutil.h') diff --git a/sys/ximagesrc/ximageutil.h b/sys/ximagesrc/ximageutil.h new file mode 100644 index 00000000..a4db7610 --- /dev/null +++ b/sys/ximagesrc/ximageutil.h @@ -0,0 +1,174 @@ +/* GStreamer + * Copyright (C) <2005> Luca Ognibene + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_XIMAGEUTIL_H__ +#define __GST_XIMAGEUTIL_H__ + +#include + +#ifdef HAVE_XSHM +#include +#include +#include +#endif /* HAVE_XSHM */ + +#include +#include + +#ifdef HAVE_XSHM +#include +#endif /* HAVE_XSHM */ + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GstXContext GstXContext; +typedef struct _GstXWindow GstXWindow; +typedef struct _GstXImage GstXImage; +typedef struct _GstXImageSrcBuffer GstXImageSrcBuffer; + +/* Global X Context stuff */ +/** + * GstXContext: + * @disp: the X11 Display of this context + * @screen: the default Screen of Display @disp + * @screen_num: the Screen number of @screen + * @visual: the default Visual of Screen @screen + * @root: the root Window of Display @disp + * @white: the value of a white pixel on Screen @screen + * @black: the value of a black pixel on Screen @screen + * @depth: the color depth of Display @disp + * @bpp: the number of bits per pixel on Display @disp + * @endianness: the endianness of image bytes on Display @disp + * @width: the width in pixels of Display @disp + * @height: the height in pixels of Display @disp + * @widthmm: the width in millimeters of Display @disp + * @heightmm: the height in millimeters of Display @disp + * @par: the pixel aspect ratio calculated from @width, @widthmm and @height, + * @heightmm ratio + * @use_xshm: used to known wether of not XShm extension is usable or not even + * if the Extension is present + * @caps: the #GstCaps that Display @disp can accept + * + * Structure used to store various informations collected/calculated for a + * Display. + */ +struct _GstXContext { + Display *disp; + + Screen *screen; + gint screen_num; + + Visual *visual; + + Window root; + + gulong white, black; + + gint depth; + gint bpp; + gint endianness; + + gint width, height; + gint widthmm, heightmm; + GValue *par; /* calculated pixel aspect ratio */ + + gboolean use_xshm; + + GstCaps *caps; +}; + +/** + * GstXWindow: + * @win: the Window ID of this X11 window + * @width: the width in pixels of Window @win + * @height: the height in pixels of Window @win + * @internal: used to remember if Window @win was created internally or passed + * through the #GstXOverlay interface + * @gc: the Graphical Context of Window @win + * + * Structure used to store informations about a Window. + */ +struct _GstXWindow { + Window win; + gint width, height; + gboolean internal; + GC gc; +}; + +gboolean ximageutil_check_xshm_calls (GstXContext * xcontext); + +GstXContext *ximageutil_xcontext_get (GstElement *parent, + const gchar *display_name); +void ximageutil_xcontext_clear (GstXContext *xcontext); +void ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext); + +/* custom ximagesrc buffer, copied from ximagesink */ + +/* BufferReturnFunc is called when a buffer is finalised */ +typedef void (*BufferReturnFunc) (GstElement *parent, GstXImageSrcBuffer *buf); + +/** + * GstXImageSrcBuffer: + * @parent: a reference to the element we belong to + * @ximage: the XImage of this buffer + * @width: the width in pixels of XImage @ximage + * @height: the height in pixels of XImage @ximage + * @size: the size in bytes of XImage @ximage + * + * Subclass of #GstBuffer containing additional information about an XImage. + */ +struct _GstXImageSrcBuffer { + GstBuffer buffer; + + /* Reference to the ximagesrc we belong to */ + GstElement *parent; + + XImage *ximage; + +#ifdef HAVE_XSHM + XShmSegmentInfo SHMInfo; +#endif /* HAVE_XSHM */ + + gint width, height; + size_t size; + + BufferReturnFunc return_func; +}; + + +GstXImageSrcBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext, + GstElement *parent, int width, int height, BufferReturnFunc return_func); + +void gst_ximageutil_ximage_destroy (GstXContext *xcontext, + GstXImageSrcBuffer * ximage); + +/* Call to manually release a buffer */ +void gst_ximage_buffer_free (GstXImageSrcBuffer *ximage); + +#define GST_TYPE_XIMAGESRC_BUFFER (gst_ximagesrc_buffer_get_type()) +#define GST_IS_XIMAGESRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGESRC_BUFFER)) +#define GST_XIMAGESRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBuffer)) +#define GST_XIMAGESRC_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBufferClass)) + +G_END_DECLS + +#endif /* __GST_XIMAGEUTIL_H__ */ -- cgit v1.2.1