2013-12-09 13:51:09 +01:00
|
|
|
/*!
|
|
|
|
* \copy
|
|
|
|
* Copyright (c) 2013, Cisco Systems
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WELS_CODEC_TRACE
|
|
|
|
#define WELS_CODEC_TRACE
|
|
|
|
|
|
|
|
|
|
|
|
#include "typedefs.h"
|
|
|
|
|
|
|
|
//using namespace WelsDec;
|
|
|
|
namespace WelsDec {
|
|
|
|
|
|
|
|
#ifdef WIN32
|
2013-12-12 23:21:12 +01:00
|
|
|
typedef int (*CM_WELS_TRACE) (const char* kpFormat, ...);
|
2013-12-09 13:51:09 +01:00
|
|
|
#else
|
2013-12-12 23:21:12 +01:00
|
|
|
typedef int (*CM_WELS_TRACE) (const char* kpDllName, const char* kpFormat, ...);
|
2013-12-09 13:51:09 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
2013-12-12 23:21:12 +01:00
|
|
|
Wels_Trace_Type = 0,
|
|
|
|
Wels_Trace_Type_File = 1,
|
|
|
|
Wels_Trace_Type_WinDgb = 2,
|
2013-12-09 13:51:09 +01:00
|
|
|
} EWelsTraceType;
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
class IWelsTrace {
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
WELS_LOG_QUIET = 0,
|
|
|
|
WELS_LOG_ERROR = 1 << 0,
|
|
|
|
WELS_LOG_WARNING = 1 << 1,
|
|
|
|
WELS_LOG_INFO = 1 << 2,
|
|
|
|
WELS_LOG_DEBUG = 1 << 3,
|
|
|
|
WELS_LOG_RESV = 1 << 4,
|
|
|
|
WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG,
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
MAX_LOG_SIZE = 1024,
|
|
|
|
};
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
virtual ~IWelsTrace() {};
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
virtual int32_t SetTraceLevel (int32_t iLevel) = 0;
|
|
|
|
virtual int32_t Trace (const int32_t kLevel, const str_t* kpFormat, va_list pVl) = 0;
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
static void_t WelsTrace (void_t* pObject, const int32_t kLevel, const str_t* kpFormat, va_list pVl) {
|
|
|
|
IWelsTrace* pThis = (IWelsTrace*) (pObject);
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
if (pThis) {
|
|
|
|
pThis->Trace (kLevel, kpFormat, pVl);
|
|
|
|
}
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
static void_t WelsVTrace (void_t* pObject, const int32_t kLevel, const str_t* kpFormat, ...) {
|
|
|
|
IWelsTrace* pThis = (IWelsTrace*) (pObject);
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
va_list argptr;
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
va_start (argptr, kpFormat);
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
if (pThis) {
|
|
|
|
pThis->Trace (kLevel, kpFormat, argptr);
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
va_end (argptr);
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
class CWelsTraceBase : public IWelsTrace {
|
|
|
|
public:
|
|
|
|
virtual int32_t SetTraceLevel (int32_t iLevel);
|
|
|
|
virtual int32_t Trace (const int32_t kLevel, const str_t* kpFormat, va_list pVl);
|
|
|
|
|
|
|
|
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr) = 0;
|
|
|
|
protected:
|
|
|
|
CWelsTraceBase() {
|
|
|
|
m_iLevel = WELS_LOG_DEFAULT;
|
2013-12-09 13:51:09 +01:00
|
|
|
};
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
private:
|
|
|
|
int32_t m_iLevel;
|
|
|
|
};
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
class CWelsTraceFile : public CWelsTraceBase {
|
|
|
|
public:
|
|
|
|
CWelsTraceFile (const str_t* filename = (const str_t*)"wels_decoder_trace.txt");
|
|
|
|
virtual ~CWelsTraceFile();
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
public:
|
|
|
|
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
WelsFileHandle* m_pTraceFile;
|
2013-12-09 13:51:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef WIN32
|
2013-12-12 23:21:12 +01:00
|
|
|
class CWelsTraceWinDgb : public CWelsTraceBase {
|
|
|
|
public:
|
|
|
|
CWelsTraceWinDgb() {};
|
|
|
|
virtual ~CWelsTraceWinDgb() {};
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr);
|
2013-12-09 13:51:09 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
class CWelsCodecTrace : public CWelsTraceBase {
|
|
|
|
public:
|
|
|
|
CWelsCodecTrace() ;
|
|
|
|
virtual ~CWelsCodecTrace();
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
public:
|
|
|
|
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr);
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
protected:
|
|
|
|
int32_t LoadWelsTraceModule();
|
|
|
|
int32_t UnloadWelsTraceModule();
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
private:
|
|
|
|
void_t* m_hTraceHandle;
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
CM_WELS_TRACE m_fpDebugTrace;
|
|
|
|
CM_WELS_TRACE m_fpInfoTrace;
|
|
|
|
CM_WELS_TRACE m_fpWarnTrace;
|
|
|
|
CM_WELS_TRACE m_fpErrorTrace;
|
2013-12-09 13:51:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
IWelsTrace* CreateWelsTrace (EWelsTraceType eType, void_t* pParam = NULL);
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
} // namespace WelsDec
|
|
|
|
|
|
|
|
#endif //WELS_CODEC_TRACE
|