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

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Wed Sep 22 00:25:46 2010 +0200

SIP Session Timer support for conference app

---

 apps/conference/Conference.cpp      |   39 ++++++++++++++++++++++++++++++++--
 apps/conference/Conference.h        |    4 +++
 apps/conference/etc/conference.conf |   34 ++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/apps/conference/Conference.cpp b/apps/conference/Conference.cpp
index f2ccce0..43beda5 100644
--- a/apps/conference/Conference.cpp
+++ b/apps/conference/Conference.cpp
@@ -73,6 +73,8 @@ PlayoutType ConferenceFactory::m_PlayoutType = 
ADAPTIVE_PLAYOUT;
 unsigned int ConferenceFactory::MaxParticipants;
 
 bool ConferenceFactory::UseRFC4240Rooms;
+AmConfigReader ConferenceFactory::cfg;
+AmSessionEventHandlerFactory* ConferenceFactory::session_timer_f = NULL;
 
 #ifdef USE_MYSQL
 mysqlpp::Connection ConferenceFactory::Connection(mysqlpp::use_exceptions);
@@ -155,7 +157,6 @@ int get_audio_file(const string& message, const string& 
domain, const string& la
 
 int ConferenceFactory::onLoad()
 {
-  AmConfigReader cfg;
   if(cfg.loadFile(AmConfig::ModConfigPath + string(APP_NAME)+ ".conf"))
     return -1;
 
@@ -297,6 +298,15 @@ int ConferenceFactory::onLoad()
   UseRFC4240Rooms = cfg.getParameter("use_rfc4240_rooms")=="yes";
   DBG("%ssing RFC4240 room naming.\n", UseRFC4240Rooms?"U":"Not u");
 
+  if(cfg.hasParameter("enable_session_timer") &&
+     (cfg.getParameter("enable_session_timer") == string("yes")) ){
+    DBG("enabling session timers\n");
+    session_timer_f = AmPlugIn::instance()->getFactory4Seh("session_timer");
+    if(session_timer_f == NULL){
+      ERROR("Could not load the session_timer module: disabling session 
timers.\n");
+    }
+  }
+
   return 0;
 }
 
@@ -322,7 +332,27 @@ AmSession* ConferenceFactory::onInvite(const AmSipRequest& 
req)
     conf_id = req.user.substr(5);
   }
 
-  return new ConferenceDialog(conf_id);
+  ConferenceDialog* s = new ConferenceDialog(conf_id);
+
+  setupSessionTimer(s);
+
+  return s;
+}
+
+void ConferenceFactory::setupSessionTimer(AmSession* s) {
+  if (NULL != session_timer_f) {
+
+    AmSessionEventHandler* h = session_timer_f->getHandler(s);
+    if (NULL == h)
+      return;
+
+    if(h->configure(cfg)){
+      ERROR("Could not configure the session timer: disabling session 
timers.\n");
+      delete h;
+    } else {
+      s->addHandler(h);
+    }
+  }
 }
 
 AmSession* ConferenceFactory::onRefer(const AmSipRequest& req)
@@ -332,7 +362,8 @@ AmSession* ConferenceFactory::onRefer(const AmSipRequest& 
req)
 
   AmSession* s = new ConferenceDialog(req.user);
   s->dlg.local_tag  = req.from_tag;
-    
+  
+  setupSessionTimer(s);
 
   DBG("ConferenceFactory::onRefer: local_tag = %s\n",s->dlg.local_tag.c_str());
 
@@ -749,6 +780,8 @@ void ConferenceDialog::createDialoutParticipant(const 
string& uri_user)
                         AmConferenceStatus::getChannel(getLocalTag(),
                                                        dialout_id));
 
+  ConferenceFactory::setupSessionTimer(dialout_session);
+
   AmSipDialog& dialout_dlg = dialout_session->dlg;
 
   dialout_dlg.local_tag    = dialout_id;
diff --git a/apps/conference/Conference.h b/apps/conference/Conference.h
index ab00af8..cc67436 100644
--- a/apps/conference/Conference.h
+++ b/apps/conference/Conference.h
@@ -75,6 +75,9 @@ struct DialoutConfEvent : public AmEvent {
 /** \brief Factory for conference sessions */
 class ConferenceFactory : public AmSessionFactory
 {
+  static AmSessionEventHandlerFactory* session_timer_f;
+  static AmConfigReader cfg;
+
 public:
   static string AudioPath;
   static string LonelyUserFile;
@@ -85,6 +88,7 @@ public:
   static unsigned int MaxParticipants;
   static bool UseRFC4240Rooms;
 
+  static void setupSessionTimer(AmSession* s);
 
 #ifdef USE_MYSQL
   static mysqlpp::Connection Connection;
diff --git a/apps/conference/etc/conference.conf 
b/apps/conference/etc/conference.conf
index cc985b9..89087b6 100644
--- a/apps/conference/etc/conference.conf
+++ b/apps/conference/etc/conference.conf
@@ -33,3 +33,37 @@ playout_type=adaptive_playout
 #default:
 # use_rfc4240_rooms=no
 #
+
+###############################################################
+# RFC4028 Session Timer
+#
+
+# - enables the session timer ([yes,no]; default: no)
+# 
+# enable_session_timer=yes
+
+# - set the "Session-Expires" parameter for the session timer.
+#
+# session_expires=240
+
+# - set the "Min-SE" parameter for the session timer.
+#
+# minimum_timer=90
+
+# session refresh (Session Timer, RFC4028) method
+#
+# INVITE                 - use re-INVITE
+# UPDATE                 - use UPDATE
+# UPDATE_FALLBACK_INVITE - use UPDATE if indicated in Allow, re-INVITE 
otherwise
+#
+# Default: UPDATE_FALLBACK_INVITE
+#
+# Note: Session Timers are only supported in some applications
+#
+#session_refresh_method=UPDATE
+
+# accept_501_reply - accept 501 reply as successful refresh? [yes|no]
+#
+# Default: yes
+#
+#accept_501_reply=no

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

Reply via email to