Blame sys/ximage/ximagesink.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_X_IMAGE_SINK_H__
Packit 971217
#define __GST_X_IMAGE_SINK_H__
Packit 971217
Packit 971217
#include <gst/video/gstvideosink.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 <string.h>
Packit 971217
#include <math.h>
Packit 971217
Packit 971217
/* Helper functions */
Packit 971217
#include <gst/video/video.h>
Packit 971217
Packit 971217
G_BEGIN_DECLS
Packit 971217
#define GST_TYPE_X_IMAGE_SINK \
Packit 971217
  (gst_x_image_sink_get_type())
Packit 971217
#define GST_X_IMAGE_SINK(obj) \
Packit 971217
  (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_X_IMAGE_SINK, GstXImageSink))
Packit 971217
#define GST_X_IMAGE_SINK_CLASS(klass) \
Packit 971217
  (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_X_IMAGE_SINK, GstXImageSinkClass))
Packit 971217
#define GST_IS_X_IMAGE_SINK(obj) \
Packit 971217
  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_X_IMAGE_SINK))
Packit 971217
#define GST_IS_X_IMAGE_SINK_CLASS(klass) \
Packit 971217
  (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_X_IMAGE_SINK))
Packit 971217
Packit 971217
typedef struct _GstXContext GstXContext;
Packit 971217
typedef struct _GstXWindow GstXWindow;
Packit 971217
Packit 971217
typedef struct _GstXImageSink GstXImageSink;
Packit 971217
typedef struct _GstXImageSinkClass GstXImageSinkClass;
Packit 971217
Packit 971217
#include "ximagepool.h"
Packit 971217
Packit 971217
/*
Packit 971217
 * GstXContext:
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
 * @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 _GstXContext
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
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
  GstCaps *caps;
Packit 971217
  GstCaps *last_caps;
Packit 971217
};
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
  Window win;
Packit 971217
  gint width, height;
Packit 971217
  gboolean internal;
Packit 971217
  GC gc;
Packit 971217
};
Packit 971217
Packit 971217
/**
Packit 971217
 * GstXImageSink:
Packit 971217
 * @display_name: the name of the Display we want to render to
Packit 971217
 * @xcontext: our instance's #GstXContext
Packit 971217
 * @xwindow: the #GstXWindow we are rendering to
Packit 971217
 * @ximage: internal #GstXImage used to store incoming buffers and render when
Packit 971217
 * not using the buffer_alloc optimization mechanism
Packit 971217
 * @cur_image: a reference to the last #GstXImage that was put to @xwindow. It
Packit 971217
 * is used when Expose events are received to redraw the latest video frame
Packit 971217
 * @event_thread: a thread listening for events on @xwindow and handling them
Packit 971217
 * @running: used to inform @event_thread if it should run/shutdown
Packit 971217
 * @fps_n: the framerate fraction numerator
Packit 971217
 * @fps_d: the framerate fraction denominator
Packit 971217
 * @x_lock: used to protect X calls as we are not using the XLib in threaded
Packit 971217
 * mode
Packit 971217
 * @flow_lock: used to protect data flow routines from external calls such as
Packit 971217
 * events from @event_thread or methods from the #GstVideoOverlay interface
Packit 971217
 * @par: used to override calculated pixel aspect ratio from @xcontext
Packit 971217
 * @pool_lock: used to protect the buffer pool
Packit 971217
 * @buffer_pool: a list of #GstXImageBuffer that could be reused at next buffer
Packit 971217
 * allocation call
Packit 971217
 * @synchronous: used to store if XSynchronous should be used or not (for
Packit 971217
 * debugging purpose only)
Packit 971217
 * @keep_aspect: used to remember if reverse negotiation scaling should respect
Packit 971217
 * aspect ratio
Packit 971217
 * @handle_events: used to know if we should handle select XEvents or not
Packit 971217
 *
Packit 971217
 * The #GstXImageSink data structure.
Packit 971217
 */
Packit 971217
struct _GstXImageSink
Packit 971217
{
Packit 971217
  /* Our element stuff */
Packit 971217
  GstVideoSink videosink;
Packit 971217
Packit 971217
  char *display_name;
Packit 971217
Packit 971217
  GstXContext *xcontext;
Packit 971217
  GstXWindow *xwindow;
Packit 971217
  GstBuffer *cur_image;
Packit 971217
Packit 971217
  GThread *event_thread;
Packit 971217
  gboolean running;
Packit 971217
Packit 971217
  GstVideoInfo info;
Packit 971217
Packit 971217
  /* Framerate numerator and denominator */
Packit 971217
  gint fps_n;
Packit 971217
  gint fps_d;
Packit 971217
Packit 971217
  GMutex x_lock;
Packit 971217
  GMutex flow_lock;
Packit 971217
Packit 971217
  /* object-set pixel aspect ratio */
Packit 971217
  GValue *par;
Packit 971217
Packit 971217
  /* the buffer pool */
Packit 971217
  GstBufferPool *pool;
Packit 971217
Packit 971217
  gboolean synchronous;
Packit 971217
  gboolean keep_aspect;
Packit 971217
  gboolean handle_events;
Packit 971217
  gboolean handle_expose;
Packit 971217
  gboolean draw_border;
Packit 971217
Packit 971217
  /* stream metadata */
Packit 971217
  gchar *media_title;
Packit 971217
};
Packit 971217
Packit 971217
struct _GstXImageSinkClass
Packit 971217
{
Packit 971217
  GstVideoSinkClass parent_class;
Packit 971217
};
Packit 971217
Packit 971217
GType gst_x_image_sink_get_type (void);
Packit 971217
Packit 971217
G_END_DECLS
Packit 971217
#endif /* __GST_X_IMAGE_SINK_H__ */