Add public options for setting a log callback

This commit is contained in:
Martin Storsjö 2014-06-10 15:09:30 +03:00
parent dc91e0958b
commit 090229f8a1
3 changed files with 35 additions and 3 deletions

View File

@ -93,7 +93,9 @@ typedef enum {
ENCODER_OPTION_CURRENT_PATH,
ENCODER_OPTION_DUMP_FILE,
ENCODER_OPTION_TRACE_LEVEL
ENCODER_OPTION_TRACE_LEVEL,
ENCODER_OPTION_TRACE_CALLBACK, // a void (*)(void* context, int level, const char* message) function which receives log messages
ENCODER_OPTION_TRACE_CALLBACK_CONTEXT,
} ENCODER_OPTION;
/* Option types introduced in decoder application */
@ -108,6 +110,8 @@ typedef enum {
DECODER_OPTION_LTR_MARKED_FRAME_NUM, // feedback frame num marked by current Frame
DECODER_OPTION_ERROR_CON_IDC, //not finished yet, indicate decoder error concealment status, in progress
DECODER_OPTION_TRACE_LEVEL,
DECODER_OPTION_TRACE_CALLBACK, // a void (*)(void* context, int level, const char* message) function which receives log messages
DECODER_OPTION_TRACE_CALLBACK_CONTEXT,
} DECODER_OPTION;

View File

@ -242,7 +242,8 @@ void CWelsDecoder::InitDecoder (void) {
long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) {
int iVal = 0;
if (m_pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL)
if (m_pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL &&
eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT)
return dsInitialOptExpected;
if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame
@ -274,6 +275,18 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) {
m_pWelsTrace->SetTraceLevel (level);
}
return cmResultSuccess;
} else if (eOptID == DECODER_OPTION_TRACE_CALLBACK) {
if (m_pWelsTrace) {
CM_WELS_TRACE callback = * ((CM_WELS_TRACE*)pOption);
m_pWelsTrace->SetTraceCallback (callback);
}
return cmResultSuccess;
} else if (eOptID == DECODER_OPTION_TRACE_CALLBACK_CONTEXT) {
if (m_pWelsTrace) {
void* ctx = * ((void**)pOption);
m_pWelsTrace->SetTraceCallbackContext (ctx);
}
return cmResultSuccess;
}
return cmInitParaError;

View File

@ -563,7 +563,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
return cmInitParaError;
}
if ((NULL == m_pEncContext || false == m_bInitialFlag) && eOptionId != ENCODER_OPTION_TRACE_LEVEL) {
if ((NULL == m_pEncContext || false == m_bInitialFlag) && eOptionId != ENCODER_OPTION_TRACE_LEVEL
&& eOptionId != ENCODER_OPTION_TRACE_CALLBACK && eOptionId != ENCODER_OPTION_TRACE_CALLBACK_CONTEXT) {
return cmInitExpected;
}
@ -871,6 +872,20 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
}
}
break;
case ENCODER_OPTION_TRACE_CALLBACK: {
if (m_pWelsTrace) {
CM_WELS_TRACE callback = * ((CM_WELS_TRACE*)pOption);
m_pWelsTrace->SetTraceCallback (callback);
}
}
break;
case ENCODER_OPTION_TRACE_CALLBACK_CONTEXT: {
if (m_pWelsTrace) {
void* ctx = * ((void**)pOption);
m_pWelsTrace->SetTraceCallbackContext (ctx);
}
}
break;
default:
return cmInitParaError;
}