[asterisk-scf-commits] asterisk-scf/integration/mediaformatgeneric.git branch "t38udptl" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Sep 20 07:31:14 CDT 2011


branch "t38udptl" has been created
        at  5c01c36fe561c33d6cfe0f5db44688ba786bc2e4 (commit)

- Log -----------------------------------------------------------------
commit 5c01c36fe561c33d6cfe0f5db44688ba786bc2e4
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Sep 20 09:37:41 2011 -0300

    Add support for the T.38 UDPTL media format.

diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
index 33c84e6..c331755 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/MediaFormatGeneric.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>
@@ -35,6 +38,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;
@@ -128,7 +132,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);
@@ -138,7 +142,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&)
@@ -165,7 +205,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...
@@ -182,7 +318,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;
+    }
 }
 
 /**
@@ -292,6 +509,16 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
     descriptorService->addFormat(alaw->name, alaw, alawSDP);
     comparatorService->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";
+    descriptorService->addFormat(t38->name, t38, t38SDP);
+    comparatorService->addFormat(t38->name);
+
     // Register our custom comparator with the service locator
     ServiceLocatorParamsComparePrx comparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
 	mAdapter->addWithUUID(comparatorService));

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


-- 
asterisk-scf/integration/mediaformatgeneric.git



More information about the asterisk-scf-commits mailing list