[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 20:12:50 CDT 2010


branch "master" has been updated
       via  7bc1df691407587778c421018e2d3eb024c60e69 (commit)
      from  82d65922352574f503be385ce5139d5937b9fae9 (commit)

Summary of changes:
 slice                                    |    2 +-
 src/PJSipSessionModule.cpp               |    5 ++-
 src/SipChannelServiceEndpointLocator.cpp |    4 ++-
 src/SipEndpoint.cpp                      |   36 +++++++++++++++--------------
 src/SipEndpoint.h                        |   20 ++++++++++++++--
 src/SipEndpointFactory.cpp               |    8 +++---
 src/SipEndpointFactory.h                 |    8 ++++--
 7 files changed, 52 insertions(+), 31 deletions(-)


- Log -----------------------------------------------------------------
commit 7bc1df691407587778c421018e2d3eb024c60e69
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 25 22:24:37 2010 -0300

    Pass SipEndpoint around in a fashion that, well, works and is storeable/accessible from pjsip callbacks.

diff --git a/slice b/slice
index d6b2777..dcb271b 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit d6b2777545b3b8eae7c5dc9b40a1ca3ff9e26a43
+Subproject commit dcb271baaca90fa89ed6b7d4846ea458fb303943
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index e0742fd..8d9e2af 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -6,6 +6,7 @@
 #include "PJSipSessionModule.h"
 #include "SipChannelServiceDataModel.h"
 #include "SipEndpoint.h"
+#include "SipEndpointFactory.h"
 #include "PJSipManager.h"
 
 namespace Hydra
@@ -109,7 +110,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 = new BaseEndpointPtr(BaseEndpointPtr::dynamicCast(factory->getEndpoint("Butt")));
+	SipEndpointPtr* caller = new SipEndpointPtr(factory->createEndpoint("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;
@@ -139,7 +140,7 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	//retrieve during signal callbacks.
 	dlg->mod_data[module->id] = (void *)caller;
 	BridgeFactoryPrx bridgeFactory = dataModel.getBridgeFactory();
-	BridgePrx bridge = bridgeFactory->createBridge(*caller, endpoints, 0);
+	BridgePrx bridge = bridgeFactory->createBridge((*caller)->getSessionEndpoint(), endpoints, 0);
 }
 
 static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
diff --git a/src/SipChannelServiceEndpointLocator.cpp b/src/SipChannelServiceEndpointLocator.cpp
index c174dbd..9ed8c06 100644
--- a/src/SipChannelServiceEndpointLocator.cpp
+++ b/src/SipChannelServiceEndpointLocator.cpp
@@ -3,6 +3,7 @@
 
 #include "SipEndpointFactory.h"
 #include "SipChannelServiceEndpointLocator.h"
+#include "SipEndpoint.h"
 
 namespace Hydra
 {
@@ -12,7 +13,8 @@ namespace SipChannelService
 Hydra::Core::Endpoint::V1::EndpointSeq SipChannelServiceEndpointLocator::lookup(const ::std::string& destination, const Ice::Current&)
 {
 	Hydra::Core::Endpoint::V1::EndpointSeq endpoints;
-	endpoints.push_back((*mEndpointFactory).getEndpoint(destination));
+	SipEndpointPtr endpoint = mEndpointFactory->createEndpoint(destination);
+	endpoints.push_back(endpoint->getSessionEndpoint());
 	return endpoints;
 }
 
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 251ec63..2039baa 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -4,6 +4,7 @@
 #include "SipEndpoint.h"
 #include "SipChannelServiceDataModel.h"
 #include "PJSipManager.h"
+#include "SipEndpointFactory.h"
 
 namespace Hydra
 {
@@ -13,7 +14,7 @@ namespace SipChannelService
 class SipSignalCommands : public Hydra::Session::V1::SignalCommands
 {
 public:
-	SipSignalCommands(SipEndpoint *endpoint) : mEndpoint(endpoint) { };
+	SipSignalCommands(SipEndpointPtr endpoint) : mEndpoint(endpoint) { };
 
 	bool call(const Core::Endpoint::V1::EndpointIdPtr& caller, const Core::Endpoint::V1::EndpointIdPtr& destination, const Hydra::Session::V1::SignalCallbackPrx& callback, const Ice::Current&)
 	{
@@ -36,7 +37,6 @@ 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));
 	   SipChannelServiceDataModel &dataModel = SipChannelServiceDataModel::getInstance();
 	   PJSipManager *manager = dataModel.getPJSipManager();
 	   pjsip_module *module = manager->getSessionModule();
@@ -44,7 +44,8 @@ public:
 	   {
 	      std::cerr << "[WARNING] Um, couldn't get the module from the PJSipManger??" << std::endl;
 	   }
-	   dialog->mod_data[module->id] = (void *)baseendpoint;
+	   SipEndpointPtr* endpoint = new SipEndpointPtr(mEndpoint);
+	   dialog->mod_data[module->id] = (void*)endpoint;
 
 	   // Since the SDP generation requires a pool we use the dialog one, so it has to be set here
 	   mEndpoint->setDialog(dialog);
@@ -91,13 +92,13 @@ private:
 	/**
 	 * A pointer to the endpoint that created us.
 	 */
-	SipEndpoint* mEndpoint;
+	SipEndpointPtr mEndpoint;
 };
 
 class SipSignalCallback : public Hydra::Session::V1::SignalCallback
 {
 public:
-	SipSignalCallback(SipEndpoint *endpoint) : mEndpoint(endpoint) { };
+	SipSignalCallback(SipEndpointPtr endpoint) : mEndpoint(endpoint) { };
 
 	void ring(const Core::Endpoint::V1::EndpointIdPtr& ep, const Ice::Current&)
 	{
@@ -182,13 +183,13 @@ private:
 	/**
 	 * A pointer to the endpoint that created us.
 	 */
-	SipEndpoint* mEndpoint;
+	SipEndpointPtr mEndpoint;
 };
 
 class SipMediaSession : public Media::V1::Session
 {
 public:
-SipMediaSession(SipEndpoint *endpoint) : mId(IceUtil::generateUUID()), mEndpoint(endpoint) { };
+SipMediaSession(SipEndpointPtr endpoint) : mId(IceUtil::generateUUID()), mEndpoint(endpoint) { };
 
    Hydra::Media::V1::StreamSourceSeq getSources(const Ice::Current&)
    {
@@ -214,7 +215,7 @@ private:
    /**
     * A pointer to the endpoint that created us.
     */
-   SipEndpoint *mEndpoint;
+   SipEndpointPtr mEndpoint;
 };
 
 /**
@@ -222,16 +223,17 @@ private:
  */
 SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory) : mAdapter(adapter), mEndpointFactory(factory)
 {
-   id = new Hydra::Core::Endpoint::V1::EndpointId();
-   id->endpointManagerId = "pjsip";
-   id->destinationId = IceUtil::generateUUID();
+   mSessionEndpoint = new Hydra::Session::V1::SessionEndpoint();
+   mSessionEndpoint->id = new Hydra::Core::Endpoint::V1::EndpointId();
+   mSessionEndpoint->id->endpointManagerId = "pjsip";
+   mSessionEndpoint->id->destinationId = IceUtil::generateUUID();
 
    mSignalCommands = new SipSignalCommands(this);
-   command = Hydra::Session::V1::SignalCommandsPrx::uncheckedCast(adapter->addWithUUID(mSignalCommands));
+   mSessionEndpoint->command = Hydra::Session::V1::SignalCommandsPrx::uncheckedCast(adapter->addWithUUID(mSignalCommands));
    mSignalCallbacks = new SipSignalCallback(this);
-   callback = Hydra::Session::V1::SignalCallbackPrx::uncheckedCast(adapter->addWithUUID(mSignalCallbacks));
+   mSessionEndpoint->callback = Hydra::Session::V1::SignalCallbackPrx::uncheckedCast(adapter->addWithUUID(mSignalCallbacks));
    mMediaSession = new SipMediaSession(this);
-   mediaSession = Hydra::Media::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(mMediaSession));
+   mSessionEndpoint->mediaSession = Hydra::Media::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(mMediaSession));
 
    // Get an RTP session capable of handling the formats we are going to offer
    Hydra::Media::V1::FormatSeq formats;
@@ -244,11 +246,11 @@ SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEnd
 void SipEndpoint::destroy()
 {
    // Remove all of the different interfaces we have exposed to the world.
-   mAdapter->remove(command->ice_getIdentity());
+   mAdapter->remove(mSessionEndpoint->command->ice_getIdentity());
    mSignalCommands = 0;
-   mAdapter->remove(callback->ice_getIdentity());
+   mAdapter->remove(mSessionEndpoint->callback->ice_getIdentity());
    mSignalCallbacks = 0;
-   mAdapter->remove(mediaSession->ice_getIdentity());
+   mAdapter->remove(mSessionEndpoint->mediaSession->ice_getIdentity());
    mMediaSession = 0;
 
    // Release all the RTP sessions we are using
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 8168c6a..3ea1025 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -15,8 +15,6 @@
 #include <pjlib-util.h>
 #include <pjlib.h>
 
-#include "SipEndpointFactory.h"
-
 namespace Hydra
 {
 
@@ -25,8 +23,9 @@ namespace SipChannelService
 
 class SipSignalCommands;
 class SipSignalCallback;
+class SipEndpointFactory;
 
-class SipEndpoint : public Hydra::Session::V1::SessionEndpoint
+class SipEndpoint : public IceUtil::Shared
 {
 public:
    SipEndpoint(Ice::ObjectAdapterPtr, boost::shared_ptr<SipEndpointFactory>);
@@ -75,6 +74,11 @@ public:
     */
    Hydra::Media::V1::StreamSinkSeq getSinks() { return mSinks; };
 
+   /**
+    * Internal function which returns a SessionEndpoint class.
+    */
+   Hydra::Session::V1::SessionEndpointPtr getSessionEndpoint() { return mSessionEndpoint; };
+
 private:
    void requestRTPSessions(Hydra::Media::V1::FormatSeq& formats);
 
@@ -132,8 +136,18 @@ private:
     * A vector of media sinks associated with this endpoint.
     */
    Hydra::Media::V1::StreamSinkSeq mSinks;
+
+   /**
+    * An instance of SessionEndpoint containing session details.
+    */
+   Hydra::Session::V1::SessionEndpointPtr mSessionEndpoint;
 };
 
+/**
+ * A typedef which creates a smart pointer type for SipEndpoint.
+ */
+typedef IceUtil::Handle<SipEndpoint> SipEndpointPtr;
+
 }; //End namespace SipChannelService
 
 }; //End namespace Hydra
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index 855823d..16f19ff 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -6,16 +6,16 @@ namespace Hydra
 namespace SipChannelService
 {
 
-Hydra::Session::V1::SessionEndpointPtr SipEndpointFactory::getEndpoint(std::string destination)
+SipEndpointPtr SipEndpointFactory::createEndpoint(std::string destination)
 {
-   Hydra::Session::V1::SessionEndpointPtr endpoint = new SipEndpoint(mAdapter, boost::shared_ptr<SipEndpointFactory>(this));
+   SipEndpointPtr endpoint = new SipEndpoint(mAdapter, boost::shared_ptr<SipEndpointFactory>(this));
    mEndpoints.push_back(endpoint);
    return endpoint;
 }
 
-void SipEndpointFactory::remove(Hydra::Session::V1::SessionEndpointPtr endpoint)
+void SipEndpointFactory::remove(SipEndpointPtr endpoint)
 {
-   mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
+//	mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
 }
 
 }; // end SipChannelService
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index cad7eb9..2c8b608 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -3,6 +3,8 @@
 #include <Core/Endpoint/EndpointIf.h>
 #include <Session/SessionIf.h>
 
+#include "SipEndpoint.h"
+
 namespace Hydra
 {
 namespace SipChannelService
@@ -18,9 +20,9 @@ class SipEndpointFactory
 public:
 SipEndpointFactory(Ice::ObjectAdapterPtr adapter) : mAdapter(adapter) { };
 
-   Hydra::Session::V1::SessionEndpointPtr getEndpoint(std::string destination);
+   SipEndpointPtr createEndpoint(std::string destination);
 
-   void remove(Hydra::Session::V1::SessionEndpointPtr);
+   void remove(SipEndpointPtr);
 private:
    /**
     * A pointer to the object adapter that endpoints will be added to.
@@ -30,7 +32,7 @@ private:
    /**
     * A vector of endpoints that this factory has created.
     */
-   std::vector<Hydra::Session::V1::SessionEndpointPtr> mEndpoints;
+   std::vector<SipEndpointPtr> mEndpoints;
 };
 
 }; // end SipChannelService

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list