Initialize Tizen 2.3
[framework/multimedia/gst-plugins-ext0.10.git] / wearable / xvimagesrc / src / gstxvimagesrc.h
1 /*
2  * xvimagesrc
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunil Park <hyunil46.park@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 #ifndef __GST_XV_IMAGE_SRC_H__
24 #define __GST_XV_IMAGE_SRC_H__
25
26 #include <gst/gst.h>
27 #include <gst/base/gstpushsrc.h>
28 #include <glib.h>
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <fcntl.h>
33 #include <unistd.h>
34 #include <pthread.h>
35 #include <signal.h>
36
37 #include <sys/types.h>
38 #include <sys/shm.h>
39
40 #include <X11/X.h>
41 #include <X11/Xlib.h>
42 #include <X11/Xutil.h>
43 #include <X11/extensions/Xvlib.h>
44 #include <X11/extensions/Xvproto.h>
45 #include <X11/extensions/XShm.h>
46 #include <X11/extensions/Xdamage.h>
47
48 #include <dri2.h> //libdri2-dev, libdrm-dev
49 #include <tbm_bufmgr.h>
50
51 #include "xv_types.h"
52
53 #define C(b,m)              (((b) >> (m)) & 0xFF)
54 #define B(c,s)              ((((unsigned int)(c)) & 0xff) << (s))
55 #define FOURCC(a,b,c,d)     (B(d,24) | B(c,16) | B(b,8) | B(a,0))
56 #define FOURCC_RGB32        FOURCC('R','G','B','4')
57 #define FOURCC_I420         FOURCC('I','4','2','0')
58 #define FOURCC_SN12         FOURCC('S','N','1','2')
59 #define FOURCC_NV12         FOURCC('N','V','1','2')
60 #define FOURCC_ST12         FOURCC('S','T','1','2')
61
62 G_BEGIN_DECLS
63
64 #define GST_TYPE_XV_IMAGE_SRC \
65   (gst_xv_image_src_get_type())
66 #define GST_XV_IMAGE_SRC(obj) \
67   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_XV_IMAGE_SRC,GstXVImageSrc))
68 #define GST_XV_IMAGE_SRC_CLASS(klass) \
69   (G_TYPE_CHECK_CLASS_CAST((klass), \
70       GST_TYPE_XV_IMAGE_SRC,GstXVImageSrcClass))
71 #define GST_IS_XV_IMAGE_SRC(obj) \
72   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_XV_IMAGE_SRC))
73 #define GST_IS_XV_IMAGE_SRC_CLASS(klass) \
74   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_XV_IMAGE_SRC))
75
76 typedef struct _GstXVImageSrc GstXVImageSrc;
77 typedef struct _GstXVImageSrcClass GstXVImageSrcClass;
78
79 struct _GstXVImageSrc {
80   GstPushSrc element;
81   Display       *dpy;
82   int p;
83   Pixmap pixmap;
84   GC gc;
85   unsigned int width;
86   unsigned int height;
87   unsigned int framesize;
88   guint32 format_id;
89   Damage damage;
90   int damage_base;
91   unsigned int evt_base;
92   tbm_bufmgr bufmgr;
93   void *virtual;
94   tbm_bo bo;
95   DRI2Buffer* dri2_buffers;
96   guint64 running_time;
97   guint64 base_time;
98   guint64 frame_duration;
99   Atom atom_stream_off;
100   gint rate_numerator;
101   gint rate_denominator;
102   GThread *updates_thread;
103   gboolean thread_return;
104   GQueue *queue;
105   GMutex *queue_lock;
106   GCond *queue_cond;
107   GMutex *cond_lock;
108   GCond *buffer_cond;
109   gboolean pause_cond_var;
110   GCond *pause_cond;
111   GMutex *pause_cond_lock;
112   GMutex *buffer_cond_lock;
113   GMutex *dpy_lock;
114   gint drm_fd;
115   gboolean is_secured_mode;
116   int current_data_type;
117   int new_data_type;
118   double get_image_overtime;
119   int get_image_overtime_cnt;
120   int gemname_cnt;
121   int tz_enable;
122   long sleep_base_time;
123   long sleep_limit_time;
124
125 };
126
127 struct _GstXVImageSrcClass {
128   GstPushSrcClass parent_class;
129
130   /* signals */
131   void  (*video_with_ui)        (void *data);
132   void  (*video_only)   (void *data);
133 };
134
135 GType gst_xv_image_src_get_type (void);
136
137 G_END_DECLS
138
139 #endif /* __GST_XV_IMAGE_SRC_H__ */
140