[asterisk-scf-commits] asterisk-scf/integration/media_operations_core.git branch "no_c++11" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Nov 18 18:27:35 CST 2011
branch "no_c++11" has been created
at 7250098efb7412f9b0fdd6cbaa85fd6e0cd47214 (commit)
- Log -----------------------------------------------------------------
commit 7250098efb7412f9b0fdd6cbaa85fd6e0cd47214
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Nov 18 18:25:33 2011 -0600
You apparently can't do BOOST_CHECK_EQUAL inside the init process as of Boost 1.47
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index bbf2bee..896c5d4 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -342,7 +342,7 @@ struct GlobalIceFixture
std::cerr << "Some non-Ice exception got encaughtened." << std::endl;
status = 1;
}
- BOOST_CHECK_EQUAL(0, status);
+
}
~GlobalIceFixture()
commit 0b24734d742896a7fe7a67a8d71df65321a94f5a
Author: David M. Lee <dlee at digium.com>
Date: Thu Oct 20 16:39:55 2011 -0500
Fixed unused variable warning
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index a5a41fc..bbf2bee 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -342,6 +342,7 @@ struct GlobalIceFixture
std::cerr << "Some non-Ice exception got encaughtened." << std::endl;
status = 1;
}
+ BOOST_CHECK_EQUAL(0, status);
}
~GlobalIceFixture()
commit 938898df0a58862bcfaad66c6dea04f797ba8538
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Oct 6 16:30:06 2011 -0500
Make it possible for ulaw and alaw to be translated to slin8 and vice-versa.
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index 2d3e2a9..b3f0722 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -19,6 +19,8 @@
#include <IceUtil/UUID.h>
#include <pjmedia.h>
+#include <boost/bind.hpp>
+
#include "ulaw_alaw.h"
#include "TranslatorSource.h"
#include "Translator.h"
@@ -60,6 +62,26 @@ private:
{
return pjmedia_alaw2ulaw(alaw);
}
+
+ short ulaw2slin(unsigned char ulaw)
+ {
+ return (short) pjmedia_ulaw2linear(ulaw);
+ }
+
+ short alaw2slin(unsigned char alaw)
+ {
+ return (short) pjmedia_alaw2linear(alaw);
+ }
+
+ unsigned char slin2ulaw(short slin)
+ {
+ return pjmedia_linear2ulaw((int) slin);
+ }
+
+ unsigned char slin2alaw(short slin)
+ {
+ return pjmedia_linear2alaw((int) slin);
+ }
/**
* Override of Translator's translate function.
@@ -72,26 +94,68 @@ private:
throw UnsupportedMediaFormatException();
}
- FramePtr outFrame;
- Ice::ByteSeq outPayload;
+ FramePtr outFrame = 0;
+ Ice::ByteSeq outPayload8;
+ Ice::ShortSeq outPayload16;
- ByteSeqPayloadPtr inPayload = ByteSeqPayloadPtr::dynamicCast(inFrame->payload);
- if (!inPayload)
+ if (inFrame->mediaFormat->name == G711uLAWName)
{
- mLogger(Error) << "The incoming frame's payload is not a byte sequence.";
- throw UnsupportedMediaFormatException();
+ ByteSeqPayloadPtr inPayload = ByteSeqPayloadPtr::dynamicCast(inFrame->payload);
+ if (!inPayload)
+ {
+ mLogger(Error) << "The incoming frame's payload is not a byte sequence.";
+ throw UnsupportedMediaFormatException();
+ }
+ if (mOutputFormat->name == G711aLAWName)
+ {
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload8), boost::bind(&UlawAlawTranslator::ulaw2alaw, this, _1));
+ outFrame = new Frame(mOutputFormat, new ByteSeqPayload(outPayload8));
+ }
+ else
+ {
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload16), boost::bind(&UlawAlawTranslator::ulaw2slin, this, _1));
+ outFrame = new Frame(mOutputFormat, new ShortSeqPayload(outPayload16));
+ }
}
-
- if (inFrame->mediaFormat->name == G711uLAWName)
+ else if (inFrame->mediaFormat->name == G711aLAWName)
{
- std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload), std::bind1st(std::mem_fun(&UlawAlawTranslator::ulaw2alaw), this));
+ ByteSeqPayloadPtr inPayload = ByteSeqPayloadPtr::dynamicCast(inFrame->payload);
+ if (!inPayload)
+ {
+ mLogger(Error) << "The incoming frame's payload is not a byte sequence.";
+ throw UnsupportedMediaFormatException();
+ }
+ if (mOutputFormat->name == G711uLAWName)
+ {
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload8), boost::bind(&UlawAlawTranslator::alaw2ulaw, this, _1));
+ outFrame = new Frame(mOutputFormat, new ByteSeqPayload(outPayload8));
+ }
+ else
+ {
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload16), boost::bind(&UlawAlawTranslator::alaw2slin, this, _1));
+ outFrame = new Frame(mOutputFormat, new ShortSeqPayload(outPayload16));
+ }
}
- else
+ else if (inFrame->mediaFormat->name == SignedLinear8Name)
{
- std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload), std::bind1st(std::mem_fun(&UlawAlawTranslator::alaw2ulaw), this));
+ ShortSeqPayloadPtr inPayload = ShortSeqPayloadPtr::dynamicCast(inFrame->payload);
+ if (!inPayload)
+ {
+ mLogger(Error) << "The incoming frame's payload is not a short sequence.";
+ throw UnsupportedMediaFormatException();
+ }
+ if (mOutputFormat->name == G711uLAWName)
+ {
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload8), boost::bind(&UlawAlawTranslator::slin2ulaw, this, _1));
+ outFrame = new Frame(mOutputFormat, new ByteSeqPayload(outPayload8));
+ }
+ else
+ {
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload8), boost::bind(&UlawAlawTranslator::slin2alaw, this, _1));
+ outFrame = new Frame(mOutputFormat, new ByteSeqPayload(outPayload8));
+ }
}
- outFrame = new Frame(mOutputFormat, new ByteSeqPayload(outPayload));
return outFrame;
}
};
@@ -134,8 +198,15 @@ void UlawAlawFactory::buildTranslations()
FormatPtr alaw = new G711aLAW();
alaw->name = G711aLAWName;
+ FormatPtr slin8 = new SignedLinear();
+ slin8->name = SignedLinear8Name;
+
addTranslation(ulaw, alaw, 100);
addTranslation(alaw, ulaw, 100);
+ addTranslation(ulaw, slin8, 100);
+ addTranslation(alaw, slin8, 100);
+ addTranslation(slin8, ulaw, 100);
+ addTranslation(slin8, alaw, 100);
}
MediaOperationPrx UlawAlawFactory::createMediaOperation(
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index 7d3d79a..a5a41fc 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -545,6 +545,128 @@ BOOST_FIXTURE_TEST_CASE(translateAlawToUlaw, PerTestFixture)
alaw2ulawTranslator->destroy();
}
+BOOST_FIXTURE_TEST_CASE(translateAlawToSlin8, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+ MediaOperationServiceLocatorParamsPtr alaw2slin8Params = createLocatorParams(Testbed.alaw, Testbed.slin8);
+
+ MediaOperationFactoryPrx alaw2slin8Factory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(alaw2slin8Params));
+
+ MediaOperationPrx alaw2slin8Translator =
+ alaw2slin8Factory->createMediaOperation(Testbed.alawSourceProxy, Testbed.slin8SinkProxy);
+
+ StreamSinkPrx translateSink = alaw2slin8Translator->getSink();
+ StreamSourcePrx translateSource = alaw2slin8Translator->getSource();
+
+ Testbed.alawSourceProxy->addSink(translateSink);
+ Testbed.slin8SinkProxy->setSource(translateSource);
+
+ translateSource->addSink(Testbed.slin8SinkProxy);
+ translateSink->setSource(Testbed.alawSourceProxy);
+
+ //We'll feed a few of the sample frames in.
+ FrameSeq alawFrames(numFramesToTranslate, Testbed.sampleAlawFrame);
+
+ try
+ {
+ Testbed.alawSource->feedFramesToTranslator(alawFrames);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::stringstream str;
+ str << "Exception caught trying to translate alaw frames: " << ex.what();
+ BOOST_FAIL(str.str());
+ }
+
+ //Since everything is synchronous, the Testbed's alawSink should
+ //have frames in it now. We need to make sure that it got
+ //the right number of frames and that the payloads are the
+ //proper size...we can't reliably check for accuracy though.
+ FrameSeq framesWritten = Testbed.slin8Sink->getFrames();
+
+ //There should be an equal number of frames written as was read
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ //Each frame written by the translator should be alaw
+ BOOST_CHECK(SignedLinearPtr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ShortSeqPayloadPtr payload = ShortSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ //Each frame written by the translator should be the
+ //same size as the frame read in.
+ BOOST_CHECK(payload->payload.size() == Testbed.sampleAlawFrameSize);
+ }
+
+ alaw2slin8Translator->destroy();
+}
+
+BOOST_FIXTURE_TEST_CASE(translateSlin8ToAlaw, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+ MediaOperationServiceLocatorParamsPtr slin82AlawParams = createLocatorParams(Testbed.slin8, Testbed.alaw);
+
+ MediaOperationFactoryPrx slin82AlawFactory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slin82AlawParams));
+
+ MediaOperationPrx slin82AlawTranslator =
+ slin82AlawFactory->createMediaOperation(Testbed.slin8SourceProxy, Testbed.alawSinkProxy);
+
+ StreamSinkPrx translateSink = slin82AlawTranslator->getSink();
+ StreamSourcePrx translateSource = slin82AlawTranslator->getSource();
+
+ Testbed.slin8SourceProxy->addSink(translateSink);
+ Testbed.alawSinkProxy->setSource(translateSource);
+
+ translateSource->addSink(Testbed.alawSinkProxy);
+ translateSink->setSource(Testbed.slin8SourceProxy);
+
+ //We'll feed a few of the sample frames in.
+ FrameSeq slin8Frames(numFramesToTranslate, Testbed.sampleSlin8Frame);
+
+ try
+ {
+ Testbed.slin8Source->feedFramesToTranslator(slin8Frames);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::stringstream str;
+ str << "Exception caught trying to translate slin8 frames: " << ex.what();
+ BOOST_FAIL(str.str());
+ }
+
+ //Since everything is synchronous, the Testbed's alawSink should
+ //have frames in it now. We need to make sure that it got
+ //the right number of frames and that the payloads are the
+ //proper size...we can't reliably check for accuracy though.
+ FrameSeq framesWritten = Testbed.alawSink->getFrames();
+
+ //There should be an equal number of frames written as was read
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ //Each frame written by the translator should be alaw
+ BOOST_CHECK(G711aLAWPtr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ByteSeqPayloadPtr payload = ByteSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ //Each frame written by the translator should be the
+ //same size as the frame read in.
+ BOOST_CHECK(payload->payload.size() == Testbed.sampleSlin8FrameSize);
+ }
+
+ slin82AlawTranslator->destroy();
+}
+
BOOST_FIXTURE_TEST_CASE(translateUlawToAlaw, PerTestFixture)
{
size_t numFramesToTranslate = 10;
@@ -606,6 +728,128 @@ BOOST_FIXTURE_TEST_CASE(translateUlawToAlaw, PerTestFixture)
ulaw2alawTranslator->destroy();
}
+BOOST_FIXTURE_TEST_CASE(translateUlawToSlin8, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+ MediaOperationServiceLocatorParamsPtr ulaw2slin8Params = createLocatorParams(Testbed.ulaw, Testbed.slin8);
+
+ MediaOperationFactoryPrx ulaw2slin8Factory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(ulaw2slin8Params));
+
+ MediaOperationPrx ulaw2slin8Translator =
+ ulaw2slin8Factory->createMediaOperation(Testbed.ulawSourceProxy, Testbed.slin8SinkProxy);
+
+ StreamSinkPrx translateSink = ulaw2slin8Translator->getSink();
+ StreamSourcePrx translateSource = ulaw2slin8Translator->getSource();
+
+ Testbed.ulawSourceProxy->addSink(translateSink);
+ Testbed.slin8SinkProxy->setSource(translateSource);
+
+ translateSource->addSink(Testbed.slin8SinkProxy);
+ translateSink->setSource(Testbed.ulawSourceProxy);
+
+ //We'll feed a few of the sample frames in.
+ FrameSeq ulawFrames(numFramesToTranslate, Testbed.sampleUlawFrame);
+
+ try
+ {
+ Testbed.ulawSource->feedFramesToTranslator(ulawFrames);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::stringstream str;
+ str << "Exception caught trying to translate ulaw frames: " << ex.what();
+ BOOST_FAIL(str.str());
+ }
+
+ //Since everything is synchronous, the Testbed's ulawSink should
+ //have frames in it now. We need to make sure that it got
+ //the right number of frames and that the payloads are the
+ //proper size...we can't reliably check for accuracy though.
+ FrameSeq framesWritten = Testbed.slin8Sink->getFrames();
+
+ //There should be an equal number of frames written as was read
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ //Each frame written by the translator should be ulaw
+ BOOST_CHECK(SignedLinearPtr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ShortSeqPayloadPtr payload = ShortSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ //Each frame written by the translator should be the
+ //same size as the frame read in.
+ BOOST_CHECK(payload->payload.size() == Testbed.sampleUlawFrameSize);
+ }
+
+ ulaw2slin8Translator->destroy();
+}
+
+BOOST_FIXTURE_TEST_CASE(translateSlin8ToUlaw, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+ MediaOperationServiceLocatorParamsPtr slin82UlawParams = createLocatorParams(Testbed.slin8, Testbed.ulaw);
+
+ MediaOperationFactoryPrx slin82UlawFactory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slin82UlawParams));
+
+ MediaOperationPrx slin82UlawTranslator =
+ slin82UlawFactory->createMediaOperation(Testbed.slin8SourceProxy, Testbed.ulawSinkProxy);
+
+ StreamSinkPrx translateSink = slin82UlawTranslator->getSink();
+ StreamSourcePrx translateSource = slin82UlawTranslator->getSource();
+
+ Testbed.slin8SourceProxy->addSink(translateSink);
+ Testbed.ulawSinkProxy->setSource(translateSource);
+
+ translateSource->addSink(Testbed.ulawSinkProxy);
+ translateSink->setSource(Testbed.slin8SourceProxy);
+
+ //We'll feed a few of the sample frames in.
+ FrameSeq slin8Frames(numFramesToTranslate, Testbed.sampleSlin8Frame);
+
+ try
+ {
+ Testbed.slin8Source->feedFramesToTranslator(slin8Frames);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::stringstream str;
+ str << "Exception caught trying to translate slin8 frames: " << ex.what();
+ BOOST_FAIL(str.str());
+ }
+
+ //Since everything is synchronous, the Testbed's ulawSink should
+ //have frames in it now. We need to make sure that it got
+ //the right number of frames and that the payloads are the
+ //proper size...we can't reliably check for accuracy though.
+ FrameSeq framesWritten = Testbed.ulawSink->getFrames();
+
+ //There should be an equal number of frames written as was read
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ //Each frame written by the translator should be ulaw
+ BOOST_CHECK(G711uLAWPtr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ByteSeqPayloadPtr payload = ByteSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ //Each frame written by the translator should be the
+ //same size as the frame read in.
+ BOOST_CHECK(payload->payload.size() == Testbed.sampleSlin8FrameSize);
+ }
+
+ slin82UlawTranslator->destroy();
+}
+
BOOST_FIXTURE_TEST_CASE(resample8To16, PerTestFixture)
{
size_t numFramesToTranslate = 10;
-----------------------------------------------------------------------
--
asterisk-scf/integration/media_operations_core.git
More information about the asterisk-scf-commits
mailing list