[asterisk-scf-commits] asterisk-scf/integration/media_operations_core.git branch "inband-events" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Oct 12 10:55:31 CDT 2011


branch "inband-events" has been updated
       via  6acdad7fb807677349da1e991456218b07d0cd7f (commit)
       via  5bbcf89dfb410a7a0b77d4c622173494c174e1d9 (commit)
      from  a14548fd1fcb491f9d9540cc61ba39765f197580 (commit)

Summary of changes:
 src/InbandTelephonyEvents.cpp |  122 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 111 insertions(+), 11 deletions(-)


- Log -----------------------------------------------------------------
commit 6acdad7fb807677349da1e991456218b07d0cd7f
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Oct 11 18:33:10 2011 -0500

    Add initial telephony source implementation.

diff --git a/src/InbandTelephonyEvents.cpp b/src/InbandTelephonyEvents.cpp
index 1c485fc..d878d25 100644
--- a/src/InbandTelephonyEvents.cpp
+++ b/src/InbandTelephonyEvents.cpp
@@ -15,6 +15,7 @@
  */
 
 #include <InbandTelephonyEvents.h>
+#include <AsteriskSCF/Helpers/ProxyHelper.h>
 
 namespace AsteriskSCF
 {
@@ -23,9 +24,45 @@ namespace MediaOperationsCore
 {
 
 using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::SessionCommunications::V1;
 
 class InbandTelephonyEventOperation : public TranslatorOperation
 {
+    class InbandTelephonyEventSource : public TelephonyEventSource
+    {
+    public:
+        void addSinks_async(const AMD_TelephonyEventSource_addSinksPtr& cb,
+                const TelephonyEventSinkSeq& sinks,
+                const Ice::Current&)
+        {
+            for (TelephonyEventSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
+            {
+                if (std::find_if(mSinks.begin(), mSinks.end(), IdentityComparePredicate<TelephonyEventSinkPrx>(*i)) == mSinks.end())
+                {
+                    mSinks.push_back(*i);
+                }
+            }
+            cb->ice_response();
+        }
+        void removeSinks_async(const AMD_TelephonyEventSource_removeSinksPtr& cb,
+                const TelephonyEventSinkSeq& sinks,
+                const Ice::Current&)
+        {
+            for (TelephonyEventSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
+            {
+                mSinks.erase(remove_if(mSinks.begin(), mSinks.end(), IdentityComparePredicate<TelephonyEventSinkPrx>(*i)), mSinks.end());
+            }
+            cb->ice_response();
+        }
+        TelephonyEventSinkSeq getSinks_async(const AMD_TelephonyEventSource_getSinksPtr& cb,
+                const Ice::Current&)
+        {
+            cb->ice_response(mSinks);
+        }
+    private:
+        TelephonyEventSinkSeq mSinks;
+    };
+
     class InbandTelephonyEventDetector : public Translator
     {
     public:
@@ -60,7 +97,12 @@ class InbandTelephonyEventOperation : public TranslatorOperation
 
             if (!detectedEvent)
             {
-                //No event detected. No biggie. Just pass the audio on unchanged.
+                //No event was processed. If we are in the midst of processing DTMF though,
+                //we need to send a continuation frame.
+                if (mProcessingDTMF)
+                {
+                }
+
                 return inAudio;
             }
 
@@ -133,11 +175,7 @@ class InbandTelephonyEventOperation : public TranslatorOperation
             }
             else
             {
-                //No event was processed. If we are in the midst of processing DTMF though,
-                //we need to send a continuation frame.
-                if (mProcessingDTMF)
-                {
-                }
+                //Unknown event detected...weird.
             }
 
             //No matter what sort of telephony event was detected, we'll want to send the

commit 5bbcf89dfb410a7a0b77d4c622173494c174e1d9
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 6 18:36:53 2011 -0500

    Get some skeleton in place for processing the telephony events returned by the DSP.

diff --git a/src/InbandTelephonyEvents.cpp b/src/InbandTelephonyEvents.cpp
index ca87c69..1c485fc 100644
--- a/src/InbandTelephonyEvents.cpp
+++ b/src/InbandTelephonyEvents.cpp
@@ -28,6 +28,7 @@ class InbandTelephonyEventOperation : public TranslatorOperation
 {
     class InbandTelephonyEventDetector : public Translator
     {
+    public:
         InbandTelephonyEventDetector(const TranslatorSourcePtr source,
                 const FormatPtr& inputFormat,
                 const FormatPtr& outputFormat,
@@ -36,6 +37,8 @@ class InbandTelephonyEventOperation : public TranslatorOperation
             //XXX We can work out the sample rate from the input format.
             mDSP(new DSP())
         {
+            mDSP->setFeatures(DSP_FEATURE_DIGIT_DETECT | DSP_FEATURE_FAX_DETECT);
+            mDSP->setDigitmode(DSP_DIGITMODE_DTMF);
         }
 
         FramePtr translate(const FramePtr inFrame)
@@ -64,29 +67,88 @@ class InbandTelephonyEventOperation : public TranslatorOperation
             //In all cases below, we will want to generate telephony
             //events.
             BeginDTMFPtr DTMF;
+            BeginCNGPtr CNG;
+            BeginCEDPtr CED;
+            BeginV21Ptr v21;
             if ((DTMF = BeginDTMFPtr::dynamicCast(detectedEvent)))
             {
-                //We've picked up some DTMF!
+                //With DTMF we get told when DTMF has begun and when it has
+                //ended. We keep track of whether we're currently handling
+                //a DTMF. If we're not, then we can just forward on the 
+                //begin event that we get back. If we are, then we need
+                //to generate an end event and unset the bool.
+                //
+                if (mProcessingDTMF)
+                {
+                    //Create an EndDTMF event
+                    mProcessingDTMF = false;
+                }
+                else
+                {
+                    //Send on the BeginDTMF event
+                    mProcessingDTMF = true;
+                }
             }
-
-            BeginCNGPtr CNG;
-            if ((CNG = BeginCNGPtr::dynamicCast(detectedEvent)))
+            else if ((CNG = BeginCNGPtr::dynamicCast(detectedEvent)))
             {
                 //We've picked up some CNG!
+                if (mProcessingCNG)
+                {
+                    //End that shizzle!
+                    mProcessingCNG = false;
+                }
+                else
+                {
+                    //Send the begin event
+                    mProcessingCNG = true;
+                }
             }
-            
-            BeginCEDPtr CED;
-            if ((CED = BeginCEDPtr::dynamicCast(detectedEvent)))
+            else if ((CED = BeginCEDPtr::dynamicCast(detectedEvent)))
             {
                 //We've picked up some CED!
+                if (mProcessingCED)
+                {
+                    //End it!
+                    mProcessingCED = false;
+                }
+                else
+                {
+                    //Forward the begin!
+                    mProcessingCED = true;
+                }
             }
-
-            BeginV21Ptr v21;
-            if ((v21 = BeginV21Ptr::dynamicCast(detectedEvent)))
+            else if ((v21 = BeginV21Ptr::dynamicCast(detectedEvent)))
             {
                 //We've picked up some V.21!
+                if (mProcessingV21)
+                {
+                    //STOP!!!
+                    mProcessingV21 = false;
+                }
+                else
+                {
+                    //Send it on!
+                    mProcessingV21 = true;
+                }
             }
+            else
+            {
+                //No event was processed. If we are in the midst of processing DTMF though,
+                //we need to send a continuation frame.
+                if (mProcessingDTMF)
+                {
+                }
+            }
+
+            //No matter what sort of telephony event was detected, we'll want to send the
+            //audio on to the next set of stuff
+            return inFrame;
         };
+    private:
+        bool mProcessingDTMF;
+        bool mProcessingCNG;
+        bool mProcessingCED;
+        bool mProcessingV21;
     };
 public:
     InbandTelephonyEventOperation(

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


-- 
asterisk-scf/integration/media_operations_core.git



More information about the asterisk-scf-commits mailing list