[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Sep 16 15:29:51 CDT 2010


branch "master" has been updated
       via  8af0138e46a6cdcfbf0f41ea740300f9e5d667da (commit)
       via  2e31b8a6be1c62b548b95e3f99435f60c41fcce5 (commit)
       via  b99acabfd0c2774ccc66d964b372a69a6c2861bd (commit)
      from  0ec999f182c937b27c2efa34c621c3f61c5189da (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   79 ++++++++++++++++++++++++++++++-------------
 src/SipEndpoint.cpp        |    2 +-
 src/SipEndpoint.h          |    5 ++-
 src/SipSession.h           |    3 ++
 4 files changed, 63 insertions(+), 26 deletions(-)


- Log -----------------------------------------------------------------
commit 8af0138e46a6cdcfbf0f41ea740300f9e5d667da
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Sep 16 14:28:47 2010 -0500

    Resolve odd public/private weirdness in PJSipSessionModInfo.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 4bc95e5..cf52b6e 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -209,9 +209,11 @@ public:
       mSession = sessionPtr;
    }
    SipSessionStateItemPtr mSessionState;
-   SipSessionPtr mSession;
    bool mNeedsReplication;
    bool mNeedsRemoval;
+
+private:
+   SipSessionPtr mSession;
 };
 
 static pj_status_t sessionLoad(pjsip_endpoint *endpt)

commit 2e31b8a6be1c62b548b95e3f99435f60c41fcce5
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Sep 16 14:27:02 2010 -0500

    Get the session mod info class into the pjsip's inv_session->mod_info array.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 810a917..4bc95e5 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -186,6 +186,11 @@ public:
    {
       mSessionState->mId = IceUtil::generateUUID();
    }
+   ~PJSipSessionModInfo()
+   {
+      mSession->destroy();
+	  mSession = 0;
+   }
    /* In keeping with the other ModInfo classes, there
 	* is an update function. Unlike the other items, this
 	* involves Asterisk SCF data and not PJSIP data, so I'm
@@ -331,19 +336,21 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 		destination = std::string(pj_strbuf(&sipRuri->user), pj_strlen(&sipRuri->user));
 	}
 
-	SipSessionPtr* session = new SipSessionPtr(SipSessionPtr::dynamicCast(caller->createSession(destination)));
-	(*session)->setInviteSession(inv_session);
-	(*session)->setDialog(dlg);
+	SipSessionPtr session = caller->createSession(destination);
+	session->setInviteSession(inv_session);
+	session->setDialog(dlg);
+	PJSipSessionModInfo *session_mod_info = new PJSipSessionModInfo(inv_session);
+	session_mod_info->setSessionPtr(session);
 
 	//Adding the SipEndpoint to the inv_session's mod_data makes it easy to
 	//retrieve during signal callbacks.
-	inv_session->mod_data[module->id] = (void *)session;
+	inv_session->mod_data[module->id] = (void *)session_mod_info;
 	dlg->mod_data[module->id] = (void *)dlg_mod_info;
 
 	AsteriskSCF::SessionCommunications::V1::SessionRouterPrx router = dataModel.getSessionRouter();
 	try
 	{
-	   router->routeSession((*session)->getSessionProxy(), destination);
+	   router->routeSession(session->getSessionProxy(), destination);
 	}
 	catch (AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
 	{
@@ -432,7 +439,8 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 static void handle_invite_response(pjsip_inv_session *inv, pjsip_rx_data *rdata, pjsip_dialog *dlg)
 {
 	int respCode = rdata->msg_info.msg->line.status.code;
-	SipSessionPtr *session = (SipSessionPtr*)inv->mod_data[pjsip_ua_instance()->id];
+	PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[pjsip_ua_instance()->id];
+	SipSessionPtr session = session_mod_info->getSessionPtr();
 	//Commented because they are currently unused. They
 	//will be once the individual cases are mapped out.
 	//pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
@@ -454,11 +462,11 @@ static void handle_invite_response(pjsip_inv_session *inv, pjsip_rx_data *rdata,
 	else if (respCode == 180)
 	{
 		std::cout << "[DEBUG] Got 180 response" << std::endl;
-		std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& listeners = (*session)->getListeners();
+		std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& listeners = session->getListeners();
 		std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>::const_iterator listener;
 		for (listener = listeners.begin(); listener != listeners.end(); ++listener)
 		{
-		   (*listener)->ringing((*session)->getSessionProxy());
+		   (*listener)->ringing(session->getSessionProxy());
 		}
 	}
 	else if (respCode == 183)
@@ -466,11 +474,11 @@ static void handle_invite_response(pjsip_inv_session *inv, pjsip_rx_data *rdata,
 		std::cout << "[DEBUG] Got 183 response" << std::endl;
 		AsteriskSCF::SessionCommunications::V1::ResponseCodePtr response = new AsteriskSCF::SessionCommunications::V1::ResponseCode();
 		response->isdnCode = 42;
-		std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& listeners = (*session)->getListeners();
+		std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& listeners = session->getListeners();
 		std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>::const_iterator listener;
 		for (listener = listeners.begin(); listener != listeners.end(); ++listener)
 		{
-		   (*listener)->progressing((*session)->getSessionProxy(), response);
+		   (*listener)->progressing(session->getSessionProxy(), response);
 		}
 	}
 	else if (respCode == 200)
@@ -478,11 +486,11 @@ static void handle_invite_response(pjsip_inv_session *inv, pjsip_rx_data *rdata,
 		std::cout << "[DEBUG] Got 200 response" << std::endl;
 		if (inv->state != PJSIP_INV_STATE_DISCONNECTED)
 		{
-		   std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& listeners = (*session)->getListeners();
+		   std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& listeners = session->getListeners();
 		   std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>::const_iterator listener;
 		   for (listener = listeners.begin(); listener != listeners.end(); ++listener)
 		   {
-		      (*listener)->connected((*session)->getSessionProxy());
+		      (*listener)->connected(session->getSessionProxy());
 		   }
 		}
 	}
@@ -530,7 +538,6 @@ static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)
 
 static pj_status_t sessionOnTransmitRequest(pjsip_tx_data *data)
 {
-	//stub
 	return PJ_SUCCESS;
 }
 
@@ -542,18 +549,19 @@ static pj_status_t sessionOnTransmitResponse(pjsip_tx_data *data)
 
 static void sessionOnTransactionStateChange(pjsip_transaction *tsx, pjsip_event *event)
 {
-	//stub
+	
 }
 
 static void invOnStateChanged(pjsip_inv_session *inv, pjsip_event *event)
 {
    if (inv->state == PJSIP_INV_STATE_DISCONNECTED)
    {
-      SipSessionPtr *session = (SipSessionPtr*)inv->mod_data[pjsip_ua_instance()->id];
-      if (session == 0)
+      PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[pjsip_ua_instance()->id];
+      if (session_mod_info == 0)
       {
 	 return;
       }
+      SipSessionPtr session = session_mod_info->getSessionPtr();
       AsteriskSCF::SessionCommunications::V1::ResponseCodePtr response = new AsteriskSCF::SessionCommunications::V1::ResponseCode();
       if (inv->cause == 486)
       {
@@ -568,15 +576,14 @@ static void invOnStateChanged(pjsip_inv_session *inv, pjsip_event *event)
 	 // TODO: See what cause is on a normal call completion
 	 response->isdnCode = 0;
       }
-      std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> listeners = (*session)->getListeners();
+      std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> listeners = session->getListeners();
       for (std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>::iterator listener = listeners.begin();
 	   listener != listeners.end();
 	   ++listener)
       {
-	 (*listener)->stopped((*session)->getSessionProxy(), response);
+	 (*listener)->stopped(session->getSessionProxy(), response);
       }
-      (*session)->destroy();
-      delete session;
+      delete session_mod_info;
       inv->mod_data[pjsip_ua_instance()->id] = 0;
    }
 	//stub
@@ -593,7 +600,28 @@ static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transacti
    {
       handle_invite_response(inv, e->body.tsx_state.src.rdata, inv->dlg);
    }
-	//stub
+	//This will be our key point for updating transaction state.
+	//This function will not be called until after a module has registered
+	//itself as the transaction user, so this won't be called on the initial
+	//INVITE we receive.
+	//
+	//The methodology here is a bit odd, and that's due to the order in which
+	//PJSIP iterates through modules. This function is called from the
+	//transaction layer. On message reception, this will get called before
+	//our application has a chance to update dialog and session state. So
+	//in that case, we just update transaction state and move on. When
+	//transmitting messages, though, this is basically the last thing
+	//that gets called prior to the message actually being sent out, so
+	//this is the opportune time to both update the transaction state and
+	//update the state replicator with all pending transaction, dialog,
+	//and session changes.
+	
+	pjsip_module *module = pjsip_ua_instance();
+	PJSipTransactionModInfo *tsx_mod_data = static_cast<PJSipTransactionModInfo *> (tsx->mod_data[module->id]);
+	tsx_mod_data->updateTransactionState(tsx);
+	if (e->type == PJSIP_EVENT_TX_MSG)
+	{
+	}
 }
 
 static void invOnReceiveOffer(pjsip_inv_session *inv, const pjmedia_sdp_session *offer)
@@ -623,8 +651,9 @@ static void invOnMediaUpdate(pjsip_inv_session *inv, pj_status_t status)
 
    const pjmedia_sdp_conn *remote_conn = remote_sdp->media[0]->conn ? remote_sdp->media[0]->conn : remote_sdp->conn;
 
-   SipSessionPtr *session = (SipSessionPtr*)inv->mod_data[pjsip_ua_instance()->id];
-   (*session)->setRemoteDetails(pj_strbuf(&remote_conn->addr), remote_sdp->media[0]->desc.port);
+   PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[pjsip_ua_instance()->id];
+   SipSessionPtr session = session_mod_info->getSessionPtr();
+   session->setRemoteDetails(pj_strbuf(&remote_conn->addr), remote_sdp->media[0]->desc.port);
 
    // Each stream has its own set of formats, so go to that granularity
    for (unsigned int stream = 0; stream < remote_sdp->media_count; stream++)

commit b99acabfd0c2774ccc66d964b372a69a6c2861bd
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Sep 16 14:09:03 2010 -0500

    Change SipEndpoint::createSession to make a SipSessionPtr.

diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 34d7fbd..20d9910 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -192,7 +192,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
    return session->getSessionProxy();
 }
 
-AsteriskSCF::SessionCommunications::V1::SessionPtr SipEndpoint::createSession(const std::string& destination)
+AsteriskSCF::SipChannelService::SipSessionPtr SipEndpoint::createSession(const std::string& destination)
 {
    SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, 0);
    mImplPriv->mSessions.push_back(session);
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 3eb1b9c..3c6db62 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -17,6 +17,7 @@
 #include <SessionCommunications/SessionCommunicationsIf.h>
 #include <Media/MediaIf.h>
 #include <Media/RTP/MediaRTPIf.h>
+#include "SipSession.h"
 
 #include <pjsip.h>
 #include <pjmedia.h>
@@ -32,6 +33,8 @@ namespace SipChannelService
 {
 
 class SipEndpointFactory;
+class SipSession;
+typedef IceUtil::Handle<SipSession> SipSessionPtr;
 
 /**
  * General purpose direction enumeration.
@@ -216,7 +219,7 @@ public:
    AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx getEndpointProxy();
 
    // TODO: Find a way to use SipSessionPtr here, right now trying to do so results in the world exploding due to dependency insanity
-   AsteriskSCF::SessionCommunications::V1::SessionPtr createSession(const std::string&);
+   AsteriskSCF::SipChannelService::SipSessionPtr createSession(const std::string&);
 
    void removeSession(AsteriskSCF::SessionCommunications::V1::SessionPtr);
 
diff --git a/src/SipSession.h b/src/SipSession.h
index 2882904..bfd186f 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -31,6 +31,9 @@ namespace AsteriskSCF
 namespace SipChannelService
 {
 
+class SipEndpoint;
+typedef IceUtil::Handle<SipEndpoint> SipEndpointPtr;
+
 /*
  * Private implementation class for SipSession.
  */

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list