[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
Tue Sep 21 09:40:02 CDT 2010


branch "master" has been updated
       via  b4a2c5e0d7587cde80ae11bbda2d3139bb6a574b (commit)
      from  7e28b5c4d0d651ca391be8d77aeeaaddb61814e3 (commit)

Summary of changes:
 src/SipStateReplicatorListener.cpp |   46 +++++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit b4a2c5e0d7587cde80ae11bbda2d3139bb6a574b
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Sep 21 11:41:49 2010 -0300

    Add dialog state item handling. Not yet complete but updates a good portion of things so far.

diff --git a/src/SipStateReplicatorListener.cpp b/src/SipStateReplicatorListener.cpp
index afeb749..3dc0771 100644
--- a/src/SipStateReplicatorListener.cpp
+++ b/src/SipStateReplicatorListener.cpp
@@ -16,6 +16,7 @@
 #include "SipEndpoint.h"
 #include "SipEndpointFactory.h"
 #include "SipSession.h"
+#include "PJSipManager.h"
 
 namespace AsteriskSCF
 {
@@ -98,7 +99,50 @@ public:
 	    {
 	       continue;
 	    }
-	    localitem = i->second;
+	    // Do we have a dialog already? If not we need to fashion ourselves one of the proper type
+	    pjsip_dialog *localDialog = i->second->getSession()->getDialog();
+
+	    if (!localDialog)
+	    {
+	       // Dialogs always start out as UAC since that does not require an actual packet, it is only later that we change them
+	       pj_str_t localUri = pj_str((char*)dialog->mLocalUri.c_str());
+	       pj_str_t remoteUri = pj_str((char*)dialog->mRemoteUri.c_str());
+	       if ((pjsip_dlg_create_uac(pjsip_ua_instance(), &localUri, &localUri, &remoteUri, &remoteUri, &localDialog)) != PJ_SUCCESS)
+	       {
+		  // For some reason we failed to create a dialog and can go no further ;(
+		  continue;
+	       }
+	       // TODO: Change role to be UAS if need be
+
+	       // Since the Call ID will never change for the lifetime of the dialog we only mess with it here when creating the dialog itself
+	       pj_strdup2(localDialog->pool, &localDialog->call_id->id, dialog->mCallId.c_str());
+
+	       // Secure status is another thing that should never change
+	       localDialog->secure = (dialog->mIsSecure == true) ? PJ_TRUE : PJ_FALSE;
+
+	       i->second->getSession()->setDialog(localDialog);
+	    }
+
+	    localDialog->state = (dialog->mIsDialogEstablished == true) ? PJSIP_DIALOG_STATE_ESTABLISHED : PJSIP_DIALOG_STATE_NULL;
+	    localDialog->local.cseq = dialog->mLocalCSeq;
+	    localDialog->remote.cseq = dialog->mRemoteCSeq;
+
+	    // Strings we do not just set since doing so could needlessly increase memory usage, and we have to be careful of that
+	    if (pj_strcmp2(&localDialog->local.info->tag, dialog->mLocalTag.c_str()))
+	    {
+	       pj_strdup2(localDialog->pool, &localDialog->local.info->tag, dialog->mLocalTag.c_str());
+	       localDialog->local.tag_hval = pj_hash_calc(0, localDialog->local.info->tag.ptr, localDialog->local.info->tag.slen);
+	    }
+
+	    if (pj_strcmp2(&localDialog->remote.info->tag, dialog->mRemoteTag.c_str()))
+	    {
+	       pj_strdup2(localDialog->pool, &localDialog->remote.info->tag, dialog->mRemoteTag.c_str());
+	       localDialog->remote.tag_hval = pj_hash_calc(0, localDialog->remote.info->tag.ptr, localDialog->remote.info->tag.slen);
+	    }
+
+	    // TODO: Handle mRouteSet, which is not as easy as it sounds!
+
+	    // TODO: Handle mTransport, which is rather difficult since transport is decided on a packet basis... do we even need it?
 	 }
 	 else if ((transaction = SipTransactionStateItemPtr::dynamicCast((*item))))
 	 {

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list