[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "media" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Jun 15 10:44:37 CDT 2011


branch "media" has been updated
       via  5f517f4e5659e6e5ef45ad974cfdbacfa04f9fe7 (commit)
      from  db491458611fb4760828cdeb9b26d464ce679ed4 (commit)

Summary of changes:
 src/SipSession.cpp |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)


- Log -----------------------------------------------------------------
commit 5f517f4e5659e6e5ef45ad974cfdbacfa04f9fe7
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Jun 15 12:45:18 2011 -0300

    Don't return SDP if it never reaches the point where it actually has media streams.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 3f050c9..1f2bd50 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -95,7 +95,7 @@ public:
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica)
         : mAdapter(adapter), mDialog(0), mInviteSession(0), mEndpoint(endpoint), mDestination(destination),
-          mManager(manager), mServiceLocator(serviceLocator), mReplica(replica), mSDP(0) { };
+          mManager(manager), mServiceLocator(serviceLocator), mReplica(replica), mSDP(0), mSDPFinalized(false) { };
 
     AsteriskSCF::SessionCommunications::V1::SessionInfoPtr getInfo()
     {
@@ -260,6 +260,11 @@ public:
      * SDP that has been produced for this session.
      */
     pjmedia_sdp_session *mSDP;
+
+    /**
+     * Whether the SDP has been finalized or not.
+     */
+    bool mSDPFinalized;
 };
 
 void SipSession::initializePJSIPStructs()
@@ -303,6 +308,7 @@ void SipSession::initializePJSIPStructs()
 
     // Create an SDP offer based on what is configured
     pjmedia_sdp_session *sdp = createSDPOffer();
+
     if ((pjsip_inv_create_uac(dialog, sdp, 0, &inviteSession)) != PJ_SUCCESS)
     {
         pjsip_dlg_terminate(dialog);
@@ -983,7 +989,7 @@ void SipSession::addFormatstoSDP(const FormatSeq& formats, pjmedia_sdp_media *me
 pjmedia_sdp_session *SipSession::createSDPOffer()
 {
     // If SDP has already been produced then just return it, don't recreate it
-    if (mImplPriv->mSDP)
+    if (mImplPriv->mSDPFinalized == true)
     {
         return mImplPriv->mSDP;
     }
@@ -997,8 +1003,11 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
         return 0;
     }
 
-    // Create the most common part of the SDP
-    mImplPriv->mSDP = createSDP();
+    // Create the most common part of the SDP if not already done
+    if (!mImplPriv->mSDP)
+    {
+        mImplPriv->mSDP = createSDP();
+    }
 
     // Iterate through each stream present in the topology
     for (StreamTopologyMap::const_iterator stream = streams.begin();
@@ -1079,9 +1088,12 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
 
         // Push the payload mapping to the RTP session so it'll correctly map things
         session->associatePayloads(payloads);
+
+        // The SDP has been finalized enough
+        mImplPriv->mSDPFinalized = true;
     }
 
-    return mImplPriv->mSDP;
+    return mImplPriv->mSDPFinalized == true ? mImplPriv->mSDP : 0;
 }
 
 /**
@@ -1090,13 +1102,16 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
 pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offer)
 {
     // If SDP has already been produced then just return it, don't recreate it
-    if (mImplPriv->mSDP)
+    if (mImplPriv->mSDPFinalized == true)
     {
         return mImplPriv->mSDP;
     }
 
-    // Create the most common part of the SDP
-    mImplPriv->mSDP = createSDP();
+    // Create the most common part of the SDP if not already done
+    if (!mImplPriv->mSDP)
+    {
+        mImplPriv->mSDP = createSDP();
+    }
 
     // Get the non-stream level connection information in case there is no connection level one
     std::string destination(pj_strbuf(&offer->conn->addr), pj_strlen(&offer->conn->addr));
@@ -1285,9 +1300,12 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
 
         // Push the payload mapping to the RTP session so it'll correctly map things
         session->associatePayloads(payloads);
+
+        // The SDP has been finalized enough
+        mImplPriv->mSDPFinalized = true;
     }
 
-    return mImplPriv->mSDP;
+    return mImplPriv->mSDPFinalized == true ? mImplPriv->mSDP : 0;
 }
 
 /**

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list