2015-10-03 81 views
0

我正在用PJSIP製作我自己的應用程序,而PJ_LOG不起作用(調用作品)。PJSIP不記錄(Android)

代碼在下方,請幫助! 謝謝!

status = pjsua_create(); 
if (status != PJ_SUCCESS) error_exit("Error in pjsua_create()", status); 
/* Init pjsua */ 
{ 
pjsua_config cfg; 
pjsua_logging_config log_cfg; 

pjsua_config_default(&cfg); 
pjsua_logging_config_default(&log_cfg); 
cfg.cb.on_incoming_call = &on_incoming_call; 
cfg.cb.on_call_media_state = &on_call_media_state; 
cfg.cb.on_call_state = &on_call_state; 

__android_log_print(ANDROID_LOG_DEBUG,"INIT","PJ_LOG_MAX_LEVEL %d", PJ_LOG_MAX_LEVEL); //PRINT 5!!! 

status = pjsua_init(&cfg, &log_cfg, 0); 

if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status); 
} 
__android_log_print(ANDROID_LOG_DEBUG,"INIT","PJ_LOG_MAX_LEVEL %d", PJ_LOG_MAX_LEVEL);//PRINT 5!!! 

PJ_LOG(1,(THIS_FILE, "Trying log %d", 1));//NOT PRINTING 
PJ_LOG(2,(THIS_FILE, "Trying log %d", 2)); 
PJ_LOG(3,(THIS_FILE, "Trying log %d", 3)); 
PJ_LOG(4,(THIS_FILE, "Trying log %d", 4)); 
+0

你可以幫我編譯PJSIP –

回答

0

您遇到的問題是使用不同的日誌工具(android和pjsip)。對於android,您只能使用__android_log_print。沒有其他作品。但趕上PJSIP日誌輸出可以選擇覆蓋PJSIP日誌寫:

#include <android/log.h> 

extern "C" { 
    static void log_writer(int level, const char *data, int len) 
    { 
     __android_log_write(ANDROID_LOG_INFO, "pjsua", data); 
    } 
} 

/** Callback wrapper **/ 
static void on_cli_config(pjsua_app_config *cfg) 
{ 
    pjsua_cb_orig = cfg->cfg.cb; 
    cfg->log_cfg.cb = &log_writer; 

    /* Override pjsua callback, e.g: to install renderer view */ 
    cfg->cfg.cb.on_call_media_state = &on_call_media_state; 
} 

你可以發現這個例子與pjsua來源:pjsip-apps\src\pjsua\android\jni\pjsua_app_callback.cpp

+0

DenisKolodin - 謝謝你! – Nir