From cd233e18dd6374b63fe93e716b9e0ff00f94e351 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Thu, 16 Feb 2023 17:17:16 +0100 Subject: [PATCH] MT#56321 office-hours: catch the finish of the playback If we get the 480 reply from the office-hours DSM application, and there is a header 'P-DSM-App: office-hours' added, with a parameter ';playback=finished', then it means the following: - there was either AA or transfer involved into the call, before the call got to the DSM office-hours - caller remains in the hold state (so there was 200/ACK) - the office-hours playback has been finished, and now we mustn't forward 480 to the caller's leg, but just terminate it with BYE Change-Id: I389c6993185008c51c61bacd8eb23ac1562871b8 --- core/AmB2BSession.cpp | 23 +++++++++++++++++++++++ core/sip/defs.h | 1 + 2 files changed, 24 insertions(+) diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index 5c57df7c..3347e2ec 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -313,6 +313,29 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev) } } } + + /* processing of the playback completion from DSM applications */ + if (reply_ev->reply.code == 480 && dlg->getStatus() == AmSipDialog::Connected) { + + string p_dsm_app = getHeader(reply_ev->reply.hdrs, SIP_HDR_P_DSM_APP, true); + + /* TT#188800, if this is a completion of the playback of one of the DSM applications, + (office hours, play last caller, pre announce) + 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("play-last-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") { + 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(); + } + } + } } } return; diff --git a/core/sip/defs.h b/core/sip/defs.h index 4d8746df..f85b0f5a 100644 --- a/core/sip/defs.h +++ b/core/sip/defs.h @@ -55,6 +55,7 @@ #define SIP_HDR_SUBSCRIPTION_STATE "Subscription-State" #define SIP_HDR_REPLACES "Replaces" #define SIP_HDR_P_EARLY_ANNOUNCE "P-Early-Announce" +#define SIP_HDR_P_DSM_APP "P-DSM-App" #define SIP_HDR_COL(_hdr) _hdr ":" #define SIP_HDR_COLSP(_hdr) SIP_HDR_COL(_hdr) " "