[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 10:55:15 CDT 2011


branch "jitterbuffer" has been updated
       via  dbf8e0bbb07fdf103df681181379860459edb801 (commit)
      from  ecd1510bc370e373f273e2860d249c57c4579c82 (commit)

Summary of changes:
 test/TestMediaOperations.cpp |  147 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 137 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit dbf8e0bbb07fdf103df681181379860459edb801
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Oct 17 12:56:14 2011 -0300

    Add some basic tests for jitterbuffer. Doesn't actually ensure frames are proper yet, but gets frames into the hands of the jitterbuffer and back out.

diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index 7d3d79a..5d90059 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -58,8 +58,12 @@ public:
 
     AudioFormatPtr slin8;
 
+    AudioFormatPtr slin8nojitter;
+
     AudioFormatPtr slin16;
 
+    AudioFormatPtr slin16nojitter;
+
     AudioFormatPtr g722;
 
     TestStreamSinkPtr ulawSink;
@@ -74,10 +78,18 @@ public:
 
     StreamSinkPrx slin8SinkProxy;
 
+    TestStreamSinkPtr slin8NoJitterSink;
+
+    StreamSinkPrx slin8NoJitterSinkProxy;
+
     TestStreamSinkPtr slin16Sink;
 
     StreamSinkPrx slin16SinkProxy;
 
+    TestStreamSinkPtr slin16NoJitterSink;
+
+    StreamSinkPrx slin16NoJitterSinkProxy;
+
     TestStreamSourcePtr alawSource;
 
     TestStreamSinkPtr g722Sink;
@@ -102,23 +114,23 @@ public:
 
     StreamSourcePrx g722SourceProxy;
 
-    FramePtr sampleAlawFrame;
+    AudioFramePtr sampleAlawFrame;
 
     size_t sampleAlawFrameSize;
 
-    FramePtr sampleUlawFrame;
+    AudioFramePtr sampleUlawFrame;
 
     size_t sampleUlawFrameSize;
 
-    FramePtr sampleSlin8Frame;
+    AudioFramePtr sampleSlin8Frame;
 
     size_t sampleSlin8FrameSize;
 
-    FramePtr sampleSlin16Frame;
+    AudioFramePtr sampleSlin16Frame;
 
     size_t sampleSlin16FrameSize;
 
-    FramePtr sampleG722Frame;
+    AudioFramePtr sampleG722Frame;
 
     size_t sampleG722FrameSize;
 };
@@ -308,28 +320,36 @@ struct GlobalIceFixture
             Testbed.slin8->name = SignedLinear8Name;
             Testbed.slin8->sampleRate = 8000;
 
+            Testbed.slin8nojitter = new SignedLinear();
+            Testbed.slin8nojitter->name = SignedLinear8NoJitterName;
+            Testbed.slin8nojitter->sampleRate = 8000;
+
             Testbed.slin16 = new SignedLinear();
             Testbed.slin16->name = SignedLinear16Name;
             Testbed.slin16->sampleRate = 16000;
 
+            Testbed.slin16nojitter = new SignedLinear();
+            Testbed.slin16nojitter->name = SignedLinear16NoJitterName;
+            Testbed.slin16nojitter->sampleRate = 16000;
+
             Testbed.g722 = new G722();
             Testbed.g722->name = G722Name;
 
-            Testbed.sampleAlawFrame = new Frame(Testbed.alaw, new ByteSeqPayload(Ice::ByteSeq(sampleAlaw, sampleAlaw + sizeof(sampleAlaw))));
+            Testbed.sampleAlawFrame = new AudioFrame(Testbed.alaw, new ByteSeqPayload(Ice::ByteSeq(sampleAlaw, sampleAlaw + sizeof(sampleAlaw))), 0, 0);
             Testbed.sampleAlawFrameSize = sizeof(sampleAlaw);
 
-            Testbed.sampleUlawFrame = new Frame(Testbed.ulaw, new ByteSeqPayload(Ice::ByteSeq(sampleUlaw, sampleUlaw + sizeof(sampleUlaw))));
+            Testbed.sampleUlawFrame = new AudioFrame(Testbed.ulaw, new ByteSeqPayload(Ice::ByteSeq(sampleUlaw, sampleUlaw + sizeof(sampleUlaw))), 0, 0);
             Testbed.sampleUlawFrameSize = sizeof(sampleUlaw);
 
             ShortSeqPayloadPtr slin8Payload(new ShortSeqPayload(Ice::ShortSeq(sampleSlin8, sampleSlin8 + (sizeof(sampleSlin8) / 2))));
-            Testbed.sampleSlin8Frame = new Frame(Testbed.slin8, slin8Payload);
+            Testbed.sampleSlin8Frame = new AudioFrame(Testbed.slin8, slin8Payload, 0, 0);
             Testbed.sampleSlin8FrameSize = slin8Payload->payload.size();
 
             ShortSeqPayloadPtr slin16Payload(new ShortSeqPayload(Ice::ShortSeq(sampleSlin16, sampleSlin16 + (sizeof(sampleSlin16) / 2))));
-            Testbed.sampleSlin16Frame = new Frame(Testbed.slin16, slin16Payload);
+            Testbed.sampleSlin16Frame = new AudioFrame(Testbed.slin16, slin16Payload, 0, 0);
             Testbed.sampleSlin16FrameSize = slin16Payload->payload.size();
 
-            Testbed.sampleG722Frame = new Frame(Testbed.g722, new ByteSeqPayload(Ice::ByteSeq(sampleG722, sampleG722 + sizeof(sampleG722))));
+            Testbed.sampleG722Frame = new AudioFrame(Testbed.g722, new ByteSeqPayload(Ice::ByteSeq(sampleG722, sampleG722 + sizeof(sampleG722))), 0, 0);
             Testbed.sampleG722FrameSize = sizeof(sampleG722);
         }
         catch (const Ice::Exception& ex)
@@ -386,9 +406,15 @@ public:
         Testbed.slin8Sink = new TestStreamSink(Testbed.slin8);
         Testbed.slin8SinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin8Sink));
 
+        Testbed.slin8NoJitterSink = new TestStreamSink(Testbed.slin8nojitter);
+        Testbed.slin8NoJitterSinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin8NoJitterSink));
+
         Testbed.slin16Sink = new TestStreamSink(Testbed.slin16);
         Testbed.slin16SinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin16Sink));
 
+        Testbed.slin16NoJitterSink = new TestStreamSink(Testbed.slin16nojitter);
+        Testbed.slin16NoJitterSinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin16NoJitterSink));
+
         Testbed.g722Source = new TestStreamSource(Testbed.g722);
         Testbed.g722SourceProxy = StreamSourcePrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.g722Source));
 
@@ -406,8 +432,10 @@ public:
         Testbed.adapter->remove(Testbed.alawSourceProxy->ice_getIdentity());
         Testbed.adapter->remove(Testbed.slin8SourceProxy->ice_getIdentity());
         Testbed.adapter->remove(Testbed.slin8SinkProxy->ice_getIdentity());
+        Testbed.adapter->remove(Testbed.slin8NoJitterSinkProxy->ice_getIdentity());
         Testbed.adapter->remove(Testbed.slin16SourceProxy->ice_getIdentity());
         Testbed.adapter->remove(Testbed.slin16SinkProxy->ice_getIdentity());
+        Testbed.adapter->remove(Testbed.slin16NoJitterSinkProxy->ice_getIdentity());
         Testbed.adapter->remove(Testbed.g722SourceProxy->ice_getIdentity());
         Testbed.adapter->remove(Testbed.g722SinkProxy->ice_getIdentity());
     }
@@ -960,3 +988,102 @@ BOOST_FIXTURE_TEST_CASE(g722ToSlin16, PerTestFixture)
     }
 }
 
+BOOST_AUTO_TEST_CASE(FindSignedLinearJitterBuffersFactory)
+{
+    try
+    {
+        MediaOperationServiceLocatorParamsPtr slin82slin8nojitterParams = createLocatorParams(Testbed.slin8, Testbed.slin8nojitter);
+        MediaOperationServiceLocatorParamsPtr slin162slin16nojitterParams = createLocatorParams(Testbed.slin16, Testbed.slin16nojitter);
+
+        // Both of these should result in our factory being returned...
+        MediaOperationFactoryPrx slin82slin8nojitterFactory =
+            MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slin82slin8nojitterParams));
+
+        MediaOperationFactoryPrx slin162slin16nojitterFactory =
+            MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slin162slin16nojitterParams));
+
+        BOOST_CHECK(slin82slin8nojitterFactory != 0);
+        BOOST_CHECK(slin162slin16nojitterFactory != 0);
+    }
+    catch (const std::exception& ex)
+    {
+        std::stringstream str;
+        str << "Exception caught while attempting to locate the jitter buffer factory: " << ex.what();
+        BOOST_FAIL(str.str());
+    }
+}
+
+BOOST_FIXTURE_TEST_CASE(createJitterBufferOperations, PerTestFixture)
+{
+    MediaOperationServiceLocatorParamsPtr slin8NoJitterParams = createLocatorParams(Testbed.slin8, Testbed.slin8nojitter);
+
+    MediaOperationFactoryPrx slin8NoJitterFactory =
+        MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slin8NoJitterParams));
+
+    try
+    {
+        MediaOperationPrx slin8NoJitterTranslator =
+            slin8NoJitterFactory->createMediaOperation(Testbed.slin8SourceProxy, Testbed.slin8NoJitterSinkProxy);
+
+        MediaOperationPrx slin16NoJitterTranslator =
+            slin8NoJitterFactory->createMediaOperation(Testbed.slin16SourceProxy, Testbed.slin16NoJitterSinkProxy);
+
+        BOOST_CHECK(slin8NoJitterTranslator != 0);
+        BOOST_CHECK(slin16NoJitterTranslator != 0);
+
+        slin8NoJitterTranslator->destroy();
+        slin16NoJitterTranslator->destroy();
+    }
+    catch (const Ice::Exception& ex)
+    {
+	std::stringstream str;
+        str << "Exception caught while attempting to create a jitterbuffer translator: " << ex.what();
+        BOOST_FAIL(str.str());
+    }
+}
+
+BOOST_FIXTURE_TEST_CASE(dejitterSlin8, PerTestFixture)
+{
+    size_t numFramesToDejitter = 10;
+
+    Testbed.slin8->frameSize = (Ice::Int) Testbed.sampleSlin8FrameSize;
+    Testbed.slin8nojitter->frameSize = (Ice::Int) Testbed.sampleSlin8FrameSize;
+
+    MediaOperationServiceLocatorParamsPtr slin8NoJitterParams = createLocatorParams(Testbed.slin8, Testbed.slin8nojitter);
+
+    MediaOperationFactoryPrx slin8NoJitterFactory =
+        MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slin8NoJitterParams));
+
+    MediaOperationPrx slin8NoJitterTranslator =
+        slin8NoJitterFactory->createMediaOperation(Testbed.slin8SourceProxy, Testbed.slin8NoJitterSinkProxy);
+
+    StreamSinkPrx translatorSink = slin8NoJitterTranslator->getSink();
+    StreamSourcePrx translatorSource = slin8NoJitterTranslator->getSource();
+
+    Testbed.slin8SourceProxy->addSink(translatorSink);
+    Testbed.slin8NoJitterSinkProxy->setSource(translatorSource);
+
+    translatorSource->addSink(Testbed.slin8NoJitterSinkProxy);
+    translatorSink->setSource(Testbed.slin8SourceProxy);
+
+    FrameSeq slin8Frames(numFramesToDejitter, Testbed.sampleSlin8Frame);
+
+    try
+    {
+        Testbed.slin8Source->feedFramesToTranslator(slin8Frames);
+    }
+    catch (const Ice::Exception& ex)
+    {
+	std::stringstream str;
+        str << "Exception caught trying to dejitter slin8 frames: " << ex.what();
+        BOOST_FAIL(str.str());
+    }
+
+    IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(5));
+
+    FrameSeq framesWritten = Testbed.slin8NoJitterSink->getFrames();
+
+    BOOST_CHECK(framesWritten.size() == numFramesToDejitter);
+
+    slin8NoJitterTranslator->destroy();
+}

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


-- 
asterisk-scf/integration/media_operations_core.git



More information about the asterisk-scf-commits mailing list