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 BUF_SHARE_METHOD_NONE = -1,
71 BUF_SHARE_METHOD_PADDR = 0,
73 BUF_SHARE_METHOD_TIZEN_BUFFER
78 #define GST_TYPE_EVASPIXMAPSINK \
79 (gst_evaspixmapsink_get_type())
80 #define GST_EVASPIXMAPSINK(obj) \
81 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSink))
82 #define GST_EVASPIXMAPSINK_CLASS(klass) \
83 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSinkClass))
84 #define GST_IS_EVASPIXMAPSINK(obj) \
85 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_EVASPIXMAPSINK))
86 #define GST_IS_EVASPIXMAPSINK_CLASS(klass) \
87 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_EVASPIXMAPSINK))
89 #define XV_SCREEN_SIZE_WIDTH 4096
90 #define XV_SCREEN_SIZE_HEIGHT 4096
92 #define MARGIN_OF_ERROR 0.005
93 #define NUM_OF_PIXMAP 3
95 typedef struct _GstXContext GstXContext;
96 typedef struct _GstXPixmap GstXPixmap;
97 typedef struct _GstEvasPixmapFormat GstEvasPixmapFormat;
98 typedef struct _GstEvasPixmapBuffer GstEvasPixmapBuffer;
99 typedef struct _GstEvasPixmapBufferClass GstEvasPixmapBufferClass;
100 typedef struct _GstEvasPixmapSink GstEvasPixmapSink;
101 typedef struct _GstEvasPixmapSinkClass GstEvasPixmapSinkClass;
105 * @disp: the X11 Display of this context
106 * @screen: the default Screen of Display @disp
107 * @screen_num: the Screen number of @screen
108 * @visual: the default Visual of Screen @screen
109 * @root: the root Window of Display @disp
110 * @white: the value of a white pixel on Screen @screen
111 * @black: the value of a black pixel on Screen @screen
112 * @depth: the color depth of Display @disp
113 * @bpp: the number of bits per pixel on Display @disp
114 * @endianness: the endianness of image bytes on Display @disp
115 * @width: the width in pixels of Display @disp
116 * @height: the height in pixels of Display @disp
117 * @widthmm: the width in millimeters of Display @disp
118 * @heightmm: the height in millimeters of Display @disp
119 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
121 * @use_xshm: used to known wether of not XShm extension is usable or not even
122 * if the Extension is present
123 * @xv_port_id: the XVideo port ID
124 * @im_format: used to store at least a valid format for XShm calls checks
125 * @formats_list: list of supported image formats on @xv_port_id
126 * @channels_list: list of #GstColorBalanceChannels
127 * @caps: the #GstCaps that Display @disp can accept
129 * Structure used to store various informations collected/calculated for a
132 struct _GstXContext {
149 gint widthmm, heightmm;
150 GValue *par; /* calculated pixel aspect ratio */
160 GList *channels_list;
167 * @pixmap: the pixmap ID of this X11 pixmap
168 * @width: the width in pixels of Pixmap @pixmap
169 * @height: the height in pixels of Pixmap @pixmap
170 * @gc: the Graphical Context of Pixmap @pixmap
172 * Structure used to store informations about a Pixmap.
186 * GstEvasPixmapFormat:
187 * @format: the image format
188 * @caps: generated #GstCaps for this image format
190 * Structure storing image format to #GstCaps association.
192 struct _GstEvasPixmapFormat {
198 * GstEvasPixmapBuffer:
199 * @evaspixmapsink: a reference to our #GstEvasPixmapSink
200 * @xvimage: the XvImage of this buffer
201 * @width: the width in pixels of XvImage @xvimage
202 * @height: the height in pixels of XvImage @xvimage
203 * @im_format: the image format of XvImage @xvimage
204 * @size: the size in bytes of XvImage @xvimage
206 * Subclass of #GstBuffer containing additional information about an XvImage.
208 struct _GstEvasPixmapBuffer {
211 /* Reference to the evaspixmapsink we belong to */
212 GstEvasPixmapSink *evaspixmapsink;
216 XShmSegmentInfo SHMInfo;
217 #endif /* HAVE_XSHM */
226 * @display_name: the name of the Display we want to render to
227 * @xcontext: our instance's #GstXContext
228 * @xpixmap: the #GstXPixmap we are rendering to
229 * @fps_n: the framerate fraction numerator
230 * @fps_d: the framerate fraction denominator
231 * @x_lock: used to protect X calls as we are not using the XLib in threaded
233 * @flow_lock: used to protect data flow routines from external calls such as
234 * methods from the #GstXOverlay interface
235 * @par: used to override calculated pixel aspect ratio from @xcontext
236 * @synchronous: used to store if XSynchronous should be used or not (for
237 * debugging purpose only)
238 * @keep_aspect: used to remember if reverse negotiation scaling should respect
240 * @brightness: used to store the user settings for color balance brightness
241 * @contrast: used to store the user settings for color balance contrast
242 * @hue: used to store the user settings for color balance hue
243 * @saturation: used to store the user settings for color balance saturation
244 * @cb_changed: used to store if the color balance settings where changed
245 * @video_width: the width of incoming video frames in pixels
246 * @video_height: the height of incoming video frames in pixels
248 * The #GstEvasPixmapSink data structure.
250 struct _GstEvasPixmapSink {
251 /* Our element stuff */
252 GstVideoSink videosink;
257 GstXContext *xcontext;
258 GstXPixmap *xpixmap[NUM_OF_PIXMAP];
259 GstEvasPixmapBuffer *evas_pixmap_buf;
261 GThread *event_thread;
269 GMutex *pixmap_ref_lock;
271 /* object-set pixel aspect ratio */
274 gboolean synchronous;
275 gboolean double_buffer;
283 /* size of incoming video, used as the size for XvImage */
284 guint video_width, video_height;
286 /* display sizes, used for clipping the image */
288 gint disp_width, disp_height;
290 /* port attributes */
291 gboolean autopaint_colorkey;
295 gboolean have_autopaint_colorkey;
296 gboolean have_colorkey;
297 gboolean have_double_buffer;
299 /* target video rectagle */
300 GstVideoRectangle render_rect;
301 gboolean have_render_rect;
306 guint display_geometry_method;
307 GstVideoRectangle dst_roi;
309 /* needed if fourcc is one if S series */
311 guint aligned_height;
314 buf_share_method_t buf_shared_type;
316 /* ecore & evas object */
321 gint last_updated_idx;
325 gboolean use_origin_size;
326 gboolean previous_origin_size;
328 gint sizediff_height;
329 guint num_of_pixmaps;
332 Damage damage[NUM_OF_PIXMAP];
333 Damage prev_damage[NUM_OF_PIXMAP];
338 gem_info_t gem_info[MAX_GEM_BUFFER_NUM];
341 /* max plane count *********************************************************/
342 #define MPLANE_IMGB_MAX_COUNT (4)
344 /* image buffer definition ***************************************************
346 +------------------------------------------+ ---
348 | uaddr[], index[] | |
349 | +---------------------------+ --- | |
351 | |<-------- width[] -------->| | | |
354 | | |height[]|elevation[]
359 | +---------------------------+ --- | |
361 +------------------------------------------+ ---
363 |<----------------- stride[] ------------------>|
365 typedef struct _GstMultiPlaneImageBuffer GstMultiPlaneImageBuffer;
366 struct _GstMultiPlaneImageBuffer
370 /* width of each image plane */
371 gint width[MPLANE_IMGB_MAX_COUNT];
372 /* height of each image plane */
373 gint height[MPLANE_IMGB_MAX_COUNT];
374 /* stride of each image plane */
375 gint stride[MPLANE_IMGB_MAX_COUNT];
376 /* elevation of each image plane */
377 gint elevation[MPLANE_IMGB_MAX_COUNT];
378 /* user space address of each image plane */
379 gpointer uaddr[MPLANE_IMGB_MAX_COUNT];
380 /* Index of real address of each image plane, if needs */
381 gpointer index[MPLANE_IMGB_MAX_COUNT];
382 /* left postion, if needs */
384 /* top position, if needs */
386 /* to align memory */
392 struct _GstEvasPixmapSinkClass {
393 GstVideoSinkClass parent_class;
396 GType gst_evaspixmapsink_get_type(void);
400 #endif /* __GST_EVASPIXMAPSINK_H__ */