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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Oct 17 14:18:02 CDT 2011


branch "jitterbuffer" has been updated
       via  4bf05f7f12720a4bf19e4c50f3e6b56c4e5e86c5 (commit)
      from  6905d722c0c98250cb314b56d544102fcb40f2b3 (commit)

Summary of changes:
 src/JitterBufferOperation.cpp |   56 ++++++++++++++++++++++------------------
 1 files changed, 31 insertions(+), 25 deletions(-)


- Log -----------------------------------------------------------------
commit 4bf05f7f12720a4bf19e4c50f3e6b56c4e5e86c5
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Oct 17 16:19:20 2011 -0300

    Fix up the part that retrieves payloads from the jiterbuffer.

diff --git a/src/JitterBufferOperation.cpp b/src/JitterBufferOperation.cpp
index bf7c058..ff5721d 100644
--- a/src/JitterBufferOperation.cpp
+++ b/src/JitterBufferOperation.cpp
@@ -52,65 +52,72 @@ private:
     {
     public:
         JitterBufferSendTask(const TranslatorSourcePtr& source,
-                             const AudioFormatPtr& inFormat,
                              const AudioFormatPtr& outFormat,
                              boost::shared_mutex& mutex,
-                             int numFramesToPush,
+                             int numPayloadsToGet,
                              const NetEqWrapperPtr& netEqWrapper) 
                          : mSource(source),
                            mOutFormat(outFormat),
-                           mInFormat(inFormat),
                            mLock(mutex),
-                           mNumFramesToPush(numFramesToPush),
+                           mNumPayloadsToGet(numPayloadsToGet),
                            mNetEq(netEqWrapper)
         { 
         }
 
-        AudioFramePtr getNextFrame()
+        Ice::ShortSeq getNextPayload()
         {
-            AudioFramePtr frame = new AudioFrame();
-            frame->mediaFormat = mOutFormat;
-            
-            ShortSeqPayloadPtr outPayload = new ShortSeqPayload(Ice::ShortSeq(mOutFormat->frameSize/2));
-            WebRtc_Word16 length;
+            Ice::ShortSeq payload(NETEQ_MAX_FRAME_SIZE);
+            WebRtc_Word16 samples;
 
             {
                 boost::unique_lock<boost::shared_mutex> lock(mLock);
 
-                WebRtcNetEQ_RecOut(mNetEq->getInstance(), 
-                                   (WebRtc_Word16*)&outPayload->payload.front(),
-                                   &length);
+                WebRtcNetEQ_RecOut(mNetEq->getInstance(),
+                                   &payload.front(),
+                                   &samples);
             }
-            frame->payload = outPayload;
 
-            // This just seems wrong... 
-            // But I don't see a way to access the sequence number and timestamp via any RecOut operation.
-            frame->timestamp = IceUtil::Time::now().toMilliSeconds();
-            frame->seqno = mSeqNumber++;
+            // Remove any contents which were not populated
+            payload.resize(samples);
 
-            return frame;
+            return payload;
         }
 
         void runTimerTask()
         {
             FrameSeq frameSeq;
 
-            for (int i=0; i < mNumFramesToPush; ++i)
+            AudioFramePtr frame = new AudioFrame();
+            frame->mediaFormat = mOutFormat;
+
+            WebRtc_UWord32 timestamp;
+            WebRtcNetEQ_GetSpeechTimeStamp(mNetEq->getInstance(), &timestamp);
+            frame->timestamp = timestamp;
+
+            frame->seqno = mSeqNumber++;
+
+            ShortSeqPayloadPtr payload = new ShortSeqPayload();
+
+            for (int i=0; i < mNumPayloadsToGet; ++i)
             {
-                AudioFramePtr frame = getNextFrame();
-                frameSeq.push_back(frame);
+                Ice::ShortSeq nextPayload = getNextPayload();
+
+                payload->payload.insert(payload->payload.end(), nextPayload.begin(), nextPayload.end());
             }
 
+            frame->payload = payload;
+
+            frameSeq.push_back(frame);
+
             mSource->distributeToSinks(frameSeq);
         }
 
     private:
         TranslatorSourcePtr mSource;
         AudioFormatPtr mOutFormat;
-        AudioFormatPtr mInFormat;
         long mSeqNumber;
         boost::shared_mutex &mLock;
-        int mNumFramesToPush;
+        int mNumPayloadsToGet;
         NetEqWrapperPtr mNetEq;
     };
 
@@ -185,7 +192,6 @@ private:
 
                 // Start a timer to push buffered frames.
                 IceUtil::TimerTaskPtr sendTask = new JitterBufferSendTask(mSource, 
-                                                                          mInAudioFormat, 
                                                                           mOutAudioFormat, 
                                                                           mLock,
                                                                           1,

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


-- 
asterisk-scf/integration/media_operations_core.git



More information about the asterisk-scf-commits mailing list