Trace.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. #ifndef AMF_Trace_h
  33. #define AMF_Trace_h
  34. #pragma once
  35. #include "Platform.h"
  36. #include "Result.h"
  37. #include "Surface.h"
  38. #include "AudioBuffer.h"
  39. #if defined(__cplusplus)
  40. namespace amf
  41. {
  42. #endif
  43. //----------------------------------------------------------------------------------------------
  44. // trace levels
  45. //----------------------------------------------------------------------------------------------
  46. #define AMF_TRACE_ERROR 0
  47. #define AMF_TRACE_WARNING 1
  48. #define AMF_TRACE_INFO 2 // default in sdk
  49. #define AMF_TRACE_DEBUG 3
  50. #define AMF_TRACE_TRACE 4
  51. #define AMF_TRACE_TEST 5
  52. #define AMF_TRACE_NOLOG 100
  53. //----------------------------------------------------------------------------------------------
  54. // available trace writers
  55. //----------------------------------------------------------------------------------------------
  56. #define AMF_TRACE_WRITER_CONSOLE L"Console"
  57. #define AMF_TRACE_WRITER_DEBUG_OUTPUT L"DebugOutput"
  58. #define AMF_TRACE_WRITER_FILE L"File"
  59. //----------------------------------------------------------------------------------------------
  60. // AMFTraceWriter interface - callback
  61. //----------------------------------------------------------------------------------------------
  62. #if defined(__cplusplus)
  63. class AMF_NO_VTABLE AMFTraceWriter
  64. {
  65. public:
  66. virtual void AMF_CDECL_CALL Write(const wchar_t* scope, const wchar_t* message) = 0;
  67. virtual void AMF_CDECL_CALL Flush() = 0;
  68. };
  69. #else // #if defined(__cplusplus)
  70. typedef struct AMFTraceWriter AMFTraceWriter;
  71. typedef struct AMFTraceWriterVtbl
  72. {
  73. // AMFTraceWriter interface
  74. void (AMF_CDECL_CALL *Write)(AMFTraceWriter* pThis, const wchar_t* scope, const wchar_t* message);
  75. void (AMF_CDECL_CALL *Flush)(AMFTraceWriter* pThis);
  76. } AMFTraceWriterVtbl;
  77. struct AMFTraceWriter
  78. {
  79. const AMFTraceWriterVtbl *pVtbl;
  80. };
  81. #endif // #if defined(__cplusplus)
  82. //----------------------------------------------------------------------------------------------
  83. // AMFTrace interface - singleton
  84. //----------------------------------------------------------------------------------------------
  85. #if defined(__cplusplus)
  86. class AMF_NO_VTABLE AMFTrace
  87. {
  88. public:
  89. virtual void AMF_STD_CALL TraceW(const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope,amf_int32 countArgs, const wchar_t* format, ...) = 0;
  90. virtual void AMF_STD_CALL Trace(const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope, const wchar_t* message, va_list* pArglist) = 0;
  91. virtual amf_int32 AMF_STD_CALL SetGlobalLevel(amf_int32 level) = 0;
  92. virtual amf_int32 AMF_STD_CALL GetGlobalLevel() = 0;
  93. virtual amf_bool AMF_STD_CALL EnableWriter(const wchar_t* writerID, bool enable) = 0;
  94. virtual amf_bool AMF_STD_CALL WriterEnabled(const wchar_t* writerID) = 0;
  95. virtual AMF_RESULT AMF_STD_CALL TraceEnableAsync(amf_bool enable) = 0;
  96. virtual AMF_RESULT AMF_STD_CALL TraceFlush() = 0;
  97. virtual AMF_RESULT AMF_STD_CALL SetPath(const wchar_t* path) = 0;
  98. virtual AMF_RESULT AMF_STD_CALL GetPath(wchar_t* path, amf_size* pSize) = 0;
  99. virtual amf_int32 AMF_STD_CALL SetWriterLevel(const wchar_t* writerID, amf_int32 level) = 0;
  100. virtual amf_int32 AMF_STD_CALL GetWriterLevel(const wchar_t* writerID) = 0;
  101. virtual amf_int32 AMF_STD_CALL SetWriterLevelForScope(const wchar_t* writerID, const wchar_t* scope, amf_int32 level) = 0;
  102. virtual amf_int32 AMF_STD_CALL GetWriterLevelForScope(const wchar_t* writerID, const wchar_t* scope) = 0;
  103. virtual amf_int32 AMF_STD_CALL GetIndentation() = 0;
  104. virtual void AMF_STD_CALL Indent(amf_int32 addIndent) = 0;
  105. virtual void AMF_STD_CALL RegisterWriter(const wchar_t* writerID, AMFTraceWriter* pWriter, amf_bool enable) = 0;
  106. virtual void AMF_STD_CALL UnregisterWriter(const wchar_t* writerID) = 0;
  107. virtual const wchar_t* AMF_STD_CALL GetResultText(AMF_RESULT res) = 0;
  108. virtual const wchar_t* AMF_STD_CALL SurfaceGetFormatName(const AMF_SURFACE_FORMAT eSurfaceFormat) = 0;
  109. virtual AMF_SURFACE_FORMAT AMF_STD_CALL SurfaceGetFormatByName(const wchar_t* name) = 0;
  110. virtual const wchar_t* AMF_STD_CALL GetMemoryTypeName(const AMF_MEMORY_TYPE memoryType) = 0;
  111. virtual AMF_MEMORY_TYPE AMF_STD_CALL GetMemoryTypeByName(const wchar_t* name) = 0;
  112. virtual const wchar_t* AMF_STD_CALL GetSampleFormatName(const AMF_AUDIO_FORMAT eFormat) = 0;
  113. virtual AMF_AUDIO_FORMAT AMF_STD_CALL GetSampleFormatByName(const wchar_t* name) = 0;
  114. };
  115. #else // #if defined(__cplusplus)
  116. typedef struct AMFTrace AMFTrace;
  117. typedef struct AMFTraceVtbl
  118. {
  119. // AMFTrace interface
  120. void (AMF_STD_CALL *TraceW)(AMFTrace* pThis, const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope,amf_int32 countArgs, const wchar_t* format, ...);
  121. void (AMF_STD_CALL *Trace)(AMFTrace* pThis, const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope, const wchar_t* message, va_list* pArglist);
  122. amf_int32 (AMF_STD_CALL *SetGlobalLevel)(AMFTrace* pThis, amf_int32 level);
  123. amf_int32 (AMF_STD_CALL *GetGlobalLevel)(AMFTrace* pThis);
  124. amf_bool (AMF_STD_CALL *EnableWriter)(AMFTrace* pThis, const wchar_t* writerID, amf_bool enable);
  125. amf_bool (AMF_STD_CALL *WriterEnabled)(AMFTrace* pThis, const wchar_t* writerID);
  126. AMF_RESULT (AMF_STD_CALL *TraceEnableAsync)(AMFTrace* pThis, amf_bool enable);
  127. AMF_RESULT (AMF_STD_CALL *TraceFlush)(AMFTrace* pThis);
  128. AMF_RESULT (AMF_STD_CALL *SetPath)(AMFTrace* pThis, const wchar_t* path);
  129. AMF_RESULT (AMF_STD_CALL *GetPath)(AMFTrace* pThis, wchar_t* path, amf_size* pSize);
  130. amf_int32 (AMF_STD_CALL *SetWriterLevel)(AMFTrace* pThis, const wchar_t* writerID, amf_int32 level);
  131. amf_int32 (AMF_STD_CALL *GetWriterLevel)(AMFTrace* pThis, const wchar_t* writerID);
  132. amf_int32 (AMF_STD_CALL *SetWriterLevelForScope)(AMFTrace* pThis, const wchar_t* writerID, const wchar_t* scope, amf_int32 level);
  133. amf_int32 (AMF_STD_CALL *GetWriterLevelForScope)(AMFTrace* pThis, const wchar_t* writerID, const wchar_t* scope);
  134. amf_int32 (AMF_STD_CALL *GetIndentation)(AMFTrace* pThis);
  135. void (AMF_STD_CALL *Indent)(AMFTrace* pThis, amf_int32 addIndent);
  136. void (AMF_STD_CALL *RegisterWriter)(AMFTrace* pThis, const wchar_t* writerID, AMFTraceWriter* pWriter, amf_bool enable);
  137. void (AMF_STD_CALL *UnregisterWriter)(AMFTrace* pThis, const wchar_t* writerID);
  138. const wchar_t* (AMF_STD_CALL *GetResultText)(AMFTrace* pThis, AMF_RESULT res);
  139. const wchar_t* (AMF_STD_CALL *SurfaceGetFormatName)(AMFTrace* pThis, const AMF_SURFACE_FORMAT eSurfaceFormat);
  140. AMF_SURFACE_FORMAT (AMF_STD_CALL *SurfaceGetFormatByName)(AMFTrace* pThis, const wchar_t* name);
  141. const wchar_t* (AMF_STD_CALL *GetMemoryTypeName)(AMFTrace* pThis, const AMF_MEMORY_TYPE memoryType);
  142. AMF_MEMORY_TYPE (AMF_STD_CALL *GetMemoryTypeByName)(AMFTrace* pThis, const wchar_t* name);
  143. const wchar_t* (AMF_STD_CALL *GetSampleFormatName)(AMFTrace* pThis, const AMF_AUDIO_FORMAT eFormat);
  144. AMF_AUDIO_FORMAT (AMF_STD_CALL *GetSampleFormatByName)(AMFTrace* pThis, const wchar_t* name);
  145. } AMFTraceVtbl;
  146. struct AMFTrace
  147. {
  148. const AMFTraceVtbl *pVtbl;
  149. };
  150. #endif
  151. #if defined(__cplusplus)
  152. }
  153. #endif
  154. #endif // AMF_Trace_h