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

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Thu Jul 14 15:09:53 2011 +0200

adapt AmSession to new session start semantic

---

 core/AmSession.cpp |   54 +++++++++++++++++++++++++++++----------------------
 core/AmSession.h   |   25 ++++++-----------------
 2 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/core/AmSession.cpp b/core/AmSession.cpp
index 753ac35..4b8183b 100644
--- a/core/AmSession.cpp
+++ b/core/AmSession.cpp
@@ -124,11 +124,29 @@ void AmSession::changeCallgroup(const string& cg) {
   AmMediaProcessor::instance()->changeCallgroup(this, cg);
 }
 
-void AmSession::startMediaProcessing() {
-  AmMediaProcessor::instance()->addSession(this, callgroup);
+void AmSession::startMediaProcessing() 
+{
+  if(getStopped() || processing_media.get())
+    return;
+
+  bool in_out_set = false;
+  lockAudio();
+  in_out_set = input || output || local_input || local_output;
+  unlockAudio();
+  if(in_out_set) {
+    AmMediaProcessor::instance()->addSession(this, callgroup);
+  }
+  else {
+    DBG("no audio input and output set. "
+       "Session will not be attached to MediaProcessor.\n");
+  }
 }
 
-void AmSession::stopMediaProcessing() {
+void AmSession::stopMediaProcessing() 
+{
+  if(!processing_media.get())
+    return;
+
   AmMediaProcessor::instance()->removeSession(this);
 }
 
@@ -1040,12 +1058,12 @@ int AmSession::onSdpCompleted(const AmSdp& local_sdp, 
const AmSdp& remote_sdp)
     return -1;
   }
 
-  lockAudio();
   // TODO: 
   //   - get the right media ID
   //   - check if the stream coresponding to the media ID 
   //     should be created or updated   
   //
+  lockAudio();
   int ret = RTPStream()->init(getPayloadProvider(),0,local_sdp,remote_sdp);
   unlockAudio();
   
@@ -1054,28 +1072,18 @@ int AmSession::onSdpCompleted(const AmSdp& local_sdp, 
const AmSdp& remote_sdp)
     return -1;
   }
 
-  if(!processing_media.get() && !getStopped()) {
 
-    DBG("status = %s\n",dlg.getStatusStr());
-    if(dlg.getStatus() == AmSipDialog::Connected){
-      DBG("Calling onSessionStart()\n");
-      onSessionStart();
-    }
-    else if(dlg.getStatus() == AmSipDialog::Early){
-      DBG("Calling onEarlySessionStart()\n");
-      onEarlySessionStart();
-    }
+  return 0;
+}
 
-    if(input || output || local_input || local_output) {
-      startMediaProcessing();
-    }
-    else {
-      DBG("no audio input and output set. "
-         "Session will not be attached to MediaProcessor.\n");
-    }
-  }
+void AmSession::onEarlySessionStart()
+{
+  startMediaProcessing();
+}
 
-  return 0;
+void AmSession::onSessionStart()
+{
+  startMediaProcessing();
 }
 
 void AmSession::onRtpTimeout()
diff --git a/core/AmSession.h b/core/AmSession.h
index 6c74a34..cb18516 100644
--- a/core/AmSession.h
+++ b/core/AmSession.h
@@ -541,24 +541,6 @@ public:
   virtual void onCancel(const AmSipRequest& req);
 
   /**
-   * onSessionStart will be called after call setup.
-   *
-   * Throw AmSession::Exception if you want to 
-   * signal any error.
-   * 
-   * Warning:
-   *   Sems will NOT send any BYE on his own.
-   */
-  virtual void onSessionStart() {}
-
-  /**
-   * onEarlySessionStart will be called when
-   * the media session is setup with the dialog
-   * in Early state.
-   */
-  virtual void onEarlySessionStart() {}
-
-  /**
    * onRinging will be called after 180 is received. 
    * If local audio is set up, session is added to media processor.
    */
@@ -631,8 +613,15 @@ public:
   /** Hook called when an SDP offer is required */
   virtual bool getSdpAnswer(const AmSdp& offer, AmSdp& answer);
 
+  /** Hook called when an SDP OA transaction has been completed */
   virtual int onSdpCompleted(const AmSdp& offer, const AmSdp& answer);
 
+  /** Hook called when an early session starts (SDP OA completed + dialog in 
early state) */
+  virtual void onEarlySessionStart();
+
+  /** Hook called when the session creation is completed (INV trans replied 
with 200) */
+  virtual void onSessionStart();
+
   /** 
    * called in the session thread before the session is destroyed,
    * i.e. after the main event loop has finished

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

Reply via email to