[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
Mon Jun 20 08:06:05 CDT 2011


branch "media" has been updated
       via  b461f6e4119b30a7d51034c8d8927631cfd9ff39 (commit)
       via  4081fae143196fd079f4bc507e9ec80de91e3f90 (commit)
      from  5f517f4e5659e6e5ef45ad974cfdbacfa04f9fe7 (commit)

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


- Log -----------------------------------------------------------------
commit b461f6e4119b30a7d51034c8d8927631cfd9ff39
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jun 20 10:05:45 2011 -0300

    By using zalloc the allocated memory is zeroed so we do not have to set these explicitly.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 5643e55..5217f7e 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -935,9 +935,6 @@ pjmedia_sdp_session *SipSession::createSDP()
     }
 
     sdp->name = sdp->origin.user;
-    sdp->time.start = 0;
-    sdp->time.stop = 0;
-    sdp->attr_count = 0;
 
     return sdp;
 }
@@ -1277,10 +1274,6 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
         pjmedia_sdp_media *media = allocate_from_pool<pjmedia_sdp_media>(mImplPriv->mDialog->pool);
         mImplPriv->mSDP->media[mImplPriv->mSDP->media_count++] = media;
 
-        // Initialize some parts to sane values
-        media->desc.fmt_count = 0;
-        media->attr_count = 0;
-
         // Since our stream should be like the offering stream we can just use some values from there
         media->desc.media = offer->media[stream]->desc.media;
         media->desc.transport = offer->media[stream]->desc.transport;

commit 4081fae143196fd079f4bc507e9ec80de91e3f90
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jun 20 10:04:53 2011 -0300

    Use an inlined templated function for allocating from a pool.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 1f2bd50..5643e55 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -267,6 +267,15 @@ public:
     bool mSDPFinalized;
 };
 
+/**
+ * Template for allocating from a pool.
+ */
+template<typename T>
+inline T *allocate_from_pool(pj_pool_t *pool)
+{
+    return static_cast<T*>(pj_pool_zalloc(pool, sizeof(T)));
+}
+
 void SipSession::initializePJSIPStructs()
 {
     pj_str_t local_uri, remote_uri;
@@ -904,8 +913,7 @@ void SipSession::destroy()
  */
 pjmedia_sdp_session *SipSession::createSDP()
 {
-    pjmedia_sdp_session *sdp = static_cast<pjmedia_sdp_session*>(pj_pool_zalloc(mImplPriv->mDialog->pool,
-                                                                                sizeof(pjmedia_sdp_session)));
+    pjmedia_sdp_session *sdp = allocate_from_pool<pjmedia_sdp_session>(mImplPriv->mDialog->pool);
 
     pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.user, "AsteriskSCF");
     pj_time_val tv;
@@ -974,7 +982,7 @@ void SipSession::addFormatstoSDP(const FormatSeq& formats, pjmedia_sdp_media *me
              parameter != ourDescriptor->parameters.end();
              ++parameter)
         {
-            attr = static_cast<pjmedia_sdp_attr*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_attr)));
+            attr = allocate_from_pool<pjmedia_sdp_attr>(mImplPriv->mDialog->pool);
             pj_strdup2(mImplPriv->mDialog->pool, &attr->name, (*parameter).c_str());
             media->attr[media->attr_count++] = attr;
         }
@@ -1050,7 +1058,7 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
         mImplPriv->mRTPSessions.push_back(session);
 
         // Add the stream to the SDP
-        pjmedia_sdp_media *media = static_cast<pjmedia_sdp_media*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_media)));
+        pjmedia_sdp_media *media = allocate_from_pool<pjmedia_sdp_media>(mImplPriv->mDialog->pool);
         mImplPriv->mSDP->media[mImplPriv->mSDP->media_count++] = media;
         pj_strdup2(mImplPriv->mDialog->pool, &media->desc.media, mImplPriv->mEndpoint->getDescriptor(stream->second.front())->type.c_str());
 
@@ -1058,7 +1066,7 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
         pj_strdup2(mImplPriv->mDialog->pool, &media->desc.transport, "RTP/AVP");
 
         // Add connection level details
-        media->conn = static_cast<pjmedia_sdp_conn*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_conn)));
+        media->conn = allocate_from_pool<pjmedia_sdp_conn>(mImplPriv->mDialog->pool);
         pj_strdup2(mImplPriv->mDialog->pool, &media->conn->net_type, "IN");
 
         if (params->ipv6 == true)
@@ -1266,8 +1274,7 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
         mImplPriv->mRTPSessions.push_back(session);
 
         // Add a new stream to the answer SDP
-        pjmedia_sdp_media *media = static_cast<pjmedia_sdp_media*>(pj_pool_zalloc(mImplPriv->mDialog->pool,
-                                                                                  sizeof(pjmedia_sdp_media)));
+        pjmedia_sdp_media *media = allocate_from_pool<pjmedia_sdp_media>(mImplPriv->mDialog->pool);
         mImplPriv->mSDP->media[mImplPriv->mSDP->media_count++] = media;
 
         // Initialize some parts to sane values
@@ -1279,7 +1286,7 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
         media->desc.transport = offer->media[stream]->desc.transport;
 
         // Add connection level information so they know our IP address
-        media->conn = static_cast<pjmedia_sdp_conn*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_conn)));
+        media->conn = allocate_from_pool<pjmedia_sdp_conn>(mImplPriv->mDialog->pool);
         media->conn->net_type = offer->origin.net_type;
         media->conn->addr_type = offer->origin.addr_type;
         pj_strdup2(mImplPriv->mDialog->pool, &media->conn->addr, source->getLocalAddress().c_str());

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list