openh264/codec/decoder/plus/inc/welsCodecTrace.h

160 lines
4.1 KiB
C
Raw Normal View History

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 {
typedef int (*CM_WELS_TRACE) (const char* kpFormat, ...);
2013-12-09 13:51:09 +01:00
typedef enum {
Wels_Trace_Type = 0,
Wels_Trace_Type_File = 1,
Wels_Trace_Type_WinDgb = 2,
2013-12-09 13:51:09 +01:00
} EWelsTraceType;
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
MAX_LOG_SIZE = 1024,
};
2013-12-09 13:51:09 +01:00
virtual ~IWelsTrace() {};
2013-12-09 13:51:09 +01:00
virtual int32_t SetTraceLevel (int32_t iLevel) = 0;
2014-02-08 22:28:42 +01:00
virtual int32_t Trace (const int32_t kLevel, const char* kpFormat, va_list pVl) = 0;
2013-12-09 13:51:09 +01:00
2014-02-08 22:28:42 +01:00
static void WelsTrace (void* pObject, const int32_t kLevel, const char* kpFormat, va_list pVl) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
2013-12-09 13:51:09 +01:00
if (pThis) {
pThis->Trace (kLevel, kpFormat, pVl);
}
}
2013-12-09 13:51:09 +01:00
2014-02-08 22:28:42 +01:00
static void WelsVTrace (void* pObject, const int32_t kLevel, const char* kpFormat, ...) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
2013-12-09 13:51:09 +01:00
va_list argptr;
2013-12-09 13:51:09 +01:00
va_start (argptr, kpFormat);
2013-12-09 13:51:09 +01:00
if (pThis) {
pThis->Trace (kLevel, kpFormat, argptr);
}
2013-12-09 13:51:09 +01:00
va_end (argptr);
}
2013-12-09 13:51:09 +01:00
};
class CWelsTraceBase : public IWelsTrace {
public:
virtual int32_t SetTraceLevel (int32_t iLevel);
2014-02-08 22:28:42 +01:00
virtual int32_t Trace (const int32_t kLevel, const char* kpFormat, va_list pVl);
2014-02-08 22:28:42 +01:00
virtual int32_t WriteString (int32_t iLevel, const char* pStr) = 0;
protected:
CWelsTraceBase() {
m_iLevel = WELS_LOG_DEFAULT;
2013-12-09 13:51:09 +01:00
};
private:
int32_t m_iLevel;
};
2013-12-09 13:51:09 +01:00
class CWelsTraceFile : public CWelsTraceBase {
public:
2014-02-08 22:28:42 +01:00
CWelsTraceFile (const char* filename = (const char*)"wels_decoder_trace.txt");
virtual ~CWelsTraceFile();
2013-12-09 13:51:09 +01:00
public:
2014-02-08 22:28:42 +01:00
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
private:
WelsFileHandle* m_pTraceFile;
2013-12-09 13:51:09 +01:00
};
#ifdef _WIN32
class CWelsTraceWinDgb : public CWelsTraceBase {
public:
CWelsTraceWinDgb() {};
virtual ~CWelsTraceWinDgb() {};
public:
2014-02-08 22:28:42 +01:00
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
2013-12-09 13:51:09 +01:00
};
#endif
class CWelsCodecTrace : public CWelsTraceBase {
public:
CWelsCodecTrace() ;
virtual ~CWelsCodecTrace();
2013-12-09 13:51:09 +01:00
public:
2014-02-08 22:28:42 +01:00
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
2013-12-09 13:51:09 +01:00
protected:
int32_t LoadWelsTraceModule();
int32_t UnloadWelsTraceModule();
2013-12-09 13:51:09 +01:00
private:
2013-12-09 13:51:09 +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
};
IWelsTrace* CreateWelsTrace (EWelsTraceType eType, void* pParam = NULL);
2013-12-09 13:51:09 +01:00
} // namespace WelsDec
#endif //WELS_CODEC_TRACE