diff --git a/apps/sbc/CallLeg.cpp b/apps/sbc/CallLeg.cpp index f8e88e1c..b65ed4fb 100644 --- a/apps/sbc/CallLeg.cpp +++ b/apps/sbc/CallLeg.cpp @@ -33,6 +33,8 @@ #include "AmRtpReceiver.h" #include "SBCCallRegistry.h" +#include "global_defs.h" + #define TRACE DBG // helper functions @@ -553,8 +555,8 @@ void CallLeg::onInitialReply(B2BSipReplyEvent *e) /* 100-199 */ if (e->reply.code < 200) { string announce = getHeader(e->reply.hdrs, SIP_HDR_P_DSM_APP); - string p_dsm_app_param = get_header_param(announce, "early-announce"); - dlg->setForcedEarlyAnnounce(p_dsm_app_param == "force"); + string p_dsm_app_param = get_header_param(announce, DSM_PARAM_EARLY_AN); + dlg->setForcedEarlyAnnounce(p_dsm_app_param == DSM_VALUE_FORCE); /* exceptionally treat 183 with the 'P-DSM-App: ;early-announce=force', similarly to the 200OK response, this will properly update the caller diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index f4209590..25250772 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -32,6 +32,8 @@ #include "AmUtils.h" #include "AmRtpReceiver.h" +#include "global_defs.h" + #include // helpers @@ -295,8 +297,8 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev) /* ensure that 'P-DSM-App: ;early-announce=force' is not present */ if (reply_ev->reply.code == 183 && !dlg->getForcedEarlyAnnounce()) { string announce = getHeader(reply_ev->reply.hdrs, SIP_HDR_P_DSM_APP); - string p_dsm_app_param = get_header_param(announce, "early-announce"); - dlg->setForcedEarlyAnnounce(p_dsm_app_param == "force"); + string p_dsm_app_param = get_header_param(announce, DSM_PARAM_EARLY_AN); + dlg->setForcedEarlyAnnounce(p_dsm_app_param == DSM_VALUE_FORCE); } /* don't forget to reset the force_early_announce, if 200 OK in the same leg received */ @@ -335,7 +337,7 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev) if (dlg->getUACInvTransPending()) { DBG("changed session, but UAC INVITE trans pending\n"); } else { - DBG("Received 183 with <;early-announce=force>, refreshing media session.\n"); + DBG("Received 183 with <;%s=%s>, refreshing media session.\n", DSM_PARAM_EARLY_AN, DSM_VALUE_FORCE); setMute(true); AmMediaProcessor::instance()->removeSession(this); @@ -357,14 +359,14 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev) (office hours, play last caller, pre announce, early dbprompt) in the session, which has had AA or a transfer before going to this DSM application, then a caller is now likely in the connected state, and requires BYE, not 480 */ - if (p_dsm_app.find("office-hours") != std::string::npos || - p_dsm_app.find("pre-announce") != std::string::npos || - p_dsm_app.find("early-dbprompt") != std::string::npos || - p_dsm_app.find("play-last-caller") != std::string::npos) { + if (p_dsm_app.find(DSM_APP_OH) != std::string::npos || + p_dsm_app.find(DSM_APP_PRE_AN) != std::string::npos || + p_dsm_app.find(DSM_APP_EARLYDB_PR) != std::string::npos || + p_dsm_app.find(DSM_APP_P_L_CALLER) != std::string::npos) { /* check the ;playback= parameter */ - string p_dsm_app_param = get_header_param(p_dsm_app, "playback"); - if (p_dsm_app_param == "finished") { + string p_dsm_app_param = get_header_param(p_dsm_app, DSM_PARAM_PLAYBACK); + if (p_dsm_app_param == DSM_VALUE_FINISHED) { DBG("This is the end of DSM playback, the caller is in the connected state.\n"); DBG("Terminating the original leg with BYE, instead of 480.\n"); terminateLeg(); diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index 765c3c91..f0e5efb6 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -39,6 +39,8 @@ #include "AmB2BMedia.h" // just because of statistics +#include "global_defs.h" + static void addTranscoderStats(string &hdrs) { // add transcoder statistics into request/reply headers @@ -408,8 +410,8 @@ bool AmSipDialog::onRxReplyStatus(const AmSipReply& reply) if (reply.code < 200) { string announce = getHeader(reply.hdrs, SIP_HDR_P_DSM_APP, true); - string p_dsm_app_param = get_header_param(announce, "early-announce"); - setForcedEarlyAnnounce(p_dsm_app_param == "force"); + string p_dsm_app_param = get_header_param(announce, DSM_PARAM_EARLY_AN); + setForcedEarlyAnnounce(p_dsm_app_param == DSM_VALUE_FORCE); /* we should always keep Route set for this leg updated in case the provisional response updates the list of routes for any reason */ @@ -431,7 +433,7 @@ bool AmSipDialog::onRxReplyStatus(const AmSipReply& reply) - pre-announce - office-hours */ if (reply.code == 183 && !announce.empty() && getForcedEarlyAnnounce()) { - DBG("This is 183 with <;early-announce=force>, treated exceptionally as 200OK.\n"); + DBG("This is 183 with <;%s=%s>, treated exceptionally as 200OK.\n", DSM_PARAM_EARLY_AN, DSM_VALUE_FORCE); setStatus(Connected); setFaked183As200(true); /* remember that this is a faked 200OK, indeed 183 */ diff --git a/core/global_defs.h b/core/global_defs.h new file mode 100644 index 00000000..bd5407af --- /dev/null +++ b/core/global_defs.h @@ -0,0 +1,22 @@ +#ifndef _global_defs_h_ +#define _global_defs_h_ + +/** + * @brief Global definitions. + * + * Use this file only to #define global definitions + * or macroses, not specificially related to the content + * of the SIP message. + * + * If is related to the SIP message - then use core/sip/defs.h + */ + +/** + * DSM applications related block + */ +#define DSM_APP_OH "office-hours" +#define DSM_APP_PRE_AN "pre-announce" +#define DSM_APP_EARLYDB_PR "early-dbprompt" +#define DSM_APP_P_L_CALLER "play-last-caller" + +#endif diff --git a/core/sip/defs.h b/core/sip/defs.h index d1186d1c..35a51927 100644 --- a/core/sip/defs.h +++ b/core/sip/defs.h @@ -56,6 +56,12 @@ #define SIP_HDR_REPLACES "Replaces" #define SIP_HDR_P_DSM_APP "P-DSM-App" +#define DSM_PARAM_EARLY_AN "early-announce" +#define DSM_PARAM_PLAYBACK "playback" + +#define DSM_VALUE_FORCE "force" +#define DSM_VALUE_FINISHED "finished" + #define SIP_HDR_COL(_hdr) _hdr ":" #define SIP_HDR_COLSP(_hdr) SIP_HDR_COL(_hdr) " " #define COLSP ": "