6
6
7
7
#if defined(LIBVA_DRM_SUPPORT) || defined(LIBVA_X11_SUPPORT) || defined(LIBVA_ANDROID_SUPPORT) || \
8
8
defined (LIBVA_WAYLAND_SUPPORT)
9
-
10
9
#include " hw_device.h"
11
10
#include " vaapi_utils_drm.h"
12
11
#include " vaapi_utils_x11.h"
13
12
#if defined(LIBVA_ANDROID_SUPPORT)
14
13
#include " vaapi_utils_android.h"
15
14
#endif
15
+ #ifdef LIBVA_GTK4_SUPPORT
16
+ #include < glibmm/dispatcher.h>
17
+ #include < future>
18
+ #include " gtkdata.h"
19
+ #include " vaapi_utils_gtk.h"
20
+ #endif
16
21
17
22
CHWDevice* CreateVAAPIDevice (const std::string& devicePath = " " , int type = MFX_LIBVA_DRM);
18
23
@@ -23,7 +28,10 @@ class CVAAPIDeviceDRM : public CHWDevice {
23
28
CVAAPIDeviceDRM (const std::string& devicePath, int type);
24
29
virtual ~CVAAPIDeviceDRM (void );
25
30
26
- virtual mfxStatus Init (mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum);
31
+ virtual mfxStatus Init (mfxHDL hWindow,
32
+ mfxU16 nViews,
33
+ mfxU32 nAdapterNum,
34
+ bool isFullScreen = false );
27
35
virtual mfxStatus Reset (void ) {
28
36
return MFX_ERR_NONE;
29
37
}
@@ -80,7 +88,10 @@ class CVAAPIDeviceX11 : public CHWDevice {
80
88
}
81
89
virtual ~CVAAPIDeviceX11 (void );
82
90
83
- virtual mfxStatus Init (mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum);
91
+ virtual mfxStatus Init (mfxHDL hWindow,
92
+ mfxU16 nViews,
93
+ mfxU32 nAdapterNum,
94
+ bool isFullScreen = false );
84
95
virtual mfxStatus Reset (void );
85
96
virtual void Close (void );
86
97
@@ -128,7 +139,10 @@ class CVAAPIDeviceWayland : public CHWDevice {
128
139
}
129
140
virtual ~CVAAPIDeviceWayland (void );
130
141
131
- virtual mfxStatus Init (mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum);
142
+ virtual mfxStatus Init (mfxHDL hWindow,
143
+ mfxU16 nViews,
144
+ mfxU32 nAdapterNum,
145
+ bool isFullScreen = false );
132
146
virtual mfxStatus Reset (void ) {
133
147
return MFX_ERR_NONE;
134
148
}
@@ -192,7 +206,10 @@ class CVAAPIDeviceAndroid : public CHWDevice {
192
206
Close ();
193
207
}
194
208
195
- virtual mfxStatus Init (mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum) {
209
+ virtual mfxStatus Init (mfxHDL hWindow,
210
+ mfxU16 nViews,
211
+ mfxU32 nAdapterNum,
212
+ bool isFullScreen = false ) {
196
213
return MFX_ERR_NONE;
197
214
}
198
215
virtual mfxStatus Reset (void ) {
@@ -222,6 +239,78 @@ class CVAAPIDeviceAndroid : public CHWDevice {
222
239
223
240
protected:
224
241
AndroidLibVA* m_pAndroidLibVA;
242
+ };
243
+ #endif
244
+ #if defined(LIBVA_GTK4_SUPPORT)
245
+ class CVAAPIDeviceGTK : public CHWDevice {
246
+ public:
247
+ CVAAPIDeviceGTK (const std::string& devicePath) {
248
+ m_nRenderWinX = 0 ;
249
+ m_nRenderWinY = 0 ;
250
+ m_nRenderWinW = 0 ;
251
+ m_nRenderWinH = 0 ;
252
+ m_bRenderWin = false ;
253
+ m_device_path = devicePath;
254
+
255
+ if (isWayland ()) {
256
+ m_DRMLibVA = new DRMLibVA (devicePath);
257
+ }
258
+ else {
259
+ m_GtkLibVA = new X11GtkVA (devicePath);
260
+ }
261
+ }
262
+
263
+ virtual ~CVAAPIDeviceGTK (void ) {
264
+ delete m_GtkLibVA;
265
+ delete m_DRMLibVA;
266
+ }
267
+
268
+ virtual mfxStatus Init (mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum, bool isFullScreen);
269
+ virtual mfxStatus Reset (void ) {
270
+ return MFX_ERR_NONE;
271
+ }
272
+ virtual void Close (void ) {}
273
+
274
+ virtual mfxStatus SetHandle (mfxHandleType type, mfxHDL hdl) {
275
+ return MFX_ERR_UNSUPPORTED;
276
+ }
277
+ virtual mfxStatus GetHandle (mfxHandleType type, mfxHDL* pHdl);
278
+
279
+ virtual mfxStatus RenderFrame (mfxFrameSurface1* pSurface, mfxFrameAllocator* pmfxAlloc);
280
+
281
+ virtual void UpdateTitle (double fps) {}
282
+ virtual void SetMondelloInput (bool isMondelloInputEnabled) {}
283
+ virtual void SetDxgiFullScreen () {}
284
+
285
+ bool GetInitDone () {
286
+ return m_initComplete.get ();
287
+ }
288
+
289
+ bool isWayland () {
290
+ return std::getenv (" WAYLAND_DISPLAY" ) != nullptr ;
291
+ }
292
+
293
+ private:
294
+ bool m_bRenderWin;
295
+ mfxU32 m_nRenderWinX;
296
+ mfxU32 m_nRenderWinY;
297
+ mfxU32 m_nRenderWinW;
298
+ mfxU32 m_nRenderWinH;
299
+ std::string m_device_path;
300
+ std::atomic<bool > m_ForceStop = false ;
301
+ std::promise<bool > m_initPromise;
302
+ std::future<bool > m_initComplete;
303
+
304
+ protected:
305
+ X11GtkVA* m_GtkLibVA;
306
+ DRMLibVA* m_DRMLibVA;
307
+ virtual void SetForceStop () {
308
+ m_ForceStop = true ;
309
+ }
310
+ void gtkMain (bool isFullScreen, std::promise<bool >&& initPromise);
311
+ Glib::Dispatcher* m_dispatcher_ptr;
312
+ gtk_data_t * m_frame_data_ptr;
313
+ std::thread* m_gtk_thread;
225
314
};
226
315
#endif
227
316
#endif // #if defined(LIBVA_DRM_SUPPORT) || defined(LIBVA_X11_SUPPORT) || defined(LIBVA_ANDROID_SUPPORT)
0 commit comments