#include "pjsip_event_notification.h"
#include <pjsip.h>
#include <pjsip_ua.h>
#include <pjlib-util.h>
#include <pjlib.h>
#include <pjlib.h>
#include <pjsua.h>
#include <pjsua-lib/pjsua_internal.h>
static EventCallBack* registeredCallbackObject = NULL;
extern "C" {
pj_bool_t on_rx_response_wrapper(pjsip_rx_data *rdata){
registeredCallbackObject->on_rx_response(rdata);
return PJ_FALSE;
}
pj_bool_t on_rx_request_wrapper(pjsip_rx_data *rdata){
registeredCallbackObject->on_rx_request(rdata);
return PJ_FALSE;
}
/* The module instance. */
static pjsip_module mod_event_handler =
{
NULL, NULL, /* prev, next. */
{ (char*)"mod-reg-event", 12 }, /* Name. */
-1, /* Id */
PJSIP_MOD_PRIORITY_TSX_LAYER - 1, /* Priority */
NULL, /* load() */
NULL, /* start() */
NULL, /* stop() */
NULL, /* unload() */
&on_rx_response_wrapper, /* on_rx_request() */
&on_rx_response_wrapper, /* on_rx_response() */
NULL, /* on_tx_request. */
NULL, /* on_tx_response() */
NULL, /* on_tsx_state() */
};
PJ_DECL(pj_status_t) event_callback_init() {
return pjsip_endpt_register_module(pjsua_get_pjsip_endpt(),
&mod_event_handler);
}
void setEventCallbackObject(EventCallBack* eventCallBack){
registeredCallbackObject=eventCallBack;
}
}
同じpjsip_event_notification.hのhファイル
#include <pj/config_site.h>
#include <pjsua-lib/pjsua.h>
class EventCallBack {
public:
virtual ~EventCallBack() {}
virtual void on_rx_response(pjsip_rx_data *rdata){
// Target Call Back for Notify message
}
virtual void on_rx_request(pjsip_rx_data *rdata){
}
};
extern "C" {
pj_status_t event_callback_init();
void setEventCallbackObject(EventCallBack* eventCallBack);
}