sys/: Actually only create a new toplevel window if we're not gonna embed it right...
[platform/upstream/gstreamer.git] / sys / ximage / ximagesink.h
1 /* GStreamer
2  * Copyright (C) <2003> Julien Moutte <julien@moutte.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GST_XIMAGESINK_H__
21 #define __GST_XIMAGESINK_H__
22
23 #include <gst/video/videosink.h>
24
25 #ifdef HAVE_XSHM
26 #include <sys/types.h>
27 #include <sys/ipc.h>
28 #include <sys/shm.h>
29 #endif /* HAVE_XSHM */
30
31 #include <X11/Xlib.h>
32 #include <X11/Xutil.h>
33
34 #ifdef HAVE_XSHM
35 #include <X11/extensions/XShm.h>
36 #endif /* HAVE_XSHM */
37
38 #include <string.h>
39 #include <math.h>
40
41 G_BEGIN_DECLS
42
43 #define GST_TYPE_XIMAGESINK \
44   (gst_ximagesink_get_type())
45 #define GST_XIMAGESINK(obj) \
46   (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_XIMAGESINK, GstXImageSink))
47 #define GST_XIMAGESINK_CLASS(klass) \
48   (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_XIMAGESINK, GstXImageSink))
49 #define GST_IS_XIMAGESINK(obj) \
50   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_XIMAGESINK))
51 #define GST_IS_XIMAGESINK_CLASS(obj) \
52   (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XIMAGESINK))
53
54 typedef struct _GstXContext GstXContext;
55 typedef struct _GstXWindow GstXWindow;
56 typedef struct _GstXImage GstXImage;
57
58 typedef struct _GstXImageSink GstXImageSink;
59 typedef struct _GstXImageSinkClass GstXImageSinkClass;
60
61 /* Global X Context stuff */
62 struct _GstXContext {
63   Display *disp;
64
65   Screen *screen;
66   gint screen_num;
67
68   Visual *visual;
69
70   Window root;
71
72   gulong white, black;
73
74   gint depth;
75   gint bpp;
76   gint endianness;
77
78   gint width, height;
79   gint widthmm, heightmm;
80   GValue *par;                  /* calculated pixel aspect ratio */
81
82   gboolean use_xshm;
83
84   GstCaps *caps;
85 };
86
87 /* XWindow stuff */
88 struct _GstXWindow {
89   Window win;
90   gint width, height;
91   gboolean internal;
92   GC gc;
93 };
94
95 /* XImage stuff */
96 struct _GstXImage {
97   /* Reference to the ximagesink we belong to */
98   GstXImageSink *ximagesink;
99
100   XImage *ximage;
101
102 #ifdef HAVE_XSHM
103   XShmSegmentInfo SHMInfo;
104 #endif /* HAVE_XSHM */
105
106   gint width, height, size;
107 };
108
109 struct _GstXImageSink {
110   /* Our element stuff */
111   GstVideoSink videosink;
112
113   char *display_name;
114
115   Drawable parent;
116   GstXContext *xcontext;
117   GstXWindow *xwindow;
118   GstXImage *ximage;
119   GstXImage *cur_image;
120
121   gdouble framerate;
122   GMutex *x_lock;
123
124   /* Unused */
125   gint pixel_width, pixel_height;
126   GValue *par;                  /* object-set pixel aspect ratio */
127
128   GstClockTime time;
129
130   GMutex *pool_lock;
131   GSList *image_pool;
132
133   gboolean synchronous;
134   gboolean sw_scaling_failed;
135 };
136
137 struct _GstXImageSinkClass {
138   GstVideoSinkClass parent_class;
139 };
140
141 GType gst_ximagesink_get_type(void);
142
143 G_END_DECLS
144
145 #endif /* __GST_XIMAGESINK_H__ */