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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sat Jul 23 18:05:55 CDT 2011


branch "sessioncontroller" has been updated
       via  6def3ef1608104dd66c9a8128a976a8c248495fc (commit)
       via  105dae6cef0812e024b028f0831bbd70e26f3d8e (commit)
       via  602337e57720cd9ab0689d440a1c39143de50d1e (commit)
      from  9301688146850ecb9237fb8cf8393b54a6e4e0be (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |    4 +-
 src/SipSession.cpp         |   64 ++++++++++++++++++++++++++++++++++++++++---
 src/SipSession.h           |    3 +-
 3 files changed, 63 insertions(+), 8 deletions(-)


- Log -----------------------------------------------------------------
commit 6def3ef1608104dd66c9a8128a976a8c248495fc
Author: Joshua Colp <jcolp at digium.com>
Date:   Sat Jul 23 19:30:13 2011 -0300

    Fix a bug where formats requested in added streams were not filtered against configured formats on the endpoint.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 6f0dbba..87275ba 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -374,16 +374,16 @@ protected:
         // Create an SDP offer or answer
 	const pjmedia_sdp_session *remote_sdp = NULL;
         pjmedia_sdp_session *sdp;
+        StreamInformationDict streams;
 
 	if (!mInv->neg || (pjmedia_sdp_neg_get_neg_remote(mInv->neg, &remote_sdp) != PJ_SUCCESS))
         {
             // No SDP was present in the INVITE so we need to create an offer
-            sdp = mSession->createSDPOffer(StreamInformationDict());
+            sdp = mSession->createSDPOffer(StreamInformationDict(), streams);
         }
         else
         {
             // SDP was present in the INVITE so we need to create an answer using their offer
-            StreamInformationDict streams;
             sdp = mSession->createSDPAnswer(remote_sdp, streams);
         }
 
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 553583f..5201ce7 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -446,7 +446,15 @@ public:
         }
 
         // Create an offer adding in the requested streams
-        pjmedia_sdp_session *sdp = mSession->createSDPOffer(mStreams);
+        StreamInformationDict added;
+        pjmedia_sdp_session *sdp = mSession->createSDPOffer(mStreams, added);
+
+        // If no streams were actually added respond back appropriately
+        if (added.empty())
+        {
+            mCb->ice_response(StreamInformationDict());
+            return Complete;
+        }
 
         // Store callback information so when the remote party responds with which streams were accepted we can
         // communicate it to the controller
@@ -601,7 +609,8 @@ void SipSession::initializePJSIPStructs()
     pjsip_inv_session *inviteSession;
 
     // Create an SDP offer based on what is configured
-    pjmedia_sdp_session *sdp = createSDPOffer(StreamInformationDict());
+    StreamInformationDict added;
+    pjmedia_sdp_session *sdp = createSDPOffer(StreamInformationDict(), added);
 
     if ((pjsip_inv_create_uac(dialog, sdp, 0, &inviteSession)) != PJ_SUCCESS)
     {
@@ -1577,7 +1586,8 @@ void SipSession::addFormatstoSDP(const FormatSeq& formats, pjmedia_sdp_media *me
 /**
  * Internal function called to produce an SDP session structure using configuration and provided streams
  */
-pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::StreamInformationDict& streams)
+pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::StreamInformationDict& streams,
+                                                AsteriskSCF::Media::V1::StreamInformationDict& newStreams)
 {
     StreamInformationDict requestedStreams = streams;
 
@@ -1608,6 +1618,28 @@ pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::St
         stream->second->sources.clear();
         stream->second->sinks.clear();
 
+        // Determine the actual formats we can handle
+        FormatSeq formats;
+
+        for (FormatSeq::const_iterator format = stream->second->formats.begin();
+             format != stream->second->formats.end();
+             ++format)
+        {
+            if (mImplPriv->mEndpoint->getDescriptor(*format) != 0)
+            {
+                formats.push_back(*format);
+            }
+        }
+
+        // If no compatible formats were provided skip this stream
+        if (formats.empty())
+        {
+            continue;
+        }
+
+        // Update the stream with the actual formats
+        stream->second->formats = formats;
+
         RTPServiceLocatorParamsPtr params = new RTPServiceLocatorParams();
         params->category = "rtp";
         params->formats = stream->second->formats;
@@ -1689,6 +1721,9 @@ pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::St
         // Push the payload mapping to the RTP session so it'll correctly map things
         session->associatePayloads(payloads);
 
+        // Make the caller aware of this new stream
+        newStreams.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count), stream->second));
+
         // Since this is a newly added stream record it as such until the remote party accepts or declines it
         mImplPriv->mNewStreams.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count), stream->second));
 
diff --git a/src/SipSession.h b/src/SipSession.h
index f82a369..e6c82fb 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -188,7 +188,8 @@ public:
      */
     void destroy();
 
-    pjmedia_sdp_session *createSDPOffer(const AsteriskSCF::Media::V1::StreamInformationDict&);
+    pjmedia_sdp_session *createSDPOffer(const AsteriskSCF::Media::V1::StreamInformationDict&,
+                                        AsteriskSCF::Media::V1::StreamInformationDict&);
 
     pjmedia_sdp_session *createSDPAnswer(const pjmedia_sdp_session*,
                                          AsteriskSCF::Media::V1::StreamInformationDict&);

commit 105dae6cef0812e024b028f0831bbd70e26f3d8e
Author: Joshua Colp <jcolp at digium.com>
Date:   Sat Jul 23 19:14:48 2011 -0300

    Do not assume that sources and sinks will be clear when asked to add streams.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index aec0cb3..553583f 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -1604,6 +1604,10 @@ pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::St
          stream != requestedStreams.end();
          ++stream)
     {
+        // Remove any provided values that we will overwrite
+        stream->second->sources.clear();
+        stream->second->sinks.clear();
+
         RTPServiceLocatorParamsPtr params = new RTPServiceLocatorParams();
         params->category = "rtp";
         params->formats = stream->second->formats;

commit 602337e57720cd9ab0689d440a1c39143de50d1e
Author: Joshua Colp <jcolp at digium.com>
Date:   Sat Jul 23 19:14:36 2011 -0300

    Always respond to an addStreams request and if streams were actually added respond back with the identities provided by the invoker.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 642b191..aec0cb3 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -296,6 +296,11 @@ public:
      * have been added.
      */
     AsteriskSCF::SessionCommunications::V1::AMD_SessionController_addStreamsPtr mAddStreamsCb;
+
+    /**
+     * A mapping for requested stream identifier to our stream identifier.
+     */
+    std::map<std::string, std::string> mAddStreamsMapping;
 };
 
 /**
@@ -1683,6 +1688,9 @@ pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::St
         // Since this is a newly added stream record it as such until the remote party accepts or declines it
         mImplPriv->mNewStreams.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count), stream->second));
 
+        // Create a mapping so if we need to respond to an addStreams request they will get their own identifier back
+        mImplPriv->mAddStreamsMapping.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count), stream->first));
+
 	// Now that all is done we can add this stream in
 	mImplPriv->mStreams.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count++), stream->second));
     }
@@ -1744,7 +1752,13 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
         // If this is a newly added stream we may need to notify a session controller that it was accepted
         if (mImplPriv->mNewStreams.find(boost::lexical_cast<std::string>(stream)) != mImplPriv->mNewStreams.end())
         {
-            streamsAdded.insert(make_pair(boost::lexical_cast<std::string>(stream), ourStream));
+            // We need to return a StreamInformationDict with their identifier so they can correctly associate it
+            std::map<std::string, std::string>::const_iterator mapping = mImplPriv->mAddStreamsMapping.find(
+                boost::lexical_cast<std::string>(stream));
+            if (mapping != mImplPriv->mAddStreamsMapping.end())
+            {
+                streamsAdded.insert(make_pair(mapping->second, ourStream));
+            }
         }
 
         // If a format is actually found we add it to this sequence so we can create an RTP session
@@ -2002,13 +2016,14 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
         }
     }
 
-    if (!streamsAdded.empty() && mImplPriv->mAddStreamsCb)
+    if (mImplPriv->mAddStreamsCb)
     {
         mImplPriv->mAddStreamsCb->ice_response(streamsAdded);
         mImplPriv->mAddStreamsCb = 0;
     }
 
     mImplPriv->mNewStreams.clear();
+    mImplPriv->mAddStreamsMapping.clear();
 
     return mImplPriv->mSDP;
 }

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list