1 /*
2  *  gstvaapidisplay_priv.h - Base VA display (private definitions)
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2011-2013 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24 
25 #ifndef GST_VAAPI_DISPLAY_PRIV_H
26 #define GST_VAAPI_DISPLAY_PRIV_H
27 
28 #include <gst/vaapi/gstvaapidisplay.h>
29 #include <gst/vaapi/gstvaapiwindow.h>
30 #include <gst/vaapi/gstvaapitexture.h>
31 #include <gst/vaapi/gstvaapitexturemap.h>
32 #include "gstvaapiminiobject.h"
33 
34 G_BEGIN_DECLS
35 
36 #define GST_VAAPI_DISPLAY_CAST(display) \
37     ((GstVaapiDisplay *)(display))
38 
39 #define GST_VAAPI_DISPLAY_GET_PRIVATE(display) \
40     (GST_VAAPI_DISPLAY_CAST (display)->priv)
41 
42 #define GST_VAAPI_DISPLAY_CLASS(klass) \
43     (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPI_DISPLAY, GstVaapiDisplayClass))
44 
45 #define GST_VAAPI_IS_DISPLAY_CLASS(klass) \
46     (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPI_DISPLAY))
47 
48 #define GST_VAAPI_DISPLAY_GET_CLASS(obj) \
49     (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPI_DISPLAY, GstVaapiDisplayClass))
50 
51 typedef struct _GstVaapiDisplayPrivate          GstVaapiDisplayPrivate;
52 typedef struct _GstVaapiDisplayClass            GstVaapiDisplayClass;
53 typedef enum _GstVaapiDisplayInitType           GstVaapiDisplayInitType;
54 
55 /**
56  * GST_VAAPI_DISPLAY_GET_CLASS_TYPE:
57  * @display: a #GstVaapiDisplay
58  *
59  * Returns the #display class type
60  * This is an internal macro that does not do any run-time type check.
61  */
62 #undef  GST_VAAPI_DISPLAY_GET_CLASS_TYPE
63 #define GST_VAAPI_DISPLAY_GET_CLASS_TYPE(display) \
64   (GST_VAAPI_DISPLAY_GET_CLASS (display)->display_type)
65 
66 /**
67  * GST_VAAPI_DISPLAY_NATIVE:
68  * @display: a #GstVaapiDisplay
69  *
70  * Macro that evaluates to the native display of @display.
71  * This is an internal macro that does not do any run-time type check.
72  */
73 #undef  GST_VAAPI_DISPLAY_NATIVE
74 #define GST_VAAPI_DISPLAY_NATIVE(display) \
75   (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->native_display)
76 
77 /**
78  * GST_VAAPI_DISPLAY_VADISPLAY:
79  * @display_: a #GstVaapiDisplay
80  *
81  * Macro that evaluates to the #VADisplay of @display_.
82  * This is an internal macro that does not do any run-time type check.
83  */
84 #undef  GST_VAAPI_DISPLAY_VADISPLAY
85 #define GST_VAAPI_DISPLAY_VADISPLAY(display_) \
86   (GST_VAAPI_DISPLAY_GET_PRIVATE (display_)->display)
87 
88 /**
89  * GST_VAAPI_DISPLAY_VADISPLAY_TYPE:
90  * @display: a #GstVaapiDisplay
91  *
92  * Returns the underlying VADisplay @display type
93  * This is an internal macro that does not do any run-time type check.
94  */
95 #undef  GST_VAAPI_DISPLAY_VADISPLAY_TYPE
96 #define GST_VAAPI_DISPLAY_VADISPLAY_TYPE(display) \
97   (GST_VAAPI_DISPLAY_GET_CLASS (display)->display_type)
98 
99 /**
100  * GST_VAAPI_DISPLAY_HAS_VPP:
101  * @display: a @GstVaapiDisplay
102  *
103  * Returns whether the @display supports video processing (VA/VPP)
104  * This is an internal macro that does not do any run-time type check.
105  */
106 #undef  GST_VAAPI_DISPLAY_HAS_VPP
107 #define GST_VAAPI_DISPLAY_HAS_VPP(display) \
108   gst_vaapi_display_has_video_processing (GST_VAAPI_DISPLAY_CAST (display))
109 
110 struct _GstVaapiDisplayPrivate
111 {
112   GstVaapiDisplay *parent;
113   GRecMutex mutex;
114   gchar *display_name;
115   VADisplay display;
116   gpointer native_display;
117   guint width;
118   guint height;
119   guint width_mm;
120   guint height_mm;
121   guint par_n;
122   guint par_d;
123   GArray *decoders;
124   GArray *encoders;
125   GArray *image_formats;
126   GArray *subpicture_formats;
127   GArray *properties;
128   gchar *vendor_string;
129   guint use_foreign_display:1;
130   guint has_vpp:1;
131   guint has_profiles:1;
132   guint got_scrres:1;
133 };
134 
135 /**
136  * GstVaapiDisplay:
137  *
138  * Base class for VA displays.
139  */
140 struct _GstVaapiDisplay
141 {
142   /*< private >*/
143   GstObject parent_instance;
144 
145   GstVaapiDisplayPrivate *priv;
146 };
147 
148 /**
149  * GstVaapiDisplayClass:
150  * @open_display: virtual function to open a display
151  * @close_display: virtual function to close a display
152  * @lock: (optional) virtual function to lock a display
153  * @unlock: (optional) virtual function to unlock a display
154  * @sync: (optional) virtual function to sync a display
155  * @flush: (optional) virtual function to flush pending requests of a display
156  * @get_display: virtual function to retrieve the #GstVaapiDisplayInfo
157  * @get_size: virtual function to retrieve the display dimensions, in pixels
158  * @get_size_mm: virtual function to retrieve the display dimensions, in millimeters
159  * @get_visual_id: (optional) virtual function to retrieve the window visual id
160  * @get_colormap: (optional) virtual function to retrieve the window colormap
161  * @create_window: (optional) virtual function to create a window
162  * @create_texture: (optional) virtual function to create a texture
163  * @get_texture_map: (optional) virtual function to get texture map
164  *
165  * Base class for VA displays.
166  */
167 struct _GstVaapiDisplayClass
168 {
169   /*< private >*/
170   GstObjectClass parent_class;
171 
172   /*< protected >*/
173   guint display_type;
174 
175   /*< public >*/
176   void                (*init)            (GstVaapiDisplay * display);
177   gboolean            (*bind_display)    (GstVaapiDisplay * display, gpointer native_dpy);
178   gboolean            (*open_display)    (GstVaapiDisplay * display, const gchar * name);
179   void                (*close_display)   (GstVaapiDisplay * display);
180   void                (*lock)            (GstVaapiDisplay * display);
181   void                (*unlock)          (GstVaapiDisplay * display);
182   void                (*sync)            (GstVaapiDisplay * display);
183   void                (*flush)           (GstVaapiDisplay * display);
184   gboolean            (*get_display)     (GstVaapiDisplay * display, GstVaapiDisplayInfo * info);
185   void                (*get_size)        (GstVaapiDisplay * display, guint * pwidth, guint * pheight);
186   void                (*get_size_mm)     (GstVaapiDisplay * display, guint * pwidth, guint * pheight);
187   guintptr            (*get_visual_id)   (GstVaapiDisplay * display, GstVaapiWindow * window);
188   guintptr            (*get_colormap)    (GstVaapiDisplay * display, GstVaapiWindow * window);
189   GstVaapiWindow     *(*create_window)   (GstVaapiDisplay * display, GstVaapiID id, guint width, guint height);
190   GstVaapiTexture    *(*create_texture)  (GstVaapiDisplay * display, GstVaapiID id, guint target, guint format,
191     guint width, guint height);
192   GstVaapiTextureMap *(*get_texture_map) (GstVaapiDisplay * display);
193 };
194 
195 /* Initialization types */
196 enum _GstVaapiDisplayInitType
197 {
198   GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME = 1,
199   GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY,
200   GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY
201 };
202 
203 GstVaapiDisplay *
204 gst_vaapi_display_config (GstVaapiDisplay * display,
205     GstVaapiDisplayInitType init_type, gpointer init_value);
206 
207 G_END_DECLS
208 
209 #endif /* GST_VAAPI_DISPLAY_PRIV_H */
210