Browse code

SBC: extended call control interface prototype

Václav Kubart authored on 13/08/2012 13:50:27
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+#ifndef __EXTENDED_CC_INTERFACE
2
+#define __EXTENDED_CC_INTERFACE
3
+
4
+class SBCCallLeg;
5
+class SBCCallProfile;
6
+
7
+class ExtendedCCInterface {
8
+  protected:
9
+    ~ExtendedCCInterface() { }
10
+
11
+  public:
12
+    virtual void onStateChange(SBCCallLeg *call, SBCCallProfile *call_profile) = 0;
13
+};
14
+
15
+#endif
... ...
@@ -794,6 +794,21 @@ bool SBCCallLeg::getCCInterfaces() {
794 794
       return false;
795 795
     }
796 796
     cc_modules.push_back(cc_di);
797
+
798
+    // extended CC interface
799
+    try {
800
+      AmArg args, ret;
801
+      cc_di->invoke("getExtendedInterfaceHandler", args, ret);
802
+      ExtendedCCInterface *iface = dynamic_cast<ExtendedCCInterface*>(ret[0].asObject());
803
+      if (iface) {
804
+        INFO("extended CC interface offered by cc_module '%s'\n", cc_module.c_str());
805
+        cc_ext.push_back(iface);
806
+      }
807
+      else WARN("BUG: returned invalid extended CC interface by cc_module '%s'\n", cc_module.c_str());
808
+    }
809
+    catch (...) {
810
+      INFO("extended CC interface not supported by cc_module '%s'\n", cc_module.c_str());
811
+    }
797 812
   }
798 813
   return true;
799 814
 }
... ...
@@ -1148,6 +1163,13 @@ void SBCCallLeg::CCEnd(const CCInterfaceListIteratorT& end_interface) {
1148 1163
   }
1149 1164
 }
1150 1165
 
1166
+void SBCCallLeg::onCallStatusChange()
1167
+{
1168
+  for (vector<ExtendedCCInterface*>::iterator i = cc_ext.begin(); i != cc_ext.end(); ++i) {
1169
+    (*i)->onStateChange(this, &call_profile);
1170
+  }
1171
+}
1172
+
1151 1173
 //////////////////////////////////////////////////////////////////////////////////////////
1152 1174
 // body filtering
1153 1175
 
... ...
@@ -2,6 +2,7 @@
2 2
 #define __SBCCALL_LEG_H
3 3
 
4 4
 #include "SBC.h"
5
+#include "ExtendedCCInterface.h"
5 6
 
6 7
 class PayloadIdMapping
7 8
 {
... ...
@@ -29,6 +30,8 @@ class SBCCallLeg : public CallLeg, public CredentialHolder
29 30
 
30 31
   // call control
31 32
   vector<AmDynInvoke*> cc_modules;
33
+  vector<ExtendedCCInterface*> cc_ext;
34
+
32 35
   // current timer ID - cc module setting timer will use this
33 36
   int cc_timer_id;
34 37
 
... ...
@@ -93,6 +96,8 @@ class SBCCallLeg : public CallLeg, public CredentialHolder
93 96
   /** apply B leg configuration from call profile */
94 97
   void applyBProfile();
95 98
 
99
+  virtual void onCallStatusChange();
100
+
96 101
  public:
97 102
 
98 103
   SBCCallLeg(const SBCCallProfile& call_profile);