From 9dba3068374f64ed244510860ef082189d0d3feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Thu, 19 Mar 2015 15:42:09 -0400 Subject: [PATCH] signal the client of peer holding Refs #68897 Change-Id: Idf8176533f19a8bee266684adc71e829ed88a46c --- daemon/bin/dbus/callmanager-introspec.xml | 7 +++++++ daemon/bin/dbus/dbusclient.cpp | 1 + daemon/src/account.cpp | 3 --- daemon/src/account.h | 3 --- daemon/src/client/signal.cpp | 1 + daemon/src/dring/call_const.h | 1 + daemon/src/dring/callmanager_interface.h | 4 ++++ daemon/src/sip/sdp.cpp | 4 ++-- daemon/src/sip/sipaccount.cpp | 2 +- daemon/src/sip/sipcall.cpp | 10 ++++++++++ daemon/src/sip/sipcall.h | 1 + daemon/src/string_utils.h | 3 +++ 12 files changed, 31 insertions(+), 9 deletions(-) diff --git a/daemon/bin/dbus/callmanager-introspec.xml b/daemon/bin/dbus/callmanager-introspec.xml index 0e67423012..912b2c3da4 100644 --- a/daemon/bin/dbus/callmanager-introspec.xml +++ b/daemon/bin/dbus/callmanager-introspec.xml @@ -792,5 +792,12 @@ </tp:docstring> </arg> </signal> + + <signal name="peerHold" tp:name-for-bindings="peerHold"> + <tp:added version="2.0.0"/> + <arg type="s" name="callID" /> + <arg type="b" name="peerHolding" /> + </signal> + </interface> </node> diff --git a/daemon/bin/dbus/dbusclient.cpp b/daemon/bin/dbus/dbusclient.cpp index a046aecdd2..268e332037 100644 --- a/daemon/bin/dbus/dbusclient.cpp +++ b/daemon/bin/dbus/dbusclient.cpp @@ -174,6 +174,7 @@ DBusClient::initLibrary(int sflphFlags) exportable_callback<CallSignal::ZrtpNotSuppOther>(bind(&DBusCallManager::zrtpNotSuppOther, callM, _1)), exportable_callback<CallSignal::ZrtpNegotiationFailed>(bind(&DBusCallManager::zrtpNegotiationFailed, callM, _1, _2, _3)), exportable_callback<CallSignal::RtcpReportReceived>(bind(&DBusCallManager::onRtcpReportReceived, callM, _1, _2)), + exportable_callback<CallSignal::PeerHold>(bind(&DBusCallManager::peerHold, callM, _1, _2)) }; // Configuration event handlers diff --git a/daemon/src/account.cpp b/daemon/src/account.cpp index 2b8c16bb91..b042077de4 100644 --- a/daemon/src/account.cpp +++ b/daemon/src/account.cpp @@ -87,9 +87,6 @@ const char * const Account::HAS_CUSTOM_USER_AGENT_KEY = "hasCustomUserAgent"; const char * const Account::PRESENCE_MODULE_ENABLED_KEY = "presenceModuleEnabled"; const char * const Account::UPNP_ENABLED_KEY = "upnpEnabled"; -constexpr const char* Account::TRUE_STR; -constexpr const char* Account::FALSE_STR; - Account::Account(const std::string &accountID) : accountID_(accountID) , username_() diff --git a/daemon/src/account.h b/daemon/src/account.h index 7656b37952..6f82021472 100644 --- a/daemon/src/account.h +++ b/daemon/src/account.h @@ -86,9 +86,6 @@ class VoipLinkException : public std::runtime_error class Account : public Serializable, public std::enable_shared_from_this<Account> { public: - constexpr static const char* TRUE_STR = "true"; - constexpr static const char* FALSE_STR = "false"; - Account(const std::string& accountID); /** diff --git a/daemon/src/client/signal.cpp b/daemon/src/client/signal.cpp index 5f74e8d7c1..ae5e99a988 100644 --- a/daemon/src/client/signal.cpp +++ b/daemon/src/client/signal.cpp @@ -60,6 +60,7 @@ getSignalHandlers() exported_callback<DRing::CallSignal::ZrtpNotSuppOther>(), exported_callback<DRing::CallSignal::ZrtpNegotiationFailed>(), exported_callback<DRing::CallSignal::RtcpReportReceived>(), + exported_callback<DRing::CallSignal::PeerHold>(), /* Configuration */ exported_callback<DRing::ConfigurationSignal::VolumeChanged>(), diff --git a/daemon/src/dring/call_const.h b/daemon/src/dring/call_const.h index a2026bd316..cf26a8b4e9 100644 --- a/daemon/src/dring/call_const.h +++ b/daemon/src/dring/call_const.h @@ -43,6 +43,7 @@ constexpr static char CALL_STATE [] = "CALL_STATE" ; constexpr static char CONF_ID [] = "CONF_ID" ; constexpr static char TIMESTAMP_START [] = "TIMESTAMP_START" ; constexpr static char ACCOUNTID [] = "ACCOUNTID" ; +constexpr static char PEER_HOLDING [] = "PEER_HOLDING" ; constexpr static char TLS_PEER_CERT [] = "TLS_PEER_CERT" ; constexpr static char TLS_CIPHER [] = "TLS_CIPHER" ; diff --git a/daemon/src/dring/callmanager_interface.h b/daemon/src/dring/callmanager_interface.h index 989be94a64..d24db1f6f2 100644 --- a/daemon/src/dring/callmanager_interface.h +++ b/daemon/src/dring/callmanager_interface.h @@ -198,6 +198,10 @@ struct CallSignal { constexpr static const char* name = "RtcpReportReceived"; using cb_type = void(const std::string&, const std::map<std::string, int>&); }; + struct PeerHold { + constexpr static const char* name = "PeerHold"; + using cb_type = void(const std::string&, bool); + }; }; } // namespace DRing diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index 1ca46c8e22..2075e74ab7 100644 --- a/daemon/src/sip/sdp.cpp +++ b/daemon/src/sip/sdp.cpp @@ -258,7 +258,7 @@ Sdp::setMediaDescriptorLines(bool audio, bool holding, sip_utils::KeyExchangePro addRTCPAttribute(med); // video has its own RTCP } - med->attr[med->attr_count++] = pjmedia_sdp_attr_create(memPool_.get(), holding ? (audio ? "recvonly" : "inactive") : "sendrecv", NULL); + med->attr[med->attr_count++] = pjmedia_sdp_attr_create(memPool_.get(), holding ? (audio ? "sendonly" : "inactive") : "sendrecv", NULL); if (kx == sip_utils::KeyExchangeProtocol::SDES) { if (pjmedia_sdp_media_add_attr(med, generateSdesAttribute()) != PJ_SUCCESS) @@ -586,7 +586,7 @@ Sdp::getMediaSlots(const pjmedia_sdp_session* session, bool remote) const descr.addr = std::string(conn->addr.ptr, conn->addr.slen); descr.addr.setPort(media->desc.port); - descr.holding = pjmedia_sdp_attr_find2(media->attr_count, media->attr, "recvonly", nullptr) + descr.holding = pjmedia_sdp_attr_find2(media->attr_count, media->attr, "sendonly", nullptr) || pjmedia_sdp_attr_find2(media->attr_count, media->attr, "inactive", nullptr); // get codecs infos diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index d7703763a4..9066aa9053 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -1751,7 +1751,7 @@ set_opt(const std::map<std::string, std::string> &details, const char *key, bool std::map<std::string, std::string>::const_iterator it = details.find(key); if (it != details.end()) - val = it->second == Account::TRUE_STR; + val = it->second == TRUE_STR; } static void diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp index 3dcb4cd9c0..dd42378293 100644 --- a/daemon/src/sip/sipcall.cpp +++ b/daemon/src/sip/sipcall.cpp @@ -42,6 +42,7 @@ #include "sdp.h" #include "manager.h" #include "array_size.h" +#include "string_utils.h" #include "upnp/upnp_control.h" #include "audio/audio_rtp_session.h" @@ -53,6 +54,7 @@ #endif #include "dring/call_const.h" +#include "client/signal.h" #ifdef RING_VIDEO #include "client/videomanager.h" @@ -775,6 +777,7 @@ SIPCall::startAllMedia() } auto slots = sdp_->getMediaSlots(); unsigned ice_comp_id = 0; + bool peer_holding {true}; for (const auto& slot : slots) { const auto& local = slot.first; @@ -805,6 +808,8 @@ SIPCall::startAllMedia() continue; } + peer_holding &= remote.holding; + if (isSecure() && (not local.crypto || not remote.crypto)) { RING_ERR("Can't perform secure call over insecure RTP transport"); continue; @@ -825,6 +830,10 @@ SIPCall::startAllMedia() } else rtp->start(); } + if (peerHolding_ != peer_holding) { + peerHolding_ = peer_holding; + emitSignal<DRing::CallSignal::PeerHold>(getCallId(), peerHolding_); + } } void @@ -928,6 +937,7 @@ std::map<std::string, std::string> SIPCall::getDetails() const { auto details = Call::getDetails(); + details.emplace(DRing::Call::Details::PEER_HOLDING, peerHolding_ ? TRUE_STR : FALSE_STR); if (transport_ and transport_->isSecure()) { const auto& tlsInfos = transport_->getTlsInfos(); auto cipher = pj_ssl_cipher_name(tlsInfos.cipher); diff --git a/daemon/src/sip/sipcall.h b/daemon/src/sip/sipcall.h index 27fcaafff3..36b76db139 100644 --- a/daemon/src/sip/sipcall.h +++ b/daemon/src/sip/sipcall.h @@ -243,6 +243,7 @@ class SIPCall : public Call * The SDP session */ std::unique_ptr<Sdp> sdp_; + bool peerHolding_ {false}; char contactBuffer_[PJSIP_MAX_URL_SIZE] {}; pj_str_t contactHeader_ {contactBuffer_, 0}; diff --git a/daemon/src/string_utils.h b/daemon/src/string_utils.h index 8f4daa6cdc..0e6bb3dcbd 100644 --- a/daemon/src/string_utils.h +++ b/daemon/src/string_utils.h @@ -41,6 +41,9 @@ namespace ring { +constexpr static const char* TRUE_STR = "true"; +constexpr static const char* FALSE_STR = "false"; + #ifdef __ANDROID__ template <typename T> -- GitLab