[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
Wed Aug 25 14:21:41 CDT 2010


branch "master" has been updated
       via  d9c7905edd783fbbc5914ce01f526db985a81e00 (commit)
      from  21f10dd4a7e4f1814da06463dd6ce7e0cb5980c9 (commit)

Summary of changes:
 slice                      |    2 +-
 src/PJSipManager.cpp       |   50 +++++++------------------------------------
 src/PJSipManager.h         |   25 ++++-----------------
 src/PJSipSessionModule.cpp |   41 +++++++++++++++++++++---------------
 src/PJSipSessionModule.h   |    1 +
 5 files changed, 39 insertions(+), 80 deletions(-)


- Log -----------------------------------------------------------------
commit d9c7905edd783fbbc5914ce01f526db985a81e00
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 25 14:20:52 2010 -0500

    Change module registration method within PJSipManager
    
    Now, the sesion module is an explicit part of PJSipManager
    and can be retrieved using the getSessionModule() function. In
    addition, PJSipManager has been altered so that on startup, it
    registers the session module.

diff --git a/slice b/slice
index dcb271b..d6b2777 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit dcb271baaca90fa89ed6b7d4846ea458fb303943
+Subproject commit d6b2777545b3b8eae7c5dc9b40a1ca3ff9e26a43
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 24f01ab..46194eb 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -46,6 +46,7 @@ PJSipManager::PJSipManager()
 	{
 		std::cerr << "[ERROR] Failed to create a memory pool" << std::endl;
 	}
+	registerSessionModule();
 	status = pj_thread_create(mMemoryPool, "SIP", (pj_thread_proc *) &monitorThread,
 			mEndpoint, PJ_THREAD_DEFAULT_STACK_SIZE, 0, &mPjThread);
 	if (status != PJ_SUCCESS)
@@ -59,49 +60,9 @@ pjsip_endpoint *PJSipManager::getEndpoint()
 	return mEndpoint;
 }
 
-bool PJSipManager::registerModule(pjsip_module *module)
+pjsip_module *PJSipManager::getSessionModule()
 {
-	pj_status_t status = pjsip_endpt_register_module(mEndpoint, module);
-	if (status != PJ_SUCCESS)
-	{
-		return false;
-	}
-	mModules.push_back(module);
-	return true;
-}
-
-bool PJSipManager::unregisterModule(pjsip_module *module)
-{
-	pj_status_t status = pjsip_endpt_unregister_module(mEndpoint, module);
-	if (status != PJ_SUCCESS)
-	{
-		return false;
-	}
-	for (std::vector<pjsip_module *>::iterator iter = mModules.begin();
-			iter != mModules.end();
-			++iter)
-	{
-		if (*iter == module)
-		{
-			mModules.erase(iter);
-			break;
-		}
-	}
-	return true;
-}
-
-pjsip_module *PJSipManager::getModuleByName(const std::string &name)
-{
-	for (std::vector<pjsip_module *>::iterator iter = mModules.begin();
-			iter != mModules.end();
-			++iter)
-	{
-		if (name == pj_strbuf(&(*iter)->name))
-		{
-			return *iter;
-		}
-	}
-	return NULL;
+	return mSessionModule->getModule();
 }
 
 bool PJSipManager::setTransports(pjsip_endpoint *endpoint)
@@ -142,6 +103,11 @@ bool PJSipManager::setTransports(pjsip_endpoint *endpoint)
 	return true;
 }
 
+void PJSipManager::registerSessionModule()
+{
+	mSessionModule = new PJSipSessionModule();
+}
+
 }; //End namespace SipChannelService
 
 }; //End namespace Hydra
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 981abf0..82396ca 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -6,6 +6,7 @@
 #include <pjsip.h>
 
 #include <boost/shared_ptr.hpp>
+#include "PJSipSessionModule.h"
 
 namespace Hydra
 {
@@ -33,40 +34,24 @@ public:
 	 * that may require it
 	 */
 	pjsip_endpoint *getEndpoint();
-	/**
-	 * Register a module with PJsip
-	 * This will result in the module's load and
-	 * start callbacks being called.
-	 * @module The module to register
-	 */
-	bool registerModule(pjsip_module *module);
-	/**
-	 * Unregister a PJSIP module.
-	 * This will result in the module's unload and
-	 * stop callbacks being called.
-	 * @module The module to unregister
-	 */
-	bool unregisterModule(pjsip_module *module);
 
 	/**
-	 * Get a pj_sip module using its name as a key.
-	 * This is helpful when a particular module is needed
-	 * from within a callback from PJSIP.
-	 * @name The name of hte module to find
+	 * Get a pointer to the PJSIP session module
 	 */
-	pjsip_module *getModuleByName(const std::string &name);
+	pjsip_module *getSessionModule();
 protected:
 	PJSipManager();
 private:
 	static PJSipManager *mInstance;
 	pjsip_endpoint *mEndpoint;
-	std::vector<pjsip_module *> mModules;
+	PJSipSessionModule *mSessionModule;
 	pj_thread_t *mPjThread;
 	pj_caching_pool mCachingPool;
 	pj_pool_t *mMemoryPool;
 	pjsip_transport *mUdpTransport;
 
 	bool setTransports(pjsip_endpoint *endpoint);
+	void registerSessionModule();
 };
 
 }; //End namespace SipChannelService
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 0efc1fb..0ddb753 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -17,8 +17,6 @@ using namespace Hydra::Core::Routing::V1;
 using namespace Hydra::Core::Bridging::V1;
 using namespace Hydra::Core::Endpoint::V1;
 
-static const std::string modName("AsteriskSCF");
-
 static pj_status_t sessionLoad(pjsip_endpoint *endpt)
 {
 	//stub
@@ -137,7 +135,7 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	//Adding the SipEndpoint to the dialog's mod_data makes it easy to
 	//retrieve during signal callbacks.
 	PJSipManager *manager = PJSipManager::getInstance();
-	pjsip_module *module = manager->getModuleByName(modName);
+	pjsip_module *module = manager->getSessionModule();
 	if (module == NULL)
 	{
 		std::cerr << "[WARNING] Um, couldn't get the module from the PJSipManger??" << std::endl;
@@ -211,6 +209,23 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 	return PJ_TRUE;
 }
 
+static void handle_invite_response(pjsip_rx_data *rdata)
+{
+	//Let's see...(This will probably be in its own function)
+	//180: Tell the bridge to ring() the other side
+	//183: Tell the bridge to progress() the other side
+	//Other 1XX, treat like a 180, I guess.
+	//2XX: There had better be an SDP. Parse and give it
+	//to the media layer. Send an ACK. If necessary put
+	//an SDP answer in the ACK.
+	//3XX: Hm, good question. I suppose I should essentially
+	//treat this as a new incoming call to the URI in the
+	//Contact header. Also terminate the previous outgoing
+	//dialog.
+	//400-699: Unless it's a 401 or 407, that means to
+	//terminate the call.
+}
+
 static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)
 {
 	//stub
@@ -226,19 +241,7 @@ static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)
 	{
 	case PJSIP_INVITE_METHOD:
 	{
-		//Let's see...(This will probably be in its own function)
-		//180: Tell the bridge to ring() the other side
-		//183: Tell the bridge to progress() the other side
-		//Other 1XX, treat like a 180, I guess.
-		//2XX: There had better be an SDP. Parse and give it
-		//to the media layer. Send an ACK. If necessary put
-		//an SDP answer in the ACK.
-		//3XX: Hm, good question. I suppose I should essentially
-		//treat this as a new incoming call to the URI in the
-		//Contact header. Also terminate the previous outgoing
-		//dialog.
-		//400-699: Unless it's a 401 or 407, that means to
-		//terminate the call.
+		handle_invite_response(rdata);
 		break;
 	}
 	case PJSIP_BYE_METHOD:
@@ -368,7 +371,11 @@ PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
 	pjsip_ua_init_module(endpt, &mUaParam);
 	pjsip_100rel_init_module(endpt);
 	pjsip_inv_usage_init(endpt, &mInvCallback);
-	manager->registerModule(&mModule);
+}
+
+pjsip_module *PJSipSessionModule::getModule()
+{
+	return &mModule;
 }
 
 }; //end namespace SipChannelService
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index fba215b..a4b8b8e 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -14,6 +14,7 @@ class PJSipSessionModule
 {
 public:
 	PJSipSessionModule();
+	pjsip_module *getModule();
 private:
 	pjsip_module mModule;
 	pjsip_inv_callback mInvCallback;

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list