[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "mediamixer" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Aug 31 19:29:47 CDT 2011


branch "mediamixer" has been updated
       via  fceeb4bfdd74b62e09da30446aaf2e2f90608a9a (commit)
      from  7accba81b7a07b3c6b3a53b3b8f9501d2655d1b7 (commit)

Summary of changes:
 src/MediaMixer.cpp |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)


- Log -----------------------------------------------------------------
commit fceeb4bfdd74b62e09da30446aaf2e2f90608a9a
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 31 21:34:41 2011 -0300

    Add signed linear manipulation code.

diff --git a/src/MediaMixer.cpp b/src/MediaMixer.cpp
index cbe3e36..77df38d 100755
--- a/src/MediaMixer.cpp
+++ b/src/MediaMixer.cpp
@@ -332,6 +332,48 @@ public:
     WriteCallbackPtr mCallback;
 };
 
+/**
+ * Transform function which performs a signed linear saturated add.
+ */
+static short saturatedSignedLinearAdd(short input, short value)
+{
+    int res = input + value;
+
+    if (res > 32767)
+    {
+        return 32767;
+    }
+    else if (res < -32767)
+    {
+        return -32767;
+    }
+    else
+    {
+        return static_cast<short>(res);
+    }
+}
+
+/**
+ * Transform function which performs a signed linear saturated subtract.
+ */
+static short saturatedSignedLinearSubtract(short input, short value)
+{
+    int res = input - value;
+
+    if (res > 32767)
+    {
+        return 32767;
+    }
+    else if (res < -32767)
+    {
+        return -32767;
+    }
+    else
+    {
+        return static_cast<short>(res);
+    }
+}
+
 MediaMixer::MediaMixer(const Ice::ObjectAdapterPtr& adapter) : mImpl(new MediaMixerI(adapter))
 {
     mImpl->mTimer->scheduleRepeated(this, IceUtil::Time::milliSeconds(MIXING_INTERVAL));
@@ -398,6 +440,10 @@ void MediaMixer::runTimerTask()
         {
             continue;
         }
+
+        std::transform(frame->payload.begin(), frame->payload.end(),
+                       sinkFrame->payload.begin(), sinkFrame->payload.end(),
+                       saturatedSignedLinearAdd);
     }
 
     for (std::vector<MediaMixerSinkPtr>::const_iterator sink = sinks.begin();
@@ -411,6 +457,10 @@ void MediaMixer::runTimerTask()
         {
             // If a frame was mixed in mix it out so we don't send their own audio to them
 	    theirFrame = FramePtr::dynamicCast(frame->ice_clone());
+
+            std::transform(theirFrame->payload.begin(), theirFrame->payload.end(),
+                           sinkFrame->payload.begin(), sinkFrame->payload.end(),
+                           saturatedSignedLinearSubtract);
         }
 
         // Send this frame to all the sinks we should

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list