[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 26 16:38:40 CDT 2011


branch "inband-events" has been updated
       via  8dd22319976eb8faf4b33ea4282215c64a09b365 (commit)
       via  4c017a32acabf1ff53f3c215f8ded69a79b47065 (commit)
      from  0ddc4b71b09c3a7aa39d13870e38f03749744755 (commit)

Summary of changes:
 .../MediaOperationsCore/MediaOperationsCoreIf.ice  |    3 -
 src/DSP.cpp                                        |    8 +-
 src/InbandTelephonyEvents.cpp                      |  118 ++++----------------
 3 files changed, 26 insertions(+), 103 deletions(-)


- Log -----------------------------------------------------------------
commit 8dd22319976eb8faf4b33ea4282215c64a09b365
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 26 16:19:42 2011 -0500

    Be sure to activate all servants.

diff --git a/src/InbandTelephonyEvents.cpp b/src/InbandTelephonyEvents.cpp
index 55ac901..e1cebd7 100644
--- a/src/InbandTelephonyEvents.cpp
+++ b/src/InbandTelephonyEvents.cpp
@@ -19,6 +19,8 @@
 #include <AsteriskSCF/Media/Formats/AudioFormats.h>
 #include <AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.h>
 
+#include <IceUtil/UUID.h>
+
 #include "TranslatorOperation.h"
 #include "InbandTelephonyEvents.h"
 #include "MediaOperationReplicationContext.h"
@@ -286,6 +288,12 @@ public:
         commonConstruction(sourceFormat, sinkFormat);
     }
 
+    MediaOperationPrx activate(const std::string& id)
+    {
+        mDetector->activateSource(id);
+        return TranslatorOperation::activate(id);
+    }
+
     ~InbandTelephonyEventOperation()
     {
         mDetector->deactivateSource();
@@ -306,7 +314,6 @@ private:
             throw UnsupportedMediaFormatException();
         }
         mDetector = new InbandTelephonyEventDetector(mSource, sinkAudio, sourceAudio, mLogger, mReplicationContext, mAdapter);
-        TelephonyEventSourcePrx source = mDetector->activateSource(mProxy->ice_getIdentity().name);
         mSink->setTranslator(mDetector);
     }
 
@@ -376,7 +383,7 @@ MediaOperationPrx InbandTelephonyEventOperationFactory::tryFormat(const FormatSe
                     *inFormat,
                     getProxy()->ice_getIdentity(),
                     mReplicationContext));
-        MediaOperationPrx proxy(MediaOperationPrx::uncheckedCast(mAdapter->addWithUUID(operation)));
+        MediaOperationPrx proxy(operation->activate(IceUtil::generateUUID()));
         return proxy;
     }
     return 0;
@@ -403,7 +410,7 @@ void InbandTelephonyEventOperationFactory::createOrUpdateMediaOperation(
             mReplicationContext,
             item);
 
-    MediaOperationPrx proxy = MediaOperationPrx::uncheckedCast(mAdapter->addWithUUID(operation));
+    MediaOperationPrx proxy(operation->activate(item->operationId));
 }
 
 } //end MediaOperationsCore

commit 4c017a32acabf1ff53f3c215f8ded69a79b47065
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 26 14:24:48 2011 -0500

    Switch around types so that they fall more in line with how the DSP works.

diff --git a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
index 4227098..61fafd0 100644
--- a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
+++ b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
@@ -114,9 +114,6 @@ class G722MediaOperationStateItem extends TranslatorMediaOperationStateItem
 class InbandTelephonyEventOperationStateItem extends TranslatorMediaOperationStateItem
 {
     bool processingDTMF;
-    bool processingCNG;
-    bool processingCED;
-    bool processingV21;
     byte currentDTMF;
     long eventBeginTime;
 };
diff --git a/src/DSP.cpp b/src/DSP.cpp
index 2b2faad..8bddd01 100644
--- a/src/DSP.cpp
+++ b/src/DSP.cpp
@@ -1096,7 +1096,7 @@ TelephonyEventPtr DSP::process(AudioFramePtr af)
 
     if ((mPriv->mFeatures & DSP_FEATURE_FAX_DETECT)) {
         if ((mPriv->mFaxmode & DSP_FAXMODE_DETECT_CNG) && mPriv->toneDetect(&mPriv->mCNGToneState, shortdata, len)) {
-            returnEvent = new BeginCNGEvent;
+            returnEvent = new CNGEvent;
             for (x = 0; x < mPriv->mMuteFragments; x++) {
                 memset(shortdata + mPriv->mMuteData[x].start, 0, sizeof(int16_t) * (mPriv->mMuteData[x].end - mPriv->mMuteData[x].start));
             }
@@ -1104,7 +1104,7 @@ TelephonyEventPtr DSP::process(AudioFramePtr af)
         }
 
         if ((mPriv->mFaxmode & DSP_FAXMODE_DETECT_CED) && mPriv->toneDetect(&mPriv->mCEDToneState, shortdata, len)) {
-            returnEvent = new BeginCEDEvent;
+            returnEvent = new CEDEvent;
             for (x = 0; x < mPriv->mMuteFragments; x++) {
                 memset(shortdata + mPriv->mMuteData[x].start, 0, sizeof(int16_t) * (mPriv->mMuteData[x].end - mPriv->mMuteData[x].start));
             }
@@ -1112,7 +1112,7 @@ TelephonyEventPtr DSP::process(AudioFramePtr af)
         }
 
         if ((mPriv->mFaxmode & DSP_FAXMODE_DETECT_V21) && mPriv->v21Detect(&mPriv->mV21State, shortdata, len)) {
-            returnEvent = new BeginV21Event;
+            returnEvent = new V21Event;
             for (x = 0; x < mPriv->mMuteFragments; x++) {
                 memset(shortdata + mPriv->mMuteData[x].start, 0, sizeof(int16_t) * (mPriv->mMuteData[x].end - mPriv->mMuteData[x].start));
             }
@@ -1147,7 +1147,7 @@ TelephonyEventPtr DSP::process(AudioFramePtr af)
                 memmove(&mPriv->mDigitState.digitlen[0], &mPriv->mDigitState.digitlen[1], mPriv->mDigitState.current_digits * sizeof(mPriv->mDigitState.digitlen[0]));
                 mPriv->mDigitState.current_digits--;
                 mPriv->mDTMFBegan = 0;
-                returnEvent = new BeginDTMFEvent(event_digit);
+                returnEvent = new EndDTMFEvent(event_digit, 0);
             }
         }
     }
diff --git a/src/InbandTelephonyEvents.cpp b/src/InbandTelephonyEvents.cpp
index 2cd64b8..55ac901 100644
--- a/src/InbandTelephonyEvents.cpp
+++ b/src/InbandTelephonyEvents.cpp
@@ -169,16 +169,6 @@ class InbandTelephonyEventOperation : public TranslatorOperation
                 throw UnsupportedMediaFormatException();
             }
 
-            //This requires some explanation...
-            //The DSP will detect the presence of certain tones. The DSP is essentially
-            //edge-triggered. In other words, it will report the beginning and end of
-            //a specific tone and let us know what it detected.
-            //
-            //The problem here is that the DSP will always report what it has found as
-            //a "Begin" event of the appropriate type. It is up to us to maintain state
-            //from the DSP's process. Thus we can properly turn the event into an end
-            //event if it is appropriate to do so.
-
             TelephonyEventPtr detectedEvent = mDSP->process(inAudio);
 
             if (!detectedEvent)
@@ -195,87 +185,26 @@ class InbandTelephonyEventOperation : public TranslatorOperation
                 return inAudio;
             }
 
-            //In all cases below, we will want to generate telephony
-            //events.
-            BeginDTMFEventPtr DTMF;
-            BeginCNGEventPtr CNG;
-            BeginCEDEventPtr CED;
-            BeginV21EventPtr v21;
-            if ((DTMF = BeginDTMFEventPtr::dynamicCast(detectedEvent)))
-            {
-                //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 (mStateItem->processingDTMF)
-                {
-                    //Create an EndDTMF event
-                    int duration = (int) (IceUtil::Time::now().toMilliSeconds() - mStateItem->eventBeginTime);
-                    EndDTMFEventPtr endDTMF(new EndDTMFEvent(mStateItem->currentDTMF, duration));
-                    mTelephonySource->distributeToSinks(endDTMF);
-                    mStateItem->processingDTMF = false;
-                }
-                else
-                {
-                    forwardBeginEvent(DTMF, mStateItem->processingDTMF);
-                }
-                replicateState();
-            }
-            else if ((CNG = BeginCNGEventPtr::dynamicCast(detectedEvent)))
-            {
-                //We've picked up some CNG!
-                if (mStateItem->processingCNG)
-                {
-                    //End that shizzle!
-                    int duration = (int) (IceUtil::Time::now().toMilliSeconds() - mStateItem->eventBeginTime);
-                    EndCNGEventPtr endCNG(new EndCNGEvent(duration));
-                    mTelephonySource->distributeToSinks(endCNG);
-                    mStateItem->processingCNG = false;
-                }
-                else
-                {
-                    forwardBeginEvent(CNG, mStateItem->processingCNG);
-                }
-                replicateState();
-            }
-            else if ((CED = BeginCEDEventPtr::dynamicCast(detectedEvent)))
+            BeginDTMFEventPtr beginDTMF;
+            EndDTMFEventPtr endDTMF;
+            if ((beginDTMF = BeginDTMFEventPtr::dynamicCast(detectedEvent)))
             {
-                //We've picked up some CED!
-                if (mStateItem->processingCED)
-                {
-                    //End it!
-                    int duration = (int) (IceUtil::Time::now().toMilliSeconds() - mStateItem->eventBeginTime);
-                    EndCNGEventPtr endCNG(new EndCNGEvent(duration));
-                    mTelephonySource->distributeToSinks(endCNG);
-                    mStateItem->processingCED = false;
-                }
-                else
-                {
-                    forwardBeginEvent(CED, mStateItem->processingCED);
-                }
+                mStateItem->eventBeginTime = IceUtil::Time::now().toMilliSeconds();
+                mTelephonySource->distributeToSinks(beginDTMF);
+                mStateItem->processingDTMF = true;
                 replicateState();
             }
-            else if ((v21 = BeginV21EventPtr::dynamicCast(detectedEvent)))
+            else if ((endDTMF = EndDTMFEventPtr::dynamicCast(detectedEvent)))
             {
-                //We've picked up some V.21!
-                if (mStateItem->processingV21)
-                {
-                    int duration = (int) (IceUtil::Time::now().toMilliSeconds() - mStateItem->eventBeginTime);
-                    EndCNGEventPtr endCNG(new EndCNGEvent(duration));
-                    mTelephonySource->distributeToSinks(endCNG);
-                    mStateItem->processingV21 = false;
-                }
-                else
-                {
-                    forwardBeginEvent(v21, mStateItem->processingV21);
-                }
+                endDTMF->duration = (int) (IceUtil::Time::now().toMilliSeconds() - mStateItem->eventBeginTime);
+                mTelephonySource->distributeToSinks(endDTMF);
+                mStateItem->processingDTMF = false;
                 replicateState();
             }
             else
             {
-                //Unknown event detected...weird.
+                //If another type of event was detected, then we'll want to just send it out straightaway.
+                mTelephonySource->distributeToSinks(detectedEvent);
             }
 
             //No matter what sort of telephony event was detected, we'll want to send the
@@ -294,16 +223,6 @@ class InbandTelephonyEventOperation : public TranslatorOperation
             mStateItem = newState;
         }
     private:
-        /**
-         * Convenience method to send along a begin event as detected by the
-         * DSP.
-         */
-        void forwardBeginEvent(const TelephonyEventPtr& event, bool &eventBegin)
-        {
-            mStateItem->eventBeginTime = IceUtil::Time::now().toMilliSeconds();
-            mTelephonySource->distributeToSinks(event);
-            eventBegin = true;
-        }
 
         /**
          * Convenience method to copy our current state to any replicas.

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


-- 
asterisk-scf/integration/media_operations_core.git



More information about the asterisk-scf-commits mailing list