From a28baa26f1f6166f447c961c945041f2ddbb65d0 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 21 Feb 2025 10:10:30 +0100 Subject: [PATCH] MT#61912 AmB2BSession: move `established_body` to dlg level Move it to the dlg level, because of complex visibility. In other words, when working on the dialog level and e.g. generating new SDP body using `dlg.oa`, there is no way to save it. Moving it to the dlg level, gives a control over it on the whole amount of inheritance levels plus dlg. Change-Id: Iebb13e3e58f2558dc060e23270d99d690fa54572 --- apps/sbc/CallLeg.cpp | 10 +++++----- apps/sbc/CallLeg.h | 4 ++-- apps/sbc/SBCCallLeg.cpp | 2 +- core/AmB2BSession.cpp | 8 ++++---- core/AmB2BSession.h | 2 -- core/AmSipDialog.h | 6 ++++++ 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/apps/sbc/CallLeg.cpp b/apps/sbc/CallLeg.cpp index e50e4f7a..9e969cdd 100644 --- a/apps/sbc/CallLeg.cpp +++ b/apps/sbc/CallLeg.cpp @@ -1018,7 +1018,7 @@ int CallLeg::resumeHeldImpl() updateLocalSdp(sdp); updateLocalSdpOrigin(sdp); - AmMimeBody body(established_body); + AmMimeBody body(dlg->established_body); sdp2body(sdp, body); if (dlg->reinvite("", &body, SIP_FLAGS_VERBATIM) != 0) { ERROR("re-INVITE failed\n"); @@ -1500,16 +1500,16 @@ void CallLeg::addCallee(CallLeg *callee, const string &hdrs) { if (!non_hold_sdp.media.empty()) { // use non-hold SDP if possible - AmMimeBody body(established_body); + AmMimeBody body(dlg->established_body); sdp2body(non_hold_sdp, body); addNewCallee(callee, new ConnectLegEvent(hdrs, body)); } - else addNewCallee(callee, new ConnectLegEvent(hdrs, established_body)); + else addNewCallee(callee, new ConnectLegEvent(hdrs, dlg->established_body)); } /*void CallLeg::addCallee(CallLeg *callee, const string &hdrs, AmB2BSession::RTPRelayMode mode) { - addNewCallee(callee, new ConnectLegEvent(hdrs, established_body), mode); + addNewCallee(callee, new ConnectLegEvent(hdrs, dlg->established_body), mode); }*/ void CallLeg::replaceExistingLeg(const string &session_tag, const AmSipRequest &relayed_invite) @@ -1554,7 +1554,7 @@ void CallLeg::replaceExistingLeg(const string &session_tag, const string &hdrs) } else b.media_session = NULL; - ReconnectLegEvent *rev = new ReconnectLegEvent(a_leg ? ReconnectLegEvent::B : ReconnectLegEvent::A, getLocalTag(), hdrs, established_body); + ReconnectLegEvent *rev = new ReconnectLegEvent(a_leg ? ReconnectLegEvent::B : ReconnectLegEvent::A, getLocalTag(), hdrs, dlg->established_body); rev->setMedia(b.media_session, rtp_relay_mode); ReplaceLegEvent *ev = new ReplaceLegEvent(getLocalTag(), rev); // TODO: what about the RTP relay and other settings? send them as well? diff --git a/apps/sbc/CallLeg.h b/apps/sbc/CallLeg.h index f42e8808..a86f0067 100644 --- a/apps/sbc/CallLeg.h +++ b/apps/sbc/CallLeg.h @@ -383,7 +383,7 @@ class CallLeg: public AmB2BSession /** add given already existing session as our B leg */ void addCallee(const string &session_tag, const AmSipRequest &relayed_invite); void addCallee(const string &session_tag, const string &hdrs) - { addExistingCallee(session_tag, new ReconnectLegEvent(a_leg ? ReconnectLegEvent::B : ReconnectLegEvent::A, getLocalTag(), hdrs, established_body)); } + { addExistingCallee(session_tag, new ReconnectLegEvent(a_leg ? ReconnectLegEvent::B : ReconnectLegEvent::A, getLocalTag(), hdrs, dlg->established_body)); } /** add given call leg as our B leg (only stored SDP is used, we don't need * to have INVITE request. @@ -391,7 +391,7 @@ class CallLeg: public AmB2BSession * Additional headers may be specified - these are used in outgoing INVITE * to the callee's destination. */ void addCallee(CallLeg *callee, const string &hdrs); -// void addCallee(CallLeg *callee, const string &hdrs, AmB2BSession::RTPRelayMode mode) { addNewCallee(callee, new ConnectLegEvent(hdrs, established_body), mode); } +// void addCallee(CallLeg *callee, const string &hdrs, AmB2BSession::RTPRelayMode mode) { addNewCallee(callee, new ConnectLegEvent(hdrs, dlg->established_body), mode); } /** Replace given already existing session in a B2B call. We become new diff --git a/apps/sbc/SBCCallLeg.cpp b/apps/sbc/SBCCallLeg.cpp index 6bd2cabf..daab47e3 100644 --- a/apps/sbc/SBCCallLeg.cpp +++ b/apps/sbc/SBCCallLeg.cpp @@ -1824,7 +1824,7 @@ void SBCCallLeg::createHoldRequest(AmSdp &sdp) // FIXME: fix SDP versioning! (remember generated versions and increase the // version number in every SDP passing through?) - AmMimeBody *s = established_body.hasContentType(SIP_APPLICATION_SDP); + AmMimeBody *s = dlg->established_body.hasContentType(SIP_APPLICATION_SDP); if (s) sdp.parse((const char*)s->getPayload()); if (sdp.media.empty()) { diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index bf2da92f..680499d7 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -933,7 +933,7 @@ bool AmB2BSession::saveSessionDescription(const AmMimeBody& body) { DBG("saving session description (%s, %.*s...)\n", sdp_body->getCTStr().c_str(), 50, sdp_body->getPayload()); - established_body = *sdp_body; + dlg->established_body = *sdp_body; const char* cmp_body_begin = (const char*)sdp_body->getPayload(); size_t cmp_body_length = sdp_body->getLen(); @@ -982,7 +982,7 @@ bool AmB2BSession::updateSessionDescription(const AmMimeBody& body) { DBG("session description changed - saving (%s, %.*s...)\n", sdp_body->getCTStr().c_str(), 50, sdp_body->getPayload()); body_hash = new_body_hash; - established_body = body; + dlg->established_body = body; return true; } @@ -990,7 +990,7 @@ bool AmB2BSession::updateSessionDescription(const AmMimeBody& body) { } int AmB2BSession::sendEstablishedReInvite(const std::string &hdrs) { - if (established_body.empty()) { + if (dlg->established_body.empty()) { ERROR("trying to re-INVITE with saved description, but none saved\n"); return -1; } @@ -998,7 +998,7 @@ int AmB2BSession::sendEstablishedReInvite(const std::string &hdrs) { DBG("sending re-INVITE with saved session description\n"); try { - AmMimeBody body(established_body); // contains only SDP + AmMimeBody body(dlg->established_body); // contains only SDP updateLocalBody(body); return dlg->reinvite(hdrs, &body, SIP_FLAGS_VERBATIM); } catch (const string& s) { diff --git a/core/AmB2BSession.h b/core/AmB2BSession.h index 8c6c3322..542193c9 100644 --- a/core/AmB2BSession.h +++ b/core/AmB2BSession.h @@ -191,8 +191,6 @@ private: /** SUBSCRIBE/NOTIFY handling */ AmSipSubscription* subs; - /** body of established session */ - AmMimeBody established_body; /** hash of body (from o-line) */ uint32_t body_hash; /** save current session description (SDP) */ diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h index c90912dc..559f29ac 100644 --- a/core/AmSipDialog.h +++ b/core/AmSipDialog.h @@ -56,6 +56,12 @@ protected: AmOfferAnswer oa; bool offeranswer_enabled; +public: + /** body of established session */ + AmMimeBody established_body; + +protected: + // Reliable provisional reply support Am100rel rel100;