diff --git a/codec/common/inc/logging.h b/codec/common/inc/logging.h index 1778c35c..91fda4b6 100644 --- a/codec/common/inc/logging.h +++ b/codec/common/inc/logging.h @@ -37,6 +37,6 @@ // Internal details. -int32_t welsStderrTrace (const char* string); +void welsStderrTrace (void* ctx, int level, const char* string); #endif diff --git a/codec/common/inc/welsCodecTrace.h b/codec/common/inc/welsCodecTrace.h index e559ee65..3802772d 100644 --- a/codec/common/inc/welsCodecTrace.h +++ b/codec/common/inc/welsCodecTrace.h @@ -37,7 +37,7 @@ #include "typedefs.h" #include "utils.h" -typedef int32_t (*CM_WELS_TRACE) (const char* string); +typedef void (*CM_WELS_TRACE) (void* ctx, int level, const char* string); class welsCodecTrace { public: @@ -45,6 +45,8 @@ class welsCodecTrace { ~welsCodecTrace(); void SetTraceLevel (const int32_t kiLevel); + void SetTraceCallback (CM_WELS_TRACE func); + void SetTraceCallbackContext (void* pCtx); private: static void StaticCodecTrace (void* pCtx, const int32_t kiLevel, const char* kpStrFormat, va_list vl); @@ -52,6 +54,7 @@ class welsCodecTrace { int32_t m_iTraceLevel; CM_WELS_TRACE m_fpTrace; + void* m_pTraceCtx; public: SLogContext m_sLogCtx; diff --git a/codec/common/src/logging.cpp b/codec/common/src/logging.cpp index 79a113b8..4528b395 100644 --- a/codec/common/src/logging.cpp +++ b/codec/common/src/logging.cpp @@ -35,7 +35,6 @@ #include #include "typedefs.h" -int32_t welsStderrTrace (const char* string) { +void welsStderrTrace (void* ctx, int level, const char* string) { fprintf (stderr, "%s", string); - return 0; } diff --git a/codec/common/src/welsCodecTrace.cpp b/codec/common/src/welsCodecTrace.cpp index ef78469f..d5bfa039 100644 --- a/codec/common/src/welsCodecTrace.cpp +++ b/codec/common/src/welsCodecTrace.cpp @@ -51,6 +51,7 @@ welsCodecTrace::welsCodecTrace() { m_iTraceLevel = WELS_LOG_DEFAULT; m_fpTrace = welsStderrTrace; + m_pTraceCtx = NULL; m_sLogCtx.pLogCtx = this; m_sLogCtx.pfLog = StaticCodecTrace; @@ -75,7 +76,7 @@ void welsCodecTrace::CodecTrace (const int32_t iLevel, const char* Str_Format, v char pBuf[MAX_LOG_SIZE] = {0}; WelsVsnprintf (pBuf, MAX_LOG_SIZE, Str_Format, vl); // confirmed_safe_unsafe_usage - m_fpTrace (pBuf); + m_fpTrace (m_pTraceCtx, iLevel, pBuf); } void welsCodecTrace::SetTraceLevel (const int32_t iLevel) { @@ -83,4 +84,11 @@ void welsCodecTrace::SetTraceLevel (const int32_t iLevel) { m_iTraceLevel = iLevel; } +void welsCodecTrace::SetTraceCallback (CM_WELS_TRACE func) { + m_fpTrace = func; +} + +void welsCodecTrace::SetTraceCallbackContext (void* ctx) { + m_pTraceCtx = ctx; +}