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>
30 #include <sys/types.h>
33 #endif /* HAVE_XSHM */
36 #include <X11/Xutil.h>
39 #include <X11/extensions/XShm.h>
40 #endif /* HAVE_XSHM */
42 #include <X11/extensions/Xv.h>
43 #include <X11/extensions/Xvlib.h>
44 #include <X11/extensions/Xdamage.h>
45 #include <X11/extensions/damagewire.h>
46 #include <X11/Xatom.h>
53 #include <tbm_bufmgr.h>
61 #define MAX_PLANE_NUM 3
62 #define MAX_BUFFER_NUM 20
63 #define MAX_GEM_BUFFER_NUM (MAX_PLANE_NUM * MAX_BUFFER_NUM)
64 typedef struct _gem_info_t {
66 unsigned int gem_handle;
67 unsigned int gem_name;
73 BUF_SHARE_METHOD_NONE = -1,
74 BUF_SHARE_METHOD_PADDR = 0,
76 BUF_SHARE_METHOD_TIZEN_BUFFER
81 #define GST_TYPE_EVASPIXMAPSINK \
82 (gst_evaspixmapsink_get_type())
83 #define GST_EVASPIXMAPSINK(obj) \
84 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSink))
85 #define GST_EVASPIXMAPSINK_CLASS(klass) \
86 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSinkClass))
87 #define GST_IS_EVASPIXMAPSINK(obj) \
88 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_EVASPIXMAPSINK))
89 #define GST_IS_EVASPIXMAPSINK_CLASS(klass) \
90 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_EVASPIXMAPSINK))
92 #define XV_SCREEN_SIZE_WIDTH 4096
93 #define XV_SCREEN_SIZE_HEIGHT 4096
95 #define MARGIN_OF_ERROR 0.005
96 #define NUM_OF_PIXMAP 3
98 typedef struct _GstXContext GstXContext;
99 typedef struct _GstXPixmap GstXPixmap;
100 typedef struct _GstEvasPixmapFormat GstEvasPixmapFormat;
101 typedef struct _GstEvasPixmapBuffer GstEvasPixmapBuffer;
102 typedef struct _GstEvasPixmapBufferClass GstEvasPixmapBufferClass;
103 typedef struct _GstEvasPixmapSink GstEvasPixmapSink;
104 typedef struct _GstEvasPixmapSinkClass GstEvasPixmapSinkClass;
108 * @disp: the X11 Display of this context
109 * @screen: the default Screen of Display @disp
110 * @screen_num: the Screen number of @screen
111 * @visual: the default Visual of Screen @screen
112 * @root: the root Window of Display @disp
113 * @white: the value of a white pixel on Screen @screen
114 * @black: the value of a black pixel on Screen @screen
115 * @depth: the color depth of Display @disp
116 * @bpp: the number of bits per pixel on Display @disp
117 * @endianness: the endianness of image bytes on Display @disp
118 * @width: the width in pixels of Display @disp
119 * @height: the height in pixels of Display @disp
120 * @widthmm: the width in millimeters of Display @disp
121 * @heightmm: the height in millimeters of Display @disp
122 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
124 * @use_xshm: used to known wether of not XShm extension is usable or not even
125 * if the Extension is present
126 * @xv_port_id: the XVideo port ID
127 * @im_format: used to store at least a valid format for XShm calls checks
128 * @formats_list: list of supported image formats on @xv_port_id
129 * @channels_list: list of #GstColorBalanceChannels
130 * @caps: the #GstCaps that Display @disp can accept
132 * Structure used to store various informations collected/calculated for a
135 struct _GstXContext {
152 gint widthmm, heightmm;
153 GValue *par; /* calculated pixel aspect ratio */
163 GList *channels_list;
170 * @pixmap: the pixmap ID of this X11 pixmap
171 * @width: the width in pixels of Pixmap @pixmap
172 * @height: the height in pixels of Pixmap @pixmap
173 * @gc: the Graphical Context of Pixmap @pixmap
175 * Structure used to store informations about a Pixmap.
189 * GstEvasPixmapFormat:
190 * @format: the image format
191 * @caps: generated #GstCaps for this image format
193 * Structure storing image format to #GstCaps association.
195 struct _GstEvasPixmapFormat {
201 * GstEvasPixmapBuffer:
202 * @evaspixmapsink: a reference to our #GstEvasPixmapSink
203 * @xvimage: the XvImage of this buffer
204 * @width: the width in pixels of XvImage @xvimage
205 * @height: the height in pixels of XvImage @xvimage
206 * @im_format: the image format of XvImage @xvimage
207 * @size: the size in bytes of XvImage @xvimage
209 * Subclass of #GstBuffer containing additional information about an XvImage.
211 struct _GstEvasPixmapBuffer {
214 /* Reference to the evaspixmapsink we belong to */
215 GstEvasPixmapSink *evaspixmapsink;
219 XShmSegmentInfo SHMInfo;
220 #endif /* HAVE_XSHM */
229 * @display_name: the name of the Display we want to render to
230 * @xcontext: our instance's #GstXContext
231 * @xpixmap: the #GstXPixmap we are rendering to
232 * @fps_n: the framerate fraction numerator
233 * @fps_d: the framerate fraction denominator
234 * @x_lock: used to protect X calls as we are not using the XLib in threaded
236 * @flow_lock: used to protect data flow routines from external calls such as
237 * methods from the #GstXOverlay interface
238 * @par: used to override calculated pixel aspect ratio from @xcontext
239 * @synchronous: used to store if XSynchronous should be used or not (for
240 * debugging purpose only)
241 * @keep_aspect: used to remember if reverse negotiation scaling should respect
243 * @brightness: used to store the user settings for color balance brightness
244 * @contrast: used to store the user settings for color balance contrast
245 * @hue: used to store the user settings for color balance hue
246 * @saturation: used to store the user settings for color balance saturation
247 * @cb_changed: used to store if the color balance settings where changed
248 * @video_width: the width of incoming video frames in pixels
249 * @video_height: the height of incoming video frames in pixels
251 * The #GstEvasPixmapSink data structure.
253 struct _GstEvasPixmapSink {
254 /* Our element stuff */
255 GstVideoSink videosink;
260 GstXContext *xcontext;
261 GstXPixmap *xpixmap[NUM_OF_PIXMAP];
262 GstEvasPixmapBuffer *evas_pixmap_buf;
264 GThread *event_thread;
272 GMutex *pixmap_ref_lock;
274 /* object-set pixel aspect ratio */
277 gboolean synchronous;
278 gboolean double_buffer;
286 /* size of incoming video, used as the size for XvImage */
287 guint video_width, video_height;
288 gboolean need_to_fill_black;
290 /* display sizes, used for clipping the image */
292 gint disp_width, disp_height;
294 /* port attributes */
295 gboolean autopaint_colorkey;
299 gboolean have_autopaint_colorkey;
300 gboolean have_colorkey;
301 gboolean have_double_buffer;
303 /* target video rectagle */
304 GstVideoRectangle render_rect;
305 gboolean have_render_rect;
310 guint display_geometry_method;
311 GstVideoRectangle dst_roi;
313 /* needed if fourcc is one if S series */
315 guint aligned_height;
318 buf_share_method_t buf_shared_type;
320 /* ecore & evas object */
326 gint last_updated_idx;
327 gchar update_visibility;
328 gint epipe_request_count;
332 gboolean use_origin_size;
333 gboolean previous_origin_size;
335 gint sizediff_height;
336 guint num_of_pixmaps;
339 Damage damage[NUM_OF_PIXMAP];
340 Damage prev_damage[NUM_OF_PIXMAP];
344 gem_info_t gem_info[MAX_GEM_BUFFER_NUM];
346 /* if needed combine planes data */
347 gint need_combine_data;
349 GstVideoRectangle src_prev;
350 GstVideoRectangle result_prev;
353 void *pixmap_addr[NUM_OF_PIXMAP];
357 /* max plane count *********************************************************/
358 #define MPLANE_IMGB_MAX_COUNT (4)
360 /* image buffer definition ***************************************************
362 +------------------------------------------+ ---
364 | uaddr[], index[] | |
365 | +---------------------------+ --- | |
367 | |<-------- width[] -------->| | | |
370 | | |height[]|elevation[]
375 | +---------------------------+ --- | |
377 +------------------------------------------+ ---
379 |<----------------- stride[] ------------------>|
381 typedef struct _GstMultiPlaneImageBuffer GstMultiPlaneImageBuffer;
382 struct _GstMultiPlaneImageBuffer
386 /* width of each image plane */
387 gint width[MPLANE_IMGB_MAX_COUNT];
388 /* height of each image plane */
389 gint height[MPLANE_IMGB_MAX_COUNT];
390 /* stride of each image plane */
391 gint stride[MPLANE_IMGB_MAX_COUNT];
392 /* elevation of each image plane */
393 gint elevation[MPLANE_IMGB_MAX_COUNT];
394 /* user space address of each image plane */
395 gpointer uaddr[MPLANE_IMGB_MAX_COUNT];
396 /* Index of real address of each image plane, if needs */
397 gpointer index[MPLANE_IMGB_MAX_COUNT];
398 /* left postion, if needs */
400 /* top position, if needs */
402 /* to align memory */
408 struct _GstEvasPixmapSinkClass {
409 GstVideoSinkClass parent_class;
412 GType gst_evaspixmapsink_get_type(void);
416 #endif /* __GST_EVASPIXMAPSINK_H__ */