1 /*############################################################################ 2 # Copyright (C) 2012-2020 Intel Corporation 3 # 4 # SPDX-License-Identifier: MIT 5 ############################################################################*/ 6 7 #ifndef DISPATCHER_WINDOWS_MFX_LIBRARY_ITERATOR_H_ 8 #define DISPATCHER_WINDOWS_MFX_LIBRARY_ITERATOR_H_ 9 10 #include <string> 11 12 #include "vpl/mfxvideo.h" 13 14 #if !defined(MEDIASDK_UWP_DISPATCHER) 15 #include "mfx_win_reg_key.h" 16 #endif 17 18 #include "windows/mfx_dispatcher.h" 19 #include "windows/mfx_driver_store_loader.h" 20 21 namespace MFX { 22 23 // declare desired storage ID 24 enum { 25 #if defined(MFX_TRACER_WA_FOR_DS) 26 MFX_UNKNOWN_KEY = -1, 27 MFX_TRACER = 0, 28 MFX_DRIVER_STORE_ONEVPL_MFXINIT = 1, 29 MFX_DRIVER_STORE = 2, 30 MFX_CURRENT_USER_KEY = 3, 31 MFX_LOCAL_MACHINE_KEY = 4, 32 MFX_APP_FOLDER = 5, 33 MFX_PATH_MSDK_FOLDER = 6, 34 MFX_STORAGE_ID_FIRST = MFX_TRACER, 35 MFX_STORAGE_ID_LAST = MFX_PATH_MSDK_FOLDER, 36 #else 37 MFX_UNKNOWN_KEY = -1, 38 MFX_DRIVER_STORE = 0, 39 MFX_CURRENT_USER_KEY = 1, 40 MFX_LOCAL_MACHINE_KEY = 2, 41 MFX_APP_FOLDER = 3, 42 MFX_PATH_MSDK_FOLDER = 4, 43 MFX_STORAGE_ID_FIRST = MFX_DRIVER_STORE, 44 MFX_STORAGE_ID_LAST = MFX_PATH_MSDK_FOLDER, 45 #endif 46 MFX_DRIVER_STORE_ONEVPL = 1001, 47 MFX_CURRENT_USER_KEY_ONEVPL = 1002, 48 MFX_LOCAL_MACHINE_KEY_ONEVPL = 1003, 49 }; 50 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, 55 mfxU32 *pVendorID, 56 mfxU32 *pDeviceID); 57 58 mfxStatus SelectImplementationType(const mfxU32 adapterNum, 59 mfxIMPL *pImplInterface, 60 mfxU32 *pVendorID, 61 mfxU32 *pDeviceID, 62 mfxU64 *pLUID); 63 64 bool GetImplPath(int storageID, wchar_t *sImplPath); 65 66 const mfxU32 msdk_disp_path_len = 1024; 67 68 class MFXLibraryIterator { 69 public: 70 // Default constructor 71 MFXLibraryIterator(void); 72 // Destructor 73 ~MFXLibraryIterator(void); 74 75 // Initialize the iterator 76 mfxStatus Init(eMfxImplType implType, 77 mfxIMPL implInterface, 78 const mfxU32 adapterNum, 79 int storageID); 80 81 // Get the next library path 82 mfxStatus SelectDLLVersion(wchar_t *pPath, 83 size_t pathSize, 84 eMfxImplType *pImplType, 85 mfxVersion minVersion); 86 87 // Return interface type on which Intel adapter was found (if any): D3D9 or D3D11 88 mfxIMPL GetImplementationType(); 89 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; 92 GetStorageID()93 int GetStorageID() const { 94 return m_StorageID; 95 } 96 97 static mfxStatus GetDriverStoreDir(std::wstring &driverStoreDir, 98 size_t length, 99 mfxU32 deviceID, 100 int storageID); 101 static mfxStatus GetRegkeyDir(std::wstring ®Dir, size_t length, int storageID); 102 103 protected: 104 // Release the iterator 105 void Release(void); 106 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(); 112 #endif 113 // Initialize the app/module folder iterator 114 mfxStatus InitFolder(eMfxImplType implType, const wchar_t *path, const int storageID); 115 116 eMfxImplType m_implType; // Required library implementation 117 mfxIMPL m_implInterface; // Required interface (D3D9, D3D11) 118 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 123 int m_StorageID; 124 125 #if !defined(MEDIASDK_UWP_DISPATCHER) 126 WinRegKey m_baseRegKey; // (WinRegKey) main registry key 127 #endif 128 129 mfxU32 m_lastLibIndex; // (mfxU32) index of previously returned library 130 mfxU32 m_lastLibMerit; // (mfxU32) merit of previously returned library 131 132 wchar_t m_path[msdk_disp_path_len]; //NOLINT(runtime/arrays) 133 wchar_t m_driverStoreDir[msdk_disp_path_len]; //NOLINT(runtime/arrays) 134 135 DriverStoreLoader m_driverStoreLoader; // for loading MediaSDK from DriverStore 136 137 private: 138 // unimplemented by intent to make this class non-copyable 139 MFXLibraryIterator(const MFXLibraryIterator &); 140 void operator=(const MFXLibraryIterator &); 141 }; 142 143 } // namespace MFX 144 145 #endif // DISPATCHER_WINDOWS_MFX_LIBRARY_ITERATOR_H_ 146