From 306ed3c7f18a99e74d26738a9b1e3fd3209ef9bc Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Fri, 27 Jan 2012 08:35:55 +0100 Subject: [PATCH] Disabled NUTAG_AUTO100, Entering PROCEEDING state after sending INVITE This also includes unfinished overlap dialing code. --- sip.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++---- sip.h | 1 + 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/sip.cpp b/sip.cpp index 20e4ece..cd03566 100644 --- a/sip.cpp +++ b/sip.cpp @@ -15,6 +15,8 @@ #include #include +#undef NUTAG_AUTO100 + unsigned char flip[256]; //pthread_mutex_t mutex_msg; @@ -851,6 +853,7 @@ int Psip::message_setup(unsigned int epoint_id, int message_id, union parameter struct in_addr ia; struct epoint_list *epointlist; sip_cseq_t *cseq = NULL; + struct lcr_msg *message; PDEBUG(DEBUG_SIP, "Doing Setup (inst %p)\n", inst); @@ -873,8 +876,6 @@ int Psip::message_setup(unsigned int epoint_id, int message_id, union parameter /* open local RTP peer (if not bridging) */ if (rtp_open() < 0) { - struct lcr_msg *message; - PERROR("Failed to open RTP sockets\n"); /* send release message to endpoit */ message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE); @@ -897,8 +898,6 @@ int Psip::message_setup(unsigned int epoint_id, int message_id, union parameter p_s_handle = nua_handle(inst->nua, NULL, TAG_END()); if (!p_s_handle) { - struct lcr_msg *message; - PERROR("Failed to create handle\n"); /* send release message to endpoit */ message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE); @@ -942,6 +941,18 @@ int Psip::message_setup(unsigned int epoint_id, int message_id, union parameter SIPTAG_PAYLOAD_STR(sdp_str), TAG_END()); new_state(PORT_STATE_OUT_SETUP); +#if 0 + PDEBUG(DEBUG_SIP, "do overlap\n"); + new_state(PORT_STATE_OUT_OVERLAP); + message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_OVERLAP); + message_put(message); +#else + PDEBUG(DEBUG_SIP, "do overlap\n"); + new_state(PORT_STATE_OUT_PROCEEDING); + message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_PROCEEDING); + message_put(message); +#endif + /* attach only if not already */ epointlist = p_epointlist; while(epointlist) { @@ -1026,6 +1037,26 @@ int Psip::message_dtmf(unsigned int epoint_id, int message_id, union parameter * return 0; } +/* NOTE: incomplete and not working */ +int Psip::message_information(unsigned int epoint_id, int message_id, union parameter *param) +{ + char dtmf_str[64]; + + /* prepare DTMF info payload */ + SPRINT(dtmf_str, + "Signal=%s\n" + "Duration=160\n" + , param->information.id); + + /* start invite to handle DTMF */ + nua_info(p_s_handle, + NUTAG_MEDIA_ENABLE(0), + SIPTAG_CONTENT_TYPE_STR("application/dtmf-relay"), + SIPTAG_PAYLOAD_STR(dtmf_str), TAG_END()); + + return 0; +} + int Psip::message_epoint(unsigned int epoint_id, int message_id, union parameter *param) { if (Port::message_epoint(epoint_id, message_id, param)) @@ -1060,6 +1091,12 @@ int Psip::message_epoint(unsigned int epoint_id, int message_id, union parameter message_setup(epoint_id, message_id, param); return 1; + case MESSAGE_INFORMATION: /* overlap dialing */ + if (p_state != PORT_STATE_OUT_OVERLAP) + return 0; + message_information(epoint_id, message_id, param); + return 1; + case MESSAGE_DTMF: /* DTMF info to be transmitted via INFO transaction */ if (p_state == PORT_STATE_CONNECT) message_dtmf(epoint_id, message_id, param); @@ -1425,10 +1462,12 @@ void Psip::r_invite(int status, char const *phrase, nua_t *nua, nua_magic_t *mag /* process 1xx */ switch (status) { case 100: +#ifdef NUTAG_AUTO100 PDEBUG(DEBUG_SIP, "do proceeding\n"); new_state(PORT_STATE_OUT_PROCEEDING); message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING); message_put(message); +#endif return; case 180: PDEBUG(DEBUG_SIP, "do alerting\n"); @@ -1645,7 +1684,9 @@ int sip_init_inst(struct interface *interface) NUTAG_APPL_METHOD("NOTIFY"), NUTAG_APPL_METHOD("INFO"), NUTAG_AUTOACK(0), +#ifdef NUTAG_AUTO100 NUTAG_AUTO100(0), +#endif NUTAG_AUTOALERT(0), NUTAG_AUTOANSWER(0), TAG_NULL()); diff --git a/sip.h b/sip.h index 2cfc62d..8fd420b 100644 --- a/sip.h +++ b/sip.h @@ -22,6 +22,7 @@ class Psip : public Port int message_release(unsigned int epoint_id, int message, union parameter *param); int message_setup(unsigned int epoint_id, int message, union parameter *param); int message_notify(unsigned int epoint_id, int message, union parameter *param); + int message_information(unsigned int epoint_id, int message, union parameter *param); int message_dtmf(unsigned int epoint_id, int message, union parameter *param); void i_invite(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]); void i_bye(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]); -- 2.13.6