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>
54 #include <tbm_bufmgr.h>
60 #define MAX_PLANE_NUM 3
61 #define MAX_BUFFER_NUM 20
62 #define MAX_GEM_BUFFER_NUM (MAX_PLANE_NUM * MAX_BUFFER_NUM)
63 typedef struct _gem_info_t {
65 unsigned int gem_handle;
66 unsigned int gem_name;
72 BUF_SHARE_METHOD_NONE = -1,
73 BUF_SHARE_METHOD_PADDR = 0,
75 BUF_SHARE_METHOD_TIZEN_BUFFER
80 #define GST_TYPE_EVASPIXMAPSINK \
81 (gst_evaspixmapsink_get_type())
82 #define GST_EVASPIXMAPSINK(obj) \
83 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSink))
84 #define GST_EVASPIXMAPSINK_CLASS(klass) \
85 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_EVASPIXMAPSINK, GstEvasPixmapSinkClass))
86 #define GST_IS_EVASPIXMAPSINK(obj) \
87 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_EVASPIXMAPSINK))
88 #define GST_IS_EVASPIXMAPSINK_CLASS(klass) \
89 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_EVASPIXMAPSINK))
91 #define XV_SCREEN_SIZE_WIDTH 4096
92 #define XV_SCREEN_SIZE_HEIGHT 4096
94 #define MARGIN_OF_ERROR 0.005
95 #define NUM_OF_PIXMAP 3
97 typedef struct _GstXContext GstXContext;
98 typedef struct _GstXPixmap GstXPixmap;
99 typedef struct _GstEvasPixmapFormat GstEvasPixmapFormat;
100 typedef struct _GstEvasPixmapBuffer GstEvasPixmapBuffer;
101 typedef struct _GstEvasPixmapBufferClass GstEvasPixmapBufferClass;
102 typedef struct _GstEvasPixmapSink GstEvasPixmapSink;
103 typedef struct _GstEvasPixmapSinkClass GstEvasPixmapSinkClass;
107 * @disp: the X11 Display of this context
108 * @screen: the default Screen of Display @disp
109 * @screen_num: the Screen number of @screen
110 * @visual: the default Visual of Screen @screen
111 * @root: the root Window of Display @disp
112 * @white: the value of a white pixel on Screen @screen
113 * @black: the value of a black pixel on Screen @screen
114 * @depth: the color depth of Display @disp
115 * @bpp: the number of bits per pixel on Display @disp
116 * @endianness: the endianness of image bytes on Display @disp
117 * @width: the width in pixels of Display @disp
118 * @height: the height in pixels of Display @disp
119 * @widthmm: the width in millimeters of Display @disp
120 * @heightmm: the height in millimeters of Display @disp
121 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
123 * @use_xshm: used to known wether of not XShm extension is usable or not even
124 * if the Extension is present
125 * @xv_port_id: the XVideo port ID
126 * @im_format: used to store at least a valid format for XShm calls checks
127 * @formats_list: list of supported image formats on @xv_port_id
128 * @channels_list: list of #GstColorBalanceChannels
129 * @caps: the #GstCaps that Display @disp can accept
131 * Structure used to store various informations collected/calculated for a
134 struct _GstXContext {
151 gint widthmm, heightmm;
152 GValue *par; /* calculated pixel aspect ratio */
162 GList *channels_list;
169 * @pixmap: the pixmap ID of this X11 pixmap
170 * @width: the width in pixels of Pixmap @pixmap
171 * @height: the height in pixels of Pixmap @pixmap
172 * @gc: the Graphical Context of Pixmap @pixmap
174 * Structure used to store informations about a Pixmap.
188 * GstEvasPixmapFormat:
189 * @format: the image format
190 * @caps: generated #GstCaps for this image format
192 * Structure storing image format to #GstCaps association.
194 struct _GstEvasPixmapFormat {
200 * GstEvasPixmapBuffer:
201 * @evaspixmapsink: a reference to our #GstEvasPixmapSink
202 * @xvimage: the XvImage of this buffer
203 * @width: the width in pixels of XvImage @xvimage
204 * @height: the height in pixels of XvImage @xvimage
205 * @im_format: the image format of XvImage @xvimage
206 * @size: the size in bytes of XvImage @xvimage
208 * Subclass of #GstBuffer containing additional information about an XvImage.
210 struct _GstEvasPixmapBuffer {
213 /* Reference to the evaspixmapsink we belong to */
214 GstEvasPixmapSink *evaspixmapsink;
218 XShmSegmentInfo SHMInfo;
219 #endif /* HAVE_XSHM */
228 * @display_name: the name of the Display we want to render to
229 * @xcontext: our instance's #GstXContext
230 * @xpixmap: the #GstXPixmap we are rendering to
231 * @fps_n: the framerate fraction numerator
232 * @fps_d: the framerate fraction denominator
233 * @x_lock: used to protect X calls as we are not using the XLib in threaded
235 * @flow_lock: used to protect data flow routines from external calls such as
236 * methods from the #GstXOverlay interface
237 * @par: used to override calculated pixel aspect ratio from @xcontext
238 * @synchronous: used to store if XSynchronous should be used or not (for
239 * debugging purpose only)
240 * @keep_aspect: used to remember if reverse negotiation scaling should respect
242 * @brightness: used to store the user settings for color balance brightness
243 * @contrast: used to store the user settings for color balance contrast
244 * @hue: used to store the user settings for color balance hue
245 * @saturation: used to store the user settings for color balance saturation
246 * @cb_changed: used to store if the color balance settings where changed
247 * @video_width: the width of incoming video frames in pixels
248 * @video_height: the height of incoming video frames in pixels
250 * The #GstEvasPixmapSink data structure.
252 struct _GstEvasPixmapSink {
253 /* Our element stuff */
254 GstVideoSink videosink;
259 GstXContext *xcontext;
260 GstXPixmap *xpixmap[NUM_OF_PIXMAP];
261 GstEvasPixmapBuffer *evas_pixmap_buf;
263 GThread *event_thread;
271 GMutex *pixmap_ref_lock;
273 /* object-set pixel aspect ratio */
276 gboolean synchronous;
277 gboolean double_buffer;
285 /* size of incoming video, used as the size for XvImage */
286 guint video_width, video_height;
288 /* display sizes, used for clipping the image */
290 gint disp_width, disp_height;
292 /* port attributes */
293 gboolean autopaint_colorkey;
297 gboolean have_autopaint_colorkey;
298 gboolean have_colorkey;
299 gboolean have_double_buffer;
301 /* target video rectagle */
302 GstVideoRectangle render_rect;
303 gboolean have_render_rect;
308 guint display_geometry_method;
309 GstVideoRectangle dst_roi;
311 /* needed if fourcc is one if S series */
313 guint aligned_height;
316 buf_share_method_t buf_shared_type;
318 /* ecore & evas object */
324 gint last_updated_idx;
325 gchar update_visibility;
326 guint epipe_request_count;
330 gboolean use_origin_size;
331 gboolean previous_origin_size;
333 gint sizediff_height;
334 guint num_of_pixmaps;
337 Damage damage[NUM_OF_PIXMAP];
338 Damage prev_damage[NUM_OF_PIXMAP];
342 gem_info_t gem_info[MAX_GEM_BUFFER_NUM];
345 /* max plane count *********************************************************/
346 #define MPLANE_IMGB_MAX_COUNT (4)
348 /* image buffer definition ***************************************************
350 +------------------------------------------+ ---
352 | uaddr[], index[] | |
353 | +---------------------------+ --- | |
355 | |<-------- width[] -------->| | | |
358 | | |height[]|elevation[]
363 | +---------------------------+ --- | |
365 +------------------------------------------+ ---
367 |<----------------- stride[] ------------------>|
369 typedef struct _GstMultiPlaneImageBuffer GstMultiPlaneImageBuffer;
370 struct _GstMultiPlaneImageBuffer
374 /* width of each image plane */
375 gint width[MPLANE_IMGB_MAX_COUNT];
376 /* height of each image plane */
377 gint height[MPLANE_IMGB_MAX_COUNT];
378 /* stride of each image plane */
379 gint stride[MPLANE_IMGB_MAX_COUNT];
380 /* elevation of each image plane */
381 gint elevation[MPLANE_IMGB_MAX_COUNT];
382 /* user space address of each image plane */
383 gpointer uaddr[MPLANE_IMGB_MAX_COUNT];
384 /* Index of real address of each image plane, if needs */
385 gpointer index[MPLANE_IMGB_MAX_COUNT];
386 /* left postion, if needs */
388 /* top position, if needs */
390 /* to align memory */
396 struct _GstEvasPixmapSinkClass {
397 GstVideoSinkClass parent_class;
400 GType gst_evaspixmapsink_get_type(void);
404 #endif /* __GST_EVASPIXMAPSINK_H__ */