Browse code

SBC: CC module initialization with values from SBC profile instead of initial INVITE request

Without the INVITE request module parameters can not be evaluated during
initialization but the values from SBC profile are already evaluated and should
be used instead.

The reason for changing this is that we can add new call legs during the call
life when doing blind call transfer and we need not to remember the initial
INVITE to be able to do that.

Václav Kubart authored on 12/10/2012 06:25:40
Showing 3 changed files
... ...
@@ -32,9 +32,9 @@ class ExtendedCCInterface
32 32
     // call state changes
33 33
 
34 34
     /** First method called from extended CC module interface.
35
-     * It should initialize CC module internals (initial INVITE can be used for
36
-     * evaluating CC module parameters. */
37
-    virtual void init(SBCCallLeg *call, const AmSipRequest &invite) { }
35
+     * It should initialize CC module internals (values from sbcprofile.conf can
36
+     * be used for evaluating CC module parameters). */
37
+    virtual void init(SBCCallLeg *call, const map<string, string> &values) { }
38 38
 
39 39
     virtual void onStateChange(SBCCallLeg *call) { };
40 40
 
... ...
@@ -154,7 +154,7 @@ SBCCallLeg::SBCCallLeg(const SBCCallProfile& call_profile)
154 154
 }
155 155
 
156 156
 // B leg constructor (from SBCCalleeSession)
157
-SBCCallLeg::SBCCallLeg(SBCCallLeg* caller, const AmSipRequest &original_invite)
157
+SBCCallLeg::SBCCallLeg(SBCCallLeg* caller)
158 158
   : auth(NULL),
159 159
     call_profile(caller->getCallProfile()),
160 160
     CallLeg(caller)
... ...
@@ -175,7 +175,7 @@ SBCCallLeg::SBCCallLeg(SBCCallLeg* caller, const AmSipRequest &original_invite)
175 175
     throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR);
176 176
   }
177 177
 
178
-  initCCModules(original_invite);
178
+  initCCModules();
179 179
 }
180 180
 
181 181
 void SBCCallLeg::onStart()
... ...
@@ -716,7 +716,7 @@ void SBCCallLeg::onInvite(const AmSipRequest& req)
716 716
     throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR);
717 717
   }
718 718
 
719
-  initCCModules(req);
719
+  initCCModules();
720 720
 
721 721
   string ruri, to, from;
722 722
   ruri = call_profile.ruri.empty() ? req.r_uri : call_profile.ruri;
... ...
@@ -795,7 +795,7 @@ void SBCCallLeg::connectCallee(const string& remote_party, const string& remote_
795 795
 {
796 796
   // FIXME: no fork for now
797 797
 
798
-  SBCCallLeg* callee_session = new SBCCallLeg(this, original_invite);
798
+  SBCCallLeg* callee_session = new SBCCallLeg(this);
799 799
   callee_session->setLocalParty(from, from);
800 800
   callee_session->setRemoteParty(remote_party, remote_uri);
801 801
 
... ...
@@ -832,21 +832,6 @@ bool SBCCallLeg::getCCInterfaces() {
832 832
       return false;
833 833
     }
834 834
     cc_modules.push_back(cc_di);
835
-
836
-    // extended CC interface
837
-    try {
838
-      AmArg args, ret;
839
-      cc_di->invoke("getExtendedInterfaceHandler", args, ret);
840
-      ExtendedCCInterface *iface = dynamic_cast<ExtendedCCInterface*>(ret[0].asObject());
841
-      if (iface) {
842
-        DBG("extended CC interface offered by cc_module '%s'\n", cc_module.c_str());
843
-        cc_ext.push_back(iface);
844
-      }
845
-      else WARN("BUG: returned invalid extended CC interface by cc_module '%s'\n", cc_module.c_str());
846
-    }
847
-    catch (...) {
848
-      DBG("extended CC interface not supported by cc_module '%s'\n", cc_module.c_str());
849
-    }
850 835
   }
851 836
   return true;
852 837
 }
... ...
@@ -1456,10 +1441,35 @@ void SBCCallLeg::changeRtpMode(RTPRelayMode new_mode)
1456 1441
   setRtpRelayMode(new_mode);
1457 1442
 }
1458 1443
 
1459
-void SBCCallLeg::initCCModules(const AmSipRequest &original_invite)
1444
+void SBCCallLeg::initCCModules()
1460 1445
 {
1461
-  for (vector<ExtendedCCInterface*>::iterator i = cc_ext.begin(); i != cc_ext.end(); ++i) {
1462
-    (*i)->init(this, original_invite);
1446
+  // init extended call control modules
1447
+  vector<AmDynInvoke*>::iterator cc_mod = cc_modules.begin();
1448
+  for (CCInterfaceListIteratorT cc_it=call_profile.cc_interfaces.begin();
1449
+       cc_it != call_profile.cc_interfaces.end(); cc_it++)
1450
+  {
1451
+    CCInterface& cc_if = *cc_it;
1452
+    string& cc_module = cc_it->cc_module;
1453
+
1454
+    // get extended CC interface
1455
+    try {
1456
+      AmArg args, ret;
1457
+      (*cc_mod)->invoke("getExtendedInterfaceHandler", args, ret);
1458
+      ExtendedCCInterface *iface = dynamic_cast<ExtendedCCInterface*>(ret[0].asObject());
1459
+      if (iface) {
1460
+        DBG("extended CC interface offered by cc_module '%s'\n", cc_module.c_str());
1461
+        cc_ext.push_back(iface);
1462
+
1463
+        // module initialization
1464
+        iface->init(this, cc_if.cc_values);
1465
+      }
1466
+      else WARN("BUG: returned invalid extended CC interface by cc_module '%s'\n", cc_module.c_str());
1467
+    }
1468
+    catch (...) {
1469
+      DBG("extended CC interface not supported by cc_module '%s'\n", cc_module.c_str());
1470
+    }
1471
+
1472
+    ++cc_mod;
1463 1473
   }
1464 1474
 }
1465 1475
 
... ...
@@ -101,7 +101,7 @@ class SBCCallLeg : public CallLeg, public CredentialHolder
101 101
  public:
102 102
 
103 103
   SBCCallLeg(const SBCCallProfile& call_profile);
104
-  SBCCallLeg(SBCCallLeg* caller, const AmSipRequest &original_invite);
104
+  SBCCallLeg(SBCCallLeg* caller);
105 105
   ~SBCCallLeg();
106 106
 
107 107
   void process(AmEvent* ev);
... ...
@@ -119,7 +119,7 @@ class SBCCallLeg : public CallLeg, public CredentialHolder
119 119
   UACAuthCred* getCredentials();
120 120
 
121 121
   void setAuthHandler(AmSessionEventHandler* h) { auth = h; }
122
-  void initCCModules(const AmSipRequest &original_invite);
122
+  void initCCModules();
123 123
 
124 124
   /** save call timer; only effective before call is connected */
125 125
   void saveCallTimer(int timer, double timeout);