[asterisk-scf-commits] asterisk-scf/release/mediaformatgeneric.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Oct 3 17:45:03 CDT 2011


branch "master" has been updated
       via  509edd9fe10e802048ef108bd8f0874724468830 (commit)
      from  408e18897ab9e63f0c30d66032baa15d7a95f97c (commit)

Summary of changes:
 src/Component.cpp |  235 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 231 insertions(+), 4 deletions(-)


- Log -----------------------------------------------------------------
commit 509edd9fe10e802048ef108bd8f0874724468830
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Oct 3 19:44:57 2011 -0300

    Add support for the T.38 media format.

diff --git a/src/Component.cpp b/src/Component.cpp
index 209e69b..09694c7 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -18,10 +18,13 @@
 #include <IceBox/IceBox.h>
 #include <IceUtil/UUID.h>
 
+#include <boost/lexical_cast.hpp>
+
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
 #include <AsteriskSCF/Media/Formats/AudioFormats.h>
+#include <AsteriskSCF/Media/Formats/T38UdptlFormat.h>
 #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/logger.h>
@@ -37,6 +40,7 @@ using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::Media::SDP::V1;
 using namespace AsteriskSCF::Media::Formats::Audio::V1;
+using namespace AsteriskSCF::Media::Formats::T38Udptl::V1;
 using namespace AsteriskSCF::Configuration::FormatGeneric::V1;
 using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
@@ -91,7 +95,7 @@ void SDPDescriptorCompareServiceImpl::removeAllFormats()
     mSupportedFormats.clear();
 }
 
-FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int, int, const Ice::StringSeq&, const Ice::Current&)
+FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int, int, const Ice::StringSeq& params, const Ice::Current&)
 {
     boost::shared_lock<boost::shared_mutex> lock(mLock);
     std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
@@ -101,7 +105,43 @@ FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int,
         return 0;
     }
 
-    return format->second;
+    if (name == "t38udptl")
+    {
+        T38UdptlFormatPtr t38Format = new T38UdptlFormat();
+
+        t38Format->name = "t38udptl";
+        
+        for (Ice::StringSeq::const_iterator param = params.begin();
+             param != params.end();
+             ++param)
+        {
+	    size_t separator = (*param).find_first_of("=");
+	    std::string param_name = (*param).substr(0, separator);
+	    std::string param_value = (*param).substr(separator + 1);
+
+	    if (param_name == "maxdatagram")
+	    {
+		t38Format->maxDatagram = boost::lexical_cast<int>(param_value);
+	    }
+	    else if (param_name == "errorcorrect")
+	    {
+		if (param_value == "fec")
+		{
+		    t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::FEC;
+		}
+		else if (param_value == "redundancy")
+		{
+		    t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::REDUNDANCY;
+		}
+	    }
+        }
+
+        return t38Format;
+    }
+    else
+    {
+        return format->second;
+    }
 }
 
 FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
@@ -128,7 +168,103 @@ FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& d
             return 0;
         }
 
-        return format->second;
+        if (descriptor->type == "image" && descriptor->subtype == "UDPTL")
+        {
+            T38UdptlFormatPtr t38Format = new T38UdptlFormat();
+
+            t38Format->name = "t38udptl";
+
+            for (SDPFormatParameterSeq::const_iterator param = descriptor->parameters.begin();
+                 param != descriptor->parameters.end();
+                 ++param)
+            {
+                std::string param_name = (*param), param_value;
+                size_t separator = (*param).find_first_of(":");
+
+                if (separator != string::npos)
+                {
+                    param_name = (*param).substr(0, separator);
+                    param_value = (*param).substr(separator + 1);
+                }
+
+                if (param_name == "T38FaxVersion")
+                {
+                    t38Format->version = boost::lexical_cast<int>(param_value);
+		    std::cout << "Set version to " << t38Format->version << std::endl;
+                }
+                else if (param_name == "T38MaxBitRate")
+                {
+                    if (param_value == "2400")
+                    {
+                        t38Format->faxRate = RATE_2400;
+                    }
+                    else if (param_value == "4800")
+                    {
+                        t38Format->faxRate = RATE_4800;
+                    }
+                    else if (param_value == "7200")
+                    {
+                        t38Format->faxRate = RATE_7200;
+                    }
+                    else if (param_value == "9600")
+                    {
+                        t38Format->faxRate = RATE_9600;
+                    }
+                    else if (param_value == "12000")
+                    {
+                        t38Format->faxRate = RATE_12000;
+                    }
+                    else if (param_value == "14400")
+                    {
+                        t38Format->faxRate = RATE_14400;
+                    }
+                }
+                else if (param_name == "T38FaxFillBitRemoval")
+                {
+                    t38Format->fillBitRemoval = true;
+                }
+                else if (param_name == "T38FaxTranscodingMMR")
+                {
+                    t38Format->transcodingMmr = true;
+                }
+                else if (param_name == "T38FaxTranscodingJBIG")
+                {
+                    t38Format->transcodingJbig = true;
+                }
+                else if (param_name == "T38FaxRateManagement")
+                {
+                    if (param_value == "transferredTCF")
+                    {
+                        t38Format->faxRateManagement = TRANSFERRED_TCF;
+                    }
+                    else if (param_value == "localTCF")
+                    {
+                        t38Format->faxRateManagement = LOCAL_TCF;
+                    }
+                }
+                else if (param_name == "T38FaxMaxDatagram")
+                {
+                    t38Format->maxDatagram = boost::lexical_cast<int>(param_value);
+                }
+                else if (param_name == "T38FaxUdpEC")
+                {
+                    if (param_value == "t38UDPFEC")
+                    {
+                        t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::FEC;
+                    }
+                    else if (param_value == "t38UDPRedundancy")
+                    {
+                        t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::REDUNDANCY;
+                    }
+                }
+            }
+
+            return t38Format;
+        }
+        else
+        {
+            return format->second;
+        }
     }
 
     // This will never get reached but just in case the compiler is silly...
@@ -145,7 +281,88 @@ SDPDescriptorPtr SDPDescriptorServiceImpl::getDescriptor(const FormatPtr& format
         return 0;
     }
 
-    return descriptor->second;
+    if (format->name == "t38udptl")
+    {
+        T38UdptlFormatPtr t38Format = T38UdptlFormatPtr::dynamicCast(format);
+
+        if (!t38Format)
+        {
+            return 0;
+        }
+
+        SDPDescriptorPtr t38SDP = new SDPDescriptor();
+        t38SDP->payload = 96;
+        t38SDP->type = "image";
+        t38SDP->subtype = "UDPTL";
+
+        t38SDP->parameters.push_back("T38FaxVersion:" + boost::lexical_cast<std::string>(t38Format->version));
+
+        if (t38Format->faxRate == RATE_2400)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:2400");
+        }
+        else if (t38Format->faxRate == RATE_4800)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:4800");
+        }
+        else if (t38Format->faxRate == RATE_7200)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:7200");
+        }
+        else if (t38Format->faxRate == RATE_9600)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:9600");
+        }
+        else if (t38Format->faxRate == RATE_12000)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:12000");
+        }
+        else if (t38Format->faxRate == RATE_14400)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:14400");
+        }
+
+        if (t38Format->fillBitRemoval == true)
+        {
+            t38SDP->parameters.push_back("T38FaxFillBitRemoval");
+        }
+
+        if (t38Format->transcodingMmr == true)
+        {
+            t38SDP->parameters.push_back("T38TranscodingMMR");
+        }
+
+        if (t38Format->transcodingJbig == true)
+        {
+            t38SDP->parameters.push_back("T38TranscodingJBIG");
+        }
+
+        if (t38Format->faxRateManagement == TRANSFERRED_TCF)
+        {
+            t38SDP->parameters.push_back("T38FaxRateManagement:transferredTCF");
+        }
+        else if (t38Format->faxRateManagement == LOCAL_TCF)
+        {
+            t38SDP->parameters.push_back("T38FaxRateManagement:localTCF");
+        }
+
+        t38SDP->parameters.push_back("T38FaxMaxDatagram:" + boost::lexical_cast<std::string>(t38Format->maxDatagram));
+
+        if (t38Format->errorCorrection == AsteriskSCF::Media::UDPTL::V1::FEC)
+        {
+            t38SDP->parameters.push_back("T38FaxUdpEC:t38UDPFEC");
+        }
+        else if (t38Format->errorCorrection == AsteriskSCF::Media::UDPTL::V1::REDUNDANCY)
+        {
+            t38SDP->parameters.push_back("T38FaxUdpEC:t38UDPRedundancy");
+        }
+
+        return t38SDP;
+    }
+    else
+    {
+        return descriptor->second;
+    }
 }
 
 /**
@@ -283,6 +500,16 @@ void Component::createPrimaryServices()
         mSdpDescriptorService->addFormat(alaw->name, alaw, alawSDP);
         mSdpComparator->addFormat(alaw->name);
 
+        // Add the T.38 media format
+        T38UdptlFormatPtr t38 = new T38UdptlFormat();
+        t38->name = "t38udptl";
+        SDPDescriptorPtr t38SDP = new SDPDescriptor();
+        t38SDP->payload = 96;
+        t38SDP->type = "image";
+        t38SDP->subtype = "UDPTL";
+        mSdpDescriptorService->addFormat(t38->name, t38, t38SDP);
+        mSdpComparator->addFormat(t38->name);
+
         // Register our custom comparator with the service locator
         ServiceLocatorParamsComparePrx comparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
 	    getServiceAdapter()->addWithUUID(mSdpComparator));

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


-- 
asterisk-scf/release/mediaformatgeneric.git



More information about the asterisk-scf-commits mailing list