[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 7 21:44:29 CDT 2010


branch "master" has been updated
       via  68b58eac7851d644c648e07e3ed3c9ee8539fc04 (commit)
       via  e5ca617500e12bb1dec092478afdccd5e0d01d3d (commit)
       via  8849c9c23f42d047681adf2ab6af67c17477e192 (commit)
      from  7e83ed56e0096655fd0bf2adc6beef74ca48ceb0 (commit)

Summary of changes:
 src/SipEndpoint.cpp |   96 +++++++++++++++++++---
 src/SipEndpoint.h   |   36 ++++-----
 src/SipSession.cpp  |  226 ++++++++++++++++++++++++++++++++++++++++-----------
 src/SipSession.h    |  105 ++++--------------------
 4 files changed, 298 insertions(+), 165 deletions(-)


- Log -----------------------------------------------------------------
commit 68b58eac7851d644c648e07e3ed3c9ee8539fc04
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Sep 7 23:51:03 2010 -0300

    Get SipEndpoint implementing the SessionEndpoint interface. Not yet creating sessions though.

diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index e968170..7dd069d 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -12,6 +12,7 @@
 #include "SipChannelServiceDataModel.h"
 #include "PJSipManager.h"
 #include "SipEndpointFactory.h"
+#include "SipSession.h"
 
 namespace AsteriskSCF
 {
@@ -48,6 +49,11 @@ SipEndpointImplPriv(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpoint
     * Configuration for this SIP endpoint.
     */
    SipEndpointConfig mConfig;
+
+   /**
+    * A vector of sessions that exist to or from this endpoint.
+    */
+   std::vector<SipSessionPtr> mSessions;
 };
 
 /**
@@ -161,6 +167,29 @@ bool SipEndpoint::operator==(const std::string &name) const
    return (mImplPriv->mName == name);
 }
 
+std::string SipEndpoint::getId(const Ice::Current&)
+{
+   return "";
+}
+
+AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(const std::string&, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&)
+{
+   AsteriskSCF::SessionCommunications::V1::SessionPrx session;
+   return session;
+}
+
+AsteriskSCF::SessionCommunications::V1::SessionSeq SipEndpoint::getSessions(const Ice::Current&)
+{
+   AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+
+   for (std::vector<SipSessionPtr>::const_iterator session = mImplPriv->mSessions.begin(); session != mImplPriv->mSessions.end(); ++session)
+   {
+      sessions.push_back((*session)->getSessionProxy());
+   }
+
+   return sessions;
+}
+
 SipEndpointConfig &SipEndpoint::getConfig()
 {
    return mImplPriv->mConfig;
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 4e808c5..d6db2e9 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -192,13 +192,17 @@ private:
  */
 class SipEndpointImplPriv;
 
-class SipEndpoint : public IceUtil::Shared
+class SipEndpoint : public AsteriskSCF::SessionCommunications::V1::SessionEndpoint
 {
 public:
    SipEndpoint(Ice::ObjectAdapterPtr, boost::shared_ptr<SipEndpointFactory>, std::string name, Ice::PropertyDict props);
 
    bool operator==(const std::string &name) const;
 
+   std::string getId(const Ice::Current&);
+   AsteriskSCF::SessionCommunications::V1::SessionPrx createSession(const std::string&, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);
+   AsteriskSCF::SessionCommunications::V1::SessionSeq getSessions(const Ice::Current&);
+
    SipEndpointConfig &getConfig();
 
    std::string getName();

commit e5ca617500e12bb1dec092478afdccd5e0d01d3d
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Sep 7 23:41:54 2010 -0300

    Apply pimpl approach to SipEndpoint.

diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index e4048c3..e968170 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -19,10 +19,42 @@ namespace SipChannelService
 {
 
 /**
+ * Private implementation details for SipEndpoint.
+ */
+class SipEndpointImplPriv
+{
+public:
+   /**
+    * Constructor for the SipEndpointImplPriv class.
+    */
+SipEndpointImplPriv(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory, std::string name) :
+   mName(name), mAdapter(adapter), mEndpointFactory(factory) { };
+   /**
+    * The name of the endpoint.
+    */
+   std::string mName;
+
+   /**
+    * The Ice object adapter that our proxies were added to.
+    */
+   Ice::ObjectAdapterPtr mAdapter;
+
+   /**
+    * The endpoint factory that created us.
+    */
+   boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
+
+   /**
+    * Configuration for this SIP endpoint.
+    */
+   SipEndpointConfig mConfig;
+};
+
+/**
  * Default constructor.
  */
 SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory, std::string name, Ice::PropertyDict props)
-: mName(name)
+   : mImplPriv(new SipEndpointImplPriv(adapter, factory, name))
 {
    std::cout << "Constructing SIP endpoint " << name << std::endl;
 
@@ -42,7 +74,7 @@ void SipEndpoint::setConfiguration(Ice::PropertyDict props)
 void SipEndpoint::setTransportConfiguration(Ice::PropertyDict props)
 {
 	std::string prefix("Sip.Endpoint.");
-	prefix.append(mName);
+	prefix.append(mImplPriv->mName);
 	prefix.append(".Transport.");
 	// Got the basic prefix. Now get the known config options.
 	Ice::PropertyDict::iterator IpAddress = props.find(prefix + "Address");
@@ -53,34 +85,34 @@ void SipEndpoint::setTransportConfiguration(Ice::PropertyDict props)
 		pj_cstr(&addr, IpAddress->second.c_str());
 		if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &sockaddr) != PJ_SUCCESS)
 		{
-			std::cerr << "[ERROR] Bad address specifier in transport configuration for SIP endpoint " << mName << std::endl;
+			std::cerr << "[ERROR] Bad address specifier in transport configuration for SIP endpoint " << mImplPriv->mName << std::endl;
 		}
 		else
 		{
-			mConfig.transportConfig.address = IpAddress->second;
+			mImplPriv->mConfig.transportConfig.address = IpAddress->second;
 		}
 	}
 	Ice::PropertyDict::iterator direction = props.find(prefix + "SecureTransport");
 	if (direction != props.end())
 	{
-		mConfig.transportConfig.secureTransport = SipEndpointConfig::stringToDirection(direction->second);
+		mImplPriv->mConfig.transportConfig.secureTransport = SipEndpointConfig::stringToDirection(direction->second);
 	}
 	Ice::PropertyDict::iterator user = props.find(prefix + "User");
 	if (user != props.end())
 	{
-		mConfig.transportConfig.user = user->second;
+		mImplPriv->mConfig.transportConfig.user = user->second;
 	}
 }
 
 void SipEndpoint::setSessionConfiguration(Ice::PropertyDict props)
 {
 	std::string prefix("Sip.Endpoint");
-	prefix.append(mName);
+	prefix.append(mImplPriv->mName);
 	prefix.append(".Session.");
 	Ice::PropertyDict::iterator direction = props.find(prefix + "CallDirection");
 	if (direction != props.end())
 	{
-		mConfig.sessionConfig.callDirection = SipEndpointConfig::stringToDirection(direction->second);
+		mImplPriv->mConfig.sessionConfig.callDirection = SipEndpointConfig::stringToDirection(direction->second);
 	}
 	Ice::PropertyDict::iterator address = props.find(prefix + "SourceAddress");
 	if (address != props.end())
@@ -90,11 +122,11 @@ void SipEndpoint::setSessionConfiguration(Ice::PropertyDict props)
 		pj_cstr(&addr, address->second.c_str());
 		if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &sockaddr) != PJ_SUCCESS)
 		{
-			std::cerr << "[ERROR] Bad address specifier in session configuration for SIP endpoint " << mName << std::endl;
+			std::cerr << "[ERROR] Bad address specifier in session configuration for SIP endpoint " << mImplPriv->mName << std::endl;
 		}
 		else
 		{
-			mConfig.sessionConfig.sourceAddress = address->second;
+			mImplPriv->mConfig.sessionConfig.sourceAddress = address->second;
 		}
 	}
 }
@@ -124,5 +156,20 @@ Direction SipEndpointConfig::stringToDirection(std::string directionString)
 	}
 }
 
+bool SipEndpoint::operator==(const std::string &name) const
+{
+   return (mImplPriv->mName == name);
+}
+
+SipEndpointConfig &SipEndpoint::getConfig()
+{
+   return mImplPriv->mConfig;
+};
+
+std::string SipEndpoint::getName()
+{
+   return mImplPriv->mName;
+};
+
 }; // end SipChannelService
 }; // end AsteriskSCF
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index af5bf18..4e808c5 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -187,30 +187,27 @@ public:
 private:
 };
 
+/**
+ * Private implementation details for SipEndpoint.
+ */
+class SipEndpointImplPriv;
+
 class SipEndpoint : public IceUtil::Shared
 {
 public:
    SipEndpoint(Ice::ObjectAdapterPtr, boost::shared_ptr<SipEndpointFactory>, std::string name, Ice::PropertyDict props);
 
-   bool operator==(const std::string &name) const
-   {
-      return (mName == name);
-   }
+   bool operator==(const std::string &name) const;
 
-   SipEndpointConfig &getConfig() { return mConfig; };
+   SipEndpointConfig &getConfig();
 
-   std::string getName() { return mName; };
+   std::string getName();
 
 private:
    /**
-    * The Ice object adapter that our proxies were added to.
+    * Private implementation details.
     */
-   Ice::ObjectAdapterPtr mAdapter;
-
-   /**
-    * The endpoint factory that created us.
-    */
-   boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
+   boost::shared_ptr<SipEndpointImplPriv> mImplPriv;
 
    /**
     * Set up configuration for the endpoint
@@ -224,13 +221,6 @@ private:
    void setAuthConfiguration(Ice::PropertyDict props);
    void setMediaConfiguration(Ice::PropertyDict props);
    void setSubscriptionConfiguration(Ice::PropertyDict props);
-
-   /**
-	* The name of the endpoint
-	*/
-   std::string mName;
-
-   SipEndpointConfig mConfig;
 };
 
 /**

commit 8849c9c23f42d047681adf2ab6af67c17477e192
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Sep 7 23:30:08 2010 -0300

    Apply pimpl approach to SipSession.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 56f9e18..2790456 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -53,15 +53,81 @@ private:
 };
 
 /**
+ * Private implementation details for SipSession.
+ */
+class SipSessionPriv
+{
+public:
+   /**
+    * Constructor for the SipSessionPriv class.
+    */
+SipSessionPriv(Ice::ObjectAdapterPtr adapter, SipEndpointPtr endpoint) : mAdapter(adapter), mEndpoint(endpoint) { };
+   /**
+    * An instance of a media session.
+    */
+   AsteriskSCF::Media::V1::SessionPtr mMediaSession;
+
+   /**
+    * A proxy to the above media session.
+    */
+   AsteriskSCF::Media::V1::SessionPrx mMediaSessionProxy;
+
+   /**
+    * A proxy to this communications session.
+    */
+   AsteriskSCF::SessionCommunications::V1::SessionPrx mSessionProxy;
+
+   /**
+    * The Ice object adapter that our proxies were added to.
+    */
+   Ice::ObjectAdapterPtr mAdapter;
+
+   /**
+    * PJsip dialog for this endpoint.
+    */
+   pjsip_dialog *mDialog;
+
+   /**
+    * PJsip INVITE session for this endpoint.
+    */
+   pjsip_inv_session *mInviteSession;
+
+   /**
+    * A vector of RTP media sessions belonging to this endpoint.
+    */
+   std::vector<AsteriskSCF::Media::RTP::V1::RTPSessionPrx> mRTPSessions;
+
+   /**
+    * A vector of media sources associated with this endpoint.
+    */
+   AsteriskSCF::Media::V1::StreamSourceSeq mSources;
+
+   /**
+    * A vector of media sinks associated with this endpoint.
+    */
+   AsteriskSCF::Media::V1::StreamSinkSeq mSinks;
+
+   /**
+    * The endpoint that we belong to.
+    */
+   SipEndpointPtr mEndpoint;
+
+   /**
+    * A vector of listeners that want to be notified of responses from the SIP endpoint.
+    */
+   std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> mListeners;
+};
+
+/**
  * Default constructor.
  */
 SipSession::SipSession(Ice::ObjectAdapterPtr adapter, SipEndpointPtr endpoint)
-: mAdapter(adapter), mEndpoint(endpoint)
+   : mImplPriv(new SipSessionPriv(adapter, endpoint))
 {
-   mSessionProxy = AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(this));
+   mImplPriv->mSessionProxy = AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(this));
 
-   mMediaSession = new SipMediaSession(this);
-   mMediaSessionProxy = AsteriskSCF::Media::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(mMediaSession));
+   mImplPriv->mMediaSession = new SipMediaSession(this);
+   mImplPriv->mMediaSessionProxy = AsteriskSCF::Media::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(mImplPriv->mMediaSession));
 
    // Get an RTP session capable of handling the formats we are going to offer
    AsteriskSCF::Media::V1::FormatSeq formats;
@@ -70,7 +136,7 @@ SipSession::SipSession(Ice::ObjectAdapterPtr adapter, SipEndpointPtr endpoint)
 
 AsteriskSCF::SessionCommunications::V1::SessionInfoPtr SipSession::addListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current& current)
 {
-   mListeners.push_back(listener);
+   mImplPriv->mListeners.push_back(listener);
    return getInfo(current);
 }
 
@@ -82,9 +148,9 @@ void SipSession::connect(const Ice::Current&)
 {
    pjmedia_sdp_session *sdp = createSDPOffer();
    pjsip_tx_data *packet;
-   if ((pjsip_inv_answer(mInviteSession, 200, NULL, sdp, &packet)) == PJ_SUCCESS)
+   if ((pjsip_inv_answer(mImplPriv->mInviteSession, 200, NULL, sdp, &packet)) == PJ_SUCCESS)
    {
-      pjsip_inv_send_msg(mInviteSession, packet);
+      pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
    }
 }
 
@@ -120,7 +186,7 @@ AsteriskSCF::SessionCommunications::V1::SessionInfoPtr SipSession::getInfo(const
  */
 AsteriskSCF::Media::V1::SessionPrx SipSession::getMediaSession(const Ice::Current&)
 {
-   return mMediaSessionProxy;
+   return mImplPriv->mMediaSessionProxy;
 }
 
 /**
@@ -134,9 +200,9 @@ void SipSession::hold(const Ice::Current&)
    // TODO: This is actually passing the hold through, we will need to support local generation
 
    pjsip_tx_data *packet;
-   if ((pjsip_inv_reinvite(mInviteSession, NULL, NULL, &packet)) == PJ_SUCCESS)
+   if ((pjsip_inv_reinvite(mImplPriv->mInviteSession, NULL, NULL, &packet)) == PJ_SUCCESS)
    {
-      pjsip_inv_send_msg(mInviteSession, packet);
+      pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
    }
 }
 
@@ -148,9 +214,9 @@ void SipSession::progress(const AsteriskSCF::SessionCommunications::V1::Response
 {
    pjmedia_sdp_session *sdp = createSDPOffer();
    pjsip_tx_data *packet;
-   if ((pjsip_inv_answer(mInviteSession, 183, NULL, sdp, &packet)) == PJ_SUCCESS)
+   if ((pjsip_inv_answer(mImplPriv->mInviteSession, 183, NULL, sdp, &packet)) == PJ_SUCCESS)
    {
-      pjsip_inv_send_msg(mInviteSession, packet);
+      pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
    }
 }
 
@@ -159,7 +225,7 @@ void SipSession::progress(const AsteriskSCF::SessionCommunications::V1::Response
  */
 void SipSession::removeListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current&)
 {
-   mListeners.erase(std::remove(mListeners.begin(), mListeners.end(), listener), mListeners.end());
+   mImplPriv->mListeners.erase(std::remove(mImplPriv->mListeners.begin(), mImplPriv->mListeners.end(), listener), mImplPriv->mListeners.end());
 }
 
 /**
@@ -170,9 +236,9 @@ void SipSession::ring(const Ice::Current&)
 {
    pjsip_tx_data *packet;
 
-   if ((pjsip_inv_answer(mInviteSession, 180, NULL, NULL, &packet)) == PJ_SUCCESS)
+   if ((pjsip_inv_answer(mImplPriv->mInviteSession, 180, NULL, NULL, &packet)) == PJ_SUCCESS)
    {
-      pjsip_inv_send_msg(mInviteSession, packet);
+      pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
    }
 }
 
@@ -184,7 +250,7 @@ void SipSession::start(const Ice::Current&)
 {
    pj_str_t local_uri, remote_uri;
    pjsip_dialog *dialog;
-   SipEndpointConfig &config = mEndpoint->getConfig();
+   SipEndpointConfig &config = mImplPriv->mEndpoint->getConfig();
 
    char local[64];
    pj_ansi_sprintf(local, "sip:%s", config.sessionConfig.sourceAddress.c_str());
@@ -210,7 +276,7 @@ void SipSession::start(const Ice::Current&)
    dialog->mod_data[pjsip_ua_instance()->id] = (void*)session;
 
    // Since the SDP generation requires a pool we use the dialog one, so it has to be set here
-   mDialog = dialog;
+   mImplPriv->mDialog = dialog;
 
    pjmedia_sdp_session *sdp = createSDPOffer();
 
@@ -234,7 +300,7 @@ void SipSession::start(const Ice::Current&)
    }
 
    // Before we send the message we probably should populate the endpoint data... just in case
-   mInviteSession = inviteSession;
+   mImplPriv->mInviteSession = inviteSession;
 
    // Boom! Houston, we have transmission.
    pjsip_inv_send_msg(inviteSession, packet);
@@ -256,9 +322,9 @@ void SipSession::stop(const AsteriskSCF::SessionCommunications::V1::ResponseCode
       code = 486;
    }
 
-   if ((pjsip_inv_end_session(mInviteSession, 503, NULL, &packet)) == PJ_SUCCESS)
+   if ((pjsip_inv_end_session(mImplPriv->mInviteSession, 503, NULL, &packet)) == PJ_SUCCESS)
    {
-      pjsip_inv_send_msg(mInviteSession, packet);
+      pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
    }
 }
 
@@ -273,9 +339,9 @@ void SipSession::unhold(const Ice::Current&)
    // TODO: This is actually passing the unhold through, we will need to support local generation
 
    pjsip_tx_data *packet;
-   if ((pjsip_inv_reinvite(mInviteSession, NULL, NULL, &packet)) == PJ_SUCCESS)
+   if ((pjsip_inv_reinvite(mImplPriv->mInviteSession, NULL, NULL, &packet)) == PJ_SUCCESS)
    {
-      pjsip_inv_send_msg(mInviteSession, packet);
+      pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
    }
 }
 
@@ -285,12 +351,12 @@ void SipSession::unhold(const Ice::Current&)
 void SipSession::destroy()
 {
    // Remove all of the different interfaces we have exposed to the world.
-   mAdapter->remove(mSessionProxy->ice_getIdentity());
-   mAdapter->remove(mMediaSessionProxy->ice_getIdentity());
-   mMediaSession = 0;
+   mImplPriv->mAdapter->remove(mImplPriv->mSessionProxy->ice_getIdentity());
+   mImplPriv->mAdapter->remove(mImplPriv->mMediaSessionProxy->ice_getIdentity());
+   mImplPriv->mMediaSession = 0;
 
    // Release all the RTP sessions we are using
-   for (std::vector<AsteriskSCF::Media::RTP::V1::RTPSessionPrx>::const_iterator i = mRTPSessions.begin(); i != mRTPSessions.end(); ++i)
+   for (std::vector<AsteriskSCF::Media::RTP::V1::RTPSessionPrx>::const_iterator i = mImplPriv->mRTPSessions.begin(); i != mImplPriv->mRTPSessions.end(); ++i)
    {
       (*i)->release();
    }
@@ -303,37 +369,37 @@ void SipSession::destroy()
  */
 pjmedia_sdp_session *SipSession::createSDPOffer()
 {
-   pjmedia_sdp_session *sdp = static_cast<pjmedia_sdp_session*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_session)));
+   pjmedia_sdp_session *sdp = static_cast<pjmedia_sdp_session*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_session)));
 
-   pj_strdup2(mDialog->pool, &sdp->origin.user, "AsteriskSCF");
+   pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.user, "AsteriskSCF");
    pj_time_val tv;
    pj_gettimeofday(&tv);
    sdp->origin.version = sdp->origin.id = tv.sec + 2208988800UL;
-   pj_strdup2(mDialog->pool, &sdp->origin.net_type, "IN");
-   pj_strdup2(mDialog->pool, &sdp->origin.addr_type, "IP4");
+   pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.net_type, "IN");
+   pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.addr_type, "IP4");
    sdp->origin.addr = *pj_gethostname();
-   pj_strdup2(mDialog->pool, &sdp->name, "sip");
+   pj_strdup2(mImplPriv->mDialog->pool, &sdp->name, "sip");
    sdp->time.start = 0;
    sdp->time.stop = 0;
    sdp->attr_count = 0;
 
    // Right now we only support a single stream so go and get it
-   AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx stream = AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx::uncheckedCast(mSources.front());
+   AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx stream = AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx::uncheckedCast(mImplPriv->mSources.front());
 
    // Add connection details at the session level since we currently only support one media stream.
-   sdp->conn = static_cast<pjmedia_sdp_conn*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_conn)));
+   sdp->conn = static_cast<pjmedia_sdp_conn*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_conn)));
    sdp->conn->net_type = sdp->origin.net_type;
    sdp->conn->addr_type = sdp->origin.addr_type;
-   pj_strdup2(mDialog->pool, &sdp->conn->addr, stream->getLocalAddress().c_str());
+   pj_strdup2(mImplPriv->mDialog->pool, &sdp->conn->addr, stream->getLocalAddress().c_str());
 
    // Add a single media stream
    sdp->media_count = 1;
-   pjmedia_sdp_media* media = static_cast<pjmedia_sdp_media*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_media)));
+   pjmedia_sdp_media* media = static_cast<pjmedia_sdp_media*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_media)));
    sdp->media[0] = media;
-   pj_strdup2(mDialog->pool, &media->desc.media, "audio");
+   pj_strdup2(mImplPriv->mDialog->pool, &media->desc.media, "audio");
    media->desc.port = stream->getLocalPort();
    media->desc.port_count = 1;
-   pj_strdup2(mDialog->pool, &media->desc.transport, "RTP/AVP");
+   pj_strdup2(mImplPriv->mDialog->pool, &media->desc.transport, "RTP/AVP");
 
    // Populate the stream with codec details
    sdp->media[0]->desc.fmt_count = 1;
@@ -344,17 +410,17 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
    pjmedia_sdp_attr *attr;
 
    // This is hardcoded value for ULAW for now
-   pj_strdup2(mDialog->pool, &media->desc.fmt[0], "0");
+   pj_strdup2(mImplPriv->mDialog->pool, &media->desc.fmt[0], "0");
    rtpmap.pt = media->desc.fmt[0];
    rtpmap.clock_rate = 8000;
-   pj_strdup2(mDialog->pool, &rtpmap.enc_name, "PCMU");
+   pj_strdup2(mImplPriv->mDialog->pool, &rtpmap.enc_name, "PCMU");
    rtpmap.param.slen = 0;
-   pjmedia_sdp_rtpmap_to_attr(mDialog->pool, &rtpmap, &attr);
+   pjmedia_sdp_rtpmap_to_attr(mImplPriv->mDialog->pool, &rtpmap, &attr);
    sdp->media[0]->attr[sdp->media[0]->attr_count++] = attr;
 
    // Might as well add sendrecv
-   attr = static_cast<pjmedia_sdp_attr*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_attr)));
-   pj_strdup2(mDialog->pool, &attr->name, "sendrecv");
+   attr = static_cast<pjmedia_sdp_attr*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_attr)));
+   pj_strdup2(mImplPriv->mDialog->pool, &attr->name, "sendrecv");
    sdp->media[0]->attr[sdp->media[0]->attr_count++] = attr;
 
    return sdp;
@@ -372,13 +438,13 @@ void SipSession::requestRTPSessions(AsteriskSCF::Media::V1::FormatSeq& formats)
    SipChannelServiceDataModel& mDataModelInstance(SipChannelServiceDataModel::getInstance());
    AsteriskSCF::Media::RTP::V1::RTPMediaServicePrx factory = AsteriskSCF::Media::RTP::V1::RTPMediaServicePrx::uncheckedCast(mDataModelInstance.getServiceLocator()->locate(params));
    AsteriskSCF::Media::RTP::V1::RTPSessionPrx session = factory->allocate(formats);
-   mRTPSessions.push_back(session);
+   mImplPriv->mRTPSessions.push_back(session);
 
    // Create a local copy of the sources, this won't get changed by the RTP session so it's all good
-   mSources = session->getSources();
+   mImplPriv->mSources = session->getSources();
 
    // Create a local copy of the sinks, this won't get changed by the RTP session so it's all good
-   mSinks = session->getSinks();
+   mImplPriv->mSinks = session->getSinks();
 
    // For testing push a static payload mapping for ULAW into the RTP session
    AsteriskSCF::Media::RTP::V1::PayloadMap payloads;
@@ -398,9 +464,77 @@ void SipSession::requestRTPSessions(AsteriskSCF::Media::V1::FormatSeq& formats)
  */
 void SipSession::setRemoteDetails(std::string destination, int port)
 {
-   AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx sink = AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx::uncheckedCast(mSinks.front());
+   AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx sink = AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx::uncheckedCast(mImplPriv->mSinks.front());
    sink->setRemoteDetails(destination, port);
 }
 
+/**
+ * Internal function which sets the PJsip dialog.
+ */
+void SipSession::setDialog(pjsip_dialog *dialog)
+{
+   mImplPriv->mDialog = dialog;
+}
+
+/**
+ * Internal function which gets the PJsip dialog.
+ */
+pjsip_dialog *SipSession::getDialog()
+{
+   return mImplPriv->mDialog;
+}
+
+/**
+ * Internal function which sets the PJsip INVITE session.
+ */
+void SipSession::setInviteSession(pjsip_inv_session *session)
+{
+   mImplPriv->mInviteSession = session;
+}
+
+/**
+ * Internal function which gets the PJsip INVITE session.
+ */
+pjsip_inv_session *SipSession::getInviteSession()
+{
+   return mImplPriv->mInviteSession;
+}
+
+/**
+ * Internal function which gets the media sources on the endpoint.
+ */
+AsteriskSCF::Media::V1::StreamSourceSeq& SipSession::getSources()
+{
+   return mImplPriv->mSources;
+}
+
+/**
+ * Internal function which gets the media sinks on the endpoint.
+ */
+AsteriskSCF::Media::V1::StreamSinkSeq& SipSession::getSinks()
+{
+   return mImplPriv->mSinks;
+}
+
+/**
+ * Internal function which gets the listeners on this session.
+ */
+std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& SipSession::getListeners()
+{
+   return mImplPriv->mListeners;
+}
+
+/**
+ * Internal function which gets the proxy to the session.
+ */
+AsteriskSCF::SessionCommunications::V1::SessionPrx& SipSession::getSessionProxy()
+{
+   return mImplPriv->mSessionProxy;
+}
+
+bool SipSession::operator==(const SipSession &other) const {
+   return (this->mImplPriv->mInviteSession == other.mImplPriv->mInviteSession);
+}
+
 }; // end SipChannelService
 }; // end AsteriskSCF
diff --git a/src/SipSession.h b/src/SipSession.h
index 4a8b3b3..559a56c 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -32,6 +32,11 @@ namespace SipChannelService
 {
 
 /*
+ * Private implementation class for SipSession.
+ */
+class SipSessionPriv;
+
+/*
  * Implementation of the Session interface as defined in SessionCommunicationsIf.ice
  */
 class SipSession : public AsteriskSCF::SessionCommunications::V1::Session
@@ -39,9 +44,7 @@ class SipSession : public AsteriskSCF::SessionCommunications::V1::Session
 public:
    SipSession(Ice::ObjectAdapterPtr, SipEndpointPtr);
 
-   bool operator==(const SipSession &other) const {
-      return (this->mInviteSession == other.mInviteSession);
-   }
+   bool operator==(const SipSession &other) const;
 
    /**
     * Interface specific functions.
@@ -67,104 +70,30 @@ public:
 
    pjmedia_sdp_session *createSDPOffer();
 
-   void setRemoteDetails(std::string destination, int port);
+   void setRemoteDetails(std::string, int);
 
-   /**
-    * Internal function which sets the PJsip dialog.
-    */
-   void setDialog(pjsip_dialog *dialog) { mDialog = dialog; };
+   void setDialog(pjsip_dialog *dialog);
 
-   /**
-    * Internal function which gets the PJsip dialog.
-    */
-   pjsip_dialog *getDialog() { return mDialog; };
+   pjsip_dialog *getDialog();
 
-   /**
-    * Internal function which sets the PJsip INVITE session.
-    */
-   void setInviteSession(pjsip_inv_session *session) { mInviteSession = session; };
+   void setInviteSession(pjsip_inv_session *session);
 
-   /**
-    * Internal function which gets the PJsip INVITE session.
-    */
-   pjsip_inv_session *getInviteSession() { return mInviteSession; };
+   pjsip_inv_session *getInviteSession();
 
-   /**
-    * Internal function which gets the media sources on the endpoint.
-    */
-   AsteriskSCF::Media::V1::StreamSourceSeq& getSources() { return mSources; };
+   AsteriskSCF::Media::V1::StreamSourceSeq& getSources();
 
-   /**
-    * Internal function which gets the media sinks on the endpoint.
-    */
-   AsteriskSCF::Media::V1::StreamSinkSeq& getSinks() { return mSinks; };
+   AsteriskSCF::Media::V1::StreamSinkSeq& getSinks();
 
-   /**
-    * Internal function which gets the listeners on this session.
-    */
-   std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& getListeners() { return mListeners; };
+   std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>& getListeners();
 
-   /**
-    * Internal function which gets the proxy to the session.
-    */
-   AsteriskSCF::SessionCommunications::V1::SessionPrx& getSessionProxy() { return mSessionProxy; };
+   AsteriskSCF::SessionCommunications::V1::SessionPrx& getSessionProxy();
 private:
    void requestRTPSessions(AsteriskSCF::Media::V1::FormatSeq& formats);
 
    /**
-    * An instance of a media session.
-    */
-   AsteriskSCF::Media::V1::SessionPtr mMediaSession;
-
-   /**
-    * A proxy to the above media session.
-    */
-   AsteriskSCF::Media::V1::SessionPrx mMediaSessionProxy;
-
-   /**
-    * A proxy to this communications session.
-    */
-   AsteriskSCF::SessionCommunications::V1::SessionPrx mSessionProxy;
-
-   /**
-    * The Ice object adapter that our proxies were added to.
-    */
-   Ice::ObjectAdapterPtr mAdapter;
-
-   /**
-    * PJsip dialog for this endpoint.
-    */
-   pjsip_dialog *mDialog;
-
-   /**
-    * PJsip INVITE session for this endpoint.
-    */
-   pjsip_inv_session *mInviteSession;
-
-   /**
-    * A vector of RTP media sessions belonging to this endpoint.
-    */
-   std::vector<AsteriskSCF::Media::RTP::V1::RTPSessionPrx> mRTPSessions;
-
-   /**
-    * A vector of media sources associated with this endpoint.
-    */
-   AsteriskSCF::Media::V1::StreamSourceSeq mSources;
-
-   /**
-    * A vector of media sinks associated with this endpoint.
-    */
-   AsteriskSCF::Media::V1::StreamSinkSeq mSinks;
-
-   /**
-    * The endpoint that we belong to.
-    */
-   SipEndpointPtr mEndpoint;
-
-   /**
-    * A vector of listeners that want to be notified of responses from the SIP endpoint.
+    * Private implementation details.
     */
-   std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> mListeners;
+   boost::shared_ptr<SipSessionPriv> mImplPriv;
 };
 
 /**

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list