Capture.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // Notice Regarding Standards. AMD does not provide a license or sublicense to
  3. // any Intellectual Property Rights relating to any standards, including but not
  4. // limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
  5. // AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
  6. // (collectively, the "Media Technologies"). For clarity, you will pay any
  7. // royalties due for such third party technologies, which may include the Media
  8. // Technologies that are owed as a result of AMD providing the Software to you.
  9. //
  10. // MIT license
  11. //
  12. // Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining a copy
  15. // of this software and associated documentation files (the "Software"), to deal
  16. // in the Software without restriction, including without limitation the rights
  17. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18. // copies of the Software, and to permit persons to whom the Software is
  19. // furnished to do so, subject to the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be included in
  22. // all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  27. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  28. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  29. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  30. // THE SOFTWARE.
  31. //
  32. //-------------------------------------------------------------------------------------------------
  33. // Capture interface declaration
  34. //-------------------------------------------------------------------------------------------------
  35. #ifndef __Capture_h__
  36. #define __Capture_h__
  37. #pragma once
  38. #include "../../../public/include/components/Component.h"
  39. typedef enum AMF_CAPTURE_DEVICE_TYPE_ENUM
  40. {
  41. AMF_CAPTURE_DEVICE_UNKNOWN = 0,
  42. AMF_CAPTURE_DEVICE_MEDIAFOUNDATION = 1,
  43. AMF_CAPTURE_DEVICE_WASAPI = 2,
  44. AMF_CAPTURE_DEVICE_SDI = 3,
  45. AMF_CAPTURE_DEVICE_SCREEN_DUPLICATION = 4,
  46. } AMF_CAPTURE_DEVICE_TYPE_ENUM;
  47. // device properties
  48. #define AMF_CAPTURE_DEVICE_TYPE L"DeviceType" // amf_int64( AMF_CAPTURE_DEVICE_TYPE_ENUM )
  49. #define AMF_CAPTURE_DEVICE_NAME L"DeviceName" // wchar_t* : name of the device
  50. #if defined(__cplusplus)
  51. namespace amf
  52. {
  53. #endif
  54. //----------------------------------------------------------------------------------------------
  55. // AMFCaptureDevice interface
  56. //----------------------------------------------------------------------------------------------
  57. #if defined(__cplusplus)
  58. class AMF_NO_VTABLE AMFCaptureDevice : public AMFComponentEx
  59. {
  60. public:
  61. AMF_DECLARE_IID (0x5bfd1b17, 0x9f2a, 0x43c4, 0x9c, 0xdd, 0x2c, 0x3, 0x88, 0x43, 0xb5, 0xf3)
  62. virtual AMF_RESULT AMF_STD_CALL Start() = 0;
  63. virtual AMF_RESULT AMF_STD_CALL Stop() = 0;
  64. // TODO add callback interface for disconnected / lost / changed device notification
  65. };
  66. //----------------------------------------------------------------------------------------------
  67. // smart pointer
  68. //----------------------------------------------------------------------------------------------
  69. typedef AMFInterfacePtr_T<AMFCaptureDevice> AMFCaptureDevicePtr;
  70. //----------------------------------------------------------------------------------------------
  71. #else // #if defined(__cplusplus)
  72. AMF_DECLARE_IID(AMFCaptureDevice, 0x5bfd1b17, 0x9f2a, 0x43c4, 0x9c, 0xdd, 0x2c, 0x3, 0x88, 0x43, 0xb5, 0xf3)
  73. typedef struct AMFCaptureDeviceVtbl
  74. {
  75. // AMFInterface interface
  76. amf_long (AMF_STD_CALL *Acquire)(AMFCaptureDevice* pThis);
  77. amf_long (AMF_STD_CALL *Release)(AMFCaptureDevice* pThis);
  78. enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFCaptureDevice* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
  79. // AMFPropertyStorage interface
  80. AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFCaptureDevice* pThis, const wchar_t* name, AMFVariantStruct value);
  81. AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFCaptureDevice* pThis, const wchar_t* name, AMFVariantStruct* pValue);
  82. amf_bool (AMF_STD_CALL *HasProperty)(AMFCaptureDevice* pThis, const wchar_t* name);
  83. amf_size (AMF_STD_CALL *GetPropertyCount)(AMFCaptureDevice* pThis);
  84. AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFCaptureDevice* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
  85. AMF_RESULT (AMF_STD_CALL *Clear)(AMFCaptureDevice* pThis);
  86. AMF_RESULT (AMF_STD_CALL *AddTo)(AMFCaptureDevice* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
  87. AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFCaptureDevice* pThis, AMFPropertyStorage* pDest, amf_bool deep);
  88. void (AMF_STD_CALL *AddObserver)(AMFCaptureDevice* pThis, AMFPropertyStorageObserver* pObserver);
  89. void (AMF_STD_CALL *RemoveObserver)(AMFCaptureDevice* pThis, AMFPropertyStorageObserver* pObserver);
  90. // AMFPropertyStorageEx interface
  91. amf_size (AMF_STD_CALL *GetPropertiesInfoCount)(AMFCaptureDevice* pThis);
  92. AMF_RESULT (AMF_STD_CALL *GetPropertyInfoAt)(AMFCaptureDevice* pThis, amf_size index, const AMFPropertyInfo** ppInfo);
  93. AMF_RESULT (AMF_STD_CALL *GetPropertyInfo)(AMFCaptureDevice* pThis, const wchar_t* name, const AMFPropertyInfo** ppInfo);
  94. AMF_RESULT (AMF_STD_CALL *ValidateProperty)(AMFCaptureDevice* pThis, const wchar_t* name, AMFVariantStruct value, AMFVariantStruct* pOutValidated);
  95. // AMFComponent interface
  96. AMF_RESULT (AMF_STD_CALL *Init)(AMFCaptureDevice* pThis, AMF_SURFACE_FORMAT format,amf_int32 width,amf_int32 height);
  97. AMF_RESULT (AMF_STD_CALL *ReInit)(AMFCaptureDevice* pThis, amf_int32 width,amf_int32 height);
  98. AMF_RESULT (AMF_STD_CALL *Terminate)(AMFCaptureDevice* pThis);
  99. AMF_RESULT (AMF_STD_CALL *Drain)(AMFCaptureDevice* pThis);
  100. AMF_RESULT (AMF_STD_CALL *Flush)(AMFCaptureDevice* pThis);
  101. AMF_RESULT (AMF_STD_CALL *SubmitInput)(AMFCaptureDevice* pThis, AMFData* pData);
  102. AMF_RESULT (AMF_STD_CALL *QueryOutput)(AMFCaptureDevice* pThis, AMFData** ppData);
  103. AMFContext* (AMF_STD_CALL *GetContext)(AMFCaptureDevice* pThis);
  104. AMF_RESULT (AMF_STD_CALL *SetOutputDataAllocatorCB)(AMFCaptureDevice* pThis, AMFDataAllocatorCB* callback);
  105. AMF_RESULT (AMF_STD_CALL *GetCaps)(AMFCaptureDevice* pThis, AMFCaps** ppCaps);
  106. AMF_RESULT (AMF_STD_CALL *Optimize)(AMFCaptureDevice* pThis, AMFComponentOptimizationCallback* pCallback);
  107. // AMFComponentEx interface
  108. amf_int32 (AMF_STD_CALL *GetInputCount)(AMFCaptureDevice* pThis);
  109. amf_int32 (AMF_STD_CALL *GetOutputCount)(AMFCaptureDevice* pThis);
  110. AMF_RESULT (AMF_STD_CALL *GetInput)(AMFCaptureDevice* pThis, amf_int32 index, AMFInput** ppInput);
  111. AMF_RESULT (AMF_STD_CALL *GetOutput)(AMFCaptureDevice* pThis, amf_int32 index, AMFOutput** ppOutput);
  112. // AMFCaptureDevice interface
  113. AMF_RESULT (AMF_STD_CALL *Start)(AMFCaptureDevice* pThis);
  114. AMF_RESULT (AMF_STD_CALL *Stop)(AMFCaptureDevice* pThis);
  115. } AMFCaptureVtbl;
  116. struct AMFCapture
  117. {
  118. const AMFCaptureVtbl *pVtbl;
  119. };
  120. #endif // #if defined(__cplusplus)
  121. //----------------------------------------------------------------------------------------------
  122. // AMFCaptureManager interface
  123. //----------------------------------------------------------------------------------------------
  124. #if defined(__cplusplus)
  125. class AMF_NO_VTABLE AMFCaptureManager : public AMFInterface
  126. {
  127. public:
  128. AMF_DECLARE_IID ( 0xf64d2f0d, 0xad16, 0x4ce7, 0x80, 0x5f, 0xa1, 0xe7, 0x3b, 0x0, 0xf4, 0x28)
  129. virtual AMF_RESULT AMF_STD_CALL Update() = 0;
  130. virtual amf_int32 AMF_STD_CALL GetDeviceCount() = 0;
  131. virtual AMF_RESULT AMF_STD_CALL GetDevice(amf_int32 index,AMFCaptureDevice **pDevice) = 0;
  132. };
  133. //----------------------------------------------------------------------------------------------
  134. // smart pointer
  135. //----------------------------------------------------------------------------------------------
  136. typedef AMFInterfacePtr_T<AMFCaptureManager> AMFCaptureManagerPtr;
  137. //----------------------------------------------------------------------------------------------
  138. #else // #if defined(__cplusplus)
  139. AMF_DECLARE_IID(AMFCaptureManager, 0xf64d2f0d, 0xad16, 0x4ce7, 0x80, 0x5f, 0xa1, 0xe7, 0x3b, 0x0, 0xf4, 0x28)
  140. typedef struct AMFCaptureManagerVtbl
  141. {
  142. // AMFInterface interface
  143. amf_long (AMF_STD_CALL *Acquire)(AMFCaptureManager* pThis);
  144. amf_long (AMF_STD_CALL *Release)(AMFCaptureManager* pThis);
  145. enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFCaptureManager* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
  146. // AMFCaptureManager interface
  147. AMF_RESULT (AMF_STD_CALL *Update)((AMFCaptureManager* pThis);
  148. amf_int32 (AMF_STD_CALL *GetDeviceCount)(AMFCaptureManager* pThis);
  149. AMF_RESULT (AMF_STD_CALL *GetDevice)(AMFCaptureManager* pThis, amf_int32 index,AMFCaptureDevice **pDevice);
  150. } AMFCaptureManagerVtbl;
  151. struct AMFCaptureManager
  152. {
  153. const AMFCaptureManagerVtbl *pVtbl;
  154. };
  155. #endif // #if defined(__cplusplus)
  156. #if defined(__cplusplus)
  157. } // namespace
  158. #endif
  159. extern "C"
  160. {
  161. AMF_RESULT AMF_CDECL_CALL AMFCreateCaptureManager(amf::AMFContext* pContext, amf::AMFCaptureManager** ppManager);
  162. }
  163. #endif // __Capture_h__