diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp index e066f674..fad03107 100644 --- a/apps/sbc/SBC.cpp +++ b/apps/sbc/SBC.cpp @@ -561,22 +561,8 @@ bool SBCDialog::onOtherReply(const AmSipReply& reply) if(getCalleeStatus() == Connected) { m_state = BB_Connected; - if ((call_profile.call_timer_enabled || call_profile.prepaid_enabled) && - (NULL == m_user_timer)) { - ERROR("internal implementation error: invalid timer reference\n"); - terminateOtherLeg(); - terminateLeg(); + if (!startCallTimer()) return ret; - } - - if (call_profile.call_timer_enabled) { - DBG("SBC: starting call timer of %u seconds\n", call_timer); - AmArg di_args,ret; - di_args.push((int)SBC_TIMER_ID_CALL_TIMER); - di_args.push((int)call_timer); // in seconds - di_args.push(getLocalTag().c_str()); - m_user_timer->invoke("setTimer", di_args, ret); - } startPrepaidAccounting(); } @@ -622,6 +608,28 @@ void SBCDialog::stopCall() { terminateLeg(); } +/** @return whether successful */ +bool SBCDialog::startCallTimer() { + if ((call_profile.call_timer_enabled || call_profile.prepaid_enabled) && + (NULL == m_user_timer)) { + ERROR("internal implementation error: invalid timer reference\n"); + terminateOtherLeg(); + terminateLeg(); + return false; + } + + if (call_profile.call_timer_enabled) { + DBG("SBC: starting call timer of %u seconds\n", call_timer); + AmArg di_args,ret; + di_args.push((int)SBC_TIMER_ID_CALL_TIMER); + di_args.push((int)call_timer); // in seconds + di_args.push(getLocalTag().c_str()); + m_user_timer->invoke("setTimer", di_args, ret); + } + + return true; +} + void SBCDialog::startPrepaidAccounting() { if (!call_profile.prepaid_enabled) return; diff --git a/apps/sbc/SBC.h b/apps/sbc/SBC.h index b5185e24..babbc474 100644 --- a/apps/sbc/SBC.h +++ b/apps/sbc/SBC.h @@ -145,6 +145,7 @@ class SBCDialog : public AmB2BCallerSession SBCCallProfile call_profile; void stopCall(); + bool startCallTimer(); void startPrepaidAccounting(); void stopPrepaidAccounting();