tizen 2.3.1 release
[framework/multimedia/gst-plugins-ext0.10.git] / evasimagesink / src / gstevasimagesink.h
1 /*
2  * evasimagesink
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Sangchul Lee <sc11.lee@samsung.com>
7  *
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)
11  * any later version.
12  *
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.
17  *
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
21  *
22  */
23
24 #ifndef __GST_EVASIMAGESINK_H__
25 #define __GST_EVASIMAGESINK_H__
26
27 //#define USE_TBM_SURFACE
28 #define USE_FIMCC
29
30 #include <gst/gst.h>
31 #include <gst/video/gstvideosink.h>
32 #include <Evas.h>
33 #include <Ecore.h>
34 #ifdef USE_TBM_SURFACE
35 #include <tbm_surface.h>
36 #include <tbm_bufmgr.h>
37 #endif
38 G_BEGIN_DECLS
39
40 /* #defines don't like whitespacey bits */
41 #define GST_TYPE_EVASIMAGESINK \
42   (gst_evas_image_sink_get_type())
43 #define GST_EVASIMAGESINK(obj) \
44   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EVASIMAGESINK,GstEvasImageSink))
45 #define GST_EVASIMAGESINK_CLASS(klass) \
46   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EVASIMAGESINK,GstEvasImageSinkClass))
47 #define GST_IS_EVASIMAGESINK(obj) \
48   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EVASIMAGESINK))
49 #define GST_IS_EVASIMAGESINK_CLASS(klass) \
50   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EVASIMAGESINK))
51
52 typedef struct _GstEvasImageSink      GstEvasImageSink;
53 typedef struct _GstEvasImageSinkClass GstEvasImageSinkClass;
54 #ifdef USE_TBM_SURFACE
55 typedef struct _GstEvasImageDisplayingBuffer GstEvasImageDisplayingBuffer;
56 typedef struct _GstEvasImageFlushBuffer GstEvasImageFlushBuffer;
57 typedef enum {
58         BUF_SHARE_METHOD_NONE = -1,
59         BUF_SHARE_METHOD_PADDR = 0,
60         BUF_SHARE_METHOD_FD,
61         BUF_SHARE_METHOD_TIZEN_BUFFER,
62         BUF_SHARE_METHOD_FLUSH_BUFFER
63 } buf_share_method_t;
64
65 enum {
66     DEGREE_0 = 0,
67     DEGREE_90,
68     DEGREE_180,
69     DEGREE_270,
70     DEGREE_NUM,
71 };
72
73 enum {
74     DISP_GEO_METHOD_LETTER_BOX = 0,
75     DISP_GEO_METHOD_ORIGIN_SIZE,
76     DISP_GEO_METHOD_FULL_SCREEN,
77     DISP_GEO_METHOD_CROPPED_FULL_SCREEN,
78     DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX,
79     DISP_GEO_METHOD_CUSTOM_DST_ROI,
80     DISP_GEO_METHOD_NUM,
81 };
82
83 enum {
84         FLIP_NONE = 0,
85         FLIP_HORIZONTAL,
86         FLIP_VERTICAL,
87         FLIP_BOTH,
88         FLIP_NUM
89 };
90
91 struct buffer_info {
92         uint64_t usr_addr;
93         uint64_t size;
94         void *bo;
95         tbm_surface_h tbm_surf;
96 };
97
98 /* _GstEvasDisplayingBuffer
99  *
100  * buffer               : manage ref count by got index through comparison
101  * bo                   : compare with buffer from codec for getting index
102  * n_buffer             : compare with buffer from evas for getting index
103  * ref_count    : decide whether it unref buffer or not in gst_evas_image_sink_fini/reset
104  */
105 struct _GstEvasImageDisplayingBuffer {
106         GstBuffer *buffer;
107         void *bo;
108         tbm_surface_h tbm_surf;
109         int ref_count;
110 };
111
112 struct _GstEvasImageFlushBuffer {
113         void *bo;
114         tbm_surface_h tbm_surf;
115 };
116 #define NATIVE_BUFFER_NUM 20
117 #define SOURCE_BUFFER_NUM 8
118 #endif
119 struct _GstEvasImageSink
120 {
121         GstVideoSink element;
122
123         Evas_Object *eo;
124         Ecore_Pipe *epipe;
125         Evas_Coord w;
126         Evas_Coord h;
127         gboolean object_show;
128         gchar update_visibility;
129         gboolean gl_zerocopy;
130
131         GstBuffer *oldbuf;
132
133         gboolean is_evas_object_size_set;
134         guint present_data_addr;
135 #ifdef USE_TBM_SURFACE
136         GMutex *display_buffer_lock;
137         GMutex *flow_lock;
138         GstEvasImageDisplayingBuffer displaying_buffer[NATIVE_BUFFER_NUM];
139         GstVideoRectangle eo_size;
140         gboolean use_ratio;
141         guint rotate_angle;
142         guint display_geometry_method;
143         guint flip;
144         GstBuffer *prev_buf;
145         gint prev_index;
146         gint cur_index;
147         gboolean need_flush;
148         gboolean enable_flush_buffer;
149         GstEvasImageFlushBuffer *flush_buffer;
150         gint sent_buffer_cnt;
151         gint debuglog_cnt_showFrame;
152         gint debuglog_cnt_ecoreCbPipe;
153
154         tbm_format tbm_surface_format;
155         struct buffer_info src_buffer_info[NATIVE_BUFFER_NUM];
156         guint src_buf_idx;
157         gboolean is_buffer_allocated;
158 #endif
159 };
160
161 struct _GstEvasImageSinkClass
162 {
163         GstVideoSinkClass parent_class;
164 };
165
166 GType gst_evas_image_sink_get_type (void);
167
168 G_END_DECLS
169
170 #endif /* __GST_EVASIMAGESINK_H__ */