1
0

mfx_dispatcher.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /* ****************************************************************************** *\
  2. Copyright (C) 2012-2017 Intel Corporation. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. - Redistributions of source code must retain the above copyright notice,
  6. this list of conditions and the following disclaimer.
  7. - Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. - Neither the name of Intel Corporation nor the names of its contributors
  11. may be used to endorse or promote products derived from this software
  12. without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
  14. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  16. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
  17. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  19. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. File Name: mfx_dispatcher.h
  24. \* ****************************************************************************** */
  25. #if !defined(__MFX_DISPATCHER_H)
  26. #define __MFX_DISPATCHER_H
  27. #include <mfxvideo.h>
  28. #include <mfxaudio.h>
  29. #include <mfxplugin.h>
  30. #include <stddef.h>
  31. #include "mfx_dispatcher_defs.h"
  32. #include "mfx_load_plugin.h"
  33. #include "mfxenc.h"
  34. #include "mfxpak.h"
  35. #define INTEL_VENDOR_ID 0x8086
  36. mfxStatus MFXQueryVersion(mfxSession session, mfxVersion *version);
  37. enum
  38. {
  39. // to avoid code changing versions are just inherited
  40. // from the API header file.
  41. DEFAULT_API_VERSION_MAJOR = MFX_VERSION_MAJOR,
  42. DEFAULT_API_VERSION_MINOR = MFX_VERSION_MINOR
  43. };
  44. //
  45. // declare functions' integer identifiers.
  46. //
  47. #undef FUNCTION
  48. #define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
  49. e##func_name,
  50. enum eFunc
  51. {
  52. eMFXInit,
  53. eMFXClose,
  54. eMFXQueryIMPL,
  55. eMFXQueryVersion,
  56. eMFXJoinSession,
  57. eMFXDisjoinSession,
  58. eMFXCloneSession,
  59. eMFXSetPriority,
  60. eMFXGetPriority,
  61. eMFXInitEx,
  62. #include "mfx_exposed_functions_list.h"
  63. eVideoFuncTotal
  64. };
  65. enum ePluginFunc
  66. {
  67. eMFXVideoUSER_Load,
  68. eMFXVideoUSER_LoadByPath,
  69. eMFXVideoUSER_UnLoad,
  70. eMFXAudioUSER_Load,
  71. eMFXAudioUSER_UnLoad,
  72. ePluginFuncTotal
  73. };
  74. enum eAudioFunc
  75. {
  76. eFakeAudioEnum = eMFXGetPriority,
  77. #include "mfxaudio_exposed_functions_list.h"
  78. eAudioFuncTotal
  79. };
  80. // declare max buffer length for regsitry key name
  81. enum
  82. {
  83. MFX_MAX_REGISTRY_KEY_NAME = 256
  84. };
  85. // declare the maximum DLL path
  86. enum
  87. {
  88. MFX_MAX_DLL_PATH = 1024
  89. };
  90. // declare library's implementation types
  91. enum eMfxImplType
  92. {
  93. MFX_LIB_HARDWARE = 0,
  94. MFX_LIB_SOFTWARE = 1,
  95. MFX_LIB_PSEUDO = 2,
  96. MFX_LIB_IMPL_TYPES
  97. };
  98. // declare dispatcher's version
  99. enum
  100. {
  101. MFX_DISPATCHER_VERSION_MAJOR = 1,
  102. MFX_DISPATCHER_VERSION_MINOR = 2
  103. };
  104. struct _mfxSession
  105. {
  106. // A real handle from MFX engine passed to a called function
  107. mfxSession session;
  108. mfxFunctionPointer callTable[eVideoFuncTotal];
  109. mfxFunctionPointer callPlugInsTable[ePluginFuncTotal];
  110. mfxFunctionPointer callAudioTable[eAudioFuncTotal];
  111. // Current library's implementation (exact implementation)
  112. mfxIMPL impl;
  113. };
  114. // declare a dispatcher's handle
  115. struct MFX_DISP_HANDLE : public _mfxSession
  116. {
  117. // Default constructor
  118. MFX_DISP_HANDLE(const mfxVersion requiredVersion);
  119. // Destructor
  120. ~MFX_DISP_HANDLE(void);
  121. // Load the library's module
  122. mfxStatus LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImplType implType, mfxIMPL impl, mfxIMPL implInterface, mfxInitParam &par);
  123. // Unload the library's module
  124. mfxStatus UnLoadSelectedDLL(void);
  125. // Close the handle
  126. mfxStatus Close(void);
  127. // NOTE: changing order of struct's members can make different version of
  128. // dispatchers incompatible. Think of different modules (e.g. MFT filters)
  129. // within a single application.
  130. // Library's implementation type (hardware or software)
  131. eMfxImplType implType;
  132. // Current library's VIA interface
  133. mfxIMPL implInterface;
  134. // Dispatcher's version. If version is 1.1 or lower, then old dispatcher's
  135. // architecture is used. Otherwise it means current dispatcher's version.
  136. mfxVersion dispVersion;
  137. // Required API version of session initialized
  138. const mfxVersion apiVersion;
  139. // Actual library API version
  140. mfxVersion actualApiVersion;
  141. // Status of loaded dll
  142. mfxStatus loadStatus;
  143. // Resgistry subkey name for windows version
  144. msdk_disp_char subkeyName[MFX_MAX_REGISTRY_KEY_NAME];
  145. // Storage ID for windows version
  146. int storageID;
  147. // Library's module handle
  148. mfxModuleHandle hModule;
  149. MFX::MFXPluginStorage pluginHive;
  150. MFX::MFXPluginFactory pluginFactory;
  151. private:
  152. // Declare assignment operator and copy constructor to prevent occasional assignment
  153. MFX_DISP_HANDLE(const MFX_DISP_HANDLE &);
  154. MFX_DISP_HANDLE & operator = (const MFX_DISP_HANDLE &);
  155. };
  156. // declare comparison operator
  157. inline
  158. bool operator == (const mfxVersion &one, const mfxVersion &two)
  159. {
  160. return (one.Version == two.Version);
  161. } // bool operator == (const mfxVersion &one, const mfxVersion &two)
  162. inline
  163. bool operator < (const mfxVersion &one, const mfxVersion &two)
  164. {
  165. return (one.Major == two.Major) && (one.Minor < two.Minor);
  166. } // bool operator < (const mfxVersion &one, const mfxVersion &two)
  167. inline
  168. bool operator <= (const mfxVersion &one, const mfxVersion &two)
  169. {
  170. return (one == two) || (one < two);
  171. } // bool operator <= (const mfxVersion &one, const mfxVersion &two)
  172. //
  173. // declare a table with functions descriptions
  174. //
  175. typedef
  176. struct FUNCTION_DESCRIPTION
  177. {
  178. // Literal function's name
  179. const char *pName;
  180. // API version when function appeared first time
  181. mfxVersion apiVersion;
  182. } FUNCTION_DESCRIPTION;
  183. extern const
  184. FUNCTION_DESCRIPTION APIFunc[eVideoFuncTotal];
  185. extern const
  186. FUNCTION_DESCRIPTION APIAudioFunc[eAudioFuncTotal];
  187. #endif // __MFX_DISPATCHER_H