display: add initial support for display attributes.
[vaapi:lorenzphs-gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapidisplay.h
1 /*
2  *  gstvaapidisplay.h - VA display abstraction
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *  Copyright (C) 2011-2012 Intel Corporation
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Lesser General Public License
9  *  as published by the Free Software Foundation; either version 2.1
10  *  of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this library; if not, write to the Free
19  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  *  Boston, MA 02110-1301 USA
21  */
22
23 #ifndef GST_VAAPI_DISPLAY_H
24 #define GST_VAAPI_DISPLAY_H
25
26 #include <va/va.h>
27 #include <gst/gst.h>
28 #include <gst/vaapi/gstvaapiimageformat.h>
29 #include <gst/vaapi/gstvaapiprofile.h>
30
31 G_BEGIN_DECLS
32
33 #define GST_VAAPI_TYPE_DISPLAY \
34     (gst_vaapi_display_get_type())
35
36 #define GST_VAAPI_DISPLAY(obj)                          \
37     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
38                                 GST_VAAPI_TYPE_DISPLAY, \
39                                 GstVaapiDisplay))
40
41 #define GST_VAAPI_DISPLAY_CLASS(klass)                  \
42     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
43                              GST_VAAPI_TYPE_DISPLAY,    \
44                              GstVaapiDisplayClass))
45
46 #define GST_VAAPI_IS_DISPLAY(obj) \
47     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DISPLAY))
48
49 #define GST_VAAPI_IS_DISPLAY_CLASS(klass) \
50     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DISPLAY))
51
52 #define GST_VAAPI_DISPLAY_GET_CLASS(obj)                \
53     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
54                                GST_VAAPI_TYPE_DISPLAY,  \
55                                GstVaapiDisplayClass))
56
57 typedef enum   _GstVaapiDisplayType             GstVaapiDisplayType;
58 typedef struct _GstVaapiDisplayInfo             GstVaapiDisplayInfo;
59 typedef struct _GstVaapiDisplay                 GstVaapiDisplay;
60 typedef struct _GstVaapiDisplayPrivate          GstVaapiDisplayPrivate;
61 typedef struct _GstVaapiDisplayClass            GstVaapiDisplayClass;
62
63 /**
64  * GstVaapiDisplayType:
65  * @GST_VAAPI_DISPLAY_TYPE_ANY: Automatic detection of the display type.
66  * @GST_VAAPI_DISPLAY_TYPE_X11: VA/X11 display.
67  * @GST_VAAPI_DISPLAY_TYPE_GLX: VA/GLX display.
68  * @GST_VAAPI_DISPLAY_TYPE_WAYLAND: VA/Wayland display.
69  * @GST_VAAPI_DISPLAY_TYPE_DRM: VA/DRM display.
70  */
71 enum _GstVaapiDisplayType {
72     GST_VAAPI_DISPLAY_TYPE_ANY = 0,
73     GST_VAAPI_DISPLAY_TYPE_X11,
74     GST_VAAPI_DISPLAY_TYPE_GLX,
75     GST_VAAPI_DISPLAY_TYPE_WAYLAND,
76     GST_VAAPI_DISPLAY_TYPE_DRM,
77 };
78
79 #define GST_VAAPI_TYPE_DISPLAY_TYPE \
80     (gst_vaapi_display_type_get_type())
81
82 GType
83 gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
84
85 /**
86  * GstVaapiDisplayInfo:
87  *
88  * Generic class to retrieve VA display info
89  */
90 struct _GstVaapiDisplayInfo {
91     GstVaapiDisplay    *display;
92     GstVaapiDisplayType display_type;
93     gchar              *display_name;
94     VADisplay           va_display;
95     gpointer            native_display;
96 };
97
98 /**
99  * GstVaapiDisplay:
100  *
101  * Base class for VA displays.
102  */
103 struct _GstVaapiDisplay {
104     /*< private >*/
105     GObject parent_instance;
106
107     GstVaapiDisplayPrivate *priv;
108 };
109
110 /**
111  * GstVaapiDisplayClass:
112  * @open_display: virtual function to open a display
113  * @close_display: virtual function to close a display
114  * @lock: (optional) virtual function to lock a display
115  * @unlock: (optional) virtual function to unlock a display
116  * @sync: (optional) virtual function to sync a display
117  * @flush: (optional) virtual function to flush pending requests of a display
118  * @get_display: virtual function to retrieve the #GstVaapiDisplayInfo
119  * @get_size: virtual function to retrieve the display dimensions, in pixels
120  * @get_size_mm: virtual function to retrieve the display dimensions, in millimeters
121  *
122  * Base class for VA displays.
123  */
124 struct _GstVaapiDisplayClass {
125     /*< private >*/
126     GObjectClass parent_class;
127
128     /*< public >*/
129     gboolean   (*open_display)  (GstVaapiDisplay *display);
130     void       (*close_display) (GstVaapiDisplay *display);
131     void       (*lock)          (GstVaapiDisplay *display);
132     void       (*unlock)        (GstVaapiDisplay *display);
133     void       (*sync)          (GstVaapiDisplay *display);
134     void       (*flush)         (GstVaapiDisplay *display);
135     gboolean   (*get_display)   (GstVaapiDisplay *display,
136                                  GstVaapiDisplayInfo *info);
137     void       (*get_size)      (GstVaapiDisplay *display,
138                                  guint *pwidth, guint *pheight);
139     void       (*get_size_mm)   (GstVaapiDisplay *display,
140                                  guint *pwidth, guint *pheight);
141 };
142
143 GType
144 gst_vaapi_display_get_type(void) G_GNUC_CONST;
145
146 GstVaapiDisplay *
147 gst_vaapi_display_new_with_display(VADisplay va_display);
148
149 void
150 gst_vaapi_display_lock(GstVaapiDisplay *display);
151
152 void
153 gst_vaapi_display_unlock(GstVaapiDisplay *display);
154
155 void
156 gst_vaapi_display_sync(GstVaapiDisplay *display);
157
158 void
159 gst_vaapi_display_flush(GstVaapiDisplay *display);
160
161 GstVaapiDisplayType
162 gst_vaapi_display_get_display_type(GstVaapiDisplay *display);
163
164 VADisplay
165 gst_vaapi_display_get_display(GstVaapiDisplay *display);
166
167 guint
168 gst_vaapi_display_get_width(GstVaapiDisplay *display);
169
170 guint
171 gst_vaapi_display_get_height(GstVaapiDisplay *display);
172
173 void
174 gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight);
175
176 void
177 gst_vaapi_display_get_pixel_aspect_ratio(
178     GstVaapiDisplay *display,
179     guint           *par_n,
180     guint           *par_d
181 );
182
183 GstCaps *
184 gst_vaapi_display_get_decode_caps(GstVaapiDisplay *display);
185
186 gboolean
187 gst_vaapi_display_has_decoder(
188     GstVaapiDisplay    *display,
189     GstVaapiProfile     profile,
190     GstVaapiEntrypoint  entrypoint
191 );
192
193 GstCaps *
194 gst_vaapi_display_get_encode_caps(GstVaapiDisplay *display);
195
196 gboolean
197 gst_vaapi_display_has_encoder(
198     GstVaapiDisplay    *display,
199     GstVaapiProfile     profile,
200     GstVaapiEntrypoint  entrypoint
201 );
202
203 GstCaps *
204 gst_vaapi_display_get_image_caps(GstVaapiDisplay *display);
205
206 gboolean
207 gst_vaapi_display_has_image_format(
208     GstVaapiDisplay    *display,
209     GstVaapiImageFormat format
210 );
211
212 GstCaps *
213 gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display);
214
215 gboolean
216 gst_vaapi_display_has_subpicture_format(
217     GstVaapiDisplay    *display,
218     GstVaapiImageFormat format
219 );
220
221 gboolean
222 gst_vaapi_display_has_property(GstVaapiDisplay *display, const gchar *name);
223
224 G_END_DECLS
225
226 #endif /* GST_VAAPI_DISPLAY_H */