Initialize Tizen 2.3
[framework/multimedia/gst-plugins-ext0.10.git] / mobile / 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_ST12         FOURCC('S','T','1','2')
60
61 G_BEGIN_DECLS
62
63 #define GST_TYPE_XV_IMAGE_SRC \
64   (gst_xv_image_src_get_type())
65 #define GST_XV_IMAGE_SRC(obj) \
66   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_XV_IMAGE_SRC,GstXVImageSrc))
67 #define GST_XV_IMAGE_SRC_CLASS(klass) \
68   (G_TYPE_CHECK_CLASS_CAST((klass), \
69       GST_TYPE_XV_IMAGE_SRC,GstXVImageSrcClass))
70 #define GST_IS_XV_IMAGE_SRC(obj) \
71   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_XV_IMAGE_SRC))
72 #define GST_IS_XV_IMAGE_SRC_CLASS(klass) \
73   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_XV_IMAGE_SRC))
74
75 typedef struct _GstXVImageSrc GstXVImageSrc;
76 typedef struct _GstXVImageSrcClass GstXVImageSrcClass;
77
78 struct _GstXVImageSrc {
79   GstPushSrc element;
80   Display       *dpy;
81   int p;
82   Pixmap pixmap;
83   GC gc;
84   unsigned int width;
85   unsigned int height;
86   unsigned int framesize;
87   guint32 format_id;
88   Damage damage;
89   int damage_base;
90   unsigned int evt_base;
91   tbm_bufmgr bufmgr;
92   void *virtual;
93   tbm_bo bo;
94   DRI2Buffer* dri2_buffers;
95   guint64 running_time;
96   guint64 base_time;
97   guint64 frame_duration;
98   Atom atom_stream_off;
99   gint rate_numerator;
100   gint rate_denominator;
101   GThread *updates_thread;
102   gboolean thread_return;
103   GQueue *queue;
104   GMutex *queue_lock;
105   GCond *queue_cond;
106   GMutex *cond_lock;
107   GCond *buffer_cond;
108   gboolean pause_cond_var;
109   GCond *pause_cond;
110   GMutex *pause_cond_lock;
111   GMutex *buffer_cond_lock;
112   GMutex *dpy_lock;
113   gint drm_fd;
114   int current_data_type;
115   int new_data_type;
116   double get_image_overtime;
117   int get_image_overtime_cnt;
118   int gemname_cnt;
119   int tz_enable;
120
121 };
122
123 struct _GstXVImageSrcClass {
124   GstPushSrcClass parent_class;
125
126   /* signals */
127   void  (*video_with_ui)        (void *data);
128   void  (*video_only)   (void *data);
129 };
130
131 GType gst_xv_image_src_get_type (void);
132
133 G_END_DECLS
134
135 #endif /* __GST_XV_IMAGE_SRC_H__ */
136