[asterisk-scf-commits] asterisk-scf/integration/mediatransportudptl.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Sep 15 07:01:51 CDT 2011


branch "master" has been updated
       via  beff2421fcee2c335becc3bf265ff497b0fd43c7 (commit)
       via  dad194b1ccef433895ced5df0ef36fb5a4560c37 (commit)
       via  50bd48a40017820ba923c8057c0b7746aeb75c4c (commit)
       via  5d4f045158e100e67794d4ef00cb74a40b68aa53 (commit)
      from  e61c003055af95a5f85e914bf5f8ca6f194b2a23 (commit)

Summary of changes:
 config/Udptl.config                                |   21 ++++
 config/UdptlConfigurator.py                        |   64 ++++++++++
 .../Configuration/UDPTL/UdptlConfigurationIf.ice   |   21 ++++
 src/UDPTLConfiguration.cpp                         |   11 ++
 src/UDPTLSink.cpp                                  |    4 +-
 test/TestMediaTransportUDPTL.cpp                   |  124 ++++++++++++++++++++
 6 files changed, 243 insertions(+), 2 deletions(-)
 create mode 100644 config/Udptl.config
 create mode 100755 config/UdptlConfigurator.py


- Log -----------------------------------------------------------------
commit beff2421fcee2c335becc3bf265ff497b0fd43c7
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Sep 15 09:07:46 2011 -0300

    Add tests for setting some UDPTL stack settings and actually writing/receiving UDPTL. It... works? Say wha?

diff --git a/test/TestMediaTransportUDPTL.cpp b/test/TestMediaTransportUDPTL.cpp
index f9de8f9..c6898f0 100644
--- a/test/TestMediaTransportUDPTL.cpp
+++ b/test/TestMediaTransportUDPTL.cpp
@@ -794,6 +794,70 @@ BOOST_AUTO_TEST_CASE(SetupUDPTLLoopback)
 }
 
 /**
+ * Set the far max datagram size
+ */
+BOOST_AUTO_TEST_CASE(SetFarMaxDatagram)
+{
+    bool set = false;
+
+    try
+    {
+        StreamSinkSeq sinks = Testbed.session->getSinks();
+        StreamSinkUDPTLPrx sink = StreamSinkUDPTLPrx::uncheckedCast(sinks.front());
+
+        boost::mutex::scoped_lock lock(Testbed.mLock);
+
+        sink->setFarMaxDatagram(1000);
+
+        set = true;
+
+        Testbed.mCondition.wait(lock);
+    }
+    catch (const Ice::Exception &e)
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    }
+    catch (...)
+    {
+    }
+
+    BOOST_CHECK(set);
+}
+
+/**
+ * Set the error correction scheme to use
+ */
+BOOST_AUTO_TEST_CASE(SetErrorCorrectionScheme)
+{
+    bool set = false;
+
+    try
+    {
+        StreamSinkSeq sinks = Testbed.session->getSinks();
+        StreamSinkUDPTLPrx sink = StreamSinkUDPTLPrx::uncheckedCast(sinks.front());
+
+        boost::mutex::scoped_lock lock(Testbed.mLock);
+
+        sink->setErrorCorrectionScheme(AsteriskSCF::Media::UDPTL::V1::REDUNDANCY);
+
+        set = true;
+
+        Testbed.mCondition.wait(lock);
+    }
+    catch (const Ice::Exception &e)
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    }
+    catch (...)
+    {
+    }
+
+    BOOST_CHECK(set);
+}
+
+/**
  * Confirm that we received the populated sink replicated item (with proper contents) for the UDPTL session.
  */
 BOOST_AUTO_TEST_CASE(ConfirmPopulatedReplicatedUDPTLSink)
@@ -803,6 +867,8 @@ BOOST_AUTO_TEST_CASE(ConfirmPopulatedReplicatedUDPTLSink)
 
     BOOST_CHECK(Testbed.mListener->mSink->remoteAddress == source->getLocalAddress());
     BOOST_CHECK(Testbed.mListener->mSink->remotePort == source->getLocalPort());
+    BOOST_CHECK(Testbed.mListener->mSink->farMaxDatagram == 1000);
+    BOOST_CHECK(Testbed.mListener->mSink->errorCorrectionScheme == AsteriskSCF::Media::UDPTL::V1::REDUNDANCY);
 }
 
 /**
@@ -854,6 +920,64 @@ BOOST_AUTO_TEST_CASE(SetInvalidAddressFamilyAddress)
 }
 
 /**
+ * Actually write a frame out, have it get transmitted via RTP, received via RTP,
+ * and then transmogrified back into a frame and written to our sink.
+ */
+BOOST_AUTO_TEST_CASE(TransmitandReceiveFrame)
+{
+    bool received = false;
+
+    try
+    {
+        StreamFramePtr frame = new StreamFrame();
+
+        /* Populate the payload with some useless data, but enough to confirm the payload passes unaltered. */
+        frame->payload.push_back('a');
+        frame->payload.push_back('b');
+        frame->payload.push_back('c');
+        frame->payload.push_back('d');
+        frame->payload.push_back('e');
+        frame->payload.push_back('f');
+        frame->payload.push_back('g');
+        frame->payload.push_back('h');
+        frame->payload.push_back('i');
+        frame->payload.push_back('j');
+
+        FrameSeq frames;
+        frames.push_back(frame);
+
+        StreamSinkSeq sinks = Testbed.session->getSinks();
+        StreamSinkUDPTLPrx sink = StreamSinkUDPTLPrx::uncheckedCast(sinks.front());
+
+	boost::mutex::scoped_lock lock(Testbed.mLock);
+
+        sink->write(frames);
+
+        /* It takes time for the packet to get sent and received so we wait until we get it here.
+         */
+	Testbed.mCondition.wait(lock);
+
+	/**
+	 * Have to check it
+	 */
+	if (!Testbed.frames.empty())
+	{
+            received = true;
+	}
+    }
+    catch (const Ice::Exception &e)
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    }
+    catch (...)
+    {
+    }
+
+    BOOST_CHECK(received);
+}
+
+/**
  * Attempt to release our UDPTL session
  */
 BOOST_AUTO_TEST_CASE(ReleaseUDPTLSession)

commit dad194b1ccef433895ced5df0ef36fb5a4560c37
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Sep 15 08:45:53 2011 -0300

    Actually build the UDPTL packet to send.

diff --git a/src/UDPTLSink.cpp b/src/UDPTLSink.cpp
index 7731bd1..e227acd 100644
--- a/src/UDPTLSink.cpp
+++ b/src/UDPTLSink.cpp
@@ -120,9 +120,9 @@ void StreamSinkUDPTLImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames,
     {
         const int bufsize = udptl_get_far_max_datagram(mImpl->mUdptl);
         uint8_t buf[bufsize];
-        unsigned int len = (unsigned int)(*frame)->payload.size();
+        int len;
 
-//        len = udptl_build_packet(mImpl->mUdptl, buf, sizeof(buf), (*frame)->payload, len);
+        len = udptl_build_packet(mImpl->mUdptl, buf, sizeof(buf), &(*frame)->payload[0], (unsigned int)(*frame)->payload.size());
 
         if (len > 0)
         {

commit 50bd48a40017820ba923c8057c0b7746aeb75c4c
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Sep 15 07:56:25 2011 -0300

    Add configurator and configuration file.

diff --git a/config/Udptl.config b/config/Udptl.config
new file mode 100644
index 0000000..3e3c40d
--- /dev/null
+++ b/config/Udptl.config
@@ -0,0 +1,21 @@
+# General Configuation Options
+
+[general]
+
+# Start port for UDPTL sessions
+startport=10000
+
+# End port for UDPTL sessions
+endport=20000
+
+# IPv4 address we should bind sessions to
+#ipv4bind=
+
+# IPv6 address we should bind sessions to
+#ipv6bind=
+
+# Default number of FEC spans for UDPTL sessions
+#defaultfecspan=5
+
+# Default number of FEC entries for UDPTL sessions
+#defaultfecentries=5
diff --git a/config/UdptlConfigurator.py b/config/UdptlConfigurator.py
new file mode 100755
index 0000000..bde1039
--- /dev/null
+++ b/config/UdptlConfigurator.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+
+#
+# Asterisk SCF -- An open-source communications framework.
+#
+# Copyright (C) 2011, Digium, Inc.
+#
+# See http://www.asterisk.org for more information about
+# the Asterisk SCF project. Please do not directly contact
+# any of the maintainers of this project for assistance;
+# the project provides a web site, mailing lists and IRC
+# channels for your use.
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License Version 2. See the LICENSE.txt file
+# at the top of the source tree.
+#
+
+# Udptl configurator
+
+# Bring in the common configuration infrastructure
+import Ice, Configurator, sys, os
+
+# Load our component specific configuration definitions
+Ice.loadSlice("-I" + os.environ["ASTSCF_HOME"] + " -I" + Ice.getSliceDir() + " --all ../slice/AsteriskSCF/Configuration/UDPTL/UdptlConfigurationIf.ice")
+import AsteriskSCF.Configuration.UDPTL.V1
+
+# Add our own visitor implementations for the sections we support
+class UdptlSectionVisitors(Configurator.SectionVisitors):
+    def visit_general(self, config, section):
+        group = AsteriskSCF.Configuration.UDPTL.V1.UdptlGeneralGroup()
+        group.configurationItems = { }
+
+        mapper = Configurator.OptionMapper()
+
+        portsItem = AsteriskSCF.Configuration.UDPTL.V1.PortRangesItem()
+        mapper.map('startport', portsItem, 'startPort', AsteriskSCF.Configuration.UDPTL.V1.PortRangesItemName, config.getint, 10000)
+        mapper.map('endport', portsItem, 'endPort', AsteriskSCF.Configuration.UDPTL.V1.PortRangesItemName, config.getint, 20000)
+
+        ipv4BindingItem = AsteriskSCF.Configuration.UDPTL.V1.BindingIPv4Item()
+        mapper.map('ipv4bind', ipv4BindingItem, 'address', AsteriskSCF.Configuration.UDPTL.V1.BindingIPv4AddressItemName, config.get, None)
+
+        ipv6BindingItem = AsteriskSCF.Configuration.UDPTL.V1.BindingIPv6Item()
+        mapper.map('ipv6bind', ipv6BindingItem, 'address', AsteriskSCF.Configuration.UDPTL.V1.BindingIPv6AddressItemName, config.get, None)
+
+        fecDefaultsItem = AsteriskSCF.Configuration.UDPTL.V1.FecDefaultsItem()
+        mapper.map('defaultfecspan', fecDefaultsItem, 'fecSpan', AsteriskSCF.Configuration.UDPTL.V1.FecDefaultsItemName, config.getint, None)
+        mapper.map('defaultfecentries', fecDefaultsItem, 'fecEntries', AsteriskSCF.Configuration.UDPTL.V1.FecDefaultsItemName, config.getint, None)
+
+        for option in config.options(section):
+            mapper.execute(group, section, option)
+
+        mapper.finish(group)
+
+        self.groups.append(group)
+
+# In order to do service locator based lookup we need to pass in a params object
+serviceLocatorParams = AsteriskSCF.Core.Discovery.V1.ServiceLocatorParams()
+serviceLocatorParams.category = AsteriskSCF.Configuration.UDPTL.V1.ConfigurationDiscoveryCategory
+serviceLocatorParams.service = 'default'
+
+# Make a configurator application and let it run
+app = Configurator.ConfiguratorApp('Udptl.config', UdptlSectionVisitors(), None, serviceLocatorParams)
+sys.exit(app.main(sys.argv))

commit 5d4f045158e100e67794d4ef00cb74a40b68aa53
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Sep 15 07:42:13 2011 -0300

    Add configuration for FEC.

diff --git a/slice/AsteriskSCF/Configuration/UDPTL/UdptlConfigurationIf.ice b/slice/AsteriskSCF/Configuration/UDPTL/UdptlConfigurationIf.ice
index 6a24b20..3b4a9dd 100644
--- a/slice/AsteriskSCF/Configuration/UDPTL/UdptlConfigurationIf.ice
+++ b/slice/AsteriskSCF/Configuration/UDPTL/UdptlConfigurationIf.ice
@@ -138,6 +138,27 @@ module V1
         string address;
     };
 
+    /**
+     * Name that the default FEC settings configuration item should be inserted as
+     */
+    const string FecDefaultsItemName = "fecDefaults";
+
+    /**
+     * Default settings for forward error correction
+     */
+    class FecDefaultsItem extends UdptlConfigurationItem
+    {
+        /**
+         * Default FEC span to use when a UDPTL session is created.
+         */
+        int fecSpan;
+
+        /**
+         * Default number of FEC entries to use when a UDPTL session is created.
+         */
+        int fecEntries;
+    };
+
 }; /* module V1 */
 
 }; /* module UDPTL */
diff --git a/src/UDPTLConfiguration.cpp b/src/UDPTLConfiguration.cpp
index 535a24f..dee3678 100644
--- a/src/UDPTLConfiguration.cpp
+++ b/src/UDPTLConfiguration.cpp
@@ -23,6 +23,8 @@
 #include <boost/thread.hpp>
 #include <boost/thread/shared_mutex.hpp>
 
+#include "udptl.h"
+
 using namespace AsteriskSCF::System::Configuration::V1;
 using namespace AsteriskSCF::UDPTL;
 using namespace std;
@@ -70,6 +72,15 @@ public:
     void replaceGroup(const UdptlGeneralGroupPtr& group)
     {
         mGeneralGroup = group;
+
+        ConfigurationItemDict::iterator item = mGeneralGroup->configurationItems.find(FecDefaultsItemName);
+        FecDefaultsItemPtr fecDefaults;
+
+        if (item != mGeneralGroup->configurationItems.end() && (fecDefaults = FecDefaultsItemPtr::dynamicCast(item->second)))
+        {
+            udptl_set_default_fec_span(fecDefaults->fecSpan);
+            udptl_set_default_fec_entries(fecDefaults->fecEntries);
+        }
     }
 
 private:

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


-- 
asterisk-scf/integration/mediatransportudptl.git



More information about the asterisk-scf-commits mailing list