4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Sangchul Lee <sc11.lee@samsung.com>
8 * This library is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; either version 2.1 of the License, or (at your option)
13 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 * License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, write to the Free Software Foundation, Inc., 51
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #ifndef __GST_EVASPIXMAPSINK_H__
25 #define __GST_EVASPIXMAPSINK_H__
27 #include <gst/video/gstvideosink.h>
31 #include <sys/types.h>
34 #endif /* HAVE_XSHM */
37 #include <X11/Xutil.h>
40 #include <X11/extensions/XShm.h>
41 #endif /* HAVE_XSHM */
43 #include <X11/extensions/Xv.h>
44 #include <X11/extensions/Xvlib.h>
45 #include <X11/extensions/Xdamage.h>
46 #include <X11/extensions/damagewire.h>
47 #include <X11/Xatom.h>
58 #define MAX_PLANE_NUM 3
59 #define MAX_BUFFER_NUM 20
60 #define MAX_GEM_BUFFER_NUM (MAX_PLANE_NUM * MAX_BUFFER_NUM)
61 typedef struct _gem_info_t {
63 unsigned int gem_handle;
64 unsigned int gem_name;
70 #define GST_TYPE_EVASPIXMAPSINK \
71 (gst_evaspixmapsink_get_type())
72 #define GST_EVASPIXMAPSINK(obj) \
73 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSink))
74 #define GST_EVASPIXMAPSINK_CLASS(klass) \
75 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSinkClass))
76 #define GST_IS_EVASPIXMAPSINK(obj) \
77 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_EVASPIXMAPSINK))
78 #define GST_IS_EVASPIXMAPSINK_CLASS(klass) \
79 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_EVASPIXMAPSINK))
81 #define XV_SCREEN_SIZE_WIDTH 4096
82 #define XV_SCREEN_SIZE_HEIGHT 4096
84 #define MARGIN_OF_ERROR 0.005
86 typedef struct _GstXContext GstXContext;
87 typedef struct _GstXPixmap GstXPixmap;
88 typedef struct _GstEvasPixmapFormat GstEvasPixmapFormat;
89 typedef struct _GstEvasPixmapBuffer GstEvasPixmapBuffer;
90 typedef struct _GstEvasPixmapBufferClass GstEvasPixmapBufferClass;
91 typedef struct _GstEvasPixmapSink GstEvasPixmapSink;
92 typedef struct _GstEvasPixmapSinkClass GstEvasPixmapSinkClass;
96 * @disp: the X11 Display of this context
97 * @screen: the default Screen of Display @disp
98 * @screen_num: the Screen number of @screen
99 * @visual: the default Visual of Screen @screen
100 * @root: the root Window of Display @disp
101 * @white: the value of a white pixel on Screen @screen
102 * @black: the value of a black pixel on Screen @screen
103 * @depth: the color depth of Display @disp
104 * @bpp: the number of bits per pixel on Display @disp
105 * @endianness: the endianness of image bytes on Display @disp
106 * @width: the width in pixels of Display @disp
107 * @height: the height in pixels of Display @disp
108 * @widthmm: the width in millimeters of Display @disp
109 * @heightmm: the height in millimeters of Display @disp
110 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
112 * @use_xshm: used to known wether of not XShm extension is usable or not even
113 * if the Extension is present
114 * @xv_port_id: the XVideo port ID
115 * @im_format: used to store at least a valid format for XShm calls checks
116 * @formats_list: list of supported image formats on @xv_port_id
117 * @channels_list: list of #GstColorBalanceChannels
118 * @caps: the #GstCaps that Display @disp can accept
120 * Structure used to store various informations collected/calculated for a
123 struct _GstXContext {
140 gint widthmm, heightmm;
141 GValue *par; /* calculated pixel aspect ratio */
151 GList *channels_list;
158 * @pixmap: the pixmap ID of this X11 pixmap
159 * @width: the width in pixels of Pixmap @pixmap
160 * @height: the height in pixels of Pixmap @pixmap
161 * @gc: the Graphical Context of Pixmap @pixmap
163 * Structure used to store informations about a Pixmap.
173 * GstEvasPixmapFormat:
174 * @format: the image format
175 * @caps: generated #GstCaps for this image format
177 * Structure storing image format to #GstCaps association.
179 struct _GstEvasPixmapFormat {
185 * GstEvasPixmapBuffer:
186 * @evaspixmapsink: a reference to our #GstEvasPixmapSink
187 * @xvimage: the XvImage of this buffer
188 * @width: the width in pixels of XvImage @xvimage
189 * @height: the height in pixels of XvImage @xvimage
190 * @im_format: the image format of XvImage @xvimage
191 * @size: the size in bytes of XvImage @xvimage
193 * Subclass of #GstBuffer containing additional information about an XvImage.
195 struct _GstEvasPixmapBuffer {
198 /* Reference to the evaspixmapsink we belong to */
199 GstEvasPixmapSink *evaspixmapsink;
203 XShmSegmentInfo SHMInfo;
204 #endif /* HAVE_XSHM */
213 * @display_name: the name of the Display we want to render to
214 * @xcontext: our instance's #GstXContext
215 * @xpixmap: the #GstXPixmap we are rendering to
216 * @fps_n: the framerate fraction numerator
217 * @fps_d: the framerate fraction denominator
218 * @x_lock: used to protect X calls as we are not using the XLib in threaded
220 * @flow_lock: used to protect data flow routines from external calls such as
221 * methods from the #GstXOverlay interface
222 * @par: used to override calculated pixel aspect ratio from @xcontext
223 * @synchronous: used to store if XSynchronous should be used or not (for
224 * debugging purpose only)
225 * @keep_aspect: used to remember if reverse negotiation scaling should respect
227 * @brightness: used to store the user settings for color balance brightness
228 * @contrast: used to store the user settings for color balance contrast
229 * @hue: used to store the user settings for color balance hue
230 * @saturation: used to store the user settings for color balance saturation
231 * @cb_changed: used to store if the color balance settings where changed
232 * @video_width: the width of incoming video frames in pixels
233 * @video_height: the height of incoming video frames in pixels
235 * The #GstEvasPixmapSink data structure.
237 struct _GstEvasPixmapSink {
238 /* Our element stuff */
239 GstVideoSink videosink;
244 GstXContext *xcontext;
246 GstEvasPixmapBuffer *evas_pixmap_buf;
248 GThread *event_thread;
257 /* object-set pixel aspect ratio */
260 gboolean synchronous;
261 gboolean double_buffer;
269 /* size of incoming video, used as the size for XvImage */
270 guint video_width, video_height;
272 /* display sizes, used for clipping the image */
274 gint disp_width, disp_height;
276 /* port attributes */
277 gboolean autopaint_colorkey;
281 gboolean have_autopaint_colorkey;
282 gboolean have_colorkey;
283 gboolean have_double_buffer;
285 /* target video rectagle */
286 GstVideoRectangle render_rect;
287 gboolean have_render_rect;
292 guint display_geometry_method;
293 GstVideoRectangle dst_roi;
295 /* needed if fourcc is one if S series */
297 guint aligned_height;
309 gboolean use_origin_size;
310 gboolean previous_origin_size;
315 Ecore_Event_Handler *handler;
319 gem_info_t gem_info[MAX_GEM_BUFFER_NUM];
322 /* max plane count *********************************************************/
323 #define MPLANE_IMGB_MAX_COUNT (4)
325 /* image buffer definition ***************************************************
327 +------------------------------------------+ ---
329 | uaddr[], index[] | |
330 | +---------------------------+ --- | |
332 | |<-------- width[] -------->| | | |
335 | | |height[]|elevation[]
340 | +---------------------------+ --- | |
342 +------------------------------------------+ ---
344 |<----------------- stride[] ------------------>|
346 typedef struct _GstMultiPlaneImageBuffer GstMultiPlaneImageBuffer;
347 struct _GstMultiPlaneImageBuffer
351 /* width of each image plane */
352 gint width[MPLANE_IMGB_MAX_COUNT];
353 /* height of each image plane */
354 gint height[MPLANE_IMGB_MAX_COUNT];
355 /* stride of each image plane */
356 gint stride[MPLANE_IMGB_MAX_COUNT];
357 /* elevation of each image plane */
358 gint elevation[MPLANE_IMGB_MAX_COUNT];
359 /* user space address of each image plane */
360 gpointer uaddr[MPLANE_IMGB_MAX_COUNT];
361 /* Index of real address of each image plane, if needs */
362 gpointer index[MPLANE_IMGB_MAX_COUNT];
363 /* left postion, if needs */
365 /* top position, if needs */
367 /* to align memory */
373 struct _GstEvasPixmapSinkClass {
374 GstVideoSinkClass parent_class;
377 GType gst_evaspixmapsink_get_type(void);
381 #endif /* __GST_EVASPIXMAPSINK_H__ */