Commit a031c92d authored by Hugo Lefeuvre's avatar Hugo Lefeuvre Committed by Philippe Gorley

call management: add PEER_BUSY status

There is currently no distinction between the "peer busy" and "we
replied busy after timeout" states, since both end in the BUSY state.

Add a new PEER_BUSY state allowing such a distinction:
* PEER_BUSY is set when peer replied busy
* BUSY is set when we replied busy to an incoming call

Bump daemon API number to major 7.0.0 since this is breaking the
current API. In fact, these changes should not break anything in
any well implemented client because unknown states should be properly
handled, but better check.

Change-Id: Id83f6db3d4524a91951b9945797f5fd2c019ff2f
Reviewed-by: Sébastien Blin's avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent 114c6644
......@@ -568,7 +568,8 @@
<li>RINGING: Initial state of received outgoing call</li>
<li>CURRENT: The normal active state of an answered call</li>
<li>HUNGUP: Notify that the call has been hungup by peer</li>
<li>BUSY</li>
<li>BUSY: Notify that we terminated an incoming call after timeout</li>
<li>PEER_BUSY: Notify that peer replied BUSY to this call</li>
<li>FAILURE: Error when processing a call</li>
<li>HOLD</li>
<li>UNHOLD</li>
......
......@@ -2,7 +2,7 @@ dnl Ring - configure.ac for automake 1.9 and autoconf 2.59
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([Ring Daemon],[6.1.0],[ring@gnu.org],[ring])
AC_INIT([Ring Daemon],[7.0.0],[ring@gnu.org],[ring])
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]])
AC_REVISION([$Revision$])
......
......@@ -31,7 +31,7 @@ PROJECT_NAME = "Ring Daemon"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 6.1.0
PROJECT_NUMBER = 7.0.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
......
......@@ -169,6 +169,7 @@ Call::validStateTransition(CallState newState)
switch (newState) {
case CallState::ACTIVE:
case CallState::BUSY:
case CallState::PEER_BUSY:
case CallState::MERROR:
return true;
default: // INACTIVE, HOLD
......@@ -178,6 +179,7 @@ Call::validStateTransition(CallState newState)
case CallState::ACTIVE:
switch (newState) {
case CallState::BUSY:
case CallState::PEER_BUSY:
case CallState::HOLD:
case CallState::MERROR:
return true;
......@@ -190,7 +192,7 @@ Call::validStateTransition(CallState newState)
case CallState::ACTIVE:
case CallState::MERROR:
return true;
default: // INACTIVE, HOLD, BUSY, MERROR
default: // INACTIVE, HOLD, BUSY, PEER_BUSY, MERROR
return false;
}
......@@ -198,7 +200,7 @@ Call::validStateTransition(CallState newState)
switch (newState) {
case CallState::MERROR:
return true;
default: // INACTIVE, ACTIVE, HOLD, BUSY
default: // INACTIVE, ACTIVE, HOLD, BUSY, PEER_BUSY
return false;
}
......@@ -288,6 +290,9 @@ Call::getStateStr() const
case CallState::BUSY:
return StateEvent::BUSY;
case CallState::PEER_BUSY:
return StateEvent::PEER_BUSY;
case CallState::INACTIVE:
switch (getConnectionState()) {
case ConnectionState::PROGRESSING:
......@@ -460,7 +465,7 @@ Call::subcallStateChanged(Call& subcall,
// Subcall is busy or failed
if (new_state >= CallState::BUSY) {
if (new_state == CallState::BUSY)
if (new_state == CallState::BUSY || new_state == CallState::PEER_BUSY)
RING_WARN("[call:%s] subcall %s busy", getCallId().c_str(), subcall.getCallId().c_str());
else
RING_WARN("[call:%s] subcall %s failed", getCallId().c_str(), subcall.getCallId().c_str());
......@@ -471,6 +476,8 @@ Call::subcallStateChanged(Call& subcall,
if (subcalls_.empty()) {
if (new_state == CallState::BUSY) {
setState(CallState::BUSY, ConnectionState::DISCONNECTED, static_cast<int>(std::errc::device_or_resource_busy));
} else if (new_state == CallState::PEER_BUSY) {
setState(CallState::PEER_BUSY, ConnectionState::DISCONNECTED, static_cast<int>(std::errc::device_or_resource_busy));
} else {
// XXX: first idea was to use std::errc::host_unreachable, but it's not available on some platforms
// like mingw.
......
......@@ -87,7 +87,7 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
* \note modify validStateTransition/getStateStr if this enum changes
*/
enum class CallState : unsigned {
INACTIVE, ACTIVE, HOLD, BUSY, MERROR, OVER, COUNT__
INACTIVE, ACTIVE, HOLD, BUSY, PEER_BUSY, MERROR, OVER, COUNT__
};
virtual ~Call();
......
......@@ -34,6 +34,7 @@ constexpr static char RINGING [] = "RINGING" ;
constexpr static char CURRENT [] = "CURRENT" ;
constexpr static char HUNGUP [] = "HUNGUP" ;
constexpr static char BUSY [] = "BUSY" ;
constexpr static char PEER_BUSY [] = "PEER_BUSY" ;
constexpr static char FAILURE [] = "FAILURE" ;
constexpr static char HOLD [] = "HOLD" ;
constexpr static char UNHOLD [] = "UNHOLD" ;
......
......@@ -727,7 +727,11 @@ SIPCall::onFailure(signed cause)
void
SIPCall::onBusyHere()
{
setState(CallState::BUSY, ConnectionState::DISCONNECTED);
if (getCallType() == CallType::OUTGOING)
setState(CallState::PEER_BUSY, ConnectionState::DISCONNECTED);
else
setState(CallState::BUSY, ConnectionState::DISCONNECTED);
runOnMainThread([w = std::weak_ptr<Call>(shared_from_this())] {
if (auto shared = w.lock()) {
auto& call = *shared;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment