[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 13:22:48 CDT 2010


branch "master" has been updated
       via  21f10dd4a7e4f1814da06463dd6ce7e0cb5980c9 (commit)
       via  99eee45ef447f57993f86c7134f28db6f89cd830 (commit)
      from  e5f8c50b24dc1e1e9b9b5bda5a3f9e17013c81dc (commit)

Summary of changes:
 src/PJSipManager.cpp       |   14 ++++++++++++++
 src/PJSipManager.h         |    8 ++++++++
 src/PJSipSessionModule.cpp |   15 +++++++++++++--
 3 files changed, 35 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit 21f10dd4a7e4f1814da06463dd6ce7e0cb5980c9
Merge: 99eee45 e5f8c50
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 25 13:24:03 2010 -0500

    Merge branch 'master' of git.asterisk.org:asterisk-scf/integration/sip


commit 99eee45ef447f57993f86c7134f28db6f89cd830
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 25 13:23:42 2010 -0500

    Add member to get pjsip_module from the PJSipManager.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index aa1ea6e..24f01ab 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -90,6 +90,20 @@ bool PJSipManager::unregisterModule(pjsip_module *module)
 	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;
+}
+
 bool PJSipManager::setTransports(pjsip_endpoint *endpoint)
 {
 	//XXX We'll also want to allow for TCP and TLS-specific
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 46d9c3e..981abf0 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -47,6 +47,14 @@ public:
 	 * @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
+	 */
+	pjsip_module *getModuleByName(const std::string &name);
 protected:
 	PJSipManager();
 private:
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 4233dfe..8e6050d 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -17,6 +17,8 @@ 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
@@ -106,7 +108,7 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	boost::shared_ptr<SipEndpointFactory> factory = dataModel.getEndpointFactory();
 	//XXX Hardcoded "Butt" is bad for a lot of reasons,
 	//but for now have it there just so stuff'll compile!
-	BaseEndpointPtr caller(BaseEndpointPtr::dynamicCast(factory->getEndpoint("Butt")));
+	BaseEndpointPtr *caller = new BaseEndpointPtr(BaseEndpointPtr::dynamicCast(factory->getEndpoint("Butt")));
 
 	//We've created our calling endpoint. Now we need to look up the destination.
 	pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
@@ -132,8 +134,17 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	{
 		std::cerr << "[WARNING] Invalid parameters in endpoint lookup. " << std::endl;
 	}
+	//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);
+	if (module == NULL)
+	{
+		std::cerr << "[WARNING] Um, couldn't get the module from the PJSipManger??" << std::endl;
+	}
+	dlg->mod_data[module->id] = (void *)caller;
 	BridgeFactoryPrx bridgeFactory = dataModel.getBridgeFactory();
-	BridgePrx bridge = bridgeFactory->createBridge(caller, endpoints, 0);
+	BridgePrx bridge = bridgeFactory->createBridge(*caller, endpoints, 0);
 }
 
 static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list