[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 15:29:06 CDT 2010


branch "master" has been updated
       via  d4b61f395ec7eba1719c7e9a6b423bcb5af4e5d5 (commit)
      from  d0f797291de1e15d73a4ea45648baa5e2ae96aba (commit)

Summary of changes:
 src/PJSipManager.cpp             |   19 ++++++-------------
 src/PJSipManager.h               |   13 ++++++-------
 src/PJSipSessionModule.cpp       |    5 +++--
 src/SipChannelServiceApp.cpp     |   13 +++++++++++++
 src/SipChannelServiceDataModel.h |    2 ++
 src/SipEndpoint.cpp              |    3 ++-
 6 files changed, 32 insertions(+), 23 deletions(-)


- Log -----------------------------------------------------------------
commit d4b61f395ec7eba1719c7e9a6b423bcb5af4e5d5
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 25 15:29:09 2010 -0500

    Add the PJSipManager to the data model.
    
    PJSipManager is no longer implemented using the singleton pattern.
    Rather, an instance is created on startup and added to the data model.
    Those that need to access the PJSipManager may do so by retrieving
    it through the data model.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 46194eb..cfc7c8c 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -8,8 +8,6 @@ namespace Hydra
 namespace SipChannelService
 {
 
-PJSipManager *PJSipManager::mInstance(new PJSipManager);
-
 static void *monitorThread(void *endpt)
 {
 	pjsip_endpoint *endpoint = static_cast<pjsip_endpoint *> (endpt);
@@ -23,11 +21,6 @@ static void *monitorThread(void *endpt)
 	return NULL;
 }
 
-PJSipManager *PJSipManager::getInstance()
-{
-	return mInstance;
-}
-
 PJSipManager::PJSipManager()
 {
 	pj_status_t status = pj_init();
@@ -46,7 +39,6 @@ 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)
@@ -55,6 +47,12 @@ PJSipManager::PJSipManager()
 	}
 }
 
+void PJSipManager::registerSessionModule()
+{
+	mSessionModule = new PJSipSessionModule();
+}
+
+
 pjsip_endpoint *PJSipManager::getEndpoint()
 {
 	return mEndpoint;
@@ -103,11 +101,6 @@ 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 82396ca..e17853d 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -25,10 +25,7 @@ namespace SipChannelService
 class PJSipManager
 {
 public:
-	/**
-	 * Get the singleton PJSipManager instance
-	 */
-	static PJSipManager *getInstance();
+	PJSipManager();
 	/**
 	 * Get a handle to the PJSipEndpoint for operations
 	 * that may require it
@@ -39,8 +36,11 @@ public:
 	 * Get a pointer to the PJSIP session module
 	 */
 	pjsip_module *getSessionModule();
-protected:
-	PJSipManager();
+	/**
+	 * Register the PJSipSessionModule, responsible
+	 * for basic call handling
+	 */
+	void registerSessionModule();
 private:
 	static PJSipManager *mInstance;
 	pjsip_endpoint *mEndpoint;
@@ -51,7 +51,6 @@ private:
 	pjsip_transport *mUdpTransport;
 
 	bool setTransports(pjsip_endpoint *endpoint);
-	void registerSessionModule();
 };
 
 }; //End namespace SipChannelService
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 0ddb753..f5e43a8 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -134,7 +134,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();
+	PJSipManager *manager = dataModel.getPJSipManager();
 	pjsip_module *module = manager->getSessionModule();
 	if (module == NULL)
 	{
@@ -365,7 +365,8 @@ PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
 		mInvCallback.on_redirected = invOnRedirected;
 	}
 	
-	PJSipManager *manager = PJSipManager::getInstance();
+	SipChannelServiceDataModel &dataModel = SipChannelServiceDataModel::getInstance();
+	PJSipManager *manager = dataModel.getPJSipManager();
 	pjsip_endpoint *endpt = manager->getEndpoint();
 	pjsip_tsx_layer_init_module(endpt);
 	pjsip_ua_init_module(endpt, &mUaParam);
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index ef88619..3a35290 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -73,6 +73,11 @@ public: // Overrides of the  SipChannelServiceDataModel singleton's public inter
       return mServiceLocator;
    }
 
+   virtual PJSipManager *getPJSipManager() const
+   {
+      return mPJSipManager;
+   }
+
    virtual bool IsPaused() const
    {
       return mPaused;
@@ -91,6 +96,7 @@ public: // Implementation details are visible to this file's classes.
    Bridging::V1::BridgeFactoryPrx mBridgeFactory;
    boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
    ServiceLocatorPrx mServiceLocator;
+   PJSipManager *mPJSipManager;
 
    bool mPaused;
 
@@ -138,6 +144,7 @@ private:
 
    Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
    ComponentServicePtr mComponentService;
+   PJSipManager *mPJSipManager;
 };
 
 static const string ComponentServiceId("SipChannelComponent");
@@ -376,6 +383,10 @@ void SipChannelServiceApp::initialize(const std::string appName)
       boost::shared_ptr<SipChannelServiceEventPublisher> eventPublisherPtr(new SipChannelServiceEventPublisher());
       mDataModelInstance.mEventPublisher = eventPublisherPtr;
 
+      // Initialize PJSIP
+	  mPJSipManager = new PJSipManager();
+	  mDataModelInstance.mPJSipManager = mPJSipManager;
+
       // Create the adapter.
       mAdapter = communicator()->createObjectAdapter("SipChannelServiceAdapter");
 
@@ -391,6 +402,8 @@ void SipChannelServiceApp::initialize(const std::string appName)
       mAdapter->add(mComponentService, communicator()->stringToIdentity(ComponentServiceId));
 
       mAdapter->activate();
+
+	  mPJSipManager->registerSessionModule();
    }
    catch(...)
    {
diff --git a/src/SipChannelServiceDataModel.h b/src/SipChannelServiceDataModel.h
index 1d9530d..4cb5b05 100644
--- a/src/SipChannelServiceDataModel.h
+++ b/src/SipChannelServiceDataModel.h
@@ -5,6 +5,7 @@
 #include "RoutingIf.h"
 #include "BridgeServiceIf.h"
 #include "ServiceLocatorIf.h"
+#include "PJSipManager.h"
 
 namespace Hydra
 {
@@ -31,6 +32,7 @@ public:
    virtual Hydra::Core::Bridging::V1::BridgeFactoryPrx getBridgeFactory() const = 0;
    virtual boost::shared_ptr<SipEndpointFactory> getEndpointFactory() const = 0;
    virtual Hydra::Core::Discovery::V1::ServiceLocatorPrx getServiceLocator() const = 0;
+   virtual PJSipManager *getPJSipManager() const = 0;
    virtual bool IsPaused() const = 0;
 
 protected:
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 743f421..96515c5 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -37,7 +37,8 @@ public:
 
 	   // Record our endpoint within the dialog so code handling pjsip events can do STUFF
 	   Hydra::Core::Endpoint::V1::BaseEndpointPtr *baseendpoint = new Hydra::Core::Endpoint::V1::BaseEndpointPtr(Hydra::Core::Endpoint::V1::BaseEndpointPtr::dynamicCast(mEndpoint));
-	   PJSipManager *manager = PJSipManager::getInstance();
+	   SipChannelServiceDataModel &dataModel = SipChannelServiceDataModel::getInstance();
+	   PJSipManager *manager = dataModel.getPJSipManager();
 	   pjsip_module *module = manager->getSessionModule();
 	   if (module == NULL)
 	   {

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list