1 /*############################################################################
2 # Copyright (C) Intel Corporation
4 # SPDX-License-Identifier: MIT
5 ############################################################################*/
7 #ifndef DISPATCHER_WINDOWS_MFX_LIBRARY_ITERATOR_H_
8 #define DISPATCHER_WINDOWS_MFX_LIBRARY_ITERATOR_H_
12 #include "vpl/mfxvideo.h"
14 #if !defined(MEDIASDK_UWP_DISPATCHER)
15 #include "mfx_win_reg_key.h"
18 #include "windows/mfx_dispatcher.h"
19 #include "windows/mfx_driver_store_loader.h"
23 // declare desired storage ID
25 #if defined(MFX_TRACER_WA_FOR_DS)
28 MFX_DRIVER_STORE_ONEVPL_MFXINIT = 1,
30 MFX_CURRENT_USER_KEY = 3,
31 MFX_LOCAL_MACHINE_KEY = 4,
33 MFX_PATH_MSDK_FOLDER = 6,
34 MFX_STORAGE_ID_FIRST = MFX_TRACER,
35 MFX_STORAGE_ID_LAST = MFX_PATH_MSDK_FOLDER,
39 MFX_CURRENT_USER_KEY = 1,
40 MFX_LOCAL_MACHINE_KEY = 2,
42 MFX_PATH_MSDK_FOLDER = 4,
43 MFX_STORAGE_ID_FIRST = MFX_DRIVER_STORE,
44 MFX_STORAGE_ID_LAST = MFX_PATH_MSDK_FOLDER,
46 MFX_DRIVER_STORE_ONEVPL = 1001,
47 MFX_CURRENT_USER_KEY_ONEVPL = 1002,
48 MFX_LOCAL_MACHINE_KEY_ONEVPL = 1003,
51 // Try to initialize using given implementation type. Select appropriate type automatically in case of MFX_IMPL_VIA_ANY.
52 // Params: adapterNum - in, pImplInterface - in/out, pVendorID - out, pDeviceID - out, pLUID - out (optional)
53 mfxStatus SelectImplementationType(const mfxU32 adapterNum,
54 mfxIMPL *pImplInterface,
58 mfxStatus SelectImplementationType(const mfxU32 adapterNum,
59 mfxIMPL *pImplInterface,
64 bool GetImplPath(int storageID, wchar_t *sImplPath);
66 const mfxU32 msdk_disp_path_len = 1024;
68 class MFXLibraryIterator {
70 // Default constructor
71 MFXLibraryIterator(void);
73 ~MFXLibraryIterator(void);
75 // Initialize the iterator
76 mfxStatus Init(eMfxImplType implType,
77 mfxIMPL implInterface,
78 const mfxU32 adapterNum,
81 // Get the next library path
82 mfxStatus SelectDLLVersion(wchar_t *pPath,
84 eMfxImplType *pImplType,
85 mfxVersion minVersion);
87 // Return interface type on which Intel adapter was found (if any): D3D9 or D3D11
88 mfxIMPL GetImplementationType();
90 // Retrun registry subkey name on which dll was selected after sucesfull call to selectDllVesion
91 bool GetSubKeyName(wchar_t *subKeyName, size_t length) const;
93 int GetStorageID() const {
97 static mfxStatus GetDriverStoreDir(std::wstring &driverStoreDir,
101 static mfxStatus GetRegkeyDir(std::wstring ®Dir, size_t length, int storageID);
104 // Release the iterator
107 // Initialize the registry iterator
108 mfxStatus InitRegistry(int storageID);
109 #if defined(MFX_TRACER_WA_FOR_DS)
110 // Initialize the registry iterator for searching for tracer
111 mfxStatus InitRegistryTracer();
113 // Initialize the app/module folder iterator
114 mfxStatus InitFolder(eMfxImplType implType, const wchar_t *path, const int storageID);
116 eMfxImplType m_implType; // Required library implementation
117 mfxIMPL m_implInterface; // Required interface (D3D9, D3D11)
119 mfxU32 m_vendorID; // (mfxU32) property of used graphic card
120 mfxU32 m_deviceID; // (mfxU32) property of used graphic card
121 bool m_bIsSubKeyValid;
122 wchar_t m_SubKeyName[MFX_MAX_REGISTRY_KEY_NAME]; // registry subkey for selected module loaded
125 #if !defined(MEDIASDK_UWP_DISPATCHER)
126 WinRegKey m_baseRegKey; // (WinRegKey) main registry key
129 mfxU32 m_lastLibIndex; // (mfxU32) index of previously returned library
130 mfxU32 m_lastLibMerit; // (mfxU32) merit of previously returned library
132 wchar_t m_path[msdk_disp_path_len]; //NOLINT(runtime/arrays)
133 wchar_t m_driverStoreDir[msdk_disp_path_len]; //NOLINT(runtime/arrays)
135 DriverStoreLoader m_driverStoreLoader; // for loading MediaSDK from DriverStore
138 // unimplemented by intent to make this class non-copyable
139 MFXLibraryIterator(const MFXLibraryIterator &);
140 void operator=(const MFXLibraryIterator &);
145 #endif // DISPATCHER_WINDOWS_MFX_LIBRARY_ITERATOR_H_