[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
Sun Jun 26 14:48:03 CDT 2011


branch "media" has been updated
       via  3af1b9d76864b48c2025445677a7c930fa05f0b8 (commit)
      from  ad2772d4e6e236de480122ba840de8243b16dcc8 (commit)

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


- Log -----------------------------------------------------------------
commit 3af1b9d76864b48c2025445677a7c930fa05f0b8
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Jun 26 16:47:33 2011 -0300

    Add support for assigning a payload dynamically if told to do so.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 05e81e4..62c8465 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -1107,6 +1107,9 @@ pjmedia_sdp_session *SipSession::createSDP()
  */
 void SipSession::addFormatstoSDP(const FormatSeq& formats, pjmedia_sdp_media *media, PayloadMap& payloads)
 {
+    // Start dynamic payload assignment at 96
+    int dynamicPayload = 96;
+
     // Iterate through each format adding it to the SDP
     for (FormatSeq::const_iterator mediaformat = formats.begin();
          mediaformat != formats.end();
@@ -1122,9 +1125,31 @@ void SipSession::addFormatstoSDP(const FormatSeq& formats, pjmedia_sdp_media *me
             continue;
         }
 
+        int payload = ourDescriptor->payload;
+
+        // If we have been told to assign a dynamic payload ourselves do so
+        if (payload == -1)
+        {
+            // Ensure we don't assign a payload that has been specified by checking the payload -> format mapping
+            for (; dynamicPayload < 130; dynamicPayload++)
+            {
+                if (payloads.find(dynamicPayload) == payloads.end())
+                {
+                    payload = dynamicPayload;
+                    break;
+                }
+            }
+
+            // If the payload still has not been decided we have no more room in the dynamic payload range
+            if (payload == -1)
+            {
+                continue;
+            }
+        }
+
         // Add the format to the 'm' line
         pj_strdup2(mImplPriv->mDialog->pool, &media->desc.fmt[media->desc.fmt_count++],
-                   boost::lexical_cast<std::string>(ourDescriptor->payload).c_str());
+                   boost::lexical_cast<std::string>(payload).c_str());
 
         // Add an rtpmap attribute line for the format
         pjmedia_sdp_rtpmap rtpmap;
@@ -1147,7 +1172,7 @@ void SipSession::addFormatstoSDP(const FormatSeq& formats, pjmedia_sdp_media *me
             media->attr[media->attr_count++] = attr;
         }
 
-        payloads.insert(std::make_pair(ourDescriptor->payload, (*mediaformat)));
+        payloads.insert(std::make_pair(payload, (*mediaformat)));
     }
 }
 

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list