MT#56321 core: introduce 'global_defs.h' header

Introduce a new header file "global_defs.h" in order to use that
for global definitions or macroses, which are not particularly
related to the SIP headers. Such as DSM applications names.

This will simplify handling and decrease hardcoding all around
the project.

With this commit additionally:
- stop hardcoding values related to DSM applications specific names
- move all the DSM definitions into the global_defs.h or defs.h

Change-Id: I389f632434f0ae1e62540e8df584fdc5e1e07e39
mr11.3.1
Donat Zenichev 4 years ago
parent 8195d1378d
commit 020cd18448

@ -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: <app-name>;early-announce=force',
similarly to the 200OK response, this will properly update the caller

@ -32,6 +32,8 @@
#include "AmUtils.h"
#include "AmRtpReceiver.h"
#include "global_defs.h"
#include <assert.h>
// helpers
@ -295,8 +297,8 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev)
/* ensure that 'P-DSM-App: <app-name>;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();

@ -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 */

@ -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

@ -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 ": "

Loading…
Cancel
Save