4765e326cce9e013423add8b7868dd02967f470e
[platform/core/multimedia/gst-plugins-ext0.10.git] / 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 <drm_slp_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   drm_slp_bufmgr bufmgr;
91   void *virtual;
92   drm_slp_bo bo;
93   DRI2Buffer* dri2_buffers;
94   guint64 running_time;
95   guint64 base_time;
96   guint64 frame_duration;;
97   Atom atom_stream_off;
98   gint rate_numerator;
99   gint rate_denominator;
100   GThread *updates_thread;
101   gboolean thread_return;
102   GQueue *queue;
103   GMutex *queue_lock;
104   GCond *queue_cond;
105   GMutex *cond_lock;
106   gint drm_fd;
107   int current_data_type;
108   int new_data_type;
109   double get_image_overtime;
110   int get_image_overtime_cnt;
111   int gemname_cnt;
112
113 };
114
115 struct _GstXVImageSrcClass {
116   GstPushSrcClass parent_class;
117
118   /* signals */
119   void  (*video_with_ui)        (void *data);
120   void  (*video_only)   (void *data);
121 };
122
123 GType gst_xv_image_src_get_type (void);
124
125 G_END_DECLS
126
127 #endif /* __GST_XV_IMAGE_SRC_H__ */
128