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
85 #define NUM_OF_PIXMAP 3
87 typedef struct _GstXContext GstXContext;
88 typedef struct _GstXPixmap GstXPixmap;
89 typedef struct _GstEvasPixmapFormat GstEvasPixmapFormat;
90 typedef struct _GstEvasPixmapBuffer GstEvasPixmapBuffer;
91 typedef struct _GstEvasPixmapBufferClass GstEvasPixmapBufferClass;
92 typedef struct _GstEvasPixmapSink GstEvasPixmapSink;
93 typedef struct _GstEvasPixmapSinkClass GstEvasPixmapSinkClass;
97 * @disp: the X11 Display of this context
98 * @screen: the default Screen of Display @disp
99 * @screen_num: the Screen number of @screen
100 * @visual: the default Visual of Screen @screen
101 * @root: the root Window of Display @disp
102 * @white: the value of a white pixel on Screen @screen
103 * @black: the value of a black pixel on Screen @screen
104 * @depth: the color depth of Display @disp
105 * @bpp: the number of bits per pixel on Display @disp
106 * @endianness: the endianness of image bytes on Display @disp
107 * @width: the width in pixels of Display @disp
108 * @height: the height in pixels of Display @disp
109 * @widthmm: the width in millimeters of Display @disp
110 * @heightmm: the height in millimeters of Display @disp
111 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
113 * @use_xshm: used to known wether of not XShm extension is usable or not even
114 * if the Extension is present
115 * @xv_port_id: the XVideo port ID
116 * @im_format: used to store at least a valid format for XShm calls checks
117 * @formats_list: list of supported image formats on @xv_port_id
118 * @channels_list: list of #GstColorBalanceChannels
119 * @caps: the #GstCaps that Display @disp can accept
121 * Structure used to store various informations collected/calculated for a
124 struct _GstXContext {
141 gint widthmm, heightmm;
142 GValue *par; /* calculated pixel aspect ratio */
152 GList *channels_list;
159 * @pixmap: the pixmap ID of this X11 pixmap
160 * @width: the width in pixels of Pixmap @pixmap
161 * @height: the height in pixels of Pixmap @pixmap
162 * @gc: the Graphical Context of Pixmap @pixmap
164 * Structure used to store informations about a Pixmap.
176 * GstEvasPixmapFormat:
177 * @format: the image format
178 * @caps: generated #GstCaps for this image format
180 * Structure storing image format to #GstCaps association.
182 struct _GstEvasPixmapFormat {
188 * GstEvasPixmapBuffer:
189 * @evaspixmapsink: a reference to our #GstEvasPixmapSink
190 * @xvimage: the XvImage of this buffer
191 * @width: the width in pixels of XvImage @xvimage
192 * @height: the height in pixels of XvImage @xvimage
193 * @im_format: the image format of XvImage @xvimage
194 * @size: the size in bytes of XvImage @xvimage
196 * Subclass of #GstBuffer containing additional information about an XvImage.
198 struct _GstEvasPixmapBuffer {
201 /* Reference to the evaspixmapsink we belong to */
202 GstEvasPixmapSink *evaspixmapsink;
206 XShmSegmentInfo SHMInfo;
207 #endif /* HAVE_XSHM */
216 * @display_name: the name of the Display we want to render to
217 * @xcontext: our instance's #GstXContext
218 * @xpixmap: the #GstXPixmap we are rendering to
219 * @fps_n: the framerate fraction numerator
220 * @fps_d: the framerate fraction denominator
221 * @x_lock: used to protect X calls as we are not using the XLib in threaded
223 * @flow_lock: used to protect data flow routines from external calls such as
224 * methods from the #GstXOverlay interface
225 * @par: used to override calculated pixel aspect ratio from @xcontext
226 * @synchronous: used to store if XSynchronous should be used or not (for
227 * debugging purpose only)
228 * @keep_aspect: used to remember if reverse negotiation scaling should respect
230 * @brightness: used to store the user settings for color balance brightness
231 * @contrast: used to store the user settings for color balance contrast
232 * @hue: used to store the user settings for color balance hue
233 * @saturation: used to store the user settings for color balance saturation
234 * @cb_changed: used to store if the color balance settings where changed
235 * @video_width: the width of incoming video frames in pixels
236 * @video_height: the height of incoming video frames in pixels
238 * The #GstEvasPixmapSink data structure.
240 struct _GstEvasPixmapSink {
241 /* Our element stuff */
242 GstVideoSink videosink;
247 GstXContext *xcontext;
248 GstXPixmap *xpixmap[NUM_OF_PIXMAP];
249 GstEvasPixmapBuffer *evas_pixmap_buf;
251 GThread *event_thread;
259 GMutex *pixmap_ref_lock;
261 /* object-set pixel aspect ratio */
264 gboolean synchronous;
265 gboolean double_buffer;
273 /* size of incoming video, used as the size for XvImage */
274 guint video_width, video_height;
276 /* display sizes, used for clipping the image */
278 gint disp_width, disp_height;
280 /* port attributes */
281 gboolean autopaint_colorkey;
285 gboolean have_autopaint_colorkey;
286 gboolean have_colorkey;
287 gboolean have_double_buffer;
289 /* target video rectagle */
290 GstVideoRectangle render_rect;
291 gboolean have_render_rect;
296 guint display_geometry_method;
297 GstVideoRectangle dst_roi;
299 /* needed if fourcc is one if S series */
301 guint aligned_height;
305 /* ecore & evas object */
310 gint last_updated_idx;
314 gboolean use_origin_size;
315 gboolean previous_origin_size;
317 gint sizediff_height;
318 guint num_of_pixmaps;
321 Damage damage[NUM_OF_PIXMAP];
326 gem_info_t gem_info[MAX_GEM_BUFFER_NUM];
329 /* max plane count *********************************************************/
330 #define MPLANE_IMGB_MAX_COUNT (4)
332 /* image buffer definition ***************************************************
334 +------------------------------------------+ ---
336 | uaddr[], index[] | |
337 | +---------------------------+ --- | |
339 | |<-------- width[] -------->| | | |
342 | | |height[]|elevation[]
347 | +---------------------------+ --- | |
349 +------------------------------------------+ ---
351 |<----------------- stride[] ------------------>|
353 typedef struct _GstMultiPlaneImageBuffer GstMultiPlaneImageBuffer;
354 struct _GstMultiPlaneImageBuffer
358 /* width of each image plane */
359 gint width[MPLANE_IMGB_MAX_COUNT];
360 /* height of each image plane */
361 gint height[MPLANE_IMGB_MAX_COUNT];
362 /* stride of each image plane */
363 gint stride[MPLANE_IMGB_MAX_COUNT];
364 /* elevation of each image plane */
365 gint elevation[MPLANE_IMGB_MAX_COUNT];
366 /* user space address of each image plane */
367 gpointer uaddr[MPLANE_IMGB_MAX_COUNT];
368 /* Index of real address of each image plane, if needs */
369 gpointer index[MPLANE_IMGB_MAX_COUNT];
370 /* left postion, if needs */
372 /* top position, if needs */
374 /* to align memory */
380 struct _GstEvasPixmapSinkClass {
381 GstVideoSinkClass parent_class;
384 GType gst_evaspixmapsink_get_type(void);
388 #endif /* __GST_EVASPIXMAPSINK_H__ */