tizen 2.3 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_NATIVE_BUFFER
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_NATIVE_BUFFER
35 #include <native-buffer.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_NATIVE_BUFFER
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         native_buffer_t *n_buffer;
96         native_buffer_provider_t *n_provider;
97 };
98
99 /* _GstEvasDisplayingBuffer
100  *
101  * buffer               : manage ref count by got index through comparison
102  * bo                   : compare with buffer from codec for getting index
103  * n_buffer             : compare with buffer from evas for getting index
104  * ref_count    : decide whether it unref buffer or not in gst_evas_image_sink_fini/reset
105  */
106 struct _GstEvasImageDisplayingBuffer {
107         GstBuffer *buffer;
108         void *bo;
109         native_buffer_t *n_buffer;
110         int ref_count;
111 };
112
113 struct _GstEvasImageFlushBuffer {
114         void *bo;
115         native_buffer_t *n_buffer;
116         native_buffer_provider_t *n_provider;
117 };
118 #define NATIVE_BUFFER_NUM 20
119 #define SOURCE_BUFFER_NUM 8
120 #endif
121 struct _GstEvasImageSink
122 {
123         GstVideoSink element;
124
125         Evas_Object *eo;
126         Ecore_Pipe *epipe;
127         Evas_Coord w;
128         Evas_Coord h;
129         gboolean object_show;
130         gchar update_visibility;
131         gboolean gl_zerocopy;
132
133         GstBuffer *oldbuf;
134
135         gboolean is_evas_object_size_set;
136         guint present_data_addr;
137 #ifdef USE_NATIVE_BUFFER
138         GMutex *display_buffer_lock;
139         GMutex *flow_lock;
140         GstEvasImageDisplayingBuffer displaying_buffer[NATIVE_BUFFER_NUM];
141         GstVideoRectangle eo_size;
142         gboolean use_ratio;
143         guint rotate_angle;
144         guint display_geometry_method;
145         guint flip;
146         native_buffer_provider_t *n_provider;
147         GstBuffer *prev_buf;
148         gint prev_index;
149         gint cur_index;
150         gboolean need_flush;
151         gboolean enable_flush_buffer;
152         GstEvasImageFlushBuffer *flush_buffer;
153         gint sent_buffer_cnt;
154         gint debuglog_cnt_showFrame;
155         gint debuglog_cnt_ecoreCbPipe;
156
157         native_buffer_format_t native_buffer_format;
158         struct buffer_info src_buffer_info[NATIVE_BUFFER_NUM];
159         guint src_buf_idx;
160         gboolean is_buffer_allocated;
161 #endif
162 };
163
164 struct _GstEvasImageSinkClass
165 {
166         GstVideoSinkClass parent_class;
167 };
168
169 GType gst_evas_image_sink_get_type (void);
170
171 G_END_DECLS
172
173 #endif /* __GST_EVASIMAGESINK_H__ */