Add gst_vaapi_display_{sync,flush}() helpers.
[platform/upstream/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapidisplay.h
1 /*
2  *  gstvaapidisplay.h - VA display abstraction
3  *
4  *  gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
19  */
20
21 #ifndef GST_VAAPI_DISPLAY_H
22 #define GST_VAAPI_DISPLAY_H
23
24 #ifdef GST_VAAPI_USE_OLD_VAAPI_0_29
25 # include <va.h>
26 #else
27 # include <va/va.h>
28 #endif
29
30 #include <gst/gst.h>
31 #include <gst/vaapi/gstvaapiimageformat.h>
32
33 G_BEGIN_DECLS
34
35 #define GST_VAAPI_TYPE_DISPLAY \
36     (gst_vaapi_display_get_type())
37
38 #define GST_VAAPI_DISPLAY(obj)                          \
39     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
40                                 GST_VAAPI_TYPE_DISPLAY, \
41                                 GstVaapiDisplay))
42
43 #define GST_VAAPI_DISPLAY_CLASS(klass)                  \
44     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
45                              GST_VAAPI_TYPE_DISPLAY,    \
46                              GstVaapiDisplayClass))
47
48 #define GST_VAAPI_IS_DISPLAY(obj) \
49     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DISPLAY))
50
51 #define GST_VAAPI_IS_DISPLAY_CLASS(klass) \
52     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DISPLAY))
53
54 #define GST_VAAPI_DISPLAY_GET_CLASS(obj)                \
55     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
56                                GST_VAAPI_TYPE_DISPLAY,  \
57                                GstVaapiDisplayClass))
58
59 /**
60  * GST_VAAPI_DISPLAY_VADISPLAY:
61  * @display: a #GstVaapiDisplay
62  *
63  * Macro that evaluates to the #VADisplay bound to @display
64  */
65 #define GST_VAAPI_DISPLAY_VADISPLAY(display) \
66     gst_vaapi_display_get_display(display)
67
68 /**
69  * GST_VAAPI_DISPLAY_LOCK:
70  * @display: a #GstVaapiDisplay
71  *
72  * Locks @display
73  */
74 #define GST_VAAPI_DISPLAY_LOCK(display) \
75     gst_vaapi_display_lock(display)
76
77 /**
78  * GST_VAAPI_DISPLAY_UNLOCK:
79  * @display: a #GstVaapiDisplay
80  *
81  * Unlocks @display
82  */
83 #define GST_VAAPI_DISPLAY_UNLOCK(display) \
84     gst_vaapi_display_unlock(display)
85
86 typedef struct _GstVaapiDisplay                 GstVaapiDisplay;
87 typedef struct _GstVaapiDisplayPrivate          GstVaapiDisplayPrivate;
88 typedef struct _GstVaapiDisplayClass            GstVaapiDisplayClass;
89
90 /**
91  * GstVaapiDisplay:
92  *
93  * Base class for VA displays.
94  */
95 struct _GstVaapiDisplay {
96     /*< private >*/
97     GObject parent_instance;
98
99     GstVaapiDisplayPrivate *priv;
100 };
101
102 /**
103  * GstVaapiDisplayClass:
104  * @open_display: virtual function to open a display
105  * @close_display: virtual function to close a display
106  * @lock: (optional) virtual function to lock a display
107  * @unlock: (optional) virtual function to unlock a display
108  * @sync: (optional) virtual function to sync a display
109  * @flush: (optional) virtual function to flush pending requests of a display
110  * @get_display: virtual function to retrieve the #VADisplay
111  * @get_size: virtual function to retrieve the display dimensions, in pixels
112  * @get_size_mm: virtual function to retrieve the display dimensions, in millimeters
113  *
114  * Base class for VA displays.
115  */
116 struct _GstVaapiDisplayClass {
117     /*< private >*/
118     GObjectClass parent_class;
119
120     /*< public >*/
121     gboolean   (*open_display)  (GstVaapiDisplay *display);
122     void       (*close_display) (GstVaapiDisplay *display);
123     void       (*lock)          (GstVaapiDisplay *display);
124     void       (*unlock)        (GstVaapiDisplay *display);
125     void       (*sync)          (GstVaapiDisplay *display);
126     void       (*flush)         (GstVaapiDisplay *display);
127     VADisplay  (*get_display)   (GstVaapiDisplay *display);
128     void       (*get_size)      (GstVaapiDisplay *display,
129                                  guint *pwidth, guint *pheight);
130     void       (*get_size_mm)   (GstVaapiDisplay *display,
131                                  guint *pwidth, guint *pheight);
132 };
133
134 GType
135 gst_vaapi_display_get_type(void);
136
137 GstVaapiDisplay *
138 gst_vaapi_display_new_with_display(VADisplay va_display);
139
140 void
141 gst_vaapi_display_lock(GstVaapiDisplay *display);
142
143 void
144 gst_vaapi_display_unlock(GstVaapiDisplay *display);
145
146 void
147 gst_vaapi_display_sync(GstVaapiDisplay *display);
148
149 void
150 gst_vaapi_display_flush(GstVaapiDisplay *display);
151
152 VADisplay
153 gst_vaapi_display_get_display(GstVaapiDisplay *display);
154
155 guint
156 gst_vaapi_display_get_width(GstVaapiDisplay *display);
157
158 guint
159 gst_vaapi_display_get_height(GstVaapiDisplay *display);
160
161 void
162 gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight);
163
164 void
165 gst_vaapi_display_get_pixel_aspect_ratio(
166     GstVaapiDisplay *display,
167     guint           *par_n,
168     guint           *par_d
169 );
170
171 gboolean
172 gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile);
173
174 GstCaps *
175 gst_vaapi_display_get_image_caps(GstVaapiDisplay *display);
176
177 gboolean
178 gst_vaapi_display_has_image_format(
179     GstVaapiDisplay    *display,
180     GstVaapiImageFormat format
181 );
182
183 GstCaps *
184 gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display);
185
186 gboolean
187 gst_vaapi_display_has_subpicture_format(
188     GstVaapiDisplay    *display,
189     GstVaapiImageFormat format
190 );
191
192 G_END_DECLS
193
194 #endif /* GST_VAAPI_DISPLAY_H */