Module: sems
Branch: master
Commit: de39709f638f5674a0166ae2e5d945962abe7e00
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=de39709f638f5674a0166ae2e5d945962abe7e00

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Tue Oct  4 19:16:51 2011 +0200

sbc: b/f: (re) setting timers while connecting

---

 apps/sbc/SBC.cpp |   39 ++++++++++++++++++++++++++++-----------
 apps/sbc/SBC.h   |    2 +-
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp
index 2166dab..252ef68 100644
--- a/apps/sbc/SBC.cpp
+++ b/apps/sbc/SBC.cpp
@@ -891,14 +891,31 @@ void SBCDialog::process(AmEvent* ev)
   SBCCallTimerEvent* ct_event;
   if (ev->event_id == SBCCallTimerEvent_ID &&
       (ct_event = dynamic_cast<SBCCallTimerEvent*>(ev)) != NULL) {
-    switch (ct_event->timer_action) {
-    case SBCCallTimerEvent::Remove: removeTimer(ct_event->timer_id); return;
-    case SBCCallTimerEvent::Set:    setTimer(ct_event->timer_id, 
ct_event->timeout); return;
-    case SBCCallTimerEvent::Reset:
-      removeTimer(ct_event->timer_id);
-      setTimer(ct_event->timer_id, ct_event->timeout);
-      return;
-    default: ERROR("unknown timer_action in sbc call timer event\n");
+    switch (m_state) {
+    case BB_Connected: {
+      switch (ct_event->timer_action) {
+      case SBCCallTimerEvent::Remove: removeTimer(ct_event->timer_id); return;
+      case SBCCallTimerEvent::Set:    setTimer(ct_event->timer_id, 
ct_event->timeout); return;
+      case SBCCallTimerEvent::Reset:
+       removeTimer(ct_event->timer_id);
+       setTimer(ct_event->timer_id, ct_event->timeout);
+       return;
+      default: ERROR("unknown timer_action in sbc call timer event\n"); return;
+      }
+    }
+
+    case BB_Init:
+    case BB_Dialing: {
+      switch (ct_event->timer_action) {
+      case SBCCallTimerEvent::Remove: call_timers.erase(ct_event->timer_id); 
return;
+      case SBCCallTimerEvent::Set:
+      case SBCCallTimerEvent::Reset:
+       call_timers[ct_event->timer_id] = ct_event->timeout; return;
+      default: ERROR("unknown timer_action in sbc call timer event\n"); return;
+      }
+    } break;
+
+    default: break;
     }
   }
 
@@ -1122,7 +1139,7 @@ bool SBCDialog::startCallTimer() {
     return false;
   }
 
-  for (vector<pair<int, unsigned int> >::iterator it=
+  for (map<int, unsigned int>::iterator it=
         call_timers.begin(); it != call_timers.end(); it++) {
     DBG("SBC: starting call timer %i of %u seconds\n", it->first, it->second);
     setTimer(it->first, it->second);
@@ -1132,7 +1149,7 @@ bool SBCDialog::startCallTimer() {
 }
 
 void SBCDialog::stopCallTimer() {
-  for (vector<pair<int, unsigned int> >::iterator it=
+  for (map<int, unsigned int>::iterator it=
         call_timers.begin(); it != call_timers.end(); it++) {
     DBG("SBC: removing call timer %i\n", it->first);
     removeTimer(it->first);
@@ -1241,7 +1258,7 @@ bool SBCDialog::CCStart(const AmSipRequest& req) {
 
          DBG("saving call timer %i: timeout %i\n",
              cc_timer_id, ret[i][SBC_CC_TIMER_TIMEOUT].asInt());
-         call_timers.push_back(std::make_pair(cc_timer_id, 
ret[i][SBC_CC_TIMER_TIMEOUT].asInt()));
+         call_timers[cc_timer_id] = ret[i][SBC_CC_TIMER_TIMEOUT].asInt();
          cc_timer_id++;
        } break;
 
diff --git a/apps/sbc/SBC.h b/apps/sbc/SBC.h
index 5979f84..3294c2b 100644
--- a/apps/sbc/SBC.h
+++ b/apps/sbc/SBC.h
@@ -104,7 +104,7 @@ class SBCDialog : public AmB2BCallerSession, public 
CredentialHolder
   string to;
   string callid;
 
-  vector<pair<int, unsigned int> > call_timers;
+  map<int, unsigned int> call_timers;
 
   int outbound_interface;
   // call control

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to