[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "configuration" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 11 06:44:05 CDT 2011


branch "configuration" has been updated
       via  8c950ee6637816c1a07b9864a8a9fdb627cb632c (commit)
       via  5ef3067c4fd3bc3c6036f0a6ac3c1bbfe7d7d488 (commit)
       via  6bc19fc030ca626b7b86b1ba39098d5a7fbaec60 (commit)
       via  0bde61f3c48d1fa13fd58115ca609f2c9a8fe954 (commit)
      from  8c0401743b4bb5b0f6db9533631d6aa0822cd975 (commit)

Summary of changes:
 config/RtpConfigurator.py          |    6 +-
 local-slice/RtpConfigurationIf.ice |   18 ++-
 src/RTPConfiguration.cpp           |  404 +++++++++++++++++++-----------------
 src/RTPConfiguration.h             |    6 -
 src/RTPSession.cpp                 |   12 +-
 5 files changed, 236 insertions(+), 210 deletions(-)


- Log -----------------------------------------------------------------
commit 8c950ee6637816c1a07b9864a8a9fdb627cb632c
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed May 11 08:45:03 2011 -0300

    Incorporate feedback from code review.

diff --git a/config/RtpConfigurator.py b/config/RtpConfigurator.py
index 983144d..87b3f65 100755
--- a/config/RtpConfigurator.py
+++ b/config/RtpConfigurator.py
@@ -34,11 +34,11 @@ class RtpSectionVisitors(Configurator.SectionVisitors):
         mapper = Configurator.OptionMapper()
 
         portsItem = AsteriskSCF.Media.RTP.V1.PortRangesItem()
-        mapper.map('startport', portsItem, 'startPort', 'ports', config.getint, 10000)
-        mapper.map('endport', portsItem, 'endPort', 'ports', config.getint, 20000)
+        mapper.map('startport', portsItem, 'startPort', AsteriskSCF.Media.RTP.V1.PortRangesItemName, config.getint, 10000)
+        mapper.map('endport', portsItem, 'endPort', AsteriskSCF.Media.RTP.V1.PortRangesItemName, config.getint, 20000)
 
         workerItem = AsteriskSCF.Media.RTP.V1.WorkerThreadCountItem()
-        mapper.map('workerthreadcount', workerItem, 'count', 'workerThreadCount', config.getint, 4)
+        mapper.map('workerthreadcount', workerItem, 'count', AsteriskSCF.Media.RTP.V1.WorkerThreadCountItemName, config.getint, 4)
 
         for option in config.options(section):
             mapper.execute(group, section, option)
diff --git a/local-slice/RtpConfigurationIf.ice b/local-slice/RtpConfigurationIf.ice
index c04c07b..45bbd59 100644
--- a/local-slice/RtpConfigurationIf.ice
+++ b/local-slice/RtpConfigurationIf.ice
@@ -66,9 +66,15 @@ module V1
    };
 
    /**
-    * Port ranges configuartion item
+    * Name that the port ranges configuration item should be inserted as
+    */
+   const string PortRangesItemName = "ports";
+
+   /**
+    * Port ranges configuration item
     *
-    * This must be added to the general configuration group using the name ports
+    * This must be added to the general configuration group using the constant string
+    * in PortRangesItemName
     *
     */
    class PortRangesItem extends RtpConfigurationItem
@@ -91,9 +97,15 @@ module V1
    };
 
    /**
+    * Name that the worker thread count configuration item should be inserted as
+    */
+   const string WorkerThreadCountItemName = "workerThreadCount";
+
+   /**
     * Worker thread count for incoming media configuration item
     *
-    * This must be added to the general configuration group using the name workerThreadCount
+    * This must be added to the general configuration group using the constant string
+    * in WorkerThreadCountItemName
     *
     */
    class WorkerThreadCountItem extends RtpConfigurationItem
diff --git a/src/RTPConfiguration.cpp b/src/RTPConfiguration.cpp
index bac536f..1fef9f5 100644
--- a/src/RTPConfiguration.cpp
+++ b/src/RTPConfiguration.cpp
@@ -18,6 +18,7 @@
 
 #include <boost/thread.hpp>
 #include <boost/shared_ptr.hpp>
+#include <boost/thread/shared_mutex.hpp>
 
 #include <AsteriskSCF/System/Component/ConfigurationIf.h>
 
@@ -34,6 +35,11 @@ public:
      * General RTP configuration
      */
     RtpGeneralGroupPtr mGeneralGroup;
+
+    /**
+     * Shared mutex lock which protects the configuration
+     */
+    boost::shared_mutex mLock;
 };
 
 ConfigurationServiceImpl::ConfigurationServiceImpl() : mImplPriv(new ConfigurationServiceImplPriv())
@@ -42,59 +48,59 @@ ConfigurationServiceImpl::ConfigurationServiceImpl() : mImplPriv(new Configurati
 
 ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
 {
-    class visitor : public RtpConfigurationGroupVisitor
+    class GroupVisitor : public RtpConfigurationGroupVisitor
     {
     public:
-	visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& visitorGroups) : mImplPriv(implPriv), mGroups(visitorGroups) { };
+        GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& visitorGroups) : mImplPriv(implPriv), mGroups(visitorGroups) { };
 
     private:
-	/**
-	 * Internal helper function which determines what configuration items should be returned
-	 */
-	void insertRequestedConfigurationItems(ConfigurationItemDict& requestedItems,
-	    ConfigurationItemDict& localItems,
-	    ConfigurationItemDict& returnedItems)
-	{
-	    
-	    for (ConfigurationItemDict::iterator requestedItem = requestedItems.begin();
-		 requestedItem != requestedItems.end();
-		 ++requestedItem)
-	    {
-		ConfigurationItemDict::iterator localItem = localItems.find((*requestedItem).first);
-
-		if (localItem == localItems.end())
-		{
-		    continue;
-		}
-
-		returnedItems.insert(make_pair((*requestedItem).first, (*requestedItem).second));
-	    }
-	}
-
-	void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr& group)
-	{
-	    if (!mImplPriv->mGeneralGroup)
-	    {
-		return;
-	    }
-
-	    RtpGeneralGroupPtr returnedGroup = new RtpGeneralGroup();
-
-	    insertRequestedConfigurationItems(group->configurationItems, mImplPriv->mGeneralGroup->configurationItems, returnedGroup->configurationItems);
-
-	    mGroups.push_back(returnedGroup);
-	};
-
-	boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
-	ConfigurationGroupSeq& mGroups;
+        /**
+         * Internal helper function which determines what configuration items should be returned
+         */
+        void insertRequestedConfigurationItems(const ConfigurationItemDict& requestedItems,
+            const ConfigurationItemDict& localItems,
+            ConfigurationItemDict& returnedItems)
+        {
+
+            boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+            for (ConfigurationItemDict::const_iterator requestedItem = requestedItems.cbegin();
+                 requestedItem != requestedItems.end();
+                 ++requestedItem)
+            {
+                ConfigurationItemDict::const_iterator localItem = localItems.find(requestedItem->first);
+
+                if (localItem != localItems.end())
+                {
+                    returnedItems.insert((*requestedItem));
+                }
+            }
+        }
+
+        void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr& group)
+        {
+            if (!mImplPriv->mGeneralGroup)
+            {
+                return;
+            }
+
+            RtpGeneralGroupPtr returnedGroup = new RtpGeneralGroup();
+
+            insertRequestedConfigurationItems(group->configurationItems, mImplPriv->mGeneralGroup->configurationItems, returnedGroup->configurationItems);
+
+            mGroups.push_back(returnedGroup);
+        };
+
+        boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+        ConfigurationGroupSeq& mGroups;
     };
     
     ConfigurationGroupSeq newGroups;
-    RtpConfigurationGroupVisitorPtr v = new visitor(mImplPriv, newGroups);
+    RtpConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv, newGroups);
     
     for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
     {
-	(*group)->visit(v);
+        (*group)->visit(v);
     }
     
     return newGroups;
@@ -102,33 +108,35 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
 
 ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
 {
-    class visitor : public RtpConfigurationGroupVisitor
+    class GroupVisitor : public RtpConfigurationGroupVisitor
     {
     public:
-	visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& visitorGroups) :
-	    mImplPriv(implPriv), mGroups(visitorGroups) { };
-	
+        GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& visitorGroups) :
+            mImplPriv(implPriv), mGroups(visitorGroups) { };
+ 
     private:
-	void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr&)
-	{
-	    if (!mImplPriv->mGeneralGroup)
-	    {
-		return;
-	    }
-	    
-	    mGroups.push_back(mImplPriv->mGeneralGroup);
-	};
-
-	boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
-	ConfigurationGroupSeq& mGroups;
+        void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr&)
+        {
+            if (!mImplPriv->mGeneralGroup)
+            {
+                return;
+            }
+     
+            mGroups.push_back(mImplPriv->mGeneralGroup);
+        };
+        
+        boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+        ConfigurationGroupSeq& mGroups;
     };
     
     ConfigurationGroupSeq newGroups;
-    RtpConfigurationGroupVisitorPtr v = new visitor(mImplPriv, newGroups);
+    RtpConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv, newGroups);
+
+    boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
     
     for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
     {
-	(*group)->visit(v);
+        (*group)->visit(v);
     }
     
     return newGroups;
@@ -137,11 +145,13 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const Asteri
 ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice::Current&)
 {
     ConfigurationGroupSeq groups;
-    
+ 
+    boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+   
     if (mImplPriv->mGeneralGroup)
     {
-	RtpGeneralGroupPtr general = new RtpGeneralGroup();
-	groups.push_back(general);
+        RtpGeneralGroupPtr general = new RtpGeneralGroup();
+        groups.push_back(general);
     }
     
     return groups;
@@ -149,147 +159,155 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
 
 void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
 {
-    class groupsVisitor : public RtpConfigurationGroupVisitor
+    class GroupVisitor : public RtpConfigurationGroupVisitor
     {
     public:
-	groupsVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
-	
+        GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+ 
     private:
-	/**
-	 * Helper function which performs serial number checking of items
-	 */
-	void performSerialCheck(ConfigurationItemDict& changedItems, ConfigurationItemDict& localItems)
-	{
-	    for (ConfigurationItemDict::iterator item = changedItems.begin();
-		 item != changedItems.end();
-		 ++item)
-	    {
-		// If serial checking is to be skipped for this item just skip over it
-		if ((*item).second->serialNumber == -1)
-		{
-		    continue;
-		}
-		
-		ConfigurationItemDict::iterator localItem = localItems.find((*item).first);
-		
-		if (localItem == localItems.end())
-		{
-		    // This is a new item so serial checking does not apply
-		    continue;
-		}
-		
-		if ((*item).second->serialNumber < (*localItem).second->serialNumber)
-		{
-		    /* XXX Need to throw the exception */
-		}
-	    }
-	}
-	
-	void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr& group)
-	{
-	    if (!mImplPriv->mGeneralGroup)
-	    {
-		mImplPriv->mGeneralGroup = new RtpGeneralGroup();
-	    }
-	    else
-	    {
-		performSerialCheck(group->configurationItems, mImplPriv->mGeneralGroup->configurationItems);
-	    }
-	    
-	    for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
-		 item != group->configurationItems.end();
-		 ++item)
-	    {
-		mImplPriv->mGeneralGroup->configurationItems.insert(make_pair((*item).first, (*item).second));
-	    }
-	}
-	
-	boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+        /**
+         * Helper function which performs serial number checking of items
+         */
+        void performSerialCheck(const ConfigurationItemDict& changedItems, const ConfigurationItemDict& localItems,
+            const AsteriskSCF::System::Configuration::V1::ConfigurationGroupPtr& group)
+        {
+            for (ConfigurationItemDict::const_iterator item = changedItems.cbegin();
+                 item != changedItems.end();
+                 ++item)
+            {
+                // If serial checking is to be skipped for this item just skip over it
+                if (item->second->serialNumber == -1)
+                {
+                    continue;
+                }
+  
+                ConfigurationItemDict::const_iterator localItem = localItems.find(item->first);
+  
+                if (localItem == localItems.end())
+                {
+                    // This is a new item so serial checking does not apply
+                    continue;
+                }
+  
+                if (item->second->serialNumber < localItem->second->serialNumber)
+                {
+                    throw SerialConflict(group, item->second);
+                }
+            }
+        }
+ 
+        void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr& group)
+        {
+            if (!mImplPriv->mGeneralGroup)
+            {
+                mImplPriv->mGeneralGroup = new RtpGeneralGroup();
+            }
+            else
+            {
+                performSerialCheck(group->configurationItems, mImplPriv->mGeneralGroup->configurationItems, group);
+            }
+     
+            for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
+                 item != group->configurationItems.end();
+                 ++item)
+            {
+                mImplPriv->mGeneralGroup->configurationItems.erase(item->first);
+                mImplPriv->mGeneralGroup->configurationItems.insert((*item));
+            }
+        }
+ 
+        boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
     };
     
-    RtpConfigurationGroupVisitorPtr v = new groupsVisitor(mImplPriv);
+    RtpConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+    boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
     
     for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
     {
-	(*group)->visit(v);
+        (*group)->visit(v);
     }
 }
 
 void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
 {
-    class groupsVisitor : public RtpConfigurationGroupVisitor
+    class GroupVisitor : public RtpConfigurationGroupVisitor
     {
     public:
-	groupsVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
-	
-	void removeItems(RtpConfigurationItemVisitor* visitor, ConfigurationItemDict& itemsToRemove,
-	    ConfigurationItemDict& localItems)
-	{
-	    for (ConfigurationItemDict::const_iterator item = itemsToRemove.begin();
-		 item != itemsToRemove.end();
-		 ++item)
-	    {
-		ConfigurationItemDict::iterator localItem = localItems.find((*item).first);
-		if (localItem ==  localItems.end())
-		{
-		    continue;
-		}
-		if (visitor != 0)
-		{
-		    (*item).second->visit(visitor);
-		}
-		localItems.erase(localItem);
-	    }
-	}
-	
-	void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr& group)
-	{
-	    if (!mImplPriv->mGeneralGroup)
-	    {
-		return;
-	    }
-
-	    removeItems(0, group->configurationItems, mImplPriv->mGeneralGroup->configurationItems);
-	};
-	
+        GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+        
+        void removeItems(RtpConfigurationItemVisitor* visitor, ConfigurationItemDict& itemsToRemove,
+            ConfigurationItemDict& localItems)
+        {
+            for (ConfigurationItemDict::const_iterator item = itemsToRemove.begin();
+                 item != itemsToRemove.end();
+                 ++item)
+            {
+                ConfigurationItemDict::iterator localItem = localItems.find(item->first);
+                if (localItem ==  localItems.end())
+                {
+                    continue;
+                }
+                if (visitor != 0)
+                {
+                    item->second->visit(visitor);
+                }
+                localItems.erase(localItem);
+            }
+        }
+ 
+        void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr& group)
+        {
+            if (!mImplPriv->mGeneralGroup)
+            {
+                return;
+            }
+            
+            removeItems(0, group->configurationItems, mImplPriv->mGeneralGroup->configurationItems);
+        };
+ 
     private:
-	boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+        boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
     };
     
-    RtpConfigurationGroupVisitorPtr v = new groupsVisitor(mImplPriv);
+    RtpConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+    boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
     
     for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
     {
-	(*group)->visit(v);
+        (*group)->visit(v);
     }
 }
 
 void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
 {
-    class visitor : public RtpConfigurationGroupVisitor
+    class GroupVisitor : public RtpConfigurationGroupVisitor
     {
     public:
-	visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
-	
+        GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+ 
     private:
-	void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr&)
-	{
-	    if (!mImplPriv->mGeneralGroup)
-	    {
-		return;
-	    }
-
-	    mImplPriv->mGeneralGroup = 0;
-	};
-
-	boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+        void visitRtpGeneralGroup(const ::AsteriskSCF::Media::RTP::V1::RtpGeneralGroupPtr&)
+        {
+            if (!mImplPriv->mGeneralGroup)
+            {
+                return;
+            }
+            
+            mImplPriv->mGeneralGroup = 0;
+        };
+        
+        boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
     };
     
-    RtpConfigurationGroupVisitorPtr v = new visitor(mImplPriv);
+    RtpConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+    boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
     
     for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
     {
-	(*group)->visit(v);
+        (*group)->visit(v);
     }
 }
 
@@ -298,23 +316,26 @@ void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::Syst
  */
 int ConfigurationServiceImpl::getStartPort()
 {
+    boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+    PortRangesItemPtr portsDefault = new PortRangesItem();
+
     if (!mImplPriv->mGeneralGroup)
     {
-	return 10000;
+        return portsDefault->startPort;
     }
 
-    ConfigurationItemDict::iterator item = mImplPriv->mGeneralGroup->configurationItems.find("ports");
+    ConfigurationItemDict::iterator item = mImplPriv->mGeneralGroup->configurationItems.find(PortRangesItemName);
 
     if (item == mImplPriv->mGeneralGroup->configurationItems.end())
     {
-	return 10000;
+        return portsDefault->startPort;
     }
 
-    PortRangesItemPtr ports = PortRangesItemPtr::dynamicCast((*item).second);
+    PortRangesItemPtr ports = PortRangesItemPtr::dynamicCast(item->second);
 
     if (!ports || (ports->endPort <= ports->startPort) || (ports->startPort % 2))
     {
-	return 10000;
+        return portsDefault->startPort;
     }
 
     return ports->startPort;
@@ -325,23 +346,26 @@ int ConfigurationServiceImpl::getStartPort()
  */
 int ConfigurationServiceImpl::getEndPort()
 {
+    boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+    PortRangesItemPtr portsDefault = new PortRangesItem();
+
     if (!mImplPriv->mGeneralGroup)
     {
-        return 20000;
+        return portsDefault->endPort;
     }
 
-    ConfigurationItemDict::iterator item = mImplPriv->mGeneralGroup->configurationItems.find("ports");
+    ConfigurationItemDict::iterator item = mImplPriv->mGeneralGroup->configurationItems.find(PortRangesItemName);
 
     if (item == mImplPriv->mGeneralGroup->configurationItems.end())
     {
-        return 20000;
+        return portsDefault->endPort;
     }
 
-    PortRangesItemPtr ports = PortRangesItemPtr::dynamicCast((*item).second);
+    PortRangesItemPtr ports = PortRangesItemPtr::dynamicCast(item->second);
 
     if (!ports || (ports->endPort <= ports->startPort) || (ports->endPort % 2))
     {
-        return 20000;
+        return portsDefault->endPort;
     }
 
     return ports->endPort;
@@ -352,23 +376,26 @@ int ConfigurationServiceImpl::getEndPort()
  */
 int ConfigurationServiceImpl::getWorkerThreadCount()
 {
+    boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+    WorkerThreadCountItemPtr workerThreadCountDefault = new WorkerThreadCountItem();
+
     if (!mImplPriv->mGeneralGroup)
     {
-        return 4;
+        return workerThreadCountDefault->count;
     }
 
-    ConfigurationItemDict::iterator item = mImplPriv->mGeneralGroup->configurationItems.find("workerThreadCount");
+    ConfigurationItemDict::iterator item = mImplPriv->mGeneralGroup->configurationItems.find(WorkerThreadCountItemName);
 
     if (item == mImplPriv->mGeneralGroup->configurationItems.end())
     {
-        return 4;
+        return workerThreadCountDefault->count;
     }
 
-    WorkerThreadCountItemPtr workerThreadCount = WorkerThreadCountItemPtr::dynamicCast((*item).second);
+    WorkerThreadCountItemPtr workerThreadCount = WorkerThreadCountItemPtr::dynamicCast(item->second);
 
     if (!workerThreadCount)
     {
-        return 4;
+        return workerThreadCountDefault->count;
     }
 
     return workerThreadCount->count;

commit 5ef3067c4fd3bc3c6036f0a6ac3c1bbfe7d7d488
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed May 11 07:58:04 2011 -0300

    Do some range checking of the ports passed in.

diff --git a/src/RTPConfiguration.cpp b/src/RTPConfiguration.cpp
index 43bb8e8..bac536f 100644
--- a/src/RTPConfiguration.cpp
+++ b/src/RTPConfiguration.cpp
@@ -278,8 +278,7 @@ void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::Syst
 	    {
 		return;
 	    }
-	    
-	    /* XXX What should we do as a result of this going away? */
+
 	    mImplPriv->mGeneralGroup = 0;
 	};
 
@@ -313,7 +312,7 @@ int ConfigurationServiceImpl::getStartPort()
 
     PortRangesItemPtr ports = PortRangesItemPtr::dynamicCast((*item).second);
 
-    if (!ports)
+    if (!ports || (ports->endPort <= ports->startPort) || (ports->startPort % 2))
     {
 	return 10000;
     }
@@ -340,7 +339,7 @@ int ConfigurationServiceImpl::getEndPort()
 
     PortRangesItemPtr ports = PortRangesItemPtr::dynamicCast((*item).second);
 
-    if (!ports)
+    if (!ports || (ports->endPort <= ports->startPort) || (ports->endPort % 2))
     {
         return 20000;
     }

commit 6bc19fc030ca626b7b86b1ba39098d5a7fbaec60
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed May 11 07:50:00 2011 -0300

    Assert if we can't create a pjmedia endpoint, it's rather critical.

diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index b97a32a..41df24f 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -145,10 +145,7 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const Forma
     /* Create an endpoint in pjmedia for our media. */
     pj_status_t status = pjmedia_endpt_create(factory, NULL, configurationService->getWorkerThreadCount(), &mImpl->mEndpoint);
 
-    if (status != PJ_SUCCESS)
-    {
-        /* TODO: This is bad... we can't go on! */
-    }
+    assert(status != PJ_SUCCESS);
 
     int minimumPort = configurationService->getStartPort();
     int maximumPort = configurationService->getEndPort();
@@ -195,15 +192,12 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, pj_pool_fac
 
     pj_status_t status = pjmedia_endpt_create(factory, NULL, configurationService->getWorkerThreadCount(), &mImpl->mEndpoint);
 
-    if (status != PJ_SUCCESS)
-    {
-	/* TODO: This is bad... we can't go on! */
-    }
+    assert(status != PJ_SUCCESS);
 
     if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport))
             != PJ_SUCCESS)
     {
-	// TODO: This is also bad, something is using the port */
+	// TODO: This is also bad, something is using the port
     }
 
     mImpl->mStreamSource = new StreamSourceRTPImpl(this, "");

commit 0bde61f3c48d1fa13fd58115ca609f2c9a8fe954
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed May 11 07:47:15 2011 -0300

    Remove comments since doxygen won't parse them as intended when we start using it.

diff --git a/src/RTPConfiguration.h b/src/RTPConfiguration.h
index 31e0016..96d2180 100644
--- a/src/RTPConfiguration.h
+++ b/src/RTPConfiguration.h
@@ -33,9 +33,6 @@ class ConfigurationServiceImpl : public AsteriskSCF::System::Configuration::V1::
 public:
     ConfigurationServiceImpl();
 
-    /**
-     * Interface defined functions.
-     */
     AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
     AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
     AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationGroups(const Ice::Current&);
@@ -43,9 +40,6 @@ public:
     void removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
     void removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
 
-    /**
-     * Internal functions.
-     */
     int getStartPort();
     int getEndPort();
     int getWorkerThreadCount();

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list